@stackwright-pro/launch-stackwright-pro 0.4.0-alpha.13 → 0.4.0-alpha.130
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +11 -20
- package/dist/index.js +219 -119
- package/dist/index.js.map +1 -1
- package/package.json +17 -17
- package/templates/pro/_app.tsx +14 -4
- package/templates/pro/content.yml +1 -1
- package/templates/pro/next.config.js +3 -0
- package/templates/pro/prebuild.js +119 -73
- package/templates/pro/pro-providers.tsx +46 -0
- package/templates/pro/scripts/pro-content-plugin.js +103 -0
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
|
-
|
|
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
|
-
|
|
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 <
|
|
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
|
-
|
|
128
|
+
cd my-app
|
|
129
|
+
npx @stackwright-pro/raft
|
|
129
130
|
```
|
|
130
131
|
|
|
131
|
-
|
|
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
|
-
|
|
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.
|
|
34
|
+
version: "0.4.0-alpha.130",
|
|
35
35
|
description: "Launch a new Stackwright Pro project with OpenAPI integration, auth, and the otter raft",
|
|
36
|
-
license: "
|
|
36
|
+
license: "SEE LICENSE IN LICENSE",
|
|
37
37
|
publishConfig: {
|
|
38
38
|
access: "public"
|
|
39
39
|
},
|
|
@@ -69,21 +69,21 @@ var require_package = __commonJS({
|
|
|
69
69
|
"@stackwright-pro/mcp": "workspace:*",
|
|
70
70
|
"@stackwright-pro/openapi": "workspace:*",
|
|
71
71
|
"@stackwright-pro/otters": "workspace:*",
|
|
72
|
-
"@stackwright-pro/scaffold-hooks": "
|
|
73
|
-
"@stackwright/cli": "^0.
|
|
74
|
-
"@stackwright/scaffold-core": "^0.
|
|
72
|
+
"@stackwright-pro/scaffold-hooks": "workspace:*",
|
|
73
|
+
"@stackwright/cli": "^0.9.0",
|
|
74
|
+
"@stackwright/scaffold-core": "^0.3.3",
|
|
75
75
|
chalk: "^5.6.2",
|
|
76
|
-
commander: "^
|
|
77
|
-
"fs-extra": "^11.3",
|
|
78
|
-
"js-yaml": "^4.
|
|
76
|
+
commander: "^15.0.0",
|
|
77
|
+
"fs-extra": "^11.3.5",
|
|
78
|
+
"js-yaml": "^4.2.0"
|
|
79
79
|
},
|
|
80
80
|
devDependencies: {
|
|
81
81
|
"@types/fs-extra": "^11.0",
|
|
82
82
|
"@types/js-yaml": "^4.0.9",
|
|
83
|
-
"@types/node": "
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
vitest: "
|
|
83
|
+
"@types/node": "catalog:",
|
|
84
|
+
tsup: "catalog:",
|
|
85
|
+
typescript: "catalog:",
|
|
86
|
+
vitest: "catalog:"
|
|
87
87
|
}
|
|
88
88
|
};
|
|
89
89
|
}
|
|
@@ -91,84 +91,75 @@ var require_package = __commonJS({
|
|
|
91
91
|
|
|
92
92
|
// src/index.ts
|
|
93
93
|
var import_commander = require("commander");
|
|
94
|
-
var
|
|
94
|
+
var import_path2 = __toESM(require("path"));
|
|
95
95
|
var import_os = __toESM(require("os"));
|
|
96
|
-
var
|
|
96
|
+
var import_fs_extra2 = __toESM(require("fs-extra"));
|
|
97
97
|
var import_chalk = __toESM(require("chalk"));
|
|
98
|
-
var import_js_yaml = __toESM(require("js-yaml"));
|
|
99
98
|
var import_child_process = require("child_process");
|
|
100
99
|
var import_cli = require("@stackwright/cli");
|
|
101
100
|
var import_scaffold_core = require("@stackwright/scaffold-core");
|
|
102
101
|
var import_scaffold_hooks = require("@stackwright-pro/scaffold-hooks");
|
|
103
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
|
+
|
|
104
108
|
// src/generated/workspace-versions.ts
|
|
105
109
|
var PRO_VERSIONS = {
|
|
106
|
-
"@stackwright-pro/auth": "0.
|
|
107
|
-
"@stackwright-pro/auth-nextjs": "0.
|
|
108
|
-
"@stackwright-pro/
|
|
109
|
-
"@stackwright-pro/
|
|
110
|
-
"@stackwright-pro/
|
|
110
|
+
"@stackwright-pro/auth": "0.2.0-alpha.19",
|
|
111
|
+
"@stackwright-pro/auth-nextjs": "0.3.0-alpha.8",
|
|
112
|
+
"@stackwright-pro/display-components": "0.2.0-alpha.11",
|
|
113
|
+
"@stackwright-pro/mcp": "0.2.0-alpha.92",
|
|
114
|
+
"@stackwright-pro/openapi": "0.3.0-alpha.32",
|
|
115
|
+
"@stackwright-pro/otters": "1.0.0-alpha.60",
|
|
116
|
+
"@stackwright-pro/pulse": "0.3.0-alpha.27",
|
|
117
|
+
"@stackwright-pro/workflow": "0.1.0-alpha.22",
|
|
118
|
+
"@stackwright-pro/workflow-components": "0.1.0-alpha.24"
|
|
111
119
|
};
|
|
112
120
|
var OSS_VERSIONS = {
|
|
113
|
-
"@stackwright/build-scripts": "^0.
|
|
114
|
-
"@stackwright/
|
|
115
|
-
"@stackwright/
|
|
116
|
-
"@stackwright/
|
|
117
|
-
"@stackwright/
|
|
118
|
-
"@stackwright/
|
|
119
|
-
"@stackwright/
|
|
121
|
+
"@stackwright/build-scripts": "^0.9.0",
|
|
122
|
+
"@stackwright/collections": "^0.1.2",
|
|
123
|
+
"@stackwright/core": "^0.10.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.7.0",
|
|
129
|
+
"@stackwright/ui-shadcn": "^0.1.3"
|
|
120
130
|
};
|
|
121
131
|
|
|
122
|
-
// src/
|
|
123
|
-
(0, import_scaffold_hooks.registerProScaffoldHooks)();
|
|
124
|
-
var { version } = require_package();
|
|
125
|
-
async function copyProTemplate(templateName, destPath) {
|
|
126
|
-
const src = import_path.default.resolve(__dirname, "..", "templates", "pro", templateName);
|
|
127
|
-
await import_fs_extra.default.copy(src, destPath);
|
|
128
|
-
}
|
|
129
|
-
async function addAuthToStackwrightYml(targetDir) {
|
|
130
|
-
const ymlPath = import_path.default.join(targetDir, "stackwright.yml");
|
|
131
|
-
const content = await import_fs_extra.default.readFile(ymlPath, "utf-8");
|
|
132
|
-
const config = import_js_yaml.default.load(content, { schema: import_js_yaml.default.CORE_SCHEMA });
|
|
133
|
-
config.auth = {
|
|
134
|
-
type: "pki",
|
|
135
|
-
profile: "dod_cac",
|
|
136
|
-
source: "gateway_headers",
|
|
137
|
-
roles: [
|
|
138
|
-
{ name: "ADMIN", permissions: ["*"] },
|
|
139
|
-
{ name: "ANALYST", permissions: ["data:read", "data:write"] },
|
|
140
|
-
{ name: "VIEWER", permissions: ["data:read"] }
|
|
141
|
-
],
|
|
142
|
-
protected_routes: [{ path: "/*", roles: ["VIEWER", "ANALYST", "ADMIN"] }],
|
|
143
|
-
public_routes: ["/", "/getting-started"]
|
|
144
|
-
};
|
|
145
|
-
await import_fs_extra.default.writeFile(ymlPath, import_js_yaml.default.dump(config, { lineWidth: 120 }));
|
|
146
|
-
}
|
|
132
|
+
// src/scaffold.ts
|
|
147
133
|
async function addProDepsToPackageJson(targetDir) {
|
|
148
134
|
const pkgPath = import_path.default.join(targetDir, "package.json");
|
|
149
135
|
const content = await import_fs_extra.default.readFile(pkgPath, "utf-8");
|
|
150
136
|
const pkg = JSON.parse(content);
|
|
151
|
-
const dependencies = pkg.dependencies
|
|
152
|
-
const devDependencies = pkg.devDependencies
|
|
153
|
-
const scripts = pkg.scripts
|
|
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 } : {};
|
|
154
140
|
for (const [pkgName, pinnedVersion] of Object.entries(OSS_VERSIONS)) {
|
|
155
|
-
if (
|
|
141
|
+
if (pkgName in dependencies) {
|
|
156
142
|
dependencies[pkgName] = pinnedVersion;
|
|
157
143
|
}
|
|
158
|
-
if (
|
|
144
|
+
if (pkgName in devDependencies) {
|
|
159
145
|
devDependencies[pkgName] = pinnedVersion;
|
|
160
146
|
}
|
|
161
147
|
}
|
|
162
148
|
Object.assign(dependencies, {
|
|
149
|
+
"@stackwright-pro/display-components": PRO_VERSIONS["@stackwright-pro/display-components"],
|
|
163
150
|
"@stackwright-pro/mcp": PRO_VERSIONS["@stackwright-pro/mcp"],
|
|
164
151
|
"@stackwright-pro/otters": PRO_VERSIONS["@stackwright-pro/otters"],
|
|
165
152
|
"@stackwright-pro/openapi": PRO_VERSIONS["@stackwright-pro/openapi"],
|
|
166
153
|
"@stackwright-pro/auth": PRO_VERSIONS["@stackwright-pro/auth"],
|
|
167
154
|
"@stackwright-pro/auth-nextjs": PRO_VERSIONS["@stackwright-pro/auth-nextjs"],
|
|
168
|
-
|
|
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"
|
|
169
160
|
});
|
|
170
161
|
Object.assign(devDependencies, {
|
|
171
|
-
"@stoplight/prism-cli": "^5.
|
|
162
|
+
"@stoplight/prism-cli": "^5.15.10"
|
|
172
163
|
});
|
|
173
164
|
Object.assign(scripts, {
|
|
174
165
|
"dev:admin": "MOCK_USER=admin next dev",
|
|
@@ -182,6 +173,13 @@ async function addProDepsToPackageJson(targetDir) {
|
|
|
182
173
|
pkg.scripts = scripts;
|
|
183
174
|
await import_fs_extra.default.writeFile(pkgPath, JSON.stringify(pkg, null, 2) + "\n", "utf-8");
|
|
184
175
|
}
|
|
176
|
+
async function addAuthToStackwrightYml(targetDir) {
|
|
177
|
+
const ymlPath = import_path.default.join(targetDir, "stackwright.yml");
|
|
178
|
+
const content = await import_fs_extra.default.readFile(ymlPath, "utf-8");
|
|
179
|
+
const config = import_js_yaml.default.load(content, { schema: import_js_yaml.default.CORE_SCHEMA });
|
|
180
|
+
config.auth = {};
|
|
181
|
+
await import_fs_extra.default.writeFile(ymlPath, import_js_yaml.default.dump(config, { lineWidth: 120 }));
|
|
182
|
+
}
|
|
185
183
|
async function addIntegrationToStackwrightYml(targetDir, specName, specFilename, mockUrl) {
|
|
186
184
|
const ymlPath = import_path.default.join(targetDir, "stackwright.yml");
|
|
187
185
|
const content = await import_fs_extra.default.readFile(ymlPath, "utf-8");
|
|
@@ -195,20 +193,71 @@ async function addIntegrationToStackwrightYml(targetDir, specName, specFilename,
|
|
|
195
193
|
if (mockUrl) {
|
|
196
194
|
integration.mockUrl = mockUrl;
|
|
197
195
|
}
|
|
198
|
-
config.integrations = [
|
|
196
|
+
config.integrations = [
|
|
197
|
+
...Array.isArray(config.integrations) ? config.integrations : [],
|
|
198
|
+
integration
|
|
199
|
+
];
|
|
199
200
|
await import_fs_extra.default.writeFile(ymlPath, import_js_yaml.default.dump(config, { lineWidth: 120 }));
|
|
200
201
|
}
|
|
201
|
-
async function
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
|
|
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");
|
|
205
260
|
}
|
|
206
|
-
const specFilename = import_path.default.basename(resolvedSpec);
|
|
207
|
-
const derivedName = specName || import_path.default.basename(specFilename, import_path.default.extname(specFilename));
|
|
208
|
-
const specsDir = import_path.default.join(targetDir, "specs");
|
|
209
|
-
await import_fs_extra.default.ensureDir(specsDir);
|
|
210
|
-
await import_fs_extra.default.copy(resolvedSpec, import_path.default.join(specsDir, specFilename));
|
|
211
|
-
return { specFilename, derivedName };
|
|
212
261
|
}
|
|
213
262
|
function generateReadme(options) {
|
|
214
263
|
const { projectName, hasSpec, specName, specFilename, hasOtters, hasMock } = options;
|
|
@@ -231,7 +280,7 @@ export const EquipmentSchema = z.object({
|
|
|
231
280
|
export type Equipment = z.infer<typeof EquipmentSchema>;
|
|
232
281
|
|
|
233
282
|
// src/generated/${specName}/client.ts
|
|
234
|
-
export class ${specName.charAt(0).toUpperCase() + specName.slice(1)}Client {
|
|
283
|
+
export class ${(specName ?? "api").charAt(0).toUpperCase() + (specName ?? "api").slice(1)}Client {
|
|
235
284
|
async getEquipment(id: string): Promise<Equipment> {
|
|
236
285
|
// Auto-wired with auth, validation, error handling
|
|
237
286
|
}
|
|
@@ -244,10 +293,10 @@ export class ${specName.charAt(0).toUpperCase() + specName.slice(1)}Client {
|
|
|
244
293
|
3. You import and use it:
|
|
245
294
|
|
|
246
295
|
\`\`\`typescript
|
|
247
|
-
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';
|
|
248
297
|
import type { Equipment } from '@/generated/${specName}/types';
|
|
249
298
|
|
|
250
|
-
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();
|
|
251
300
|
const gear: Equipment = await client.getEquipment('123');
|
|
252
301
|
\`\`\`
|
|
253
302
|
|
|
@@ -283,12 +332,10 @@ Your project includes **SIX specialized AI agents** in \`node_modules/@stackwrig
|
|
|
283
332
|
**Start the otter raft:**
|
|
284
333
|
|
|
285
334
|
\`\`\`bash
|
|
286
|
-
|
|
335
|
+
npx @stackwright-pro/raft
|
|
287
336
|
\`\`\`
|
|
288
337
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
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.
|
|
292
339
|
|
|
293
340
|
**Example session prompt:**
|
|
294
341
|
|
|
@@ -331,12 +378,16 @@ ${mockSection}## \u{1F4C1} Project Structure
|
|
|
331
378
|
|
|
332
379
|
\`\`\`
|
|
333
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
|
|
334
389
|
\u251C\u2500\u2500 pages/
|
|
335
|
-
\u2502 \
|
|
336
|
-
\u2502 \u251C\u2500\u2500 index.tsx # Home page (auto-generated by Stackwright)
|
|
337
|
-
\u2502 \u251C\u2500\u2500 about/
|
|
338
|
-
\u2502 \u2502 \u2514\u2500\u2500 content.yml # Page content in YAML
|
|
339
|
-
\u2502 \u2514\u2500\u2500 ...
|
|
390
|
+
\u2502 \u2514\u2500\u2500 content.yml # Root page content in YAML
|
|
340
391
|
\u251C\u2500\u2500 lib/
|
|
341
392
|
\u2502 \u2514\u2500\u2500 mock-auth.ts # Dev-only auth mocking (no backend needed)
|
|
342
393
|
\u251C\u2500\u2500 scripts/
|
|
@@ -356,7 +407,7 @@ ${mockSection}## \u{1F4C1} Project Structure
|
|
|
356
407
|
\`\`\`
|
|
357
408
|
|
|
358
409
|
**Key Files:**
|
|
359
|
-
- \`
|
|
410
|
+
- \`app/_components/providers.tsx\` - Wraps your app with \`AuthProvider\` for RBAC
|
|
360
411
|
- \`stackwright.yml\` - Single source of truth for theme, auth roles, and API wiring
|
|
361
412
|
- \`lib/mock-auth.ts\` - Mocks CAC/PIV headers locally so you can test auth flows
|
|
362
413
|
- \`scripts/prebuild.js\` - Runs before dev/build to generate types from your OpenAPI spec
|
|
@@ -466,8 +517,28 @@ ${aiAgentsSection}## \u{1F4DA} Learn More
|
|
|
466
517
|
**Questions?** File an issue or ping us in the discussions. We're here to help you ship faster.
|
|
467
518
|
`;
|
|
468
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
|
+
}
|
|
469
540
|
async function launch(targetDir, options) {
|
|
470
|
-
const dirName =
|
|
541
|
+
const dirName = import_path2.default.basename(targetDir);
|
|
471
542
|
console.log(import_chalk.default.cyan.bold("\n\u{1F6A2} Launching Stackwright Pro...\n"));
|
|
472
543
|
const scaffoldOpts = {
|
|
473
544
|
name: options.name || dirName,
|
|
@@ -483,11 +554,11 @@ async function launch(targetDir, options) {
|
|
|
483
554
|
await addProDepsToPackageJson(targetDir);
|
|
484
555
|
console.log(import_chalk.default.green("\u{1F9A6} Pro packages added to package.json"));
|
|
485
556
|
const verifyPkg = JSON.parse(
|
|
486
|
-
await
|
|
557
|
+
await import_fs_extra2.default.readFile(import_path2.default.join(targetDir, "package.json"), "utf-8")
|
|
487
558
|
);
|
|
488
|
-
const proDepCount = Object.keys(
|
|
489
|
-
|
|
490
|
-
).length;
|
|
559
|
+
const proDepCount = Object.keys(
|
|
560
|
+
typeof verifyPkg.dependencies === "object" && verifyPkg.dependencies !== null ? verifyPkg.dependencies : {}
|
|
561
|
+
).filter((k) => k.startsWith("@stackwright-pro")).length;
|
|
491
562
|
console.log(import_chalk.default.dim(` \u2192 package.json verified: ${proDepCount} @stackwright-pro/* deps ready`));
|
|
492
563
|
console.log(import_chalk.default.cyan("\n\u{1F4E6} Installing dependencies (this takes a moment)..."));
|
|
493
564
|
if (!options.skipInstall) {
|
|
@@ -522,33 +593,42 @@ async function launch(targetDir, options) {
|
|
|
522
593
|
const dependencyMode = "standalone";
|
|
523
594
|
await (0, import_scaffold_core.runScaffoldHooks)("postInstall", {
|
|
524
595
|
targetDir,
|
|
525
|
-
projectName: options.name ||
|
|
526
|
-
siteTitle: options.title || options.name ||
|
|
596
|
+
projectName: options.name || import_path2.default.basename(targetDir),
|
|
597
|
+
siteTitle: options.title || options.name || import_path2.default.basename(targetDir),
|
|
527
598
|
themeId: options.theme || "corporate",
|
|
528
599
|
packageJson: {},
|
|
529
600
|
dependencyMode
|
|
530
601
|
});
|
|
531
|
-
await copyProTemplate(
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
await copyProTemplate("
|
|
536
|
-
await copyProTemplate("
|
|
537
|
-
await
|
|
538
|
-
await copyProTemplate("
|
|
539
|
-
|
|
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)"));
|
|
540
618
|
await addAuthToStackwrightYml(targetDir);
|
|
541
619
|
let specInfo = null;
|
|
542
620
|
const MOCK_URL = "http://localhost:4010";
|
|
543
|
-
if (options.spec) {
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
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`));
|
|
552
632
|
if (options.mock) {
|
|
553
633
|
console.log(import_chalk.default.green("\u{1F3AD} Prism mock server configured"));
|
|
554
634
|
}
|
|
@@ -558,9 +638,9 @@ async function launch(targetDir, options) {
|
|
|
558
638
|
"\u26A0\uFE0F No spec provided with --mock. Using sample Petstore spec for demo. Replace with your API spec."
|
|
559
639
|
)
|
|
560
640
|
);
|
|
561
|
-
const specsDir =
|
|
562
|
-
await
|
|
563
|
-
await copyProTemplate("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"));
|
|
564
644
|
specInfo = { specFilename: "petstore.yaml", derivedName: "petstore" };
|
|
565
645
|
await addIntegrationToStackwrightYml(
|
|
566
646
|
targetDir,
|
|
@@ -579,13 +659,33 @@ async function launch(targetDir, options) {
|
|
|
579
659
|
hasOtters: !options.skipOtters,
|
|
580
660
|
hasMock: !!options.mock
|
|
581
661
|
});
|
|
582
|
-
await
|
|
662
|
+
await import_fs_extra2.default.writeFile(import_path2.default.join(targetDir, "README.md"), readmeContent);
|
|
583
663
|
console.log(import_chalk.default.green("\u{1F4C4} README.md created"));
|
|
584
|
-
const
|
|
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) || ".";
|
|
585
685
|
console.log(import_chalk.default.cyan.bold("\n\u{1F389} All set! Here's what to do next:\n"));
|
|
586
686
|
console.log(import_chalk.default.white(` 1. cd ${relDir}`));
|
|
587
|
-
console.log(import_chalk.default.white(" 2.
|
|
588
|
-
console.log(import_chalk.default.dim(" (
|
|
687
|
+
console.log(import_chalk.default.white(" 2. npx @stackwright-pro/raft"));
|
|
688
|
+
console.log(import_chalk.default.dim(" (use --verbose for troubleshooting)"));
|
|
589
689
|
if (specInfo) {
|
|
590
690
|
console.log(import_chalk.default.cyan(`
|
|
591
691
|
\u{1F4E1} Your API spec was copied to specs/${specInfo.specFilename}`));
|
|
@@ -603,8 +703,8 @@ async function launch(targetDir, options) {
|
|
|
603
703
|
async function main() {
|
|
604
704
|
const program = new import_commander.Command();
|
|
605
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(
|
|
606
|
-
"--spec <
|
|
607
|
-
"
|
|
706
|
+
"--spec <paths...>",
|
|
707
|
+
"Paths to OpenAPI specs (YAML or JSON) \u2014 copies into project and wires up integrations (can be specified multiple times)"
|
|
608
708
|
).option(
|
|
609
709
|
"--spec-name <name>",
|
|
610
710
|
"Name for the API integration (default: derived from spec filename)"
|
|
@@ -613,8 +713,8 @@ async function main() {
|
|
|
613
713
|
"Skip automatic pnpm install (useful in CI or when using a different package manager)"
|
|
614
714
|
).action(async (directory, options) => {
|
|
615
715
|
const homeDir = import_os.default.homedir();
|
|
616
|
-
const targetDir =
|
|
617
|
-
if (!targetDir.startsWith(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) {
|
|
618
718
|
console.warn(import_chalk.default.yellow(`\u26A0\uFE0F Scaffolding outside your home directory: ${targetDir}`));
|
|
619
719
|
}
|
|
620
720
|
await launch(targetDir, options);
|