thatgfsj-code 0.7.2 → 0.7.4
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 +94 -63
- package/dist/cmd/index.js +37 -3
- 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/tui/components/Header.js +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 +98 -97
- package/dist/tui/hooks/useChat.js.map +1 -1
- package/package.json +1 -1
- package/src/cmd/index.tsx +34 -3
- package/src/prompts/index.ts +13 -1
- package/src/tui/components/Header.tsx +1 -1
- package/src/tui/hooks/useChat.ts +100 -100
package/README.md
CHANGED
|
@@ -1,29 +1,36 @@
|
|
|
1
|
-
# Thatgfsj Code
|
|
1
|
+
# Thatgfsj Code ⚡
|
|
2
2
|
|
|
3
|
-
AI 编程助手
|
|
3
|
+
AI 编程助手 — 终端里的 AI 编程伙伴
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## 特性
|
|
8
8
|
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
9
|
+
- **Ink TUI** — React 驱动的终端 UI,流式输出、Markdown 渲染
|
|
10
|
+
- **工具调用** — AI 可以读写文件、执行命令、搜索代码、操作 Git
|
|
11
|
+
- **16 个内置 Skills** — 规划、调试、TDD、架构优化、代码审查等
|
|
12
|
+
- **NeuroWeave Timeline** — 项目演进记忆,自动归档(30天)
|
|
13
|
+
- **多 Provider** — 15 个平台 + 自定义中转站
|
|
14
|
+
- **上下文压缩** — 超限自动压缩,节省 token
|
|
15
|
+
- **Playwright** — 浏览器自动化(测试/抓取/截图)
|
|
14
16
|
|
|
15
17
|
---
|
|
16
18
|
|
|
17
|
-
##
|
|
19
|
+
## 快速开始
|
|
18
20
|
|
|
19
21
|
### 安装
|
|
20
22
|
|
|
21
|
-
**Windows
|
|
23
|
+
**Windows(一键安装,自动下载 Node.js):**
|
|
22
24
|
```powershell
|
|
23
|
-
irm https://
|
|
25
|
+
irm https://www.thatgfsj.xyz/install/gfcode.ps1 | iex
|
|
24
26
|
```
|
|
25
27
|
|
|
26
|
-
**
|
|
28
|
+
**Linux / macOS:**
|
|
29
|
+
```bash
|
|
30
|
+
curl -fsSL https://www.thatgfsj.xyz/install/gfcode.sh | bash
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**npm(已有 Node.js):**
|
|
27
34
|
```bash
|
|
28
35
|
npm install -g thatgfsj-code
|
|
29
36
|
```
|
|
@@ -31,101 +38,125 @@ npm install -g thatgfsj-code
|
|
|
31
38
|
### 配置
|
|
32
39
|
|
|
33
40
|
```bash
|
|
34
|
-
# 交互式配置向导(推荐)
|
|
35
41
|
gfcode init
|
|
36
|
-
|
|
37
|
-
# 或手动设置环境变量
|
|
38
|
-
export OPENAI_API_KEY="sk-..."
|
|
39
|
-
export SILICONFLOW_API_KEY="sk-..."
|
|
40
42
|
```
|
|
41
43
|
|
|
44
|
+
交互式选择 Provider → 输入 API Key → 选模型 → 设上下文长度。
|
|
45
|
+
|
|
42
46
|
---
|
|
43
47
|
|
|
44
|
-
##
|
|
48
|
+
## 使用
|
|
45
49
|
|
|
46
50
|
```bash
|
|
47
|
-
#
|
|
51
|
+
# 交互模式(Ink TUI)
|
|
48
52
|
gfcode
|
|
49
53
|
|
|
50
54
|
# 单次 prompt
|
|
51
|
-
gfcode "帮我写一个
|
|
55
|
+
gfcode "帮我写一个 Hello World"
|
|
52
56
|
|
|
53
57
|
# 指定模型
|
|
54
58
|
gfcode -m gpt-4o "你的任务"
|
|
55
|
-
|
|
56
|
-
# 启用审计日志
|
|
57
|
-
gfcode --hooks "你的任务"
|
|
58
59
|
```
|
|
59
60
|
|
|
60
|
-
###
|
|
61
|
+
### 内置命令
|
|
61
62
|
|
|
62
63
|
| 命令 | 说明 |
|
|
63
64
|
|------|------|
|
|
64
65
|
| `help` | 显示帮助 |
|
|
65
66
|
| `tools` | 列出可用工具 |
|
|
66
67
|
| `model` | 显示当前模型 |
|
|
68
|
+
| `skill list` | 查看所有 Skills |
|
|
69
|
+
| `skill <id>` | 切换 Skill |
|
|
67
70
|
| `clear` | 清屏 |
|
|
68
71
|
| `exit` | 退出 |
|
|
69
72
|
|
|
70
73
|
---
|
|
71
74
|
|
|
72
|
-
##
|
|
73
|
-
|
|
74
|
-
```
|
|
75
|
-
src/
|
|
76
|
-
├── cmd/ # CLI 入口 (commander)
|
|
77
|
-
├── app/ # 核心应用服务 + Agent Loop
|
|
78
|
-
├── config/ # 配置管理 + Provider 定义
|
|
79
|
-
├── llm/ # LLM Provider 抽象层
|
|
80
|
-
│ ├── openai.ts # OpenAI 兼容 (SiliconFlow/DeepSeek/Kimi/...)
|
|
81
|
-
│ ├── anthropic.ts # Anthropic Claude
|
|
82
|
-
│ └── gemini.ts # Google Gemini
|
|
83
|
-
├── session/ # 会话与消息管理
|
|
84
|
-
├── tools/ # 工具系统 (file/shell/git/search)
|
|
85
|
-
├── tui/ # 终端 UI (REPL)
|
|
86
|
-
├── mcp/ # MCP 协议支持
|
|
87
|
-
├── hooks/ # 生命周期钩子
|
|
88
|
-
├── prompts/ # 系统提示构建
|
|
89
|
-
├── utils/ # 工具函数
|
|
90
|
-
└── types.ts # 全局类型
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
---
|
|
94
|
-
|
|
95
|
-
## 🔌 支持的 Provider
|
|
75
|
+
## 支持的 Provider
|
|
96
76
|
|
|
97
77
|
| Provider | 格式 | 默认模型 |
|
|
98
78
|
|----------|------|----------|
|
|
99
79
|
| SiliconFlow | OpenAI | Qwen2.5-7B |
|
|
100
|
-
| MiniMax | Anthropic | MiniMax-M2.5 |
|
|
101
80
|
| OpenAI | OpenAI | gpt-4o-mini |
|
|
102
|
-
| Anthropic | Anthropic | claude-3-haiku |
|
|
103
|
-
| Gemini | Gemini | gemini-1.5-flash |
|
|
104
81
|
| DeepSeek | OpenAI | deepseek-chat |
|
|
105
|
-
| Kimi | OpenAI |
|
|
106
|
-
|
|
|
107
|
-
|
|
|
82
|
+
| Kimi | OpenAI | kimi-k2.6 |
|
|
83
|
+
| Zhipu GLM | OpenAI | glm-4-flash |
|
|
84
|
+
| MiniMax | OpenAI | MiniMax-Text-01 |
|
|
85
|
+
| Baichuan | OpenAI | Baichuan4 |
|
|
86
|
+
| Stepfun | OpenAI | step-1-flash |
|
|
87
|
+
| Doubao | OpenAI | doubao-1.5-pro-32k |
|
|
88
|
+
| Anthropic | Anthropic | claude-sonnet-4 |
|
|
89
|
+
| Gemini | Gemini | gemini-2.0-flash |
|
|
90
|
+
| ERNIE | OpenAI | ernie-4.5-8k |
|
|
91
|
+
| Ollama | OpenAI | llama3.1 |
|
|
92
|
+
| **自定义 OpenAI** | OpenAI | 中转站 |
|
|
93
|
+
| **自定义 Anthropic** | Anthropic | 中转站 |
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## 内置工具
|
|
98
|
+
|
|
99
|
+
| 工具 | 功能 |
|
|
100
|
+
|------|------|
|
|
101
|
+
| `file` | 读/写/列表/删除文件 |
|
|
102
|
+
| `shell` | 执行 shell 命令 |
|
|
103
|
+
| `git` | Git 操作 |
|
|
104
|
+
| `search` | 代码搜索 |
|
|
105
|
+
| `nwt` | 项目演进记忆(自动归档) |
|
|
108
106
|
|
|
109
107
|
---
|
|
110
108
|
|
|
111
|
-
##
|
|
109
|
+
## 内置 Skills
|
|
110
|
+
|
|
111
|
+
| Skill | 用途 |
|
|
112
|
+
|-------|------|
|
|
113
|
+
| writing-plans | 任务拆解 |
|
|
114
|
+
| executing-plans | 按步骤执行 |
|
|
115
|
+
| systematic-debugging | 结构化调试 |
|
|
116
|
+
| brainstorming | 多方案对比 |
|
|
117
|
+
| tdd | 测试驱动开发 |
|
|
118
|
+
| improve-architecture | 架构优化 |
|
|
119
|
+
| verification | 完成前验证 |
|
|
120
|
+
| code-review | 代码审查 |
|
|
121
|
+
| prototype | 快速原型 |
|
|
122
|
+
| triage | 问题分级 |
|
|
123
|
+
| git-workflow | Git 最佳实践 |
|
|
124
|
+
| subagent | 任务分解 |
|
|
125
|
+
| playwright | 浏览器自动化 |
|
|
126
|
+
| frontend-design | UI/UX 实践 |
|
|
127
|
+
| supabase | 数据库实践 |
|
|
128
|
+
| neuroweave | 项目记忆 |
|
|
112
129
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## 架构
|
|
133
|
+
|
|
134
|
+
```
|
|
135
|
+
src/
|
|
136
|
+
├── cmd/ # CLI 入口
|
|
137
|
+
├── app/ # 核心服务
|
|
138
|
+
├── config/ # 配置 + Provider
|
|
139
|
+
├── llm/ # LLM 抽象层
|
|
140
|
+
├── session/ # 会话 + 自动压缩
|
|
141
|
+
├── tools/ # 工具系统
|
|
142
|
+
├── skills/ # 16 个内置 Skills
|
|
143
|
+
├── tui/ # Ink TUI 组件
|
|
144
|
+
├── mcp/ # MCP 协议
|
|
145
|
+
├── hooks/ # 钩子系统
|
|
146
|
+
├── prompts/ # 系统提示
|
|
147
|
+
├── utils/ # 工具函数
|
|
148
|
+
└── types.ts # 全局类型
|
|
149
|
+
```
|
|
119
150
|
|
|
120
151
|
---
|
|
121
152
|
|
|
122
|
-
##
|
|
153
|
+
## 文档
|
|
123
154
|
|
|
124
155
|
- [API Key 获取教程](./docs/API_KEY_GUIDE.md)
|
|
125
156
|
- [常见问题 FAQ](./docs/FAQ.md)
|
|
126
157
|
|
|
127
158
|
---
|
|
128
159
|
|
|
129
|
-
##
|
|
160
|
+
## 问题反馈
|
|
130
161
|
|
|
131
162
|
https://github.com/Thatgfsj/thatgfsj-code/issues
|
package/dist/cmd/index.js
CHANGED
|
@@ -24,14 +24,33 @@ process.on('unhandledRejection', (reason) => {
|
|
|
24
24
|
program
|
|
25
25
|
.name('gfcode')
|
|
26
26
|
.description('Thatgfsj Code - AI Coding Assistant')
|
|
27
|
-
.version('0.7.
|
|
27
|
+
.version('0.7.4')
|
|
28
28
|
.argument('[prompt]', 'Task to execute (omit to start interactive mode)')
|
|
29
29
|
.option('-m, --model <model>', 'Specify model')
|
|
30
30
|
.option('-i, --interactive', 'Force interactive mode')
|
|
31
31
|
.action(async (prompt, options) => {
|
|
32
32
|
try {
|
|
33
33
|
const app = await App.create();
|
|
34
|
-
|
|
34
|
+
// Check if API key is configured
|
|
35
|
+
if (!app.config.hasApiKey()) {
|
|
36
|
+
console.log(chalk.yellow('\n ⚠ No API key configured\n'));
|
|
37
|
+
console.log(chalk.gray(' Run ') + chalk.cyan('gfcode init') + chalk.gray(' to set up your provider.\n'));
|
|
38
|
+
const readline = await import('readline');
|
|
39
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
40
|
+
const answer = await new Promise(resolve => {
|
|
41
|
+
rl.question(chalk.cyan(' Run init now? (Y/n): '), resolve);
|
|
42
|
+
});
|
|
43
|
+
rl.close();
|
|
44
|
+
if (answer.toLowerCase() !== 'n') {
|
|
45
|
+
await WelcomeScreen.interactiveSetup();
|
|
46
|
+
// Reload config after setup
|
|
47
|
+
const newApp = await App.create();
|
|
48
|
+
Object.assign(app, newApp);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
process.exit(0);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
35
54
|
if (options.model) {
|
|
36
55
|
await app.config.save({ model: options.model });
|
|
37
56
|
}
|
|
@@ -94,7 +113,22 @@ program
|
|
|
94
113
|
app.session.addMessage('assistant', fullResponse);
|
|
95
114
|
}
|
|
96
115
|
catch (error) {
|
|
97
|
-
|
|
116
|
+
const msg = error.message || String(error);
|
|
117
|
+
if (msg.includes('401') || msg.includes('403') || msg.includes('Unauthorized')) {
|
|
118
|
+
console.error(chalk.red('\n ❌ API key invalid or expired.'));
|
|
119
|
+
console.log(chalk.gray(' Run ') + chalk.cyan('gfcode init') + chalk.gray(' to reconfigure.\n'));
|
|
120
|
+
}
|
|
121
|
+
else if (msg.includes('429') || msg.includes('rate limit') || msg.includes('quota')) {
|
|
122
|
+
console.error(chalk.red('\n ❌ Rate limit or quota exceeded.'));
|
|
123
|
+
console.log(chalk.gray(' Wait or run ') + chalk.cyan('gfcode init') + chalk.gray(' to switch provider.\n'));
|
|
124
|
+
}
|
|
125
|
+
else if (msg.includes('ECONNREFUSED') || msg.includes('ENOTFOUND')) {
|
|
126
|
+
console.error(chalk.red('\n ❌ Cannot connect to API server.'));
|
|
127
|
+
console.log(chalk.gray(' Check network or run ') + chalk.cyan('gfcode init') + chalk.gray('.\n'));
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
console.error(chalk.red(`\n Error: ${msg}`));
|
|
131
|
+
}
|
|
98
132
|
}
|
|
99
133
|
}
|
|
100
134
|
}
|
package/dist/cmd/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cmd/index.tsx"],"names":[],"mappings":";;AAEA;;GAEG;AAEH,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;IACjC,IAAI,CAAC;QACH,OAAO,CAAC,eAAe,CAAC,CAAC,QAAQ,CAAC,YAAY,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1F,CAAC;IAAC,MAAM,CAAC,CAAA,CAAC;AACZ,CAAC;AAED,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,CAAC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AQ,IAAI,CAAC,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;aAC9G,IAAI,CAAC,GAAG,CAAC,CAAC;IACf,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;IAC7D,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAE9C,MAAM,WAAW,kBAAkB;IACjC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;IACf,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,cAAc,CAAC,EAAE,QAAQ,GAAG,MAAM,GAAG,KAAK,CAAC;IAC3C,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,MAAM,CAA+B;gBAEjC,MAAM,GAAE,kBAAuB;IAW3C,KAAK,IAAI,MAAM;IAaf,OAAO,CAAC,aAAa;IAsBrB,OAAO,CAAC,qBAAqB;IAgB7B,OAAO,CAAC,gBAAgB;IAIxB,OAAO,CAAC,mBAAmB;IAU3B,OAAO,CAAC,wBAAwB;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAE9C,MAAM,WAAW,kBAAkB;IACjC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;IACf,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,cAAc,CAAC,EAAE,QAAQ,GAAG,MAAM,GAAG,KAAK,CAAC;IAC3C,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,MAAM,CAA+B;gBAEjC,MAAM,GAAE,kBAAuB;IAW3C,KAAK,IAAI,MAAM;IAaf,OAAO,CAAC,aAAa;IAsBrB,OAAO,CAAC,qBAAqB;IAgB7B,OAAO,CAAC,gBAAgB;IAIxB,OAAO,CAAC,mBAAmB;IAU3B,OAAO,CAAC,wBAAwB;IA+BhC,OAAO,CAAC,WAAW;IAKnB,OAAO,CAAC,aAAa;IAMrB,QAAQ,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI;IAC7B,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IACzB,iBAAiB,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,KAAK,GAAG,IAAI;CACzD"}
|
package/dist/prompts/index.js
CHANGED
|
@@ -78,7 +78,19 @@ export class SystemPromptBuilder {
|
|
|
78
78
|
if (!this.config.includeProjectMd)
|
|
79
79
|
return '';
|
|
80
80
|
const cwd = this.config.cwd;
|
|
81
|
-
const
|
|
81
|
+
const home = process.env.USERPROFILE || process.env.HOME || '';
|
|
82
|
+
const paths = [
|
|
83
|
+
join(cwd, 'CLAUDE.md'),
|
|
84
|
+
join(cwd, '.claude.md'),
|
|
85
|
+
join(cwd, 'AGENTS.md'),
|
|
86
|
+
join(cwd, 'Codex.md'),
|
|
87
|
+
join(cwd, '.Codex.md'),
|
|
88
|
+
join(cwd, 'CODEX.md'),
|
|
89
|
+
join(cwd, '.codex.md'),
|
|
90
|
+
join(home, '.Codex', 'SKILLS.md'),
|
|
91
|
+
join(home, '.agents', 'AGENTS.md'),
|
|
92
|
+
join(home, '.claude', 'CLAUDE.md'),
|
|
93
|
+
];
|
|
82
94
|
for (const path of paths) {
|
|
83
95
|
if (existsSync(path)) {
|
|
84
96
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAY5B,MAAM,OAAO,mBAAmB;IACtB,MAAM,CAA+B;IAE7C,YAAY,SAA6B,EAAE;QACzC,IAAI,CAAC,MAAM,GAAG;YACZ,GAAG,EAAE,MAAM,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE;YAChC,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,EAAE;YACzB,gBAAgB,EAAE,MAAM,CAAC,gBAAgB,IAAI,IAAI;YACjD,cAAc,EAAE,MAAM,CAAC,cAAc,IAAI,KAAK;YAC9C,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,IAAI,IAAI,EAAE;YAC/B,YAAY,EAAE,MAAM,CAAC,YAAY,IAAI,EAAE;SACxC,CAAC;IACJ,CAAC;IAED,KAAK;QACH,MAAM,SAAS,GAAa;YAC1B,IAAI,CAAC,aAAa,EAAE;YACpB,IAAI,CAAC,qBAAqB,EAAE;YAC5B,IAAI,CAAC,gBAAgB,EAAE;YACvB,IAAI,CAAC,mBAAmB,EAAE;YAC1B,IAAI,CAAC,wBAAwB,EAAE;YAC/B,IAAI,CAAC,WAAW,EAAE;YAClB,IAAI,CAAC,aAAa,EAAE;SACrB,CAAC;QACF,OAAO,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,M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|
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.4" })] }), _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
|
|
@@ -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;EAgJnC"}
|
|
@@ -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,114 @@ 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
|
+
const msg = error.message || String(error);
|
|
104
|
+
let errorMsg = `Error: ${msg}`;
|
|
105
|
+
// Detect API auth/quota errors
|
|
106
|
+
if (msg.includes('401') || msg.includes('403') || msg.includes('Unauthorized')) {
|
|
107
|
+
errorMsg = `❌ API key invalid or expired.\n\nRun \`gfcode init\` to reconfigure.`;
|
|
108
|
+
}
|
|
109
|
+
else if (msg.includes('429') || msg.includes('rate limit') || msg.includes('quota')) {
|
|
110
|
+
errorMsg = `❌ Rate limit or quota exceeded.\n\nWait a moment or run \`gfcode init\` to switch provider.`;
|
|
111
|
+
}
|
|
112
|
+
else if (msg.includes('ECONNREFUSED') || msg.includes('ENOTFOUND')) {
|
|
113
|
+
errorMsg = `❌ Cannot connect to API server.\n\nCheck your network or run \`gfcode init\` to change base URL.`;
|
|
114
|
+
}
|
|
115
|
+
setState(prev => ({
|
|
116
|
+
...prev,
|
|
117
|
+
messages: [
|
|
118
|
+
...prev.messages,
|
|
119
|
+
...(fullContent.trim()
|
|
120
|
+
? [{ role: 'assistant', content: fullContent }]
|
|
121
|
+
: []),
|
|
122
|
+
{ role: 'assistant', content: errorMsg },
|
|
123
|
+
],
|
|
124
|
+
streaming: '',
|
|
125
|
+
streamingToolCalls: [],
|
|
126
|
+
isThinking: false,
|
|
127
|
+
}));
|
|
97
128
|
}
|
|
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;
|
|
129
|
+
processingRef.current = false;
|
|
130
|
+
};
|
|
131
|
+
// Start processing without blocking
|
|
132
|
+
processStream();
|
|
132
133
|
}, [app]);
|
|
133
134
|
return {
|
|
134
135
|
...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,Q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ANGED
|
@@ -28,14 +28,33 @@ process.on('unhandledRejection', (reason) => {
|
|
|
28
28
|
program
|
|
29
29
|
.name('gfcode')
|
|
30
30
|
.description('Thatgfsj Code - AI Coding Assistant')
|
|
31
|
-
.version('0.7.
|
|
31
|
+
.version('0.7.4')
|
|
32
32
|
.argument('[prompt]', 'Task to execute (omit to start interactive mode)')
|
|
33
33
|
.option('-m, --model <model>', 'Specify model')
|
|
34
34
|
.option('-i, --interactive', 'Force interactive mode')
|
|
35
35
|
.action(async (prompt: string | undefined, options: { model?: string; interactive?: boolean }) => {
|
|
36
36
|
try {
|
|
37
37
|
const app = await App.create();
|
|
38
|
-
|
|
38
|
+
|
|
39
|
+
// Check if API key is configured
|
|
40
|
+
if (!app.config.hasApiKey()) {
|
|
41
|
+
console.log(chalk.yellow('\n ⚠ No API key configured\n'));
|
|
42
|
+
console.log(chalk.gray(' Run ') + chalk.cyan('gfcode init') + chalk.gray(' to set up your provider.\n'));
|
|
43
|
+
const readline = await import('readline');
|
|
44
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
45
|
+
const answer = await new Promise<string>(resolve => {
|
|
46
|
+
rl.question(chalk.cyan(' Run init now? (Y/n): '), resolve);
|
|
47
|
+
});
|
|
48
|
+
rl.close();
|
|
49
|
+
if (answer.toLowerCase() !== 'n') {
|
|
50
|
+
await WelcomeScreen.interactiveSetup();
|
|
51
|
+
// Reload config after setup
|
|
52
|
+
const newApp = await App.create();
|
|
53
|
+
Object.assign(app, newApp);
|
|
54
|
+
} else {
|
|
55
|
+
process.exit(0);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
39
58
|
|
|
40
59
|
if (options.model) {
|
|
41
60
|
await app.config.save({ model: options.model });
|
|
@@ -99,7 +118,19 @@ program
|
|
|
99
118
|
console.log();
|
|
100
119
|
app.session.addMessage('assistant', fullResponse);
|
|
101
120
|
} catch (error: any) {
|
|
102
|
-
|
|
121
|
+
const msg = error.message || String(error);
|
|
122
|
+
if (msg.includes('401') || msg.includes('403') || msg.includes('Unauthorized')) {
|
|
123
|
+
console.error(chalk.red('\n ❌ API key invalid or expired.'));
|
|
124
|
+
console.log(chalk.gray(' Run ') + chalk.cyan('gfcode init') + chalk.gray(' to reconfigure.\n'));
|
|
125
|
+
} else if (msg.includes('429') || msg.includes('rate limit') || msg.includes('quota')) {
|
|
126
|
+
console.error(chalk.red('\n ❌ Rate limit or quota exceeded.'));
|
|
127
|
+
console.log(chalk.gray(' Wait or run ') + chalk.cyan('gfcode init') + chalk.gray(' to switch provider.\n'));
|
|
128
|
+
} else if (msg.includes('ECONNREFUSED') || msg.includes('ENOTFOUND')) {
|
|
129
|
+
console.error(chalk.red('\n ❌ Cannot connect to API server.'));
|
|
130
|
+
console.log(chalk.gray(' Check network or run ') + chalk.cyan('gfcode init') + chalk.gray('.\n'));
|
|
131
|
+
} else {
|
|
132
|
+
console.error(chalk.red(`\n Error: ${msg}`));
|
|
133
|
+
}
|
|
103
134
|
}
|
|
104
135
|
}
|
|
105
136
|
} catch (error: any) {
|
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)) {
|
|
@@ -14,7 +14,7 @@ export const Header = React.memo(function Header({ provider, model }: Props) {
|
|
|
14
14
|
<Box>
|
|
15
15
|
<Text color="#06B6D4" bold> ⚡ </Text>
|
|
16
16
|
<Text color="#22D3EE" bold>THATGFSJ CODE</Text>
|
|
17
|
-
<Text dimColor> v0.7.
|
|
17
|
+
<Text dimColor> v0.7.4</Text>
|
|
18
18
|
</Box>
|
|
19
19
|
<Box>
|
|
20
20
|
<Text color="#06B6D4" bold> {provider} </Text>
|
package/src/tui/hooks/useChat.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useState, useCallback, useRef } from 'react';
|
|
1
|
+
import { useState, useCallback, useRef, useEffect } from 'react';
|
|
2
2
|
import type { MessageData } from '../components/ChatMessage.js';
|
|
3
3
|
import type { ToolCallData } from '../components/ToolCall.js';
|
|
4
4
|
import type { App } from '../../app/index.js';
|
|
@@ -18,10 +18,12 @@ export function useChat(app: App) {
|
|
|
18
18
|
streamingToolCalls: [],
|
|
19
19
|
});
|
|
20
20
|
const processingRef = useRef(false);
|
|
21
|
+
const abortRef = useRef(false);
|
|
21
22
|
|
|
22
|
-
const sendMessage = useCallback(
|
|
23
|
+
const sendMessage = useCallback((input: string) => {
|
|
23
24
|
if (processingRef.current) return;
|
|
24
25
|
processingRef.current = true;
|
|
26
|
+
abortRef.current = false;
|
|
25
27
|
|
|
26
28
|
// Add user message
|
|
27
29
|
setState(prev => ({
|
|
@@ -34,117 +36,115 @@ export function useChat(app: App) {
|
|
|
34
36
|
|
|
35
37
|
app.session.addMessage('user', input);
|
|
36
38
|
|
|
39
|
+
// Process stream in background (non-blocking)
|
|
40
|
+
const stream = app.streamResponse();
|
|
37
41
|
let fullContent = '';
|
|
38
42
|
let currentToolCalls: ToolCallData[] = [];
|
|
39
43
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
44
|
+
const processStream = async () => {
|
|
45
|
+
try {
|
|
46
|
+
for await (const chunk of stream) {
|
|
47
|
+
if (abortRef.current) break;
|
|
48
|
+
|
|
49
|
+
if (chunk.includes('@@TOOL@@')) {
|
|
50
|
+
const parts = chunk.split('\n');
|
|
51
|
+
for (const part of parts) {
|
|
52
|
+
if (part.startsWith('@@TOOL@@')) {
|
|
53
|
+
try {
|
|
54
|
+
const data = JSON.parse(part.slice(8));
|
|
55
|
+
if (data.action === 'call') {
|
|
56
|
+
currentToolCalls.push({ name: data.name, args: data.args || '' });
|
|
57
|
+
setState(prev => ({
|
|
58
|
+
...prev,
|
|
59
|
+
isThinking: false,
|
|
60
|
+
streamingToolCalls: [...currentToolCalls],
|
|
61
|
+
}));
|
|
62
|
+
} else if (data.action === 'result') {
|
|
63
|
+
const lastIdx = currentToolCalls.length - 1;
|
|
64
|
+
if (lastIdx >= 0) {
|
|
65
|
+
currentToolCalls[lastIdx] = {
|
|
66
|
+
...currentToolCalls[lastIdx],
|
|
67
|
+
result: data.output || data.error || '',
|
|
68
|
+
isError: !!data.error,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
setState(prev => ({
|
|
72
|
+
...prev,
|
|
73
|
+
streamingToolCalls: [...currentToolCalls],
|
|
74
|
+
isThinking: true,
|
|
75
|
+
}));
|
|
71
76
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
isThinking: true, // Continue thinking after tool
|
|
76
|
-
}));
|
|
77
|
+
} catch {
|
|
78
|
+
fullContent += part;
|
|
79
|
+
setState(prev => ({ ...prev, isThinking: false, streaming: fullContent }));
|
|
77
80
|
}
|
|
78
|
-
}
|
|
79
|
-
// Not a tool message, treat as text
|
|
81
|
+
} else if (part) {
|
|
80
82
|
fullContent += part;
|
|
81
|
-
setState(prev => ({
|
|
82
|
-
...prev,
|
|
83
|
-
isThinking: false,
|
|
84
|
-
streaming: fullContent,
|
|
85
|
-
}));
|
|
83
|
+
setState(prev => ({ ...prev, isThinking: false, streaming: fullContent }));
|
|
86
84
|
}
|
|
87
|
-
} else if (part) {
|
|
88
|
-
fullContent += part;
|
|
89
|
-
setState(prev => ({
|
|
90
|
-
...prev,
|
|
91
|
-
isThinking: false,
|
|
92
|
-
streaming: fullContent,
|
|
93
|
-
}));
|
|
94
85
|
}
|
|
86
|
+
} else {
|
|
87
|
+
fullContent += chunk;
|
|
88
|
+
setState(prev => ({ ...prev, isThinking: false, streaming: fullContent }));
|
|
95
89
|
}
|
|
96
|
-
} else {
|
|
97
|
-
// Regular text chunk
|
|
98
|
-
fullContent += chunk;
|
|
99
|
-
setState(prev => ({
|
|
100
|
-
...prev,
|
|
101
|
-
isThinking: false,
|
|
102
|
-
streaming: fullContent,
|
|
103
|
-
}));
|
|
104
90
|
}
|
|
105
|
-
}
|
|
106
91
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
92
|
+
// Finalize
|
|
93
|
+
if (fullContent.trim() || currentToolCalls.length > 0) {
|
|
94
|
+
app.session.addMessage('assistant', fullContent);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
setState(prev => ({
|
|
98
|
+
...prev,
|
|
99
|
+
messages: [
|
|
100
|
+
...prev.messages,
|
|
101
|
+
...(fullContent.trim() || currentToolCalls.length > 0
|
|
102
|
+
? [{
|
|
103
|
+
role: 'assistant' as const,
|
|
104
|
+
content: fullContent,
|
|
105
|
+
toolCalls: currentToolCalls.length > 0 ? currentToolCalls : undefined,
|
|
106
|
+
}]
|
|
107
|
+
: []),
|
|
108
|
+
],
|
|
109
|
+
streaming: '',
|
|
110
|
+
streamingToolCalls: [],
|
|
111
|
+
isThinking: false,
|
|
112
|
+
}));
|
|
113
|
+
|
|
114
|
+
app.session.truncate();
|
|
115
|
+
} catch (error: any) {
|
|
116
|
+
const msg = error.message || String(error);
|
|
117
|
+
let errorMsg = `Error: ${msg}`;
|
|
118
|
+
|
|
119
|
+
// Detect API auth/quota errors
|
|
120
|
+
if (msg.includes('401') || msg.includes('403') || msg.includes('Unauthorized')) {
|
|
121
|
+
errorMsg = `❌ API key invalid or expired.\n\nRun \`gfcode init\` to reconfigure.`;
|
|
122
|
+
} else if (msg.includes('429') || msg.includes('rate limit') || msg.includes('quota')) {
|
|
123
|
+
errorMsg = `❌ Rate limit or quota exceeded.\n\nWait a moment or run \`gfcode init\` to switch provider.`;
|
|
124
|
+
} else if (msg.includes('ECONNREFUSED') || msg.includes('ENOTFOUND')) {
|
|
125
|
+
errorMsg = `❌ Cannot connect to API server.\n\nCheck your network or run \`gfcode init\` to change base URL.`;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
setState(prev => ({
|
|
129
|
+
...prev,
|
|
130
|
+
messages: [
|
|
131
|
+
...prev.messages,
|
|
132
|
+
...(fullContent.trim()
|
|
133
|
+
? [{ role: 'assistant' as const, content: fullContent }]
|
|
134
|
+
: []),
|
|
135
|
+
{ role: 'assistant', content: errorMsg },
|
|
136
|
+
],
|
|
137
|
+
streaming: '',
|
|
138
|
+
streamingToolCalls: [],
|
|
139
|
+
isThinking: false,
|
|
140
|
+
}));
|
|
110
141
|
}
|
|
111
142
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
? [{
|
|
118
|
-
role: 'assistant' as const,
|
|
119
|
-
content: fullContent,
|
|
120
|
-
toolCalls: currentToolCalls.length > 0 ? currentToolCalls : undefined,
|
|
121
|
-
}]
|
|
122
|
-
: []),
|
|
123
|
-
],
|
|
124
|
-
streaming: '',
|
|
125
|
-
streamingToolCalls: [],
|
|
126
|
-
isThinking: false,
|
|
127
|
-
}));
|
|
128
|
-
|
|
129
|
-
app.session.truncate();
|
|
130
|
-
|
|
131
|
-
} catch (error: any) {
|
|
132
|
-
setState(prev => ({
|
|
133
|
-
...prev,
|
|
134
|
-
messages: [
|
|
135
|
-
...prev.messages,
|
|
136
|
-
...(fullContent.trim()
|
|
137
|
-
? [{ role: 'assistant' as const, content: fullContent }]
|
|
138
|
-
: []),
|
|
139
|
-
{ role: 'assistant', content: `Error: ${error.message}` },
|
|
140
|
-
],
|
|
141
|
-
streaming: '',
|
|
142
|
-
streamingToolCalls: [],
|
|
143
|
-
isThinking: false,
|
|
144
|
-
}));
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
processingRef.current = false;
|
|
143
|
+
processingRef.current = false;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
// Start processing without blocking
|
|
147
|
+
processStream();
|
|
148
148
|
}, [app]);
|
|
149
149
|
|
|
150
150
|
return {
|