supracortex 0.0.0-stage → 0.2.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.
Files changed (161) hide show
  1. package/COMPATIBILITY.md +171 -0
  2. package/INSTALL.md +229 -0
  3. package/LICENSE +21 -0
  4. package/MCP_PROTOCOL.md +100 -0
  5. package/README.md +275 -2
  6. package/SECURITY.md +187 -0
  7. package/dist/api.js +11840 -0
  8. package/dist/cli.js +18625 -0
  9. package/dist/mcp.js +11508 -0
  10. package/dist/opencode-v2.js +11299 -0
  11. package/dist/opencode.js +21772 -0
  12. package/dist/pi-extension.js +28654 -0
  13. package/dist/protocol.js +699 -0
  14. package/dist/types/packages/core/src/cache/cache-key.d.ts +11 -0
  15. package/dist/types/packages/core/src/cache/context-cache.d.ts +51 -0
  16. package/dist/types/packages/core/src/cache/invalidation.d.ts +8 -0
  17. package/dist/types/packages/core/src/capabilities/health.d.ts +54 -0
  18. package/dist/types/packages/core/src/capabilities/web.d.ts +23 -0
  19. package/dist/types/packages/core/src/config-files.d.ts +34 -0
  20. package/dist/types/packages/core/src/config.d.ts +322 -0
  21. package/dist/types/packages/core/src/context/builder.d.ts +59 -0
  22. package/dist/types/packages/core/src/context/invalidation.d.ts +14 -0
  23. package/dist/types/packages/core/src/context/repository-indexer.d.ts +50 -0
  24. package/dist/types/packages/core/src/context/selector.d.ts +72 -0
  25. package/dist/types/packages/core/src/context/summaries.d.ts +25 -0
  26. package/dist/types/packages/core/src/context/token-budget.d.ts +43 -0
  27. package/dist/types/packages/core/src/context/wire-budget.d.ts +44 -0
  28. package/dist/types/packages/core/src/diagnostics/index.d.ts +95 -0
  29. package/dist/types/packages/core/src/engine.d.ts +433 -0
  30. package/dist/types/packages/core/src/events/normalizer.d.ts +4 -0
  31. package/dist/types/packages/core/src/events/store.d.ts +21 -0
  32. package/dist/types/packages/core/src/events/types.d.ts +18 -0
  33. package/dist/types/packages/core/src/graph/builder.d.ts +24 -0
  34. package/dist/types/packages/core/src/graph/extractor.d.ts +99 -0
  35. package/dist/types/packages/core/src/graph/query.d.ts +16 -0
  36. package/dist/types/packages/core/src/graph/schema.d.ts +20 -0
  37. package/dist/types/packages/core/src/graph/store.d.ts +15 -0
  38. package/dist/types/packages/core/src/importers/index.d.ts +17 -0
  39. package/dist/types/packages/core/src/index.d.ts +98 -0
  40. package/dist/types/packages/core/src/jev/budget.d.ts +19 -0
  41. package/dist/types/packages/core/src/jev/client.d.ts +111 -0
  42. package/dist/types/packages/core/src/jev/credentials.d.ts +59 -0
  43. package/dist/types/packages/core/src/jev/enrich.d.ts +95 -0
  44. package/dist/types/packages/core/src/jev/health.d.ts +48 -0
  45. package/dist/types/packages/core/src/jev/providers.d.ts +94 -0
  46. package/dist/types/packages/core/src/jev/questions.d.ts +50 -0
  47. package/dist/types/packages/core/src/jev/router.d.ts +95 -0
  48. package/dist/types/packages/core/src/jev/types.d.ts +149 -0
  49. package/dist/types/packages/core/src/jev/validate.d.ts +53 -0
  50. package/dist/types/packages/core/src/mcp/selector.d.ts +39 -0
  51. package/dist/types/packages/core/src/memory/compaction.d.ts +63 -0
  52. package/dist/types/packages/core/src/memory/manager.d.ts +123 -0
  53. package/dist/types/packages/core/src/memory/ranking.d.ts +75 -0
  54. package/dist/types/packages/core/src/memory/repository.d.ts +43 -0
  55. package/dist/types/packages/core/src/memory/retrieval.d.ts +46 -0
  56. package/dist/types/packages/core/src/memory/schemas.d.ts +59 -0
  57. package/dist/types/packages/core/src/memory/transitions.d.ts +27 -0
  58. package/dist/types/packages/core/src/memory/validation.d.ts +32 -0
  59. package/dist/types/packages/core/src/metrics/collector.d.ts +43 -0
  60. package/dist/types/packages/core/src/metrics/report.d.ts +15 -0
  61. package/dist/types/packages/core/src/metrics/session-prune.d.ts +65 -0
  62. package/dist/types/packages/core/src/metrics/token-estimator.d.ts +48 -0
  63. package/dist/types/packages/core/src/metrics/value/index.d.ts +10 -0
  64. package/dist/types/packages/core/src/metrics/value/report.d.ts +94 -0
  65. package/dist/types/packages/core/src/metrics/value/store.d.ts +49 -0
  66. package/dist/types/packages/core/src/metrics/value/types.d.ts +103 -0
  67. package/dist/types/packages/core/src/orchestration/duplicate-detector.d.ts +19 -0
  68. package/dist/types/packages/core/src/orchestration/ownership.d.ts +58 -0
  69. package/dist/types/packages/core/src/orchestration/parallel-safety.d.ts +23 -0
  70. package/dist/types/packages/core/src/orchestration/reconciler.d.ts +61 -0
  71. package/dist/types/packages/core/src/orchestration/scheduler.d.ts +12 -0
  72. package/dist/types/packages/core/src/orchestration/sweeper.d.ts +40 -0
  73. package/dist/types/packages/core/src/orchestration/task-graph.d.ts +11 -0
  74. package/dist/types/packages/core/src/provider-cache.d.ts +107 -0
  75. package/dist/types/packages/core/src/review-types.d.ts +58 -0
  76. package/dist/types/packages/core/src/skills/registry.d.ts +24 -0
  77. package/dist/types/packages/core/src/storage/file-lock.d.ts +54 -0
  78. package/dist/types/packages/core/src/storage/jsonl-store.d.ts +37 -0
  79. package/dist/types/packages/core/src/storage/migrate.d.ts +33 -0
  80. package/dist/types/packages/core/src/storage/migrations.d.ts +33 -0
  81. package/dist/types/packages/core/src/storage/runtime-gitignore.d.ts +10 -0
  82. package/dist/types/packages/core/src/storage/safe-path.d.ts +16 -0
  83. package/dist/types/packages/core/src/storage/sqlite-store.d.ts +86 -0
  84. package/dist/types/packages/core/src/storage/storage-adapter.d.ts +122 -0
  85. package/dist/types/packages/core/src/supraspace/graph.d.ts +18 -0
  86. package/dist/types/packages/core/src/supraspace/projector.d.ts +61 -0
  87. package/dist/types/packages/core/src/supraspace/store.d.ts +21 -0
  88. package/dist/types/packages/core/src/types.d.ts +768 -0
  89. package/dist/types/packages/core/src/vault/projector.d.ts +11 -0
  90. package/dist/types/packages/opencode/src/agent-wiring.d.ts +89 -0
  91. package/dist/types/packages/opencode/src/bounded-set.d.ts +13 -0
  92. package/dist/types/packages/opencode/src/cli-core.d.ts +296 -0
  93. package/dist/types/packages/opencode/src/config-loader.d.ts +31 -0
  94. package/dist/types/packages/opencode/src/connect.d.ts +16 -0
  95. package/dist/types/packages/opencode/src/feature-gate.d.ts +24 -0
  96. package/dist/types/packages/opencode/src/host-config.d.ts +135 -0
  97. package/dist/types/packages/opencode/src/index.d.ts +15 -0
  98. package/dist/types/packages/opencode/src/isolation.d.ts +32 -0
  99. package/dist/types/packages/opencode/src/lifecycle.d.ts +61 -0
  100. package/dist/types/packages/opencode/src/mcp-discovery.d.ts +23 -0
  101. package/dist/types/packages/opencode/src/packet-rendering.d.ts +46 -0
  102. package/dist/types/packages/opencode/src/plugin-v2.d.ts +74 -0
  103. package/dist/types/packages/opencode/src/plugin.d.ts +113 -0
  104. package/dist/types/packages/opencode/src/profile.d.ts +88 -0
  105. package/dist/types/packages/opencode/src/provider-cache-adapter.d.ts +39 -0
  106. package/dist/types/packages/opencode/src/provider-cli.d.ts +55 -0
  107. package/dist/types/packages/opencode/src/runtime.d.ts +28 -0
  108. package/dist/types/packages/opencode/src/shared.d.ts +48 -0
  109. package/dist/types/packages/opencode/src/skills-discovery.d.ts +21 -0
  110. package/dist/types/packages/opencode/src/tools/index.d.ts +35 -0
  111. package/dist/types/packages/pi/src/agents.d.ts +42 -0
  112. package/dist/types/packages/pi/src/brand.d.ts +53 -0
  113. package/dist/types/packages/pi/src/child-runner.d.ts +81 -0
  114. package/dist/types/packages/pi/src/commands.d.ts +23 -0
  115. package/dist/types/packages/pi/src/config.d.ts +165 -0
  116. package/dist/types/packages/pi/src/context.d.ts +33 -0
  117. package/dist/types/packages/pi/src/contracts.d.ts +236 -0
  118. package/dist/types/packages/pi/src/dashboard.d.ts +20 -0
  119. package/dist/types/packages/pi/src/extension.d.ts +18 -0
  120. package/dist/types/packages/pi/src/git.d.ts +9 -0
  121. package/dist/types/packages/pi/src/index.d.ts +19 -0
  122. package/dist/types/packages/pi/src/job-store.d.ts +29 -0
  123. package/dist/types/packages/pi/src/launch.d.ts +53 -0
  124. package/dist/types/packages/pi/src/log.d.ts +30 -0
  125. package/dist/types/packages/pi/src/models.d.ts +28 -0
  126. package/dist/types/packages/pi/src/provider-fetch.d.ts +13 -0
  127. package/dist/types/packages/pi/src/result-tool.d.ts +26 -0
  128. package/dist/types/packages/pi/src/service.d.ts +42 -0
  129. package/dist/types/packages/pi/src/supervisor.d.ts +140 -0
  130. package/dist/types/packages/pi/src/tools.d.ts +79 -0
  131. package/dist/types/packages/pi/src/usage.d.ts +70 -0
  132. package/dist/types/packages/tui/src/tui-v2.d.ts +3 -0
  133. package/dist/types/packages/tui/src/tui.d.ts +23 -0
  134. package/dist/types/src/api.d.ts +3 -0
  135. package/dist/types/src/mcp.d.ts +69 -0
  136. package/dist/types/src/opencode-v2.d.ts +1 -0
  137. package/dist/types/src/opencode.d.ts +2 -0
  138. package/dist/types/src/pi-extension.d.ts +2 -0
  139. package/dist/types/src/protocol.d.ts +7629 -0
  140. package/dist/types/src/version.d.ts +24 -0
  141. package/package.json +127 -4
  142. package/packages/tui/dist/tui-v2.js +94 -0
  143. package/packages/tui/dist/tui.js +129 -0
  144. package/packages/tui/package.json +19 -0
  145. package/scripts/launcher-common.sh +56 -0
  146. package/scripts/laya-env.sh +24 -0
  147. package/scripts/supracortex-mcp +12 -0
  148. package/templates/agent_guidance.md +11 -0
  149. package/templates/central-config.jsonc +25 -0
  150. package/templates/commands/cortex-compact.md +10 -0
  151. package/templates/commands/cortex-disable.md +10 -0
  152. package/templates/commands/cortex-doctor.md +10 -0
  153. package/templates/commands/cortex-enable.md +10 -0
  154. package/templates/commands/cortex-inspect.md +10 -0
  155. package/templates/commands/cortex-reset.md +16 -0
  156. package/templates/commands/cortex-status.md +10 -0
  157. package/templates/gitignore-entry.txt +3 -0
  158. package/templates/opencode-plugin-entry.jsonc +16 -0
  159. package/templates/pi/agents/explorer.md +17 -0
  160. package/templates/pi/agents/reviewer.md +15 -0
  161. package/templates/skills/supracortex/SKILL.md +64 -0
@@ -0,0 +1,171 @@
1
+ # Compatibility
2
+
3
+ This document records the environment SupraCortex was built against, the hosts
4
+ that have actually been exercised, and the API assumptions the adapters depend
5
+ on. Status is as of **2026-10-17**. If a host or dependency changes, the
6
+ compatibility suite is the first place a break should surface.
7
+
8
+ Verification levels used below:
9
+
10
+ - **Live-tested**: a real host session was run against this repository's build.
11
+ - **Wiring live-verified**: the real host binary accepted, listed, and removed
12
+ the server against this repository's build in an isolated config directory,
13
+ but a full model-driven session was not exercised.
14
+ - **Fixture/tarball-verified only**: config generation/merge/uninstall and the
15
+ packed MCP stdio server are covered by tests, but no live session of that host
16
+ was run.
17
+ - **Documented only**: wiring is documented and may have config fixtures; there
18
+ is no live-session verification claim.
19
+ - **Untested**: no verification claim.
20
+
21
+ ## Verified environment
22
+
23
+ | Component | Version | Notes |
24
+ |---|---|---|
25
+ | OpenCode | 1.18.32 | V1 plugin host (`opencode --version`) |
26
+ | `@opencode-ai/plugin` | 1.18.32 | V1 plugin + tool API (pinned in `package.json`) |
27
+ | `@opencode/plugin` | 2.0.16 | V2 plugin API (pinned in `package.json`) |
28
+ | `@opencode-ai/sdk` | 1.18.32 | Client used for git/MCP discovery (transitive) |
29
+ | Node.js | 22.23.1 | Built CLI + stdio MCP server; declared minimum is 22.6 |
30
+ | pnpm | 11.9.0 | Workspace manager; npm also works |
31
+ | MCP SDK | 1.29.0 | `@modelcontextprotocol/sdk` (pinned) |
32
+ | CI platforms | Ubuntu, macOS, Windows | Workflow matrix for typecheck, tests, and the tarball gate |
33
+
34
+ ## MCP toolset
35
+
36
+ MCP hosts receive the tools documented in [MCP_PROTOCOL.md](./MCP_PROTOCOL.md):
37
+ the stable `cortex_*` set plus the experimental graph, Jev, and capability
38
+ tools. The native OpenCode adapter is a **superset**: it adds lifecycle hooks and
39
+ orchestration tools (planning, file claims, cache validation, compaction, sweep,
40
+ metrics, SupraSpace sync, graph export).
41
+
42
+ Host capabilities are not identical. MCP is tools-only here: automatic context
43
+ injection, lifecycle hooks, usage observation, and other host-side integration
44
+ are available only where the adapter is supported. Do not assume equivalent
45
+ behavior across hosts.
46
+
47
+ ## Host status
48
+
49
+ | Host | Wiring | Status |
50
+ |---|---|---|
51
+ | OpenCode 1.18.32 (V1) | Native V1 plugin via `supracortex init` | **Live-tested on this machine** |
52
+ | OpenCode 2.0.16 (V2) | Native V2 plugin | **Fixture/tarball-verified only**; no separate live V2 session recorded here |
53
+ | Claude Code 2.1.283 | `supracortex connect claude` (user scope) or project `init` | **Wiring live-verified**: add/list/remove in an isolated `CLAUDE_CONFIG_DIR` reported `Connected`; full model session not exercised |
54
+ | Codex CLI 0.162.1 | `supracortex connect codex` (`~/.codex/config.toml`) or project `init` | **Wiring live-verified**: add/list/remove in an isolated `HOME`; `mcp list` does not health-check, so liveness is covered by the stdio handshake test |
55
+ | Pi | Bundled extension; adapter is experimental | **Fixture/tarball-verified only**; no live session here; the pinned upstream patch is not shipped |
56
+ | Cursor | `mcpServers` config fixture / custom target | **Documented only**; no live session |
57
+ | Gemini CLI | `mcpServers` config fixture (bare style) | **Documented only**; no live session |
58
+ | DeepSeek Harness | MCP stdio via custom target or `connect generic` snippet | **Untested** |
59
+ | Other MCP stdio clients | `connect generic` snippet or `--target name=path[:bare]` | **Documented only**; verify in your client |
60
+ | ChatGPT web | Local stdio server | **Unsupported**; a browser session cannot launch a local stdio MCP server |
61
+
62
+ "Fixture/tarball-verified" means the generated configuration is tested for
63
+ create/merge/uninstall and the MCP server is tested over real stdio from the
64
+ packed artifact. It does not assert that the vendor's current client was run
65
+ against it.
66
+
67
+ ## OpenCode version matrix
68
+
69
+ | OpenCode | Status | Notes |
70
+ |---|---|---|
71
+ | 1.18.x | Yes (verified 1.18.32) | Target. `dispose`, `tool`, and `experimental.chat.system.transform` are present. |
72
+ | 1.17.x and earlier | Untested | Plugin API may differ; `doctor` reports mismatches. |
73
+ | 1.19+ | Expected | Uses hooks present in 1.18; re-run compatibility tests after upgrading. |
74
+
75
+ ## Node.js matrix
76
+
77
+ | Node | Status | Notes |
78
+ |---|---|---|
79
+ | >= 22.6 | Yes | Built CLI and stdio MCP server (`node:sqlite`). Running `.ts` sources directly needs Node's default type-stripping, enabled by default only on newer 22.x; 22.6–22.17 need `--experimental-strip-types` (the MCP source fallback passes it). |
80
+ | 22.0–22.5 | Partial | `node:sqlite` may need a flag. The JSONL driver is unaffected. |
81
+ | < 22 | No | Required built-ins are unavailable. |
82
+
83
+ ## Windows and shell support
84
+
85
+ The core, CLI, and stdio MCP server run on Node.js and are designed for macOS,
86
+ Linux, and Windows. The compatibility CI matrix runs typecheck and tests on
87
+ Ubuntu, macOS, and Windows, and the packed-tarball gate exercises the Node MCP
88
+ entrypoint on all three.
89
+
90
+ The `supracortex-mcp` launcher is a **POSIX bash script** and is not supported
91
+ on Windows. On Windows, invoke the Node entrypoint:
92
+
93
+ ```powershell
94
+ node C:\path\to\supracortex\dist\cli.js mcp
95
+ node C:\path\to\supracortex\dist\cli.js init --yes
96
+ node C:\path\to\supracortex\dist\cli.js doctor
97
+ ```
98
+
99
+ For an installed package use
100
+ `node node_modules\supracortex\dist\cli.js ...`. Bash, Zsh, Fish, PowerShell,
101
+ and CMD can invoke the Node CLI; unusual shells are not claimed as verified.
102
+ Host applications remain responsible for their own platform support.
103
+
104
+ ## Recorded API assumptions
105
+
106
+ These were verified by inspecting installed type definitions and docs.
107
+
108
+ ### Plugin API (`@opencode-ai/plugin`)
109
+
110
+ - A plugin is `(input, options?) => Promise<Hooks>`, exported as a named export.
111
+ `PluginInput = { client, project, directory, worktree, serverUrl, $,
112
+ experimental_workspace }`.
113
+ - `Hooks` includes `dispose()`, `event`, `config`, `tool`, `chat.message`,
114
+ `chat.params`, `chat.headers`, `permission.ask`, `command.execute.before`,
115
+ `tool.execute.before`, `tool.execute.after`, `shell.env`, and experimental
116
+ hooks including `experimental.chat.system.transform`.
117
+ - `dispose()` exists and is used to flush metrics. There is no documented
118
+ hot-unload; full module unload requires a new session.
119
+ - Tools use `tool()` with zod argument shapes. `ToolContext` supplies
120
+ `sessionID`, `messageID`, `agent`, `directory`, `worktree`, `abort`,
121
+ `metadata()`, and `ask()`.
122
+
123
+ ### Commands
124
+
125
+ OpenCode does not support plugin-registered commands. Commands are markdown
126
+ files in `.opencode/commands/` (project) or
127
+ `~/.config/opencode/commands/` (global), with frontmatter and template features.
128
+ This project installs its slash commands as markdown files that shell out to the
129
+ CLI.
130
+
131
+ ### Plugin load locations
132
+
133
+ - Project: `.opencode/plugins/`. Global: `~/.config/opencode/plugins/`.
134
+ - `supracortex init` writes its project loader to
135
+ `.opencode/plugins/supracortex.ts`; it does not modify unrelated plugin or
136
+ agent files.
137
+
138
+ ### SDK client (`@opencode-ai/sdk`)
139
+
140
+ - Namespaces used: `find.{text,files,symbols}`, `file.{list,read,status}`,
141
+ `mcp.status`, `vcs.*`, `config`, `session`, `project`, `command.list`.
142
+ - MCP discovery uses `client.mcp.status()`; the response shape is normalized
143
+ defensively (array, `{servers:[]}`, or a name→server map).
144
+
145
+ ## Behaviors that depend on optional runtime support
146
+
147
+ | Behavior | Requires | Fallback |
148
+ |---|---|---|
149
+ | Git-changed-file bias in context | `$` shell + git available | Omitted; retrieval still works. |
150
+ | MCP recommendations | `client.mcp.status()` present | Empty recommendation set. |
151
+ | Automatic prompt injection | OpenCode experimental message/system transform hooks and `integration.automaticContextPreparation` | No automatic packet; tools remain callable. |
152
+ | SQLite driver | `node:sqlite` (or `bun:sqlite` on Bun) | JSONL is the default. A configured SQLite store that cannot open surfaces an error instead of switching drivers. |
153
+ | Full module unload on disable | Not available in OpenCode 1.18.x | Feature gate makes it inert; a new session fully unloads. |
154
+ | Code-graph automatic hints | Explicit graph rebuild + `graph.automaticContext: true` | Graph tools still work explicitly; retrieval uses file/memory ranking. |
155
+
156
+ ## Not implemented and not claimed
157
+
158
+ - **Provider-level prompt caching** (for example Anthropic cache-control) is not
159
+ implemented. Only local summary/context caching exists, and it is never
160
+ labelled as a provider cache hit.
161
+ - **Exact provider billing amounts.** The host does not surface per-request
162
+ billed usage to the adapter, so token figures are local estimates.
163
+ - **True hot-unload** of the OpenCode plugin module from a running process is not
164
+ supported by the 1.18.x lifecycle.
165
+ - **Periodic/timer sweeps.** OpenCode exposes no timer hook, so the staleness
166
+ sweep runs opportunistically (engine init, `session.idle`, `session.deleted`)
167
+ and on demand. It is idempotent.
168
+ - **ChatGPT web or any browser-only MCP client.** Local stdio cannot be launched
169
+ from a web session.
170
+ - **Unverified host parity.** Supported hosts and their verification level are
171
+ the table above; anything not listed is documented-only or untested.
package/INSTALL.md ADDED
@@ -0,0 +1,229 @@
1
+ # SupraCortex — Install tutorial
2
+
3
+ A short, copy-paste guide for installing SupraCortex as an MCP server and CLI.
4
+ For architecture, host status, and the full tool contract see
5
+ [README.md](./README.md), [COMPATIBILITY.md](./COMPATIBILITY.md), and
6
+ [MCP_PROTOCOL.md](./MCP_PROTOCOL.md).
7
+
8
+ SupraCortex is designed for **MCP stdio clients**; verified and unverified hosts
9
+ are listed in the README support matrix. You do **not** need OpenCode to use the
10
+ MCP server. The OpenCode adapter is an optional extra that adds native tools and
11
+ lifecycle hooks.
12
+
13
+ ---
14
+
15
+ ## 0. Prerequisites
16
+
17
+ - **Node.js >= 22.6** (declared in `package.json`) for the CLI and stdio MCP
18
+ server. Check with:
19
+ ```bash
20
+ node --version
21
+ ```
22
+ - **npm** (bundled with Node) for the packaged install. `pnpm` is only needed
23
+ when working from a source checkout.
24
+
25
+ ---
26
+
27
+ ## 1. Install the CLI
28
+
29
+ Global install (recommended if you want `supracortex` on your PATH):
30
+
31
+ ```bash
32
+ npm install -g supracortex
33
+ supracortex --version
34
+ ```
35
+
36
+ Local install (use `npx` or `node_modules/.bin`):
37
+
38
+ ```bash
39
+ npm install supracortex
40
+ npx supracortex --version
41
+ ```
42
+
43
+ From a source checkout, build once and use the Node entrypoint:
44
+
45
+ ```bash
46
+ cd /path/to/supracortex
47
+ pnpm install
48
+ pnpm run build
49
+ node dist/cli.js --version
50
+ ```
51
+
52
+ The package ships two entry points: the `supracortex` CLI
53
+ (`dist/cli.js`) and the `supracortex-mcp` stdio shim. They resolve the project
54
+ root the same way, so hosts can use either.
55
+
56
+ ---
57
+
58
+ ## 2. Wire the project
59
+
60
+ Run this inside each project you want SupraCortex to remember:
61
+
62
+ ```bash
63
+ cd /path/to/your/project
64
+ supracortex init --yes
65
+ ```
66
+
67
+ - Without `--yes`, `init` prints a **plan only** and changes no files.
68
+ - With `--yes`, it wires the project and detected hosts, writes the guidance it
69
+ owns, enables the project, and backfills the project index.
70
+ - Limit detection with `--agent claude` (repeatable; known values: `claude`,
71
+ `codex`, `cursor`, `gemini`, `opencode`, `pi`).
72
+ - Wire another CLI on the standard `mcpServers` convention with
73
+ `--target name=relative/path.json[:bare]`. The `:bare` suffix omits the `type`
74
+ field for clients that reject it.
75
+
76
+ Runtime state is created lazily under `<project>/.supracortex/`. The generated
77
+ `.supracortex/.gitignore` keeps runtime memory, tasks, and cache out of Git
78
+ while leaving `config.jsonc`, `config.schema.json`, and `.supracortexignore`
79
+ visible. Settings stay central in `~/.config/supracortex/config.jsonc`; a
80
+ project file holds only store identity and a per-project kill switch.
81
+
82
+ ---
83
+
84
+ ## 3. Register the host
85
+
86
+ `init` handles project-local wiring. `connect` additionally registers the server
87
+ for a host once, at user/global scope:
88
+
89
+ ```bash
90
+ supracortex connect claude # Claude Code user scope
91
+ supracortex connect codex # Codex ~/.codex/config.toml marker block
92
+ supracortex connect generic # print an mcpServers JSON snippet
93
+ supracortex connect all # claude + codex
94
+ ```
95
+
96
+ Then **restart the host** so it loads the server. The server entry point is:
97
+
98
+ ```bash
99
+ supracortex mcp
100
+ ```
101
+
102
+ For a local install use `npx supracortex mcp` or the `supracortex-mcp` shim; on
103
+ Windows use the Node entrypoint. The server resolves its project root as
104
+ `SUPRACORTEX_ROOT ?? process.cwd()`, so the host must launch it with its working
105
+ directory set to the project root (or export `SUPRACORTEX_ROOT`). Launching it
106
+ elsewhere creates or reads a different `.supracortex/`.
107
+
108
+ For a host with no built-in adapter, paste the `connect generic` snippet into
109
+ its MCP configuration. This documents the wiring convention; it is not a claim
110
+ that the host has been live-tested.
111
+
112
+ | Host | Recommended wiring | Verification level |
113
+ |---|---|---|
114
+ | Claude Code | `supracortex connect claude` or project `init` | Wiring live-verified |
115
+ | Codex CLI | `supracortex connect codex` or project `init` | Wiring live-verified |
116
+ | OpenCode V1 | Project `init` installs the native V1 plugin | Live-tested |
117
+ | OpenCode V2 | Project `init` installs the native V2 plugin | Fixture/tarball-verified only |
118
+ | Cursor | `init` detection or a custom `--target` | Documented only |
119
+ | Gemini CLI | `init` detection or a bare `--target` | Documented only |
120
+ | Pi | Bundled experimental extension | Fixture/tarball-verified only |
121
+ | Other MCP stdio clients | `connect generic` snippet | Documented only |
122
+
123
+ See [COMPATIBILITY.md](./COMPATIBILITY.md) for the full status definitions and
124
+ recorded versions.
125
+
126
+ Disconnect with `supracortex disconnect claude`, `disconnect codex`, or
127
+ `disconnect all`.
128
+
129
+ ---
130
+
131
+ ## 4. Verify
132
+
133
+ From the project directory:
134
+
135
+ ```bash
136
+ supracortex doctor # health checks; exit 1 if a check fails
137
+ supracortex status # enabled state, storage, counts, last error
138
+ supracortex status --json # machine-readable
139
+ supracortex inspect "fix login" # preview the context packet, no model call
140
+ ```
141
+
142
+ Inside OpenCode, the equivalent slash commands are `/cortex-status`,
143
+ `/cortex-doctor`, and `/cortex-inspect <query>`. Other hosts call the MCP tools
144
+ directly (`cortex_status`, `cortex_context`, ...).
145
+
146
+ If `doctor` fails, read its first failing check; it names the file or setting it
147
+ could not validate. `supracortex doctor --fix` can repair the loader wiring.
148
+
149
+ ---
150
+
151
+ ## 5. Everyday commands
152
+
153
+ | Task | Command |
154
+ |---|---|
155
+ | Status | `supracortex status` |
156
+ | Health check | `supracortex doctor` |
157
+ | Enable this project | `supracortex enable` |
158
+ | Disable this project | `supracortex disable` |
159
+ | Preview context | `supracortex inspect "task"` |
160
+ | Compact memory | `supracortex compact` |
161
+ | Rebuild the experimental code graph | `supracortex code-graph rebuild --yes` |
162
+ | Clear generated data (keeps memory) | `supracortex reset all-generated --yes` |
163
+
164
+ Emergency kill switch (overrides configuration):
165
+
166
+ ```bash
167
+ export SUPRACORTEX_DISABLE=1 # macOS/Linux
168
+ $env:SUPRACORTEX_DISABLE = "1" # Windows PowerShell
169
+ ```
170
+
171
+ `SUPRACORTEX_ENABLE=1` is also honoured, but disable wins.
172
+
173
+ ---
174
+
175
+ ## 6. Uninstall
176
+
177
+ Uninstall is mutating, so it requires `--yes`. Data is kept by default:
178
+
179
+ ```bash
180
+ # Remove wiring, keep memory and configuration:
181
+ supracortex uninstall --yes
182
+
183
+ # Remove runtime data as well:
184
+ supracortex uninstall --yes --remove-data
185
+
186
+ # Global install:
187
+ supracortex uninstall --global --yes
188
+ ```
189
+
190
+ Uninstall removes only files it owns and reverts only its own marker block in
191
+ shared files. It does not touch your source files.
192
+
193
+ ---
194
+
195
+ ## 7. Windows
196
+
197
+ The `supracortex-mcp` launcher is a POSIX bash script and is **not supported on
198
+ Windows**. Use the Node entrypoint instead:
199
+
200
+ ```powershell
201
+ node C:\path\to\supracortex\dist\cli.js init --yes
202
+ node C:\path\to\supracortex\dist\cli.js connect generic
203
+ node C:\path\to\supracortex\dist\cli.js doctor
204
+ node C:\path\to\supracortex\dist\cli.js mcp
205
+ ```
206
+
207
+ For an installed package, replace the path with
208
+ `node_modules\supracortex\dist\cli.js`. The compatibility CI matrix exercises
209
+ the Node CLI and MCP transport on Windows.
210
+
211
+ ---
212
+
213
+ ## Gotchas
214
+
215
+ 1. **Restart the host** after install, connect, or enable/disable. A running
216
+ OpenCode session needs a new session to fully reload the plugin module.
217
+ 2. **Paths matter.** `supracortex init` records absolute paths for a source
218
+ checkout. If you move or rename the checkout, re-run `init --yes`.
219
+ 3. **One project root.** Every host that should share memory must launch
220
+ `supracortex mcp` with the same working directory (or the same
221
+ `SUPRACORTEX_ROOT`).
222
+ 4. **Global install is enabled everywhere by default.** Opt one project out
223
+ with `supracortex disable` inside it; `enable` removes the opt-out. Settings
224
+ themselves stay central.
225
+ 5. **SQLite is opt-in.** JSONL is the default. If `storage.driver` is set to
226
+ `"sqlite"` and the database cannot open, the engine reports an error rather
227
+ than silently switching stores.
228
+ 6. **No hot unload.** Disabling makes the adapter inert immediately; a new host
229
+ session completes the unload.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 supracortex contributors
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.
@@ -0,0 +1,100 @@
1
+ # SupraCortex MCP tool contract
2
+
3
+ The stdio adapter (`supracortex mcp` or the `supracortex-mcp` shim) exposes the
4
+ tools below. Protocol JSON is written to stdout; diagnostics are written only to
5
+ stderr. The toolset API version is `2.0.0`; it is distinct from the date-based
6
+ MCP protocol version negotiated by the SDK.
7
+
8
+ ## Stability tiers
9
+
10
+ | Tier | Tools |
11
+ |---|---|
12
+ | **STABLE** | `cortex_context`, `cortex_search`, `cortex_record`, `cortex_status`, `cortex_timeline`, `cortex_detail`, `cortex_handoff`, `cortex_resume`, `cortex_review`, `cortex_safety` |
13
+ | **EXPERIMENTAL** | `cortex_graph_status`, `cortex_graph_rebuild`, `cortex_graph_query`, `cortex_graph_path`, `cortex_graph_explain`, `cortex_graph_impact`, `cortex_jev_status`, `cortex_jev_review`, `cortex_capabilities` |
14
+
15
+ Stable tools are the supported contract. Experimental tools may change in shape
16
+ or behavior between releases; consumers should tolerate additive fields and pin
17
+ any integration that depends on their exact output.
18
+
19
+ The code-graph tools are experimental local navigation: they require an explicit
20
+ `cortex_graph_rebuild` before queries return a generation. Automatic graph hints
21
+ are off by default and require both a built generation and
22
+ `graph.automaticContext: true`.
23
+
24
+ ## Stable tools
25
+
26
+ | Tool | Purpose |
27
+ |---|---|
28
+ | `cortex_context` | Prepare a bounded, explained context packet for a task. Read-only and deterministic. |
29
+ | `cortex_search` | Search persistent memory for relevant entries. Read-only. |
30
+ | `cortex_record` | Record a verified memory entry or task outcome. Durable kinds require source references; secret-shaped content is redacted. |
31
+ | `cortex_status` | Report enabled state, storage, counts, and the last error. Read-only. |
32
+ | `cortex_timeline` | Return a bounded chronological window of structural events. Read-only. |
33
+ | `cortex_detail` | Show one structural event by id. Read-only. |
34
+ | `cortex_handoff` | Create a bounded handoff capsule with goal, work, risks, and next actions. |
35
+ | `cortex_resume` | Read a previously created handoff capsule. Read-only. |
36
+ | `cortex_review` | List candidates or move an entry through the review actions below. |
37
+ | `cortex_safety` | Report observed local evidence for changed files. It never runs git, tests, shells, or scanners. |
38
+
39
+ ## Inputs and output shape
40
+
41
+ - Inputs use strict schemas and are bounded per field and as a complete JSON
42
+ argument payload (**32,000 UTF-8 bytes**).
43
+ - `content[0]` is always a JSON text block containing the tool result. If an
44
+ advisory is present (for example the untrusted-data notice on
45
+ `cortex_context` / `cortex_search`), it is a separate trailing text item and
46
+ is never merged into the validated JSON payload.
47
+ - `structuredContent` carries the same JSON object as `content[0]`. A non-object
48
+ result is wrapped as `{ "value": ... }`.
49
+ - Text and `structuredContent` are each bounded to **48,000 UTF-8 bytes**. An
50
+ oversized result returns a small, valid truncation envelope
51
+ (`truncated`, `limitBytes`, `result`) rather than half-serialized JSON.
52
+ - Tool listings include strict input and output JSON schemas plus
53
+ read-only/destructive annotations where applicable. Output schemas are
54
+ advertised permissively so a host validating `structuredContent` cannot reject
55
+ a committed result; the server still validates strictly before returning.
56
+ - Disabled projects return `{ "disabled": true, "noop": true }` successfully and
57
+ perform no writes. Invalid input is a model-visible tool error.
58
+ - An abort signal observed before a mutating commit returns an error and does not
59
+ mutate storage.
60
+
61
+ The server advertises tools only: no resource, prompt, or completion capability
62
+ is exposed until it has a stable, bounded implementation.
63
+
64
+ ## `cortex_review` actions
65
+
66
+ | Action | Semantics |
67
+ |---|---|
68
+ | `list` | List entries by status (default `candidate`). Read-only. |
69
+ | `approve` | Verify every hashed file reference against the current index, then set the entry `active`. This is the activation step. |
70
+ | `edit` | Update content, confidence, or tags. Does not re-verify evidence. |
71
+ | `dispute` | Mark the entry `disputed` for contradiction review. |
72
+ | `invalidate` | Mark the entry `stale` explicitly because its evidence is no longer trusted. |
73
+ | `pin` | Add the `pinned` tag so retrieval keeps the entry prominent. |
74
+ | `suppress` | Set the entry to `forgotten` so it is no longer surfaced. |
75
+ | `purge` | Delete the entry. Destructive and irreversible. |
76
+ | `refresh-evidence` | Re-read current hashed file references, store the new hashes, set `lastVerifiedAt`, and clear `needsReverifyAt`. It never activates the entry. If any referenced file is missing, the action fails with the `missing` paths, changes nothing, and writes no audit row. |
77
+
78
+ Age-based re-verification sets `needsReverifyAt` without changing `status`.
79
+ `stale` means an evidence mismatch or explicit invalidation. The recovery order
80
+ is `refresh-evidence`, then `approve` when activation is intended.
81
+
82
+ `cortex_record` accepts an explicit verified memory or task outcome only;
83
+ candidate or imported text is not recorded as active memory through this
84
+ surface. Imported or candidate content never becomes active without an explicit
85
+ `approve`.
86
+
87
+ `cortex_safety` reports observed evidence only and never runs git, tests, shells,
88
+ or scanners.
89
+
90
+ ## Output guarantees
91
+
92
+ - A normal result is a single, schema-valid JSON object in `content[0]` and
93
+ `structuredContent`; optional advisory text is separate.
94
+ - Results never exceed the 48,000-byte cap; oversized results are replaced by a
95
+ valid truncation envelope.
96
+ - Unknown input fields are rejected rather than ignored.
97
+ - Tools annotated read-only do not mutate memory, tasks, or graph state.
98
+ Mutating tools either commit fully or return an error without committing when
99
+ aborted first.
100
+ - Disabled projects are a successful no-op, not an error.