@kontextmind/kxm 0.6.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/.claude-plugin/marketplace.json +19 -0
- package/.kxm/README.md +14 -0
- package/.kxm/assets/README.md +5 -0
- package/.kxm/assets/retrospectives/README.md +5 -0
- package/.kxm/config/README.md +5 -0
- package/.kxm/config/agents.json +43 -0
- package/.kxm/config/env.example +56 -0
- package/.kxm/config/update.example.yaml +9 -0
- package/.kxm/config/workflows/fix.json +160 -0
- package/.kxm/config/workflows/jira-development.json +116 -0
- package/.kxm/config/workflows/provenance-quorum.json +150 -0
- package/.kxm/config/workflows/v04-dogfood.json +72 -0
- package/CHANGELOG.md +465 -0
- package/LICENSE +21 -0
- package/README.md +306 -0
- package/SECURITY.md +72 -0
- package/docs/README.md +48 -0
- package/docs/agent-communication-envelopes-and-gates.md +553 -0
- package/docs/architecture.md +242 -0
- package/docs/assignment-runner.md +241 -0
- package/docs/configuration.md +361 -0
- package/docs/continuous-improvement.md +114 -0
- package/docs/getting-started.md +253 -0
- package/docs/kxm-handbook.md +1090 -0
- package/docs/operations.md +205 -0
- package/docs/provenance-gates.md +291 -0
- package/docs/skills.md +45 -0
- package/docs/templates/README.md +95 -0
- package/docs/templates/adr.md +88 -0
- package/docs/templates/architecture.md +120 -0
- package/docs/templates/bug-fix.md +109 -0
- package/docs/templates/feature.md +108 -0
- package/docs/templates/handoff.md +72 -0
- package/docs/templates/postmortem.md +77 -0
- package/docs/templates/research.md +100 -0
- package/docs/templates/review.md +85 -0
- package/docs/templates/runbook.md +73 -0
- package/docs/templates/test-plan.md +87 -0
- package/docs/templates/test-report.md +72 -0
- package/docs/test-matrix.md +121 -0
- package/docs/troubleshooting.md +249 -0
- package/docs/vnext/README.md +62 -0
- package/docs/vnext/architecture.md +185 -0
- package/docs/vnext/effects-and-recovery.md +172 -0
- package/docs/vnext/lifecycles.md +235 -0
- package/docs/vnext/migration.md +220 -0
- package/docs/vnext/routing.md +184 -0
- package/docs/vnext/synchronization.md +172 -0
- package/docs/vnext/terminology.md +240 -0
- package/docs/vnext/validation.md +335 -0
- package/docs/webhook-workflows.md +240 -0
- package/docs/workflow-guide.md +1150 -0
- package/examples/README.md +102 -0
- package/examples/provenance-workflow.json +40 -0
- package/examples/requester.ts +30 -0
- package/examples/reviewer-agent.ts +29 -0
- package/examples/roundtrip.ts +46 -0
- package/examples/vnext/.kxm/agents/coordinator.yaml +16 -0
- package/examples/vnext/.kxm/agents/critic-1.yaml +16 -0
- package/examples/vnext/.kxm/agents/critic-2.yaml +15 -0
- package/examples/vnext/.kxm/agents/critic-3.yaml +15 -0
- package/examples/vnext/.kxm/agents/implementer.yaml +15 -0
- package/examples/vnext/.kxm/agents/planner.yaml +13 -0
- package/examples/vnext/.kxm/agents/reproducer.yaml +15 -0
- package/examples/vnext/.kxm/agents/reviewer.yaml +15 -0
- package/examples/vnext/.kxm/gates.yaml +8 -0
- package/examples/vnext/.kxm/models/critic-claude.yaml +11 -0
- package/examples/vnext/.kxm/models/critic-gemini.yaml +11 -0
- package/examples/vnext/.kxm/models/critic-grok.yaml +12 -0
- package/examples/vnext/.kxm/models/implementation.yaml +14 -0
- package/examples/vnext/.kxm/models/primary.yaml +17 -0
- package/examples/vnext/.kxm/prices.yaml +111 -0
- package/examples/vnext/.kxm/project/env.yaml +7 -0
- package/examples/vnext/.kxm/project.yaml +32 -0
- package/examples/vnext/.kxm/repo/repo.yaml +8 -0
- package/examples/vnext/.kxm/workflows/default.yaml +92 -0
- package/examples/vnext/.kxm/workflows/fix.yaml +376 -0
- package/examples/vnext/.kxm/workflows/improve.yaml +57 -0
- package/examples/vnext/README.md +53 -0
- package/examples/vnext/records/assignment-result-recorded.json +63 -0
- package/examples/vnext/records/assignment-result.json +46 -0
- package/examples/vnext/records/context-candidate.json +42 -0
- package/examples/vnext/records/delivery-manifest.json +66 -0
- package/examples/vnext/records/effect-uncertainty-resolved-sync.json +67 -0
- package/examples/vnext/records/effect-uncertainty-resolved.json +62 -0
- package/examples/vnext/records/run-created.json +54 -0
- package/examples/vnext/records/sync-event.json +65 -0
- package/examples/vnext/repositories/api/.kxm/repo/env.yaml +7 -0
- package/examples/vnext/repositories/api/.kxm/repo/repo.yaml +8 -0
- package/examples/vnext/repositories/web/.kxm/repo/repo.yaml +8 -0
- package/examples/workflow-signal.ts +63 -0
- package/package.json +129 -0
- package/plugins/kxm/.claude-plugin/plugin.json +73 -0
- package/plugins/kxm/.mcp.json +19 -0
- package/plugins/kxm/README.md +93 -0
- package/plugins/kxm/dist/cli.js +42853 -0
- package/plugins/kxm/dist/client.js +416 -0
- package/plugins/kxm/dist/core.js +1823 -0
- package/plugins/kxm/dist/extension.js +3797 -0
- package/plugins/kxm/dist/mcp-server.js +17104 -0
- package/plugins/kxm/dist/runtime.js +23361 -0
- package/plugins/kxm/dist/server.js +13640 -0
- package/plugins/kxm/dist/vnext-runtime-supervisor.js +21109 -0
- package/plugins/kxm/package.json +12 -0
- package/plugins/kxm/skills/kxm/SKILL.md +97 -0
- package/plugins/kxm/skills/kxm/references/protocol.md +103 -0
- package/plugins/kxm/skills/kxm-session/SKILL.md +53 -0
- package/plugins/kxm/src/arbiter.ts +355 -0
- package/plugins/kxm/src/artifacts-exist.ts +62 -0
- package/plugins/kxm/src/autocomplete.ts +236 -0
- package/plugins/kxm/src/cli.ts +3707 -0
- package/plugins/kxm/src/client.ts +614 -0
- package/plugins/kxm/src/commands.ts +1063 -0
- package/plugins/kxm/src/config.ts +290 -0
- package/plugins/kxm/src/context/providers.ts +101 -0
- package/plugins/kxm/src/context-packet.ts +332 -0
- package/plugins/kxm/src/context.ts +499 -0
- package/plugins/kxm/src/core.ts +6 -0
- package/plugins/kxm/src/database.ts +563 -0
- package/plugins/kxm/src/diagnostics.ts +184 -0
- package/plugins/kxm/src/envelope.ts +118 -0
- package/plugins/kxm/src/extension.ts +895 -0
- package/plugins/kxm/src/external-effects.ts +299 -0
- package/plugins/kxm/src/github-watch.ts +255 -0
- package/plugins/kxm/src/hub-binding.ts +160 -0
- package/plugins/kxm/src/hub.ts +2502 -0
- package/plugins/kxm/src/improve.ts +383 -0
- package/plugins/kxm/src/inbox.ts +10 -0
- package/plugins/kxm/src/kxm-install-kind.ts +113 -0
- package/plugins/kxm/src/kxm-update-config.ts +39 -0
- package/plugins/kxm/src/kxm-update.ts +238 -0
- package/plugins/kxm/src/local-snapshot.ts +406 -0
- package/plugins/kxm/src/logger.ts +198 -0
- package/plugins/kxm/src/mcp-server.ts +143 -0
- package/plugins/kxm/src/memory.ts +385 -0
- package/plugins/kxm/src/nous-pi.ts +287 -0
- package/plugins/kxm/src/nous-provider.ts +729 -0
- package/plugins/kxm/src/price-calc.ts +87 -0
- package/plugins/kxm/src/prices.ts +121 -0
- package/plugins/kxm/src/protocol.ts +172 -0
- package/plugins/kxm/src/recovery.ts +211 -0
- package/plugins/kxm/src/redact.ts +26 -0
- package/plugins/kxm/src/retrospective.ts +400 -0
- package/plugins/kxm/src/routing.ts +830 -0
- package/plugins/kxm/src/runtime.ts +9 -0
- package/plugins/kxm/src/server.ts +117 -0
- package/plugins/kxm/src/session-work.ts +571 -0
- package/plugins/kxm/src/session.ts +184 -0
- package/plugins/kxm/src/skills.ts +535 -0
- package/plugins/kxm/src/state.ts +326 -0
- package/plugins/kxm/src/store.ts +637 -0
- package/plugins/kxm/src/studio-layout.ts +268 -0
- package/plugins/kxm/src/suggest.ts +162 -0
- package/plugins/kxm/src/task-manager.ts +244 -0
- package/plugins/kxm/src/telemetry.ts +116 -0
- package/plugins/kxm/src/tui.ts +1046 -0
- package/plugins/kxm/src/vnext-bindings.ts +403 -0
- package/plugins/kxm/src/vnext-config.ts +1646 -0
- package/plugins/kxm/src/vnext-engine-artifacts.ts +86 -0
- package/plugins/kxm/src/vnext-engine-command.ts +533 -0
- package/plugins/kxm/src/vnext-engine-compile.ts +722 -0
- package/plugins/kxm/src/vnext-engine-evidence.ts +273 -0
- package/plugins/kxm/src/vnext-engine-fold.ts +1400 -0
- package/plugins/kxm/src/vnext-engine-gate-records.ts +583 -0
- package/plugins/kxm/src/vnext-engine-plan.ts +717 -0
- package/plugins/kxm/src/vnext-engine.ts +2458 -0
- package/plugins/kxm/src/vnext-gate-hash.ts +10 -0
- package/plugins/kxm/src/vnext-harness.ts +1142 -0
- package/plugins/kxm/src/vnext-init.ts +430 -0
- package/plugins/kxm/src/vnext-migrate.ts +1848 -0
- package/plugins/kxm/src/vnext-oneshot-producer.ts +424 -0
- package/plugins/kxm/src/vnext-permission.ts +936 -0
- package/plugins/kxm/src/vnext-pi-producer.ts +628 -0
- package/plugins/kxm/src/vnext-repair.ts +1094 -0
- package/plugins/kxm/src/vnext-runtime-owner.ts +320 -0
- package/plugins/kxm/src/vnext-runtime-store.ts +1560 -0
- package/plugins/kxm/src/vnext-runtime-supervisor.ts +586 -0
- package/plugins/kxm/src/vnext-runtime.ts +663 -0
- package/plugins/kxm/src/vnext-template.ts +247 -0
- package/plugins/kxm/src/wiki.ts +313 -0
- package/plugins/kxm/src/workflow.ts +1548 -0
- package/schemas/vnext/README.md +46 -0
- package/schemas/vnext/agent.schema.json +40 -0
- package/schemas/vnext/assignment-result.schema.json +66 -0
- package/schemas/vnext/backup-manifest.schema.json +89 -0
- package/schemas/vnext/candidate.schema.json +109 -0
- package/schemas/vnext/common.schema.json +422 -0
- package/schemas/vnext/context-candidate.schema.json +76 -0
- package/schemas/vnext/context-packet.schema.json +192 -0
- package/schemas/vnext/delivery-manifest.schema.json +159 -0
- package/schemas/vnext/environment.schema.json +66 -0
- package/schemas/vnext/gate-registry.schema.json +109 -0
- package/schemas/vnext/handoff-manifest.schema.json +146 -0
- package/schemas/vnext/init-operation.schema.json +61 -0
- package/schemas/vnext/local-repository-bindings.schema.json +30 -0
- package/schemas/vnext/memory-record.schema.json +45 -0
- package/schemas/vnext/migration-decision.schema.json +26 -0
- package/schemas/vnext/migration-plan.schema.json +123 -0
- package/schemas/vnext/migration-receipt.schema.json +52 -0
- package/schemas/vnext/model.schema.json +42 -0
- package/schemas/vnext/permission-diff.schema.json +57 -0
- package/schemas/vnext/prices.schema.json +115 -0
- package/schemas/vnext/project.schema.json +85 -0
- package/schemas/vnext/repository.schema.json +24 -0
- package/schemas/vnext/run-event.schema.json +460 -0
- package/schemas/vnext/session-brief.schema.json +153 -0
- package/schemas/vnext/sync-event.schema.json +234 -0
- package/schemas/vnext/template-provenance.schema.json +38 -0
- package/schemas/vnext/workflow.schema.json +248 -0
- package/scripts/assignment-run.d.mts +354 -0
- package/scripts/assignment-run.mjs +4451 -0
- package/scripts/build-runtime.mjs +56 -0
- package/scripts/check-generated.mjs +77 -0
- package/scripts/check-versions.mjs +34 -0
- package/scripts/emit-codex-artifacts.d.mts +9 -0
- package/scripts/emit-codex-artifacts.mjs +91 -0
- package/scripts/harness-run.d.mts +83 -0
- package/scripts/harness-run.mjs +2095 -0
- package/scripts/kxm-hub.mjs +105 -0
- package/scripts/kxm-publish-npm.mjs +327 -0
- package/scripts/kxm-release-github.mjs +472 -0
- package/scripts/kxm-runtime-supervisor.mjs +7 -0
- package/scripts/kxm-worker.mjs +1127 -0
- package/scripts/kxm.mjs +27 -0
- package/scripts/roster-policy.d.mts +20 -0
- package/scripts/roster-policy.mjs +161 -0
- package/scripts/smoke-multi-pi.mjs +479 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { build } from "esbuild";
|
|
3
|
+
|
|
4
|
+
await build({
|
|
5
|
+
entryPoints: ["plugins/kxm/src/cli.ts", "plugins/kxm/src/server.ts", "plugins/kxm/src/vnext-runtime-supervisor.ts"],
|
|
6
|
+
bundle: true,
|
|
7
|
+
platform: "node",
|
|
8
|
+
format: "esm",
|
|
9
|
+
target: "node22",
|
|
10
|
+
outdir: "plugins/kxm/dist",
|
|
11
|
+
entryNames: "[name]",
|
|
12
|
+
banner: { js: "#!/usr/bin/env node" },
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
await build({
|
|
16
|
+
entryPoints: [
|
|
17
|
+
"plugins/kxm/src/core.ts",
|
|
18
|
+
"plugins/kxm/src/runtime.ts",
|
|
19
|
+
"plugins/kxm/src/client.ts",
|
|
20
|
+
"plugins/kxm/src/extension.ts",
|
|
21
|
+
],
|
|
22
|
+
bundle: true,
|
|
23
|
+
platform: "node",
|
|
24
|
+
format: "esm",
|
|
25
|
+
target: "node22",
|
|
26
|
+
outdir: "plugins/kxm/dist",
|
|
27
|
+
entryNames: "[name]",
|
|
28
|
+
external: ["@earendil-works/pi-coding-agent", "typebox"],
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const shebang = "#!/usr/bin/env node\n";
|
|
32
|
+
const createRequire = "import { createRequire as __kxmCreateRequire } from 'node:module'; const require = __kxmCreateRequire(import.meta.url);\n";
|
|
33
|
+
// The bundled YAML CommonJS internals use dynamic require, which is
|
|
34
|
+
// unsupported in ESM output; provide createRequire for every runtime bundle.
|
|
35
|
+
for (const bundlePath of [
|
|
36
|
+
"plugins/kxm/dist/cli.js",
|
|
37
|
+
"plugins/kxm/dist/server.js",
|
|
38
|
+
"plugins/kxm/dist/vnext-runtime-supervisor.js",
|
|
39
|
+
]) {
|
|
40
|
+
const bundled = readFileSync(bundlePath, "utf8");
|
|
41
|
+
if (!bundled.startsWith(shebang)) throw new Error(`runtime bundle is missing its executable shebang: ${bundlePath}`);
|
|
42
|
+
writeFileSync(bundlePath, `${shebang}${createRequire}${bundled.slice(shebang.length)}`);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const runtimeLibrary = "plugins/kxm/dist/runtime.js";
|
|
46
|
+
const runtimeLibraryText = readFileSync(runtimeLibrary, "utf8");
|
|
47
|
+
if (runtimeLibraryText.startsWith(shebang)) {
|
|
48
|
+
throw new Error(`library bundle must not have an executable shebang: ${runtimeLibrary}`);
|
|
49
|
+
}
|
|
50
|
+
writeFileSync(runtimeLibrary, `${createRequire}${runtimeLibraryText}`);
|
|
51
|
+
|
|
52
|
+
const { emitCodexArtifacts } = await import("./emit-codex-artifacts.mjs");
|
|
53
|
+
emitCodexArtifacts();
|
|
54
|
+
|
|
55
|
+
const { syncHarnessMemory } = await import("../plugins/kxm/src/memory.ts");
|
|
56
|
+
syncHarnessMemory(process.cwd());
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { existsSync } from "node:fs";
|
|
4
|
+
import { resolve } from "node:path";
|
|
5
|
+
import { spawnSync } from "node:child_process";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
|
|
8
|
+
export const GENERATED_ARTIFACTS = [
|
|
9
|
+
"plugins/kxm/dist/cli.js",
|
|
10
|
+
"plugins/kxm/dist/server.js",
|
|
11
|
+
"plugins/kxm/dist/mcp-server.js",
|
|
12
|
+
"plugins/kxm/dist/vnext-runtime-supervisor.js",
|
|
13
|
+
"plugins/kxm/dist/core.js",
|
|
14
|
+
"plugins/kxm/dist/runtime.js",
|
|
15
|
+
"plugins/kxm/dist/client.js",
|
|
16
|
+
"plugins/kxm/dist/extension.js",
|
|
17
|
+
".agents/skills/kxm/SKILL.md",
|
|
18
|
+
".agents/skills/kxm/references/protocol.md",
|
|
19
|
+
".agents/skills/kxm-session/SKILL.md",
|
|
20
|
+
"AGENTS.md",
|
|
21
|
+
"CLAUDE.md",
|
|
22
|
+
"GEMINI.md",
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
function runGit(repository, args, allowFailure = false) {
|
|
26
|
+
const result = spawnSync("git", args, {
|
|
27
|
+
cwd: repository,
|
|
28
|
+
encoding: "utf8",
|
|
29
|
+
windowsHide: true,
|
|
30
|
+
});
|
|
31
|
+
if (result.error) throw new Error(`could not run git: ${result.error.message}`);
|
|
32
|
+
if (!allowFailure && result.status !== 0) {
|
|
33
|
+
throw new Error(`git ${args.join(" ")} failed: ${(result.stderr || result.stdout).trim()}`);
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function checkGeneratedArtifacts(repository = process.cwd()) {
|
|
39
|
+
const requestedRoot = resolve(repository);
|
|
40
|
+
const topLevel = runGit(requestedRoot, ["rev-parse", "--show-toplevel"]).stdout.trim();
|
|
41
|
+
const root = resolve(topLevel);
|
|
42
|
+
const missing = GENERATED_ARTIFACTS.filter((path) => !existsSync(resolve(root, path)));
|
|
43
|
+
if (missing.length > 0) {
|
|
44
|
+
throw new Error(`generated artifacts are missing: ${missing.join(", ")}`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const untracked = GENERATED_ARTIFACTS.filter((path) => runGit(
|
|
48
|
+
root,
|
|
49
|
+
["--literal-pathspecs", "ls-files", "--error-unmatch", "--", path],
|
|
50
|
+
true,
|
|
51
|
+
).status !== 0);
|
|
52
|
+
if (untracked.length > 0) {
|
|
53
|
+
throw new Error(`generated artifacts are not tracked by git: ${untracked.join(", ")}`);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const status = runGit(root, [
|
|
57
|
+
"--literal-pathspecs",
|
|
58
|
+
"diff",
|
|
59
|
+
"--name-only",
|
|
60
|
+
"--",
|
|
61
|
+
...GENERATED_ARTIFACTS,
|
|
62
|
+
]).stdout.trim();
|
|
63
|
+
if (status) {
|
|
64
|
+
throw new Error(`generated artifacts changed after build:\n${status}`);
|
|
65
|
+
}
|
|
66
|
+
return { root, artifacts: [...GENERATED_ARTIFACTS] };
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
70
|
+
try {
|
|
71
|
+
const result = checkGeneratedArtifacts();
|
|
72
|
+
process.stdout.write(`generated artifacts are tracked and current (${result.artifacts.length})\n`);
|
|
73
|
+
} catch (error) {
|
|
74
|
+
process.stderr.write(`${error instanceof Error ? error.message : "generated artifact check failed"}\n`);
|
|
75
|
+
process.exitCode = 1;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
|
|
3
|
+
async function json(path) {
|
|
4
|
+
return JSON.parse(await readFile(path, "utf8"));
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
const root = await json("package.json");
|
|
8
|
+
const lock = await json("package-lock.json");
|
|
9
|
+
const pluginPackage = await json("plugins/kxm/package.json");
|
|
10
|
+
const pluginManifest = await json("plugins/kxm/.claude-plugin/plugin.json");
|
|
11
|
+
const marketplace = await json(".claude-plugin/marketplace.json");
|
|
12
|
+
const mcpSource = await readFile("plugins/kxm/src/mcp-server.ts", "utf8");
|
|
13
|
+
const mcpVersion = mcpSource.match(/const VERSION = "([^"]+)"/)?.[1];
|
|
14
|
+
const marketplaceEntry = marketplace.plugins?.find((plugin) => plugin.name === "kxm");
|
|
15
|
+
|
|
16
|
+
const versions = new Map([
|
|
17
|
+
["root package", root.version],
|
|
18
|
+
["package lock", lock.version],
|
|
19
|
+
["package lock root", lock.packages?.[""]?.version],
|
|
20
|
+
["plugin package", pluginPackage.version],
|
|
21
|
+
["Claude plugin manifest", pluginManifest.version],
|
|
22
|
+
["Claude marketplace entry", marketplaceEntry?.version],
|
|
23
|
+
["MCP server", mcpVersion],
|
|
24
|
+
]);
|
|
25
|
+
|
|
26
|
+
const failures = [...versions].filter(([, version]) => version !== root.version);
|
|
27
|
+
if (failures.length > 0) {
|
|
28
|
+
for (const [name, version] of failures) {
|
|
29
|
+
process.stderr.write(`${name} version ${String(version)} does not match ${root.version}\n`);
|
|
30
|
+
}
|
|
31
|
+
process.exitCode = 1;
|
|
32
|
+
} else {
|
|
33
|
+
process.stdout.write(`all package surfaces use version ${root.version}\n`);
|
|
34
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const CODEX_COMMANDS_BLOCK: string;
|
|
2
|
+
|
|
3
|
+
export interface EmitCodexArtifactsResult {
|
|
4
|
+
readonly destSkillsDir: string;
|
|
5
|
+
readonly agentsPath: string;
|
|
6
|
+
readonly agentsUpdated: boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function emitCodexArtifacts(repoRoot?: string): EmitCodexArtifactsResult;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { cpSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { dirname, join, resolve } from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
|
|
7
|
+
const MARKER_START = "<!-- kxm:codex:commands:start -->";
|
|
8
|
+
const MARKER_END = "<!-- kxm:codex:commands:end -->";
|
|
9
|
+
|
|
10
|
+
export const CODEX_COMMANDS_BLOCK = `${MARKER_START}
|
|
11
|
+
## KXM agent commands
|
|
12
|
+
|
|
13
|
+
The \`kxm\` CLI is the unified agent surface for peer collaboration and workflow stages. Every command supports \`--json\`.
|
|
14
|
+
|
|
15
|
+
### Peer messaging (\`kxm peer <verb> --json\`)
|
|
16
|
+
|
|
17
|
+
| Command | Purpose | Key options |
|
|
18
|
+
|---|---|---|
|
|
19
|
+
| \`kxm peer list\` | List online peer agents and purposes | \`--json\` |
|
|
20
|
+
| \`kxm peer send [target] [content]\` | Send a focused request to a peer | \`--target\`, \`--content\`, \`--delivery <steer\\|followUp\\|nextTurn>\`, \`--correlation-id\`, \`--idempotency-key\`, \`--workflow-context <json>\`, \`--ttl-ms\` |
|
|
21
|
+
| \`kxm peer get [messageId]\` | Check request status without blocking | \`--message-id\` |
|
|
22
|
+
| \`kxm peer await [messageId]\` | Wait for reply (capped at 60 seconds) | \`--message-id\`, \`--timeout-ms\` (max 60000) |
|
|
23
|
+
| \`kxm peer cancel [messageId]\` | Cancel a queued or delivered request | \`--message-id\` |
|
|
24
|
+
| \`kxm peer fanout\` | Send same request to 1–3 peers | \`--targets <t1,t2>\`, \`--content\`, \`--timeout-ms\`, \`--workflow-context <json>\` |
|
|
25
|
+
| \`kxm peer inbox\` | List inbound requests awaiting a reply | \`--json\` |
|
|
26
|
+
| \`kxm peer reply [messageId] [content]\` | Reply to an inbound request | \`--message-id\`, \`--content\` |
|
|
27
|
+
|
|
28
|
+
### Workflow lifecycle (\`kxm workflow <verb> --json\`)
|
|
29
|
+
|
|
30
|
+
| Command | Purpose | Key options |
|
|
31
|
+
|---|---|---|
|
|
32
|
+
| \`kxm workflow checkpoint [runId] [stageId] [status] [summary]\` | Record stage result with verified evidence | \`--run-id\`, \`--stage-id\`, \`--status <passed\\|warning\\|failed>\`, \`--summary\`, \`--evidence <json>\`, \`--evidence-refs <json>\` |
|
|
33
|
+
| \`kxm workflow record [runId] [category] [area] [summary]\` | Record plans, decisions, contradictions, errors, lessons | \`--run-id\`, \`--category <plan\\|decision\\|contradiction\\|error\\|lesson>\`, \`--area\`, \`--severity <info\\|warning\\|error>\`, \`--details\`, \`--evidence <items...>\` |
|
|
34
|
+
| \`kxm workflow wait [runId] [stageId] [signalKey] [summary]\` | Pause stage until an external signed signal arrives | \`--run-id\`, \`--stage-id\`, \`--signal-key\`, \`--summary\`, \`--evidence <json>\`, \`--evidence-refs <json>\`, \`--timeout-ms\` |
|
|
35
|
+
| \`kxm workflow signal <runId> <signalKey> <status> <summary>\` | Resume or unblock a waiting stage or vNext run | \`[evidence...]\`, \`--delivery-id\` |
|
|
36
|
+
| \`kxm workflow list\` | List local workflow runs | \`--json\` |
|
|
37
|
+
| \`kxm workflow get <runId>\` | Get stages and journal for a run | \`--json\` |
|
|
38
|
+
|
|
39
|
+
### Context operating system (\`kxm context <verb> --json\`)
|
|
40
|
+
|
|
41
|
+
| Command | Purpose | Key options |
|
|
42
|
+
|---|---|---|
|
|
43
|
+
| \`kxm context get <project>\` | Assemble role-aware context packet | \`--role\`, \`--task\`, \`--run\`, \`--stage\`, \`--budget\` |
|
|
44
|
+
| \`kxm context recall <project>\` | Search durable context metadata | \`--query\`, \`--kinds\`, \`--limit\` |
|
|
45
|
+
| \`kxm context state <project> <key>\` | Query authoritative temporal state | \`--as-of <timestamp>\` |
|
|
46
|
+
| \`kxm context episode <project>\` | Query workflow learning episodes | \`--run\` |
|
|
47
|
+
| \`kxm context promote <project> <key>\` | Propose temporal state change | \`--summary\`, \`--authority\`, \`--confidence\`, \`--evidence\` |
|
|
48
|
+
${MARKER_END}`;
|
|
49
|
+
|
|
50
|
+
export function emitCodexArtifacts(repoRoot = process.cwd()) {
|
|
51
|
+
const root = resolve(repoRoot);
|
|
52
|
+
const srcSkillsDir = join(root, "plugins", "kxm", "skills");
|
|
53
|
+
const destSkillsDir = join(root, ".agents", "skills");
|
|
54
|
+
|
|
55
|
+
// 1. Emit .agents/skills from authored skill tree
|
|
56
|
+
if (existsSync(srcSkillsDir)) {
|
|
57
|
+
mkdirSync(destSkillsDir, { recursive: true });
|
|
58
|
+
cpSync(srcSkillsDir, destSkillsDir, { recursive: true });
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// 2. Emit marker-delimited AGENTS.md block
|
|
62
|
+
const agentsPath = join(root, "AGENTS.md");
|
|
63
|
+
let agentsUpdated = false;
|
|
64
|
+
if (existsSync(agentsPath)) {
|
|
65
|
+
const original = readFileSync(agentsPath, "utf8");
|
|
66
|
+
let updated;
|
|
67
|
+
if (original.includes(MARKER_START) && original.includes(MARKER_END)) {
|
|
68
|
+
const startIdx = original.indexOf(MARKER_START);
|
|
69
|
+
const endIdx = original.indexOf(MARKER_END) + MARKER_END.length;
|
|
70
|
+
updated = original.slice(0, startIdx) + CODEX_COMMANDS_BLOCK + original.slice(endIdx);
|
|
71
|
+
} else {
|
|
72
|
+
const doNotIdx = original.indexOf("## Do not");
|
|
73
|
+
if (doNotIdx !== -1) {
|
|
74
|
+
updated = `${original.slice(0, doNotIdx)}${CODEX_COMMANDS_BLOCK}\n\n${original.slice(doNotIdx)}`;
|
|
75
|
+
} else {
|
|
76
|
+
updated = `${original.trimEnd()}\n\n${CODEX_COMMANDS_BLOCK}\n`;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (updated !== original) {
|
|
80
|
+
writeFileSync(agentsPath, updated);
|
|
81
|
+
agentsUpdated = true;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return { destSkillsDir, agentsPath, agentsUpdated };
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
89
|
+
const result = emitCodexArtifacts();
|
|
90
|
+
process.stdout.write(`Codex artifacts emitted: skills -> ${result.destSkillsDir}, AGENTS.md updated -> ${result.agentsUpdated}\n`);
|
|
91
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
export const REQUEST_SCHEMA: "kxm.harness-request.v1";
|
|
2
|
+
export const RESULT_SCHEMA: "kxm.harness-result.v2";
|
|
3
|
+
export const OBSOLETE_RESULT_SCHEMA: "kxm.harness-result.v1";
|
|
4
|
+
export const ROUTING_INT_CAP: number;
|
|
5
|
+
export const TOKEN_BASIS: "cumulative";
|
|
6
|
+
export const CONTEXT_OCCUPANCY_UNKNOWN: "unknown";
|
|
7
|
+
export const COST_BASIS: readonly string[];
|
|
8
|
+
export const MODEL_CLAIM_STATUSES: readonly string[];
|
|
9
|
+
export const REVIEW_VERDICTS: readonly string[];
|
|
10
|
+
export const CLAIM_SOURCES: readonly string[];
|
|
11
|
+
export const CLAIM_COUNT_CAP: number;
|
|
12
|
+
export const TRANSPORT_STATUSES: readonly string[];
|
|
13
|
+
export const TRANSPORT_STAGES: readonly string[];
|
|
14
|
+
export const STOP_REASONS: readonly string[];
|
|
15
|
+
export const ERROR_CODES: readonly string[];
|
|
16
|
+
export const EFFORT: readonly string[];
|
|
17
|
+
export const NATIVE_PI_BRAKE_PROVIDERS: readonly string[];
|
|
18
|
+
export const PI_ALLOWED_PROVIDERS: readonly string[];
|
|
19
|
+
export const PI_NOUS_PORTAL_HY4: "nous-portal/tencent/hy4-preview";
|
|
20
|
+
export const PI_ADMITTED_WRITER: "openrouter/qwen/qwen3-coder-plus";
|
|
21
|
+
export const ROUTES: Record<string, {
|
|
22
|
+
provider: string;
|
|
23
|
+
roles: readonly string[];
|
|
24
|
+
permissions: readonly string[];
|
|
25
|
+
models: readonly string[];
|
|
26
|
+
efforts: readonly string[];
|
|
27
|
+
auth: { args: readonly string[]; loginHint: string };
|
|
28
|
+
}>;
|
|
29
|
+
|
|
30
|
+
export function clampEffort(harness: string, effort?: string): { effort?: string; clamped?: string };
|
|
31
|
+
export function parseJson(text: string): unknown;
|
|
32
|
+
export function piProviderOf(model?: string): string | undefined;
|
|
33
|
+
export function piModelId(model?: string): string | undefined;
|
|
34
|
+
export function piAuthCheckArgs(request: { model: string; role: string }): string[];
|
|
35
|
+
export function resolveLauncher(cliId: string, options?: {
|
|
36
|
+
platform?: NodeJS.Platform | string;
|
|
37
|
+
pathEnv?: string;
|
|
38
|
+
existsSync?: (path: string) => boolean;
|
|
39
|
+
realpathSync?: (path: string) => string;
|
|
40
|
+
}): string;
|
|
41
|
+
export function unsupportedLauncherMessage(target: string, platform?: string): string;
|
|
42
|
+
export function parseAuth(harness: string, stdio: {
|
|
43
|
+
stdout?: string;
|
|
44
|
+
stderr?: string;
|
|
45
|
+
exitCode?: number | null;
|
|
46
|
+
status?: number | null;
|
|
47
|
+
}, options?: { observedAt?: string; provider?: string }): {
|
|
48
|
+
loggedIn: true;
|
|
49
|
+
method: string;
|
|
50
|
+
observedAt: string;
|
|
51
|
+
subscriptionType?: unknown;
|
|
52
|
+
};
|
|
53
|
+
export function buildArgv(request: Record<string, unknown>, ctx?: {
|
|
54
|
+
mcpConfigPath?: string;
|
|
55
|
+
promptPath?: string;
|
|
56
|
+
promptText?: string;
|
|
57
|
+
schemaPath?: string;
|
|
58
|
+
schemaText?: string;
|
|
59
|
+
}): string[];
|
|
60
|
+
export function formatRunCost(result: {
|
|
61
|
+
costBasis?: string | null;
|
|
62
|
+
costUsd?: number;
|
|
63
|
+
providerReportedCostUsd?: number;
|
|
64
|
+
}): string;
|
|
65
|
+
export function diagnoseHarnessResult(payload: unknown, filePath?: string): {
|
|
66
|
+
result?: Record<string, any>;
|
|
67
|
+
diagnostic?: string;
|
|
68
|
+
};
|
|
69
|
+
export function formatRunListing(payload: unknown, filePath?: string): string;
|
|
70
|
+
export function normalizePi(stdout: string): Record<string, any>;
|
|
71
|
+
export function normalizeCodex(stdout: string): Record<string, any>;
|
|
72
|
+
export function normalizeAgy(payload: unknown): Record<string, any>;
|
|
73
|
+
export function resolveModelUsage(modelUsage: Record<string, unknown>, requestedModel?: string): {
|
|
74
|
+
effectiveModel?: string;
|
|
75
|
+
primary?: Record<string, unknown>;
|
|
76
|
+
auxiliary: unknown[];
|
|
77
|
+
candidates: string[];
|
|
78
|
+
matched?: string;
|
|
79
|
+
};
|
|
80
|
+
export function normalizeClaudeOrGrok(payload: unknown, requestedModel?: string): Record<string, any>;
|
|
81
|
+
export function preflightRequest(request: unknown): unknown;
|
|
82
|
+
export function runHarness(request: unknown, deps?: Record<string, unknown>): Promise<Record<string, any>>;
|
|
83
|
+
export function main(argv?: string[], io?: { stdin: NodeJS.ReadableStream; stdout: NodeJS.WritableStream; stderr: NodeJS.WritableStream }): Promise<Record<string, unknown>>;
|