context-mode 2.1.0 → 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/cli.mjs CHANGED
@@ -645,7 +645,7 @@ function outputOf(resp) {
645
645
  function textSlot(r2) {
646
646
  const file = r2.file;
647
647
  if (r2.type === "text" && typeof file === "object" && file !== null && typeof file.content === "string") {
648
- return { text: file.content, put: (o2, output) => ({ ...o2, file: { ...o2.file, content: output } }) };
648
+ return { text: file.content, put: (o2, output) => ({ ...o2, file: readFile(o2.file, output) }) };
649
649
  }
650
650
  if (isGrepContent(r2)) return { text: r2.content, put: (o2, output) => ({ ...o2, content: output }) };
651
651
  if (Array.isArray(r2.filenames) && r2.filenames.every((f2) => typeof f2 === "string")) {
@@ -654,13 +654,35 @@ function textSlot(r2) {
654
654
  if (typeof r2.result === "string") return { text: r2.result, put: (o2, output) => ({ ...o2, result: output }) };
655
655
  return null;
656
656
  }
657
+ function readFile(file, output) {
658
+ const start = typeof file.startLine === "number" ? file.startLine : 1;
659
+ const lines = String(file.content).split("\n");
660
+ const read = typeof file.numLines === "number" ? file.numLines : lines.length;
661
+ const out2 = output.split("\n");
662
+ const run = firstRun(lines, out2);
663
+ if (run === null) return { ...file, content: output, startLine: start + read, numLines: out2.length };
664
+ const kept = out2.slice(0, run.length);
665
+ if (run.length < out2.length) kept.push(out2[out2.length - 1]);
666
+ return { ...file, content: kept.join("\n"), startLine: start + run.at, numLines: kept.length };
667
+ }
668
+ function firstRun(lines, out2) {
669
+ let best = null;
670
+ for (let i2 = 0; i2 < lines.length; i2++) {
671
+ if (lines[i2] !== out2[0]) continue;
672
+ let n3 = 1;
673
+ while (n3 < out2.length && i2 + n3 < lines.length && lines[i2 + n3] === out2[n3]) n3++;
674
+ if (best === null || n3 > best.length) best = { at: i2, length: n3 };
675
+ if (n3 === out2.length) break;
676
+ }
677
+ return best;
678
+ }
657
679
  function isShellShape(resp) {
658
680
  const r2 = resp;
659
681
  return typeof r2.stdout === "string" || typeof r2.stderr === "string";
660
682
  }
661
683
  function isGrepContent(resp) {
662
684
  const r2 = resp;
663
- return r2.mode === "content" && typeof r2.content === "string";
685
+ return (r2.mode === "content" || r2.mode === "count") && typeof r2.content === "string";
664
686
  }
665
687
  function blocksOf(resp) {
666
688
  const parts = [];
@@ -676,6 +698,7 @@ function readResult(resp) {
676
698
  const text2 = outputOf(resp);
677
699
  const isError = typeof resp === "object" && resp !== null && resp.is_error === true;
678
700
  const info = { isError, bytes: Buffer.byteLength(text2), text: text2 };
701
+ if (typeof resp === "object" && resp !== null && !Array.isArray(resp) && isShellShape(resp)) info.shape = resp;
679
702
  if (typeof resp === "object" && resp !== null && !Array.isArray(resp) && !isShellShape(resp)) {
680
703
  if (textSlot(resp) !== null) info.shape = resp;
681
704
  else info.keep = true;
@@ -715,8 +738,11 @@ function decodeClaudeShape(raw, agent, ownPrefix, sources2) {
715
738
  return ev;
716
739
  }
717
740
  function replaceShape(ev, output) {
718
- if (ev.tool?.canonicalName === "Bash") return { stdout: output, stderr: "", interrupted: false };
719
741
  const shape = ev.result?.shape;
742
+ if (ev.tool?.canonicalName === "Bash") {
743
+ const { persistedOutputPath: _p, persistedOutputSize: _s, ...host } = shape ?? {};
744
+ return { interrupted: false, ...host, stdout: output, stderr: "" };
745
+ }
720
746
  const slot = shape === void 0 ? null : textSlot(shape);
721
747
  if (shape !== void 0 && slot !== null) return slot.put(shape, output);
722
748
  if (ev.result?.blocks === true) return [{ type: "text", text: output }];
@@ -1336,8 +1362,8 @@ var ADAPTERS = Object.freeze([
1336
1362
  hookTimeoutMs: HOOK_TIMEOUT_MS,
1337
1363
  denyChannel: "deny-reason",
1338
1364
  hookChannel: { kind: "package", path: "hooks/claude-code.json" },
1339
- skillChannel: { kind: "package", path: "claude-code/skills" },
1340
- // ADR-0020, D-HQ-SKILLS-2
1365
+ skillChannel: { kind: "package", path: "skills" },
1366
+ // ADR-0020, D-R33-CC-SKILLS-1: Claude Code always loads <plugin>/skills, shared with gemini and qwen
1341
1367
  decode,
1342
1368
  encode
1343
1369
  },
@@ -9358,11 +9384,20 @@ function hookSeenCheck(row, home) {
9358
9384
  }
9359
9385
  return { name: "hook-seen", ok: true, warn: true, detail: NOT_SEEN_LINE };
9360
9386
  }
9387
+ var SKILL_TOOL_STEM = "ctx_";
9361
9388
  function skillsCheck(row, pkgDir) {
9362
9389
  const s = row.skillInstall;
9363
9390
  if (s.kind === "package") {
9364
- const miss = COMMAND_SKILLS.map((n3) => path12.join(pkgDir, s.via, n3, SKILL_FILE)).filter((f2) => !existsSync15(f2));
9365
- return { name: "skills", ok: miss.length === 0, detail: miss.length ? `missing ${miss.join(", ")}` : void 0 };
9391
+ const files = COMMAND_SKILLS.map((n3) => path12.join(pkgDir, s.via, n3, SKILL_FILE));
9392
+ const miss = files.filter((f2) => !existsSync15(f2));
9393
+ if (miss.length) return { name: "skills", ok: false, detail: `missing ${miss.join(", ")}` };
9394
+ const own2 = getAdapter(row.id).toolNamePrefix + SKILL_TOOL_STEM;
9395
+ const foreign = [...new Set(ADAPTERS.map((r2) => r2.toolNamePrefix + SKILL_TOOL_STEM))].filter((n3) => n3 !== SKILL_TOOL_STEM && n3 !== own2);
9396
+ const bad2 = files.filter((f2) => {
9397
+ const t2 = readFileSync10(f2, "utf8");
9398
+ return !t2.includes(own2) && foreign.some((n3) => t2.includes(n3));
9399
+ });
9400
+ return { name: "skills", ok: bad2.length === 0, detail: bad2.length ? `${bad2.join(", ")} without the ${own2}* tool name` : void 0 };
9366
9401
  }
9367
9402
  const bad = s.files.filter((f2) => readRaw(f2.file) !== (existsSync15(f2.src) ? renderSkill(readFileSync10(f2.src, "utf8"), s.prefixes) : void 0));
9368
9403
  return { name: "skills", ok: bad.length === 0, detail: bad.length ? `${bad.map((f2) => f2.file).join(", ")} missing or without the ${s.prefixes.join(" / ") || "plain"} tool prefix` : void 0 };
@@ -11,5 +11,5 @@
11
11
  }
12
12
  },
13
13
  "name": "context-mode",
14
- "version": "2.1.0"
14
+ "version": "2.1.1"
15
15
  }
@@ -11,5 +11,5 @@
11
11
  }
12
12
  },
13
13
  "name": "context-mode",
14
- "version": "2.1.0"
14
+ "version": "2.1.1"
15
15
  }