@vectorize-io/hindsight-coding-agents 0.1.2 → 0.2.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 +30 -3
- package/dist/antigravity-hook.js +73 -15
- package/dist/antigravity-statusline.js +32 -12
- package/dist/antigravity-stop-hook.js +143 -21
- package/dist/claude-hook.js +73 -15
- package/dist/claude-sessionstart-hook.js +73 -15
- package/dist/claude-stop-hook.js +143 -21
- package/dist/cline.js +141 -21
- package/dist/codex-hook.js +73 -15
- package/dist/codex-sessionstart-hook.js +73 -15
- package/dist/codex-stop-hook.js +143 -21
- package/dist/copilot-hook.js +73 -15
- package/dist/copilot-sessionstart-hook.js +73 -15
- package/dist/copilot-stop-hook.js +143 -21
- package/dist/cursor-hook.js +73 -15
- package/dist/cursor-sessionstart-hook.js +73 -15
- package/dist/cursor-stop-hook.js +143 -21
- package/dist/daemon-start.js +14 -1
- package/dist/deepen.js +69 -14
- package/dist/devin-hook.js +73 -15
- package/dist/devin-sessionstart-hook.js +73 -15
- package/dist/devin-stop-hook.js +143 -21
- package/dist/grok-hook.js +73 -15
- package/dist/grok-sessionstart-hook.js +73 -15
- package/dist/grok-stop-hook.js +143 -21
- package/dist/hindsight-seed.js +32 -12
- package/dist/index.js +142 -22
- package/dist/installer.js +4 -1
- package/dist/kilo.js +142 -22
- package/dist/mcp-server.js +70 -15
- package/dist/status.js +69 -14
- package/package.json +1 -1
package/dist/mcp-server.js
CHANGED
|
@@ -31008,6 +31008,12 @@ function resolveConfig(raw = {}) {
|
|
|
31008
31008
|
surveyBudgetUsd: raw.surveyBudgetUsd || 2,
|
|
31009
31009
|
surveyRefreshCommits: raw.surveyRefreshCommits ?? 20,
|
|
31010
31010
|
gitIngest: ["message", "full", "none"].includes(raw.gitIngest) ? raw.gitIngest : "message",
|
|
31011
|
+
// Hostile input is a config typo, not an attack: keep only string entries so a stray number or
|
|
31012
|
+
// nested object cannot reach the API as a tag and fail the whole retain.
|
|
31013
|
+
retainTags: Array.isArray(raw.retainTags) ? raw.retainTags.filter((t) => typeof t === "string" && t.trim() !== "") : [],
|
|
31014
|
+
retainMetadata: raw.retainMetadata && typeof raw.retainMetadata === "object" ? Object.fromEntries(
|
|
31015
|
+
Object.entries(raw.retainMetadata).filter(([, v]) => typeof v === "string")
|
|
31016
|
+
) : {},
|
|
31011
31017
|
banks: raw.banks && typeof raw.banks === "object" ? raw.banks : {},
|
|
31012
31018
|
logLevel: ["debug", "info", "warn", "error"].includes(raw.logLevel) ? raw.logLevel : "info"
|
|
31013
31019
|
};
|
|
@@ -31061,7 +31067,10 @@ var ENV_KEYS = {
|
|
|
31061
31067
|
surveyBudgetUsd: "HINDSIGHT_SURVEY_BUDGET_USD",
|
|
31062
31068
|
surveyRefreshCommits: "HINDSIGHT_SURVEY_REFRESH_COMMITS",
|
|
31063
31069
|
logLevel: "HINDSIGHT_LOG_LEVEL",
|
|
31064
|
-
gitIngest: "HINDSIGHT_GIT_INGEST"
|
|
31070
|
+
gitIngest: "HINDSIGHT_GIT_INGEST",
|
|
31071
|
+
// Comma-separated, e.g. HINDSIGHT_RETAIN_TAGS="project:{gitProject},env:work". A LIST rather than
|
|
31072
|
+
// a map, so it flattens cleanly; its sibling retainMetadata stays file-only for the reason above.
|
|
31073
|
+
retainTags: "HINDSIGHT_RETAIN_TAGS"
|
|
31065
31074
|
};
|
|
31066
31075
|
var ENV_BOOLEANS = /* @__PURE__ */ new Set([
|
|
31067
31076
|
"dynamicBankId",
|
|
@@ -31072,6 +31081,7 @@ var ENV_BOOLEANS = /* @__PURE__ */ new Set([
|
|
|
31072
31081
|
"autoSeed",
|
|
31073
31082
|
"codebaseSurvey"
|
|
31074
31083
|
]);
|
|
31084
|
+
var ENV_LISTS = /* @__PURE__ */ new Set(["retainTags"]);
|
|
31075
31085
|
var ENV_NUMBERS = /* @__PURE__ */ new Set([
|
|
31076
31086
|
"apiPort",
|
|
31077
31087
|
"daemonIdleTimeout",
|
|
@@ -31089,6 +31099,9 @@ function readEnvConfig(env = process.env) {
|
|
|
31089
31099
|
if (value === void 0 || value.trim() === "") continue;
|
|
31090
31100
|
if (ENV_BOOLEANS.has(key)) {
|
|
31091
31101
|
out[key] = ["1", "true", "yes", "on"].includes(value.trim().toLowerCase());
|
|
31102
|
+
} else if (ENV_LISTS.has(key)) {
|
|
31103
|
+
const items = value.split(",").map((v) => v.trim()).filter(Boolean);
|
|
31104
|
+
if (items.length) out[key] = items;
|
|
31092
31105
|
} else if (ENV_NUMBERS.has(key)) {
|
|
31093
31106
|
const n = Number(value);
|
|
31094
31107
|
if (Number.isFinite(n)) out[key] = n;
|
|
@@ -31138,9 +31151,25 @@ function resolvePartial(cfg, patch) {
|
|
|
31138
31151
|
import { execFileSync } from "child_process";
|
|
31139
31152
|
import { homedir as homedir2 } from "os";
|
|
31140
31153
|
import { basename, dirname as dirname2, join as join3, normalize, sep } from "path";
|
|
31154
|
+
|
|
31155
|
+
// src/core/template.ts
|
|
31156
|
+
var PLACEHOLDER = /\{([a-zA-Z_]+)\}/g;
|
|
31157
|
+
function applyTemplate(template, resolvers, what) {
|
|
31158
|
+
return template.replace(PLACEHOLDER, (_, name) => {
|
|
31159
|
+
const resolve2 = resolvers[name];
|
|
31160
|
+
if (!resolve2) {
|
|
31161
|
+
console.error(
|
|
31162
|
+
`hindsight: unknown ${what} placeholder "{${name}}" \u2014 valid: ` + Object.keys(resolvers).sort().map((k) => `{${k}}`).join(", ")
|
|
31163
|
+
);
|
|
31164
|
+
return "unknown";
|
|
31165
|
+
}
|
|
31166
|
+
return resolve2();
|
|
31167
|
+
});
|
|
31168
|
+
}
|
|
31169
|
+
|
|
31170
|
+
// src/core/bank.ts
|
|
31141
31171
|
var DEFAULT_BANK_NAME = "coding";
|
|
31142
31172
|
var DEFAULT_TEMPLATE = "coding-agent::{gitProject}";
|
|
31143
|
-
var PLACEHOLDER = /\{([a-zA-Z]+)\}/g;
|
|
31144
31173
|
function getProjectRootFromGit(directory) {
|
|
31145
31174
|
if (!directory) return null;
|
|
31146
31175
|
try {
|
|
@@ -31189,16 +31218,7 @@ function deriveBankId(config2, directory, harness = "coding") {
|
|
|
31189
31218
|
channel: () => process.env.HINDSIGHT_CHANNEL_ID || "default",
|
|
31190
31219
|
user: () => process.env.HINDSIGHT_USER_ID || "anonymous"
|
|
31191
31220
|
};
|
|
31192
|
-
return (config2.bankIdTemplate || DEFAULT_TEMPLATE
|
|
31193
|
-
const r = resolvers[name];
|
|
31194
|
-
if (!r) {
|
|
31195
|
-
console.error(
|
|
31196
|
-
`hindsight: unknown bankIdTemplate placeholder "{${name}}" \u2014 valid: ` + Object.keys(resolvers).sort().map((k) => `{${k}}`).join(", ")
|
|
31197
|
-
);
|
|
31198
|
-
return "unknown";
|
|
31199
|
-
}
|
|
31200
|
-
return r();
|
|
31201
|
-
});
|
|
31221
|
+
return applyTemplate(config2.bankIdTemplate || DEFAULT_TEMPLATE, resolvers, "bankIdTemplate");
|
|
31202
31222
|
}
|
|
31203
31223
|
|
|
31204
31224
|
// src/core/missions.ts
|
|
@@ -31322,6 +31342,13 @@ var CODING_BANK_TEMPLATE = {
|
|
|
31322
31342
|
entities_allow_free_form: true
|
|
31323
31343
|
}
|
|
31324
31344
|
};
|
|
31345
|
+
var CODING_BANK_STRUCTURE = {
|
|
31346
|
+
version: "1",
|
|
31347
|
+
bank: {
|
|
31348
|
+
retain_strategies: RETAIN_STRATEGIES,
|
|
31349
|
+
entity_labels: [KNOWLEDGE_LABELS]
|
|
31350
|
+
}
|
|
31351
|
+
};
|
|
31325
31352
|
|
|
31326
31353
|
// src/core/util.ts
|
|
31327
31354
|
var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
@@ -31349,6 +31376,7 @@ var KnowledgePagesUnavailableError = class extends Error {
|
|
|
31349
31376
|
}
|
|
31350
31377
|
};
|
|
31351
31378
|
var TERMINAL = /* @__PURE__ */ new Set(["completed", "failed", "cancelled", "error"]);
|
|
31379
|
+
var MISSION_FIELDS = ["reflect_mission", "retain_mission", "observations_mission"];
|
|
31352
31380
|
var HindsightClient = class {
|
|
31353
31381
|
apiUrl;
|
|
31354
31382
|
apiToken;
|
|
@@ -31465,12 +31493,39 @@ var HindsightClient = class {
|
|
|
31465
31493
|
await this.req("DELETE", this.bankUrl());
|
|
31466
31494
|
this.log(`[bank] reset ${this.bank}`);
|
|
31467
31495
|
}
|
|
31468
|
-
|
|
31496
|
+
const seeded = opts.reset ? false : await this.hasBankMissions();
|
|
31497
|
+
await this.req(
|
|
31498
|
+
"POST",
|
|
31499
|
+
this.bankUrl("/import"),
|
|
31500
|
+
seeded ? CODING_BANK_STRUCTURE : CODING_BANK_TEMPLATE
|
|
31501
|
+
);
|
|
31469
31502
|
this.log(
|
|
31470
|
-
`[bank] template applied to ${this.bank}: missions, entity_labels {knowledge}, strategies {git, gitlog, conversation, document}`
|
|
31503
|
+
seeded ? `[bank] structure applied to ${this.bank}: entity_labels {knowledge}, strategies {git, gitlog, conversation, document} \u2014 missions left as configured` : `[bank] template applied to ${this.bank}: missions, entity_labels {knowledge}, strategies {git, gitlog, conversation, document}`
|
|
31471
31504
|
);
|
|
31472
31505
|
await this.seedPages();
|
|
31473
31506
|
}
|
|
31507
|
+
/**
|
|
31508
|
+
* Whether this bank already carries bank-level mission overrides — ours from an earlier seed, or
|
|
31509
|
+
* the user's own edit. Either way they are not ours to overwrite.
|
|
31510
|
+
*
|
|
31511
|
+
* Reads the bank-scoped OVERRIDES, not the resolved config, so inherited global defaults don't
|
|
31512
|
+
* read as "already set". A missing bank, or a deployment with the bank-config API switched off,
|
|
31513
|
+
* answers false: there is nothing to preserve, and without that API a user cannot set per-bank
|
|
31514
|
+
* missions in the first place.
|
|
31515
|
+
*/
|
|
31516
|
+
async hasBankMissions() {
|
|
31517
|
+
try {
|
|
31518
|
+
const r = await this.req("GET", this.bankUrl("/config"));
|
|
31519
|
+
if (!r.ok) return false;
|
|
31520
|
+
const j = await r.json();
|
|
31521
|
+
return MISSION_FIELDS.some((f) => {
|
|
31522
|
+
const v = j.overrides?.[f];
|
|
31523
|
+
return typeof v === "string" && v.trim() !== "";
|
|
31524
|
+
});
|
|
31525
|
+
} catch {
|
|
31526
|
+
return false;
|
|
31527
|
+
}
|
|
31528
|
+
}
|
|
31474
31529
|
/** Delete one document (cascades its memory units/links). Used by deepen's self-cleanup. */
|
|
31475
31530
|
async deleteDocument(documentId) {
|
|
31476
31531
|
await this.req("DELETE", this.bankUrl(`/documents/${encodeURIComponent(documentId)}`));
|
|
@@ -31985,7 +32040,7 @@ function buildKnowledgeTools(client, bankId, opts = {}) {
|
|
|
31985
32040
|
|
|
31986
32041
|
// src/mcp-server.ts
|
|
31987
32042
|
function selectTools(cfg, client, bankId) {
|
|
31988
|
-
return cfg.disabled ? [] : buildKnowledgeTools(client, bankId, { repoDir: process.cwd() });
|
|
32043
|
+
return cfg.disabled ? [] : buildKnowledgeTools(client, bankId, { repoDir: process.cwd(), harness: cfg.harness });
|
|
31989
32044
|
}
|
|
31990
32045
|
async function main() {
|
|
31991
32046
|
const cwd = process.env.HINDSIGHT_MCP_PROJECT_CWD || process.cwd();
|
package/dist/status.js
CHANGED
|
@@ -4,9 +4,25 @@
|
|
|
4
4
|
import { execFileSync } from "child_process";
|
|
5
5
|
import { homedir } from "os";
|
|
6
6
|
import { basename, dirname, join, normalize, sep } from "path";
|
|
7
|
+
|
|
8
|
+
// src/core/template.ts
|
|
9
|
+
var PLACEHOLDER = /\{([a-zA-Z_]+)\}/g;
|
|
10
|
+
function applyTemplate(template, resolvers, what) {
|
|
11
|
+
return template.replace(PLACEHOLDER, (_, name) => {
|
|
12
|
+
const resolve2 = resolvers[name];
|
|
13
|
+
if (!resolve2) {
|
|
14
|
+
console.error(
|
|
15
|
+
`hindsight: unknown ${what} placeholder "{${name}}" \u2014 valid: ` + Object.keys(resolvers).sort().map((k) => `{${k}}`).join(", ")
|
|
16
|
+
);
|
|
17
|
+
return "unknown";
|
|
18
|
+
}
|
|
19
|
+
return resolve2();
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// src/core/bank.ts
|
|
7
24
|
var DEFAULT_BANK_NAME = "coding";
|
|
8
25
|
var DEFAULT_TEMPLATE = "coding-agent::{gitProject}";
|
|
9
|
-
var PLACEHOLDER = /\{([a-zA-Z]+)\}/g;
|
|
10
26
|
function getProjectRootFromGit(directory) {
|
|
11
27
|
if (!directory) return null;
|
|
12
28
|
try {
|
|
@@ -55,16 +71,7 @@ function deriveBankId(config, directory, harness = "coding") {
|
|
|
55
71
|
channel: () => process.env.HINDSIGHT_CHANNEL_ID || "default",
|
|
56
72
|
user: () => process.env.HINDSIGHT_USER_ID || "anonymous"
|
|
57
73
|
};
|
|
58
|
-
return (config.bankIdTemplate || DEFAULT_TEMPLATE
|
|
59
|
-
const r = resolvers[name];
|
|
60
|
-
if (!r) {
|
|
61
|
-
console.error(
|
|
62
|
-
`hindsight: unknown bankIdTemplate placeholder "{${name}}" \u2014 valid: ` + Object.keys(resolvers).sort().map((k) => `{${k}}`).join(", ")
|
|
63
|
-
);
|
|
64
|
-
return "unknown";
|
|
65
|
-
}
|
|
66
|
-
return r();
|
|
67
|
-
});
|
|
74
|
+
return applyTemplate(config.bankIdTemplate || DEFAULT_TEMPLATE, resolvers, "bankIdTemplate");
|
|
68
75
|
}
|
|
69
76
|
|
|
70
77
|
// src/core/config.ts
|
|
@@ -118,6 +125,12 @@ function resolveConfig(raw = {}) {
|
|
|
118
125
|
surveyBudgetUsd: raw.surveyBudgetUsd || 2,
|
|
119
126
|
surveyRefreshCommits: raw.surveyRefreshCommits ?? 20,
|
|
120
127
|
gitIngest: ["message", "full", "none"].includes(raw.gitIngest) ? raw.gitIngest : "message",
|
|
128
|
+
// Hostile input is a config typo, not an attack: keep only string entries so a stray number or
|
|
129
|
+
// nested object cannot reach the API as a tag and fail the whole retain.
|
|
130
|
+
retainTags: Array.isArray(raw.retainTags) ? raw.retainTags.filter((t) => typeof t === "string" && t.trim() !== "") : [],
|
|
131
|
+
retainMetadata: raw.retainMetadata && typeof raw.retainMetadata === "object" ? Object.fromEntries(
|
|
132
|
+
Object.entries(raw.retainMetadata).filter(([, v]) => typeof v === "string")
|
|
133
|
+
) : {},
|
|
121
134
|
banks: raw.banks && typeof raw.banks === "object" ? raw.banks : {},
|
|
122
135
|
logLevel: ["debug", "info", "warn", "error"].includes(raw.logLevel) ? raw.logLevel : "info"
|
|
123
136
|
};
|
|
@@ -171,7 +184,10 @@ var ENV_KEYS = {
|
|
|
171
184
|
surveyBudgetUsd: "HINDSIGHT_SURVEY_BUDGET_USD",
|
|
172
185
|
surveyRefreshCommits: "HINDSIGHT_SURVEY_REFRESH_COMMITS",
|
|
173
186
|
logLevel: "HINDSIGHT_LOG_LEVEL",
|
|
174
|
-
gitIngest: "HINDSIGHT_GIT_INGEST"
|
|
187
|
+
gitIngest: "HINDSIGHT_GIT_INGEST",
|
|
188
|
+
// Comma-separated, e.g. HINDSIGHT_RETAIN_TAGS="project:{gitProject},env:work". A LIST rather than
|
|
189
|
+
// a map, so it flattens cleanly; its sibling retainMetadata stays file-only for the reason above.
|
|
190
|
+
retainTags: "HINDSIGHT_RETAIN_TAGS"
|
|
175
191
|
};
|
|
176
192
|
var ENV_BOOLEANS = /* @__PURE__ */ new Set([
|
|
177
193
|
"dynamicBankId",
|
|
@@ -182,6 +198,7 @@ var ENV_BOOLEANS = /* @__PURE__ */ new Set([
|
|
|
182
198
|
"autoSeed",
|
|
183
199
|
"codebaseSurvey"
|
|
184
200
|
]);
|
|
201
|
+
var ENV_LISTS = /* @__PURE__ */ new Set(["retainTags"]);
|
|
185
202
|
var ENV_NUMBERS = /* @__PURE__ */ new Set([
|
|
186
203
|
"apiPort",
|
|
187
204
|
"daemonIdleTimeout",
|
|
@@ -199,6 +216,9 @@ function readEnvConfig(env = process.env) {
|
|
|
199
216
|
if (value === void 0 || value.trim() === "") continue;
|
|
200
217
|
if (ENV_BOOLEANS.has(key)) {
|
|
201
218
|
out[key] = ["1", "true", "yes", "on"].includes(value.trim().toLowerCase());
|
|
219
|
+
} else if (ENV_LISTS.has(key)) {
|
|
220
|
+
const items = value.split(",").map((v) => v.trim()).filter(Boolean);
|
|
221
|
+
if (items.length) out[key] = items;
|
|
202
222
|
} else if (ENV_NUMBERS.has(key)) {
|
|
203
223
|
const n = Number(value);
|
|
204
224
|
if (Number.isFinite(n)) out[key] = n;
|
|
@@ -365,6 +385,13 @@ var CODING_BANK_TEMPLATE = {
|
|
|
365
385
|
entities_allow_free_form: true
|
|
366
386
|
}
|
|
367
387
|
};
|
|
388
|
+
var CODING_BANK_STRUCTURE = {
|
|
389
|
+
version: "1",
|
|
390
|
+
bank: {
|
|
391
|
+
retain_strategies: RETAIN_STRATEGIES,
|
|
392
|
+
entity_labels: [KNOWLEDGE_LABELS]
|
|
393
|
+
}
|
|
394
|
+
};
|
|
368
395
|
|
|
369
396
|
// src/core/util.ts
|
|
370
397
|
var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
@@ -392,6 +419,7 @@ var KnowledgePagesUnavailableError = class extends Error {
|
|
|
392
419
|
}
|
|
393
420
|
};
|
|
394
421
|
var TERMINAL = /* @__PURE__ */ new Set(["completed", "failed", "cancelled", "error"]);
|
|
422
|
+
var MISSION_FIELDS = ["reflect_mission", "retain_mission", "observations_mission"];
|
|
395
423
|
var HindsightClient = class {
|
|
396
424
|
apiUrl;
|
|
397
425
|
apiToken;
|
|
@@ -508,12 +536,39 @@ var HindsightClient = class {
|
|
|
508
536
|
await this.req("DELETE", this.bankUrl());
|
|
509
537
|
this.log(`[bank] reset ${this.bank}`);
|
|
510
538
|
}
|
|
511
|
-
|
|
539
|
+
const seeded = opts.reset ? false : await this.hasBankMissions();
|
|
540
|
+
await this.req(
|
|
541
|
+
"POST",
|
|
542
|
+
this.bankUrl("/import"),
|
|
543
|
+
seeded ? CODING_BANK_STRUCTURE : CODING_BANK_TEMPLATE
|
|
544
|
+
);
|
|
512
545
|
this.log(
|
|
513
|
-
`[bank] template applied to ${this.bank}: missions, entity_labels {knowledge}, strategies {git, gitlog, conversation, document}`
|
|
546
|
+
seeded ? `[bank] structure applied to ${this.bank}: entity_labels {knowledge}, strategies {git, gitlog, conversation, document} \u2014 missions left as configured` : `[bank] template applied to ${this.bank}: missions, entity_labels {knowledge}, strategies {git, gitlog, conversation, document}`
|
|
514
547
|
);
|
|
515
548
|
await this.seedPages();
|
|
516
549
|
}
|
|
550
|
+
/**
|
|
551
|
+
* Whether this bank already carries bank-level mission overrides — ours from an earlier seed, or
|
|
552
|
+
* the user's own edit. Either way they are not ours to overwrite.
|
|
553
|
+
*
|
|
554
|
+
* Reads the bank-scoped OVERRIDES, not the resolved config, so inherited global defaults don't
|
|
555
|
+
* read as "already set". A missing bank, or a deployment with the bank-config API switched off,
|
|
556
|
+
* answers false: there is nothing to preserve, and without that API a user cannot set per-bank
|
|
557
|
+
* missions in the first place.
|
|
558
|
+
*/
|
|
559
|
+
async hasBankMissions() {
|
|
560
|
+
try {
|
|
561
|
+
const r = await this.req("GET", this.bankUrl("/config"));
|
|
562
|
+
if (!r.ok) return false;
|
|
563
|
+
const j = await r.json();
|
|
564
|
+
return MISSION_FIELDS.some((f) => {
|
|
565
|
+
const v = j.overrides?.[f];
|
|
566
|
+
return typeof v === "string" && v.trim() !== "";
|
|
567
|
+
});
|
|
568
|
+
} catch {
|
|
569
|
+
return false;
|
|
570
|
+
}
|
|
571
|
+
}
|
|
517
572
|
/** Delete one document (cascades its memory units/links). Used by deepen's self-cleanup. */
|
|
518
573
|
async deleteDocument(documentId) {
|
|
519
574
|
await this.req("DELETE", this.bankUrl(`/documents/${encodeURIComponent(documentId)}`));
|