agent-manifesto-kit 1.2.0 → 1.5.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 +101 -1
- package/collection/bundles/blender-3d/README.md +138 -0
- package/collection/bundles/blender-3d/agents/visual-reviewer.md +58 -0
- package/collection/bundles/blender-3d/skills/blender-asset/SKILL.md +75 -0
- package/collection/bundles/blender-3d/skills/blender-asset/scripts/record_run.py +175 -0
- package/collection/bundles/blender-3d/skills/blender-asset/scripts/task_state.py +199 -0
- package/collection/bundles/blender-3d/skills/blender-asset/workflows/asset.yml +105 -0
- package/collection/bundles/blender-3d/skills/blender-mocap-retarget/SKILL.md +115 -0
- package/collection/bundles/blender-3d/skills/blender-mocap-retarget/scripts/check_motion.py +244 -0
- package/collection/bundles/blender-3d/skills/blender-mocap-retarget/scripts/export_gltf_clip.py +71 -0
- package/collection/bundles/blender-3d/skills/blender-mocap-retarget/scripts/godot_verify.py +87 -0
- package/collection/bundles/blender-3d/skills/blender-mocap-retarget/scripts/inspect_motion_source.py +107 -0
- package/collection/bundles/blender-3d/skills/blender-mocap-retarget/scripts/render_frames.py +117 -0
- package/collection/bundles/blender-3d/skills/blender-mocap-retarget/scripts/verify_gltf.py +117 -0
- package/collection/bundles/blender-3d/skills/blender-reference-model/SKILL.md +110 -0
- package/collection/bundles/blender-3d/skills/blender-reference-model/scripts/colors.py +50 -0
- package/collection/bundles/blender-3d/skills/blender-reference-model/scripts/compare.py +77 -0
- package/collection/bundles/blender-3d/skills/blender-reference-model/scripts/contact_sheet.py +51 -0
- package/collection/bundles/blender-3d/skills/blender-reference-model/scripts/diff_renders.py +58 -0
- package/collection/bundles/blender-3d/skills/blender-reference-model/scripts/edges.py +54 -0
- package/collection/bundles/blender-3d/skills/blender-reference-model/scripts/measure_ref.py +137 -0
- package/collection/bundles/blender-3d/skills/blender-reference-model/scripts/mesh_report.py +67 -0
- package/collection/bundles/blender-3d/skills/blender-reference-model/scripts/refspec.py +91 -0
- package/collection/bundles/blender-3d/skills/blender-reference-model/scripts/render_views.py +99 -0
- package/collection/bundles/blender-3d/skills/blender-reference-model/scripts/zoom.py +47 -0
- package/collection/bundles/kit-adopt/README.md +1 -1
- package/collection/bundles/kit-adopt/skills/kit-adopt/SKILL.md +2 -2
- package/collection/bundles/session-retro/README.md +64 -0
- package/collection/bundles/session-retro/agents/retro-analyst.md +77 -0
- package/collection/bundles/session-retro/skills/session-retro/SKILL.md +74 -0
- package/collection/bundles/session-retro/skills/session-retro/scripts/install_hooks.py +114 -0
- package/collection/bundles/session-retro/skills/session-retro/scripts/retro_hook.py +117 -0
- package/collection/bundles/session-retro/skills/session-retro/scripts/session_digest.py +457 -0
- package/dist/agent-format.js +218 -0
- package/dist/catalog.js +13 -13
- package/dist/cli.js +95 -4
- package/dist/commands/adopt.js +13 -3
- package/dist/commands/ingest.js +120 -0
- package/dist/commands/sync.js +201 -0
- package/dist/commands/update.js +36 -0
- package/dist/portability.js +19 -2
- package/dist/providers.js +12 -2
- package/package.json +1 -1
package/dist/catalog.js
CHANGED
|
@@ -6,11 +6,11 @@ export function packageRoot() {
|
|
|
6
6
|
const here = dirname(fileURLToPath(import.meta.url));
|
|
7
7
|
return dirname(here);
|
|
8
8
|
}
|
|
9
|
-
function collectionDir() {
|
|
10
|
-
return join(
|
|
9
|
+
function collectionDir(root = packageRoot()) {
|
|
10
|
+
return join(root, "collection");
|
|
11
11
|
}
|
|
12
|
-
function bundlesDir() {
|
|
13
|
-
return join(collectionDir(), "bundles");
|
|
12
|
+
function bundlesDir(root) {
|
|
13
|
+
return join(collectionDir(root), "bundles");
|
|
14
14
|
}
|
|
15
15
|
function parseFrontmatter(text) {
|
|
16
16
|
const out = {};
|
|
@@ -107,8 +107,8 @@ function scanTypeDir(base, type, bundle) {
|
|
|
107
107
|
}
|
|
108
108
|
const ALL_TYPES = ["skill", "agent", "pipeline", "convention"];
|
|
109
109
|
/** Bundles found under collection/bundles/, each a cohesive, independently adoptable unit. */
|
|
110
|
-
export function scanBundles() {
|
|
111
|
-
const root = bundlesDir();
|
|
110
|
+
export function scanBundles(kitRoot) {
|
|
111
|
+
const root = bundlesDir(kitRoot);
|
|
112
112
|
if (!existsSync(root))
|
|
113
113
|
return [];
|
|
114
114
|
const bundles = [];
|
|
@@ -129,18 +129,18 @@ export function scanBundles() {
|
|
|
129
129
|
return bundles;
|
|
130
130
|
}
|
|
131
131
|
/** All individually addressable capabilities: flat collection items plus every bundle's items. */
|
|
132
|
-
export function scanCatalog() {
|
|
133
|
-
const root = collectionDir();
|
|
132
|
+
export function scanCatalog(kitRoot) {
|
|
133
|
+
const root = collectionDir(kitRoot);
|
|
134
134
|
const flat = ALL_TYPES.flatMap((t) => scanTypeDir(root, t));
|
|
135
|
-
const bundled = scanBundles().flatMap((b) => b.items);
|
|
135
|
+
const bundled = scanBundles(kitRoot).flatMap((b) => b.items);
|
|
136
136
|
return [...flat, ...bundled];
|
|
137
137
|
}
|
|
138
|
-
export function findCapability(name) {
|
|
139
|
-
const matches = scanCatalog().filter((c) => c.name === name);
|
|
138
|
+
export function findCapability(name, kitRoot) {
|
|
139
|
+
const matches = scanCatalog(kitRoot).filter((c) => c.name === name);
|
|
140
140
|
if (matches.length === 1)
|
|
141
141
|
return { match: matches[0], ambiguous: [] };
|
|
142
142
|
return { ambiguous: matches.length > 1 ? matches : [] };
|
|
143
143
|
}
|
|
144
|
-
export function findBundle(name) {
|
|
145
|
-
return scanBundles().find((b) => b.name === name);
|
|
144
|
+
export function findBundle(name, kitRoot) {
|
|
145
|
+
return scanBundles(kitRoot).find((b) => b.name === name);
|
|
146
146
|
}
|
package/dist/cli.js
CHANGED
|
@@ -4,6 +4,9 @@ import { join } from "node:path";
|
|
|
4
4
|
import { list } from "./commands/list.js";
|
|
5
5
|
import { adopt, isSupportedCli, SUPPORTED_CLIS } from "./commands/adopt.js";
|
|
6
6
|
import { runLint } from "./commands/lint.js";
|
|
7
|
+
import { ingest } from "./commands/ingest.js";
|
|
8
|
+
import { sync, SYNC_PROVIDERS } from "./commands/sync.js";
|
|
9
|
+
import { update } from "./commands/update.js";
|
|
7
10
|
import { isProvider } from "./providers.js";
|
|
8
11
|
import { packageRoot } from "./catalog.js";
|
|
9
12
|
function version() {
|
|
@@ -15,24 +18,42 @@ function version() {
|
|
|
15
18
|
return "unknown";
|
|
16
19
|
}
|
|
17
20
|
}
|
|
21
|
+
/** Flags that never take a value, so a following positional is not swallowed. */
|
|
22
|
+
const BOOLEAN_FLAGS = new Set(["force", "replace", "dry-run", "help", "version"]);
|
|
23
|
+
const VALUE_FLAGS = new Set(["provider", "dest", "cli", "bundle", "kit", "remove"]);
|
|
18
24
|
function parseArgs(args) {
|
|
19
25
|
const positionals = [];
|
|
20
26
|
const flags = {};
|
|
21
27
|
for (let i = 0; i < args.length; i++) {
|
|
22
28
|
const arg = args[i];
|
|
23
29
|
if (arg.startsWith("--")) {
|
|
24
|
-
const
|
|
30
|
+
const equal = arg.indexOf("=");
|
|
31
|
+
const key = arg.slice(2, equal === -1 ? undefined : equal);
|
|
32
|
+
if (equal !== -1) {
|
|
33
|
+
const value = arg.slice(equal + 1);
|
|
34
|
+
if (BOOLEAN_FLAGS.has(key))
|
|
35
|
+
throw new Error(`--${key} does not take a value.`);
|
|
36
|
+
if (!value)
|
|
37
|
+
throw new Error(`--${key} needs a value.`);
|
|
38
|
+
flags[key] = value;
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
25
41
|
const next = args[i + 1];
|
|
26
|
-
if (next !== undefined && !next.startsWith("-")) {
|
|
42
|
+
if (!BOOLEAN_FLAGS.has(key) && next !== undefined && !next.startsWith("-")) {
|
|
27
43
|
flags[key] = next;
|
|
28
44
|
i++;
|
|
29
45
|
}
|
|
30
46
|
else {
|
|
47
|
+
if (VALUE_FLAGS.has(key))
|
|
48
|
+
throw new Error(`--${key} needs a value.`);
|
|
31
49
|
flags[key] = true;
|
|
32
50
|
}
|
|
33
51
|
}
|
|
34
52
|
else if (arg.length > 1 && arg.startsWith("-")) {
|
|
35
|
-
|
|
53
|
+
const key = arg.slice(1);
|
|
54
|
+
if (VALUE_FLAGS.has(key))
|
|
55
|
+
throw new Error(`Unknown option "${arg}". Use "--${key} <value>".`);
|
|
56
|
+
flags[key] = true;
|
|
36
57
|
}
|
|
37
58
|
else {
|
|
38
59
|
positionals.push(arg);
|
|
@@ -44,23 +65,41 @@ function help() {
|
|
|
44
65
|
console.log(`agentkit - discover and adopt Agent Manifesto Kit capabilities
|
|
45
66
|
|
|
46
67
|
Usage:
|
|
68
|
+
agentkit update
|
|
47
69
|
agentkit list [skills|agents|bundles]
|
|
48
70
|
agentkit lint [name]
|
|
49
71
|
agentkit adopt <name> [--provider claude|codex|agnostic] [--dest <dir>] [--force] [--cli <cli>]
|
|
72
|
+
agentkit ingest <path> [--bundle <name>] [--replace] [--kit <dir>]
|
|
73
|
+
agentkit sync [<name>...] [--provider claude,codex] [--remove <name,...>] [--dest <dir>] [--force] [--dry-run]
|
|
50
74
|
|
|
51
75
|
<name> is a capability (skill/agent/pipeline/convention) or a bundle.
|
|
52
76
|
Adopting a bundle explodes it into type-specific directories.
|
|
53
77
|
|
|
54
78
|
list accepts one exact lowercase selector. Without a selector it shows the full catalog.
|
|
55
79
|
|
|
80
|
+
update installs agent-manifesto-kit@latest globally using npm. Run sync separately
|
|
81
|
+
in each project to refresh installed skills and agents.
|
|
82
|
+
|
|
83
|
+
ingest imports a skill folder (SKILL.md), a Claude agent .md, or a Codex agent .toml
|
|
84
|
+
into the kit's collection/ as a canonical Claude-style capability.
|
|
85
|
+
|
|
86
|
+
sync keeps hard copies of skills and agents in the project's native Claude and Codex
|
|
87
|
+
locations. Names add to the sync set recorded in .agentkit-lock.json; without names it
|
|
88
|
+
refreshes that set. Locally edited files are kept and reported unless --force is given.
|
|
89
|
+
|
|
56
90
|
Pass --cli to run an AI assistant after adoption to adapt the files to your project.
|
|
57
91
|
Pass --force to overwrite existing targets without prompting.
|
|
58
92
|
|
|
59
93
|
Options:
|
|
60
|
-
--provider target AI provider (default: claude)
|
|
94
|
+
--provider target AI provider (default: claude; sync: claude,codex)
|
|
61
95
|
--cli AI CLI to run after adoption for project-specific adaptation
|
|
62
96
|
supported: ${SUPPORTED_CLIS.join("|")}
|
|
63
97
|
--force overwrite existing targets without prompting
|
|
98
|
+
--bundle ingest into collection/bundles/<name>/ instead of the flat collection
|
|
99
|
+
--replace let ingest overwrite an existing item at the same location
|
|
100
|
+
--kit kit checkout whose collection/ ingest writes to (default: this package)
|
|
101
|
+
--remove comma-separated names to drop from the sync set
|
|
102
|
+
--dry-run show what sync would change without writing
|
|
64
103
|
--dest target project root (default: current directory)
|
|
65
104
|
--version,-v print the installed version
|
|
66
105
|
--help,-h show this help`);
|
|
@@ -84,11 +123,26 @@ async function main() {
|
|
|
84
123
|
case "help":
|
|
85
124
|
help();
|
|
86
125
|
return 0;
|
|
126
|
+
case "update":
|
|
127
|
+
if (positionals.length !== 1 || Object.keys(flags).length !== 0) {
|
|
128
|
+
console.error('update takes no arguments or options. Run "agentkit update".');
|
|
129
|
+
return 1;
|
|
130
|
+
}
|
|
131
|
+
return update();
|
|
87
132
|
case "list":
|
|
88
133
|
return list(positionals.slice(1), flags);
|
|
89
134
|
case "lint":
|
|
90
135
|
return runLint(positionals[1]);
|
|
91
136
|
case "adopt": {
|
|
137
|
+
const unknown = Object.keys(flags).find((key) => !["provider", "dest", "force", "cli"].includes(key));
|
|
138
|
+
if (unknown) {
|
|
139
|
+
console.error(`adopt: unknown option "--${unknown}". Use "--help" for help.`);
|
|
140
|
+
return 1;
|
|
141
|
+
}
|
|
142
|
+
if (positionals.length > 2) {
|
|
143
|
+
console.error('adopt requires exactly one <name>. Use "--provider codex" or "--provider=codex" to select Codex.');
|
|
144
|
+
return 1;
|
|
145
|
+
}
|
|
92
146
|
const name = positionals[1];
|
|
93
147
|
if (!name) {
|
|
94
148
|
console.error('adopt requires a <name>. Run "agentkit list" to see options.');
|
|
@@ -108,6 +162,43 @@ async function main() {
|
|
|
108
162
|
const force = flags.force === true;
|
|
109
163
|
return adopt({ name, provider, projectRoot, force, cli });
|
|
110
164
|
}
|
|
165
|
+
case "ingest": {
|
|
166
|
+
const source = positionals[1];
|
|
167
|
+
if (!source || positionals.length > 2) {
|
|
168
|
+
console.error("ingest requires exactly one <path>: a skill folder, an agent .md, or a Codex agent .toml.");
|
|
169
|
+
return 1;
|
|
170
|
+
}
|
|
171
|
+
return ingest({
|
|
172
|
+
source,
|
|
173
|
+
bundle: typeof flags.bundle === "string" ? flags.bundle : undefined,
|
|
174
|
+
kitRoot: typeof flags.kit === "string" ? flags.kit : undefined,
|
|
175
|
+
replace: flags.replace === true,
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
case "sync": {
|
|
179
|
+
let providers;
|
|
180
|
+
if (flags.provider !== undefined) {
|
|
181
|
+
const list = typeof flags.provider === "string" ? flags.provider.split(",").map((p) => p.trim()) : [];
|
|
182
|
+
const bad = list.filter((p) => !SYNC_PROVIDERS.includes(p));
|
|
183
|
+
if (list.length === 0 || bad.length > 0) {
|
|
184
|
+
console.error(`Invalid --provider "${String(flags.provider)}". sync supports: ${SYNC_PROVIDERS.join(",")}.`);
|
|
185
|
+
return 1;
|
|
186
|
+
}
|
|
187
|
+
providers = [...new Set(list)];
|
|
188
|
+
}
|
|
189
|
+
if (flags.remove === true) {
|
|
190
|
+
console.error("--remove needs a comma-separated list of names.");
|
|
191
|
+
return 1;
|
|
192
|
+
}
|
|
193
|
+
return sync({
|
|
194
|
+
names: positionals.slice(1),
|
|
195
|
+
remove: typeof flags.remove === "string" ? flags.remove.split(",").map((n) => n.trim()).filter(Boolean) : [],
|
|
196
|
+
providers,
|
|
197
|
+
projectRoot: typeof flags.dest === "string" ? flags.dest : process.cwd(),
|
|
198
|
+
force: flags.force === true,
|
|
199
|
+
dryRun: flags["dry-run"] === true,
|
|
200
|
+
});
|
|
201
|
+
}
|
|
111
202
|
default:
|
|
112
203
|
console.error(`Unknown command "${cmd}". Run "agentkit --help".`);
|
|
113
204
|
return 1;
|
package/dist/commands/adopt.js
CHANGED
|
@@ -5,7 +5,7 @@ import { tmpdir } from "node:os";
|
|
|
5
5
|
import { dirname, join, relative } from "node:path";
|
|
6
6
|
import { findBundle, findCapability } from "../catalog.js";
|
|
7
7
|
import { bundleExtrasDestination, destinationFor, wiringHint } from "../providers.js";
|
|
8
|
-
import { lint, transform } from "../portability.js";
|
|
8
|
+
import { lint, renderAgent, transform } from "../portability.js";
|
|
9
9
|
export const SUPPORTED_CLIS = [
|
|
10
10
|
"claude", "codex", "agy", "aider", "opencode", "grok", "kilo", "qwen",
|
|
11
11
|
];
|
|
@@ -185,6 +185,16 @@ function surfaceCompanions(recommendsPath) {
|
|
|
185
185
|
console.log(r);
|
|
186
186
|
console.log("Adopt any you want with: agentkit adopt <name>");
|
|
187
187
|
}
|
|
188
|
+
/** Render a single-file capability in the provider's native format, reporting dropped metadata. */
|
|
189
|
+
export function renderFile(cap, content, provider) {
|
|
190
|
+
if (cap.type !== "agent")
|
|
191
|
+
return transform(content, provider);
|
|
192
|
+
const { content: rendered, dropped } = renderAgent(content, provider, cap.name);
|
|
193
|
+
if (dropped.length > 0) {
|
|
194
|
+
console.warn(`warning: ${cap.name}: frontmatter ${dropped.join(", ")} has no ${provider} equivalent and was not carried over.`);
|
|
195
|
+
}
|
|
196
|
+
return rendered;
|
|
197
|
+
}
|
|
188
198
|
const CAPABILITY_DIRS = new Set(["skills", "agents", "pipelines", "conventions"]);
|
|
189
199
|
async function adoptBundle(bundle, opts, onFile) {
|
|
190
200
|
let bulkAction = null;
|
|
@@ -233,7 +243,7 @@ async function adoptBundle(bundle, opts, onFile) {
|
|
|
233
243
|
for (const f of lint(content)) {
|
|
234
244
|
console.warn(`warning: ${item.name}:${f.line} contains "${f.token}" — review for ${opts.provider}.`);
|
|
235
245
|
}
|
|
236
|
-
writeFileSync(target,
|
|
246
|
+
writeFileSync(target, renderFile(item, content, opts.provider));
|
|
237
247
|
onFile?.(target);
|
|
238
248
|
}
|
|
239
249
|
}
|
|
@@ -283,7 +293,7 @@ async function adoptSingle(match, opts, onFile) {
|
|
|
283
293
|
}
|
|
284
294
|
}
|
|
285
295
|
else {
|
|
286
|
-
writeFileSync(target,
|
|
296
|
+
writeFileSync(target, renderFile(match, readFileSync(match.sourceCopyPath, "utf8"), opts.provider));
|
|
287
297
|
onFile?.(target);
|
|
288
298
|
}
|
|
289
299
|
console.log(`Adopted ${match.type} "${match.name}" (${opts.provider}) -> ${target}`);
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { cpSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { basename, join, relative, resolve } from "node:path";
|
|
3
|
+
import { findCapability, packageRoot } from "../catalog.js";
|
|
4
|
+
import { codexTomlAgentToMarkdown, parseMarkdown } from "../agent-format.js";
|
|
5
|
+
import { lint } from "../portability.js";
|
|
6
|
+
const NAME = /^[a-z0-9][a-z0-9-]*$/;
|
|
7
|
+
/** Codex-native locations mapped back to the canonical `.claude/` tokens that adopt/sync rewrite. */
|
|
8
|
+
export function toCanonicalPaths(content) {
|
|
9
|
+
return content
|
|
10
|
+
.replace(/\.codex\/agents\/([A-Za-z0-9_.-]+)\.toml/g, ".claude/agents/$1.md")
|
|
11
|
+
.split(".agents/skills/")
|
|
12
|
+
.join(".claude/skills/");
|
|
13
|
+
}
|
|
14
|
+
function walkFiles(dir) {
|
|
15
|
+
const out = [];
|
|
16
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
17
|
+
if (entry.name.startsWith(".") || entry.name === "__pycache__")
|
|
18
|
+
continue;
|
|
19
|
+
const p = join(dir, entry.name);
|
|
20
|
+
if (entry.isDirectory())
|
|
21
|
+
out.push(...walkFiles(p));
|
|
22
|
+
else
|
|
23
|
+
out.push(p);
|
|
24
|
+
}
|
|
25
|
+
return out;
|
|
26
|
+
}
|
|
27
|
+
function fail(message) {
|
|
28
|
+
console.error(`ingest: ${message}`);
|
|
29
|
+
return 1;
|
|
30
|
+
}
|
|
31
|
+
export function ingest(opts) {
|
|
32
|
+
const source = resolve(opts.source);
|
|
33
|
+
if (!existsSync(source))
|
|
34
|
+
return fail(`source not found: ${opts.source}`);
|
|
35
|
+
const kitRoot = resolve(opts.kitRoot ?? packageRoot());
|
|
36
|
+
const collection = join(kitRoot, "collection");
|
|
37
|
+
if (!existsSync(collection))
|
|
38
|
+
return fail(`no collection/ directory in kit root ${kitRoot}`);
|
|
39
|
+
if (opts.bundle !== undefined && !NAME.test(opts.bundle))
|
|
40
|
+
return fail(`invalid bundle name "${opts.bundle}"`);
|
|
41
|
+
let kind;
|
|
42
|
+
let content;
|
|
43
|
+
let skillDir;
|
|
44
|
+
if (statSync(source).isDirectory()) {
|
|
45
|
+
const skillFile = join(source, "SKILL.md");
|
|
46
|
+
if (!existsSync(skillFile))
|
|
47
|
+
return fail(`${opts.source} is a directory without SKILL.md`);
|
|
48
|
+
kind = "skill";
|
|
49
|
+
skillDir = source;
|
|
50
|
+
content = readFileSync(skillFile, "utf8");
|
|
51
|
+
}
|
|
52
|
+
else if (source.endsWith(".toml")) {
|
|
53
|
+
kind = "agent";
|
|
54
|
+
try {
|
|
55
|
+
const converted = codexTomlAgentToMarkdown(readFileSync(source, "utf8"));
|
|
56
|
+
for (const key of converted.skipped)
|
|
57
|
+
console.warn(`warning: ${basename(source)}: "${key}" is not a scalar setting and was not ingested.`);
|
|
58
|
+
content = converted.markdown;
|
|
59
|
+
}
|
|
60
|
+
catch (err) {
|
|
61
|
+
return fail(`${opts.source}: ${err instanceof Error ? err.message : String(err)}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
else if (source.endsWith(".md")) {
|
|
65
|
+
kind = "agent";
|
|
66
|
+
content = readFileSync(source, "utf8");
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
return fail(`unsupported source ${opts.source}: expected a skill folder, an agent .md, or a Codex agent .toml`);
|
|
70
|
+
}
|
|
71
|
+
const { frontmatter } = parseMarkdown(content);
|
|
72
|
+
const fmName = typeof frontmatter.name === "string" ? frontmatter.name : "";
|
|
73
|
+
const fallback = kind === "skill" ? basename(source) : basename(source).replace(/\.(md|toml)$/, "");
|
|
74
|
+
const name = fmName || fallback;
|
|
75
|
+
if (!NAME.test(name))
|
|
76
|
+
return fail(`invalid capability name "${name}" (use lowercase letters, digits and hyphens)`);
|
|
77
|
+
if (typeof frontmatter.description !== "string" || frontmatter.description.trim() === "") {
|
|
78
|
+
return fail(`${name} has no frontmatter description; add one before ingesting`);
|
|
79
|
+
}
|
|
80
|
+
const base = opts.bundle ? join(collection, "bundles", opts.bundle) : collection;
|
|
81
|
+
const target = kind === "skill" ? join(base, "skills", name) : join(base, "agents", `${name}.md`);
|
|
82
|
+
const existing = findCapability(name, kitRoot);
|
|
83
|
+
const clash = [...(existing.match ? [existing.match] : []), ...existing.ambiguous];
|
|
84
|
+
const elsewhere = clash.filter((c) => resolve(c.sourceCopyPath) !== target);
|
|
85
|
+
if (elsewhere.length > 0) {
|
|
86
|
+
return fail(`"${name}" already exists at ${elsewhere.map((c) => relative(kitRoot, c.sourceCopyPath)).join(", ")}; capability names must be unique`);
|
|
87
|
+
}
|
|
88
|
+
if (existsSync(target)) {
|
|
89
|
+
if (!opts.replace)
|
|
90
|
+
return fail(`${relative(kitRoot, target)} already exists; pass --replace to overwrite it`);
|
|
91
|
+
rmSync(target, { recursive: true, force: true });
|
|
92
|
+
}
|
|
93
|
+
const written = [];
|
|
94
|
+
if (skillDir) {
|
|
95
|
+
for (const file of walkFiles(skillDir)) {
|
|
96
|
+
const dest = join(target, relative(skillDir, file));
|
|
97
|
+
mkdirSync(join(dest, ".."), { recursive: true });
|
|
98
|
+
if (file.endsWith(".md"))
|
|
99
|
+
writeFileSync(dest, toCanonicalPaths(readFileSync(file, "utf8")));
|
|
100
|
+
else
|
|
101
|
+
cpSync(file, dest);
|
|
102
|
+
written.push(dest);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
mkdirSync(join(target, ".."), { recursive: true });
|
|
107
|
+
writeFileSync(target, toCanonicalPaths(content));
|
|
108
|
+
written.push(target);
|
|
109
|
+
}
|
|
110
|
+
for (const file of written.filter((f) => f.endsWith(".md"))) {
|
|
111
|
+
for (const f of lint(readFileSync(file, "utf8"))) {
|
|
112
|
+
console.warn(`warning: ${relative(kitRoot, file)}:${f.line} contains "${f.token}" — make it provider-neutral.`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
console.log(`Ingested ${kind} "${name}" -> ${relative(kitRoot, target)} (${written.length} file(s))`);
|
|
116
|
+
if (opts.bundle && !existsSync(join(base, "README.md"))) {
|
|
117
|
+
console.log(`Note: bundle "${opts.bundle}" has no README.md yet; its first paragraph becomes the bundle description.`);
|
|
118
|
+
}
|
|
119
|
+
return 0;
|
|
120
|
+
}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, rmdirSync, unlinkSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { dirname, join, relative, resolve, sep } from "node:path";
|
|
4
|
+
import { findBundle, findCapability, packageRoot } from "../catalog.js";
|
|
5
|
+
import { destinationFor } from "../providers.js";
|
|
6
|
+
import { lint, transform } from "../portability.js";
|
|
7
|
+
import { renderFile } from "./adopt.js";
|
|
8
|
+
export const SYNC_PROVIDERS = ["claude", "codex"];
|
|
9
|
+
export const LOCK_FILE = ".agentkit-lock.json";
|
|
10
|
+
const sha256 = (data) => createHash("sha256").update(data).digest("hex");
|
|
11
|
+
/** Lock paths are project-relative with forward slashes, stable across platforms. */
|
|
12
|
+
const lockPath = (projectRoot, abs) => relative(projectRoot, abs).split(sep).join("/");
|
|
13
|
+
function readLock(projectRoot) {
|
|
14
|
+
const file = join(projectRoot, LOCK_FILE);
|
|
15
|
+
if (!existsSync(file))
|
|
16
|
+
return undefined;
|
|
17
|
+
const lock = JSON.parse(readFileSync(file, "utf8"));
|
|
18
|
+
if (lock.version !== 1 || typeof lock.files !== "object")
|
|
19
|
+
throw new Error(`${LOCK_FILE} has an unsupported format`);
|
|
20
|
+
return lock;
|
|
21
|
+
}
|
|
22
|
+
function kitVersion(kitRoot) {
|
|
23
|
+
try {
|
|
24
|
+
return JSON.parse(readFileSync(join(kitRoot, "package.json"), "utf8")).version ?? "unknown";
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return "unknown";
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function walkFiles(dir) {
|
|
31
|
+
const out = [];
|
|
32
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
33
|
+
if (entry.name.startsWith(".") || entry.name === "__pycache__")
|
|
34
|
+
continue;
|
|
35
|
+
const p = join(dir, entry.name);
|
|
36
|
+
if (entry.isDirectory())
|
|
37
|
+
out.push(...walkFiles(p));
|
|
38
|
+
else
|
|
39
|
+
out.push(p);
|
|
40
|
+
}
|
|
41
|
+
return out;
|
|
42
|
+
}
|
|
43
|
+
/** Resolve a sync-set name to the skills and agents it contributes. */
|
|
44
|
+
function resolveItem(name, kitRoot) {
|
|
45
|
+
const bundle = findBundle(name, kitRoot);
|
|
46
|
+
if (bundle) {
|
|
47
|
+
const other = bundle.items.filter((i) => i.type !== "skill" && i.type !== "agent");
|
|
48
|
+
if (other.length > 0) {
|
|
49
|
+
console.warn(`warning: bundle "${name}" also has ${other.map((i) => `${i.type} ${i.name}`).join(", ")}; sync covers skills and agents only — use "agentkit adopt ${name}" for the rest.`);
|
|
50
|
+
}
|
|
51
|
+
return bundle.items.filter((i) => i.type === "skill" || i.type === "agent");
|
|
52
|
+
}
|
|
53
|
+
const { match, ambiguous } = findCapability(name, kitRoot);
|
|
54
|
+
if (ambiguous.length > 0)
|
|
55
|
+
return `ambiguous name "${name}"`;
|
|
56
|
+
if (!match)
|
|
57
|
+
return `no capability or bundle named "${name}"`;
|
|
58
|
+
if (match.bundle)
|
|
59
|
+
return `"${name}" belongs to bundle "${match.bundle}"; sync the bundle instead`;
|
|
60
|
+
if (match.type !== "skill" && match.type !== "agent")
|
|
61
|
+
return `"${name}" is a ${match.type}; sync covers skills and agents only`;
|
|
62
|
+
return [match];
|
|
63
|
+
}
|
|
64
|
+
function render(cap, item, provider, projectRoot, out) {
|
|
65
|
+
const target = destinationFor(cap, provider, projectRoot);
|
|
66
|
+
const add = (abs, content) => out.set(lockPath(projectRoot, abs), { content, item, provider });
|
|
67
|
+
if (cap.isDir) {
|
|
68
|
+
for (const file of walkFiles(cap.sourceCopyPath)) {
|
|
69
|
+
const dest = join(target, relative(cap.sourceCopyPath, file));
|
|
70
|
+
if (file.endsWith(".md"))
|
|
71
|
+
add(dest, Buffer.from(transform(readFileSync(file, "utf8"), provider)));
|
|
72
|
+
else
|
|
73
|
+
add(dest, readFileSync(file));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
add(target, Buffer.from(renderFile(cap, readFileSync(cap.sourceCopyPath, "utf8"), provider)));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function removeEmptyParents(projectRoot, abs) {
|
|
81
|
+
let dir = dirname(abs);
|
|
82
|
+
while (dir.startsWith(projectRoot + sep) && dir !== projectRoot) {
|
|
83
|
+
try {
|
|
84
|
+
if (readdirSync(dir).length > 0)
|
|
85
|
+
return;
|
|
86
|
+
rmdirSync(dir);
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
dir = dirname(dir);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
export function sync(opts) {
|
|
95
|
+
const projectRoot = resolve(opts.projectRoot);
|
|
96
|
+
const kitRoot = resolve(opts.kitRoot ?? packageRoot());
|
|
97
|
+
let lock;
|
|
98
|
+
try {
|
|
99
|
+
lock = readLock(projectRoot);
|
|
100
|
+
}
|
|
101
|
+
catch (err) {
|
|
102
|
+
console.error(`sync: ${err instanceof Error ? err.message : String(err)}`);
|
|
103
|
+
return 1;
|
|
104
|
+
}
|
|
105
|
+
const remove = new Set(opts.remove ?? []);
|
|
106
|
+
const items = [...new Set([...(lock?.items ?? []), ...opts.names])].filter((n) => !remove.has(n));
|
|
107
|
+
const unknownRemovals = [...remove].filter((n) => !(lock?.items ?? []).includes(n) && !opts.names.includes(n));
|
|
108
|
+
if (unknownRemovals.length > 0)
|
|
109
|
+
console.warn(`warning: not in the sync set: ${unknownRemovals.join(", ")}`);
|
|
110
|
+
const providers = opts.providers ?? lock?.providers ?? [...SYNC_PROVIDERS];
|
|
111
|
+
if (items.length === 0 && !lock) {
|
|
112
|
+
console.error('sync: nothing to sync. Name capabilities or bundles, e.g. "agentkit sync blender-3d".');
|
|
113
|
+
return 1;
|
|
114
|
+
}
|
|
115
|
+
const desired = new Map();
|
|
116
|
+
for (const item of items) {
|
|
117
|
+
const caps = resolveItem(item, kitRoot);
|
|
118
|
+
if (typeof caps === "string") {
|
|
119
|
+
console.error(`sync: ${caps}. Run "agentkit list" to see options.`);
|
|
120
|
+
return 1;
|
|
121
|
+
}
|
|
122
|
+
for (const cap of caps) {
|
|
123
|
+
for (const f of lint(readFileSync(cap.sourcePath, "utf8"))) {
|
|
124
|
+
console.warn(`warning: ${cap.name}:${f.line} contains "${f.token}" — review before relying on it.`);
|
|
125
|
+
}
|
|
126
|
+
for (const provider of providers)
|
|
127
|
+
render(cap, item, provider, projectRoot, desired);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
const files = {};
|
|
131
|
+
const report = { created: [], updated: [], unchanged: 0, removed: [], kept: [] };
|
|
132
|
+
const write = (rel, d) => {
|
|
133
|
+
if (opts.dryRun)
|
|
134
|
+
return;
|
|
135
|
+
const abs = join(projectRoot, rel);
|
|
136
|
+
mkdirSync(dirname(abs), { recursive: true });
|
|
137
|
+
writeFileSync(abs, d.content);
|
|
138
|
+
};
|
|
139
|
+
for (const [rel, d] of desired) {
|
|
140
|
+
const abs = join(projectRoot, rel);
|
|
141
|
+
const want = sha256(d.content);
|
|
142
|
+
const owned = lock?.files[rel];
|
|
143
|
+
if (!existsSync(abs)) {
|
|
144
|
+
write(rel, d);
|
|
145
|
+
report.created.push(rel);
|
|
146
|
+
files[rel] = { sha256: want, item: d.item, provider: d.provider };
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
const have = sha256(readFileSync(abs));
|
|
150
|
+
if (have === want) {
|
|
151
|
+
report.unchanged++;
|
|
152
|
+
files[rel] = { sha256: want, item: d.item, provider: d.provider };
|
|
153
|
+
}
|
|
154
|
+
else if ((owned && owned.sha256 === have) || opts.force) {
|
|
155
|
+
write(rel, d);
|
|
156
|
+
report.updated.push(rel);
|
|
157
|
+
files[rel] = { sha256: want, item: d.item, provider: d.provider };
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
report.kept.push(`${rel} (${owned ? "modified locally" : "not created by agentkit"})`);
|
|
161
|
+
if (owned)
|
|
162
|
+
files[rel] = owned;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
for (const [rel, entry] of Object.entries(lock?.files ?? {})) {
|
|
166
|
+
if (desired.has(rel))
|
|
167
|
+
continue;
|
|
168
|
+
const abs = join(projectRoot, rel);
|
|
169
|
+
if (!existsSync(abs))
|
|
170
|
+
continue;
|
|
171
|
+
if (sha256(readFileSync(abs)) === entry.sha256 || opts.force) {
|
|
172
|
+
if (!opts.dryRun) {
|
|
173
|
+
unlinkSync(abs);
|
|
174
|
+
removeEmptyParents(projectRoot, abs);
|
|
175
|
+
}
|
|
176
|
+
report.removed.push(rel);
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
report.kept.push(`${rel} (modified locally; no longer synced, left in place)`);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
if (!opts.dryRun) {
|
|
183
|
+
const next = { version: 1, kitVersion: kitVersion(kitRoot), providers, items, files };
|
|
184
|
+
writeFileSync(join(projectRoot, LOCK_FILE), JSON.stringify(next, null, 2) + "\n");
|
|
185
|
+
}
|
|
186
|
+
const prefix = opts.dryRun ? "[dry run] " : "";
|
|
187
|
+
for (const rel of report.created)
|
|
188
|
+
console.log(`${prefix}+ ${rel}`);
|
|
189
|
+
for (const rel of report.updated)
|
|
190
|
+
console.log(`${prefix}~ ${rel}`);
|
|
191
|
+
for (const rel of report.removed)
|
|
192
|
+
console.log(`${prefix}- ${rel}`);
|
|
193
|
+
for (const rel of report.kept)
|
|
194
|
+
console.warn(`${prefix}! kept ${rel}`);
|
|
195
|
+
console.log(`${prefix}Synced ${items.length} item(s) for ${providers.join(", ")} -> ${projectRoot}: ` +
|
|
196
|
+
`${report.created.length} created, ${report.updated.length} updated, ${report.unchanged} unchanged, ` +
|
|
197
|
+
`${report.removed.length} removed, ${report.kept.length} kept.`);
|
|
198
|
+
if (report.kept.length > 0)
|
|
199
|
+
console.warn("Kept files were not overwritten; review them, or rerun with --force to replace them.");
|
|
200
|
+
return report.kept.length > 0 ? 1 : 0;
|
|
201
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { constants } from "node:os";
|
|
3
|
+
/** Update the documented global npm installation, leaving project sync explicit. */
|
|
4
|
+
export function update() {
|
|
5
|
+
console.log("Updating Agent Manifesto Kit: npm install --global agent-manifesto-kit@latest");
|
|
6
|
+
// Windows npm is a .cmd shim. All shell arguments are fixed literals, never user input.
|
|
7
|
+
const child = spawn("npm", ["install", "--global", "agent-manifesto-kit@latest"], {
|
|
8
|
+
stdio: "inherit",
|
|
9
|
+
shell: process.platform === "win32",
|
|
10
|
+
});
|
|
11
|
+
return new Promise((resolve) => {
|
|
12
|
+
let launchFailed = false;
|
|
13
|
+
child.once("error", (error) => {
|
|
14
|
+
launchFailed = true;
|
|
15
|
+
console.error(`update: could not start npm: ${error.message}`);
|
|
16
|
+
console.error("Make sure Node.js and npm are installed and npm is available on PATH.");
|
|
17
|
+
resolve(1);
|
|
18
|
+
});
|
|
19
|
+
child.once("close", (code, signal) => {
|
|
20
|
+
if (launchFailed)
|
|
21
|
+
return;
|
|
22
|
+
if (signal) {
|
|
23
|
+
console.error(`update: npm was interrupted by ${signal}.`);
|
|
24
|
+
resolve(128 + (constants.signals[signal] ?? 1));
|
|
25
|
+
}
|
|
26
|
+
else if (code !== 0) {
|
|
27
|
+
console.error(`update: npm failed (exit code ${code ?? "unknown"}). See its output above.`);
|
|
28
|
+
resolve(code ?? 1);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
console.log('Update completed. Run "agentkit --version" to check the installed version.');
|
|
32
|
+
resolve(0);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
}
|
package/dist/portability.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { PROVIDER_ROOT } from "./providers.js";
|
|
1
|
+
import { CODEX_SKILLS_DIR, PROVIDER_ROOT } from "./providers.js";
|
|
2
|
+
import { markdownAgentToCodexToml } from "./agent-format.js";
|
|
2
3
|
/** Breaking Claude-specific tokens — high-precision, safe to match mechanically. */
|
|
3
4
|
const BREAKING_TOKENS = ["CLAUDE.md", "Task tool"];
|
|
4
5
|
/** Detect breaking provider-specific tokens. Detection only — never rewrites prose. */
|
|
@@ -22,11 +23,27 @@ export function transform(content, provider) {
|
|
|
22
23
|
const rule = RULES[provider];
|
|
23
24
|
let out = content;
|
|
24
25
|
if (rule.swapPaths)
|
|
25
|
-
out = out
|
|
26
|
+
out = swapPaths(out, provider);
|
|
26
27
|
if (rule.stripKeys.length > 0)
|
|
27
28
|
out = stripFrontmatterKeys(out, rule.stripKeys);
|
|
28
29
|
return out;
|
|
29
30
|
}
|
|
31
|
+
/** Rewrite `.claude/` references to the provider's native locations. */
|
|
32
|
+
function swapPaths(content, provider) {
|
|
33
|
+
let out = content;
|
|
34
|
+
if (provider === "codex") {
|
|
35
|
+
out = out.split(".claude/skills/").join(`${CODEX_SKILLS_DIR}/`);
|
|
36
|
+
out = out.replace(/\.claude\/agents\/([A-Za-z0-9_.-]+)\.md/g, ".codex/agents/$1.toml");
|
|
37
|
+
}
|
|
38
|
+
return out.split(".claude/").join(`${PROVIDER_ROOT[provider]}/`);
|
|
39
|
+
}
|
|
40
|
+
/** Render a canonical Markdown agent in the provider's native agent format. */
|
|
41
|
+
export function renderAgent(content, provider, name) {
|
|
42
|
+
if (provider !== "codex")
|
|
43
|
+
return { content: transform(content, provider), dropped: [] };
|
|
44
|
+
const { toml, dropped } = markdownAgentToCodexToml(swapPaths(content, provider), name);
|
|
45
|
+
return { content: toml, dropped };
|
|
46
|
+
}
|
|
30
47
|
/** Remove the given keys from the leading YAML frontmatter block only. */
|
|
31
48
|
function stripFrontmatterKeys(content, keys) {
|
|
32
49
|
const m = /^(---\r?\n)([\s\S]*?)(\r?\n---)/.exec(content);
|