fraim-framework 2.0.27 โ†’ 2.0.33

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 (130) hide show
  1. package/.github/workflows/deploy-fraim.yml +1 -1
  2. package/dist/registry/scripts/build-scripts-generator.js +205 -0
  3. package/dist/registry/scripts/cleanup-branch.js +258 -0
  4. package/dist/registry/scripts/evaluate-code-quality.js +66 -0
  5. package/dist/registry/scripts/exec-with-timeout.js +142 -0
  6. package/dist/registry/scripts/fraim-config.js +61 -0
  7. package/dist/registry/scripts/generate-engagement-emails.js +630 -0
  8. package/dist/registry/scripts/generic-issues-api.js +100 -0
  9. package/dist/registry/scripts/newsletter-helpers.js +731 -0
  10. package/dist/registry/scripts/openapi-generator.js +664 -0
  11. package/{registry/scripts/performance/profile-server.ts โ†’ dist/registry/scripts/performance/profile-server.js} +390 -368
  12. package/dist/registry/scripts/run-thank-you-workflow.js +92 -0
  13. package/dist/registry/scripts/send-newsletter-simple.js +85 -0
  14. package/dist/registry/scripts/send-thank-you-emails.js +54 -0
  15. package/dist/registry/scripts/validate-openapi-limits.js +311 -0
  16. package/dist/registry/scripts/validate-test-coverage.js +262 -0
  17. package/dist/registry/scripts/verify-test-coverage.js +66 -0
  18. package/dist/src/cli/commands/init.js +42 -15
  19. package/dist/src/cli/commands/sync.js +22 -5
  20. package/dist/src/cli/fraim.js +24 -22
  21. package/dist/src/cli/setup/first-run.js +13 -6
  22. package/dist/src/fraim/db-service.js +26 -15
  23. package/dist/src/fraim/issues.js +67 -0
  24. package/dist/src/fraim-mcp-server.js +272 -18
  25. package/dist/src/utils/git-utils.js +1 -1
  26. package/dist/src/utils/script-sync-utils.js +218 -0
  27. package/dist/tests/debug-tools.js +80 -0
  28. package/dist/tests/esm-compat.js +11 -0
  29. package/dist/tests/test-chalk-esm-issue.js +159 -0
  30. package/dist/tests/test-chalk-real-world.js +265 -0
  31. package/dist/tests/test-chalk-regression.js +377 -0
  32. package/dist/tests/test-chalk-resolution-issue.js +304 -0
  33. package/dist/tests/test-cli.js +70 -5
  34. package/dist/tests/test-end-to-end-hybrid-validation.js +349 -0
  35. package/dist/tests/test-first-run-journey.js +43 -3
  36. package/dist/tests/test-fraim-install-chalk-issue.js +254 -0
  37. package/dist/tests/test-fraim-issues.js +59 -0
  38. package/dist/tests/test-genericization.js +1 -1
  39. package/dist/tests/test-hybrid-script-execution.js +369 -0
  40. package/dist/tests/test-mcp-connection.js +166 -0
  41. package/dist/tests/test-mcp-issue-integration.js +152 -0
  42. package/dist/tests/test-mcp-lifecycle-methods.js +312 -0
  43. package/dist/tests/test-node-compatibility.js +93 -0
  44. package/dist/tests/test-npm-install.js +66 -0
  45. package/dist/tests/test-npm-resolution-diagnostic.js +140 -0
  46. package/dist/tests/test-prep-issue.js +4 -1
  47. package/dist/tests/test-script-location-independence.js +173 -0
  48. package/dist/tests/test-script-sync.js +557 -0
  49. package/dist/tests/test-session-rehydration.js +145 -0
  50. package/dist/tests/test-standalone.js +5 -11
  51. package/dist/tests/test-sync-version-update.js +1 -1
  52. package/dist/tests/test-telemetry.js +190 -0
  53. package/dist/tests/test-user-journey.js +8 -4
  54. package/dist/tests/test-utils.js +13 -0
  55. package/dist/tests/test-wizard.js +2 -2
  56. package/package.json +11 -9
  57. package/registry/agent-guardrails.md +62 -54
  58. package/registry/rules/agent-success-criteria.md +52 -0
  59. package/registry/rules/agent-testing-guidelines.md +7 -7
  60. package/registry/rules/communication.md +121 -121
  61. package/registry/rules/continuous-learning.md +54 -54
  62. package/registry/rules/ephemeral-execution.md +39 -24
  63. package/registry/rules/hitl-ppe-record-analysis.md +302 -302
  64. package/registry/rules/local-development.md +7 -5
  65. package/registry/rules/software-development-lifecycle.md +104 -104
  66. package/registry/rules/successful-debugging-patterns.md +29 -16
  67. package/registry/rules/telemetry.md +67 -0
  68. package/registry/scripts/code-quality-check.sh +559 -559
  69. package/registry/scripts/detect-tautological-tests.sh +38 -38
  70. package/registry/scripts/evaluate-code-quality.ts +1 -1
  71. package/registry/scripts/prep-issue.sh +16 -3
  72. package/registry/scripts/validate-openapi-limits.ts +366 -365
  73. package/registry/scripts/validate-test-coverage.ts +280 -280
  74. package/registry/scripts/verify-pr-comments.sh +70 -70
  75. package/registry/scripts/verify-test-coverage.ts +1 -1
  76. package/registry/templates/bootstrap/ARCHITECTURE-TEMPLATE.md +53 -53
  77. package/registry/templates/evidence/Implementation-BugEvidence.md +85 -85
  78. package/registry/templates/evidence/Implementation-FeatureEvidence.md +120 -120
  79. package/registry/templates/marketing/HBR-ARTICLE-TEMPLATE.md +66 -0
  80. package/registry/workflows/bootstrap/create-architecture.md +2 -2
  81. package/registry/workflows/bootstrap/evaluate-code-quality.md +10 -4
  82. package/registry/workflows/bootstrap/verify-test-coverage.md +9 -3
  83. package/registry/workflows/customer-development/insight-analysis.md +156 -156
  84. package/registry/workflows/customer-development/interview-preparation.md +421 -421
  85. package/registry/workflows/customer-development/strategic-brainstorming.md +146 -146
  86. package/registry/workflows/customer-development/thank-customers.md +14 -2
  87. package/registry/workflows/customer-development/weekly-newsletter.md +27 -13
  88. package/registry/workflows/improve-fraim/contribute.md +32 -0
  89. package/registry/workflows/improve-fraim/file-issue.md +32 -0
  90. package/registry/workflows/marketing/hbr-article.md +73 -0
  91. package/registry/workflows/performance/analyze-performance.md +10 -4
  92. package/registry/workflows/product-building/design.md +3 -2
  93. package/registry/workflows/product-building/implement.md +10 -5
  94. package/registry/workflows/product-building/prep-issue.md +16 -18
  95. package/registry/workflows/product-building/resolve.md +8 -3
  96. package/registry/workflows/product-building/retrospect.md +3 -2
  97. package/registry/workflows/product-building/spec.md +5 -4
  98. package/registry/workflows/product-building/test.md +3 -2
  99. package/registry/workflows/quality-assurance/iterative-improvement-cycle.md +562 -562
  100. package/registry/workflows/replicate/replicate-discovery.md +336 -0
  101. package/registry/workflows/replicate/replicate-to-issues.md +319 -0
  102. package/registry/workflows/reviewer/review-implementation-vs-design-spec.md +3 -3
  103. package/registry/workflows/reviewer/review-implementation-vs-feature-spec.md +669 -669
  104. package/tsconfig.json +2 -1
  105. package/.windsurf/rules/windsurf-rules.md +0 -7
  106. package/.windsurf/workflows/resolve-issue.md +0 -6
  107. package/.windsurf/workflows/retrospect.md +0 -6
  108. package/.windsurf/workflows/start-design.md +0 -6
  109. package/.windsurf/workflows/start-impl.md +0 -6
  110. package/.windsurf/workflows/start-spec.md +0 -6
  111. package/.windsurf/workflows/start-tests.md +0 -6
  112. package/bin/fraim.js +0 -23
  113. package/registry/scripts/build-scripts-generator.ts +0 -215
  114. package/registry/scripts/cleanup-branch.ts +0 -284
  115. package/registry/scripts/fraim-config.ts +0 -63
  116. package/registry/scripts/generate-engagement-emails.ts +0 -744
  117. package/registry/scripts/generic-issues-api.ts +0 -150
  118. package/registry/scripts/newsletter-helpers.ts +0 -874
  119. package/registry/scripts/openapi-generator.ts +0 -693
  120. package/registry/scripts/run-thank-you-workflow.ts +0 -122
  121. package/registry/scripts/send-newsletter-simple.ts +0 -104
  122. package/registry/scripts/send-thank-you-emails.ts +0 -57
  123. package/registry/workflows/replicate/re-implementation-strategy.md +0 -226
  124. package/registry/workflows/replicate/use-case-extraction.md +0 -135
  125. package/registry/workflows/replicate/visual-analysis.md +0 -154
  126. package/registry/workflows/replicate/website-discovery-analysis.md +0 -231
  127. package/sample_package.json +0 -18
  128. /package/registry/scripts/{replicate/comprehensive-explorer.py โ†’ comprehensive-explorer.py} +0 -0
  129. /package/registry/scripts/{replicate/interactive-explorer.py โ†’ interactive-explorer.py} +0 -0
  130. /package/registry/scripts/{replicate/scrape-site.py โ†’ scrape-site.py} +0 -0
package/tsconfig.json CHANGED
@@ -14,7 +14,8 @@
14
14
  },
15
15
  "include": [
16
16
  "src/**/*.ts",
17
- "tests/**/*.ts"
17
+ "tests/**/*.ts",
18
+ "registry/**/*.ts"
18
19
  ],
19
20
  "exclude": [
20
21
  "node_modules"
@@ -1,7 +0,0 @@
1
- ---
2
- trigger: always_on
3
- ---
4
-
5
- # Windsurf AI Agent Rules
6
-
7
- Thoroughly review `.ai-agents/agent-guardrails.md`
@@ -1,6 +0,0 @@
1
- ---
2
- description: Resolve issue (once confirmed complete)
3
- auto_execution_mode: 3
4
- ---
5
-
6
- Follow instructions in `.ai-agents/workflows/resolve.md`
@@ -1,6 +0,0 @@
1
- ---
2
- description: Resolve issue (once confirmed complete)
3
- auto_execution_mode: 3
4
- ---
5
-
6
- Follow instructions in `.ai-agents/workflows/retrospect.md`
@@ -1,6 +0,0 @@
1
- ---
2
- description: Start working on the issue
3
- auto_execution_mode: 3
4
- ---
5
-
6
- Follow instructions in `.ai-agents/workflows/design.md`
@@ -1,6 +0,0 @@
1
- ---
2
- description: Implement issue
3
- auto_execution_mode: 3
4
- ---
5
-
6
- Follow instructions in `.ai-agents/workflows/implement.md`
@@ -1,6 +0,0 @@
1
- ---
2
- description: Spec Issue
3
- auto_execution_mode: 3
4
- ---
5
-
6
- Follow instructions in `.ai-agents/workflows/spec.md`
@@ -1,6 +0,0 @@
1
- ---
2
- description: Start writing tests
3
- auto_execution_mode: 3
4
- ---
5
-
6
- Follow instructions in `.ai-agents/workflows/test.md`
package/bin/fraim.js DELETED
@@ -1,23 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * FRAIM Framework CLI Entry Point
5
- *
6
- * This file delegates to the compiled TypeScript implementation.
7
- */
8
-
9
- try {
10
- // In production/installed package, code is in dist/
11
- require('../dist/src/cli/fraim.js');
12
- } catch (error) {
13
- if (error.code === 'MODULE_NOT_FOUND') {
14
- // In development (local clone), we might use tsx if dist is missing
15
- // But typically we should just tell user to build.
16
- console.error('โŒ Could not find FRAIM CLI implementation.');
17
- console.error(' If you are running from source, please run "npm run build" first.');
18
- console.error(` Error details: ${error.message}`);
19
- process.exit(1);
20
- } else {
21
- throw error;
22
- }
23
- }
@@ -1,215 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * FRAIM Build Scripts Generator
5
- *
6
- * Generates generic build scripts and validation patterns.
7
- * These are generic enough to apply to any project.
8
- *
9
- * Usage:
10
- * npx tsx .ai-agents/scripts/build-scripts-generator.ts
11
- */
12
-
13
- import { writeFileSync, existsSync, mkdirSync } from 'fs';
14
- import { join } from 'path';
15
- import { loadFraimConfig } from '../../../src/fraim/config-loader.js';
16
-
17
- /**
18
- * Generate package.json scripts section
19
- */
20
- export function generatePackageScripts(config: any): any {
21
- return {
22
- "build": "tsc && npm run validate:openapi",
23
- "validate:openapi": "npx tsx fraim/generators/validate-openapi-limits.ts",
24
- "start": "node dist/src/server.js",
25
- "start:mcp": "node dist/src/mcp-server.js",
26
- "dev": "npx tsx --watch src/server.ts",
27
- "dev:mcp": "tsx src/mcp-server.ts",
28
- "generate:openapi": "npx tsx fraim/generators/openapi-generator.ts",
29
- "test": "npx tsx --test test*.ts",
30
- "lint": "eslint *.ts",
31
- "lint:fix": "eslint *.ts --fix"
32
- };
33
- }
34
-
35
- /**
36
- * Generate code quality check script (generic version)
37
- */
38
- export function generateCodeQualityScript(outputDir: string): void {
39
- if (!existsSync(outputDir)) {
40
- mkdirSync(outputDir, { recursive: true });
41
- }
42
-
43
- const scriptContent = `#!/bin/bash
44
-
45
- # FRAIM Generic Code Quality Check
46
- # Validates code quality, build, and ChatGPT limits
47
-
48
- set -e
49
-
50
- MODE=\${1:-full}
51
- FAILED=0
52
- WARNINGS=0
53
-
54
- echo "================================================"
55
- echo "๐Ÿ” CODE QUALITY CHECK ($MODE mode)"
56
- echo "================================================"
57
- echo ""
58
-
59
- # Build check
60
- if [ "$MODE" = "full" ] || [ "$MODE" = "build" ]; then
61
- echo "๐Ÿ“ฆ Building project..."
62
- if npm run build; then
63
- echo "โœ… Build passed"
64
- else
65
- echo "โŒ Build failed"
66
- FAILED=1
67
- fi
68
- echo ""
69
- fi
70
-
71
- # Lint check
72
- if [ "$MODE" = "full" ] || [ "$MODE" = "lint" ]; then
73
- echo "๐Ÿ” Linting code..."
74
- if npm run lint; then
75
- echo "โœ… Lint passed"
76
- else
77
- echo "โš ๏ธ Lint warnings (non-blocking)"
78
- WARNINGS=1
79
- fi
80
- echo ""
81
- fi
82
-
83
- # OpenAPI validation (ChatGPT limits)
84
- if [ "$MODE" = "full" ] || [ "$MODE" = "openapi" ]; then
85
- echo "๐Ÿ“‹ Validating OpenAPI and ChatGPT limits..."
86
- if npm run validate:openapi; then
87
- echo "โœ… OpenAPI validation passed"
88
- else
89
- echo "โŒ OpenAPI validation failed"
90
- FAILED=1
91
- fi
92
- echo ""
93
- fi
94
-
95
- # Summary
96
- echo "================================================"
97
- echo "๐Ÿ“Š QUALITY CHECK SUMMARY ($MODE mode)"
98
- echo "================================================"
99
- echo ""
100
-
101
- if [ $FAILED -eq 1 ]; then
102
- echo "โŒ CHECKS FAILED"
103
- echo ""
104
- echo "Fix the errors above before proceeding."
105
- exit 1
106
- elif [ $WARNINGS -eq 1 ]; then
107
- echo "โš ๏ธ CHECKS PASSED WITH WARNINGS"
108
- echo ""
109
- echo "Review warnings above."
110
- exit 0
111
- else
112
- echo "โœ… ALL CHECKS PASSED"
113
- echo ""
114
- exit 0
115
- fi
116
- `;
117
-
118
- const scriptPath = join(outputDir, 'code-quality-check.sh');
119
- writeFileSync(scriptPath, scriptContent);
120
-
121
- // Make executable (Unix)
122
- if (process.platform !== 'win32') {
123
- const { execSync } = require('child_process');
124
- execSync(`chmod +x ${scriptPath}`);
125
- }
126
-
127
- console.log(`โœ… Generated code quality check script at ${scriptPath}`);
128
- }
129
-
130
- /**
131
- * Generate build copy scripts (generic)
132
- */
133
- export function generateCopyScripts(outputDir: string): void {
134
- if (!existsSync(outputDir)) {
135
- mkdirSync(outputDir, { recursive: true });
136
- }
137
-
138
- // Copy AI agents script (if .ai-agents exists)
139
- const copyAiAgents = `#!/usr/bin/env node
140
-
141
- /**
142
- * Copy .ai-agents directory to dist
143
- * Generic build script for FRAIM projects
144
- */
145
-
146
- const fs = require('fs');
147
- const path = require('path');
148
-
149
- const sourceDir = path.join(__dirname, '..', '.ai-agents');
150
- const destDir = path.join(__dirname, '..', 'dist', '.ai-agents');
151
-
152
- if (fs.existsSync(sourceDir)) {
153
- // Recursive copy
154
- function copyRecursive(src, dest) {
155
- if (!fs.existsSync(dest)) {
156
- fs.mkdirSync(dest, { recursive: true });
157
- }
158
-
159
- const entries = fs.readdirSync(src, { withFileTypes: true });
160
-
161
- for (const entry of entries) {
162
- const srcPath = path.join(src, entry.name);
163
- const destPath = path.join(dest, entry.name);
164
-
165
- if (entry.isDirectory()) {
166
- copyRecursive(srcPath, destPath);
167
- } else {
168
- fs.copyFileSync(srcPath, destPath);
169
- }
170
- }
171
- }
172
-
173
- copyRecursive(sourceDir, destDir);
174
- console.log('โœ… Copied .ai-agents to dist/.ai-agents');
175
- } else {
176
- console.log('โ„น๏ธ .ai-agents directory not found, skipping');
177
- }
178
- `;
179
-
180
- writeFileSync(join(outputDir, 'copy-ai-agents.js'), copyAiAgents);
181
- console.log(`โœ… Generated copy-ai-agents.js`);
182
- }
183
-
184
- /**
185
- * Main generator function
186
- */
187
- export function generateBuildScripts(config: any, outputDir: string = 'scripts/build'): void {
188
- console.log('๐Ÿš€ FRAIM Build Scripts Generator\n');
189
- console.log(`๐Ÿ“ Output directory: ${outputDir}\n`);
190
-
191
- // Ensure output directory exists
192
- if (!existsSync(outputDir)) {
193
- mkdirSync(outputDir, { recursive: true });
194
- }
195
-
196
- // Generate code quality check
197
- console.log('๐Ÿ“ Generating code quality check script...');
198
- generateCodeQualityScript(outputDir);
199
-
200
- // Generate build scripts
201
- console.log('\n๐Ÿ“ Generating build scripts...');
202
- generateCopyScripts(outputDir);
203
-
204
- console.log('\nโœ… Build scripts generation complete!');
205
- console.log('\n๐Ÿ“‹ Next steps:');
206
- console.log('1. Add scripts to package.json');
207
- console.log('2. Run: npm run validate:openapi');
208
- console.log('3. Run: ./scripts/build/code-quality-check.sh');
209
- }
210
-
211
- // Run if executed directly
212
- if (import.meta.url === `file://${process.argv[1]}`) {
213
- const config = loadFraimConfig();
214
- generateBuildScripts(config);
215
- }
@@ -1,284 +0,0 @@
1
- #!/usr/bin/env npx tsx
2
-
3
- import { execSync } from 'child_process';
4
- import dotenv from 'dotenv';
5
-
6
- // Load environment variables
7
- dotenv.config({ override: true });
8
-
9
- interface CleanupOptions {
10
- branchName?: string;
11
- force?: boolean;
12
- skipProjectCleanup?: boolean;
13
- skipGit?: boolean;
14
- }
15
-
16
- class BranchCleanup {
17
- private options: CleanupOptions;
18
-
19
- constructor(options: CleanupOptions = {}) {
20
- this.options = {
21
- branchName: options.branchName,
22
- force: options.force || false,
23
- skipProjectCleanup: options.skipProjectCleanup || false,
24
- skipGit: options.skipGit || false,
25
- };
26
- }
27
-
28
- private async insertYourCodeHere(branchName: string): Promise<void> {
29
- const { extractIssueNumber } = require('../../src/utils/git-utils');
30
- const branchPattern = "branch_" + extractIssueNumber(branchName) + "%";
31
- this.log(`Calling MongoDB cleanup script with pattern: ${branchPattern}`);
32
- await this.executeCommand(
33
- `npx tsx scripts/database/cleanup-mongo-schemas.ts "${branchPattern}"`,
34
- 'Run project-specific cleanup script'
35
- );
36
- }
37
-
38
-
39
- private log(message: string, level: 'info' | 'warn' | 'error' | 'success' = 'info') {
40
- const timestamp = new Date().toISOString();
41
- const prefix = {
42
- info: 'โ„น๏ธ ',
43
- warn: 'โš ๏ธ ',
44
- error: 'โŒ',
45
- success: 'โœ…'
46
- }[level];
47
-
48
- console.log(`${prefix} [${timestamp}] ${message}`);
49
- }
50
-
51
- private async executeCommand(command: string, description: string): Promise<string> {
52
- this.log(`Executing: ${description}`);
53
-
54
- try {
55
- const result = execSync(command, {
56
- encoding: 'utf8',
57
- stdio: 'pipe',
58
- cwd: process.cwd()
59
- });
60
- this.log(`Success: ${description}`, 'success');
61
- return result;
62
- } catch (error: any) {
63
- this.log(`Failed: ${description} - ${error.message}`, 'error');
64
- throw error;
65
- }
66
- }
67
-
68
- private async getCurrentBranch(): Promise<string> {
69
- try {
70
- const result = await this.executeCommand('git branch --show-current', 'Get current branch');
71
- return result.trim();
72
- } catch (error) {
73
- this.log('Could not determine current branch', 'warn');
74
- return 'unknown';
75
- }
76
- }
77
-
78
- private async getBranchName(): Promise<string> {
79
- if (this.options.branchName) {
80
- return this.options.branchName;
81
- }
82
-
83
- const currentBranch = await this.getCurrentBranch();
84
- if (currentBranch === 'master' || currentBranch === 'main') {
85
- throw new Error('Cannot cleanup master/main branch. Please specify a feature branch name.');
86
- }
87
-
88
- return currentBranch;
89
- }
90
-
91
- private async checkBranchExists(branchName: string, remote: boolean = false): Promise<boolean> {
92
- try {
93
- const command = remote
94
- ? `git ls-remote --heads origin ${branchName}`
95
- : `git branch --list ${branchName}`;
96
-
97
- const result = await this.executeCommand(command, `Check if ${remote ? 'remote' : 'local'} branch exists`);
98
- return result.trim().length > 0;
99
- } catch (error) {
100
- return false;
101
- }
102
- }
103
-
104
- private async doProjectSpecificCleanup(branchName: string): Promise<void> {
105
- try {
106
- if (this.options.skipProjectCleanup) {
107
- this.log('Skipping project-specific cleanup', 'warn');
108
- return;
109
- }
110
-
111
- this.log('Starting project-specific cleanup...');
112
-
113
- await this.insertYourCodeHere(branchName);
114
-
115
- this.log('Project-specific cleanup completed successfully', 'success');
116
- } catch (error: any) {
117
- this.log(`Project-specific cleanup failed: ${error.message}`, 'error');
118
- if (!this.options.force) {
119
- throw error;
120
- }
121
- }
122
- }
123
-
124
- private async cleanupGitBranches(branchName: string): Promise<void> {
125
- if (this.options.skipGit) {
126
- this.log('Skipping Git cleanup', 'warn');
127
- return;
128
- }
129
-
130
- this.log(`Starting Git branch cleanup for: ${branchName}`);
131
-
132
- // Check if we're on the branch we want to delete
133
- const currentBranch = await this.getCurrentBranch();
134
- if (currentBranch === branchName) {
135
- this.log(`Currently on branch ${branchName}, switching to master first`, 'warn');
136
- await this.executeCommand('git checkout master', 'Switch to master branch');
137
- }
138
-
139
- // Delete remote branch
140
- const remoteExists = await this.checkBranchExists(branchName, true);
141
- if (remoteExists) {
142
- this.log(`Deleting remote branch: origin/${branchName}`);
143
- await this.executeCommand(`git push origin --delete ${branchName}`, `Delete remote branch ${branchName}`);
144
- } else {
145
- this.log(`Remote branch origin/${branchName} does not exist`, 'info');
146
- }
147
-
148
- // Delete local branch
149
- const localExists = await this.checkBranchExists(branchName, false);
150
- if (localExists) {
151
- this.log(`Deleting local branch: ${branchName}`);
152
- await this.executeCommand(`git branch -D ${branchName}`, `Delete local branch ${branchName}`);
153
- } else {
154
- this.log(`Local branch ${branchName} does not exist`, 'info');
155
- }
156
-
157
- // Clean up any untracked files
158
- this.log('Cleaning up untracked files...');
159
- await this.executeCommand('git clean -fd', 'Remove untracked files and directories');
160
-
161
- // Reset any uncommitted changes
162
- this.log('Resetting uncommitted changes...');
163
- await this.executeCommand('git reset --hard HEAD', 'Reset to HEAD');
164
-
165
- this.log('Git branch cleanup completed', 'success');
166
- }
167
-
168
-
169
- private async verifyCleanup(branchName: string): Promise<void> {
170
- this.log('Verifying cleanup...');
171
-
172
- // Verify branch deletion
173
- const remoteExists = await this.checkBranchExists(branchName, true);
174
- const localExists = await this.checkBranchExists(branchName, false);
175
-
176
- if (remoteExists || localExists) {
177
- this.log(`Warning: Branch ${branchName} still exists (remote: ${remoteExists}, local: ${localExists})`, 'warn');
178
- } else {
179
- this.log(`Branch ${branchName} successfully deleted`, 'success');
180
- }
181
-
182
- // Verify we're on master
183
- const currentBranch = await this.getCurrentBranch();
184
- if (currentBranch === 'master' || currentBranch === 'main') {
185
- this.log('Currently on master/main branch', 'success');
186
- } else {
187
- this.log(`Warning: Not on master branch, currently on ${currentBranch}`, 'warn');
188
- }
189
-
190
- this.log('Cleanup verification completed', 'success');
191
- }
192
-
193
- async cleanup(): Promise<void> {
194
- try {
195
- this.log('๐Ÿš€ Starting branch cleanup process...');
196
-
197
- const branchName = await this.getBranchName();
198
- this.log(`Target branch: ${branchName}`);
199
-
200
- // Step 1: Project-specific cleanup
201
- await this.doProjectSpecificCleanup(branchName);
202
-
203
- // Step 2: Git branch cleanup
204
- await this.cleanupGitBranches(branchName);
205
-
206
- // Step 3: Verification
207
- await this.verifyCleanup(branchName);
208
-
209
- this.log('๐ŸŽ‰ Branch cleanup completed successfully!', 'success');
210
-
211
- } catch (error: any) {
212
- this.log(`Cleanup failed: ${error.message}`, 'error');
213
- if (!this.options.force) {
214
- process.exit(1);
215
- }
216
- }
217
- }
218
- }
219
-
220
- // Parse command line arguments
221
- const args = process.argv.slice(2);
222
- const options: CleanupOptions = {};
223
-
224
- // Parse arguments
225
- for (let i = 0; i < args.length; i++) {
226
- const arg = args[i];
227
-
228
- switch (arg) {
229
- case '--branch':
230
- case '-b':
231
- options.branchName = args[++i];
232
- break;
233
- case '--force':
234
- case '-f':
235
- options.force = true;
236
- break;
237
- case '--skip-project-cleanup':
238
- options.skipProjectCleanup = true;
239
- break;
240
- case '--skip-git':
241
- options.skipGit = true;
242
- break;
243
- case '--help':
244
- case '-h':
245
- console.log(`
246
- ๐Ÿงน Branch Cleanup Script
247
-
248
- Usage:
249
- npx tsx .ai-agents/scripts/cleanup-branch.ts [options]
250
-
251
- Options:
252
- --branch, -b <name> Specific branch name to cleanup (default: current branch)
253
- --force, -f Continue even if some operations fail
254
- --skip-project-cleanup Skip project-specific cleanup
255
- --skip-git Skip Git branch deletion
256
- --help, -h Show this help message
257
-
258
- Examples:
259
- # Cleanup current branch with default settings
260
- npx tsx .ai-agents/scripts/cleanup-branch.ts
261
-
262
- # Cleanup specific branch
263
- npx tsx .ai-agents/scripts/cleanup-branch.ts --branch feature/123
264
-
265
- # Force cleanup even if some operations fail
266
- npx tsx .ai-agents/scripts/cleanup-branch.ts --force
267
-
268
- # Skip project-specific cleanup (only do Git cleanup)
269
- npx tsx .ai-agents/scripts/cleanup-branch.ts --skip-project-cleanup
270
-
271
- This script performs the following cleanup operations:
272
- 1. ๐Ÿ—„๏ธ Project-specific cleanup (calls existing cleanup-mongo-schemas.ts with branch-based pattern)
273
- 2. ๐ŸŒฟ Git branch deletion (remote and local)
274
- 3. โœ… Verification of cleanup completion
275
-
276
- โš ๏ธ WARNING: This script will permanently delete branches and data!
277
- `);
278
- process.exit(0);
279
- }
280
- }
281
-
282
- // Run the cleanup
283
- const cleanup = new BranchCleanup(options);
284
- cleanup.cleanup();
@@ -1,63 +0,0 @@
1
- import { loadFraimConfig } from '../../src/fraim/config-loader';
2
-
3
- const config = loadFraimConfig();
4
-
5
- const envOr = (keys: string[], fallback: string): string => {
6
- for (const key of keys) {
7
- const value = process.env[key];
8
- if (value && value.length) {
9
- return value;
10
- }
11
- }
12
- return fallback;
13
- };
14
-
15
- const personaName = config.persona.name;
16
- const personaDisplayNameDefault = config.persona.displayNamePattern.replace('{executiveName}', 'Your');
17
-
18
- export const fraimConfig = {
19
- repoOwner: config.git.repoOwner || 'mathursrus',
20
- repoName: config.git.repoName || 'fraim-repo',
21
- projectName: config.project.name,
22
- personaName,
23
- personaPronouns: envOr(['FRAIM_PERSONA_PRONOUNS'], 'they/them'), // Could add to config if needed
24
- personaDisplayName: envOr(['FRAIM_PERSONA_DISPLAY_NAME'], personaDisplayNameDefault),
25
- personaDisplayNamePattern: config.persona.displayNamePattern,
26
- personaThankYouSignature: config.persona.emailSignature,
27
- defaultEmail: envOr(['FRAIM_DEFAULT_EMAIL'], 'agent@example.com'),
28
- prodDefaultEmail: envOr(['PROD_FRAIM_DEFAULT_EMAIL'], 'agent@example.com'),
29
- defaultAccessToken: envOr(['FRAIM_DEFAULT_ACCESS_TOKEN'], ''),
30
- defaultRefreshToken: envOr(['FRAIM_DEFAULT_REFRESH_TOKEN'], ''),
31
- prodAccessToken: envOr(['PROD_FRAIM_DEFAULT_ACCESS_TOKEN'], ''),
32
- prodRefreshToken: envOr(['PROD_FRAIM_DEFAULT_REFRESH_TOKEN'], ''),
33
- defaultOAuthClientId: envOr(['FRAIM_DEFAULT_OAUTH_CLIENT_ID'], ''),
34
- defaultOAuthClientSecret: envOr(['FRAIM_DEFAULT_OAUTH_CLIENT_SECRET'], ''),
35
- prodOAuthClientId: envOr(['PROD_FRAIM_DEFAULT_OAUTH_CLIENT_ID'], ''),
36
- prodOAuthClientSecret: envOr(['PROD_FRAIM_DEFAULT_OAUTH_CLIENT_SECRET'], ''),
37
- identityCollection: config.database?.identityCollection || 'Identity',
38
- executiveCollection: config.database?.executiveCollection || 'Executive',
39
- newsletterTitle: config.marketing?.newsletterTitle || 'Weekly Update',
40
- newsletterCtaText: config.marketing?.newsletterCtaText || 'Learn More',
41
- newsletterUrl: config.marketing?.newsletterUrl || envOr(['FRAIM_NEWSLETTER_URL'], ''),
42
- issueRepoUrl: config.git.url || `https://github.com/${config.git.repoOwner}/${config.git.repoName}.git`,
43
- identityTokensCollection: config.database?.tokensCollection || 'Tokens',
44
- webAppUrl: config.marketing?.websiteUrl || envOr(['FRAIM_WEB_APP_URL'], 'http://localhost:3000'),
45
- chatUrl: config.marketing?.chatUrl || envOr(['FRAIM_CHAT_URL'], ''),
46
- azure: {
47
- prodAppName: envOr(['FRAIM_AZURE_PROD_APP_NAME'], 'fraim-app-prod'),
48
- prodResourceGroup: envOr(['FRAIM_AZURE_PROD_RESOURCE_GROUP'], 'fraim-prod-rg'),
49
- preprodAppName: envOr(['FRAIM_AZURE_PREPROD_APP_NAME'], 'fraim-app-pre-prod'),
50
- preprodResourceGroup: envOr(['FRAIM_AZURE_PREPROD_RESOURCE_GROUP'], 'fraim-pre-prod-rg'),
51
- localAppName: envOr(['FRAIM_AZURE_LOCAL_APP_NAME'], 'local'),
52
- localResourceGroup: envOr(['FRAIM_AZURE_LOCAL_RESOURCE_GROUP'], 'local')
53
- }
54
- };
55
-
56
- export function formatExecutiveDisplayName(executiveName: string): string {
57
- return config.persona.displayNamePattern.replace('{executiveName}', executiveName);
58
- }
59
-
60
- export function formatPersonaSignature(): string {
61
- return `With gratitude,\n${fraimConfig.personaThankYouSignature}\n${personaName} - Your AI Executive Assistant\n\n`;
62
- }
63
-