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.
Files changed (54) hide show
  1. package/README.md +145 -54
  2. package/dist/cli.js +25 -10
  3. package/dist/cli.js.map +1 -1
  4. package/dist/config.js +46 -24
  5. package/dist/config.js.map +1 -1
  6. package/dist/credential-store.js +77 -0
  7. package/dist/credential-store.js.map +1 -0
  8. package/dist/doctor.js +114 -32
  9. package/dist/doctor.js.map +1 -1
  10. package/dist/frontmatter.js +25 -0
  11. package/dist/frontmatter.js.map +1 -1
  12. package/dist/guard-hook.js +94 -0
  13. package/dist/guard-hook.js.map +1 -0
  14. package/dist/hook-clients.js +20 -34
  15. package/dist/hook-clients.js.map +1 -1
  16. package/dist/hook.js +3 -3
  17. package/dist/hook.js.map +1 -1
  18. package/dist/index.js +2 -2
  19. package/dist/index.js.map +1 -1
  20. package/dist/init-configs.js +84 -31
  21. package/dist/init-configs.js.map +1 -1
  22. package/dist/init-env.js +18 -11
  23. package/dist/init-env.js.map +1 -1
  24. package/dist/init-remote.js +186 -98
  25. package/dist/init-remote.js.map +1 -1
  26. package/dist/init.js +22 -9
  27. package/dist/init.js.map +1 -1
  28. package/dist/keychain.js +19 -0
  29. package/dist/keychain.js.map +1 -0
  30. package/dist/metrics.js +1 -1
  31. package/dist/metrics.js.map +1 -1
  32. package/dist/oauth-login.js +197 -0
  33. package/dist/oauth-login.js.map +1 -0
  34. package/dist/oauth-session.js +122 -0
  35. package/dist/oauth-session.js.map +1 -0
  36. package/dist/prompt-hook.js +5 -4
  37. package/dist/prompt-hook.js.map +1 -1
  38. package/dist/remote-read.js +42 -13
  39. package/dist/remote-read.js.map +1 -1
  40. package/dist/session-prompt.js +33 -8
  41. package/dist/session-prompt.js.map +1 -1
  42. package/dist/space-create.js +17 -201
  43. package/dist/space-create.js.map +1 -1
  44. package/dist/store.js +3 -2
  45. package/dist/store.js.map +1 -1
  46. package/dist/token-budget.js +7 -0
  47. package/dist/token-budget.js.map +1 -1
  48. package/dist/token.js +36 -0
  49. package/dist/token.js.map +1 -0
  50. package/package.json +3 -2
  51. package/dist/review-prompt.js +0 -25
  52. package/dist/review-prompt.js.map +0 -1
  53. package/dist/stop-hook.js +0 -45
  54. package/dist/stop-hook.js.map +0 -1
@@ -7,8 +7,8 @@
7
7
  * - idempotent: our command appears at most once on re-run (matched by command
8
8
  * substring / server key).
9
9
  *
10
- * Commands invoke the globally-installed `memorylayer` binary (fast, offline),
11
- * NOT a bash launcher or npx. All are secret-free: `memorylayer` self-loads
10
+ * Commands invoke the globally-installed `wayform` binary (fast, offline),
11
+ * NOT a bash launcher or npx. All are secret-free: `wayform` self-loads
12
12
  * `.memorylayer-hook.env` from the project cwd at runtime.
13
13
  */
14
14
  import { createHash } from "node:crypto";
@@ -19,7 +19,7 @@ const asArray = (v) => (Array.isArray(v) ? [...v] : []);
19
19
  * for this event. `marker` MUST be the stable `<subcommand> <client>` token
20
20
  * (e.g. "hook cursor", "stop-review claude-code") — NOT a whole command string —
21
21
  * so an equivalent hook that invokes the tool via a different form (the dogfood
22
- * `node ./dist/cli.js hook cursor`, an absolute path, or `npx memorylayer …`) is
22
+ * `node ./dist/cli.js hook cursor`, an absolute path, or `npx wayform …`) is
23
23
  * still recognized and re-running `init` stays idempotent instead of appending a
24
24
  * duplicate hook that would fire the read/review twice per turn.
25
25
  */
@@ -27,7 +27,7 @@ function addOnce(list, marker, entry) {
27
27
  const present = list.some((item) => JSON.stringify(item).includes(marker));
28
28
  return present ? list : [...list, entry];
29
29
  }
30
- export function mergeClaudeSettings(existing, bin = "memorylayer") {
30
+ export function mergeClaudeSettings(existing, bin = "wayform") {
31
31
  const root = asObject(existing);
32
32
  const hooks = asObject(root.hooks);
33
33
  hooks.SessionStart = addOnce(asArray(hooks.SessionStart), "hook claude-code", {
@@ -45,10 +45,20 @@ export function mergeClaudeSettings(existing, bin = "memorylayer") {
45
45
  },
46
46
  ],
47
47
  });
48
+ // PreToolUse guard (Phase E): matcher limits the hook to mutating tools so
49
+ // reads never pay for a network round trip.
50
+ hooks.PreToolUse = addOnce(asArray(hooks.PreToolUse), "guard claude-code", {
51
+ matcher: "Edit|Write|Bash",
52
+ hooks: [
53
+ // 10s wrapper > GUARD_TIMEOUT_MS (6s) + node startup; the hook itself
54
+ // fails open long before the wrapper would kill it.
55
+ { type: "command", command: `${bin} guard claude-code`, timeout: 10 },
56
+ ],
57
+ });
48
58
  root.hooks = hooks;
49
59
  return root;
50
60
  }
51
- export function mergeCursorHooks(existing, bin = "memorylayer") {
61
+ export function mergeCursorHooks(existing, bin = "wayform") {
52
62
  const root = asObject(existing);
53
63
  root.version = 1;
54
64
  const hooks = asObject(root.hooks);
@@ -60,7 +70,7 @@ export function mergeCursorHooks(existing, bin = "memorylayer") {
60
70
  root.hooks = hooks;
61
71
  return root;
62
72
  }
63
- export function mergeCodexHooks(existing, bin = "memorylayer") {
73
+ export function mergeCodexHooks(existing, bin = "wayform") {
64
74
  const root = asObject(existing);
65
75
  const hooks = asObject(root.hooks);
66
76
  hooks.SessionStart = addOnce(asArray(hooks.SessionStart), "hook codex", {
@@ -157,52 +167,95 @@ export function mergeCodexTrustToml(existing, entries) {
157
167
  export function mergeMcpJson(existing) {
158
168
  const root = asObject(existing);
159
169
  const servers = asObject(root.mcpServers);
160
- servers.memorylayer = { command: "memorylayer", args: [], env: {} };
170
+ servers.wayform = { command: "wayform", args: [], env: {} };
161
171
  root.mcpServers = servers;
162
172
  return root;
163
173
  }
164
174
  /**
165
175
  * Project-scoped Codex MCP block for the LOCAL (self-hosted clone) tier, written
166
- * to `.codex/config.toml`. Secret-free stdio server: `command = "memorylayer"`
176
+ * to `.codex/config.toml`. Secret-free stdio server: `command = "wayform"`
167
177
  * self-loads `.memorylayer-hook.env` at runtime. Codex applies project config
168
178
  * for trusted repos, so this needs no global paste.
169
179
  */
170
- export const CODEX_MCP_TOML = `[mcp_servers.memorylayer]
171
- command = "memorylayer"
180
+ export const CODEX_MCP_TOML = `[mcp_servers.wayform]
181
+ command = "wayform"
172
182
  args = []
173
183
  `;
174
184
  /**
175
- * Native HTTP MCP for a hosted member, written into a project's `.cursor/mcp.json`.
176
- * This file carries the member token, so `init --remote` MUST gitignore it — it is
177
- * per-member and never committed. Non-clobbering + idempotent on `wayform`.
185
+ * Native HTTP MCP for a hosted member. No token in the file — the client runs
186
+ * OAuth. Used for Cursor `.cursor/mcp.json` and Claude Code project-scope
187
+ * `.mcp.json` (never `~/.cursor/mcp.json` or `--scope user`).
188
+ *
189
+ * `type` is REQUIRED, not decorative: Claude Code skips a `url` entry that
190
+ * omits it ("has a url but no type; add type: http"), so a URL-only file
191
+ * silently yields no tools. Cursor ignores the extra key.
178
192
  */
179
- export function mergeCursorRemoteMcp(existing, gatewayUrl, token) {
193
+ export function mergeRemoteHttpMcp(existing, gatewayUrl) {
180
194
  const root = asObject(existing);
181
195
  const servers = asObject(root.mcpServers);
182
- servers.wayform = {
183
- url: `${gatewayUrl}/mcp`,
184
- headers: { Authorization: `Bearer ${token}` },
185
- };
196
+ servers.wayform = { type: "http", url: `${gatewayUrl}/mcp` };
186
197
  root.mcpServers = servers;
187
198
  return root;
188
199
  }
200
+ export const mergeCursorRemoteMcp = mergeRemoteHttpMcp;
189
201
  /**
190
- * Project-scoped Codex MCP block for a HOSTED (gateway) member, written to
191
- * `.codex/config.toml`. Codex 0.144+ speaks native streamable-HTTP and applies
192
- * project config for trusted repos, so no global paste and no `mcp-remote`
193
- * bridge are needed. The member token is inlined as a literal Authorization
194
- * header via `http_headers` — the same pattern as `.cursor/mcp.json` — because
195
- * the env-var alternative (`bearer_token_env_var`) requires exporting the token
196
- * before every launch and fails SILENTLY for IDE-launched Codex (the MCP client
197
- * never initializes and the model just sees no tools). Codex rejects a literal
198
- * `bearer_token` field for HTTP servers; `http_headers` is the sanctioned
199
- * literal path. This file therefore CARRIES THE TOKEN: `init --remote` MUST
200
- * gitignore it and harden it to 0600.
202
+ * Project-scoped Codex MCP block for a HOSTED (gateway) member. Lives in
203
+ * `.codex/config.toml` (trusted project only) — not `~/.codex/config.toml`.
201
204
  */
202
- export function codexRemoteConfigToml(gatewayUrl, token) {
205
+ export function codexRemoteConfigToml(gatewayUrl) {
203
206
  return `[mcp_servers.wayform]
204
207
  url = "${gatewayUrl}/mcp"
205
- http_headers = { Authorization = "Bearer ${token}" }
208
+ auth = "oauth"
206
209
  `;
207
210
  }
211
+ /**
212
+ * Replace only Codex's project-scoped Wayform table. Keeping the operation
213
+ * text-based preserves comments, model settings, trust, and unrelated MCP
214
+ * servers without introducing a TOML serializer that rewrites user config.
215
+ */
216
+ export function mergeCodexRemoteConfigToml(existing, gatewayUrl) {
217
+ const replacement = codexRemoteConfigToml(gatewayUrl);
218
+ const header = /^\[mcp_servers\.wayform\]\s*$/m;
219
+ const found = header.exec(existing);
220
+ if (!found) {
221
+ let out = existing;
222
+ if (out && !out.endsWith("\n"))
223
+ out += "\n";
224
+ if (out && !out.endsWith("\n\n"))
225
+ out += "\n";
226
+ return out + replacement;
227
+ }
228
+ const nextHeader = /^\[/gm;
229
+ nextHeader.lastIndex = found.index + found[0].length;
230
+ const next = nextHeader.exec(existing);
231
+ const end = next?.index ?? existing.length;
232
+ const suffix = existing.slice(end);
233
+ return (existing.slice(0, found.index) + replacement + (suffix ? "\n" : "") + suffix);
234
+ }
235
+ /**
236
+ * Devin CLI project MCP (`.devin/mcp_config.json`). Not `--scope user` /
237
+ * `~/.config/devin/mcp_config.json`, which would load in every repo.
238
+ */
239
+ export function mergeDevinRemoteMcp(existing, gatewayUrl) {
240
+ const root = asObject(existing);
241
+ const servers = asObject(root.mcpServers);
242
+ servers.wayform = {
243
+ url: `${gatewayUrl}/mcp`,
244
+ transport: "http",
245
+ };
246
+ root.mcpServers = servers;
247
+ return root;
248
+ }
249
+ /**
250
+ * Antigravity workspace MCP (`.agents/mcp_config.json`). Uses `serverUrl`
251
+ * per Google's schema. Not `~/.gemini/config/mcp_config.json` (global).
252
+ * DCR OAuth: URL only, no headers.
253
+ */
254
+ export function mergeAntigravityRemoteMcp(existing, gatewayUrl) {
255
+ const root = asObject(existing);
256
+ const servers = asObject(root.mcpServers);
257
+ servers.wayform = { serverUrl: `${gatewayUrl}/mcp` };
258
+ root.mcpServers = servers;
259
+ return root;
260
+ }
208
261
  //# sourceMappingURL=init-configs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"init-configs.js","sourceRoot":"","sources":["../src/init-configs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAIzC,MAAM,QAAQ,GAAG,CAAC,CAAU,EAAQ,EAAE,CACpC,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,GAAI,CAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AAC5E,MAAM,OAAO,GAAG,CAAC,CAAU,EAAa,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAE5E;;;;;;;;GAQG;AACH,SAAS,OAAO,CAAC,IAAe,EAAE,MAAc,EAAE,KAAc;IAC9D,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;IAC3E,OAAO,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,mBAAmB,CACjC,QAAiB,EACjB,MAAc,aAAa;IAE3B,MAAM,IAAI,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAChC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AO,GAAG;QAChB,GAAG,EAAE,GAAG,UAAU,MAAM;QACxB,SAAS,EAAE,MAAM;KAClB,CAAC;IACF,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC;IAC1B,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CACvC,QAAiB,EACjB,UAAkB;IAElB,MAAM,IAAI,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAChC,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC1C,OAAO,CAAC,OAAO,GAAG,EAAE,SAAS,EAAE,GAAG,UAAU,MAAM,EAAE,CAAC;IACrD,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC;IAC1B,OAAO,IAAI,CAAC;AACd,CAAC"}
package/dist/init-env.js CHANGED
@@ -30,22 +30,19 @@ export function buildHookEnv(v) {
30
30
  "# Wayform per-user hook config — gitignored. Do NOT commit.",
31
31
  "# Written by `wayform init`. Your identity + context-repo access.",
32
32
  `CONTEXT_REPO_URL=${v.repoUrl}`,
33
- `MEMORYLAYER_AUTHOR=${v.author}`,
34
- `MEMORYLAYER_AUTHOR_EMAIL=${v.email}`,
35
- `MEMORYLAYER_PROJECT=${v.project}`,
33
+ `WAYFORM_AUTHOR=${v.author}`,
34
+ `WAYFORM_AUTHOR_EMAIL=${v.email}`,
35
+ `WAYFORM_PROJECT=${v.project}`,
36
36
  "",
37
37
  ].join("\n");
38
38
  }
39
- /** Contents of `.memorylayer-hook.env` for a HOSTED (gateway) member — gitignored. */
39
+ /** Contents of `.wayform-hook.env` for a HOSTED (gateway) member. */
40
40
  export function buildRemoteHookEnv(v) {
41
41
  return [
42
- "# Wayform per-user hook config — gitignored. Do NOT commit.",
43
- "# Written by `wayform init --remote`. Hosted (gateway) member — no local clone.",
44
- `MEMORYLAYER_GATEWAY_URL=${v.gatewayUrl}`,
45
- `MEMORYLAYER_GATEWAY_TOKEN=${v.token}`,
46
- `MEMORYLAYER_PROJECT=${v.project}`,
47
- `MEMORYLAYER_AUTHOR=${v.author}`,
48
- `MEMORYLAYER_AUTHOR_EMAIL=${v.email}`,
42
+ "# Wayform hosted hook config — project scoped and credential-free.",
43
+ "# Written by `wayform init --remote`. Safe to commit for teammates.",
44
+ `WAYFORM_GATEWAY_URL=${v.gatewayUrl}`,
45
+ `WAYFORM_PROJECT=${v.project}`,
49
46
  "",
50
47
  ].join("\n");
51
48
  }
@@ -97,4 +94,14 @@ export function ensureGitignore(existing, entries) {
97
94
  }
98
95
  return out;
99
96
  }
97
+ /** Remove exact obsolete ignore entries while preserving all unrelated lines. */
98
+ export function removeGitignoreEntries(existing, entries) {
99
+ const removed = new Set(entries);
100
+ const lines = existing
101
+ .split(/\r?\n/)
102
+ .filter((line) => !removed.has(line.trim()));
103
+ while (lines.length > 0 && lines.at(-1) === "")
104
+ lines.pop();
105
+ return lines.length > 0 ? `${lines.join("\n")}\n` : "";
106
+ }
100
107
  //# sourceMappingURL=init-env.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"init-env.js","sourceRoot":"","sources":["../src/init-env.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExE;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC,IAAY,EAAE,QAAgB;IAC5D,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IAClD,gBAAgB,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,IAAI,CAAC;QACH,EAA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GAAG,CAAC,OAAO,CAAC,CAAC;IACjC,MAAM,KAAK,GAAG,QAAQ;SACnB,KAAK,CAAC,OAAO,CAAC;SACd,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAC/C,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE;QAAE,KAAK,CAAC,GAAG,EAAE,CAAC;IAC5D,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;AACzD,CAAC"}
@@ -1,17 +1,19 @@
1
+ import { HOOK_ENV_FILE, LEGACY_HOOK_ENV_FILE } from "./config.js";
1
2
  /**
2
3
  * `wayform init --remote` — wire a HOSTED (gateway) member into the current
3
- * project. Same LOUD, idempotent posture as local `init`, but writes gateway
4
- * creds + native HTTP MCP instead of a local clone. Token never touches a
5
- * committed file (gitignored env + gitignored .cursor/mcp.json and
6
- * .codex/config.toml + Claude's user-scoped ~/.claude.json).
4
+ * project. Same LOUD, idempotent posture as local `init`, but writes a gateway
5
+ * URL + native HTTP MCP instead of a local clone. No member token is written
6
+ * anywhere: selected clients run OAuth; hooks use `wayform login` + keychain.
7
+ * `--clients` picks which vendor folders to write so unused tools are not dumped.
7
8
  */
8
9
  import { execFileSync } from "node:child_process";
9
10
  import fs from "node:fs";
10
11
  import path from "node:path";
11
12
  import readline from "node:readline/promises";
12
13
  import { stdin as input, stdout as output } from "node:process";
13
- import { mergeClaudeSettings, mergeCursorHooks, mergeCodexHooks, mergeCursorRemoteMcp, codexRemoteConfigToml, } from "./init-configs.js";
14
- import { buildRemoteHookEnv, gitConfigDefault, ensureGitignore, writeSecretFile, hardenSecretFile, trustCodexHooks, } from "./init-env.js";
14
+ import { mergeClaudeSettings, mergeCursorHooks, mergeCodexHooks, mergeRemoteHttpMcp, mergeDevinRemoteMcp, mergeAntigravityRemoteMcp, mergeCodexRemoteConfigToml, } from "./init-configs.js";
15
+ import { buildRemoteHookEnv, ensureGitignore, removeGitignoreEntries, writeSecretFile, trustCodexHooks, } from "./init-env.js";
16
+ import { DEFAULT_GATEWAY_URL } from "./oauth-login.js";
15
17
  const defaultRunner = (cmd, args) => {
16
18
  // Bounded + non-interactive: a hanging or prompting `claude` must never freeze
17
19
  // init. On timeout/ENOENT this throws → the caller falls open to a printed
@@ -38,26 +40,22 @@ const defaultRunner = (cmd, args) => {
38
40
  throw lastErr;
39
41
  };
40
42
  /**
41
- * Register the gateway as a project-scoped (`--scope local`) HTTP MCP server for
42
- * Claude Code. `--scope local` stores config in ~/.claude.json (NOT the repo), so
43
- * it is project-scoped AND token-safe. Non-fatal: if `claude` is absent the
44
- * returned command is printed for the member to run by hand.
43
+ * Recommended Claude Code CLI if someone adds the server by hand.
44
+ * `--scope project` writes `.mcp.json` in this repo. Never `--scope user`
45
+ * (that would load Wayform in every folder they open).
45
46
  */
46
- export function registerClaudeCodeMcp(gatewayUrl, token, run = defaultRunner) {
47
+ export function registerClaudeCodeMcp(gatewayUrl, run = defaultRunner) {
47
48
  const args = [
48
49
  "mcp",
49
50
  "add",
50
51
  "--transport",
51
52
  "http",
52
53
  "--scope",
53
- "local",
54
+ "project",
54
55
  "wayform",
55
56
  `${gatewayUrl}/mcp`,
56
- "--header",
57
- `Authorization: Bearer ${token}`,
58
57
  ];
59
- // Shell-quote the header arg so the printed fallback is copy-paste safe.
60
- const command = `claude ${args.map((a) => (a.includes(" ") ? `"${a}"` : a)).join(" ")}`;
58
+ const command = `claude ${args.join(" ")}`;
61
59
  try {
62
60
  run("claude", args);
63
61
  return { ok: true, command };
@@ -66,6 +64,47 @@ export function registerClaudeCodeMcp(gatewayUrl, token, run = defaultRunner) {
66
64
  return { ok: false, command };
67
65
  }
68
66
  }
67
+ const CLIENT_ALIASES = {
68
+ cursor: "cursor",
69
+ claude: "claude",
70
+ "claude-code": "claude",
71
+ codex: "codex",
72
+ devin: "devin",
73
+ antigravity: "antigravity",
74
+ agy: "antigravity",
75
+ };
76
+ export function parseRemoteClients(raw) {
77
+ const out = [];
78
+ for (const part of raw.split(/[\s,]+/).filter(Boolean)) {
79
+ const id = CLIENT_ALIASES[part.toLowerCase()];
80
+ if (!id) {
81
+ throw new Error(`Unknown client "${part}". Use: cursor, claude, codex, devin, antigravity`);
82
+ }
83
+ if (!out.includes(id))
84
+ out.push(id);
85
+ }
86
+ return out;
87
+ }
88
+ /** Clients that already have a project folder/file in this repo. */
89
+ export function detectExistingClients(cwd) {
90
+ const found = [];
91
+ if (fs.existsSync(path.join(cwd, ".cursor")))
92
+ found.push("cursor");
93
+ if (fs.existsSync(path.join(cwd, ".claude")) ||
94
+ fs.existsSync(path.join(cwd, ".mcp.json"))) {
95
+ found.push("claude");
96
+ }
97
+ if (fs.existsSync(path.join(cwd, ".codex")))
98
+ found.push("codex");
99
+ if (fs.existsSync(path.join(cwd, ".devin")))
100
+ found.push("devin");
101
+ if (fs.existsSync(path.join(cwd, ".agents")))
102
+ found.push("antigravity");
103
+ return found;
104
+ }
105
+ function wants(clients, id) {
106
+ return clients.includes(id);
107
+ }
69
108
  const flag = (args, name) => {
70
109
  const i = args.indexOf(`--${name}`);
71
110
  return i >= 0 && i + 1 < args.length ? args[i + 1] : undefined;
@@ -95,39 +134,14 @@ function writeText(cwd, rel, text) {
95
134
  fs.writeFileSync(file, text);
96
135
  console.log(` wrote ${rel}`);
97
136
  }
98
- /**
99
- * Exchange a team invite for this member's own personal token via the
100
- * gateway's public /join. The token is minted server-side and returned
101
- * exactly once — it exists nowhere but this process until init writes it
102
- * to the 0600 secret files.
103
- */
104
- export async function joinGateway(gatewayUrl, invite, author, email, fetchImpl = fetch) {
105
- const res = await fetchImpl(`${gatewayUrl}/join`, {
106
- method: "POST",
107
- headers: { "content-type": "application/json" },
108
- body: JSON.stringify({ invite, author, authorEmail: email }),
109
- });
110
- if (!res.ok) {
111
- const detail = await res.text();
112
- throw new Error(`invite join failed (${res.status}): ${detail}`);
113
- }
114
- const { token } = (await res.json());
115
- return token;
116
- }
117
137
  export async function runInitRemote(args) {
118
138
  const cwd = process.cwd();
119
139
  if (!fs.existsSync(path.join(cwd, ".git"))) {
120
140
  throw new Error("Not a git repository — cd to your project's root and re-run. Nothing was written.");
121
141
  }
122
- const gatewayUrl = (flag(args, "gateway") ?? "").replace(/\/+$/, "");
123
- let token = flag(args, "token") ?? "";
124
- const inviteCode = flag(args, "invite") ?? "";
125
- if (!gatewayUrl || (!token && !inviteCode)) {
126
- throw new Error("wayform init --remote requires --gateway <url> and --token <mlk_...> or --invite <wfi_...>");
127
- }
128
- // Identity (attribution/display; the gateway is authoritative on write).
142
+ const gatewayUrl = (flag(args, "gateway") ?? DEFAULT_GATEWAY_URL).replace(/\/+$/, "");
129
143
  const useDefaults = has(args, "yes");
130
- const rl = useDefaults || (flag(args, "author") && flag(args, "email"))
144
+ const rl = useDefaults
131
145
  ? undefined
132
146
  : readline.createInterface({ input, output });
133
147
  const ask = async (q, def) => {
@@ -136,70 +150,144 @@ export async function runInitRemote(args) {
136
150
  const a = (await rl.question(def ? `${q} [${def}]: ` : `${q}: `)).trim();
137
151
  return a || def;
138
152
  };
139
- const author = flag(args, "author") ??
140
- (await ask("Author name", gitConfigDefault("user.name")));
141
- const email = flag(args, "email") ??
142
- (await ask("Author email", gitConfigDefault("user.email")));
143
153
  const project = flag(args, "project") ?? path.basename(cwd);
144
- rl?.close();
145
- if (!token) {
146
- token = await joinGateway(gatewayUrl, inviteCode, author, email);
147
- console.log(" joined via invite — minted your personal member token");
148
- }
149
- // --- Project tier: session + (Claude) UserPromptSubmit hooks ---
150
- writeJson(cwd, ".claude/settings.json", mergeClaudeSettings(readJson(path.join(cwd, ".claude/settings.json")), "wayform"));
151
- writeJson(cwd, ".cursor/hooks.json", mergeCursorHooks(readJson(path.join(cwd, ".cursor/hooks.json")), "wayform"));
152
- const codexHooks = mergeCodexHooks(readJson(path.join(cwd, ".codex/hooks.json")), "wayform");
153
- writeJson(cwd, ".codex/hooks.json", codexHooks);
154
- // User tier: codex requires per-hook trust in ~/.codex/config.toml and
155
- // silently skips untrusted hooks — grant it for the hooks we just wrote.
156
- trustCodexHooks(cwd, codexHooks);
157
- // --- Cursor native HTTP MCP (gitignored — carries the token) ---
158
- writeJson(cwd, ".cursor/mcp.json", mergeCursorRemoteMcp(readJson(path.join(cwd, ".cursor/mcp.json")), gatewayUrl, token));
159
- // Token-bearing: tighten to owner-only (writeJson creates at umask default).
160
- hardenSecretFile(path.join(cwd, ".cursor/mcp.json"));
161
- // --- Codex native HTTP MCP (project-scoped, gitignored — carries the token) ---
162
- writeText(cwd, ".codex/config.toml", codexRemoteConfigToml(gatewayUrl, token));
163
- hardenSecretFile(path.join(cwd, ".codex/config.toml"));
164
- // --- User tier: gitignored gateway env (hosted-only, no CONTEXT_REPO_URL) ---
165
- const envFile = path.join(cwd, ".memorylayer-hook.env");
166
- if (fs.existsSync(envFile) && !has(args, "force")) {
167
- hardenSecretFile(envFile); // retro-tighten a pre-existing 0644 file
168
- console.log(" .memorylayer-hook.env exists — leaving it (use --force to rewrite).");
154
+ const clientsFlag = flag(args, "clients");
155
+ let clients;
156
+ if (clientsFlag !== undefined) {
157
+ clients = parseRemoteClients(clientsFlag);
158
+ }
159
+ else if (rl) {
160
+ const existing = detectExistingClients(cwd);
161
+ const picked = await ask("Clients to wire (cursor, claude, codex, devin, antigravity)", existing.join(","));
162
+ clients = picked ? parseRemoteClients(picked) : existing;
169
163
  }
170
164
  else {
171
- writeSecretFile(envFile, buildRemoteHookEnv({ gatewayUrl, token, project, author, email }));
172
- console.log(" wrote .memorylayer-hook.env (gitignored)");
165
+ clients = detectExistingClients(cwd);
166
+ }
167
+ rl?.close();
168
+ if (wants(clients, "claude")) {
169
+ writeJson(cwd, ".claude/settings.json", mergeClaudeSettings(readJson(path.join(cwd, ".claude/settings.json")), "wayform"));
170
+ writeJson(cwd, ".mcp.json", mergeRemoteHttpMcp(readJson(path.join(cwd, ".mcp.json")), gatewayUrl));
171
+ }
172
+ if (wants(clients, "cursor")) {
173
+ writeJson(cwd, ".cursor/hooks.json", mergeCursorHooks(readJson(path.join(cwd, ".cursor/hooks.json")), "wayform"));
174
+ writeJson(cwd, ".cursor/mcp.json", mergeRemoteHttpMcp(readJson(path.join(cwd, ".cursor/mcp.json")), gatewayUrl));
175
+ }
176
+ if (wants(clients, "codex")) {
177
+ const codexHooks = mergeCodexHooks(readJson(path.join(cwd, ".codex/hooks.json")), "wayform");
178
+ writeJson(cwd, ".codex/hooks.json", codexHooks);
179
+ trustCodexHooks(cwd, codexHooks);
180
+ const codexConfig = path.join(cwd, ".codex/config.toml");
181
+ const existing = fs.existsSync(codexConfig)
182
+ ? fs.readFileSync(codexConfig, "utf8")
183
+ : "";
184
+ writeText(cwd, ".codex/config.toml", mergeCodexRemoteConfigToml(existing, gatewayUrl));
185
+ }
186
+ if (wants(clients, "devin")) {
187
+ writeJson(cwd, ".devin/mcp_config.json", mergeDevinRemoteMcp(readJson(path.join(cwd, ".devin/mcp_config.json")), gatewayUrl));
188
+ }
189
+ if (wants(clients, "antigravity")) {
190
+ writeJson(cwd, ".agents/mcp_config.json", mergeAntigravityRemoteMcp(readJson(path.join(cwd, ".agents/mcp_config.json")), gatewayUrl));
173
191
  }
174
- // --- Gitignore secrets: env + local settings + the token-bearing cursor mcp ---
175
192
  const giPath = path.join(cwd, ".gitignore");
193
+ const initialGitignore = fs.existsSync(giPath)
194
+ ? fs.readFileSync(giPath, "utf8")
195
+ : "";
196
+ fs.writeFileSync(giPath, ensureGitignore(initialGitignore, [
197
+ `${HOOK_ENV_FILE}.bak`,
198
+ `${LEGACY_HOOK_ENV_FILE}.bak`,
199
+ ]));
200
+ const envFile = path.join(cwd, HOOK_ENV_FILE);
201
+ const legacyFile = path.join(cwd, LEGACY_HOOK_ENV_FILE);
202
+ const hasNew = fs.existsSync(envFile);
203
+ const hasLegacy = fs.existsSync(legacyFile);
204
+ const existingEnv = hasNew
205
+ ? fs.readFileSync(envFile, "utf8")
206
+ : hasLegacy
207
+ ? fs.readFileSync(legacyFile, "utf8")
208
+ : "";
209
+ // Credential-bearing shapes from before token-free onboarding. Both env-var
210
+ // prefixes are checked: the rename does not make an old token safe.
211
+ const credentialed = /(?:MEMORYLAYER|WAYFORM)_GATEWAY_TOKEN\s*=|(?:MEMORYLAYER|WAYFORM)_AUTHOR(?:_EMAIL)?\s*=|(?:mlk_|wfi_)[A-Za-z0-9_-]+/.test(existingEnv);
212
+ if (credentialed) {
213
+ writeSecretFile(`${envFile}.bak`, existingEnv);
214
+ writeSecretFile(envFile, buildRemoteHookEnv({ gatewayUrl, project }));
215
+ if (hasLegacy)
216
+ fs.rmSync(legacyFile, { force: true });
217
+ console.log(` migrated ${HOOK_ENV_FILE} (legacy file backed up to ${HOOK_ENV_FILE}.bak)`);
218
+ }
219
+ else if (hasLegacy && !hasNew) {
220
+ // Same contract, new file name. Rewrite rather than copy so the contents
221
+ // use the current var names too.
222
+ writeSecretFile(envFile, buildRemoteHookEnv({ gatewayUrl, project }));
223
+ fs.rmSync(legacyFile, { force: true });
224
+ console.log(` renamed ${LEGACY_HOOK_ENV_FILE} -> ${HOOK_ENV_FILE}`);
225
+ }
226
+ else if (existingEnv && !has(args, "force")) {
227
+ console.log(` ${HOOK_ENV_FILE} exists — leaving it (use --force to rewrite).`);
228
+ }
229
+ else {
230
+ writeSecretFile(envFile, buildRemoteHookEnv({ gatewayUrl, project }));
231
+ console.log(` wrote ${HOOK_ENV_FILE}`);
232
+ }
176
233
  const gi = fs.existsSync(giPath) ? fs.readFileSync(giPath, "utf8") : "";
177
- fs.writeFileSync(giPath, ensureGitignore(gi, [
178
- ".memorylayer-hook.env",
179
- ".claude/settings.local.json",
234
+ const cleaned = removeGitignoreEntries(gi, [
235
+ HOOK_ENV_FILE,
236
+ LEGACY_HOOK_ENV_FILE,
180
237
  ".cursor/mcp.json",
181
238
  ".codex/config.toml",
182
- ]));
239
+ ]);
240
+ const ignore = [
241
+ `${HOOK_ENV_FILE}.bak`,
242
+ `${LEGACY_HOOK_ENV_FILE}.bak`,
243
+ ];
244
+ if (wants(clients, "claude"))
245
+ ignore.push(".claude/settings.local.json");
246
+ fs.writeFileSync(giPath, ensureGitignore(cleaned, ignore));
183
247
  console.log(" updated .gitignore");
184
- // --- Claude Code native HTTP MCP (project-scoped, token in ~/.claude.json) ---
185
- const claude = registerClaudeCodeMcp(gatewayUrl, token);
186
- if (claude.ok) {
187
- console.log(" registered Claude Code MCP (claude mcp add --scope local)");
248
+ if (clients.length === 0) {
249
+ console.log("\nNo agent configs written. Pass --clients with the tools this team uses:");
250
+ console.log(" wayform init --remote --clients cursor,claude # example — only those folders");
188
251
  }
189
- else {
190
- console.log(" ! Couldn't find the Claude Code CLI — finish setup by running this in your project root:\n");
191
- console.log(` ${claude.command}\n`);
192
- console.log(' then restart Claude Code and check /mcp shows "wayform" connected.\n');
193
- }
194
- console.log("\nNext steps:");
195
- console.log(" 1. Verify the round trip:");
196
- console.log(" wayform doctor (gateway reachable + token accepted)");
197
- console.log(' then restart your agent and ask it to "read the shared context" —');
198
- console.log(" you should see your team's entries. (Claude Code: /mcp shows wayform connected.)");
199
- console.log(" 2. Commit the project hook configs so teammates inherit them:");
200
- console.log(" git add .claude .cursor/hooks.json .codex/hooks.json .gitignore && git commit -m 'chore: wire Wayform (remote)'");
201
- console.log(" (.cursor/mcp.json, .codex/config.toml and .memorylayer-hook.env are gitignored — each member runs init --remote.)");
202
- console.log(" 3. Codex users: mark the project trusted (Codex only loads project-scoped");
203
- console.log(" config for trusted repos) — then wayform tools appear on next launch.");
252
+ console.log("\nNext steps (this product repo only — not a global MCP):");
253
+ console.log(" 1. wayform login # OS keychain for session-start hooks");
254
+ if (clients.length > 0) {
255
+ console.log(" 2. In this folder, authenticate the client you use:");
256
+ if (wants(clients, "cursor")) {
257
+ console.log(" Cursor: Connect on the wayform server");
258
+ }
259
+ if (wants(clients, "claude")) {
260
+ console.log(" Claude Code: claude mcp login wayform");
261
+ }
262
+ if (wants(clients, "codex")) {
263
+ console.log(" Codex: codex mcp login wayform");
264
+ }
265
+ if (wants(clients, "devin")) {
266
+ console.log(" Devin CLI: devin mcp login wayform");
267
+ }
268
+ if (wants(clients, "antigravity")) {
269
+ console.log(" Antigravity: Authenticate wayform in MCP settings");
270
+ }
271
+ }
272
+ console.log(" 3. wayform doctor");
273
+ const add = commitPaths(clients);
274
+ if (add.length > 0) {
275
+ console.log(" 4. Commit the project MCP files so teammates inherit them:");
276
+ console.log(` git add ${add.join(" ")} && git commit -m 'chore: wire Wayform (remote)'`);
277
+ }
278
+ }
279
+ function commitPaths(clients) {
280
+ const add = [".gitignore", ".memorylayer-hook.env"];
281
+ if (wants(clients, "claude"))
282
+ add.push(".mcp.json", ".claude");
283
+ if (wants(clients, "cursor"))
284
+ add.push(".cursor");
285
+ if (wants(clients, "codex"))
286
+ add.push(".codex");
287
+ if (wants(clients, "devin"))
288
+ add.push(".devin");
289
+ if (wants(clients, "antigravity"))
290
+ add.push(".agents");
291
+ return add;
204
292
  }
205
293
  //# sourceMappingURL=init-remote.js.map