thatgfsj-code 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (165) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +136 -0
  3. package/ROADMAP.md +61 -0
  4. package/dist/app/agent.d.ts +31 -0
  5. package/dist/app/agent.d.ts.map +1 -0
  6. package/dist/app/agent.js +106 -0
  7. package/dist/app/agent.js.map +1 -0
  8. package/dist/app/index.d.ts +39 -0
  9. package/dist/app/index.d.ts.map +1 -0
  10. package/dist/app/index.js +80 -0
  11. package/dist/app/index.js.map +1 -0
  12. package/dist/cmd/index.d.ts +12 -0
  13. package/dist/cmd/index.d.ts.map +1 -0
  14. package/dist/cmd/index.js +85 -0
  15. package/dist/cmd/index.js.map +1 -0
  16. package/dist/config/index.d.ts +39 -0
  17. package/dist/config/index.d.ts.map +1 -0
  18. package/dist/config/index.js +110 -0
  19. package/dist/config/index.js.map +1 -0
  20. package/dist/config/providers.d.ts +23 -0
  21. package/dist/config/providers.d.ts.map +1 -0
  22. package/dist/config/providers.js +152 -0
  23. package/dist/config/providers.js.map +1 -0
  24. package/dist/config/types.d.ts +33 -0
  25. package/dist/config/types.d.ts.map +1 -0
  26. package/dist/config/types.js +5 -0
  27. package/dist/config/types.js.map +1 -0
  28. package/dist/hooks/index.d.ts +31 -0
  29. package/dist/hooks/index.d.ts.map +1 -0
  30. package/dist/hooks/index.js +71 -0
  31. package/dist/hooks/index.js.map +1 -0
  32. package/dist/llm/anthropic.d.ts +17 -0
  33. package/dist/llm/anthropic.d.ts.map +1 -0
  34. package/dist/llm/anthropic.js +126 -0
  35. package/dist/llm/anthropic.js.map +1 -0
  36. package/dist/llm/gemini.d.ts +16 -0
  37. package/dist/llm/gemini.d.ts.map +1 -0
  38. package/dist/llm/gemini.js +107 -0
  39. package/dist/llm/gemini.js.map +1 -0
  40. package/dist/llm/index.d.ts +48 -0
  41. package/dist/llm/index.d.ts.map +1 -0
  42. package/dist/llm/index.js +174 -0
  43. package/dist/llm/index.js.map +1 -0
  44. package/dist/llm/openai.d.ts +17 -0
  45. package/dist/llm/openai.d.ts.map +1 -0
  46. package/dist/llm/openai.js +113 -0
  47. package/dist/llm/openai.js.map +1 -0
  48. package/dist/llm/provider.d.ts +33 -0
  49. package/dist/llm/provider.d.ts.map +1 -0
  50. package/dist/llm/provider.js +6 -0
  51. package/dist/llm/provider.js.map +1 -0
  52. package/dist/mcp/client.d.ts +83 -0
  53. package/dist/mcp/client.d.ts.map +1 -0
  54. package/dist/mcp/client.js +267 -0
  55. package/dist/mcp/client.js.map +1 -0
  56. package/dist/prompts/index.d.ts +27 -0
  57. package/dist/prompts/index.d.ts.map +1 -0
  58. package/dist/prompts/index.js +102 -0
  59. package/dist/prompts/index.js.map +1 -0
  60. package/dist/session/compactor.d.ts +48 -0
  61. package/dist/session/compactor.d.ts.map +1 -0
  62. package/dist/session/compactor.js +77 -0
  63. package/dist/session/compactor.js.map +1 -0
  64. package/dist/session/index.d.ts +48 -0
  65. package/dist/session/index.d.ts.map +1 -0
  66. package/dist/session/index.js +69 -0
  67. package/dist/session/index.js.map +1 -0
  68. package/dist/session/message.d.ts +26 -0
  69. package/dist/session/message.d.ts.map +1 -0
  70. package/dist/session/message.js +34 -0
  71. package/dist/session/message.js.map +1 -0
  72. package/dist/tools/file.d.ts +46 -0
  73. package/dist/tools/file.d.ts.map +1 -0
  74. package/dist/tools/file.js +100 -0
  75. package/dist/tools/file.js.map +1 -0
  76. package/dist/tools/git.d.ts +52 -0
  77. package/dist/tools/git.d.ts.map +1 -0
  78. package/dist/tools/git.js +112 -0
  79. package/dist/tools/git.js.map +1 -0
  80. package/dist/tools/index.d.ts +42 -0
  81. package/dist/tools/index.d.ts.map +1 -0
  82. package/dist/tools/index.js +92 -0
  83. package/dist/tools/index.js.map +1 -0
  84. package/dist/tools/search.d.ts +36 -0
  85. package/dist/tools/search.d.ts.map +1 -0
  86. package/dist/tools/search.js +223 -0
  87. package/dist/tools/search.js.map +1 -0
  88. package/dist/tools/shell.d.ts +50 -0
  89. package/dist/tools/shell.d.ts.map +1 -0
  90. package/dist/tools/shell.js +117 -0
  91. package/dist/tools/shell.js.map +1 -0
  92. package/dist/tools/types.d.ts +68 -0
  93. package/dist/tools/types.d.ts.map +1 -0
  94. package/dist/tools/types.js +57 -0
  95. package/dist/tools/types.js.map +1 -0
  96. package/dist/tui/index.d.ts +8 -0
  97. package/dist/tui/index.d.ts.map +1 -0
  98. package/dist/tui/index.js +8 -0
  99. package/dist/tui/index.js.map +1 -0
  100. package/dist/tui/input.d.ts +14 -0
  101. package/dist/tui/input.d.ts.map +1 -0
  102. package/dist/tui/input.js +50 -0
  103. package/dist/tui/input.js.map +1 -0
  104. package/dist/tui/output.d.ts +20 -0
  105. package/dist/tui/output.d.ts.map +1 -0
  106. package/dist/tui/output.js +70 -0
  107. package/dist/tui/output.js.map +1 -0
  108. package/dist/tui/repl.d.ts +25 -0
  109. package/dist/tui/repl.d.ts.map +1 -0
  110. package/dist/tui/repl.js +114 -0
  111. package/dist/tui/repl.js.map +1 -0
  112. package/dist/tui/welcome.d.ts +15 -0
  113. package/dist/tui/welcome.d.ts.map +1 -0
  114. package/dist/tui/welcome.js +86 -0
  115. package/dist/tui/welcome.js.map +1 -0
  116. package/dist/types.d.ts +38 -0
  117. package/dist/types.d.ts.map +1 -0
  118. package/dist/types.js +6 -0
  119. package/dist/types.js.map +1 -0
  120. package/dist/utils/diff.d.ts +22 -0
  121. package/dist/utils/diff.d.ts.map +1 -0
  122. package/dist/utils/diff.js +60 -0
  123. package/dist/utils/diff.js.map +1 -0
  124. package/dist/utils/project.d.ts +32 -0
  125. package/dist/utils/project.d.ts.map +1 -0
  126. package/dist/utils/project.js +89 -0
  127. package/dist/utils/project.js.map +1 -0
  128. package/docs/API_KEY_GUIDE.md +236 -0
  129. package/docs/FAQ.md +182 -0
  130. package/install.bat +63 -0
  131. package/install.ps1 +238 -0
  132. package/install.sh +113 -0
  133. package/package.json +36 -0
  134. package/src/app/agent.ts +140 -0
  135. package/src/app/index.ts +101 -0
  136. package/src/cmd/index.ts +96 -0
  137. package/src/config/index.ts +130 -0
  138. package/src/config/providers.ts +160 -0
  139. package/src/config/types.ts +46 -0
  140. package/src/hooks/index.ts +111 -0
  141. package/src/llm/anthropic.ts +146 -0
  142. package/src/llm/gemini.ts +127 -0
  143. package/src/llm/index.ts +209 -0
  144. package/src/llm/openai.ts +132 -0
  145. package/src/llm/provider.ts +38 -0
  146. package/src/mcp/client.ts +330 -0
  147. package/src/prompts/index.ts +123 -0
  148. package/src/session/compactor.ts +103 -0
  149. package/src/session/index.ts +81 -0
  150. package/src/session/message.ts +42 -0
  151. package/src/tools/file.ts +117 -0
  152. package/src/tools/git.ts +132 -0
  153. package/src/tools/index.ts +108 -0
  154. package/src/tools/search.ts +263 -0
  155. package/src/tools/shell.ts +136 -0
  156. package/src/tools/types.ts +122 -0
  157. package/src/tui/index.ts +8 -0
  158. package/src/tui/input.ts +56 -0
  159. package/src/tui/output.ts +83 -0
  160. package/src/tui/repl.ts +131 -0
  161. package/src/tui/welcome.ts +101 -0
  162. package/src/types.ts +42 -0
  163. package/src/utils/diff.ts +71 -0
  164. package/src/utils/project.ts +99 -0
  165. package/tsconfig.json +19 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Thatgfsj
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,136 @@
1
+ # Thatgfsj Code 🤖
2
+
3
+ AI 编程助手 - 终端里的 AI 编程伙伴
4
+
5
+ ---
6
+
7
+ ## ⭐ 特性
8
+
9
+ - 🤖 **AI 对话** - 用自然语言让 AI 帮你写代码
10
+ - 🔧 **工具调用** - AI 可以读写文件、执行命令、搜索代码、操作 Git
11
+ - 💬 **交互模式** - 持续对话,像聊天一样编程
12
+ - 📡 **流式输出** - 实时显示 AI 回复
13
+ - 🔌 **多 Provider** - 支持 SiliconFlow、OpenAI、Anthropic、Gemini、DeepSeek、Kimi 等
14
+
15
+ ---
16
+
17
+ ## 🚀 快速开始
18
+
19
+ ### 安装
20
+
21
+ ```bash
22
+ # 克隆仓库
23
+ git clone https://github.com/Thatgfsj/thatgfsj-code.git
24
+ cd thatgfsj-code
25
+
26
+ # 安装依赖
27
+ npm install
28
+
29
+ # 编译
30
+ npm run build
31
+
32
+ # 全局链接
33
+ npm link
34
+ ```
35
+
36
+ ### 配置
37
+
38
+ ```bash
39
+ # 交互式配置向导(推荐)
40
+ gfcode init
41
+
42
+ # 或手动设置环境变量
43
+ export OPENAI_API_KEY="sk-..."
44
+ export SILICONFLOW_API_KEY="sk-..."
45
+ ```
46
+
47
+ ---
48
+
49
+ ## 📖 使用方法
50
+
51
+ ```bash
52
+ # 交互模式(推荐)
53
+ gfcode
54
+
55
+ # 单次 prompt
56
+ gfcode "帮我写一个 Python 的 Hello World"
57
+
58
+ # 指定模型
59
+ gfcode -m gpt-4o "你的任务"
60
+
61
+ # 启用审计日志
62
+ gfcode --hooks "你的任务"
63
+ ```
64
+
65
+ ### 交互模式内置命令
66
+
67
+ | 命令 | 说明 |
68
+ |------|------|
69
+ | `help` | 显示帮助 |
70
+ | `tools` | 列出可用工具 |
71
+ | `model` | 显示当前模型 |
72
+ | `clear` | 清屏 |
73
+ | `exit` | 退出 |
74
+
75
+ ---
76
+
77
+ ## 🏗️ 架构
78
+
79
+ ```
80
+ src/
81
+ ├── cmd/ # CLI 入口 (commander)
82
+ ├── app/ # 核心应用服务 + Agent Loop
83
+ ├── config/ # 配置管理 + Provider 定义
84
+ ├── llm/ # LLM Provider 抽象层
85
+ │ ├── openai.ts # OpenAI 兼容 (SiliconFlow/DeepSeek/Kimi/...)
86
+ │ ├── anthropic.ts # Anthropic Claude
87
+ │ └── gemini.ts # Google Gemini
88
+ ├── session/ # 会话与消息管理
89
+ ├── tools/ # 工具系统 (file/shell/git/search)
90
+ ├── tui/ # 终端 UI (REPL)
91
+ ├── mcp/ # MCP 协议支持
92
+ ├── hooks/ # 生命周期钩子
93
+ ├── prompts/ # 系统提示构建
94
+ ├── utils/ # 工具函数
95
+ └── types.ts # 全局类型
96
+ ```
97
+
98
+ ---
99
+
100
+ ## 🔌 支持的 Provider
101
+
102
+ | Provider | 格式 | 默认模型 |
103
+ |----------|------|----------|
104
+ | SiliconFlow | OpenAI | Qwen2.5-7B |
105
+ | MiniMax | Anthropic | MiniMax-M2.5 |
106
+ | OpenAI | OpenAI | gpt-4o-mini |
107
+ | Anthropic | Anthropic | claude-3-haiku |
108
+ | Gemini | Gemini | gemini-1.5-flash |
109
+ | DeepSeek | OpenAI | deepseek-chat |
110
+ | Kimi | OpenAI | moonshot-v1-8k |
111
+ | ERNIE | OpenAI | ernie-4.0-8k |
112
+ | Ollama | OpenAI | llama2 |
113
+
114
+ ---
115
+
116
+ ## 🔧 可用工具
117
+
118
+ | 工具 | 功能 | 权限 |
119
+ |------|------|------|
120
+ | `file` | 读/写/列表/删除文件 | read, write |
121
+ | `shell` | 执行 shell 命令 | execute, network |
122
+ | `git` | Git 操作 (status/log/diff/commit/branch) | execute |
123
+ | `search` | 代码搜索 (grep/find/tree) | read |
124
+
125
+ ---
126
+
127
+ ## 📚 文档
128
+
129
+ - [API Key 获取教程](./docs/API_KEY_GUIDE.md)
130
+ - [常见问题 FAQ](./docs/FAQ.md)
131
+
132
+ ---
133
+
134
+ ## 🤝 问题反馈
135
+
136
+ https://github.com/Thatgfsj/thatgfsj-code/issues
package/ROADMAP.md ADDED
@@ -0,0 +1,61 @@
1
+ # Thatgfsj Code - Development Roadmap
2
+
3
+ ---
4
+
5
+ ## ✅ v0.3.0 - 架构重构 (当前版本)
6
+
7
+ ### 核心改进
8
+ - [x] 参考 opencode 重构模块化架构
9
+ - [x] LLM Provider 抽象层 (OpenAI/Anthropic/Gemini)
10
+ - [x] 统一 App 核心服务层
11
+ - [x] 精简 CLI 入口 (去掉 explain/debug/chat/template)
12
+ - [x] 类型系统整理 (types.ts 拆分到各模块)
13
+ - [x] 删除未使用模块 (skills, subagent, state, intent)
14
+
15
+ ### 新目录结构
16
+ ```
17
+ src/
18
+ ├── cmd/ # CLI 入口
19
+ ├── app/ # 核心服务 + Agent Loop
20
+ ├── config/ # 配置 + Provider 定义
21
+ ├── llm/ # LLM Provider 抽象
22
+ ├── session/ # 会话管理
23
+ ├── tools/ # 工具系统
24
+ ├── tui/ # 终端 UI
25
+ ├── mcp/ # MCP 协议
26
+ ├── hooks/ # 钩子系统
27
+ ├── prompts/ # 提示构建
28
+ └── utils/ # 工具函数
29
+ ```
30
+
31
+ ---
32
+
33
+ ## 📋 未来计划
34
+
35
+ ### v0.4.0 - 增强功能
36
+ - [ ] SQLite 会话持久化
37
+ - [ ] 命令历史持久化
38
+ - [ ] 自定义工具插件加载
39
+ - [ ] MCP 服务器配置文件支持
40
+
41
+ ### v0.5.0 - TUI 升级
42
+ - [ ] Ink/React TUI 替换 readline
43
+ - [ ] 分屏显示 (代码 + 对话)
44
+ - [ ] Vim 模式编辑器
45
+ - [ ] 文件变更预览面板
46
+
47
+ ### v1.0.0 - 稳定版
48
+ - [ ] LSP 集成
49
+ - [ ] 多会话管理
50
+ - [ ] 插件市场
51
+ - [ ] 完整测试覆盖
52
+
53
+ ---
54
+
55
+ ## 已完成的历史阶段
56
+
57
+ ### ✅ v0.1.0 - REPL 基础
58
+ - 彩色 UI、命令提示符、Ctrl+C 中断、内置命令
59
+
60
+ ### ✅ v0.2.0 - 工具 + LLM
61
+ - Git/搜索工具、多 Provider 支持、流式输出、意图识别
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Agent Loop - Core agent logic with streaming and tool execution
3
+ * Extracted from old src/core/ai-engine.ts
4
+ *
5
+ * The agent loop: while(true) { stream response → check tool calls → execute → repeat }
6
+ */
7
+ import type { ChatMessage, ChatResponse } from '../types.js';
8
+ import type { HookManager } from '../hooks/index.js';
9
+ import { LLMService } from '../llm/index.js';
10
+ import { ToolRegistry } from '../tools/index.js';
11
+ export interface AgentConfig {
12
+ maxIterations?: number;
13
+ hooks?: HookManager;
14
+ }
15
+ export declare class Agent {
16
+ private llm;
17
+ private registry;
18
+ private hooks?;
19
+ private maxIterations;
20
+ constructor(llm: LLMService, registry: ToolRegistry, config?: AgentConfig);
21
+ /**
22
+ * Run agent loop with streaming output
23
+ * Returns the final response
24
+ */
25
+ run(messages: ChatMessage[]): AsyncGenerator<string, ChatResponse>;
26
+ /**
27
+ * Non-streaming chat (convenience method)
28
+ */
29
+ chat(messages: ChatMessage[]): Promise<ChatResponse>;
30
+ }
31
+ //# sourceMappingURL=agent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/app/agent.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,MAAM,WAAW,WAAW;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB;AAED,qBAAa,KAAK;IAChB,OAAO,CAAC,GAAG,CAAa;IACxB,OAAO,CAAC,QAAQ,CAAe;IAC/B,OAAO,CAAC,KAAK,CAAC,CAAc;IAC5B,OAAO,CAAC,aAAa,CAAS;gBAElB,GAAG,EAAE,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,GAAE,WAAgB;IAU7E;;;OAGG;IACI,GAAG,CAAC,QAAQ,EAAE,WAAW,EAAE,GAAG,cAAc,CAAC,MAAM,EAAE,YAAY,CAAC;IA0FzE;;OAEG;IACG,IAAI,CAAC,QAAQ,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,YAAY,CAAC;CAO3D"}
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Agent Loop - Core agent logic with streaming and tool execution
3
+ * Extracted from old src/core/ai-engine.ts
4
+ *
5
+ * The agent loop: while(true) { stream response → check tool calls → execute → repeat }
6
+ */
7
+ import chalk from 'chalk';
8
+ export class Agent {
9
+ llm;
10
+ registry;
11
+ hooks;
12
+ maxIterations;
13
+ constructor(llm, registry, config = {}) {
14
+ this.llm = llm;
15
+ this.registry = registry;
16
+ this.hooks = config.hooks;
17
+ this.maxIterations = config.maxIterations ?? 10;
18
+ // Register tools with LLM service
19
+ this.llm.registerTools(registry.list());
20
+ }
21
+ /**
22
+ * Run agent loop with streaming output
23
+ * Returns the final response
24
+ */
25
+ async *run(messages) {
26
+ let currentMessages = [...messages];
27
+ let iterations = 0;
28
+ while (iterations < this.maxIterations) {
29
+ iterations++;
30
+ // Hook: beforeAgentLoop
31
+ if (this.hooks) {
32
+ await this.hooks.emit('beforeAgentLoop', { messages: currentMessages, iteration: iterations });
33
+ }
34
+ // Stream the response
35
+ let fullContent = '';
36
+ for await (const chunk of this.llm.chatStream(currentMessages, { maxIterations: 1 })) {
37
+ fullContent += chunk;
38
+ yield chunk;
39
+ }
40
+ // Get the full response to check for tool calls
41
+ const response = {
42
+ content: fullContent,
43
+ role: 'assistant',
44
+ };
45
+ // Check if the response contains tool calls
46
+ // For now, we rely on the LLM service to handle tool calls internally
47
+ // If the LLM service returned tool_calls, we need to process them
48
+ if (response.tool_calls && response.tool_calls.length > 0) {
49
+ currentMessages.push({
50
+ role: 'assistant',
51
+ content: response.content,
52
+ tool_calls: response.tool_calls,
53
+ });
54
+ for (const toolCall of response.tool_calls) {
55
+ // Hook: beforeToolCall
56
+ if (this.hooks) {
57
+ await this.hooks.emit('beforeToolCall', {
58
+ toolName: toolCall.function.name,
59
+ toolParams: JSON.parse(toolCall.function.arguments || '{}'),
60
+ toolCallId: toolCall.id,
61
+ });
62
+ }
63
+ const result = await this.registry.execute(toolCall.function.name, JSON.parse(toolCall.function.arguments || '{}'));
64
+ // Hook: afterToolCall
65
+ if (this.hooks) {
66
+ await this.hooks.emit('afterToolCall', {
67
+ toolName: toolCall.function.name,
68
+ toolParams: JSON.parse(toolCall.function.arguments || '{}'),
69
+ toolResult: result,
70
+ toolCallId: toolCall.id,
71
+ });
72
+ }
73
+ currentMessages.push({
74
+ role: 'tool',
75
+ content: result.success ? (result.output || JSON.stringify(result.data)) : (result.error || 'Tool failed'),
76
+ tool_call_id: toolCall.id,
77
+ name: toolCall.function.name,
78
+ });
79
+ yield `\n${chalk.gray(`[tool: ${toolCall.function.name}]`)}`;
80
+ }
81
+ continue; // Next iteration
82
+ }
83
+ // No tool calls - done
84
+ if (response.content) {
85
+ currentMessages.push({ role: 'assistant', content: response.content });
86
+ }
87
+ // Hook: afterAgentLoop
88
+ if (this.hooks) {
89
+ await this.hooks.emit('afterAgentLoop', { messages: currentMessages, iteration: iterations });
90
+ }
91
+ return response;
92
+ }
93
+ return { content: '[Agent loop exceeded maximum iterations]', role: 'assistant' };
94
+ }
95
+ /**
96
+ * Non-streaming chat (convenience method)
97
+ */
98
+ async chat(messages) {
99
+ let fullContent = '';
100
+ for await (const chunk of this.run(messages)) {
101
+ fullContent += chunk;
102
+ }
103
+ return { content: fullContent, role: 'assistant' };
104
+ }
105
+ }
106
+ //# sourceMappingURL=agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.js","sourceRoot":"","sources":["../../src/app/agent.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAY1B,MAAM,OAAO,KAAK;IACR,GAAG,CAAa;IAChB,QAAQ,CAAe;IACvB,KAAK,CAAe;IACpB,aAAa,CAAS;IAE9B,YAAY,GAAe,EAAE,QAAsB,EAAE,SAAsB,EAAE;QAC3E,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;QAC1B,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC,aAAa,IAAI,EAAE,CAAC;QAEhD,kCAAkC;QAClC,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IAC1C,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,CAAC,GAAG,CAAC,QAAuB;QAChC,IAAI,eAAe,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC;QACpC,IAAI,UAAU,GAAG,CAAC,CAAC;QAEnB,OAAO,UAAU,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;YACvC,UAAU,EAAE,CAAC;YAEb,wBAAwB;YACxB,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;gBACf,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,iBAAiB,EAAE,EAAE,QAAQ,EAAE,eAAe,EAAE,SAAS,EAAE,UAAU,EAAE,C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AQ,EAAE,eAAe,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC,CAAC;YAChG,CAAC;YAED,OAAO,QAAQ,CAAC;QAClB,CAAC;QAED,OAAO,EAAE,OAAO,EAAE,0CAA0C,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;IACpF,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,IAAI,CAAC,QAAuB;QAChC,IAAI,WAAW,GAAG,EAAE,CAAC;QACrB,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC7C,WAAW,IAAI,KAAK,CAAC;QACvB,CAAC;QACD,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;IACrD,CAAC;CACF"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * App - Core application singleton
3
+ * Assembles all services: config, LLM, session, tools, hooks, prompts
4
+ * Replaces the scattered initialization in old src/index.ts
5
+ */
6
+ import { ConfigManager } from '../config/index.js';
7
+ import { LLMService } from '../llm/index.js';
8
+ import { SessionManager } from '../session/index.js';
9
+ import { ToolRegistry } from '../tools/index.js';
10
+ import { HookManager } from '../hooks/index.js';
11
+ import { SystemPromptBuilder } from '../prompts/index.js';
12
+ import { Agent } from './agent.js';
13
+ export declare class App {
14
+ config: ConfigManager;
15
+ llm: LLMService;
16
+ session: SessionManager;
17
+ tools: ToolRegistry;
18
+ hooks: HookManager;
19
+ prompts: SystemPromptBuilder;
20
+ private agent;
21
+ private constructor();
22
+ /**
23
+ * Create and initialize the App
24
+ */
25
+ static create(): Promise<App>;
26
+ /**
27
+ * Run a single prompt (non-interactive mode)
28
+ */
29
+ runPrompt(prompt: string): Promise<string>;
30
+ /**
31
+ * Get the agent for streaming control
32
+ */
33
+ getAgent(): Agent;
34
+ /**
35
+ * Get current config
36
+ */
37
+ getConfig(): ConfigManager;
38
+ }
39
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/app/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAGnC,qBAAa,GAAG;IACd,MAAM,EAAE,aAAa,CAAC;IACtB,GAAG,EAAE,UAAU,CAAC;IAChB,OAAO,EAAE,cAAc,CAAC;IACxB,KAAK,EAAE,YAAY,CAAC;IACpB,KAAK,EAAE,WAAW,CAAC;IACnB,OAAO,EAAE,mBAAmB,CAAC;IAC7B,OAAO,CAAC,KAAK,CAAQ;IAErB,OAAO;IAkBP;;OAEG;WACU,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC;IAyBnC;;OAEG;IACG,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAchD;;OAEG;IACH,QAAQ,IAAI,KAAK;IAIjB;;OAEG;IACH,SAAS,IAAI,aAAa;CAG3B"}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * App - Core application singleton
3
+ * Assembles all services: config, LLM, session, tools, hooks, prompts
4
+ * Replaces the scattered initialization in old src/index.ts
5
+ */
6
+ import { ConfigManager } from '../config/index.js';
7
+ import { LLMService } from '../llm/index.js';
8
+ import { SessionManager } from '../session/index.js';
9
+ import { ToolRegistry } from '../tools/index.js';
10
+ import { HookManager } from '../hooks/index.js';
11
+ import { SystemPromptBuilder } from '../prompts/index.js';
12
+ import { Agent } from './agent.js';
13
+ export class App {
14
+ config;
15
+ llm;
16
+ session;
17
+ tools;
18
+ hooks;
19
+ prompts;
20
+ agent;
21
+ constructor(config, llm, session, tools, hooks, prompts, agent) {
22
+ this.config = config;
23
+ this.llm = llm;
24
+ this.session = session;
25
+ this.tools = tools;
26
+ this.hooks = hooks;
27
+ this.prompts = prompts;
28
+ this.agent = agent;
29
+ }
30
+ /**
31
+ * Create and initialize the App
32
+ */
33
+ static async create() {
34
+ // Load config
35
+ const config = await ConfigManager.load();
36
+ const aiConfig = config.getAIConfig();
37
+ // Create services
38
+ const llm = LLMService.fromConfig(aiConfig);
39
+ const session = new SessionManager();
40
+ const tools = new ToolRegistry();
41
+ const hooks = new HookManager();
42
+ const prompts = new SystemPromptBuilder({
43
+ cwd: process.cwd(),
44
+ tools: tools.list(),
45
+ permissionMode: 'ask',
46
+ });
47
+ // Create agent
48
+ const agent = new Agent(llm, tools, { hooks, maxIterations: 10 });
49
+ // Set up system prompt
50
+ session.addMessage('system', prompts.build());
51
+ return new App(config, llm, session, tools, hooks, prompts, agent);
52
+ }
53
+ /**
54
+ * Run a single prompt (non-interactive mode)
55
+ */
56
+ async runPrompt(prompt) {
57
+ this.session.addMessage('user', prompt);
58
+ let fullResponse = '';
59
+ for await (const chunk of this.agent.run(this.session.getMessages())) {
60
+ process.stdout.write(chunk);
61
+ fullResponse += chunk;
62
+ }
63
+ console.log(); // newline
64
+ this.session.addMessage('assistant', fullResponse);
65
+ return fullResponse;
66
+ }
67
+ /**
68
+ * Get the agent for streaming control
69
+ */
70
+ getAgent() {
71
+ return this.agent;
72
+ }
73
+ /**
74
+ * Get current config
75
+ */
76
+ getConfig() {
77
+ return this.config;
78
+ }
79
+ }
80
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/app/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,E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CAAC;CACF"}
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Thatgfsj Code - CLI Entry Point
4
+ * Simplified from old src/index.ts (655 lines → ~60 lines)
5
+ *
6
+ * Two modes:
7
+ * gfcode → Interactive REPL
8
+ * gfcode "prompt" → Single prompt mode
9
+ * gfcode init → Setup wizard
10
+ */
11
+ export {};
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cmd/index.ts"],"names":[],"mappings":";AAEA;;;;;;;;GAQG"}
@@ -0,0 +1,85 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Thatgfsj Code - CLI Entry Point
4
+ * Simplified from old src/index.ts (655 lines → ~60 lines)
5
+ *
6
+ * Two modes:
7
+ * gfcode → Interactive REPL
8
+ * gfcode "prompt" → Single prompt mode
9
+ * gfcode init → Setup wizard
10
+ */
11
+ // Force UTF-8 on Windows
12
+ if (process.platform === 'win32') {
13
+ try {
14
+ require('child_process').execSync('chcp 65001', { stdio: 'ignore', windowsHide: true });
15
+ }
16
+ catch { }
17
+ }
18
+ import { program } from 'commander';
19
+ import chalk from 'chalk';
20
+ import { App } from '../app/index.js';
21
+ import { REPL } from '../tui/repl.js';
22
+ import { WelcomeScreen } from '../tui/welcome.js';
23
+ import { ProjectContext } from '../utils/project.js';
24
+ // ==================== Error Handling ====================
25
+ process.on('uncaughtException', (error) => {
26
+ console.error(chalk.red('\n❌ Error:'), error.message);
27
+ process.exit(1);
28
+ });
29
+ process.on('unhandledRejection', (reason) => {
30
+ console.error(chalk.red('\n❌ Error:'), reason);
31
+ process.exit(1);
32
+ });
33
+ // ==================== CLI Commands ====================
34
+ program
35
+ .name('gfcode')
36
+ .description('🤖 Thatgfsj Code - AI Coding Assistant')
37
+ .version('0.3.0')
38
+ .argument('[prompt]', 'Task to execute (omit to start interactive mode)')
39
+ .option('-m, --model <model>', 'Specify model')
40
+ .option('-i, --interactive', 'Force interactive mode')
41
+ .option('--hooks', 'Enable audit logging hooks')
42
+ .action(async (prompt, options) => {
43
+ try {
44
+ // Initialize app
45
+ const app = await App.create();
46
+ // Show welcome if no API key
47
+ WelcomeScreen.show(app.config.hasApiKey());
48
+ // Override model if specified
49
+ if (options.model) {
50
+ await app.config.save({ model: options.model });
51
+ }
52
+ // Enable hooks if requested
53
+ if (options.hooks) {
54
+ const { auditLogHook } = await import('../hooks/index.js');
55
+ app.hooks.register('afterToolCall', auditLogHook);
56
+ }
57
+ if (!prompt || options.interactive) {
58
+ // Interactive REPL mode
59
+ const repl = new REPL(app);
60
+ await repl.start();
61
+ }
62
+ else {
63
+ // Single prompt mode
64
+ console.log(chalk.cyan('\n🤖 Thatgfsj Code\n'));
65
+ console.log(chalk.gray(ProjectContext.getSummary()));
66
+ console.log(chalk.gray('─'.repeat(40)));
67
+ console.log(chalk.cyan('\n> ') + prompt + '\n');
68
+ await app.runPrompt(prompt);
69
+ }
70
+ }
71
+ catch (error) {
72
+ console.error(chalk.red(`\n❌ ${error.message}`));
73
+ process.exit(1);
74
+ }
75
+ });
76
+ // Init command - setup wizard
77
+ program
78
+ .command('init')
79
+ .description('配置 API Key 和模型')
80
+ .action(async () => {
81
+ await WelcomeScreen.interactiveSetup();
82
+ });
83
+ // Parse and run
84
+ program.parse(process.argv);
85
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cmd/index.ts"],"names":[],"mappings":";AAEA;;;;;;;;GAQG;AAEH,yBAAyB;AACzB,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;AA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AK,CAAC,GAAG,CAAC,OAAO,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QACjD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC,CAAC,CAAC;AAEL,8BAA8B;AAC9B,OAAO;KACJ,OAAO,CAAC,MAAM,CAAC;KACf,WAAW,CAAC,gBAAgB,CAAC;KAC7B,MAAM,CAAC,KAAK,IAAI,EAAE;IACjB,MAAM,aAAa,CAAC,gBAAgB,EAAE,CAAC;AACzC,CAAC,CAAC,CAAC;AAEL,gBAAgB;AAChB,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Config Manager - Handles configuration loading and saving
3
+ * Migrated from old src/core/config.ts
4
+ */
5
+ import type { Config, AIConfig } from './types.js';
6
+ export declare class ConfigManager {
7
+ private configPath;
8
+ private config;
9
+ private constructor();
10
+ /**
11
+ * Load configuration from file + environment variables
12
+ */
13
+ static load(): Promise<ConfigManager>;
14
+ /**
15
+ * Resolve provider settings: API key from env, base URL, model
16
+ */
17
+ private static resolveProvider;
18
+ /**
19
+ * Get the current config
20
+ */
21
+ get(): Config;
22
+ /**
23
+ * Get AIConfig for LLM providers
24
+ */
25
+ getAIConfig(): AIConfig;
26
+ /**
27
+ * Get provider format (openai | anthropic | gemini)
28
+ */
29
+ getProviderFormat(): 'openai' | 'anthropic' | 'gemini';
30
+ /**
31
+ * Update config and save to file
32
+ */
33
+ save(updates: Partial<Config>): Promise<void>;
34
+ /**
35
+ * Check if an API key is configured
36
+ */
37
+ hasApiKey(): boolean;
38
+ }
39
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAgB,MAAM,YAAY,CAAC;AAWjE,qBAAa,aAAa;IACxB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,MAAM,CAAS;IAEvB,OAAO;IAKP;;OAEG;WACU,IAAI,IAAI,OAAO,CAAC,aAAa,CAAC;IAsB3C;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,eAAe;IAyB9B;;OAEG;IACH,GAAG,IAAI,MAAM;IAIb;;OAEG;IACH,WAAW,IAAI,QAAQ;IAWvB;;OAEG;IACH,iBAAiB,IAAI,QAAQ,GAAG,WAAW,GAAG,QAAQ;IAItD;;OAEG;IACG,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAWnD;;OAEG;IACH,SAAS,IAAI,OAAO;CAGrB"}