context-mode 2.0.2 → 2.1.1
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 +6 -2
- package/.claude-plugin/plugin.json +5 -2
- package/.codex-plugin/plugin.json +1 -1
- package/README.md +87 -91
- package/SHA256SUMS +18 -21
- package/cli.mjs +244 -118
- package/copilot/plugin.json +1 -1
- package/gemini-extension.json +1 -1
- package/hook.mjs +87 -84
- package/opencode/plugin.js +316 -214
- package/package.json +1 -2
- package/pi/index.js +364 -262
- package/qwen-extension.json +1 -1
- package/run.mjs +66 -21
- package/search.mjs +66 -21
- package/server.mjs +349 -247
- package/skills/ctx-doctor/SKILL.md +1 -1
- package/skills/ctx-stats/SKILL.md +1 -1
- package/skills/ctx-upgrade/SKILL.md +1 -1
- package/claude-code/skills/ctx-doctor/SKILL.md +0 -6
- package/claude-code/skills/ctx-stats/SKILL.md +0 -6
- package/claude-code/skills/ctx-upgrade/SKILL.md +0 -6
package/qwen-extension.json
CHANGED
package/run.mjs
CHANGED
|
@@ -359,8 +359,8 @@ var DB_SIBLING_SUFFIXES = Object.freeze(["", DB_WAL_SUFFIX, DB_SHM_SUFFIX]);
|
|
|
359
359
|
var UPGRADE_HOST_COMMAND = Object.freeze({
|
|
360
360
|
"claude-code": "claude plugin marketplace update context-mode && claude plugin update context-mode@context-mode",
|
|
361
361
|
codex: "rewrite config.toml's [mcp_servers.context-mode*] block to the v2 entry, then restart Codex",
|
|
362
|
-
gemini: "gemini extensions install https://github.com/mksglu/context-mode --
|
|
363
|
-
qwen: "qwen extensions install https://github.com/mksglu/context-mode --
|
|
362
|
+
gemini: "gemini extensions install https://github.com/mksglu/context-mode --auto-update",
|
|
363
|
+
qwen: "qwen extensions install https://github.com/mksglu/context-mode --auto-update"
|
|
364
364
|
});
|
|
365
365
|
var V1_SCRIPT_NAMES = Object.freeze([
|
|
366
366
|
"afteragentresponse.mjs",
|
|
@@ -385,6 +385,7 @@ var VSCODE_MCP_FILE = "mcp.json";
|
|
|
385
385
|
var KIRO_AGENT_FILE = Object.freeze(["agents", "default.json"]);
|
|
386
386
|
var KIRO_STEERING_FILE = Object.freeze(["steering", "KIRO.md"]);
|
|
387
387
|
var OPENCODE_CONFIG_FILES = Object.freeze(["opencode.jsonc", "opencode.json"]);
|
|
388
|
+
var OPENCODE_NPM_SPEC_PREFIX = `${SERVER_KEY}@`;
|
|
388
389
|
var V1_DATA_ROOT_ENTRIES = Object.freeze(["content", "platform.json"]);
|
|
389
390
|
var PI_ROLE = "custom";
|
|
390
391
|
var V1_PATH_SEPS = Object.freeze(["/", "\\"]);
|
|
@@ -438,6 +439,7 @@ var DOCTOR_DOCS_LABEL = "Docs: ";
|
|
|
438
439
|
var DOCTOR_REPORT_LINE = "Report file: ";
|
|
439
440
|
var DOCTOR_GH_LINE = "File it: ";
|
|
440
441
|
var DOCTOR_URL_LINE = "Or open: ";
|
|
442
|
+
var DOCTOR_RULES_LINE = "Rules: ";
|
|
441
443
|
var DOCTOR_GH_NEXT = " --";
|
|
442
444
|
var DOCTOR_NOTE_PREFIXES = Object.freeze([
|
|
443
445
|
DOCTOR_ENV_PREFIX,
|
|
@@ -445,10 +447,23 @@ var DOCTOR_NOTE_PREFIXES = Object.freeze([
|
|
|
445
447
|
DOCTOR_REPORT_LINE,
|
|
446
448
|
DOCTOR_GH_LINE,
|
|
447
449
|
DOCTOR_GH_NEXT.trim(),
|
|
448
|
-
DOCTOR_URL_LINE
|
|
450
|
+
DOCTOR_URL_LINE,
|
|
451
|
+
DOCTOR_RULES_LINE
|
|
449
452
|
]);
|
|
450
453
|
var ISSUE_REPO_SLUG = "mksglu/context-mode";
|
|
451
454
|
var ISSUE_FORM_FILE = "agent-report.yml";
|
|
455
|
+
var ISSUE_GUIDE_URL = `https://github.com/${ISSUE_REPO_SLUG}/blob/main/.github/AGENT_ISSUE.md`;
|
|
456
|
+
var ISSUE_AGENT_RULES = Object.freeze([
|
|
457
|
+
'Search for the same problem first: `gh issue list -R mksglu/context-mode --state all --search "<check id or error>"`. When one matches, add your facts there as a comment.',
|
|
458
|
+
"File one bug per issue.",
|
|
459
|
+
"Call the `ctx_doctor` tool and paste its full output unchanged in the `ctx-report` field.",
|
|
460
|
+
"Give the versions: context-mode, the agent, the OS and arch, and Node.",
|
|
461
|
+
"Write numbered repro steps that start from a fresh project (`mktemp -d`) and the agent's own install command.",
|
|
462
|
+
"Give the exact command and its exact output in a fenced code block.",
|
|
463
|
+
"Say what you expected and what happened instead.",
|
|
464
|
+
"Name the source file and line when you found the cause.",
|
|
465
|
+
"Replace every secret with `<masked>` and the home folder with `~` before you send."
|
|
466
|
+
]);
|
|
452
467
|
var ISSUE_FORM_HEADINGS = Object.freeze([
|
|
453
468
|
"Summary",
|
|
454
469
|
"ctx-report",
|
|
@@ -474,16 +489,16 @@ var DOCTOR_ENV_NAMES = Object.freeze([
|
|
|
474
489
|
var DOCTOR_PATH_TOOLS = Object.freeze(["node", "git", "sh"]);
|
|
475
490
|
var DOCTOR_SECRET_WORDS = Object.freeze(["token", "secret", "password", "apikey", "api_key", "authorization", "bearer"]);
|
|
476
491
|
var NATIVE_INSTALL = Object.freeze({
|
|
477
|
-
"claude-code": ["claude plugin marketplace add mksglu/context-mode
|
|
478
|
-
codex: ["codex plugin marketplace add mksglu/context-mode
|
|
479
|
-
gemini: ["gemini extensions install https://github.com/mksglu/context-mode
|
|
480
|
-
qwen: ["qwen extensions install https://github.com/mksglu/context-mode:context-mode
|
|
481
|
-
opencode: ["opencode plugin add context-mode
|
|
482
|
-
pi: ["pi install npm:context-mode
|
|
483
|
-
"copilot-cli": ["npm i -g context-mode
|
|
484
|
-
vscode: ["npm i -g context-mode
|
|
485
|
-
kiro: ["npm i -g context-mode
|
|
486
|
-
zcode: ["npm i -g context-mode
|
|
492
|
+
"claude-code": ["claude plugin marketplace add mksglu/context-mode", "claude plugin install context-mode@context-mode"],
|
|
493
|
+
codex: ["codex plugin marketplace add mksglu/context-mode", "codex plugin add context-mode@context-mode"],
|
|
494
|
+
gemini: ["gemini extensions install https://github.com/mksglu/context-mode"],
|
|
495
|
+
qwen: ["qwen extensions install https://github.com/mksglu/context-mode:context-mode"],
|
|
496
|
+
opencode: ["opencode plugin add context-mode"],
|
|
497
|
+
pi: ["pi install npm:context-mode"],
|
|
498
|
+
"copilot-cli": ["npm i -g context-mode", "context-mode setup --agents copilot-cli"],
|
|
499
|
+
vscode: ["npm i -g context-mode", "context-mode setup --agents vscode"],
|
|
500
|
+
kiro: ["npm i -g context-mode", "context-mode setup --agents kiro"],
|
|
501
|
+
zcode: ["npm i -g context-mode", "context-mode setup --agents zcode"]
|
|
487
502
|
});
|
|
488
503
|
var ISSUE_FORM_URL = `https://github.com/${ISSUE_REPO_SLUG}/issues/new?template=${ISSUE_FORM_FILE}`;
|
|
489
504
|
|
|
@@ -529,7 +544,7 @@ function outputOf(resp) {
|
|
|
529
544
|
function textSlot(r) {
|
|
530
545
|
const file = r.file;
|
|
531
546
|
if (r.type === "text" && typeof file === "object" && file !== null && typeof file.content === "string") {
|
|
532
|
-
return { text: file.content, put: (o, output) => ({ ...o, file:
|
|
547
|
+
return { text: file.content, put: (o, output) => ({ ...o, file: readFile(o.file, output) }) };
|
|
533
548
|
}
|
|
534
549
|
if (isGrepContent(r)) return { text: r.content, put: (o, output) => ({ ...o, content: output }) };
|
|
535
550
|
if (Array.isArray(r.filenames) && r.filenames.every((f) => typeof f === "string")) {
|
|
@@ -538,13 +553,35 @@ function textSlot(r) {
|
|
|
538
553
|
if (typeof r.result === "string") return { text: r.result, put: (o, output) => ({ ...o, result: output }) };
|
|
539
554
|
return null;
|
|
540
555
|
}
|
|
556
|
+
function readFile(file, output) {
|
|
557
|
+
const start = typeof file.startLine === "number" ? file.startLine : 1;
|
|
558
|
+
const lines = String(file.content).split("\n");
|
|
559
|
+
const read2 = typeof file.numLines === "number" ? file.numLines : lines.length;
|
|
560
|
+
const out = output.split("\n");
|
|
561
|
+
const run = firstRun(lines, out);
|
|
562
|
+
if (run === null) return { ...file, content: output, startLine: start + read2, numLines: out.length };
|
|
563
|
+
const kept = out.slice(0, run.length);
|
|
564
|
+
if (run.length < out.length) kept.push(out[out.length - 1]);
|
|
565
|
+
return { ...file, content: kept.join("\n"), startLine: start + run.at, numLines: kept.length };
|
|
566
|
+
}
|
|
567
|
+
function firstRun(lines, out) {
|
|
568
|
+
let best = null;
|
|
569
|
+
for (let i = 0; i < lines.length; i++) {
|
|
570
|
+
if (lines[i] !== out[0]) continue;
|
|
571
|
+
let n = 1;
|
|
572
|
+
while (n < out.length && i + n < lines.length && lines[i + n] === out[n]) n++;
|
|
573
|
+
if (best === null || n > best.length) best = { at: i, length: n };
|
|
574
|
+
if (n === out.length) break;
|
|
575
|
+
}
|
|
576
|
+
return best;
|
|
577
|
+
}
|
|
541
578
|
function isShellShape(resp) {
|
|
542
579
|
const r = resp;
|
|
543
580
|
return typeof r.stdout === "string" || typeof r.stderr === "string";
|
|
544
581
|
}
|
|
545
582
|
function isGrepContent(resp) {
|
|
546
583
|
const r = resp;
|
|
547
|
-
return r.mode === "content" && typeof r.content === "string";
|
|
584
|
+
return (r.mode === "content" || r.mode === "count") && typeof r.content === "string";
|
|
548
585
|
}
|
|
549
586
|
function blocksOf(resp) {
|
|
550
587
|
const parts = [];
|
|
@@ -560,6 +597,7 @@ function readResult(resp) {
|
|
|
560
597
|
const text = outputOf(resp);
|
|
561
598
|
const isError = typeof resp === "object" && resp !== null && resp.is_error === true;
|
|
562
599
|
const info = { isError, bytes: Buffer.byteLength(text), text };
|
|
600
|
+
if (typeof resp === "object" && resp !== null && !Array.isArray(resp) && isShellShape(resp)) info.shape = resp;
|
|
563
601
|
if (typeof resp === "object" && resp !== null && !Array.isArray(resp) && !isShellShape(resp)) {
|
|
564
602
|
if (textSlot(resp) !== null) info.shape = resp;
|
|
565
603
|
else info.keep = true;
|
|
@@ -599,8 +637,11 @@ function decodeClaudeShape(raw, agent, ownPrefix, sources) {
|
|
|
599
637
|
return ev;
|
|
600
638
|
}
|
|
601
639
|
function replaceShape(ev, output) {
|
|
602
|
-
if (ev.tool?.canonicalName === "Bash") return { stdout: output, stderr: "", interrupted: false };
|
|
603
640
|
const shape = ev.result?.shape;
|
|
641
|
+
if (ev.tool?.canonicalName === "Bash") {
|
|
642
|
+
const { persistedOutputPath: _p, persistedOutputSize: _s, ...host } = shape ?? {};
|
|
643
|
+
return { interrupted: false, ...host, stdout: output, stderr: "" };
|
|
644
|
+
}
|
|
604
645
|
const slot = shape === void 0 ? null : textSlot(shape);
|
|
605
646
|
if (shape !== void 0 && slot !== null) return slot.put(shape, output);
|
|
606
647
|
if (ev.result?.blocks === true) return [{ type: "text", text: output }];
|
|
@@ -995,7 +1036,8 @@ function encode6(ev, d, _extra) {
|
|
|
995
1036
|
}
|
|
996
1037
|
|
|
997
1038
|
// src/adapters/kiro.ts
|
|
998
|
-
var TOOL_NAME_PREFIX7 = "
|
|
1039
|
+
var TOOL_NAME_PREFIX7 = "mcp_context_mode_";
|
|
1040
|
+
var LEGACY_TOOL_NAME_PREFIX = "mcp_context-mode_";
|
|
999
1041
|
var KIRO_EVENTS = {
|
|
1000
1042
|
SessionStart: "SessionStart",
|
|
1001
1043
|
agentSpawn: "SessionStart",
|
|
@@ -1007,6 +1049,7 @@ var KIRO_EVENTS = {
|
|
|
1007
1049
|
PostToolUse: "PostToolUse",
|
|
1008
1050
|
postToolUse: "PostToolUse"
|
|
1009
1051
|
};
|
|
1052
|
+
var PROMPT_FIELD = "prompt";
|
|
1010
1053
|
var PROMPT_ENV = "USER_PROMPT";
|
|
1011
1054
|
var MCP_PREFIX3 = "mcp_";
|
|
1012
1055
|
var SHELL_TOOL_NAMES4 = Object.freeze(["execute_bash", "execute_pwsh", "shell"]);
|
|
@@ -1015,6 +1058,7 @@ var MCP_SEP3 = "_";
|
|
|
1015
1058
|
var KIRO_SOURCES = { startup: "startup", resume: "resume", clear: "clear", compact: "compact" };
|
|
1016
1059
|
function canonicalName5(name) {
|
|
1017
1060
|
if (name.startsWith(TOOL_NAME_PREFIX7)) return name.slice(TOOL_NAME_PREFIX7.length);
|
|
1061
|
+
if (name.startsWith(LEGACY_TOOL_NAME_PREFIX)) return name.slice(LEGACY_TOOL_NAME_PREFIX.length);
|
|
1018
1062
|
if (Object.hasOwn(NATIVE_TO_CANONICAL5, name)) return NATIVE_TO_CANONICAL5[name];
|
|
1019
1063
|
if (!name.startsWith(MCP_PREFIX3)) return name;
|
|
1020
1064
|
const rest = name.slice(MCP_PREFIX3.length);
|
|
@@ -1035,7 +1079,8 @@ function decode7(raw) {
|
|
|
1035
1079
|
const ev = { event, agent: "kiro", sessionId: String(p.session_id ?? ""), cwd: String(p.cwd ?? "") };
|
|
1036
1080
|
if (event === "SessionStart" && typeof p.source === "string" && KIRO_SOURCES[p.source] !== void 0) ev.source = KIRO_SOURCES[p.source];
|
|
1037
1081
|
if (event === "UserPromptSubmit") {
|
|
1038
|
-
const
|
|
1082
|
+
const field = p[PROMPT_FIELD];
|
|
1083
|
+
const prompt = typeof field === "string" ? field : process.env[PROMPT_ENV];
|
|
1039
1084
|
if (prompt !== void 0) ev.prompt = prompt;
|
|
1040
1085
|
}
|
|
1041
1086
|
if (event === "PreToolUse" || event === "PostToolUse") {
|
|
@@ -1047,7 +1092,7 @@ function decode7(raw) {
|
|
|
1047
1092
|
return ev;
|
|
1048
1093
|
}
|
|
1049
1094
|
function encode7(ev, d, _extra) {
|
|
1050
|
-
if (ev.event === "UserPromptSubmit") return { stdout: "", exitCode: 0 };
|
|
1095
|
+
if (ev.event === "UserPromptSubmit") return { stdout: d.kind === "hint" ? d.text : "", exitCode: 0 };
|
|
1051
1096
|
switch (d.kind) {
|
|
1052
1097
|
case "allow":
|
|
1053
1098
|
return { stdout: "", exitCode: 0 };
|
|
@@ -1216,8 +1261,8 @@ var ADAPTERS = Object.freeze([
|
|
|
1216
1261
|
hookTimeoutMs: HOOK_TIMEOUT_MS,
|
|
1217
1262
|
denyChannel: "deny-reason",
|
|
1218
1263
|
hookChannel: { kind: "package", path: "hooks/claude-code.json" },
|
|
1219
|
-
skillChannel: { kind: "package", path: "
|
|
1220
|
-
// ADR-0020, D-
|
|
1264
|
+
skillChannel: { kind: "package", path: "skills" },
|
|
1265
|
+
// ADR-0020, D-R33-CC-SKILLS-1: Claude Code always loads <plugin>/skills, shared with gemini and qwen
|
|
1221
1266
|
decode,
|
|
1222
1267
|
encode
|
|
1223
1268
|
},
|
package/search.mjs
CHANGED
|
@@ -359,8 +359,8 @@ var DB_SIBLING_SUFFIXES = Object.freeze(["", DB_WAL_SUFFIX, DB_SHM_SUFFIX]);
|
|
|
359
359
|
var UPGRADE_HOST_COMMAND = Object.freeze({
|
|
360
360
|
"claude-code": "claude plugin marketplace update context-mode && claude plugin update context-mode@context-mode",
|
|
361
361
|
codex: "rewrite config.toml's [mcp_servers.context-mode*] block to the v2 entry, then restart Codex",
|
|
362
|
-
gemini: "gemini extensions install https://github.com/mksglu/context-mode --
|
|
363
|
-
qwen: "qwen extensions install https://github.com/mksglu/context-mode --
|
|
362
|
+
gemini: "gemini extensions install https://github.com/mksglu/context-mode --auto-update",
|
|
363
|
+
qwen: "qwen extensions install https://github.com/mksglu/context-mode --auto-update"
|
|
364
364
|
});
|
|
365
365
|
var V1_SCRIPT_NAMES = Object.freeze([
|
|
366
366
|
"afteragentresponse.mjs",
|
|
@@ -385,6 +385,7 @@ var VSCODE_MCP_FILE = "mcp.json";
|
|
|
385
385
|
var KIRO_AGENT_FILE = Object.freeze(["agents", "default.json"]);
|
|
386
386
|
var KIRO_STEERING_FILE = Object.freeze(["steering", "KIRO.md"]);
|
|
387
387
|
var OPENCODE_CONFIG_FILES = Object.freeze(["opencode.jsonc", "opencode.json"]);
|
|
388
|
+
var OPENCODE_NPM_SPEC_PREFIX = `${SERVER_KEY}@`;
|
|
388
389
|
var V1_DATA_ROOT_ENTRIES = Object.freeze(["content", "platform.json"]);
|
|
389
390
|
var PI_ROLE = "custom";
|
|
390
391
|
var V1_PATH_SEPS = Object.freeze(["/", "\\"]);
|
|
@@ -438,6 +439,7 @@ var DOCTOR_DOCS_LABEL = "Docs: ";
|
|
|
438
439
|
var DOCTOR_REPORT_LINE = "Report file: ";
|
|
439
440
|
var DOCTOR_GH_LINE = "File it: ";
|
|
440
441
|
var DOCTOR_URL_LINE = "Or open: ";
|
|
442
|
+
var DOCTOR_RULES_LINE = "Rules: ";
|
|
441
443
|
var DOCTOR_GH_NEXT = " --";
|
|
442
444
|
var DOCTOR_NOTE_PREFIXES = Object.freeze([
|
|
443
445
|
DOCTOR_ENV_PREFIX,
|
|
@@ -445,10 +447,23 @@ var DOCTOR_NOTE_PREFIXES = Object.freeze([
|
|
|
445
447
|
DOCTOR_REPORT_LINE,
|
|
446
448
|
DOCTOR_GH_LINE,
|
|
447
449
|
DOCTOR_GH_NEXT.trim(),
|
|
448
|
-
DOCTOR_URL_LINE
|
|
450
|
+
DOCTOR_URL_LINE,
|
|
451
|
+
DOCTOR_RULES_LINE
|
|
449
452
|
]);
|
|
450
453
|
var ISSUE_REPO_SLUG = "mksglu/context-mode";
|
|
451
454
|
var ISSUE_FORM_FILE = "agent-report.yml";
|
|
455
|
+
var ISSUE_GUIDE_URL = `https://github.com/${ISSUE_REPO_SLUG}/blob/main/.github/AGENT_ISSUE.md`;
|
|
456
|
+
var ISSUE_AGENT_RULES = Object.freeze([
|
|
457
|
+
'Search for the same problem first: `gh issue list -R mksglu/context-mode --state all --search "<check id or error>"`. When one matches, add your facts there as a comment.',
|
|
458
|
+
"File one bug per issue.",
|
|
459
|
+
"Call the `ctx_doctor` tool and paste its full output unchanged in the `ctx-report` field.",
|
|
460
|
+
"Give the versions: context-mode, the agent, the OS and arch, and Node.",
|
|
461
|
+
"Write numbered repro steps that start from a fresh project (`mktemp -d`) and the agent's own install command.",
|
|
462
|
+
"Give the exact command and its exact output in a fenced code block.",
|
|
463
|
+
"Say what you expected and what happened instead.",
|
|
464
|
+
"Name the source file and line when you found the cause.",
|
|
465
|
+
"Replace every secret with `<masked>` and the home folder with `~` before you send."
|
|
466
|
+
]);
|
|
452
467
|
var ISSUE_FORM_HEADINGS = Object.freeze([
|
|
453
468
|
"Summary",
|
|
454
469
|
"ctx-report",
|
|
@@ -474,16 +489,16 @@ var DOCTOR_ENV_NAMES = Object.freeze([
|
|
|
474
489
|
var DOCTOR_PATH_TOOLS = Object.freeze(["node", "git", "sh"]);
|
|
475
490
|
var DOCTOR_SECRET_WORDS = Object.freeze(["token", "secret", "password", "apikey", "api_key", "authorization", "bearer"]);
|
|
476
491
|
var NATIVE_INSTALL = Object.freeze({
|
|
477
|
-
"claude-code": ["claude plugin marketplace add mksglu/context-mode
|
|
478
|
-
codex: ["codex plugin marketplace add mksglu/context-mode
|
|
479
|
-
gemini: ["gemini extensions install https://github.com/mksglu/context-mode
|
|
480
|
-
qwen: ["qwen extensions install https://github.com/mksglu/context-mode:context-mode
|
|
481
|
-
opencode: ["opencode plugin add context-mode
|
|
482
|
-
pi: ["pi install npm:context-mode
|
|
483
|
-
"copilot-cli": ["npm i -g context-mode
|
|
484
|
-
vscode: ["npm i -g context-mode
|
|
485
|
-
kiro: ["npm i -g context-mode
|
|
486
|
-
zcode: ["npm i -g context-mode
|
|
492
|
+
"claude-code": ["claude plugin marketplace add mksglu/context-mode", "claude plugin install context-mode@context-mode"],
|
|
493
|
+
codex: ["codex plugin marketplace add mksglu/context-mode", "codex plugin add context-mode@context-mode"],
|
|
494
|
+
gemini: ["gemini extensions install https://github.com/mksglu/context-mode"],
|
|
495
|
+
qwen: ["qwen extensions install https://github.com/mksglu/context-mode:context-mode"],
|
|
496
|
+
opencode: ["opencode plugin add context-mode"],
|
|
497
|
+
pi: ["pi install npm:context-mode"],
|
|
498
|
+
"copilot-cli": ["npm i -g context-mode", "context-mode setup --agents copilot-cli"],
|
|
499
|
+
vscode: ["npm i -g context-mode", "context-mode setup --agents vscode"],
|
|
500
|
+
kiro: ["npm i -g context-mode", "context-mode setup --agents kiro"],
|
|
501
|
+
zcode: ["npm i -g context-mode", "context-mode setup --agents zcode"]
|
|
487
502
|
});
|
|
488
503
|
var ISSUE_FORM_URL = `https://github.com/${ISSUE_REPO_SLUG}/issues/new?template=${ISSUE_FORM_FILE}`;
|
|
489
504
|
|
|
@@ -529,7 +544,7 @@ function outputOf(resp) {
|
|
|
529
544
|
function textSlot(r) {
|
|
530
545
|
const file = r.file;
|
|
531
546
|
if (r.type === "text" && typeof file === "object" && file !== null && typeof file.content === "string") {
|
|
532
|
-
return { text: file.content, put: (o, output) => ({ ...o, file:
|
|
547
|
+
return { text: file.content, put: (o, output) => ({ ...o, file: readFile(o.file, output) }) };
|
|
533
548
|
}
|
|
534
549
|
if (isGrepContent(r)) return { text: r.content, put: (o, output) => ({ ...o, content: output }) };
|
|
535
550
|
if (Array.isArray(r.filenames) && r.filenames.every((f) => typeof f === "string")) {
|
|
@@ -538,13 +553,35 @@ function textSlot(r) {
|
|
|
538
553
|
if (typeof r.result === "string") return { text: r.result, put: (o, output) => ({ ...o, result: output }) };
|
|
539
554
|
return null;
|
|
540
555
|
}
|
|
556
|
+
function readFile(file, output) {
|
|
557
|
+
const start = typeof file.startLine === "number" ? file.startLine : 1;
|
|
558
|
+
const lines = String(file.content).split("\n");
|
|
559
|
+
const read2 = typeof file.numLines === "number" ? file.numLines : lines.length;
|
|
560
|
+
const out = output.split("\n");
|
|
561
|
+
const run = firstRun(lines, out);
|
|
562
|
+
if (run === null) return { ...file, content: output, startLine: start + read2, numLines: out.length };
|
|
563
|
+
const kept = out.slice(0, run.length);
|
|
564
|
+
if (run.length < out.length) kept.push(out[out.length - 1]);
|
|
565
|
+
return { ...file, content: kept.join("\n"), startLine: start + run.at, numLines: kept.length };
|
|
566
|
+
}
|
|
567
|
+
function firstRun(lines, out) {
|
|
568
|
+
let best = null;
|
|
569
|
+
for (let i = 0; i < lines.length; i++) {
|
|
570
|
+
if (lines[i] !== out[0]) continue;
|
|
571
|
+
let n = 1;
|
|
572
|
+
while (n < out.length && i + n < lines.length && lines[i + n] === out[n]) n++;
|
|
573
|
+
if (best === null || n > best.length) best = { at: i, length: n };
|
|
574
|
+
if (n === out.length) break;
|
|
575
|
+
}
|
|
576
|
+
return best;
|
|
577
|
+
}
|
|
541
578
|
function isShellShape(resp) {
|
|
542
579
|
const r = resp;
|
|
543
580
|
return typeof r.stdout === "string" || typeof r.stderr === "string";
|
|
544
581
|
}
|
|
545
582
|
function isGrepContent(resp) {
|
|
546
583
|
const r = resp;
|
|
547
|
-
return r.mode === "content" && typeof r.content === "string";
|
|
584
|
+
return (r.mode === "content" || r.mode === "count") && typeof r.content === "string";
|
|
548
585
|
}
|
|
549
586
|
function blocksOf(resp) {
|
|
550
587
|
const parts = [];
|
|
@@ -560,6 +597,7 @@ function readResult(resp) {
|
|
|
560
597
|
const text = outputOf(resp);
|
|
561
598
|
const isError = typeof resp === "object" && resp !== null && resp.is_error === true;
|
|
562
599
|
const info = { isError, bytes: Buffer.byteLength(text), text };
|
|
600
|
+
if (typeof resp === "object" && resp !== null && !Array.isArray(resp) && isShellShape(resp)) info.shape = resp;
|
|
563
601
|
if (typeof resp === "object" && resp !== null && !Array.isArray(resp) && !isShellShape(resp)) {
|
|
564
602
|
if (textSlot(resp) !== null) info.shape = resp;
|
|
565
603
|
else info.keep = true;
|
|
@@ -599,8 +637,11 @@ function decodeClaudeShape(raw, agent, ownPrefix, sources) {
|
|
|
599
637
|
return ev;
|
|
600
638
|
}
|
|
601
639
|
function replaceShape(ev, output) {
|
|
602
|
-
if (ev.tool?.canonicalName === "Bash") return { stdout: output, stderr: "", interrupted: false };
|
|
603
640
|
const shape = ev.result?.shape;
|
|
641
|
+
if (ev.tool?.canonicalName === "Bash") {
|
|
642
|
+
const { persistedOutputPath: _p, persistedOutputSize: _s, ...host } = shape ?? {};
|
|
643
|
+
return { interrupted: false, ...host, stdout: output, stderr: "" };
|
|
644
|
+
}
|
|
604
645
|
const slot = shape === void 0 ? null : textSlot(shape);
|
|
605
646
|
if (shape !== void 0 && slot !== null) return slot.put(shape, output);
|
|
606
647
|
if (ev.result?.blocks === true) return [{ type: "text", text: output }];
|
|
@@ -995,7 +1036,8 @@ function encode6(ev, d, _extra) {
|
|
|
995
1036
|
}
|
|
996
1037
|
|
|
997
1038
|
// src/adapters/kiro.ts
|
|
998
|
-
var TOOL_NAME_PREFIX7 = "
|
|
1039
|
+
var TOOL_NAME_PREFIX7 = "mcp_context_mode_";
|
|
1040
|
+
var LEGACY_TOOL_NAME_PREFIX = "mcp_context-mode_";
|
|
999
1041
|
var KIRO_EVENTS = {
|
|
1000
1042
|
SessionStart: "SessionStart",
|
|
1001
1043
|
agentSpawn: "SessionStart",
|
|
@@ -1007,6 +1049,7 @@ var KIRO_EVENTS = {
|
|
|
1007
1049
|
PostToolUse: "PostToolUse",
|
|
1008
1050
|
postToolUse: "PostToolUse"
|
|
1009
1051
|
};
|
|
1052
|
+
var PROMPT_FIELD = "prompt";
|
|
1010
1053
|
var PROMPT_ENV = "USER_PROMPT";
|
|
1011
1054
|
var MCP_PREFIX3 = "mcp_";
|
|
1012
1055
|
var SHELL_TOOL_NAMES4 = Object.freeze(["execute_bash", "execute_pwsh", "shell"]);
|
|
@@ -1015,6 +1058,7 @@ var MCP_SEP3 = "_";
|
|
|
1015
1058
|
var KIRO_SOURCES = { startup: "startup", resume: "resume", clear: "clear", compact: "compact" };
|
|
1016
1059
|
function canonicalName5(name) {
|
|
1017
1060
|
if (name.startsWith(TOOL_NAME_PREFIX7)) return name.slice(TOOL_NAME_PREFIX7.length);
|
|
1061
|
+
if (name.startsWith(LEGACY_TOOL_NAME_PREFIX)) return name.slice(LEGACY_TOOL_NAME_PREFIX.length);
|
|
1018
1062
|
if (Object.hasOwn(NATIVE_TO_CANONICAL5, name)) return NATIVE_TO_CANONICAL5[name];
|
|
1019
1063
|
if (!name.startsWith(MCP_PREFIX3)) return name;
|
|
1020
1064
|
const rest = name.slice(MCP_PREFIX3.length);
|
|
@@ -1035,7 +1079,8 @@ function decode7(raw) {
|
|
|
1035
1079
|
const ev = { event, agent: "kiro", sessionId: String(p.session_id ?? ""), cwd: String(p.cwd ?? "") };
|
|
1036
1080
|
if (event === "SessionStart" && typeof p.source === "string" && KIRO_SOURCES[p.source] !== void 0) ev.source = KIRO_SOURCES[p.source];
|
|
1037
1081
|
if (event === "UserPromptSubmit") {
|
|
1038
|
-
const
|
|
1082
|
+
const field = p[PROMPT_FIELD];
|
|
1083
|
+
const prompt = typeof field === "string" ? field : process.env[PROMPT_ENV];
|
|
1039
1084
|
if (prompt !== void 0) ev.prompt = prompt;
|
|
1040
1085
|
}
|
|
1041
1086
|
if (event === "PreToolUse" || event === "PostToolUse") {
|
|
@@ -1047,7 +1092,7 @@ function decode7(raw) {
|
|
|
1047
1092
|
return ev;
|
|
1048
1093
|
}
|
|
1049
1094
|
function encode7(ev, d, _extra) {
|
|
1050
|
-
if (ev.event === "UserPromptSubmit") return { stdout: "", exitCode: 0 };
|
|
1095
|
+
if (ev.event === "UserPromptSubmit") return { stdout: d.kind === "hint" ? d.text : "", exitCode: 0 };
|
|
1051
1096
|
switch (d.kind) {
|
|
1052
1097
|
case "allow":
|
|
1053
1098
|
return { stdout: "", exitCode: 0 };
|
|
@@ -1216,8 +1261,8 @@ var ADAPTERS = Object.freeze([
|
|
|
1216
1261
|
hookTimeoutMs: HOOK_TIMEOUT_MS,
|
|
1217
1262
|
denyChannel: "deny-reason",
|
|
1218
1263
|
hookChannel: { kind: "package", path: "hooks/claude-code.json" },
|
|
1219
|
-
skillChannel: { kind: "package", path: "
|
|
1220
|
-
// ADR-0020, D-
|
|
1264
|
+
skillChannel: { kind: "package", path: "skills" },
|
|
1265
|
+
// ADR-0020, D-R33-CC-SKILLS-1: Claude Code always loads <plugin>/skills, shared with gemini and qwen
|
|
1221
1266
|
decode,
|
|
1222
1267
|
encode
|
|
1223
1268
|
},
|