agent-manifesto-kit 0.0.0-development → 1.0.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/README.md +44 -6
- package/dist/cli.js +19 -10
- package/dist/commands/adopt.js +240 -40
- package/dist/commands/aiadopt.js +95 -0
- package/dist/providers.js +3 -6
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -34,6 +34,8 @@ Options for `adopt`:
|
|
|
34
34
|
| Option | Default | Meaning |
|
|
35
35
|
|---|---|---|
|
|
36
36
|
| `--provider claude\|codex\|agnostic` | `claude` | target AI provider |
|
|
37
|
+
| `--cli <cli>` | _(none)_ | run an AI CLI after adoption to adapt files to your project |
|
|
38
|
+
| `--force` | _(off)_ | overwrite existing targets without prompting |
|
|
37
39
|
| `--dest <dir>` | current directory | target project root |
|
|
38
40
|
|
|
39
41
|
Global: `--version` / `-v`, `--help` / `-h`.
|
|
@@ -41,18 +43,54 @@ Global: `--version` / `-v`, `--help` / `-h`.
|
|
|
41
43
|
### Bundles
|
|
42
44
|
|
|
43
45
|
A bundle is a cohesive set of capabilities meant to be adopted together (for example `sdd`,
|
|
44
|
-
the Spec-Driven Development kit). Adopting a bundle
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
the Spec-Driven Development kit). Adopting a bundle explodes it into type-specific directories
|
|
47
|
+
(`.claude/skills/`, `.claude/agents/`, etc.) so each capability lands where the provider
|
|
48
|
+
expects to find it. Recommended companions are surfaced as opt-in follow-ups and are never
|
|
49
|
+
installed automatically.
|
|
48
50
|
|
|
49
51
|
```bash
|
|
50
|
-
agentkit adopt sdd --provider claude # the whole SDD bundle
|
|
51
|
-
agentkit adopt brainstorm # a single skill from the
|
|
52
|
+
agentkit adopt sdd --provider claude # adopt the whole SDD bundle
|
|
53
|
+
agentkit adopt brainstorm # adopt a single skill from the collection
|
|
52
54
|
```
|
|
53
55
|
|
|
54
56
|
Items that live inside a bundle are adopted as part of that bundle, not on their own.
|
|
55
57
|
|
|
58
|
+
### AI-assisted adaptation with `--cli`
|
|
59
|
+
|
|
60
|
+
After copying the files, `--cli` launches an AI CLI with a structured prompt that asks it to
|
|
61
|
+
read your project's context (CLAUDE.md / AGENTS.md, README, spec files) and adapt each
|
|
62
|
+
adopted file to your project's naming, paths, and conventions.
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
# Adopt the SDD bundle and let Claude adapt it to this project
|
|
66
|
+
agentkit adopt sdd --provider claude --cli claude
|
|
67
|
+
|
|
68
|
+
# Same, but force-overwrite files that already exist
|
|
69
|
+
agentkit adopt sdd --provider claude --cli claude --force
|
|
70
|
+
|
|
71
|
+
# Adopt a single skill for Codex and adapt with agy
|
|
72
|
+
agentkit adopt brainstorm --provider codex --cli agy
|
|
73
|
+
|
|
74
|
+
# Adopt without AI adaptation (deterministic copy only)
|
|
75
|
+
agentkit adopt sdd --provider agnostic
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Supported CLIs: `claude`, `codex`, `agy`, `aider`, `opencode`, `grok`, `kilo`, `qwen`.
|
|
79
|
+
|
|
80
|
+
The AI step runs non-interactively — permission prompts are pre-approved where each CLI
|
|
81
|
+
supports it (`--dangerously-skip-permissions` for claude and agy, `--yes-always` for aider).
|
|
82
|
+
|
|
83
|
+
### Conflict resolution
|
|
84
|
+
|
|
85
|
+
When a target already exists and `--force` is not set, `adopt` asks per file:
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
Target already exists: .claude/skills/brainstorm
|
|
89
|
+
[r] replace [s] skip [A] replace all [S] skip all: _
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
`A` and `S` apply the choice to all remaining conflicts in the same run.
|
|
93
|
+
|
|
56
94
|
### Provider model
|
|
57
95
|
|
|
58
96
|
`adopt` is a deterministic, AI-free transform. Capabilities are authored provider-neutral, so
|
package/dist/cli.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { list } from "./commands/list.js";
|
|
5
|
-
import { adopt } from "./commands/adopt.js";
|
|
5
|
+
import { adopt, isSupportedCli, SUPPORTED_CLIS } from "./commands/adopt.js";
|
|
6
6
|
import { runLint } from "./commands/lint.js";
|
|
7
7
|
import { isProvider } from "./providers.js";
|
|
8
8
|
import { packageRoot } from "./catalog.js";
|
|
@@ -46,18 +46,24 @@ function help() {
|
|
|
46
46
|
Usage:
|
|
47
47
|
agentkit list
|
|
48
48
|
agentkit lint [name]
|
|
49
|
-
agentkit adopt <name> [--provider claude|codex|agnostic] [--dest <dir>]
|
|
49
|
+
agentkit adopt <name> [--provider claude|codex|agnostic] [--dest <dir>] [--force] [--cli <cli>]
|
|
50
50
|
|
|
51
51
|
<name> is a capability (skill/agent/pipeline/convention) or a bundle.
|
|
52
|
-
Adopting a bundle
|
|
52
|
+
Adopting a bundle explodes it into type-specific directories.
|
|
53
|
+
|
|
54
|
+
Pass --cli to run an AI assistant after adoption to adapt the files to your project.
|
|
55
|
+
Pass --force to overwrite existing targets without prompting.
|
|
53
56
|
|
|
54
57
|
Options:
|
|
55
58
|
--provider target AI provider (default: claude)
|
|
59
|
+
--cli AI CLI to run after adoption for project-specific adaptation
|
|
60
|
+
supported: ${SUPPORTED_CLIS.join("|")}
|
|
61
|
+
--force overwrite existing targets without prompting
|
|
56
62
|
--dest target project root (default: current directory)
|
|
57
63
|
--version,-v print the installed version
|
|
58
64
|
--help,-h show this help`);
|
|
59
65
|
}
|
|
60
|
-
function main() {
|
|
66
|
+
async function main() {
|
|
61
67
|
const { positionals, flags } = parseArgs(process.argv.slice(2));
|
|
62
68
|
const cmd = positionals[0];
|
|
63
69
|
if (flags.version || flags.v) {
|
|
@@ -91,18 +97,21 @@ function main() {
|
|
|
91
97
|
console.error(`Invalid --provider "${provider}". Use claude|codex|agnostic.`);
|
|
92
98
|
return 1;
|
|
93
99
|
}
|
|
100
|
+
const cli = typeof flags.cli === "string" ? flags.cli : undefined;
|
|
101
|
+
if (cli !== undefined && !isSupportedCli(cli)) {
|
|
102
|
+
console.error(`Unknown --cli "${cli}". Supported: ${SUPPORTED_CLIS.join("|")}`);
|
|
103
|
+
return 1;
|
|
104
|
+
}
|
|
94
105
|
const projectRoot = typeof flags.dest === "string" ? flags.dest : process.cwd();
|
|
95
|
-
|
|
106
|
+
const force = flags.force === true;
|
|
107
|
+
return adopt({ name, provider, projectRoot, force, cli });
|
|
96
108
|
}
|
|
97
109
|
default:
|
|
98
110
|
console.error(`Unknown command "${cmd}". Run "agentkit --help".`);
|
|
99
111
|
return 1;
|
|
100
112
|
}
|
|
101
113
|
}
|
|
102
|
-
|
|
103
|
-
process.exit(main());
|
|
104
|
-
}
|
|
105
|
-
catch (err) {
|
|
114
|
+
main().then(process.exit).catch((err) => {
|
|
106
115
|
console.error(`agentkit: ${err instanceof Error ? err.message : String(err)}`);
|
|
107
116
|
process.exit(1);
|
|
108
|
-
}
|
|
117
|
+
});
|
package/dist/commands/adopt.js
CHANGED
|
@@ -1,8 +1,136 @@
|
|
|
1
|
-
import { cpSync, existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
|
|
1
|
+
import { cpSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, unlinkSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { createInterface } from "node:readline/promises";
|
|
3
|
+
import { spawn } from "node:child_process";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
2
5
|
import { dirname, join, relative } from "node:path";
|
|
3
6
|
import { findBundle, findCapability } from "../catalog.js";
|
|
4
|
-
import {
|
|
7
|
+
import { bundleExtrasDestination, destinationFor, wiringHint } from "../providers.js";
|
|
5
8
|
import { lint, transform } from "../portability.js";
|
|
9
|
+
export const SUPPORTED_CLIS = [
|
|
10
|
+
"claude", "codex", "agy", "aider", "opencode", "grok", "kilo", "qwen",
|
|
11
|
+
];
|
|
12
|
+
export function isSupportedCli(value) {
|
|
13
|
+
return SUPPORTED_CLIS.includes(value);
|
|
14
|
+
}
|
|
15
|
+
const CLI_INVOCATIONS = {
|
|
16
|
+
claude: { kind: "direct", args: (p) => ["claude", "--dangerously-skip-permissions", "-p", p] },
|
|
17
|
+
codex: { kind: "stdin", bin: "codex", args: ["exec", "--skip-git-repo-check", "-"] },
|
|
18
|
+
agy: { kind: "bash", cmd: 'agy --dangerously-skip-permissions -p "$(cat "$0")"' },
|
|
19
|
+
aider: { kind: "bash", cmd: 'aider --message "$(cat "$0")" --yes-always' },
|
|
20
|
+
opencode: { kind: "bash", cmd: 'opencode run "$(cat "$0")"' },
|
|
21
|
+
grok: { kind: "bash", cmd: 'grok -p "$(cat "$0")"' },
|
|
22
|
+
kilo: { kind: "bash", cmd: 'kilocode --auto "$(cat "$0")"' },
|
|
23
|
+
qwen: { kind: "bash", cmd: 'qwen --prompt "$(cat "$0")"' },
|
|
24
|
+
};
|
|
25
|
+
function buildPrompt(files) {
|
|
26
|
+
return `You have adopted the following AI capability files into this project:
|
|
27
|
+
${files.join("\n")}
|
|
28
|
+
|
|
29
|
+
Before editing anything:
|
|
30
|
+
1. Read CLAUDE.md (or AGENTS.md if present), README.md, and any project
|
|
31
|
+
specification files under .docs/ or .ai/docs/.
|
|
32
|
+
2. Build a clear picture of the project's domain, naming conventions,
|
|
33
|
+
file structure, tools in use, and vocabulary.
|
|
34
|
+
|
|
35
|
+
Adapt each file to this project:
|
|
36
|
+
- Replace generic references with project-specific names, paths, and terms
|
|
37
|
+
- Align tool references and file paths to what this project actually uses
|
|
38
|
+
- Preserve the file's structure, scope, and intent exactly
|
|
39
|
+
- Leave files that need no changes untouched`;
|
|
40
|
+
}
|
|
41
|
+
const SPINNER = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
|
42
|
+
// On Windows, `bash` in PATH resolves to the WSL relay (C:\Windows\System32\bash.exe),
|
|
43
|
+
// which fails when WSL has no distro or no /bin/bash. Prefer Git Bash explicitly.
|
|
44
|
+
function findBash() {
|
|
45
|
+
if (process.platform !== "win32")
|
|
46
|
+
return "bash";
|
|
47
|
+
const candidates = [
|
|
48
|
+
`${process.env.LOCALAPPDATA}\\Programs\\Git\\bin\\bash.exe`,
|
|
49
|
+
`${process.env.PROGRAMFILES}\\Git\\bin\\bash.exe`,
|
|
50
|
+
`${process.env["PROGRAMFILES(X86)"]}\\Git\\bin\\bash.exe`,
|
|
51
|
+
"C:\\Program Files\\Git\\bin\\bash.exe",
|
|
52
|
+
];
|
|
53
|
+
for (const c of candidates) {
|
|
54
|
+
try {
|
|
55
|
+
if (existsSync(c))
|
|
56
|
+
return c;
|
|
57
|
+
}
|
|
58
|
+
catch { /* skip */ }
|
|
59
|
+
}
|
|
60
|
+
return "bash";
|
|
61
|
+
}
|
|
62
|
+
async function invokeAi(inv, prompt, cwd, cli) {
|
|
63
|
+
console.log(`\nRunning ${cli} to adapt adopted files — this may take a several minutes…`);
|
|
64
|
+
let promptFile;
|
|
65
|
+
let child;
|
|
66
|
+
if (inv.kind === "direct") {
|
|
67
|
+
const [bin, ...args] = inv.args(prompt);
|
|
68
|
+
child = spawn(bin, args, { stdio: "inherit", cwd });
|
|
69
|
+
}
|
|
70
|
+
else if (inv.kind === "stdin") {
|
|
71
|
+
child = spawn(inv.bin, inv.args, {
|
|
72
|
+
stdio: ["pipe", "inherit", "inherit"],
|
|
73
|
+
cwd,
|
|
74
|
+
shell: process.platform === "win32",
|
|
75
|
+
});
|
|
76
|
+
child.stdin.write(prompt, "utf8");
|
|
77
|
+
child.stdin.end();
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
promptFile = join(tmpdir(), `akt-prompt-${Date.now()}.txt`);
|
|
81
|
+
writeFileSync(promptFile, prompt, "utf8");
|
|
82
|
+
child = spawn(findBash(), ["-c", inv.cmd, promptFile], { stdio: "inherit", cwd });
|
|
83
|
+
}
|
|
84
|
+
// Spinner on stderr — visible when the AI CLI is silent during thinking.
|
|
85
|
+
let frame = 0;
|
|
86
|
+
const start = Date.now();
|
|
87
|
+
const timer = setInterval(() => {
|
|
88
|
+
const s = Math.floor((Date.now() - start) / 1000);
|
|
89
|
+
const ts = `${Math.floor(s / 60)}:${(s % 60).toString().padStart(2, "0")}`;
|
|
90
|
+
process.stderr.write(`\r${SPINNER[frame++ % SPINNER.length]} Working… ${ts} `);
|
|
91
|
+
}, 200);
|
|
92
|
+
return new Promise((resolve) => {
|
|
93
|
+
const cleanup = () => {
|
|
94
|
+
clearInterval(timer);
|
|
95
|
+
process.stderr.write("\r\x1b[K");
|
|
96
|
+
if (promptFile) {
|
|
97
|
+
try {
|
|
98
|
+
unlinkSync(promptFile);
|
|
99
|
+
}
|
|
100
|
+
catch { /* ignore */ }
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
child.on("error", (err) => {
|
|
104
|
+
cleanup();
|
|
105
|
+
console.error(`Failed to launch ${cli}: ${err instanceof Error ? err.message : String(err)}`);
|
|
106
|
+
resolve(1);
|
|
107
|
+
});
|
|
108
|
+
child.on("close", (code) => {
|
|
109
|
+
cleanup();
|
|
110
|
+
resolve(code ?? 1);
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
async function promptConflict(target) {
|
|
115
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
116
|
+
try {
|
|
117
|
+
for (;;) {
|
|
118
|
+
const ans = (await rl.question(`Target already exists: ${target}\n[r] replace [s] skip [A] replace all [S] skip all: `)).trim();
|
|
119
|
+
if (ans === "r")
|
|
120
|
+
return "replace";
|
|
121
|
+
if (ans === "s")
|
|
122
|
+
return "skip";
|
|
123
|
+
if (ans === "A")
|
|
124
|
+
return "replace-all";
|
|
125
|
+
if (ans === "S")
|
|
126
|
+
return "skip-all";
|
|
127
|
+
console.log("Please enter r, s, A, or S.");
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
finally {
|
|
131
|
+
rl.close();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
6
134
|
function walkMd(dir) {
|
|
7
135
|
const out = [];
|
|
8
136
|
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
@@ -14,7 +142,6 @@ function walkMd(dir) {
|
|
|
14
142
|
}
|
|
15
143
|
return out;
|
|
16
144
|
}
|
|
17
|
-
/** Print a bundle's RECOMMENDS.md companions as opt-in suggestions; never installs them. */
|
|
18
145
|
function surfaceCompanions(recommendsPath) {
|
|
19
146
|
const rows = readFileSync(recommendsPath, "utf8")
|
|
20
147
|
.split("\n")
|
|
@@ -28,73 +155,146 @@ function surfaceCompanions(recommendsPath) {
|
|
|
28
155
|
console.log(r);
|
|
29
156
|
console.log("Adopt any you want with: agentkit adopt <name>");
|
|
30
157
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
158
|
+
const CAPABILITY_DIRS = new Set(["skills", "agents", "pipelines", "conventions"]);
|
|
159
|
+
async function adoptBundle(bundle, opts, onFile) {
|
|
160
|
+
let bulkAction = null;
|
|
161
|
+
const toProcess = [];
|
|
162
|
+
for (const item of bundle.items) {
|
|
163
|
+
const target = destinationFor(item, opts.provider, opts.projectRoot);
|
|
164
|
+
if (!existsSync(target)) {
|
|
165
|
+
toProcess.push({ item, target });
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
if (opts.force) {
|
|
169
|
+
rmSync(target, { recursive: true, force: true });
|
|
170
|
+
toProcess.push({ item, target });
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
const choice = bulkAction ?? await promptConflict(target);
|
|
174
|
+
if (choice === "replace-all") {
|
|
175
|
+
bulkAction = "replace";
|
|
176
|
+
rmSync(target, { recursive: true, force: true });
|
|
177
|
+
toProcess.push({ item, target });
|
|
178
|
+
}
|
|
179
|
+
else if (choice === "replace") {
|
|
180
|
+
rmSync(target, { recursive: true, force: true });
|
|
181
|
+
toProcess.push({ item, target });
|
|
182
|
+
}
|
|
183
|
+
else if (choice === "skip-all") {
|
|
184
|
+
bulkAction = "skip";
|
|
185
|
+
}
|
|
186
|
+
// "skip" — leave existing, do not push
|
|
37
187
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
188
|
+
for (const { item, target } of toProcess) {
|
|
189
|
+
mkdirSync(dirname(target), { recursive: true });
|
|
190
|
+
if (item.isDir) {
|
|
191
|
+
cpSync(item.sourceCopyPath, target, { recursive: true });
|
|
192
|
+
for (const md of walkMd(target)) {
|
|
193
|
+
const content = readFileSync(md, "utf8");
|
|
194
|
+
for (const f of lint(content)) {
|
|
195
|
+
console.warn(`warning: ${relative(target, md)}:${f.line} contains "${f.token}" — review for ${opts.provider}.`);
|
|
196
|
+
}
|
|
197
|
+
writeFileSync(md, transform(content, opts.provider));
|
|
198
|
+
onFile?.(md);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
const content = readFileSync(item.sourceCopyPath, "utf8");
|
|
203
|
+
for (const f of lint(content)) {
|
|
204
|
+
console.warn(`warning: ${item.name}:${f.line} contains "${f.token}" — review for ${opts.provider}.`);
|
|
205
|
+
}
|
|
206
|
+
writeFileSync(target, transform(content, opts.provider));
|
|
207
|
+
onFile?.(target);
|
|
44
208
|
}
|
|
45
|
-
writeFileSync(md, transform(content, opts.provider));
|
|
46
209
|
}
|
|
47
|
-
|
|
48
|
-
for (const
|
|
210
|
+
const extrasBase = bundleExtrasDestination(bundle.name, opts.provider, opts.projectRoot);
|
|
211
|
+
for (const entry of readdirSync(bundle.dir, { withFileTypes: true })) {
|
|
212
|
+
if (!entry.isDirectory() || CAPABILITY_DIRS.has(entry.name))
|
|
213
|
+
continue;
|
|
214
|
+
const src = join(bundle.dir, entry.name);
|
|
215
|
+
const dest = join(extrasBase, entry.name);
|
|
216
|
+
mkdirSync(dirname(dest), { recursive: true });
|
|
217
|
+
cpSync(src, dest, { recursive: true });
|
|
218
|
+
}
|
|
219
|
+
console.log(`Adopted bundle "${bundle.name}" (${opts.provider}) -> ${opts.projectRoot}`);
|
|
220
|
+
for (const { item } of toProcess)
|
|
49
221
|
console.log(` + ${item.type} ${item.name}`);
|
|
50
222
|
console.log(wiringHint(opts.provider));
|
|
51
223
|
if (bundle.recommendsPath)
|
|
52
224
|
surfaceCompanions(bundle.recommendsPath);
|
|
53
225
|
return 0;
|
|
54
226
|
}
|
|
55
|
-
function adoptSingle(match, opts) {
|
|
227
|
+
async function adoptSingle(match, opts, onFile) {
|
|
56
228
|
const target = destinationFor(match, opts.provider, opts.projectRoot);
|
|
57
229
|
if (existsSync(target)) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
230
|
+
if (opts.force) {
|
|
231
|
+
rmSync(target, { recursive: true, force: true });
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
const choice = await promptConflict(target);
|
|
235
|
+
if (choice === "skip" || choice === "skip-all") {
|
|
236
|
+
console.log(`Skipped ${match.name}.`);
|
|
237
|
+
return 0;
|
|
238
|
+
}
|
|
239
|
+
rmSync(target, { recursive: true, force: true });
|
|
240
|
+
}
|
|
61
241
|
}
|
|
62
|
-
// Non-fatal neutrality warning on the source.
|
|
63
242
|
for (const f of lint(readFileSync(match.sourcePath, "utf8"))) {
|
|
64
243
|
console.warn(`warning: ${match.name}:${f.line} contains "${f.token}" — review before relying on it for ${opts.provider}.`);
|
|
65
244
|
}
|
|
66
245
|
mkdirSync(dirname(target), { recursive: true });
|
|
67
246
|
if (match.isDir) {
|
|
68
247
|
cpSync(match.sourceCopyPath, target, { recursive: true });
|
|
69
|
-
for (const md of walkMd(target))
|
|
248
|
+
for (const md of walkMd(target)) {
|
|
70
249
|
writeFileSync(md, transform(readFileSync(md, "utf8"), opts.provider));
|
|
250
|
+
onFile?.(md);
|
|
251
|
+
}
|
|
71
252
|
}
|
|
72
253
|
else {
|
|
73
254
|
writeFileSync(target, transform(readFileSync(match.sourceCopyPath, "utf8"), opts.provider));
|
|
255
|
+
onFile?.(target);
|
|
74
256
|
}
|
|
75
257
|
console.log(`Adopted ${match.type} "${match.name}" (${opts.provider}) -> ${target}`);
|
|
76
258
|
console.log(wiringHint(opts.provider));
|
|
77
259
|
return 0;
|
|
78
260
|
}
|
|
79
|
-
export function adopt(opts) {
|
|
80
|
-
|
|
261
|
+
export async function adopt(opts, onFile) {
|
|
262
|
+
const files = [];
|
|
263
|
+
const track = (p) => { files.push(p); onFile?.(p); };
|
|
81
264
|
const bundle = findBundle(opts.name);
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if (ambiguous.length > 0) {
|
|
86
|
-
console.error(`Ambiguous name "${opts.name}" matches: ${ambiguous.map((c) => `${c.type}/${c.name}`).join(", ")}.`);
|
|
87
|
-
console.error("Names are expected to be unique; resolve the collision in the kit before adopting.");
|
|
88
|
-
return 1;
|
|
265
|
+
let code;
|
|
266
|
+
if (bundle) {
|
|
267
|
+
code = await adoptBundle(bundle, opts, track);
|
|
89
268
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
269
|
+
else {
|
|
270
|
+
const { match, ambiguous } = findCapability(opts.name);
|
|
271
|
+
if (ambiguous.length > 0) {
|
|
272
|
+
console.error(`Ambiguous name "${opts.name}" matches: ${ambiguous.map((c) => `${c.type}/${c.name}`).join(", ")}.`);
|
|
273
|
+
console.error("Names are expected to be unique; resolve the collision in the kit before adopting.");
|
|
274
|
+
return 1;
|
|
275
|
+
}
|
|
276
|
+
if (!match) {
|
|
277
|
+
console.error(`No capability named "${opts.name}". Run "agentkit list" to see options.`);
|
|
278
|
+
return 1;
|
|
279
|
+
}
|
|
280
|
+
if (match.bundle) {
|
|
281
|
+
console.error(`"${match.name}" is part of the "${match.bundle}" bundle and depends on other files in it.`);
|
|
282
|
+
console.error(`Adopt the whole bundle instead: agentkit adopt ${match.bundle}`);
|
|
283
|
+
return 1;
|
|
284
|
+
}
|
|
285
|
+
code = await adoptSingle(match, opts, track);
|
|
286
|
+
}
|
|
287
|
+
if (code !== 0 || !opts.cli)
|
|
288
|
+
return code;
|
|
289
|
+
if (files.length === 0) {
|
|
290
|
+
console.log("No files adopted; nothing to adapt.");
|
|
291
|
+
return 0;
|
|
292
|
+
}
|
|
293
|
+
try {
|
|
294
|
+
return await invokeAi(CLI_INVOCATIONS[opts.cli], buildPrompt(files), opts.projectRoot, opts.cli);
|
|
93
295
|
}
|
|
94
|
-
|
|
95
|
-
console.error(`
|
|
96
|
-
console.error(`Adopt the whole bundle instead: agentkit adopt ${match.bundle}`);
|
|
296
|
+
catch (err) {
|
|
297
|
+
console.error(`Failed to launch ${opts.cli}: ${err instanceof Error ? err.message : String(err)}`);
|
|
97
298
|
return 1;
|
|
98
299
|
}
|
|
99
|
-
return adoptSingle(match, opts);
|
|
100
300
|
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import { writeFileSync, unlinkSync } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { adopt } from "./adopt.js";
|
|
6
|
+
export const SUPPORTED_CLIS = [
|
|
7
|
+
"claude", "codex", "agy", "aider", "opencode", "grok", "kilo", "qwen",
|
|
8
|
+
];
|
|
9
|
+
const CLI_INVOCATIONS = {
|
|
10
|
+
// Native binary — arg-based, no shell needed.
|
|
11
|
+
claude: { kind: "direct", args: (p) => ["claude", "-p", p] },
|
|
12
|
+
// Supports `exec -` for stdin; --skip-git-repo-check for non-git dirs.
|
|
13
|
+
codex: { kind: "stdin", bin: "codex", args: ["exec", "--skip-git-repo-check", "-"] },
|
|
14
|
+
// Requires -p <value>; use bash $() substitution to pass multi-line content safely.
|
|
15
|
+
agy: { kind: "bash", cmd: 'agy -p "$(cat "$0")"' },
|
|
16
|
+
aider: { kind: "bash", cmd: 'aider --message "$(cat "$0")" --yes-always' },
|
|
17
|
+
opencode: { kind: "bash", cmd: 'opencode run "$(cat "$0")"' },
|
|
18
|
+
grok: { kind: "bash", cmd: 'grok -p "$(cat "$0")"' },
|
|
19
|
+
kilo: { kind: "bash", cmd: 'kilocode --auto "$(cat "$0")"' },
|
|
20
|
+
qwen: { kind: "bash", cmd: 'qwen --prompt "$(cat "$0")"' },
|
|
21
|
+
};
|
|
22
|
+
export function isSupportedCli(value) {
|
|
23
|
+
return SUPPORTED_CLIS.includes(value);
|
|
24
|
+
}
|
|
25
|
+
function buildPrompt(files) {
|
|
26
|
+
return `You have adopted the following AI capability files into this project:
|
|
27
|
+
${files.join("\n")}
|
|
28
|
+
|
|
29
|
+
Before editing anything:
|
|
30
|
+
1. Read CLAUDE.md (or AGENTS.md if present), README.md, and any project
|
|
31
|
+
specification files under .docs/ or .ai/docs/.
|
|
32
|
+
2. Build a clear picture of the project's domain, naming conventions,
|
|
33
|
+
file structure, tools in use, and vocabulary.
|
|
34
|
+
|
|
35
|
+
Adapt each file to this project:
|
|
36
|
+
- Replace generic references with project-specific names, paths, and terms
|
|
37
|
+
- Align tool references and file paths to what this project actually uses
|
|
38
|
+
- Preserve the file's structure, scope, and intent exactly
|
|
39
|
+
- Leave files that need no changes untouched`;
|
|
40
|
+
}
|
|
41
|
+
function invoke(inv, prompt, cwd) {
|
|
42
|
+
if (inv.kind === "direct") {
|
|
43
|
+
const [bin, ...args] = inv.args(prompt);
|
|
44
|
+
const r = spawnSync(bin, args, { stdio: "inherit", cwd });
|
|
45
|
+
if (r.error)
|
|
46
|
+
throw r.error;
|
|
47
|
+
return r.status ?? 1;
|
|
48
|
+
}
|
|
49
|
+
if (inv.kind === "stdin") {
|
|
50
|
+
const r = spawnSync(inv.bin, inv.args, {
|
|
51
|
+
input: prompt,
|
|
52
|
+
stdio: ["pipe", "inherit", "inherit"],
|
|
53
|
+
cwd,
|
|
54
|
+
shell: process.platform === "win32",
|
|
55
|
+
});
|
|
56
|
+
if (r.error)
|
|
57
|
+
throw r.error;
|
|
58
|
+
return r.status ?? 1;
|
|
59
|
+
}
|
|
60
|
+
// bash kind — write prompt to temp file, let bash expand it via $(cat "$0")
|
|
61
|
+
const promptFile = join(tmpdir(), `akt-prompt-${Date.now()}.txt`);
|
|
62
|
+
writeFileSync(promptFile, prompt, "utf8");
|
|
63
|
+
try {
|
|
64
|
+
const r = spawnSync("bash", ["-c", inv.cmd, promptFile], { stdio: "inherit", cwd });
|
|
65
|
+
if (r.error)
|
|
66
|
+
throw r.error;
|
|
67
|
+
return r.status ?? 1;
|
|
68
|
+
}
|
|
69
|
+
finally {
|
|
70
|
+
try {
|
|
71
|
+
unlinkSync(promptFile);
|
|
72
|
+
}
|
|
73
|
+
catch { /* ignore */ }
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
export function aiadopt(opts) {
|
|
77
|
+
const files = [];
|
|
78
|
+
const code = adopt({ name: opts.name, provider: opts.provider, projectRoot: opts.projectRoot }, (path) => files.push(path));
|
|
79
|
+
if (code !== 0)
|
|
80
|
+
return code;
|
|
81
|
+
if (files.length === 0) {
|
|
82
|
+
console.log("No files adopted; nothing to adapt.");
|
|
83
|
+
return 0;
|
|
84
|
+
}
|
|
85
|
+
const prompt = buildPrompt(files);
|
|
86
|
+
const inv = CLI_INVOCATIONS[opts.cli];
|
|
87
|
+
console.log(`\nRunning ${opts.cli} to adapt adopted files...`);
|
|
88
|
+
try {
|
|
89
|
+
return invoke(inv, prompt, opts.projectRoot);
|
|
90
|
+
}
|
|
91
|
+
catch (err) {
|
|
92
|
+
console.error(`Failed to launch ${opts.cli}: ${err instanceof Error ? err.message : String(err)}`);
|
|
93
|
+
return 1;
|
|
94
|
+
}
|
|
95
|
+
}
|
package/dist/providers.js
CHANGED
|
@@ -18,12 +18,9 @@ export function destinationFor(cap, provider, projectRoot) {
|
|
|
18
18
|
const base = join(projectRoot, PROVIDER_ROOT[provider], TYPE_DIR[cap.type]);
|
|
19
19
|
return cap.isDir ? join(base, cap.name) : join(base, `${cap.name}.md`);
|
|
20
20
|
}
|
|
21
|
-
/**
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
*/
|
|
25
|
-
export function bundleDestination(name, provider, projectRoot) {
|
|
26
|
-
return join(projectRoot, PROVIDER_ROOT[provider], "bundles", name);
|
|
21
|
+
/** Destination for bundle extras (templates, etc.) that are not capability items. */
|
|
22
|
+
export function bundleExtrasDestination(name, provider, projectRoot) {
|
|
23
|
+
return join(projectRoot, PROVIDER_ROOT[provider], name);
|
|
27
24
|
}
|
|
28
25
|
export function wiringHint(provider) {
|
|
29
26
|
switch (provider) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-manifesto-kit",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "CLI to discover and adopt Agent Manifesto Kit capabilities (skills, agents, pipelines) into your project for Claude, Codex, or AI-agnostic targets.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -24,7 +24,9 @@
|
|
|
24
24
|
"build": "tsc",
|
|
25
25
|
"start": "node dist/cli.js",
|
|
26
26
|
"test": "npm run build && node --test",
|
|
27
|
-
"prepublishOnly": "npm run build && npm test"
|
|
27
|
+
"prepublishOnly": "npm run build && npm test",
|
|
28
|
+
"prepare": "git config core.hooksPath .githooks",
|
|
29
|
+
"version-branch": "node .ai/scripts/bump-version.mjs"
|
|
28
30
|
},
|
|
29
31
|
"engines": {
|
|
30
32
|
"node": ">=20"
|