@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
@@ -0,0 +1,363 @@
1
+ import type { LspServerConfig } from '../runtime/services/lsp/types.js'
2
+ import type { McpServerConfig } from '../runtime/services/mcp/types.js'
3
+ import type { BundledSkillDefinition } from '../runtime/skills/bundledSkills.js'
4
+ import type {
5
+ CommandMetadata,
6
+ PluginAuthor,
7
+ PluginManifest,
8
+ } from '../utils/plugins/schemas.js'
9
+ import type { HooksSettings } from '../utils/settings/types.js'
10
+
11
+ export type { PluginAuthor, PluginManifest, CommandMetadata }
12
+
13
+ /**
14
+ * Definition for a built-in plugin that ships with the CLI.
15
+ * Built-in plugins appear in the /plugin UI and can be enabled/disabled by
16
+ * users (persisted to user settings).
17
+ */
18
+ export type BuiltinPluginDefinition = {
19
+ /** Plugin name (used in `{name}@builtin` identifier) */
20
+ name: string
21
+ /** Description shown in the /plugin UI */
22
+ description: string
23
+ /** Optional version string */
24
+ version?: string
25
+ /** Skills provided by this plugin */
26
+ skills?: BundledSkillDefinition[]
27
+ /** Hooks provided by this plugin */
28
+ hooks?: HooksSettings
29
+ /** MCP servers provided by this plugin */
30
+ mcpServers?: Record<string, McpServerConfig>
31
+ /** Whether this plugin is available (e.g. based on system capabilities). Unavailable plugins are hidden entirely. */
32
+ isAvailable?: () => boolean
33
+ /** Default enabled state before the user sets a preference (defaults to true) */
34
+ defaultEnabled?: boolean
35
+ }
36
+
37
+ export type PluginRepository = {
38
+ url: string
39
+ branch: string
40
+ lastUpdated?: string
41
+ commitSha?: string
42
+ }
43
+
44
+ export type PluginConfig = {
45
+ repositories: Record<string, PluginRepository>
46
+ }
47
+
48
+ export type LoadedPlugin = {
49
+ name: string
50
+ manifest: PluginManifest
51
+ path: string
52
+ source: string
53
+ repository: string // Repository identifier, usually same as source
54
+ enabled?: boolean
55
+ isBuiltin?: boolean // true for built-in plugins that ship with the CLI
56
+ sha?: string // Git commit SHA for version pinning (from marketplace entry source)
57
+ commandsPath?: string
58
+ commandsPaths?: string[] // Additional command paths from manifest
59
+ commandsMetadata?: Record<string, CommandMetadata> // Metadata for named commands from object-mapping format
60
+ agentsPath?: string
61
+ agentsPaths?: string[] // Additional agent paths from manifest
62
+ skillsPath?: string
63
+ skillsPaths?: string[] // Additional skill paths from manifest
64
+ outputStylesPath?: string
65
+ outputStylesPaths?: string[] // Additional output style paths from manifest
66
+ hooksConfig?: HooksSettings
67
+ mcpServers?: Record<string, McpServerConfig>
68
+ lspServers?: Record<string, LspServerConfig>
69
+ settings?: Record<string, unknown>
70
+ }
71
+
72
+ export type PluginComponent =
73
+ | 'commands'
74
+ | 'agents'
75
+ | 'skills'
76
+ | 'hooks'
77
+ | 'output-styles'
78
+
79
+ /**
80
+ * Discriminated union of plugin error types.
81
+ * Each error type has specific contextual data for better debugging and user guidance.
82
+ *
83
+ * This replaces the previous string-based error matching approach with type-safe
84
+ * error handling that can't break when error messages change.
85
+ *
86
+ * IMPLEMENTATION STATUS:
87
+ * Currently used in production (2 types):
88
+ * - generic-error: Used for various plugin loading failures
89
+ * - plugin-not-found: Used when plugin not found in marketplace
90
+ *
91
+ * Planned for future use (10 types - see TODOs in pluginLoader.ts):
92
+ * - path-not-found, git-auth-failed, git-timeout, network-error
93
+ * - manifest-parse-error, manifest-validation-error
94
+ * - marketplace-not-found, marketplace-load-failed
95
+ * - mcp-config-invalid, hook-load-failed, component-load-failed
96
+ *
97
+ * These unused types support UI formatting and provide a clear roadmap for
98
+ * improving error specificity. They can be incrementally implemented as
99
+ * error creation sites are refactored.
100
+ */
101
+ export type PluginError =
102
+ | {
103
+ type: 'path-not-found'
104
+ source: string
105
+ plugin?: string
106
+ path: string
107
+ component: PluginComponent
108
+ }
109
+ | {
110
+ type: 'git-auth-failed'
111
+ source: string
112
+ plugin?: string
113
+ gitUrl: string
114
+ authType: 'ssh' | 'https'
115
+ }
116
+ | {
117
+ type: 'git-timeout'
118
+ source: string
119
+ plugin?: string
120
+ gitUrl: string
121
+ operation: 'clone' | 'pull'
122
+ }
123
+ | {
124
+ type: 'network-error'
125
+ source: string
126
+ plugin?: string
127
+ url: string
128
+ details?: string
129
+ }
130
+ | {
131
+ type: 'manifest-parse-error'
132
+ source: string
133
+ plugin?: string
134
+ manifestPath: string
135
+ parseError: string
136
+ }
137
+ | {
138
+ type: 'manifest-validation-error'
139
+ source: string
140
+ plugin?: string
141
+ manifestPath: string
142
+ validationErrors: string[]
143
+ }
144
+ | {
145
+ type: 'plugin-not-found'
146
+ source: string
147
+ pluginId: string
148
+ marketplace: string
149
+ }
150
+ | {
151
+ type: 'marketplace-not-found'
152
+ source: string
153
+ marketplace: string
154
+ availableMarketplaces: string[]
155
+ }
156
+ | {
157
+ type: 'marketplace-load-failed'
158
+ source: string
159
+ marketplace: string
160
+ reason: string
161
+ }
162
+ | {
163
+ type: 'mcp-config-invalid'
164
+ source: string
165
+ plugin: string
166
+ serverName: string
167
+ validationError: string
168
+ }
169
+ | {
170
+ type: 'mcp-server-suppressed-duplicate'
171
+ source: string
172
+ plugin: string
173
+ serverName: string
174
+ duplicateOf: string
175
+ }
176
+ | {
177
+ type: 'lsp-config-invalid'
178
+ source: string
179
+ plugin: string
180
+ serverName: string
181
+ validationError: string
182
+ }
183
+ | {
184
+ type: 'hook-load-failed'
185
+ source: string
186
+ plugin: string
187
+ hookPath: string
188
+ reason: string
189
+ }
190
+ | {
191
+ type: 'component-load-failed'
192
+ source: string
193
+ plugin: string
194
+ component: PluginComponent
195
+ path: string
196
+ reason: string
197
+ }
198
+ | {
199
+ type: 'mcpb-download-failed'
200
+ source: string
201
+ plugin: string
202
+ url: string
203
+ reason: string
204
+ }
205
+ | {
206
+ type: 'mcpb-extract-failed'
207
+ source: string
208
+ plugin: string
209
+ mcpbPath: string
210
+ reason: string
211
+ }
212
+ | {
213
+ type: 'mcpb-invalid-manifest'
214
+ source: string
215
+ plugin: string
216
+ mcpbPath: string
217
+ validationError: string
218
+ }
219
+ | {
220
+ type: 'lsp-config-invalid'
221
+ source: string
222
+ plugin: string
223
+ serverName: string
224
+ validationError: string
225
+ }
226
+ | {
227
+ type: 'lsp-server-start-failed'
228
+ source: string
229
+ plugin: string
230
+ serverName: string
231
+ reason: string
232
+ }
233
+ | {
234
+ type: 'lsp-server-crashed'
235
+ source: string
236
+ plugin: string
237
+ serverName: string
238
+ exitCode: number | null
239
+ signal?: string
240
+ }
241
+ | {
242
+ type: 'lsp-request-timeout'
243
+ source: string
244
+ plugin: string
245
+ serverName: string
246
+ method: string
247
+ timeoutMs: number
248
+ }
249
+ | {
250
+ type: 'lsp-request-failed'
251
+ source: string
252
+ plugin: string
253
+ serverName: string
254
+ method: string
255
+ error: string
256
+ }
257
+ | {
258
+ type: 'marketplace-blocked-by-policy'
259
+ source: string
260
+ plugin?: string
261
+ marketplace: string
262
+ blockedByBlocklist?: boolean // true if blocked by blockedMarketplaces, false if not in strictKnownMarketplaces
263
+ allowedSources: string[] // Formatted source strings (e.g., "github:owner/repo")
264
+ }
265
+ | {
266
+ type: 'dependency-unsatisfied'
267
+ source: string
268
+ plugin: string
269
+ dependency: string
270
+ reason: 'not-enabled' | 'not-found'
271
+ }
272
+ | {
273
+ type: 'plugin-cache-miss'
274
+ source: string
275
+ plugin: string
276
+ installPath: string
277
+ }
278
+ | {
279
+ type: 'generic-error'
280
+ source: string
281
+ plugin?: string
282
+ error: string
283
+ }
284
+
285
+ export type PluginLoadResult = {
286
+ enabled: LoadedPlugin[]
287
+ disabled: LoadedPlugin[]
288
+ errors: PluginError[]
289
+ }
290
+
291
+ /**
292
+ * Helper function to get a display message from any PluginError
293
+ * Useful for logging and simple error displays
294
+ */
295
+ export function getPluginErrorMessage(error: PluginError): string {
296
+ switch (error.type) {
297
+ case 'generic-error':
298
+ return error.error
299
+ case 'path-not-found':
300
+ return `Path not found: ${error.path} (${error.component})`
301
+ case 'git-auth-failed':
302
+ return `Git authentication failed (${error.authType}): ${error.gitUrl}`
303
+ case 'git-timeout':
304
+ return `Git ${error.operation} timeout: ${error.gitUrl}`
305
+ case 'network-error':
306
+ return `Network error: ${error.url}${error.details ? ` - ${error.details}` : ''}`
307
+ case 'manifest-parse-error':
308
+ return `Manifest parse error: ${error.parseError}`
309
+ case 'manifest-validation-error':
310
+ return `Manifest validation failed: ${error.validationErrors.join(', ')}`
311
+ case 'plugin-not-found':
312
+ return `Plugin ${error.pluginId} not found in marketplace ${error.marketplace}`
313
+ case 'marketplace-not-found':
314
+ return `Marketplace ${error.marketplace} not found`
315
+ case 'marketplace-load-failed':
316
+ return `Marketplace ${error.marketplace} failed to load: ${error.reason}`
317
+ case 'mcp-config-invalid':
318
+ return `MCP server ${error.serverName} invalid: ${error.validationError}`
319
+ case 'mcp-server-suppressed-duplicate': {
320
+ const dup = error.duplicateOf.startsWith('plugin:')
321
+ ? `server provided by plugin "${error.duplicateOf.split(':')[1] ?? '?'}"`
322
+ : `already-configured "${error.duplicateOf}"`
323
+ return `MCP server "${error.serverName}" skipped — same command/URL as ${dup}`
324
+ }
325
+ case 'hook-load-failed':
326
+ return `Hook load failed: ${error.reason}`
327
+ case 'component-load-failed':
328
+ return `${error.component} load failed from ${error.path}: ${error.reason}`
329
+ case 'mcpb-download-failed':
330
+ return `Failed to download MCPB from ${error.url}: ${error.reason}`
331
+ case 'mcpb-extract-failed':
332
+ return `Failed to extract MCPB ${error.mcpbPath}: ${error.reason}`
333
+ case 'mcpb-invalid-manifest':
334
+ return `MCPB manifest invalid at ${error.mcpbPath}: ${error.validationError}`
335
+ case 'lsp-config-invalid':
336
+ return `Plugin "${error.plugin}" has invalid LSP server config for "${error.serverName}": ${error.validationError}`
337
+ case 'lsp-server-start-failed':
338
+ return `Plugin "${error.plugin}" failed to start LSP server "${error.serverName}": ${error.reason}`
339
+ case 'lsp-server-crashed':
340
+ if (error.signal) {
341
+ return `Plugin "${error.plugin}" LSP server "${error.serverName}" crashed with signal ${error.signal}`
342
+ }
343
+ return `Plugin "${error.plugin}" LSP server "${error.serverName}" crashed with exit code ${error.exitCode ?? 'unknown'}`
344
+ case 'lsp-request-timeout':
345
+ return `Plugin "${error.plugin}" LSP server "${error.serverName}" timed out on ${error.method} request after ${error.timeoutMs}ms`
346
+ case 'lsp-request-failed':
347
+ return `Plugin "${error.plugin}" LSP server "${error.serverName}" ${error.method} request failed: ${error.error}`
348
+ case 'marketplace-blocked-by-policy':
349
+ if (error.blockedByBlocklist) {
350
+ return `Marketplace '${error.marketplace}' is blocked by enterprise policy`
351
+ }
352
+ return `Marketplace '${error.marketplace}' is not in the allowed marketplace list`
353
+ case 'dependency-unsatisfied': {
354
+ const hint =
355
+ error.reason === 'not-enabled'
356
+ ? 'disabled — enable it or remove the dependency'
357
+ : 'not found in any configured marketplace'
358
+ return `Dependency "${error.dependency}" is ${hint}`
359
+ }
360
+ case 'plugin-cache-miss':
361
+ return `Plugin "${error.plugin}" not cached at ${error.installPath} — run /plugins to refresh`
362
+ }
363
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Status line types
3
+ */
4
+
5
+ export interface StatusLineState {
6
+ text: string
7
+ type: 'info' | 'warning' | 'error' | 'success'
8
+ timeout?: number
9
+ }
10
+
11
+ export interface StatusLineCommandInput {
12
+ command: string
13
+ args: string[]
14
+ context?: Record<string, unknown>
15
+ }