momo-ai 1.0.21 → 1.0.24
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/.claude/skills/r2mo-rad-lain/SKILL.md +63 -374
- package/.trae/skills/algorithmic-art/LICENSE.txt +202 -0
- package/.trae/skills/algorithmic-art/SKILL.md +405 -0
- package/.trae/skills/algorithmic-art/templates/generator_template.js +223 -0
- package/.trae/skills/algorithmic-art/templates/viewer.html +599 -0
- package/.trae/skills/doc-coauthoring/SKILL.md +375 -0
- package/.trae/skills/frontend-design/LICENSE.txt +177 -0
- package/.trae/skills/frontend-design/SKILL.md +42 -0
- package/.trae/skills/r2mo-rad-lain/SKILL.md +101 -0
- package/README.md +9 -32
- package/docs/images/r2mo-lain.png +0 -0
- package/package.json +12 -12
- package/publish.sh +26 -0
- package/skills/r2mo-rad-domain/SKILL.md +70 -0
- package/src/_skill/repositories.json +9 -3
- package/src/_template/LAIN/.obsidian/app.json +1 -0
- package/src/_template/LAIN/.obsidian/appearance.json +10 -0
- package/src/_template/LAIN/.obsidian/community-plugins.json +7 -0
- package/src/_template/LAIN/.obsidian/core-plugins.json +33 -0
- package/src/_template/LAIN/.obsidian/plugins/dataview/main.js +20876 -0
- package/src/_template/LAIN/.obsidian/plugins/dataview/manifest.json +11 -0
- package/src/_template/LAIN/.obsidian/plugins/dataview/styles.css +141 -0
- package/src/_template/LAIN/.obsidian/plugins/obsidian-excalidraw-plugin/data.json +815 -0
- package/src/_template/LAIN/.obsidian/plugins/obsidian-excalidraw-plugin/main.js +10 -0
- package/src/_template/LAIN/.obsidian/plugins/obsidian-excalidraw-plugin/manifest.json +12 -0
- package/src/_template/LAIN/.obsidian/plugins/obsidian-excalidraw-plugin/styles.css +1 -0
- package/src/_template/LAIN/.obsidian/plugins/obsidian-kanban/main.js +153 -0
- package/src/_template/LAIN/.obsidian/plugins/obsidian-kanban/manifest.json +11 -0
- package/src/_template/LAIN/.obsidian/plugins/obsidian-kanban/styles.css +1 -0
- package/src/_template/LAIN/.obsidian/plugins/obsidian-plantuml/main.js +7732 -0
- package/src/_template/LAIN/.obsidian/plugins/obsidian-plantuml/manifest.json +10 -0
- package/src/_template/LAIN/.obsidian/plugins/obsidian-plantuml/styles.css +38 -0
- package/src/_template/LAIN/.obsidian/plugins/obsidian-tasks-plugin/main.js +504 -0
- package/src/_template/LAIN/.obsidian/plugins/obsidian-tasks-plugin/manifest.json +12 -0
- package/src/_template/LAIN/.obsidian/plugins/obsidian-tasks-plugin/styles.css +1 -0
- package/src/_template/LAIN/.obsidian/snippets/body-font.css +27 -0
- package/src/_template/LAIN/.obsidian/themes/Primary/manifest.json +9 -0
- package/src/_template/LAIN/.obsidian/themes/Primary/theme.css +3878 -0
- package/src/_template/LAIN/.obsidian/themes/Retro Windows/manifest.json +7 -0
- package/src/_template/LAIN/.obsidian/themes/Retro Windows/theme.css +582 -0
- package/src/_template/LAIN/.obsidian/themes/RetroOS 98/manifest.json +9 -0
- package/src/_template/LAIN/.obsidian/themes/RetroOS 98/theme.css +2566 -0
- package/src/_template/LAIN/.obsidian/types.json +28 -0
- package/src/_template/LAIN/.obsidian/workspace.json +184 -0
- package/src/_template/LAIN/AGENTS.md +170 -16
- package/src/_template/R2MO/domain-enhance.md +10 -0
- package/src/commander/app.json +13 -0
- package/src/commander/apply.json +13 -0
- package/src/commander/ask.json +6 -0
- package/src/commander/docs.json +13 -0
- package/src/commander/domain.json +19 -0
- package/src/commander/init.json +1 -1
- package/src/commander/mmr0.json +6 -0
- package/src/commander/mmr2.json +6 -0
- package/src/executor/executeApp.js +133 -0
- package/src/executor/{executeSkills.js → executeApply.js} +166 -302
- package/src/executor/executeAsk.js +274 -0
- package/src/executor/executeDocs.js +498 -0
- package/src/executor/executeDomain.js +293 -0
- package/src/executor/executeInit.js +159 -383
- package/src/executor/executeMcp.js +74 -1
- package/src/executor/executeMmr0.js +488 -0
- package/src/executor/executeMmr2.js +880 -0
- package/src/executor/index.js +15 -3
- package/src/python/r2mo_proto.py +418 -0
- package/src/python/r2mo_proto_database.py +369 -0
- package/src/python/r2mo_proto_domain.py +458 -0
- package/src/utils/momo-menu.js +43 -13
- package/.claude/skills/r2mo-rad-lain/PROMPT.md +0 -281
- package/.claude/skills/r2mo-rad-lain/README.md +0 -192
- package/.claude/skills/r2mo-rad-lain/examples/argument-parsing.js +0 -154
- package/.claude/skills/r2mo-rad-lain/examples/file-operations.js +0 -182
- package/.claude/skills/r2mo-rad-lain/file-utils-api.md +0 -281
- package/.claude/skills/r2mo-rad-lain/menu-api.md +0 -187
- package/.claude/skills/r2mo-rad-lain/scripts/file-utils.js +0 -223
- package/.claude/skills/r2mo-rad-lain/scripts/menu.js +0 -289
- package/.claude/skills/r2mo-rad-lain/scripts/yaml-parser.js +0 -209
- package/.claude/skills/r2mo-rad-lain/templates/command.json.template +0 -13
- package/.claude/skills/r2mo-rad-lain/templates/executor.js.template +0 -32
- package/.claude/skills/r2mo-rad-lain/templates/interactive-menu.js.template +0 -221
- package/src/_template/LAIN/.momo/advanced/actor.md +0 -42
- package/src/_template/LAIN/.momo/advanced/refer.json +0 -46
- package/src/_template/LAIN/.momo/scripts/submodule-clean.sh +0 -56
- package/src/_template/LAIN/changes/proposal.md +0 -39
- package/src/_template/LAIN/changes/tasks/task-detail.md +0 -45
- package/src/_template/LAIN/changes/tasks.md +0 -49
- package/src/_template/LAIN/execute/admin-n-f-dashboard.md +0 -53
- package/src/_template/LAIN/execute/admin-n-f-form.md +0 -51
- package/src/_template/LAIN/execute/admin-n-f-home.md +0 -49
- package/src/_template/LAIN/execute/admin-n-f-list.md +0 -52
- package/src/_template/LAIN/execute/admin-n-f-login.md +0 -56
- package/src/_template/LAIN/specification/project-model.md +0 -13
- package/src/_template/LAIN/specification/project.md +0 -73
- package/src/_template/LAIN/specification/requirement.md +0 -25
- package/src/commander/skills.json +0 -20
|
@@ -1,412 +1,101 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: r2mo-rad-lain
|
|
3
|
-
description:
|
|
4
|
-
version:
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
- r2mo
|
|
8
|
-
- rad
|
|
9
|
-
- lain
|
|
10
|
-
- nodejs
|
|
11
|
-
- cli
|
|
12
|
-
- momo
|
|
3
|
+
description: R2MO RAD CLI Dev Skill (Lain Native)
|
|
4
|
+
version: 3.0.0
|
|
5
|
+
tags: [r2mo, rad, lain, nodejs, cli, momo]
|
|
6
|
+
repository: https://gitee.com/silentbalanceyh/r2mo-lain.git
|
|
13
7
|
---
|
|
14
8
|
|
|
15
|
-
# R2MO RAD
|
|
9
|
+
# Role: R2MO RAD Expert (Lain Project)
|
|
16
10
|
|
|
17
|
-
##
|
|
11
|
+
## 🚨 Critical Rules
|
|
12
|
+
1. **Stack**: CommonJS (`require`). **NO** ESM.
|
|
13
|
+
2. **Core Libs**:
|
|
14
|
+
- Use `const Ec = require('../epic');` for logging/flow.
|
|
15
|
+
- Use `const Utils = require('../utils/momo-*');` for helpers.
|
|
16
|
+
3. **Interactive**: MUST use `require('../utils/momo-menu')`. **NO** raw readline.
|
|
17
|
+
4. **Style**: Use `Ec` for all logging.
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
### 必须遵守
|
|
24
|
-
|
|
25
|
-
| 项目 | 要求 | 说明 |
|
|
26
|
-
|------|------|------|
|
|
27
|
-
| **模块规范** | CommonJS | 使用 `require`/`module.exports`,禁止使用 ES Module |
|
|
28
|
-
| **Node 版本** | >= 22.x | 项目要求的最低版本 |
|
|
29
|
-
| **参数解析** | 原生/Epic | 使用 `Ec.parseArgument` 或 `process.argv` |
|
|
30
|
-
| **日志输出** | Epic 工具 | 使用 `Ec.info`/`Ec.warn`/`Ec.error`/`Ec.waiting` |
|
|
31
|
-
| **颜色库** | colors | 已全局配置,使用 `.green`/`.blue` 等 |
|
|
32
|
-
| **用户输入** | Ec.ask | 使用项目统一的 readline 封装 |
|
|
33
|
-
|
|
34
|
-
### 禁止使用
|
|
35
|
-
|
|
36
|
-
| 项目 | 原因 |
|
|
37
|
-
|------|------|
|
|
38
|
-
| Commander.js | 过重,与项目风格不符 |
|
|
39
|
-
| Yargs | 过重,与项目风格不符 |
|
|
40
|
-
| Inquirer.js | 与项目 readline 冲突 |
|
|
41
|
-
| ES Module (import/export) | 项目使用 CommonJS |
|
|
42
|
-
| TypeScript | 项目使用纯 JavaScript |
|
|
43
|
-
|
|
44
|
-
### 推荐使用
|
|
45
|
-
|
|
46
|
-
| 项目 | 场景 |
|
|
47
|
-
|------|------|
|
|
48
|
-
| fs/fs.promises | 文件操作 |
|
|
49
|
-
| path | 路径处理 |
|
|
50
|
-
| os | 系统信息(如 homedir、tmpdir) |
|
|
51
|
-
| child_process | 外部命令执行 |
|
|
52
|
-
| readline | 交互式菜单(仅限本技能脚本) |
|
|
53
|
-
|
|
54
|
-
## 工作流决策树
|
|
55
|
-
|
|
56
|
-
### 开发新命令
|
|
57
|
-
1. 阅读本文档 SKILL.md
|
|
58
|
-
2. 创建命令配置 `src/commander/{command}.json`
|
|
59
|
-
3. 创建执行器 `src/executor/execute{Command}.js`
|
|
60
|
-
4. 在 `src/executor/index.js` 中注册
|
|
61
|
-
|
|
62
|
-
### 需要交互式菜单
|
|
63
|
-
1. **必须阅读**: [`menu-api.md`](menu-api.md) - 完整菜单 API 文档
|
|
64
|
-
2. 使用 `scripts/menu.js` 模块
|
|
65
|
-
3. 菜单完成后再使用 `Ec.ask` 进行确认
|
|
66
|
-
|
|
67
|
-
### 需要文件操作
|
|
68
|
-
1. **必须阅读**: [`file-utils-api.md`](file-utils-api.md) - 文件工具 API 文档
|
|
69
|
-
2. 使用 `scripts/file-utils.js` 模块
|
|
70
|
-
3. 使用 `scripts/yaml-parser.js` 解析 YAML
|
|
71
|
-
|
|
72
|
-
## 项目架构
|
|
73
|
-
|
|
74
|
-
### 目录结构
|
|
75
|
-
```
|
|
76
|
-
src/
|
|
77
|
-
├── commander/ # 命令配置文件 (JSON)
|
|
78
|
-
│ └── {command}.json
|
|
79
|
-
├── executor/ # 命令执行器
|
|
80
|
-
│ ├── index.js # 执行器导出索引
|
|
81
|
-
│ └── execute{Command}.js
|
|
82
|
-
├── epic/ # 核心工具库
|
|
83
|
-
│ ├── index.js # 统一导出
|
|
84
|
-
│ ├── momo.fn.log.js # 日志输出
|
|
85
|
-
│ ├── lain.fn.parse.js # 参数解析
|
|
86
|
-
│ └── ...
|
|
87
|
-
├── _skill/ # 技能配置
|
|
88
|
-
│ └── repositories.json
|
|
89
|
-
└── momo.js # 主入口
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
## 命令配置格式
|
|
93
|
-
|
|
94
|
-
在 `src/commander/` 目录下创建 JSON 配置文件:
|
|
19
|
+
## 📂 Architecture
|
|
20
|
+
- **Config**: `src/commander/{cmd}.json`
|
|
21
|
+
- **Executor**: `src/executor/execute{Cmd}.js`
|
|
22
|
+
- **Utils**: `src/utils/` (momo-fs, momo-menu, momo-args)
|
|
95
23
|
|
|
24
|
+
## 📝 Config Schema (JSON)
|
|
96
25
|
```json
|
|
97
26
|
{
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
"command": "mycommand",
|
|
101
|
-
"options": [
|
|
102
|
-
{
|
|
103
|
-
"name": "param",
|
|
104
|
-
"alias": "p",
|
|
105
|
-
"description": "参数描述",
|
|
106
|
-
"type": "string",
|
|
107
|
-
"default": "默认值"
|
|
108
|
-
}
|
|
109
|
-
]
|
|
27
|
+
"executor": "executeName", "command": "name", "description": "desc",
|
|
28
|
+
"options": [{ "name": "arg", "alias": "a", "type": "string" }]
|
|
110
29
|
}
|
|
111
30
|
```
|
|
112
31
|
|
|
113
|
-
|
|
114
|
-
- `executor`: 对应 `src/executor/` 中的执行器函数名
|
|
115
|
-
- `description`: 命令描述,`(CV)` 前缀表示会复制内容到剪切板
|
|
116
|
-
- `command`: 命令名称
|
|
117
|
-
- `options`: 参数列表
|
|
118
|
-
- `name`: 参数全名 (--name)
|
|
119
|
-
- `alias`: 参数别名 (-n)
|
|
120
|
-
- `type`: 类型 string/number/boolean
|
|
121
|
-
- `default`: 默认值
|
|
122
|
-
- `required`: 是否必需
|
|
123
|
-
|
|
124
|
-
## 执行器开发
|
|
32
|
+
## 💻 Executor Template(Native)
|
|
125
33
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
参考 `templates/executor.js.template`:
|
|
129
|
-
|
|
130
|
-
```javascript
|
|
131
|
-
const fs = require('fs');
|
|
132
|
-
const path = require('path');
|
|
34
|
+
```js
|
|
133
35
|
const Ec = require('../epic');
|
|
134
|
-
const
|
|
36
|
+
const Args = require('../utils/momo-args');
|
|
37
|
+
const FS = require('../utils/momo-fs');
|
|
38
|
+
const { selectSingle } = require('../utils/momo-menu');
|
|
135
39
|
|
|
136
40
|
module.exports = async (options) => {
|
|
137
41
|
try {
|
|
138
|
-
//
|
|
139
|
-
const
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
// 业务逻辑
|
|
143
|
-
Ec.waiting('正在执行...');
|
|
144
|
-
|
|
145
|
-
// 成功退出
|
|
146
|
-
Ec.info('✅ 执行成功!');
|
|
147
|
-
process.exit(0);
|
|
148
|
-
} catch (error) {
|
|
149
|
-
Ec.error(`❌ 执行失败: ${error.message}`);
|
|
150
|
-
process.exit(1);
|
|
151
|
-
}
|
|
152
|
-
};
|
|
153
|
-
```
|
|
42
|
+
// 1. Parsing
|
|
43
|
+
const opts = Args.parseStandard(options);
|
|
44
|
+
const target = Args.parsePositional()[0];
|
|
154
45
|
|
|
155
|
-
|
|
46
|
+
// 2. Logic
|
|
47
|
+
Ec.waiting('Working...');
|
|
48
|
+
if (!FS.exists(target)) Ec.error('Path not found');
|
|
156
49
|
|
|
157
|
-
|
|
50
|
+
// 3. Menu Example
|
|
51
|
+
const item = await selectSingle([{name: 'Go'}], 'Title');
|
|
52
|
+
if(!item) process.exit(0);
|
|
158
53
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
```javascript
|
|
162
|
-
const Ec = require('../epic');
|
|
163
|
-
// 引用技能脚本(需要调整路径或复制到项目中)
|
|
164
|
-
const { selectMultiple } = require('../../skills/r2mo-rad-lain/scripts/menu');
|
|
165
|
-
|
|
166
|
-
module.exports = async (options) => {
|
|
167
|
-
const items = [
|
|
168
|
-
{ name: 'item-1', description: '选项一' },
|
|
169
|
-
{ name: 'item-2', description: '选项二' }
|
|
170
|
-
];
|
|
171
|
-
|
|
172
|
-
// 1. 菜单选择(raw mode)
|
|
173
|
-
const result = await selectMultiple(items, '选择菜单');
|
|
174
|
-
|
|
175
|
-
if (result.items.length === 0) {
|
|
176
|
-
Ec.waiting('未选择任何项');
|
|
54
|
+
// 4. Finish
|
|
55
|
+
Ec.info('✅ Done');
|
|
177
56
|
process.exit(0);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
// 2. 确认(普通输入模式,菜单完成后才能使用)
|
|
181
|
-
const answer = await Ec.ask('确认?(y/N): ');
|
|
182
|
-
if (answer.toLowerCase() !== 'y') {
|
|
183
|
-
Ec.waiting('已取消');
|
|
184
|
-
process.exit(0);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
// 3. 执行操作
|
|
188
|
-
// ...
|
|
57
|
+
} catch (e) { Ec.error(e.message); process.exit(1); }
|
|
189
58
|
};
|
|
190
59
|
```
|
|
191
60
|
|
|
192
|
-
##
|
|
193
|
-
|
|
194
|
-
### 日志输出
|
|
195
|
-
|
|
196
|
-
```javascript
|
|
197
|
-
Ec.info('绿色信息'); // [Momo AI] 绿色信息
|
|
198
|
-
Ec.waiting('蓝色执行'); // [Momo AI] 蓝色执行
|
|
199
|
-
Ec.warn('黄色警告'); // [Momo AI] 黄色警告
|
|
200
|
-
Ec.error('红色错误'); // [Momo ER] 红色错误
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
### 参数解析
|
|
204
|
-
|
|
205
|
-
```javascript
|
|
206
|
-
const parsed = Ec.parseArgument(options);
|
|
207
|
-
// 支持 --name 和 -n 两种形式
|
|
208
|
-
const value = parsed.name || parsed.n;
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
**注意:** `Ec.parseArgument` 要求参数成对出现。对于可选值参数(如 `-r` 可带可不带值),需要自行解析 `process.argv`。
|
|
212
|
-
|
|
213
|
-
### 用户输入
|
|
214
|
-
|
|
215
|
-
```javascript
|
|
216
|
-
const answer = await Ec.ask('请输入: ');
|
|
217
|
-
// 程序退出前关闭
|
|
218
|
-
Ec.askClose();
|
|
219
|
-
```
|
|
220
|
-
|
|
221
|
-
### 颜色扩展
|
|
222
|
-
|
|
223
|
-
```javascript
|
|
224
|
-
'文本'.green // 绿色
|
|
225
|
-
'文本'.blue // 蓝色
|
|
226
|
-
'文本'.yellow // 黄色
|
|
227
|
-
'文本'.red // 红色
|
|
228
|
-
'文本'.cyan // 青色
|
|
229
|
-
'文本'.gray // 灰色
|
|
230
|
-
'文本'.bold // 加粗
|
|
231
|
-
```
|
|
232
|
-
|
|
233
|
-
## UI 排版规范
|
|
61
|
+
## 📚 API Reference (Project Context)
|
|
234
62
|
|
|
235
|
-
###
|
|
63
|
+
### 1. File System ( `momo-fs.js` )
|
|
236
64
|
|
|
237
|
-
|
|
238
|
-
// 计算最大长度
|
|
239
|
-
const maxLen = Math.max(...items.map(i => i.name.length), 4);
|
|
65
|
+
Combines file-utils and yaml-parser.
|
|
240
66
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
67
|
+
```js
|
|
68
|
+
const FS = require('../utils/momo-fs');
|
|
69
|
+
// Methods:
|
|
70
|
+
ensureDir(path), exists(path), readJson(path), writeJson(path, data)
|
|
71
|
+
copyDir(src, dest), scanDir(dir, filterFn?), createTempDir(prefix?)
|
|
72
|
+
cleanup(path), gitClone(url, dest)
|
|
73
|
+
parseFile(path) // YAML Frontmatter
|
|
246
74
|
```
|
|
247
75
|
|
|
248
|
-
###
|
|
76
|
+
### 2. Interactive Menu ( `momo-menu.js` )
|
|
249
77
|
|
|
250
|
-
```
|
|
251
|
-
|
|
78
|
+
```js
|
|
79
|
+
const { selectMultiple, selectSingle, clearScreen } = require('../utils/momo-menu');
|
|
80
|
+
// selectMultiple returns { indices: [], items: [] }
|
|
81
|
+
// selectSingle returns Item | null
|
|
252
82
|
```
|
|
253
83
|
|
|
254
|
-
###
|
|
84
|
+
### 3. Argument Parser ( `momo-args.js` )
|
|
255
85
|
|
|
256
|
-
```
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
86
|
+
```js
|
|
87
|
+
const Args = require('../utils/momo-args');
|
|
88
|
+
// Methods:
|
|
89
|
+
parseStandard(options) // Standard KV
|
|
90
|
+
parseOptional(flag, alias)
|
|
91
|
+
parseBool(flag, alias)
|
|
92
|
+
parsePositional()
|
|
262
93
|
```
|
|
263
94
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
### readline 回显问题
|
|
267
|
-
|
|
268
|
-
**问题:** 输入显示两次
|
|
269
|
-
|
|
270
|
-
**原因:** 同时使用多个 readline 实例,或 raw mode 与普通 readline 混用
|
|
271
|
-
|
|
272
|
-
**解决:**
|
|
273
|
-
1. 使用本技能提供的 `scripts/menu.js`,它正确处理了 raw mode
|
|
274
|
-
2. 菜单选择和确认输入分离:菜单完成后才使用 `Ec.ask`
|
|
275
|
-
3. 不要在 raw mode 中调用 `Ec.ask`
|
|
276
|
-
|
|
277
|
-
### raw mode 管理
|
|
278
|
-
|
|
279
|
-
**问题:** 程序退出后终端异常
|
|
280
|
-
|
|
281
|
-
**原因:** 未正确退出 raw mode
|
|
282
|
-
|
|
283
|
-
**解决:**
|
|
284
|
-
```javascript
|
|
285
|
-
// 所有退出路径都要恢复
|
|
286
|
-
process.stdin.setRawMode(false);
|
|
287
|
-
process.stdin.removeListener('keypress', onKeypress);
|
|
288
|
-
```
|
|
289
|
-
|
|
290
|
-
### 异步流程问题
|
|
291
|
-
|
|
292
|
-
**问题:** setTimeout 中的 async 函数未被等待
|
|
293
|
-
|
|
294
|
-
**原因:** Promise 未正确链接
|
|
295
|
-
|
|
296
|
-
**解决:** 使用独立的 async 函数,而不是在 Promise 回调中嵌套 async
|
|
297
|
-
|
|
298
|
-
```javascript
|
|
299
|
-
// 错误
|
|
300
|
-
setTimeout(async () => {
|
|
301
|
-
const answer = await Ec.ask('?');
|
|
302
|
-
resolve(answer); // resolve 可能在 await 之前执行
|
|
303
|
-
}, 100);
|
|
304
|
-
|
|
305
|
-
// 正确:分离成两个函数
|
|
306
|
-
const menuResult = await selectMenu(items); // 菜单
|
|
307
|
-
const answer = await Ec.ask('确认?'); // 确认
|
|
308
|
-
```
|
|
309
|
-
|
|
310
|
-
### 参数解析限制
|
|
311
|
-
|
|
312
|
-
**问题:** `Ec.parseArgument` 不支持可选值参数
|
|
313
|
-
|
|
314
|
-
**解决:** 自行解析 `process.argv`
|
|
315
|
-
|
|
316
|
-
```javascript
|
|
317
|
-
const parseOptionalArg = (flagName, aliasName) => {
|
|
318
|
-
const args = process.argv.slice(3);
|
|
319
|
-
let hasFlag = false;
|
|
320
|
-
let value = null;
|
|
321
|
-
|
|
322
|
-
for (let i = 0; i < args.length; i++) {
|
|
323
|
-
if (args[i] === `-${aliasName}` || args[i] === `--${flagName}`) {
|
|
324
|
-
hasFlag = true;
|
|
325
|
-
const next = args[i + 1];
|
|
326
|
-
if (next && !next.startsWith('-')) {
|
|
327
|
-
value = next;
|
|
328
|
-
}
|
|
329
|
-
break;
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
return { hasFlag, value };
|
|
334
|
-
};
|
|
335
|
-
```
|
|
336
|
-
|
|
337
|
-
### 资源清理
|
|
338
|
-
|
|
339
|
-
**问题:** 临时文件未清理
|
|
340
|
-
|
|
341
|
-
**解决:** 使用 try/finally
|
|
342
|
-
|
|
343
|
-
```javascript
|
|
344
|
-
let tempDir = null;
|
|
345
|
-
try {
|
|
346
|
-
tempDir = createTempDir('task');
|
|
347
|
-
// 操作...
|
|
348
|
-
} finally {
|
|
349
|
-
if (tempDir) {
|
|
350
|
-
await cleanup(tempDir);
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
```
|
|
354
|
-
|
|
355
|
-
## 脚本引用
|
|
356
|
-
|
|
357
|
-
本技能提供以下可复用的脚本模块:
|
|
358
|
-
|
|
359
|
-
| 脚本 | 说明 | 文档 |
|
|
360
|
-
|------|------|------|
|
|
361
|
-
| `scripts/menu.js` | 交互式菜单 | [menu-api.md](menu-api.md) |
|
|
362
|
-
| `scripts/file-utils.js` | 文件操作工具 | [file-utils-api.md](file-utils-api.md) |
|
|
363
|
-
| `scripts/yaml-parser.js` | YAML 解析器 | [file-utils-api.md](file-utils-api.md) |
|
|
364
|
-
|
|
365
|
-
**使用方式:**
|
|
366
|
-
|
|
367
|
-
1. **复制到项目中使用**(推荐)
|
|
368
|
-
```bash
|
|
369
|
-
cp -r skills/r2mo-rad-lain/scripts src/_scripts
|
|
370
|
-
```
|
|
371
|
-
|
|
372
|
-
2. **直接引用**(开发阶段)
|
|
373
|
-
```javascript
|
|
374
|
-
const { selectMultiple } = require('../../skills/r2mo-rad-lain/scripts/menu');
|
|
375
|
-
```
|
|
376
|
-
|
|
377
|
-
## 注册执行器
|
|
378
|
-
|
|
379
|
-
在 `src/executor/index.js` 中添加:
|
|
380
|
-
|
|
381
|
-
```javascript
|
|
382
|
-
const executeMyCommand = require('./executeMyCommand');
|
|
383
|
-
|
|
384
|
-
const exported = {
|
|
385
|
-
// ... 其他执行器
|
|
386
|
-
executeMyCommand
|
|
387
|
-
};
|
|
388
|
-
module.exports = exported;
|
|
389
|
-
```
|
|
390
|
-
|
|
391
|
-
## 测试命令
|
|
392
|
-
|
|
393
|
-
```bash
|
|
394
|
-
# 运行命令
|
|
395
|
-
node src/momo.js mycommand
|
|
396
|
-
|
|
397
|
-
# 带参数
|
|
398
|
-
node src/momo.js mycommand -p value
|
|
399
|
-
|
|
400
|
-
# 查看帮助
|
|
401
|
-
node src/momo.js help -c mycommand
|
|
402
|
-
```
|
|
95
|
+
### 4. Core (`../epic`)
|
|
403
96
|
|
|
404
|
-
|
|
97
|
+
`Ec.info/warn/error/waiting(msg)`
|
|
405
98
|
|
|
406
|
-
|
|
99
|
+
`await Ec.ask(query)` (Use only AFTER menu closes)
|
|
407
100
|
|
|
408
|
-
|
|
409
|
-
- **co**: 生成器函数执行
|
|
410
|
-
- **commander**: 命令行框架(仅用于底层,执行器不直接使用)
|
|
411
|
-
- **underscore**: 工具函数
|
|
412
|
-
- **immutable**: 不可变数据结构
|
|
101
|
+
String colors: `.green, .blue, .bold`, etc.
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|