@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,160 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import { dirname, isAbsolute, join, resolve } from "node:path";
|
|
4
|
+
|
|
5
|
+
export const HUB_BINDING_SCHEMA = "kxm.hub-binding.v1" as const;
|
|
6
|
+
export const HUB_HEALTH_PROBE_MS = 300;
|
|
7
|
+
|
|
8
|
+
export type HubHealth = "on" | "off" | "unknown";
|
|
9
|
+
|
|
10
|
+
export interface HubBindingRecord {
|
|
11
|
+
schema: typeof HUB_BINDING_SCHEMA;
|
|
12
|
+
url: string;
|
|
13
|
+
boundAt: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export class HubBindingError extends Error {
|
|
17
|
+
constructor(message: string) {
|
|
18
|
+
super(message);
|
|
19
|
+
this.name = "HubBindingError";
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function resolveUserStateRoot(env: NodeJS.ProcessEnv): string {
|
|
24
|
+
const explicit = env.KXM_STATE_HOME?.trim();
|
|
25
|
+
if (explicit) {
|
|
26
|
+
if (!isAbsolute(explicit)) throw new HubBindingError("local_state_root_not_absolute");
|
|
27
|
+
return resolve(explicit);
|
|
28
|
+
}
|
|
29
|
+
if (process.platform === "win32") {
|
|
30
|
+
const localAppData = env.LOCALAPPDATA?.trim();
|
|
31
|
+
const base = localAppData && isAbsolute(localAppData) ? localAppData : join(homedir(), "AppData", "Local");
|
|
32
|
+
return resolve(base, "KXM");
|
|
33
|
+
}
|
|
34
|
+
if (process.platform === "darwin") return resolve(homedir(), "Library", "Application Support", "KXM");
|
|
35
|
+
const xdgState = env.XDG_STATE_HOME?.trim();
|
|
36
|
+
const base = xdgState && isAbsolute(xdgState) ? xdgState : join(homedir(), ".local", "state");
|
|
37
|
+
return resolve(base, "kxm");
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function hubBindingFile(env: NodeJS.ProcessEnv = process.env): string {
|
|
41
|
+
return join(resolveUserStateRoot(env), "hub-binding.json");
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function validateHubUrl(raw: string): string {
|
|
45
|
+
let parsed: URL;
|
|
46
|
+
try {
|
|
47
|
+
parsed = new URL(raw);
|
|
48
|
+
} catch {
|
|
49
|
+
throw new HubBindingError("hub_url_invalid");
|
|
50
|
+
}
|
|
51
|
+
if (
|
|
52
|
+
(parsed.protocol !== "http:" && parsed.protocol !== "https:")
|
|
53
|
+
|| parsed.username !== ""
|
|
54
|
+
|| parsed.password !== ""
|
|
55
|
+
|| parsed.search !== ""
|
|
56
|
+
|| parsed.hash !== ""
|
|
57
|
+
|| raw.includes("?")
|
|
58
|
+
|| raw.includes("#")
|
|
59
|
+
) {
|
|
60
|
+
throw new HubBindingError("hub_url_invalid");
|
|
61
|
+
}
|
|
62
|
+
return parsed.href.replace(/\/$/, "");
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function isIsoTimestamp(value: string): boolean {
|
|
66
|
+
if (Number.isNaN(Date.parse(value))) return false;
|
|
67
|
+
return value === new Date(value).toISOString();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function isAbortError(error: unknown): boolean {
|
|
71
|
+
return Boolean(
|
|
72
|
+
error
|
|
73
|
+
&& typeof error === "object"
|
|
74
|
+
&& (("name" in error && error.name === "AbortError") || ("code" in error && error.code === "ABORT_ERR")),
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function readHubBinding(env: NodeJS.ProcessEnv = process.env): HubBindingRecord | undefined {
|
|
79
|
+
const file = hubBindingFile(env);
|
|
80
|
+
if (!existsSync(file)) return undefined;
|
|
81
|
+
let parsed: unknown;
|
|
82
|
+
try {
|
|
83
|
+
parsed = JSON.parse(readFileSync(file, "utf8"));
|
|
84
|
+
} catch {
|
|
85
|
+
throw new HubBindingError(`malformed hub binding at ${file}`);
|
|
86
|
+
}
|
|
87
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
88
|
+
throw new HubBindingError(`malformed hub binding at ${file}`);
|
|
89
|
+
}
|
|
90
|
+
const row = parsed as Record<string, unknown>;
|
|
91
|
+
const keys = Object.keys(row);
|
|
92
|
+
if (
|
|
93
|
+
keys.length !== 3
|
|
94
|
+
|| row.schema !== HUB_BINDING_SCHEMA
|
|
95
|
+
|| typeof row.url !== "string"
|
|
96
|
+
|| typeof row.boundAt !== "string"
|
|
97
|
+
|| !isIsoTimestamp(row.boundAt)
|
|
98
|
+
) {
|
|
99
|
+
throw new HubBindingError(`malformed hub binding at ${file}`);
|
|
100
|
+
}
|
|
101
|
+
let url: string;
|
|
102
|
+
try {
|
|
103
|
+
url = validateHubUrl(row.url);
|
|
104
|
+
} catch {
|
|
105
|
+
throw new HubBindingError(`malformed hub binding at ${file}`);
|
|
106
|
+
}
|
|
107
|
+
return { schema: HUB_BINDING_SCHEMA, url, boundAt: row.boundAt };
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export function writeHubBinding(record: HubBindingRecord, env: NodeJS.ProcessEnv = process.env): string {
|
|
111
|
+
const file = hubBindingFile(env);
|
|
112
|
+
mkdirSync(dirname(file), { recursive: true, mode: 0o700 });
|
|
113
|
+
const temporary = join(dirname(file), `.hub-binding-${process.pid}.tmp`);
|
|
114
|
+
try {
|
|
115
|
+
writeFileSync(temporary, `${JSON.stringify(record, null, 2)}\n`, { encoding: "utf8", mode: 0o600 });
|
|
116
|
+
renameSync(temporary, file);
|
|
117
|
+
} finally {
|
|
118
|
+
rmSync(temporary, { force: true });
|
|
119
|
+
}
|
|
120
|
+
return file;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export function removeHubBinding(env: NodeJS.ProcessEnv = process.env): boolean {
|
|
124
|
+
const file = hubBindingFile(env);
|
|
125
|
+
try {
|
|
126
|
+
rmSync(file);
|
|
127
|
+
return true;
|
|
128
|
+
} catch (error) {
|
|
129
|
+
if ((error as NodeJS.ErrnoException).code === "ENOENT") return false;
|
|
130
|
+
throw error;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export async function probeHubHealth(
|
|
135
|
+
url: string,
|
|
136
|
+
fetchImpl: typeof fetch,
|
|
137
|
+
timeoutMs = HUB_HEALTH_PROBE_MS,
|
|
138
|
+
): Promise<{ health: HubHealth; probeMs: number }> {
|
|
139
|
+
const started = Date.now();
|
|
140
|
+
const controller = new AbortController();
|
|
141
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
142
|
+
try {
|
|
143
|
+
const response = await fetchImpl(`${url}/health`, { signal: controller.signal });
|
|
144
|
+
if (!response.ok) return { health: "unknown", probeMs: Date.now() - started };
|
|
145
|
+
let body: unknown;
|
|
146
|
+
try {
|
|
147
|
+
body = await response.json();
|
|
148
|
+
} catch {
|
|
149
|
+
return { health: "unknown", probeMs: Date.now() - started };
|
|
150
|
+
}
|
|
151
|
+
if (body && typeof body === "object" && (body as { ok?: unknown }).ok === true) {
|
|
152
|
+
return { health: "on", probeMs: Date.now() - started };
|
|
153
|
+
}
|
|
154
|
+
return { health: "unknown", probeMs: Date.now() - started };
|
|
155
|
+
} catch (error) {
|
|
156
|
+
return { health: isAbortError(error) ? "unknown" : "off", probeMs: Date.now() - started };
|
|
157
|
+
} finally {
|
|
158
|
+
clearTimeout(timer);
|
|
159
|
+
}
|
|
160
|
+
}
|