@seamward/setup 0.1.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1 @@
1
+ Copyright 2026 Seamward. All rights reserved.
package/README.md ADDED
@@ -0,0 +1,59 @@
1
+ # Seamward project setup
2
+
3
+ `@seamward/setup` authorizes one workspace application environment and adds the local setup MCP to a supported coding-agent project.
4
+
5
+ Run this from the deployable backend service:
6
+
7
+ ```bash
8
+ npx @seamward/setup@alpha
9
+ ```
10
+
11
+ The command opens Seamward in your browser, asks you to choose the workspace and application environment for this project, installs an exact `@seamward/setup-mcp` version, and previews project-scoped configuration for:
12
+
13
+ - Claude Code in `.mcp.json`
14
+ - Cursor in `.cursor/mcp.json`
15
+ - Codex in `.codex/config.toml`
16
+
17
+ It preserves unrelated configuration and refuses to replace an existing custom `seamward-setup` server. Credentials are stored outside the repository with owner-only permissions. Environment files are never read or changed.
18
+
19
+ After the command completes, restart the coding agent and ask:
20
+
21
+ ```text
22
+ Set up Seamward in this project.
23
+ ```
24
+
25
+ The agent analyzes the repository locally, separates independent business integrations, and proposes readable names and providers. It then previews supported source changes, runs the project's verification commands after approval, previews which Integrations it will create or reuse, connects reviewed contracts, and checks the first accepted observation for each binding. You do not copy Integration IDs into the prompt.
26
+
27
+ ## Options
28
+
29
+ ```text
30
+ --integration <id> Compatibility mode for one existing exact Integration
31
+ --dry-run Preview project changes without applying them
32
+ --yes Apply the displayed project changes without a terminal prompt
33
+ --disconnect Remove this project's locally stored authorization
34
+ ```
35
+
36
+ ## Runtime credentials
37
+
38
+ Project setup authorization is not an observation credential. The deployed
39
+ backend still needs every binding's reported public Connection key and the
40
+ binding's source ingest token in its runtime secret environment:
41
+
42
+ ```text
43
+ SEAMWARD_CONNECTION_KEY_CANDIDATE_C5E54BF1=sw_conn_v1...
44
+ SEAMWARD_INGEST_TOKEN_CANDIDATE_C5E54BF1=sw_ing_...
45
+ SEAMWARD_CONNECTION_KEY_PAYMENT_C5E54BF1=sw_conn_v1...
46
+ SEAMWARD_INGEST_TOKEN_PAYMENT_C5E54BF1=sw_ing_...
47
+ ```
48
+
49
+ Use the exact variable names returned by the reviewed setup plan. When several
50
+ bindings share one application source, their generated token variables can use
51
+ the same ingest token value.
52
+
53
+ Do not put runtime credentials in the project MCP configuration or an agent prompt.
54
+
55
+ ## Returning projects
56
+
57
+ Run the same command again as the service changes. A valid authorization is reused. The installer validates the grant and restarts browser approval when refresh is no longer possible. The setup MCP analyzes current source and proposes only new, stale, or conflicting boundaries.
58
+
59
+ If a running coding agent reports `authentication_required`, run the same installer command and retry the setup operation. Use `--disconnect` to remove only the local authorization. Revoke the **Project setup** client under **Workspace settings > MCP** to invalidate active access and refresh tokens. Neither action changes application source or runtime environment files.
@@ -0,0 +1,30 @@
1
+ export declare const setupMcpDependency: string;
2
+ export type PackageManager = "pnpm" | "npm" | "yarn" | "bun";
3
+ export interface BootstrapFile {
4
+ path: string;
5
+ content: string;
6
+ changed: boolean;
7
+ }
8
+ export interface BootstrapPlan {
9
+ root: string;
10
+ packageManager: PackageManager;
11
+ install: {
12
+ command: string;
13
+ args: string[];
14
+ cwd: string;
15
+ };
16
+ installRequired: boolean;
17
+ files: BootstrapFile[];
18
+ }
19
+ export interface BootstrapOptions {
20
+ root: string;
21
+ credentialId?: string;
22
+ }
23
+ export interface BootstrapApplyOptions {
24
+ run?: (command: string, args: string[], cwd: string) => Promise<void>;
25
+ }
26
+ export declare function configuredCredentialId(root: string): Promise<string | null>;
27
+ export declare function createBootstrapPlan({ root: requestedRoot, credentialId, }: BootstrapOptions): Promise<BootstrapPlan>;
28
+ export declare function applyBootstrap(plan: BootstrapPlan, { run }?: BootstrapApplyOptions): Promise<void>;
29
+ export declare function renderBootstrapPlan(plan: BootstrapPlan): string;
30
+ export declare function renderBootstrapSummary(plan: BootstrapPlan): string;
@@ -0,0 +1,398 @@
1
+ import { spawn } from "node:child_process";
2
+ import { access, mkdir, readFile, rename, rm, writeFile, } from "node:fs/promises";
3
+ import path from "node:path";
4
+ import { setupMcpVersion } from "@seamward/setup-mcp";
5
+ const setupMcpPackage = "@seamward/setup-mcp";
6
+ export const setupMcpDependency = `${setupMcpPackage}@${setupMcpVersion}`;
7
+ const managedStart = "# seamward:setup begin";
8
+ const managedEnd = "# seamward:setup end";
9
+ async function exists(target) {
10
+ try {
11
+ await access(target);
12
+ return true;
13
+ }
14
+ catch {
15
+ return false;
16
+ }
17
+ }
18
+ async function readOptional(target) {
19
+ try {
20
+ return await readFile(target, "utf8");
21
+ }
22
+ catch (error) {
23
+ if (error.code === "ENOENT")
24
+ return null;
25
+ throw error;
26
+ }
27
+ }
28
+ export async function configuredCredentialId(root) {
29
+ const source = await readOptional(path.join(path.resolve(root), ".mcp.json"));
30
+ if (!source)
31
+ return null;
32
+ const config = parseJsonConfig(source, ".mcp.json");
33
+ const servers = config.mcpServers;
34
+ if (!servers || typeof servers !== "object" || Array.isArray(servers))
35
+ return null;
36
+ const server = servers["seamward-setup"];
37
+ if (!server || typeof server !== "object" || Array.isArray(server))
38
+ return null;
39
+ const args = server.args;
40
+ if (!Array.isArray(args))
41
+ return null;
42
+ const index = args.indexOf("--credential");
43
+ const value = index >= 0 ? args[index + 1] : null;
44
+ return typeof value === "string" && /^cred_[A-Za-z0-9_-]+$/.test(value)
45
+ ? value
46
+ : null;
47
+ }
48
+ async function detectPackageManager(root) {
49
+ const candidates = [
50
+ ["pnpm-lock.yaml", "pnpm"],
51
+ ["package-lock.json", "npm"],
52
+ ["yarn.lock", "yarn"],
53
+ ["bun.lock", "bun"],
54
+ ["bun.lockb", "bun"],
55
+ ];
56
+ let current = root;
57
+ let nearest;
58
+ while (true) {
59
+ if (await exists(path.join(current, "pnpm-workspace.yaml"))) {
60
+ return { installRoot: current, manager: "pnpm", workspaceRoot: true };
61
+ }
62
+ if (!nearest) {
63
+ for (const [file, manager] of candidates) {
64
+ if (await exists(path.join(current, file))) {
65
+ nearest = { installRoot: current, manager };
66
+ break;
67
+ }
68
+ }
69
+ }
70
+ const parent = path.dirname(current);
71
+ if (parent === current)
72
+ break;
73
+ current = parent;
74
+ }
75
+ return nearest
76
+ ? { ...nearest, workspaceRoot: false }
77
+ : { installRoot: root, manager: "npm", workspaceRoot: false };
78
+ }
79
+ function installCommand(context) {
80
+ if (context.manager === "pnpm") {
81
+ return {
82
+ command: "pnpm",
83
+ args: [
84
+ "add",
85
+ "--save-dev",
86
+ "--save-exact",
87
+ ...(context.workspaceRoot ? ["--workspace-root"] : []),
88
+ setupMcpDependency,
89
+ ],
90
+ cwd: context.installRoot,
91
+ };
92
+ }
93
+ if (context.manager === "yarn") {
94
+ return {
95
+ command: "yarn",
96
+ args: ["add", "--dev", "--exact", setupMcpDependency],
97
+ cwd: context.installRoot,
98
+ };
99
+ }
100
+ if (context.manager === "bun") {
101
+ return {
102
+ command: "bun",
103
+ args: ["add", "--dev", "--exact", setupMcpDependency],
104
+ cwd: context.installRoot,
105
+ };
106
+ }
107
+ return {
108
+ command: "npm",
109
+ args: ["install", "--save-dev", "--save-exact", setupMcpDependency],
110
+ cwd: context.installRoot,
111
+ };
112
+ }
113
+ function serverCommand(manager, credentialId) {
114
+ const credentialArguments = credentialId
115
+ ? ["--credential", credentialId]
116
+ : [];
117
+ if (manager === "pnpm") {
118
+ return {
119
+ command: "pnpm",
120
+ args: [
121
+ "exec",
122
+ "seamward-setup-mcp",
123
+ "--root",
124
+ ".",
125
+ ...credentialArguments,
126
+ ],
127
+ };
128
+ }
129
+ if (manager === "yarn") {
130
+ return {
131
+ command: "yarn",
132
+ args: [
133
+ "exec",
134
+ "seamward-setup-mcp",
135
+ "--root",
136
+ ".",
137
+ ...credentialArguments,
138
+ ],
139
+ };
140
+ }
141
+ if (manager === "bun") {
142
+ return {
143
+ command: "bunx",
144
+ args: [
145
+ "--no-install",
146
+ "seamward-setup-mcp",
147
+ "--root",
148
+ ".",
149
+ ...credentialArguments,
150
+ ],
151
+ };
152
+ }
153
+ return {
154
+ command: "npx",
155
+ args: [
156
+ "--no-install",
157
+ "seamward-setup-mcp",
158
+ "--root",
159
+ ".",
160
+ ...credentialArguments,
161
+ ],
162
+ };
163
+ }
164
+ function parseJsonConfig(content, file) {
165
+ if (content === null || content.trim() === "")
166
+ return {};
167
+ try {
168
+ const parsed = JSON.parse(content);
169
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
170
+ throw new Error("expected an object");
171
+ }
172
+ return parsed;
173
+ }
174
+ catch (error) {
175
+ const detail = error instanceof Error ? error.message : "invalid JSON";
176
+ throw new Error(`${file} is not valid JSON: ${detail}`);
177
+ }
178
+ }
179
+ function sameServer(value, expected) {
180
+ return JSON.stringify(value) === JSON.stringify(expected);
181
+ }
182
+ function withoutCredentialArgument(value) {
183
+ if (!value || typeof value !== "object" || Array.isArray(value))
184
+ return null;
185
+ const server = value;
186
+ if (!Array.isArray(server.args))
187
+ return server;
188
+ const args = [...server.args];
189
+ const credentialIndex = args.indexOf("--credential");
190
+ if (credentialIndex >= 0)
191
+ args.splice(credentialIndex, 2);
192
+ return { ...server, args };
193
+ }
194
+ function isManagedServer(value, expected) {
195
+ const currentWithoutCredential = withoutCredentialArgument(value);
196
+ const expectedWithoutCredential = withoutCredentialArgument(expected);
197
+ if (!currentWithoutCredential || !expectedWithoutCredential)
198
+ return false;
199
+ return sameServer(currentWithoutCredential, expectedWithoutCredential);
200
+ }
201
+ function mergeJsonConfig(existing, file, manager, credentialId) {
202
+ const config = parseJsonConfig(existing, file);
203
+ const currentServers = config.mcpServers;
204
+ if (currentServers !== undefined &&
205
+ (!currentServers ||
206
+ typeof currentServers !== "object" ||
207
+ Array.isArray(currentServers))) {
208
+ throw new Error(`${file} must define mcpServers as an object`);
209
+ }
210
+ const mcpServers = { ...(currentServers ?? {}) };
211
+ const expected = serverCommand(manager, credentialId);
212
+ const current = mcpServers["seamward-setup"];
213
+ if (current !== undefined &&
214
+ !sameServer(current, expected) &&
215
+ !isManagedServer(current, expected)) {
216
+ throw new Error(`${file} already defines seamward-setup. Remove or rename that custom server before running Seamward setup.`);
217
+ }
218
+ mcpServers["seamward-setup"] = expected;
219
+ return `${JSON.stringify({ ...config, mcpServers }, null, 2)}\n`;
220
+ }
221
+ function escapeToml(value) {
222
+ return JSON.stringify(value);
223
+ }
224
+ function codexManagedBlock(manager, credentialId) {
225
+ const server = serverCommand(manager, credentialId);
226
+ return [
227
+ managedStart,
228
+ "[mcp_servers.seamward-setup]",
229
+ `command = ${escapeToml(server.command)}`,
230
+ `args = [${server.args.map(escapeToml).join(", ")}]`,
231
+ 'cwd = "."',
232
+ "required = true",
233
+ 'default_tools_approval_mode = "writes"',
234
+ managedEnd,
235
+ ].join("\n");
236
+ }
237
+ function mergeCodexConfig(existing, manager, credentialId) {
238
+ const source = existing ?? "";
239
+ const start = source.indexOf(managedStart);
240
+ const end = source.indexOf(managedEnd);
241
+ const unmanaged = start >= 0 && end >= start
242
+ ? `${source.slice(0, start)}${source.slice(end + managedEnd.length)}`
243
+ : source;
244
+ if (unmanaged.includes("[mcp_servers.seamward-setup]")) {
245
+ throw new Error(".codex/config.toml already defines seamward-setup outside Seamward's managed block. Remove or rename that custom server before running Seamward setup.");
246
+ }
247
+ if (start >= 0 !== end >= 0) {
248
+ throw new Error(".codex/config.toml contains an incomplete Seamward managed block.");
249
+ }
250
+ const prefix = unmanaged.trimEnd();
251
+ return `${prefix ? `${prefix}\n\n` : ""}${codexManagedBlock(manager, credentialId)}\n`;
252
+ }
253
+ function dependencyInstalled(packageJson) {
254
+ for (const section of ["devDependencies", "dependencies"]) {
255
+ const dependencies = packageJson[section];
256
+ if (dependencies &&
257
+ typeof dependencies === "object" &&
258
+ !Array.isArray(dependencies) &&
259
+ dependencies[setupMcpPackage] === setupMcpVersion) {
260
+ return true;
261
+ }
262
+ }
263
+ return false;
264
+ }
265
+ async function installedPackageMatches(root) {
266
+ const content = await readOptional(path.join(root, "node_modules", "@seamward", "setup-mcp", "package.json"));
267
+ if (!content)
268
+ return false;
269
+ const packageJson = parseJsonConfig(content, "node_modules/@seamward/setup-mcp/package.json");
270
+ return packageJson.version === setupMcpVersion;
271
+ }
272
+ export async function createBootstrapPlan({ root: requestedRoot, credentialId, }) {
273
+ const root = path.resolve(requestedRoot);
274
+ const packageJsonPath = path.join(root, "package.json");
275
+ const packageJsonContent = await readOptional(packageJsonPath);
276
+ if (packageJsonContent === null) {
277
+ throw new Error("Run Seamward setup from a project containing package.json.");
278
+ }
279
+ const packageJson = parseJsonConfig(packageJsonContent, "package.json");
280
+ const packageManagerContext = await detectPackageManager(root);
281
+ const packageManager = packageManagerContext.manager;
282
+ const installPackageJsonContent = await readOptional(path.join(packageManagerContext.installRoot, "package.json"));
283
+ const installPackageJson = installPackageJsonContent
284
+ ? parseJsonConfig(installPackageJsonContent, "package.json")
285
+ : {};
286
+ const installedPackagePresent = (await installedPackageMatches(root)) ||
287
+ (packageManagerContext.installRoot !== root &&
288
+ (await installedPackageMatches(packageManagerContext.installRoot)));
289
+ const configurations = [
290
+ {
291
+ path: ".mcp.json",
292
+ render: (current) => mergeJsonConfig(current, ".mcp.json", packageManager, credentialId),
293
+ },
294
+ {
295
+ path: ".cursor/mcp.json",
296
+ render: (current) => mergeJsonConfig(current, ".cursor/mcp.json", packageManager, credentialId),
297
+ },
298
+ {
299
+ path: ".codex/config.toml",
300
+ render: (current) => mergeCodexConfig(current, packageManager, credentialId),
301
+ },
302
+ ];
303
+ const files = await Promise.all(configurations.map(async (configuration) => {
304
+ const target = path.join(root, configuration.path);
305
+ const current = await readOptional(target);
306
+ const content = configuration.render(current);
307
+ return {
308
+ path: configuration.path,
309
+ content,
310
+ changed: current !== content,
311
+ };
312
+ }));
313
+ return {
314
+ root,
315
+ packageManager,
316
+ install: installCommand(packageManagerContext),
317
+ installRequired: !dependencyInstalled(packageJson) &&
318
+ !dependencyInstalled(installPackageJson) &&
319
+ !installedPackagePresent,
320
+ files,
321
+ };
322
+ }
323
+ function safeChildEnvironment(source) {
324
+ const allowed = [
325
+ "CI",
326
+ "PATH",
327
+ "SHELL",
328
+ "TERM",
329
+ "TMPDIR",
330
+ "USER",
331
+ "XDG_CACHE_HOME",
332
+ "XDG_CONFIG_HOME",
333
+ ];
334
+ return Object.fromEntries(allowed.flatMap((name) => source[name] === undefined ? [] : [[name, source[name]]]));
335
+ }
336
+ async function runCommand(command, args, cwd) {
337
+ await new Promise((resolve, reject) => {
338
+ const child = spawn(command, args, {
339
+ cwd,
340
+ env: safeChildEnvironment(process.env),
341
+ stdio: "inherit",
342
+ });
343
+ child.once("error", reject);
344
+ child.once("exit", (code, signal) => {
345
+ if (code === 0)
346
+ resolve();
347
+ else
348
+ reject(new Error(`${command} failed${signal ? ` with signal ${signal}` : ` with exit code ${code ?? "unknown"}`}`));
349
+ });
350
+ });
351
+ }
352
+ async function writeAtomic(target, content) {
353
+ await mkdir(path.dirname(target), { recursive: true });
354
+ const temporary = `${target}.seamward-${process.pid}.tmp`;
355
+ try {
356
+ await writeFile(temporary, content, { mode: 0o600 });
357
+ await rename(temporary, target);
358
+ }
359
+ finally {
360
+ await rm(temporary, { force: true });
361
+ }
362
+ }
363
+ export async function applyBootstrap(plan, { run = runCommand } = {}) {
364
+ if (plan.installRequired) {
365
+ await run(plan.install.command, plan.install.args, plan.install.cwd);
366
+ }
367
+ for (const file of plan.files) {
368
+ if (file.changed) {
369
+ await writeAtomic(path.join(plan.root, file.path), file.content);
370
+ }
371
+ }
372
+ }
373
+ export function renderBootstrapPlan(plan) {
374
+ const changes = plan.files.filter(({ changed }) => changed);
375
+ const lines = ["Seamward setup preview", ""];
376
+ if (plan.installRequired) {
377
+ lines.push(`Dependency: ${plan.install.command} ${plan.install.args.join(" ")}`);
378
+ }
379
+ else {
380
+ lines.push(`Dependency: ${setupMcpPackage}@${setupMcpVersion} is installed`);
381
+ }
382
+ lines.push(`Project configuration: ${changes.length > 0 ? changes.map(({ path: file }) => file).join(", ") : "already current"}`, "Environment files: not read or changed");
383
+ return lines.join("\n");
384
+ }
385
+ export function renderBootstrapSummary(plan) {
386
+ const changed = plan.installRequired || plan.files.some((file) => file.changed);
387
+ return [
388
+ changed
389
+ ? "Seamward is configured for this project."
390
+ : "Seamward is already configured for this project.",
391
+ "Reopen your coding agent, then enter:",
392
+ "",
393
+ "Set up Seamward in this project.",
394
+ "",
395
+ "On later runs, the same prompt checks the saved setup against the current codebase and proposes only new or stale work.",
396
+ ].join("\n");
397
+ }
398
+ //# sourceMappingURL=bootstrap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EACL,MAAM,EACN,KAAK,EACL,QAAQ,EACR,MAAM,EACN,EAAE,EACF,SAAS,GACV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,MAAM,eAAe,GAAG,qBAAqB,CAAC;AAC9C,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,eAAe,IAAI,eAAe,EAAE,CAAC;AAC1E,MAAM,YAAY,GAAG,wBAAwB,CAAC;AAC9C,MAAM,UAAU,GAAG,sBAAsB,CAAC;AA6B1C,KAAK,UAAU,MAAM,CAAC,MAAc;IAClC,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,MAAM,CAAC,CAAC;QACrB,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,KAAK,UAAU,YAAY,CAAC,MAAc;IACxC,IAAI,CAAC;QACH,OAAO,MAAM,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ;YAAE,OAAO,IAAI,CAAC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 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/cli.js ADDED
@@ -0,0 +1,119 @@
1
+ #!/usr/bin/env node
2
+ import { createInterface } from "node:readline/promises";
3
+ import { stdin, stdout } from "node:process";
4
+ import { applyBootstrap, configuredCredentialId, createBootstrapPlan, renderBootstrapPlan, renderBootstrapSummary, } from "./bootstrap.js";
5
+ import { authorizeSetup } from "./oauth.js";
6
+ import { ensureSetupCredential } from "@seamward/setup-mcp/credentials";
7
+ import { removeSetupCredential } from "@seamward/setup-mcp/credentials";
8
+ function usage() {
9
+ return [
10
+ "Usage: npx @seamward/setup@alpha [--yes] [--dry-run] [--disconnect] [--integration <id>]",
11
+ "",
12
+ "Configures the current project for agent-assisted Seamward setup.",
13
+ "Environment files are never read or changed.",
14
+ ].join("\n");
15
+ }
16
+ const arguments_ = process.argv.slice(2);
17
+ if (arguments_.includes("--help") || arguments_.includes("-h")) {
18
+ stdout.write(`${usage()}\n`);
19
+ process.exit(0);
20
+ }
21
+ const flags = new Set();
22
+ const values = new Map();
23
+ for (let index = 0; index < arguments_.length; index += 1) {
24
+ const argument = arguments_[index];
25
+ if (argument === "--yes" ||
26
+ argument === "--dry-run" ||
27
+ argument === "--disconnect")
28
+ flags.add(argument);
29
+ else if (argument === "--integration" ||
30
+ argument === "--console-url" ||
31
+ argument === "--api-url") {
32
+ const value = arguments_[index + 1];
33
+ if (!value) {
34
+ process.stderr.write(`Missing value for ${argument}.\n\n${usage()}\n`);
35
+ process.exit(1);
36
+ }
37
+ values.set(argument, value);
38
+ index += 1;
39
+ }
40
+ else {
41
+ process.stderr.write(`Unknown option: ${argument}\n\n${usage()}\n`);
42
+ process.exit(1);
43
+ }
44
+ }
45
+ try {
46
+ const root = process.cwd();
47
+ const requestedIntegrationId = values.get("--integration");
48
+ let credentialId = await configuredCredentialId(root);
49
+ if (flags.has("--disconnect")) {
50
+ if (credentialId)
51
+ await removeSetupCredential(credentialId);
52
+ stdout.write(credentialId
53
+ ? "Local Seamward setup authorization removed. Project configuration was preserved.\n"
54
+ : "No local Seamward setup authorization was configured.\n");
55
+ process.exit(0);
56
+ }
57
+ if (credentialId) {
58
+ try {
59
+ const current = await ensureSetupCredential(credentialId);
60
+ if (requestedIntegrationId &&
61
+ !(current.integrationId === requestedIntegrationId ||
62
+ current.integrations?.some(({ id }) => id === requestedIntegrationId))) {
63
+ credentialId = null;
64
+ }
65
+ }
66
+ catch {
67
+ credentialId = null;
68
+ }
69
+ }
70
+ if (!credentialId && !flags.has("--dry-run")) {
71
+ const consoleUrl = values.get("--console-url") ?? "https://seamward.com";
72
+ const authorization = await authorizeSetup({
73
+ apiBaseUrl: values.get("--api-url") ?? "https://api.seamward.com",
74
+ authBaseUrl: `${consoleUrl.replace(/\/$/, "")}/api/auth`,
75
+ ...(requestedIntegrationId
76
+ ? { integrationId: requestedIntegrationId }
77
+ : {}),
78
+ onAuthorizationUrl: (url) => stdout.write(`Continue setup in your browser. If it did not open, use this URL:\n${url}\n`),
79
+ setupResource: `${consoleUrl.replace(/\/$/, "")}/api/setup`,
80
+ });
81
+ credentialId = authorization.credentialId;
82
+ stdout.write(authorization.source
83
+ ? `Authorized application environment ${authorization.source.environmentId} in ${authorization.workspace.slug}.\n`
84
+ : `Authorized ${authorization.integrations.length} Integration${authorization.integrations.length === 1 ? "" : "s"} in ${authorization.workspace.slug}.\n`);
85
+ }
86
+ const plan = await createBootstrapPlan({
87
+ root,
88
+ ...(credentialId ? { credentialId } : {}),
89
+ });
90
+ stdout.write(`${renderBootstrapPlan(plan)}\n`);
91
+ if (flags.has("--dry-run"))
92
+ process.exit(0);
93
+ let approved = flags.has("--yes");
94
+ if (!approved) {
95
+ if (!stdin.isTTY || !stdout.isTTY) {
96
+ throw new Error("Interactive approval is unavailable. Review with --dry-run, then rerun with --yes.");
97
+ }
98
+ const prompt = createInterface({ input: stdin, output: stdout });
99
+ try {
100
+ const answer = await prompt.question("Apply these project changes? [y/N] ");
101
+ approved = answer.trim().toLowerCase() === "y";
102
+ }
103
+ finally {
104
+ prompt.close();
105
+ }
106
+ }
107
+ if (!approved) {
108
+ stdout.write("No changes applied.\n");
109
+ process.exit(0);
110
+ }
111
+ await applyBootstrap(plan);
112
+ stdout.write(`\n${renderBootstrapSummary(plan)}\n`);
113
+ }
114
+ catch (error) {
115
+ const message = error instanceof Error ? error.message : "Setup failed.";
116
+ process.stderr.write(`Seamward setup failed: ${message}\n`);
117
+ process.exitCode = 1;
118
+ }
119
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAExE,SAAS,KAAK;IACZ,OAAO;QACL,0FAA0F;QAC1F,EAAE;QACF,mEAAmE;QACnE,8CAA8C;KAC/C,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC;AAED,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACzC,IAAI,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;IAC/D,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,EAAE,IAAI,CAAC,CAAC;IAC7B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AACD,MAAM,KAAK,G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,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,QAAQ,CAClC,qCAAqC,CACtC,CAAC;YACF,QAAQ,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,GAAG,CAAC;QACjD,CAAC;gBAAS,CAAC;YACT,MAAM,CAAC,KAAK,EAAE,CAAC;QACjB,CAAC;IACH,CAAC;IACD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;QACtC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IACD,MAAM,cAAc,CAAC,IAAI,CAAC,CAAC;IAC3B,MAAM,CAAC,KAAK,CAAC,KAAK,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACtD,CAAC;AAAC,OAAO,KAAK,EAAE,CAAC;IACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;IACzE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,0BAA0B,OAAO,IAAI,CAAC,CAAC;IAC5D,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { applyBootstrap, createBootstrapPlan, configuredCredentialId, renderBootstrapPlan, renderBootstrapSummary, type BootstrapApplyOptions, type BootstrapFile, type BootstrapOptions, type BootstrapPlan, type PackageManager, } from "./bootstrap.js";
2
+ export { authorizeSetup, type AuthorizeSetupOptions, type SetupAuthorizationResult, } from "./oauth.js";
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export { applyBootstrap, createBootstrapPlan, configuredCredentialId, renderBootstrapPlan, renderBootstrapSummary, } from "./bootstrap.js";
2
+ export { authorizeSetup, } from "./oauth.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,sBAAsB,EACtB,mBAAmB,EACnB,sBAAsB,GAMvB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,cAAc,GAGf,MAAM,YAAY,CAAC"}
@@ -0,0 +1,32 @@
1
+ interface AuthorizationCode {
2
+ code: string;
3
+ state: string;
4
+ }
5
+ export interface AuthorizeSetupOptions {
6
+ apiBaseUrl: string;
7
+ authBaseUrl: string;
8
+ credentialFile?: string;
9
+ fetchFn?: typeof fetch;
10
+ integrationId?: string;
11
+ now?: () => number;
12
+ onAuthorizationUrl?: (url: string) => void;
13
+ randomToken?: (length: number) => string;
14
+ receiveAuthorizationCode?: (authorizationUrl: string, expectedState: string) => Promise<AuthorizationCode>;
15
+ setupResource: string;
16
+ }
17
+ export interface SetupAuthorizationResult {
18
+ credentialId: string;
19
+ integrations: Array<{
20
+ id: string;
21
+ name: string;
22
+ }>;
23
+ source?: {
24
+ environmentId: string;
25
+ id: string;
26
+ };
27
+ workspace: {
28
+ slug: string;
29
+ };
30
+ }
31
+ export declare function authorizeSetup(options: AuthorizeSetupOptions): Promise<SetupAuthorizationResult>;
32
+ export {};
package/dist/oauth.js ADDED
@@ -0,0 +1,257 @@
1
+ import { createHash, randomBytes } from "node:crypto";
2
+ import { spawn } from "node:child_process";
3
+ import http from "node:http";
4
+ import { saveSetupCredential } from "@seamward/setup-mcp/credentials";
5
+ const setupScopes = [
6
+ "seamward:setup:integrations:read",
7
+ "seamward:setup:integrations:write",
8
+ "seamward:setup:contracts:read",
9
+ "seamward:setup:contracts:write",
10
+ "seamward:setup:contracts:activate",
11
+ "seamward:setup:observations:read",
12
+ "offline_access",
13
+ ];
14
+ function base64Url(value) {
15
+ return value.toString("base64url");
16
+ }
17
+ function secureToken(length) {
18
+ return base64Url(randomBytes(Math.ceil((length * 3) / 4))).slice(0, length);
19
+ }
20
+ function stableCredentialId(input) {
21
+ const alias = createHash("sha256")
22
+ .update(`${input.apiBaseUrl}\n${input.workspaceSlug}\n${input.collectorSourceId ?? ""}\n${[...input.integrationIds].sort().join(",")}`)
23
+ .digest("base64url")
24
+ .slice(0, 24);
25
+ return `cred_${alias}`;
26
+ }
27
+ function openBrowser(url) {
28
+ const [command, args] = process.platform === "darwin"
29
+ ? ["open", [url]]
30
+ : process.platform === "win32"
31
+ ? ["cmd", ["/c", "start", "", url]]
32
+ : ["xdg-open", [url]];
33
+ const child = spawn(command, args, { detached: true, stdio: "ignore" });
34
+ child.unref();
35
+ }
36
+ function validUrl(value) {
37
+ const url = new URL(value);
38
+ const loopback = ["127.0.0.1", "localhost", "::1"].includes(url.hostname);
39
+ if (url.protocol !== "https:" && !(url.protocol === "http:" && loopback)) {
40
+ throw new Error("Seamward setup URLs must use HTTPS unless they are local.");
41
+ }
42
+ return url.toString().replace(/\/$/, "");
43
+ }
44
+ export async function authorizeSetup(options) {
45
+ const authBaseUrl = validUrl(options.authBaseUrl);
46
+ const apiBaseUrl = validUrl(options.apiBaseUrl);
47
+ const setupResource = validUrl(options.setupResource);
48
+ const fetchFn = options.fetchFn ?? fetch;
49
+ const randomToken = options.randomToken ?? secureToken;
50
+ const state = randomToken(32);
51
+ const verifier = randomToken(64);
52
+ const challenge = base64Url(createHash("sha256").update(verifier).digest());
53
+ let redirectUri = "http://127.0.0.1/callback";
54
+ const register = async (callback) => {
55
+ redirectUri = callback;
56
+ const response = await fetchFn(`${authBaseUrl}/oauth2/register`, {
57
+ body: JSON.stringify({
58
+ client_name: "Seamward project setup",
59
+ client_uri: "https://seamward.com/docs/integrate/automatic-setup",
60
+ grant_types: ["authorization_code", "refresh_token"],
61
+ redirect_uris: [redirectUri],
62
+ response_types: ["code"],
63
+ scope: setupScopes.join(" "),
64
+ software_id: "seamward-setup-cli",
65
+ software_version: "0.1.0-alpha.0",
66
+ token_endpoint_auth_method: "none",
67
+ type: "native",
68
+ }),
69
+ headers: { "content-type": "application/json" },
70
+ method: "POST",
71
+ });
72
+ if (!response.ok)
73
+ throw new Error("Seamward could not register the setup client.");
74
+ const payload = (await response.json());
75
+ if (typeof payload.client_id !== "string") {
76
+ throw new Error("Seamward returned an invalid setup client.");
77
+ }
78
+ return payload.client_id;
79
+ };
80
+ let clientId = "";
81
+ const buildAuthorizationUrl = (callback) => {
82
+ const url = new URL(`${authBaseUrl}/oauth2/authorize`);
83
+ url.searchParams.set("client_id", clientId);
84
+ url.searchParams.set("code_challenge", challenge);
85
+ url.searchParams.set("code_challenge_method", "S256");
86
+ url.searchParams.set("redirect_uri", callback);
87
+ url.searchParams.set("resource", setupResource);
88
+ url.searchParams.set("response_type", "code");
89
+ url.searchParams.set("scope", setupScopes.join(" "));
90
+ url.searchParams.set("state", state);
91
+ if (options.integrationId) {
92
+ url.searchParams.set("seamward_integration_id", options.integrationId);
93
+ }
94
+ return url.toString();
95
+ };
96
+ let authorization;
97
+ if (options.receiveAuthorizationCode) {
98
+ clientId = await register(redirectUri);
99
+ authorization = await options.receiveAuthorizationCode(buildAuthorizationUrl(redirectUri), state);
100
+ }
101
+ else {
102
+ authorization = await new Promise((resolve, reject) => {
103
+ const server = http.createServer(async (request, response) => {
104
+ const requestUrl = new URL(request.url ?? "/", "http://127.0.0.1");
105
+ const code = requestUrl.searchParams.get("code");
106
+ const returnedState = requestUrl.searchParams.get("state");
107
+ if (!code || returnedState !== state) {
108
+ response.writeHead(400, {
109
+ "content-type": "text/plain; charset=utf-8",
110
+ });
111
+ response.end("Seamward setup authorization was not completed.");
112
+ return;
113
+ }
114
+ response.writeHead(200, {
115
+ "content-type": "text/plain; charset=utf-8",
116
+ });
117
+ response.end("Seamward setup is authorized. You can return to your terminal.");
118
+ server.close();
119
+ resolve({ code, state: returnedState });
120
+ });
121
+ server.once("error", reject);
122
+ server.listen(0, "127.0.0.1", async () => {
123
+ try {
124
+ const address = server.address();
125
+ if (!address || typeof address === "string")
126
+ throw new Error("callback unavailable");
127
+ redirectUri = `http://127.0.0.1:${address.port}/callback`;
128
+ clientId = await register(redirectUri);
129
+ const authorizationUrl = buildAuthorizationUrl(redirectUri);
130
+ options.onAuthorizationUrl?.(authorizationUrl);
131
+ openBrowser(authorizationUrl);
132
+ }
133
+ catch (error) {
134
+ server.close();
135
+ reject(error);
136
+ }
137
+ });
138
+ setTimeout(() => {
139
+ server.close();
140
+ reject(new Error("Seamward setup authorization timed out."));
141
+ }, 5 * 60_000).unref();
142
+ });
143
+ }
144
+ if (authorization.state !== state)
145
+ throw new Error("Seamward setup authorization state is invalid.");
146
+ const tokenBody = new URLSearchParams({
147
+ client_id: clientId,
148
+ code: authorization.code,
149
+ code_verifier: verifier,
150
+ grant_type: "authorization_code",
151
+ redirect_uri: redirectUri,
152
+ resource: setupResource,
153
+ });
154
+ const tokenResponse = await fetchFn(`${authBaseUrl}/oauth2/token`, {
155
+ body: tokenBody,
156
+ headers: { "content-type": "application/x-www-form-urlencoded" },
157
+ method: "POST",
158
+ });
159
+ if (!tokenResponse.ok)
160
+ throw new Error("Seamward setup authorization could not be completed.");
161
+ const token = (await tokenResponse.json());
162
+ if (typeof token.access_token !== "string" ||
163
+ typeof token.refresh_token !== "string" ||
164
+ typeof token.expires_in !== "number") {
165
+ throw new Error("Seamward returned an invalid setup authorization response.");
166
+ }
167
+ const contextResponse = await fetchFn(`${apiBaseUrl}/v1/setup/context`, {
168
+ headers: { authorization: `Bearer ${token.access_token}` },
169
+ });
170
+ if (!contextResponse.ok)
171
+ throw new Error("Seamward setup context could not be loaded.");
172
+ const context = (await contextResponse.json());
173
+ if (!Array.isArray(context.integrations) ||
174
+ context.integrations.some((integration) => typeof integration.connectionKey !== "string" ||
175
+ typeof integration.id !== "string" ||
176
+ typeof integration.integrationKey !== "string" ||
177
+ typeof integration.name !== "string" ||
178
+ typeof integration.provider !== "string" ||
179
+ typeof integration.sourceKey !== "string" ||
180
+ !["inbound", "outbound"].includes(String(integration.direction)) ||
181
+ !["http-api", "http-webhook", "queue", "scheduled-feed"].includes(String(integration.protocol))) ||
182
+ typeof context.workspace?.slug !== "string" ||
183
+ (context.integrations.length === 0 &&
184
+ (typeof context.source?.id !== "string" ||
185
+ typeof context.source?.environmentId !== "string" ||
186
+ typeof context.source?.sourceKey !== "string"))) {
187
+ throw new Error("Seamward returned an invalid setup context.");
188
+ }
189
+ if (options.integrationId &&
190
+ !context.integrations.some((integration) => integration.id === options.integrationId)) {
191
+ throw new Error("Seamward authorized a different Integration from the one requested.");
192
+ }
193
+ const credentialId = stableCredentialId({
194
+ apiBaseUrl,
195
+ ...(typeof context.source?.id === "string"
196
+ ? { collectorSourceId: context.source.id }
197
+ : {}),
198
+ integrationIds: context.integrations.map((integration) => String(integration.id)),
199
+ workspaceSlug: context.workspace.slug,
200
+ });
201
+ await saveSetupCredential({
202
+ accessToken: token.access_token,
203
+ apiBaseUrl,
204
+ authBaseUrl,
205
+ clientId,
206
+ ...(typeof context.source?.id === "string"
207
+ ? { collectorSourceId: context.source.id }
208
+ : {}),
209
+ ...(context.integrations[0]
210
+ ? { connectionKey: String(context.integrations[0].connectionKey) }
211
+ : {}),
212
+ ...(typeof context.source?.environmentId === "string"
213
+ ? { environmentId: context.source.environmentId }
214
+ : {}),
215
+ expiresAt: (options.now?.() ?? Date.now()) + token.expires_in * 1_000,
216
+ id: credentialId,
217
+ ...(context.integrations[0]
218
+ ? { integrationId: String(context.integrations[0].id) }
219
+ : {}),
220
+ integrations: context.integrations.map((integration) => ({
221
+ connectionKey: String(integration.connectionKey),
222
+ direction: integration.direction,
223
+ id: String(integration.id),
224
+ integrationKey: String(integration.integrationKey),
225
+ name: String(integration.name),
226
+ protocol: integration.protocol,
227
+ provider: String(integration.provider),
228
+ sourceKey: String(integration.sourceKey),
229
+ })),
230
+ refreshToken: token.refresh_token,
231
+ setupResource,
232
+ sourceKey: typeof context.source?.sourceKey === "string"
233
+ ? context.source.sourceKey
234
+ : typeof context.sourceKey === "string"
235
+ ? context.sourceKey
236
+ : String(context.integrations[0]?.sourceKey),
237
+ workspaceSlug: context.workspace.slug,
238
+ }, options.credentialFile ? { file: options.credentialFile } : {});
239
+ return {
240
+ credentialId,
241
+ integrations: context.integrations.map((integration) => ({
242
+ id: String(integration.id),
243
+ name: String(integration.name),
244
+ })),
245
+ ...(typeof context.source?.id === "string" &&
246
+ typeof context.source.environmentId === "string"
247
+ ? {
248
+ source: {
249
+ environmentId: context.source.environmentId,
250
+ id: context.source.id,
251
+ },
252
+ }
253
+ : {}),
254
+ workspace: { slug: context.workspace.slug },
255
+ };
256
+ }
257
+ //# sourceMappingURL=oauth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth.js","sourceRoot":"","sources":["../src/oauth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAEtE,MAAM,WAAW,GAAG;IAClB,kCAAkC;IAClC,mCAAmC;IACnC,+BAA+B;IAC/B,gCAAgC;IAChC,mCAAmC;IACnC,kCAAkC;IAClC,gBAAgB;CACR,CAAC;AA8BX,SAAS,SAAS,CAAC,KAAa;IAC9B,OAAO,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;AACrC,CAAC;AAED,SAAS,WAAW,CAAC,MAAc;IACjC,OAAO,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,kBAAkB,CAAC,KAK3B;IACC,MAAM,KAAK,GAAG,UAAU,CAAC,QAAQ,CAAC;SAC/B,MAAM,CACL,GAAG,KAAK,CAAC,UAAU,KAAK,KAAK,CAAC,aAAa,KAAK,KAAK,CAAC,iBAA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,IAAI,EAAE,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC;SAC/B,CAAC,CAAC;QACH,GAAG,CAAC,OAAO,OAAO,CAAC,MAAM,EAAE,EAAE,KAAK,QAAQ;YAC1C,OAAO,OAAO,CAAC,MAAM,CAAC,aAAa,KAAK,QAAQ;YAC9C,CAAC,CAAC;gBACE,MAAM,EAAE;oBACN,aAAa,EAAE,OAAO,CAAC,MAAM,CAAC,aAAa;oBAC3C,EAAE,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE;iBACtB;aACF;YACH,CAAC,CAAC,EAAE,CAAC;QACP,SAAS,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,SAAS,CAAC,IAAI,EAAE;KAC5C,CAAC;AACJ,CAAC"}
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@seamward/setup",
3
+ "version": "0.1.0-alpha.2",
4
+ "description": "One-command, project-scoped setup for Seamward coding agents.",
5
+ "license": "SEE LICENSE IN LICENSE",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/a4anthony/relayguard.git",
9
+ "directory": "packages/setup"
10
+ },
11
+ "engines": {
12
+ "node": ">=22"
13
+ },
14
+ "private": false,
15
+ "files": [
16
+ "dist",
17
+ "README.md",
18
+ "LICENSE"
19
+ ],
20
+ "type": "module",
21
+ "main": "./dist/index.js",
22
+ "types": "./dist/index.d.ts",
23
+ "bin": {
24
+ "seamward-setup": "./dist/cli.js"
25
+ },
26
+ "exports": {
27
+ ".": {
28
+ "types": "./dist/index.d.ts",
29
+ "default": "./dist/index.js"
30
+ }
31
+ },
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
35
+ "dependencies": {
36
+ "@seamward/setup-mcp": "0.1.0-alpha.9"
37
+ },
38
+ "devDependencies": {
39
+ "@types/node": "^22.0.0",
40
+ "typescript": "^5.6.0",
41
+ "vitest": "^3.0.0"
42
+ },
43
+ "scripts": {
44
+ "build": "tsc -p tsconfig.json",
45
+ "postbuild": "node scripts/mark-bin-executable.mjs",
46
+ "typecheck": "tsc -p tsconfig.json --noEmit",
47
+ "test": "vitest run"
48
+ }
49
+ }