thatgfsj-code 0.7.1 → 0.7.3
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/prompts/index.d.ts.map +1 -1
- package/dist/prompts/index.js +13 -1
- package/dist/prompts/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.js +1 -1
- package/dist/tui/components/ChatList.js.map +1 -1
- package/dist/tui/components/Header.js +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/hooks/useChat.d.ts +1 -1
- package/dist/tui/hooks/useChat.d.ts.map +1 -1
- package/dist/tui/hooks/useChat.js +86 -97
- package/dist/tui/hooks/useChat.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/prompts/index.ts +13 -1
- 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 +1 -1
- package/src/tui/components/Header.tsx +1 -1
- package/src/tui/components/Thinking.tsx +7 -1
- package/src/tui/hooks/useChat.ts +85 -97
- 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/dist/tui/app.js
CHANGED
|
@@ -35,6 +35,6 @@ export function TuiApp({ app }) {
|
|
|
35
35
|
}, [handleCommand, sendMessage]);
|
|
36
36
|
const allMessages = [...systemMessages, ...messages];
|
|
37
37
|
const activeSkills = app.skills.listActive().map(s => s.id);
|
|
38
|
-
return (_jsxs(Box, { flexDirection: "column", paddingX: 1, children: [_jsx(Header, { provider: config.provider, model: config.model }), _jsx(ChatList, { messages: allMessages, streaming: streaming, streamingToolCalls: streamingToolCalls, width: terminalWidth - 4 }),
|
|
38
|
+
return (_jsxs(Box, { flexDirection: "column", paddingX: 1, children: [_jsx(Header, { provider: config.provider, model: config.model }), _jsx(ChatList, { messages: allMessages, streaming: streaming, streamingToolCalls: streamingToolCalls, width: terminalWidth - 4 }), _jsx(Thinking, { active: isThinking }), _jsx(UserInput, { onSubmit: onSubmit, disabled: isThinking }), _jsx(StatusBar, { messageCount: allMessages.length, skills: activeSkills })] }));
|
|
39
39
|
}
|
|
40
40
|
//# sourceMappingURL=app.js.map
|
package/dist/tui/app.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/tui/app.tsx"],"names":[],"m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;iBAC/C,CAAC,CAAC;YACL,CAAC;YACD,IAAI,KAAK,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,KAAK,OAAO,EAAE,CAAC;gBAC3C,iBAAiB,CAAC,EAAE,CAAC,CAAC;YACxB,CAAC;YACD,OAAO;QACT,CAAC;QACD,MAAM,WAAW,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC,EAAE,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC,CAAC;IAEjC,MAAM,WAAW,GAAG,CAAC,GAAG,cAAc,EAAE,GAAG,QAAQ,CAAC,CAAC;IACrD,MAAM,YAAY,GAAG,GAAG,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAE5D,OAAO,CACL,MAAC,GAAG,IAAC,aAAa,EAAC,QAAQ,EAAC,QAAQ,EAAE,CAAC,aACrC,KAAC,MAAM,IAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,GAAI,EAC1D,KAAC,QAAQ,IACP,QAAQ,EAAE,WAAW,EACrB,SAAS,EAAE,SAAS,EACpB,kBAAkB,EAAE,kBAAkB,EACtC,KAAK,EAAE,aAAa,GAAG,CAAC,GACxB,EACF,KAAC,QAAQ,IAAC,MAAM,EAAE,UAAU,GAAI,EAChC,KAAC,SAAS,IAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,GAAI,EACvD,KAAC,SAAS,IAAC,YAAY,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,GAAI,IACjE,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -4,7 +4,7 @@ import { memo } from 'react';
|
|
|
4
4
|
import { Box } from 'ink';
|
|
5
5
|
import { ChatMessage } from './ChatMessage.js';
|
|
6
6
|
export const ChatList = memo(function ChatList({ messages, streaming, streamingToolCalls, width }) {
|
|
7
|
-
return (_jsxs(Box, { flexDirection: "column",
|
|
7
|
+
return (_jsxs(Box, { flexDirection: "column", children: [messages.map((msg, i) => (_jsx(ChatMessage, { message: msg, width: width }, i))), (streaming || streamingToolCalls) && (_jsx(ChatMessage, { message: {
|
|
8
8
|
role: 'assistant',
|
|
9
9
|
content: streaming || '',
|
|
10
10
|
toolCalls: streamingToolCalls,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatList.js","sourceRoot":"","sources":["../../../src/tui/components/ChatList.tsx"],"names":[],"mappings":";AAAA,6BAA6B;AAC7B,OAAc,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAoB,MAAM,kBAAkB,CAAC;AAUjE,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,QAAQ,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,kBAAkB,EAAE,KAAK,EAAS;IACtG,OAAO,CACL,MAAC,GAAG,IAAC,aAAa,EAAC,QAAQ,
|
|
1
|
+
{"version":3,"file":"ChatList.js","sourceRoot":"","sources":["../../../src/tui/components/ChatList.tsx"],"names":[],"mappings":";AAAA,6BAA6B;AAC7B,OAAc,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAoB,MAAM,kBAAkB,CAAC;AAUjE,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,QAAQ,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,kBAAkB,EAAE,KAAK,EAAS;IACtG,OAAO,CACL,MAAC,GAAG,IAAC,aAAa,EAAC,QAAQ,aACxB,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CACxB,KAAC,WAAW,IAAS,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,IAA7B,CAAC,CAAgC,CACpD,CAAC,EACD,CAAC,SAAS,IAAI,kBAAkB,CAAC,IAAI,CACpC,KAAC,WAAW,IACV,OAAO,EAAE;oBACP,IAAI,EAAE,WAAW;oBACjB,OAAO,EAAE,SAAS,IAAI,EAAE;oBACxB,SAAS,EAAE,kBAAkB;iBAC9B,EACD,KAAK,EAAE,KAAK,GACZ,CACH,IACG,CACP,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -3,6 +3,6 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { Box, Text } from 'ink';
|
|
5
5
|
export const Header = React.memo(function Header({ provider, model }) {
|
|
6
|
-
return (_jsxs(Box, { flexDirection: "column", marginBottom: 0, children: [_jsxs(Box, { justifyContent: "space-between", width: "100%", children: [_jsxs(Box, { children: [_jsx(Text, { color: "#06B6D4", bold: true, children: " \u26A1 " }), _jsx(Text, { color: "#22D3EE", bold: true, children: "THATGFSJ CODE" }), _jsx(Text, { dimColor: true, children: " v0.7.
|
|
6
|
+
return (_jsxs(Box, { flexDirection: "column", marginBottom: 0, children: [_jsxs(Box, { justifyContent: "space-between", width: "100%", children: [_jsxs(Box, { children: [_jsx(Text, { color: "#06B6D4", bold: true, children: " \u26A1 " }), _jsx(Text, { color: "#22D3EE", bold: true, children: "THATGFSJ CODE" }), _jsx(Text, { dimColor: true, children: " v0.7.3" })] }), _jsxs(Box, { children: [_jsxs(Text, { color: "#06B6D4", bold: true, children: [" ", provider, " "] }), _jsx(Text, { dimColor: true, children: "/" }), _jsxs(Text, { color: "#22D3EE", children: [" ", model, " "] })] })] }), _jsx(Text, { color: "#374151", children: '─'.repeat(80) })] }));
|
|
7
7
|
});
|
|
8
8
|
//# sourceMappingURL=Header.js.map
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/** @jsxImportSource react */
|
|
2
2
|
import React from 'react';
|
|
3
3
|
interface Props {
|
|
4
|
+
active?: boolean;
|
|
4
5
|
message?: string;
|
|
5
6
|
}
|
|
6
|
-
export declare function Thinking({ message }: Props): React.JSX.Element;
|
|
7
|
+
export declare function Thinking({ active, message }: Props): React.JSX.Element;
|
|
7
8
|
export {};
|
|
8
9
|
//# sourceMappingURL=Thinking.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Thinking.d.ts","sourceRoot":"","sources":["../../../src/tui/components/Thinking.tsx"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,UAAU,KAAK;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,QAAQ,CAAC,EAAE,OAAoB,EAAE,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"Thinking.d.ts","sourceRoot":"","sources":["../../../src/tui/components/Thinking.tsx"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,UAAU,KAAK;IACb,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,QAAQ,CAAC,EAAE,MAAa,EAAE,OAAoB,EAAE,EAAE,KAAK,qBActE"}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Box, Text } from 'ink';
|
|
3
3
|
import Spinner from 'ink-spinner';
|
|
4
|
-
export function Thinking({ message = 'Thinking' }) {
|
|
4
|
+
export function Thinking({ active = true, message = 'Thinking' }) {
|
|
5
|
+
if (!active) {
|
|
6
|
+
// Keep layout stable - render empty space
|
|
7
|
+
return _jsx(Box, { paddingY: 0, children: _jsx(Text, { children: " " }) });
|
|
8
|
+
}
|
|
5
9
|
return (_jsxs(Box, { paddingLeft: 1, children: [_jsx(Text, { color: "#06B6D4", children: _jsx(Spinner, { type: "dots" }) }), _jsxs(Text, { color: "#06B6D4", children: [" ", message] })] }));
|
|
6
10
|
}
|
|
7
11
|
//# sourceMappingURL=Thinking.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Thinking.js","sourceRoot":"","sources":["../../../src/tui/components/Thinking.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAChC,OAAO,OAAO,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"Thinking.js","sourceRoot":"","sources":["../../../src/tui/components/Thinking.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAChC,OAAO,OAAO,MAAM,aAAa,CAAC;AAOlC,MAAM,UAAU,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,OAAO,GAAG,UAAU,EAAS;IACrE,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,0CAA0C;QAC1C,OAAO,KAAC,GAAG,IAAC,QAAQ,EAAE,CAAC,YAAE,KAAC,IAAI,oBAAS,GAAM,CAAC;IAChD,CAAC;IAED,OAAO,CACL,MAAC,GAAG,IAAC,WAAW,EAAE,CAAC,aACjB,KAAC,IAAI,IAAC,KAAK,EAAC,SAAS,YACnB,KAAC,OAAO,IAAC,IAAI,EAAC,MAAM,GAAG,GAClB,EACP,MAAC,IAAI,IAAC,KAAK,EAAC,SAAS,kBAAG,OAAO,IAAQ,IACnC,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -2,7 +2,7 @@ import type { MessageData } from '../components/ChatMessage.js';
|
|
|
2
2
|
import type { ToolCallData } from '../components/ToolCall.js';
|
|
3
3
|
import type { App } from '../../app/index.js';
|
|
4
4
|
export declare function useChat(app: App): {
|
|
5
|
-
sendMessage: (input: string) =>
|
|
5
|
+
sendMessage: (input: string) => void;
|
|
6
6
|
messages: MessageData[];
|
|
7
7
|
isThinking: boolean;
|
|
8
8
|
streaming: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useChat.d.ts","sourceRoot":"","sources":["../../../src/tui/hooks/useChat.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAS9C,wBAAgB,OAAO,CAAC,GAAG,EAAE,GAAG;
|
|
1
|
+
{"version":3,"file":"useChat.d.ts","sourceRoot":"","sources":["../../../src/tui/hooks/useChat.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAS9C,wBAAgB,OAAO,CAAC,GAAG,EAAE,GAAG;yBAUU,MAAM;cAhBpC,WAAW,EAAE;gBACX,OAAO;eACR,MAAM;wBACG,YAAY,EAAE;EAoInC"}
|
|
@@ -7,10 +7,12 @@ export function useChat(app) {
|
|
|
7
7
|
streamingToolCalls: [],
|
|
8
8
|
});
|
|
9
9
|
const processingRef = useRef(false);
|
|
10
|
-
const
|
|
10
|
+
const abortRef = useRef(false);
|
|
11
|
+
const sendMessage = useCallback((input) => {
|
|
11
12
|
if (processingRef.current)
|
|
12
13
|
return;
|
|
13
14
|
processingRef.current = true;
|
|
15
|
+
abortRef.current = false;
|
|
14
16
|
// Add user message
|
|
15
17
|
setState(prev => ({
|
|
16
18
|
...prev,
|
|
@@ -20,115 +22,102 @@ export function useChat(app) {
|
|
|
20
22
|
streamingToolCalls: [],
|
|
21
23
|
}));
|
|
22
24
|
app.session.addMessage('user', input);
|
|
25
|
+
// Process stream in background (non-blocking)
|
|
26
|
+
const stream = app.streamResponse();
|
|
23
27
|
let fullContent = '';
|
|
24
28
|
let currentToolCalls = [];
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
29
|
+
const processStream = async () => {
|
|
30
|
+
try {
|
|
31
|
+
for await (const chunk of stream) {
|
|
32
|
+
if (abortRef.current)
|
|
33
|
+
break;
|
|
34
|
+
if (chunk.includes('@@TOOL@@')) {
|
|
35
|
+
const parts = chunk.split('\n');
|
|
36
|
+
for (const part of parts) {
|
|
37
|
+
if (part.startsWith('@@TOOL@@')) {
|
|
38
|
+
try {
|
|
39
|
+
const data = JSON.parse(part.slice(8));
|
|
40
|
+
if (data.action === 'call') {
|
|
41
|
+
currentToolCalls.push({ name: data.name, args: data.args || '' });
|
|
42
|
+
setState(prev => ({
|
|
43
|
+
...prev,
|
|
44
|
+
isThinking: false,
|
|
45
|
+
streamingToolCalls: [...currentToolCalls],
|
|
46
|
+
}));
|
|
47
|
+
}
|
|
48
|
+
else if (data.action === 'result') {
|
|
49
|
+
const lastIdx = currentToolCalls.length - 1;
|
|
50
|
+
if (lastIdx >= 0) {
|
|
51
|
+
currentToolCalls[lastIdx] = {
|
|
52
|
+
...currentToolCalls[lastIdx],
|
|
53
|
+
result: data.output || data.error || '',
|
|
54
|
+
isError: !!data.error,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
setState(prev => ({
|
|
58
|
+
...prev,
|
|
59
|
+
streamingToolCalls: [...currentToolCalls],
|
|
60
|
+
isThinking: true,
|
|
61
|
+
}));
|
|
56
62
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}));
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
fullContent += part;
|
|
66
|
+
setState(prev => ({ ...prev, isThinking: false, streaming: fullContent }));
|
|
62
67
|
}
|
|
63
68
|
}
|
|
64
|
-
|
|
65
|
-
// Not a tool message, treat as text
|
|
69
|
+
else if (part) {
|
|
66
70
|
fullContent += part;
|
|
67
|
-
setState(prev => ({
|
|
68
|
-
...prev,
|
|
69
|
-
isThinking: false,
|
|
70
|
-
streaming: fullContent,
|
|
71
|
-
}));
|
|
71
|
+
setState(prev => ({ ...prev, isThinking: false, streaming: fullContent }));
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
isThinking: false,
|
|
79
|
-
streaming: fullContent,
|
|
80
|
-
}));
|
|
81
|
-
}
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
fullContent += chunk;
|
|
77
|
+
setState(prev => ({ ...prev, isThinking: false, streaming: fullContent }));
|
|
82
78
|
}
|
|
83
79
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
fullContent
|
|
87
|
-
setState(prev => ({
|
|
88
|
-
...prev,
|
|
89
|
-
isThinking: false,
|
|
90
|
-
streaming: fullContent,
|
|
91
|
-
}));
|
|
80
|
+
// Finalize
|
|
81
|
+
if (fullContent.trim() || currentToolCalls.length > 0) {
|
|
82
|
+
app.session.addMessage('assistant', fullContent);
|
|
92
83
|
}
|
|
84
|
+
setState(prev => ({
|
|
85
|
+
...prev,
|
|
86
|
+
messages: [
|
|
87
|
+
...prev.messages,
|
|
88
|
+
...(fullContent.trim() || currentToolCalls.length > 0
|
|
89
|
+
? [{
|
|
90
|
+
role: 'assistant',
|
|
91
|
+
content: fullContent,
|
|
92
|
+
toolCalls: currentToolCalls.length > 0 ? currentToolCalls : undefined,
|
|
93
|
+
}]
|
|
94
|
+
: []),
|
|
95
|
+
],
|
|
96
|
+
streaming: '',
|
|
97
|
+
streamingToolCalls: [],
|
|
98
|
+
isThinking: false,
|
|
99
|
+
}));
|
|
100
|
+
app.session.truncate();
|
|
93
101
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
102
|
+
catch (error) {
|
|
103
|
+
setState(prev => ({
|
|
104
|
+
...prev,
|
|
105
|
+
messages: [
|
|
106
|
+
...prev.messages,
|
|
107
|
+
...(fullContent.trim()
|
|
108
|
+
? [{ role: 'assistant', content: fullContent }]
|
|
109
|
+
: []),
|
|
110
|
+
{ role: 'assistant', content: `Error: ${error.message}` },
|
|
111
|
+
],
|
|
112
|
+
streaming: '',
|
|
113
|
+
streamingToolCalls: [],
|
|
114
|
+
isThinking: false,
|
|
115
|
+
}));
|
|
97
116
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
...(fullContent.trim() || currentToolCalls.length > 0
|
|
103
|
-
? [{
|
|
104
|
-
role: 'assistant',
|
|
105
|
-
content: fullContent,
|
|
106
|
-
toolCalls: currentToolCalls.length > 0 ? currentToolCalls : undefined,
|
|
107
|
-
}]
|
|
108
|
-
: []),
|
|
109
|
-
],
|
|
110
|
-
streaming: '',
|
|
111
|
-
streamingToolCalls: [],
|
|
112
|
-
isThinking: false,
|
|
113
|
-
}));
|
|
114
|
-
app.session.truncate();
|
|
115
|
-
}
|
|
116
|
-
catch (error) {
|
|
117
|
-
setState(prev => ({
|
|
118
|
-
...prev,
|
|
119
|
-
messages: [
|
|
120
|
-
...prev.messages,
|
|
121
|
-
...(fullContent.trim()
|
|
122
|
-
? [{ role: 'assistant', content: fullContent }]
|
|
123
|
-
: []),
|
|
124
|
-
{ role: 'assistant', content: `Error: ${error.message}` },
|
|
125
|
-
],
|
|
126
|
-
streaming: '',
|
|
127
|
-
streamingToolCalls: [],
|
|
128
|
-
isThinking: false,
|
|
129
|
-
}));
|
|
130
|
-
}
|
|
131
|
-
processingRef.current = false;
|
|
117
|
+
processingRef.current = false;
|
|
118
|
+
};
|
|
119
|
+
// Start processing without blocking
|
|
120
|
+
processStream();
|
|
132
121
|
}, [app]);
|
|
133
122
|
return {
|
|
134
123
|
...state,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useChat.js","sourceRoot":"","sources":["../../../src/tui/hooks/useChat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"useChat.js","sourceRoot":"","sources":["../../../src/tui/hooks/useChat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAa,MAAM,OAAO,CAAC;AAYjE,MAAM,UAAU,OAAO,CAAC,GAAQ;IAC9B,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAY;QAC5C,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,KAAK;QACjB,SAAS,EAAE,EAAE;QACb,kBAAkB,EAAE,EAAE;KACvB,CAAC,CAAC;IACH,MAAM,aAAa,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IACpC,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAE/B,MAAM,WAAW,GAAG,WAAW,CAAC,CAAC,KAAa,EAAE,EAAE;QAChD,IAAI,aAAa,CAAC,OAAO;YAAE,OAAO;QAClC,aAAa,CAAC,OAAO,GAAG,IAAI,CAAC;QAC7B,QAAQ,CAAC,OAAO,GAAG,KAAK,CAAC;QAEzB,mBAAmB;QACnB,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAChB,GAAG,IAAI;YACP,QAAQ,EAAE,CAAC,GAAG,IAAI,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;YAC9D,UAAU,EAAE,IAAI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U,EAAE,KAAK;iBAClB,CAAC,CAAC,CAAC;YACN,CAAC;YAED,aAAa,CAAC,OAAO,GAAG,KAAK,CAAC;QAChC,CAAC,CAAC;QAEF,oCAAoC;QACpC,aAAa,EAAE,CAAC;IAClB,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAEV,OAAO;QACL,GAAG,KAAK;QACR,WAAW;KACZ,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
package/src/app/index.ts
CHANGED
|
@@ -52,6 +52,12 @@ export class App {
|
|
|
52
52
|
// Register tools with LLM service
|
|
53
53
|
llm.registerTools(tools.list());
|
|
54
54
|
|
|
55
|
+
// Auto-init NWT timeline
|
|
56
|
+
const nwtTool = tools.get('nwt');
|
|
57
|
+
if (nwtTool) {
|
|
58
|
+
await nwtTool.execute({ action: 'init' });
|
|
59
|
+
}
|
|
60
|
+
|
|
55
61
|
// Build system prompt with active skills
|
|
56
62
|
const prompts = new SystemPromptBuilder({
|
|
57
63
|
cwd: process.cwd(),
|
package/src/cmd/index.tsx
CHANGED
|
@@ -2,14 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Thatgfsj Code - CLI Entry Point
|
|
5
|
-
*
|
|
6
|
-
* Two modes:
|
|
7
|
-
* gfcode → Interactive TUI (Ink)
|
|
8
|
-
* gfcode "prompt" → Single prompt mode
|
|
9
|
-
* gfcode init → Setup wizard
|
|
10
5
|
*/
|
|
11
6
|
|
|
12
|
-
// Force UTF-8 on Windows
|
|
13
7
|
if (process.platform === 'win32') {
|
|
14
8
|
try {
|
|
15
9
|
require('child_process').execSync('chcp 65001', { stdio: 'ignore', windowsHide: true });
|
|
@@ -20,9 +14,6 @@ import { program } from 'commander';
|
|
|
20
14
|
import chalk from 'chalk';
|
|
21
15
|
import { App } from '../app/index.js';
|
|
22
16
|
import { WelcomeScreen } from '../tui/welcome.js';
|
|
23
|
-
import { REPLOutput } from '../tui/output.js';
|
|
24
|
-
|
|
25
|
-
// ==================== Error Handling ====================
|
|
26
17
|
|
|
27
18
|
process.on('uncaughtException', (error) => {
|
|
28
19
|
console.error(chalk.red('\n Error:'), error.message);
|
|
@@ -34,61 +25,50 @@ process.on('unhandledRejection', (reason) => {
|
|
|
34
25
|
process.exit(1);
|
|
35
26
|
});
|
|
36
27
|
|
|
37
|
-
// ==================== CLI Commands ====================
|
|
38
|
-
|
|
39
28
|
program
|
|
40
29
|
.name('gfcode')
|
|
41
30
|
.description('Thatgfsj Code - AI Coding Assistant')
|
|
42
|
-
.version('0.7.
|
|
31
|
+
.version('0.7.3')
|
|
43
32
|
.argument('[prompt]', 'Task to execute (omit to start interactive mode)')
|
|
44
33
|
.option('-m, --model <model>', 'Specify model')
|
|
45
34
|
.option('-i, --interactive', 'Force interactive mode')
|
|
46
35
|
.action(async (prompt: string | undefined, options: { model?: string; interactive?: boolean }) => {
|
|
47
36
|
try {
|
|
48
37
|
const app = await App.create();
|
|
49
|
-
|
|
50
|
-
// Show welcome if no API key
|
|
51
38
|
WelcomeScreen.show(app.config.hasApiKey());
|
|
52
39
|
|
|
53
|
-
// Override model if specified
|
|
54
40
|
if (options.model) {
|
|
55
41
|
await app.config.save({ model: options.model });
|
|
56
42
|
}
|
|
57
43
|
|
|
58
44
|
if (!prompt || options.interactive) {
|
|
59
|
-
// Interactive mode -
|
|
45
|
+
// Interactive mode - Ink TUI
|
|
60
46
|
const { render } = await import('ink');
|
|
61
47
|
const { TuiApp } = await import('../tui/app.js');
|
|
62
|
-
|
|
63
48
|
const { unmount } = render(<TuiApp app={app} />);
|
|
64
|
-
|
|
65
|
-
// Wait for the app to exit
|
|
66
49
|
await new Promise<void>((resolve) => {
|
|
67
|
-
|
|
68
|
-
// Ink will call process.exit or we detect it
|
|
69
|
-
}, 1000);
|
|
70
|
-
process.on('exit', () => {
|
|
71
|
-
clearInterval(check);
|
|
72
|
-
unmount();
|
|
73
|
-
resolve();
|
|
74
|
-
});
|
|
50
|
+
process.on('exit', () => { unmount(); resolve(); });
|
|
75
51
|
});
|
|
76
52
|
} else {
|
|
77
|
-
// Single prompt mode
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
53
|
+
// Single prompt mode
|
|
54
|
+
console.log(chalk.cyan.bold('\n ⚡ THATGFSJ CODE\n'));
|
|
55
|
+
console.log(chalk.gray(' You'));
|
|
56
|
+
console.log(chalk.gray(' ' + '─'.repeat(40)));
|
|
57
|
+
console.log(' ' + prompt);
|
|
58
|
+
console.log();
|
|
82
59
|
|
|
83
60
|
app.session.addMessage('user', prompt);
|
|
84
61
|
let fullResponse = '';
|
|
85
|
-
let hasStarted = false;
|
|
86
62
|
|
|
87
63
|
try {
|
|
64
|
+
process.stdout.write(chalk.gray(' Thinking...\r'));
|
|
88
65
|
const stream = app.streamResponse();
|
|
66
|
+
|
|
89
67
|
for await (const chunk of stream) {
|
|
90
|
-
|
|
68
|
+
// Clear thinking line
|
|
69
|
+
process.stdout.write('\r' + ' '.repeat(40) + '\r');
|
|
91
70
|
|
|
71
|
+
// Parse tool messages
|
|
92
72
|
if (chunk.includes('@@TOOL@@')) {
|
|
93
73
|
const parts = chunk.split('\n');
|
|
94
74
|
for (const part of parts) {
|
|
@@ -96,34 +76,31 @@ program
|
|
|
96
76
|
try {
|
|
97
77
|
const data = JSON.parse(part.slice(8));
|
|
98
78
|
if (data.action === 'call') {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
out.startExecuting(data.name);
|
|
79
|
+
console.log();
|
|
80
|
+
console.log(chalk.cyan(` ⚙ ${data.name}: ${formatArgs(data.args)}`));
|
|
102
81
|
} else if (data.action === 'result') {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
82
|
+
const output = data.output || data.error || '';
|
|
83
|
+
const lines = output.split('\n').slice(0, 10);
|
|
84
|
+
for (const line of lines) {
|
|
85
|
+
console.log(chalk.gray(' │ ') + line);
|
|
86
|
+
}
|
|
106
87
|
}
|
|
107
88
|
} catch {}
|
|
108
89
|
} else if (part) {
|
|
109
|
-
|
|
110
|
-
out.writeChunk(part + '\n');
|
|
90
|
+
process.stdout.write(chalk.cyan(' │ ') + part);
|
|
111
91
|
}
|
|
112
92
|
}
|
|
113
93
|
} else {
|
|
114
|
-
|
|
115
|
-
out.writeChunk(chunk);
|
|
94
|
+
process.stdout.write(chunk);
|
|
116
95
|
}
|
|
117
96
|
fullResponse += chunk;
|
|
118
97
|
}
|
|
119
|
-
|
|
98
|
+
|
|
99
|
+
console.log();
|
|
100
|
+
app.session.addMessage('assistant', fullResponse);
|
|
120
101
|
} catch (error: any) {
|
|
121
|
-
|
|
122
|
-
out.stopThinkingFail(error.message);
|
|
123
|
-
out.error(error.message);
|
|
102
|
+
console.error(chalk.red(`\n Error: ${error.message}`));
|
|
124
103
|
}
|
|
125
|
-
|
|
126
|
-
app.session.addMessage('assistant', fullResponse);
|
|
127
104
|
}
|
|
128
105
|
} catch (error: any) {
|
|
129
106
|
console.error(chalk.red(`\n ${error.message}`));
|
|
@@ -131,7 +108,6 @@ program
|
|
|
131
108
|
}
|
|
132
109
|
});
|
|
133
110
|
|
|
134
|
-
// Init command
|
|
135
111
|
program
|
|
136
112
|
.command('init')
|
|
137
113
|
.description('Configure API key and model')
|
|
@@ -140,3 +116,14 @@ program
|
|
|
140
116
|
});
|
|
141
117
|
|
|
142
118
|
program.parse(process.argv);
|
|
119
|
+
|
|
120
|
+
function formatArgs(args: string): string {
|
|
121
|
+
try {
|
|
122
|
+
const obj = JSON.parse(args);
|
|
123
|
+
return Object.entries(obj)
|
|
124
|
+
.map(([k, v]) => `${k}=${typeof v === 'string' && v.length > 40 ? v.slice(0, 40) + '...' : JSON.stringify(v)}`)
|
|
125
|
+
.join(' ');
|
|
126
|
+
} catch {
|
|
127
|
+
return args.length > 60 ? args.slice(0, 60) + '...' : args;
|
|
128
|
+
}
|
|
129
|
+
}
|
package/src/prompts/index.ts
CHANGED
|
@@ -99,7 +99,19 @@ export class SystemPromptBuilder {
|
|
|
99
99
|
if (!this.config.includeProjectMd) return '';
|
|
100
100
|
|
|
101
101
|
const cwd = this.config.cwd;
|
|
102
|
-
const
|
|
102
|
+
const home = process.env.USERPROFILE || process.env.HOME || '';
|
|
103
|
+
const paths = [
|
|
104
|
+
join(cwd, 'CLAUDE.md'),
|
|
105
|
+
join(cwd, '.claude.md'),
|
|
106
|
+
join(cwd, 'AGENTS.md'),
|
|
107
|
+
join(cwd, 'Codex.md'),
|
|
108
|
+
join(cwd, '.Codex.md'),
|
|
109
|
+
join(cwd, 'CODEX.md'),
|
|
110
|
+
join(cwd, '.codex.md'),
|
|
111
|
+
join(home, '.Codex', 'SKILLS.md'),
|
|
112
|
+
join(home, '.agents', 'AGENTS.md'),
|
|
113
|
+
join(home, '.claude', 'CLAUDE.md'),
|
|
114
|
+
];
|
|
103
115
|
|
|
104
116
|
for (const path of paths) {
|
|
105
117
|
if (existsSync(path)) {
|