@vectorize-io/hindsight-coding-agents 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -0
- package/dist/antigravity-hook.js +32 -6
- package/dist/antigravity-statusline.js +124 -98
- package/dist/antigravity-stop-hook.js +32 -6
- package/dist/claude-hook.js +32 -6
- package/dist/claude-sessionstart-hook.js +32 -6
- package/dist/claude-stop-hook.js +32 -6
- package/dist/cline.js +131 -101
- package/dist/codex-hook.js +32 -6
- package/dist/codex-sessionstart-hook.js +32 -6
- package/dist/codex-stop-hook.js +32 -6
- package/dist/copilot-hook.js +32 -6
- package/dist/copilot-sessionstart-hook.js +32 -6
- package/dist/copilot-stop-hook.js +32 -6
- package/dist/cursor-hook.js +32 -6
- package/dist/cursor-sessionstart-hook.js +32 -6
- package/dist/cursor-stop-hook.js +32 -6
- package/dist/daemon-start.js +24 -12
- package/dist/deepen.js +32 -6
- package/dist/devin-hook.js +32 -6
- package/dist/devin-sessionstart-hook.js +32 -6
- package/dist/devin-stop-hook.js +32 -6
- package/dist/grok-hook.js +32 -6
- package/dist/grok-sessionstart-hook.js +32 -6
- package/dist/grok-stop-hook.js +32 -6
- package/dist/hindsight-seed.js +108 -96
- package/dist/index.js +36 -6
- package/dist/kilo.js +36 -6
- package/dist/mcp-server.js +127 -101
- package/dist/prime-agent.js +32 -6
- package/dist/status.js +31 -5
- package/package.json +1 -1
package/dist/mcp-server.js
CHANGED
|
@@ -30959,8 +30959,8 @@ var StdioServerTransport = class {
|
|
|
30959
30959
|
|
|
30960
30960
|
// src/core/config.ts
|
|
30961
30961
|
import { readFileSync } from "fs";
|
|
30962
|
-
import { homedir } from "os";
|
|
30963
|
-
import { join as
|
|
30962
|
+
import { homedir as homedir2 } from "os";
|
|
30963
|
+
import { join as join3 } from "path";
|
|
30964
30964
|
|
|
30965
30965
|
// src/core/seed.ts
|
|
30966
30966
|
import { spawn as realSpawn } from "child_process";
|
|
@@ -30968,8 +30968,117 @@ import { dirname, join } from "path";
|
|
|
30968
30968
|
import { fileURLToPath } from "url";
|
|
30969
30969
|
var DEFAULT_SEED_LIMIT = 300;
|
|
30970
30970
|
|
|
30971
|
+
// src/core/bank.ts
|
|
30972
|
+
import { execFileSync } from "child_process";
|
|
30973
|
+
import { existsSync } from "fs";
|
|
30974
|
+
import { homedir } from "os";
|
|
30975
|
+
import { basename, dirname as dirname2, join as join2, normalize, sep } from "path";
|
|
30976
|
+
|
|
30977
|
+
// src/core/template.ts
|
|
30978
|
+
var PLACEHOLDER = /\{([a-zA-Z_]+)\}/g;
|
|
30979
|
+
function applyTemplate(template, resolvers, what) {
|
|
30980
|
+
return template.replace(PLACEHOLDER, (_, name) => {
|
|
30981
|
+
const resolve2 = resolvers[name];
|
|
30982
|
+
if (!resolve2) {
|
|
30983
|
+
console.error(
|
|
30984
|
+
`hindsight: unknown ${what} placeholder "{${name}}" \u2014 valid: ` + Object.keys(resolvers).sort().map((k) => `{${k}}`).join(", ")
|
|
30985
|
+
);
|
|
30986
|
+
return "unknown";
|
|
30987
|
+
}
|
|
30988
|
+
return resolve2();
|
|
30989
|
+
});
|
|
30990
|
+
}
|
|
30991
|
+
|
|
30992
|
+
// src/core/bank.ts
|
|
30993
|
+
var DEFAULT_BANK_NAME = "coding";
|
|
30994
|
+
var DEFAULT_TEMPLATE = "coding-agent::{gitProject}";
|
|
30995
|
+
function getProjectRootFromGit(directory) {
|
|
30996
|
+
if (!directory) return null;
|
|
30997
|
+
try {
|
|
30998
|
+
const commonDir = execFileSync(
|
|
30999
|
+
"git",
|
|
31000
|
+
["rev-parse", "--path-format=absolute", "--git-common-dir"],
|
|
31001
|
+
{ cwd: directory, encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"], timeout: 1e3 }
|
|
31002
|
+
).trim();
|
|
31003
|
+
if (!commonDir) return null;
|
|
31004
|
+
return basename(commonDir) === ".git" ? dirname2(commonDir) : commonDir;
|
|
31005
|
+
} catch {
|
|
31006
|
+
return null;
|
|
31007
|
+
}
|
|
31008
|
+
}
|
|
31009
|
+
function projectNameOf(directory) {
|
|
31010
|
+
return gitProjectName(directory, true);
|
|
31011
|
+
}
|
|
31012
|
+
var PROJECT_ROOT_ENV = ["CLAUDE_PROJECT_DIR"];
|
|
31013
|
+
function nearestExistingDir(directory) {
|
|
31014
|
+
let current2 = directory;
|
|
31015
|
+
while (current2) {
|
|
31016
|
+
if (existsSync(current2)) return current2;
|
|
31017
|
+
const parent = dirname2(current2);
|
|
31018
|
+
if (parent === current2) return "";
|
|
31019
|
+
current2 = parent;
|
|
31020
|
+
}
|
|
31021
|
+
return "";
|
|
31022
|
+
}
|
|
31023
|
+
function dirName(directory) {
|
|
31024
|
+
return directory && basename(directory) || "unknown";
|
|
31025
|
+
}
|
|
31026
|
+
function gitProjectName(directory, resolveWorktrees) {
|
|
31027
|
+
if (resolveWorktrees) {
|
|
31028
|
+
const candidates = [
|
|
31029
|
+
nearestExistingDir(directory),
|
|
31030
|
+
...PROJECT_ROOT_ENV.map((v) => process.env[v] || "")
|
|
31031
|
+
];
|
|
31032
|
+
for (const candidate of candidates) {
|
|
31033
|
+
const root = candidate ? getProjectRootFromGit(candidate) : null;
|
|
31034
|
+
if (root) return basename(root);
|
|
31035
|
+
}
|
|
31036
|
+
}
|
|
31037
|
+
return dirName(directory);
|
|
31038
|
+
}
|
|
31039
|
+
function configuredDir(dir) {
|
|
31040
|
+
const expanded = dir === "~" || dir.startsWith("~/") ? join2(homedir(), dir.slice(1)) : dir;
|
|
31041
|
+
return normalize(expanded).replace(new RegExp(`\\${sep}+$`), "");
|
|
31042
|
+
}
|
|
31043
|
+
function isWithin(directory, configured) {
|
|
31044
|
+
return directory === configured || directory.startsWith(configured + sep);
|
|
31045
|
+
}
|
|
31046
|
+
function mapLookup(map2, directory) {
|
|
31047
|
+
const cwd = normalize(directory);
|
|
31048
|
+
let best;
|
|
31049
|
+
for (const [dir, bank] of Object.entries(map2)) {
|
|
31050
|
+
const p = configuredDir(dir);
|
|
31051
|
+
if (isWithin(cwd, p)) {
|
|
31052
|
+
if (!best || p.length > best.len) best = { len: p.length, bank };
|
|
31053
|
+
}
|
|
31054
|
+
}
|
|
31055
|
+
return best?.bank;
|
|
31056
|
+
}
|
|
31057
|
+
function isOptedIn(config2, directory) {
|
|
31058
|
+
if (!config2.optInOnly) return true;
|
|
31059
|
+
if (!directory) return false;
|
|
31060
|
+
const cwd = normalize(directory);
|
|
31061
|
+
if ((config2.optInPaths ?? []).some((dir) => dir && isWithin(cwd, configuredDir(dir))))
|
|
31062
|
+
return true;
|
|
31063
|
+
return Boolean(config2.mapPathToBank && mapLookup(config2.mapPathToBank, directory));
|
|
31064
|
+
}
|
|
31065
|
+
function deriveBankId(config2, directory, harness = "coding") {
|
|
31066
|
+
const mapped = directory && config2.mapPathToBank ? mapLookup(config2.mapPathToBank, directory) : void 0;
|
|
31067
|
+
if (mapped) return mapped;
|
|
31068
|
+
const dynamic = config2.dynamicBankId ?? !config2.bankId;
|
|
31069
|
+
if (!dynamic) return config2.bankId || DEFAULT_BANK_NAME;
|
|
31070
|
+
const resolvers = {
|
|
31071
|
+
harness: () => harness,
|
|
31072
|
+
project: () => dirName(directory),
|
|
31073
|
+
gitProject: () => gitProjectName(directory, config2.resolveWorktrees ?? true),
|
|
31074
|
+
channel: () => process.env.HINDSIGHT_CHANNEL_ID || "default",
|
|
31075
|
+
user: () => process.env.HINDSIGHT_USER_ID || "anonymous"
|
|
31076
|
+
};
|
|
31077
|
+
return applyTemplate(config2.bankIdTemplate || DEFAULT_TEMPLATE, resolvers, "bankIdTemplate");
|
|
31078
|
+
}
|
|
31079
|
+
|
|
30971
31080
|
// src/core/config.ts
|
|
30972
|
-
var CONFIG_PATH = process.env.HINDSIGHT_CONFIG ||
|
|
31081
|
+
var CONFIG_PATH = process.env.HINDSIGHT_CONFIG || join3(homedir2(), ".hindsight", "coding-agent.json");
|
|
30973
31082
|
var DEFAULT_DAEMON_PORT = 9077;
|
|
30974
31083
|
var DEFAULT_DAEMON_IDLE_TIMEOUT = 300;
|
|
30975
31084
|
var DEFAULT_DAEMON_PROFILE = "coding-agent";
|
|
@@ -30993,6 +31102,9 @@ function resolveConfig(raw = {}) {
|
|
|
30993
31102
|
bankIdTemplate: raw.bankIdTemplate,
|
|
30994
31103
|
mapPathToBank: raw.mapPathToBank,
|
|
30995
31104
|
resolveWorktrees: raw.resolveWorktrees,
|
|
31105
|
+
optInOnly: raw.optInOnly ?? false,
|
|
31106
|
+
// Same shape as retainTags: a config typo must not become a path that silently approves nothing.
|
|
31107
|
+
optInPaths: Array.isArray(raw.optInPaths) ? raw.optInPaths.filter((p) => typeof p === "string" && p.trim() !== "") : [],
|
|
30996
31108
|
harness: raw.harness ?? "opencode",
|
|
30997
31109
|
disabled: raw.disabled ?? false,
|
|
30998
31110
|
retainSessions: raw.retainSessions ?? true,
|
|
@@ -31053,6 +31165,8 @@ var ENV_KEYS = {
|
|
|
31053
31165
|
dynamicBankId: "HINDSIGHT_DYNAMIC_BANK_ID",
|
|
31054
31166
|
bankIdTemplate: "HINDSIGHT_BANK_ID_TEMPLATE",
|
|
31055
31167
|
resolveWorktrees: "HINDSIGHT_RESOLVE_WORKTREES",
|
|
31168
|
+
optInOnly: "HINDSIGHT_OPT_IN_ONLY",
|
|
31169
|
+
optInPaths: "HINDSIGHT_OPT_IN_PATHS",
|
|
31056
31170
|
harness: "HINDSIGHT_HARNESS",
|
|
31057
31171
|
disabled: "HINDSIGHT_DISABLED",
|
|
31058
31172
|
retainSessions: "HINDSIGHT_RETAIN_SESSIONS",
|
|
@@ -31075,13 +31189,14 @@ var ENV_KEYS = {
|
|
|
31075
31189
|
var ENV_BOOLEANS = /* @__PURE__ */ new Set([
|
|
31076
31190
|
"dynamicBankId",
|
|
31077
31191
|
"resolveWorktrees",
|
|
31192
|
+
"optInOnly",
|
|
31078
31193
|
"disabled",
|
|
31079
31194
|
"retainSessions",
|
|
31080
31195
|
"autoReflect",
|
|
31081
31196
|
"autoSeed",
|
|
31082
31197
|
"codebaseSurvey"
|
|
31083
31198
|
]);
|
|
31084
|
-
var ENV_LISTS = /* @__PURE__ */ new Set(["retainTags"]);
|
|
31199
|
+
var ENV_LISTS = /* @__PURE__ */ new Set(["retainTags", "optInPaths"]);
|
|
31085
31200
|
var ENV_NUMBERS = /* @__PURE__ */ new Set([
|
|
31086
31201
|
"apiPort",
|
|
31087
31202
|
"daemonIdleTimeout",
|
|
@@ -31125,9 +31240,15 @@ var BANK_OVERRIDE_EXCLUDED = [
|
|
|
31125
31240
|
"mapPathToBank",
|
|
31126
31241
|
"dynamicBankId",
|
|
31127
31242
|
"resolveWorktrees",
|
|
31243
|
+
// Approval is decided BEFORE the bank is resolved, so a `banks.<id>` section naming these could
|
|
31244
|
+
// only ever arrive too late to matter — strip them rather than let them read as effective.
|
|
31245
|
+
"optInOnly",
|
|
31246
|
+
"optInPaths",
|
|
31128
31247
|
"harness"
|
|
31129
31248
|
];
|
|
31130
|
-
function applyBankConfig(cfg, resolvedId) {
|
|
31249
|
+
function applyBankConfig(cfg, resolvedId, directory) {
|
|
31250
|
+
if (directory !== void 0 && !isOptedIn(cfg, directory))
|
|
31251
|
+
return { cfg: { ...cfg, disabled: true }, bankId: resolvedId };
|
|
31131
31252
|
const section = cfg.banks[resolvedId];
|
|
31132
31253
|
if (!section) return { cfg, bankId: resolvedId };
|
|
31133
31254
|
const safe = { ...section };
|
|
@@ -31147,101 +31268,6 @@ function resolvePartial(cfg, patch) {
|
|
|
31147
31268
|
return out;
|
|
31148
31269
|
}
|
|
31149
31270
|
|
|
31150
|
-
// src/core/bank.ts
|
|
31151
|
-
import { execFileSync } from "child_process";
|
|
31152
|
-
import { existsSync } from "fs";
|
|
31153
|
-
import { homedir as homedir2 } from "os";
|
|
31154
|
-
import { basename, dirname as dirname2, join as join3, normalize, sep } from "path";
|
|
31155
|
-
|
|
31156
|
-
// src/core/template.ts
|
|
31157
|
-
var PLACEHOLDER = /\{([a-zA-Z_]+)\}/g;
|
|
31158
|
-
function applyTemplate(template, resolvers, what) {
|
|
31159
|
-
return template.replace(PLACEHOLDER, (_, name) => {
|
|
31160
|
-
const resolve2 = resolvers[name];
|
|
31161
|
-
if (!resolve2) {
|
|
31162
|
-
console.error(
|
|
31163
|
-
`hindsight: unknown ${what} placeholder "{${name}}" \u2014 valid: ` + Object.keys(resolvers).sort().map((k) => `{${k}}`).join(", ")
|
|
31164
|
-
);
|
|
31165
|
-
return "unknown";
|
|
31166
|
-
}
|
|
31167
|
-
return resolve2();
|
|
31168
|
-
});
|
|
31169
|
-
}
|
|
31170
|
-
|
|
31171
|
-
// src/core/bank.ts
|
|
31172
|
-
var DEFAULT_BANK_NAME = "coding";
|
|
31173
|
-
var DEFAULT_TEMPLATE = "coding-agent::{gitProject}";
|
|
31174
|
-
function getProjectRootFromGit(directory) {
|
|
31175
|
-
if (!directory) return null;
|
|
31176
|
-
try {
|
|
31177
|
-
const commonDir = execFileSync(
|
|
31178
|
-
"git",
|
|
31179
|
-
["rev-parse", "--path-format=absolute", "--git-common-dir"],
|
|
31180
|
-
{ cwd: directory, encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"], timeout: 1e3 }
|
|
31181
|
-
).trim();
|
|
31182
|
-
if (!commonDir) return null;
|
|
31183
|
-
return basename(commonDir) === ".git" ? dirname2(commonDir) : commonDir;
|
|
31184
|
-
} catch {
|
|
31185
|
-
return null;
|
|
31186
|
-
}
|
|
31187
|
-
}
|
|
31188
|
-
function projectNameOf(directory) {
|
|
31189
|
-
return gitProjectName(directory, true);
|
|
31190
|
-
}
|
|
31191
|
-
var PROJECT_ROOT_ENV = ["CLAUDE_PROJECT_DIR"];
|
|
31192
|
-
function nearestExistingDir(directory) {
|
|
31193
|
-
let current2 = directory;
|
|
31194
|
-
while (current2) {
|
|
31195
|
-
if (existsSync(current2)) return current2;
|
|
31196
|
-
const parent = dirname2(current2);
|
|
31197
|
-
if (parent === current2) return "";
|
|
31198
|
-
current2 = parent;
|
|
31199
|
-
}
|
|
31200
|
-
return "";
|
|
31201
|
-
}
|
|
31202
|
-
function dirName(directory) {
|
|
31203
|
-
return directory && basename(directory) || "unknown";
|
|
31204
|
-
}
|
|
31205
|
-
function gitProjectName(directory, resolveWorktrees) {
|
|
31206
|
-
if (resolveWorktrees) {
|
|
31207
|
-
const candidates = [
|
|
31208
|
-
nearestExistingDir(directory),
|
|
31209
|
-
...PROJECT_ROOT_ENV.map((v) => process.env[v] || "")
|
|
31210
|
-
];
|
|
31211
|
-
for (const candidate of candidates) {
|
|
31212
|
-
const root = candidate ? getProjectRootFromGit(candidate) : null;
|
|
31213
|
-
if (root) return basename(root);
|
|
31214
|
-
}
|
|
31215
|
-
}
|
|
31216
|
-
return dirName(directory);
|
|
31217
|
-
}
|
|
31218
|
-
function mapLookup(map2, directory) {
|
|
31219
|
-
const cwd = normalize(directory);
|
|
31220
|
-
let best;
|
|
31221
|
-
for (const [dir, bank] of Object.entries(map2)) {
|
|
31222
|
-
const expanded = dir === "~" || dir.startsWith("~/") ? join3(homedir2(), dir.slice(1)) : dir;
|
|
31223
|
-
const p = normalize(expanded).replace(new RegExp(`\\${sep}+$`), "");
|
|
31224
|
-
if (cwd === p || cwd.startsWith(p + sep)) {
|
|
31225
|
-
if (!best || p.length > best.len) best = { len: p.length, bank };
|
|
31226
|
-
}
|
|
31227
|
-
}
|
|
31228
|
-
return best?.bank;
|
|
31229
|
-
}
|
|
31230
|
-
function deriveBankId(config2, directory, harness = "coding") {
|
|
31231
|
-
const mapped = directory && config2.mapPathToBank ? mapLookup(config2.mapPathToBank, directory) : void 0;
|
|
31232
|
-
if (mapped) return mapped;
|
|
31233
|
-
const dynamic = config2.dynamicBankId ?? !config2.bankId;
|
|
31234
|
-
if (!dynamic) return config2.bankId || DEFAULT_BANK_NAME;
|
|
31235
|
-
const resolvers = {
|
|
31236
|
-
harness: () => harness,
|
|
31237
|
-
project: () => dirName(directory),
|
|
31238
|
-
gitProject: () => gitProjectName(directory, config2.resolveWorktrees ?? true),
|
|
31239
|
-
channel: () => process.env.HINDSIGHT_CHANNEL_ID || "default",
|
|
31240
|
-
user: () => process.env.HINDSIGHT_USER_ID || "anonymous"
|
|
31241
|
-
};
|
|
31242
|
-
return applyTemplate(config2.bankIdTemplate || DEFAULT_TEMPLATE, resolvers, "bankIdTemplate");
|
|
31243
|
-
}
|
|
31244
|
-
|
|
31245
31271
|
// src/core/missions.ts
|
|
31246
31272
|
var GIT_MISSION = "You are ingesting a single git commit: its message and its full diff. Extract the concrete technical DECISION and the CAUSE/INVARIANT it encodes, bound to the specific code entities (functions, methods, files) and behaviors it changes. Preserve exact identifiers, paths, and literal values verbatim. Preserve the 'REF-ID: <token>' marker verbatim in every fact. Capture both WHAT changed and WHY. Issue/PR references (#123, GH-123, PROJ-123) are load-bearing: keep them VERBATIM in the fact text and emit each as an ENTITY, so a later question about that issue or PR retrieves this decision.";
|
|
31247
31273
|
var GITLOG_MISSION = "You are ingesting an aggregated block of git commit MESSAGES ONLY (no diffs) \u2014 the project's recent commit-message history, newest first. Extract the project's INITIATIVES, FEATURES, ENHANCEMENTS, and notable changes or THEMES over time \u2014 what the project has been working on and how it has evolved. Do NOT extract per-line code detail (there is no diff to draw it from). Group related commits into a coherent initiative/theme where the messages make that clear; preserve exact identifiers and literal values verbatim when quoting a subject line. Keep issue/PR references (#123, GH-123) VERBATIM and emit each as an ENTITY \u2014 they are how future sessions will ask about this work.";
|
|
@@ -32225,7 +32251,7 @@ async function main() {
|
|
|
32225
32251
|
const cwd = process.env.HINDSIGHT_MCP_PROJECT_CWD || process.cwd();
|
|
32226
32252
|
const harness = process.env.HINDSIGHT_MCP_HARNESS || "claude-code";
|
|
32227
32253
|
const cfg0 = loadConfig({ harness });
|
|
32228
|
-
const { cfg, bankId } = applyBankConfig(cfg0, deriveBankId(cfg0, cwd, harness));
|
|
32254
|
+
const { cfg, bankId } = applyBankConfig(cfg0, deriveBankId(cfg0, cwd, harness), cwd);
|
|
32229
32255
|
const client = new HindsightClient({
|
|
32230
32256
|
apiUrl: cfg.apiUrl,
|
|
32231
32257
|
apiToken: cfg.apiToken,
|
package/dist/prime-agent.js
CHANGED
|
@@ -14586,18 +14586,32 @@ function gitProjectName(directory, resolveWorktrees) {
|
|
|
14586
14586
|
}
|
|
14587
14587
|
return dirName(directory);
|
|
14588
14588
|
}
|
|
14589
|
+
function configuredDir(dir) {
|
|
14590
|
+
const expanded = dir === "~" || dir.startsWith("~/") ? join(homedir(), dir.slice(1)) : dir;
|
|
14591
|
+
return normalize(expanded).replace(new RegExp(`\\${sep}+$`), "");
|
|
14592
|
+
}
|
|
14593
|
+
function isWithin(directory, configured) {
|
|
14594
|
+
return directory === configured || directory.startsWith(configured + sep);
|
|
14595
|
+
}
|
|
14589
14596
|
function mapLookup(map2, directory) {
|
|
14590
14597
|
const cwd = normalize(directory);
|
|
14591
14598
|
let best;
|
|
14592
14599
|
for (const [dir, bank] of Object.entries(map2)) {
|
|
14593
|
-
const
|
|
14594
|
-
|
|
14595
|
-
if (cwd === p || cwd.startsWith(p + sep)) {
|
|
14600
|
+
const p = configuredDir(dir);
|
|
14601
|
+
if (isWithin(cwd, p)) {
|
|
14596
14602
|
if (!best || p.length > best.len) best = { len: p.length, bank };
|
|
14597
14603
|
}
|
|
14598
14604
|
}
|
|
14599
14605
|
return best?.bank;
|
|
14600
14606
|
}
|
|
14607
|
+
function isOptedIn(config2, directory) {
|
|
14608
|
+
if (!config2.optInOnly) return true;
|
|
14609
|
+
if (!directory) return false;
|
|
14610
|
+
const cwd = normalize(directory);
|
|
14611
|
+
if ((config2.optInPaths ?? []).some((dir) => dir && isWithin(cwd, configuredDir(dir))))
|
|
14612
|
+
return true;
|
|
14613
|
+
return Boolean(config2.mapPathToBank && mapLookup(config2.mapPathToBank, directory));
|
|
14614
|
+
}
|
|
14601
14615
|
function deriveBankId(config2, directory, harness = "coding") {
|
|
14602
14616
|
const mapped = directory && config2.mapPathToBank ? mapLookup(config2.mapPathToBank, directory) : void 0;
|
|
14603
14617
|
if (mapped) return mapped;
|
|
@@ -14675,6 +14689,9 @@ function resolveConfig(raw = {}) {
|
|
|
14675
14689
|
bankIdTemplate: raw.bankIdTemplate,
|
|
14676
14690
|
mapPathToBank: raw.mapPathToBank,
|
|
14677
14691
|
resolveWorktrees: raw.resolveWorktrees,
|
|
14692
|
+
optInOnly: raw.optInOnly ?? false,
|
|
14693
|
+
// Same shape as retainTags: a config typo must not become a path that silently approves nothing.
|
|
14694
|
+
optInPaths: Array.isArray(raw.optInPaths) ? raw.optInPaths.filter((p) => typeof p === "string" && p.trim() !== "") : [],
|
|
14678
14695
|
harness: raw.harness ?? "opencode",
|
|
14679
14696
|
disabled: raw.disabled ?? false,
|
|
14680
14697
|
retainSessions: raw.retainSessions ?? true,
|
|
@@ -14735,6 +14752,8 @@ var ENV_KEYS = {
|
|
|
14735
14752
|
dynamicBankId: "HINDSIGHT_DYNAMIC_BANK_ID",
|
|
14736
14753
|
bankIdTemplate: "HINDSIGHT_BANK_ID_TEMPLATE",
|
|
14737
14754
|
resolveWorktrees: "HINDSIGHT_RESOLVE_WORKTREES",
|
|
14755
|
+
optInOnly: "HINDSIGHT_OPT_IN_ONLY",
|
|
14756
|
+
optInPaths: "HINDSIGHT_OPT_IN_PATHS",
|
|
14738
14757
|
harness: "HINDSIGHT_HARNESS",
|
|
14739
14758
|
disabled: "HINDSIGHT_DISABLED",
|
|
14740
14759
|
retainSessions: "HINDSIGHT_RETAIN_SESSIONS",
|
|
@@ -14757,13 +14776,14 @@ var ENV_KEYS = {
|
|
|
14757
14776
|
var ENV_BOOLEANS = /* @__PURE__ */ new Set([
|
|
14758
14777
|
"dynamicBankId",
|
|
14759
14778
|
"resolveWorktrees",
|
|
14779
|
+
"optInOnly",
|
|
14760
14780
|
"disabled",
|
|
14761
14781
|
"retainSessions",
|
|
14762
14782
|
"autoReflect",
|
|
14763
14783
|
"autoSeed",
|
|
14764
14784
|
"codebaseSurvey"
|
|
14765
14785
|
]);
|
|
14766
|
-
var ENV_LISTS = /* @__PURE__ */ new Set(["retainTags"]);
|
|
14786
|
+
var ENV_LISTS = /* @__PURE__ */ new Set(["retainTags", "optInPaths"]);
|
|
14767
14787
|
var ENV_NUMBERS = /* @__PURE__ */ new Set([
|
|
14768
14788
|
"apiPort",
|
|
14769
14789
|
"daemonIdleTimeout",
|
|
@@ -14807,9 +14827,15 @@ var BANK_OVERRIDE_EXCLUDED = [
|
|
|
14807
14827
|
"mapPathToBank",
|
|
14808
14828
|
"dynamicBankId",
|
|
14809
14829
|
"resolveWorktrees",
|
|
14830
|
+
// Approval is decided BEFORE the bank is resolved, so a `banks.<id>` section naming these could
|
|
14831
|
+
// only ever arrive too late to matter — strip them rather than let them read as effective.
|
|
14832
|
+
"optInOnly",
|
|
14833
|
+
"optInPaths",
|
|
14810
14834
|
"harness"
|
|
14811
14835
|
];
|
|
14812
|
-
function applyBankConfig(cfg, resolvedId) {
|
|
14836
|
+
function applyBankConfig(cfg, resolvedId, directory) {
|
|
14837
|
+
if (directory !== void 0 && !isOptedIn(cfg, directory))
|
|
14838
|
+
return { cfg: { ...cfg, disabled: true }, bankId: resolvedId };
|
|
14813
14839
|
const section = cfg.banks[resolvedId];
|
|
14814
14840
|
if (!section) return { cfg, bankId: resolvedId };
|
|
14815
14841
|
const safe = { ...section };
|
|
@@ -16842,7 +16868,7 @@ ${injection}` };
|
|
|
16842
16868
|
function createRuntime(repoPath) {
|
|
16843
16869
|
let cfg = loadConfig({ harness: HARNESS2 });
|
|
16844
16870
|
if (cfg.disabled) return void 0;
|
|
16845
|
-
const resolved = applyBankConfig(cfg, deriveBankId(cfg, repoPath, HARNESS2));
|
|
16871
|
+
const resolved = applyBankConfig(cfg, deriveBankId(cfg, repoPath, HARNESS2), repoPath);
|
|
16846
16872
|
cfg = resolved.cfg;
|
|
16847
16873
|
if (cfg.disabled) return void 0;
|
|
16848
16874
|
const client = new HindsightClient({
|
package/dist/status.js
CHANGED
|
@@ -68,18 +68,32 @@ function gitProjectName(directory, resolveWorktrees) {
|
|
|
68
68
|
}
|
|
69
69
|
return dirName(directory);
|
|
70
70
|
}
|
|
71
|
+
function configuredDir(dir) {
|
|
72
|
+
const expanded = dir === "~" || dir.startsWith("~/") ? join(homedir(), dir.slice(1)) : dir;
|
|
73
|
+
return normalize(expanded).replace(new RegExp(`\\${sep}+$`), "");
|
|
74
|
+
}
|
|
75
|
+
function isWithin(directory, configured) {
|
|
76
|
+
return directory === configured || directory.startsWith(configured + sep);
|
|
77
|
+
}
|
|
71
78
|
function mapLookup(map, directory) {
|
|
72
79
|
const cwd = normalize(directory);
|
|
73
80
|
let best;
|
|
74
81
|
for (const [dir, bank] of Object.entries(map)) {
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
if (cwd === p || cwd.startsWith(p + sep)) {
|
|
82
|
+
const p = configuredDir(dir);
|
|
83
|
+
if (isWithin(cwd, p)) {
|
|
78
84
|
if (!best || p.length > best.len) best = { len: p.length, bank };
|
|
79
85
|
}
|
|
80
86
|
}
|
|
81
87
|
return best?.bank;
|
|
82
88
|
}
|
|
89
|
+
function isOptedIn(config, directory) {
|
|
90
|
+
if (!config.optInOnly) return true;
|
|
91
|
+
if (!directory) return false;
|
|
92
|
+
const cwd = normalize(directory);
|
|
93
|
+
if ((config.optInPaths ?? []).some((dir) => dir && isWithin(cwd, configuredDir(dir))))
|
|
94
|
+
return true;
|
|
95
|
+
return Boolean(config.mapPathToBank && mapLookup(config.mapPathToBank, directory));
|
|
96
|
+
}
|
|
83
97
|
function deriveBankId(config, directory, harness = "coding") {
|
|
84
98
|
const mapped = directory && config.mapPathToBank ? mapLookup(config.mapPathToBank, directory) : void 0;
|
|
85
99
|
if (mapped) return mapped;
|
|
@@ -131,6 +145,9 @@ function resolveConfig(raw = {}) {
|
|
|
131
145
|
bankIdTemplate: raw.bankIdTemplate,
|
|
132
146
|
mapPathToBank: raw.mapPathToBank,
|
|
133
147
|
resolveWorktrees: raw.resolveWorktrees,
|
|
148
|
+
optInOnly: raw.optInOnly ?? false,
|
|
149
|
+
// Same shape as retainTags: a config typo must not become a path that silently approves nothing.
|
|
150
|
+
optInPaths: Array.isArray(raw.optInPaths) ? raw.optInPaths.filter((p) => typeof p === "string" && p.trim() !== "") : [],
|
|
134
151
|
harness: raw.harness ?? "opencode",
|
|
135
152
|
disabled: raw.disabled ?? false,
|
|
136
153
|
retainSessions: raw.retainSessions ?? true,
|
|
@@ -191,6 +208,8 @@ var ENV_KEYS = {
|
|
|
191
208
|
dynamicBankId: "HINDSIGHT_DYNAMIC_BANK_ID",
|
|
192
209
|
bankIdTemplate: "HINDSIGHT_BANK_ID_TEMPLATE",
|
|
193
210
|
resolveWorktrees: "HINDSIGHT_RESOLVE_WORKTREES",
|
|
211
|
+
optInOnly: "HINDSIGHT_OPT_IN_ONLY",
|
|
212
|
+
optInPaths: "HINDSIGHT_OPT_IN_PATHS",
|
|
194
213
|
harness: "HINDSIGHT_HARNESS",
|
|
195
214
|
disabled: "HINDSIGHT_DISABLED",
|
|
196
215
|
retainSessions: "HINDSIGHT_RETAIN_SESSIONS",
|
|
@@ -213,13 +232,14 @@ var ENV_KEYS = {
|
|
|
213
232
|
var ENV_BOOLEANS = /* @__PURE__ */ new Set([
|
|
214
233
|
"dynamicBankId",
|
|
215
234
|
"resolveWorktrees",
|
|
235
|
+
"optInOnly",
|
|
216
236
|
"disabled",
|
|
217
237
|
"retainSessions",
|
|
218
238
|
"autoReflect",
|
|
219
239
|
"autoSeed",
|
|
220
240
|
"codebaseSurvey"
|
|
221
241
|
]);
|
|
222
|
-
var ENV_LISTS = /* @__PURE__ */ new Set(["retainTags"]);
|
|
242
|
+
var ENV_LISTS = /* @__PURE__ */ new Set(["retainTags", "optInPaths"]);
|
|
223
243
|
var ENV_NUMBERS = /* @__PURE__ */ new Set([
|
|
224
244
|
"apiPort",
|
|
225
245
|
"daemonIdleTimeout",
|
|
@@ -263,9 +283,15 @@ var BANK_OVERRIDE_EXCLUDED = [
|
|
|
263
283
|
"mapPathToBank",
|
|
264
284
|
"dynamicBankId",
|
|
265
285
|
"resolveWorktrees",
|
|
286
|
+
// Approval is decided BEFORE the bank is resolved, so a `banks.<id>` section naming these could
|
|
287
|
+
// only ever arrive too late to matter — strip them rather than let them read as effective.
|
|
288
|
+
"optInOnly",
|
|
289
|
+
"optInPaths",
|
|
266
290
|
"harness"
|
|
267
291
|
];
|
|
268
|
-
function applyBankConfig(cfg2, resolvedId) {
|
|
292
|
+
function applyBankConfig(cfg2, resolvedId, directory) {
|
|
293
|
+
if (directory !== void 0 && !isOptedIn(cfg2, directory))
|
|
294
|
+
return { cfg: { ...cfg2, disabled: true }, bankId: resolvedId };
|
|
269
295
|
const section = cfg2.banks[resolvedId];
|
|
270
296
|
if (!section) return { cfg: cfg2, bankId: resolvedId };
|
|
271
297
|
const safe = { ...section };
|