sp-rag 0.6.6 → 0.6.7

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 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.6`
20
+ - version đang publish: `0.6.7`
21
21
  - binary public: `sp-rag`
22
22
 
23
23
  ## Cài từ source trong monorepo
@@ -160,7 +160,7 @@ npx sp-rag@latest token verify --token $env:GRAPHRAG_MCP_TOKEN
160
160
  - `antigravity` -> `SKILL.md`
161
161
  - `opencode` -> `SKILL.md`
162
162
  - `cursor` -> `.cursor/rules/sp-rag.mdc`
163
- - `vscode` -> `.github/agents/sp-rag.agent.md` hoặc `~/.copilot/agents/sp-rag.agent.md`
163
+ - `vscode` -> `.github/agents/sp-rag.agent.md` + `.github/copilot-instructions.md` hoặc `~/.copilot/agents/sp-rag.agent.md` + `~/.copilot/instructions/sp-rag.instructions.md`
164
164
 
165
165
  Ghi chú:
166
166
 
@@ -190,8 +190,8 @@ Ghi chú:
190
190
  - `antigravity`: `~/.gemini/antigravity/skills/sp-rag/SKILL.md`
191
191
  - `opencode`: `~/.config/opencode/skills/sp-rag/SKILL.md`
192
192
  - `cursor` project: `.cursor/rules/sp-rag.mdc`
193
- - `vscode` project: `.github/agents/sp-rag.agent.md`
194
- - `vscode` global: `~/.copilot/agents/sp-rag.agent.md`
193
+ - `vscode` project: `.github/agents/sp-rag.agent.md` và `.github/copilot-instructions.md`
194
+ - `vscode` global: `~/.copilot/agents/sp-rag.agent.md` và `~/.copilot/instructions/sp-rag.instructions.md`
195
195
 
196
196
  ## Luồng khuyên dùng cho dev mới
197
197
 
package/dist/cli.js CHANGED
@@ -4,7 +4,7 @@ import { runEvaluationSuite } from './lib/eval.js';
4
4
  import { defaultBaseUrl, defaultMcpServerAlias, defaultMcpUrl, installMcpConfig, resolveMcpConfigPath, } from './lib/mcp-config.js';
5
5
  import { fetchJson, fetchText, runDoctor } from './lib/http.js';
6
6
  import { installSkill, resolveSkillInstallTarget, } from './lib/skill.js';
7
- const cliVersion = '0.6.6';
7
+ const cliVersion = '0.6.7';
8
8
  function parseArgv(argv) {
9
9
  const positionals = [];
10
10
  const options = {};
@@ -368,6 +368,9 @@ async function runSkillInstall(parsed, defaults, explicitClient) {
368
368
  docsUrl: optionString(parsed, 'docs-url') ?? defaults.docsUrl,
369
369
  });
370
370
  process.stdout.write(`Đã cài skill cho ${result.client} tại ${result.path}\n`);
371
+ for (const extraPath of result.paths.slice(1)) {
372
+ process.stdout.write(`Đã cài thêm hướng dẫn cho ${result.client} tại ${extraPath}\n`);
373
+ }
371
374
  }
372
375
  async function saveResolvedConfig(defaults) {
373
376
  return saveCliConfig(buildCliConfig(defaults), defaults.homeDir);
package/dist/lib/skill.js CHANGED
@@ -150,6 +150,19 @@ You must call an SP-RAG MCP tool before using local workspace search, grep, or f
150
150
  - 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.
151
151
  `;
152
152
  }
153
+ function renderVsCodeAlwaysOnInstructions(context) {
154
+ return `# SP-RAG workspace instructions
155
+
156
+ - Always use the \`${context.serverAlias}\` MCP server first for codebase, domain, architecture, workflow, and operational questions before local workspace search, grep, or file reads.
157
+ - Start with \`healthz\` only when connectivity is uncertain or the session is new.
158
+ - Use \`query_context\` first for feature, entity, relation, and business-flow questions.
159
+ - When \`query_context\` returns, synthesize the final answer from \`matched_passages\`, \`top_entities\`, \`top_relations\`, and \`citations\`.
160
+ - Treat \`answer_brief\` as a hint only, not the final answer.
161
+ - Use \`get_rendered_docs\` when rendered docs can answer the question faster than raw code inspection.
162
+ - Only trigger codegraph sync when the user explicitly asks for it or stale graph evidence is the confirmed blocker.
163
+ - If MCP is unavailable or clearly lacks evidence, say so explicitly before falling back to local workspace search or file reads.
164
+ `;
165
+ }
153
166
  function renderSkillArtifact(context) {
154
167
  switch (context.client) {
155
168
  case 'cursor':
@@ -169,24 +182,45 @@ function renderSkillArtifact(context) {
169
182
  };
170
183
  }
171
184
  }
185
+ function createSkillContext(options = {}, client) {
186
+ return {
187
+ client: client ?? options.client ?? 'codex',
188
+ serverAlias: options.serverAlias?.trim() || 'sp-rag',
189
+ mcpUrl: options.mcpUrl?.trim() || 'https://sp-rag.secomapp.com/mcp',
190
+ docsUrl: options.docsUrl?.trim() || 'https://sp-rag.secomapp.com/codegraph/docs/public?format=md',
191
+ };
192
+ }
193
+ function resolveAdditionalSkillArtifacts(options, resolved, context) {
194
+ if (resolved.client !== 'vscode') {
195
+ return [];
196
+ }
197
+ const workspaceRoot = resolved.scope === 'project'
198
+ ? requireProjectCwd('vscode', options.cwd)
199
+ : undefined;
200
+ const instructionsPath = resolved.scope === 'project'
201
+ ? path.join(workspaceRoot, '.github', 'copilot-instructions.md')
202
+ : path.join(os.homedir(), '.copilot', 'instructions', 'sp-rag.instructions.md');
203
+ return [
204
+ {
205
+ path: instructionsPath,
206
+ content: renderVsCodeAlwaysOnInstructions(context),
207
+ },
208
+ ];
209
+ }
172
210
  export function resolveSkillInstallTarget(options = {}) {
173
211
  const client = options.client ?? 'codex';
174
212
  const scope = normalizeScope(client, options.scope);
175
213
  const targetDir = path.resolve(options.targetDir ?? defaultSkillDir(client, options.cwd, scope));
176
- const artifact = renderSkillArtifact({
177
- client,
178
- serverAlias: options.serverAlias?.trim() || 'sp-rag',
179
- mcpUrl: options.mcpUrl?.trim() || 'https://sp-rag.secomapp.com/mcp',
180
- docsUrl: options.docsUrl?.trim() || 'https://sp-rag.secomapp.com/codegraph/docs/public?format=md',
181
- });
214
+ const artifact = renderSkillArtifact(createSkillContext(options, client));
182
215
  return {
183
216
  client,
184
217
  scope,
185
218
  path: path.join(targetDir, artifact.fileName),
219
+ paths: [path.join(targetDir, artifact.fileName)],
186
220
  };
187
221
  }
188
222
  export function renderSkill(options) {
189
- return renderSkillArtifact(options).content;
223
+ return renderSkillArtifact(createSkillContext(options, options.client)).content;
190
224
  }
191
225
  export function renderCodexSkill(options) {
192
226
  return renderSkill({
@@ -196,17 +230,20 @@ export function renderCodexSkill(options) {
196
230
  }
197
231
  export async function installSkill(options = {}) {
198
232
  const resolved = resolveSkillInstallTarget(options);
199
- const artifact = renderSkillArtifact({
200
- client: resolved.client,
201
- serverAlias: options.serverAlias?.trim() || 'sp-rag',
202
- mcpUrl: options.mcpUrl?.trim() || 'https://sp-rag.secomapp.com/mcp',
203
- docsUrl: options.docsUrl?.trim() || 'https://sp-rag.secomapp.com/codegraph/docs/public?format=md',
204
- });
233
+ const context = createSkillContext(options, resolved.client);
234
+ const artifact = renderSkillArtifact(context);
235
+ const additionalArtifacts = resolveAdditionalSkillArtifacts(options, resolved, context);
205
236
  await mkdir(path.dirname(resolved.path), { recursive: true });
206
237
  await writeFile(resolved.path, artifact.content, 'utf8');
238
+ for (const extra of additionalArtifacts) {
239
+ await mkdir(path.dirname(extra.path), { recursive: true });
240
+ await writeFile(extra.path, extra.content, 'utf8');
241
+ }
242
+ const paths = [resolved.path, ...additionalArtifacts.map((entry) => entry.path)];
207
243
  return {
208
244
  client: resolved.client,
209
245
  path: resolved.path,
246
+ paths,
210
247
  };
211
248
  }
212
249
  export async function installCodexSkill(options = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sp-rag",
3
- "version": "0.6.6",
3
+ "version": "0.6.7",
4
4
  "description": "CLI cho setup MCP, codegraph GitNexus và skill của SP-RAG",
5
5
  "type": "module",
6
6
  "files": [