@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,226 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Keybinding hook for gizzi-code integration
|
|
3
|
+
* @module hooks/useKeybinding
|
|
4
|
+
*
|
|
5
|
+
* Provides a React hook for registering keyboard shortcuts and key combinations.
|
|
6
|
+
* Supports modifier keys (Ctrl, Alt, Shift, Meta) and automatic cleanup on unmount.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { useEffect, useCallback, useRef } from 'react';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Key combination configuration
|
|
13
|
+
* @interface KeybindingConfig
|
|
14
|
+
*/
|
|
15
|
+
export interface KeybindingConfig {
|
|
16
|
+
/** The main key (e.g., 'c', 'Enter', 'Escape') */
|
|
17
|
+
readonly key: string;
|
|
18
|
+
/** Require Ctrl key to be pressed */
|
|
19
|
+
readonly ctrl?: boolean;
|
|
20
|
+
/** Require Alt/Option key to be pressed */
|
|
21
|
+
readonly alt?: boolean;
|
|
22
|
+
/** Require Shift key to be pressed */
|
|
23
|
+
readonly shift?: boolean;
|
|
24
|
+
/** Require Meta/Command key to be pressed */
|
|
25
|
+
readonly meta?: boolean;
|
|
26
|
+
/** Prevent default browser behavior */
|
|
27
|
+
readonly preventDefault?: boolean;
|
|
28
|
+
/** Stop event propagation */
|
|
29
|
+
readonly stopPropagation?: boolean;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Mutable version for internal parsing
|
|
34
|
+
* @interface MutableKeybindingConfig
|
|
35
|
+
*/
|
|
36
|
+
interface MutableKeybindingConfig {
|
|
37
|
+
key: string;
|
|
38
|
+
ctrl?: boolean;
|
|
39
|
+
alt?: boolean;
|
|
40
|
+
shift?: boolean;
|
|
41
|
+
meta?: boolean;
|
|
42
|
+
preventDefault?: boolean;
|
|
43
|
+
stopPropagation?: boolean;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Normalized key combination string for comparison
|
|
48
|
+
* @param {KeybindingConfig} config - Keybinding configuration
|
|
49
|
+
* @returns {string} Normalized key combination string
|
|
50
|
+
*/
|
|
51
|
+
function normalizeKeyCombo(config: KeybindingConfig): string {
|
|
52
|
+
const parts: string[] = [];
|
|
53
|
+
if (config.ctrl) parts.push('ctrl');
|
|
54
|
+
if (config.alt) parts.push('alt');
|
|
55
|
+
if (config.shift) parts.push('shift');
|
|
56
|
+
if (config.meta) parts.push('meta');
|
|
57
|
+
parts.push(config.key.toLowerCase());
|
|
58
|
+
return parts.join('+');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Parses a keybinding string into a config object
|
|
63
|
+
*
|
|
64
|
+
* @param {string} keybinding - Keybinding string (e.g., "Ctrl+C", "Escape", "Ctrl+Shift+A")
|
|
65
|
+
* @returns {KeybindingConfig} Parsed keybinding configuration
|
|
66
|
+
* @example
|
|
67
|
+
* ```typescript
|
|
68
|
+
* parseKeybinding("Ctrl+C"); // { key: 'c', ctrl: true }
|
|
69
|
+
* parseKeybinding("Escape"); // { key: 'escape' }
|
|
70
|
+
* parseKeybinding("Ctrl+Shift+A"); // { key: 'a', ctrl: true, shift: true }
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export function parseKeybinding(keybinding: string): KeybindingConfig {
|
|
74
|
+
const parts = keybinding.split('+').map((p) => p.trim().toLowerCase());
|
|
75
|
+
|
|
76
|
+
const config: MutableKeybindingConfig = {
|
|
77
|
+
key: '',
|
|
78
|
+
ctrl: false,
|
|
79
|
+
alt: false,
|
|
80
|
+
shift: false,
|
|
81
|
+
meta: false,
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
for (const part of parts) {
|
|
85
|
+
switch (part) {
|
|
86
|
+
case 'ctrl':
|
|
87
|
+
case 'control':
|
|
88
|
+
config.ctrl = true;
|
|
89
|
+
break;
|
|
90
|
+
case 'alt':
|
|
91
|
+
case 'option':
|
|
92
|
+
config.alt = true;
|
|
93
|
+
break;
|
|
94
|
+
case 'shift':
|
|
95
|
+
config.shift = true;
|
|
96
|
+
break;
|
|
97
|
+
case 'meta':
|
|
98
|
+
case 'cmd':
|
|
99
|
+
case 'command':
|
|
100
|
+
case 'win':
|
|
101
|
+
case 'windows':
|
|
102
|
+
config.meta = true;
|
|
103
|
+
break;
|
|
104
|
+
default:
|
|
105
|
+
config.key = part;
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return config;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Key event handler type
|
|
115
|
+
* @typedef {Function} KeyHandler
|
|
116
|
+
*/
|
|
117
|
+
export type KeyHandler = (event: KeyboardEvent) => void | boolean;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* React hook for registering keyboard shortcuts
|
|
121
|
+
*
|
|
122
|
+
* Registers a keyboard shortcut that triggers the provided handler when pressed.
|
|
123
|
+
* Automatically cleans up the event listener when the component unmounts or
|
|
124
|
+
* when the keybinding changes.
|
|
125
|
+
*
|
|
126
|
+
* @param {string | KeybindingConfig} key - Key combination (e.g., "Ctrl+C") or config object
|
|
127
|
+
* @param {KeyHandler} handler - Function to call when keybinding is triggered
|
|
128
|
+
* @param {boolean} [enabled=true] - Whether the keybinding is active
|
|
129
|
+
* @example
|
|
130
|
+
* ```typescript
|
|
131
|
+
* // Using string keybinding
|
|
132
|
+
* useKeybinding('Ctrl+C', () => {
|
|
133
|
+
* console.log('Copy!');
|
|
134
|
+
* });
|
|
135
|
+
*
|
|
136
|
+
* // Using config object
|
|
137
|
+
* useKeybinding({ key: 'k', ctrl: true }, (e) => {
|
|
138
|
+
* e.preventDefault();
|
|
139
|
+
* console.log('Ctrl+K pressed');
|
|
140
|
+
* });
|
|
141
|
+
*
|
|
142
|
+
* // With conditional enabling
|
|
143
|
+
* useKeybinding('Escape', handleClose, isModalOpen);
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
export function useKeybinding(
|
|
147
|
+
key: string | KeybindingConfig,
|
|
148
|
+
handler: KeyHandler,
|
|
149
|
+
enabled: boolean = true
|
|
150
|
+
): void {
|
|
151
|
+
const config = typeof key === 'string' ? parseKeybinding(key) : key;
|
|
152
|
+
const expectedCombo = normalizeKeyCombo(config);
|
|
153
|
+
const handlerRef = useRef<KeyHandler>(handler);
|
|
154
|
+
|
|
155
|
+
// Keep handler reference up to date without re-registering
|
|
156
|
+
useEffect(() => {
|
|
157
|
+
handlerRef.current = handler;
|
|
158
|
+
}, [handler]);
|
|
159
|
+
|
|
160
|
+
const handleKeyDown = useCallback(
|
|
161
|
+
(event: KeyboardEvent) => {
|
|
162
|
+
// Check if this key event matches our expected combination
|
|
163
|
+
const actualCombo = normalizeKeyCombo({
|
|
164
|
+
key: event.key,
|
|
165
|
+
ctrl: event.ctrlKey,
|
|
166
|
+
alt: event.altKey,
|
|
167
|
+
shift: event.shiftKey,
|
|
168
|
+
meta: event.metaKey,
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
if (actualCombo === expectedCombo) {
|
|
172
|
+
if (config.preventDefault) {
|
|
173
|
+
event.preventDefault();
|
|
174
|
+
}
|
|
175
|
+
if (config.stopPropagation) {
|
|
176
|
+
event.stopPropagation();
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const result = handlerRef.current(event);
|
|
180
|
+
// Allow handler to prevent default by returning false
|
|
181
|
+
if (result === false) {
|
|
182
|
+
event.preventDefault();
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
[config, expectedCombo]
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
useEffect(() => {
|
|
190
|
+
if (!enabled || typeof window === 'undefined') {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
window.addEventListener('keydown', handleKeyDown);
|
|
195
|
+
|
|
196
|
+
return () => {
|
|
197
|
+
window.removeEventListener('keydown', handleKeyDown);
|
|
198
|
+
};
|
|
199
|
+
}, [enabled, handleKeyDown]);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Hook for registering multiple keybindings at once
|
|
204
|
+
*
|
|
205
|
+
* @param {Array<[string | KeybindingConfig, KeyHandler]>} bindings - Array of [keybinding, handler] tuples
|
|
206
|
+
* @param {boolean} [enabled=true] - Whether all keybindings are active
|
|
207
|
+
* @example
|
|
208
|
+
* ```typescript
|
|
209
|
+
* useKeybindings([
|
|
210
|
+
* ['Ctrl+C', handleCopy],
|
|
211
|
+
* ['Ctrl+V', handlePaste],
|
|
212
|
+
* ['Escape', handleClose],
|
|
213
|
+
* ]);
|
|
214
|
+
* ```
|
|
215
|
+
*/
|
|
216
|
+
export function useKeybindings(
|
|
217
|
+
bindings: Array<[string | KeybindingConfig, KeyHandler]>,
|
|
218
|
+
enabled: boolean = true
|
|
219
|
+
): void {
|
|
220
|
+
bindings.forEach(([key, handler]) => {
|
|
221
|
+
useKeybinding(key, handler, enabled);
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// Default export
|
|
226
|
+
export default useKeybinding;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Terminal size hook for gizzi-code integration
|
|
3
|
+
* @module hooks/useTerminalSize
|
|
4
|
+
*
|
|
5
|
+
* Provides a React hook to track terminal dimensions with resize event handling.
|
|
6
|
+
* Returns the current terminal width and height, defaulting to standard terminal
|
|
7
|
+
* dimensions when not in a browser environment.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Terminal size state interface
|
|
11
|
+
* @interface TerminalSize
|
|
12
|
+
*/
|
|
13
|
+
export interface TerminalSize {
|
|
14
|
+
/** Current terminal width in columns */
|
|
15
|
+
readonly width: number;
|
|
16
|
+
/** Current terminal height in rows */
|
|
17
|
+
readonly height: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* React hook for tracking terminal size
|
|
21
|
+
*
|
|
22
|
+
* Returns the current terminal dimensions and automatically updates
|
|
23
|
+
* when the window is resized. Uses debouncing to prevent excessive
|
|
24
|
+
* re-renders during resize operations.
|
|
25
|
+
*
|
|
26
|
+
* @returns {TerminalSize} Current terminal width and height
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* function MyComponent() {
|
|
30
|
+
* const { width, height } = useTerminalSize();
|
|
31
|
+
*
|
|
32
|
+
* return (
|
|
33
|
+
* <div>
|
|
34
|
+
* Terminal: {width}×{height}
|
|
35
|
+
* </div>
|
|
36
|
+
* );
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare function useTerminalSize(): TerminalSize;
|
|
41
|
+
export default useTerminalSize;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Terminal size hook for gizzi-code integration
|
|
3
|
+
* @module hooks/useTerminalSize
|
|
4
|
+
*
|
|
5
|
+
* Provides a React hook to track terminal dimensions with resize event handling.
|
|
6
|
+
* Returns the current terminal width and height, defaulting to standard terminal
|
|
7
|
+
* dimensions when not in a browser environment.
|
|
8
|
+
*/
|
|
9
|
+
import { useState, useEffect, useCallback } from 'react';
|
|
10
|
+
/**
|
|
11
|
+
* Default terminal dimensions (80x24 is standard terminal size)
|
|
12
|
+
* @constant {TerminalSize}
|
|
13
|
+
*/
|
|
14
|
+
const DEFAULT_TERMINAL_SIZE = {
|
|
15
|
+
width: 80,
|
|
16
|
+
height: 24,
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Gets the current terminal size from the window object
|
|
20
|
+
* Falls back to default dimensions if window is not available
|
|
21
|
+
*
|
|
22
|
+
* @returns {TerminalSize} Current terminal dimensions
|
|
23
|
+
*/
|
|
24
|
+
function getTerminalSize() {
|
|
25
|
+
if (typeof window === 'undefined') {
|
|
26
|
+
return DEFAULT_TERMINAL_SIZE;
|
|
27
|
+
}
|
|
28
|
+
// Estimate columns/rows based on window size and average character dimensions
|
|
29
|
+
// This is an approximation - actual terminal emulators may vary
|
|
30
|
+
const avgCharWidth = 8; // pixels per character (approximate)
|
|
31
|
+
const avgLineHeight = 16; // pixels per line (approximate)
|
|
32
|
+
const width = Math.max(20, Math.floor(window.innerWidth / avgCharWidth));
|
|
33
|
+
const height = Math.max(5, Math.floor(window.innerHeight / avgLineHeight));
|
|
34
|
+
return { width, height };
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* React hook for tracking terminal size
|
|
38
|
+
*
|
|
39
|
+
* Returns the current terminal dimensions and automatically updates
|
|
40
|
+
* when the window is resized. Uses debouncing to prevent excessive
|
|
41
|
+
* re-renders during resize operations.
|
|
42
|
+
*
|
|
43
|
+
* @returns {TerminalSize} Current terminal width and height
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* function MyComponent() {
|
|
47
|
+
* const { width, height } = useTerminalSize();
|
|
48
|
+
*
|
|
49
|
+
* return (
|
|
50
|
+
* <div>
|
|
51
|
+
* Terminal: {width}×{height}
|
|
52
|
+
* </div>
|
|
53
|
+
* );
|
|
54
|
+
* }
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export function useTerminalSize() {
|
|
58
|
+
const [size, setSize] = useState(getTerminalSize);
|
|
59
|
+
const handleResize = useCallback(() => {
|
|
60
|
+
setSize(getTerminalSize());
|
|
61
|
+
}, []);
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
// Check if window is available (SSR safety)
|
|
64
|
+
if (typeof window === 'undefined') {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
// Debounced resize handler
|
|
68
|
+
let resizeTimeout = null;
|
|
69
|
+
const debouncedHandleResize = () => {
|
|
70
|
+
if (resizeTimeout) {
|
|
71
|
+
clearTimeout(resizeTimeout);
|
|
72
|
+
}
|
|
73
|
+
resizeTimeout = setTimeout(handleResize, 100);
|
|
74
|
+
};
|
|
75
|
+
// Set initial size
|
|
76
|
+
handleResize();
|
|
77
|
+
// Add resize listener
|
|
78
|
+
window.addEventListener('resize', debouncedHandleResize);
|
|
79
|
+
// Cleanup
|
|
80
|
+
return () => {
|
|
81
|
+
window.removeEventListener('resize', debouncedHandleResize);
|
|
82
|
+
if (resizeTimeout) {
|
|
83
|
+
clearTimeout(resizeTimeout);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}, [handleResize]);
|
|
87
|
+
return size;
|
|
88
|
+
}
|
|
89
|
+
// Default export for convenient importing
|
|
90
|
+
export default useTerminalSize;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Terminal size hook for gizzi-code integration
|
|
3
|
+
* @module hooks/useTerminalSize
|
|
4
|
+
*
|
|
5
|
+
* Provides a React hook to track terminal dimensions with resize event handling.
|
|
6
|
+
* Returns the current terminal width and height, defaulting to standard terminal
|
|
7
|
+
* dimensions when not in a browser environment.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { useState, useEffect, useCallback } from 'react';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Terminal size state interface
|
|
14
|
+
* @interface TerminalSize
|
|
15
|
+
*/
|
|
16
|
+
export interface TerminalSize {
|
|
17
|
+
/** Current terminal width in columns */
|
|
18
|
+
readonly width: number;
|
|
19
|
+
/** Current terminal height in rows */
|
|
20
|
+
readonly height: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Default terminal dimensions (80x24 is standard terminal size)
|
|
25
|
+
* @constant {TerminalSize}
|
|
26
|
+
*/
|
|
27
|
+
const DEFAULT_TERMINAL_SIZE: TerminalSize = {
|
|
28
|
+
width: 80,
|
|
29
|
+
height: 24,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Gets the current terminal size from the window object
|
|
34
|
+
* Falls back to default dimensions if window is not available
|
|
35
|
+
*
|
|
36
|
+
* @returns {TerminalSize} Current terminal dimensions
|
|
37
|
+
*/
|
|
38
|
+
function getTerminalSize(): TerminalSize {
|
|
39
|
+
if (typeof window === 'undefined') {
|
|
40
|
+
return DEFAULT_TERMINAL_SIZE;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Estimate columns/rows based on window size and average character dimensions
|
|
44
|
+
// This is an approximation - actual terminal emulators may vary
|
|
45
|
+
const avgCharWidth = 8; // pixels per character (approximate)
|
|
46
|
+
const avgLineHeight = 16; // pixels per line (approximate)
|
|
47
|
+
|
|
48
|
+
const width = Math.max(20, Math.floor(window.innerWidth / avgCharWidth));
|
|
49
|
+
const height = Math.max(5, Math.floor(window.innerHeight / avgLineHeight));
|
|
50
|
+
|
|
51
|
+
return { width, height };
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* React hook for tracking terminal size
|
|
56
|
+
*
|
|
57
|
+
* Returns the current terminal dimensions and automatically updates
|
|
58
|
+
* when the window is resized. Uses debouncing to prevent excessive
|
|
59
|
+
* re-renders during resize operations.
|
|
60
|
+
*
|
|
61
|
+
* @returns {TerminalSize} Current terminal width and height
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* function MyComponent() {
|
|
65
|
+
* const { width, height } = useTerminalSize();
|
|
66
|
+
*
|
|
67
|
+
* return (
|
|
68
|
+
* <div>
|
|
69
|
+
* Terminal: {width}×{height}
|
|
70
|
+
* </div>
|
|
71
|
+
* );
|
|
72
|
+
* }
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
export function useTerminalSize(): TerminalSize {
|
|
76
|
+
const [size, setSize] = useState<TerminalSize>(getTerminalSize);
|
|
77
|
+
|
|
78
|
+
const handleResize = useCallback(() => {
|
|
79
|
+
setSize(getTerminalSize());
|
|
80
|
+
}, []);
|
|
81
|
+
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
// Check if window is available (SSR safety)
|
|
84
|
+
if (typeof window === 'undefined') {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Debounced resize handler
|
|
89
|
+
let resizeTimeout: ReturnType<typeof setTimeout> | null = null;
|
|
90
|
+
|
|
91
|
+
const debouncedHandleResize = (): void => {
|
|
92
|
+
if (resizeTimeout) {
|
|
93
|
+
clearTimeout(resizeTimeout);
|
|
94
|
+
}
|
|
95
|
+
resizeTimeout = setTimeout(handleResize, 100);
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
// Set initial size
|
|
99
|
+
handleResize();
|
|
100
|
+
|
|
101
|
+
// Add resize listener
|
|
102
|
+
window.addEventListener('resize', debouncedHandleResize);
|
|
103
|
+
|
|
104
|
+
// Cleanup
|
|
105
|
+
return () => {
|
|
106
|
+
window.removeEventListener('resize', debouncedHandleResize);
|
|
107
|
+
if (resizeTimeout) {
|
|
108
|
+
clearTimeout(resizeTimeout);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
}, [handleResize]);
|
|
112
|
+
|
|
113
|
+
return size;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Default export for convenient importing
|
|
117
|
+
export default useTerminalSize;
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gizzi Code - Main Entry Point
|
|
3
|
+
*
|
|
4
|
+
* Workspace-aware AI assistant framework
|
|
5
|
+
*/
|
|
6
|
+
export { AppStateStore, getGlobalStore, setGlobalStore, useAppStateStore, useAppStateSelector, useAppStateActions, } from './state/AppStateStore';
|
|
7
|
+
export type { UserPreferences, UserSession, ConnectionStatus, AppState, AppError, } from './state/AppStateStore';
|
|
8
|
+
export { WorkspaceStateStore, getWorkspaceStore, setWorkspaceStore, } from './state/WorkspaceStateStore';
|
|
9
|
+
export type { WorkspaceFile, TrustTier, ScheduledTask, ToolDefinition, ContextPack, WorkspaceSession, MessageRole, } from './workspace/types';
|
|
10
|
+
export { loadWorkspace, executeStartupTasks, enhanceSessionWithWorkspace, } from './workspace/loader';
|
|
11
|
+
export type { FileSystem, LoadWorkspaceOptions, LoadedWorkspace, } from './workspace/loader';
|
|
12
|
+
export { buildContextPack, buildSystemPrompt, parseSoulMd, parseHeartbeatMd, classifyFile, getStartupTasks, requiresPermission, shouldRefreshContext, } from './context/pack-builder';
|
|
13
|
+
export type { BuildContextPackOptions } from './context/pack-builder';
|
|
14
|
+
export type { Message, MessageRole, UserMessage, AssistantMessage, SystemMessage, TypedMessage, MessageThread, Attachment, AttachmentMimeType, MessageStatus, } from './types/message';
|
|
15
|
+
export { MESSAGE_ROLES, isUserMessage, isAssistantMessage, isSystemMessage, isMessageRole, createMessage, } from './types/message';
|
|
16
|
+
export { useTerminalSize, } from './hooks/useTerminalSize';
|
|
17
|
+
export { useExitOnCtrlCD, } from './hooks/useExitOnCtrlCD';
|
|
18
|
+
export { useKeybinding, } from './hooks/useKeybinding';
|
|
19
|
+
export { TaskScheduler, taskScheduler, } from './scheduler/TaskScheduler';
|
|
20
|
+
export type { TaskFrequency, ScheduledTask, SchedulerJob, } from './scheduler/TaskScheduler';
|
|
21
|
+
export { WorkspaceWatcher, getWorkspaceWatcher, stopAllWatchers, workspaceWatcher, } from './watcher/WorkspaceWatcher';
|
|
22
|
+
export type { FileChange, WatcherOptions, } from './watcher/WorkspaceWatcher';
|
|
23
|
+
export declare const VERSION = "1.0.1";
|
package/src/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gizzi Code - Main Entry Point
|
|
3
|
+
*
|
|
4
|
+
* Workspace-aware AI assistant framework
|
|
5
|
+
*/
|
|
6
|
+
// Core State Management
|
|
7
|
+
export { AppStateStore, getGlobalStore, setGlobalStore, useAppStateStore, useAppStateSelector, useAppStateActions, } from './state/AppStateStore';
|
|
8
|
+
// Workspace State (NEW)
|
|
9
|
+
export { WorkspaceStateStore, getWorkspaceStore, setWorkspaceStore, } from './state/WorkspaceStateStore';
|
|
10
|
+
// Workspace Loader (NEW)
|
|
11
|
+
export { loadWorkspace, executeStartupTasks, enhanceSessionWithWorkspace, } from './workspace/loader';
|
|
12
|
+
// Context Pack Builder (NEW)
|
|
13
|
+
export { buildContextPack, buildSystemPrompt, parseSoulMd, parseHeartbeatMd, classifyFile, getStartupTasks, requiresPermission, shouldRefreshContext, } from './context/pack-builder';
|
|
14
|
+
export { MESSAGE_ROLES, isUserMessage, isAssistantMessage, isSystemMessage, isMessageRole, createMessage, } from './types/message';
|
|
15
|
+
// React Hooks
|
|
16
|
+
export { useTerminalSize, } from './hooks/useTerminalSize';
|
|
17
|
+
export { useExitOnCtrlCD, } from './hooks/useExitOnCtrlCD';
|
|
18
|
+
export { useKeybinding, } from './hooks/useKeybinding';
|
|
19
|
+
// Task Scheduler (NEW)
|
|
20
|
+
export { TaskScheduler, taskScheduler, } from './scheduler/TaskScheduler';
|
|
21
|
+
// Workspace Watcher (NEW)
|
|
22
|
+
export { WorkspaceWatcher, getWorkspaceWatcher, stopAllWatchers, workspaceWatcher, } from './watcher/WorkspaceWatcher';
|
|
23
|
+
// Version
|
|
24
|
+
export const VERSION = '1.0.1';
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gizzi Code - Main Entry Point
|
|
3
|
+
*
|
|
4
|
+
* Workspace-aware AI assistant framework
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// Core State Management
|
|
8
|
+
export {
|
|
9
|
+
AppStateStore,
|
|
10
|
+
getGlobalStore,
|
|
11
|
+
setGlobalStore,
|
|
12
|
+
useAppStateStore,
|
|
13
|
+
useAppStateSelector,
|
|
14
|
+
useAppStateActions,
|
|
15
|
+
} from './state/AppStateStore';
|
|
16
|
+
|
|
17
|
+
export type {
|
|
18
|
+
UserPreferences,
|
|
19
|
+
UserSession,
|
|
20
|
+
ConnectionStatus,
|
|
21
|
+
AppState,
|
|
22
|
+
AppError,
|
|
23
|
+
} from './state/AppStateStore';
|
|
24
|
+
|
|
25
|
+
// Workspace State (NEW)
|
|
26
|
+
export {
|
|
27
|
+
WorkspaceStateStore,
|
|
28
|
+
getWorkspaceStore,
|
|
29
|
+
setWorkspaceStore,
|
|
30
|
+
} from './state/WorkspaceStateStore';
|
|
31
|
+
|
|
32
|
+
// Workspace Types (NEW)
|
|
33
|
+
export type {
|
|
34
|
+
WorkspaceFile,
|
|
35
|
+
TrustTier,
|
|
36
|
+
ScheduledTask,
|
|
37
|
+
ToolDefinition,
|
|
38
|
+
ContextPack,
|
|
39
|
+
WorkspaceSession,
|
|
40
|
+
MessageRole,
|
|
41
|
+
} from './workspace/types';
|
|
42
|
+
|
|
43
|
+
// Workspace Loader (NEW)
|
|
44
|
+
export {
|
|
45
|
+
loadWorkspace,
|
|
46
|
+
executeStartupTasks,
|
|
47
|
+
enhanceSessionWithWorkspace,
|
|
48
|
+
} from './workspace/loader';
|
|
49
|
+
|
|
50
|
+
export type {
|
|
51
|
+
FileSystem,
|
|
52
|
+
LoadWorkspaceOptions,
|
|
53
|
+
LoadedWorkspace,
|
|
54
|
+
} from './workspace/loader';
|
|
55
|
+
|
|
56
|
+
// Context Pack Builder (NEW)
|
|
57
|
+
export {
|
|
58
|
+
buildContextPack,
|
|
59
|
+
buildSystemPrompt,
|
|
60
|
+
parseSoulMd,
|
|
61
|
+
parseHeartbeatMd,
|
|
62
|
+
classifyFile,
|
|
63
|
+
getStartupTasks,
|
|
64
|
+
requiresPermission,
|
|
65
|
+
shouldRefreshContext,
|
|
66
|
+
} from './context/pack-builder';
|
|
67
|
+
|
|
68
|
+
export type { BuildContextPackOptions } from './context/pack-builder';
|
|
69
|
+
|
|
70
|
+
// Message Types
|
|
71
|
+
export type {
|
|
72
|
+
Message,
|
|
73
|
+
MessageRole,
|
|
74
|
+
UserMessage,
|
|
75
|
+
AssistantMessage,
|
|
76
|
+
SystemMessage,
|
|
77
|
+
TypedMessage,
|
|
78
|
+
MessageThread,
|
|
79
|
+
Attachment,
|
|
80
|
+
AttachmentMimeType,
|
|
81
|
+
MessageStatus,
|
|
82
|
+
} from './types/message';
|
|
83
|
+
|
|
84
|
+
export {
|
|
85
|
+
MESSAGE_ROLES,
|
|
86
|
+
isUserMessage,
|
|
87
|
+
isAssistantMessage,
|
|
88
|
+
isSystemMessage,
|
|
89
|
+
isMessageRole,
|
|
90
|
+
createMessage,
|
|
91
|
+
} from './types/message';
|
|
92
|
+
|
|
93
|
+
// React Hooks
|
|
94
|
+
export {
|
|
95
|
+
useTerminalSize,
|
|
96
|
+
} from './hooks/useTerminalSize';
|
|
97
|
+
|
|
98
|
+
export {
|
|
99
|
+
useExitOnCtrlCD,
|
|
100
|
+
} from './hooks/useExitOnCtrlCD';
|
|
101
|
+
|
|
102
|
+
export {
|
|
103
|
+
useKeybinding,
|
|
104
|
+
} from './hooks/useKeybinding';
|
|
105
|
+
|
|
106
|
+
// Task Scheduler (NEW)
|
|
107
|
+
export {
|
|
108
|
+
TaskScheduler,
|
|
109
|
+
taskScheduler,
|
|
110
|
+
} from './scheduler/TaskScheduler';
|
|
111
|
+
|
|
112
|
+
export type {
|
|
113
|
+
TaskFrequency,
|
|
114
|
+
ScheduledTask,
|
|
115
|
+
SchedulerJob,
|
|
116
|
+
} from './scheduler/TaskScheduler';
|
|
117
|
+
|
|
118
|
+
// Workspace Watcher (NEW)
|
|
119
|
+
export {
|
|
120
|
+
WorkspaceWatcher,
|
|
121
|
+
getWorkspaceWatcher,
|
|
122
|
+
stopAllWatchers,
|
|
123
|
+
workspaceWatcher,
|
|
124
|
+
} from './watcher/WorkspaceWatcher';
|
|
125
|
+
|
|
126
|
+
export type {
|
|
127
|
+
FileChange,
|
|
128
|
+
WatcherOptions,
|
|
129
|
+
} from './watcher/WorkspaceWatcher';
|
|
130
|
+
|
|
131
|
+
// Version
|
|
132
|
+
export const VERSION = '1.0.1';
|