@denizokcu/haze 0.7.0 → 0.9.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 +35 -9
- package/README.md +37 -35
- package/dist/cli/chat/inputSuggestions.js +2 -2
- package/dist/cli/chat/sessionRecorder.d.ts +3 -0
- package/dist/cli/chat/sessionRecorder.js +23 -8
- package/dist/cli/commands/chat.js +136 -124
- package/dist/cli/commands/chatModes.js +1 -1
- package/dist/cli/commands/commandHelp.js +2 -2
- package/dist/cli/commands/commands.d.ts +1 -1
- package/dist/cli/commands/commands.js +1 -1
- package/dist/cli/commands/formatters.d.ts +6 -0
- package/dist/cli/commands/formatters.js +41 -3
- package/dist/cli/commands/logsCommand.js +7 -21
- package/dist/cli/commands/mcpWizard.js +24 -2
- package/dist/cli/commands/providerWizard.js +18 -5
- package/dist/cli/commands/runCommand.js +7 -15
- package/dist/cli/commands/settingsSummary.js +3 -1
- package/dist/cli/commands/streaming/turnOutcome.d.ts +10 -0
- package/dist/cli/commands/streaming/turnOutcome.js +13 -0
- package/dist/cli/commands/streaming.js +99 -51
- package/dist/cli/commands/wizardPrompts.js +1 -1
- package/dist/cli/commands/wizardSuggestions.js +3 -2
- package/dist/cli/commands/wizardTransition.d.ts +33 -0
- package/dist/cli/commands/wizardTransition.js +44 -0
- package/dist/config/contextFiles.js +6 -3
- package/dist/config/endpointSecurity.d.ts +2 -0
- package/dist/config/endpointSecurity.js +28 -0
- package/dist/config/inputHistory.js +4 -2
- package/dist/config/privateStorage.d.ts +6 -0
- package/dist/config/privateStorage.js +61 -0
- package/dist/config/providers.js +5 -9
- package/dist/config/settings.d.ts +1 -0
- package/dist/config/settings.js +55 -3
- package/dist/config/updateCheck.js +4 -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/agent/toolOutputStore.d.ts +3 -0
- package/dist/core/agent/toolOutputStore.js +32 -11
- package/dist/core/bashOutput/registry.js +11 -9
- package/dist/core/goal/completionPolicy.d.ts +0 -28
- package/dist/core/goal/completionPolicy.js +1 -89
- package/dist/core/io/boundedRead.d.ts +15 -0
- package/dist/core/io/boundedRead.js +97 -0
- package/dist/core/limits/byteBudgets.d.ts +13 -0
- package/dist/core/limits/byteBudgets.js +13 -0
- package/dist/core/log/llmLog.d.ts +10 -0
- package/dist/core/log/llmLog.js +59 -13
- package/dist/core/persistence/orderedFileWriter.d.ts +11 -0
- package/dist/core/persistence/orderedFileWriter.js +29 -0
- package/dist/core/process/runBoundedProcess.d.ts +27 -0
- package/dist/core/process/runBoundedProcess.js +80 -0
- package/dist/core/session/sessionStore.js +48 -25
- package/dist/core/subagent/subagentRunner.d.ts +252 -9
- package/dist/core/subagent/subagentRunner.js +14 -19
- 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 +19 -3
- package/dist/llm/hazeTools.d.ts +8103 -364
- package/dist/llm/hazeTools.js +43 -33
- package/dist/llm/initPrompt.js +1 -1
- package/dist/llm/lsp.d.ts +21 -3
- package/dist/llm/lsp.js +65 -14
- package/dist/llm/lspTools.d.ts +2358 -101
- package/dist/llm/mcp.d.ts +1 -1
- package/dist/llm/mcp.js +65 -16
- package/dist/llm/requestContext.d.ts +1 -0
- package/dist/llm/requestContext.js +6 -3
- package/dist/llm/systemPrompt.js +2 -2
- package/dist/llm/toolResultTypes.d.ts +1 -1
- package/dist/llm/tools/bashTool.d.ts +603 -5
- package/dist/llm/tools/bashTool.js +23 -60
- package/dist/llm/tools/fetchTool.d.ts +1201 -65
- package/dist/llm/tools/fetchTool.js +2 -1
- package/dist/llm/tools/grepRunner.d.ts +15 -0
- package/dist/llm/tools/grepRunner.js +85 -0
- 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/SkillLoader.js +17 -5
- package/dist/skills/SkillRegistry.js +19 -6
- package/dist/skills/builder/SkillBuilder.js +7 -7
- package/dist/skills/types.d.ts +5 -0
- 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/dist/utils/path.d.ts +2 -0
- package/dist/utils/path.js +9 -4
- 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`.
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import fs from 'fs-extra';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import YAML from 'yaml';
|
|
4
|
+
import { assertRealPathInsideRoot } from '../utils/path.js';
|
|
5
|
+
import { SKILL_MARKDOWN_BYTES } from '../core/limits/byteBudgets.js';
|
|
6
|
+
import { readUtf8Prefix } from '../core/io/boundedRead.js';
|
|
4
7
|
const MAX_REFERENCE_BYTES = 50_000;
|
|
5
8
|
const FRONTMATTER_RE = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?/;
|
|
6
9
|
const MARKDOWN_LINK_RE = /\[[^\]]*\]\(([^)]+)\)/g;
|
|
@@ -49,20 +52,29 @@ async function loadReference(dir, referencePath) {
|
|
|
49
52
|
const relative = path.relative(dir, absolutePath);
|
|
50
53
|
if (relative.startsWith('..') || path.isAbsolute(relative))
|
|
51
54
|
throw new Error(`Skill reference escapes skill directory: ${referencePath}`);
|
|
52
|
-
const
|
|
55
|
+
const realPath = await assertRealPathInsideRoot(dir, absolutePath, referencePath, 'skill directory');
|
|
56
|
+
const stat = await fs.stat(realPath);
|
|
53
57
|
if (!stat.isFile())
|
|
54
58
|
throw new Error(`Skill reference is not a file: ${referencePath}`);
|
|
55
|
-
|
|
59
|
+
const prefix = await readUtf8Prefix(realPath, MAX_REFERENCE_BYTES);
|
|
60
|
+
if (prefix.truncated)
|
|
56
61
|
throw new Error(`Skill reference is too large: ${referencePath}`);
|
|
57
|
-
return { path: referencePath, absolutePath, content:
|
|
62
|
+
return { path: referencePath, absolutePath: realPath, content: prefix.content };
|
|
58
63
|
}
|
|
59
64
|
export async function loadSkill(dir, source = 'global') {
|
|
60
65
|
const skillPath = path.join(dir, 'SKILL.md');
|
|
61
66
|
if (!(await fs.pathExists(skillPath)))
|
|
62
67
|
return null;
|
|
63
|
-
const
|
|
68
|
+
const realSkillPath = await assertRealPathInsideRoot(dir, skillPath, 'SKILL.md', 'skill directory');
|
|
69
|
+
const stat = await fs.stat(realSkillPath);
|
|
70
|
+
if (!stat.isFile())
|
|
71
|
+
throw new Error('SKILL.md is not a file');
|
|
72
|
+
const prefix = await readUtf8Prefix(realSkillPath, SKILL_MARKDOWN_BYTES);
|
|
73
|
+
if (prefix.truncated)
|
|
74
|
+
throw new Error(`SKILL.md exceeds ${SKILL_MARKDOWN_BYTES} byte limit`);
|
|
75
|
+
const content = prefix.content;
|
|
64
76
|
const { frontmatter, body } = parseSkillMarkdown(content);
|
|
65
77
|
const references = await Promise.all(referencedPaths(body).map(ref => loadReference(dir, ref)));
|
|
66
|
-
return { dir, path:
|
|
78
|
+
return { dir, path: realSkillPath, name: frontmatter.name, description: frontmatter.description, body, references, source };
|
|
67
79
|
}
|
|
68
80
|
export const internals = { parseSkillMarkdown, referencedPaths };
|
|
@@ -2,16 +2,29 @@ import fs from 'fs-extra';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { GLOBAL_SKILLS_DIR } from '../config/paths.js';
|
|
4
4
|
import { loadSkill } from './SkillLoader.js';
|
|
5
|
+
import { assertRealPathInsideRoot } from '../utils/path.js';
|
|
5
6
|
export async function loadSkillRegistry() {
|
|
6
7
|
const skills = new Map();
|
|
8
|
+
const errors = [];
|
|
7
9
|
await fs.ensureDir(GLOBAL_SKILLS_DIR);
|
|
8
|
-
for (const name of await fs.readdir(GLOBAL_SKILLS_DIR)) {
|
|
10
|
+
for (const name of (await fs.readdir(GLOBAL_SKILLS_DIR)).sort()) {
|
|
9
11
|
const dir = path.join(GLOBAL_SKILLS_DIR, name);
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
try {
|
|
13
|
+
await assertRealPathInsideRoot(GLOBAL_SKILLS_DIR, dir, name, 'skills root');
|
|
14
|
+
if (!(await fs.stat(dir)).isDirectory())
|
|
15
|
+
continue;
|
|
16
|
+
const skill = await loadSkill(dir, 'global');
|
|
17
|
+
if (!skill)
|
|
18
|
+
continue;
|
|
19
|
+
if (skills.has(skill.name)) {
|
|
20
|
+
errors.push({ directory: name, message: `duplicate skill name "${skill.name}"; first valid skill wins` });
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
14
23
|
skills.set(skill.name, skill);
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
errors.push({ directory: name, message: error instanceof Error ? error.message : String(error) });
|
|
27
|
+
}
|
|
15
28
|
}
|
|
16
|
-
return { skills };
|
|
29
|
+
return { skills, errors };
|
|
17
30
|
}
|
|
@@ -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}`,
|
package/dist/skills/types.d.ts
CHANGED
|
@@ -16,6 +16,11 @@ export interface LoadedSkill {
|
|
|
16
16
|
references: LoadedSkillReference[];
|
|
17
17
|
source: 'global';
|
|
18
18
|
}
|
|
19
|
+
export interface SkillRegistryError {
|
|
20
|
+
directory: string;
|
|
21
|
+
message: string;
|
|
22
|
+
}
|
|
19
23
|
export interface SkillRegistry {
|
|
20
24
|
skills: Map<string, LoadedSkill>;
|
|
25
|
+
errors: SkillRegistryError[];
|
|
21
26
|
}
|
|
@@ -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
|
+
}
|
package/dist/utils/path.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export declare function workspaceRoot(): string;
|
|
2
2
|
export declare function resolveWorkspacePath(inputPath: string): string;
|
|
3
3
|
export declare function workspaceRelativePath(absolutePath: string): string;
|
|
4
|
+
export declare function assertPathInsideRoot(root: string, candidate: string, inputPath: string, label?: string): void;
|
|
5
|
+
export declare function assertRealPathInsideRoot(root: string, candidate: string, inputPath?: string, label?: string): Promise<string>;
|
|
4
6
|
export declare function assertRealPathInsideWorkspace(absolutePath: string, inputPath?: string): Promise<void>;
|
|
5
7
|
export declare function assertWritablePathInsideWorkspace(absolutePath: string, inputPath?: string): Promise<void>;
|
package/dist/utils/path.js
CHANGED
|
@@ -15,18 +15,23 @@ export function resolveWorkspacePath(inputPath) {
|
|
|
15
15
|
export function workspaceRelativePath(absolutePath) {
|
|
16
16
|
return path.relative(workspaceRoot(), absolutePath) || '.';
|
|
17
17
|
}
|
|
18
|
-
function assertPathInsideRoot(root, candidate, inputPath) {
|
|
18
|
+
export function assertPathInsideRoot(root, candidate, inputPath, label = 'workspace') {
|
|
19
19
|
const relative = path.relative(root, candidate);
|
|
20
20
|
if (relative.startsWith('..') || path.isAbsolute(relative)) {
|
|
21
|
-
throw new Error(`Path is outside the
|
|
21
|
+
throw new Error(`Path is outside the ${label}: ${inputPath}`);
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
+
export async function assertRealPathInsideRoot(root, candidate, inputPath = candidate, label = 'root') {
|
|
25
|
+
const [realRoot, realCandidate] = await Promise.all([fs.realpath(root), fs.realpath(candidate)]);
|
|
26
|
+
assertPathInsideRoot(realRoot, realCandidate, inputPath, label);
|
|
27
|
+
return realCandidate;
|
|
28
|
+
}
|
|
24
29
|
export async function assertRealPathInsideWorkspace(absolutePath, inputPath = absolutePath) {
|
|
25
30
|
const [realRoot, realPath] = await Promise.all([
|
|
26
31
|
fs.realpath(workspaceRoot()),
|
|
27
32
|
fs.realpath(absolutePath),
|
|
28
33
|
]);
|
|
29
|
-
assertPathInsideRoot(realRoot, realPath, inputPath);
|
|
34
|
+
assertPathInsideRoot(realRoot, realPath, inputPath, 'workspace');
|
|
30
35
|
}
|
|
31
36
|
async function nearestExistingPath(absolutePath) {
|
|
32
37
|
let current = absolutePath;
|
|
@@ -52,5 +57,5 @@ export async function assertWritablePathInsideWorkspace(absolutePath, inputPath
|
|
|
52
57
|
nearestExistingPath(absolutePath),
|
|
53
58
|
]);
|
|
54
59
|
const realExisting = await fs.realpath(existing);
|
|
55
|
-
assertPathInsideRoot(realRoot, realExisting, inputPath);
|
|
60
|
+
assertPathInsideRoot(realRoot, realExisting, inputPath, 'workspace');
|
|
56
61
|
}
|
|
@@ -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.9.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,
|