@jc20231028/local-code-agent 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +274 -263
- package/bin/local-code.js +8 -8
- package/package.json +34 -32
- package/scripts/postinstall.js +14 -0
- package/src/checkpoint.js +125 -125
- package/src/cli.js +932 -932
- package/src/config.js +106 -106
- package/src/providers/lmstudio.js +49 -49
- package/src/providers/ollama.js +52 -52
- package/src/runtime.js +341 -341
- package/src/skills.js +130 -130
- package/src/syntaxCheck.js +62 -62
- package/src/tools.js +105 -105
- package/src/ui.js +281 -281
- package/src/workspace.js +224 -224
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 jeff
|
|
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.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 jeff
|
|
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
CHANGED
|
@@ -1,263 +1,274 @@
|
|
|
1
|
-
# local-code-agent
|
|
2
|
-
|
|
3
|
-
`local-code-agent` 是一個本地端 npm CLI,功能方向接近 Claude Code,但模型來源改成你自己電腦上的:
|
|
4
|
-
|
|
5
|
-
- `Ollama`
|
|
6
|
-
- `LM Studio`
|
|
7
|
-
|
|
8
|
-
它會在啟動時先做偵測:
|
|
9
|
-
|
|
10
|
-
- 讓使用者選擇 `Ollama` 或 `LM Studio`
|
|
11
|
-
- 使用上下鍵與 Enter 在終端內選擇
|
|
12
|
-
- 檢查電腦上是否有安裝該軟體
|
|
13
|
-
- 檢查本地 API 是否已啟動
|
|
14
|
-
- 檢查是否已有可用的本地模型
|
|
15
|
-
- 將使用者選過的 `provider` / `model` 自動寫回 `.local-code.json`
|
|
16
|
-
|
|
17
|
-
如果缺少任何一項,CLI 會直接提示使用者先安裝或先下載模型。
|
|
18
|
-
|
|
19
|
-
## 目前支援的能力
|
|
20
|
-
|
|
21
|
-
- 列出檔案
|
|
22
|
-
- 讀取檔案
|
|
23
|
-
- 搜尋文字
|
|
24
|
-
- 建立資料夾
|
|
25
|
-
- 寫入或覆蓋檔案
|
|
26
|
-
- 追加內容到既有檔案(`append_file`),不用重新輸出整份既有內容
|
|
27
|
-
- 進行局部字串替換
|
|
28
|
-
- 寫入 `.py` / `.js` / `.mjs` 後自動做語法檢查,結果會回饋給模型自我修正
|
|
29
|
-
- 執行本地命令(`dotnet build`、`npm test`、`python xxx.py` 等)來編譯/測試/執行程式碼——預設每次執行前會在終端機跳出來問你要不要允許,`--allow-commands` 則整個 session 都自動允許不再詢問
|
|
30
|
-
- 用 `/名稱` 打關鍵字叫出自訂 Skill(見下方「Skill 系統」)
|
|
31
|
-
- 任務進度 Checkpoint:存目標/待辦事項,並自動附上最近對話內容,跨 session 恢復(見下方「任務進度 Checkpoint」)
|
|
32
|
-
|
|
33
|
-
##
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
`
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
`
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
-
|
|
238
|
-
-
|
|
239
|
-
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
-
|
|
250
|
-
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
-
|
|
261
|
-
-
|
|
262
|
-
|
|
263
|
-
|
|
1
|
+
# local-code-agent
|
|
2
|
+
|
|
3
|
+
`local-code-agent` 是一個本地端 npm CLI,功能方向接近 Claude Code,但模型來源改成你自己電腦上的:
|
|
4
|
+
|
|
5
|
+
- `Ollama`
|
|
6
|
+
- `LM Studio`
|
|
7
|
+
|
|
8
|
+
它會在啟動時先做偵測:
|
|
9
|
+
|
|
10
|
+
- 讓使用者選擇 `Ollama` 或 `LM Studio`
|
|
11
|
+
- 使用上下鍵與 Enter 在終端內選擇
|
|
12
|
+
- 檢查電腦上是否有安裝該軟體
|
|
13
|
+
- 檢查本地 API 是否已啟動
|
|
14
|
+
- 檢查是否已有可用的本地模型
|
|
15
|
+
- 將使用者選過的 `provider` / `model` 自動寫回 `.local-code.json`
|
|
16
|
+
|
|
17
|
+
如果缺少任何一項,CLI 會直接提示使用者先安裝或先下載模型。
|
|
18
|
+
|
|
19
|
+
## 目前支援的能力
|
|
20
|
+
|
|
21
|
+
- 列出檔案
|
|
22
|
+
- 讀取檔案
|
|
23
|
+
- 搜尋文字
|
|
24
|
+
- 建立資料夾
|
|
25
|
+
- 寫入或覆蓋檔案
|
|
26
|
+
- 追加內容到既有檔案(`append_file`),不用重新輸出整份既有內容
|
|
27
|
+
- 進行局部字串替換
|
|
28
|
+
- 寫入 `.py` / `.js` / `.mjs` 後自動做語法檢查,結果會回饋給模型自我修正
|
|
29
|
+
- 執行本地命令(`dotnet build`、`npm test`、`python xxx.py` 等)來編譯/測試/執行程式碼——預設每次執行前會在終端機跳出來問你要不要允許,`--allow-commands` 則整個 session 都自動允許不再詢問
|
|
30
|
+
- 用 `/名稱` 打關鍵字叫出自訂 Skill(見下方「Skill 系統」)
|
|
31
|
+
- 任務進度 Checkpoint:存目標/待辦事項,並自動附上最近對話內容,跨 session 恢復(見下方「任務進度 Checkpoint」)
|
|
32
|
+
|
|
33
|
+
## 安裝(推薦,跟 Claude Code 一樣)
|
|
34
|
+
|
|
35
|
+
從 npm 全域安裝,裝完就能在任何資料夾直接打 `local-code`,不用額外初始化:
|
|
36
|
+
|
|
37
|
+
```powershell
|
|
38
|
+
npm install -g @jc20231028/local-code-agent
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
裝完之後,切到任何專案資料夾都可以直接執行:
|
|
42
|
+
|
|
43
|
+
```powershell
|
|
44
|
+
cd C:\path\to\your-project
|
|
45
|
+
local-code chat
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
**注意:一定要加 `-g`。** 如果只下 `npm install @jc20231028/local-code-agent`(沒有 `-g`),
|
|
49
|
+
npm 只會把執行檔裝進當下專案的 `node_modules/.bin`,不會加進系統 PATH,
|
|
50
|
+
在 cmd 直接打 `local-code` 會抓不到指令。這種情況下要嘛加 `-g` 重裝,要嘛用 `npx local-code chat` 執行。
|
|
51
|
+
|
|
52
|
+
`provider` / `model` 留空時,`local-code chat` 第一次啟動就會直接跳出互動選單讓你選(見下方「初始化設定」),
|
|
53
|
+
不需要先手動跑 `local-code init`——`init` 只是用來印出設定檔範例,不是必要步驟。
|
|
54
|
+
|
|
55
|
+
`workspace` 預設就是執行當下的 `process.cwd()`,所以不同專案資料夾會各自使用自己的 `.local-code.json` / `.local-code-state.json`(沒有的話 CLI 會在互動模式下詢問並建立)。
|
|
56
|
+
|
|
57
|
+
## 本地開發(clone 這個 repo 時使用)
|
|
58
|
+
|
|
59
|
+
```powershell
|
|
60
|
+
npm.cmd install
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
直接執行:
|
|
64
|
+
|
|
65
|
+
```powershell
|
|
66
|
+
node ./bin/local-code.js help
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
想在其他專案資料夾測試本地修改,可以用 `npm.cmd link` 掛成全域命令:
|
|
70
|
+
|
|
71
|
+
```powershell
|
|
72
|
+
npm.cmd link
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## 初始化設定(選用)
|
|
76
|
+
|
|
77
|
+
```powershell
|
|
78
|
+
node ./bin/local-code.js init
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
建立 `.local-code.json`:
|
|
82
|
+
|
|
83
|
+
```json
|
|
84
|
+
{
|
|
85
|
+
"provider": "",
|
|
86
|
+
"model": "",
|
|
87
|
+
"workspace": ".",
|
|
88
|
+
"ollamaBaseUrl": "http://127.0.0.1:11434",
|
|
89
|
+
"lmStudioBaseUrl": "http://127.0.0.1:1234",
|
|
90
|
+
"maxSteps": 12,
|
|
91
|
+
"allowCommands": false,
|
|
92
|
+
"temperature": 0.2
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
`provider` 或 `model` 留空時,程式會在啟動時互動式詢問使用者。
|
|
97
|
+
如果目前終端不是互動模式,程式會輸出完整的 provider 診斷摘要。
|
|
98
|
+
首次選完後,CLI 會把結果寫回 `.local-code.json`,下次直接沿用。
|
|
99
|
+
|
|
100
|
+
## 用法
|
|
101
|
+
|
|
102
|
+
列出可用模型:
|
|
103
|
+
|
|
104
|
+
```powershell
|
|
105
|
+
node ./bin/local-code.js models
|
|
106
|
+
node ./bin/local-code.js models --provider ollama
|
|
107
|
+
node ./bin/local-code.js models --provider lmstudio
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
單次執行:
|
|
111
|
+
|
|
112
|
+
```powershell
|
|
113
|
+
node ./bin/local-code.js run "閱讀目前專案,建立一個簡單的 express API"
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
互動模式:
|
|
117
|
+
|
|
118
|
+
```powershell
|
|
119
|
+
node ./bin/local-code.js chat
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
執行本機命令(編譯、測試、跑程式):
|
|
123
|
+
|
|
124
|
+
```powershell
|
|
125
|
+
node ./bin/local-code.js run "編譯並執行這個 C# 專案"
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
預設不用加任何參數——模型呼叫 `run_command`(例如 `dotnet build`、`npm test`)時,會直接在終端機印出指令內容並問你 `Allow this command? [y/N]:`,按 `y` 才會真的執行。如果不是在真人操作的終端機裡執行(例如透過管道/腳本),沒有 TTY 可以問就會直接安全拒絕。
|
|
129
|
+
|
|
130
|
+
如果你完全信任這個專案、不想每次都被問,可以整個 session 跳過詢問:
|
|
131
|
+
|
|
132
|
+
```powershell
|
|
133
|
+
node ./bin/local-code.js run "執行測試並修正失敗案例" --allow-commands
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
列出目前可用的 Skill:
|
|
137
|
+
|
|
138
|
+
```powershell
|
|
139
|
+
local-code skills
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
用關鍵字叫出 Skill(`run` 跟 `chat` 都支援,一開頭打 `/名稱`):
|
|
143
|
+
|
|
144
|
+
```powershell
|
|
145
|
+
local-code run "/reviewer 看一下 src/agent.js 有沒有明顯 bug"
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
```powershell
|
|
149
|
+
local-code chat
|
|
150
|
+
> /skills
|
|
151
|
+
> /reviewer 看一下 src/agent.js 有沒有明顯 bug
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Skill 系統
|
|
155
|
+
|
|
156
|
+
Skill 是一份 Markdown 檔,開頭有簡單的 frontmatter,用來把「特定任務的額外指示」跟「這次任務可以用哪些工具」包成一個可重複使用、可分享的單位,類似 Claude Code 的 Skill / Slash command。
|
|
157
|
+
|
|
158
|
+
放置位置(同名時,專案層級蓋掉使用者層級):
|
|
159
|
+
|
|
160
|
+
- 專案層級:`<workspace>/.local-code/skills/*.md` — 可以連同專案一起 commit,團隊共用
|
|
161
|
+
- 使用者層級:`~/.local-code/skills/*.md` — 個人跨專案共用
|
|
162
|
+
|
|
163
|
+
檔案格式,例如 `.local-code/skills/reviewer.md`:
|
|
164
|
+
|
|
165
|
+
```markdown
|
|
166
|
+
---
|
|
167
|
+
name: reviewer
|
|
168
|
+
description: Review code changes for bugs, risky edge cases, and style issues.
|
|
169
|
+
keywords: rv, code-review
|
|
170
|
+
tools: read_file, search_text, list_files
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
You are in "reviewer" mode for this task. Only look for bugs, risky edge
|
|
174
|
+
cases, and style issues. Do not modify files unless explicitly asked.
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
欄位說明:
|
|
178
|
+
|
|
179
|
+
- `name`:必填,唯一識別,也是預設觸發用的 `/名稱`
|
|
180
|
+
- `description`:必填,`local-code skills` 列表會顯示
|
|
181
|
+
- `keywords`:選填,逗號分隔的別名,一樣可以用 `/別名` 觸發
|
|
182
|
+
- `tools`:選填,逗號分隔的工具白名單;省略代表這次任務可以用全部工具。模型呼叫白名單以外的工具時,會收到明確的錯誤訊息(不會讓整個 CLI 崩潰),可以在剩餘步數內自行改用允許的工具
|
|
183
|
+
|
|
184
|
+
觸發方式是明確的 `/名稱` 前綴(不是讓模型自己語意判斷要不要用),對本地小型模型來說最穩定、可預期:
|
|
185
|
+
|
|
186
|
+
```powershell
|
|
187
|
+
local-code run "/reviewer 檢查 src/agent.js"
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
`reviewer` 開頭的指示會被組進送給模型的內容,格式類似:
|
|
191
|
+
|
|
192
|
+
```
|
|
193
|
+
[Skill: reviewer]
|
|
194
|
+
<skill 內文>
|
|
195
|
+
|
|
196
|
+
Task: 檢查 src/agent.js
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
保留字(不能拿來當 Skill 名稱或別名,會被忽略並印出警告):`exit`、`provider`、`model`、`status`、`skills`。
|
|
200
|
+
|
|
201
|
+
`chat` 模式內也可以用 `/skills` 列出可用 Skill,或直接打 `/名稱 ...` 觸發。
|
|
202
|
+
|
|
203
|
+
## Chat 指令與記憶重置
|
|
204
|
+
|
|
205
|
+
`chat` 對話記錄會存在 `.local-code-state.json`,下次在同一個資料夾用同樣的 provider/model 開 `chat` 時會自動還原(`restored saved chat history (N turn(s))`)。
|
|
206
|
+
|
|
207
|
+
Chat 內建指令:
|
|
208
|
+
|
|
209
|
+
- `/provider` 切換 provider,同時清空記憶重新開始
|
|
210
|
+
- `/model` 切換 model,同時清空記憶重新開始
|
|
211
|
+
- `/status` 顯示目前 provider、model、workspace、記憶狀態
|
|
212
|
+
- `/reset` 只清空對話記憶,provider/model/workspace 都不變
|
|
213
|
+
- `/skills` 列出可用 Skill
|
|
214
|
+
- `/exit` 離開
|
|
215
|
+
|
|
216
|
+
**什麼時候要用 `/reset`:** 對話記憶會把過去的 `<tool_result>`(包含失敗訊息)一起還原給模型。如果你升級了 `local-code`(例如修了某個工具的 bug)、或改了 `--allow-commands` 之類的設定,但這個資料夾的 chat 記憶裡還留著「舊版工具失敗」的紀錄,模型會傾向照著自己之前講過的話回答,即使新版工具其實已經能做到了,也可能還是說「我做不到」。這時候打 `/reset` 清掉舊記憶重新開始,模型才會重新嘗試。
|
|
217
|
+
|
|
218
|
+
## 任務進度 Checkpoint
|
|
219
|
+
|
|
220
|
+
跟 chat 記憶(對話逐字稿)分開,另外提供一套「任務進度」的存檔機制:記錄目標、目前狀態、已完成/待完成的步驟、背景決策、卡關點、關鍵檔案,存在同一個 `.local-code-state.json` 的 `checkpoints`欄位裡,跨資料夾重開 `chat` 或重啟電腦都還在。
|
|
221
|
+
|
|
222
|
+
存檔時會**自動從當下的對話紀錄擷取最近幾則你打過的原始 prompt**(會過濾掉 `<tool_result>` 之類的工具回傳內容,只留你自己輸入的部分),附加進 checkpoint 裡,不用自己手動回想輸入一次。
|
|
223
|
+
|
|
224
|
+
在 `chat` 內使用:
|
|
225
|
+
|
|
226
|
+
```
|
|
227
|
+
/checkpoint # 互動式存檔(依序詢問目標/狀態/已完成/待辦/背景/卡關點/關鍵檔案)
|
|
228
|
+
/checkpoint list # 列出所有 checkpoint
|
|
229
|
+
/checkpoint show [id] # 顯示指定或目前進行中的 checkpoint 完整內容
|
|
230
|
+
/checkpoint complete [id] # 標記完成
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
不進 chat,直接用 CLI 也可以:
|
|
234
|
+
|
|
235
|
+
```powershell
|
|
236
|
+
node ./bin/local-code.js checkpoint save
|
|
237
|
+
node ./bin/local-code.js checkpoint list
|
|
238
|
+
node ./bin/local-code.js checkpoint show
|
|
239
|
+
node ./bin/local-code.js checkpoint complete
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
只要該資料夾還有「進行中」(未標記完成)的 checkpoint,下次執行 `local-code chat` 時會自動在最上方顯示,提醒你從待辦步驟繼續,不用自己去找。
|
|
243
|
+
|
|
244
|
+
## 偵測邏輯
|
|
245
|
+
|
|
246
|
+
`Ollama`
|
|
247
|
+
|
|
248
|
+
- 先檢查 `ollama` 指令或常見安裝路徑
|
|
249
|
+
- 再檢查 `http://127.0.0.1:11434/api/tags`
|
|
250
|
+
- 如果沒有模型,會提示像 `ollama pull qwen2.5-coder:7b`
|
|
251
|
+
|
|
252
|
+
`LM Studio`
|
|
253
|
+
|
|
254
|
+
- 先檢查 `LM Studio` 常見安裝路徑或 `lms` 指令
|
|
255
|
+
- 再檢查 `http://127.0.0.1:1234/v1/models`
|
|
256
|
+
- 如果沒有模型,會提示先在 LM Studio 下載並啟用 local server
|
|
257
|
+
|
|
258
|
+
## 限制
|
|
259
|
+
|
|
260
|
+
- 目前仍是 MVP,不是完整複刻 Claude Code
|
|
261
|
+
- 工具呼叫仍採 prompt 協議,不是原生 function calling,本地小型模型偶爾會把大段程式碼包進 JSON 時跳脫字元出錯或被輸出長度截斷(CLI 會自動重試、多次失敗會清楚回報而不是靜默卡住,但無法保證每次都成功)
|
|
262
|
+
- `replace_in_file` 仍是字串替換,不是 AST 或 diff patch
|
|
263
|
+
- 語法檢查目前只支援 `.py`(需要系統裝有 `python`/`python3`/`py`)與 `.js`/`.mjs`(用 Node 內建 `--check`),其他副檔名不會檢查
|
|
264
|
+
- Skill 觸發只支援明確的 `/名稱` 前綴,沒有 Claude Code 那種依描述語意自動判斷要不要用某個 Skill 的能力
|
|
265
|
+
- 模型偶爾會在自然語言回答裡「宣稱」做了某件事但實際沒有呼叫工具(幻覺);system prompt 已要求模型有實際工具結果才能宣稱成功、被問到檔案在哪要先查證,但無法 100% 杜絕,遇到可疑的回答可以直接請它用 `list_files`/`read_file` 再次確認
|
|
266
|
+
|
|
267
|
+
## Workspace 掃描的容錯處理
|
|
268
|
+
|
|
269
|
+
啟動時(例如顯示「最近修改的檔案」)會遞迴掃描 workspace 目錄。掃描邏輯會:
|
|
270
|
+
|
|
271
|
+
- 略過讀取失敗(權限不足、壞掉的 symlink 等)的檔案或資料夾,不會讓整個 CLI 崩潰
|
|
272
|
+
- 最多掃描 5000 個項目,避免在超大型目錄(例如整個使用者家目錄)下卡住
|
|
273
|
+
|
|
274
|
+
如果直接在很大的資料夾(如使用者家目錄)下執行,建議還是切到實際的專案子資料夾再用 `local-code`,掃描範圍較小、啟動也更快。
|
package/bin/local-code.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { main } from "../src/cli.js";
|
|
4
|
-
|
|
5
|
-
main(process.argv.slice(2)).catch((error) => {
|
|
6
|
-
console.error(error instanceof Error ? error.message : String(error));
|
|
7
|
-
process.exitCode = 1;
|
|
8
|
-
});
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { main } from "../src/cli.js";
|
|
4
|
+
|
|
5
|
+
main(process.argv.slice(2)).catch((error) => {
|
|
6
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
7
|
+
process.exitCode = 1;
|
|
8
|
+
});
|