@lumenflow/cli 3.18.1 → 3.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (159) hide show
  1. package/dist/docs-sync.js +123 -6
  2. package/dist/docs-sync.js.map +1 -1
  3. package/dist/gate-co-change.js +23 -4
  4. package/dist/gate-co-change.js.map +1 -1
  5. package/dist/gates-runners.js +108 -12
  6. package/dist/gates-runners.js.map +1 -1
  7. package/dist/lumenflow-upgrade.js +1 -0
  8. package/dist/lumenflow-upgrade.js.map +1 -1
  9. package/dist/public-manifest.js +1 -1
  10. package/dist/public-manifest.js.map +1 -1
  11. package/dist/sync-templates.js +13 -0
  12. package/dist/sync-templates.js.map +1 -1
  13. package/dist/wu-block.js +10 -0
  14. package/dist/wu-block.js.map +1 -1
  15. package/dist/wu-claim-validation.js +3 -1
  16. package/dist/wu-claim-validation.js.map +1 -1
  17. package/dist/wu-claim.js +3 -1
  18. package/dist/wu-claim.js.map +1 -1
  19. package/dist/wu-done-memory-telemetry.js +5 -1
  20. package/dist/wu-done-memory-telemetry.js.map +1 -1
  21. package/dist/wu-done-ownership.js +6 -0
  22. package/dist/wu-done-ownership.js.map +1 -1
  23. package/dist/wu-edit-operations.js +4 -4
  24. package/dist/wu-edit-operations.js.map +1 -1
  25. package/dist/wu-prep.js +88 -13
  26. package/dist/wu-prep.js.map +1 -1
  27. package/dist/wu-recover.js +15 -0
  28. package/dist/wu-recover.js.map +1 -1
  29. package/dist/wu-release.js +10 -1
  30. package/dist/wu-release.js.map +1 -1
  31. package/dist/wu-spawn-prompt-builders.js +27 -2
  32. package/dist/wu-spawn-prompt-builders.js.map +1 -1
  33. package/dist/wu-state-mutation-ownership.js +136 -0
  34. package/dist/wu-state-mutation-ownership.js.map +1 -0
  35. package/dist/wu-unblock.js +10 -0
  36. package/dist/wu-unblock.js.map +1 -1
  37. package/package.json +111 -110
  38. package/packs/agent-runtime/.turbo/turbo-build.log +1 -1
  39. package/packs/agent-runtime/package.json +1 -1
  40. package/packs/sidekick/.turbo/turbo-build.log +1 -1
  41. package/packs/sidekick/package.json +1 -1
  42. package/packs/software-delivery/.turbo/turbo-build.log +1 -1
  43. package/packs/software-delivery/package.json +1 -1
  44. package/templates/core/AGENTS.md.template +157 -32
  45. package/templates/core/LUMENFLOW.md.template +44 -29
  46. package/templates/core/_frameworks/lumenflow/wu-sizing-guide.md.template +644 -0
  47. package/templates/core/ai/onboarding/agent-invocation-guide.md.template +5 -5
  48. package/templates/core/ai/onboarding/agent-safety-card.md.template +1 -0
  49. package/templates/core/ai/onboarding/docs-generation.md.template +94 -4
  50. package/templates/core/ai/onboarding/first-15-mins.md.template +1 -1
  51. package/templates/core/ai/onboarding/first-wu-mistakes.md.template +2 -1
  52. package/templates/core/ai/onboarding/initiative-orchestration.md.template +21 -21
  53. package/templates/core/ai/onboarding/quick-ref-commands.md.template +102 -95
  54. package/templates/core/ai/onboarding/release-process.md.template +12 -12
  55. package/templates/core/ai/onboarding/starting-prompt.md.template +31 -31
  56. package/templates/vendors/claude/.claude/skills/initiative-management/SKILL.md.template +2 -2
  57. package/templates/vendors/claude/.claude/skills/multi-agent-coordination/SKILL.md.template +2 -2
  58. package/templates/vendors/claude/.claude/skills/orchestration/SKILL.md.template +3 -3
  59. package/dist/chunk-2D2VOCA4.js +0 -37
  60. package/dist/chunk-2D5KFYGX.js +0 -284
  61. package/dist/chunk-2GXVIN57.js +0 -14072
  62. package/dist/chunk-2MQ7HZWZ.js +0 -26
  63. package/dist/chunk-2UFQ3A3C.js +0 -643
  64. package/dist/chunk-3RG5ZIWI.js +0 -10
  65. package/dist/chunk-4N74J3UT.js +0 -15
  66. package/dist/chunk-5GTOXFYR.js +0 -392
  67. package/dist/chunk-5VY6MQMC.js +0 -240
  68. package/dist/chunk-67XVPMRY.js +0 -1297
  69. package/dist/chunk-6HO4GWJE.js +0 -164
  70. package/dist/chunk-6W5XHWYV.js +0 -1890
  71. package/dist/chunk-6X4EMYJQ.js +0 -64
  72. package/dist/chunk-6XYXI2NQ.js +0 -772
  73. package/dist/chunk-7ANSOV6Q.js +0 -285
  74. package/dist/chunk-A624LFLB.js +0 -1380
  75. package/dist/chunk-ADN5NHG4.js +0 -126
  76. package/dist/chunk-B7YJYJKG.js +0 -33
  77. package/dist/chunk-CCLHCPKG.js +0 -210
  78. package/dist/chunk-CK36VROC.js +0 -1584
  79. package/dist/chunk-D3UOFRSB.js +0 -81
  80. package/dist/chunk-DFR4DJBM.js +0 -230
  81. package/dist/chunk-DSYBDHYH.js +0 -79
  82. package/dist/chunk-DWMLTXKQ.js +0 -1176
  83. package/dist/chunk-E3REJTAJ.js +0 -28
  84. package/dist/chunk-EA3IVO64.js +0 -633
  85. package/dist/chunk-EK2AKZKD.js +0 -55
  86. package/dist/chunk-ELD7JTTT.js +0 -343
  87. package/dist/chunk-EX6TT2XI.js +0 -195
  88. package/dist/chunk-EXINSFZE.js +0 -82
  89. package/dist/chunk-EZ6ZBYBM.js +0 -510
  90. package/dist/chunk-FBKAPTJ2.js +0 -16
  91. package/dist/chunk-FVLV5RYH.js +0 -1118
  92. package/dist/chunk-GDNSBQVK.js +0 -2485
  93. package/dist/chunk-GPQHMBNN.js +0 -278
  94. package/dist/chunk-GTFJB67L.js +0 -68
  95. package/dist/chunk-HANJXVKW.js +0 -1127
  96. package/dist/chunk-HEVS5YLD.js +0 -269
  97. package/dist/chunk-HMEVZKPQ.js +0 -9
  98. package/dist/chunk-HRGSYNLM.js +0 -3511
  99. package/dist/chunk-ISZR5N4K.js +0 -60
  100. package/dist/chunk-J6SUPR2C.js +0 -226
  101. package/dist/chunk-JERYVEIZ.js +0 -244
  102. package/dist/chunk-JHHWGL2N.js +0 -87
  103. package/dist/chunk-JONWQUB5.js +0 -775
  104. package/dist/chunk-K2DIWWDM.js +0 -1766
  105. package/dist/chunk-KY4PGL5V.js +0 -969
  106. package/dist/chunk-L737LQ4C.js +0 -1285
  107. package/dist/chunk-LFTWYIB2.js +0 -497
  108. package/dist/chunk-LV47RFNJ.js +0 -41
  109. package/dist/chunk-MKSAITI7.js +0 -15
  110. package/dist/chunk-MZ7RKIX4.js +0 -212
  111. package/dist/chunk-NAP6CFSO.js +0 -84
  112. package/dist/chunk-ND6MY37M.js +0 -16
  113. package/dist/chunk-NMG736UR.js +0 -683
  114. package/dist/chunk-NRAXROED.js +0 -32
  115. package/dist/chunk-NRIZR3A7.js +0 -690
  116. package/dist/chunk-NX43BG3M.js +0 -233
  117. package/dist/chunk-O645XLSI.js +0 -297
  118. package/dist/chunk-OMJD6A3S.js +0 -235
  119. package/dist/chunk-QB6SJD4T.js +0 -430
  120. package/dist/chunk-QFSTL4J3.js +0 -276
  121. package/dist/chunk-QLGDFMFX.js +0 -212
  122. package/dist/chunk-RIAAGL2E.js +0 -13
  123. package/dist/chunk-RWO5XMZ6.js +0 -86
  124. package/dist/chunk-RXRKBBSM.js +0 -149
  125. package/dist/chunk-RZOZMML6.js +0 -363
  126. package/dist/chunk-U7I7FS7T.js +0 -113
  127. package/dist/chunk-UI42RODY.js +0 -717
  128. package/dist/chunk-UTVMVSCO.js +0 -519
  129. package/dist/chunk-V6OJGLBA.js +0 -1746
  130. package/dist/chunk-W2JHVH7D.js +0 -152
  131. package/dist/chunk-WD3Y7VQN.js +0 -280
  132. package/dist/chunk-WOCTQ5MS.js +0 -303
  133. package/dist/chunk-WZR3ZUNN.js +0 -696
  134. package/dist/chunk-XGI665H7.js +0 -150
  135. package/dist/chunk-XKY65P2T.js +0 -304
  136. package/dist/chunk-Y4CQZY65.js +0 -57
  137. package/dist/chunk-YFEXKLVE.js +0 -194
  138. package/dist/chunk-YHO3HS5X.js +0 -287
  139. package/dist/chunk-YLS7AZSX.js +0 -738
  140. package/dist/chunk-ZE473AO6.js +0 -49
  141. package/dist/chunk-ZF747T3O.js +0 -644
  142. package/dist/chunk-ZHCZHZH3.js +0 -43
  143. package/dist/chunk-ZZNZX2XY.js +0 -87
  144. package/dist/constants-7QAP3VQ4.js +0 -23
  145. package/dist/dist-IY3UUMWK.js +0 -33
  146. package/dist/invariants-runner-W5RGHCSU.js +0 -27
  147. package/dist/lane-lock-6J36HD5O.js +0 -35
  148. package/dist/mem-checkpoint-core-EANG2GVN.js +0 -14
  149. package/dist/mem-signal-core-2LZ2WYHW.js +0 -19
  150. package/dist/memory-store-OLB5FO7K.js +0 -18
  151. package/dist/service-6BYCOCO5.js +0 -13
  152. package/dist/spawn-policy-resolver-NTSZYQ6R.js +0 -17
  153. package/dist/spawn-task-builder-R4E2BHSW.js +0 -22
  154. package/dist/wu-done-pr-WLFFFEPJ.js +0 -25
  155. package/dist/wu-done-validation-3J5E36FE.js +0 -30
  156. package/dist/wu-duplicate-id-detector-5S7JHELK.js +0 -232
  157. package/packs/sidekick/.turbo/turbo-test.log +0 -12
  158. package/packs/sidekick/.turbo/turbo-typecheck.log +0 -4
  159. package/packs/software-delivery/.turbo/turbo-typecheck.log +0 -4
@@ -1,510 +0,0 @@
1
- import {
2
- isCodeFile,
3
- validateAutomatedTestRequirement
4
- } from "./chunk-U7I7FS7T.js";
5
- import {
6
- parseYAML
7
- } from "./chunk-NRIZR3A7.js";
8
- import {
9
- DIRECTORIES
10
- } from "./chunk-DWMLTXKQ.js";
11
- import {
12
- GIT_DIRECTORY_NAME,
13
- WU_STATUS
14
- } from "./chunk-V6OJGLBA.js";
15
- import {
16
- ErrorCodes,
17
- createError,
18
- getErrorMessage
19
- } from "./chunk-RXRKBBSM.js";
20
-
21
- // ../core/dist/invariants-runner.js
22
- import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
23
- import path2 from "path";
24
- import { globSync } from "glob";
25
-
26
- // ../core/dist/invariants/check-automated-tests.js
27
- import { existsSync, readdirSync, readFileSync } from "fs";
28
- import path from "path";
29
- var INVARIANT_ID = "INV-AUTOMATED-TESTS-FOR-CODE";
30
- var INVARIANT_TYPE = "wu-automated-tests";
31
- var ACTIVE_STATUSES = Object.freeze([WU_STATUS.IN_PROGRESS, WU_STATUS.BLOCKED]);
32
- var WU_YAML_PATH = DIRECTORIES.WU_DIR;
33
- function checkWUFile(filePath, options = {}) {
34
- const { skipStatusCheck = false } = options;
35
- try {
36
- const content = readFileSync(filePath, "utf-8");
37
- const doc = parseYAML(content);
38
- if (!doc) {
39
- return { valid: true, wuId: null, error: null };
40
- }
41
- const wuId = doc.id || path.basename(filePath, ".yaml");
42
- const status = doc.status || "";
43
- if (!skipStatusCheck && !ACTIVE_STATUSES.includes(status)) {
44
- return { valid: true, wuId, error: null };
45
- }
46
- const result = validateAutomatedTestRequirement(doc);
47
- if (!result.valid) {
48
- return {
49
- valid: false,
50
- wuId,
51
- error: result.errors.join("\n"),
52
- codeFiles: getCodeFilesFromPaths(doc.code_paths || [])
53
- };
54
- }
55
- return { valid: true, wuId, error: null };
56
- } catch {
57
- return { valid: true, wuId: null, error: null };
58
- }
59
- }
60
- function getCodeFilesFromPaths(codePaths) {
61
- if (!codePaths || !Array.isArray(codePaths)) {
62
- return [];
63
- }
64
- return codePaths.filter((p) => isCodeFile(p));
65
- }
66
- function checkAutomatedTestsInvariant(options = {}) {
67
- const { baseDir = process.cwd(), wuId } = options;
68
- const wuDir = path.join(baseDir, WU_YAML_PATH);
69
- const violations = [];
70
- if (!existsSync(wuDir)) {
71
- return { valid: true, violations: [] };
72
- }
73
- if (wuId) {
74
- const filePath = path.join(wuDir, `${wuId}.yaml`);
75
- if (!existsSync(filePath)) {
76
- return { valid: true, violations: [] };
77
- }
78
- const result = checkWUFile(filePath, { skipStatusCheck: true });
79
- if (!result.valid) {
80
- violations.push({
81
- id: INVARIANT_ID,
82
- type: INVARIANT_TYPE,
83
- wuId: result.wuId,
84
- description: `WU ${result.wuId} has code files but no automated tests`,
85
- message: result.error,
86
- codeFiles: result.codeFiles
87
- });
88
- }
89
- return {
90
- valid: violations.length === 0,
91
- violations
92
- };
93
- }
94
- let files;
95
- try {
96
- files = readdirSync(wuDir).filter((f) => f.startsWith("WU-") && (f.endsWith(".yaml") || f.endsWith(".yml")));
97
- } catch {
98
- return { valid: true, violations: [] };
99
- }
100
- for (const file of files) {
101
- const filePath = path.join(wuDir, file);
102
- const result = checkWUFile(filePath);
103
- if (!result.valid) {
104
- violations.push({
105
- id: INVARIANT_ID,
106
- type: INVARIANT_TYPE,
107
- wuId: result.wuId,
108
- description: `WU ${result.wuId} has code files but no automated tests`,
109
- message: result.error,
110
- codeFiles: result.codeFiles
111
- });
112
- }
113
- }
114
- return {
115
- valid: violations.length === 0,
116
- violations
117
- };
118
- }
119
-
120
- // ../core/dist/invariants-runner.js
121
- var INVARIANT_TYPES = {
122
- REQUIRED_FILE: "required-file",
123
- FORBIDDEN_FILE: "forbidden-file",
124
- MUTUAL_EXCLUSIVITY: "mutual-exclusivity",
125
- FORBIDDEN_PATTERN: "forbidden-pattern",
126
- // WU-2254: New invariant types
127
- REQUIRED_PATTERN: "required-pattern",
128
- FORBIDDEN_IMPORT: "forbidden-import",
129
- // WU-2333: WU automated tests invariant
130
- WU_AUTOMATED_TESTS: "wu-automated-tests"
131
- };
132
- var EXCLUDED_DIRS = ["node_modules", "worktrees", ".next", "dist", GIT_DIRECTORY_NAME];
133
- var checkerRegistry = /* @__PURE__ */ new Map();
134
- function registerInvariantChecker(type, checker) {
135
- checkerRegistry.set(type, checker);
136
- }
137
- function getInvariantChecker(type) {
138
- return checkerRegistry.get(type);
139
- }
140
- var RequiredFileChecker = class {
141
- validate(invariant, baseDir) {
142
- if (typeof invariant.path !== "string") {
143
- return {
144
- ...invariant,
145
- valid: false,
146
- path: invariant.path
147
- };
148
- }
149
- const fullPath = path2.join(baseDir, invariant.path);
150
- if (!existsSync2(fullPath)) {
151
- return {
152
- ...invariant,
153
- valid: false,
154
- path: invariant.path
155
- };
156
- }
157
- return null;
158
- }
159
- };
160
- var ForbiddenFileChecker = class {
161
- validate(invariant, baseDir) {
162
- if (typeof invariant.path !== "string") {
163
- return null;
164
- }
165
- const fullPath = path2.join(baseDir, invariant.path);
166
- if (existsSync2(fullPath)) {
167
- return {
168
- ...invariant,
169
- valid: false,
170
- path: invariant.path
171
- };
172
- }
173
- return null;
174
- }
175
- };
176
- var MutualExclusivityChecker = class {
177
- validate(invariant, baseDir) {
178
- const paths = Array.isArray(invariant.paths) ? invariant.paths : [];
179
- const existingPaths = paths.filter((p) => {
180
- const fullPath = path2.join(baseDir, p);
181
- return existsSync2(fullPath);
182
- });
183
- if (existingPaths.length > 1) {
184
- return {
185
- ...invariant,
186
- valid: false,
187
- existingPaths
188
- };
189
- }
190
- return null;
191
- }
192
- };
193
- var ForbiddenPatternChecker = class {
194
- validate(invariant, baseDir) {
195
- const { pattern, scope } = invariant;
196
- if (!pattern || !scope || !Array.isArray(scope)) {
197
- return null;
198
- }
199
- const ignorePatterns = EXCLUDED_DIRS.map((dir) => `**/${dir}/**`);
200
- const matchingFiles = [];
201
- for (const scopePattern of scope) {
202
- const files = globSync(scopePattern, {
203
- cwd: baseDir,
204
- ignore: ignorePatterns,
205
- nodir: true
206
- });
207
- const regex = new RegExp(pattern);
208
- for (const file of files) {
209
- const fullPath = path2.join(baseDir, file);
210
- try {
211
- const content = readFileSync2(fullPath, "utf-8");
212
- if (regex.test(content)) {
213
- matchingFiles.push(file);
214
- }
215
- } catch {
216
- }
217
- }
218
- }
219
- if (matchingFiles.length > 0) {
220
- return {
221
- ...invariant,
222
- valid: false,
223
- matchingFiles
224
- };
225
- }
226
- return null;
227
- }
228
- };
229
- var RequiredPatternChecker = class {
230
- validate(invariant, baseDir) {
231
- const { pattern, scope } = invariant;
232
- if (!pattern || !scope || !Array.isArray(scope)) {
233
- return null;
234
- }
235
- const ignorePatterns = EXCLUDED_DIRS.map((dir) => `**/${dir}/**`);
236
- const regex = new RegExp(pattern);
237
- for (const scopePattern of scope) {
238
- const files = globSync(scopePattern, {
239
- cwd: baseDir,
240
- ignore: ignorePatterns,
241
- nodir: true
242
- });
243
- for (const file of files) {
244
- const fullPath = path2.join(baseDir, file);
245
- try {
246
- const content = readFileSync2(fullPath, "utf-8");
247
- if (regex.test(content)) {
248
- return null;
249
- }
250
- } catch {
251
- }
252
- }
253
- }
254
- return {
255
- ...invariant,
256
- valid: false,
257
- patternNotFound: true
258
- };
259
- }
260
- };
261
- var ForbiddenImportChecker = class {
262
- validate(invariant, baseDir) {
263
- const { from, cannot_import } = invariant;
264
- if (!from || !cannot_import || !Array.isArray(cannot_import)) {
265
- return null;
266
- }
267
- const ignorePatterns = EXCLUDED_DIRS.map((dir) => `**/${dir}/**`);
268
- const files = globSync(from, {
269
- cwd: baseDir,
270
- ignore: ignorePatterns,
271
- nodir: true
272
- });
273
- const violatingFiles = [];
274
- const violatingImports = {};
275
- const forbiddenModulePatterns = cannot_import.map((mod) => {
276
- const escapedMod = mod.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
277
- return new RegExp(`(?:import\\s+[^;]*from\\s*['"]${escapedMod}['"]|export\\s+[^;]*from\\s*['"]${escapedMod}['"]|require\\s*\\(\\s*['"]${escapedMod}['"]\\s*\\)|import\\s*\\(\\s*['"]${escapedMod}['"]\\s*\\))`);
278
- });
279
- for (const file of files) {
280
- const fullPath = path2.join(baseDir, file);
281
- try {
282
- const content = readFileSync2(fullPath, "utf-8");
283
- for (let i = 0; i < forbiddenModulePatterns.length; i++) {
284
- const pattern = forbiddenModulePatterns[i];
285
- if (!pattern)
286
- continue;
287
- const moduleName = cannot_import[i] ?? "unknown-module";
288
- if (pattern.test(content)) {
289
- if (!violatingFiles.includes(file)) {
290
- violatingFiles.push(file);
291
- }
292
- violatingImports[moduleName] = (violatingImports[moduleName] || 0) + 1;
293
- }
294
- }
295
- } catch {
296
- }
297
- }
298
- if (violatingFiles.length > 0) {
299
- return {
300
- ...invariant,
301
- valid: false,
302
- violatingFiles,
303
- violatingImports
304
- };
305
- }
306
- return null;
307
- }
308
- };
309
- var WUAutomatedTestsChecker = class {
310
- validate(invariant, baseDir, context = {}) {
311
- const { wuId } = context;
312
- const result = checkAutomatedTestsInvariant({ baseDir, wuId });
313
- if (!result.valid && result.violations.length > 0) {
314
- return {
315
- ...invariant,
316
- valid: false,
317
- wuViolations: result.violations
318
- };
319
- }
320
- return null;
321
- }
322
- };
323
- registerInvariantChecker(INVARIANT_TYPES.REQUIRED_FILE, new RequiredFileChecker());
324
- registerInvariantChecker(INVARIANT_TYPES.FORBIDDEN_FILE, new ForbiddenFileChecker());
325
- registerInvariantChecker(INVARIANT_TYPES.MUTUAL_EXCLUSIVITY, new MutualExclusivityChecker());
326
- registerInvariantChecker(INVARIANT_TYPES.FORBIDDEN_PATTERN, new ForbiddenPatternChecker());
327
- registerInvariantChecker(INVARIANT_TYPES.REQUIRED_PATTERN, new RequiredPatternChecker());
328
- registerInvariantChecker(INVARIANT_TYPES.FORBIDDEN_IMPORT, new ForbiddenImportChecker());
329
- registerInvariantChecker(INVARIANT_TYPES.WU_AUTOMATED_TESTS, new WUAutomatedTestsChecker());
330
- var InvariantError = class extends Error {
331
- /** The invariant ID */
332
- invariantId;
333
- /**
334
- * @param {string} invariantId - The invariant ID (e.g., 'INV-001')
335
- * @param {string} message - Error message
336
- */
337
- constructor(invariantId, message) {
338
- super(message);
339
- this.name = "InvariantError";
340
- this.invariantId = invariantId;
341
- }
342
- };
343
- function loadInvariants(filePath) {
344
- if (!existsSync2(filePath)) {
345
- throw createError(ErrorCodes.FILE_NOT_FOUND, `Invariants file not found: ${filePath}`);
346
- }
347
- const content = readFileSync2(filePath, "utf-8");
348
- let doc;
349
- try {
350
- doc = parseYAML(content);
351
- } catch (e) {
352
- throw createError(ErrorCodes.YAML_PARSE_ERROR, `Invalid YAML in ${filePath}: ${getErrorMessage(e)}`);
353
- }
354
- if (!doc || !Array.isArray(doc.invariants)) {
355
- throw createError(ErrorCodes.INVARIANT_ERROR, `Invalid invariants.yml: expected 'invariants' array at root`);
356
- }
357
- return doc.invariants;
358
- }
359
- function validateInvariants(invariants, options = {}) {
360
- const { baseDir = process.cwd(), wuId } = options;
361
- const violations = [];
362
- const context = { wuId };
363
- for (const invariant of invariants) {
364
- const checker = checkerRegistry.get(invariant.type);
365
- if (checker) {
366
- const violation = checker.validate(invariant, baseDir, context);
367
- if (violation) {
368
- violations.push(violation);
369
- }
370
- } else {
371
- console.warn(`[invariants] Unknown invariant type: ${invariant.type} (${invariant.id})`);
372
- }
373
- }
374
- return {
375
- valid: violations.length === 0,
376
- violations
377
- };
378
- }
379
- function formatFileViolationDetails(violation) {
380
- const lines = [];
381
- if (violation.path) {
382
- lines.push(`Path: ${violation.path}`);
383
- }
384
- if (violation.existingPaths) {
385
- lines.push(`Conflicting files: ${violation.existingPaths.join(", ")}`);
386
- }
387
- if (violation.matchingFiles) {
388
- lines.push(`Files with forbidden pattern: ${violation.matchingFiles.join(", ")}`);
389
- }
390
- return lines;
391
- }
392
- function formatImportViolationDetails(violation) {
393
- const lines = [];
394
- if (violation.from) {
395
- lines.push(`From: ${violation.from}`);
396
- }
397
- if (violation.cannot_import) {
398
- lines.push(`Cannot import: ${violation.cannot_import.join(", ")}`);
399
- }
400
- if (violation.violatingFiles) {
401
- lines.push(`Files with forbidden imports: ${violation.violatingFiles.join(", ")}`);
402
- }
403
- if (violation.violatingImports) {
404
- const imports = Object.entries(violation.violatingImports).map(([mod, count]) => `${mod} (${count} occurrence${count > 1 ? "s" : ""})`).join(", ");
405
- lines.push(`Forbidden imports found: ${imports}`);
406
- }
407
- return lines;
408
- }
409
- function formatPatternViolationDetails(violation) {
410
- const lines = [];
411
- if (violation.patternNotFound) {
412
- lines.push(`Required pattern not found: ${violation.pattern}`);
413
- if (violation.scope) {
414
- lines.push(`Searched in: ${violation.scope.join(", ")}`);
415
- }
416
- }
417
- return lines;
418
- }
419
- function formatWUAutomatedTestsViolationDetails(violation) {
420
- const lines = [];
421
- if (violation.wuViolations) {
422
- lines.push(`WUs missing automated tests:`);
423
- for (const wuViolation of violation.wuViolations) {
424
- lines.push(` - ${wuViolation.wuId}`);
425
- if (wuViolation.codeFiles && wuViolation.codeFiles.length > 0) {
426
- lines.push(` Code files: ${wuViolation.codeFiles.join(", ")}`);
427
- }
428
- }
429
- }
430
- return lines;
431
- }
432
- function formatViolationDetails(violation) {
433
- return [
434
- ...formatFileViolationDetails(violation),
435
- ...formatImportViolationDetails(violation),
436
- ...formatPatternViolationDetails(violation),
437
- ...formatWUAutomatedTestsViolationDetails(violation)
438
- ];
439
- }
440
- function formatInvariantError(violation) {
441
- const lines = [
442
- `INVARIANT VIOLATION: ${violation.id}`,
443
- `Type: ${violation.type}`,
444
- `Description: ${violation.description}`,
445
- ...formatViolationDetails(violation)
446
- ];
447
- if (violation.message) {
448
- lines.push("");
449
- lines.push(`Action: ${violation.message}`);
450
- }
451
- return lines.join("\n");
452
- }
453
- function runInvariants(options = {}) {
454
- const { configPath = "tools/invariants.yml", baseDir = process.cwd(), silent = false, wuId } = options;
455
- const fullConfigPath = path2.isAbsolute(configPath) ? configPath : path2.join(baseDir, configPath);
456
- if (!existsSync2(fullConfigPath)) {
457
- if (!silent) {
458
- console.log("[invariants] No tools/invariants.yml found - skipping");
459
- }
460
- return { success: true, violations: [], formatted: "" };
461
- }
462
- try {
463
- const invariants = loadInvariants(fullConfigPath);
464
- if (invariants.length === 0) {
465
- if (!silent) {
466
- console.log("[invariants] No invariants defined - skipping");
467
- }
468
- return { success: true, violations: [], formatted: "" };
469
- }
470
- const result = validateInvariants(invariants, { baseDir, wuId });
471
- if (result.valid) {
472
- if (!silent) {
473
- console.log(`[invariants] All ${invariants.length} invariants passed`);
474
- }
475
- return { success: true, violations: [], formatted: "" };
476
- }
477
- const formatted = result.violations.map(formatInvariantError).join("\n\n");
478
- if (!silent) {
479
- console.error("[invariants] FAILED - violations detected:");
480
- console.error("");
481
- console.error(formatted);
482
- }
483
- return {
484
- success: false,
485
- violations: result.violations,
486
- formatted
487
- };
488
- } catch (e) {
489
- const error = `[invariants] Error: ${getErrorMessage(e)}`;
490
- if (!silent) {
491
- console.error(error);
492
- }
493
- return {
494
- success: false,
495
- violations: [],
496
- formatted: error
497
- };
498
- }
499
- }
500
-
501
- export {
502
- INVARIANT_TYPES,
503
- registerInvariantChecker,
504
- getInvariantChecker,
505
- InvariantError,
506
- loadInvariants,
507
- validateInvariants,
508
- formatInvariantError,
509
- runInvariants
510
- };
@@ -1,16 +0,0 @@
1
- // src/onboarding-template-paths.ts
2
- var SCAFFOLDED_ONBOARDING_TEMPLATE_PATHS = {
3
- "starting-prompt.md": "core/ai/onboarding/starting-prompt.md.template",
4
- "first-15-mins.md": "core/ai/onboarding/first-15-mins.md.template",
5
- "local-only.md": "core/ai/onboarding/local-only.md.template",
6
- "quick-ref-commands.md": "core/ai/onboarding/quick-ref-commands.md.template",
7
- "first-wu-mistakes.md": "core/ai/onboarding/first-wu-mistakes.md.template",
8
- "troubleshooting-wu-done.md": "core/ai/onboarding/troubleshooting-wu-done.md.template",
9
- "agent-safety-card.md": "core/ai/onboarding/agent-safety-card.md.template",
10
- "wu-create-checklist.md": "core/ai/onboarding/wu-create-checklist.md.template",
11
- "wu-sizing-guide.md": "core/ai/onboarding/wu-sizing-guide.md.template"
12
- };
13
-
14
- export {
15
- SCAFFOLDED_ONBOARDING_TEMPLATE_PATHS
16
- };