sp-rag 0.6.13 → 0.6.15
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 +138 -70
- package/dist/cli.js +104 -13
- package/dist/lib/config-store.js +7 -2
- package/dist/lib/json.js +6 -0
- package/dist/lib/mcp-config.js +2 -1
- package/dist/lib/skill.js +295 -85
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
|
-
# `sp-rag`
|
|
1
|
+
# `sp-rag`
|
|
2
|
+
|
|
3
|
+
## Context boundary
|
|
4
|
+
|
|
5
|
+
`sp-rag` exists to connect IDEs/agents to SP-RAG evidence for the `seo-booster`
|
|
6
|
+
application.
|
|
7
|
+
|
|
8
|
+
- `graphrag-core` is the SP-RAG platform and knowledge runtime.
|
|
9
|
+
- `seo-booster` is the target application and source workspace for app/business review.
|
|
10
|
+
- `GitNexus`/codegraph references are platform internals or artifact sources, not
|
|
11
|
+
the project to review unless the task explicitly asks for codegraph debugging.
|
|
12
|
+
- For project-scoped installs, use `--cwd <seo-booster-workspace>`.
|
|
13
|
+
- Do not install project-scoped VS Code/Cursor/Claude config into `<graphrag-core-workspace>` when the goal is to review `seo-booster`.
|
|
14
|
+
- Use `<graphrag-core-workspace>` as `--cwd` only when developing or debugging this SP-RAG platform itself.
|
|
15
|
+
- `<seo-booster-workspace>` and `<graphrag-core-workspace>` are placeholders, not literal paths. Replace them with the local checkout path on each machine, or omit `--cwd` when already inside the target repo.
|
|
16
|
+
|
|
17
|
+
Canonical boundary doc: [../../docs/runbooks/sp-rag-seo-booster-boundary.md](../../docs/runbooks/sp-rag-seo-booster-boundary.md)
|
|
2
18
|
|
|
3
19
|
CLI để setup nhanh SP-RAG theo hướng dev-friendly:
|
|
4
20
|
|
|
@@ -17,7 +33,7 @@ CLI để setup nhanh SP-RAG theo hướng dev-friendly:
|
|
|
17
33
|
## Trạng thái package
|
|
18
34
|
|
|
19
35
|
- package npm public: `sp-rag`
|
|
20
|
-
- version đang publish: `0.6.
|
|
36
|
+
- version đang publish: `0.6.15`
|
|
21
37
|
- binary public: `sp-rag`
|
|
22
38
|
|
|
23
39
|
## Cài từ source trong monorepo
|
|
@@ -32,30 +48,32 @@ node dist/index.js doctor
|
|
|
32
48
|
|
|
33
49
|
## Cài nhanh qua `npx`
|
|
34
50
|
|
|
35
|
-
```bash
|
|
36
|
-
npx sp-rag@latest
|
|
37
|
-
npx sp-rag@latest install --client
|
|
38
|
-
npx sp-rag@latest install --client
|
|
39
|
-
npx sp-rag@latest
|
|
40
|
-
npx sp-rag@latest
|
|
41
|
-
npx sp-rag@latest
|
|
42
|
-
npx sp-rag@latest
|
|
51
|
+
```bash
|
|
52
|
+
npx sp-rag@latest token add --token <grc_pat_...>
|
|
53
|
+
npx sp-rag@latest install --client codex --doctor
|
|
54
|
+
npx sp-rag@latest install --client cursor --cwd <seo-booster-workspace>
|
|
55
|
+
npx sp-rag@latest install --client vscode --cwd <seo-booster-workspace>
|
|
56
|
+
npx sp-rag@latest add --client claude-code --scope project --cwd <seo-booster-workspace>
|
|
57
|
+
npx sp-rag@latest update --client claude-code --scope project --cwd <seo-booster-workspace>
|
|
58
|
+
npx sp-rag@latest uninstall --client claude-code --scope project --cwd <seo-booster-workspace>
|
|
59
|
+
npx sp-rag@latest explain --client vscode --scope project --cwd <seo-booster-workspace>
|
|
43
60
|
npx sp-rag@latest token add --token <grc_pat_...>
|
|
44
61
|
npx sp-rag@latest token verify --token <grc_pat_...>
|
|
45
62
|
npx sp-rag@latest mcp add antigravity
|
|
46
|
-
npx sp-rag@latest mcp add opencode --scope project --cwd
|
|
47
|
-
npx sp-rag@latest skill install --client cursor --scope project --cwd
|
|
48
|
-
npx sp-rag@latest skill install --client vscode --scope project --cwd
|
|
63
|
+
npx sp-rag@latest mcp add opencode --scope project --cwd <seo-booster-workspace>
|
|
64
|
+
npx sp-rag@latest skill install --client cursor --scope project --cwd <seo-booster-workspace>
|
|
65
|
+
npx sp-rag@latest skill install --client vscode --scope project --cwd <seo-booster-workspace>
|
|
49
66
|
```
|
|
50
67
|
|
|
51
68
|
Tương đương bằng `npm`:
|
|
52
69
|
|
|
53
|
-
```bash
|
|
54
|
-
npm exec --yes sp-rag@latest
|
|
55
|
-
npm exec --yes sp-rag@latest
|
|
56
|
-
npm exec --yes sp-rag@latest
|
|
57
|
-
npm exec --yes sp-rag@latest
|
|
58
|
-
npm exec --yes sp-rag@latest
|
|
70
|
+
```bash
|
|
71
|
+
npm exec --yes sp-rag@latest token add -- --token <grc_pat_...>
|
|
72
|
+
npm exec --yes sp-rag@latest install -- --client codex --doctor
|
|
73
|
+
npm exec --yes sp-rag@latest add -- --client claude-code --scope project --cwd <seo-booster-workspace>
|
|
74
|
+
npm exec --yes sp-rag@latest update -- --client claude-code --scope project --cwd <seo-booster-workspace>
|
|
75
|
+
npm exec --yes sp-rag@latest uninstall -- --client claude-code --scope project --cwd <seo-booster-workspace>
|
|
76
|
+
npm exec --yes sp-rag@latest explain -- --client vscode --scope project --cwd <seo-booster-workspace>
|
|
59
77
|
npm exec --yes sp-rag@latest token add -- --token <grc_pat_...>
|
|
60
78
|
npm exec --yes sp-rag@latest token verify -- --token <grc_pat_...>
|
|
61
79
|
```
|
|
@@ -64,13 +82,14 @@ npm exec --yes sp-rag@latest token verify -- --token <grc_pat_...>
|
|
|
64
82
|
|
|
65
83
|
Flow khuyên dùng sau khi đã có `grc_pat_*`:
|
|
66
84
|
|
|
67
|
-
1. chạy `
|
|
68
|
-
2.
|
|
69
|
-
3.
|
|
70
|
-
4. khi muốn
|
|
71
|
-
5. khi
|
|
72
|
-
6. khi
|
|
73
|
-
7. khi
|
|
85
|
+
1. chạy `sp-rag token add --token <grc_pat_...>` đúng một lần để lưu token
|
|
86
|
+
2. chạy `install` cho client đầu tiên, không cần kèm `--mcp-token`
|
|
87
|
+
3. từ lần sau, dùng `add --client ...` để cài thêm MCP + skill cho client khác mà không phải nhập lại token
|
|
88
|
+
4. khi muốn cập nhật lại MCP + skill mà giữ token cũ, dùng `update`
|
|
89
|
+
5. khi muốn gỡ sạch MCP + skill + config CLI do `sp-rag` tạo, dùng `uninstall`
|
|
90
|
+
6. khi chỉ muốn làm một nửa, dùng `mcp add` hoặc `skill install`
|
|
91
|
+
7. khi đổi token, chỉ cần `token add`
|
|
92
|
+
8. khi muốn kiểm tra máy đang được cấu hình ra sao, dùng `explain`
|
|
74
93
|
|
|
75
94
|
Ghi chú:
|
|
76
95
|
|
|
@@ -82,15 +101,16 @@ Ghi chú:
|
|
|
82
101
|
|
|
83
102
|
Ví dụ:
|
|
84
103
|
|
|
85
|
-
```bash
|
|
86
|
-
sp-rag
|
|
87
|
-
sp-rag
|
|
88
|
-
sp-rag
|
|
89
|
-
sp-rag
|
|
104
|
+
```bash
|
|
105
|
+
sp-rag token add --token <grc_pat_...>
|
|
106
|
+
sp-rag install --client vscode --cwd <seo-booster-workspace> --doctor
|
|
107
|
+
sp-rag add --client cursor --cwd <seo-booster-workspace>
|
|
108
|
+
sp-rag update --client vscode --cwd <seo-booster-workspace>
|
|
109
|
+
sp-rag uninstall --client claude-code --scope project --cwd <seo-booster-workspace>
|
|
90
110
|
sp-rag mcp add antigravity
|
|
91
|
-
sp-rag skill install --client vscode --scope project --cwd
|
|
111
|
+
sp-rag skill install --client vscode --scope project --cwd <seo-booster-workspace>
|
|
92
112
|
sp-rag token add --token <grc_pat_moi>
|
|
93
|
-
sp-rag explain --client vscode --scope project --cwd
|
|
113
|
+
sp-rag explain --client vscode --scope project --cwd <seo-booster-workspace>
|
|
94
114
|
```
|
|
95
115
|
|
|
96
116
|
## Lấy token ở đâu
|
|
@@ -137,19 +157,20 @@ curl -X POST https://sp-rag.secomapp.com/api/v1/account/personal-access-tokens \
|
|
|
137
157
|
|
|
138
158
|
Response sẽ trả `generated_token`, chính là token `grc_pat_*` để đưa vào `sp-rag`.
|
|
139
159
|
|
|
140
|
-
Ví dụ dev
|
|
141
|
-
|
|
142
|
-
```bash
|
|
143
|
-
npx sp-rag@latest
|
|
144
|
-
npx sp-rag@latest
|
|
145
|
-
npx sp-rag@latest
|
|
146
|
-
|
|
160
|
+
Ví dụ dev lưu token một lần rồi cài client:
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
npx sp-rag@latest token add --token <grc_pat_...>
|
|
164
|
+
npx sp-rag@latest install --client cursor --cwd <seo-booster-workspace>
|
|
165
|
+
npx sp-rag@latest token verify --token <grc_pat_...>
|
|
166
|
+
npx sp-rag@latest explain --client cursor --scope project --cwd <seo-booster-workspace>
|
|
167
|
+
```
|
|
147
168
|
|
|
148
169
|
Hoặc dùng biến môi trường:
|
|
149
170
|
|
|
150
171
|
```bash
|
|
151
172
|
$env:GRAPHRAG_MCP_TOKEN="<grc_pat_...>"
|
|
152
|
-
npx sp-rag@latest mcp add vscode --scope project --cwd
|
|
173
|
+
npx sp-rag@latest mcp add vscode --scope project --cwd <seo-booster-workspace> --auth-env-var GRAPHRAG_MCP_TOKEN
|
|
153
174
|
npx sp-rag@latest token verify --token $env:GRAPHRAG_MCP_TOKEN
|
|
154
175
|
```
|
|
155
176
|
|
|
@@ -205,14 +226,14 @@ Ghi chú:
|
|
|
205
226
|
|
|
206
227
|
## Luồng khuyên dùng cho dev mới
|
|
207
228
|
|
|
208
|
-
```bash
|
|
209
|
-
sp-rag
|
|
210
|
-
sp-rag
|
|
211
|
-
sp-rag
|
|
212
|
-
sp-rag
|
|
229
|
+
```bash
|
|
230
|
+
sp-rag token add --token <grc_pat_...>
|
|
231
|
+
sp-rag install --client codex --doctor
|
|
232
|
+
sp-rag add --client cursor --cwd <seo-booster-workspace>
|
|
233
|
+
sp-rag update --client cursor --cwd <seo-booster-workspace>
|
|
234
|
+
sp-rag uninstall --client cursor --scope project --cwd <seo-booster-workspace>
|
|
213
235
|
sp-rag explain --client codex
|
|
214
|
-
sp-rag token
|
|
215
|
-
sp-rag token verify --token <grc_pat_...>
|
|
236
|
+
sp-rag token verify --token <grc_pat_...>
|
|
216
237
|
sp-rag config show
|
|
217
238
|
sp-rag codegraph status
|
|
218
239
|
sp-rag codegraph watch --interval-ms 2000
|
|
@@ -220,27 +241,29 @@ sp-rag codegraph runs --limit 5
|
|
|
220
241
|
sp-rag codegraph metrics
|
|
221
242
|
sp-rag codegraph recover --reason "Ops dọn stale run sau crash"
|
|
222
243
|
sp-rag mcp add antigravity
|
|
223
|
-
sp-rag mcp add vscode --scope project --cwd
|
|
224
|
-
sp-rag mcp add opencode --scope project --cwd
|
|
244
|
+
sp-rag mcp add vscode --scope project --cwd <seo-booster-workspace>
|
|
245
|
+
sp-rag mcp add opencode --scope project --cwd <seo-booster-workspace>
|
|
225
246
|
sp-rag skill install --client codex
|
|
226
|
-
sp-rag skill install --client cursor --scope project --cwd
|
|
227
|
-
sp-rag skill install --client vscode --scope project --cwd
|
|
247
|
+
sp-rag skill install --client cursor --scope project --cwd <seo-booster-workspace>
|
|
248
|
+
sp-rag skill install --client vscode --scope project --cwd <seo-booster-workspace>
|
|
228
249
|
sp-rag eval run --file ./examples/eval-suite.sample.json
|
|
229
|
-
sp-rag update --client vscode --scope project --cwd
|
|
230
|
-
sp-rag uninstall --client vscode --scope project --cwd
|
|
250
|
+
sp-rag update --client vscode --scope project --cwd <seo-booster-workspace>
|
|
251
|
+
sp-rag uninstall --client vscode --scope project --cwd <seo-booster-workspace>
|
|
231
252
|
```
|
|
232
253
|
|
|
233
254
|
## Lệnh chính
|
|
234
255
|
|
|
235
|
-
```bash
|
|
236
|
-
sp-rag
|
|
237
|
-
sp-rag
|
|
238
|
-
sp-rag
|
|
239
|
-
sp-rag
|
|
240
|
-
sp-rag token verify --token <grc_pat_...>
|
|
241
|
-
sp-rag config show
|
|
242
|
-
sp-rag doctor
|
|
243
|
-
sp-rag
|
|
256
|
+
```bash
|
|
257
|
+
sp-rag token add --token <grc_pat_...>
|
|
258
|
+
sp-rag install --client codex --doctor
|
|
259
|
+
sp-rag add --client cursor --cwd <seo-booster-workspace>
|
|
260
|
+
sp-rag explain --client codex
|
|
261
|
+
sp-rag token verify --token <grc_pat_...>
|
|
262
|
+
sp-rag config show
|
|
263
|
+
sp-rag doctor
|
|
264
|
+
sp-rag audit install --client codex
|
|
265
|
+
sp-rag audit signal --file ./sp-audit-signal.json
|
|
266
|
+
sp-rag codegraph status
|
|
244
267
|
sp-rag codegraph watch --interval-ms 2000
|
|
245
268
|
sp-rag codegraph runs --limit 10
|
|
246
269
|
sp-rag codegraph metrics
|
|
@@ -249,11 +272,11 @@ sp-rag codegraph sync --branch master --commit-sha <sha> --webhook-token <token
|
|
|
249
272
|
sp-rag docs get public --format md
|
|
250
273
|
sp-rag mcp add codex
|
|
251
274
|
sp-rag mcp add antigravity
|
|
252
|
-
sp-rag mcp add vscode --scope project --cwd
|
|
253
|
-
sp-rag mcp add opencode --scope project --cwd
|
|
275
|
+
sp-rag mcp add vscode --scope project --cwd <seo-booster-workspace>
|
|
276
|
+
sp-rag mcp add opencode --scope project --cwd <seo-booster-workspace>
|
|
254
277
|
sp-rag skill install --client codex
|
|
255
|
-
sp-rag skill install --client cursor --scope project --cwd
|
|
256
|
-
sp-rag skill install --client vscode --scope project --cwd
|
|
278
|
+
sp-rag skill install --client cursor --scope project --cwd <seo-booster-workspace>
|
|
279
|
+
sp-rag skill install --client vscode --scope project --cwd <seo-booster-workspace>
|
|
257
280
|
sp-rag eval run --file ./examples/eval-suite.sample.json
|
|
258
281
|
sp-rag update --client codex
|
|
259
282
|
sp-rag update setup --client codex
|
|
@@ -274,7 +297,7 @@ sp-rag uninstall --client codex
|
|
|
274
297
|
Ví dụ:
|
|
275
298
|
|
|
276
299
|
```bash
|
|
277
|
-
sp-rag doctor --client vscode --scope project --cwd
|
|
300
|
+
sp-rag doctor --client vscode --scope project --cwd <seo-booster-workspace>
|
|
278
301
|
```
|
|
279
302
|
|
|
280
303
|
Nếu output có dòng:
|
|
@@ -303,7 +326,51 @@ Giá trị mặc định:
|
|
|
303
326
|
|
|
304
327
|
- base URL: `https://sp-rag.secomapp.com`
|
|
305
328
|
- MCP URL: `https://sp-rag.secomapp.com/mcp`
|
|
306
|
-
- alias MCP: `sp-rag`
|
|
329
|
+
- alias MCP: `sp-rag`
|
|
330
|
+
|
|
331
|
+
## Audit workflow `sp-rag audit`
|
|
332
|
+
|
|
333
|
+
`sp-audit` khong phai la CLI moi. No la skill/agent workflow duoc cai bang
|
|
334
|
+
CLI hien tai `sp-rag`.
|
|
335
|
+
|
|
336
|
+
Lenh chuan de cai audit workflow:
|
|
337
|
+
|
|
338
|
+
```bash
|
|
339
|
+
sp-rag audit install --client codex
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
Lenh nay:
|
|
343
|
+
|
|
344
|
+
- cai MCP config cho client da chon
|
|
345
|
+
- cai native skill/rule/custom agent `sp-audit`
|
|
346
|
+
- tai su dung config/token cua `sp-rag`
|
|
347
|
+
- van la cung binary `sp-rag`, tuong tu `sp-rag add` hay `sp-rag doctor`
|
|
348
|
+
- neu token chua duoc luu, chay `sp-rag token add --token <grc_pat_...>` mot lan truoc do
|
|
349
|
+
- scope mac dinh suy theo client: `codex` la global, `cursor`/`vscode` la project
|
|
350
|
+
|
|
351
|
+
Neu chi muon cai lai skill audit ma khong cham vao MCP config, co the dung
|
|
352
|
+
low-level command:
|
|
353
|
+
|
|
354
|
+
```bash
|
|
355
|
+
sp-rag skill install --client codex --name sp-audit
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
Day JSON signal do `sp-audit` tao ra vao server memory import path:
|
|
359
|
+
|
|
360
|
+
```bash
|
|
361
|
+
sp-rag audit signal --file ./sp-audit-signal.json
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
Native paths cua audit workflow:
|
|
365
|
+
|
|
366
|
+
- Codex: `~/.codex/skills/sp-audit/SKILL.md`
|
|
367
|
+
- Claude Code: `.claude/skills/sp-audit/SKILL.md` hoac `~/.claude/skills/sp-audit/SKILL.md`
|
|
368
|
+
- Antigravity: `~/.gemini/antigravity/skills/sp-audit/SKILL.md`
|
|
369
|
+
- OpenCode: `~/.config/opencode/skills/sp-audit/SKILL.md`
|
|
370
|
+
- Cursor: `.cursor/rules/sp-audit.mdc`
|
|
371
|
+
- VS Code: `.github/agents/sp-audit.agent.md` hoac `~/.copilot/agents/sp-audit.agent.md`
|
|
372
|
+
|
|
373
|
+
Chi tiet: [Runbook `sp-rag audit`](../../docs/runbooks/sp-audit.md).
|
|
307
374
|
|
|
308
375
|
## Evaluation mẫu
|
|
309
376
|
|
|
@@ -312,6 +379,7 @@ Giá trị mặc định:
|
|
|
312
379
|
## Tài liệu thêm
|
|
313
380
|
|
|
314
381
|
- [Hướng dẫn dev sử dụng SP-RAG](../../docs/runbooks/dev-usage-guide.md)
|
|
315
|
-
- [Runbook CLI `sp-rag`](../../docs/runbooks/sp-rag-cli.md)
|
|
382
|
+
- [Runbook CLI `sp-rag`](../../docs/runbooks/sp-rag-cli.md)
|
|
383
|
+
- [Runbook `sp-rag audit`](../../docs/runbooks/sp-audit.md)
|
|
316
384
|
- [Runbook phát hành CLI `sp-rag`](../../docs/runbooks/sp-rag-cli-release.md)
|
|
317
385
|
- [Runbook MCP Public](../../docs/runbooks/mcp-public-clients.md)
|
package/dist/cli.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
2
3
|
import { clearCliConfig, loadCliConfig, saveCliConfig, } from './lib/config-store.js';
|
|
3
4
|
import { runEvaluationSuite } from './lib/eval.js';
|
|
4
5
|
import { defaultBaseUrl, defaultMcpServerAlias, defaultMcpUrl, installMcpConfig, removeMcpConfig, resolveMcpConfigPath, } from './lib/mcp-config.js';
|
|
5
6
|
import { diagnoseMcpConfig, formatMcpDoctorResult } from './lib/doctor.js';
|
|
6
7
|
import { fetchJson, fetchText, runDoctor } from './lib/http.js';
|
|
7
|
-
import { installSkill, removeSkill, resolveSkillInstallTarget, } from './lib/skill.js';
|
|
8
|
+
import { installSkill, removeSkill, resolveSkillInstallTarget, supportedSkillName, } from './lib/skill.js';
|
|
8
9
|
let cliVersionPromise;
|
|
9
10
|
async function resolveCliVersion() {
|
|
10
11
|
if (!cliVersionPromise) {
|
|
@@ -83,6 +84,20 @@ function supportedSkillClient(value) {
|
|
|
83
84
|
}
|
|
84
85
|
throw new Error('Skill client phải là codex, cursor, claude-code, antigravity, vscode hoặc opencode.');
|
|
85
86
|
}
|
|
87
|
+
function resolveSelectedSkillName(parsed) {
|
|
88
|
+
return supportedSkillName(optionString(parsed, 'name') ??
|
|
89
|
+
optionString(parsed, 'skill-name') ??
|
|
90
|
+
optionString(parsed, 'skill'));
|
|
91
|
+
}
|
|
92
|
+
function withSelectedSkillName(parsed, skillName) {
|
|
93
|
+
return {
|
|
94
|
+
...parsed,
|
|
95
|
+
options: {
|
|
96
|
+
...parsed.options,
|
|
97
|
+
name: skillName,
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
}
|
|
86
101
|
function defaultSkillClientForMcpClient(client) {
|
|
87
102
|
switch (client) {
|
|
88
103
|
case 'codex':
|
|
@@ -110,6 +125,13 @@ function supportedScope(value) {
|
|
|
110
125
|
}
|
|
111
126
|
throw new Error('Scope phải là global hoặc project.');
|
|
112
127
|
}
|
|
128
|
+
function hasExplicitClientSelection(parsed, explicitClient) {
|
|
129
|
+
return Boolean(explicitClient ?? optionString(parsed, 'client') ?? parsed.positionals[2]);
|
|
130
|
+
}
|
|
131
|
+
function resolveScopeForSelectedClient(parsed, defaults, explicitClient) {
|
|
132
|
+
return (supportedScope(optionString(parsed, 'scope')) ??
|
|
133
|
+
(hasExplicitClientSelection(parsed, explicitClient) ? undefined : defaults.defaultScope));
|
|
134
|
+
}
|
|
113
135
|
async function loadRuntimeDefaults(parsed) {
|
|
114
136
|
const homeDir = optionString(parsed, 'home-dir');
|
|
115
137
|
const config = await loadCliConfig(homeDir);
|
|
@@ -168,7 +190,7 @@ function resolveSelectedSkillClient(parsed, defaults, client) {
|
|
|
168
190
|
}
|
|
169
191
|
function deriveDefaultsForClient(parsed, defaults, client) {
|
|
170
192
|
const nextClient = client ?? defaults.defaultClient;
|
|
171
|
-
const nextScope =
|
|
193
|
+
const nextScope = resolveScopeForSelectedClient(parsed, defaults);
|
|
172
194
|
const nextSkillClient = resolveSelectedSkillClient(parsed, defaults, nextClient);
|
|
173
195
|
return {
|
|
174
196
|
...defaults,
|
|
@@ -194,7 +216,7 @@ function resolveAuthForMcp(parsed, defaults) {
|
|
|
194
216
|
const authToken = validateMcpToken(optionString(parsed, 'mcp-token') ?? defaults.mcpToken);
|
|
195
217
|
const authEnvVar = optionString(parsed, 'auth-env-var') ?? defaults.authEnvVar;
|
|
196
218
|
if (!authToken?.trim() && !authEnvVar?.trim()) {
|
|
197
|
-
throw new Error('Chưa có token MCP trong config. Hãy chạy sp-rag
|
|
219
|
+
throw new Error('Chưa có token MCP trong config. Hãy chạy sp-rag token add --token <token> một lần, hoặc truyền --mcp-token cho lần cài đặt này.');
|
|
198
220
|
}
|
|
199
221
|
return {
|
|
200
222
|
authToken: authToken?.trim(),
|
|
@@ -222,10 +244,12 @@ Lệnh chính:
|
|
|
222
244
|
sp-rag codegraph recover [--base-url URL] [--reason TEXT]
|
|
223
245
|
sp-rag codegraph sync [--base-url URL] [--branch BRANCH] [--commit-sha SHA] [--force] [--webhook-token TOKEN] [--gitlab-job-token TOKEN]
|
|
224
246
|
sp-rag docs get <public|function|dev> [--base-url URL] [--format md|json|html]
|
|
225
|
-
sp-rag mcp add <codex|cursor|claude-code|antigravity|vscode|opencode> [--url URL] [--scope global|project] [--auth-env-var ENV_VAR] [--mcp-token TOKEN]
|
|
226
|
-
sp-rag skill install [--client codex|cursor|claude-code|antigravity|vscode|opencode] [--skill-client codex|cursor|claude-code|antigravity|vscode|opencode] [--scope global|project] [--cwd PATH] [--target-dir PATH] [--mcp-url URL] [--docs-url URL]
|
|
227
|
-
sp-rag
|
|
228
|
-
sp-rag
|
|
247
|
+
sp-rag mcp add <codex|cursor|claude-code|antigravity|vscode|opencode> [--url URL] [--scope global|project] [--auth-env-var ENV_VAR] [--mcp-token TOKEN]
|
|
248
|
+
sp-rag skill install [--client codex|cursor|claude-code|antigravity|vscode|opencode] [--skill-client codex|cursor|claude-code|antigravity|vscode|opencode] [--scope global|project] [--cwd PATH] [--target-dir PATH] [--mcp-url URL] [--docs-url URL]
|
|
249
|
+
sp-rag audit install --client codex|cursor|claude-code|antigravity|vscode|opencode [--scope global|project] [--mcp-token TOKEN] [--auth-env-var ENV_VAR] [--target-dir PATH] [--doctor]
|
|
250
|
+
sp-rag audit signal --file signal.json [--mcp-token TOKEN] [--external-ref REF] [--title TEXT] [--provider builtin]
|
|
251
|
+
sp-rag eval run --file eval-suite.json [--base-url URL]
|
|
252
|
+
sp-rag update setup [--client codex|cursor|claude-code|antigravity|vscode|opencode] [--name sp-rag|sp-audit] [--skill-client codex|cursor|claude-code|antigravity|vscode|opencode] [--scope global|project] [--url URL] [--auth-env-var ENV_VAR] [--target-dir PATH]
|
|
229
253
|
`;
|
|
230
254
|
}
|
|
231
255
|
function buildCliConfig(defaults) {
|
|
@@ -374,7 +398,7 @@ async function runMcpAdd(parsed, defaults, explicitClient) {
|
|
|
374
398
|
const result = await installMcpConfig({
|
|
375
399
|
client,
|
|
376
400
|
url: optionString(parsed, 'url') ?? defaults.mcpUrl,
|
|
377
|
-
scope:
|
|
401
|
+
scope: resolveScopeForSelectedClient(parsed, defaults, explicitClient),
|
|
378
402
|
authEnvVar: resolveAuthForMcp(parsed, defaults).authEnvVar,
|
|
379
403
|
authToken: resolveAuthForMcp(parsed, defaults).authToken,
|
|
380
404
|
cwd: optionString(parsed, 'cwd'),
|
|
@@ -386,6 +410,7 @@ async function runSkillInstall(parsed, defaults, explicitClient) {
|
|
|
386
410
|
const client = resolveSelectedSkillClient(parsed, defaults, explicitClient) ?? 'codex';
|
|
387
411
|
const result = await installSkill({
|
|
388
412
|
client,
|
|
413
|
+
skillName: resolveSelectedSkillName(parsed),
|
|
389
414
|
cwd: optionString(parsed, 'cwd'),
|
|
390
415
|
scope: supportedScope(optionString(parsed, 'scope')),
|
|
391
416
|
targetDir: optionString(parsed, 'target-dir'),
|
|
@@ -415,7 +440,7 @@ async function emitDoctorReport(parsed, defaults, explicitClient, checks) {
|
|
|
415
440
|
client,
|
|
416
441
|
url: defaults.mcpUrl,
|
|
417
442
|
serverAlias: defaults.serverAlias,
|
|
418
|
-
scope:
|
|
443
|
+
scope: resolveScopeForSelectedClient(parsed, defaults, explicitClient),
|
|
419
444
|
cwd: optionString(parsed, 'cwd'),
|
|
420
445
|
});
|
|
421
446
|
for (const line of formatMcpDoctorResult(mcpDiagnostic)) {
|
|
@@ -426,6 +451,9 @@ async function emitDoctorReport(parsed, defaults, explicitClient, checks) {
|
|
|
426
451
|
async function runClientSetup(parsed, defaults, client) {
|
|
427
452
|
const nextDefaults = deriveDefaultsForClient(parsed, defaults, client);
|
|
428
453
|
validateStoredToken(nextDefaults);
|
|
454
|
+
if (!optionFlag(parsed, 'skip-mcp')) {
|
|
455
|
+
resolveAuthForMcp(parsed, nextDefaults);
|
|
456
|
+
}
|
|
429
457
|
const configPath = await saveResolvedConfig(nextDefaults);
|
|
430
458
|
process.stdout.write(`Đã lưu config CLI tại ${configPath}\n`);
|
|
431
459
|
if (!optionFlag(parsed, 'skip-mcp')) {
|
|
@@ -459,7 +487,7 @@ async function runInstall(parsed) {
|
|
|
459
487
|
const defaults = await loadRuntimeDefaults(parsed);
|
|
460
488
|
const client = resolveSelectedClient(parsed, defaults);
|
|
461
489
|
if (!client) {
|
|
462
|
-
throw new Error('Thiếu client. Dùng sp-rag install --client <client
|
|
490
|
+
throw new Error('Thiếu client. Dùng sp-rag install --client <client>.');
|
|
463
491
|
}
|
|
464
492
|
await runClientSetup(parsed, defaults, client);
|
|
465
493
|
}
|
|
@@ -471,6 +499,15 @@ async function runAdd(parsed) {
|
|
|
471
499
|
}
|
|
472
500
|
await runClientSetup(parsed, defaults, client);
|
|
473
501
|
}
|
|
502
|
+
async function runAuditInstall(parsed) {
|
|
503
|
+
const auditParsed = withSelectedSkillName(parsed, 'sp-audit');
|
|
504
|
+
const defaults = await loadRuntimeDefaults(auditParsed);
|
|
505
|
+
const client = resolveSelectedClient(auditParsed, defaults);
|
|
506
|
+
if (!client) {
|
|
507
|
+
throw new Error('Thieu client. Dung sp-rag audit install --client <client>.');
|
|
508
|
+
}
|
|
509
|
+
await runClientSetup(auditParsed, defaults, client);
|
|
510
|
+
}
|
|
474
511
|
async function runTokenAdd(parsed) {
|
|
475
512
|
const defaults = await loadRuntimeDefaults(parsed);
|
|
476
513
|
const token = validateMcpToken(optionString(parsed, 'token') ?? optionString(parsed, 'mcp-token') ?? defaults.mcpToken);
|
|
@@ -507,7 +544,7 @@ async function runConfigShow(parsed) {
|
|
|
507
544
|
async function runExplain(parsed) {
|
|
508
545
|
const defaults = await loadRuntimeDefaults(parsed);
|
|
509
546
|
const client = resolveSelectedClient(parsed, defaults);
|
|
510
|
-
const scope =
|
|
547
|
+
const scope = resolveScopeForSelectedClient(parsed, defaults);
|
|
511
548
|
const tokenStatus = defaults.mcpToken?.trim()
|
|
512
549
|
? 'đã lưu'
|
|
513
550
|
: defaults.authEnvVar?.trim()
|
|
@@ -539,6 +576,7 @@ async function runExplain(parsed) {
|
|
|
539
576
|
if (skillClient) {
|
|
540
577
|
const skillTarget = resolveSkillInstallTarget({
|
|
541
578
|
client: skillClient,
|
|
579
|
+
skillName: resolveSelectedSkillName(parsed),
|
|
542
580
|
scope: supportedScope(optionString(parsed, 'scope')),
|
|
543
581
|
cwd: optionString(parsed, 'cwd'),
|
|
544
582
|
targetDir: optionString(parsed, 'target-dir'),
|
|
@@ -557,7 +595,8 @@ async function runExplain(parsed) {
|
|
|
557
595
|
lines.push('## Cách dùng chuẩn');
|
|
558
596
|
if (!defaults.mcpToken?.trim() && !defaults.authEnvVar?.trim()) {
|
|
559
597
|
lines.push('- Máy này chưa có token MCP. Hãy chạy:');
|
|
560
|
-
lines.push(
|
|
598
|
+
lines.push(' sp-rag token add --token <token>');
|
|
599
|
+
lines.push(` sp-rag install --client ${client ?? 'vscode'}`);
|
|
561
600
|
}
|
|
562
601
|
else {
|
|
563
602
|
const chosenClient = client ?? defaults.defaultClient ?? 'vscode';
|
|
@@ -586,6 +625,50 @@ async function runEval(parsed) {
|
|
|
586
625
|
process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
|
|
587
626
|
return result.failed === 0 ? 0 : 1;
|
|
588
627
|
}
|
|
628
|
+
async function runAuditSignal(parsed) {
|
|
629
|
+
const filePath = optionString(parsed, 'file');
|
|
630
|
+
if (!filePath) {
|
|
631
|
+
throw new Error('Thieu --file tro toi JSON signal cua sp-audit.');
|
|
632
|
+
}
|
|
633
|
+
const defaults = await loadRuntimeDefaults(parsed);
|
|
634
|
+
const token = validateMcpToken(optionString(parsed, 'mcp-token') ?? defaults.mcpToken);
|
|
635
|
+
if (!token?.trim()) {
|
|
636
|
+
throw new Error('Thieu token. Dung --mcp-token <grc_pat_...> hoac sp-rag token add --token <grc_pat_...>.');
|
|
637
|
+
}
|
|
638
|
+
const raw = await readFile(filePath, 'utf8');
|
|
639
|
+
let parsedSignal;
|
|
640
|
+
try {
|
|
641
|
+
parsedSignal = JSON.parse(raw);
|
|
642
|
+
}
|
|
643
|
+
catch {
|
|
644
|
+
parsedSignal = undefined;
|
|
645
|
+
}
|
|
646
|
+
const fileName = optionString(parsed, 'file-name') ?? path.basename(filePath);
|
|
647
|
+
const externalRef = optionString(parsed, 'external-ref') ?? `sp-audit:${fileName}`;
|
|
648
|
+
const titleHint = optionString(parsed, 'title') ??
|
|
649
|
+
(typeof parsedSignal?.['flow'] === 'string'
|
|
650
|
+
? `SP-AUDIT signal: ${parsedSignal['flow']}`
|
|
651
|
+
: 'SP-AUDIT optimization signal');
|
|
652
|
+
const params = new URLSearchParams({
|
|
653
|
+
external_ref: externalRef,
|
|
654
|
+
file_name: fileName,
|
|
655
|
+
content_type: 'application/json',
|
|
656
|
+
title_hint: titleHint,
|
|
657
|
+
provider: optionString(parsed, 'provider') ?? 'builtin',
|
|
658
|
+
});
|
|
659
|
+
const result = await fetchJson(`${defaults.baseUrl.replace(/\/+$/, '')}/api/v1/import/knowledge-source/file?${params.toString()}`, {
|
|
660
|
+
method: 'POST',
|
|
661
|
+
headers: {
|
|
662
|
+
authorization: `Bearer ${token.trim()}`,
|
|
663
|
+
'content-type': 'application/json',
|
|
664
|
+
},
|
|
665
|
+
body: raw,
|
|
666
|
+
});
|
|
667
|
+
process.stdout.write(`${JSON.stringify({
|
|
668
|
+
ok: true,
|
|
669
|
+
imported: result,
|
|
670
|
+
}, null, 2)}\n`);
|
|
671
|
+
}
|
|
589
672
|
async function runUpdateSetup(parsed) {
|
|
590
673
|
const defaults = await loadRuntimeDefaults(parsed);
|
|
591
674
|
const client = resolveSelectedClient(parsed, defaults);
|
|
@@ -613,7 +696,7 @@ async function runUninstall(parsed) {
|
|
|
613
696
|
if (!client) {
|
|
614
697
|
throw new Error('Thiếu client. Dùng sp-rag uninstall --client <client>.');
|
|
615
698
|
}
|
|
616
|
-
const scope =
|
|
699
|
+
const scope = resolveScopeForSelectedClient(parsed, defaults);
|
|
617
700
|
const mcpResult = await removeMcpConfig({
|
|
618
701
|
client,
|
|
619
702
|
url: optionString(parsed, 'url') ?? defaults.mcpUrl,
|
|
@@ -738,6 +821,14 @@ export async function runCli(argv) {
|
|
|
738
821
|
await runSkillInstall(parsed, defaults);
|
|
739
822
|
return 0;
|
|
740
823
|
}
|
|
824
|
+
if (group === 'audit' && action === 'install') {
|
|
825
|
+
await runAuditInstall(parsed);
|
|
826
|
+
return 0;
|
|
827
|
+
}
|
|
828
|
+
if (group === 'audit' && action === 'signal') {
|
|
829
|
+
await runAuditSignal(parsed);
|
|
830
|
+
return 0;
|
|
831
|
+
}
|
|
741
832
|
if (group === 'eval' && action === 'run') {
|
|
742
833
|
return runEval(parsed);
|
|
743
834
|
}
|
package/dist/lib/config-store.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import os from 'node:os';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { mkdir, readFile, rm, writeFile } from 'node:fs/promises';
|
|
4
|
+
import { parseJsonWithBom, stripUtf8Bom } from './json.js';
|
|
4
5
|
function stripUndefined(value) {
|
|
5
6
|
return Object.fromEntries(Object.entries(value).filter(([, entry]) => entry !== undefined));
|
|
6
7
|
}
|
|
@@ -22,10 +23,14 @@ export async function loadCliConfig(homeDir) {
|
|
|
22
23
|
}
|
|
23
24
|
throw error;
|
|
24
25
|
});
|
|
25
|
-
if (
|
|
26
|
+
if (content === null) {
|
|
26
27
|
return null;
|
|
27
28
|
}
|
|
28
|
-
|
|
29
|
+
const normalized = stripUtf8Bom(content);
|
|
30
|
+
if (!normalized.trim()) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
return parseJsonWithBom(normalized);
|
|
29
34
|
}
|
|
30
35
|
export async function saveCliConfig(config, homeDir) {
|
|
31
36
|
const filePath = resolveCliConfigPath(homeDir);
|
package/dist/lib/json.js
ADDED
package/dist/lib/mcp-config.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import os from 'node:os';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
4
|
+
import { parseJsonWithBom } from './json.js';
|
|
4
5
|
function escapeRegex(value) {
|
|
5
6
|
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
6
7
|
}
|
|
@@ -8,7 +9,7 @@ function quotedTomlKey(value) {
|
|
|
8
9
|
return `"${value.replace(/"/g, '\\"')}"`;
|
|
9
10
|
}
|
|
10
11
|
function parseJsonObject(existing) {
|
|
11
|
-
return existing?.trim() ?
|
|
12
|
+
return existing?.trim() ? parseJsonWithBom(existing) : {};
|
|
12
13
|
}
|
|
13
14
|
function withHeaders(target, headers) {
|
|
14
15
|
if (!headers) {
|
package/dist/lib/skill.js
CHANGED
|
@@ -8,6 +8,20 @@ const seoBoosterProjectGuard = [
|
|
|
8
8
|
`- Nếu basename không phải \`seo-booster\` hoặc \`sb\`, hãy kiểm tra \`git remote get-url origin\` và chỉ gọi SP-RAG khi remote hiện tại là \`${seoBoosterRemoteUrl}\`.`,
|
|
9
9
|
'- Nếu project hiện tại không khớp hai điều kiện trên, không được gọi SP-RAG và phải nói rõ MCP này chỉ dành cho seo-booster.',
|
|
10
10
|
].join('\n');
|
|
11
|
+
const seoBoosterReportGuard = [
|
|
12
|
+
'- Report file paths repo-relative; do not include machine-specific absolute workspace paths in answers.',
|
|
13
|
+
'- Confirm the workspace by repo basename and remote identity, not by printing a local absolute path.',
|
|
14
|
+
'- Do not grade SP-RAG, MCP, GitNexus, or codegraph quality unless the user explicitly asks for platform evaluation.',
|
|
15
|
+
'- Use MCP as supporting evidence for seo-booster; do not make MCP quality the main subject of an app review.',
|
|
16
|
+
'- Final verdict must judge the target seo-booster workflow or implementation.',
|
|
17
|
+
'- If serious bugs, missing retries, weak constraints, or missing tests are found, do not call the app flow reliable just because MCP citations matched source files.',
|
|
18
|
+
'- For user-facing flows, verify frontend entry points by searching route names, controller actions, or request payload keys.',
|
|
19
|
+
'- If the flow reads or writes database tables, open the actual model and migration or schema files.',
|
|
20
|
+
'- Only call MCP evidence stale when it cites a concrete file, symbol, or behavior that conflicts with current source.',
|
|
21
|
+
'- Treat semantic-only MCP entities as context-only evidence, not stale source evidence.',
|
|
22
|
+
'- Every high or medium risk should include repo-relative path, symbol, line range when available, and confidence.',
|
|
23
|
+
'- If external runtime behavior is not directly verified, mark that specific behavior as not verified instead of using it as strong evidence.',
|
|
24
|
+
].join('\n');
|
|
11
25
|
function clientLabel(client) {
|
|
12
26
|
switch (client) {
|
|
13
27
|
case 'codex':
|
|
@@ -38,6 +52,15 @@ function normalizeScope(client, scope) {
|
|
|
38
52
|
return 'global';
|
|
39
53
|
}
|
|
40
54
|
}
|
|
55
|
+
export function supportedSkillName(value) {
|
|
56
|
+
if (!value) {
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
if (value === 'sp-rag' || value === 'sp-audit') {
|
|
60
|
+
return value;
|
|
61
|
+
}
|
|
62
|
+
throw new Error('Skill name phải là sp-rag hoặc sp-audit.');
|
|
63
|
+
}
|
|
41
64
|
function requireProjectCwd(client, cwd) {
|
|
42
65
|
const resolvedCwd = cwd?.trim() ? cwd : process.cwd();
|
|
43
66
|
if (!resolvedCwd.trim()) {
|
|
@@ -45,19 +68,19 @@ function requireProjectCwd(client, cwd) {
|
|
|
45
68
|
}
|
|
46
69
|
return path.resolve(resolvedCwd);
|
|
47
70
|
}
|
|
48
|
-
export function defaultSkillDir(client = 'codex', cwd, scope) {
|
|
71
|
+
export function defaultSkillDir(client = 'codex', cwd, scope, skillName = 'sp-rag') {
|
|
49
72
|
const normalizedScope = normalizeScope(client, scope);
|
|
50
73
|
switch (client) {
|
|
51
74
|
case 'codex':
|
|
52
|
-
return path.join(os.homedir(), '.codex', 'skills',
|
|
75
|
+
return path.join(os.homedir(), '.codex', 'skills', skillName);
|
|
53
76
|
case 'claude-code':
|
|
54
77
|
return normalizedScope === 'project'
|
|
55
|
-
? path.join(requireProjectCwd(client, cwd), '.claude', 'skills',
|
|
56
|
-
: path.join(os.homedir(), '.claude', 'skills',
|
|
78
|
+
? path.join(requireProjectCwd(client, cwd), '.claude', 'skills', skillName)
|
|
79
|
+
: path.join(os.homedir(), '.claude', 'skills', skillName);
|
|
57
80
|
case 'antigravity':
|
|
58
|
-
return path.join(os.homedir(), '.gemini', 'antigravity', 'skills',
|
|
81
|
+
return path.join(os.homedir(), '.gemini', 'antigravity', 'skills', skillName);
|
|
59
82
|
case 'opencode':
|
|
60
|
-
return path.join(os.homedir(), '.config', 'opencode', 'skills',
|
|
83
|
+
return path.join(os.homedir(), '.config', 'opencode', 'skills', skillName);
|
|
61
84
|
case 'cursor':
|
|
62
85
|
if (normalizedScope !== 'project') {
|
|
63
86
|
throw new Error('Cursor rule hiện chỉ nên cài ở scope project qua .cursor/rules.');
|
|
@@ -72,10 +95,65 @@ export function defaultSkillDir(client = 'codex', cwd, scope) {
|
|
|
72
95
|
function renderSkillMarkdown(context) {
|
|
73
96
|
return `---
|
|
74
97
|
name: sp-rag
|
|
75
|
-
description: Use SP-RAG for seo-booster codebase, feature, domain, rendered-docs, import-inventory, or codegraph freshness work that needs grounded evidence.
|
|
98
|
+
description: Use SP-RAG for seo-booster codebase, feature, domain, rendered-docs, import-inventory, or codegraph freshness work that needs grounded evidence.
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
# SP-RAG
|
|
102
|
+
|
|
103
|
+
Target client: ${clientLabel(context.client)}
|
|
104
|
+
Default MCP server alias: \`${context.serverAlias}\`
|
|
105
|
+
MCP URL: \`${context.mcpUrl}\`
|
|
106
|
+
Docs URL: \`${context.docsUrl}\`
|
|
107
|
+
|
|
108
|
+
## When To Use This Skill
|
|
109
|
+
|
|
110
|
+
- Use SP-RAG whenever the request is about seo-booster codebase, features, business workflows, rendered docs, import inventory, or sync state.
|
|
111
|
+
- Use this skill for seo-booster codebase, feature, business workflow, rendered docs, import inventory, and sync-state questions.
|
|
112
|
+
- The operating model is MCP-grounded, workspace-verified.
|
|
113
|
+
- Do not treat MCP as the only source. MCP gives context; current workspace files and git state verify the final answer.
|
|
114
|
+
|
|
115
|
+
## Intent Routing
|
|
116
|
+
|
|
117
|
+
- For feature, domain, architecture, workflow, docs, or "what does this do" questions: call \`${context.serverAlias}\` MCP first, usually \`query_context\`, then verify with workspace files when implementation details matter.
|
|
118
|
+
- For current-code, edit, bug, failing-test, local-error, or "why is this broken right now" work: inspect the workspace first with \`git status --short\`, \`rg\`, and direct file reads, then use MCP to widen context if needed.
|
|
119
|
+
- For mixed questions: get MCP context, inspect current files, compare both, then answer.
|
|
120
|
+
- For docs questions, use \`get_rendered_docs\` when public, function, or dev docs may already answer the question.
|
|
121
|
+
- For sync freshness and operations, use \`get_sync_status\`, \`get_sync_runs\`, and \`get_sync_metrics\`. Only use \`trigger_code_graph_sync\` when the user explicitly asks or stale evidence is the confirmed blocker.
|
|
122
|
+
|
|
123
|
+
## Workspace Verification
|
|
124
|
+
|
|
125
|
+
1. Run or mentally account for \`git status --short\` before relying on MCP for current behavior.
|
|
126
|
+
2. If MCP cites files, inspect the current workspace version of those files when the answer depends on exact code.
|
|
127
|
+
3. If changed files are related to the question, current workspace files override MCP evidence.
|
|
128
|
+
4. If MCP and workspace disagree, say the graph may be stale and explain which source you are trusting.
|
|
129
|
+
|
|
130
|
+
## Expand Evidence
|
|
131
|
+
|
|
132
|
+
- After \`query_context\`, synthesize from \`matched_passages\`, \`top_entities\`, \`top_relations\`, \`citations\`, and \`feature_memory\` diagnostics when present.
|
|
133
|
+
- Treat \`answer_brief\` as a hint only.
|
|
134
|
+
- Do not stop at the first one or two MCP citations for broad feature questions.
|
|
135
|
+
- Expand through related symbols, callers, services, controllers, jobs, routes, models, components, and tests using workspace search when needed.
|
|
136
|
+
- Prefer rendered docs when they answer business behavior, but verify current code before making implementation claims.
|
|
137
|
+
|
|
138
|
+
## Guardrails
|
|
139
|
+
|
|
140
|
+
${seoBoosterProjectGuard}
|
|
141
|
+
${seoBoosterReportGuard}
|
|
142
|
+
- Find root cause before fixing bugs.
|
|
143
|
+
- Use evidence before conclusions; do not claim completion without verification.
|
|
144
|
+
- For behavior changes, write or update tests before implementation when feasible.
|
|
145
|
+
- If evidence may be stale, say so clearly and mention that the graph or docs may need a refresh.
|
|
146
|
+
- Do not trigger sync or import actions unless the user asked for it or the workflow truly requires it.
|
|
147
|
+
- When rendered docs already answer the question, cite or summarize those docs, then check current code if the answer depends on implementation details.
|
|
148
|
+
`;
|
|
149
|
+
}
|
|
150
|
+
function renderSpAuditMarkdown(context) {
|
|
151
|
+
return `---
|
|
152
|
+
name: sp-audit
|
|
153
|
+
description: Use when reviewing seo-booster or SP-RAG audit reports, scoring report quality, extracting optimization signals, or preparing admin-agent feedback loops.
|
|
76
154
|
---
|
|
77
155
|
|
|
78
|
-
# SP-
|
|
156
|
+
# SP-AUDIT
|
|
79
157
|
|
|
80
158
|
Target client: ${clientLabel(context.client)}
|
|
81
159
|
Default MCP server alias: \`${context.serverAlias}\`
|
|
@@ -84,119 +162,243 @@ Docs URL: \`${context.docsUrl}\`
|
|
|
84
162
|
|
|
85
163
|
## When To Use This Skill
|
|
86
164
|
|
|
87
|
-
- Use
|
|
88
|
-
- Use
|
|
89
|
-
-
|
|
90
|
-
- Do not
|
|
165
|
+
- Use this after an AI agent returns an audit or review report for seo-booster.
|
|
166
|
+
- Use it to score the report quality, identify missing verification, and extract optimization signals.
|
|
167
|
+
- Use it when the user asks to audit MCP/RAG-assisted answers, improve prompts, or make the system learn from weak reports.
|
|
168
|
+
- Do not use it as a replacement for the original source audit. This skill audits the audit result.
|
|
91
169
|
|
|
92
|
-
##
|
|
170
|
+
## Hard Boundaries
|
|
93
171
|
|
|
94
|
-
|
|
95
|
-
-
|
|
96
|
-
-
|
|
97
|
-
-
|
|
98
|
-
-
|
|
172
|
+
${seoBoosterProjectGuard}
|
|
173
|
+
- Do not grade SP-RAG, MCP, GitNexus, or codegraph quality unless the report explicitly evaluates platform quality.
|
|
174
|
+
- If the report is supposed to audit seo-booster, the final score must judge report quality for seo-booster, not MCP quality.
|
|
175
|
+
- Report file paths must be repo-relative. Do not include machine-specific absolute workspace paths in the final answer.
|
|
176
|
+
- Tra loi bang tieng Viet. Keep code symbols, file paths, route names, and JSON keys unchanged.
|
|
99
177
|
|
|
100
|
-
##
|
|
178
|
+
## Required Input
|
|
101
179
|
|
|
102
|
-
|
|
103
|
-
2. If MCP cites files, inspect the current workspace version of those files when the answer depends on exact code.
|
|
104
|
-
3. If changed files are related to the question, current workspace files override MCP evidence.
|
|
105
|
-
4. If MCP and workspace disagree, say the graph may be stale and explain which source you are trusting.
|
|
180
|
+
Before scoring, identify:
|
|
106
181
|
|
|
107
|
-
|
|
182
|
+
1. Target workflow or feature under review.
|
|
183
|
+
2. Claims made by the audit report.
|
|
184
|
+
3. MCP evidence the report used, if any.
|
|
185
|
+
4. Workspace source evidence the report verified.
|
|
186
|
+
5. Bugs, risks, tests, or gaps the report found.
|
|
108
187
|
|
|
109
|
-
|
|
110
|
-
- Treat \`answer_brief\` as a hint only.
|
|
111
|
-
- Do not stop at the first one or two MCP citations for broad feature questions.
|
|
112
|
-
- Expand through related symbols, callers, services, controllers, jobs, routes, models, components, and tests using workspace search when needed.
|
|
113
|
-
- Prefer rendered docs when they answer business behavior, but verify current code before making implementation claims.
|
|
188
|
+
If the report lacks enough evidence, score it down and say exactly what evidence is missing.
|
|
114
189
|
|
|
115
|
-
##
|
|
190
|
+
## Scoring Rubric
|
|
116
191
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
-
|
|
120
|
-
-
|
|
121
|
-
-
|
|
122
|
-
-
|
|
123
|
-
-
|
|
192
|
+
Start from 100 and subtract only for concrete gaps:
|
|
193
|
+
|
|
194
|
+
- Target and repo boundary: 10 points.
|
|
195
|
+
- MCP usage and provenance: 10 points.
|
|
196
|
+
- Source coverage across routes, controllers, services, jobs, models, database, frontend, and tests: 25 points.
|
|
197
|
+
- Evidence quality with repo-relative paths, symbols, line ranges when available, and confidence: 20 points.
|
|
198
|
+
- Risk quality with severity, what can go wrong, why current source suggests it, and verification limits: 15 points.
|
|
199
|
+
- No overclaiming, no local absolute paths, and no accidental MCP/platform grading: 10 points.
|
|
200
|
+
- Optimization signal clarity: 10 points.
|
|
201
|
+
|
|
202
|
+
Verdict bands:
|
|
203
|
+
|
|
204
|
+
- 90-100: pass.
|
|
205
|
+
- 70-89: needs optimization.
|
|
206
|
+
- 0-69: fail.
|
|
207
|
+
|
|
208
|
+
## Required Output
|
|
209
|
+
|
|
210
|
+
Use this exact structure:
|
|
211
|
+
|
|
212
|
+
## 1. Audit score
|
|
213
|
+
- Score: X/100
|
|
214
|
+
- Verdict: pass | needs optimization | fail
|
|
215
|
+
|
|
216
|
+
## 2. What the report did well
|
|
217
|
+
|
|
218
|
+
## 3. Issues in the report
|
|
219
|
+
|
|
220
|
+
## 4. Required improvements
|
|
221
|
+
|
|
222
|
+
Separate improvements into:
|
|
223
|
+
- Prompt or skill guardrails.
|
|
224
|
+
- MCP retrieval or indexing.
|
|
225
|
+
- Source-inspection checklist.
|
|
226
|
+
- Tests or evaluation cases.
|
|
227
|
+
|
|
228
|
+
## 5. Optimization signals for server memory
|
|
229
|
+
|
|
230
|
+
Return one compact JSON object:
|
|
231
|
+
|
|
232
|
+
~~~json
|
|
233
|
+
{
|
|
234
|
+
"target_app": "seo-booster",
|
|
235
|
+
"flow": "short workflow name",
|
|
236
|
+
"score": 0,
|
|
237
|
+
"verdict": "pass | needs_optimization | fail",
|
|
238
|
+
"missing_checks": [],
|
|
239
|
+
"prompt_guardrail_gaps": [],
|
|
240
|
+
"mcp_retrieval_gaps": [],
|
|
241
|
+
"source_index_gaps": [],
|
|
242
|
+
"recommended_actions": [],
|
|
243
|
+
"requires_admin_agent": false
|
|
244
|
+
}
|
|
245
|
+
~~~
|
|
246
|
+
|
|
247
|
+
## 6. Admin-agent fallback command
|
|
248
|
+
|
|
249
|
+
If a dedicated server-side audit-signal ingestion endpoint is available, send the JSON signal there and mention the trace/id returned.
|
|
250
|
+
|
|
251
|
+
If server-side self-evolution is not available, do not claim it happened. If token is already saved in \`sp-rag\`, tell the admin to run:
|
|
252
|
+
|
|
253
|
+
\`sp-rag audit install --client <codex|cursor|claude-code|antigravity|vscode|opencode>\`
|
|
254
|
+
|
|
255
|
+
If this is the first setup on the machine, save the token once with:
|
|
256
|
+
|
|
257
|
+
\`sp-rag token add --token <token>\`
|
|
258
|
+
|
|
259
|
+
Then run the audit install command above. The admin AI agent should use the installed \`sp-audit\` skill to review new audit outputs. To persist the JSON signal through the existing server memory import path, save the JSON object and run:
|
|
260
|
+
|
|
261
|
+
\`sp-rag audit signal --file <signal.json>\`
|
|
262
|
+
|
|
263
|
+
Feed the same JSON signal into the next prompt, eval suite, retrieval tuning task, or reviewed server-side memory import.
|
|
264
|
+
|
|
265
|
+
## Evolution Policy
|
|
266
|
+
|
|
267
|
+
- Self-evolution must be review-gated. Do not let the server silently rewrite prompts, skills, indexes, or production settings from one weak report.
|
|
268
|
+
- If the same optimization signal repeats across reports, propose a durable change: prompt guardrail, skill update, eval case, retrieval query rewrite, docs import, or index refresh.
|
|
269
|
+
- Prefer measurable changes: a failing eval case before prompt/retrieval changes, then a passing eval after the fix.
|
|
124
270
|
`;
|
|
125
271
|
}
|
|
272
|
+
function withoutYamlFrontmatter(markdown) {
|
|
273
|
+
if (!markdown.startsWith('---\n')) {
|
|
274
|
+
return markdown;
|
|
275
|
+
}
|
|
276
|
+
const endIndex = markdown.indexOf('\n---\n', 4);
|
|
277
|
+
if (endIndex < 0) {
|
|
278
|
+
return markdown;
|
|
279
|
+
}
|
|
280
|
+
return markdown.slice(endIndex + '\n---\n'.length);
|
|
281
|
+
}
|
|
126
282
|
function renderCursorRule(context) {
|
|
127
283
|
return `---
|
|
128
284
|
description: Use SP-RAG when the request is about this codebase, internal business workflows, rendered docs, import inventory, or codegraph sync status.
|
|
129
|
-
globs:
|
|
130
|
-
alwaysApply: true
|
|
131
|
-
---
|
|
132
|
-
|
|
133
|
-
# SP-RAG
|
|
134
|
-
|
|
285
|
+
globs:
|
|
286
|
+
alwaysApply: true
|
|
287
|
+
---
|
|
288
|
+
|
|
289
|
+
# SP-RAG
|
|
290
|
+
|
|
135
291
|
${seoBoosterProjectGuard}
|
|
292
|
+
${seoBoosterReportGuard}
|
|
136
293
|
- Route by intent before choosing tools.
|
|
137
294
|
- Use the \`${context.serverAlias}\` MCP server first for feature, domain, architecture, workflow, docs, and "what does this do" questions.
|
|
138
295
|
- Use workspace search first for current-code, edit, bug, and test-failure work.
|
|
139
|
-
- Verify MCP evidence against \`git status --short\` and current workspace files before making implementation claims.
|
|
140
|
-
- Use rendered docs from \`${context.docsUrl}\` when documentation already answers the question.
|
|
141
|
-
- Treat \`answer_brief\` only as a hint. Build the final answer from \`matched_passages\`, \`top_entities\`, \`top_relations\`, and \`citations\`.
|
|
142
|
-
- Do not stop at the first one or two MCP citations for broad feature questions. Expand through related files, symbols, services, controllers, jobs, components, and tests.
|
|
143
|
-
- For freshness or operational questions, check sync status, recent runs, and metrics before assuming the graph is current.
|
|
144
|
-
- Only trigger codegraph sync when the user explicitly asks for it or stale evidence is the confirmed blocker.
|
|
145
|
-
- If the evidence may be stale, say so clearly.
|
|
296
|
+
- Verify MCP evidence against \`git status --short\` and current workspace files before making implementation claims.
|
|
297
|
+
- Use rendered docs from \`${context.docsUrl}\` when documentation already answers the question.
|
|
298
|
+
- Treat \`answer_brief\` only as a hint. Build the final answer from \`matched_passages\`, \`top_entities\`, \`top_relations\`, and \`citations\`.
|
|
299
|
+
- Do not stop at the first one or two MCP citations for broad feature questions. Expand through related files, symbols, services, controllers, jobs, components, and tests.
|
|
300
|
+
- For freshness or operational questions, check sync status, recent runs, and metrics before assuming the graph is current.
|
|
301
|
+
- Only trigger codegraph sync when the user explicitly asks for it or stale evidence is the confirmed blocker.
|
|
302
|
+
- If the evidence may be stale, say so clearly.
|
|
303
|
+
`;
|
|
304
|
+
}
|
|
305
|
+
function renderSpAuditCursorRule(context) {
|
|
306
|
+
return `---
|
|
307
|
+
description: Use SP-AUDIT when reviewing seo-booster audit reports, scoring report quality, or extracting optimization signals.
|
|
308
|
+
globs:
|
|
309
|
+
alwaysApply: false
|
|
310
|
+
---
|
|
311
|
+
|
|
312
|
+
${withoutYamlFrontmatter(renderSpAuditMarkdown(context))}
|
|
146
313
|
`;
|
|
147
314
|
}
|
|
148
315
|
function renderVsCodeAgent(context) {
|
|
149
316
|
return `---
|
|
150
317
|
name: SP-RAG
|
|
151
|
-
description: Use this custom agent whenever the request is about this codebase, internal business workflows, rendered docs, import inventory, or codegraph sync status.
|
|
318
|
+
description: Use this custom agent whenever the request is about this codebase, internal business workflows, rendered docs, import inventory, or codegraph sync status.
|
|
319
|
+
tools: ['${context.serverAlias}/*']
|
|
320
|
+
---
|
|
321
|
+
|
|
322
|
+
You are the SP-RAG custom agent for this workspace.
|
|
323
|
+
|
|
324
|
+
Use the \`${context.serverAlias}\` MCP server at \`${context.mcpUrl}\` and the rendered docs URL \`${context.docsUrl}\` as your grounded source of truth.
|
|
325
|
+
|
|
326
|
+
Route by intent before choosing tools. MCP gives the semantic map; the current workspace verifies exact code.
|
|
327
|
+
|
|
328
|
+
## Recommended Workflow
|
|
329
|
+
|
|
330
|
+
1. For feature, domain, architecture, workflow, docs, and "what does this do" questions, use \`query_context\` first.
|
|
331
|
+
2. For current-code, edit, debug, failing-test, and local-error work, inspect the workspace first with \`git status --short\`, \`rg\`, and direct file reads.
|
|
332
|
+
3. Use \`get_rendered_docs\` when public, function, or dev docs may already answer the question.
|
|
333
|
+
4. Use \`get_sync_status\`, \`get_sync_runs\`, or \`get_sync_metrics\` for freshness, incident review, or operational debugging.
|
|
334
|
+
5. After MCP returns, verify important citations against current workspace files if the answer depends on exact implementation.
|
|
335
|
+
6. Expand beyond the first one or two MCP citations for broad feature questions. Search related symbols, callers, services, controllers, jobs, routes, models, components, and tests.
|
|
336
|
+
7. Trigger codegraph sync only when the user explicitly requests a refresh or stale evidence is the confirmed blocker.
|
|
337
|
+
|
|
338
|
+
## Guardrails
|
|
339
|
+
|
|
340
|
+
${seoBoosterProjectGuard}
|
|
341
|
+
${seoBoosterReportGuard}
|
|
342
|
+
- Prefer MCP-grounded evidence before answering from memory, but current workspace files override MCP evidence when they differ.
|
|
343
|
+
- Treat \`answer_brief\` as a hint. Prefer the richer evidence in \`matched_passages\`, \`top_entities\`, \`top_relations\`, and \`citations\` when writing the final answer.
|
|
344
|
+
- When evidence may be stale, say so clearly and mention that a refresh might be needed.
|
|
345
|
+
- Do not trigger sync or import actions unless the workflow truly requires it.
|
|
346
|
+
- When rendered docs already answer the question, summarize those docs instead of rewriting everything from scratch.
|
|
347
|
+
- Find root cause before fixes, write or update tests for behavior changes when feasible, and verify before claiming completion.
|
|
348
|
+
`;
|
|
349
|
+
}
|
|
350
|
+
function renderSpAuditVsCodeAgent(context) {
|
|
351
|
+
return `---
|
|
352
|
+
name: SP-AUDIT
|
|
353
|
+
description: Use this custom agent to score seo-booster audit reports and extract optimization signals.
|
|
152
354
|
tools: ['${context.serverAlias}/*']
|
|
153
355
|
---
|
|
154
356
|
|
|
155
|
-
You are the SP-
|
|
357
|
+
You are the SP-AUDIT custom agent for this workspace.
|
|
156
358
|
|
|
157
|
-
Use the \`${context.serverAlias}\` MCP server
|
|
158
|
-
|
|
159
|
-
Route by intent before choosing tools. MCP gives the semantic map; the current workspace verifies exact code.
|
|
160
|
-
|
|
161
|
-
## Recommended Workflow
|
|
162
|
-
|
|
163
|
-
1. For feature, domain, architecture, workflow, docs, and "what does this do" questions, use \`query_context\` first.
|
|
164
|
-
2. For current-code, edit, debug, failing-test, and local-error work, inspect the workspace first with \`git status --short\`, \`rg\`, and direct file reads.
|
|
165
|
-
3. Use \`get_rendered_docs\` when public, function, or dev docs may already answer the question.
|
|
166
|
-
4. Use \`get_sync_status\`, \`get_sync_runs\`, or \`get_sync_metrics\` for freshness, incident review, or operational debugging.
|
|
167
|
-
5. After MCP returns, verify important citations against current workspace files if the answer depends on exact implementation.
|
|
168
|
-
6. Expand beyond the first one or two MCP citations for broad feature questions. Search related symbols, callers, services, controllers, jobs, routes, models, components, and tests.
|
|
169
|
-
7. Trigger codegraph sync only when the user explicitly requests a refresh or stale evidence is the confirmed blocker.
|
|
170
|
-
|
|
171
|
-
## Guardrails
|
|
359
|
+
Use the \`${context.serverAlias}\` MCP server only when you need to verify freshness, citations, rendered docs, or retrieval gaps. Your primary job is to audit the audit result.
|
|
172
360
|
|
|
173
|
-
${
|
|
174
|
-
- Prefer MCP-grounded evidence before answering from memory, but current workspace files override MCP evidence when they differ.
|
|
175
|
-
- Treat \`answer_brief\` as a hint. Prefer the richer evidence in \`matched_passages\`, \`top_entities\`, \`top_relations\`, and \`citations\` when writing the final answer.
|
|
176
|
-
- When evidence may be stale, say so clearly and mention that a refresh might be needed.
|
|
177
|
-
- Do not trigger sync or import actions unless the workflow truly requires it.
|
|
178
|
-
- When rendered docs already answer the question, summarize those docs instead of rewriting everything from scratch.
|
|
179
|
-
- Find root cause before fixes, write or update tests for behavior changes when feasible, and verify before claiming completion.
|
|
361
|
+
${withoutYamlFrontmatter(renderSpAuditMarkdown(context))}
|
|
180
362
|
`;
|
|
181
363
|
}
|
|
182
364
|
function renderVsCodeAlwaysOnInstructions(context) {
|
|
183
365
|
return `# SP-RAG workspace instructions
|
|
184
|
-
|
|
366
|
+
|
|
185
367
|
${seoBoosterProjectGuard}
|
|
368
|
+
${seoBoosterReportGuard}
|
|
186
369
|
- Route by intent before choosing tools.
|
|
187
370
|
- Use the \`${context.serverAlias}\` MCP server first for feature, domain, architecture, workflow, docs, and "what does this do" questions.
|
|
188
371
|
- Use workspace inspection first for current-code, edit, debug, failing-test, and local-error work.
|
|
189
|
-
- Verify MCP evidence against current workspace state, including \`git status --short\` and current file contents when implementation details matter.
|
|
190
|
-
- Start with \`healthz\` only when connectivity is uncertain or the session is new.
|
|
191
|
-
- When \`query_context\` returns, synthesize the final answer from \`matched_passages\`, \`top_entities\`, \`top_relations\`, and \`citations\`.
|
|
192
|
-
- Treat \`answer_brief\` as a hint only, not the final answer.
|
|
193
|
-
- Expand beyond the first one or two MCP citations for broad feature questions.
|
|
194
|
-
- Use \`get_rendered_docs\` when rendered docs can answer the question faster than raw code inspection.
|
|
195
|
-
- Only trigger codegraph sync when the user explicitly asks for it or stale graph evidence is the confirmed blocker.
|
|
196
|
-
- If MCP and current workspace files disagree, say MCP may be stale and trust the current workspace for implementation details.
|
|
372
|
+
- Verify MCP evidence against current workspace state, including \`git status --short\` and current file contents when implementation details matter.
|
|
373
|
+
- Start with \`healthz\` only when connectivity is uncertain or the session is new.
|
|
374
|
+
- When \`query_context\` returns, synthesize the final answer from \`matched_passages\`, \`top_entities\`, \`top_relations\`, and \`citations\`.
|
|
375
|
+
- Treat \`answer_brief\` as a hint only, not the final answer.
|
|
376
|
+
- Expand beyond the first one or two MCP citations for broad feature questions.
|
|
377
|
+
- Use \`get_rendered_docs\` when rendered docs can answer the question faster than raw code inspection.
|
|
378
|
+
- Only trigger codegraph sync when the user explicitly asks for it or stale graph evidence is the confirmed blocker.
|
|
379
|
+
- If MCP and current workspace files disagree, say MCP may be stale and trust the current workspace for implementation details.
|
|
197
380
|
`;
|
|
198
381
|
}
|
|
199
382
|
function renderSkillArtifact(context) {
|
|
383
|
+
if (context.skillName === 'sp-audit') {
|
|
384
|
+
switch (context.client) {
|
|
385
|
+
case 'cursor':
|
|
386
|
+
return {
|
|
387
|
+
fileName: 'sp-audit.mdc',
|
|
388
|
+
content: renderSpAuditCursorRule(context),
|
|
389
|
+
};
|
|
390
|
+
case 'vscode':
|
|
391
|
+
return {
|
|
392
|
+
fileName: 'sp-audit.agent.md',
|
|
393
|
+
content: renderSpAuditVsCodeAgent(context),
|
|
394
|
+
};
|
|
395
|
+
default:
|
|
396
|
+
return {
|
|
397
|
+
fileName: 'SKILL.md',
|
|
398
|
+
content: renderSpAuditMarkdown(context),
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
}
|
|
200
402
|
switch (context.client) {
|
|
201
403
|
case 'cursor':
|
|
202
404
|
return {
|
|
@@ -218,6 +420,7 @@ function renderSkillArtifact(context) {
|
|
|
218
420
|
function createSkillContext(options = {}, client) {
|
|
219
421
|
return {
|
|
220
422
|
client: client ?? options.client ?? 'codex',
|
|
423
|
+
skillName: options.skillName ?? 'sp-rag',
|
|
221
424
|
serverAlias: options.serverAlias?.trim() || 'sp-rag',
|
|
222
425
|
mcpUrl: options.mcpUrl?.trim() || 'https://sp-rag.secomapp.com/mcp',
|
|
223
426
|
docsUrl: options.docsUrl?.trim() || 'https://sp-rag.secomapp.com/codegraph/docs/public?format=md',
|
|
@@ -227,6 +430,9 @@ function resolveAdditionalSkillArtifacts(options, resolved, context) {
|
|
|
227
430
|
if (resolved.client !== 'vscode') {
|
|
228
431
|
return [];
|
|
229
432
|
}
|
|
433
|
+
if (context.skillName !== 'sp-rag') {
|
|
434
|
+
return [];
|
|
435
|
+
}
|
|
230
436
|
const workspaceRoot = resolved.scope === 'project'
|
|
231
437
|
? requireProjectCwd('vscode', options.cwd)
|
|
232
438
|
: undefined;
|
|
@@ -243,7 +449,8 @@ function resolveAdditionalSkillArtifacts(options, resolved, context) {
|
|
|
243
449
|
export function resolveSkillInstallTarget(options = {}) {
|
|
244
450
|
const client = options.client ?? 'codex';
|
|
245
451
|
const scope = normalizeScope(client, options.scope);
|
|
246
|
-
const
|
|
452
|
+
const skillName = options.skillName ?? 'sp-rag';
|
|
453
|
+
const targetDir = path.resolve(options.targetDir ?? defaultSkillDir(client, options.cwd, scope, skillName));
|
|
247
454
|
const artifact = renderSkillArtifact(createSkillContext(options, client));
|
|
248
455
|
return {
|
|
249
456
|
client,
|
|
@@ -289,7 +496,10 @@ async function removeIfSpRagArtifact(filePath) {
|
|
|
289
496
|
if (content === null) {
|
|
290
497
|
return false;
|
|
291
498
|
}
|
|
292
|
-
if (!content.includes('SP-RAG') &&
|
|
499
|
+
if (!content.includes('SP-RAG') &&
|
|
500
|
+
!content.includes('sp-rag') &&
|
|
501
|
+
!content.includes('SP-AUDIT') &&
|
|
502
|
+
!content.includes('sp-audit')) {
|
|
293
503
|
return false;
|
|
294
504
|
}
|
|
295
505
|
await rm(filePath, { force: true });
|