@reposkein/mcp 0.3.0 → 0.5.0
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 +76 -1
- package/binary-digests.json +4 -4
- package/dist/SKILL.md +19 -0
- package/dist/cli/agentAdapters.d.ts +68 -0
- package/dist/cli/agentAdapters.js +223 -0
- package/dist/cli/agentAdapters.js.map +1 -0
- package/dist/cli/ansi.d.ts +24 -0
- package/dist/cli/ansi.js +40 -0
- package/dist/cli/ansi.js.map +1 -0
- package/dist/cli/doctor.d.ts +34 -2
- package/dist/cli/doctor.js +51 -6
- package/dist/cli/doctor.js.map +1 -1
- package/dist/cli/doctorFreshness.d.ts +43 -0
- package/dist/cli/doctorFreshness.js +111 -0
- package/dist/cli/doctorFreshness.js.map +1 -0
- package/dist/cli/doctorSummaries.d.ts +2 -0
- package/dist/cli/doctorSummaries.js +95 -0
- package/dist/cli/doctorSummaries.js.map +1 -0
- package/dist/cli/federatedDiscovery.d.ts +16 -0
- package/dist/cli/federatedDiscovery.js +75 -0
- package/dist/cli/federatedDiscovery.js.map +1 -0
- package/dist/cli/init.d.ts +69 -6
- package/dist/cli/init.js +194 -28
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/sourceSlices.d.ts +17 -0
- package/dist/cli/sourceSlices.js +59 -0
- package/dist/cli/sourceSlices.js.map +1 -0
- package/dist/cli/stats.d.ts +29 -0
- package/dist/cli/stats.js +180 -0
- package/dist/cli/stats.js.map +1 -0
- package/dist/cli/view.d.ts +71 -3
- package/dist/cli/view.js +170 -14
- package/dist/cli/view.js.map +1 -1
- package/dist/index.d.ts +8 -48
- package/dist/index.js +94 -295
- package/dist/index.js.map +1 -1
- package/dist/indexer/fetchBinary.d.ts +14 -0
- package/dist/indexer/fetchBinary.js +81 -40
- package/dist/indexer/fetchBinary.js.map +1 -1
- package/dist/indexer/indexLock.d.ts +13 -0
- package/dist/indexer/indexLock.js +66 -0
- package/dist/indexer/indexLock.js.map +1 -0
- package/dist/indexer/runIndexer.d.ts +8 -2
- package/dist/indexer/runIndexer.js +20 -4
- package/dist/indexer/runIndexer.js.map +1 -1
- package/dist/serve/serve.d.ts +95 -0
- package/dist/serve/serve.js +581 -0
- package/dist/serve/serve.js.map +1 -0
- package/dist/serve/tokens.d.ts +49 -0
- package/dist/serve/tokens.js +108 -0
- package/dist/serve/tokens.js.map +1 -0
- package/dist/serve/watch.d.ts +73 -0
- package/dist/serve/watch.js +135 -0
- package/dist/serve/watch.js.map +1 -0
- package/dist/server/createMcpServer.d.ts +129 -0
- package/dist/server/createMcpServer.js +464 -0
- package/dist/server/createMcpServer.js.map +1 -0
- package/dist/store/JsonlGraphStore.d.ts +18 -4
- package/dist/store/JsonlGraphStore.js +61 -19
- package/dist/store/JsonlGraphStore.js.map +1 -1
- package/dist/store/decisions.d.ts +20 -2
- package/dist/store/decisions.js +35 -2
- package/dist/store/decisions.js.map +1 -1
- package/dist/store/indexedAt.d.ts +18 -0
- package/dist/store/indexedAt.js +56 -0
- package/dist/store/indexedAt.js.map +1 -0
- package/dist/store/instrumentTool.d.ts +40 -0
- package/dist/store/instrumentTool.js +82 -0
- package/dist/store/instrumentTool.js.map +1 -0
- package/dist/store/repoContextCache.d.ts +15 -0
- package/dist/store/repoContextCache.js +26 -0
- package/dist/store/repoContextCache.js.map +1 -0
- package/dist/store/repoSession.d.ts +63 -0
- package/dist/store/repoSession.js +123 -0
- package/dist/store/repoSession.js.map +1 -0
- package/dist/store/resolveRepoPath.d.ts +31 -0
- package/dist/store/resolveRepoPath.js +85 -0
- package/dist/store/resolveRepoPath.js.map +1 -0
- package/dist/store/sessionLog.d.ts +98 -0
- package/dist/store/sessionLog.js +216 -0
- package/dist/store/sessionLog.js.map +1 -0
- package/dist/store/sessionStats.d.ts +55 -0
- package/dist/store/sessionStats.js +140 -0
- package/dist/store/sessionStats.js.map +1 -0
- package/dist/store/sidecar.d.ts +39 -3
- package/dist/store/sidecar.js +89 -5
- package/dist/store/sidecar.js.map +1 -1
- package/dist/store/summaryShards.d.ts +117 -0
- package/dist/store/summaryShards.js +291 -0
- package/dist/store/summaryShards.js.map +1 -0
- package/dist/store/teamConfig.d.ts +17 -0
- package/dist/store/teamConfig.js +55 -0
- package/dist/store/teamConfig.js.map +1 -0
- package/dist/tools/indexerTools.d.ts +14 -2
- package/dist/tools/indexerTools.js +17 -5
- package/dist/tools/indexerTools.js.map +1 -1
- package/dist/tools/recordDecision.d.ts +3 -0
- package/dist/tools/recordDecision.js +7 -2
- package/dist/tools/recordDecision.js.map +1 -1
- package/dist/tools/writeSemanticSummary.d.ts +4 -1
- package/dist/tools/writeSemanticSummary.js +5 -2
- package/dist/tools/writeSemanticSummary.js.map +1 -1
- package/dist/viz/assets/{graph.worker-CC7BeE-8.js → graph.worker-DkH6-lMU.js} +1 -1
- package/dist/viz/assets/index-BnqIVYFE.css +1 -0
- package/dist/viz/assets/index-IhtszTp0.js +5 -0
- package/dist/viz/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
- package/dist/viz/assets/jetbrains-mono-latin-500-normal-BWZEU5yA.woff2 +0 -0
- package/dist/viz/assets/jetbrains-mono-latin-700-normal-BYuf6tUa.woff2 +0 -0
- package/dist/viz/assets/r3f-Bn9htB92.js +336 -0
- package/dist/viz/assets/tanstack-CSzx6NDA.js +62 -0
- package/dist/viz/assets/three-Cpu5RUEM.js +4116 -0
- package/dist/viz/index.html +5 -4
- package/package.json +5 -4
- package/dist/viz/assets/index-C_8UkiJ8.js +0 -9
- package/dist/viz/assets/r3f-Cku1OhB-.js +0 -277
- package/dist/viz/assets/tanstack-DyXcNRWk.js +0 -77
- package/dist/viz/assets/three-Z8XaLGmf.js +0 -3839
package/README.md
CHANGED
|
@@ -57,6 +57,8 @@ Then ask your agent *"what calls this function?"* or *"what breaks if I change X
|
|
|
57
57
|
|
|
58
58
|
| Tool | What it does |
|
|
59
59
|
| --- | --- |
|
|
60
|
+
| `list_repos` | enumerate the repos discovered by resolution — path, name, cheap node/edge counts. One entry in single-repo mode; workspace mode lists every sibling repo found |
|
|
61
|
+
| `select_repo` | set the session-active repo (by `path` or `name` from `list_repos`) for every repo-scoped tool below — how workspace mode resolves ambiguity, and how you switch repos without restarting the server |
|
|
60
62
|
| `get_context_profile` | resolve a function/class → its caller/callee neighborhood as ready-to-read prose |
|
|
61
63
|
| `semantic_find` | find where to start — rank functions/classes by meaning (lexical BM25F; optional pluggable embeddings), seeding `get_context_profile` |
|
|
62
64
|
| `impact` | transitive callers of a function/class — split into impacted code vs covering tests — with counts and truncated flag |
|
|
@@ -71,7 +73,9 @@ Then ask your agent *"what calls this function?"* or *"what breaks if I change X
|
|
|
71
73
|
- `reposkein-mcp init` — set up a repo (downloads the indexer, installs git hooks + the skill, builds the graph, prints an MCP config block).
|
|
72
74
|
- `reposkein-mcp doctor` — health check (binary → index → MCP reachability).
|
|
73
75
|
- `reposkein-mcp index` — rebuild the committed graph after big changes.
|
|
76
|
+
- `reposkein-mcp stats [--last | --session <id> | --all] [--json]` — session usage report: calls by tool, top queried nodes/files, ADRs/summaries written, session duration, and an *estimated* context-tokens-saved-vs-grep number. See [Session usage stats](#session-usage-stats) below.
|
|
74
77
|
- `reposkein-mcp view [path]` — open the **constellation viewer**: a local, read-only, zero-infra web app (bound to `127.0.0.1`) that renders the committed `.reposkein` graph as an interactive 3D astronomy-style map. `--export <dir>` instead writes a self-contained static site (works from `file://` or any static host). See the [viewer section in the main README](https://github.com/reposkein/reposkein#visualize-the-graph--the-constellation-viewer), or **[try the live demo](https://reposkein.github.io/reposkein/)** (RepoSkein viewing its own graph).
|
|
78
|
+
- `reposkein-mcp serve --http [path]` — **advanced, optional**: one shared server for agents that have no clone. Speaks MCP over Streamable HTTP and serves the viewer + `/api/*` from the same process, behind bearer-token auth, read-only by default, re-indexing when the served checkout's HEAD moves. Nothing binds a socket unless you run it; stdio remains the default transport. See [`docs/REMOTE.md`](https://github.com/reposkein/reposkein/blob/main/docs/REMOTE.md).
|
|
75
79
|
|
|
76
80
|
## How your agent uses it
|
|
77
81
|
|
|
@@ -92,12 +96,83 @@ npx skills add reposkein/reposkein --all
|
|
|
92
96
|
|
|
93
97
|
(`reposkein-mcp init` already installs the navigation skill for Claude Code; this adds it to Cursor, Codex, and 70+ other agents.)
|
|
94
98
|
|
|
99
|
+
## Session usage stats
|
|
100
|
+
|
|
101
|
+
Every tool call is logged, server-side, as one JSONL line to
|
|
102
|
+
`.reposkein/local/sessions/<session-id>.jsonl` under the repo the call
|
|
103
|
+
touched — `{ts, tool, argsShape, resultBytes, nodeIds}`, never argument or
|
|
104
|
+
result *values* (only argument key names — no code/user text ever lands on
|
|
105
|
+
disk). Because logging happens in the server, this works for **any**
|
|
106
|
+
MCP-capable agent (Claude Code, Cursor, Codex, …), not just one. It's
|
|
107
|
+
zero-infra like everything else here: local-only, git-ignored (`local/`),
|
|
108
|
+
never blocks or fails a tool call — a logging failure is always swallowed.
|
|
109
|
+
Old sessions are pruned automatically (newest 50, or 30 days, whichever is
|
|
110
|
+
stricter).
|
|
111
|
+
|
|
112
|
+
```sh
|
|
113
|
+
reposkein-mcp stats # last session, human-readable
|
|
114
|
+
reposkein-mcp stats --all # every retained session, combined
|
|
115
|
+
reposkein-mcp stats --session <id> # one specific session
|
|
116
|
+
reposkein-mcp stats --json # machine-readable
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
The report includes calls by tool, the top queried nodes/files, ADRs and
|
|
120
|
+
semantic summaries written, session duration, and an **estimated**
|
|
121
|
+
context-tokens-saved-vs-grep figure (using the ~8.4× mean token ratio
|
|
122
|
+
measured in [`mcp/bench`](https://github.com/reposkein/reposkein/tree/main/mcp/bench) — always labeled an estimate, never claimed as measured).
|
|
123
|
+
|
|
124
|
+
**Claude Code Stop-hook recipe** — print a session's stats the moment it ends, by adding to `.claude/settings.json`:
|
|
125
|
+
|
|
126
|
+
```json
|
|
127
|
+
{
|
|
128
|
+
"hooks": {
|
|
129
|
+
"Stop": [
|
|
130
|
+
{
|
|
131
|
+
"hooks": [
|
|
132
|
+
{ "type": "command", "command": "reposkein-mcp stats --last" }
|
|
133
|
+
]
|
|
134
|
+
}
|
|
135
|
+
]
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
95
140
|
## Configuration
|
|
96
141
|
|
|
142
|
+
### Repo resolution (zero-config)
|
|
143
|
+
|
|
144
|
+
`REPOSKEIN_REPO_PATH` is optional — the server resolves the target repo from
|
|
145
|
+
the process's working directory. Full precedence:
|
|
146
|
+
|
|
147
|
+
1. **`select_repo`** — an MCP tool call that sets the session-active repo
|
|
148
|
+
(by `path` or `name` from `list_repos`) for every repo-scoped tool call
|
|
149
|
+
made afterward, for the rest of the connection. The only one of these
|
|
150
|
+
that's mutable at runtime — everything below it is fixed at server start.
|
|
151
|
+
2. `REPOSKEIN_REPO_PATH`, if set.
|
|
152
|
+
3. **Walk up:** the nearest ancestor of the cwd containing `.reposkein/`.
|
|
153
|
+
4. **Walk down** (workspace mode, only tried when no ancestor has one): scans
|
|
154
|
+
the cwd's children and grandchildren (skipping `node_modules`, `.git`,
|
|
155
|
+
`target`, `dist`, `.worktrees`, `.claude`) for `.reposkein/` dirs. One hit
|
|
156
|
+
is used automatically; two or more leave the repo unresolved until a
|
|
157
|
+
`select_repo` call picks one — `list_repos` always enumerates every repo
|
|
158
|
+
the walk finds (plus a `REPOSKEIN_REPO_PATH` pin, if one is set and not
|
|
159
|
+
already among them), regardless of which one is currently active.
|
|
160
|
+
|
|
161
|
+
If nothing resolves — or step 4 finds more than one repo and none has been
|
|
162
|
+
`select_repo`'d — repo-scoped tools don't fail silently at startup: each call
|
|
163
|
+
returns a structured error telling you what to run (`reposkein-mcp init`,
|
|
164
|
+
`list_repos`/`select_repo`, or which `REPOSKEIN_REPO_PATH` to set — naming the
|
|
165
|
+
candidates when ambiguous). `reposkein-mcp doctor` and `--help` never require
|
|
166
|
+
a resolved repo. See `mcp/src/store/resolveRepoPath.ts` and
|
|
167
|
+
`mcp/src/store/repoSession.ts`.
|
|
168
|
+
|
|
97
169
|
| Env var | Purpose |
|
|
98
170
|
| --- | --- |
|
|
99
|
-
| `REPOSKEIN_REPO_PATH` | the repository the server operates on
|
|
171
|
+
| `REPOSKEIN_REPO_PATH` | pins the repository the server operates on — optional, see repo resolution above |
|
|
172
|
+
| `REPOSKEIN_SESSION_ID` | override the session id used for `reposkein-mcp stats` logging (default: start-timestamp + pid) |
|
|
100
173
|
| `REPOSKEIN_STORE` | `auto` (default) · `jsonl` (zero-infra) · `neo4j` |
|
|
174
|
+
| `REPOSKEIN_AGENT` | names the writer in `summary_by` / `decided_by` and picks its `local/summaries-<agent>.jsonl` sidecar (default `agent`) |
|
|
175
|
+
| `REPOSKEIN_SERVE_TOKENS` | `serve --http` only — `name:secret[:write]` entries, comma- or whitespace-separated. Required for that mode; see [`docs/REMOTE.md`](https://github.com/reposkein/reposkein/blob/main/docs/REMOTE.md) |
|
|
101
176
|
| `REPOSKEIN_INDEXER_BIN` | override the `reposkein-indexer` binary path (unsupported platforms) |
|
|
102
177
|
| `NEO4J_URI` / `NEO4J_USER` / `NEO4J_PASSWORD` | optional Neo4j backend (large graphs / Cypher at scale) |
|
|
103
178
|
| `REPOSKEIN_EMBED_PROVIDER` | `none` (default) · `voyage` · `http` — see below |
|
package/binary-digests.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"reposkein-indexer-darwin-arm64": "
|
|
3
|
-
"reposkein-indexer-linux-arm64": "
|
|
4
|
-
"reposkein-indexer-linux-x64": "
|
|
5
|
-
"reposkein-indexer-win32-x64.exe": "
|
|
2
|
+
"reposkein-indexer-darwin-arm64": "44e6507e9c196139eecabf754155a464c1674f4f639165cbcbab2f47fe80028e",
|
|
3
|
+
"reposkein-indexer-linux-arm64": "3b5ea437991512aa259ded52b0ad0ed231ad67b85658ecf19f833ebf46aae3a1",
|
|
4
|
+
"reposkein-indexer-linux-x64": "6efcd8389ed0a4e9bb92bd87189ed31930914dd43f73aeed0d862cda482b54b6",
|
|
5
|
+
"reposkein-indexer-win32-x64.exe": "1da272f56560a8744776ce88d808be5afb95490baa144cc5818ac586a7fd22b0"
|
|
6
6
|
}
|
package/dist/SKILL.md
CHANGED
|
@@ -14,8 +14,27 @@ calls — that you enrich with natural-language summaries just-in-time. Do NOT
|
|
|
14
14
|
guess file dependencies, and do NOT explore the repo by directory listing or
|
|
15
15
|
grep when the graph can answer structurally.
|
|
16
16
|
|
|
17
|
+
The server resolves the target repo automatically from your working
|
|
18
|
+
directory — no setup is required. If a tool call returns an error naming
|
|
19
|
+
`list_repos`/`select_repo` or `REPOSKEIN_REPO_PATH`, do not abandon these
|
|
20
|
+
tools and fall back to grep — the error is actionable:
|
|
21
|
+
|
|
22
|
+
- **No repo found at all** — run `reposkein-mcp init` in the repo (if it has
|
|
23
|
+
no `.reposkein/` yet), or set `REPOSKEIN_REPO_PATH`.
|
|
24
|
+
- **Multiple repos found (workspace mode)** — the error names the
|
|
25
|
+
candidates. Call `list_repos` to see them (path, name, node/edge counts),
|
|
26
|
+
then `select_repo` with one candidate's `path` or `name` — this sets the
|
|
27
|
+
active repo for the rest of the session, so you only do it once. Retry the
|
|
28
|
+
call that failed.
|
|
29
|
+
|
|
17
30
|
## Tools
|
|
18
31
|
|
|
32
|
+
- **`list_repos`** / **`select_repo`** — only needed in workspace mode
|
|
33
|
+
(multiple sibling repos, no unambiguous default). `list_repos` enumerates
|
|
34
|
+
what was discovered; `select_repo` (a `path` or `name` from that list) sets
|
|
35
|
+
the active repo for every repo-scoped tool below, for the rest of the
|
|
36
|
+
session. Skip these in the common single-repo case — resolution just works.
|
|
37
|
+
|
|
19
38
|
- **`semantic_find`** — **start here when you don't have a seed symbol.** Rank
|
|
20
39
|
functions/classes/interfaces/enums by a lexical match (BM25F) over their
|
|
21
40
|
qualified names, signatures, and committed summaries. Use for cold-start "where
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/** Per-agent MCP config adapters for `reposkein-mcp init`'s join mode
|
|
2
|
+
* (REP-16 T5). A "join" is: someone cloned a repo that already has RepoSkein
|
|
3
|
+
* set up (committed `.reposkein/meta.json`) — the one thing left to do is
|
|
4
|
+
* wire the local agent(s) up, which today means hand-copying a JSON snippet
|
|
5
|
+
* from docs/INSTALL.md §6. These adapters do that automatically.
|
|
6
|
+
*
|
|
7
|
+
* Schemas match docs/INSTALL.md §6 exactly — that doc is the spec:
|
|
8
|
+
* - Claude Code: `<repo>/.mcp.json`, `mcpServers` key. Prefers `claude mcp
|
|
9
|
+
* add` (scope "project", which itself targets .mcp.json) when the CLI is
|
|
10
|
+
* on PATH, so Claude's own approval/health-check flow sees the entry;
|
|
11
|
+
* falls back to writing the file directly.
|
|
12
|
+
* - OpenCode (+omo): `<repo>/opencode.json`, `mcp` key (NOT `mcpServers`).
|
|
13
|
+
* - Cursor: `<repo>/.cursor/mcp.json`, `mcpServers` key.
|
|
14
|
+
* - Unknown/no agent detected: falls back to `.mcp.json` (§6.6 "generic").
|
|
15
|
+
*
|
|
16
|
+
* Every write is idempotent (re-run = no-op, byte-identical file), dry-run
|
|
17
|
+
* aware (never touches disk when `dryRun: true`), and backs up any file it
|
|
18
|
+
* actually modifies to a timestamped `.bak` sibling first. */
|
|
19
|
+
export type AgentId = "claude" | "opencode" | "cursor";
|
|
20
|
+
export declare const ALL_AGENT_IDS: readonly AgentId[];
|
|
21
|
+
export type AdapterAction = "created" | "updated" | "unchanged" | "dry-run" | "error";
|
|
22
|
+
export interface AdapterResult {
|
|
23
|
+
agent: AgentId;
|
|
24
|
+
/** File this adapter wrote (or would write). For the "claude" adapter via
|
|
25
|
+
* the CLI this is still `.mcp.json` — `claude mcp add -s project` writes
|
|
26
|
+
* there under the hood. */
|
|
27
|
+
path: string;
|
|
28
|
+
action: AdapterAction;
|
|
29
|
+
/** Set only when an existing file was actually modified. */
|
|
30
|
+
backupPath?: string;
|
|
31
|
+
message: string;
|
|
32
|
+
}
|
|
33
|
+
export interface ExecResult {
|
|
34
|
+
status: number;
|
|
35
|
+
stdout: string;
|
|
36
|
+
stderr: string;
|
|
37
|
+
}
|
|
38
|
+
/** Injectable command runner — never throws (unlike execFileSync). Tests
|
|
39
|
+
* inject a fake to avoid shelling out to a real `claude`/`opencode` CLI or
|
|
40
|
+
* mutating a real project's MCP config. */
|
|
41
|
+
export type Exec = (cmd: string, args: string[], opts: {
|
|
42
|
+
cwd: string;
|
|
43
|
+
}) => ExecResult;
|
|
44
|
+
export declare const defaultExec: Exec;
|
|
45
|
+
/** Detects which agents are "present": their CLI is on PATH, or their config
|
|
46
|
+
* file already exists (someone opted in previously — keep writing there).
|
|
47
|
+
* Falls back to `["claude"]` (→ `.mcp.json`, the generic/broadest-compat
|
|
48
|
+
* target) when nothing is detected at all, matching docs/INSTALL.md §6.6. */
|
|
49
|
+
export declare function detectAgents(repoPath: string, exec?: Exec): AgentId[];
|
|
50
|
+
/** Parses a comma/space-separated `--agents` value into AgentId[], ignoring
|
|
51
|
+
* unknown tokens (never throws — an unrecognized agent name just writes
|
|
52
|
+
* nothing rather than crashing `init`). */
|
|
53
|
+
export declare function parseAgentsFlag(value: string): AgentId[];
|
|
54
|
+
export interface WriteAgentConfigsOptions {
|
|
55
|
+
/** Explicit `--agents` override — write exactly these, skipping detection. */
|
|
56
|
+
agents?: AgentId[];
|
|
57
|
+
dryRun?: boolean;
|
|
58
|
+
/** Injectable for tests. */
|
|
59
|
+
exec?: Exec;
|
|
60
|
+
now?: () => Date;
|
|
61
|
+
}
|
|
62
|
+
/** Writes (or plans, under `dryRun`) the local agent MCP config for every
|
|
63
|
+
* detected/requested agent. Pure w.r.t. its inputs beyond `exec`/`now`/fs —
|
|
64
|
+
* same repo state + same options always produces the same plan, which is
|
|
65
|
+
* what makes idempotence and dry-run trustworthy. */
|
|
66
|
+
export declare function writeAgentConfigs(repoPath: string, opts?: WriteAgentConfigsOptions): AdapterResult[];
|
|
67
|
+
/** One line per adapter result, for `init`'s stderr summary. */
|
|
68
|
+
export declare function formatAdapterResult(r: AdapterResult): string;
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
/** Per-agent MCP config adapters for `reposkein-mcp init`'s join mode
|
|
2
|
+
* (REP-16 T5). A "join" is: someone cloned a repo that already has RepoSkein
|
|
3
|
+
* set up (committed `.reposkein/meta.json`) — the one thing left to do is
|
|
4
|
+
* wire the local agent(s) up, which today means hand-copying a JSON snippet
|
|
5
|
+
* from docs/INSTALL.md §6. These adapters do that automatically.
|
|
6
|
+
*
|
|
7
|
+
* Schemas match docs/INSTALL.md §6 exactly — that doc is the spec:
|
|
8
|
+
* - Claude Code: `<repo>/.mcp.json`, `mcpServers` key. Prefers `claude mcp
|
|
9
|
+
* add` (scope "project", which itself targets .mcp.json) when the CLI is
|
|
10
|
+
* on PATH, so Claude's own approval/health-check flow sees the entry;
|
|
11
|
+
* falls back to writing the file directly.
|
|
12
|
+
* - OpenCode (+omo): `<repo>/opencode.json`, `mcp` key (NOT `mcpServers`).
|
|
13
|
+
* - Cursor: `<repo>/.cursor/mcp.json`, `mcpServers` key.
|
|
14
|
+
* - Unknown/no agent detected: falls back to `.mcp.json` (§6.6 "generic").
|
|
15
|
+
*
|
|
16
|
+
* Every write is idempotent (re-run = no-op, byte-identical file), dry-run
|
|
17
|
+
* aware (never touches disk when `dryRun: true`), and backs up any file it
|
|
18
|
+
* actually modifies to a timestamped `.bak` sibling first. */
|
|
19
|
+
import { existsSync, readFileSync, writeFileSync, copyFileSync, mkdirSync } from "node:fs";
|
|
20
|
+
import { execFileSync } from "node:child_process";
|
|
21
|
+
import { dirname, join, resolve } from "node:path";
|
|
22
|
+
export const ALL_AGENT_IDS = ["claude", "opencode", "cursor"];
|
|
23
|
+
export const defaultExec = (cmd, args, opts) => {
|
|
24
|
+
try {
|
|
25
|
+
const stdout = execFileSync(cmd, args, { cwd: opts.cwd, encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] });
|
|
26
|
+
return { status: 0, stdout, stderr: "" };
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
const e = err;
|
|
30
|
+
return {
|
|
31
|
+
status: typeof e.status === "number" ? e.status : 1,
|
|
32
|
+
stdout: e.stdout ? e.stdout.toString() : "",
|
|
33
|
+
stderr: e.stderr ? e.stderr.toString() : String(e.message ?? err),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
function commandAvailable(exec, cmd, cwd) {
|
|
38
|
+
return exec(cmd, ["--version"], { cwd }).status === 0;
|
|
39
|
+
}
|
|
40
|
+
/** Detects which agents are "present": their CLI is on PATH, or their config
|
|
41
|
+
* file already exists (someone opted in previously — keep writing there).
|
|
42
|
+
* Falls back to `["claude"]` (→ `.mcp.json`, the generic/broadest-compat
|
|
43
|
+
* target) when nothing is detected at all, matching docs/INSTALL.md §6.6. */
|
|
44
|
+
export function detectAgents(repoPath, exec = defaultExec) {
|
|
45
|
+
const present = [];
|
|
46
|
+
if (existsSync(join(repoPath, ".mcp.json")) || commandAvailable(exec, "claude", repoPath))
|
|
47
|
+
present.push("claude");
|
|
48
|
+
if (existsSync(join(repoPath, "opencode.json")) || commandAvailable(exec, "opencode", repoPath))
|
|
49
|
+
present.push("opencode");
|
|
50
|
+
if (existsSync(join(repoPath, ".cursor")))
|
|
51
|
+
present.push("cursor");
|
|
52
|
+
if (present.length === 0)
|
|
53
|
+
present.push("claude");
|
|
54
|
+
return present;
|
|
55
|
+
}
|
|
56
|
+
/** Parses a comma/space-separated `--agents` value into AgentId[], ignoring
|
|
57
|
+
* unknown tokens (never throws — an unrecognized agent name just writes
|
|
58
|
+
* nothing rather than crashing `init`). */
|
|
59
|
+
export function parseAgentsFlag(value) {
|
|
60
|
+
const known = new Set(ALL_AGENT_IDS);
|
|
61
|
+
return value
|
|
62
|
+
.split(/[,\s]+/)
|
|
63
|
+
.map((s) => s.trim().toLowerCase())
|
|
64
|
+
.filter((s) => known.has(s));
|
|
65
|
+
}
|
|
66
|
+
function timestampSuffix(now) {
|
|
67
|
+
return now.toISOString().replace(/[:.]/g, "-");
|
|
68
|
+
}
|
|
69
|
+
/** Copies `path` to `<path>.<timestamp>.bak` before it's modified. */
|
|
70
|
+
function backupFile(path, now) {
|
|
71
|
+
const backupPath = `${path}.${timestampSuffix(now)}.bak`;
|
|
72
|
+
copyFileSync(path, backupPath);
|
|
73
|
+
return backupPath;
|
|
74
|
+
}
|
|
75
|
+
const MCP_JSON_SPEC = {
|
|
76
|
+
relPath: ".mcp.json",
|
|
77
|
+
topKey: "mcpServers",
|
|
78
|
+
buildEntry: (absRepoPath) => ({ command: "reposkein-mcp", env: { REPOSKEIN_REPO_PATH: absRepoPath } }),
|
|
79
|
+
};
|
|
80
|
+
const OPENCODE_JSON_SPEC = {
|
|
81
|
+
relPath: "opencode.json",
|
|
82
|
+
topKey: "mcp",
|
|
83
|
+
buildEntry: (absRepoPath) => ({
|
|
84
|
+
type: "local",
|
|
85
|
+
command: ["reposkein-mcp"],
|
|
86
|
+
environment: { REPOSKEIN_REPO_PATH: absRepoPath },
|
|
87
|
+
enabled: true,
|
|
88
|
+
}),
|
|
89
|
+
};
|
|
90
|
+
const CURSOR_JSON_SPEC = {
|
|
91
|
+
relPath: join(".cursor", "mcp.json"),
|
|
92
|
+
topKey: "mcpServers",
|
|
93
|
+
buildEntry: (absRepoPath) => ({ command: "reposkein-mcp", env: { REPOSKEIN_REPO_PATH: absRepoPath } }),
|
|
94
|
+
};
|
|
95
|
+
/** Idempotently upserts `doc[topKey].reposkein = entry` in a JSON config
|
|
96
|
+
* file, preserving every other key untouched (other MCP servers, `$schema`,
|
|
97
|
+
* etc.). Never guesses at a corrupt/hand-edited existing file — see the
|
|
98
|
+
* early return below: it backs the file up (real run only) and reports an
|
|
99
|
+
* "error" result instead of overwriting it with a reposkein-only doc,
|
|
100
|
+
* which would silently destroy whatever else was in there. */
|
|
101
|
+
function upsertJsonAdapter(repoPath, spec, dryRun, now) {
|
|
102
|
+
const path = join(repoPath, spec.relPath);
|
|
103
|
+
const exists = existsSync(path);
|
|
104
|
+
let doc = {};
|
|
105
|
+
if (exists) {
|
|
106
|
+
let raw;
|
|
107
|
+
try {
|
|
108
|
+
raw = readFileSync(path, "utf8");
|
|
109
|
+
}
|
|
110
|
+
catch (err) {
|
|
111
|
+
return {
|
|
112
|
+
path,
|
|
113
|
+
action: "error",
|
|
114
|
+
message: `could not read ${spec.relPath}: ${err instanceof Error ? err.message : String(err)}`,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
try {
|
|
118
|
+
doc = JSON.parse(raw);
|
|
119
|
+
}
|
|
120
|
+
catch (err) {
|
|
121
|
+
const parseMessage = err instanceof Error ? err.message : String(err);
|
|
122
|
+
if (dryRun) {
|
|
123
|
+
return {
|
|
124
|
+
path,
|
|
125
|
+
action: "error",
|
|
126
|
+
message: `${spec.relPath} is not valid JSON (${parseMessage}) — left untouched. ` +
|
|
127
|
+
"Fix the JSON and re-run, or delete the file.",
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
const backupPath = backupFile(path, now);
|
|
131
|
+
return {
|
|
132
|
+
path,
|
|
133
|
+
action: "error",
|
|
134
|
+
backupPath,
|
|
135
|
+
message: `${spec.relPath} is not valid JSON (${parseMessage}) — left untouched, backed up to ${backupPath}. ` +
|
|
136
|
+
"Fix the JSON and re-run, or delete the file.",
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
const section = doc[spec.topKey] ?? {};
|
|
141
|
+
const entry = spec.buildEntry(resolve(repoPath));
|
|
142
|
+
if (JSON.stringify(section.reposkein ?? null) === JSON.stringify(entry)) {
|
|
143
|
+
return { path, action: "unchanged", message: `${spec.relPath} already has an up-to-date reposkein entry` };
|
|
144
|
+
}
|
|
145
|
+
if (dryRun) {
|
|
146
|
+
return {
|
|
147
|
+
path,
|
|
148
|
+
action: "dry-run",
|
|
149
|
+
message: `would ${exists ? "update" : "create"} ${spec.relPath} (${spec.topKey}.reposkein)`,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
let backupPath;
|
|
153
|
+
if (exists)
|
|
154
|
+
backupPath = backupFile(path, now);
|
|
155
|
+
doc[spec.topKey] = { ...section, reposkein: entry };
|
|
156
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
157
|
+
writeFileSync(path, JSON.stringify(doc, null, 2) + "\n", "utf8");
|
|
158
|
+
return { path, action: exists ? "updated" : "created", backupPath, message: `${exists ? "updated" : "created"} ${spec.relPath}` };
|
|
159
|
+
}
|
|
160
|
+
function claudeCliEntryExists(exec, repoPath) {
|
|
161
|
+
return exec("claude", ["mcp", "get", "reposkein"], { cwd: repoPath }).status === 0;
|
|
162
|
+
}
|
|
163
|
+
/** Writes the Claude Code entry via `claude mcp add -s project` (which
|
|
164
|
+
* itself targets `.mcp.json`), so Claude's own health-check/approval UI
|
|
165
|
+
* picks it up immediately. Idempotent via `claude mcp get` — a re-run
|
|
166
|
+
* no-ops instead of erroring on a duplicate name. */
|
|
167
|
+
function writeViaClaudeCli(repoPath, dryRun, exec) {
|
|
168
|
+
const path = join(repoPath, ".mcp.json");
|
|
169
|
+
if (claudeCliEntryExists(exec, repoPath)) {
|
|
170
|
+
return { agent: "claude", path, action: "unchanged", message: "`claude mcp get reposkein` already resolves — nothing to add" };
|
|
171
|
+
}
|
|
172
|
+
const args = ["mcp", "add", "reposkein", "-s", "project", "-e", `REPOSKEIN_REPO_PATH=${resolve(repoPath)}`, "--", "reposkein-mcp"];
|
|
173
|
+
if (dryRun) {
|
|
174
|
+
return { agent: "claude", path, action: "dry-run", message: `would run: claude ${args.join(" ")}` };
|
|
175
|
+
}
|
|
176
|
+
const r = exec("claude", args, { cwd: repoPath });
|
|
177
|
+
if (r.status !== 0) {
|
|
178
|
+
return { agent: "claude", path, action: "error", message: `claude mcp add failed: ${(r.stderr || r.stdout).trim()}` };
|
|
179
|
+
}
|
|
180
|
+
return { agent: "claude", path, action: "created", message: "added via `claude mcp add` (project scope → .mcp.json)" };
|
|
181
|
+
}
|
|
182
|
+
/** Writes (or plans, under `dryRun`) the local agent MCP config for every
|
|
183
|
+
* detected/requested agent. Pure w.r.t. its inputs beyond `exec`/`now`/fs —
|
|
184
|
+
* same repo state + same options always produces the same plan, which is
|
|
185
|
+
* what makes idempotence and dry-run trustworthy. */
|
|
186
|
+
export function writeAgentConfigs(repoPath, opts = {}) {
|
|
187
|
+
const exec = opts.exec ?? defaultExec;
|
|
188
|
+
const now = (opts.now ?? (() => new Date()))();
|
|
189
|
+
const dryRun = !!opts.dryRun;
|
|
190
|
+
const agents = opts.agents ?? detectAgents(repoPath, exec);
|
|
191
|
+
const results = [];
|
|
192
|
+
for (const agent of agents) {
|
|
193
|
+
if (agent === "claude") {
|
|
194
|
+
if (commandAvailable(exec, "claude", repoPath)) {
|
|
195
|
+
results.push(writeViaClaudeCli(repoPath, dryRun, exec));
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
const r = upsertJsonAdapter(repoPath, MCP_JSON_SPEC, dryRun, now);
|
|
199
|
+
results.push({ agent: "claude", ...r });
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
else if (agent === "opencode") {
|
|
203
|
+
const r = upsertJsonAdapter(repoPath, OPENCODE_JSON_SPEC, dryRun, now);
|
|
204
|
+
results.push({ agent: "opencode", ...r });
|
|
205
|
+
}
|
|
206
|
+
else if (agent === "cursor") {
|
|
207
|
+
const r = upsertJsonAdapter(repoPath, CURSOR_JSON_SPEC, dryRun, now);
|
|
208
|
+
results.push({ agent: "cursor", ...r });
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return results;
|
|
212
|
+
}
|
|
213
|
+
/** One line per adapter result, for `init`'s stderr summary. */
|
|
214
|
+
export function formatAdapterResult(r) {
|
|
215
|
+
const verb = r.action === "created" ? "wrote" :
|
|
216
|
+
r.action === "updated" ? "updated" :
|
|
217
|
+
r.action === "unchanged" ? "unchanged" :
|
|
218
|
+
r.action === "dry-run" ? "[dry-run]" :
|
|
219
|
+
"ERROR";
|
|
220
|
+
const backup = r.backupPath ? ` (backup: ${r.backupPath})` : "";
|
|
221
|
+
return `reposkein: [${r.agent}] ${verb} — ${r.message}${backup}`;
|
|
222
|
+
}
|
|
223
|
+
//# sourceMappingURL=agentAdapters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentAdapters.js","sourceRoot":"","sources":["../../src/cli/agentAdapters.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;+DAiB+D;AAE/D,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC3F,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGnD,MAAM,CAAC,MAAM,aAAa,GAAuB,CAAC,QAAQ,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;AA2BlF,MAAM,CAAC,MAAM,WAAW,GAAS,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;IACnD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,YAAY,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;QAC/G,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;IAC3C,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,CAAC,GAAG,GAAgG,CAAC;QAC3G,OAAO;YACL,MAAM,EAAE,OAAO,CAAC,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YACnD,MAAM,EAAE,CAAC,CAAC,MAAM,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CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAChE,OAAO,eAAe,CAAC,CAAC,KAAK,KAAK,IAAI,MAAM,CAAC,CAAC,OAAO,GAAG,MAAM,EAAE,CAAC;AACnE,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** Dependency-free ANSI styling for `reposkein-mcp stats` — raw escape codes,
|
|
2
|
+
* no chalk/picocolors. Auto-disables when stdout isn't a TTY or `NO_COLOR`
|
|
3
|
+
* is set (https://no-color.org), per the zero-infra/deterministic-tooling
|
|
4
|
+
* convention: never assume a terminal, never require a dependency for a
|
|
5
|
+
* cosmetic feature.
|
|
6
|
+
*
|
|
7
|
+
* Colors: teal `#2DD4BF` ≈ ANSI 256 color 44 (`38;5;44`), amber ≈ 256 color
|
|
8
|
+
* 214 (`38;5;214`) — same palette as the project's README banners. Falls
|
|
9
|
+
* back to the portable 16-color codes (36 cyan, 33 yellow) is intentionally
|
|
10
|
+
* NOT done: 256-color support is effectively universal on anything that
|
|
11
|
+
* reports `isTTY`, and matching the brand hex matters more here than
|
|
12
|
+
* supporting truly ancient terminals for a purely cosmetic CLI report. */
|
|
13
|
+
export declare function colorEnabled(stream?: {
|
|
14
|
+
isTTY?: boolean;
|
|
15
|
+
}, env?: NodeJS.ProcessEnv): boolean;
|
|
16
|
+
export interface Styler {
|
|
17
|
+
teal(s: string): string;
|
|
18
|
+
amber(s: string): string;
|
|
19
|
+
bold(s: string): string;
|
|
20
|
+
dim(s: string): string;
|
|
21
|
+
}
|
|
22
|
+
/** Returns the styling functions to use, given whether color is enabled —
|
|
23
|
+
* callers pass `colorEnabled()`'s result so this stays pure/testable. */
|
|
24
|
+
export declare function styler(enabled: boolean): Styler;
|
package/dist/cli/ansi.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** Dependency-free ANSI styling for `reposkein-mcp stats` — raw escape codes,
|
|
2
|
+
* no chalk/picocolors. Auto-disables when stdout isn't a TTY or `NO_COLOR`
|
|
3
|
+
* is set (https://no-color.org), per the zero-infra/deterministic-tooling
|
|
4
|
+
* convention: never assume a terminal, never require a dependency for a
|
|
5
|
+
* cosmetic feature.
|
|
6
|
+
*
|
|
7
|
+
* Colors: teal `#2DD4BF` ≈ ANSI 256 color 44 (`38;5;44`), amber ≈ 256 color
|
|
8
|
+
* 214 (`38;5;214`) — same palette as the project's README banners. Falls
|
|
9
|
+
* back to the portable 16-color codes (36 cyan, 33 yellow) is intentionally
|
|
10
|
+
* NOT done: 256-color support is effectively universal on anything that
|
|
11
|
+
* reports `isTTY`, and matching the brand hex matters more here than
|
|
12
|
+
* supporting truly ancient terminals for a purely cosmetic CLI report. */
|
|
13
|
+
const RESET = "\x1b[0m";
|
|
14
|
+
const BOLD = "\x1b[1m";
|
|
15
|
+
const DIM = "\x1b[2m";
|
|
16
|
+
const TEAL = "\x1b[38;5;44m";
|
|
17
|
+
const AMBER = "\x1b[38;5;214m";
|
|
18
|
+
export function colorEnabled(stream = process.stdout, env = process.env) {
|
|
19
|
+
if (env.NO_COLOR !== undefined)
|
|
20
|
+
return false;
|
|
21
|
+
return !!stream.isTTY;
|
|
22
|
+
}
|
|
23
|
+
const identity = {
|
|
24
|
+
teal: (s) => s,
|
|
25
|
+
amber: (s) => s,
|
|
26
|
+
bold: (s) => s,
|
|
27
|
+
dim: (s) => s,
|
|
28
|
+
};
|
|
29
|
+
const styled = {
|
|
30
|
+
teal: (s) => `${TEAL}${s}${RESET}`,
|
|
31
|
+
amber: (s) => `${AMBER}${s}${RESET}`,
|
|
32
|
+
bold: (s) => `${BOLD}${s}${RESET}`,
|
|
33
|
+
dim: (s) => `${DIM}${s}${RESET}`,
|
|
34
|
+
};
|
|
35
|
+
/** Returns the styling functions to use, given whether color is enabled —
|
|
36
|
+
* callers pass `colorEnabled()`'s result so this stays pure/testable. */
|
|
37
|
+
export function styler(enabled) {
|
|
38
|
+
return enabled ? styled : identity;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMapp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AAC,OAAgB;IACrC,OAAO,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC;AACrC,CAAC"}
|
package/dist/cli/doctor.d.ts
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
export interface DoctorPathResolution {
|
|
2
|
+
path: string;
|
|
3
|
+
/** Set when walk-down found 2+ candidate repos and neither an explicit
|
|
4
|
+
* path nor REPOSKEIN_REPO_PATH picked one — `path` falls back to `cwd`
|
|
5
|
+
* in this case so the caller can still print a real (failing) report. */
|
|
6
|
+
error?: string;
|
|
7
|
+
}
|
|
8
|
+
/** Resolves the repo path for `reposkein-mcp doctor [path]`: explicit arg >
|
|
9
|
+
* REPOSKEIN_REPO_PATH > walk-up (nearest ancestor with .reposkein/) >
|
|
10
|
+
* walk-down (workspace mode). Verifies doctor works from a subdirectory
|
|
11
|
+
* cwd — the common case of running it somewhere other than the repo root. */
|
|
12
|
+
export declare function resolveDoctorRepoPath(explicitPath: string | undefined, cwd: string, envRepoPath: string | undefined): DoctorPathResolution;
|
|
1
13
|
export interface Check {
|
|
2
14
|
id: string;
|
|
3
15
|
label: string;
|
|
@@ -15,5 +27,25 @@ export interface DoctorReport {
|
|
|
15
27
|
* Does NOT check MCP host registration — a CLI can't see that; the
|
|
16
28
|
* reposkein-setup skill verifies reachability via a probe tool call. */
|
|
17
29
|
export declare function runChecks(repoPath: string): Promise<DoctorReport>;
|
|
18
|
-
/**
|
|
19
|
-
|
|
30
|
+
/** Check ids that `doctor --ci` treats as build-breaking even though they're
|
|
31
|
+
* non-critical for interactive use (degrade gracefully for a human at the
|
|
32
|
+
* keyboard, but should fail a CI job so drift gets caught before it's
|
|
33
|
+
* merged): missing/foreign git hooks, a stale committed graph, and an
|
|
34
|
+
* unsplit legacy `summaries.jsonl` (see docs/INSTALL.md §4.2 — every branch
|
|
35
|
+
* that writes a summary would conflict on it). */
|
|
36
|
+
export declare const CI_FAIL_IDS: Set<string>;
|
|
37
|
+
/** Checks (by id) that `doctor --ci` additionally fails on, beyond the
|
|
38
|
+
* normal critical-check gate. */
|
|
39
|
+
export declare function ciFailingChecks(report: DoctorReport): Check[];
|
|
40
|
+
export declare function renderDoctorReport(report: DoctorReport): string;
|
|
41
|
+
export interface RunDoctorOptions {
|
|
42
|
+
json?: boolean;
|
|
43
|
+
/** `doctor --ci`: additionally fail (non-zero exit) when any CI_FAIL_IDS
|
|
44
|
+
* check is non-ok, even though those checks are non-critical for
|
|
45
|
+
* interactive use. Doesn't change what's printed — only the exit code. */
|
|
46
|
+
ci?: boolean;
|
|
47
|
+
}
|
|
48
|
+
/** Entry point for `reposkein-mcp doctor [path] [--json] [--ci]`. Returns the
|
|
49
|
+
* process exit code. Accepts a bare boolean for `json` for backwards
|
|
50
|
+
* compatibility with the pre-`--ci` call signature. */
|
|
51
|
+
export declare function runDoctor(repoPath?: string, opts?: RunDoctorOptions | boolean): Promise<number>;
|