Skip to content

Commit b85f39a

Browse files
chore: update eslint logic and finalize premium dark dashboard
1 parent 19482c9 commit b85f39a

1,242 files changed

Lines changed: 432336 additions & 1331 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.aiox-core/cli/commands/config/index.js

Lines changed: 607 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
/**
2+
* Generate Command
3+
*
4+
* CLI command for generating documents using the Template Engine.
5+
* Supports: prd, adr, pmdr, dbdr, story, epic, task
6+
*
7+
* @module cli/commands/generate
8+
* @version 1.0.0
9+
* @story 3.9 - Template PMDR (AC3.9.8)
10+
*/
11+
12+
'use strict';
13+
14+
const { Command } = require('commander');
15+
const path = require('path');
16+
17+
// Lazy load TemplateEngine to avoid startup overhead
18+
let TemplateEngine = null;
19+
20+
/**
21+
* Get TemplateEngine instance (lazy loaded)
22+
* @returns {Object} TemplateEngine class
23+
*/
24+
function getTemplateEngine() {
25+
if (!TemplateEngine) {
26+
const enginePath = path.join(__dirname, '..', '..', '..', 'product', 'templates', 'engine');
27+
const engine = require(enginePath);
28+
TemplateEngine = engine.TemplateEngine;
29+
}
30+
return TemplateEngine;
31+
}
32+
33+
/**
34+
* Generate a document from template
35+
* @param {string} templateType - Template type (prd, adr, pmdr, etc.)
36+
* @param {Object} options - Command options
37+
*/
38+
async function generateDocument(templateType, options) {
39+
const Engine = getTemplateEngine();
40+
41+
const engine = new Engine({
42+
interactive: !options.nonInteractive,
43+
baseDir: options.baseDir || process.cwd(),
44+
});
45+
46+
// Validate template type
47+
if (!engine.supportedTypes.includes(templateType)) {
48+
console.error(`❌ Unsupported template type: ${templateType}`);
49+
console.log(`\nSupported types: ${engine.supportedTypes.join(', ')}`);
50+
process.exit(1);
51+
}
52+
53+
try {
54+
console.log(`\n📝 Generating ${templateType.toUpperCase()} document...\n`);
55+
56+
// Build context from options
57+
const context = {};
58+
if (options.title) context.title = options.title;
59+
if (options.number) context.number = parseInt(options.number, 10);
60+
if (options.status) context.status = options.status;
61+
if (options.owner) context.owner = options.owner;
62+
63+
// Generate document
64+
const result = await engine.generate(templateType, context, {
65+
validate: !options.skipValidation,
66+
save: options.save,
67+
outputPath: options.output,
68+
});
69+
70+
// Output result
71+
if (options.save && result.savedTo) {
72+
console.log(`\n✅ Document saved to: ${result.savedTo}`);
73+
} else if (!options.save) {
74+
console.log('\n--- Generated Document ---\n');
75+
console.log(result.content);
76+
console.log('\n--- End Document ---\n');
77+
}
78+
79+
// Show validation warnings
80+
if (result.validation && !result.validation.isValid) {
81+
console.warn('\n⚠️ Validation warnings:');
82+
result.validation.errors.forEach(err => console.warn(` - ${err}`));
83+
}
84+
85+
// Show metadata
86+
if (options.verbose) {
87+
console.log('\n📊 Metadata:');
88+
console.log(` Template: ${result.templateType}`);
89+
console.log(` Generated: ${result.generatedAt}`);
90+
if (result.savedTo) console.log(` Saved to: ${result.savedTo}`);
91+
}
92+
93+
} catch (error) {
94+
console.error(`\n❌ Generation failed: ${error.message}`);
95+
if (options.verbose) {
96+
console.error('\nStack trace:', error.stack);
97+
}
98+
process.exit(1);
99+
}
100+
}
101+
102+
/**
103+
* List available templates
104+
* @param {Object} options - Command options
105+
*/
106+
async function listTemplates(options) {
107+
const Engine = getTemplateEngine();
108+
const engine = new Engine({ interactive: false });
109+
110+
try {
111+
const templates = await engine.listTemplates();
112+
113+
console.log('\n📋 Available Templates:\n');
114+
115+
if (options.json) {
116+
console.log(JSON.stringify(templates, null, 2));
117+
} else {
118+
templates.forEach(t => {
119+
const status = t.status === 'missing' ? '⚠️ (missing)' : '✅';
120+
console.log(` ${status} ${t.type.padEnd(10)} - ${t.name} v${t.version}`);
121+
122+
if (options.verbose && t.variables.length > 0) {
123+
console.log(' Variables:');
124+
t.variables.forEach(v => {
125+
const req = v.required ? '*' : ' ';
126+
console.log(` ${req}${v.name} (${v.type})`);
127+
});
128+
}
129+
});
130+
}
131+
132+
console.log('');
133+
} catch (error) {
134+
console.error(`❌ Error listing templates: ${error.message}`);
135+
process.exit(1);
136+
}
137+
}
138+
139+
/**
140+
* Show template info
141+
* @param {string} templateType - Template type
142+
* @param {Object} options - Command options
143+
*/
144+
async function showTemplateInfo(templateType, options) {
145+
const Engine = getTemplateEngine();
146+
const engine = new Engine({ interactive: false });
147+
148+
try {
149+
const info = await engine.getTemplateInfo(templateType);
150+
151+
if (options.json) {
152+
console.log(JSON.stringify(info, null, 2));
153+
} else {
154+
console.log(`\n📝 Template: ${info.name}`);
155+
console.log(` Type: ${info.type}`);
156+
console.log(` Version: ${info.version}`);
157+
console.log('\n Variables:');
158+
info.variables.forEach(v => {
159+
const req = v.required ? '(required)' : '(optional)';
160+
console.log(` - ${v.name}: ${v.type} ${req}`);
161+
if (v.description) console.log(` ${v.description}`);
162+
});
163+
console.log('');
164+
}
165+
} catch (error) {
166+
console.error(`❌ Error getting template info: ${error.message}`);
167+
process.exit(1);
168+
}
169+
}
170+
171+
/**
172+
* Create the generate command
173+
* @returns {Command} Commander command instance
174+
*/
175+
function createGenerateCommand() {
176+
const generate = new Command('generate')
177+
.description('Generate documents from templates (prd, adr, pmdr, dbdr, story, epic, task)')
178+
.argument('[type]', 'Template type to generate')
179+
.option('-t, --title <title>', 'Document title')
180+
.option('-n, --number <number>', 'Document number')
181+
.option('-s, --status <status>', 'Initial status')
182+
.option('-o, --owner <owner>', 'Document owner')
183+
.option('--output <path>', 'Output file path')
184+
.option('--save', 'Save to file (default location if --output not specified)')
185+
.option('--non-interactive', 'Disable interactive prompts')
186+
.option('--skip-validation', 'Skip schema validation')
187+
.option('--base-dir <dir>', 'Base directory for paths')
188+
.option('-v, --verbose', 'Show detailed output')
189+
.option('--json', 'Output as JSON')
190+
.action(async (type, options) => {
191+
if (!type) {
192+
// No type specified - show help
193+
generate.help();
194+
return;
195+
}
196+
await generateDocument(type, options);
197+
});
198+
199+
// Add list subcommand
200+
generate
201+
.command('list')
202+
.description('List available templates')
203+
.option('-v, --verbose', 'Show variable details')
204+
.option('--json', 'Output as JSON')
205+
.action(listTemplates);
206+
207+
// Add info subcommand
208+
generate
209+
.command('info <type>')
210+
.description('Show template information')
211+
.option('--json', 'Output as JSON')
212+
.action(showTemplateInfo);
213+
214+
return generate;
215+
}
216+
217+
module.exports = {
218+
createGenerateCommand,
219+
generateDocument,
220+
listTemplates,
221+
showTemplateInfo,
222+
};
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/**
2+
* Manifest Command Module
3+
*
4+
* Entry point for all manifest-related CLI commands.
5+
* Includes validate and regenerate subcommands.
6+
*
7+
* @module cli/commands/manifest
8+
* @version 1.0.0
9+
* @story 2.13 - Manifest System
10+
*/
11+
12+
const { Command } = require('commander');
13+
const { createValidateCommand } = require('./validate');
14+
const { createRegenerateCommand } = require('./regenerate');
15+
16+
/**
17+
* Create the manifest command with all subcommands
18+
* @returns {Command} Commander command instance
19+
*/
20+
function createManifestCommand() {
21+
const manifest = new Command('manifest');
22+
23+
manifest
24+
.description('Manage AIOX manifest files for agents, workers, and tasks')
25+
.addHelpText('after', `
26+
Commands:
27+
validate Validate all manifest files
28+
regenerate Regenerate manifests from source files
29+
30+
Examples:
31+
$ aiox manifest validate
32+
$ aiox manifest validate --verbose
33+
$ aiox manifest regenerate
34+
$ aiox manifest regenerate --force
35+
`);
36+
37+
// Add subcommands
38+
manifest.addCommand(createValidateCommand());
39+
manifest.addCommand(createRegenerateCommand());
40+
41+
return manifest;
42+
}
43+
44+
module.exports = {
45+
createManifestCommand,
46+
};
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/**
2+
* Manifest Regenerate Command
3+
*
4+
* CLI command to regenerate all manifest files from source.
5+
*
6+
* @module cli/commands/manifest/regenerate
7+
* @version 1.0.0
8+
* @story 2.13 - Manifest System
9+
*/
10+
11+
const { Command } = require('commander');
12+
const path = require('path');
13+
const { createManifestGenerator } = require('../../../core/manifest/manifest-generator');
14+
15+
/**
16+
* Create the regenerate subcommand
17+
* @returns {Command} Commander command instance
18+
*/
19+
function createRegenerateCommand() {
20+
const regenerate = new Command('regenerate');
21+
22+
regenerate
23+
.description('Regenerate all manifest files from source files')
24+
.option('-f, --force', 'Force regeneration even if manifests exist')
25+
.option('--json', 'Output results as JSON')
26+
.option('--dry-run', 'Show what would be generated without writing files')
27+
.action(async (options) => {
28+
try {
29+
const generator = createManifestGenerator({
30+
basePath: process.cwd(),
31+
});
32+
33+
if (!options.dryRun) {
34+
console.log('Scanning .aiox-core/...\n');
35+
} else {
36+
console.log('[DRY RUN] Would generate:\n');
37+
}
38+
39+
const results = await generator.generateAll();
40+
41+
if (options.json) {
42+
console.log(JSON.stringify(results, null, 2));
43+
return;
44+
}
45+
46+
// Format output
47+
const formatResult = (name, result) => {
48+
if (result.success) {
49+
const verb = options.dryRun ? 'Would generate' : 'Generated';
50+
console.log(`✓ ${verb} ${name}.csv (${result.count} entries)`);
51+
if (result.errors.length > 0) {
52+
result.errors.forEach(e => console.log(` ⚠ ${e}`));
53+
}
54+
} else {
55+
console.log(`✗ Failed to generate ${name}.csv`);
56+
result.errors.forEach(e => console.log(` ✗ ${e}`));
57+
}
58+
};
59+
60+
formatResult('agents', results.agents);
61+
formatResult('workers', results.workers);
62+
formatResult('tasks', results.tasks);
63+
64+
console.log('');
65+
66+
if (results.errors.length > 0) {
67+
console.log('❌ Errors during generation:');
68+
results.errors.forEach(e => console.log(` ✗ ${e}`));
69+
process.exit(1);
70+
}
71+
72+
const allSuccess = results.agents.success &&
73+
results.workers.success &&
74+
results.tasks.success;
75+
76+
if (allSuccess) {
77+
const verb = options.dryRun ? 'Would be generated' : 'regenerated';
78+
console.log(`✅ Manifests ${verb}!`);
79+
console.log(` Duration: ${results.duration}ms`);
80+
} else {
81+
console.log('❌ Some manifests failed to generate');
82+
process.exit(1);
83+
}
84+
85+
} catch (error) {
86+
console.error(`Error: ${error.message}`);
87+
process.exit(1);
88+
}
89+
});
90+
91+
return regenerate;
92+
}
93+
94+
module.exports = {
95+
createRegenerateCommand,
96+
};

0 commit comments

Comments
 (0)