zcode-expert-system 3.2.1 → 3.2.2

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.
@@ -5,7 +5,7 @@
5
5
  "en": "ZCode Expert System v3.2 - 331 experts in 32 top-level categories with two-axis routing (scale -> nine-stage workflow, domain -> expert). Fuses OpenSpec + Superpowers + multi-agent + TDD.",
6
6
  "zh-CN": "ZCode 专家体系 v3.2 - 331 位专家 / 32 个一级大类,两轴正交路由(规模→九阶段工作流,领域→专家)。融合 OpenSpec 规格、Superpowers 纪律、多 Agent 协作与 TDD。"
7
7
  },
8
- "version": "3.2.1",
8
+ "version": "3.2.2",
9
9
  "author": {
10
10
  "name": "wutian122"
11
11
  },
package/README.md CHANGED
@@ -4,13 +4,20 @@
4
4
 
5
5
  ## 📋 Overview
6
6
 
7
- **ZCode Expert System** is an expert-routing plugin for ZCode. It ships the full persona prompts of **331 specialists** from [dsh-agency-agents](https://github.com/MichengAI/dsh-agency-agents), adapted to ZCode with **two-axis routing**: the *scale axis* decides how long a workflow runs, the *domain axis* decides which expert handles it.
7
+ **ZCode Expert System** is an expert-routing plugin that runs on **both ZCode and Claude Code**. It ships the full persona prompts of **331 specialists** from [dsh-agency-agents](https://github.com/MichengAI/dsh-agency-agents), adapted with **two-axis routing**: the *scale axis* decides how long a workflow runs, the *domain axis* decides which expert handles it.
8
+
9
+ The same package deploys to either host. ZCode reads `.zcode-plugin/` and `hooks/hooks.json`; Claude Code reads `.claude-plugin/` and `hooks/claude-hooks.json`. The two sides are fully isolated — installing on one never affects the other.
10
+
11
+ | Host | Manifest | Hooks config | Sub-agent location | Dispatch name |
12
+ |---|---|---|---|---|
13
+ | ZCode | `.zcode-plugin/plugin.json` | `hooks/hooks.json` (`type: process`) | `~/.zcode/agents/` | `后端架构师` (Chinese bare name) |
14
+ | Claude Code | `.claude-plugin/plugin.json` | `hooks/claude-hooks.json` (`type: command`) | `agents/` inside plugin | `zcode-expert-system:后端架构师` (qualified name) |
8
15
 
9
16
  ## 🏗️ Plugin Architecture
10
17
 
11
18
  ### System Overview
12
19
 
13
- ZCode Expert System v3.2.1 is an expert-routing plugin for ZCode. It ships the full persona prompts of **331 specialists** from [dsh-agency-agents](https://github.com/MichengAI/dsh-agency-agents), fused with **Superpowers engineering discipline** and **OpenSpec spec-driven development**. The plugin uses **two-axis orthogonal routing**:
20
+ ZCode Expert System v3.2.2 is an expert-routing plugin for ZCode. It ships the full persona prompts of **331 specialists** from [dsh-agency-agents](https://github.com/MichengAI/dsh-agency-agents), fused with **Superpowers engineering discipline** and **OpenSpec spec-driven development**. The plugin uses **two-axis orthogonal routing**:
14
21
 
15
22
  | Axis | Question | Implementation |
16
23
  |---|---|---|
@@ -72,7 +79,18 @@ User task
72
79
  5. **Dispatch** via `Agent(subagent_type="<specialist display name>")` with a process-contract prefix
73
80
  6. **Propagate** context across stages via return values
74
81
 
75
- > **Semantic selection contract**: The plugin deliberately does not configure an external LLM/Embedding service — it depends on the model already active in the session. `scripts/llm_client.py` `_call_llm` and `embedding_client.py` `get_embedding` return `None`, so coarse screening degrades to local token-overlap scoring. When `semantic_selection_required=true`, the controller must review `score_detail` and may override with `build_dispatch_for_expert("<specialist name>", task)`.
82
+ > **Semantic selection contract**: The plugin deliberately does not configure an external LLM/Embedding service — it depends on the model already active in the session. `scripts/llm_client.py` `_call_llm` and `embedding_client.py` `get_embedding` return `None`, so coarse screening degrades to local token-overlap scoring. When `semantic_selection_required=true`, the controller must review `score_detail` and may override with `build_dispatch_for_expert("<specialist name>", task)`. A wrong specialist name raises `ValueError` with the closest matches (difflib suggestion) rather than silently degrading.
83
+
84
+ **Confidence guard rails** (applied during plan generation):
85
+
86
+ | Condition | Behaviour |
87
+ |---|---|
88
+ | `confidence ≥ 0.5` | Proceed to semantic review |
89
+ | `confidence < 0.5` **and** `selection_basis: heuristic` | **Implementer dispatch is blocked** (`action: blocked_low_confidence` + `plan.blocking`); clarify the domain with the boss first — token-fallback experts are not dispatched |
90
+ | `confidence < 0.5`, semantic review already done | Dispatch proceeds, but a `semantic_recheck` action is emitted so the controller re-checks `score_detail` |
91
+ | `confidence = 0` | `domain.no_signal = true` — the category is only the `business-support` default, not a real domain judgement |
92
+
93
+ > **Word-boundary guards**: `返回500` does not fire on `返回5000行数据` (a trailing numeric segment must not be followed by another digit), and zero-width characters (ZWSP / BOM / soft hyphen) are stripped before matching, so they cannot be used to slip past Bug detection.
76
94
 
77
95
  ### Role × Specialist Matrix (Workflow Roles)
78
96
 
@@ -331,12 +349,108 @@ zcode-expert-system install
331
349
  (Not yet published — use Option 1 (npm) for now.) Search for `zcode-expert-system`
332
350
  in the ZCode plugin marketplace and click install.
333
351
 
352
+ ### Option 4: Claude Code plugin
353
+
354
+ The same package also works as a Claude Code plugin. Claude Code reads the `.claude-plugin/`
355
+ directory and `hooks/claude-hooks.json` (Claude Code format), while ZCode reads
356
+ `.zcode-plugin/` and `hooks/hooks.json` (ZCode format). The two are fully isolated:
357
+
358
+ ```bash
359
+ # 1. One-click install (recommended)
360
+ npm install -g zcode-expert-system
361
+ zcode-expert-system cc-install
362
+
363
+ # 2. Or from a cloned repo
364
+ npm install
365
+ npm run cc:install
366
+ ```
367
+
368
+ Uninstall the Claude Code side:
369
+
370
+ ```bash
371
+ zcode-expert-system cc-uninstall # global install
372
+ npm run cc:uninstall # from a cloned repo
373
+ ```
374
+
375
+ **What the one-click installer does** (it wraps four CLI steps so you don't have to run them
376
+ manually):
377
+
378
+ 1. Builds a local marketplace at `~/.claude/plugins/marketplaces/zcode-local/`
379
+ (`marketplace.json` + the full plugin tree, including a `skills/zcode-expert-system/`
380
+ mirror so `/wf:*` command script paths resolve)
381
+ 2. Registers the marketplace (`claude plugin marketplace add`)
382
+ 3. Installs and enables the plugin (`claude plugin install`)
383
+ 4. Verifies both `installed_plugins.json` and `enabledPlugins` are updated
384
+
385
+ After install:
386
+
387
+ - In Claude Code, run `/plugin` — `zcode-expert-system` should appear
388
+ - Dispatch sub-agents with the qualified name: `zcode-expert-system:<专家中文名>`
389
+ (e.g. `zcode-expert-system:后端架构师`)
390
+ - Use `/wf:*` commands for the nine-stage workflow
391
+
392
+ **P5 install safety contract** (`scripts/install-claude-code.js`): the installer is
393
+ *check → back up → build → roll back on failure*:
394
+
395
+ 1. **Preflight** — `preflightCheck()` verifies every required source component
396
+ (`SKILL.md`, `config/`, `agents/`, `commands/`, `.claude-plugin/`, `hooks/`,
397
+ `scripts/`) exists **before** anything is deleted; a missing component aborts
398
+ with `[preflight] 源树缺少部署必需组件`.
399
+ 2. **Back up before delete** — an existing marketplace directory is first copied to
400
+ `.bak-marketplace-<timestamp>` next to it.
401
+ 3. **Rollback on failure** — if the build fails, the half-built directory is removed
402
+ and the backup is restored; if rollback itself fails, the backup path is printed
403
+ for manual recovery.
404
+
405
+ **Unpacked component**: `src/` is declared in `UNPACKED_COMPONENTS` and is **not**
406
+ shipped with the plugin. It holds the in-progress `openspec/changes/jwt-auth-system`
407
+ module (`src/auth/`), which has no production consumer yet.
408
+
409
+ **Other commands:**
410
+
411
+ ```bash
412
+ npm run cc:install:dry # Preview, touches nothing
413
+ npm run cc:install -- --force # Force reinstall
414
+ npm run cc:uninstall # Uninstall (removes registration + marketplace dir)
415
+ ```
416
+
417
+ > **ZCode compatibility is unaffected.** The ZCode deployment paths and behavior
418
+ > remain exactly as before. The Claude Code adapter is fully additive and does not
419
+ > modify any ZCode-facing files.
420
+
334
421
  ### Uninstall
335
422
 
423
+ Uninstall is unified through `install.js`, with `--zcode` / `--claude-code` flags to choose which side to remove:
424
+
336
425
  ```bash
337
- zcode-expert-system uninstall
338
- # or
339
- node scripts/install.js --uninstall
426
+ node scripts/install.js --uninstall # Uninstall ZCode + Claude Code (both)
427
+ node scripts/install.js --uninstall --zcode # Uninstall ZCode only
428
+ node scripts/install.js --uninstall --claude-code # Uninstall Claude Code only
429
+ node scripts/install.js --uninstall --zcode --purge # Uninstall ZCode and wipe all residue (incl. runtime data)
430
+ ```
431
+
432
+ Or via npm:
433
+
434
+ ```bash
435
+ npm run uninstall # both
436
+ npm run uninstall:zcode # ZCode only
437
+ npm run uninstall:claude # Claude Code only
438
+ ```
439
+
440
+ **What ZCode-side removal does**: removes the plugin registration, cache, skill,
441
+ commands, sub-agents, and deployment manifests, and cleans up backup
442
+ directories (`skills/*.bak-*`) plus any now-empty command/`expert-system`
443
+ folders. **User runtime data** under `~/.zcode/expert-system/context/` is
444
+ kept by default — add `--purge` to wipe it too.
445
+
446
+ **What Claude Code-side removal does**: removes the plugin registration and
447
+ `enabledPlugins` entry, removes the marketplace registration, and deletes the
448
+ local marketplace directory. ZCode is not touched.
449
+
450
+ Prefer a dry run first to preview the full removal plan (zero writes):
451
+
452
+ ```bash
453
+ node scripts/install.js --uninstall --dry-run
340
454
  ```
341
455
 
342
456
  ## ⚙️ Configuration
@@ -451,15 +565,21 @@ session start; additions or edits made mid-session are not picked up.
451
565
  ```
452
566
  zcode-expert-system/
453
567
  ├── .zcode-plugin/plugin.json # Plugin manifest
568
+ ├── .claude-plugin/plugin.json # Claude Code manifest
454
569
  ├── SKILL.md # ZCode skill entry
455
570
  ├── README.md / README_CN.md # English / Chinese docs
456
571
  ├── zcode_expert_system.py # Domain axis (32 categories → 331 experts)
457
572
  ├── zcode_dev_workflow.py # Scale axis (triage → stages → dispatch plan)
458
573
  ├── skill_entry.py # Skill invocation wrapper
459
574
  ├── package.json # npm package config
575
+ ├── src/
576
+ │ └── auth/ # jwt-auth-system (openspec, in progress; not shipped — UNPACKED_COMPONENTS)
460
577
  ├── scripts/
461
- │ ├── install.js # One-click deploy / uninstall
578
+ │ ├── install.js # ZCode deploy / uninstall
579
+ │ ├── install-claude-code.js # Claude Code deploy (preflight + backup + rollback)
580
+ │ ├── cc-uninstall.js # Claude Code uninstall
462
581
  │ ├── workflow_check.py # Mechanical gate checker (+ --self-check)
582
+ │ ├── openspec_engine.py # OpenSpec change/spec engine
463
583
  │ ├── llm_client.py # LLM call helper
464
584
  │ └── embedding_client.py # Embedding client
465
585
  ├── config/
@@ -480,9 +600,10 @@ zcode-expert-system/
480
600
  │ └── workflow-fusion-design.md # Design baseline (why this architecture)
481
601
  ├── context/
482
602
  │ └── context-manager.py # Context manager (data in ~/.zcode/expert-system/context/)
483
- ├── tests/ # Regression tests (pytest)
603
+ ├── tests/ # Regression tests (pytest, 639 passed / 1 skipped)
484
604
  ├── hooks/
485
605
  │ ├── hooks.json # Hook config (ZCode standard schema)
606
+ │ ├── claude-hooks.json # Hook config (Claude Code format)
486
607
  │ └── prepend-global-rules-reminder.mjs # Injects trigger rules before each prompt
487
608
  └── agents/
488
609
  ├── manager-*.md # 32 domain manager definitions
@@ -518,6 +639,17 @@ Before opening the PR, make sure the full regression suite is green:
518
639
  python -m pytest tests/ -q # must end with "passed", 0 failed
519
640
  ```
520
641
 
642
+ Expected baseline: **639 passed, 1 skipped**.
643
+
644
+ > Note on `src/auth/`: the JWT auth module (`jwt-auth-system` OpenSpec change) is under
645
+ > construction and covered by `tests/test_auth_login.py`. Its implementation choices are
646
+ > deliberate: password hashing is **PBKDF2-HMAC-SHA256, 100 000 iterations**, 16-byte
647
+ > random salt, stored base64(`salt||dk`) (bcrypt is a documented fallback, not a
648
+ > dependency); refresh tokens are **`secrets.token_urlsafe(32)`** (256-bit entropy) and
649
+ > only their **sha256 hash** is persisted; `expires_at` is stored and parsed as an
650
+ > **ISO 8601 string** via `datetime.fromisoformat`; JWT verification parses the header
651
+ > and whitelists **`alg=HS256` and `typ=JWT`** before checking the signature.
652
+
521
653
  ## 📄 License
522
654
 
523
655
  Released under the [MIT License](LICENSE).
@@ -546,4 +678,4 @@ Questions or suggestions? Open a GitHub Issue.
546
678
 
547
679
  ---
548
680
 
549
- **ZCode Expert System v3.2.1** — smarter collaboration between AI experts 🚀
681
+ **ZCode Expert System v3.2.2** — smarter collaboration between AI experts 🚀
package/README_CN.md CHANGED
@@ -1,16 +1,23 @@
1
- # ZCode Expert System v3.2.1 - ZCode 专家体系
1
+ # ZCode Expert System v3.2.2 - ZCode 专家体系
2
2
 
3
3
  [English](README.md) · **简体中文**
4
4
 
5
5
  ## 📋 项目简介
6
6
 
7
- **ZCode Expert System** 是 ZCode 插件系统的专家体系插件,基于 [dsh-agency-agents](https://github.com/MichengAI/dsh-agency-agents) 的 331 位专家完整人格提示词,适配 ZCode 平台实现**两轴正交路由**:规模轴决定流程走多长,域轴决定派哪位专家。
7
+ **ZCode Expert System** 是**同时适配 ZCode 与 Claude Code 的专家体系插件**,基于 [dsh-agency-agents](https://github.com/MichengAI/dsh-agency-agents) 的 331 位专家完整人格提示词,实现**两轴正交路由**:规模轴决定流程走多长,域轴决定派哪位专家。
8
+
9
+ 同一个包可部署到两个平台。ZCode 读取 `.zcode-plugin/` 与 `hooks/hooks.json`,Claude Code 读取 `.claude-plugin/` 与 `hooks/claude-hooks.json`。两侧完全隔离——安装到任一侧都不会影响另一侧。
10
+
11
+ | 平台 | 清单 | 钩子配置 | 子代理位置 | 派发名 |
12
+ |---|---|---|---|---|
13
+ | ZCode | `.zcode-plugin/plugin.json` | `hooks/hooks.json`(`type: process`) | `~/.zcode/agents/` | `后端架构师`(中文裸名) |
14
+ | Claude Code | `.claude-plugin/plugin.json` | `hooks/claude-hooks.json`(`type: command`) | 插件内 `agents/` | `zcode-expert-system:后端架构师`(限定名) |
8
15
 
9
16
  ## 🏗️ 架构设计
10
17
 
11
18
  ### 系统概述
12
19
 
13
- ZCode Expert System v3.2.1 是 ZCode 的专家路由插件。它承载来自 [dsh-agency-agents](https://github.com/MichengAI/dsh-agency-agents) 的 331 位专家完整人格提示词,并融合 **Superpowers 工程能力体系** 与 **OpenSpec 规格驱动开发体系**。插件采用**两轴正交路由**:
20
+ ZCode Expert System v3.2.2 是 ZCode 的专家路由插件。它承载来自 [dsh-agency-agents](https://github.com/MichengAI/dsh-agency-agents) 的 331 位专家完整人格提示词,并融合 **Superpowers 工程能力体系** 与 **OpenSpec 规格驱动开发体系**。插件采用**两轴正交路由**:
14
21
 
15
22
  | 轴 | 回答问题 | 实现 |
16
23
  |---|---|---|
@@ -68,10 +75,38 @@ ZCode Expert System v3.2.1 是 ZCode 的专家路由插件。它承载来自 [ds
68
75
  2. **总经理路由** → 对应的领域总经理(`manager-<分类>`)
69
76
  3. **专家粗筛** → 从该大类专家中选 Top-5 候选(Embedding 可用时用向量,否则词元重叠打分)
70
77
  4. **语义精判** → **主控(会话模型)必须亲自做**;Python 的选择只是词元计数,不是语义判断。`semantic_selection_required=true` 时,主控必须查看 `top_candidates[].score_detail` 按业务语义定夺,必要时用 `build_dispatch_for_expert("<专家名>", task)` 改判
71
- 5. **专家派发** → `Agent(subagent_type="<专家中文显示名>")`,派发 prompt 首段硬声明流程契约优先于专家人格
78
+ 5. **专家派发** → `Agent(subagent_type="<专家中文显示名>")`,派发 prompt 首段硬声明流程契约优先于专家人格;`confidence < 0.5` 且 `selection_basis: heuristic` 时**阻断实施者派发**,先向老板澄清领域
72
79
  6. **上下文传递** → 各阶段结果通过返回值传递
73
80
 
74
- > **语义精判契约**:本插件故意不额外配置 LLM/Embedding 服务,依赖会话中正在运行的模型。`scripts/llm_client.py` 的 `_call_llm` 与 `embedding_client.py` 的 `get_embedding` 恒返回 `None`,粗筛退化为本地词元重叠。当 `semantic_selection_required=true` 时,主控必须复核 `score_detail`,判断 Python 排序是否只是词面巧合(如「飞书集成开发工程师」仅因描述含「登录」二字而胜出),必要时改判。
81
+ > **语义精判契约**:本插件故意不额外配置 LLM/Embedding 服务,依赖会话中正在运行的模型。`scripts/llm_client.py` 的 `_call_llm` 与 `embedding_client.py` 的 `get_embedding` 恒返回 `None`,粗筛退化为本地词元重叠。当 `semantic_selection_required=true` 时,主控必须复核 `score_detail`,判断 Python 排序是否只是词面巧合(如「飞书集成开发工程师」仅因描述含「登录」二字而胜出),必要时改判。`build_dispatch_for_expert` 传入错误的专家名时抛 `ValueError`,并附上 difflib 近似的候选名,不会静默降级。
82
+
83
+ **置信度护栏**(在生成派发计划时生效):
84
+
85
+ | 条件 | 行为 |
86
+ |---|---|
87
+ | `confidence ≥ 0.5` | 进入语义复核 |
88
+ | `confidence < 0.5` **且** `selection_basis: heuristic` | **实施者派发被阻断**(`action: blocked_low_confidence` + `plan.blocking`);须先向老板澄清领域,词元兜底选出的专家不得直接派发 |
89
+ | `confidence < 0.5`,但语义复核已完成 | 允许派发,但附加 `semantic_recheck` 动作,主控必须复核 `top_candidates[].score_detail` |
90
+ | `confidence = 0` | `domain.no_signal = true`——此时的 category 只是 `business-support` 兜底,不构成真实领域判断 |
91
+
92
+ > **词边界护栏**:`返回500` 不会命中 `返回5000行数据`(尾部数字段后面再接数字,视为更长数字串的一部分);零宽字符(ZWSP / BOM / 软连字符)在匹配前即被清洗,无法借此绕过 Bug 判定。
93
+
94
+ ### 规模轴信号词(本轮修复)
95
+
96
+ | 修复点 | 说明 |
97
+ |---|---|
98
+ | **写操作信号** | `WRITE_SIGNALS` 补入「变更 / 改变」:「数据模型变更」「接口变更」判为 `large`,不再误判只读 |
99
+ | **搭建 / 建设(N-NEW-1)** | `WRITE_SIGNALS` 补入「搭建 / 建设」:「搭建一个博客系统」「建设一个数据中台」不再误判只读(此前仅登记于 `FEATURE_CONTEXT` 与 `NEW_BUILD_VERBS` 两张语境/守卫表,主表缺席——与「变更」缺陷同族);`NEW_BUILD_VERBS` 同步补「建设」并提升为模块级常量供表间一致性校验锚定 |
100
+ | **复合执行形态(N-NEW-2)** | `WRITE_SIGNALS` 补入「处理一下 / 处理下 / 应急响应 / 事件响应 / 处置一下 / 处置下」:「处理一下这个报错」「JWT令牌泄漏应急响应处理」等执行任务不再误判只读。裸「处理 / 处置」刻意不收——「怎么处理这个报错」(询问)会失守;新词均不进 `HARD_WRITE`,评审请求(「帮我看看这个搭建方案合理吗」)仍判只读 |
101
+ | **混合任务主诉** | 按诉求出现的位置定主诉:「修复...bug,顺便增加日志」判 **Bug**;「增加修复后的日志采集功能」判**非 Bug** |
102
+ | **表间一致性校验** | `tests/test_p4_consistency.py` 新增三表一致性测试:`NEW_BUILD_VERBS` / `FEATURE_CONTEXT`(名词豁免外)的实施动词必须在 `WRITE_SIGNALS` 登记(或显式豁免留档);历次实证缺陷动词(变更/改变/搭建/建设)为种子锚——再缺主表必红 |
103
+ | **领域路由补词** | `frontend-client` 词表补「博客」:「搭建一个博客系统」不再因泛化词噪声决胜误路由 hr(conf=0.0268) |
104
+
105
+ **残余风险留档(实测记录,均为可接受偏置)**:
106
+
107
+ - **误伤族**(readonly→light,符合「宁可偏重」偏置——误走一趟流程的代价低于漏判跳过门禁):「采纳大家的建设性意见」「事件响应时间的P95统计怎么做」「这个搭建方案需要多少钱」「搭建环境教程」类名词短语。守护测试已锁定评审反例(「帮我看看这个搭建方案合理吗」「搭建方案是什么」仍 readonly)。
108
+ - **覆盖缺口**:「处理这个安全隐患」「处置这个安全事件」仍判只读——裸「处置 / 处理」误伤面大(名词语境「危废处置资质」「异常处理」),本轮只收「一下/下」复合形态;裸词修复待后续决策。
109
+ - **已知同构缺口**:`NEW_BUILD_VERBS` 中「做一个 / 做个 / 新增」字面不在 `WRITE_SIGNALS` 且无单字子串覆盖——实测「做一个登录页面」「新增日志功能」仍误判只读(与「搭建」缺陷完全同形态),已在一致性测试中显式豁免留档,修复待决策。
75
110
 
76
111
  ### 角色 × 专家矩阵(工作流角色)
77
112
 
@@ -170,6 +205,8 @@ python "$ZCODE_PLUGIN_ROOT/skills/zcode-expert-system/scripts/workflow_check.py"
170
205
 
171
206
  退出码:`0` 无 FAIL,`1` 有 FAIL(不得进下一阶段)。
172
207
 
208
+ > **归档前必须校验 `tasks.md` 勾选**:存在未勾选任务时拒绝归档(`completedTasks == totalTasks`,只认 `x`/`X`)。Hook 每轮也会检测未完成任务并告警,不依赖主控自觉。
209
+
173
210
  > **纯 Markdown 检查表一定会被跳过,所以必须机械可验。**
174
211
 
175
212
  ### 32 个一级大类
@@ -232,12 +269,95 @@ zcode-expert-system install
232
269
  (尚未上架,当前请用方式一 npm 安装。)在 ZCode 的插件市场中搜索
233
270
  `zcode-expert-system` 并点击安装。
234
271
 
272
+ ### 方式四:Claude Code 插件
273
+
274
+ 本包同时支持 Claude Code 插件形态。Claude Code 读取 `.claude-plugin/` 目录和
275
+ `hooks/claude-hooks.json`(Claude Code 格式),ZCode 读取 `.zcode-plugin/` 和
276
+ `hooks/hooks.json`(ZCode 格式)。两套配置完全隔离:
277
+
278
+ ```bash
279
+ # 一键安装(推荐)
280
+ npm install -g zcode-expert-system
281
+ zcode-expert-system cc-install
282
+
283
+ # 或从克隆的源码仓库
284
+ npm install
285
+ npm run cc:install
286
+ ```
287
+
288
+ 卸载 Claude Code 侧:
289
+
290
+ ```bash
291
+ zcode-expert-system cc-uninstall # 全局安装
292
+ npm run cc:uninstall # 源码仓库
293
+ ```
294
+
295
+ **一键安装脚本封装了四步 CLI 操作**,无需手工执行:
296
+
297
+ 1. 构建本地市场目录 `~/.claude/plugins/marketplaces/zcode-local/`
298
+ (`marketplace.json` + 完整插件树,含 `skills/zcode-expert-system/` 镜像,让 `/wf:*` 命令的脚本路径可解析)
299
+ 2. 注册市场(`claude plugin marketplace add`)
300
+ 3. 安装并启用插件(`claude plugin install`)
301
+ 4. 验证 `installed_plugins.json` 与 `enabledPlugins` 均已更新
302
+
303
+ 安装后:
304
+
305
+ - 在 Claude Code 中执行 `/plugin`,应出现 `zcode-expert-system`
306
+ - 派发子代理使用限定名格式:`zcode-expert-system:<专家中文名>`(例如 `zcode-expert-system:后端架构师`)
307
+ - 使用 `/wf:*` 命令调用九阶段工作流
308
+
309
+ **P5 安装安全契约**(`scripts/install-claude-code.js`):安装流程是 *预检 → 备份 → 构建 → 失败回滚*:
310
+
311
+ 1. **源树预检** —— `preflightCheck()` 在**删除任何东西之前**校验每个必需源组件
312
+ (`SKILL.md`、`config/`、`agents/`、`commands/`、`.claude-plugin/`、`hooks/`、`scripts/`)
313
+ 均存在;缺任一组件即中止,报 `[preflight] 源树缺少部署必需组件`。
314
+ 2. **删前备份** —— 已存在的市场目录先复制为同级的 `.bak-marketplace-<时间戳>`。
315
+ 3. **失败回滚** —— 构建失败时移除半成品目录并还原备份;若回滚本身也失败,打印备份路径供手工恢复。
316
+
317
+ **未打包组件**:`src/` 声明在 `UNPACKED_COMPONENTS` 中,**不随插件分发**。它承载在建中的
318
+ `openspec/changes/jwt-auth-system` 模块(`src/auth/`),目前尚无生产消费者。
319
+
320
+ **其它命令:**
321
+
322
+ ```bash
323
+ npm run cc:install:dry # 预演,不改动任何东西
324
+ npm run cc:install -- --force # 强制重装
325
+ npm run cc:uninstall # 卸载(移除注册与市场目录)
326
+ ```
327
+
328
+ > **ZCode 兼容性不受影响。** ZCode 的部署路径和行为与之前完全一致。
329
+ > Claude Code 适配层是纯增量,不修改任何 ZCode 面向的文件。
330
+
235
331
  ### 卸载
236
332
 
333
+ 卸载统一走 `install.js`,用 `--zcode` / `--claude-code` 标志选择卸载哪一侧:
334
+
237
335
  ```bash
238
- zcode-expert-system uninstall
239
- # 或
240
- node scripts/install.js --uninstall
336
+ node scripts/install.js --uninstall # 卸载 ZCode + Claude Code(两者)
337
+ node scripts/install.js --uninstall --zcode # 只卸载 ZCode
338
+ node scripts/install.js --uninstall --claude-code # 只卸载 Claude Code
339
+ node scripts/install.js --uninstall --zcode --purge # 卸载 ZCode 并清除所有残留(含运行时数据)
340
+ ```
341
+
342
+ 或用 npm:
343
+
344
+ ```bash
345
+ npm run uninstall # 两者
346
+ npm run uninstall:zcode # 只卸 ZCode
347
+ npm run uninstall:claude # 只卸 Claude Code
348
+ ```
349
+
350
+ **ZCode 侧卸载**:移除插件注册、缓存、技能、命令、子代理、部署清单,并清理
351
+ 备份目录(`skills/*.bak-*`)与已空的命令/`expert-system` 目录。
352
+ **用户运行时数据**(`~/.zcode/expert-system/context/`)默认保留,加 `--purge` 连它一起清除。
353
+
354
+ **Claude Code 侧卸载**:移除插件注册与 `enabledPlugins` 条目、移除市场注册、
355
+ 删除本地市场目录。不触碰 ZCode。
356
+
357
+ 建议先跑预演(零写入,展示完整删除计划):
358
+
359
+ ```bash
360
+ node scripts/install.js --uninstall --dry-run
241
361
  ```
242
362
 
243
363
  ## ⚙️ 配置说明
@@ -335,6 +455,9 @@ node scripts/install.js --uninstall
335
455
  | 领域总经理 | 32 | `~/.zcode/agents/manager-*.md` | `Agent(subagent_type="manager-backend-architecture")` |
336
456
  | 领域专家 | 331 | `~/.zcode/agents/expert-*.md` | `Agent(subagent_type="后端架构师")` |
337
457
 
458
+ > **专家名写错时的表现**:`build_dispatch_for_expert` 找不到精确匹配会抛 `ValueError`,
459
+ > 并在错误信息里给出 difflib 近似候选名,不会静默选一位"差不多"的专家。
460
+
338
461
  > 注意:总经理用 **slug**(`manager-<分类>`)派发,因为 `install.js` 写入部署文件的
339
462
  > `name:` 就是 slug;专家用**中文显示名**派发。两者混淆会导致 `Agent` 调用找不到代理。
340
463
 
@@ -348,15 +471,21 @@ node scripts/install.js --uninstall
348
471
  ```
349
472
  zcode-expert-system/
350
473
  ├── .zcode-plugin/plugin.json # 插件清单
474
+ ├── .claude-plugin/plugin.json # Claude Code 插件清单
351
475
  ├── SKILL.md # ZCode 技能入口
352
476
  ├── README.md / README_CN.md # 英文 / 中文文档
353
477
  ├── zcode_expert_system.py # 域轴(32 大类 → 331 专家)
354
478
  ├── zcode_dev_workflow.py # 规模轴(分诊 → 阶段 → 派发计划)
355
479
  ├── skill_entry.py # 技能调用包装层
356
480
  ├── package.json # npm 包配置
481
+ ├── src/
482
+ │ └── auth/ # jwt-auth-system(openspec 在建;不随插件分发 — UNPACKED_COMPONENTS)
357
483
  ├── scripts/
358
- │ ├── install.js # 一键部署 / 卸载脚本
484
+ │ ├── install.js # ZCode 一键部署 / 卸载脚本
485
+ │ ├── install-claude-code.js # Claude Code 部署(预检 + 备份 + 回滚)
486
+ │ ├── cc-uninstall.js # Claude Code 卸载
359
487
  │ ├── workflow_check.py # 门禁机械核对(+ --self-check)
488
+ │ ├── openspec_engine.py # OpenSpec change/规格引擎
360
489
  │ ├── llm_client.py # LLM 调用辅助
361
490
  │ └── embedding_client.py # Embedding 客户端
362
491
  ├── config/
@@ -377,9 +506,10 @@ zcode-expert-system/
377
506
  │ └── workflow-fusion-design.md # 融合设计基线(为什么这样设计)
378
507
  ├── context/
379
508
  │ └── context-manager.py # 上下文管理器(数据落 ~/.zcode/expert-system/context/)
380
- ├── tests/ # 回归测试(pytest)
509
+ ├── tests/ # 回归测试(pytest,665 passed / 1 skipped)(2026-11-23 词表批次后同步)
381
510
  ├── hooks/
382
511
  │ ├── hooks.json # 钩子配置(ZCode 标准 schema)
512
+ │ ├── claude-hooks.json # 钩子配置(Claude Code 格式)
383
513
  │ └── prepend-global-rules-reminder.mjs # 输入前注入触发规则
384
514
  └── agents/
385
515
  ├── manager-*.md # 32 个领域总经理定义
@@ -415,6 +545,19 @@ python -c "from zcode_expert_system import zcode_expert_system; print(zcode_expe
415
545
  python -m pytest tests/ -q # 末行必须是 "passed",0 failed
416
546
  ```
417
547
 
548
+ 期望基线:**665 passed, 1 skipped**(2026-11-23 词表批次后同步)。
549
+
550
+ > 关于 `src/auth/`:JWT 认证模块(`jwt-auth-system` OpenSpec change)尚在建设中,由
551
+ > `tests/test_auth_login.py` 覆盖。其实现选择是刻意为之:
552
+ >
553
+ > - **口令哈希**:PBKDF2-HMAC-SHA256、100 000 轮、16 字节随机盐,存 base64(`salt||dk`)
554
+ > (bcrypt 仅作为文档记录的备选,不是依赖)
555
+ > - **refresh token**:用 `secrets.token_urlsafe(32)` 生成(256 位熵),不再用
556
+ > `sha256(user_id:time_ns)` 这类可预测派生;库中**只存 sha256 哈希**,不存令牌明文
557
+ > - **过期时间**:`expires_at` 以 **ISO 8601 字符串**存储,用 `datetime.fromisoformat`
558
+ > 解析(此前的 `float(ISO串)` 必然抛错)
559
+ > - **JWT 验签**:先解析 header,白名单校验 **`alg=HS256` 与 `typ=JWT`**,通过后再验签名
560
+
418
561
  ## 📄 许可证
419
562
 
420
563
  本项目基于 [MIT 许可证](LICENSE) 开源。
@@ -441,4 +584,4 @@ python -m pytest tests/ -q # 末行必须是 "passed",0 failed
441
584
 
442
585
  ---
443
586
 
444
- **ZCode Expert System v3.2.1** - 让 AI 专家协作更智能 🚀
587
+ **ZCode Expert System v3.2.2** - 让 AI 专家协作更智能 🚀
package/SKILL.md CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: zcode-expert-system
3
3
  description: Use when a task spans design, development, security, marketing, testing, research, finance, legal, healthcare or any other professional domain and needs routing to a specialist, or when the task is a software engineering task that needs a disciplined workflow (requirements → spec → plan → TDD → review → delivery). 331 experts in 32 top-level categories with two-axis routing (scale → workflow stages, domain → expert), nine-stage dev workflow with gates and evidence. Also use when the user says 专家 / 会诊 / 多专家 / 专业分析 / 任务路由 / 任务分解 / 工作流 / 研发流程.
4
- version: "3.2.1"
4
+ version: "3.2.2"
5
5
  ---
6
6
 
7
7
  # ZCode Expert System v3.2
package/bin/cli.js CHANGED
@@ -15,14 +15,17 @@ const HELP = `
15
15
  ZCode 专家体系 - CLI 工具
16
16
 
17
17
  用法:
18
- zcode-expert-system install 安装插件到 ZCode
19
- zcode-expert-system uninstall 从 ZCode 卸载插件
20
- zcode-expert-system version 显示版本信息
21
- zcode-expert-system help 显示本帮助
18
+ zcode-expert-system install 安装插件到 ZCode
19
+ zcode-expert-system uninstall 从 ZCode 卸载插件
20
+ zcode-expert-system cc-install 安装插件到 Claude Code
21
+ zcode-expert-system cc-uninstall 从 Claude Code 卸载插件
22
+ zcode-expert-system version 显示版本信息
23
+ zcode-expert-system help 显示本帮助
22
24
 
23
25
  示例:
24
26
  zcode-expert-system install
25
- zcode-expert-system uninstall
27
+ zcode-expert-system cc-install
28
+ zcode-expert-system cc-uninstall
26
29
  `;
27
30
 
28
31
  function runInstaller(uninstall) {
@@ -48,6 +51,20 @@ switch (command) {
48
51
  runInstaller(true);
49
52
  break;
50
53
 
54
+ // cc-install / cc-uninstall:Claude Code 侧安装/卸载(全局安装场景,
55
+ // npm script 不可用——README 方式四的 `zcode-expert-system cc:install`
56
+ // 之前无对应实现,2026-11-24 补齐)。
57
+ case 'cc-install':
58
+ console.log('安装 Claude Code 专家体系插件...');
59
+ require('../scripts/install-claude-code.js');
60
+ break;
61
+
62
+ case 'cc-uninstall':
63
+ console.log('卸载 Claude Code 专家体系插件...');
64
+ process.argv = [process.argv[0], 'install-claude-code.js', '--uninstall', ...process.argv.slice(3)];
65
+ require('../scripts/install-claude-code.js');
66
+ break;
67
+
51
68
  case 'version': {
52
69
  const packageJson = require('../package.json');
53
70
  console.log(`版本: ${packageJson.version}`);