openclaw-weiyuan-init 1.0.83 → 1.0.87
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/README.md +5 -0
- package/docs/OPENCLAW_WEIYUAN_CLI_RULES.md +26 -0
- package/lib/commands.js +94 -3
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -30,6 +30,11 @@ npx -y openclaw-weiyuan-init@latest init --invite <inviteToken>
|
|
|
30
30
|
|
|
31
31
|
`inviteToken` 包含 `server/upgrade/project/code`,会自动完成安装与入组。
|
|
32
32
|
初始化过程会自动准备 `weiyuan` CLI 运行时依赖并生成完整 `.weiyuan` 身份文件。
|
|
33
|
+
并会在 `workspace-weiyuan/weiyuan` 下生成以下固定文件,供 OpenClaw 稳定识别:
|
|
34
|
+
- `CHANGELOG_OPENCLAW.md`
|
|
35
|
+
- `release-notes/latest.json`
|
|
36
|
+
- `docs/OPENCLAW_WEIYUAN_CLI_RULES.md`
|
|
37
|
+
- `OPENCLAW_REQUIRED_READ.json`
|
|
33
38
|
|
|
34
39
|
如需指定固定 zip,可覆盖自动识别:
|
|
35
40
|
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# OpenClaw 微元CLI行为规范
|
|
2
|
+
|
|
3
|
+
## 适用范围
|
|
4
|
+
- 仅在微元系统 CLI、项目看板、驾驶舱联动场景生效。
|
|
5
|
+
- 不影响 OpenClaw 在其他场景的默认行为。
|
|
6
|
+
|
|
7
|
+
## 高危操作规则
|
|
8
|
+
- 删除项目、初始化覆盖身份、清理关键数据,必须人工二次确认。
|
|
9
|
+
- 固定确认词:第一步“是”,第二步“同意”。
|
|
10
|
+
- 未收到本轮人工确认,禁止执行高危动作。
|
|
11
|
+
|
|
12
|
+
## 更新后必读规则
|
|
13
|
+
- 每次更新后,先读更新文件再回复。
|
|
14
|
+
- 必读:`CHANGELOG_OPENCLAW.md`、`release-notes/latest.json`、`docs/OPENCLAW_WEIYUAN_CLI_RULES.md`。
|
|
15
|
+
|
|
16
|
+
## 回复风格规则(微元CLI)
|
|
17
|
+
- 简短:先结论后动作。
|
|
18
|
+
- 结构化:结果 / 影响 / 下一步。
|
|
19
|
+
- 禁止跑题:仅围绕当前任务答复。
|
|
20
|
+
|
|
21
|
+
## 禁止绕过规则
|
|
22
|
+
- 禁止直调 API 跳过确认流程。
|
|
23
|
+
- 禁止通过隐式参数或脚本捷径绕过确认。
|
|
24
|
+
|
|
25
|
+
## 规范注入提示
|
|
26
|
+
- 更新后需将本规范写入 `agent.md`、`SOUL.md`、长期记忆,并注明“仅微元CLI场景生效”。
|
package/lib/commands.js
CHANGED
|
@@ -53,9 +53,9 @@ const DEFAULT_SKILL_TSCONFIG = {
|
|
|
53
53
|
};
|
|
54
54
|
|
|
55
55
|
const DEFAULT_FIXED_MESSAGES = {
|
|
56
|
-
sceneA: "【微元协作】✨
|
|
57
|
-
sceneB: "【微元协作】✨
|
|
58
|
-
sceneC: "【微元协作】✨
|
|
56
|
+
sceneA: "【微元协作】✨ 老板好~欢迎加入微元系统。\n【先执行】先读 3 个文件:CHANGELOG_OPENCLAW.md、release-notes/latest.json、docs/OPENCLAW_WEIYUAN_CLI_RULES.md;高危操作必须“是→同意”;禁止直调API绕过。\n请先回复:已进入微元CLI受控模式。",
|
|
57
|
+
sceneB: "【微元协作】✨ 已为你接入微元系统并加入项目。\n项目ID:{projectId}\n【先执行】先读 3 个文件:CHANGELOG_OPENCLAW.md、release-notes/latest.json、docs/OPENCLAW_WEIYUAN_CLI_RULES.md;高危操作必须“是→同意”;禁止直调API绕过。\n请先回复:已进入微元CLI受控模式。",
|
|
58
|
+
sceneC: "【微元协作】✨ 你已成功加入项目。\n项目ID:{projectId}\n【先执行】先读 3 个文件:CHANGELOG_OPENCLAW.md、release-notes/latest.json、docs/OPENCLAW_WEIYUAN_CLI_RULES.md;高危操作必须“是→同意”;禁止直调API绕过。\n请先回复:已进入微元CLI受控模式。"
|
|
59
59
|
};
|
|
60
60
|
|
|
61
61
|
let fixedMessagesCache = null;
|
|
@@ -99,6 +99,91 @@ function printReleaseNotes(notes) {
|
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
+
function markdownFromReleaseNotes(notes) {
|
|
103
|
+
if (!notes || typeof notes !== 'object') return '';
|
|
104
|
+
const version = String(notes.version || '').trim();
|
|
105
|
+
const summary = String(notes.summary || '').trim();
|
|
106
|
+
const releasedAt = String(notes.releasedAt || '').trim();
|
|
107
|
+
const changes = Array.isArray(notes.changes) ? notes.changes.map((x) => String(x || '').trim()).filter(Boolean) : [];
|
|
108
|
+
const lines = [];
|
|
109
|
+
lines.push(`# 微元系统更新日志${version ? ` v${version}` : ''}`);
|
|
110
|
+
if (releasedAt) lines.push(`- 发布时间:${releasedAt}`);
|
|
111
|
+
if (summary) lines.push(`- 版本摘要:${summary}`);
|
|
112
|
+
if (changes.length) {
|
|
113
|
+
lines.push('');
|
|
114
|
+
lines.push('## 变更清单');
|
|
115
|
+
for (const item of changes) lines.push(`- ${item}`);
|
|
116
|
+
}
|
|
117
|
+
lines.push('');
|
|
118
|
+
lines.push('## OpenClaw 必读');
|
|
119
|
+
lines.push('- 每次更新后,先阅读本文件,再执行任何命令。');
|
|
120
|
+
lines.push('- 涉及删除项目、初始化覆盖、清理数据等高危动作,必须人工二次确认。');
|
|
121
|
+
return lines.join('\n') + '\n';
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function weiyuanCliRulesMarkdown() {
|
|
125
|
+
return [
|
|
126
|
+
'# 微元系统 CLI 场景下 OpenClaw 操作规范',
|
|
127
|
+
'',
|
|
128
|
+
'## 适用范围',
|
|
129
|
+
'- 仅适用于微元系统 CLI 与项目看板/驾驶舱联动场景。',
|
|
130
|
+
'',
|
|
131
|
+
'## 高危动作规则',
|
|
132
|
+
'- 删除项目、初始化覆盖身份、清理数据目录必须走人工二次确认。',
|
|
133
|
+
'- 二次确认固定用词:第一步输入“是”,第二步输入“同意”。',
|
|
134
|
+
'- 禁止通过隐式参数或自动化跳过确认。',
|
|
135
|
+
'',
|
|
136
|
+
'## 更新后必做',
|
|
137
|
+
'- 每次更新后必须先读取 `CHANGELOG_OPENCLAW.md`、`release-notes/latest.json` 与 `docs/OPENCLAW_WEIYUAN_CLI_RULES.md`。',
|
|
138
|
+
'- 读取后再更新本地行为规范文档(如 `agent.md`、`SOUL.md`)和长期记忆。',
|
|
139
|
+
'',
|
|
140
|
+
'## 回复风格',
|
|
141
|
+
'- 优先输出可执行结论与下一步动作。',
|
|
142
|
+
'- 不输出内部推理过程,只保留对用户可决策信息。',
|
|
143
|
+
''
|
|
144
|
+
].join('\n');
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
async function loadBundledRulesMarkdown() {
|
|
148
|
+
const p = path.join(__dirname, '..', 'docs', 'OPENCLAW_WEIYUAN_CLI_RULES.md');
|
|
149
|
+
try {
|
|
150
|
+
const raw = await fs.readFile(p, 'utf8');
|
|
151
|
+
const text = String(raw || '').trim();
|
|
152
|
+
return text ? `${text}\n` : weiyuanCliRulesMarkdown();
|
|
153
|
+
} catch (_) {
|
|
154
|
+
return weiyuanCliRulesMarkdown();
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function printRulesInjectionHint() {
|
|
159
|
+
console.log(chalk.cyan('\n[OpenClaw 规范注入提示]'));
|
|
160
|
+
console.log(chalk.gray('- 请先阅读:weiyuan/docs/OPENCLAW_WEIYUAN_CLI_RULES.md'));
|
|
161
|
+
console.log(chalk.gray('- 再将要点写入 agent.md / SOUL.md / 长期记忆(仅微元CLI场景生效)。'));
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
async function persistOpenClawRequiredFiles(weiyuanPath, notes) {
|
|
165
|
+
const md = markdownFromReleaseNotes(notes);
|
|
166
|
+
const notesDir = path.join(weiyuanPath, 'release-notes');
|
|
167
|
+
const docsDir = path.join(weiyuanPath, 'docs');
|
|
168
|
+
await fs.ensureDir(notesDir);
|
|
169
|
+
await fs.ensureDir(docsDir);
|
|
170
|
+
if (md) {
|
|
171
|
+
await fs.writeFile(path.join(notesDir, 'RELEASE_NOTES_LATEST.md'), md, 'utf8');
|
|
172
|
+
await fs.writeFile(path.join(weiyuanPath, 'RELEASE_NOTES_LATEST.md'), md, 'utf8');
|
|
173
|
+
await fs.writeFile(path.join(weiyuanPath, 'CHANGELOG_OPENCLAW.md'), md, 'utf8');
|
|
174
|
+
}
|
|
175
|
+
const rules = await loadBundledRulesMarkdown();
|
|
176
|
+
await fs.writeFile(path.join(weiyuanPath, 'OPENCLAW_WEIYUAN_CLI_RULES.md'), rules, 'utf8');
|
|
177
|
+
await fs.writeFile(path.join(docsDir, 'OPENCLAW_WEIYUAN_CLI_RULES.md'), rules, 'utf8');
|
|
178
|
+
await fs.writeJson(path.join(weiyuanPath, 'OPENCLAW_REQUIRED_READ.json'), {
|
|
179
|
+
mustRead: ['CHANGELOG_OPENCLAW.md', 'release-notes/latest.json', 'docs/OPENCLAW_WEIYUAN_CLI_RULES.md'],
|
|
180
|
+
scope: 'weiyuan-cli-only',
|
|
181
|
+
injectTargets: ['agent.md', 'SOUL.md', 'long_term_memory'],
|
|
182
|
+
injectPrompt: '请将本次更新要点和微元CLI行为规范写入 agent.md / SOUL.md / 长期记忆(仅微元CLI场景生效)。',
|
|
183
|
+
updatedAt: new Date().toISOString()
|
|
184
|
+
}, { spaces: 2 });
|
|
185
|
+
}
|
|
186
|
+
|
|
102
187
|
async function persistReleaseNotes(weiyuanPath, notes) {
|
|
103
188
|
const notesDir = path.join(weiyuanPath, 'release-notes');
|
|
104
189
|
const latestPath = path.join(notesDir, 'latest.json');
|
|
@@ -130,6 +215,7 @@ async function persistReleaseNotes(weiyuanPath, notes) {
|
|
|
130
215
|
if (!name.toLowerCase().endsWith('.json')) continue;
|
|
131
216
|
await fs.remove(path.join(notesDir, name));
|
|
132
217
|
}
|
|
218
|
+
await persistOpenClawRequiredFiles(weiyuanPath, notes);
|
|
133
219
|
}
|
|
134
220
|
|
|
135
221
|
function resolveWorkspacePath(workspaceOption) {
|
|
@@ -332,7 +418,9 @@ async function runInit(options) {
|
|
|
332
418
|
await fs.writeJson(identityPath, identity, { spaces: 2 });
|
|
333
419
|
await runJoin(weiyuanPath, identityPath, options.project, options.code, false);
|
|
334
420
|
});
|
|
421
|
+
await persistOpenClawRequiredFiles(weiyuanPath, null);
|
|
335
422
|
spinner.succeed(`已加入项目: ${options.project}`);
|
|
423
|
+
printRulesInjectionHint();
|
|
336
424
|
console.log(renderFixedMessage(fixedMessages.sceneC, { projectId: options.project }));
|
|
337
425
|
return;
|
|
338
426
|
} catch (error) {
|
|
@@ -420,6 +508,7 @@ async function runInit(options) {
|
|
|
420
508
|
spinner = ora('准备 CLI 运行时...').start();
|
|
421
509
|
try {
|
|
422
510
|
await ensureSkillRuntime(weiyuanPath);
|
|
511
|
+
await persistOpenClawRequiredFiles(weiyuanPath, null);
|
|
423
512
|
spinner.succeed('CLI 运行时就绪');
|
|
424
513
|
} catch (error) {
|
|
425
514
|
spinner.fail(`CLI 运行时准备失败: ${error.message}`);
|
|
@@ -472,9 +561,11 @@ async function runInit(options) {
|
|
|
472
561
|
throw error;
|
|
473
562
|
}
|
|
474
563
|
spinner.succeed(`已加入项目: ${options.project}`);
|
|
564
|
+
printRulesInjectionHint();
|
|
475
565
|
console.log(renderFixedMessage(fixedMessages.sceneB, { projectId: options.project }));
|
|
476
566
|
return;
|
|
477
567
|
}
|
|
568
|
+
printRulesInjectionHint();
|
|
478
569
|
console.log(fixedMessages.sceneA);
|
|
479
570
|
}
|
|
480
571
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openclaw-weiyuan-init",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.87",
|
|
4
4
|
"description": "OpenClaw Weiyuan Skill 一键初始化工具",
|
|
5
5
|
"main": "bin/cli.js",
|
|
6
6
|
"bin": {
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"files": [
|
|
13
13
|
"bin/",
|
|
14
14
|
"lib/",
|
|
15
|
+
"docs/",
|
|
15
16
|
"README.md"
|
|
16
17
|
],
|
|
17
18
|
"dependencies": {
|