wayform 0.1.1
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/LICENSE +21 -0
- package/README.md +262 -0
- package/dist/cli.js +65 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.js +174 -0
- package/dist/config.js.map +1 -0
- package/dist/context-format.js +18 -0
- package/dist/context-format.js.map +1 -0
- package/dist/doctor.js +182 -0
- package/dist/doctor.js.map +1 -0
- package/dist/frontmatter.js +50 -0
- package/dist/frontmatter.js.map +1 -0
- package/dist/git-repo.js +166 -0
- package/dist/git-repo.js.map +1 -0
- package/dist/hook-clients.js +90 -0
- package/dist/hook-clients.js.map +1 -0
- package/dist/hook.js +95 -0
- package/dist/hook.js.map +1 -0
- package/dist/index.js +213 -0
- package/dist/index.js.map +1 -0
- package/dist/init-configs.js +119 -0
- package/dist/init-configs.js.map +1 -0
- package/dist/init-env.js +70 -0
- package/dist/init-env.js.map +1 -0
- package/dist/init-remote.js +155 -0
- package/dist/init-remote.js.map +1 -0
- package/dist/init.js +132 -0
- package/dist/init.js.map +1 -0
- package/dist/is-main.js +14 -0
- package/dist/is-main.js.map +1 -0
- package/dist/metrics.js +35 -0
- package/dist/metrics.js.map +1 -0
- package/dist/remote-read.js +57 -0
- package/dist/remote-read.js.map +1 -0
- package/dist/review-prompt.js +23 -0
- package/dist/review-prompt.js.map +1 -0
- package/dist/slug.js +19 -0
- package/dist/slug.js.map +1 -0
- package/dist/space-create.js +195 -0
- package/dist/space-create.js.map +1 -0
- package/dist/stop-hook.js +66 -0
- package/dist/stop-hook.js.map +1 -0
- package/dist/store.js +177 -0
- package/dist/store.js.map +1 -0
- package/dist/token-budget.js +35 -0
- package/dist/token-budget.js.map +1 -0
- package/package.json +39 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { loadConfig, defaultProject } from "./config.js";
|
|
6
|
+
import { ContextStore } from "./store.js";
|
|
7
|
+
import { remoteApiRead } from "./remote-read.js";
|
|
8
|
+
import { projectContext } from "./context-format.js";
|
|
9
|
+
import { recordMetric } from "./metrics.js";
|
|
10
|
+
import { isMain } from "./is-main.js";
|
|
11
|
+
export async function runServer() {
|
|
12
|
+
const cfg = loadConfig();
|
|
13
|
+
// Gateway-only members ("" repoUrl) have no local clone: constructing the
|
|
14
|
+
// store would run git ops against whatever cwd happens to be (the crash a
|
|
15
|
+
// fallen-back agent hits). Reads stay remote-first; store-needing paths
|
|
16
|
+
// return honest tool errors instead.
|
|
17
|
+
const store = cfg.repoUrl ? new ContextStore(cfg) : null;
|
|
18
|
+
if (store)
|
|
19
|
+
await store.ensure();
|
|
20
|
+
const server = new McpServer({
|
|
21
|
+
name: "memorylayer",
|
|
22
|
+
version: "0.1.0",
|
|
23
|
+
});
|
|
24
|
+
server.registerTool("read_context", {
|
|
25
|
+
title: "Read shared planning context",
|
|
26
|
+
description: "Pull the latest shared planning context for a project and return the current projected state (all recorded decisions and context, in write order). Call this at the START of a planning turn so decisions written by collaborators are already present without anyone pasting them.",
|
|
27
|
+
inputSchema: {
|
|
28
|
+
project: z
|
|
29
|
+
.string()
|
|
30
|
+
.describe("The shared project/space name, e.g. 'business-one'."),
|
|
31
|
+
budget_tokens: z
|
|
32
|
+
.number()
|
|
33
|
+
.int()
|
|
34
|
+
.positive()
|
|
35
|
+
.optional()
|
|
36
|
+
.describe("Override the default read token budget for this call (larger = more history, smaller = tighter context)."),
|
|
37
|
+
query: z
|
|
38
|
+
.string()
|
|
39
|
+
.optional()
|
|
40
|
+
.describe("Optional query: relevance-ranked search over the WHOLE history " +
|
|
41
|
+
"(keyword + semantic) instead of the most recent entries. " +
|
|
42
|
+
"Requires the hosted gateway; ignored offline."),
|
|
43
|
+
},
|
|
44
|
+
}, async ({ project, query, budget_tokens }) => {
|
|
45
|
+
const budget = budget_tokens ?? cfg.readBudgetTokens;
|
|
46
|
+
// Remote-first (§2.2): gateway index read, local clone as fallback.
|
|
47
|
+
const remote = await remoteApiRead(cfg, {
|
|
48
|
+
project,
|
|
49
|
+
query: query?.trim() || undefined,
|
|
50
|
+
budgetTokens: budget,
|
|
51
|
+
trigger: "mcp_read",
|
|
52
|
+
});
|
|
53
|
+
if (remote !== null) {
|
|
54
|
+
await recordMetric(cfg, {
|
|
55
|
+
source: "mcp",
|
|
56
|
+
event: "read",
|
|
57
|
+
project,
|
|
58
|
+
total: remote.total,
|
|
59
|
+
});
|
|
60
|
+
return { content: [{ type: "text", text: remote.text }] };
|
|
61
|
+
}
|
|
62
|
+
if (!store) {
|
|
63
|
+
return {
|
|
64
|
+
content: [
|
|
65
|
+
{
|
|
66
|
+
type: "text",
|
|
67
|
+
text: "read_context could not reach the hosted gateway and this member " +
|
|
68
|
+
"is gateway-only (no local clone to fall back to). Retry online, " +
|
|
69
|
+
"or check MEMORYLAYER_GATEWAY_URL / MEMORYLAYER_GATEWAY_TOKEN.",
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
isError: true,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
const { entries, total } = await store.read(project, budget);
|
|
76
|
+
await recordMetric(cfg, { source: "mcp", event: "read", project, total });
|
|
77
|
+
const note = query?.trim()
|
|
78
|
+
? "(offline fallback: relevance search unavailable — showing the most recent entries)\n\n"
|
|
79
|
+
: "";
|
|
80
|
+
return {
|
|
81
|
+
content: [
|
|
82
|
+
{
|
|
83
|
+
type: "text",
|
|
84
|
+
text: note + projectContext(project, entries, total),
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
};
|
|
88
|
+
});
|
|
89
|
+
server.registerTool("write_context", {
|
|
90
|
+
title: "Write a shared planning decision",
|
|
91
|
+
description: "Append a DELIBERATE decision or established context to the shared project space and commit it, so collaborators' sessions see it. Write decisions ('we decided X because Y') and durable context — NOT a firehose of every reasoning step. When the user says 'record this', 'remember this', 'save this decision' (or runs the /remember command), treat it as an EXPLICIT instruction to call this tool right away.",
|
|
92
|
+
inputSchema: {
|
|
93
|
+
project: z
|
|
94
|
+
.string()
|
|
95
|
+
.describe("The shared project/space name, e.g. 'business-one'."),
|
|
96
|
+
type: z
|
|
97
|
+
.enum(["decision", "context"])
|
|
98
|
+
.default("decision")
|
|
99
|
+
.describe("'decision' for a settled call, 'context' for durable background."),
|
|
100
|
+
payload: z
|
|
101
|
+
.string()
|
|
102
|
+
.describe("The decision or context, stated plainly. For decisions, include the 'because' — the reasoning that settles it."),
|
|
103
|
+
author: z
|
|
104
|
+
.string()
|
|
105
|
+
.optional()
|
|
106
|
+
.describe("Who is recording this. Defaults to the configured MEMORYLAYER_AUTHOR."),
|
|
107
|
+
},
|
|
108
|
+
}, async ({ project, type, payload, author }) => {
|
|
109
|
+
// Gateway-only members write through the hosted MCP endpoint (the gateway
|
|
110
|
+
// owns the GitHub store); the local server has no clone to commit to.
|
|
111
|
+
if (!store) {
|
|
112
|
+
return {
|
|
113
|
+
content: [
|
|
114
|
+
{
|
|
115
|
+
type: "text",
|
|
116
|
+
text: "write_context is unavailable on the local server for gateway-only " +
|
|
117
|
+
"members — connect your client to the hosted MCP endpoint " +
|
|
118
|
+
`(${cfg.gatewayUrl ?? "MEMORYLAYER_GATEWAY_URL"}/mcp) instead.`,
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
isError: true,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
try {
|
|
125
|
+
const entry = await store.write(project, {
|
|
126
|
+
author: author?.trim() || cfg.author,
|
|
127
|
+
type,
|
|
128
|
+
payload,
|
|
129
|
+
});
|
|
130
|
+
await recordMetric(cfg, { source: "mcp", event: "write", project });
|
|
131
|
+
await store.flushMetrics();
|
|
132
|
+
return {
|
|
133
|
+
content: [
|
|
134
|
+
{
|
|
135
|
+
type: "text",
|
|
136
|
+
text: `Recorded ${entry.type} in '${project}' as ${entry.author} at ${entry.timestamp} (${entry.file}).`,
|
|
137
|
+
},
|
|
138
|
+
],
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
catch (err) {
|
|
142
|
+
// Surface the honest "recorded locally, NOT shared yet" message (and any
|
|
143
|
+
// other write failure) as a tool error rather than a raw transport crash.
|
|
144
|
+
return {
|
|
145
|
+
content: [{ type: "text", text: err.message }],
|
|
146
|
+
isError: true,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
server.registerTool("search_memory", {
|
|
151
|
+
title: "Search the shared memory",
|
|
152
|
+
description: "Relevance-ranked search over ALL recorded decisions and context " +
|
|
153
|
+
"(keyword + semantic, whole history — not just recent entries). Use it " +
|
|
154
|
+
"BEFORE contradicting or re-deciding anything that may already be " +
|
|
155
|
+
"settled, and when the user references prior work or decisions.",
|
|
156
|
+
inputSchema: {
|
|
157
|
+
query: z
|
|
158
|
+
.string()
|
|
159
|
+
.describe("What to look for, e.g. 'cursor mcp config scoping'."),
|
|
160
|
+
project: z
|
|
161
|
+
.string()
|
|
162
|
+
.optional()
|
|
163
|
+
.describe("Restrict to one project/space name. Omit to search every project."),
|
|
164
|
+
kinds: z
|
|
165
|
+
.array(z.enum(["decision", "context"]))
|
|
166
|
+
.optional()
|
|
167
|
+
.describe("Restrict to entry kinds."),
|
|
168
|
+
},
|
|
169
|
+
}, async ({ query, project, kinds }) => {
|
|
170
|
+
// /api/read requires a project for its recency fallback; the gateway
|
|
171
|
+
// searches the whole space when the query is present, so the default
|
|
172
|
+
// project only scopes the offline fallback.
|
|
173
|
+
const scopeProject = project?.trim() || defaultProject();
|
|
174
|
+
const remote = await remoteApiRead(cfg, {
|
|
175
|
+
project: scopeProject,
|
|
176
|
+
query,
|
|
177
|
+
kinds,
|
|
178
|
+
budgetTokens: cfg.readBudgetTokens,
|
|
179
|
+
trigger: "search_memory",
|
|
180
|
+
});
|
|
181
|
+
if (remote === null) {
|
|
182
|
+
return {
|
|
183
|
+
content: [
|
|
184
|
+
{
|
|
185
|
+
type: "text",
|
|
186
|
+
text: "search_memory needs the hosted gateway and it was not reachable " +
|
|
187
|
+
"(set MEMORYLAYER_GATEWAY_URL and MEMORYLAYER_GATEWAY_TOKEN, or retry online). " +
|
|
188
|
+
"Use read_context for the local recency view.",
|
|
189
|
+
},
|
|
190
|
+
],
|
|
191
|
+
isError: true,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
await recordMetric(cfg, {
|
|
195
|
+
source: "mcp",
|
|
196
|
+
event: "read",
|
|
197
|
+
project: scopeProject,
|
|
198
|
+
total: remote.total,
|
|
199
|
+
});
|
|
200
|
+
return { content: [{ type: "text", text: remote.text }] };
|
|
201
|
+
});
|
|
202
|
+
const transport = new StdioServerTransport();
|
|
203
|
+
await server.connect(transport);
|
|
204
|
+
// stdio transport owns stdout; log to stderr only.
|
|
205
|
+
console.error(`wayform MCP server ready (author=${cfg.author}, store=${cfg.repoPath || `gateway-only via ${cfg.gatewayUrl ?? "unset gateway"}`})`);
|
|
206
|
+
}
|
|
207
|
+
if (isMain(import.meta.url)) {
|
|
208
|
+
runServer().catch((err) => {
|
|
209
|
+
console.error("memorylayer failed to start:", err);
|
|
210
|
+
process.exit(1);
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO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+
* Pure builders/mergers for the per-vendor config artifacts `init` writes.
|
|
3
|
+
*
|
|
4
|
+
* Each `merge*` takes the client's existing parsed config (or undefined) and
|
|
5
|
+
* returns it with MemoryLayer's entries added. Merges are:
|
|
6
|
+
* - non-clobbering: unrelated existing entries are preserved;
|
|
7
|
+
* - idempotent: our command appears at most once on re-run (matched by command
|
|
8
|
+
* substring / server key).
|
|
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
|
|
12
|
+
* `.memorylayer-hook.env` from the project cwd at runtime.
|
|
13
|
+
*/
|
|
14
|
+
const asObject = (v) => v && typeof v === "object" && !Array.isArray(v) ? { ...v } : {};
|
|
15
|
+
const asArray = (v) => (Array.isArray(v) ? [...v] : []);
|
|
16
|
+
/**
|
|
17
|
+
* Append `entry` to `list` unless some existing item already invokes MemoryLayer
|
|
18
|
+
* for this event. `marker` MUST be the stable `<subcommand> <client>` token
|
|
19
|
+
* (e.g. "hook cursor", "stop-review claude-code") — NOT a whole command string —
|
|
20
|
+
* so an equivalent hook that invokes the tool via a different form (the dogfood
|
|
21
|
+
* `node ./dist/cli.js hook cursor`, an absolute path, or `npx memorylayer …`) is
|
|
22
|
+
* still recognized and re-running `init` stays idempotent instead of appending a
|
|
23
|
+
* duplicate hook that would fire the read/review twice per turn.
|
|
24
|
+
*/
|
|
25
|
+
function addOnce(list, marker, entry) {
|
|
26
|
+
const present = list.some((item) => JSON.stringify(item).includes(marker));
|
|
27
|
+
return present ? list : [...list, entry];
|
|
28
|
+
}
|
|
29
|
+
export function mergeClaudeSettings(existing, bin = "memorylayer") {
|
|
30
|
+
const root = asObject(existing);
|
|
31
|
+
const hooks = asObject(root.hooks);
|
|
32
|
+
hooks.SessionStart = addOnce(asArray(hooks.SessionStart), "hook claude-code", {
|
|
33
|
+
hooks: [{ type: "command", command: `${bin} hook claude-code` }],
|
|
34
|
+
});
|
|
35
|
+
hooks.Stop = addOnce(asArray(hooks.Stop), "stop-review claude-code", {
|
|
36
|
+
hooks: [{ type: "command", command: `${bin} stop-review claude-code` }],
|
|
37
|
+
});
|
|
38
|
+
root.hooks = hooks;
|
|
39
|
+
return root;
|
|
40
|
+
}
|
|
41
|
+
export function mergeCursorHooks(existing, bin = "memorylayer") {
|
|
42
|
+
const root = asObject(existing);
|
|
43
|
+
root.version = 1;
|
|
44
|
+
const hooks = asObject(root.hooks);
|
|
45
|
+
hooks.sessionStart = addOnce(asArray(hooks.sessionStart), "hook cursor", {
|
|
46
|
+
command: `${bin} hook cursor`,
|
|
47
|
+
});
|
|
48
|
+
hooks.stop = addOnce(asArray(hooks.stop), "stop-review cursor", {
|
|
49
|
+
command: `${bin} stop-review cursor`,
|
|
50
|
+
loop_limit: 3,
|
|
51
|
+
});
|
|
52
|
+
root.hooks = hooks;
|
|
53
|
+
return root;
|
|
54
|
+
}
|
|
55
|
+
export function mergeCodexHooks(existing, bin = "memorylayer") {
|
|
56
|
+
const root = asObject(existing);
|
|
57
|
+
const hooks = asObject(root.hooks);
|
|
58
|
+
hooks.SessionStart = addOnce(asArray(hooks.SessionStart), "hook codex", {
|
|
59
|
+
matcher: "startup|resume",
|
|
60
|
+
hooks: [{ type: "command", command: `${bin} hook codex` }],
|
|
61
|
+
});
|
|
62
|
+
hooks.Stop = addOnce(asArray(hooks.Stop), "stop-review codex", {
|
|
63
|
+
hooks: [{ type: "command", command: `${bin} stop-review codex` }],
|
|
64
|
+
});
|
|
65
|
+
root.hooks = hooks;
|
|
66
|
+
return root;
|
|
67
|
+
}
|
|
68
|
+
export function mergeMcpJson(existing) {
|
|
69
|
+
const root = asObject(existing);
|
|
70
|
+
const servers = asObject(root.mcpServers);
|
|
71
|
+
servers.memorylayer = { command: "memorylayer", args: [], env: {} };
|
|
72
|
+
root.mcpServers = servers;
|
|
73
|
+
return root;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Project-scoped Codex MCP block for the LOCAL (self-hosted clone) tier, written
|
|
77
|
+
* to `.codex/config.toml`. Secret-free stdio server: `command = "memorylayer"`
|
|
78
|
+
* self-loads `.memorylayer-hook.env` at runtime. Codex applies project config
|
|
79
|
+
* for trusted repos, so this needs no global paste.
|
|
80
|
+
*/
|
|
81
|
+
export const CODEX_MCP_TOML = `[mcp_servers.memorylayer]
|
|
82
|
+
command = "memorylayer"
|
|
83
|
+
args = []
|
|
84
|
+
`;
|
|
85
|
+
/**
|
|
86
|
+
* Native HTTP MCP for a hosted member, written into a project's `.cursor/mcp.json`.
|
|
87
|
+
* This file carries the member token, so `init --remote` MUST gitignore it — it is
|
|
88
|
+
* per-member and never committed. Non-clobbering + idempotent on `wayform`.
|
|
89
|
+
*/
|
|
90
|
+
export function mergeCursorRemoteMcp(existing, gatewayUrl, token) {
|
|
91
|
+
const root = asObject(existing);
|
|
92
|
+
const servers = asObject(root.mcpServers);
|
|
93
|
+
servers.wayform = {
|
|
94
|
+
url: `${gatewayUrl}/mcp`,
|
|
95
|
+
headers: { Authorization: `Bearer ${token}` },
|
|
96
|
+
};
|
|
97
|
+
root.mcpServers = servers;
|
|
98
|
+
return root;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Project-scoped Codex MCP block for a HOSTED (gateway) member, written to
|
|
102
|
+
* `.codex/config.toml`. Codex 0.144+ speaks native streamable-HTTP and applies
|
|
103
|
+
* project config for trusted repos, so no global paste and no `mcp-remote`
|
|
104
|
+
* bridge are needed. The member token is inlined as a literal Authorization
|
|
105
|
+
* header via `http_headers` — the same pattern as `.cursor/mcp.json` — because
|
|
106
|
+
* the env-var alternative (`bearer_token_env_var`) requires exporting the token
|
|
107
|
+
* before every launch and fails SILENTLY for IDE-launched Codex (the MCP client
|
|
108
|
+
* never initializes and the model just sees no tools). Codex rejects a literal
|
|
109
|
+
* `bearer_token` field for HTTP servers; `http_headers` is the sanctioned
|
|
110
|
+
* literal path. This file therefore CARRIES THE TOKEN: `init --remote` MUST
|
|
111
|
+
* gitignore it and harden it to 0600.
|
|
112
|
+
*/
|
|
113
|
+
export function codexRemoteConfigToml(gatewayUrl, token) {
|
|
114
|
+
return `[mcp_servers.wayform]
|
|
115
|
+
url = "${gatewayUrl}/mcp"
|
|
116
|
+
http_headers = { Authorization = "Bearer ${token}" }
|
|
117
|
+
`;
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=init-configs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init-configs.js","sourceRoot":"","sources":["../src/init-configs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,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,CAA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C,CAAC;IAChC,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC1C,OAAO,CAAC,OAAO,GAAG;QAChB,GAAG,EAAE,GAAG,UAAU,MAAM;QACxB,OAAO,EAAE,EAAE,aAAa,EAAE,UAAU,KAAK,EAAE,EAAE;KAC9C,CAAC;IACF,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC;IAC1B,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,qBAAqB,CAAC,UAAkB,EAAE,KAAa;IACrE,OAAO;SACA,UAAU;2CACwB,KAAK;CAC/C,CAAC;AACF,CAAC"}
|
package/dist/init-env.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
/**
|
|
4
|
+
* Write a secret-bearing file (identity env / token-carrying MCP config) with
|
|
5
|
+
* owner-only perms (0600). writeFileSync only applies `mode` on CREATE, so an
|
|
6
|
+
* older file left at the umask default (0644, world-readable) would keep loose
|
|
7
|
+
* perms on a rewrite — the explicit chmod retro-tightens it. Best-effort on
|
|
8
|
+
* filesystems without POSIX perms (Windows/NTFS): the chmod no-ops there, which
|
|
9
|
+
* is fine since the multi-UID threat model is a POSIX host.
|
|
10
|
+
*/
|
|
11
|
+
export function writeSecretFile(file, contents) {
|
|
12
|
+
fs.writeFileSync(file, contents, { mode: 0o600 });
|
|
13
|
+
hardenSecretFile(file);
|
|
14
|
+
}
|
|
15
|
+
/** Tighten an existing secret file to 0600 without rewriting its contents. */
|
|
16
|
+
export function hardenSecretFile(file) {
|
|
17
|
+
try {
|
|
18
|
+
fs.chmodSync(file, 0o600);
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
// best-effort: no POSIX perms (Windows) or file vanished — nothing to do.
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/** Contents of the per-user, gitignored .memorylayer-hook.env file. */
|
|
25
|
+
export function buildHookEnv(v) {
|
|
26
|
+
return [
|
|
27
|
+
"# Wayform per-user hook config — gitignored. Do NOT commit.",
|
|
28
|
+
"# Written by `wayform init`. Your identity + context-repo access.",
|
|
29
|
+
`CONTEXT_REPO_URL=${v.repoUrl}`,
|
|
30
|
+
`MEMORYLAYER_AUTHOR=${v.author}`,
|
|
31
|
+
`MEMORYLAYER_AUTHOR_EMAIL=${v.email}`,
|
|
32
|
+
`MEMORYLAYER_PROJECT=${v.project}`,
|
|
33
|
+
"",
|
|
34
|
+
].join("\n");
|
|
35
|
+
}
|
|
36
|
+
/** Contents of `.memorylayer-hook.env` for a HOSTED (gateway) member — gitignored. */
|
|
37
|
+
export function buildRemoteHookEnv(v) {
|
|
38
|
+
return [
|
|
39
|
+
"# Wayform per-user hook config — gitignored. Do NOT commit.",
|
|
40
|
+
"# Written by `wayform init --remote`. Hosted (gateway) member — no local clone.",
|
|
41
|
+
`MEMORYLAYER_GATEWAY_URL=${v.gatewayUrl}`,
|
|
42
|
+
`MEMORYLAYER_GATEWAY_TOKEN=${v.token}`,
|
|
43
|
+
`MEMORYLAYER_PROJECT=${v.project}`,
|
|
44
|
+
`MEMORYLAYER_AUTHOR=${v.author}`,
|
|
45
|
+
`MEMORYLAYER_AUTHOR_EMAIL=${v.email}`,
|
|
46
|
+
"",
|
|
47
|
+
].join("\n");
|
|
48
|
+
}
|
|
49
|
+
/** Read a git config value for a prompt default; "" if git/key is absent. */
|
|
50
|
+
export function gitConfigDefault(key) {
|
|
51
|
+
try {
|
|
52
|
+
return execFileSync("git", ["config", "--get", key], {
|
|
53
|
+
encoding: "utf8",
|
|
54
|
+
}).trim();
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
return "";
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/** Append each missing entry to .gitignore content exactly once. */
|
|
61
|
+
export function ensureGitignore(existing, entries) {
|
|
62
|
+
const lines = existing.split(/\r?\n/).map((l) => l.trim());
|
|
63
|
+
let out = existing.endsWith("\n") || existing === "" ? existing : existing + "\n";
|
|
64
|
+
for (const entry of entries) {
|
|
65
|
+
if (!lines.includes(entry))
|
|
66
|
+
out += `${entry}\n`;
|
|
67
|
+
}
|
|
68
|
+
return out;
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=init-env.js.map
|
|
@@ -0,0 +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;AAEzB;;;;;;;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,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC5B,CAAC;IAAC,MAAM,CAAC;QACP,0EAA0E;IAC5E,CAAC;AACH,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,YAAY,CAAC,CAK5B;IACC,OAAO;QACL,6DAA6D;QAC7D,mEAAmE;QACnE,oBAAoB,CAAC,CAAC,OAAO,EAAE;QAC/B,sBAAsB,CAAC,CAAC,MAAM,EAAE;QAChC,4BAA4B,CAAC,CAAC,KAAK,EAAE;QACrC,uBAAuB,CAAC,CAAC,OAAO,EAAE;QAClC,EAAE;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC;AAED,sFAAsF;AACtF,MAAM,UAAU,kBAAkB,CAAC,CAMlC;IACC,OAAO;QACL,6DAA6D;QAC7D,iFAAiF;QACjF,2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, 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).
|
|
7
|
+
*/
|
|
8
|
+
import { execFileSync } from "node:child_process";
|
|
9
|
+
import fs from "node:fs";
|
|
10
|
+
import path from "node:path";
|
|
11
|
+
import readline from "node:readline/promises";
|
|
12
|
+
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, } from "./init-env.js";
|
|
15
|
+
const defaultRunner = (cmd, args) =>
|
|
16
|
+
// Bounded + non-interactive: a hanging or prompting `claude` must never freeze
|
|
17
|
+
// init. On timeout/ENOENT this throws → the caller falls open to a printed
|
|
18
|
+
// manual command. stdin is closed so the child cannot block waiting for input.
|
|
19
|
+
void execFileSync(cmd, args, {
|
|
20
|
+
stdio: ["ignore", "ignore", "ignore"],
|
|
21
|
+
timeout: 15000,
|
|
22
|
+
});
|
|
23
|
+
/**
|
|
24
|
+
* Register the gateway as a project-scoped (`--scope local`) HTTP MCP server for
|
|
25
|
+
* Claude Code. `--scope local` stores config in ~/.claude.json (NOT the repo), so
|
|
26
|
+
* it is project-scoped AND token-safe. Non-fatal: if `claude` is absent the
|
|
27
|
+
* returned command is printed for the member to run by hand.
|
|
28
|
+
*/
|
|
29
|
+
export function registerClaudeCodeMcp(gatewayUrl, token, run = defaultRunner) {
|
|
30
|
+
const args = [
|
|
31
|
+
"mcp",
|
|
32
|
+
"add",
|
|
33
|
+
"--transport",
|
|
34
|
+
"http",
|
|
35
|
+
"--scope",
|
|
36
|
+
"local",
|
|
37
|
+
"wayform",
|
|
38
|
+
`${gatewayUrl}/mcp`,
|
|
39
|
+
"--header",
|
|
40
|
+
`Authorization: Bearer ${token}`,
|
|
41
|
+
];
|
|
42
|
+
const command = `claude ${args.join(" ")}`;
|
|
43
|
+
try {
|
|
44
|
+
run("claude", args);
|
|
45
|
+
return { ok: true, command };
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return { ok: false, command };
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const flag = (args, name) => {
|
|
52
|
+
const i = args.indexOf(`--${name}`);
|
|
53
|
+
return i >= 0 && i + 1 < args.length ? args[i + 1] : undefined;
|
|
54
|
+
};
|
|
55
|
+
const has = (args, name) => args.includes(`--${name}`);
|
|
56
|
+
function readJson(file) {
|
|
57
|
+
if (!fs.existsSync(file))
|
|
58
|
+
return undefined;
|
|
59
|
+
try {
|
|
60
|
+
return JSON.parse(fs.readFileSync(file, "utf8"));
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
fs.copyFileSync(file, `${file}.bak`);
|
|
64
|
+
console.warn(`! ${file} was not valid JSON — backed up to ${file}.bak.`);
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function writeJson(cwd, rel, data) {
|
|
69
|
+
const file = path.join(cwd, rel);
|
|
70
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
71
|
+
fs.writeFileSync(file, JSON.stringify(data, null, 2) + "\n");
|
|
72
|
+
console.log(` wrote ${rel}`);
|
|
73
|
+
}
|
|
74
|
+
function writeText(cwd, rel, text) {
|
|
75
|
+
const file = path.join(cwd, rel);
|
|
76
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
77
|
+
fs.writeFileSync(file, text);
|
|
78
|
+
console.log(` wrote ${rel}`);
|
|
79
|
+
}
|
|
80
|
+
export async function runInitRemote(args) {
|
|
81
|
+
const cwd = process.cwd();
|
|
82
|
+
if (!fs.existsSync(path.join(cwd, ".git"))) {
|
|
83
|
+
console.warn("! Not a git repository. Hooks are project-scoped; run this in your project root.");
|
|
84
|
+
}
|
|
85
|
+
const gatewayUrl = (flag(args, "gateway") ?? "").replace(/\/+$/, "");
|
|
86
|
+
const token = flag(args, "token") ?? "";
|
|
87
|
+
if (!gatewayUrl || !token) {
|
|
88
|
+
throw new Error("wayform init --remote requires --gateway <url> and --token <mlk_...>");
|
|
89
|
+
}
|
|
90
|
+
// Identity (attribution/display; the gateway is authoritative on write).
|
|
91
|
+
const useDefaults = has(args, "yes");
|
|
92
|
+
const rl = useDefaults || (flag(args, "author") && flag(args, "email"))
|
|
93
|
+
? undefined
|
|
94
|
+
: readline.createInterface({ input, output });
|
|
95
|
+
const ask = async (q, def) => {
|
|
96
|
+
if (!rl)
|
|
97
|
+
return def;
|
|
98
|
+
const a = (await rl.question(def ? `${q} [${def}]: ` : `${q}: `)).trim();
|
|
99
|
+
return a || def;
|
|
100
|
+
};
|
|
101
|
+
const author = flag(args, "author") ??
|
|
102
|
+
(await ask("Author name", gitConfigDefault("user.name")));
|
|
103
|
+
const email = flag(args, "email") ??
|
|
104
|
+
(await ask("Author email", gitConfigDefault("user.email")));
|
|
105
|
+
const project = flag(args, "project") ?? path.basename(cwd);
|
|
106
|
+
rl?.close();
|
|
107
|
+
// --- Project tier: session/Stop hooks calling the `wayform` binary ---
|
|
108
|
+
writeJson(cwd, ".claude/settings.json", mergeClaudeSettings(readJson(path.join(cwd, ".claude/settings.json")), "wayform"));
|
|
109
|
+
writeJson(cwd, ".cursor/hooks.json", mergeCursorHooks(readJson(path.join(cwd, ".cursor/hooks.json")), "wayform"));
|
|
110
|
+
writeJson(cwd, ".codex/hooks.json", mergeCodexHooks(readJson(path.join(cwd, ".codex/hooks.json")), "wayform"));
|
|
111
|
+
// --- Cursor native HTTP MCP (gitignored — carries the token) ---
|
|
112
|
+
writeJson(cwd, ".cursor/mcp.json", mergeCursorRemoteMcp(readJson(path.join(cwd, ".cursor/mcp.json")), gatewayUrl, token));
|
|
113
|
+
// Token-bearing: tighten to owner-only (writeJson creates at umask default).
|
|
114
|
+
hardenSecretFile(path.join(cwd, ".cursor/mcp.json"));
|
|
115
|
+
// --- Codex native HTTP MCP (project-scoped, gitignored — carries the token) ---
|
|
116
|
+
writeText(cwd, ".codex/config.toml", codexRemoteConfigToml(gatewayUrl, token));
|
|
117
|
+
hardenSecretFile(path.join(cwd, ".codex/config.toml"));
|
|
118
|
+
// --- User tier: gitignored gateway env (hosted-only, no CONTEXT_REPO_URL) ---
|
|
119
|
+
const envFile = path.join(cwd, ".memorylayer-hook.env");
|
|
120
|
+
if (fs.existsSync(envFile) && !has(args, "force")) {
|
|
121
|
+
hardenSecretFile(envFile); // retro-tighten a pre-existing 0644 file
|
|
122
|
+
console.log(" .memorylayer-hook.env exists — leaving it (use --force to rewrite).");
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
writeSecretFile(envFile, buildRemoteHookEnv({ gatewayUrl, token, project, author, email }));
|
|
126
|
+
console.log(" wrote .memorylayer-hook.env (gitignored)");
|
|
127
|
+
}
|
|
128
|
+
// --- Gitignore secrets: env + local settings + the token-bearing cursor mcp ---
|
|
129
|
+
const giPath = path.join(cwd, ".gitignore");
|
|
130
|
+
const gi = fs.existsSync(giPath) ? fs.readFileSync(giPath, "utf8") : "";
|
|
131
|
+
fs.writeFileSync(giPath, ensureGitignore(gi, [
|
|
132
|
+
".memorylayer-hook.env",
|
|
133
|
+
".claude/settings.local.json",
|
|
134
|
+
".cursor/mcp.json",
|
|
135
|
+
".codex/config.toml",
|
|
136
|
+
]));
|
|
137
|
+
console.log(" updated .gitignore");
|
|
138
|
+
// --- Claude Code native HTTP MCP (project-scoped, token in ~/.claude.json) ---
|
|
139
|
+
const claude = registerClaudeCodeMcp(gatewayUrl, token);
|
|
140
|
+
if (claude.ok) {
|
|
141
|
+
console.log(" registered Claude Code MCP (claude mcp add --scope local)");
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
console.log(" ! Could not run the Claude CLI — register Claude Code MCP by hand:\n");
|
|
145
|
+
console.log(` ${claude.command}\n`);
|
|
146
|
+
}
|
|
147
|
+
console.log(" wrote .codex/config.toml (gitignored — carries the member token)");
|
|
148
|
+
console.log("\nNext steps:");
|
|
149
|
+
console.log(" 1. Commit the project hook configs so teammates inherit them:");
|
|
150
|
+
console.log(" git add .claude .cursor/hooks.json .codex/hooks.json .gitignore && git commit -m 'chore: wire Wayform (remote)'");
|
|
151
|
+
console.log(" (.cursor/mcp.json, .codex/config.toml and .memorylayer-hook.env are gitignored — each member runs init --remote.)");
|
|
152
|
+
console.log(" 2. Codex users: mark the project trusted (Codex only loads project-scoped");
|
|
153
|
+
console.log(" config for trusted repos) — then wayform tools appear on next launch.");
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=init-remote.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init-remote.js","sourceRoot":"","sources":["../src/init-remote.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,QAAQ,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,KAAK,IAAI,KAAK,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,gBAAgB,GACjB,MAAM,eAAe,CAAC;AAIvB,MAAM,aAAa,GAAW,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;AAC1C,+EAA+E;AAC/E,2EAA2E;AAC3E,+EAA+E;AAC/E,KAAK,YAAY,CAAC,GAAG,EAAE,IAAI,EAAE;IAC3B,KAAK,EAAE,CAAC,QAAQ,EAAE,QAAQ,E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