@specdest/devkit 0.2.2 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/README.md +17 -18
  2. package/package.json +4 -4
  3. package/src/canonical-project-operations.js +164 -0
  4. package/src/canonical-project.js +78 -0
  5. package/src/canonical-source.js +114 -0
  6. package/src/cli.js +2 -2
  7. package/src/git-catalog.js +105 -0
  8. package/src/index.js +6 -2
  9. package/src/project-operations.js +65 -6
  10. package/src/remote-installer.js +478 -0
  11. package/src/sync-core.js +20 -7
  12. package/catalog/README.md +0 -11
  13. package/catalog/modules/backend-convex/manifest.json +0 -14
  14. package/catalog/modules/backend-convex-expo/manifest.json +0 -11
  15. package/catalog/modules/backend-supabase/manifest.json +0 -15
  16. package/catalog/modules/backend-supabase-expo/manifest.json +0 -11
  17. package/catalog/modules/checker-runtime/config.ts +0 -25
  18. package/catalog/modules/checker-runtime/fs.ts +0 -48
  19. package/catalog/modules/checker-runtime/manifest.json +0 -29
  20. package/catalog/modules/checker-runtime/runtime.ts +0 -79
  21. package/catalog/modules/devflow/.agents/skills/devflow/SKILL.md +0 -33
  22. package/catalog/modules/devflow/.devflow.json +0 -10
  23. package/catalog/modules/devflow/manifest.json +0 -35
  24. package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/SKILL.md +0 -85
  25. package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/activeScenario.mjs +0 -130
  26. package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/checkLocalEnvironment.mjs +0 -7
  27. package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/completeActiveScenario.mjs +0 -36
  28. package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/createActiveScenario.mjs +0 -143
  29. package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/localEnvironment.mjs +0 -43
  30. package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/prompt.mjs +0 -25
  31. package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/runActiveScenario.mjs +0 -66
  32. package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/runAuthoringScenario.mjs +0 -146
  33. package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/seed.mjs +0 -56
  34. package/catalog/modules/e2e-playwright/.agents/skills/e2e-playwright/scripts/seedActiveScenario.mjs +0 -6
  35. package/catalog/modules/e2e-playwright/docs/e2e-playwright/README.md +0 -103
  36. package/catalog/modules/e2e-playwright/manifest.json +0 -206
  37. package/catalog/modules/e2e-playwright/playwright.e2e.config.ts +0 -39
  38. package/catalog/modules/e2e-playwright/tests/e2e/support/e2ePlaywrightFlow.ts +0 -107
  39. package/catalog/modules/e2e-playwright/tests/e2e/support/fixtures.ts +0 -27
  40. package/catalog/modules/local-log/AGENTS.local-log.md +0 -13
  41. package/catalog/modules/local-log/docs/features/local-logging/README.md +0 -70
  42. package/catalog/modules/local-log/manifest.json +0 -39
  43. package/catalog/modules/local-log/tmp/logs/.gitignore +0 -2
  44. package/catalog/modules/local-log/tools/local-log/README.md +0 -47
  45. package/catalog/modules/local-log/tools/local-log/local-log.mjs +0 -241
  46. package/catalog/modules/stack-common-vite/manifest.json +0 -16
  47. package/catalog/modules/stack-expo-convex/manifest.json +0 -31
  48. package/catalog/modules/stack-expo-supabase/manifest.json +0 -44
  49. package/catalog/modules/stack-vite-convex/manifest.json +0 -32
  50. package/catalog/modules/stack-vite-supabase/manifest.json +0 -45
  51. package/catalog/rules/abac-permissions-convex/SKILL.md +0 -17
  52. package/catalog/rules/abac-permissions-convex/check.ts +0 -87
  53. package/catalog/rules/abac-permissions-convex/manifest.json +0 -33
  54. package/catalog/rules/abac-permissions-supabase/SKILL.md +0 -17
  55. package/catalog/rules/abac-permissions-supabase/check.ts +0 -87
  56. package/catalog/rules/abac-permissions-supabase/manifest.json +0 -33
  57. package/catalog/rules/convex-multi-presentation/SKILL.md +0 -47
  58. package/catalog/rules/convex-multi-presentation/check.ts +0 -205
  59. package/catalog/rules/convex-multi-presentation/manifest.json +0 -47
  60. package/catalog/rules/convex-multi-presentation/policy.ts +0 -261
  61. package/catalog/rules/design-rules/SKILL.md +0 -12
  62. package/catalog/rules/design-rules/check.ts +0 -84
  63. package/catalog/rules/design-rules/config.json +0 -5
  64. package/catalog/rules/design-rules/manifest.json +0 -38
  65. package/catalog/rules/e2e-test-rules/SKILL.md +0 -46
  66. package/catalog/rules/e2e-test-rules/check.ts +0 -145
  67. package/catalog/rules/e2e-test-rules/config.json +0 -32
  68. package/catalog/rules/e2e-test-rules/manifest.json +0 -38
  69. package/catalog/rules/error-handling-rules/SKILL.md +0 -21
  70. package/catalog/rules/error-handling-rules/check.ts +0 -73
  71. package/catalog/rules/error-handling-rules/manifest.json +0 -33
  72. package/catalog/rules/layers-and-contracts/SKILL.md +0 -36
  73. package/catalog/rules/layers-and-contracts/check.ts +0 -266
  74. package/catalog/rules/layers-and-contracts/manifest.json +0 -33
  75. package/catalog/rules/layers-and-contracts-convex/SKILL.md +0 -49
  76. package/catalog/rules/layers-and-contracts-convex/check.ts +0 -289
  77. package/catalog/rules/layers-and-contracts-convex/manifest.json +0 -38
  78. package/catalog/rules/layers-and-contracts-convex/policy.ts +0 -68
  79. package/catalog/rules/layers-and-contracts-supabase/SKILL.md +0 -52
  80. package/catalog/rules/layers-and-contracts-supabase/check.ts +0 -371
  81. package/catalog/rules/layers-and-contracts-supabase/manifest.json +0 -38
  82. package/catalog/rules/layers-and-contracts-supabase/policy.ts +0 -68
  83. package/catalog/rules/module-size-rules/SKILL.md +0 -5
  84. package/catalog/rules/module-size-rules/check.ts +0 -144
  85. package/catalog/rules/module-size-rules/config.json +0 -6
  86. package/catalog/rules/module-size-rules/manifest.json +0 -38
  87. package/catalog/rules/module-size-rules-convex/SKILL.md +0 -5
  88. package/catalog/rules/module-size-rules-convex/check.ts +0 -146
  89. package/catalog/rules/module-size-rules-convex/config.json +0 -6
  90. package/catalog/rules/module-size-rules-convex/manifest.json +0 -38
  91. package/catalog/rules/module-size-rules-supabase/SKILL.md +0 -5
  92. package/catalog/rules/module-size-rules-supabase/check.ts +0 -146
  93. package/catalog/rules/module-size-rules-supabase/config.json +0 -12
  94. package/catalog/rules/module-size-rules-supabase/manifest.json +0 -38
  95. package/catalog/rules/mutation-command-rules/SKILL.md +0 -15
  96. package/catalog/rules/mutation-command-rules/check.ts +0 -30
  97. package/catalog/rules/mutation-command-rules/config.json +0 -19
  98. package/catalog/rules/mutation-command-rules/manifest.json +0 -38
  99. package/catalog/rules/nearby-contracts/SKILL.md +0 -18
  100. package/catalog/rules/nearby-contracts/check.ts +0 -138
  101. package/catalog/rules/nearby-contracts/config.json +0 -10
  102. package/catalog/rules/nearby-contracts/manifest.json +0 -38
  103. package/catalog/rules/no-raw-click-buttons/SKILL.md +0 -5
  104. package/catalog/rules/no-raw-click-buttons/check.ts +0 -37
  105. package/catalog/rules/no-raw-click-buttons/manifest.json +0 -33
  106. package/catalog/rules/public-api-export-barrels/SKILL.md +0 -45
  107. package/catalog/rules/public-api-export-barrels/check.ts +0 -73
  108. package/catalog/rules/public-api-export-barrels/config.json +0 -4
  109. package/catalog/rules/public-api-export-barrels/manifest.json +0 -38
  110. package/catalog/rules/route-tree-fresh/SKILL.md +0 -16
  111. package/catalog/rules/route-tree-fresh/check.ts +0 -66
  112. package/catalog/rules/route-tree-fresh/manifest.json +0 -33
  113. package/catalog/rules/strict-typescript/SKILL.md +0 -3
  114. package/catalog/rules/strict-typescript/check.ts +0 -119
  115. package/catalog/rules/strict-typescript/manifest.json +0 -33
  116. package/catalog/rules/supabase-contracts/SKILL.md +0 -3
  117. package/catalog/rules/supabase-contracts/check.ts +0 -172
  118. package/catalog/rules/supabase-contracts/manifest.json +0 -33
  119. package/catalog/rules/supabase-declarative-schema/SKILL.md +0 -30
  120. package/catalog/rules/supabase-declarative-schema/check.ts +0 -262
  121. package/catalog/rules/supabase-declarative-schema/config.json +0 -8
  122. package/catalog/rules/supabase-declarative-schema/manifest.json +0 -38
  123. package/catalog/rules/tanstack-form-rules/SKILL.md +0 -11
  124. package/catalog/rules/tanstack-form-rules/check.ts +0 -58
  125. package/catalog/rules/tanstack-form-rules/manifest.json +0 -33
  126. package/catalog/rules/unit-test-rules/SKILL.md +0 -55
  127. package/catalog/rules/unit-test-rules/check.ts +0 -132
  128. package/catalog/rules/unit-test-rules/config.json +0 -22
  129. package/catalog/rules/unit-test-rules/manifest.json +0 -38
  130. package/catalog/rules/unit-test-rules-convex/SKILL.md +0 -41
  131. package/catalog/rules/unit-test-rules-convex/check.ts +0 -418
  132. package/catalog/rules/unit-test-rules-convex/manifest.json +0 -33
  133. package/catalog/rules/unit-test-rules-supabase/SKILL.md +0 -40
  134. package/catalog/rules/unit-test-rules-supabase/check.ts +0 -492
  135. package/catalog/rules/unit-test-rules-supabase/manifest.json +0 -33
  136. package/catalog/rules/workstation-controller-rules/SKILL.md +0 -22
  137. package/catalog/rules/workstation-controller-rules/check.ts +0 -108
  138. package/catalog/rules/workstation-controller-rules/manifest.json +0 -33
@@ -1,143 +0,0 @@
1
- import { existsSync } from "node:fs";
2
- import {
3
- activeScenariosRoot,
4
- completedScenariosRoot,
5
- defaultStartPath,
6
- ensureScenarioDirectories,
7
- getCliArg,
8
- getOptionalActiveScenario,
9
- scenarioPaths,
10
- toRepoRelative,
11
- toScenarioId,
12
- writeIfMissing,
13
- } from "./activeScenario.mjs";
14
- import { promptText } from "./prompt.mjs";
15
-
16
- const rawScenarioId =
17
- getCliArg() ??
18
- process.env.E2E_PLAYWRIGHT_SCENARIO_ID ??
19
- (await promptText({ label: "Active E2E scenario id", required: true }));
20
-
21
- const existing = await getOptionalActiveScenario();
22
- if (existing) {
23
- console.log(`Active E2E scenario already exists: ${toRepoRelative(existing.root)}`);
24
- console.log("Finish or remove that scenario before creating another one.");
25
- process.exit(0);
26
- }
27
-
28
- const id = toScenarioId(rawScenarioId);
29
- const paths = scenarioPaths(id, activeScenariosRoot);
30
- const completedPath = scenarioPaths(id, completedScenariosRoot).root;
31
-
32
- if (existsSync(completedPath)) {
33
- console.error(`Completed scenario already exists: ${toRepoRelative(completedPath)}`);
34
- process.exit(2);
35
- }
36
-
37
- await ensureScenarioDirectories(paths);
38
-
39
- await writeIfMissing(paths.intentPath, intentTemplate(id));
40
- await writeIfMissing(paths.authoringPath, authoringTemplate(id));
41
- await writeIfMissing(paths.startUrlPath, `${defaultStartPath}\n`);
42
- await writeIfMissing(paths.seedPath, seedTemplate());
43
- await writeIfMissing(paths.flowScriptPath, flowScriptTemplate());
44
- await writeIfMissing(paths.specPath, specTemplate(id));
45
- await writeIfMissing(`${paths.artifactsDir}/.gitkeep`, "");
46
-
47
- console.log(`Created active E2E scenario: ${toRepoRelative(paths.root)}`);
48
- console.log("Next: fill intent.md, seed.mjs, and flow.script.ts, then run authoring mode.");
49
-
50
- function intentTemplate(scenarioId) {
51
- return [
52
- `# ${scenarioId}`,
53
- "",
54
- "## Rough user intent",
55
- "",
56
- "Describe the user-facing behavior this E2E scenario must prove.",
57
- "",
58
- "## Deterministic starting data",
59
- "",
60
- "List the scenario-owned data that seed.mjs must create/reset.",
61
- "",
62
- "## Expected final behavior",
63
- "",
64
- "Describe the visible UI results and any expected data changes.",
65
- "",
66
- ].join("\n");
67
- }
68
-
69
- function authoringTemplate(scenarioId) {
70
- return [
71
- `# ${scenarioId} authoring log`,
72
- "",
73
- "Use this while authoring the flow step by step.",
74
- "",
75
- "## Loop",
76
- "",
77
- "1. Read app code and identify route, labels, and user actions.",
78
- "2. Write or update one/few flow steps.",
79
- "3. Run authoring mode with --until or --pause-after.",
80
- "4. Observe UI state and errors.",
81
- "5. Update flow.script.ts.",
82
- "6. Remove exploratory/noise steps.",
83
- "7. Verify from clean seed and step 0.",
84
- "",
85
- ].join("\n");
86
- }
87
-
88
- function seedTemplate() {
89
- return [
90
- "export async function seedScenario({ projectRoot, scenario, now, executeCommand }) {",
91
- " // Keep this deterministic and idempotent.",
92
- " // Use project-owned local seed scripts or local DB tooling here.",
93
- " // Do not touch production services.",
94
- " //",
95
- " // Example:",
96
- ' // await executeCommand("node", ["scripts/seed-e2e.mjs", scenario.id], { cwd: projectRoot });',
97
- "",
98
- " void projectRoot;",
99
- " void scenario;",
100
- " void now;",
101
- " void executeCommand;",
102
- "}",
103
- "",
104
- "export async function verifySeed({ scenario }) {",
105
- " // Optional: assert seeded records exist before the browser flow starts.",
106
- " void scenario;",
107
- "}",
108
- "",
109
- ].join("\n");
110
- }
111
-
112
- function flowScriptTemplate() {
113
- return [
114
- 'import { expect } from "@playwright/test";',
115
- 'import { step, type E2EPlaywrightFlow } from "../../support/e2ePlaywrightFlow";',
116
- "",
117
- "export const flow = [",
118
- ' step("open start page", async ({ page }) => {',
119
- ` await page.goto("${defaultStartPath}");`,
120
- " }),",
121
- "",
122
- ' step("assert page loaded", async ({ page }) => {',
123
- ' await expect(page.locator("body")).toBeVisible();',
124
- " }),",
125
- "] satisfies E2EPlaywrightFlow;",
126
- "",
127
- ].join("\n");
128
- }
129
-
130
- function specTemplate(scenarioId) {
131
- return [
132
- 'import { test } from "../../../support/fixtures";',
133
- 'import { e2ePlaywrightFlowOptionsFromEnv, runE2EPlaywrightFlow } from "../../../support/e2ePlaywrightFlow";',
134
- 'import { flow } from "../flow.script";',
135
- "",
136
- `test.describe("${scenarioId}", () => {`,
137
- ' test("runs the E2E flow", async ({ context, page }, testInfo) => {',
138
- " await runE2EPlaywrightFlow(flow, { context, page, testInfo }, e2ePlaywrightFlowOptionsFromEnv());",
139
- " });",
140
- "});",
141
- "",
142
- ].join("\n");
143
- }
@@ -1,43 +0,0 @@
1
- export async function assertLocalEnvironment(input = {}) {
2
- if (process.env.APP_ENV === "production") {
3
- throw new Error("Refusing E2E Playwright run with APP_ENV=production.");
4
- }
5
- if (process.env.NODE_ENV === "production") {
6
- throw new Error("Refusing E2E Playwright run with NODE_ENV=production.");
7
- }
8
-
9
- const baseUrl = process.env.E2E_BASE_URL ?? "http://127.0.0.1:5173";
10
- assertLocalUrl(baseUrl, "E2E_BASE_URL");
11
-
12
- if (input.requireFrontend ?? false) await assertReachable(baseUrl, "local frontend");
13
-
14
- return { baseUrl };
15
- }
16
-
17
- export function assertLocalUrl(rawUrl, label) {
18
- const url = new URL(rawUrl, "http://127.0.0.1:5173");
19
- const allowedHosts = new Set(["127.0.0.1", "localhost", "::1", "[::1]"]);
20
- if (!allowedHosts.has(url.hostname)) {
21
- throw new Error(`${label} must be local. Refusing URL: ${url.toString()}`);
22
- }
23
- return url;
24
- }
25
-
26
- async function assertReachable(url, label) {
27
- try {
28
- const response = await fetch(url, { method: "HEAD" });
29
- if (response.status < 500) return;
30
- } catch {
31
- // Some local apps reject HEAD. Retry with GET before failing.
32
- }
33
-
34
- try {
35
- const response = await fetch(url, { method: "GET" });
36
- if (response.status < 500) return;
37
- throw new Error(`HTTP ${response.status}`);
38
- } catch (error) {
39
- throw new Error(
40
- `${label} is not reachable at ${url}. Start the local app and retry. ${error instanceof Error ? error.message : String(error)}`,
41
- );
42
- }
43
- }
@@ -1,25 +0,0 @@
1
- import { stdin as input, stdout as output } from "node:process";
2
- import { createInterface } from "node:readline/promises";
3
-
4
- export async function promptText(inputConfig) {
5
- if (!process.stdin.isTTY) {
6
- if (inputConfig.defaultValue !== undefined) return inputConfig.defaultValue;
7
- if (inputConfig.required) throw new Error(`Missing required input: ${inputConfig.label}`);
8
- return "";
9
- }
10
-
11
- const prompt = inputConfig.defaultValue
12
- ? `${inputConfig.label} [${inputConfig.defaultValue}]: `
13
- : `${inputConfig.label}: `;
14
- const readline = createInterface({ input, output });
15
-
16
- try {
17
- const value = (await readline.question(prompt)).trim();
18
- const resolved = value || inputConfig.defaultValue || "";
19
- if (inputConfig.required && !resolved)
20
- throw new Error(`Missing required input: ${inputConfig.label}`);
21
- return resolved;
22
- } finally {
23
- readline.close();
24
- }
25
- }
@@ -1,66 +0,0 @@
1
- import { existsSync } from "node:fs";
2
- import { spawn } from "node:child_process";
3
- import path from "node:path";
4
- import { assertLocalEnvironment } from "./localEnvironment.mjs";
5
- import { seedScenario } from "./seed.mjs";
6
- import {
7
- getRequiredActiveScenario,
8
- repoRoot,
9
- requireFile,
10
- toRepoRelative,
11
- } from "./activeScenario.mjs";
12
-
13
- const scenario = await getRequiredActiveScenario();
14
-
15
- requireFile(
16
- scenario.seedPath,
17
- `Missing seed: ${toRepoRelative(scenario.seedPath)}. Create seed.mjs first.`,
18
- );
19
- requireFile(
20
- scenario.flowScriptPath,
21
- `Missing flow script: ${toRepoRelative(scenario.flowScriptPath)}. Create flow.script.ts first.`,
22
- );
23
-
24
- if (!existsSync(scenario.specPath)) {
25
- console.error(`Missing active scenario spec: ${toRepoRelative(scenario.specPath)}`);
26
- console.error("Create the spec before running the active scenario.");
27
- process.exit(2);
28
- }
29
-
30
- await assertLocalEnvironment({ requireFrontend: true });
31
-
32
- if (process.env.E2E_PLAYWRIGHT_SKIP_SEED !== "1") {
33
- console.log("Seeding active E2E scenario before run.");
34
- await seedScenario(scenario);
35
- }
36
-
37
- const playwrightBin = path.join(
38
- repoRoot,
39
- "node_modules",
40
- ".bin",
41
- process.platform === "win32" ? "playwright.cmd" : "playwright",
42
- );
43
- const specPath = toRepoRelative(scenario.specPath);
44
- const args = ["test", "--config", "playwright.e2e.config.ts", specPath];
45
-
46
- console.log(`Running active E2E scenario: ${scenario.id}`);
47
- console.log(`Spec: ${specPath}`);
48
- console.log("Using local Playwright. No backend mocking is installed by this template.");
49
- console.log("");
50
-
51
- const child = spawn(playwrightBin, args, {
52
- cwd: repoRoot,
53
- env: {
54
- ...process.env,
55
- E2E_PLAYWRIGHT_ACTIVE_SCENARIO_ID: scenario.id,
56
- },
57
- stdio: "inherit",
58
- });
59
-
60
- child.on("exit", (code, signal) => {
61
- if (signal) {
62
- console.error(`Active E2E scenario runner exited by signal ${signal}`);
63
- process.exit(1);
64
- }
65
- process.exit(code ?? 1);
66
- });
@@ -1,146 +0,0 @@
1
- import { existsSync } from "node:fs";
2
- import { spawn } from "node:child_process";
3
- import path from "node:path";
4
- import { assertLocalEnvironment } from "./localEnvironment.mjs";
5
- import { seedScenario } from "./seed.mjs";
6
- import {
7
- getRequiredActiveScenario,
8
- repoRoot,
9
- requireFile,
10
- toRepoRelative,
11
- } from "./activeScenario.mjs";
12
-
13
- const scenario = await getRequiredActiveScenario();
14
- const options = parseOptions(process.argv.slice(2));
15
-
16
- requireFile(
17
- scenario.seedPath,
18
- `Missing seed: ${toRepoRelative(scenario.seedPath)}. Create seed.mjs first.`,
19
- );
20
- requireFile(
21
- scenario.flowScriptPath,
22
- `Missing flow script: ${toRepoRelative(scenario.flowScriptPath)}. Create flow.script.ts first.`,
23
- );
24
-
25
- if (!existsSync(scenario.specPath)) {
26
- console.error(`Missing active scenario spec: ${toRepoRelative(scenario.specPath)}`);
27
- console.error("Create the spec before running authoring mode.");
28
- process.exit(2);
29
- }
30
-
31
- await assertLocalEnvironment({ requireFrontend: true });
32
-
33
- if (!options.skipSeed) {
34
- console.log("Seeding active E2E scenario before authoring run.");
35
- await seedScenario(scenario);
36
- }
37
-
38
- const playwrightBin = path.join(
39
- repoRoot,
40
- "node_modules",
41
- ".bin",
42
- process.platform === "win32" ? "playwright.cmd" : "playwright",
43
- );
44
- const specPath = toRepoRelative(scenario.specPath);
45
- const args = ["test", "--config", "playwright.e2e.config.ts", specPath];
46
-
47
- if (options.debug) args.push("--debug");
48
- else if (options.headed) args.push("--headed");
49
-
50
- console.log(`Running active E2E scenario in authoring mode: ${scenario.id}`);
51
- console.log(`Spec: ${specPath}`);
52
- if (options.until) console.log(`Until step: ${options.until}`);
53
- if (options.pauseAfter) console.log(`Pause after step: ${options.pauseAfter}`);
54
- console.log("Using local Playwright. No backend mocking is installed by this template.");
55
- console.log("");
56
-
57
- const child = spawn(playwrightBin, args, {
58
- cwd: repoRoot,
59
- env: {
60
- ...process.env,
61
- E2E_PLAYWRIGHT_ACTIVE_SCENARIO_ID: scenario.id,
62
- E2E_PLAYWRIGHT_TRACE_STEPS: "1",
63
- E2E_PLAYWRIGHT_UNTIL_STEP: options.until ?? "",
64
- E2E_PLAYWRIGHT_PAUSE_AFTER_STEP: options.pauseAfter ?? "",
65
- },
66
- stdio: "inherit",
67
- });
68
-
69
- child.on("exit", (code, signal) => {
70
- if (signal) {
71
- console.error(`Active E2E authoring runner exited by signal ${signal}`);
72
- process.exit(1);
73
- }
74
- process.exit(code ?? 1);
75
- });
76
-
77
- function parseOptions(args) {
78
- let until;
79
- let pauseAfter;
80
- let debug = false;
81
- let headed = true;
82
- let skipSeed = process.env.E2E_PLAYWRIGHT_SKIP_SEED === "1";
83
-
84
- for (let index = 0; index < args.length; index += 1) {
85
- const arg = args[index];
86
- if (!arg || arg === "--") continue;
87
-
88
- if (arg === "--until") {
89
- const parsed = readValueArgs(args, index, arg);
90
- until = parsed.value;
91
- index = parsed.nextIndex;
92
- continue;
93
- }
94
- if (arg.startsWith("--until=")) {
95
- until = arg.slice("--until=".length);
96
- continue;
97
- }
98
- if (arg === "--pause-after") {
99
- const parsed = readValueArgs(args, index, arg);
100
- pauseAfter = parsed.value;
101
- debug = true;
102
- index = parsed.nextIndex;
103
- continue;
104
- }
105
- if (arg.startsWith("--pause-after=")) {
106
- pauseAfter = arg.slice("--pause-after=".length);
107
- debug = true;
108
- continue;
109
- }
110
- if (arg === "--debug") {
111
- debug = true;
112
- continue;
113
- }
114
- if (arg === "--headed") {
115
- headed = true;
116
- continue;
117
- }
118
- if (arg === "--headless") {
119
- headed = false;
120
- continue;
121
- }
122
- if (arg === "--skip-seed") {
123
- skipSeed = true;
124
- continue;
125
- }
126
-
127
- throw new Error(`Unknown authoring option: ${arg}`);
128
- }
129
-
130
- return { until, pauseAfter, debug, headed, skipSeed };
131
- }
132
-
133
- function readValueArgs(args, index, flag) {
134
- const values = [];
135
- let cursor = index + 1;
136
-
137
- while (cursor < args.length) {
138
- const value = args[cursor];
139
- if (!value || value.startsWith("--")) break;
140
- values.push(value);
141
- cursor += 1;
142
- }
143
-
144
- if (values.length === 0) throw new Error(`${flag} requires a value.`);
145
- return { value: values.join(" "), nextIndex: cursor - 1 };
146
- }
@@ -1,56 +0,0 @@
1
- import { spawnSync } from "node:child_process";
2
- import { pathToFileURL } from "node:url";
3
- import { assertLocalEnvironment } from "./localEnvironment.mjs";
4
- import { getRequiredActiveScenario, repoRoot, toRepoRelative } from "./activeScenario.mjs";
5
-
6
- export async function seedScenario(scenario) {
7
- await assertLocalEnvironment({ requireFrontend: false });
8
- const moduleUrl = pathToFileURL(scenario.seedPath).href;
9
- const seedModule = await import(moduleUrl);
10
-
11
- if (typeof seedModule.seedScenario !== "function") {
12
- throw new Error(`${toRepoRelative(scenario.seedPath)} must export seedScenario(context).`);
13
- }
14
-
15
- const context = {
16
- projectRoot: repoRoot,
17
- scenario,
18
- now: new Date("2030-01-01T00:00:00.000Z").toISOString(),
19
- env: { ...process.env },
20
- executeCommand,
21
- };
22
-
23
- await seedModule.seedScenario(context);
24
- if (typeof seedModule.verifySeed === "function") await seedModule.verifySeed(context);
25
- }
26
-
27
- export async function seedActiveScenario() {
28
- await seedScenario(await getRequiredActiveScenario());
29
- }
30
-
31
- async function executeCommand(command, args = [], options = {}) {
32
- const result = spawnSync(command, args, {
33
- cwd: options.cwd ?? repoRoot,
34
- encoding: "utf8",
35
- env: { ...process.env, ...(options.env ?? {}) },
36
- stdio: ["ignore", "pipe", "pipe"],
37
- maxBuffer: 1024 * 1024 * 32,
38
- });
39
-
40
- if (result.status === 0) {
41
- return {
42
- stdout: result.stdout ?? "",
43
- stderr: result.stderr ?? "",
44
- };
45
- }
46
-
47
- throw new Error(
48
- [
49
- `Command failed: ${command} ${args.join(" ")}`,
50
- result.stdout ? `stdout:\n${result.stdout}` : "",
51
- result.stderr ? `stderr:\n${result.stderr}` : "",
52
- ]
53
- .filter(Boolean)
54
- .join("\n"),
55
- );
56
- }
@@ -1,6 +0,0 @@
1
- import { seedActiveScenario } from "./seed.mjs";
2
- import { getRequiredActiveScenario, toRepoRelative } from "./activeScenario.mjs";
3
-
4
- const scenario = await getRequiredActiveScenario();
5
- await seedActiveScenario();
6
- console.log(`Seeded active E2E scenario: ${toRepoRelative(scenario.root)}`);
@@ -1,103 +0,0 @@
1
- # E2E Playwright
2
-
3
- This template installs a generic Playwright E2E authoring flow for Vite/web projects.
4
-
5
- ## Commands
6
-
7
- When the target project uses `package-scripts.yml` or `package-scripts.yaml`:
8
-
9
- ```bash
10
- nps "e2e.playwright.0CreateActiveScenario -- <scenario-id>"
11
- nps e2e.playwright.1CheckLocal
12
- nps e2e.playwright.2SeedActiveScenario
13
- nps e2e.playwright.5RunAuthoring
14
- nps "e2e.playwright.5RunAuthoring -- --until <step-name>"
15
- nps "e2e.playwright.5RunAuthoring -- --pause-after <step-name>"
16
- nps e2e.playwright.3RunActiveScenario
17
- nps "e2e.playwright.4CompleteActiveScenario -- <scenario-id>"
18
- ```
19
-
20
- Without package-scripts/NPS:
21
-
22
- ```bash
23
- npm run e2e:create -- <scenario-id>
24
- npm run e2e:check-local
25
- npm run e2e:seed
26
- npm run e2e:author
27
- npm run e2e:run
28
- npm run e2e:complete -- <scenario-id>
29
- ```
30
-
31
- ## Local service boundary
32
-
33
- The template only permits local browser targets:
34
-
35
- ```txt
36
- localhost
37
- 127.0.0.1
38
- ::1
39
- ```
40
-
41
- Set the app URL with:
42
-
43
- ```bash
44
- E2E_BASE_URL=http://127.0.0.1:5173
45
- ```
46
-
47
- Override the Playwright web server command with:
48
-
49
- ```bash
50
- E2E_WEB_SERVER_COMMAND="pnpm dev -- --host 127.0.0.1 --port 5173"
51
- ```
52
-
53
- Do not point this flow at production services.
54
-
55
- ## Scenario folders
56
-
57
- Active scenario:
58
-
59
- ```txt
60
- tests/e2e/_active/<scenario-id>/
61
- ```
62
-
63
- Completed scenario:
64
-
65
- ```txt
66
- tests/e2e/scenarios/<scenario-id>/
67
- ```
68
-
69
- Generated files:
70
-
71
- ```txt
72
- intent.md
73
- authoring.md
74
- start-url.txt
75
- seed.mjs
76
- flow.script.ts
77
- specs/<scenario-id>.spec.ts
78
- artifacts/
79
- ```
80
-
81
- ## Authoring loop
82
-
83
- ```txt
84
- 1. Write rough business intent in intent.md.
85
- 2. Add deterministic project-owned data setup in seed.mjs.
86
- 3. Write named Playwright steps in flow.script.ts.
87
- 4. Run authoring mode with --until or --pause-after.
88
- 5. Fix one step at a time.
89
- 6. Remove exploratory pauses/noise.
90
- 7. Run clean verification from seed and step 0.
91
- 8. Complete the scenario.
92
- ```
93
-
94
- ## Seed hook
95
-
96
- `seed.mjs` is intentionally project-specific. It receives:
97
-
98
- ```js
99
- export async function seedScenario({ projectRoot, scenario, now, executeCommand }) {}
100
- export async function verifySeed({ projectRoot, scenario, now, executeCommand }) {}
101
- ```
102
-
103
- Use this to call project-owned seed scripts, local database tools, or fixture setup commands. The template does not own database schema, auth, routes, or business data.