@agentic-sdlc-kit/cli 0.0.0-stage → 0.9.1
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 +91 -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 +116 -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/attach-exclude.d.ts +8 -0
- package/dist/commands/attach-exclude.d.ts.map +1 -0
- package/dist/commands/attach-exclude.js +48 -0
- package/dist/commands/attach-exclude.js.map +1 -0
- package/dist/commands/attach-git.d.ts +11 -0
- package/dist/commands/attach-git.d.ts.map +1 -0
- package/dist/commands/attach-git.js +40 -0
- package/dist/commands/attach-git.js.map +1 -0
- package/dist/commands/attach-store.d.ts +10 -0
- package/dist/commands/attach-store.d.ts.map +1 -0
- package/dist/commands/attach-store.js +107 -0
- package/dist/commands/attach-store.js.map +1 -0
- package/dist/commands/attach.d.ts +8 -0
- package/dist/commands/attach.d.ts.map +1 -0
- package/dist/commands/attach.js +124 -0
- package/dist/commands/attach.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 +4 -0
- package/dist/commands/fix.d.ts.map +1 -0
- package/dist/commands/fix.js +53 -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/host-apply.d.ts +12 -0
- package/dist/commands/host-apply.d.ts.map +1 -0
- package/dist/commands/host-apply.js +43 -0
- package/dist/commands/host-apply.js.map +1 -0
- package/dist/commands/host.d.ts +3 -0
- package/dist/commands/host.d.ts.map +1 -0
- package/dist/commands/host.js +107 -0
- package/dist/commands/host.js.map +1 -0
- package/dist/commands/index.d.ts +25 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +26 -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 +92 -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 +337 -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 +43 -0
- package/dist/commands/plugin-linker.d.ts.map +1 -0
- package/dist/commands/plugin-linker.js +216 -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/skills-install-commit.d.ts +34 -0
- package/dist/commands/skills-install-commit.d.ts.map +1 -0
- package/dist/commands/skills-install-commit.js +113 -0
- package/dist/commands/skills-install-commit.js.map +1 -0
- package/dist/commands/skills-install-manifest.d.ts +35 -0
- package/dist/commands/skills-install-manifest.d.ts.map +1 -0
- package/dist/commands/skills-install-manifest.js +89 -0
- package/dist/commands/skills-install-manifest.js.map +1 -0
- package/dist/commands/skills-install-report.d.ts +12 -0
- package/dist/commands/skills-install-report.d.ts.map +1 -0
- package/dist/commands/skills-install-report.js +44 -0
- package/dist/commands/skills-install-report.js.map +1 -0
- package/dist/commands/skills-install-secure.d.ts +14 -0
- package/dist/commands/skills-install-secure.d.ts.map +1 -0
- package/dist/commands/skills-install-secure.js +96 -0
- package/dist/commands/skills-install-secure.js.map +1 -0
- package/dist/commands/skills-install.d.ts +15 -0
- package/dist/commands/skills-install.d.ts.map +1 -0
- package/dist/commands/skills-install.js +182 -0
- package/dist/commands/skills-install.js.map +1 -0
- package/dist/commands/skills.d.ts +3 -0
- package/dist/commands/skills.d.ts.map +1 -0
- package/dist/commands/skills.js +217 -0
- package/dist/commands/skills.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/uninstall.d.ts +3 -0
- package/dist/commands/uninstall.d.ts.map +1 -0
- package/dist/commands/uninstall.js +113 -0
- package/dist/commands/uninstall.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 +163 -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 +629 -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 +108 -0
- package/src/application/dispatcher.ts +106 -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/attach-exclude.ts +50 -0
- package/src/commands/attach-git.ts +50 -0
- package/src/commands/attach-store.ts +107 -0
- package/src/commands/attach.test.ts +192 -0
- package/src/commands/attach.ts +143 -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 +118 -0
- package/src/commands/fix.ts +58 -0
- package/src/commands/help.test.ts +33 -0
- package/src/commands/help.ts +35 -0
- package/src/commands/host-apply.ts +61 -0
- package/src/commands/host.test.ts +120 -0
- package/src/commands/host.ts +125 -0
- package/src/commands/index.ts +25 -0
- package/src/commands/init.test.ts +87 -0
- package/src/commands/init.ts +110 -0
- package/src/commands/inspect.test.ts +57 -0
- package/src/commands/inspect.ts +73 -0
- package/src/commands/install.test.ts +92 -0
- package/src/commands/install.ts +389 -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 +219 -0
- package/src/commands/plugin-linker.ts +244 -0
- package/src/commands/refactor.ts +34 -0
- package/src/commands/skills-install-commit.ts +149 -0
- package/src/commands/skills-install-manifest.ts +124 -0
- package/src/commands/skills-install-report.ts +60 -0
- package/src/commands/skills-install-secure.ts +113 -0
- package/src/commands/skills-install.ts +245 -0
- package/src/commands/skills.test.ts +449 -0
- package/src/commands/skills.ts +247 -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/uninstall.test.ts +122 -0
- package/src/commands/uninstall.ts +116 -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,449 @@
|
|
|
1
|
+
// packages/cli/src/commands/skills.test.ts
|
|
2
|
+
//
|
|
3
|
+
// `kit skills` — list/show/recommend run from the core registry with no I/O;
|
|
4
|
+
// install is exercised against a local --source fixture so the suite never
|
|
5
|
+
// needs network access. The GitHub clone path is the same code with the
|
|
6
|
+
// source lookup replaced by `git clone`.
|
|
7
|
+
|
|
8
|
+
import { promises as fs } from 'node:fs';
|
|
9
|
+
import path from 'node:path';
|
|
10
|
+
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
|
11
|
+
import { makeTempDir, type TempDir } from '@agentic-sdlc-kit/testing';
|
|
12
|
+
import { runSkillsInstall } from './skills-install.js';
|
|
13
|
+
import { skillsCommand } from './skills.js';
|
|
14
|
+
import type { CommandContext } from './types.js';
|
|
15
|
+
|
|
16
|
+
const makeCtx = (
|
|
17
|
+
argv: ReadonlyArray<string>,
|
|
18
|
+
cwd = '/tmp',
|
|
19
|
+
): CommandContext & { out: string[]; err: string[] } => {
|
|
20
|
+
const out: string[] = [];
|
|
21
|
+
const err: string[] = [];
|
|
22
|
+
return { argv, cwd, stdout: (s) => void out.push(s), stderr: (s) => void err.push(s), out, err };
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const exists = (p: string): Promise<boolean> =>
|
|
26
|
+
fs.access(p).then(
|
|
27
|
+
() => true,
|
|
28
|
+
() => false,
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
describe('kit skills list/show/recommend', () => {
|
|
32
|
+
it('lists the three integrated packs with repositories and counts', async () => {
|
|
33
|
+
const ctx = makeCtx([]);
|
|
34
|
+
const r = await skillsCommand.run(ctx);
|
|
35
|
+
expect(r.exitCode).toBe(0);
|
|
36
|
+
const text = ctx.out.join('');
|
|
37
|
+
expect(text).toContain('ruby-agent-skills');
|
|
38
|
+
expect(text).toContain('node-agent-skills');
|
|
39
|
+
expect(text).toContain('react-agent-skills');
|
|
40
|
+
expect(text).toContain('shubhamtaywade82/node-agent-skills');
|
|
41
|
+
expect(text).toContain('322 skills');
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('shows one pack with its workflow mapping', async () => {
|
|
45
|
+
const ctx = makeCtx(['show', 'ruby-agent-skills']);
|
|
46
|
+
const r = await skillsCommand.run(ctx);
|
|
47
|
+
expect(r.exitCode).toBe(0);
|
|
48
|
+
const text = ctx.out.join('');
|
|
49
|
+
expect(text).toContain('https://github.com/shubhamtaywade82/ruby-agent-skills');
|
|
50
|
+
expect(text).toContain('ruby-rails');
|
|
51
|
+
expect(text).toContain('planning-spec');
|
|
52
|
+
expect(text).toContain('rails-release-engineering');
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('fails show for an unknown pack', async () => {
|
|
56
|
+
const ctx = makeCtx(['show', 'nope-pack']);
|
|
57
|
+
const r = await skillsCommand.run(ctx);
|
|
58
|
+
expect(r.exitCode).toBe(1);
|
|
59
|
+
expect(ctx.err.join('')).toMatch(/unknown skills pack/);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('maps a kit stack to its pack and recommendations', async () => {
|
|
63
|
+
const ctx = makeCtx(['for-stack', 'ruby-rails']);
|
|
64
|
+
const r = await skillsCommand.run(ctx);
|
|
65
|
+
expect(r.exitCode).toBe(0);
|
|
66
|
+
const text = ctx.out.join('');
|
|
67
|
+
expect(text).toContain('ruby-agent-skills');
|
|
68
|
+
expect(text).toContain('planning-tickets');
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('fails for-stack for stacks without a pack', async () => {
|
|
72
|
+
const ctx = makeCtx(['for-stack', 'python']);
|
|
73
|
+
expect((await skillsCommand.run(ctx)).exitCode).toBe(1);
|
|
74
|
+
expect(ctx.err.join('')).toMatch(/no skills pack covers stack 'python'/);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('recommends stage skills for a stack, in text and JSON', async () => {
|
|
78
|
+
const text = makeCtx(['recommend', '--stack', 'node-typescript', '--stage', 'tdd']);
|
|
79
|
+
expect((await skillsCommand.run(text)).exitCode).toBe(0);
|
|
80
|
+
expect(text.out.join('')).toContain('node-testing');
|
|
81
|
+
|
|
82
|
+
const json = makeCtx([
|
|
83
|
+
'recommend',
|
|
84
|
+
'--stack',
|
|
85
|
+
'node-typescript',
|
|
86
|
+
'--stage',
|
|
87
|
+
'review',
|
|
88
|
+
'--json',
|
|
89
|
+
]);
|
|
90
|
+
expect((await skillsCommand.run(json)).exitCode).toBe(0);
|
|
91
|
+
const parsed = JSON.parse(json.out.join('')) as {
|
|
92
|
+
stack: string;
|
|
93
|
+
stage: string;
|
|
94
|
+
skills: string[];
|
|
95
|
+
};
|
|
96
|
+
expect(parsed.stack).toBe('node-typescript');
|
|
97
|
+
expect(parsed.stage).toBe('review');
|
|
98
|
+
expect(parsed.skills).toContain('node-code-review');
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it('rejects unknown stacks and stages for recommend', async () => {
|
|
102
|
+
const badStack = makeCtx(['recommend', '--stack', 'python']);
|
|
103
|
+
expect((await skillsCommand.run(badStack)).exitCode).toBe(1);
|
|
104
|
+
const badStage = makeCtx(['recommend', '--stack', 'ruby', '--stage', 'deploy']);
|
|
105
|
+
expect((await skillsCommand.run(badStage)).exitCode).toBe(1);
|
|
106
|
+
expect(badStage.err.join('')).toMatch(/unknown stage 'deploy'/);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('rejects unknown subcommands and prints usage on --help', async () => {
|
|
110
|
+
const bogus = makeCtx(['teleport']);
|
|
111
|
+
expect((await skillsCommand.run(bogus)).exitCode).toBe(1);
|
|
112
|
+
const help = makeCtx(['--help']);
|
|
113
|
+
expect((await skillsCommand.run(help)).exitCode).toBe(0);
|
|
114
|
+
expect(help.out.join('')).toContain('Usage: kit skills');
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
describe('kit skills install', () => {
|
|
119
|
+
let project: TempDir;
|
|
120
|
+
let source: TempDir;
|
|
121
|
+
|
|
122
|
+
const makeSourceSkill = async (name: string): Promise<void> => {
|
|
123
|
+
const dir = path.join(source.path, 'skills', name);
|
|
124
|
+
await fs.mkdir(dir, { recursive: true });
|
|
125
|
+
await fs.writeFile(
|
|
126
|
+
path.join(dir, 'SKILL.md'),
|
|
127
|
+
`---\nname: ${name}\ndescription: fixture skill for tests\nlicense: MIT\n---\n\n# ${name}\n`,
|
|
128
|
+
'utf8',
|
|
129
|
+
);
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
beforeEach(async () => {
|
|
133
|
+
project = await makeTempDir('kit-skills-project-');
|
|
134
|
+
source = await makeTempDir('kit-skills-source-');
|
|
135
|
+
await makeSourceSkill('alpha-one');
|
|
136
|
+
await makeSourceSkill('beta-two');
|
|
137
|
+
});
|
|
138
|
+
afterEach(async () => {
|
|
139
|
+
await project.cleanup();
|
|
140
|
+
await source.cleanup();
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
const installArgv = (extra: string[] = []): string[] => [
|
|
144
|
+
'install',
|
|
145
|
+
'node-agent-skills',
|
|
146
|
+
'--dir',
|
|
147
|
+
project.path,
|
|
148
|
+
'--source',
|
|
149
|
+
source.path,
|
|
150
|
+
...extra,
|
|
151
|
+
];
|
|
152
|
+
|
|
153
|
+
it('dry-run plans without cloning or writing anything', async () => {
|
|
154
|
+
const ctx = makeCtx(installArgv(['--dry-run', '--json']));
|
|
155
|
+
const r = await skillsCommand.run(ctx);
|
|
156
|
+
expect(r.exitCode).toBe(0);
|
|
157
|
+
const plan = JSON.parse(ctx.out.join('')) as { dryRun: boolean; expectedSkills: number };
|
|
158
|
+
expect(plan.dryRun).toBe(true);
|
|
159
|
+
expect(plan.expectedSkills).toBe(322);
|
|
160
|
+
expect(await exists(path.join(project.path, '.claude'))).toBe(false);
|
|
161
|
+
expect(await exists(path.join(project.path, '.ai-kit'))).toBe(false);
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
it('copies skills into .claude/skills and records the manifest', async () => {
|
|
165
|
+
const ctx = makeCtx(installArgv());
|
|
166
|
+
const r = await skillsCommand.run(ctx);
|
|
167
|
+
expect(r.exitCode).toBe(0);
|
|
168
|
+
expect(
|
|
169
|
+
await exists(path.join(project.path, '.claude', 'skills', 'alpha-one', 'SKILL.md')),
|
|
170
|
+
).toBe(true);
|
|
171
|
+
expect(await exists(path.join(project.path, '.claude', 'skills', 'beta-two', 'SKILL.md'))).toBe(
|
|
172
|
+
true,
|
|
173
|
+
);
|
|
174
|
+
const manifestRaw = await fs.readFile(
|
|
175
|
+
path.join(project.path, '.ai-kit', 'skills-manifest.json'),
|
|
176
|
+
'utf8',
|
|
177
|
+
);
|
|
178
|
+
const manifest = JSON.parse(manifestRaw) as {
|
|
179
|
+
packs: Record<
|
|
180
|
+
string,
|
|
181
|
+
{ skills: Array<{ name: string; status: string }> }
|
|
182
|
+
>;
|
|
183
|
+
};
|
|
184
|
+
expect(manifest.packs['node-agent-skills'].repository).toBe(
|
|
185
|
+
'shubhamtaywade82/node-agent-skills',
|
|
186
|
+
);
|
|
187
|
+
expect(manifest.packs['node-agent-skills'].skills).toHaveLength(2);
|
|
188
|
+
expect(ctx.out.join('')).toContain('Installed: 2 skill(s)');
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
it('is idempotent: a second run skips existing skills unless --force', async () => {
|
|
192
|
+
await skillsCommand.run(makeCtx(installArgv()));
|
|
193
|
+
const second = makeCtx(installArgv());
|
|
194
|
+
expect((await skillsCommand.run(second)).exitCode).toBe(0);
|
|
195
|
+
expect(second.out.join('')).toContain('Skipped: 2 existing skill(s)');
|
|
196
|
+
|
|
197
|
+
const forced = makeCtx(installArgv(['--force']));
|
|
198
|
+
expect((await skillsCommand.run(forced)).exitCode).toBe(0);
|
|
199
|
+
expect(forced.out.join('')).toContain('Installed: 2 skill(s)');
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
it('installs into a custom --into directory', async () => {
|
|
203
|
+
const ctx = makeCtx(installArgv(['--into', 'docs/agent-skills']));
|
|
204
|
+
const r = await skillsCommand.run(ctx);
|
|
205
|
+
expect(r.exitCode).toBe(0);
|
|
206
|
+
expect(
|
|
207
|
+
await exists(path.join(project.path, 'docs', 'agent-skills', 'alpha-one', 'SKILL.md')),
|
|
208
|
+
).toBe(true);
|
|
209
|
+
expect(await exists(path.join(project.path, '.claude'))).toBe(false);
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
it('fails for an unknown pack and for a missing --dir', async () => {
|
|
213
|
+
const badPack = makeCtx(['install', 'nope-pack', '--dir', project.path]);
|
|
214
|
+
expect((await skillsCommand.run(badPack)).exitCode).toBe(1);
|
|
215
|
+
const badDir = makeCtx([
|
|
216
|
+
'install',
|
|
217
|
+
'node-agent-skills',
|
|
218
|
+
'--dir',
|
|
219
|
+
path.join(project.path, 'missing'),
|
|
220
|
+
]);
|
|
221
|
+
expect((await skillsCommand.run(badDir)).exitCode).toBe(1);
|
|
222
|
+
expect(badDir.err.join('')).toMatch(/target directory does not exist/);
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
describe('kit skills install security (fail-closed installer)', () => {
|
|
227
|
+
let project: TempDir;
|
|
228
|
+
let source: TempDir;
|
|
229
|
+
|
|
230
|
+
const makeSourceSkill = async (name: string, frontmatterName?: string): Promise<void> => {
|
|
231
|
+
const dir = path.join(source.path, 'skills', name);
|
|
232
|
+
await fs.mkdir(dir, { recursive: true });
|
|
233
|
+
const fm = frontmatterName ?? name;
|
|
234
|
+
await fs.writeFile(
|
|
235
|
+
path.join(dir, 'SKILL.md'),
|
|
236
|
+
`---\nname: ${fm}\ndescription: fixture skill for tests\n---\n\n# ${name}\n`,
|
|
237
|
+
'utf8',
|
|
238
|
+
);
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
beforeEach(async () => {
|
|
242
|
+
project = await makeTempDir('kit-skills-sec-project-');
|
|
243
|
+
source = await makeTempDir('kit-skills-sec-source-');
|
|
244
|
+
await makeSourceSkill('alpha-one');
|
|
245
|
+
await makeSourceSkill('beta-two');
|
|
246
|
+
});
|
|
247
|
+
afterEach(async () => {
|
|
248
|
+
await project.cleanup();
|
|
249
|
+
await source.cleanup();
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
const installArgv = (extra: string[] = []): string[] => [
|
|
253
|
+
'install',
|
|
254
|
+
'node-agent-skills',
|
|
255
|
+
'--dir',
|
|
256
|
+
project.path,
|
|
257
|
+
'--source',
|
|
258
|
+
source.path,
|
|
259
|
+
...extra,
|
|
260
|
+
];
|
|
261
|
+
|
|
262
|
+
const manifestPath = (): string => path.join(project.path, '.ai-kit', 'skills-manifest.json');
|
|
263
|
+
|
|
264
|
+
const readManifest = async (): Promise<{
|
|
265
|
+
packs: Record<string, { skills: Array<{ name: string; status: string }> }>;
|
|
266
|
+
}> => JSON.parse(await fs.readFile(manifestPath(), 'utf8'));
|
|
267
|
+
|
|
268
|
+
it('rejects --into that escapes or equals the project directory', async () => {
|
|
269
|
+
for (const into of ['../../outside', '/etc', '.']) {
|
|
270
|
+
const ctx = makeCtx(installArgv(['--into', into]));
|
|
271
|
+
const r = await skillsCommand.run(ctx);
|
|
272
|
+
expect(r.exitCode).toBe(1);
|
|
273
|
+
expect(ctx.err.join('')).toMatch(/--into/);
|
|
274
|
+
}
|
|
275
|
+
expect(await exists(path.join(project.path, '.claude'))).toBe(false);
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
it('validates the install target even for --dry-run', async () => {
|
|
279
|
+
const ctx = makeCtx(installArgv(['--dry-run', '--into', '../escape']));
|
|
280
|
+
const r = await skillsCommand.run(ctx);
|
|
281
|
+
expect(r.exitCode).toBe(1);
|
|
282
|
+
expect(ctx.err.join('')).toMatch(/escapes the project directory/);
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
it('refuses to install through a symlinked destination component', async () => {
|
|
286
|
+
const outside = await makeTempDir('kit-skills-outside-');
|
|
287
|
+
await fs.mkdir(path.join(outside.path, 'skills'), { recursive: true });
|
|
288
|
+
await fs.symlink(path.join(outside.path, 'skills'), path.join(project.path, '.claude'));
|
|
289
|
+
const ctx = makeCtx(installArgv());
|
|
290
|
+
const r = await skillsCommand.run(ctx);
|
|
291
|
+
expect(r.exitCode).toBe(1);
|
|
292
|
+
expect(ctx.err.join('')).toMatch(/symlinked path component/);
|
|
293
|
+
expect(await exists(path.join(outside.path, 'skills', 'alpha-one'))).toBe(false);
|
|
294
|
+
await outside.cleanup();
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
it('fails closed on a corrupt manifest and never overwrites it', async () => {
|
|
298
|
+
const corrupt = '{ this is not json';
|
|
299
|
+
await fs.mkdir(path.join(project.path, '.ai-kit'), { recursive: true });
|
|
300
|
+
await fs.writeFile(manifestPath(), corrupt, 'utf8');
|
|
301
|
+
const ctx = makeCtx(installArgv());
|
|
302
|
+
const r = await skillsCommand.run(ctx);
|
|
303
|
+
expect(r.exitCode).toBe(1);
|
|
304
|
+
expect(ctx.err.join('')).toMatch(/not valid JSON/);
|
|
305
|
+
expect(ctx.err.join('')).toMatch(/refuses to overwrite/);
|
|
306
|
+
expect(await fs.readFile(manifestPath(), 'utf8')).toBe(corrupt);
|
|
307
|
+
expect(await exists(path.join(project.path, '.claude'))).toBe(false);
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
it('fails closed on a manifest with an unexpected shape', async () => {
|
|
311
|
+
const wrong = JSON.stringify({ schemaVersion: 2, packs: {} });
|
|
312
|
+
await fs.mkdir(path.join(project.path, '.ai-kit'), { recursive: true });
|
|
313
|
+
await fs.writeFile(manifestPath(), wrong, 'utf8');
|
|
314
|
+
const ctx = makeCtx(installArgv());
|
|
315
|
+
const r = await skillsCommand.run(ctx);
|
|
316
|
+
expect(r.exitCode).toBe(1);
|
|
317
|
+
expect(ctx.err.join('')).toMatch(/unexpected shape/);
|
|
318
|
+
expect(await fs.readFile(manifestPath(), 'utf8')).toBe(wrong);
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
it('--force never replaces or deletes directories the kit did not install', async () => {
|
|
322
|
+
const userSkill = path.join(project.path, '.claude', 'skills', 'alpha-one');
|
|
323
|
+
await fs.mkdir(userSkill, { recursive: true });
|
|
324
|
+
await fs.writeFile(path.join(userSkill, 'SKILL.md'), 'user-authored content\n', 'utf8');
|
|
325
|
+
const ctx = makeCtx(installArgv(['--force']));
|
|
326
|
+
const r = await skillsCommand.run(ctx);
|
|
327
|
+
expect(r.exitCode).toBe(0);
|
|
328
|
+
expect(ctx.out.join('')).toContain('Refused: 1 unowned skill(s)');
|
|
329
|
+
expect(await fs.readFile(path.join(userSkill, 'SKILL.md'), 'utf8')).toBe(
|
|
330
|
+
'user-authored content\n',
|
|
331
|
+
);
|
|
332
|
+
expect(await exists(path.join(project.path, '.claude', 'skills', 'beta-two', 'SKILL.md'))).toBe(
|
|
333
|
+
true,
|
|
334
|
+
);
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
it('--force replaces kit-installed skills; ownership survives idempotent re-runs', async () => {
|
|
338
|
+
await skillsCommand.run(makeCtx(installArgv()));
|
|
339
|
+
const skillMd = path.join(project.path, '.claude', 'skills', 'alpha-one', 'SKILL.md');
|
|
340
|
+
await fs.appendFile(skillMd, 'user drift\n', 'utf8');
|
|
341
|
+
|
|
342
|
+
// Idempotent re-run must not lose ownership of previously installed skills.
|
|
343
|
+
await skillsCommand.run(makeCtx(installArgv()));
|
|
344
|
+
const afterSkip = await readManifest();
|
|
345
|
+
expect(afterSkip.packs['node-agent-skills'].skills).toContainEqual({
|
|
346
|
+
name: 'alpha-one',
|
|
347
|
+
status: 'installed',
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
const forced = makeCtx(installArgv(['--force']));
|
|
351
|
+
expect((await skillsCommand.run(forced)).exitCode).toBe(0);
|
|
352
|
+
expect(forced.out.join('')).toContain('Installed: 2 skill(s)');
|
|
353
|
+
expect(await fs.readFile(skillMd, 'utf8')).not.toContain('user drift');
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
it('rejects symlinked content inside a skill before writing anything', async () => {
|
|
357
|
+
const target = await makeTempDir('kit-skills-linktarget-');
|
|
358
|
+
await fs.writeFile(path.join(target.path, 'payload.txt'), 'x', 'utf8');
|
|
359
|
+
await fs.symlink(target.path, path.join(source.path, 'skills', 'alpha-one', 'link'));
|
|
360
|
+
const ctx = makeCtx(installArgv());
|
|
361
|
+
const r = await skillsCommand.run(ctx);
|
|
362
|
+
expect(r.exitCode).toBe(1);
|
|
363
|
+
expect(ctx.err.join('')).toMatch(/symlink in pack content/);
|
|
364
|
+
expect(await exists(path.join(project.path, '.claude'))).toBe(false);
|
|
365
|
+
await target.cleanup();
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
it('rejects a symlinked skill directory at the pack skills/ root', async () => {
|
|
369
|
+
const elsewhere = await makeTempDir('kit-skills-elsewhere-');
|
|
370
|
+
await fs.mkdir(path.join(elsewhere.path, 'nested'), { recursive: true });
|
|
371
|
+
await fs.symlink(elsewhere.path, path.join(source.path, 'skills', 'linked-skill'));
|
|
372
|
+
const ctx = makeCtx(installArgv());
|
|
373
|
+
const r = await skillsCommand.run(ctx);
|
|
374
|
+
expect(r.exitCode).toBe(1);
|
|
375
|
+
expect(ctx.err.join('')).toMatch(/symlinked entry in pack skills/);
|
|
376
|
+
await elsewhere.cleanup();
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
it('rejects SKILL.md without valid frontmatter or with a name mismatch', async () => {
|
|
380
|
+
await fs.writeFile(
|
|
381
|
+
path.join(source.path, 'skills', 'alpha-one', 'SKILL.md'),
|
|
382
|
+
'# just markdown, no frontmatter\n',
|
|
383
|
+
'utf8',
|
|
384
|
+
);
|
|
385
|
+
const noFm = makeCtx(installArgv());
|
|
386
|
+
expect((await skillsCommand.run(noFm)).exitCode).toBe(1);
|
|
387
|
+
expect(noFm.err.join('')).toMatch(/no YAML frontmatter/);
|
|
388
|
+
expect(await exists(path.join(project.path, '.claude'))).toBe(false);
|
|
389
|
+
|
|
390
|
+
await makeSourceSkill('alpha-one', 'wrong-name');
|
|
391
|
+
const mismatch = makeCtx(installArgv());
|
|
392
|
+
expect((await skillsCommand.run(mismatch)).exitCode).toBe(1);
|
|
393
|
+
expect(mismatch.err.join('')).toMatch(/does not match its directory/);
|
|
394
|
+
expect(await exists(path.join(project.path, '.claude'))).toBe(false);
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
it('rejects unsafe skill directory names in a pack', async () => {
|
|
398
|
+
await makeSourceSkill('weird skill');
|
|
399
|
+
const ctx = makeCtx(installArgv());
|
|
400
|
+
const r = await skillsCommand.run(ctx);
|
|
401
|
+
expect(r.exitCode).toBe(1);
|
|
402
|
+
expect(ctx.err.join('')).toMatch(/unsafe skill directory name/);
|
|
403
|
+
expect(await exists(path.join(project.path, '.claude'))).toBe(false);
|
|
404
|
+
});
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
describe('kit skills install (runSkillsInstall)', () => {
|
|
408
|
+
let project: TempDir;
|
|
409
|
+
|
|
410
|
+
beforeEach(async () => {
|
|
411
|
+
project = await makeTempDir('kit-skills-run-');
|
|
412
|
+
});
|
|
413
|
+
afterEach(async () => {
|
|
414
|
+
await project.cleanup();
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
it('returns JSON with per-skill statuses', async () => {
|
|
418
|
+
const source = await makeTempDir('kit-skills-jsonsrc-');
|
|
419
|
+
const dir = path.join(source.path, 'skills', 'gamma-three');
|
|
420
|
+
await fs.mkdir(dir, { recursive: true });
|
|
421
|
+
await fs.writeFile(
|
|
422
|
+
path.join(dir, 'SKILL.md'),
|
|
423
|
+
'---\nname: gamma-three\ndescription: x\n---\n',
|
|
424
|
+
'utf8',
|
|
425
|
+
);
|
|
426
|
+
const ctx = makeCtx([]);
|
|
427
|
+
const r = await runSkillsInstall(
|
|
428
|
+
{
|
|
429
|
+
packId: 'react-agent-skills',
|
|
430
|
+
targetRoot: project.path,
|
|
431
|
+
force: false,
|
|
432
|
+
dryRun: false,
|
|
433
|
+
json: true,
|
|
434
|
+
source: source.path,
|
|
435
|
+
},
|
|
436
|
+
ctx,
|
|
437
|
+
);
|
|
438
|
+
expect(r.exitCode).toBe(0);
|
|
439
|
+
const parsed = JSON.parse(ctx.out.join('')) as {
|
|
440
|
+
installed: boolean;
|
|
441
|
+
pack: string;
|
|
442
|
+
skills: Array<{ name: string; status: string }>;
|
|
443
|
+
};
|
|
444
|
+
expect(parsed.installed).toBe(true);
|
|
445
|
+
expect(parsed.pack).toBe('react-agent-skills');
|
|
446
|
+
expect(parsed.skills).toEqual([{ name: 'gamma-three', status: 'installed' }]);
|
|
447
|
+
await source.cleanup();
|
|
448
|
+
});
|
|
449
|
+
});
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
// packages/cli/src/commands/skills.ts
|
|
2
|
+
//
|
|
3
|
+
// `kit skills` — inspect and install the external agent-skills packs
|
|
4
|
+
// (ruby-agent-skills, node-agent-skills, react-agent-skills) that the kit
|
|
5
|
+
// integrates with its M14 stack packs and SDLC workflow stages.
|
|
6
|
+
//
|
|
7
|
+
// Subcommands:
|
|
8
|
+
// kit skills list the integrated packs
|
|
9
|
+
// kit skills show <pack> details for one pack, incl. workflow map
|
|
10
|
+
// kit skills for-stack <stack> pack + recommendations for a kit stack
|
|
11
|
+
// kit skills recommend --stack <stack> [--stage <stage>] [--json]
|
|
12
|
+
// kit skills install <pack> [--dir <path>] [--into <dir>] [--ref <gitref>]
|
|
13
|
+
// [--force] [--dry-run] [--json]
|
|
14
|
+
//
|
|
15
|
+
// This command never bundles pack content: list/show/recommend work from the
|
|
16
|
+
// registry in @agentic-sdlc-kit/core, and install fetches the pack from its
|
|
17
|
+
// GitHub repository (see ./skills-install.ts).
|
|
18
|
+
|
|
19
|
+
import {
|
|
20
|
+
WORKFLOW_STAGES,
|
|
21
|
+
defaultSkillsPackForStack,
|
|
22
|
+
listSkillsPacks,
|
|
23
|
+
recommendSkillsByStage,
|
|
24
|
+
recommendSkillsForStage,
|
|
25
|
+
resolveSkillsPack,
|
|
26
|
+
resolveStackPack,
|
|
27
|
+
type WorkflowStage,
|
|
28
|
+
} from '@agentic-sdlc-kit/core';
|
|
29
|
+
import { promises as fs } from 'node:fs';
|
|
30
|
+
import path from 'node:path';
|
|
31
|
+
import type { Command, CommandContext, CommandResult } from './types.js';
|
|
32
|
+
import { runSkillsInstall } from './skills-install.js';
|
|
33
|
+
|
|
34
|
+
function optValue(argv: ReadonlyArray<string>, name: string): string | undefined {
|
|
35
|
+
const idx = argv.indexOf(name);
|
|
36
|
+
if (idx === -1) return undefined;
|
|
37
|
+
const value = argv[idx + 1];
|
|
38
|
+
return value && !value.startsWith('-') ? value : undefined;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const hasFlag = (argv: ReadonlyArray<string>, name: string): boolean => argv.includes(name);
|
|
42
|
+
|
|
43
|
+
function formatList(): string {
|
|
44
|
+
const lines: string[] = ['kit skills — integrated agent skills packs', ''];
|
|
45
|
+
for (const pack of listSkillsPacks()) {
|
|
46
|
+
lines.push(` ${pack.id}`);
|
|
47
|
+
lines.push(` ${pack.description}`);
|
|
48
|
+
lines.push(` Repository: ${pack.repository} (${pack.skillCount} skills, MIT)`);
|
|
49
|
+
lines.push('');
|
|
50
|
+
}
|
|
51
|
+
lines.push("Run 'kit skills show <pack>' for the workflow mapping.");
|
|
52
|
+
lines.push("Run 'kit skills install <pack> --dir <project>' to install into a project.");
|
|
53
|
+
lines.push('');
|
|
54
|
+
return lines.join('\n');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function formatWorkflowMap(stackIds: readonly string[]): string {
|
|
58
|
+
const lines: string[] = [` Workflow mapping (stack: ${stackIds.join(', ')}):`];
|
|
59
|
+
for (const stage of WORKFLOW_STAGES) {
|
|
60
|
+
const skills = recommendSkillsForStage(stackIds[0]!, stage);
|
|
61
|
+
lines.push(` ${stage.padEnd(12)} ${skills.join(', ')}`);
|
|
62
|
+
}
|
|
63
|
+
return lines.join('\n');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function formatShow(packId: string): string {
|
|
67
|
+
const pack = resolveSkillsPack(packId)!;
|
|
68
|
+
const stackIds = ['node-typescript', 'react-typescript', 'ruby-rails', 'ruby'].filter(
|
|
69
|
+
(s) => defaultSkillsPackForStack(s)?.id === pack.id,
|
|
70
|
+
);
|
|
71
|
+
const lines: string[] = [
|
|
72
|
+
`kit skills show ${pack.id}`,
|
|
73
|
+
'',
|
|
74
|
+
` Name: ${pack.name}`,
|
|
75
|
+
` Description: ${pack.description}`,
|
|
76
|
+
` Repository: ${pack.url}`,
|
|
77
|
+
` Skills: ${pack.skillCount}`,
|
|
78
|
+
` Categories: ${pack.categories.join(', ')}`,
|
|
79
|
+
` License: ${pack.license}`,
|
|
80
|
+
` Kit stacks: ${stackIds.join(', ')}`,
|
|
81
|
+
'',
|
|
82
|
+
formatWorkflowMap(stackIds),
|
|
83
|
+
'',
|
|
84
|
+
];
|
|
85
|
+
return lines.join('\n');
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function formatForStack(stackId: string): string {
|
|
89
|
+
const pack = defaultSkillsPackForStack(stackId)!;
|
|
90
|
+
const byStage = recommendSkillsByStage(stackId);
|
|
91
|
+
const total = Object.values(byStage).reduce((n, skills) => n + skills.length, 0);
|
|
92
|
+
const lines: string[] = [
|
|
93
|
+
`kit skills for-stack ${stackId}`,
|
|
94
|
+
'',
|
|
95
|
+
` Pack: ${pack.id} (${pack.repository})`,
|
|
96
|
+
` Recommended: ${total} skill(s) across ${WORKFLOW_STAGES.length} workflow stages`,
|
|
97
|
+
'',
|
|
98
|
+
formatWorkflowMap([stackId]),
|
|
99
|
+
'',
|
|
100
|
+
];
|
|
101
|
+
return lines.join('\n');
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function formatRecommend(stackId: string, stage: string | undefined, isJson: boolean): string {
|
|
105
|
+
if (stage) {
|
|
106
|
+
const skills = recommendSkillsForStage(stackId, stage as WorkflowStage);
|
|
107
|
+
if (isJson) {
|
|
108
|
+
return JSON.stringify({ stack: stackId, stage, skills }, null, 2) + '\n';
|
|
109
|
+
}
|
|
110
|
+
return [
|
|
111
|
+
`kit skills recommend --stack ${stackId} --stage ${stage}`,
|
|
112
|
+
'',
|
|
113
|
+
...skills.map((s) => ` ${s}`),
|
|
114
|
+
'',
|
|
115
|
+
].join('\n');
|
|
116
|
+
}
|
|
117
|
+
const byStage = recommendSkillsByStage(stackId);
|
|
118
|
+
if (isJson) {
|
|
119
|
+
return JSON.stringify({ stack: stackId, stages: byStage }, null, 2) + '\n';
|
|
120
|
+
}
|
|
121
|
+
const lines: string[] = [`kit skills recommend --stack ${stackId}`, ''];
|
|
122
|
+
for (const s of WORKFLOW_STAGES) {
|
|
123
|
+
lines.push(` ${s.padEnd(12)} ${byStage[s].join(', ')}`);
|
|
124
|
+
}
|
|
125
|
+
lines.push('');
|
|
126
|
+
return lines.join('\n');
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function formatSkillsHelp(): string {
|
|
130
|
+
return [
|
|
131
|
+
'Usage: kit skills [list | show <pack> | for-stack <stack> | recommend | install <pack>]',
|
|
132
|
+
'',
|
|
133
|
+
'Inspect and install the external agent-skills packs integrated with the kit.',
|
|
134
|
+
'',
|
|
135
|
+
'Subcommands:',
|
|
136
|
+
' list List the integrated packs (default)',
|
|
137
|
+
' show <pack> Pack details and its workflow mapping',
|
|
138
|
+
' for-stack <stack> Pack and recommendations for a kit stack',
|
|
139
|
+
' recommend --stack <stack> Skills to load per SDLC stage (--stage to filter, --json for machines)',
|
|
140
|
+
' install <pack> Install a pack into a project',
|
|
141
|
+
'',
|
|
142
|
+
'Install options:',
|
|
143
|
+
' --dir <path> Project directory (default: current directory)',
|
|
144
|
+
' --into <dir> Target skills directory (default: .claude/skills)',
|
|
145
|
+
' --ref <gitref> Clone a specific branch or tag (default: repository HEAD)',
|
|
146
|
+
' --source <dir> Install from a local checkout of the pack instead of GitHub',
|
|
147
|
+
' --force Overwrite already-installed skills',
|
|
148
|
+
' --dry-run Preview without cloning or writing',
|
|
149
|
+
' --json Machine-readable output',
|
|
150
|
+
'',
|
|
151
|
+
'Stacks with a pack: node-typescript, react-typescript, ruby-rails, ruby.',
|
|
152
|
+
'Install target: skills are copied to <project>/.claude/skills/<skill>/SKILL.md',
|
|
153
|
+
'and recorded in <project>/.ai-kit/skills-manifest.json.',
|
|
154
|
+
'',
|
|
155
|
+
].join('\n');
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export const skillsCommand: Command = {
|
|
159
|
+
name: 'skills',
|
|
160
|
+
summary: 'Inspect and install external agent skills packs (ruby/node/react).',
|
|
161
|
+
async run(ctx: CommandContext): Promise<CommandResult> {
|
|
162
|
+
const argv = ctx.argv;
|
|
163
|
+
if (argv.includes('--help') || argv.includes('-h')) {
|
|
164
|
+
ctx.stdout(formatSkillsHelp());
|
|
165
|
+
return { exitCode: 0 };
|
|
166
|
+
}
|
|
167
|
+
const rest = argv.filter((a) => !['list'].includes(a));
|
|
168
|
+
const sub = rest.find((a) => !a.startsWith('-')) ?? 'list';
|
|
169
|
+
|
|
170
|
+
if (sub === 'list') {
|
|
171
|
+
ctx.stdout(formatList());
|
|
172
|
+
return { exitCode: 0 };
|
|
173
|
+
}
|
|
174
|
+
if (sub === 'show') {
|
|
175
|
+
const packId = rest.find((a) => a !== 'show' && !a.startsWith('-'));
|
|
176
|
+
const pack = packId ? resolveSkillsPack(packId) : undefined;
|
|
177
|
+
if (!pack) {
|
|
178
|
+
ctx.stderr(`kit skills: unknown skills pack '${packId ?? '(missing)'}'\n`);
|
|
179
|
+
return { exitCode: 1, message: 'unknown or missing pack id' };
|
|
180
|
+
}
|
|
181
|
+
ctx.stdout(formatShow(pack.id));
|
|
182
|
+
return { exitCode: 0 };
|
|
183
|
+
}
|
|
184
|
+
if (sub === 'for-stack') {
|
|
185
|
+
const stackId = rest.find((a) => a !== 'for-stack' && !a.startsWith('-'));
|
|
186
|
+
if (!stackId || !resolveStackPack(stackId)) {
|
|
187
|
+
ctx.stderr(
|
|
188
|
+
`kit skills: unknown stack '${stackId ?? '(missing)'}'. Known stacks: node-typescript, react-typescript, ruby-rails, ruby, python, go\n`,
|
|
189
|
+
);
|
|
190
|
+
return { exitCode: 1, message: 'unknown or missing stack id' };
|
|
191
|
+
}
|
|
192
|
+
if (!defaultSkillsPackForStack(stackId)) {
|
|
193
|
+
ctx.stderr(`kit skills: no skills pack covers stack '${stackId}' yet\n`);
|
|
194
|
+
return { exitCode: 1, message: `no pack for stack: ${stackId}` };
|
|
195
|
+
}
|
|
196
|
+
ctx.stdout(formatForStack(stackId));
|
|
197
|
+
return { exitCode: 0 };
|
|
198
|
+
}
|
|
199
|
+
if (sub === 'recommend') {
|
|
200
|
+
const stackId = optValue(rest, '--stack');
|
|
201
|
+
const stage = optValue(rest, '--stage');
|
|
202
|
+
if (!stackId || !defaultSkillsPackForStack(stackId)) {
|
|
203
|
+
ctx.stderr(
|
|
204
|
+
`kit skills: recommend requires --stack with a pack-covered stack (node-typescript, react-typescript, ruby-rails, ruby)\n`,
|
|
205
|
+
);
|
|
206
|
+
return { exitCode: 1, message: 'missing or unsupported --stack' };
|
|
207
|
+
}
|
|
208
|
+
if (stage && !(WORKFLOW_STAGES as readonly string[]).includes(stage)) {
|
|
209
|
+
ctx.stderr(`kit skills: unknown stage '${stage}'. Stages: ${WORKFLOW_STAGES.join(', ')}\n`);
|
|
210
|
+
return { exitCode: 1, message: `unknown stage: ${stage}` };
|
|
211
|
+
}
|
|
212
|
+
ctx.stdout(formatRecommend(stackId, stage, hasFlag(rest, '--json')));
|
|
213
|
+
return { exitCode: 0 };
|
|
214
|
+
}
|
|
215
|
+
if (sub === 'install') {
|
|
216
|
+
const packId = rest.find((a) => a !== 'install' && !a.startsWith('-'));
|
|
217
|
+
if (!packId) {
|
|
218
|
+
ctx.stderr(
|
|
219
|
+
'kit skills: install requires a pack id (ruby-agent-skills, node-agent-skills, react-agent-skills)\n',
|
|
220
|
+
);
|
|
221
|
+
return { exitCode: 1, message: 'missing pack id' };
|
|
222
|
+
}
|
|
223
|
+
const dirArg = optValue(rest, '--dir');
|
|
224
|
+
const targetRoot = path.resolve(ctx.cwd, dirArg ?? '.');
|
|
225
|
+
const stat = await fs.stat(targetRoot).catch(() => null);
|
|
226
|
+
if (!stat?.isDirectory()) {
|
|
227
|
+
ctx.stderr(`kit skills: target directory does not exist: ${targetRoot}\n`);
|
|
228
|
+
return { exitCode: 1, message: `target directory not found: ${targetRoot}` };
|
|
229
|
+
}
|
|
230
|
+
return runSkillsInstall(
|
|
231
|
+
{
|
|
232
|
+
packId,
|
|
233
|
+
targetRoot,
|
|
234
|
+
into: optValue(rest, '--into'),
|
|
235
|
+
ref: optValue(rest, '--ref'),
|
|
236
|
+
source: optValue(rest, '--source'),
|
|
237
|
+
force: hasFlag(rest, '--force'),
|
|
238
|
+
dryRun: hasFlag(rest, '--dry-run'),
|
|
239
|
+
json: hasFlag(rest, '--json'),
|
|
240
|
+
},
|
|
241
|
+
ctx,
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
ctx.stderr(`kit skills: unknown subcommand '${sub}'\nRun 'kit skills --help' for usage.\n`);
|
|
245
|
+
return { exitCode: 1, message: `unknown subcommand: ${sub}` };
|
|
246
|
+
},
|
|
247
|
+
};
|