@vectorize-io/hindsight-coding-agents 0.4.3 → 0.5.0
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 +202 -52
- package/dist/antigravity-hook.js +637 -199
- package/dist/antigravity-statusline.js +219 -84
- package/dist/antigravity-stop-hook.js +654 -205
- package/dist/claude-hook.js +637 -199
- package/dist/claude-sessionstart-hook.js +863 -236
- package/dist/claude-stop-hook.js +654 -205
- package/dist/cline.js +589 -234
- package/dist/codex-hook.js +637 -199
- package/dist/codex-sessionstart-hook.js +863 -236
- package/dist/codex-stop-hook.js +654 -205
- package/dist/copilot-hook.js +637 -199
- package/dist/copilot-sessionstart-hook.js +863 -236
- package/dist/copilot-stop-hook.js +654 -205
- package/dist/cursor-hook.js +637 -199
- package/dist/cursor-sessionstart-hook.js +863 -236
- package/dist/cursor-stop-hook.js +654 -205
- package/dist/daemon-start.js +62 -43
- package/dist/dcode-hook.js +2577 -0
- package/dist/dcode-sessionstart-hook.js +3194 -0
- package/dist/dcode-stop-hook.js +2807 -0
- package/dist/deepen.js +361 -204
- package/dist/devin-hook.js +637 -199
- package/dist/devin-sessionstart-hook.js +863 -236
- package/dist/devin-stop-hook.js +654 -205
- package/dist/dsh.js +592 -235
- package/dist/grok-hook.js +637 -199
- package/dist/grok-sessionstart-hook.js +863 -236
- package/dist/grok-stop-hook.js +654 -205
- package/dist/hindsight-seed.js +222 -83
- package/dist/index.js +589 -234
- package/dist/installer.js +2331 -299
- package/dist/kilo.js +589 -234
- package/dist/mcp-server.js +363 -169
- package/dist/opencode2.js +30092 -0
- package/dist/pi.js +17650 -0
- package/dist/prime-agent.js +625 -260
- package/dist/qwen-hook.js +2577 -0
- package/dist/qwen-sessionstart-hook.js +3194 -0
- package/dist/qwen-stop-hook.js +2807 -0
- package/dist/status.js +300 -136
- package/hooks/hooks.json +37 -0
- package/index.js +10 -0
- package/package.json +15 -8
- package/plugin.json +16 -0
- package/skill/SKILL.md +114 -43
package/dist/hindsight-seed.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/core/config.ts
|
|
4
|
-
import { readFileSync } from "fs";
|
|
4
|
+
import { readFileSync as readFileSync2 } from "fs";
|
|
5
5
|
import { homedir as homedir2 } from "os";
|
|
6
|
-
import { join as
|
|
6
|
+
import { join as join6 } from "path";
|
|
7
7
|
|
|
8
8
|
// src/core/seed.ts
|
|
9
9
|
import { spawn as realSpawn } from "child_process";
|
|
@@ -49,71 +49,197 @@ function seedControl(command2, args) {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
// src/core/bank.ts
|
|
52
|
-
import { execFileSync } from "child_process";
|
|
53
52
|
import { existsSync } from "fs";
|
|
54
53
|
import { homedir } from "os";
|
|
55
|
-
import { basename, dirname as
|
|
54
|
+
import { basename, dirname as dirname4, join as join4, normalize, sep } from "path";
|
|
55
|
+
|
|
56
|
+
// src/core/diag.ts
|
|
57
|
+
import { appendFileSync as appendFileSync2 } from "fs";
|
|
58
|
+
|
|
59
|
+
// src/core/log.ts
|
|
60
|
+
import { appendFileSync, mkdirSync } from "fs";
|
|
61
|
+
import { tmpdir } from "os";
|
|
62
|
+
import { dirname as dirname2, join as join2 } from "path";
|
|
63
|
+
var WEIGHT = { debug: 10, info: 20, warn: 30, error: 40 };
|
|
64
|
+
var current = ["debug", "info", "warn", "error"].find(
|
|
65
|
+
(l) => l === process.env.HINDSIGHT_LOG_LEVEL
|
|
66
|
+
) ?? "info";
|
|
67
|
+
function logFilePath() {
|
|
68
|
+
return process.env.HINDSIGHT_LOG_FILE || join2(tmpdir(), "hindsight-coding-agent", "plugin.log");
|
|
69
|
+
}
|
|
70
|
+
function write(level, scope, msg, extra) {
|
|
71
|
+
if (WEIGHT[level] < WEIGHT[current]) return;
|
|
72
|
+
try {
|
|
73
|
+
const file = logFilePath();
|
|
74
|
+
mkdirSync(dirname2(file), { recursive: true });
|
|
75
|
+
appendFileSync(
|
|
76
|
+
file,
|
|
77
|
+
`${(/* @__PURE__ */ new Date()).toISOString()} ${level.toUpperCase().padEnd(5)} [${scope}] ${msg}` + (extra && Object.keys(extra).length ? ` ${JSON.stringify(extra)}` : "") + "\n"
|
|
78
|
+
);
|
|
79
|
+
} catch {
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
var log = {
|
|
83
|
+
debug: (scope, msg, extra) => write("debug", scope, msg, extra),
|
|
84
|
+
info: (scope, msg, extra) => write("info", scope, msg, extra),
|
|
85
|
+
warn: (scope, msg, extra) => write("warn", scope, msg, extra),
|
|
86
|
+
error: (scope, msg, extra) => write("error", scope, msg, extra)
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// src/core/diag.ts
|
|
90
|
+
function diagFilePath() {
|
|
91
|
+
return process.env.HINDSIGHT_DIAG_FILE || "/tmp/hindsight-plugin.log";
|
|
92
|
+
}
|
|
93
|
+
function diag(harness, event, extra = {}) {
|
|
94
|
+
log.debug(harness, `diag:${event}`, extra);
|
|
95
|
+
try {
|
|
96
|
+
appendFileSync2(
|
|
97
|
+
diagFilePath(),
|
|
98
|
+
JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), harness, event, ...extra }) + "\n"
|
|
99
|
+
);
|
|
100
|
+
} catch {
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// src/core/git-layout.ts
|
|
105
|
+
import { lstatSync, readFileSync, realpathSync } from "fs";
|
|
106
|
+
import { dirname as dirname3, isAbsolute, join as join3, resolve } from "path";
|
|
107
|
+
var TRANSIENT = /* @__PURE__ */ new Set(["EAGAIN", "EMFILE", "ENFILE", "EBUSY", "EINTR", "EIO", "ETIMEDOUT"]);
|
|
108
|
+
var ATTEMPTS = 3;
|
|
109
|
+
var BACKOFF_MS = 20;
|
|
110
|
+
function errorCode(error) {
|
|
111
|
+
return error?.code ?? "";
|
|
112
|
+
}
|
|
113
|
+
function sleepSync(ms) {
|
|
114
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
|
|
115
|
+
}
|
|
116
|
+
var TransientProbeError = class extends Error {
|
|
117
|
+
};
|
|
118
|
+
function entryKind(path) {
|
|
119
|
+
try {
|
|
120
|
+
const st = lstatSync(path);
|
|
121
|
+
return st.isDirectory() ? "dir" : "file";
|
|
122
|
+
} catch (error) {
|
|
123
|
+
if (TRANSIENT.has(errorCode(error))) throw new TransientProbeError(errorCode(error));
|
|
124
|
+
return "none";
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function readTextOrNull(path) {
|
|
128
|
+
try {
|
|
129
|
+
return readFileSync(path, "utf8");
|
|
130
|
+
} catch (error) {
|
|
131
|
+
if (TRANSIENT.has(errorCode(error))) throw new TransientProbeError(errorCode(error));
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
function gitDirFromPointer(text, holder) {
|
|
136
|
+
const match = /^\s*gitdir:\s*(.+?)\s*$/m.exec(text);
|
|
137
|
+
if (!match) return null;
|
|
138
|
+
const target = match[1];
|
|
139
|
+
return isAbsolute(target) ? target : resolve(holder, target);
|
|
140
|
+
}
|
|
141
|
+
function commonDirOf(gitDir) {
|
|
142
|
+
const pointer = entryKind(join3(gitDir, "commondir")) === "file" ? readTextOrNull(join3(gitDir, "commondir"))?.trim() : null;
|
|
143
|
+
if (!pointer) return gitDir;
|
|
144
|
+
return isAbsolute(pointer) ? pointer : resolve(gitDir, pointer);
|
|
145
|
+
}
|
|
146
|
+
function isBare(commonDir) {
|
|
147
|
+
const config = readTextOrNull(join3(commonDir, "config"));
|
|
148
|
+
return config !== null && /^\s*bare\s*=\s*true\s*$/im.test(config);
|
|
149
|
+
}
|
|
150
|
+
function looksLikeBareRepository(directory) {
|
|
151
|
+
return entryKind(join3(directory, "HEAD")) === "file" && entryKind(join3(directory, "objects")) === "dir" && entryKind(join3(directory, "refs")) === "dir";
|
|
152
|
+
}
|
|
153
|
+
function canonical(path) {
|
|
154
|
+
try {
|
|
155
|
+
return realpathSync(path);
|
|
156
|
+
} catch {
|
|
157
|
+
return path;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
function resolved(commonDir) {
|
|
161
|
+
if (entryKind(commonDir) !== "dir") return null;
|
|
162
|
+
const canonicalDir = canonical(commonDir);
|
|
163
|
+
return { status: "resolved", commonDir: canonicalDir, bare: isBare(canonicalDir) };
|
|
164
|
+
}
|
|
165
|
+
function probeOnce(directory) {
|
|
166
|
+
let current2 = resolve(directory);
|
|
167
|
+
for (; ; ) {
|
|
168
|
+
const dotGit = join3(current2, ".git");
|
|
169
|
+
const kind = entryKind(dotGit);
|
|
170
|
+
if (kind === "dir") {
|
|
171
|
+
const layout = resolved(commonDirOf(dotGit));
|
|
172
|
+
if (layout) return layout;
|
|
173
|
+
} else if (kind === "file") {
|
|
174
|
+
const text = readTextOrNull(dotGit);
|
|
175
|
+
const gitDir = text ? gitDirFromPointer(text, current2) : null;
|
|
176
|
+
const layout = gitDir ? resolved(commonDirOf(gitDir)) : null;
|
|
177
|
+
if (layout) return layout;
|
|
178
|
+
}
|
|
179
|
+
if (looksLikeBareRepository(current2)) {
|
|
180
|
+
const layout = resolved(current2);
|
|
181
|
+
if (layout) return layout;
|
|
182
|
+
}
|
|
183
|
+
const parent = dirname3(current2);
|
|
184
|
+
if (parent === current2) return { status: "absent" };
|
|
185
|
+
current2 = parent;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
function probeGitLayout(directory) {
|
|
189
|
+
if (!directory) return { status: "absent" };
|
|
190
|
+
let last = "";
|
|
191
|
+
for (let attempt = 0; attempt < ATTEMPTS; attempt++) {
|
|
192
|
+
if (attempt) sleepSync(BACKOFF_MS * attempt);
|
|
193
|
+
try {
|
|
194
|
+
return probeOnce(directory);
|
|
195
|
+
} catch (error) {
|
|
196
|
+
last = error instanceof TransientProbeError ? error.message : errorCode(error) || "unknown";
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return { status: "failed", reason: last };
|
|
200
|
+
}
|
|
56
201
|
|
|
57
202
|
// src/core/template.ts
|
|
58
203
|
var PLACEHOLDER = /\{([a-zA-Z_]+)\}/g;
|
|
59
204
|
function applyTemplate(template, resolvers, what) {
|
|
60
205
|
return template.replace(PLACEHOLDER, (_, name) => {
|
|
61
|
-
const
|
|
62
|
-
if (!
|
|
206
|
+
const resolve2 = resolvers[name];
|
|
207
|
+
if (!resolve2) {
|
|
63
208
|
console.error(
|
|
64
209
|
`hindsight: unknown ${what} placeholder "{${name}}" \u2014 valid: ` + Object.keys(resolvers).sort().map((k) => `{${k}}`).join(", ")
|
|
65
210
|
);
|
|
66
211
|
return "unknown";
|
|
67
212
|
}
|
|
68
|
-
return
|
|
213
|
+
return resolve2();
|
|
69
214
|
});
|
|
70
215
|
}
|
|
71
216
|
|
|
72
217
|
// src/core/bank.ts
|
|
73
218
|
var DEFAULT_BANK_NAME = "coding";
|
|
74
219
|
var DEFAULT_TEMPLATE = "coding-agent::{gitProject}";
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
"git",
|
|
80
|
-
["rev-parse", "--path-format=absolute", "--git-common-dir"],
|
|
81
|
-
{
|
|
82
|
-
cwd: directory,
|
|
83
|
-
encoding: "utf-8",
|
|
84
|
-
stdio: ["ignore", "pipe", "ignore"],
|
|
85
|
-
timeout: 1e3,
|
|
86
|
-
windowsHide: true
|
|
87
|
-
}
|
|
88
|
-
).trim();
|
|
89
|
-
if (!commonDir) return null;
|
|
90
|
-
if (basename(commonDir) === ".git") return dirname2(commonDir);
|
|
91
|
-
if (basename(commonDir).startsWith(".") && isBareRepository(commonDir)) {
|
|
92
|
-
return dirname2(commonDir);
|
|
93
|
-
}
|
|
94
|
-
return commonDir;
|
|
95
|
-
} catch {
|
|
96
|
-
return null;
|
|
220
|
+
var BankResolutionError = class extends Error {
|
|
221
|
+
constructor(message) {
|
|
222
|
+
super(message);
|
|
223
|
+
this.name = "BankResolutionError";
|
|
97
224
|
}
|
|
98
|
-
}
|
|
99
|
-
function
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
} catch {
|
|
108
|
-
return false;
|
|
225
|
+
};
|
|
226
|
+
function resolveProjectRoot(directory) {
|
|
227
|
+
if (!directory) return { status: "absent" };
|
|
228
|
+
const layout = probeGitLayout(directory);
|
|
229
|
+
if (layout.status !== "resolved") return layout;
|
|
230
|
+
const commonDir = layout.commonDir;
|
|
231
|
+
if (basename(commonDir) === ".git") return { status: "resolved", root: dirname4(commonDir) };
|
|
232
|
+
if (basename(commonDir).startsWith(".") && layout.bare) {
|
|
233
|
+
return { status: "resolved", root: dirname4(commonDir) };
|
|
109
234
|
}
|
|
235
|
+
return { status: "resolved", root: commonDir };
|
|
110
236
|
}
|
|
111
237
|
var PROJECT_ROOT_ENV = ["CLAUDE_PROJECT_DIR"];
|
|
112
238
|
function nearestExistingDir(directory) {
|
|
113
239
|
let current2 = directory;
|
|
114
240
|
while (current2) {
|
|
115
241
|
if (existsSync(current2)) return current2;
|
|
116
|
-
const parent =
|
|
242
|
+
const parent = dirname4(current2);
|
|
117
243
|
if (parent === current2) return "";
|
|
118
244
|
current2 = parent;
|
|
119
245
|
}
|
|
@@ -128,21 +254,29 @@ function mainWorktreeRoot(directory, sessionRoot = "") {
|
|
|
128
254
|
sessionRoot,
|
|
129
255
|
...PROJECT_ROOT_ENV.map((v) => process.env[v] || "")
|
|
130
256
|
];
|
|
257
|
+
let failure = null;
|
|
131
258
|
for (const candidate of candidates) {
|
|
132
|
-
|
|
133
|
-
|
|
259
|
+
if (!candidate) continue;
|
|
260
|
+
const projectRoot = resolveProjectRoot(candidate);
|
|
261
|
+
if (projectRoot.status === "resolved") return projectRoot;
|
|
262
|
+
if (projectRoot.status === "failed") failure = projectRoot;
|
|
134
263
|
}
|
|
135
|
-
return
|
|
264
|
+
return failure ?? { status: "absent" };
|
|
136
265
|
}
|
|
137
266
|
function gitProjectName(directory, resolveWorktrees, sessionRoot = "") {
|
|
138
267
|
if (resolveWorktrees) {
|
|
139
|
-
const
|
|
140
|
-
if (
|
|
268
|
+
const projectRoot = mainWorktreeRoot(directory, sessionRoot);
|
|
269
|
+
if (projectRoot.status === "resolved") return basename(projectRoot.root);
|
|
270
|
+
if (projectRoot.status === "failed") {
|
|
271
|
+
throw new BankResolutionError(
|
|
272
|
+
`git probe failed for ${directory} (${projectRoot.reason}) \u2014 refusing to guess a bank id`
|
|
273
|
+
);
|
|
274
|
+
}
|
|
141
275
|
}
|
|
142
276
|
return dirName(sessionRoot || directory);
|
|
143
277
|
}
|
|
144
278
|
function configuredDir(dir) {
|
|
145
|
-
const expanded = dir === "~" || dir.startsWith("~/") ?
|
|
279
|
+
const expanded = dir === "~" || dir.startsWith("~/") ? join4(homedir(), dir.slice(1)) : dir;
|
|
146
280
|
return normalize(expanded).replace(new RegExp(`\\${sep}+$`), "");
|
|
147
281
|
}
|
|
148
282
|
function isWithin(directory, configured) {
|
|
@@ -162,8 +296,8 @@ function mapLookup(map, directory) {
|
|
|
162
296
|
function lookupDirectories(config, directory, sessionRoot = "") {
|
|
163
297
|
const directories = [normalize(directory)];
|
|
164
298
|
if (config.resolveWorktrees ?? true) {
|
|
165
|
-
const
|
|
166
|
-
const normalizedRoot =
|
|
299
|
+
const projectRoot = mainWorktreeRoot(directory, sessionRoot);
|
|
300
|
+
const normalizedRoot = projectRoot.status === "resolved" ? normalize(projectRoot.root) : "";
|
|
167
301
|
if (normalizedRoot && normalizedRoot !== directories[0]) directories.push(normalizedRoot);
|
|
168
302
|
}
|
|
169
303
|
return directories;
|
|
@@ -183,36 +317,23 @@ function deriveBankId(config, directory, harness = "coding", sessionRoot) {
|
|
|
183
317
|
};
|
|
184
318
|
return applyTemplate(config.bankIdTemplate || DEFAULT_TEMPLATE, resolvers, "bankIdTemplate");
|
|
185
319
|
}
|
|
186
|
-
|
|
187
|
-
// src/core/log.ts
|
|
188
|
-
import { appendFileSync, mkdirSync } from "fs";
|
|
189
|
-
import { tmpdir } from "os";
|
|
190
|
-
import { dirname as dirname3, join as join3 } from "path";
|
|
191
|
-
var WEIGHT = { debug: 10, info: 20, warn: 30, error: 40 };
|
|
192
|
-
var current = ["debug", "info", "warn", "error"].find(
|
|
193
|
-
(l) => l === process.env.HINDSIGHT_LOG_LEVEL
|
|
194
|
-
) ?? "info";
|
|
195
|
-
function logFilePath() {
|
|
196
|
-
return process.env.HINDSIGHT_LOG_FILE || join3(tmpdir(), "hindsight-coding-agent", "plugin.log");
|
|
197
|
-
}
|
|
198
|
-
function write(level, scope, msg, extra) {
|
|
199
|
-
if (WEIGHT[level] < WEIGHT[current]) return;
|
|
320
|
+
function deriveBankIdOrSkip(config, directory, harness = "coding", sessionRoot) {
|
|
200
321
|
try {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
322
|
+
return deriveBankId(config, directory, harness, sessionRoot);
|
|
323
|
+
} catch (error) {
|
|
324
|
+
if (!(error instanceof BankResolutionError)) throw error;
|
|
325
|
+
log.warn(harness, "bank unresolved: skipping (repository could not be identified)", {
|
|
326
|
+
directory,
|
|
327
|
+
error: error.message
|
|
328
|
+
});
|
|
329
|
+
diag(harness, "bank_unresolved", { directory, error: error.message });
|
|
330
|
+
return null;
|
|
208
331
|
}
|
|
209
332
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
error: (scope, msg, extra) => write("error", scope, msg, extra)
|
|
215
|
-
};
|
|
333
|
+
|
|
334
|
+
// src/core/util.ts
|
|
335
|
+
import { accessSync, constants } from "fs";
|
|
336
|
+
import { delimiter, join as join5 } from "path";
|
|
216
337
|
|
|
217
338
|
// src/core/hindsight.ts
|
|
218
339
|
var DEFAULT_OBSERVATION_SCOPES = "shared";
|
|
@@ -220,7 +341,7 @@ var RETRY_AFTER_FLOOR_MS = 10 * 1e3;
|
|
|
220
341
|
var RETRY_AFTER_CEILING_MS = 60 * 1e3;
|
|
221
342
|
|
|
222
343
|
// src/core/config.ts
|
|
223
|
-
var CONFIG_PATH = process.env.HINDSIGHT_CONFIG ||
|
|
344
|
+
var CONFIG_PATH = process.env.HINDSIGHT_CONFIG || join6(homedir2(), ".hindsight", "coding-agent.json");
|
|
224
345
|
var DEFAULT_DAEMON_PORT = 9077;
|
|
225
346
|
var DEFAULT_DAEMON_PROFILE = "coding-agent";
|
|
226
347
|
function resolvePageTriggerType(raw) {
|
|
@@ -244,7 +365,13 @@ function resolveReflectBudget(raw) {
|
|
|
244
365
|
log.warn("config", `ignoring reflectBudget=${JSON.stringify(value)} \u2014 expected low|mid|high`);
|
|
245
366
|
return "high";
|
|
246
367
|
}
|
|
247
|
-
var OBSERVATION_SCOPE_MODES = [
|
|
368
|
+
var OBSERVATION_SCOPE_MODES = [
|
|
369
|
+
"shared",
|
|
370
|
+
"combined",
|
|
371
|
+
"per_tag",
|
|
372
|
+
"all_combinations",
|
|
373
|
+
"per_source"
|
|
374
|
+
];
|
|
248
375
|
function resolveObservationScopes(raw) {
|
|
249
376
|
const value = raw;
|
|
250
377
|
if (typeof value === "string")
|
|
@@ -282,6 +409,7 @@ function resolveConfig(raw = {}) {
|
|
|
282
409
|
disabled: raw.disabled ?? false,
|
|
283
410
|
retainSessions: raw.retainSessions ?? true,
|
|
284
411
|
// write sessions back by default, every harness
|
|
412
|
+
manageBankConfig: raw.manageBankConfig ?? true,
|
|
285
413
|
maxParallelRetains: raw.maxParallelRetains || 10,
|
|
286
414
|
reflectTimeoutMs: raw.reflectTimeoutMs || 12e4,
|
|
287
415
|
// Inherit an explicitly-raised reflectTimeoutMs (that is what users reaching for a longer
|
|
@@ -308,12 +436,13 @@ function resolveConfig(raw = {}) {
|
|
|
308
436
|
) : {},
|
|
309
437
|
observationScopes: resolveObservationScopes(raw.observationScopes),
|
|
310
438
|
banks: raw.banks && typeof raw.banks === "object" ? raw.banks : {},
|
|
311
|
-
logLevel: ["debug", "info", "warn", "error"].includes(raw.logLevel) ? raw.logLevel : "info"
|
|
439
|
+
logLevel: ["debug", "info", "warn", "error"].includes(raw.logLevel) ? raw.logLevel : "info",
|
|
440
|
+
autoUpdate: raw.autoUpdate ?? true
|
|
312
441
|
};
|
|
313
442
|
}
|
|
314
443
|
function readRaw(path) {
|
|
315
444
|
try {
|
|
316
|
-
return JSON.parse(
|
|
445
|
+
return JSON.parse(readFileSync2(path, "utf8"));
|
|
317
446
|
} catch (e) {
|
|
318
447
|
if (e?.code !== "ENOENT") {
|
|
319
448
|
console.error(`hindsight: ignoring invalid config at ${path}: ${e?.message || e}`);
|
|
@@ -366,13 +495,15 @@ var ENV_KEYS = {
|
|
|
366
495
|
surveyBudgetUsd: "HINDSIGHT_SURVEY_BUDGET_USD",
|
|
367
496
|
surveyRefreshCommits: "HINDSIGHT_SURVEY_REFRESH_COMMITS",
|
|
368
497
|
logLevel: "HINDSIGHT_LOG_LEVEL",
|
|
498
|
+
autoUpdate: "HINDSIGHT_AUTO_UPDATE",
|
|
369
499
|
gitIngest: "HINDSIGHT_GIT_INGEST",
|
|
370
500
|
// Scalar modes only ("shared", "combined", "per_tag", "all_combinations"). An explicit scope
|
|
371
501
|
// list is a list OF lists, which does not survive flattening into one variable — file-only.
|
|
372
502
|
observationScopes: "HINDSIGHT_OBSERVATION_SCOPES",
|
|
373
503
|
// Comma-separated, e.g. HINDSIGHT_RETAIN_TAGS="project:{gitProject},env:work". A LIST rather than
|
|
374
504
|
// a map, so it flattens cleanly; its sibling retainMetadata stays file-only for the reason above.
|
|
375
|
-
retainTags: "HINDSIGHT_RETAIN_TAGS"
|
|
505
|
+
retainTags: "HINDSIGHT_RETAIN_TAGS",
|
|
506
|
+
manageBankConfig: "HINDSIGHT_MANAGE_BANK_CONFIG"
|
|
376
507
|
};
|
|
377
508
|
var ENV_BOOLEANS = /* @__PURE__ */ new Set([
|
|
378
509
|
"dynamicBankId",
|
|
@@ -382,7 +513,9 @@ var ENV_BOOLEANS = /* @__PURE__ */ new Set([
|
|
|
382
513
|
"retainSessions",
|
|
383
514
|
"autoReflect",
|
|
384
515
|
"autoSeed",
|
|
385
|
-
"codebaseSurvey"
|
|
516
|
+
"codebaseSurvey",
|
|
517
|
+
"autoUpdate",
|
|
518
|
+
"manageBankConfig"
|
|
386
519
|
]);
|
|
387
520
|
var ENV_LISTS = /* @__PURE__ */ new Set(["retainTags", "optInPaths"]);
|
|
388
521
|
var ENV_NUMBERS = /* @__PURE__ */ new Set([
|
|
@@ -432,7 +565,13 @@ function arg(name) {
|
|
|
432
565
|
var command = process.argv[2] || "";
|
|
433
566
|
var repo = arg("repo") || process.cwd();
|
|
434
567
|
var cfg = loadConfig({ harness: "claude-code" });
|
|
435
|
-
var bankId =
|
|
568
|
+
var bankId = deriveBankIdOrSkip(cfg, repo, "claude-code");
|
|
569
|
+
if (bankId === null) {
|
|
570
|
+
console.error(
|
|
571
|
+
`seed: cannot identify the repository at ${repo} \u2014 refusing to seed a guessed bank`
|
|
572
|
+
);
|
|
573
|
+
process.exit(1);
|
|
574
|
+
}
|
|
436
575
|
var result = seedControl(command, { repo, bankId });
|
|
437
576
|
console.log(result.message);
|
|
438
577
|
process.exit(result.ok ? 0 : 1);
|