neuro-cli 4.1.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/LICENSE +21 -0
- package/README.md +510 -0
- package/dist/advisor/advisor.d.ts +50 -0
- package/dist/advisor/advisor.js +178 -0
- package/dist/agents/base.d.ts +62 -0
- package/dist/agents/base.js +215 -0
- package/dist/agents/orchestrator.d.ts +46 -0
- package/dist/agents/orchestrator.js +192 -0
- package/dist/agents/team.d.ts +51 -0
- package/dist/agents/team.js +210 -0
- package/dist/api/models.d.ts +23 -0
- package/dist/api/models.js +514 -0
- package/dist/api/ollama.d.ts +153 -0
- package/dist/api/ollama.js +751 -0
- package/dist/api/openrouter.d.ts +55 -0
- package/dist/api/openrouter.js +223 -0
- package/dist/commands/commands.d.ts +43 -0
- package/dist/commands/commands.js +308 -0
- package/dist/config/config.d.ts +8 -0
- package/dist/config/config.js +311 -0
- package/dist/context/compaction.d.ts +54 -0
- package/dist/context/compaction.js +251 -0
- package/dist/context/custom-agents.d.ts +107 -0
- package/dist/context/custom-agents.js +397 -0
- package/dist/context/custom-tools.d.ts +120 -0
- package/dist/context/custom-tools.js +564 -0
- package/dist/context/git-checkpoint.d.ts +52 -0
- package/dist/context/git-checkpoint.js +240 -0
- package/dist/context/neuro-md.d.ts +48 -0
- package/dist/context/neuro-md.js +202 -0
- package/dist/context/neuroignore.d.ts +102 -0
- package/dist/context/neuroignore.js +441 -0
- package/dist/context/repo-map.d.ts +38 -0
- package/dist/context/repo-map.js +220 -0
- package/dist/context/skill-standard.d.ts +262 -0
- package/dist/context/skill-standard.js +1156 -0
- package/dist/context/skill-system.d.ts +75 -0
- package/dist/context/skill-system.js +578 -0
- package/dist/context/tree-sitter.d.ts +99 -0
- package/dist/context/tree-sitter.js +1956 -0
- package/dist/core/acp.d.ts +325 -0
- package/dist/core/acp.js +1498 -0
- package/dist/core/api-server.d.ts +143 -0
- package/dist/core/api-server.js +550 -0
- package/dist/core/approval.d.ts +81 -0
- package/dist/core/approval.js +432 -0
- package/dist/core/auto-compact.d.ts +127 -0
- package/dist/core/auto-compact.js +436 -0
- package/dist/core/auto-mode.d.ts +232 -0
- package/dist/core/auto-mode.js +831 -0
- package/dist/core/background-session.d.ts +166 -0
- package/dist/core/background-session.js +696 -0
- package/dist/core/cicd.d.ts +257 -0
- package/dist/core/cicd.js +1443 -0
- package/dist/core/cloud-sync.d.ts +156 -0
- package/dist/core/cloud-sync.js +582 -0
- package/dist/core/code-review.d.ts +132 -0
- package/dist/core/code-review.js +1191 -0
- package/dist/core/completion.d.ts +49 -0
- package/dist/core/completion.js +384 -0
- package/dist/core/context.d.ts +38 -0
- package/dist/core/context.js +144 -0
- package/dist/core/diff-preview.d.ts +35 -0
- package/dist/core/diff-preview.js +173 -0
- package/dist/core/doom-loop.d.ts +51 -0
- package/dist/core/doom-loop.js +179 -0
- package/dist/core/engine.d.ts +183 -0
- package/dist/core/engine.js +942 -0
- package/dist/core/extended-thinking.d.ts +103 -0
- package/dist/core/extended-thinking.js +269 -0
- package/dist/core/fallback.d.ts +54 -0
- package/dist/core/fallback.js +104 -0
- package/dist/core/git-worktree.d.ts +139 -0
- package/dist/core/git-worktree.js +614 -0
- package/dist/core/headless.d.ts +30 -0
- package/dist/core/headless.js +101 -0
- package/dist/core/i18n.d.ts +83 -0
- package/dist/core/i18n.js +739 -0
- package/dist/core/linting.d.ts +129 -0
- package/dist/core/linting.js +699 -0
- package/dist/core/model-router.d.ts +109 -0
- package/dist/core/model-router.js +581 -0
- package/dist/core/multi-model.d.ts +243 -0
- package/dist/core/multi-model.js +1099 -0
- package/dist/core/multi-session.d.ts +144 -0
- package/dist/core/multi-session.js +442 -0
- package/dist/core/multimodal.d.ts +125 -0
- package/dist/core/multimodal.js +286 -0
- package/dist/core/observability.d.ts +93 -0
- package/dist/core/observability.js +737 -0
- package/dist/core/os-sandbox.d.ts +122 -0
- package/dist/core/os-sandbox.js +1193 -0
- package/dist/core/outcome-grading.d.ts +228 -0
- package/dist/core/outcome-grading.js +1123 -0
- package/dist/core/output-styles.d.ts +57 -0
- package/dist/core/output-styles.js +382 -0
- package/dist/core/parallel-agents.d.ts +183 -0
- package/dist/core/parallel-agents.js +563 -0
- package/dist/core/plugin-bundle.d.ts +236 -0
- package/dist/core/plugin-bundle.js +887 -0
- package/dist/core/plugin-sdk.d.ts +139 -0
- package/dist/core/plugin-sdk.js +273 -0
- package/dist/core/prompt-cache.d.ts +163 -0
- package/dist/core/prompt-cache.js +599 -0
- package/dist/core/sandbox.d.ts +127 -0
- package/dist/core/sandbox.js +369 -0
- package/dist/core/scheduled-tasks.d.ts +151 -0
- package/dist/core/scheduled-tasks.js +502 -0
- package/dist/core/security-scanner.d.ts +160 -0
- package/dist/core/security-scanner.js +1494 -0
- package/dist/core/session.d.ts +83 -0
- package/dist/core/session.js +269 -0
- package/dist/core/shell-completion.d.ts +51 -0
- package/dist/core/shell-completion.js +674 -0
- package/dist/core/smart-monitor.d.ts +146 -0
- package/dist/core/smart-monitor.js +1199 -0
- package/dist/core/spec-driven.d.ts +233 -0
- package/dist/core/spec-driven.js +1485 -0
- package/dist/core/spending-warnings.d.ts +123 -0
- package/dist/core/spending-warnings.js +456 -0
- package/dist/core/sub-agent.d.ts +298 -0
- package/dist/core/sub-agent.js +1023 -0
- package/dist/core/telemetry.d.ts +157 -0
- package/dist/core/telemetry.js +412 -0
- package/dist/core/terminal-ux.d.ts +134 -0
- package/dist/core/terminal-ux.js +649 -0
- package/dist/core/testing.d.ts +146 -0
- package/dist/core/testing.js +1200 -0
- package/dist/core/types.d.ts +439 -0
- package/dist/core/types.js +6 -0
- package/dist/core/undo-redo.d.ts +112 -0
- package/dist/core/undo-redo.js +290 -0
- package/dist/core/updater.d.ts +159 -0
- package/dist/core/updater.js +608 -0
- package/dist/core/vim-mode.d.ts +151 -0
- package/dist/core/vim-mode.js +771 -0
- package/dist/core/voice.d.ts +137 -0
- package/dist/core/voice.js +538 -0
- package/dist/core/web-dashboard.d.ts +109 -0
- package/dist/core/web-dashboard.js +484 -0
- package/dist/hooks/hooks.d.ts +74 -0
- package/dist/hooks/hooks.js +160 -0
- package/dist/hooks/llm-evaluator.d.ts +165 -0
- package/dist/hooks/llm-evaluator.js +560 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1186 -0
- package/dist/lsp/lsp-manager.d.ts +63 -0
- package/dist/lsp/lsp-manager.js +351 -0
- package/dist/mcp/client.d.ts +133 -0
- package/dist/mcp/client.js +684 -0
- package/dist/mcp/mcp-apps.d.ts +70 -0
- package/dist/mcp/mcp-apps.js +1007 -0
- package/dist/tools/bash.d.ts +5 -0
- package/dist/tools/bash.js +195 -0
- package/dist/tools/browser.d.ts +92 -0
- package/dist/tools/browser.js +1570 -0
- package/dist/tools/extended.d.ts +6 -0
- package/dist/tools/extended.js +191 -0
- package/dist/tools/file.d.ts +10 -0
- package/dist/tools/file.js +382 -0
- package/dist/tools/github.d.ts +389 -0
- package/dist/tools/github.js +759 -0
- package/dist/tools/index.d.ts +9 -0
- package/dist/tools/index.js +40 -0
- package/dist/tools/memory.d.ts +6 -0
- package/dist/tools/memory.js +197 -0
- package/dist/tools/registry.d.ts +29 -0
- package/dist/tools/registry.js +64 -0
- package/dist/tools/web.d.ts +6 -0
- package/dist/tools/web.js +150 -0
- package/dist/ui/renderer.d.ts +97 -0
- package/dist/ui/renderer.js +279 -0
- package/dist/ui/theme.d.ts +27 -0
- package/dist/ui/theme.js +106 -0
- package/package.json +83 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { Session, Message, AgentExecution } from '../core/types.js';
|
|
2
|
+
export declare class SessionManager {
|
|
3
|
+
private currentSession;
|
|
4
|
+
/**
|
|
5
|
+
* Create a new session
|
|
6
|
+
*/
|
|
7
|
+
create(workingDirectory: string, model: string): Session;
|
|
8
|
+
/**
|
|
9
|
+
* Load an existing session
|
|
10
|
+
*/
|
|
11
|
+
load(sessionId: string): Session | null;
|
|
12
|
+
/**
|
|
13
|
+
* Get the current session
|
|
14
|
+
*/
|
|
15
|
+
getCurrent(): Session | null;
|
|
16
|
+
/**
|
|
17
|
+
* Save the current session
|
|
18
|
+
*/
|
|
19
|
+
save(): void;
|
|
20
|
+
/**
|
|
21
|
+
* Add a message to the current session
|
|
22
|
+
*/
|
|
23
|
+
addMessage(message: Message): void;
|
|
24
|
+
/**
|
|
25
|
+
* Add an agent execution record
|
|
26
|
+
*/
|
|
27
|
+
addAgentExecution(execution: AgentExecution): void;
|
|
28
|
+
/**
|
|
29
|
+
* Update token usage
|
|
30
|
+
*/
|
|
31
|
+
updateUsage(inputTokens: number, outputTokens: number, cost: number): void;
|
|
32
|
+
/**
|
|
33
|
+
* List all sessions
|
|
34
|
+
*/
|
|
35
|
+
list(): Array<{
|
|
36
|
+
id: string;
|
|
37
|
+
createdAt: number;
|
|
38
|
+
messageCount: number;
|
|
39
|
+
model: string;
|
|
40
|
+
cost: number;
|
|
41
|
+
}>;
|
|
42
|
+
/**
|
|
43
|
+
* Delete a session
|
|
44
|
+
*/
|
|
45
|
+
delete(sessionId: string): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Fork a session (create a copy with new ID)
|
|
48
|
+
*/
|
|
49
|
+
fork(sessionId: string): Session | null;
|
|
50
|
+
/**
|
|
51
|
+
* Get the most recent session
|
|
52
|
+
*/
|
|
53
|
+
getMostRecent(): Session | null;
|
|
54
|
+
/**
|
|
55
|
+
* Search sessions by content
|
|
56
|
+
*/
|
|
57
|
+
search(query: string): Array<{
|
|
58
|
+
id: string;
|
|
59
|
+
createdAt: number;
|
|
60
|
+
messageCount: number;
|
|
61
|
+
model: string;
|
|
62
|
+
cost: number;
|
|
63
|
+
matchPreview: string;
|
|
64
|
+
}>;
|
|
65
|
+
/**
|
|
66
|
+
* Export a session to a portable JSON format
|
|
67
|
+
*/
|
|
68
|
+
exportSession(sessionId: string, outputPath: string): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Import a session from a JSON file
|
|
71
|
+
*/
|
|
72
|
+
importSession(filePath: string): Session | null;
|
|
73
|
+
/**
|
|
74
|
+
* Get session statistics
|
|
75
|
+
*/
|
|
76
|
+
getStats(): {
|
|
77
|
+
totalSessions: number;
|
|
78
|
+
totalMessages: number;
|
|
79
|
+
totalCost: number;
|
|
80
|
+
totalTokens: number;
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=session.d.ts.map
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// NeuroCLI - Session Manager
|
|
3
|
+
// Persistent conversation sessions
|
|
4
|
+
// ============================================================
|
|
5
|
+
import { readFileSync, writeFileSync, existsSync, mkdirSync, readdirSync, unlinkSync } from 'fs';
|
|
6
|
+
import { join } from 'path';
|
|
7
|
+
import { homedir } from 'os';
|
|
8
|
+
const SESSION_DIR = join(homedir(), '.neuro', 'sessions');
|
|
9
|
+
export class SessionManager {
|
|
10
|
+
currentSession = null;
|
|
11
|
+
/**
|
|
12
|
+
* Create a new session
|
|
13
|
+
*/
|
|
14
|
+
create(workingDirectory, model) {
|
|
15
|
+
this.currentSession = {
|
|
16
|
+
id: `session_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`,
|
|
17
|
+
createdAt: Date.now(),
|
|
18
|
+
updatedAt: Date.now(),
|
|
19
|
+
messages: [],
|
|
20
|
+
workingDirectory,
|
|
21
|
+
model,
|
|
22
|
+
totalInputTokens: 0,
|
|
23
|
+
totalOutputTokens: 0,
|
|
24
|
+
totalCost: 0,
|
|
25
|
+
agentHistory: [],
|
|
26
|
+
tags: [],
|
|
27
|
+
};
|
|
28
|
+
this.save();
|
|
29
|
+
return this.currentSession;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Load an existing session
|
|
33
|
+
*/
|
|
34
|
+
load(sessionId) {
|
|
35
|
+
const filePath = join(SESSION_DIR, `${sessionId}.json`);
|
|
36
|
+
if (!existsSync(filePath))
|
|
37
|
+
return null;
|
|
38
|
+
try {
|
|
39
|
+
const data = readFileSync(filePath, 'utf-8');
|
|
40
|
+
this.currentSession = JSON.parse(data);
|
|
41
|
+
return this.currentSession;
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Get the current session
|
|
49
|
+
*/
|
|
50
|
+
getCurrent() {
|
|
51
|
+
return this.currentSession;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Save the current session
|
|
55
|
+
*/
|
|
56
|
+
save() {
|
|
57
|
+
if (!this.currentSession)
|
|
58
|
+
return;
|
|
59
|
+
if (!existsSync(SESSION_DIR)) {
|
|
60
|
+
mkdirSync(SESSION_DIR, { recursive: true });
|
|
61
|
+
}
|
|
62
|
+
this.currentSession.updatedAt = Date.now();
|
|
63
|
+
const filePath = join(SESSION_DIR, `${this.currentSession.id}.json`);
|
|
64
|
+
writeFileSync(filePath, JSON.stringify(this.currentSession, null, 2), 'utf-8');
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Add a message to the current session
|
|
68
|
+
*/
|
|
69
|
+
addMessage(message) {
|
|
70
|
+
if (!this.currentSession)
|
|
71
|
+
return;
|
|
72
|
+
this.currentSession.messages.push(message);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Add an agent execution record
|
|
76
|
+
*/
|
|
77
|
+
addAgentExecution(execution) {
|
|
78
|
+
if (!this.currentSession)
|
|
79
|
+
return;
|
|
80
|
+
this.currentSession.agentHistory.push(execution);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Update token usage
|
|
84
|
+
*/
|
|
85
|
+
updateUsage(inputTokens, outputTokens, cost) {
|
|
86
|
+
if (!this.currentSession)
|
|
87
|
+
return;
|
|
88
|
+
this.currentSession.totalInputTokens += inputTokens;
|
|
89
|
+
this.currentSession.totalOutputTokens += outputTokens;
|
|
90
|
+
this.currentSession.totalCost += cost;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* List all sessions
|
|
94
|
+
*/
|
|
95
|
+
list() {
|
|
96
|
+
if (!existsSync(SESSION_DIR))
|
|
97
|
+
return [];
|
|
98
|
+
const sessions = [];
|
|
99
|
+
for (const file of readdirSync(SESSION_DIR)) {
|
|
100
|
+
if (!file.endsWith('.json'))
|
|
101
|
+
continue;
|
|
102
|
+
try {
|
|
103
|
+
const data = JSON.parse(readFileSync(join(SESSION_DIR, file), 'utf-8'));
|
|
104
|
+
sessions.push({
|
|
105
|
+
id: data.id,
|
|
106
|
+
createdAt: data.createdAt,
|
|
107
|
+
messageCount: data.messages?.length || 0,
|
|
108
|
+
model: data.model,
|
|
109
|
+
cost: data.totalCost || 0,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
catch { }
|
|
113
|
+
}
|
|
114
|
+
return sessions.sort((a, b) => b.createdAt - a.createdAt);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Delete a session
|
|
118
|
+
*/
|
|
119
|
+
delete(sessionId) {
|
|
120
|
+
const filePath = join(SESSION_DIR, `${sessionId}.json`);
|
|
121
|
+
if (!existsSync(filePath))
|
|
122
|
+
return false;
|
|
123
|
+
try {
|
|
124
|
+
unlinkSync(filePath);
|
|
125
|
+
if (this.currentSession?.id === sessionId) {
|
|
126
|
+
this.currentSession = null;
|
|
127
|
+
}
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
catch {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Fork a session (create a copy with new ID)
|
|
136
|
+
*/
|
|
137
|
+
fork(sessionId) {
|
|
138
|
+
const source = this.load(sessionId);
|
|
139
|
+
if (!source)
|
|
140
|
+
return null;
|
|
141
|
+
const forked = {
|
|
142
|
+
...source,
|
|
143
|
+
id: `session_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`,
|
|
144
|
+
createdAt: Date.now(),
|
|
145
|
+
updatedAt: Date.now(),
|
|
146
|
+
messages: [...source.messages],
|
|
147
|
+
agentHistory: [...source.agentHistory],
|
|
148
|
+
totalInputTokens: source.totalInputTokens,
|
|
149
|
+
totalOutputTokens: source.totalOutputTokens,
|
|
150
|
+
totalCost: source.totalCost,
|
|
151
|
+
forkedFrom: source.id,
|
|
152
|
+
parentSessionId: source.id,
|
|
153
|
+
};
|
|
154
|
+
this.currentSession = forked;
|
|
155
|
+
this.save();
|
|
156
|
+
return forked;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Get the most recent session
|
|
160
|
+
*/
|
|
161
|
+
getMostRecent() {
|
|
162
|
+
const sessions = this.list();
|
|
163
|
+
if (sessions.length === 0)
|
|
164
|
+
return null;
|
|
165
|
+
return this.load(sessions[0].id);
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Search sessions by content
|
|
169
|
+
*/
|
|
170
|
+
search(query) {
|
|
171
|
+
if (!existsSync(SESSION_DIR))
|
|
172
|
+
return [];
|
|
173
|
+
const results = [];
|
|
174
|
+
const lowerQuery = query.toLowerCase();
|
|
175
|
+
for (const file of readdirSync(SESSION_DIR)) {
|
|
176
|
+
if (!file.endsWith('.json'))
|
|
177
|
+
continue;
|
|
178
|
+
try {
|
|
179
|
+
const data = JSON.parse(readFileSync(join(SESSION_DIR, file), 'utf-8'));
|
|
180
|
+
// Search in messages
|
|
181
|
+
const matchMsg = data.messages?.find((m) => m.content?.toLowerCase().includes(lowerQuery));
|
|
182
|
+
if (matchMsg) {
|
|
183
|
+
const preview = matchMsg.content.slice(0, 80).replace(/\n/g, ' ');
|
|
184
|
+
results.push({
|
|
185
|
+
id: data.id,
|
|
186
|
+
createdAt: data.createdAt,
|
|
187
|
+
messageCount: data.messages?.length || 0,
|
|
188
|
+
model: data.model,
|
|
189
|
+
cost: data.totalCost || 0,
|
|
190
|
+
matchPreview: preview,
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
catch { }
|
|
195
|
+
}
|
|
196
|
+
return results.sort((a, b) => b.createdAt - a.createdAt);
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Export a session to a portable JSON format
|
|
200
|
+
*/
|
|
201
|
+
exportSession(sessionId, outputPath) {
|
|
202
|
+
const session = this.load(sessionId);
|
|
203
|
+
if (!session)
|
|
204
|
+
return false;
|
|
205
|
+
const exportData = {
|
|
206
|
+
version: '3.0.0',
|
|
207
|
+
exportedAt: Date.now(),
|
|
208
|
+
session,
|
|
209
|
+
neuroVersion: '3.0.0',
|
|
210
|
+
};
|
|
211
|
+
try {
|
|
212
|
+
writeFileSync(outputPath, JSON.stringify(exportData, null, 2), 'utf-8');
|
|
213
|
+
return true;
|
|
214
|
+
}
|
|
215
|
+
catch {
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Import a session from a JSON file
|
|
221
|
+
*/
|
|
222
|
+
importSession(filePath) {
|
|
223
|
+
try {
|
|
224
|
+
const content = readFileSync(filePath, 'utf-8');
|
|
225
|
+
const importData = JSON.parse(content);
|
|
226
|
+
const sessionData = importData.session || importData;
|
|
227
|
+
const newSession = {
|
|
228
|
+
id: `session_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`,
|
|
229
|
+
createdAt: Date.now(),
|
|
230
|
+
updatedAt: Date.now(),
|
|
231
|
+
messages: sessionData.messages || [],
|
|
232
|
+
workingDirectory: sessionData.workingDirectory || process.cwd(),
|
|
233
|
+
model: sessionData.model || 'qwen/qwen3-coder:free',
|
|
234
|
+
totalInputTokens: sessionData.totalInputTokens || 0,
|
|
235
|
+
totalOutputTokens: sessionData.totalOutputTokens || 0,
|
|
236
|
+
totalCost: sessionData.totalCost || 0,
|
|
237
|
+
agentHistory: sessionData.agentHistory || [],
|
|
238
|
+
tags: sessionData.tags || [],
|
|
239
|
+
description: sessionData.description || `Imported from ${filePath}`,
|
|
240
|
+
parentSessionId: sessionData.id,
|
|
241
|
+
};
|
|
242
|
+
this.currentSession = newSession;
|
|
243
|
+
this.save();
|
|
244
|
+
return newSession;
|
|
245
|
+
}
|
|
246
|
+
catch {
|
|
247
|
+
return null;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Get session statistics
|
|
252
|
+
*/
|
|
253
|
+
getStats() {
|
|
254
|
+
const sessions = this.list();
|
|
255
|
+
let totalMessages = 0;
|
|
256
|
+
let totalCost = 0;
|
|
257
|
+
for (const session of sessions) {
|
|
258
|
+
totalMessages += session.messageCount;
|
|
259
|
+
totalCost += session.cost;
|
|
260
|
+
}
|
|
261
|
+
return {
|
|
262
|
+
totalSessions: sessions.length,
|
|
263
|
+
totalMessages,
|
|
264
|
+
totalCost,
|
|
265
|
+
totalTokens: 0, // Would need to sum from all sessions
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
//# sourceMappingURL=session.js.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export type ShellType = 'bash' | 'zsh' | 'fish';
|
|
2
|
+
export interface CompletionOptions {
|
|
3
|
+
commands: Array<{
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
options: Array<{
|
|
7
|
+
flags: string;
|
|
8
|
+
description: string;
|
|
9
|
+
}>;
|
|
10
|
+
subcommands?: Array<{
|
|
11
|
+
name: string;
|
|
12
|
+
description: string;
|
|
13
|
+
}>;
|
|
14
|
+
}>;
|
|
15
|
+
models: string[];
|
|
16
|
+
themes: string[];
|
|
17
|
+
permissionModes: string[];
|
|
18
|
+
agents: string[];
|
|
19
|
+
slashCommands: string[];
|
|
20
|
+
}
|
|
21
|
+
export declare class ShellCompletionGenerator {
|
|
22
|
+
private options;
|
|
23
|
+
constructor(options: CompletionOptions);
|
|
24
|
+
/**
|
|
25
|
+
* Generate a completion script for the given shell type.
|
|
26
|
+
*/
|
|
27
|
+
generate(shell: ShellType): string;
|
|
28
|
+
generateBash(): string;
|
|
29
|
+
generateZsh(): string;
|
|
30
|
+
generateFish(): string;
|
|
31
|
+
writeToFile(shell: ShellType, filePath: string): void;
|
|
32
|
+
static getDefaultOptions(): CompletionOptions;
|
|
33
|
+
/**
|
|
34
|
+
* Escape a string for safe embedding in a bash double-quoted context.
|
|
35
|
+
* Escapes: backslash, double-quote, dollar, backtick, and exclamation.
|
|
36
|
+
*/
|
|
37
|
+
private bashEscape;
|
|
38
|
+
/**
|
|
39
|
+
* Escape a string for safe embedding in a zsh single-quoted context.
|
|
40
|
+
* Inside single quotes only the single quote itself needs escaping;
|
|
41
|
+
* zsh uses '\'' (end quote, escaped quote, reopen quote).
|
|
42
|
+
*/
|
|
43
|
+
private zshEscape;
|
|
44
|
+
/**
|
|
45
|
+
* Escape a string for safe embedding in a fish completion description
|
|
46
|
+
* or argument. Fish uses single quotes; escape single quotes and
|
|
47
|
+
* backslashes.
|
|
48
|
+
*/
|
|
49
|
+
private fishEscape;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=shell-completion.d.ts.map
|