fraim-framework 2.0.56 → 2.0.58
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/CHANGELOG.md +10 -0
- package/bin/fraim-mcp.js +14 -0
- package/bin/fraim.js +23 -0
- package/dist/src/cli/commands/init-project.js +10 -4
- package/dist/src/cli/commands/mcp.js +65 -0
- package/dist/src/cli/setup/mcp-config-generator.js +19 -16
- package/dist/src/fraim/issue-tracking/ado-provider.js +304 -0
- package/dist/src/fraim/issue-tracking/factory.js +63 -0
- package/dist/src/fraim/issue-tracking/github-provider.js +200 -0
- package/dist/src/fraim/issue-tracking/types.js +7 -0
- package/dist/src/fraim/issue-tracking-config.js +83 -0
- package/dist/src/local-mcp-server/stdio-server.js +207 -0
- package/dist/src/utils/workflow-parser.js +81 -0
- package/package.json +17 -12
- package/registry/scripts/pdf-styles.css +172 -0
- package/registry/scripts/prep-issue.sh +46 -4
- package/registry/scripts/profile-server.ts +131 -130
- package/registry/stubs/workflows/customer-development/user-survey-dispatch.md +1 -1
- package/registry/stubs/workflows/customer-development/users-to-target.md +1 -1
- package/registry/stubs/workflows/product-building/design.md +1 -1
- package/registry/stubs/workflows/product-building/implement.md +1 -1
- package/Claude.md +0 -1
- package/dist/registry/ai-manager-rules/customer-development-phases/phase1-customer-profiling.md +0 -101
- package/dist/registry/ai-manager-rules/customer-development-phases/phase2-platform-discovery.md +0 -235
- package/dist/registry/ai-manager-rules/customer-development-phases/phase3-prospect-qualification.md +0 -243
- package/dist/registry/ai-manager-rules/customer-development-phases/phase4-inventory-compilation.md +0 -206
- package/dist/registry/ai-manager-rules/design-phases/design-completeness-review.md +0 -73
- package/dist/registry/ai-manager-rules/design-phases/design-design.md +0 -145
- package/dist/registry/ai-manager-rules/implement-phases/implement-code.md +0 -283
- package/dist/registry/ai-manager-rules/implement-phases/implement-completeness-review.md +0 -120
- package/dist/registry/ai-manager-rules/implement-phases/implement-regression.md +0 -173
- package/dist/registry/ai-manager-rules/implement-phases/implement-repro.md +0 -104
- package/dist/registry/ai-manager-rules/implement-phases/implement-scoping.md +0 -100
- package/dist/registry/ai-manager-rules/implement-phases/implement-smoke.md +0 -237
- package/dist/registry/ai-manager-rules/implement-phases/implement-spike.md +0 -121
- package/dist/registry/ai-manager-rules/implement-phases/implement-validate.md +0 -375
- package/dist/registry/ai-manager-rules/retrospective.md +0 -116
- package/dist/registry/ai-manager-rules/shared-phases/address-pr-feedback.md +0 -188
- package/dist/registry/ai-manager-rules/shared-phases/submit-pr.md +0 -202
- package/dist/registry/ai-manager-rules/shared-phases/wait-for-pr-review.md +0 -170
- package/dist/registry/ai-manager-rules/spec-phases/spec-competitor-analysis.md +0 -105
- package/dist/registry/ai-manager-rules/spec-phases/spec-completeness-review.md +0 -66
- package/dist/registry/ai-manager-rules/spec-phases/spec-spec.md +0 -139
- package/dist/registry/ai-manager-rules/user-survey-phases/phase1-survey-scoping.md +0 -60
- package/dist/registry/ai-manager-rules/user-survey-phases/phase2-survey-build-linkedin.md +0 -23
- package/dist/registry/ai-manager-rules/user-survey-phases/phase3-survey-build-reddit.md +0 -22
- package/dist/registry/ai-manager-rules/user-survey-phases/phase4-survey-build-x.md +0 -21
- package/dist/registry/ai-manager-rules/user-survey-phases/phase5-survey-build-facebook.md +0 -19
- package/dist/registry/ai-manager-rules/user-survey-phases/phase6-survey-build-custom.md +0 -15
- package/dist/registry/ai-manager-rules/user-survey-phases/phase7-survey-dispatch.md +0 -45
- package/dist/registry/providers/ado.json +0 -19
- package/dist/registry/providers/github.json +0 -19
- package/dist/registry/scripts/cleanup-branch.js +0 -287
- package/dist/registry/scripts/evaluate-code-quality.js +0 -66
- package/dist/registry/scripts/exec-with-timeout.js +0 -142
- package/dist/registry/scripts/generate-engagement-emails.js +0 -705
- package/dist/registry/scripts/newsletter-helpers.js +0 -671
- package/dist/registry/scripts/profile-server.js +0 -388
- package/dist/registry/scripts/run-thank-you-workflow.js +0 -92
- package/dist/registry/scripts/send-newsletter-simple.js +0 -85
- package/dist/registry/scripts/send-thank-you-emails.js +0 -54
- package/dist/registry/scripts/validate-openapi-limits.js +0 -311
- package/dist/registry/scripts/validate-test-coverage.js +0 -262
- package/dist/registry/scripts/verify-test-coverage.js +0 -66
- package/dist/registry/templates/bootstrap/ARCHITECTURE-TEMPLATE.md +0 -53
- package/dist/registry/templates/bootstrap/CODE-QUALITY-REPORT-TEMPLATE.md +0 -37
- package/dist/registry/templates/bootstrap/TEST-COVERAGE-REPORT-TEMPLATE.md +0 -35
- package/dist/registry/templates/business-development/IDEATION-REPORT-TEMPLATE.md +0 -29
- package/dist/registry/templates/business-development/PRICING-STRATEGY-TEMPLATE.md +0 -126
- package/dist/registry/templates/customer-development/customer-interview-template.md +0 -99
- package/dist/registry/templates/customer-development/customer-persona-template.md +0 -69
- package/dist/registry/templates/customer-development/follow-up-email-templates.md +0 -132
- package/dist/registry/templates/customer-development/insight-analysis-template.md +0 -74
- package/dist/registry/templates/customer-development/prospect-inventory-template.csv +0 -3
- package/dist/registry/templates/customer-development/search-strategy-template.md +0 -123
- package/dist/registry/templates/customer-development/strategic-recommendations-template.md +0 -53
- package/dist/registry/templates/customer-development/thank-you-email-template.html +0 -124
- package/dist/registry/templates/customer-development/thank-you-note-template.md +0 -16
- package/dist/registry/templates/customer-development/triage-log-template.md +0 -278
- package/dist/registry/templates/customer-development/weekly-newsletter-template.html +0 -204
- package/dist/registry/templates/evidence/Design-Evidence.md +0 -30
- package/dist/registry/templates/evidence/Implementation-BugEvidence.md +0 -94
- package/dist/registry/templates/evidence/Implementation-FeatureEvidence.md +0 -129
- package/dist/registry/templates/evidence/Spec-Evidence.md +0 -19
- package/dist/registry/templates/help/HelpNeeded.md +0 -14
- package/dist/registry/templates/legal/NDA-TEMPLATE.md +0 -170
- package/dist/registry/templates/legal/PATENT-TEMPLATE.md +0 -372
- package/dist/registry/templates/legal/TRADEMARK-TEMPLATE.md +0 -339
- package/dist/registry/templates/legal/contract-review-checklist.md +0 -193
- package/dist/registry/templates/legal/review-report-template.md +0 -198
- package/dist/registry/templates/legal/saas-terms-template.md +0 -174
- package/dist/registry/templates/legal/sow-template.md +0 -117
- package/dist/registry/templates/legal/template-variables.md +0 -131
- package/dist/registry/templates/marketing/DOMAIN-REGISTRATION-TEMPLATE.md +0 -194
- package/dist/registry/templates/marketing/HBR-ARTICLE-TEMPLATE.md +0 -66
- package/dist/registry/templates/marketing/STORYTELLING-TEMPLATE.md +0 -130
- package/dist/registry/templates/marketing/WEBSITE-TEMPLATE.md +0 -262
- package/dist/registry/templates/marketing/github-pages-workflow.yml +0 -64
- package/dist/registry/templates/replicate/implementation-checklist.md +0 -39
- package/dist/registry/templates/replicate/use-cases-template.md +0 -88
- package/dist/registry/templates/retrospective/RETROSPECTIVE-TEMPLATE.md +0 -55
- package/dist/registry/templates/specs/BUGSPEC-TEMPLATE.md +0 -37
- package/dist/registry/templates/specs/FEATURESPEC-TEMPLATE.md +0 -66
- package/dist/registry/templates/specs/TECHSPEC-TEMPLATE.md +0 -39
- package/dist/registry/workflows/bootstrap/create-architecture.md +0 -38
- package/dist/registry/workflows/bootstrap/detect-broken-windows.md +0 -300
- package/dist/registry/workflows/bootstrap/evaluate-code-quality.md +0 -35
- package/dist/registry/workflows/bootstrap/verify-test-coverage.md +0 -36
- package/dist/registry/workflows/brainstorming/blue-sky-brainstorming.md +0 -211
- package/dist/registry/workflows/brainstorming/codebase-brainstorming.md +0 -165
- package/dist/registry/workflows/business-development/create-business-plan.md +0 -737
- package/dist/registry/workflows/business-development/ideate-business-opportunity.md +0 -55
- package/dist/registry/workflows/business-development/price-product.md +0 -325
- package/dist/registry/workflows/compliance/detect-compliance-requirements.md +0 -78
- package/dist/registry/workflows/compliance/generate-audit-evidence.md +0 -75
- package/dist/registry/workflows/compliance/soc2-evidence-generator.md +0 -332
- package/dist/registry/workflows/customer-development/insight-analysis.md +0 -156
- package/dist/registry/workflows/customer-development/insight-triage.md +0 -938
- package/dist/registry/workflows/customer-development/interview-preparation.md +0 -452
- package/dist/registry/workflows/customer-development/linkedin-outreach.md +0 -593
- package/dist/registry/workflows/customer-development/strategic-brainstorming.md +0 -146
- package/dist/registry/workflows/customer-development/thank-customers.md +0 -203
- package/dist/registry/workflows/customer-development/user-survey-dispatch.md +0 -60
- package/dist/registry/workflows/customer-development/users-to-target.md +0 -112
- package/dist/registry/workflows/customer-development/weekly-newsletter.md +0 -366
- package/dist/registry/workflows/deploy/cloud-deployment.md +0 -310
- package/dist/registry/workflows/improve-fraim/contribute.md +0 -32
- package/dist/registry/workflows/improve-fraim/file-issue.md +0 -32
- package/dist/registry/workflows/learning/build-skillset.md +0 -212
- package/dist/registry/workflows/learning/synthesize-learnings.md +0 -284
- package/dist/registry/workflows/legal/contract-review-analysis.md +0 -382
- package/dist/registry/workflows/legal/nda.md +0 -69
- package/dist/registry/workflows/legal/patent-filing.md +0 -76
- package/dist/registry/workflows/legal/saas-contract-development.md +0 -213
- package/dist/registry/workflows/legal/trademark-filing.md +0 -77
- package/dist/registry/workflows/marketing/content-creation.md +0 -37
- package/dist/registry/workflows/marketing/convert-to-pdf.md +0 -235
- package/dist/registry/workflows/marketing/create-modern-website.md +0 -456
- package/dist/registry/workflows/marketing/domain-registration.md +0 -323
- package/dist/registry/workflows/marketing/hbr-article.md +0 -73
- package/dist/registry/workflows/marketing/launch-checklist.md +0 -37
- package/dist/registry/workflows/marketing/marketing-strategy.md +0 -45
- package/dist/registry/workflows/marketing/storytelling.md +0 -65
- package/dist/registry/workflows/performance/analyze-performance.md +0 -65
- package/dist/registry/workflows/product-building/design.md +0 -103
- package/dist/registry/workflows/product-building/implement.md +0 -74
- package/dist/registry/workflows/product-building/iterate-on-pr-comments.md +0 -70
- package/dist/registry/workflows/product-building/prep-issue.md +0 -41
- package/dist/registry/workflows/product-building/prototype.md +0 -65
- package/dist/registry/workflows/product-building/resolve.md +0 -168
- package/dist/registry/workflows/product-building/retrospect.md +0 -86
- package/dist/registry/workflows/product-building/spec.md +0 -181
- package/dist/registry/workflows/product-building/test.md +0 -125
- package/dist/registry/workflows/productivity-report/productivity-report.md +0 -263
- package/dist/registry/workflows/quality-assurance/browser-validation.md +0 -221
- package/dist/registry/workflows/quality-assurance/iterative-improvement-cycle.md +0 -562
- package/dist/registry/workflows/replicate/replicate-discovery.md +0 -336
- package/dist/registry/workflows/replicate/replicate-to-issues.md +0 -324
- package/dist/registry/workflows/reviewer/review-implementation-vs-design-spec.md +0 -638
- package/dist/registry/workflows/reviewer/review-implementation-vs-feature-spec.md +0 -675
- package/dist/registry/workflows/startup-credits/aws-activate-application.md +0 -535
- package/dist/registry/workflows/startup-credits/google-cloud-application.md +0 -647
- package/dist/registry/workflows/startup-credits/microsoft-azure-application.md +0 -538
- package/dist/scripts/build-stub-registry.js +0 -108
- package/dist/src/ai-manager/ai-manager.js +0 -480
- package/dist/src/ai-manager/phase-flow.js +0 -357
- package/dist/src/ai-manager/types.js +0 -5
- package/dist/src/fraim-mcp-server.js +0 -1885
- package/dist/tests/debug-tools.js +0 -80
- package/dist/tests/shared-server-utils.js +0 -57
- package/dist/tests/test-add-ide.js +0 -283
- package/dist/tests/test-ai-coach-edge-cases.js +0 -420
- package/dist/tests/test-ai-coach-mcp-integration.js +0 -450
- package/dist/tests/test-ai-coach-performance.js +0 -328
- package/dist/tests/test-ai-coach-phase-content.js +0 -264
- package/dist/tests/test-ai-coach-workflows.js +0 -514
- package/dist/tests/test-cli.js +0 -228
- package/dist/tests/test-client-scripts-validation.js +0 -167
- package/dist/tests/test-complete-setup-flow.js +0 -110
- package/dist/tests/test-config-system.js +0 -279
- package/dist/tests/test-debug-session.js +0 -134
- package/dist/tests/test-end-to-end-hybrid-validation.js +0 -328
- package/dist/tests/test-enhanced-session-init.js +0 -188
- package/dist/tests/test-first-run-journey.js +0 -368
- package/dist/tests/test-fraim-issues.js +0 -59
- package/dist/tests/test-genericization.js +0 -44
- package/dist/tests/test-hybrid-script-execution.js +0 -340
- package/dist/tests/test-ide-detector.js +0 -46
- package/dist/tests/test-improved-setup.js +0 -121
- package/dist/tests/test-mcp-config-generator.js +0 -99
- package/dist/tests/test-mcp-connection.js +0 -107
- package/dist/tests/test-mcp-issue-integration.js +0 -156
- package/dist/tests/test-mcp-lifecycle-methods.js +0 -240
- package/dist/tests/test-mcp-shared-server.js +0 -308
- package/dist/tests/test-mcp-template-processing.js +0 -160
- package/dist/tests/test-modular-issue-tracking.js +0 -165
- package/dist/tests/test-node-compatibility.js +0 -95
- package/dist/tests/test-npm-install.js +0 -68
- package/dist/tests/test-package-size.js +0 -108
- package/dist/tests/test-pr-review-workflow.js +0 -307
- package/dist/tests/test-prep-issue.js +0 -129
- package/dist/tests/test-productivity-integration.js +0 -157
- package/dist/tests/test-script-location-independence.js +0 -198
- package/dist/tests/test-script-sync.js +0 -557
- package/dist/tests/test-server-utils.js +0 -32
- package/dist/tests/test-session-rehydration.js +0 -148
- package/dist/tests/test-setup-integration.js +0 -98
- package/dist/tests/test-setup-scenarios.js +0 -322
- package/dist/tests/test-standalone.js +0 -143
- package/dist/tests/test-stub-registry.js +0 -136
- package/dist/tests/test-sync-stubs.js +0 -143
- package/dist/tests/test-sync-version-update.js +0 -93
- package/dist/tests/test-telemetry.js +0 -193
- package/dist/tests/test-token-validator.js +0 -30
- package/dist/tests/test-user-journey.js +0 -236
- package/dist/tests/test-users-to-target-workflow.js +0 -253
- package/dist/tests/test-utils.js +0 -109
- package/dist/tests/test-wizard.js +0 -71
- package/dist/tests/test-workflow-discovery.js +0 -242
- package/labels.json +0 -52
- package/registry/agent-guardrails.md +0 -63
- package/registry/fraim.md +0 -48
- package/setup.js +0 -171
- package/tsconfig.json +0 -23
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const node_child_process_1 = require("node:child_process");
|
|
7
|
-
const axios_1 = __importDefault(require("axios"));
|
|
8
|
-
const db_service_js_1 = require("../src/fraim/db-service.js");
|
|
9
|
-
const test_utils_1 = require("./test-utils");
|
|
10
|
-
const node_assert_1 = __importDefault(require("node:assert"));
|
|
11
|
-
const tree_kill_1 = __importDefault(require("tree-kill"));
|
|
12
|
-
const test_server_utils_1 = require("./test-server-utils");
|
|
13
|
-
async function testRehydrationAndExemptions() {
|
|
14
|
-
console.log(' 🚀 Testing Session Re-hydration and Initialization Exemptions...');
|
|
15
|
-
let fraimProcess;
|
|
16
|
-
let dbService;
|
|
17
|
-
const PORT = Math.floor(Math.random() * 1000) + 12000;
|
|
18
|
-
const TEST_API_KEY = 'test-rehydration-key';
|
|
19
|
-
const TEST_ADMIN_KEY = 'test-admin-key';
|
|
20
|
-
const BASE_URL = `http://localhost:${PORT}`;
|
|
21
|
-
const startServer = async () => {
|
|
22
|
-
console.log(` Starting server on port ${PORT}...`);
|
|
23
|
-
const npxCommand = process.platform === 'win32' ? 'npx.cmd' : 'npx';
|
|
24
|
-
const serverScript = (0, test_server_utils_1.getServerScriptPath)();
|
|
25
|
-
const proc = (0, node_child_process_1.spawn)(npxCommand, ['node', `"${serverScript}"`], {
|
|
26
|
-
env: {
|
|
27
|
-
...process.env,
|
|
28
|
-
FRAIM_MCP_PORT: PORT.toString(),
|
|
29
|
-
FRAIM_ADMIN_KEY: TEST_ADMIN_KEY,
|
|
30
|
-
FRAIM_SKIP_INDEX_ON_START: 'true'
|
|
31
|
-
},
|
|
32
|
-
stdio: 'inherit',
|
|
33
|
-
shell: true
|
|
34
|
-
});
|
|
35
|
-
let started = false;
|
|
36
|
-
for (let i = 0; i < 15; i++) {
|
|
37
|
-
try {
|
|
38
|
-
await axios_1.default.get(`${BASE_URL}/health`, { timeout: 500 });
|
|
39
|
-
started = true;
|
|
40
|
-
break;
|
|
41
|
-
}
|
|
42
|
-
catch (e) {
|
|
43
|
-
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
if (!started)
|
|
47
|
-
throw new Error('Server failed to start');
|
|
48
|
-
return proc;
|
|
49
|
-
};
|
|
50
|
-
const stopServer = async (proc) => {
|
|
51
|
-
if (proc && proc.pid) {
|
|
52
|
-
await new Promise(resolve => (0, tree_kill_1.default)(proc.pid, 'SIGKILL', () => resolve()));
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
try {
|
|
56
|
-
// 1. Setup DB and Key
|
|
57
|
-
dbService = new db_service_js_1.FraimDbService();
|
|
58
|
-
await dbService.connect();
|
|
59
|
-
const db = dbService.db;
|
|
60
|
-
await db.collection('fraim_api_keys').deleteOne({ key: TEST_API_KEY });
|
|
61
|
-
await db.collection('fraim_telemetry_sessions').deleteMany({ userId: 'test-user-recalc' });
|
|
62
|
-
await db.collection('fraim_api_keys').insertOne({
|
|
63
|
-
key: TEST_API_KEY,
|
|
64
|
-
userId: 'test-user-recalc',
|
|
65
|
-
orgId: 'test-org',
|
|
66
|
-
isActive: true,
|
|
67
|
-
createdAt: new Date()
|
|
68
|
-
});
|
|
69
|
-
// 2. Start Server (Instance 1)
|
|
70
|
-
fraimProcess = await startServer();
|
|
71
|
-
// 3. Verify Initialization Exemptions
|
|
72
|
-
console.log(' Testing standard MCP exemptions (initialize, tools/list)...');
|
|
73
|
-
const initRes = await axios_1.default.post(`${BASE_URL}/mcp`, {
|
|
74
|
-
jsonrpc: '2.0', id: 1, method: 'initialize', params: {}
|
|
75
|
-
}, { headers: { 'x-api-key': TEST_API_KEY } });
|
|
76
|
-
node_assert_1.default.strictEqual(initRes.status, 200, 'initialize should be exempt');
|
|
77
|
-
const listRes = await axios_1.default.post(`${BASE_URL}/mcp`, {
|
|
78
|
-
jsonrpc: '2.0', id: 2, method: 'tools/list', params: {}
|
|
79
|
-
}, { headers: { 'x-api-key': TEST_API_KEY } });
|
|
80
|
-
node_assert_1.default.strictEqual(listRes.status, 200, 'tools/list should be exempt');
|
|
81
|
-
console.log(' Testing discovery tools exemptions (get_fraim_init)...');
|
|
82
|
-
const discoveryRes = await axios_1.default.post(`${BASE_URL}/mcp`, {
|
|
83
|
-
jsonrpc: '2.0', id: 3, method: 'tools/call',
|
|
84
|
-
params: { name: 'get_fraim_init', arguments: {} }
|
|
85
|
-
}, { headers: { 'x-api-key': TEST_API_KEY } });
|
|
86
|
-
node_assert_1.default.strictEqual(discoveryRes.status, 200, 'get_fraim_init should be exempt');
|
|
87
|
-
console.log(' ✅ Exemptions verified.');
|
|
88
|
-
// 4. Start Session
|
|
89
|
-
console.log(' Starting session...');
|
|
90
|
-
await axios_1.default.post(`${BASE_URL}/mcp`, {
|
|
91
|
-
jsonrpc: '2.0', id: 4, method: 'tools/call',
|
|
92
|
-
params: {
|
|
93
|
-
name: 'fraim_connect',
|
|
94
|
-
arguments: {
|
|
95
|
-
agent: {
|
|
96
|
-
name: 'Claude',
|
|
97
|
-
model: 'test-model'
|
|
98
|
-
},
|
|
99
|
-
machine: { hostname: 'repro-host', platform: 'test' },
|
|
100
|
-
repo: { url: 'http://github.com/repro' }
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}, { headers: { 'x-api-key': TEST_API_KEY } });
|
|
104
|
-
// 5. Restart Server (Instance 2)
|
|
105
|
-
console.log(' ♻️ Swapping server instances (Simulating restart)...');
|
|
106
|
-
await stopServer(fraimProcess);
|
|
107
|
-
fraimProcess = await startServer();
|
|
108
|
-
// 6. Verify Re-hydration
|
|
109
|
-
console.log(' Checking if session re-hydrated from DB...');
|
|
110
|
-
const secureRes = await axios_1.default.post(`${BASE_URL}/mcp`, {
|
|
111
|
-
jsonrpc: '2.0', id: 5, method: 'tools/call',
|
|
112
|
-
params: { name: 'get_fraim_workflow', arguments: { workflow: 'test' } }
|
|
113
|
-
}, { headers: { 'x-api-key': TEST_API_KEY } });
|
|
114
|
-
node_assert_1.default.strictEqual(secureRes.status, 200, 'Request should be authorized via re-hydrated session');
|
|
115
|
-
console.log(' ✅ Re-hydration successful!');
|
|
116
|
-
return true;
|
|
117
|
-
}
|
|
118
|
-
catch (error) {
|
|
119
|
-
console.error(' ❌ Test failed:', error.message);
|
|
120
|
-
if (error.response?.data) {
|
|
121
|
-
console.error(' 🔍 Server Error Detail:', JSON.stringify(error.response.data, null, 2));
|
|
122
|
-
}
|
|
123
|
-
return false;
|
|
124
|
-
}
|
|
125
|
-
finally {
|
|
126
|
-
if (dbService) {
|
|
127
|
-
const db = dbService.db;
|
|
128
|
-
await db.collection('fraim_api_keys').deleteOne({ key: TEST_API_KEY }).catch(() => { });
|
|
129
|
-
await db.collection('fraim_telemetry_sessions').deleteMany({ userId: 'test-user-recalc' }).catch(() => { });
|
|
130
|
-
await dbService.close();
|
|
131
|
-
}
|
|
132
|
-
if (fraimProcess)
|
|
133
|
-
await stopServer(fraimProcess);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
const testCases = [
|
|
137
|
-
{
|
|
138
|
-
name: 'MCP Session Re-hydration and Initialization',
|
|
139
|
-
description: 'Verifies re-hydration from DB after restart and initialization exemptions',
|
|
140
|
-
testFunction: testRehydrationAndExemptions,
|
|
141
|
-
tags: ['session', 'rehydration']
|
|
142
|
-
}
|
|
143
|
-
];
|
|
144
|
-
(0, test_utils_1.runTests)(testCases, async (t) => t.testFunction(), 'Fraim Session System')
|
|
145
|
-
.catch((err) => {
|
|
146
|
-
console.error('Test runner failed:', err);
|
|
147
|
-
throw err;
|
|
148
|
-
});
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const node_test_1 = require("node:test");
|
|
7
|
-
const node_assert_1 = __importDefault(require("node:assert"));
|
|
8
|
-
const fs_1 = __importDefault(require("fs"));
|
|
9
|
-
const path_1 = __importDefault(require("path"));
|
|
10
|
-
const os_1 = __importDefault(require("os"));
|
|
11
|
-
const ide_detector_1 = require("../src/cli/setup/ide-detector");
|
|
12
|
-
const mcp_config_generator_1 = require("../src/cli/setup/mcp-config-generator");
|
|
13
|
-
const token_validator_1 = require("../src/cli/setup/token-validator");
|
|
14
|
-
(0, node_test_1.test)('Setup integration - token validation flow', async () => {
|
|
15
|
-
// Test valid tokens
|
|
16
|
-
const validFraimKey = 'fraim_test123456789012345';
|
|
17
|
-
const validGithubToken = 'ghp_test123456789012345';
|
|
18
|
-
(0, node_assert_1.default)((0, token_validator_1.isValidTokenFormat)(validFraimKey, 'fraim'), 'Valid FRAIM key format should pass');
|
|
19
|
-
(0, node_assert_1.default)((0, token_validator_1.isValidTokenFormat)(validGithubToken, 'github'), 'Valid GitHub token format should pass');
|
|
20
|
-
(0, node_assert_1.default)(await (0, token_validator_1.validateFraimKey)(validFraimKey), 'Valid FRAIM key should validate');
|
|
21
|
-
// Test invalid tokens
|
|
22
|
-
(0, node_assert_1.default)(!(0, token_validator_1.isValidTokenFormat)('invalid_key', 'fraim'), 'Invalid FRAIM key should fail');
|
|
23
|
-
(0, node_assert_1.default)(!(0, token_validator_1.isValidTokenFormat)('invalid_token', 'github'), 'Invalid GitHub token should fail');
|
|
24
|
-
(0, node_assert_1.default)(!await (0, token_validator_1.validateFraimKey)('invalid_key'), 'Invalid FRAIM key should not validate');
|
|
25
|
-
});
|
|
26
|
-
(0, node_test_1.test)('Setup integration - MCP config generation for all IDE types', () => {
|
|
27
|
-
const testFraimKey = 'fraim_test123456789012345';
|
|
28
|
-
const testGithubToken = 'ghp_test123456789012345';
|
|
29
|
-
// Test all config types
|
|
30
|
-
const standardConfig = (0, mcp_config_generator_1.generateMCPConfig)('standard', testFraimKey, testGithubToken);
|
|
31
|
-
const kiroConfig = (0, mcp_config_generator_1.generateMCPConfig)('kiro', testFraimKey, testGithubToken);
|
|
32
|
-
const codexConfig = (0, mcp_config_generator_1.generateMCPConfig)('codex', testFraimKey, testGithubToken);
|
|
33
|
-
const windsurfConfig = (0, mcp_config_generator_1.generateMCPConfig)('windsurf', testFraimKey, testGithubToken);
|
|
34
|
-
// Verify standard config structure
|
|
35
|
-
(0, node_assert_1.default)(standardConfig.mcpServers, 'Standard config should have mcpServers');
|
|
36
|
-
(0, node_assert_1.default)(standardConfig.mcpServers.fraim.serverUrl, 'Standard should use serverUrl');
|
|
37
|
-
(0, node_assert_1.default)(standardConfig.mcpServers.fraim.headers['x-api-key'] === testFraimKey, 'Should contain FRAIM key');
|
|
38
|
-
// Verify kiro config structure
|
|
39
|
-
(0, node_assert_1.default)(kiroConfig.mcpServers.fraim.url, 'Kiro should use url');
|
|
40
|
-
(0, node_assert_1.default)(!kiroConfig.mcpServers.fraim.serverUrl, 'Kiro should not have serverUrl');
|
|
41
|
-
// Verify codex config is TOML string
|
|
42
|
-
(0, node_assert_1.default)(typeof codexConfig === 'string', 'Codex should return TOML string');
|
|
43
|
-
(0, node_assert_1.default)(codexConfig.includes('[mcp_servers.fraim]'), 'Should contain FRAIM section');
|
|
44
|
-
(0, node_assert_1.default)(codexConfig.includes(testFraimKey), 'Should contain FRAIM key');
|
|
45
|
-
// Verify windsurf config structure
|
|
46
|
-
(0, node_assert_1.default)(windsurfConfig.mcpServers.fraim.command, 'Windsurf should use command');
|
|
47
|
-
(0, node_assert_1.default)(windsurfConfig.mcpServers.fraim.env.FRAIM_API_KEY === testFraimKey, 'Should contain FRAIM key in env');
|
|
48
|
-
});
|
|
49
|
-
(0, node_test_1.test)('Setup integration - IDE detection works', () => {
|
|
50
|
-
const detectedIDEs = (0, ide_detector_1.detectInstalledIDEs)();
|
|
51
|
-
// Should return an array (might be empty in test environment)
|
|
52
|
-
(0, node_assert_1.default)(Array.isArray(detectedIDEs), 'Should return an array');
|
|
53
|
-
// If any IDEs are detected, they should have the correct structure
|
|
54
|
-
detectedIDEs.forEach(ide => {
|
|
55
|
-
(0, node_assert_1.default)(typeof ide.name === 'string', 'IDE should have name');
|
|
56
|
-
(0, node_assert_1.default)(typeof ide.configPath === 'string', 'IDE should have configPath');
|
|
57
|
-
(0, node_assert_1.default)(['json', 'toml'].includes(ide.configFormat), 'IDE should have valid configFormat');
|
|
58
|
-
(0, node_assert_1.default)(['standard', 'kiro', 'codex', 'windsurf', 'claude'].includes(ide.configType), 'IDE should have valid configType');
|
|
59
|
-
(0, node_assert_1.default)(typeof ide.detectMethod === 'function', 'IDE should have detectMethod');
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
(0, node_test_1.test)('Setup integration - global config directory creation', () => {
|
|
63
|
-
const testConfigDir = path_1.default.join(os_1.default.tmpdir(), 'fraim-test-' + Date.now());
|
|
64
|
-
// Simulate creating global config directory
|
|
65
|
-
if (!fs_1.default.existsSync(testConfigDir)) {
|
|
66
|
-
fs_1.default.mkdirSync(testConfigDir, { recursive: true });
|
|
67
|
-
}
|
|
68
|
-
(0, node_assert_1.default)(fs_1.default.existsSync(testConfigDir), 'Config directory should be created');
|
|
69
|
-
// Test config file creation
|
|
70
|
-
const testConfig = {
|
|
71
|
-
version: '2.0.37',
|
|
72
|
-
apiKey: 'fraim_test123456789012345',
|
|
73
|
-
configuredAt: new Date().toISOString()
|
|
74
|
-
};
|
|
75
|
-
const configPath = path_1.default.join(testConfigDir, 'config.json');
|
|
76
|
-
fs_1.default.writeFileSync(configPath, JSON.stringify(testConfig, null, 2));
|
|
77
|
-
(0, node_assert_1.default)(fs_1.default.existsSync(configPath), 'Config file should be created');
|
|
78
|
-
const savedConfig = JSON.parse(fs_1.default.readFileSync(configPath, 'utf8'));
|
|
79
|
-
(0, node_assert_1.default)(savedConfig.apiKey === testConfig.apiKey, 'Config should contain API key');
|
|
80
|
-
(0, node_assert_1.default)(savedConfig.version === testConfig.version, 'Config should contain version');
|
|
81
|
-
// Cleanup
|
|
82
|
-
fs_1.default.rmSync(testConfigDir, { recursive: true, force: true });
|
|
83
|
-
});
|
|
84
|
-
(0, node_test_1.test)('Setup integration - backup functionality', () => {
|
|
85
|
-
const testDir = path_1.default.join(os_1.default.tmpdir(), 'fraim-backup-test-' + Date.now());
|
|
86
|
-
fs_1.default.mkdirSync(testDir, { recursive: true });
|
|
87
|
-
const originalConfigPath = path_1.default.join(testDir, 'test-config.json');
|
|
88
|
-
const originalConfig = { existing: 'config' };
|
|
89
|
-
fs_1.default.writeFileSync(originalConfigPath, JSON.stringify(originalConfig, null, 2));
|
|
90
|
-
// Simulate backup creation
|
|
91
|
-
const backupPath = `${originalConfigPath}.fraim-backup-${Date.now()}`;
|
|
92
|
-
fs_1.default.copyFileSync(originalConfigPath, backupPath);
|
|
93
|
-
(0, node_assert_1.default)(fs_1.default.existsSync(backupPath), 'Backup file should be created');
|
|
94
|
-
const backupConfig = JSON.parse(fs_1.default.readFileSync(backupPath, 'utf8'));
|
|
95
|
-
node_assert_1.default.deepStrictEqual(backupConfig, originalConfig, 'Backup should match original');
|
|
96
|
-
// Cleanup
|
|
97
|
-
fs_1.default.rmSync(testDir, { recursive: true, force: true });
|
|
98
|
-
});
|
|
@@ -1,322 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
const node_test_1 = require("node:test");
|
|
40
|
-
const node_assert_1 = __importDefault(require("node:assert"));
|
|
41
|
-
const fs_1 = __importDefault(require("fs"));
|
|
42
|
-
const path_1 = __importDefault(require("path"));
|
|
43
|
-
const os_1 = __importDefault(require("os"));
|
|
44
|
-
// Test various setup scenarios without interactive prompts
|
|
45
|
-
(0, node_test_1.test)('Setup Scenarios - Fresh Installation', async () => {
|
|
46
|
-
const tempHomeDir = path_1.default.join(os_1.default.tmpdir(), '.fraim-test-fresh-' + Date.now());
|
|
47
|
-
const originalHomedir = os_1.default.homedir;
|
|
48
|
-
os_1.default.homedir = () => tempHomeDir;
|
|
49
|
-
try {
|
|
50
|
-
// Test 1: No existing global config
|
|
51
|
-
const globalConfigPath = path_1.default.join(tempHomeDir, '.fraim', 'config.json');
|
|
52
|
-
// Verify no config exists initially
|
|
53
|
-
(0, node_assert_1.default)(!fs_1.default.existsSync(globalConfigPath), 'No global config should exist initially');
|
|
54
|
-
// Simulate what setup command would create
|
|
55
|
-
fs_1.default.mkdirSync(path_1.default.dirname(globalConfigPath), { recursive: true });
|
|
56
|
-
const newConfig = {
|
|
57
|
-
version: '2.0.27',
|
|
58
|
-
apiKey: 'fraim_fresh_install_key',
|
|
59
|
-
githubToken: 'ghp_fresh_install_token',
|
|
60
|
-
configuredAt: new Date().toISOString(),
|
|
61
|
-
userPreferences: {
|
|
62
|
-
autoSync: true,
|
|
63
|
-
backupConfigs: true
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
fs_1.default.writeFileSync(globalConfigPath, JSON.stringify(newConfig, null, 2));
|
|
67
|
-
// Verify config was created correctly
|
|
68
|
-
(0, node_assert_1.default)(fs_1.default.existsSync(globalConfigPath), 'Global config should be created');
|
|
69
|
-
const savedConfig = JSON.parse(fs_1.default.readFileSync(globalConfigPath, 'utf8'));
|
|
70
|
-
node_assert_1.default.strictEqual(savedConfig.apiKey, 'fraim_fresh_install_key', 'FRAIM key should be saved');
|
|
71
|
-
node_assert_1.default.strictEqual(savedConfig.githubToken, 'ghp_fresh_install_token', 'GitHub token should be saved');
|
|
72
|
-
(0, node_assert_1.default)(savedConfig.userPreferences, 'User preferences should be saved');
|
|
73
|
-
console.log('✅ Fresh installation scenario passed');
|
|
74
|
-
}
|
|
75
|
-
finally {
|
|
76
|
-
// Cleanup
|
|
77
|
-
fs_1.default.rmSync(tempHomeDir, { recursive: true, force: true });
|
|
78
|
-
os_1.default.homedir = originalHomedir;
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
(0, node_test_1.test)('Setup Scenarios - Existing Config Without GitHub Token', async () => {
|
|
82
|
-
const tempHomeDir = path_1.default.join(os_1.default.tmpdir(), '.fraim-test-existing-' + Date.now());
|
|
83
|
-
const originalHomedir = os_1.default.homedir;
|
|
84
|
-
os_1.default.homedir = () => tempHomeDir;
|
|
85
|
-
try {
|
|
86
|
-
const globalConfigPath = path_1.default.join(tempHomeDir, '.fraim', 'config.json');
|
|
87
|
-
// Create existing config without GitHub token (simulates old version)
|
|
88
|
-
fs_1.default.mkdirSync(path_1.default.dirname(globalConfigPath), { recursive: true });
|
|
89
|
-
const oldConfig = {
|
|
90
|
-
version: '2.0.20',
|
|
91
|
-
apiKey: 'fraim_existing_key',
|
|
92
|
-
configuredAt: '2024-01-01T00:00:00.000Z',
|
|
93
|
-
userPreferences: {
|
|
94
|
-
autoSync: true,
|
|
95
|
-
backupConfigs: true
|
|
96
|
-
}
|
|
97
|
-
// No githubToken
|
|
98
|
-
};
|
|
99
|
-
fs_1.default.writeFileSync(globalConfigPath, JSON.stringify(oldConfig, null, 2));
|
|
100
|
-
// Test loadGlobalConfig behavior with missing GitHub token
|
|
101
|
-
const { loadGlobalConfig } = await Promise.resolve().then(() => __importStar(require('../src/cli/commands/add-ide')));
|
|
102
|
-
const result = loadGlobalConfig();
|
|
103
|
-
(0, node_assert_1.default)(result, 'Should load existing config');
|
|
104
|
-
node_assert_1.default.strictEqual(result.fraimKey, 'fraim_existing_key', 'Should preserve existing FRAIM key');
|
|
105
|
-
node_assert_1.default.strictEqual(result.githubToken, undefined, 'GitHub token should be undefined');
|
|
106
|
-
// Simulate adding GitHub token (what add-ide would do)
|
|
107
|
-
const updatedConfig = {
|
|
108
|
-
...oldConfig,
|
|
109
|
-
githubToken: 'ghp_newly_added_token',
|
|
110
|
-
version: '2.0.27'
|
|
111
|
-
};
|
|
112
|
-
fs_1.default.writeFileSync(globalConfigPath, JSON.stringify(updatedConfig, null, 2));
|
|
113
|
-
// Verify token was added
|
|
114
|
-
const result2 = loadGlobalConfig();
|
|
115
|
-
(0, node_assert_1.default)(result2, 'Should load updated config');
|
|
116
|
-
node_assert_1.default.strictEqual(result2.fraimKey, 'fraim_existing_key', 'Should preserve existing FRAIM key');
|
|
117
|
-
node_assert_1.default.strictEqual(result2.githubToken, 'ghp_newly_added_token', 'Should have new GitHub token');
|
|
118
|
-
console.log('✅ Existing config without GitHub token scenario passed');
|
|
119
|
-
}
|
|
120
|
-
finally {
|
|
121
|
-
// Cleanup
|
|
122
|
-
fs_1.default.rmSync(tempHomeDir, { recursive: true, force: true });
|
|
123
|
-
os_1.default.homedir = originalHomedir;
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
(0, node_test_1.test)('Setup Scenarios - Corrupted Config Recovery', async () => {
|
|
127
|
-
const tempHomeDir = path_1.default.join(os_1.default.tmpdir(), '.fraim-test-corrupted-' + Date.now());
|
|
128
|
-
const originalHomedir = os_1.default.homedir;
|
|
129
|
-
os_1.default.homedir = () => tempHomeDir;
|
|
130
|
-
try {
|
|
131
|
-
const globalConfigPath = path_1.default.join(tempHomeDir, '.fraim', 'config.json');
|
|
132
|
-
// Create corrupted config file
|
|
133
|
-
fs_1.default.mkdirSync(path_1.default.dirname(globalConfigPath), { recursive: true });
|
|
134
|
-
fs_1.default.writeFileSync(globalConfigPath, 'invalid json content {');
|
|
135
|
-
// Test loadGlobalConfig behavior with corrupted file
|
|
136
|
-
const { loadGlobalConfig } = await Promise.resolve().then(() => __importStar(require('../src/cli/commands/add-ide')));
|
|
137
|
-
const result = loadGlobalConfig();
|
|
138
|
-
node_assert_1.default.strictEqual(result, null, 'Should return null for corrupted config');
|
|
139
|
-
// Simulate recovery by creating new config
|
|
140
|
-
const newConfig = {
|
|
141
|
-
version: '2.0.27',
|
|
142
|
-
apiKey: 'fraim_recovered_key',
|
|
143
|
-
githubToken: 'ghp_recovered_token',
|
|
144
|
-
configuredAt: new Date().toISOString(),
|
|
145
|
-
userPreferences: {
|
|
146
|
-
autoSync: true,
|
|
147
|
-
backupConfigs: true
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
fs_1.default.writeFileSync(globalConfigPath, JSON.stringify(newConfig, null, 2));
|
|
151
|
-
// Verify recovery
|
|
152
|
-
const result2 = loadGlobalConfig();
|
|
153
|
-
(0, node_assert_1.default)(result2, 'Should load recovered config');
|
|
154
|
-
node_assert_1.default.strictEqual(result2.fraimKey, 'fraim_recovered_key', 'Should have recovered FRAIM key');
|
|
155
|
-
node_assert_1.default.strictEqual(result2.githubToken, 'ghp_recovered_token', 'Should have recovered GitHub token');
|
|
156
|
-
console.log('✅ Corrupted config recovery scenario passed');
|
|
157
|
-
}
|
|
158
|
-
finally {
|
|
159
|
-
// Cleanup
|
|
160
|
-
fs_1.default.rmSync(tempHomeDir, { recursive: true, force: true });
|
|
161
|
-
os_1.default.homedir = originalHomedir;
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
(0, node_test_1.test)('Setup Scenarios - Multiple Users Same Machine', async () => {
|
|
165
|
-
// Simulate multiple users on the same machine
|
|
166
|
-
const user1HomeDir = path_1.default.join(os_1.default.tmpdir(), '.fraim-test-user1-' + Date.now());
|
|
167
|
-
const user2HomeDir = path_1.default.join(os_1.default.tmpdir(), '.fraim-test-user2-' + Date.now());
|
|
168
|
-
const originalHomedir = os_1.default.homedir;
|
|
169
|
-
try {
|
|
170
|
-
// User 1 setup
|
|
171
|
-
os_1.default.homedir = () => user1HomeDir;
|
|
172
|
-
const user1ConfigPath = path_1.default.join(user1HomeDir, '.fraim', 'config.json');
|
|
173
|
-
fs_1.default.mkdirSync(path_1.default.dirname(user1ConfigPath), { recursive: true });
|
|
174
|
-
const user1Config = {
|
|
175
|
-
version: '2.0.27',
|
|
176
|
-
apiKey: 'fraim_user1_key',
|
|
177
|
-
githubToken: 'ghp_user1_token',
|
|
178
|
-
configuredAt: new Date().toISOString(),
|
|
179
|
-
userPreferences: {
|
|
180
|
-
autoSync: true,
|
|
181
|
-
backupConfigs: true
|
|
182
|
-
}
|
|
183
|
-
};
|
|
184
|
-
fs_1.default.writeFileSync(user1ConfigPath, JSON.stringify(user1Config, null, 2));
|
|
185
|
-
// User 2 setup
|
|
186
|
-
os_1.default.homedir = () => user2HomeDir;
|
|
187
|
-
const user2ConfigPath = path_1.default.join(user2HomeDir, '.fraim', 'config.json');
|
|
188
|
-
fs_1.default.mkdirSync(path_1.default.dirname(user2ConfigPath), { recursive: true });
|
|
189
|
-
const user2Config = {
|
|
190
|
-
version: '2.0.27',
|
|
191
|
-
apiKey: 'fraim_user2_key',
|
|
192
|
-
githubToken: 'ghp_user2_token',
|
|
193
|
-
configuredAt: new Date().toISOString(),
|
|
194
|
-
userPreferences: {
|
|
195
|
-
autoSync: false,
|
|
196
|
-
backupConfigs: false
|
|
197
|
-
}
|
|
198
|
-
};
|
|
199
|
-
fs_1.default.writeFileSync(user2ConfigPath, JSON.stringify(user2Config, null, 2));
|
|
200
|
-
// Verify both configs exist and are separate
|
|
201
|
-
(0, node_assert_1.default)(fs_1.default.existsSync(user1ConfigPath), 'User 1 config should exist');
|
|
202
|
-
(0, node_assert_1.default)(fs_1.default.existsSync(user2ConfigPath), 'User 2 config should exist');
|
|
203
|
-
const user1Data = JSON.parse(fs_1.default.readFileSync(user1ConfigPath, 'utf8'));
|
|
204
|
-
const user2Data = JSON.parse(fs_1.default.readFileSync(user2ConfigPath, 'utf8'));
|
|
205
|
-
// Verify they have different keys
|
|
206
|
-
node_assert_1.default.strictEqual(user1Data.apiKey, 'fraim_user1_key', 'User 1 should have their own key');
|
|
207
|
-
node_assert_1.default.strictEqual(user2Data.apiKey, 'fraim_user2_key', 'User 2 should have their own key');
|
|
208
|
-
node_assert_1.default.notStrictEqual(user1Data.apiKey, user2Data.apiKey, 'Users should have different keys');
|
|
209
|
-
// Verify they have different preferences
|
|
210
|
-
node_assert_1.default.strictEqual(user1Data.userPreferences.autoSync, true, 'User 1 preferences');
|
|
211
|
-
node_assert_1.default.strictEqual(user2Data.userPreferences.autoSync, false, 'User 2 preferences');
|
|
212
|
-
console.log('✅ Multiple users scenario passed');
|
|
213
|
-
}
|
|
214
|
-
finally {
|
|
215
|
-
// Cleanup
|
|
216
|
-
fs_1.default.rmSync(user1HomeDir, { recursive: true, force: true });
|
|
217
|
-
fs_1.default.rmSync(user2HomeDir, { recursive: true, force: true });
|
|
218
|
-
os_1.default.homedir = originalHomedir;
|
|
219
|
-
}
|
|
220
|
-
});
|
|
221
|
-
(0, node_test_1.test)('Setup Scenarios - Project Config Independence', async () => {
|
|
222
|
-
const tempHomeDir = path_1.default.join(os_1.default.tmpdir(), '.fraim-test-independence-home-' + Date.now());
|
|
223
|
-
const project1Dir = path_1.default.join(os_1.default.tmpdir(), '.fraim-test-project1-' + Date.now());
|
|
224
|
-
const project2Dir = path_1.default.join(os_1.default.tmpdir(), '.fraim-test-project2-' + Date.now());
|
|
225
|
-
const originalHomedir = os_1.default.homedir;
|
|
226
|
-
const originalCwd = process.cwd;
|
|
227
|
-
os_1.default.homedir = () => tempHomeDir;
|
|
228
|
-
try {
|
|
229
|
-
// Create global config
|
|
230
|
-
const globalConfigPath = path_1.default.join(tempHomeDir, '.fraim', 'config.json');
|
|
231
|
-
fs_1.default.mkdirSync(path_1.default.dirname(globalConfigPath), { recursive: true });
|
|
232
|
-
const globalConfig = {
|
|
233
|
-
version: '2.0.27',
|
|
234
|
-
apiKey: 'fraim_global_key',
|
|
235
|
-
githubToken: 'ghp_global_token',
|
|
236
|
-
configuredAt: new Date().toISOString(),
|
|
237
|
-
userPreferences: {
|
|
238
|
-
autoSync: true,
|
|
239
|
-
backupConfigs: true
|
|
240
|
-
}
|
|
241
|
-
};
|
|
242
|
-
fs_1.default.writeFileSync(globalConfigPath, JSON.stringify(globalConfig, null, 2));
|
|
243
|
-
// Create project 1 config
|
|
244
|
-
process.cwd = () => project1Dir;
|
|
245
|
-
const project1ConfigPath = path_1.default.join(project1Dir, '.fraim', 'config.json');
|
|
246
|
-
fs_1.default.mkdirSync(path_1.default.dirname(project1ConfigPath), { recursive: true });
|
|
247
|
-
const project1Config = {
|
|
248
|
-
version: '2.0.27',
|
|
249
|
-
project: {
|
|
250
|
-
name: 'project-one'
|
|
251
|
-
},
|
|
252
|
-
git: {
|
|
253
|
-
defaultBranch: 'main',
|
|
254
|
-
repoOwner: 'user',
|
|
255
|
-
repoName: 'project-one'
|
|
256
|
-
}
|
|
257
|
-
};
|
|
258
|
-
fs_1.default.writeFileSync(project1ConfigPath, JSON.stringify(project1Config, null, 2));
|
|
259
|
-
// Create project 2 config
|
|
260
|
-
process.cwd = () => project2Dir;
|
|
261
|
-
const project2ConfigPath = path_1.default.join(project2Dir, '.fraim', 'config.json');
|
|
262
|
-
fs_1.default.mkdirSync(path_1.default.dirname(project2ConfigPath), { recursive: true });
|
|
263
|
-
const project2Config = {
|
|
264
|
-
version: '2.0.27',
|
|
265
|
-
project: {
|
|
266
|
-
name: 'project-two'
|
|
267
|
-
},
|
|
268
|
-
git: {
|
|
269
|
-
defaultBranch: 'master',
|
|
270
|
-
repoOwner: 'user',
|
|
271
|
-
repoName: 'project-two'
|
|
272
|
-
}
|
|
273
|
-
};
|
|
274
|
-
fs_1.default.writeFileSync(project2ConfigPath, JSON.stringify(project2Config, null, 2));
|
|
275
|
-
// Verify all configs exist
|
|
276
|
-
(0, node_assert_1.default)(fs_1.default.existsSync(globalConfigPath), 'Global config should exist');
|
|
277
|
-
(0, node_assert_1.default)(fs_1.default.existsSync(project1ConfigPath), 'Project 1 config should exist');
|
|
278
|
-
(0, node_assert_1.default)(fs_1.default.existsSync(project2ConfigPath), 'Project 2 config should exist');
|
|
279
|
-
// Verify global config has secrets, projects don't
|
|
280
|
-
const globalData = JSON.parse(fs_1.default.readFileSync(globalConfigPath, 'utf8'));
|
|
281
|
-
const project1Data = JSON.parse(fs_1.default.readFileSync(project1ConfigPath, 'utf8'));
|
|
282
|
-
const project2Data = JSON.parse(fs_1.default.readFileSync(project2ConfigPath, 'utf8'));
|
|
283
|
-
// Global should have secrets
|
|
284
|
-
(0, node_assert_1.default)(globalData.apiKey, 'Global config should have API key');
|
|
285
|
-
(0, node_assert_1.default)(globalData.githubToken, 'Global config should have GitHub token');
|
|
286
|
-
// Projects should not have secrets
|
|
287
|
-
(0, node_assert_1.default)(!project1Data.apiKey, 'Project 1 should not have API key');
|
|
288
|
-
(0, node_assert_1.default)(!project1Data.githubToken, 'Project 1 should not have GitHub token');
|
|
289
|
-
(0, node_assert_1.default)(!project2Data.apiKey, 'Project 2 should not have API key');
|
|
290
|
-
(0, node_assert_1.default)(!project2Data.githubToken, 'Project 2 should not have GitHub token');
|
|
291
|
-
// Projects should have different settings
|
|
292
|
-
node_assert_1.default.strictEqual(project1Data.project.name, 'project-one', 'Project 1 name');
|
|
293
|
-
node_assert_1.default.strictEqual(project2Data.project.name, 'project-two', 'Project 2 name');
|
|
294
|
-
node_assert_1.default.strictEqual(project1Data.git.defaultBranch, 'main', 'Project 1 branch');
|
|
295
|
-
node_assert_1.default.strictEqual(project2Data.git.defaultBranch, 'master', 'Project 2 branch');
|
|
296
|
-
console.log('✅ Project config independence scenario passed');
|
|
297
|
-
}
|
|
298
|
-
finally {
|
|
299
|
-
// Cleanup
|
|
300
|
-
fs_1.default.rmSync(tempHomeDir, { recursive: true, force: true });
|
|
301
|
-
fs_1.default.rmSync(project1Dir, { recursive: true, force: true });
|
|
302
|
-
fs_1.default.rmSync(project2Dir, { recursive: true, force: true });
|
|
303
|
-
os_1.default.homedir = originalHomedir;
|
|
304
|
-
process.cwd = originalCwd;
|
|
305
|
-
}
|
|
306
|
-
});
|
|
307
|
-
(0, node_test_1.test)('Setup Scenarios - Token Validation Edge Cases', async () => {
|
|
308
|
-
// Test various token format validations
|
|
309
|
-
const { isValidTokenFormat } = await Promise.resolve().then(() => __importStar(require('../src/cli/setup/token-validator')));
|
|
310
|
-
// Test FRAIM key validation
|
|
311
|
-
(0, node_assert_1.default)(isValidTokenFormat('fraim_valid_key_123', 'fraim'), 'Valid FRAIM key should pass');
|
|
312
|
-
(0, node_assert_1.default)(!isValidTokenFormat('invalid_key', 'fraim'), 'Invalid FRAIM key should fail');
|
|
313
|
-
(0, node_assert_1.default)(!isValidTokenFormat('', 'fraim'), 'Empty FRAIM key should fail');
|
|
314
|
-
(0, node_assert_1.default)(!isValidTokenFormat('github_pat_123', 'fraim'), 'GitHub token as FRAIM key should fail');
|
|
315
|
-
// Test GitHub token validation
|
|
316
|
-
(0, node_assert_1.default)(isValidTokenFormat('ghp_valid_token_123', 'github'), 'Valid GitHub classic token should pass');
|
|
317
|
-
(0, node_assert_1.default)(isValidTokenFormat('github_pat_valid_token_123', 'github'), 'Valid GitHub PAT should pass');
|
|
318
|
-
(0, node_assert_1.default)(!isValidTokenFormat('invalid_token', 'github'), 'Invalid GitHub token should fail');
|
|
319
|
-
(0, node_assert_1.default)(!isValidTokenFormat('', 'github'), 'Empty GitHub token should fail');
|
|
320
|
-
(0, node_assert_1.default)(!isValidTokenFormat('fraim_123', 'github'), 'FRAIM key as GitHub token should fail');
|
|
321
|
-
console.log('✅ Token validation edge cases passed');
|
|
322
|
-
});
|