@allternit/gizzi-code 1.0.0 → 1.0.1

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 (158) hide show
  1. package/bin/gizzi +4 -0
  2. package/bin/gizzi-ink +5 -0
  3. package/package.json +137 -31
  4. package/src/Tool.ts +26 -0
  5. package/src/bootstrap/state.ts +165 -322
  6. package/src/commands.ts +209 -0
  7. package/src/context/QueuedMessageContext.tsx +63 -0
  8. package/src/context/fpsMetrics.tsx +30 -0
  9. package/src/context/mailbox.tsx +38 -0
  10. package/src/context/modalContext.tsx +58 -0
  11. package/src/context/notifications.tsx +240 -0
  12. package/src/context/overlayContext.tsx +151 -0
  13. package/src/context/promptOverlayContext.tsx +125 -0
  14. package/src/context/stats.tsx +220 -0
  15. package/src/context/voice.tsx +88 -0
  16. package/src/hooks/useCanUseTool.ts +11 -0
  17. package/src/hooks/useExitOnCtrlCD.ts +40 -187
  18. package/src/hooks/useExitOnCtrlCDWithKeybindings.ts +68 -0
  19. package/src/hooks/useKeybinding.ts +68 -209
  20. package/src/hooks/useTerminalSize.ts +31 -99
  21. package/src/hooks.ts +37 -0
  22. package/src/ink.ts +204 -0
  23. package/src/main.ts +7 -0
  24. package/src/types/command.ts +216 -0
  25. package/src/types/connectorText.ts +39 -0
  26. package/src/types/fileSuggestion.ts +15 -0
  27. package/src/types/generated/events_mono/claude_code/v1/claude_code_internal_event.ts +865 -0
  28. package/src/types/generated/events_mono/common/v1/auth.ts +100 -0
  29. package/src/types/generated/events_mono/growthbook/v1/growthbook_experiment_event.ts +223 -0
  30. package/src/types/generated/google/protobuf/timestamp.ts +187 -0
  31. package/src/types/hooks.ts +319 -0
  32. package/src/types/ids.ts +44 -0
  33. package/src/types/logs.ts +331 -0
  34. package/src/types/merged/index.ts +5 -0
  35. package/src/types/merged/message.ts +552 -0
  36. package/src/types/message.ts +927 -186
  37. package/src/types/messageQueueTypes.ts +21 -0
  38. package/src/types/notebook.ts +72 -0
  39. package/src/types/permissions.ts +447 -0
  40. package/src/types/plugin.ts +363 -0
  41. package/src/types/statusLine.ts +15 -0
  42. package/src/types/textInputTypes.ts +387 -0
  43. package/src/types/tools.ts +149 -0
  44. package/src/types/utils.ts +20 -0
  45. package/src/utils/advisor.ts +12 -0
  46. package/src/utils/api.ts +29 -0
  47. package/src/utils/array.ts +7 -0
  48. package/src/utils/attachments.ts +60 -0
  49. package/src/utils/auth.ts +3 -0
  50. package/src/utils/claudeInChrome/chromeNativeHost.ts +15 -0
  51. package/src/utils/claudeInChrome/common.ts +12 -0
  52. package/src/utils/claudeInChrome/mcpServer.ts +15 -0
  53. package/src/utils/computerUse/common.ts +19 -0
  54. package/src/utils/computerUse/mcpServer.ts +15 -0
  55. package/src/utils/config.ts +35 -0
  56. package/src/utils/context.ts +19 -0
  57. package/src/utils/cwd.ts +3 -0
  58. package/src/utils/debug.ts +3 -0
  59. package/src/utils/earlyInput.ts +7 -0
  60. package/src/utils/effort.ts +13 -0
  61. package/src/utils/embeddedTools.ts +12 -0
  62. package/src/utils/envUtils.ts +3 -0
  63. package/src/utils/errors.ts +3 -0
  64. package/src/utils/execFileNoThrow.ts +24 -0
  65. package/src/utils/feature-flags.ts +112 -0
  66. package/src/utils/file.ts +3 -0
  67. package/src/utils/fileHistory.ts +17 -0
  68. package/src/utils/fingerprint.ts +7 -0
  69. package/src/utils/format.ts +75 -305
  70. package/src/utils/frontmatterParser.ts +33 -0
  71. package/src/utils/fsOperations.ts +31 -0
  72. package/src/utils/fullscreen.ts +40 -350
  73. package/src/utils/git.ts +15 -0
  74. package/src/utils/imageResizer.ts +30 -0
  75. package/src/utils/lazySchema.ts +9 -0
  76. package/src/utils/log.ts +3 -0
  77. package/src/utils/markdownConfigLoader.ts +12 -0
  78. package/src/utils/messages.ts +13 -0
  79. package/src/utils/migration.ts +137 -0
  80. package/src/utils/model/providers.ts +15 -0
  81. package/src/utils/path.ts +3 -0
  82. package/src/utils/permissions/PermissionResult.ts +14 -0
  83. package/src/utils/permissions/autoModeState.ts +12 -0
  84. package/src/utils/permissions/filesystem.ts +12 -0
  85. package/src/utils/plugins/loadPluginOutputStyles.ts +12 -0
  86. package/src/utils/plugins/schemas.ts +25 -0
  87. package/src/utils/process.ts +16 -0
  88. package/src/utils/sandbox/sandbox-adapter.ts +19 -0
  89. package/src/utils/sessionStorage.ts +238 -472
  90. package/src/utils/settings/constants.ts +10 -0
  91. package/src/utils/settings/settings.ts +19 -0
  92. package/src/utils/settings/types.ts +18 -0
  93. package/src/utils/shell/shellToolUtils.ts +9 -0
  94. package/src/utils/sinks.ts +11 -0
  95. package/src/utils/sleep.ts +7 -0
  96. package/src/utils/sliceAnsi.ts +7 -0
  97. package/src/utils/slowOperations.ts +3 -0
  98. package/src/utils/startupProfiler.ts +11 -0
  99. package/src/utils/stringUtils.ts +106 -0
  100. package/src/utils/systemPromptType.ts +9 -0
  101. package/src/utils/teleport/api.ts +15 -0
  102. package/src/utils/textHighlighting.ts +16 -0
  103. package/src/utils/theme.ts +17 -0
  104. package/src/utils/thinking.ts +58 -0
  105. package/src/utils/tokens.ts +11 -0
  106. package/src/utils/toolResultStorage.ts +17 -0
  107. package/src/utils/worktreeModeEnabled.ts +7 -0
  108. package/WORKSPACE_INTEGRATION.md +0 -290
  109. package/chat-sessions/sessions-index.json +0 -98
  110. package/package.json.original +0 -31
  111. package/package.json.publish +0 -47
  112. package/src/bootstrap/state.d.ts +0 -169
  113. package/src/bootstrap/state.js +0 -261
  114. package/src/context/pack-builder.d.ts +0 -24
  115. package/src/context/pack-builder.js +0 -281
  116. package/src/hooks/useExitOnCtrlCD.d.ts +0 -86
  117. package/src/hooks/useExitOnCtrlCD.js +0 -130
  118. package/src/hooks/useKeybinding.d.ts +0 -89
  119. package/src/hooks/useKeybinding.js +0 -163
  120. package/src/hooks/useTerminalSize.d.ts +0 -41
  121. package/src/hooks/useTerminalSize.js +0 -90
  122. package/src/index.d.ts +0 -23
  123. package/src/index.js +0 -24
  124. package/src/runtime/brand/brand.d.ts +0 -488
  125. package/src/runtime/brand/brand.js +0 -464
  126. package/src/runtime/brand/brand.ts +0 -667
  127. package/src/runtime/services/tokenEstimation.d.ts +0 -187
  128. package/src/runtime/services/tokenEstimation.js +0 -423
  129. package/src/runtime/services/tokenEstimation.ts +0 -547
  130. package/src/runtime/tools/Tool.d.ts +0 -239
  131. package/src/runtime/tools/Tool.js +0 -285
  132. package/src/runtime/tools/Tool.ts +0 -524
  133. package/src/scheduler/TaskScheduler.d.ts +0 -98
  134. package/src/scheduler/TaskScheduler.js +0 -201
  135. package/src/scheduler/TaskScheduler.ts +0 -259
  136. package/src/state/AppStateStore.d.ts +0 -347
  137. package/src/state/AppStateStore.js +0 -439
  138. package/src/state/AppStateStore.ts +0 -658
  139. package/src/state/WorkspaceStateStore.d.ts +0 -43
  140. package/src/state/WorkspaceStateStore.js +0 -224
  141. package/src/state/WorkspaceStateStore.ts +0 -297
  142. package/src/types/message.d.ts +0 -190
  143. package/src/types/message.js +0 -77
  144. package/src/utils/format.d.ts +0 -126
  145. package/src/utils/format.js +0 -230
  146. package/src/utils/fullscreen.d.ts +0 -161
  147. package/src/utils/fullscreen.js +0 -277
  148. package/src/utils/sessionStorage.d.ts +0 -210
  149. package/src/utils/sessionStorage.js +0 -435
  150. package/src/watcher/WorkspaceWatcher.d.ts +0 -70
  151. package/src/watcher/WorkspaceWatcher.js +0 -191
  152. package/src/watcher/WorkspaceWatcher.ts +0 -251
  153. package/src/workspace/loader.d.ts +0 -30
  154. package/src/workspace/loader.js +0 -117
  155. package/src/workspace/types.d.ts +0 -91
  156. package/src/workspace/types.js +0 -7
  157. package/threads/thread_1775361175022.json +0 -9
  158. package/tsconfig.json +0 -14
@@ -1,382 +1,72 @@
1
1
  /**
2
- * @fileoverview Fullscreen utilities for gizzi-code integration
3
- * @module utils/fullscreen
4
- *
5
- * Provides utilities for managing fullscreen mode in browser environments.
6
- * Includes support for the standard Fullscreen API with vendor prefixes
7
- * for cross-browser compatibility.
2
+ * Fullscreen utilities
8
3
  */
9
4
 
10
- /**
11
- * Fullscreen change event handler type
12
- * @typedef {Function} FullscreenChangeHandler
13
- */
14
- export type FullscreenChangeHandler = (isFullscreen: boolean) => void;
15
-
16
- /**
17
- * Extended document interface with vendor-prefixed fullscreen properties
18
- * @interface FullscreenDocument
19
- */
20
- interface FullscreenDocument extends Document {
21
- readonly webkitFullscreenElement?: Element | null;
22
- readonly mozFullScreenElement?: Element | null;
23
- readonly msFullscreenElement?: Element | null;
24
- readonly webkitIsFullScreen?: boolean;
25
- readonly mozFullScreen?: boolean;
26
- readonly msIsFullScreen?: boolean;
27
- webkitExitFullscreen?: () => Promise<void>;
28
- mozCancelFullScreen?: () => Promise<void>;
29
- msExitFullscreen?: () => Promise<void>;
30
- }
31
-
32
- /**
33
- * Extended HTML element interface with vendor-prefixed fullscreen methods
34
- * @interface FullscreenElement
35
- */
36
- interface FullscreenElement extends HTMLElement {
37
- webkitRequestFullscreen?: (options?: FullscreenOptions) => Promise<void>;
38
- mozRequestFullScreen?: (options?: FullscreenOptions) => Promise<void>;
39
- msRequestFullscreen?: () => Promise<void>;
40
- }
41
-
42
- /**
43
- * Checks if the Fullscreen API is supported in the current environment
44
- *
45
- * @returns {boolean} True if fullscreen is supported
46
- * @example
47
- * ```typescript
48
- * if (isFullscreenSupported()) {
49
- * enterFullscreen();
50
- * }
51
- * ```
52
- */
53
- export function isFullscreenSupported(): boolean {
54
- if (typeof document === 'undefined') {
55
- return false;
5
+ export function enterFullscreen(): Promise<void> {
6
+ if (typeof process !== 'undefined' && process.stdout) {
7
+ // Terminal fullscreen escape sequence
8
+ process.stdout.write('\x1b[?1049h')
9
+ return Promise.resolve()
56
10
  }
57
-
58
- const doc = document as FullscreenDocument;
59
- const elem = document.documentElement as FullscreenElement;
60
-
61
- return !!(
62
- doc.fullscreenEnabled ??
63
- (doc as unknown as { webkitFullscreenEnabled?: boolean }).webkitFullscreenEnabled ??
64
- (doc as unknown as { mozFullScreenEnabled?: boolean }).mozFullScreenEnabled ??
65
- (doc as unknown as { msFullscreenEnabled?: boolean }).msFullscreenEnabled ??
66
- elem.requestFullscreen ??
67
- elem.webkitRequestFullscreen ??
68
- elem.mozRequestFullScreen ??
69
- elem.msRequestFullscreen
70
- );
11
+ return Promise.reject(new Error('Fullscreen not supported'))
71
12
  }
72
13
 
73
- /**
74
- * Checks if the document is currently in fullscreen mode
75
- *
76
- * @returns {boolean} True if currently in fullscreen
77
- * @example
78
- * ```typescript
79
- * if (isFullscreen()) {
80
- * console.log('Currently in fullscreen mode');
81
- * }
82
- * ```
83
- */
84
- export function isFullscreen(): boolean {
85
- if (typeof document === 'undefined') {
86
- return false;
14
+ export function exitFullscreen(): Promise<void> {
15
+ if (typeof process !== 'undefined' && process.stdout) {
16
+ // Exit terminal fullscreen
17
+ process.stdout.write('\x1b[?1049l')
18
+ return Promise.resolve()
87
19
  }
88
-
89
- const doc = document as FullscreenDocument;
90
-
91
- return !!(
92
- doc.fullscreenElement ??
93
- doc.webkitFullscreenElement ??
94
- doc.mozFullScreenElement ??
95
- doc.msFullscreenElement ??
96
- doc.webkitIsFullScreen ??
97
- doc.mozFullScreen ??
98
- doc.msIsFullScreen
99
- );
20
+ return Promise.reject(new Error('Fullscreen not supported'))
100
21
  }
101
22
 
102
- /**
103
- * Enters fullscreen mode for the specified element or document
104
- *
105
- * @param {HTMLElement} [element] - Element to make fullscreen (defaults to document.documentElement)
106
- * @param {FullscreenOptions} [options] - Fullscreen options
107
- * @returns {Promise<void>} Promise that resolves when fullscreen is entered
108
- * @throws {Error} If fullscreen is not supported or permission is denied
109
- * @example
110
- * ```typescript
111
- * // Make entire page fullscreen
112
- * await enterFullscreen();
113
- *
114
- * // Make specific element fullscreen
115
- * const video = document.getElementById('myVideo');
116
- * await enterFullscreen(video);
117
- *
118
- * // With navigation UI hidden
119
- * await enterFullscreen(undefined, { navigationUI: 'hide' });
120
- * ```
121
- */
122
- export async function enterFullscreen(
123
- element?: HTMLElement,
124
- options?: FullscreenOptions
125
- ): Promise<void> {
126
- if (typeof document === 'undefined') {
127
- return Promise.reject(new Error('Fullscreen not available in server environment'));
128
- }
129
-
130
- const target = (element ?? document.documentElement) as FullscreenElement;
131
-
132
- // Try standard method first
133
- if (target.requestFullscreen) {
134
- return target.requestFullscreen(options);
135
- }
136
-
137
- // Vendor prefixed fallbacks
138
- if (target.webkitRequestFullscreen) {
139
- return target.webkitRequestFullscreen(options);
140
- }
141
-
142
- if (target.mozRequestFullScreen) {
143
- return target.mozRequestFullScreen(options);
144
- }
145
-
146
- if (target.msRequestFullscreen) {
147
- return target.msRequestFullscreen();
148
- }
149
-
150
- throw new Error('Fullscreen API is not supported in this browser');
23
+ export function isFullscreen(): boolean {
24
+ // In terminal context, we can't reliably detect fullscreen
25
+ return false
151
26
  }
152
27
 
153
- /**
154
- * Exits fullscreen mode
155
- *
156
- * @returns {Promise<void>} Promise that resolves when fullscreen is exited
157
- * @throws {Error} If not in fullscreen or API not supported
158
- * @example
159
- * ```typescript
160
- * await exitFullscreen();
161
- * console.log('Exited fullscreen');
162
- * ```
163
- */
164
- export async function exitFullscreen(): Promise<void> {
165
- if (typeof document === 'undefined') {
166
- return Promise.reject(new Error('Fullscreen not available in server environment'));
167
- }
168
-
169
- if (!isFullscreen()) {
170
- return Promise.resolve();
171
- }
172
-
173
- const doc = document as FullscreenDocument;
174
-
175
- // Try standard method first
176
- if (document.exitFullscreen) {
177
- return document.exitFullscreen();
178
- }
179
-
180
- // Vendor prefixed fallbacks
181
- if (doc.webkitExitFullscreen) {
182
- return doc.webkitExitFullscreen();
183
- }
184
-
185
- if (doc.mozCancelFullScreen) {
186
- return doc.mozCancelFullScreen();
187
- }
188
-
189
- if (doc.msExitFullscreen) {
190
- return doc.msExitFullscreen();
191
- }
192
-
193
- throw new Error('Fullscreen API is not supported in this browser');
28
+ export function toggleFullscreen(): Promise<void> {
29
+ return isFullscreen() ? exitFullscreen() : enterFullscreen()
194
30
  }
195
31
 
196
- /**
197
- * Toggles fullscreen mode for the specified element
198
- *
199
- * @param {HTMLElement} [element] - Element to toggle (defaults to document.documentElement)
200
- * @param {FullscreenOptions} [options] - Fullscreen options
201
- * @returns {Promise<boolean>} Promise that resolves to new fullscreen state
202
- * @example
203
- * ```typescript
204
- * const isFullscreen = await toggleFullscreen();
205
- * console.log('Fullscreen active:', isFullscreen);
206
- * ```
207
- */
208
- export async function toggleFullscreen(
209
- element?: HTMLElement,
210
- options?: FullscreenOptions
211
- ): Promise<boolean> {
212
- if (isFullscreen()) {
213
- await exitFullscreen();
214
- return false;
215
- } else {
216
- await enterFullscreen(element, options);
217
- return true;
32
+ export function clearScreen(): void {
33
+ if (typeof process !== 'undefined' && process.stdout) {
34
+ process.stdout.write('\x1b[2J\x1b[H')
218
35
  }
219
36
  }
220
37
 
221
- /**
222
- * Subscribes to fullscreen change events
223
- *
224
- * @param {FullscreenChangeHandler} handler - Callback fired when fullscreen state changes
225
- * @returns {() => void} Unsubscribe function
226
- * @example
227
- * ```typescript
228
- * const unsubscribe = onFullscreenChange((isFullscreen) => {
229
- * console.log('Fullscreen changed:', isFullscreen);
230
- * });
231
- *
232
- * // Later: unsubscribe();
233
- * ```
234
- */
235
- export function onFullscreenChange(
236
- handler: FullscreenChangeHandler
237
- ): () => void {
238
- if (typeof document === 'undefined') {
239
- return () => {
240
- // No-op in server environment
241
- };
38
+ export function hideCursor(): void {
39
+ if (typeof process !== 'undefined' && process.stdout) {
40
+ process.stdout.write('\x1b[?25l')
242
41
  }
243
-
244
- const handleChange = (): void => {
245
- handler(isFullscreen());
246
- };
247
-
248
- // Standard event
249
- document.addEventListener('fullscreenchange', handleChange);
250
- // Vendor prefixed events
251
- document.addEventListener('webkitfullscreenchange', handleChange);
252
- document.addEventListener('mozfullscreenchange', handleChange);
253
- document.addEventListener('MSFullscreenChange', handleChange);
254
-
255
- // Return unsubscribe function
256
- return () => {
257
- document.removeEventListener('fullscreenchange', handleChange);
258
- document.removeEventListener('webkitfullscreenchange', handleChange);
259
- document.removeEventListener('mozfullscreenchange', handleChange);
260
- document.removeEventListener('MSFullscreenChange', handleChange);
261
- };
262
42
  }
263
43
 
264
- /**
265
- * Gets the current fullscreen element
266
- *
267
- * @returns {Element | null} The element currently in fullscreen, or null
268
- * @example
269
- * ```typescript
270
- * const element = getFullscreenElement();
271
- * if (element) {
272
- * console.log('Fullscreen element:', element.tagName);
273
- * }
274
- * ```
275
- */
276
- export function getFullscreenElement(): Element | null {
277
- if (typeof document === 'undefined') {
278
- return null;
44
+ export function showCursor(): void {
45
+ if (typeof process !== 'undefined' && process.stdout) {
46
+ process.stdout.write('\x1b[?25h')
279
47
  }
280
-
281
- const doc = document as FullscreenDocument;
282
-
283
- return (
284
- doc.fullscreenElement ??
285
- doc.webkitFullscreenElement ??
286
- doc.mozFullScreenElement ??
287
- doc.msFullscreenElement ??
288
- null
289
- );
290
48
  }
291
49
 
292
- /**
293
- * Locks screen orientation when in fullscreen (mobile devices)
294
- *
295
- * @param {OrientationLockType} orientation - Orientation to lock to
296
- * @returns {Promise<void>} Promise that resolves when orientation is locked
297
- * @example
298
- * ```typescript
299
- * await lockOrientation('landscape');
300
- * await enterFullscreen();
301
- * ```
302
- */
303
- /**
304
- * Valid orientation lock types
305
- * @typedef {string} OrientationLockType
306
- */
307
- type OrientationLockType = 'any' | 'natural' | 'landscape' | 'portrait' | 'portrait-primary' | 'portrait-secondary' | 'landscape-primary' | 'landscape-secondary';
308
-
309
- /**
310
- * Locks screen orientation when in fullscreen (mobile devices)
311
- *
312
- * @param {OrientationLockType} orientation - Orientation to lock to
313
- * @returns {Promise<void>} Promise that resolves when orientation is locked
314
- * @example
315
- * ```typescript
316
- * await lockOrientation('landscape');
317
- * await enterFullscreen();
318
- * ```
319
- */
320
- export async function lockOrientation(
321
- orientation: OrientationLockType
322
- ): Promise<void> {
323
- if (typeof screen === 'undefined' || !screen.orientation) {
324
- return Promise.reject(new Error('Screen Orientation API not supported'));
325
- }
326
-
327
- // Type assertion for lock method which may not be in all TypeScript lib versions
328
- const orientationApi = screen.orientation as {
329
- lock?(orientation: OrientationLockType): Promise<void>;
330
- unlock?(): void;
331
- };
332
-
333
- if (!orientationApi.lock) {
334
- return Promise.reject(new Error('Screen orientation lock not supported'));
335
- }
336
-
337
- try {
338
- await orientationApi.lock(orientation);
339
- } catch (error) {
340
- return Promise.reject(error);
50
+ export function alternateScreen(): void {
51
+ if (typeof process !== 'undefined' && process.stdout) {
52
+ process.stdout.write('\x1b[?1049h')
341
53
  }
342
54
  }
343
55
 
344
- /**
345
- * Unlocks screen orientation
346
- *
347
- * @returns {Promise<void>} Promise that resolves when orientation is unlocked
348
- * @example
349
- * ```typescript
350
- * await unlockOrientation();
351
- * ```
352
- */
353
- export async function unlockOrientation(): Promise<void> {
354
- if (typeof screen === 'undefined' || !screen.orientation) {
355
- return Promise.resolve();
356
- }
357
-
358
- // Type assertion for unlock method which may not be in all TypeScript lib versions
359
- const orientationApi = screen.orientation as {
360
- lock?(orientation: OrientationLockType): Promise<void>;
361
- unlock?(): void;
362
- };
363
-
364
- try {
365
- orientationApi.unlock?.();
366
- } catch {
367
- // Ignore unlock errors
56
+ export function mainScreen(): void {
57
+ if (typeof process !== 'undefined' && process.stdout) {
58
+ process.stdout.write('\x1b[?1049l')
368
59
  }
369
60
  }
370
61
 
371
- // Default export
372
62
  export default {
373
- isFullscreenSupported,
374
- isFullscreen,
375
63
  enterFullscreen,
376
64
  exitFullscreen,
65
+ isFullscreen,
377
66
  toggleFullscreen,
378
- onFullscreenChange,
379
- getFullscreenElement,
380
- lockOrientation,
381
- unlockOrientation,
382
- };
67
+ clearScreen,
68
+ hideCursor,
69
+ showCursor,
70
+ alternateScreen,
71
+ mainScreen,
72
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Git Utilities
3
+ */
4
+
5
+ export async function getGitRoot(cwd?: string): Promise<string | null> {
6
+ return null
7
+ }
8
+
9
+ export async function getBranch(cwd?: string): Promise<string | null> {
10
+ return null
11
+ }
12
+
13
+ export async function getIsGit(cwd?: string): Promise<boolean> {
14
+ return false
15
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Image Resizer Utilities
3
+ */
4
+
5
+ export interface ImageResizeOptions {
6
+ maxWidth?: number
7
+ maxHeight?: number
8
+ quality?: number
9
+ }
10
+
11
+ export async function resizeImage(
12
+ buffer: Buffer,
13
+ options: ImageResizeOptions
14
+ ): Promise<Buffer> {
15
+ // Placeholder implementation
16
+ return buffer
17
+ }
18
+
19
+ export function createImageMetadataText(
20
+ dimensions: { width: number; height: number },
21
+ size: number
22
+ ): string {
23
+ return `Image (${dimensions.width}x${dimensions.height}, ${formatFileSize(size)})`
24
+ }
25
+
26
+ function formatFileSize(bytes: number): string {
27
+ if (bytes < 1024) return `${bytes}B`
28
+ if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)}KB`
29
+ return `${(bytes / (1024 * 1024)).toFixed(1)}MB`
30
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Lazy Schema Utilities
3
+ */
4
+
5
+ import { z } from 'zod/v4'
6
+
7
+ export function createLazySchema<T>(schema: z.ZodType<T>): z.ZodType<T> {
8
+ return schema
9
+ }
@@ -0,0 +1,3 @@
1
+ // Re-export from shared/utils
2
+ export * from '../shared/utils/log.js'
3
+ export { default } from '../shared/utils/log.js'
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Markdown Config Loader
3
+ */
4
+
5
+ export interface MarkdownConfig {
6
+ theme?: string
7
+ highlight?: boolean
8
+ }
9
+
10
+ export function loadMarkdownConfig(): MarkdownConfig {
11
+ return {}
12
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Message Utilities
3
+ */
4
+
5
+ import type { Message } from '@/types/message.js'
6
+
7
+ export function countToolCalls(messages: Message[]): number {
8
+ return messages.filter(m => m.type === 'tool_use').length
9
+ }
10
+
11
+ export const SYNTHETIC_MESSAGES = {
12
+ compact: 'COMPACT',
13
+ } as const
@@ -0,0 +1,137 @@
1
+ /**
2
+ * Migration Utilities
3
+ *
4
+ * Handles migration from legacy SDK to Allternit Harness.
5
+ */
6
+
7
+ import { Config } from '@/config';
8
+ import { HarnessConfig } from '@allternit/sdk';
9
+ import { getHarnessMode, FEATURE_FLAGS } from './feature-flags';
10
+
11
+ /**
12
+ * Migrate existing configuration to harness format.
13
+ */
14
+ export async function migrateToHarness(): Promise<void> {
15
+ const mode = getHarnessMode();
16
+
17
+ // Check if already migrated
18
+ const existingMode = await Config.get('harness.mode');
19
+ if (existingMode) {
20
+ return; // Already migrated
21
+ }
22
+
23
+ // Migrate based on mode
24
+ switch (mode) {
25
+ case 'byok':
26
+ await migrateBYOK();
27
+ break;
28
+ case 'cloud':
29
+ await migrateCloud();
30
+ break;
31
+ case 'local':
32
+ await migrateLocal();
33
+ break;
34
+ case 'subprocess':
35
+ await migrateSubprocess();
36
+ break;
37
+ }
38
+
39
+ // Set mode
40
+ await Config.set('harness.mode', mode);
41
+ }
42
+
43
+ /**
44
+ * Migrate BYOK configuration.
45
+ */
46
+ async function migrateBYOK(): Promise<void> {
47
+ // Check for existing API keys
48
+ const anthropicKey = process.env.ANTHROPIC_API_KEY || await Config.get('anthropic.apiKey');
49
+ const openaiKey = process.env.OPENAI_API_KEY || await Config.get('openai.apiKey');
50
+ const googleKey = process.env.GOOGLE_API_KEY || await Config.get('google.apiKey');
51
+
52
+ if (anthropicKey) {
53
+ await Config.set('harness.byok.anthropic.apiKey', anthropicKey);
54
+ }
55
+ if (openaiKey) {
56
+ await Config.set('harness.byok.openai.apiKey', openaiKey);
57
+ }
58
+ if (googleKey) {
59
+ await Config.set('harness.byok.google.apiKey', googleKey);
60
+ }
61
+ }
62
+
63
+ /**
64
+ * Migrate cloud configuration.
65
+ */
66
+ async function migrateCloud(): Promise<void> {
67
+ const accessToken = await Config.get('oauth.accessToken') || process.env.ALLTERNIT_ACCESS_TOKEN;
68
+
69
+ if (accessToken) {
70
+ await Config.set('harness.cloud.accessToken', accessToken);
71
+ await Config.set('harness.cloud.baseURL', FEATURE_FLAGS.CLOUD_BASE_URL);
72
+ }
73
+ }
74
+
75
+ /**
76
+ * Migrate local configuration.
77
+ */
78
+ async function migrateLocal(): Promise<void> {
79
+ await Config.set('harness.local.baseURL', FEATURE_FLAGS.LOCAL_BASE_URL);
80
+ }
81
+
82
+ /**
83
+ * Migrate subprocess configuration.
84
+ */
85
+ async function migrateSubprocess(): Promise<void> {
86
+ if (FEATURE_FLAGS.SUBPROCESS_CMD) {
87
+ await Config.set('harness.subprocess.command', FEATURE_FLAGS.SUBPROCESS_CMD);
88
+ }
89
+ }
90
+
91
+ /**
92
+ * Get harness configuration for initialization.
93
+ */
94
+ export async function getHarnessConfig(): Promise<HarnessConfig> {
95
+ const mode = getHarnessMode();
96
+
97
+ switch (mode) {
98
+ case 'byok':
99
+ return {
100
+ mode: 'byok',
101
+ byok: {
102
+ anthropic: { apiKey: await Config.get('harness.byok.anthropic.apiKey') },
103
+ openai: { apiKey: await Config.get('harness.byok.openai.apiKey') },
104
+ google: { apiKey: await Config.get('harness.byok.google.apiKey') },
105
+ },
106
+ };
107
+
108
+ case 'cloud':
109
+ return {
110
+ mode: 'cloud',
111
+ cloud: {
112
+ baseURL: await Config.get('harness.cloud.baseURL') || FEATURE_FLAGS.CLOUD_BASE_URL,
113
+ accessToken: await Config.get('harness.cloud.accessToken'),
114
+ refreshToken: await Config.get('harness.cloud.refreshToken'),
115
+ },
116
+ };
117
+
118
+ case 'local':
119
+ return {
120
+ mode: 'local',
121
+ local: {
122
+ baseURL: await Config.get('harness.local.baseURL') || FEATURE_FLAGS.LOCAL_BASE_URL,
123
+ },
124
+ };
125
+
126
+ case 'subprocess':
127
+ return {
128
+ mode: 'subprocess',
129
+ subprocess: {
130
+ command: await Config.get('harness.subprocess.command') || FEATURE_FLAGS.SUBPROCESS_CMD || 'kimi -p',
131
+ },
132
+ };
133
+
134
+ default:
135
+ throw new Error(`Unknown harness mode: ${mode}`);
136
+ }
137
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Model Providers
3
+ */
4
+
5
+ export type ModelProvider = 'anthropic' | 'openai' | 'google'
6
+
7
+ export function getAPIProvider(): ModelProvider {
8
+ return 'anthropic'
9
+ }
10
+
11
+ export function getModelProvider(model: string): ModelProvider {
12
+ if (model.includes('claude')) return 'anthropic'
13
+ if (model.includes('gpt')) return 'openai'
14
+ return 'anthropic'
15
+ }
@@ -0,0 +1,3 @@
1
+ // Re-export from shared/utils
2
+ export * from '../shared/utils/path.js'
3
+ export { default } from '../shared/utils/path.js'
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Permission Result Types
3
+ */
4
+
5
+ export type PermissionResult =
6
+ | { type: 'allowed' }
7
+ | { type: 'denied'; reason: string }
8
+ | { type: 'pending' }
9
+
10
+ export const PermissionResult = {
11
+ allowed: (): PermissionResult => ({ type: 'allowed' }),
12
+ denied: (reason: string): PermissionResult => ({ type: 'denied', reason }),
13
+ pending: (): PermissionResult => ({ type: 'pending' }),
14
+ }