fraim-framework 2.0.26 ā 2.0.30
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.
- package/.github/workflows/deploy-fraim.yml +1 -1
- package/dist/registry/scripts/build-scripts-generator.js +205 -0
- package/dist/registry/scripts/cleanup-branch.js +258 -0
- package/dist/registry/scripts/evaluate-code-quality.js +66 -0
- package/dist/registry/scripts/exec-with-timeout.js +142 -0
- package/dist/registry/scripts/fraim-config.js +61 -0
- package/dist/registry/scripts/generate-engagement-emails.js +630 -0
- package/dist/registry/scripts/generic-issues-api.js +100 -0
- package/dist/registry/scripts/newsletter-helpers.js +731 -0
- package/dist/registry/scripts/openapi-generator.js +664 -0
- package/dist/registry/scripts/performance/profile-server.js +390 -0
- package/dist/registry/scripts/run-thank-you-workflow.js +92 -0
- package/dist/registry/scripts/send-newsletter-simple.js +85 -0
- package/dist/registry/scripts/send-thank-you-emails.js +54 -0
- package/dist/registry/scripts/validate-openapi-limits.js +311 -0
- package/dist/registry/scripts/validate-test-coverage.js +262 -0
- package/dist/registry/scripts/verify-test-coverage.js +66 -0
- package/dist/src/cli/commands/init.js +14 -12
- package/dist/src/cli/commands/sync.js +19 -2
- package/dist/src/cli/fraim.js +24 -22
- package/dist/src/cli/setup/first-run.js +13 -6
- package/dist/src/fraim/config-loader.js +0 -8
- package/dist/src/fraim/db-service.js +26 -15
- package/dist/src/fraim/issues.js +67 -0
- package/dist/src/fraim/setup-wizard.js +1 -69
- package/dist/src/fraim/types.js +0 -11
- package/dist/src/fraim-mcp-server.js +272 -18
- package/dist/src/utils/git-utils.js +1 -1
- package/dist/src/utils/version-utils.js +32 -0
- package/dist/tests/debug-tools.js +79 -0
- package/dist/tests/esm-compat.js +11 -0
- package/dist/tests/test-chalk-esm-issue.js +159 -0
- package/dist/tests/test-chalk-real-world.js +265 -0
- package/dist/tests/test-chalk-regression.js +327 -0
- package/dist/tests/test-chalk-resolution-issue.js +304 -0
- package/dist/tests/test-cli.js +0 -2
- package/dist/tests/test-fraim-install-chalk-issue.js +254 -0
- package/dist/tests/test-fraim-issues.js +59 -0
- package/dist/tests/test-genericization.js +1 -3
- package/dist/tests/test-mcp-connection.js +166 -0
- package/dist/tests/test-mcp-issue-integration.js +144 -0
- package/dist/tests/test-mcp-lifecycle-methods.js +312 -0
- package/dist/tests/test-node-compatibility.js +71 -0
- package/dist/tests/test-npm-install.js +66 -0
- package/dist/tests/test-npm-resolution-diagnostic.js +140 -0
- package/dist/tests/test-session-rehydration.js +145 -0
- package/dist/tests/test-standalone.js +2 -8
- package/dist/tests/test-sync-version-update.js +93 -0
- package/dist/tests/test-telemetry.js +190 -0
- package/package.json +10 -8
- package/registry/agent-guardrails.md +62 -54
- package/registry/rules/agent-success-criteria.md +52 -0
- package/registry/rules/agent-testing-guidelines.md +502 -502
- package/registry/rules/communication.md +121 -121
- package/registry/rules/continuous-learning.md +54 -54
- package/registry/rules/ephemeral-execution.md +10 -5
- package/registry/rules/hitl-ppe-record-analysis.md +302 -302
- package/registry/rules/local-development.md +251 -251
- package/registry/rules/software-development-lifecycle.md +104 -104
- package/registry/rules/successful-debugging-patterns.md +482 -478
- package/registry/rules/telemetry.md +67 -0
- package/registry/scripts/build-scripts-generator.ts +216 -215
- package/registry/scripts/cleanup-branch.ts +303 -284
- package/registry/scripts/code-quality-check.sh +559 -559
- package/registry/scripts/detect-tautological-tests.sh +38 -38
- package/registry/scripts/evaluate-code-quality.ts +1 -1
- package/registry/scripts/generate-engagement-emails.ts +744 -744
- package/registry/scripts/generic-issues-api.ts +110 -150
- package/registry/scripts/newsletter-helpers.ts +874 -874
- package/registry/scripts/openapi-generator.ts +695 -693
- package/registry/scripts/performance/profile-server.ts +5 -3
- package/registry/scripts/prep-issue.sh +468 -455
- package/registry/scripts/validate-openapi-limits.ts +366 -365
- package/registry/scripts/validate-test-coverage.ts +280 -280
- package/registry/scripts/verify-pr-comments.sh +70 -70
- package/registry/scripts/verify-test-coverage.ts +1 -1
- package/registry/templates/bootstrap/ARCHITECTURE-TEMPLATE.md +53 -53
- package/registry/templates/evidence/Implementation-BugEvidence.md +85 -85
- package/registry/templates/evidence/Implementation-FeatureEvidence.md +120 -120
- package/registry/templates/marketing/HBR-ARTICLE-TEMPLATE.md +66 -0
- package/registry/workflows/bootstrap/create-architecture.md +2 -2
- package/registry/workflows/bootstrap/evaluate-code-quality.md +3 -3
- package/registry/workflows/bootstrap/verify-test-coverage.md +2 -2
- package/registry/workflows/customer-development/insight-analysis.md +156 -156
- package/registry/workflows/customer-development/interview-preparation.md +421 -421
- package/registry/workflows/customer-development/strategic-brainstorming.md +146 -146
- package/registry/workflows/customer-development/thank-customers.md +193 -191
- package/registry/workflows/customer-development/weekly-newsletter.md +362 -352
- package/registry/workflows/improve-fraim/contribute.md +32 -0
- package/registry/workflows/improve-fraim/file-issue.md +32 -0
- package/registry/workflows/marketing/hbr-article.md +73 -0
- package/registry/workflows/performance/analyze-performance.md +63 -59
- package/registry/workflows/product-building/design.md +3 -2
- package/registry/workflows/product-building/implement.md +4 -3
- package/registry/workflows/product-building/prep-issue.md +28 -17
- package/registry/workflows/product-building/resolve.md +3 -2
- package/registry/workflows/product-building/retrospect.md +3 -2
- package/registry/workflows/product-building/spec.md +5 -4
- package/registry/workflows/product-building/test.md +3 -2
- package/registry/workflows/quality-assurance/iterative-improvement-cycle.md +562 -562
- package/registry/workflows/replicate/website-discovery-analysis.md +3 -3
- package/registry/workflows/reviewer/review-implementation-vs-design-spec.md +632 -632
- package/registry/workflows/reviewer/review-implementation-vs-feature-spec.md +669 -669
- package/tsconfig.json +2 -1
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Telemetry & Session Management
|
|
2
|
+
|
|
3
|
+
## Protocol Overview
|
|
4
|
+
|
|
5
|
+
FRAIM enforces a strict **Session Handshake** protocol to ensure proper environment tracking and implicit activity monitoring. All Agents interacting with a FRAIM server MUST adhere to this protocol.
|
|
6
|
+
|
|
7
|
+
### 1. Mandatory Handshake (`fraim_connect`)
|
|
8
|
+
|
|
9
|
+
At the start of **every** session (i.e., when the agent starts up or connects to a new workspace), you MUST call the `fraim_connect` tool immediately.
|
|
10
|
+
|
|
11
|
+
**Tool**: `fraim_connect`
|
|
12
|
+
**Arguments**:
|
|
13
|
+
- `machine`: Object containing hardware specs.
|
|
14
|
+
- `hostname`: (string) e.g., "dev-box-1"
|
|
15
|
+
- `platform`: (string) e.g., "win32", "darwin"
|
|
16
|
+
- `arch`: (string) e.g., "x64"
|
|
17
|
+
- `cpus`: (string/number) CPU details
|
|
18
|
+
- `memory`: (string/number) Total RAM
|
|
19
|
+
- `repo`: Object containing repository context.
|
|
20
|
+
- `url`: (string) **Required**. The git remote URL.
|
|
21
|
+
- `owner`: (string) e.g., "user-or-org"
|
|
22
|
+
- `name`: (string) e.g., "my-repo"
|
|
23
|
+
|
|
24
|
+
**Example Call**:
|
|
25
|
+
```json
|
|
26
|
+
{
|
|
27
|
+
"name": "fraim_connect",
|
|
28
|
+
"arguments": {
|
|
29
|
+
"machine": {
|
|
30
|
+
"hostname": "azure-vm-01",
|
|
31
|
+
"platform": "linux",
|
|
32
|
+
"arch": "x64"
|
|
33
|
+
},
|
|
34
|
+
"repo": {
|
|
35
|
+
"url": "https://github.com/fraim/framework.git",
|
|
36
|
+
"owner": "fraim",
|
|
37
|
+
"name": "framework"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**Failure Consequence**:
|
|
44
|
+
If you attempt to call other tools (e.g., `get_fraim_workflow`, `get_fraim_file`) *without* first establishing a session via `fraim_connect`, the server will reject your request with a **400 Bad Request** error:
|
|
45
|
+
|
|
46
|
+
> "ā Session Not Started. Please call the 'fraim_connect' tool first to register your environment and begin the session."
|
|
47
|
+
|
|
48
|
+
### 2. Implicit Activity Tracking
|
|
49
|
+
|
|
50
|
+
Once a session is established, you do **not** need to manually report usage. The FRAIM server automatically tracks your activity based on the API calls you make.
|
|
51
|
+
|
|
52
|
+
- **Keep-Alive**: Every tool call acts as a "heartbeat", updating your session's `lastActive` timestamp.
|
|
53
|
+
- **Efficiency**: The server uses write-behind caching to minimize database writes, so you can make frequent calls without performance penalty.
|
|
54
|
+
- **Persistence**: Usage data is persisted across server restarts.
|
|
55
|
+
|
|
56
|
+
### 3. Data Collection Policy
|
|
57
|
+
|
|
58
|
+
We collect minimal metadata to improve the FRAIM system and validate startup credits:
|
|
59
|
+
- **Hardware**: To optimize resource allocation recommendations.
|
|
60
|
+
- **Repository**: To map work to specific projects/organizations.
|
|
61
|
+
- **Duration**: Calculated as `lastActive - startTime` to measure session length.
|
|
62
|
+
- **Tool Usage**: Which tools are used (implicitly derived).
|
|
63
|
+
|
|
64
|
+
**We do NOT collect**:
|
|
65
|
+
- Source code content (except what is explicitly passed in specific tool arguments like reviews).
|
|
66
|
+
- Environment variables.
|
|
67
|
+
- Personal files.
|
|
@@ -1,215 +1,216 @@
|
|
|
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
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import { writeFileSync, existsSync, mkdirSync } from 'fs';
|
|
14
|
-
import { join } from 'path';
|
|
15
|
-
import { loadFraimConfig } from '
|
|
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
|
|
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
|
|
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 .
|
|
139
|
-
const copyAiAgents = `#!/usr/bin/env node
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Copy
|
|
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, '..', '
|
|
150
|
-
const destDir = path.join(__dirname, '..', 'dist', '
|
|
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
|
|
175
|
-
} else {
|
|
176
|
-
console.log('ā¹ļø
|
|
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 =
|
|
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
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
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 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 " + "reg" + "istry/scripts/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 " + "reg" + "istry/scripts/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 .fraim exists)
|
|
139
|
+
const copyAiAgents = `#!/usr/bin/env node
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Copy registry 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, '..', '..', 'registry');
|
|
150
|
+
const destDir = path.join(__dirname, '..', '..', 'dist', 'registry');
|
|
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 registry to dist/registry');
|
|
175
|
+
} else {
|
|
176
|
+
console.log('ā¹ļø registry 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 = "scr" + "ipts/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
|
+
// @ts-ignore
|
|
213
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
214
|
+
const config = loadFraimConfig();
|
|
215
|
+
generateBuildScripts(config);
|
|
216
|
+
}
|