@vectorize-io/hindsight-coding-agents 0.8.6 → 0.8.8
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 +31 -21
- package/dist/antigravity-hook.js +278 -190
- package/dist/antigravity-statusline.js +30 -24
- package/dist/antigravity-stop-hook.js +271 -169
- package/dist/claude-hook.js +278 -190
- package/dist/claude-sessionstart-hook.js +301 -212
- package/dist/claude-stop-hook.js +271 -169
- package/dist/cline.js +258 -214
- package/dist/codebuddy-hook.js +278 -190
- package/dist/codebuddy-sessionstart-hook.js +301 -212
- package/dist/codebuddy-stop-hook.js +271 -169
- package/dist/codex-hook.js +278 -190
- package/dist/codex-sessionstart-hook.js +301 -212
- package/dist/codex-stop-hook.js +271 -169
- package/dist/copilot-hook.js +278 -190
- package/dist/copilot-sessionstart-hook.js +301 -212
- package/dist/copilot-stop-hook.js +271 -169
- package/dist/cursor-hook.js +278 -190
- package/dist/cursor-sessionstart-hook.js +301 -212
- package/dist/cursor-stop-hook.js +271 -169
- package/dist/daemon-start.js +20 -16
- package/dist/dcode-hook.js +278 -190
- package/dist/dcode-sessionstart-hook.js +301 -212
- package/dist/dcode-stop-hook.js +271 -169
- package/dist/deepen.js +98 -83
- package/dist/devin-hook.js +278 -190
- package/dist/devin-sessionstart-hook.js +301 -212
- package/dist/devin-stop-hook.js +271 -169
- package/dist/droid-hook.js +278 -190
- package/dist/droid-sessionstart-hook.js +301 -212
- package/dist/droid-stop-hook.js +271 -169
- package/dist/dsh.js +309 -251
- package/dist/grok-hook.js +278 -190
- package/dist/grok-sessionstart-hook.js +301 -212
- package/dist/grok-stop-hook.js +271 -169
- package/dist/hindsight-seed.js +35 -26
- package/dist/index.js +310 -252
- package/dist/installer.js +172 -68
- package/dist/kilo.js +310 -252
- package/dist/kimi-hook.js +278 -190
- package/dist/kimi-sessionstart-hook.js +301 -212
- package/dist/kimi-stop-hook.js +271 -169
- package/dist/mcp-server.js +165 -148
- package/dist/opencode2.js +310 -252
- package/dist/pi.js +309 -251
- package/dist/prime-agent.js +309 -251
- package/dist/qwen-hook.js +278 -190
- package/dist/qwen-sessionstart-hook.js +301 -212
- package/dist/qwen-stop-hook.js +271 -169
- package/dist/status.js +134 -117
- package/dist/traecode-hook.js +278 -190
- package/dist/traecode-sessionstart-hook.js +301 -212
- package/dist/traecode-stop-hook.js +271 -169
- package/dist/workbuddy-hook.js +278 -190
- package/dist/workbuddy-sessionstart-hook.js +301 -212
- package/dist/workbuddy-stop-hook.js +271 -169
- package/dist/zcode-hook.js +278 -190
- package/dist/zcode-sessionstart-hook.js +301 -212
- package/dist/zcode-stop-hook.js +271 -169
- package/package.json +2 -1
- package/plugin.json +1 -1
- package/skill/SKILL.md +31 -26
package/dist/installer.js
CHANGED
|
@@ -2182,9 +2182,59 @@ import { join as join7 } from "path";
|
|
|
2182
2182
|
|
|
2183
2183
|
// src/core/seed.ts
|
|
2184
2184
|
import { spawn as realSpawn } from "child_process";
|
|
2185
|
-
import { dirname as dirname4, join as
|
|
2185
|
+
import { dirname as dirname4, join as join6 } from "path";
|
|
2186
2186
|
import { fileURLToPath } from "url";
|
|
2187
2187
|
|
|
2188
|
+
// src/core/util.ts
|
|
2189
|
+
import { accessSync, constants, statSync as statSync2 } from "fs";
|
|
2190
|
+
import { delimiter, extname, isAbsolute as isAbsolute2, join as join5, resolve as resolve2 } from "path";
|
|
2191
|
+
function binOnPath(bin, opts = {}) {
|
|
2192
|
+
const platform = opts.platform ?? process.platform;
|
|
2193
|
+
const env = opts.env ?? process.env;
|
|
2194
|
+
const runnable = (file) => {
|
|
2195
|
+
try {
|
|
2196
|
+
if (!statSync2(file).isFile()) return false;
|
|
2197
|
+
if (platform !== "win32") accessSync(file, constants.X_OK);
|
|
2198
|
+
return true;
|
|
2199
|
+
} catch {
|
|
2200
|
+
return false;
|
|
2201
|
+
}
|
|
2202
|
+
};
|
|
2203
|
+
if (isAbsolute2(bin) || /[\\/]/.test(bin)) return runnable(bin) ? resolve2(bin) : void 0;
|
|
2204
|
+
const names = platform !== "win32" || extname(bin) ? [bin] : (opts.exts ?? (env.PATHEXT || ".COM;.EXE;.BAT;.CMD").split(";")).filter(Boolean).map((ext) => bin + ext.toLowerCase());
|
|
2205
|
+
for (const dir of (env.PATH || "").split(delimiter)) {
|
|
2206
|
+
if (!dir) continue;
|
|
2207
|
+
for (const name of names) {
|
|
2208
|
+
const file = join5(dir, name);
|
|
2209
|
+
if (runnable(file)) return resolve2(file);
|
|
2210
|
+
}
|
|
2211
|
+
}
|
|
2212
|
+
return void 0;
|
|
2213
|
+
}
|
|
2214
|
+
function nodeBinary() {
|
|
2215
|
+
return process.versions.bun || process.versions.electron ? "node" : process.execPath;
|
|
2216
|
+
}
|
|
2217
|
+
function hookNode(opts = {}) {
|
|
2218
|
+
const platform = opts.platform ?? process.platform;
|
|
2219
|
+
if (platform === "win32" || binOnPath("node", opts)) return "node";
|
|
2220
|
+
return nodeBinary();
|
|
2221
|
+
}
|
|
2222
|
+
function hookNodeShell() {
|
|
2223
|
+
const node = hookNode();
|
|
2224
|
+
return node.includes(" ") ? `"${node}"` : node;
|
|
2225
|
+
}
|
|
2226
|
+
function isOurMcpEntry(entry) {
|
|
2227
|
+
if (!entry || typeof entry !== "object") return false;
|
|
2228
|
+
const candidate = entry;
|
|
2229
|
+
const command = typeof candidate.command === "string" ? candidate.command : "";
|
|
2230
|
+
const bin = command.replaceAll("\\", "/").split("/").at(-1);
|
|
2231
|
+
if (bin !== "node" && bin !== "node.exe" || !Array.isArray(candidate.args)) return false;
|
|
2232
|
+
const script = candidate.args[0];
|
|
2233
|
+
if (typeof script !== "string") return false;
|
|
2234
|
+
const parts = script.replaceAll("\\", "/").split("/").filter(Boolean);
|
|
2235
|
+
return parts.at(-1) === "mcp-server.js" && parts.at(-2) === "dist" && (parts.at(-3) === "coding-agents" || parts.at(-3) === "hindsight-coding-agents");
|
|
2236
|
+
}
|
|
2237
|
+
|
|
2188
2238
|
// src/core/missions.ts
|
|
2189
2239
|
import { createHash } from "crypto";
|
|
2190
2240
|
var PAGE_TAXONOMY = [
|
|
@@ -2217,20 +2267,7 @@ var PAGE_TAXONOMY = [
|
|
|
2217
2267
|
var PAGE_NAMES = PAGE_TAXONOMY.map((page) => page.name);
|
|
2218
2268
|
|
|
2219
2269
|
// package.json
|
|
2220
|
-
var version = "0.8.
|
|
2221
|
-
|
|
2222
|
-
// src/core/util.ts
|
|
2223
|
-
import { accessSync, constants, statSync as statSync2 } from "fs";
|
|
2224
|
-
import { delimiter, extname, isAbsolute as isAbsolute2, join as join6, resolve as resolve2 } from "path";
|
|
2225
|
-
function isOurMcpEntry(entry) {
|
|
2226
|
-
if (!entry || typeof entry !== "object") return false;
|
|
2227
|
-
const candidate = entry;
|
|
2228
|
-
if (candidate.command !== "node" || !Array.isArray(candidate.args)) return false;
|
|
2229
|
-
const script = candidate.args[0];
|
|
2230
|
-
if (typeof script !== "string") return false;
|
|
2231
|
-
const parts = script.replaceAll("\\", "/").split("/").filter(Boolean);
|
|
2232
|
-
return parts.at(-1) === "mcp-server.js" && parts.at(-2) === "dist" && (parts.at(-3) === "coding-agents" || parts.at(-3) === "hindsight-coding-agents");
|
|
2233
|
-
}
|
|
2270
|
+
var version = "0.8.8";
|
|
2234
2271
|
|
|
2235
2272
|
// src/core/hindsight.ts
|
|
2236
2273
|
var USER_AGENT = `hindsight-coding-agents/${version}`;
|
|
@@ -2241,35 +2278,15 @@ var RETRY_AFTER_CEILING_MS = 60 * 1e3;
|
|
|
2241
2278
|
var CONFIG_PATH = process.env.HINDSIGHT_CONFIG || join7(homedir3(), ".hindsight", "coding-agent.json");
|
|
2242
2279
|
var DEFAULT_DAEMON_PORT = 9077;
|
|
2243
2280
|
|
|
2244
|
-
// src/core/brand.ts
|
|
2245
|
-
function brandWord() {
|
|
2246
|
-
const start = [0, 116, 217];
|
|
2247
|
-
const end = [0, 146, 150];
|
|
2248
|
-
const word = "Hindsight";
|
|
2249
|
-
let out = "";
|
|
2250
|
-
for (let i = 0; i < word.length; i++) {
|
|
2251
|
-
const t = i / (word.length - 1);
|
|
2252
|
-
const [r, g, b] = start.map((s, k) => Math.round(s + (end[k] - s) * t));
|
|
2253
|
-
out += `\x1B[38;2;${r};${g};${b}m${word[i]}`;
|
|
2254
|
-
}
|
|
2255
|
-
return `${out}\x1B[0m`;
|
|
2256
|
-
}
|
|
2257
|
-
|
|
2258
|
-
// src/core/session-cache.ts
|
|
2259
|
-
import { mkdirSync as mkdirSync2, readFileSync as readFileSync4, renameSync as renameSync2, rmSync, writeFileSync } from "fs";
|
|
2260
|
-
import { tmpdir } from "os";
|
|
2261
|
-
import { dirname as dirname5, join as join8 } from "path";
|
|
2262
|
-
|
|
2263
|
-
// src/core/turn-journal.ts
|
|
2264
|
-
import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync3, readFileSync as readFileSync5, statSync as statSync3 } from "fs";
|
|
2265
|
-
import { tmpdir as tmpdir2 } from "os";
|
|
2266
|
-
import { dirname as dirname6, join as join9 } from "path";
|
|
2267
|
-
|
|
2268
2281
|
// src/core/transcript-util.ts
|
|
2269
|
-
var
|
|
2282
|
+
var TOOL_TEXT_CAP = 2e3;
|
|
2283
|
+
var MEMORY_TAG_RE = /<(hook_prompt|task-notification|system-reminder|hindsight_memory|hindsight_memories|hindsight_bank|relevant_memories|user_feedback|hindsight_pages|hindsight_page_refresh|hindsight_knowledge|hindsight_knowledge_refresh)\b[\s\S]*?<\/\1>/g;
|
|
2270
2284
|
function stripInjectedMemory(s) {
|
|
2271
2285
|
return s.replace(MEMORY_TAG_RE, "");
|
|
2272
2286
|
}
|
|
2287
|
+
function truncate(s, max = TOOL_TEXT_CAP) {
|
|
2288
|
+
return s.length > max ? `${s.slice(0, max)}\u2026 (truncated)` : s;
|
|
2289
|
+
}
|
|
2273
2290
|
var TARGET_KEYS = [
|
|
2274
2291
|
"file_path",
|
|
2275
2292
|
"path",
|
|
@@ -2297,10 +2314,50 @@ function actionLine(tool, input) {
|
|
|
2297
2314
|
target = input.trim().split("\n")[0];
|
|
2298
2315
|
}
|
|
2299
2316
|
if (target.length > ACTION_TARGET_CAP) target = `${target.slice(0, ACTION_TARGET_CAP)}\u2026`;
|
|
2300
|
-
|
|
2317
|
+
const line = target ? `${tool} ${target}` : tool;
|
|
2318
|
+
const note = memoryNoteText(input);
|
|
2319
|
+
return note ? `${line}
|
|
2320
|
+
${truncate(note, MEMORY_NOTE_CAP)}` : line;
|
|
2321
|
+
}
|
|
2322
|
+
var MEMORY_NOTE_CAP = 8e3;
|
|
2323
|
+
var MEMORY_NOTE_PATH_RE = /(^|[\\/])(memory|memories)[\\/]|(^|[\\/])MEMORY\.md$/i;
|
|
2324
|
+
var MEMORY_SHELL_WRITE_RE = /[\\/](memory|memories)([\\/\s"']|$)|MEMORY\.md/i;
|
|
2325
|
+
var SHELL_WRITE_RE = /(^|[^0-9&>])>>?(?!&)|\btee\b/;
|
|
2326
|
+
function memoryNoteText(input) {
|
|
2327
|
+
if (!input || typeof input !== "object") return "";
|
|
2328
|
+
const rec = input;
|
|
2329
|
+
const cmd = rec.command;
|
|
2330
|
+
if (typeof cmd === "string")
|
|
2331
|
+
return MEMORY_SHELL_WRITE_RE.test(cmd) && SHELL_WRITE_RE.test(cmd) ? cmd.trim() : "";
|
|
2332
|
+
const path = rec.file_path ?? rec.path;
|
|
2333
|
+
if (typeof path !== "string" || !MEMORY_NOTE_PATH_RE.test(path)) return "";
|
|
2334
|
+
const text = rec.content ?? rec.new_string;
|
|
2335
|
+
return typeof text === "string" ? text.trim() : "";
|
|
2301
2336
|
}
|
|
2302
2337
|
|
|
2338
|
+
// src/core/brand.ts
|
|
2339
|
+
function brandWord() {
|
|
2340
|
+
const start = [0, 116, 217];
|
|
2341
|
+
const end = [0, 146, 150];
|
|
2342
|
+
const word = "Hindsight";
|
|
2343
|
+
let out = "";
|
|
2344
|
+
for (let i = 0; i < word.length; i++) {
|
|
2345
|
+
const t = i / (word.length - 1);
|
|
2346
|
+
const [r, g, b] = start.map((s, k) => Math.round(s + (end[k] - s) * t));
|
|
2347
|
+
out += `\x1B[38;2;${r};${g};${b}m${word[i]}`;
|
|
2348
|
+
}
|
|
2349
|
+
return `${out}\x1B[0m`;
|
|
2350
|
+
}
|
|
2351
|
+
|
|
2352
|
+
// src/core/session-cache.ts
|
|
2353
|
+
import { mkdirSync as mkdirSync2, readFileSync as readFileSync4, renameSync as renameSync2, rmSync, writeFileSync } from "fs";
|
|
2354
|
+
import { tmpdir } from "os";
|
|
2355
|
+
import { dirname as dirname5, join as join8 } from "path";
|
|
2356
|
+
|
|
2303
2357
|
// src/core/turn-journal.ts
|
|
2358
|
+
import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync3, readFileSync as readFileSync5, statSync as statSync3 } from "fs";
|
|
2359
|
+
import { tmpdir as tmpdir2 } from "os";
|
|
2360
|
+
import { dirname as dirname6, join as join9 } from "path";
|
|
2304
2361
|
var JOURNAL_MAX_BYTES = 8 * 1024 * 1024;
|
|
2305
2362
|
|
|
2306
2363
|
// src/core/retain-cursor.ts
|
|
@@ -2415,7 +2472,7 @@ function* readJsonl(path) {
|
|
|
2415
2472
|
}
|
|
2416
2473
|
|
|
2417
2474
|
// src/core/transcript.ts
|
|
2418
|
-
function renderLine(content, type) {
|
|
2475
|
+
function renderLine(content, type, questionIds) {
|
|
2419
2476
|
if (typeof content === "string") {
|
|
2420
2477
|
const text = stripInjectedMemory(content).trim();
|
|
2421
2478
|
return text ? [{ role: type, content: text }] : [];
|
|
@@ -2429,7 +2486,11 @@ function renderLine(content, type) {
|
|
|
2429
2486
|
const t = stripInjectedMemory(b.text).trim();
|
|
2430
2487
|
if (t) texts.push(t);
|
|
2431
2488
|
} else if (b.type === "tool_use" && typeof b.name === "string") {
|
|
2489
|
+
if (b.name === "AskUserQuestion" && typeof b.id === "string") questionIds.add(b.id);
|
|
2432
2490
|
actions.push({ role: "action", content: actionLine(b.name, b.input) });
|
|
2491
|
+
} else if (b.type === "tool_result" && b.tool_use_id && questionIds.has(b.tool_use_id)) {
|
|
2492
|
+
const answer = renderLine(b.content, type, questionIds).map((r) => r.content).join("\n");
|
|
2493
|
+
if (answer) texts.push(answer);
|
|
2433
2494
|
}
|
|
2434
2495
|
}
|
|
2435
2496
|
const out = [];
|
|
@@ -2440,6 +2501,7 @@ function renderLine(content, type) {
|
|
|
2440
2501
|
}
|
|
2441
2502
|
function readClaudeTranscript(path) {
|
|
2442
2503
|
const turns = [];
|
|
2504
|
+
const questionIds = /* @__PURE__ */ new Set();
|
|
2443
2505
|
for (const rawLine of readJsonl(path)) {
|
|
2444
2506
|
const trimmed = rawLine.trim();
|
|
2445
2507
|
if (!trimmed) continue;
|
|
@@ -2456,7 +2518,7 @@ function readClaudeTranscript(path) {
|
|
|
2456
2518
|
if (line.isSidechain === true) continue;
|
|
2457
2519
|
if (line.isCompactSummary === true) continue;
|
|
2458
2520
|
if (typeof line.message !== "object" || line.message === null) continue;
|
|
2459
|
-
for (const rendered of renderLine(line.message.content, line.type)) {
|
|
2521
|
+
for (const rendered of renderLine(line.message.content, line.type, questionIds)) {
|
|
2460
2522
|
const turn = { role: rendered.role, content: rendered.content };
|
|
2461
2523
|
if (typeof line.timestamp === "string") turn.timestamp = line.timestamp;
|
|
2462
2524
|
turns.push(turn);
|
|
@@ -2472,10 +2534,14 @@ function usageFilePath() {
|
|
|
2472
2534
|
return process.env.HINDSIGHT_USAGE_FILE || join11(logsDir(), "usage.jsonl");
|
|
2473
2535
|
}
|
|
2474
2536
|
var RETRIEVAL_TOOLS = /* @__PURE__ */ new Set([
|
|
2537
|
+
"hindsight_search_pages",
|
|
2538
|
+
"hindsight_list_pages",
|
|
2539
|
+
"hindsight_read_page",
|
|
2540
|
+
"hindsight_reflect",
|
|
2541
|
+
// Pre-rename names, still in transcripts recorded before the page tools were renamed. Remove in 2.x.
|
|
2475
2542
|
"hindsight_search_knowledge_pages",
|
|
2476
2543
|
"hindsight_list_knowledge_pages",
|
|
2477
|
-
"hindsight_read_knowledge_page"
|
|
2478
|
-
"hindsight_reflect"
|
|
2544
|
+
"hindsight_read_knowledge_page"
|
|
2479
2545
|
]);
|
|
2480
2546
|
function isUsageLine(v) {
|
|
2481
2547
|
const r = v;
|
|
@@ -2849,7 +2915,7 @@ function registerTraecodeWorkspaceMcp(cwd, opts = {}) {
|
|
|
2849
2915
|
}
|
|
2850
2916
|
const servers = doc.mcpServers && typeof doc.mcpServers === "object" && !Array.isArray(doc.mcpServers) ? doc.mcpServers : doc.mcpServers = {};
|
|
2851
2917
|
const entry = {
|
|
2852
|
-
command:
|
|
2918
|
+
command: hookNode(),
|
|
2853
2919
|
args: [script],
|
|
2854
2920
|
env: { HINDSIGHT_MCP_HARNESS: "traecode", HINDSIGHT_MCP_PROJECT_CWD: cwd }
|
|
2855
2921
|
};
|
|
@@ -3213,6 +3279,27 @@ function readAntigravityTranscript(path) {
|
|
|
3213
3279
|
}
|
|
3214
3280
|
return turns;
|
|
3215
3281
|
}
|
|
3282
|
+
function readAntigravityPromptTurn(path) {
|
|
3283
|
+
if (!path) return void 0;
|
|
3284
|
+
let lastRole;
|
|
3285
|
+
let lastUserPrompt;
|
|
3286
|
+
for (const line of readJsonl(path)) {
|
|
3287
|
+
try {
|
|
3288
|
+
const event = JSON.parse(line);
|
|
3289
|
+
const role = event.role ?? event.message?.role ?? event.type;
|
|
3290
|
+
if (!role || role === "CHECKPOINT" || role === "EPHEMERAL_MESSAGE") continue;
|
|
3291
|
+
lastRole = role;
|
|
3292
|
+
if (role === "user" || role === "USER_INPUT") {
|
|
3293
|
+
const content = event.content ?? event.text ?? event.message?.content ?? event.message?.text;
|
|
3294
|
+
const text = typeof content === "string" ? stripInjectedMemory(content) : "";
|
|
3295
|
+
const clean = unwrapUserRequest(text).trim();
|
|
3296
|
+
lastUserPrompt = clean || void 0;
|
|
3297
|
+
}
|
|
3298
|
+
} catch {
|
|
3299
|
+
}
|
|
3300
|
+
}
|
|
3301
|
+
return lastRole === "user" || lastRole === "USER_INPUT" ? lastUserPrompt : void 0;
|
|
3302
|
+
}
|
|
3216
3303
|
|
|
3217
3304
|
// src/core/transcript-copilot.ts
|
|
3218
3305
|
function readCopilotTranscript(path) {
|
|
@@ -3937,9 +4024,10 @@ var antigravityPrompt = {
|
|
|
3937
4024
|
harness: "antigravity-cli",
|
|
3938
4025
|
requireCwd: true,
|
|
3939
4026
|
parse: (ev) => ({
|
|
3940
|
-
// Antigravity's PreInvocation payload
|
|
3941
|
-
//
|
|
3942
|
-
prompt
|
|
4027
|
+
// Antigravity's PreInvocation payload omits the prompt and fires before EVERY planner step in
|
|
4028
|
+
// the agent loop (including after every tool call). Read the transcript's trailing record so
|
|
4029
|
+
// only a genuine user submission returns a prompt and tool-result continuations are suppressed.
|
|
4030
|
+
prompt: readAntigravityPromptTurn(ev.transcriptPath),
|
|
3943
4031
|
cwd: antigravityCwd(ev),
|
|
3944
4032
|
sessionId: ev.conversationId
|
|
3945
4033
|
}),
|
|
@@ -5242,14 +5330,14 @@ function setOrDelete(obj, key, arr) {
|
|
|
5242
5330
|
else delete obj[key];
|
|
5243
5331
|
}
|
|
5244
5332
|
var cmdHook = (dist, file, timeout) => ({
|
|
5245
|
-
hooks: [{ type: "command", command:
|
|
5333
|
+
hooks: [{ type: "command", command: `${hookNodeShell()} "${join24(dist, file)}"`, timeout }]
|
|
5246
5334
|
});
|
|
5247
|
-
var nodeCommand = (script) => script.includes(" ") ?
|
|
5335
|
+
var nodeCommand = (script) => script.includes(" ") ? `${hookNodeShell()} "${script}"` : `${hookNodeShell()} ${script}`;
|
|
5248
5336
|
var processHook = (dist, file, timeoutMs) => ({
|
|
5249
|
-
hooks: [{ type: "process", command:
|
|
5337
|
+
hooks: [{ type: "process", command: hookNode(), args: [join24(dist, file)], timeoutMs }]
|
|
5250
5338
|
});
|
|
5251
5339
|
var mcpServerEntry = (dist, harness, extraArgs = []) => ({
|
|
5252
|
-
command:
|
|
5340
|
+
command: hookNode(),
|
|
5253
5341
|
args: [join24(dist, "mcp-server.js"), ...extraArgs],
|
|
5254
5342
|
env: { HINDSIGHT_MCP_HARNESS: harness }
|
|
5255
5343
|
});
|
|
@@ -5340,16 +5428,28 @@ function registerOpencodePlugin(c, name) {
|
|
|
5340
5428
|
}
|
|
5341
5429
|
const plugins = Array.isArray(cfg.plugin) ? cfg.plugin : [];
|
|
5342
5430
|
writeJsonc(path, "plugin", [...plugins.filter((p) => !String(p).includes(MARKER)), c.pkgRoot]);
|
|
5431
|
+
dropOursFromV2Plugins(path, cfg);
|
|
5343
5432
|
c.log?.(`${name}: plugin registered in ${path}`);
|
|
5344
5433
|
}
|
|
5434
|
+
function dropOursFromV2Plugins(path, cfg) {
|
|
5435
|
+
if (!Array.isArray(cfg.plugins)) return false;
|
|
5436
|
+
const kept = cfg.plugins.filter((p) => !String(p).includes(MARKER));
|
|
5437
|
+
if (kept.length === cfg.plugins.length) return false;
|
|
5438
|
+
writeJsonc(path, "plugins", kept.length ? kept : void 0);
|
|
5439
|
+
return true;
|
|
5440
|
+
}
|
|
5345
5441
|
function unregisterOpencodePlugin(c, name) {
|
|
5346
5442
|
const path = opencodeConfigPath(c);
|
|
5347
5443
|
if (!existsSync13(path)) return;
|
|
5348
5444
|
const cfg = parseJsonc(readFileSync16(path, "utf8"));
|
|
5349
|
-
if (!cfg
|
|
5350
|
-
|
|
5351
|
-
|
|
5352
|
-
|
|
5445
|
+
if (!cfg) return;
|
|
5446
|
+
let removed = dropOursFromV2Plugins(path, cfg);
|
|
5447
|
+
if (Array.isArray(cfg.plugin)) {
|
|
5448
|
+
const kept = cfg.plugin.filter((p) => !String(p).includes(MARKER));
|
|
5449
|
+
writeJsonc(path, "plugin", kept.length ? kept : void 0);
|
|
5450
|
+
removed = true;
|
|
5451
|
+
}
|
|
5452
|
+
if (removed) c.log?.(`${name}: plugin entry removed`);
|
|
5353
5453
|
}
|
|
5354
5454
|
var opencode = {
|
|
5355
5455
|
name: "opencode",
|
|
@@ -5453,14 +5553,14 @@ var claudeCode = {
|
|
|
5453
5553
|
"--env",
|
|
5454
5554
|
"HINDSIGHT_MCP_HARNESS=claude-code",
|
|
5455
5555
|
"--",
|
|
5456
|
-
|
|
5556
|
+
hookNode(),
|
|
5457
5557
|
join24(c.dist, "mcp-server.js")
|
|
5458
5558
|
])) {
|
|
5459
5559
|
c.log?.("claude-code: MCP server registered (claude mcp add, user scope)");
|
|
5460
5560
|
} else {
|
|
5461
5561
|
c.log?.(
|
|
5462
5562
|
`claude-code: could not run \`claude mcp add\` \u2014 register the tools manually:
|
|
5463
|
-
claude mcp add --scope user hindsight --env HINDSIGHT_MCP_HARNESS=claude-code --
|
|
5563
|
+
claude mcp add --scope user hindsight --env HINDSIGHT_MCP_HARNESS=claude-code -- ${hookNodeShell()} "${join24(c.dist, "mcp-server.js")}"`
|
|
5464
5564
|
);
|
|
5465
5565
|
}
|
|
5466
5566
|
},
|
|
@@ -5490,7 +5590,7 @@ function defaultClaudeMcp(args) {
|
|
|
5490
5590
|
}
|
|
5491
5591
|
var CODEX_MCP_BLOCK_RE = /^\[mcp_servers\.hindsight(?:\.[^\]]+)?\][^\n]*\n(?:(?!\[)[^\n]*\n?)*/gm;
|
|
5492
5592
|
var codexMcpBlock = (dist) => `[mcp_servers.hindsight]
|
|
5493
|
-
command =
|
|
5593
|
+
command = ${JSON.stringify(hookNode())}
|
|
5494
5594
|
args = [${JSON.stringify(join24(dist, "mcp-server.js"))}]
|
|
5495
5595
|
env = { HINDSIGHT_MCP_HARNESS = "codex" }`;
|
|
5496
5596
|
var codex = {
|
|
@@ -5633,7 +5733,7 @@ var antigravity = {
|
|
|
5633
5733
|
};
|
|
5634
5734
|
function pathNodeHasSqlite() {
|
|
5635
5735
|
try {
|
|
5636
|
-
execFileSync8(
|
|
5736
|
+
execFileSync8(hookNode(), ["-e", "require('node:sqlite')"], { stdio: "pipe", timeout: 1e4 });
|
|
5637
5737
|
return true;
|
|
5638
5738
|
} catch {
|
|
5639
5739
|
return false;
|
|
@@ -5641,7 +5741,7 @@ function pathNodeHasSqlite() {
|
|
|
5641
5741
|
}
|
|
5642
5742
|
function pathNodeVersion() {
|
|
5643
5743
|
try {
|
|
5644
|
-
return execFileSync8(
|
|
5744
|
+
return execFileSync8(hookNode(), ["-v"], { encoding: "utf8", stdio: "pipe" }).trim();
|
|
5645
5745
|
} catch {
|
|
5646
5746
|
return "not found";
|
|
5647
5747
|
}
|
|
@@ -6107,7 +6207,7 @@ var kimi = {
|
|
|
6107
6207
|
const entries = Object.values(spec.install).map(
|
|
6108
6208
|
(h) => `[[hooks]]
|
|
6109
6209
|
event = ${JSON.stringify(h.event)}
|
|
6110
|
-
command = ${JSON.stringify(
|
|
6210
|
+
command = ${JSON.stringify(`${hookNodeShell()} "${join24(c.dist, h.entry)}"`)}
|
|
6111
6211
|
timeout = ${h.timeout}
|
|
6112
6212
|
`
|
|
6113
6213
|
).join("\n");
|
|
@@ -6353,14 +6453,14 @@ var qwen = {
|
|
|
6353
6453
|
"-e",
|
|
6354
6454
|
"HINDSIGHT_MCP_HARNESS=qwen-code",
|
|
6355
6455
|
"hindsight",
|
|
6356
|
-
|
|
6456
|
+
hookNode(),
|
|
6357
6457
|
join24(c.dist, "mcp-server.js")
|
|
6358
6458
|
])) {
|
|
6359
6459
|
c.log?.("qwen-code: MCP server registered (qwen mcp add, user scope)");
|
|
6360
6460
|
} else {
|
|
6361
6461
|
c.log?.(
|
|
6362
6462
|
`qwen-code: could not run \`qwen mcp add\` \u2014 register the tools manually:
|
|
6363
|
-
qwen mcp add -s user -e HINDSIGHT_MCP_HARNESS=qwen-code hindsight
|
|
6463
|
+
qwen mcp add -s user -e HINDSIGHT_MCP_HARNESS=qwen-code hindsight ${hookNodeShell()} "${join24(c.dist, "mcp-server.js")}"`
|
|
6364
6464
|
);
|
|
6365
6465
|
}
|
|
6366
6466
|
},
|
|
@@ -6734,9 +6834,13 @@ function importConversations(harness, ctx) {
|
|
|
6734
6834
|
`${harness}: importing ${found.sessions.length} past sessions (${turns} turns) from ${repo} \u2014 this runs extraction and may take a while`
|
|
6735
6835
|
);
|
|
6736
6836
|
try {
|
|
6737
|
-
execFileSync8(
|
|
6738
|
-
|
|
6739
|
-
|
|
6837
|
+
execFileSync8(
|
|
6838
|
+
nodeBinary(),
|
|
6839
|
+
[join24(ctx.dist, "deepen.js"), "--repo", repo, "--conversations", file],
|
|
6840
|
+
{
|
|
6841
|
+
stdio: "inherit"
|
|
6842
|
+
}
|
|
6843
|
+
);
|
|
6740
6844
|
} catch {
|
|
6741
6845
|
ctx.log?.(`${harness}: conversation import did not finish \u2014 re-run it any time with:`);
|
|
6742
6846
|
ctx.log?.(` node "${join24(ctx.dist, "deepen.js")}" --repo "${repo}" --conversations "${file}"`);
|