gemkit-cli 0.2.2 → 0.3.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/README.md +152 -5
- package/dist/commands/agent/index.d.ts +9 -0
- package/dist/commands/agent/index.js +1329 -0
- package/dist/commands/cache/index.d.ts +5 -0
- package/dist/commands/cache/index.js +43 -0
- package/dist/commands/catalog/index.d.ts +2 -0
- package/dist/commands/catalog/index.js +57 -0
- package/dist/commands/config/index.d.ts +7 -0
- package/dist/commands/config/index.js +122 -0
- package/dist/commands/convert/index.d.ts +8 -0
- package/dist/commands/convert/index.js +391 -0
- package/dist/commands/doctor/index.d.ts +2 -0
- package/dist/commands/doctor/index.js +243 -0
- package/dist/commands/extension/index.d.ts +5 -0
- package/dist/commands/extension/index.js +52 -0
- package/dist/commands/index.d.ts +5 -0
- package/dist/commands/index.js +37 -0
- package/dist/commands/init/index.d.ts +6 -0
- package/dist/commands/init/index.js +345 -0
- package/dist/commands/new/index.d.ts +5 -0
- package/dist/commands/new/index.js +49 -0
- package/dist/commands/office/index.d.ts +5 -0
- package/dist/commands/office/index.js +283 -0
- package/dist/commands/paste/index.d.ts +10 -0
- package/dist/commands/paste/index.js +533 -0
- package/dist/commands/plan/index.d.ts +8 -0
- package/dist/commands/plan/index.js +247 -0
- package/dist/commands/session/index.d.ts +8 -0
- package/dist/commands/session/index.js +289 -0
- package/dist/commands/tokens/index.d.ts +6 -0
- package/dist/commands/tokens/index.js +148 -0
- package/dist/commands/update/index.d.ts +26 -0
- package/dist/commands/update/index.js +199 -0
- package/dist/commands/versions/index.d.ts +5 -0
- package/dist/commands/versions/index.js +39 -0
- package/dist/domains/agent/index.d.ts +8 -0
- package/dist/domains/agent/index.js +8 -0
- package/dist/domains/agent/mappings.d.ts +32 -0
- package/dist/domains/agent/mappings.js +164 -0
- package/dist/domains/agent/profile.d.ts +26 -0
- package/dist/domains/agent/profile.js +225 -0
- package/dist/domains/agent/pty-context.d.ts +11 -0
- package/dist/domains/agent/pty-context.js +83 -0
- package/dist/domains/agent/pty-providers.d.ts +18 -0
- package/dist/domains/agent/pty-providers.js +66 -0
- package/dist/domains/agent/pty-session.d.ts +33 -0
- package/dist/domains/agent/pty-session.js +82 -0
- package/dist/domains/agent/pty-types.d.ts +127 -0
- package/dist/domains/agent/pty-types.js +4 -0
- package/dist/domains/agent/search.d.ts +45 -0
- package/dist/domains/agent/search.js +614 -0
- package/dist/domains/agent/types.d.ts +78 -0
- package/dist/domains/agent/types.js +5 -0
- package/dist/domains/agent-office/documents-scanner.d.ts +9 -0
- package/dist/domains/agent-office/documents-scanner.js +143 -0
- package/dist/domains/agent-office/event-emitter.d.ts +43 -0
- package/dist/domains/agent-office/event-emitter.js +86 -0
- package/dist/domains/agent-office/file-watcher.d.ts +40 -0
- package/dist/domains/agent-office/file-watcher.js +173 -0
- package/dist/domains/agent-office/icons.d.ts +11 -0
- package/dist/domains/agent-office/icons.js +36 -0
- package/dist/domains/agent-office/index.d.ts +12 -0
- package/dist/domains/agent-office/index.js +20 -0
- package/dist/domains/agent-office/renderer/web/assets.d.ts +11 -0
- package/dist/domains/agent-office/renderer/web/assets.js +3419 -0
- package/dist/domains/agent-office/renderer/web/server.d.ts +42 -0
- package/dist/domains/agent-office/renderer/web/server.js +228 -0
- package/dist/domains/agent-office/renderer/web.d.ts +30 -0
- package/dist/domains/agent-office/renderer/web.js +111 -0
- package/dist/domains/agent-office/session-bridge.d.ts +23 -0
- package/dist/domains/agent-office/session-bridge.js +171 -0
- package/dist/domains/agent-office/state-machine.d.ts +5 -0
- package/dist/domains/agent-office/state-machine.js +82 -0
- package/dist/domains/agent-office/types.d.ts +91 -0
- package/dist/domains/agent-office/types.js +4 -0
- package/dist/domains/cache/index.d.ts +1 -0
- package/dist/domains/cache/index.js +1 -0
- package/dist/domains/cache/manager.d.ts +22 -0
- package/dist/domains/cache/manager.js +84 -0
- package/dist/domains/config/index.d.ts +5 -0
- package/dist/domains/config/index.js +5 -0
- package/dist/domains/config/manager.d.ts +24 -0
- package/dist/domains/config/manager.js +85 -0
- package/dist/domains/config/schema.d.ts +17 -0
- package/dist/domains/config/schema.js +96 -0
- package/dist/domains/convert/converter.d.ts +78 -0
- package/dist/domains/convert/converter.js +471 -0
- package/dist/domains/convert/index.d.ts +5 -0
- package/dist/domains/convert/index.js +5 -0
- package/dist/domains/convert/types.d.ts +88 -0
- package/dist/domains/convert/types.js +18 -0
- package/dist/domains/github/download.d.ts +12 -0
- package/dist/domains/github/download.js +51 -0
- package/dist/domains/github/index.d.ts +2 -0
- package/dist/domains/github/index.js +2 -0
- package/dist/domains/github/releases.d.ts +16 -0
- package/dist/domains/github/releases.js +68 -0
- package/dist/domains/installation/conflict.d.ts +13 -0
- package/dist/domains/installation/conflict.js +38 -0
- package/dist/domains/installation/file-sync.d.ts +16 -0
- package/dist/domains/installation/file-sync.js +77 -0
- package/dist/domains/installation/index.d.ts +3 -0
- package/dist/domains/installation/index.js +3 -0
- package/dist/domains/installation/metadata.d.ts +20 -0
- package/dist/domains/installation/metadata.js +52 -0
- package/dist/domains/plan/index.d.ts +2 -0
- package/dist/domains/plan/index.js +2 -0
- package/dist/domains/plan/resolver.d.ts +24 -0
- package/dist/domains/plan/resolver.js +164 -0
- package/dist/domains/plan/types.d.ts +13 -0
- package/dist/domains/plan/types.js +4 -0
- package/dist/domains/session/env.d.ts +51 -0
- package/dist/domains/session/env.js +118 -0
- package/dist/domains/session/index.d.ts +8 -0
- package/dist/domains/session/index.js +8 -0
- package/dist/domains/session/manager.d.ts +56 -0
- package/dist/domains/session/manager.js +205 -0
- package/dist/domains/session/paths.d.ts +6 -0
- package/dist/domains/session/paths.js +6 -0
- package/dist/domains/session/types.d.ts +121 -0
- package/dist/domains/session/types.js +5 -0
- package/dist/domains/session/writer.d.ts +82 -0
- package/dist/domains/session/writer.js +431 -0
- package/dist/domains/tokens/index.d.ts +5 -0
- package/dist/domains/tokens/index.js +5 -0
- package/dist/domains/tokens/pricing.d.ts +38 -0
- package/dist/domains/tokens/pricing.js +129 -0
- package/dist/domains/tokens/scanner.d.ts +42 -0
- package/dist/domains/tokens/scanner.js +168 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +86 -57
- package/dist/services/aipty.d.ts +76 -0
- package/dist/services/aipty.js +276 -0
- package/dist/services/archive.d.ts +22 -0
- package/dist/services/archive.js +53 -0
- package/dist/services/auto-update.d.ts +26 -0
- package/dist/services/auto-update.js +117 -0
- package/dist/services/hash.d.ts +36 -0
- package/dist/services/hash.js +63 -0
- package/dist/services/logger.d.ts +28 -0
- package/dist/services/logger.js +102 -0
- package/dist/services/music.d.ts +67 -0
- package/dist/services/music.js +290 -0
- package/dist/services/npm.d.ts +22 -0
- package/dist/services/npm.js +65 -0
- package/dist/services/pty-client.d.ts +66 -0
- package/dist/services/pty-client.js +154 -0
- package/dist/services/pty-server.d.ts +102 -0
- package/dist/services/pty-server.js +613 -0
- package/dist/types/index.d.ts +155 -0
- package/dist/types/index.js +4 -0
- package/dist/utils/colors.d.ts +43 -0
- package/dist/utils/colors.js +98 -0
- package/dist/utils/errors.d.ts +24 -0
- package/dist/utils/errors.js +56 -0
- package/dist/utils/paths.d.ts +46 -0
- package/dist/utils/paths.js +89 -0
- package/dist/utils/platform.d.ts +11 -0
- package/dist/utils/platform.js +31 -0
- package/package.json +55 -54
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core type definitions for GemKit CLI
|
|
3
|
+
*/
|
|
4
|
+
export interface GemKitConfig {
|
|
5
|
+
defaultScope: 'local' | 'global';
|
|
6
|
+
github: {
|
|
7
|
+
repo: string;
|
|
8
|
+
apiUrl: string;
|
|
9
|
+
};
|
|
10
|
+
cache: {
|
|
11
|
+
enabled: boolean;
|
|
12
|
+
ttl: number;
|
|
13
|
+
};
|
|
14
|
+
installation: {
|
|
15
|
+
excludePatterns: string[];
|
|
16
|
+
backupOnUpdate: boolean;
|
|
17
|
+
};
|
|
18
|
+
ui: {
|
|
19
|
+
colors: boolean;
|
|
20
|
+
spinner: boolean;
|
|
21
|
+
verbose: boolean;
|
|
22
|
+
};
|
|
23
|
+
paths: {
|
|
24
|
+
plans?: string;
|
|
25
|
+
agents?: string;
|
|
26
|
+
};
|
|
27
|
+
spawn: {
|
|
28
|
+
defaultModel: string;
|
|
29
|
+
music: boolean;
|
|
30
|
+
musicFile?: string;
|
|
31
|
+
};
|
|
32
|
+
office?: {
|
|
33
|
+
enabled: boolean;
|
|
34
|
+
mode: 'web' | 'terminal' | 'both';
|
|
35
|
+
port: number;
|
|
36
|
+
autoOpen: boolean;
|
|
37
|
+
sounds: boolean;
|
|
38
|
+
refreshRate: number;
|
|
39
|
+
};
|
|
40
|
+
update?: {
|
|
41
|
+
autoCheck: boolean;
|
|
42
|
+
checkInterval: number;
|
|
43
|
+
notifyOnly: boolean;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export interface GemKitMetadata {
|
|
47
|
+
name: string;
|
|
48
|
+
version: string;
|
|
49
|
+
installedAt: string;
|
|
50
|
+
scope: 'local' | 'global';
|
|
51
|
+
installedFiles: string[];
|
|
52
|
+
customizedFiles: Array<{
|
|
53
|
+
path: string;
|
|
54
|
+
hash: string;
|
|
55
|
+
}>;
|
|
56
|
+
}
|
|
57
|
+
export interface Release {
|
|
58
|
+
version: string;
|
|
59
|
+
tag: string;
|
|
60
|
+
publishedAt: string;
|
|
61
|
+
assets: ReleaseAsset[];
|
|
62
|
+
prerelease: boolean;
|
|
63
|
+
}
|
|
64
|
+
export interface ReleaseAsset {
|
|
65
|
+
name: string;
|
|
66
|
+
url: string;
|
|
67
|
+
size: number;
|
|
68
|
+
downloadUrl: string;
|
|
69
|
+
}
|
|
70
|
+
export interface GkSession {
|
|
71
|
+
gkSessionId: string;
|
|
72
|
+
geminiSessionId?: string;
|
|
73
|
+
gkProjectHash: string;
|
|
74
|
+
projectDir: string;
|
|
75
|
+
status: 'active' | 'completed' | 'failed';
|
|
76
|
+
startTime: string;
|
|
77
|
+
endTime?: string;
|
|
78
|
+
activePlan?: string;
|
|
79
|
+
agents: GkAgent[];
|
|
80
|
+
}
|
|
81
|
+
export interface GkAgent {
|
|
82
|
+
gkSessionId: string;
|
|
83
|
+
geminiSessionId?: string;
|
|
84
|
+
agentRole: string;
|
|
85
|
+
model: string;
|
|
86
|
+
prompt: string;
|
|
87
|
+
status: 'active' | 'completed' | 'failed';
|
|
88
|
+
startTime: string;
|
|
89
|
+
endTime?: string;
|
|
90
|
+
tokenUsage?: TokenUsage;
|
|
91
|
+
injected?: {
|
|
92
|
+
skills?: string[];
|
|
93
|
+
context?: string[];
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
export interface TokenUsage {
|
|
97
|
+
input: number;
|
|
98
|
+
output: number;
|
|
99
|
+
cached: number;
|
|
100
|
+
thoughts: number;
|
|
101
|
+
tool: number;
|
|
102
|
+
total: number;
|
|
103
|
+
}
|
|
104
|
+
export interface AgentProfile {
|
|
105
|
+
name: string;
|
|
106
|
+
description: string;
|
|
107
|
+
model: string;
|
|
108
|
+
skills?: string[];
|
|
109
|
+
content: string;
|
|
110
|
+
filePath: string;
|
|
111
|
+
}
|
|
112
|
+
export interface SpawnOptions {
|
|
113
|
+
prompt: string;
|
|
114
|
+
agent?: string;
|
|
115
|
+
skills?: string;
|
|
116
|
+
context?: string;
|
|
117
|
+
model?: string;
|
|
118
|
+
}
|
|
119
|
+
export interface SpawnResult {
|
|
120
|
+
success: boolean;
|
|
121
|
+
output?: string;
|
|
122
|
+
error?: string;
|
|
123
|
+
exitCode: number;
|
|
124
|
+
prompt?: string;
|
|
125
|
+
tokenUsage?: TokenUsage;
|
|
126
|
+
agentRole?: string;
|
|
127
|
+
}
|
|
128
|
+
export interface SearchResult {
|
|
129
|
+
agent: string;
|
|
130
|
+
skills: string[];
|
|
131
|
+
score: number;
|
|
132
|
+
description: string;
|
|
133
|
+
}
|
|
134
|
+
export interface Plan {
|
|
135
|
+
name: string;
|
|
136
|
+
path: string;
|
|
137
|
+
createdAt: string;
|
|
138
|
+
isActive: boolean;
|
|
139
|
+
}
|
|
140
|
+
export interface Extension {
|
|
141
|
+
name: string;
|
|
142
|
+
path: string;
|
|
143
|
+
skills: string[];
|
|
144
|
+
tools: ExtensionTool[];
|
|
145
|
+
}
|
|
146
|
+
export interface ExtensionTool {
|
|
147
|
+
name: string;
|
|
148
|
+
description: string;
|
|
149
|
+
command?: string;
|
|
150
|
+
}
|
|
151
|
+
export interface CommandContext {
|
|
152
|
+
cwd: string;
|
|
153
|
+
verbose: boolean;
|
|
154
|
+
json: boolean;
|
|
155
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Brand colors and styling for GemKit CLI
|
|
3
|
+
* Matches gemkit-cli theme
|
|
4
|
+
*/
|
|
5
|
+
import pc from 'picocolors';
|
|
6
|
+
export declare const brand: {
|
|
7
|
+
primary: (text: string) => string;
|
|
8
|
+
secondary: (text: string) => string;
|
|
9
|
+
accent: (text: string) => string;
|
|
10
|
+
geminiBlue: (text: string) => string;
|
|
11
|
+
geminiPurple: (text: string) => string;
|
|
12
|
+
success: (text: string) => string;
|
|
13
|
+
error: (text: string) => string;
|
|
14
|
+
warn: (text: string) => string;
|
|
15
|
+
info: (text: string) => string;
|
|
16
|
+
dim: (text: string) => string;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* UI helpers
|
|
20
|
+
*/
|
|
21
|
+
export declare const ui: {
|
|
22
|
+
line: (width?: number) => string;
|
|
23
|
+
doubleLine: (width?: number) => string;
|
|
24
|
+
statusIcon: (status: string) => string;
|
|
25
|
+
checkIcon: (passed: boolean, optional?: boolean) => string;
|
|
26
|
+
header: (text: string) => string;
|
|
27
|
+
section: (title: string, width?: number) => void;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Prints the GemKit CLI banner.
|
|
31
|
+
*/
|
|
32
|
+
export declare function printBanner(): void;
|
|
33
|
+
export declare const colors: {
|
|
34
|
+
success: (text: string) => string;
|
|
35
|
+
error: (text: string) => string;
|
|
36
|
+
warning: (text: string) => string;
|
|
37
|
+
info: (text: string) => string;
|
|
38
|
+
dim: (text: string) => string;
|
|
39
|
+
primary: (text: string) => string;
|
|
40
|
+
secondary: (text: string) => string;
|
|
41
|
+
bold: import("picocolors/types.js").Formatter;
|
|
42
|
+
};
|
|
43
|
+
export { pc };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Brand colors and styling for GemKit CLI
|
|
3
|
+
* Matches gemkit-cli theme
|
|
4
|
+
*/
|
|
5
|
+
import pc from 'picocolors';
|
|
6
|
+
/**
|
|
7
|
+
* Converts a hex color string to an ANSI escape sequence for 24-bit truecolor.
|
|
8
|
+
*/
|
|
9
|
+
const hexToAnsi = (hex) => {
|
|
10
|
+
const r = parseInt(hex.slice(1, 3), 16);
|
|
11
|
+
const g = parseInt(hex.slice(3, 5), 16);
|
|
12
|
+
const b = parseInt(hex.slice(5, 7), 16);
|
|
13
|
+
return `\x1b[38;2;${r};${g};${b}m`;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Wraps text in a 24-bit truecolor ANSI escape sequence.
|
|
17
|
+
*/
|
|
18
|
+
const wrap = (hex) => (text) => {
|
|
19
|
+
if (!pc.isColorSupported)
|
|
20
|
+
return text;
|
|
21
|
+
return `${hexToAnsi(hex)}${text}\x1b[39m`;
|
|
22
|
+
};
|
|
23
|
+
export const brand = {
|
|
24
|
+
// Brand colors
|
|
25
|
+
primary: wrap('#4f46e5'),
|
|
26
|
+
secondary: wrap('#9333ea'),
|
|
27
|
+
accent: wrap('#06b6d4'),
|
|
28
|
+
geminiBlue: wrap('#1a73e8'),
|
|
29
|
+
geminiPurple: wrap('#8e24aa'),
|
|
30
|
+
// Semantic colors
|
|
31
|
+
success: (text) => pc.green(text),
|
|
32
|
+
error: (text) => pc.red(text),
|
|
33
|
+
warn: (text) => pc.yellow(text),
|
|
34
|
+
info: (text) => pc.cyan(text),
|
|
35
|
+
dim: (text) => pc.dim(text),
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* UI helpers
|
|
39
|
+
*/
|
|
40
|
+
export const ui = {
|
|
41
|
+
// Horizontal lines
|
|
42
|
+
line: (width = 60) => '─'.repeat(width),
|
|
43
|
+
doubleLine: (width = 60) => '═'.repeat(width),
|
|
44
|
+
// Status icons
|
|
45
|
+
statusIcon: (status) => {
|
|
46
|
+
switch (status) {
|
|
47
|
+
case 'active': return brand.success('●');
|
|
48
|
+
case 'completed': return brand.dim('○');
|
|
49
|
+
case 'failed': return brand.error('✗');
|
|
50
|
+
default: return '?';
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
// Check icons
|
|
54
|
+
checkIcon: (passed, optional = false) => {
|
|
55
|
+
if (passed)
|
|
56
|
+
return brand.success('✓');
|
|
57
|
+
return optional ? brand.warn('○') : brand.error('✗');
|
|
58
|
+
},
|
|
59
|
+
// Header
|
|
60
|
+
header: (text) => pc.bold(brand.geminiPurple(text)),
|
|
61
|
+
// Section with lines
|
|
62
|
+
section: (title, width = 60) => {
|
|
63
|
+
console.log();
|
|
64
|
+
console.log('─'.repeat(width));
|
|
65
|
+
console.log(pc.bold(brand.geminiPurple(title)));
|
|
66
|
+
console.log('─'.repeat(width));
|
|
67
|
+
console.log();
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Prints the GemKit CLI banner.
|
|
72
|
+
*/
|
|
73
|
+
export function printBanner() {
|
|
74
|
+
console.log();
|
|
75
|
+
console.log(pc.bold(brand.geminiPurple(' ┌─────────────────────────────┐')));
|
|
76
|
+
console.log(pc.bold(brand.geminiPurple(' │')) +
|
|
77
|
+
' ' +
|
|
78
|
+
pc.bold(brand.primary('GK')) +
|
|
79
|
+
' ' +
|
|
80
|
+
pc.white('GemKit CLI MVP') +
|
|
81
|
+
' ' +
|
|
82
|
+
pc.bold(brand.geminiPurple('│')));
|
|
83
|
+
console.log(pc.bold(brand.geminiPurple(' └─────────────────────────────┘')));
|
|
84
|
+
console.log();
|
|
85
|
+
}
|
|
86
|
+
// Legacy compatibility - map old colors to new brand
|
|
87
|
+
export const colors = {
|
|
88
|
+
success: brand.success,
|
|
89
|
+
error: brand.error,
|
|
90
|
+
warning: brand.warn,
|
|
91
|
+
info: brand.info,
|
|
92
|
+
dim: brand.dim,
|
|
93
|
+
primary: brand.primary,
|
|
94
|
+
secondary: brand.secondary,
|
|
95
|
+
bold: pc.bold,
|
|
96
|
+
};
|
|
97
|
+
// Re-export picocolors
|
|
98
|
+
export { pc };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom error classes for GemKit CLI
|
|
3
|
+
*/
|
|
4
|
+
export declare class GemKitError extends Error {
|
|
5
|
+
code: string;
|
|
6
|
+
details?: Record<string, unknown> | undefined;
|
|
7
|
+
constructor(message: string, code?: string, details?: Record<string, unknown> | undefined);
|
|
8
|
+
}
|
|
9
|
+
export declare class ConfigError extends GemKitError {
|
|
10
|
+
constructor(message: string, details?: Record<string, unknown>);
|
|
11
|
+
}
|
|
12
|
+
export declare class InstallationError extends GemKitError {
|
|
13
|
+
constructor(message: string, details?: Record<string, unknown>);
|
|
14
|
+
}
|
|
15
|
+
export declare class SessionError extends GemKitError {
|
|
16
|
+
constructor(message: string, details?: Record<string, unknown>);
|
|
17
|
+
}
|
|
18
|
+
export declare class AgentError extends GemKitError {
|
|
19
|
+
constructor(message: string, details?: Record<string, unknown>);
|
|
20
|
+
}
|
|
21
|
+
export declare class GitHubError extends GemKitError {
|
|
22
|
+
constructor(message: string, details?: Record<string, unknown>);
|
|
23
|
+
}
|
|
24
|
+
export declare function formatErrorForDisplay(error: unknown): string;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom error classes for GemKit CLI
|
|
3
|
+
*/
|
|
4
|
+
export class GemKitError extends Error {
|
|
5
|
+
code;
|
|
6
|
+
details;
|
|
7
|
+
constructor(message, code = 'GEMKIT_ERROR', details) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.code = code;
|
|
10
|
+
this.details = details;
|
|
11
|
+
this.name = 'GemKitError';
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export class ConfigError extends GemKitError {
|
|
15
|
+
constructor(message, details) {
|
|
16
|
+
super(message, 'CONFIG_ERROR', details);
|
|
17
|
+
this.name = 'ConfigError';
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export class InstallationError extends GemKitError {
|
|
21
|
+
constructor(message, details) {
|
|
22
|
+
super(message, 'INSTALLATION_ERROR', details);
|
|
23
|
+
this.name = 'InstallationError';
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export class SessionError extends GemKitError {
|
|
27
|
+
constructor(message, details) {
|
|
28
|
+
super(message, 'SESSION_ERROR', details);
|
|
29
|
+
this.name = 'SessionError';
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export class AgentError extends GemKitError {
|
|
33
|
+
constructor(message, details) {
|
|
34
|
+
super(message, 'AGENT_ERROR', details);
|
|
35
|
+
this.name = 'AgentError';
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export class GitHubError extends GemKitError {
|
|
39
|
+
constructor(message, details) {
|
|
40
|
+
super(message, 'GITHUB_ERROR', details);
|
|
41
|
+
this.name = 'GitHubError';
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export function formatErrorForDisplay(error) {
|
|
45
|
+
if (error instanceof GemKitError) {
|
|
46
|
+
let message = `[${error.code}] ${error.message}`;
|
|
47
|
+
if (error.details) {
|
|
48
|
+
message += `\nDetails: ${JSON.stringify(error.details, null, 2)}`;
|
|
49
|
+
}
|
|
50
|
+
return message;
|
|
51
|
+
}
|
|
52
|
+
if (error instanceof Error) {
|
|
53
|
+
return error.message;
|
|
54
|
+
}
|
|
55
|
+
return String(error);
|
|
56
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Path constants and utilities for GemKit CLI
|
|
3
|
+
* Aligned with gk-session-manager.cjs
|
|
4
|
+
*/
|
|
5
|
+
export declare const GEMKIT_HOME: string;
|
|
6
|
+
export declare const GEMKIT_PROJECTS_DIR: string;
|
|
7
|
+
export declare const GEMINI_HOME: string;
|
|
8
|
+
export declare const GEMKIT_CONFIG_DIR: string;
|
|
9
|
+
export declare const GEMKIT_CACHE_DIR: string;
|
|
10
|
+
export declare const GEMKIT_TMP_DIR: string;
|
|
11
|
+
export declare const LOCAL_GEMINI_DIR = ".gemini";
|
|
12
|
+
export declare const LOCAL_AGENT_DIR = ".agent";
|
|
13
|
+
export declare const LOCAL_PLANS_DIR = "plans";
|
|
14
|
+
export declare const CONFIG_FILE = ".gk.json";
|
|
15
|
+
export declare const METADATA_FILE = "metadata.json";
|
|
16
|
+
export declare const ENV_FILE = ".env";
|
|
17
|
+
export declare function getLocalGeminiDir(projectDir?: string): string;
|
|
18
|
+
export declare function getLocalConfigPath(projectDir?: string): string;
|
|
19
|
+
export declare function getLocalMetadataPath(projectDir?: string): string;
|
|
20
|
+
export declare function getLocalEnvPath(projectDir?: string): string;
|
|
21
|
+
export declare function getAgentsDir(projectDir?: string): string;
|
|
22
|
+
export declare function getExtensionsDir(projectDir?: string): string;
|
|
23
|
+
export declare function getPlansDir(projectDir?: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Sanitize path to create safe directory name
|
|
26
|
+
* Matches gk-session-manager.cjs sanitizeProjectPath()
|
|
27
|
+
*/
|
|
28
|
+
export declare function sanitizeProjectPath(projectPath: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* Get project data directory
|
|
31
|
+
* Matches gk-session-manager.cjs getProjectDataDir()
|
|
32
|
+
* Storage: ~/.gemkit/projects/{projectDir}/
|
|
33
|
+
*/
|
|
34
|
+
export declare function getProjectDataDir(projectDir: string): string;
|
|
35
|
+
/**
|
|
36
|
+
* Get session file path
|
|
37
|
+
* Matches gk-session-manager.cjs getSessionPath()
|
|
38
|
+
*/
|
|
39
|
+
export declare function getSessionPath(projectDir: string, gkSessionId: string): string;
|
|
40
|
+
/**
|
|
41
|
+
* Get project file path
|
|
42
|
+
* Matches gk-session-manager.cjs getProjectPath()
|
|
43
|
+
*/
|
|
44
|
+
export declare function getProjectPath(projectDir: string, gkProjectHash: string): string;
|
|
45
|
+
export declare function getTempDir(projectHash?: string): string;
|
|
46
|
+
export declare function getCacheDir(): string;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Path constants and utilities for GemKit CLI
|
|
3
|
+
* Aligned with gk-session-manager.cjs
|
|
4
|
+
*/
|
|
5
|
+
import { homedir } from 'os';
|
|
6
|
+
import { join } from 'path';
|
|
7
|
+
// Global paths - aligned with gk-session-manager.cjs
|
|
8
|
+
export const GEMKIT_HOME = join(homedir(), '.gemkit');
|
|
9
|
+
export const GEMKIT_PROJECTS_DIR = join(GEMKIT_HOME, 'projects');
|
|
10
|
+
// Legacy paths (for backwards compatibility)
|
|
11
|
+
export const GEMINI_HOME = join(homedir(), '.gemini');
|
|
12
|
+
export const GEMKIT_CONFIG_DIR = join(GEMINI_HOME, 'config');
|
|
13
|
+
export const GEMKIT_CACHE_DIR = join(GEMINI_HOME, 'cache');
|
|
14
|
+
export const GEMKIT_TMP_DIR = join(GEMINI_HOME, 'tmp');
|
|
15
|
+
// Local paths (relative to project)
|
|
16
|
+
export const LOCAL_GEMINI_DIR = '.gemini';
|
|
17
|
+
export const LOCAL_AGENT_DIR = '.agent';
|
|
18
|
+
export const LOCAL_PLANS_DIR = 'plans';
|
|
19
|
+
// File names
|
|
20
|
+
export const CONFIG_FILE = '.gk.json';
|
|
21
|
+
export const METADATA_FILE = 'metadata.json';
|
|
22
|
+
export const ENV_FILE = '.env';
|
|
23
|
+
// Get local paths
|
|
24
|
+
export function getLocalGeminiDir(projectDir = process.cwd()) {
|
|
25
|
+
return join(projectDir, LOCAL_GEMINI_DIR);
|
|
26
|
+
}
|
|
27
|
+
export function getLocalConfigPath(projectDir = process.cwd()) {
|
|
28
|
+
return join(projectDir, LOCAL_GEMINI_DIR, CONFIG_FILE);
|
|
29
|
+
}
|
|
30
|
+
export function getLocalMetadataPath(projectDir = process.cwd()) {
|
|
31
|
+
return join(projectDir, LOCAL_GEMINI_DIR, METADATA_FILE);
|
|
32
|
+
}
|
|
33
|
+
export function getLocalEnvPath(projectDir = process.cwd()) {
|
|
34
|
+
return join(projectDir, LOCAL_GEMINI_DIR, ENV_FILE);
|
|
35
|
+
}
|
|
36
|
+
export function getAgentsDir(projectDir = process.cwd()) {
|
|
37
|
+
return join(projectDir, LOCAL_GEMINI_DIR, 'agents');
|
|
38
|
+
}
|
|
39
|
+
export function getExtensionsDir(projectDir = process.cwd()) {
|
|
40
|
+
return join(projectDir, LOCAL_GEMINI_DIR, 'extensions');
|
|
41
|
+
}
|
|
42
|
+
export function getPlansDir(projectDir = process.cwd()) {
|
|
43
|
+
return join(projectDir, LOCAL_PLANS_DIR);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Sanitize path to create safe directory name
|
|
47
|
+
* Matches gk-session-manager.cjs sanitizeProjectPath()
|
|
48
|
+
*/
|
|
49
|
+
export function sanitizeProjectPath(projectPath) {
|
|
50
|
+
if (!projectPath)
|
|
51
|
+
return '';
|
|
52
|
+
return projectPath
|
|
53
|
+
.replace(/^[A-Za-z]:/, m => m.replace(':', '')) // C: -> C
|
|
54
|
+
.replace(/[\\/]+/g, '-') // path separators to hyphens
|
|
55
|
+
.replace(/[^a-zA-Z0-9-]/g, '-') // other special chars to hyphens
|
|
56
|
+
.replace(/-+/g, '-') // collapse multiple hyphens
|
|
57
|
+
.replace(/^-|-$/g, ''); // trim leading/trailing hyphens
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Get project data directory
|
|
61
|
+
* Matches gk-session-manager.cjs getProjectDataDir()
|
|
62
|
+
* Storage: ~/.gemkit/projects/{projectDir}/
|
|
63
|
+
*/
|
|
64
|
+
export function getProjectDataDir(projectDir) {
|
|
65
|
+
return join(GEMKIT_PROJECTS_DIR, projectDir);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Get session file path
|
|
69
|
+
* Matches gk-session-manager.cjs getSessionPath()
|
|
70
|
+
*/
|
|
71
|
+
export function getSessionPath(projectDir, gkSessionId) {
|
|
72
|
+
return join(getProjectDataDir(projectDir), `gk-session-${gkSessionId}.json`);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Get project file path
|
|
76
|
+
* Matches gk-session-manager.cjs getProjectPath()
|
|
77
|
+
*/
|
|
78
|
+
export function getProjectPath(projectDir, gkProjectHash) {
|
|
79
|
+
return join(getProjectDataDir(projectDir), `gk-project-${gkProjectHash}.json`);
|
|
80
|
+
}
|
|
81
|
+
export function getTempDir(projectHash) {
|
|
82
|
+
if (projectHash) {
|
|
83
|
+
return join(GEMKIT_TMP_DIR, projectHash);
|
|
84
|
+
}
|
|
85
|
+
return GEMKIT_TMP_DIR;
|
|
86
|
+
}
|
|
87
|
+
export function getCacheDir() {
|
|
88
|
+
return GEMKIT_CACHE_DIR;
|
|
89
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform detection utilities
|
|
3
|
+
*/
|
|
4
|
+
export type Platform = 'win32' | 'darwin' | 'linux' | 'unknown';
|
|
5
|
+
export declare function getPlatform(): Platform;
|
|
6
|
+
export declare function isWindows(): boolean;
|
|
7
|
+
export declare function isMacOS(): boolean;
|
|
8
|
+
export declare function isLinux(): boolean;
|
|
9
|
+
export declare function getShell(): string;
|
|
10
|
+
export declare function getHomeDir(): string;
|
|
11
|
+
export declare function getPathSeparator(): string;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform detection utilities
|
|
3
|
+
*/
|
|
4
|
+
export function getPlatform() {
|
|
5
|
+
const platform = process.platform;
|
|
6
|
+
if (platform === 'win32' || platform === 'darwin' || platform === 'linux') {
|
|
7
|
+
return platform;
|
|
8
|
+
}
|
|
9
|
+
return 'unknown';
|
|
10
|
+
}
|
|
11
|
+
export function isWindows() {
|
|
12
|
+
return process.platform === 'win32';
|
|
13
|
+
}
|
|
14
|
+
export function isMacOS() {
|
|
15
|
+
return process.platform === 'darwin';
|
|
16
|
+
}
|
|
17
|
+
export function isLinux() {
|
|
18
|
+
return process.platform === 'linux';
|
|
19
|
+
}
|
|
20
|
+
export function getShell() {
|
|
21
|
+
if (isWindows()) {
|
|
22
|
+
return process.env.COMSPEC || 'cmd.exe';
|
|
23
|
+
}
|
|
24
|
+
return process.env.SHELL || '/bin/sh';
|
|
25
|
+
}
|
|
26
|
+
export function getHomeDir() {
|
|
27
|
+
return process.env.HOME || process.env.USERPROFILE || '';
|
|
28
|
+
}
|
|
29
|
+
export function getPathSeparator() {
|
|
30
|
+
return isWindows() ? ';' : ':';
|
|
31
|
+
}
|
package/package.json
CHANGED
|
@@ -1,54 +1,55 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "gemkit-cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "CLI for working with Gemini AI agents, plans, and sessions",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"author": "Richard Ng <the.richardng.ai@gmail.com>",
|
|
7
|
-
"license": "MIT",
|
|
8
|
-
"repository": {
|
|
9
|
-
"type": "git",
|
|
10
|
-
"url": "git+https://github.com/therichardngai-code/gemkit-cli.git"
|
|
11
|
-
},
|
|
12
|
-
"homepage": "https://gemkit.cc",
|
|
13
|
-
"bugs": {
|
|
14
|
-
"url": "https://github.com/therichardngai-code/gemkit-cli/issues"
|
|
15
|
-
},
|
|
16
|
-
"keywords": [
|
|
17
|
-
"cli",
|
|
18
|
-
"gemkit",
|
|
19
|
-
"gemini",
|
|
20
|
-
"ai"
|
|
21
|
-
],
|
|
22
|
-
"main": "dist/index.js",
|
|
23
|
-
"bin": {
|
|
24
|
-
"gk": "dist/index.js"
|
|
25
|
-
},
|
|
26
|
-
"files": [
|
|
27
|
-
"dist"
|
|
28
|
-
],
|
|
29
|
-
"scripts": {
|
|
30
|
-
"build": "esbuild src/index.ts --bundle --platform=node --target=node18 --format=esm --minify --outfile=dist/index.js --external:ws",
|
|
31
|
-
"build:dev": "tsc",
|
|
32
|
-
"typecheck": "tsc --noEmit",
|
|
33
|
-
"dev": "tsc --watch",
|
|
34
|
-
"start": "node dist/index.js"
|
|
35
|
-
},
|
|
36
|
-
"dependencies": {
|
|
37
|
-
"cac": "^6.7.14",
|
|
38
|
-
"dotenv": "^16.3.1",
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
"@types/
|
|
47
|
-
"@types/
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "gemkit-cli",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "CLI for working with Gemini AI agents, plans, and sessions",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"author": "Richard Ng <the.richardng.ai@gmail.com>",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/therichardngai-code/gemkit-cli.git"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://gemkit.cc",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/therichardngai-code/gemkit-cli/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"cli",
|
|
18
|
+
"gemkit",
|
|
19
|
+
"gemini",
|
|
20
|
+
"ai"
|
|
21
|
+
],
|
|
22
|
+
"main": "dist/index.js",
|
|
23
|
+
"bin": {
|
|
24
|
+
"gk": "dist/index.js"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"dist"
|
|
28
|
+
],
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "esbuild src/index.ts --bundle --platform=node --target=node18 --format=esm --minify --outfile=dist/index.js --external:ws --external:node-pty",
|
|
31
|
+
"build:dev": "tsc",
|
|
32
|
+
"typecheck": "tsc --noEmit",
|
|
33
|
+
"dev": "tsc --watch",
|
|
34
|
+
"start": "node dist/index.js"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"cac": "^6.7.14",
|
|
38
|
+
"dotenv": "^16.3.1",
|
|
39
|
+
"node-pty": "^1.1.0",
|
|
40
|
+
"ora": "^8.0.1",
|
|
41
|
+
"picocolors": "^1.1.1",
|
|
42
|
+
"tar": "^7.5.2",
|
|
43
|
+
"ws": "^8.19.0"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@types/node": "^20.10.0",
|
|
47
|
+
"@types/tar": "^6.1.13",
|
|
48
|
+
"@types/ws": "^8.18.1",
|
|
49
|
+
"esbuild": "^0.27.2",
|
|
50
|
+
"typescript": "^5.3.0"
|
|
51
|
+
},
|
|
52
|
+
"engines": {
|
|
53
|
+
"node": ">=18"
|
|
54
|
+
}
|
|
55
|
+
}
|