@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.
- package/bin/gizzi +4 -0
- package/bin/gizzi-ink +5 -0
- package/package.json +137 -31
- package/src/Tool.ts +26 -0
- package/src/bootstrap/state.ts +165 -322
- package/src/commands.ts +209 -0
- package/src/context/QueuedMessageContext.tsx +63 -0
- package/src/context/fpsMetrics.tsx +30 -0
- package/src/context/mailbox.tsx +38 -0
- package/src/context/modalContext.tsx +58 -0
- package/src/context/notifications.tsx +240 -0
- package/src/context/overlayContext.tsx +151 -0
- package/src/context/promptOverlayContext.tsx +125 -0
- package/src/context/stats.tsx +220 -0
- package/src/context/voice.tsx +88 -0
- package/src/hooks/useCanUseTool.ts +11 -0
- package/src/hooks/useExitOnCtrlCD.ts +40 -187
- package/src/hooks/useExitOnCtrlCDWithKeybindings.ts +68 -0
- package/src/hooks/useKeybinding.ts +68 -209
- package/src/hooks/useTerminalSize.ts +31 -99
- package/src/hooks.ts +37 -0
- package/src/ink.ts +204 -0
- package/src/main.ts +7 -0
- package/src/types/command.ts +216 -0
- package/src/types/connectorText.ts +39 -0
- package/src/types/fileSuggestion.ts +15 -0
- package/src/types/generated/events_mono/claude_code/v1/claude_code_internal_event.ts +865 -0
- package/src/types/generated/events_mono/common/v1/auth.ts +100 -0
- package/src/types/generated/events_mono/growthbook/v1/growthbook_experiment_event.ts +223 -0
- package/src/types/generated/google/protobuf/timestamp.ts +187 -0
- package/src/types/hooks.ts +319 -0
- package/src/types/ids.ts +44 -0
- package/src/types/logs.ts +331 -0
- package/src/types/merged/index.ts +5 -0
- package/src/types/merged/message.ts +552 -0
- package/src/types/message.ts +927 -186
- package/src/types/messageQueueTypes.ts +21 -0
- package/src/types/notebook.ts +72 -0
- package/src/types/permissions.ts +447 -0
- package/src/types/plugin.ts +363 -0
- package/src/types/statusLine.ts +15 -0
- package/src/types/textInputTypes.ts +387 -0
- package/src/types/tools.ts +149 -0
- package/src/types/utils.ts +20 -0
- package/src/utils/advisor.ts +12 -0
- package/src/utils/api.ts +29 -0
- package/src/utils/array.ts +7 -0
- package/src/utils/attachments.ts +60 -0
- package/src/utils/auth.ts +3 -0
- package/src/utils/claudeInChrome/chromeNativeHost.ts +15 -0
- package/src/utils/claudeInChrome/common.ts +12 -0
- package/src/utils/claudeInChrome/mcpServer.ts +15 -0
- package/src/utils/computerUse/common.ts +19 -0
- package/src/utils/computerUse/mcpServer.ts +15 -0
- package/src/utils/config.ts +35 -0
- package/src/utils/context.ts +19 -0
- package/src/utils/cwd.ts +3 -0
- package/src/utils/debug.ts +3 -0
- package/src/utils/earlyInput.ts +7 -0
- package/src/utils/effort.ts +13 -0
- package/src/utils/embeddedTools.ts +12 -0
- package/src/utils/envUtils.ts +3 -0
- package/src/utils/errors.ts +3 -0
- package/src/utils/execFileNoThrow.ts +24 -0
- package/src/utils/feature-flags.ts +112 -0
- package/src/utils/file.ts +3 -0
- package/src/utils/fileHistory.ts +17 -0
- package/src/utils/fingerprint.ts +7 -0
- package/src/utils/format.ts +75 -305
- package/src/utils/frontmatterParser.ts +33 -0
- package/src/utils/fsOperations.ts +31 -0
- package/src/utils/fullscreen.ts +40 -350
- package/src/utils/git.ts +15 -0
- package/src/utils/imageResizer.ts +30 -0
- package/src/utils/lazySchema.ts +9 -0
- package/src/utils/log.ts +3 -0
- package/src/utils/markdownConfigLoader.ts +12 -0
- package/src/utils/messages.ts +13 -0
- package/src/utils/migration.ts +137 -0
- package/src/utils/model/providers.ts +15 -0
- package/src/utils/path.ts +3 -0
- package/src/utils/permissions/PermissionResult.ts +14 -0
- package/src/utils/permissions/autoModeState.ts +12 -0
- package/src/utils/permissions/filesystem.ts +12 -0
- package/src/utils/plugins/loadPluginOutputStyles.ts +12 -0
- package/src/utils/plugins/schemas.ts +25 -0
- package/src/utils/process.ts +16 -0
- package/src/utils/sandbox/sandbox-adapter.ts +19 -0
- package/src/utils/sessionStorage.ts +238 -472
- package/src/utils/settings/constants.ts +10 -0
- package/src/utils/settings/settings.ts +19 -0
- package/src/utils/settings/types.ts +18 -0
- package/src/utils/shell/shellToolUtils.ts +9 -0
- package/src/utils/sinks.ts +11 -0
- package/src/utils/sleep.ts +7 -0
- package/src/utils/sliceAnsi.ts +7 -0
- package/src/utils/slowOperations.ts +3 -0
- package/src/utils/startupProfiler.ts +11 -0
- package/src/utils/stringUtils.ts +106 -0
- package/src/utils/systemPromptType.ts +9 -0
- package/src/utils/teleport/api.ts +15 -0
- package/src/utils/textHighlighting.ts +16 -0
- package/src/utils/theme.ts +17 -0
- package/src/utils/thinking.ts +58 -0
- package/src/utils/tokens.ts +11 -0
- package/src/utils/toolResultStorage.ts +17 -0
- package/src/utils/worktreeModeEnabled.ts +7 -0
- package/WORKSPACE_INTEGRATION.md +0 -290
- package/chat-sessions/sessions-index.json +0 -98
- package/package.json.original +0 -31
- package/package.json.publish +0 -47
- package/src/bootstrap/state.d.ts +0 -169
- package/src/bootstrap/state.js +0 -261
- package/src/context/pack-builder.d.ts +0 -24
- package/src/context/pack-builder.js +0 -281
- package/src/hooks/useExitOnCtrlCD.d.ts +0 -86
- package/src/hooks/useExitOnCtrlCD.js +0 -130
- package/src/hooks/useKeybinding.d.ts +0 -89
- package/src/hooks/useKeybinding.js +0 -163
- package/src/hooks/useTerminalSize.d.ts +0 -41
- package/src/hooks/useTerminalSize.js +0 -90
- package/src/index.d.ts +0 -23
- package/src/index.js +0 -24
- package/src/runtime/brand/brand.d.ts +0 -488
- package/src/runtime/brand/brand.js +0 -464
- package/src/runtime/brand/brand.ts +0 -667
- package/src/runtime/services/tokenEstimation.d.ts +0 -187
- package/src/runtime/services/tokenEstimation.js +0 -423
- package/src/runtime/services/tokenEstimation.ts +0 -547
- package/src/runtime/tools/Tool.d.ts +0 -239
- package/src/runtime/tools/Tool.js +0 -285
- package/src/runtime/tools/Tool.ts +0 -524
- package/src/scheduler/TaskScheduler.d.ts +0 -98
- package/src/scheduler/TaskScheduler.js +0 -201
- package/src/scheduler/TaskScheduler.ts +0 -259
- package/src/state/AppStateStore.d.ts +0 -347
- package/src/state/AppStateStore.js +0 -439
- package/src/state/AppStateStore.ts +0 -658
- package/src/state/WorkspaceStateStore.d.ts +0 -43
- package/src/state/WorkspaceStateStore.js +0 -224
- package/src/state/WorkspaceStateStore.ts +0 -297
- package/src/types/message.d.ts +0 -190
- package/src/types/message.js +0 -77
- package/src/utils/format.d.ts +0 -126
- package/src/utils/format.js +0 -230
- package/src/utils/fullscreen.d.ts +0 -161
- package/src/utils/fullscreen.js +0 -277
- package/src/utils/sessionStorage.d.ts +0 -210
- package/src/utils/sessionStorage.js +0 -435
- package/src/watcher/WorkspaceWatcher.d.ts +0 -70
- package/src/watcher/WorkspaceWatcher.js +0 -191
- package/src/watcher/WorkspaceWatcher.ts +0 -251
- package/src/workspace/loader.d.ts +0 -30
- package/src/workspace/loader.js +0 -117
- package/src/workspace/types.d.ts +0 -91
- package/src/workspace/types.js +0 -7
- package/threads/thread_1775361175022.json +0 -9
- package/tsconfig.json +0 -14
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"sessionId": "sess_1774559556358",
|
|
4
|
-
"fullPath": "/Users/macbook/.gizzi/chat-sessions/sess_1774559556358",
|
|
5
|
-
"title": "Test Chat Session",
|
|
6
|
-
"messageCount": 0,
|
|
7
|
-
"created": 1774559556358,
|
|
8
|
-
"modified": 1774559556358
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
"sessionId": "sess_1774559556361",
|
|
12
|
-
"fullPath": "/Users/macbook/.gizzi/chat-sessions/sess_1774559556361",
|
|
13
|
-
"title": "Test",
|
|
14
|
-
"messageCount": 0,
|
|
15
|
-
"created": 1774559556361,
|
|
16
|
-
"modified": 1774559556361
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
"sessionId": "sess_1774559557365",
|
|
20
|
-
"fullPath": "/Users/macbook/.gizzi/chat-sessions/sess_1774559557365",
|
|
21
|
-
"title": "Chat Session",
|
|
22
|
-
"messageCount": 0,
|
|
23
|
-
"created": 1774559557365,
|
|
24
|
-
"modified": 1774559557365
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
"sessionId": "sess_1774559557367",
|
|
28
|
-
"fullPath": "/Users/macbook/.gizzi/chat-sessions/sess_1774559557367",
|
|
29
|
-
"title": "Chat",
|
|
30
|
-
"messageCount": 0,
|
|
31
|
-
"created": 1774559557367,
|
|
32
|
-
"modified": 1774559557368
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
"sessionId": "sess_retry",
|
|
36
|
-
"fullPath": "/Users/macbook/.gizzi/chat-sessions/sess_retry",
|
|
37
|
-
"title": "Retry Success",
|
|
38
|
-
"messageCount": 0,
|
|
39
|
-
"created": 1774559560441,
|
|
40
|
-
"modified": 1774559560441
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
"sessionId": "sess_retry",
|
|
44
|
-
"fullPath": "/Users/macbook/.gizzi/chat-sessions/sess_retry",
|
|
45
|
-
"title": "Retry Success",
|
|
46
|
-
"messageCount": 0,
|
|
47
|
-
"created": 1774559561443,
|
|
48
|
-
"modified": 1774559561443
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
"sessionId": "sess_1774559746746",
|
|
52
|
-
"fullPath": "/Users/macbook/.gizzi/chat-sessions/sess_1774559746746",
|
|
53
|
-
"title": "Test Chat Session",
|
|
54
|
-
"messageCount": 0,
|
|
55
|
-
"created": 1774559746746,
|
|
56
|
-
"modified": 1774559746746
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
"sessionId": "sess_1774559746749",
|
|
60
|
-
"fullPath": "/Users/macbook/.gizzi/chat-sessions/sess_1774559746749",
|
|
61
|
-
"title": "Test",
|
|
62
|
-
"messageCount": 0,
|
|
63
|
-
"created": 1774559746749,
|
|
64
|
-
"modified": 1774559746749
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
"sessionId": "sess_1774559747751",
|
|
68
|
-
"fullPath": "/Users/macbook/.gizzi/chat-sessions/sess_1774559747751",
|
|
69
|
-
"title": "Chat Session",
|
|
70
|
-
"messageCount": 0,
|
|
71
|
-
"created": 1774559747751,
|
|
72
|
-
"modified": 1774559747752
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
"sessionId": "sess_1774559747753",
|
|
76
|
-
"fullPath": "/Users/macbook/.gizzi/chat-sessions/sess_1774559747753",
|
|
77
|
-
"title": "Chat",
|
|
78
|
-
"messageCount": 0,
|
|
79
|
-
"created": 1774559747753,
|
|
80
|
-
"modified": 1774559747754
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
"sessionId": "sess_retry",
|
|
84
|
-
"fullPath": "/Users/macbook/.gizzi/chat-sessions/sess_retry",
|
|
85
|
-
"title": "Retry Success",
|
|
86
|
-
"messageCount": 0,
|
|
87
|
-
"created": 1774559750761,
|
|
88
|
-
"modified": 1774559750761
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
"sessionId": "sess_retry",
|
|
92
|
-
"fullPath": "/Users/macbook/.gizzi/chat-sessions/sess_retry",
|
|
93
|
-
"title": "Retry Success",
|
|
94
|
-
"messageCount": 0,
|
|
95
|
-
"created": 1774559751764,
|
|
96
|
-
"modified": 1774559751764
|
|
97
|
-
}
|
|
98
|
-
]
|
package/package.json.original
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@gizzi/code",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"description": "Gizzi Code - Workspace-aware AI assistant framework",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "./dist/index.js",
|
|
7
|
-
"types": "./dist/index.d.ts",
|
|
8
|
-
"exports": {
|
|
9
|
-
".": {
|
|
10
|
-
"import": "./dist/index.js",
|
|
11
|
-
"types": "./dist/index.d.ts"
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
"scripts": {
|
|
15
|
-
"build": "tsc",
|
|
16
|
-
"dev": "tsc --watch",
|
|
17
|
-
"typecheck": "tsc --noEmit"
|
|
18
|
-
},
|
|
19
|
-
"dependencies": {
|
|
20
|
-
"@allternit/plugin": "link:/Users/macbook/Desktop/allternit-workspace/allternit/cmd/gizzi-code/packages/plugin",
|
|
21
|
-
"@a2r/plugin": "link:/Users/macbook/Desktop/a2rchitech-workspace/a2rchitech/cmd/gizzi-code/packages/plugin"
|
|
22
|
-
},
|
|
23
|
-
"devDependencies": {
|
|
24
|
-
"@types/node": "^20.0.0",
|
|
25
|
-
"@types/react": "^18.0.0",
|
|
26
|
-
"typescript": "^5.0.0"
|
|
27
|
-
},
|
|
28
|
-
"peerDependencies": {
|
|
29
|
-
"react": "^18.0.0"
|
|
30
|
-
}
|
|
31
|
-
}
|
package/package.json.publish
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@allternit/gizzi-code",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"description": "Gizzi Code - Workspace-aware AI assistant framework (like Claude Code for Allternit)",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "./dist/index.js",
|
|
7
|
-
"types": "./dist/index.d.ts",
|
|
8
|
-
"exports": {
|
|
9
|
-
".": {
|
|
10
|
-
"import": "./dist/index.js",
|
|
11
|
-
"types": "./dist/index.d.ts"
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
"bin": {
|
|
15
|
-
"gizzi": "./dist/cli/index.js"
|
|
16
|
-
},
|
|
17
|
-
"scripts": {
|
|
18
|
-
"build": "tsc",
|
|
19
|
-
"prepare": "npm run build",
|
|
20
|
-
"dev": "tsc --watch",
|
|
21
|
-
"typecheck": "tsc --noEmit"
|
|
22
|
-
},
|
|
23
|
-
"keywords": [
|
|
24
|
-
"allternit",
|
|
25
|
-
"gizzi",
|
|
26
|
-
"cli",
|
|
27
|
-
"ai",
|
|
28
|
-
"assistant",
|
|
29
|
-
"workspace"
|
|
30
|
-
],
|
|
31
|
-
"author": "Allternit",
|
|
32
|
-
"license": "MIT",
|
|
33
|
-
"publishConfig": {
|
|
34
|
-
"access": "public"
|
|
35
|
-
},
|
|
36
|
-
"devDependencies": {
|
|
37
|
-
"@types/node": "^20.0.0",
|
|
38
|
-
"@types/react": "^18.0.0",
|
|
39
|
-
"typescript": "^5.0.0"
|
|
40
|
-
},
|
|
41
|
-
"peerDependencies": {
|
|
42
|
-
"react": "^18.0.0"
|
|
43
|
-
},
|
|
44
|
-
"engines": {
|
|
45
|
-
"node": ">=18.0.0"
|
|
46
|
-
}
|
|
47
|
-
}
|
package/src/bootstrap/state.d.ts
DELETED
|
@@ -1,169 +0,0 @@
|
|
|
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
|
-
import type { TypedMessage } from '../types/message';
|
|
9
|
-
/**
|
|
10
|
-
* Loading phase identifiers for the bootstrap process
|
|
11
|
-
* @typedef {'idle' | 'initializing' | 'loading_config' | 'connecting' | 'authenticating' | 'ready' | 'error'} LoadingPhase
|
|
12
|
-
*/
|
|
13
|
-
export type LoadingPhase = 'idle' | 'initializing' | 'loading_config' | 'connecting' | 'authenticating' | 'ready' | 'error';
|
|
14
|
-
/**
|
|
15
|
-
* Valid loading phase transitions
|
|
16
|
-
* @constant {Record<LoadingPhase, readonly LoadingPhase[]>}
|
|
17
|
-
*/
|
|
18
|
-
export declare const VALID_PHASE_TRANSITIONS: Readonly<Record<LoadingPhase, readonly LoadingPhase[]>>;
|
|
19
|
-
/**
|
|
20
|
-
* Bootstrap error structure
|
|
21
|
-
* @interface BootstrapError
|
|
22
|
-
*/
|
|
23
|
-
export interface BootstrapError {
|
|
24
|
-
/** Error code for programmatic handling */
|
|
25
|
-
readonly code: string;
|
|
26
|
-
/** Human-readable error message */
|
|
27
|
-
readonly message: string;
|
|
28
|
-
/** Error timestamp */
|
|
29
|
-
readonly timestamp: Date;
|
|
30
|
-
/** Optional error details or stack trace */
|
|
31
|
-
readonly details?: string;
|
|
32
|
-
/** Phase where the error occurred */
|
|
33
|
-
readonly phase: LoadingPhase;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Bootstrap state interface tracking initialization progress
|
|
37
|
-
* @interface BootstrapState
|
|
38
|
-
*/
|
|
39
|
-
export interface BootstrapState {
|
|
40
|
-
/** Current loading phase */
|
|
41
|
-
readonly phase: LoadingPhase;
|
|
42
|
-
/** Overall progress percentage (0-100) */
|
|
43
|
-
readonly progress: number;
|
|
44
|
-
/** Whether the application has completed bootstrap */
|
|
45
|
-
readonly isComplete: boolean;
|
|
46
|
-
/** Whether an error has occurred during bootstrap */
|
|
47
|
-
readonly hasError: boolean;
|
|
48
|
-
/** Current error if any */
|
|
49
|
-
readonly error: BootstrapError | null;
|
|
50
|
-
/** Timestamp when bootstrap started */
|
|
51
|
-
readonly startTime: Date | null;
|
|
52
|
-
/** Timestamp when bootstrap completed */
|
|
53
|
-
readonly endTime: Date | null;
|
|
54
|
-
/** Messages collected during initialization */
|
|
55
|
-
readonly messages: readonly TypedMessage[];
|
|
56
|
-
/** Configuration data loaded during bootstrap */
|
|
57
|
-
readonly config: Readonly<Record<string, unknown>>;
|
|
58
|
-
/** Services initialized during bootstrap */
|
|
59
|
-
readonly services: readonly string[];
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Listener callback type for state changes
|
|
63
|
-
* @typedef {(state: BootstrapState) => void} StateChangeListener
|
|
64
|
-
*/
|
|
65
|
-
type StateChangeListener = (state: BootstrapState) => void;
|
|
66
|
-
/**
|
|
67
|
-
* Gets the current bootstrap state
|
|
68
|
-
* @returns {Readonly<BootstrapState>} The current bootstrap state (immutable)
|
|
69
|
-
* @example
|
|
70
|
-
* ```typescript
|
|
71
|
-
* const state = getBootstrapState();
|
|
72
|
-
* if (state.phase === 'ready') {
|
|
73
|
-
* console.log('Application is ready');
|
|
74
|
-
* }
|
|
75
|
-
* ```
|
|
76
|
-
*/
|
|
77
|
-
export declare function getBootstrapState(): Readonly<BootstrapState>;
|
|
78
|
-
/**
|
|
79
|
-
* Sets the bootstrap state with partial updates
|
|
80
|
-
* Automatically notifies all registered listeners
|
|
81
|
-
*
|
|
82
|
-
* @param {Partial<BootstrapState>} updates - Partial state updates to apply
|
|
83
|
-
* @returns {Readonly<BootstrapState>} The updated state
|
|
84
|
-
* @throws {Error} If attempting an invalid phase transition
|
|
85
|
-
* @example
|
|
86
|
-
* ```typescript
|
|
87
|
-
* setBootstrapState({ phase: 'initializing', progress: 10 });
|
|
88
|
-
* ```
|
|
89
|
-
*/
|
|
90
|
-
export declare function setBootstrapState(updates: Partial<BootstrapState>): Readonly<BootstrapState>;
|
|
91
|
-
/**
|
|
92
|
-
* Subscribes to bootstrap state changes
|
|
93
|
-
*
|
|
94
|
-
* @param {StateChangeListener} listener - Callback function to invoke on state changes
|
|
95
|
-
* @returns {() => void} Unsubscribe function
|
|
96
|
-
* @example
|
|
97
|
-
* ```typescript
|
|
98
|
-
* const unsubscribe = subscribeToBootstrapState((state) => {
|
|
99
|
-
* console.log('Phase:', state.phase);
|
|
100
|
-
* });
|
|
101
|
-
* // Later: unsubscribe();
|
|
102
|
-
* ```
|
|
103
|
-
*/
|
|
104
|
-
export declare function subscribeToBootstrapState(listener: StateChangeListener): () => void;
|
|
105
|
-
/**
|
|
106
|
-
* Resets the bootstrap state to initial values
|
|
107
|
-
* Useful for testing or re-initializing the application
|
|
108
|
-
*
|
|
109
|
-
* @param {boolean} [notifyListeners=true] - Whether to notify listeners of the reset
|
|
110
|
-
* @returns {Readonly<BootstrapState>} The reset state
|
|
111
|
-
*/
|
|
112
|
-
export declare function resetBootstrapState(notifyListeners?: boolean): Readonly<BootstrapState>;
|
|
113
|
-
/**
|
|
114
|
-
* Starts the bootstrap process
|
|
115
|
-
* Sets phase to 'initializing' and records start time
|
|
116
|
-
*
|
|
117
|
-
* @returns {Readonly<BootstrapState>} The updated state
|
|
118
|
-
*/
|
|
119
|
-
export declare function startBootstrap(): Readonly<BootstrapState>;
|
|
120
|
-
/**
|
|
121
|
-
* Reports a bootstrap error
|
|
122
|
-
* Sets phase to 'error' and records error details
|
|
123
|
-
*
|
|
124
|
-
* @param {string} code - Error code
|
|
125
|
-
* @param {string} message - Error message
|
|
126
|
-
* @param {string} [details] - Optional error details
|
|
127
|
-
* @returns {Readonly<BootstrapState>} The updated state
|
|
128
|
-
*/
|
|
129
|
-
export declare function setBootstrapError(code: string, message: string, details?: string): Readonly<BootstrapState>;
|
|
130
|
-
/**
|
|
131
|
-
* Completes the bootstrap process
|
|
132
|
-
* Sets phase to 'ready' and records completion time
|
|
133
|
-
*
|
|
134
|
-
* @returns {Readonly<BootstrapState>} The updated state
|
|
135
|
-
*/
|
|
136
|
-
export declare function completeBootstrap(): Readonly<BootstrapState>;
|
|
137
|
-
/**
|
|
138
|
-
* Gets the estimated time remaining for bootstrap
|
|
139
|
-
*
|
|
140
|
-
* @returns {number | null} Estimated milliseconds remaining, or null if not available
|
|
141
|
-
*/
|
|
142
|
-
export declare function getEstimatedTimeRemaining(): number | null;
|
|
143
|
-
/**
|
|
144
|
-
* Adds a message to the bootstrap state
|
|
145
|
-
*
|
|
146
|
-
* @param {TypedMessage} message - The message to add
|
|
147
|
-
* @returns {Readonly<BootstrapState>} The updated state
|
|
148
|
-
*/
|
|
149
|
-
export declare function addBootstrapMessage(message: TypedMessage): Readonly<BootstrapState>;
|
|
150
|
-
/**
|
|
151
|
-
* Registers a service as initialized
|
|
152
|
-
*
|
|
153
|
-
* @param {string} serviceName - Name of the service
|
|
154
|
-
* @returns {Readonly<BootstrapState>} The updated state
|
|
155
|
-
*/
|
|
156
|
-
export declare function registerService(serviceName: string): Readonly<BootstrapState>;
|
|
157
|
-
declare const _default: {
|
|
158
|
-
getBootstrapState: typeof getBootstrapState;
|
|
159
|
-
setBootstrapState: typeof setBootstrapState;
|
|
160
|
-
subscribeToBootstrapState: typeof subscribeToBootstrapState;
|
|
161
|
-
resetBootstrapState: typeof resetBootstrapState;
|
|
162
|
-
startBootstrap: typeof startBootstrap;
|
|
163
|
-
completeBootstrap: typeof completeBootstrap;
|
|
164
|
-
setBootstrapError: typeof setBootstrapError;
|
|
165
|
-
addBootstrapMessage: typeof addBootstrapMessage;
|
|
166
|
-
registerService: typeof registerService;
|
|
167
|
-
getEstimatedTimeRemaining: typeof getEstimatedTimeRemaining;
|
|
168
|
-
};
|
|
169
|
-
export default _default;
|
package/src/bootstrap/state.js
DELETED
|
@@ -1,261 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
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;
|