thatgfsj-code 0.7.0 → 0.7.2
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/dist/app/index.d.ts.map +1 -1
- package/dist/app/index.js +5 -0
- package/dist/app/index.js.map +1 -1
- package/dist/cmd/index.d.ts +0 -5
- package/dist/cmd/index.d.ts.map +1 -1
- package/dist/cmd/index.js +36 -56
- package/dist/cmd/index.js.map +1 -1
- package/dist/session/index.d.ts +5 -21
- package/dist/session/index.d.ts.map +1 -1
- package/dist/session/index.js +26 -22
- package/dist/session/index.js.map +1 -1
- package/dist/tools/nwt.d.ts +5 -0
- package/dist/tools/nwt.d.ts.map +1 -1
- package/dist/tools/nwt.js +68 -0
- package/dist/tools/nwt.js.map +1 -1
- package/dist/tui/app.js +1 -1
- package/dist/tui/app.js.map +1 -1
- package/dist/tui/components/ChatList.d.ts +1 -1
- package/dist/tui/components/ChatList.d.ts.map +1 -1
- package/dist/tui/components/ChatList.js +5 -3
- package/dist/tui/components/ChatList.js.map +1 -1
- package/dist/tui/components/ChatMessage.d.ts +1 -1
- package/dist/tui/components/ChatMessage.d.ts.map +1 -1
- package/dist/tui/components/ChatMessage.js +4 -2
- package/dist/tui/components/ChatMessage.js.map +1 -1
- package/dist/tui/components/Header.d.ts +1 -1
- package/dist/tui/components/Header.d.ts.map +1 -1
- package/dist/tui/components/Header.js +5 -3
- package/dist/tui/components/Header.js.map +1 -1
- package/dist/tui/components/StatusBar.d.ts +1 -1
- package/dist/tui/components/StatusBar.d.ts.map +1 -1
- package/dist/tui/components/StatusBar.js +4 -2
- package/dist/tui/components/StatusBar.js.map +1 -1
- package/dist/tui/components/Thinking.d.ts +2 -1
- package/dist/tui/components/Thinking.d.ts.map +1 -1
- package/dist/tui/components/Thinking.js +5 -1
- package/dist/tui/components/Thinking.js.map +1 -1
- package/dist/tui/components/UserInput.d.ts +1 -1
- package/dist/tui/components/UserInput.d.ts.map +1 -1
- package/dist/tui/components/UserInput.js +5 -22
- package/dist/tui/components/UserInput.js.map +1 -1
- package/package.json +1 -1
- package/src/app/index.ts +6 -0
- package/src/cmd/index.tsx +38 -51
- package/src/session/index.ts +28 -22
- package/src/tools/nwt.ts +68 -0
- package/src/tui/app.tsx +1 -1
- package/src/tui/components/ChatList.tsx +4 -4
- package/src/tui/components/ChatMessage.tsx +2 -2
- package/src/tui/components/Header.tsx +3 -3
- package/src/tui/components/StatusBar.tsx +2 -2
- package/src/tui/components/Thinking.tsx +7 -1
- package/src/tui/components/UserInput.tsx +8 -24
- package/dist/app/agent.d.ts +0 -31
- package/dist/app/agent.d.ts.map +0 -1
- package/dist/app/agent.js +0 -106
- package/dist/app/agent.js.map +0 -1
- package/dist/tui/input.d.ts +0 -13
- package/dist/tui/input.d.ts.map +0 -1
- package/dist/tui/input.js +0 -47
- package/dist/tui/input.js.map +0 -1
- package/dist/tui/output.d.ts +0 -44
- package/dist/tui/output.d.ts.map +0 -1
- package/dist/tui/output.js +0 -202
- package/dist/tui/output.js.map +0 -1
- package/dist/tui/repl.d.ts +0 -15
- package/dist/tui/repl.d.ts.map +0 -1
- package/dist/tui/repl.js +0 -162
- package/dist/tui/repl.js.map +0 -1
- package/install.bat +0 -63
- package/install.ps1 +0 -217
- package/install.sh +0 -113
- package/src/tui/input.ts +0 -53
- package/src/tui/output.ts +0 -235
- package/src/tui/repl.ts +0 -181
package/src/tui/repl.ts
DELETED
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* REPL - Main interactive loop
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import chalk from 'chalk';
|
|
6
|
-
import { REPLInput } from './input.js';
|
|
7
|
-
import { REPLOutput } from './output.js';
|
|
8
|
-
import { App } from '../app/index.js';
|
|
9
|
-
import { ProjectContext } from '../utils/project.js';
|
|
10
|
-
|
|
11
|
-
export class REPL {
|
|
12
|
-
private input: REPLInput;
|
|
13
|
-
private output: REPLOutput;
|
|
14
|
-
private app: App;
|
|
15
|
-
private running = false;
|
|
16
|
-
|
|
17
|
-
constructor(app: App) {
|
|
18
|
-
this.input = new REPLInput();
|
|
19
|
-
this.output = new REPLOutput();
|
|
20
|
-
this.app = app;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
async start(): Promise<void> {
|
|
24
|
-
this.running = true;
|
|
25
|
-
|
|
26
|
-
this.output.clear();
|
|
27
|
-
this.output.printBanner();
|
|
28
|
-
|
|
29
|
-
const cfg = this.app.config.get();
|
|
30
|
-
this.output.section('Session', [
|
|
31
|
-
{ label: 'Provider', value: cfg.provider },
|
|
32
|
-
{ label: 'Model', value: cfg.model },
|
|
33
|
-
{ label: 'Project', value: ProjectContext.detectType() },
|
|
34
|
-
]);
|
|
35
|
-
|
|
36
|
-
this.output.info('Type ' + chalk.cyan('help') + ' for commands');
|
|
37
|
-
this.output.spacer();
|
|
38
|
-
|
|
39
|
-
while (this.running) {
|
|
40
|
-
try {
|
|
41
|
-
const userInput = await this.input.prompt(this.output.getPrompt());
|
|
42
|
-
if (!userInput.trim()) continue;
|
|
43
|
-
|
|
44
|
-
const handled = await this.handleCommand(userInput.trim());
|
|
45
|
-
if (handled) continue;
|
|
46
|
-
|
|
47
|
-
await this.processInput(userInput.trim());
|
|
48
|
-
} catch (error: any) {
|
|
49
|
-
if (error.message === 'SIGINT') continue;
|
|
50
|
-
this.output.error(error.message);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
private async handleCommand(input: string): Promise<boolean> {
|
|
56
|
-
const cmd = input.toLowerCase();
|
|
57
|
-
|
|
58
|
-
switch (cmd) {
|
|
59
|
-
case 'exit':
|
|
60
|
-
case 'quit':
|
|
61
|
-
this.output.dim('Goodbye! 👋');
|
|
62
|
-
this.running = false;
|
|
63
|
-
this.input.close();
|
|
64
|
-
return true;
|
|
65
|
-
|
|
66
|
-
case 'clear':
|
|
67
|
-
this.output.clear();
|
|
68
|
-
this.output.printBanner();
|
|
69
|
-
return true;
|
|
70
|
-
|
|
71
|
-
case 'help':
|
|
72
|
-
this.output.printHelp();
|
|
73
|
-
return true;
|
|
74
|
-
|
|
75
|
-
case 'tools':
|
|
76
|
-
this.output.section('Available Tools',
|
|
77
|
-
this.app.tools.list().map(t => ({
|
|
78
|
-
label: t.name,
|
|
79
|
-
value: t.description,
|
|
80
|
-
}))
|
|
81
|
-
);
|
|
82
|
-
return true;
|
|
83
|
-
|
|
84
|
-
case 'model': {
|
|
85
|
-
const c = this.app.config.get();
|
|
86
|
-
this.output.section('Current Model', [
|
|
87
|
-
{ label: 'Provider', value: c.provider },
|
|
88
|
-
{ label: 'Model', value: c.model },
|
|
89
|
-
{ label: 'Base URL', value: c.baseUrl || 'default' },
|
|
90
|
-
{ label: 'API Key', value: c.apiKey ? '••••' + c.apiKey.slice(-4) : 'not set' },
|
|
91
|
-
]);
|
|
92
|
-
return true;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
default:
|
|
96
|
-
return false;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
private async processInput(input: string): Promise<void> {
|
|
101
|
-
this.app.session.addMessage('user', input);
|
|
102
|
-
this.output.printUserInput(input);
|
|
103
|
-
this.output.startThinking();
|
|
104
|
-
|
|
105
|
-
let fullResponse = '';
|
|
106
|
-
let hasStartedOutput = false;
|
|
107
|
-
|
|
108
|
-
try {
|
|
109
|
-
const stream = this.app.streamResponse();
|
|
110
|
-
|
|
111
|
-
for await (const chunk of stream) {
|
|
112
|
-
this.output.stopThinking();
|
|
113
|
-
|
|
114
|
-
// Check for structured tool messages
|
|
115
|
-
if (chunk.includes('@@TOOL@@')) {
|
|
116
|
-
const parts = chunk.split('\n');
|
|
117
|
-
for (const part of parts) {
|
|
118
|
-
if (part.startsWith('@@TOOL@@')) {
|
|
119
|
-
try {
|
|
120
|
-
const data = JSON.parse(part.slice(8));
|
|
121
|
-
if (data.action === 'call') {
|
|
122
|
-
if (hasStartedOutput) {
|
|
123
|
-
this.output.endAssistant();
|
|
124
|
-
hasStartedOutput = false;
|
|
125
|
-
}
|
|
126
|
-
this.output.printToolCall(data.name, data.args || '');
|
|
127
|
-
this.output.startExecuting(data.name);
|
|
128
|
-
} else if (data.action === 'result') {
|
|
129
|
-
this.output.stopThinking();
|
|
130
|
-
this.output.printToolResult(data.output || data.error || '', !!data.error);
|
|
131
|
-
this.output.printToolEnd();
|
|
132
|
-
}
|
|
133
|
-
} catch {
|
|
134
|
-
// If parse fails, treat as regular text
|
|
135
|
-
if (part) {
|
|
136
|
-
if (!hasStartedOutput) {
|
|
137
|
-
this.output.beginAssistant();
|
|
138
|
-
hasStartedOutput = true;
|
|
139
|
-
}
|
|
140
|
-
this.output.writeChunk(part);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
} else if (part) {
|
|
144
|
-
// Regular text between tool messages
|
|
145
|
-
if (!hasStartedOutput) {
|
|
146
|
-
this.output.beginAssistant();
|
|
147
|
-
hasStartedOutput = true;
|
|
148
|
-
}
|
|
149
|
-
this.output.writeChunk(part + '\n');
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
} else {
|
|
153
|
-
// Pure text chunk - just output it
|
|
154
|
-
if (!hasStartedOutput) {
|
|
155
|
-
this.output.beginAssistant();
|
|
156
|
-
hasStartedOutput = true;
|
|
157
|
-
}
|
|
158
|
-
this.output.writeChunk(chunk);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
fullResponse += chunk;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
if (hasStartedOutput) {
|
|
165
|
-
this.output.endAssistant();
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
if (fullResponse.trim()) {
|
|
169
|
-
this.app.session.addMessage('assistant', fullResponse);
|
|
170
|
-
this.app.session.truncate();
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
} catch (error: any) {
|
|
174
|
-
if (hasStartedOutput) {
|
|
175
|
-
this.output.endAssistant();
|
|
176
|
-
}
|
|
177
|
-
this.output.stopThinkingFail(error.message);
|
|
178
|
-
this.output.error(error.message);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|