@denizokcu/haze 0.4.0 → 0.6.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.
Files changed (79) hide show
  1. package/CHANGELOG.md +45 -1
  2. package/README.md +68 -36
  3. package/dist/cli/commands/chat.d.ts +1 -1
  4. package/dist/cli/commands/chat.js +789 -106
  5. package/dist/cli/commands/commands.d.ts +2 -1
  6. package/dist/cli/commands/commands.js +77 -102
  7. package/dist/cli/commands/formatters.d.ts +27 -0
  8. package/dist/cli/commands/formatters.js +137 -0
  9. package/dist/cli/commands/streaming.d.ts +14 -13
  10. package/dist/cli/commands/streaming.js +399 -665
  11. package/dist/config/contextFiles.d.ts +6 -0
  12. package/dist/config/contextFiles.js +47 -16
  13. package/dist/config/lspSettings.d.ts +16 -0
  14. package/dist/config/lspSettings.js +98 -0
  15. package/dist/config/mcpSettings.d.ts +24 -0
  16. package/dist/config/mcpSettings.js +100 -0
  17. package/dist/config/providers.d.ts +2 -5
  18. package/dist/config/providers.js +16 -12
  19. package/dist/config/settings.d.ts +34 -0
  20. package/dist/config/skillSettings.d.ts +15 -0
  21. package/dist/config/skillSettings.js +31 -0
  22. package/dist/config/updateCheck.d.ts +44 -0
  23. package/dist/config/updateCheck.js +83 -0
  24. package/dist/core/agent/requestAssembly.js +12 -1
  25. package/dist/core/agent/toolOutputStore.d.ts +6 -1
  26. package/dist/core/agent/toolOutputStore.js +33 -1
  27. package/dist/core/bashOutput/ansi.d.ts +1 -0
  28. package/dist/core/bashOutput/ansi.js +7 -0
  29. package/dist/core/bashOutput/command.d.ts +2 -0
  30. package/dist/core/bashOutput/command.js +62 -0
  31. package/dist/core/bashOutput/lineFilter.d.ts +25 -0
  32. package/dist/core/bashOutput/lineFilter.js +62 -0
  33. package/dist/core/bashOutput/reducers/content.d.ts +3 -0
  34. package/dist/core/bashOutput/reducers/content.js +134 -0
  35. package/dist/core/bashOutput/reducers/git.d.ts +1 -0
  36. package/dist/core/bashOutput/reducers/git.js +147 -0
  37. package/dist/core/bashOutput/reducers/search.d.ts +7 -0
  38. package/dist/core/bashOutput/reducers/search.js +76 -0
  39. package/dist/core/bashOutput/reducers/validation.d.ts +2 -0
  40. package/dist/core/bashOutput/reducers/validation.js +41 -0
  41. package/dist/core/bashOutput/registry.d.ts +4 -0
  42. package/dist/core/bashOutput/registry.js +126 -0
  43. package/dist/core/bashOutput/types.d.ts +46 -0
  44. package/dist/core/bashOutput/types.js +1 -0
  45. package/dist/core/goal/completionPolicy.d.ts +1 -0
  46. package/dist/core/goal/completionPolicy.js +4 -0
  47. package/dist/core/safety/urlGuard.d.ts +37 -0
  48. package/dist/core/safety/urlGuard.js +206 -0
  49. package/dist/core/subagent/subagentRunner.d.ts +1 -1
  50. package/dist/core/subagent/subagentRunner.js +2 -2
  51. package/dist/core/toolOutput/reduction.d.ts +25 -0
  52. package/dist/core/toolOutput/reduction.js +23 -0
  53. package/dist/llm/client.d.ts +2 -2
  54. package/dist/llm/client.js +6 -4
  55. package/dist/llm/hazeTools.d.ts +133 -16
  56. package/dist/llm/hazeTools.js +205 -31
  57. package/dist/llm/initPrompt.js +2 -1
  58. package/dist/llm/lsp.d.ts +64 -0
  59. package/dist/llm/lsp.js +241 -0
  60. package/dist/llm/lspTools.d.ts +122 -0
  61. package/dist/llm/lspTools.js +115 -0
  62. package/dist/llm/mcp.d.ts +19 -0
  63. package/dist/llm/mcp.js +64 -0
  64. package/dist/llm/requestContext.d.ts +28 -0
  65. package/dist/llm/requestContext.js +56 -0
  66. package/dist/llm/systemPrompt.d.ts +4 -1
  67. package/dist/llm/systemPrompt.js +11 -3
  68. package/dist/llm/toolResultTypes.d.ts +1 -1
  69. package/dist/llm/webFetch.d.ts +57 -0
  70. package/dist/llm/webFetch.js +270 -0
  71. package/dist/skills/builder/SkillBuilder.js +23 -44
  72. package/dist/ui/components/MarkdownText.d.ts +2 -0
  73. package/dist/ui/components/MarkdownText.js +116 -3
  74. package/dist/ui/components/TextInput.d.ts +1 -1
  75. package/dist/utils/version.d.ts +20 -0
  76. package/dist/utils/version.js +72 -0
  77. package/package.json +18 -10
  78. package/dist/cli/commands/skills.d.ts +0 -4
  79. package/dist/cli/commands/skills.js +0 -38
@@ -14,7 +14,7 @@ function MarkdownBlock({ token, width }) {
14
14
  switch (token.type) {
15
15
  case 'heading': {
16
16
  const heading = token;
17
- return _jsx(Box, { marginTop: heading.depth <= 2 ? 1 : 0, children: _jsxs(Text, { color: theme.purple, bold: true, children: ['#'.repeat(heading.depth), " ", _jsx(InlineMarkdown, { text: heading.text })] }) });
17
+ return _jsx(HeadingBlock, { heading: heading, width: width });
18
18
  }
19
19
  case 'paragraph': {
20
20
  const paragraph = token;
@@ -42,12 +42,28 @@ function MarkdownBlock({ token, width }) {
42
42
  }
43
43
  case 'table': {
44
44
  const table = token;
45
- return _jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsx(Text, { color: theme.violet, children: table.header.map(cell => stripInline(cell.text)).join(' | ') }), _jsx(Text, { color: theme.deepPurple, children: table.header.map(() => '---').join(' | ') }), table.rows.map((row, index) => _jsx(Text, { children: row.map(cell => stripInline(cell.text)).join(' | ') }, index))] });
45
+ const lines = renderMarkdownTable(table, width);
46
+ return _jsx(Box, { flexDirection: "column", marginBottom: 1, children: lines.map((line, index) => _jsx(TableLine, { line: line }, index)) });
46
47
  }
47
48
  default:
48
49
  return _jsx(Text, { children: 'raw' in token ? String(token.raw) : '' });
49
50
  }
50
51
  }
52
+ function HeadingBlock({ heading, width }) {
53
+ const title = stripInline(heading.text).trim();
54
+ if (heading.depth === 1)
55
+ return _jsxs(Box, { flexDirection: "column", marginTop: 1, marginBottom: 1, children: [_jsx(Text, { color: theme.purple, bold: true, children: title.toUpperCase() }), _jsx(Text, { color: theme.deepPurple, children: '─'.repeat(Math.min(width, Math.max(12, visibleLength(title)))) })] });
56
+ if (heading.depth === 2)
57
+ return _jsx(Box, { marginTop: 1, marginBottom: 1, children: _jsx(Text, { color: theme.purple, bold: true, children: title }) });
58
+ return _jsx(Box, { marginTop: heading.depth <= 3 ? 1 : 0, children: _jsx(Text, { color: theme.violet, bold: true, children: title }) });
59
+ }
60
+ function TableLine({ line }) {
61
+ if (isTableBorder(line))
62
+ return _jsx(Text, { color: theme.deepPurple, children: line });
63
+ return _jsx(Text, { children: [...line].map((char, index) => char === '│'
64
+ ? _jsx(Text, { color: theme.deepPurple, children: char }, index)
65
+ : _jsx(Text, { children: char }, index)) });
66
+ }
51
67
  function CodeBlock({ code, language, width }) {
52
68
  let rendered;
53
69
  try {
@@ -94,6 +110,100 @@ function tokenizeInline(text) {
94
110
  out.push({ kind: 'text', text: text.slice(last) });
95
111
  return out;
96
112
  }
113
+ export function renderMarkdownTable(table, maxWidth) {
114
+ const rows = [table.header, ...table.rows].map(row => row.map(cell => normalizeTableCell(cell.text)));
115
+ const columnCount = Math.max(table.header.length, ...table.rows.map(row => row.length), 0);
116
+ const widths = tableColumnWidths(rows, columnCount, maxWidth);
117
+ const aligns = Array.from({ length: columnCount }, (_, column) => table.align[column] ?? null);
118
+ const border = (left, separator, right) => `${left}${widths.map(width => '─'.repeat(width + 2)).join(separator)}${right}`;
119
+ const rowLines = (row, isHeader = false) => {
120
+ const wrappedCells = widths.map((width, column) => wrapTableCell(row[column] ?? '', width));
121
+ const height = Math.max(1, ...wrappedCells.map(cell => cell.length));
122
+ return Array.from({ length: height }, (_, line) => `│${widths.map((width, column) => {
123
+ const align = isHeader ? null : aligns[column];
124
+ return ` ${alignCell(wrappedCells[column]?.[line] ?? '', width, align)} `;
125
+ }).join('│')}│`);
126
+ };
127
+ return [
128
+ border('┌', '┬', '┐'),
129
+ ...rowLines(rows[0] ?? [], true),
130
+ border('├', '┼', '┤'),
131
+ ...rows.slice(1).flatMap(row => rowLines(row)),
132
+ border('└', '┴', '┘'),
133
+ ];
134
+ }
135
+ function tableColumnWidths(rows, columnCount, maxWidth) {
136
+ const naturalWidths = Array.from({ length: columnCount }, (_, column) => Math.max(3, ...rows.map(row => visibleLength(row[column] ?? ''))));
137
+ if (!maxWidth)
138
+ return naturalWidths;
139
+ const contentBudget = Math.max(columnCount, maxWidth - (columnCount * 3 + 1));
140
+ if (naturalWidths.reduce((sum, width) => sum + width, 0) <= contentBudget)
141
+ return naturalWidths;
142
+ const minWidths = naturalWidths.map(width => Math.min(3, width));
143
+ const widths = [...naturalWidths];
144
+ while (widths.reduce((sum, width) => sum + width, 0) > contentBudget) {
145
+ let widest = -1;
146
+ for (let index = 0; index < widths.length; index++) {
147
+ if (widths[index] > minWidths[index] && (widest === -1 || widths[index] > widths[widest]))
148
+ widest = index;
149
+ }
150
+ if (widest === -1)
151
+ break;
152
+ widths[widest]--;
153
+ }
154
+ return widths;
155
+ }
156
+ function wrapTableCell(text, width) {
157
+ if (!text)
158
+ return [''];
159
+ const lines = [];
160
+ let current = '';
161
+ const flush = () => {
162
+ lines.push(current);
163
+ current = '';
164
+ };
165
+ for (const word of text.split(/\s+/)) {
166
+ if (!word)
167
+ continue;
168
+ if (!current && visibleLength(word) > width) {
169
+ for (let index = 0; index < word.length; index += width)
170
+ lines.push(word.slice(index, index + width));
171
+ continue;
172
+ }
173
+ const next = current ? `${current} ${word}` : word;
174
+ if (visibleLength(next) <= width)
175
+ current = next;
176
+ else {
177
+ flush();
178
+ if (visibleLength(word) > width) {
179
+ for (let index = 0; index < word.length; index += width)
180
+ lines.push(word.slice(index, index + width));
181
+ }
182
+ else {
183
+ current = word;
184
+ }
185
+ }
186
+ }
187
+ if (current || lines.length === 0)
188
+ lines.push(current);
189
+ return lines;
190
+ }
191
+ function isTableBorder(line) {
192
+ return line.startsWith('┌') || line.startsWith('├') || line.startsWith('└');
193
+ }
194
+ function normalizeTableCell(text) {
195
+ return stripInline(text).replace(/\s+/g, ' ').trim();
196
+ }
197
+ function alignCell(value, width, align) {
198
+ const padding = Math.max(0, width - visibleLength(value));
199
+ if (align === 'right')
200
+ return `${' '.repeat(padding)}${value}`;
201
+ if (align === 'center') {
202
+ const left = Math.floor(padding / 2);
203
+ return `${' '.repeat(left)}${value}${' '.repeat(padding - left)}`;
204
+ }
205
+ return `${value}${' '.repeat(padding)}`;
206
+ }
97
207
  function stripInline(text) {
98
208
  return text
99
209
  .replace(/`([^`]+)`/g, '$1')
@@ -102,7 +212,10 @@ function stripInline(text) {
102
212
  .replace(/~~([^~]+)~~/g, '$1')
103
213
  .replace(/\[([^\]]+)\]\([^)]+\)/g, '$1');
104
214
  }
215
+ function visibleLength(value) {
216
+ return stripAnsi(value).length;
217
+ }
105
218
  function padAnsi(value, width) {
106
- const visible = stripAnsi(value).length;
219
+ const visible = visibleLength(value);
107
220
  return visible >= width ? value : value + ' '.repeat(width - visible);
108
221
  }
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  export type TextInputSuggestion = {
3
3
  value: string;
4
4
  description?: string;
5
- kind?: 'command' | 'skill' | 'provider' | 'model';
5
+ kind?: 'command' | 'skill' | 'provider' | 'model' | 'lsp' | 'mcp';
6
6
  };
7
7
  export declare function TextInput({ placeholder, disabled, mask, historyItems, recordHistory, suggestions, suggestionMode, submitOnEmpty, width, onHistoryAdd, onCancel, onEscape, onToggleTasks, onSubmit }: {
8
8
  placeholder?: string;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Minimal, dependency-free version comparison for the update check.
3
+ *
4
+ * Handles npm package versions like `0.6.0`, `1.2.3`, with optional leading
5
+ * `v` and optional pre-release suffix (`1.0.0-beta.1`). Numeric release
6
+ * segments are compared numerically; pre-release sorts *below* its release
7
+ * (so `1.0.0-beta.1` is older than `1.0.0`). Malformed input is treated as
8
+ * `0.0.0` so the check degrades to "no update" rather than throwing.
9
+ *
10
+ * Kept small on purpose: no `semver` dependency for a single comparison.
11
+ */
12
+ export interface ParsedVersion {
13
+ release: [number, number, number];
14
+ prerelease: string[];
15
+ }
16
+ export declare function parseVersion(input: string): ParsedVersion;
17
+ /** Returns -1 if `a` is older than `b`, 0 if equal, 1 if `a` is newer. */
18
+ export declare function compareVersions(a: string, b: string): number;
19
+ /** True when `latest` is strictly newer than `current`. */
20
+ export declare function isNewer(latest: string, current: string): boolean;
@@ -0,0 +1,72 @@
1
+ export function parseVersion(input) {
2
+ const cleaned = input.trim().replace(/^v/i, '');
3
+ // Drop build metadata: everything from the first '+' onward is ignored.
4
+ const withoutBuild = cleaned.split('+')[0] ?? '';
5
+ // Pre-release is denoted by the first '-' after the release identifier.
6
+ const dashIndex = withoutBuild.indexOf('-');
7
+ const releasePart = dashIndex >= 0 ? withoutBuild.slice(0, dashIndex) : withoutBuild;
8
+ // No numeric release segment => treat the whole input as 0.0.0 (no pre-release).
9
+ if (!/\d/.test(releasePart))
10
+ return { release: [0, 0, 0], prerelease: [] };
11
+ const segments = releasePart.split('.');
12
+ const nums = [0, 0, 0];
13
+ for (let index = 0; index < 3; index++) {
14
+ const parsed = Number.parseInt((segments[index] ?? '').replace(/[^0-9]/g, ''), 10);
15
+ nums[index] = Number.isFinite(parsed) ? parsed : 0;
16
+ }
17
+ const prereleasePart = dashIndex >= 0 ? withoutBuild.slice(dashIndex + 1) : '';
18
+ const prerelease = prereleasePart ? prereleasePart.split('.').map(part => part.trim()).filter(Boolean) : [];
19
+ return { release: nums, prerelease };
20
+ }
21
+ function comparePrerelease(a, b) {
22
+ // No prerelease suffix means "higher" than any prerelease; handled by caller.
23
+ const max = Math.max(a.length, b.length);
24
+ for (let index = 0; index < max; index++) {
25
+ if (index >= a.length)
26
+ return -1; // a is shorter → a is older
27
+ if (index >= b.length)
28
+ return 1;
29
+ const aa = a[index];
30
+ const bb = b[index];
31
+ const anum = Number(aa);
32
+ const bnum = Number(bb);
33
+ const bothNumeric = Number.isFinite(anum) && Number.isFinite(bnum);
34
+ if (bothNumeric) {
35
+ if (anum < bnum)
36
+ return -1;
37
+ if (anum > bnum)
38
+ return 1;
39
+ }
40
+ else {
41
+ if (aa < bb)
42
+ return -1;
43
+ if (aa > bb)
44
+ return 1;
45
+ }
46
+ }
47
+ return 0;
48
+ }
49
+ /** Returns -1 if `a` is older than `b`, 0 if equal, 1 if `a` is newer. */
50
+ export function compareVersions(a, b) {
51
+ const pa = parseVersion(a);
52
+ const pb = parseVersion(b);
53
+ for (let index = 0; index < 3; index++) {
54
+ if (pa.release[index] < pb.release[index])
55
+ return -1;
56
+ if (pa.release[index] > pb.release[index])
57
+ return 1;
58
+ }
59
+ const aHasPre = pa.prerelease.length > 0;
60
+ const bHasPre = pb.prerelease.length > 0;
61
+ if (!aHasPre && bHasPre)
62
+ return 1; // release is newer than prerelease
63
+ if (aHasPre && !bHasPre)
64
+ return -1;
65
+ if (aHasPre && bHasPre)
66
+ return comparePrerelease(pa.prerelease, pb.prerelease);
67
+ return 0;
68
+ }
69
+ /** True when `latest` is strictly newer than `current`. */
70
+ export function isNewer(latest, current) {
71
+ return compareVersions(latest, current) > 0;
72
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@denizokcu/haze",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "description": "A pragmatic agentic CLI for building apps from the terminal.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -44,30 +44,38 @@
44
44
  "prepublishOnly": "npm run typecheck && npm run build"
45
45
  },
46
46
  "dependencies": {
47
- "@ai-sdk/openai": "3.0.67",
47
+ "@ai-sdk/mcp": "^1.0.52",
48
+ "@ai-sdk/openai": "3.0.73",
48
49
  "@inquirer/prompts": "8.5.2",
49
50
  "@vscode/ripgrep": "1.18.0",
50
- "ai": "6.0.194",
51
+ "ai": "6.0.208",
51
52
  "cli-highlight": "2.1.11",
52
53
  "commander": "15.0.0",
54
+ "defuddle": "^0.19.0",
53
55
  "fs-extra": "11.3.5",
54
- "ink": "7.0.5",
56
+ "ink": "7.1.0",
55
57
  "ink-spinner": "5.0.0",
56
- "marked": "18.0.4",
58
+ "linkedom": "^0.18.12",
59
+ "marked": "18.0.5",
57
60
  "react": "19.2.7",
58
61
  "strip-ansi": "7.2.0",
62
+ "turndown": "^7.2.4",
59
63
  "yaml": "2.9.0",
60
64
  "zod": "4.4.3"
61
65
  },
62
66
  "devDependencies": {
63
67
  "@eslint/js": "^10.0.1",
64
68
  "@types/fs-extra": "11.0.4",
65
- "@types/node": "25.9.1",
66
- "@types/react": "19.2.16",
67
- "eslint": "^10.4.1",
69
+ "@types/node": "26.0.0",
70
+ "@types/react": "19.2.17",
71
+ "eslint": "^10.5.0",
68
72
  "tsx": "4.22.4",
69
73
  "typescript": "6.0.3",
70
- "typescript-eslint": "^8.60.1",
71
- "vitest": "^4.1.8"
74
+ "typescript-eslint": "^8.61.1",
75
+ "vitest": "^4.1.9"
76
+ },
77
+ "allowScripts": {
78
+ "esbuild@0.28.1": true,
79
+ "fsevents@2.3.3": true
72
80
  }
73
81
  }
@@ -1,4 +0,0 @@
1
- export declare function listSkills(): Promise<void>;
2
- export declare function infoSkill(name: string): Promise<void>;
3
- export declare function removeSkill(name: string): Promise<void>;
4
- export declare function validateSkill(target: string): Promise<void>;
@@ -1,38 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { render, Box, Text } from 'ink';
3
- import fs from 'fs-extra';
4
- import path from 'node:path';
5
- import { confirm } from '@inquirer/prompts';
6
- import { GLOBAL_SKILLS_DIR } from '../../config/paths.js';
7
- import { loadSkillRegistry } from '../../skills/SkillRegistry.js';
8
- import { Header } from '../../ui/components/Header.js';
9
- import { theme } from '../../ui/theme.js';
10
- export async function listSkills() {
11
- const registry = await loadSkillRegistry();
12
- render(_jsxs(Box, { flexDirection: "column", children: [_jsx(Header, { subtitle: "Installed skills" }), [...registry.skills.values()].map(s => _jsxs(Text, { children: [_jsx(Text, { color: theme.purple, children: s.name }), " \u2014 ", s.description] }, s.name))] }));
13
- }
14
- export async function infoSkill(name) {
15
- const registry = await loadSkillRegistry();
16
- const skill = registry.skills.get(name);
17
- if (!skill)
18
- throw new Error(`No skill named ${name}`);
19
- render(_jsxs(Box, { flexDirection: "column", children: [_jsx(Header, { subtitle: `Skill: ${name}` }), _jsx(Text, { children: skill.description }), _jsx(Text, { color: theme.violet, children: "References" }), skill.references.map(r => _jsxs(Text, { children: [" ", r.path] }, r.path)), _jsx(Text, { color: theme.violet, children: "Path" }), _jsx(Text, { children: skill.dir })] }));
20
- }
21
- export async function removeSkill(name) {
22
- const registry = await loadSkillRegistry();
23
- const skill = registry.skills.get(name);
24
- if (!skill)
25
- throw new Error(`No skill named ${name}`);
26
- const ok = await confirm({ message: `Remove ${name} from ${skill.dir}?`, default: false });
27
- if (!ok)
28
- return;
29
- await fs.remove(skill.dir);
30
- console.log(`Removed ${name}. A rare case of subtraction as progress.`);
31
- }
32
- export async function validateSkill(target) {
33
- const { loadSkill } = await import('../../skills/SkillLoader.js');
34
- const direct = path.resolve(target);
35
- const dir = await fs.pathExists(path.join(direct, 'SKILL.md')) ? direct : path.join(GLOBAL_SKILLS_DIR, target);
36
- const skill = await loadSkill(dir, 'global');
37
- console.log(skill ? `Valid: ${skill.name}` : 'No SKILL.md found');
38
- }