@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
- export declare function checkFlags(args: string[]): {
2
- refresh: boolean;
3
- json: boolean;
4
- mode: "full" | "staged" | "files";
5
- files: string[] | null;
6
- };
7
- export declare function createCanonicalCommandHandlers(projectRoot?: string, options?: any): {
8
- add: (args: string[], io: any) => Promise<0 | 1 | 2>;
9
- status: (args: string[], io: any) => Promise<0 | 1>;
10
- sync: (args: string[], io: any) => Promise<0 | 2>;
11
- check: (args: string[], io: any) => Promise<number>;
12
- rules: (args: string[], io: any) => Promise<number>;
13
- 'ai-instruction': (args: string[], io: any) => Promise<0 | 2>;
14
- doctor: (args: string[], io: any) => Promise<0 | 1 | 2>;
15
- };
@@ -1,188 +0,0 @@
1
- import { createCanonicalSource } from "./canonical-source.js";
2
- import { canonicalCheck } from "./project-check.js";
3
- import { aiInstructionText, canonicalRules } from "./project-rules.js";
4
- import { canonicalDoctor, canonicalStatus } from "./project-status.js";
5
- import { addPredefinedPackage } from "./predefined-packages/index.js";
6
- import { canonicalSync } from "./project-sync.js";
7
- function flags(args) {
8
- const known = new Set(['--refresh', '--json']);
9
- for (const arg of args)
10
- if (!known.has(arg))
11
- throw new Error(`Unknown option: ${arg}`);
12
- return { refresh: args.includes('--refresh'), json: args.includes('--json') };
13
- }
14
- export function checkFlags(args) {
15
- const result = {
16
- refresh: false,
17
- json: false,
18
- mode: 'full',
19
- files: null,
20
- };
21
- const remaining = [];
22
- for (const arg of args) {
23
- if (arg === '--refresh')
24
- result.refresh = true;
25
- else if (arg === '--json')
26
- result.json = true;
27
- else
28
- remaining.push(arg);
29
- }
30
- if (remaining.includes('--staged') && remaining.includes('--files'))
31
- throw new Error('Use either --staged or --files, not both');
32
- if (remaining.includes('--staged')) {
33
- if (remaining.length !== 1)
34
- throw new Error('Usage: specdest check [--refresh] [--json] [--staged | --files <path...>]');
35
- result.mode = 'staged';
36
- return result;
37
- }
38
- const filesIndex = remaining.indexOf('--files');
39
- if (filesIndex >= 0) {
40
- if (filesIndex !== 0 || remaining.length < 2)
41
- throw new Error('Usage: specdest check [--refresh] [--json] [--staged | --files <path...>]');
42
- result.mode = 'files';
43
- result.files = remaining.slice(1);
44
- return result;
45
- }
46
- if (remaining.length)
47
- throw new Error(`Unknown option: ${remaining[0]}`);
48
- return result;
49
- }
50
- function rulesFlags(args) {
51
- const result = {
52
- json: false,
53
- ids: [],
54
- categories: [],
55
- failed: false,
56
- };
57
- for (let index = 0; index < args.length; index += 1) {
58
- const arg = args[index];
59
- if (arg === '--json')
60
- result.json = true;
61
- else if (arg === '--failed')
62
- result.failed = true;
63
- else if (arg === '--id' && args[index + 1])
64
- result.ids.push(args[++index]);
65
- else if (arg === '--category' && args[index + 1])
66
- result.categories.push(args[++index]);
67
- else
68
- throw new Error(`Unknown option: ${arg}`);
69
- }
70
- return result;
71
- }
72
- export function createCanonicalCommandHandlers(projectRoot = process.cwd(), options = {}) {
73
- const source = options.source ?? createCanonicalSource(options);
74
- return {
75
- add: async (args, io) => {
76
- if (args.length !== 1) {
77
- io.stderr.write('Usage: specdest add <package>\n');
78
- return 2;
79
- }
80
- try {
81
- const result = await addPredefinedPackage(projectRoot, args[0]);
82
- const setup = result.setupPackages?.length
83
- ? `; ensured stack setup: ${result.setupPackages.join(', ')}`
84
- : '';
85
- io.stdout.write(result.changed
86
- ? `Registered ${result.id} (recipe ${result.recipeVersion}, detected ${result.detectedVersion ?? 'unknown'}, ${result.source})${setup}\n`
87
- : `${result.id} already registered (recipe ${result.recipeVersion}, detected ${result.detectedVersion ?? 'unknown'}); no changes${setup}.\n`);
88
- return 0;
89
- }
90
- catch (error) {
91
- io.stderr.write(`${error.message}\n`);
92
- return 1;
93
- }
94
- },
95
- status: async (args, io) => {
96
- const parsed = flags(args);
97
- const result = await canonicalStatus(projectRoot, source, { refresh: parsed.refresh });
98
- if (parsed.json)
99
- io.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
100
- else {
101
- io.stdout.write(`Stack: ${result.stack ?? 'unknown'}\nApplicable: ${result.totals.applicable} Current: ${result.totals.current} Missing: ${result.totals.missing} Outdated: ${result.totals.outdated}\n`);
102
- if (result.packages.length)
103
- io.stdout.write(`Packages: ${result.packages.map((item) => `${item.id}@${item.detectedVersion ?? 'unknown'} (recipe ${item.recipeVersion ?? 'unknown'})`).join(', ')}\n`);
104
- for (const issue of result.packageIssues)
105
- io.stderr.write(`FAIL ${issue}\n`);
106
- }
107
- return result.totals.missing || result.totals.outdated || result.packageIssues.length ? 1 : 0;
108
- },
109
- sync: async (args, io) => {
110
- if (args.length) {
111
- io.stderr.write('Usage: specdest sync\n');
112
- return 2;
113
- }
114
- const result = await canonicalSync(projectRoot, source);
115
- io.stdout.write(`Synced ${result.applicable} applicable rules; ${result.changed.length} changed.\n`);
116
- for (const item of result.changed)
117
- io.stdout.write(`${item.action.toUpperCase()} ${item.id}@${item.version}\n`);
118
- return 0;
119
- },
120
- check: async (args, io) => {
121
- let parsed;
122
- try {
123
- parsed = checkFlags(args);
124
- }
125
- catch (error) {
126
- io.stderr.write(`${error.message}\n`);
127
- return 2;
128
- }
129
- const result = await canonicalCheck(projectRoot, source, parsed);
130
- if (result.versionProblems?.length && !parsed.json) {
131
- for (const problem of result.versionProblems) {
132
- io.stderr.write(`FAIL stale rule ${problem.id}: installed ${problem.installedVersion}, canonical ${problem.requiredVersion}${problem.contentMismatch ? ' (content hash mismatch)' : ''}.\n`);
133
- }
134
- io.stderr.write('No validators executed. Run `pnpm exec specdest sync`, commit `.spd/installed.json`, then retry.\n');
135
- }
136
- if (parsed.json) {
137
- io.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
138
- return result.exitCode;
139
- }
140
- for (const [id, check] of Object.entries(result.results)) {
141
- io.stdout.write(`${check.status.toUpperCase()} ${id}\n`);
142
- }
143
- for (const execution of result.executions.filter((item) => item.exitCode !== 0)) {
144
- io.stderr.write(`\nChecker failure (${execution.ids.join(', ')}):\n`);
145
- if (execution.stdout)
146
- io.stderr.write(execution.stdout.endsWith('\n') ? execution.stdout : `${execution.stdout}\n`);
147
- if (execution.stderr)
148
- io.stderr.write(execution.stderr.endsWith('\n') ? execution.stderr : `${execution.stderr}\n`);
149
- }
150
- return result.exitCode;
151
- },
152
- rules: async (args, io) => {
153
- const parsed = rulesFlags(args);
154
- const result = await canonicalRules(projectRoot, source, parsed);
155
- if (parsed.json)
156
- io.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
157
- else {
158
- for (const rule of result.rules) {
159
- const body = result.detail ? rule.content.trim() : rule.summary;
160
- const composition = rule.composedOf.length
161
- ? `\nComposed of: ${rule.composedOf.join(', ')}`
162
- : '';
163
- io.stdout.write(`## ${rule.id} — ${rule.name}\n${body}${composition}\n\n`);
164
- }
165
- }
166
- return 0;
167
- },
168
- 'ai-instruction': async (args, io) => {
169
- if (args.length) {
170
- io.stderr.write('Usage: specdest ai-instruction\n');
171
- return 2;
172
- }
173
- io.stdout.write(`${aiInstructionText()}\n`);
174
- return 0;
175
- },
176
- doctor: async (args, io) => {
177
- if (args.length) {
178
- io.stderr.write('Usage: specdest doctor\n');
179
- return 2;
180
- }
181
- const result = await canonicalDoctor(projectRoot, source);
182
- io.stdout.write(`Cache: ${result.cacheRoot}\nStack: ${result.stack ?? 'unknown'}\n`);
183
- for (const issue of result.issues)
184
- io.stderr.write(`FAIL ${issue}\n`);
185
- return result.ok ? 0 : 1;
186
- },
187
- };
188
- }
@@ -1,40 +0,0 @@
1
- type ProjectProfiles = Record<string, {
2
- ruleIds: string[];
3
- }>;
4
- type GitCatalogEntry = {
5
- id: string;
6
- kind: 'rule' | 'module';
7
- version: string;
8
- name: string;
9
- content: string;
10
- order: number;
11
- source: string;
12
- revision: string;
13
- contentHash: string;
14
- summary?: string;
15
- category?: string;
16
- scope?: string;
17
- labels?: string[];
18
- enforcement?: string;
19
- legacyInstalledIds?: string[];
20
- applicableStacks?: string[];
21
- requiredPackages?: string[];
22
- requiredCapabilities?: string[];
23
- composedOf?: string[];
24
- notApplicableRuleIds?: string[];
25
- projectProfiles?: ProjectProfiles;
26
- ai?: unknown;
27
- verification?: unknown;
28
- };
29
- export declare function buildGitCatalog({ modulesRoot, repositoryRevision, }: {
30
- modulesRoot: string;
31
- repositoryRevision?: string;
32
- }): Promise<{
33
- schemaVersion: number;
34
- package: {
35
- name: string;
36
- version: string;
37
- };
38
- entries: GitCatalogEntry[];
39
- }>;
40
- export {};
@@ -1,222 +0,0 @@
1
- import { createHash } from 'node:crypto';
2
- import { readdir, readFile } from 'node:fs/promises';
3
- import { join } from 'node:path';
4
- import { CanonicalManifestSchema, parseWithSchema } from "./schemas.js";
5
- const sha256 = (value) => createHash('sha256').update(value).digest('hex');
6
- const legacyImplementationFamilies = new Map([
7
- ['abac-permissions-supabase', ['abac-permissions-convex', 'abac-permissions-supabase']],
8
- [
9
- 'layers-and-contracts',
10
- ['layers-and-contracts', 'layers-and-contracts-convex', 'layers-and-contracts-supabase'],
11
- ],
12
- ['unit-test-rules', ['unit-test-rules', 'unit-test-rules-convex', 'unit-test-rules-supabase']],
13
- [
14
- 'unit-test-rules-supabase',
15
- ['unit-test-rules', 'unit-test-rules-convex', 'unit-test-rules-supabase'],
16
- ],
17
- ]);
18
- function legacyImplementationIds(manifest) {
19
- const implementation = manifest.checker?.implementation;
20
- if (!implementation || implementation === manifest.id)
21
- return [];
22
- return legacyImplementationFamilies.get(implementation) ?? [implementation];
23
- }
24
- async function moduleFiles(root) {
25
- const files = [];
26
- const walk = async (dir, prefix = '') => {
27
- for (const entry of (await readdir(dir, { withFileTypes: true })).sort((a, b) => a.name.localeCompare(b.name))) {
28
- const relative = prefix ? `${prefix}/${entry.name}` : entry.name;
29
- if (entry.isDirectory())
30
- await walk(join(dir, entry.name), relative);
31
- else if (entry.isFile())
32
- files.push({ path: relative, content: await readFile(join(dir, entry.name), 'utf8') });
33
- }
34
- };
35
- await walk(root);
36
- return files.sort((a, b) => a.path.localeCompare(b.path));
37
- }
38
- function title(content, id) {
39
- return content.match(/^#\s+(.+)$/mu)?.[1]?.trim() || id;
40
- }
41
- function summary(content, fallback) {
42
- const normalized = String(content ?? '').replace(/\r\n?/gu, '\n');
43
- const intent = normalized.match(/(?:^|\n)## Intent\s*\n+([^#][\s\S]*?)(?=\n## |$)/u)?.[1]?.trim();
44
- const source = intent ||
45
- normalized
46
- .split('\n')
47
- .map((line) => line.trim())
48
- .find((line) => line && !line.startsWith('#')) ||
49
- fallback;
50
- return source
51
- .replace(/^\*\*Rule:\*\*\s*/u, '')
52
- .replace(/\s+/gu, ' ')
53
- .slice(0, 240)
54
- .trim();
55
- }
56
- function canonicalVersion(manifest) {
57
- const version = String(manifest.version ?? '');
58
- if (!/^\d+\.\d+\.\d+$/u.test(version)) {
59
- throw new Error(`Canonical catalog entry requires SemVer version: ${manifest.id}`);
60
- }
61
- return version;
62
- }
63
- function catalogKind(manifest) {
64
- const kind = manifest.kind ?? 'rule';
65
- if (!['rule', 'module'].includes(kind))
66
- throw new Error(`Invalid canonical kind: ${manifest.id}`);
67
- return kind;
68
- }
69
- function notApplicableRuleIds(manifest) {
70
- if (!Array.isArray(manifest.notApplicableRuleIds))
71
- return undefined;
72
- return [...new Set(manifest.notApplicableRuleIds.map(String))].sort();
73
- }
74
- function projectProfiles(manifest) {
75
- if (!manifest.projectProfiles)
76
- return undefined;
77
- if (typeof manifest.projectProfiles !== 'object' || Array.isArray(manifest.projectProfiles)) {
78
- throw new Error(`Invalid projectProfiles: ${manifest.id}`);
79
- }
80
- return Object.fromEntries(Object.entries(manifest.projectProfiles)
81
- .sort(([a], [b]) => a.localeCompare(b))
82
- .map(([name, definition]) => {
83
- if (!definition || !Array.isArray(definition.ruleIds) || definition.ruleIds.length === 0) {
84
- throw new Error(`Invalid project profile: ${manifest.id}:${name}`);
85
- }
86
- return [name, { ruleIds: [...new Set(definition.ruleIds.map(String))].sort() }];
87
- }));
88
- }
89
- function stringList(value) {
90
- if (!Array.isArray(value) || value.length === 0)
91
- return undefined;
92
- return [
93
- ...new Set(value
94
- .map(String)
95
- .map((item) => item.trim())
96
- .filter(Boolean)),
97
- ].sort();
98
- }
99
- function applicableStacks(manifest) {
100
- if (!Array.isArray(manifest.applicableStacks) || manifest.applicableStacks.length === 0)
101
- return undefined;
102
- return [...new Set(manifest.applicableStacks.map(String))].sort();
103
- }
104
- function requiredPackages(manifest) {
105
- return stringList(manifest.requiredPackages);
106
- }
107
- function validateRuleApplicability(manifest) {
108
- if (manifest.scope !== 'Stack-specific')
109
- return;
110
- if (!applicableStacks(manifest) && !requiredPackages(manifest)) {
111
- throw new Error(`Stack-specific rule requires applicableStacks or requiredPackages: ${manifest.id}`);
112
- }
113
- }
114
- export async function buildGitCatalog({ modulesRoot, repositoryRevision = 'working-tree', }) {
115
- const directories = (await readdir(modulesRoot, { withFileTypes: true }))
116
- .filter((entry) => entry.isDirectory())
117
- .sort((a, b) => a.name.localeCompare(b.name));
118
- const modules = [];
119
- for (const directory of directories) {
120
- const root = join(modulesRoot, directory.name);
121
- const files = await moduleFiles(root);
122
- const manifestFile = files.find((file) => file.path === 'manifest.json');
123
- if (!manifestFile)
124
- throw new Error(`Missing manifest.json: ${directory.name}`);
125
- const manifest = parseWithSchema(CanonicalManifestSchema, JSON.parse(manifestFile.content), `canonical manifest ${directory.name}`);
126
- if (manifest.id !== directory.name)
127
- throw new Error(`Module id/path mismatch: ${directory.name}`);
128
- modules.push({ files, manifest, ownContentHash: sha256(JSON.stringify(files)) });
129
- }
130
- const canonicalCheckHash = modules.find(({ manifest }) => manifest.id === 'canonical-check')?.ownContentHash ?? null;
131
- const entries = [];
132
- for (const { files, manifest, ownContentHash } of modules) {
133
- const contentHash = manifest.checker?.path && canonicalCheckHash
134
- ? sha256(JSON.stringify({ ownContentHash, canonicalCheckHash }))
135
- : ownContentHash;
136
- const guidance = files.find((file) => /(^|\/)rule\.md$/u.test(file.path) || /(^|\/)SKILL\.md$/u.test(file.path))?.content ?? '';
137
- const kind = catalogKind(manifest);
138
- if (kind === 'rule')
139
- validateRuleApplicability(manifest);
140
- entries.push({
141
- id: manifest.id,
142
- kind,
143
- version: canonicalVersion(manifest),
144
- name: title(guidance, manifest.id),
145
- content: guidance,
146
- ...(kind === 'rule' ? { summary: summary(guidance, manifest.name ?? manifest.id) } : {}),
147
- ...(kind === 'rule' && manifest.category ? { category: String(manifest.category) } : {}),
148
- ...(kind === 'rule' && manifest.scope ? { scope: String(manifest.scope) } : {}),
149
- ...(kind === 'rule' && stringList(manifest.labels)
150
- ? { labels: stringList(manifest.labels) }
151
- : {}),
152
- order: entries.length + 1,
153
- source: 'private-devkit-git',
154
- revision: repositoryRevision,
155
- contentHash,
156
- ...(kind === 'rule' ? { legacyInstalledIds: legacyImplementationIds(manifest) } : {}),
157
- ...(kind === 'rule' ? { enforcement: String(manifest.enforcement ?? 'guidance') } : {}),
158
- ...(kind === 'rule' && applicableStacks(manifest)
159
- ? { applicableStacks: applicableStacks(manifest) }
160
- : {}),
161
- ...(kind === 'rule' && requiredPackages(manifest)
162
- ? { requiredPackages: requiredPackages(manifest) }
163
- : {}),
164
- ...(kind === 'rule' && stringList(manifest.requiredCapabilities)
165
- ? { requiredCapabilities: stringList(manifest.requiredCapabilities) }
166
- : {}),
167
- ...(kind === 'rule' && manifest.ai ? { ai: manifest.ai } : {}),
168
- ...(kind === 'rule' && manifest.verification ? { verification: manifest.verification } : {}),
169
- ...(kind === 'rule' && stringList(manifest.composedOf)
170
- ? { composedOf: stringList(manifest.composedOf) }
171
- : {}),
172
- ...(kind === 'module' && notApplicableRuleIds(manifest)
173
- ? { notApplicableRuleIds: notApplicableRuleIds(manifest) }
174
- : {}),
175
- ...(kind === 'module' && projectProfiles(manifest)
176
- ? { projectProfiles: projectProfiles(manifest) }
177
- : {}),
178
- });
179
- }
180
- const ruleIds = new Set(entries.filter((entry) => entry.kind === 'rule').map((entry) => entry.id));
181
- for (const entry of entries) {
182
- for (const ruleId of entry.notApplicableRuleIds ?? []) {
183
- if (!ruleIds.has(ruleId))
184
- throw new Error(`Unknown not-applicable rule: ${entry.id}:${ruleId}`);
185
- }
186
- for (const [profileName, definition] of Object.entries(entry.projectProfiles ?? {})) {
187
- for (const ruleId of definition.ruleIds) {
188
- if (!ruleIds.has(ruleId))
189
- throw new Error(`Unknown project-profile rule: ${entry.id}:${profileName}:${ruleId}`);
190
- }
191
- }
192
- for (const childId of entry.composedOf ?? []) {
193
- if (!ruleIds.has(childId))
194
- throw new Error(`Unknown composed rule: ${entry.id}:${childId}`);
195
- if (childId === entry.id)
196
- throw new Error(`Rule cannot compose itself: ${entry.id}`);
197
- }
198
- }
199
- const composition = new Map(entries
200
- .filter((entry) => entry.kind === 'rule')
201
- .map((entry) => [entry.id, entry.composedOf ?? []]));
202
- const visiting = new Set();
203
- const visited = new Set();
204
- const visit = (id) => {
205
- if (visiting.has(id))
206
- throw new Error(`Rule composition cycle: ${id}`);
207
- if (visited.has(id))
208
- return;
209
- visiting.add(id);
210
- for (const childId of composition.get(id) ?? [])
211
- visit(childId);
212
- visiting.delete(id);
213
- visited.add(id);
214
- };
215
- for (const id of composition.keys())
216
- visit(id);
217
- return {
218
- schemaVersion: 1,
219
- package: { name: '@specdest/devkit', version: repositoryRevision },
220
- entries,
221
- };
222
- }
@@ -1,9 +0,0 @@
1
- import { spawnSync } from 'node:child_process';
2
- declare const TOOLS: {
3
- readonly device: "agent-device";
4
- readonly browser: "agent-browser";
5
- readonly 'jev-browser': "jev-browser";
6
- };
7
- /** Forward unchanged arguments through Controller's queue, or its trusted NPS host context. */
8
- export declare function runHostAutomation(command: keyof typeof TOOLS, args: string[], cwd?: string, invoke?: typeof spawnSync, gatewayExists?: (path: string) => boolean, env?: Record<string, string | undefined>): number;
9
- export {};
@@ -1,66 +0,0 @@
1
- import { spawnSync } from 'node:child_process';
2
- import { existsSync, readFileSync } from 'node:fs';
3
- import { basename, resolve } from 'node:path';
4
- import { projectFromCwd } from "./supabase-local.js";
5
- const TOOLS = {
6
- device: 'agent-device',
7
- browser: 'agent-browser',
8
- 'jev-browser': 'jev-browser',
9
- };
10
- const NPS_BIN_ENV = {
11
- device: 'SPECDEST_DEVKIT_AGENT_DEVICE_BIN',
12
- browser: 'SPECDEST_DEVKIT_AGENT_BROWSER_BIN',
13
- 'jev-browser': 'SPECDEST_DEVKIT_JEV_BROWSER_BIN',
14
- };
15
- /** Forward unchanged arguments through Controller's queue, or its trusted NPS host context. */
16
- export function runHostAutomation(command, args, cwd = process.cwd(), invoke = spawnSync, gatewayExists = existsSync, env = process.env) {
17
- // Non-Supabase admin frontend: identity is used only to request access;
18
- // Controller's root-owned allowlist still decides whether automation is authorized.
19
- const adminManifest = resolve(cwd, 'package.json');
20
- const isAdmin = basename(resolve(cwd)) === 'mycone-admin' &&
21
- existsSync(adminManifest) &&
22
- (() => {
23
- try {
24
- return JSON.parse(readFileSync(adminManifest, 'utf8')).name === 'mycone-admin';
25
- }
26
- catch {
27
- return false;
28
- }
29
- })();
30
- const project = projectFromCwd(cwd) ?? (isAdmin ? 'mycone-admin' : undefined);
31
- if (!project) {
32
- process.stderr.write('Controller project registration required.\n');
33
- return 2;
34
- }
35
- if (!args.length) {
36
- process.stderr.write(`Usage: specdest ${command} <subcommand> [args...]\n`);
37
- return 2;
38
- }
39
- // NPS executes inside the Mac gateway worker. Re-enqueuing to that worker
40
- // would deadlock, so use the trusted host path injected by Controller.
41
- if (env.SPECDEST_DEVKIT_GATEWAY_NPS === '1') {
42
- const binary = env[NPS_BIN_ENV[command]];
43
- if (!binary?.startsWith('/') || !gatewayExists(binary)) {
44
- process.stderr.write('Controller did not authorize this host automation binary.\n');
45
- return 1;
46
- }
47
- const result = invoke(binary, args, { stdio: 'inherit', shell: false });
48
- if (result.error)
49
- process.stderr.write(`${result.error.message}\n`);
50
- return result.error ? 1 : (result.status ?? 1);
51
- }
52
- const client = '/usr/local/bin/host-cli';
53
- if (!gatewayExists(client)) {
54
- process.stderr.write('Controller gateway client unavailable.\n');
55
- return 1;
56
- }
57
- const result = invoke(client, ['devkit-automation', project, TOOLS[command], ...args], {
58
- stdio: 'inherit',
59
- shell: false,
60
- });
61
- if (result.error) {
62
- process.stderr.write(`${result.error.message}\n`);
63
- return 1;
64
- }
65
- return result.status ?? 1;
66
- }
@@ -1,3 +0,0 @@
1
- export declare function resolveProjectPath(projectRoot: string, relativePath: string): string;
2
- export declare function upsertMarkdownSection(existing: string, heading: string, body: string): string;
3
- export declare function removeMarkdownSection(existing: string, heading: string): string;
@@ -1,50 +0,0 @@
1
- import { isAbsolute, resolve, sep } from 'node:path';
2
- export function resolveProjectPath(projectRoot, relativePath) {
3
- if (!relativePath || isAbsolute(relativePath)) {
4
- throw new Error(`Path must be project-relative: ${relativePath}`);
5
- }
6
- const root = resolve(projectRoot);
7
- const target = resolve(root, relativePath);
8
- if (target !== root && !target.startsWith(`${root}${sep}`)) {
9
- throw new Error(`Path escapes project: ${relativePath}`);
10
- }
11
- return target;
12
- }
13
- function markdownSectionBounds(existing, heading) {
14
- const trimmed = heading.trim();
15
- const level = trimmed.match(/^(#{1,6})\s+/)?.[1].length ?? 2;
16
- const lines = existing.split(/(?<=\n)/);
17
- let offset = 0;
18
- let start = -1;
19
- let end = existing.length;
20
- for (const line of lines) {
21
- if (start < 0 && line.trim() === trimmed)
22
- start = offset;
23
- else if (start >= 0 && new RegExp(`^#{1,${level}}\\s+`).test(line.trim())) {
24
- end = offset;
25
- break;
26
- }
27
- offset += line.length;
28
- }
29
- return start >= 0 ? [start, end] : null;
30
- }
31
- export function upsertMarkdownSection(existing, heading, body) {
32
- const block = `${heading.trim()}\n\n${body.trim()}\n`;
33
- const bounds = markdownSectionBounds(existing, heading);
34
- if (!bounds)
35
- return `${existing.trimEnd()}${existing.trim() ? '\n\n' : ''}${block}`;
36
- const [start, end] = bounds;
37
- const before = existing.slice(0, start).trimEnd();
38
- const after = existing.slice(end).trim();
39
- return `${[before, block.trimEnd(), after].filter(Boolean).join('\n\n')}\n`;
40
- }
41
- export function removeMarkdownSection(existing, heading) {
42
- const bounds = markdownSectionBounds(existing, heading);
43
- if (!bounds)
44
- return existing;
45
- const [start, end] = bounds;
46
- const updated = `${existing.slice(0, start).trimEnd()}\n\n${existing.slice(end).trimStart()}`
47
- .replace(/\n{3,}/g, '\n\n')
48
- .trimEnd();
49
- return updated ? `${updated}\n` : '';
50
- }
@@ -1,2 +0,0 @@
1
- import type { PackageRecipe } from './types.ts';
2
- export declare const abacRecipe: PackageRecipe;
@@ -1,22 +0,0 @@
1
- import { detectAnyPath } from "./project-signals.js";
2
- export const abacRecipe = {
3
- id: 'abac',
4
- recipeVersion: '1.0.0',
5
- role: 'feature',
6
- requires: ['auth'],
7
- variants: [
8
- { id: 'supabase', when: ['supabase'] },
9
- { id: 'convex', when: ['convex'] },
10
- ],
11
- async detect(projectRoot) {
12
- return await detectAnyPath(projectRoot, ['src/lib/permissions.ts', 'src/permissions', 'src/policies', 'src/features/permissions'], 'ABAC policy integration was not detected');
13
- },
14
- async apply(_projectRoot, detection, _resolution) {
15
- if (!detection.present) {
16
- throw new Error('ABAC is not implemented in this project; creating ABAC policy code is not supported by `add abac` yet.');
17
- }
18
- if (!detection.compatible)
19
- throw new Error(detection.reason ?? 'Existing ABAC integration is not compatible.');
20
- return { source: 'adopted' };
21
- },
22
- };
@@ -1,46 +0,0 @@
1
- import type { ReactNode } from 'react';
2
- import {
3
- AlertDialog,
4
- AlertDialogAction,
5
- AlertDialogCancel,
6
- AlertDialogContent,
7
- AlertDialogDescription,
8
- AlertDialogFooter,
9
- AlertDialogHeader,
10
- AlertDialogTitle,
11
- AlertDialogTrigger,
12
- } from '@/components/ui/alert-dialog';
13
-
14
- type AdminConfirmDialogProps = {
15
- trigger: ReactNode;
16
- title: ReactNode;
17
- description: ReactNode;
18
- onConfirm: () => void;
19
- confirmLabel?: string;
20
- cancelLabel?: string;
21
- };
22
-
23
- export function AdminConfirmDialog({
24
- trigger,
25
- title,
26
- description,
27
- onConfirm,
28
- confirmLabel = 'Confirm',
29
- cancelLabel = 'Cancel',
30
- }: AdminConfirmDialogProps) {
31
- return (
32
- <AlertDialog>
33
- <AlertDialogTrigger asChild>{trigger}</AlertDialogTrigger>
34
- <AlertDialogContent>
35
- <AlertDialogHeader>
36
- <AlertDialogTitle>{title}</AlertDialogTitle>
37
- <AlertDialogDescription>{description}</AlertDialogDescription>
38
- </AlertDialogHeader>
39
- <AlertDialogFooter>
40
- <AlertDialogCancel>{cancelLabel}</AlertDialogCancel>
41
- <AlertDialogAction onClick={onConfirm}>{confirmLabel}</AlertDialogAction>
42
- </AlertDialogFooter>
43
- </AlertDialogContent>
44
- </AlertDialog>
45
- );
46
- }