@archme/cli 0.4.0 → 0.4.2

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 (5) hide show
  1. package/LICENSE +64 -0
  2. package/README.md +64 -277
  3. package/SKILL.md +3 -4
  4. package/dist/cli.js +731 -83
  5. package/package.json +19 -3
package/LICENSE ADDED
@@ -0,0 +1,64 @@
1
+ ArchitectMe CLI License
2
+
3
+ Copyright (c) 2026 ArchitectMe. All rights reserved.
4
+
5
+ This software (the "Software") is proprietary and is licensed, not sold.
6
+
7
+ 1. GRANT OF LICENSE
8
+
9
+ Subject to the terms below, you are granted a non-exclusive,
10
+ non-transferable, revocable license to install and use the Software solely
11
+ to interact with the ArchitectMe service operated at archme.io (the
12
+ "Service"), in connection with an active ArchitectMe account.
13
+
14
+ Use of the Software for any other purpose — including use with any service,
15
+ endpoint, or system other than the Service — is not licensed.
16
+
17
+ 2. RESTRICTIONS
18
+
19
+ You may not:
20
+
21
+ (a) redistribute, sublicense, sell, rent, lease, or otherwise transfer the
22
+ Software or copies of it;
23
+ (b) modify, adapt, translate, or create derivative works of the Software;
24
+ (c) reverse engineer, decompile, or disassemble the Software, or otherwise
25
+ attempt to derive its source code, except to the extent that such
26
+ activity is expressly permitted by applicable law notwithstanding this
27
+ restriction;
28
+ (d) remove, obscure, or alter any proprietary notices contained in the
29
+ Software; or
30
+ (e) use the Software to build, train, or improve a competing product or
31
+ service.
32
+
33
+ 3. RESERVATION OF RIGHTS
34
+
35
+ All right, title, and interest in and to the Software, including all
36
+ intellectual property rights, remain with ArchitectMe. No rights are granted
37
+ except as expressly set out in this license.
38
+
39
+ 4. TERMINATION
40
+
41
+ This license terminates automatically if you breach any of its terms, and
42
+ may be terminated by ArchitectMe at any time. On termination you must cease
43
+ all use of the Software and destroy all copies in your possession.
44
+
45
+ 5. NO WARRANTY
46
+
47
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
48
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
49
+ FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT.
50
+
51
+ 6. LIMITATION OF LIABILITY
52
+
53
+ IN NO EVENT SHALL ARCHITECTME BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER
54
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING
55
+ FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE OF OR OTHER
56
+ DEALINGS IN THE SOFTWARE.
57
+
58
+ 7. THIRD-PARTY COMPONENTS
59
+
60
+ The Software incorporates third-party open-source components, which remain
61
+ subject to their own licenses. Nothing in this license limits your rights
62
+ under those licenses with respect to those components.
63
+
64
+ For licensing enquiries, contact archme.io.
package/README.md CHANGED
@@ -1,300 +1,87 @@
1
- # archme-cli
1
+ # @archme/cli
2
2
 
3
- Multi-subcommand CLI for ArchitectMe. The daemon (original purpose of this
4
- package) is one subcommand; the others cover code analysis, OAuth login, and
5
- MCP API key management.
6
-
7
- See also:
8
- - Proposal: `../future-proposals/26-05-12-archme-cli-and-component-anchors.md`
9
- - Analyze methodology: `./SKILL.md`
10
- - Daemon commit-driven flow: `../future-proposals/26-04-29-github-app-commit-driven-updates.md`
11
- - Release runbook (bump → distribute → set floor): `./RELEASE.md`
12
-
13
- ## Subcommands at a glance
14
-
15
- | Subcommand | Purpose |
16
- |---|---|
17
- | `archme daemon` | Local job runner — claims `archme_jobs` rows and runs Claude to update architecture |
18
- | `archme analyze outline\|repo\|diff\|match\|prefetch` | Code analysis primitives (tree-sitter) for keeping architecture in sync with code |
19
- | `archme login \| logout` | OAuth flow — authenticate this machine against ArchitectMe |
20
- | `archme keys list\|create\|revoke` | Manage MCP API keys for headless/CI use |
21
-
22
- ## Installation
3
+ Command-line companion for [ArchMe](https://archme.io) — maps your codebase into
4
+ a living architecture diagram and keeps it current as you commit.
23
5
 
24
6
  ```bash
25
7
  npm install -g @archme/cli
26
8
  ```
27
9
 
28
- Requires Node 20+. `keytar` is an *optional* dependency — if its native build
29
- fails, credentials fall back to `~/.archme/credentials.json` (0600) and
30
- everything else keeps working.
31
-
32
- ### Developing on the CLI
33
-
34
- From a clone, `npm link` puts the local copy on your `PATH`:
35
-
36
- ```bash
37
- cd archme-cli
38
- npm install
39
- npm link
40
-
41
- which archme # → <your-npm-prefix>/bin/archme
42
- ```
43
-
44
- To uninstall: `cd archme-cli && npm unlink` (or `npm rm -g @archme/cli`).
45
-
46
- **One-off / no global install:**
47
-
48
- ```bash
49
- npx tsx archme-cli/src/bin.ts <subcommand> [args]
50
- ```
51
-
52
- The published package runs `dist/cli.js`, built by `npm run build` (esbuild
53
- inlines the repo's top-level `shared/` modules, which do not exist inside the
54
- package). `npm run build:check` builds and then executes the artifact — that is
55
- what CI and `prepublishOnly` run. When iterating on sources, prefer
56
- `npx tsx src/bin.ts`, which never consults `dist/`.
57
-
58
- ### Do you need env config?
59
-
60
- | Goal | Env setup |
61
- |---|---|
62
- | `archme analyze` (outline / repo / diff / match / prefetch) against local files | **None.** Analyze doesn't talk to Supabase. |
63
- | `archme login` / `archme daemon` / `archme scan` against **prod** | **None.** Defaults are hardcoded; just `archme login && archme daemon`. |
64
- | Same commands against **local Supabase** | `ARCHME_ENV=local`. The per-developer OAuth client id is set up once via `npm run setup:local-daemon-oauth` from the repo root (after `supabase start`) — that writes `~/.archme/local-config.json`, which the CLI auto-reads when `ARCHME_ENV=local`. |
65
- | Self-hosted ArchitectMe deployment | Override individual env vars: `SUPABASE_URL=... SUPABASE_ANON_KEY=... ARCHME_DAEMON_CLIENT_ID=... ARCHME_MCP_BASE_URL=... archme daemon`. |
66
-
67
- The CLI never reads `.env` files. Configuration comes from (in order of precedence): explicit env vars > `~/.archme/local-config.json` (when `ARCHME_ENV=local`) > built-in preset for `ARCHME_ENV` (`prod` by default). The full set of overrideable vars is `SUPABASE_URL`, `SUPABASE_ANON_KEY`, `ARCHME_DAEMON_CLIENT_ID`, `ARCHME_MCP_BASE_URL`, plus `CLONE_BASE_DIR` (daemon only, defaults to `~/.archme-job-runner/clones`).
68
-
69
- ---
70
-
71
- ## archme daemon
72
-
73
- Local daemon that consumes `archme_jobs` rows from Supabase and runs Claude
74
- on this machine to update the architecture diagram. It is the local worker
75
- for the GitHub-App → Supabase → laptop-daemon flow
76
- (see `../future-proposals/26-04-29-github-app-commit-driven-updates.md`).
77
-
78
- ### How it works
79
-
80
- 1. Subscribes to Supabase Realtime `INSERT` events on `archme_jobs` filtered
81
- to `status = 'pending'`. On startup and reconnect, also runs a sweep over
82
- any pending rows.
83
- 2. Atomically claims a row through the `claim_archme_job` RPC using its
84
- registered org device id.
85
- 3. Requests short-lived GitHub App installation credentials for the claimed
86
- job's repo, then uses the repo under `CLONE_BASE_DIR/<owner>/<repo>` as a
87
- shared Git object cache.
88
- 4. Creates a temporary detached worktree at the job's `after_sha`.
89
- 5. Generates a temp `mcp.json` pointing at the archme MCP with
90
- `?project=<slug>&branch=<branch>` from the job row.
91
- 6. Shells out to `claude -p <prompt> --mcp-config <path>` with its working
92
- directory set to that temporary worktree. Claude reads the architecture,
93
- reasons about the diff, and calls `update_architecture`.
94
- 7. Calls the `archme-job-complete` edge function to mark the row
95
- `completed` (with the model's summary) or `failed` (with the error) and
96
- post the GitHub check run.
97
- 8. Runs a safety sweep every 30 seconds so pending rows are still picked up if
98
- Realtime misses an event.
99
-
100
- ### Setup
101
-
102
- ```bash
103
- cd archme-cli
104
- npm install
105
- ```
106
-
107
- That's it for the prod target — config defaults live in `src/config/defaults.ts`. For local-Supabase development, see "Do you need env config?" above.
10
+ Requires Node 20+ and [Claude Code](https://claude.com/claude-code) installed and
11
+ signed in — scans and updates run on **your** Claude subscription, on your
12
+ machine. Your code is never sent to ArchMe's servers; only the resulting
13
+ architecture is.
108
14
 
109
- ### Auth
15
+ ## 1. Scan your repo
110
16
 
111
- The daemon always uses one-time browser enrollment:
17
+ `cd` into the repository you want mapped, then:
112
18
 
113
19
  ```bash
114
- cd archme-cli
115
- npm run enroll
20
+ archme init
116
21
  ```
117
22
 
118
- The command prints a code and opens `/agents/pair` in your browser. Pick the
119
- org this daemon should work for, then confirm the matching code while signed
120
- in to ArchitectMe. Pairing creates an enabled `agent_devices` row for that
121
- org. The daemon stores the resulting refresh token, org id, and device id in
122
- macOS Keychain under service `archme-daemon`, using `SUPABASE_URL` as the
123
- account. If Keychain is unavailable, it falls back to
124
- `~/.archme/credentials.json` with mode `0600`.
23
+ This signs you in, creates a project named after the repo, writes the agent
24
+ config (`.mcp.json`, a `CLAUDE.md` block, the architecture skill), tells you
25
+ what the scan will cost before spending it, and runs the scan. It prints a link
26
+ to your board — components appear on it as they're written.
125
27
 
126
- On every token refresh the daemon persists the rotated refresh token. If the
127
- stored token is revoked, invalid, or missing org/device identity, startup
128
- exits with re-enrollment instructions.
28
+ ## 2. Keep it up to date
129
29
 
130
- The web app must be configured with `VITE_ARCHME_DAEMON_CLIENT_ID` matching
131
- the pre-registered Supabase OAuth client for the daemon. That client needs
132
- `<app-origin>/agents/pair/callback` as an allowed redirect URI.
133
-
134
- For local Supabase, run this from the repo root after `supabase start`:
30
+ `archme init` also starts watching the repo, so every push queues an architecture
31
+ update — but nothing processes that queue until you run the agent:
135
32
 
136
33
  ```bash
137
- npm run setup:local-daemon-oauth
34
+ archme daemon start
138
35
  ```
139
36
 
140
- That creates or updates the local daemon OAuth client and writes:
141
-
142
- - `.env.local` for the Vite app (so `/agents/pair` knows the client id)
143
- - `~/.archme/local-config.json` for the CLI (auto-loaded when `ARCHME_ENV=local`)
37
+ Installs the daemon as a background service (launchd/systemd), enables it at
38
+ login, and starts it. Run it on a machine that stays on. Each update counts
39
+ tokens against your Claude account, the same way the scan did.
144
40
 
145
- After that:
146
-
147
- ```bash
148
- ARCHME_ENV=local archme login
149
- ARCHME_ENV=local archme daemon
150
- ```
151
-
152
- To complete the browser step locally, the local app still needs a normal
153
- ArchitectMe web session. If your browser is not already signed in, configure
154
- the local Supabase sign-in provider before starting Supabase.
155
-
156
- ### Run
157
-
158
- ```bash
159
- npm run dev
160
- ```
161
-
162
- Logs prefixed with `[<job-id>]` per job.
163
-
164
- ### Enrollment Verification
165
-
166
- ```bash
167
- cd archme-cli
168
- npm run enroll
169
- # confirm the browser prompt
170
- npm run dev
171
- ```
172
-
173
- On macOS, the credential should be visible with:
174
-
175
- ```bash
176
- security find-generic-password -s archme-daemon -a "$SUPABASE_URL"
177
- ```
178
-
179
- If Keychain was unavailable, check `~/.archme/credentials.json` exists with
180
- mode `0600`.
181
-
182
- ### Job Verification
183
-
184
- With the daemon running, enqueue a job for a watched repo/project. The watched
185
- repo must have a valid GitHub App `installation_id`; the daemon uses that
186
- installation to mint short-lived HTTPS clone/fetch credentials.
187
-
188
- ```sql
189
- select enqueue_archme_job(
190
- '<watched_repo_id>',
191
- '<org_id>',
192
- '<user_id>',
193
- '<project_id>',
194
- '<repo_owner>',
195
- '<repo_name>',
196
- '<repo_branch>',
197
- '<archme_branch>',
198
- '<before_sha>',
199
- '<after_sha>',
200
- false,
201
- null
202
- );
203
- ```
204
-
205
- Within one safety sweep the daemon should claim the row, set
206
- `claimed_by_device_id`, fetch the repo without persisting tokenized remotes,
207
- run Claude, call the completion edge function, and mark the row
208
- `completed`. Open the project in the web app on the same branch; the diagram
209
- should reflect the change, or the row's `result.summary` should explain why
210
- no update was needed.
41
+ Watching a repo needs the ArchMe GitHub App installed on it; `archme init` tells
42
+ you if that step is still missing. Not up for hosting the agent yourself? Get in
43
+ touch at [archme.io](https://archme.io) and we'll run it for you.
211
44
 
212
45
  ---
213
46
 
214
- ## archme analyze
215
-
216
- Code analysis primitives that power keeping ArchitectMe architecture in sync
217
- with actual source code. Parses files with
218
- [web-tree-sitter](https://github.com/tree-sitter/tree-sitter/tree/master/lib/binding_web)
219
- and emits structured JSON that the MCP server and agents consume.
220
-
221
- Grammars are fetched on demand to `~/.archme/tools/grammars/` (override with
222
- `ARCHME_TOOLS_DIR`). No build step required — grammars are downloaded the
223
- first time a language is encountered.
224
-
225
- **Supported languages:** TypeScript, TSX, JavaScript, Python, Go, Java, Ruby,
226
- Rust, Swift, Kotlin.
227
-
228
- For the full agent methodology (how to run a repo scan, match anchors, and
229
- write architecture updates) see `./SKILL.md`.
230
-
231
- ### Commands
232
-
233
- ```
234
- archme analyze outline <file> Emit a JSON symbol outline for a single file
235
- archme analyze repo Walk the repo and outline every supported file
236
- archme analyze diff <range> Outline only files changed in a git range (e.g. HEAD~3..HEAD)
237
- archme analyze match <anchor-spec> Match anchor specs (JSON file) against current symbol outlines
238
- archme analyze prefetch [langs...] Pre-download grammars so first analysis is instant
239
- ```
240
-
241
- ### Example
242
-
243
- ```bash
244
- archme analyze outline src/api/upload.ts
245
- ```
47
+ ## Other commands
246
48
 
247
- Output is a JSON envelope:
248
-
249
- ```json
250
- {
251
- "file": "src/api/upload.ts",
252
- "lang": "typescript",
253
- "symbols": [
254
- { "kind": "function", "name": "handleUpload", "line": 12, "exported": true },
255
- { "kind": "class", "name": "UploadService", "line": 34, "exported": true }
256
- ]
257
- }
258
- ```
259
-
260
- `archme analyze repo` emits one envelope per file (newline-delimited JSON) and
261
- is the starting point for a full codebase scan.
262
-
263
- `archme analyze match <anchor-spec.json>` takes a JSON file describing named
264
- anchors (component → expected symbols) and reports which anchors still resolve
265
- and which have drifted, enabling the MCP server to flag stale architecture
266
- nodes.
267
-
268
- ---
269
-
270
- ## Auth & keys
271
-
272
- ### archme login / logout
273
-
274
- ```bash
275
- archme login # Opens browser OAuth flow; stores token in macOS Keychain
276
- # (falls back to ~/.archme/credentials.json with mode 0600)
277
- archme logout # Clears stored credentials
278
- ```
279
-
280
- OAuth flow uses the same Supabase OAuth 2.1 / PKCE mechanism as the daemon
281
- enrollment. Intended for interactive use; the daemon uses its own enrollment
282
- flow (`npm run enroll`) instead.
283
-
284
- ### archme keys list | create | revoke
285
-
286
- ```bash
287
- archme keys list # List MCP API keys for the authenticated user
288
- archme keys create <name> # Mint a new am_* key for CI / headless use
289
- archme keys revoke <key-id> # Revoke a key
290
- ```
291
-
292
- > **Currently stub** — these commands print placeholder messages. Full
293
- > implementation (Unkey integration, org-scoped key listing) is pending.
294
-
295
- ---
296
-
297
- ## Privacy / sync
298
-
299
- This directory is excluded from the work-repo sync
300
- (`scripts/sync-to-on-prem.sh`).
49
+ | Command | Purpose |
50
+ |---|---|
51
+ | `archme init [repo-path]` | Guided setup + scan (see above); `--force` re-scans |
52
+ | `archme scan <repo-path>` | Low-level single-pass scan into an explicit `--project` / `--branch` |
53
+ | `archme daemon <sub>` | `start` · `stop` · `restart` · `status` · `logs` · `enable` · `disable` · `install` · `uninstall` · `run` |
54
+ | `archme analyze <sub>` | Tree-sitter code analysis: `outline` · `repo` · `diff` · `match` · `prefetch` |
55
+ | `archme login` / `archme logout` | Authenticate this machine against ArchMe |
56
+
57
+ Every command takes `--help`. Useful flags:
58
+
59
+ - `archme init --skip-scan` — wire up the repo without scanning; `--force`
60
+ re-scans a project that already has an architecture; `--yes` runs unattended
61
+ (scans are interactive by default, so you can steer them as they go).
62
+ - `archme daemon status` — is it installed, running, and signed in?
63
+ `archme daemon logs -f` follows the log.
64
+ - `archme analyze outline <file>` — JSON symbol outline for one file; `repo`
65
+ outlines everything, `diff <range>` only what a git range touched. Supports
66
+ TypeScript, TSX, JavaScript, Python, Go, Java, Ruby, Rust, Swift, and Kotlin.
67
+ Grammars download on first use to `~/.archme/tools/grammars/`.
68
+
69
+ ### Notes
70
+
71
+ - **Credentials**: stored in the macOS Keychain when available, otherwise
72
+ `~/.archme/credentials.json` (mode `0600`). `keytar` is an *optional*
73
+ dependency — if its native build fails, everything still works via the file
74
+ store.
75
+ - **Configuration**: no env setup needed against archme.io; the CLI never reads
76
+ `.env` files. Self-hosted deployments can override `SUPABASE_URL`,
77
+ `SUPABASE_ANON_KEY`, `ARCHME_DAEMON_CLIENT_ID`, `ARCHME_MCP_BASE_URL`, and
78
+ `CLONE_BASE_DIR` (daemon only, defaults to
79
+ `~/.archme-job-runner/clones`).
80
+ - **Agent methodology** — how an agent scans a repo, anchors components to code,
81
+ and writes architecture updates — is in the `SKILL.md` bundled with this
82
+ package. `archme init` installs it into your repo for you.
83
+
84
+ ## License
85
+
86
+ Proprietary — see the bundled `LICENSE`. Use is granted against the archme.io
87
+ service; bundled open-source components keep their own terms.
package/SKILL.md CHANGED
@@ -237,7 +237,6 @@ own code.
237
237
 
238
238
  ## Where to look
239
239
 
240
- - Spec (this skill's source of truth):
241
- `future-proposals/26-05-12-archme-cli-and-component-anchors.md`
242
- - Tool descriptions live in the MCP server (`supabase/functions/mcp/index.ts`).
243
- - CLI source: `archme-cli/src/analyze/`.
240
+ - Every archme MCP tool documents its own arguments and constraints — list the
241
+ tools and read the description before guessing at a payload shape.
242
+ - `archme <command> --help` documents the CLI side.