@denizokcu/haze 0.0.1 → 0.0.3

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 (73) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +169 -70
  3. package/dist/cli/commands/chat.d.ts +4 -1
  4. package/dist/cli/commands/chat.js +606 -24
  5. package/dist/cli/commands/commands.d.ts +5 -0
  6. package/dist/cli/commands/commands.js +220 -11
  7. package/dist/cli/commands/formatters.d.ts +1 -0
  8. package/dist/cli/commands/formatters.js +23 -3
  9. package/dist/cli/commands/skills.d.ts +1 -1
  10. package/dist/cli/commands/skills.js +8 -5
  11. package/dist/cli/commands/streaming.d.ts +7 -1
  12. package/dist/cli/commands/streaming.js +533 -41
  13. package/dist/cli/index.js +5 -12
  14. package/dist/config/inputHistory.js +8 -0
  15. package/dist/config/paths.d.ts +0 -1
  16. package/dist/config/paths.js +0 -1
  17. package/dist/config/providers.d.ts +26 -0
  18. package/dist/config/providers.js +88 -0
  19. package/dist/config/settings.d.ts +9 -2
  20. package/dist/core/agent/compaction.d.ts +13 -0
  21. package/dist/core/agent/compaction.js +34 -0
  22. package/dist/core/agent/errors.d.ts +3 -0
  23. package/dist/core/agent/errors.js +13 -0
  24. package/dist/core/agent/events.d.ts +58 -0
  25. package/dist/core/agent/events.js +3 -0
  26. package/dist/core/goal/completionPolicy.d.ts +27 -0
  27. package/dist/core/goal/completionPolicy.js +67 -0
  28. package/dist/core/goal/requestClassifier.d.ts +6 -0
  29. package/dist/core/goal/requestClassifier.js +31 -0
  30. package/dist/core/goal/sessionGoal.d.ts +30 -0
  31. package/dist/core/goal/sessionGoal.js +88 -0
  32. package/dist/core/session/sessionStore.d.ts +37 -0
  33. package/dist/core/session/sessionStore.js +59 -0
  34. package/dist/llm/client.d.ts +1 -1
  35. package/dist/llm/client.js +6 -6
  36. package/dist/llm/hazeTools.d.ts +70 -0
  37. package/dist/llm/hazeTools.js +311 -97
  38. package/dist/llm/initPrompt.js +7 -5
  39. package/dist/llm/systemPrompt.js +25 -11
  40. package/dist/skills/SkillLoader.d.ts +12 -2
  41. package/dist/skills/SkillLoader.js +64 -18
  42. package/dist/skills/SkillRegistry.d.ts +1 -5
  43. package/dist/skills/SkillRegistry.js +10 -21
  44. package/dist/skills/builder/SkillBuilder.d.ts +31 -1
  45. package/dist/skills/builder/SkillBuilder.js +291 -20
  46. package/dist/skills/skillTools.d.ts +20 -0
  47. package/dist/skills/skillTools.js +25 -0
  48. package/dist/skills/types.d.ts +12 -51
  49. package/dist/ui/components/ErrorView.d.ts +2 -1
  50. package/dist/ui/components/Header.d.ts +4 -2
  51. package/dist/ui/components/Header.js +2 -2
  52. package/dist/ui/components/MarkdownText.d.ts +2 -1
  53. package/dist/ui/components/TextInput.d.ts +13 -2
  54. package/dist/ui/components/TextInput.js +125 -25
  55. package/dist/ui/theme.d.ts +2 -0
  56. package/dist/ui/theme.js +3 -1
  57. package/dist/utils/fs.d.ts +1 -0
  58. package/dist/utils/fs.js +10 -6
  59. package/examples/skills/files/SKILL.md +16 -0
  60. package/examples/skills/files/examples/file-editing.md +3 -0
  61. package/package.json +9 -9
  62. package/dist/skills/installer/SkillInstaller.d.ts +0 -1
  63. package/dist/skills/installer/SkillInstaller.js +0 -48
  64. package/dist/skills/manifestSchema.d.ts +0 -31
  65. package/dist/skills/manifestSchema.js +0 -23
  66. package/dist/tools/ToolExecutor.d.ts +0 -3
  67. package/dist/tools/ToolExecutor.js +0 -15
  68. package/dist/tools/types.d.ts +0 -9
  69. package/dist/tools/types.js +0 -1
  70. package/examples/skills/files/prompts/file_tasks.md +0 -1
  71. package/examples/skills/files/skill.yaml +0 -28
  72. package/examples/skills/files/tools/list_files.ts +0 -21
  73. package/examples/skills/files/tools/read_file.ts +0 -12
@@ -0,0 +1,59 @@
1
+ import crypto from 'node:crypto';
2
+ import path from 'node:path';
3
+ import fs from 'fs-extra';
4
+ import { HAZE_DIR } from '../../config/paths.js';
5
+ const DEFAULT_SESSIONS_DIR = path.join(HAZE_DIR, 'sessions');
6
+ function cwdHash(cwd = process.cwd()) {
7
+ return crypto.createHash('sha256').update(path.resolve(cwd)).digest('hex').slice(0, 16);
8
+ }
9
+ function sessionDir(cwd = process.cwd(), sessionsDir = DEFAULT_SESSIONS_DIR) {
10
+ return path.join(sessionsDir, cwdHash(cwd));
11
+ }
12
+ function sessionFile(id, cwd = process.cwd(), sessionsDir = DEFAULT_SESSIONS_DIR) {
13
+ return path.join(sessionDir(cwd, sessionsDir), `${id}.jsonl`);
14
+ }
15
+ function newSessionId(now = new Date()) {
16
+ return now.toISOString().replace(/[:.]/g, '-');
17
+ }
18
+ export async function createSession(options = {}) {
19
+ const cwd = path.resolve(options.cwd ?? process.cwd());
20
+ const id = newSessionId();
21
+ const file = sessionFile(id, cwd, options.sessionsDir);
22
+ await fs.ensureDir(path.dirname(file));
23
+ await appendSessionEntry({ id, file, cwd }, { type: 'header', id, cwd, createdAt: new Date().toISOString(), hazeVersion: options.hazeVersion });
24
+ return { id, file, cwd };
25
+ }
26
+ export async function latestSession(cwd = process.cwd(), sessionsDir = DEFAULT_SESSIONS_DIR) {
27
+ const dir = sessionDir(cwd, sessionsDir);
28
+ const files = (await fs.readdir(dir).catch(() => []))
29
+ .filter(file => file.endsWith('.jsonl'))
30
+ .sort();
31
+ const latest = files.at(-1);
32
+ if (!latest)
33
+ return undefined;
34
+ const id = path.basename(latest, '.jsonl');
35
+ return { id, file: path.join(dir, latest), cwd: path.resolve(cwd) };
36
+ }
37
+ export async function appendSessionEntry(session, entry) {
38
+ await fs.ensureDir(path.dirname(session.file));
39
+ await fs.appendFile(session.file, `${JSON.stringify(entry)}\n`, 'utf8');
40
+ }
41
+ export async function readSessionEntries(session) {
42
+ const raw = await fs.readFile(session.file, 'utf8');
43
+ return raw.split('\n').filter(Boolean).flatMap(line => {
44
+ try {
45
+ return [JSON.parse(line)];
46
+ }
47
+ catch {
48
+ return [];
49
+ }
50
+ });
51
+ }
52
+ export async function restoreConversation(session) {
53
+ const entries = await readSessionEntries(session);
54
+ const snapshots = entries.filter((entry) => entry.type === 'conversation_snapshot');
55
+ return snapshots.at(-1)?.messages ?? [];
56
+ }
57
+ export function formatSession(session) {
58
+ return `${session.id} · ${session.file}`;
59
+ }
@@ -1 +1 @@
1
- export declare function model(): Promise<import("@ai-sdk/provider").LanguageModelV3 | null>;
1
+ export declare function model(): Promise<import("@ai-sdk/provider").LanguageModelV3>;
@@ -1,11 +1,11 @@
1
1
  import { createOpenAI } from '@ai-sdk/openai';
2
2
  import { readSettings } from '../config/settings.js';
3
+ import { activeModel } from '../config/providers.js';
3
4
  export async function model() {
4
5
  const settings = await readSettings();
5
- const baseURL = process.env.OPENAI_BASE_URL ?? settings.baseURL;
6
- const apiKey = process.env.OPENAI_API_KEY ?? settings.apiKey;
7
- const name = process.env.HAZE_MODEL ?? settings.model ?? 'openai/gpt-4o-mini';
8
- if (!apiKey)
9
- return null;
10
- return createOpenAI({ apiKey, baseURL })(name);
6
+ const selection = activeModel(settings);
7
+ const baseURL = process.env.OPENAI_BASE_URL ?? selection.provider.url;
8
+ const apiKey = process.env.OPENAI_API_KEY ?? selection.provider.key ?? settings.apiKey ?? 'not-needed';
9
+ const name = process.env.HAZE_MODEL ?? selection.model;
10
+ return createOpenAI({ apiKey, baseURL }).chat(name);
11
11
  }
@@ -4,10 +4,25 @@ export declare const hazeTools: {
4
4
  recursive: boolean;
5
5
  maxEntries: number;
6
6
  includeIgnored: boolean;
7
+ cursor?: string | undefined;
7
8
  }, {
9
+ ok: boolean;
10
+ toolName: string;
11
+ path: string | undefined;
12
+ error: string;
13
+ recoverable: boolean;
14
+ suggestedNextStep: string;
15
+ } | {
16
+ ok: true;
17
+ duplicateSkipped: true;
18
+ toolName: string;
19
+ reason: string;
20
+ } | {
8
21
  path: string;
9
22
  recursive: boolean;
10
23
  includeIgnored: boolean;
24
+ cursor: string | undefined;
25
+ nextCursor: string | undefined;
11
26
  ignoredSkipped: number;
12
27
  entries: {
13
28
  path: string;
@@ -22,6 +37,18 @@ export declare const hazeTools: {
22
37
  offset?: number | undefined;
23
38
  limit?: number | undefined;
24
39
  }, {
40
+ ok: boolean;
41
+ toolName: string;
42
+ path: string | undefined;
43
+ error: string;
44
+ recoverable: boolean;
45
+ suggestedNextStep: string;
46
+ } | {
47
+ ok: true;
48
+ duplicateSkipped: true;
49
+ toolName: string;
50
+ reason: string;
51
+ } | {
25
52
  text: string;
26
53
  truncated: boolean;
27
54
  omittedChars?: undefined;
@@ -47,20 +74,49 @@ export declare const hazeTools: {
47
74
  content: string;
48
75
  allowIgnored: boolean;
49
76
  }, {
77
+ ok: boolean;
78
+ toolName: string;
79
+ path: string | undefined;
80
+ error: string;
81
+ recoverable: boolean;
82
+ suggestedNextStep: string;
83
+ } | {
84
+ ok: true;
85
+ duplicateSkipped: true;
86
+ toolName: string;
87
+ reason: string;
88
+ } | {
50
89
  ok: boolean;
51
90
  path: string;
52
91
  startLine: number;
53
92
  endLine: number;
93
+ requestedEndLine: number;
94
+ endLineClamped: boolean;
54
95
  replacementLines: number;
96
+ appended: boolean;
55
97
  }>;
56
98
  writeFile: import("ai").Tool<{
57
99
  path: string;
58
100
  content: string;
101
+ overwriteExisting: boolean;
59
102
  allowIgnored: boolean;
60
103
  }, {
104
+ ok: boolean;
105
+ toolName: string;
106
+ path: string | undefined;
107
+ error: string;
108
+ recoverable: boolean;
109
+ suggestedNextStep: string;
110
+ } | {
111
+ ok: true;
112
+ duplicateSkipped: true;
113
+ toolName: string;
114
+ reason: string;
115
+ } | {
61
116
  ok: boolean;
62
117
  path: string;
63
118
  bytes: number;
119
+ overwritten: boolean;
64
120
  }>;
65
121
  editFile: import("ai").Tool<{
66
122
  path: string;
@@ -70,12 +126,26 @@ export declare const hazeTools: {
70
126
  }[];
71
127
  allowIgnored: boolean;
72
128
  }, {
129
+ ok: boolean;
130
+ toolName: string;
131
+ path: string | undefined;
132
+ error: string;
133
+ recoverable: boolean;
134
+ suggestedNextStep: string;
135
+ } | {
136
+ ok: true;
137
+ duplicateSkipped: true;
138
+ toolName: string;
139
+ reason: string;
140
+ } | {
73
141
  ok: boolean;
74
142
  path: string;
75
143
  edits: number;
144
+ approximateMatches: number;
76
145
  }>;
77
146
  bash: import("ai").Tool<{
78
147
  command: string;
148
+ allowMutation: boolean;
79
149
  timeoutSeconds?: number | undefined;
80
150
  }, unknown>;
81
151
  };