sp-rag
v0.6.16
Published
CLI cho setup MCP, codegraph GitNexus và skill của SP-RAG
Readme
sp-rag
Context boundary
sp-rag exists to connect IDEs/agents to SP-RAG evidence for the seo-booster
application.
graphrag-coreis the SP-RAG platform and knowledge runtime.seo-boosteris the target application and source workspace for app/business review.GitNexus/codegraph references are platform internals or artifact sources, not the project to review unless the task explicitly asks for codegraph debugging.- For project-scoped installs, use
--cwd <seo-booster-workspace>. - Do not install project-scoped VS Code/Cursor/Claude config into
<graphrag-core-workspace>when the goal is to reviewseo-booster. - Use
<graphrag-core-workspace>as--cwdonly when developing or debugging this SP-RAG platform itself. <seo-booster-workspace>and<graphrag-core-workspace>are placeholders, not literal paths. Replace them with the local checkout path on each machine, or omit--cwdwhen already inside the target repo.
Canonical boundary doc: ../../docs/runbooks/sp-rag-seo-booster-boundary.md
CLI để setup nhanh SP-RAG theo hướng dev-friendly:
- lưu cấu hình mặc định để dev không phải nhớ lại URL, client, alias
- cài MCP config đúng format cho từng client
- cài native skill / rule / custom agent cho từng IDE khi có convention ổn định
- kiểm tra nhanh health và observability của stack
- gọi sync codegraph/GitNexus theo branch hoặc
commit_sha - đọc docs đã render
- chạy evaluation/regression suite từ file JSON
Yêu cầu
- Node.js
>= 20
Trạng thái package
- package npm public:
sp-rag - version trong repo:
0.6.16 - npm latest hiện tại:
0.6.15 - binary public:
sp-rag
Cài từ source trong monorepo
cd apps/sp-rag-cli
npm install
npm test -- --run
npm run build
node dist/index.js doctorCài nhanh qua npx
npx sp-rag@latest token add --token <grc_pat_...>
npx sp-rag@latest install --client codex --doctor
npx sp-rag@latest install --client cursor --cwd <seo-booster-workspace>
npx sp-rag@latest install --client vscode --cwd <seo-booster-workspace>
npx sp-rag@latest add --client claude-code --scope project --cwd <seo-booster-workspace>
npx sp-rag@latest update --client claude-code --scope project --cwd <seo-booster-workspace>
npx sp-rag@latest uninstall --client claude-code --scope project --cwd <seo-booster-workspace>
npx sp-rag@latest explain --client vscode --scope project --cwd <seo-booster-workspace>
npx sp-rag@latest token add --token <grc_pat_...>
npx sp-rag@latest token verify --token <grc_pat_...>
npx sp-rag@latest mcp add antigravity
npx sp-rag@latest mcp add opencode --scope project --cwd <seo-booster-workspace>
npx sp-rag@latest skill install --client cursor --scope project --cwd <seo-booster-workspace>
npx sp-rag@latest skill install --client vscode --scope project --cwd <seo-booster-workspace>Tương đương bằng npm:
npm exec --yes sp-rag@latest token add -- --token <grc_pat_...>
npm exec --yes sp-rag@latest install -- --client codex --doctor
npm exec --yes sp-rag@latest add -- --client claude-code --scope project --cwd <seo-booster-workspace>
npm exec --yes sp-rag@latest update -- --client claude-code --scope project --cwd <seo-booster-workspace>
npm exec --yes sp-rag@latest uninstall -- --client claude-code --scope project --cwd <seo-booster-workspace>
npm exec --yes sp-rag@latest explain -- --client vscode --scope project --cwd <seo-booster-workspace>
npm exec --yes sp-rag@latest token add -- --token <grc_pat_...>
npm exec --yes sp-rag@latest token verify -- --token <grc_pat_...>Flow gọn cho dev
Flow khuyên dùng sau khi đã có grc_pat_*:
- chạy
sp-rag token add --token <grc_pat_...>đúng một lần để lưu token - chạy
installcho client đầu tiên, không cần kèm--mcp-token - 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 - khi muốn cập nhật lại MCP + skill mà giữ token cũ, dùng
update - khi muốn gỡ sạch MCP + skill + config CLI do
sp-ragtạo, dùnguninstall - khi chỉ muốn làm một nửa, dùng
mcp addhoặcskill install - khi đổi token, chỉ cần
token add - khi muốn kiểm tra máy đang được cấu hình ra sao, dùng
explain
Ghi chú:
- với
cursorvàvscodeởscope project, nếu Sếpp đang đứng sẵn trong repo thì có thể bỏ--cwd - CLI sẽ tự dùng thư mục hiện tại cho cả MCP lẫn skill
updatesẽ tự tính lại target project từ--cwdhoặ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- 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
- 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ênanswer_brief, và đối chiếu lạigit status --short/file hiện tại khi cần
Ví dụ:
sp-rag token add --token <grc_pat_...>
sp-rag install --client vscode --cwd <seo-booster-workspace> --doctor
sp-rag add --client cursor --cwd <seo-booster-workspace>
sp-rag update --client vscode --cwd <seo-booster-workspace>
sp-rag uninstall --client claude-code --scope project --cwd <seo-booster-workspace>
sp-rag mcp add antigravity
sp-rag skill install --client vscode --scope project --cwd <seo-booster-workspace>
sp-rag token add --token <grc_pat_moi>
sp-rag explain --client vscode --scope project --cwd <seo-booster-workspace>Lấy token ở đâu
sp-rag public bây giờ dùng token gắn với tài khoản thật trên server.
Luồng chuẩn:
- đăng nhập dashboard hoặc API account của GraphRAG
- tạo
personal access tokenqua account hiện tại - dùng chính token
grc_pat_*đó cho MCP và CLI - kiểm tra token bằng
sp-rag token verify
Điểm quan trọng:
- token dev dùng cho MCP nên là
grc_pat_*của account - quyền nhìn thấy tool/resource trên MCP bám theo role của account đó
viewer,operator,approver,adminsẽ thấy inventory khác nhauMCP_SERVER_ACCESS_TOKENS_JSONchỉ còn là fallback legacy/break-glass, không còn là luồng chính cho dev- khi client đã có sẵn một alias trỏ cùng MCP endpoint, CLI sẽ ưu tiên cập nhật alias đó thay vì tạo alias mới song song
Tự tạo PAT bằng API hiện có:
- lấy session token qua
POST /v1/account/login - gọi
POST /v1/account/personal-access-tokens - dùng trường
generated_token
Ví dụ đầy đủ:
curl -X POST https://sp-rag.secomapp.com/api/v1/account/login \
-H "Content-Type: application/json" \
-d '{"email":"[email protected]","password":"<mật-khẩu>"}'Lấy session_token, rồi gọi tiếp:
curl -X POST https://sp-rag.secomapp.com/api/v1/account/personal-access-tokens \
-H "Authorization: Bearer <grc_sess_...>" \
-H "Content-Type: application/json" \
-d '{"label":"SP-RAG CLI","expires_in_days":30}'Response sẽ trả generated_token, chính là token grc_pat_* để đưa vào sp-rag.
Ví dụ dev lưu token một lần rồi cài client:
npx sp-rag@latest token add --token <grc_pat_...>
npx sp-rag@latest install --client cursor --cwd <seo-booster-workspace>
npx sp-rag@latest token verify --token <grc_pat_...>
npx sp-rag@latest explain --client cursor --scope project --cwd <seo-booster-workspace>Hoặc dùng biến môi trường:
$env:GRAPHRAG_MCP_TOKEN="<grc_pat_...>"
npx sp-rag@latest mcp add vscode --scope project --cwd <seo-booster-workspace> --auth-env-var GRAPHRAG_MCP_TOKEN
npx sp-rag@latest token verify --token $env:GRAPHRAG_MCP_TOKENMCP client được hỗ trợ
codexcursorclaude-codeantigravityvscodeopencode
Skill client được hỗ trợ
codex->SKILL.mdclaude-code->SKILL.mdantigravity->SKILL.mdopencode->SKILL.mdcursor->.cursor/rules/sp-rag.mdcvscode->.github/agents/sp-rag.agent.md+.github/copilot-instructions.mdhoặc~/.copilot/agents/sp-rag.agent.md+~/.copilot/instructions/sp-rag.instructions.md
Ghi chú:
- generated skill luôn được render bằng tiếng Anh
cursorhiện nên dùngscope projectcho rule.mdcvscodehỗ trợ cảscope projectlẫnscope global- nếu không muốn lưu token literal vào file config client, dùng
sp-rag mcp add --auth-env-var SP_RAG_MCP_TOKEN
Path mặc định quan trọng
MCP
codex:~/.codex/config.tomlcursorproject:.cursor/mcp.jsoncursorglobal:~/.cursor/mcp.jsonclaude-code:.mcp.jsonantigravity:~/.gemini/antigravity/mcp_config.jsonvscodeproject:.vscode/mcp.jsonvscodeglobal: filemcp.jsontrong user profile của VS Codeopencodeproject:opencode.jsonopencodeglobal:~/.config/opencode/opencode.json
Skill / rule / custom agent
codex:~/.codex/skills/sp-rag/SKILL.mdclaude-codeproject:.claude/skills/sp-rag/SKILL.mdclaude-codeglobal skill-only override:~/.claude/skills/sp-rag/SKILL.mdantigravity:~/.gemini/antigravity/skills/sp-rag/SKILL.mdopencode:~/.config/opencode/skills/sp-rag/SKILL.mdcursorproject:.cursor/rules/sp-rag.mdcvscodeproject:.github/agents/sp-rag.agent.mdvà.github/copilot-instructions.mdvscodeglobal:~/.copilot/agents/sp-rag.agent.mdvà~/.copilot/instructions/sp-rag.instructions.md
Luồng khuyên dùng cho dev mới
sp-rag token add --token <grc_pat_...>
sp-rag install --client codex --doctor
sp-rag add --client cursor --cwd <seo-booster-workspace>
sp-rag update --client cursor --cwd <seo-booster-workspace>
sp-rag uninstall --client cursor --scope project --cwd <seo-booster-workspace>
sp-rag explain --client codex
sp-rag token verify --token <grc_pat_...>
sp-rag config show
sp-rag codegraph status
sp-rag codegraph watch --interval-ms 2000
sp-rag codegraph runs --limit 5
sp-rag codegraph metrics
sp-rag codegraph recover --reason "Ops dọn stale run sau crash"
sp-rag mcp add antigravity
sp-rag mcp add vscode --scope project --cwd <seo-booster-workspace>
sp-rag mcp add opencode --scope project --cwd <seo-booster-workspace>
sp-rag skill install --client codex
sp-rag skill install --client cursor --scope project --cwd <seo-booster-workspace>
sp-rag skill install --client vscode --scope project --cwd <seo-booster-workspace>
sp-rag eval run --file ./examples/eval-suite.sample.json
sp-rag update --client vscode --scope project --cwd <seo-booster-workspace>
sp-rag uninstall --client vscode --scope project --cwd <seo-booster-workspace>Lệnh chính
sp-rag token add --token <grc_pat_...>
sp-rag install --client codex --doctor
sp-rag add --client cursor --cwd <seo-booster-workspace>
sp-rag explain --client codex
sp-rag token verify --token <grc_pat_...>
sp-rag config show
sp-rag doctor
sp-rag audit install --client codex
sp-rag audit signal --file ./sp-audit-signal.json
sp-rag codegraph status
sp-rag codegraph watch --interval-ms 2000
sp-rag codegraph runs --limit 10
sp-rag codegraph metrics
sp-rag codegraph recover --reason "Ops dọn stale run sau crash"
sp-rag codegraph sync --branch master --commit-sha <sha> --webhook-token <token webhook codegraph> --gitlab-job-token <ci-job-token>
sp-rag docs get public --format md
sp-rag mcp add codex
sp-rag mcp add antigravity
sp-rag mcp add vscode --scope project --cwd <seo-booster-workspace>
sp-rag mcp add opencode --scope project --cwd <seo-booster-workspace>
sp-rag skill install --client codex
sp-rag skill install --client cursor --scope project --cwd <seo-booster-workspace>
sp-rag skill install --client vscode --scope project --cwd <seo-booster-workspace>
sp-rag eval run --file ./examples/eval-suite.sample.json
sp-rag update --client codex
sp-rag update setup --client codex
sp-rag uninstall --client codexdoctor kiểm gì
sp-rag doctor giờ kiểm 2 lớp:
- ping các endpoint
api,mcp,codegraph - đọc đúng file MCP của client để kiểm:
- IDE đang nhìn vào file nào
- server entry nào được match theo alias hoặc theo endpoint
Authorizationđang là token literal, env var hợp lệ, hay đang thiếu- riêng Codex, xác nhận
bearer_token_env_var/http_headersthay vì legacy[mcp_servers.<alias>.headers] - khả năng IDE sẽ bật link đăng nhập OAuth
Ví dụ:
sp-rag doctor --client vscode --scope project --cwd <seo-booster-workspace>Nếu output có dòng:
- Authorization: thiếu hoàn toàn
- Khả năng IDE bật link đăng nhập: caothì vấn đề thường không nằm ở skill, mà ở chỗ IDE chưa nạp được bearer header từ file MCP thực tế.
Cấu hình mặc định
CLI lưu cấu hình tại:
~/.sp-rag/config.json- có thể override home dir bằng
SP_RAG_HOME_DIR
CLI có thể lưu thêm:
mcpTokencho flow cài nhanhauthEnvVarnếu muốn client đọc token từ biến môi trường thay vì lưu literaldefaultClient,defaultScope,skillClient
Giá trị mặc định:
- base URL:
https://sp-rag.secomapp.com - MCP URL:
https://sp-rag.secomapp.com/mcp - alias MCP:
sp-rag
Audit workflow sp-rag audit
sp-audit khong phai la CLI moi. No la skill/agent workflow duoc cai bang
CLI hien tai sp-rag.
Lenh chuan de cai audit workflow:
sp-rag audit install --client codexLenh nay:
- cai MCP config cho client da chon
- cai native skill/rule/custom agent
sp-audit - tai su dung config/token cua
sp-rag - van la cung binary
sp-rag, tuong tusp-rag addhaysp-rag doctor - neu token chua duoc luu, chay
sp-rag token add --token <grc_pat_...>mot lan truoc do - scope mac dinh suy theo client:
codexla global,cursor/vscodela project
Neu chi muon cai lai skill audit ma khong cham vao MCP config, co the dung low-level command:
sp-rag skill install --client codex --name sp-auditDay JSON signal do sp-audit tao ra vao server memory import path:
sp-rag audit signal --file ./sp-audit-signal.jsonaudit signal posts through the existing knowledge-source import API with
normalizer_provider=heuristic and warm_cache=false, so small audit feedback
records do not block on AI normalization or semantic-cache materialization.
Native paths cua audit workflow:
- Codex:
~/.codex/skills/sp-audit/SKILL.md - Claude Code:
.claude/skills/sp-audit/SKILL.mdhoac~/.claude/skills/sp-audit/SKILL.md - Antigravity:
~/.gemini/antigravity/skills/sp-audit/SKILL.md - OpenCode:
~/.config/opencode/skills/sp-audit/SKILL.md - Cursor:
.cursor/rules/sp-audit.mdc - VS Code:
.github/agents/sp-audit.agent.mdhoac~/.copilot/agents/sp-audit.agent.md
Chi tiet: Runbook sp-rag audit.
Evaluation mẫu
- file mẫu:
examples/eval-suite.sample.json
