haansi 0.1.113 → 0.1.115

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 +92 -6
  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.113",
98
+ version: "0.1.115",
99
99
  description: "Haansi CLI - Session collector and MCP server for Claude Code & OpenAI Codex",
100
100
  bin: {
101
101
  haansi: "./dist/haansi.js"
@@ -60289,7 +60289,7 @@ var init_stdio2 = __esm({
60289
60289
  function searchSolutionsTool(contextSchema2) {
60290
60290
  return {
60291
60291
  name: "search_solutions",
60292
- 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. Describe the problem in a sentence in query: a test name, an identifier or a list of file names alone rarely matches; pass those in the structured inputs instead. 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.",
60292
+ 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. Most are related problems rather than yours: take an idea, step or check only where it fits your change, check it still applies to the code as it is, and say which you used. Describe the problem in a sentence in query: a test name, an identifier or a list of file names alone rarely matches; pass those in the structured inputs instead. For a failing test, pass its name in failing_tests and the error line in error. Pass the files you changed (or will change), or that the failure runs through, in files.",
60293
60293
  inputSchema: {
60294
60294
  type: "object",
60295
60295
  properties: {
@@ -60309,7 +60309,7 @@ function searchSolutionsTool(contextSchema2) {
60309
60309
  description: "Optional. The error line, e.g. the assertion or exception message"
60310
60310
  },
60311
60311
  files: stringList(
60312
- "Optional. File paths you expect to change, or that the failure runs through"
60312
+ "Optional. File paths you changed (or will change), or that the failure runs through"
60313
60313
  ),
60314
60314
  names: stringList(
60315
60315
  "Optional. Identifiers involved: functions, classes, routes, config keys"
@@ -89186,6 +89186,73 @@ var init_replay_lang = __esm({
89186
89186
  }
89187
89187
  });
89188
89188
 
89189
+ // src/commands/replay-spec-gaps.ts
89190
+ function testKeysOf(source, path2) {
89191
+ const lang = adapterFor(path2);
89192
+ if (!lang) return [];
89193
+ const out = /* @__PURE__ */ new Set();
89194
+ const add = (re) => {
89195
+ for (const m of source.matchAll(re)) out.add(m[1]);
89196
+ };
89197
+ if (lang.id === "js") {
89198
+ add(new RegExp(String.raw`[{,]\s*(${IDENT3})\s*\??:`, "g"));
89199
+ } else {
89200
+ add(new RegExp(String.raw`[(,]\s*(${IDENT3})\s*=(?!=)`, "g"));
89201
+ add(new RegExp(String.raw`["'](${IDENT3})["']\s*:`, "g"));
89202
+ }
89203
+ add(
89204
+ new RegExp(String.raw`(?<!(?:^|[^A-Za-z0-9_$])[0-9]+)\.\s*(${IDENT3})`, "g")
89205
+ );
89206
+ return [...out];
89207
+ }
89208
+ function wordsOf2(text) {
89209
+ return new Set(text.match(new RegExp(IDENT3, "g")) ?? []);
89210
+ }
89211
+ async function specGapsOf(show, grep, task, prompt2) {
89212
+ const shown = wordsOf2(prompt2);
89213
+ const candidates = /* @__PURE__ */ new Set();
89214
+ for (const file2 of task.testFiles) {
89215
+ const source = await show(task.targetSha, file2);
89216
+ if (source === null) continue;
89217
+ for (const key of testKeysOf(source, file2))
89218
+ if (!shown.has(key)) candidates.add(key);
89219
+ }
89220
+ const asked = [...candidates].sort().slice(0, MAX_GAP_CANDIDATES);
89221
+ if (!asked.length) return [];
89222
+ const found = await grep(task.baseSha, asked);
89223
+ return asked.filter((n) => !found.has(n)).slice(0, MAX_GAPS);
89224
+ }
89225
+ function gitGrepNames(run3) {
89226
+ return async (sha, names) => {
89227
+ const found = /* @__PURE__ */ new Set();
89228
+ for (const name of names) {
89229
+ const res = await run3([
89230
+ "grep",
89231
+ "-q",
89232
+ "-w",
89233
+ "-I",
89234
+ "-F",
89235
+ "-e",
89236
+ name,
89237
+ sha,
89238
+ "--"
89239
+ ]).catch(() => null);
89240
+ if (!res || res.code !== 1) found.add(name);
89241
+ }
89242
+ return found;
89243
+ };
89244
+ }
89245
+ var MAX_GAP_CANDIDATES, MAX_GAPS, IDENT3;
89246
+ var init_replay_spec_gaps = __esm({
89247
+ "src/commands/replay-spec-gaps.ts"() {
89248
+ "use strict";
89249
+ init_replay_lang();
89250
+ MAX_GAP_CANDIDATES = 200;
89251
+ MAX_GAPS = 20;
89252
+ IDENT3 = String.raw`[A-Za-z_][A-Za-z0-9_]*`;
89253
+ }
89254
+ });
89255
+
89189
89256
  // src/commands/replay-interface.ts
89190
89257
  async function firstAt(show, sha, paths) {
89191
89258
  for (const path2 of paths) {
@@ -89903,7 +89970,7 @@ function haansiSection(tools, hint = null) {
89903
89970
  "- Incidents like this one: search_prior_incidents.",
89904
89971
  "- Recent work, conventions and shared answers: search_digests, search_guides and search_exchange.",
89905
89972
  "",
89906
- "A test name, an identifier or a list of file names alone rarely finds anything; ask with what is wrong, and pass those in the structured inputs. Read what applies and say which items you used.",
89973
+ "A test name, an identifier or a list of file names alone rarely finds anything; ask with what is wrong, and pass those in the structured inputs. Most of what comes back is a related problem rather than this one: take an idea, step or check only where it fits your change, check it still applies to the code as it is, and say which items you used.",
89907
89974
  "",
89908
89975
  ...hint ? [HAANSI_HINTS[hint], ""] : [],
89909
89976
  ...tools.flatMap((s) => [
@@ -90145,6 +90212,19 @@ async function runStoredReplays(options, deps) {
90145
90212
  targetSha: task.targetSha,
90146
90213
  testFiles: task.testFiles
90147
90214
  }).catch(() => []);
90215
+ if (!named.length && task.baseSha && task.targetSha)
90216
+ task.specGaps = await specGapsOf(
90217
+ deps.showFile,
90218
+ gitGrepNames(
90219
+ (args) => (deps.gitStdout ?? deps.git)(args, deps.repoDir)
90220
+ ),
90221
+ {
90222
+ baseSha: task.baseSha,
90223
+ targetSha: task.targetSha,
90224
+ testFiles: task.testFiles
90225
+ },
90226
+ cardPrompt(task, null)
90227
+ ).catch(() => []);
90148
90228
  if (named.length && task.baseSha)
90149
90229
  task.failingPaths = await failingPathsOf(
90150
90230
  deps.showFile,
@@ -90237,6 +90317,10 @@ async function runStoredReplays(options, deps) {
90237
90317
  deps.log(
90238
90318
  `\u2026 ${label}: the tests use ${task.testInterface.length} module(s) the start lacks; named in the prompt`
90239
90319
  );
90320
+ if (task.specGaps?.length)
90321
+ deps.log(
90322
+ `\u2026 ${label}: the tests rely on ${task.specGaps.length} name(s) the prompt and the start never have: ${task.specGaps.join(", ")}`
90323
+ );
90240
90324
  let targetSent = false;
90241
90325
  let baselineChange = null;
90242
90326
  for (const arm of arms) {
@@ -90404,7 +90488,8 @@ async function runStoredReplays(options, deps) {
90404
90488
  configFingerprint,
90405
90489
  errors: options.noDiffs ? null : r.errors ?? [],
90406
90490
  testCounts: r.testCounts ?? [],
90407
- usage: r.usage ?? []
90491
+ usage: r.usage ?? [],
90492
+ specGaps: task.specGaps ? task.specGaps.length : null
90408
90493
  });
90409
90494
  if (sendTarget) targetSent = true;
90410
90495
  deps.log(
@@ -90461,6 +90546,7 @@ var init_replay_tasks = __esm({
90461
90546
  init_replay();
90462
90547
  init_replay_scale();
90463
90548
  init_replay_codex();
90549
+ init_replay_spec_gaps();
90464
90550
  init_replay_interface();
90465
90551
  init_replay_spec();
90466
90552
  init_replay_context();
@@ -90478,7 +90564,7 @@ var init_replay_tasks = __esm({
90478
90564
  "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.",
90479
90565
  feature: "Ask with the modules and names under 'What the tests use'."
90480
90566
  };
90481
- FEATURE_MIN_FILE_RECALL = 0.5;
90567
+ FEATURE_MIN_FILE_RECALL = 0.4;
90482
90568
  share2 = (part, whole) => whole === 0 ? null : Math.round(part / whole * 1e3) / 1e3;
90483
90569
  pct = (v) => v === null ? "n/a" : `${Math.round(v * 100)}%`;
90484
90570
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "haansi",
3
- "version": "0.1.113",
3
+ "version": "0.1.115",
4
4
  "description": "Haansi CLI - Session collector and MCP server for Claude Code & OpenAI Codex",
5
5
  "bin": {
6
6
  "haansi": "./dist/haansi.js"