fraim-framework 2.0.37 → 2.0.38

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 (30) hide show
  1. package/dist/src/cli/commands/init-project.js +74 -0
  2. package/dist/src/cli/commands/setup.js +176 -0
  3. package/dist/src/cli/commands/test-mcp.js +135 -0
  4. package/dist/src/cli/fraim.js +6 -0
  5. package/dist/src/cli/setup/auto-mcp-setup.js +367 -0
  6. package/dist/src/cli/setup/ide-detector.js +163 -0
  7. package/dist/src/cli/setup/mcp-config-generator.js +115 -0
  8. package/dist/src/cli/setup/token-validator.js +49 -0
  9. package/dist/tests/debug-tools.js +2 -2
  10. package/dist/tests/shared-server-utils.js +57 -0
  11. package/dist/tests/test-client-scripts-validation.js +27 -5
  12. package/dist/tests/test-complete-setup-flow.js +110 -0
  13. package/dist/tests/test-ide-detector.js +46 -0
  14. package/dist/tests/test-improved-setup.js +121 -0
  15. package/dist/tests/test-mcp-config-generator.js +70 -0
  16. package/dist/tests/test-mcp-connection.js +58 -117
  17. package/dist/tests/test-mcp-issue-integration.js +2 -2
  18. package/dist/tests/test-mcp-lifecycle-methods.js +34 -100
  19. package/dist/tests/test-mcp-shared-server.js +308 -0
  20. package/dist/tests/test-package-size.js +21 -8
  21. package/dist/tests/test-script-location-independence.js +39 -62
  22. package/dist/tests/test-server-utils.js +32 -0
  23. package/dist/tests/test-session-rehydration.js +2 -2
  24. package/dist/tests/test-setup-integration.js +98 -0
  25. package/dist/tests/test-standalone.js +2 -2
  26. package/dist/tests/test-stub-registry.js +23 -7
  27. package/dist/tests/test-telemetry.js +2 -2
  28. package/dist/tests/test-token-validator.js +30 -0
  29. package/dist/tests/test-user-journey.js +2 -1
  30. package/package.json +2 -2
@@ -9,7 +9,7 @@ const db_service_js_1 = require("../src/fraim/db-service.js");
9
9
  const test_utils_1 = require("./test-utils");
10
10
  const node_assert_1 = __importDefault(require("node:assert"));
11
11
  const tree_kill_1 = __importDefault(require("tree-kill"));
12
- const path_1 = __importDefault(require("path"));
12
+ const test_server_utils_1 = require("./test-server-utils");
13
13
  async function testServerStartsAndResponds() {
14
14
  console.log(' 🚀 Testing Fraim Standalone Server...');
15
15
  let fraimProcess;
@@ -35,7 +35,7 @@ async function testServerStartsAndResponds() {
35
35
  // 2. Start server in standalone mode
36
36
  console.log(` Starting server on port ${PORT}...`);
37
37
  const npxCommand = process.platform === 'win32' ? 'npx.cmd' : 'npx';
38
- const serverScript = path_1.default.resolve(__dirname, '../dist/src/fraim-mcp-server.js');
38
+ const serverScript = (0, test_server_utils_1.getServerScriptPath)();
39
39
  fraimProcess = (0, node_child_process_1.spawn)(npxCommand, ['node', `"${serverScript}"`], {
40
40
  env: {
41
41
  ...process.env,
@@ -13,9 +13,21 @@ const build_stub_registry_1 = require("../scripts/build-stub-registry");
13
13
  * Tests for stub registry build process
14
14
  * Ensures that the npm package contains only stubs and scripts, not full workflows
15
15
  */
16
+ // Find project root by looking for package.json
17
+ function findProjectRoot() {
18
+ let currentDir = __dirname;
19
+ while (currentDir !== path_1.default.dirname(currentDir)) {
20
+ if (fs_1.default.existsSync(path_1.default.join(currentDir, 'package.json'))) {
21
+ return currentDir;
22
+ }
23
+ currentDir = path_1.default.dirname(currentDir);
24
+ }
25
+ throw new Error('Could not find project root (package.json not found)');
26
+ }
16
27
  (0, node_test_1.test)('Stub registry build generates correct structure', async () => {
17
28
  // Clean up any existing stubs
18
- const stubsPath = path_1.default.join(__dirname, '..', 'registry', 'stubs');
29
+ const projectRoot = findProjectRoot();
30
+ const stubsPath = path_1.default.join(projectRoot, 'registry', 'stubs');
19
31
  if (fs_1.default.existsSync(stubsPath)) {
20
32
  fs_1.default.rmSync(stubsPath, { recursive: true, force: true });
21
33
  }
@@ -32,7 +44,8 @@ const build_stub_registry_1 = require("../scripts/build-stub-registry");
32
44
  console.log(`✅ Generated ${stubFiles.length} workflow stubs`);
33
45
  });
34
46
  (0, node_test_1.test)('Generated stubs are lightweight and contain correct format', async () => {
35
- const stubsPath = path_1.default.join(__dirname, '..', 'registry', 'stubs', 'workflows');
47
+ const projectRoot = findProjectRoot();
48
+ const stubsPath = path_1.default.join(projectRoot, 'registry', 'stubs', 'workflows');
36
49
  // Find a stub file to test
37
50
  const stubFiles = getAllFiles(stubsPath, '.md');
38
51
  (0, node_assert_1.default)(stubFiles.length > 0, 'Should have stub files to test');
@@ -50,8 +63,9 @@ const build_stub_registry_1 = require("../scripts/build-stub-registry");
50
63
  console.log(`✅ Stub format verified (${stubLines} lines)`);
51
64
  });
52
65
  (0, node_test_1.test)('Stubs do not contain full workflow content', async () => {
53
- const stubsPath = path_1.default.join(__dirname, '..', 'registry', 'stubs', 'workflows');
54
- const fullWorkflowsPath = path_1.default.join(__dirname, '..', 'registry', 'workflows');
66
+ const projectRoot = findProjectRoot();
67
+ const stubsPath = path_1.default.join(projectRoot, 'registry', 'stubs', 'workflows');
68
+ const fullWorkflowsPath = path_1.default.join(projectRoot, 'registry', 'workflows');
55
69
  const stubFiles = getAllFiles(stubsPath, '.md');
56
70
  (0, node_assert_1.default)(stubFiles.length > 0, 'Should have stub files to test');
57
71
  for (const stubFile of stubFiles.slice(0, 3)) { // Test first 3 stubs
@@ -72,7 +86,8 @@ const build_stub_registry_1 = require("../scripts/build-stub-registry");
72
86
  console.log('✅ Stubs are properly lightweight');
73
87
  });
74
88
  (0, node_test_1.test)('Package.json files array excludes full workflows', () => {
75
- const packageJsonPath = path_1.default.join(__dirname, '..', 'package.json');
89
+ const projectRoot = findProjectRoot();
90
+ const packageJsonPath = path_1.default.join(projectRoot, 'package.json');
76
91
  const packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonPath, 'utf8'));
77
92
  const files = packageJson.files || [];
78
93
  // Should include stubs
@@ -87,12 +102,13 @@ const build_stub_registry_1 = require("../scripts/build-stub-registry");
87
102
  console.log('✅ Package.json correctly excludes full workflows');
88
103
  });
89
104
  (0, node_test_1.test)('Scripts are still included in package', () => {
90
- const scriptsPath = path_1.default.join(__dirname, '..', 'registry', 'scripts');
105
+ const projectRoot = findProjectRoot();
106
+ const scriptsPath = path_1.default.join(projectRoot, 'registry', 'scripts');
91
107
  (0, node_assert_1.default)(fs_1.default.existsSync(scriptsPath), 'Scripts directory should exist');
92
108
  const scriptFiles = getAllFiles(scriptsPath);
93
109
  (0, node_assert_1.default)(scriptFiles.length > 0, 'Should have script files');
94
110
  // Verify package.json includes scripts
95
- const packageJsonPath = path_1.default.join(__dirname, '..', 'package.json');
111
+ const packageJsonPath = path_1.default.join(projectRoot, 'package.json');
96
112
  const packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonPath, 'utf8'));
97
113
  const files = packageJson.files || [];
98
114
  (0, node_assert_1.default)(files.includes('registry/scripts/'), 'Package should include scripts');
@@ -9,7 +9,7 @@ const db_service_js_1 = require("../src/fraim/db-service.js");
9
9
  const test_utils_1 = require("./test-utils");
10
10
  const node_assert_1 = __importDefault(require("node:assert"));
11
11
  const tree_kill_1 = __importDefault(require("tree-kill"));
12
- const path_1 = __importDefault(require("path"));
12
+ const test_server_utils_1 = require("./test-server-utils");
13
13
  async function testTelemetryFlow() {
14
14
  console.log(' 🚀 Testing Fraim Telemetry System...');
15
15
  let fraimProcess;
@@ -39,7 +39,7 @@ async function testTelemetryFlow() {
39
39
  // 2. Start Server
40
40
  console.log(` Starting server on port ${PORT}...`);
41
41
  const npxCommand = process.platform === 'win32' ? 'npx.cmd' : 'npx';
42
- const serverScript = path_1.default.resolve(__dirname, '../dist/src/fraim-mcp-server.js');
42
+ const serverScript = (0, test_server_utils_1.getServerScriptPath)();
43
43
  fraimProcess = (0, node_child_process_1.spawn)(npxCommand, ['node', `"${serverScript}"`], {
44
44
  env: {
45
45
  ...process.env,
@@ -0,0 +1,30 @@
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 token_validator_1 = require("../src/cli/setup/token-validator");
9
+ (0, node_test_1.test)('isValidTokenFormat should validate FRAIM keys correctly', () => {
10
+ (0, node_assert_1.default)((0, token_validator_1.isValidTokenFormat)('fraim_abc123456789012', 'fraim'), 'Valid FRAIM key should pass');
11
+ (0, node_assert_1.default)(!(0, token_validator_1.isValidTokenFormat)('invalid_key', 'fraim'), 'Invalid FRAIM key should fail');
12
+ (0, node_assert_1.default)(!(0, token_validator_1.isValidTokenFormat)('fraim_short', 'fraim'), 'Short FRAIM key should fail');
13
+ (0, node_assert_1.default)(!(0, token_validator_1.isValidTokenFormat)('', 'fraim'), 'Empty string should fail');
14
+ });
15
+ (0, node_test_1.test)('isValidTokenFormat should validate GitHub tokens correctly', () => {
16
+ (0, node_assert_1.default)((0, token_validator_1.isValidTokenFormat)('ghp_abc123456789', 'github'), 'Valid GitHub classic token should pass');
17
+ (0, node_assert_1.default)((0, token_validator_1.isValidTokenFormat)('github_pat_abc123456789', 'github'), 'Valid GitHub PAT should pass');
18
+ (0, node_assert_1.default)(!(0, token_validator_1.isValidTokenFormat)('invalid_token', 'github'), 'Invalid GitHub token should fail');
19
+ (0, node_assert_1.default)(!(0, token_validator_1.isValidTokenFormat)('gho_abc123456789', 'github'), 'OAuth token should fail');
20
+ (0, node_assert_1.default)(!(0, token_validator_1.isValidTokenFormat)('', 'github'), 'Empty string should fail');
21
+ });
22
+ (0, node_test_1.test)('validateFraimKey should validate format', async () => {
23
+ const validKey = 'fraim_abc123456789012';
24
+ const invalidKey = 'invalid_key';
25
+ const shortKey = 'fraim_short';
26
+ (0, node_assert_1.default)(await (0, token_validator_1.validateFraimKey)(validKey), 'Valid FRAIM key should pass');
27
+ (0, node_assert_1.default)(!await (0, token_validator_1.validateFraimKey)(invalidKey), 'Invalid FRAIM key should fail');
28
+ (0, node_assert_1.default)(!await (0, token_validator_1.validateFraimKey)(shortKey), 'Short FRAIM key should fail');
29
+ (0, node_assert_1.default)(!await (0, token_validator_1.validateFraimKey)(''), 'Empty key should fail');
30
+ });
@@ -12,6 +12,7 @@ const tree_kill_1 = __importDefault(require("tree-kill"));
12
12
  const fs_1 = __importDefault(require("fs"));
13
13
  const path_1 = __importDefault(require("path"));
14
14
  const os_1 = __importDefault(require("os"));
15
+ const test_server_utils_1 = require("./test-server-utils");
15
16
  async function testDualDiscoveryJourney() {
16
17
  console.log(' 🚀 Starting Dual Discovery User Journey Test...');
17
18
  // Setup
@@ -156,7 +157,7 @@ async function testDualDiscoveryJourney() {
156
157
  fs_1.default.writeFileSync(path_1.default.join(tempDir, 'package.json'), JSON.stringify({
157
158
  dependencies: { "@fraim/framework": "1.0.0" }
158
159
  }));
159
- const serverScript = path_1.default.resolve(__dirname, '../dist/src/fraim-mcp-server.js');
160
+ const serverScript = (0, test_server_utils_1.getServerScriptPath)();
160
161
  fraimProcess = (0, node_child_process_1.spawn)(process.execPath, [tsxCli, serverScript], {
161
162
  cwd: tempDir,
162
163
  env: { ...process.env, FRAIM_MCP_PORT: PORT.toString(), FRAIM_SKIP_INDEX_ON_START: 'true' },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fraim-framework",
3
- "version": "2.0.37",
3
+ "version": "2.0.38",
4
4
  "description": "FRAIM v2: Framework for Rigor-based AI Management - Transform from solo developer to AI manager orchestrating production-ready code with enterprise-grade discipline",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -12,7 +12,7 @@
12
12
  "dev": "tsx --watch src/fraim-mcp-server.ts",
13
13
  "build": "tsc && npm run build:stubs && npm run validate:registry",
14
14
  "build:stubs": "tsx scripts/build-stub-registry.ts",
15
- "test": "tsx --test > test.log 2>&1",
15
+ "test": "node scripts/test-with-server.js",
16
16
  "start:fraim": "tsx src/fraim-mcp-server.ts",
17
17
  "dev:fraim": "tsx --watch src/fraim-mcp-server.ts",
18
18
  "watch:fraimlogs": "tsx scripts/watch-fraim-logs.ts",