agent-window 1.3.0 → 1.3.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-window",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "A window to interact with AI agents through chat interfaces. Simplified interaction, powerful backend capabilities.",
5
5
  "type": "module",
6
6
  "main": "src/bot.js",
@@ -187,7 +187,9 @@ export async function addInstance(name, projectPath, options = {}) {
187
187
  }
188
188
 
189
189
  // Determine config path for BMAD plugin
190
- configPath = options.configPath || null;
190
+ // BMAD plugins use their own config file in the project: {projectPath}/_agent-bridge/config/config.json
191
+ const agentBridgeConfigPath = path.join(validation.projectPath, '_agent-bridge', 'config', 'config.json');
192
+ configPath = options.configPath || agentBridgeConfigPath;
191
193
 
192
194
  newInstance = {
193
195
  name,
@@ -477,11 +479,21 @@ export async function importInstance(discovered) {
477
479
  }
478
480
  }
479
481
 
482
+ // Determine correct config path based on instance type
483
+ let finalConfigPath = discovered.configPath;
484
+ if (discovered.instanceType === 'bmad-plugin' && validatedPath) {
485
+ // For BMAD plugins, ensure config path points to _agent-bridge/config/config.json
486
+ const agentBridgeConfigPath = path.join(validatedPath, '_agent-bridge', 'config', 'config.json');
487
+ if (existsSync(agentBridgeConfigPath)) {
488
+ finalConfigPath = agentBridgeConfigPath;
489
+ }
490
+ }
491
+
480
492
  const newInstance = {
481
493
  name: discovered.name,
482
494
  displayName: discovered.displayName,
483
495
  projectPath: validatedPath,
484
- configPath: discovered.configPath,
496
+ configPath: finalConfigPath,
485
497
  pluginPath: validatedPluginPath,
486
498
  botName: discovered.botName,
487
499
  instanceType: discovered.instanceType || 'simple-config', // Save instance type
@@ -1,12 +0,0 @@
1
- {
2
- "BOT_TOKEN": "MTQ2MjczODE4MDc4NzY2Njk3Nw.GZYfmO.z1yzHmhHZbbg0sy-oJDDyNxSpedsXVI1BpifOY",
3
- "CLAUDE_CODE_OAUTH_TOKEN": "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",
4
- "PROJECT_DIR": "/Users/cyrus/Documents/project/cognitive-prototype/interactive-prototype-cognitiveOS",
5
- "ALLOWED_CHANNELS": "1462723721188868096",
6
- "_comment_workspace": "工作空间配置(v1.0.9+ 新标准)",
7
- "workspace": {
8
- "containerName": "claude-sandbox",
9
- "dockerImage": "claude-sandbox:latest",
10
- "portMappings": []
11
- }
12
- }
@@ -1,152 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * 实例管理诊断脚本
4
- *
5
- * 用于诊断实例管理中的问题:
6
- * 1. agentbridge 实例的配置路径错误
7
- * 2. Edit Config 点击报错
8
- */
9
-
10
- import { readInstances } from '../src/core/instance/manager.js';
11
- import { getProcesses } from '../src/core/instance/pm2-bridge.js';
12
- import { existsSync } from 'fs';
13
- import { paths } from '../src/core/platform/index.js';
14
-
15
- console.log('\n=== AgentWindow 实例管理诊断 ===\n');
16
-
17
- // 1. 检查 instances.json 状态
18
- console.log('1. instances.json 状态');
19
- try {
20
- const data = await readInstances();
21
- console.log(` 总实例数: ${data.instances.length}`);
22
- data.instances.forEach(inst => {
23
- console.log(`\n 实例: ${inst.name}`);
24
- console.log(` - displayName: ${inst.displayName}`);
25
- console.log(` - botName: ${inst.botName}`);
26
- console.log(` - projectPath: ${inst.projectPath}`);
27
- console.log(` - configPath: ${inst.configPath || '未设置'}`);
28
- console.log(` - pluginPath: ${inst.pluginPath || '未设置'}`);
29
- console.log(` - instanceType: ${inst.instanceType}`);
30
- console.log(` - enabled: ${inst.enabled}`);
31
- });
32
- } catch (error) {
33
- console.log(` 读取失败: ${error.message}`);
34
- }
35
-
36
- // 2. 检查 PM2 进程状态
37
- console.log('\n2. PM2 进程状态');
38
- try {
39
- const processes = await getProcesses();
40
- const botProcesses = processes.filter(p => p.name && p.name.startsWith('bot-'));
41
-
42
- console.log(` 总 bot 进程数: ${botProcesses.length}`);
43
- botProcesses.forEach(proc => {
44
- console.log(`\n 进程: ${proc.name}`);
45
- console.log(` - pid: ${proc.pid}`);
46
- console.log(` - status: ${proc.status}`);
47
- console.log(` - cwd: ${proc.cwd}`);
48
- console.log(` - configPath (从 env): ${proc.configPath || '未设置'}`);
49
- console.log(` - memory: ${(proc.memory / 1024 / 1024).toFixed(1)} MB`);
50
- console.log(` - cpu: ${proc.cpu}%`);
51
-
52
- // 检查环境变量
53
- if (proc.env && proc.env.CONFIG_PATH) {
54
- console.log(` - env.CONFIG_PATH: ${proc.env.CONFIG_PATH}`);
55
- const configExists = existsSync(proc.env.CONFIG_PATH);
56
- console.log(` - CONFIG_PATH 存在: ${configExists ? '是' : '否'}`);
57
- }
58
- });
59
- } catch (error) {
60
- console.log(` 读取 PM2 失败: ${error.message}`);
61
- }
62
-
63
- // 3. 检查 bots 目录
64
- console.log('\n3. Bots 目录检查');
65
- const botsDir = paths.getBotsDir();
66
- console.log(` Bots Dir: ${botsDir}`);
67
-
68
- // 4. 分析问题
69
- console.log('\n4. 问题分析');
70
-
71
- // 检查 agentbridge 实例
72
- const data = await readInstances();
73
- const agentbridge = data.instances.find(i => i.name === 'agentbridge');
74
-
75
- if (agentbridge) {
76
- console.log('\n 【问题 1】agentbridge 实例配置路径分析');
77
- console.log(` 当前 configPath: ${agentbridge.configPath || '未设置'}`);
78
-
79
- // 检查 PM2 进程
80
- const processes = await getProcesses();
81
- const proc = processes.find(p => p.name === 'bot-agentbridge');
82
-
83
- if (proc) {
84
- console.log(` PM2 进程 cwd: ${proc.cwd}`);
85
- console.log(` PM2 env.CONFIG_PATH: ${proc.configPath || '未设置'}`);
86
-
87
- // 分析期望的配置路径
88
- const expectedConfigPath = `${botsDir}/agentbridge/config.json`;
89
- console.log(`\n 期望配置路径: ${expectedConfigPath}`);
90
- console.log(` 配置文件存在: ${existsSync(expectedConfigPath) ? '是' : '否'}`);
91
-
92
- // 判断问题
93
- if (!agentbridge.configPath || agentbridge.configPath.includes('agent-bridge-main/config')) {
94
- console.log('\n ❌ 问题确认: configPath 指向项目内配置,而非 ~/bots/agentbridge/config.json');
95
- console.log(' 原因: discoverInstances() 未能正确读取 CONFIG_PATH 环境变量');
96
- } else {
97
- console.log('\n ✓ configPath 设置正确');
98
- }
99
- } else {
100
- console.log(' ⚠ 未找到 bot-agentbridge 进程');
101
- }
102
- }
103
-
104
- // 检查 Edit Config 问题
105
- console.log('\n 【问题 2】Edit Config 功能分析');
106
-
107
- for (const inst of data.instances) {
108
- console.log(`\n 实例: ${inst.name}`);
109
- console.log(` - configPath: ${inst.configPath || '未设置'}`);
110
- console.log(` - configPath 为 null: ${inst.configPath === null ? '是(会触发错误)' : '否'}`);
111
-
112
- if (inst.configPath) {
113
- const exists = existsSync(inst.configPath);
114
- console.log(` - 配置文件存在: ${exists ? '是' : '否'}`);
115
-
116
- if (!exists) {
117
- console.log(` ⚠ 警告: configPath 指向的文件不存在`);
118
- }
119
- } else {
120
- console.log(` ❌ 问题: configPath 为 null,点击 Edit Config 会报错`);
121
- }
122
- }
123
-
124
- // 5. 根本原因分析
125
- console.log('\n5. 根本原因分析');
126
- console.log('\n 问题 1 - agentbridge 配置路径错误:');
127
- console.log(' - discoverInstances() 依赖 PM2 进程的 CONFIG_PATH 环境变量');
128
- console.log(' - bot-agentbridge 进程没有设置 CONFIG_PATH 环境变量');
129
- console.log(' - 导致 discoverInstances() 无法获取正确的配置路径');
130
- console.log(' - 最后回退到使用 cwd 作为项目路径,但配置路径仍为 null');
131
-
132
- console.log('\n 问题 2 - Edit Config 报错:');
133
- console.log(' - 前端检查 instance.configPath 是否存在');
134
- console.log(' - 如果 configPath 为 null,显示错误 "This instance does not have a config file"');
135
- console.log(' - 这是因为 discoverInstances() 未能从 PM2 获取 CONFIG_PATH');
136
-
137
- // 6. 解决方案
138
- console.log('\n6. 建议解决方案');
139
- console.log('\n 方案 A: 为 bot-agentbridge 设置 CONFIG_PATH 环境变量');
140
- console.log(` pm2 restart bot-agentbridge --env CONFIG_PATH=/Users/cyrus/bots/agentbridge/config.json`);
141
-
142
- console.log('\n 方案 B: 修改 discoverInstances() 逻辑');
143
- console.log(' - 在 discoverInstances() 中,按实例名推断配置路径');
144
- console.log(` - 如果实例名为 "agentbridge",自动推断 configPath 为 ~/bots/agentbridge/config.json`);
145
- console.log(' - 优先级: CONFIG_PATH > 推断路径 > null');
146
-
147
- console.log('\n 方案 C: 创建 ~/bots/agentbridge/ 目录并设置配置');
148
- console.log(' mkdir -p ~/bots/agentbridge');
149
- console.log(' cp config/config.json ~/bots/agentbridge/');
150
- console.log(' pm2 restart bot-agentbridge --env CONFIG_PATH=~/bots/agentbridge/config.json');
151
-
152
- console.log('\n=== 诊断完成 ===\n');
@@ -1,136 +0,0 @@
1
- #!/bin/bash
2
-
3
- echo "=== AgentWindow 实例类型显示问题 - 最终验证测试 ==="
4
- echo ""
5
-
6
- # 颜色定义
7
- GREEN='\033[0;32m'
8
- RED='\033[0;31m'
9
- YELLOW='\033[1;33m'
10
- NC='\033[0m' # No Color
11
-
12
- # 测试计数
13
- TOTAL=0
14
- PASSED=0
15
- FAILED=0
16
-
17
- # 测试函数
18
- test_case() {
19
- local name="$1"
20
- local command="$2"
21
- local expected="$3"
22
-
23
- TOTAL=$((TOTAL + 1))
24
- echo -n "测试 $TOTAL: $name ... "
25
-
26
- result=$(eval "$command" 2>/dev/null)
27
-
28
- if echo "$result" | grep -q "$expected"; then
29
- echo -e "${GREEN}✓ 通过${NC}"
30
- PASSED=$((PASSED + 1))
31
- return 0
32
- else
33
- echo -e "${RED}✗ 失败${NC}"
34
- echo " 期望: $expected"
35
- echo " 实际: $result"
36
- FAILED=$((FAILED + 1))
37
- return 1
38
- fi
39
- }
40
-
41
- echo "1. 测试实例类型检测"
42
- echo "-------------------"
43
-
44
- test_case \
45
- "agentbridge 实例类型" \
46
- "curl -s http://127.0.0.1:3721/api/instances | jq -r '.[] | select(.name==\"agentbridge\") | .instanceType'" \
47
- "bmad-plugin"
48
-
49
- test_case \
50
- "cognitive 实例类型" \
51
- "curl -s http://127.0.0.1:3721/api/instances | jq -r '.[] | select(.name==\"cognitive\") | .instanceType'" \
52
- "bmad-plugin"
53
-
54
- test_case \
55
- "corp 实例类型" \
56
- "curl -s http://127.0.0.1:3721/api/instances | jq -r '.[] | select(.name==\"corp\") | .instanceType'" \
57
- "bmad-plugin"
58
-
59
- echo ""
60
- echo "2. 测试实例数据完整性"
61
- echo "---------------------"
62
-
63
- test_case \
64
- "agentbridge 有 projectPath" \
65
- "curl -s http://127.0.0.1:3721/api/instances | jq -r '.[] | select(.name==\"agentbridge\") | .projectPath'" \
66
- "cognitive-prototype"
67
-
68
- test_case \
69
- "cognitive 有 projectPath" \
70
- "curl -s http://127.0.0.1:3721/api/instances | jq -r '.[] | select(.name==\"cognitive\") | .projectPath'" \
71
- "cognitive-prototype"
72
-
73
- test_case \
74
- "corp 有 projectPath" \
75
- "curl -s http://127.0.0.1:3721/api/instances | jq -r '.[] | select(.name==\"corp\") | .projectPath'" \
76
- "corp-office"
77
-
78
- echo ""
79
- echo "3. 测试 API 响应结构"
80
- echo "-------------------"
81
-
82
- test_case \
83
- "API 返回 instanceType 字段" \
84
- "curl -s http://127.0.0.1:3721/api/instances | jq -r '.[0] | keys[]' | grep instanceType" \
85
- "instanceType"
86
-
87
- test_case \
88
- "API 返回 botName 字段" \
89
- "curl -s http://127.0.0.1:3721/api/instances | jq -r '.[0] | keys[]' | grep botName" \
90
- "botName"
91
-
92
- test_case \
93
- "API 返回 configPath 字段" \
94
- "curl -s http://127.0.0.1:3721/api/instances | jq -r '.[0] | keys[]' | grep configPath" \
95
- "configPath"
96
-
97
- echo ""
98
- echo "4. 验证 instances.json 文件"
99
- echo "-------------------------"
100
-
101
- test_case \
102
- "instances.json 存在" \
103
- "test -f ~/.agent-window/instances.json && echo 'exists'" \
104
- "exists"
105
-
106
- test_case \
107
- "instances.json 包含 3 个实例" \
108
- "cat ~/.agent-window/instances.json | jq '.instances | length'" \
109
- "3"
110
-
111
- test_case \
112
- "所有实例都有 instanceType" \
113
- "cat ~/.agent-window/instances.json | jq -r '.instances[].instanceType' | sort -u" \
114
- "bmad-plugin"
115
-
116
- echo ""
117
- echo "=== 测试总结 ==="
118
- echo "----------------"
119
- echo "总测试数: $TOTAL"
120
- echo -e "通过: ${GREEN}$PASSED${NC}"
121
- echo -e "失败: ${RED}$FAILED${NC}"
122
-
123
- if [ $FAILED -eq 0 ]; then
124
- echo ""
125
- echo -e "${GREEN}✓ 所有测试通过!实例类型显示问题已完全修复。${NC}"
126
- echo ""
127
- echo "前端预期显示:"
128
- echo " - agentbridge: BMAD 插件 (绿色)"
129
- echo " - cognitive: BMAD 插件 (绿色)"
130
- echo " - corp: BMAD 插件 (绿色)"
131
- exit 0
132
- else
133
- echo ""
134
- echo -e "${RED}✗ 有 $FAILED 个测试失败,请检查修复。${NC}"
135
- exit 1
136
- fi
@@ -1,89 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Fix agentbridge instance to use correct project path
5
- */
6
-
7
- import { readInstances, writeInstances, updateInstance } from '../src/core/instance/manager.js';
8
- import { detectInstanceType } from '../src/core/instance/validator.js';
9
- import { existsSync } from 'fs';
10
- import fs from 'fs/promises';
11
-
12
- async function main() {
13
- console.log('=== Fix AgentBridge Instance ===\n');
14
-
15
- const data = await readInstances();
16
- const agentbridge = data.instances.find(i => i.name === 'agentbridge');
17
-
18
- if (!agentbridge) {
19
- console.log('No agentbridge instance found');
20
- return;
21
- }
22
-
23
- console.log('Current agentbridge instance:');
24
- console.log(` Name: ${agentbridge.name}`);
25
- console.log(` Project Path: ${agentbridge.projectPath}`);
26
- console.log(` Config Path: ${agentbridge.configPath}`);
27
- console.log(` Instance Type: ${agentbridge.instanceType}`);
28
-
29
- // Read config to get PROJECT_DIR
30
- if (agentbridge.configPath && existsSync(agentbridge.configPath)) {
31
- try {
32
- const configContent = await fs.readFile(agentbridge.configPath, 'utf8');
33
- const config = JSON.parse(configContent);
34
-
35
- if (config.PROJECT_DIR) {
36
- console.log(`\nConfig PROJECT_DIR: ${config.PROJECT_DIR}`);
37
-
38
- // Check if PROJECT_DIR exists and detect its type
39
- if (existsSync(config.PROJECT_DIR)) {
40
- const projectType = detectInstanceType(config.PROJECT_DIR);
41
- console.log(`PROJECT_DIR Type: ${projectType}`);
42
-
43
- if (projectType === 'bmad-plugin') {
44
- console.log('\n✓ PROJECT_DIR is a valid BMAD plugin');
45
-
46
- // Update instance
47
- const index = data.instances.findIndex(i => i.name === 'agentbridge');
48
- data.instances[index].projectPath = config.PROJECT_DIR;
49
- data.instances[index].instanceType = projectType;
50
-
51
- // Try to find plugin path
52
- const pluginPath = existsSync(config.PROJECT_DIR + '/_agent-bridge')
53
- ? config.PROJECT_DIR + '/_agent-bridge/src'
54
- : existsSync(config.PROJECT_DIR + '/src/bot.js')
55
- ? config.PROJECT_DIR + '/src'
56
- : null;
57
-
58
- if (pluginPath) {
59
- data.instances[index].pluginPath = pluginPath;
60
- }
61
-
62
- data.instances[index].updatedAt = new Date().toISOString();
63
-
64
- await writeInstances(data);
65
-
66
- console.log('\n✓ Instance updated successfully');
67
- console.log(` New Project Path: ${data.instances[index].projectPath}`);
68
- console.log(` New Instance Type: ${data.instances[index].instanceType}`);
69
- console.log(` New Plugin Path: ${data.instances[index].pluginPath || 'none'}`);
70
- } else {
71
- console.log('\n✗ PROJECT_DIR is not a BMAD plugin');
72
- }
73
- } else {
74
- console.log('\n✗ PROJECT_DIR does not exist');
75
- }
76
- } else {
77
- console.log('\n✗ Config does not have PROJECT_DIR');
78
- }
79
- } catch (error) {
80
- console.error(`\n✗ Error reading config: ${error.message}`);
81
- }
82
- } else {
83
- console.log('\n✗ Config path does not exist');
84
- }
85
-
86
- console.log('\n=== Fix Complete ===');
87
- }
88
-
89
- main().catch(console.error);
@@ -1,55 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Import cognitive and corp instances
5
- */
6
-
7
- import { discoverInstances, importInstance, listInstances } from '../src/core/instance/manager.js';
8
-
9
- async function main() {
10
- console.log('=== Import Instances ===\n');
11
-
12
- // Discover instances
13
- console.log('Discovering instances...');
14
- const discovered = await discoverInstances();
15
-
16
- console.log(`Found ${discovered.length} unregistered instances:\n`);
17
-
18
- for (const inst of discovered) {
19
- console.log(`Instance: ${inst.name}`);
20
- console.log(` Type: ${inst.instanceType}`);
21
- console.log(` Project: ${inst.projectPath}`);
22
- console.log(` Status: ${inst.status}`);
23
-
24
- // Import the instance
25
- console.log(`\nImporting ${inst.name}...`);
26
- const result = await importInstance(inst);
27
-
28
- if (result.success) {
29
- console.log(`✓ Imported successfully`);
30
- console.log(` Name: ${result.instance.name}`);
31
- console.log(` Type: ${result.instance.instanceType}`);
32
- console.log(` Project Path: ${result.instance.projectPath}`);
33
- } else {
34
- console.log(`✗ Import failed: ${result.error}`);
35
- }
36
- console.log('');
37
- }
38
-
39
- // List all instances
40
- console.log('\n=== All Registered Instances ===\n');
41
- const allInstances = await listInstances();
42
-
43
- for (const inst of allInstances) {
44
- console.log(`${inst.displayName} (${inst.name})`);
45
- console.log(` Type: ${inst.instanceType}`);
46
- console.log(` Project: ${inst.projectPath}`);
47
- console.log(` Bot: ${inst.botName}`);
48
- console.log(` Tags: ${inst.tags?.join(', ') || 'none'}`);
49
- console.log('');
50
- }
51
-
52
- console.log('=== Import Complete ===');
53
- }
54
-
55
- main().catch(console.error);
@@ -1,39 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Test all API endpoints to verify instanceType is returned correctly
5
- */
6
-
7
- const instances = await fetch('http://127.0.0.1:3721/api/instances').then(r => r.json());
8
-
9
- console.log('=== API Test Results ===\n');
10
- console.log(`Total instances: ${instances.length}\n`);
11
-
12
- for (const inst of instances) {
13
- console.log(`Instance: ${inst.name}`);
14
- console.log(` Display Name: ${inst.displayName}`);
15
- console.log(` Type: ${inst.instanceType}`);
16
- console.log(` Project: ${inst.projectPath}`);
17
- console.log(` Bot: ${inst.botName}`);
18
-
19
- // Verify type is correct
20
- if (inst.instanceType === 'bmad-plugin') {
21
- console.log(` ✓ Correctly detected as BMAD plugin`);
22
- } else if (inst.instanceType === 'simple-config') {
23
- console.log(` ✓ Correctly detected as simple config`);
24
- } else {
25
- console.log(` ✗ Unknown type - This should not happen!`);
26
- }
27
- console.log('');
28
- }
29
-
30
- console.log('=== Frontend Display Test ===\n');
31
- console.log('Expected frontend behavior:');
32
- console.log(' - agentbridge: Display "BMAD 插件" (green badge)');
33
- console.log(' - cognitive: Display "BMAD 插件" (green badge)');
34
- console.log(' - corp: Display "BMAD 插件" (green badge)');
35
- console.log('\nFrontend code (InstanceCard.vue):');
36
- console.log(' - Line 154-161: instanceTypeLabel maps instanceType to display text');
37
- console.log(' - Line 163-165: instanceTypeClass applies CSS class');
38
- console.log(' - Line 355-374: CSS styles for different types');
39
- console.log('\n✓ All instances should display "BMAD 插件" with green background');
@@ -1,95 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Comprehensive test for instance discovery and type detection
5
- */
6
-
7
- import { discoverInstances, getInstance } from '../src/core/instance/manager.js';
8
- import { detectInstanceType } from '../src/core/instance/validator.js';
9
- import { existsSync } from 'fs';
10
- import path from 'path';
11
-
12
- async function main() {
13
- console.log('=== Instance Discovery and Type Detection Test ===\n');
14
-
15
- // Test 1: Discover instances
16
- console.log('Test 1: Discover unregistered PM2 instances');
17
- console.log(''.repeat(50));
18
-
19
- const discovered = await discoverInstances();
20
- console.log(`Found ${discovered.length} unregistered instances\n`);
21
-
22
- for (const inst of discovered) {
23
- console.log(`Instance: ${inst.name}`);
24
- console.log(` Bot Name: ${inst.botName}`);
25
- console.log(` Display Name: ${inst.displayName}`);
26
- console.log(` Project Path: ${inst.projectPath}`);
27
- console.log(` Config Path: ${inst.configPath}`);
28
- console.log(` Instance Type: ${inst.instanceType}`);
29
- console.log(` Status: ${inst.status}`);
30
- console.log(` Running: ${inst.isRunning}`);
31
-
32
- // Verify detection
33
- if (inst.projectPath && existsSync(inst.projectPath)) {
34
- const verifiedType = detectInstanceType(inst.projectPath);
35
- console.log(` Verified Type: ${verifiedType}`);
36
- console.log(` Match: ${verifiedType === inst.instanceType ? '✓' : '✗'}`);
37
-
38
- // Check directory structure
39
- console.log(` Directory structure:`);
40
- console.log(` - _bmad: ${existsSync(path.join(inst.projectPath, '_bmad')) ? '✓' : '✗'}`);
41
- console.log(` - _agent-bridge: ${existsSync(path.join(inst.projectPath, '_agent-bridge')) ? '✓' : '✗'}`);
42
- console.log(` - config.json: ${existsSync(path.join(inst.projectPath, 'config.json')) ? '✓' : '✗'}`);
43
- } else {
44
- console.log(` Project path invalid or not accessible`);
45
- }
46
- console.log('');
47
- }
48
-
49
- // Test 2: Check registered instances
50
- console.log('\nTest 2: Check registered instances');
51
- console.log(''.repeat(50));
52
-
53
- const agentbridge = await getInstance('agentbridge');
54
- if (agentbridge) {
55
- console.log('Registered Instance: agentbridge');
56
- console.log(` Project Path: ${agentbridge.projectPath}`);
57
- console.log(` Config Path: ${agentbridge.configPath}`);
58
- console.log(` Instance Type: ${agentbridge.instanceType}`);
59
- console.log(` Bot Name: ${agentbridge.botName}`);
60
-
61
- // Verify detection
62
- if (agentbridge.projectPath && existsSync(agentbridge.projectPath)) {
63
- const verifiedType = detectInstanceType(agentbridge.projectPath);
64
- console.log(` Verified Type: ${verifiedType}`);
65
- console.log(` Match: ${verifiedType === agentbridge.instanceType ? '✓' : '✗'}`);
66
- }
67
-
68
- // Check config for PROJECT_DIR
69
- if (agentbridge.configPath && existsSync(agentbridge.configPath)) {
70
- const fs = await import('fs/promises');
71
- try {
72
- const configContent = await fs.readFile(agentbridge.configPath, 'utf8');
73
- const config = JSON.parse(configContent);
74
- if (config.PROJECT_DIR) {
75
- console.log(` Config PROJECT_DIR: ${config.PROJECT_DIR}`);
76
- const projectType = detectInstanceType(config.PROJECT_DIR);
77
- console.log(` PROJECT_DIR Type: ${projectType}`);
78
- console.log(` Should be: bmad-plugin`);
79
- }
80
- } catch (e) {
81
- console.log(` Config read error: ${e.message}`);
82
- }
83
- }
84
- } else {
85
- console.log('No agentbridge instance found');
86
- }
87
-
88
- console.log('\n=== Expected Results ===');
89
- console.log('cognitive: bmad-plugin (has _bmad)');
90
- console.log('corp: bmad-plugin (has _bmad and _agent-bridge)');
91
- console.log('agentbridge: Should point to cognitive project (bmad-plugin)');
92
- console.log('\n=== Test Complete ===');
93
- }
94
-
95
- main().catch(console.error);
@@ -1,85 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Test script to check instance type detection
5
- */
6
-
7
- import { detectInstanceType } from '../src/core/instance/validator.js';
8
- import { discoverInstances } from '../src/core/instance/manager.js';
9
- import { existsSync } from 'fs';
10
- import path from 'path';
11
-
12
- async function main() {
13
- console.log('=== Instance Type Detection Test ===\n');
14
-
15
- // Test 1: Check agent-bridge-main
16
- const bridgePath = '/Users/cyrus/Documents/project/agent-bridge-main';
17
- console.log(`Test 1: agent-bridge-main`);
18
- console.log(`Path: ${bridgePath}`);
19
- console.log(`Has _bmad: ${existsSync(path.join(bridgePath, '_bmad'))}`);
20
- console.log(`Has _agent-bridge: ${existsSync(path.join(bridgePath, '_agent-bridge'))}`);
21
- console.log(`Has config.json: ${existsSync(path.join(bridgePath, 'config.json'))}`);
22
- const bridgeType = detectInstanceType(bridgePath);
23
- console.log(`Detected type: ${bridgeType}`);
24
- console.log(`Expected: bmad-plugin (has _agent-bridge directory)\n`);
25
-
26
- // Test 2: Discover running instances
27
- console.log('Test 2: Discover PM2 instances');
28
- try {
29
- const discovered = await discoverInstances();
30
- console.log(`Found ${discovered.length} unregistered instances:\n`);
31
-
32
- for (const inst of discovered) {
33
- console.log(`Instance: ${inst.name}`);
34
- console.log(` Bot Name: ${inst.botName}`);
35
- console.log(` Project Path: ${inst.projectPath}`);
36
- console.log(` Config Path: ${inst.configPath}`);
37
- console.log(` Instance Type: ${inst.instanceType}`);
38
- console.log(` Status: ${inst.status}`);
39
-
40
- // Verify detection
41
- if (inst.projectPath && existsSync(inst.projectPath)) {
42
- const detectedType = detectInstanceType(inst.projectPath);
43
- console.log(` Verified Type: ${detectedType}`);
44
-
45
- // Check directory structure
46
- const hasBmad = existsSync(path.join(inst.projectPath, '_bmad'));
47
- const hasAgentBridge = existsSync(path.join(inst.projectPath, '_agent-bridge'));
48
- const hasConfig = existsSync(path.join(inst.projectPath, 'config.json'));
49
- console.log(` Directory check:`);
50
- console.log(` - _bmad: ${hasBmad}`);
51
- console.log(` - _agent-bridge: ${hasAgentBridge}`);
52
- console.log(` - config.json: ${hasConfig}`);
53
- }
54
- console.log('');
55
- }
56
- } catch (error) {
57
- console.error(`Error discovering instances: ${error.message}`);
58
- }
59
-
60
- // Test 3: Check known instances
61
- console.log('Test 3: Check known project directories');
62
-
63
- const knownProjects = [
64
- { name: 'cognitive', path: '/Users/cyrus/Documents/project/cognitive' },
65
- { name: 'corp', path: '/Users/cyrus/Documents/project/corp' },
66
- ];
67
-
68
- for (const proj of knownProjects) {
69
- if (existsSync(proj.path)) {
70
- console.log(`\n${proj.name}:`);
71
- console.log(` Path: ${proj.path}`);
72
- const type = detectInstanceType(proj.path);
73
- console.log(` Type: ${type}`);
74
- console.log(` _bmad: ${existsSync(path.join(proj.path, '_bmad'))}`);
75
- console.log(` _agent-bridge: ${existsSync(path.join(proj.path, '_agent-bridge'))}`);
76
- console.log(` config.json: ${existsSync(path.join(proj.path, 'config.json'))}`);
77
- } else {
78
- console.log(`\n${proj.name}: Path does not exist`);
79
- }
80
- }
81
-
82
- console.log('\n=== Test Complete ===');
83
- }
84
-
85
- main().catch(console.error);
@@ -1,109 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Platform Compatibility Test Script
4
- *
5
- * Tests the platform abstraction layer to ensure cross-platform compatibility.
6
- * Run this script on different platforms to verify functionality.
7
- */
8
-
9
- import {
10
- Platform,
11
- currentPlatform,
12
- isWindows,
13
- isWSLAvailable,
14
- getShell,
15
- paths,
16
- docker,
17
- pm2
18
- } from '../src/core/platform/index.js';
19
-
20
- console.log('\n=== Platform Compatibility Test ===\n');
21
-
22
- // Test 1: Platform Detection
23
- console.log('1. Platform Detection');
24
- console.log(` Current Platform: ${currentPlatform}`);
25
- console.log(` Is Windows: ${isWindows()}`);
26
- console.log(` Platform Enum: ${Platform.WINDOWS}, ${Platform.LINUX}, ${Platform.MACOS}\n`);
27
-
28
- // Test 2: Shell Detection
29
- console.log('2. Shell Detection');
30
- const shell = getShell();
31
- console.log(` Shell Command: ${shell.command}`);
32
- console.log(` Shell Type: ${shell.type}\n`);
33
-
34
- // Test 3: Path Utilities
35
- console.log('3. Path Utilities');
36
- console.log(` Home Dir: ${paths.getHomeDir()}`);
37
- console.log(` AgentWindow Home: ${paths.getAgentWindowHome()}`);
38
- console.log(` Bots Dir: ${paths.getBotsDir()}`);
39
- console.log(` Claude Config: ${paths.getClaudeConfigDir()}`);
40
- console.log(` Expanded ~: ${paths.expandTilde('~/test')}`);
41
- console.log(` Config Dir: ${paths.getConfigDir()}`);
42
- console.log(` Data Dir: ${paths.getDataDir()}\n`);
43
-
44
- // Test 4: WSL Detection (Windows only)
45
- if (isWindows()) {
46
- console.log('4. WSL Detection (Windows)');
47
- isWSLAvailable().then(available => {
48
- console.log(` WSL Available: ${available}\n`);
49
- }).catch(() => {
50
- console.log(' WSL Detection failed\n');
51
- });
52
- } else {
53
- console.log('4. WSL Detection: Skipped (not Windows)\n');
54
- }
55
-
56
- // Test 5: PM2 Availability
57
- console.log('5. PM2 Availability');
58
- pm2.isAvailable().then(available => {
59
- console.log(` PM2 Available: ${available}`);
60
- if (available) {
61
- pm2.version().then(version => {
62
- console.log(` PM2 Version: ${version}`);
63
- runDockerTests();
64
- }).catch(() => {
65
- console.log(' PM2 Version: unknown');
66
- runDockerTests();
67
- });
68
- } else {
69
- console.log(' PM2 not installed - skipping PM2 tests');
70
- runDockerTests();
71
- }
72
- }).catch(() => {
73
- console.log(' PM2 detection failed');
74
- runDockerTests();
75
- });
76
-
77
- // Test 6: Docker Availability
78
- function runDockerTests() {
79
- console.log('\n6. Docker Availability');
80
- docker.isAvailable().then(available => {
81
- console.log(` Docker Available: ${available}`);
82
- if (available) {
83
- docker.version().then(version => {
84
- console.log(` Docker Version: ${version.Server?.Version || 'unknown'}`);
85
- finishTests();
86
- }).catch(() => {
87
- console.log(' Docker Version: unknown');
88
- finishTests();
89
- });
90
- } else {
91
- console.log(' Docker not installed - skipping Docker tests');
92
- finishTests();
93
- }
94
- }).catch(() => {
95
- console.log(' Docker detection failed');
96
- finishTests();
97
- });
98
- }
99
-
100
- function finishTests() {
101
- console.log('\n=== Test Complete ===\n');
102
- console.log('Platform abstraction layer is working correctly.');
103
- console.log('Next steps:');
104
- console.log(' - Test actual PM2 process management');
105
- console.log(' - Test Docker container operations');
106
- console.log(' - Test on Windows with WSL2');
107
- console.log(' - Test on Windows with Docker Desktop');
108
- console.log('');
109
- }
@@ -1,54 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Test script to check PM2 process data
5
- */
6
-
7
- import { getProcesses } from '../src/core/instance/pm2-bridge.js';
8
- import { existsSync } from 'fs';
9
- import path from 'path';
10
-
11
- async function main() {
12
- console.log('=== PM2 Process Data Test ===\n');
13
-
14
- try {
15
- const processes = await getProcesses();
16
- console.log(`Found ${processes.length} PM2 processes\n`);
17
-
18
- for (const proc of processes) {
19
- console.log(`Process: ${proc.name}`);
20
- console.log(` PID: ${proc.pid}`);
21
- console.log(` Status: ${proc.status}`);
22
- console.log(` CWD: ${proc.cwd}`);
23
- console.log(` Script: ${proc.script}`);
24
- console.log(` Config Path: ${proc.configPath}`);
25
- console.log(` Environment vars: ${Object.keys(proc.env || {}).length}`);
26
-
27
- // Check if CONFIG_PATH is in env
28
- if (proc.env && proc.env.CONFIG_PATH) {
29
- console.log(` CONFIG_PATH (env): ${proc.env.CONFIG_PATH}`);
30
- console.log(` CONFIG_PATH exists: ${existsSync(proc.env.CONFIG_PATH)}`);
31
- }
32
-
33
- // Try to find config file
34
- if (proc.cwd) {
35
- const configInCwd = path.join(proc.cwd, 'config.json');
36
- console.log(` config.json in cwd: ${existsSync(configInCwd)} (${configInCwd})`);
37
-
38
- const configDir = path.join(proc.cwd, 'config', 'config.json');
39
- console.log(` config/config.json: ${existsSync(configDir)} (${configDir})`);
40
- }
41
-
42
- // Check bots directory
43
- const botConfig = `/Users/cyrus/bots/${proc.name.replace('bot-', '')}/config.json`;
44
- console.log(` Bot config: ${existsSync(botConfig)} (${botConfig})`);
45
-
46
- console.log('');
47
- }
48
- } catch (error) {
49
- console.error(`Error: ${error.message}`);
50
- console.error(error.stack);
51
- }
52
- }
53
-
54
- main().catch(console.error);