@agentic-sdlc-kit/cli 0.8.0 → 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/dist/application/agent/execution-store.d.ts.map +1 -1
- package/dist/application/agent/execution-store.js +2 -1
- package/dist/application/agent/execution-store.js.map +1 -1
- package/dist/application/agent/orchestrator.d.ts.map +1 -1
- package/dist/application/agent/orchestrator.js +2 -2
- package/dist/application/agent/orchestrator.js.map +1 -1
- package/dist/application/dispatcher.d.ts.map +1 -1
- package/dist/application/dispatcher.js +12 -0
- package/dist/application/dispatcher.js.map +1 -1
- package/dist/application/version.d.ts +1 -1
- package/dist/application/version.js +1 -1
- 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/fix.d.ts +1 -0
- package/dist/commands/fix.d.ts.map +1 -1
- package/dist/commands/fix.js +42 -50
- package/dist/commands/fix.js.map +1 -1
- 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 +4 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +4 -0
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +5 -3
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/install.d.ts.map +1 -1
- package/dist/commands/install.js +15 -7
- package/dist/commands/install.js.map +1 -1
- package/dist/commands/plugin-linker.d.ts +10 -1
- package/dist/commands/plugin-linker.d.ts.map +1 -1
- package/dist/commands/plugin-linker.js +53 -14
- package/dist/commands/plugin-linker.js.map +1 -1
- 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/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/package.json +4 -4
- package/src/application/agent/execution-store.ts +2 -1
- package/src/application/agent/orchestrator.ts +2 -1
- package/src/application/dispatcher.test.ts +22 -3
- package/src/application/dispatcher.ts +8 -0
- package/src/application/version.ts +1 -1
- 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/doctor.test.ts +1 -1
- package/src/commands/fix.test.ts +95 -13
- package/src/commands/fix.ts +44 -55
- 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 +4 -0
- package/src/commands/init.test.ts +22 -0
- package/src/commands/init.ts +10 -3
- package/src/commands/install.test.ts +31 -0
- package/src/commands/install.ts +21 -7
- package/src/commands/plugin-linker.test.ts +80 -0
- package/src/commands/plugin-linker.ts +62 -14
- 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/uninstall.test.ts +122 -0
- package/src/commands/uninstall.ts +116 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uninstall.d.ts","sourceRoot":"","sources":["../../src/commands/uninstall.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,OAAO,EAAiC,MAAM,YAAY,CAAC;AAqDzE,eAAO,MAAM,gBAAgB,EAAE,OAkD9B,CAAC"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// packages/cli/src/commands/uninstall.ts
|
|
2
|
+
//
|
|
3
|
+
// `kit uninstall [--dir <path>] [--dry-run] [--json]`. Removes only what
|
|
4
|
+
// `kit install` recorded in the ownership manifest: files whose content is
|
|
5
|
+
// unchanged since install, and plugin symlinks (the link, never its target).
|
|
6
|
+
// Files the user edited or that were never ours are kept and reported.
|
|
7
|
+
import crypto from 'node:crypto';
|
|
8
|
+
import { promises as fs } from 'node:fs';
|
|
9
|
+
import path from 'node:path';
|
|
10
|
+
import { OwnershipManifestSchema } from '@agentic-sdlc-kit/contracts';
|
|
11
|
+
import { linkTarget } from './plugin-linker.js';
|
|
12
|
+
const MANIFEST_PATH = '.ai-kit/ownership-manifest.json';
|
|
13
|
+
const sha256 = (text) => crypto.createHash('sha256').update(text, 'utf8').digest('hex');
|
|
14
|
+
/** True only when `full` stays inside `root` (a manifest must never reach outside it). */
|
|
15
|
+
function isInside(root, full) {
|
|
16
|
+
const rel = path.relative(root, full);
|
|
17
|
+
return rel !== '' && !rel.startsWith('..') && !path.isAbsolute(rel);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A recorded link is the kit's only while it still points where the kit
|
|
21
|
+
* pointed it. Entries from before `target` existed are verified by content:
|
|
22
|
+
* the plugin identity file read through the link must hash to the recorded value.
|
|
23
|
+
*/
|
|
24
|
+
async function ownsLink(full, entry) {
|
|
25
|
+
if (entry.target !== undefined)
|
|
26
|
+
return (await linkTarget(full)) === entry.target;
|
|
27
|
+
const identity = await fs
|
|
28
|
+
.readFile(path.join(full, '.claude-plugin', 'plugin.json'), 'utf8')
|
|
29
|
+
.catch(() => undefined);
|
|
30
|
+
return identity !== undefined && sha256(identity) === entry.sha256;
|
|
31
|
+
}
|
|
32
|
+
async function judge(root, entry) {
|
|
33
|
+
const full = path.resolve(root, entry.path);
|
|
34
|
+
if (!isInside(root, full))
|
|
35
|
+
return 'keep-foreign';
|
|
36
|
+
const stat = await fs.lstat(full).catch(() => null);
|
|
37
|
+
if (!stat)
|
|
38
|
+
return 'missing';
|
|
39
|
+
if (stat.isSymbolicLink())
|
|
40
|
+
return (await ownsLink(full, entry)) ? 'remove' : 'keep-foreign';
|
|
41
|
+
if (!stat.isFile())
|
|
42
|
+
return 'keep-foreign'; // a real directory is never ours to delete
|
|
43
|
+
const content = await fs.readFile(full, 'utf8');
|
|
44
|
+
return sha256(content) === entry.sha256 ? 'remove' : 'keep-modified';
|
|
45
|
+
}
|
|
46
|
+
/** One bad entry must not abort the run half-way: anything unjudgeable is kept. */
|
|
47
|
+
async function safeJudge(root, entry) {
|
|
48
|
+
try {
|
|
49
|
+
return await judge(root, entry);
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return 'keep-foreign';
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async function readManifest(root) {
|
|
56
|
+
const raw = await fs.readFile(path.join(root, MANIFEST_PATH), 'utf8').catch(() => undefined);
|
|
57
|
+
if (raw === undefined)
|
|
58
|
+
return undefined;
|
|
59
|
+
return OwnershipManifestSchema.parse(JSON.parse(raw)).entries;
|
|
60
|
+
}
|
|
61
|
+
export const uninstallCommand = {
|
|
62
|
+
name: 'uninstall',
|
|
63
|
+
summary: 'Remove files and plugin links that kit install created and you have not edited.',
|
|
64
|
+
async run(ctx) {
|
|
65
|
+
const dryRun = ctx.argv.includes('--dry-run');
|
|
66
|
+
const dirIdx = ctx.argv.indexOf('--dir');
|
|
67
|
+
const dirArg = dirIdx !== -1 ? ctx.argv[dirIdx + 1] : undefined;
|
|
68
|
+
if (dirIdx !== -1 && (!dirArg || dirArg.startsWith('-'))) {
|
|
69
|
+
ctx.stderr('kit uninstall: --dir requires a directory path\n');
|
|
70
|
+
return { exitCode: 1, message: 'missing --dir value' };
|
|
71
|
+
}
|
|
72
|
+
const root = path.resolve(ctx.cwd, dirArg ?? '.');
|
|
73
|
+
let entries;
|
|
74
|
+
try {
|
|
75
|
+
entries = await readManifest(root);
|
|
76
|
+
}
|
|
77
|
+
catch (err) {
|
|
78
|
+
ctx.stderr(`kit uninstall: unreadable ownership manifest in ${root}: ${String(err)}\n`);
|
|
79
|
+
return { exitCode: 1, message: 'invalid ownership manifest' };
|
|
80
|
+
}
|
|
81
|
+
if (!entries) {
|
|
82
|
+
ctx.stderr(`kit uninstall: no ${MANIFEST_PATH} in ${root}; nothing owned to remove\n`);
|
|
83
|
+
return { exitCode: 1, message: 'no ownership manifest' };
|
|
84
|
+
}
|
|
85
|
+
const removed = [];
|
|
86
|
+
const kept = [];
|
|
87
|
+
const foreign = [];
|
|
88
|
+
for (const entry of entries) {
|
|
89
|
+
const verdict = await safeJudge(root, entry);
|
|
90
|
+
if (verdict === 'keep-modified')
|
|
91
|
+
kept.push(entry.path);
|
|
92
|
+
if (verdict === 'keep-foreign')
|
|
93
|
+
foreign.push(entry.path);
|
|
94
|
+
if (verdict !== 'remove')
|
|
95
|
+
continue;
|
|
96
|
+
if (!dryRun)
|
|
97
|
+
await fs.rm(path.resolve(root, entry.path), { force: true });
|
|
98
|
+
removed.push(entry.path);
|
|
99
|
+
}
|
|
100
|
+
if (!dryRun)
|
|
101
|
+
await fs.rm(path.join(root, MANIFEST_PATH), { force: true });
|
|
102
|
+
const label = dryRun ? 'would remove' : 'removed';
|
|
103
|
+
ctx.stdout([
|
|
104
|
+
`kit uninstall${dryRun ? ' --dry-run' : ''}`,
|
|
105
|
+
...removed.map((p) => ` ${label} ${p}`),
|
|
106
|
+
...kept.map((p) => ` kept (edited since install) ${p}`),
|
|
107
|
+
...foreign.map((p) => ` kept (not a file or link the kit created) ${p}`),
|
|
108
|
+
'',
|
|
109
|
+
].join('\n'));
|
|
110
|
+
return { exitCode: 0 };
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
//# sourceMappingURL=uninstall.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uninstall.js","sourceRoot":"","sources":["../../src/commands/uninstall.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,yEAAyE;AACzE,2EAA2E;AAC3E,6EAA6E;AAC7E,uEAAuE;AAEvE,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAA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AAC,KAAK,KAAK,KAAK,CAAC,EAAE,CAAC;YACzC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,kCAAkC,CAAC,EAAE,CAAC;YACzD,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,gDAAgD,CAAC,EAAE,CAAC;YAC1E,EAAE;SACH,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,CAAC;QACF,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;IACzB,CAAC;CACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentic-sdlc-kit/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "The `kit` executable: user-facing entry point for the Agentic SDLC Kit.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
"src"
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@agentic-sdlc-kit/contracts": "0.
|
|
24
|
-
"@agentic-sdlc-kit/core": "0.
|
|
23
|
+
"@agentic-sdlc-kit/contracts": "0.9.1",
|
|
24
|
+
"@agentic-sdlc-kit/core": "0.9.1"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@agentic-sdlc-kit/testing": "0.
|
|
27
|
+
"@agentic-sdlc-kit/testing": "0.9.1",
|
|
28
28
|
"@types/node": "^20.14.0",
|
|
29
29
|
"typescript": "^5.5.0",
|
|
30
30
|
"vitest": "^2.0.0"
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
import { promises as fs } from 'node:fs';
|
|
19
19
|
import path from 'node:path';
|
|
20
|
+
import { kitStateRoot } from '@agentic-sdlc-kit/core';
|
|
20
21
|
import type {
|
|
21
22
|
AgentExecutionEvent,
|
|
22
23
|
AgentExecutionRequest,
|
|
@@ -85,7 +86,7 @@ export function validateExecutionId(executionId: string): boolean {
|
|
|
85
86
|
}
|
|
86
87
|
|
|
87
88
|
export function executionStoreDir(projectRoot: string): string {
|
|
88
|
-
return path.
|
|
89
|
+
return path.join(kitStateRoot(projectRoot), 'state', 'agent-executions');
|
|
89
90
|
}
|
|
90
91
|
|
|
91
92
|
export function executionRecordPath(projectRoot: string, executionId: string): string {
|
|
@@ -47,6 +47,7 @@ import {
|
|
|
47
47
|
import {
|
|
48
48
|
finalizeFeatureRun,
|
|
49
49
|
getFeatureRunState,
|
|
50
|
+
kitStateRoot,
|
|
50
51
|
loadPlan,
|
|
51
52
|
loadSpecification,
|
|
52
53
|
runTddPhase,
|
|
@@ -150,7 +151,7 @@ const DEFAULT_MAX_DURATION_MS = 600_000;
|
|
|
150
151
|
const DEFAULT_MAX_TOOL_CALLS = 200;
|
|
151
152
|
|
|
152
153
|
function orchestrationPath(projectRoot: string, featureId: string): string {
|
|
153
|
-
return path.
|
|
154
|
+
return path.join(kitStateRoot(projectRoot), 'state', 'orchestrations', `${featureId}.json`);
|
|
154
155
|
}
|
|
155
156
|
|
|
156
157
|
/**
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
// packages/cli/src/application/dispatcher.test.ts
|
|
2
|
+
import { readFileSync } from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
2
5
|
import { describe, expect, it } from 'vitest';
|
|
3
6
|
import { createDispatcher } from './dispatcher.js';
|
|
4
7
|
import type { CommandContext } from '../commands/types.js';
|
|
@@ -24,7 +27,7 @@ describe('dispatcher', () => {
|
|
|
24
27
|
const ctx = makeCtx(['--version']);
|
|
25
28
|
const r = await dispatch(ctx);
|
|
26
29
|
expect(r.exitCode).toBe(0);
|
|
27
|
-
expect(r.message).toBe('0.
|
|
30
|
+
expect(r.message).toBe('0.9.1');
|
|
28
31
|
expect(r.command).toBe('version');
|
|
29
32
|
});
|
|
30
33
|
|
|
@@ -33,7 +36,7 @@ describe('dispatcher', () => {
|
|
|
33
36
|
const ctx = makeCtx(['-v']);
|
|
34
37
|
const r = await dispatch(ctx);
|
|
35
38
|
expect(r.exitCode).toBe(0);
|
|
36
|
-
expect(r.message).toBe('0.
|
|
39
|
+
expect(r.message).toBe('0.9.1');
|
|
37
40
|
});
|
|
38
41
|
|
|
39
42
|
it('handles --help', async () => {
|
|
@@ -74,7 +77,7 @@ describe('dispatcher', () => {
|
|
|
74
77
|
const r = await dispatch(ctx);
|
|
75
78
|
expect(r.exitCode).toBe(0);
|
|
76
79
|
expect(r.command).toBe('doctor');
|
|
77
|
-
expect(ctx.out[0]).toContain('kit 0.
|
|
80
|
+
expect(ctx.out[0]).toContain('kit 0.9.1');
|
|
78
81
|
expect(ctx.out[0]).toContain('node');
|
|
79
82
|
});
|
|
80
83
|
|
|
@@ -87,3 +90,19 @@ describe('dispatcher', () => {
|
|
|
87
90
|
expect(ctx.err[0]).toContain("unknown command 'bogus'");
|
|
88
91
|
});
|
|
89
92
|
});
|
|
93
|
+
|
|
94
|
+
// The docs quote the command count in prose; it drifted (16 vs 17 vs the real
|
|
95
|
+
// registry size) because nothing tied them together. This does.
|
|
96
|
+
describe('documented command count', () => {
|
|
97
|
+
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..', '..', '..');
|
|
98
|
+
it.each([
|
|
99
|
+
['README.md', /\((\d+) commands\)/],
|
|
100
|
+
['README.md', /provides (\d+) commands/],
|
|
101
|
+
['AGENTS.md', /\((\d+) commands\)/],
|
|
102
|
+
])('%s states the registry size (%s)', (file, re) => {
|
|
103
|
+
const size = createDispatcher().registry.list().length;
|
|
104
|
+
const match = re.exec(readFileSync(path.join(root, file), 'utf8'));
|
|
105
|
+
expect(match, `${file} must state the command count`).not.toBeNull();
|
|
106
|
+
expect(Number(match![1])).toBe(size);
|
|
107
|
+
});
|
|
108
|
+
});
|
|
@@ -16,12 +16,16 @@ import { featureCommand } from '../commands/feature.js';
|
|
|
16
16
|
import { newCommand } from '../commands/new.js';
|
|
17
17
|
import { fixCommand } from '../commands/fix.js';
|
|
18
18
|
import { installCommand } from '../commands/install.js';
|
|
19
|
+
import { uninstallCommand } from '../commands/uninstall.js';
|
|
19
20
|
import { memoryCommand } from '../commands/memory.js';
|
|
20
21
|
import { evolveCommand } from '../commands/evolve.js';
|
|
21
22
|
import { refactorCommand } from '../commands/refactor.js';
|
|
22
23
|
import { optimizeCommand } from '../commands/optimize.js';
|
|
23
24
|
import { nextCommand } from '../commands/next.js';
|
|
24
25
|
import { journalCommand } from '../commands/journal.js';
|
|
26
|
+
import { skillsCommand } from '../commands/skills.js';
|
|
27
|
+
import { attachCommand } from '../commands/attach.js';
|
|
28
|
+
import { hostCommand } from '../commands/host.js';
|
|
25
29
|
import type { Command, CommandContext, CommandResult } from '../commands/types.js';
|
|
26
30
|
import { createCommandRegistry, type CommandRegistry } from './registry.js';
|
|
27
31
|
import { VERSION } from './version.js';
|
|
@@ -52,12 +56,16 @@ export function createDispatcher(opts: DispatcherOptions = {}): {
|
|
|
52
56
|
if (!registry.get('new')) registry.register(newCommand);
|
|
53
57
|
if (!registry.get('fix')) registry.register(fixCommand);
|
|
54
58
|
if (!registry.get('install')) registry.register(installCommand);
|
|
59
|
+
if (!registry.get('uninstall')) registry.register(uninstallCommand);
|
|
55
60
|
if (!registry.get('memory')) registry.register(memoryCommand);
|
|
56
61
|
if (!registry.get('evolve')) registry.register(evolveCommand);
|
|
57
62
|
if (!registry.get('refactor')) registry.register(refactorCommand);
|
|
58
63
|
if (!registry.get('optimize')) registry.register(optimizeCommand);
|
|
59
64
|
if (!registry.get('next')) registry.register(nextCommand);
|
|
60
65
|
if (!registry.get('journal')) registry.register(journalCommand);
|
|
66
|
+
if (!registry.get('skills')) registry.register(skillsCommand);
|
|
67
|
+
if (!registry.get('attach')) registry.register(attachCommand);
|
|
68
|
+
if (!registry.get('host')) registry.register(hostCommand);
|
|
61
69
|
if (!registry.get('help')) registry.register(makeHelpCommand(registry));
|
|
62
70
|
|
|
63
71
|
return {
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// packages/cli/src/commands/attach-exclude.ts
|
|
2
|
+
//
|
|
3
|
+
// Managed block inside `.git/info/exclude`. Patterns carry NO trailing slash:
|
|
4
|
+
// a slash-suffixed gitignore pattern matches directories only and git treats
|
|
5
|
+
// a symlink as a file, so the symlinked (global) mode would leak.
|
|
6
|
+
|
|
7
|
+
import { promises as fs } from 'node:fs';
|
|
8
|
+
import path from 'node:path';
|
|
9
|
+
|
|
10
|
+
export const BLOCK_BEGIN = '# >>> kit-attach managed block >>>';
|
|
11
|
+
export const BLOCK_END = '# <<< kit-attach managed block <<<';
|
|
12
|
+
|
|
13
|
+
export function stripBlock(text: string): string {
|
|
14
|
+
const out: string[] = [];
|
|
15
|
+
let skip = false;
|
|
16
|
+
for (const line of text.split('\n')) {
|
|
17
|
+
if (line === BLOCK_BEGIN) skip = true;
|
|
18
|
+
if (!skip) out.push(line);
|
|
19
|
+
if (line === BLOCK_END) skip = false;
|
|
20
|
+
}
|
|
21
|
+
return out.join('\n');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function withBlock(text: string, paths: readonly string[]): string {
|
|
25
|
+
const base = stripBlock(text).replace(/\n*$/, '');
|
|
26
|
+
const block = [BLOCK_BEGIN, ...paths, BLOCK_END].join('\n');
|
|
27
|
+
return (base ? base + '\n' : '') + block + '\n';
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async function readOrEmpty(file: string): Promise<string> {
|
|
31
|
+
try {
|
|
32
|
+
return await fs.readFile(file, 'utf8');
|
|
33
|
+
} catch {
|
|
34
|
+
return '';
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export async function writeBlock(file: string, paths: readonly string[]): Promise<void> {
|
|
39
|
+
await fs.mkdir(path.dirname(file), { recursive: true });
|
|
40
|
+
await fs.writeFile(file, withBlock(await readOrEmpty(file), paths));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export async function removeBlock(file: string): Promise<void> {
|
|
44
|
+
const text = await readOrEmpty(file);
|
|
45
|
+
if (text.includes(BLOCK_BEGIN)) await fs.writeFile(file, stripBlock(text));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export async function hasBlock(file: string): Promise<boolean> {
|
|
49
|
+
return (await readOrEmpty(file)).includes(BLOCK_BEGIN);
|
|
50
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// packages/cli/src/commands/attach-git.ts
|
|
2
|
+
//
|
|
3
|
+
// Thin git helpers for `kit attach`. All calls use argument arrays (never a
|
|
4
|
+
// shell string) so paths with spaces or metacharacters cannot be injected.
|
|
5
|
+
|
|
6
|
+
import { execFileSync } from 'node:child_process';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
|
|
9
|
+
export interface RepoInfo {
|
|
10
|
+
/** Working-tree root of the repository (or linked worktree). */
|
|
11
|
+
root: string;
|
|
12
|
+
/** Shared git dir: where `info/exclude` must live so linked worktrees agree. */
|
|
13
|
+
commonDir: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function git(cwd: string, args: readonly string[]): string {
|
|
17
|
+
return execFileSync('git', [...args], {
|
|
18
|
+
cwd,
|
|
19
|
+
encoding: 'utf8',
|
|
20
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function resolveRepo(cwd: string): RepoInfo | null {
|
|
25
|
+
try {
|
|
26
|
+
const root = git(cwd, ['rev-parse', '--show-toplevel']).trim();
|
|
27
|
+
const common = git(root, ['rev-parse', '--git-common-dir']).trim();
|
|
28
|
+
return { root, commonDir: path.resolve(root, common) };
|
|
29
|
+
} catch {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function hasTrackedFiles(root: string, rel: string): boolean {
|
|
35
|
+
return git(root, ['ls-files', '--', rel]).trim().length > 0;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function isIgnored(root: string, rel: string): boolean {
|
|
39
|
+
try {
|
|
40
|
+
git(root, ['check-ignore', '-q', '--', rel]);
|
|
41
|
+
return true;
|
|
42
|
+
} catch {
|
|
43
|
+
return false; // exit 1 = not ignored
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function statusLeaks(root: string, rels: readonly string[]): string[] {
|
|
48
|
+
const out = git(root, ['status', '--porcelain', '--', ...rels]);
|
|
49
|
+
return out.split('\n').filter((l) => l.length > 0);
|
|
50
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// packages/cli/src/commands/attach-store.ts
|
|
2
|
+
//
|
|
3
|
+
// Filesystem operations for `kit attach local|global|detach`.
|
|
4
|
+
|
|
5
|
+
import { createHash } from 'node:crypto';
|
|
6
|
+
import { promises as fs, type Stats } from 'node:fs';
|
|
7
|
+
import os from 'node:os';
|
|
8
|
+
import path from 'node:path';
|
|
9
|
+
|
|
10
|
+
export const MANAGED_PATHS: readonly string[] = [
|
|
11
|
+
'.ai-kit',
|
|
12
|
+
'.claude',
|
|
13
|
+
'docs/specifications',
|
|
14
|
+
'docs/plans',
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
export class AttachError extends Error {}
|
|
18
|
+
|
|
19
|
+
export function storeDirFor(root: string, env: NodeJS.ProcessEnv = process.env): string {
|
|
20
|
+
const base = env['KIT_ATTACH_HOME'] ?? path.join(os.homedir(), '.agentic-sdlc', 'projects');
|
|
21
|
+
const hash = createHash('sha256').update(root).digest('hex').slice(0, 8);
|
|
22
|
+
return path.join(base, `${path.basename(root)}-${hash}`);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const storeBase = (storeDir: string): string => path.dirname(storeDir);
|
|
26
|
+
|
|
27
|
+
async function lstatOrNull(p: string): Promise<Stats | null> {
|
|
28
|
+
try {
|
|
29
|
+
return await fs.lstat(p);
|
|
30
|
+
} catch {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export async function attachLocal(root: string): Promise<void> {
|
|
36
|
+
for (const rel of MANAGED_PATHS) {
|
|
37
|
+
const abs = path.join(root, rel);
|
|
38
|
+
if ((await lstatOrNull(abs))?.isSymbolicLink()) {
|
|
39
|
+
throw new AttachError(`'${rel}' is a symlink; run 'kit attach detach' before switching modes`);
|
|
40
|
+
}
|
|
41
|
+
await fs.mkdir(abs, { recursive: true });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async function linkOne(root: string, storeDir: string, rel: string, adopt: boolean): Promise<void> {
|
|
46
|
+
const abs = path.join(root, rel);
|
|
47
|
+
const target = path.join(storeDir, rel);
|
|
48
|
+
await fs.mkdir(target, { recursive: true });
|
|
49
|
+
await fs.mkdir(path.dirname(abs), { recursive: true });
|
|
50
|
+
const st = await lstatOrNull(abs);
|
|
51
|
+
if (st?.isSymbolicLink()) {
|
|
52
|
+
if ((await fs.readlink(abs)) !== target) {
|
|
53
|
+
throw new AttachError(`'${rel}' points elsewhere; refusing to touch it`);
|
|
54
|
+
}
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (st) await migrateExisting(abs, target, rel, adopt);
|
|
58
|
+
await fs.symlink(target, abs, 'dir');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async function migrateExisting(abs: string, target: string, rel: string, adopt: boolean): Promise<void> {
|
|
62
|
+
const st = await fs.lstat(abs);
|
|
63
|
+
if (!st.isDirectory()) throw new AttachError(`'${rel}' exists and is not a directory`);
|
|
64
|
+
if ((await fs.readdir(abs)).length > 0) {
|
|
65
|
+
if (!adopt) {
|
|
66
|
+
throw new AttachError(`'${rel}' has content; re-run with --adopt to migrate it into the store`);
|
|
67
|
+
}
|
|
68
|
+
await fs.cp(abs, target, { recursive: true });
|
|
69
|
+
}
|
|
70
|
+
await fs.rm(abs, { recursive: true, force: true });
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export async function attachGlobal(root: string, storeDir: string, adopt: boolean): Promise<void> {
|
|
74
|
+
// Preflight so a refusal on a later path cannot leave a half-attached repo.
|
|
75
|
+
for (const rel of MANAGED_PATHS) await preflight(path.join(root, rel), rel, adopt);
|
|
76
|
+
for (const rel of MANAGED_PATHS) await linkOne(root, storeDir, rel, adopt);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async function preflight(abs: string, rel: string, adopt: boolean): Promise<void> {
|
|
80
|
+
const st = await lstatOrNull(abs);
|
|
81
|
+
if (!st || st.isSymbolicLink()) return;
|
|
82
|
+
if (!st.isDirectory()) throw new AttachError(`'${rel}' exists and is not a directory`);
|
|
83
|
+
if (!adopt && (await fs.readdir(abs)).length > 0) {
|
|
84
|
+
throw new AttachError(`'${rel}' has content; re-run with --adopt to migrate it into the store`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export async function detachLinks(root: string, base: string): Promise<string[]> {
|
|
89
|
+
const removed: string[] = [];
|
|
90
|
+
for (const rel of MANAGED_PATHS) {
|
|
91
|
+
const abs = path.join(root, rel);
|
|
92
|
+
if (!(await lstatOrNull(abs))?.isSymbolicLink()) continue;
|
|
93
|
+
const dest = await fs.readlink(abs);
|
|
94
|
+
if (!dest.startsWith(base + path.sep)) continue; // not ours
|
|
95
|
+
await fs.unlink(abs);
|
|
96
|
+
removed.push(rel);
|
|
97
|
+
}
|
|
98
|
+
return removed;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export async function describePath(root: string, rel: string): Promise<string> {
|
|
102
|
+
const abs = path.join(root, rel);
|
|
103
|
+
const st = await lstatOrNull(abs);
|
|
104
|
+
if (!st) return `${rel} (absent)`;
|
|
105
|
+
if (st.isSymbolicLink()) return `${rel} -> ${await fs.readlink(abs)} (global)`;
|
|
106
|
+
return `${rel} (local dir)`;
|
|
107
|
+
}
|