@agentic-sdlc-kit/cli 0.0.0-stage → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +32 -2
- package/dist/application/agent/execution-store.d.ts +55 -0
- package/dist/application/agent/execution-store.d.ts.map +1 -0
- package/dist/application/agent/execution-store.js +90 -0
- package/dist/application/agent/execution-store.js.map +1 -0
- package/dist/application/agent/gateway.d.ts +74 -0
- package/dist/application/agent/gateway.d.ts.map +1 -0
- package/dist/application/agent/gateway.js +580 -0
- package/dist/application/agent/gateway.js.map +1 -0
- package/dist/application/agent/index.d.ts +6 -0
- package/dist/application/agent/index.d.ts.map +1 -0
- package/dist/application/agent/index.js +18 -0
- package/dist/application/agent/index.js.map +1 -0
- package/dist/application/agent/orchestrator.d.ts +76 -0
- package/dist/application/agent/orchestrator.d.ts.map +1 -0
- package/dist/application/agent/orchestrator.js +422 -0
- package/dist/application/agent/orchestrator.js.map +1 -0
- package/dist/application/agent/providers/claude-code/claude-argv.d.ts +15 -0
- package/dist/application/agent/providers/claude-code/claude-argv.d.ts.map +1 -0
- package/dist/application/agent/providers/claude-code/claude-argv.js +98 -0
- package/dist/application/agent/providers/claude-code/claude-argv.js.map +1 -0
- package/dist/application/agent/providers/claude-code/index.d.ts +7 -0
- package/dist/application/agent/providers/claude-code/index.d.ts.map +1 -0
- package/dist/application/agent/providers/claude-code/index.js +13 -0
- package/dist/application/agent/providers/claude-code/index.js.map +1 -0
- package/dist/application/agent/providers/claude-code/mod-parity.d.ts +15 -0
- package/dist/application/agent/providers/claude-code/mod-parity.d.ts.map +1 -0
- package/dist/application/agent/providers/claude-code/mod-parity.js +41 -0
- package/dist/application/agent/providers/claude-code/mod-parity.js.map +1 -0
- package/dist/application/agent/providers/claude-code/permission-config.d.ts +59 -0
- package/dist/application/agent/providers/claude-code/permission-config.d.ts.map +1 -0
- package/dist/application/agent/providers/claude-code/permission-config.js +189 -0
- package/dist/application/agent/providers/claude-code/permission-config.js.map +1 -0
- package/dist/application/agent/providers/claude-code/provider.d.ts +38 -0
- package/dist/application/agent/providers/claude-code/provider.d.ts.map +1 -0
- package/dist/application/agent/providers/claude-code/provider.js +577 -0
- package/dist/application/agent/providers/claude-code/provider.js.map +1 -0
- package/dist/application/agent/providers/claude-code/resume-store.d.ts +25 -0
- package/dist/application/agent/providers/claude-code/resume-store.d.ts.map +1 -0
- package/dist/application/agent/providers/claude-code/resume-store.js +120 -0
- package/dist/application/agent/providers/claude-code/resume-store.js.map +1 -0
- package/dist/application/agent/providers/claude-code/stream-parser.d.ts +50 -0
- package/dist/application/agent/providers/claude-code/stream-parser.d.ts.map +1 -0
- package/dist/application/agent/providers/claude-code/stream-parser.js +129 -0
- package/dist/application/agent/providers/claude-code/stream-parser.js.map +1 -0
- package/dist/application/agent/test-fixture.d.ts +15 -0
- package/dist/application/agent/test-fixture.d.ts.map +1 -0
- package/dist/application/agent/test-fixture.js +93 -0
- package/dist/application/agent/test-fixture.js.map +1 -0
- package/dist/application/agent/workspace.d.ts +24 -0
- package/dist/application/agent/workspace.d.ts.map +1 -0
- package/dist/application/agent/workspace.js +139 -0
- package/dist/application/agent/workspace.js.map +1 -0
- package/dist/application/dispatcher.d.ts +13 -0
- package/dist/application/dispatcher.d.ts.map +1 -0
- package/dist/application/dispatcher.js +104 -0
- package/dist/application/dispatcher.js.map +1 -0
- package/dist/application/index.d.ts +5 -0
- package/dist/application/index.d.ts.map +1 -0
- package/dist/application/index.js +6 -0
- package/dist/application/index.js.map +1 -0
- package/dist/application/registry.d.ts +8 -0
- package/dist/application/registry.d.ts.map +1 -0
- package/dist/application/registry.js +17 -0
- package/dist/application/registry.js.map +1 -0
- package/dist/application/version.d.ts +2 -0
- package/dist/application/version.d.ts.map +1 -0
- package/dist/application/version.js +7 -0
- package/dist/application/version.js.map +1 -0
- package/dist/commands/doctor.d.ts +3 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +68 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/elicit.d.ts +3 -0
- package/dist/commands/elicit.d.ts.map +1 -0
- package/dist/commands/elicit.js +163 -0
- package/dist/commands/elicit.js.map +1 -0
- package/dist/commands/evolve.d.ts +3 -0
- package/dist/commands/evolve.d.ts.map +1 -0
- package/dist/commands/evolve.js +165 -0
- package/dist/commands/evolve.js.map +1 -0
- package/dist/commands/feature.d.ts +13 -0
- package/dist/commands/feature.d.ts.map +1 -0
- package/dist/commands/feature.js +326 -0
- package/dist/commands/feature.js.map +1 -0
- package/dist/commands/fix.d.ts +3 -0
- package/dist/commands/fix.d.ts.map +1 -0
- package/dist/commands/fix.js +61 -0
- package/dist/commands/fix.js.map +1 -0
- package/dist/commands/help.d.ts +4 -0
- package/dist/commands/help.d.ts.map +1 -0
- package/dist/commands/help.js +32 -0
- package/dist/commands/help.js.map +1 -0
- package/dist/commands/index.d.ts +21 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +22 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/init.d.ts +3 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +90 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/inspect.d.ts +3 -0
- package/dist/commands/inspect.d.ts.map +1 -0
- package/dist/commands/inspect.js +64 -0
- package/dist/commands/inspect.js.map +1 -0
- package/dist/commands/install.d.ts +3 -0
- package/dist/commands/install.d.ts.map +1 -0
- package/dist/commands/install.js +329 -0
- package/dist/commands/install.js.map +1 -0
- package/dist/commands/journal.d.ts +3 -0
- package/dist/commands/journal.d.ts.map +1 -0
- package/dist/commands/journal.js +107 -0
- package/dist/commands/journal.js.map +1 -0
- package/dist/commands/memory.d.ts +3 -0
- package/dist/commands/memory.d.ts.map +1 -0
- package/dist/commands/memory.js +85 -0
- package/dist/commands/memory.js.map +1 -0
- package/dist/commands/new.d.ts +3 -0
- package/dist/commands/new.d.ts.map +1 -0
- package/dist/commands/new.js +68 -0
- package/dist/commands/new.js.map +1 -0
- package/dist/commands/next.d.ts +3 -0
- package/dist/commands/next.d.ts.map +1 -0
- package/dist/commands/next.js +107 -0
- package/dist/commands/next.js.map +1 -0
- package/dist/commands/optimize.d.ts +3 -0
- package/dist/commands/optimize.d.ts.map +1 -0
- package/dist/commands/optimize.js +28 -0
- package/dist/commands/optimize.js.map +1 -0
- package/dist/commands/plugin-linker.d.ts +34 -0
- package/dist/commands/plugin-linker.d.ts.map +1 -0
- package/dist/commands/plugin-linker.js +177 -0
- package/dist/commands/plugin-linker.js.map +1 -0
- package/dist/commands/refactor.d.ts +3 -0
- package/dist/commands/refactor.d.ts.map +1 -0
- package/dist/commands/refactor.js +32 -0
- package/dist/commands/refactor.js.map +1 -0
- package/dist/commands/types.d.ts +19 -0
- package/dist/commands/types.d.ts.map +1 -0
- package/dist/commands/types.js +7 -0
- package/dist/commands/types.js.map +1 -0
- package/dist/commands/validate-plan.d.ts +3 -0
- package/dist/commands/validate-plan.d.ts.map +1 -0
- package/dist/commands/validate-plan.js +62 -0
- package/dist/commands/validate-plan.js.map +1 -0
- package/dist/commands/validate-spec.d.ts +3 -0
- package/dist/commands/validate-spec.d.ts.map +1 -0
- package/dist/commands/validate-spec.js +62 -0
- package/dist/commands/validate-spec.js.map +1 -0
- package/dist/commands/verify.d.ts +3 -0
- package/dist/commands/verify.d.ts.map +1 -0
- package/dist/commands/verify.js +103 -0
- package/dist/commands/verify.js.map +1 -0
- package/dist/commands/version.d.ts +3 -0
- package/dist/commands/version.d.ts.map +1 -0
- package/dist/commands/version.js +12 -0
- package/dist/commands/version.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/output/formatter.d.ts +2 -0
- package/dist/output/formatter.d.ts.map +1 -0
- package/dist/output/formatter.js +10 -0
- package/dist/output/formatter.js.map +1 -0
- package/dist/output/index.d.ts +2 -0
- package/dist/output/index.d.ts.map +1 -0
- package/dist/output/index.js +3 -0
- package/dist/output/index.js.map +1 -0
- package/package.json +37 -3
- package/src/application/agent/execution-store.ts +162 -0
- package/src/application/agent/gateway.test.ts +529 -0
- package/src/application/agent/gateway.ts +744 -0
- package/src/application/agent/index.ts +18 -0
- package/src/application/agent/orchestrator.test.ts +341 -0
- package/src/application/agent/orchestrator.ts +628 -0
- package/src/application/agent/providers/claude-code/claude-argv.ts +119 -0
- package/src/application/agent/providers/claude-code/claude-code-smoke.test.ts +139 -0
- package/src/application/agent/providers/claude-code/fixtures/fake-claude.mjs +125 -0
- package/src/application/agent/providers/claude-code/index.ts +28 -0
- package/src/application/agent/providers/claude-code/mod-parity.ts +50 -0
- package/src/application/agent/providers/claude-code/permission-config.test.ts +221 -0
- package/src/application/agent/providers/claude-code/permission-config.ts +242 -0
- package/src/application/agent/providers/claude-code/provider.test.ts +378 -0
- package/src/application/agent/providers/claude-code/provider.ts +717 -0
- package/src/application/agent/providers/claude-code/resume-store.test.ts +161 -0
- package/src/application/agent/providers/claude-code/resume-store.ts +157 -0
- package/src/application/agent/providers/claude-code/stream-parser.ts +166 -0
- package/src/application/agent/test-fixture.ts +131 -0
- package/src/application/agent/workspace.test.ts +104 -0
- package/src/application/agent/workspace.ts +156 -0
- package/src/application/dispatcher.test.ts +89 -0
- package/src/application/dispatcher.ts +98 -0
- package/src/application/index.ts +5 -0
- package/src/application/registry.ts +24 -0
- package/src/application/version.ts +7 -0
- package/src/commands/clse.test.ts +181 -0
- package/src/commands/doctor.test.ts +29 -0
- package/src/commands/doctor.ts +78 -0
- package/src/commands/elicit.test.ts +111 -0
- package/src/commands/elicit.ts +188 -0
- package/src/commands/evolve.ts +209 -0
- package/src/commands/feature.test.ts +323 -0
- package/src/commands/feature.ts +405 -0
- package/src/commands/fix.test.ts +36 -0
- package/src/commands/fix.ts +69 -0
- package/src/commands/help.test.ts +33 -0
- package/src/commands/help.ts +35 -0
- package/src/commands/index.ts +21 -0
- package/src/commands/init.test.ts +65 -0
- package/src/commands/init.ts +103 -0
- package/src/commands/inspect.test.ts +57 -0
- package/src/commands/inspect.ts +73 -0
- package/src/commands/install.test.ts +61 -0
- package/src/commands/install.ts +375 -0
- package/src/commands/journal.ts +118 -0
- package/src/commands/memory.ts +96 -0
- package/src/commands/new.test.ts +44 -0
- package/src/commands/new.ts +77 -0
- package/src/commands/next.test.ts +241 -0
- package/src/commands/next.ts +124 -0
- package/src/commands/optimize.ts +30 -0
- package/src/commands/plugin-linker.test.ts +139 -0
- package/src/commands/plugin-linker.ts +196 -0
- package/src/commands/refactor.ts +34 -0
- package/src/commands/stack-commands.test.ts +67 -0
- package/src/commands/tier-c-conformance.test.ts +194 -0
- package/src/commands/types.ts +26 -0
- package/src/commands/validate-plan.test.ts +107 -0
- package/src/commands/validate-plan.ts +67 -0
- package/src/commands/validate-spec.test.ts +59 -0
- package/src/commands/validate-spec.ts +68 -0
- package/src/commands/verify.test.ts +117 -0
- package/src/commands/verify.ts +112 -0
- package/src/commands/version.test.ts +11 -0
- package/src/commands/version.ts +14 -0
- package/src/index.ts +30 -0
- package/src/output/formatter.ts +10 -0
- package/src/output/index.ts +2 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// packages/cli/src/commands/init.ts
|
|
2
|
+
//
|
|
3
|
+
// `kit init [path] [--force] [--json]`.
|
|
4
|
+
// Initializes the Agentic SDLC Kit configuration (.ai-kit/project.yml).
|
|
5
|
+
|
|
6
|
+
import { promises as fs } from 'node:fs';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import { FileSystemRepositoryScanner, generateProfile, writeProfile } from '@agentic-sdlc-kit/core';
|
|
9
|
+
import type { ProjectProfile } from '@agentic-sdlc-kit/contracts';
|
|
10
|
+
import type { Command, CommandContext, CommandResult } from './types.js';
|
|
11
|
+
|
|
12
|
+
export const initCommand: Command = {
|
|
13
|
+
name: 'init',
|
|
14
|
+
summary: 'Initialize the Agentic SDLC Kit profile (.ai-kit/project.yml) for a repository.',
|
|
15
|
+
async run(ctx: CommandContext): Promise<CommandResult> {
|
|
16
|
+
if (ctx.argv.includes('--help') || ctx.argv.includes('-h')) {
|
|
17
|
+
ctx.stdout(formatHelp());
|
|
18
|
+
return { exitCode: 0 };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const isJson = ctx.argv.includes('--json');
|
|
22
|
+
const isForce = ctx.argv.includes('--force') || ctx.argv.includes('-f');
|
|
23
|
+
const targetArg = ctx.argv.find((a) => !a.startsWith('-'));
|
|
24
|
+
const targetRoot = path.resolve(ctx.cwd, targetArg ?? '.');
|
|
25
|
+
|
|
26
|
+
const configPath = path.join(targetRoot, '.ai-kit', 'project.yml');
|
|
27
|
+
if (!isForce && (await fileExists(configPath))) {
|
|
28
|
+
ctx.stderr('kit init: .ai-kit/project.yml already exists (use --force to overwrite)\n');
|
|
29
|
+
return { exitCode: 1, message: 'project profile already exists' };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const scanner = new FileSystemRepositoryScanner();
|
|
33
|
+
const scanRes = await scanner.scan(targetRoot);
|
|
34
|
+
if (!scanRes.ok) {
|
|
35
|
+
ctx.stderr(`kit init: discovery failed: ${scanRes.error.message}\n`);
|
|
36
|
+
return { exitCode: 1, message: scanRes.error.message };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const profileRes = generateProfile(scanRes.value);
|
|
40
|
+
if (!profileRes.ok) {
|
|
41
|
+
ctx.stderr(`kit init: profile generation failed: ${profileRes.error.message}\n`);
|
|
42
|
+
return { exitCode: 1, message: profileRes.error.message };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const profile = profileRes.value;
|
|
46
|
+
const writeRes = await writeProfile(targetRoot, profile);
|
|
47
|
+
if (!writeRes.ok) {
|
|
48
|
+
ctx.stderr(`kit init: write failed: ${writeRes.error.message}\n`);
|
|
49
|
+
return { exitCode: 1, message: writeRes.error.message };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
await ensureDirectories(targetRoot);
|
|
53
|
+
|
|
54
|
+
if (isJson) {
|
|
55
|
+
ctx.stdout(JSON.stringify(profile, null, 2) + '\n');
|
|
56
|
+
} else {
|
|
57
|
+
ctx.stdout(formatOutput(targetRoot, profile));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return { exitCode: 0 };
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
async function fileExists(p: string): Promise<boolean> {
|
|
65
|
+
try {
|
|
66
|
+
const s = await fs.stat(p);
|
|
67
|
+
return s.isFile();
|
|
68
|
+
} catch {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
async function ensureDirectories(root: string): Promise<void> {
|
|
74
|
+
await fs.mkdir(path.join(root, '.ai-kit', 'state'), { recursive: true });
|
|
75
|
+
await fs.mkdir(path.join(root, '.ai-kit', 'reports'), { recursive: true });
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function formatOutput(root: string, profile: ProjectProfile): string {
|
|
79
|
+
const lines: string[] = [
|
|
80
|
+
`Initialized Agentic SDLC Kit profile for '${profile.name}':`,
|
|
81
|
+
` Stack: ${profile.stack.join(', ')}`,
|
|
82
|
+
` Commands: ${Object.keys(profile.commands).join(', ') || '(none)'}`,
|
|
83
|
+
` Config: ${path.join(root, '.ai-kit', 'project.yml')}`,
|
|
84
|
+
'',
|
|
85
|
+
"Next: Run 'kit inspect' to verify repository information.",
|
|
86
|
+
'',
|
|
87
|
+
];
|
|
88
|
+
return lines.join('\n');
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function formatHelp(): string {
|
|
92
|
+
return [
|
|
93
|
+
'Usage: kit init [path] [--force] [--json]',
|
|
94
|
+
'',
|
|
95
|
+
'Inspect a repository and generate .ai-kit/project.yml configuration.',
|
|
96
|
+
'',
|
|
97
|
+
'Options:',
|
|
98
|
+
' --force, -f Overwrite existing .ai-kit/project.yml',
|
|
99
|
+
' --json Output generated profile as JSON',
|
|
100
|
+
' -h, --help Show this help message',
|
|
101
|
+
'',
|
|
102
|
+
].join('\n');
|
|
103
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// packages/cli/src/commands/inspect.test.ts
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { describe, expect, it } from 'vitest';
|
|
4
|
+
import { inspectCommand } from './inspect.js';
|
|
5
|
+
import type { CommandContext } from './types.js';
|
|
6
|
+
|
|
7
|
+
const FIXTURE_ROOT = path.resolve(
|
|
8
|
+
new URL('../../../../fixtures/fixture-node-fullstack', import.meta.url).pathname,
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
const makeCtx = (argv: string[]): CommandContext & { out: string[]; err: string[] } => {
|
|
12
|
+
const out: string[] = [];
|
|
13
|
+
const err: string[] = [];
|
|
14
|
+
return {
|
|
15
|
+
argv,
|
|
16
|
+
cwd: FIXTURE_ROOT,
|
|
17
|
+
stdout: (s) => void out.push(s),
|
|
18
|
+
stderr: (s) => void err.push(s),
|
|
19
|
+
out,
|
|
20
|
+
err,
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
describe('inspectCommand', () => {
|
|
25
|
+
it('shows help when --help is passed', async () => {
|
|
26
|
+
const ctx = makeCtx(['--help']);
|
|
27
|
+
const r = await inspectCommand.run(ctx);
|
|
28
|
+
expect(r.exitCode).toBe(0);
|
|
29
|
+
expect(ctx.out[0]).toContain('Usage: kit inspect');
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('inspects fixture repository and prints summary', async () => {
|
|
33
|
+
const ctx = makeCtx([]);
|
|
34
|
+
const r = await inspectCommand.run(ctx);
|
|
35
|
+
expect(r.exitCode).toBe(0);
|
|
36
|
+
const text = ctx.out[0] ?? '';
|
|
37
|
+
expect(text).toContain('Repository:');
|
|
38
|
+
expect(text).toContain('node');
|
|
39
|
+
expect(text).toContain('node:test');
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('emits valid JSON when --json flag is passed', async () => {
|
|
43
|
+
const ctx = makeCtx(['--json']);
|
|
44
|
+
const r = await inspectCommand.run(ctx);
|
|
45
|
+
expect(r.exitCode).toBe(0);
|
|
46
|
+
const parsed = JSON.parse(ctx.out[0] ?? '{}');
|
|
47
|
+
expect(parsed.detectedStacks).toContain('node');
|
|
48
|
+
expect(parsed.testFrameworks).toContain('node:test');
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('fails when target path does not exist', async () => {
|
|
52
|
+
const ctx = makeCtx(['/non/existent/repo/path/xyz']);
|
|
53
|
+
const r = await inspectCommand.run(ctx);
|
|
54
|
+
expect(r.exitCode).toBe(1);
|
|
55
|
+
expect(ctx.err[0]).toContain('kit inspect: error:');
|
|
56
|
+
});
|
|
57
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// packages/cli/src/commands/inspect.ts
|
|
2
|
+
//
|
|
3
|
+
// `kit inspect [path] [--json]`.
|
|
4
|
+
// Read-only inspection of target repository stacks, conventions, and git state.
|
|
5
|
+
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import { FileSystemRepositoryScanner } from '@agentic-sdlc-kit/core';
|
|
8
|
+
import type { RepositoryScan } from '@agentic-sdlc-kit/contracts';
|
|
9
|
+
import type { Command, CommandContext, CommandResult } from './types.js';
|
|
10
|
+
|
|
11
|
+
export const inspectCommand: Command = {
|
|
12
|
+
name: 'inspect',
|
|
13
|
+
summary:
|
|
14
|
+
'Inspect a repository and report detected stacks, frameworks, and conventions (read-only).',
|
|
15
|
+
async run(ctx: CommandContext): Promise<CommandResult> {
|
|
16
|
+
if (ctx.argv.includes('--help') || ctx.argv.includes('-h')) {
|
|
17
|
+
ctx.stdout(formatHelp());
|
|
18
|
+
return { exitCode: 0 };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const isJson = ctx.argv.includes('--json');
|
|
22
|
+
const targetArg = ctx.argv.find((a) => !a.startsWith('-'));
|
|
23
|
+
const targetRoot = path.resolve(ctx.cwd, targetArg ?? '.');
|
|
24
|
+
|
|
25
|
+
const scanner = new FileSystemRepositoryScanner();
|
|
26
|
+
const res = await scanner.scan(targetRoot);
|
|
27
|
+
if (!res.ok) {
|
|
28
|
+
ctx.stderr(`kit inspect: error: ${res.error.message}\n`);
|
|
29
|
+
return { exitCode: 1, message: res.error.message };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (isJson) {
|
|
33
|
+
ctx.stdout(JSON.stringify(res.value, null, 2) + '\n');
|
|
34
|
+
} else {
|
|
35
|
+
ctx.stdout(formatSummary(res.value));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return { exitCode: 0 };
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
function formatSummary(scan: RepositoryScan): string {
|
|
43
|
+
const lines: string[] = [
|
|
44
|
+
`Repository: ${scan.root}`,
|
|
45
|
+
`Stacks: ${scan.detectedStacks.join(', ') || '(none)'}`,
|
|
46
|
+
`Package Mgr: ${scan.packageManagers.join(', ') || '(none)'}`,
|
|
47
|
+
`Test Tooling: ${scan.testFrameworks.join(', ') || '(none)'}`,
|
|
48
|
+
`Entry Points: ${scan.entryPoints.join(', ') || '(none)'}`,
|
|
49
|
+
`Migrations: ${scan.hasMigrations ? 'yes' : 'no'}`,
|
|
50
|
+
`CI Pipeline: ${scan.hasCi ? 'yes' : 'no'}`,
|
|
51
|
+
`Instructions: ${scan.agentInstructionFiles.join(', ') || '(none)'}`,
|
|
52
|
+
// Never fabricate git state: outside a work tree the scanner reports
|
|
53
|
+
// isRepo: false, and we say so instead of printing branch=main/0000000.
|
|
54
|
+
scan.git.isRepo
|
|
55
|
+
? `Git Status: branch=${scan.git.branch || '(detached)'}, dirty=${scan.git.dirty}, commit=${scan.git.headSha.slice(0, 7)}`
|
|
56
|
+
: 'Git Status: (not a git repository)',
|
|
57
|
+
];
|
|
58
|
+
return lines.join('\n') + '\n';
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function formatHelp(): string {
|
|
62
|
+
return [
|
|
63
|
+
'Usage: kit inspect [path] [--json]',
|
|
64
|
+
'',
|
|
65
|
+
'Inspect a repository and report detected stacks, frameworks, and conventions.',
|
|
66
|
+
'This command is strictly read-only and never modifies repository files.',
|
|
67
|
+
'',
|
|
68
|
+
'Options:',
|
|
69
|
+
' --json Output full inspection report as JSON',
|
|
70
|
+
' -h, --help Show this help message',
|
|
71
|
+
'',
|
|
72
|
+
].join('\n');
|
|
73
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// packages/cli/src/commands/install.test.ts
|
|
2
|
+
//
|
|
3
|
+
// Regression: `kit install --dir <target>` must write into <target>, never
|
|
4
|
+
// into the process cwd. Before this fix --dir was not parsed at all, so the
|
|
5
|
+
// profile, ownership manifest and plugin links all landed in cwd.
|
|
6
|
+
import { promises as fs } from 'node:fs';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
|
9
|
+
import { makeTempDir, type TempDir } from '@agentic-sdlc-kit/testing';
|
|
10
|
+
import { installCommand } from './install.js';
|
|
11
|
+
import type { CommandContext } from './types.js';
|
|
12
|
+
|
|
13
|
+
const makeCtx = (argv: string[], cwd: string): CommandContext & { err: string[] } => {
|
|
14
|
+
const err: string[] = [];
|
|
15
|
+
return { argv, cwd, stdout: () => undefined, stderr: (s) => void err.push(s), err };
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const exists = (p: string): Promise<boolean> =>
|
|
19
|
+
fs.access(p).then(
|
|
20
|
+
() => true,
|
|
21
|
+
() => false,
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
describe('installCommand --dir', () => {
|
|
25
|
+
let target: TempDir;
|
|
26
|
+
let elsewhere: TempDir;
|
|
27
|
+
|
|
28
|
+
beforeEach(async () => {
|
|
29
|
+
target = await makeTempDir('kit-install-target-');
|
|
30
|
+
elsewhere = await makeTempDir('kit-install-cwd-');
|
|
31
|
+
});
|
|
32
|
+
afterEach(async () => {
|
|
33
|
+
await target.cleanup();
|
|
34
|
+
await elsewhere.cleanup();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('writes the profile and ownership manifest under --dir, not under cwd', async () => {
|
|
38
|
+
const ctx = makeCtx(['--profile', 'minimal', '--dir', target.path], elsewhere.path);
|
|
39
|
+
const r = await installCommand.run(ctx);
|
|
40
|
+
expect(r.exitCode).toBe(0);
|
|
41
|
+
expect(await exists(path.join(target.path, '.ai-kit', 'project.yml'))).toBe(true);
|
|
42
|
+
expect(await exists(path.join(target.path, '.ai-kit', 'ownership-manifest.json'))).toBe(true);
|
|
43
|
+
expect(await exists(path.join(elsewhere.path, '.ai-kit'))).toBe(false);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('fails with exit 1 when --dir does not exist, and writes nothing', async () => {
|
|
47
|
+
const missing = path.join(elsewhere.path, 'nope');
|
|
48
|
+
const ctx = makeCtx(['--profile', 'minimal', '--dir', missing], elsewhere.path);
|
|
49
|
+
const r = await installCommand.run(ctx);
|
|
50
|
+
expect(r.exitCode).toBe(1);
|
|
51
|
+
expect(ctx.err.join('')).toMatch(/does not exist/);
|
|
52
|
+
expect(await exists(path.join(elsewhere.path, '.ai-kit'))).toBe(false);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('fails with exit 1 when --dir has no value', async () => {
|
|
56
|
+
const ctx = makeCtx(['--profile', 'minimal', '--dir'], elsewhere.path);
|
|
57
|
+
const r = await installCommand.run(ctx);
|
|
58
|
+
expect(r.exitCode).toBe(1);
|
|
59
|
+
expect(await exists(path.join(elsewhere.path, '.ai-kit'))).toBe(false);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
// packages/cli/src/commands/install.ts
|
|
2
|
+
//
|
|
3
|
+
// `kit install [--profile minimal|full-sdlc|runtime] [--stack <stack>] [--dry-run] [--json]`.
|
|
4
|
+
// M15 CLI installer: writes configuration files, tracks ownership, supports
|
|
5
|
+
// dry-run preview and idempotent re-installation.
|
|
6
|
+
|
|
7
|
+
import { promises as fs } from 'node:fs';
|
|
8
|
+
import path from 'node:path';
|
|
9
|
+
import { resolveStackPack } from '@agentic-sdlc-kit/core';
|
|
10
|
+
import type { Command, CommandContext, CommandResult } from './types.js';
|
|
11
|
+
import type { OwnershipEntry } from '@agentic-sdlc-kit/contracts';
|
|
12
|
+
import { linkRuntimePlugins, type PluginLinkResult } from './plugin-linker.js';
|
|
13
|
+
|
|
14
|
+
// Profiles that also link the four runtime guard plugins into the
|
|
15
|
+
// project's `.claude/plugins/` directory (as documented in
|
|
16
|
+
// docs/HOST_INTEGRATIONS.md). `minimal` is plugin-free.
|
|
17
|
+
const PROFILES_WITH_PLUGINS: ReadonlySet<string> = new Set(['full-sdlc', 'runtime']);
|
|
18
|
+
|
|
19
|
+
interface InstallOperation {
|
|
20
|
+
path: string;
|
|
21
|
+
kind: 'create' | 'skip-existing' | 'overwrite-approved';
|
|
22
|
+
content: string;
|
|
23
|
+
sha256: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const FILES_BY_PROFILE: Record<string, ReadonlyArray<{ path: string; content: string }>> = {
|
|
27
|
+
minimal: [
|
|
28
|
+
{
|
|
29
|
+
path: '.ai-kit/project.yml',
|
|
30
|
+
content: [
|
|
31
|
+
'# Generated by kit install --profile minimal',
|
|
32
|
+
'# Run `kit init` to populate this file with detected values.',
|
|
33
|
+
'schemaVersion: 1',
|
|
34
|
+
'name: ""',
|
|
35
|
+
'stack: []',
|
|
36
|
+
'commands: {}',
|
|
37
|
+
'',
|
|
38
|
+
].join('\n'),
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
'full-sdlc': [
|
|
42
|
+
{
|
|
43
|
+
path: '.ai-kit/project.yml',
|
|
44
|
+
content: [
|
|
45
|
+
'# Generated by kit install --profile full-sdlc',
|
|
46
|
+
'# Run `kit init` to populate this file with detected values.',
|
|
47
|
+
'schemaVersion: 1',
|
|
48
|
+
'name: ""',
|
|
49
|
+
'stack: []',
|
|
50
|
+
'commands: {}',
|
|
51
|
+
'',
|
|
52
|
+
].join('\n'),
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
path: 'docs/specifications/.gitkeep',
|
|
56
|
+
content: '',
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
path: 'docs/plans/.gitkeep',
|
|
60
|
+
content: '',
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
path: 'docs/architecture/adr/.gitkeep',
|
|
64
|
+
content: '',
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
path: 'docs/releases/.gitkeep',
|
|
68
|
+
content: '',
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
runtime: [
|
|
72
|
+
{
|
|
73
|
+
path: '.ai-kit/state/.gitkeep',
|
|
74
|
+
content: '',
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
path: '.ai-kit/reports/.gitkeep',
|
|
78
|
+
content: '',
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
async function sha256(text: string): Promise<string> {
|
|
84
|
+
const crypto = await import('node:crypto');
|
|
85
|
+
return crypto.createHash('sha256').update(text, 'utf8').digest('hex');
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async function fileExists(p: string): Promise<boolean> {
|
|
89
|
+
try {
|
|
90
|
+
await fs.access(p);
|
|
91
|
+
return true;
|
|
92
|
+
} catch {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export const installCommand: Command = {
|
|
98
|
+
name: 'install',
|
|
99
|
+
summary: 'Install and configure kit environment, instructions, and stack packs (M15).',
|
|
100
|
+
async run(ctx: CommandContext): Promise<CommandResult> {
|
|
101
|
+
if (ctx.argv.includes('--help') || ctx.argv.includes('-h')) {
|
|
102
|
+
ctx.stdout(formatHelp());
|
|
103
|
+
return { exitCode: 0 };
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const isJson = ctx.argv.includes('--json');
|
|
107
|
+
const isDryRun = ctx.argv.includes('--dry-run');
|
|
108
|
+
const stackIdx = ctx.argv.indexOf('--stack');
|
|
109
|
+
const stackName = stackIdx !== -1 ? ctx.argv[stackIdx + 1] : undefined;
|
|
110
|
+
const profileIdx = ctx.argv.indexOf('--profile');
|
|
111
|
+
const installProfile = profileIdx !== -1 ? ctx.argv[profileIdx + 1] : 'full-sdlc';
|
|
112
|
+
|
|
113
|
+
// --dir selects the project to install into. Every write, plugin link and
|
|
114
|
+
// the ownership manifest resolve under this root; without it they used to
|
|
115
|
+
// land in the process cwd regardless of what the user asked for.
|
|
116
|
+
const dirIdx = ctx.argv.indexOf('--dir');
|
|
117
|
+
const dirArg = dirIdx !== -1 ? ctx.argv[dirIdx + 1] : undefined;
|
|
118
|
+
if (dirIdx !== -1 && (!dirArg || dirArg.startsWith('-'))) {
|
|
119
|
+
ctx.stderr('kit install: --dir requires a directory path\n');
|
|
120
|
+
return { exitCode: 1, message: 'missing --dir value' };
|
|
121
|
+
}
|
|
122
|
+
const targetRoot = path.resolve(ctx.cwd, dirArg ?? '.');
|
|
123
|
+
const targetStat = await fs.stat(targetRoot).catch(() => null);
|
|
124
|
+
if (!targetStat?.isDirectory()) {
|
|
125
|
+
ctx.stderr(`kit install: target directory does not exist: ${targetRoot}\n`);
|
|
126
|
+
return { exitCode: 1, message: `target directory not found: ${targetRoot}` };
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (!installProfile || !FILES_BY_PROFILE[installProfile]) {
|
|
130
|
+
ctx.stderr(`kit install: unknown profile '${installProfile ?? '(missing)'}'\n`);
|
|
131
|
+
return { exitCode: 1, message: `unknown profile: ${installProfile ?? '(missing)'}` };
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Plan: compute operations for the selected profile.
|
|
135
|
+
const filesToWrite = FILES_BY_PROFILE[installProfile]!;
|
|
136
|
+
const operations: InstallOperation[] = [];
|
|
137
|
+
|
|
138
|
+
for (const file of filesToWrite) {
|
|
139
|
+
const targetPath = path.join(targetRoot, file.path);
|
|
140
|
+
const exists = await fileExists(targetPath);
|
|
141
|
+
let kind: InstallOperation['kind'] = 'create';
|
|
142
|
+
if (exists) {
|
|
143
|
+
// Idempotent: skip files that already exist unless they're .gitkeep
|
|
144
|
+
// (which are safe to overwrite).
|
|
145
|
+
if (file.path.endsWith('.gitkeep')) {
|
|
146
|
+
kind = 'overwrite-approved';
|
|
147
|
+
} else {
|
|
148
|
+
kind = 'skip-existing';
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
const hash = await sha256(file.content);
|
|
152
|
+
operations.push({ path: file.path, kind, content: file.content, sha256: hash });
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// If a stack is specified, record it in the plan.
|
|
156
|
+
let stackInfo = 'none';
|
|
157
|
+
if (stackName) {
|
|
158
|
+
const pack = resolveStackPack(stackName);
|
|
159
|
+
stackInfo = pack ? pack.name : stackName;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Plugin-enabled profiles also link the runtime guard plugins.
|
|
163
|
+
const withPlugins = PROFILES_WITH_PLUGINS.has(installProfile);
|
|
164
|
+
|
|
165
|
+
// In dry-run mode, print the plan and exit without writing.
|
|
166
|
+
if (isDryRun) {
|
|
167
|
+
const plan = {
|
|
168
|
+
profile: installProfile,
|
|
169
|
+
stack: stackInfo,
|
|
170
|
+
dryRun: true,
|
|
171
|
+
plugins: withPlugins ? ['sdlc-guard', 'secret-guard', 'model-router', 'run-observer'] : [],
|
|
172
|
+
operations: operations.map((op) => ({
|
|
173
|
+
path: op.path,
|
|
174
|
+
kind: op.kind,
|
|
175
|
+
sha256: op.sha256,
|
|
176
|
+
})),
|
|
177
|
+
};
|
|
178
|
+
if (isJson) {
|
|
179
|
+
ctx.stdout(JSON.stringify(plan, null, 2) + '\n');
|
|
180
|
+
} else {
|
|
181
|
+
ctx.stdout(formatDryRun(plan));
|
|
182
|
+
}
|
|
183
|
+
return { exitCode: 0 };
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// Execute: write files that are create or overwrite-approved.
|
|
187
|
+
const writtenFiles: string[] = [];
|
|
188
|
+
const skippedFiles: string[] = [];
|
|
189
|
+
const ownershipEntries: OwnershipEntry[] = [];
|
|
190
|
+
const now = new Date().toISOString();
|
|
191
|
+
|
|
192
|
+
for (const op of operations) {
|
|
193
|
+
if (op.kind === 'skip-existing') {
|
|
194
|
+
skippedFiles.push(op.path);
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
const targetPath = path.join(targetRoot, op.path);
|
|
198
|
+
await fs.mkdir(path.dirname(targetPath), { recursive: true });
|
|
199
|
+
await fs.writeFile(targetPath, op.content, 'utf8');
|
|
200
|
+
writtenFiles.push(op.path);
|
|
201
|
+
// By this point, the file was written (create or overwrite-approved);
|
|
202
|
+
// preserved is false because we did not skip it.
|
|
203
|
+
ownershipEntries.push({
|
|
204
|
+
packageId: 'agentic-sdlc-kit',
|
|
205
|
+
packageVersion: '0.8.0',
|
|
206
|
+
path: op.path,
|
|
207
|
+
sha256: op.sha256,
|
|
208
|
+
installedAt: now,
|
|
209
|
+
preserved: false,
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// Link the runtime guard plugins for plugin-enabled profiles. This is
|
|
214
|
+
// what HOST_INTEGRATIONS.md documents: the plugins land in
|
|
215
|
+
// `<project>/.claude/plugins/` with validated hooks module paths.
|
|
216
|
+
let pluginResults: PluginLinkResult[] = [];
|
|
217
|
+
if (withPlugins) {
|
|
218
|
+
pluginResults = await linkRuntimePlugins(targetRoot);
|
|
219
|
+
for (const pr of pluginResults) {
|
|
220
|
+
if (pr.status === 'linked' || pr.status === 'already-linked') {
|
|
221
|
+
// Ownership hash for a plugin link: the content hash of the
|
|
222
|
+
// linked plugin's identity file (what the symlink resolves to),
|
|
223
|
+
// NOT the hash of the path string.
|
|
224
|
+
let pluginHash = '';
|
|
225
|
+
try {
|
|
226
|
+
const pluginJson = await fs.readFile(
|
|
227
|
+
path.join(pr.linkPath, '.claude-plugin', 'plugin.json'),
|
|
228
|
+
'utf8',
|
|
229
|
+
);
|
|
230
|
+
pluginHash = await sha256(pluginJson);
|
|
231
|
+
} catch {
|
|
232
|
+
pluginHash = await sha256(`${pr.name}:${pr.status}`);
|
|
233
|
+
}
|
|
234
|
+
ownershipEntries.push({
|
|
235
|
+
packageId: 'agentic-sdlc-kit',
|
|
236
|
+
packageVersion: '0.8.0',
|
|
237
|
+
path: path.relative(targetRoot, pr.linkPath),
|
|
238
|
+
sha256: pluginHash,
|
|
239
|
+
installedAt: now,
|
|
240
|
+
preserved: pr.status === 'already-linked',
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// Write ownership manifest so kit uninstall knows what we own.
|
|
247
|
+
const manifestPath = path.join(targetRoot, '.ai-kit', 'ownership-manifest.json');
|
|
248
|
+
await fs.mkdir(path.dirname(manifestPath), { recursive: true });
|
|
249
|
+
const manifest = {
|
|
250
|
+
schemaVersion: 1,
|
|
251
|
+
root: targetRoot,
|
|
252
|
+
scope: 'project',
|
|
253
|
+
entries: ownershipEntries,
|
|
254
|
+
};
|
|
255
|
+
await fs.writeFile(manifestPath, JSON.stringify(manifest, null, 2) + '\n', 'utf8');
|
|
256
|
+
|
|
257
|
+
const result = {
|
|
258
|
+
installed: true,
|
|
259
|
+
profile: installProfile,
|
|
260
|
+
stack: stackInfo,
|
|
261
|
+
writtenFiles,
|
|
262
|
+
skippedFiles,
|
|
263
|
+
plugins: pluginResults,
|
|
264
|
+
ownershipManifest: '.ai-kit/ownership-manifest.json',
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
if (isJson) {
|
|
268
|
+
ctx.stdout(JSON.stringify(result, null, 2) + '\n');
|
|
269
|
+
} else {
|
|
270
|
+
ctx.stdout(formatResult(result));
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
return { exitCode: 0 };
|
|
274
|
+
},
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
interface DryRunPlan {
|
|
278
|
+
profile: string;
|
|
279
|
+
stack: string;
|
|
280
|
+
dryRun: boolean;
|
|
281
|
+
plugins: string[];
|
|
282
|
+
operations: Array<{ path: string; kind: string; sha256: string }>;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
function formatDryRun(plan: DryRunPlan): string {
|
|
286
|
+
const lines: string[] = [
|
|
287
|
+
'kit install --dry-run',
|
|
288
|
+
` Profile: ${plan.profile}`,
|
|
289
|
+
` Stack: ${plan.stack}`,
|
|
290
|
+
'',
|
|
291
|
+
'Planned operations:',
|
|
292
|
+
];
|
|
293
|
+
for (const op of plan.operations) {
|
|
294
|
+
lines.push(` ${op.kind.padEnd(20)} ${op.path}`);
|
|
295
|
+
}
|
|
296
|
+
if (plan.plugins.length > 0) {
|
|
297
|
+
lines.push(` link${' '.repeat(17)}.claude/plugins/ (${plan.plugins.join(', ')})`);
|
|
298
|
+
}
|
|
299
|
+
lines.push('');
|
|
300
|
+
lines.push(`${plan.operations.length} operation(s) planned. Run without --dry-run to execute.`);
|
|
301
|
+
lines.push('');
|
|
302
|
+
return lines.join('\n');
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
interface InstallResult {
|
|
306
|
+
installed: boolean;
|
|
307
|
+
profile: string;
|
|
308
|
+
stack: string;
|
|
309
|
+
writtenFiles: string[];
|
|
310
|
+
skippedFiles: string[];
|
|
311
|
+
plugins: PluginLinkResult[];
|
|
312
|
+
ownershipManifest: string;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
function formatResult(r: InstallResult): string {
|
|
316
|
+
const lines: string[] = [
|
|
317
|
+
'kit install: SUCCESS',
|
|
318
|
+
` Profile: ${r.profile}`,
|
|
319
|
+
` Stack: ${r.stack}`,
|
|
320
|
+
` Written: ${r.writtenFiles.length} file(s)`,
|
|
321
|
+
];
|
|
322
|
+
for (const f of r.writtenFiles) {
|
|
323
|
+
lines.push(` + ${f}`);
|
|
324
|
+
}
|
|
325
|
+
if (r.skippedFiles.length > 0) {
|
|
326
|
+
lines.push(` Skipped: ${r.skippedFiles.length} existing file(s)`);
|
|
327
|
+
for (const f of r.skippedFiles) {
|
|
328
|
+
lines.push(` ~ ${f}`);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
if (r.plugins.length > 0) {
|
|
332
|
+
lines.push(` Plugins: ${r.plugins.length} runtime plugin(s)`);
|
|
333
|
+
for (const p of r.plugins) {
|
|
334
|
+
if (p.status === 'linked') {
|
|
335
|
+
lines.push(` + ${p.name} -> ${p.linkPath}`);
|
|
336
|
+
} else if (p.status === 'already-linked') {
|
|
337
|
+
lines.push(` ~ ${p.name} (already linked)`);
|
|
338
|
+
} else {
|
|
339
|
+
// incomplete / not-found: a plugin the profile promised but could
|
|
340
|
+
// not deliver. Report loudly; never claim it is installed.
|
|
341
|
+
lines.push(` ! ${p.name}: ${p.status} — ${p.detail ?? ''}`);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
lines.push(` Ownership: ${r.ownershipManifest}`);
|
|
346
|
+
lines.push('');
|
|
347
|
+
return lines.join('\n');
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
function formatHelp(): string {
|
|
351
|
+
return [
|
|
352
|
+
'Usage: kit install [--profile <profile>] [--stack <stack>] [--dry-run] [--json]',
|
|
353
|
+
'',
|
|
354
|
+
'Install and configure kit environment, instructions, commands, and stack packs.',
|
|
355
|
+
'',
|
|
356
|
+
'Profiles:',
|
|
357
|
+
' minimal Core instructions and essential skills only (no plugins)',
|
|
358
|
+
' full-sdlc Complete workflows, templates, and the runtime guard plugins (default)',
|
|
359
|
+
' runtime Runtime governance, secret protection, and model routing plugins',
|
|
360
|
+
'',
|
|
361
|
+
'The full-sdlc and runtime profiles link the four guard plugins',
|
|
362
|
+
'(sdlc-guard, secret-guard, model-router, run-observer) into',
|
|
363
|
+
'.claude/plugins/. They are Claude Code Mods: Claude Code loads each',
|
|
364
|
+
'plugin\'s TypeScript hooks module (hooks/register.ts) directly, so they',
|
|
365
|
+
'work from a fresh clone with no build step (Claude Code v2.1.287+).',
|
|
366
|
+
'',
|
|
367
|
+
'Options:',
|
|
368
|
+
' --stack <id> Stack pack to activate (e.g. node-typescript, ruby-rails)',
|
|
369
|
+
' --dir <path> Project directory to install into (default: current directory)',
|
|
370
|
+
' --dry-run Preview planned operations without writing files',
|
|
371
|
+
' --json Output machine-readable installation status',
|
|
372
|
+
' --help Show this message',
|
|
373
|
+
'',
|
|
374
|
+
].join('\n');
|
|
375
|
+
}
|