@allternit/gizzi-code 1.0.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.
Files changed (64) hide show
  1. package/WORKSPACE_INTEGRATION.md +290 -0
  2. package/chat-sessions/sessions-index.json +98 -0
  3. package/package.json +43 -0
  4. package/package.json.original +31 -0
  5. package/package.json.publish +47 -0
  6. package/src/bootstrap/state.d.ts +169 -0
  7. package/src/bootstrap/state.js +261 -0
  8. package/src/bootstrap/state.ts +371 -0
  9. package/src/context/pack-builder.d.ts +24 -0
  10. package/src/context/pack-builder.js +281 -0
  11. package/src/context/pack-builder.ts +334 -0
  12. package/src/hooks/useExitOnCtrlCD.d.ts +86 -0
  13. package/src/hooks/useExitOnCtrlCD.js +130 -0
  14. package/src/hooks/useExitOnCtrlCD.ts +202 -0
  15. package/src/hooks/useKeybinding.d.ts +89 -0
  16. package/src/hooks/useKeybinding.js +163 -0
  17. package/src/hooks/useKeybinding.ts +226 -0
  18. package/src/hooks/useTerminalSize.d.ts +41 -0
  19. package/src/hooks/useTerminalSize.js +90 -0
  20. package/src/hooks/useTerminalSize.ts +117 -0
  21. package/src/index.d.ts +23 -0
  22. package/src/index.js +24 -0
  23. package/src/index.ts +132 -0
  24. package/src/runtime/brand/brand.d.ts +488 -0
  25. package/src/runtime/brand/brand.js +464 -0
  26. package/src/runtime/brand/brand.ts +667 -0
  27. package/src/runtime/services/tokenEstimation.d.ts +187 -0
  28. package/src/runtime/services/tokenEstimation.js +423 -0
  29. package/src/runtime/services/tokenEstimation.ts +547 -0
  30. package/src/runtime/tools/Tool.d.ts +239 -0
  31. package/src/runtime/tools/Tool.js +285 -0
  32. package/src/runtime/tools/Tool.ts +524 -0
  33. package/src/scheduler/TaskScheduler.d.ts +98 -0
  34. package/src/scheduler/TaskScheduler.js +201 -0
  35. package/src/scheduler/TaskScheduler.ts +259 -0
  36. package/src/state/AppStateStore.d.ts +347 -0
  37. package/src/state/AppStateStore.js +439 -0
  38. package/src/state/AppStateStore.ts +658 -0
  39. package/src/state/WorkspaceStateStore.d.ts +43 -0
  40. package/src/state/WorkspaceStateStore.js +224 -0
  41. package/src/state/WorkspaceStateStore.ts +297 -0
  42. package/src/types/message.d.ts +190 -0
  43. package/src/types/message.js +77 -0
  44. package/src/types/message.ts +277 -0
  45. package/src/utils/format.d.ts +126 -0
  46. package/src/utils/format.js +230 -0
  47. package/src/utils/format.ts +336 -0
  48. package/src/utils/fullscreen.d.ts +161 -0
  49. package/src/utils/fullscreen.js +277 -0
  50. package/src/utils/fullscreen.ts +382 -0
  51. package/src/utils/sessionStorage.d.ts +210 -0
  52. package/src/utils/sessionStorage.js +435 -0
  53. package/src/utils/sessionStorage.ts +559 -0
  54. package/src/watcher/WorkspaceWatcher.d.ts +70 -0
  55. package/src/watcher/WorkspaceWatcher.js +191 -0
  56. package/src/watcher/WorkspaceWatcher.ts +251 -0
  57. package/src/workspace/loader.d.ts +30 -0
  58. package/src/workspace/loader.js +117 -0
  59. package/src/workspace/loader.ts +171 -0
  60. package/src/workspace/types.d.ts +91 -0
  61. package/src/workspace/types.js +7 -0
  62. package/src/workspace/types.ts +122 -0
  63. package/threads/thread_1775361175022.json +9 -0
  64. package/tsconfig.json +14 -0
@@ -0,0 +1,261 @@
1
+ /**
2
+ * @fileoverview Bootstrap state management for gizzi-code integration
3
+ * @module bootstrap/state
4
+ *
5
+ * Manages application initialization state, loading phases, and bootstrap
6
+ * lifecycle events. Provides centralized state tracking during application startup.
7
+ */
8
+ /**
9
+ * Valid loading phase transitions
10
+ * @constant {Record<LoadingPhase, readonly LoadingPhase[]>}
11
+ */
12
+ export const VALID_PHASE_TRANSITIONS = {
13
+ idle: ['initializing'],
14
+ initializing: ['loading_config', 'error'],
15
+ loading_config: ['connecting', 'error'],
16
+ connecting: ['authenticating', 'error'],
17
+ authenticating: ['ready', 'error'],
18
+ ready: ['idle', 'initializing'],
19
+ error: ['idle', 'initializing'],
20
+ };
21
+ /**
22
+ * Initial bootstrap state
23
+ * @constant {BootstrapState}
24
+ */
25
+ const INITIAL_STATE = {
26
+ phase: 'idle',
27
+ progress: 0,
28
+ isComplete: false,
29
+ hasError: false,
30
+ error: null,
31
+ startTime: null,
32
+ endTime: null,
33
+ messages: [],
34
+ config: {},
35
+ services: [],
36
+ };
37
+ // Module-level state (singleton pattern)
38
+ let currentState = { ...INITIAL_STATE };
39
+ const listeners = new Set();
40
+ /**
41
+ * Gets the current bootstrap state
42
+ * @returns {Readonly<BootstrapState>} The current bootstrap state (immutable)
43
+ * @example
44
+ * ```typescript
45
+ * const state = getBootstrapState();
46
+ * if (state.phase === 'ready') {
47
+ * console.log('Application is ready');
48
+ * }
49
+ * ```
50
+ */
51
+ export function getBootstrapState() {
52
+ return Object.freeze({ ...currentState });
53
+ }
54
+ /**
55
+ * Sets the bootstrap state with partial updates
56
+ * Automatically notifies all registered listeners
57
+ *
58
+ * @param {Partial<BootstrapState>} updates - Partial state updates to apply
59
+ * @returns {Readonly<BootstrapState>} The updated state
60
+ * @throws {Error} If attempting an invalid phase transition
61
+ * @example
62
+ * ```typescript
63
+ * setBootstrapState({ phase: 'initializing', progress: 10 });
64
+ * ```
65
+ */
66
+ export function setBootstrapState(updates) {
67
+ // Validate phase transition if phase is being updated
68
+ if (updates.phase && updates.phase !== currentState.phase) {
69
+ if (!isValidPhaseTransition(currentState.phase, updates.phase)) {
70
+ throw new Error(`Invalid phase transition from '${currentState.phase}' to '${updates.phase}'. ` +
71
+ `Valid transitions: ${VALID_PHASE_TRANSITIONS[currentState.phase].join(', ')}`);
72
+ }
73
+ }
74
+ // Create new state with updates
75
+ const previousState = currentState;
76
+ currentState = {
77
+ ...currentState,
78
+ ...updates,
79
+ // Merge nested objects carefully
80
+ config: updates.config ? { ...currentState.config, ...updates.config } : currentState.config,
81
+ messages: updates.messages ?? currentState.messages,
82
+ services: updates.services ?? currentState.services,
83
+ };
84
+ // Update computed fields
85
+ currentState = {
86
+ ...currentState,
87
+ isComplete: currentState.phase === 'ready',
88
+ hasError: currentState.phase === 'error' || currentState.error !== null,
89
+ };
90
+ // Notify listeners (async to avoid blocking)
91
+ queueMicrotask(() => {
92
+ listeners.forEach((listener) => {
93
+ try {
94
+ listener(currentState);
95
+ }
96
+ catch (error) {
97
+ console.error('Bootstrap state listener error:', error);
98
+ }
99
+ });
100
+ });
101
+ // Log state change in development
102
+ if (process.env.NODE_ENV === 'development') {
103
+ console.debug('[BootstrapState]', previousState.phase, '->', currentState.phase);
104
+ }
105
+ return Object.freeze({ ...currentState });
106
+ }
107
+ /**
108
+ * Subscribes to bootstrap state changes
109
+ *
110
+ * @param {StateChangeListener} listener - Callback function to invoke on state changes
111
+ * @returns {() => void} Unsubscribe function
112
+ * @example
113
+ * ```typescript
114
+ * const unsubscribe = subscribeToBootstrapState((state) => {
115
+ * console.log('Phase:', state.phase);
116
+ * });
117
+ * // Later: unsubscribe();
118
+ * ```
119
+ */
120
+ export function subscribeToBootstrapState(listener) {
121
+ listeners.add(listener);
122
+ // Immediately notify with current state
123
+ listener(currentState);
124
+ return () => {
125
+ listeners.delete(listener);
126
+ };
127
+ }
128
+ /**
129
+ * Resets the bootstrap state to initial values
130
+ * Useful for testing or re-initializing the application
131
+ *
132
+ * @param {boolean} [notifyListeners=true] - Whether to notify listeners of the reset
133
+ * @returns {Readonly<BootstrapState>} The reset state
134
+ */
135
+ export function resetBootstrapState(notifyListeners = true) {
136
+ currentState = { ...INITIAL_STATE };
137
+ if (notifyListeners) {
138
+ queueMicrotask(() => {
139
+ listeners.forEach((listener) => {
140
+ try {
141
+ listener(currentState);
142
+ }
143
+ catch (error) {
144
+ console.error('Bootstrap state listener error:', error);
145
+ }
146
+ });
147
+ });
148
+ }
149
+ return Object.freeze({ ...currentState });
150
+ }
151
+ /**
152
+ * Starts the bootstrap process
153
+ * Sets phase to 'initializing' and records start time
154
+ *
155
+ * @returns {Readonly<BootstrapState>} The updated state
156
+ */
157
+ export function startBootstrap() {
158
+ return setBootstrapState({
159
+ phase: 'initializing',
160
+ startTime: new Date(),
161
+ progress: 5,
162
+ });
163
+ }
164
+ /**
165
+ * Reports a bootstrap error
166
+ * Sets phase to 'error' and records error details
167
+ *
168
+ * @param {string} code - Error code
169
+ * @param {string} message - Error message
170
+ * @param {string} [details] - Optional error details
171
+ * @returns {Readonly<BootstrapState>} The updated state
172
+ */
173
+ export function setBootstrapError(code, message, details) {
174
+ const error = {
175
+ code,
176
+ message,
177
+ timestamp: new Date(),
178
+ details,
179
+ phase: currentState.phase,
180
+ };
181
+ return setBootstrapState({
182
+ phase: 'error',
183
+ error,
184
+ endTime: new Date(),
185
+ });
186
+ }
187
+ /**
188
+ * Completes the bootstrap process
189
+ * Sets phase to 'ready' and records completion time
190
+ *
191
+ * @returns {Readonly<BootstrapState>} The updated state
192
+ */
193
+ export function completeBootstrap() {
194
+ return setBootstrapState({
195
+ phase: 'ready',
196
+ progress: 100,
197
+ endTime: new Date(),
198
+ });
199
+ }
200
+ /**
201
+ * Validates if a phase transition is allowed
202
+ *
203
+ * @param {LoadingPhase} from - Current phase
204
+ * @param {LoadingPhase} to - Target phase
205
+ * @returns {boolean} Whether the transition is valid
206
+ */
207
+ function isValidPhaseTransition(from, to) {
208
+ return VALID_PHASE_TRANSITIONS[from].includes(to);
209
+ }
210
+ /**
211
+ * Gets the estimated time remaining for bootstrap
212
+ *
213
+ * @returns {number | null} Estimated milliseconds remaining, or null if not available
214
+ */
215
+ export function getEstimatedTimeRemaining() {
216
+ if (!currentState.startTime || currentState.progress === 0) {
217
+ return null;
218
+ }
219
+ const elapsed = Date.now() - currentState.startTime.getTime();
220
+ const progressRemaining = 100 - currentState.progress;
221
+ const estimatedTotal = (elapsed / currentState.progress) * 100;
222
+ return Math.max(0, (estimatedTotal * progressRemaining) / 100);
223
+ }
224
+ /**
225
+ * Adds a message to the bootstrap state
226
+ *
227
+ * @param {TypedMessage} message - The message to add
228
+ * @returns {Readonly<BootstrapState>} The updated state
229
+ */
230
+ export function addBootstrapMessage(message) {
231
+ return setBootstrapState({
232
+ messages: [...currentState.messages, message],
233
+ });
234
+ }
235
+ /**
236
+ * Registers a service as initialized
237
+ *
238
+ * @param {string} serviceName - Name of the service
239
+ * @returns {Readonly<BootstrapState>} The updated state
240
+ */
241
+ export function registerService(serviceName) {
242
+ if (currentState.services.includes(serviceName)) {
243
+ return getBootstrapState();
244
+ }
245
+ return setBootstrapState({
246
+ services: [...currentState.services, serviceName],
247
+ });
248
+ }
249
+ // Default export
250
+ export default {
251
+ getBootstrapState,
252
+ setBootstrapState,
253
+ subscribeToBootstrapState,
254
+ resetBootstrapState,
255
+ startBootstrap,
256
+ completeBootstrap,
257
+ setBootstrapError,
258
+ addBootstrapMessage,
259
+ registerService,
260
+ getEstimatedTimeRemaining,
261
+ };
@@ -0,0 +1,371 @@
1
+ /**
2
+ * @fileoverview Bootstrap state management for gizzi-code integration
3
+ * @module bootstrap/state
4
+ *
5
+ * Manages application initialization state, loading phases, and bootstrap
6
+ * lifecycle events. Provides centralized state tracking during application startup.
7
+ */
8
+
9
+ import type { TypedMessage } from '../types/message';
10
+
11
+ /**
12
+ * Loading phase identifiers for the bootstrap process
13
+ * @typedef {'idle' | 'initializing' | 'loading_config' | 'connecting' | 'authenticating' | 'ready' | 'error'} LoadingPhase
14
+ */
15
+ export type LoadingPhase =
16
+ | 'idle'
17
+ | 'initializing'
18
+ | 'loading_config'
19
+ | 'connecting'
20
+ | 'authenticating'
21
+ | 'ready'
22
+ | 'error';
23
+
24
+ /**
25
+ * Valid loading phase transitions
26
+ * @constant {Record<LoadingPhase, readonly LoadingPhase[]>}
27
+ */
28
+ export const VALID_PHASE_TRANSITIONS: Readonly<Record<LoadingPhase, readonly LoadingPhase[]>> = {
29
+ idle: ['initializing'],
30
+ initializing: ['loading_config', 'error'],
31
+ loading_config: ['connecting', 'error'],
32
+ connecting: ['authenticating', 'error'],
33
+ authenticating: ['ready', 'error'],
34
+ ready: ['idle', 'initializing'],
35
+ error: ['idle', 'initializing'],
36
+ } as const;
37
+
38
+ /**
39
+ * Bootstrap error structure
40
+ * @interface BootstrapError
41
+ */
42
+ export interface BootstrapError {
43
+ /** Error code for programmatic handling */
44
+ readonly code: string;
45
+
46
+ /** Human-readable error message */
47
+ readonly message: string;
48
+
49
+ /** Error timestamp */
50
+ readonly timestamp: Date;
51
+
52
+ /** Optional error details or stack trace */
53
+ readonly details?: string;
54
+
55
+ /** Phase where the error occurred */
56
+ readonly phase: LoadingPhase;
57
+ }
58
+
59
+ /**
60
+ * Bootstrap state interface tracking initialization progress
61
+ * @interface BootstrapState
62
+ */
63
+ export interface BootstrapState {
64
+ /** Current loading phase */
65
+ readonly phase: LoadingPhase;
66
+
67
+ /** Overall progress percentage (0-100) */
68
+ readonly progress: number;
69
+
70
+ /** Whether the application has completed bootstrap */
71
+ readonly isComplete: boolean;
72
+
73
+ /** Whether an error has occurred during bootstrap */
74
+ readonly hasError: boolean;
75
+
76
+ /** Current error if any */
77
+ readonly error: BootstrapError | null;
78
+
79
+ /** Timestamp when bootstrap started */
80
+ readonly startTime: Date | null;
81
+
82
+ /** Timestamp when bootstrap completed */
83
+ readonly endTime: Date | null;
84
+
85
+ /** Messages collected during initialization */
86
+ readonly messages: readonly TypedMessage[];
87
+
88
+ /** Configuration data loaded during bootstrap */
89
+ readonly config: Readonly<Record<string, unknown>>;
90
+
91
+ /** Services initialized during bootstrap */
92
+ readonly services: readonly string[];
93
+ }
94
+
95
+ /**
96
+ * Initial bootstrap state
97
+ * @constant {BootstrapState}
98
+ */
99
+ const INITIAL_STATE: BootstrapState = {
100
+ phase: 'idle',
101
+ progress: 0,
102
+ isComplete: false,
103
+ hasError: false,
104
+ error: null,
105
+ startTime: null,
106
+ endTime: null,
107
+ messages: [],
108
+ config: {},
109
+ services: [],
110
+ } as const;
111
+
112
+ /**
113
+ * Listener callback type for state changes
114
+ * @typedef {(state: BootstrapState) => void} StateChangeListener
115
+ */
116
+ type StateChangeListener = (state: BootstrapState) => void;
117
+
118
+ // Module-level state (singleton pattern)
119
+ let currentState: BootstrapState = { ...INITIAL_STATE };
120
+ const listeners: Set<StateChangeListener> = new Set();
121
+
122
+ /**
123
+ * Gets the current bootstrap state
124
+ * @returns {Readonly<BootstrapState>} The current bootstrap state (immutable)
125
+ * @example
126
+ * ```typescript
127
+ * const state = getBootstrapState();
128
+ * if (state.phase === 'ready') {
129
+ * console.log('Application is ready');
130
+ * }
131
+ * ```
132
+ */
133
+ export function getBootstrapState(): Readonly<BootstrapState> {
134
+ return Object.freeze({ ...currentState });
135
+ }
136
+
137
+ /**
138
+ * Sets the bootstrap state with partial updates
139
+ * Automatically notifies all registered listeners
140
+ *
141
+ * @param {Partial<BootstrapState>} updates - Partial state updates to apply
142
+ * @returns {Readonly<BootstrapState>} The updated state
143
+ * @throws {Error} If attempting an invalid phase transition
144
+ * @example
145
+ * ```typescript
146
+ * setBootstrapState({ phase: 'initializing', progress: 10 });
147
+ * ```
148
+ */
149
+ export function setBootstrapState(updates: Partial<BootstrapState>): Readonly<BootstrapState> {
150
+ // Validate phase transition if phase is being updated
151
+ if (updates.phase && updates.phase !== currentState.phase) {
152
+ if (!isValidPhaseTransition(currentState.phase, updates.phase)) {
153
+ throw new Error(
154
+ `Invalid phase transition from '${currentState.phase}' to '${updates.phase}'. ` +
155
+ `Valid transitions: ${VALID_PHASE_TRANSITIONS[currentState.phase].join(', ')}`
156
+ );
157
+ }
158
+ }
159
+
160
+ // Create new state with updates
161
+ const previousState = currentState;
162
+ currentState = {
163
+ ...currentState,
164
+ ...updates,
165
+ // Merge nested objects carefully
166
+ config: updates.config ? { ...currentState.config, ...updates.config } : currentState.config,
167
+ messages: updates.messages ?? currentState.messages,
168
+ services: updates.services ?? currentState.services,
169
+ };
170
+
171
+ // Update computed fields
172
+ currentState = {
173
+ ...currentState,
174
+ isComplete: currentState.phase === 'ready',
175
+ hasError: currentState.phase === 'error' || currentState.error !== null,
176
+ };
177
+
178
+ // Notify listeners (async to avoid blocking)
179
+ queueMicrotask(() => {
180
+ listeners.forEach((listener) => {
181
+ try {
182
+ listener(currentState);
183
+ } catch (error) {
184
+ console.error('Bootstrap state listener error:', error);
185
+ }
186
+ });
187
+ });
188
+
189
+ // Log state change in development
190
+ if (process.env.NODE_ENV === 'development') {
191
+ console.debug('[BootstrapState]', previousState.phase, '->', currentState.phase);
192
+ }
193
+
194
+ return Object.freeze({ ...currentState });
195
+ }
196
+
197
+ /**
198
+ * Subscribes to bootstrap state changes
199
+ *
200
+ * @param {StateChangeListener} listener - Callback function to invoke on state changes
201
+ * @returns {() => void} Unsubscribe function
202
+ * @example
203
+ * ```typescript
204
+ * const unsubscribe = subscribeToBootstrapState((state) => {
205
+ * console.log('Phase:', state.phase);
206
+ * });
207
+ * // Later: unsubscribe();
208
+ * ```
209
+ */
210
+ export function subscribeToBootstrapState(listener: StateChangeListener): () => void {
211
+ listeners.add(listener);
212
+
213
+ // Immediately notify with current state
214
+ listener(currentState);
215
+
216
+ return () => {
217
+ listeners.delete(listener);
218
+ };
219
+ }
220
+
221
+ /**
222
+ * Resets the bootstrap state to initial values
223
+ * Useful for testing or re-initializing the application
224
+ *
225
+ * @param {boolean} [notifyListeners=true] - Whether to notify listeners of the reset
226
+ * @returns {Readonly<BootstrapState>} The reset state
227
+ */
228
+ export function resetBootstrapState(notifyListeners = true): Readonly<BootstrapState> {
229
+ currentState = { ...INITIAL_STATE };
230
+
231
+ if (notifyListeners) {
232
+ queueMicrotask(() => {
233
+ listeners.forEach((listener) => {
234
+ try {
235
+ listener(currentState);
236
+ } catch (error) {
237
+ console.error('Bootstrap state listener error:', error);
238
+ }
239
+ });
240
+ });
241
+ }
242
+
243
+ return Object.freeze({ ...currentState });
244
+ }
245
+
246
+ /**
247
+ * Starts the bootstrap process
248
+ * Sets phase to 'initializing' and records start time
249
+ *
250
+ * @returns {Readonly<BootstrapState>} The updated state
251
+ */
252
+ export function startBootstrap(): Readonly<BootstrapState> {
253
+ return setBootstrapState({
254
+ phase: 'initializing',
255
+ startTime: new Date(),
256
+ progress: 5,
257
+ });
258
+ }
259
+
260
+ /**
261
+ * Reports a bootstrap error
262
+ * Sets phase to 'error' and records error details
263
+ *
264
+ * @param {string} code - Error code
265
+ * @param {string} message - Error message
266
+ * @param {string} [details] - Optional error details
267
+ * @returns {Readonly<BootstrapState>} The updated state
268
+ */
269
+ export function setBootstrapError(
270
+ code: string,
271
+ message: string,
272
+ details?: string
273
+ ): Readonly<BootstrapState> {
274
+ const error: BootstrapError = {
275
+ code,
276
+ message,
277
+ timestamp: new Date(),
278
+ details,
279
+ phase: currentState.phase,
280
+ };
281
+
282
+ return setBootstrapState({
283
+ phase: 'error',
284
+ error,
285
+ endTime: new Date(),
286
+ });
287
+ }
288
+
289
+ /**
290
+ * Completes the bootstrap process
291
+ * Sets phase to 'ready' and records completion time
292
+ *
293
+ * @returns {Readonly<BootstrapState>} The updated state
294
+ */
295
+ export function completeBootstrap(): Readonly<BootstrapState> {
296
+ return setBootstrapState({
297
+ phase: 'ready',
298
+ progress: 100,
299
+ endTime: new Date(),
300
+ });
301
+ }
302
+
303
+ /**
304
+ * Validates if a phase transition is allowed
305
+ *
306
+ * @param {LoadingPhase} from - Current phase
307
+ * @param {LoadingPhase} to - Target phase
308
+ * @returns {boolean} Whether the transition is valid
309
+ */
310
+ function isValidPhaseTransition(from: LoadingPhase, to: LoadingPhase): boolean {
311
+ return VALID_PHASE_TRANSITIONS[from].includes(to);
312
+ }
313
+
314
+ /**
315
+ * Gets the estimated time remaining for bootstrap
316
+ *
317
+ * @returns {number | null} Estimated milliseconds remaining, or null if not available
318
+ */
319
+ export function getEstimatedTimeRemaining(): number | null {
320
+ if (!currentState.startTime || currentState.progress === 0) {
321
+ return null;
322
+ }
323
+
324
+ const elapsed = Date.now() - currentState.startTime.getTime();
325
+ const progressRemaining = 100 - currentState.progress;
326
+ const estimatedTotal = (elapsed / currentState.progress) * 100;
327
+
328
+ return Math.max(0, (estimatedTotal * progressRemaining) / 100);
329
+ }
330
+
331
+ /**
332
+ * Adds a message to the bootstrap state
333
+ *
334
+ * @param {TypedMessage} message - The message to add
335
+ * @returns {Readonly<BootstrapState>} The updated state
336
+ */
337
+ export function addBootstrapMessage(message: TypedMessage): Readonly<BootstrapState> {
338
+ return setBootstrapState({
339
+ messages: [...currentState.messages, message],
340
+ });
341
+ }
342
+
343
+ /**
344
+ * Registers a service as initialized
345
+ *
346
+ * @param {string} serviceName - Name of the service
347
+ * @returns {Readonly<BootstrapState>} The updated state
348
+ */
349
+ export function registerService(serviceName: string): Readonly<BootstrapState> {
350
+ if (currentState.services.includes(serviceName)) {
351
+ return getBootstrapState();
352
+ }
353
+
354
+ return setBootstrapState({
355
+ services: [...currentState.services, serviceName],
356
+ });
357
+ }
358
+
359
+ // Default export
360
+ export default {
361
+ getBootstrapState,
362
+ setBootstrapState,
363
+ subscribeToBootstrapState,
364
+ resetBootstrapState,
365
+ startBootstrap,
366
+ completeBootstrap,
367
+ setBootstrapError,
368
+ addBootstrapMessage,
369
+ registerService,
370
+ getEstimatedTimeRemaining,
371
+ };
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Gizzi Context Pack Builder
3
+ *
4
+ * Builds structured context packs from workspace files
5
+ * Production-quality implementation matching Allternit platform
6
+ */
7
+ import type { ContextPack, ScheduledTask, WorkspaceFile } from '../workspace/types';
8
+ export declare function classifyFile(filePath: string): WorkspaceFile['type'];
9
+ export declare function parseSoulMd(content: string): {
10
+ trustTiers: ContextPack['trustTiers'];
11
+ identity: Partial<ContextPack['identity']>;
12
+ };
13
+ export declare function parseHeartbeatMd(content: string): ScheduledTask[];
14
+ export declare function buildSystemPrompt(pack: ContextPack): string;
15
+ export interface BuildContextPackOptions {
16
+ sessionId: string;
17
+ agentId: string;
18
+ agentName: string;
19
+ files: Map<string, string>;
20
+ }
21
+ export declare function buildContextPack(options: BuildContextPackOptions): ContextPack;
22
+ export declare function getStartupTasks(pack: ContextPack): ScheduledTask[];
23
+ export declare function requiresPermission(pack: ContextPack, action: string): boolean;
24
+ export declare function shouldRefreshContext(pack: ContextPack): boolean;