@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.
- package/WORKSPACE_INTEGRATION.md +290 -0
- package/chat-sessions/sessions-index.json +98 -0
- package/package.json +43 -0
- package/package.json.original +31 -0
- package/package.json.publish +47 -0
- package/src/bootstrap/state.d.ts +169 -0
- package/src/bootstrap/state.js +261 -0
- package/src/bootstrap/state.ts +371 -0
- package/src/context/pack-builder.d.ts +24 -0
- package/src/context/pack-builder.js +281 -0
- package/src/context/pack-builder.ts +334 -0
- package/src/hooks/useExitOnCtrlCD.d.ts +86 -0
- package/src/hooks/useExitOnCtrlCD.js +130 -0
- package/src/hooks/useExitOnCtrlCD.ts +202 -0
- package/src/hooks/useKeybinding.d.ts +89 -0
- package/src/hooks/useKeybinding.js +163 -0
- package/src/hooks/useKeybinding.ts +226 -0
- package/src/hooks/useTerminalSize.d.ts +41 -0
- package/src/hooks/useTerminalSize.js +90 -0
- package/src/hooks/useTerminalSize.ts +117 -0
- package/src/index.d.ts +23 -0
- package/src/index.js +24 -0
- package/src/index.ts +132 -0
- package/src/runtime/brand/brand.d.ts +488 -0
- package/src/runtime/brand/brand.js +464 -0
- package/src/runtime/brand/brand.ts +667 -0
- package/src/runtime/services/tokenEstimation.d.ts +187 -0
- package/src/runtime/services/tokenEstimation.js +423 -0
- package/src/runtime/services/tokenEstimation.ts +547 -0
- package/src/runtime/tools/Tool.d.ts +239 -0
- package/src/runtime/tools/Tool.js +285 -0
- package/src/runtime/tools/Tool.ts +524 -0
- package/src/scheduler/TaskScheduler.d.ts +98 -0
- package/src/scheduler/TaskScheduler.js +201 -0
- package/src/scheduler/TaskScheduler.ts +259 -0
- package/src/state/AppStateStore.d.ts +347 -0
- package/src/state/AppStateStore.js +439 -0
- package/src/state/AppStateStore.ts +658 -0
- package/src/state/WorkspaceStateStore.d.ts +43 -0
- package/src/state/WorkspaceStateStore.js +224 -0
- package/src/state/WorkspaceStateStore.ts +297 -0
- package/src/types/message.d.ts +190 -0
- package/src/types/message.js +77 -0
- package/src/types/message.ts +277 -0
- package/src/utils/format.d.ts +126 -0
- package/src/utils/format.js +230 -0
- package/src/utils/format.ts +336 -0
- package/src/utils/fullscreen.d.ts +161 -0
- package/src/utils/fullscreen.js +277 -0
- package/src/utils/fullscreen.ts +382 -0
- package/src/utils/sessionStorage.d.ts +210 -0
- package/src/utils/sessionStorage.js +435 -0
- package/src/utils/sessionStorage.ts +559 -0
- package/src/watcher/WorkspaceWatcher.d.ts +70 -0
- package/src/watcher/WorkspaceWatcher.js +191 -0
- package/src/watcher/WorkspaceWatcher.ts +251 -0
- package/src/workspace/loader.d.ts +30 -0
- package/src/workspace/loader.js +117 -0
- package/src/workspace/loader.ts +171 -0
- package/src/workspace/types.d.ts +91 -0
- package/src/workspace/types.js +7 -0
- package/src/workspace/types.ts +122 -0
- package/threads/thread_1775361175022.json +9 -0
- package/tsconfig.json +14 -0
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
# Gizzi Code - Workspace Integration
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Gizzi Code now supports **agent workspace files** - the same production-quality implementation as the Allternit Platform.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
### ✅ Workspace File Loading
|
|
10
|
+
- SOUL.md (trust tiers, self-awareness)
|
|
11
|
+
- HEARTBEAT.md (periodic tasks)
|
|
12
|
+
- IDENTITY.md (core identity)
|
|
13
|
+
- PLAYBOOK.md (execution rules)
|
|
14
|
+
- TOOLS.md (tool inventory)
|
|
15
|
+
- VOICE.md (communication style)
|
|
16
|
+
- BRAIN.md, MEMORY.md (memory system)
|
|
17
|
+
- And all other workspace files
|
|
18
|
+
|
|
19
|
+
### ✅ Trust Tier Enforcement
|
|
20
|
+
SOUL.md trust tiers are parsed and enforced:
|
|
21
|
+
- **Tier 1**: Always apply (hard rules)
|
|
22
|
+
- **Tier 2**: Context-dependent (apply when relevant)
|
|
23
|
+
- **Tier 3**: Permission required (ask user first)
|
|
24
|
+
|
|
25
|
+
### ✅ HEARTBEAT Task Execution
|
|
26
|
+
HEARTBEAT.md tasks are executed on session start:
|
|
27
|
+
- `on-session-start` tasks run immediately
|
|
28
|
+
- Future: `daily`, `weekly`, `monthly` scheduled tasks
|
|
29
|
+
|
|
30
|
+
### ✅ Context Sent with Every Message
|
|
31
|
+
Full context pack sent to AI on every interaction:
|
|
32
|
+
```typescript
|
|
33
|
+
{
|
|
34
|
+
systemPrompt: 'Complete agent identity and rules',
|
|
35
|
+
trustTiers: { tier1, tier2, tier3 },
|
|
36
|
+
governance: { playbook, tools, hardBans },
|
|
37
|
+
heartbeat: { tasks },
|
|
38
|
+
memory: { brain, activeTasks, lessons }
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Usage
|
|
43
|
+
|
|
44
|
+
### Basic Setup
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
import { getWorkspaceStore, loadWorkspace } from '@gizzi/code';
|
|
48
|
+
|
|
49
|
+
// Get the workspace-enabled store
|
|
50
|
+
const store = getWorkspaceStore();
|
|
51
|
+
|
|
52
|
+
// Configure filesystem
|
|
53
|
+
store.setFileSystem({
|
|
54
|
+
readFile: async (path) => { /* ... */ },
|
|
55
|
+
listDirectory: async (path) => { /* ... */ },
|
|
56
|
+
exists: async (path) => { /* ... */ },
|
|
57
|
+
}, '/path/to/agent/workspace');
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Activate Agent Mode
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
// Activate agent with workspace
|
|
64
|
+
const success = await store.activateAgentMode('my-agent', 'My Custom Agent');
|
|
65
|
+
|
|
66
|
+
if (success) {
|
|
67
|
+
console.log('Agent mode activated with workspace context');
|
|
68
|
+
|
|
69
|
+
// Send message with automatic context inclusion
|
|
70
|
+
await store.sendMessageWithContext('Hello!');
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Check Trust Tiers
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
// Before executing sensitive actions
|
|
78
|
+
if (store.requiresPermission('deploy_to_production')) {
|
|
79
|
+
await askUserPermission('Deploy to production?');
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Get full trust tiers
|
|
83
|
+
const tiers = store.getTrustTiers();
|
|
84
|
+
console.log('Tier 1 rules:', tiers?.tier1.rules);
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Get System Prompt
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
// Get the complete system prompt built from workspace
|
|
91
|
+
const systemPrompt = store.getSystemPrompt();
|
|
92
|
+
console.log(systemPrompt);
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Workspace File Structure
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
agents/{agent-id}/
|
|
99
|
+
└── .allternit/
|
|
100
|
+
├── manifest.json
|
|
101
|
+
├── brain/BRAIN.md
|
|
102
|
+
├── memory/
|
|
103
|
+
│ ├── MEMORY.md
|
|
104
|
+
│ ├── active-tasks.md
|
|
105
|
+
│ ├── daily.md
|
|
106
|
+
│ ├── lessons.md
|
|
107
|
+
│ └── self-review.md
|
|
108
|
+
├── identity/
|
|
109
|
+
│ ├── IDENTITY.md
|
|
110
|
+
│ ├── SOUL.md ← Trust tiers (CRITICAL)
|
|
111
|
+
│ ├── USER.md
|
|
112
|
+
│ ├── VOICE.md
|
|
113
|
+
│ └── POLICY.md
|
|
114
|
+
├── governance/
|
|
115
|
+
│ ├── PLAYBOOK.md
|
|
116
|
+
│ ├── TOOLS.md
|
|
117
|
+
│ ├── HEARTBEAT.md ← Scheduled tasks (CRITICAL)
|
|
118
|
+
│ ├── SYSTEM.md
|
|
119
|
+
│ └── CHANNELS.md
|
|
120
|
+
├── skills/
|
|
121
|
+
│ └── _template/
|
|
122
|
+
│ ├── SKILL.md
|
|
123
|
+
│ └── contract.json
|
|
124
|
+
└── business/
|
|
125
|
+
└── CLIENTS.md
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## SOUL.md Example
|
|
129
|
+
|
|
130
|
+
```markdown
|
|
131
|
+
# SOUL.md — Agent's Soul Configuration
|
|
132
|
+
|
|
133
|
+
## Tier 1 — Foundation
|
|
134
|
+
✅ Always apply:
|
|
135
|
+
- Respect user privacy
|
|
136
|
+
- Be transparent about capabilities
|
|
137
|
+
- Never execute code without permission
|
|
138
|
+
|
|
139
|
+
## Tier 2 — Contextual
|
|
140
|
+
- Adapt tone to user's expertise level
|
|
141
|
+
- Offer alternatives when uncertain
|
|
142
|
+
|
|
143
|
+
## Tier 3 — Permission Required
|
|
144
|
+
- Access external APIs
|
|
145
|
+
- Execute shell commands
|
|
146
|
+
- Modify production systems
|
|
147
|
+
- Access sensitive user data
|
|
148
|
+
|
|
149
|
+
## Self-Awareness
|
|
150
|
+
I am {agent_name}, an AI assistant specialized in {specialty}.
|
|
151
|
+
I aim to be helpful while respecting safety boundaries.
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## HEARTBEAT.md Example
|
|
155
|
+
|
|
156
|
+
```markdown
|
|
157
|
+
# HEARTBEAT.md — Periodic Tasks
|
|
158
|
+
|
|
159
|
+
## On Session Start
|
|
160
|
+
- [ ] Load recent context from memory
|
|
161
|
+
- [ ] Check for pending user requests
|
|
162
|
+
- [ ] Initialize tool connections
|
|
163
|
+
|
|
164
|
+
## Daily
|
|
165
|
+
- [ ] Memory compaction
|
|
166
|
+
- [ ] Self-review of recent interactions
|
|
167
|
+
|
|
168
|
+
## Weekly
|
|
169
|
+
- [ ] Performance analysis
|
|
170
|
+
- [ ] Update knowledge base
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## API Reference
|
|
174
|
+
|
|
175
|
+
### WorkspaceStateStore
|
|
176
|
+
|
|
177
|
+
```typescript
|
|
178
|
+
class WorkspaceStateStore extends AppStateStore {
|
|
179
|
+
// Configuration
|
|
180
|
+
setFileSystem(fs: FileSystem, basePath: string): void
|
|
181
|
+
|
|
182
|
+
// Agent Mode
|
|
183
|
+
activateAgentMode(agentId: string, agentName: string): Promise<boolean>
|
|
184
|
+
resetAgentMode(): void
|
|
185
|
+
|
|
186
|
+
// Messaging with Context
|
|
187
|
+
sendMessageWithContext(
|
|
188
|
+
content: string,
|
|
189
|
+
options?: { skipContext?: boolean }
|
|
190
|
+
): Promise<void>
|
|
191
|
+
|
|
192
|
+
// Context Access
|
|
193
|
+
getContextPack(): ContextPack | null
|
|
194
|
+
getSystemPrompt(): string
|
|
195
|
+
getTrustTiers(): TrustTiers | null
|
|
196
|
+
requiresPermission(action: string): boolean
|
|
197
|
+
isAgentMode(): boolean
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Context Pack
|
|
202
|
+
|
|
203
|
+
```typescript
|
|
204
|
+
interface ContextPack {
|
|
205
|
+
version: '1.0.0';
|
|
206
|
+
agentId: string;
|
|
207
|
+
agentName: string;
|
|
208
|
+
sessionId: string;
|
|
209
|
+
|
|
210
|
+
identity: {
|
|
211
|
+
name: string;
|
|
212
|
+
purpose: string;
|
|
213
|
+
backstory: string;
|
|
214
|
+
personalityTraits: string[];
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
trustTiers: {
|
|
218
|
+
tier1: TrustTier; // Always apply
|
|
219
|
+
tier2: TrustTier; // Context-dependent
|
|
220
|
+
tier3: TrustTier; // Permission required
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
governance: {
|
|
224
|
+
playbook: string;
|
|
225
|
+
availableTools: ToolDefinition[];
|
|
226
|
+
hardBans: string[];
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
heartbeat: {
|
|
230
|
+
tasks: ScheduledTask[];
|
|
231
|
+
lastCheck: string;
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
systemPrompt: string; // Complete prompt for AI
|
|
235
|
+
hash: string; // For caching
|
|
236
|
+
}
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
## Integration Example
|
|
240
|
+
|
|
241
|
+
```typescript
|
|
242
|
+
import { getWorkspaceStore } from '@gizzi/code';
|
|
243
|
+
|
|
244
|
+
async function main() {
|
|
245
|
+
const store = getWorkspaceStore();
|
|
246
|
+
|
|
247
|
+
// Setup filesystem (example using Node.js fs)
|
|
248
|
+
store.setFileSystem(
|
|
249
|
+
{
|
|
250
|
+
readFile: async (path) => await fs.readFile(path, 'utf-8'),
|
|
251
|
+
listDirectory: async (path) => await fs.readdir(path, { withFileTypes: true })
|
|
252
|
+
.then(entries => entries.map(e => ({ name: e.name, type: e.isDirectory() ? 'directory' : 'file' }))),
|
|
253
|
+
exists: async (path) => await fs.access(path).then(() => true).catch(() => false),
|
|
254
|
+
},
|
|
255
|
+
'/Users/me/agents/my-agent'
|
|
256
|
+
);
|
|
257
|
+
|
|
258
|
+
// Activate agent
|
|
259
|
+
await store.activateAgentMode('my-agent', 'Code Assistant');
|
|
260
|
+
|
|
261
|
+
// Check permissions before action
|
|
262
|
+
if (store.requiresPermission('execute_shell_command')) {
|
|
263
|
+
const approved = await confirm('Execute: rm -rf /?');
|
|
264
|
+
if (!approved) return;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// Send message (context automatically included)
|
|
268
|
+
await store.sendMessageWithContext('Help me refactor this code');
|
|
269
|
+
}
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
## Determinism
|
|
273
|
+
|
|
274
|
+
The workspace system is **deterministic**:
|
|
275
|
+
1. Files are loaded in a specific order
|
|
276
|
+
2. Context pack is built with consistent structure
|
|
277
|
+
3. Same workspace files → same system prompt → same AI behavior
|
|
278
|
+
4. Context hash ensures cache consistency
|
|
279
|
+
|
|
280
|
+
## Next Steps
|
|
281
|
+
|
|
282
|
+
1. Implement backend AI integration that accepts context packs
|
|
283
|
+
2. ~~Add file watcher for automatic context refresh~~ ✅ Done
|
|
284
|
+
3. ~~Implement scheduled task execution (cron)~~ ✅ Done
|
|
285
|
+
4. Add context pack versioning
|
|
286
|
+
|
|
287
|
+
## See Also
|
|
288
|
+
|
|
289
|
+
- Allternit Platform Workspace Implementation (mirrors this)
|
|
290
|
+
- `WORKSPACE_PRODUCTION_IMPLEMENTATION.md` in Allternit codebase
|
|
@@ -0,0 +1,98 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
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": "./src/index.ts",
|
|
7
|
+
"types": "./src/index.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./src/index.ts",
|
|
11
|
+
"types": "./src/index.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsc || true",
|
|
16
|
+
"dev": "tsc --watch",
|
|
17
|
+
"typecheck": "tsc --noEmit || true"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"allternit",
|
|
21
|
+
"gizzi",
|
|
22
|
+
"cli",
|
|
23
|
+
"ai",
|
|
24
|
+
"assistant",
|
|
25
|
+
"workspace"
|
|
26
|
+
],
|
|
27
|
+
"author": "Allternit",
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/node": "^20.0.0",
|
|
34
|
+
"@types/react": "^18.0.0",
|
|
35
|
+
"typescript": "^5.0.0"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"react": "^18.0.0"
|
|
39
|
+
},
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": ">=18.0.0"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,169 @@
|
|
|
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;
|