@vectorize-io/hindsight-coding-agents 0.5.2 → 0.5.4
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 +42 -8
- package/dist/antigravity-hook.js +335 -91
- package/dist/antigravity-statusline.js +17 -10
- package/dist/antigravity-stop-hook.js +340 -92
- package/dist/claude-hook.js +335 -91
- package/dist/claude-sessionstart-hook.js +459 -132
- package/dist/claude-stop-hook.js +340 -92
- package/dist/cline.js +283 -64
- package/dist/codex-hook.js +335 -91
- package/dist/codex-sessionstart-hook.js +459 -132
- package/dist/codex-stop-hook.js +340 -92
- package/dist/copilot-hook.js +335 -91
- package/dist/copilot-sessionstart-hook.js +459 -132
- package/dist/copilot-stop-hook.js +340 -92
- package/dist/cursor-hook.js +335 -91
- package/dist/cursor-sessionstart-hook.js +459 -132
- package/dist/cursor-stop-hook.js +340 -92
- package/dist/daemon-start.js +17 -10
- package/dist/dcode-hook.js +335 -91
- package/dist/dcode-sessionstart-hook.js +459 -132
- package/dist/dcode-stop-hook.js +340 -92
- package/dist/deepen.js +113 -32
- package/dist/devin-hook.js +335 -91
- package/dist/devin-sessionstart-hook.js +459 -132
- package/dist/devin-stop-hook.js +340 -92
- package/dist/droid-hook.js +335 -91
- package/dist/droid-sessionstart-hook.js +459 -132
- package/dist/droid-stop-hook.js +340 -92
- package/dist/dsh.js +322 -101
- package/dist/grok-hook.js +335 -91
- package/dist/grok-sessionstart-hook.js +459 -132
- package/dist/grok-stop-hook.js +340 -92
- package/dist/hindsight-seed.js +17 -10
- package/dist/index.js +322 -101
- package/dist/installer.js +1252 -325
- package/dist/kilo.js +322 -101
- package/dist/mcp-server.js +100 -23
- package/dist/opencode2.js +322 -101
- package/dist/pi.js +321 -100
- package/dist/prime-agent.js +321 -100
- package/dist/qwen-hook.js +335 -91
- package/dist/qwen-sessionstart-hook.js +459 -132
- package/dist/qwen-stop-hook.js +340 -92
- package/dist/status.js +98 -21
- package/dist/survey-supervisor.js +81 -0
- package/dist/zcode-hook.js +2954 -0
- package/dist/zcode-sessionstart-hook.js +3655 -0
- package/dist/zcode-stop-hook.js +3218 -0
- package/package.json +7 -3
- package/plugin.json +1 -1
- package/skill/SKILL.md +17 -7
package/dist/mcp-server.js
CHANGED
|
@@ -31705,6 +31705,7 @@ function pagesFor(project) {
|
|
|
31705
31705
|
var PAGE_MAX_TOKENS = 4096;
|
|
31706
31706
|
var PAGE_TAGS_MATCH = "all";
|
|
31707
31707
|
var PAGE_FACT_TYPES = ["world", "experience", "observation"];
|
|
31708
|
+
var DEFAULT_PAGE_TRIGGER_CRON = "H * * * *";
|
|
31708
31709
|
var CRON_FIELD_RANGES = [
|
|
31709
31710
|
[0, 59],
|
|
31710
31711
|
// minute
|
|
@@ -31758,14 +31759,23 @@ function pageTriggerFor(trigger, bank, page) {
|
|
|
31758
31759
|
function buildPageTrigger(cfg = {}) {
|
|
31759
31760
|
const base = { fact_types: PAGE_FACT_TYPES, tags_match: PAGE_TAGS_MATCH };
|
|
31760
31761
|
switch (cfg.pageTriggerType) {
|
|
31761
|
-
case "
|
|
31762
|
-
return { ...base,
|
|
31762
|
+
case "auto-refresh":
|
|
31763
|
+
return { ...base, refresh_after_consolidation: true };
|
|
31763
31764
|
case "manual":
|
|
31764
31765
|
return { ...base, refresh_after_consolidation: false };
|
|
31766
|
+
// "cron" and an unset type alike: the default schedule stands in for a missing expression, so
|
|
31767
|
+
// a trigger built from a partial config is never a cron trigger with nothing to fire on.
|
|
31765
31768
|
default:
|
|
31766
|
-
return { ...base,
|
|
31769
|
+
return { ...base, refresh_cron: cfg.pageTriggerCron || DEFAULT_PAGE_TRIGGER_CRON };
|
|
31767
31770
|
}
|
|
31768
31771
|
}
|
|
31772
|
+
function pageTriggerDrifted(current2, desired) {
|
|
31773
|
+
return current2.tags_match !== desired.tags_match || (current2.refresh_cron ?? null) !== (desired.refresh_cron ?? null) || Boolean(current2.refresh_after_consolidation) !== Boolean(desired.refresh_after_consolidation);
|
|
31774
|
+
}
|
|
31775
|
+
function pageTriggerPatch(desired) {
|
|
31776
|
+
if (desired.refresh_after_consolidation === false) return { ...desired, refresh_cron: null };
|
|
31777
|
+
return desired;
|
|
31778
|
+
}
|
|
31769
31779
|
var CODING_BANK_TEMPLATE = {
|
|
31770
31780
|
version: "1",
|
|
31771
31781
|
bank: {
|
|
@@ -32170,9 +32180,16 @@ var HindsightClient = class {
|
|
|
32170
32180
|
body: JSON.stringify({ query, budget: opts.budget ?? "high" }),
|
|
32171
32181
|
signal: ctrl.signal
|
|
32172
32182
|
});
|
|
32173
|
-
if (!resp.ok)
|
|
32183
|
+
if (!resp.ok)
|
|
32184
|
+
throw new Error(
|
|
32185
|
+
`reflect ${resp.status} ${(await resp.text()).slice(0, 1e3)}${this.authHint(resp.status)}`
|
|
32186
|
+
);
|
|
32174
32187
|
const data = await resp.json();
|
|
32175
32188
|
return (data.text || "").trim();
|
|
32189
|
+
} catch (e) {
|
|
32190
|
+
if (ctrl.signal.aborted)
|
|
32191
|
+
throw new Error(`reflect timed out after ${opts.timeoutMs}ms`, { cause: e });
|
|
32192
|
+
throw e;
|
|
32176
32193
|
} finally {
|
|
32177
32194
|
clearTimeout(timer);
|
|
32178
32195
|
}
|
|
@@ -32305,14 +32322,14 @@ var HindsightClient = class {
|
|
|
32305
32322
|
if (r.status !== 409) created++;
|
|
32306
32323
|
} else {
|
|
32307
32324
|
const sourceDrift = hit.description !== page.source_query;
|
|
32308
|
-
const triggerDrift = hit.trigger != null && hit.trigger
|
|
32325
|
+
const triggerDrift = hit.trigger != null && pageTriggerDrifted(hit.trigger, body.trigger);
|
|
32309
32326
|
if (!sourceDrift && !triggerDrift) continue;
|
|
32310
32327
|
const patch = {};
|
|
32311
32328
|
if (sourceDrift) {
|
|
32312
32329
|
patch.source_query = page.source_query;
|
|
32313
32330
|
patch.tags = page.tags;
|
|
32314
32331
|
}
|
|
32315
|
-
if (triggerDrift) patch.trigger =
|
|
32332
|
+
if (triggerDrift) patch.trigger = pageTriggerPatch(body.trigger);
|
|
32316
32333
|
const r = await this.req(
|
|
32317
32334
|
"PATCH",
|
|
32318
32335
|
this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(hit.id)}`),
|
|
@@ -32328,9 +32345,41 @@ var HindsightClient = class {
|
|
|
32328
32345
|
updated++;
|
|
32329
32346
|
}
|
|
32330
32347
|
}
|
|
32348
|
+
const initiatives = await this.resyncInitiativeTriggers(roots, pageTrigger);
|
|
32331
32349
|
this.log(
|
|
32332
|
-
`[bank] knowledge pages seeded on ${this.bank} (scoped to ${this.project ?? this.bank}): ${created} created, ${updated} re-synced, ${pages.length - created - updated} unchanged`
|
|
32350
|
+
`[bank] knowledge pages seeded on ${this.bank} (scoped to ${this.project ?? this.bank}): ${created} created, ${updated} re-synced, ${pages.length - created - updated} unchanged` + (initiatives ? `, ${initiatives} initiative pages re-synced` : "")
|
|
32351
|
+
);
|
|
32352
|
+
}
|
|
32353
|
+
/**
|
|
32354
|
+
* Bring the captured initiative pages onto the same refresh policy as the seeded taxonomy.
|
|
32355
|
+
*
|
|
32356
|
+
* `captureInitiative` stamps this very trigger when it creates a page, so on a bank seeded under
|
|
32357
|
+
* an older default they are the same drift as the taxonomy — and on a real repo they are most of
|
|
32358
|
+
* it: five taxonomy pages against one page per initiative, each an LLM synthesis per
|
|
32359
|
+
* consolidation under the auto-refresh that used to be the default (#3506).
|
|
32360
|
+
*
|
|
32361
|
+
* Only the trigger is touched. Their `name` and `source_query` are written once, from the
|
|
32362
|
+
* initiative's own title, and re-stating either would rebuild a page whose question never
|
|
32363
|
+
* changed. The tree read above is reused rather than re-fetched.
|
|
32364
|
+
*/
|
|
32365
|
+
async resyncInitiativeTriggers(roots, pageTrigger) {
|
|
32366
|
+
const folder = roots.find(
|
|
32367
|
+
(n) => n.kind === "folder" && (n.name || "").toLowerCase() === "initiatives"
|
|
32333
32368
|
);
|
|
32369
|
+
let updated = 0;
|
|
32370
|
+
for (const page of folder?.children ?? []) {
|
|
32371
|
+
if (page.kind !== "page" || page.trigger == null) continue;
|
|
32372
|
+
const desired = pageTriggerFor(pageTrigger, this.bank, page.name);
|
|
32373
|
+
if (!pageTriggerDrifted(page.trigger, desired)) continue;
|
|
32374
|
+
const r = await this.req(
|
|
32375
|
+
"PATCH",
|
|
32376
|
+
this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(page.id)}`),
|
|
32377
|
+
{ trigger: pageTriggerPatch(desired) }
|
|
32378
|
+
);
|
|
32379
|
+
if ([404, 405, 501].includes(r.status)) break;
|
|
32380
|
+
updated++;
|
|
32381
|
+
}
|
|
32382
|
+
return updated;
|
|
32334
32383
|
}
|
|
32335
32384
|
/** URL/id-safe slug: lowercase, non-alphanumerics → "-", trim dashes, cap length; fallback "initiative". */
|
|
32336
32385
|
slugify(s) {
|
|
@@ -32353,11 +32402,13 @@ var HindsightClient = class {
|
|
|
32353
32402
|
let pageId = args.relatesToPageId;
|
|
32354
32403
|
if (!pageId) {
|
|
32355
32404
|
const folderId = await this.ensureFolder("Initiatives");
|
|
32405
|
+
const subject = this.project ?? this.bank;
|
|
32356
32406
|
const r = await this.req("POST", this.bankUrl("/knowledge-base/pages"), {
|
|
32357
32407
|
name: args.title,
|
|
32358
|
-
source_query: `Summarize the "${args.title}" initiative: what is being built or changed and why, and its current state \u2014 drawn from the project's memory
|
|
32408
|
+
source_query: `Summarize the "${args.title}" initiative: what is being built or changed and why, and its current state \u2014 drawn from the project's memory.` + pageScopeRule(subject),
|
|
32359
32409
|
parent_id: folderId,
|
|
32360
32410
|
tags: ["knowledge:feature-work"],
|
|
32411
|
+
max_tokens: PAGE_MAX_TOKENS,
|
|
32361
32412
|
trigger: pageTriggerFor(args.pageTrigger ?? buildPageTrigger(), this.bank, args.title)
|
|
32362
32413
|
});
|
|
32363
32414
|
try {
|
|
@@ -32400,17 +32451,22 @@ var HindsightClient = class {
|
|
|
32400
32451
|
var CONFIG_PATH = process.env.HINDSIGHT_CONFIG || join6(homedir2(), ".hindsight", "coding-agent.json");
|
|
32401
32452
|
var DEFAULT_DAEMON_PORT = 9077;
|
|
32402
32453
|
var DEFAULT_DAEMON_PROFILE = "coding-agent";
|
|
32403
|
-
function
|
|
32404
|
-
if (raw.pageTriggerType === "manual") return "manual";
|
|
32405
|
-
if (raw.pageTriggerType === "
|
|
32406
|
-
|
|
32407
|
-
if (cron && (!isHashedCron(cron) || parseHashedCron(cron))) return "cron";
|
|
32454
|
+
function resolvePageTrigger(raw) {
|
|
32455
|
+
if (raw.pageTriggerType === "manual") return { type: "manual" };
|
|
32456
|
+
if (raw.pageTriggerType === "auto-refresh") return { type: "auto-refresh" };
|
|
32457
|
+
if (raw.pageTriggerType !== void 0 && raw.pageTriggerType !== "cron")
|
|
32408
32458
|
log.warn(
|
|
32409
32459
|
"config",
|
|
32410
|
-
|
|
32460
|
+
`ignoring pageTriggerType=${JSON.stringify(raw.pageTriggerType)} \u2014 expected cron|auto-refresh|manual`
|
|
32411
32461
|
);
|
|
32412
|
-
|
|
32413
|
-
return "
|
|
32462
|
+
const cron = raw.pageTriggerCron?.trim();
|
|
32463
|
+
if (!cron) return { type: "cron", cron: DEFAULT_PAGE_TRIGGER_CRON };
|
|
32464
|
+
if (!isHashedCron(cron) || parseHashedCron(cron)) return { type: "cron", cron };
|
|
32465
|
+
log.warn(
|
|
32466
|
+
"config",
|
|
32467
|
+
`pageTriggerCron ${JSON.stringify(cron)} has a malformed hashed field \u2014 write \`H\` or \`H(<lo>-<hi>)\` within the field's own range, e.g. "H H(0-5) * * *" \u2014 falling back to ${JSON.stringify(DEFAULT_PAGE_TRIGGER_CRON)}`
|
|
32468
|
+
);
|
|
32469
|
+
return { type: "cron", cron: DEFAULT_PAGE_TRIGGER_CRON };
|
|
32414
32470
|
}
|
|
32415
32471
|
var DEFAULT_REFLECT_TOOL_TIMEOUT_MS = 33e4;
|
|
32416
32472
|
var REFLECT_BUDGETS = ["low", "mid", "high"];
|
|
@@ -32442,6 +32498,7 @@ function resolveObservationScopes(raw) {
|
|
|
32442
32498
|
function resolveConfig(raw = {}) {
|
|
32443
32499
|
const serverMode = ["cloud", "self-hosted", "daemon"].includes(raw.serverMode) ? raw.serverMode : "cloud";
|
|
32444
32500
|
const apiPort = raw.apiPort || DEFAULT_DAEMON_PORT;
|
|
32501
|
+
const pageTrigger = resolvePageTrigger(raw);
|
|
32445
32502
|
return {
|
|
32446
32503
|
serverMode,
|
|
32447
32504
|
// Daemon mode resolves the URL HERE rather than at each call site: every entry point already
|
|
@@ -32476,8 +32533,8 @@ function resolveConfig(raw = {}) {
|
|
|
32476
32533
|
reflectBudget: resolveReflectBudget(raw),
|
|
32477
32534
|
autoReflect: raw.autoReflect ?? true,
|
|
32478
32535
|
pageRefreshEveryTurns: raw.pageRefreshEveryTurns || 10,
|
|
32479
|
-
pageTriggerType:
|
|
32480
|
-
pageTriggerCron:
|
|
32536
|
+
pageTriggerType: pageTrigger.type,
|
|
32537
|
+
pageTriggerCron: pageTrigger.cron,
|
|
32481
32538
|
autoSeed: raw.autoSeed ?? true,
|
|
32482
32539
|
seedLimit: raw.seedLimit || DEFAULT_SEED_LIMIT,
|
|
32483
32540
|
codebaseSurvey: raw.codebaseSurvey ?? true,
|
|
@@ -32678,7 +32735,7 @@ function resolveHostMemory(harness, directory) {
|
|
|
32678
32735
|
// src/core/knowledge-tools.ts
|
|
32679
32736
|
import { existsSync as existsSync3 } from "fs";
|
|
32680
32737
|
import { homedir as homedir4 } from "os";
|
|
32681
|
-
import { join as
|
|
32738
|
+
import { join as join9 } from "path";
|
|
32682
32739
|
|
|
32683
32740
|
// src/core/status.ts
|
|
32684
32741
|
import { execFileSync as execFileSync2 } from "child_process";
|
|
@@ -32719,11 +32776,31 @@ function parsePageList(raw) {
|
|
|
32719
32776
|
}
|
|
32720
32777
|
|
|
32721
32778
|
// src/core/survey.ts
|
|
32722
|
-
import { spawn as
|
|
32779
|
+
import { spawn as realSpawn3 } from "child_process";
|
|
32780
|
+
import { createHash as createHash2 } from "crypto";
|
|
32723
32781
|
import { existsSync as existsSync2 } from "fs";
|
|
32724
|
-
import { homedir as homedir3 } from "os";
|
|
32725
|
-
import { dirname as dirname5, join as
|
|
32782
|
+
import { homedir as homedir3, tmpdir as tmpdir2 } from "os";
|
|
32783
|
+
import { dirname as dirname5, join as join8 } from "path";
|
|
32726
32784
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
32785
|
+
|
|
32786
|
+
// src/core/survey-lease.ts
|
|
32787
|
+
import { spawn as realSpawn2 } from "child_process";
|
|
32788
|
+
import { randomUUID } from "crypto";
|
|
32789
|
+
import {
|
|
32790
|
+
mkdirSync as mkdirSync2,
|
|
32791
|
+
mkdtempSync,
|
|
32792
|
+
readdirSync,
|
|
32793
|
+
renameSync,
|
|
32794
|
+
rmdirSync,
|
|
32795
|
+
rmSync,
|
|
32796
|
+
statSync,
|
|
32797
|
+
unlinkSync,
|
|
32798
|
+
utimesSync,
|
|
32799
|
+
writeFileSync
|
|
32800
|
+
} from "fs";
|
|
32801
|
+
import { join as join7 } from "path";
|
|
32802
|
+
|
|
32803
|
+
// src/core/survey.ts
|
|
32727
32804
|
var SURVEY_DOC_IDS = [
|
|
32728
32805
|
"repository-component-map",
|
|
32729
32806
|
"repository-core-concepts",
|
|
@@ -32841,7 +32918,7 @@ function buildKnowledgeTools(client, bankId, opts = {}) {
|
|
|
32841
32918
|
inputSchema: {},
|
|
32842
32919
|
annotations: READ_ONLY_ANNOTATIONS,
|
|
32843
32920
|
handler: async (_args) => {
|
|
32844
|
-
const configPath = process.env.HINDSIGHT_CONFIG ||
|
|
32921
|
+
const configPath = process.env.HINDSIGHT_CONFIG || join9(homedir4(), ".hindsight", "coding-agent.json");
|
|
32845
32922
|
const harness = opts.harness ?? "unknown";
|
|
32846
32923
|
const cfg = applyBankConfig(
|
|
32847
32924
|
loadConfig({ harness: opts.harness }),
|