evolcore 0.0.43-test.1 → 0.0.43-test.3

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 (200) hide show
  1. package/CHANGELOG.md +31 -1
  2. package/README.md +22 -0
  3. package/dist/agents/claude-runner.js +26 -2
  4. package/dist/agents/codex/app-server-client.js +12 -0
  5. package/dist/agents/codex-runner.js +49 -8
  6. package/dist/agents/ecagent-runner.js +39 -15
  7. package/dist/agents/gemini-runner.js +15 -12
  8. package/dist/agents/tool-time-context.js +55 -0
  9. package/dist/aun/aid/agentmd.js +21 -1
  10. package/dist/aun/menu/client.js +1 -1
  11. package/dist/aun/model-headers.js +17 -0
  12. package/dist/aun/msg/p2p.js +7 -2
  13. package/dist/channels/aun.js +522 -50
  14. package/dist/channels/builtin-plugins.js +16 -11
  15. package/dist/channels/daemon.js +4 -0
  16. package/dist/channels/dingtalk.js +83 -31
  17. package/dist/channels/feishu.js +29 -13
  18. package/dist/channels/qqbot.js +32 -11
  19. package/dist/channels/wechat.js +13 -3
  20. package/dist/channels/wecom.js +67 -27
  21. package/dist/cli/agent-command.js +3 -86
  22. package/dist/cli/agent-create.js +20 -6
  23. package/dist/cli/agent.js +1 -79
  24. package/dist/cli/aun-commands.js +18 -19
  25. package/dist/cli/config.js +1 -1
  26. package/dist/cli/daemon-commands.js +47 -2
  27. package/dist/cli/data-command.js +9 -1
  28. package/dist/cli/debug-mode.js +1 -1
  29. package/dist/cli/diag.js +1 -1
  30. package/dist/cli/directory.js +149 -91
  31. package/dist/cli/getmeta-command.js +1 -1
  32. package/dist/cli/index.js +79 -22
  33. package/dist/cli/init.js +1 -23
  34. package/dist/cli/link-rules.js +1 -1
  35. package/dist/cli/managed-command-guard.js +0 -1
  36. package/dist/cli/pa-workspace-command.js +36 -2
  37. package/dist/cli/peer.js +3 -2
  38. package/dist/cli/restart-monitor.js +17 -3
  39. package/dist/cli/role.js +1 -1
  40. package/dist/cli/session-command.js +1 -1
  41. package/dist/cli/stats.js +2 -2
  42. package/dist/cli/task-context.js +3 -1
  43. package/dist/cli/thread-command.js +1 -1
  44. package/dist/cli/watch-msg.js +1 -1
  45. package/dist/config/builtin-role-templates.js +2 -2
  46. package/dist/config/builtin-roles.js +2 -1
  47. package/dist/config/config-field-policy.js +7 -2
  48. package/dist/config/config-manager.js +32 -10
  49. package/dist/config/peer-role-resolver.js +23 -1
  50. package/dist/config/role-schema.js +29 -4
  51. package/dist/config/role-service.js +12 -7
  52. package/dist/config/role-store.js +30 -8
  53. package/dist/config-store.js +75 -4
  54. package/dist/core/agent-ipc-registration.js +16 -59
  55. package/dist/core/auth/auth-gateway.js +14 -4
  56. package/dist/core/auth/authorization-audit.js +52 -14
  57. package/dist/core/auth/operation-authorizer.js +17 -11
  58. package/dist/core/auth/operation-catalog.js +5 -13
  59. package/dist/core/channel-loader.js +152 -16
  60. package/dist/core/channel-runtime.js +5 -0
  61. package/dist/core/command/agent-control.js +2 -1
  62. package/dist/core/command/agentmd-menu-request.js +50 -0
  63. package/dist/core/command/agentmd-menu.js +156 -0
  64. package/dist/core/command/cli-intent-parser.js +0 -8
  65. package/dist/core/command/command-handler.js +47 -40
  66. package/dist/core/command/connect-menu.js +7 -3
  67. package/dist/core/command/menu-catalog.js +16 -2
  68. package/dist/core/command/menu-handler.js +107 -14
  69. package/dist/core/command/menu-protocol.js +28 -0
  70. package/dist/core/command/role-menu.js +23 -9
  71. package/dist/core/command/slash-handler.js +139 -51
  72. package/dist/core/daemon-file-cache.js +3 -3
  73. package/dist/core/daemon-lifecycle.js +9 -1
  74. package/dist/core/evolagent-registry.js +5 -4
  75. package/dist/core/evolagent.js +10 -12
  76. package/dist/core/handoff/argv-parse.js +115 -0
  77. package/dist/core/handoff/ipc-registration.js +1 -1
  78. package/dist/core/ipc-registration.js +19 -2
  79. package/dist/core/lifecycle-notice.js +185 -0
  80. package/dist/core/memory/consolidation.js +8 -1
  81. package/dist/core/memory/relation-sweep.js +20 -8
  82. package/dist/core/message/aun-ipc-sender.js +35 -2
  83. package/dist/core/message/contact-admission.js +530 -0
  84. package/dist/core/message/im-renderer.js +111 -16
  85. package/dist/core/message/message-admission.js +29 -54
  86. package/dist/core/message/message-bridge.js +62 -8
  87. package/dist/core/message/message-utils.js +9 -5
  88. package/dist/core/message/peer-mode.js +55 -13
  89. package/dist/core/message/response-engine.js +298 -78
  90. package/dist/core/message/retry-scheduler.js +4 -0
  91. package/dist/core/ownership/owner-resolver.js +72 -34
  92. package/dist/core/permission/ec-command-parser.js +25 -38
  93. package/dist/core/permission/readonly-shell-query.js +34 -8
  94. package/dist/core/permission/tool-policy.js +50 -5
  95. package/dist/core/relation/pa-team.js +127 -0
  96. package/dist/core/role/runtime-policy.js +18 -5
  97. package/dist/core/session/session-manager.js +9 -1
  98. package/dist/core/soul.js +66 -0
  99. package/dist/core/system-session/memory.js +2 -2
  100. package/dist/core/thread/thread-service.js +6 -4
  101. package/dist/directory/contact-admission-paths.js +9 -0
  102. package/dist/directory/owner-directory-admission.js +125 -29
  103. package/dist/directory/owner-directory-cache.js +554 -58
  104. package/dist/directory/owner-directory-identity.js +60 -0
  105. package/dist/directory/owner-directory-markdown.js +154 -58
  106. package/dist/directory/owner-directory-policy.js +108 -0
  107. package/dist/directory/owner-directory-query-operation.js +399 -90
  108. package/dist/directory/owner-directory-remarks.js +29 -2
  109. package/dist/directory/owner-directory-request-operation.js +76 -0
  110. package/dist/directory/owner-directory-scope.js +35 -4
  111. package/dist/directory/owner-directory-search.js +118 -33
  112. package/dist/directory/owner-directory-store.js +117 -30
  113. package/dist/directory/owner-directory-text.js +60 -0
  114. package/dist/eck/kit-renderer.js +18 -8
  115. package/dist/eck/manifest-engine.js +55 -6
  116. package/dist/ecweb/basic-settings-service.js +2 -2
  117. package/dist/ecweb/message-context-service.js +28 -16
  118. package/dist/index.js +20 -5
  119. package/dist/ipc.js +1 -1
  120. package/dist/paths.js +29 -1
  121. package/dist/product.js +1 -0
  122. package/dist/response-system/config-resolver.js +1 -1
  123. package/dist/response-system/engines/v1/index.js +2 -1
  124. package/dist/response-system/modes/single-session/index.js +7 -2
  125. package/dist/trigger/scheduler.js +7 -4
  126. package/dist/trigger/validation.js +4 -0
  127. package/dist/utils/error-utils.js +12 -7
  128. package/dist/utils/logger.js +13 -4
  129. package/dist/utils/npm-ops.js +2 -2
  130. package/dist/utils/windows-autostart.js +1 -1
  131. package/ecagent/README.md +18 -0
  132. package/ecagent/dist/agent-loop.js +43 -1
  133. package/ecagent/dist/harness/agent-harness.d.ts +2 -0
  134. package/ecagent/dist/harness/agent-harness.js +24 -8
  135. package/ecagent/dist/harness/compaction/compaction.js +3 -0
  136. package/ecagent/dist/harness/types.d.ts +1 -0
  137. package/kits/docs/INDEX.md +1 -0
  138. package/kits/docs/channels/aun.md +1 -1
  139. package/kits/docs/context-assembly.md +21 -6
  140. package/kits/docs/eck_templates/INDEX.template.md +1 -2
  141. package/kits/docs/evolcore/INDEX.md +4 -1
  142. package/kits/docs/evolcore/agent-create.md +5 -5
  143. package/kits/docs/evolcore/agent.md +4 -9
  144. package/kits/docs/evolcore/directory.md +227 -0
  145. package/kits/docs/evolcore/ecweb-lifecycle.md +26 -0
  146. package/kits/docs/evolcore/file-navigation.md +265 -0
  147. package/kits/docs/evolcore/menu-protocol.md +55 -0
  148. package/kits/docs/evolcore/msg.md +1 -0
  149. package/kits/docs/evolcore/peer.md +2 -1
  150. package/kits/docs/evolcore/response.md +7 -1
  151. package/kits/docs/evolcore/task.md +2 -0
  152. package/kits/docs/evolcore/tool-authorization.md +1 -1
  153. package/kits/docs/evolcore/trigger.md +4 -0
  154. package/kits/docs/identity/ROLE_DETAIL.md +2 -0
  155. package/kits/docs/prompt-loading-architecture.md +6 -2
  156. package/kits/eck_manifest.auxiliary.json +1 -0
  157. package/kits/eck_manifest.json +64 -7
  158. package/kits/eck_manifest.memory.json +93 -4
  159. package/kits/rules/01-overview.md +2 -2
  160. package/kits/rules/03-identity.md +10 -9
  161. package/kits/rules/05-venue.md +2 -4
  162. package/kits/rules/06-channel.md +1 -1
  163. package/kits/schemas/_meta.json +44 -3
  164. package/kits/schemas/agent-config.schema.18.json +5 -0
  165. package/kits/schemas/agent-config.schema.19.json +924 -0
  166. package/kits/schemas/agent-config.schema.20.json +925 -0
  167. package/kits/schemas/relation-config.schema.12.json +289 -0
  168. package/kits/schemas/relation-config.schema.13.json +289 -0
  169. package/kits/schemas/role-config.schema.2.json +215 -0
  170. package/kits/schemas/role-config.schema.3.json +1038 -0
  171. package/kits/schemas/role-registry.schema.1.json +3 -2
  172. package/kits/skills/ec-skill/scripts/cli.mjs +3 -2
  173. package/kits/skills/ec-trigger/SKILL.md +4 -4
  174. package/kits/skills/personal-assistant/SKILL.md +109 -53
  175. package/kits/skills/personal-assistant/references/02-bootstrap.md +73 -30
  176. package/kits/skills/personal-assistant/scripts/clean.mjs +35 -18
  177. package/kits/skills/personal-assistant/scripts/init.mjs +41 -2
  178. package/kits/skills/personal-assistant/scripts/lib/persona.mjs +185 -0
  179. package/kits/skills/personal-assistant/scripts/migrate.mjs +55 -4
  180. package/kits/skills/personal-assistant/scripts/pa.mjs +173 -0
  181. package/kits/skills/personal-assistant/scripts/uninstall.mjs +130 -0
  182. package/kits/skills/personal-assistant/templates/persona-section.md +3 -3
  183. package/kits/templates/message-fragments/handoff-request-to-target.md +1 -1
  184. package/kits/templates/soul/00-GUIDE.md +39 -0
  185. package/kits/templates/soul/01-identity.md +5 -0
  186. package/kits/templates/soul/02-persona.md +11 -0
  187. package/kits/templates/soul/03-duties.md +5 -0
  188. package/kits/templates/soul/04-working-style.md +5 -0
  189. package/kits/templates/system-fragments/bootstrap.md +7 -7
  190. package/kits/templates/system-fragments/channel.md +2 -2
  191. package/kits/templates/system-fragments/commands.md +3 -2
  192. package/kits/templates/system-fragments/directory-contacts.md +9 -0
  193. package/kits/templates/system-fragments/memory.md +1 -1
  194. package/kits/templates/system-fragments/personal-assistant.md +50 -0
  195. package/kits/templates/system-fragments/reply.md +7 -0
  196. package/kits/templates/system-fragments/session.md +6 -2
  197. package/package.json +3 -2
  198. package/dist/cli/handoff-command.js +0 -353
  199. package/dist/directory/owner-directory-remark-operation.js +0 -147
  200. package/kits/docs/evolcore/self-summary.md +0 -29
@@ -23,11 +23,12 @@
23
23
  "type": "object",
24
24
  "additionalProperties": false,
25
25
  "required": ["private", "group"],
26
- "default": { "private": null, "group": null },
26
+ "default": { "private": null, "group": null, "paTeam": "member" },
27
27
  "description": "未显式分配角色时,私聊和群聊分别采用的默认角色;null 表示不自动授予角色。",
28
28
  "properties": {
29
29
  "private": { "type": ["string", "null"], "pattern": "^(?!owner$)[a-z0-9_-]+$", "default": null, "description": "私聊默认角色;必须已注册且不能为 owner。" },
30
- "group": { "type": ["string", "null"], "pattern": "^(?!owner$)[a-z0-9_-]+$", "default": null, "description": "群聊默认角色;必须已注册且不能为 owner。" }
30
+ "group": { "type": ["string", "null"], "pattern": "^(?!owner$)[a-z0-9_-]+$", "default": null, "description": "群聊默认角色;必须已注册且不能为 owner。" },
31
+ "paTeam": { "type": ["string", "null"], "pattern": "^(?!owner$)[a-z0-9_-]+$", "default": "member", "description": "同 Owner 且双方为 pa.* Agent 的私聊默认角色;未设置或 null 时独立默认为 member,不继承 private。必须已注册且不能为 owner。" }
31
32
  },
32
33
  "x-merge": "dict"
33
34
  }
@@ -10,9 +10,10 @@ import * as S from './skill.mjs';
10
10
  import path from 'node:path';
11
11
  import { spawnSync } from 'node:child_process';
12
12
 
13
- const USAGE = `ec skill —— EC 技能管理
13
+ const USAGE = `用法: ec skill <command> [options]
14
+
15
+ ec skill —— EC 技能管理
14
16
 
15
- 用法:
16
17
  ec skill load <name> [--source builtin|local] [--with-frontmatter]
17
18
  加载技能正文(输出 SKILL.md 内容 + skillDir)
18
19
  ec skill path <name> [--json] 查看技能 SKILL.md 完整路径(含状态和时间戳)
@@ -72,8 +72,8 @@ ec trigger create --cron '0 9 * * *' --tz Asia/Shanghai \
72
72
  1. **边界**:短期跟进的周期 trigger 加 `--max-runs` 或 `--max-duration`。到上限自动 `disable`
73
73
  (定义留着、可查),不会删。无限周期的巡检只留给用户明确要求"一直跑"的场景。
74
74
  2. **NOOP**:周期任务有"没事可报"的情况,提示词里写死"无异常时**只输出** `[[NOOP]]`"。
75
- **整段输出必须恰好是 `[[NOOP]]`**(前后不能有其它文字,结尾换行没关系),否则结果照样
76
- 投递,模型还会额外对着用户说一圈废话。
75
+ 成功回复忽略开头空白后,以 `[[NOOP]]` 开头就静默;后面可以附原因,仅留在内部执行记录。
76
+ 正文中间引用标记不会静默,执行失败仍报告错误。流式拆分的标记也在投递前识别。
77
77
  3. **复核**:建完立刻 `ec trigger show <id> --json` 看三样:`enabled`、`feedback.target`、
78
78
  `schedule.nextFireAt`(cron 看得到下次触发时刻;与预期不符就是时区/表达式问题)。
79
79
  改定义一律带 `--if-revision <show 返回的 revision>`,改完再看 revision 变了没有。
@@ -92,7 +92,7 @@ ec trigger create --cron '0 9 * * *' --tz Asia/Shanghai \
92
92
  用户没收到。排查时看 `history` 里的 `effects`。
93
93
  - **你被 trigger 唤醒时**:信封里的 `触发于:` 是排定时刻(firedAt),不是唤醒时刻;
94
94
  proactive 模式下正文流式输出会被丢弃,**回复必须走 `ec ctl send`**;`[[NOOP]]` 仍适用,
95
- 只用它、别在它前后多说一句。
95
+ 应放在正文开头(允许前导空白);附带原因只保留在内部记录。显式发送的消息无法撤回。
96
96
  - **提示词里能用的变量**:`{{trigger.name}}`、`{{run.number}}`(第几次)、`{{run.elapsed}}`、
97
97
  `{{date}}`、`{{time}}`,事件触发另有 `{{event.<字段>}}`。提示词正文走同一套渲染。
98
98
  - **每次创建都是新 trigger**:重复建同一个提醒会得到多个 trigger,各自都会触发。先 `list` 查。
@@ -154,7 +154,7 @@ ec trigger create --event 'task:error' \
154
154
  | 根本没触发 | `show --json` 的 `nextFireAt`、`recentRuns`;`list --all` | 被 disable、cron 表达式/时区错、一次性已跑完、上限已命中 |
155
155
  | 触发了但没送到 | `history` 的 `effects` / `feedback` | target 路由写错、AUN 缺 chatType、渠道未配置 |
156
156
  | 发到了错的会话 | `show --json` 的 `feedback.target` / `origin` | 在话题里建但用了 target、目标会话不存在被新建 |
157
- | 用户收到一堆废话 | run 状态 `completed` 但内容很啰嗦 | `[[NOOP]]` 没独占整段输出 |
157
+ | 用户收到一堆废话 | run 状态 `completed` 但内容很啰嗦 | `[[NOOP]]` 没放在正文开头,或已显式发送消息 |
158
158
  | 每次跑很久/堆任务 | `show --json` 的 `active`;`history` | 周期比执行时间短,queue 串行排队;concurrency 设为 forbid |
159
159
  | 脚本报沙箱不可用 | 脚本路径/项目路径 | 受保护路径,或宿主未准备沙箱 |
160
160
  | 手动跑有效、定时没效 | `history` 时间线 | 错过策略、daemon 停机、时区 |
@@ -53,6 +53,41 @@ license: MIT
53
53
 
54
54
  ## 三、初始化
55
55
 
56
+ ### 3.0 唯一入口:四种操作
57
+
58
+ **这套自动化对外只有一个入口 `pa.mjs`,四种操作。调用方(程序或 Agent)只做一件事:
59
+ 传工作区路径和 AID,剩下全部由脚本完成。**
60
+
61
+ ```bash
62
+ node "<技能目录>/scripts/pa.mjs" init --workspace <路径> --self <AID> [--owner <AID>]
63
+ node "<技能目录>/scripts/pa.mjs" clean --workspace <路径> --self <AID> [--yes]
64
+ node "<技能目录>/scripts/pa.mjs" uninstall --workspace <路径> --self <AID> [--remove-triggers]
65
+ node "<技能目录>/scripts/pa.mjs" update --workspace <路径> --self <AID>
66
+ ```
67
+
68
+ | 操作 | 做什么 | 工作区档案 | 什么时候用 |
69
+ |---|---|---|---|
70
+ | `init` | 建目录 + 装触发器 + 写 state.json + 写 persona 入口 + **Core 绑定** | 新建 | 全新环境;或已有工作区上做幂等修复 |
71
+ | `clean` | 删工作区目录 + 触发器 + persona 入口 + Core 登记 | **全部删除** | 清空重来(测试循环);不可逆,默认只预览 |
72
+ | `uninstall` | 恢复 persona + 删触发器 + **解绑 Core** | **全部保留** | 拆掉自动化但保住档案 |
73
+ | `update` | 结构升到当前版本 + 按新模板刷新 persona 入口 | 保留 | 技能升级后 |
74
+
75
+ **Core 绑定不是可选项,是初始化的一部分。** 少了它:App 里没有「个人助理」入口,
76
+ `ec pa-workspace navigation show` 报 `NOT_CONFIGURED`。绑的是**同一次初始化**,
77
+ 不是事后补一步——所以它写在 `init` 里,不是单独命令。
78
+
79
+ **`clean` 和 `uninstall` 只差一个词,破坏力差一个量级**:
80
+
81
+ - 要「清空后重新初始化」→ `clean --yes`
82
+ - 要「不要再自动跑了,但数据留着」→ `uninstall`
83
+
84
+ 拿不准时先用 `clean` 不带 `--yes` 预览,它会列出将删除的每一项。
85
+
86
+ 四种操作都支持 `--dry-run`、`--json`,参数原样透传给实现脚本。
87
+
88
+ **模型不要自己拼这些步骤**:不要手动建目录、不要手动写 persona、不要手动装触发器。
89
+ 判断只在两处:用哪个操作、传哪个路径。
90
+
56
91
  ### 3.1 工作区放哪(先定路径,再建)
57
92
 
58
93
  **默认落在当前工作目录下的 `PersonalAssistant/`**,即 `$CURRENT_PROJECT/PersonalAssistant`。
@@ -73,27 +108,27 @@ license: MIT
73
108
 
74
109
  ### 3.2 调用
75
110
 
76
- **整条初始化只有 4 次命令调用**,一次参数给全,不要拆成多轮试探:
111
+ **整条初始化只有 3 次命令调用**,一次参数给全,不要拆成多轮试探:
77
112
 
78
113
  ```bash
79
114
  # 1. 体检(先看是不是已经初始化过——见 3.2.1)
80
115
  node "<技能目录>/scripts/check.mjs" --workspace "<工作区绝对路径>"
81
116
 
82
- # 2. 建结构 + 装触发器(参数一次给全,尤其 --self 和 --with-triggers)
83
- node "<技能目录>/scripts/init.mjs" --workspace "<工作区绝对路径>" \
117
+ # 2. 初始化(参数一次给全,尤其 --self 和 --with-triggers)
118
+ node "<技能目录>/scripts/pa.mjs" init --workspace "<工作区绝对路径>" \
84
119
  --owner "<owner AID>" --self "<本 Agent AID>" --with-triggers
85
120
 
86
- # 3. 落地今天的对话(可选,想让工作区立刻有内容就跑)
87
- node "<技能目录>/scripts/ingest.mjs" --workspace "<工作区绝对路径>" --self "<本 Agent AID>" --date today
88
-
89
- # 4. 重建索引
121
+ # 3. 重建索引(init 已写 README/INDEX,这一步确保与现有文件一致)
90
122
  node "<技能目录>/scripts/index-rebuild.mjs" --workspace "<工作区绝对路径>"
91
123
  ```
92
124
 
93
- 然后写 persona.md(§3.3),最后再跑一次 `check.mjs` 验收。**共 6 步。**
125
+ 最后再跑一次 `check.mjs` 验收。**共 4 步。**
94
126
 
95
- 脚本会:检查前置条件 → 建目录 → 写 README/INDEX → 装触发器 → 写 `.assistant/state.json`
96
- (含 `triggers` 清单和 `capabilities` 实测结果)→ 输出验收清单。
127
+ `init` 内部会:检查前置条件 → 建目录 → 写 README/INDEX → 装触发器 →
128
+ 写 `.assistant/state.json`(含 `triggers` 清单和 `capabilities` 实测结果)→
129
+ **写 soul「工作方式」分册的工作区入口** → 输出验收清单。
130
+
131
+ > `soul/04-working-style.md` 由 `init.mjs` 自动处理(备份 → 重建),模型不用手改文件,详见 §3.3。
97
132
 
98
133
  > `--self` 不能省。触发器 prompt 里要写 `--self` 才能调通 `ingest.mjs`;
99
134
  > 没给 `--self` 时触发器全部装不上,脚本会在验收清单里报 `(all) 缺少 --self`。
@@ -111,8 +146,8 @@ node "<技能目录>/scripts/index-rebuild.mjs" --workspace "<工作区绝对路
111
146
  | 输出 | 含义 | 下一步 |
112
147
  |---|---|---|
113
148
  | `工作区不存在` / `v0 未初始化` | 全新 | 正常走 §3.2 |
114
- | `OK:N 项全部符合` | 已初始化过 | **不要重跑 init**,直接进 §3.3 检查 persona.md |
115
- | `MISSING` | 初始化到一半 | 跑 `init.mjs` 补建 |
149
+ | `OK:N 项全部符合` | 已初始化过 | 跑 `pa.mjs init --self` 刷新 persona 入口(幂等,不会重建目录) |
150
+ | `MISSING` | 初始化到一半 | 跑 `pa.mjs init` 补建 |
116
151
  | `DRIFT` | 版本落后 | 走 §五 升级 |
117
152
 
118
153
  > 实测教训:曾跳过体检直接 init,结果 4 个触发器早就存在(比工作区早 20 分钟,
@@ -125,7 +160,7 @@ node "<技能目录>/scripts/index-rebuild.mjs" --workspace "<工作区绝对路
125
160
  `init.mjs` / `apply.mjs` / `schema.mjs`——要确认用法跑 `--help`,要确认结果看输出。
126
161
  唯一需要读源码的情形是:输出和文档矛盾,需要判断是脚本 bug 还是文档过时。
127
162
 
128
- ### 3.3 写回 persona.md(必做,否则等于没装)
163
+ ### 3.3 写回 soul「工作方式」分册(必做,否则等于没装)
129
164
 
130
165
  **这一步不做,初始化就只是建了一堆没人知道的空目录。**
131
166
 
@@ -133,45 +168,37 @@ node "<技能目录>/scripts/index-rebuild.mjs" --workspace "<工作区绝对路
133
168
  新会话开场的你是个不知道工作区存在的普通 agent,主人得每次重新交代路径——
134
169
  这违背了"把复杂度锁在技能里"的前提。
135
170
 
136
- `persona.md`(`$PERSONAL_DIR/persona.md`)是唯一**保证每轮注入**的位置:ECK manifest 的
137
- `persona` 段只要求 `chatType ≠ null` 且 `lifecycle = active`,**不依赖任何记忆开关**。
171
+ `soul/04-working-style.md`(`$PERSONAL_DIR/soul/04-working-style.md`)是唯一**保证每轮注入**的位置:ECK manifest 的
172
+ `soul` 目录段只要求 `chatType ≠ null` 且 `lifecycle = active`,**不依赖任何记忆开关**;
173
+ 该文件只要非空就会注入。
138
174
  相比之下 `memory/MEMORY.md` 虽然默认开启(`memory.enableAgent ?? true`),但可以被关掉;
139
175
  而且 `ec memory note` 写的 `pending/` 要等整理会话跑完才进索引——**中间那段是断的**,
140
176
  不能当唯一入口。
141
177
 
142
- **先备份,再重建。不要试图合并。**
143
-
144
- 合并看起来温柔,实际最容易出错:漏读一段、拼接位置错、编码不对,都会悄悄毁掉原文,
145
- 而且毁了还不知道。备份 + 重建只有两种结局——**要么成功,要么原样可退**。
146
-
147
- 用 Read / Write 工具直接操作文件,不走脚本、不用 `ec agent persona --file` 转手临时文件
148
- (那条路是整体覆盖,天然做不了"先备份")。
149
-
150
- 三步:
178
+ **这一步由 `pa.mjs init` 自动完成,模型不需要再手动编辑文件。**
151
179
 
152
- 1. **备份老的**:`persona.md` 存在就整份复制到同目录的 `persona.before-personal-assistant.md`。
153
- **备份已存在时不要覆盖**——最早那份才是真正的原始状态,后面的重复初始化不能拿
154
- 已经被改过的版本去顶掉它。文件不存在就跳过(原始状态就是"没有",见下面「清理」)。
155
- 2. **重新创建**:Write 一份新的 `persona.md`,内容按 `templates/persona-section.md` 渲染。
156
- 备份里有想保留的个人信息,**从备份里抄过来**,不要指望原文件还在。
157
- 3. **写完复查**:Read 一遍,确认路径、入口清单、触发器列表都在,备份文件也还在。
180
+ 调用时传 `--self <AID>` 即可,脚本会把工作区路径、owner、触发器清单渲染进
181
+ `soul/04-working-style.md` 的标记块,并先备份原文件:
158
182
 
159
- ### 清理(撤销初始化)
183
+ ```
184
+ <!-- personal-assistant:begin -->
185
+ ## 数据位置
186
+ ……
187
+ <!-- personal-assistant:end -->
188
+ ```
160
189
 
161
- 初始化必须可逆,否则用户不敢用。撤销时把备份放回去,删掉这次创建的内容:
190
+ **为什么用标记块**:重复初始化只替换块内内容,不会产生重复段落;撤销时能精确摘掉
191
+ 本技能写进去的部分,不碰人格主体。备份文件 `04-working-style.before-personal-assistant.md`
192
+ 存在时不覆盖——最早那份才是真正的原始状态。
162
193
 
163
- ```bash
164
- # 有备份:恢复原始状态
165
- mv persona.before-personal-assistant.md persona.md
194
+ **模型只需要做两件事**:
166
195
 
167
- # 没有备份(原本就不存在):删掉这次创建的
168
- rm persona.md
169
- ```
196
+ 1. 调 `pa.mjs init --workspace <路径> --owner <owner AID> --self <本 Agent AID>`
197
+ 2. 看输出里的 `persona:` 一行,确认是「已创建」或「已更新」,不是「跳过」
170
198
 
171
- **删之前必须先确认备份存在且非空。** 没有备份就直接删,等于把用户的原始人格永久销毁——
172
- 这一步不可逆,做之前必须跟用户说清楚。
199
+ **看到「跳过 —— 缺少 --self」必须补上 AID 重跑**,否则新会话永远发现不了这个工作区。
173
200
 
174
- **这一节必须写清什么**:
201
+ **写进去的内容**(由 `templates/persona-section.md` 渲染,改模板即改产物):
175
202
 
176
203
  1. **工作区绝对路径**,以及"涉及归档/回顾/报告/任务时先读它的 `INDEX.md`"。
177
204
  2. **目录用途**:`capture/` 原料、`output/reports/` 报告、`output/tasks/` 任务、
@@ -189,12 +216,36 @@ rm persona.md
189
216
  4. **持久记忆是什么**:工作区 `output/knowledge/memory/` 改主意不改老条目,旧版本标
190
217
  `superseded` 永久保留。这是运行时记忆故意做不到的事。
191
218
  5. **已装触发器清单**,避免下次重复创建。
192
- 6. **不改人格主体**:新文件里只放本技能需要的内容,不编造性格设定、不写行为守则。
193
219
 
194
- `persona.md` 缺失时没有默认人格兜底,这一节就是新会话唯一的入口——**它缺了,整个工作区对外不可见**。
220
+ ### 3.4 清理(两种强度)
195
221
 
196
- 参考成品见 `templates/persona-section.md`(整份 persona 的模板,含备份+重建的用法说明)。
197
- 详细流程见 `references/02-bootstrap.md` 阶段 4.5。
222
+ **都由脚本完成,模型不手改文件。先选强度:**
223
+
224
+ | 意图 | 命令 | 结果 |
225
+ |---|---|---|
226
+ | 清空重来 | `pa.mjs clean --workspace <路径> --self <AID> --yes` | 删目录、触发器、persona 入口、Core 登记 |
227
+ | 撤装保档 | `pa.mjs uninstall --workspace <路径> --self <AID> --remove-triggers` | 只恢复 persona、删触发器,档案不动 |
228
+
229
+ ```bash
230
+ # 清空重来(先不带 --yes 预览)
231
+ node "<技能目录>/scripts/pa.mjs" clean --workspace "<工作区绝对路径>" --self "<本 Agent AID>"
232
+ node "<技能目录>/scripts/pa.mjs" clean --workspace "<工作区绝对路径>" --self "<本 Agent AID>" --yes
233
+
234
+ # 撤装保档
235
+ node "<技能目录>/scripts/pa.mjs" uninstall --workspace "<工作区绝对路径>" --self "<本 Agent AID>" --remove-triggers
236
+ ```
237
+
238
+ **`--workspace` 必传,不是摆设。** 脚本会读出 persona 标记块里登记的路径做比对:
239
+ 对不上就整体拒绝(连触发器都不动)——防止 A 工作区的清理命令把 B 工作区的入口摘掉。
240
+
241
+ `clean` 默认**只预览不删**,加 `--yes` 才真执行;锁定(`.assistant/LOCK`)的工作区一律拒绝。
242
+ `uninstall` 优先从 `04-working-style.before-personal-assistant.md` 恢复,没有备份才摘标记块。
243
+
244
+ 撤装 ≠ 删档。要删档案必须由用户明确要求并单独确认,脚本不碰用户数据。
245
+
246
+ `soul/04-working-style.md` 缺失时没有默认人格兜底,这一节就是新会话唯一的入口——**它缺了,整个工作区对外不可见**。
247
+
248
+ 参考成品见 `templates/persona-section.md`。详细流程见 `references/02-bootstrap.md` 阶段 4.5。
198
249
 
199
250
  ---
200
251
 
@@ -220,11 +271,14 @@ node "<技能目录>/scripts/check.mjs" --workspace "<工作区绝对路径>"
220
271
  ## 五、升级
221
272
 
222
273
  ```bash
223
- node "<技能目录>/scripts/check.mjs" --workspace "<路径>" # 1. 先看差什么
224
- node "<技能目录>/scripts/migrate.mjs" --workspace "<路径>" # 2. 执行迁移
225
- node "<技能目录>/scripts/check.mjs" --workspace "<路径>" # 3. 复查
274
+ node "<技能目录>/scripts/check.mjs" --workspace "<路径>" # 1. 先看差什么
275
+ node "<技能目录>/scripts/pa.mjs" update --workspace "<路径>" --self "<本 Agent AID>" # 2. 迁移 + 刷新 persona
276
+ node "<技能目录>/scripts/check.mjs" --workspace "<路径>" # 3. 复查
226
277
  ```
227
278
 
279
+ `--self` 不是必须,但给了就会顺带按新模板刷新 `soul/04-working-style.md` 里的工作区入口——
280
+ 技能升级常改模板和触发器清单,不刷新的话 persona 里写的还是旧内容。
281
+
228
282
  迁移的硬规则:
229
283
 
230
284
  1. **只做加法**:建目录、补字段、改元数据。**永不删用户数据。**
@@ -293,7 +347,9 @@ node "<技能目录>/scripts/check.mjs" --workspace "<路径>" # 3. 复查
293
347
 
294
348
  | 脚本 | 作用 | 退出码 0 的含义 |
295
349
  |---|---|---|
296
- | `init.mjs` | 建/修复工作区 | 成功(含"已是最新") |
350
+ | `pa.mjs` | **唯一入口**:`init` / `clean` / `uninstall` / `update` | 成功 |
351
+ | `init.mjs` | `pa.mjs init` 的实现:建/修复工作区 + 写 persona 入口 | 成功(含"已是最新") |
352
+ | `uninstall.mjs` | `pa.mjs clean` 的实现:恢复 persona、可选删触发器 | 成功 |
297
353
  | `check.mjs` | 只读体检 | 完全一致;`10` = 有缺失可补建 |
298
354
  | `migrate.mjs` | 版本迁移 | 成功(含"无需迁移") |
299
355
  | `ingest.mjs` | 对话落地 | 成功 |
@@ -329,7 +385,7 @@ node "<技能目录>/scripts/check.mjs" --workspace "<路径>" # 3. 复查
329
385
  | 残留物 | 在哪 | 留着会怎样 |
330
386
  |---|---|---|
331
387
  | 4 个 `pa-*` 触发器 | EvolCore 的系统目录 | 每天半夜按时醒来,对着不存在的路径报错 |
332
- | persona.md 的「## 数据位置」小节 | `$PERSONAL_DIR/persona.md` | 新会话每轮都被告知去读一个已经没了的路径 |
388
+ | soul/04-working-style.md 的「## 数据位置」小节 | `$PERSONAL_DIR/soul/04-working-style.md` | 新会话每轮都被告知去读一个已经没了的路径 |
333
389
  | Core 的工作区绑定登记 | `agents/<aid>/data/pa-workspace-state.json` | 导航面板还挂着一个不存在的路径 |
334
390
 
335
391
  `clean.mjs` 四样一起清(含工作区目录本身):
@@ -396,11 +452,11 @@ node "<技能目录>/scripts/lock.mjs" --workspace "<路径>" --show # 查
396
452
 
397
453
  ```bash
398
454
  # 1. 建
399
- node "<技能目录>/scripts/init.mjs" --workspace "<路径>" --owner "<AID>" --self "<AID>" --with-triggers
455
+ node "<技能目录>/scripts/pa.mjs" init --workspace "<路径>" --owner "<AID>" --self "<AID>" --with-triggers
400
456
  # 2. 验
401
457
  node "<技能目录>/scripts/check.mjs" --workspace "<路径>"
402
- # 3. 清(连触发器一起)
403
- node "<技能目录>/scripts/clean.mjs" --workspace "<路径>" --self "<AID>" --yes
458
+ # 3. 清空(连触发器、persona 入口一起)
459
+ node "<技能目录>/scripts/pa.mjs" clean --workspace "<路径>" --self "<AID>" --yes
404
460
  # 4. 回到第 1 步
405
461
  ```
406
462
 
@@ -150,40 +150,82 @@ ec trigger create --exec trigger-session --file triggers/ingest-daily.json --ena
150
150
 
151
151
  装失败的单独报告,不因为一个失败就整体回滚——助理有 80% 功能可用,胜过一次都不跑。
152
152
 
153
- ### 阶段 4.5:备份并重建 persona.md
153
+ ### 阶段 4.5:写「工作方式」分册(由 init.mjs 自动完成)
154
154
 
155
- **这一步由模型直接用 Read / Write 编辑文件完成,不调脚本。**
155
+ **不需要模型编辑文件**。`init.mjs` 在装完触发器、写完 `state.json` 之后自动调用
156
+ `lib/persona.mjs` 完成:备份 → 渲染 → 写入 → 报告。
156
157
 
157
- | 步骤 | 动作 |
158
+ | 内部步骤 | 实现 |
158
159
  |---|---|
159
- | 1. 备份 | `persona.md` 存在 → 整份复制到 `persona.before-personal-assistant.md`。<br>**备份已存在不覆盖**,最早那份才是真正的原始状态。不存在 → 跳过 |
160
- | 2. 重建 | Write 新的 `persona.md`,按 `templates/persona-section.md` 渲染。<br>备份里有要保留的信息,从备份里抄 |
161
- | 3. 复查 | Read 确认路径、入口清单、触发器都在;备份文件也在 |
160
+ | 解析路径 | `$EVOLCORE_HOME/agents/<selfAid>/personal/soul/04-working-style.md`,`EVOLCORE_HOME` 缺省 `~/.evolcore` |
161
+ | 备份 | 原文件存在 → 复制为 `04-working-style.before-personal-assistant.md`;**已存在不覆盖** |
162
+ | 渲染 | `templates/persona-section.md`,替换 `{{workspace}}` `{{owner}}` `{{skillDir}}` `{{triggers}}` |
163
+ | 写入 | 摘掉旧的 `<!-- personal-assistant:begin/end -->` 块,再把新块追加到文末 |
164
+ | 输出 | 验收清单里打一行 `persona:已创建/已更新`,或 `跳过 —— <原因>` |
162
165
 
163
- **为什么是备份+重建,而不是读旧的→合并→写新的**:合并看起来温柔,实际最容易出错——
166
+ **为什么是备份+重建,而不是就地合并**:合并看起来温柔,实际最容易出错——
164
167
  漏读一段、拼接位置错、编码不对,都会悄悄毁掉原文,而且毁了不知道。
165
168
  备份 + 重建只有两种结局:**要么成功,要么原样可退**。
166
169
 
167
- **为什么不用 `ec agent persona --text/--file`**:那两个参数是**整体覆盖**,
168
- 必须先自己拼好全文再传,天然做不了"先备份再重建";而且中间还要落一个临时文件。
169
- owner 会话里直接读写 persona 文件是被允许的。
170
+ **为什么用标记块**:重复初始化只替换块内内容,不产生重复段落;
171
+ 撤销时能精确摘掉本技能写入的部分,不碰人格主体。
170
172
 
171
173
  **为什么必须做**:工作区路径只存在 `.assistant/state.json` 和 Core 的导航状态里,
172
- 两者都**不进上下文**。`persona.md` 是唯一保证每轮注入的位置(manifest 的 `persona` 段
173
- 只要求 `chatType ≠ null` + `lifecycle = active`)。不写这一步,新会话根本不知道工作区存在。
174
+ 两者都**不进上下文**。「工作方式」分册是唯一保证每轮注入的位置(manifest 的 `soul` 目录段只要求
175
+ `chatType ≠ null` + `lifecycle = active`,且非空文件才会注入)。不写这一步,新会话根本不知道工作区存在。
174
176
 
175
- #### 撤销初始化
177
+ **失败情形**:没传 `--self` 时这一行会报 `跳过 —— 缺少 --self <AID>`。
178
+ 这不是可忽略的警告,必须补上 AID 重跑。
176
179
 
177
- ```bash
178
- # 有备份:恢复原始状态
179
- mv persona.before-personal-assistant.md persona.md
180
+ #### 清理:两种强度
180
181
 
181
- # 没有备份(原本就不存在):删掉这次创建的
182
- rm persona.md
183
- ```
182
+ | 意图 | 命令 | 工作区档案 |
183
+ |---|---|---|
184
+ | 清空重来 | `pa.mjs clean --workspace <路径> --self <AID> --yes` | 删除 |
185
+ | 撤装保档 | `pa.mjs uninstall --workspace <路径> --self <AID> --remove-triggers` | 保留 |
186
+
187
+ **`clean`**(`clean.mjs`):
188
+
189
+ - 默认**只预览不删**,`--yes` 才执行——不可逆操作不给"一条命令误触发"的机会
190
+ - 删:工作区目录、`pa-*` 触发器、persona 入口、Core 工作区登记
191
+ - 锁定的工作区一律拒绝,且没有 `--force` 绕过
192
+
193
+ **`uninstall`**(`uninstall.mjs`):
194
+
195
+ | 情况 | 行为 |
196
+ |---|---|
197
+ | 传入路径 ≠ persona 登记路径 | **整体拒绝**,连触发器都不动 |
198
+ | 备份存在 | 用备份覆盖回 `soul/04-working-style.md`(备份文件被消费掉) |
199
+ | 无备份、但有人格正文 | 只摘掉标记块,正文保留 |
200
+ | 无备份、只剩标记块 | 删除 `soul/04-working-style.md` |
201
+ | `--remove-triggers` | 删除 4 个 `pa-*` 触发器 |
202
+
203
+ 两者都要求 `--workspace`。脚本从 persona 标记块解析出当初写入的路径做比对,
204
+ 防的是"清理 A 工作区时把 B 工作区的入口摘掉"。路径归一化:统一 `/`、去尾斜杠、
205
+ Windows 下忽略大小写。
206
+
207
+ **工作区文件一律不动**。撤装 ≠ 删档。
208
+
209
+ ### 阶段 4.6:绑定 Core 的 PA 工作区
210
+
211
+ **由 `pa.mjs` 自动完成,不单独调命令。**
212
+
213
+ `ec pa-workspace bind --workspace <路径>` 把工作区登记进 Core,App 的「个人助理」入口靠它。
214
+ 不绑定的话 `ec pa-workspace navigation show` 报 `NOT_CONFIGURED`,App 里看不到任何入口。
215
+
216
+ | 操作 | 绑定行为 |
217
+ |---|---|
218
+ | `init` | 未绑定或绑的是别处 → 绑定;已绑同一路径 → 跳过 |
219
+ | `update` | 同上(顺带修复丢失的绑定) |
220
+ | `uninstall` | 解绑(工作区档案保留);已绑到别的工作区则拒绝 |
221
+ | `clean` | **只有真正删掉工作区(带 `--yes`)才解绑**;预览模式不动 |
222
+
223
+ 登记文件:`$EVOLCORE_HOME/agents/<selfAid>/data/pa-workspace-state.json`。
224
+ `clean` 解绑前会核对 `rootPath` 指向的是本工作区,指向别处就拒绝删除——
225
+ 这个文件同时存着 ownerAid 和导航条目,误删会影响别的 Agent。
184
226
 
185
- **删之前必须确认备份存在且非空**。没有备份就删 = 永久销毁用户原始人格,不可逆,
186
- 做之前必须跟用户讲清楚。
227
+ > 踩过的坑:`clean.mjs` 预览时也返回退出码 0,`pa.mjs` 光看退出码分不清
228
+ > 「预览成功」和「真的删了」,结果预览把绑定删掉了。现在按工作区目录是否真的消失来判断。
187
229
 
188
230
  ### 阶段 5:验收
189
231
 
@@ -194,8 +236,8 @@ rm persona.md
194
236
  ✅ 目录:4 个根项 + 29 个子目录
195
237
  ✅ README / INDEX 已生成
196
238
  ✅ state.json 已写入(技能版本 0.1.0)
197
- ✅ persona.md 已重建(含「数据位置」一节,新会话据此发现工作区)
198
- 原文件已备份为 persona.before-personal-assistant.md
239
+ ✅ soul/04-working-style.md 已重建(含「数据位置」一节,新会话据此发现工作区)
240
+ 原文件已备份为 04-working-style.before-personal-assistant.md
199
241
  ✅ 触发器:5 个已启用
200
242
  ├─ ingest-daily 下次 23:50
201
243
  ├─ ingest-on-idle 事件驱动
@@ -211,13 +253,14 @@ rm persona.md
211
253
  2. `INDEX.md` 可被 `scripts/index-rebuild` 重建且内容一致
212
254
  3. `state.json` 可读,版本号正确
213
255
  4. 至少 `ingest-daily` 和 `report-daily` 两个触发器处于 enabled
214
- 5. **`persona.md` 里有「数据位置」一节**:工作区路径 + "什么时候该进来读"的入口清单
215
- 6. **原 persona 已备份**(原本存在时):`persona.before-personal-assistant.md` 内容与原文一致,
256
+ 5. **`soul/04-working-style.md` 里有「数据位置」一节**:工作区路径 + "什么时候该进来读"的入口清单
257
+ 6. **原 persona 已备份**(原本存在时):`04-working-style.before-personal-assistant.md` 内容与原文一致,
216
258
  且撤销命令能原样恢复
217
- 7. 已报告的能力缺口,用户知情
259
+ 7. **Core 绑定生效**:`ec pa-workspace navigation show` 返回 `ok: true`,不是 `NOT_CONFIGURED`
260
+ 8. 已报告的能力缺口,用户知情
218
261
 
219
262
  > 第 5 条是硬性的。工作区路径只落在 `.assistant/` 和 Core 导航状态里,两者都不进上下文;
220
- > 不进 `persona.md`,新会话就是不知道有这么个地方,等于没装。详见 SKILL.md §3.3。
263
+ > 不进 `soul/04-working-style.md`,新会话就是不知道有这么个地方,等于没装。详见 SKILL.md §3.3。
221
264
 
222
265
  ---
223
266
 
@@ -233,12 +276,12 @@ rm persona.md
233
276
  | `state.json` 缺失 | 重建,标记 `recovered: true` |
234
277
  | 技能版本升级 | 保留全部数据,只更新 `state.json` 和触发器定义 |
235
278
  | 触发器丢失或被禁用 | 重新安装,不重复创建(按 `name` 去重) |
236
- | `persona.md` 里没有工作区入口 | 按阶段 4.5 重新备份+重建(**备份已存在则不覆盖**) |
279
+ | `soul/04-working-style.md` 里没有工作区入口 | 按阶段 4.5 重新备份+重建(**备份已存在则不覆盖**) |
237
280
 
238
281
  **永远不删用户数据。** 修复模式只做加法。
239
282
 
240
- `persona.md` 是唯一例外:它是**重建**而非追加,所以必须有备份兜底。
241
- 重复初始化时 `persona.before-personal-assistant.md` 已存在就保持原样——
283
+ `soul/04-working-style.md` 是唯一例外:它是**重建**而非追加,所以必须有备份兜底。
284
+ 重复初始化时 `04-working-style.before-personal-assistant.md` 已存在就保持原样——
242
285
  那份是最早的原始状态,不能被后来改过的版本顶掉。
243
286
 
244
287
  ### 4.2 版本迁移
@@ -17,7 +17,7 @@
17
17
  * · 触发器 pa-ingest-daily / pa-report-daily / pa-report-weekly / pa-memory-consolidate
18
18
  * 它们存在 EvolCore 的系统目录里,删工作区目录不会带走它们;
19
19
  * 留着的话每天半夜会按时醒来,对着一个不存在的路径报错。
20
- * · persona.md 里的「## 数据位置」小节
20
+ * · soul「工作方式」分册(04-working-style.md)里的「## 数据位置」小节
21
21
  * 不清掉的话,新会话每轮都被告知"去读这个工作区的 INDEX.md",而那个路径已经没了。
22
22
  *
23
23
  * 工作区外(第二块,Core 的登记):
@@ -38,6 +38,7 @@ import { join, resolve, basename } from 'node:path';
38
38
  import { homedir } from 'node:os';
39
39
  import { execFileSync } from 'node:child_process';
40
40
  import { SKILL_DIR } from './lib/schema.mjs';
41
+ import { stripBlock, restorePersona } from './lib/persona.mjs';
41
42
 
42
43
  // ── 参数 ────────────────────────────────────────────────────────
43
44
  function parseArgs(argv) {
@@ -59,7 +60,7 @@ if (args.help || !args.workspace) {
59
60
 
60
61
  默认只预览。加 --yes 才真正删除。
61
62
 
62
- 会清理:工作区目录 + pa-* 触发器 + persona.md 的「数据位置」小节
63
+ 会清理:工作区目录 + pa-* 触发器 + soul「工作方式」分册的「数据位置」小节
63
64
  不会清理:Core 的工作区绑定登记(没有 unbind 命令)
64
65
 
65
66
  已锁定的工作区拒绝清理,没有绕过开关。`);
@@ -153,20 +154,20 @@ function collectTriggers() {
153
154
  return [...ids];
154
155
  }
155
156
 
156
- // ── 4. 定位 persona.md 并摘掉「数据位置」小节 ───────────────────
157
+ // ── 4. 定位「工作方式」分册并摘掉「数据位置」小节 ───────────────────
157
158
  function resolvePersonaPath() {
158
159
  if (args.self) {
159
160
  const home = process.env.EVOLCORE_HOME || join(homedir(), '.evolcore');
160
- const p = join(home, 'agents', args.self, 'personal', 'persona.md');
161
+ const p = join(home, 'agents', args.self, 'personal', 'soul', '04-working-style.md');
161
162
  return existsSync(p) ? p : null;
162
163
  }
163
164
 
164
- // 没给 --self:扫所有 agent 的 persona,找提到这个工作区的那个
165
+ // 没给 --self:扫所有 agent 的「工作方式」分册,找提到这个工作区的那个
165
166
  const home = process.env.EVOLCORE_HOME || join(homedir(), '.evolcore');
166
167
  const agentsDir = join(home, 'agents');
167
168
  if (!existsSync(agentsDir)) return null;
168
169
  for (const aid of readdirSync(agentsDir)) {
169
- const p = join(agentsDir, aid, 'personal', 'persona.md');
170
+ const p = join(agentsDir, aid, 'personal', 'soul', '04-working-style.md');
170
171
  if (!existsSync(p)) continue;
171
172
  try {
172
173
  if (readFileSync(p, 'utf8').includes(workspace)) return p;
@@ -177,9 +178,16 @@ function resolvePersonaPath() {
177
178
 
178
179
  /**
179
180
  * 删掉 `## 数据位置` 这一节。
180
- * 节内可能有 `###` 子标题,所以只在下一次出现**二级**标题时收手。
181
+ *
182
+ * 优先按标记块整段摘除(`init` 写入的格式带 `<!-- personal-assistant:begin/end -->`),
183
+ * 这样不会留下孤立标记;老格式没有标记块时,退回按二级标题裁剪。
181
184
  */
182
185
  function stripDataLocationSection(md) {
186
+ const stripped = stripBlock(md);
187
+ if (stripped !== md) {
188
+ return { text: stripped.replace(/\s+$/, '\n'), removed: true };
189
+ }
190
+
183
191
  const START = /^##(?!#)\s*数据位置\s*$/;
184
192
  const NEXT_L2 = /^##(?!#)\s/;
185
193
 
@@ -277,9 +285,9 @@ if (!args.yes) {
277
285
  for (const t of triggers) console.log(` · ${t}`);
278
286
  console.log('');
279
287
  if (personaWillChange) {
280
- console.log(` persona.md 的「## 数据位置」小节:${personaPath}`);
288
+ console.log(` soul「工作方式」分册的「## 数据位置」小节:${personaPath}`);
281
289
  } else {
282
- console.log(' persona.md:没有需要摘掉的「数据位置」小节');
290
+ console.log(' soul「工作方式」分册:没有需要摘掉的「数据位置」小节');
283
291
  }
284
292
  console.log('');
285
293
  if (coreBinding) {
@@ -315,17 +323,26 @@ for (const id of triggers) {
315
323
 
316
324
  if (personaPath) {
317
325
  try {
318
- const md = readFileSync(personaPath, 'utf8');
319
- const { text, removed } = stripDataLocationSection(md);
320
- if (removed) {
321
- writeFileSync(personaPath, text, 'utf8');
322
- report.removed.personaSection = personaPath;
323
- }
326
+ // 从 agents/<aid>/personal/soul/04-working-style.md 反推 AID,走统一的恢复逻辑:
327
+ // 有备份就恢复原始内容,没备份才摘标记块。只按标题裁剪会留下孤立标记。
328
+ const m = /[\\/]agents[\\/]([^\\/]+)[\\/]personal[\\/]soul[\\/]04-working-style\.md$/i.exec(personaPath);
329
+ const aid = m ? m[1] : null;
330
+ const result = aid
331
+ ? restorePersona({ selfAid: aid, workspace })
332
+ : (() => {
333
+ const md = readFileSync(personaPath, 'utf8');
334
+ const { text, removed } = stripDataLocationSection(md);
335
+ if (removed) writeFileSync(personaPath, text, 'utf8');
336
+ return { ok: true, action: removed ? 'block-removed' : 'noop' };
337
+ })();
338
+
339
+ if (!result.ok) throw new Error(result.error || result.action);
340
+ if (result.action !== 'noop') report.removed.personaSection = personaPath;
324
341
  } catch (e) {
325
- report.failed.push({ item: 'persona.md 数据位置小节', reason: String(e.message).slice(0, 200) });
342
+ report.failed.push({ item: 'soul 工作方式分册的数据位置小节', reason: String(e.message).slice(0, 200) });
326
343
  }
327
344
  } else {
328
- report.warnings.push('没找到对应本工作区的 persona.md,「数据位置」小节可能残留');
345
+ report.warnings.push('没找到对应本工作区的 soul「工作方式」分册,「数据位置」小节可能残留');
329
346
  }
330
347
 
331
348
  // Core 绑定登记:删文件(没有 unbind 命令,只能直接删)
@@ -368,7 +385,7 @@ console.log(`清理完成:${workspace}`);
368
385
  console.log('');
369
386
  console.log(` 触发器:已删除 ${report.removed.triggers.length} 个`);
370
387
  for (const t of report.removed.triggers) console.log(` · ${t}`);
371
- console.log(` persona.md:${report.removed.personaSection ? '已摘掉「数据位置」小节' : '无需改动'}`);
388
+ console.log(` soul「工作方式」分册:${report.removed.personaSection ? '已摘掉「数据位置」小节' : '无需改动'}`);
372
389
  console.log(` Core 工作区登记:${report.removed.coreBinding ? '已删除' : '无需改动'}`);
373
390
  console.log(` 工作区目录:${report.removed.workspaceDir ? '已删除' : '未删除'}`);
374
391
  console.log('');