momo-ai 1.0.5 → 1.0.7
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/.momo/advanced/refer.json +50 -0
- package/README.md +83 -35
- package/package.json +3 -2
- package/src/_agent/trae/momo-datamodel.json +5 -0
- package/src/_agent/trae/momo-module-req.json +5 -0
- package/src/_agent/trae/momo-system-req.json +5 -0
- package/src/_agent/trae/momo-task.json +5 -0
- package/src/_template/LAIN/AGENTS.md +93 -86
- package/src/_template/MCP/.gitkeep +0 -0
- package/src/_template/PROMPT/plan.md.ejs +1 -1
- package/src/_template/PROMPT/trae/momo-datamodel.ejs +8 -0
- package/src/_template/PROMPT/trae/momo-module-req.ejs +11 -0
- package/src/_template/PROMPT/trae/momo-system-req.ejs +9 -0
- package/src/_template/PROMPT/trae/momo-task.ejs +11 -0
- package/src/commander/agent.json +12 -0
- package/src/commander/agentcfg.json +5 -0
- package/src/commander/console.json +7 -0
- package/src/commander/lain.json +7 -0
- package/src/commander/project.json +12 -0
- package/src/executor/executeAgent.js +214 -0
- package/src/executor/executeAgentCfg.js +195 -0
- package/src/executor/executeConsole.js +115 -0
- package/src/executor/executeInit.js +97 -2
- package/src/executor/executeOpen.js +22 -21
- package/src/executor/executeProject.js +296 -0
- package/src/executor/index.js +10 -1
- package/src/lain.js +142 -0
- package/src/terminal/commandHelp.js +16 -0
- package/src/terminal/commandLlm.js +195 -0
- package/src/terminal/commandQuit.js +12 -0
- package/src/terminal/commandTest.js +21 -0
- package/src/terminal/index.js +25 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LLM command implementation
|
|
3
|
+
*
|
|
4
|
+
* 查看所有大模型配置信息,包括名称、token、主页等
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
const path = require('path');
|
|
9
|
+
|
|
10
|
+
const llmCommand = (context) => {
|
|
11
|
+
console.log('');
|
|
12
|
+
console.log('大模型配置信息:'.bold.brightCyan);
|
|
13
|
+
|
|
14
|
+
// 定义所有支持的 LLM 及其主页信息
|
|
15
|
+
const llmInfo = {
|
|
16
|
+
'openspec': { name: 'OpenSpec', homepage: 'https://openspec.dev/', isLLM: false },
|
|
17
|
+
'spec-kit': { name: 'SpecKit', homepage: 'https://github.com/github/spec-kit', isLLM: false },
|
|
18
|
+
'kiro': { name: 'Kiro', homepage: 'https://kiro.dev/', isLLM: false },
|
|
19
|
+
'trea': { name: 'Trea', homepage: 'https://www.trae.ai/', isLLM: false },
|
|
20
|
+
'cursor': { name: 'Cursor', homepage: 'https://cursor.com/', isLLM: false },
|
|
21
|
+
'lingma': { name: 'Lingma', homepage: 'https://lingma.aliyun.com/', isLLM: false },
|
|
22
|
+
'qoder': { name: 'Qoder', homepage: 'https://qoder.com/', isLLM: false },
|
|
23
|
+
'windsurf': { name: 'WindSurf', homepage: 'https://windsurf.com/', isLLM: false },
|
|
24
|
+
'github': { name: 'GitHub Copilot', homepage: 'https://github.com/features/copilot', isLLM: false },
|
|
25
|
+
'claude-code': { name: 'Claude Code', homepage: 'https://claude.ai/code', isLLM: true },
|
|
26
|
+
'chatgpt': { name: 'ChatGPT', homepage: 'https://chatgpt.com/', isLLM: true },
|
|
27
|
+
'auggie': { name: 'Auggie', homepage: 'https://auggie.dev', isLLM: false },
|
|
28
|
+
'cline': { name: 'Cline', homepage: 'https://cline.bot/', isLLM: false },
|
|
29
|
+
'roocode': { name: 'RooCode', homepage: 'https://roocode.com', isLLM: false },
|
|
30
|
+
'codebuddy': { name: 'CodeBuddy', homepage: 'https://codebuddy.ai', isLLM: false },
|
|
31
|
+
'crush': { name: 'Crush', homepage: 'https://github.com/charmbracelet/crush', isLLM: false },
|
|
32
|
+
'factory': { name: 'Factory Droid', homepage: 'https://factory.ai/', isLLM: false },
|
|
33
|
+
'gemini': { name: 'Gemini', homepage: 'https://gemini.google.com', isLLM: true },
|
|
34
|
+
'opencode': { name: 'OpenCode', homepage: 'https://opencode.ai', isLLM: false },
|
|
35
|
+
'kilo': { name: 'Kilo Code', homepage: 'https://kilo.ai/', isLLM: false },
|
|
36
|
+
'codex': { name: 'Codex', homepage: 'https://chatgpt.com/codex', isLLM: false },
|
|
37
|
+
'qwen': { name: 'Qwen Code', homepage: 'https://chat.qwen.ai/', isLLM: true },
|
|
38
|
+
'deepseek': { name: 'Deep Seek', homepage: 'https://www.deepseek.com/', isLLM: true },
|
|
39
|
+
'silicon': { name: 'Silicon Flow', homepage: 'https://www.siliconflow.com/', isLLM: false },
|
|
40
|
+
'kimi': { name: 'Kimi', homepage: 'https://www.kimi.com/', isLLM: false },
|
|
41
|
+
'grok': { name: 'Grok', homepage: 'https://grok.com/', isLLM: true }
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// 获取当前项目中的 integration 目录
|
|
45
|
+
const integrationBaseDir = path.resolve(process.cwd(), 'integration');
|
|
46
|
+
|
|
47
|
+
// 确保 integration 目录存在
|
|
48
|
+
if (!fs.existsSync(integrationBaseDir)) {
|
|
49
|
+
try {
|
|
50
|
+
fs.mkdirSync(integrationBaseDir, { recursive: true });
|
|
51
|
+
} catch (e) {
|
|
52
|
+
// 创建目录出错
|
|
53
|
+
console.log(' 无法创建 integration 目录'.brightRed);
|
|
54
|
+
console.log('');
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// 获取所有 integration 目录
|
|
60
|
+
let integrationDirs = [];
|
|
61
|
+
try {
|
|
62
|
+
if (fs.existsSync(integrationBaseDir)) {
|
|
63
|
+
integrationDirs = fs.readdirSync(integrationBaseDir)
|
|
64
|
+
.filter(dir => fs.statSync(path.join(integrationBaseDir, dir)).isDirectory());
|
|
65
|
+
}
|
|
66
|
+
} catch (e) {
|
|
67
|
+
// 读取目录出错
|
|
68
|
+
console.log(' 无法读取 integration 目录'.brightRed);
|
|
69
|
+
console.log('');
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// 构建所有支持模型的数据
|
|
74
|
+
const allModels = Object.keys(llmInfo).map(key => {
|
|
75
|
+
const info = llmInfo[key];
|
|
76
|
+
return {
|
|
77
|
+
dir: key,
|
|
78
|
+
name: info.name,
|
|
79
|
+
homepage: info.homepage,
|
|
80
|
+
isLLM: info.isLLM
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
// 获取每个目录的详细信息并排序
|
|
85
|
+
const llmData = allModels.map(model => {
|
|
86
|
+
let name = model.name;
|
|
87
|
+
let homepage = model.homepage;
|
|
88
|
+
let configured = ''; // 默认为空
|
|
89
|
+
let isLLM = model.isLLM;
|
|
90
|
+
|
|
91
|
+
// 尝试读取对应 integration 目录中的 config.json
|
|
92
|
+
try {
|
|
93
|
+
const configPath = path.resolve(integrationBaseDir, model.dir, 'config.json');
|
|
94
|
+
if (fs.existsSync(configPath)) {
|
|
95
|
+
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
96
|
+
const token = config.token || '-';
|
|
97
|
+
|
|
98
|
+
// 处理 token 显示,避免显示完整 token
|
|
99
|
+
if (token !== '-' && token.length > 0) {
|
|
100
|
+
configured = '✅'; // 有token则标记为已配置
|
|
101
|
+
} else if (isLLM) {
|
|
102
|
+
configured = '❌'; // 是LLM但没有token
|
|
103
|
+
}
|
|
104
|
+
} else if (isLLM) {
|
|
105
|
+
configured = '❌'; // 是LLM但没有配置文件
|
|
106
|
+
|
|
107
|
+
// 自动创建目录和基本配置文件
|
|
108
|
+
const modelDir = path.resolve(integrationBaseDir, model.dir);
|
|
109
|
+
if (!fs.existsSync(modelDir)) {
|
|
110
|
+
fs.mkdirSync(modelDir, { recursive: true });
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// 创建默认配置文件
|
|
114
|
+
const defaultConfig = {
|
|
115
|
+
llm: model.dir,
|
|
116
|
+
token: "",
|
|
117
|
+
baseUrl: "",
|
|
118
|
+
model: "",
|
|
119
|
+
temperature: 0.7,
|
|
120
|
+
maxTokens: 2048,
|
|
121
|
+
topP: 1,
|
|
122
|
+
frequencyPenalty: 0,
|
|
123
|
+
presencePenalty: 0
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
const configPath = path.resolve(modelDir, 'config.json');
|
|
127
|
+
if (!fs.existsSync(configPath)) {
|
|
128
|
+
fs.writeFileSync(configPath, JSON.stringify(defaultConfig, null, 2));
|
|
129
|
+
}
|
|
130
|
+
} else if (!isLLM) {
|
|
131
|
+
// 对于非LLM,如果没有配置文件也创建一个
|
|
132
|
+
const modelDir = path.resolve(integrationBaseDir, model.dir);
|
|
133
|
+
if (!fs.existsSync(modelDir)) {
|
|
134
|
+
fs.mkdirSync(modelDir, { recursive: true });
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// 创建默认配置文件
|
|
138
|
+
const defaultConfig = {
|
|
139
|
+
llm: model.dir,
|
|
140
|
+
token: "",
|
|
141
|
+
baseUrl: "",
|
|
142
|
+
model: "",
|
|
143
|
+
temperature: 0.7,
|
|
144
|
+
maxTokens: 2048,
|
|
145
|
+
topP: 1,
|
|
146
|
+
frequencyPenalty: 0,
|
|
147
|
+
presencePenalty: 0
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
const configPath = path.resolve(modelDir, 'config.json');
|
|
151
|
+
if (!fs.existsSync(configPath)) {
|
|
152
|
+
fs.writeFileSync(configPath, JSON.stringify(defaultConfig, null, 2));
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
} catch (e) {
|
|
156
|
+
// 读取配置文件出错
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// 如果是LLM,在名称后添加(LLM)和emoji
|
|
160
|
+
if (isLLM) {
|
|
161
|
+
name = name + ' (LLM) 🌟';
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return {
|
|
165
|
+
dir: model.dir,
|
|
166
|
+
name: name,
|
|
167
|
+
homepage: homepage,
|
|
168
|
+
configured: configured,
|
|
169
|
+
isLLM: isLLM
|
|
170
|
+
};
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
// 按类型排序,LLM优先,然后按名称排序
|
|
174
|
+
llmData.sort((a, b) => {
|
|
175
|
+
// 首先按类型排序(LLM在前)
|
|
176
|
+
if (a.isLLM && !b.isLLM) return -1;
|
|
177
|
+
if (!a.isLLM && b.isLLM) return 1;
|
|
178
|
+
// 然后按名称排序
|
|
179
|
+
return a.name.localeCompare(b.name);
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
// 表格头部,调整列宽
|
|
183
|
+
console.log(' ' + '名称'.padEnd(25) + '标识符'.padEnd(15) + '主页'.padEnd(45) + '状态');
|
|
184
|
+
console.log(' ' + '-'.repeat(85));
|
|
185
|
+
|
|
186
|
+
// 显示每个 LLM 的信息
|
|
187
|
+
llmData.forEach(item => {
|
|
188
|
+
// 输出格式:名称 标识符 主页 状态
|
|
189
|
+
console.log(' ' + item.name.padEnd(25) + item.dir.padEnd(15) + item.homepage.padEnd(45) + item.configured);
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
console.log('');
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
module.exports = llmCommand;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test command implementation
|
|
3
|
+
*
|
|
4
|
+
* 这是一个示例测试命令,用于演示如何添加新命令
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const testCommand = (context) => {
|
|
8
|
+
console.log('');
|
|
9
|
+
console.log('测试命令执行结果:'.bold.brightCyan);
|
|
10
|
+
console.log(' 这是一个测试命令的输出'.white);
|
|
11
|
+
console.log(' 当前时间: ' + new Date().toLocaleString().yellow);
|
|
12
|
+
console.log(' 您可以在此处添加任何测试逻辑'.gray);
|
|
13
|
+
console.log('');
|
|
14
|
+
|
|
15
|
+
// 示例:访问上下文中的信息
|
|
16
|
+
const commandCount = Object.keys(context.commands).length;
|
|
17
|
+
console.log(` 当前系统中可用命令数量: ${commandCount.toString().green}`);
|
|
18
|
+
console.log('');
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
module.exports = testCommand;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Terminal Commands Index
|
|
3
|
+
*
|
|
4
|
+
* 所有终端命令的入口文件
|
|
5
|
+
* 除 help 和 quit 命令外,所有新追加的命令都应在此处导出
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// 基础命令
|
|
9
|
+
const helpCommand = require('./commandHelp');
|
|
10
|
+
const quitCommand = require('./commandQuit');
|
|
11
|
+
|
|
12
|
+
// 在此处添加新命令的导入
|
|
13
|
+
const testCommand = require('./commandTest');
|
|
14
|
+
const llmCommand = require('./commandLlm');
|
|
15
|
+
|
|
16
|
+
// 导出所有命令
|
|
17
|
+
module.exports = {
|
|
18
|
+
// 基础命令
|
|
19
|
+
help: helpCommand,
|
|
20
|
+
quit: quitCommand,
|
|
21
|
+
|
|
22
|
+
// 在此处添加新命令的导出
|
|
23
|
+
test: testCommand,
|
|
24
|
+
llm: llmCommand
|
|
25
|
+
};
|