@denizokcu/haze 1.7.11 → 1.7.12

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 (80) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +113 -97
  3. package/assets/graph-grammars/NOTICE.md +21 -0
  4. package/assets/graph-grammars/tree-sitter-javascript.wasm +0 -0
  5. package/assets/graph-grammars/tree-sitter-tsx.wasm +0 -0
  6. package/assets/graph-grammars/tree-sitter-typescript.wasm +0 -0
  7. package/assets/graph-grammars/web-tree-sitter.cjs +4116 -0
  8. package/assets/graph-grammars/web-tree-sitter.cjs.map +7 -0
  9. package/assets/graph-grammars/web-tree-sitter.js +4056 -0
  10. package/assets/graph-grammars/web-tree-sitter.js.map +7 -0
  11. package/assets/graph-grammars/web-tree-sitter.wasm +0 -0
  12. package/assets/graph-grammars/web-tree-sitter.wasm.map +55 -0
  13. package/dist/buildInfo.json +3 -3
  14. package/dist/cli/chat/inputSuggestions.js +1 -0
  15. package/dist/cli/chat/sessionLifecycle.js +2 -1
  16. package/dist/cli/chat/sessionRecorder.js +4 -1
  17. package/dist/cli/chat/startupSequence.d.ts +2 -0
  18. package/dist/cli/chat/startupSequence.js +6 -0
  19. package/dist/cli/commands/chat.js +5 -2
  20. package/dist/cli/commands/commandHelp.js +4 -1
  21. package/dist/cli/commands/commands.js +2 -0
  22. package/dist/cli/commands/formatters.js +28 -0
  23. package/dist/cli/commands/graphCommand.d.ts +2 -0
  24. package/dist/cli/commands/graphCommand.js +60 -0
  25. package/dist/cli/commands/initCommand.js +14 -0
  26. package/dist/cli/commands/streaming/agentAttempt.js +11 -1
  27. package/dist/cli/commands/streaming/attemptOutcome.js +1 -1
  28. package/dist/cli/commands/streaming/attemptSetup.d.ts +3 -0
  29. package/dist/cli/commands/streaming/attemptSetup.js +8 -3
  30. package/dist/cli/commands/streaming/goalSupervisor.js +5 -3
  31. package/dist/cli/commands/streaming/prepareStep.js +1 -0
  32. package/dist/cli/commands/streaming/streamLoop.d.ts +2 -0
  33. package/dist/cli/commands/streaming/streamLoop.js +3 -0
  34. package/dist/cli/commands/streaming/toolPartHandlers.js +7 -1
  35. package/dist/cli/commands/streaming.js +5 -0
  36. package/dist/core/agent/compaction.d.ts +1 -0
  37. package/dist/core/agent/compaction.js +3 -0
  38. package/dist/core/graph/analyze.d.ts +61 -0
  39. package/dist/core/graph/analyze.js +274 -0
  40. package/dist/core/graph/buildGraph.d.ts +44 -0
  41. package/dist/core/graph/buildGraph.js +290 -0
  42. package/dist/core/graph/digest.d.ts +2 -0
  43. package/dist/core/graph/digest.js +40 -0
  44. package/dist/core/graph/extract.d.ts +58 -0
  45. package/dist/core/graph/extract.js +394 -0
  46. package/dist/core/graph/model.d.ts +63 -0
  47. package/dist/core/graph/model.js +96 -0
  48. package/dist/core/graph/query.d.ts +69 -0
  49. package/dist/core/graph/query.js +391 -0
  50. package/dist/core/graph/store.d.ts +64 -0
  51. package/dist/core/graph/store.js +171 -0
  52. package/dist/core/process/runBoundedProcess.js +12 -6
  53. package/dist/core/safety/untrustedEnvelopes.d.ts +6 -0
  54. package/dist/core/safety/untrustedEnvelopes.js +17 -2
  55. package/dist/core/subagent/executionProfiles.js +4 -4
  56. package/dist/core/tasks/taskStorage.js +11 -1
  57. package/dist/core/validation/outputParser.js +16 -8
  58. package/dist/llm/hazeTools.d.ts +2 -12426
  59. package/dist/llm/hazeTools.js +2 -0
  60. package/dist/llm/lspTools.d.ts +3 -12622
  61. package/dist/llm/requestContext.d.ts +3 -0
  62. package/dist/llm/requestContext.js +13 -4
  63. package/dist/llm/subagentRunner.d.ts +2 -308
  64. package/dist/llm/systemPrompt.js +7 -4
  65. package/dist/llm/toolResultTypes.d.ts +1 -1
  66. package/dist/llm/tools/fetchTool.d.ts +2 -1221
  67. package/dist/llm/tools/fileTools.d.ts +2 -7768
  68. package/dist/llm/tools/graphAdvisory.d.ts +22 -0
  69. package/dist/llm/tools/graphAdvisory.js +68 -0
  70. package/dist/llm/tools/graphTools.d.ts +13 -0
  71. package/dist/llm/tools/graphTools.js +195 -0
  72. package/dist/llm/tools/processTool.d.ts +2 -1081
  73. package/dist/llm/tools/shellTool.d.ts +2 -1513
  74. package/dist/llm/tools/storedOutputTool.d.ts +2 -355
  75. package/dist/llm/tools/taskTool.d.ts +2 -489
  76. package/dist/llm/tools/toolContext.js +24 -9
  77. package/dist/llm/tools/toolContextState.d.ts +3 -0
  78. package/dist/llm/tools/toolContextState.js +2 -1
  79. package/dist/skills/skillTools.js +4 -1
  80. package/package.json +18 -15
@@ -13,7 +13,12 @@
13
13
  *
14
14
  * One helper for all envelope producers: no ad-hoc per-site escapes.
15
15
  */
16
- const ENVELOPE_CLOSER = /<\/\s*(web_content|mcp_result|project_instructions|project_context|haze_compaction)\s*>/gi;
16
+ const ENVELOPE_TAGS = ['web_content', 'mcp_result', 'project_instructions', 'project_context', 'haze_compaction'];
17
+ const ENVELOPE_CLOSER = new RegExp(`<\\/\\s*(?:${ENVELOPE_TAGS.join('|')})\\s*>`, 'gi');
18
+ /** Neutralize one matched closer by breaking the tag open (`<\/`). */
19
+ function escapeCloserMatch(closer) {
20
+ return closer.replace('</', '<\\/');
21
+ }
17
22
  /**
18
23
  * Escape every envelope-closing-tag variant in `content` so the payload
19
24
  * cannot forge an envelope boundary. The escape breaks the tag open (`<\/`)
@@ -21,5 +26,15 @@ const ENVELOPE_CLOSER = /<\/\s*(web_content|mcp_result|project_instructions|proj
21
26
  * the exact form keep working because the producer's own closer is intact.
22
27
  */
23
28
  export function escapeEnvelopeClosers(content) {
24
- return content.replace(ENVELOPE_CLOSER, closer => closer.replace('</', '<\\/'));
29
+ return content.replace(ENVELOPE_CLOSER, escapeCloserMatch);
30
+ }
31
+ /**
32
+ * Escape every closing-tag variant of one additional labeled container (e.g.
33
+ * `project_skill`) with the same variant tolerance as the five built-in
34
+ * kinds, so ad-hoc per-site `replaceAll` escapes cannot reappear.
35
+ */
36
+ export function escapeTagCloserVariants(content, tag) {
37
+ if (!/^[a-z0-9_]+$/i.test(tag))
38
+ throw new Error(`Invalid envelope tag: ${tag}`);
39
+ return content.replace(new RegExp(`<\\/\\s*${tag}\\s*>`, 'gi'), escapeCloserMatch);
25
40
  }
@@ -27,10 +27,10 @@ export const BUILT_IN_SUBAGENT_PROFILES = {
27
27
  'cloud-fast': { ...COMPATIBILITY_PROFILE, name: 'cloud-fast', maxConcurrency: 5, deadlineMs: 240_000, maxRetries: 1 },
28
28
  };
29
29
  export const MODE_TOOL_NAMES = {
30
- inspect: ['listFiles', 'readFile', 'grep', 'readToolOutput'],
31
- research: ['listFiles', 'readFile', 'grep', 'readToolOutput', 'fetch'],
32
- implement: ['listFiles', 'readFile', 'grep', 'readToolOutput', 'editFile', 'replaceLines', 'writeFile', 'shell'],
33
- validate: ['listFiles', 'readFile', 'grep', 'readToolOutput', 'shell'],
30
+ inspect: ['listFiles', 'readFile', 'grep', 'readToolOutput', 'graphQuery', 'graphExplain', 'graphPath'],
31
+ research: ['listFiles', 'readFile', 'grep', 'readToolOutput', 'fetch', 'graphQuery', 'graphExplain', 'graphPath'],
32
+ implement: ['listFiles', 'readFile', 'grep', 'readToolOutput', 'editFile', 'replaceLines', 'writeFile', 'shell', 'graphQuery', 'graphAffected'],
33
+ validate: ['listFiles', 'readFile', 'grep', 'readToolOutput', 'shell', 'graphAffected'],
34
34
  };
35
35
  export function isMutationMode(mode) {
36
36
  return mode === 'implement' || mode === 'validate';
@@ -40,7 +40,17 @@ export async function saveTasks(tasks) {
40
40
  // Mutation guards fail closed: an escaped real path throws instead of writing.
41
41
  await assertWritablePathInsideWorkspace(filePath, filePath);
42
42
  await fs.mkdir(path.dirname(filePath), { recursive: true });
43
- await fs.writeFile(filePath, JSON.stringify(tasks, null, 2), 'utf-8');
43
+ // Atomic temp-file-plus-rename (same directory) so a crash mid-write cannot
44
+ // leave truncated JSON that loadTasks would silently reset to an empty list.
45
+ const tempPath = `${filePath}.tmp-${randomUUID()}`;
46
+ await fs.writeFile(tempPath, JSON.stringify(tasks, null, 2), 'utf-8');
47
+ try {
48
+ await fs.rename(tempPath, filePath);
49
+ }
50
+ catch (error) {
51
+ await fs.rm(tempPath, { force: true }).catch(() => undefined);
52
+ throw error;
53
+ }
44
54
  }
45
55
  export async function clearTasks() {
46
56
  await saveTasks([]);
@@ -36,14 +36,17 @@ export function parseValidationOutput(input) {
36
36
  if (ts) {
37
37
  const [, file, lineNo, column, severity, message] = ts;
38
38
  diagnostics.push({ file, line: Number(lineNo), column: Number(column), severity: severity === 'warning' ? 'warning' : 'error', message: message ?? '' });
39
- failedFiles.push(file ?? '');
39
+ if (severity !== 'warning')
40
+ failedFiles.push(file ?? '');
40
41
  continue;
41
42
  }
42
43
  const eslint = line.match(/^(.+?\.(?:ts|tsx|js|jsx|mts|cts))\s*$/);
43
44
  if (eslint) {
44
45
  const currentFile = eslint[1] ?? '';
45
46
  const next = lines[index + 1];
46
- if (next && /^\s*\d+:\d+\s+/.test(next))
47
+ // Only error-severity follow-up lines make this a failed file; a
48
+ // warnings-only run must not populate `failedFiles`.
49
+ if (next && /^\s*\d+:\d+\s+error\s/.test(next))
47
50
  failedFiles.push(currentFile);
48
51
  }
49
52
  const eslintDiag = line.match(/^\s*(\d+):(\d+)\s+(error|warning)\s+(.+?)(?:\s{2,}\S+)?$/);
@@ -52,7 +55,7 @@ export function parseValidationOutput(input) {
52
55
  diagnostics.push({ line: Number(lineNo), column: Number(column), severity: severity === 'warning' ? 'warning' : 'error', message: message ?? '' });
53
56
  continue;
54
57
  }
55
- const vitestFile = line.match(/^\s*(?:FAIL|FAILED|✓|✗|❯)?\s*([^\s]+\.(?:test|spec)\.(?:ts|tsx|js|jsx))/i);
58
+ const vitestFile = line.match(/^\s*(?:FAIL|FAILED|✗|❯)?\s*([^\s]+\.(?:test|spec)\.(?:ts|tsx|js|jsx))/i);
56
59
  if (vitestFile)
57
60
  failedFiles.push(vitestFile[1] ?? '');
58
61
  const testName = line.match(/^\s*(?:FAIL|✗|×|●)\s+(.+)$/);
@@ -61,19 +64,24 @@ export function parseValidationOutput(input) {
61
64
  const genericFile = line.match(/([^\s()]+\.(?:ts|tsx|js|jsx|mts|cts)):(\d+):(\d+)/);
62
65
  if (genericFile) {
63
66
  const [, file, lineNo, column] = genericFile;
64
- failedFiles.push(file ?? '');
65
- diagnostics.push({ file, line: Number(lineNo), column: Number(column), severity: /warn/i.test(line) ? 'warning' : 'error', message: line.trim() });
67
+ const severity = /warn/i.test(line) ? 'warning' : 'error';
68
+ diagnostics.push({ file, line: Number(lineNo), column: Number(column), severity, message: line.trim() });
69
+ if (severity === 'error')
70
+ failedFiles.push(file ?? '');
66
71
  }
67
72
  }
68
73
  const uniqueFiles = uniq(failedFiles).slice(0, 10);
69
74
  const uniqueTests = uniq(failedTests).slice(0, 10);
70
75
  const diagCount = diagnostics.length;
76
+ const errorDiagCount = diagnostics.filter(diagnostic => diagnostic.severity === 'error').length;
71
77
  const rawOutputTruncated = Boolean(input.stdoutTruncated || input.stderrTruncated);
72
78
  // Pipes (e.g. `npm test | tail`) and process substitutions can mask a
73
79
  // non-zero exit code behind the final command in the pipeline. Treat
74
- // parsed failure evidence as authoritative over `code` so a green exit
75
- // status does not override real failures the parser already found.
76
- const hasFailureEvidence = uniqueTests.length > 0 || diagCount > 0;
80
+ // parsed *failure* evidence as authoritative over `code` so a green exit
81
+ // status does not override real failures the parser already found. Only
82
+ // error-severity diagnostics and failed tests count: warning diagnostics
83
+ // never fail an otherwise-green run (ESLint exits 0 on warnings only).
84
+ const hasFailureEvidence = uniqueTests.length > 0 || errorDiagCount > 0;
77
85
  const status = input.timedOut
78
86
  ? 'timed_out'
79
87
  : hasFailureEvidence