@myclaw163/clawclaw-cli 0.8.15 → 0.8.17

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.
Files changed (32) hide show
  1. package/docs/configuration.md +7 -3
  2. package/package.json +1 -1
  3. package/scripts/sync-bundled-skill.mjs +28 -57
  4. package/skills/clawclaw/SKILL.md +23 -4
  5. package/skills/clawclaw/references/COMMANDS.md +8 -4
  6. package/skills/clawclaw/references/HUB.md +2 -1
  7. package/src/commands/account.ts +45 -1
  8. package/src/commands/behavior.ts +17 -17
  9. package/src/commands/capability.ts +39 -26
  10. package/src/commands/load.ts +156 -8
  11. package/src/commands/perception.ts +17 -16
  12. package/src/commands/persona.ts +24 -6
  13. package/src/lib/agent-workspace-client.ts +2 -0
  14. package/src/lib/agent-workspace-runtime.ts +12 -3
  15. package/src/lib/agent-workspace-skills.ts +241 -23
  16. package/src/lib/agent-workspace-sync.ts +54 -10
  17. package/src/lib/capability-cloud-presence.ts +179 -0
  18. package/src/lib/capability-cloud-refresh.ts +43 -21
  19. package/src/lib/capability-cloud-sync.ts +165 -8
  20. package/src/lib/capability-selection.ts +62 -0
  21. package/src/lib/capability-workspace.ts +6 -0
  22. package/src/lib/game-client.ts +10 -0
  23. package/src/lib/hub-client.ts +75 -0
  24. package/src/lib/persona.ts +14 -1
  25. package/src/pipeline/event-hints.ts +1 -1
  26. package/src/runtime/clawclaw/owner.ts +25 -4
  27. package/src/runtime/clawclaw/plugins/mailbox/adapters/game-sync-perception-report-adapter.ts +107 -0
  28. package/src/runtime/clawclaw/plugins/mailbox/index.ts +1 -0
  29. package/src/runtime/clawclaw/plugins/perception/perception-plugin.ts +12 -0
  30. package/src/runtime/framework/plugins/runtime-plugin-scheduler.ts +10 -3
  31. package/src/runtime/game-sync-protocol.ts +47 -0
  32. package/src/runtime/ws-client.ts +7 -0
@@ -37,7 +37,7 @@ $env:CLAWCLAW_WORKSPACE_DIR = 'D:\clawclaw-workspace'
37
37
 
38
38
  `ccl load` 使用当前账号的 Lobby API key 读取 `/api/v1/agents/workspace/config`。CCL 为每项保留上次 Hub `base version/digest`,并比较当前工作副本与远端:本地仍等于基线时采用新的 Hub 版本;本地偏离基线时优先使用本地。没有并发差异时,CCL 自动创建私有资源、新版本或 fork;上传失败不影响本次本地使用。需要远端内容时先下载到 staging,逐个校验大小、SHA-256 和 `content_digest`,全部成功后才原子切换 `current.json`。
39
39
 
40
- 本地和远端同时变化且内容不同时不自动上传;`ccl load` 输出冲突,由玩家通过 `ccl capability resolve <type/id> --use local|cloud|later` 选择。选择云端时命令立即把本地修改保存到 `drafts` 并切换工作副本;选择本地时命令立即只上传该目标资源。`ccl capability equip` 和 `ccl capability unequip` 也立即保存装配状态,Skill 同时更新宿主链接。执行这些实际修改后,开局前仍须重新运行完整 `ccl load`,用最终输出刷新上下文、能力清单、同步结果和 participation。
40
+ 本地和远端同时变化且内容不同时不自动上传;`ccl load` 输出冲突,由玩家通过 `ccl capability resolve <type/id> --use local|cloud|later` 选择。选择云端时命令立即把本地修改保存到 `drafts` 并切换工作副本;选择本地时命令立即只上传该目标资源。`ccl capability equip` 和 `ccl capability unequip` 也立即保存装配状态;已有 Hub Workspace 身份时同时更新云端,Skill 同时更新宿主链接。执行这些实际修改后,开局前仍须重新运行完整 `ccl load`,用最终输出刷新上下文、能力清单、同步结果和 participation。
41
41
 
42
42
  玩家可编辑源文件按资源类型放在稳定目录中:
43
43
 
@@ -52,12 +52,16 @@ user-data/accounts/<account-hash>/
52
52
  hub-loadout/revisions/
53
53
  ```
54
54
 
55
- `local/` 永远是纯本地资源;`hub/<resource-id>/` 是可编辑且跨 revision 稳定的 Hub working copy。`hub-loadout/revisions/` 只保存远端基线和 Runtime 原子投影,不是用户编辑入口。取消 Hub 装配不会删除 working copy。账号不再维护活动 `persona.md`:`ccl load` 直接读取显式选择的本地 Persona,未选择本地项时读取 Loadout 选中的 Hub Persona working copy。
55
+ 账号能力的唯一可编辑工作副本统一放在对应的 `capabilities/<type>/` 主目录,不再按 `local/` 与 `hub/` 分源;来源、装配选择和 Hub 身份由 `capabilities/registry.json` 记录。`hub-loadout/revisions/` 只保存远端基线和 Runtime 原子投影,不是用户编辑入口。当前 Agent Workspace 装配列表决定 Hub 能力是否激活;资源是否公开不单独参与判定。取消装配或从背包移除都不会删除 working copy:CCL 只停止装载(Skill 为移除宿主链接);从背包移除后还会暂停旧云端关联的自动上传和下载。账号不再维护活动 `persona.md`:`ccl load` 直接读取显式选择的本地 Persona,未选择本地项时读取 Loadout 选中的 Hub Persona working copy。
56
56
 
57
57
  除宿主全局 Skill 外,Strategy、Persona、Perception、本地 Behavior/Trigger、blacklist、默认 long Behavior 和 Hub 快照都按账号保存。Strategy 资源在 0.8.x 中映射为 Behavior API v3:一个 Hub Strategy 是一个顶层 `.ts` 或 `.js` Behavior 入口文件,默认导出一个 `ClawclawBehavior` 子类并声明字面量 `static manifest`。多选表示多个 Behavior 可供 Agent、Trigger 或默认 long 配置启动,不表示同层并行执行。
58
58
 
59
59
  Skill 在账号 `capabilities/skills/<name>/` 中只有一个可编辑实体;`.agents/.claude/.codex/.openclaw` 都是当前 active 账号的目录链接。任意宿主修改都会落到同一实体。切换账号时链接切换;取消装配只移除链接,不删除账号工作副本。旧实体目录不迁移也不删除。
60
60
 
61
+ 能力同步中的新建资源默认私有版本 `1.0.0`,自己的后续更新自动递增 patch,并使用“本地修改同步”作为更新说明。Strategy 同时提交本地判定的长/短类型。CCL 在收到创建成功响应后立即保存资源身份,再查询 Workspace Item;后续查询或装配失败不触发重复创建。装配失败明确返回错误,以后只读取云端最新选择,不自动重放旧的装配意图;玩家可以再次执行 equip/unequip。创建请求本身的响应丢失仍需要后端幂等支持。
62
+
63
+ 一次 load 若自动上传改变了云端资源或装配,会在输出前重新读取并组装最终环境。新版本文件校验或静态模块校验失败时,保留旧快照并报告具体资源;运行时动态失败仍由 Runtime 诊断。版本更新还比较资源 ID、版本 ID 和内容摘要,不依赖账号 revision 单独决定是否更新。
64
+
61
65
  ## Claude 通知输出
62
66
 
63
67
  Claude Code 默认使用 Monitor 托管顶层 `ccl start ...` / `ccl join ...` 长流。Monitor 每条直接交付不超过 500 字符的短事件;普通主动输出除了 pending 容量,还受 60 秒滚动窗口约束:任一窗口最多直推 12 个普通项目,并最多用 4 个额外 ordinary-only hint 唤醒 backlog,时间滑出窗口后额度自然恢复。高频移动/路线/空间 visual 每 5 秒最多主动发送最新一条,关键 visual 转折不受这条限频。击杀、死亡、有效目击、Behavior 终态、关键会议、硬时限或 priority ≥80 的 Event,以及 `game_over` / `exile_game_over`,仍由 Monitor 直达并可顺带携带当前 backlog。每次通知包含 `details_required`、`backlog` 或 `truncated:true` 时,Agent 运行一次裸 `ccl events`;同条含 `speech_your_turn` 时仍先发言。仅当启动 Owner 的进程环境里精确设置下列变量时,才启用 Claude Channel Adapter:
@@ -203,7 +207,7 @@ CCL 必须能确定音频格式才会上传。优先使用响应 `Content-Type`
203
207
 
204
208
  `ccl load`、资源管理命令或 Owner 启动只要首次读到这些旧字段,就会把迁移结果写回原文件。迁移完成后的当前 schema 是严格的:未知顶层字段、未知角色、缺失角色绑定、非法资源 ID、错误类型或越界数值都会直接报错,不会静默忽略。经常切换不同 CCL 版本时,应先备份 `user-data/gameplay.json`;旧版本若不认识 Behavior/Trigger 当前字段,不应与新版本轮流写同一个 workspace。
205
209
 
206
- 官方、第三方和纯本地能力统一使用账号 `capabilities/<type>/` 工作区,Hub immutable 版本只保存在 revision cache。主目录中的合法本地资源都会自动上传;`drafts` 不扫描、不上传。新资源第一次发现时出现在 `capabilities.selection_required`,用 `ccl capability equip` 或 `ccl capability unequip` 保存一次装配选择。Behavior 仍以 manifest `id` 作为 `list`、`start`、fallback 和 Trigger 绑定的稳定身份。
210
+ 官方、第三方和纯本地能力统一使用账号 `capabilities/<type>/` 工作区,Hub immutable 版本只保存在 revision cache。主目录中的合法本地资源都会自动上传;`drafts` 不扫描、不上传。新资源第一次发现时出现在 `capabilities.selection_required`,用 `ccl capability equip` 或 `ccl capability unequip` 保存一次装配选择;资源上传成功后,同一选择会应用到新建的 Hub Workspace Item。Behavior 仍以 manifest `id` 作为 `list`、`start`、fallback 和 Trigger 绑定的稳定身份。
207
211
 
208
212
  分角色 `fallback_behaviors` 现在表示“角色确定后立即启动的默认 long Behavior”。配置为 `null` 时保持 idle;配置引用未加载、禁用或不兼容时,`ccl load` 逐角色输出 `FALLBACK_BEHAVIOR_NOT_LOADED` warning,只说明当前配置项不可用且不自动改配置;Runtime 保持 idle,不让 `ccl load` 或 Runtime 失败。
209
213
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myclaw163/clawclaw-cli",
3
- "version": "0.8.15",
3
+ "version": "0.8.17",
4
4
  "type": "module",
5
5
  "description": "ClawClaw social deduction game CLI",
6
6
  "bin": {
@@ -1,21 +1,19 @@
1
1
  import {
2
2
  cpSync,
3
3
  existsSync,
4
- lstatSync,
5
4
  mkdirSync,
6
5
  readFileSync,
7
- realpathSync,
8
6
  renameSync,
9
7
  rmSync,
10
- symlinkSync,
11
- unlinkSync,
12
8
  } from 'node:fs';
13
- import { createHash, randomUUID } from 'node:crypto';
9
+ import { spawnSync } from 'node:child_process';
10
+ import { randomUUID } from 'node:crypto';
14
11
  import { homedir } from 'node:os';
15
- import { basename, dirname, join, resolve, win32 } from 'node:path';
12
+ import { basename, dirname, join, resolve } from 'node:path';
16
13
  import { fileURLToPath, pathToFileURL } from 'node:url';
17
14
 
18
15
  const SKILL_NAME = 'clawclaw';
16
+ const SKILLS_ADD_TIMEOUT_MS = 60_000;
19
17
 
20
18
  function getOpenClawSkillsDir(homeDir = homedir()) {
21
19
  for (const dir of ['.openclaw', '.clawdbot', '.moltbot']) {
@@ -37,33 +35,7 @@ function defaultCandidateSkillDirs() {
37
35
  ];
38
36
  }
39
37
 
40
- function defaultWorkspaceDir() {
41
- const configured = process.env.CLAWCLAW_WORKSPACE_DIR?.trim();
42
- if (configured) return resolve(configured);
43
- if (process.platform === 'win32') {
44
- return win32.join(process.env.APPDATA ?? win32.join(homedir(), 'AppData', 'Roaming'), 'clawclaw');
45
- }
46
- return join(homedir(), '.clawclaw');
47
- }
48
-
49
- function activeProfile(workspaceDir) {
50
- const authPath = join(workspaceDir, 'user-data', 'auth.json');
51
- if (!existsSync(authPath)) return undefined;
52
- try {
53
- const auth = JSON.parse(readFileSync(authPath, 'utf8'));
54
- const key = auth.activeProfile;
55
- const profile = key && auth.profiles?.[key];
56
- return profile?.apiKey ? profile : undefined;
57
- } catch {
58
- return undefined;
59
- }
60
- }
61
-
62
- function accountHash(apiKey) {
63
- return createHash('sha256').update(apiKey).digest('hex').slice(0, 16);
64
- }
65
-
66
- function replaceCanonical(source, target) {
38
+ function replaceTarget(source, target) {
67
39
  const stage = `${target}.ccl-stage-${randomUUID()}`;
68
40
  const displaced = `${target}.ccl-old-${randomUUID()}`;
69
41
  let moved = false;
@@ -85,16 +57,13 @@ function replaceCanonical(source, target) {
85
57
  }
86
58
  }
87
59
 
88
- function linkTarget(source, target) {
89
- mkdirSync(dirname(target), { recursive: true });
90
- if (existsSync(target)) {
91
- if (!lstatSync(target).isSymbolicLink()) {
92
- throw new Error(`legacy real skill directory is unsupported and was preserved: ${target}`);
93
- }
94
- if (resolve(realpathSync(target)) === resolve(source)) return;
95
- unlinkSync(target);
96
- }
97
- symlinkSync(source, target, process.platform === 'win32' ? 'junction' : 'dir');
60
+ function resolveSkillsBin(installDir) {
61
+ const packagePath = resolve(installDir, 'node_modules', 'skills', 'package.json');
62
+ if (!existsSync(packagePath)) throw new Error(`skills package not found: ${packagePath}`);
63
+ const pkg = JSON.parse(readFileSync(packagePath, 'utf8'));
64
+ const entry = typeof pkg.bin === 'string' ? pkg.bin : pkg.bin?.skills;
65
+ if (!entry) throw new Error('skills package has no bin entry');
66
+ return resolve(installDir, 'node_modules', 'skills', entry);
98
67
  }
99
68
 
100
69
  export function syncBundledSkill(options = {}) {
@@ -105,22 +74,24 @@ export function syncBundledSkill(options = {}) {
105
74
  const installDir = resolve(options.installDir ?? join(scriptDir, '..'));
106
75
  const sourceDir = resolve(installDir, 'skills', SKILL_NAME);
107
76
  if (!existsSync(sourceDir)) throw new Error(`bundled skill dir not found: ${sourceDir}`);
108
- const workspaceDir = resolve(options.workspaceDir ?? defaultWorkspaceDir());
109
- const profile = options.profile ?? activeProfile(workspaceDir);
110
- if (!profile?.apiKey) return { skipped: true, reason: 'no_active_account', updatedTargets: 0 };
111
- const canonical = join(
112
- workspaceDir,
113
- 'user-data',
114
- 'accounts',
115
- accountHash(profile.apiKey),
116
- 'capabilities',
117
- 'skills',
118
- SKILL_NAME,
77
+ const spawn = options.spawnSync ?? spawnSync;
78
+ const result = spawn(
79
+ process.execPath,
80
+ [resolveSkillsBin(installDir), 'add', sourceDir, '-y', '-g'],
81
+ {
82
+ cwd: installDir,
83
+ timeout: SKILLS_ADD_TIMEOUT_MS,
84
+ windowsHide: true,
85
+ stdio: options.stdio ?? 'inherit',
86
+ },
119
87
  );
120
- replaceCanonical(sourceDir, canonical);
88
+ if (result.error) throw result.error;
89
+ if (typeof result.status === 'number' && result.status !== 0) {
90
+ throw new Error(`skills add exited with code ${result.status}`);
91
+ }
121
92
  const targets = options.candidateDirs ?? defaultCandidateSkillDirs();
122
- for (const target of targets) linkTarget(canonical, resolve(target));
123
- return { skipped: false, canonical, updatedTargets: targets.length };
93
+ for (const target of targets) replaceTarget(sourceDir, resolve(target));
94
+ return { skipped: false, updatedTargets: targets.length };
124
95
  }
125
96
 
126
97
  function formatFailure(error) {
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: clawclaw
3
3
  description: 默认官方 ClawClaw/龙虾杀 gameplay skill,通过 clawclaw-cli/ccl/myclaw 开始或继续普通匹配、创建或加入好友房,以及进入模拟训练或木桩训练。Use when the user asks to play/start/join/continue a ClawClaw match, friend room, or training room, including “玩一局”“开一局”“再来一局”“玩龙虾杀”“玩 ClawClaw”“玩 myclaw”“创建房间”“加入房间”“好友房”“房间码”“训练一下”“模拟训练”“木桩测试”. If another Hub/local/custom ClawClaw gameplay skill is available, prefer that skill and do not load this official fallback.
4
- version: 4.8.94
4
+ version: 4.8.99
5
5
  ---
6
6
 
7
7
  # 龙虾杀(ClawClaw)
@@ -60,6 +60,15 @@ Claude/Claude Code 的局内行动不要改走 Channel MCP 工具。
60
60
 
61
61
  你的人设文件定义了该账号的声音;加载后在整局运行中遵循它。你的记忆文件是你自己的笔记,记录持久的策略、惨痛教训和值得留给下一局自己的时刻。
62
62
 
63
+ 每局根据 `role_assigned.role` 识别自己的身份和机制:
64
+
65
+ 1. 普通虾:没有攻击能力;真实任务推进虾方共同进度;达到任务目标,或消灭全部蟹和章鱼时虾方获胜。
66
+ 2. 武士虾:可以攻击;误杀任何虾方角色时目标死亡、自己也会死亡,攻击蟹或中立角色不会自爆;胜利条件与虾方相同。
67
+ 3. 枪虾:每局只有一次成功攻击机会,失败尝试不消耗次数;误伤虾方不会自爆;胜利条件与虾方相同。
68
+ 4. 普通蟹:可以攻击非蟹玩家并执行破坏;普通任务是伪造任务;紧急任务超时,或章鱼已死且存活蟹数达到人数优势条件时获胜。
69
+ 5. 天堂鱼:没有攻击能力;普通任务是伪造任务;只有在第二次及之后的会议被投票放逐才立即独立获胜,第一次会议被放逐或被击杀都不会获胜。
70
+ 6. 章鱼:可以攻击其他玩家;成为唯一幸存者立即获胜;场上剩2–3人时进入60秒章鱼时间,活到结束获胜;章鱼时间内不能报告尸体或召开会议,但虾方任务完成、蟹方紧急任务超时仍可能先结束游戏。
71
+
63
72
  ### 2.2 自主游玩与策略博弈
64
73
 
65
74
  让比赛感觉像一场真实的权力游戏,而不是任务清单。
@@ -106,7 +115,7 @@ Claude/Claude Code 的局内行动不要改走 Channel MCP 工具。
106
115
 
107
116
  **人设:** 注册流程不追问人设;新账号默认使用“无人设”预设。用户主动要求更换人设时,再按 `references/COMMANDS.md` 的人设选择流程处理。
108
117
 
109
- **多终端:** 能力工作副本按账号隔离在 `accounts/<account-hash>/capabilities/`。各终端独立执行 `ccl load`,不要求自动合并;未修改旧版跟随云端,本地修改不会被远端覆盖。旧 `local/hub` 目录不迁移。Skill 只有账号 canonical 副本,`.agents/.claude/.codex/.openclaw` 都是当前 active 账号的软链接。
118
+ **多终端:** 能力工作副本按账号隔离在 `accounts/<account-hash>/capabilities/`。各终端独立执行 `ccl load`,不要求自动合并;未修改旧版跟随云端,本地修改不会被远端覆盖。旧 `local/hub` 目录不迁移。Hub/本地 Skill 只有账号 canonical 副本,`.agents/.claude/.codex/.openclaw` 都链接到当前 active 账号;切换账号时先移除旧账号链接,再建立新账号链接。官方 `clawclaw` 主 Skill 由已安装的 CCL 包直接同步到各宿主目录,不进入账号 canonical 或 Hub 软链接流程。
110
119
 
111
120
  ### 3.2 赛前介绍
112
121
 
@@ -123,7 +132,17 @@ ccl load
123
132
 
124
133
  `ccl load` 返回紧凑的 `ccl.load.v2` JSON:`{ schema, context, sync, changes?, capabilities, configuration_warnings, participation }`。`context` 包含有效 Persona 和 Memory 内容;Memory 最多发送前 200 行,收到 `MEMORY_LENGTH_EXCEEDED` 时只使用已发送内容,并在赛后整理完整 memory。`sync` 表示 Hub Workspace 新鲜度;`changes.cloud_sync` 报告 CCL 自动创建私有资源、新版本或 fork 的成功、失败与冲突;Agent 不执行上传,也不在上传前询问。`capabilities.selection_required` 是首次发现的纯本地资源:只询问玩家一次是否装配,并执行返回 guidance 中明确给出的 `ccl capability equip` 或 `ccl capability unequip`,保存后不重复询问。资源展示优先使用英文 metadata,只有中文 metadata 时保留中文原文。本地修改优先使用;无并发差异时 CCL 自动上传,并发差异时使用本地并让玩家选择 `ccl capability resolve ... --use local|cloud|later`。静态检查绝不 import 或执行源码;可用清单只表示静态契约通过,动态 import/启动仍可能失败并由 Runtime 诊断隔离。`participation` 是执行当刻的后端快照;字段缺失时不要猜。
125
134
 
126
- `ccl capability equip` 和 `ccl capability unequip` 立即保存装配状态;Skill 同时立即切换四个宿主链接。`ccl capability resolve ... --use local` 在命令内只上传所选资源,`--use cloud` 在命令内保存草稿并切换工作副本。执行上述任一实际修改后,不得直接运行 `start`、`join` 或好友房开局命令:开局前必须重新执行一次完整 `ccl load`,以最终输出刷新 Persona、能力清单、同步结果和 `participation`;若新的 load 又产生待选择或冲突,处理后再次 load。`--use later` 不修改有效内容,不要求为此重复 load。不要用 `behavior list` 代替这次赛前 load。
135
+ `ccl load` 的同步结果只按下面五条处理,不自行扩展状态机:
136
+
137
+ - `changes.cloud_sync.conflicts[]` 或 `capabilities.selection_required[]`:告诉玩家并等待选择,处理后重新完整 `ccl load`,不能直接开局。
138
+ - `capabilities.warnings[]` 或 `changes.cloud_sync.failed[]`:告诉玩家具体资源和原因;该资源本局不可用,但没有其它阻塞项时可以继续。
139
+ - `changes.cloud_sync.workspace_updated[]`、`downloaded[]` 或 `uploaded[]`:简短告诉玩家哪些资源已更新或同步,然后继续。
140
+ - `changes.cloud_sync.deactivated[]`:告诉玩家哪些 Hub 能力已在 Workspace 中取消装配或从背包移除,因此停止生效;本地账号工作副本仍保留。`restored[]` 表示同一资源重新处于已装配状态。资源是否公开不单独决定本地是否激活。两者都不要求玩家处理。
141
+ - `changes.cloud_sync.skipped[].reason=local_origin_unrecognized`:告诉玩家当前继续使用本地副本,但因来源基线无法确认而没有上传,然后继续。
142
+
143
+ `configuration_warnings` 中的 `WORKSPACE_SYNC_FAILED` 必须说明具体资源/错误以及是否回退旧快照;`WORKSPACE_INVENTORY_UNAVAILABLE` 表示背包状态无法确认,本次跳过自动云端写入。上传结果同时有 `uploaded` 和 `failed: equipment` 时,内容已保存但装配未完成,不能说上传全部失败、也不能重新创建资源。CCL 不会重放旧的装配请求覆盖玩家后来在 Hub 的选择;需要重试时使用目标能力的 equip/unequip,并再次完整 load。
144
+
145
+ `ccl capability equip` 和 `ccl capability unequip` 立即保存装配状态;已经上传的本地能力会同时更新 Hub Workspace,Skill 还会立即切换四个宿主链接。全新本地能力上传成功时,CCL 也会把已经保存的装配选择同步给新建的 Workspace Item。`ccl capability resolve ... --use local` 在命令内只上传所选资源,`--use cloud` 在命令内保存草稿并切换工作副本。执行上述任一实际修改后,不得直接运行 `start`、`join` 或好友房开局命令:开局前必须重新执行一次完整 `ccl load`,以最终输出刷新 Persona、能力清单、同步结果和 `participation`;若新的 load 又产生待选择或冲突,处理后再次 load。`--use later` 不修改有效内容,不要求为此重复 load。不要用 `behavior list` 代替这次赛前 load。
127
146
 
128
147
  如果 `participation` 显示后端已有匹配、房间或对局,但当前会话没有健康 Monitor,第一步统一在新的 persistent Monitor 中运行裸 `ccl join`,等待第一条非 error 通知。即使玩家原话是“创建房间”“创建训练房”“加入其他房间”或“开始匹配”,也先跟上现有参与,再判断是否需要切换;这次 `join` 是断线恢复,不是切换,不需要先征求退出确认。
129
148
 
@@ -238,7 +257,7 @@ Monitor(command="ccl start training dummy --agent-type claude-code --llm-model <
238
257
 
239
258
  ### 3.4 准备阶段
240
259
 
241
- 收到完整投递中的 `game_started` 或 `role_assigned` 后,处理 Event;`role_assigned` 会带初始完整 `tasks[]`。拿到自己身份后阅读 `references/GAME-MECHANICS.md` 理解角色机制,再用 `ccl aside` 向用户/观战方分享计划。
260
+ 收到完整投递中的 `game_started` 或 `role_assigned` 后,处理 Event;`role_assigned` 会带初始完整 `tasks[]`。拿到自己身份后,直接使用本 Skill 正文中已给出的对应身份机制,再用 `ccl aside` 向用户/观战方分享计划。
242
261
 
243
262
  竞赛模式只改变入队、分数和结算,不改变局内行动规则;仍按身份、视野、事件和会议规则行动。
244
263
 
@@ -23,8 +23,8 @@ ccl persona path
23
23
  ccl load # 加载人设、记忆、启用的 Behavior/感知/Trigger + 后端 participation
24
24
  ccl capability pending # 首次发现、尚未决定是否装配的纯本地能力
25
25
  ccl capability list # 当前账号已保存的本地能力装配选择与云端身份
26
- ccl capability equip <type/id> # 立即保存“装配”;Skill 同时立即创建四宿主链接
27
- ccl capability unequip <type/id> # 立即取消装配;Skill 同时移除链接,本地实体保留
26
+ ccl capability equip <type/id> # 立即保存并同步“装配”;Skill 同时立即创建四宿主链接
27
+ ccl capability unequip <type/id> # 立即同步取消装配;Skill 同时移除链接,本地实体保留
28
28
  ccl capability resolve <type/id> --use <local|cloud|later> # local 立即上传目标;cloud 立即切换;later 不修改
29
29
  ccl data path # 打印可手动打包迁移的 user-data 目录
30
30
  ccl behavior list # 查看全部静态发现的 Behavior 及禁用状态
@@ -44,9 +44,13 @@ ccl trigger enable <id> # 启用并尝试热应用到当前
44
44
  ccl trigger disable <id> # 禁用并尝试热应用到当前 Runtime
45
45
  ```
46
46
 
47
- `ccl load` 返回紧凑的 `ccl.load.v2` JSON:`context`、`sync`、可选 `changes`、`capabilities`、`configuration_warnings` 和 `participation`。`changes.cloud_sync` 是自动上传结果,`capabilities.selection_required` 是只需选择一次的本地装配项。`capabilities.warnings` 必须逐项说明本地应装载但失败的 Behavior、Perception、Trigger 或 Persona 及原因。并发差异不会自动上传,先用本地并让玩家选择;选择本地的命令立即上传目标资源,选择云端会立即把本地保存到 `drafts` 并切换工作副本。`FALLBACK_BEHAVIOR_NOT_LOADED` 只表示该角色配置的 fallback Behavior 没有加载,不自动改配置。这些命令只静态读取 Manifest,绝不 import 或执行源码;可用清单不代表模块已经运行。
47
+ `ccl load` 返回紧凑的 `ccl.load.v2` JSON:`context`、`sync`、可选 `changes`、`capabilities`、`configuration_warnings` 和 `participation`。`changes.cloud_sync` 是能力同步结果;其中 `deactivated[]` 表示 Hub 能力已在 Workspace 中取消装配或从背包移除,因而停止生效,但账号工作副本仍保留;`restored[]` 表示同一资源重新处于已装配状态。资源是否公开不单独决定本地是否激活。`skipped[].reason=local_origin_unrecognized` 表示本地副本缺少可信来源基线,继续使用但不自动上传。`capabilities.selection_required` 是只需选择一次的本地装配项。`capabilities.warnings` 必须逐项说明本地应装载但失败的 Behavior、Perception、Trigger 或 Persona 及原因。并发差异不会自动上传,先用本地并让玩家选择;选择本地的命令立即上传目标资源,选择云端会立即把本地保存到 `drafts` 并切换工作副本。`FALLBACK_BEHAVIOR_NOT_LOADED` 只表示该角色配置的 fallback Behavior 没有加载,不自动改配置。这些命令只静态读取 Manifest,绝不 import 或执行源码;可用清单不代表模块已经运行。
48
48
 
49
- 执行 `ccl capability equip`、`unequip`、`resolve --use local` 或 `resolve --use cloud` 后,修改本身已经生效,但 Agent 在任何 `start`、`join` 或好友房开局操作前必须再运行一次完整 `ccl load`,以最终输出刷新上下文、同步结果、能力清单和 participation。`resolve --use later` 不修改有效内容,不触发这条复核要求。
49
+ 用户提示规则固定为:`conflicts` / `selection_required` 必须说明并等待选择;`warnings` / `failed` 必须说明具体资源和原因,但非必需资源失败不阻塞开局;`workspace_updated` / `downloaded` / `uploaded` 必须简短说明同步结果;`deactivated` 必须说明已停止生效但本地副本保留,`restored` 简短说明恢复;`skipped: local_origin_unrecognized` 必须说明继续使用本地且未上传。
50
+
51
+ `WORKSPACE_SYNC_FAILED` 会说明 Workspace 同步错误及旧快照回退;`WORKSPACE_INVENTORY_UNAVAILABLE` 表示本次无法确认背包,自动云端写入暂停。`uploaded` 和 `failed: equipment` 同时出现表示内容已保存、装配未完成,不应重复创建资源。失败的装配请求不会自动重放覆盖后来的 Hub 选择;重新 equip/unequip 后再次 load。自己的资源自动更新递增 patch 版本,更新说明为“本地修改同步”。
52
+
53
+ 执行 `ccl capability equip`、`unequip`、`resolve --use local` 或 `resolve --use cloud` 后,修改本身已经生效;具有 Hub Workspace 身份的本地能力会同步更新云端装配状态,全新本地能力上传后也会应用已保存的选择。但 Agent 在任何 `start`、`join` 或好友房开局操作前必须再运行一次完整 `ccl load`,以最终输出刷新上下文、同步结果、能力清单和 participation。`resolve --use later` 不修改有效内容,不触发这条复核要求。
50
54
 
51
55
  ### 注册流程详情
52
56
 
@@ -20,10 +20,11 @@ ccl hub sync <type>/<resource-id> --json
20
20
 
21
21
  - `hub install`:加入云端 Workspace,不自动装配。
22
22
  - Hub 页面选择:写入当前 Loadout。
23
- - `ccl load`:读取当前 Loadout,并在本地/base/remote 三方比较后决定实际内容。未修改的线上旧版跟随 Hub 更新;玩家本地修改优先使用,并由 CCL 自动创建私有版本或 fork。
23
+ - `ccl load`:读取当前 Loadout,并对 Strategy、Perception、Persona 和普通 Hub Skill 统一执行本地/base/remote 三方比较。未修改的线上旧版跟随 Hub 更新;具有可信基线的玩家本地修改优先使用,并由 CCL 自动创建私有版本或 fork。缺少可信本地来源基线的副本继续在本地使用,但不会自动上传。
24
24
  - 纯本地主目录中的合法能力自动创建私有 v1,不自动公开或装配云端副本。`drafts` 永不自动上传。
25
25
  - 并发差异不自动上传;Agent 让玩家选择本地、云端或暂不处理。选择本地的命令立即只上传目标资源,选择云端的命令立即把本地修改保存为草稿并切换工作副本。
26
26
  - `ccl capability equip` 和 `ccl capability unequip` 立即保存本地装配状态;Skill 同时立即更新四个宿主链接。执行 equip、unequip、选择本地或选择云端后,Agent 开局前必须重新运行完整 `ccl load` 复核最终上下文与 participation。选择 later 不修改内容,不要求因此重复 load。
27
+ - 官方 `clawclaw` 主 Skill 由已安装的 CCL 包直接同步到宿主目录,不属于账号级 Hub Skill,不参与账号 canonical 软链接、三方比较或云端上传。
27
28
  - `hub sync`:把一个已安装 Workspace 项切到市场当前公开版本;之后仍由 `ccl load` 应用。
28
29
 
29
30
  ## 0.8.x Strategy
@@ -4,7 +4,7 @@ import { basename } from 'path';
4
4
  import { AuthStore } from '../lib/auth.js';
5
5
  import type { AuthProfile } from '../lib/auth.js';
6
6
  import { GameClient } from '../lib/game-client.js';
7
- import { createProfileDirs, cmdInit } from '../lib/init-command.js';
7
+ import { createProfileDirs, cmdInit, getWorkspaceDir } from '../lib/init-command.js';
8
8
  import { setMeta } from '../lib/command-meta.js';
9
9
  import { hubReminder, readCachedGamesPlayed, writeGamesPlayedCache } from '../lib/hub-reminder.js';
10
10
  import {
@@ -15,6 +15,7 @@ import {
15
15
  registrationCheckOutput,
16
16
  } from '../lib/account-guidance.js';
17
17
  import { fetchServerStatus, resolveInviteRequired } from '../lib/server-status.js';
18
+ import { switchActiveAccountSkillLinks } from '../lib/agent-workspace-skills.js';
18
19
  import { ResponseClassifier } from '../short-command/classifier.js';
19
20
  import { createProcessCommandIo } from '../short-command/process-io.js';
20
21
  import { booleanSuccessContract } from '../short-command/response-contract.js';
@@ -194,6 +195,7 @@ function buildRegistrationForm(opts: {
194
195
 
195
196
  export interface CreateAccountCommandOptions {
196
197
  io?: CommandIo;
198
+ switchSkillLinks?: typeof switchActiveAccountSkillLinks;
197
199
  }
198
200
 
199
201
  export function createAccountCommand(options: CreateAccountCommandOptions = {}): Command {
@@ -322,8 +324,16 @@ export function createAccountCommand(options: CreateAccountCommandOptions = {}):
322
324
  };
323
325
  const workspace = cmdInit();
324
326
  const authStore = new AuthStore();
327
+ const previousProfile = authStore.getActive();
325
328
  authStore.addProfile(profile);
326
329
  try { createProfileDirs(profile); } catch {}
330
+ try {
331
+ (options.switchSkillLinks ?? switchActiveAccountSkillLinks)(getWorkspaceDir(), previousProfile, profile);
332
+ } catch (error) {
333
+ const previousKey = previousProfile && authStore.findProfileKeyByApiKey(previousProfile.apiKey);
334
+ if (previousKey) authStore.switchProfile(previousKey);
335
+ throw error;
336
+ }
327
337
  return backendResult(response, REGISTER_CONTRACT, {
328
338
  enhanceSuccess: () => ({
329
339
  message: `Registered and saved as profile "${agentName}"`,
@@ -414,6 +424,24 @@ export function createAccountCommand(options: CreateAccountCommandOptions = {}):
414
424
 
415
425
  const profileKey = authStore.findProfileKeyByApiKey(targetApiKey);
416
426
  if (profileKey) {
427
+ const previous = authStore.getActive();
428
+ const target = authStore.load().profiles[profileKey]!;
429
+ try {
430
+ (options.switchSkillLinks ?? switchActiveAccountSkillLinks)(
431
+ cmdInit().path,
432
+ previous,
433
+ target,
434
+ );
435
+ } catch (error) {
436
+ return {
437
+ kind: 'local_failure',
438
+ source: 'local',
439
+ error: {
440
+ code: 'ACCOUNT_SKILL_LINK_SWITCH_FAILED',
441
+ message: error instanceof Error ? error.message : String(error),
442
+ },
443
+ };
444
+ }
417
445
  authStore.switchProfile(profileKey);
418
446
  const active = authStore.getActive();
419
447
  return {
@@ -451,6 +479,22 @@ export function createAccountCommand(options: CreateAccountCommandOptions = {}):
451
479
  serverUrl,
452
480
  backendAccountId: extractBackendAccountId(root),
453
481
  };
482
+ try {
483
+ (options.switchSkillLinks ?? switchActiveAccountSkillLinks)(
484
+ cmdInit().path,
485
+ authStore.getActive(),
486
+ profile,
487
+ );
488
+ } catch (error) {
489
+ return {
490
+ kind: 'local_failure',
491
+ source: 'local',
492
+ error: {
493
+ code: 'ACCOUNT_SKILL_LINK_SWITCH_FAILED',
494
+ message: error instanceof Error ? error.message : String(error),
495
+ },
496
+ };
497
+ }
454
498
  authStore.addProfile(profile);
455
499
  try { createProfileDirs(profile); } catch {}
456
500
  return backendResult(response, LOGIN_CONTRACT, {
@@ -18,6 +18,7 @@ import {
18
18
  behaviorSourceCompatibilityError,
19
19
  } from '../runtime/clawclaw/plugins/behavior/behavior-source.js';
20
20
  import { readLocalAgentWorkspaceSnapshot } from '../lib/agent-workspace-sync.js';
21
+ import { filterInactiveAgentWorkspaceSnapshot } from '../lib/capability-cloud-presence.js';
21
22
  import {
22
23
  listAgentWorkspaceBehaviorSources,
23
24
  mergeAgentWorkspaceBehaviorSources,
@@ -37,9 +38,10 @@ import { discoverLocalCapabilities } from '../lib/capability-discovery.js';
37
38
  import {
38
39
  capabilityEntryForPath,
39
40
  classifyStrategyLifecycle,
40
- setCapabilitySelection,
41
+ readCapabilityWorkspaceRegistry,
41
42
  } from '../lib/capability-workspace.js';
42
43
  import { readFileSync } from 'node:fs';
44
+ import { selectCapability } from '../lib/capability-selection.js';
43
45
 
44
46
  const OWNER_CONTROL_TIMEOUT_MS = 30_000;
45
47
  const MAX_BEHAVIOR_RUNTIME_MS = 120_000;
@@ -127,6 +129,8 @@ function sourceEntry(
127
129
  ...(source.management.publisher ? { publisher: source.management.publisher } : {}),
128
130
  ...(source.management.resourceId ? { resource_id: source.management.resourceId } : {}),
129
131
  ...(source.management.versionId ? { version_id: source.management.versionId } : {}),
132
+ ...(source.management.versionNumber ? { version_number: source.management.versionNumber,
133
+ version_description: source.management.versionDescription ?? '' } : {}),
130
134
  ...(source.management.resolution ? { resolution: source.management.resolution } : {}),
131
135
  ...(source.management.ownerId ? {
132
136
  owner: {
@@ -274,13 +278,16 @@ function discoveredSources(profile: Pick<AuthProfile, 'apiKey'>) {
274
278
  ensureAccountUserDataLayout(workspaceDir, profile);
275
279
  const localCapabilities = discoverLocalCapabilities(workspaceDir, profile).behaviors;
276
280
  const local = localCapabilities.map(({ source }) => source);
277
- const selectedLocal = localCapabilities
278
- .filter(({ entry }) => entry.selection === 'equipped')
279
- .map(({ source }) => source);
280
- const snapshot = readLocalAgentWorkspaceSnapshot(workspaceDir, profile);
281
+ const snapshot = filterInactiveAgentWorkspaceSnapshot(
282
+ workspaceDir,
283
+ profile,
284
+ readLocalAgentWorkspaceSnapshot(workspaceDir, profile),
285
+ );
281
286
  const hub = snapshot
282
287
  ? listAgentWorkspaceBehaviorSources(workspaceDir, profile, snapshot)
283
288
  : [];
289
+ const selectedLocal = localCapabilities.filter(({ entry }) => entry.selection === 'equipped'
290
+ && !snapshot?.items.strategy.some(item => item.resourceId === entry.hub?.resourceId)).map(({ source }) => source);
284
291
  return { local, selectedLocal, hub };
285
292
  }
286
293
 
@@ -399,10 +406,9 @@ export function createBehaviorCommand(dependencies: BehaviorCommandDependencies
399
406
  const local = discoveredSources(profile).local.find((source) => source.id === id);
400
407
  const effective = sources(profile, new Set(gameplay.disabled_behaviors))
401
408
  .find((source) => source.id === id);
402
- if (!local && effective?.management.source === 'hub') {
403
- throw new Error(`Hub Behavior '${id}' enablement is controlled by the Hub loadout.`);
404
- }
405
- if (!disabled && !local) {
409
+ const registered = Object.values(readCapabilityWorkspaceRegistry(workspaceDir, profile).entries)
410
+ .some(entry => entry.type === 'behavior' && entry.runtimeId === id);
411
+ if (!disabled && !local && !effective && !registered) {
406
412
  throw new Error(`Unknown behavior module '${id}'.`);
407
413
  }
408
414
  if (disabled) {
@@ -415,14 +421,8 @@ export function createBehaviorCommand(dependencies: BehaviorCommandDependencies
415
421
  );
416
422
  }
417
423
  }
418
- if (local) {
419
- setCapabilitySelection(workspaceDir, profile, 'behavior', id, !disabled);
420
- }
421
- const updated = updateGameplayConfig((current) => {
422
- current.disabled_behaviors = disabled
423
- ? [...current.disabled_behaviors, id]
424
- : current.disabled_behaviors.filter((candidate) => candidate !== id);
425
- }, workspaceDir, profile);
424
+ await selectCapability(workspaceDir, profile, 'behavior', id, !disabled);
425
+ const updated = readGameplayConfig(workspaceDir, profile);
426
426
  console.log(JSON.stringify({
427
427
  behavior: id,
428
428
  disabled,
@@ -14,7 +14,8 @@ import {
14
14
  type CapabilityWorkspaceType,
15
15
  } from '../lib/capability-workspace.js';
16
16
  import { getWorkspaceDir } from '../lib/init-command.js';
17
- import { writePersonaSelection } from '../lib/persona.js';
17
+ import { writePersonaSelection, readPersonaSelection } from '../lib/persona.js';
18
+ import { selectCapability } from '../lib/capability-selection.js';
18
19
  import {
19
20
  agentSkillTargets,
20
21
  findSkillRoot,
@@ -46,8 +47,15 @@ import {
46
47
  import { syncCapabilitiesToCloud } from '../lib/capability-cloud-sync.js';
47
48
 
48
49
  interface CapabilityResolveCloudClient {
50
+ findWorkspaceItem: HubClient['findWorkspaceItem'];
49
51
  getResource(type: ResourceType, id: string, workspaceItemId?: string): ReturnType<HubClient['getResource']>;
50
52
  downloadArtifact(type: ResourceType, id: string, workspaceItemId?: string): ReturnType<HubClient['downloadArtifact']>;
53
+ updateWorkspaceEquipment(
54
+ workspaceItemId: string,
55
+ equipped: boolean,
56
+ ): ReturnType<HubClient['updateWorkspaceEquipment']>;
57
+ updateWorkspaceLoadout(input: Parameters<HubClient['updateWorkspaceLoadout']>[0]):
58
+ ReturnType<HubClient['updateWorkspaceLoadout']>;
51
59
  }
52
60
 
53
61
  export interface CapabilityCommandDependencies {
@@ -128,7 +136,11 @@ function parseRef(value: string): { type: CapabilityWorkspaceType; id: string }
128
136
  if (!match) {
129
137
  throw new InvalidArgumentError('expected <behavior|perception|persona|skill>/<id>');
130
138
  }
131
- return { type: match[1] as CapabilityWorkspaceType, id: match[2]! };
139
+ const parsed = { type: match[1] as CapabilityWorkspaceType, id: match[2]! };
140
+ if (parsed.type === 'skill' && parsed.id === 'clawclaw') {
141
+ throw new InvalidArgumentError('The official clawclaw Skill is managed by the installed CCL package');
142
+ }
143
+ return parsed;
132
144
  }
133
145
 
134
146
  function applySkillSelection(
@@ -158,42 +170,38 @@ function applySkillSelection(
158
170
  }
159
171
  }
160
172
 
161
- function updateSelection(
173
+ async function updateSelection(
162
174
  ref: string,
163
175
  equipped: boolean,
164
176
  dependencies: CapabilityCommandDependencies,
165
- ): Record<string, unknown> {
177
+ ): Promise<Record<string, unknown>> {
166
178
  const workspaceDir = getWorkspaceDir();
167
179
  const profile = activeProfile();
168
180
  discoverLocalCapabilities(workspaceDir, profile);
169
181
  const { type, id } = parseRef(ref);
182
+ const entry = await selectCapability(workspaceDir, profile, type, id, equipped, dependencies.client);
170
183
  if (type === 'skill') {
171
- const matches = Object.values(readCapabilityWorkspaceRegistry(workspaceDir, profile).entries)
172
- .filter((candidate) => (
173
- candidate.type === type && candidate.runtimeId === id && candidate.origin === 'local'
174
- ));
175
- if (matches.length !== 1) {
176
- throw new Error(`capability_selection_${matches.length === 0 ? 'not_found' : 'ambiguous'}:${type}:${id}`);
184
+ try {
185
+ applySkillSelection(entry, equipped, workspaceDir, profile, dependencies);
186
+ } catch (error) {
187
+ throw new Error(`capability_selection_saved_skill_links_failed:run_ccl_load:${error instanceof Error ? error.message : String(error)}`);
177
188
  }
178
- applySkillSelection(matches[0]!, equipped, workspaceDir, profile, dependencies);
179
189
  }
180
- const entry = setCapabilitySelection(workspaceDir, profile, type, id, equipped);
181
- if (type === 'persona') {
182
- writePersonaSelection(
183
- workspaceDir,
184
- profile,
185
- equipped ? { source: 'local', id } : { source: 'none' },
186
- );
190
+ if (type === 'persona' && equipped) {
191
+ writePersonaSelection(workspaceDir, profile, entry.hub
192
+ ? { source: 'hub' } : { source: 'local', id });
193
+ } else if (type === 'persona') {
194
+ // Do not clear another active Persona when this particular item is unequipped.
195
+ const selected = readPersonaSelection(workspaceDir, profile);
196
+ if (selected?.source === 'local' && selected.id === id) {
197
+ writePersonaSelection(workspaceDir, profile, { source: 'hub' });
198
+ }
187
199
  }
188
200
  return {
189
- capability: `${type}/${id}`,
190
- equipped,
191
- selection: entry.selection,
192
- effective: 'immediate',
193
- reload_required_before_game: true,
201
+ capability: `${type}/${id}`, equipped, selection: entry.selection,
202
+ effective: 'immediate', reload_required_before_game: true,
194
203
  };
195
204
  }
196
-
197
205
  export function createCapabilityCommand(dependencies: CapabilityCommandDependencies = {}): Command {
198
206
  const capability = new Command('capability')
199
207
  .alias('cap')
@@ -222,12 +230,16 @@ export function createCapabilityCommand(dependencies: CapabilityCommandDependenc
222
230
  capability.addCommand(new Command('equip')
223
231
  .argument('<type/id>', 'Local capability reference')
224
232
  .allowExcessArguments(false)
225
- .action((ref: string) => console.log(JSON.stringify(updateSelection(ref, true, dependencies), null, 2))));
233
+ .action(async (ref: string) => console.log(JSON.stringify(
234
+ await updateSelection(ref, true, dependencies), null, 2,
235
+ ))));
226
236
 
227
237
  capability.addCommand(new Command('unequip')
228
238
  .argument('<type/id>', 'Local capability reference')
229
239
  .allowExcessArguments(false)
230
- .action((ref: string) => console.log(JSON.stringify(updateSelection(ref, false, dependencies), null, 2))));
240
+ .action(async (ref: string) => console.log(JSON.stringify(
241
+ await updateSelection(ref, false, dependencies), null, 2,
242
+ ))));
231
243
 
232
244
  capability.addCommand(new Command('resolve')
233
245
  .description('Resolve one local/cloud content conflict')
@@ -330,6 +342,7 @@ export function createCapabilityCommand(dependencies: CapabilityCommandDependenc
330
342
  baseSha256: digest,
331
343
  lastUploadedSha256: digest,
332
344
  observedCloudVersionId: undefined,
345
+ localOriginUnrecognized: undefined,
333
346
  });
334
347
  setCapabilityConflictChoice(workspaceDir, profile, entry.key, undefined);
335
348
  console.log(JSON.stringify({