@specdest/devkit 0.2.1 → 0.3.0

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 +15 -20
  2. package/package.json +4 -4
  3. package/src/canonical-project-operations.js +157 -0
  4. package/src/canonical-project.js +50 -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 +69 -9
  10. package/src/remote-installer.js +462 -0
  11. package/src/sync-core.js +26 -10
  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 -28
  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,55 +0,0 @@
1
- ---
2
- name: unit-test-rules
3
- description: General rules for deterministic unit tests, colocated test ownership, and coverage gates.
4
- ---
5
-
6
- # Unit test rules
7
-
8
- Use this skill before adding or moving unit tests.
9
-
10
- ## Rules
11
-
12
- - Unit tests live beside their strongest owner.
13
- - Source-file tests live beside the source file.
14
- - Script tests live beside the script.
15
- - Template tests live inside the template folder.
16
- - Feature tests live inside the feature folder.
17
- - Rule or docs tests live beside the rule or docs they protect.
18
- - Do not add new tests to the root `tests/` folder unless migration is explicitly deferred in `config.json`.
19
- - Unit tests must be deterministic: no production services, no network dependency, and no sleeps as assertions.
20
- - Every bug fix must add a regression test that fails for the reported defect before production code is changed.
21
- - Stateful third-party UI integrations must test user events separately from initialization, programmatic updates, and responsive/reflow events.
22
- - Critical source files configured by the project must have colocated owner tests with configured behavioral markers.
23
- - The project must keep a coverage gate in the canonical check path when `config.json` requires it.
24
-
25
- ## Existing root tests
26
-
27
- The root `tests/` folder is migration debt. Existing root tests are allowed only while they are listed in this skill's `config.json` allowlist.
28
-
29
- Do not add to that allowlist unless the move is explicitly deferred with a reason.
30
-
31
- ## Project-specific TODO
32
-
33
- - Decide whether existing root tests should be migrated or allowlisted.
34
- - Set project-specific coverage floors in the project test runner.
35
- - Decide whether snapshots are allowed.
36
- - Document allowed test doubles: fakes, mocks, fixtures, and contract tests.
37
- - Document intentionally slow unit tests.
38
-
39
- ## Check
40
-
41
- Run before handoff:
42
-
43
- ```bash
44
- nps lint
45
- ```
46
-
47
- Direct checker:
48
-
49
- ```bash
50
- node .agents/skills/unit-test-rules/check.ts
51
- ```
52
-
53
- ## Fix violations
54
-
55
- Move the test next to the strongest owner, remove sleeps/network calls, and update test discovery if needed.
@@ -1,132 +0,0 @@
1
- import { runtime } from "../shared/runtime.ts";
2
- import { assertSchemaVersion, readSkillConfig } from "../shared/config.ts";
3
- import { exists, normalizePath, walk } from "../shared/fs.ts";
4
-
5
- type CriticalOwnerTest = { source: string; test: string; markers?: string[] };
6
-
7
- type Config = {
8
- schemaVersion: number;
9
- allowedRootTests: string[];
10
- ignoredDirectories?: string[];
11
- requireCoverageScript?: boolean;
12
- packageJsonPath?: string;
13
- canonicalCheckScript?: string;
14
- coverageScript?: string;
15
- forbiddenUnitTestPatterns?: string[];
16
- allowedForbiddenPatternFiles?: string[];
17
- requiredCriticalOwnerTests?: CriticalOwnerTest[];
18
- };
19
-
20
- const { config, root } = await readSkillConfig<Config>(import.meta.url);
21
- assertSchemaVersion(config.schemaVersion);
22
- if (!Array.isArray(config.allowedRootTests)) {
23
- throw new Error("config.json allowedRootTests must be an array");
24
- }
25
-
26
- const allowedRootTests = new Set(config.allowedRootTests.map(normalizePath));
27
- const ignoredDirectories = new Set(config.ignoredDirectories ?? []);
28
- const testFilePattern = /\.(test|spec)\.(ts|tsx|js|jsx|mjs|cjs)$/;
29
- const allowedForbiddenPatternFiles = new Set(
30
- (config.allowedForbiddenPatternFiles ?? []).map(normalizePath),
31
- );
32
- const forbiddenUnitTestPatterns = config.forbiddenUnitTestPatterns ?? [
33
- "waitForTimeout(",
34
- "setTimeout(",
35
- "https://api.",
36
- "http://api.",
37
- "https://prod",
38
- "http://prod",
39
- ];
40
-
41
- function isRootTest(file: string): boolean {
42
- return file.startsWith("tests/") && file.split("/").length === 2 && testFilePattern.test(file);
43
- }
44
-
45
- function isUnitTest(file: string): boolean {
46
- if (!testFilePattern.test(file)) return false;
47
- if (file.includes("/e2e/") || file.startsWith("tests/e2e/")) return false;
48
- if (file.includes(".agents/skills/")) return false;
49
- return true;
50
- }
51
-
52
- async function readJsonFile(path: string): Promise<Record<string, unknown> | null> {
53
- try {
54
- return JSON.parse(await runtime.readTextFile(path)) as Record<string, unknown>;
55
- } catch (error) {
56
- if (error instanceof runtime.errors.NotFound) return null;
57
- throw error;
58
- }
59
- }
60
-
61
- const files = await walk(root, { ignoredDirectories });
62
- const rootTests = files.filter(isRootTest).sort();
63
- const existingRootTests = new Set(rootTests);
64
- const violations: string[] = [];
65
-
66
- for (const file of rootTests) {
67
- if (!allowedRootTests.has(file)) {
68
- violations.push(
69
- `${file}: new unit tests must live beside their strongest owner, not in root tests/`,
70
- );
71
- }
72
- }
73
-
74
- for (const file of [...allowedRootTests].sort()) {
75
- if (!existingRootTests.has(file)) {
76
- violations.push(
77
- `${file}: stale unit-test-rules allowlist entry; remove it from .agents/skills/unit-test-rules/config.json`,
78
- );
79
- }
80
- }
81
-
82
- for (const file of files.filter(isUnitTest).sort()) {
83
- if (allowedForbiddenPatternFiles.has(file)) continue;
84
- const text = await runtime.readTextFile(`${root}/${file}`);
85
- for (const pattern of forbiddenUnitTestPatterns) {
86
- if (text.includes(pattern)) {
87
- violations.push(`${file}: unit test contains forbidden pattern ${JSON.stringify(pattern)}`);
88
- }
89
- }
90
- }
91
-
92
- for (const owner of config.requiredCriticalOwnerTests ?? []) {
93
- if (!(await exists(`${root}/${owner.source}`))) {
94
- violations.push(`${owner.source}: configured critical source is missing`);
95
- continue;
96
- }
97
- if (!(await exists(`${root}/${owner.test}`))) {
98
- violations.push(`${owner.test}: critical source ${owner.source} requires this owner test`);
99
- continue;
100
- }
101
- const text = await runtime.readTextFile(`${root}/${owner.test}`);
102
- for (const marker of owner.markers ?? [])
103
- if (!text.includes(marker))
104
- violations.push(
105
- `${owner.test}: missing required critical-test marker ${JSON.stringify(marker)}`,
106
- );
107
- }
108
-
109
- if (config.requireCoverageScript ?? true) {
110
- const packageJson = await readJsonFile(`${root}/${config.packageJsonPath ?? "package.json"}`);
111
- const scripts =
112
- packageJson?.scripts && typeof packageJson.scripts === "object"
113
- ? (packageJson.scripts as Record<string, unknown>)
114
- : {};
115
- const canonicalCheckScript = config.canonicalCheckScript ?? "check";
116
- const coverageScript = config.coverageScript ?? "test:coverage";
117
- const checkCommand = String(scripts[canonicalCheckScript] ?? "");
118
- if (!scripts[coverageScript]) {
119
- violations.push(`package.json: missing scripts.${coverageScript} coverage gate`);
120
- }
121
- if (
122
- !checkCommand.includes(`npm run ${coverageScript}`) &&
123
- !checkCommand.includes(`nps ${coverageScript}`) &&
124
- !checkCommand.includes(String(scripts[coverageScript] ?? "__missing__"))
125
- ) {
126
- violations.push(`package.json: scripts.${canonicalCheckScript} must run ${coverageScript}`);
127
- }
128
- }
129
-
130
- console.log(`# unit test rule violations: ${violations.length}`);
131
- for (const violation of violations) console.log(`- ${violation}`);
132
- if (violations.length > 0) runtime.exit(1);
@@ -1,22 +0,0 @@
1
- {
2
- "schemaVersion": 1,
3
- "allowedRootTests": [],
4
- "allowedForbiddenPatternFiles": [],
5
- "requireCoverageScript": false,
6
- "ignoredDirectories": [".git", "code-templates", "node_modules", "dist", "build", "coverage"],
7
- "requiredCriticalOwnerTests": [
8
- {
9
- "source": "src/routes/dashboard/-components/ui/DashboardGrid.tsx",
10
- "test": "src/routes/dashboard/-components/ui/DashboardGrid.test.tsx",
11
- "markers": [
12
- "does not persist generic GridStack change events",
13
- "persists dragstop and resizestop user layout events"
14
- ]
15
- },
16
- {
17
- "source": "src/routes/dashboard/-components/contracts/DashboardWidgetSaveCommand.ts",
18
- "test": "src/routes/dashboard/-components/contracts/DashboardWidgetSaveCommand.test.ts",
19
- "markers": ["strips read-model persistence fields from mutation commands"]
20
- }
21
- ]
22
- }
@@ -1,38 +0,0 @@
1
- {
2
- "id": "unit-test-rules",
3
- "kind": "rule",
4
- "version": "1.0.1",
5
- "requires": [
6
- "checker-runtime"
7
- ],
8
- "artifacts": [
9
- {
10
- "kind": "managed-file",
11
- "path": ".agents/skills/unit-test-rules/SKILL.md",
12
- "source": "SKILL.md"
13
- },
14
- {
15
- "kind": "managed-file",
16
- "path": ".agents/skills/unit-test-rules/check.ts",
17
- "source": "check.ts"
18
- },
19
- {
20
- "kind": "managed-file",
21
- "path": ".agents/skills/unit-test-rules/config.json",
22
- "source": "config.json"
23
- },
24
- {
25
- "kind": "shared-markdown-section",
26
- "path": "AGENTS.md",
27
- "heading": "## Specdest rule: unit-test-rules",
28
- "body": "Use `.agents/skills/unit-test-rules/SKILL.md` when working in this rule area. Run `node .agents/skills/unit-test-rules/check.ts` before handoff."
29
- }
30
- ],
31
- "obsolete": [],
32
- "check": {
33
- "command": [
34
- "node",
35
- ".agents/skills/unit-test-rules/check.ts"
36
- ]
37
- }
38
- }
@@ -1,41 +0,0 @@
1
- # Unit test rules
2
-
3
- Unit tests should verify one file's responsibility only. Layer tests should use
4
- input contract -> layer logic -> output contract.
5
-
6
- ## Enforced coverage
7
-
8
- The checker at `check.ts` enforces these generated-project rules:
9
-
10
- - App-owned shared UI under `src/components/general/` and page UI under `src/**/-components/ui/` must
11
- have a colocated Storybook story. Bulk generated shadcn primitives under `src/components/ui/` are not automatically required to have stories.
12
- - UI stories must include a `play` test with visible Testing Library assertions
13
- so component states are executable, not only visual examples.
14
- - UI stories must render the real component, not placeholder contract text.
15
- - Storybook stories must not import `zod`, define story-local Zod schemas, or
16
- import storybook-only schema files such as `story.schema`, `stories.schema`,
17
- or `storybook.schema`.
18
- - Schema-backed UI stories must import production `*.schema` files and parse
19
- args or fixtures through the real schema with `.parse()` or `.safeParse()`.
20
- - Page-local UI components that display data collections must include these
21
- Storybook states: `Empty`, `Loading`, `MinimumData`, and `FullData`.
22
- - Page-local form UI that uses `DevFormFillButtons` must export `EmptyDisplay`, `EmptySubmit`,
23
- `MinimalRightDataSubmit`, `AllFieldRightDataSubmit`, `AllFieldBadDataSubmit`,
24
- and `FullInitialValueDisplay`.
25
- - Every required form story must have its own `play` test. Submit stories must
26
- submit through `userEvent`, assert exactly one submit call, and compare the
27
- complete submitted value object with `toStrictEqual` or
28
- `toHaveBeenCalledWith`; do not use lenient matchers such as
29
- `objectContaining`, `arrayContaining`, `expect.any`, or `expect.anything` for
30
- submitted values.
31
- - Container components under `src/**/-components/container/` must have colocated
32
- unit/component tests.
33
- - UI hooks under `src/**/-components/ui-hooks/` must have colocated unit tests.
34
- - Data hooks under `src/**/-components/data-hooks/` must be referenced by
35
- route-layer unit tests.
36
-
37
- ## Script wiring
38
-
39
- Run `nps lint.unitTestRules` for this checker directly. It is also part of
40
- `nps lint.raw`, so `nps lint`, `nps check`, and the generated Husky pre-commit
41
- hook all enforce these rules.