@vectorize-io/hindsight-coding-agents 0.2.1 → 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.
@@ -296,8 +296,8 @@ var init_dist = __esm({
296
296
 
297
297
  // src/core/config.ts
298
298
  import { readFileSync } from "fs";
299
- import { homedir } from "os";
300
- import { join as join2 } from "path";
299
+ import { homedir as homedir2 } from "os";
300
+ import { join as join3 } from "path";
301
301
 
302
302
  // src/core/seed.ts
303
303
  import { spawn as realSpawn } from "child_process";
@@ -305,8 +305,14 @@ import { dirname, join } from "path";
305
305
  import { fileURLToPath } from "url";
306
306
  var DEFAULT_SEED_LIMIT = 300;
307
307
 
308
+ // src/core/bank.ts
309
+ import { execFileSync } from "child_process";
310
+ import { existsSync } from "fs";
311
+ import { homedir } from "os";
312
+ import { basename, dirname as dirname2, join as join2, normalize, sep } from "path";
313
+
308
314
  // src/core/config.ts
309
- var CONFIG_PATH = process.env.HINDSIGHT_CONFIG || join2(homedir(), ".hindsight", "coding-agent.json");
315
+ var CONFIG_PATH = process.env.HINDSIGHT_CONFIG || join3(homedir2(), ".hindsight", "coding-agent.json");
310
316
  var DEFAULT_DAEMON_PORT = 9077;
311
317
  var DEFAULT_DAEMON_IDLE_TIMEOUT = 300;
312
318
  var DEFAULT_DAEMON_PROFILE = "coding-agent";
@@ -330,11 +336,14 @@ function resolveConfig(raw = {}) {
330
336
  bankIdTemplate: raw.bankIdTemplate,
331
337
  mapPathToBank: raw.mapPathToBank,
332
338
  resolveWorktrees: raw.resolveWorktrees,
339
+ optInOnly: raw.optInOnly ?? false,
340
+ // Same shape as retainTags: a config typo must not become a path that silently approves nothing.
341
+ optInPaths: Array.isArray(raw.optInPaths) ? raw.optInPaths.filter((p) => typeof p === "string" && p.trim() !== "") : [],
333
342
  harness: raw.harness ?? "opencode",
334
343
  disabled: raw.disabled ?? false,
335
344
  retainSessions: raw.retainSessions ?? true,
336
345
  // opencode: write back by default (parity with hook-harness Stop)
337
- retainEveryTurns: raw.retainEveryTurns || 1,
346
+ maxParallelRetains: raw.maxParallelRetains || 10,
338
347
  reflectTimeoutMs: raw.reflectTimeoutMs || 12e4,
339
348
  autoReflect: raw.autoReflect ?? true,
340
349
  pageRefreshEveryTurns: raw.pageRefreshEveryTurns || 10,
@@ -390,10 +399,12 @@ var ENV_KEYS = {
390
399
  dynamicBankId: "HINDSIGHT_DYNAMIC_BANK_ID",
391
400
  bankIdTemplate: "HINDSIGHT_BANK_ID_TEMPLATE",
392
401
  resolveWorktrees: "HINDSIGHT_RESOLVE_WORKTREES",
402
+ optInOnly: "HINDSIGHT_OPT_IN_ONLY",
403
+ optInPaths: "HINDSIGHT_OPT_IN_PATHS",
393
404
  harness: "HINDSIGHT_HARNESS",
394
405
  disabled: "HINDSIGHT_DISABLED",
395
406
  retainSessions: "HINDSIGHT_RETAIN_SESSIONS",
396
- retainEveryTurns: "HINDSIGHT_RETAIN_EVERY_TURNS",
407
+ maxParallelRetains: "HINDSIGHT_MAX_PARALLEL_RETAINS",
397
408
  reflectTimeoutMs: "HINDSIGHT_REFLECT_TIMEOUT_MS",
398
409
  autoReflect: "HINDSIGHT_AUTO_REFLECT",
399
410
  pageRefreshEveryTurns: "HINDSIGHT_PAGE_REFRESH_EVERY_TURNS",
@@ -412,17 +423,18 @@ var ENV_KEYS = {
412
423
  var ENV_BOOLEANS = /* @__PURE__ */ new Set([
413
424
  "dynamicBankId",
414
425
  "resolveWorktrees",
426
+ "optInOnly",
415
427
  "disabled",
416
428
  "retainSessions",
417
429
  "autoReflect",
418
430
  "autoSeed",
419
431
  "codebaseSurvey"
420
432
  ]);
421
- var ENV_LISTS = /* @__PURE__ */ new Set(["retainTags"]);
433
+ var ENV_LISTS = /* @__PURE__ */ new Set(["retainTags", "optInPaths"]);
422
434
  var ENV_NUMBERS = /* @__PURE__ */ new Set([
423
435
  "apiPort",
424
436
  "daemonIdleTimeout",
425
- "retainEveryTurns",
437
+ "maxParallelRetains",
426
438
  "reflectTimeoutMs",
427
439
  "pageRefreshEveryTurns",
428
440
  "seedLimit",
@@ -458,8 +470,8 @@ function loadConfig(opts = {}) {
458
470
  }
459
471
 
460
472
  // src/core/daemon.ts
461
- import { execFileSync, spawn as realSpawn2 } from "child_process";
462
- import { dirname as dirname3, join as join4 } from "path";
473
+ import { execFileSync as execFileSync2, spawn as realSpawn2 } from "child_process";
474
+ import { dirname as dirname4, join as join5 } from "path";
463
475
  import { fileURLToPath as fileURLToPath2 } from "url";
464
476
 
465
477
  // src/core/diag.ts
@@ -468,7 +480,7 @@ import { appendFileSync as appendFileSync2 } from "fs";
468
480
  // src/core/log.ts
469
481
  import { appendFileSync, mkdirSync } from "fs";
470
482
  import { tmpdir } from "os";
471
- import { dirname as dirname2, join as join3 } from "path";
483
+ import { dirname as dirname3, join as join4 } from "path";
472
484
  var WEIGHT = { debug: 10, info: 20, warn: 30, error: 40 };
473
485
  var current = ["debug", "info", "warn", "error"].find(
474
486
  (l) => l === process.env.HINDSIGHT_LOG_LEVEL
@@ -477,13 +489,13 @@ function setLogLevel(level) {
477
489
  if (!process.env.HINDSIGHT_LOG_LEVEL) current = level;
478
490
  }
479
491
  function logFilePath() {
480
- return process.env.HINDSIGHT_LOG_FILE || join3(tmpdir(), "hindsight-coding-agent", "plugin.log");
492
+ return process.env.HINDSIGHT_LOG_FILE || join4(tmpdir(), "hindsight-coding-agent", "plugin.log");
481
493
  }
482
494
  function write(level, scope, msg, extra) {
483
495
  if (WEIGHT[level] < WEIGHT[current]) return;
484
496
  try {
485
497
  const file = logFilePath();
486
- mkdirSync(dirname2(file), { recursive: true });
498
+ mkdirSync(dirname3(file), { recursive: true });
487
499
  appendFileSync(
488
500
  file,
489
501
  `${(/* @__PURE__ */ new Date()).toISOString()} ${level.toUpperCase().padEnd(5)} [${scope}] ${msg}` + (extra && Object.keys(extra).length ? ` ${JSON.stringify(extra)}` : "") + "\n"
@@ -522,7 +534,7 @@ async function isServerHealthy(baseUrl, timeoutMs = 2e3) {
522
534
  function hasRustToolchain() {
523
535
  if (process.platform !== "darwin") return true;
524
536
  try {
525
- execFileSync("cargo", ["--version"], { stdio: "pipe", timeout: 1e4 });
537
+ execFileSync2("cargo", ["--version"], { stdio: "pipe", timeout: 1e4 });
526
538
  return true;
527
539
  } catch {
528
540
  return false;
@@ -530,7 +542,7 @@ function hasRustToolchain() {
530
542
  }
531
543
  function hasUvx() {
532
544
  try {
533
- execFileSync("uvx", ["--version"], { stdio: "pipe", timeout: 1e4 });
545
+ execFileSync2("uvx", ["--version"], { stdio: "pipe", timeout: 1e4 });
534
546
  return true;
535
547
  } catch {
536
548
  return false;
@@ -562,7 +574,7 @@ function detectLlm(env = process.env) {
562
574
  }
563
575
  function onPath(bin) {
564
576
  try {
565
- execFileSync("which", [bin], { stdio: "pipe", timeout: 5e3 });
577
+ execFileSync2("which", [bin], { stdio: "pipe", timeout: 5e3 });
566
578
  return true;
567
579
  } catch {
568
580
  return false;