@specdest/devkit 0.4.18 → 0.4.20

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 (146) hide show
  1. package/README.md +107 -28
  2. package/dist/npm/cli.js +16 -24
  3. package/dist/npm/index.js +5 -1
  4. package/dist/npm/native/specdest-darwin-arm64 +0 -0
  5. package/dist/npm/native/specdest-darwin-x64 +0 -0
  6. package/dist/npm/native/specdest-linux-arm64 +0 -0
  7. package/dist/npm/native/specdest-linux-x64 +0 -0
  8. package/package.json +8 -5
  9. package/dist/npm/automation-policy.d.ts +0 -2
  10. package/dist/npm/automation-policy.js +0 -30
  11. package/dist/npm/canonical-project-operations.d.ts +0 -5
  12. package/dist/npm/canonical-project-operations.js +0 -5
  13. package/dist/npm/canonical-project.d.ts +0 -21
  14. package/dist/npm/canonical-project.js +0 -115
  15. package/dist/npm/catalog-snapshot.d.ts +0 -53
  16. package/dist/npm/catalog-snapshot.js +0 -35
  17. package/dist/npm/client-only-boundary.d.ts +0 -1
  18. package/dist/npm/client-only-boundary.js +0 -29
  19. package/dist/npm/commands.d.ts +0 -15
  20. package/dist/npm/commands.js +0 -188
  21. package/dist/npm/git-catalog.d.ts +0 -40
  22. package/dist/npm/git-catalog.js +0 -222
  23. package/dist/npm/host-automation.d.ts +0 -9
  24. package/dist/npm/host-automation.js +0 -66
  25. package/dist/npm/installer-primitives.d.ts +0 -3
  26. package/dist/npm/installer-primitives.js +0 -50
  27. package/dist/npm/predefined-packages/abac.d.ts +0 -2
  28. package/dist/npm/predefined-packages/abac.js +0 -22
  29. package/dist/npm/predefined-packages/admin-ui-templates/AdminConfirmDialog.tsx.template +0 -46
  30. package/dist/npm/predefined-packages/admin-ui-templates/AdminDataTable.tsx.template +0 -49
  31. package/dist/npm/predefined-packages/admin-ui-templates/AdminDetailLayout.tsx.template +0 -15
  32. package/dist/npm/predefined-packages/admin-ui-templates/AdminEmptyState.tsx.template +0 -17
  33. package/dist/npm/predefined-packages/admin-ui-templates/AdminFilterBar.tsx.template +0 -16
  34. package/dist/npm/predefined-packages/admin-ui-templates/AdminFormLayout.tsx.template +0 -19
  35. package/dist/npm/predefined-packages/admin-ui-templates/AdminPage.tsx.template +0 -19
  36. package/dist/npm/predefined-packages/admin-ui-templates/AdminPageHeader.tsx.template +0 -19
  37. package/dist/npm/predefined-packages/admin-ui-templates/AdminPagination.tsx.template +0 -20
  38. package/dist/npm/predefined-packages/admin-ui-templates/AdminShell.tsx.template +0 -20
  39. package/dist/npm/predefined-packages/admin-ui-templates/AdminSidebar.tsx.template +0 -18
  40. package/dist/npm/predefined-packages/admin-ui-templates/AdminStatCard.tsx.template +0 -22
  41. package/dist/npm/predefined-packages/admin-ui.d.ts +0 -2
  42. package/dist/npm/predefined-packages/admin-ui.js +0 -79
  43. package/dist/npm/predefined-packages/auth.d.ts +0 -2
  44. package/dist/npm/predefined-packages/auth.js +0 -21
  45. package/dist/npm/predefined-packages/convex.d.ts +0 -2
  46. package/dist/npm/predefined-packages/convex.js +0 -53
  47. package/dist/npm/predefined-packages/expo.d.ts +0 -2
  48. package/dist/npm/predefined-packages/expo.js +0 -88
  49. package/dist/npm/predefined-packages/firebase-hosting.d.ts +0 -2
  50. package/dist/npm/predefined-packages/firebase-hosting.js +0 -24
  51. package/dist/npm/predefined-packages/health.d.ts +0 -10
  52. package/dist/npm/predefined-packages/health.js +0 -52
  53. package/dist/npm/predefined-packages/husky.d.ts +0 -2
  54. package/dist/npm/predefined-packages/husky.js +0 -57
  55. package/dist/npm/predefined-packages/index.d.ts +0 -12
  56. package/dist/npm/predefined-packages/index.js +0 -97
  57. package/dist/npm/predefined-packages/install.d.ts +0 -19
  58. package/dist/npm/predefined-packages/install.js +0 -86
  59. package/dist/npm/predefined-packages/local-logging.d.ts +0 -2
  60. package/dist/npm/predefined-packages/local-logging.js +0 -17
  61. package/dist/npm/predefined-packages/logging.d.ts +0 -2
  62. package/dist/npm/predefined-packages/logging.js +0 -21
  63. package/dist/npm/predefined-packages/multi-tenancy.d.ts +0 -2
  64. package/dist/npm/predefined-packages/multi-tenancy.js +0 -21
  65. package/dist/npm/predefined-packages/nps.d.ts +0 -2
  66. package/dist/npm/predefined-packages/nps.js +0 -32
  67. package/dist/npm/predefined-packages/oxfmt.d.ts +0 -2
  68. package/dist/npm/predefined-packages/oxfmt.js +0 -22
  69. package/dist/npm/predefined-packages/oxlint.d.ts +0 -2
  70. package/dist/npm/predefined-packages/oxlint.js +0 -35
  71. package/dist/npm/predefined-packages/package-json.d.ts +0 -3
  72. package/dist/npm/predefined-packages/package-json.js +0 -61
  73. package/dist/npm/predefined-packages/payments.d.ts +0 -2
  74. package/dist/npm/predefined-packages/payments.js +0 -31
  75. package/dist/npm/predefined-packages/playwright.d.ts +0 -2
  76. package/dist/npm/predefined-packages/playwright.js +0 -35
  77. package/dist/npm/predefined-packages/project-signals.d.ts +0 -4
  78. package/dist/npm/predefined-packages/project-signals.js +0 -39
  79. package/dist/npm/predefined-packages/registry.d.ts +0 -3
  80. package/dist/npm/predefined-packages/registry.js +0 -65
  81. package/dist/npm/predefined-packages/resolver.d.ts +0 -8
  82. package/dist/npm/predefined-packages/resolver.js +0 -35
  83. package/dist/npm/predefined-packages/sentry.d.ts +0 -2
  84. package/dist/npm/predefined-packages/sentry.js +0 -29
  85. package/dist/npm/predefined-packages/shadcn.d.ts +0 -2
  86. package/dist/npm/predefined-packages/shadcn.js +0 -23
  87. package/dist/npm/predefined-packages/storybook.d.ts +0 -2
  88. package/dist/npm/predefined-packages/storybook.js +0 -25
  89. package/dist/npm/predefined-packages/stryker.d.ts +0 -2
  90. package/dist/npm/predefined-packages/stryker.js +0 -48
  91. package/dist/npm/predefined-packages/supabase.d.ts +0 -2
  92. package/dist/npm/predefined-packages/supabase.js +0 -355
  93. package/dist/npm/predefined-packages/tailwind.d.ts +0 -2
  94. package/dist/npm/predefined-packages/tailwind.js +0 -18
  95. package/dist/npm/predefined-packages/tanstack-form.d.ts +0 -2
  96. package/dist/npm/predefined-packages/tanstack-form.js +0 -19
  97. package/dist/npm/predefined-packages/tanstack-query.d.ts +0 -2
  98. package/dist/npm/predefined-packages/tanstack-query.js +0 -15
  99. package/dist/npm/predefined-packages/tanstack-router.d.ts +0 -2
  100. package/dist/npm/predefined-packages/tanstack-router.js +0 -18
  101. package/dist/npm/predefined-packages/types.d.ts +0 -38
  102. package/dist/npm/predefined-packages/types.js +0 -1
  103. package/dist/npm/predefined-packages/vite.d.ts +0 -2
  104. package/dist/npm/predefined-packages/vite.js +0 -127
  105. package/dist/npm/predefined-packages/vitest.d.ts +0 -2
  106. package/dist/npm/predefined-packages/vitest.js +0 -20
  107. package/dist/npm/predefined-packages/zod.d.ts +0 -2
  108. package/dist/npm/predefined-packages/zod.js +0 -18
  109. package/dist/npm/project-check.d.ts +0 -25
  110. package/dist/npm/project-check.js +0 -178
  111. package/dist/npm/project-context.d.ts +0 -52
  112. package/dist/npm/project-context.js +0 -211
  113. package/dist/npm/project-install-guard.d.ts +0 -2
  114. package/dist/npm/project-install-guard.js +0 -51
  115. package/dist/npm/project-rules.d.ts +0 -25
  116. package/dist/npm/project-rules.js +0 -106
  117. package/dist/npm/project-runtime.d.ts +0 -21
  118. package/dist/npm/project-runtime.js +0 -41
  119. package/dist/npm/project-status.d.ts +0 -32
  120. package/dist/npm/project-status.js +0 -70
  121. package/dist/npm/project-sync.d.ts +0 -7
  122. package/dist/npm/project-sync.js +0 -143
  123. package/dist/npm/remote-installer.d.ts +0 -35
  124. package/dist/npm/remote-installer.js +0 -351
  125. package/dist/npm/rule-id-migrations.d.ts +0 -6
  126. package/dist/npm/rule-id-migrations.js +0 -19
  127. package/dist/npm/slack.d.ts +0 -16
  128. package/dist/npm/slack.js +0 -135
  129. package/dist/npm/snapshot/config.d.ts +0 -10
  130. package/dist/npm/snapshot/config.js +0 -24
  131. package/dist/npm/snapshot/policy.d.ts +0 -1
  132. package/dist/npm/snapshot/policy.js +0 -64
  133. package/dist/npm/snapshot/restore.d.ts +0 -10
  134. package/dist/npm/snapshot/restore.js +0 -19
  135. package/dist/npm/snapshot/sql.d.ts +0 -2
  136. package/dist/npm/snapshot/sql.js +0 -113
  137. package/dist/npm/snapshot/storage.d.ts +0 -8
  138. package/dist/npm/snapshot/storage.js +0 -70
  139. package/dist/npm/snapshot/verify.d.ts +0 -11
  140. package/dist/npm/snapshot/verify.js +0 -13
  141. package/dist/npm/snapshot-cli.d.ts +0 -6
  142. package/dist/npm/snapshot-cli.js +0 -45
  143. package/dist/npm/state.d.ts +0 -14
  144. package/dist/npm/state.js +0 -269
  145. package/dist/npm/supabase-local.d.ts +0 -2
  146. package/dist/npm/supabase-local.js +0 -62
@@ -1,15 +0,0 @@
1
- import { detectDependency } from "./package-json.js";
2
- export const tanstackQueryRecipe = {
3
- id: 'tanstack-query',
4
- recipeVersion: '1.0.1',
5
- role: 'integration',
6
- requires: ['supabase'],
7
- async detect(projectRoot) {
8
- return await detectDependency(projectRoot, '@tanstack/react-query', '@tanstack/react-query');
9
- },
10
- async apply(_projectRoot, detection, _resolution) {
11
- if (!detection.present)
12
- throw new Error('TanStack Query is not installed; creating Query configuration is not supported by `add tanstack-query` yet.');
13
- return { source: 'adopted' };
14
- },
15
- };
@@ -1,2 +0,0 @@
1
- import type { PackageRecipe } from './types.ts';
2
- export declare const tanstackRouterRecipe: PackageRecipe;
@@ -1,18 +0,0 @@
1
- import { detectDependency } from "./package-json.js";
2
- export const tanstackRouterRecipe = {
3
- id: 'tanstack-router',
4
- recipeVersion: '1.0.0',
5
- role: 'integration',
6
- requires: ['vite'],
7
- async detect(projectRoot) {
8
- return await detectDependency(projectRoot, '@tanstack/react-router', '@tanstack/react-router');
9
- },
10
- async apply(_projectRoot, detection, _resolution) {
11
- if (!detection.present) {
12
- throw new Error('TanStack Router is not installed; creating router configuration is not supported by `add tanstack-router` yet.');
13
- }
14
- if (!detection.compatible)
15
- throw new Error(detection.reason ?? 'Existing TanStack Router integration is not compatible.');
16
- return { source: 'adopted' };
17
- },
18
- };
@@ -1,38 +0,0 @@
1
- export type PackageSource = 'adopted' | 'installed';
2
- export type PackageDetection = {
3
- present: boolean;
4
- compatible: boolean;
5
- detectedVersion: string | null;
6
- reason?: string;
7
- };
8
- export type PackageVariant = {
9
- id: string;
10
- when: string[];
11
- };
12
- export type PackageResolution = {
13
- variant: string | null;
14
- };
15
- export type PackageSetupRequirement = {
16
- kind: 'package';
17
- packageId: string;
18
- required: boolean;
19
- when?: 'git';
20
- };
21
- export type PackageApplyContext = {
22
- runCommand(command: string, args: string[], options: {
23
- cwd: string;
24
- }): Promise<void>;
25
- };
26
- export type PackageRecipe = {
27
- id: string;
28
- recipeVersion: string;
29
- role: string;
30
- requires?: string[];
31
- conflicts?: string[];
32
- variants?: PackageVariant[];
33
- setupRequirements?: PackageSetupRequirement[];
34
- detect(projectRoot: string): Promise<PackageDetection>;
35
- apply(projectRoot: string, detection: PackageDetection, resolution: PackageResolution, context: PackageApplyContext): Promise<{
36
- source: PackageSource;
37
- }>;
38
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,2 +0,0 @@
1
- import type { PackageRecipe } from './types.ts';
2
- export declare const viteRecipe: PackageRecipe;
@@ -1,127 +0,0 @@
1
- import { basename } from 'node:path';
2
- import { ensurePnpmBuildPolicy, mergeMissing, updatePackageJson, writeProjectFileIfMissing } from "./install.js";
3
- import { detectDependency } from "./package-json.js";
4
- const dependencies = {
5
- react: '19.2.3',
6
- 'react-dom': '19.2.3',
7
- };
8
- const devDependencies = {
9
- '@types/react': '19.2.7',
10
- '@types/react-dom': '19.2.3',
11
- '@vitejs/plugin-react': '5.1.2',
12
- typescript: '6.0.3',
13
- vite: '7.3.0',
14
- };
15
- function packageName(projectRoot) {
16
- const normalized = basename(projectRoot).toLowerCase().replace(/[^a-z0-9._-]+/gu, '-');
17
- return normalized || 'specdest-app';
18
- }
19
- async function installVite(projectRoot, context) {
20
- await updatePackageJson(projectRoot, (pkg) => ({
21
- ...pkg,
22
- name: pkg.name ?? packageName(projectRoot),
23
- private: pkg.private ?? true,
24
- type: pkg.type ?? 'module',
25
- packageManager: pkg.packageManager ?? 'pnpm@11.6.0',
26
- engines: {
27
- ...pkg.engines,
28
- node: pkg.engines?.node ?? '>=24.0.0',
29
- pnpm: pkg.engines?.pnpm ?? '>=11.0.0',
30
- },
31
- scripts: mergeMissing(pkg.scripts, {
32
- dev: 'vite',
33
- build: 'tsc -b && vite build',
34
- typecheck: 'tsc -b',
35
- preview: 'vite preview',
36
- }),
37
- dependencies: mergeMissing(pkg.dependencies, dependencies),
38
- devDependencies: mergeMissing(pkg.devDependencies, devDependencies),
39
- }));
40
- await ensurePnpmBuildPolicy(projectRoot);
41
- await writeProjectFileIfMissing(projectRoot, 'index.html', `<!doctype html>
42
- <html lang="en">
43
- <head><meta charset="UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /></head>
44
- <body><div id="root"></div><script type="module" src="/src/main.tsx"></script></body>
45
- </html>
46
- `);
47
- await writeProjectFileIfMissing(projectRoot, 'src/main.tsx', `import { StrictMode } from 'react';
48
- import { createRoot } from 'react-dom/client';
49
- import App from './App';
50
-
51
- createRoot(document.getElementById('root')!).render(
52
- <StrictMode>
53
- <App />
54
- </StrictMode>,
55
- );
56
- `);
57
- await writeProjectFileIfMissing(projectRoot, 'src/App.tsx', `export default function App() {
58
- return <main>Specdest app</main>;
59
- }
60
- `);
61
- await writeProjectFileIfMissing(projectRoot, 'vite.config.ts', `import { defineConfig } from 'vite';
62
- import react from '@vitejs/plugin-react';
63
-
64
- export default defineConfig({ plugins: [react()] });
65
- `);
66
- await writeProjectFileIfMissing(projectRoot, 'tsconfig.json', `{
67
- "files": [],
68
- "references": [
69
- { "path": "./tsconfig.app.json" },
70
- { "path": "./tsconfig.node.json" }
71
- ]
72
- }
73
- `);
74
- await writeProjectFileIfMissing(projectRoot, 'tsconfig.app.json', `{
75
- "compilerOptions": {
76
- "target": "ES2022",
77
- "useDefineForClassFields": true,
78
- "lib": ["ES2022", "DOM", "DOM.Iterable"],
79
- "skipLibCheck": true,
80
- "module": "ESNext",
81
- "moduleResolution": "Bundler",
82
- "allowImportingTsExtensions": true,
83
- "resolveJsonModule": true,
84
- "isolatedModules": true,
85
- "noEmit": true,
86
- "jsx": "react-jsx",
87
- "strict": true
88
- },
89
- "include": ["src"]
90
- }
91
- `);
92
- await writeProjectFileIfMissing(projectRoot, 'tsconfig.node.json', `{
93
- "compilerOptions": {
94
- "composite": true,
95
- "skipLibCheck": true,
96
- "module": "ESNext",
97
- "moduleResolution": "Bundler",
98
- "allowImportingTsExtensions": true,
99
- "noEmit": true
100
- },
101
- "include": ["vite.config.ts"]
102
- }
103
- `);
104
- await context.runCommand('pnpm', ['install', '--no-frozen-lockfile'], { cwd: projectRoot });
105
- }
106
- export const viteRecipe = {
107
- id: 'vite',
108
- recipeVersion: '1.2.0',
109
- role: 'frontend',
110
- setupRequirements: [
111
- { kind: 'package', packageId: 'oxlint', required: true },
112
- { kind: 'package', packageId: 'husky', required: true, when: 'git' },
113
- ],
114
- conflicts: ['expo'],
115
- async detect(projectRoot) {
116
- return await detectDependency(projectRoot, 'vite', 'Vite');
117
- },
118
- async apply(projectRoot, detection, _resolution, context) {
119
- if (detection.present) {
120
- if (!detection.compatible)
121
- throw new Error(detection.reason ?? 'Existing Vite setup is not compatible.');
122
- return { source: 'adopted' };
123
- }
124
- await installVite(projectRoot, context);
125
- return { source: 'installed' };
126
- },
127
- };
@@ -1,2 +0,0 @@
1
- import type { PackageRecipe } from './types.ts';
2
- export declare const vitestRecipe: PackageRecipe;
@@ -1,20 +0,0 @@
1
- import { installPackageJsonPatch } from "./install.js";
2
- import { detectDependency } from "./package-json.js";
3
- export const vitestRecipe = {
4
- id: 'vitest',
5
- recipeVersion: '1.1.0',
6
- role: 'integration',
7
- requires: ['vite'],
8
- async detect(projectRoot) {
9
- return await detectDependency(projectRoot, 'vitest', 'Vitest');
10
- },
11
- async apply(projectRoot, detection, _resolution, context) {
12
- if (detection.present)
13
- return { source: 'adopted' };
14
- await installPackageJsonPatch(projectRoot, context.runCommand, {
15
- devDependencies: { vitest: '4.1.0' },
16
- scripts: { test: 'vitest run', 'test:watch': 'vitest' },
17
- });
18
- return { source: 'installed' };
19
- },
20
- };
@@ -1,2 +0,0 @@
1
- import type { PackageRecipe } from './types.ts';
2
- export declare const zodRecipe: PackageRecipe;
@@ -1,18 +0,0 @@
1
- import { installPackageJsonPatch } from "./install.js";
2
- import { detectDependency } from "./package-json.js";
3
- export const zodRecipe = {
4
- id: 'zod',
5
- recipeVersion: '1.1.0',
6
- role: 'integration',
7
- async detect(projectRoot) {
8
- return await detectDependency(projectRoot, 'zod', 'Zod');
9
- },
10
- async apply(projectRoot, detection, _resolution, context) {
11
- if (detection.present)
12
- return { source: 'adopted' };
13
- await installPackageJsonPatch(projectRoot, context.runCommand, {
14
- dependencies: { zod: '4.3.6' },
15
- });
16
- return { source: 'installed' };
17
- },
18
- };
@@ -1,25 +0,0 @@
1
- export declare function runWithConcurrency<T, R>(items: T[], limit: number, worker: (item: T, index: number) => Promise<R>): Promise<R[]>;
2
- export declare function canonicalCheck(projectRoot: string, source: any, options?: any): Promise<{
3
- exitCode: number;
4
- results: any;
5
- executions: never[];
6
- versionProblems: {
7
- id: any;
8
- installedVersion: any;
9
- requiredVersion: any;
10
- contentMismatch: boolean;
11
- }[];
12
- } | {
13
- exitCode: number;
14
- results: {
15
- [k: string]: any;
16
- };
17
- executions: {
18
- ids: any[];
19
- checkerPath: any;
20
- exitCode: any;
21
- stdout: any;
22
- stderr: any;
23
- }[];
24
- versionProblems?: undefined;
25
- }>;
@@ -1,178 +0,0 @@
1
- import { spawn } from 'node:child_process';
2
- import { readdirSync } from 'node:fs';
3
- import { automationPolicyFindings } from "./automation-policy.js";
4
- import { projectFromCwd } from "./supabase-local.js";
5
- import { clientOnlyBoundaryViolations } from "./client-only-boundary.js";
6
- import { readRuleProfile } from "./project-context.js";
7
- import { loadCanonicalProjectContext, prepareCanonicalManifest } from "./project-runtime.js";
8
- import { assertPredefinedPackageState } from "./predefined-packages/health.js";
9
- import { readInstalledState, writeChecksState } from "./state.js";
10
- function execute(command, args, cwd) {
11
- return new Promise((resolve, reject) => {
12
- const child = spawn(command, args, { cwd, stdio: ['ignore', 'pipe', 'pipe'] });
13
- let stdout = '';
14
- let stderr = '';
15
- child.stdout.setEncoding('utf8');
16
- child.stderr.setEncoding('utf8');
17
- child.stdout.on('data', (chunk) => {
18
- stdout += chunk;
19
- });
20
- child.stderr.on('data', (chunk) => {
21
- stderr += chunk;
22
- });
23
- child.on('error', reject);
24
- child.on('close', (code) => resolve({ exitCode: code ?? 1, stdout, stderr }));
25
- });
26
- }
27
- export async function runWithConcurrency(items, limit, worker) {
28
- const concurrency = Math.max(1, Math.min(Math.floor(limit), items.length || 1));
29
- const results = new Array(items.length);
30
- let nextIndex = 0;
31
- await Promise.all(Array.from({ length: concurrency }, async () => {
32
- while (nextIndex < items.length) {
33
- const index = nextIndex++;
34
- results[index] = await worker(items[index], index);
35
- }
36
- }));
37
- return results;
38
- }
39
- export async function canonicalCheck(projectRoot, source, options = {}) {
40
- await assertPredefinedPackageState(projectRoot);
41
- const current = await readInstalledState(projectRoot);
42
- const { applicable, canonicalCheckRoot, checkerRuntimeRoot } = await loadCanonicalProjectContext(projectRoot, source, { offline: false, withCheckers: true, refresh: true });
43
- const byId = new Map(applicable.map((entry) => [entry.id, entry]));
44
- // Fail closed before invoking any checker if its installed contract is stale.
45
- // A cached validator may otherwise report PASS against obsolete requirements.
46
- const versionProblems = applicable.flatMap((entry) => {
47
- if ((entry.enforcement ?? 'guidance') === 'guidance')
48
- return [];
49
- const installed = current.installed[entry.id];
50
- if (!installed || installed.kind !== 'rule')
51
- return [];
52
- if (installed.version === entry.version && installed.contentHash === entry.contentHash)
53
- return [];
54
- return [
55
- {
56
- id: entry.id,
57
- installedVersion: installed.version ?? 'unknown',
58
- requiredVersion: entry.version,
59
- contentMismatch: installed.version === entry.version,
60
- },
61
- ];
62
- });
63
- if (versionProblems.length) {
64
- const results = Object.fromEntries(versionProblems.map((problem) => {
65
- const message = `STALE RULE ${problem.id}: installed ${problem.installedVersion}, canonical ${problem.requiredVersion}${problem.contentMismatch ? ' (content hash differs)' : ''}. Run \`pnpm exec specdest sync\` and commit .spd/installed.json.`;
66
- return [
67
- problem.id,
68
- { status: 'fail', exitCode: 1, stderr: message, diagnostics: [{ message }] },
69
- ];
70
- }));
71
- return { exitCode: 1, results, executions: [], versionProblems };
72
- }
73
- const results = {};
74
- const groups = new Map();
75
- const executor = options.executor ?? execute;
76
- const targetMode = options.mode ?? 'full';
77
- let targetFiles = options.files ?? null;
78
- if (targetMode === 'staged' && targetFiles === null) {
79
- const staged = await executor('git', ['diff', '--cached', '--name-only', '-z', '--diff-filter=ACMR'], projectRoot);
80
- if (staged.exitCode !== 0)
81
- throw new Error(staged.stderr || 'Unable to read staged files');
82
- targetFiles = staged.stdout.split('\0').filter(Boolean);
83
- }
84
- const normalizedTargetFiles = (targetFiles ?? []).map((file) => String(file).replaceAll('\\', '/'));
85
- let exitCode = 0;
86
- if (projectFromCwd(projectRoot)) {
87
- const scripts = readdirSync(`${projectRoot}/scripts`, { recursive: true, withFileTypes: true })
88
- .filter((entry) => entry.isFile())
89
- .map((entry) => `scripts/${entry.parentPath.replace(`${projectRoot}/scripts/`, '')}/${entry.name}`.replace('scripts//', 'scripts/'));
90
- const violations = automationPolicyFindings(projectRoot, ['package-scripts.yml', ...scripts]);
91
- results['automation-gateway'] = {
92
- status: violations.length ? 'fail' : 'pass',
93
- exitCode: violations.length ? 1 : 0,
94
- stderr: violations.join('\n'),
95
- diagnostics: violations.map((message) => ({ message })),
96
- };
97
- if (violations.length)
98
- exitCode = 1;
99
- }
100
- const profile = await readRuleProfile(projectRoot);
101
- if (profile.capabilities.includes('client-only')) {
102
- const findings = await clientOnlyBoundaryViolations(projectRoot);
103
- results['client-only-boundary'] = {
104
- status: findings.length ? 'fail' : 'pass',
105
- exitCode: findings.length ? 1 : 0,
106
- stderr: findings.join('\n'),
107
- diagnostics: findings.map((message) => ({ message })),
108
- };
109
- if (findings.length)
110
- exitCode = 1;
111
- }
112
- for (const [id, installed] of Object.entries(current.installed).sort(([a], [b]) => a.localeCompare(b))) {
113
- const entry = byId.get(id);
114
- if (!entry || installed.kind !== 'rule')
115
- continue;
116
- const prepared = await prepareCanonicalManifest(source, entry, canonicalCheckRoot, checkerRuntimeRoot);
117
- if (!prepared?.checkerPath) {
118
- if ((entry.enforcement ?? 'guidance') === 'guidance')
119
- continue;
120
- results[id] = {
121
- status: 'fail',
122
- exitCode: 1,
123
- stderr: 'Canonical checker unavailable for enforced installed rule.',
124
- };
125
- exitCode = 1;
126
- continue;
127
- }
128
- if (prepared.execution === 'manual')
129
- continue;
130
- const baseKey = prepared.checkerKey ??
131
- `path:${prepared.checkerPath}:${JSON.stringify(prepared.checkerArgs ?? [])}`;
132
- const key = `${baseKey}:targeting:${prepared.targeting?.scope ?? 'repository'}:execution:${prepared.execution ?? 'automatic'}`;
133
- const group = groups.get(key) ?? {
134
- checkerPath: prepared.checkerPath,
135
- checkerArgs: prepared.checkerArgs ?? [],
136
- targeting: prepared.targeting ?? { scope: 'repository' },
137
- ids: [],
138
- };
139
- group.ids.push(id);
140
- groups.set(key, group);
141
- }
142
- const groupExecutions = await runWithConcurrency([...groups.values()], options.concurrency ?? 6, async (group) => {
143
- const args = [group.checkerPath, ...group.checkerArgs];
144
- if (targetMode !== 'full' && group.targeting.scope !== 'repository') {
145
- args.push('--target-mode', targetMode);
146
- for (const file of normalizedTargetFiles)
147
- args.push('--target-file', file);
148
- }
149
- const execution = await executor('node', args, projectRoot);
150
- return { group, execution };
151
- });
152
- for (const { group, execution } of groupExecutions) {
153
- const result = { status: execution.exitCode === 0 ? 'pass' : 'fail', ...execution };
154
- for (const id of group.ids)
155
- results[id] = result;
156
- if (execution.exitCode !== 0)
157
- exitCode = 1;
158
- }
159
- const orderedResults = Object.fromEntries(Object.entries(results).sort(([a], [b]) => a.localeCompare(b)));
160
- if (targetMode === 'full') {
161
- await writeChecksState(projectRoot, {
162
- schemaVersion: 2,
163
- checkedAt: new Date().toISOString(),
164
- results: Object.fromEntries(Object.entries(orderedResults).map(([id, result]) => [id, { status: result.status }])),
165
- });
166
- }
167
- return {
168
- exitCode,
169
- results: orderedResults,
170
- executions: groupExecutions.map(({ group, execution }) => ({
171
- ids: [...group.ids].sort(),
172
- checkerPath: group.checkerPath,
173
- exitCode: execution.exitCode,
174
- stdout: execution.stdout,
175
- stderr: execution.stderr,
176
- })),
177
- };
178
- }
@@ -1,52 +0,0 @@
1
- export declare const RULE_PROFILE_RELATIVE_PATH = ".spd/rules.json";
2
- export declare const PROJECT_TYPES: readonly string[];
3
- export declare const EMPTY_RULE_PROFILE: Readonly<{
4
- schemaVersion: 1;
5
- projectType: null;
6
- capabilities: never[];
7
- include: never[];
8
- exclude: never[];
9
- }>;
10
- export declare function validateRuleProfile(profile: unknown): {
11
- schemaVersion: number;
12
- projectType: string | null;
13
- capabilities: unknown[];
14
- include: unknown[];
15
- exclude: {
16
- id: string;
17
- reason: string;
18
- }[];
19
- };
20
- export declare function readRuleProfile(projectRoot: string): Promise<{
21
- schemaVersion: number;
22
- projectType: string | null;
23
- capabilities: unknown[];
24
- include: unknown[];
25
- exclude: {
26
- id: string;
27
- reason: string;
28
- }[];
29
- }>;
30
- export declare function assertKnownRuleOverrides(entries: any[], profile: any): void;
31
- export declare function resolveProjectType(stack: string | null, profile?: any): any;
32
- export declare const STACK_PACKAGES: Record<string, string[]>;
33
- export declare function ruleApplies(entry: any, stack: string | null, profile?: any, packageIds?: Iterable<string>): boolean;
34
- export declare function projectRuleApplies(entry: any, stack: string | null, profile?: any, entries?: any[], packageIds?: Iterable<string>): any;
35
- export declare function applicableCatalogEntries(entries: any[], stack: string | null, profile?: any, packageIds?: Iterable<string>): any[];
36
- export declare function detectProjectStack(projectRoot: string): Promise<string | null>;
37
- export declare function resolveProjectStack(projectRoot: string): Promise<any>;
38
- export declare function loadProjectContext(projectRoot: string, entries: any[]): Promise<{
39
- stack: any;
40
- profile: {
41
- schemaVersion: number;
42
- projectType: string | null;
43
- capabilities: unknown[];
44
- include: unknown[];
45
- exclude: {
46
- id: string;
47
- reason: string;
48
- }[];
49
- };
50
- projectType: any;
51
- applicable: any[];
52
- }>;