wayform 0.1.8 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +145 -54
- package/dist/cli.js +25 -10
- package/dist/cli.js.map +1 -1
- package/dist/config.js +46 -24
- package/dist/config.js.map +1 -1
- package/dist/credential-store.js +77 -0
- package/dist/credential-store.js.map +1 -0
- package/dist/doctor.js +114 -32
- package/dist/doctor.js.map +1 -1
- package/dist/frontmatter.js +25 -0
- package/dist/frontmatter.js.map +1 -1
- package/dist/guard-hook.js +94 -0
- package/dist/guard-hook.js.map +1 -0
- package/dist/hook-clients.js +20 -34
- package/dist/hook-clients.js.map +1 -1
- package/dist/hook.js +3 -3
- package/dist/hook.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/init-configs.js +84 -31
- package/dist/init-configs.js.map +1 -1
- package/dist/init-env.js +18 -11
- package/dist/init-env.js.map +1 -1
- package/dist/init-remote.js +186 -98
- package/dist/init-remote.js.map +1 -1
- package/dist/init.js +22 -9
- package/dist/init.js.map +1 -1
- package/dist/keychain.js +19 -0
- package/dist/keychain.js.map +1 -0
- package/dist/metrics.js +1 -1
- package/dist/metrics.js.map +1 -1
- package/dist/oauth-login.js +197 -0
- package/dist/oauth-login.js.map +1 -0
- package/dist/oauth-session.js +122 -0
- package/dist/oauth-session.js.map +1 -0
- package/dist/prompt-hook.js +5 -4
- package/dist/prompt-hook.js.map +1 -1
- package/dist/remote-read.js +42 -13
- package/dist/remote-read.js.map +1 -1
- package/dist/session-prompt.js +33 -8
- package/dist/session-prompt.js.map +1 -1
- package/dist/space-create.js +17 -201
- package/dist/space-create.js.map +1 -1
- package/dist/store.js +3 -2
- package/dist/store.js.map +1 -1
- package/dist/token-budget.js +7 -0
- package/dist/token-budget.js.map +1 -1
- package/dist/token.js +36 -0
- package/dist/token.js.map +1 -0
- package/package.json +3 -2
- package/dist/review-prompt.js +0 -25
- package/dist/review-prompt.js.map +0 -1
- package/dist/stop-hook.js +0 -45
- package/dist/stop-hook.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Wayform
|
|
2
2
|
|
|
3
3
|
**Shared planning memory for teams that build with AI.** A decision made in one
|
|
4
4
|
person's Claude session is already loaded in their teammate's Cursor session —
|
|
@@ -21,7 +21,7 @@ starts cold. Every collaborator re-explains the same settled decisions to their
|
|
|
21
21
|
own agent, every day. The context that matters — *what we decided and why* —
|
|
22
22
|
lives in Slack scrollback and people's heads.
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
Wayform fixes the loop with three properties nothing else combines:
|
|
25
25
|
|
|
26
26
|
- **Multiplayer.** One shared store per team. Your agent reads what your
|
|
27
27
|
teammate's agent wrote. Attribution is git commit authorship — you always know
|
|
@@ -50,8 +50,8 @@ Three steps: install the CLI, create the shared repo, wire your project.
|
|
|
50
50
|
### 1. Install the CLI (once per machine)
|
|
51
51
|
|
|
52
52
|
```bash
|
|
53
|
-
git clone https://github.com/skandaramanan/
|
|
54
|
-
&& npm install -g /tmp/
|
|
53
|
+
git clone https://github.com/skandaramanan/Wayform /tmp/wayform \
|
|
54
|
+
&& npm install -g /tmp/wayform
|
|
55
55
|
```
|
|
56
56
|
|
|
57
57
|
Requires Node ≥ 18. `dist/` is pre-built and committed, so no build step runs
|
|
@@ -75,58 +75,120 @@ or SSH. No accounts, no separate auth.
|
|
|
75
75
|
From your project repo:
|
|
76
76
|
|
|
77
77
|
```bash
|
|
78
|
-
|
|
78
|
+
wayform init
|
|
79
79
|
```
|
|
80
80
|
|
|
81
81
|
`init` writes, idempotently and without clobbering existing config:
|
|
82
82
|
|
|
83
83
|
- **Session-start read hooks + MCP registration** for Claude Code
|
|
84
84
|
(`.claude/settings.json`, `.mcp.json`), Cursor (`.cursor/hooks.json`,
|
|
85
|
-
`.cursor/mcp.json`), and Codex (`.codex/hooks.json
|
|
86
|
-
|
|
85
|
+
`.cursor/mcp.json`), and Codex (`.codex/hooks.json` and project
|
|
86
|
+
`.codex/config.toml`)
|
|
87
87
|
- **End-of-turn write-review hooks** (the Stop hook — see
|
|
88
88
|
[The loop](#the-loop-how-reads-and-writes-actually-happen))
|
|
89
89
|
- Your per-user, **gitignored** `.memorylayer-hook.env` (identity + repo URL —
|
|
90
90
|
secrets never enter git)
|
|
91
91
|
|
|
92
|
-
One person commits the project configs; each teammate runs `
|
|
92
|
+
One person commits the project configs; each teammate runs `wayform init`
|
|
93
93
|
once to set their own identity. Done — the next coding session in that project
|
|
94
94
|
starts with the team's context already loaded.
|
|
95
95
|
|
|
96
96
|
**Verify the round-trip:** from a session, say *"record this decision: testing
|
|
97
|
-
|
|
97
|
+
Wayform, because we just set it up."* Then have a teammate (or a second
|
|
98
98
|
machine) open a fresh session — the decision should be in their context without
|
|
99
99
|
anyone pasting it. That round-trip is the product.
|
|
100
100
|
|
|
101
101
|
---
|
|
102
102
|
|
|
103
|
-
## Hosted gateway
|
|
103
|
+
## Hosted gateway
|
|
104
104
|
|
|
105
105
|
The local mode above needs each member to hold a git token. The **hosted
|
|
106
|
-
gateway** removes even that: a stateless Cloudflare Worker exposes the same
|
|
107
|
-
tools over MCP Streamable HTTP
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
106
|
+
gateway** removes even that: a stateless Cloudflare Worker exposes the same
|
|
107
|
+
tools over **MCP Streamable HTTP**. Identity is **GitHub OAuth** (the same App
|
|
108
|
+
that writes the memory repo). Members never copy, paste, or store a Wayform
|
|
109
|
+
credential.
|
|
110
|
+
|
|
111
|
+
Wayform is **vendor-neutral**. The same URL works in Cursor, Claude Code,
|
|
112
|
+
Codex, Devin, Antigravity, or any MCP client that speaks Streamable HTTP +
|
|
113
|
+
OAuth. Configure it in **this product repo** (the codebase you work in) — never
|
|
114
|
+
as a user-global MCP, or it will follow you into unrelated folders.
|
|
115
|
+
|
|
116
|
+
Every customer is a new team. The operator allowlists their GitHub user or org;
|
|
117
|
+
they create their own private memory repo, initialize project-scoped config,
|
|
118
|
+
and select that memory repo in the guided App installation. Teammates are
|
|
119
|
+
invited in-agent by GitHub username.
|
|
120
|
+
|
|
121
|
+
**Operator (once per client):** add their GitHub login or org to the allowlist,
|
|
122
|
+
then send the MCP URL. Never send a token.
|
|
123
|
+
|
|
124
|
+
**They do:**
|
|
125
|
+
|
|
126
|
+
1. On GitHub, create a **private** team-memory repo and give it a first commit
|
|
127
|
+
(for example, initialize it with a README).
|
|
128
|
+
2. In the product repo, run
|
|
129
|
+
`wayform init --remote --clients cursor,claude` with the clients the team
|
|
130
|
+
actually uses. This writes URL-only, project-scoped configuration.
|
|
131
|
+
3. Connect the `wayform` MCP server. Sign in with GitHub, follow the guided App
|
|
132
|
+
installation, and select only the private memory repo from step 1.
|
|
133
|
+
4. Run `wayform login` once on the machine so session hooks can authenticate.
|
|
134
|
+
5. Run `wayform doctor`; resolve every failed hosted check before continuing.
|
|
135
|
+
6. Ask the agent to record a test decision, then open a new session and confirm
|
|
136
|
+
that decision is already present.
|
|
137
|
+
7. Commit the URL-only project configuration. Teammates run remote init and
|
|
138
|
+
authenticate; nobody copies a credential.
|
|
139
|
+
|
|
140
|
+
### Client setup (project-scoped, OAuth)
|
|
141
|
+
|
|
142
|
+
Same URL everywhere. OAuth credentials are managed internally by each MCP
|
|
143
|
+
client or the native OS credential store; users never copy or configure them.
|
|
144
|
+
|
|
145
|
+
| Client | Project file (commit this) | Do **not** use (global) | Authenticate |
|
|
146
|
+
|---|---|---|---|
|
|
147
|
+
| **Cursor** | `.cursor/mcp.json` → `{ "mcpServers": { "wayform": { "url": "…" } } }` | `~/.cursor/mcp.json` | Connect |
|
|
148
|
+
| **Claude Code** | `.mcp.json` (same JSON), or `claude mcp add --transport http --scope project wayform <url>` | `--scope user` | `claude mcp login wayform` |
|
|
149
|
+
| **Codex** | `.codex/config.toml` → `url` + `auth = "oauth"` | `~/.codex/config.toml` | `codex mcp login wayform` |
|
|
150
|
+
| **Devin CLI** | `.devin/mcp_config.json` → `{ "url": "…", "transport": "http" }` | `--scope user` / `~/.config/devin/mcp_config.json` | `devin mcp login wayform` |
|
|
151
|
+
| **Antigravity** | `.agents/mcp_config.json` → `{ "serverUrl": "…" }` | `~/.gemini/config/mcp_config.json` | Authenticate in MCP settings (DCR) |
|
|
152
|
+
|
|
153
|
+
`wayform init --remote --clients cursor,claude` writes **only** those
|
|
154
|
+
clients' files. With `--yes` and no `--clients`, it updates folders
|
|
155
|
+
already in the repo and does not create the rest. `wayform doctor` says
|
|
156
|
+
"run wayform login" when the hook session is missing — never "paste a token".
|
|
157
|
+
|
|
158
|
+
Do **not** add Wayform as a Devin Cloud **organization-wide** MCP if you only
|
|
159
|
+
want it in this repo — that surface is shared across the org, not one folder.
|
|
160
|
+
|
|
161
|
+
Endpoints, allowlist, and the deploy runbook live in
|
|
162
|
+
[gateway/README.md](gateway/README.md).
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## The guard
|
|
167
|
+
|
|
168
|
+
Reading decisions back is half the loop. The other half is catching an agent
|
|
169
|
+
about to contradict one.
|
|
170
|
+
|
|
171
|
+
With the hosted gateway configured, `wayform init` wires a `PreToolUse` hook in
|
|
172
|
+
Claude Code. Before any `Edit`, `Write`, or `Bash`, the proposed action is
|
|
173
|
+
checked against the team's live decisions. If it contradicts one, you get a
|
|
174
|
+
confirmation prompt naming the decision, who made it, and when:
|
|
175
|
+
|
|
176
|
+
> **Wayform — this contradicts a recorded team decision:**
|
|
177
|
+
> We ruled out a second datastore; Postgres is not being added.
|
|
178
|
+
> — Skanda, 2026-07-12
|
|
125
179
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
180
|
+
It **asks**; it never blocks. Reads are never guarded, so only mutating tools
|
|
181
|
+
pay any latency, capped at 1.5s before the check gives up and allows.
|
|
182
|
+
|
|
183
|
+
Turn it off per machine with `WAYFORM_GUARD=off` in `.memorylayer-hook.env`.
|
|
184
|
+
|
|
185
|
+
How often it fires:
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
curl -H "$WAYFORM_AUTH" \
|
|
189
|
+
"$GATEWAY/mcp/admin/retrieval-log?space=<space>&trigger=hook_guard"
|
|
190
|
+
# → { "rows": [...], "fired": 12 }
|
|
191
|
+
```
|
|
130
192
|
|
|
131
193
|
---
|
|
132
194
|
|
|
@@ -171,8 +233,9 @@ coding session. (The flip side: failures are quiet — that's what `doctor` is
|
|
|
171
233
|
for.)
|
|
172
234
|
|
|
173
235
|
**Claude Desktop** has no hook system, so it's MCP-pull-only: register
|
|
174
|
-
`
|
|
175
|
-
reads when the model chooses to — path 1 is your write path
|
|
236
|
+
`wayform` as a stdio server (or point Desktop at the hosted gateway URL and
|
|
237
|
+
Connect) and it reads when the model chooses to — path 1 is your write path
|
|
238
|
+
there.
|
|
176
239
|
|
|
177
240
|
## Configuration (`.memorylayer-hook.env`)
|
|
178
241
|
|
|
@@ -182,18 +245,22 @@ into hook subprocesses:
|
|
|
182
245
|
|
|
183
246
|
| Var | Required | Meaning |
|
|
184
247
|
|-----|----------|---------|
|
|
185
|
-
| `CONTEXT_REPO_URL` |
|
|
186
|
-
| `
|
|
187
|
-
| `
|
|
248
|
+
| `CONTEXT_REPO_URL` | local mode | Shared context repo URL (may embed a git token). |
|
|
249
|
+
| `MEMORYLAYER_GATEWAY_URL` | hosted mode | Gateway base URL. Presence selects hosted (no clone). |
|
|
250
|
+
| `MEMORYLAYER_AUTHOR` | local mode | Your name — local commit author / attribution. Hosted attribution comes from GitHub OAuth. |
|
|
251
|
+
| `MEMORYLAYER_AUTHOR_EMAIL` | no | Local commit email. Defaults from author name. |
|
|
188
252
|
| `MEMORYLAYER_PROJECT` | no | Project/space name. Default: repo directory name. |
|
|
189
253
|
| `CONTEXT_REPO_PATH` | no | Local clone path. Default: keyed per repo URL under `$XDG_DATA_HOME/memorylayer/clones/<repo-slug>-<hash>` (falls back to `~/.local/share/...`), so two spaces can never share a clone. |
|
|
190
254
|
| `MEMORYLAYER_READ_BUDGET_TOKENS` | no | Read token budget. Default 4000; `<=0` = unlimited. |
|
|
191
255
|
| `MEMORYLAYER_AUTO_PUSH` | no | `false` to skip pushing (local smoke tests). |
|
|
192
256
|
|
|
257
|
+
Hosted hook env contains only project settings and the gateway URL. The OAuth
|
|
258
|
+
session is held by the native OS credential store after `wayform login`.
|
|
259
|
+
|
|
193
260
|
## Diagnostics
|
|
194
261
|
|
|
195
262
|
```bash
|
|
196
|
-
|
|
263
|
+
wayform doctor
|
|
197
264
|
```
|
|
198
265
|
|
|
199
266
|
Read-only. Checks the env file, resolved config, clone health and origin,
|
|
@@ -209,35 +276,59 @@ write "silently" does nothing — fail-open means problems hide here first.
|
|
|
209
276
|
`context/`; error output redacts embedded tokens.
|
|
210
277
|
- **Hosted mode:** the gateway is a stateless proxy — the source of truth stays
|
|
211
278
|
a private GitHub repo in *your* account. The App holds Contents-only
|
|
212
|
-
permission on exactly one repo per space;
|
|
213
|
-
|
|
214
|
-
store, never in code or git.
|
|
279
|
+
permission on exactly one repo per space; members are keyed by GitHub user
|
|
280
|
+
id after OAuth. The Worker holds operator secrets in Cloudflare's secret
|
|
281
|
+
store, never in code or git. Members never see a Wayform API key. For now,
|
|
282
|
+
one GitHub user can belong to one Wayform space; multi-space membership is a
|
|
283
|
+
deferred product decision.
|
|
215
284
|
- **Trust boundary to know about:** everything a space member writes is
|
|
216
285
|
injected into every member's sessions. You trust the people in your space —
|
|
217
286
|
that's the model, stated plainly.
|
|
287
|
+
- **Rate limits — wired but NOT currently enforcing.** Verified live
|
|
288
|
+
2026-08-30: the binding is bound and called on every request, but returned
|
|
289
|
+
success for 100+ requests in seconds against a limit of 20/60s. Treat these
|
|
290
|
+
surfaces as **unprotected** until a `ratelimit_block` line appears in Workers
|
|
291
|
+
Logs. Intended shape: unauthenticated surfaces (`/authorize`, `/callback`,
|
|
292
|
+
`/oauth/register`, `/oauth/token`, `/install/*`, `/admin/*`) are capped at 20
|
|
293
|
+
requests per minute per caller. `/mcp` is not capped — it requires a valid
|
|
294
|
+
token, so abuse there is a revocation problem, not a throttling one.
|
|
295
|
+
`/health` and the signed GitHub webhook are never throttled: dropping a
|
|
296
|
+
webhook would stall indexing silently, which is worse than the abuse it would
|
|
297
|
+
prevent. If the limiter is unavailable the gateway serves normally rather
|
|
298
|
+
than refusing traffic.
|
|
299
|
+
|
|
300
|
+
### Managing your own sessions
|
|
301
|
+
|
|
302
|
+
Every editor you connect is a separate OAuth grant. You can review and
|
|
303
|
+
disconnect them yourself, from any agent — no operator involved:
|
|
304
|
+
|
|
305
|
+
> "list my wayform sessions"
|
|
306
|
+
> "revoke wayform session <id>"
|
|
307
|
+
|
|
308
|
+
`list_sessions` shows each connected client, when it was connected, and marks
|
|
309
|
+
the one you are currently using. `revoke_session` disconnects one and takes
|
|
310
|
+
effect immediately; that client must sign in again. Both act only on **your**
|
|
311
|
+
account — removing a *teammate* from the space is `revoke_member`, and is
|
|
312
|
+
admin-only. A revoke that cannot be confirmed reports an error rather than
|
|
313
|
+
claiming success, so "revoked" always means revoked.
|
|
218
314
|
|
|
219
315
|
## Troubleshooting
|
|
220
316
|
|
|
221
317
|
| Symptom | Cause & fix |
|
|
222
318
|
|---|---|
|
|
223
|
-
| `
|
|
319
|
+
| `wayform: command not found` right after `npm install -g github:...` | npm 10 git-global-install bug: the global bin points at an ephemeral cache clone with no files. Fix: the clone-then-install path from the Quickstart, or `npm pack` + `npm install -g ./wayform-*.tgz`. |
|
|
224
320
|
| `ENOTDIR` reinstalling over a previous failed install | Same bug, stale symlink. Remove the target dir shown in the error, then clone-then-install. |
|
|
225
|
-
| Reads/writes silently do nothing | `
|
|
321
|
+
| Reads/writes silently do nothing | `wayform doctor`. Hosted: usually `wayform login`. Local: missing `.memorylayer-hook.env`, no repo access, or unpushed local commits (self-heals on next read). |
|
|
226
322
|
| Teammates still see old behavior after an upgrade | The fix lives in the **global binary** — each teammate must reinstall it (committed project configs aren't enough), and a running MCP server needs a restart to pick it up. |
|
|
227
323
|
| macOS `curl` fails TLS against the hosted gateway (`workers.dev`) | LibreSSL negotiation quirk — add `--tlsv1.2`. Client-side only; SDK-based MCP clients are unaffected. |
|
|
228
324
|
|
|
229
325
|
## Project status
|
|
230
326
|
|
|
231
|
-
Working and in daily two-person dogfood
|
|
232
|
-
|
|
233
|
-
byte-intact by the local tool). Currently running a multi-week reliance pilot —
|
|
234
|
-
the success signal is a collaborator who **stops re-explaining decisions**
|
|
235
|
-
because they trust the shared space.
|
|
327
|
+
Working and in daily two-person dogfood on GitHub OAuth (no member API keys).
|
|
328
|
+
Hosted onboarding is Connect + GitHub App install on your private memory repo.
|
|
236
329
|
|
|
237
|
-
**Deliberately not built yet
|
|
238
|
-
|
|
239
|
-
engine (git *is* the merge engine). Next increments: gateway client shims
|
|
240
|
-
(`init --remote`), space-provisioning CLI.
|
|
330
|
+
**Deliberately not built yet:** Stripe/paid plans, per-space extract caps,
|
|
331
|
+
dashboard UI, custom merge engine (git *is* the merge engine).
|
|
241
332
|
|
|
242
333
|
## Repo layout
|
|
243
334
|
|
|
@@ -255,7 +346,7 @@ test/ node:test suites (gateway has its own under gateway/test/)
|
|
|
255
346
|
```bash
|
|
256
347
|
npm test # build + full local suite, lint: npm run lint
|
|
257
348
|
npm run test:gateway # gateway suite (Node >= 20)
|
|
258
|
-
|
|
349
|
+
wayform --help # subcommands: init, login, hook, doctor, space
|
|
259
350
|
```
|
|
260
351
|
|
|
261
352
|
Both planes share the entry format modules (`src/frontmatter.ts`,
|
package/dist/cli.js
CHANGED
|
@@ -6,22 +6,26 @@
|
|
|
6
6
|
* wayform -> MCP server (default)
|
|
7
7
|
* wayform hook <client> -> read hook
|
|
8
8
|
* wayform prompt-hook <client> -> Claude UserPromptSubmit → /hook/prompt
|
|
9
|
+
* wayform guard <client> -> PreToolUse guard → /hook/guard
|
|
9
10
|
* wayform stop-review <client> -> Stop no-op (legacy; re-engagement removed)
|
|
11
|
+
* wayform login -> GitHub OAuth; tokens go to the OS keychain
|
|
10
12
|
* wayform init [flags] -> installer (add --remote for hosted members)
|
|
11
13
|
* wayform doctor -> local diagnostics
|
|
12
|
-
* wayform space create [flags] ->
|
|
14
|
+
* wayform space create [flags] -> print App install URL + allowlist reminder
|
|
13
15
|
*
|
|
14
|
-
* `hook`/`prompt-hook
|
|
16
|
+
* `hook`/`prompt-hook` set WAYFORM_HOOK_CLIENT from the positional arg, then
|
|
15
17
|
* delegate to the neutral run functions (which self-load .memorylayer-hook.env).
|
|
16
18
|
*/
|
|
17
19
|
import { loadHookEnv } from "./config.js";
|
|
18
20
|
import { runServer } from "./index.js";
|
|
19
21
|
import { runHook } from "./hook.js";
|
|
20
22
|
import { runPromptHook } from "./prompt-hook.js";
|
|
21
|
-
import {
|
|
23
|
+
import { runGuardHook } from "./guard-hook.js";
|
|
22
24
|
import { runInit } from "./init.js";
|
|
23
25
|
import { runDoctor } from "./doctor.js";
|
|
24
26
|
import { runSpaceCreate } from "./space-create.js";
|
|
27
|
+
import { runLogin } from "./oauth-login.js";
|
|
28
|
+
import { runToken } from "./token.js";
|
|
25
29
|
async function main() {
|
|
26
30
|
// Self-load .memorylayer-hook.env from the project cwd for every subcommand,
|
|
27
31
|
// so the command is self-contained (no bash launcher). loadConfig stays pure.
|
|
@@ -30,18 +34,23 @@ async function main() {
|
|
|
30
34
|
switch (sub) {
|
|
31
35
|
case "hook":
|
|
32
36
|
if (rest[0])
|
|
33
|
-
process.env.
|
|
37
|
+
process.env.WAYFORM_HOOK_CLIENT = rest[0];
|
|
34
38
|
await runHook();
|
|
35
39
|
return;
|
|
36
40
|
case "prompt-hook":
|
|
37
41
|
if (rest[0])
|
|
38
|
-
process.env.
|
|
42
|
+
process.env.WAYFORM_HOOK_CLIENT = rest[0];
|
|
39
43
|
await runPromptHook();
|
|
40
44
|
return;
|
|
41
|
-
case "
|
|
45
|
+
case "guard":
|
|
42
46
|
if (rest[0])
|
|
43
|
-
process.env.
|
|
44
|
-
await
|
|
47
|
+
process.env.WAYFORM_HOOK_CLIENT = rest[0];
|
|
48
|
+
await runGuardHook();
|
|
49
|
+
return;
|
|
50
|
+
case "stop-review":
|
|
51
|
+
// Stop re-engagement retired (da491a7d): emit the client no-op so stale
|
|
52
|
+
// Stop wiring keeps working until configs drop it.
|
|
53
|
+
process.stdout.write(rest[0] === "raw" ? "" : "{}");
|
|
45
54
|
return;
|
|
46
55
|
case "init":
|
|
47
56
|
await runInit(rest);
|
|
@@ -49,19 +58,25 @@ async function main() {
|
|
|
49
58
|
case "doctor":
|
|
50
59
|
await runDoctor();
|
|
51
60
|
return;
|
|
61
|
+
case "login":
|
|
62
|
+
await runLogin(rest);
|
|
63
|
+
return;
|
|
64
|
+
case "token":
|
|
65
|
+
await runToken(rest);
|
|
66
|
+
return;
|
|
52
67
|
case "space":
|
|
53
68
|
if (rest[0] === "create") {
|
|
54
69
|
await runSpaceCreate(rest.slice(1));
|
|
55
70
|
return;
|
|
56
71
|
}
|
|
57
|
-
console.error(`Unknown "space" subcommand "${rest[0]}". Use: wayform space create --
|
|
72
|
+
console.error(`Unknown "space" subcommand "${rest[0]}". Use: wayform space create --owner <github-login>`);
|
|
58
73
|
process.exit(1);
|
|
59
74
|
return;
|
|
60
75
|
case undefined:
|
|
61
76
|
await runServer();
|
|
62
77
|
return;
|
|
63
78
|
default:
|
|
64
|
-
console.error(`Unknown command "${sub}". Use: wayform [hook|prompt-hook|stop-review|init|doctor|space] …`);
|
|
79
|
+
console.error(`Unknown command "${sub}". Use: wayform [hook|prompt-hook|guard|stop-review|init|doctor|login|token|space] …`);
|
|
65
80
|
process.exit(1);
|
|
66
81
|
}
|
|
67
82
|
}
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,KAAK,UAAU,IAAI;IACjB,6EAA6E;IAC7E,8EAA8E;IAC9E,WAAW,EAAE,CAAC;IAEd,MAAM,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAE7C,QAAQ,GAAG,EAAE,CAAC;QACZ,KAAK,MAAM;YACT,IAAI,IAAI,CAAC,CAAC,CAAC;gBAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YACvD,MAAM,OAAO,EAAE,CAAC;YAChB,OAAO;QACT,KAAK,aAAa;YAChB,IAAI,IAAI,CAAC,CAAC,CAAC;gBAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YACvD,MAAM,aAAa,EAAE,CAAC;YACtB,OAAO;QACT,KAAK,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,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;IAChE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/config.js
CHANGED
|
@@ -19,18 +19,36 @@ function required(name) {
|
|
|
19
19
|
* inject process-hijacking vars (NODE_OPTIONS, PATH, GIT_*, LD_PRELOAD, …) and
|
|
20
20
|
* reach code execution. We only ever set MemoryLayer's own config keys.
|
|
21
21
|
*/
|
|
22
|
+
const HOOK_ENV_KEYS = [
|
|
23
|
+
"AUTHOR",
|
|
24
|
+
"AUTHOR_EMAIL",
|
|
25
|
+
"PROJECT",
|
|
26
|
+
"AUTO_PUSH",
|
|
27
|
+
"HOOK_CLIENT",
|
|
28
|
+
"READ_BUDGET_TOKENS",
|
|
29
|
+
"GATEWAY_URL",
|
|
30
|
+
];
|
|
22
31
|
const HOOK_ENV_ALLOWLIST = new Set([
|
|
23
32
|
"CONTEXT_REPO_URL",
|
|
24
33
|
"CONTEXT_REPO_PATH",
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"MEMORYLAYER_PROJECT",
|
|
28
|
-
"MEMORYLAYER_AUTO_PUSH",
|
|
29
|
-
"MEMORYLAYER_HOOK_CLIENT",
|
|
30
|
-
"MEMORYLAYER_READ_BUDGET_TOKENS",
|
|
31
|
-
"MEMORYLAYER_GATEWAY_URL",
|
|
32
|
-
"MEMORYLAYER_GATEWAY_TOKEN",
|
|
34
|
+
...HOOK_ENV_KEYS.map((k) => `WAYFORM_${k}`),
|
|
35
|
+
...HOOK_ENV_KEYS.map((k) => `MEMORYLAYER_${k}`), // legacy, still honored
|
|
33
36
|
]);
|
|
37
|
+
/**
|
|
38
|
+
* Read `WAYFORM_<name>`, falling back to the legacy `MEMORYLAYER_<name>`.
|
|
39
|
+
*
|
|
40
|
+
* Both are honored indefinitely, not for a deprecation window: hook configs
|
|
41
|
+
* already written into collaborators' repos reference the old names, and a
|
|
42
|
+
* rename that silently stops loading config is exactly the failure mode that
|
|
43
|
+
* looks like "the tool just stopped working" with no error.
|
|
44
|
+
*/
|
|
45
|
+
export function envVar(name) {
|
|
46
|
+
return process.env[`WAYFORM_${name}`] ?? process.env[`MEMORYLAYER_${name}`];
|
|
47
|
+
}
|
|
48
|
+
/** Hook env file names, newest first. The legacy name is read forever — see envVar(). */
|
|
49
|
+
export const HOOK_ENV_FILE = ".wayform-hook.env";
|
|
50
|
+
export const LEGACY_HOOK_ENV_FILE = ".memorylayer-hook.env";
|
|
51
|
+
export const HOOK_ENV_FILES = [HOOK_ENV_FILE, LEGACY_HOOK_ENV_FILE];
|
|
34
52
|
/**
|
|
35
53
|
* Load `.memorylayer-hook.env` (KEY=VALUE lines) from `cwd` into process.env,
|
|
36
54
|
* for allowlisted keys NOT already set. This replaces the old bash launcher's
|
|
@@ -43,14 +61,18 @@ const HOOK_ENV_ALLOWLIST = new Set([
|
|
|
43
61
|
* the file is absent or unreadable — never throws.
|
|
44
62
|
*/
|
|
45
63
|
export function loadHookEnv(cwd = process.cwd()) {
|
|
46
|
-
const file = path.join(cwd, ".memorylayer-hook.env");
|
|
47
64
|
let text;
|
|
48
|
-
|
|
49
|
-
|
|
65
|
+
for (const name of HOOK_ENV_FILES) {
|
|
66
|
+
try {
|
|
67
|
+
text = fs.readFileSync(path.join(cwd, name), "utf8");
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
continue; // try the legacy name before giving up
|
|
72
|
+
}
|
|
50
73
|
}
|
|
51
|
-
|
|
74
|
+
if (text === undefined)
|
|
52
75
|
return; // absent/unreadable — nothing to load.
|
|
53
|
-
}
|
|
54
76
|
for (const rawLine of text.split(/\r?\n/)) {
|
|
55
77
|
const line = rawLine.trim();
|
|
56
78
|
if (!line || line.startsWith("#"))
|
|
@@ -116,7 +138,7 @@ export function cloneKey(repoUrl) {
|
|
|
116
138
|
* Resolution: MEMORYLAYER_HOME > $XDG_DATA_HOME/memorylayer > ~/.local/share/memorylayer.
|
|
117
139
|
*/
|
|
118
140
|
function dataHome() {
|
|
119
|
-
const explicit = process.env.MEMORYLAYER_HOME?.trim();
|
|
141
|
+
const explicit = process.env.WAYFORM_HOME?.trim() || process.env.MEMORYLAYER_HOME?.trim();
|
|
120
142
|
if (explicit)
|
|
121
143
|
return explicit;
|
|
122
144
|
const xdg = process.env.XDG_DATA_HOME?.trim();
|
|
@@ -137,11 +159,8 @@ export function defaultProject(cwd = process.cwd()) {
|
|
|
137
159
|
return path.basename(cwd) || "unknown";
|
|
138
160
|
}
|
|
139
161
|
export function loadConfig() {
|
|
140
|
-
const
|
|
141
|
-
const
|
|
142
|
-
undefined;
|
|
143
|
-
const gatewayToken = process.env.MEMORYLAYER_GATEWAY_TOKEN?.trim() || undefined;
|
|
144
|
-
const hasGateway = Boolean(gatewayUrl && gatewayToken);
|
|
162
|
+
const gatewayUrl = envVar("GATEWAY_URL")?.trim().replace(/\/+$/, "") || undefined;
|
|
163
|
+
const hasGateway = Boolean(gatewayUrl);
|
|
145
164
|
// Gateway-only members have no local clone. CONTEXT_REPO_URL is optional when a
|
|
146
165
|
// gateway is configured; without a gateway it stays required (local-only mode).
|
|
147
166
|
// We use "" as a clear "no clone" sentinel rather than making repoUrl/repoPath
|
|
@@ -155,7 +174,9 @@ export function loadConfig() {
|
|
|
155
174
|
? process.env.CONTEXT_REPO_PATH?.trim() ||
|
|
156
175
|
path.join(dataHome(), "clones", cloneKey(repoUrl))
|
|
157
176
|
: "";
|
|
158
|
-
const
|
|
177
|
+
const author = envVar("AUTHOR")?.trim() ||
|
|
178
|
+
(repoUrl ? required("WAYFORM_AUTHOR") : "GitHub");
|
|
179
|
+
const rawBudget = Number(envVar("READ_BUDGET_TOKENS"));
|
|
159
180
|
const readBudgetTokens = Number.isFinite(rawBudget) && rawBudget > 0
|
|
160
181
|
? rawBudget
|
|
161
182
|
: DEFAULT_BUDGET_TOKENS;
|
|
@@ -163,12 +184,13 @@ export function loadConfig() {
|
|
|
163
184
|
repoUrl,
|
|
164
185
|
repoPath,
|
|
165
186
|
author,
|
|
166
|
-
authorEmail:
|
|
167
|
-
|
|
168
|
-
|
|
187
|
+
authorEmail: envVar("AUTHOR_EMAIL")?.trim() ||
|
|
188
|
+
(repoUrl
|
|
189
|
+
? `${author.replace(/\s+/g, ".").toLowerCase()}@memorylayer.local`
|
|
190
|
+
: "github@users.noreply.github.com"),
|
|
191
|
+
autoPush: (envVar("AUTO_PUSH")?.trim() || "true") !== "false",
|
|
169
192
|
readBudgetTokens,
|
|
170
193
|
gatewayUrl,
|
|
171
|
-
gatewayToken,
|
|
172
194
|
};
|
|
173
195
|
}
|
|
174
196
|
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AA0B1D,SAAS,QAAQ,CAAC,IAAY;IAC5B,MAAM,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC5B,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,E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GAAG,MAAM,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC,CAAC;IACvD,MAAM,gBAAgB,GACpB,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,SAAS,GAAG,CAAC;QACzC,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,qBAAqB,CAAC;IAE5B,OAAO;QACL,OAAO;QACP,QAAQ;QACR,MAAM;QACN,WAAW,EACT,MAAM,CAAC,cAAc,CAAC,EAAE,IAAI,EAAE;YAC9B,CAAC,OAAO;gBACN,CAAC,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,oBAAoB;gBAClE,CAAC,CAAC,iCAAiC,CAAC;QACxC,QAAQ,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,IAAI,MAAM,CAAC,KAAK,OAAO;QAC7D,gBAAgB;QAChB,UAAU;KACX,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { Entry } from "@napi-rs/keyring";
|
|
4
|
+
const SERVICE = "wayform-oauth";
|
|
5
|
+
const BACKEND_ERROR = "Wayform could not access this operating system's credential store. " +
|
|
6
|
+
"Configure Keychain, Secret Service, or Credential Manager and run `wayform login` again.";
|
|
7
|
+
function readFile(file) {
|
|
8
|
+
try {
|
|
9
|
+
return JSON.parse(fs.readFileSync(file, "utf8"));
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return {};
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function writeFile(file, values) {
|
|
16
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
17
|
+
fs.writeFileSync(file, JSON.stringify(values), { mode: 0o600 });
|
|
18
|
+
try {
|
|
19
|
+
fs.chmodSync(file, 0o600);
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
// Windows does not expose POSIX permission bits.
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function testFileCredentialStore(file) {
|
|
26
|
+
return {
|
|
27
|
+
get(account) {
|
|
28
|
+
return readFile(file)[account] ?? null;
|
|
29
|
+
},
|
|
30
|
+
set(account, secret) {
|
|
31
|
+
const values = readFile(file);
|
|
32
|
+
values[account] = secret;
|
|
33
|
+
writeFile(file, values);
|
|
34
|
+
},
|
|
35
|
+
delete(account) {
|
|
36
|
+
const values = readFile(file);
|
|
37
|
+
delete values[account];
|
|
38
|
+
writeFile(file, values);
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function credentialError(error) {
|
|
43
|
+
return new Error(BACKEND_ERROR, { cause: error });
|
|
44
|
+
}
|
|
45
|
+
export function createCredentialStore(env = process.env, entryFactory = (service, account) => new Entry(service, account)) {
|
|
46
|
+
const testFile = env.WAYFORM_KEYCHAIN_FILE?.trim();
|
|
47
|
+
if (env.NODE_ENV === "test" && testFile) {
|
|
48
|
+
return testFileCredentialStore(testFile);
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
get(account) {
|
|
52
|
+
try {
|
|
53
|
+
return entryFactory(SERVICE, account).getPassword();
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
throw credentialError(error);
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
set(account, secret) {
|
|
60
|
+
try {
|
|
61
|
+
entryFactory(SERVICE, account).setPassword(secret);
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
throw credentialError(error);
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
delete(account) {
|
|
68
|
+
try {
|
|
69
|
+
entryFactory(SERVICE, account).deletePassword();
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
throw credentialError(error);
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=credential-store.js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