@geohar/opencode-cribsheet 0.3.0-dev.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/LICENSE +21 -0
- package/README.md +104 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +376 -0
- package/dist/index.js.map +1 -0
- package/package.json +55 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) George Harker
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# @geohar/opencode-cribsheet
|
|
2
|
+
|
|
3
|
+
An [OpenCode](https://opencode.ai) plugin that brings **`crib`** (cribsheet —
|
|
4
|
+
persistent cross-session markdown memory + a code symbol index) to OpenCode: it
|
|
5
|
+
starts crib (supervised by
|
|
6
|
+
[`sharedserver`](https://github.com/georgeharker/sharedserver)), registers its
|
|
7
|
+
HTTP MCP endpoint, injects the reach-for-crib directive, and ships the `/crib`
|
|
8
|
+
recall command — and **stands down** when a combiner already serves crib.
|
|
9
|
+
|
|
10
|
+
It is the OpenCode counterpart of cribsheet's Claude Code plugin, and mirrors its
|
|
11
|
+
behaviour.
|
|
12
|
+
|
|
13
|
+
## What it does
|
|
14
|
+
|
|
15
|
+
1. **Stand-down switch.** If a combiner already serves crib, the plugin neither
|
|
16
|
+
registers a standalone MCP entry nor launches a backend (the combiner owns
|
|
17
|
+
crib's lifecycle):
|
|
18
|
+
- `MCP_COMBINER=1` — global switch.
|
|
19
|
+
- `MCP_COMBINER_SERVES_CRIBSHEET=0|1` — per-backend override (wins).
|
|
20
|
+
|
|
21
|
+
The directive and `/crib` command are injected **either way** — crib's tools
|
|
22
|
+
are present via the combiner too.
|
|
23
|
+
2. **Register.** Otherwise it injects `cribsheet` into OpenCode's `mcp` config as
|
|
24
|
+
a `type: "remote"` endpoint (default `http://127.0.0.1:7732/mcp`). A user-
|
|
25
|
+
defined entry is left untouched.
|
|
26
|
+
3. **Run one warm crib.** It drives `sharedserver`:
|
|
27
|
+
```
|
|
28
|
+
sharedserver use cribsheet --pid <opencode-pid> --grace-period 1h \
|
|
29
|
+
-- crib --mcp --http --host 127.0.0.1 --port 7732
|
|
30
|
+
```
|
|
31
|
+
`sharedserver` refcounts by PID, so one crib process is shared across clients
|
|
32
|
+
(OpenCode, Claude Code, Neovim) and outlives any single one. `unuse` on exit.
|
|
33
|
+
4. **Reach-for-crib directive.** Appended to the system prompt each session via
|
|
34
|
+
`experimental.chat.system.transform` — the analogue of the Claude Code plugin's
|
|
35
|
+
SessionStart `additionalContext`.
|
|
36
|
+
5. **`/crib` command.** Registered in OpenCode's `command` config, mirroring
|
|
37
|
+
cribsheet's `commands/crib.md`: recalls memory (`crib note apropos`) and the
|
|
38
|
+
code index (`crib code lookup`) for a topic, then summarizes.
|
|
39
|
+
|
|
40
|
+
## Install
|
|
41
|
+
|
|
42
|
+
Add it to your `opencode.json` `plugin` list:
|
|
43
|
+
|
|
44
|
+
```json
|
|
45
|
+
{
|
|
46
|
+
"plugin": [
|
|
47
|
+
"@geohar/opencode-cribsheet@latest"
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
With options (all optional — defaults shown):
|
|
53
|
+
|
|
54
|
+
```json
|
|
55
|
+
{
|
|
56
|
+
"plugin": [
|
|
57
|
+
["@geohar/opencode-cribsheet@latest", {
|
|
58
|
+
"port": 7732,
|
|
59
|
+
"host": "127.0.0.1",
|
|
60
|
+
"gracePeriod": "1h",
|
|
61
|
+
"manage": true,
|
|
62
|
+
"register": true,
|
|
63
|
+
"instructions": true,
|
|
64
|
+
"command": true,
|
|
65
|
+
"notify": true
|
|
66
|
+
}]
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Options
|
|
72
|
+
|
|
73
|
+
| option | default | meaning |
|
|
74
|
+
|---|---|---|
|
|
75
|
+
| `mcpName` | `"cribsheet"` | key under OpenCode's `mcp` config |
|
|
76
|
+
| `url` | `http://127.0.0.1:<port>/mcp` | MCP URL to register |
|
|
77
|
+
| `register` | `true` | register the endpoint with OpenCode |
|
|
78
|
+
| `instructions` | `true` | inject the reach-for-crib directive into the system prompt |
|
|
79
|
+
| `command` | `true` | register the `/crib` command |
|
|
80
|
+
| `manage` | `true` | launch/attach crib via sharedserver (`false` → register only) |
|
|
81
|
+
| `binary` | auto | path to `sharedserver` (`$SHAREDSERVER_BIN` also honoured) |
|
|
82
|
+
| `lockdir` | — | override `SHAREDSERVER_LOCKDIR` |
|
|
83
|
+
| `name` | `"cribsheet"` | sharedserver instance name |
|
|
84
|
+
| `gracePeriod` | `"1h"` | sharedserver grace period |
|
|
85
|
+
| `logFile` | — | capture crib output (`sharedserver --log-file`) |
|
|
86
|
+
| `crib` | `crib` on PATH | override the crib command (`$OPENCODE_CRIBSHEET_COMMAND`) |
|
|
87
|
+
| `checkout` | — | cribsheet checkout for `uv run --project` (`$OPENCODE_CRIBSHEET_CHECKOUT`) |
|
|
88
|
+
| `port` | `7732` | HTTP port crib serves on |
|
|
89
|
+
| `host` | `127.0.0.1` | HTTP host crib binds |
|
|
90
|
+
| `notify` | `true` | show TUI toasts for attach/health outcomes |
|
|
91
|
+
|
|
92
|
+
## Requirements
|
|
93
|
+
|
|
94
|
+
- [`sharedserver`](https://github.com/georgeharker/sharedserver) on `PATH`
|
|
95
|
+
(`cargo install sharedserver`) — unless `manage: false`.
|
|
96
|
+
- `crib` on `PATH` (install cribsheet), or a `checkout` + `uv`.
|
|
97
|
+
|
|
98
|
+
## Relationship to the other plugins
|
|
99
|
+
|
|
100
|
+
crib behind a **combiner** is served through
|
|
101
|
+
[`mcp-combiner`](https://github.com/georgeharker/mcp-companion); set
|
|
102
|
+
`MCP_COMBINER=1` (or run `mcp-combiner env-disable`) and this plugin stands down.
|
|
103
|
+
The Claude Code counterpart ships in the
|
|
104
|
+
[cribsheet](https://github.com/georgeharker/cribsheet) repo's marketplace.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAsSjD,QAAA,MAAM,eAAe,EAAE,MAoItB,CAAA;AAED,eAAe,eAAe,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
// OpenCode plugin: run the `crib` (cribsheet) memory + code-index MCP server via
|
|
2
|
+
// the `sharedserver` CLI, register its HTTP endpoint with OpenCode, inject the
|
|
3
|
+
// reach-for-crib directive, and ship the `/crib` recall command.
|
|
4
|
+
//
|
|
5
|
+
// This is the OpenCode counterpart of cribsheet's Claude Code plugin (a
|
|
6
|
+
// SessionStart shell hook + additionalContext + a /crib command). It mirrors that
|
|
7
|
+
// plugin's behaviour:
|
|
8
|
+
//
|
|
9
|
+
// 1. Stand-down switch — if a combiner already serves crib (global MCP_COMBINER,
|
|
10
|
+
// or the per-backend MCP_COMBINER_SERVES_CRIBSHEET override, which wins), do
|
|
11
|
+
// NOT register a standalone entry and do NOT launch a backend. The combiner
|
|
12
|
+
// owns crib's lifecycle. (Only the MCP registration + launch are gated — the
|
|
13
|
+
// directive and /crib command are injected either way, since crib's tools are
|
|
14
|
+
// present via the combiner too.)
|
|
15
|
+
// 2. Registration — inject a `type: "remote"` entry into OpenCode's `mcp` config
|
|
16
|
+
// via the `config` hook.
|
|
17
|
+
// 3. Process — drive `sharedserver use … -- crib --mcp --http …` so one warm crib
|
|
18
|
+
// is running and refcounted (shared across clients). `unuse` on exit.
|
|
19
|
+
// 4. Directive — append the reach-for-crib text to the system prompt each session
|
|
20
|
+
// via `experimental.chat.system.transform` (the analogue of Claude Code's
|
|
21
|
+
// SessionStart additionalContext).
|
|
22
|
+
// 5. /crib command — register an OpenCode command mirroring commands/crib.md.
|
|
23
|
+
import { spawnSync } from "node:child_process";
|
|
24
|
+
import { existsSync } from "node:fs";
|
|
25
|
+
import { homedir } from "node:os";
|
|
26
|
+
import { join } from "node:path";
|
|
27
|
+
const DEFAULT_PORT = 7732;
|
|
28
|
+
const DEFAULT_HOST = "127.0.0.1";
|
|
29
|
+
const DEFAULT_NAME = "cribsheet";
|
|
30
|
+
const DEFAULT_GRACE = "1h";
|
|
31
|
+
// ── the reach-for-crib directive ───────────────────────────────────
|
|
32
|
+
// Canonical source: cribsheet's CLAUDE.md.example (plugins/cribsheet/instructions.txt
|
|
33
|
+
// symlinks it). Bundled here so the published npm package is self-contained; keep in
|
|
34
|
+
// sync with that file.
|
|
35
|
+
const CRIB_DIRECTIVE = `# Memory (cribsheet)
|
|
36
|
+
|
|
37
|
+
- **Consult memory first.** Before answering about a project, topic, or past decision
|
|
38
|
+
— or exploring a codebase cold — \`lookup\`/\`apropos\` cribsheet first; the answer may
|
|
39
|
+
already be stored, and more current than reasoning from scratch.
|
|
40
|
+
- **Prefer the code index over grep/Read for understanding code.** The reflex to
|
|
41
|
+
\`grep\`/\`rg\`/\`Glob\` for a symbol — or to open a file to see what it does — is the cue
|
|
42
|
+
to reach for the index first; grep is the fallback when it misses, not the default.
|
|
43
|
+
- *find code by concept or name* → \`code_lookup "…in your own words"\`, **not**
|
|
44
|
+
\`grep -r\` (answers by intent + cross-file).
|
|
45
|
+
- *understand a symbol + who uses it* → \`code_dossier <symbol>\`, **not** reading
|
|
46
|
+
the whole file (one call: signature, description, callers/callees/references).
|
|
47
|
+
- *trace calls* → \`code_xref\` / \`code_graph\`, **not** chains of greps.
|
|
48
|
+
- *repo not indexed?* → that's the expected first step, not a dead end: **index it**
|
|
49
|
+
— \`project_index\` (indexes the source in one call), then look up.
|
|
50
|
+
- *which project?* → code tools act on ONE **current project**. Set it once
|
|
51
|
+
(\`use_project <name>\`, or it's inferred from \`project_path\` on your first code
|
|
52
|
+
call); to look up a **different** project, name it: \`project=<name>\` or
|
|
53
|
+
\`project_path=<a path in that repo>\`.
|
|
54
|
+
- **Persist durably.** When a durable fact emerges (a decision, convention, gotcha,
|
|
55
|
+
contract), \`store\` it — \`lookup\` first, \`append\`/\`edit\` over duplicating. **Name the
|
|
56
|
+
project it's ABOUT** (writes require an explicit \`project=\`/\`project_path=\`): a fact
|
|
57
|
+
about the repo you're in goes there, but cross-cutting/tooling knowledge belongs in
|
|
58
|
+
\`default\` or that tool's own project. Say which project it landed in.`;
|
|
59
|
+
// ── the /crib command template (mirrors commands/crib.md) ──────────
|
|
60
|
+
const CRIB_COMMAND_TEMPLATE = `Consult crib first — recall memory + the code index for "$ARGUMENTS" before reasoning from scratch.
|
|
61
|
+
|
|
62
|
+
If "$ARGUMENTS" is empty, ask the user what to recall and stop.
|
|
63
|
+
|
|
64
|
+
Memory — semantic recall, full matched sections:
|
|
65
|
+
|
|
66
|
+
!\`crib note apropos "$ARGUMENTS"\`
|
|
67
|
+
|
|
68
|
+
Code index — symbols by concept or name (skip if the topic is clearly not about code; a "project not indexed" reply just means there's nothing to add here):
|
|
69
|
+
|
|
70
|
+
!\`crib code lookup "$ARGUMENTS"\`
|
|
71
|
+
|
|
72
|
+
Then summarize what crib already knows about "$ARGUMENTS": lead with the notes' answer, fold in any relevant code symbols, and cite note/symbol names so the user can \`crib note read\` / \`crib code dossier\` to go deeper. If nothing relevant came back, say so plainly rather than guessing — that's a signal the knowledge isn't captured yet.`;
|
|
73
|
+
// ── stand-down switch (mirrors the CC hook's combiner_serves) ──────
|
|
74
|
+
function truthy(v) {
|
|
75
|
+
if (v == null)
|
|
76
|
+
return false;
|
|
77
|
+
return !["", "0", "false", "no", "off"].includes(v.trim().toLowerCase());
|
|
78
|
+
}
|
|
79
|
+
/** Does a combiner serve `name`? The per-backend `MCP_COMBINER_SERVES_<NAME>`
|
|
80
|
+
* override wins over the global `MCP_COMBINER` switch (presence, even empty,
|
|
81
|
+
* counts as an override — matching the CC hook's `+set` test). */
|
|
82
|
+
function combinerServes(name, env) {
|
|
83
|
+
const key = "MCP_COMBINER_SERVES_" + name.toUpperCase().replace(/[-\s]/g, "_");
|
|
84
|
+
if (key in env)
|
|
85
|
+
return truthy(env[key]);
|
|
86
|
+
return truthy(env.MCP_COMBINER);
|
|
87
|
+
}
|
|
88
|
+
// ── sharedserver binary resolution (ported) ────────────────────────
|
|
89
|
+
const CANDIDATE_BINARIES = [
|
|
90
|
+
"sharedserver",
|
|
91
|
+
join(homedir(), ".cargo", "bin", "sharedserver"),
|
|
92
|
+
join(homedir(), ".local", "bin", "sharedserver"),
|
|
93
|
+
"/usr/local/bin/sharedserver",
|
|
94
|
+
"/opt/homebrew/bin/sharedserver",
|
|
95
|
+
];
|
|
96
|
+
function resolveBinary(override, env) {
|
|
97
|
+
const candidates = [override, env.SHAREDSERVER_BIN, ...CANDIDATE_BINARIES].filter((v) => typeof v === "string" && v.length > 0);
|
|
98
|
+
for (const candidate of candidates) {
|
|
99
|
+
if (candidate.includes("/")) {
|
|
100
|
+
if (existsSync(candidate))
|
|
101
|
+
return candidate;
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
const probe = spawnSync(candidate, ["--version"], { stdio: "ignore", env });
|
|
105
|
+
if (probe.status === 0)
|
|
106
|
+
return candidate;
|
|
107
|
+
}
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
function onPath(cmd, env) {
|
|
111
|
+
return spawnSync(cmd, ["--version"], { stdio: "ignore", env }).status === 0;
|
|
112
|
+
}
|
|
113
|
+
function splitArgs(value) {
|
|
114
|
+
if (!value)
|
|
115
|
+
return [];
|
|
116
|
+
return value.split(/\s+/).filter((s) => s.length > 0);
|
|
117
|
+
}
|
|
118
|
+
/** Resolve how to invoke crib: explicit option → env command → `crib` on PATH →
|
|
119
|
+
* `uv run --project <checkout> crib`. */
|
|
120
|
+
function resolveCrib(opts, env) {
|
|
121
|
+
const extra = opts.args ?? [];
|
|
122
|
+
if (opts.crib)
|
|
123
|
+
return { cmd: opts.crib, args: extra };
|
|
124
|
+
if (env.OPENCODE_CRIBSHEET_COMMAND) {
|
|
125
|
+
return {
|
|
126
|
+
cmd: env.OPENCODE_CRIBSHEET_COMMAND,
|
|
127
|
+
args: [...splitArgs(env.OPENCODE_CRIBSHEET_ARGS), ...extra],
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
if (onPath("crib", env))
|
|
131
|
+
return { cmd: "crib", args: extra };
|
|
132
|
+
const checkout = opts.checkout ?? env.OPENCODE_CRIBSHEET_CHECKOUT;
|
|
133
|
+
if (checkout && onPath("uv", env)) {
|
|
134
|
+
return { cmd: "uv", args: ["run", "--project", checkout, "crib", ...extra] };
|
|
135
|
+
}
|
|
136
|
+
return undefined;
|
|
137
|
+
}
|
|
138
|
+
function preCheck(binary, name, env) {
|
|
139
|
+
const result = spawnSync(binary, ["check", name], { stdio: "ignore", env });
|
|
140
|
+
switch (result.status) {
|
|
141
|
+
case 0: return "active";
|
|
142
|
+
case 1: return "grace";
|
|
143
|
+
case 2: return "stopped";
|
|
144
|
+
default: return "unknown";
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
function readServerInfo(binary, name, env) {
|
|
148
|
+
const result = spawnSync(binary, ["info", name, "--json"], { env });
|
|
149
|
+
if (result.status !== 0)
|
|
150
|
+
return undefined;
|
|
151
|
+
try {
|
|
152
|
+
return JSON.parse(result.stdout.toString());
|
|
153
|
+
}
|
|
154
|
+
catch {
|
|
155
|
+
return undefined;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
function isPidAlive(pid) {
|
|
159
|
+
try {
|
|
160
|
+
process.kill(pid, 0);
|
|
161
|
+
return true;
|
|
162
|
+
}
|
|
163
|
+
catch {
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
const attached = [];
|
|
168
|
+
let cleanupInstalled = false;
|
|
169
|
+
function installCleanup() {
|
|
170
|
+
if (cleanupInstalled)
|
|
171
|
+
return;
|
|
172
|
+
cleanupInstalled = true;
|
|
173
|
+
const drain = () => {
|
|
174
|
+
while (attached.length) {
|
|
175
|
+
const s = attached.pop();
|
|
176
|
+
spawnSync(s.binary, ["unuse", s.name, "--pid", String(process.pid)], {
|
|
177
|
+
stdio: "ignore",
|
|
178
|
+
env: s.env,
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
process.on("exit", drain);
|
|
183
|
+
for (const sig of ["SIGINT", "SIGTERM", "SIGHUP"]) {
|
|
184
|
+
process.on(sig, () => {
|
|
185
|
+
drain();
|
|
186
|
+
process.kill(process.pid, sig);
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
// ── health checks (ported) ─────────────────────────────────────────
|
|
191
|
+
function scheduleProcessHealthCheck(binary, name, env, log, toast, delayMs) {
|
|
192
|
+
setTimeout(() => {
|
|
193
|
+
const info = readServerInfo(binary, name, env);
|
|
194
|
+
if (!info) {
|
|
195
|
+
log("warn", `${name}: process health check returned no data`);
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
if (info.state && info.state !== "active") {
|
|
199
|
+
const msg = `${name}: not active after start (state: ${info.state})`;
|
|
200
|
+
log("error", msg);
|
|
201
|
+
toast("error", msg);
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
if (info.pid && !isPidAlive(info.pid)) {
|
|
205
|
+
const msg = `${name}: PID ${info.pid} died shortly after start`;
|
|
206
|
+
log("error", msg);
|
|
207
|
+
toast("error", msg);
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
log("info", `${name}: process healthy (pid=${info.pid}, state=${info.state})`);
|
|
211
|
+
}, delayMs).unref();
|
|
212
|
+
}
|
|
213
|
+
function scheduleMcpHealthCheck(client, mcpName, log, toast, delayMs) {
|
|
214
|
+
setTimeout(() => {
|
|
215
|
+
client.mcp
|
|
216
|
+
.status()
|
|
217
|
+
.then((res) => {
|
|
218
|
+
const st = res.data?.[mcpName];
|
|
219
|
+
if (!st) {
|
|
220
|
+
log("warn", `${mcpName}: not present in OpenCode mcp status yet`);
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
switch (st.status) {
|
|
224
|
+
case "connected":
|
|
225
|
+
log("info", `${mcpName}: connected`);
|
|
226
|
+
toast("success", `${mcpName}: connected`);
|
|
227
|
+
break;
|
|
228
|
+
case "failed":
|
|
229
|
+
toast("error", `${mcpName}: failed — ${st.error ?? "unknown error"}`);
|
|
230
|
+
break;
|
|
231
|
+
case "needs_auth":
|
|
232
|
+
case "needs_client_registration":
|
|
233
|
+
toast("warning", `${mcpName}: ${st.status}`);
|
|
234
|
+
break;
|
|
235
|
+
default:
|
|
236
|
+
log("info", `${mcpName}: status ${st.status}`);
|
|
237
|
+
}
|
|
238
|
+
})
|
|
239
|
+
.catch((err) => {
|
|
240
|
+
log("warn", `${mcpName}: mcp status check failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
241
|
+
});
|
|
242
|
+
}, delayMs).unref();
|
|
243
|
+
}
|
|
244
|
+
// ── plugin ─────────────────────────────────────────────────────────
|
|
245
|
+
const CribsheetPlugin = async ({ client }, options) => {
|
|
246
|
+
const opts = (options ?? {});
|
|
247
|
+
const notify = opts.notify !== false;
|
|
248
|
+
const log = (level, message) => {
|
|
249
|
+
client.app.log({ body: { service: "cribsheet", level, message } }).catch(() => { });
|
|
250
|
+
};
|
|
251
|
+
const toast = (variant, message) => {
|
|
252
|
+
if (!notify)
|
|
253
|
+
return;
|
|
254
|
+
setTimeout(() => {
|
|
255
|
+
client.tui.showToast({ body: { title: "cribsheet", message, variant } }).catch(() => { });
|
|
256
|
+
}, 1500).unref();
|
|
257
|
+
};
|
|
258
|
+
const env = { ...process.env };
|
|
259
|
+
if (opts.lockdir)
|
|
260
|
+
env.SHAREDSERVER_LOCKDIR = opts.lockdir;
|
|
261
|
+
const port = opts.port ?? DEFAULT_PORT;
|
|
262
|
+
const host = opts.host ?? DEFAULT_HOST;
|
|
263
|
+
const mcpName = opts.mcpName ?? DEFAULT_NAME;
|
|
264
|
+
const name = opts.name ?? DEFAULT_NAME;
|
|
265
|
+
const register = opts.register !== false;
|
|
266
|
+
const wantInstructions = opts.instructions !== false;
|
|
267
|
+
const wantCommand = opts.command !== false;
|
|
268
|
+
const url = opts.url ?? `http://127.0.0.1:${port}/mcp`;
|
|
269
|
+
const served = combinerServes(mcpName, env);
|
|
270
|
+
// The config hook: MCP registration (gated by the stand-down switch) plus the
|
|
271
|
+
// /crib command (always — crib's tools are present via the combiner too).
|
|
272
|
+
const configHook = async (cfg) => {
|
|
273
|
+
if (register) {
|
|
274
|
+
cfg.mcp ??= {};
|
|
275
|
+
if (cfg.mcp[mcpName]) {
|
|
276
|
+
log("info", `mcp "${mcpName}" already configured by the user; leaving as-is`);
|
|
277
|
+
}
|
|
278
|
+
else if (served) {
|
|
279
|
+
log("info", `a combiner serves "${mcpName}"; not registering a standalone entry`);
|
|
280
|
+
}
|
|
281
|
+
else {
|
|
282
|
+
cfg.mcp[mcpName] = { type: "remote", url, enabled: true };
|
|
283
|
+
log("info", `registered mcp "${mcpName}" → ${url}`);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
if (wantCommand) {
|
|
287
|
+
cfg.command ??= {};
|
|
288
|
+
if (cfg.command.crib) {
|
|
289
|
+
log("info", `command "/crib" already configured by the user; leaving as-is`);
|
|
290
|
+
}
|
|
291
|
+
else {
|
|
292
|
+
cfg.command.crib = {
|
|
293
|
+
template: CRIB_COMMAND_TEMPLATE,
|
|
294
|
+
description: "Consult crib first — recall memory + the code index for a topic",
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
// The directive: appended to the system prompt each session (analogue of the CC
|
|
300
|
+
// plugin's SessionStart additionalContext). Injected regardless of `served`.
|
|
301
|
+
const systemHook = async (_input, output) => {
|
|
302
|
+
if (!wantInstructions)
|
|
303
|
+
return;
|
|
304
|
+
output.system.push(CRIB_DIRECTIVE);
|
|
305
|
+
};
|
|
306
|
+
const hooks = {
|
|
307
|
+
config: configHook,
|
|
308
|
+
"experimental.chat.system.transform": systemHook,
|
|
309
|
+
};
|
|
310
|
+
// The process half — skipped when combiner-served or manage=false.
|
|
311
|
+
if (served) {
|
|
312
|
+
log("info", `a combiner serves "${mcpName}"; not launching a standalone backend`);
|
|
313
|
+
return hooks;
|
|
314
|
+
}
|
|
315
|
+
const manage = opts.manage !== false;
|
|
316
|
+
if (!manage) {
|
|
317
|
+
log("info", `manage=false; registering ${url} only (assuming crib is started elsewhere)`);
|
|
318
|
+
scheduleMcpHealthCheck(client, mcpName, log, toast, 5000);
|
|
319
|
+
return hooks;
|
|
320
|
+
}
|
|
321
|
+
const binary = resolveBinary(opts.binary, env);
|
|
322
|
+
if (!binary) {
|
|
323
|
+
const msg = "sharedserver binary not found; set `binary`/`$SHAREDSERVER_BIN`, or use manage:false";
|
|
324
|
+
log("error", msg);
|
|
325
|
+
toast("error", msg);
|
|
326
|
+
return hooks;
|
|
327
|
+
}
|
|
328
|
+
const crib = resolveCrib(opts, env);
|
|
329
|
+
if (!crib) {
|
|
330
|
+
const msg = "crib command not found; install cribsheet (so `crib` is on PATH), set " +
|
|
331
|
+
"`crib`/`checkout`, or $OPENCODE_CRIBSHEET_COMMAND / $OPENCODE_CRIBSHEET_CHECKOUT";
|
|
332
|
+
log("error", msg);
|
|
333
|
+
toast("error", msg);
|
|
334
|
+
return hooks;
|
|
335
|
+
}
|
|
336
|
+
// Assemble: crib [extra args] --mcp --http --host <host> --port <port>
|
|
337
|
+
const serve = ["--mcp", "--http", "--host", host, "--port", String(port)];
|
|
338
|
+
const wrapped = { cmd: crib.cmd, args: [...crib.args, ...serve] };
|
|
339
|
+
const useArgs = [
|
|
340
|
+
"use", name,
|
|
341
|
+
"--pid", String(process.pid),
|
|
342
|
+
"--grace-period", opts.gracePeriod ?? DEFAULT_GRACE,
|
|
343
|
+
"--metadata", `opencode-${process.pid}`,
|
|
344
|
+
];
|
|
345
|
+
if (opts.logFile)
|
|
346
|
+
useArgs.push("--log-file", opts.logFile);
|
|
347
|
+
useArgs.push("--", wrapped.cmd, ...wrapped.args);
|
|
348
|
+
installCleanup();
|
|
349
|
+
const pre = preCheck(binary, name, env);
|
|
350
|
+
const result = spawnSync(binary, useArgs, { stdio: "pipe", env });
|
|
351
|
+
if (result.error) {
|
|
352
|
+
const msg = `${name}: failed to spawn sharedserver (${result.error.message})`;
|
|
353
|
+
log("error", msg);
|
|
354
|
+
toast("error", msg);
|
|
355
|
+
return hooks;
|
|
356
|
+
}
|
|
357
|
+
if (result.status !== 0) {
|
|
358
|
+
const stderr = result.stderr?.toString().trim();
|
|
359
|
+
const msg = `${name}: sharedserver use exited ${result.status}${stderr ? ` (${stderr})` : ""}`;
|
|
360
|
+
log("error", msg);
|
|
361
|
+
toast("error", msg);
|
|
362
|
+
return hooks;
|
|
363
|
+
}
|
|
364
|
+
attached.push({ binary, name, env });
|
|
365
|
+
if (pre === "stopped" || pre === "unknown") {
|
|
366
|
+
log("info", `started crib "${name}" (${wrapped.cmd} ${wrapped.args.join(" ")})`);
|
|
367
|
+
}
|
|
368
|
+
else {
|
|
369
|
+
log("info", `attached to running crib "${name}" (was ${pre})`);
|
|
370
|
+
}
|
|
371
|
+
scheduleProcessHealthCheck(binary, name, env, log, toast, 2500);
|
|
372
|
+
scheduleMcpHealthCheck(client, mcpName, log, toast, 5000);
|
|
373
|
+
return hooks;
|
|
374
|
+
};
|
|
375
|
+
export default CribsheetPlugin;
|
|
376
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,+EAA+E;AAC/E,iEAAiE;AACjE,EAAE;AACF,wEAAwE;AACxE,kFAAkF;AAClF,sBAAsB;AACtB,EAAE;AACF,mFAAmF;AACnF,kFAAkF;AAClF,iFAAiF;AACjF,kFAAkF;AAClF,mFAAmF;AACnF,sCAAsC;AACtC,mFAAmF;AACnF,8BAA8B;AAC9B,oFAAoF;AACpF,2EAA2E;AAC3E,oFAAoF;AACpF,+EAA+E;AAC/E,wCAAwC;AACxC,gFAAgF;AAEhF,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAkDhC,MAAM,YAAY,GAAG,IAAI,CAAA;AACzB,MAAM,YAAY,GAAG,WAAW,CAAA;AAChC,MAAM,YAAY,GAAG,WAAW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}
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@geohar/opencode-cribsheet",
|
|
3
|
+
"version": "0.3.0-dev.0",
|
|
4
|
+
"description": "OpenCode plugin: run the crib (cribsheet) memory + code-index MCP server via sharedserver, register its endpoint, inject the reach-for-crib directive, and ship the /crib command. Stands down when a combiner already serves crib.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"README.md",
|
|
11
|
+
"LICENSE"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsc",
|
|
15
|
+
"clean": "rm -rf dist",
|
|
16
|
+
"typecheck": "tsc --noEmit",
|
|
17
|
+
"prepublishOnly": "npm run clean && npm run build"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"opencode",
|
|
21
|
+
"opencode-plugin",
|
|
22
|
+
"mcp",
|
|
23
|
+
"cribsheet",
|
|
24
|
+
"crib",
|
|
25
|
+
"memory",
|
|
26
|
+
"code-index",
|
|
27
|
+
"sharedserver",
|
|
28
|
+
"plugin"
|
|
29
|
+
],
|
|
30
|
+
"author": "George Harker <george@georgeharker.com>",
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "git+https://github.com/georgeharker/cribsheet.git",
|
|
35
|
+
"directory": "plugins/opencode-cribsheet"
|
|
36
|
+
},
|
|
37
|
+
"bugs": {
|
|
38
|
+
"url": "https://github.com/georgeharker/cribsheet/issues"
|
|
39
|
+
},
|
|
40
|
+
"homepage": "https://github.com/georgeharker/cribsheet/tree/main/plugins/opencode-cribsheet#readme",
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public"
|
|
43
|
+
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"@opencode-ai/plugin": ">=1.3.0"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@opencode-ai/plugin": "^1.3.0",
|
|
49
|
+
"@types/node": "^22.0.0",
|
|
50
|
+
"typescript": "^5.6.0"
|
|
51
|
+
},
|
|
52
|
+
"engines": {
|
|
53
|
+
"node": ">=18.0.0"
|
|
54
|
+
}
|
|
55
|
+
}
|