@stackwright-pro/launch-stackwright-pro 0.4.0-alpha.9 → 0.4.0-alpha.93

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,21 @@
1
+ PROPRIETARY SOFTWARE LICENSE
2
+
3
+ Copyright (c) 2024-2026 Per Aspera LLC. All Rights Reserved.
4
+
5
+ This software and associated documentation files (the "Software") are the
6
+ proprietary and confidential property of Per Aspera LLC ("Company").
7
+
8
+ RESTRICTIONS: You may not use, copy, modify, merge, publish, distribute,
9
+ sublicense, sell, or otherwise exploit this Software or any portion thereof
10
+ without the express prior written consent of the Company.
11
+
12
+ GOVERNMENT USE: Use, duplication, or disclosure by the U.S. Government is
13
+ subject to restrictions as set forth in FAR 52.227-19 (Commercial Computer
14
+ Software - Restricted Rights) and DFARS 252.227-7013 (Rights in Technical
15
+ Data and Computer Software), as applicable.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED. IN NO EVENT SHALL THE COMPANY BE LIABLE FOR ANY CLAIM, DAMAGES, OR
19
+ OTHER LIABILITY ARISING FROM THE USE OF THE SOFTWARE.
20
+
21
+ For licensing inquiries: legal@peraspera.com
package/README.md CHANGED
@@ -21,10 +21,14 @@ to automatically wire up Pro features:
21
21
  ## Quick Start
22
22
 
23
23
  ```bash
24
- pnpx @stackwright-pro/launch-stackwright-pro my-app -y
24
+ # Works — project created in $cwd/my-app
25
+ pnpx @stackwright-pro/launch-stackwright-pro --name my-app -y
25
26
  # Dependencies install automatically (~7s)
26
27
  cd my-app
27
- uvx stackwright-pro-raft # Start the otter raft
28
+ npx @stackwright-pro/raft # Start the otter raft
29
+
30
+ # Equivalent explicit form
31
+ pnpx @stackwright-pro/launch-stackwright-pro my-app --name my-app -y
28
32
  ```
29
33
 
30
34
  ### With an OpenAPI Spec
@@ -72,7 +76,7 @@ Options:
72
76
  --force Overwrite existing directory
73
77
  --skip-otters Skip otter raft setup
74
78
  -y, --yes Skip prompts, use defaults
75
- --spec <path> Path to an OpenAPI spec (YAML or JSON)
79
+ --spec <paths...> Paths to OpenAPI specs (can be specified multiple times)
76
80
  --spec-name <name> Name for the API integration (default: derived from filename)
77
81
  -V, --version Output the version number
78
82
  -h, --help Display help
@@ -120,24 +124,11 @@ for architecture details, auth deep-dives, and deployment guides.
120
124
 
121
125
  ## Starting the Otter Raft
122
126
 
123
- The otter raft runs in two modes:
124
-
125
- ### Interactive Mode (Default)
126
-
127
127
  ```bash
128
- python -m stackwright_pro.raft.cli_adapter foreman --spawn
128
+ cd my-app
129
+ npx @stackwright-pro/raft
129
130
  ```
130
131
 
131
- This spawns code-puppy with the foreman system prompt. The foreman:
132
-
133
- - Asks questions about your project via TUI
134
- - Coordinates specialist otters (brand, theme, api, auth, page)
135
- - Uses certificate pinning to ensure only approved otters are invoked
136
-
137
- ### Phases Mode (Debugging)
138
-
139
- ```bash
140
- python -m stackwright_pro.raft.cli_adapter foreman --phases
141
- ```
132
+ The raft verifies otter integrity, loads project context from `.stackwright/init-context.json`, and spawns code-puppy in foreman mode. Tell the foreman about your specs in natural language — it coordinates the API, auth, data, and page otters to build your app.
142
133
 
143
- Executes phases sequentially via the Python state machine. Useful for debugging.
134
+ All state lives in `.stackwright/` you can interrupt and resume at any time.
package/dist/index.js CHANGED
@@ -31,9 +31,9 @@ var require_package = __commonJS({
31
31
  "package.json"(exports2, module2) {
32
32
  module2.exports = {
33
33
  name: "@stackwright-pro/launch-stackwright-pro",
34
- version: "0.4.0-alpha.7",
34
+ version: "0.4.0-alpha.93",
35
35
  description: "Launch a new Stackwright Pro project with OpenAPI integration, auth, and the otter raft",
36
- license: "MIT",
36
+ license: "SEE LICENSE IN LICENSE",
37
37
  publishConfig: {
38
38
  access: "public"
39
39
  },
@@ -57,27 +57,33 @@ var require_package = __commonJS({
57
57
  "launch-stackwright-pro": "dist/index.js"
58
58
  },
59
59
  scripts: {
60
- build: "tsup",
60
+ build: "node ../../scripts/sync-versions.mjs && tsup",
61
+ "sync-versions": "node ../../scripts/sync-versions.mjs",
61
62
  dev: "tsup --watch",
62
63
  test: "vitest run",
63
64
  "test:coverage": "vitest run --coverage"
64
65
  },
65
66
  dependencies: {
67
+ "@stackwright-pro/auth": "workspace:*",
68
+ "@stackwright-pro/auth-nextjs": "workspace:*",
69
+ "@stackwright-pro/mcp": "workspace:*",
70
+ "@stackwright-pro/openapi": "workspace:*",
71
+ "@stackwright-pro/otters": "workspace:*",
66
72
  "@stackwright-pro/scaffold-hooks": "workspace:*",
67
- "@stackwright/cli": "^0.7.0",
68
- "@stackwright/scaffold-core": "^0.1.0",
73
+ "@stackwright/cli": "^0.9.0",
74
+ "@stackwright/scaffold-core": "^0.3.2",
69
75
  chalk: "^5.6.2",
70
- commander: "^14.0.3",
71
- "fs-extra": "^11.3",
72
- "js-yaml": "^4.1.0"
76
+ commander: "^15.0.0",
77
+ "fs-extra": "^11.3.5",
78
+ "js-yaml": "^4.2.0"
73
79
  },
74
80
  devDependencies: {
75
81
  "@types/fs-extra": "^11.0",
76
82
  "@types/js-yaml": "^4.0.9",
77
- "@types/node": "^24.0.0",
78
- typescript: "^5.0",
79
- tsup: "^8.5",
80
- vitest: "^4.0.18"
83
+ "@types/node": "catalog:",
84
+ typescript: "catalog:",
85
+ tsup: "catalog:",
86
+ vitest: "catalog:"
81
87
  }
82
88
  };
83
89
  }
@@ -85,43 +91,99 @@ var require_package = __commonJS({
85
91
 
86
92
  // src/index.ts
87
93
  var import_commander = require("commander");
88
- var import_path = __toESM(require("path"));
94
+ var import_path2 = __toESM(require("path"));
89
95
  var import_os = __toESM(require("os"));
90
- var import_fs_extra = __toESM(require("fs-extra"));
96
+ var import_fs_extra2 = __toESM(require("fs-extra"));
91
97
  var import_chalk = __toESM(require("chalk"));
92
- var import_js_yaml = __toESM(require("js-yaml"));
93
98
  var import_child_process = require("child_process");
94
99
  var import_cli = require("@stackwright/cli");
95
100
  var import_scaffold_core = require("@stackwright/scaffold-core");
96
101
  var import_scaffold_hooks = require("@stackwright-pro/scaffold-hooks");
97
- (0, import_scaffold_hooks.registerProScaffoldHooks)();
98
- var { version } = require_package();
99
- async function copyProTemplate(templateName, destPath) {
100
- const src = import_path.default.resolve(__dirname, "..", "templates", "pro", templateName);
101
- await import_fs_extra.default.copy(src, destPath);
102
+
103
+ // src/scaffold.ts
104
+ var import_fs_extra = __toESM(require("fs-extra"));
105
+ var import_js_yaml = __toESM(require("js-yaml"));
106
+ var import_path = __toESM(require("path"));
107
+
108
+ // src/generated/workspace-versions.ts
109
+ var PRO_VERSIONS = {
110
+ "@stackwright-pro/auth": "0.2.0-alpha.11",
111
+ "@stackwright-pro/auth-nextjs": "0.2.0-alpha.13",
112
+ "@stackwright-pro/display-components": "0.2.0-alpha.10",
113
+ "@stackwright-pro/mcp": "0.2.0-alpha.58",
114
+ "@stackwright-pro/openapi": "0.3.0-alpha.23",
115
+ "@stackwright-pro/otters": "1.0.0-alpha.43",
116
+ "@stackwright-pro/pulse": "0.3.0-alpha.16",
117
+ "@stackwright-pro/workflow": "0.1.0-alpha.15",
118
+ "@stackwright-pro/workflow-components": "0.1.0-alpha.17"
119
+ };
120
+ var OSS_VERSIONS = {
121
+ "@stackwright/build-scripts": "^0.8.0",
122
+ "@stackwright/collections": "^0.1.2",
123
+ "@stackwright/core": "^0.9.0",
124
+ "@stackwright/icons": "^0.5.2",
125
+ "@stackwright/mcp": "^0.5.0",
126
+ "@stackwright/nextjs": "^0.6.0",
127
+ "@stackwright/otters": "^0.2.2",
128
+ "@stackwright/types": "^1.6.0",
129
+ "@stackwright/ui-shadcn": "^0.1.3"
130
+ };
131
+
132
+ // src/scaffold.ts
133
+ async function addProDepsToPackageJson(targetDir) {
134
+ const pkgPath = import_path.default.join(targetDir, "package.json");
135
+ const content = await import_fs_extra.default.readFile(pkgPath, "utf-8");
136
+ const pkg = JSON.parse(content);
137
+ const dependencies = typeof pkg.dependencies === "object" && pkg.dependencies !== null ? { ...pkg.dependencies } : {};
138
+ const devDependencies = typeof pkg.devDependencies === "object" && pkg.devDependencies !== null ? { ...pkg.devDependencies } : {};
139
+ const scripts = typeof pkg.scripts === "object" && pkg.scripts !== null ? { ...pkg.scripts } : {};
140
+ for (const [pkgName, pinnedVersion] of Object.entries(OSS_VERSIONS)) {
141
+ if (pkgName in dependencies) {
142
+ dependencies[pkgName] = pinnedVersion;
143
+ }
144
+ if (pkgName in devDependencies) {
145
+ devDependencies[pkgName] = pinnedVersion;
146
+ }
147
+ }
148
+ Object.assign(dependencies, {
149
+ "@stackwright-pro/display-components": PRO_VERSIONS["@stackwright-pro/display-components"],
150
+ "@stackwright-pro/mcp": PRO_VERSIONS["@stackwright-pro/mcp"],
151
+ "@stackwright-pro/otters": PRO_VERSIONS["@stackwright-pro/otters"],
152
+ "@stackwright-pro/openapi": PRO_VERSIONS["@stackwright-pro/openapi"],
153
+ "@stackwright-pro/auth": PRO_VERSIONS["@stackwright-pro/auth"],
154
+ "@stackwright-pro/auth-nextjs": PRO_VERSIONS["@stackwright-pro/auth-nextjs"],
155
+ "@stackwright-pro/pulse": PRO_VERSIONS["@stackwright-pro/pulse"],
156
+ "@stackwright-pro/workflow-components": PRO_VERSIONS["@stackwright-pro/workflow-components"],
157
+ "@stackwright-pro/workflow": PRO_VERSIONS["@stackwright-pro/workflow"],
158
+ "@stackwright/build-scripts": OSS_VERSIONS["@stackwright/build-scripts"],
159
+ zod: "^4.0.0"
160
+ });
161
+ Object.assign(devDependencies, {
162
+ "@stoplight/prism-cli": "^5.15.10"
163
+ });
164
+ Object.assign(scripts, {
165
+ "dev:admin": "MOCK_USER=admin next dev",
166
+ "dev:analyst": "MOCK_USER=analyst next dev",
167
+ "dev:viewer": "MOCK_USER=viewer next dev",
168
+ prebuild: "node scripts/prebuild.js",
169
+ predev: "node scripts/prebuild.js"
170
+ });
171
+ pkg.dependencies = dependencies;
172
+ pkg.devDependencies = devDependencies;
173
+ pkg.scripts = scripts;
174
+ await import_fs_extra.default.writeFile(pkgPath, JSON.stringify(pkg, null, 2) + "\n", "utf-8");
102
175
  }
103
176
  async function addAuthToStackwrightYml(targetDir) {
104
177
  const ymlPath = import_path.default.join(targetDir, "stackwright.yml");
105
178
  const content = await import_fs_extra.default.readFile(ymlPath, "utf-8");
106
- const config = import_js_yaml.default.load(content);
107
- config.auth = {
108
- type: "pki",
109
- profile: "dod_cac",
110
- source: "gateway_headers",
111
- roles: [
112
- { name: "ADMIN", permissions: ["*"] },
113
- { name: "ANALYST", permissions: ["data:read", "data:write"] },
114
- { name: "VIEWER", permissions: ["data:read"] }
115
- ],
116
- protected_routes: [{ path: "/*", roles: ["VIEWER", "ANALYST", "ADMIN"] }],
117
- public_routes: ["/", "/getting-started"]
118
- };
179
+ const config = import_js_yaml.default.load(content, { schema: import_js_yaml.default.CORE_SCHEMA });
180
+ config.auth = {};
119
181
  await import_fs_extra.default.writeFile(ymlPath, import_js_yaml.default.dump(config, { lineWidth: 120 }));
120
182
  }
121
183
  async function addIntegrationToStackwrightYml(targetDir, specName, specFilename, mockUrl) {
122
184
  const ymlPath = import_path.default.join(targetDir, "stackwright.yml");
123
185
  const content = await import_fs_extra.default.readFile(ymlPath, "utf-8");
124
- const config = import_js_yaml.default.load(content);
186
+ const config = import_js_yaml.default.load(content, { schema: import_js_yaml.default.CORE_SCHEMA });
125
187
  const integration = {
126
188
  type: "openapi",
127
189
  name: specName,
@@ -131,20 +193,71 @@ async function addIntegrationToStackwrightYml(targetDir, specName, specFilename,
131
193
  if (mockUrl) {
132
194
  integration.mockUrl = mockUrl;
133
195
  }
134
- config.integrations = [integration];
196
+ config.integrations = [
197
+ ...Array.isArray(config.integrations) ? config.integrations : [],
198
+ integration
199
+ ];
135
200
  await import_fs_extra.default.writeFile(ymlPath, import_js_yaml.default.dump(config, { lineWidth: 120 }));
136
201
  }
137
- async function handleSpec(targetDir, specPath, specName) {
138
- const resolvedSpec = import_path.default.resolve(specPath);
139
- if (!import_fs_extra.default.existsSync(resolvedSpec)) {
140
- throw new Error(`Spec file not found: ${resolvedSpec}`);
202
+ async function scaffoldWorkspaceConfig(targetDir) {
203
+ const workspaceDir = import_path.default.join(targetDir, ".code_puppy");
204
+ await import_fs_extra.default.ensureDir(workspaceDir);
205
+ const workspaceStats = await import_fs_extra.default.lstat(workspaceDir);
206
+ if (workspaceStats.isSymbolicLink()) {
207
+ throw new Error(".code_puppy/ is a symlink \u2014 refusing to write. Check for tampering.");
208
+ }
209
+ const agentsDir = import_path.default.join(workspaceDir, "agents");
210
+ await import_fs_extra.default.ensureDir(agentsDir);
211
+ if (await import_fs_extra.default.pathExists(agentsDir)) {
212
+ const agentsStats = await import_fs_extra.default.lstat(agentsDir);
213
+ if (agentsStats.isSymbolicLink()) {
214
+ throw new Error(".code_puppy/agents is a symlink \u2014 refusing to write. Check for tampering.");
215
+ }
216
+ }
217
+ const configPath = import_path.default.join(workspaceDir, "config.json");
218
+ let existingConfig = {};
219
+ if (import_fs_extra.default.existsSync(configPath)) {
220
+ try {
221
+ existingConfig = JSON.parse(await import_fs_extra.default.readFile(configPath, "utf-8"));
222
+ } catch {
223
+ }
224
+ }
225
+ if (await import_fs_extra.default.pathExists(configPath)) {
226
+ const configStats = await import_fs_extra.default.lstat(configPath);
227
+ if (configStats.isSymbolicLink()) {
228
+ throw new Error(
229
+ ".code_puppy/config.json is a symlink \u2014 refusing to write. Check for tampering."
230
+ );
231
+ }
232
+ }
233
+ await import_fs_extra.default.writeFile(
234
+ configPath,
235
+ JSON.stringify({ ...existingConfig, projectOnly: true }, null, 2) + "\n",
236
+ "utf-8"
237
+ );
238
+ const mcpServersPath = import_path.default.join(workspaceDir, "mcp_servers.json");
239
+ if (await import_fs_extra.default.pathExists(mcpServersPath)) {
240
+ const mcpStats = await import_fs_extra.default.lstat(mcpServersPath);
241
+ if (mcpStats.isSymbolicLink()) {
242
+ throw new Error(
243
+ ".code_puppy/mcp_servers.json is a symlink \u2014 refusing to write. Check for tampering."
244
+ );
245
+ }
246
+ }
247
+ if (!import_fs_extra.default.existsSync(mcpServersPath)) {
248
+ const mcpConfig = {
249
+ mcp_servers: {
250
+ "stackwright-pro-mcp": {
251
+ type: "stdio",
252
+ command: "pnpm",
253
+ args: ["exec", "stackwright-pro-mcp"],
254
+ enabled: true,
255
+ cwd: "${PROJECT_ROOT}"
256
+ }
257
+ }
258
+ };
259
+ await import_fs_extra.default.writeFile(mcpServersPath, JSON.stringify(mcpConfig, null, 2) + "\n", "utf-8");
141
260
  }
142
- const specFilename = import_path.default.basename(resolvedSpec);
143
- const derivedName = specName || import_path.default.basename(specFilename, import_path.default.extname(specFilename));
144
- const specsDir = import_path.default.join(targetDir, "specs");
145
- await import_fs_extra.default.ensureDir(specsDir);
146
- await import_fs_extra.default.copy(resolvedSpec, import_path.default.join(specsDir, specFilename));
147
- return { specFilename, derivedName };
148
261
  }
149
262
  function generateReadme(options) {
150
263
  const { projectName, hasSpec, specName, specFilename, hasOtters, hasMock } = options;
@@ -167,7 +280,7 @@ export const EquipmentSchema = z.object({
167
280
  export type Equipment = z.infer<typeof EquipmentSchema>;
168
281
 
169
282
  // src/generated/${specName}/client.ts
170
- export class ${specName.charAt(0).toUpperCase() + specName.slice(1)}Client {
283
+ export class ${(specName ?? "api").charAt(0).toUpperCase() + (specName ?? "api").slice(1)}Client {
171
284
  async getEquipment(id: string): Promise<Equipment> {
172
285
  // Auto-wired with auth, validation, error handling
173
286
  }
@@ -180,10 +293,10 @@ export class ${specName.charAt(0).toUpperCase() + specName.slice(1)}Client {
180
293
  3. You import and use it:
181
294
 
182
295
  \`\`\`typescript
183
- import { ${specName.charAt(0).toUpperCase() + specName.slice(1)}Client } from '@/generated/${specName}/client';
296
+ import { ${(specName ?? "api").charAt(0).toUpperCase() + (specName ?? "api").slice(1)}Client } from '@/generated/${specName}/client';
184
297
  import type { Equipment } from '@/generated/${specName}/types';
185
298
 
186
- const client = new ${specName.charAt(0).toUpperCase() + specName.slice(1)}Client();
299
+ const client = new ${(specName ?? "api").charAt(0).toUpperCase() + (specName ?? "api").slice(1)}Client();
187
300
  const gear: Equipment = await client.getEquipment('123');
188
301
  \`\`\`
189
302
 
@@ -219,12 +332,10 @@ Your project includes **SIX specialized AI agents** in \`node_modules/@stackwrig
219
332
  **Start the otter raft:**
220
333
 
221
334
  \`\`\`bash
222
- uvx stackwright-pro-raft
335
+ npx @stackwright-pro/raft
223
336
  \`\`\`
224
337
 
225
- > **Local dev (before PyPI publish):** \`python -m stackwright_pro.raft.cli_adapter foreman\`
226
-
227
- The raft is a Python state machine with a Rich terminal UI \u2014 it asks questions about your brand, auth, and data preferences, then coordinates specialist otters to build your app. All user interaction happens in the terminal; code-puppy is called as a one-shot subprocess for creative tasks only.
338
+ The raft verifies otter integrity, writes project context, and spawns code-puppy in foreman mode. The foreman asks questions about your brand, auth, and data preferences, then coordinates specialist otters to build your app. All state lives in \`.stackwright/\` \u2014 interrupt and resume anytime.
228
339
 
229
340
  **Example session prompt:**
230
341
 
@@ -267,12 +378,16 @@ ${mockSection}## \u{1F4C1} Project Structure
267
378
 
268
379
  \`\`\`
269
380
  .
381
+ \u251C\u2500\u2500 app/
382
+ \u2502 \u251C\u2500\u2500 layout.tsx # Root layout (StackwrightLayout + Providers)
383
+ \u2502 \u251C\u2500\u2500 page.tsx # Home page (renders root content)
384
+ \u2502 \u251C\u2500\u2500 [...slug]/
385
+ \u2502 \u2502 \u2514\u2500\u2500 page.tsx # Dynamic pages from YAML content
386
+ \u2502 \u2514\u2500\u2500 _components/
387
+ \u2502 \u251C\u2500\u2500 providers.tsx # Pro: AuthProvider + component registration
388
+ \u2502 \u2514\u2500\u2500 page-client.tsx # Client-side page renderer
270
389
  \u251C\u2500\u2500 pages/
271
- \u2502 \u251C\u2500\u2500 _app.tsx # Pro version with AuthProvider + shadcn
272
- \u2502 \u251C\u2500\u2500 index.tsx # Home page (auto-generated by Stackwright)
273
- \u2502 \u251C\u2500\u2500 about/
274
- \u2502 \u2502 \u2514\u2500\u2500 content.yml # Page content in YAML
275
- \u2502 \u2514\u2500\u2500 ...
390
+ \u2502 \u2514\u2500\u2500 content.yml # Root page content in YAML
276
391
  \u251C\u2500\u2500 lib/
277
392
  \u2502 \u2514\u2500\u2500 mock-auth.ts # Dev-only auth mocking (no backend needed)
278
393
  \u251C\u2500\u2500 scripts/
@@ -292,7 +407,7 @@ ${mockSection}## \u{1F4C1} Project Structure
292
407
  \`\`\`
293
408
 
294
409
  **Key Files:**
295
- - \`pages/_app.tsx\` - Wraps your app with \`AuthProvider\` for RBAC
410
+ - \`app/_components/providers.tsx\` - Wraps your app with \`AuthProvider\` for RBAC
296
411
  - \`stackwright.yml\` - Single source of truth for theme, auth roles, and API wiring
297
412
  - \`lib/mock-auth.ts\` - Mocks CAC/PIV headers locally so you can test auth flows
298
413
  - \`scripts/prebuild.js\` - Runs before dev/build to generate types from your OpenAPI spec
@@ -402,11 +517,33 @@ ${aiAgentsSection}## \u{1F4DA} Learn More
402
517
  **Questions?** File an issue or ping us in the discussions. We're here to help you ship faster.
403
518
  `;
404
519
  }
520
+
521
+ // src/index.ts
522
+ (0, import_scaffold_hooks.registerProScaffoldHooks)();
523
+ var { version } = require_package();
524
+ async function copyProTemplate(templateName, destPath) {
525
+ const src = import_path2.default.resolve(__dirname, "..", "templates", "pro", templateName);
526
+ await import_fs_extra2.default.copy(src, destPath);
527
+ }
528
+ async function handleSpec(targetDir, specPath, specName) {
529
+ const resolvedSpec = import_path2.default.resolve(specPath);
530
+ if (!import_fs_extra2.default.existsSync(resolvedSpec)) {
531
+ throw new Error(`Spec file not found: ${resolvedSpec}`);
532
+ }
533
+ const specFilename = import_path2.default.basename(resolvedSpec);
534
+ const derivedName = specName || import_path2.default.basename(specFilename, import_path2.default.extname(specFilename));
535
+ const specsDir = import_path2.default.join(targetDir, "specs");
536
+ await import_fs_extra2.default.ensureDir(specsDir);
537
+ await import_fs_extra2.default.copy(resolvedSpec, import_path2.default.join(specsDir, specFilename));
538
+ return { specFilename, derivedName };
539
+ }
405
540
  async function launch(targetDir, options) {
406
- const dirName = import_path.default.basename(targetDir);
541
+ const dirName = import_path2.default.basename(targetDir);
407
542
  console.log(import_chalk.default.cyan.bold("\n\u{1F6A2} Launching Stackwright Pro...\n"));
408
543
  const scaffoldOpts = {
409
544
  name: options.name || dirName,
545
+ standalone: true,
546
+ // prevents `workspace:*` refs when CLI runs inside the Pro monorepo
410
547
  ...options.title !== void 0 && { title: options.title },
411
548
  ...options.theme !== void 0 && { theme: options.theme },
412
549
  ...options.force !== void 0 && { force: options.force },
@@ -414,13 +551,41 @@ async function launch(targetDir, options) {
414
551
  };
415
552
  await (0, import_cli.scaffold)(targetDir, scaffoldOpts);
416
553
  console.log(import_chalk.default.green("\u2705 Base project scaffolded (hooks added Pro deps + MCP config)"));
554
+ await addProDepsToPackageJson(targetDir);
555
+ console.log(import_chalk.default.green("\u{1F9A6} Pro packages added to package.json"));
556
+ const verifyPkg = JSON.parse(
557
+ await import_fs_extra2.default.readFile(import_path2.default.join(targetDir, "package.json"), "utf-8")
558
+ );
559
+ const proDepCount = Object.keys(
560
+ typeof verifyPkg.dependencies === "object" && verifyPkg.dependencies !== null ? verifyPkg.dependencies : {}
561
+ ).filter((k) => k.startsWith("@stackwright-pro")).length;
562
+ console.log(import_chalk.default.dim(` \u2192 package.json verified: ${proDepCount} @stackwright-pro/* deps ready`));
417
563
  console.log(import_chalk.default.cyan("\n\u{1F4E6} Installing dependencies (this takes a moment)..."));
418
564
  if (!options.skipInstall) {
419
565
  try {
420
- (0, import_child_process.execSync)("pnpm install", { cwd: targetDir, stdio: "inherit", timeout: 12e4 });
566
+ (0, import_child_process.execSync)("pnpm install --ignore-workspace", {
567
+ cwd: targetDir,
568
+ stdio: "inherit",
569
+ timeout: 12e4
570
+ });
421
571
  console.log(import_chalk.default.green("\u2705 Dependencies installed"));
422
- } catch {
423
- console.warn(import_chalk.default.yellow("\u26A0\uFE0F pnpm install failed \u2014 run it manually: pnpm install"));
572
+ } catch (err) {
573
+ const isTimeout = err instanceof Error && (err.message.includes("ETIMEDOUT") || err.message.includes("timeout"));
574
+ console.error(
575
+ import_chalk.default.red("\n\u274C pnpm install failed. Auth and Pro packages are NOT installed.")
576
+ );
577
+ console.error(
578
+ import_chalk.default.red(" Your project is in an incomplete state \u2014 do NOT run or deploy it.")
579
+ );
580
+ if (isTimeout) {
581
+ console.error(
582
+ import_chalk.default.yellow(" The install timed out (>2 min). Check your network connection.")
583
+ );
584
+ }
585
+ console.error(
586
+ import_chalk.default.yellow(` Fix the error above, then run: pnpm install --ignore-workspace`)
587
+ );
588
+ process.exit(1);
424
589
  }
425
590
  } else {
426
591
  console.log(import_chalk.default.dim("\u2139\uFE0F Skipping install (--skip-install). Run: pnpm install"));
@@ -428,33 +593,42 @@ async function launch(targetDir, options) {
428
593
  const dependencyMode = "standalone";
429
594
  await (0, import_scaffold_core.runScaffoldHooks)("postInstall", {
430
595
  targetDir,
431
- projectName: options.name || import_path.default.basename(targetDir),
432
- siteTitle: options.title || options.name || import_path.default.basename(targetDir),
596
+ projectName: options.name || import_path2.default.basename(targetDir),
597
+ siteTitle: options.title || options.name || import_path2.default.basename(targetDir),
433
598
  themeId: options.theme || "corporate",
434
599
  packageJson: {},
435
600
  dependencyMode
436
601
  });
437
- await copyProTemplate("_app.tsx", import_path.default.join(targetDir, "pages", "_app.tsx"));
438
- await copyProTemplate("content.yml", import_path.default.join(targetDir, "pages", "content.yml"));
439
- await copyProTemplate("next.config.js", import_path.default.join(targetDir, "next.config.js"));
440
- await import_fs_extra.default.ensureDir(import_path.default.join(targetDir, "lib"));
441
- await copyProTemplate("mock-auth.ts", import_path.default.join(targetDir, "lib", "mock-auth.ts"));
442
- await copyProTemplate("yaml.d.ts", import_path.default.join(targetDir, "yaml.d.ts"));
443
- await import_fs_extra.default.ensureDir(import_path.default.join(targetDir, "scripts"));
444
- await copyProTemplate("prebuild.js", import_path.default.join(targetDir, "scripts", "prebuild.js"));
445
- console.log(import_chalk.default.green("\u{1F510} Auth integration added (RBAC with 3 roles)"));
602
+ await copyProTemplate(
603
+ "pro-providers.tsx",
604
+ import_path2.default.join(targetDir, "app", "_components", "providers.tsx")
605
+ );
606
+ await copyProTemplate("content.yml", import_path2.default.join(targetDir, "pages", "content.yml"));
607
+ await copyProTemplate("next.config.js", import_path2.default.join(targetDir, "next.config.js"));
608
+ await import_fs_extra2.default.ensureDir(import_path2.default.join(targetDir, "lib"));
609
+ await copyProTemplate("mock-auth.ts", import_path2.default.join(targetDir, "lib", "mock-auth.ts"));
610
+ await copyProTemplate("yaml.d.ts", import_path2.default.join(targetDir, "yaml.d.ts"));
611
+ await import_fs_extra2.default.ensureDir(import_path2.default.join(targetDir, "scripts"));
612
+ await copyProTemplate("prebuild.js", import_path2.default.join(targetDir, "scripts", "prebuild.js"));
613
+ await copyProTemplate(
614
+ "scripts/pro-content-plugin.js",
615
+ import_path2.default.join(targetDir, "scripts", "pro-content-plugin.js")
616
+ );
617
+ console.log(import_chalk.default.green(" Auth integration added (App Router providers + RBAC)"));
446
618
  await addAuthToStackwrightYml(targetDir);
447
619
  let specInfo = null;
448
620
  const MOCK_URL = "http://localhost:4010";
449
- if (options.spec) {
450
- specInfo = await handleSpec(targetDir, options.spec, options.specName);
451
- await addIntegrationToStackwrightYml(
452
- targetDir,
453
- specInfo.derivedName,
454
- specInfo.specFilename,
455
- options.mock ? MOCK_URL : void 0
456
- );
457
- console.log(import_chalk.default.green("\u{1F4E1} OpenAPI integration wired up"));
621
+ if (options.spec && options.spec.length > 0) {
622
+ for (const specPath of options.spec) {
623
+ specInfo = await handleSpec(targetDir, specPath, options.specName);
624
+ await addIntegrationToStackwrightYml(
625
+ targetDir,
626
+ specInfo.derivedName,
627
+ specInfo.specFilename,
628
+ options.mock ? MOCK_URL : void 0
629
+ );
630
+ }
631
+ console.log(import_chalk.default.green(`\u{1F4E1} ${options.spec.length} OpenAPI integration(s) wired up`));
458
632
  if (options.mock) {
459
633
  console.log(import_chalk.default.green("\u{1F3AD} Prism mock server configured"));
460
634
  }
@@ -464,9 +638,9 @@ async function launch(targetDir, options) {
464
638
  "\u26A0\uFE0F No spec provided with --mock. Using sample Petstore spec for demo. Replace with your API spec."
465
639
  )
466
640
  );
467
- const specsDir = import_path.default.join(targetDir, "specs");
468
- await import_fs_extra.default.ensureDir(specsDir);
469
- await copyProTemplate("petstore.yaml", import_path.default.join(specsDir, "petstore.yaml"));
641
+ const specsDir = import_path2.default.join(targetDir, "specs");
642
+ await import_fs_extra2.default.ensureDir(specsDir);
643
+ await copyProTemplate("petstore.yaml", import_path2.default.join(specsDir, "petstore.yaml"));
470
644
  specInfo = { specFilename: "petstore.yaml", derivedName: "petstore" };
471
645
  await addIntegrationToStackwrightYml(
472
646
  targetDir,
@@ -485,13 +659,33 @@ async function launch(targetDir, options) {
485
659
  hasOtters: !options.skipOtters,
486
660
  hasMock: !!options.mock
487
661
  });
488
- await import_fs_extra.default.writeFile(import_path.default.join(targetDir, "README.md"), readmeContent);
662
+ await import_fs_extra2.default.writeFile(import_path2.default.join(targetDir, "README.md"), readmeContent);
489
663
  console.log(import_chalk.default.green("\u{1F4C4} README.md created"));
490
- const relDir = import_path.default.relative(process.cwd(), targetDir) || ".";
664
+ const initContext = {
665
+ projectRoot: targetDir,
666
+ projectName: options.name || dirName,
667
+ generatedBy: "launch-stackwright-pro",
668
+ version: "1.0"
669
+ };
670
+ if (specInfo) {
671
+ initContext.specPath = `specs/${specInfo.specFilename}`;
672
+ initContext.specName = specInfo.derivedName;
673
+ }
674
+ initContext.theme = options.theme || "corporate";
675
+ const stackwrightDir = import_path2.default.join(targetDir, ".stackwright");
676
+ await import_fs_extra2.default.ensureDir(stackwrightDir);
677
+ await import_fs_extra2.default.writeFile(
678
+ import_path2.default.join(stackwrightDir, "init-context.json"),
679
+ JSON.stringify(initContext, null, 2) + "\n",
680
+ "utf-8"
681
+ );
682
+ await scaffoldWorkspaceConfig(targetDir);
683
+ console.log(import_chalk.default.green("\u{1F43E} .code_puppy/ workspace scaffolded (projectOnly: true)"));
684
+ const relDir = import_path2.default.relative(process.cwd(), targetDir) || ".";
491
685
  console.log(import_chalk.default.cyan.bold("\n\u{1F389} All set! Here's what to do next:\n"));
492
686
  console.log(import_chalk.default.white(` 1. cd ${relDir}`));
493
- console.log(import_chalk.default.white(" 2. uvx stackwright-pro-raft"));
494
- console.log(import_chalk.default.dim(" (local dev: python -m stackwright_pro.raft.cli_adapter foreman)"));
687
+ console.log(import_chalk.default.white(" 2. npx @stackwright-pro/raft"));
688
+ console.log(import_chalk.default.dim(" (use --verbose for troubleshooting)"));
495
689
  if (specInfo) {
496
690
  console.log(import_chalk.default.cyan(`
497
691
  \u{1F4E1} Your API spec was copied to specs/${specInfo.specFilename}`));
@@ -509,8 +703,8 @@ async function launch(targetDir, options) {
509
703
  async function main() {
510
704
  const program = new import_commander.Command();
511
705
  program.name("launch-stackwright-pro").description("\u{1F6A2} Launch a new Stackwright Pro project with auth, OpenAPI, and the otter raft").version(version).argument("[directory]", "Project directory", ".").option("--name <name>", "Project name (used in package.json)").option("--title <title>", "Site title shown in the app bar and browser tab").option("--theme <themeId>", "Theme ID (e.g., corporate, creative, minimal)").option("--force", "Launch even if the target directory is not empty").option("--skip-otters", "Skip copying otter raft configs").option("-y, --yes", "Skip all prompts, use defaults").option("--mock", "Configure Prism mock server for API development (runs on port 4010)").option(
512
- "--spec <path>",
513
- "Path to an OpenAPI spec (YAML or JSON) \u2014 copies into project and wires up integration"
706
+ "--spec <paths...>",
707
+ "Paths to OpenAPI specs (YAML or JSON) \u2014 copies into project and wires up integrations (can be specified multiple times)"
514
708
  ).option(
515
709
  "--spec-name <name>",
516
710
  "Name for the API integration (default: derived from spec filename)"
@@ -519,8 +713,8 @@ async function main() {
519
713
  "Skip automatic pnpm install (useful in CI or when using a different package manager)"
520
714
  ).action(async (directory, options) => {
521
715
  const homeDir = import_os.default.homedir();
522
- const targetDir = import_path.default.resolve(directory);
523
- if (!targetDir.startsWith(homeDir + import_path.default.sep) && targetDir !== homeDir) {
716
+ const targetDir = directory !== "." ? import_path2.default.resolve(process.cwd(), directory) : options.name ? import_path2.default.resolve(process.cwd(), options.name) : process.cwd();
717
+ if (!targetDir.startsWith(homeDir + import_path2.default.sep) && targetDir !== homeDir) {
524
718
  console.warn(import_chalk.default.yellow(`\u26A0\uFE0F Scaffolding outside your home directory: ${targetDir}`));
525
719
  }
526
720
  await launch(targetDir, options);
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../package.json","../src/index.ts"],"sourcesContent":["{\n \"name\": \"@stackwright-pro/launch-stackwright-pro\",\n \"version\": \"0.4.0-alpha.7\",\n \"description\": \"Launch a new Stackwright Pro project with OpenAPI integration, auth, and the otter raft\",\n \"license\": \"MIT\",\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/Per-Aspera-LLC/stackwright-pro\"\n },\n \"keywords\": [\n \"stackwright\",\n \"stackwright-pro\",\n \"scaffolding\",\n \"openapi\",\n \"government\",\n \"hackathon\"\n ],\n \"files\": [\n \"dist\",\n \"templates\"\n ],\n \"bin\": {\n \"launch-stackwright-pro\": \"dist/index.js\"\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"dev\": \"tsup --watch\",\n \"test\": \"vitest run\",\n \"test:coverage\": \"vitest run --coverage\"\n },\n \"dependencies\": {\n \"@stackwright-pro/scaffold-hooks\": \"workspace:*\",\n \"@stackwright/cli\": \"^0.7.0\",\n \"@stackwright/scaffold-core\": \"^0.1.0\",\n \"chalk\": \"^5.6.2\",\n \"commander\": \"^14.0.3\",\n \"fs-extra\": \"^11.3\",\n \"js-yaml\": \"^4.1.0\"\n },\n \"devDependencies\": {\n \"@types/fs-extra\": \"^11.0\",\n \"@types/js-yaml\": \"^4.0.9\",\n \"@types/node\": \"^24.0.0\",\n \"typescript\": \"^5.0\",\n \"tsup\": \"^8.5\",\n \"vitest\": \"^4.0.18\"\n }\n}\n","import { Command } from 'commander';\nimport path from 'path';\nimport os from 'os';\nimport fs from 'fs-extra';\nimport chalk from 'chalk';\nimport yaml from 'js-yaml';\nimport { execSync } from 'child_process';\n\nimport { scaffold, ScaffoldOptions } from '@stackwright/cli';\nimport { runScaffoldHooks } from '@stackwright/scaffold-core';\nimport { registerProScaffoldHooks } from '@stackwright-pro/scaffold-hooks';\n// Register Pro hooks (adds deps, MCP config, etc.)\n// Must be called before scaffold() to ensure hooks run in the CLI's scaffold-core context\nregisterProScaffoldHooks();\n\nconst { version } = require('../package.json') as { version: string };\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\ninterface LaunchProOptions {\n name?: string;\n title?: string;\n theme?: string;\n force?: boolean;\n skipOtters?: boolean;\n skipInstall?: boolean;\n yes?: boolean;\n spec?: string;\n specName?: string;\n mock?: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Template copying (Pro-specific - hooks can't handle these)\n// ---------------------------------------------------------------------------\n\nasync function copyProTemplate(templateName: string, destPath: string): Promise<void> {\n const src = path.resolve(__dirname, '..', 'templates', 'pro', templateName);\n await fs.copy(src, destPath);\n}\n\n// ---------------------------------------------------------------------------\n// Auth config (Pro-specific - hooks can't handle these)\n// ---------------------------------------------------------------------------\n\nasync function addAuthToStackwrightYml(targetDir: string): Promise<void> {\n const ymlPath = path.join(targetDir, 'stackwright.yml');\n const content = await fs.readFile(ymlPath, 'utf-8');\n const config = yaml.load(content) as Record<string, unknown>;\n\n config.auth = {\n type: 'pki',\n profile: 'dod_cac',\n source: 'gateway_headers',\n roles: [\n { name: 'ADMIN', permissions: ['*'] },\n { name: 'ANALYST', permissions: ['data:read', 'data:write'] },\n { name: 'VIEWER', permissions: ['data:read'] },\n ],\n protected_routes: [{ path: '/*', roles: ['VIEWER', 'ANALYST', 'ADMIN'] }],\n public_routes: ['/', '/getting-started'],\n };\n\n await fs.writeFile(ymlPath, yaml.dump(config, { lineWidth: 120 }));\n}\n\nasync function addIntegrationToStackwrightYml(\n targetDir: string,\n specName: string,\n specFilename: string,\n mockUrl?: string\n): Promise<void> {\n const ymlPath = path.join(targetDir, 'stackwright.yml');\n const content = await fs.readFile(ymlPath, 'utf-8');\n const config = yaml.load(content) as Record<string, unknown>;\n\n const integration: Record<string, unknown> = {\n type: 'openapi',\n name: specName,\n spec: `./specs/${specFilename}`,\n collections: [],\n };\n\n if (mockUrl) {\n integration.mockUrl = mockUrl;\n }\n\n config.integrations = [integration];\n\n await fs.writeFile(ymlPath, yaml.dump(config, { lineWidth: 120 }));\n}\n\n// ---------------------------------------------------------------------------\n// Spec handling (Pro-specific - hooks can't handle these)\n// ---------------------------------------------------------------------------\n\nasync function handleSpec(\n targetDir: string,\n specPath: string,\n specName?: string\n): Promise<{ specFilename: string; derivedName: string }> {\n const resolvedSpec = path.resolve(specPath);\n\n if (!fs.existsSync(resolvedSpec)) {\n throw new Error(`Spec file not found: ${resolvedSpec}`);\n }\n\n const specFilename = path.basename(resolvedSpec);\n const derivedName = specName || path.basename(specFilename, path.extname(specFilename));\n\n const specsDir = path.join(targetDir, 'specs');\n await fs.ensureDir(specsDir);\n await fs.copy(resolvedSpec, path.join(specsDir, specFilename));\n\n return { specFilename, derivedName };\n}\n\n// ---------------------------------------------------------------------------\n// README generator (Pro-specific - hooks can't handle these)\n// ---------------------------------------------------------------------------\n\nfunction generateReadme(options: {\n projectName: string;\n hasSpec: boolean;\n specName?: string;\n specFilename?: string;\n hasOtters: boolean;\n hasMock: boolean;\n}): string {\n const { projectName, hasSpec, specName, specFilename, hasOtters, hasMock } = options;\n\n // Build API Integration section if spec is present\n const apiIntegrationSection = hasSpec\n ? `## 📡 API Integration\n\nYour OpenAPI spec was copied to \\`specs/${specFilename}\\` and wired up in \\`stackwright.yml\\`.\n\n**What gets generated:**\n\n\\`\\`\\`typescript\n// src/generated/${specName}/schemas.ts\nexport const EquipmentSchema = z.object({\n id: z.string(),\n name: z.string(),\n status: z.enum(['operational', 'maintenance', 'retired']),\n // ... Zod validation for runtime safety\n});\n\n// src/generated/${specName}/types.ts\nexport type Equipment = z.infer<typeof EquipmentSchema>;\n\n// src/generated/${specName}/client.ts\nexport class ${specName!.charAt(0).toUpperCase() + specName!.slice(1)}Client {\n async getEquipment(id: string): Promise<Equipment> {\n // Auto-wired with auth, validation, error handling\n }\n}\n\\`\\`\\`\n\n**How it works:**\n1. The \\`predev\\` script in \\`package.json\\` runs \\`prebuild.js\\` before every \\`pnpm dev\\`\n2. Prebuild reads your spec and generates type-safe code\n3. You import and use it:\n\n\\`\\`\\`typescript\nimport { ${specName!.charAt(0).toUpperCase() + specName!.slice(1)}Client } from '@/generated/${specName}/client';\nimport type { Equipment } from '@/generated/${specName}/types';\n\nconst client = new ${specName!.charAt(0).toUpperCase() + specName!.slice(1)}Client();\nconst gear: Equipment = await client.getEquipment('123');\n\\`\\`\\`\n\nNo manual typing. No drift. No runtime surprises.\n\n`\n : '';\n\n // Build mock server section if enabled\n const mockSection = hasMock\n ? `## 🎭 Mock Server\n\nPrism mock server is configured to serve your API at **http://localhost:4010**.\n\n\\`\\`\\`bash\npnpm dev:mock # Starts Prism + Next.js together\n\\`\\`\\`\n\nThis starts:\n1. Prism mock server on port 4010 (serves your OpenAPI spec)\n2. Next.js dev server on port 3000\n\nThe generated API client is automatically configured to use the mock server.\n\n`\n : '';\n\n // Build AI Agents section if otters are present\n const aiAgentsSection = hasOtters\n ? `## 🦦 AI Agents (The Otter Raft)\n\nYour project includes **SIX specialized AI agents** in \\`node_modules/@stackwright-pro/otters/\\`:\n\n- \\`stackwright-pro-foreman-otter\\` - Master coordinator that orchestrates all specialist otters\n- \\`stackwright-pro-api-otter\\` - Discovers entities from OpenAPI specs\n- \\`stackwright-pro-auth-otter\\` - Configures CAC/OIDC auth, RBAC rules, and audit middleware\n- \\`stackwright-pro-data-otter\\` - Configures endpoint filters & ISR revalidation\n- \\`stackwright-pro-page-otter\\` - Generates pages auto-wired with data, theme, and auth\n- \\`stackwright-pro-dashboard-otter\\` - Builds live data dashboards\n\n**Start the otter raft:**\n\n\\`\\`\\`bash\nuvx stackwright-pro-raft\n\\`\\`\\`\n\n> **Local dev (before PyPI publish):** \\`python -m stackwright_pro.raft.cli_adapter foreman\\`\n\nThe raft is a Python state machine with a Rich terminal UI — it asks questions about your brand, auth, and data preferences, then coordinates specialist otters to build your app. All user interaction happens in the terminal; code-puppy is called as a one-shot subprocess for creative tasks only.\n\n**Example session prompt:**\n\n\"Build me a logistics dashboard from our OpenAPI spec. Connect to /equipment and /supplies endpoints.\"\n\n`\n : '';\n\n return `# ${projectName}\n\nA Stackwright Pro application with role-based auth, OpenAPI integration, and intelligent AI agents.\n\n## 🚀 Quick Start\n\n\\`\\`\\`bash\n# Start development server\npnpm dev\n\n# Open your browser\nopen http://localhost:3000\n\\`\\`\\`\n\n## 👥 Role-Based Development\n\nStackwright Pro includes **mock authentication** for local development with three pre-configured roles:\n\n\\`\\`\\`bash\npnpm dev:admin # Full permissions (*)\npnpm dev:analyst # Read & write data\npnpm dev:viewer # Read-only access\n\\`\\`\\`\n\n**How it works:**\n- Each script sets the \\`MOCK_USER\\` environment variable\n- \\`lib/mock-auth.ts\\` intercepts requests and injects the appropriate user context\n- Your pages & API routes respect the RBAC rules in \\`stackwright.yml\\`\n- No backend required for testing auth flows! 🎉\n\n**Pro tip:** Test your UI for all three roles to ensure proper permissions enforcement.\n\n${mockSection}## 📁 Project Structure\n\n\\`\\`\\`\n.\n├── pages/\n│ ├── _app.tsx # Pro version with AuthProvider + shadcn\n│ ├── index.tsx # Home page (auto-generated by Stackwright)\n│ ├── about/\n│ │ └── content.yml # Page content in YAML\n│ └── ...\n├── lib/\n│ └── mock-auth.ts # Dev-only auth mocking (no backend needed)\n├── scripts/\n│ └── prebuild.js # Auto-generates code from OpenAPI specs\n├── specs/ # OpenAPI spec files (if --spec was used)\n├── src/\n│ └── generated/ # Auto-generated types & clients\n│ └── {specName}/\n│ ├── schemas.ts # Zod schemas for runtime validation\n│ ├── types.ts # TypeScript types\n│ ├── client.ts # API client with auth\n│ └── provider.ts # CollectionProvider for Stackwright\n├── .stackwright/\n│ └── otters/ # AI agent configs (4 specialized otters)\n├── stackwright.yml # Theme, auth, API integrations\n└── package.json\n\\`\\`\\`\n\n**Key Files:**\n- \\`pages/_app.tsx\\` - Wraps your app with \\`AuthProvider\\` for RBAC\n- \\`stackwright.yml\\` - Single source of truth for theme, auth roles, and API wiring\n- \\`lib/mock-auth.ts\\` - Mocks CAC/PIV headers locally so you can test auth flows\n- \\`scripts/prebuild.js\\` - Runs before dev/build to generate types from your OpenAPI spec\n\n## 📄 Adding Pages\n\nStackwright uses **YAML for content**, so you never touch JSX unless you want to.\n\n**Example:** Create \\`pages/about/content.yml\\`:\n\n\\`\\`\\`yaml\ntitle: About Us\ndescription: Learn more about our mission\n\nsections:\n - type: main\n heading: Who We Are\n body: |\n We build mission-critical logistics systems for the Marine Corps.\n\n - type: feature_list\n title: Our Capabilities\n features:\n - icon: Security\n title: Zero Trust\n description: PKI-based auth with CAC/PIV\n - icon: Api\n title: Real-time Data\n description: OpenAPI-backed, Zod-validated\n\\`\\`\\`\n\nThat's it. Navigate to \\`/about\\` and it just works. No routing config, no React components.\n\n${apiIntegrationSection}## 🎨 Customizing Theme\n\nEdit \\`stackwright.yml\\` to change colors, fonts, spacing — applies everywhere instantly.\n\n\\`\\`\\`yaml\ntheme:\n id: my-theme\n name: My Custom Theme\n colors:\n primary: \"#C41E3A\" # Marine Corps red\n background: \"#FFFFFF\"\n text: \"#1A1A1A\"\n accent: \"#FFD700\" # Gold\n typography:\n fontFamily: \"'Inter', sans-serif\"\n h1Size: \"2.5rem\"\n spacing:\n unit: 8\n\\`\\`\\`\n\nNo CSS files. No theme provider boilerplate. Just YAML. Stackwright handles the rest.\n\n## 🔐 Auth Configuration\n\nStackwright Pro comes with **3 pre-configured roles** in \\`stackwright.yml\\`:\n\n\\`\\`\\`yaml\nauth:\n roles:\n - name: ADMIN\n permissions: ['*'] # Full access\n - name: ANALYST \n permissions: ['data:read', 'data:write'] # Read/write data\n - name: VIEWER\n permissions: ['data:read'] # Read-only\n\\`\\`\\`\n\n**Gate content in your YAML:**\n\n\\`\\`\\`yaml\nsections:\n - type: button\n label: Delete Equipment\n action: /api/equipment/delete\n auth:\n required_roles: [ADMIN]\n fallback: hide # Options: hide, disable, show_message\n\\`\\`\\`\n\nOnly admins see the button. Analysts and viewers? Button doesn't exist in the DOM.\n\n**Route protection:**\n\n\\`\\`\\`yaml\nauth:\n protected_routes:\n - path: /admin/*\n roles: [ADMIN]\n - path: /equipment/* \n roles: [ANALYST, ADMIN]\n public_routes:\n - /\n - /about\n\\`\\`\\`\n\nNo middleware to write. No useAuth hooks to remember. RBAC is declarative.\n\n${aiAgentsSection}## 📚 Learn More\n\n- **Stackwright Docs:** [https://stackwright.dev](https://stackwright.dev)\n- **OSS Repo:** [https://github.com/Per-Aspera-LLC/stackwright](https://github.com/Per-Aspera-LLC/stackwright)\n- **Pro Repo:** [https://github.com/Per-Aspera-LLC/stackwright-pro](https://github.com/Per-Aspera-LLC/stackwright-pro)\n\n**Questions?** File an issue or ping us in the discussions. We're here to help you ship faster.\n`;\n}\n\n// ---------------------------------------------------------------------------\n// Main launch flow\n// ---------------------------------------------------------------------------\n\nasync function launch(targetDir: string, options: LaunchProOptions): Promise<void> {\n const dirName = path.basename(targetDir);\n\n console.log(chalk.cyan.bold('\\n🚢 Launching Stackwright Pro...\\n'));\n\n // ------------------------------------------------------------------\n // 1. Scaffold base OSS project via @stackwright/cli\n // Hooks auto-handle: Pro deps, MCP config, role-based scripts\n // ------------------------------------------------------------------\n\n const scaffoldOpts: ScaffoldOptions = {\n name: options.name || dirName,\n ...(options.title !== undefined && { title: options.title }),\n ...(options.theme !== undefined && { theme: options.theme }),\n ...(options.force !== undefined && { force: options.force }),\n ...(options.yes !== undefined && { noInteractive: options.yes }),\n };\n\n await scaffold(targetDir, scaffoldOpts);\n console.log(chalk.green('✅ Base project scaffolded (hooks added Pro deps + MCP config)'));\n\n // ------------------------------------------------------------------\n // 1b. Run pnpm install — citizen devs shouldn't need to know this step exists\n // ------------------------------------------------------------------\n\n console.log(chalk.cyan('\\n📦 Installing dependencies (this takes a moment)...'));\n if (!options.skipInstall) {\n try {\n execSync('pnpm install', { cwd: targetDir, stdio: 'inherit', timeout: 120_000 });\n console.log(chalk.green('✅ Dependencies installed'));\n } catch {\n console.warn(chalk.yellow('⚠️ pnpm install failed — run it manually: pnpm install'));\n }\n } else {\n console.log(chalk.dim('ℹ️ Skipping install (--skip-install). Run: pnpm install'));\n }\n\n // Fire postInstall hooks now that install has run\n const dependencyMode: 'workspace' | 'standalone' = 'standalone';\n await runScaffoldHooks('postInstall', {\n targetDir,\n projectName: options.name || path.basename(targetDir),\n siteTitle: options.title || options.name || path.basename(targetDir),\n themeId: options.theme || 'corporate',\n packageJson: {},\n dependencyMode,\n });\n\n // ------------------------------------------------------------------\n // 2. Copy Pro templates (hooks can't handle these)\n // ------------------------------------------------------------------\n\n // Replace _app.tsx with Pro version (AuthProvider, shadcn, etc.)\n await copyProTemplate('_app.tsx', path.join(targetDir, 'pages', '_app.tsx'));\n\n // Add root content.yml for the home page\n await copyProTemplate('content.yml', path.join(targetDir, 'pages', 'content.yml'));\n\n // Replace next.config.js with Pro version (transpile pro pkgs)\n await copyProTemplate('next.config.js', path.join(targetDir, 'next.config.js'));\n\n // Add lib/mock-auth.ts\n await fs.ensureDir(path.join(targetDir, 'lib'));\n await copyProTemplate('mock-auth.ts', path.join(targetDir, 'lib', 'mock-auth.ts'));\n\n // Add yaml.d.ts for TypeScript support\n await copyProTemplate('yaml.d.ts', path.join(targetDir, 'yaml.d.ts'));\n\n // Add scripts/prebuild.js\n await fs.ensureDir(path.join(targetDir, 'scripts'));\n await copyProTemplate('prebuild.js', path.join(targetDir, 'scripts', 'prebuild.js'));\n\n console.log(chalk.green('🔐 Auth integration added (RBAC with 3 roles)'));\n\n // ------------------------------------------------------------------\n // 3. Add auth section to stackwright.yml\n // ------------------------------------------------------------------\n\n await addAuthToStackwrightYml(targetDir);\n\n // ------------------------------------------------------------------\n // 4. Handle --spec if provided\n // ------------------------------------------------------------------\n\n let specInfo: { specFilename: string; derivedName: string } | null = null;\n const MOCK_URL = 'http://localhost:4010';\n\n if (options.spec) {\n specInfo = await handleSpec(targetDir, options.spec, options.specName);\n\n // Pass mockUrl if --mock flag is set\n await addIntegrationToStackwrightYml(\n targetDir,\n specInfo.derivedName,\n specInfo.specFilename,\n options.mock ? MOCK_URL : undefined\n );\n console.log(chalk.green('📡 OpenAPI integration wired up'));\n\n if (options.mock) {\n console.log(chalk.green('🎭 Prism mock server configured'));\n }\n } else if (options.mock) {\n // --mock without --spec: use sample Petstore spec for demo\n console.log(\n chalk.yellow(\n '⚠️ No spec provided with --mock. Using sample Petstore spec for demo. Replace with your API spec.'\n )\n );\n\n const specsDir = path.join(targetDir, 'specs');\n await fs.ensureDir(specsDir);\n await copyProTemplate('petstore.yaml', path.join(specsDir, 'petstore.yaml'));\n\n specInfo = { specFilename: 'petstore.yaml', derivedName: 'petstore' };\n\n await addIntegrationToStackwrightYml(\n targetDir,\n specInfo.derivedName,\n specInfo.specFilename,\n MOCK_URL\n );\n console.log(chalk.green('📡 Sample Petstore spec wired up'));\n console.log(chalk.green('🎭 Prism mock server configured'));\n }\n\n // ------------------------------------------------------------------\n // 5. Generate README\n // ------------------------------------------------------------------\n\n const readmeContent = generateReadme({\n projectName: options.name || dirName,\n hasSpec: !!specInfo,\n ...(specInfo?.derivedName !== undefined && { specName: specInfo.derivedName }),\n ...(specInfo?.specFilename !== undefined && { specFilename: specInfo.specFilename }),\n hasOtters: !options.skipOtters,\n hasMock: !!options.mock,\n });\n\n await fs.writeFile(path.join(targetDir, 'README.md'), readmeContent);\n console.log(chalk.green('📄 README.md created'));\n\n // ------------------------------------------------------------------\n // 6. Print next steps\n // ------------------------------------------------------------------\n\n const relDir = path.relative(process.cwd(), targetDir) || '.';\n\n console.log(chalk.cyan.bold(\"\\n🎉 All set! Here's what to do next:\\n\"));\n console.log(chalk.white(` 1. cd ${relDir}`));\n console.log(chalk.white(' 2. uvx stackwright-pro-raft'));\n console.log(chalk.dim(' (local dev: python -m stackwright_pro.raft.cli_adapter foreman)'));\n\n if (specInfo) {\n console.log(chalk.cyan(`\\n📡 Your API spec was copied to specs/${specInfo.specFilename}`));\n console.log(chalk.dim(' The prebuild will generate types & client on first `pnpm dev`.'));\n }\n\n if (options.mock) {\n console.log(chalk.cyan('\\n🎭 Run with mock server:'));\n console.log(chalk.white(' pnpm dev:mock # Starts Prism + Next.js'));\n }\n\n if (!options.skipOtters) {\n console.log(chalk.cyan.bold('\\n🦦 The otter raft is ready to build your site!'));\n console.log(chalk.dim(' Run the command above to get started.\\n'));\n }\n}\n\n// ---------------------------------------------------------------------------\n// CLI definition\n// ---------------------------------------------------------------------------\n\nasync function main(): Promise<void> {\n const program = new Command();\n\n program\n .name('launch-stackwright-pro')\n .description('🚢 Launch a new Stackwright Pro project with auth, OpenAPI, and the otter raft')\n .version(version)\n .argument('[directory]', 'Project directory', '.')\n .option('--name <name>', 'Project name (used in package.json)')\n .option('--title <title>', 'Site title shown in the app bar and browser tab')\n .option('--theme <themeId>', 'Theme ID (e.g., corporate, creative, minimal)')\n .option('--force', 'Launch even if the target directory is not empty')\n .option('--skip-otters', 'Skip copying otter raft configs')\n .option('-y, --yes', 'Skip all prompts, use defaults')\n .option('--mock', 'Configure Prism mock server for API development (runs on port 4010)')\n .option(\n '--spec <path>',\n 'Path to an OpenAPI spec (YAML or JSON) — copies into project and wires up integration'\n )\n .option(\n '--spec-name <name>',\n 'Name for the API integration (default: derived from spec filename)'\n )\n .option(\n '--skip-install',\n 'Skip automatic pnpm install (useful in CI or when using a different package manager)'\n )\n .action(async (directory: string, options: LaunchProOptions) => {\n const homeDir = os.homedir();\n const targetDir = path.resolve(directory);\n\n // Warn (don't block) when scaffolding outside home dir — unusual for a user-facing CLI\n if (!targetDir.startsWith(homeDir + path.sep) && targetDir !== homeDir) {\n console.warn(chalk.yellow(`⚠️ Scaffolding outside your home directory: ${targetDir}`));\n }\n\n await launch(targetDir, options);\n });\n\n await program.parseAsync(process.argv);\n}\n\nmain().catch((err: unknown) => {\n console.error(chalk.red('\\n❌ Launch failed:'), err);\n process.exit(1);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,iBAAAA,UAAAC,SAAA;AAAA,IAAAA,QAAA;AAAA,MACE,MAAQ;AAAA,MACR,SAAW;AAAA,MACX,aAAe;AAAA,MACf,SAAW;AAAA,MACX,eAAiB;AAAA,QACf,QAAU;AAAA,MACZ;AAAA,MACA,YAAc;AAAA,QACZ,MAAQ;AAAA,QACR,KAAO;AAAA,MACT;AAAA,MACA,UAAY;AAAA,QACV;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MACA,OAAS;AAAA,QACP;AAAA,QACA;AAAA,MACF;AAAA,MACA,KAAO;AAAA,QACL,0BAA0B;AAAA,MAC5B;AAAA,MACA,SAAW;AAAA,QACT,OAAS;AAAA,QACT,KAAO;AAAA,QACP,MAAQ;AAAA,QACR,iBAAiB;AAAA,MACnB;AAAA,MACA,cAAgB;AAAA,QACd,mCAAmC;AAAA,QACnC,oBAAoB;AAAA,QACpB,8BAA8B;AAAA,QAC9B,OAAS;AAAA,QACT,WAAa;AAAA,QACb,YAAY;AAAA,QACZ,WAAW;AAAA,MACb;AAAA,MACA,iBAAmB;AAAA,QACjB,mBAAmB;AAAA,QACnB,kBAAkB;AAAA,QAClB,eAAe;AAAA,QACf,YAAc;AAAA,QACd,MAAQ;AAAA,QACR,QAAU;AAAA,MACZ;AAAA,IACF;AAAA;AAAA;;;AClDA,uBAAwB;AACxB,kBAAiB;AACjB,gBAAe;AACf,sBAAe;AACf,mBAAkB;AAClB,qBAAiB;AACjB,2BAAyB;AAEzB,iBAA0C;AAC1C,2BAAiC;AACjC,4BAAyC;AAAA,IAGzC,gDAAyB;AAEzB,IAAM,EAAE,QAAQ,IAAI;AA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Q,IAAI;AACvC;AAEA,KAAK,EAAE,MAAM,CAAC,QAAiB;AAC7B,UAAQ,MAAM,aAAAA,QAAM,IAAI,yBAAoB,GAAG,GAAG;AAClD,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["exports","module","path","fs","yaml","chalk","os"]}
1
+ {"version":3,"sources":["../package.json","../src/index.ts","../src/scaffold.ts","../src/generated/workspace-versions.ts"],"sourcesContent":["{\n \"name\": \"@stackwright-pro/launch-stackwright-pro\",\n \"version\": \"0.4.0-alpha.93\",\n \"description\": \"Launch a new Stackwright Pro project with OpenAPI integration, auth, and the otter raft\",\n \"license\": \"SEE LICENSE IN LICENSE\",\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/Per-Aspera-LLC/stackwright-pro\"\n },\n \"keywords\": [\n \"stackwright\",\n \"stackwright-pro\",\n \"scaffolding\",\n \"openapi\",\n \"government\",\n \"hackathon\"\n ],\n \"files\": [\n \"dist\",\n \"templates\"\n ],\n \"bin\": {\n \"launch-stackwright-pro\": \"dist/index.js\"\n },\n \"scripts\": {\n \"build\": \"node ../../scripts/sync-versions.mjs && tsup\",\n \"sync-versions\": \"node ../../scripts/sync-versions.mjs\",\n \"dev\": \"tsup --watch\",\n \"test\": \"vitest run\",\n \"test:coverage\": \"vitest run --coverage\"\n },\n \"dependencies\": {\n \"@stackwright-pro/auth\": \"workspace:*\",\n \"@stackwright-pro/auth-nextjs\": \"workspace:*\",\n \"@stackwright-pro/mcp\": \"workspace:*\",\n \"@stackwright-pro/openapi\": \"workspace:*\",\n \"@stackwright-pro/otters\": \"workspace:*\",\n \"@stackwright-pro/scaffold-hooks\": \"workspace:*\",\n \"@stackwright/cli\": \"^0.9.0\",\n \"@stackwright/scaffold-core\": \"^0.3.2\",\n \"chalk\": \"^5.6.2\",\n \"commander\": \"^15.0.0\",\n \"fs-extra\": \"^11.3.5\",\n \"js-yaml\": \"^4.2.0\"\n },\n \"devDependencies\": {\n \"@types/fs-extra\": \"^11.0\",\n \"@types/js-yaml\": \"^4.0.9\",\n \"@types/node\": \"catalog:\",\n \"typescript\": \"catalog:\",\n \"tsup\": \"catalog:\",\n \"vitest\": \"catalog:\"\n }\n}\n","import { Command } from 'commander';\nimport path from 'path';\nimport os from 'os';\nimport fs from 'fs-extra';\nimport chalk from 'chalk';\nimport { execSync } from 'child_process';\n\nimport { scaffold, ScaffoldOptions } from '@stackwright/cli';\nimport { runScaffoldHooks } from '@stackwright/scaffold-core';\nimport { registerProScaffoldHooks } from '@stackwright-pro/scaffold-hooks';\nimport {\n addProDepsToPackageJson,\n addAuthToStackwrightYml,\n scaffoldWorkspaceConfig,\n addIntegrationToStackwrightYml,\n generateReadme,\n} from './scaffold.js';\n// Register Pro hooks (adds deps, MCP config, etc.)\n// Must be called before scaffold() to ensure hooks run in the CLI's scaffold-core context\nregisterProScaffoldHooks();\n\nconst { version } = require('../package.json') as { version: string };\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\ninterface LaunchProOptions {\n name?: string;\n title?: string;\n theme?: string;\n force?: boolean;\n skipOtters?: boolean;\n skipInstall?: boolean;\n yes?: boolean;\n spec?: string[];\n specName?: string;\n mock?: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Template copying (Pro-specific - hooks can't handle these)\n// ---------------------------------------------------------------------------\n\nasync function copyProTemplate(templateName: string, destPath: string): Promise<void> {\n const src = path.resolve(__dirname, '..', 'templates', 'pro', templateName);\n await fs.copy(src, destPath);\n}\n\n// ---------------------------------------------------------------------------\n// Spec handling (Pro-specific - hooks can't handle these)\n// ---------------------------------------------------------------------------\n\nasync function handleSpec(\n targetDir: string,\n specPath: string,\n specName?: string\n): Promise<{ specFilename: string; derivedName: string }> {\n const resolvedSpec = path.resolve(specPath);\n\n if (!fs.existsSync(resolvedSpec)) {\n throw new Error(`Spec file not found: ${resolvedSpec}`);\n }\n\n const specFilename = path.basename(resolvedSpec);\n const derivedName = specName || path.basename(specFilename, path.extname(specFilename));\n\n const specsDir = path.join(targetDir, 'specs');\n await fs.ensureDir(specsDir);\n await fs.copy(resolvedSpec, path.join(specsDir, specFilename));\n\n return { specFilename, derivedName };\n}\n\n// ---------------------------------------------------------------------------\n// Main launch flow\n// ---------------------------------------------------------------------------\n\nasync function launch(targetDir: string, options: LaunchProOptions): Promise<void> {\n const dirName = path.basename(targetDir);\n\n console.log(chalk.cyan.bold('\\n🚢 Launching Stackwright Pro...\\n'));\n\n // ------------------------------------------------------------------\n // 1. Scaffold base OSS project via @stackwright/cli\n // Hooks auto-handle: Pro deps, MCP config, role-based scripts\n // ------------------------------------------------------------------\n\n const scaffoldOpts: ScaffoldOptions = {\n name: options.name || dirName,\n standalone: true, // prevents `workspace:*` refs when CLI runs inside the Pro monorepo\n ...(options.title !== undefined && { title: options.title }),\n ...(options.theme !== undefined && { theme: options.theme }),\n ...(options.force !== undefined && { force: options.force }),\n ...(options.yes !== undefined && { noInteractive: options.yes }),\n };\n\n await scaffold(targetDir, scaffoldOpts);\n console.log(chalk.green('✅ Base project scaffolded (hooks added Pro deps + MCP config)'));\n\n // ------------------------------------------------------------------\n // 1b. Run pnpm install — citizen devs shouldn't need to know this step exists\n // ------------------------------------------------------------------\n\n // Patch Pro packages directly into package.json before install.\n // This bypasses the scaffold hooks system (which has a known version-resolution\n // issue) and guarantees pro deps land regardless of hook execution order.\n await addProDepsToPackageJson(targetDir);\n console.log(chalk.green('🦦 Pro packages added to package.json'));\n\n // Verify package.json has Pro deps before installing\n const verifyPkg = JSON.parse(\n await fs.readFile(path.join(targetDir, 'package.json'), 'utf-8')\n ) as Record<string, unknown>;\n const proDepCount = Object.keys(\n typeof verifyPkg.dependencies === 'object' && verifyPkg.dependencies !== null\n ? (verifyPkg.dependencies as Record<string, string>)\n : {}\n ).filter((k) => k.startsWith('@stackwright-pro')).length;\n console.log(chalk.dim(` → package.json verified: ${proDepCount} @stackwright-pro/* deps ready`));\n\n console.log(chalk.cyan('\\n📦 Installing dependencies (this takes a moment)...'));\n if (!options.skipInstall) {\n try {\n execSync('pnpm install --ignore-workspace', {\n cwd: targetDir,\n stdio: 'inherit',\n timeout: 120_000,\n });\n console.log(chalk.green('✅ Dependencies installed'));\n } catch (err: unknown) {\n const isTimeout =\n err instanceof Error &&\n (err.message.includes('ETIMEDOUT') || err.message.includes('timeout'));\n console.error(\n chalk.red('\\n❌ pnpm install failed. Auth and Pro packages are NOT installed.')\n );\n console.error(\n chalk.red(' Your project is in an incomplete state — do NOT run or deploy it.')\n );\n if (isTimeout) {\n console.error(\n chalk.yellow(' The install timed out (>2 min). Check your network connection.')\n );\n }\n console.error(\n chalk.yellow(` Fix the error above, then run: pnpm install --ignore-workspace`)\n );\n process.exit(1);\n }\n } else {\n console.log(chalk.dim('ℹ️ Skipping install (--skip-install). Run: pnpm install'));\n }\n\n // Fire postInstall hooks now that install has run\n const dependencyMode: 'workspace' | 'standalone' = 'standalone';\n await runScaffoldHooks('postInstall', {\n targetDir,\n projectName: options.name || path.basename(targetDir),\n siteTitle: options.title || options.name || path.basename(targetDir),\n themeId: options.theme || 'corporate',\n packageJson: {},\n dependencyMode,\n });\n\n // ------------------------------------------------------------------\n // 2. Copy Pro templates (hooks can't handle these)\n // ------------------------------------------------------------------\n\n // Replace providers.tsx with Pro version (AuthProvider, Pro component registration)\n // Pro integrates into the App Router layout — NOT the Pages Router _app.tsx.\n // Putting _app.tsx in pages/ triggers Next.js 16 Pages Router mode which fails\n // on missing _document (see swp-srp / GH scaffold smoke test).\n await copyProTemplate(\n 'pro-providers.tsx',\n path.join(targetDir, 'app', '_components', 'providers.tsx')\n );\n\n // Add root content.yml for the home page\n // Goes in pages/ for Stackwright's content system — this is a YAML data file,\n // not a Next.js page module, so it does NOT trigger Pages Router mode.\n await copyProTemplate('content.yml', path.join(targetDir, 'pages', 'content.yml'));\n\n // Replace next.config.js with Pro version (transpile pro pkgs)\n await copyProTemplate('next.config.js', path.join(targetDir, 'next.config.js'));\n\n // Add lib/mock-auth.ts\n await fs.ensureDir(path.join(targetDir, 'lib'));\n await copyProTemplate('mock-auth.ts', path.join(targetDir, 'lib', 'mock-auth.ts'));\n\n // Add yaml.d.ts for TypeScript support\n await copyProTemplate('yaml.d.ts', path.join(targetDir, 'yaml.d.ts'));\n\n // Add scripts/prebuild.js + scripts/pro-content-plugin.js\n await fs.ensureDir(path.join(targetDir, 'scripts'));\n await copyProTemplate('prebuild.js', path.join(targetDir, 'scripts', 'prebuild.js'));\n await copyProTemplate(\n 'scripts/pro-content-plugin.js',\n path.join(targetDir, 'scripts', 'pro-content-plugin.js')\n );\n\n console.log(chalk.green(' Auth integration added (App Router providers + RBAC)'));\n\n // ------------------------------------------------------------------\n // 3. Add auth section to stackwright.yml\n // ------------------------------------------------------------------\n\n await addAuthToStackwrightYml(targetDir);\n\n // ------------------------------------------------------------------\n // 4. Handle --spec if provided\n // ------------------------------------------------------------------\n\n let specInfo: { specFilename: string; derivedName: string } | null = null;\n const MOCK_URL = 'http://localhost:4010';\n\n if (options.spec && options.spec.length > 0) {\n for (const specPath of options.spec) {\n specInfo = await handleSpec(targetDir, specPath, options.specName);\n await addIntegrationToStackwrightYml(\n targetDir,\n specInfo.derivedName,\n specInfo.specFilename,\n options.mock ? MOCK_URL : undefined\n );\n }\n console.log(chalk.green(`📡 ${options.spec.length} OpenAPI integration(s) wired up`));\n if (options.mock) {\n console.log(chalk.green('🎭 Prism mock server configured'));\n }\n } else if (options.mock) {\n // --mock without --spec: use sample Petstore spec for demo\n console.log(\n chalk.yellow(\n '⚠️ No spec provided with --mock. Using sample Petstore spec for demo. Replace with your API spec.'\n )\n );\n\n const specsDir = path.join(targetDir, 'specs');\n await fs.ensureDir(specsDir);\n await copyProTemplate('petstore.yaml', path.join(specsDir, 'petstore.yaml'));\n\n specInfo = { specFilename: 'petstore.yaml', derivedName: 'petstore' };\n\n await addIntegrationToStackwrightYml(\n targetDir,\n specInfo.derivedName,\n specInfo.specFilename,\n MOCK_URL\n );\n console.log(chalk.green('📡 Sample Petstore spec wired up'));\n console.log(chalk.green('🎭 Prism mock server configured'));\n }\n\n // ------------------------------------------------------------------\n // 5. Generate README\n // ------------------------------------------------------------------\n\n const readmeContent = generateReadme({\n projectName: options.name || dirName,\n hasSpec: !!specInfo,\n ...(specInfo?.derivedName !== undefined && { specName: specInfo.derivedName }),\n ...(specInfo?.specFilename !== undefined && { specFilename: specInfo.specFilename }),\n hasOtters: !options.skipOtters,\n hasMock: !!options.mock,\n });\n\n await fs.writeFile(path.join(targetDir, 'README.md'), readmeContent);\n console.log(chalk.green('📄 README.md created'));\n\n // ------------------------------------------------------------------\n // 5b. Write init-context.json for raft launcher\n // ------------------------------------------------------------------\n\n const initContext: Record<string, unknown> = {\n projectRoot: targetDir,\n projectName: options.name || dirName,\n generatedBy: 'launch-stackwright-pro',\n version: '1.0',\n };\n\n if (specInfo) {\n initContext.specPath = `specs/${specInfo.specFilename}`;\n initContext.specName = specInfo.derivedName;\n }\n\n initContext.theme = options.theme || 'corporate';\n\n const stackwrightDir = path.join(targetDir, '.stackwright');\n await fs.ensureDir(stackwrightDir);\n await fs.writeFile(\n path.join(stackwrightDir, 'init-context.json'),\n JSON.stringify(initContext, null, 2) + '\\n',\n 'utf-8'\n );\n\n // ------------------------------------------------------------------\n // 5c. Scaffold .code_puppy/ workspace directory\n // Creates config.json (projectOnly: true), mcp_servers.json,\n // and agents/ dir. raft-puppy discovers this via walk-up from cwd\n // on first startup — no CLI flags needed.\n // ------------------------------------------------------------------\n\n await scaffoldWorkspaceConfig(targetDir);\n console.log(chalk.green('🐾 .code_puppy/ workspace scaffolded (projectOnly: true)'));\n\n // ------------------------------------------------------------------\n // 6. Print next steps\n // ------------------------------------------------------------------\n\n const relDir = path.relative(process.cwd(), targetDir) || '.';\n\n console.log(chalk.cyan.bold(\"\\n🎉 All set! Here's what to do next:\\n\"));\n console.log(chalk.white(` 1. cd ${relDir}`));\n console.log(chalk.white(' 2. npx @stackwright-pro/raft'));\n console.log(chalk.dim(' (use --verbose for troubleshooting)'));\n\n if (specInfo) {\n console.log(chalk.cyan(`\\n📡 Your API spec was copied to specs/${specInfo.specFilename}`));\n console.log(chalk.dim(' The prebuild will generate types & client on first `pnpm dev`.'));\n }\n\n if (options.mock) {\n console.log(chalk.cyan('\\n🎭 Run with mock server:'));\n console.log(chalk.white(' pnpm dev:mock # Starts Prism + Next.js'));\n }\n\n if (!options.skipOtters) {\n console.log(chalk.cyan.bold('\\n🦦 The otter raft is ready to build your site!'));\n console.log(chalk.dim(' Run the command above to get started.\\n'));\n }\n}\n\n// ---------------------------------------------------------------------------\n// CLI definition\n// ---------------------------------------------------------------------------\n\nasync function main(): Promise<void> {\n const program = new Command();\n\n program\n .name('launch-stackwright-pro')\n .description('🚢 Launch a new Stackwright Pro project with auth, OpenAPI, and the otter raft')\n .version(version)\n .argument('[directory]', 'Project directory', '.')\n .option('--name <name>', 'Project name (used in package.json)')\n .option('--title <title>', 'Site title shown in the app bar and browser tab')\n .option('--theme <themeId>', 'Theme ID (e.g., corporate, creative, minimal)')\n .option('--force', 'Launch even if the target directory is not empty')\n .option('--skip-otters', 'Skip copying otter raft configs')\n .option('-y, --yes', 'Skip all prompts, use defaults')\n .option('--mock', 'Configure Prism mock server for API development (runs on port 4010)')\n .option(\n '--spec <paths...>',\n 'Paths to OpenAPI specs (YAML or JSON) — copies into project and wires up integrations (can be specified multiple times)'\n )\n .option(\n '--spec-name <name>',\n 'Name for the API integration (default: derived from spec filename)'\n )\n .option(\n '--skip-install',\n 'Skip automatic pnpm install (useful in CI or when using a different package manager)'\n )\n .action(async (directory: string, options: LaunchProOptions) => {\n const homeDir = os.homedir();\n const targetDir =\n directory !== '.'\n ? path.resolve(process.cwd(), directory)\n : options.name\n ? path.resolve(process.cwd(), options.name)\n : process.cwd(); // last resort — same as old behaviour, only hit if neither arg nor --name\n\n // Warn (don't block) when scaffolding outside home dir — unusual for a user-facing CLI\n if (!targetDir.startsWith(homeDir + path.sep) && targetDir !== homeDir) {\n console.warn(chalk.yellow(`⚠️ Scaffolding outside your home directory: ${targetDir}`));\n }\n\n await launch(targetDir, options);\n });\n\n await program.parseAsync(process.argv);\n}\n\nmain().catch((err: unknown) => {\n console.error(chalk.red('\\n❌ Launch failed:'), err);\n process.exit(1);\n});\n","/**\n * scaffold.ts — Pro-specific scaffold mutation helpers\n *\n * Extracted from src/index.ts so these pure filesystem transforms can be\n * imported and tested independently (no __dirname, no fs.copy, no chalk).\n *\n * Every function here:\n * - Accepts a targetDir and operates on real files\n * - Is async/await throughout\n * - Has no side effects beyond writing to targetDir\n * - Is fully unit-testable with a real temp filesystem\n */\n\nimport fs from 'fs-extra';\nimport yaml from 'js-yaml';\nimport path from 'path';\nimport { PRO_VERSIONS, OSS_VERSIONS } from './generated/workspace-versions.js';\n\n// ---------------------------------------------------------------------------\n// Package.json mutations\n// ---------------------------------------------------------------------------\n\n/**\n * Inject Pro runtime dependencies and scripts into an existing package.json.\n * Enforces OSS version floors and adds Pro-specific dev scripts (prebuild/predev).\n * Safe to call multiple times — idempotent for dep keys.\n */\nexport async function addProDepsToPackageJson(targetDir: string): Promise<void> {\n const pkgPath = path.join(targetDir, 'package.json');\n const content = await fs.readFile(pkgPath, 'utf-8');\n const pkg = JSON.parse(content) as Record<string, unknown>;\n\n const dependencies: Record<string, string> =\n typeof pkg.dependencies === 'object' && pkg.dependencies !== null\n ? { ...(pkg.dependencies as Record<string, string>) }\n : {};\n const devDependencies: Record<string, string> =\n typeof pkg.devDependencies === 'object' && pkg.devDependencies !== null\n ? { ...(pkg.devDependencies as Record<string, string>) }\n : {};\n const scripts: Record<string, string> =\n typeof pkg.scripts === 'object' && pkg.scripts !== null\n ? { ...(pkg.scripts as Record<string, string>) }\n : {};\n\n // Enforce OSS version floors — replace workspace:* refs AND upgrade any stale version\n // pinned by the OSS scaffold template to our tested minimum.\n // OSS_VERSIONS = \"minimum tested versions\" — we always want them to win.\n for (const [pkgName, pinnedVersion] of Object.entries(OSS_VERSIONS)) {\n if (pkgName in dependencies) {\n dependencies[pkgName] = pinnedVersion;\n }\n if (pkgName in devDependencies) {\n devDependencies[pkgName] = pinnedVersion;\n }\n }\n\n // Pro runtime dependencies — exact versions from workspace at build time\n Object.assign(dependencies, {\n '@stackwright-pro/display-components': PRO_VERSIONS['@stackwright-pro/display-components'],\n '@stackwright-pro/mcp': PRO_VERSIONS['@stackwright-pro/mcp'],\n '@stackwright-pro/otters': PRO_VERSIONS['@stackwright-pro/otters'],\n '@stackwright-pro/openapi': PRO_VERSIONS['@stackwright-pro/openapi'],\n '@stackwright-pro/auth': PRO_VERSIONS['@stackwright-pro/auth'],\n '@stackwright-pro/auth-nextjs': PRO_VERSIONS['@stackwright-pro/auth-nextjs'],\n '@stackwright-pro/pulse': PRO_VERSIONS['@stackwright-pro/pulse'],\n '@stackwright-pro/workflow-components': PRO_VERSIONS['@stackwright-pro/workflow-components'],\n '@stackwright-pro/workflow': PRO_VERSIONS['@stackwright-pro/workflow'],\n '@stackwright/build-scripts': OSS_VERSIONS['@stackwright/build-scripts'],\n zod: '^4.0.0',\n });\n\n // Pro dev dependencies\n Object.assign(devDependencies, {\n '@stoplight/prism-cli': '^5.15.10',\n });\n\n // Role-based dev scripts\n Object.assign(scripts, {\n 'dev:admin': 'MOCK_USER=admin next dev',\n 'dev:analyst': 'MOCK_USER=analyst next dev',\n 'dev:viewer': 'MOCK_USER=viewer next dev',\n prebuild: 'node scripts/prebuild.js',\n predev: 'node scripts/prebuild.js',\n });\n\n pkg.dependencies = dependencies;\n pkg.devDependencies = devDependencies;\n pkg.scripts = scripts;\n\n await fs.writeFile(pkgPath, JSON.stringify(pkg, null, 2) + '\\n', 'utf-8');\n}\n\n// ---------------------------------------------------------------------------\n// stackwright.yml mutations\n// ---------------------------------------------------------------------------\n\n/**\n * Add an empty `auth:` key to an existing stackwright.yml.\n * The auth key is the hook point for Pro RBAC configuration.\n */\nexport async function addAuthToStackwrightYml(targetDir: string): Promise<void> {\n const ymlPath = path.join(targetDir, 'stackwright.yml');\n const content = await fs.readFile(ymlPath, 'utf-8');\n const config = yaml.load(content, { schema: yaml.CORE_SCHEMA }) as Record<string, unknown>;\n\n config.auth = {};\n\n await fs.writeFile(ymlPath, yaml.dump(config, { lineWidth: 120 }));\n}\n\n/**\n * Append an OpenAPI integration entry to the `integrations:` array in stackwright.yml.\n * Creates the array if it does not exist. Safe to call multiple times for different specs.\n */\nexport async function addIntegrationToStackwrightYml(\n targetDir: string,\n specName: string,\n specFilename: string,\n mockUrl?: string\n): Promise<void> {\n const ymlPath = path.join(targetDir, 'stackwright.yml');\n const content = await fs.readFile(ymlPath, 'utf-8');\n const config = yaml.load(content, { schema: yaml.CORE_SCHEMA }) as Record<string, unknown>;\n\n const integration: Record<string, unknown> = {\n type: 'openapi',\n name: specName,\n spec: `./specs/${specFilename}`,\n collections: [],\n };\n\n if (mockUrl) {\n integration.mockUrl = mockUrl;\n }\n\n config.integrations = [\n ...(Array.isArray(config.integrations) ? config.integrations : []),\n integration,\n ];\n\n await fs.writeFile(ymlPath, yaml.dump(config, { lineWidth: 120 }));\n}\n\n// ---------------------------------------------------------------------------\n// .code_puppy/ workspace config scaffolding\n// ---------------------------------------------------------------------------\n\n/**\n * Create (or idempotently update) the .code_puppy/ workspace directory.\n *\n * Creates:\n * - .code_puppy/config.json { projectOnly: true } (merges with existing)\n * - .code_puppy/mcp_servers.json stackwright-pro-mcp stdio server entry\n * - .code_puppy/agents/ empty directory for future agent configs\n *\n * Symlink guard: refuses to write if any of the managed paths is a symlink,\n * consistent with raft/src/lib.ts ensureWorkspaceConfig.\n */\nexport async function scaffoldWorkspaceConfig(targetDir: string): Promise<void> {\n const workspaceDir = path.join(targetDir, '.code_puppy');\n await fs.ensureDir(workspaceDir);\n // Symlink guard — consistent with raft/src/lib.ts ensureWorkspaceConfig\n const workspaceStats = await fs.lstat(workspaceDir);\n if (workspaceStats.isSymbolicLink()) {\n throw new Error('.code_puppy/ is a symlink — refusing to write. Check for tampering.');\n }\n\n const agentsDir = path.join(workspaceDir, 'agents');\n await fs.ensureDir(agentsDir);\n if (await fs.pathExists(agentsDir)) {\n const agentsStats = await fs.lstat(agentsDir);\n if (agentsStats.isSymbolicLink()) {\n throw new Error('.code_puppy/agents is a symlink — refusing to write. Check for tampering.');\n }\n }\n\n // config.json — projectOnly: true\n // Merge with existing so we don't clobber user customizations on re-scaffold\n const configPath = path.join(workspaceDir, 'config.json');\n let existingConfig: Record<string, unknown> = {};\n if (fs.existsSync(configPath)) {\n try {\n existingConfig = JSON.parse(await fs.readFile(configPath, 'utf-8')) as Record<\n string,\n unknown\n >;\n } catch {\n // Malformed — start fresh\n }\n }\n if (await fs.pathExists(configPath)) {\n const configStats = await fs.lstat(configPath);\n if (configStats.isSymbolicLink()) {\n throw new Error(\n '.code_puppy/config.json is a symlink — refusing to write. Check for tampering.'\n );\n }\n }\n await fs.writeFile(\n configPath,\n JSON.stringify({ ...existingConfig, projectOnly: true }, null, 2) + '\\n',\n 'utf-8'\n );\n\n // mcp_servers.json — pnpm-based stackwright-pro-mcp server\n // ${PROJECT_ROOT} is a literal — raft-puppy expands it at runtime to the\n // directory containing .code_puppy/ (walk-up discovery root).\n const mcpServersPath = path.join(workspaceDir, 'mcp_servers.json');\n if (await fs.pathExists(mcpServersPath)) {\n const mcpStats = await fs.lstat(mcpServersPath);\n if (mcpStats.isSymbolicLink()) {\n throw new Error(\n '.code_puppy/mcp_servers.json is a symlink — refusing to write. Check for tampering.'\n );\n }\n }\n if (!fs.existsSync(mcpServersPath)) {\n const mcpConfig = {\n mcp_servers: {\n 'stackwright-pro-mcp': {\n type: 'stdio',\n command: 'pnpm',\n args: ['exec', 'stackwright-pro-mcp'],\n enabled: true,\n cwd: '${PROJECT_ROOT}',\n },\n },\n };\n await fs.writeFile(mcpServersPath, JSON.stringify(mcpConfig, null, 2) + '\\n', 'utf-8');\n }\n}\n\n// ---------------------------------------------------------------------------\n// README generation\n// ---------------------------------------------------------------------------\n\nexport interface GenerateReadmeOptions {\n projectName: string;\n hasSpec: boolean;\n specName?: string;\n specFilename?: string;\n hasOtters: boolean;\n hasMock: boolean;\n}\n\n/**\n * Generate a project README.md with conditional sections based on which\n * Pro features are enabled (spec, mock server, otter raft).\n */\nexport function generateReadme(options: GenerateReadmeOptions): string {\n const { projectName, hasSpec, specName, specFilename, hasOtters, hasMock } = options;\n\n // Build API Integration section if spec is present\n const apiIntegrationSection = hasSpec\n ? `## 📡 API Integration\\n\\nYour OpenAPI spec was copied to \\`specs/${specFilename}\\` and wired up in \\`stackwright.yml\\`.\\n\\n**What gets generated:**\\n\\n\\`\\`\\`typescript\\n// src/generated/${specName}/schemas.ts\\nexport const EquipmentSchema = z.object({\\n id: z.string(),\\n name: z.string(),\\n status: z.enum(['operational', 'maintenance', 'retired']),\\n // ... Zod validation for runtime safety\\n});\\n\\n// src/generated/${specName}/types.ts\\nexport type Equipment = z.infer<typeof EquipmentSchema>;\\n\\n// src/generated/${specName}/client.ts\\nexport class ${(specName ?? 'api').charAt(0).toUpperCase() + (specName ?? 'api').slice(1)}Client {\\n async getEquipment(id: string): Promise<Equipment> {\\n // Auto-wired with auth, validation, error handling\\n }\\n}\\n\\`\\`\\`\\n\\n**How it works:**\\n1. The \\`predev\\` script in \\`package.json\\` runs \\`prebuild.js\\` before every \\`pnpm dev\\`\\n2. Prebuild reads your spec and generates type-safe code\\n3. You import and use it:\\n\\n\\`\\`\\`typescript\\nimport { ${(specName ?? 'api').charAt(0).toUpperCase() + (specName ?? 'api').slice(1)}Client } from '@/generated/${specName}/client';\\nimport type { Equipment } from '@/generated/${specName}/types';\\n\\nconst client = new ${(specName ?? 'api').charAt(0).toUpperCase() + (specName ?? 'api').slice(1)}Client();\\nconst gear: Equipment = await client.getEquipment('123');\\n\\`\\`\\`\\n\\nNo manual typing. No drift. No runtime surprises.\\n\\n`\n : '';\n\n // Build mock server section if enabled\n const mockSection = hasMock\n ? `## 🎭 Mock Server\\n\\nPrism mock server is configured to serve your API at **http://localhost:4010**.\\n\\n\\`\\`\\`bash\\npnpm dev:mock # Starts Prism + Next.js together\\n\\`\\`\\`\\n\\nThis starts:\\n1. Prism mock server on port 4010 (serves your OpenAPI spec)\\n2. Next.js dev server on port 3000\\n\\nThe generated API client is automatically configured to use the mock server.\\n\\n`\n : '';\n\n // Build AI Agents section if otters are present\n const aiAgentsSection = hasOtters\n ? `## 🦦 AI Agents (The Otter Raft)\\n\\nYour project includes **SIX specialized AI agents** in \\`node_modules/@stackwright-pro/otters/\\`:\\n\\n- \\`stackwright-pro-foreman-otter\\` - Master coordinator that orchestrates all specialist otters\\n- \\`stackwright-pro-api-otter\\` - Discovers entities from OpenAPI specs\\n- \\`stackwright-pro-auth-otter\\` - Configures CAC/OIDC auth, RBAC rules, and audit middleware\\n- \\`stackwright-pro-data-otter\\` - Configures endpoint filters & ISR revalidation\\n- \\`stackwright-pro-page-otter\\` - Generates pages auto-wired with data, theme, and auth\\n- \\`stackwright-pro-dashboard-otter\\` - Builds live data dashboards\\n\\n**Start the otter raft:**\\n\\n\\`\\`\\`bash\\nnpx @stackwright-pro/raft\\n\\`\\`\\`\\n\\nThe raft verifies otter integrity, writes project context, and spawns code-puppy in foreman mode. The foreman asks questions about your brand, auth, and data preferences, then coordinates specialist otters to build your app. All state lives in \\`.stackwright/\\` — interrupt and resume anytime.\\n\\n**Example session prompt:**\\n\\n\"Build me a logistics dashboard from our OpenAPI spec. Connect to /equipment and /supplies endpoints.\"\\n\\n`\n : '';\n\n return `# ${projectName}\\n\\nA Stackwright Pro application with role-based auth, OpenAPI integration, and intelligent AI agents.\\n\\n## 🚀 Quick Start\\n\\n\\`\\`\\`bash\\n# Start development server\\npnpm dev\\n\\n# Open your browser\\nopen http://localhost:3000\\n\\`\\`\\`\\n\\n## 👥 Role-Based Development\\n\\nStackwright Pro includes **mock authentication** for local development with three pre-configured roles:\\n\\n\\`\\`\\`bash\\npnpm dev:admin # Full permissions (*)\\npnpm dev:analyst # Read & write data\\npnpm dev:viewer # Read-only access\\n\\`\\`\\`\\n\\n**How it works:**\\n- Each script sets the \\`MOCK_USER\\` environment variable\\n- \\`lib/mock-auth.ts\\` intercepts requests and injects the appropriate user context\\n- Your pages & API routes respect the RBAC rules in \\`stackwright.yml\\`\\n- No backend required for testing auth flows! 🎉\\n\\n**Pro tip:** Test your UI for all three roles to ensure proper permissions enforcement.\\n\\n${mockSection}## 📁 Project Structure\\n\\n\\`\\`\\`\\n.\\n├── app/\\n│ ├── layout.tsx # Root layout (StackwrightLayout + Providers)\\n│ ├── page.tsx # Home page (renders root content)\\n│ ├── [...slug]/\\n│ │ └── page.tsx # Dynamic pages from YAML content\\n│ └── _components/\\n│ ├── providers.tsx # Pro: AuthProvider + component registration\\n│ └── page-client.tsx # Client-side page renderer\\n├── pages/\\n│ └── content.yml # Root page content in YAML\\n├── lib/\\n│ └── mock-auth.ts # Dev-only auth mocking (no backend needed)\\n├── scripts/\\n│ └── prebuild.js # Auto-generates code from OpenAPI specs\\n├── specs/ # OpenAPI spec files (if --spec was used)\\n├── src/\\n│ └── generated/ # Auto-generated types & clients\\n│ └── {specName}/\\n│ ├── schemas.ts # Zod schemas for runtime validation\\n│ ├── types.ts # TypeScript types\\n│ ├── client.ts # API client with auth\\n│ └── provider.ts # CollectionProvider for Stackwright\\n├── .stackwright/\\n│ └── otters/ # AI agent configs (4 specialized otters)\\n├── stackwright.yml # Theme, auth, API integrations\\n└── package.json\\n\\`\\`\\`\\n\\n**Key Files:**\\n- \\`app/_components/providers.tsx\\` - Wraps your app with \\`AuthProvider\\` for RBAC\\n- \\`stackwright.yml\\` - Single source of truth for theme, auth roles, and API wiring\\n- \\`lib/mock-auth.ts\\` - Mocks CAC/PIV headers locally so you can test auth flows\\n- \\`scripts/prebuild.js\\` - Runs before dev/build to generate types from your OpenAPI spec\\n\\n## 📄 Adding Pages\\n\\nStackwright uses **YAML for content**, so you never touch JSX unless you want to.\\n\\n**Example:** Create \\`pages/about/content.yml\\`:\\n\\n\\`\\`\\`yaml\\ntitle: About Us\\ndescription: Learn more about our mission\\n\\nsections:\\n - type: main\\n heading: Who We Are\\n body: |\\n We build mission-critical logistics systems for the Marine Corps.\\n\\n - type: feature_list\\n title: Our Capabilities\\n features:\\n - icon: Security\\n title: Zero Trust\\n description: PKI-based auth with CAC/PIV\\n - icon: Api\\n title: Real-time Data\\n description: OpenAPI-backed, Zod-validated\\n\\`\\`\\`\\n\\nThat's it. Navigate to \\`/about\\` and it just works. No routing config, no React components.\\n\\n${apiIntegrationSection}## 🎨 Customizing Theme\\n\\nEdit \\`stackwright.yml\\` to change colors, fonts, spacing — applies everywhere instantly.\\n\\n\\`\\`\\`yaml\\ntheme:\\n id: my-theme\\n name: My Custom Theme\\n colors:\\n primary: \"#C41E3A\" # Marine Corps red\\n background: \"#FFFFFF\"\\n text: \"#1A1A1A\"\\n accent: \"#FFD700\" # Gold\\n typography:\\n fontFamily: \"'Inter', sans-serif\"\\n h1Size: \"2.5rem\"\\n spacing:\\n unit: 8\\n\\`\\`\\`\\n\\nNo CSS files. No theme provider boilerplate. Just YAML. Stackwright handles the rest.\\n\\n## 🔐 Auth Configuration\\n\\nStackwright Pro comes with **3 pre-configured roles** in \\`stackwright.yml\\`:\\n\\n\\`\\`\\`yaml\\nauth:\\n roles:\\n - name: ADMIN\\n permissions: ['*'] # Full access\\n - name: ANALYST \\n permissions: ['data:read', 'data:write'] # Read/write data\\n - name: VIEWER\\n permissions: ['data:read'] # Read-only\\n\\`\\`\\`\\n\\n**Gate content in your YAML:**\\n\\n\\`\\`\\`yaml\\nsections:\\n - type: button\\n label: Delete Equipment\\n action: /api/equipment/delete\\n auth:\\n required_roles: [ADMIN]\\n fallback: hide # Options: hide, disable, show_message\\n\\`\\`\\`\\n\\nOnly admins see the button. Analysts and viewers? Button doesn't exist in the DOM.\\n\\n**Route protection:**\\n\\n\\`\\`\\`yaml\\nauth:\\n protected_routes:\\n - path: /admin/*\\n roles: [ADMIN]\\n - path: /equipment/* \\n roles: [ANALYST, ADMIN]\\n public_routes:\\n - /\\n - /about\\n\\`\\`\\`\\n\\nNo middleware to write. No useAuth hooks to remember. RBAC is declarative.\\n\\n${aiAgentsSection}## 📚 Learn More\\n\\n- **Stackwright Docs:** [https://stackwright.dev](https://stackwright.dev)\\n- **OSS Repo:** [https://github.com/Per-Aspera-LLC/stackwright](https://github.com/Per-Aspera-LLC/stackwright)\\n- **Pro Repo:** [https://github.com/Per-Aspera-LLC/stackwright-pro](https://github.com/Per-Aspera-LLC/stackwright-pro)\\n\\n**Questions?** File an issue or ping us in the discussions. We're here to help you ship faster.\\n`;\n}\n","// AUTO-GENERATED — do not edit manually.\n// Run `pnpm sync-versions` or `pnpm build` to regenerate.\n//\n// PRO_VERSIONS: exact versions of @stackwright-pro/* packages in this workspace.\n// OSS_VERSIONS: minimum tested versions of @stackwright/* OSS packages (caret range).\n\n/**\n * Exact versions of every @stackwright-pro/* package currently in the workspace.\n * Used by launch-stackwright-pro and scaffold-hooks to pin deps in scaffolded projects.\n * Updated automatically on every build — never edit this file by hand.\n */\nexport const PRO_VERSIONS = {\n '@stackwright-pro/auth': '0.2.0-alpha.11',\n '@stackwright-pro/auth-nextjs': '0.2.0-alpha.13',\n '@stackwright-pro/display-components': '0.2.0-alpha.10',\n '@stackwright-pro/mcp': '0.2.0-alpha.58',\n '@stackwright-pro/openapi': '0.3.0-alpha.23',\n '@stackwright-pro/otters': '1.0.0-alpha.43',\n '@stackwright-pro/pulse': '0.3.0-alpha.16',\n '@stackwright-pro/workflow': '0.1.0-alpha.15',\n '@stackwright-pro/workflow-components': '0.1.0-alpha.17',\n} as const satisfies Record<string, string>;\n\n/**\n * Minimum tested versions of @stackwright/* OSS packages.\n * Caret ranges anchored to the last version resolved in pnpm-lock.yaml.\n * Updated automatically on every build.\n */\nexport const OSS_VERSIONS = {\n '@stackwright/build-scripts': '^0.8.0',\n '@stackwright/collections': '^0.1.2',\n '@stackwright/core': '^0.9.0',\n '@stackwright/icons': '^0.5.2',\n '@stackwright/mcp': '^0.5.0',\n '@stackwright/nextjs': '^0.6.0',\n '@stackwright/otters': '^0.2.2',\n '@stackwright/types': '^1.6.0',\n '@stackwright/ui-shadcn': '^0.1.3',\n} as const satisfies Record<string, string>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,iBAAAA,UAAAC,SAAA;AAAA,IAAAA,QAAA;AAAA,MACE,MAAQ;AAAA,MACR,SAAW;AAAA,MACX,aAAe;AAAA,MACf,SAAW;AAAA,MACX,eAAiB;AAAA,QACf,QAAU;AAAA,MACZ;AAAA,MACA,YAAc;AAAA,QACZ,MAAQ;AAAA,QACR,KAAO;AAAA,MACT;AAAA,MACA,UAAY;AAAA,QACV;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MACA,OAAS;AAAA,QACP;AAAA,QACA;AAAA,MACF;AAAA,MACA,KAAO;AAAA,QACL,0BAA0B;AAAA,MAC5B;AAAA,MACA,SAAW;AAAA,QACT,OAAS;AAAA,QACT,iBAAiB;AAAA,QACjB,KAAO;AAAA,QACP,MAAQ;AAAA,QACR,iBAAiB;AAAA,MACnB;AAAA,MACA,cAAgB;AAAA,QACd,yBAAyB;AAAA,QACzB,gCAAgC;AAAA,QAChC,wBAAwB;AAAA,QACxB,4BAA4B;AAAA,QAC5B,2BAA2B;AAAA,QAC3B,mCAAmC;AAAA,QACnC,oBAAoB;AAAA,QACpB,8BAA8B;AAAA,QAC9B,OAAS;AAAA,QACT,WAAa;AAAA,QACb,YAAY;AAAA,QACZ,WAAW;AAAA,MACb;AAAA,MACA,iBAAmB;AAAA,QACjB,mBAAmB;AAAA,QACnB,kBAAkB;AAAA,QAClB,eAAe;AAAA,QACf,YAAc;AAAA,QACd,MAAQ;AAAA,QACR,QAAU;AAAA,MACZ;AAAA,IACF;AAAA;AAAA;;;ACxDA,uBAAwB;AACxB,IAAAC,eAAiB;AACjB,gBAAe;AACf,IAAAC,mBAAe;AACf,mBAAkB;AAClB,2BAAyB;AAEzB,iBAA0C;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,aAAAA,QAAK,QAAQ,QAAQ,IAAI,GAAG,QAAQ,IAAI,IACxC,QAAQ,IAAI;AAGpB,QAAI,CAAC,UAAU,WAAW,UAAU,aAAAA,QAAK,GAAG,KAAK,cAAc,SAAS;AACtE,cAAQ,KAAK,aAAAE,QAAM,OAAO,0DAAgD,SAAS,EAAE,CAAC;AAAA,IACxF;AAEA,UAAM,OAAO,WAAW,OAAO;AAAA,EACjC,CAAC;AAEH,QAAM,QAAQ,WAAW,QAAQ,IAAI;AACvC;AAEA,KAAK,EAAE,MAAM,CAAC,QAAiB;AAC7B,UAAQ,MAAM,aAAAA,QAAM,IAAI,yBAAoB,GAAG,GAAG;AAClD,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["exports","module","import_path","import_fs_extra","path","fs","yaml","path","fs","chalk","os"]}
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@stackwright-pro/launch-stackwright-pro",
3
- "version": "0.4.0-alpha.9",
3
+ "version": "0.4.0-alpha.93",
4
4
  "description": "Launch a new Stackwright Pro project with OpenAPI integration, auth, and the otter raft",
5
- "license": "MIT",
5
+ "license": "SEE LICENSE IN LICENSE",
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },
@@ -26,24 +26,30 @@
26
26
  "launch-stackwright-pro": "dist/index.js"
27
27
  },
28
28
  "dependencies": {
29
- "@stackwright-pro/scaffold-hooks": "latest",
30
- "@stackwright/cli": "^0.7.1-alpha.0",
31
- "@stackwright/scaffold-core": "^0.1.0",
29
+ "@stackwright/cli": "^0.9.0",
30
+ "@stackwright/scaffold-core": "^0.3.2",
32
31
  "chalk": "^5.6.2",
33
- "commander": "^14.0.3",
34
- "fs-extra": "^11.3",
35
- "js-yaml": "^4.1.0"
32
+ "commander": "^15.0.0",
33
+ "fs-extra": "^11.3.5",
34
+ "js-yaml": "^4.2.0",
35
+ "@stackwright-pro/auth-nextjs": "0.2.0-alpha.13",
36
+ "@stackwright-pro/auth": "0.2.0-alpha.11",
37
+ "@stackwright-pro/openapi": "0.3.0-alpha.23",
38
+ "@stackwright-pro/otters": "1.0.0-alpha.43",
39
+ "@stackwright-pro/mcp": "0.2.0-alpha.58",
40
+ "@stackwright-pro/scaffold-hooks": "1.0.0-alpha.15"
36
41
  },
37
42
  "devDependencies": {
38
43
  "@types/fs-extra": "^11.0",
39
44
  "@types/js-yaml": "^4.0.9",
40
- "@types/node": "^24.0.0",
41
- "typescript": "^5.0",
42
- "tsup": "^8.5",
43
- "vitest": "^4.0.18"
45
+ "@types/node": "^25.9.2",
46
+ "typescript": "^6.0.3",
47
+ "tsup": "^8.5.1",
48
+ "vitest": "^4.1.8"
44
49
  },
45
50
  "scripts": {
46
- "build": "tsup",
51
+ "build": "node ../../scripts/sync-versions.mjs && tsup",
52
+ "sync-versions": "node ../../scripts/sync-versions.mjs",
47
53
  "dev": "tsup --watch",
48
54
  "test": "vitest run",
49
55
  "test:coverage": "vitest run --coverage"
@@ -6,7 +6,17 @@ import { registerDisplayComponents } from '@stackwright-pro/display-components';
6
6
  import { registerPulseComponents } from '@stackwright-pro/pulse';
7
7
  import { AuthProvider } from '@stackwright-pro/auth';
8
8
  import '@stackwright/ui-shadcn/styles.css';
9
- import authConfig from '../src/auth-config.json'; // Generated at build time by prebuild.js
9
+ import authConfigRaw from '../src/auth-config.json'; // Generated at build time by prebuild.js
10
+
11
+ // auth-config.json is written from stackwright.yml `auth:` section — it may be
12
+ // sparse (e.g. `{}`) when roles haven't been configured yet, so we cast to the
13
+ // full shape and use || fallbacks below.
14
+ type AuthConfigShape = {
15
+ roles?: Array<{ name: string; permissions?: string[] }>;
16
+ protected_routes?: Array<{ path: string; roles: string[] }>;
17
+ public_routes?: string[];
18
+ };
19
+ const authConfig = authConfigRaw as AuthConfigShape;
10
20
 
11
21
  // Register Stackwright components
12
22
  registerNextJSComponents();
@@ -24,9 +34,9 @@ export default function App({ Component, pageProps }: AppProps) {
24
34
  user={user}
25
35
  session={session}
26
36
  rbacConfig={{
27
- roles: authConfig.roles || [],
28
- protected_routes: authConfig.protected_routes || [],
29
- public_routes: authConfig.public_routes || [],
37
+ roles: authConfig.roles ?? [],
38
+ protected_routes: authConfig.protected_routes ?? [],
39
+ public_routes: authConfig.public_routes ?? [],
30
40
  }}
31
41
  >
32
42
  <Component {...pageProps} />
@@ -7,5 +7,5 @@ content:
7
7
  textSize: h1
8
8
  textColor: secondary
9
9
  textBlocks:
10
- - text: Welcome to your new Stackwright Pro project. Edit pages/content.yml to update this page.
10
+ - text: Welcome to your new Stackwright Pro project. Run the otter raft to build your pages.
11
11
  textSize: h6
@@ -13,6 +13,9 @@ module.exports = createStackwrightNextConfig({
13
13
  '@stackwright-pro/auth',
14
14
  '@stackwright-pro/auth-nextjs',
15
15
  '@stackwright-pro/display-components',
16
+ '@stackwright-pro/pulse',
17
+ '@stackwright-pro/workflow',
18
+ '@stackwright-pro/workflow-components',
16
19
  ],
17
20
  // YAML is parsed server-side at build time - no loader needed in browser
18
21
  });
@@ -1,105 +1,103 @@
1
1
  /**
2
2
  * Stackwright Pro prebuild script
3
3
  *
4
- * Runs stackwright-prebuild to generate content JSON files from YAML,
5
- * then runs the OpenAPI plugin to generate API client code.
6
- * Also extracts auth config and generates auth-config.json for client-side use.
4
+ * Uses runPrebuild() from @stackwright/build-scripts directly with the pro
5
+ * content plugin, enabling pro content types to pass schema validation
6
+ * alongside OSS content types.
7
+ *
8
+ * Also runs the OpenAPI plugin for API client generation and extracts
9
+ * auth config for client-side use.
10
+ *
11
+ * Requires @stackwright/build-scripts >= 0.7.0
7
12
  */
8
13
 
9
- const { spawn } = require('child_process');
14
+ 'use strict';
15
+
10
16
  const fs = require('fs');
11
17
  const path = require('path');
12
18
  const yaml = require('js-yaml');
13
- const { createOpenAPIPlugin } = require('@stackwright-pro/openapi');
14
-
15
- /**
16
- * Run stackwright-prebuild to generate _root.json, _site.json, etc.
17
- */
18
- async function runStackwrightPrebuild(projectRoot) {
19
- return new Promise((resolve, reject) => {
20
- // Use pnpm exec to ensure we use the correct package manager
21
- const proc = spawn(process.platform === 'win32' ? 'pnpm.cmd' : 'pnpm', ['exec', 'stackwright-prebuild'], {
22
- cwd: projectRoot,
23
- stdio: 'inherit',
24
- shell: true,
25
- });
26
- proc.on('close', (code) => {
27
- if (code === 0) {
28
- resolve();
29
- } else {
30
- reject(new Error(`stackwright-prebuild exited with code ${code}`));
31
- }
32
- });
33
- proc.on('error', reject);
34
- });
35
- }
19
+ const { runPrebuild } = require('@stackwright/build-scripts');
20
+ const { createWorkflowPlugin } = require('@stackwright-pro/workflow');
21
+ const { proContentPlugin } = require('./pro-content-plugin');
36
22
 
37
23
  /**
38
24
  * Parse full stackwright.yml using js-yaml for complete config parsing
39
25
  */
40
26
  function parseStackwrightYml(content) {
41
- return yaml.load(content);
27
+ return yaml.load(content, { schema: yaml.CORE_SCHEMA });
42
28
  }
43
29
 
44
30
  async function main() {
45
- try {
46
- const projectRoot = path.resolve(__dirname, '..');
47
-
48
- const configPath = path.join(projectRoot, 'stackwright.yml');
49
- if (!fs.existsSync(configPath)) {
50
- console.log('No stackwright.yml found — skipping prebuild.');
51
- return;
52
- }
31
+ const projectRoot = path.resolve(__dirname, '..');
53
32
 
54
- // Run stackwright-prebuild first to generate content JSON files
55
- console.log('Generating content files...');
56
- await runStackwrightPrebuild(projectRoot);
33
+ const configPath = path.join(projectRoot, 'stackwright.yml');
34
+ if (!fs.existsSync(configPath)) {
35
+ console.log('No stackwright.yml found — skipping prebuild.');
36
+ return;
37
+ }
57
38
 
58
- const configContent = fs.readFileSync(configPath, 'utf-8');
59
- const fullConfig = parseStackwrightYml(configContent);
39
+ const configContent = fs.readFileSync(configPath, 'utf-8');
40
+ let fullConfig = parseStackwrightYml(configContent);
60
41
 
61
- // Extract auth config and write as JSON for client-side use
62
- if (fullConfig.auth) {
63
- const authConfig = fullConfig.auth;
64
- const srcDir = path.join(projectRoot, 'src');
65
-
66
- if (!fs.existsSync(srcDir)) {
67
- fs.mkdirSync(srcDir, { recursive: true });
68
- }
69
-
70
- fs.writeFileSync(
71
- path.join(srcDir, 'auth-config.json'),
72
- JSON.stringify(authConfig, null, 2)
73
- );
74
- console.log('✓ Generated src/auth-config.json');
42
+ // --- Interim: merge theme file into stackwright.yml before prebuild ---
43
+ // Theme Otter writes stackwright.theme.yml separately to avoid clobbering.
44
+ // Remove this block when @stackwright/build-scripts natively supports stackwright.theme.yml.
45
+ const themeConfigPath = path.join(projectRoot, 'stackwright.theme.yml');
46
+ let originalConfigContent = null;
47
+ if (fs.existsSync(themeConfigPath)) {
48
+ const themeContent = fs.readFileSync(themeConfigPath, 'utf-8');
49
+ const themeOverlay = yaml.load(themeContent, { schema: yaml.CORE_SCHEMA });
50
+ if (themeOverlay && typeof themeOverlay === 'object') {
51
+ originalConfigContent = configContent; // save for restore
52
+ Object.assign(fullConfig, themeOverlay);
53
+ fs.writeFileSync(configPath, yaml.dump(fullConfig, { lineWidth: -1, noRefs: true }));
54
+ console.log(' Merged stackwright.theme.yml -> stackwright.yml (interim shim)');
75
55
  }
56
+ }
76
57
 
77
- // Extract integrations for OpenAPI plugin
78
- const siteConfig = { integrations: fullConfig.integrations || [] };
79
-
80
- if (!siteConfig.integrations.length) {
81
- console.log('No integrations in stackwright.yml — skipping OpenAPI plugin.');
82
- console.log('✓ Prebuild complete!');
83
- return;
84
- }
58
+ // Assemble plugins
59
+ const workflowPlugin = createWorkflowPlugin();
60
+ const plugins = [proContentPlugin, workflowPlugin];
85
61
 
86
- console.log(`Found ${siteConfig.integrations.length} integration(s). Running OpenAPI plugin...`);
62
+ const integrations = fullConfig.integrations || [];
63
+ if (integrations.length > 0) {
64
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
65
+ const { createOpenAPIPlugin } = require('@stackwright-pro/openapi');
66
+ plugins.push(createOpenAPIPlugin());
67
+ console.log(` OpenAPI plugin: loaded (${integrations.length} integrations)`);
68
+ }
87
69
 
88
- const plugin = createOpenAPIPlugin();
70
+ // Run prebuild with all plugins
71
+ console.log('Generating content files...');
72
+ await runPrebuild({
73
+ projectRoot,
74
+ plugins,
75
+ unknownContentTypes: 'warn', // log warnings for unknown types instead of failing build
76
+ });
89
77
 
90
- if (plugin.beforeBuild) {
91
- await plugin.beforeBuild({
92
- siteConfig,
93
- projectRoot,
94
- });
78
+ // Extract auth config and write as JSON for client-side use
79
+ if (fullConfig.auth) {
80
+ const srcDir = path.join(projectRoot, 'src');
81
+ if (!fs.existsSync(srcDir)) {
82
+ fs.mkdirSync(srcDir, { recursive: true });
95
83
  }
84
+ fs.writeFileSync(
85
+ path.join(srcDir, 'auth-config.json'),
86
+ JSON.stringify(fullConfig.auth, null, 2)
87
+ );
88
+ console.log('✓ Generated src/auth-config.json');
89
+ }
96
90
 
97
- console.log('✓ Prebuild complete!');
98
- } catch (error) {
99
- console.error('Prebuild failed:', error.message);
100
- console.error(error.stack);
101
- process.exit(1);
91
+ // Restore original stackwright.yml if we modified it during theme merge
92
+ if (originalConfigContent !== null) {
93
+ fs.writeFileSync(configPath, originalConfigContent);
102
94
  }
95
+
96
+ console.log(' Prebuild complete!');
103
97
  }
104
98
 
105
- main();
99
+ main().catch((err) => {
100
+ console.error('Prebuild failed:', err.message);
101
+ console.error(err.stack);
102
+ process.exit(1);
103
+ });
@@ -0,0 +1,46 @@
1
+ 'use client';
2
+ import { registerAppRouterComponents } from '@stackwright/nextjs/app-router';
3
+ import { registerShadcnComponents } from '@stackwright/ui-shadcn';
4
+ import { registerDefaultIcons } from '@stackwright/icons';
5
+ import { registerDisplayComponents } from '@stackwright-pro/display-components';
6
+ import { registerPulseComponents } from '@stackwright-pro/pulse';
7
+ import { AuthProvider } from '@stackwright-pro/auth';
8
+ import '@stackwright/ui-shadcn/styles.css';
9
+ // Generated by stackwright-prebuild. Run `pnpm predev` to regenerate when icons change.
10
+ // This file is safe to commit — it is updated deterministically from your YAML content.
11
+ import { registerSiteIcons } from '../../stackwright-generated/icons';
12
+ import authConfigRaw from '../../src/auth-config.json';
13
+
14
+ // auth-config.json is written from stackwright.yml `auth:` section by prebuild.js — it may be
15
+ // sparse (e.g. `{}`) when roles haven't been configured yet, so we cast to the full shape
16
+ // and use ?? fallbacks below.
17
+ type AuthConfigShape = {
18
+ roles?: Array<{ name: string; permissions?: string[] }>;
19
+ protected_routes?: Array<{ path: string; roles: string[] }>;
20
+ public_routes?: string[];
21
+ };
22
+ const authConfig = authConfigRaw as AuthConfigShape;
23
+
24
+ // Register Stackwright components (OSS + Pro)
25
+ registerAppRouterComponents();
26
+ registerSiteIcons();
27
+ registerShadcnComponents();
28
+ registerDefaultIcons();
29
+ registerDisplayComponents();
30
+ registerPulseComponents();
31
+
32
+ export function Providers({ children }: { children: React.ReactNode }) {
33
+ return (
34
+ <AuthProvider
35
+ user={null}
36
+ session={null}
37
+ rbacConfig={{
38
+ roles: authConfig.roles ?? [],
39
+ protected_routes: authConfig.protected_routes ?? [],
40
+ public_routes: authConfig.public_routes ?? [],
41
+ }}
42
+ >
43
+ {children}
44
+ </AuthProvider>
45
+ );
46
+ }
@@ -0,0 +1,99 @@
1
+ // packages/launch-stackwright-pro/templates/pro/scripts/pro-content-plugin.js
2
+ //
3
+ // Pro content type plugin for @stackwright/build-scripts.
4
+ //
5
+ // CONFIRMED CASE B (@stackwright/build-scripts@0.5.0-alpha.0 / types@1.2.0-alpha.0):
6
+ // The currently shipped version of build-scripts does NOT read
7
+ // `contentItemSchemas` or `knownContentTypeKeys` from plugin objects.
8
+ // Those fields first appear in @stackwright/types@1.4.0+ and will be
9
+ // consumed by build-scripts@0.7.0 when that release ships.
10
+ //
11
+ // CURRENT BEHAVIOUR (pre-0.7.0):
12
+ // `unknownContentTypes: 'warn'` in prebuild.js already prevents hard failures
13
+ // for unrecognised content types. The `beforeBuild` stub below ensures this
14
+ // plugin is a syntactically valid, callable plugin (not silently ignored by
15
+ // the plugin runner) even though there is no side-effect to execute yet.
16
+ //
17
+ // TODO(@stackwright/build-scripts@0.7.0): Once 0.7.0 is the resolved floor,
18
+ // remove the `beforeBuild` stub — `contentItemSchemas` and
19
+ // `knownContentTypeKeys` will be consumed natively by the runtime and the
20
+ // plugin will suppress "unknown content type" warnings automatically.
21
+
22
+ 'use strict';
23
+
24
+ const { z } = require('zod');
25
+
26
+ const PRO_CONTENT_TYPE_KEYS = [
27
+ // @stackwright-pro/display-components
28
+ 'metric_card',
29
+ 'status_badge',
30
+ 'stat_bar',
31
+ 'sparkline',
32
+ 'activity_feed',
33
+ 'dashboard_grid',
34
+ 'data_table',
35
+ 'json_viewer',
36
+ 'action_bar',
37
+ 'section',
38
+ 'collection_listing',
39
+ // @stackwright-pro/pulse
40
+ 'pulse_provider',
41
+ 'metric_card_pulse',
42
+ 'data_table_pulse',
43
+ 'status_badge_pulse',
44
+ 'stats_grid',
45
+ 'alert_banner',
46
+ // @stackwright-pro/workflow-components
47
+ 'workflow_mount',
48
+ // @stackwright-pro/display-components — navigation
49
+ 'breadcrumb',
50
+ 'page_header_bar',
51
+ ];
52
+
53
+ // OSS content types that Pro otters augment with extra fields (e.g. `theme:`,
54
+ // `auth:`). The strict OSS Zod schemas reject unknown properties, so we
55
+ // register passthrough variants here. When build-scripts@0.7.0+ evaluates
56
+ // the union [contentItemSchema, ...extraSchemas], the strict OSS schema
57
+ // fails on the extra field and falls through to our passthrough version.
58
+ const OSS_TYPES_WITH_PRO_EXTENSIONS = [
59
+ 'text_block',
60
+ 'alert',
61
+ 'grid',
62
+ 'main',
63
+ 'collection_list',
64
+ ];
65
+
66
+ const proContentPlugin = {
67
+ name: 'pro-content',
68
+
69
+ // --- Fields read by build-scripts@0.7.0+ (types@1.4.0+) ---
70
+ // Passthrough schemas — let each component handle its own prop validation
71
+ // at runtime. Registered here so the prebuild content-item validator
72
+ // accepts pro types without errors.
73
+ contentItemSchemas: [
74
+ // Pro-only types — fully passthrough (no OSS schema exists)
75
+ ...PRO_CONTENT_TYPE_KEYS.map((type) =>
76
+ z.object({ type: z.literal(type) }).passthrough()
77
+ ),
78
+ // OSS types with Pro extensions (theme:, auth:, etc.) — passthrough
79
+ // variants so the extra fields don't fail strict OSS validation.
80
+ ...OSS_TYPES_WITH_PRO_EXTENSIONS.map((type) =>
81
+ z.object({ type: z.literal(type) }).passthrough()
82
+ ),
83
+ ],
84
+ // String keys so the prebuild skips "unknown content type" warnings.
85
+ knownContentTypeKeys: [...PRO_CONTENT_TYPE_KEYS, ...OSS_TYPES_WITH_PRO_EXTENSIONS],
86
+
87
+ // --- Stub lifecycle hook (required for build-scripts@0.5.x / types@1.2.x) ---
88
+ // build-scripts@0.5.x only calls plugins that have beforeBuild or afterBuild.
89
+ // Without this stub the plugin object is accepted but never invoked, making
90
+ // the whole registration a silent no-op. The stub has no side-effects; its
91
+ // only purpose is to keep the plugin in the active lifecycle.
92
+ //
93
+ // Remove this stub when build-scripts@0.7.0 is the resolved floor (the
94
+ // 0.7.x runner calls plugins purely for their schema/key registration,
95
+ // not via beforeBuild/afterBuild).
96
+ beforeBuild: () => {},
97
+ };
98
+
99
+ module.exports = { proContentPlugin };