fraim-framework 2.0.36 → 2.0.37

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 (165) hide show
  1. package/bin/fraim.js +5 -52
  2. package/dist/registry/scripts/build-scripts-generator.js +205 -0
  3. package/dist/registry/scripts/fraim-config.js +61 -0
  4. package/dist/registry/scripts/generic-issues-api.js +100 -0
  5. package/dist/registry/scripts/openapi-generator.js +664 -0
  6. package/dist/registry/scripts/performance/profile-server.js +390 -0
  7. package/dist/scripts/build-stub-registry.js +108 -0
  8. package/dist/src/cli/commands/doctor.js +5 -5
  9. package/dist/src/cli/commands/sync.js +33 -19
  10. package/dist/test-utils.js +96 -0
  11. package/dist/tests/esm-compat.js +11 -0
  12. package/dist/tests/test-chalk-esm-issue.js +159 -0
  13. package/dist/tests/test-chalk-real-world.js +265 -0
  14. package/dist/tests/test-chalk-regression.js +2 -18
  15. package/dist/tests/test-chalk-resolution-issue.js +304 -0
  16. package/dist/tests/test-fraim-install-chalk-issue.js +254 -0
  17. package/dist/tests/test-npm-resolution-diagnostic.js +140 -0
  18. package/dist/tests/test-package-size.js +88 -0
  19. package/dist/tests/test-prep-issue.js +34 -1
  20. package/dist/tests/test-stub-registry.js +120 -0
  21. package/dist/tests/test-sync-stubs.js +143 -0
  22. package/package.json +6 -8
  23. package/registry/agent-guardrails.md +62 -62
  24. package/registry/scripts/code-quality-check.sh +559 -559
  25. package/registry/scripts/detect-tautological-tests.sh +38 -38
  26. package/registry/scripts/prep-issue.sh +61 -30
  27. package/registry/scripts/validate-openapi-limits.ts +366 -366
  28. package/registry/scripts/validate-test-coverage.ts +280 -280
  29. package/registry/scripts/verify-pr-comments.sh +70 -70
  30. package/registry/stubs/workflows/bootstrap/create-architecture.md +11 -0
  31. package/registry/stubs/workflows/bootstrap/detect-broken-windows.md +11 -0
  32. package/registry/stubs/workflows/bootstrap/evaluate-code-quality.md +11 -0
  33. package/registry/stubs/workflows/bootstrap/verify-test-coverage.md +11 -0
  34. package/registry/stubs/workflows/business-development/create-business-plan.md +11 -0
  35. package/registry/stubs/workflows/business-development/ideate-business-opportunity.md +11 -0
  36. package/registry/stubs/workflows/business-development/price-product.md +18 -0
  37. package/registry/stubs/workflows/convert-to-pdf.md +11 -0
  38. package/registry/stubs/workflows/customer-development/insight-analysis.md +11 -0
  39. package/registry/stubs/workflows/customer-development/insight-triage.md +11 -0
  40. package/registry/stubs/workflows/customer-development/interview-preparation.md +11 -0
  41. package/registry/stubs/workflows/customer-development/linkedin-outreach.md +11 -0
  42. package/registry/stubs/workflows/customer-development/strategic-brainstorming.md +11 -0
  43. package/registry/stubs/workflows/customer-development/thank-customers.md +11 -0
  44. package/registry/stubs/workflows/customer-development/weekly-newsletter.md +11 -0
  45. package/registry/stubs/workflows/deploy/cloud-deployment.md +11 -0
  46. package/registry/stubs/workflows/improve-fraim/contribute.md +11 -0
  47. package/registry/stubs/workflows/improve-fraim/file-issue.md +11 -0
  48. package/registry/stubs/workflows/marketing/content-creation.md +11 -0
  49. package/registry/stubs/workflows/marketing/hbr-article.md +11 -0
  50. package/registry/stubs/workflows/marketing/launch-checklist.md +11 -0
  51. package/registry/stubs/workflows/marketing/marketing-strategy.md +11 -0
  52. package/registry/stubs/workflows/marketing/storytelling.md +11 -0
  53. package/registry/stubs/workflows/performance/analyze-performance.md +11 -0
  54. package/registry/stubs/workflows/product-building/design.md +11 -0
  55. package/registry/stubs/workflows/product-building/implement.md +12 -0
  56. package/registry/stubs/workflows/product-building/iterate-on-pr-comments.md +11 -0
  57. package/registry/stubs/workflows/product-building/prep-issue.md +11 -0
  58. package/registry/stubs/workflows/product-building/prototype.md +11 -0
  59. package/registry/stubs/workflows/product-building/resolve.md +11 -0
  60. package/registry/stubs/workflows/product-building/retrospect.md +11 -0
  61. package/registry/stubs/workflows/product-building/spec.md +11 -0
  62. package/registry/stubs/workflows/product-building/test.md +11 -0
  63. package/registry/stubs/workflows/quality-assurance/browser-validation.md +11 -0
  64. package/registry/stubs/workflows/quality-assurance/iterative-improvement-cycle.md +11 -0
  65. package/registry/stubs/workflows/replicate/replicate-discovery.md +11 -0
  66. package/registry/stubs/workflows/replicate/replicate-to-issues.md +11 -0
  67. package/registry/stubs/workflows/reviewer/review-implementation-vs-design-spec.md +11 -0
  68. package/registry/stubs/workflows/reviewer/review-implementation-vs-feature-spec.md +11 -0
  69. package/registry/stubs/workflows/startup-credits/aws-activate-application.md +11 -0
  70. package/registry/stubs/workflows/startup-credits/google-cloud-application.md +11 -0
  71. package/registry/stubs/workflows/startup-credits/microsoft-azure-application.md +11 -0
  72. package/.github/workflows/ci.yml +0 -65
  73. package/.github/workflows/deploy-fraim.yml +0 -87
  74. package/.github/workflows/phase-change.yml +0 -251
  75. package/.github/workflows/status-change.yml +0 -68
  76. package/.github/workflows/sync-on-pr-review.yml +0 -66
  77. package/examples/simple-webapp/TESTING.md +0 -62
  78. package/examples/simple-webapp/example-test.ts +0 -186
  79. package/registry/github/workflows/ci.yml +0 -51
  80. package/registry/github/workflows/phase-change.yml +0 -251
  81. package/registry/github/workflows/status-change.yml +0 -68
  82. package/registry/github/workflows/sync-on-pr-review.yml +0 -66
  83. package/registry/mcp-template.jsonc +0 -29
  84. package/registry/rules/agent-success-criteria.md +0 -52
  85. package/registry/rules/agent-testing-guidelines.md +0 -502
  86. package/registry/rules/architecture.md +0 -52
  87. package/registry/rules/communication.md +0 -122
  88. package/registry/rules/continuous-learning.md +0 -55
  89. package/registry/rules/debugging-multitenancy-issues.md +0 -85
  90. package/registry/rules/ephemeral-execution.md +0 -57
  91. package/registry/rules/git-safe-commands.md +0 -34
  92. package/registry/rules/hitl-ppe-record-analysis.md +0 -302
  93. package/registry/rules/integrity-and-test-ethics.md +0 -275
  94. package/registry/rules/local-development.md +0 -254
  95. package/registry/rules/merge-requirements.md +0 -231
  96. package/registry/rules/simplicity.md +0 -118
  97. package/registry/rules/software-development-lifecycle.md +0 -105
  98. package/registry/rules/spike-first-development.md +0 -205
  99. package/registry/rules/successful-debugging-patterns.md +0 -491
  100. package/registry/rules/telemetry.md +0 -67
  101. package/registry/templates/bootstrap/ARCHITECTURE-TEMPLATE.md +0 -53
  102. package/registry/templates/bootstrap/CODE-QUALITY-REPORT-TEMPLATE.md +0 -37
  103. package/registry/templates/bootstrap/TEST-COVERAGE-REPORT-TEMPLATE.md +0 -35
  104. package/registry/templates/business-development/IDEATION-REPORT-TEMPLATE.md +0 -29
  105. package/registry/templates/business-development/PRICING-STRATEGY-TEMPLATE.md +0 -126
  106. package/registry/templates/customer-development/customer-interview-template.md +0 -99
  107. package/registry/templates/customer-development/follow-up-email-templates.md +0 -132
  108. package/registry/templates/customer-development/insight-analysis-template.md +0 -74
  109. package/registry/templates/customer-development/strategic-recommendations-template.md +0 -53
  110. package/registry/templates/customer-development/thank-you-email-template.html +0 -124
  111. package/registry/templates/customer-development/thank-you-note-template.md +0 -16
  112. package/registry/templates/customer-development/triage-log-template.md +0 -278
  113. package/registry/templates/customer-development/weekly-newsletter-template.html +0 -204
  114. package/registry/templates/evidence/Design-Evidence.md +0 -30
  115. package/registry/templates/evidence/Implementation-BugEvidence.md +0 -86
  116. package/registry/templates/evidence/Implementation-FeatureEvidence.md +0 -121
  117. package/registry/templates/evidence/Spec-Evidence.md +0 -19
  118. package/registry/templates/help/HelpNeeded.md +0 -14
  119. package/registry/templates/marketing/HBR-ARTICLE-TEMPLATE.md +0 -66
  120. package/registry/templates/replicate/implementation-checklist.md +0 -39
  121. package/registry/templates/replicate/use-cases-template.md +0 -88
  122. package/registry/templates/retrospective/RETROSPECTIVE-TEMPLATE.md +0 -55
  123. package/registry/templates/specs/BUGSPEC-TEMPLATE.md +0 -37
  124. package/registry/templates/specs/FEATURESPEC-TEMPLATE.md +0 -29
  125. package/registry/templates/specs/TECHSPEC-TEMPLATE.md +0 -39
  126. package/registry/workflows/bootstrap/create-architecture.md +0 -38
  127. package/registry/workflows/bootstrap/evaluate-code-quality.md +0 -36
  128. package/registry/workflows/bootstrap/verify-test-coverage.md +0 -37
  129. package/registry/workflows/business-development/create-business-plan.md +0 -737
  130. package/registry/workflows/business-development/ideate-business-opportunity.md +0 -55
  131. package/registry/workflows/business-development/price-product.md +0 -325
  132. package/registry/workflows/convert-to-pdf.md +0 -235
  133. package/registry/workflows/customer-development/insight-analysis.md +0 -156
  134. package/registry/workflows/customer-development/insight-triage.md +0 -933
  135. package/registry/workflows/customer-development/interview-preparation.md +0 -421
  136. package/registry/workflows/customer-development/linkedin-outreach.md +0 -593
  137. package/registry/workflows/customer-development/strategic-brainstorming.md +0 -146
  138. package/registry/workflows/customer-development/thank-customers.md +0 -203
  139. package/registry/workflows/customer-development/weekly-newsletter.md +0 -366
  140. package/registry/workflows/deploy/cloud-deployment.md +0 -310
  141. package/registry/workflows/improve-fraim/contribute.md +0 -32
  142. package/registry/workflows/improve-fraim/file-issue.md +0 -32
  143. package/registry/workflows/marketing/content-creation.md +0 -37
  144. package/registry/workflows/marketing/hbr-article.md +0 -73
  145. package/registry/workflows/marketing/launch-checklist.md +0 -37
  146. package/registry/workflows/marketing/marketing-strategy.md +0 -45
  147. package/registry/workflows/performance/analyze-performance.md +0 -65
  148. package/registry/workflows/product-building/design.md +0 -130
  149. package/registry/workflows/product-building/implement.md +0 -315
  150. package/registry/workflows/product-building/iterate-on-pr-comments.md +0 -70
  151. package/registry/workflows/product-building/prep-issue.md +0 -43
  152. package/registry/workflows/product-building/prototype.md +0 -60
  153. package/registry/workflows/product-building/resolve.md +0 -164
  154. package/registry/workflows/product-building/retrospect.md +0 -86
  155. package/registry/workflows/product-building/spec.md +0 -117
  156. package/registry/workflows/product-building/test.md +0 -120
  157. package/registry/workflows/quality-assurance/browser-validation.md +0 -221
  158. package/registry/workflows/quality-assurance/iterative-improvement-cycle.md +0 -562
  159. package/registry/workflows/replicate/replicate-discovery.md +0 -336
  160. package/registry/workflows/replicate/replicate-to-issues.md +0 -319
  161. package/registry/workflows/reviewer/review-implementation-vs-design-spec.md +0 -632
  162. package/registry/workflows/reviewer/review-implementation-vs-feature-spec.md +0 -669
  163. package/registry/workflows/startup-credits/aws-activate-application.md +0 -535
  164. package/registry/workflows/startup-credits/google-cloud-application.md +0 -647
  165. package/registry/workflows/startup-credits/microsoft-azure-application.md +0 -538
@@ -0,0 +1,304 @@
1
+ "use strict";
2
+ /**
3
+ * Test to reproduce and verify the fix for the chalk v5 resolution issue
4
+ *
5
+ * This test creates a scenario where npm might resolve chalk to v5 by:
6
+ * 1. Creating a dependency that requires chalk v5
7
+ * 2. Testing if fraim-framework with ^4.1.2 gets upgraded
8
+ * 3. Testing if fraim-framework with 4.1.2 (pinned) stays at v4
9
+ */
10
+ var __importDefault = (this && this.__importDefault) || function (mod) {
11
+ return (mod && mod.__esModule) ? mod : { "default": mod };
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ const node_child_process_1 = require("node:child_process");
15
+ const test_utils_1 = require("./test-utils");
16
+ const fs_1 = __importDefault(require("fs"));
17
+ const path_1 = __importDefault(require("path"));
18
+ const os_1 = __importDefault(require("os"));
19
+ async function runCommand(command, args, cwd) {
20
+ return new Promise((resolve) => {
21
+ const proc = (0, node_child_process_1.spawn)(command, args, {
22
+ cwd,
23
+ stdio: 'pipe',
24
+ shell: true
25
+ });
26
+ let stdout = '';
27
+ let stderr = '';
28
+ proc.stdout?.on('data', (data) => {
29
+ stdout += data.toString();
30
+ });
31
+ proc.stderr?.on('data', (data) => {
32
+ stderr += data.toString();
33
+ });
34
+ proc.on('close', (code) => {
35
+ resolve({ code, stdout, stderr });
36
+ });
37
+ });
38
+ }
39
+ async function testChalkResolutionWithConflict() {
40
+ console.log(' 🧪 Testing chalk resolution with conflicting dependency...');
41
+ const tempDir = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), 'chalk-conflict-'));
42
+ console.log(` 📂 Created temp dir: ${tempDir}`);
43
+ try {
44
+ // 1. Create a package that depends on chalk v5
45
+ console.log(' 📦 Creating fake package that requires chalk v5...');
46
+ const fakePackageDir = path_1.default.join(tempDir, 'fake-chalk5-package');
47
+ fs_1.default.mkdirSync(fakePackageDir, { recursive: true });
48
+ const fakePackageJson = {
49
+ name: 'fake-chalk5-package',
50
+ version: '1.0.0',
51
+ dependencies: {
52
+ 'chalk': '^5.0.0'
53
+ }
54
+ };
55
+ fs_1.default.writeFileSync(path_1.default.join(fakePackageDir, 'package.json'), JSON.stringify(fakePackageJson, null, 2));
56
+ // Create a simple index.js that uses chalk
57
+ fs_1.default.writeFileSync(path_1.default.join(fakePackageDir, 'index.js'), 'export { default as chalk } from "chalk";\n');
58
+ // 2. Pack fraim-framework with ^4.1.2 (unpinned)
59
+ console.log(' 📦 Packing fraim-framework with ^4.1.2...');
60
+ const projectRoot = process.cwd();
61
+ const packageJsonPath = path_1.default.join(projectRoot, 'package.json');
62
+ const originalPackageJson = fs_1.default.readFileSync(packageJsonPath, 'utf-8');
63
+ const packageJson = JSON.parse(originalPackageJson);
64
+ // Temporarily change to ^4.1.2
65
+ packageJson.dependencies.chalk = '^4.1.2';
66
+ fs_1.default.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
67
+ const packResult = (0, node_child_process_1.execSync)('npm pack', {
68
+ cwd: projectRoot,
69
+ encoding: 'utf-8'
70
+ });
71
+ const tarballName = packResult.trim().split('\n').pop()?.trim();
72
+ if (!tarballName) {
73
+ fs_1.default.writeFileSync(packageJsonPath, originalPackageJson);
74
+ return false;
75
+ }
76
+ const tarballPath = path_1.default.join(projectRoot, tarballName);
77
+ // Restore original package.json
78
+ fs_1.default.writeFileSync(packageJsonPath, originalPackageJson);
79
+ // 3. Create test project that depends on BOTH packages
80
+ console.log(' 🔧 Creating test project with conflicting dependencies...');
81
+ const testPackageJson = {
82
+ name: 'chalk-conflict-test',
83
+ version: '1.0.0',
84
+ dependencies: {
85
+ 'fake-chalk5-package': 'file:./fake-chalk5-package',
86
+ 'fraim-framework': `file:${tarballPath}`
87
+ }
88
+ };
89
+ fs_1.default.writeFileSync(path_1.default.join(tempDir, 'package.json'), JSON.stringify(testPackageJson, null, 2));
90
+ // 4. Install dependencies - npm will try to resolve chalk
91
+ console.log(' 📥 Installing with conflicting chalk requirements...');
92
+ console.log(' ⚠️ fake-chalk5-package wants chalk ^5.0.0');
93
+ console.log(' ⚠️ fraim-framework wants chalk ^4.1.2');
94
+ const installResult = await runCommand('npm', ['install'], tempDir);
95
+ if (installResult.code !== 0) {
96
+ console.log(' ⚠️ npm install failed (might be expected)');
97
+ console.log(` stderr: ${installResult.stderr.substring(0, 300)}`);
98
+ }
99
+ // 5. Check what version of chalk was installed for fraim-framework
100
+ const fraimChalkPath = path_1.default.join(tempDir, 'node_modules', 'fraim-framework', 'node_modules', 'chalk', 'package.json');
101
+ const rootChalkPath = path_1.default.join(tempDir, 'node_modules', 'chalk', 'package.json');
102
+ let fraimChalkVersion = null;
103
+ let rootChalkVersion = null;
104
+ if (fs_1.default.existsSync(fraimChalkPath)) {
105
+ const chalkPkg = JSON.parse(fs_1.default.readFileSync(fraimChalkPath, 'utf-8'));
106
+ fraimChalkVersion = chalkPkg.version;
107
+ console.log(` 📋 fraim-framework's chalk: ${fraimChalkVersion}`);
108
+ }
109
+ if (fs_1.default.existsSync(rootChalkPath)) {
110
+ const chalkPkg = JSON.parse(fs_1.default.readFileSync(rootChalkPath, 'utf-8'));
111
+ rootChalkVersion = chalkPkg.version;
112
+ console.log(` 📋 Root chalk: ${rootChalkVersion}`);
113
+ }
114
+ // 6. Try to load fraim CLI
115
+ console.log(' 🚀 Testing if fraim CLI loads...');
116
+ const testScript = `
117
+ try {
118
+ const fraimCli = require('./node_modules/fraim-framework/dist/src/cli/fraim.js');
119
+ console.log('SUCCESS: fraim CLI loaded');
120
+ process.exit(0);
121
+ } catch (error) {
122
+ if (error.code === 'ERR_REQUIRE_ESM') {
123
+ console.log('ERROR: ERR_REQUIRE_ESM - chalk v5 was used!');
124
+ console.log('Chalk version caused issue:', error.message);
125
+ process.exit(1);
126
+ } else {
127
+ console.log('ERROR: Other error:', error.message);
128
+ process.exit(2);
129
+ }
130
+ }
131
+ `;
132
+ fs_1.default.writeFileSync(path_1.default.join(tempDir, 'test.js'), testScript);
133
+ const testResult = await runCommand('node', ['test.js'], tempDir);
134
+ if (testResult.code === 1) {
135
+ console.log(' ❌ REPRODUCED THE BUG! npm resolved chalk to v5');
136
+ console.log(' ❌ fraim-framework with ^4.1.2 got chalk v5 due to conflict');
137
+ console.log(' ✅ This proves the issue exists with ^4.1.2');
138
+ // Cleanup
139
+ fs_1.default.unlinkSync(tarballPath);
140
+ return true; // We successfully reproduced the bug!
141
+ }
142
+ else if (testResult.code === 0) {
143
+ console.log(' ℹ️ fraim CLI loaded successfully');
144
+ console.log(' ℹ️ npm resolved the conflict without upgrading to v5');
145
+ console.log(' ℹ️ This scenario didn\'t trigger the bug, but it could in other environments');
146
+ }
147
+ else {
148
+ console.log(' ⚠️ Got unexpected error');
149
+ console.log(` stdout: ${testResult.stdout}`);
150
+ }
151
+ // Cleanup
152
+ fs_1.default.unlinkSync(tarballPath);
153
+ return true;
154
+ }
155
+ catch (error) {
156
+ console.error(' ❌ Test failed with error:', error);
157
+ return false;
158
+ }
159
+ finally {
160
+ try {
161
+ fs_1.default.rmSync(tempDir, { recursive: true, force: true });
162
+ console.log(' 🧹 Cleaned up temp directory');
163
+ }
164
+ catch (e) {
165
+ console.log(' ⚠️ Could not clean up temp directory');
166
+ }
167
+ }
168
+ }
169
+ async function testChalkResolutionWithPinnedVersion() {
170
+ console.log(' 🧪 Testing chalk resolution with PINNED version (4.1.2)...');
171
+ const tempDir = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), 'chalk-pinned-'));
172
+ console.log(` 📂 Created temp dir: ${tempDir}`);
173
+ try {
174
+ // 1. Create a package that depends on chalk v5
175
+ console.log(' 📦 Creating fake package that requires chalk v5...');
176
+ const fakePackageDir = path_1.default.join(tempDir, 'fake-chalk5-package');
177
+ fs_1.default.mkdirSync(fakePackageDir, { recursive: true });
178
+ const fakePackageJson = {
179
+ name: 'fake-chalk5-package',
180
+ version: '1.0.0',
181
+ dependencies: {
182
+ 'chalk': '^5.0.0'
183
+ }
184
+ };
185
+ fs_1.default.writeFileSync(path_1.default.join(fakePackageDir, 'package.json'), JSON.stringify(fakePackageJson, null, 2));
186
+ fs_1.default.writeFileSync(path_1.default.join(fakePackageDir, 'index.js'), 'export { default as chalk } from "chalk";\n');
187
+ // 2. Pack fraim-framework with 4.1.2 (PINNED - current state)
188
+ console.log(' 📦 Packing fraim-framework with pinned 4.1.2...');
189
+ const projectRoot = process.cwd();
190
+ const packResult = (0, node_child_process_1.execSync)('npm pack', {
191
+ cwd: projectRoot,
192
+ encoding: 'utf-8'
193
+ });
194
+ const tarballName = packResult.trim().split('\n').pop()?.trim();
195
+ if (!tarballName) {
196
+ return false;
197
+ }
198
+ const tarballPath = path_1.default.join(projectRoot, tarballName);
199
+ // 3. Create test project with conflicting dependencies
200
+ console.log(' 🔧 Creating test project with conflicting dependencies...');
201
+ const testPackageJson = {
202
+ name: 'chalk-pinned-test',
203
+ version: '1.0.0',
204
+ dependencies: {
205
+ 'fake-chalk5-package': 'file:./fake-chalk5-package',
206
+ 'fraim-framework': `file:${tarballPath}`
207
+ }
208
+ };
209
+ fs_1.default.writeFileSync(path_1.default.join(tempDir, 'package.json'), JSON.stringify(testPackageJson, null, 2));
210
+ // 4. Install dependencies
211
+ console.log(' 📥 Installing with conflicting chalk requirements...');
212
+ console.log(' ⚠️ fake-chalk5-package wants chalk ^5.0.0');
213
+ console.log(' ✅ fraim-framework wants chalk 4.1.2 (PINNED)');
214
+ const installResult = await runCommand('npm', ['install'], tempDir);
215
+ if (installResult.code !== 0) {
216
+ console.log(' ⚠️ npm install failed');
217
+ }
218
+ // 5. Check chalk versions
219
+ const fraimChalkPath = path_1.default.join(tempDir, 'node_modules', 'fraim-framework', 'node_modules', 'chalk', 'package.json');
220
+ const rootChalkPath = path_1.default.join(tempDir, 'node_modules', 'chalk', 'package.json');
221
+ let fraimChalkVersion = null;
222
+ let rootChalkVersion = null;
223
+ if (fs_1.default.existsSync(fraimChalkPath)) {
224
+ const chalkPkg = JSON.parse(fs_1.default.readFileSync(fraimChalkPath, 'utf-8'));
225
+ fraimChalkVersion = chalkPkg.version;
226
+ console.log(` 📋 fraim-framework's chalk: ${fraimChalkVersion}`);
227
+ }
228
+ if (fs_1.default.existsSync(rootChalkPath)) {
229
+ const chalkPkg = JSON.parse(fs_1.default.readFileSync(rootChalkPath, 'utf-8'));
230
+ rootChalkVersion = chalkPkg.version;
231
+ console.log(` 📋 Root chalk: ${rootChalkVersion}`);
232
+ }
233
+ // Verify fraim has v4
234
+ if (fraimChalkVersion && !fraimChalkVersion.startsWith('4.')) {
235
+ console.log(` ❌ PINNED version failed! Got chalk ${fraimChalkVersion}`);
236
+ fs_1.default.unlinkSync(tarballPath);
237
+ return false;
238
+ }
239
+ // 6. Try to load fraim CLI
240
+ console.log(' 🚀 Testing if fraim CLI loads...');
241
+ const testScript = `
242
+ try {
243
+ const fraimCli = require('./node_modules/fraim-framework/dist/src/cli/fraim.js');
244
+ console.log('SUCCESS: fraim CLI loaded with pinned chalk');
245
+ process.exit(0);
246
+ } catch (error) {
247
+ if (error.code === 'ERR_REQUIRE_ESM') {
248
+ console.log('ERROR: ERR_REQUIRE_ESM even with pinned version!');
249
+ process.exit(1);
250
+ } else {
251
+ console.log('ERROR: Other error:', error.message);
252
+ process.exit(2);
253
+ }
254
+ }
255
+ `;
256
+ fs_1.default.writeFileSync(path_1.default.join(tempDir, 'test.js'), testScript);
257
+ const testResult = await runCommand('node', ['test.js'], tempDir);
258
+ if (testResult.code === 0) {
259
+ console.log(' ✅ SUCCESS! Pinned version prevents chalk v5 upgrade');
260
+ console.log(' ✅ fraim CLI works even with chalk v5 dependency nearby');
261
+ console.log(' ✅ This proves the fix works!');
262
+ }
263
+ else if (testResult.code === 1) {
264
+ console.log(' ❌ FAILED! Even pinned version got chalk v5');
265
+ console.log(' ❌ The fix doesn\'t work!');
266
+ fs_1.default.unlinkSync(tarballPath);
267
+ return false;
268
+ }
269
+ // Cleanup
270
+ fs_1.default.unlinkSync(tarballPath);
271
+ return true;
272
+ }
273
+ catch (error) {
274
+ console.error(' ❌ Test failed with error:', error);
275
+ return false;
276
+ }
277
+ finally {
278
+ try {
279
+ fs_1.default.rmSync(tempDir, { recursive: true, force: true });
280
+ console.log(' 🧹 Cleaned up temp directory');
281
+ }
282
+ catch (e) {
283
+ console.log(' ⚠️ Could not clean up temp directory');
284
+ }
285
+ }
286
+ }
287
+ async function runChalkResolutionTest(testCase) {
288
+ return await testCase.testFunction();
289
+ }
290
+ const testCases = [
291
+ {
292
+ name: 'Chalk Resolution with Conflict (^4.1.2)',
293
+ description: 'Tests if ^4.1.2 allows npm to upgrade to chalk v5 when there\'s a conflicting dependency',
294
+ testFunction: testChalkResolutionWithConflict,
295
+ tags: ['chalk', 'resolution', 'conflict']
296
+ },
297
+ {
298
+ name: 'Chalk Resolution with Pinned Version (4.1.2)',
299
+ description: 'Tests if pinned 4.1.2 prevents npm from upgrading to chalk v5',
300
+ testFunction: testChalkResolutionWithPinnedVersion,
301
+ tags: ['chalk', 'resolution', 'pinned', 'fix']
302
+ }
303
+ ];
304
+ (0, test_utils_1.runTests)(testCases, runChalkResolutionTest, 'Chalk Resolution Issue Test');
@@ -0,0 +1,254 @@
1
+ "use strict";
2
+ /**
3
+ * Integration test to verify fraim-framework installs correctly
4
+ * and doesn't have the chalk ESM issue
5
+ *
6
+ * This test:
7
+ * 1. Packs the current fraim-framework into a tarball
8
+ * 2. Installs it fresh in a temp directory
9
+ * 3. Runs fraim init to verify it works
10
+ * 4. Tests with both pinned (4.1.2) and unpinned (^4.1.2) chalk versions
11
+ */
12
+ var __importDefault = (this && this.__importDefault) || function (mod) {
13
+ return (mod && mod.__esModule) ? mod : { "default": mod };
14
+ };
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ const node_child_process_1 = require("node:child_process");
17
+ const test_utils_1 = require("./test-utils");
18
+ const fs_1 = __importDefault(require("fs"));
19
+ const path_1 = __importDefault(require("path"));
20
+ const os_1 = __importDefault(require("os"));
21
+ async function runCommand(command, args, cwd) {
22
+ return new Promise((resolve) => {
23
+ const proc = (0, node_child_process_1.spawn)(command, args, {
24
+ cwd,
25
+ stdio: 'pipe',
26
+ shell: true
27
+ });
28
+ let stdout = '';
29
+ let stderr = '';
30
+ proc.stdout?.on('data', (data) => {
31
+ stdout += data.toString();
32
+ });
33
+ proc.stderr?.on('data', (data) => {
34
+ stderr += data.toString();
35
+ });
36
+ proc.on('close', (code) => {
37
+ resolve({ code, stdout, stderr });
38
+ });
39
+ });
40
+ }
41
+ async function testFraimInstallWithPinnedChalk() {
42
+ console.log(' 🧪 Testing FRAIM install with PINNED chalk (4.1.2)...');
43
+ const tempDir = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), 'fraim-install-pinned-'));
44
+ console.log(` 📂 Created temp dir: ${tempDir}`);
45
+ try {
46
+ // 1. Pack the current fraim-framework
47
+ console.log(' 📦 Packing fraim-framework...');
48
+ const projectRoot = process.cwd();
49
+ // Run npm pack in the project root
50
+ const packResult = (0, node_child_process_1.execSync)('npm pack', {
51
+ cwd: projectRoot,
52
+ encoding: 'utf-8'
53
+ });
54
+ const tarballName = packResult.trim().split('\n').pop()?.trim();
55
+ if (!tarballName) {
56
+ console.log(' ❌ Failed to get tarball name');
57
+ return false;
58
+ }
59
+ const tarballPath = path_1.default.join(projectRoot, tarballName);
60
+ console.log(` ✅ Created tarball: ${tarballName}`);
61
+ // 2. Create a test project
62
+ const testPackageJson = {
63
+ name: 'fraim-install-test',
64
+ version: '1.0.0',
65
+ private: true
66
+ };
67
+ fs_1.default.writeFileSync(path_1.default.join(tempDir, 'package.json'), JSON.stringify(testPackageJson, null, 2));
68
+ // 3. Install fraim-framework from the tarball
69
+ console.log(' 📥 Installing fraim-framework from tarball...');
70
+ const installResult = await runCommand('npm', ['install', tarballPath, '--silent'], tempDir);
71
+ if (installResult.code !== 0) {
72
+ console.log(' ❌ npm install failed');
73
+ console.log(` stderr: ${installResult.stderr.substring(0, 500)}`);
74
+ return false;
75
+ }
76
+ console.log(' ✅ fraim-framework installed successfully');
77
+ // 4. Check which version of chalk was installed
78
+ const chalkPackageJsonPath = path_1.default.join(tempDir, 'node_modules', 'chalk', 'package.json');
79
+ if (!fs_1.default.existsSync(chalkPackageJsonPath)) {
80
+ console.log(' ❌ chalk not found in node_modules');
81
+ return false;
82
+ }
83
+ const chalkPackageJson = JSON.parse(fs_1.default.readFileSync(chalkPackageJsonPath, 'utf-8'));
84
+ console.log(` 📋 Installed chalk version: ${chalkPackageJson.version}`);
85
+ // Verify it's v4.x
86
+ if (!chalkPackageJson.version.startsWith('4.')) {
87
+ console.log(` ❌ Expected chalk v4.x, got ${chalkPackageJson.version}`);
88
+ return false;
89
+ }
90
+ console.log(' ✅ Chalk v4 installed correctly');
91
+ // 5. Try to run fraim init (should work)
92
+ console.log(' 🚀 Running fraim init...');
93
+ const fraimBin = path_1.default.join(tempDir, 'node_modules', '.bin', 'fraim');
94
+ // Create a simple test by requiring the CLI directly
95
+ const testScript = `
96
+ const fraimCli = require('./node_modules/fraim-framework/dist/src/cli/fraim.js');
97
+ console.log('✅ fraim CLI loaded successfully');
98
+ `;
99
+ fs_1.default.writeFileSync(path_1.default.join(tempDir, 'test.js'), testScript);
100
+ const testResult = await runCommand('node', ['test.js'], tempDir);
101
+ if (testResult.code !== 0) {
102
+ console.log(' ❌ Failed to load fraim CLI');
103
+ console.log(` stderr: ${testResult.stderr.substring(0, 500)}`);
104
+ return false;
105
+ }
106
+ if (!testResult.stdout.includes('fraim CLI loaded successfully')) {
107
+ console.log(' ❌ fraim CLI did not load correctly');
108
+ return false;
109
+ }
110
+ console.log(' ✅ fraim CLI works with pinned chalk!');
111
+ // Cleanup tarball
112
+ fs_1.default.unlinkSync(tarballPath);
113
+ return true;
114
+ }
115
+ catch (error) {
116
+ console.error(' ❌ Test failed with error:', error);
117
+ return false;
118
+ }
119
+ finally {
120
+ // Cleanup
121
+ try {
122
+ fs_1.default.rmSync(tempDir, { recursive: true, force: true });
123
+ console.log(' 🧹 Cleaned up temp directory');
124
+ }
125
+ catch (e) {
126
+ console.log(' ⚠️ Could not clean up temp directory');
127
+ }
128
+ }
129
+ }
130
+ async function testFraimInstallWithUnpinnedChalk() {
131
+ console.log(' 🧪 Testing FRAIM install with UNPINNED chalk (^4.1.2)...');
132
+ console.log(' ⚠️ This simulates the original issue...');
133
+ const tempDir = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), 'fraim-install-unpinned-'));
134
+ console.log(` 📂 Created temp dir: ${tempDir}`);
135
+ try {
136
+ // 1. Temporarily modify package.json to use ^4.1.2
137
+ const projectRoot = process.cwd();
138
+ const packageJsonPath = path_1.default.join(projectRoot, 'package.json');
139
+ const originalPackageJson = fs_1.default.readFileSync(packageJsonPath, 'utf-8');
140
+ const packageJson = JSON.parse(originalPackageJson);
141
+ // Save original chalk version
142
+ const originalChalkVersion = packageJson.dependencies.chalk;
143
+ console.log(` 📋 Original chalk version: ${originalChalkVersion}`);
144
+ // Temporarily change to ^4.1.2
145
+ packageJson.dependencies.chalk = '^4.1.2';
146
+ fs_1.default.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
147
+ console.log(' 🔄 Temporarily changed chalk to ^4.1.2');
148
+ // 2. Pack with unpinned version
149
+ console.log(' 📦 Packing fraim-framework with unpinned chalk...');
150
+ const packResult = (0, node_child_process_1.execSync)('npm pack', {
151
+ cwd: projectRoot,
152
+ encoding: 'utf-8'
153
+ });
154
+ const tarballName = packResult.trim().split('\n').pop()?.trim();
155
+ if (!tarballName) {
156
+ console.log(' ❌ Failed to get tarball name');
157
+ // Restore original package.json
158
+ fs_1.default.writeFileSync(packageJsonPath, originalPackageJson);
159
+ return false;
160
+ }
161
+ const tarballPath = path_1.default.join(projectRoot, tarballName);
162
+ console.log(` ✅ Created tarball: ${tarballName}`);
163
+ // 3. Restore original package.json
164
+ fs_1.default.writeFileSync(packageJsonPath, originalPackageJson);
165
+ console.log(' ✅ Restored original package.json');
166
+ // 4. Create a test project
167
+ const testPackageJson = {
168
+ name: 'fraim-install-test-unpinned',
169
+ version: '1.0.0',
170
+ private: true
171
+ };
172
+ fs_1.default.writeFileSync(path_1.default.join(tempDir, 'package.json'), JSON.stringify(testPackageJson, null, 2));
173
+ // 5. Install fraim-framework from the tarball
174
+ console.log(' 📥 Installing fraim-framework with unpinned chalk...');
175
+ const installResult = await runCommand('npm', ['install', tarballPath, '--silent'], tempDir);
176
+ if (installResult.code !== 0) {
177
+ console.log(' ❌ npm install failed');
178
+ console.log(` stderr: ${installResult.stderr.substring(0, 500)}`);
179
+ fs_1.default.unlinkSync(tarballPath);
180
+ return false;
181
+ }
182
+ console.log(' ✅ fraim-framework installed');
183
+ // 6. Check which version of chalk was installed
184
+ const chalkPackageJsonPath = path_1.default.join(tempDir, 'node_modules', 'chalk', 'package.json');
185
+ if (!fs_1.default.existsSync(chalkPackageJsonPath)) {
186
+ console.log(' ❌ chalk not found in node_modules');
187
+ fs_1.default.unlinkSync(tarballPath);
188
+ return false;
189
+ }
190
+ const chalkPackageJson = JSON.parse(fs_1.default.readFileSync(chalkPackageJsonPath, 'utf-8'));
191
+ console.log(` 📋 Installed chalk version: ${chalkPackageJson.version}`);
192
+ // 7. Try to load fraim CLI
193
+ const testScript = `
194
+ const fraimCli = require('./node_modules/fraim-framework/dist/src/cli/fraim.js');
195
+ console.log('✅ fraim CLI loaded successfully');
196
+ `;
197
+ fs_1.default.writeFileSync(path_1.default.join(tempDir, 'test.js'), testScript);
198
+ const testResult = await runCommand('node', ['test.js'], tempDir);
199
+ // With ^4.1.2, it MIGHT install v5 in some scenarios, causing ERR_REQUIRE_ESM
200
+ if (testResult.code !== 0) {
201
+ if (testResult.stderr.includes('ERR_REQUIRE_ESM')) {
202
+ console.log(' ⚠️ Got ERR_REQUIRE_ESM error (this is the bug we fixed!)');
203
+ console.log(` 📋 Chalk version that caused issue: ${chalkPackageJson.version}`);
204
+ console.log(' ✅ Test successfully reproduced the original issue');
205
+ fs_1.default.unlinkSync(tarballPath);
206
+ return true; // This is expected - we reproduced the bug
207
+ }
208
+ else {
209
+ console.log(' ❌ Failed with unexpected error');
210
+ console.log(` stderr: ${testResult.stderr.substring(0, 500)}`);
211
+ fs_1.default.unlinkSync(tarballPath);
212
+ return false;
213
+ }
214
+ }
215
+ // If it worked, that's also fine - means npm resolved to v4
216
+ console.log(' ✅ fraim CLI works (npm resolved to v4)');
217
+ console.log(' ℹ️ Note: ^4.1.2 worked this time, but could fail in other environments');
218
+ // Cleanup tarball
219
+ fs_1.default.unlinkSync(tarballPath);
220
+ return true;
221
+ }
222
+ catch (error) {
223
+ console.error(' ❌ Test failed with error:', error);
224
+ return false;
225
+ }
226
+ finally {
227
+ // Cleanup
228
+ try {
229
+ fs_1.default.rmSync(tempDir, { recursive: true, force: true });
230
+ console.log(' 🧹 Cleaned up temp directory');
231
+ }
232
+ catch (e) {
233
+ console.log(' ⚠️ Could not clean up temp directory');
234
+ }
235
+ }
236
+ }
237
+ async function runFraimInstallTest(testCase) {
238
+ return await testCase.testFunction();
239
+ }
240
+ const testCases = [
241
+ {
242
+ name: 'FRAIM Install with Pinned Chalk',
243
+ description: 'Verifies fraim-framework installs correctly with chalk pinned to 4.1.2',
244
+ testFunction: testFraimInstallWithPinnedChalk,
245
+ tags: ['integration', 'install', 'chalk']
246
+ },
247
+ {
248
+ name: 'FRAIM Install with Unpinned Chalk',
249
+ description: 'Tests fraim-framework with ^4.1.2 to see if it can reproduce the issue',
250
+ testFunction: testFraimInstallWithUnpinnedChalk,
251
+ tags: ['integration', 'install', 'chalk', 'reproduction']
252
+ }
253
+ ];
254
+ (0, test_utils_1.runTests)(testCases, runFraimInstallTest, 'FRAIM Install Chalk Issue Test');