@vectorize-io/hindsight-coding-agents 0.3.4 → 0.4.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 +101 -32
- package/dist/antigravity-hook.js +449 -282
- package/dist/antigravity-statusline.js +130 -27
- package/dist/antigravity-stop-hook.js +456 -284
- package/dist/claude-hook.js +449 -282
- package/dist/claude-sessionstart-hook.js +461 -288
- package/dist/claude-stop-hook.js +456 -284
- package/dist/cline.js +652 -348
- package/dist/codex-hook.js +449 -282
- package/dist/codex-sessionstart-hook.js +461 -288
- package/dist/codex-stop-hook.js +456 -284
- package/dist/copilot-hook.js +449 -282
- package/dist/copilot-sessionstart-hook.js +461 -288
- package/dist/copilot-stop-hook.js +456 -284
- package/dist/cursor-hook.js +449 -282
- package/dist/cursor-sessionstart-hook.js +461 -288
- package/dist/cursor-stop-hook.js +456 -284
- package/dist/daemon-start.js +101 -45
- package/dist/deepen.js +314 -149
- package/dist/devin-hook.js +449 -282
- package/dist/devin-sessionstart-hook.js +461 -288
- package/dist/devin-stop-hook.js +456 -284
- package/dist/dsh.js +888 -585
- package/dist/grok-hook.js +449 -282
- package/dist/grok-sessionstart-hook.js +461 -288
- package/dist/grok-stop-hook.js +456 -284
- package/dist/hindsight-seed.js +122 -24
- package/dist/index.js +676 -371
- package/dist/installer.js +40 -48
- package/dist/kilo.js +676 -371
- package/dist/mcp-server.js +550 -318
- package/dist/prime-agent.js +888 -582
- package/dist/status.js +444 -263
- package/package.json +10 -2
- package/skill/SKILL.md +20 -4
package/dist/daemon-start.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __esm = (fn, res) => function __init() {
|
|
5
|
-
|
|
4
|
+
var __esm = (fn, res, err) => function __init() {
|
|
5
|
+
if (err) throw err[0];
|
|
6
|
+
try {
|
|
7
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
8
|
+
} catch (e) {
|
|
9
|
+
throw err = [e], e;
|
|
10
|
+
}
|
|
6
11
|
};
|
|
7
12
|
var __export = (target, all) => {
|
|
8
13
|
for (var name in all)
|
|
@@ -297,7 +302,7 @@ var init_dist = __esm({
|
|
|
297
302
|
// src/core/config.ts
|
|
298
303
|
import { readFileSync } from "fs";
|
|
299
304
|
import { homedir as homedir2 } from "os";
|
|
300
|
-
import { join as
|
|
305
|
+
import { join as join4 } from "path";
|
|
301
306
|
|
|
302
307
|
// src/core/seed.ts
|
|
303
308
|
import { spawn as realSpawn } from "child_process";
|
|
@@ -311,11 +316,80 @@ import { existsSync } from "fs";
|
|
|
311
316
|
import { homedir } from "os";
|
|
312
317
|
import { basename, dirname as dirname2, join as join2, normalize, sep } from "path";
|
|
313
318
|
|
|
319
|
+
// src/core/log.ts
|
|
320
|
+
import { appendFileSync, mkdirSync } from "fs";
|
|
321
|
+
import { tmpdir } from "os";
|
|
322
|
+
import { dirname as dirname3, join as join3 } from "path";
|
|
323
|
+
var WEIGHT = { debug: 10, info: 20, warn: 30, error: 40 };
|
|
324
|
+
var current = ["debug", "info", "warn", "error"].find(
|
|
325
|
+
(l) => l === process.env.HINDSIGHT_LOG_LEVEL
|
|
326
|
+
) ?? "info";
|
|
327
|
+
function setLogLevel(level) {
|
|
328
|
+
if (!process.env.HINDSIGHT_LOG_LEVEL) current = level;
|
|
329
|
+
}
|
|
330
|
+
function logFilePath() {
|
|
331
|
+
return process.env.HINDSIGHT_LOG_FILE || join3(tmpdir(), "hindsight-coding-agent", "plugin.log");
|
|
332
|
+
}
|
|
333
|
+
function write(level, scope, msg, extra) {
|
|
334
|
+
if (WEIGHT[level] < WEIGHT[current]) return;
|
|
335
|
+
try {
|
|
336
|
+
const file = logFilePath();
|
|
337
|
+
mkdirSync(dirname3(file), { recursive: true });
|
|
338
|
+
appendFileSync(
|
|
339
|
+
file,
|
|
340
|
+
`${(/* @__PURE__ */ new Date()).toISOString()} ${level.toUpperCase().padEnd(5)} [${scope}] ${msg}` + (extra && Object.keys(extra).length ? ` ${JSON.stringify(extra)}` : "") + "\n"
|
|
341
|
+
);
|
|
342
|
+
} catch {
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
var log = {
|
|
346
|
+
debug: (scope, msg, extra) => write("debug", scope, msg, extra),
|
|
347
|
+
info: (scope, msg, extra) => write("info", scope, msg, extra),
|
|
348
|
+
warn: (scope, msg, extra) => write("warn", scope, msg, extra),
|
|
349
|
+
error: (scope, msg, extra) => write("error", scope, msg, extra)
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
// src/core/hindsight.ts
|
|
353
|
+
var DEFAULT_OBSERVATION_SCOPES = "shared";
|
|
354
|
+
var RETRY_AFTER_FLOOR_MS = 10 * 1e3;
|
|
355
|
+
var RETRY_AFTER_CEILING_MS = 60 * 1e3;
|
|
356
|
+
|
|
314
357
|
// src/core/config.ts
|
|
315
|
-
var CONFIG_PATH = process.env.HINDSIGHT_CONFIG ||
|
|
358
|
+
var CONFIG_PATH = process.env.HINDSIGHT_CONFIG || join4(homedir2(), ".hindsight", "coding-agent.json");
|
|
316
359
|
var DEFAULT_DAEMON_PORT = 9077;
|
|
317
|
-
var DEFAULT_DAEMON_IDLE_TIMEOUT = 300;
|
|
318
360
|
var DEFAULT_DAEMON_PROFILE = "coding-agent";
|
|
361
|
+
function resolvePageTriggerType(raw) {
|
|
362
|
+
if (raw.pageTriggerType === "manual") return "manual";
|
|
363
|
+
if (raw.pageTriggerType === "cron") {
|
|
364
|
+
if (raw.pageTriggerCron?.trim()) return "cron";
|
|
365
|
+
log.warn(
|
|
366
|
+
"config",
|
|
367
|
+
'pageTriggerType "cron" needs pageTriggerCron (UTC 5-field, e.g. "0 3 * * *") \u2014 falling back to "auto-refresh"'
|
|
368
|
+
);
|
|
369
|
+
}
|
|
370
|
+
return "auto-refresh";
|
|
371
|
+
}
|
|
372
|
+
var DEFAULT_REFLECT_TOOL_TIMEOUT_MS = 33e4;
|
|
373
|
+
var REFLECT_BUDGETS = ["low", "mid", "high"];
|
|
374
|
+
function resolveReflectBudget(raw) {
|
|
375
|
+
const value = raw.reflectBudget;
|
|
376
|
+
if (value === void 0) return "high";
|
|
377
|
+
if (typeof value === "string" && REFLECT_BUDGETS.includes(value))
|
|
378
|
+
return value;
|
|
379
|
+
log.warn("config", `ignoring reflectBudget=${JSON.stringify(value)} \u2014 expected low|mid|high`);
|
|
380
|
+
return "high";
|
|
381
|
+
}
|
|
382
|
+
var OBSERVATION_SCOPE_MODES = ["shared", "combined", "per_tag", "all_combinations"];
|
|
383
|
+
function resolveObservationScopes(raw) {
|
|
384
|
+
const value = raw;
|
|
385
|
+
if (typeof value === "string")
|
|
386
|
+
return OBSERVATION_SCOPE_MODES.includes(value) ? value : DEFAULT_OBSERVATION_SCOPES;
|
|
387
|
+
if (Array.isArray(value)) {
|
|
388
|
+
const scopes = value.filter((scope) => Array.isArray(scope)).map((scope) => scope.filter((t) => typeof t === "string" && t.trim() !== ""));
|
|
389
|
+
if (scopes.length) return scopes;
|
|
390
|
+
}
|
|
391
|
+
return DEFAULT_OBSERVATION_SCOPES;
|
|
392
|
+
}
|
|
319
393
|
function resolveConfig(raw = {}) {
|
|
320
394
|
const serverMode = ["cloud", "self-hosted", "daemon"].includes(raw.serverMode) ? raw.serverMode : "cloud";
|
|
321
395
|
const apiPort = raw.apiPort || DEFAULT_DAEMON_PORT;
|
|
@@ -327,7 +401,7 @@ function resolveConfig(raw = {}) {
|
|
|
327
401
|
apiUrl: serverMode === "daemon" ? `http://127.0.0.1:${apiPort}` : raw.apiUrl ?? "https://api.hindsight.vectorize.io",
|
|
328
402
|
apiToken: raw.apiToken || void 0,
|
|
329
403
|
apiPort,
|
|
330
|
-
daemonIdleTimeout: raw.daemonIdleTimeout
|
|
404
|
+
daemonIdleTimeout: raw.daemonIdleTimeout,
|
|
331
405
|
daemonProfile: raw.daemonProfile || DEFAULT_DAEMON_PROFILE,
|
|
332
406
|
embedVersion: raw.embedVersion || void 0,
|
|
333
407
|
embedPackagePath: raw.embedPackagePath || void 0,
|
|
@@ -342,11 +416,18 @@ function resolveConfig(raw = {}) {
|
|
|
342
416
|
harness: raw.harness ?? "opencode",
|
|
343
417
|
disabled: raw.disabled ?? false,
|
|
344
418
|
retainSessions: raw.retainSessions ?? true,
|
|
345
|
-
//
|
|
419
|
+
// write sessions back by default, every harness
|
|
346
420
|
maxParallelRetains: raw.maxParallelRetains || 10,
|
|
347
421
|
reflectTimeoutMs: raw.reflectTimeoutMs || 12e4,
|
|
422
|
+
// Inherit an explicitly-raised reflectTimeoutMs (that is what users reaching for a longer
|
|
423
|
+
// reflect already set), but never let it LOWER the tool below the default — a short window is
|
|
424
|
+
// set to bound the automatic hook, not to cut off a call the agent is waiting on.
|
|
425
|
+
reflectToolTimeoutMs: raw.reflectToolTimeoutMs || Math.max(raw.reflectTimeoutMs || 0, DEFAULT_REFLECT_TOOL_TIMEOUT_MS),
|
|
426
|
+
reflectBudget: resolveReflectBudget(raw),
|
|
348
427
|
autoReflect: raw.autoReflect ?? true,
|
|
349
428
|
pageRefreshEveryTurns: raw.pageRefreshEveryTurns || 10,
|
|
429
|
+
pageTriggerType: resolvePageTriggerType(raw),
|
|
430
|
+
pageTriggerCron: raw.pageTriggerCron?.trim() || void 0,
|
|
350
431
|
autoSeed: raw.autoSeed ?? true,
|
|
351
432
|
seedLimit: raw.seedLimit || DEFAULT_SEED_LIMIT,
|
|
352
433
|
codebaseSurvey: raw.codebaseSurvey ?? true,
|
|
@@ -360,6 +441,7 @@ function resolveConfig(raw = {}) {
|
|
|
360
441
|
retainMetadata: raw.retainMetadata && typeof raw.retainMetadata === "object" ? Object.fromEntries(
|
|
361
442
|
Object.entries(raw.retainMetadata).filter(([, v]) => typeof v === "string")
|
|
362
443
|
) : {},
|
|
444
|
+
observationScopes: resolveObservationScopes(raw.observationScopes),
|
|
363
445
|
banks: raw.banks && typeof raw.banks === "object" ? raw.banks : {},
|
|
364
446
|
logLevel: ["debug", "info", "warn", "error"].includes(raw.logLevel) ? raw.logLevel : "info"
|
|
365
447
|
};
|
|
@@ -406,8 +488,12 @@ var ENV_KEYS = {
|
|
|
406
488
|
retainSessions: "HINDSIGHT_RETAIN_SESSIONS",
|
|
407
489
|
maxParallelRetains: "HINDSIGHT_MAX_PARALLEL_RETAINS",
|
|
408
490
|
reflectTimeoutMs: "HINDSIGHT_REFLECT_TIMEOUT_MS",
|
|
491
|
+
reflectToolTimeoutMs: "HINDSIGHT_REFLECT_TOOL_TIMEOUT_MS",
|
|
492
|
+
reflectBudget: "HINDSIGHT_REFLECT_BUDGET",
|
|
409
493
|
autoReflect: "HINDSIGHT_AUTO_REFLECT",
|
|
410
494
|
pageRefreshEveryTurns: "HINDSIGHT_PAGE_REFRESH_EVERY_TURNS",
|
|
495
|
+
pageTriggerType: "HINDSIGHT_PAGE_TRIGGER_TYPE",
|
|
496
|
+
pageTriggerCron: "HINDSIGHT_PAGE_TRIGGER_CRON",
|
|
411
497
|
autoSeed: "HINDSIGHT_AUTO_SEED",
|
|
412
498
|
seedLimit: "HINDSIGHT_SEED_LIMIT",
|
|
413
499
|
codebaseSurvey: "HINDSIGHT_CODEBASE_SURVEY",
|
|
@@ -416,6 +502,9 @@ var ENV_KEYS = {
|
|
|
416
502
|
surveyRefreshCommits: "HINDSIGHT_SURVEY_REFRESH_COMMITS",
|
|
417
503
|
logLevel: "HINDSIGHT_LOG_LEVEL",
|
|
418
504
|
gitIngest: "HINDSIGHT_GIT_INGEST",
|
|
505
|
+
// Scalar modes only ("shared", "combined", "per_tag", "all_combinations"). An explicit scope
|
|
506
|
+
// list is a list OF lists, which does not survive flattening into one variable — file-only.
|
|
507
|
+
observationScopes: "HINDSIGHT_OBSERVATION_SCOPES",
|
|
419
508
|
// Comma-separated, e.g. HINDSIGHT_RETAIN_TAGS="project:{gitProject},env:work". A LIST rather than
|
|
420
509
|
// a map, so it flattens cleanly; its sibling retainMetadata stays file-only for the reason above.
|
|
421
510
|
retainTags: "HINDSIGHT_RETAIN_TAGS"
|
|
@@ -436,6 +525,7 @@ var ENV_NUMBERS = /* @__PURE__ */ new Set([
|
|
|
436
525
|
"daemonIdleTimeout",
|
|
437
526
|
"maxParallelRetains",
|
|
438
527
|
"reflectTimeoutMs",
|
|
528
|
+
"reflectToolTimeoutMs",
|
|
439
529
|
"pageRefreshEveryTurns",
|
|
440
530
|
"seedLimit",
|
|
441
531
|
"surveyBudgetUsd",
|
|
@@ -476,41 +566,6 @@ import { fileURLToPath as fileURLToPath2 } from "url";
|
|
|
476
566
|
|
|
477
567
|
// src/core/diag.ts
|
|
478
568
|
import { appendFileSync as appendFileSync2 } from "fs";
|
|
479
|
-
|
|
480
|
-
// src/core/log.ts
|
|
481
|
-
import { appendFileSync, mkdirSync } from "fs";
|
|
482
|
-
import { tmpdir } from "os";
|
|
483
|
-
import { dirname as dirname3, join as join4 } from "path";
|
|
484
|
-
var WEIGHT = { debug: 10, info: 20, warn: 30, error: 40 };
|
|
485
|
-
var current = ["debug", "info", "warn", "error"].find(
|
|
486
|
-
(l) => l === process.env.HINDSIGHT_LOG_LEVEL
|
|
487
|
-
) ?? "info";
|
|
488
|
-
function setLogLevel(level) {
|
|
489
|
-
if (!process.env.HINDSIGHT_LOG_LEVEL) current = level;
|
|
490
|
-
}
|
|
491
|
-
function logFilePath() {
|
|
492
|
-
return process.env.HINDSIGHT_LOG_FILE || join4(tmpdir(), "hindsight-coding-agent", "plugin.log");
|
|
493
|
-
}
|
|
494
|
-
function write(level, scope, msg, extra) {
|
|
495
|
-
if (WEIGHT[level] < WEIGHT[current]) return;
|
|
496
|
-
try {
|
|
497
|
-
const file = logFilePath();
|
|
498
|
-
mkdirSync(dirname3(file), { recursive: true });
|
|
499
|
-
appendFileSync(
|
|
500
|
-
file,
|
|
501
|
-
`${(/* @__PURE__ */ new Date()).toISOString()} ${level.toUpperCase().padEnd(5)} [${scope}] ${msg}` + (extra && Object.keys(extra).length ? ` ${JSON.stringify(extra)}` : "") + "\n"
|
|
502
|
-
);
|
|
503
|
-
} catch {
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
var log = {
|
|
507
|
-
debug: (scope, msg, extra) => write("debug", scope, msg, extra),
|
|
508
|
-
info: (scope, msg, extra) => write("info", scope, msg, extra),
|
|
509
|
-
warn: (scope, msg, extra) => write("warn", scope, msg, extra),
|
|
510
|
-
error: (scope, msg, extra) => write("error", scope, msg, extra)
|
|
511
|
-
};
|
|
512
|
-
|
|
513
|
-
// src/core/diag.ts
|
|
514
569
|
function diagFilePath() {
|
|
515
570
|
return process.env.HINDSIGHT_DIAG_FILE || "/tmp/hindsight-plugin.log";
|
|
516
571
|
}
|
|
@@ -584,9 +639,10 @@ function onPath(bin) {
|
|
|
584
639
|
}
|
|
585
640
|
}
|
|
586
641
|
function daemonEnv(cfg, env = process.env) {
|
|
587
|
-
const out = {
|
|
588
|
-
|
|
589
|
-
|
|
642
|
+
const out = {};
|
|
643
|
+
if (cfg.daemonIdleTimeout !== void 0) {
|
|
644
|
+
out.HINDSIGHT_EMBED_DAEMON_IDLE_TIMEOUT = String(cfg.daemonIdleTimeout);
|
|
645
|
+
}
|
|
590
646
|
for (const [key, value] of Object.entries(env)) {
|
|
591
647
|
if (key.startsWith("HINDSIGHT_API_") && value) out[key] = value;
|
|
592
648
|
}
|