@vectorize-io/hindsight-coding-agents 0.6.1 → 0.7.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 +179 -40
- package/dist/antigravity-hook.js +343 -158
- package/dist/antigravity-statusline.js +117 -4
- package/dist/antigravity-stop-hook.js +262 -113
- package/dist/claude-hook.js +343 -158
- package/dist/claude-sessionstart-hook.js +348 -136
- package/dist/claude-stop-hook.js +262 -113
- package/dist/cline.js +493 -173
- package/dist/codex-hook.js +343 -158
- package/dist/codex-sessionstart-hook.js +348 -136
- package/dist/codex-stop-hook.js +262 -113
- package/dist/copilot-hook.js +343 -158
- package/dist/copilot-sessionstart-hook.js +348 -136
- package/dist/copilot-stop-hook.js +262 -113
- package/dist/cursor-hook.js +343 -158
- package/dist/cursor-sessionstart-hook.js +348 -136
- package/dist/cursor-stop-hook.js +262 -113
- package/dist/daemon-start.js +116 -4
- package/dist/dcode-hook.js +343 -158
- package/dist/dcode-sessionstart-hook.js +348 -136
- package/dist/dcode-stop-hook.js +262 -113
- package/dist/deepen.js +204 -47
- package/dist/devin-hook.js +343 -158
- package/dist/devin-sessionstart-hook.js +348 -136
- package/dist/devin-stop-hook.js +262 -113
- package/dist/droid-hook.js +343 -158
- package/dist/droid-sessionstart-hook.js +348 -136
- package/dist/droid-stop-hook.js +262 -113
- package/dist/dsh.js +493 -173
- package/dist/grok-hook.js +343 -158
- package/dist/grok-sessionstart-hook.js +348 -136
- package/dist/grok-stop-hook.js +262 -113
- package/dist/hindsight-seed.js +116 -4
- package/dist/index.js +493 -173
- package/dist/installer.js +92 -70
- package/dist/kilo.js +493 -173
- package/dist/mcp-server.js +230 -57
- package/dist/opencode2.js +520 -173
- package/dist/pi.js +494 -175
- package/dist/prime-agent.js +494 -175
- package/dist/qwen-hook.js +343 -158
- package/dist/qwen-sessionstart-hook.js +348 -136
- package/dist/qwen-stop-hook.js +262 -113
- package/dist/status.js +203 -47
- package/dist/zcode-hook.js +343 -158
- package/dist/zcode-sessionstart-hook.js +348 -136
- package/dist/zcode-stop-hook.js +262 -113
- package/package.json +2 -2
- package/plugin.json +1 -1
- package/skill/SKILL.md +173 -39
package/dist/hindsight-seed.js
CHANGED
|
@@ -347,6 +347,36 @@ function deriveBankIdOrSkip(config, directory, harness = "coding", sessionRoot)
|
|
|
347
347
|
|
|
348
348
|
// src/core/missions.ts
|
|
349
349
|
import { createHash } from "crypto";
|
|
350
|
+
var RETAIN_EXTRACTION_MODES = ["concise", "verbose", "verbatim", "chunks"];
|
|
351
|
+
var DEFAULT_RETAIN_EXTRACTION_MODE = "concise";
|
|
352
|
+
var PAGE_TAXONOMY = [
|
|
353
|
+
{
|
|
354
|
+
name: "Component map",
|
|
355
|
+
source_query: "From this project's commit history and past discussions, what are the main components/modules/subsystems, what is each responsible for, and how do they relate to or depend on one another? Describe the structure and responsibilities.",
|
|
356
|
+
tags: ["knowledge:component"]
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
name: "Core concepts",
|
|
360
|
+
source_query: "What are the core concepts, domain abstractions, and key entities in this project \u2014 the vocabulary a developer must understand? For each, explain what it represents and its role, drawn from how they are introduced and discussed across the history and conversations.",
|
|
361
|
+
tags: ["knowledge:concept"]
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
name: "Conventions and patterns",
|
|
365
|
+
source_query: "What conventions, idioms, and recurring patterns does this project follow \u2014 its approach to testing, error handling, naming, structure, and how changes are typically made? Describe how THIS project does things, as evidenced across its history and discussions.",
|
|
366
|
+
tags: ["knowledge:convention"]
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
name: "Key decisions and rationale",
|
|
370
|
+
source_query: "What are the significant technical decisions made in this project and the rationale behind them \u2014 the durable 'why we do it this way' a developer should know? Summarize the decisions and their reasoning from the commit rationales and past conversations.",
|
|
371
|
+
tags: ["knowledge:decision"]
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
name: "Initiatives and enhancements",
|
|
375
|
+
source_query: "Based on this repository's commit history, what are the major initiatives, features, and enhancements the project has worked on? Summarize the themes and notable changes over time. When a source memory's context carries a `[[page:<id>]]` link, repeat that link in the summary of what it describes, so each initiative links to its detailed page.",
|
|
376
|
+
tags: ["knowledge:feature-work"]
|
|
377
|
+
}
|
|
378
|
+
];
|
|
379
|
+
var PAGE_NAMES = PAGE_TAXONOMY.map((page) => page.name);
|
|
350
380
|
var DEFAULT_PAGE_TRIGGER_CRON = "H * * * *";
|
|
351
381
|
var CRON_FIELD_RANGES = [
|
|
352
382
|
[0, 59],
|
|
@@ -385,6 +415,7 @@ import { delimiter, join as join6 } from "path";
|
|
|
385
415
|
|
|
386
416
|
// src/core/hindsight.ts
|
|
387
417
|
var DEFAULT_OBSERVATION_SCOPES = "shared";
|
|
418
|
+
var DEFAULT_PAGE_SEARCH_LIMIT = 10;
|
|
388
419
|
var RETRY_AFTER_FLOOR_MS = 10 * 1e3;
|
|
389
420
|
var RETRY_AFTER_CEILING_MS = 60 * 1e3;
|
|
390
421
|
|
|
@@ -409,6 +440,63 @@ function resolvePageTrigger(raw) {
|
|
|
409
440
|
);
|
|
410
441
|
return { type: "cron", cron: DEFAULT_PAGE_TRIGGER_CRON };
|
|
411
442
|
}
|
|
443
|
+
function resolvePages(raw) {
|
|
444
|
+
const value = raw;
|
|
445
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return {};
|
|
446
|
+
const out = {};
|
|
447
|
+
for (const [name, entry] of Object.entries(value)) {
|
|
448
|
+
if (!PAGE_NAMES.some((known) => known.toLowerCase() === name.trim().toLowerCase())) {
|
|
449
|
+
log.warn(
|
|
450
|
+
"config",
|
|
451
|
+
`ignoring pages[${JSON.stringify(name)}] \u2014 no seeded page has that name; expected one of: ${PAGE_NAMES.join(", ")}`
|
|
452
|
+
);
|
|
453
|
+
continue;
|
|
454
|
+
}
|
|
455
|
+
if (entry === false) {
|
|
456
|
+
out[name] = false;
|
|
457
|
+
continue;
|
|
458
|
+
}
|
|
459
|
+
const query = entry && typeof entry === "object" && !Array.isArray(entry) ? entry.source_query : void 0;
|
|
460
|
+
if (typeof query === "string" && query.trim()) {
|
|
461
|
+
out[name] = { source_query: query };
|
|
462
|
+
continue;
|
|
463
|
+
}
|
|
464
|
+
log.warn(
|
|
465
|
+
"config",
|
|
466
|
+
`ignoring pages[${JSON.stringify(name)}]=${JSON.stringify(entry)} \u2014 expected false, or {"source_query": "<your question>"}`
|
|
467
|
+
);
|
|
468
|
+
}
|
|
469
|
+
return out;
|
|
470
|
+
}
|
|
471
|
+
function resolveCustomPages(raw) {
|
|
472
|
+
const value = raw;
|
|
473
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return {};
|
|
474
|
+
const out = {};
|
|
475
|
+
for (const [rawName, entry] of Object.entries(value)) {
|
|
476
|
+
const name = rawName.trim();
|
|
477
|
+
if (!name) continue;
|
|
478
|
+
if (PAGE_NAMES.some((known) => known.toLowerCase() === name.toLowerCase())) {
|
|
479
|
+
log.warn(
|
|
480
|
+
"config",
|
|
481
|
+
`ignoring customPages[${JSON.stringify(rawName)}] \u2014 that is a seeded page; reword it under \`pages\` instead`
|
|
482
|
+
);
|
|
483
|
+
continue;
|
|
484
|
+
}
|
|
485
|
+
const query = entry && typeof entry === "object" && !Array.isArray(entry) ? entry.source_query : void 0;
|
|
486
|
+
if (typeof query !== "string" || !query.trim()) {
|
|
487
|
+
log.warn(
|
|
488
|
+
"config",
|
|
489
|
+
`ignoring customPages[${JSON.stringify(rawName)}]=${JSON.stringify(entry)} \u2014 expected {"source_query": "<your question>"}`
|
|
490
|
+
);
|
|
491
|
+
continue;
|
|
492
|
+
}
|
|
493
|
+
const rawTags = entry.tags;
|
|
494
|
+
const tags = Array.isArray(rawTags) ? rawTags.filter((t) => typeof t === "string" && t.trim() !== "") : [];
|
|
495
|
+
out[name] = tags.length ? { source_query: query, tags } : { source_query: query };
|
|
496
|
+
}
|
|
497
|
+
return out;
|
|
498
|
+
}
|
|
499
|
+
var DEFAULT_REFLECT_TIMEOUT_MS = 2e4;
|
|
412
500
|
var DEFAULT_REFLECT_TOOL_TIMEOUT_MS = 33e4;
|
|
413
501
|
var REFLECT_BUDGETS = ["low", "mid", "high"];
|
|
414
502
|
function resolveReflectBudget(raw) {
|
|
@@ -436,6 +524,15 @@ function resolveObservationScopes(raw) {
|
|
|
436
524
|
}
|
|
437
525
|
return DEFAULT_OBSERVATION_SCOPES;
|
|
438
526
|
}
|
|
527
|
+
var AUTO_INJECT_MODES = ["reflect", "pages", "recall", "none"];
|
|
528
|
+
function resolveAutoInject(raw) {
|
|
529
|
+
if (raw.autoReflect !== void 0) {
|
|
530
|
+
const replacement = raw.autoReflect === false ? "none" : "reflect";
|
|
531
|
+
log.warn("config", `autoReflect is deprecated \u2014 use autoInject: "${replacement}" instead`);
|
|
532
|
+
}
|
|
533
|
+
if (AUTO_INJECT_MODES.includes(raw.autoInject)) return raw.autoInject;
|
|
534
|
+
return raw.autoReflect === false ? "none" : "reflect";
|
|
535
|
+
}
|
|
439
536
|
function resolveConfig(raw = {}) {
|
|
440
537
|
const serverMode = ["cloud", "self-hosted", "daemon"].includes(raw.serverMode) ? raw.serverMode : "cloud";
|
|
441
538
|
const apiPort = raw.apiPort || DEFAULT_DAEMON_PORT;
|
|
@@ -465,17 +562,28 @@ function resolveConfig(raw = {}) {
|
|
|
465
562
|
retainSessions: raw.retainSessions ?? true,
|
|
466
563
|
// write sessions back by default, every harness
|
|
467
564
|
manageBankConfig: raw.manageBankConfig ?? true,
|
|
565
|
+
retainExtractionMode: RETAIN_EXTRACTION_MODES.includes(raw.retainExtractionMode) ? raw.retainExtractionMode : DEFAULT_RETAIN_EXTRACTION_MODE,
|
|
468
566
|
maxParallelRetains: raw.maxParallelRetains || 10,
|
|
469
|
-
reflectTimeoutMs: raw.reflectTimeoutMs ||
|
|
567
|
+
reflectTimeoutMs: raw.reflectTimeoutMs || DEFAULT_REFLECT_TIMEOUT_MS,
|
|
470
568
|
// Inherit an explicitly-raised reflectTimeoutMs (that is what users reaching for a longer
|
|
471
569
|
// reflect already set), but never let it LOWER the tool below the default — a short window is
|
|
472
570
|
// set to bound the automatic hook, not to cut off a call the agent is waiting on.
|
|
473
571
|
reflectToolTimeoutMs: raw.reflectToolTimeoutMs || Math.max(raw.reflectTimeoutMs || 0, DEFAULT_REFLECT_TOOL_TIMEOUT_MS),
|
|
474
572
|
reflectBudget: resolveReflectBudget(raw),
|
|
475
|
-
|
|
476
|
-
|
|
573
|
+
autoInject: resolveAutoInject(raw),
|
|
574
|
+
pageSearchLimit: raw.pageSearchLimit || DEFAULT_PAGE_SEARCH_LIMIT,
|
|
575
|
+
// Same shape as retainMetadata: an object, or nothing. An array would spread into numeric
|
|
576
|
+
// keys and reach the API as garbage, so it is rejected like any other non-object.
|
|
577
|
+
recallOptions: raw.recallOptions && typeof raw.recallOptions === "object" && !Array.isArray(raw.recallOptions) ? { ...raw.recallOptions } : {},
|
|
578
|
+
// Every turn, not every tenth. The guide is what tells the agent WHEN to reach for memory, and
|
|
579
|
+
// at a cadence of 10 a normal session is told once, on turn 1, and never again. Measured over
|
|
580
|
+
// 40 real Claude Code turns, moving this from 10 to 1 took searches from 15% of turns to 32.5%
|
|
581
|
+
// with no wording change at all. The cost is the guide's ~2KB re-sent per turn, which caches.
|
|
582
|
+
pageRefreshEveryTurns: raw.pageRefreshEveryTurns || 1,
|
|
477
583
|
pageTriggerType: pageTrigger.type,
|
|
478
584
|
pageTriggerCron: pageTrigger.cron,
|
|
585
|
+
pages: resolvePages(raw.pages),
|
|
586
|
+
customPages: resolveCustomPages(raw.customPages),
|
|
479
587
|
autoSeed: raw.autoSeed ?? true,
|
|
480
588
|
seedLimit: raw.seedLimit || DEFAULT_SEED_LIMIT,
|
|
481
589
|
codebaseSurvey: raw.codebaseSurvey ?? true,
|
|
@@ -539,6 +647,8 @@ var ENV_KEYS = {
|
|
|
539
647
|
reflectTimeoutMs: "HINDSIGHT_REFLECT_TIMEOUT_MS",
|
|
540
648
|
reflectToolTimeoutMs: "HINDSIGHT_REFLECT_TOOL_TIMEOUT_MS",
|
|
541
649
|
reflectBudget: "HINDSIGHT_REFLECT_BUDGET",
|
|
650
|
+
autoInject: "HINDSIGHT_AUTO_INJECT",
|
|
651
|
+
pageSearchLimit: "HINDSIGHT_PAGE_SEARCH_LIMIT",
|
|
542
652
|
autoReflect: "HINDSIGHT_AUTO_REFLECT",
|
|
543
653
|
pageRefreshEveryTurns: "HINDSIGHT_PAGE_REFRESH_EVERY_TURNS",
|
|
544
654
|
pageTriggerType: "HINDSIGHT_PAGE_TRIGGER_TYPE",
|
|
@@ -558,7 +668,8 @@ var ENV_KEYS = {
|
|
|
558
668
|
// Comma-separated, e.g. HINDSIGHT_RETAIN_TAGS="project:{gitProject},env:work". A LIST rather than
|
|
559
669
|
// a map, so it flattens cleanly; its sibling retainMetadata stays file-only for the reason above.
|
|
560
670
|
retainTags: "HINDSIGHT_RETAIN_TAGS",
|
|
561
|
-
manageBankConfig: "HINDSIGHT_MANAGE_BANK_CONFIG"
|
|
671
|
+
manageBankConfig: "HINDSIGHT_MANAGE_BANK_CONFIG",
|
|
672
|
+
retainExtractionMode: "HINDSIGHT_RETAIN_EXTRACTION_MODE"
|
|
562
673
|
};
|
|
563
674
|
var ENV_BOOLEANS = /* @__PURE__ */ new Set([
|
|
564
675
|
"dynamicBankId",
|
|
@@ -579,6 +690,7 @@ var ENV_NUMBERS = /* @__PURE__ */ new Set([
|
|
|
579
690
|
"maxParallelRetains",
|
|
580
691
|
"reflectTimeoutMs",
|
|
581
692
|
"reflectToolTimeoutMs",
|
|
693
|
+
"pageSearchLimit",
|
|
582
694
|
"pageRefreshEveryTurns",
|
|
583
695
|
"seedLimit",
|
|
584
696
|
"surveyBudgetUsd",
|