@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.
- package/README.md +46 -7
- package/dist/antigravity-hook.js +175 -48
- package/dist/antigravity-statusline.js +127 -80
- package/dist/antigravity-stop-hook.js +233 -88
- package/dist/claude-hook.js +175 -48
- package/dist/claude-sessionstart-hook.js +234 -58
- package/dist/claude-stop-hook.js +233 -88
- package/dist/cline.js +351 -167
- package/dist/codex-hook.js +175 -48
- package/dist/codex-sessionstart-hook.js +234 -58
- package/dist/codex-stop-hook.js +233 -88
- package/dist/copilot-hook.js +175 -48
- package/dist/copilot-sessionstart-hook.js +234 -58
- package/dist/copilot-stop-hook.js +233 -88
- package/dist/cursor-hook.js +175 -48
- package/dist/cursor-sessionstart-hook.js +234 -58
- package/dist/cursor-stop-hook.js +233 -88
- package/dist/daemon-start.js +27 -15
- package/dist/deepen.js +688 -497
- package/dist/devin-hook.js +175 -48
- package/dist/devin-sessionstart-hook.js +234 -58
- package/dist/devin-stop-hook.js +233 -88
- package/dist/grok-hook.js +175 -48
- package/dist/grok-sessionstart-hook.js +234 -58
- package/dist/grok-stop-hook.js +233 -88
- package/dist/hindsight-seed.js +111 -78
- package/dist/index.js +282 -98
- package/dist/installer.js +86 -56
- package/dist/kilo.js +282 -98
- package/dist/mcp-server.js +327 -117
- package/dist/prime-agent.js +16900 -0
- package/dist/status.js +143 -36
- package/package.json +6 -1
package/dist/hindsight-seed.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
// src/core/config.ts
|
|
4
4
|
import { readFileSync } from "fs";
|
|
5
|
-
import { homedir } from "os";
|
|
6
|
-
import { join as
|
|
5
|
+
import { homedir as homedir2 } from "os";
|
|
6
|
+
import { join as join3 } from "path";
|
|
7
7
|
|
|
8
8
|
// src/core/seed.ts
|
|
9
9
|
import { spawn as realSpawn } from "child_process";
|
|
@@ -47,8 +47,106 @@ function seedControl(command2, args) {
|
|
|
47
47
|
return { ok: false, message: "usage: hindsight-seed seed --repo <dir>" };
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
// src/core/bank.ts
|
|
51
|
+
import { execFileSync } from "child_process";
|
|
52
|
+
import { existsSync } from "fs";
|
|
53
|
+
import { homedir } from "os";
|
|
54
|
+
import { basename, dirname as dirname2, join as join2, normalize, sep } from "path";
|
|
55
|
+
|
|
56
|
+
// src/core/template.ts
|
|
57
|
+
var PLACEHOLDER = /\{([a-zA-Z_]+)\}/g;
|
|
58
|
+
function applyTemplate(template, resolvers, what) {
|
|
59
|
+
return template.replace(PLACEHOLDER, (_, name) => {
|
|
60
|
+
const resolve = resolvers[name];
|
|
61
|
+
if (!resolve) {
|
|
62
|
+
console.error(
|
|
63
|
+
`hindsight: unknown ${what} placeholder "{${name}}" \u2014 valid: ` + Object.keys(resolvers).sort().map((k) => `{${k}}`).join(", ")
|
|
64
|
+
);
|
|
65
|
+
return "unknown";
|
|
66
|
+
}
|
|
67
|
+
return resolve();
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// src/core/bank.ts
|
|
72
|
+
var DEFAULT_BANK_NAME = "coding";
|
|
73
|
+
var DEFAULT_TEMPLATE = "coding-agent::{gitProject}";
|
|
74
|
+
function getProjectRootFromGit(directory) {
|
|
75
|
+
if (!directory) return null;
|
|
76
|
+
try {
|
|
77
|
+
const commonDir = execFileSync(
|
|
78
|
+
"git",
|
|
79
|
+
["rev-parse", "--path-format=absolute", "--git-common-dir"],
|
|
80
|
+
{ cwd: directory, encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"], timeout: 1e3 }
|
|
81
|
+
).trim();
|
|
82
|
+
if (!commonDir) return null;
|
|
83
|
+
return basename(commonDir) === ".git" ? dirname2(commonDir) : commonDir;
|
|
84
|
+
} catch {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
var PROJECT_ROOT_ENV = ["CLAUDE_PROJECT_DIR"];
|
|
89
|
+
function nearestExistingDir(directory) {
|
|
90
|
+
let current = directory;
|
|
91
|
+
while (current) {
|
|
92
|
+
if (existsSync(current)) return current;
|
|
93
|
+
const parent = dirname2(current);
|
|
94
|
+
if (parent === current) return "";
|
|
95
|
+
current = parent;
|
|
96
|
+
}
|
|
97
|
+
return "";
|
|
98
|
+
}
|
|
99
|
+
function dirName(directory) {
|
|
100
|
+
return directory && basename(directory) || "unknown";
|
|
101
|
+
}
|
|
102
|
+
function gitProjectName(directory, resolveWorktrees) {
|
|
103
|
+
if (resolveWorktrees) {
|
|
104
|
+
const candidates = [
|
|
105
|
+
nearestExistingDir(directory),
|
|
106
|
+
...PROJECT_ROOT_ENV.map((v) => process.env[v] || "")
|
|
107
|
+
];
|
|
108
|
+
for (const candidate of candidates) {
|
|
109
|
+
const root = candidate ? getProjectRootFromGit(candidate) : null;
|
|
110
|
+
if (root) return basename(root);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return dirName(directory);
|
|
114
|
+
}
|
|
115
|
+
function configuredDir(dir) {
|
|
116
|
+
const expanded = dir === "~" || dir.startsWith("~/") ? join2(homedir(), dir.slice(1)) : dir;
|
|
117
|
+
return normalize(expanded).replace(new RegExp(`\\${sep}+$`), "");
|
|
118
|
+
}
|
|
119
|
+
function isWithin(directory, configured) {
|
|
120
|
+
return directory === configured || directory.startsWith(configured + sep);
|
|
121
|
+
}
|
|
122
|
+
function mapLookup(map, directory) {
|
|
123
|
+
const cwd = normalize(directory);
|
|
124
|
+
let best;
|
|
125
|
+
for (const [dir, bank] of Object.entries(map)) {
|
|
126
|
+
const p = configuredDir(dir);
|
|
127
|
+
if (isWithin(cwd, p)) {
|
|
128
|
+
if (!best || p.length > best.len) best = { len: p.length, bank };
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return best?.bank;
|
|
132
|
+
}
|
|
133
|
+
function deriveBankId(config, directory, harness = "coding") {
|
|
134
|
+
const mapped = directory && config.mapPathToBank ? mapLookup(config.mapPathToBank, directory) : void 0;
|
|
135
|
+
if (mapped) return mapped;
|
|
136
|
+
const dynamic = config.dynamicBankId ?? !config.bankId;
|
|
137
|
+
if (!dynamic) return config.bankId || DEFAULT_BANK_NAME;
|
|
138
|
+
const resolvers = {
|
|
139
|
+
harness: () => harness,
|
|
140
|
+
project: () => dirName(directory),
|
|
141
|
+
gitProject: () => gitProjectName(directory, config.resolveWorktrees ?? true),
|
|
142
|
+
channel: () => process.env.HINDSIGHT_CHANNEL_ID || "default",
|
|
143
|
+
user: () => process.env.HINDSIGHT_USER_ID || "anonymous"
|
|
144
|
+
};
|
|
145
|
+
return applyTemplate(config.bankIdTemplate || DEFAULT_TEMPLATE, resolvers, "bankIdTemplate");
|
|
146
|
+
}
|
|
147
|
+
|
|
50
148
|
// src/core/config.ts
|
|
51
|
-
var CONFIG_PATH = process.env.HINDSIGHT_CONFIG ||
|
|
149
|
+
var CONFIG_PATH = process.env.HINDSIGHT_CONFIG || join3(homedir2(), ".hindsight", "coding-agent.json");
|
|
52
150
|
var DEFAULT_DAEMON_PORT = 9077;
|
|
53
151
|
var DEFAULT_DAEMON_IDLE_TIMEOUT = 300;
|
|
54
152
|
var DEFAULT_DAEMON_PROFILE = "coding-agent";
|
|
@@ -72,11 +170,14 @@ function resolveConfig(raw = {}) {
|
|
|
72
170
|
bankIdTemplate: raw.bankIdTemplate,
|
|
73
171
|
mapPathToBank: raw.mapPathToBank,
|
|
74
172
|
resolveWorktrees: raw.resolveWorktrees,
|
|
173
|
+
optInOnly: raw.optInOnly ?? false,
|
|
174
|
+
// Same shape as retainTags: a config typo must not become a path that silently approves nothing.
|
|
175
|
+
optInPaths: Array.isArray(raw.optInPaths) ? raw.optInPaths.filter((p) => typeof p === "string" && p.trim() !== "") : [],
|
|
75
176
|
harness: raw.harness ?? "opencode",
|
|
76
177
|
disabled: raw.disabled ?? false,
|
|
77
178
|
retainSessions: raw.retainSessions ?? true,
|
|
78
179
|
// opencode: write back by default (parity with hook-harness Stop)
|
|
79
|
-
|
|
180
|
+
maxParallelRetains: raw.maxParallelRetains || 10,
|
|
80
181
|
reflectTimeoutMs: raw.reflectTimeoutMs || 12e4,
|
|
81
182
|
autoReflect: raw.autoReflect ?? true,
|
|
82
183
|
pageRefreshEveryTurns: raw.pageRefreshEveryTurns || 10,
|
|
@@ -132,10 +233,12 @@ var ENV_KEYS = {
|
|
|
132
233
|
dynamicBankId: "HINDSIGHT_DYNAMIC_BANK_ID",
|
|
133
234
|
bankIdTemplate: "HINDSIGHT_BANK_ID_TEMPLATE",
|
|
134
235
|
resolveWorktrees: "HINDSIGHT_RESOLVE_WORKTREES",
|
|
236
|
+
optInOnly: "HINDSIGHT_OPT_IN_ONLY",
|
|
237
|
+
optInPaths: "HINDSIGHT_OPT_IN_PATHS",
|
|
135
238
|
harness: "HINDSIGHT_HARNESS",
|
|
136
239
|
disabled: "HINDSIGHT_DISABLED",
|
|
137
240
|
retainSessions: "HINDSIGHT_RETAIN_SESSIONS",
|
|
138
|
-
|
|
241
|
+
maxParallelRetains: "HINDSIGHT_MAX_PARALLEL_RETAINS",
|
|
139
242
|
reflectTimeoutMs: "HINDSIGHT_REFLECT_TIMEOUT_MS",
|
|
140
243
|
autoReflect: "HINDSIGHT_AUTO_REFLECT",
|
|
141
244
|
pageRefreshEveryTurns: "HINDSIGHT_PAGE_REFRESH_EVERY_TURNS",
|
|
@@ -154,17 +257,18 @@ var ENV_KEYS = {
|
|
|
154
257
|
var ENV_BOOLEANS = /* @__PURE__ */ new Set([
|
|
155
258
|
"dynamicBankId",
|
|
156
259
|
"resolveWorktrees",
|
|
260
|
+
"optInOnly",
|
|
157
261
|
"disabled",
|
|
158
262
|
"retainSessions",
|
|
159
263
|
"autoReflect",
|
|
160
264
|
"autoSeed",
|
|
161
265
|
"codebaseSurvey"
|
|
162
266
|
]);
|
|
163
|
-
var ENV_LISTS = /* @__PURE__ */ new Set(["retainTags"]);
|
|
267
|
+
var ENV_LISTS = /* @__PURE__ */ new Set(["retainTags", "optInPaths"]);
|
|
164
268
|
var ENV_NUMBERS = /* @__PURE__ */ new Set([
|
|
165
269
|
"apiPort",
|
|
166
270
|
"daemonIdleTimeout",
|
|
167
|
-
"
|
|
271
|
+
"maxParallelRetains",
|
|
168
272
|
"reflectTimeoutMs",
|
|
169
273
|
"pageRefreshEveryTurns",
|
|
170
274
|
"seedLimit",
|
|
@@ -199,77 +303,6 @@ function loadConfig(opts = {}) {
|
|
|
199
303
|
return resolveConfig(raw);
|
|
200
304
|
}
|
|
201
305
|
|
|
202
|
-
// src/core/bank.ts
|
|
203
|
-
import { execFileSync } from "child_process";
|
|
204
|
-
import { homedir as homedir2 } from "os";
|
|
205
|
-
import { basename, dirname as dirname2, join as join3, normalize, sep } from "path";
|
|
206
|
-
|
|
207
|
-
// src/core/template.ts
|
|
208
|
-
var PLACEHOLDER = /\{([a-zA-Z_]+)\}/g;
|
|
209
|
-
function applyTemplate(template, resolvers, what) {
|
|
210
|
-
return template.replace(PLACEHOLDER, (_, name) => {
|
|
211
|
-
const resolve = resolvers[name];
|
|
212
|
-
if (!resolve) {
|
|
213
|
-
console.error(
|
|
214
|
-
`hindsight: unknown ${what} placeholder "{${name}}" \u2014 valid: ` + Object.keys(resolvers).sort().map((k) => `{${k}}`).join(", ")
|
|
215
|
-
);
|
|
216
|
-
return "unknown";
|
|
217
|
-
}
|
|
218
|
-
return resolve();
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
// src/core/bank.ts
|
|
223
|
-
var DEFAULT_BANK_NAME = "coding";
|
|
224
|
-
var DEFAULT_TEMPLATE = "coding-agent::{gitProject}";
|
|
225
|
-
function getProjectRootFromGit(directory) {
|
|
226
|
-
if (!directory) return null;
|
|
227
|
-
try {
|
|
228
|
-
const commonDir = execFileSync(
|
|
229
|
-
"git",
|
|
230
|
-
["rev-parse", "--path-format=absolute", "--git-common-dir"],
|
|
231
|
-
{ cwd: directory, encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"], timeout: 1e3 }
|
|
232
|
-
).trim();
|
|
233
|
-
if (!commonDir) return null;
|
|
234
|
-
return basename(commonDir) === ".git" ? dirname2(commonDir) : commonDir;
|
|
235
|
-
} catch {
|
|
236
|
-
return null;
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
function gitProjectName(directory, resolveWorktrees) {
|
|
240
|
-
if (resolveWorktrees) {
|
|
241
|
-
const root = getProjectRootFromGit(directory);
|
|
242
|
-
if (root) return basename(root);
|
|
243
|
-
}
|
|
244
|
-
return directory ? basename(directory) : "unknown";
|
|
245
|
-
}
|
|
246
|
-
function mapLookup(map, directory) {
|
|
247
|
-
const cwd = normalize(directory);
|
|
248
|
-
let best;
|
|
249
|
-
for (const [dir, bank] of Object.entries(map)) {
|
|
250
|
-
const expanded = dir === "~" || dir.startsWith("~/") ? join3(homedir2(), dir.slice(1)) : dir;
|
|
251
|
-
const p = normalize(expanded).replace(new RegExp(`\\${sep}+$`), "");
|
|
252
|
-
if (cwd === p || cwd.startsWith(p + sep)) {
|
|
253
|
-
if (!best || p.length > best.len) best = { len: p.length, bank };
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
return best?.bank;
|
|
257
|
-
}
|
|
258
|
-
function deriveBankId(config, directory, harness = "coding") {
|
|
259
|
-
const mapped = directory && config.mapPathToBank ? mapLookup(config.mapPathToBank, directory) : void 0;
|
|
260
|
-
if (mapped) return mapped;
|
|
261
|
-
const dynamic = config.dynamicBankId ?? !config.bankId;
|
|
262
|
-
if (!dynamic) return config.bankId || DEFAULT_BANK_NAME;
|
|
263
|
-
const resolvers = {
|
|
264
|
-
harness: () => harness,
|
|
265
|
-
project: () => directory ? basename(directory) : "unknown",
|
|
266
|
-
gitProject: () => gitProjectName(directory, config.resolveWorktrees ?? true),
|
|
267
|
-
channel: () => process.env.HINDSIGHT_CHANNEL_ID || "default",
|
|
268
|
-
user: () => process.env.HINDSIGHT_USER_ID || "anonymous"
|
|
269
|
-
};
|
|
270
|
-
return applyTemplate(config.bankIdTemplate || DEFAULT_TEMPLATE, resolvers, "bankIdTemplate");
|
|
271
|
-
}
|
|
272
|
-
|
|
273
306
|
// src/hindsight-seed.ts
|
|
274
307
|
function arg(name) {
|
|
275
308
|
const i = process.argv.indexOf(`--${name}`);
|