@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,211 +0,0 @@
1
- import { readFile, readdir } from 'node:fs/promises';
2
- import { join } from 'node:path';
3
- import { PackageJsonSchema, RuleProfileSchema, parseWithSchema } from "./schemas.js";
4
- import { ensureMetadataNamespace, readInstalledState } from "./state.js";
5
- export const RULE_PROFILE_RELATIVE_PATH = '.spd/rules.json';
6
- export const PROJECT_TYPES = Object.freeze([
7
- 'product',
8
- 'static-site',
9
- 'tooling',
10
- 'backend',
11
- 'monorepo',
12
- 'generic',
13
- ]);
14
- export const EMPTY_RULE_PROFILE = Object.freeze({
15
- schemaVersion: 1,
16
- projectType: null,
17
- capabilities: [],
18
- include: [],
19
- exclude: [],
20
- });
21
- function uniqueStrings(values, label) {
22
- if (!Array.isArray(values ?? []))
23
- throw new Error(`Invalid ${label}`);
24
- return [
25
- ...new Set((values ?? [])
26
- .map(String)
27
- .map((value) => value.trim())
28
- .filter(Boolean)),
29
- ].sort();
30
- }
31
- export function validateRuleProfile(profile) {
32
- const validated = parseWithSchema(RuleProfileSchema, profile, '.spd/rules.json profile');
33
- const projectType = validated.projectType == null ? null : validated.projectType.trim();
34
- if (validated.projectType != null && !projectType)
35
- throw new Error('Invalid rule profile projectType');
36
- const capabilities = uniqueStrings(validated.capabilities, 'rule profile capabilities');
37
- const include = uniqueStrings(validated.include, 'rule profile include');
38
- const exclude = (validated.exclude ?? [])
39
- .map((item) => {
40
- if (!item ||
41
- typeof item !== 'object' ||
42
- !String(item.id ?? '').trim() ||
43
- !String(item.reason ?? '').trim()) {
44
- throw new Error('Rule exclusions require both id and non-empty reason');
45
- }
46
- return { id: String(item.id).trim(), reason: String(item.reason).trim() };
47
- })
48
- .sort((a, b) => a.id.localeCompare(b.id));
49
- return { schemaVersion: 1, projectType, capabilities, include, exclude };
50
- }
51
- export async function readRuleProfile(projectRoot) {
52
- await ensureMetadataNamespace(projectRoot);
53
- try {
54
- return validateRuleProfile(JSON.parse(await readFile(join(projectRoot, RULE_PROFILE_RELATIVE_PATH), 'utf8')));
55
- }
56
- catch (error) {
57
- if (error?.code === 'ENOENT')
58
- return { ...EMPTY_RULE_PROFILE, capabilities: [], include: [], exclude: [] };
59
- throw error;
60
- }
61
- }
62
- export function assertKnownRuleOverrides(entries, profile) {
63
- const ids = new Set(entries.filter((entry) => entry.kind === 'rule').map((entry) => entry.id));
64
- for (const id of profile.include ?? [])
65
- if (!ids.has(id))
66
- throw new Error(`Unknown included rule: ${id}`);
67
- for (const item of profile.exclude ?? [])
68
- if (!ids.has(item.id))
69
- throw new Error(`Unknown excluded rule: ${item.id}`);
70
- }
71
- export function resolveProjectType(stack, profile = EMPTY_RULE_PROFILE) {
72
- return profile.projectType ?? (stack ? 'product' : 'generic');
73
- }
74
- export const STACK_PACKAGES = {
75
- 'stack-vite-supabase': ['vite', 'supabase'],
76
- 'stack-vite-convex': ['vite', 'convex'],
77
- 'stack-expo-supabase': ['expo', 'supabase'],
78
- 'stack-expo-convex': ['expo', 'convex'],
79
- };
80
- function effectivePackages(stack, packageIds = []) {
81
- return new Set([...(stack ? (STACK_PACKAGES[stack] ?? []) : []), ...packageIds]);
82
- }
83
- const backendOnlyRuleIds = new Set(['db-schema-static-validation']);
84
- export function ruleApplies(entry, stack, profile = EMPTY_RULE_PROFILE, packageIds = []) {
85
- if (profile.capabilities?.includes('client-only') && backendOnlyRuleIds.has(entry.id))
86
- return false;
87
- const included = new Set(profile.include ?? []);
88
- const excluded = new Set((profile.exclude ?? []).map((item) => item.id));
89
- if (excluded.has(entry.id))
90
- return false;
91
- if (included.has(entry.id))
92
- return true;
93
- if (entry.applicableStacks?.length && (!stack || !entry.applicableStacks.includes(stack)))
94
- return false;
95
- const packages = effectivePackages(stack, packageIds);
96
- if (entry.requiredPackages?.some((id) => !packages.has(id)))
97
- return false;
98
- return capabilitySatisfied(entry, profile);
99
- }
100
- function profileDefinition(entries, projectType) {
101
- if (projectType === 'product')
102
- return null;
103
- const module = entries.find((entry) => entry.kind === 'module' && entry.id === 'project-profiles');
104
- const definition = module?.projectProfiles?.[projectType];
105
- if (!definition)
106
- throw new Error(`Canonical project profile not found: ${projectType}`);
107
- return definition;
108
- }
109
- function capabilitySatisfied(entry, profile) {
110
- const capabilities = new Set(profile.capabilities ?? []);
111
- return !entry.requiredCapabilities?.some((capability) => !capabilities.has(capability));
112
- }
113
- export function projectRuleApplies(entry, stack, profile = EMPTY_RULE_PROFILE, entries = [], packageIds = []) {
114
- if (profile.capabilities?.includes('client-only') && backendOnlyRuleIds.has(entry.id))
115
- return false;
116
- const included = new Set(profile.include ?? []);
117
- const excluded = new Set((profile.exclude ?? []).map((item) => item.id));
118
- if (excluded.has(entry.id))
119
- return false;
120
- if (included.has(entry.id))
121
- return true;
122
- const projectType = resolveProjectType(stack, profile);
123
- if (projectType === 'product')
124
- return ruleApplies(entry, stack, profile, packageIds);
125
- const definition = profileDefinition(entries, projectType);
126
- return definition.ruleIds.includes(entry.id) && capabilitySatisfied(entry, profile);
127
- }
128
- export function applicableCatalogEntries(entries, stack, profile = EMPTY_RULE_PROFILE, packageIds = []) {
129
- return entries
130
- .filter((entry) => entry.kind === 'rule')
131
- .filter((entry) => projectRuleApplies(entry, stack, profile, entries, packageIds))
132
- .sort((a, b) => a.id.localeCompare(b.id));
133
- }
134
- function stackFromDependencies(deps) {
135
- const frontends = [
136
- deps.expo ? 'expo' : null,
137
- deps.vite || deps['@vitejs/plugin-react'] ? 'vite' : null,
138
- ].filter(Boolean);
139
- const backends = [
140
- deps.convex ? 'convex' : null,
141
- deps['@supabase/supabase-js'] ? 'supabase' : null,
142
- ].filter(Boolean);
143
- if (frontends.length > 1)
144
- throw new Error(`Conflicting frontend packages detected: ${frontends.sort().join(', ')}`);
145
- if (backends.length > 1)
146
- throw new Error(`Conflicting backend packages detected: ${backends.sort().join(', ')}`);
147
- if (frontends.length !== 1 || backends.length !== 1)
148
- return null;
149
- return `stack-${frontends[0]}-${backends[0]}`;
150
- }
151
- async function readPackageDependencies(path) {
152
- try {
153
- const pkg = parseWithSchema(PackageJsonSchema, JSON.parse(await readFile(path, 'utf8')), `package.json at ${path}`);
154
- return { ...(pkg.dependencies ?? {}), ...(pkg.devDependencies ?? {}) };
155
- }
156
- catch (error) {
157
- if (error?.code === 'ENOENT')
158
- return null;
159
- throw error;
160
- }
161
- }
162
- export async function detectProjectStack(projectRoot) {
163
- const dependencySets = [];
164
- const rootDeps = await readPackageDependencies(join(projectRoot, 'package.json'));
165
- if (rootDeps)
166
- dependencySets.push(rootDeps);
167
- for (const group of ['apps', 'packages']) {
168
- let children = [];
169
- try {
170
- children = await readdir(join(projectRoot, group), { withFileTypes: true });
171
- }
172
- catch (error) {
173
- if (error?.code !== 'ENOENT')
174
- throw error;
175
- }
176
- for (const child of children.filter((entry) => entry.isDirectory())) {
177
- const deps = await readPackageDependencies(join(projectRoot, group, child.name, 'package.json'));
178
- if (deps)
179
- dependencySets.push(deps);
180
- }
181
- }
182
- const detected = new Set(dependencySets.map(stackFromDependencies).filter(Boolean));
183
- if (detected.size === 1)
184
- return [...detected][0];
185
- if (detected.size > 1)
186
- throw new Error(`Multiple canonical stacks detected: ${[...detected].sort().join(', ')}`);
187
- return stackFromDependencies(Object.assign({}, ...dependencySets));
188
- }
189
- export async function resolveProjectStack(projectRoot) {
190
- const detectedStack = await detectProjectStack(projectRoot);
191
- if (detectedStack)
192
- return detectedStack;
193
- const installedState = await readInstalledState(projectRoot);
194
- const requestedStacks = (installedState.requested ?? []).filter((id) => id.startsWith('stack-'));
195
- return requestedStacks.length === 1 ? requestedStacks[0] : null;
196
- }
197
- export async function loadProjectContext(projectRoot, entries) {
198
- const stack = await resolveProjectStack(projectRoot);
199
- const installedState = await readInstalledState(projectRoot);
200
- const packageIds = Object.entries(installedState.installed ?? {})
201
- .filter(([, value]) => value?.kind === 'package')
202
- .map(([id]) => id);
203
- const profile = await readRuleProfile(projectRoot);
204
- assertKnownRuleOverrides(entries, profile);
205
- return {
206
- stack,
207
- profile,
208
- projectType: resolveProjectType(stack, profile),
209
- applicable: applicableCatalogEntries(entries, stack, profile, packageIds),
210
- };
211
- }
@@ -1,2 +0,0 @@
1
- /** Reject project dependency declarations without blocking standalone CLI use. */
2
- export declare function assertStandaloneDevkit(cwd?: string): void;
@@ -1,51 +0,0 @@
1
- import { readFileSync } from 'node:fs';
2
- import { dirname, join, parse, resolve } from 'node:path';
3
- const PACKAGE = '@specdest/devkit';
4
- const DEPENDENCY_FIELDS = [
5
- 'dependencies',
6
- 'devDependencies',
7
- 'optionalDependencies',
8
- 'peerDependencies',
9
- ];
10
- /** Reject project dependency declarations without blocking standalone CLI use. */
11
- export function assertStandaloneDevkit(cwd = process.cwd()) {
12
- let current = resolve(cwd);
13
- while (true) {
14
- const manifest = join(current, 'package.json');
15
- let source;
16
- try {
17
- source = readFileSync(manifest, 'utf8');
18
- }
19
- catch (error) {
20
- if (error.code !== 'ENOENT')
21
- throw error;
22
- source = '';
23
- }
24
- if (source) {
25
- const packageJson = JSON.parse(source);
26
- if (packageJson && typeof packageJson === 'object') {
27
- const fields = packageJson;
28
- // Devkit's own checkout is not a consuming project.
29
- if (fields.name === PACKAGE)
30
- return;
31
- if (DEPENDENCY_FIELDS.some((field) => {
32
- const dependencies = fields[field];
33
- return (dependencies &&
34
- typeof dependencies === 'object' &&
35
- Object.hasOwn(dependencies, PACKAGE));
36
- })) {
37
- throw new Error(`ERROR: ${PACKAGE} must not be installed as a project dependency.\n\n` +
38
- `Remove it: pnpm remove -D ${PACKAGE}\n` +
39
- `Install globally: pnpm add -g ${PACKAGE}\n` +
40
- `Then run: specdest <command>\n` +
41
- `(Project: ${manifest})`);
42
- }
43
- }
44
- // The closest package manifest defines the current project boundary.
45
- return;
46
- }
47
- if (current === parse(current).root)
48
- return;
49
- current = dirname(current);
50
- }
51
- }
@@ -1,25 +0,0 @@
1
- export declare function aiInstructionText(): string;
2
- export declare function canonicalRules(projectRoot: string, source: any, options?: any): Promise<{
3
- stack: any;
4
- profile: {
5
- schemaVersion: number;
6
- projectType: string | null;
7
- capabilities: unknown[];
8
- include: unknown[];
9
- exclude: {
10
- id: string;
11
- reason: string;
12
- }[];
13
- };
14
- detail: boolean;
15
- rules: {
16
- content?: any;
17
- id: any;
18
- name: any;
19
- category: any;
20
- enforcement: any;
21
- aiLoad: any;
22
- summary: any;
23
- composedOf: any;
24
- }[];
25
- }>;
@@ -1,106 +0,0 @@
1
- import { loadCanonicalProjectContext } from "./project-runtime.js";
2
- import { assertPredefinedPackageState } from "./predefined-packages/health.js";
3
- import { readChecksState } from "./state.js";
4
- function aiMode(entry) {
5
- return entry.ai?.load ?? 'failure-only';
6
- }
7
- function ruleSummary(entry) {
8
- if (entry.summary)
9
- return String(entry.summary).trim();
10
- const content = String(entry.content ?? '').replace(/\r\n?/gu, '\n');
11
- const intent = content.match(/(?:^|\n)## Intent\s*\n+([^#][\s\S]*?)(?=\n## |$)/u)?.[1]?.trim();
12
- const source = intent ||
13
- content
14
- .split('\n')
15
- .map((line) => line.trim())
16
- .find((line) => line && !line.startsWith('#')) ||
17
- entry.name ||
18
- entry.id;
19
- return source
20
- .replace(/^\*\*Rule:\*\*\s*/u, '')
21
- .replace(/\s+/gu, ' ')
22
- .slice(0, 240)
23
- .trim();
24
- }
25
- export function aiInstructionText() {
26
- return [
27
- '# Specdest Development Instructions',
28
- '',
29
- 'Specdest Devkit governs repository engineering rules and deterministic development flow.',
30
- '',
31
- '## Environment and repository context',
32
- '- Use Local Coder MCP for repository operations. On macOS it runs inside Docker; do not assume direct host access.',
33
- '- Read `/workspace/specdest-company/tools/controller/AGENTS.md` for workspace/project structure, worktrees, host access, and supported development tools.',
34
- '- Locate the target repository and read its `AGENTS.md` / `CLAUDE.md`; inspect its relevant structure, architecture, documentation, and tests.',
35
- '- These instructions are the Devkit bootstrap. Do not duplicate Controller, project, or canonical Devkit rules.',
36
- '',
37
- '## Understand and prepare',
38
- '- Understand the intended outcome and whether code changes are requested. Analysis does not authorize implementation.',
39
- '- Inspect Git status and existing worktrees; use the agent development policy to classify the work and choose the appropriate worktree. Preserve unrelated changes.',
40
- '- Before repository work, inspect persisted Flow state with `npx @specdest/devkit flow status`. Do not infer persisted Flow state from chat history.',
41
- '- Follow an existing plan when provided, without recreating it. Ask only for clarification that materially blocks progress.',
42
- '- Start or resume an appropriate task using `npx @specdest/devkit flow start --mode <feature|fix|inspect> --goal <text> [--task <id>]` when no matching task exists.',
43
- '- Devkit Flow owns persisted task state, phase transitions, verification, and completion. Keep planning proportional to complexity.',
44
- '- Do not preload the full rule catalog. Before changing code, use `npx @specdest/devkit rules --category <category>` for compact relevant summaries, then `npx @specdest/devkit rules --id <rule>` only when full guidance is needed.',
45
- '',
46
- '## Execute',
47
- '- For implementation tasks, checkpoint with `npx @specdest/devkit flow checkpoint --phase implement` after planning.',
48
- '- Create or update relevant tests first where practical (TDD); reproduce bugs before fixing them.',
49
- '- Make the smallest change satisfying the request; reuse existing architecture, libraries, and conventions.',
50
- '- Update documentation when behavior or contracts change. For investigation, establish reproducible evidence; for performance, measure first; for UI, inspect rendered appearance.',
51
- '- Use relevant optional browser, device, screenshot, diagram, or other tooling through approved Controller/Devkit workflows only when needed.',
52
- '',
53
- '## Verify and complete',
54
- '- Run focused tests first, then relevant lint, formatting, typechecks, and repository-required gates, including `npx @specdest/devkit check` when applicable.',
55
- '- If Devkit checks fail, use `npx @specdest/devkit rules --failed` and fix violations without weakening rules.',
56
- '- For implementation flows, run `npx @specdest/devkit flow verify` with the repository-configured gate; verify actual UI when relevant.',
57
- '- Inspect the diff and stage only task changes; commit with existing Husky hooks enabled. Do not bypass failed checks.',
58
- '- Ensure verification remains current and use `npx @specdest/devkit flow complete` when appropriate. A commit changes Git state; rerun verification after committing if needed.',
59
- '- Do not push unless requested. Never commit secrets, runtime state, or unrelated changes.',
60
- '',
61
- '## Final response',
62
- '- Report only the requested result: changes, verification, commit hash, or investigation findings and grounded recommendations.',
63
- '- State actual blockers or remaining failures. Stop once the requested work and required verification are complete.',
64
- ].join('\n');
65
- }
66
- export async function canonicalRules(projectRoot, source, options = {}) {
67
- await assertPredefinedPackageState(projectRoot);
68
- const { stack, profile, applicable } = await loadCanonicalProjectContext(projectRoot, source);
69
- let selected = applicable;
70
- let detail = false;
71
- if (options.ids?.length) {
72
- const wanted = new Set(options.ids);
73
- selected = selected.filter((entry) => wanted.has(entry.id));
74
- detail = true;
75
- }
76
- else if (options.categories?.length) {
77
- const wanted = new Set(options.categories.map((value) => value.toLowerCase()));
78
- selected = selected.filter((entry) => wanted.has(String(entry.category ?? '').toLowerCase()));
79
- }
80
- else if (options.failed) {
81
- const state = await readChecksState(projectRoot);
82
- const failed = new Set(Object.entries(state.results ?? {})
83
- .filter(([, value]) => value.status === 'fail')
84
- .map(([id]) => id));
85
- selected = selected.filter((entry) => failed.has(entry.id));
86
- detail = true;
87
- }
88
- else {
89
- selected = selected.filter((entry) => aiMode(entry) === 'always');
90
- }
91
- return {
92
- stack,
93
- profile,
94
- detail,
95
- rules: selected.map((entry) => ({
96
- id: entry.id,
97
- name: entry.name,
98
- category: entry.category ?? null,
99
- enforcement: entry.enforcement ?? 'guidance',
100
- aiLoad: aiMode(entry),
101
- summary: ruleSummary(entry),
102
- composedOf: entry.composedOf ?? [],
103
- ...(detail ? { content: entry.content ?? '' } : {}),
104
- })),
105
- };
106
- }
@@ -1,21 +0,0 @@
1
- export declare function prepareCanonicalManifest(source: any, entry: any, canonicalCheckRoot: string | null, checkerRuntimeRoot: string | null, { offline }?: {
2
- offline?: boolean;
3
- }): Promise<any>;
4
- export declare function loadCanonicalProjectContext(projectRoot: string, source: any, options?: any): Promise<{
5
- catalog: any;
6
- stack: any;
7
- projectType: any;
8
- profile: {
9
- schemaVersion: number;
10
- projectType: string | null;
11
- capabilities: unknown[];
12
- include: unknown[];
13
- exclude: {
14
- id: string;
15
- reason: string;
16
- }[];
17
- };
18
- applicable: any[];
19
- canonicalCheckRoot: any;
20
- checkerRuntimeRoot: any;
21
- }>;
@@ -1,41 +0,0 @@
1
- import { prepareCachedManifest } from "./canonical-project.js";
2
- import { loadProjectContext } from "./project-context.js";
3
- export async function prepareCanonicalManifest(source, entry, canonicalCheckRoot, checkerRuntimeRoot, { offline = false } = {}) {
4
- if (offline && !(await source.hasModule(entry.id, entry.version, entry.contentHash)))
5
- return null;
6
- const root = await source.module(entry.id, entry.version, { contentHash: entry.contentHash });
7
- return await prepareCachedManifest(entry, root, canonicalCheckRoot, checkerRuntimeRoot);
8
- }
9
- export async function loadCanonicalProjectContext(projectRoot, source, options = {}) {
10
- const catalog = await source.catalog({ refresh: options.refresh ?? false });
11
- const { stack, profile, projectType, applicable } = await loadProjectContext(projectRoot, catalog.entries ?? []);
12
- const canonicalCheck = (catalog.entries ?? []).find((entry) => entry.id === 'canonical-check');
13
- const checkerRuntime = (catalog.entries ?? []).find((entry) => entry.id === 'checker-runtime');
14
- let canonicalCheckRoot = null;
15
- let checkerRuntimeRoot = null;
16
- if (options.withCheckers && canonicalCheck) {
17
- if (!options.offline ||
18
- (await source.hasModule(canonicalCheck.id, canonicalCheck.version, canonicalCheck.contentHash))) {
19
- canonicalCheckRoot = await source.module(canonicalCheck.id, canonicalCheck.version, {
20
- contentHash: canonicalCheck.contentHash,
21
- });
22
- }
23
- }
24
- if (options.withCheckers && checkerRuntime) {
25
- if (!options.offline ||
26
- (await source.hasModule(checkerRuntime.id, checkerRuntime.version, checkerRuntime.contentHash))) {
27
- checkerRuntimeRoot = await source.module(checkerRuntime.id, checkerRuntime.version, {
28
- contentHash: checkerRuntime.contentHash,
29
- });
30
- }
31
- }
32
- return {
33
- catalog,
34
- stack,
35
- projectType,
36
- profile,
37
- applicable,
38
- canonicalCheckRoot,
39
- checkerRuntimeRoot,
40
- };
41
- }
@@ -1,32 +0,0 @@
1
- export declare function canonicalStatus(projectRoot: string, source: any, options?: any): Promise<{
2
- stack: any;
3
- projectType: any;
4
- totals: {
5
- applicable: number;
6
- current: number;
7
- missing: number;
8
- outdated: number;
9
- };
10
- rows: {
11
- id: any;
12
- canonicalVersion: any;
13
- installedVersion: any;
14
- state: string;
15
- }[];
16
- packages: {
17
- id: string;
18
- recipeVersion: any;
19
- detectedVersion: any;
20
- role: any;
21
- source: any;
22
- resolvedVariant: any;
23
- }[];
24
- packageIssues: string[];
25
- installedNonApplicable: string[];
26
- }>;
27
- export declare function canonicalDoctor(projectRoot: string, source: any): Promise<{
28
- ok: boolean;
29
- stack: string | null;
30
- cacheRoot: any;
31
- issues: string[];
32
- }>;
@@ -1,70 +0,0 @@
1
- import { resolveProjectStack } from "./project-context.js";
2
- import { inspectPredefinedPackageState } from "./predefined-packages/health.js";
3
- import { loadCanonicalProjectContext } from "./project-runtime.js";
4
- import { readInstalledState } from "./state.js";
5
- export async function canonicalStatus(projectRoot, source, options = {}) {
6
- const current = await readInstalledState(projectRoot);
7
- const packageHealth = await inspectPredefinedPackageState(projectRoot, current);
8
- const { stack, projectType, applicable } = await loadCanonicalProjectContext(projectRoot, source, options);
9
- const installed = current.installed;
10
- const rows = applicable.map((entry) => {
11
- const found = installed[entry.id];
12
- const state = !found ? 'missing' : found.version === entry.version ? 'current' : 'outdated';
13
- return {
14
- id: entry.id,
15
- canonicalVersion: entry.version,
16
- installedVersion: found?.version ?? null,
17
- state,
18
- };
19
- });
20
- const applicableIds = new Set(applicable.map((entry) => entry.id));
21
- const packages = Object.entries(installed)
22
- .filter(([, value]) => value?.kind === 'package')
23
- .map(([id, value]) => ({
24
- id,
25
- recipeVersion: value.recipeVersion ?? null,
26
- detectedVersion: value.detectedVersion ?? value.version ?? null,
27
- role: value.role ?? null,
28
- source: value.source ?? null,
29
- resolvedVariant: value.resolvedVariant ?? null,
30
- }))
31
- .sort((a, b) => a.id.localeCompare(b.id));
32
- const installedNonApplicable = Object.keys(installed)
33
- .filter((id) => !applicableIds.has(id) && installed[id]?.kind !== 'package')
34
- .sort();
35
- return {
36
- stack,
37
- projectType,
38
- totals: {
39
- applicable: rows.length,
40
- current: rows.filter((row) => row.state === 'current').length,
41
- missing: rows.filter((row) => row.state === 'missing').length,
42
- outdated: rows.filter((row) => row.state === 'outdated').length,
43
- },
44
- rows,
45
- packages,
46
- packageIssues: packageHealth.issues,
47
- installedNonApplicable,
48
- };
49
- }
50
- export async function canonicalDoctor(projectRoot, source) {
51
- const issues = [];
52
- let stack = null;
53
- try {
54
- stack = await resolveProjectStack(projectRoot);
55
- if (!stack)
56
- issues.push('Unable to resolve a supported project stack.');
57
- }
58
- catch (error) {
59
- issues.push(error.message);
60
- }
61
- const packageHealth = await inspectPredefinedPackageState(projectRoot);
62
- issues.push(...packageHealth.issues);
63
- try {
64
- await source.catalog();
65
- }
66
- catch (error) {
67
- issues.push(`Catalog unavailable: ${error.message}`);
68
- }
69
- return { ok: issues.length === 0, stack, cacheRoot: source.cacheRoot, issues };
70
- }
@@ -1,7 +0,0 @@
1
- export declare function canonicalSync(projectRoot: string, source: any): Promise<{
2
- stack: any;
3
- projectType: any;
4
- applicable: number;
5
- changed: any[];
6
- removed: string[];
7
- }>;