@aiyiran/myclaw 1.0.114 → 1.0.116
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/build-manifest.js +1 -1
- package/index.js +4 -2
- package/inject-minimax.js +11 -0
- package/package.json +1 -1
- package/patch-agent.js +31 -2
- package/patch-manifest.json +2 -2
- package/patch-skill.js +45 -3
- package/skills/minimax-inject/scripts/inject.js +8 -0
package/build-manifest.js
CHANGED
|
@@ -91,7 +91,7 @@ function buildManifest() {
|
|
|
91
91
|
const config = existing.config || DEFAULT_CONFIG;
|
|
92
92
|
|
|
93
93
|
const manifest = {
|
|
94
|
-
_doc: 'MyClaw 注入清单 (auto-generated)。strategy: auto | on | off',
|
|
94
|
+
_doc: 'MyClaw 注入清单 (auto-generated)。strategy: auto | on | off | delete',
|
|
95
95
|
_generated: new Date().toISOString(),
|
|
96
96
|
agents,
|
|
97
97
|
skills,
|
package/index.js
CHANGED
|
@@ -893,7 +893,8 @@ function runList() {
|
|
|
893
893
|
function formatStrategy(strat) {
|
|
894
894
|
if (strat === 'auto') return colors.green + '[auto]' + colors.nc;
|
|
895
895
|
if (strat === 'on') return colors.yellow + '[on]' + colors.nc;
|
|
896
|
-
if (strat === 'off') return colors.
|
|
896
|
+
if (strat === 'off') return colors.yellow + '[off]' + colors.nc;
|
|
897
|
+
if (strat === 'delete') return colors.red + '[delete]' + colors.nc;
|
|
897
898
|
return '[' + strat + ']';
|
|
898
899
|
}
|
|
899
900
|
|
|
@@ -936,7 +937,8 @@ function runList() {
|
|
|
936
937
|
console.log(bar);
|
|
937
938
|
console.log('策略说明: ' + colors.green + 'auto' + colors.nc + '=不存在才注入 '
|
|
938
939
|
+ colors.yellow + 'on' + colors.nc + '=始终覆盖更新 '
|
|
939
|
-
+ colors.
|
|
940
|
+
+ colors.yellow + 'off' + colors.nc + '=关闭不注入 '
|
|
941
|
+
+ colors.red + 'delete' + colors.nc + '=删除目标');
|
|
940
942
|
console.log('');
|
|
941
943
|
}
|
|
942
944
|
|
package/inject-minimax.js
CHANGED
|
@@ -14,6 +14,11 @@
|
|
|
14
14
|
|
|
15
15
|
const { readConfig, writeConfig } = require('./find-config');
|
|
16
16
|
|
|
17
|
+
// ============================================================
|
|
18
|
+
// 请在这里填写默认的 MiniMax API Key
|
|
19
|
+
// ============================================================
|
|
20
|
+
const DEFAULT_MINIMAX_KEY = "sk-cp-hZrI2mmHl_bQxHGSwRkDJvIrroe6xebBaKyhUhdnH1s4TABiJ4j_RcP85i44fGSbrhxv6yGij-mM0a0EXvMaLkcL2UhjtW6YAm3TF-2SuRGAemg3LC8F4xM";
|
|
21
|
+
|
|
17
22
|
function run(cliArgs) {
|
|
18
23
|
// 解析 --key 参数
|
|
19
24
|
let apiKey = null;
|
|
@@ -24,6 +29,12 @@ function run(cliArgs) {
|
|
|
24
29
|
}
|
|
25
30
|
}
|
|
26
31
|
|
|
32
|
+
// 如果没有传参数,并且配置了默认 Key,则使用默认 Key
|
|
33
|
+
if (!apiKey && DEFAULT_MINIMAX_KEY && DEFAULT_MINIMAX_KEY !== "请在这里填入你的默认Key") {
|
|
34
|
+
apiKey = DEFAULT_MINIMAX_KEY;
|
|
35
|
+
console.log('💡 未传入 --key 参数,自动使用默认的 API Key');
|
|
36
|
+
}
|
|
37
|
+
|
|
27
38
|
// 查找配置
|
|
28
39
|
let configPath;
|
|
29
40
|
try {
|
package/package.json
CHANGED
package/patch-agent.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* 2. 根据 strategy 决定行为:
|
|
9
9
|
* - auto: 目标 workspace 不存在时才注入(默认)
|
|
10
10
|
* - on: 始终覆盖更新 workspace 文件
|
|
11
|
+
* - delete: 彻底删除该智能体(配置、目录)
|
|
11
12
|
* - off: 跳过,不注入
|
|
12
13
|
* 3. 将 workspace 复制到 ~/.openclaw/ 下
|
|
13
14
|
* 4. 在 openclaw.json 的 agents.list 中注册
|
|
@@ -113,6 +114,10 @@ function patchAgents() {
|
|
|
113
114
|
const strategy = entry.strategy || 'auto';
|
|
114
115
|
const desc = entry.description || agentId;
|
|
115
116
|
|
|
117
|
+
const destWorkspace = path.join(openclawDir, workspaceName);
|
|
118
|
+
const agentDir = path.join(openclawDir, 'agents', agentId, 'agent');
|
|
119
|
+
const agentsDirBase = path.join(openclawDir, 'agents', agentId);
|
|
120
|
+
|
|
116
121
|
// off → 跳过
|
|
117
122
|
if (strategy === 'off') {
|
|
118
123
|
console.log('[myclaw-agent] ⏭️ 跳过: ' + agentId + ' (' + desc + ') [off]');
|
|
@@ -120,9 +125,33 @@ function patchAgents() {
|
|
|
120
125
|
continue;
|
|
121
126
|
}
|
|
122
127
|
|
|
128
|
+
// delete → 彻底移除
|
|
129
|
+
if (strategy === 'delete') {
|
|
130
|
+
let deleted = false;
|
|
131
|
+
if (fs.existsSync(destWorkspace)) {
|
|
132
|
+
fs.rmSync(destWorkspace, { recursive: true, force: true });
|
|
133
|
+
deleted = true;
|
|
134
|
+
}
|
|
135
|
+
if (fs.existsSync(agentsDirBase)) {
|
|
136
|
+
fs.rmSync(agentsDirBase, { recursive: true, force: true });
|
|
137
|
+
deleted = true;
|
|
138
|
+
}
|
|
139
|
+
if (existingIds.has(agentId)) {
|
|
140
|
+
configData.agents.list = configData.agents.list.filter(e => e.id !== agentId);
|
|
141
|
+
existingIds.delete(agentId);
|
|
142
|
+
configChanged = true;
|
|
143
|
+
deleted = true;
|
|
144
|
+
}
|
|
145
|
+
if (deleted) {
|
|
146
|
+
console.log('[myclaw-agent] 🗑️ 已彻底删除: ' + agentId + ' (' + desc + ') [delete]');
|
|
147
|
+
} else {
|
|
148
|
+
console.log('[myclaw-agent] ⏭️ 未找到需删除的: ' + agentId + ' (' + desc + ') [delete]');
|
|
149
|
+
}
|
|
150
|
+
skipped++;
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
|
|
123
154
|
const srcWorkspace = path.join(agentListDir, workspaceName);
|
|
124
|
-
const destWorkspace = path.join(openclawDir, workspaceName);
|
|
125
|
-
const agentDir = path.join(openclawDir, 'agents', agentId, 'agent');
|
|
126
155
|
|
|
127
156
|
// 检查源文件是否存在
|
|
128
157
|
if (!fs.existsSync(srcWorkspace)) {
|
package/patch-manifest.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"_doc": "MyClaw 注入清单 (auto-generated)。strategy: auto | on | off",
|
|
3
|
-
"_generated": "2026-04-
|
|
2
|
+
"_doc": "MyClaw 注入清单 (auto-generated)。strategy: auto | on | off | delete",
|
|
3
|
+
"_generated": "2026-04-02T14:01:48.263Z",
|
|
4
4
|
"agents": [
|
|
5
5
|
{
|
|
6
6
|
"id": "danci",
|
package/patch-skill.js
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
* 功能:
|
|
7
7
|
* 1. 探测 OpenClaw 安装路径下的 skills/ 目录
|
|
8
8
|
* 2. 将 myclaw 自带的 skill 复制到 openclaw/skills/ 下
|
|
9
|
-
* 3.
|
|
9
|
+
* 3. 读取 patch-manifest.json 中的 skills 配置,响应 strategy(delete/off)
|
|
10
|
+
* 4. 幂等:重复执行覆盖更新
|
|
10
11
|
*
|
|
11
12
|
* 使用:
|
|
12
13
|
* const { patchSkills, listSkills } = require('./patch-skill');
|
|
@@ -90,10 +91,51 @@ function patchSkills() {
|
|
|
90
91
|
return { success: true, count: 0 };
|
|
91
92
|
}
|
|
92
93
|
|
|
94
|
+
const { loadManifest } = require('./patch-agent');
|
|
95
|
+
const manifest = loadManifest();
|
|
96
|
+
const manifestSkills = manifest && Array.isArray(manifest.skills) ? manifest.skills : [];
|
|
97
|
+
|
|
98
|
+
// 把 manifest 里的配置做成一个 map 方便查询
|
|
99
|
+
const skillStrategyMap = {};
|
|
100
|
+
for (const s of manifestSkills) {
|
|
101
|
+
if (s.name) skillStrategyMap[s.name] = s.strategy || 'auto';
|
|
102
|
+
}
|
|
103
|
+
|
|
93
104
|
let count = 0;
|
|
105
|
+
|
|
106
|
+
// 1. 处理 manifest 中明确被 delete 的 skill
|
|
107
|
+
for (const [name, strategy] of Object.entries(skillStrategyMap)) {
|
|
108
|
+
if (strategy === 'delete') {
|
|
109
|
+
const targetDir = path.join(skillsDir, name);
|
|
110
|
+
if (fs.existsSync(targetDir)) {
|
|
111
|
+
fs.rmSync(targetDir, { recursive: true, force: true });
|
|
112
|
+
console.log('[myclaw-skill] 🗑️ 已彻底删除技能: ' + name + ' [delete]');
|
|
113
|
+
} else {
|
|
114
|
+
console.log('[myclaw-skill] ⏭️ 未找到需删除的技能: ' + name + ' [delete]');
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// 2. 遍历 skills/ 目录下的每个子目录 = 准备注入的 skill
|
|
94
120
|
for (const skillDir of skillDirs) {
|
|
95
121
|
const srcDir = path.join(myclawSkillsDir, skillDir.name);
|
|
96
122
|
const destDir = path.join(skillsDir, skillDir.name);
|
|
123
|
+
const strategy = skillStrategyMap[skillDir.name] || 'auto';
|
|
124
|
+
|
|
125
|
+
if (strategy === 'off') {
|
|
126
|
+
console.log('[myclaw-skill] ⏭️ 跳过: ' + skillDir.name + ' [off]');
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (strategy === 'delete') {
|
|
131
|
+
continue; // 已经处理过删除,跳过注入
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// auto 策略下,如果已经存在则跳过
|
|
135
|
+
if (strategy === 'auto' && fs.existsSync(destDir)) {
|
|
136
|
+
console.log('[myclaw-skill] ✔️ 已存在: ' + skillDir.name + ' [auto, 跳过]');
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
97
139
|
|
|
98
140
|
// 检查是否有 SKILL.md(必须有才是合法 skill)
|
|
99
141
|
if (!fs.existsSync(path.join(srcDir, 'SKILL.md'))) {
|
|
@@ -103,10 +145,10 @@ function patchSkills() {
|
|
|
103
145
|
|
|
104
146
|
copyDirSync(srcDir, destDir);
|
|
105
147
|
count++;
|
|
106
|
-
console.log('[myclaw-skill] ✅ 已注入: ' + skillDir.name);
|
|
148
|
+
console.log('[myclaw-skill] ✅ 已注入: ' + skillDir.name + ' [' + strategy + ']');
|
|
107
149
|
}
|
|
108
150
|
|
|
109
|
-
console.log('[myclaw-skill] 🎉
|
|
151
|
+
console.log('[myclaw-skill] 🎉 注入任务完成,本次有效注入/更新: ' + count + ' 个');
|
|
110
152
|
return { success: true, count };
|
|
111
153
|
}
|
|
112
154
|
|
|
@@ -24,6 +24,8 @@ const { execSync } = require('child_process');
|
|
|
24
24
|
// 解析参数
|
|
25
25
|
// ============================================================================
|
|
26
26
|
|
|
27
|
+
const DEFAULT_MINIMAX_KEY = "sk-cp-hZrI2mmHl_bQxHGSwRkDJvIrroe6xebBaKyhUhdnH1s4TABiJ4j_RcP85i44fGSbrhxv6yGij-mM0a0EXvMaLkcL2UhjtW6YAm3TF-2SuRGAemg3LC8F4xM";
|
|
28
|
+
|
|
27
29
|
let apiKey = null;
|
|
28
30
|
const args = process.argv.slice(2);
|
|
29
31
|
for (let i = 0; i < args.length; i++) {
|
|
@@ -33,6 +35,12 @@ for (let i = 0; i < args.length; i++) {
|
|
|
33
35
|
}
|
|
34
36
|
}
|
|
35
37
|
|
|
38
|
+
// 如果没有传参数,并且配置了默认 Key,则使用默认 Key
|
|
39
|
+
if (!apiKey && DEFAULT_MINIMAX_KEY && DEFAULT_MINIMAX_KEY !== "请在这里填入你的默认Key") {
|
|
40
|
+
apiKey = DEFAULT_MINIMAX_KEY;
|
|
41
|
+
console.log('💡 未传入 --key 参数,自动使用默认的 API Key');
|
|
42
|
+
}
|
|
43
|
+
|
|
36
44
|
// ============================================================================
|
|
37
45
|
// 查找 openclaw.json
|
|
38
46
|
// ============================================================================
|