Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions packages/cli/src/commands/adf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,27 @@ Do not duplicate rules from .ai/ modules into this file or other agent config fi
function adfInit(options: CLIOptions, args: string[]): number {
const force = options.yes || args.includes('--force');
const aiDir = getFlag(args, '--ai-dir') || '.ai';
const moduleFlag = getFlag(args, '--module');
const manifestPath = path.join(aiDir, 'manifest.adf');

// --module: additive single-module creation — delegate to adf create
if (moduleFlag) {
if (!fs.existsSync(manifestPath)) {
throw new CLIError(
`manifest.adf not found at ${manifestPath}. Run 'charter adf init' first to scaffold .ai/.`
);
}
return adfCreate(options, [moduleFlag, '--ai-dir', aiDir]);
}

if (fs.existsSync(manifestPath) && !force) {
const result: AdfInitResult = { created: false, aiDir, files: [] };
if (options.format === 'json') {
console.log(JSON.stringify({ ...result, nextActions: ['charter adf fmt .ai/core.adf --check', 'charter adf bundle --task "<prompt>"'] }, null, 2));
} else {
console.log(` .ai/ already exists at ${aiDir}/`);
console.log(' Use --force (or --yes) to overwrite.');
console.log(' To add a single module: charter adf init --module <name>');
}
return EXIT_CODE.SUCCESS;
}
Expand Down Expand Up @@ -495,6 +507,7 @@ function printHelp(): void {
console.log(' Usage:');
console.log(' charter adf init [--ai-dir <dir>] [--force] [--emit-pointers]');
console.log(' Scaffold .ai/ directory with manifest, core, and state modules.');
console.log(' --module <name>: add a single module to an existing .ai/ (additive, no overwrite)');
console.log(' --emit-pointers: also generate thin pointer files (CLAUDE.md, .cursorrules, agents.md)');
console.log('');
console.log(' charter adf fmt <file> [--check] [--write]');
Expand Down