@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,11 +0,0 @@
1
- {
2
- "id": "backend-convex-expo",
3
- "kind": "module",
4
- "version": "1.0.0",
5
- "requires": [
6
- "abac-permissions-convex",
7
- "module-size-rules-convex"
8
- ],
9
- "artifacts": [],
10
- "obsolete": []
11
- }
@@ -1,15 +0,0 @@
1
- {
2
- "id": "backend-supabase",
3
- "kind": "module",
4
- "version": "1.0.0",
5
- "requires": [
6
- "abac-permissions-supabase",
7
- "layers-and-contracts-supabase",
8
- "module-size-rules-supabase",
9
- "supabase-contracts",
10
- "supabase-declarative-schema",
11
- "unit-test-rules-supabase"
12
- ],
13
- "artifacts": [],
14
- "obsolete": []
15
- }
@@ -1,11 +0,0 @@
1
- {
2
- "id": "backend-supabase-expo",
3
- "kind": "module",
4
- "version": "1.0.0",
5
- "requires": [
6
- "abac-permissions-supabase",
7
- "module-size-rules-supabase"
8
- ],
9
- "artifacts": [],
10
- "obsolete": []
11
- }
@@ -1,25 +0,0 @@
1
- import { runtime } from "./runtime.ts";
2
- // fallow-ignore-next-line complexity
3
- function configPathFromArgs(args: string[], defaultUrl: URL): string | URL {
4
- const configArgIndex = args.indexOf("--config");
5
- const configPath = configArgIndex >= 0 ? args[configArgIndex + 1] : null;
6
- if (configArgIndex >= 0 && !configPath) {
7
- throw new Error("--config requires a path");
8
- }
9
- return configPath ?? defaultUrl;
10
- }
11
-
12
- async function readConfig<T>(args: string[], defaultUrl: URL): Promise<T> {
13
- return JSON.parse(await runtime.readTextFile(configPathFromArgs(args, defaultUrl))) as T;
14
- }
15
-
16
- export async function readSkillConfig<T>(moduleUrl: string): Promise<{ config: T; root: string }> {
17
- return {
18
- config: await readConfig<T>(runtime.args, new URL("./config.json", moduleUrl)),
19
- root: runtime.cwd(),
20
- };
21
- }
22
-
23
- export function assertSchemaVersion(version: number): void {
24
- if (version !== 1) throw new Error("config.json schemaVersion must be 1");
25
- }
@@ -1,48 +0,0 @@
1
- import { runtime } from "./runtime.ts";
2
- export function normalizePath(value: string): string {
3
- return value.replaceAll("\\", "/").replace(/^\.\//, "");
4
- }
5
-
6
- function isIgnoredDirectory(relativePath: string, ignoredDirectories: Set<string>): boolean {
7
- const normalized = normalizePath(relativePath);
8
- if (!normalized) return false;
9
- return ignoredDirectories.has(normalized) || ignoredDirectories.has(normalized.split("/")[0]);
10
- }
11
-
12
- export async function exists(path: string): Promise<boolean> {
13
- try {
14
- await runtime.stat(path);
15
- return true;
16
- } catch (error) {
17
- if (error instanceof runtime.errors.NotFound) return false;
18
- throw error;
19
- }
20
- }
21
-
22
- // fallow-ignore-next-line complexity
23
- export async function walk(
24
- directory: string,
25
- options: { ignoredDirectories?: Set<string>; relativeDirectory?: string } = {},
26
- ): Promise<string[]> {
27
- const { ignoredDirectories = new Set<string>(), relativeDirectory = "" } = options;
28
- if (isIgnoredDirectory(relativeDirectory, ignoredDirectories) || !(await exists(directory)))
29
- return [];
30
- const entries: string[] = [];
31
- for await (const entry of runtime.readDir(directory)) {
32
- const relativePath = normalizePath(
33
- relativeDirectory ? `${relativeDirectory}/${entry.name}` : entry.name,
34
- );
35
- const absolutePath = `${directory}/${entry.name}`;
36
- if (entry.isDirectory) {
37
- entries.push(
38
- ...(await walk(absolutePath, {
39
- ignoredDirectories,
40
- relativeDirectory: relativePath,
41
- })),
42
- );
43
- continue;
44
- }
45
- if (entry.isFile) entries.push(relativePath);
46
- }
47
- return entries;
48
- }
@@ -1,29 +0,0 @@
1
- {
2
- "id": "checker-runtime",
3
- "kind": "module",
4
- "version": "2.0.1",
5
- "artifacts": [
6
- {
7
- "kind": "managed-file",
8
- "path": ".agents/skills/shared/runtime.ts",
9
- "source": "runtime.ts"
10
- },
11
- {
12
- "kind": "managed-file",
13
- "path": ".agents/skills/shared/fs.ts",
14
- "source": "fs.ts"
15
- },
16
- {
17
- "kind": "managed-file",
18
- "path": ".agents/skills/shared/config.ts",
19
- "source": "config.ts"
20
- }
21
- ],
22
- "obsolete": [
23
- {
24
- "kind": "shared-line",
25
- "path": ".gitignore",
26
- "line": ".specdest/checks.json"
27
- }
28
- ]
29
- }
@@ -1,79 +0,0 @@
1
- import { readFile as readFileNode, readdir, stat as statNode } from "node:fs/promises";
2
- import process from "node:process";
3
-
4
- export class NotFoundError extends Error {
5
- constructor(path: string) {
6
- super(`No such file or directory: ${path}`);
7
- this.name = "NotFoundError";
8
- }
9
- }
10
-
11
- function translateNotFound(error: unknown, path: string): never {
12
- if (
13
- error instanceof Error &&
14
- "code" in error &&
15
- (error as NodeJS.ErrnoException).code === "ENOENT"
16
- ) {
17
- throw new NotFoundError(path);
18
- }
19
- throw error;
20
- }
21
-
22
- async function stat(path: string) {
23
- try {
24
- return await statNode(path);
25
- } catch (error) {
26
- return translateNotFound(error, path);
27
- }
28
- }
29
-
30
- async function readFile(path: string | URL): Promise<Uint8Array> {
31
- try {
32
- return await readFileNode(path);
33
- } catch (error) {
34
- return translateNotFound(error, String(path));
35
- }
36
- }
37
-
38
- async function readTextFile(path: string | URL): Promise<string> {
39
- try {
40
- return await readFileNode(path, "utf8");
41
- } catch (error) {
42
- return translateNotFound(error, String(path));
43
- }
44
- }
45
-
46
- async function* readDir(path: string) {
47
- let entries;
48
- try {
49
- entries = await readdir(path, { withFileTypes: true });
50
- } catch (error) {
51
- return translateNotFound(error, path);
52
- }
53
- for (const entry of entries) {
54
- yield {
55
- name: entry.name,
56
- isFile: entry.isFile(),
57
- isDirectory: entry.isDirectory(),
58
- isSymlink: entry.isSymbolicLink(),
59
- };
60
- }
61
- }
62
-
63
- function writeSync(stream: NodeJS.WriteStream, data: Uint8Array): number {
64
- stream.write(data);
65
- return data.byteLength;
66
- }
67
-
68
- export const runtime = {
69
- args: process.argv.slice(2),
70
- cwd: () => process.cwd(),
71
- exit: (code = 0): never => process.exit(code),
72
- stat,
73
- readFile,
74
- readTextFile,
75
- readDir,
76
- stdout: { writeSync: (data: Uint8Array) => writeSync(process.stdout, data) },
77
- stderr: { writeSync: (data: Uint8Array) => writeSync(process.stderr, data) },
78
- errors: { NotFound: NotFoundError },
79
- } as const;
@@ -1,33 +0,0 @@
1
- ---
2
- name: devflow
3
- description: Guidance for using DevFlow task lifecycle prompts and artifacts.
4
- ---
5
-
6
- # DevFlow lifecycle prompts
7
-
8
- DevFlow manages project-local task state and generates the current coding prompt. It does not launch or control a coding agent.
9
-
10
- ## Workflow
11
-
12
- 1. Open the project in the Chrome extension and create a task.
13
- 2. Copy the current prompt into the coding agent of your choice.
14
- 3. Save only the artifact editable in the current state.
15
- 4. Submit and approve requirements and plan artifacts through the UI.
16
- 5. Use the TDD and implementation prompts manually.
17
- 6. Run fast checks only during TDD or implementation.
18
- 7. Run full validation only after entering `VALIDATION`.
19
- 8. Save the final report and complete the task.
20
-
21
- ## Artifact locking
22
-
23
- - `requirements.md` is editable only in `REQUIREMENTS`.
24
- - `plan.md` is editable only in `PLAN`.
25
- - `report.md`, `follow-ups.md`, and `learning.md` are editable only in `REPORT`.
26
- - `validation.json` is controller-owned and read-only.
27
- - Approval locks requirements or plan content. Rejection reopens the relevant artifact.
28
-
29
- Task workspaces are stored under `tasks/<task-id>/`. They are temporary but intentionally versioned while active. Keep lifecycle artifacts, metadata, event history, prompt overrides, follow-ups, learning notes, structured evidence, and useful Markdown notes. Raw files under `logs/` are local-only runtime output.
30
-
31
- Do not discard useful midpoint evidence merely because the workflow advanced. During report, write future improvements to `follow-ups.md`, reusable session learning to `learning.md`, and evidence summaries under `evidence/`. During documentation and completion, move durable knowledge into permanent project docs, decisions, rules, lessons, improvements, or testing gaps. Delete the task folder only after the task is completed and that transfer is recorded.
32
-
33
- Project validation commands are allowlisted in `.devflow.json` as argument arrays. Do not bypass approval gates, edit `state.json` manually, call the controller's `state-write` command directly, or treat generated prompts as ordinary saved prompts.
@@ -1,10 +0,0 @@
1
- {
2
- "schemaVersion": 1,
3
- "rulesFiles": [
4
- "AGENTS.md"
5
- ],
6
- "checks": {
7
- "fast": [],
8
- "full": []
9
- }
10
- }
@@ -1,35 +0,0 @@
1
- {
2
- "id": "devflow",
3
- "kind": "module",
4
- "version": "1.2.0",
5
- "artifacts": [
6
- {
7
- "kind": "managed-file",
8
- "path": ".agents/skills/devflow/SKILL.md",
9
- "source": ".agents/skills/devflow/SKILL.md"
10
- },
11
- {
12
- "kind": "scaffold",
13
- "path": ".devflow.json",
14
- "source": ".devflow.json"
15
- },
16
- {
17
- "kind": "shared-line",
18
- "path": ".gitignore",
19
- "line": "/tasks/*/logs/"
20
- },
21
- {
22
- "kind": "shared-markdown-section",
23
- "path": "AGENTS.md",
24
- "heading": "## DevFlow task lifecycle",
25
- "body": "Use `.agents/skills/devflow/SKILL.md` for DevFlow-managed tasks. Respect lifecycle states and approval gates. Keep task evidence versioned while active, ignore only raw `tasks/*/logs/`, promote durable knowledge before completion, and configure project validation in `.devflow.json`."
26
- }
27
- ],
28
- "obsolete": [
29
- {
30
- "kind": "shared-line",
31
- "path": ".gitignore",
32
- "line": "/tasks/"
33
- }
34
- ]
35
- }
@@ -1,85 +0,0 @@
1
- # E2E Playwright
2
-
3
- Use this skill when creating or maintaining generic Playwright E2E scenarios for a local web application.
4
-
5
- ## Goal
6
-
7
- Turn a rough user flow into a deterministic, repeatable Playwright test using project-owned seed data and named UI steps.
8
-
9
- ## Workflow
10
-
11
- ```txt
12
- 1. Create one active scenario.
13
- 2. Confirm the target app URL is local-only.
14
- 3. Fill intent.md with the business flow.
15
- 4. Implement seed.mjs with deterministic project-owned data setup.
16
- 5. Implement flow.script.ts with named Playwright steps.
17
- 6. Run authoring mode with --until or --pause-after.
18
- 7. Fix one step at a time.
19
- 8. Verify from seed and step 0.
20
- 9. Complete the scenario when stable.
21
- ```
22
-
23
- ## Commands
24
-
25
- ```bash
26
- nps "e2e.playwright.0CreateActiveScenario -- <scenario-id>"
27
- nps e2e.playwright.1CheckLocal
28
- nps e2e.playwright.2SeedActiveScenario
29
- nps e2e.playwright.5RunAuthoring
30
- nps "e2e.playwright.5RunAuthoring -- --until <step-name>"
31
- nps "e2e.playwright.5RunAuthoring -- --pause-after <step-name>"
32
- nps e2e.playwright.3RunActiveScenario
33
- nps "e2e.playwright.4CompleteActiveScenario -- <scenario-id>"
34
- ```
35
-
36
- Direct npm-script aliases may exist in projects without NPS/package-scripts.
37
-
38
- ## Scenario folders
39
-
40
- Active:
41
-
42
- ```txt
43
- tests/e2e/_active/<scenario-id>/
44
- ```
45
-
46
- Completed:
47
-
48
- ```txt
49
- tests/e2e/scenarios/<scenario-id>/
50
- ```
51
-
52
- Only one active scenario is allowed at a time.
53
-
54
- ## Local-only safety
55
-
56
- This skill must only use local app URLs:
57
-
58
- ```txt
59
- http://127.0.0.1:5173
60
- http://localhost:5173
61
- http://[::1]:5173
62
- ```
63
-
64
- Override with `E2E_BASE_URL`. The guard refuses non-local hosts and production `APP_ENV` / `NODE_ENV`.
65
-
66
- ## Seed rules
67
-
68
- - `seed.mjs` is project-owned and may call project seed scripts or local DB tools.
69
- - Keep seed deterministic and idempotent.
70
- - Delete/reset only scenario-owned data.
71
- - Do not connect to production services.
72
- - Export `verifySeed(context)` when the seed needs a pre-browser assertion.
73
-
74
- ## Flow script rules
75
-
76
- - `flow.script.ts` is the action recipe.
77
- - Use accessible locators first: role, label, placeholder, text.
78
- - Keep steps small and named.
79
- - Step names are used by `--until` and `--pause-after`.
80
- - Scope selectors to avoid strict-mode ambiguity.
81
- - Remove exploratory pauses before completing the scenario.
82
-
83
- ## Agent/controller boundary
84
-
85
- Agents may edit scenario files, inspect code, and reason about failures. Do not start long-running app servers or Playwright browser runs from tooling/controller unless the user explicitly accepts that execution boundary. Prefer user terminal for app servers and final browser verification.
@@ -1,130 +0,0 @@
1
- import { existsSync } from "node:fs";
2
- import { mkdir, readdir, readFile, rename, writeFile } from "node:fs/promises";
3
- import path from "node:path";
4
- import { fileURLToPath } from "node:url";
5
-
6
- export const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../../..");
7
- export const e2eRoot = path.join(repoRoot, "tests", "e2e");
8
- export const activeScenariosRoot = path.join(e2eRoot, "_active");
9
- export const completedScenariosRoot = path.join(e2eRoot, "scenarios");
10
- export const defaultStartPath = "/";
11
-
12
- export function toRepoRelative(absolutePath) {
13
- return path.relative(repoRoot, absolutePath);
14
- }
15
-
16
- export function getCliArg(index = 0) {
17
- const args = process.argv.slice(2).filter((arg) => arg !== "--");
18
- return args[index];
19
- }
20
-
21
- export function toScenarioId(input) {
22
- const id = input
23
- .trim()
24
- .replace(/([a-z0-9])([A-Z])/g, "$1-$2")
25
- .toLowerCase()
26
- .replace(/[^a-z0-9]+/g, "-")
27
- .replace(/^-+|-+$/g, "");
28
-
29
- assertScenarioId(id);
30
- return id;
31
- }
32
-
33
- export function assertScenarioId(id) {
34
- if (!/^[a-z0-9][a-z0-9-]*[a-z0-9]$|^[a-z0-9]$/.test(id)) {
35
- throw new Error(
36
- `Invalid scenario id "${id}". Use lowercase letters, numbers, and dashes only.`,
37
- );
38
- }
39
-
40
- if (id.includes("..")) {
41
- throw new Error(`Invalid scenario id "${id}". Parent directory references are not allowed.`);
42
- }
43
- }
44
-
45
- export function scenarioPaths(id, baseDir = activeScenariosRoot) {
46
- assertScenarioId(id);
47
- const root = path.join(baseDir, id);
48
- const specsDir = path.join(root, "specs");
49
-
50
- return {
51
- id,
52
- root,
53
- intentPath: path.join(root, "intent.md"),
54
- authoringPath: path.join(root, "authoring.md"),
55
- startUrlPath: path.join(root, "start-url.txt"),
56
- seedPath: path.join(root, "seed.mjs"),
57
- flowScriptPath: path.join(root, "flow.script.ts"),
58
- specsDir,
59
- artifactsDir: path.join(root, "artifacts"),
60
- specPath: path.join(specsDir, `${id}.spec.ts`),
61
- };
62
- }
63
-
64
- export async function ensureScenarioRoots() {
65
- await mkdir(activeScenariosRoot, { recursive: true });
66
- await mkdir(completedScenariosRoot, { recursive: true });
67
- }
68
-
69
- export async function listScenarioIds(root) {
70
- if (!existsSync(root)) return [];
71
- const entries = await readdir(root, { withFileTypes: true });
72
- return entries
73
- .filter((entry) => entry.isDirectory() && !entry.name.startsWith("."))
74
- .map((entry) => entry.name)
75
- .sort();
76
- }
77
-
78
- export async function getOptionalActiveScenario() {
79
- await ensureScenarioRoots();
80
- const ids = await listScenarioIds(activeScenariosRoot);
81
- if (ids.length === 0) return null;
82
- if (ids.length > 1) {
83
- throw new Error(
84
- `Expected at most one active E2E scenario, found ${ids.length}: ${ids.join(", ")}`,
85
- );
86
- }
87
- return scenarioPaths(ids[0]);
88
- }
89
-
90
- export async function getRequiredActiveScenario() {
91
- const scenario = await getOptionalActiveScenario();
92
- if (!scenario) {
93
- throw new Error(
94
- "No active E2E scenario found. Create one with `nps e2e.playwright.0CreateActiveScenario -- <scenario-id>`.",
95
- );
96
- }
97
- return scenario;
98
- }
99
-
100
- export async function ensureScenarioDirectories(paths) {
101
- await mkdir(paths.root, { recursive: true });
102
- await mkdir(paths.specsDir, { recursive: true });
103
- await mkdir(paths.artifactsDir, { recursive: true });
104
- }
105
-
106
- export async function writeIfMissing(filePath, content) {
107
- if (existsSync(filePath)) return false;
108
- await mkdir(path.dirname(filePath), { recursive: true });
109
- await writeFile(filePath, content, "utf8");
110
- return true;
111
- }
112
-
113
- export async function readTextIfExists(filePath) {
114
- if (!existsSync(filePath)) return null;
115
- return readFile(filePath, "utf8");
116
- }
117
-
118
- export async function moveActiveScenarioToCompleted(active, completedId) {
119
- const completed = scenarioPaths(completedId, completedScenariosRoot);
120
- if (existsSync(completed.root)) {
121
- throw new Error(`Completed scenario already exists: ${toRepoRelative(completed.root)}`);
122
- }
123
- await mkdir(path.dirname(completed.root), { recursive: true });
124
- await rename(active.root, completed.root);
125
- return completed;
126
- }
127
-
128
- export function requireFile(filePath, message) {
129
- if (!existsSync(filePath)) throw new Error(message);
130
- }
@@ -1,7 +0,0 @@
1
- import { assertLocalEnvironment } from "./localEnvironment.mjs";
2
-
3
- const requireFrontend = process.argv.includes("--frontend") || true;
4
- const config = await assertLocalEnvironment({ requireFrontend });
5
-
6
- console.log("E2E Playwright environment is local-only.");
7
- console.log(`Base URL: ${config.baseUrl}`);
@@ -1,36 +0,0 @@
1
- import { existsSync } from "node:fs";
2
- import { rename } from "node:fs/promises";
3
- import path from "node:path";
4
- import {
5
- getCliArg,
6
- getRequiredActiveScenario,
7
- moveActiveScenarioToCompleted,
8
- requireFile,
9
- toRepoRelative,
10
- toScenarioId,
11
- } from "./activeScenario.mjs";
12
- import { promptText } from "./prompt.mjs";
13
-
14
- const active = await getRequiredActiveScenario();
15
- const rawCompletedId =
16
- getCliArg() ??
17
- process.env.E2E_PLAYWRIGHT_COMPLETED_SCENARIO_ID ??
18
- (await promptText({ label: "Completed E2E scenario id", defaultValue: active.id }));
19
- const completedId = toScenarioId(rawCompletedId);
20
-
21
- requireFile(active.seedPath, `Missing seed: ${toRepoRelative(active.seedPath)}.`);
22
- requireFile(
23
- active.flowScriptPath,
24
- `Missing flow script: ${toRepoRelative(active.flowScriptPath)}.`,
25
- );
26
- requireFile(active.specPath, `Missing spec: ${toRepoRelative(active.specPath)}.`);
27
-
28
- const completed = await moveActiveScenarioToCompleted(active, completedId);
29
-
30
- if (completedId !== active.id) {
31
- const oldSpecPath = path.join(completed.specsDir, `${active.id}.spec.ts`);
32
- const newSpecPath = completed.specPath;
33
- if (existsSync(oldSpecPath) && !existsSync(newSpecPath)) await rename(oldSpecPath, newSpecPath);
34
- }
35
-
36
- console.log(`Completed E2E scenario: ${toRepoRelative(completed.root)}`);