@atolis-hq/corum 0.1.0 → 0.1.6

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 CHANGED
@@ -1,223 +1,188 @@
1
- <div width="100%" align="center">
2
- <img src="assets/corum-logo.svg" width="120" height="120" /><br>
3
- <h1>Corum</h1>
4
- </div>
5
-
6
- Corum loads design graph files from disk into an in-memory graph and exposes the graph through MCP tools.
7
-
8
- ## Requirements
9
-
10
- - Node.js 20 or newer
11
- - npm
12
-
13
- ## Install
14
-
15
- From the repository root:
16
-
17
- ```powershell
18
- npm install
19
- ```
20
-
21
- This installs TypeScript, the MCP SDK, and YAML parsing dependencies.
22
-
23
- ## Build
24
-
25
- Compile the TypeScript sources into `dist/`:
26
-
27
- ```powershell
28
- npm run build
29
- ```
30
-
31
- The build command runs `tsc`.
32
-
33
- ## Test
34
-
35
- Run the full test suite:
36
-
37
- ```powershell
38
- npm test
39
- ```
40
-
41
- This compiles the project and runs the Node test runner against:
42
-
43
- - `test/schema.test.ts`
44
- - `test/loader.test.ts`
45
- - `test/graph.test.ts`
46
- - `test/mcp.test.ts`
47
- - `test/writer.test.ts`
48
- - `test/serializer.test.ts`
49
-
50
- The fixture graph used by the tests is in `fixtures/sample-graph`. The tests verify that it loads as `45` nodes and `38` edges.
51
-
52
- ## Run The MCP Server
53
-
54
- Build first:
55
-
56
- ```powershell
57
- npm run build
58
- ```
59
-
60
- Run the MCP server against the default graph path:
61
-
62
- ```powershell
63
- npm run mcp
64
- ```
65
-
66
- By default, the server loads:
67
-
68
- ```text
69
- .corum/graph
70
- ```
71
-
72
- To run it against the sample graph fixture instead:
73
-
74
- ```powershell
75
- $env:CORUM_GRAPH_PATH = "fixtures/sample-graph"
76
- npm run mcp
77
- ```
78
-
79
- To reload the in-memory graph when graph YAML or template YAML files change, pass `--watch` to the built server:
80
-
81
- ```powershell
82
- node dist/src/mcp/index.js --watch
83
- ```
84
-
85
- The same watcher can be enabled for the web server with `node dist/src/web/server.js --watch`, or for either server by setting `CORUM_FILE_WATCHER=true`.
86
-
87
- Starting with powershell
88
- ```
89
- $env:CORUM_GRAPH_PATH = "fixtures/sample-graph";
90
- $env:CORUM_WEB_PORT = 3001;
91
- $env:CORUM_FILE_WATCHER="true";
92
- npm run web
93
- ```
94
-
95
- To run the web app against a git repository instead of a filesystem graph path, set `CORUM_SOURCE=git` before starting the app.
96
-
97
- For a local git repository:
98
-
99
- ```powershell
100
- $env:CORUM_SOURCE = "git"
101
- $env:CORUM_GIT_LOCAL_PATH = "C:\git\atolis-hq\corum-design-graph"
102
- $env:CORUM_GIT_BRANCH = "main"
103
- $env:CORUM_GIT_POLL_SECONDS = 10
104
- $env:CORUM_WEB_PORT = 3001
105
- npm run web
106
- ```
107
-
108
- For a remote repository:
109
-
110
- ```powershell
111
- $env:CORUM_SOURCE = "git"
112
- $env:CORUM_GIT_REMOTE_URL = "https://github.com/org/design-repo.git"
113
- $env:CORUM_GIT_BRANCH = "main"
114
- $env:CORUM_GIT_POLL_SECONDS = 10
115
- $env:CORUM_WEB_PORT = 3001
116
- npm run web
117
- ```
118
-
119
- For private remote repositories, also set `CORUM_GIT_TOKEN`. `CORUM_GIT_USERNAME` defaults to `x-access-token` when a token is present.
120
-
121
- The same git source config is used by `npm run mcp`. Git-backed startup expects graph files in `.corum/graph` and template packs in `.corum/packs`, and loads the selected branch at process start.
122
-
123
- `CORUM_GIT_POLL_SECONDS` is optional. When set to a positive number of seconds, the web server polls the git source for branch/ref changes, invalidates its cached multi-branch view, and reloads the app automatically. If it is not set, git-backed content is not polled.
124
-
125
- `CORUM_FILE_WATCHER` only watches filesystem graph paths. It does not watch git refs. For git-backed web sessions, you can either enable `CORUM_GIT_POLL_SECONDS` or use the always-visible `Reload` button in the branch bar to force a refresh.
126
-
127
- The MCP server exposes these tools:
128
-
129
- - `list_nodes`: lists graph nodes, optionally filtered by `template`, `component`, `state`, or `stability`
130
- - `list_templates`: lists loaded graph templates with summary metadata
131
- - `get_template`: returns full details for a loaded graph template
132
- - `get_cluster`: returns a root node, owned child nodes, and edges inside that cluster
133
- - `get_linked_fields`: returns `maps-to` edges touching fields owned by a root node
134
-
135
- Each tool accepts an optional `format` argument:
136
-
137
- - `yaml`: default, human-readable YAML
138
- - `json`: pretty JSON
139
- - `toon`: TOON output via the official `@toon-format/toon` encoder for lower token use
140
-
141
- Each tool also accepts `compact_keys: true` to shorten common graph keys before serialization. This works with all formats:
142
-
143
- ```text
144
- id -> i
145
- template -> t
146
- component -> cp
147
- state -> s
148
- stability -> st
149
- schemaVersion -> sv
150
- lastModifiedAt -> lm
151
- extractedFrom -> xf
152
- properties -> p
153
- root -> r
154
- children -> ch
155
- edges -> e
156
- nodes -> n
157
- from -> fr
158
- to -> to
159
- type -> ty
160
- notes -> nt
161
- ```
162
-
163
- ## MCP Client Configuration
164
-
165
- This repo includes a project-level `.mcp.json`:
166
-
167
- ```json
168
- {
169
- "mcpServers": {
170
- "corum": {
171
- "command": "node",
172
- "args": ["dist/src/mcp/index.js"],
173
- "env": {
174
- "CORUM_GRAPH_PATH": "fixtures/sample-graph"
175
- }
176
- }
177
- }
178
- }
179
- ```
180
-
181
- Build the project before using this config from an MCP client:
182
-
183
- ```powershell
184
- npm run build
185
- ```
186
-
187
- The checked-in config points at `fixtures/sample-graph` so the tools return sample nodes immediately. Change `CORUM_GRAPH_PATH` to `.corum/graph` when you have graph component files there.
188
-
189
- ## MCP Smoke Test
190
-
191
- Run a local MCP client against the configured server and print graph data:
192
-
193
- ```powershell
194
- npm run mcp:smoke
195
- ```
196
-
197
- The smoke test starts the MCP server over stdio and calls:
198
-
199
- - `list_nodes`
200
- - `list_nodes` filtered to `APIEndpoint`
201
- - `get_cluster` for `orders.DomainModel.order`
202
- - `get_linked_fields` for `orders.DomainModel.order`
203
-
204
- ## Useful Development Commands
205
-
206
- Type-check without emitting files:
207
-
208
- ```powershell
209
- npx tsc --noEmit
210
- ```
211
-
212
- Run one compiled test file after building:
213
-
214
- ```powershell
215
- npm run build
216
- node --test dist/test/loader.test.js
217
- ```
218
-
219
- Clean generated build output manually if needed:
220
-
221
- ```powershell
222
- Remove-Item -Recurse -Force dist
223
- ```
1
+ # Corum
2
+
3
+ Corum is a Git-native design graph for service architecture. It models components (APIs, domain models, schemas, fields) as nodes with typed edges, and exposes the graph through MCP tools so AI assistants can reason about your architecture.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install -g @atolis-hq/corum
9
+ ```
10
+
11
+ Or run without installing:
12
+
13
+ ```bash
14
+ npx @atolis-hq/corum <command>
15
+ ```
16
+
17
+ **Windows:** If you see an "execution policy" error in PowerShell, run this once:
18
+
19
+ ```powershell
20
+ Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
21
+ ```
22
+
23
+ This is a standard one-time setup step for Node.js development on Windows. Alternatively, `npx @atolis-hq/corum <command>` works without any setup on all platforms.
24
+
25
+ ## Update
26
+
27
+ ```bash
28
+ npm update -g @atolis-hq/corum
29
+ ```
30
+
31
+ ## Quick Start
32
+
33
+ Scaffold a config file in your project:
34
+
35
+ ```bash
36
+ corum init
37
+ ```
38
+
39
+ This creates `.corum/config.yaml` with commented defaults. Edit it to point at your graph directory or git repository, then start the MCP server:
40
+
41
+ ```bash
42
+ corum mcp
43
+ ```
44
+
45
+ ## Commands
46
+
47
+ ### `corum mcp`
48
+
49
+ Start the MCP stdio server. Also starts a web UI by default.
50
+
51
+ ```bash
52
+ corum mcp [options]
53
+
54
+ Options:
55
+ --no-web Suppress the web UI
56
+ --watch Reload graph on file changes
57
+ --graph <path> Override the graph directory
58
+ ```
59
+
60
+ ### `corum web`
61
+
62
+ Start the web UI only.
63
+
64
+ ```bash
65
+ corum web [options]
66
+
67
+ Options:
68
+ --port <n> Port to listen on (default: 3000)
69
+ --graph <path> Override the graph directory
70
+ ```
71
+
72
+ ### `corum init`
73
+
74
+ Scaffold `.corum/config.yaml` with commented defaults. Does not overwrite an existing file.
75
+
76
+ ```bash
77
+ corum init
78
+ ```
79
+
80
+ ### `corum import`
81
+
82
+ Import specifications into the graph.
83
+
84
+ ```bash
85
+ corum import --config <path> Import using a config YAML file
86
+ ```
87
+
88
+ #### `corum import openapi <spec>`
89
+
90
+ Import an OpenAPI spec directly.
91
+
92
+ ```bash
93
+ corum import openapi <spec> [options]
94
+
95
+ Options:
96
+ --component-strategy <strategy> Component mapping: uri-segment (default), tag, hardcoded
97
+ --segment <n> URI segment index (uri-segment strategy)
98
+ --pattern <regex> Regex pattern (uri-segment strategy)
99
+ --component <name> Component name (hardcoded strategy)
100
+ --graph <path> Override the graph directory
101
+ ```
102
+
103
+ ## Configuration
104
+
105
+ Run `corum init` to generate a `.corum/config.yaml` with all available options. Corum walks up from the current directory to find it, so you can place it at your project root.
106
+
107
+ **Precedence (highest to lowest):** CLI flags → environment variables → `.corum/config.yaml`
108
+
109
+ | Config key | Environment variable | Description |
110
+ |---|---|---|
111
+ | `source` | `CORUM_SOURCE` | `file` (default) or `git` |
112
+ | `graph` | `CORUM_GRAPH_PATH` | Path to the graph directory |
113
+ | `git_local_path` | `CORUM_GIT_LOCAL_PATH` | Local git repo path |
114
+ | `git_remote_url` | `CORUM_GIT_REMOTE_URL` | Remote git repo URL |
115
+ | `git_branch` | `CORUM_GIT_BRANCH` | Branch to load |
116
+ | `git_poll_seconds` | `CORUM_GIT_POLL_SECONDS` | Polling interval for remote git |
117
+ | `git_token` | `CORUM_GIT_TOKEN` | Auth token for private repos |
118
+ | `git_username` | `CORUM_GIT_USERNAME` | Auth username (default: `x-access-token`) |
119
+
120
+ ### File source (default)
121
+
122
+ ```yaml
123
+ # .corum/config.yaml
124
+ source: file
125
+ graph: .corum/graph
126
+ ```
127
+
128
+ ### Git source
129
+
130
+ ```yaml
131
+ # .corum/config.yaml
132
+ source: git
133
+ git_remote_url: https://github.com/org/design-repo
134
+ git_branch: main
135
+ git_poll_seconds: 30
136
+ ```
137
+
138
+ For private repositories, set `CORUM_GIT_TOKEN` as an environment variable rather than storing it in the config file.
139
+
140
+ ## MCP Client Configuration
141
+
142
+ Configure your MCP client to run Corum. For Claude Code or Claude Desktop:
143
+
144
+ ```json
145
+ {
146
+ "mcpServers": {
147
+ "corum": {
148
+ "command": "npx",
149
+ "args": ["@atolis-hq/corum", "mcp", "--no-web"],
150
+ "env": {
151
+ "CORUM_GRAPH_PATH": "/path/to/your/graph"
152
+ }
153
+ }
154
+ }
155
+ }
156
+ ```
157
+
158
+ Or if installed globally:
159
+
160
+ ```json
161
+ {
162
+ "mcpServers": {
163
+ "corum": {
164
+ "command": "corum",
165
+ "args": ["mcp", "--no-web"],
166
+ "env": {
167
+ "CORUM_GRAPH_PATH": "/path/to/your/graph"
168
+ }
169
+ }
170
+ }
171
+ }
172
+ ```
173
+
174
+ ## MCP Tools
175
+
176
+ | Tool | Description |
177
+ |---|---|
178
+ | `list_nodes` | List graph nodes, optionally filtered by `template`, `component`, `state`, or `stability` |
179
+ | `list_templates` | List loaded templates with summary metadata |
180
+ | `get_template` | Return full details for a template |
181
+ | `get_cluster` | Return a root node, its owned children, and internal edges |
182
+ | `get_linked_fields` | Return `maps-to` edges touching fields owned by a root node |
183
+
184
+ All tools accept an optional `format` argument: `yaml` (default), `json`, or `toon`. All tools also accept `compact_keys: true` to shorten common keys before serialization, reducing token usage.
185
+
186
+ ## Contributing
187
+
188
+ See [DEVELOPMENT.md](DEVELOPMENT.md) for build, test, and local development instructions.
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/env node
1
2
  import { Command } from 'commander';
2
3
  import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
3
4
  import path from 'node:path';
@@ -49,45 +50,45 @@ program
49
50
  });
50
51
  });
51
52
  // ── init ─────────────────────────────────────────────────────────────────────
52
- const CONFIG_TEMPLATE = `# Corum project configuration
53
- # Uncomment and set the options relevant to your setup.
54
- # All values can be overridden by environment variables (CORUM_*) or CLI flags.
55
-
56
- # Source type: 'file' (default) or 'git'
57
- # Maps to: CORUM_SOURCE
58
- # source: file
59
-
60
- # ── File source (default) ─────────────────────────────────────────────────────
61
- # Local path to the graph directory.
62
- # Maps to: CORUM_GRAPH_PATH
63
- # graph: .corum/graph
64
-
65
- # ── Git source ────────────────────────────────────────────────────────────────
66
- # Uncomment 'source: git' above and configure one of the following:
67
-
68
- # Local path to a git repository containing the graph.
69
- # Maps to: CORUM_GIT_LOCAL_PATH
70
- # git_local_path: /path/to/repo
71
-
72
- # Remote URL of a git repository containing the graph.
73
- # Maps to: CORUM_GIT_REMOTE_URL
74
- # git_remote_url: https://github.com/org/repo
75
-
76
- # Default branch to load (git source only).
77
- # Maps to: CORUM_GIT_BRANCH
78
- # git_branch: main
79
-
80
- # How often to poll the remote for changes, in seconds (remote git only).
81
- # Maps to: CORUM_GIT_POLL_SECONDS
82
- # git_poll_seconds: 30
83
-
84
- # Auth token for private repositories. Prefer setting CORUM_GIT_TOKEN as an
85
- # environment variable rather than storing a token in this file.
86
- # git_token: ""
87
-
88
- # Auth username (default: x-access-token, suits GitHub PATs and Actions tokens).
89
- # Maps to: CORUM_GIT_USERNAME
90
- # git_username: x-access-token
53
+ const CONFIG_TEMPLATE = `# Corum project configuration
54
+ # Uncomment and set the options relevant to your setup.
55
+ # All values can be overridden by environment variables (CORUM_*) or CLI flags.
56
+
57
+ # Source type: 'file' (default) or 'git'
58
+ # Maps to: CORUM_SOURCE
59
+ # source: file
60
+
61
+ # ── File source (default) ─────────────────────────────────────────────────────
62
+ # Local path to the graph directory.
63
+ # Maps to: CORUM_GRAPH_PATH
64
+ # graph: .corum/graph
65
+
66
+ # ── Git source ────────────────────────────────────────────────────────────────
67
+ # Uncomment 'source: git' above and configure one of the following:
68
+
69
+ # Local path to a git repository containing the graph.
70
+ # Maps to: CORUM_GIT_LOCAL_PATH
71
+ # git_local_path: /path/to/repo
72
+
73
+ # Remote URL of a git repository containing the graph.
74
+ # Maps to: CORUM_GIT_REMOTE_URL
75
+ # git_remote_url: https://github.com/org/repo
76
+
77
+ # Default branch to load (git source only).
78
+ # Maps to: CORUM_GIT_BRANCH
79
+ # git_branch: main
80
+
81
+ # How often to poll the remote for changes, in seconds (remote git only).
82
+ # Maps to: CORUM_GIT_POLL_SECONDS
83
+ # git_poll_seconds: 30
84
+
85
+ # Auth token for private repositories. Prefer setting CORUM_GIT_TOKEN as an
86
+ # environment variable rather than storing a token in this file.
87
+ # git_token: ""
88
+
89
+ # Auth username (default: x-access-token, suits GitHub PATs and Actions tokens).
90
+ # Maps to: CORUM_GIT_USERNAME
91
+ # git_username: x-access-token
91
92
  `;
92
93
  program
93
94
  .command('init')
package/package.json CHANGED
@@ -1,36 +1,40 @@
1
- {
2
- "name": "@atolis-hq/corum",
3
- "version": "0.1.0",
4
- "type": "module",
5
- "files": [
6
- "dist/src/",
7
- "web/"
8
- ],
9
- "bin": {
10
- "corum": "./dist/src/bin/corum.js"
11
- },
12
- "scripts": {
13
- "build": "tsc",
14
- "test": "tsc && node --test dist/test",
15
- "wireframes": "node design/wireframes/server.mjs",
16
- "mcp": "node dist/src/mcp/index.js",
17
- "mcp:smoke": "npm run build && node scripts/mcp-smoke.mjs",
18
- "web": "node dist/src/web/server.js"
19
- },
20
- "dependencies": {
21
- "@apidevtools/swagger-parser": "^12.1.0",
22
- "@modelcontextprotocol/sdk": "^1.0.0",
23
- "@toon-format/toon": "^2.1.0",
24
- "commander": "^14.0.3",
25
- "express": "^4.22.1",
26
- "isomorphic-git": "^1.37.6",
27
- "openapi-types": "^12.1.3",
28
- "yaml": "^2.3.4"
29
- },
30
- "devDependencies": {
31
- "@types/express": "^4.17.25",
32
- "@types/node": "^20.0.0",
33
- "@types/swagger-parser": "^4.0.3",
34
- "typescript": "^5.0.0"
35
- }
36
- }
1
+ {
2
+ "name": "@atolis-hq/corum",
3
+ "version": "0.1.6",
4
+ "type": "module",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/atolis-hq/corum"
8
+ },
9
+ "files": [
10
+ "dist/src/",
11
+ "web/"
12
+ ],
13
+ "bin": {
14
+ "corum": "dist/src/bin/corum.js"
15
+ },
16
+ "scripts": {
17
+ "build": "tsc",
18
+ "test": "tsc && node scripts/run-tests.mjs",
19
+ "wireframes": "node design/wireframes/server.mjs",
20
+ "mcp": "node dist/src/mcp/index.js",
21
+ "mcp:smoke": "npm run build && node scripts/mcp-smoke.mjs",
22
+ "web": "node dist/src/web/server.js"
23
+ },
24
+ "dependencies": {
25
+ "@apidevtools/swagger-parser": "^12.1.0",
26
+ "@modelcontextprotocol/sdk": "^1.0.0",
27
+ "@toon-format/toon": "^2.1.0",
28
+ "commander": "^14.0.3",
29
+ "express": "^4.22.1",
30
+ "isomorphic-git": "^1.37.6",
31
+ "openapi-types": "^12.1.3",
32
+ "yaml": "^2.3.4"
33
+ },
34
+ "devDependencies": {
35
+ "@types/express": "^4.17.25",
36
+ "@types/node": "^24.0.0",
37
+ "@types/swagger-parser": "^4.0.3",
38
+ "typescript": "^5.0.0"
39
+ }
40
+ }