ci: fixed-on-main label on push to main, release closes the shipped issues (D-FIXED-ON-MAIN-1)

A fix:, feat: or perf: commit on main that names #N labels open issue N fixed-on-main; a revert takes the label off when no un-reverted fix stays. The main release path closes each labeled issue whose fix is in the new tag, with one comment naming the agent's own update command (UPGRADE_HOST_COMMAND). Tests: red 18 fail, green 25 pass (tests/0014-repo-hygiene.test.mjs).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mksgluandClaude Opus 5.5 committed 2026-11-12 22:18:56 +03:00
1 parent bca36462e0
commit 61fb210fa5
12 files changed
+1752 -2

No files matched your search

+357
View File
@@ -0,0 +1,357 @@
// .github/scripts/fixed-on-main.mjs
// D-FIXED-ON-MAIN-1 (owner 2026-11-12: "tamam supermis bu fixed-on-main etiket fikri bunu bot da uygulasin otomatik";
// earlier: "fixle ve comment at ancak release cikmayalim ... biraz issuler biriksin toplu release cikariz").
// Two modes, one file, string scanning only (no regex, same rule as the intake bot):
// label (.github/workflows/fixed-on-main.yml, push to main): a fix:, feat: or perf: commit (any scope, "fix+docs"
// too) that names #N adds the label "fixed-on-main" to open issue N. A revert commit naming #N removes it when
// no un-reverted fix commit for #N stays on main. test:, docs:, chore:, data: commits never label. It never
// comments and never closes.
// close (.github/workflows/release.yml job main-close-issues, after the GitHub release of the main path): each open
// issue with the label whose live fix commits are all in tag v<version> gets one comment with its agent's own
// update command (UPGRADE_HOST_COMMAND), loses the label and closes as completed. An API error is logged and
// the run goes on; the step never fails the release.
// The functions above the CLI block are pure (tests/0014-repo-hygiene.test.mjs runs them); the CLI block calls git and gh.
import { execFileSync, spawnSync } from "node:child_process";
import fs from "node:fs";
import { pathToFileURL } from "node:url";
import { UPGRADE_HOST_COMMAND } from "../../src/core/contracts/constants.ts";
export const LABEL = { name: "fixed-on-main", color: "0E8A16", description: "Fix is on main, ships in the next release" };
export const FIX_TYPES = ["fix", "feat", "perf"];
export const REVERT_TYPE = "revert";
export const MAINTAINERS = ["OWNER", "MEMBER", "COLLABORATOR"];
export const MARKER = "<!-- context-mode-released -->";
export const INSTALL_GUIDE = "https://github.com/mksglu/context-mode/blob/main/docs/install/README.md";
export const REPO_DEFAULT = "mksglu/context-mode";
const GIT_REVERT = 'Revert "'; // the subject `git revert` writes
const AGENT_HEAD = "### Agent"; // feature.yml dropdown field
const DOCTOR_ENV = "Environment: "; // ctx_doctor env line: "Environment: context-mode 2.1.9 (sha), agent claude-code"
const DOCTOR_AGENT = ", agent ";
// Names a reporter writes for an agent, lower case, mapped to the agent id (the keys of UPGRADE_HOST_COMMAND).
export const AGENT_NAMES = [
["claude code", "claude-code"], ["claude-code", "claude-code"], ["claude", "claude-code"], ["codex", "codex"],
["gemini cli", "gemini"], ["gemini", "gemini"], ["qwen code", "qwen"], ["qwen", "qwen"], ["opencode", "opencode"],
["pi coding agent", "pi"], ["pi", "pi"], ["copilot cli", "copilot-cli"], ["copilot-cli", "copilot-cli"], ["copilot", "copilot-cli"],
["vs code", "vscode"], ["vscode", "vscode"], ["kiro", "kiro"], ["z code", "zcode"], ["zcode", "zcode"],
];
const isDigit = (c) => c !== undefined && c >= "0" && c <= "9";
const isHex = (c) => isDigit(c) || (c >= "a" && c <= "f");
const isAlnum = (c) => c !== undefined && (isDigit(c) || (c >= "a" && c <= "z") || (c >= "A" && c <= "Z"));
/** "fix(core)!: x" -> ["fix"]; "fix+docs: x" -> ["fix", "docs"]; no conventional head -> null. */
export function subjectTypes(subject) {
const colon = subject.indexOf(": ");
if (colon <= 0) return null;
let head = subject.slice(0, colon).trim().toLowerCase();
if (head.endsWith("!")) head = head.slice(0, -1);
const paren = head.indexOf("(");
if (paren >= 0) {
if (!head.endsWith(")")) return null;
head = head.slice(0, paren);
}
if (head === "" || head.includes(" ")) return null;
return head.split("+");
}
/** "fix" (fix/feat/perf), "revert", "unrevert" (a revert of a revert) or null (test, docs, chore, data, ...). */
export function commitKind(subject) {
const s = subject.trim();
if (s.startsWith(GIT_REVERT)) {
const inner = s.slice(GIT_REVERT.length);
if (inner.startsWith(GIT_REVERT)) return "unrevert";
const t = subjectTypes(inner);
return t !== null && t.includes(REVERT_TYPE) ? "unrevert" : "revert";
}
const types = subjectTypes(s);
if (types === null) return null;
if (types.includes(REVERT_TYPE)) return "revert";
return types.some((t) => FIX_TYPES.includes(t)) ? "fix" : null;
}
/** Issue numbers a text names as "#N", in order, each once. "a#1" and "&#123;" are no reference. */
export function issueRefs(text) {
const out = [];
for (let i = text.indexOf("#"); i !== -1; i = text.indexOf("#", i + 1)) {
if (isAlnum(text[i - 1]) || text[i - 1] === "&") continue;
let j = i + 1;
while (isDigit(text[j])) j++;
if (j === i + 1 || isAlnum(text[j])) continue;
const n = Number(text.slice(i + 1, j));
if (n > 0 && !out.includes(n)) out.push(n);
}
return out;
}
/** Words of a commit body that look like a commit sha: 7 to 40 hex characters, bounded by non-alphanumerics. */
export function shaTokens(body) {
const out = [];
let word = "";
for (const ch of body + " ") {
if (isAlnum(ch)) { word += ch; continue; }
const w = word.toLowerCase();
if (w.length >= 7 && w.length <= 40 && [...w].every(isHex)) out.push(w);
word = "";
}
return out;
}
/**
* The fix commits that stay on main for each issue, after the reverts. Input: commits oldest first, { sha, subject, body }.
* A revert removes the fix commits its body names by sha ("This reverts commit <sha>", "Reverts ... 4d45b836 921ba58c");
* a revert whose body names no known commit removes every fix commit of the issues its subject names. A revert of a
* revert puts back what that revert removed. Output: Map issue -> Set of full shas.
*/
export function liveFixes(commits) {
const live = new Map();
const seen = [];
const removedBy = new Map(); // revert sha -> [[issue, sha]]
const lastRemoved = new Map(); // issue -> [[issue, sha]]
const add = (n, sha) => { if (!live.has(n)) live.set(n, new Set()); live.get(n).add(sha); };
for (const c of commits) {
const kind = commitKind(c.subject);
const refs = kind === null ? [] : issueRefs(c.subject);
const named = kind === null || kind === "fix" ? [] : shaTokens(c.body ?? "");
const knows = (t) => seen.some((s) => s.startsWith(t));
seen.push(c.sha);
if (kind === "fix") { for (const n of refs) add(n, c.sha); continue; }
if (kind === "revert") {
const exact = named.filter(knows);
const out = [];
for (const [n, set] of live) {
for (const sha of set) {
if (exact.length ? exact.some((t) => sha.startsWith(t)) : refs.includes(n)) out.push([n, sha]);
}
}
for (const [n, sha] of out) live.get(n).delete(sha);
removedBy.set(c.sha, out);
for (const n of refs) lastRemoved.set(n, out);
continue;
}
if (kind === "unrevert") {
let back = null;
for (const [rsha, out] of removedBy) if (named.some((t) => rsha.startsWith(t))) back = out;
if (back === null) back = refs.flatMap((n) => lastRemoved.get(n) ?? []);
for (const [n, sha] of back) add(n, sha);
}
}
for (const [n, set] of live) if (set.size === 0) live.delete(n);
return live;
}
/**
* Label actions for one push. pushed: the pushed commits { sha, subject }; live: liveFixes() of main after the push;
* open: Map issue -> label names (open issues only, no pull requests). Output: label-create, label-add, label-remove.
*/
export function labelPlan({ pushed, live, open }) {
const add = [];
const remove = [];
for (const c of pushed) {
if (commitKind(c.subject) === null) continue;
for (const n of issueRefs(c.subject)) {
if (!open.has(n)) continue;
const has = open.get(n).includes(LABEL.name);
const alive = live.has(n);
if (alive && !has && !add.includes(n)) add.push(n);
if (!alive && has && !remove.includes(n)) remove.push(n);
}
}
return [
...(add.length ? [{ op: "label-create", ...LABEL }] : []),
...add.map((issue) => ({ op: "label-add", issue, name: LABEL.name })),
...remove.map((issue) => ({ op: "label-remove", issue, name: LABEL.name })),
];
}
/** The agent id a name stands for, or null. */
export function agentId(name) {
const t = name.trim().toLowerCase();
const hit = AGENT_NAMES.find(([n]) => n === t);
return hit ? hit[1] : null;
}
/** The words of a title prefix, alone and in pairs ("claude code", "gemini cli"). */
function prefixWords(prefix) {
const words = [];
let w = "";
for (const ch of prefix + " ") {
if (ch === " " || ch === "/" || ch === "," || ch === "\t") { if (w) words.push(w); w = ""; } else w += ch;
}
const out = [];
for (let i = 0; i < words.length; i++) {
if (i + 1 < words.length) out.push(words[i] + " " + words[i + 1]);
out.push(words[i]);
}
return out;
}
/**
* The agent of an issue: the feature form field "### Agent", then the title prefix ("[claude-code] ...", "Pi: ...",
* "Windows/OpenCode: ..."), then the ctx_doctor env line ("agent opencode"). null when none names a known agent.
*/
export function agentOf({ title = "", body = "" }) {
const lines = body.split("\n").map((l) => (l.endsWith("\r") ? l.slice(0, -1) : l));
const head = lines.findIndex((l) => l.trim() === AGENT_HEAD);
if (head !== -1) {
const value = lines.slice(head + 1).find((l) => l.trim() !== "");
const id = value === undefined ? null : agentId(value) ?? agentId(prefixWords(value.trim())[0] ?? "");
if (id) return id;
}
// Title: the "[...]" prefix, then the words before the first colon, then the first word (pair) of the title.
let t = title.trim().toLowerCase();
const cands = [];
const close = t.indexOf("]");
if (t.startsWith("[") && close !== -1) {
cands.push(...prefixWords(t.slice(1, close)));
let k = close + 1;
while (t[k] === ":" || t[k] === " ") k++;
t = t.slice(k);
}
const colon = t.indexOf(":");
if (colon > 0) cands.push(...prefixWords(t.slice(0, colon)));
cands.push(...prefixWords(t).slice(0, 2));
for (const w of cands) { const id = agentId(w); if (id) return id; }
for (const l of lines) {
const s = l.trim();
const at = s.indexOf(DOCTOR_AGENT);
if (!s.startsWith(DOCTOR_ENV) || at === -1) continue;
const rest = s.slice(at + DOCTOR_AGENT.length);
const space = rest.indexOf(" ");
const id = agentId(space === -1 ? rest : rest.slice(0, space));
if (id) return id;
}
return null;
}
/** "2.1.11" from "v2.1.11" or "2.1.11". */
export const bareVersion = (v) => (v.startsWith("v") ? v.slice(1) : v).trim();
/** True when text names version v as a whole: "2.1.1" is not named by "2.1.11" or "12.1.1". */
export function namesVersion(text, version) {
const v = bareVersion(version);
for (let i = text.indexOf(v); i !== -1; i = text.indexOf(v, i + 1)) {
const before = text[i - 1];
const after = text[i + v.length];
if (isDigit(before) || before === ".") continue;
if (isDigit(after) || (after === "." && isDigit(text[i + v.length + 1]))) continue;
return true;
}
return false;
}
/** The one release comment: version, the agent's own update command, how to reopen. */
export function releaseComment(version, agent) {
const v = "v" + bareVersion(version);
const cmd = agent ? UPGRADE_HOST_COMMAND[agent] : undefined;
const update = cmd ? `Update with \`${cmd}\`.` : `Update with your agent's own update command: ${INSTALL_GUIDE}.`;
return `${MARKER}\nReleased in ${v}. ${update} If it still happens on ${v}, please reopen this issue.`;
}
/**
* Close actions for one release. issues: open issues { number, title, body, labels, comments: [{ body, bot, assoc }] };
* live: liveFixes() of main; inTag(sha): the sha is in tag v<version>. An issue closes when it holds the label and every
* fix commit that stays on main for it is in the tag. Output: { actions, skipped }; an action is comment-create,
* label-remove or close.
*/
export function closePlan({ version, issues, live, inTag }) {
const actions = [];
const skipped = [];
const v = "v" + bareVersion(version);
for (const i of issues) {
if (!i.labels.includes(LABEL.name)) continue;
const shas = [...(live.get(i.number) ?? [])];
if (shas.length === 0) { skipped.push({ issue: i.number, why: "no fix commit for it stays on main" }); continue; }
if (!shas.every(inTag)) { skipped.push({ issue: i.number, why: `a fix commit is after ${v}` }); continue; }
const comments = i.comments ?? [];
if (comments.some((c) => !c.bot && MAINTAINERS.includes(c.assoc) && namesVersion(c.body, version))) {
skipped.push({ issue: i.number, why: `a maintainer comment names ${v}` });
continue;
}
if (!comments.some((c) => c.body.includes(MARKER) && namesVersion(c.body, version))) {
actions.push({ op: "comment-create", issue: i.number, body: releaseComment(version, agentOf(i)) });
}
actions.push({ op: "label-remove", issue: i.number, name: LABEL.name }, { op: "close", issue: i.number });
}
return { actions, skipped };
}
/** `git log --format=%H%x1f%s%x1f%b%x1e` output -> [{ sha, subject, body }]. */
export function parseLog(text) {
const out = [];
for (const rec of text.split("\x1e")) {
const r = rec.startsWith("\n") ? rec.slice(1) : rec;
if (r.trim() === "") continue;
const [sha, subject = "", body = ""] = r.split("\x1f");
out.push({ sha: sha.trim(), subject, body });
}
return out;
}
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
const args = process.argv.slice(2);
const mode = args[0];
const flag = (name) => { const i = args.indexOf(name); return i === -1 ? undefined : args[i + 1]; };
const dry = args.includes("--dry-run");
const repo = flag("--repo") ?? process.env.GITHUB_REPOSITORY ?? REPO_DEFAULT;
const LOG = ["log", "--reverse", "--format=%H%x1f%s%x1f%b%x1e"];
const git = (a) => execFileSync("git", a, { encoding: "utf8", maxBuffer: 1 << 28 });
const gh = (a) => execFileSync("gh", a, { encoding: "utf8", maxBuffer: 1 << 28 });
let failed = 0;
const run = (a, argv) => {
if (dry) { console.log("dry-run: " + a.op + (a.issue ? " #" + a.issue : "")); return; }
try { gh(argv); console.log(a.op + (a.issue ? " #" + a.issue : "")); }
catch (e) { failed++; console.log(`::warning::${a.op} #${a.issue ?? ""} failed: ${String(e.message).split("\n")[0]}`); }
};
const live = () => liveFixes(parseLog(git([...LOG, "HEAD"])));
try {
if (mode === "label") {
// The pushed range is before..HEAD of the push event (its commits list stops at 20); a new branch or a run by hand
// uses --since, else the newest v* tag.
const ev = process.env.GITHUB_EVENT_PATH ? JSON.parse(fs.readFileSync(process.env.GITHUB_EVENT_PATH, "utf8")) : null;
const before = ev && typeof ev.before === "string" && !ev.before.split("").every((c) => c === "0") ? ev.before : null;
const since = flag("--since") ?? before ?? git(["describe", "--tags", "--abbrev=0", "--match", "v*", "HEAD"]).trim();
const pushed = parseLog(git([...LOG, since + "..HEAD"]));
const open = new Map(JSON.parse(gh(["issue", "list", "-R", repo, "--state", "open", "--limit", "1000", "--json", "number,labels"]))
.map((i) => [i.number, i.labels.map((l) => l.name)]));
const fixes = live();
const plan = labelPlan({ pushed, live: fixes, open });
const holds = [...open.keys()].filter((n) => fixes.has(n) && pushed.some((c) => commitKind(c.subject) === "fix" && issueRefs(c.subject).includes(n)));
console.log(JSON.stringify({ since, pushed: pushed.length, holds: holds.sort((a, b) => a - b).map((n) => "#" + n + (open.get(n).includes(LABEL.name) ? " (has it)" : "")), ops: plan.map((a) => a.op + (a.issue ? " #" + a.issue : "")) }));
for (const a of plan) {
if (a.op === "label-create") run(a, ["label", "create", a.name, "--color", a.color, "--description", a.description, "--force", "-R", repo]);
if (a.op === "label-add") run(a, ["issue", "edit", String(a.issue), "--add-label", a.name, "-R", repo]);
if (a.op === "label-remove") run(a, ["issue", "edit", String(a.issue), "--remove-label", a.name, "-R", repo]);
}
process.exitCode = failed ? 1 : 0;
} else if (mode === "close") {
const version = bareVersion(flag("--version") ?? process.env.VERSION ?? "");
if (!version) throw new Error("close needs --version");
const tag = flag("--tag") ?? "v" + version;
const issues = JSON.parse(gh(["issue", "list", "-R", repo, "--state", "open", "--label", LABEL.name, "--limit", "1000", "--json", "number,title,body,labels"]))
.map((i) => ({ ...i, labels: i.labels.map((l) => l.name) }));
const readable = [];
for (const i of issues) {
try {
i.comments = gh(["api", "--paginate", `repos/${repo}/issues/${i.number}/comments`, "--jq",
".[] | {body, bot: (.user.type == \"Bot\"), assoc: .author_association}"])
.split("\n").filter((l) => l.trim()).map((l) => JSON.parse(l));
readable.push(i);
} catch (e) { console.log(`::warning::comments of #${i.number} unread, issue skipped: ${String(e.message).split("\n")[0]}`); }
}
const inTag = (sha) => spawnSync("git", ["merge-base", "--is-ancestor", sha, tag]).status === 0;
const { actions, skipped } = closePlan({ version, issues: readable, live: live(), inTag });
console.log(JSON.stringify({ tag, labeled: issues.length, ops: actions.map((a) => a.op + " #" + a.issue), skipped }));
for (const a of actions) {
if (a.op === "comment-create") run(a, ["issue", "comment", String(a.issue), "--body", a.body, "-R", repo]);
if (a.op === "label-remove") run(a, ["issue", "edit", String(a.issue), "--remove-label", a.name, "-R", repo]);
if (a.op === "close") run(a, ["issue", "close", String(a.issue), "--reason", "completed", "-R", repo]);
}
} else {
throw new Error("usage: fixed-on-main.mjs label|close [--dry-run] [--repo o/r] [--since ref] [--version x.y.z] [--tag vX]");
}
} catch (e) {
console.log(`::warning::fixed-on-main ${mode}: ${String(e.message).split("\n")[0]}`);
// The close step must not fail the release; a label run shows its failure.
process.exitCode = mode === "close" ? 0 : 1;
}
}
+31
View File
@@ -0,0 +1,31 @@
# D-FIXED-ON-MAIN-1: a fix:, feat: or perf: commit on main that names #N adds the label "fixed-on-main" to open issue N;
# a revert removes it when no un-reverted fix for N stays on main. It never comments and never closes: the release
# (release.yml job main-close-issues) closes the labeled issues whose fix is in the new tag.
name: fixed-on-main
on:
push:
branches: [main]
permissions:
issues: write
contents: read
concurrency:
group: fixed-on-main
cancel-in-progress: false
jobs:
label:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: "24.15.0"
- name: label the open issues a pushed fix names
env:
GH_TOKEN: ${{ github.token }}
run: node .github/scripts/fixed-on-main.mjs label
+24
View File
@@ -521,6 +521,30 @@ jobs:
VERSION: ${{ needs.main-plan.outputs.version }}
NOTES: ${{ needs.main-plan.outputs.notes }}
run: node scripts/release/publish.mjs --github-release --version "$VERSION" --notes "$NOTES"
# D-FIXED-ON-MAIN-1: each open issue labeled fixed-on-main whose fix commits are in the new tag gets one comment with
# its agent's own update command, loses the label and closes as completed. It never fails the release.
main-close-issues:
needs: [route, main-plan, main-github-release]
if: ${{ needs.route.outputs.layout == 'main' && inputs.mode != 'rollback' && !inputs.dry_run }}
runs-on: ubuntu-latest
timeout-minutes: 10
continue-on-error: true
permissions:
issues: write
contents: read
steps:
- uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: "24.15.0"
- name: close the fixed-on-main issues this release ships
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ needs.main-plan.outputs.version }}
run: node .github/scripts/fixed-on-main.mjs close --version "$VERSION"
main-rollback:
needs: [ci, route]
if: ${{ needs.route.outputs.layout == 'main' && inputs.mode == 'rollback' }}
+3
View File
@@ -9,3 +9,6 @@ If you are a person: ask your agent to "file a context-mode issue", or run `/ctx
Security problems go to https://github.com/mksglu/context-mode/security/advisories/new, never to a public issue.
Main is the only source: every fix lands on main, and the next release run ships it.
When a `fix:`, `feat:` or `perf:` commit that names `#N` lands on main, a GitHub Action adds the label `fixed-on-main` to issue N (a revert takes it off again).
When a release ships that fix, the release run posts one comment with your agent's own update command, removes the label and closes the issue; reopen it if the problem still happens on that version.
+1
View File
@@ -275,3 +275,4 @@ Split: this file holds the deviation rows without a date (format: id, files, dec
| D-1370-OLDNODE-ALLOW-1 | src/core/hooks/dispatch.ts (handleHook node stage, report), src/core/hooks/fallback.ts (allowOutput), tests/prd10-hooks-runtime.test.mjs ([D-1370] per host), e2e/cases/GP3-hooks.e2e.mjs (GP3/old-node-hook-allows) | #1370 (Claude Code plugin, Node 18.20.5 on PATH): on NODE_TOO_OLD the hook denied Bash, Read, Grep and WebFetch with a redirect to ctx_execute/ctx_index, but the MCP server runs on the same node and is degraded (PRD.md:284, §13: it lists ctx_doctor only; ctx_execute answers -32602 "Tool ctx_execute not found"), so the session could not run any tool. Archaeology: 6de98259 (D-HNE-GUARD-1, DEVIATIONS.md:104) chose one table-only fallback for every failure stage so flooding tools stay guarded; fallback.ts:3 assumes "ctx_doctor and the sandbox stay reachable". That holds for the decode/project/store/encode stages (healthy server) and not for the node stage. Now, on the node stage, the 8 server hosts get their allow reply; the stderr line and the hook-errors.log line stay (D5). Pi and OpenCode (installMode in-process) keep the deny: their ctx_* tools register in the host with no version gate (Bun reports v24.3.0 / v26.3.0), so the redirect target exists. Other stages unchanged. Out of scope: node:sqlite missing on Node >= 24.15 still ends in the store-stage deny while the server is degraded. Red run: 8 hosts deny. Profile (hook, median of 50): Node 24.15.0 30.4/32.3 ms before, 32.7 ms after (same path); Node 18.18.2 37.4/38.8 ms before (deny), 40.0 ms after (allow). |
| D-1350-D5-SCALE-1 | src/core/ops/doctor-hook.ts (checkHookRoundTrip: in-process shape-only, bound = max(HOOK_P95_MS, D5_BARE_SHARE x fastest bare)), src/core/contracts/constants.ts (D5_BARE_SHARE, D5_SLOW_DETAIL bound arg, D5_SLOW_START_DETAIL, D5_IN_PROCESS_DETAIL), src/core/ops/doctor-issue.ts (environmentLine: RuntimeInfo, host Bun and the ctx_execute PATH node; runtimeInfo async), src/core/tools/doctor.ts (doctorReply starts runtimeInfo beside the checks), docs/architecture/adr/0010-doctor-and-upgrade.md (D5 row), tests/0010-doctor-upgrade.test.mjs (D5 describe: 5 [#1350] tests, D-D5-ALL-AGENTS-1 detail per installMode; issue-path describe: env-line test, runtimeInfo test) | #1350 (emngny, OpenCode 2.2.7 = Bun 1.4.4 compiled host, Windows 11 corporate-managed Ryzen 7 PRO 8840U, PATH node v24.22.2, context-mode 2.1.7): D5 FAIL "88/98 ms over bare node, over 40 ms". Reporter profile: bare `node -e ""` n=13 avg 643 ms (594-749), hook.mjs avg 722 ms (671-824), pair deltas 84,127,78,52,68,16,66,62,87,67: the hook adds ~12% to a node start there, 27% on the owner's Mac (bare 30.8, hook 39.2 ms). ADR-0010 line 45 (D5 row) and TECH-SPEC GS6 set 40 ms where node starts in ~30-45 ms ("bare Node alone is 45.6 ms p95 on the owner's Mac"). Archaeology: HOOK_P95_MS = 40 comes from 5215efc9 (M0-T2 contracts, GS6 / DECISIONS-r9 V14, a Claude Code wall budget); 7b68b5b8 (D-D5-BARE-1, Windows Claude Desktop, bare 42.7 ms) made D5 hook wall minus bare wall but kept 40 ms absolute; 37a48049 (D-D5-MORE-PAIRS-1) added 3 to 9 pairs for CI noise. Both were designed on machines where node starts in 30-50 ms; none saw a 600 ms start, where the bare spread (155 ms) alone is 4x the bound. Our earlier not_reproduced reply missed this. Repro (/private/tmp/r56-1350-work/repro.mjs, the reporter's walls through checkHookRoundTrip): before opencode, pi, claude-code all FAIL "66 ms over bare node, over 40 ms" at 11.1% added cost; after: claude-code PASS "hook adds 98 ms to a 598 ms node start, inside 299 ms", opencode and pi PASS shape-only. Also: OpenCode and Pi run every hook in-process (src/entries/opencode.ts, pi.ts call handleHook; no spawn), so D5 timing a spawn measured a path no tool call takes; D5 now runs one hook for the shape there. Env line: under Bun, process.version is Bun's node-compat version; the line now says "host runtime Bun X (node-compat vY)" and "ctx_execute node vZ (PATH)" (or "ctx_execute node: none on PATH"). Review round 1: an earlier label "hook node vZ (PATH)" gave the PATH node the wrong role; on a Bun host every hook runs in the host process (handleHook), and the PATH node runs only ctx_execute javascript (execute.ts findRuntime) and the D5 shape spawn. The PATH node version comes from an async runProcess that doctorReply starts beside the checks (it was a sync spawnSync: one more node start per reply). Profile ctx_doctor (doctorReply, opencode, bun 1.3.4, macOS, 50 runs, PATH node made to start in ~600 ms like the reporter's): median 1308.1 -> 670.2 ms (p95 1338.1 -> 681.8); normal PATH node: 74.1 -> 55.4 ms (p95 80.0 -> 59.3). Scripts: /private/tmp/r56-1350-work/profile-doctor.mjs. Strength kept: 40 ms stays the floor; a slow hook on a fast machine FAILs (test: 100 ms over a 30 ms start), a hook over half a start FAILs on a slow one (400 over 600); the shape check is unchanged for every host. Profile (50 runs, macOS, release-out, one D5 check): claude-code median 370.8 -> 372.1 ms (p95 388.4 -> 390.2), opencode 200.5 -> 36.4 ms (p95 208.7 -> 39.0). Red: 5 fail; green: 0010 + 0018-contracts 360 pass. |
| D-1373-STAT-1 | src/core/sandbox/runtimes.ts (probe, lookupRuntime, findRuntime), src/core/tools/execute.ts (findRuntime inside the handler's guard), src/core/ops/doctor-env.ts (checkRuntimes), src/core/tools/doctor.ts (D11 = checkRuntimes over checkShell), src/core/contracts/constants.ts (D11_RUNTIME_DETAIL, D11_RUNTIME_FIX), docs/architecture/modules/03-sandbox.md (Error cases), tests/prd9-sandbox.test.mjs ([#1373] describe, 9 tests) | #1373 (inferno7291, Windows 11, Claude Code 2.1.322, context-mode 2.1.9): ctx_execute python answered "Internal error. Fix: run ctx_doctor." while shell, javascript and powershell worked; every doctor row was PASS. Cause: the first python.exe on PATH is the Microsoft Store app alias; node's statSync throws EACCES on it; `throwIfNoEntry: false` silences only ENOENT; the throw left findRuntime and execute.ts step 4 (outside its try) so server errorReply gave the generic line. Reproduced on the 2.1.9 npm bundle over MCP and on main (a PATH dir with no search permission first, a real python3 later). ADR/spec line: modules/03-sandbox.md "Error cases: None inside findRuntime - absence is a valid null return, not a thrown error" and step 4 "check existence with a sync stat call"; modules/04-tools-exec.md step 4 "null -> NO_RUNTIME". Both state findRuntime never throws, the code did. Archaeology: 571ecc13 (impl M2-T4) wrote isRunnable with throwIfNoEntry:false, handling ENOENT only, because the spec reads "absent" as the only miss. v1 (fb4bc5ad, #457, v1.0.169 runtime.ts runnableExists) filtered WindowsApps hits from `where` and ran `<cmd> --version`; v2 dropped `where` and spawns (PRD 9, P4, P5), and kept the stub case only for bash (D-VT-WINBASH-1), so python lost its guard. Change: a stat error of any code is "unreadable": skipped, the walk goes on; every candidate unreadable gives null and ctx_execute returns the named NO_RUNTIME line; a throw from the lookup also maps to NO_RUNTIME. D11 resolves each sandbox language and is a WARN naming the language and the unreadable paths when none is found, so ctx_doctor shows it. A language that is merely not installed is no finding. Profile (50 runs, macOS, median): findRuntime over 4 languages 0.146 -> 0.150 ms, D11 0.012 -> 0.151 ms. Red: 9 fail; green: prd9-sandbox 121 pass. |
| D-FIXED-ON-MAIN-1 | .github/scripts/fixed-on-main.mjs (`commitKind`, `issueRefs`, `liveFixes`, `labelPlan`, `agentOf`, `releaseComment`, `closePlan`), .github/workflows/fixed-on-main.yml (push to main, label mode), .github/workflows/release.yml (job `main-close-issues` after `main-github-release`), CONTRIBUTING.md (two lines), tests/0014-repo-hygiene.test.mjs (D-FIXED-ON-MAIN-1 section), tests/fixtures/fixed-on-main/{main.log,tag-v2.1.10.txt,subjects.txt}, tests/fixtures/issue-intake/{1350,1371,1373}.md | Owner 2026-11-12: "tamam supermis bu fixed-on-main etiket fikri bunu bot da uygulasin otomatik"; earlier: "fixle ve comment at ancak release cikmayalim ... biraz issuler biriksin toplu release cikariz". A fix:, feat: or perf: commit on main that names #N labels open issue N `fixed-on-main`; a revert takes the label off when no un-reverted fix for N stays on main; test:, docs:, chore:, data: never label; the push run never comments or closes. The main release path closes each labeled issue whose live fix commits are all in the new tag (git merge-base --is-ancestor), with one comment that names the version and the agent's own update command from UPGRADE_HOST_COMMAND (install guide link for an unknown agent); it skips an issue a maintainer comment already names the version on, and never fails the release (continue-on-error, API errors logged). Permissions: issues: write, contents: read. String scanning only, no regex. |
+175 -2
View File
@@ -676,7 +676,7 @@ describe("ADR-0013 repo: main-only release workflow", () => {
const l = body(name).find((x) => x.startsWith("needs:"));
return l === undefined ? [] : l.slice(6).split("[").join("").split("]").join("").split(",").map((s) => s.trim()).filter(Boolean);
};
const MAIN_JOBS = ["main-plan", "main-build", "main-smoke", "main-npm", "main-commit", "main-github-release", "main-rollback"];
const MAIN_JOBS = ["main-plan", "main-build", "main-smoke", "main-npm", "main-commit", "main-github-release", "main-close-issues", "main-rollback"];
const inputBlock = (name) => {
const i = LINES.indexOf(" " + name + ":");
assert.ok(i > 0, "input " + name);
@@ -718,7 +718,7 @@ describe("ADR-0013 repo: main-only release workflow", () => {
test("[MAIN-ONLY] release.yml main path: job order ci/route -> plan -> build -> smoke -> npm -> commit on main -> github release", () => {
assert.deepEqual(MAIN_JOBS.filter((j) => J[j]), MAIN_JOBS);
assert.ok(Object.keys(J).indexOf("main-plan") < Object.keys(J).indexOf("main-build"));
const chain = { "main-plan": "ci", "main-build": "main-plan", "main-smoke": "main-build", "main-npm": "main-smoke", "main-commit": "main-npm", "main-github-release": "main-commit" };
const chain = { "main-plan": "ci", "main-build": "main-plan", "main-smoke": "main-build", "main-npm": "main-smoke", "main-commit": "main-npm", "main-github-release": "main-commit", "main-close-issues": "main-github-release" };
for (const [j, dep] of Object.entries(chain)) assert.ok(needsOf(j).includes(dep), j + " needs " + dep + ": " + needsOf(j));
assert.ok(needsOf("main-rollback").includes("ci"));
});
@@ -2584,3 +2584,176 @@ describe("ADR-0014 issue intake: score, one comment, issue state stays with main
assert.equal(plan({ result, author: "CONTRIBUTOR", labels: [], comments: [user] }).skip, null);
});
});
describe("ADR-0014 issue flow: fixed-on-main label on push, close on release (D-FIXED-ON-MAIN-1)", () => {
// Owner 2026-11-12: "tamam supermis bu fixed-on-main etiket fikri bunu bot da uygulasin otomatik".
// Fixtures: main.log = `git log --reverse --format=%H%x1f%s%x1f%b%x1e 4d45b836^..06520806` (100 real commits with the
// r54 revert pair and the #1350, #1371, #1373 fixes); tag-v2.1.10.txt = the shas of that range in tag v2.1.10
// (git merge-base --is-ancestor); subjects.txt = real subjects of each commit type; issue bodies of #1350, #1371, #1373.
const REPO = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
const readRepo = (rel) => readFileSync(path.join(REPO, rel), "utf8");
const FX = "tests/fixtures/fixed-on-main/";
const bot = () => import("../.github/scripts/fixed-on-main.mjs");
const mainLog = async () => (await bot()).parseLog(readRepo(FX + "main.log"));
const TAG = new Set(readRepo(FX + "tag-v2.1.10.txt").split("\n").filter(Boolean));
const inTag = (sha) => TAG.has(sha);
const issue = (n) => {
const body = readRepo(`tests/fixtures/issue-intake/${n}.md`);
const first = body.split("\n")[0];
return { number: n, title: first.slice("<!-- Title: ".length, first.length - " -->".length), body };
};
const shaOf = (log, short) => log.find((c) => c.sha.startsWith(short)).sha;
test("commit kinds: fix, feat, perf (any scope, fix+docs) label; revert removes; test, docs, chore, data, refactor never", async () => {
const { commitKind } = await bot();
const subjects = readRepo(FX + "subjects.txt").split("\n").filter(Boolean);
assert.deepEqual(subjects.map(commitKind), ["fix", "fix", "fix", "revert", "unrevert", "fix", "fix", null, null, null, null, null]);
assert.equal(commitKind("fix(core)!: x (#1)"), "fix");
assert.equal(commitKind("Revert \"fix: x (#1)\""), "revert");
assert.equal(commitKind("Merge branch 'main' (#1)"), null);
assert.equal(commitKind("fixes: x (#1)"), null);
});
test("issue refs: (#N) and #N, each once; a#1, &#123; and #12a are no reference", async () => {
const { issueRefs } = await bot();
assert.deepEqual(issueRefs("revert: lane r54 (#1342, #1358) and #1342"), [1342, 1358]);
assert.deepEqual(issueRefs("fix: #7: x"), [7]);
for (const s of ["a#1", "&#123;", "#12a", "#", "# 5", "D-REL-WHO-1"]) assert.deepEqual(issueRefs(s), [], s);
});
test("live fixes on the real main log: the r54 revert pair leaves #1342 and #1358 fixed; #1373, #1371, #1350 hold their fix commits", async () => {
const { liveFixes } = await bot();
const log = await mainLog();
assert.equal(log.length, 100);
const live = liveFixes(log);
for (const n of [1342, 1358, 1371, 1350, 1373]) assert.ok(live.has(n), "#" + n);
assert.deepEqual([...live.get(1373)], [shaOf(log, "08bb798b")]);
assert.deepEqual([...live.get(1371)], [shaOf(log, "29fd99d9")]);
assert.deepEqual([...live.get(1350)].sort(), [shaOf(log, "16dac25e"), shaOf(log, "877eebcc")].sort());
assert.ok(live.get(1342).has(shaOf(log, "921ba58c")) && live.get(1342).has(shaOf(log, "6a001fe6")));
// Up to the revert only: the revert removed every r54 fix commit.
const cut = log.findIndex((c) => c.sha.startsWith("92c1ad26"));
const before = liveFixes(log.slice(0, cut + 1));
assert.ok(!before.has(1342) && !before.has(1358), JSON.stringify([...before.keys()]));
});
test("live fixes: a revert by sha removes that commit only; a revert with no sha removes the issue; a later fix counts", async () => {
const { liveFixes } = await bot();
const a = "a".repeat(40), b = "b".repeat(40), r = "c".repeat(40), f = "d".repeat(40);
const two = [{ sha: a, subject: "fix: x (#5)", body: "" }, { sha: b, subject: "fix: y (#5)", body: "" }];
const bySha = liveFixes([...two, { sha: r, subject: "Revert \"fix: x (#5)\"", body: "This reverts commit " + a + "." }]);
assert.deepEqual([...bySha.get(5)], [b]);
assert.ok(!liveFixes([...two, { sha: r, subject: "revert: lane x (#5)", body: "" }]).has(5));
const again = liveFixes([...two, { sha: r, subject: "revert: lane x (#5)", body: "" }, { sha: f, subject: "fix: z (#5)", body: "" }]);
assert.deepEqual([...again.get(5)], [f]);
});
test("label plan: a fix push labels open issues once and creates the label; test/docs/chore/data pushes never label", async () => {
const { labelPlan, liveFixes, LABEL } = await bot();
const log = await mainLog();
const live = liveFixes(log);
const pushed = log.filter((c) => c.subject.includes("(#1373)"));
const open = new Map([[1373, ["bug", "repro-ready"]], [1371, []]]);
assert.deepEqual(labelPlan({ pushed, live, open }), [
{ op: "label-create", name: "fixed-on-main", color: "0E8A16", description: "Fix is on main, ships in the next release" },
{ op: "label-add", issue: 1373, name: LABEL.name },
]);
const noFix = ["test: red x (#1373)", "docs: y (#1373)", "chore: z (#1373)", "data: w (#1373)"].map((subject) => ({ sha: "e".repeat(40), subject }));
assert.deepEqual(labelPlan({ pushed: noFix, live, open }), []);
assert.deepEqual(labelPlan({ pushed, live, open: new Map([[1373, ["fixed-on-main"]]]) }), [], "already labeled");
assert.deepEqual(labelPlan({ pushed, live, open: new Map() }), [], "closed issue or a pull request number");
});
test("label plan: a revert removes the label only when no un-reverted fix for the issue stays on main", async () => {
const { labelPlan, liveFixes } = await bot();
const log = await mainLog();
const cut = log.findIndex((c) => c.sha.startsWith("92c1ad26"));
const revert = [log[cut]];
const open = new Map([[1342, ["fixed-on-main"]], [1358, ["fixed-on-main"]]]);
assert.deepEqual(labelPlan({ pushed: revert, live: liveFixes(log.slice(0, cut + 1)), open }).map((a) => a.op + a.issue),
["label-remove1342", "label-remove1358"]);
assert.deepEqual(labelPlan({ pushed: revert, live: liveFixes(log), open }), [], "the revert of the revert keeps the fix");
});
test("agent of an issue: form field, title prefix, doctor env line (real bodies #1373, #1371, #1350)", async () => {
const { agentOf } = await bot();
assert.equal(agentOf(issue(1373)), "claude-code");
assert.equal(agentOf(issue(1371)), "opencode");
assert.equal(agentOf(issue(1350)), "opencode");
assert.equal(agentOf({ title: "[claude-code] hook fails", body: "" }), "claude-code");
assert.equal(agentOf({ title: "Pi: search is slow", body: "" }), "pi");
assert.equal(agentOf({ title: "OpenCode plugin does not load", body: "" }), "opencode");
assert.equal(agentOf({ title: "x", body: "### Agent\n\ngemini\n\n### Problem\n\ny" }), "gemini");
assert.equal(agentOf({ title: "ctx_search misses a file", body: "### Agent config\n\n_No response_" }), null);
});
test("release comment: version, the agent's own update command from UPGRADE_HOST_COMMAND, reopen line; unknown agent links the install guide", async () => {
const { releaseComment, MARKER, INSTALL_GUIDE } = await bot();
const { UPGRADE_HOST_COMMAND } = await import("../src/core/contracts/constants.ts");
for (const [agent, cmd] of Object.entries(UPGRADE_HOST_COMMAND)) {
const c = releaseComment("2.1.11", agent);
assert.equal(c, `${MARKER}\nReleased in v2.1.11. Update with \`${cmd}\`. If it still happens on v2.1.11, please reopen this issue.`);
}
const u = releaseComment("v2.1.11", null);
assert.ok(u.includes(INSTALL_GUIDE) && u.startsWith(MARKER + "\nReleased in v2.1.11."), u);
const src = readRepo(".github/scripts/fixed-on-main.mjs");
assert.ok(!src.includes("claude plugin update") && !src.includes("pi update"), "commands come from constants.ts only");
for (const w of ["weekly", "next week", "Weekly"]) assert.ok(!(releaseComment("2.1.11", "pi") + u).includes(w), w);
});
test("close plan against the v2.1.10 tag stub: in-tag fixes close with one comment; later fixes, maintainer comments, no fix skip", async () => {
const { closePlan, liveFixes, MARKER, namesVersion } = await bot();
const live = liveFixes(await mainLog());
const L = ["bug", "fixed-on-main"];
const issues = [
{ ...issue(1350), labels: L, comments: [] },
{ ...issue(1373), labels: L, comments: [] },
{ ...issue(1371), labels: ["bug"], comments: [] },
{ number: 1342, title: "[claude-code] x", body: "", labels: L, comments: [{ body: "Fixed in v2.1.10, thanks", bot: false, assoc: "OWNER" }] },
{ number: 1358, title: "x", body: "", labels: L, comments: [{ body: MARKER + "\nReleased in v2.1.10.", bot: true, assoc: "NONE" }] },
{ number: 9999, title: "x", body: "", labels: L, comments: [] },
];
const { actions, skipped } = closePlan({ version: "2.1.10", issues, live, inTag });
assert.deepEqual(actions.map((a) => a.op + " #" + a.issue), [
"comment-create #1350", "label-remove #1350", "close #1350", "label-remove #1358", "close #1358",
]);
assert.ok(actions[0].body.includes("opencode plugin update") && actions[0].body.includes("v2.1.10"), actions[0].body);
assert.deepEqual(skipped.map((s) => s.issue), [1373, 1342, 9999]);
assert.ok(!namesVersion("Fixed in v2.1.10", "2.1.1") && namesVersion("Released in v2.1.10.", "v2.1.10"));
});
test("scripts: string scanning only (no regex), the close run never fails the release", () => {
const src = readRepo(".github/scripts/fixed-on-main.mjs");
for (const s of ["RegExp", ".match(", ".matchAll(", ".test(", ".search(", ".replace(", "/g,", "/g)"]) assert.ok(!src.includes(s), s);
assert.ok(src.includes('process.exitCode = mode === "close" ? 0 : 1;'));
});
test("fixed-on-main.yml: push to main only, issues: write and contents: read, full history, runs the label mode", () => {
const y = readRepo(".github/workflows/fixed-on-main.yml").split("\n").map((l) => l.trim());
for (const l of ["push:", "branches: [main]", "issues: write", "contents: read", "fetch-depth: 0", 'node-version: "24.15.0"',
"GH_TOKEN: ${{ github.token }}", "run: node .github/scripts/fixed-on-main.mjs label"]) assert.ok(y.includes(l), l);
const perms = y.filter((l) => l.endsWith(": write") || l.endsWith(": read"));
assert.deepEqual(perms, ["issues: write", "contents: read"]);
assert.ok(!y.some((l) => l.includes("issue comment") || l.includes("issue close")), "the label run never comments or closes");
});
test("release.yml main-close-issues: after the GitHub release, issues: write and contents: read, never fails the release", () => {
const L = readRepo(".github/workflows/release.yml").split("\n");
const at = L.indexOf(" main-close-issues:");
assert.ok(at > L.indexOf(" main-github-release:"), "after main-github-release");
const b = [];
for (let k = at + 1; k < L.length && (L[k].startsWith(" ") || L[k].trim() === ""); k++) b.push(L[k].trim());
for (const l of ["needs: [route, main-plan, main-github-release]", "continue-on-error: true", "issues: write", "contents: read",
"fetch-depth: 0", "GH_TOKEN: ${{ github.token }}", "VERSION: ${{ needs.main-plan.outputs.version }}",
'run: node .github/scripts/fixed-on-main.mjs close --version "$VERSION"']) assert.ok(b.includes(l), l + "\n" + b.join("|"));
assert.deepEqual(b.filter((l) => l.endsWith(": write") || l.endsWith(": read")), ["issues: write", "contents: read"]);
});
test("docs: CONTRIBUTING names the flow; one DEVIATIONS row quotes the owner", () => {
const c = readRepo("CONTRIBUTING.md");
assert.ok(c.includes("`fixed-on-main`") && c.includes("closes"), c);
const rows = readRepo("docs/architecture/DEVIATIONS.md").split("\n").filter((l) => l.startsWith("| D-FIXED-ON-MAIN-1 |"));
assert.equal(rows.length, 1);
assert.ok(rows[0].includes("bunu bot da uygulasin otomatik"), rows[0]);
});
});
+602
View File
@@ -0,0 +1,602 @@
9ed3323cf7e034dfa94bc4ae92d2f1ca05adbf98test: red Pi tool_result keeps details and structuredContent, excludeTools keeps a tool whole (#1352)Unit (tests/0020-plugins, tests/0020-adapters, ADR-0020) and e2e (GP3, Pi's own
ExtensionRunner.emitToolResult). They fail on main: the replace sends
details: {text} and no structuredContent, so Pi drops it (ADR-0016:48 Pi row).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

cbd773279fe85fb9c91f4a12f02f50ae4a904d01fix: Pi tool_result keeps details and structuredContent, contextMode.excludeTools keeps a tool whole (#1352)A case-C replace now returns { content } plus the event's structuredContent
(ADR-0016:48 Pi row; Pi types.d.ts ToolResultEventResult: replacing content
without structuredContent drops it). details is omitted, so Pi keeps the
tool's own value. contextMode.excludeTools (exact names, read through
pi.getSettings) sends keep: true; the pi adapter copies it to result.keep and
dispatch returns ALLOW at the existing D-M2-MCP-1 point. Journal rows are
still written. Pi with no getSettings, or a malformed value, keeps the default.
Profile, src/entries/pi.ts tool_result, 23 KB result, median of 50 (p90):
before: replace 7.14-8.02 ms (15.47-17.93 ms)
after: replace 7.44-7.64 ms (14.12-14.68 ms); excluded tool 0.04 ms (0.05 ms)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

73632a808d45229494d0de290ee3d582ef46787erefactor: drop the unused fakePi getSettings option; docs and DEVIATIONS D-R54-PI-META-1 (#1352)docs/install/pi.md: tool_result keeps structuredContent and details; new
section "Keep a tool's result whole" (contextMode.excludeTools).
DEVIATIONS D-R54-PI-META-1 amends D-M5-P1-1 (ADR-0016:48, archaeology 526e1c57).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

35e2194fb7c55bc3202b69e65202e6db5887b18atest: red copilot-cli SKIPPED when VS Code's copilot launcher has no Copilot CLI (#1360)Unit (tests/0019-setup-engine.test.mjs, next to D-SETUP-HOST-BROKEN-1): a fake copilot that prints the
copilot_shim app.rs l.485 (no terminal) and l.475 (policy) texts and exits 127. Setup must be SKIPPED with
npm install -g @github/copilot, write nothing, run no mcp add, exit 0; doctor SKIPPED too.
E2E (GP-SETUP-npm-install): built cli.mjs setup --agents copilot-cli --yes --no-input with the stand-in on PATH.
Today all three fail: FAIL (rolled back), exit 1, gh issue prompt. #1361 is a duplicate.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

714a2fc3126ccf0f79dcce4881b641fe5041be20fix: copilot-cli is SKIPPED with npm install -g @github/copilot when VS Code's copilot launcher has no CLI (#1360)VS Code ships a copilot launcher (microsoft/vscode copilot_shim; Linux /usr/bin/copilot). With no Copilot CLI
installed and no terminal it prints "GitHub Copilot CLI was not found. ..." and exits 127 (app.rs l.42, l.485).
Setup took any PATH hit as the host (966af39f), so mcp add failed, rolled back, exit 1 and an issue prompt.
HOST_BROKEN (034e7519, #1308) now holds a list per bin; the shim prefix covers all its variants (includes, no regex).
listState sees it on the first host call, before any write: SKIPPED, nothing written, no mcp add, exit 0;
doctor shares listState and reports SKIPPED. The #1308 case keeps its exact wording.
Profile (median of 50, runSetup/runDoctor copilot-cli with the launcher stand-in):
before: setup 143.8 ms (FAIL + rollback), doctor 4.0 ms
after: setup 142.9 ms (SKIPPED), doctor 3.6 ms
#1361 is a duplicate.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

5172e15cf5af114245d82e91c2bdec3e638e0610docs: DEVIATIONS D-SETUP-COPILOT-SHIM-1 (#1360)Cites #1360/#1361, ADR-0019 l.56/l.66, D-SETUP-HOST-BROKEN-1 (l.195) and the archaeology
(966af39f, 37fd45c8, 034e7519). Profile: setup 143.8 -> 142.9 ms, doctor 4.0 -> 3.6 ms (median of 50).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

d1ca9a21e0dffa6fb3ebf01f0194758e2262bee9refactor: HOST_BROKEN reuses HOST_BROKEN_PREFIX for the #1308 entry (#1360)No behavior change: 0019-setup-engine 96/96, e2e copilot-launcher 1/1, tsc clean, build --generated-only clean.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

f0ec05658ccacf111c51b5547e1f8dc1e7a320c0test: red ctx_search zero cursors and ctx_resume blank session (#1354, #1353)Unit (ADR-0009 group): [M4] GP5/explicit-zero-is-not-paging, [M4] resume/blank-session-falls-back.
The cross-mode guard test now uses real cursors (offset:20, after:1700000000).
Pi path (ADR-0007 group): whole-schema zero payloads through the Pi execute().
E2E: GP5 search-param-schema-match gets zero-filled inputs; GP6 resume-blank-session-falls-back.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

0af5f262f89eda9ad208d6829465b11979a69f91fix: ctx_search accepts offset:0/after:0, ctx_resume treats a blank session as absent (#1354, #1353)non-zero cursor. 0 is the first page of either cursor; whole-schema clients (Pi) send it on
every call. Every non-zero conflict keeps its exact INVALID_ARGS line. ADR-0009 line 215 and
the 00-architecture INVALID_ARGS row say so. Archaeology: dfac356e (M2-T9, spec review).
ctx.sessionId (06-tools-session.md step 2). Archaeology: 0e3b3828 copied the spec's
'input.session ?? ...' literally; v1 used a truthy check.
The GP5 cross-mode e2e case now uses real cursors (offset:20, after:1700000000); the
golden is unchanged.
Profile, handler, median of 50 runs, 20 journal rows, before -> after (ms):
ctx_search timeline 0.478 -> 0.467
ctx_search relevance 0.742 -> 0.752
ctx_resume {} 0.515 -> 0.525
ctx_resume {seq:1} 0.326 -> 0.317
(no change beyond noise)
Tests: 0009 + 0007 + doc-reading unit files 1849 pass, 0 fail; GP5 + GP6 e2e 45/45; tsc clean.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

e3648b80873acfcdf978117cf90835d3f177b868test: red ctx_search blank source with the reporter's whole-schema payload (#1354)The #1354 payload also holds source:"". The zero-paging unit test and the Pi
execute test now seed one ctx_index row, send source:"" with offset:0/after:0,
and check for the hit (and for the <context_mode_state block on ctx_resume).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

548c305516a53d5fa2ec037744033fc5a6215c68fix: ctx_search treats a blank source as absent (#1354)The #1354 payload holds source:"" next to offset:0/after:0. With the cursors
fixed, the blank source still filtered on a source named "" and the search
found nothing. A blank or whitespace-only source now counts as absent, the
same rule as ctx_resume's blank session (D-1353-RESUME-BLANK-1).
ADR-0009 §8.1 rule 6 (line 168) now matches §8.4: a non-zero cursor conflicts,
0 is the first page, and a blank source names no source. The
D-R54-SEARCH-ZERO-1 row cites line 168 and the blank-source reason.
Profile, handler, median of 50 runs, 20 indexed rows, before -> after (ms):
bare call 1.830 -> 1.943
blank source 1.774 -> 1.851
named source 1.722 -> 1.817
(3 runs after stay in 1.7-2.1 ms: noise)
Tests: 0009 + 0007 157/157; GP5 + GP6 e2e 45/45; tsc clean.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

7961c51bc92a459ecd9f6f300189add2e3e827b8test: red Codex D4 treats user tool approval tables and user hooks/codex/*.mjs hooks as v1 (#1359 #1364)Repro on main f681b458: doctor --agents codex exits 1 on the reporter's two
[mcp_servers.context-mode.tools.*] approval_mode tables, setup again deletes them,
and ctx_upgrade removes a user hook under ~/.agents/hooks/codex/.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

3d845758f6aea56cbc6c32160f3f3dacc099b802fix: Codex D4 keeps user tool approval tables and user hooks/codex/*.mjs hooks (#1359 #1364)- detect-v1 scanCodex: a sub-table of a v2 [mcp_servers.context-mode] entry (env,
tools.<tool> approval_mode) is Codex config, never a v1 leftover. Under a v1 parent
(command = "context-mode") every sub-table is still flagged. Replaces the env-only
exception (D-1327-CODEX-ENV-1).
- detect-v1 isCodexScript: v1 only for hooks/codex/<event>.mjs with the six v1.0.169
Codex event names (LEGACY_HOOK_PATH_SUFFIXES), POSIX or Windows separators.
- setup ownConfigEdits keeps the user tools table, as it keeps env_vars.
- D-DOC-RT-1 CODEX_HOME test now uses a v1 data dir as the leftover in CODEX_HOME.
- DEVIATIONS D-1359-CODEX-TOOLS-1, D-1364-CODEX-V1-SCRIPT-1.
Profile detectV1("codex"), median of 50 (3 runs): before 163.1/169.3/163.9 us,
after 167.0/168.1/167.8 us.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

8100813c919c0d6fd9160e4c543991fe9ca2f149test: red v1 upgrade against main leaves a hybrid install (#1363)Unit (tests/0011, ADR-0011 v1 upgrade stop): main's build script must stop a v1
upgrade and name npm i -g context-mode. E2E (GP11): the real 1.0.169 upgrade
against this checkout must write nothing; npm i -g of the release tree gives 2.x.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

de5ed0c8cd94c69c5c4891fce6c3d148ffafca89fix: main's build script stops a 1.0.x upgrade before any write (#1363)v1 context-mode upgrade clones main, runs npm install and npm run build in the
clone, then copies package.json and src/ over the install. Since the MAIN-ONLY
merge (30b95f76) main carries the 2.x version, so the ADR-0011 frozen-main
guard was gone and v1 left a hybrid tree (package.json 2.1.7, bin 1.0.169).
scripts.build now runs scripts/v1-upgrade-stop.mjs: it writes nothing, names
npm i -g context-mode and exits 1, so v1 takes its own NOT updated path.
build:release stays the contributor build.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

6e8c89590cc40bffe0b2aed300584900326729bbtest: GP11 v1 upgrade case builds its own 2.x release tree (#1363)Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

509d68837d1d01d1bc4068bb9c6961c5c7e2f772docs: ADR-0011/0017/PRD guard is main's build script; DEVIATIONS D-V1-UPGRADE-STOP-1 (#1363)Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

d9b5f00f1c6cd4f1fc2455496cee8ab899ac78acdocs: D-V1-UPGRADE-STOP-1 profile numbers (#1363)Median of 50 runs, macOS arm64, Node 26.8.1:
- npm run build, before: 473.4 ms (p10 453.7, p90 509.1), full build, exit 0
- npm run build, after: 146.3 ms (p10 139.4, p90 171.8), stop script, exit 1, no write
- npm run build:release, after: 469.3 ms and 523.6 ms (two runs; same work as the
old build, spread is load from parallel lanes)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

314ee9e19080a73c97c063c0afe67bf265680cbdtest: red docs must state the build-script guard for v1 upgrade (#1363)Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

fb4d6a5aea84aeb00bc3d1053eae9ea0d8c9cda7docs: ADR-0011/0017, module 15 and install guide match the build-script guard (#1363)Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

3d0fe344075ad4a35a326e88bffb2cf0a14bdb62test: #1359 ctx_upgrade test writes a Windows server path as an escaped TOML string (#1359)The Windows CI runner failed: C:\Users\... inside a TOML basic string is an
invalid escape, so config.toml did not parse. JSON.stringify escapes it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

e2e11f7179379cac3c44575c5ebbbd71ce125fa9test: red skill reference under a symlinked skill dir is replaced and denied (#1345)D-R54-OWN-FILE-LINK-1: ~/.claude/skills/<skill> as a symlink to a dir outside
~/.claude. PostToolUse Read is replaced by a ctx_search pointer, PreToolUse Read
over OUTPUT_CAP is denied, the fallback deny misses it too. Negatives: a .jsonl
through the same link and the link target by its own path keep the rules.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

84bc3bd42c49f380528decd2f3fde90f726538b9fix: a skill file under a symlinked skill dir reaches the model whole (#1345)D-R54-OWN-FILE-LINK-1. isOwnFile now counts a Markdown path inside an own
dir by the path as written (path.resolve, components, no realpath) or by
realpath components as before. One change at the decision point covers
decide.ts bigDeny, fallback.ts bigRead and dispatch.ts ownRead.
Archaeology: ee0a1f60 (#1326) reused the realpath containment predicate of
5e26bdb5 (D-M1-T3-4, GP7), made for ctx_execute(file=) containment (#852).
No ADR or PRD line asks for realpath here; this exemption opens no file.
isInside and isInsideAny are unchanged, so #852 keeps realpath.
Profile, isOwnFile, median of 50 runs x 1000 calls:
own file 16.71 us -> 3.24 us
linked own file 48.37 us (false) -> 3.27 us (true)
project file 29.19 us -> 31.47 us
Tests: 0008-enforcement 197/0, prd10-hooks-runtime 302/0, 0007-identity
87/0, GP3-hooks e2e 23/0, 0023-install-docs 46/0, 0014-repo-hygiene 157/0.
tsc --noEmit clean, build --generated-only clean.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

5717cfb55ba7cc1442e08d2bf1803bb248c47209perf: keep own-dir root components, skip resolve for absolute POSIX paths (#1345)Review r54 finding: the project-.md Read path was 10-12% slower because
isLexicallyInsideAny resolved and split every fixed root on each call.
The roots' components are now kept in a Map (as rootReal keeps their
realpaths) and an absolute POSIX path skips path.resolve. Project file
28.7 -> 29.4 us (+2.3%), own file 15.9 -> 1.6 us, linked own file
48.1 us (false) -> 1.5 us (true); median of 50 x 1000 calls, 5 runs.
D-R54-OWN-FILE-LINK-1 row updated; 0008 test covers a '.' step.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

474468e1b50cfd35853f0c49a2dbe56361c6b638test: red a .. step through a symlinked skill dir still replaces (#1345)path.resolve folds skills/linked/.. to skills, but the OS reads the parent of
the link target. isOwnFile must see the raw tool path. Review r54 round 2.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

1f3e5a46db1fb64979e865d50bde9b5a20e38e3afix: isOwnFile checks for .. on the raw tool path, before resolve (#1345)isOwnFile(agent, cwd, p, env) takes the path as the tool gave it. The lexical
branch runs only when p (and cwd for a relative p) has no .. component
(hasParentStep, by path components). The realpath branch is unchanged.
Callers decide.ts bigDeny, dispatch.ts ownRead, fallback.ts bigRead pass cwd + p.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

2407821cd1dfc4d75eb2d8a9b5d23f533ac2a52edocs: D-R54-OWN-FILE-LINK-1 names the raw-path .. rule and new profile (#1345)Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

4d45b836d62f33cd47e3d07d8e2e37f6059ece57test: red replace pointer the caller can call, built-in and synced agents, subagent labels (#1342, #1358)ADR-0016 line 16: one budget everywhere, and the follow-up names only a tool the caller can call.
- general-purpose, fork, Explore, Plan resolve to ctx tools (LV8); claude-code-guide, statusline-setup, unknown stay not A
- synced plugin agents under plugins/synced/<id>/<plugin>/agents; dot dirs never read
- case C and case B replaces name no ctx tool; case B line runs search.mjs
- two subagent calls give two labels (today both subagent:Grep:0)
- main-session MCP result: no empty query; search.mjs line works from any cwd
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

87d829a4015cc30d1dd8b13cb5c54ce4e358ce1btest: red, OpenCode 1.x list check fails on a slow user MCP server and on an unreadable version (#1362)A fake opencode 1.x whose mcp list takes 15 s (one user server that never answers)
makes setup FAIL 'list: opencode mcp list --pure does not list context-mode'.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

ede6046cf78af999323d9c8304b6a33665021388fix: OpenCode 1.x list check reads debug config --pure, not the slow mcp list (#1362)mcp list --pure connects every user MCP server; one that never answers held it
past the 10 s budget and setup rolled back. 1.x now reads the merged config the
CLI loaded (mcp.context-mode), as 2.x already does (D-OC2-LIST-1). A --version
with no digits is reported as such, with no silent 1.x fallback.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

9db3f80a061d2ea57eff93bef0758ef0d04fb440test: red, OpenCode 2 bare native entry plugins:["context-mode"] is not seen by setup and doctor (#1344)After `opencode plugin add context-mode` (2.2.6) doctor says 'not set up, ... or run:
opencode plugin add context-mode', setup adds a second path entry, and a path entry
next to the bare entry is not reported as a double load. 1.19 control stays green.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

d7bef0931ff19c3e4a75261dbe07e7af85856fbbfix: OpenCode 2 bare native entry plugins:["context-mode"] counts as the hooks entry (#1344)`opencode plugin add context-mode` (2.2.6) writes the bare name under plugins. The
engine only knew the context-mode@<tag> prefix of the @next era (765964a7 changed the
command, not the rule), so doctor said 'not set up ... or run: opencode plugin add' and
setup added a second path entry (loads twice). One rule, isNativeOpencodeEntry, now
serves setup and D3; the native entry is read from opencode.jsonc too. 1.x plugin key:
the bare name stays the v1 entry (D4).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

2d29c780dd05384f21a0e3466945fe30bb527b6etest: red, OpenCode plugins dir file of ours is not seen by D3, setup and doctor (#1349)~/.config/opencode/plugins/context-mode/index.js re-exporting context-mode/server
(OpenCode 2.2.6 loads it): D3 says 'wrong: MCP entry', doctor says 'not set up ...
or run: opencode plugin add', and setup adds a path entry that loads it twice.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

92d4ea4e6416a2c91ec0d8c64f31e9937695ce29fix: an OpenCode plugins dir file of ours counts as the hooks entry (#1349)OpenCode 2.2.6 loads ~/.config/opencode/plugins/<name>/index.js with no config entry.
A file whose module names are context-mode, context-mode/server or our bundle's
opencode/plugin.js now passes D3 and hook-registered, and setup writes no path entry
next to it (that entry made the plugin load twice). The scan reads string literals
with a quote-aware scanner (no regex); files over 64 KB are skipped.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

ebc4f3fd5a5bc79fdee3bcee000a002f99408436docs: DEVIATIONS rows and install doc for the OpenCode list check, bare native entry and plugins dir (#1362, #1344, #1349)Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

0cabec3bd1e3b065ef1bdb7e561dca0d03970a7bdocs: profile numbers for the OpenCode list check and native entry fixes (#1362, #1344, #1349)cli.mjs doctor --agents opencode, median of 50 runs, temp HOME, before (main f681b458) -> after:
- 1.19.5, one user MCP server that never answers: 10502 ms FAIL -> 913 ms PASS
- 1.19.5, plain setup: 1191 ms PASS -> 895 ms PASS
- 2.2.6, plugins:["context-mode"] only: 112 ms -> 55 ms (fix line no longer repeats plugin add)
- 2.2.6, plugins dir file only: 160 ms -> 55 ms
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

adab8b84670c9aecadaa10834ba821e4a1052a6btest: red, OpenCode project .opencode/plugins file and a plugins dir file with no package (#1349)Review round 1: setup wrote a path entry next to <project>/.opencode/plugins/context-mode/index.js (two plugin
loads on 2.2.6, doctor PASS), and a dir file that re-exports context-mode/server with no node_modules/context-mode
passed setup and doctor while OpenCode logged "Cannot find package 'context-mode'".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

6bb2b778a6f068f6497ce62d01e4612e899ad62bfix: OpenCode project .opencode/plugins file counts for setup, and a dir file with no package is no entry (#1349)nativePluginsKey now reads the same plugins dirs as D3 (opencodePluginDirs: config dir and <project>/.opencode), so
setup adds no path entry next to a project plugins file and doctor FAILs one as "loads twice". A dir file counts only
when OpenCode can resolve its module (node_modules/context-mode next to it or above it, or an existing plugin.js path);
otherwise doctor names the file and the missing package, and setup writes the path entry.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

29de2ee7fe0e6b3c1f60dbb4e5efa4518bf7b810docs: OpenCode plugins dir row and install doc for the project dir and the package check; doctor reads debug config (#1349)Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

851300de48b9d70376e4bd66c3fb1cc3f2b5230dtest: red, setup in a project with .opencode/plugins keeps the global OpenCode path entry; doctor names the project file (#1349)Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

cdb1050134797bfff51e83782c4fec475beb343efix: only the OpenCode config plugins dir decides the global entry; a project plugins file next to it names the file to remove (#1349)Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

2da9830c33c8f95546d5ab8711202aa6937debd8docs: OpenCode plugins dir row and install doc, a project plugins file keeps the global entry (#1349)Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

011d86cda3ba47dc99c94d322570ca134a92705btest: red, the CLI Fix: line names the OpenCode project plugins file to remove, not setup (#1349)Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

133c1b653e027719a4ec8be3b74015d3ed946d0bfix: the CLI Fix: line names the OpenCode project plugins file to remove; doctor does not offer setup for it (#1349)Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

8f5e533dac08fd2810e1a59d19835c750fc92f14e2e: real OpenCode 2 loads context-mode once after setup, with the bare plugins entry and with a config plugins dir file (#1344, #1349)Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

8a50942a59c5a72b1bd2bcbe4184d74f28f32c79e2e: real OpenCode 1.19.5 setup PASSes in under 10 s next to a user MCP server that never answers (#1362)Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

a69161b458d683fe405667c824e3806e5e2aaa3adocs: round 2 profiling in the OpenCode plugins dir row (#1349)Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

658e224824db0065e62f65147ab9f010cf519b94test: red, fresh HOME setup in a project with a .opencode/plugins file keeps the MCP and global entry and names the file to remove (#1349)Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

e90d64be5c3c835ce52a64cf1257c6208a68663ffix: setup keeps the MCP and global OpenCode entry when only a project .opencode/plugins file loads twice, and its Fix: line names that file (#1349)The fix line now reads the files before any rollback.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

64bd22cf09cc8a0025c4ce8260930ebeeae26693docs: round 3 in the OpenCode plugins dir row, setup keeps its entries when only a project file loads twice (#1349)Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

fb04aed39bf22e593560e99f6d27f518415ed18edocs: round 3 profiling in the OpenCode plugins dir row (#1349)Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

921ba58c6b969b02d667291e477a25940e67c356fix: Claude Code replace pointer names only tools the caller can call (#1342, #1358)- D-CC-POINTER-1 (#1342, ADR-0016 line 16): every caller keeps the same replace budget. Case A subagents get
the main-path replace with the callable ctx_search pointer (no passthrough). Case B/C subagents get a
handle line that names no ctx tool; it names Read offset/limit only when the subagent has Read.
- D-CC-POINTER-2 (#1358): on the claude-code row a caller with a shell also gets the MCP-free
search.mjs call (short id + project dir), so the pointer works when the MCP server is not connected.
search.mjs accepts the s<base36> handle and an explicit project dir. An MCP input with no intent
field falls back to the tool name (never an empty query).
- D-CC-POINTER-3 (#1342): built-in agent row for claude-code (general-purpose, fork: all tools; Explore,
Plan: all minus disallowed; claude-code-guide, statusline-setup stay restricted) and the synced
plugin store <claude dir>/plugins/synced/<id>/<plugin>/agents (dot dirs skipped).
- D-CC-POINTER-4 (#1342): subagent label is subagent:<tool>:<callId ?? turn>, as mainLabel.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

17f8ab11a6b10a4e5d86be2df303a622b5a25cfetest: the ADR-0007 XDG OpenCode fake prints a version and its debug config, the list check reads (#1362)Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

17ea79e3f0dfd0db939ab3c23822bd7598e1c37cdocs: ADR-0016 LV8 row and synced store, DEVIATIONS D-CC-POINTER-1..4, subagent-handle draft (#1342, #1358)Profile (paired, 50 runs each, built hook.mjs, --agent claude-code):
- mcpMain (MCP replace): median 96.4 -> 101.3 ms, p95 130.1 -> 125.0 ms
- subGP (general-purpose Bash): median 107.1 -> 108.2 ms, p95 137.5 -> 136.2 ms
- subC (unknown type Grep): median 110.2 -> 109.9 ms, p95 138.0 -> 132.8 ms
No measurable change (shared machine, load 14).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

f0e952d6351038975b879adab98e5f19a9735677test: e2e GP3 subagent pointer is callable (#1342)On the base build (f681b458) a restricted subagent (tools: Read, Bash) got a replace that named ctx_search,
which it cannot call: the first case fails there and passes on the fix. The general-purpose case guards
against case A turning into a passthrough (full output).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

79fa820cc24c1bb93435619cf60bafae321b9173e2e: the GP-SETUP fake opencode prints a version and its debug config, the list check reads (#1362)Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

4a50c4b0758208e38ca9fee82f8a88a6aebab31ftest: red OpenCode agent tool set and in-process replace (#1348, #1347)#1348: an OpenCode 2 subagent whose permissions deny every ctx_* tool gets a
webfetch deny that names ctx_index (ADR-0016 l.23, l.91 D-SUB-NOCTX-1).
#1347: a large completed shell result reaches the model unchanged on 2.x
(278889 bytes) and on 1.19 (208000 bytes) (ADR-0016 l.49, 12-plugins 4.5).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

0fe650eeb6c3e1c7a4fc5de97bbc75dd4e671308fix: OpenCode 2 subagent tool set and in-process replace (#1348, #1347)#1348 (ADR-0016 l.23, D-SUB-NOCTX-1): the 2.x bridge now forwards the
event's agent. ctx.agent.get gives Agent.Info once per agent (cached); a
"subagent" mode agent gets agentId/agentType and the tools its permissions
leave on (core whollyDisabled rule), passed as the manifestTools source.
A subagent whose permissions deny every ctx_* tool now runs webfetch
instead of a deny that names tools it lacks.
#1347 (modules/12 §4.5 step 3, ADR-0016 l.49): opencode joins
REPLACE_ROWS (not DUMP_REPLACE_ROWS). encode returns the replace on
PostToolUse; the 2.x bridge writes it into result.content (output and
metadata stay), the 1.19 hook into output.output. The impl/10 §11 reason
"no replace field" came from the 1.19 shape and no longer holds.
Tests: 5 pinned tests moved from D to R for opencode (D-M7-RR-1), doctor
hook sample carries the output on a replace row.
Profile (median of 50, OpenCode 2 setup() hooks, before -> after):
- execute.before subagent webfetch: 0.061 ms -> 0.058 ms
- execute.after small result: 0.747 ms -> 0.50 ms
- execute.after 278 KB result: 0.882 ms -> 69 ms (now indexes and
replaces; before it passed 278889 bytes to the model)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

2be951c23792cfdcbd6243b51affe7ca08e85f2adocs: OpenCode subagent fields and replace channel, DEVIATIONS rows (#1348, #1347)D-R54-OC-AGENT-1 and D-R54-OC-REPLACE-1. modules/10 §11 now names the
2.x agent field and the mutable execute.after result; ADR-0020 opencode
row moves from D to R.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

ab0dcb0a0f6c9b2818963b3ff1f28513cb0d4d7dtest: real-host OpenCode 1.19 and 2.x replace of a large grep (#1347)Fire cases drive the real opencode binaries against a fake provider.
On c4c0f13e (no fix) both fail: the model gets the whole grep output.
On the fix both pass: the model gets the replace with the ctx_search line.
This is the gate the #1347 plan asked for before the row split.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

a75a6753c2a9f4f5adb89d3eaf53648aa48e7418test: red search.mjs line must not run $( ), backticks or $VAR from the intent (#1358, #1342)Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

d6e54c84456d723b04ee382911b007c949b29b73fix: quote the search.mjs line as POSIX single-quoted words (#1358, #1342)The twin line and the case B more: line used JSON.stringify, which is not a shell quote.
A $( ) or backtick in the intent ran again when the agent ran the line.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

81d4360f3857cc867fbaa5717aa4f64fbf009e56docs+test: ADR-0008 row 4 and the not-connected row name the search.mjs recovery; GP3 runs the printed line (#1358, #1342)Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

a4a318f4e255329ca3b89a69d1ce77d6da79c70atest: red Explore and Plan drop the Agent, Artifact and ExitPlanMode tools of the LV8 list (#1342)Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

6a001fe6e06d5458fac058de1101b734835657b2fix+docs: Explore/Plan deny list matches the 2.1.322 binary; DEVIATIONS D-CC-POINTER-5, bench replay and LV8 evidence (#1342, #1358)Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

4b6292d7bef6193ed4ed99a157a6e77f9db1949fmerge origin/main into lane/r54-cc-pointer (#1342, #1358)postReplace keeps the lane block and takes toolSetSources(ev, project, env) from
0fe650ee (#1348), so the OpenCode 2.x agentTools still reach the subagent tool set.
GP3 has one node:fs import. DEVIATIONS keeps both sides; D-CC-POINTER-1 names
OpenCode 2.x as a replace row this change affects.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

f0aa73bc456d73e6e2766c0e6bd9d73bd18a57a8docs: D-CC-POINTER-1 profile after the origin/main merge (#1342, #1358)Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

8e12296165e6c779b0bee7872ee77c58db6859cebench: count the search.mjs paths as fixed tokens, results.json from this build (D-CC-POINTER-6, #1358, #1342)Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

92c1ad26d57b45e786a3dc9149549c416badca09revert: lane r54-cc-pointer on main, Windows CI red (#1342, #1358)Reverts the tree changes of 4d45b836 921ba58c 17ea79e3 f0e952d6 a75a6753 d6e54c84
81d4360f a4a318f4 6a001fe6 f0aa73bc 8e122961 (pushed as ab0dcb0a..8e122961).
CI run 43100308997 failed on windows-latest (node 24.15.0 and 26):
- prd10-hooks-runtime.test.mjs:804 and :843 expect the 8.3 temp path
(RUNNER~1); the hook prints the long path (runneradmin).
- 0016-subagent.test.mjs:288 EPERM on the temp dir cleanup.
- 0018-build.test.mjs:1421 the printed search.mjs line is not runnable
through the Windows test runner (quoted path read as a module name).
The work stays on lane/r54-cc-pointer for a fix forward.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

d55bdb551cf46f337af038caf5bd7b992886cc58chore(release): v2.1.8
890a3f6b8015b0ca4ab5761db8335c02325b0470data: adoption history for 2026-11-12
f322c514557fd631c14fce455bc4dff66ea24939Revert "revert: lane r54-cc-pointer on main, Windows CI red (#1342, #1358)"This reverts commit 92c1ad26d57b45e786a3dc9149549c416badca09.

7828f882417e118b87ecce35205c611f53d904e1test: red a project dir alias makes the search.mjs twin expectation differ (#1342, #1358)windows-latest CI 43100308997: tests expect the 8.3 form (RUNNER~1) from realpathSync,
the hook prints the native long form (runneradmin) from resolve.ts realpathSync.native.
This host has no 8.3 names; a letter-case alias (REPO for repo) on the case-insensitive
APFS volume gives the same split: realpathSync keeps the alias, .native does not.
The new case uses the same expectation as D-CR3-HANDLE-1/2 (realpathSync), so it fails here
the way those two fail on windows-latest.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

e61c00cb65add7f06deb0c67f3a9f55b0821f5cefix: twin tests expect the native project dir; Windows-safe temp cleanup (#1342, #1358)D-CC-POINTER-7. The hook names the project dir from resolve.ts realpathSync.native (the long
Windows name, on-disk letter case). D-CR3-HANDLE-1/2 built the expected line with realpathSync,
which keeps an 8.3 alias (RUNNER~1) on windows-latest: CI 43100308997. Expected values now use
realpathSync.native. The ADR-0016 pointer suite cleans its temp dirs with tests/_lib/fs.mjs
rmTemp (EPERM on Windows while the detached index write holds context.db). Product code is
unchanged. 0018-build:1421 in that run is the todo Q-WIN-5 (known defect, not this lane).
Tests: prd10-hooks-runtime + 0016-subagent 369/369 pass; tsc --noEmit ok; build --generated-only ok.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

61280e8e77d8910e3d1779a725b0b1c5e0d5cdaadocs: DEVIATIONS D-CC-POINTER-7, Windows twin path tests (#1342, #1358)Hook profile, median of 50 paired runs (origin/main 890a3f6b -> lane e61c00cb):
mcpMain 92.6 -> 94.2 ms, subGP 99.5 -> 100.0 ms, subC 100.2 -> 101.5 ms. No regression.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

2a5d3bed7e4796fafc6dc40832511ebbd9a93e03test: red opencode 2 generate request misses the system payload (#1369)@opencode/core 2.2.6 SessionModelRequest sends the primary request through the
session hook "context" and session.generate (WarmingPlugin) through "generate".
setup(ctx) registers prompt,context,compaction only, so a generate request gets
1 system part (29 B) where the context request of the same session gets 2
(29+592 B): the warmed cache prefix is one the next turn never reads.
Red run on main 890a3f6b:
- tests/0021-cache-safety.test.mjs: setup(ctx) registers the session hook "generate"
- tests/0020-plugins.test.mjs: generate
- e2e GP2/opencode-generate-same-system: setup(ctx) registers the session hook generate
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

85a9431b87f7a2ecf6f49214d95b00b7c23ff057fix: opencode 2 generate request gets the same system payload as context (#1369)setup(ctx) now registers one named system handler on the session hooks
"context" and "generate". @opencode/core 2.2.6 sends session.generate
(WarmingPlugin cache warming) through "generate"; the payload is memoised per
session, so both requests carry the same bytes and the warmed prefix is the
one the next primary request reads. compaction and title stay as they are
(ADR-0021 rule 5; title has no agent or tools). setupLegacy (1.19, KiloCode)
does not change.
DEVIATIONS: D-R54-OC2-GENERATE-1 (ADR-0021 l.15-18, PRD.md l.270).
Archaeology: 2600c92b (D-OC2-SETUP-1) ported the 1.19 hooks one to one; the
2.x generate kind has no 1.19 match and no record chose to skip it.
Profile (built release-out/opencode/plugin.js, median of 50, 3 runs):
- generate hook: not registered before; 0.54 / 0.58 / 0.54 us after
- context hook: 0.67 / 0.67 / 0.63 us before; 0.67 / 0.63 / 0.67 us after
Green: tests/0021-cache-safety + tests/0020-plugins 93/93, e2e GP2 9/9,
tests/0014 + 0013 237/237, tsc --noEmit clean.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

1d8e2ab2ca61aa0bd4524ccb297f81b6915dcd07test: red hostBin runs the realpath, a mise shim loses argv[0] claude (#1335)A mise shim (shims/claude -> ../bin/mise) passes the native check, but setup
runs realpath(f), so mise sees argv[0] 'mise' and answers
'claude plugin marketplace add' with 'unrecognized subcommand'.
New case: [H8] hostBin #1335. Two H8 assertions now expect the PATH file.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

d798452e2e5be980ac031048fe6f225c4351cddefix: hostBin runs the PATH file that passed the check, not its realpath (#1335)The native/package check still reads realpath(f). The returned run path is f,
so a multi-call launcher (mise: shims/claude -> ../bin/mise) sees argv[0]
'claude'. Repro with the mise stand-in: marketplace add exits 0 through the
shim, row ends 'bin: .../fakemise/shims/claude' (was '.../bin/mise').
Tests: tests/0019-setup-engine.test.mjs 100 pass, 0 fail, 2 skipped.
tsc --noEmit: 0. build --generated-only: 0.
Profile hostBin('claude'), mise PATH, median of 50 (x100 calls each):
before 138.42 us (p95 162.42), after 141.05 us (p95 163.93), same within noise.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

7d18a0786a783eb09ae151607296dbd3cd67b28ftest: e2e setup claude-code via a mise-style symlink shim (#1335)Compiled argv[0]-dispatch stand-in (shims/claude -> ../bin/mise).
Without the fix (9bb6f669): FAIL 'claude plugin marketplace add ... exited 2:
error: unrecognized subcommand marketplace ... bin: .../mise/bin/mise
(rolled back)', the reporter's exact text. With the fix: PASS, setup and
doctor rows end 'bin: .../mise/shims/claude'.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

40ed0fbcc2619fcd16b361e7803bb7c72e36f747test: red, Node below 24.15 must not deny native tools on the 8 server hosts (#1370)The degraded server (PRD §13) lists ctx_doctor only, so the hook deny that
redirects to ctx_execute blocks the host. Red on main for claude-code, codex,
gemini, qwen, copilot-cli, vscode, kiro, zcode. Pi and OpenCode keep the deny:
their ctx_* tools register in-process with no version gate.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

f277c7bcc9be574333c97ee76887373f03428976fix: hook allows native tools on Node below 24.15 for the 8 server hosts (#1370)The MCP server runs on the same node and is degraded there (PRD §13:
ctx_doctor only), so the D-HNE-GUARD-1 redirect to ctx_execute blocked
the host. dispatch.ts now logs the NODE_TOO_OLD line (stderr and
hook-errors.log, D5 still shows it) and returns this host's allow reply.
Pi and OpenCode (installMode in-process) keep the deny: their ctx_*
tools register in the host with no version gate. Other stages unchanged.
E2E GP3/old-node-hook-allows: real Node 18.18.2, reporter payload, no
deny; server.mjs tools/list on the same node lists ctx_doctor only.
Profile (hook, Bash PreToolUse, median of 50, 3 warm-up runs):
Node 24.15.0 before 30.4 / 32.3 ms, after 32.7 ms (unchanged path, noise)
Node 18.18.2 before 37.4 / 38.8 ms (deny), after 40.0 ms (allow)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

3ed42c46a16649034809f32366b963e30b5c8768docs: DEVIATIONS row D-1370-OLDNODE-ALLOW-1 (#1370)Cites DEVIATIONS.md:104 (D-HNE-GUARD-1), PRD.md:284 (§13 degraded server),
fallback.ts:3 and 6de98259. Profile numbers in the row.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

189aaddd51c38c89fdd4480d3d7e51067b65775drefactor: failureOutput calls allowOutput directly (#1370)No behavior change. 105/105 hook-never-errors tests and the GP3 Node 18 e2e
stay green.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

a1ca27b7951cc1089bccc319529e8b86acc30ea4docs: DEVIATIONS row D-R54-CLAUDE-MISE-1, hostBin returns the PATH file (#1335)Cites #1335, ADR-0012:21, DEVIATIONS.md:602 (D-HF-CLAUDE-SHIM-1, text updated:
bin holds the PATH file that passed the check), archaeology 37fd45c8.
Profile hostBin median of 50: 138.42 us before, 141.05 us after.
Docs/hygiene tests: 0014, 0011, 0017, 0018, 0023 pass, 0 fail.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

39bbc4d5b1c83d8b87655472bf432eaebb2d0025test: H8 cli/doctor-bin expects the PATH file on the bin line (#1335)Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

ccc066a65aa5c4a9d676c17c86022ab56c744150test: red, findRuntime and doctor D11 read a Path-only env on Windows (#1371)Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

29fd99d9557d7cd324e7b4ee51460f92aafe4e95fix: read the PATH and PATHEXT keys without case on Windows, one envValue reader for findRuntime, D11, the doctor report and setup (#1371)OpenCode 2 runs the plugin in-process under Bun; Bun's process.env is case-sensitive on Windows and a process started
from PowerShell or cmd spells the key Path, so env.PATH was undefined: every ctx_execute language was NO_RUNTIME and
doctor D11 said Git Bash not found. POSIX keeps exact-case names.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

0f9dfc392540a468fddf6a202b98c2fac25df667docs: DEVIATIONS D-1371-PATH-CASE-1, impl/03 step 2 reads PATH without case on Windows (#1371)Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

9c0c8a6d580cf4a310ff2d3138ad3c24f6a1dcdetest: D1 git timeout test uses a 3000 ms limit so the local registry answers first (D-R55-D1-TIMEOUT-1)CI 43188103173 macos node 26: the 300 ms limit also cut the local
registry read on a loaded runner. Product code unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

edbebef22f63733c4dc61f3a45826cd481aa32c2chore(release): v2.1.9
7cf736524c2778a3d650f7ad8c98b500f1c1fd91test: red D5 scales the hook-cost bound with the node start, in-process hosts check shape only, env line names the host Bun (#1350)Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

16dac25e52101efdaa5b811747fe7390dbdc71f3fix(doctor): D5 bound scales with the node start, in-process hosts check shape only, env line names the host Bun (#1350)Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

a19421afa478334b723c37ee2465b8c765bd903fdocs: ADR-0010 D5 row and DEVIATIONS D-1350-D5-SCALE-1 (#1350)Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

acc539885e94e1224b555369a018fe5d950756f7refactor(doctor): D5 keeps the fastest bare start in one place, env line fits 80 columns (#1350)Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

877eebcc432f90882c2b5ea04ad22fc95e9dc6c2fix(doctor): env line names the PATH node for ctx_execute, PATH node version read beside the checks (#1350)On a Bun host (OpenCode 2, Pi) every hook runs in the host process, so the
PATH node runs ctx_execute javascript, not hooks. The line now says
"ctx_execute node vX (PATH)" or "ctx_execute node: none on PATH".
runtimeInfo is async (runProcess) and doctorReply starts it beside the
checks: ctx_doctor under bun with a 600 ms node start, median of 50,
1308.1 -> 670.2 ms. ADR-0010 D5 row: positive wording.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

4bffb4283bf2198b959062192882a8f33655c8d0chore(release): v2.1.10
e1c844abbf2aa15ba0ae798935dccc3cbd92006etest: red a PATH candidate stat cannot read is skipped, lookup failures are named, doctor names a missing runtime (#1373)
08bb798b59ca07e2d6a78584b0f5764b1d9f2a2dfix(sandbox): a PATH candidate stat cannot read is skipped, lookup failures are named, D11 names a language it cannot resolve (#1373)
065208062c58c154c884ed5df48ee5ece5083202docs: DEVIATIONS D-1373-STAT-1 and sandbox module error cases (#1373)
+12
View File
@@ -0,0 +1,12 @@
fix(sandbox): a PATH candidate stat cannot read is skipped, lookup failures are named, D11 names a language it cannot resolve (#1373)
fix: read the PATH and PATHEXT keys without case on Windows, one envValue reader for findRuntime, D11, the doctor report and setup (#1371)
fix+docs: Explore/Plan deny list matches the 2.1.322 binary; DEVIATIONS D-CC-POINTER-5, bench replay and LV8 evidence (#1342, #1358)
revert: lane r54-cc-pointer on main, Windows CI red (#1342, #1358)
Revert "revert: lane r54-cc-pointer on main, Windows CI red (#1342, #1358)"
feat(release): plan shows who gets each release; dry_run input (D-REL-WHO-1)
perf: keep own-dir root components, skip resolve for absolute POSIX paths (#1345)
test: red a PATH candidate stat cannot read is skipped, lookup failures are named, doctor names a missing runtime (#1373)
docs: DEVIATIONS D-1373-STAT-1 and sandbox module error cases (#1373)
chore(release): v2.1.10
data: adoption history for 2026-11-12
refactor(doctor): D5 keeps the fastest bare start in one place, env line fits 80 columns (#1350)
+97
View File
@@ -0,0 +1,97 @@
4bffb4283bf2198b959062192882a8f33655c8d0
877eebcc432f90882c2b5ea04ad22fc95e9dc6c2
acc539885e94e1224b555369a018fe5d950756f7
a19421afa478334b723c37ee2465b8c765bd903f
16dac25e52101efdaa5b811747fe7390dbdc71f3
7cf736524c2778a3d650f7ad8c98b500f1c1fd91
edbebef22f63733c4dc61f3a45826cd481aa32c2
9c0c8a6d580cf4a310ff2d3138ad3c24f6a1dcde
0f9dfc392540a468fddf6a202b98c2fac25df667
29fd99d9557d7cd324e7b4ee51460f92aafe4e95
ccc066a65aa5c4a9d676c17c86022ab56c744150
39bbc4d5b1c83d8b87655472bf432eaebb2d0025
a1ca27b7951cc1089bccc319529e8b86acc30ea4
189aaddd51c38c89fdd4480d3d7e51067b65775d
3ed42c46a16649034809f32366b963e30b5c8768
f277c7bcc9be574333c97ee76887373f03428976
40ed0fbcc2619fcd16b361e7803bb7c72e36f747
7d18a0786a783eb09ae151607296dbd3cd67b28f
d798452e2e5be980ac031048fe6f225c4351cdde
1d8e2ab2ca61aa0bd4524ccb297f81b6915dcd07
85a9431b87f7a2ecf6f49214d95b00b7c23ff057
2a5d3bed7e4796fafc6dc40832511ebbd9a93e03
61280e8e77d8910e3d1779a725b0b1c5e0d5cdaa
e61c00cb65add7f06deb0c67f3a9f55b0821f5ce
7828f882417e118b87ecce35205c611f53d904e1
f322c514557fd631c14fce455bc4dff66ea24939
890a3f6b8015b0ca4ab5761db8335c02325b0470
d55bdb551cf46f337af038caf5bd7b992886cc58
92c1ad26d57b45e786a3dc9149549c416badca09
8e12296165e6c779b0bee7872ee77c58db6859ce
f0aa73bc456d73e6e2766c0e6bd9d73bd18a57a8
4b6292d7bef6193ed4ed99a157a6e77f9db1949f
6a001fe6e06d5458fac058de1101b734835657b2
a4a318f4e255329ca3b89a69d1ce77d6da79c70a
81d4360f3857cc867fbaa5717aa4f64fbf009e56
d6e54c84456d723b04ee382911b007c949b29b73
a75a6753c2a9f4f5adb89d3eaf53648aa48e7418
ab0dcb0a0f6c9b2818963b3ff1f28513cb0d4d7d
2be951c23792cfdcbd6243b51affe7ca08e85f2a
0fe650eeb6c3e1c7a4fc5de97bbc75dd4e671308
4a50c4b0758208e38ca9fee82f8a88a6aebab31f
79fa820cc24c1bb93435619cf60bafae321b9173
f0e952d6351038975b879adab98e5f19a9735677
17ea79e3f0dfd0db939ab3c23822bd7598e1c37c
17f8ab11a6b10a4e5d86be2df303a622b5a25cfe
921ba58c6b969b02d667291e477a25940e67c356
fb04aed39bf22e593560e99f6d27f518415ed18e
64bd22cf09cc8a0025c4ce8260930ebeeae26693
e90d64be5c3c835ce52a64cf1257c6208a68663f
658e224824db0065e62f65147ab9f010cf519b94
a69161b458d683fe405667c824e3806e5e2aaa3a
8a50942a59c5a72b1bd2bcbe4184d74f28f32c79
8f5e533dac08fd2810e1a59d19835c750fc92f14
133c1b653e027719a4ec8be3b74015d3ed946d0b
011d86cda3ba47dc99c94d322570ca134a92705b
2da9830c33c8f95546d5ab8711202aa6937debd8
cdb1050134797bfff51e83782c4fec475beb343e
851300de48b9d70376e4bd66c3fb1cc3f2b5230d
29de2ee7fe0e6b3c1f60dbb4e5efa4518bf7b810
6bb2b778a6f068f6497ce62d01e4612e899ad62b
adab8b84670c9aecadaa10834ba821e4a1052a6b
0cabec3bd1e3b065ef1bdb7e561dca0d03970a7b
ebc4f3fd5a5bc79fdee3bcee000a002f99408436
92d4ea4e6416a2c91ec0d8c64f31e9937695ce29
2d29c780dd05384f21a0e3466945fe30bb527b6e
d7bef0931ff19c3e4a75261dbe07e7af85856fbb
9db3f80a061d2ea57eff93bef0758ef0d04fb440
ede6046cf78af999323d9c8304b6a33665021388
87d829a4015cc30d1dd8b13cb5c54ce4e358ce1b
4d45b836d62f33cd47e3d07d8e2e37f6059ece57
2407821cd1dfc4d75eb2d8a9b5d23f533ac2a52e
1f3e5a46db1fb64979e865d50bde9b5a20e38e3a
474468e1b50cfd35853f0c49a2dbe56361c6b638
5717cfb55ba7cc1442e08d2bf1803bb248c47209
84bc3bd42c49f380528decd2f3fde90f726538b9
e2e11f7179379cac3c44575c5ebbbd71ce125fa9
3d0fe344075ad4a35a326e88bffb2cf0a14bdb62
fb4d6a5aea84aeb00bc3d1053eae9ea0d8c9cda7
314ee9e19080a73c97c063c0afe67bf265680cbd
d9b5f00f1c6cd4f1fc2455496cee8ab899ac78ac
509d68837d1d01d1bc4068bb9c6961c5c7e2f772
6e8c89590cc40bffe0b2aed300584900326729bb
de5ed0c8cd94c69c5c4891fce6c3d148ffafca89
8100813c919c0d6fd9160e4c543991fe9ca2f149
3d845758f6aea56cbc6c32160f3f3dacc099b802
7961c51bc92a459ecd9f6f300189add2e3e827b8
548c305516a53d5fa2ec037744033fc5a6215c68
e3648b80873acfcdf978117cf90835d3f177b868
0af5f262f89eda9ad208d6829465b11979a69f91
f0ec05658ccacf111c51b5547e1f8dc1e7a320c0
d1ca9a21e0dffa6fb3ebf01f0194758e2262bee9
5172e15cf5af114245d82e91c2bdec3e638e0610
714a2fc3126ccf0f79dcce4881b641fe5041be20
35e2194fb7c55bc3202b69e65202e6db5887b18a
73632a808d45229494d0de290ee3d582ef46787e
cbd773279fe85fb9c91f4a12f02f50ae4a904d01
9ed3323cf7e034dfa94bc4ae92d2f1ca05adbf98
+177
View File
@@ -0,0 +1,177 @@
<!-- Title: ctx_doctor opencode: D5 hook round trip FAIL -->
### Summary
D5 hook round trip FAIL on opencode: hook round trip took 88 ms over bare node, over 40 ms
### ctx-report
```text
### Summary
D5 hook round trip FAIL on opencode: hook round trip took 98 ms over bare node, over 40 ms
### ctx-report
| Check | Status | Detail | Fix |
|---|---|---|---|
| D1 version | PASS | 2.1.7 (5539b63): latest latest on npm | |
| D2 node | PASS | running under Bun 1.4.4 | |
| D3 host config | PASS | ok | |
| D4 old entries | PASS | old context-mode temp file context-mode-* under the OS temp dir: report only, safe to keep | |
| D5 hook round trip | FAIL | hook round trip took 98 ms over bare node, over 40 ms | FAIL opencode: D5 — hook round trip took 98 ms over bare node, over 40 ms. Fix: run ctx_upgrade |
| D5b double-fire | PASS | ok | |
| D6 MCP | PASS | in-process plugin: this call ran inside the agent, no MCP session to read | |
| D7 project and worktree | PASS | ok | |
| D8 context.db | PASS | ok | |
| D9 index | PASS | 0 sources, 0 chunks indexed | |
| D10 enforcement mode | PASS | enforcement mode: deny-reason; OpenCode permission rules apply to ctx_* tools | |
| D11 shell | PASS | Git Bash: C:\Program Files\Git\bin\bash.exe | |
Run in a terminal: context-mode setup --agents opencode
### What happened
Rows that need a look:
- D5 hook round trip FAIL: hook round trip took 98 ms over bare node, over 40 ms (Fix: run ctx_upgrade)
Error code and text: <the agent fills this in: the exact error the user saw>
### Hook errors
hook-errors.log, last 50 lines (UTC):
(~/.context-mode/hook-errors.log holds zero lines)
### Journal rows
events, newest first, last 30 (bodies stay local):
| kind | tool | bytes | ok | exit_code | created_at |
|---|---|---|---|---|---|
| cmd | ctx_upgrade | 0 | 1 | | 2026-11-09T08:45:55.360Z |
| cost | | 0 | 1 | | 2026-11-09T08:45:52.651Z |
| cmd | ctx_doctor | 1886 | 1 | | 2026-11-09T08:45:52.572Z |
| prompt | | 12 | 1 | | 2026-11-09T08:45:34.877Z |
| prompt | | 12 | 1 | | 2026-11-09T08:44:14.606Z |
### Agent config
MCP entry: ~/.config/opencode/opencode.json (1 matching lines)
"context-mode"
### Expected
Expected: D5 hook round trip completes under 40 ms over bare node, all doctor checks PASS after running the suggested fix (ctx_upgrade).
### Steps
Reproduced: yes (2 of 2)
Prompt or command: `ctx_doctor({})` — called via MCP tool from opencode agent
Actual: ctx_doctor returned a 1886-byte report table with D5 FAIL both times: hook round trip took 88 ms, then 98 ms over bare node (threshold 40 ms). Ran ctx_upgrade as suggested (plugin root rewritten, restart requested) — re-check still FAILs at 98 ms. Full report: doctor-2026-11-09T08-46-15-145Z.md (3347 bytes), attached below.
Repro script:
export HOME="$(mktemp -d)"
cd "$HOME"
opencode plugin add context-mode
ctx_doctor
### Environment
Environment: context-mode 2.1.7 (5539b63), agent opencode
Environment: win32-x64, Node v26.3.0, shell C:\WINDOWS\system32\cmd.exe
context-mode bundle: ~/.cache/opencode/npm/context-mode@latest/1794213196034/node_modules/context-mode
Install route: opencode plugin add context-mode
git: git version 2.51.0.windows.1
PATH holds node: C:\Program Files\nodejs\node.exe
PATH holds git: C:\Program Files\Git\cmd\git.exe, C:\Program Files\Git\cmd\git.exe
PATH holds sh: (absent)
CODEX_HOME=~/.codex-corp/codex-config
CLAUDE_CONFIG_DIR=~/.claude-corp/claude-config
CLAUDE_PLUGIN_ROOT (unset)
COPILOT_HOME (unset)
KIRO_HOME (unset)
OPENCODE_CONFIG_DIR (unset)
PI_CODING_AGENT_DIR (unset)
XDG_CONFIG_HOME (unset)
SHELL (unset)
Project: D:\DESKTOP_Shortcuts\IS_VE_BEN\ONENT_GENEL\ONENT_CODEBASE\ONENT_PLANLAMA (key c2732c7a98bef829)
Filed by: opencode agent, context-mode 2.1.7 (5539b63), model claude-sonnet-5-5 (omniroute)
```
### What happened
`ctx_doctor` on opencode reports D5 hook round trip FAIL, twice in a row:
- Run 1: `hook round trip took 88 ms over bare node, over 40 ms`
- Run 2 (after ctx_upgrade, still 2.1.7): `hook round trip took 98 ms over bare node, over 40 ms`
Exact command:
```
ctx_doctor({})
```
Exact output (D5 row):
```
| D5 hook round trip | FAIL | hook round trip took 98 ms over bare node, over 40 ms | FAIL opencode: D5 — hook round trip took 98 ms over bare node, over 40 ms. Fix: run ctx_upgrade |
```
Fix suggested by the tool (`ctx_upgrade`) was run — plugin root changed, restart requested, but D5 still FAILs on re-check. All other checks pass (D1–D11 except D5).
Cause not found in source; report file attached below.
### Hook errors
```
(~/.context-mode/hook-errors.log does not exist — zero lines, ENOENT)
```
### Journal rows
events, newest first, last 30 (bodies stay local):
| kind | tool | bytes | ok | exit_code | created_at |
|---|---|---|---|---|---|
| cmd | ctx_upgrade | 0 | 1 | | 2026-11-09T08:45:55.360Z |
| cost | | 0 | 1 | | 2026-11-09T08:45:52.651Z |
| cmd | ctx_doctor | 1886 | 1 | | 2026-11-09T08:45:52.572Z |
| prompt | | 12 | 1 | | 2026-11-09T08:45:34.877Z |
| prompt | | 12 | 1 | | 2026-11-09T08:44:14.606Z |
### Agent config
MCP entry: ~/.config/opencode/opencode.json (1 matching lines)
"context-mode"
### Expected
D5 hook round trip completes under 40 ms over bare node; all doctor checks PASS after the suggested fix (ctx_upgrade) is applied.
### Steps
1. Fresh project, opencode + context-mode installed via `opencode plugin add context-mode`.
2. Run: `ctx_doctor({})` (MCP tool call from opencode agent)
3. Actual: report table returned (1886 bytes) with D5 FAIL — `hook round trip took 88 ms over bare node, over 40 ms`
4. Ran suggested fix: `ctx_upgrade({mode: "upgrade"})` — plugin root rewritten, restart requested. Version unchanged (2.1.7, already latest).
5. Re-ran `ctx_doctor({})` — D5 still FAIL: `hook round trip took 98 ms over bare node, over 40 ms`. All other checks PASS. Full report (3347 bytes) attached below.
### Environment
Environment: context-mode 2.1.7 (5539b63), agent opencode
Environment: win32-x64, Node v26.3.0, shell C:\WINDOWS\system32\cmd.exe
context-mode bundle: ~/.cache/opencode/npm/context-mode@latest/1794213196034/node_modules/context-mode
Install route: opencode plugin add context-mode
git: git version 2.51.0.windows.1
PATH holds node: C:\Program Files\nodejs\node.exe
PATH holds git: C:\Program Files\Git\cmd\git.exe, C:\Program Files\Git\cmd\git.exe
PATH holds sh: (absent)
CODEX_HOME=~/.codex-corp/codex-config
CLAUDE_CONFIG_DIR=~/.claude-corp/claude-config
CLAUDE_PLUGIN_ROOT (unset)
COPILOT_HOME (unset)
KIRO_HOME (unset)
OPENCODE_CONFIG_DIR (unset)
PI_CODING_AGENT_DIR (unset)
XDG_CONFIG_HOME (unset)
SHELL (unset)
Project: D:\DESKTOP_Shortcuts\IS_VE_BEN\ONENT_GENEL\ONENT_CODEBASE\ONENT_PLANLAMA (key c2732c7a98bef829)
Filed by: opencode agent, context-mode 2.1.7 (5539b63), model claude-sonnet-5-5 (omniroute)
+179
View File
@@ -0,0 +1,179 @@
<!-- Title: Windows/OpenCode: findRuntime reads only env.PATH (no env.Path fallback) — D11 "Git Bash not found" and every ctx_execute language fails when the env block spells it "Path" -->
### Summary
D11 shell FAIL ("Git Bash not found") plus NO_RUNTIME for every ctx_execute language on win32 OpenCode: findRuntime() reads only `env.PATH`, but OpenCode's embedded Bun runtime has a case-sensitive process.env and the Windows env block spells the variable `Path`.
### ctx-report
```text
Environment: context-mode 2.1.8 (92c1ad2), agent opencode
Environment: win32-x64, Node v26.3.0, shell C:\windows\system32\cmd.exe
| Check | Status | Detail | Fix |
|---|---|---|---|
| D1 version | PASS | 2.1.8 (92c1ad2): latest latest on npm | |
| D2 node | PASS | running under Bun 1.4.4 | |
| D3 host config | FAIL | wrong: MCP entry | FAIL opencode: D3 — wrong: MCP entry. Fix: context-mode setup --agents opencode |
| D4 old entries | WARN | old context-mode OpenCode plugin spec context-mode; old context-mode temp file context-mode-* under the OS temp dir: report only, safe to keep | Fix: run ctx_upgrade |
| D5 hook round trip | PASS | ok; past hook error 2026-11-12T06:48:36.035Z at node (NODE_TOO_OLD), before this run, stack in hook-errors.log | |
| D5b double-fire | PASS | ok | |
| D6 MCP | PASS | in-process plugin: this call ran inside the agent, no MCP session to read | |
| D7 project and worktree | PASS | ok | |
| D8 context.db | PASS | ok | |
| D9 index | PASS | 4 sources, 413 chunks indexed | |
| D10 enforcement mode | PASS | enforcement mode: deny-reason; OpenCode permission rules apply to ctx_* tools | |
| D11 shell | FAIL | Git Bash not found | FAIL opencode: D11 — Git Bash not found. Fix: install Git for Windows |
Run in a terminal: context-mode setup --agents opencode
Note: the D3/D4 rows are a separate, already-reported concern (legacy bare `context-mode` plugin spec, see #1339 / #1344). This issue is only about D11 and the sandbox NO_RUNTIME failures.
```
### What happened
Git for Windows IS installed (`C:\Program Files\Git\bin\bash.exe` exists, git 2.54.0.windows.1), Node v24.22.3 and PowerShell 5.1 are installed and resolve in the same terminal. Yet:
```text
ctx_execute({language:"javascript", code:"..."})
→ No javascript runtime on PATH. Fix: install it or pick another language.
ctx_execute({language:"powershell", code:"..."})
→ No powershell runtime on PATH. Fix: install it or pick another language.
ctx_doctor → D11 shell | FAIL | Git Bash not found
```
Root cause — `src/core/sandbox/runtimes.ts` (line numbers from the bundled `opencode/plugin.js` of 2.1.8):
```js
// findRuntime, bundled line 20735 — no env.Path fallback:
const dirs = pathEntries(env.PATH ?? "", process.platform, path.delimiter);
// findGitBash, bundled lines 20751-20758 — depends on findRuntime:
const git2 = findRuntime(GIT_BIN, env); // null → D11 "Git Bash not found"
```
The doctor's own probe in the same file DOES have the fallback and works:
```js
// onPath, bundled line 27870:
for (const dir of (env.PATH ?? env.Path ?? "").split(delimiter)) {
```
Same env object, two results: the report's Environment section (produced by onPath) lists
`PATH holds node: C:\Program Files\nodejs\node.exe` and `PATH holds git: C:\Program Files\Git\cmd\git.exe`,
while findRuntime sees an empty PATH. The only difference is the `?? env.Path` fallback.
Why `env.PATH` is undefined: OpenCode 1.19.5 runs plugins in-process under Bun 1.4.4 (D2 row). Bun's process.env is case-sensitive on Windows (Node.js's is case-insensitive). A process launched from PowerShell / cmd / VS Code integrated terminal inherits the Windows-default spelling `Path` — verified by enumerating the environment of a child process of opencode.exe: the key is `Path`, not `PATH`. So `env.PATH` → undefined, `env.Path` → the full path.
Control experiments (all verified on this machine):
1. Launch opencode from Git Bash instead (MSYS normalizes env names to uppercase): node spawned via Git Bash enumerates the key as `PATH`. This matches #1309's ctx-report (win32-x64, same Bun 1.4.4) which shows `D11 shell | PASS | Git Bash: C:\Program Files\Git\bin\bash.exe`.
2. Normalize the casing before launch, then D11's detection path works:
```powershell
$p = [Environment]::GetEnvironmentVariable('Path','Process')
[Environment]::SetEnvironmentVariable('Path',$null,'Process')
[Environment]::SetEnvironmentVariable('PATH',$p,'Process')
opencode
```
Impact: the entire sandbox surface (ctx_execute, ctx_execute_file, ctx_batch_execute) is unusable for ALL languages on any Windows OpenCode install launched from a native Windows shell — the common case. D11's fix advice ("install Git for Windows") is misleading because Git is already installed.
Suggested fix (one line, align findRuntime with onPath):
```js
const dirs = pathEntries(env.PATH ?? env.Path ?? "", process.platform, path.delimiter);
```
or resolve the PATH key case-insensitively on win32 (match /^path$/i). Please also audit other direct `env.PATH` reads.
### Hook errors
hook-errors.log last 50 lines are all the same NODE_TOO_OLD entry (Node v24.3.0) from before the Node upgrade to v24.22.3 — unrelated to this bug. Representative entries (UTC, stacks trimmed, home masked):
```json
{"ts":"2026-11-12T06:43:24.853Z","agent":"opencode","stage":"node","label":"NODE_TOO_OLD","message":"Context Mode needs Node 24.15.0 or newer; you have v24.3.0. Fix: nvm install 24, or install it from https://nodejs.org.","stack":"Error: ... at pu (~/AppData/Roaming/npm/node_modules/context-mode/hook.mjs:215:58) at mE (~/AppData/Roaming/npm/node_modules/context-mode/hook.mjs:225:352)"}
{"ts":"2026-11-12T06:43:25.923Z","agent":"opencode","stage":"node","label":"NODE_TOO_OLD","message":"Context Mode needs Node 24.15.0 or newer; you have v24.3.0. ...","stack":"Error: ... at handleHook (~/AppData/Roaming/npm/node_modules/context-mode/opencode/plugin.js:9049:61)"}
{"ts":"2026-11-12T06:48:36.035Z","agent":"opencode","stage":"node","label":"NODE_TOO_OLD","message":"Context Mode needs Node 24.15.0 or newer; you have v24.3.0. ...","stack":"Error: ... at handleHook (~/AppData/Roaming/npm/node_modules/context-mode/opencode/plugin.js:9049:61) ... at B:/~BUN/root/chunk-1bdwc54v.js:439:29549 ..."}
```
Full 50-line log available at ~/.context-mode/hook-errors.log.
### Journal rows
events, newest first, last 30 (bodies stay local):
| kind | tool | bytes | ok | exit_code | created_at |
|---|---|---|---|---|---|
| prompt | | 499 | 1 | | 2026-11-12T07:21:00.007Z |
| prompt | | 33 | 1 | | 2026-11-12T07:20:48.642Z |
| cmd | Bash | 604 | 1 | | 2026-11-12T07:20:31.504Z |
| cmd | Bash | 2253 | 1 | | 2026-11-12T07:19:21.489Z |
| cost | | 0 | 1 | | 2026-11-12T07:18:47.269Z |
| prompt | | 119 | 1 | | 2026-11-12T07:18:38.363Z |
| cmd | Bash | 698 | 1 | | 2026-11-12T07:18:36.809Z |
| cmd | Bash | 18142 | 1 | | 2026-11-12T07:18:03.972Z |
| prompt | | 499 | 1 | | 2026-11-12T07:17:56.640Z |
| cmd | Bash | 1367 | 1 | | 2026-11-12T07:17:35.602Z |
| prompt | | 499 | 1 | | 2026-11-12T07:16:27.124Z |
| prompt | | 9 | 1 | | 2026-11-12T07:16:22.094Z |
| cmd | Bash | 347 | 1 | | 2026-11-12T07:15:09.677Z |
| cmd | Bash | 1345 | 1 | | 2026-11-12T07:14:59.419Z |
| cmd | Bash | 12 | 1 | | 2026-11-12T07:14:56.117Z |
| cmd | Bash | 544 | 1 | | 2026-11-12T07:14:42.874Z |
| cmd | Bash | 1499 | 1 | | 2026-11-12T07:14:34.980Z |
| cost | | 0 | 1 | | 2026-11-12T07:14:17.218Z |
| cmd | Bash | 298 | 1 | | 2026-11-12T07:14:15.612Z |
| cmd | Bash | 2402 | 1 | | 2026-11-12T07:13:59.851Z |
| prompt | | 65 | 1 | | 2026-11-12T07:13:11.638Z |
| cmd | Bash | 25 | 1 | | 2026-11-12T07:12:35.119Z |
| cmd | Bash | 3538 | 1 | | 2026-11-12T07:12:03.645Z |
| cmd | Bash | 54 | 1 | | 2026-11-12T07:11:17.703Z |
| cmd | Bash | 10178 | 1 | | 2026-11-12T07:10:50.266Z |
| cmd | Bash | 3246 | 1 | | 2026-11-12T07:10:24.353Z |
| cmd | Bash | 81 | 1 | | 2026-11-12T07:10:22.218Z |
| cost | | 0 | 1 | | 2026-11-12T07:09:44.146Z |
| prompt | | 60 | 1 | | 2026-11-12T07:09:28.502Z |
| cmd | Bash | 516 | 1 | | 2026-11-12T07:07:17.353Z |
### Agent config
~/.config/opencode/opencode.jsonc at the time of the doctor run (no secrets in these entries):
```jsonc
"plugin": [
"oh-my-opencode-slim@v3.0.7",
"context-mode"
]
```
No context-mode MCP entry (in-process plugin, D6 PASS). Plugin root: ~/.cache/opencode/packages/context-mode@latest/node_modules/context-mode. After diagnosis the user pinned context-mode@1.0.169 (v1) as a workaround; this report concerns 2.1.8.
### Expected
- D11 PASS with detail `Git Bash: C:\Program Files\Git\bin\bash.exe`.
- `ctx_execute({language:"javascript", code:"console.log(1)"})` returns `1\n` (2 B) instead of the NO_RUNTIME error.
- Runtime resolution on Windows must not depend on the casing of the PATH environment variable name.
### Steps
1. Windows 10/11 x64. Install Git for Windows (default location), Node 24, and OpenCode: `npm i -g opencode-ai`.
2. Fresh project: `mkdir fresh && cd fresh && git init`.
3. `opencode plugin add context-mode` (resolves 2.1.8).
4. Launch `opencode` from PowerShell or the VS Code integrated terminal (NOT Git Bash). The process env block spells the path variable `Path`.
5. Call ctx_doctor → `D11 shell | FAIL | Git Bash not found`, while the report's Environment section lists `PATH holds node: C:\Program Files\nodejs\node.exe` and `PATH holds git: C:\Program Files\Git\cmd\git.exe`.
6. Call ctx_execute with language javascript (or powershell) → `No javascript runtime on PATH` / `No powershell runtime on PATH`, although both resolve in the same terminal.
7. Control: exit, launch `opencode` from Git Bash → D11 PASS and ctx_execute works.
### Environment
- context-mode 2.1.8 (92c1ad2); install route: opencode plugin add context-mode (in-process plugin)
- Agent: OpenCode 1.19.5 (npm opencode-ai); plugins run under embedded Bun 1.4.4
- OS: Windows 10 x64 (build 18362), win32-x64
- Node: v24.22.3 installed at C:\Program Files\nodejs\node.exe; doctor prints "Node v26.3.0" (Bun's compat version)
- Launch shell: PowerShell 5.1 (VS Code integrated terminal); doctor detects shell C:\windows\system32\cmd.exe
- git 2.54.0.windows.1 at C:\Program Files\Git\cmd\git.exe; Git Bash exists at C:\Program Files\Git\bin\bash.exe
- Env var spelling: `Path` (verified in a child process of opencode.exe); `env.PATH` is undefined under Bun
- PATH holds node: C:\Program Files\nodejs\node.exe; PATH holds git: C:\Program Files\Git\cmd\git.exe (via onPath's env.Path fallback)
- Filed by: user via OpenCode agent
+94
View File
@@ -0,0 +1,94 @@
<!-- Title: [Bug]: ctx_execute with language: "python" returns "Internal error" on Windows when the Microsoft Store python alias is first on PATH (statSync throws EACCES) -->
### Did you run `/ctx-doctor`?
Yes
### Paste the full ctx_doctor report here
```text
Environment: context-mode 2.1.9 (9c0c8a6), agent claude-code
Environment: win32-x64, Node v24.22.1, shell C:\Program Files\Git\bin\bash.exe
| Check | Status | Detail | Fix |
|---|---|---|---|
| D1 version | PASS | 2.1.9 (9c0c8a6): latest latest on npm | |
| D2 node | PASS | ok | |
| D3 host config | PASS | ok | |
| D4 old entries | PASS | ok | |
| D5 hook round trip | PASS | ok | |
| D5b double-fire | PASS | ok | |
| D6 MCP | PASS | ok | |
| D7 project and worktree | PASS | ok | |
| D8 context.db | PASS | ok | |
| D9 index | PASS | 67 sources, 6796 chunks indexed | |
| D10 enforcement mode | PASS | enforcement mode: deny-reason | |
| D11 shell | PASS | Git Bash: C:\Program Files\Git\bin\bash.exe | |
```
All rows PASS: the doctor never runs a Python script, so it does not see this bug.
### Node version
v24.22.1
### What happened
On Windows 11, `ctx_execute` with `language: "python"` always returns `Internal error. Fix: run ctx_doctor.`, while `shell`, `javascript` and `powershell` work.
Versions:
- context-mode 2.1.9 (9c0c8a6)
- Claude Code 2.1.322
- Windows_NT 10.0.26300 x64
- Node v24.22.1
- Shell: Git Bash
- Python (real install): 3.14.3
**Cause** (in the 2.1.9 `server.mjs` bundle; sources `src/core/sandbox/runtimes.ts` and `src/core/tools/execute.ts`):
- `server.mjs:44237`: for `python` on Windows the candidates are `python.exe`, `py.exe`, `python`.
- `server.mjs:44247`: `isRunnable()` calls `statSync(full, { throwIfNoEntry: false })` on every PATH candidate. The first `python.exe` on PATH is the Microsoft Store app-execution alias `%LOCALAPPDATA%\Microsoft\WindowsApps\python.exe`. Node cannot stat it:
```text
EACCES: permission denied, stat '%LOCALAPPDATA%\Microsoft\WindowsApps\python.exe'
```
- `throwIfNoEntry: false` only suppresses ENOENT, so EACCES propagates out of `findRuntime`.
- `server.mjs:53018`: `handler3` calls `findRuntime(input.language)` outside its `try`, so the raw error is not a `CtxError` and `errorReply` turns it into the generic internal-error line.
- The real interpreter (`%LOCALAPPDATA%\Python\bin\python.exe`) is later in PATH and works when spawned from Node (status 0).
### Expected
A `statSync` error (EACCES/EPERM/UNKNOWN) on a PATH candidate should mean "not runnable": continue with the next PATH entry, or return `NO_RUNTIME`. That is what #457 and #462 intended for the Store stubs.
**Confirmed workaround:** after disabling the `python.exe`, `python3.exe` and `py.exe` app execution aliases (Settings > Apps > Advanced app settings > App execution aliases), the same call returns `hola` with no other change. This confirms the failure comes from the Store alias in PATH, not from the real Python install or the Node version.
### Steps
1. On Windows with the Store `python.exe` alias enabled and ahead of the real Python on PATH (`where python` lists `...\WindowsApps\python.exe` first).
2. `mkdir %TEMP%\ctx-repro && cd %TEMP%\ctx-repro`
3. Install the plugin: `claude plugin marketplace add mksglu/context-mode` then `claude plugin install context-mode@context-mode`.
4. Start `claude` in that directory.
5. Call the tool:
```text
ctx_execute({ "language": "python", "code": "print(\"hola\")" })
```
6. Observed output, copied unchanged:
```text
Internal error. Fix: run ctx_doctor.
```
7. Disable the Store aliases, restart Claude Code, repeat step 5. Output:
```text
hola
```
### Checks
- [x] I ran `/ctx-doctor` or asked the agent to call the `ctx_doctor` tool
- [x] I am an AI agent filing this on behalf of a user, or I pasted the full agent transcript