@opencodehub/cli 0.2.2 → 0.2.3
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/dist/commands/ci-templates/github-nightly.yml +35 -0
- package/dist/commands/ci-templates/github-rescan.yml +52 -0
- package/dist/commands/ci-templates/github-verdict.yml +24 -0
- package/dist/commands/ci-templates/github-weekly.yml +49 -0
- package/dist/commands/ci-templates/gitlab-ci.yml +56 -0
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/plugin-assets/agents/code-analyst.md +18 -0
- package/dist/plugin-assets/commands/audit-deps.md +29 -0
- package/dist/plugin-assets/commands/owners.md +20 -0
- package/dist/plugin-assets/commands/probe.md +21 -0
- package/dist/plugin-assets/commands/rename.md +20 -0
- package/dist/plugin-assets/commands/verdict.md +18 -0
- package/dist/plugin-assets/hooks/augment.sh +128 -0
- package/dist/plugin-assets/hooks/docs-staleness.sh +45 -0
- package/dist/plugin-assets/hooks.json +34 -0
- package/dist/plugin-assets/skills/codehub-code-pack/SKILL.md +181 -0
- package/dist/plugin-assets/skills/codehub-code-pack/references/determinism-contract.md +150 -0
- package/dist/plugin-assets/skills/codehub-contract-map/SKILL.md +144 -0
- package/dist/plugin-assets/skills/codehub-document/SKILL.md +152 -0
- package/dist/plugin-assets/skills/codehub-document/references/cross-reference-spec.md +142 -0
- package/dist/plugin-assets/skills/codehub-document/references/data-source-map.md +139 -0
- package/dist/plugin-assets/skills/codehub-document/references/document-templates.md +347 -0
- package/dist/plugin-assets/skills/codehub-document/references/mermaid-patterns.md +181 -0
- package/dist/plugin-assets/skills/codehub-document/templates/agents/README.md +64 -0
- package/dist/plugin-assets/skills/codehub-document/templates/agents/doc-analysis-dead-code.md +104 -0
- package/dist/plugin-assets/skills/codehub-document/templates/agents/doc-analysis-ownership.md +101 -0
- package/dist/plugin-assets/skills/codehub-document/templates/agents/doc-analysis-risk-hotspots.md +105 -0
- package/dist/plugin-assets/skills/codehub-document/templates/agents/doc-architecture-data-flow.md +103 -0
- package/dist/plugin-assets/skills/codehub-document/templates/agents/doc-architecture-module-map.md +102 -0
- package/dist/plugin-assets/skills/codehub-document/templates/agents/doc-architecture-system-overview.md +100 -0
- package/dist/plugin-assets/skills/codehub-document/templates/agents/doc-behavior-processes.md +103 -0
- package/dist/plugin-assets/skills/codehub-document/templates/agents/doc-behavior-state-machines.md +101 -0
- package/dist/plugin-assets/skills/codehub-document/templates/agents/doc-cross-repo-contracts-matrix.md +104 -0
- package/dist/plugin-assets/skills/codehub-document/templates/agents/doc-cross-repo-dependency-flow.md +111 -0
- package/dist/plugin-assets/skills/codehub-document/templates/agents/doc-cross-repo-portfolio-map.md +106 -0
- package/dist/plugin-assets/skills/codehub-document/templates/agents/doc-diagrams-components.md +99 -0
- package/dist/plugin-assets/skills/codehub-document/templates/agents/doc-diagrams-dependency-graph.md +104 -0
- package/dist/plugin-assets/skills/codehub-document/templates/agents/doc-diagrams-sequences.md +103 -0
- package/dist/plugin-assets/skills/codehub-document/templates/agents/doc-reference-cli.md +110 -0
- package/dist/plugin-assets/skills/codehub-document/templates/agents/doc-reference-mcp-tools.md +100 -0
- package/dist/plugin-assets/skills/codehub-document/templates/agents/doc-reference-public-api.md +111 -0
- package/dist/plugin-assets/skills/codehub-document/templates/orchestrator-prompt.md +110 -0
- package/dist/plugin-assets/skills/codehub-onboarding/SKILL.md +111 -0
- package/dist/plugin-assets/skills/codehub-pr-description/SKILL.md +122 -0
- package/dist/plugin-assets/skills/opencodehub-debugging/SKILL.md +144 -0
- package/dist/plugin-assets/skills/opencodehub-exploring/SKILL.md +120 -0
- package/dist/plugin-assets/skills/opencodehub-guide/SKILL.md +180 -0
- package/dist/plugin-assets/skills/opencodehub-impact-analysis/SKILL.md +151 -0
- package/dist/plugin-assets/skills/opencodehub-pr-review/SKILL.md +246 -0
- package/dist/plugin-assets/skills/opencodehub-refactoring/SKILL.md +180 -0
- package/package.json +11 -9
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: codehub-pr-description
|
|
3
|
+
description: "Use when the user asks for a PR description, a pull request summary, a merge write-up, or a release note for a branch or diff. Examples: \"write the PR description\", \"summarize this branch for review\", \"draft release notes for HEAD\". Calls `detect_changes` + `verdict` + `owners` + `list_findings_delta` and writes Markdown. DO NOT use for open-ended architecture docs (use `codehub-document`) or onboarding guides (use `codehub-onboarding`). DO NOT use when no diff exists — the skill refuses on a clean tree."
|
|
4
|
+
allowed-tools: "Read, Write, Bash(git diff:*), Bash(git log:*), Bash(git rev-parse:*), mcp__opencodehub__detect_changes, mcp__opencodehub__verdict, mcp__opencodehub__owners, mcp__opencodehub__impact, mcp__opencodehub__signature, mcp__opencodehub__list_findings_delta, mcp__opencodehub__api_impact"
|
|
5
|
+
argument-hint: "[--base <rev>] [--head <rev>] [--out <path>]"
|
|
6
|
+
color: teal
|
|
7
|
+
model: sonnet
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# codehub-pr-description
|
|
11
|
+
|
|
12
|
+
Generates a Markdown PR body from graph primitives. Linear (no subagents). Sonnet. Refuses on a clean tree.
|
|
13
|
+
|
|
14
|
+
## Preconditions
|
|
15
|
+
|
|
16
|
+
1. Resolve `--base` (default `main`) and `--head` (default `HEAD`) via `git rev-parse`.
|
|
17
|
+
2. `git diff --name-only <base>..<head>` must return ≥ 1 path. If empty, emit `No diff detected — resolve base/head or stage changes.` and stop.
|
|
18
|
+
|
|
19
|
+
## Arguments
|
|
20
|
+
|
|
21
|
+
- `--base <rev>` — base revision. Default: `main`.
|
|
22
|
+
- `--head <rev>` — head revision. Default: `HEAD`.
|
|
23
|
+
- `--out <path>` — output path. Default: `.codehub/pr/PR-<branch>.md`.
|
|
24
|
+
|
|
25
|
+
## Process
|
|
26
|
+
|
|
27
|
+
1. Run the preconditions. On clean tree, refuse and stop.
|
|
28
|
+
2. `mcp__opencodehub__detect_changes({base, head})` — map the diff to affected symbols + processes.
|
|
29
|
+
3. `mcp__opencodehub__verdict({base, head})` — 5-tier merge recommendation with reasons.
|
|
30
|
+
4. `mcp__opencodehub__owners({paths: <changed-files>})` — required reviewers per path.
|
|
31
|
+
5. `mcp__opencodehub__list_findings_delta({base, head})` — new/resolved scanner findings in the diff range.
|
|
32
|
+
6. For any symbol flagged as tier ≥ 3 by verdict: `mcp__opencodehub__impact({symbol, direction: "downstream", depth: 2})` — spell out who breaks.
|
|
33
|
+
7. For public API changes: `mcp__opencodehub__api_impact({route})` when the diff touches a handler.
|
|
34
|
+
8. Assemble the Markdown body using the template below.
|
|
35
|
+
9. `Write` to `<out>`.
|
|
36
|
+
|
|
37
|
+
## Output template
|
|
38
|
+
|
|
39
|
+
```markdown
|
|
40
|
+
# <branch-name or commit subject>
|
|
41
|
+
|
|
42
|
+
## Summary
|
|
43
|
+
|
|
44
|
+
2–3 sentences describing what this PR changes and why. Grounded in the
|
|
45
|
+
commit messages + the highest-impact change detected.
|
|
46
|
+
|
|
47
|
+
## Verdict
|
|
48
|
+
|
|
49
|
+
**Tier <N> — <label>** per `mcp__opencodehub__verdict`.
|
|
50
|
+
|
|
51
|
+
Reasons:
|
|
52
|
+
- ... (from verdict.reasons[])
|
|
53
|
+
|
|
54
|
+
## Affected surface
|
|
55
|
+
|
|
56
|
+
| Category | Count | Details |
|
|
57
|
+
|---|---|---|
|
|
58
|
+
| Files changed | N | `git diff --stat` summary |
|
|
59
|
+
| Symbols added | N | from `detect_changes` |
|
|
60
|
+
| Symbols removed | N | from `detect_changes` |
|
|
61
|
+
| Processes touched | N | from `detect_changes.processes[]` |
|
|
62
|
+
|
|
63
|
+
### Top touched files
|
|
64
|
+
|
|
65
|
+
| File | Change | Top owner |
|
|
66
|
+
|---|---|---|
|
|
67
|
+
| `packages/foo/src/bar.ts` | +40 / -12 | alice@ |
|
|
68
|
+
| ... | ... | ... |
|
|
69
|
+
|
|
70
|
+
## Blast radius
|
|
71
|
+
|
|
72
|
+
(Only when verdict tier ≥ 3.)
|
|
73
|
+
|
|
74
|
+
- Downstream consumers of `<symbol>`: <count>. See `impact` output.
|
|
75
|
+
- Affected routes: (if `api_impact` returned non-empty)
|
|
76
|
+
|
|
77
|
+
## Findings delta
|
|
78
|
+
|
|
79
|
+
| Change | Severity | File |
|
|
80
|
+
|---|---|---|
|
|
81
|
+
| new | error | `packages/foo/src/bar.ts:42` |
|
|
82
|
+
| resolved | warn | `packages/other.ts:88` |
|
|
83
|
+
|
|
84
|
+
(Or: "No new findings. 2 findings resolved." as a terse summary.)
|
|
85
|
+
|
|
86
|
+
## Required reviewers
|
|
87
|
+
|
|
88
|
+
- `packages/foo/` — alice@, bob@
|
|
89
|
+
- `packages/other/` — charlie@
|
|
90
|
+
|
|
91
|
+
## Test plan
|
|
92
|
+
|
|
93
|
+
- [ ] ...
|
|
94
|
+
- [ ] ...
|
|
95
|
+
|
|
96
|
+
(Extract TODO-shaped lines from `git log <base>..<head>` or leave a blank checklist for the author to fill in.)
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Document format rules
|
|
100
|
+
|
|
101
|
+
- H1 = the PR title. If the branch name is descriptive, use it; otherwise fall back to the first commit subject.
|
|
102
|
+
- Every file citation uses backtick `path:LOC` form where line information is meaningful.
|
|
103
|
+
- The `Verdict` tier line is always present, even on clean-verdict passes ("Tier 1 — safe to merge").
|
|
104
|
+
- No YAML frontmatter on the output.
|
|
105
|
+
- No emojis.
|
|
106
|
+
|
|
107
|
+
## Fallback paths
|
|
108
|
+
|
|
109
|
+
- If `verdict` errors: emit "Verdict unavailable — running in degraded mode" in the Verdict section and proceed with the rest.
|
|
110
|
+
- If `list_findings_delta` returns `status: "no_baseline"`: use `list_findings` for the current head and note "No baseline for findings delta; showing current findings only."
|
|
111
|
+
- If `owners` returns `[]` for all paths: omit the Required reviewers section and record `*owners unavailable*` inline.
|
|
112
|
+
|
|
113
|
+
## Quality checklist
|
|
114
|
+
|
|
115
|
+
- [ ] Preconditions enforced — refused on clean tree.
|
|
116
|
+
- [ ] Verdict tier appears.
|
|
117
|
+
- [ ] Affected surface table present with non-empty rows.
|
|
118
|
+
- [ ] Top touched files table has at least one row with owner.
|
|
119
|
+
- [ ] Blast radius section appears iff verdict tier ≥ 3.
|
|
120
|
+
- [ ] Findings delta has a row for every new/resolved finding, or a "No new findings" summary.
|
|
121
|
+
- [ ] Test plan section exists (may be empty checklist).
|
|
122
|
+
- [ ] Output written to `<out>`; default is `.codehub/pr/PR-<branch>.md`.
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: opencodehub-debugging
|
|
3
|
+
description: "Use when the user is debugging a bug, tracing an error, or asking why something fails. Examples: \"Why is X failing?\", \"Where does this error come from?\", \"Trace this bug\", \"This endpoint returns 500\"."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Debugging with OpenCodeHub
|
|
7
|
+
|
|
8
|
+
## When to Use
|
|
9
|
+
|
|
10
|
+
- "Why is this function failing?"
|
|
11
|
+
- "Trace where this error comes from."
|
|
12
|
+
- "Who calls this method?"
|
|
13
|
+
- "This endpoint returns 500 intermittently."
|
|
14
|
+
- Investigating bugs, errors, test failures, or unexpected behaviour.
|
|
15
|
+
|
|
16
|
+
## Workflow
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
1. mcp__opencodehub__detect_changes → Is this a recent regression?
|
|
20
|
+
2. mcp__opencodehub__query({ query: "<error or symptom>" }) → Find code related to the symptom
|
|
21
|
+
3. mcp__opencodehub__context({ name: "<suspect>" }) → Callers, callees, processes, cochanges
|
|
22
|
+
4. mcp__opencodehub__sql for a process trace → Ordered PROCESS_STEP chain
|
|
23
|
+
5. mcp__opencodehub__list_findings → SARIF findings that already flagged the area
|
|
24
|
+
6. Read source files only after the graph has narrowed the suspect set
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
> If the context envelope warns the index is stale, run `codehub analyze` first — stale graphs point at the wrong suspect.
|
|
28
|
+
|
|
29
|
+
## Checklist
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
- [ ] Capture the symptom (error text, stack frame, failing assertion, wrong output)
|
|
33
|
+
- [ ] mcp__opencodehub__detect_changes({ scope: "unstaged" | "staged" })
|
|
34
|
+
— if non-empty, recent edits are the primary suspect
|
|
35
|
+
- [ ] mcp__opencodehub__query for the error text or related concept
|
|
36
|
+
- [ ] mcp__opencodehub__context on the suspect symbol
|
|
37
|
+
- [ ] Read confidenceBreakdown — if unknown > 0, an LSP contradicted a heuristic edge;
|
|
38
|
+
the suspect may be a stale or dead reference
|
|
39
|
+
- [ ] Review cochanges (git-history signal, NOT call deps) — files historically edited
|
|
40
|
+
together often point at the hidden collaborator
|
|
41
|
+
- [ ] Trace the execution via mcp__opencodehub__sql on PROCESS_STEP edges
|
|
42
|
+
- [ ] mcp__opencodehub__list_findings to see if a scanner already flagged the area
|
|
43
|
+
- [ ] Read source to confirm root cause
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Debugging Patterns
|
|
47
|
+
|
|
48
|
+
| Symptom | OpenCodeHub path |
|
|
49
|
+
| -------------------- | -------------------------------------------------------------------------- |
|
|
50
|
+
| Error message | `query` for the error text → `context` on every throw site it returned |
|
|
51
|
+
| Wrong return value | `context` on the function → trace outgoing CALLS for the data flow |
|
|
52
|
+
| Intermittent failure | `context` → look for outgoing FETCHES (external I/O) + cochanges |
|
|
53
|
+
| Performance issue | `impact` (downstream) → find symbols with many outbound CALLS (hot paths) |
|
|
54
|
+
| Recent regression | `detect_changes` → symbols touched in the working tree or staged diff |
|
|
55
|
+
| Failing scanner gate | `list_findings({ severity: "error" })` → read the rule + the hit line |
|
|
56
|
+
|
|
57
|
+
## Tools
|
|
58
|
+
|
|
59
|
+
### `mcp__opencodehub__query` — find code related to the error
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
mcp__opencodehub__query({ query: "payment validation error", repo })
|
|
63
|
+
|
|
64
|
+
→ results: validatePayment, handlePaymentError, PaymentException
|
|
65
|
+
→ processes: CheckoutFlow (populated when PROCESS_STEP edges exist)
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### `mcp__opencodehub__context` — full context for a suspect
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
mcp__opencodehub__context({ name: "validatePayment", repo })
|
|
72
|
+
|
|
73
|
+
→ incoming.CALLS: [processCheckout, webhookHandler]
|
|
74
|
+
→ outgoing.CALLS: [verifyCard, fetchRates] ← fetchRates is external I/O — likely culprit
|
|
75
|
+
→ outgoing.FETCHES: [POST https://api.stripe.com/...]
|
|
76
|
+
→ processes: [{process: "CheckoutFlow", step: 3}]
|
|
77
|
+
→ confidenceBreakdown: {confirmed: 3, heuristic: 1, unknown: 0}
|
|
78
|
+
→ cochanges: [src/payments/refund.ts (lift 4.2)] (git history, NOT call deps)
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
The `cochanges` section frequently surfaces the hidden collaborator a heuristic call graph misses. Always label it as git-history signal so the user does not treat it as a dependency.
|
|
82
|
+
|
|
83
|
+
### `mcp__opencodehub__sql` — custom call-chain trace
|
|
84
|
+
|
|
85
|
+
Two-hop upstream trace for every caller of `validatePayment`:
|
|
86
|
+
|
|
87
|
+
```sql
|
|
88
|
+
WITH direct AS (
|
|
89
|
+
SELECT from_id, to_id, 1 AS depth
|
|
90
|
+
FROM relations
|
|
91
|
+
WHERE type = 'CALLS'
|
|
92
|
+
AND to_id IN (SELECT id FROM nodes WHERE name = 'validatePayment' AND kind = 'Function')
|
|
93
|
+
),
|
|
94
|
+
indirect AS (
|
|
95
|
+
SELECT r.from_id, d.to_id, 2 AS depth
|
|
96
|
+
FROM relations r
|
|
97
|
+
JOIN direct d ON d.from_id = r.to_id
|
|
98
|
+
WHERE r.type = 'CALLS'
|
|
99
|
+
)
|
|
100
|
+
SELECT caller.name, caller.file_path, caller.start_line, u.depth
|
|
101
|
+
FROM (SELECT * FROM direct UNION ALL SELECT * FROM indirect) u
|
|
102
|
+
JOIN nodes caller ON caller.id = u.from_id
|
|
103
|
+
ORDER BY u.depth ASC, caller.name;
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### `mcp__opencodehub__list_findings` — scanner hits in the suspect area
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
mcp__opencodehub__list_findings({
|
|
110
|
+
repo,
|
|
111
|
+
severity: "error",
|
|
112
|
+
path_prefix: "src/payments"
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
→ [{rule, severity, message, file, line, snippet}]
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Use it early — a scanner often has the bug pre-labelled.
|
|
119
|
+
|
|
120
|
+
## Example: "Payment endpoint returns 500 intermittently"
|
|
121
|
+
|
|
122
|
+
```
|
|
123
|
+
1. mcp__opencodehub__detect_changes({ scope: "staged", repo: "my-app" })
|
|
124
|
+
→ empty. Not a recent regression.
|
|
125
|
+
|
|
126
|
+
2. mcp__opencodehub__query({ query: "payment error handling", repo: "my-app" })
|
|
127
|
+
→ results: validatePayment, handlePaymentError, PaymentException
|
|
128
|
+
→ processes: [CheckoutFlow (7 steps), ErrorHandling (4 steps)]
|
|
129
|
+
|
|
130
|
+
3. mcp__opencodehub__context({ name: "validatePayment", repo: "my-app" })
|
|
131
|
+
→ outgoing.CALLS: [verifyCard, fetchRates]
|
|
132
|
+
→ outgoing.FETCHES: [GET https://rates.example.com/v1/latest] ← external I/O
|
|
133
|
+
→ confidenceBreakdown: {confirmed: 3, heuristic: 0, unknown: 0}
|
|
134
|
+
→ cochanges: [src/utils/http-client.ts (lift 5.1)] ← investigate this file
|
|
135
|
+
|
|
136
|
+
4. mcp__opencodehub__list_findings({
|
|
137
|
+
repo: "my-app",
|
|
138
|
+
path_prefix: "src/utils/http-client"
|
|
139
|
+
})
|
|
140
|
+
→ security-rule "missing-request-timeout" at src/utils/http-client.ts:42 (error)
|
|
141
|
+
|
|
142
|
+
5. Root cause: `fetchRates` uses a shared HTTP client with no timeout configured;
|
|
143
|
+
Stripe rate endpoint occasionally hangs, caller returns 500.
|
|
144
|
+
```
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: opencodehub-exploring
|
|
3
|
+
description: "Use when the user asks how code works, wants to understand architecture, trace execution flows, or explore unfamiliar parts of a codebase. Examples: \"How does X work?\", \"What calls this function?\", \"Show me the auth flow\", \"Where does the request enter the system?\"."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Exploring Codebases with OpenCodeHub
|
|
7
|
+
|
|
8
|
+
## When to Use
|
|
9
|
+
|
|
10
|
+
- "How does authentication work?"
|
|
11
|
+
- "What's the project structure?"
|
|
12
|
+
- "Where is the database logic?"
|
|
13
|
+
- "Show me the request lifecycle."
|
|
14
|
+
- Onboarding to a codebase you have not seen before.
|
|
15
|
+
|
|
16
|
+
## Workflow
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
1. mcp__opencodehub__list_repos → Pick the repo name
|
|
20
|
+
2. READ codehub://repo/{name}/context → Stats + staleness envelope
|
|
21
|
+
3. mcp__opencodehub__query({query: "<concept>", repo}) → Hybrid BM25 + vector hits, grouped by process
|
|
22
|
+
4. mcp__opencodehub__context({name: "<symbol>", repo}) → 360-degree view, categorised edges, cochange side-section
|
|
23
|
+
5. mcp__opencodehub__sql for process traces → Step ordering from the relations table
|
|
24
|
+
6. Read source files only after the graph has pointed you at the hot spots
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
> If the context envelope warns the index is stale, run `codehub analyze` in the terminal first.
|
|
28
|
+
|
|
29
|
+
## Checklist
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
- [ ] mcp__opencodehub__list_repos — confirm the repo
|
|
33
|
+
- [ ] READ codehub://repo/{name}/context — check freshness
|
|
34
|
+
- [ ] mcp__opencodehub__query for the concept
|
|
35
|
+
- [ ] Scan returned processes (execution flows) before scanning files
|
|
36
|
+
- [ ] mcp__opencodehub__context on the strongest hit
|
|
37
|
+
- [ ] Inspect confidenceBreakdown — prefer confirmed edges for architectural claims
|
|
38
|
+
- [ ] Review cochanges as a secondary signal (git history, NOT call deps)
|
|
39
|
+
- [ ] Follow PROCESS_STEP edges via mcp__opencodehub__sql to trace the flow end-to-end
|
|
40
|
+
- [ ] Read source files for implementation detail only
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Tools
|
|
44
|
+
|
|
45
|
+
### `mcp__opencodehub__query` — hybrid BM25 + vector search, grouped by process
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
mcp__opencodehub__query({ query: "payment processing", repo: "my-app", limit: 20 })
|
|
49
|
+
|
|
50
|
+
→ results: ranked symbols with file path, kind, score
|
|
51
|
+
→ processes: execution flows that contain the top hits (populated when PROCESS_STEP edges exist)
|
|
52
|
+
→ next_steps: pointer to the next tool
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Use it as the first broad read after the context resource. Prefer it over Grep for concept-level questions.
|
|
56
|
+
|
|
57
|
+
### `mcp__opencodehub__context` — 360-degree view of a symbol
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
mcp__opencodehub__context({ name: "validateUser", repo: "my-app" })
|
|
61
|
+
|
|
62
|
+
→ target: {uid, kind, filePath, startLine}
|
|
63
|
+
→ incoming: categorised by edge type (CALLS, REFERENCES, IMPORTS, METHOD_OVERRIDES, ...)
|
|
64
|
+
→ outgoing: same, in the other direction
|
|
65
|
+
→ processes: [{process, step}]
|
|
66
|
+
→ cochanges: files historically edited with target's file (git history, NOT call deps)
|
|
67
|
+
→ confidenceBreakdown: {confirmed, heuristic, unknown}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Always read `confidenceBreakdown` before making an architectural claim. If `confirmed` is zero and `unknown` is non-zero, the edges are contradicted by the LSP oracle — report that caveat.
|
|
71
|
+
|
|
72
|
+
When a name is ambiguous, `context` returns a ranked candidate list instead of silently picking one. Disambiguate by passing `uid` (preferred) or `{name, file_path, kind}`.
|
|
73
|
+
|
|
74
|
+
### `mcp__opencodehub__sql` — trace a named process end-to-end
|
|
75
|
+
|
|
76
|
+
```sql
|
|
77
|
+
SELECT r.step, callee.name, callee.file_path, callee.start_line
|
|
78
|
+
FROM relations r
|
|
79
|
+
JOIN nodes proc ON proc.id = r.from_id
|
|
80
|
+
JOIN nodes callee ON callee.id = r.to_id
|
|
81
|
+
WHERE r.type = 'PROCESS_STEP'
|
|
82
|
+
AND proc.kind = 'Process'
|
|
83
|
+
AND proc.name = 'CheckoutFlow'
|
|
84
|
+
ORDER BY r.step ASC;
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Cross-repo exploration
|
|
88
|
+
|
|
89
|
+
When the concept crosses repo boundaries (e.g. a microservice calls another), use the group tools:
|
|
90
|
+
|
|
91
|
+
- `mcp__opencodehub__group_list` — discover named groups.
|
|
92
|
+
- `mcp__opencodehub__group_query({ group, query, limit })` — BM25 fan-out across every repo in the group, results tagged with `_repo`.
|
|
93
|
+
- `mcp__opencodehub__group_contracts({ group })` — HTTP contract cross-links (consumer `FETCHES` edge → producer `Route`).
|
|
94
|
+
|
|
95
|
+
## Example: "How does payment processing work?"
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
1. mcp__opencodehub__list_repos
|
|
99
|
+
→ [{name: "my-app", root: "/Users/.../my-app", nodes: 918}]
|
|
100
|
+
|
|
101
|
+
2. READ codehub://repo/my-app/context
|
|
102
|
+
→ 918 symbols, 45 processes, index fresh.
|
|
103
|
+
|
|
104
|
+
3. mcp__opencodehub__query({ query: "payment processing", repo: "my-app" })
|
|
105
|
+
→ results: processPayment (Function, src/payments/processor.ts),
|
|
106
|
+
chargeStripe, validateCard, handleRefund
|
|
107
|
+
→ processes: CheckoutFlow (step_count=7), RefundFlow (step_count=5)
|
|
108
|
+
|
|
109
|
+
4. mcp__opencodehub__context({ name: "processPayment", repo: "my-app" })
|
|
110
|
+
→ incoming.CALLS: [checkoutHandler, webhookHandler]
|
|
111
|
+
→ outgoing.CALLS: [validateCard, chargeStripe, saveTransaction]
|
|
112
|
+
→ processes: [{process: "CheckoutFlow", step: 3}]
|
|
113
|
+
→ confidenceBreakdown: {confirmed: 4, heuristic: 1, unknown: 0}
|
|
114
|
+
→ cochanges: [src/payments/refund.ts (lift 4.2), src/webhooks/stripe.ts (lift 3.1)]
|
|
115
|
+
(git history signal — files often edited together, NOT call deps.)
|
|
116
|
+
|
|
117
|
+
5. mcp__opencodehub__sql to dump the ordered CheckoutFlow.
|
|
118
|
+
|
|
119
|
+
6. Read src/payments/processor.ts for the actual implementation.
|
|
120
|
+
```
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: opencodehub-guide
|
|
3
|
+
description: "Use when the user asks about OpenCodeHub itself — available MCP tools, resources, graph schema, or workflow reference. Examples: \"What OpenCodeHub tools are available?\", \"How do I query the code graph?\", \"Show me the schema\"."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# OpenCodeHub Guide
|
|
7
|
+
|
|
8
|
+
Quick reference for every OpenCodeHub MCP tool, MCP resource, and the DuckDB-backed graph schema.
|
|
9
|
+
|
|
10
|
+
## Always Start Here
|
|
11
|
+
|
|
12
|
+
For any task that touches code understanding, debugging, impact analysis, refactoring, or PR review:
|
|
13
|
+
|
|
14
|
+
1. Call `mcp__opencodehub__list_repos` — confirm the repo is indexed and pick a `repo` name.
|
|
15
|
+
2. Read `codehub://repo/{name}/context` — codebase stats and a staleness envelope.
|
|
16
|
+
3. Match the task to a skill below and follow that skill's checklist.
|
|
17
|
+
|
|
18
|
+
> If the context envelope reports the index is stale, run `codehub analyze` in the terminal first. If it says weights are missing, run `codehub setup --embeddings` to fetch the 768d gte-modernbert-base ONNX weights.
|
|
19
|
+
|
|
20
|
+
## Skills · analysis
|
|
21
|
+
|
|
22
|
+
| Task | Skill to read |
|
|
23
|
+
| --------------------------------------------- | ----------------------------- |
|
|
24
|
+
| Understand architecture / "How does X work?" | `opencodehub-exploring` |
|
|
25
|
+
| Blast radius / "What breaks if I change X?" | `opencodehub-impact-analysis` |
|
|
26
|
+
| Trace bugs / "Why is X failing?" | `opencodehub-debugging` |
|
|
27
|
+
| Rename / extract / split / restructure | `opencodehub-refactoring` |
|
|
28
|
+
| Review a PR / "Is this safe to merge?" | `opencodehub-pr-review` |
|
|
29
|
+
| Tools, resources, schema reference | `opencodehub-guide` (here) |
|
|
30
|
+
|
|
31
|
+
## Skills · artifact factory (spec 001)
|
|
32
|
+
|
|
33
|
+
These skills produce committed Markdown artifacts — the durable output
|
|
34
|
+
Principal engineers ship. See [ADR 0007](../../../docs/adr/0007-artifact-factory.md)
|
|
35
|
+
for the scope rationale.
|
|
36
|
+
|
|
37
|
+
| Task | Skill to invoke | Trigger phrase |
|
|
38
|
+
| --------------------------------------------- | ----------------------------- | ----------------------------------------------- |
|
|
39
|
+
| Generate the full doc tree (single or group) | `codehub-document` | "document this repo", "regenerate architecture docs" |
|
|
40
|
+
| Draft a PR description from the current diff | `codehub-pr-description` | "write the PR description", "summarize this branch" |
|
|
41
|
+
| Write an onboarding guide with reading order | `codehub-onboarding` | "write ONBOARDING.md", "what should a new hire read first" |
|
|
42
|
+
| Map inter-repo contracts for a group | `codehub-contract-map` | "map the contracts", "show the contract matrix for <group>" |
|
|
43
|
+
| Build a deterministic 9-item code-pack BOM | `codehub-code-pack` | "pack this repo for an LLM", "deterministic code pack", "pack the platform group" |
|
|
44
|
+
| Draft an ADR (P1 — not yet shipped) | `codehub-adr` *(P1 backlog)* | — |
|
|
45
|
+
|
|
46
|
+
Fire these directly; do not nest them inside analysis skills. Each is a
|
|
47
|
+
standalone artifact producer with its own preconditions and output path.
|
|
48
|
+
|
|
49
|
+
## Tool Inventory (27 MCP tools)
|
|
50
|
+
|
|
51
|
+
### Code intelligence (per-repo)
|
|
52
|
+
|
|
53
|
+
| Tool | What it gives you |
|
|
54
|
+
| ----------------------------- | --------------------------------------------------------------------------------- |
|
|
55
|
+
| `mcp__opencodehub__list_repos` | Enumerate indexed repos on this machine |
|
|
56
|
+
| `mcp__opencodehub__query` | Hybrid BM25 + vector search over symbols, grouped by process |
|
|
57
|
+
| `mcp__opencodehub__context` | 360-degree symbol view + `confidenceBreakdown` + `cochanges` side-section |
|
|
58
|
+
| `mcp__opencodehub__impact` | Blast radius with risk tier + `confidenceBreakdown` |
|
|
59
|
+
| `mcp__opencodehub__detect_changes` | Map an uncommitted or committed diff to affected symbols and flows |
|
|
60
|
+
| `mcp__opencodehub__rename` | Graph-assisted multi-file rename; dry-run by default |
|
|
61
|
+
| `mcp__opencodehub__sql` | Read-only DuckDB SQL against the graph (5 s timeout) |
|
|
62
|
+
| `mcp__opencodehub__signature` | Function signature lookup for a target symbol |
|
|
63
|
+
|
|
64
|
+
### HTTP / RPC surface
|
|
65
|
+
|
|
66
|
+
| Tool | What it gives you |
|
|
67
|
+
| ----------------------------- | --------------------------------------------------------------------------------- |
|
|
68
|
+
| `mcp__opencodehub__route_map` | HTTP route inventory (method, path, handler, middleware) |
|
|
69
|
+
| `mcp__opencodehub__tool_map` | MCP tool inventory exported by this repo |
|
|
70
|
+
| `mcp__opencodehub__shape_check` | Producer/consumer response-shape mismatches |
|
|
71
|
+
| `mcp__opencodehub__api_impact` | HTTP consumer chain + middleware + affected processes for one route |
|
|
72
|
+
|
|
73
|
+
### Cross-repo (groups)
|
|
74
|
+
|
|
75
|
+
| Tool | What it gives you |
|
|
76
|
+
| ----------------------------- | --------------------------------------------------------------------------------- |
|
|
77
|
+
| `mcp__opencodehub__group_list` | Discover named repo groups |
|
|
78
|
+
| `mcp__opencodehub__group_query` | BM25 fan-out across a group with reciprocal-rank fusion |
|
|
79
|
+
| `mcp__opencodehub__group_status` | Per-repo staleness + contract freshness for a group |
|
|
80
|
+
| `mcp__opencodehub__group_contracts` | HTTP contract cross-links (consumer FETCHES edge → producer Route) |
|
|
81
|
+
|
|
82
|
+
### Supply-chain / PR review (OpenCodeHub differentiators)
|
|
83
|
+
|
|
84
|
+
| Tool | What it gives you |
|
|
85
|
+
| -------------------------------- | ------------------------------------------------------------------------------ |
|
|
86
|
+
| `mcp__opencodehub__verdict` | 5-tier PR decision (`auto_merge` → `block`) with top drivers |
|
|
87
|
+
| `mcp__opencodehub__scan` | Run Priority-1 scanners (openWorld — spawns child processes) |
|
|
88
|
+
| `mcp__opencodehub__list_findings` | Browse SARIF findings produced by `scan` or `ingest-sarif` |
|
|
89
|
+
| `mcp__opencodehub__list_findings_delta` | Diff latest scan vs. frozen baseline (new / fixed / unchanged / updated) |
|
|
90
|
+
| `mcp__opencodehub__list_dead_code` | Unreferenced exported symbols |
|
|
91
|
+
| `mcp__opencodehub__remove_dead_code` | Scripted removal of dead-code items (dry-run by default) |
|
|
92
|
+
| `mcp__opencodehub__license_audit` | Copyleft / unknown / proprietary tier check over dependencies |
|
|
93
|
+
| `mcp__opencodehub__dependencies` | External package list (ecosystem + version + manifest path) |
|
|
94
|
+
| `mcp__opencodehub__owners` | File/symbol ownership from CODEOWNERS + git blame signal |
|
|
95
|
+
| `mcp__opencodehub__risk_trends` | Per-community trend lines and 30-day projections |
|
|
96
|
+
| `mcp__opencodehub__project_profile` | High-level repo summary (languages, stacks, entry points) |
|
|
97
|
+
|
|
98
|
+
## Differentiators to surface in responses
|
|
99
|
+
|
|
100
|
+
- **`confidenceBreakdown`** — every `context` and `impact` response carries a `{confirmed, heuristic, unknown}` tally. `confirmed` means a SCIP indexer (scip-typescript / scip-python / scip-go / rust-analyzer / scip-java) has confirmed the edge at confidence ≥ 0.95. `heuristic` is tree-sitter or tier-1/tier-2 inference the SCIP oracle has not confirmed. `unknown` is demoted (≤ 0.2) — a SCIP-confirmed edge exists at the same triple and the heuristic carries a `+scip-unconfirmed` reason suffix. Report this breakdown when an agent is about to take a destructive action based on edges.
|
|
101
|
+
- **`cochanges` side-section** — `context` includes files historically co-edited with the target (by lift, from the dedicated `cochanges` table). This is a **git-history signal, not call dependencies** — label it that way when you report it. It is excluded from the graph hash.
|
|
102
|
+
- **`verdict` + `list_findings` + `list_findings_delta`** — PR review grade is deterministic, not opinion.
|
|
103
|
+
- **`license_audit`** + **`risk_trends`** + **`owners`** — first-class audit workflows without writing SQL.
|
|
104
|
+
|
|
105
|
+
## Resource Inventory
|
|
106
|
+
|
|
107
|
+
Lightweight reads for navigation (every URI uses the `codehub://` scheme):
|
|
108
|
+
|
|
109
|
+
| Resource | Content |
|
|
110
|
+
| ---------------------------------------------- | ------------------------------------------- |
|
|
111
|
+
| `codehub://repos` | Registry list: names, roots, graph hashes |
|
|
112
|
+
| `codehub://repo/{name}/context` | Stats + staleness envelope |
|
|
113
|
+
| `codehub://repo/{name}/schema` | Live node kinds / relation types for `sql` |
|
|
114
|
+
|
|
115
|
+
> Cluster and process navigation resources (`codehub://repo/{name}/clusters`, `codehub://repo/{name}/processes`, etc.) are slated for a later wave. Use `sql` against the `nodes` table filtered to `kind = 'Community'` or `kind = 'Process'` in the meantime.
|
|
116
|
+
|
|
117
|
+
## Graph schema
|
|
118
|
+
|
|
119
|
+
The graph is a DuckDB-backed store. One unified `nodes` table, one `relations` table, an `embeddings` table, a `cochanges` side table, and `store_meta`.
|
|
120
|
+
|
|
121
|
+
**Node kinds** (load-bearing order — new kinds are appended):
|
|
122
|
+
File, Folder, Function, Class, Method, Interface, Constructor, Struct, Enum, Macro, Typedef, Union, Namespace, Trait, Impl, TypeAlias, Const, Static, Variable, Property, Record, Delegate, Annotation, Template, Module, CodeElement, Community, Process, Route, Tool.
|
|
123
|
+
|
|
124
|
+
**Relation types** (append-only):
|
|
125
|
+
CONTAINS, DEFINES, IMPORTS, CALLS, EXTENDS, IMPLEMENTS, HAS_METHOD, HAS_PROPERTY, ACCESSES, METHOD_OVERRIDES, OVERRIDES, METHOD_IMPLEMENTS, MEMBER_OF, PROCESS_STEP, HANDLES_ROUTE, FETCHES, HANDLES_TOOL, ENTRY_POINT_OF, WRAPS, QUERIES, REFERENCES, FOUND_IN, DEPENDS_ON, OWNED_BY.
|
|
126
|
+
|
|
127
|
+
Cochange edges live in a **separate `cochanges` table**, NOT in `relations`. Do not query `relations` for them.
|
|
128
|
+
|
|
129
|
+
## SQL cheat-sheet (use `mcp__opencodehub__sql`)
|
|
130
|
+
|
|
131
|
+
All inbound callers of a function by name:
|
|
132
|
+
|
|
133
|
+
```sql
|
|
134
|
+
SELECT caller.name, caller.file_path, caller.start_line, r.confidence, r.reason
|
|
135
|
+
FROM relations r
|
|
136
|
+
JOIN nodes caller ON caller.id = r.from_id
|
|
137
|
+
JOIN nodes callee ON callee.id = r.to_id
|
|
138
|
+
WHERE r.type = 'CALLS'
|
|
139
|
+
AND callee.name = 'validateUser'
|
|
140
|
+
AND callee.kind = 'Function'
|
|
141
|
+
ORDER BY r.confidence DESC
|
|
142
|
+
LIMIT 50;
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Top communities by cohesion:
|
|
146
|
+
|
|
147
|
+
```sql
|
|
148
|
+
SELECT name, inferred_label, cohesion, symbol_count, keywords
|
|
149
|
+
FROM nodes
|
|
150
|
+
WHERE kind = 'Community'
|
|
151
|
+
ORDER BY cohesion DESC
|
|
152
|
+
LIMIT 20;
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Process entry points:
|
|
156
|
+
|
|
157
|
+
```sql
|
|
158
|
+
SELECT n.name, n.inferred_label, n.step_count, entry.name AS entry_point
|
|
159
|
+
FROM nodes n
|
|
160
|
+
LEFT JOIN nodes entry ON entry.id = n.entry_point_id
|
|
161
|
+
WHERE n.kind = 'Process'
|
|
162
|
+
ORDER BY n.step_count DESC;
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
SCIP-confirmed edges only (for strict impact queries):
|
|
166
|
+
|
|
167
|
+
```sql
|
|
168
|
+
SELECT from_id, to_id, type, reason
|
|
169
|
+
FROM relations
|
|
170
|
+
WHERE confidence >= 0.95
|
|
171
|
+
AND reason LIKE 'scip:%';
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Invariants agents must respect
|
|
175
|
+
|
|
176
|
+
- Every per-repo tool accepts an optional `repo` argument. When exactly one repo is indexed, `repo` is optional. When two or more are indexed and `repo` is omitted, the tool returns `AMBIGUOUS_REPO` — pass `repo` explicitly.
|
|
177
|
+
- Every response may carry `_meta.codehub/staleness` when the index is behind HEAD. Surface that to the user when it is present.
|
|
178
|
+
- Every response includes a `next_steps` array under `structuredContent`. Use it to pick the next tool without guessing.
|
|
179
|
+
- `rename` is dry-run by default — explicitly pass `dry_run: false` to apply edits.
|
|
180
|
+
- `scan` has `openWorldHint: true` — it spawns child processes. Do not invoke it on every turn.
|