@denizokcu/haze 0.7.0 → 0.8.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.
- package/CHANGELOG.md +24 -8
- package/README.md +31 -31
- package/dist/cli/chat/inputSuggestions.js +2 -2
- package/dist/cli/commands/chat.js +46 -20
- package/dist/cli/commands/chatModes.js +1 -1
- package/dist/cli/commands/commandHelp.js +2 -2
- package/dist/cli/commands/formatters.d.ts +6 -0
- package/dist/cli/commands/formatters.js +38 -0
- package/dist/cli/commands/streaming.js +34 -23
- package/dist/cli/commands/wizardSuggestions.js +1 -1
- package/dist/config/providers.js +5 -9
- package/dist/config/settings.d.ts +1 -0
- package/dist/config/settings.js +54 -2
- package/dist/core/agent/compaction.js +2 -2
- package/dist/core/agent/errors.js +1 -1
- package/dist/core/agent/requestAssembly.d.ts +1 -0
- package/dist/core/agent/requestAssembly.js +13 -0
- package/dist/core/bashOutput/registry.js +11 -9
- package/dist/core/goal/completionPolicy.js +1 -1
- package/dist/core/subagent/subagentRunner.d.ts +252 -9
- package/dist/core/subagent/subagentRunner.js +13 -18
- package/dist/core/toolOutput/reduction.d.ts +2 -0
- package/dist/core/toolOutput/reduction.js +12 -0
- package/dist/core/validation/outputParser.js +5 -3
- package/dist/llm/client.d.ts +2 -2
- package/dist/llm/client.js +15 -2
- package/dist/llm/hazeTools.d.ts +7709 -364
- package/dist/llm/hazeTools.js +7 -1
- package/dist/llm/initPrompt.js +1 -1
- package/dist/llm/lsp.js +10 -1
- package/dist/llm/lspTools.d.ts +2310 -101
- package/dist/llm/systemPrompt.js +2 -2
- package/dist/llm/tools/bashTool.d.ts +251 -5
- package/dist/llm/tools/bashTool.js +4 -3
- package/dist/llm/tools/fetchTool.d.ts +1201 -65
- package/dist/llm/tools/fetchTool.js +2 -1
- package/dist/llm/tools/storedOutputTool.d.ts +351 -10
- package/dist/llm/tools/taskTool.d.ts +629 -28
- package/dist/llm/tools/toolContext.d.ts +7 -2
- package/dist/llm/tools/toolContext.js +11 -2
- package/dist/llm/webFetch.js +31 -21
- package/dist/skills/builder/SkillBuilder.js +7 -7
- package/dist/ui/components/TextInput.d.ts +7 -0
- package/dist/ui/components/TextInput.js +10 -0
- package/dist/utils/modelName.d.ts +2 -0
- package/dist/utils/modelName.js +15 -0
- package/examples/skills/files/SKILL.md +1 -1
- package/package.json +14 -14
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
1
2
|
import { readScopedContextFilesForPath } from '../../config/contextFiles.js';
|
|
2
3
|
import { workspaceRoot } from '../../utils/path.js';
|
|
3
4
|
import { isFailedToolOutput, toolInputField } from '../../core/agent/toolResults.js';
|
|
@@ -16,11 +17,19 @@ function stableJsonStringify(value) {
|
|
|
16
17
|
function toolCallKey(toolName, input) {
|
|
17
18
|
return `${toolName}:${stableJsonStringify(input)}`;
|
|
18
19
|
}
|
|
20
|
+
export const hazeToolContextSchema = z.custom(value => typeof value === 'object' && value !== null);
|
|
19
21
|
export function hazeContext(context) {
|
|
20
|
-
|
|
21
|
-
? context.
|
|
22
|
+
const value = typeof context.context === 'object' && context.context != null
|
|
23
|
+
? context.context
|
|
24
|
+
: context.experimental_context;
|
|
25
|
+
return typeof value === 'object' && value != null
|
|
26
|
+
? value
|
|
22
27
|
: undefined;
|
|
23
28
|
}
|
|
29
|
+
export function toolsContextFor(tools, context) {
|
|
30
|
+
const hazeToolNames = new Set(['listFiles', 'readFile', 'grep', 'replaceLines', 'writeFile', 'editFile', 'bash', 'fetch']);
|
|
31
|
+
return Object.fromEntries(Object.keys(tools).filter(name => hazeToolNames.has(name)).map(name => [name, context]));
|
|
32
|
+
}
|
|
24
33
|
/**
|
|
25
34
|
* Lazily load scoped CLAUDE.md/AGENTS.md files that apply to `filePath` and
|
|
26
35
|
* have not been surfaced yet this turn. Mutates the context's loaded-set so
|
package/dist/llm/webFetch.js
CHANGED
|
@@ -5,7 +5,7 @@ import { validateUrl } from '../core/safety/urlGuard.js';
|
|
|
5
5
|
const DEFAULT_TIMEOUT_MS = 30_000;
|
|
6
6
|
const DEFAULT_MAX_BYTES = 2_000_000;
|
|
7
7
|
const DEFAULT_MAX_REDIRECTS = 5;
|
|
8
|
-
const USER_AGENT = '
|
|
8
|
+
const USER_AGENT = 'haze/0.5 (+https://github.com/DenizOkcu/haze)';
|
|
9
9
|
/** Error thrown when a URL is rejected by the SSRF guard. */
|
|
10
10
|
export class BlockedUrlError extends Error {
|
|
11
11
|
reasonCode;
|
|
@@ -71,36 +71,49 @@ function classifyContentType(contentType) {
|
|
|
71
71
|
return 'html';
|
|
72
72
|
return 'text';
|
|
73
73
|
}
|
|
74
|
+
function decodeValidUtf8Prefix(buffer) {
|
|
75
|
+
for (let end = buffer.byteLength; end >= 0; end--) {
|
|
76
|
+
try {
|
|
77
|
+
return new TextDecoder('utf-8', { fatal: true }).decode(buffer.subarray(0, end));
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
// Back up until we land on a UTF-8 character boundary.
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return '';
|
|
84
|
+
}
|
|
85
|
+
function truncateUtf8Bytes(text, maxBytes) {
|
|
86
|
+
const buffer = Buffer.from(text, 'utf8');
|
|
87
|
+
if (buffer.byteLength <= maxBytes)
|
|
88
|
+
return { text, bytes: buffer.byteLength, truncated: false };
|
|
89
|
+
return { text: decodeValidUtf8Prefix(buffer.subarray(0, maxBytes)), bytes: maxBytes, truncated: true };
|
|
90
|
+
}
|
|
74
91
|
async function readBodyCapped(response, maxBytes, abortController) {
|
|
75
92
|
const body = response.body;
|
|
76
93
|
if (body == null || typeof body.getReader !== 'function') {
|
|
77
94
|
// No streamable body; read as text once and cap.
|
|
78
|
-
|
|
79
|
-
const bytes = Buffer.byteLength(text, 'utf8');
|
|
80
|
-
if (bytes > maxBytes) {
|
|
81
|
-
return { text: text.slice(0, maxBytes), bytes: maxBytes, truncated: true };
|
|
82
|
-
}
|
|
83
|
-
return { text, bytes, truncated: false };
|
|
95
|
+
return truncateUtf8Bytes(await response.text(), maxBytes);
|
|
84
96
|
}
|
|
85
97
|
const reader = body.getReader();
|
|
86
|
-
const
|
|
87
|
-
let text = '';
|
|
98
|
+
const chunks = [];
|
|
88
99
|
let received = 0;
|
|
100
|
+
let kept = 0;
|
|
89
101
|
let truncated = false;
|
|
90
102
|
try {
|
|
91
|
-
// Stream with a byte counter;
|
|
103
|
+
// Stream with a byte counter; keep only bytes up to the ceiling and stop once hit.
|
|
92
104
|
while (true) {
|
|
93
105
|
const { done, value } = await reader.read();
|
|
94
106
|
if (done)
|
|
95
107
|
break;
|
|
96
|
-
const
|
|
97
|
-
received +=
|
|
108
|
+
const chunk = Buffer.from(value);
|
|
109
|
+
received += chunk.byteLength;
|
|
110
|
+
const remaining = Math.max(0, maxBytes - kept);
|
|
111
|
+
if (remaining > 0) {
|
|
112
|
+
const slice = chunk.subarray(0, Math.min(remaining, chunk.byteLength));
|
|
113
|
+
chunks.push(slice);
|
|
114
|
+
kept += slice.byteLength;
|
|
115
|
+
}
|
|
98
116
|
if (received > maxBytes) {
|
|
99
|
-
const already = received - chunkBytes;
|
|
100
|
-
const remaining = Math.max(0, maxBytes - already);
|
|
101
|
-
if (remaining > 0)
|
|
102
|
-
text += decoder.decode(value.slice(0, remaining), { stream: true });
|
|
103
|
-
text += decoder.decode();
|
|
104
117
|
truncated = true;
|
|
105
118
|
try {
|
|
106
119
|
reader.cancel();
|
|
@@ -108,10 +121,7 @@ async function readBodyCapped(response, maxBytes, abortController) {
|
|
|
108
121
|
catch { /* ignore */ }
|
|
109
122
|
break;
|
|
110
123
|
}
|
|
111
|
-
text += decoder.decode(value, { stream: true });
|
|
112
124
|
}
|
|
113
|
-
if (!truncated)
|
|
114
|
-
text += decoder.decode();
|
|
115
125
|
}
|
|
116
126
|
finally {
|
|
117
127
|
try {
|
|
@@ -122,7 +132,7 @@ async function readBodyCapped(response, maxBytes, abortController) {
|
|
|
122
132
|
if (truncated && !abortController.signal.aborted)
|
|
123
133
|
abortController.abort();
|
|
124
134
|
}
|
|
125
|
-
return { text, bytes: Math.min(received, maxBytes), truncated };
|
|
135
|
+
return { text: decodeValidUtf8Prefix(Buffer.concat(chunks)), bytes: Math.min(received, maxBytes), truncated };
|
|
126
136
|
}
|
|
127
137
|
/**
|
|
128
138
|
* Perform an HTTP(S) request with the TCP connection pinned to `pinnedIp`.
|
|
@@ -21,12 +21,12 @@ const STANDARD_SKILL_REQUIREMENTS = `
|
|
|
21
21
|
`;
|
|
22
22
|
const SKILL_CREATOR_SKILL = `---
|
|
23
23
|
name: skill-creator
|
|
24
|
-
description: Use when the user asks
|
|
24
|
+
description: Use when the user asks haze to create a new skill from a natural-language description.
|
|
25
25
|
---
|
|
26
26
|
|
|
27
|
-
You create predictable, high-quality
|
|
27
|
+
You create predictable, high-quality haze skills.
|
|
28
28
|
|
|
29
|
-
A
|
|
29
|
+
A haze skill is a directory in ~/.haze/skills containing SKILL.md and optional referenced files.
|
|
30
30
|
SKILL.md must be Markdown with YAML frontmatter, followed by a role and focused prompt:
|
|
31
31
|
|
|
32
32
|
---
|
|
@@ -45,7 +45,7 @@ The body must be a deterministic operating procedure, not generic advice.
|
|
|
45
45
|
Keep skills simple, short, and practical: prefer the fewest commands and sections that reliably complete the workflow for a professional user.
|
|
46
46
|
Avoid exhaustive checklists, rigid citation requirements, or heavyweight output formats unless the user's request truly requires them.
|
|
47
47
|
Additional files are allowed only when SKILL.md explicitly references them with relative paths.
|
|
48
|
-
Skills do not execute code. They teach
|
|
48
|
+
Skills do not execute code. They teach haze how to behave for a workflow.
|
|
49
49
|
|
|
50
50
|
Every skill you create must include, in this order:
|
|
51
51
|
- YAML frontmatter.
|
|
@@ -179,12 +179,12 @@ async function generateSkill(input) {
|
|
|
179
179
|
const role = input.role?.trim() || DEFAULT_SKILL_ROLE;
|
|
180
180
|
const result = await generateObject({
|
|
181
181
|
model: activeModel,
|
|
182
|
-
|
|
182
|
+
instructions: SKILL_CREATOR_SKILL,
|
|
183
183
|
schema: generatedSkillSchema,
|
|
184
184
|
schemaName: 'GeneratedHazeSkill',
|
|
185
|
-
schemaDescription: 'A generated
|
|
185
|
+
schemaDescription: 'A generated haze Markdown skill and optional referenced files.',
|
|
186
186
|
prompt: [
|
|
187
|
-
'A user is creating a
|
|
187
|
+
'A user is creating a haze skill via a 3-step wizard. They have already chosen the NAME and the ROLE; you do NOT choose those.',
|
|
188
188
|
'',
|
|
189
189
|
`User-chosen skill name (use VERBATIM in frontmatter, do not rename): ${input.name}`,
|
|
190
190
|
`User-chosen Role text (paste VERBATIM into the # Role section): ${role}`,
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
type TextInputKey = {
|
|
3
|
+
return?: boolean;
|
|
4
|
+
shift?: boolean;
|
|
5
|
+
ctrl?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare function shouldInsertNewline(input: string, key: TextInputKey): boolean;
|
|
2
8
|
export type TextInputSuggestion = {
|
|
3
9
|
value: string;
|
|
4
10
|
description?: string;
|
|
@@ -20,3 +26,4 @@ export declare function TextInput({ placeholder, disabled, mask, historyItems, r
|
|
|
20
26
|
onToggleTasks?: () => void;
|
|
21
27
|
onSubmit: (value: string) => void;
|
|
22
28
|
}): React.JSX.Element;
|
|
29
|
+
export {};
|
|
@@ -4,6 +4,12 @@ import { Box, Text, useInput } from 'ink';
|
|
|
4
4
|
import { theme } from '../theme.js';
|
|
5
5
|
import { compactPasteBlocksForDisplay, cursorPosition, displayCursorForValueCursor, lineCount, normalizeLineEndings, updatePasteBlocksForReplacement, valueCursorForDisplayCursor, wrapDisplayValue, } from '../inputBuffer.js';
|
|
6
6
|
const COMPACT_PASTE_MIN_LINES = 4;
|
|
7
|
+
const CTRL_ENTER_ESCAPE_INPUTS = new Set(['\u001B[13;5u', '\u001B[13;5~']);
|
|
8
|
+
export function shouldInsertNewline(input, key) {
|
|
9
|
+
return (key.return === true && (key.shift === true || key.ctrl === true))
|
|
10
|
+
|| input === '\n'
|
|
11
|
+
|| CTRL_ENTER_ESCAPE_INPUTS.has(input);
|
|
12
|
+
}
|
|
7
13
|
export function TextInput({ placeholder, disabled, mask, historyItems = [], recordHistory = true, suggestions = [], suggestionMode = 'slash', submitOnEmpty = false, width = 80, onHistoryAdd, onCancel, onEscape, onToggleTasks, onSubmit }) {
|
|
8
14
|
const [value, setValue] = useState('');
|
|
9
15
|
const [cursor, setCursor] = useState(0);
|
|
@@ -106,6 +112,10 @@ export function TextInput({ placeholder, disabled, mask, historyItems = [], reco
|
|
|
106
112
|
historyIndex.current = null;
|
|
107
113
|
return;
|
|
108
114
|
}
|
|
115
|
+
if (shouldInsertNewline(input, key)) {
|
|
116
|
+
replaceInput(cursor, cursor, '\n');
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
109
119
|
if (key.return) {
|
|
110
120
|
const shouldUseSuggestion = activeSuggestion && activeSuggestion.value !== value.trim() && (suggestionMode === 'always' || value.startsWith('/'));
|
|
111
121
|
const submitted = shouldUseSuggestion ? activeSuggestion.value : value.trim();
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function shortModelName(modelName) {
|
|
2
|
+
const trimmed = modelName?.trim();
|
|
3
|
+
if (!trimmed)
|
|
4
|
+
return 'model';
|
|
5
|
+
const slashIndex = trimmed.indexOf('/');
|
|
6
|
+
const colonIndex = trimmed.indexOf(':');
|
|
7
|
+
const selectorShort = colonIndex >= 0 && (slashIndex < 0 || colonIndex < slashIndex)
|
|
8
|
+
? trimmed.slice(colonIndex + 1)
|
|
9
|
+
: trimmed;
|
|
10
|
+
const slashShort = selectorShort.split('/').filter(Boolean).at(-1) ?? selectorShort;
|
|
11
|
+
return slashShort.length > 32 ? `${slashShort.slice(0, 29)}…` : slashShort;
|
|
12
|
+
}
|
|
13
|
+
export function modelThinkingLabel(modelName) {
|
|
14
|
+
return `${shortModelName(modelName)} is thinking`;
|
|
15
|
+
}
|
|
@@ -3,7 +3,7 @@ name: files
|
|
|
3
3
|
description: Use when the user asks for a careful file-inspection or file-editing workflow.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
Use
|
|
6
|
+
Use haze's built-in file tools rather than shell commands for file discovery and edits.
|
|
7
7
|
|
|
8
8
|
Workflow:
|
|
9
9
|
1. Use `listFiles` for project discovery.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@denizokcu/haze",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "A pragmatic agentic CLI for building apps from the terminal.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"access": "public"
|
|
17
17
|
},
|
|
18
18
|
"engines": {
|
|
19
|
-
"node": ">=
|
|
19
|
+
"node": ">=22"
|
|
20
20
|
},
|
|
21
21
|
"bin": {
|
|
22
22
|
"haze": "bin/haze.js"
|
|
@@ -44,18 +44,18 @@
|
|
|
44
44
|
"prepublishOnly": "npm run typecheck && npm run build"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@ai-sdk/mcp": "^
|
|
48
|
-
"@ai-sdk/openai": "
|
|
47
|
+
"@ai-sdk/mcp": "^2.0.10",
|
|
48
|
+
"@ai-sdk/openai": "4.0.10",
|
|
49
49
|
"@vscode/ripgrep": "1.18.0",
|
|
50
|
-
"ai": "
|
|
50
|
+
"ai": "7.0.19",
|
|
51
51
|
"cli-highlight": "2.1.11",
|
|
52
52
|
"commander": "15.0.0",
|
|
53
|
-
"defuddle": "^0.19.
|
|
54
|
-
"fs-extra": "11.3.
|
|
53
|
+
"defuddle": "^0.19.1",
|
|
54
|
+
"fs-extra": "11.3.6",
|
|
55
55
|
"ink": "7.1.0",
|
|
56
56
|
"ink-spinner": "5.0.0",
|
|
57
|
-
"linkedom": "^0.18.
|
|
58
|
-
"marked": "18.0.
|
|
57
|
+
"linkedom": "^0.18.13",
|
|
58
|
+
"marked": "18.0.6",
|
|
59
59
|
"react": "19.2.7",
|
|
60
60
|
"strip-ansi": "7.2.0",
|
|
61
61
|
"turndown": "^7.2.4",
|
|
@@ -65,13 +65,13 @@
|
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@eslint/js": "^10.0.1",
|
|
67
67
|
"@types/fs-extra": "11.0.4",
|
|
68
|
-
"@types/node": "26.
|
|
68
|
+
"@types/node": "26.1.1",
|
|
69
69
|
"@types/react": "19.2.17",
|
|
70
|
-
"eslint": "^10.
|
|
71
|
-
"tsx": "4.
|
|
70
|
+
"eslint": "^10.6.0",
|
|
71
|
+
"tsx": "4.23.0",
|
|
72
72
|
"typescript": "6.0.3",
|
|
73
|
-
"typescript-eslint": "^8.
|
|
74
|
-
"vitest": "^4.1.
|
|
73
|
+
"typescript-eslint": "^8.63.0",
|
|
74
|
+
"vitest": "^4.1.10"
|
|
75
75
|
},
|
|
76
76
|
"allowScripts": {
|
|
77
77
|
"esbuild@0.28.1": true,
|