@vectorize-io/hindsight-coding-agents 0.3.0 → 0.3.2

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/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 expanded = dir === "~" || dir.startsWith("~/") ? join(homedir(), dir.slice(1)) : dir;
76
- const p = normalize(expanded).replace(new RegExp(`\\${sep}+$`), "");
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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vectorize-io/hindsight-coding-agents",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/vectorize-io/hindsight.git",