@vectorize-io/hindsight-coding-agents 0.8.4 → 0.8.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -12
- package/dist/antigravity-hook.js +1 -1
- package/dist/antigravity-statusline.js +1 -1
- package/dist/antigravity-stop-hook.js +1 -1
- package/dist/claude-hook.js +1 -1
- package/dist/claude-sessionstart-hook.js +85 -88
- package/dist/claude-stop-hook.js +1 -1
- package/dist/cline.js +86 -89
- package/dist/codebuddy-hook.js +1 -1
- package/dist/codebuddy-sessionstart-hook.js +85 -88
- package/dist/codebuddy-stop-hook.js +1 -1
- package/dist/codex-hook.js +1 -1
- package/dist/codex-sessionstart-hook.js +85 -88
- package/dist/codex-stop-hook.js +1 -1
- package/dist/copilot-hook.js +1 -1
- package/dist/copilot-sessionstart-hook.js +85 -88
- package/dist/copilot-stop-hook.js +1 -1
- package/dist/cursor-hook.js +1 -1
- package/dist/cursor-sessionstart-hook.js +85 -88
- package/dist/cursor-stop-hook.js +1 -1
- package/dist/daemon-start.js +1 -1
- package/dist/dcode-hook.js +1 -1
- package/dist/dcode-sessionstart-hook.js +85 -88
- package/dist/dcode-stop-hook.js +1 -1
- package/dist/deepen.js +1 -1
- package/dist/devin-hook.js +1 -1
- package/dist/devin-sessionstart-hook.js +85 -88
- package/dist/devin-stop-hook.js +1 -1
- package/dist/droid-hook.js +1 -1
- package/dist/droid-sessionstart-hook.js +85 -88
- package/dist/droid-stop-hook.js +1 -1
- package/dist/dsh.js +86 -89
- package/dist/grok-hook.js +1 -1
- package/dist/grok-sessionstart-hook.js +85 -88
- package/dist/grok-stop-hook.js +1 -1
- package/dist/hindsight-seed.js +1 -1
- package/dist/index.js +86 -89
- package/dist/installer.js +1 -1
- package/dist/kilo.js +86 -89
- package/dist/kimi-hook.js +1 -1
- package/dist/kimi-sessionstart-hook.js +85 -88
- package/dist/kimi-stop-hook.js +1 -1
- package/dist/mcp-server.js +1 -1
- package/dist/opencode2.js +86 -89
- package/dist/pi.js +86 -89
- package/dist/prime-agent.js +86 -89
- package/dist/qwen-hook.js +1 -1
- package/dist/qwen-sessionstart-hook.js +85 -88
- package/dist/qwen-stop-hook.js +1 -1
- package/dist/status.js +1 -1
- package/dist/traecode-hook.js +1 -1
- package/dist/traecode-sessionstart-hook.js +85 -88
- package/dist/traecode-stop-hook.js +1 -1
- package/dist/workbuddy-hook.js +1 -1
- package/dist/workbuddy-sessionstart-hook.js +85 -88
- package/dist/workbuddy-stop-hook.js +1 -1
- package/dist/zcode-hook.js +1 -1
- package/dist/zcode-sessionstart-hook.js +85 -88
- package/dist/zcode-stop-hook.js +1 -1
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/skill/SKILL.md +3 -3
package/README.md
CHANGED
|
@@ -109,9 +109,9 @@ Dcode namespaces a plugin's MCP tools, so they appear as
|
|
|
109
109
|
them from the tool guide either way. In headless runs (`dcode -n`) Dcode allows the read-only
|
|
110
110
|
Hindsight tools and gates the two that write (`hindsight_ingest_document`,
|
|
111
111
|
`hindsight_capture_initiative`) behind an approval it has no UI for; use the interactive TUI to
|
|
112
|
-
capture an initiative or ingest a document. For the same reason
|
|
113
|
-
under
|
|
114
|
-
|
|
112
|
+
capture an initiative or ingest a document. For the same reason Dcode gets no one-time codebase
|
|
113
|
+
survey: the survey runs only under the current agent's own CLI, and only Claude Code, Codex,
|
|
114
|
+
Antigravity and opencode v1 have a headless, read-only recipe for it.
|
|
115
115
|
|
|
116
116
|
#### <img src="https://hindsight.vectorize.io/img/harness/opencode.png" alt="" width="20" height="20" /> opencode
|
|
117
117
|
|
|
@@ -133,12 +133,13 @@ rewrote the plugin API, so it is a harness of its own. It writes the same plugin
|
|
|
133
133
|
if it sees v2's `plugins` key — and each CLI then loads its own entry point from the one registered
|
|
134
134
|
path. So installing either harness wires both, and uninstalling either removes the shared entry.
|
|
135
135
|
|
|
136
|
-
Two differences from v1, both because of the host:
|
|
137
|
-
|
|
138
|
-
banner is written to the plugin log instead of a TUI toast (v2 plugins cannot
|
|
139
|
-
injection, the native `hindsight_*` tools and session write-back are identical.
|
|
140
|
-
is identical too, but it is registered in memory through v2's skill API rather
|
|
141
|
-
skills directory — opencode2 has none of its own, and the two it reads belong to
|
|
136
|
+
Two differences from v1, both because of the host: there is no one-time codebase survey (v2 plugins
|
|
137
|
+
cannot define the read-only agent the survey needs, and the survey never borrows another agent's
|
|
138
|
+
CLI), and the seed banner is written to the plugin log instead of a TUI toast (v2 plugins cannot
|
|
139
|
+
raise one). Recall, injection, the native `hindsight_*` tools and session write-back are identical.
|
|
140
|
+
The companion skill is identical too, but it is registered in memory through v2's skill API rather
|
|
141
|
+
than copied into a skills directory — opencode2 has none of its own, and the two it reads belong to
|
|
142
|
+
other agents.
|
|
142
143
|
|
|
143
144
|
#### <img src="https://hindsight.vectorize.io/img/harness/kilo.svg" alt="" width="20" height="20" /> Kilo CLI
|
|
144
145
|
|
|
@@ -678,7 +679,7 @@ hook by Codex...), so one shared config serves several agents side by side:
|
|
|
678
679
|
| `customPages` | — | knowledge pages of your own, seeded alongside the five above and keyed by the name they get: `{"Security posture": {"source_query": "...", "tags": ["knowledge:decision"]}}`. `source_query` is required; `tags` picks which facts feed the page and is optional — omitted, the page draws on everything the bank holds. A separate setting from `pages` on purpose, so that an unknown name there stays a typo warning rather than quietly creating a page. File-only, and replaced (not merged) by a `banks.<id>` section |
|
|
679
680
|
| `autoSeed` | `true` | SessionStart: auto-seed a cold repo's bank from git history |
|
|
680
681
|
| `seedLimit` | `300` | git-log document size: a full write keeps the newest commits, between half of this and this many (the window moves in steps of half), and logs how many older ones it drops |
|
|
681
|
-
| `codebaseSurvey` | `true` | SessionStart: headless survey of a cold repo's structure, run under the current harness's own CLI (
|
|
682
|
+
| `codebaseSurvey` | `true` | SessionStart: headless survey of a cold repo's structure, run only under the current harness's own CLI (Claude Code, Codex, Antigravity, opencode v1); other agents get no survey |
|
|
682
683
|
| `surveyModel` | `haiku` | model for the survey — Claude recipe only (`claude -p --model`); other agents use their configured default |
|
|
683
684
|
| `surveyBudgetUsd` | `2` | survey spend cap — Claude recipe only (`claude -p --max-budget-usd`); other agents rely on their read-only sandbox |
|
|
684
685
|
| `surveyRefreshCommits` | `20` | re-run the survey at SessionStart once this many commits have accrued since the last one, so the structural pages track an architecture that keeps moving (`0` = survey a cold repo only, never again) |
|
|
@@ -1204,8 +1205,8 @@ that: `"synced": true` means the seeded memory is queryable. It also reports git
|
|
|
1204
1205
|
far per-commit deepening has got, the codebase survey's state (`surveyBaseline` is the HEAD the last
|
|
1205
1206
|
survey started from, `surveyDocs` counts the findings documents that have landed, 0–4 — a baseline
|
|
1206
1207
|
with no findings retries automatically, at most three times per commit), and the extraction
|
|
1207
|
-
operations still in flight.
|
|
1208
|
-
with an error leaves one `[survey]` line in the plugin log.
|
|
1208
|
+
operations still in flight. A survey that was skipped (no survey for this agent, or its CLI not
|
|
1209
|
+
found), failed to launch or exited with an error leaves one `[survey]` line in the plugin log.
|
|
1209
1210
|
|
|
1210
1211
|
### Resetting a repo's memory
|
|
1211
1212
|
|
package/dist/antigravity-hook.js
CHANGED
|
@@ -657,7 +657,7 @@ function codingBankManifest(overrides, mode = DEFAULT_RETAIN_EXTRACTION_MODE, de
|
|
|
657
657
|
}
|
|
658
658
|
|
|
659
659
|
// package.json
|
|
660
|
-
var version = "0.8.
|
|
660
|
+
var version = "0.8.6";
|
|
661
661
|
|
|
662
662
|
// src/core/util.ts
|
|
663
663
|
import { accessSync, constants, statSync as statSync2 } from "fs";
|
|
@@ -633,7 +633,7 @@ function codingBankManifest(overrides, mode = DEFAULT_RETAIN_EXTRACTION_MODE, de
|
|
|
633
633
|
}
|
|
634
634
|
|
|
635
635
|
// package.json
|
|
636
|
-
var version = "0.8.
|
|
636
|
+
var version = "0.8.6";
|
|
637
637
|
|
|
638
638
|
// src/core/util.ts
|
|
639
639
|
import { accessSync, constants, statSync as statSync2 } from "fs";
|
package/dist/claude-hook.js
CHANGED
|
@@ -657,7 +657,7 @@ function codingBankManifest(overrides, mode = DEFAULT_RETAIN_EXTRACTION_MODE, de
|
|
|
657
657
|
}
|
|
658
658
|
|
|
659
659
|
// package.json
|
|
660
|
-
var version = "0.8.
|
|
660
|
+
var version = "0.8.6";
|
|
661
661
|
|
|
662
662
|
// src/core/util.ts
|
|
663
663
|
import { accessSync, constants, statSync as statSync2 } from "fs";
|
|
@@ -673,7 +673,7 @@ function codingBankManifest(overrides, mode = DEFAULT_RETAIN_EXTRACTION_MODE, de
|
|
|
673
673
|
}
|
|
674
674
|
|
|
675
675
|
// package.json
|
|
676
|
-
var version = "0.8.
|
|
676
|
+
var version = "0.8.6";
|
|
677
677
|
|
|
678
678
|
// src/core/util.ts
|
|
679
679
|
import { accessSync, constants, statSync as statSync2 } from "fs";
|
|
@@ -2737,6 +2737,8 @@ function resolveAgentBin(harness, claudeBin) {
|
|
|
2737
2737
|
return process.env.HINDSIGHT_ANTIGRAVITY_BIN || "agy";
|
|
2738
2738
|
case "opencode":
|
|
2739
2739
|
return process.env.HINDSIGHT_OPENCODE_BIN || "opencode";
|
|
2740
|
+
default:
|
|
2741
|
+
return void 0;
|
|
2740
2742
|
}
|
|
2741
2743
|
}
|
|
2742
2744
|
function opencodeCanDefineSurveyAgent(bin) {
|
|
@@ -2765,7 +2767,10 @@ var SURVEY_DISALLOWED_TOOLS = [
|
|
|
2765
2767
|
var tomlValue = (value) => stringify({ v: value }).slice("v = ".length).trim();
|
|
2766
2768
|
function buildSurveyPlan(harness, bin, repoDir, opts) {
|
|
2767
2769
|
const env = {
|
|
2768
|
-
|
|
2770
|
+
// Terminal managers name the user's pane in env vars and hook the agent's Stop: inherited,
|
|
2771
|
+
// they made the survey's run look like the user's, so Orca closed the pane and Herdr rebound
|
|
2772
|
+
// it to the survey's session (#6075).
|
|
2773
|
+
...Object.fromEntries(Object.entries(process.env).filter(([k]) => !/^(ORCA|HERDR)_/.test(k))),
|
|
2769
2774
|
// Anti-recursion: the survey's own agent session must not fire our hooks (session-start,
|
|
2770
2775
|
// UserPromptSubmit/BeforeAgent, Stop/SessionEnd) or re-seed — see the HINDSIGHT_DISABLE_HOOKS
|
|
2771
2776
|
// guard in hook.ts / retain-hook.ts / session-start.ts / runtime.ts.
|
|
@@ -2859,96 +2864,88 @@ function surveyAttempts(file, sha) {
|
|
|
2859
2864
|
async function startCodebaseSurvey(repoDir, opts = {}) {
|
|
2860
2865
|
try {
|
|
2861
2866
|
const spawnFn = opts.spawn ?? realSpawn4;
|
|
2862
|
-
const resolveBin = opts.resolveBin ?? ((
|
|
2867
|
+
const resolveBin = opts.resolveBin ?? ((bin2) => binOnPath(bin2, { exts: [".exe"] }));
|
|
2863
2868
|
const mcpServerPath = opts.mcpServerPath ?? join13(dirname8(fileURLToPath3(import.meta.url)), "mcp-server.js");
|
|
2864
|
-
const
|
|
2865
|
-
const
|
|
2866
|
-
|
|
2867
|
-
"
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
stdio: "ignore",
|
|
2920
|
-
windowsHide: true,
|
|
2921
|
-
env: { ...plan.env, [SURVEY_SPEC_ENV]: JSON.stringify(spec) }
|
|
2922
|
-
});
|
|
2923
|
-
let spawned = false;
|
|
2924
|
-
child.on("error", (e) => {
|
|
2925
|
-
if (spawned) return;
|
|
2926
|
-
log.warn("survey", `survey supervisor failed to launch: ${describeError(e)}`);
|
|
2927
|
-
releaseLease(lease);
|
|
2928
|
-
resolve4(false);
|
|
2929
|
-
});
|
|
2930
|
-
child.once("spawn", () => {
|
|
2931
|
-
spawned = true;
|
|
2932
|
-
child.unref();
|
|
2933
|
-
if (opts.sha) {
|
|
2934
|
-
try {
|
|
2935
|
-
writeFileSync3(
|
|
2936
|
-
attemptsFile,
|
|
2937
|
-
JSON.stringify({ sha: opts.sha, attempts: attempts + 1 }),
|
|
2938
|
-
{ mode: 384 }
|
|
2939
|
-
);
|
|
2940
|
-
} catch {
|
|
2941
|
-
}
|
|
2942
|
-
}
|
|
2943
|
-
resolve4(true);
|
|
2944
|
-
});
|
|
2945
|
-
} catch (e) {
|
|
2869
|
+
const harness = opts.harness ?? "claude-code";
|
|
2870
|
+
const name = resolveAgentBin(harness, opts.claudeBin);
|
|
2871
|
+
if (!name) {
|
|
2872
|
+
log.info("survey", `${harness}: no headless survey for this agent, skipping the survey`);
|
|
2873
|
+
return false;
|
|
2874
|
+
}
|
|
2875
|
+
const bin = resolveBin(name);
|
|
2876
|
+
if (!bin) {
|
|
2877
|
+
log.info("survey", `${harness}: ${name} not found, skipping the survey`);
|
|
2878
|
+
return false;
|
|
2879
|
+
}
|
|
2880
|
+
if (harness === "opencode" && !(opts.opencodeDefinesAgent ?? opencodeCanDefineSurveyAgent)(bin)) {
|
|
2881
|
+
log.info("survey", `${harness}: ${bin} cannot define the survey agent, skipping the survey`);
|
|
2882
|
+
return false;
|
|
2883
|
+
}
|
|
2884
|
+
const plan = buildSurveyPlan(harness, bin, repoDir, {
|
|
2885
|
+
model: opts.model,
|
|
2886
|
+
budgetUsd: opts.budgetUsd,
|
|
2887
|
+
mcpServerPath
|
|
2888
|
+
});
|
|
2889
|
+
const { cfg, bankId } = resolveHostConfig(harness, repoDir);
|
|
2890
|
+
if (cfg.disabled) return false;
|
|
2891
|
+
const key = createHash4("sha256").update(JSON.stringify([cfg.apiUrl.replace(/\/+$/, ""), cfg.apiToken ?? "", bankId])).digest("hex");
|
|
2892
|
+
const leaseDir = opts.lease?.dir ?? join13(tmpdir3(), "hindsight-coding-agent", "surveys");
|
|
2893
|
+
const lease = acquireLease(leaseDir, key, opts.lease?.staleMs ?? LEASE_STALE_MS);
|
|
2894
|
+
if (!lease) return false;
|
|
2895
|
+
const attemptsFile = join13(
|
|
2896
|
+
leaseDir,
|
|
2897
|
+
`attempts-${createHash4("sha256").update(JSON.stringify([key, repoDir])).digest("hex")}.json`
|
|
2898
|
+
);
|
|
2899
|
+
const attempts = opts.sha ? surveyAttempts(attemptsFile, opts.sha) : 0;
|
|
2900
|
+
if (attempts >= SURVEY_MAX_ATTEMPTS) {
|
|
2901
|
+
log.info("survey", `${attempts} surveys already launched at ${opts.sha}, skipping`);
|
|
2902
|
+
releaseLease(lease);
|
|
2903
|
+
return false;
|
|
2904
|
+
}
|
|
2905
|
+
const spec = {
|
|
2906
|
+
lease,
|
|
2907
|
+
bin: plan.bin,
|
|
2908
|
+
args: plan.args,
|
|
2909
|
+
...opts.lease?.heartbeatMs ? { heartbeatMs: opts.lease.heartbeatMs } : {}
|
|
2910
|
+
};
|
|
2911
|
+
const supervisorPath = opts.supervisorPath ?? join13(dirname8(fileURLToPath3(import.meta.url)), "survey-supervisor.js");
|
|
2912
|
+
return await new Promise((resolve4) => {
|
|
2913
|
+
try {
|
|
2914
|
+
const child = spawnFn("node", [supervisorPath], {
|
|
2915
|
+
cwd: repoDir,
|
|
2916
|
+
detached: true,
|
|
2917
|
+
stdio: "ignore",
|
|
2918
|
+
windowsHide: true,
|
|
2919
|
+
env: { ...plan.env, [SURVEY_SPEC_ENV]: JSON.stringify(spec) }
|
|
2920
|
+
});
|
|
2921
|
+
let spawned = false;
|
|
2922
|
+
child.on("error", (e) => {
|
|
2923
|
+
if (spawned) return;
|
|
2946
2924
|
log.warn("survey", `survey supervisor failed to launch: ${describeError(e)}`);
|
|
2947
2925
|
releaseLease(lease);
|
|
2948
2926
|
resolve4(false);
|
|
2949
|
-
}
|
|
2950
|
-
|
|
2951
|
-
|
|
2927
|
+
});
|
|
2928
|
+
child.once("spawn", () => {
|
|
2929
|
+
spawned = true;
|
|
2930
|
+
child.unref();
|
|
2931
|
+
if (opts.sha) {
|
|
2932
|
+
try {
|
|
2933
|
+
writeFileSync3(
|
|
2934
|
+
attemptsFile,
|
|
2935
|
+
JSON.stringify({ sha: opts.sha, attempts: attempts + 1 }),
|
|
2936
|
+
{ mode: 384 }
|
|
2937
|
+
);
|
|
2938
|
+
} catch {
|
|
2939
|
+
}
|
|
2940
|
+
}
|
|
2941
|
+
resolve4(true);
|
|
2942
|
+
});
|
|
2943
|
+
} catch (e) {
|
|
2944
|
+
log.warn("survey", `survey supervisor failed to launch: ${describeError(e)}`);
|
|
2945
|
+
releaseLease(lease);
|
|
2946
|
+
resolve4(false);
|
|
2947
|
+
}
|
|
2948
|
+
});
|
|
2952
2949
|
} catch {
|
|
2953
2950
|
}
|
|
2954
2951
|
return false;
|
package/dist/claude-stop-hook.js
CHANGED
|
@@ -633,7 +633,7 @@ function codingBankManifest(overrides, mode = DEFAULT_RETAIN_EXTRACTION_MODE, de
|
|
|
633
633
|
}
|
|
634
634
|
|
|
635
635
|
// package.json
|
|
636
|
-
var version = "0.8.
|
|
636
|
+
var version = "0.8.6";
|
|
637
637
|
|
|
638
638
|
// src/core/util.ts
|
|
639
639
|
import { accessSync, constants, statSync as statSync2 } from "fs";
|
package/dist/cline.js
CHANGED
|
@@ -653,7 +653,7 @@ function codingBankManifest(overrides, mode = DEFAULT_RETAIN_EXTRACTION_MODE, de
|
|
|
653
653
|
}
|
|
654
654
|
|
|
655
655
|
// package.json
|
|
656
|
-
var version = "0.8.
|
|
656
|
+
var version = "0.8.6";
|
|
657
657
|
|
|
658
658
|
// src/core/util.ts
|
|
659
659
|
import { accessSync, constants, statSync as statSync2 } from "fs";
|
|
@@ -17308,6 +17308,8 @@ function resolveAgentBin(harness, claudeBin) {
|
|
|
17308
17308
|
return process.env.HINDSIGHT_ANTIGRAVITY_BIN || "agy";
|
|
17309
17309
|
case "opencode":
|
|
17310
17310
|
return process.env.HINDSIGHT_OPENCODE_BIN || "opencode";
|
|
17311
|
+
default:
|
|
17312
|
+
return void 0;
|
|
17311
17313
|
}
|
|
17312
17314
|
}
|
|
17313
17315
|
function opencodeCanDefineSurveyAgent(bin) {
|
|
@@ -17336,7 +17338,10 @@ var SURVEY_DISALLOWED_TOOLS = [
|
|
|
17336
17338
|
var tomlValue = (value) => stringify({ v: value }).slice("v = ".length).trim();
|
|
17337
17339
|
function buildSurveyPlan(harness, bin, repoDir, opts) {
|
|
17338
17340
|
const env = {
|
|
17339
|
-
|
|
17341
|
+
// Terminal managers name the user's pane in env vars and hook the agent's Stop: inherited,
|
|
17342
|
+
// they made the survey's run look like the user's, so Orca closed the pane and Herdr rebound
|
|
17343
|
+
// it to the survey's session (#6075).
|
|
17344
|
+
...Object.fromEntries(Object.entries(process.env).filter(([k]) => !/^(ORCA|HERDR)_/.test(k))),
|
|
17340
17345
|
// Anti-recursion: the survey's own agent session must not fire our hooks (session-start,
|
|
17341
17346
|
// UserPromptSubmit/BeforeAgent, Stop/SessionEnd) or re-seed — see the HINDSIGHT_DISABLE_HOOKS
|
|
17342
17347
|
// guard in hook.ts / retain-hook.ts / session-start.ts / runtime.ts.
|
|
@@ -17430,96 +17435,88 @@ function surveyAttempts(file2, sha) {
|
|
|
17430
17435
|
async function startCodebaseSurvey(repoDir, opts = {}) {
|
|
17431
17436
|
try {
|
|
17432
17437
|
const spawnFn = opts.spawn ?? realSpawn5;
|
|
17433
|
-
const resolveBin = opts.resolveBin ?? ((
|
|
17438
|
+
const resolveBin = opts.resolveBin ?? ((bin2) => binOnPath(bin2, { exts: [".exe"] }));
|
|
17434
17439
|
const mcpServerPath = opts.mcpServerPath ?? join11(dirname7(fileURLToPath4(import.meta.url)), "mcp-server.js");
|
|
17435
|
-
const
|
|
17436
|
-
const
|
|
17437
|
-
|
|
17438
|
-
"
|
|
17439
|
-
|
|
17440
|
-
|
|
17441
|
-
|
|
17442
|
-
|
|
17443
|
-
|
|
17444
|
-
|
|
17445
|
-
|
|
17446
|
-
|
|
17447
|
-
|
|
17448
|
-
|
|
17449
|
-
|
|
17450
|
-
|
|
17451
|
-
|
|
17452
|
-
|
|
17453
|
-
|
|
17454
|
-
|
|
17455
|
-
|
|
17456
|
-
|
|
17457
|
-
|
|
17458
|
-
|
|
17459
|
-
|
|
17460
|
-
|
|
17461
|
-
|
|
17462
|
-
|
|
17463
|
-
|
|
17464
|
-
|
|
17465
|
-
|
|
17466
|
-
|
|
17467
|
-
|
|
17468
|
-
|
|
17469
|
-
|
|
17470
|
-
|
|
17471
|
-
|
|
17472
|
-
|
|
17473
|
-
|
|
17474
|
-
|
|
17475
|
-
|
|
17476
|
-
|
|
17477
|
-
|
|
17478
|
-
|
|
17479
|
-
|
|
17480
|
-
|
|
17481
|
-
|
|
17482
|
-
|
|
17483
|
-
|
|
17484
|
-
|
|
17485
|
-
|
|
17486
|
-
|
|
17487
|
-
|
|
17488
|
-
|
|
17489
|
-
|
|
17490
|
-
stdio: "ignore",
|
|
17491
|
-
windowsHide: true,
|
|
17492
|
-
env: { ...plan.env, [SURVEY_SPEC_ENV]: JSON.stringify(spec) }
|
|
17493
|
-
});
|
|
17494
|
-
let spawned = false;
|
|
17495
|
-
child.on("error", (e) => {
|
|
17496
|
-
if (spawned) return;
|
|
17497
|
-
log.warn("survey", `survey supervisor failed to launch: ${describeError(e)}`);
|
|
17498
|
-
releaseLease(lease);
|
|
17499
|
-
resolve4(false);
|
|
17500
|
-
});
|
|
17501
|
-
child.once("spawn", () => {
|
|
17502
|
-
spawned = true;
|
|
17503
|
-
child.unref();
|
|
17504
|
-
if (opts.sha) {
|
|
17505
|
-
try {
|
|
17506
|
-
writeFileSync3(
|
|
17507
|
-
attemptsFile,
|
|
17508
|
-
JSON.stringify({ sha: opts.sha, attempts: attempts + 1 }),
|
|
17509
|
-
{ mode: 384 }
|
|
17510
|
-
);
|
|
17511
|
-
} catch {
|
|
17512
|
-
}
|
|
17513
|
-
}
|
|
17514
|
-
resolve4(true);
|
|
17515
|
-
});
|
|
17516
|
-
} catch (e) {
|
|
17440
|
+
const harness = opts.harness ?? "claude-code";
|
|
17441
|
+
const name = resolveAgentBin(harness, opts.claudeBin);
|
|
17442
|
+
if (!name) {
|
|
17443
|
+
log.info("survey", `${harness}: no headless survey for this agent, skipping the survey`);
|
|
17444
|
+
return false;
|
|
17445
|
+
}
|
|
17446
|
+
const bin = resolveBin(name);
|
|
17447
|
+
if (!bin) {
|
|
17448
|
+
log.info("survey", `${harness}: ${name} not found, skipping the survey`);
|
|
17449
|
+
return false;
|
|
17450
|
+
}
|
|
17451
|
+
if (harness === "opencode" && !(opts.opencodeDefinesAgent ?? opencodeCanDefineSurveyAgent)(bin)) {
|
|
17452
|
+
log.info("survey", `${harness}: ${bin} cannot define the survey agent, skipping the survey`);
|
|
17453
|
+
return false;
|
|
17454
|
+
}
|
|
17455
|
+
const plan = buildSurveyPlan(harness, bin, repoDir, {
|
|
17456
|
+
model: opts.model,
|
|
17457
|
+
budgetUsd: opts.budgetUsd,
|
|
17458
|
+
mcpServerPath
|
|
17459
|
+
});
|
|
17460
|
+
const { cfg, bankId } = resolveHostConfig(harness, repoDir);
|
|
17461
|
+
if (cfg.disabled) return false;
|
|
17462
|
+
const key = createHash3("sha256").update(JSON.stringify([cfg.apiUrl.replace(/\/+$/, ""), cfg.apiToken ?? "", bankId])).digest("hex");
|
|
17463
|
+
const leaseDir = opts.lease?.dir ?? join11(tmpdir2(), "hindsight-coding-agent", "surveys");
|
|
17464
|
+
const lease = acquireLease(leaseDir, key, opts.lease?.staleMs ?? LEASE_STALE_MS);
|
|
17465
|
+
if (!lease) return false;
|
|
17466
|
+
const attemptsFile = join11(
|
|
17467
|
+
leaseDir,
|
|
17468
|
+
`attempts-${createHash3("sha256").update(JSON.stringify([key, repoDir])).digest("hex")}.json`
|
|
17469
|
+
);
|
|
17470
|
+
const attempts = opts.sha ? surveyAttempts(attemptsFile, opts.sha) : 0;
|
|
17471
|
+
if (attempts >= SURVEY_MAX_ATTEMPTS) {
|
|
17472
|
+
log.info("survey", `${attempts} surveys already launched at ${opts.sha}, skipping`);
|
|
17473
|
+
releaseLease(lease);
|
|
17474
|
+
return false;
|
|
17475
|
+
}
|
|
17476
|
+
const spec = {
|
|
17477
|
+
lease,
|
|
17478
|
+
bin: plan.bin,
|
|
17479
|
+
args: plan.args,
|
|
17480
|
+
...opts.lease?.heartbeatMs ? { heartbeatMs: opts.lease.heartbeatMs } : {}
|
|
17481
|
+
};
|
|
17482
|
+
const supervisorPath = opts.supervisorPath ?? join11(dirname7(fileURLToPath4(import.meta.url)), "survey-supervisor.js");
|
|
17483
|
+
return await new Promise((resolve4) => {
|
|
17484
|
+
try {
|
|
17485
|
+
const child = spawnFn("node", [supervisorPath], {
|
|
17486
|
+
cwd: repoDir,
|
|
17487
|
+
detached: true,
|
|
17488
|
+
stdio: "ignore",
|
|
17489
|
+
windowsHide: true,
|
|
17490
|
+
env: { ...plan.env, [SURVEY_SPEC_ENV]: JSON.stringify(spec) }
|
|
17491
|
+
});
|
|
17492
|
+
let spawned = false;
|
|
17493
|
+
child.on("error", (e) => {
|
|
17494
|
+
if (spawned) return;
|
|
17517
17495
|
log.warn("survey", `survey supervisor failed to launch: ${describeError(e)}`);
|
|
17518
17496
|
releaseLease(lease);
|
|
17519
17497
|
resolve4(false);
|
|
17520
|
-
}
|
|
17521
|
-
|
|
17522
|
-
|
|
17498
|
+
});
|
|
17499
|
+
child.once("spawn", () => {
|
|
17500
|
+
spawned = true;
|
|
17501
|
+
child.unref();
|
|
17502
|
+
if (opts.sha) {
|
|
17503
|
+
try {
|
|
17504
|
+
writeFileSync3(
|
|
17505
|
+
attemptsFile,
|
|
17506
|
+
JSON.stringify({ sha: opts.sha, attempts: attempts + 1 }),
|
|
17507
|
+
{ mode: 384 }
|
|
17508
|
+
);
|
|
17509
|
+
} catch {
|
|
17510
|
+
}
|
|
17511
|
+
}
|
|
17512
|
+
resolve4(true);
|
|
17513
|
+
});
|
|
17514
|
+
} catch (e) {
|
|
17515
|
+
log.warn("survey", `survey supervisor failed to launch: ${describeError(e)}`);
|
|
17516
|
+
releaseLease(lease);
|
|
17517
|
+
resolve4(false);
|
|
17518
|
+
}
|
|
17519
|
+
});
|
|
17523
17520
|
} catch {
|
|
17524
17521
|
}
|
|
17525
17522
|
return false;
|
|
@@ -18860,7 +18857,7 @@ var RuntimeCore = class {
|
|
|
18860
18857
|
}
|
|
18861
18858
|
if (output.context) blocks.push(output.context);
|
|
18862
18859
|
if (output.notice) {
|
|
18863
|
-
const preview = output.notice.replace(/\s+/g, " ").trim().slice(0, 140);
|
|
18860
|
+
const preview = output.notice.replace(/\x1b\[[0-9;]*m/g, "").replace(/\s+/g, " ").trim().slice(0, 140);
|
|
18864
18861
|
log.info(this.harness, "reflect goal", { preview });
|
|
18865
18862
|
this.notify?.("Hindsight \xB7 recalled past decisions", preview);
|
|
18866
18863
|
}
|
package/dist/codebuddy-hook.js
CHANGED
|
@@ -657,7 +657,7 @@ function codingBankManifest(overrides, mode = DEFAULT_RETAIN_EXTRACTION_MODE, de
|
|
|
657
657
|
}
|
|
658
658
|
|
|
659
659
|
// package.json
|
|
660
|
-
var version = "0.8.
|
|
660
|
+
var version = "0.8.6";
|
|
661
661
|
|
|
662
662
|
// src/core/util.ts
|
|
663
663
|
import { accessSync, constants, statSync as statSync2 } from "fs";
|