sp-rag 0.6.12 → 0.6.14
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 +3 -3
- package/dist/cli.js +3 -0
- 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 +50 -31
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ CLI để setup nhanh SP-RAG theo hướng dev-friendly:
|
|
|
17
17
|
## Trạng thái package
|
|
18
18
|
|
|
19
19
|
- package npm public: `sp-rag`
|
|
20
|
-
- version đang publish: `0.6.
|
|
20
|
+
- version đang publish: `0.6.14`
|
|
21
21
|
- binary public: `sp-rag`
|
|
22
22
|
|
|
23
23
|
## Cài từ source trong monorepo
|
|
@@ -77,8 +77,8 @@ Ghi chú:
|
|
|
77
77
|
- với `cursor` và `vscode` ở `scope project`, nếu Sếpp đang đứng sẵn trong repo thì có thể bỏ `--cwd`
|
|
78
78
|
- CLI sẽ tự dùng thư mục hiện tại cho cả MCP lẫn skill
|
|
79
79
|
- `update` sẽ tự tính lại target project từ `--cwd` hoặc thư mục hiện tại, không dùng target cũ lệch project nếu user không truyền `--target-dir`
|
|
80
|
-
- rule/agent mới
|
|
81
|
-
- skill mới
|
|
80
|
+
- rule/agent mới route theo intent: feature/domain/docs thì MCP trước, còn edit/debug/current-code thì kiểm tra workspace trước
|
|
81
|
+
- skill mới dùng hướng MCP-grounded + workspace-verified: tổng hợp từ `matched_passages`, `top_entities`, `top_relations`, `citations`, không bê nguyên `answer_brief`, và đối chiếu lại `git status --short`/file hiện tại khi cần
|
|
82
82
|
|
|
83
83
|
Ví dụ:
|
|
84
84
|
|
package/dist/cli.js
CHANGED
|
@@ -426,6 +426,9 @@ async function emitDoctorReport(parsed, defaults, explicitClient, checks) {
|
|
|
426
426
|
async function runClientSetup(parsed, defaults, client) {
|
|
427
427
|
const nextDefaults = deriveDefaultsForClient(parsed, defaults, client);
|
|
428
428
|
validateStoredToken(nextDefaults);
|
|
429
|
+
if (!optionFlag(parsed, 'skip-mcp')) {
|
|
430
|
+
resolveAuthForMcp(parsed, nextDefaults);
|
|
431
|
+
}
|
|
429
432
|
const configPath = await saveResolvedConfig(nextDefaults);
|
|
430
433
|
process.stdout.write(`Đã lưu config CLI tại ${configPath}\n`);
|
|
431
434
|
if (!optionFlag(parsed, 'skip-mcp')) {
|
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
|
@@ -72,7 +72,7 @@ export function defaultSkillDir(client = 'codex', cwd, scope) {
|
|
|
72
72
|
function renderSkillMarkdown(context) {
|
|
73
73
|
return `---
|
|
74
74
|
name: sp-rag
|
|
75
|
-
description: Use 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.
|
|
76
76
|
---
|
|
77
77
|
|
|
78
78
|
# SP-RAG
|
|
@@ -84,29 +84,43 @@ Docs URL: \`${context.docsUrl}\`
|
|
|
84
84
|
|
|
85
85
|
## When To Use This Skill
|
|
86
86
|
|
|
87
|
-
- Use
|
|
88
|
-
- Use this skill
|
|
89
|
-
-
|
|
87
|
+
- Use SP-RAG whenever the request is about seo-booster codebase, features, business workflows, rendered docs, import inventory, or sync state.
|
|
88
|
+
- Use this skill for seo-booster codebase, feature, business workflow, rendered docs, import inventory, and sync-state questions.
|
|
89
|
+
- The operating model is MCP-grounded, workspace-verified.
|
|
90
|
+
- Do not treat MCP as the only source. MCP gives context; current workspace files and git state verify the final answer.
|
|
90
91
|
|
|
91
|
-
##
|
|
92
|
+
## Intent Routing
|
|
93
|
+
|
|
94
|
+
- 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.
|
|
95
|
+
- 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.
|
|
96
|
+
- For mixed questions: get MCP context, inspect current files, compare both, then answer.
|
|
97
|
+
- For docs questions, use \`get_rendered_docs\` when public, function, or dev docs may already answer the question.
|
|
98
|
+
- 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.
|
|
99
|
+
|
|
100
|
+
## Workspace Verification
|
|
101
|
+
|
|
102
|
+
1. Run or mentally account for \`git status --short\` before relying on MCP for current behavior.
|
|
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.
|
|
106
|
+
|
|
107
|
+
## Expand Evidence
|
|
92
108
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
6. After \`query_context\` returns, synthesize the final answer from \`matched_passages\`, \`top_entities\`, \`top_relations\`, and \`citations\`. Treat \`answer_brief\` as a hint only.
|
|
109
|
+
- After \`query_context\`, synthesize from \`matched_passages\`, \`top_entities\`, \`top_relations\`, \`citations\`, and \`feature_memory\` diagnostics when present.
|
|
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.
|
|
99
114
|
|
|
100
115
|
## Guardrails
|
|
101
116
|
|
|
102
117
|
${seoBoosterProjectGuard}
|
|
103
|
-
-
|
|
104
|
-
-
|
|
105
|
-
-
|
|
106
|
-
- If
|
|
118
|
+
- Find root cause before fixing bugs.
|
|
119
|
+
- Use evidence before conclusions; do not claim completion without verification.
|
|
120
|
+
- For behavior changes, write or update tests before implementation when feasible.
|
|
121
|
+
- If evidence may be stale, say so clearly and mention that the graph or docs may need a refresh.
|
|
107
122
|
- Do not trigger sync or import actions unless the user asked for it or the workflow truly requires it.
|
|
108
|
-
- When rendered docs already answer the question, cite or summarize those docs
|
|
109
|
-
- Only fall back to local workspace search or file reads after MCP is unavailable or clearly lacks the needed evidence, and say that you are falling back.
|
|
123
|
+
- When rendered docs already answer the question, cite or summarize those docs, then check current code if the answer depends on implementation details.
|
|
110
124
|
`;
|
|
111
125
|
}
|
|
112
126
|
function renderCursorRule(context) {
|
|
@@ -119,14 +133,16 @@ alwaysApply: true
|
|
|
119
133
|
# SP-RAG
|
|
120
134
|
|
|
121
135
|
${seoBoosterProjectGuard}
|
|
122
|
-
-
|
|
136
|
+
- Route by intent before choosing tools.
|
|
137
|
+
- Use the \`${context.serverAlias}\` MCP server first for feature, domain, architecture, workflow, docs, and "what does this do" questions.
|
|
138
|
+
- 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.
|
|
123
140
|
- Use rendered docs from \`${context.docsUrl}\` when documentation already answers the question.
|
|
124
|
-
- For architecture, domain, entities, relations, and business workflow questions, query MCP first and only then synthesize the answer.
|
|
125
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.
|
|
126
143
|
- For freshness or operational questions, check sync status, recent runs, and metrics before assuming the graph is current.
|
|
127
144
|
- Only trigger codegraph sync when the user explicitly asks for it or stale evidence is the confirmed blocker.
|
|
128
145
|
- If the evidence may be stale, say so clearly.
|
|
129
|
-
- Only fall back to local workspace search after MCP is unavailable or clearly lacks the needed evidence, and say that you are falling back.
|
|
130
146
|
`;
|
|
131
147
|
}
|
|
132
148
|
function renderVsCodeAgent(context) {
|
|
@@ -140,41 +156,44 @@ You are the SP-RAG custom agent for this workspace.
|
|
|
140
156
|
|
|
141
157
|
Use the \`${context.serverAlias}\` MCP server at \`${context.mcpUrl}\` and the rendered docs URL \`${context.docsUrl}\` as your grounded source of truth.
|
|
142
158
|
|
|
143
|
-
|
|
159
|
+
Route by intent before choosing tools. MCP gives the semantic map; the current workspace verifies exact code.
|
|
144
160
|
|
|
145
161
|
## Recommended Workflow
|
|
146
162
|
|
|
147
|
-
1.
|
|
148
|
-
2.
|
|
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.
|
|
149
165
|
3. Use \`get_rendered_docs\` when public, function, or dev docs may already answer the question.
|
|
150
166
|
4. Use \`get_sync_status\`, \`get_sync_runs\`, or \`get_sync_metrics\` for freshness, incident review, or operational debugging.
|
|
151
|
-
5.
|
|
152
|
-
6.
|
|
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.
|
|
153
170
|
|
|
154
171
|
## Guardrails
|
|
155
172
|
|
|
156
173
|
${seoBoosterProjectGuard}
|
|
157
|
-
- Prefer MCP-grounded evidence before answering from memory.
|
|
174
|
+
- Prefer MCP-grounded evidence before answering from memory, but current workspace files override MCP evidence when they differ.
|
|
158
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.
|
|
159
|
-
- Do not use local workspace search, grep, or file reads until SP-RAG MCP has been tried first for the current question.
|
|
160
176
|
- When evidence may be stale, say so clearly and mention that a refresh might be needed.
|
|
161
177
|
- Do not trigger sync or import actions unless the workflow truly requires it.
|
|
162
178
|
- When rendered docs already answer the question, summarize those docs instead of rewriting everything from scratch.
|
|
163
|
-
-
|
|
179
|
+
- Find root cause before fixes, write or update tests for behavior changes when feasible, and verify before claiming completion.
|
|
164
180
|
`;
|
|
165
181
|
}
|
|
166
182
|
function renderVsCodeAlwaysOnInstructions(context) {
|
|
167
183
|
return `# SP-RAG workspace instructions
|
|
168
184
|
|
|
169
185
|
${seoBoosterProjectGuard}
|
|
170
|
-
-
|
|
186
|
+
- Route by intent before choosing tools.
|
|
187
|
+
- Use the \`${context.serverAlias}\` MCP server first for feature, domain, architecture, workflow, docs, and "what does this do" questions.
|
|
188
|
+
- 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.
|
|
171
190
|
- Start with \`healthz\` only when connectivity is uncertain or the session is new.
|
|
172
|
-
- Use \`query_context\` first for feature, entity, relation, and business-flow questions.
|
|
173
191
|
- When \`query_context\` returns, synthesize the final answer from \`matched_passages\`, \`top_entities\`, \`top_relations\`, and \`citations\`.
|
|
174
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.
|
|
175
194
|
- Use \`get_rendered_docs\` when rendered docs can answer the question faster than raw code inspection.
|
|
176
195
|
- Only trigger codegraph sync when the user explicitly asks for it or stale graph evidence is the confirmed blocker.
|
|
177
|
-
- If MCP
|
|
196
|
+
- If MCP and current workspace files disagree, say MCP may be stale and trust the current workspace for implementation details.
|
|
178
197
|
`;
|
|
179
198
|
}
|
|
180
199
|
function renderSkillArtifact(context) {
|