@kontextmind/kxm 0.7.5 → 0.7.6
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 +1 -1
- package/package.json +1 -1
- package/plugins/kxm/.claude-plugin/plugin.json +1 -1
- package/plugins/kxm/dist/cli.js +421 -155
- package/plugins/kxm/dist/mcp-server.js +1 -1
- package/plugins/kxm/dist/runtime.js +267 -16
- package/plugins/kxm/package.json +1 -1
- package/plugins/kxm/src/cli.ts +39 -0
- package/plugins/kxm/src/mcp-server.ts +1 -1
- package/plugins/kxm/src/modes.ts +348 -0
- package/plugins/kxm/src/runtime.ts +1 -0
- package/schemas/vnext/modes.schema.json +56 -0
|
@@ -17036,7 +17036,7 @@ async function deliverInboxNotification(messageId, delivered, notify) {
|
|
|
17036
17036
|
}
|
|
17037
17037
|
|
|
17038
17038
|
// plugins/kxm/src/mcp-server.ts
|
|
17039
|
-
var VERSION = "0.7.
|
|
17039
|
+
var VERSION = "0.7.6";
|
|
17040
17040
|
var inbox = /* @__PURE__ */ new Map();
|
|
17041
17041
|
var notifiedInbox = /* @__PURE__ */ new Set();
|
|
17042
17042
|
var meshClient;
|
|
@@ -3834,7 +3834,7 @@ var require_fast_uri = __commonJS({
|
|
|
3834
3834
|
normalizeString(uri, options);
|
|
3835
3835
|
} else if (typeof uri === "object") {
|
|
3836
3836
|
uri = /** @type {T} */
|
|
3837
|
-
|
|
3837
|
+
parse6(serialize(uri, options), options);
|
|
3838
3838
|
}
|
|
3839
3839
|
return uri;
|
|
3840
3840
|
}
|
|
@@ -3874,8 +3874,8 @@ var require_fast_uri = __commonJS({
|
|
|
3874
3874
|
function resolveComponent(base, relative5, options, skipNormalization) {
|
|
3875
3875
|
const target = {};
|
|
3876
3876
|
if (!skipNormalization) {
|
|
3877
|
-
base =
|
|
3878
|
-
relative5 =
|
|
3877
|
+
base = parse6(serialize(base, options), options);
|
|
3878
|
+
relative5 = parse6(serialize(relative5, options), options);
|
|
3879
3879
|
}
|
|
3880
3880
|
options = options || {};
|
|
3881
3881
|
if (!options.tolerant && relative5.scheme) {
|
|
@@ -4167,7 +4167,7 @@ var require_fast_uri = __commonJS({
|
|
|
4167
4167
|
}
|
|
4168
4168
|
return { parsed, malformedAuthorityOrPort, malformedPercentEncoding, malformedSchemeSpecific, malformedHost, malformedScheme };
|
|
4169
4169
|
}
|
|
4170
|
-
function
|
|
4170
|
+
function parse6(uri, opts) {
|
|
4171
4171
|
return parseWithStatus(uri, opts).parsed;
|
|
4172
4172
|
}
|
|
4173
4173
|
function normalizeString(uri, opts) {
|
|
@@ -4204,7 +4204,7 @@ var require_fast_uri = __commonJS({
|
|
|
4204
4204
|
resolveComponent,
|
|
4205
4205
|
equal,
|
|
4206
4206
|
serialize,
|
|
4207
|
-
parse:
|
|
4207
|
+
parse: parse6
|
|
4208
4208
|
};
|
|
4209
4209
|
module.exports = fastUri;
|
|
4210
4210
|
module.exports.default = fastUri;
|
|
@@ -14674,7 +14674,7 @@ var require_public_api = __commonJS({
|
|
|
14674
14674
|
}
|
|
14675
14675
|
return doc;
|
|
14676
14676
|
}
|
|
14677
|
-
function
|
|
14677
|
+
function parse6(src, reviver, options) {
|
|
14678
14678
|
let _reviver = void 0;
|
|
14679
14679
|
if (typeof reviver === "function") {
|
|
14680
14680
|
_reviver = reviver;
|
|
@@ -14715,7 +14715,7 @@ var require_public_api = __commonJS({
|
|
|
14715
14715
|
return value.toString(options);
|
|
14716
14716
|
return new Document.Document(value, _replacer, options).toString(options);
|
|
14717
14717
|
}
|
|
14718
|
-
exports.parse =
|
|
14718
|
+
exports.parse = parse6;
|
|
14719
14719
|
exports.parseAllDocuments = parseAllDocuments;
|
|
14720
14720
|
exports.parseDocument = parseDocument2;
|
|
14721
14721
|
exports.stringify = stringify3;
|
|
@@ -16925,8 +16925,8 @@ function validateWorkflow(workflow, agents, models, repositories, gates, issues)
|
|
|
16925
16925
|
const writable = Object.values(objectValue(step.repositories) ?? {}).filter((access) => access === "write").length;
|
|
16926
16926
|
if (maxWriteRepositories > writable) issues.push(issue2("semantic", "write_repository_bound_invalid", file, `${stepId} maxWriteRepositories exceeds writable repository scope`));
|
|
16927
16927
|
}
|
|
16928
|
-
const
|
|
16929
|
-
const minimumPassed =
|
|
16928
|
+
const join16 = objectValue(step.join);
|
|
16929
|
+
const minimumPassed = join16 && typeof join16.minimumPassed === "number" ? join16.minimumPassed : void 0;
|
|
16930
16930
|
if (minimumPassed !== void 0 && minimumPassed > maximum) issues.push(issue2("semantic", "join_impossible", file, `${stepId} minimumPassed exceeds assignment maximum`));
|
|
16931
16931
|
const distinctBy = names(assignment?.distinctBy);
|
|
16932
16932
|
if (distinctBy.length > 0) {
|
|
@@ -20454,7 +20454,7 @@ function compileStep(step, index, stepIndex, requirePlanHash, sink) {
|
|
|
20454
20454
|
const maxAttempts = compileCountField(step.maxAttempts, 1, `${id}.maxAttempts`, id, sink);
|
|
20455
20455
|
const timeoutMs = compileOptionalDuration(step.timeoutMs, `${id}.timeoutMs`, id, sink);
|
|
20456
20456
|
const assignments = compileAssignments(step, id, agent, sink);
|
|
20457
|
-
const
|
|
20457
|
+
const join16 = compileJoin(step, id, sink);
|
|
20458
20458
|
const requiredEvidence = compileEvidence(step, id, sink);
|
|
20459
20459
|
const transitions = compileTransitions(step, id, index, stepIndex, sink);
|
|
20460
20460
|
const outcomes = Object.keys(transitions).sort(compareCodeUnits4);
|
|
@@ -20482,7 +20482,7 @@ function compileStep(step, index, stepIndex, requirePlanHash, sink) {
|
|
|
20482
20482
|
transitions: orderedTransitions,
|
|
20483
20483
|
requiresPlanHash: requirePlanHash.includes(id),
|
|
20484
20484
|
assignments,
|
|
20485
|
-
join:
|
|
20485
|
+
join: join16
|
|
20486
20486
|
};
|
|
20487
20487
|
if (kind === "agent" || kind === "moa") {
|
|
20488
20488
|
if (!agent) return void 0;
|
|
@@ -20532,15 +20532,15 @@ function compileAssignments(step, stepId, primaryAgentId, sink) {
|
|
|
20532
20532
|
};
|
|
20533
20533
|
}
|
|
20534
20534
|
function compileJoin(step, stepId, sink) {
|
|
20535
|
-
const
|
|
20536
|
-
if (!
|
|
20537
|
-
const declared = stringValue2(
|
|
20535
|
+
const join16 = objectValue2(step.join);
|
|
20536
|
+
if (!join16) return { strategy: "all" };
|
|
20537
|
+
const declared = stringValue2(join16.strategy);
|
|
20538
20538
|
const strategy = declared && JOIN_STRATEGIES.has(declared) ? declared : "all";
|
|
20539
|
-
const minimumPassed = compileOptionalCount(
|
|
20539
|
+
const minimumPassed = compileOptionalCount(join16.minimumPassed, `${stepId}.join.minimumPassed`, stepId, sink);
|
|
20540
20540
|
const compiled = {
|
|
20541
20541
|
strategy,
|
|
20542
20542
|
...minimumPassed !== void 0 ? { minimumPassed } : {},
|
|
20543
|
-
...typeof
|
|
20543
|
+
...typeof join16.cancelRemaining === "boolean" ? { cancelRemaining: join16.cancelRemaining } : {}
|
|
20544
20544
|
};
|
|
20545
20545
|
return compiled;
|
|
20546
20546
|
}
|
|
@@ -28173,6 +28173,251 @@ Instructions for Operator:
|
|
|
28173
28173
|
return orphaned;
|
|
28174
28174
|
}
|
|
28175
28175
|
};
|
|
28176
|
+
|
|
28177
|
+
// plugins/kxm/src/modes.ts
|
|
28178
|
+
var import_yaml6 = __toESM(require_dist(), 1);
|
|
28179
|
+
import { existsSync as existsSync12, readFileSync as readFileSync10 } from "node:fs";
|
|
28180
|
+
import { join as join15 } from "node:path";
|
|
28181
|
+
var DEFAULT_MODES_CONFIG = Object.freeze({
|
|
28182
|
+
schema: "kxm.modes.v1",
|
|
28183
|
+
majorModes: {
|
|
28184
|
+
coder: {
|
|
28185
|
+
description: "First-pass implementation, bug fixing, and test authoring",
|
|
28186
|
+
baseTools: ["read", "edit", "write", "bash"],
|
|
28187
|
+
contextFiles: ["AGENTS.md"],
|
|
28188
|
+
thinkingLevel: "medium",
|
|
28189
|
+
model: "grok/grok-4.6"
|
|
28190
|
+
},
|
|
28191
|
+
planner: {
|
|
28192
|
+
description: "High-level architectural planning, scoping, and decomposition",
|
|
28193
|
+
baseTools: ["read", "grep", "find"],
|
|
28194
|
+
contextFiles: ["plans/implementation-plan.md"],
|
|
28195
|
+
thinkingLevel: "high",
|
|
28196
|
+
model: "claude/fable"
|
|
28197
|
+
},
|
|
28198
|
+
auditor: {
|
|
28199
|
+
description: "Security, compliance, and code quality verification",
|
|
28200
|
+
baseTools: ["read", "grep"],
|
|
28201
|
+
contextFiles: ["SECURITY.md"],
|
|
28202
|
+
thinkingLevel: "high",
|
|
28203
|
+
model: "codex/gpt-5.6-sol"
|
|
28204
|
+
},
|
|
28205
|
+
browser: {
|
|
28206
|
+
description: "Web application exploration, screenshotting, and UI testing",
|
|
28207
|
+
baseTools: ["read", "bash"],
|
|
28208
|
+
contextFiles: ["docs/browser-automation.md"],
|
|
28209
|
+
thinkingLevel: "medium",
|
|
28210
|
+
model: "grok/grok-4.6"
|
|
28211
|
+
}
|
|
28212
|
+
},
|
|
28213
|
+
domains: {
|
|
28214
|
+
git: {
|
|
28215
|
+
description: "Git version control operations",
|
|
28216
|
+
tools: ["git_status", "git_diff", "git_commit"],
|
|
28217
|
+
promptSnippet: "Follow git branch conventions; never commit directly to main."
|
|
28218
|
+
},
|
|
28219
|
+
k8s: {
|
|
28220
|
+
description: "Kubernetes cluster inspection and deployment",
|
|
28221
|
+
tools: ["kubectl_get", "kubectl_describe"],
|
|
28222
|
+
promptSnippet: "Target local dev cluster; verify namespaces before mutating."
|
|
28223
|
+
},
|
|
28224
|
+
database: {
|
|
28225
|
+
description: "Database queries and schema verification",
|
|
28226
|
+
tools: ["sqlite_query", "sqlite_schema"],
|
|
28227
|
+
promptSnippet: "Database is SQLite at .kxm/state/kxm.db; use read-only queries."
|
|
28228
|
+
},
|
|
28229
|
+
browser: {
|
|
28230
|
+
description: "Remote Steel browser sessions and visual testing",
|
|
28231
|
+
tools: ["steel_session", "steel_scrape", "steel_screenshot"],
|
|
28232
|
+
promptSnippet: "Use Steel on DOKS for browser automation; invoke takeover on MFA."
|
|
28233
|
+
}
|
|
28234
|
+
}
|
|
28235
|
+
});
|
|
28236
|
+
function estimateTokens(charCount) {
|
|
28237
|
+
return Math.ceil(charCount / 3.8);
|
|
28238
|
+
}
|
|
28239
|
+
function loadModesConfig(projectRoot) {
|
|
28240
|
+
if (!projectRoot) {
|
|
28241
|
+
return DEFAULT_MODES_CONFIG;
|
|
28242
|
+
}
|
|
28243
|
+
const modesPath = join15(projectRoot, ".kxm", "modes.yaml");
|
|
28244
|
+
if (!existsSync12(modesPath)) {
|
|
28245
|
+
return DEFAULT_MODES_CONFIG;
|
|
28246
|
+
}
|
|
28247
|
+
try {
|
|
28248
|
+
const raw = readFileSync10(modesPath, "utf8");
|
|
28249
|
+
const parsed = (0, import_yaml6.parse)(raw);
|
|
28250
|
+
if (parsed && parsed.schema === "kxm.modes.v1" && parsed.majorModes) {
|
|
28251
|
+
return {
|
|
28252
|
+
schema: "kxm.modes.v1",
|
|
28253
|
+
majorModes: { ...DEFAULT_MODES_CONFIG.majorModes, ...parsed.majorModes },
|
|
28254
|
+
domains: { ...DEFAULT_MODES_CONFIG.domains, ...parsed.domains }
|
|
28255
|
+
};
|
|
28256
|
+
}
|
|
28257
|
+
} catch {
|
|
28258
|
+
}
|
|
28259
|
+
return DEFAULT_MODES_CONFIG;
|
|
28260
|
+
}
|
|
28261
|
+
function resolveActiveMode(config, majorModeName = "coder", domainNames = []) {
|
|
28262
|
+
const major = config.majorModes[majorModeName] || config.majorModes["coder"] || DEFAULT_MODES_CONFIG.majorModes["coder"];
|
|
28263
|
+
const tools = new Set(major.baseTools);
|
|
28264
|
+
const contextFiles = new Set(major.contextFiles || []);
|
|
28265
|
+
const promptSnippets = [];
|
|
28266
|
+
const enabledDomains = [];
|
|
28267
|
+
if (config.domains) {
|
|
28268
|
+
for (const dName of domainNames) {
|
|
28269
|
+
const d = config.domains[dName.toLowerCase().trim()];
|
|
28270
|
+
if (d) {
|
|
28271
|
+
enabledDomains.push(dName.toLowerCase().trim());
|
|
28272
|
+
d.tools.forEach((t) => tools.add(t));
|
|
28273
|
+
(d.contextFiles || []).forEach((f) => contextFiles.add(f));
|
|
28274
|
+
if (d.promptSnippet) {
|
|
28275
|
+
promptSnippets.push(d.promptSnippet);
|
|
28276
|
+
}
|
|
28277
|
+
}
|
|
28278
|
+
}
|
|
28279
|
+
}
|
|
28280
|
+
return {
|
|
28281
|
+
majorMode: majorModeName,
|
|
28282
|
+
enabledDomains,
|
|
28283
|
+
tools: Array.from(tools),
|
|
28284
|
+
contextFiles: Array.from(contextFiles),
|
|
28285
|
+
promptSnippets,
|
|
28286
|
+
thinkingLevel: major.thinkingLevel,
|
|
28287
|
+
model: major.model || "grok/grok-4.6"
|
|
28288
|
+
};
|
|
28289
|
+
}
|
|
28290
|
+
function calculatePromptFootprint(resolved, projectRoot = process.cwd(), catalog) {
|
|
28291
|
+
const breakdown = [];
|
|
28292
|
+
const baseSystemPromptChars = 3200;
|
|
28293
|
+
breakdown.push({
|
|
28294
|
+
name: `Base System Prompt (${resolved.majorMode})`,
|
|
28295
|
+
chars: baseSystemPromptChars,
|
|
28296
|
+
estimatedTokens: estimateTokens(baseSystemPromptChars)
|
|
28297
|
+
});
|
|
28298
|
+
for (const relPath of resolved.contextFiles) {
|
|
28299
|
+
const fullPath = join15(projectRoot, relPath);
|
|
28300
|
+
let chars = 0;
|
|
28301
|
+
if (existsSync12(fullPath)) {
|
|
28302
|
+
try {
|
|
28303
|
+
chars = readFileSync10(fullPath, "utf8").length;
|
|
28304
|
+
} catch {
|
|
28305
|
+
chars = 0;
|
|
28306
|
+
}
|
|
28307
|
+
}
|
|
28308
|
+
if (chars === 0) {
|
|
28309
|
+
chars = 1500;
|
|
28310
|
+
}
|
|
28311
|
+
breakdown.push({
|
|
28312
|
+
name: `Context File: ${relPath}`,
|
|
28313
|
+
chars,
|
|
28314
|
+
estimatedTokens: estimateTokens(chars)
|
|
28315
|
+
});
|
|
28316
|
+
}
|
|
28317
|
+
if (resolved.promptSnippets.length > 0) {
|
|
28318
|
+
const snippetChars = resolved.promptSnippets.join("\n").length;
|
|
28319
|
+
breakdown.push({
|
|
28320
|
+
name: `Domain Prompts (${resolved.enabledDomains.join(", ")})`,
|
|
28321
|
+
chars: snippetChars,
|
|
28322
|
+
estimatedTokens: estimateTokens(snippetChars)
|
|
28323
|
+
});
|
|
28324
|
+
}
|
|
28325
|
+
const toolSchemaChars = resolved.tools.length * 650;
|
|
28326
|
+
breakdown.push({
|
|
28327
|
+
name: `Tool Schemas (${resolved.tools.length} active tools)`,
|
|
28328
|
+
chars: toolSchemaChars,
|
|
28329
|
+
estimatedTokens: estimateTokens(toolSchemaChars)
|
|
28330
|
+
});
|
|
28331
|
+
const totalChars = breakdown.reduce((sum, item) => sum + item.chars, 0);
|
|
28332
|
+
const totalTokens = breakdown.reduce((sum, item) => sum + item.estimatedTokens, 0);
|
|
28333
|
+
const maxContextWindow = 2e5;
|
|
28334
|
+
const contextWindowRatio = Math.round(totalTokens / maxContextWindow * 1e3) / 10;
|
|
28335
|
+
const cat = catalog || loadPriceCatalog(projectRoot);
|
|
28336
|
+
const rawModel = resolved.model || "grok/grok-4.6";
|
|
28337
|
+
const [prov, mod] = rawModel.includes("/") ? rawModel.split("/", 2) : [void 0, rawModel];
|
|
28338
|
+
const inputCost = cat ? calculateModelCost(cat, {
|
|
28339
|
+
model: mod || rawModel,
|
|
28340
|
+
...prov !== void 0 ? { provider: prov } : {},
|
|
28341
|
+
tokensIn: totalTokens,
|
|
28342
|
+
tokensOut: 0,
|
|
28343
|
+
cacheReadTokens: 0,
|
|
28344
|
+
cacheWriteTokens: 0
|
|
28345
|
+
}) : void 0;
|
|
28346
|
+
const cacheReadCost = cat ? calculateModelCost(cat, {
|
|
28347
|
+
model: mod || rawModel,
|
|
28348
|
+
...prov !== void 0 ? { provider: prov } : {},
|
|
28349
|
+
tokensIn: 0,
|
|
28350
|
+
tokensOut: 0,
|
|
28351
|
+
cacheReadTokens: totalTokens,
|
|
28352
|
+
cacheWriteTokens: 0
|
|
28353
|
+
}) : void 0;
|
|
28354
|
+
const outputEstimateCost = cat ? calculateModelCost(cat, {
|
|
28355
|
+
model: mod || rawModel,
|
|
28356
|
+
...prov !== void 0 ? { provider: prov } : {},
|
|
28357
|
+
tokensIn: 0,
|
|
28358
|
+
tokensOut: 1e3,
|
|
28359
|
+
cacheReadTokens: 0,
|
|
28360
|
+
cacheWriteTokens: 0
|
|
28361
|
+
}) : void 0;
|
|
28362
|
+
return {
|
|
28363
|
+
majorMode: resolved.majorMode,
|
|
28364
|
+
enabledDomains: resolved.enabledDomains,
|
|
28365
|
+
model: resolved.model || "grok/grok-4.6",
|
|
28366
|
+
breakdown,
|
|
28367
|
+
totalChars,
|
|
28368
|
+
totalTokens,
|
|
28369
|
+
contextWindowRatio,
|
|
28370
|
+
projectedCost: {
|
|
28371
|
+
inputCostUsd: inputCost?.costUsd ?? null,
|
|
28372
|
+
cacheReadCostUsd: cacheReadCost?.costUsd ?? null,
|
|
28373
|
+
outputCostEstimateUsd: outputEstimateCost?.costUsd ?? null
|
|
28374
|
+
}
|
|
28375
|
+
};
|
|
28376
|
+
}
|
|
28377
|
+
function formatModesExplainReport(footprint) {
|
|
28378
|
+
const divider = "\u2550".repeat(60);
|
|
28379
|
+
const subDivider = "\u2500".repeat(60);
|
|
28380
|
+
let out = `
|
|
28381
|
+
${divider}
|
|
28382
|
+
`;
|
|
28383
|
+
out += `KXM PRE-FLIGHT CONTEXT EXPLAIN
|
|
28384
|
+
`;
|
|
28385
|
+
out += `${divider}
|
|
28386
|
+
`;
|
|
28387
|
+
out += `Major Mode: ${footprint.majorMode}
|
|
28388
|
+
`;
|
|
28389
|
+
out += `Enabled Domains: ${footprint.enabledDomains.length > 0 ? footprint.enabledDomains.join(", ") : "(none)"}
|
|
28390
|
+
`;
|
|
28391
|
+
out += `Target Model: ${footprint.model}
|
|
28392
|
+
|
|
28393
|
+
`;
|
|
28394
|
+
out += `CONTEXT BREAKDOWN:
|
|
28395
|
+
`;
|
|
28396
|
+
for (const item of footprint.breakdown) {
|
|
28397
|
+
const padName = item.name.padEnd(38, " ");
|
|
28398
|
+
const tokenStr = `${item.estimatedTokens.toLocaleString()} tokens`.padStart(16, " ");
|
|
28399
|
+
out += ` \u2022 ${padName} ${tokenStr}
|
|
28400
|
+
`;
|
|
28401
|
+
}
|
|
28402
|
+
out += `${subDivider}
|
|
28403
|
+
`;
|
|
28404
|
+
const totalPad = `TOTAL PROMPT FOOTPRINT:`.padEnd(38, " ");
|
|
28405
|
+
const totalStr = `${footprint.totalTokens.toLocaleString()} tokens`.padStart(16, " ");
|
|
28406
|
+
out += ` ${totalPad} ${totalStr} (${footprint.contextWindowRatio}% of 200k window)
|
|
28407
|
+
|
|
28408
|
+
`;
|
|
28409
|
+
out += `PROJECTED COSTS (per turn):
|
|
28410
|
+
`;
|
|
28411
|
+
out += ` \u2022 Initial Turn Input Cost: ${footprint.projectedCost.inputCostUsd !== null ? `$${footprint.projectedCost.inputCostUsd.toFixed(4)}` : "unmetered/unknown"}
|
|
28412
|
+
`;
|
|
28413
|
+
out += ` \u2022 Subsequent Cache-Read Cost: ${footprint.projectedCost.cacheReadCostUsd !== null ? `$${footprint.projectedCost.cacheReadCostUsd.toFixed(4)} (approx 90% savings)` : "unmetered/unknown"}
|
|
28414
|
+
`;
|
|
28415
|
+
out += ` \u2022 Output Estimate (1k tokens): ${footprint.projectedCost.outputCostEstimateUsd !== null ? `$${footprint.projectedCost.outputCostEstimateUsd.toFixed(4)}` : "unmetered/unknown"}
|
|
28416
|
+
`;
|
|
28417
|
+
out += `${divider}
|
|
28418
|
+
`;
|
|
28419
|
+
return out;
|
|
28420
|
+
}
|
|
28176
28421
|
export {
|
|
28177
28422
|
BUILTIN_HARNESSES,
|
|
28178
28423
|
BUILTIN_HARNESS_IDS,
|
|
@@ -28180,6 +28425,7 @@ export {
|
|
|
28180
28425
|
DEFAULT_HARNESS,
|
|
28181
28426
|
DEFAULT_LOG_MAX_BYTES,
|
|
28182
28427
|
DEFAULT_LOG_MAX_FILES,
|
|
28428
|
+
DEFAULT_MODES_CONFIG,
|
|
28183
28429
|
IMPROVEMENT_REPORT_SCHEMA,
|
|
28184
28430
|
IMPROVEMENT_REPORT_V1_SCHEMA,
|
|
28185
28431
|
LOG_LEVEL_PRIORITY,
|
|
@@ -28202,6 +28448,7 @@ export {
|
|
|
28202
28448
|
assertVnextConfigError,
|
|
28203
28449
|
backupDatabaseFile,
|
|
28204
28450
|
buildImprovementReport,
|
|
28451
|
+
calculatePromptFootprint,
|
|
28205
28452
|
cancelVnextRun,
|
|
28206
28453
|
checkIntegrity,
|
|
28207
28454
|
checkMemoryRevisionDrift,
|
|
@@ -28222,6 +28469,7 @@ export {
|
|
|
28222
28469
|
eligibleHarnesses,
|
|
28223
28470
|
ensureVnextSupervisor,
|
|
28224
28471
|
ensureWalJournalMode,
|
|
28472
|
+
estimateTokens,
|
|
28225
28473
|
evaluatePromotionPolicy,
|
|
28226
28474
|
fileSha256,
|
|
28227
28475
|
findWinNpmInnerExe,
|
|
@@ -28231,6 +28479,7 @@ export {
|
|
|
28231
28479
|
formatHarnessInventory,
|
|
28232
28480
|
formatHarnessUpdate,
|
|
28233
28481
|
formatImprovementReport,
|
|
28482
|
+
formatModesExplainReport,
|
|
28234
28483
|
formatPiSessionDisplayName,
|
|
28235
28484
|
formatPiSessionKey,
|
|
28236
28485
|
gateRowContentHash,
|
|
@@ -28242,6 +28491,7 @@ export {
|
|
|
28242
28491
|
isKnownHarnessId,
|
|
28243
28492
|
isVnextRuntimeContextClosed,
|
|
28244
28493
|
isWindowsHarnessShim,
|
|
28494
|
+
loadModesConfig,
|
|
28245
28495
|
newVnextAssignmentId,
|
|
28246
28496
|
newVnextAttemptId,
|
|
28247
28497
|
newVnextCommandId,
|
|
@@ -28271,6 +28521,7 @@ export {
|
|
|
28271
28521
|
rebuildVnextRunProjection,
|
|
28272
28522
|
redactLogValue,
|
|
28273
28523
|
registerVnextRuntimeCloseHook,
|
|
28524
|
+
resolveActiveMode,
|
|
28274
28525
|
resolveDispatchStatus,
|
|
28275
28526
|
resolvePassCliApiKey,
|
|
28276
28527
|
resolveSteelConfig,
|
package/plugins/kxm/package.json
CHANGED
package/plugins/kxm/src/cli.ts
CHANGED
|
@@ -113,6 +113,12 @@ import {
|
|
|
113
113
|
import { generateShellCompletion, type SupportedShell } from "./autocomplete.ts";
|
|
114
114
|
import { completionRcTarget, completionScriptPath, detectShell, installPathEntry, installShellCompletion, kxmBinDir } from "./completion-install.ts";
|
|
115
115
|
import { suggestWorkflowAndRoles } from "./suggest.ts";
|
|
116
|
+
import {
|
|
117
|
+
loadModesConfig,
|
|
118
|
+
resolveActiveMode,
|
|
119
|
+
calculatePromptFootprint,
|
|
120
|
+
formatModesExplainReport,
|
|
121
|
+
} from "./modes.ts";
|
|
116
122
|
import {
|
|
117
123
|
createGoal,
|
|
118
124
|
createTask,
|
|
@@ -1261,6 +1267,28 @@ async function cmdModelInventoryRefresh(runtime: Runtime): Promise<number> {
|
|
|
1261
1267
|
return failed ? 1 : 0;
|
|
1262
1268
|
}
|
|
1263
1269
|
|
|
1270
|
+
async function cmdExplain(
|
|
1271
|
+
runtime: Runtime,
|
|
1272
|
+
options: { mode?: string; domains?: string; model?: string },
|
|
1273
|
+
): Promise<number> {
|
|
1274
|
+
const modesConfig = loadModesConfig(runtime.dirs.workdir);
|
|
1275
|
+
const majorMode = options.mode || "coder";
|
|
1276
|
+
const domains = options.domains
|
|
1277
|
+
? options.domains.split(",").map((s) => s.trim()).filter(Boolean)
|
|
1278
|
+
: [];
|
|
1279
|
+
const resolved = resolveActiveMode(modesConfig, majorMode, domains);
|
|
1280
|
+
if (options.model) {
|
|
1281
|
+
resolved.model = options.model;
|
|
1282
|
+
}
|
|
1283
|
+
const footprint = calculatePromptFootprint(resolved, runtime.dirs.workdir);
|
|
1284
|
+
if (runtime.json) {
|
|
1285
|
+
print(runtime.io, runtime.json, { ok: true, command: "explain", ...footprint }, "");
|
|
1286
|
+
} else {
|
|
1287
|
+
runtime.io.stdout(formatModesExplainReport(footprint) + "\n");
|
|
1288
|
+
}
|
|
1289
|
+
return 0;
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1264
1292
|
async function cmdUpdate(runtime: Runtime, harness: string | undefined, options: {
|
|
1265
1293
|
self?: boolean;
|
|
1266
1294
|
extensions?: boolean;
|
|
@@ -5080,6 +5108,17 @@ function createProgram(ctx: CliContext, result: { code: number }): Command {
|
|
|
5080
5108
|
result.code = await cmdRoutingBenchmark(runtimeFrom(ctx, this), options);
|
|
5081
5109
|
});
|
|
5082
5110
|
|
|
5111
|
+
addGlobalOptions(
|
|
5112
|
+
program
|
|
5113
|
+
.command("explain")
|
|
5114
|
+
.description("Pre-flight context footprint and token cost inspection for workflow modes")
|
|
5115
|
+
.option("--mode <name>", "Major mode (coder, planner, auditor, browser)", "coder")
|
|
5116
|
+
.option("--domains <list>", "Comma-separated domain modules (git, k8s, database, browser)")
|
|
5117
|
+
.option("--model <id>", "Target model identifier (e.g. grok/grok-4.6, claude/fable)")
|
|
5118
|
+
).action(async function explainAction(this: Command, options: { mode?: string; domains?: string; model?: string }) {
|
|
5119
|
+
result.code = await cmdExplain(runtimeFrom(ctx, this), options);
|
|
5120
|
+
});
|
|
5121
|
+
|
|
5083
5122
|
const hub = addGlobalOptions(program.command("hub").description("Start, inspect, and stop the local KXM hub"));
|
|
5084
5123
|
hub.helpCommand("help", "Show hub help");
|
|
5085
5124
|
addGlobalOptions(hub.command("view").description("Check hub /health and /ready")).action(bind(cmdStatus));
|
|
@@ -7,7 +7,7 @@ import { AGENT_COMMANDS_MAP, enforceToolPolicy, getMcpTools, reconcileInbox } fr
|
|
|
7
7
|
import { deliverInboxNotification } from "./inbox.ts";
|
|
8
8
|
import type { HubEvent, MessageRecord } from "./protocol.ts";
|
|
9
9
|
|
|
10
|
-
const VERSION = "0.7.
|
|
10
|
+
const VERSION = "0.7.6";
|
|
11
11
|
const inbox = new Map<string, MessageRecord>();
|
|
12
12
|
const notifiedInbox = new Set<string>();
|
|
13
13
|
let meshClient: HubClient | undefined;
|