code-workspace-zhuiyi 0.1.0-beta.2 → 0.1.0-beta.4

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 (47) hide show
  1. package/README.md +81 -8
  2. package/README.zh-CN.md +79 -8
  3. package/artifacts/manifest.json +12 -1
  4. package/artifacts/templates/claude/task-coordination-settings.json +13 -0
  5. package/artifacts/templates/codex/task-coordination-hooks.json +12 -0
  6. package/bin/code-workspace-task-hook.js +17 -0
  7. package/docs/extension-architecture.zh-CN.md +4 -0
  8. package/extensions/zhuiyi-jira-mcp/0.1.0/artifacts/claude/server.json +3 -1
  9. package/extensions/zhuiyi-jira-mcp/0.1.0/artifacts/codex/config.toml +2 -0
  10. package/extensions/zhuiyi-jira-mcp/0.1.0/artifacts/gitignore +2 -0
  11. package/extensions/zhuiyi-jira-mcp/0.1.0/init.js +3 -0
  12. package/extensions/zhuiyi-jira-mcp/0.1.0/manifest.json +8 -1
  13. package/package.json +2 -1
  14. package/schemas/extension-manifest-v3.json +26 -1
  15. package/spec/extension/v1/specification.en-US.md +36 -0
  16. package/spec/extension/v1/specification.zh-CN.md +34 -0
  17. package/src/cli/commands/extension.js +3 -1
  18. package/src/cli/commands/init.js +2 -0
  19. package/src/cli/commands/project-branch.js +2 -2
  20. package/src/cli/commands/task.js +75 -0
  21. package/src/cli/commands/update.js +15 -0
  22. package/src/cli/registry.js +18 -2
  23. package/src/cli.js +2 -0
  24. package/src/core/config.js +195 -17
  25. package/src/core/extension-artifacts.js +7 -1
  26. package/src/core/extensions.js +59 -9
  27. package/src/core/hooks.js +253 -0
  28. package/src/core/initializer.js +20 -5
  29. package/src/core/managed-files.js +9 -3
  30. package/src/core/project-configuration.js +4 -3
  31. package/src/core/task-coordination-managed.js +112 -0
  32. package/src/core/task-coordination-protocol.js +214 -0
  33. package/src/core/task-coordination.js +1077 -0
  34. package/src/hooks/adapters/claude.js +62 -0
  35. package/src/hooks/adapters/codex.js +59 -0
  36. package/src/hooks/adapters/common.js +49 -0
  37. package/src/hooks/adapters/index.js +18 -0
  38. package/src/hooks/claude-task-coordination.js +3 -0
  39. package/src/hooks/codex-task-coordination.js +3 -0
  40. package/src/hooks/index.js +7 -0
  41. package/src/index.js +10 -0
  42. package/docs/extensions.md +0 -64
  43. package/docs/extensions.zh-CN.md +0 -64
  44. package/extensions/openspec-workspace/1.0.0/artifacts/claude/SKILL.md +0 -16
  45. package/extensions/openspec-workspace/1.0.0/artifacts/codex/SKILL.md +0 -16
  46. package/extensions/openspec-workspace/1.0.0/init.js +0 -54
  47. package/extensions/openspec-workspace/1.0.0/manifest.json +0 -27
package/README.md CHANGED
@@ -34,10 +34,11 @@ code-workspace init . \
34
34
  ```
35
35
 
36
36
  Use `--tools claude`, `--tools codex`, or `--tools none` to override the default tool selection. Codex monitoring is enabled by default when Codex is selected; use `--no-monitor` to disable it.
37
+ Pass `--coordination` to install the provider-neutral write-coordination Hook artifacts for the selected tools.
37
38
 
38
39
  Initialization writes only Workspace-owned state and integrations:
39
40
 
40
- - `.code-workspace/config.yaml` and `.code-workspace/state.json`
41
+ - `.code-workspace/config.yaml`, its referenced project configuration file (default: `.code-workspace/config-projects.yaml`), and `.code-workspace/state.json`
41
42
  - `USER_GUIDE.md`
42
43
  - `CLAUDE.md` and/or `AGENTS.md`
43
44
  - Workspace-specific commands and skills whose names start with `code-workspace-` or use the `/code-workspace` namespace
@@ -50,24 +51,29 @@ It does not create `openspec/`, install native `/opsx` commands, or install nati
50
51
  `init` can install integrations from the versioned `extensions/` repository shipped inside this npm package. Select extension names interactively, or pass a comma-separated name list non-interactively. The dedicated install command accepts one or more names; without names it opens the built-in extension multiselect, where ESC exits without changes:
51
52
 
52
53
  ```bash
53
- code-w init . --extensions openspec-workspace --yes
54
+ code-w init . --extensions zhuiyi-jira-mcp --yes
54
55
  code-w init . --extensions none --yes
55
56
  code-w extension install
56
- code-w extension install openspec-workspace --yes
57
- code-w extension uninstall openspec-workspace --yes
57
+ code-w extension install zhuiyi-jira-mcp --yes
58
+ code-w extension uninstall zhuiyi-jira-mcp --yes
58
59
  ```
59
60
 
60
61
  The Workspace operation lock shared by init, extension install, and extension uninstall is configured in the Code Workspace project's `.env` (not in the target Workspace). `CODE_WORKSPACE_INIT_LOCK_UPDATE_MS` defaults to `5000`, and `CODE_WORKSPACE_INIT_LOCK_STALE_MS` defaults to `30000`; process environment variables take precedence. See `.env.example` for the project configuration names.
61
62
 
62
- Users select names, not versions; `openspec-workspace@1.0.0` is intentionally rejected. Code Workspace resolves the highest extension SemVer implemented against a Host-supported Extension Spec before confirmation. A new non-interactive Workspace installs no extensions unless `--extensions` is provided. Re-initializing an existing Workspace defaults to its installed extensions and upgrades them when a newer supported built-in version exists. `none` skips extension work and does not uninstall existing artifacts.
63
+ Users select names, not versions; `zhuiyi-jira-mcp@0.1.0` is intentionally rejected. Code Workspace resolves the highest extension SemVer implemented against a Host-supported Extension Spec before confirmation. A new non-interactive Workspace installs no extensions unless `--extensions` is provided. Re-initializing an existing Workspace defaults to its installed extensions and upgrades them when a newer supported built-in version exists. `none` skips extension work and does not uninstall existing artifacts.
63
64
 
64
65
  `extension install` does not rerun core Workspace initialization. In JSON, non-TTY, or `--yes` mode, at least one extension name is required. Multiple names are installed in order with one confirmation boundary and independent transactions; any failure makes the install command fail while later extensions still run.
65
66
 
66
- The bundled `openspec-workspace` extension installs a namespaced `code-workspace-openspec-propose` skill for the selected Agent tools. It does not create an `openspec/` directory or install native OpenSpec commands.
67
+ The bundled `zhuiyi-jira-mcp` extension configures the Jira MCP service for the selected Agent tools. It does not create an `openspec/` directory or install native OpenSpec commands.
67
68
 
68
69
  Extension entries run in separate Node processes and generate files in temporary staging directories. The host rejects undeclared, missing, symbolic-link, non-file, path-escaping, conflicting, and checksum-mismatched artifacts before transactionally installing them. Per-Workspace state is stored in `.code-workspace/ext-manifest.json`. A failed extension is reported as a warning and does not roll back successful core initialization or stop later extensions; a failed upgrade restores and retains the previous installed version.
69
70
 
70
- Extensions may own complete files or contribute Host-managed Codex TOML blocks and Hook fragments. Shared targets are composed and verified by Code Workspace; extensions never patch the real Workspace directly. Uninstall uses recorded installed state and does not execute extension code. Unknown changes to extension-owned files or contributions stop the operation instead of being overwritten.
71
+ Extensions may own complete files or declare Host-managed abstract Hooks. Codex and Claude
72
+ adaptors render those declarations into each provider's native configuration and dynamically plug
73
+ or unplug them during extension install, upgrade, and uninstall. Shared targets are composed and
74
+ verified by Code Workspace; extensions never patch the real Workspace directly. Uninstall uses
75
+ recorded installed state and does not execute extension code. Unknown changes to extension-owned
76
+ files or contributions stop the operation instead of being overwritten.
71
77
 
72
78
  This is fault isolation, not a malicious-code security sandbox. The experimental release trusts only extension code shipped with Code Workspace; network sources, external extension directories, dependencies, arbitrary patches, force uninstall, disable commands, and automatic extension updates through `code-w update` are not supported. The developer contract is in `docs/extensions.md`.
73
79
 
@@ -93,6 +99,32 @@ code-workspace project add --projects-file projects.json --yes --json
93
99
 
94
100
  The registry stores each project's name, real location, registered branch, type, and context. The registered branch is the Code Workspace expected state; the actual branch is observed from the selected Git worktree. Workspace never guesses a path from a conversation or automatically decides which branch is authoritative.
95
101
 
102
+ Project registration is always stored in a separate file in the `.code-workspace` directory. Initialization uses `config-projects.yaml` by default, while `projects.ref` may name any safe regular filename in that directory:
103
+
104
+ ```yaml
105
+ # .code-workspace/config.yaml
106
+ projects:
107
+ ref: config-projects.yaml
108
+ ```
109
+
110
+ The referenced file uses this format:
111
+
112
+ ```yaml
113
+ # .code-workspace/config-projects.yaml
114
+ schemaVersion: 1
115
+ projects:
116
+ - name: payments
117
+ location: /absolute/path/to/payments
118
+ branch: main
119
+ type: backend
120
+ context: |-
121
+ Service ownership and navigation context.
122
+ ```
123
+
124
+ `projects.ref` is resolved relative to `config.yaml`. It must be one safe regular filename in the same `.code-workspace` directory; URLs, globs, absolute paths, path traversal, and inline `projects` arrays are not supported. All project commands keep their existing CLI semantics; they read and write the referenced project file. The `.code-workspace/` directory is ignored by default, so Git history for this local registry requires an explicit repository policy.
125
+
126
+ For example, `ref: team-projects.yaml` makes the project registry `.code-workspace/team-projects.yaml`; the default remains `config-projects.yaml`.
127
+
96
128
  ## Daily commands
97
129
 
98
130
  ```bash
@@ -117,11 +149,18 @@ The two reconciliation directions are deliberately separate:
117
149
 
118
150
  Both commands detect plan drift and verify postconditions. `project branch update-latest` is the separate, opt-in path for projects with `updateLatest: true`; it only fetches the configured upstream and fast-forwards a clean matching branch. Code Workspace never creates or downloads a branch and never performs stash, reset, rebase, non-fast-forward merge, production-code edits, or conflict resolution.
119
151
 
120
- Users may manually set the optional project policy in `.code-workspace/config.yaml`:
152
+ Users may manually set the optional project policy in the file named by `projects.ref` (default: `.code-workspace/config-projects.yaml`):
121
153
 
122
154
  ```yaml
155
+ # .code-workspace/config-projects.yaml
156
+ schemaVersion: 1
123
157
  projects:
124
158
  - name: payments
159
+ location: /absolute/path/to/payments
160
+ branch: main
161
+ type: backend
162
+ context: |-
163
+ Service ownership and navigation context.
125
164
  updateLatest: true
126
165
  ```
127
166
 
@@ -129,11 +168,45 @@ AI/Agent must not directly edit this file. They may read the policy and invoke t
129
168
 
130
169
  `permissions apply` shows the complete authorization plan for the selected Agent tools, requires confirmation when changes are needed, applies and verifies the requested grants, and reports the result per tool. Agent directory access remains a user authorization. The command adds missing registered-project access but does not revoke additional directories; use `project remove` or edit the Agent settings explicitly to revoke access.
131
170
 
171
+ ## Coordinate concurrent Agent writes
172
+
173
+ When trusted Codex or Claude Hooks are installed, Code Workspace keeps the coordination ledger outside the Workspace and reserves write ranges before a supported tool runs. Different files in one project can proceed after an explicit project-parallel approval; overlapping files are denied without a force override.
174
+
175
+ Inspect tasks, claims, and pending recovery decisions:
176
+
177
+ ```bash
178
+ code-workspace task list --json
179
+ code-workspace task show <task-id> --json
180
+ code-workspace task lock list --json
181
+ code-workspace task decision show <request-id> --json
182
+ ```
183
+
184
+ Resolve a pending decision only after reviewing its evidence. Planned-write commands require confirmation; automation must pass `--yes` and always retry the original Agent operation after a successful decision:
185
+
186
+ ```bash
187
+ code-workspace task decision keep <request-id> --yes --json
188
+ code-workspace task decision approve <request-id> --yes --json
189
+ code-workspace task decision release <request-id> --yes --json
190
+ code-workspace task decision abandon <request-id> --yes --json
191
+ ```
192
+
193
+ `ACTIVE` file conflicts cannot be overridden. `UNKNOWN` reservations remain protected until the user keeps them or abandons the entire generation; a known live process blocks abandon. The mechanism covers only trusted, enabled, supported Agent Hooks and is not an OS-level sandbox for editors, shells, or external processes.
194
+
195
+ Hook support matrix (schema v1):
196
+
197
+ | Provider | Lifecycle events | Write events | Target handling |
198
+ | --- | --- | --- | --- |
199
+ | Codex | `SessionStart`, `UserPromptSubmit`, `PermissionRequest`, `Stop`, `SessionEnd` | `PreToolUse`, `PostToolUse` and available failure events | Known Edit/Write-style tools use exact files; unknown shell/tools use `PROJECT_WIDE` |
200
+ | Claude | `SessionStart`, `UserPromptSubmit`, `PermissionRequest`, `Stop`, `StopFailure`, `SessionEnd` | `PreToolUse`, `PostToolUse`, `PostToolUseFailure` | Same normalized core decisions and scope rules as Codex |
201
+
202
+ The adapters are versioned fixtures rather than a promise that future Agent releases keep identical native fields. New or unrecognized tools fail closed as possible writes; Hook enforcement does not cover bypassed or disabled Hooks, external editors, or arbitrary OS processes.
203
+
132
204
  ## Update and language
133
205
 
134
206
  ```bash
135
207
  code-workspace update --json
136
208
  code-workspace update --language zh-CN --json
209
+ code-workspace update --coordination --json
137
210
  code-workspace language --json
138
211
  ```
139
212
 
package/README.zh-CN.md CHANGED
@@ -34,10 +34,11 @@ code-workspace init . \
34
34
  ```
35
35
 
36
36
  可用 `--tools claude`、`--tools codex` 或 `--tools none` 覆盖默认工具选择。选择 Codex 时默认启用监控;可传 `--no-monitor` 关闭。
37
+ 传入 `--coordination` 可为选中的工具安装与 Monitor 独立的写入协调 Hook 制品。
37
38
 
38
39
  初始化只写入 Workspace 自有状态和集成:
39
40
 
40
- - `.code-workspace/config.yaml` 与 `.code-workspace/state.json`
41
+ - `.code-workspace/config.yaml`、其引用的项目配置文件(默认:`.code-workspace/config-projects.yaml`)与 `.code-workspace/state.json`
41
42
  - `USER_GUIDE.md`
42
43
  - `CLAUDE.md` 和/或 `AGENTS.md`
43
44
  - 名称以 `code-workspace-` 开头或使用 `/code-workspace` 命名空间的 Workspace 专用命令与 Skill
@@ -50,24 +51,27 @@ code-workspace init . \
50
51
  `init` 可以从 npm 包内随附的版本化 `extensions/` 仓库安装集成。交互模式按扩展名多选;非交互模式传入逗号分隔的扩展名。独立安装命令接受一个或多个扩展名;不传名称时打开内置扩展多选,按 ESC 可无修改退出:
51
52
 
52
53
  ```bash
53
- code-w init . --extensions openspec-workspace --yes
54
+ code-w init . --extensions zhuiyi-jira-mcp --yes
54
55
  code-w init . --extensions none --yes
55
56
  code-w extension install
56
- code-w extension install openspec-workspace --yes
57
- code-w extension uninstall openspec-workspace --yes
57
+ code-w extension install zhuiyi-jira-mcp --yes
58
+ code-w extension uninstall zhuiyi-jira-mcp --yes
58
59
  ```
59
60
 
60
61
  `init`、扩展安装和扩展卸载共享的 Workspace 操作锁配置在 Code Workspace 项目自身的 `.env` 中(不在目标 Workspace 中)。`CODE_WORKSPACE_INIT_LOCK_UPDATE_MS` 默认值为 `5000`,`CODE_WORKSPACE_INIT_LOCK_STALE_MS` 默认值为 `30000`;进程环境变量优先于 `.env`。配置项名称见 `.env.example`。
61
62
 
62
- 用户只选择扩展名,不能选择版本;`openspec-workspace@1.0.0` 会被明确拒绝。Code Workspace 在确认前,从 Host 明确支持的 Extension Spec 实现中解析最高扩展 SemVer。新 Workspace 非交互初始化时,未传 `--extensions` 就不安装扩展;已有 Workspace 重新初始化时,默认选择已安装扩展,并在存在更高受支持内置版本时升级。`none` 只跳过本次扩展初始化,不会卸载已有制品。
63
+ 用户只选择扩展名,不能选择版本;`zhuiyi-jira-mcp@0.1.0` 会被明确拒绝。Code Workspace 在确认前,从 Host 明确支持的 Extension Spec 实现中解析最高扩展 SemVer。新 Workspace 非交互初始化时,未传 `--extensions` 就不安装扩展;已有 Workspace 重新初始化时,默认选择已安装扩展,并在存在更高受支持内置版本时升级。`none` 只跳过本次扩展初始化,不会卸载已有制品。
63
64
 
64
65
  `extension install` 不会重新执行 Workspace 核心初始化。在 JSON、非 TTY 或 `--yes` 模式下,必须至少提供一个扩展名。多个名称按顺序安装,只确认一次且各自使用独立事务;任一扩展失败会使安装命令失败,但后续扩展仍会继续执行。
65
66
 
66
- 内置 `openspec-workspace` 扩展会为选中的 Agent 工具安装命名空间为 `code-workspace-openspec-propose` 的 Skill;它不会创建 `openspec/` 目录,也不会安装 OpenSpec 原生命令。
67
+ 当前随包提供的内置扩展是 `zhuiyi-jira-mcp`,用于为选中的 Agent 工具配置 Jira MCP 服务;它不会创建 `openspec/` 目录,也不会安装 OpenSpec 原生命令。
67
68
 
68
69
  扩展入口在独立 Node 进程中运行,只向临时 staging 目录生成文件。Host 会在事务安装前拒绝未声明、缺失、符号链接、非文件、路径逃逸、目标冲突和 hash 不匹配的制品。Workspace 状态存放在 `.code-workspace/ext-manifest.json`。扩展失败以 warning 报告,不回滚已成功的核心初始化,也不阻止后续扩展;升级失败会恢复并保留旧的已安装版本。
69
70
 
70
- 扩展可以独占完整文件,也可以贡献由 Host 管理的 Codex TOML 配置块和 Hook 片段。共享目标由 Code Workspace 合成和验证;扩展不会直接 patch 真实 Workspace。卸载只使用已安装状态,不执行扩展代码;扩展所有的文件或贡献存在未知修改时会拒绝覆盖或删除。
71
+ 扩展可以独占完整文件,也可以声明由 Host 管理的抽象 Hook。Host 通过 Codex/Claude adaptor
72
+ 把声明转换为各自的原生配置,并在扩展安装、升级和卸载时动态插拔;共享目标由 Code
73
+ Workspace 合成和验证,扩展不会直接 patch 真实 Workspace。卸载只使用已安装状态,不执行
74
+ 扩展代码;扩展所有的文件或贡献存在未知修改时会拒绝覆盖或删除。
71
75
 
72
76
  这是故障隔离,不是恶意代码安全沙箱。试验版本只信任随 Code Workspace 发布的扩展代码;暂不支持网络源、外部扩展目录、扩展依赖、任意 patch、强制卸载、禁用命令,也不会通过 `code-w update` 自动更新扩展。开发契约见 `docs/extensions.zh-CN.md`。
73
77
 
@@ -93,6 +97,32 @@ code-workspace project add --projects-file projects.json --yes --json
93
97
 
94
98
  注册表保存项目名称、真实路径、注册分支、类型和上下文。注册分支是 Code Workspace 的期望状态,实际分支是从选中 Git worktree 观测到的状态。Workspace 不会根据对话猜测路径,也不会自动判断哪一侧分支更权威。
95
99
 
100
+ 项目注册配置始终独立保存于 `.code-workspace` 目录下的单独文件。初始化默认使用 `config-projects.yaml`,但 `projects.ref` 可以引用该目录下任意安全的普通文件名:
101
+
102
+ ```yaml
103
+ # .code-workspace/config.yaml
104
+ projects:
105
+ ref: config-projects.yaml
106
+ ```
107
+
108
+ 引用文件使用以下格式:
109
+
110
+ ```yaml
111
+ # .code-workspace/config-projects.yaml
112
+ schemaVersion: 1
113
+ projects:
114
+ - name: payments
115
+ location: /absolute/path/to/payments
116
+ branch: main
117
+ type: backend
118
+ context: |-
119
+ 服务职责和代码导航上下文。
120
+ ```
121
+
122
+ `projects.ref` 相对于 `config.yaml` 解析,必须是同一 `.code-workspace` 目录下的安全普通文件名。不支持 URL、glob、绝对路径、路径逃逸或内联 `projects` 数组。所有项目 CLI 的语义保持不变,只是改为读取和写入引用文件。`.code-workspace/` 默认被忽略;如需 Git 历史,需要显式制定仓库策略。
123
+
124
+ 例如,`ref: team-projects.yaml` 会将项目注册表放在 `.code-workspace/team-projects.yaml`;默认名称仍为 `config-projects.yaml`。
125
+
96
126
  ## 日常命令
97
127
 
98
128
  ```bash
@@ -117,11 +147,18 @@ code-workspace doctor --json
117
147
 
118
148
  两条命令都会检查计划漂移并验证后置条件。`project branch update-latest` 是独立的显式配置路径:仅当项目 `updateLatest: true` 时,才对干净且分支一致的 worktree fetch upstream 并 fast-forward。Code Workspace 不会创建或下载分支,也不会执行 stash、reset、rebase、非 fast-forward merge、生产代码编辑或冲突处理。
119
149
 
120
- 用户可以手动在 `.code-workspace/config.yaml` 中设置项目策略:
150
+ 用户可以手动在 `projects.ref` 指定的文件(默认:`.code-workspace/config-projects.yaml`)中设置项目策略:
121
151
 
122
152
  ```yaml
153
+ # .code-workspace/config-projects.yaml
154
+ schemaVersion: 1
123
155
  projects:
124
156
  - name: payments
157
+ location: /absolute/path/to/payments
158
+ branch: main
159
+ type: backend
160
+ context: |-
161
+ 服务职责和代码导航上下文。
125
162
  updateLatest: true
126
163
  ```
127
164
 
@@ -129,11 +166,45 @@ AI/Agent 不得直接编辑该文件;可以读取策略并调用已注册的 C
129
166
 
130
167
  `permissions apply` 会展示选中 Agent 工具的完整授权计划,在需要修改时要求确认,实施并验证请求的授权,并按工具报告结果。Agent 目录访问仍属于用户授权。该命令只补齐已注册项目缺失的访问权限,不撤销额外目录;如需撤销,请使用 `project remove` 或显式编辑 Agent 设置。
131
168
 
169
+ ## 协调并行 Agent 写入
170
+
171
+ 安装并信任 Codex 或 Claude 协调 Hook 后,Code Workspace 会把协调台账保存在 Workspace 外部,并在受支持工具真正运行前预约写入范围。同一项目写不同文件时,经过一次明确的项目并行确认即可继续;范围重叠时强制拒绝,不提供强制覆盖。
172
+
173
+ 查询任务、范围 claim 和待处理裁决:
174
+
175
+ ```bash
176
+ code-workspace task list --json
177
+ code-workspace task show <task-id> --json
178
+ code-workspace task lock list --json
179
+ code-workspace task decision show <request-id> --json
180
+ ```
181
+
182
+ 查看证据后再处理裁决。写入型命令需要确认;自动化场景必须传 `--yes`,裁决成功后始终重新执行原 Agent 操作:
183
+
184
+ ```bash
185
+ code-workspace task decision keep <request-id> --yes --json
186
+ code-workspace task decision approve <request-id> --yes --json
187
+ code-workspace task decision release <request-id> --yes --json
188
+ code-workspace task decision abandon <request-id> --yes --json
189
+ ```
190
+
191
+ `ACTIVE` 文件冲突不能覆盖。`UNKNOWN` reservation 必须由用户选择保留,或放弃整个 generation;已知旧进程仍存活时不能 abandon。该机制只覆盖已信任、已启用且受支持的 Agent Hook,不是编辑器、Shell 或外部进程的 OS 级沙箱。
192
+
193
+ Hook 支持矩阵(schema v1):
194
+
195
+ | Provider | 生命周期事件 | 写入事件 | 目标处理 |
196
+ | --- | --- | --- | --- |
197
+ | Codex | `SessionStart`、`UserPromptSubmit`、`PermissionRequest`、`Stop`、`SessionEnd` | `PreToolUse`、`PostToolUse` 及可用失败事件 | 已知 Edit/Write 类工具使用 exact 文件;未知 Shell/工具使用 `PROJECT_WIDE` |
198
+ | Claude | `SessionStart`、`UserPromptSubmit`、`PermissionRequest`、`Stop`、`StopFailure`、`SessionEnd` | `PreToolUse`、`PostToolUse`、`PostToolUseFailure` | 与 Codex 使用相同的归一化核心决策和范围规则 |
199
+
200
+ 适配器通过版本化 fixture 固化输入,而不是承诺未来 Agent 版本保持相同原生字段。新增或无法识别的工具按可能写入处理并 fail closed;Hook 强制范围不包含被绕过或禁用的 Hook、外部编辑器或任意 OS 进程。
201
+
132
202
  ## 更新与语言
133
203
 
134
204
  ```bash
135
205
  code-workspace update --json
136
206
  code-workspace update --language en-US --json
207
+ code-workspace update --coordination --json
137
208
  code-workspace language --json
138
209
  ```
139
210
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "schemaVersion": 2,
3
- "releaseVersion": "0.1.0-beta.2",
3
+ "releaseVersion": "0.1.0-beta.4",
4
4
  "requirements": {
5
5
  "node": ">=20.19.0"
6
6
  },
@@ -22,6 +22,17 @@
22
22
  "sha256": "4dc207305a3975ab7272addedf3bc2930054e860c2b0b2b6e0e102f4457f5cc0"
23
23
  }
24
24
  ],
25
+ "coordinationArtifacts": {
26
+ "schemaVersion": 1,
27
+ "sources": [
28
+ { "id": "task-coordination-codex-hooks", "path": "templates/codex/task-coordination-hooks.json", "sha256": "68fcefa83f75294fd270713e07eb3ea3f266e63dc9d2be4ba77fe8af7596742f" },
29
+ { "id": "task-coordination-claude-settings", "path": "templates/claude/task-coordination-settings.json", "sha256": "4faedcc67a78c8e7e61e44dc34571e55d0d3a2ce1ce7aa636222e1813505ca29" }
30
+ ],
31
+ "managedFiles": [
32
+ { "id": "task-coordination-codex-hooks", "target": ".codex/task-coordination-hooks.json", "tool": "codex" },
33
+ { "id": "task-coordination-claude-settings", "target": ".claude/task-coordination-settings.json", "tool": "claude" }
34
+ ]
35
+ },
25
36
  "managedFiles": [
26
37
  {
27
38
  "id": "workspace-user-guide",
@@ -0,0 +1,13 @@
1
+ {
2
+ "hooks": {
3
+ "SessionStart": [{ "hooks": [{ "type": "command", "command": "code-workspace-task-hook claude", "timeout": 2 }] }],
4
+ "UserPromptSubmit": [{ "hooks": [{ "type": "command", "command": "code-workspace-task-hook claude", "timeout": 2 }] }],
5
+ "PermissionRequest": [{ "hooks": [{ "type": "command", "command": "code-workspace-task-hook claude", "timeout": 2 }] }],
6
+ "PreToolUse": [{ "matcher": "*", "hooks": [{ "type": "command", "command": "code-workspace-task-hook claude", "timeout": 2 }] }],
7
+ "PostToolUse": [{ "matcher": "*", "hooks": [{ "type": "command", "command": "code-workspace-task-hook claude", "timeout": 2 }] }],
8
+ "PostToolUseFailure": [{ "matcher": "*", "hooks": [{ "type": "command", "command": "code-workspace-task-hook claude", "timeout": 2 }] }],
9
+ "Stop": [{ "hooks": [{ "type": "command", "command": "code-workspace-task-hook claude", "timeout": 2 }] }],
10
+ "StopFailure": [{ "hooks": [{ "type": "command", "command": "code-workspace-task-hook claude", "timeout": 2 }] }],
11
+ "SessionEnd": [{ "hooks": [{ "type": "command", "command": "code-workspace-task-hook claude", "timeout": 2 }] }]
12
+ }
13
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "description": "Coordinate supported Codex writes before tools execute. This Hook is independent from Monitor reporting.",
3
+ "hooks": {
4
+ "SessionStart": [{ "hooks": [{ "type": "command", "command": "code-workspace-task-hook codex", "timeout": 2 }] }],
5
+ "UserPromptSubmit": [{ "hooks": [{ "type": "command", "command": "code-workspace-task-hook codex", "timeout": 2 }] }],
6
+ "PermissionRequest": [{ "hooks": [{ "type": "command", "command": "code-workspace-task-hook codex", "timeout": 2 }] }],
7
+ "PreToolUse": [{ "matcher": "*", "hooks": [{ "type": "command", "command": "code-workspace-task-hook codex", "timeout": 2 }] }],
8
+ "PostToolUse": [{ "matcher": "*", "hooks": [{ "type": "command", "command": "code-workspace-task-hook codex", "timeout": 2 }] }],
9
+ "Stop": [{ "hooks": [{ "type": "command", "command": "code-workspace-task-hook codex", "timeout": 2 }] }],
10
+ "SessionEnd": [{ "hooks": [{ "type": "command", "command": "code-workspace-task-hook codex", "timeout": 2 }] }]
11
+ }
12
+ }
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const { runHookStdin } = require("../src/core/task-coordination-protocol");
5
+
6
+ const provider = String(process.argv[2] || "").toLowerCase();
7
+ if (!["codex", "claude"].includes(provider)) {
8
+ process.stdout.write(JSON.stringify({ decision: "block", reason: "Unsupported task coordination Hook provider." }) + "\n");
9
+ process.exitCode = 2;
10
+ } else {
11
+ runHookStdin(provider, { workspaceRoot: process.cwd() })
12
+ .then((output) => process.stdout.write(`${JSON.stringify(output)}\n`))
13
+ .catch((error) => {
14
+ process.stdout.write(`${JSON.stringify({ decision: "block", reason: `Task coordination Hook failed closed: ${error.message}` })}\n`);
15
+ process.exitCode = 1;
16
+ });
17
+ }
@@ -64,6 +64,10 @@ Host 是 Code Workspace 中负责扩展生命周期治理的核心实现。Host
64
64
 
65
65
  扩展仓库是 Code Workspace 发布包中用于保存内置扩展的目录集合。基础版不从网络发现或安装扩展定义。
66
66
 
67
+ 扩展还可以通过 manifest 的 `hooks` 声明抽象 Workspace Hook。Hook 声明由 Host 通过
68
+ Codex/Claude adaptor 转换为原生配置,并随扩展安装、升级和卸载动态插拔;扩展不得把
69
+ Provider 原生事件名直接写入公共合同。
70
+
67
71
  ### 4.3 扩展包
68
72
 
69
73
  扩展包是一个符合扩展协议的、具有明确 id 和版本的可执行目录:
@@ -5,10 +5,12 @@
5
5
  ],
6
6
  "env": {
7
7
  "JIRA_AUTH_TYPE": "cookie",
8
+ "JIRA_COOKIE": "",
8
9
  "JIRA_API_VERSION": "latest",
9
10
  "JIRA_ALLOWED_HOSTS": "jira.in.wezhuiyi.com",
10
11
  "JIRA_REQUIREMENT_FIELDS": "{\"acceptanceCriteria\":\"customfield_10042\",\"storyPoints\":\"customfield_10016\"}",
11
12
  "JIRA_ATTACHMENT_DIR": ".jira-attachments",
12
- "JIRA_ATTACHMENT_MAX_SIZE": "20MB"
13
+ "JIRA_ATTACHMENT_MAX_SIZE": "20MB",
14
+ "JIRA_ATTACHMENT_ALLOWED_TYPES": "pdf,png,jpg,jpeg,gif,webp,txt,md,csv,json,xml,doc,docx,xls,xlsx,ppt,pptx,html"
13
15
  }
14
16
  }
@@ -4,8 +4,10 @@ args = [".code-workspace/extensions/zhuiyi-jira-mcp/0.1.0/dist/index.js"]
4
4
 
5
5
  [mcp_servers.zhuiyi-jira.env]
6
6
  JIRA_AUTH_TYPE = "cookie"
7
+ JIRA_COOKIE = ""
7
8
  JIRA_API_VERSION = "latest"
8
9
  JIRA_ALLOWED_HOSTS = "jira.in.wezhuiyi.com"
9
10
  JIRA_REQUIREMENT_FIELDS = '{"acceptanceCriteria":"customfield_10042","storyPoints":"customfield_10016"}'
10
11
  JIRA_ATTACHMENT_DIR = ".jira-attachments"
11
12
  JIRA_ATTACHMENT_MAX_SIZE = "20MB"
13
+ JIRA_ATTACHMENT_ALLOWED_TYPES = "pdf,png,jpg,jpeg,gif,webp,txt,md,csv,json,xml,doc,docx,xls,xlsx,ppt,pptx,html"
@@ -0,0 +1,2 @@
1
+ # Zhuiyi Jira MCP attachments
2
+ /.jira-attachments/
@@ -30,6 +30,9 @@ async function main() {
30
30
  await prepareRelease(release, runtime);
31
31
  outputs.push({ id: "runtime", source: "runtime" });
32
32
 
33
+ copyOutput(outputRoot, "artifacts/gitignore", "gitignore");
34
+ outputs.push({ id: "gitignore", source: "gitignore" });
35
+
33
36
  if (context.tools.includes("codex")) {
34
37
  copyOutput(outputRoot, "artifacts/codex/config.toml", "codex-config.toml");
35
38
  outputs.push({ id: "codex-config", source: "codex-config.toml" });
@@ -6,7 +6,7 @@
6
6
  "name": "Zhuiyi Jira MCP",
7
7
  "version": "0.1.0",
8
8
  "entry": "init.js",
9
- "entrySha256": "af7f4a71835402235b3d763418ee1b4135da0125a85aff1153bfaa0f6c83a022",
9
+ "entrySha256": "53a814ffcbc5669a024f921c5c30e74385d334b749913b0212bdcc2e48a2e0bd",
10
10
  "timeoutMs": 120000,
11
11
  "capabilities": {
12
12
  "networkHosts": ["gitee.com", "raw.giteeusercontent.com"]
@@ -18,6 +18,13 @@
18
18
  "ownership": "exclusive",
19
19
  "target": ".code-workspace/extensions/zhuiyi-jira-mcp/0.1.0"
20
20
  },
21
+ {
22
+ "id": "gitignore",
23
+ "kind": "text-block",
24
+ "ownership": "shared",
25
+ "target": ".gitignore",
26
+ "format": "text"
27
+ },
21
28
  {
22
29
  "id": "codex-config",
23
30
  "kind": "text-block",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "code-workspace-zhuiyi",
3
- "version": "0.1.0-beta.2",
3
+ "version": "0.1.0-beta.4",
4
4
  "description": "Local multi-project registry and safety layer for AI coding workspaces",
5
5
  "author": "icebearx-ai",
6
6
  "license": "MIT",
@@ -22,6 +22,7 @@
22
22
  "src/cli",
23
23
  "src/index.js",
24
24
  "src/core",
25
+ "src/hooks",
25
26
  "src/i18n",
26
27
  "src/init",
27
28
  "src/monitor",
@@ -4,7 +4,7 @@
4
4
  "title": "Code Workspace Extension Spec v1 manifest schema v3",
5
5
  "type": "object",
6
6
  "additionalProperties": false,
7
- "required": ["schemaVersion", "extensionSpecVersion", "experimental", "id", "name", "version", "entry", "entrySha256", "timeoutMs", "outputs"],
7
+ "required": ["schemaVersion", "extensionSpecVersion", "experimental", "id", "name", "version", "entry", "entrySha256", "timeoutMs"],
8
8
  "properties": {
9
9
  "schemaVersion": { "const": 3 },
10
10
  "extensionSpecVersion": { "const": 1 },
@@ -69,8 +69,33 @@
69
69
  }
70
70
  ]
71
71
  }
72
+ },
73
+ "hooks": {
74
+ "type": "array",
75
+ "items": {
76
+ "type": "object",
77
+ "additionalProperties": false,
78
+ "required": ["id", "event", "command"],
79
+ "properties": {
80
+ "id": { "$ref": "#/$defs/id" },
81
+ "event": { "enum": ["task.started", "task.activity", "write.before", "write.after", "task.turn-ended", "task.ended", "task.subagent-started", "task.subagent-ended", "session.start", "session.activity", "session.end", "turn.end", "subagent.start", "subagent.end", "pre-write", "post-write"] },
82
+ "command": { "type": "string", "minLength": 1, "maxLength": 4096, "pattern": "^[^\\r\\n]+$" },
83
+ "tools": {
84
+ "type": "array",
85
+ "minItems": 1,
86
+ "uniqueItems": true,
87
+ "items": { "enum": ["claude", "codex"] }
88
+ },
89
+ "matcher": { "type": "string", "minLength": 1, "maxLength": 1024, "pattern": "^[^\\r\\n]+$" },
90
+ "timeoutMs": { "type": "integer", "minimum": 1, "maximum": 300000 }
91
+ }
92
+ }
72
93
  }
73
94
  },
95
+ "anyOf": [
96
+ { "required": ["outputs"], "properties": { "outputs": { "minItems": 1 } } },
97
+ { "required": ["hooks"], "properties": { "hooks": { "minItems": 1 } } }
98
+ ],
74
99
  "$defs": {
75
100
  "id": { "type": "string", "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$" },
76
101
  "sha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
@@ -134,6 +134,42 @@ Spec v1 supports four output kinds:
134
134
 
135
135
  Public output kinds MUST NOT encode private business concepts such as Jira, MCP, npm, archive formats, or individual Agent products.
136
136
 
137
+ ### 7.1 Abstract Hook declarations
138
+
139
+ An extension MAY declare pluggable Workspace Hooks. Hooks are not extension output files and
140
+ MUST NOT declare Provider-native names such as `PreToolUse` or `SessionStart`. The optional
141
+ manifest `hooks` array contains entries with at least `id`, `event`, and `command`:
142
+
143
+ ```json
144
+ {
145
+ "hooks": [
146
+ {
147
+ "id": "audit-task",
148
+ "event": "task.activity",
149
+ "command": "code-workspace-plugin-audit",
150
+ "tools": ["codex", "claude"],
151
+ "matcher": "*",
152
+ "timeoutMs": 2
153
+ }
154
+ ]
155
+ }
156
+ ```
157
+
158
+ Supported abstract events are `task.started`, `task.activity`, `write.before`, `write.after`,
159
+ `task.turn-ended`, `task.ended`, `task.subagent-started`, and `task.subagent-ended`.
160
+ The aliases `session.start`, `session.activity`, `session.end`, `turn.end`, `subagent.start`,
161
+ `subagent.end`, `pre-write`, and `post-write` are accepted and normalized to those events.
162
+ When `tools` is omitted, the declaration applies to every tool supported by the Host.
163
+ `command` is a trusted extension Hook entry point. The Host validates the declaration, renders
164
+ it through a Provider adaptor, and governs its lifecycle; it does not interpret arbitrary native
165
+ configuration fragments.
166
+
167
+ Codex and Claude adaptors map one abstract event to their native events and compose only the
168
+ extension-owned entries. Install, upgrade, and uninstall use installed Workspace state;
169
+ uninstall does not execute extension code and preserves user and other-extension Hooks. If an
170
+ installed contribution is missing, duplicated, or modified, the Host MUST fail closed and roll
171
+ back the transaction.
172
+
137
173
  ## 8. Staging Verification
138
174
 
139
175
  An extension MUST generate candidate content only inside the staging directory supplied by the Host. The Host MUST:
@@ -133,6 +133,40 @@ Spec v1 支持四种输出:
133
133
 
134
134
  公共输出不得包含 Jira、MCP、npm、归档或特定 Agent 产品的业务类型。
135
135
 
136
+ ### 7.1 抽象 Hook 声明
137
+
138
+ 扩展可以声明可插拔的 Workspace Hook。Hook 不是扩展输出文件,也不得直接声明
139
+ `PreToolUse`、`SessionStart` 等 Provider 原生名称。manifest 的 `hooks` 是一个可选数组,
140
+ 每项至少包含 `id`、`event` 和 `command`:
141
+
142
+ ```json
143
+ {
144
+ "hooks": [
145
+ {
146
+ "id": "audit-task",
147
+ "event": "task.activity",
148
+ "command": "code-workspace-plugin-audit",
149
+ "tools": ["codex", "claude"],
150
+ "matcher": "*",
151
+ "timeoutMs": 2
152
+ }
153
+ ]
154
+ }
155
+ ```
156
+
157
+ 支持的抽象事件为 `task.started`、`task.activity`、`write.before`、`write.after`、
158
+ `task.turn-ended`、`task.ended`、`task.subagent-started` 和 `task.subagent-ended`。
159
+ `session.start`、`session.activity`、`session.end`、`turn.end`、`subagent.start`、
160
+ `subagent.end`、`pre-write` 和 `post-write` 作为兼容别名会被规范化为上述事件。
161
+ `tools` 缺省时表示适用于 Host 支持的全部工具。`command` 是可信扩展提供的 Hook
162
+ 执行入口;Host 只负责声明校验、适配器渲染和生命周期治理,不把它解释为任意原生
163
+ 配置片段。
164
+
165
+ Codex 与 Claude 的适配器会把一个抽象事件映射到各自的原生事件,并只合成扩展拥有的
166
+ 局部 entry。安装、升级和卸载均依据 Workspace 中的 installed 状态完成;卸载不执行
167
+ 扩展代码,并保留用户及其他扩展的 Hook。扩展 Hook 被手动删除、重复或修改时,Host
168
+ 必须 fail closed 并回滚本次事务。
169
+
136
170
  ## 8. Staging 验证
137
171
 
138
172
  扩展只能在 Host 提供的 staging 目录生成候选内容。Host 必须:
@@ -32,6 +32,7 @@ function formatInstallPlan(plans) {
32
32
  ` ${plan.id}@${plan.version} [Extension Spec ${plan.extensionSpecVersion}] (manifest ${plan.manifestSha256})`,
33
33
  ...(plan.capabilities.networkHosts || []).map((host) => ` NETWORK https://${host}`),
34
34
  ...plan.artifacts.map((artifact) => ` WRITE ${artifact.target} (${artifact.kind})`),
35
+ ...(plan.hooks || []).map((hook) => ` HOOK ${hook.id} (${hook.event}${hook.tools?.length ? ` · ${hook.tools.join(",")}` : ""}) -> ${hook.command}`),
35
36
  ]),
36
37
  ].join("\n");
37
38
  }
@@ -69,6 +70,7 @@ function installResultEntry(entry) {
69
70
  extensionSpecVersion: entry.extensionSpecVersion,
70
71
  ...(entry.reason ? { reason: entry.reason } : {}),
71
72
  ...(entry.artifacts ? { artifacts: entry.artifacts } : {}),
73
+ ...(entry.hooks ? { hooks: entry.hooks } : {}),
72
74
  ...(entry.code ? { code: entry.code } : {}),
73
75
  ...(entry.message ? { message: entry.message } : {}),
74
76
  ...(entry.statePersisted !== undefined ? { statePersisted: entry.statePersisted } : {}),
@@ -95,7 +97,7 @@ async function executeExtensionInstall(invocation) {
95
97
  let requested = invocation.args.length > 0 ? normalizeExtensionNames(invocation.args) : null;
96
98
  if (requested === null && !interactive) {
97
99
  throw new WorkspaceError("EXTENSION_SELECTION_REQUIRED", "Extension installation requires one or more extension names outside interactive mode.", {
98
- remediation: "Pass one or more names, for example: code-w extension install openspec-workspace --yes",
100
+ remediation: "Pass one or more extension names, for example: code-w extension install <extension-name> --yes",
99
101
  });
100
102
  }
101
103
 
@@ -120,6 +120,7 @@ async function executeInitUnlocked(invocation, root) {
120
120
  workspaceUuid: plan?.workspace.uuid,
121
121
  monitor: plan?.monitor.enable ?? (options.monitor === true ? true : options["no-monitor"] === true ? false : undefined),
122
122
  monitorUrl: plan?.monitor.url || options["monitor-url"],
123
+ coordination: options.coordination === true,
123
124
  language: plan?.language || options.language,
124
125
  interactive: false,
125
126
  initPlan: plan,
@@ -172,6 +173,7 @@ async function executeInitUnlocked(invocation, root) {
172
173
  monitor: result.workspaceConfig.monitor,
173
174
  language: result.language,
174
175
  tools: toolSelection,
176
+ coordination: options.coordination === true,
175
177
  migration: migrationData(result.migration),
176
178
  permissions: result.permissions,
177
179
  verification: result.verification,