haansi 0.1.102 → 0.1.103

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.
Files changed (2) hide show
  1. package/dist/haansi.js +724 -62
  2. package/package.json +1 -1
package/dist/haansi.js CHANGED
@@ -95,7 +95,7 @@ var require_package = __commonJS({
95
95
  "package.json"(exports2, module2) {
96
96
  module2.exports = {
97
97
  name: "haansi",
98
- version: "0.1.102",
98
+ version: "0.1.103",
99
99
  description: "Haansi CLI - Session collector and MCP server for Claude Code & OpenAI Codex",
100
100
  bin: {
101
101
  haansi: "./dist/haansi.js"
@@ -26109,6 +26109,38 @@ var init_src5 = __esm({
26109
26109
  }
26110
26110
  });
26111
26111
 
26112
+ // ../../packages/@company/db/src/keyword-terms.ts
26113
+ var COMMON_WORDS;
26114
+ var init_keyword_terms = __esm({
26115
+ "../../packages/@company/db/src/keyword-terms.ts"() {
26116
+ "use strict";
26117
+ COMMON_WORDS = new Set(
26118
+ `a about above after again against all also am an and any are aren't as at be
26119
+ because been before being below between both but by can can't cannot could
26120
+ couldn't did didn't do does doesn't doing don't down during each few for from
26121
+ further had hadn't has hasn't have haven't having he her here hers herself him
26122
+ himself his how i if in into is isn't it it's its itself just let's me more most
26123
+ mustn't my myself no nor not of off on once only or other ought our ours
26124
+ ourselves out over own same shan't she should shouldn't so some such than that
26125
+ the their theirs them themselves then there these they this those through to
26126
+ too under until up very was wasn't we were weren't what when where which while
26127
+ who whom why will with won't would wouldn't you your yours yourself yourselves
26128
+ able across actually already always another anything around away back become
26129
+ being best better came come comes coming currently does done else even ever
26130
+ every everything example fail fails failed failing find fine fix fixed fixes
26131
+ fixing get gets getting give given go goes going gone got happen happens help
26132
+ however instead issue issues keep know last later like likely longer look looks
26133
+ lot make makes making many may maybe might much must need needed needs never
26134
+ new now often one ones please possible pretty probably problem problems put
26135
+ rather really right run runs running said say see seem seems seen several
26136
+ since something sometimes somewhere still sure take thing things think though
26137
+ three try trying two use used uses using want wants way ways well whether
26138
+ within without work works working yet get post put patch delete head options
26139
+ etc via per vs ok okay yes error errors exception warning test tests`.split(/\s+/).filter(Boolean)
26140
+ );
26141
+ }
26142
+ });
26143
+
26112
26144
  // ../../packages/@company/db/src/search-vector-write.ts
26113
26145
  var KNOWLEDGE_ARTIFACT_VECTOR_NULLS, PROCESS_REGISTRY_VECTOR_NULLS;
26114
26146
  var init_search_vector_write = __esm({
@@ -26117,6 +26149,7 @@ var init_search_vector_write = __esm({
26117
26149
  init_src5();
26118
26150
  init_src4();
26119
26151
  init_org_context();
26152
+ init_keyword_terms();
26120
26153
  KNOWLEDGE_ARTIFACT_VECTOR_NULLS = (KNOWLEDGE_ARTIFACTS_SEARCH_VECTOR.weights ?? []).map(() => null);
26121
26154
  PROCESS_REGISTRY_VECTOR_NULLS = (PROCESS_REGISTRY_SEARCH_VECTOR.weights ?? []).map(() => null);
26122
26155
  }
@@ -27955,6 +27988,7 @@ var init_src6 = __esm({
27955
27988
  init_org_context();
27956
27989
  init_admin_pools();
27957
27990
  init_search_vector_write();
27991
+ init_keyword_terms();
27958
27992
  init_org_purge();
27959
27993
  init_org_orphan_scan();
27960
27994
  init_integration_purge();
@@ -39113,13 +39147,13 @@ function _file(Class2, params) {
39113
39147
  }
39114
39148
  // @__NO_SIDE_EFFECTS__
39115
39149
  function _custom(Class2, fn, _params) {
39116
- const norm = normalizeParams(_params);
39117
- norm.abort ?? (norm.abort = true);
39150
+ const norm2 = normalizeParams(_params);
39151
+ norm2.abort ?? (norm2.abort = true);
39118
39152
  const schema = new Class2({
39119
39153
  type: "custom",
39120
39154
  check: "custom",
39121
39155
  fn,
39122
- ...norm
39156
+ ...norm2
39123
39157
  });
39124
39158
  return schema;
39125
39159
  }
@@ -60133,6 +60167,74 @@ var init_stdio2 = __esm({
60133
60167
  }
60134
60168
  });
60135
60169
 
60170
+ // ../service-capture/agent-sessions/search-solutions-tool.ts
60171
+ function searchSolutionsTool(contextSchema2) {
60172
+ return {
60173
+ name: "search_solutions",
60174
+ description: "Search previously solved similar questions from your organization's knowledge base. Finds how bugs were fixed, what patterns were used, and past resolutions to similar problems. Results are ranked by a composite of relevance, quality, recency, and verification status. For a failing test, pass its name in failing_tests and the error line in error. Pass the files you expect to change, or that the failure runs through, in files.",
60175
+ inputSchema: {
60176
+ type: "object",
60177
+ properties: {
60178
+ query: {
60179
+ type: "string",
60180
+ description: "Natural-language description of the problem or solution to search for"
60181
+ },
60182
+ top_k: {
60183
+ type: "number",
60184
+ description: "Number of results to return (default: 5, max: 20)"
60185
+ },
60186
+ failing_tests: stringList(
60187
+ "Optional. Names of the failing tests, as the test runner prints them"
60188
+ ),
60189
+ error: {
60190
+ type: "string",
60191
+ description: "Optional. The error line, e.g. the assertion or exception message"
60192
+ },
60193
+ files: stringList(
60194
+ "Optional. File paths you expect to change, or that the failure runs through"
60195
+ ),
60196
+ names: stringList(
60197
+ "Optional. Identifiers involved: functions, classes, routes, config keys"
60198
+ ),
60199
+ _context: contextSchema2
60200
+ },
60201
+ required: ["query"]
60202
+ }
60203
+ };
60204
+ }
60205
+ function clipList(value) {
60206
+ const items = Array.isArray(value) ? value : value === void 0 ? [] : [value];
60207
+ return items.filter((v) => typeof v === "string").map((v) => v.trim().slice(0, MAX_HINT_ITEM_CHARS)).filter(Boolean).slice(0, MAX_HINT_ITEMS);
60208
+ }
60209
+ function searchSolutionsPath(args) {
60210
+ const k = Math.min(Math.max(1, Number(args.top_k ?? 5) || 5), 20);
60211
+ const params = new URLSearchParams();
60212
+ params.set("q", String(args.query ?? ""));
60213
+ params.set("top_k", String(k));
60214
+ for (const t of clipList(args.failing_tests))
60215
+ params.append("failing_tests", t);
60216
+ if (typeof args.error === "string" && args.error.trim()) {
60217
+ params.set("error", args.error.trim().slice(0, MAX_HINT_ERROR_CHARS));
60218
+ }
60219
+ for (const f of clipList(args.files)) params.append("files", f);
60220
+ for (const n of clipList(args.names)) params.append("names", n);
60221
+ return `/memory/solutions/search?${params.toString()}`;
60222
+ }
60223
+ var MAX_HINT_ITEMS, MAX_HINT_ITEM_CHARS, MAX_HINT_ERROR_CHARS, stringList;
60224
+ var init_search_solutions_tool = __esm({
60225
+ "../service-capture/agent-sessions/search-solutions-tool.ts"() {
60226
+ "use strict";
60227
+ MAX_HINT_ITEMS = 10;
60228
+ MAX_HINT_ITEM_CHARS = 300;
60229
+ MAX_HINT_ERROR_CHARS = 1e3;
60230
+ stringList = (description) => ({
60231
+ type: "array",
60232
+ items: { type: "string" },
60233
+ description
60234
+ });
60235
+ }
60236
+ });
60237
+
60136
60238
  // ../../node_modules/depd/index.js
60137
60239
  var require_depd = __commonJS({
60138
60240
  "../../node_modules/depd/index.js"(exports2, module2) {
@@ -84298,6 +84400,7 @@ var init_mcp_server2 = __esm({
84298
84400
  init_mcp();
84299
84401
  init_stdio2();
84300
84402
  init_entrypoint();
84403
+ init_search_solutions_tool();
84301
84404
  init_types4();
84302
84405
  (0, import_dotenv3.config)({ path: (0, import_path5.resolve)(__dirname, "../../../.env") });
84303
84406
  DEFAULT_API_URL3 = SERVICE_URL_DEFAULTS.haansiApiBaseUrl;
@@ -84334,25 +84437,7 @@ var init_mcp_server2 = __esm({
84334
84437
  server = mcpServer.server;
84335
84438
  server.setRequestHandler(ListToolsRequestSchema, async () => ({
84336
84439
  tools: [
84337
- {
84338
- name: "search_solutions",
84339
- description: "Search previously solved similar questions from your organization's knowledge base. Finds how bugs were fixed, what patterns were used, and past resolutions to similar problems. Results are ranked by a composite of relevance, quality, recency, and verification status.",
84340
- inputSchema: {
84341
- type: "object",
84342
- properties: {
84343
- query: {
84344
- type: "string",
84345
- description: "Natural-language description of the problem or solution to search for"
84346
- },
84347
- top_k: {
84348
- type: "number",
84349
- description: "Number of results to return (default: 5, max: 20)"
84350
- },
84351
- _context: contextSchema
84352
- },
84353
- required: ["query"]
84354
- }
84355
- },
84440
+ searchSolutionsTool(contextSchema),
84356
84441
  {
84357
84442
  name: "list_recent_solutions",
84358
84443
  description: "List the most recently added distilled paths from the knowledge base.",
@@ -84461,12 +84546,8 @@ var init_mcp_server2 = __esm({
84461
84546
  try {
84462
84547
  switch (name) {
84463
84548
  case "search_solutions": {
84464
- const {
84465
- query,
84466
- top_k = 5,
84467
- _context
84468
- } = args;
84469
- const k = Math.min(Math.max(1, top_k), 20);
84549
+ const searchArgs = args;
84550
+ const { _context } = searchArgs;
84470
84551
  const extraHeaders = {};
84471
84552
  if (_context?.userId) {
84472
84553
  extraHeaders["X-Session-User-Id"] = String(_context.userId);
@@ -84474,10 +84555,9 @@ var init_mcp_server2 = __esm({
84474
84555
  if (_context?.orgId) {
84475
84556
  extraHeaders["X-Session-Org-Id"] = String(_context.orgId);
84476
84557
  }
84477
- const data = await apiGet2(
84478
- `/memory/solutions/search?q=${encodeURIComponent(query)}&top_k=${k}`,
84479
- { extraHeaders }
84480
- );
84558
+ const data = await apiGet2(searchSolutionsPath(searchArgs), {
84559
+ extraHeaders
84560
+ });
84481
84561
  if (!data.results || data.results.length === 0) {
84482
84562
  return {
84483
84563
  content: [
@@ -88025,6 +88105,11 @@ async function firstAt(show, sha, paths) {
88025
88105
  }
88026
88106
  return null;
88027
88107
  }
88108
+ function isTestSupport(path2) {
88109
+ return /(^|\/)(__tests__|__mocks__|__fixtures__|fixtures?|test-utils?)\//.test(
88110
+ path2
88111
+ );
88112
+ }
88028
88113
  async function testInterfaceOf(show, task) {
88029
88114
  const tests = new Set(task.testFiles);
88030
88115
  const byPath = /* @__PURE__ */ new Map();
@@ -88036,10 +88121,7 @@ async function testInterfaceOf(show, task) {
88036
88121
  const candidates = candidatesFor(file2, imp.spec);
88037
88122
  const atTarget = await firstAt(show, task.targetSha, candidates);
88038
88123
  if (!atTarget || tests.has(atTarget.path)) continue;
88039
- if (/(^|\/)(__tests__|__mocks__|__fixtures__|fixtures?|test-utils?)\//.test(
88040
- atTarget.path
88041
- ))
88042
- continue;
88124
+ if (isTestSupport(atTarget.path)) continue;
88043
88125
  const atBase = await show(task.baseSha, atTarget.path);
88044
88126
  const names = imp.names.filter(
88045
88127
  (n) => atBase === null || !exportsName(atBase, n)
@@ -88064,20 +88146,37 @@ async function testInterfaceOf(show, task) {
88064
88146
  return { ...e, names };
88065
88147
  });
88066
88148
  }
88149
+ function fencedTs(text) {
88150
+ const longest = Math.max(
88151
+ 0,
88152
+ ...(text.match(/`+/g) ?? []).map((run3) => run3.length)
88153
+ );
88154
+ const fence = "`".repeat(Math.max(3, longest + 1));
88155
+ return [`${fence}ts`, ...text.split("\n"), fence];
88156
+ }
88067
88157
  function interfaceSection(entries) {
88068
88158
  if (entries.length === 0) return [];
88069
88159
  return [
88070
88160
  "## What the tests use",
88071
88161
  "",
88072
- "The task's tests import these from the code, and they do not exist yet. Create them at these paths with these names; how they work is up to you.",
88162
+ "The task's tests import these from the code, and they do not exist yet. Create them at these paths with these names, declared as shown where a declaration is given; how they work is up to you.",
88073
88163
  "",
88074
- ...entries.map((e) => {
88164
+ ...entries.flatMap((e) => {
88075
88165
  const what = [
88076
88166
  ...e.defaultExport ? ["a default export"] : [],
88077
88167
  ...e.names.map((n) => `\`${n}\``)
88078
88168
  ];
88079
88169
  const where = `\`${e.path}\`${e.newFile ? " (a new file)" : ""}`;
88080
- return `- ${where}${what.length ? `: ${what.join(", ")}` : ""}`;
88170
+ const declared = e.names.filter((n) => e.signatures?.[n]);
88171
+ return [
88172
+ `- ${where}${what.length ? `: ${what.join(", ")}` : ""}`,
88173
+ // As the target declares each: its shape, never its body.
88174
+ ...declared.flatMap((n) => [
88175
+ "",
88176
+ ...fencedTs(e.signatures[n]).map((l) => ` ${l}`)
88177
+ ]),
88178
+ ...declared.length ? [""] : []
88179
+ ];
88081
88180
  }),
88082
88181
  ""
88083
88182
  ];
@@ -88096,6 +88195,494 @@ var init_replay_interface = __esm({
88096
88195
  }
88097
88196
  });
88098
88197
 
88198
+ // src/commands/replay-failure-paths.ts
88199
+ function isAppFile(path2) {
88200
+ return SOURCE.test(path2) && !TEST_FILE.test(path2) && !isTestSupport(path2) && !/(^|\/)(node_modules|dist|build|coverage|\.next)\//.test(path2);
88201
+ }
88202
+ function stackFramesOf(output) {
88203
+ const out = [];
88204
+ const seen = /* @__PURE__ */ new Set();
88205
+ for (const raw of output.split("\n")) {
88206
+ const line = relativePaths(raw);
88207
+ for (const m of line.matchAll(FRAME)) {
88208
+ const path2 = m[1].replace(/^\.\//, "");
88209
+ const n = Number(m[2]);
88210
+ if (!n || path2.split("/").includes("..") || !isAppFile(path2)) continue;
88211
+ const key = `${path2}:${n}`;
88212
+ if (seen.has(key)) continue;
88213
+ seen.add(key);
88214
+ out.push({ path: path2, line: n });
88215
+ if (out.length >= MAX_FRAMES) return out;
88216
+ }
88217
+ }
88218
+ return out;
88219
+ }
88220
+ async function resolveFrames(show, baseSha, frames) {
88221
+ const out = [];
88222
+ for (const f of frames) {
88223
+ const parts = f.path.replace(/^\/+/, "").split("/");
88224
+ const tries = f.path.startsWith("/") ? parts.slice(1, ABSOLUTE_TRIES + 1).map((_, i) => parts.slice(i + 1).join("/")) : [f.path];
88225
+ for (const p of tries) {
88226
+ if (!p || !isAppFile(p)) continue;
88227
+ if (await show(baseSha, p).catch(() => null) !== null) {
88228
+ if (!out.some((o) => o.path === p && o.line === f.line))
88229
+ out.push({ path: p, line: f.line });
88230
+ break;
88231
+ }
88232
+ }
88233
+ }
88234
+ return out;
88235
+ }
88236
+ function boundedGit(git, max2 = MAX_GIT_CALLS) {
88237
+ let calls = 0;
88238
+ return async (args) => {
88239
+ if (calls >= max2) return { code: 1, output: "" };
88240
+ calls += 1;
88241
+ try {
88242
+ return await git(args);
88243
+ } catch {
88244
+ return { code: 1, output: "" };
88245
+ }
88246
+ };
88247
+ }
88248
+ async function filesOfCommit(git, sha) {
88249
+ const out = await git(["show", "--name-only", "--format=", sha]);
88250
+ if (out.code !== 0) return [];
88251
+ return out.output.split("\n").map((l) => l.trim()).filter((l) => l && isAppFile(l)).slice(0, FILES_PER_COMMIT);
88252
+ }
88253
+ async function filesOfCommits(git, commits) {
88254
+ const out = [];
88255
+ for (const sha of commits.slice(0, MAX_COMMITS)) {
88256
+ for (const f of await filesOfCommit(git, sha))
88257
+ if (!out.includes(f)) out.push(f);
88258
+ if (out.length >= MAX_WHERE_PATHS) break;
88259
+ }
88260
+ return out.slice(0, MAX_WHERE_PATHS);
88261
+ }
88262
+ async function blamedPaths(git, baseSha, frames) {
88263
+ const commits = [];
88264
+ for (const f of frames.slice(0, MAX_FRAMES)) {
88265
+ const out = await git([
88266
+ "blame",
88267
+ "-L",
88268
+ `${f.line},${f.line}`,
88269
+ "--porcelain",
88270
+ baseSha,
88271
+ "--",
88272
+ f.path
88273
+ ]);
88274
+ if (out.code !== 0) continue;
88275
+ const sha = out.output.split(/\s/)[0] ?? "";
88276
+ if (SHA2.test(sha) && !/^0+$/.test(sha) && !commits.includes(sha))
88277
+ commits.push(sha);
88278
+ }
88279
+ const files = await filesOfCommits(git, commits);
88280
+ return [.../* @__PURE__ */ new Set([...frames.map((f) => f.path), ...files])].slice(
88281
+ 0,
88282
+ MAX_WHERE_PATHS
88283
+ );
88284
+ }
88285
+ async function historyPaths(git, baseSha, files) {
88286
+ const commits = /* @__PURE__ */ new Map();
88287
+ for (const file2 of files.slice(0, MAX_HISTORY_FILES)) {
88288
+ const out = await git([
88289
+ "log",
88290
+ "-n",
88291
+ String(COMMITS_PER_FILE),
88292
+ "--format=%H %ct",
88293
+ baseSha,
88294
+ "--",
88295
+ file2
88296
+ ]);
88297
+ if (out.code !== 0) continue;
88298
+ for (const line of out.output.split("\n")) {
88299
+ const [sha, at] = line.trim().split(/\s+/);
88300
+ if (sha && SHA2.test(sha) && !commits.has(sha))
88301
+ commits.set(sha, Number(at) || 0);
88302
+ }
88303
+ }
88304
+ const newest = [...commits.entries()].sort((a, b) => b[1] - a[1]).map(([sha]) => sha);
88305
+ return filesOfCommits(git, newest);
88306
+ }
88307
+ function packageCandidates(spec2) {
88308
+ const m = /^(@[\w.-]+\/[\w.-]+)(?:\/(.+))?$/.exec(spec2);
88309
+ if (!m) return [];
88310
+ const [, pkg, sub] = m;
88311
+ const stems = sub ? [`packages/${pkg}/src/${sub}`, `packages/${pkg}/${sub}`] : [`packages/${pkg}/src/index`, `packages/${pkg}/index`];
88312
+ return stems.flatMap((s) => [
88313
+ `${s}.ts`,
88314
+ `${s}.tsx`,
88315
+ `${s}.js`,
88316
+ `${s}/index.ts`
88317
+ ]);
88318
+ }
88319
+ function packageSpecsOf(source) {
88320
+ const text = source.replace(/\/\*[\s\S]*?\*\//g, " ").replace(/(^|[^:])\/\/.*$/gm, "$1");
88321
+ const out = [];
88322
+ for (const m of text.matchAll(
88323
+ /(?:\bfrom\s*|\b(?:vi|jest)\.(?:mock|doMock)\(\s*|\bimport\(\s*)["'](@[^"'\s]+)["']/g
88324
+ ))
88325
+ if (!out.includes(m[1])) out.push(m[1]);
88326
+ return out;
88327
+ }
88328
+ var MAX_FRAMES, COMMITS_PER_FILE, MAX_HISTORY_FILES, MAX_COMMITS, FILES_PER_COMMIT, MAX_WHERE_PATHS, MAX_GIT_CALLS, ABSOLUTE_TRIES, SOURCE, TEST_FILE, SHA2, FRAME;
88329
+ var init_replay_failure_paths = __esm({
88330
+ "src/commands/replay-failure-paths.ts"() {
88331
+ "use strict";
88332
+ init_replay_errors();
88333
+ init_replay_interface();
88334
+ MAX_FRAMES = 10;
88335
+ COMMITS_PER_FILE = 3;
88336
+ MAX_HISTORY_FILES = 16;
88337
+ MAX_COMMITS = 4;
88338
+ FILES_PER_COMMIT = 4;
88339
+ MAX_WHERE_PATHS = 6;
88340
+ MAX_GIT_CALLS = 40;
88341
+ ABSOLUTE_TRIES = 6;
88342
+ SOURCE = /\.(?:[cm]?[jt]sx?|py|go)$/;
88343
+ TEST_FILE = /(?:\.(?:test|spec)\.[cm]?[jt]sx?|_test\.go|(?:^|\/)test_[^/]*\.py|_test\.py)$/;
88344
+ SHA2 = /^[0-9a-f]{40}$/;
88345
+ FRAME = /(?:file:\/\/)?((?:\/|\.{0,2}\/)?(?:[\w.@+-]+\/)*[\w.@+-]+\.(?:[cm]?[jt]sx?|py|go)):(\d+)(?::\d+)?/g;
88346
+ }
88347
+ });
88348
+
88349
+ // src/commands/replay-spec.ts
88350
+ function stringAt(text, i) {
88351
+ const quote = text[i];
88352
+ if (quote !== "'" && quote !== '"' && quote !== "`") return null;
88353
+ let value = "";
88354
+ for (let j = i + 1; j < text.length; j++) {
88355
+ const c = text[j];
88356
+ if (c === "\\" && j + 1 < text.length) {
88357
+ value += text[j + 1];
88358
+ j += 1;
88359
+ } else if (c === quote) return { value, end: j + 1 };
88360
+ else if (quote !== "`" && c === "\n") return null;
88361
+ else value += c;
88362
+ }
88363
+ return null;
88364
+ }
88365
+ function skipGroup(text, i) {
88366
+ const open = text[i];
88367
+ const close = open === "(" ? ")" : open === "[" ? "]" : null;
88368
+ if (!close) return -1;
88369
+ let depth = 0;
88370
+ for (let j = i; j < text.length; j++) {
88371
+ const c = text[j];
88372
+ if (c === "'" || c === '"' || c === "`") {
88373
+ const s = stringAt(text, j);
88374
+ if (!s) return -1;
88375
+ j = s.end - 1;
88376
+ } else if (c === "(" || c === "[" || c === "{") depth += 1;
88377
+ else if (c === ")" || c === "]" || c === "}") {
88378
+ depth -= 1;
88379
+ if (depth === 0) return c === close ? j + 1 : -1;
88380
+ }
88381
+ }
88382
+ return -1;
88383
+ }
88384
+ function testCallAt(text, i) {
88385
+ CALL.lastIndex = i;
88386
+ const m = CALL.exec(text);
88387
+ if (!m) return null;
88388
+ let j = CALL.lastIndex;
88389
+ if (/[\w$]/.test(text[j] ?? "")) return null;
88390
+ const mods = m[2];
88391
+ if (/\.(?:each|skipIf|runIf|for)\b/.test(mods)) {
88392
+ while (/\s/.test(text[j] ?? "")) j++;
88393
+ if (text[j] === "`") {
88394
+ const s2 = stringAt(text, j);
88395
+ if (!s2) return null;
88396
+ j = s2.end;
88397
+ } else {
88398
+ j = skipGroup(text, j);
88399
+ if (j < 0) return null;
88400
+ }
88401
+ }
88402
+ while (/\s/.test(text[j] ?? "")) j++;
88403
+ if (text[j] !== "(") return null;
88404
+ j++;
88405
+ while (/\s/.test(text[j] ?? "")) j++;
88406
+ const s = stringAt(text, j);
88407
+ if (!s) return null;
88408
+ const suite = m[1] === "describe" || m[1] === "suite" || m[1] === "context";
88409
+ return { suite, title: s.value.replace(/\s+/g, " ").trim(), end: s.end };
88410
+ }
88411
+ function testTitlesOf(source) {
88412
+ const out = [];
88413
+ const stack = [];
88414
+ let depth = 0;
88415
+ const text = source;
88416
+ for (let i = 0; i < text.length; i++) {
88417
+ const c = text[i];
88418
+ const next = text[i + 1];
88419
+ if (c === "/" && next === "/") {
88420
+ const nl = text.indexOf("\n", i);
88421
+ i = nl < 0 ? text.length : nl;
88422
+ } else if (c === "/" && next === "*") {
88423
+ const close = text.indexOf("*/", i + 2);
88424
+ i = close < 0 ? text.length : close + 1;
88425
+ } else if (c === "'" || c === '"' || c === "`") {
88426
+ const s = stringAt(text, i);
88427
+ if (s) i = s.end - 1;
88428
+ } else if (c === "{") depth += 1;
88429
+ else if (c === "}") {
88430
+ depth -= 1;
88431
+ while (stack.length && depth <= stack[stack.length - 1].depth)
88432
+ stack.pop();
88433
+ } else if (/[a-z]/.test(c) && !/[\w$.]/.test(text[i - 1] ?? "")) {
88434
+ const call = testCallAt(text, i);
88435
+ if (!call) continue;
88436
+ if (call.suite) stack.push({ title: call.title, depth });
88437
+ else if (call.title)
88438
+ out.push([...stack.map((s) => s.title), call.title].join(" \u203A "));
88439
+ i = call.end - 1;
88440
+ }
88441
+ }
88442
+ return out;
88443
+ }
88444
+ async function targetTestTitles(show, task) {
88445
+ const out = [];
88446
+ for (const file2 of task.testFiles) {
88447
+ if (!JS_SOURCE.test(file2)) continue;
88448
+ const source = await show(task.targetSha, file2);
88449
+ if (source === null) continue;
88450
+ for (const t of testTitlesOf(source)) out.push(`${file2} \u203A ${t}`);
88451
+ }
88452
+ return out;
88453
+ }
88454
+ function cappedTitles(titles) {
88455
+ const shown = [];
88456
+ let chars = 0;
88457
+ for (const t of titles) {
88458
+ if (shown.length >= MAX_TITLES || chars + t.length > MAX_TITLE_CHARS) break;
88459
+ shown.push(t);
88460
+ chars += t.length;
88461
+ }
88462
+ return { shown, more: titles.length - shown.length };
88463
+ }
88464
+ function typeEnd(text, i, stops, bodyBrace) {
88465
+ let depth = 0;
88466
+ let expectType = true;
88467
+ for (let j = i; j < text.length; j++) {
88468
+ const c = text[j];
88469
+ if (c === "'" || c === '"' || c === "`") {
88470
+ const s = stringAt(text, j);
88471
+ if (s) j = s.end - 1;
88472
+ expectType = false;
88473
+ continue;
88474
+ }
88475
+ if (c === "=" && text[j + 1] === ">") {
88476
+ j += 1;
88477
+ expectType = true;
88478
+ continue;
88479
+ }
88480
+ if (depth === 0 && stops.includes(c)) return j;
88481
+ if (c === "{" && depth === 0 && bodyBrace && !expectType) return j;
88482
+ if ("([<{".includes(c)) {
88483
+ depth += 1;
88484
+ expectType = true;
88485
+ } else if (")]>}".includes(c)) {
88486
+ depth -= 1;
88487
+ expectType = false;
88488
+ if (depth < 0) return j;
88489
+ } else if (/[:|&,?]/.test(c)) expectType = true;
88490
+ else if (!/\s/.test(c)) expectType = false;
88491
+ }
88492
+ return text.length;
88493
+ }
88494
+ function capped(text) {
88495
+ const lines = text.trim().split("\n").map((l) => l.replace(/\s+$/, ""));
88496
+ let out = lines.slice(0, MAX_SIGNATURE_LINES).join("\n");
88497
+ let cut2 = lines.length > MAX_SIGNATURE_LINES;
88498
+ if (out.length > MAX_SIGNATURE_CHARS) {
88499
+ out = out.slice(0, MAX_SIGNATURE_CHARS);
88500
+ cut2 = true;
88501
+ }
88502
+ return cut2 ? `${out.trimEnd()}
88503
+ \u2026` : out;
88504
+ }
88505
+ function signatureOf(source, name) {
88506
+ const text = STRIP_COMMENTS(source);
88507
+ const n = name.replace(/\$/g, "\\$");
88508
+ const lead = String.raw`(?:^|\n)[ \t]*((?:export\s+)?(?:declare\s+)?(?:default\s+)?(?:abstract\s+)?(?:async\s+)?)`;
88509
+ const fn = new RegExp(`${lead}(function\\*?\\s+${n})\\b`).exec(text);
88510
+ if (fn) {
88511
+ const start = fn.index + fn[0].length - fn[2].length - fn[1].length;
88512
+ const end = typeEnd(text, fn.index + fn[0].length, ";", true);
88513
+ return capped(text.slice(start, end));
88514
+ }
88515
+ const cls = new RegExp(`${lead}(class\\s+${n})\\b`).exec(text);
88516
+ if (cls) {
88517
+ const start = cls.index + cls[0].length - cls[2].length - cls[1].length;
88518
+ const brace = text.indexOf("{", cls.index + cls[0].length);
88519
+ return capped(text.slice(start, brace < 0 ? text.length : brace));
88520
+ }
88521
+ const decl = new RegExp(`${lead}((?:interface|enum)\\s+${n})\\b`).exec(text);
88522
+ if (decl) {
88523
+ const start = decl.index + decl[0].length - decl[2].length - decl[1].length;
88524
+ const brace = text.indexOf("{", decl.index + decl[0].length);
88525
+ if (brace < 0 || /;|\n\s*(?:export|interface|type|const|function|class|enum)\b/.test(
88526
+ text.slice(decl.index + decl[0].length, brace)
88527
+ ))
88528
+ return null;
88529
+ let depth = 0;
88530
+ let end = text.length;
88531
+ for (let j = brace; j < text.length; j++) {
88532
+ if (text[j] === "{") depth += 1;
88533
+ else if (text[j] === "}" && --depth === 0) {
88534
+ end = j + 1;
88535
+ break;
88536
+ }
88537
+ }
88538
+ return capped(text.slice(start, end));
88539
+ }
88540
+ const type = new RegExp(`${lead}(type\\s+${n})\\b`).exec(text);
88541
+ if (type) {
88542
+ const start = type.index + type[0].length - type[2].length - type[1].length;
88543
+ const end = typeEnd(text, type.index + type[0].length, ";", false);
88544
+ return capped(text.slice(start, end));
88545
+ }
88546
+ const v = new RegExp(`${lead}((?:const|let|var)\\s+${n})\\b`).exec(text);
88547
+ if (v) {
88548
+ const start = v.index + v[0].length - v[2].length - v[1].length;
88549
+ const after = v.index + v[0].length;
88550
+ const rest = text.slice(after);
88551
+ if (/^\s*:/.test(rest)) {
88552
+ const end = typeEnd(text, after, "=;", false);
88553
+ return capped(text.slice(start, end));
88554
+ }
88555
+ const arrow = /^\s*=\s*(?:async\s+)?(?:<[^>]*>\s*)?(?=\()/.exec(rest);
88556
+ if (!arrow) return null;
88557
+ const close = skipGroup(text, after + arrow[0].length);
88558
+ if (close < 0) return null;
88559
+ const ret = /^\s*(?::[^=;{]*?)?\s*=>/.exec(text.slice(close));
88560
+ return ret ? capped(text.slice(start, close + ret[0].length)) : null;
88561
+ }
88562
+ return null;
88563
+ }
88564
+ async function withSignatures(show, targetSha, entries) {
88565
+ const out = [];
88566
+ for (const e of entries) {
88567
+ const source = e.names.length ? await show(targetSha, e.path) : null;
88568
+ const signatures = {};
88569
+ for (const n of e.names) {
88570
+ const sig = source === null ? null : signatureOf(source, n);
88571
+ if (sig) signatures[n] = sig;
88572
+ }
88573
+ out.push(Object.keys(signatures).length ? { ...e, signatures } : e);
88574
+ }
88575
+ return out;
88576
+ }
88577
+ function fileOfTest(name) {
88578
+ const file2 = name.split(" \u203A ")[0]?.trim() ?? "";
88579
+ return /\.[cm]?[jt]sx?$|\.py$|_test\.go$/.test(file2) && !/\s/.test(file2) ? file2 : null;
88580
+ }
88581
+ function titleOfTest(name) {
88582
+ const parts = name.split(" \u203A ");
88583
+ return (fileOfTest(name) ? parts.slice(1) : parts).join(" \u203A ").trim();
88584
+ }
88585
+ function mockedSpecsOf(source) {
88586
+ const out = [];
88587
+ for (const m of STRIP_COMMENTS(source).matchAll(
88588
+ /\b(?:vi|jest)\.(?:mock|doMock)\(\s*["'](\.[^"']*)["']/g
88589
+ ))
88590
+ if (!out.includes(m[1])) out.push(m[1]);
88591
+ return out;
88592
+ }
88593
+ async function hopOf(show, baseSha, from, skip) {
88594
+ const out = [];
88595
+ for (const file2 of from) {
88596
+ if (out.length >= MAX_HOP_MODULES) break;
88597
+ if (!JS_SOURCE.test(file2)) continue;
88598
+ const source = await show(baseSha, file2).catch(() => null);
88599
+ if (source === null) continue;
88600
+ const reexports = [
88601
+ ...STRIP_COMMENTS(source).matchAll(
88602
+ /\bexport\s+(?:type\s+)?(?:\*(?:\s+as\s+[\w$]+)?|\{[^}]*\})\s*from\s*["'](\.[^"']+)["']/g
88603
+ )
88604
+ ].map((m) => m[1]);
88605
+ const relative4 = [
88606
+ .../* @__PURE__ */ new Set([
88607
+ ...importsOf(source).map((i) => i.spec),
88608
+ ...mockedSpecsOf(source),
88609
+ ...reexports
88610
+ ])
88611
+ ].map((spec2) => candidatesFor(file2, spec2));
88612
+ const packages = packageSpecsOf(source).map(packageCandidates);
88613
+ for (const candidates of [...relative4, ...packages]) {
88614
+ if (out.length >= MAX_HOP_MODULES) break;
88615
+ if (!candidates.length) continue;
88616
+ const at = await firstAt(show, baseSha, candidates).catch(() => null);
88617
+ if (!at || skip.has(at.path) || TEST_FILE2.test(at.path) || isTestSupport(at.path) || out.includes(at.path))
88618
+ continue;
88619
+ out.push(at.path);
88620
+ }
88621
+ }
88622
+ return out;
88623
+ }
88624
+ async function failingPathsOf(show, task, git) {
88625
+ const named = [
88626
+ ...new Set(task.tests.map(fileOfTest).filter((f) => !!f))
88627
+ ];
88628
+ const files = [...new Set(named.length ? named : task.testFiles)];
88629
+ const tests = /* @__PURE__ */ new Set([...files, ...task.testFiles]);
88630
+ const direct = await hopOf(show, task.baseSha, files, tests);
88631
+ const second = await hopOf(
88632
+ show,
88633
+ task.baseSha,
88634
+ direct,
88635
+ /* @__PURE__ */ new Set([...tests, ...direct])
88636
+ );
88637
+ let where = [];
88638
+ if (git) {
88639
+ const run3 = boundedGit(git);
88640
+ const frames = await resolveFrames(
88641
+ show,
88642
+ task.baseSha,
88643
+ stackFramesOf(task.output ?? "")
88644
+ );
88645
+ where = frames.length ? await blamedPaths(run3, task.baseSha, frames) : await historyPaths(run3, task.baseSha, [...files, ...direct, ...second]);
88646
+ }
88647
+ return [.../* @__PURE__ */ new Set([...files, ...where, ...direct, ...second])].slice(
88648
+ 0,
88649
+ MAX_FAILING_PATHS
88650
+ );
88651
+ }
88652
+ function errorLineOf(output) {
88653
+ for (const line of output.split("\n")) {
88654
+ const m = /\b\w*(?:Error|Exception)\b:?\s*(.+)$/.exec(line) ?? /\b(expected .+)$/i.exec(line);
88655
+ if (!m) continue;
88656
+ const key = norm(m[1]).slice(0, 120);
88657
+ if (key.length >= 12) return key;
88658
+ }
88659
+ return null;
88660
+ }
88661
+ function baseNameOf(path2) {
88662
+ const parts = path2.split("/");
88663
+ const name = (parts.pop() ?? path2).replace(/\.[cm]?[jt]sx?$/, "").replace(/\.(?:test|spec)$/, "");
88664
+ return name === "index" && parts.length ? parts[parts.length - 1] : name;
88665
+ }
88666
+ var MAX_TITLES, MAX_TITLE_CHARS, MAX_SIGNATURE_LINES, MAX_SIGNATURE_CHARS, MAX_FAILING_PATHS, JS_SOURCE, TEST_FILE2, CALL, STRIP_COMMENTS, MAX_HOP_MODULES, norm;
88667
+ var init_replay_spec = __esm({
88668
+ "src/commands/replay-spec.ts"() {
88669
+ "use strict";
88670
+ init_replay_interface();
88671
+ init_replay_failure_paths();
88672
+ MAX_TITLES = 40;
88673
+ MAX_TITLE_CHARS = 4e3;
88674
+ MAX_SIGNATURE_LINES = 15;
88675
+ MAX_SIGNATURE_CHARS = 600;
88676
+ MAX_FAILING_PATHS = 12;
88677
+ JS_SOURCE = /\.[cm]?[jt]sx?$/;
88678
+ TEST_FILE2 = /\.(?:test|spec)\.[cm]?[jt]sx?$/;
88679
+ CALL = /(describe|suite|context|it|test)((?:\.[A-Za-z]+)*)/y;
88680
+ STRIP_COMMENTS = (source) => source.replace(/\/\*[\s\S]*?\*\//g, " ").replace(/(^|[^:])\/\/.*$/gm, "$1");
88681
+ MAX_HOP_MODULES = 24;
88682
+ norm = (s) => s.replace(/\s+/g, " ").trim();
88683
+ }
88684
+ });
88685
+
88099
88686
  // src/commands/replay-context.ts
88100
88687
  function stateOf(knowledge) {
88101
88688
  if (knowledge === "returned") return "found";
@@ -88103,7 +88690,8 @@ function stateOf(knowledge) {
88103
88690
  }
88104
88691
  function needsCheck(task) {
88105
88692
  const c = task.context;
88106
- return !c || c.state === null || c.stale;
88693
+ if (!c || c.state === null || c.stale) return true;
88694
+ return c.checkVersion !== void 0 && c.checkVersion !== CONTEXT_CHECK_VERSION;
88107
88695
  }
88108
88696
  function pathsIn(text) {
88109
88697
  const found = text.match(/(?<![\w./-])(?:[\w.-]+\/)+[\w.-]*[\w-](?:\.[a-z0-9]+)?/gi) ?? [];
@@ -88118,22 +88706,42 @@ function pathsIn(text) {
88118
88706
  function visibleAsk(task) {
88119
88707
  const failing = task.kind === "recovery" ? task.failing : null;
88120
88708
  const problem = flat2(task.card.problem);
88709
+ const head = problem.slice(0, HEAD_CHARS).trim();
88121
88710
  const cardText = [
88122
88711
  task.card.problem,
88123
88712
  task.card.acceptance,
88124
88713
  task.card.area ?? ""
88125
88714
  ].join("\n");
88126
- const iface = task.testInterface ?? [];
88127
- const paths = [
88128
- .../* @__PURE__ */ new Set([...iface.map((e) => e.path), ...pathsIn(cardText)])
88129
- ].slice(0, MAX_PATHS);
88130
- const names = iface.flatMap((e) => e.names);
88131
- const queries = [
88132
- problem,
88133
- flat2(`${task.card.area ?? ""} ${flat2(task.card.acceptance)}`),
88134
- failing?.tests.length ? flat2(failing.tests.join(" ")) : "",
88135
- names.length ? names.join(" ") : ""
88136
- ].map((q) => q.slice(0, QUERY_CHARS2).trim()).filter((q, i, all) => q !== "" && all.indexOf(q) === i);
88715
+ let paths;
88716
+ let queries;
88717
+ if (failing?.tests.length) {
88718
+ const named = failing.tests.map(fileOfTest).filter((f) => !!f);
88719
+ paths = [
88720
+ .../* @__PURE__ */ new Set([
88721
+ ...task.failingPaths?.length ? task.failingPaths : named.length ? named : task.testFiles,
88722
+ ...pathsIn(cardText)
88723
+ ])
88724
+ ].slice(0, MAX_FAILING_PATHS);
88725
+ const files = [...new Set(paths.map(baseNameOf))];
88726
+ queries = [
88727
+ ...failing.tests.slice(0, FAILING_QUERIES).map(titleOfTest),
88728
+ errorLineOf(failing.output) ?? "",
88729
+ files.slice(0, 6).join(" ")
88730
+ ];
88731
+ } else {
88732
+ const iface = task.testInterface ?? [];
88733
+ paths = [
88734
+ .../* @__PURE__ */ new Set([...iface.map((e) => e.path), ...pathsIn(cardText)])
88735
+ ].slice(0, MAX_PATHS);
88736
+ const names = iface.flatMap((e) => e.names);
88737
+ queries = [
88738
+ head,
88739
+ ...(task.kind !== "recovery" ? task.testTitles ?? [] : []).slice(0, TITLE_QUERIES).map(titleOfTest),
88740
+ names.join(" ")
88741
+ ];
88742
+ }
88743
+ queries = queries.map((q) => flat2(q).slice(0, QUERY_CHARS2).trim()).filter((q, i, all) => q !== "" && all.indexOf(q) === i).slice(0, MAX_QUERIES);
88744
+ if (!queries.length && head) queries = [head];
88137
88745
  const error2 = failing ? [
88138
88746
  ...failing.tests,
88139
88747
  ...failing.output ? [failing.output.slice(0, ERROR_CHARS)] : []
@@ -88189,7 +88797,8 @@ async function checkContext(deps, input) {
88189
88797
  inputsFingerprint: task.inputsFingerprint,
88190
88798
  state,
88191
88799
  relevantIds: judged.relevantIds,
88192
- judgeTag: judged.judgeTag
88800
+ judgeTag: judged.judgeTag,
88801
+ checkVersion: CONTEXT_CHECK_VERSION
88193
88802
  };
88194
88803
  }
88195
88804
  async function gateOnContext(deps, tasks, options) {
@@ -88262,16 +88871,22 @@ async function gateOnContext(deps, tasks, options) {
88262
88871
  }
88263
88872
  return { replay: replay2, noContext, unknown: unknown2 };
88264
88873
  }
88265
- var QUERY_CHARS2, ERROR_CHARS, MAX_PATHS, CONTEXT_REPORT_CHUNK, flat2;
88874
+ var CONTEXT_CHECK_VERSION, QUERY_CHARS2, ERROR_CHARS, MAX_PATHS, HEAD_CHARS, MAX_QUERIES, FAILING_QUERIES, TITLE_QUERIES, CONTEXT_REPORT_CHUNK, flat2;
88266
88875
  var init_replay_context = __esm({
88267
88876
  "src/commands/replay-context.ts"() {
88268
88877
  "use strict";
88269
88878
  init_replay_relevance();
88270
88879
  init_replay_diff();
88271
88880
  init_replay_scale();
88881
+ init_replay_spec();
88882
+ CONTEXT_CHECK_VERSION = 2;
88272
88883
  QUERY_CHARS2 = 200;
88273
88884
  ERROR_CHARS = 1e3;
88274
88885
  MAX_PATHS = 20;
88886
+ HEAD_CHARS = 120;
88887
+ MAX_QUERIES = 5;
88888
+ FAILING_QUERIES = 3;
88889
+ TITLE_QUERIES = 2;
88275
88890
  CONTEXT_REPORT_CHUNK = 100;
88276
88891
  flat2 = (text) => text.replace(/\s+/g, " ").trim();
88277
88892
  }
@@ -88283,6 +88898,7 @@ __export(replay_tasks_exports, {
88283
88898
  BUG_FIX_DONE: () => BUG_FIX_DONE,
88284
88899
  CODE_ONLY_LINE: () => CODE_ONLY_LINE,
88285
88900
  FEATURE_MIN_FILE_RECALL: () => FEATURE_MIN_FILE_RECALL,
88901
+ HAANSI_HINTS: () => HAANSI_HINTS,
88286
88902
  HAANSI_LINE: () => HAANSI_LINE,
88287
88903
  areaOf: () => areaOf,
88288
88904
  cardPrompt: () => cardPrompt,
@@ -88296,7 +88912,8 @@ __export(replay_tasks_exports, {
88296
88912
  mcpConfig: () => mcpConfig,
88297
88913
  overlapOf: () => overlapOf,
88298
88914
  reportBatches: () => reportBatches,
88299
- runStoredReplays: () => runStoredReplays
88915
+ runStoredReplays: () => runStoredReplays,
88916
+ titlesSection: () => titlesSection
88300
88917
  });
88301
88918
  function reportBatches(results, size = (r) => JSON.stringify(r).length) {
88302
88919
  const batches = [];
@@ -88327,7 +88944,18 @@ function listItem(name) {
88327
88944
  const flat3 = name.replace(/[\u0000-\u001f\u007f]+/g, " ").trim();
88328
88945
  return `- \`${flat3.replace(/`/g, "'")}\``;
88329
88946
  }
88330
- function haansiSection(tools) {
88947
+ function titlesSection(titles) {
88948
+ if (titles.length === 0) return [];
88949
+ const { shown, more } = cappedTitles(titles);
88950
+ return [
88951
+ "These tests pass (the target's tests, by title):",
88952
+ "",
88953
+ ...shown.map(listItem),
88954
+ ...more ? [`- +${more} more`] : [],
88955
+ ""
88956
+ ];
88957
+ }
88958
+ function haansiSection(tools, hint = null) {
88331
88959
  return [
88332
88960
  "## Your organization's knowledge (Haansi)",
88333
88961
  "",
@@ -88335,6 +88963,7 @@ function haansiSection(tools) {
88335
88963
  "",
88336
88964
  "Start here, before you read or change any code: search them for this problem (search_solutions with the problem and its error, match_playbook and search_skills for a team playbook, get_prior_attempts with the files you expect to change), and read what applies. Search again when you get stuck.",
88337
88965
  "",
88966
+ ...hint ? [HAANSI_HINTS[hint], ""] : [],
88338
88967
  ...tools.flatMap((s) => [
88339
88968
  `- ${toolLine(s.server)}`,
88340
88969
  ...s.tools.map(
@@ -88367,11 +88996,16 @@ function cardPrompt(task, feedback, arm = "baseline", tools = []) {
88367
88996
  "## Done when",
88368
88997
  "",
88369
88998
  ...failing?.tests.length ? [BUG_FIX_DONE, ""] : [],
88999
+ // A feature's own tests, by title: what a ticket's spec would say.
89000
+ ...task.kind !== "recovery" ? titlesSection(task.testTitles ?? []) : [],
88370
89001
  task.card.acceptance,
88371
89002
  ...task.card.area ? ["", "## Part of the code", "", task.card.area] : [],
88372
89003
  "",
88373
89004
  ...interfaceSection(task.testInterface ?? []),
88374
- ...arm === "haansi" ? tools.length ? haansiSection(tools) : [HAANSI_LINE, ""] : [],
89005
+ ...arm === "haansi" ? tools.length ? haansiSection(
89006
+ tools,
89007
+ failing?.tests.length ? "bug-fix" : task.kind !== "recovery" && task.testInterface?.length ? "feature" : null
89008
+ ) : [HAANSI_LINE, ""] : [],
88375
89009
  ...feedback ? [FEEDBACK_HEADER, "", "```", feedback, "```", ""] : [],
88376
89010
  CODE_ONLY_LINE,
88377
89011
  "",
@@ -88533,11 +89167,31 @@ async function runStoredReplays(options, deps) {
88533
89167
  };
88534
89168
  const interfaceOf = async (task) => {
88535
89169
  if (task.testInterface !== void 0) return;
88536
- task.testInterface = !testNamesOf(task).length && task.baseSha && task.targetSha ? await testInterfaceOf(deps.showFile, {
89170
+ const named = testNamesOf(task);
89171
+ task.testInterface = !named.length && task.baseSha && task.targetSha ? await testInterfaceOf(deps.showFile, {
88537
89172
  baseSha: task.baseSha,
88538
89173
  targetSha: task.targetSha,
88539
89174
  testFiles: task.testFiles
88540
- }).catch(() => []) : [];
89175
+ }).then(
89176
+ (entries) => withSignatures(deps.showFile, task.targetSha, entries)
89177
+ ).catch(() => []) : [];
89178
+ if (task.kind !== "recovery" && task.targetSha)
89179
+ task.testTitles = await targetTestTitles(deps.showFile, {
89180
+ targetSha: task.targetSha,
89181
+ testFiles: task.testFiles
89182
+ }).catch(() => []);
89183
+ if (named.length && task.baseSha)
89184
+ task.failingPaths = await failingPathsOf(
89185
+ deps.showFile,
89186
+ {
89187
+ baseSha: task.baseSha,
89188
+ tests: named,
89189
+ testFiles: task.testFiles,
89190
+ output: task.failing?.output ?? ""
89191
+ },
89192
+ // Failure-tolerant itself: a read or git error skips that source.
89193
+ (args) => (deps.gitStdout ?? deps.git)(args, deps.repoDir)
89194
+ );
88541
89195
  };
88542
89196
  let noContext = 0;
88543
89197
  let contextUnknown = 0;
@@ -88813,7 +89467,7 @@ function haansiText(use) {
88813
89467
  if (!use.used || use.calls === 0 && !handed) return base;
88814
89468
  return use.used === "not_used" ? `${base}, not used` : `${base}, ${use.used === "partly" ? "partly " : ""}used${use.usedItems ? ` (${use.usedItems})` : ""}`;
88815
89469
  }
88816
- var import_node_crypto6, FEEDBACK_HEADER, REPORT_CHUNK2, REPORT_CHARS, HAANSI_LINE, BUG_FIX_DONE, CODE_ONLY_LINE, toolLine, FEATURE_MIN_FILE_RECALL, share2, pct;
89470
+ var import_node_crypto6, FEEDBACK_HEADER, REPORT_CHUNK2, REPORT_CHARS, HAANSI_LINE, BUG_FIX_DONE, CODE_ONLY_LINE, toolLine, HAANSI_HINTS, FEATURE_MIN_FILE_RECALL, share2, pct;
88817
89471
  var init_replay_tasks = __esm({
88818
89472
  "src/commands/replay-tasks.ts"() {
88819
89473
  "use strict";
@@ -88828,6 +89482,7 @@ var init_replay_tasks = __esm({
88828
89482
  init_replay_scale();
88829
89483
  init_replay_codex();
88830
89484
  init_replay_interface();
89485
+ init_replay_spec();
88831
89486
  init_replay_context();
88832
89487
  FEEDBACK_HEADER = "Your previous attempt did not pass the tests. Their output ends with:";
88833
89488
  REPORT_CHUNK2 = 200;
@@ -88839,6 +89494,10 @@ var init_replay_tasks = __esm({
88839
89494
  // eslint-disable-next-line no-control-regex
88840
89495
  text.replace(/[\u0000-\u001f\u007f`]+/g, " ").trim()
88841
89496
  );
89497
+ HAANSI_HINTS = {
89498
+ "bug-fix": "For a failing test, search with its name and the error line, and ask get_prior_attempts with the failing test files and the files they import.",
89499
+ feature: "Ask with the modules and names under 'What the tests use'."
89500
+ };
88842
89501
  FEATURE_MIN_FILE_RECALL = 0.5;
88843
89502
  share2 = (part, whole) => whole === 0 ? null : Math.round(part / whole * 1e3) / 1e3;
88844
89503
  pct = (v) => v === null ? "n/a" : `${Math.round(v * 100)}%`;
@@ -89504,8 +90163,11 @@ it instead of running the setup again; not with --container.
89504
90163
 
89505
90164
  Only tasks Haansi holds relevant context for are replayed. Before any agent
89506
90165
  runs, each valid task is checked: Haansi is searched with only what the agent
89507
- sees at the task's start (its card, a bug fix's failing tests, what its tests
89508
- import, the paths the card names), and the relevance judge (your agent
90166
+ sees at the task's start (a bug fix's failing tests, their error line, the
90167
+ files they are and import, and the files changed by the commits that wrote
90168
+ the lines its stack frames name, or by those files' own last commits before
90169
+ the start; a feature's problem, its tests' titles and the
90170
+ names they use; the paths the card names), and the relevance judge (your agent
89509
90171
  command, once per task checked) says whether anything relevant came back.
89510
90172
  A task with nothing relevant Haansi can return is skipped, and checked again
89511
90173
  once the organization gains new Haansi content. --any-context replays every
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "haansi",
3
- "version": "0.1.102",
3
+ "version": "0.1.103",
4
4
  "description": "Haansi CLI - Session collector and MCP server for Claude Code & OpenAI Codex",
5
5
  "bin": {
6
6
  "haansi": "./dist/haansi.js"