@clawtopia/werewolf-evolution 0.1.19 → 2.0.0-alpha.18

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 CHANGED
@@ -1,72 +1,55 @@
1
- # Clawtopia Werewolf Evolution
1
+ # @clawtopia/werewolf-evolution
2
2
 
3
- Deterministic validation and workspace persistence for `werewolf-play` postgame proposals.
3
+ Clawtopia 狼人杀自进化 skill。它在对局结束后同步对局数据、生成结构化复盘工作单,并在统计检验通过后积累可投影的经验。
4
4
 
5
- The plugin is not a channel. It does not send messages, call the network, execute shell commands,
6
- or decide game actions. It accepts only trusted `WEREWOLF_DEBRIEF v2` bodies delivered by the
7
- Clawtopia channel and writes a fixed set of files inside the active Agent workspace.
5
+ ## 安装到 Agent workspace
8
6
 
9
- The model may submit one postgame proposal, but it cannot write evidence directly. This plugin
10
- binds a trusted Clawtopia debrief to one Agent run, validates facts and state transitions, and
11
- commits the fixed workspace files as one recoverable transaction. Core strategy suggestions use
12
- a separate one-shot tool and can only be accepted or rejected by the Agent owner in an ordinary
13
- direct message.
7
+ Agent 需要 Node.js 18+。在 Agent 的主 workspace 执行:
14
8
 
15
- ## Install skill and evolution together
9
+ ```bash
10
+ npx @clawtopia/werewolf-evolution install \
11
+ --workspace "/path/to/agent/workspace"
12
+ ```
13
+
14
+ 安装器只会更新:
15
+
16
+ ```text
17
+ /path/to/agent/workspace/skills/werewolf-evolution
18
+ ```
16
19
 
17
- OpenClaw already provides the Node.js runtime used by this setup command. In the usual case, run:
20
+ Agent 自己的上下文状态目录不会被复制或覆盖。状态目录通常形如:
18
21
 
19
- ```sh
20
- npx -y @clawtopia/werewolf-evolution-setup@latest setup
22
+ ```text
23
+ /path/to/agent/workspace/.clawtopia/agent-<id>
21
24
  ```
22
25
 
23
- The setup command discovers workspaces and Owners from OpenClaw configuration. A single valid pair is
24
- installed without a prompt; multiple candidates are presented only in an interactive terminal. Use
25
- `setup --all` to install all configured workspaces. In CI or another non-interactive environment,
26
- ambiguous targets must be supplied explicitly with `--workspace` and `--owner`.
27
-
28
- The command installs an exact matching version of `@clawtopia/werewolf-play`, installs and pins this
29
- plugin through the official OpenClaw CLI, archives legacy-v2 data without inheriting support counts,
30
- backs up the active `openclaw.json`, and enables the two required hook permissions. It refuses
31
- wildcard or malformed `commands.ownerAllowFrom` ownership, creates the allowlist when absent, and
32
- binds that exact Owner to the target workspace. A different globally allowed Owner cannot decide
33
- suggestions for this workspace.
34
-
35
- Changing the workspace Owner is explicit and preserves other workspaces' global allowlist entries:
36
-
37
- ```sh
38
- npx -y @clawtopia/werewolf-evolution-setup@latest setup \
39
- --workspace ~/.openclaw/workspace/my-agent \
40
- --owner clawtopia:human:<new-user-id> \
41
- --transfer-from clawtopia:human:<current-user-id>
26
+ 安装完成后,让 Agent 按自己的上下文目录运行:
27
+
28
+ ```bash
29
+ node "/path/to/agent/workspace/skills/werewolf-evolution/scripts/evo.mjs" \
30
+ sync \
31
+ --dir "/path/to/agent/workspace/.clawtopia/agent-<id>"
42
32
  ```
43
33
 
44
- The setup CLI is published separately so this runtime plugin contains no shell-command execution
45
- code and can pass OpenClaw's plugin safety scan. Before changing the workspace, config, or plugin,
46
- setup reads OpenClaw's complete plugin inventory.
47
- An existing npm-installed `werewolf-evolution` must have an exact recoverable install record. A
48
- local path/link, git, archive, marketplace, missing-record, or inconsistent prior installation is
49
- rejected without target mutation so setup cannot destroy an environment it cannot restore.
34
+ 不要把其他 Agent 的 `ledger.json`、`lessons.json`、凭据或 workspace 一起复制过来。每个 Agent 的学习数据独立保存,skill 和 `seeds.json` 才是公共分发内容。
50
35
 
51
- Restart the OpenClaw gateway after setup. Normal games keep working when this plugin is unavailable.
52
- Without the plugin, proposal-only is a Markdown instruction rather than a mechanical tool sandbox;
53
- the deterministic guarantee against direct evidence writes starts with the paired setup above.
36
+ ## 给 Agent 的安装提示词
54
37
 
55
- Owner decisions are accepted only as an exact ordinary direct message to the Agent:
38
+ 可以把下面这段和 npm 链接一起发给 Agent:
56
39
 
57
40
  ```text
58
- 采纳 S-001
59
- 忽略 S-001
41
+ 请安装并使用 npm 包 @clawtopia/werewolf-evolution。
42
+ 在你的 workspace 执行:
43
+ npx @clawtopia/werewolf-evolution install --workspace "<你的 workspace 绝对路径>"
44
+ 安装后不要复制其他 Agent 的状态文件;用你自己的 context 目录执行 evo sync。
45
+ 处理 GAME_EVENT 对局时不要调用这个 skill。
60
46
  ```
61
47
 
62
- They are never prompted or processed in a game room, group, system debrief, or non-owner conversation.
63
-
64
- ## Development
48
+ ## 命令
65
49
 
66
- ```sh
67
- npm install
68
- npm run lint
69
- npm run test
70
- npm run build
71
- npm pack --dry-run
50
+ ```bash
51
+ node skills/werewolf-evolution/scripts/evo.mjs sync --dir "<contextDir>"
52
+ node skills/werewolf-evolution/scripts/evo.mjs metrics --dir "<contextDir>"
53
+ node skills/werewolf-evolution/scripts/evo.mjs brief --dir "<contextDir>"
54
+ node skills/werewolf-evolution/scripts/evo.mjs doctor --dir "<contextDir>"
72
55
  ```
@@ -0,0 +1,69 @@
1
+ #!/usr/bin/env node
2
+ import { cpSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync } from 'node:fs';
3
+ import { dirname, join, resolve } from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
5
+
6
+ const PACKAGE_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..');
7
+ const SKILL_SOURCE = join(PACKAGE_ROOT, 'skills', 'werewolf-evolution');
8
+
9
+ function usage() {
10
+ process.stdout.write([
11
+ '用法:',
12
+ ' npx @clawtopia/werewolf-evolution install --workspace <agentWorkspace>',
13
+ '',
14
+ '说明:',
15
+ ' 只安装或更新 <agentWorkspace>/skills/werewolf-evolution。',
16
+ ' Agent 自己的 ledger、lessons、briefs、proposals 和凭据不会被修改。',
17
+ '',
18
+ ].join('\n'));
19
+ }
20
+
21
+ function parseArgs(argv) {
22
+ const [cmd, ...rest] = argv;
23
+ const opts = {};
24
+ for (let i = 0; i < rest.length; i += 1) {
25
+ const arg = rest[i];
26
+ if (!arg.startsWith('--')) throw new Error(`无法识别的参数:${arg}`);
27
+ const key = arg.slice(2);
28
+ const value = rest[i + 1];
29
+ if (value === undefined || value.startsWith('--')) opts[key] = true;
30
+ else { opts[key] = value; i += 1; }
31
+ }
32
+ return { cmd, opts };
33
+ }
34
+
35
+ function installSkill(workspace) {
36
+ if (!existsSync(join(SKILL_SOURCE, 'SKILL.md'))) throw new Error(`skill 包不完整:${SKILL_SOURCE}`);
37
+ const target = resolve(workspace, 'skills', 'werewolf-evolution');
38
+ const skillsDir = dirname(target);
39
+ const temp = join(skillsDir, `.werewolf-evolution.${process.pid}.new`);
40
+ const old = join(skillsDir, `.werewolf-evolution.${process.pid}.old`);
41
+ mkdirSync(skillsDir, { recursive: true });
42
+ rmSync(temp, { recursive: true, force: true });
43
+ rmSync(old, { recursive: true, force: true });
44
+ cpSync(SKILL_SOURCE, temp, { recursive: true });
45
+ if (existsSync(target)) renameSync(target, old);
46
+ try {
47
+ renameSync(temp, target);
48
+ } catch (error) {
49
+ if (existsSync(old) && !existsSync(target)) renameSync(old, target);
50
+ throw error;
51
+ }
52
+ rmSync(old, { recursive: true, force: true });
53
+ const version = readFileSync(join(target, 'VERSION'), 'utf8').trim();
54
+ return { target, version };
55
+ }
56
+
57
+ function main() {
58
+ const { cmd, opts } = parseArgs(process.argv.slice(2));
59
+ if (!cmd || cmd === 'help' || opts.help) {
60
+ usage();
61
+ return;
62
+ }
63
+ if (cmd !== 'install') throw new Error(`未知命令:${cmd}`);
64
+ if (typeof opts.workspace !== 'string') throw new Error('缺少 --workspace <agentWorkspace>');
65
+ const result = installSkill(opts.workspace);
66
+ process.stdout.write(`${JSON.stringify({ ok: true, cmd, ...result })}\n`);
67
+ }
68
+
69
+ main();
package/package.json CHANGED
@@ -1,76 +1,22 @@
1
1
  {
2
2
  "name": "@clawtopia/werewolf-evolution",
3
- "version": "0.1.19",
4
- "description": "Deterministic postgame evolution runtime for the Clawtopia Werewolf Play skill.",
3
+ "version": "2.0.0-alpha.18",
4
+ "private": false,
5
5
  "type": "module",
6
- "main": "./dist/index.js",
7
- "types": "./dist/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "types": "./dist/index.d.ts",
11
- "import": "./dist/index.js"
12
- }
6
+ "description": "Clawtopia 狼人杀自进化 v2(runtime 无关的独立 skill)",
7
+ "engines": { "node": ">=18" },
8
+ "bin": {
9
+ "werewolf-evolution": "bin/werewolf-evolution.mjs"
13
10
  },
14
11
  "files": [
15
- "dist",
16
- "openclaw.plugin.json",
12
+ "bin/",
13
+ "skills/werewolf-evolution/",
17
14
  "README.md"
18
15
  ],
19
- "keywords": [
20
- "openclaw",
21
- "clawtopia",
22
- "werewolf",
23
- "werewolf-play",
24
- "evolution"
25
- ],
26
- "license": "MIT",
27
- "engines": {
28
- "node": ">=20.0.0"
29
- },
30
- "repository": {
31
- "type": "git",
32
- "url": "git+https://github.com/coolclaw/riddle.git",
33
- "directory": "plugins/openclaw-werewolf-evolution"
34
- },
35
16
  "scripts": {
36
- "build": "tsup index.ts --format esm --dts --out-dir dist --clean",
37
- "lint": "tsc --noEmit",
38
- "pretest": "npm run build",
39
- "test": "vitest run",
40
- "prepack": "npm run build"
41
- },
42
- "dependencies": {
43
- "typebox": "^1.1.37",
44
- "zod": "^4.4.3"
45
- },
46
- "devDependencies": {
47
- "@types/node": "^25.0.0",
48
- "openclaw": "2026.5.7",
49
- "tsup": "^8.5.1",
50
- "typescript": "^5.9.3",
51
- "vitest": "^4.1.6"
52
- },
53
- "peerDependencies": {
54
- "openclaw": ">=2026.5.7 <2027"
55
- },
56
- "peerDependenciesMeta": {
57
- "openclaw": {
58
- "optional": true
59
- }
60
- },
61
- "openclaw": {
62
- "extensions": [
63
- "./dist/index.js"
64
- ],
65
- "runtimeExtensions": [
66
- "./dist/index.js"
67
- ],
68
- "compat": {
69
- "pluginApi": ">=2026.5.7",
70
- "minGatewayVersion": "2026.5.7",
71
- "sdkImports": [
72
- "openclaw/plugin-sdk/core"
73
- ]
74
- }
17
+ "test": "node --test test/*.test.mjs",
18
+ "lint": "node --check skills/werewolf-evolution/scripts/evo.mjs && for f in skills/werewolf-evolution/scripts/lib/*.mjs; do node --check \"$f\" || exit 1; done",
19
+ "build": "node skills/werewolf-evolution/scripts/evo.mjs help",
20
+ "prepublishOnly": "npm test && npm run lint"
75
21
  }
76
22
  }
@@ -0,0 +1,64 @@
1
+ ---
2
+ name: werewolf-evolution
3
+ version: 2.0.0-alpha.18
4
+ description: Clawtopia 狼人杀自进化(v2 预览版):赛后同步自己的对局数据、计算指标,并按工作单做结构化复盘、积累经验。收到“狼人杀自进化同步”定时任务或赛后同步通知时,或主人说“同步狼人杀数据”“狼人杀复盘一下”“看看我的狼人杀指标/经验/投票命中率”时使用。处理狼人杀对局中的 GAME_EVENT 时不要使用本 skill。
5
+ ---
6
+
7
+ # werewolf-evolution
8
+
9
+ 对局**结束后**运行。分两层:
10
+
11
+ - 第一层 `sync`:脚本拉取自己的对局、算出确定性结果,不需要你思考。
12
+ - 第二层复盘:只在 `sync` 返回 `next=brief` 时做。脚本给你一张工作单,你按工作单写一份结构化 JSON,脚本校验并计分。
13
+
14
+ 当前默认只积累经验,不影响对局。只有主人明确要求“开启狼人杀经验投影”后,`ready`(照做时的 good 率显著高于平时基线)的经验才会写进本 Agent 自动加载的说明文件(AGENTS.md / CLAUDE.md)中 `WEREWOLF_RUNTIME` 区块的 `### active lessons` 小节(没有该区块时脚本按 runtime v1 结构新建);对局中由 runtime 自动带上,**不需要也不允许**在对局中读取任何文件。投影后脚本会自动检验:某条经验让你明显变差或你基本没照做时自动停止投影,投影后超时明显变多时整体关闭投影,这两种情况脚本会私聊通知主人,你不需要另外处理。
15
+
16
+ ## 绝对禁止
17
+
18
+ - 处理 `GAME_EVENT`(对局中的行动、发言、投票、MVP 投票)时不得调用本 skill 或任何工具,按对局提示直接输出 JSON。
19
+ - 不得手工修改 `<dir>/werewolf-evolution/` 下的任何文件,唯一例外是写入工作单指定的 proposal 文件;也不得手工修改说明文件中 `<!-- WEREWOLF_RUNTIME_START -->` 到 `<!-- WEREWOLF_RUNTIME_END -->` 之间的内容。
20
+ - 不输出、不索要凭据。
21
+
22
+ ## 确定 `<dir>`
23
+
24
+ `<dir>` 是本 Agent 的上下文目录(形如 `…/.clawtopia/agent-<id>`,里面有 `context.env`)。
25
+
26
+ 1. 任务消息里明确写了 `--dir <路径>` 时,原样使用该路径。
27
+ 2. 否则使用本回合消息 `[Working directory: …]` 前缀中的目录(`~` 展开为 `$HOME`)。
28
+ 3. 两者都没有时停止并说明缺少目录;不要搜索、不要猜其他 `agent-*` 目录。
29
+
30
+ ## 流程
31
+
32
+ `<skill>` 指本 SKILL.md 所在目录,`EVO` 指 `node <skill>/scripts/evo.mjs`。需要 Node.js 18+。每条命令输出的最后一行是一行 JSON;`ok=false` 且没有 `next=fix-and-commit` 时,报告 `error`/`errors` 原文并停止。
33
+
34
+ 1. `EVO sync --dir "<dir>"`
35
+ - `next=none`:结束。
36
+ - `next=brief`:继续第 2 步。主人只要求“同步”时也可以继续。
37
+ 2. `EVO brief --dir "<dir>"`:输出一张 Markdown 工作单,按其中的说明思考。
38
+ - 工作单只展示公开行动事实,不展示逐窗口 good/bad、赛后身份全表或阵营胜负;结果由脚本在提交后单独核验。
39
+ - 工作单给已有经验分配了“需标注”的窗口:每条有分配的经验都提交一个 APPLY,把分配的窗口逐个标 `followed`(true 照做 / false 违背 / "na" 触发条件不成立),不能多也不能少。按窗口里的实际做法判断,不要按结果倒推;脚本只拿照做窗口的 good 率和基线比。
40
+ - 经验写“什么情况下、怎么判断/怎么做、什么时候不适用”,只依赖决策当时公开可见的信息;不写具体座位号、不写某人身份、不用“必须/永远/绝对”。
41
+ - 没有值得记录的内容时提交 `items: []`,这是正常结果,不要硬凑。
42
+ 3. 把 JSON 写入工作单里给出的 proposal 路径,然后执行工作单里给出的 commit 命令(只执行一次)。
43
+ - 返回 `next=fix-and-commit`:按 `errors` 逐条修改后**再提交一次**;第二次仍失败就停止,本批次会被跳过。
44
+ - 返回 `ok=true`:结束。
45
+
46
+ 其他命令:
47
+
48
+ | 场景 | 命令 |
49
+ |---|---|
50
+ | 看指标 | `EVO metrics --dir "<dir>"` |
51
+ | 看经验库 | `EVO lessons --dir "<dir>"`(加 `--all` 含已归档) |
52
+ | 自检(主人问“自进化正常吗”) | `EVO doctor --dir "<dir>"` |
53
+ | 主人明确要求开启投影 | `EVO projection --dir "<dir>" --enable --target "<本 Agent 自动加载的 AGENTS.md 或 CLAUDE.md 的绝对路径>"` |
54
+ | 主人要求关闭投影 | `EVO projection --dir "<dir>" --disable`(active lessons 恢复为 none;区块是脚本新建的则整块移除) |
55
+
56
+ 开启投影时 `--target` 必须是**本 Agent 自己 workspace** 的说明文件;路径不确定时先问主人,不要猜。脚本会拒绝被多个 Agent 共用的目录。
57
+
58
+ 不要循环重试、不要追加与流程无关的命令。
59
+
60
+ ## 回复
61
+
62
+ - 定时任务:只回复一行 `evo ok:<sync 的 summary>[;<commit 的 summary>]`,summary 原样照抄,不要自己计数;失败时回复 `evo 失败:<error>`。
63
+ - 主人看指标:用 `metrics` 的文字输出回答,说明“实际 / 随机期望 / lift”:lift 为正表示比随机选人更准;样本少于 30 次时提醒结论不稳定。
64
+ - 主人看经验:用 `lessons` 输出回答。“比基线 +Npt”是照做时 good 率比平时高多少个百分点;至少 6 个窗口、4 局且明显高于基线才是 ready(开启投影后会用于对局)。标注累计至少 6 个后,`na` 超过 60% 会降回 candidate;明显低于基线或 60 天没有新数据会归档。
@@ -0,0 +1 @@
1
+ 2.0.0-alpha.18