code-workspace-zhuiyi 0.1.0-beta.1

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 (98) hide show
  1. package/.env.example +3 -0
  2. package/LICENSE +21 -0
  3. package/README.md +168 -0
  4. package/README.zh-CN.md +168 -0
  5. package/artifacts/manifest.json +183 -0
  6. package/artifacts/templates/USER_GUIDE.template.md +1 -0
  7. package/artifacts/templates/agents/WORKSPACE_GUARD.md.template +73 -0
  8. package/artifacts/templates/agents/skills/code-workspace-resolve-branch/SKILL.md +88 -0
  9. package/artifacts/templates/agents/skills/code-workspace-resolve-branch/evals/evals.json +45 -0
  10. package/artifacts/templates/claude/commands/code-workspace/add-projects.md +23 -0
  11. package/artifacts/templates/codex/hooks.json +86 -0
  12. package/artifacts/templates/codex/skills/code-workspace-add-projects/SKILL.md +28 -0
  13. package/artifacts/templates/user-guide/en-US.md +97 -0
  14. package/artifacts/templates/user-guide/zh-CN.md +97 -0
  15. package/assets/i18n-icon.svg +1 -0
  16. package/assets/logo-vector.svg +30 -0
  17. package/assets/request_tip.mp3 +0 -0
  18. package/assets/session_finish.mp3 +0 -0
  19. package/bin/code-workspace.js +11 -0
  20. package/docs/extension-architecture.zh-CN.md +429 -0
  21. package/docs/extensions.md +64 -0
  22. package/docs/extensions.zh-CN.md +64 -0
  23. package/extensions/openspec-workspace/1.0.0/artifacts/claude/SKILL.md +16 -0
  24. package/extensions/openspec-workspace/1.0.0/artifacts/codex/SKILL.md +16 -0
  25. package/extensions/openspec-workspace/1.0.0/init.js +54 -0
  26. package/extensions/openspec-workspace/1.0.0/manifest.json +27 -0
  27. package/extensions/zhuiyi-jira-mcp/0.1.0/artifacts/claude/server.json +14 -0
  28. package/extensions/zhuiyi-jira-mcp/0.1.0/artifacts/codex/config.toml +11 -0
  29. package/extensions/zhuiyi-jira-mcp/0.1.0/init.js +53 -0
  30. package/extensions/zhuiyi-jira-mcp/0.1.0/lib/archive.js +196 -0
  31. package/extensions/zhuiyi-jira-mcp/0.1.0/manifest.json +38 -0
  32. package/extensions/zhuiyi-jira-mcp/0.1.0/release.json +15 -0
  33. package/package.json +58 -0
  34. package/schemas/extension-init-context-v1.json +39 -0
  35. package/schemas/extension-init-result-v1.json +42 -0
  36. package/schemas/extension-manifest-v1.json +55 -0
  37. package/schemas/extension-manifest-v2.json +84 -0
  38. package/schemas/extension-manifest-v3.json +84 -0
  39. package/spec/extension/v1/specification.en-US.md +171 -0
  40. package/spec/extension/v1/specification.zh-CN.md +170 -0
  41. package/src/cli/commands/completion.js +203 -0
  42. package/src/cli/commands/extension.js +193 -0
  43. package/src/cli/commands/help.js +36 -0
  44. package/src/cli/commands/init.js +200 -0
  45. package/src/cli/commands/monitor.js +62 -0
  46. package/src/cli/commands/permissions.js +33 -0
  47. package/src/cli/commands/project-branch-update.js +107 -0
  48. package/src/cli/commands/project-branch.js +433 -0
  49. package/src/cli/commands/project.js +259 -0
  50. package/src/cli/commands/update.js +146 -0
  51. package/src/cli/commands/workspace.js +24 -0
  52. package/src/cli/confirmation.js +22 -0
  53. package/src/cli/parser.js +108 -0
  54. package/src/cli/registry.js +108 -0
  55. package/src/cli/renderer.js +20 -0
  56. package/src/cli/result.js +118 -0
  57. package/src/cli.js +76 -0
  58. package/src/core/assets.js +83 -0
  59. package/src/core/config.js +378 -0
  60. package/src/core/diagnostics.js +20 -0
  61. package/src/core/directory-digest.js +34 -0
  62. package/src/core/doctor.js +115 -0
  63. package/src/core/errors.js +10 -0
  64. package/src/core/extension-artifacts-legacy.js +180 -0
  65. package/src/core/extension-artifacts.js +310 -0
  66. package/src/core/extensions.js +1216 -0
  67. package/src/core/fs.js +32 -0
  68. package/src/core/init-lock-holder.js +30 -0
  69. package/src/core/init-lock.js +159 -0
  70. package/src/core/init.js +160 -0
  71. package/src/core/initializer.js +233 -0
  72. package/src/core/language.js +102 -0
  73. package/src/core/managed-files.js +334 -0
  74. package/src/core/migration.js +68 -0
  75. package/src/core/permissions/claude.js +92 -0
  76. package/src/core/permissions/codex.js +126 -0
  77. package/src/core/permissions/common.js +44 -0
  78. package/src/core/permissions/index.js +163 -0
  79. package/src/core/project-branch-update.js +424 -0
  80. package/src/core/project-configuration.js +55 -0
  81. package/src/core/project.js +674 -0
  82. package/src/core/tools.js +34 -0
  83. package/src/core/transaction.js +132 -0
  84. package/src/core/validation.js +186 -0
  85. package/src/i18n/index.js +11 -0
  86. package/src/i18n/interpolate.js +7 -0
  87. package/src/i18n/locales/en-US.js +10 -0
  88. package/src/i18n/locales/zh-CN.js +11 -0
  89. package/src/i18n/registry.js +42 -0
  90. package/src/index.js +25 -0
  91. package/src/init/plan.js +12 -0
  92. package/src/init/ui.js +61 -0
  93. package/src/init/wizard.js +97 -0
  94. package/src/monitor/i18n/index.js +33 -0
  95. package/src/monitor/i18n/locales/en-US.js +85 -0
  96. package/src/monitor/i18n/locales/zh-CN.js +79 -0
  97. package/src/monitor/index.js +344 -0
  98. package/src/monitor/page.js +118 -0
package/.env.example ADDED
@@ -0,0 +1,3 @@
1
+ # Code Workspace init operation lock
2
+ CODE_WORKSPACE_INIT_LOCK_UPDATE_MS=5000
3
+ CODE_WORKSPACE_INIT_LOCK_STALE_MS=30000
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 icebearx-ai
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,168 @@
1
+ # Code Workspace
2
+
3
+ Code Workspace is a local multi-project registry and safety layer for Claude Code and Codex. It manages workspace identity, project locations and branches, agent instructions, writable-root permissions, validation, and optional monitoring.
4
+
5
+ ## Requirements
6
+
7
+ - Node.js 20.19.0 or newer
8
+ - Git repositories for projects you register
9
+
10
+ ## Install
11
+
12
+ ```bash
13
+ npm install -g @icebearx-ai/code-workspace
14
+ ```
15
+
16
+ The package provides `code-workspace` and the shorter alias `code-w`.
17
+
18
+ ## Initialize
19
+
20
+ Interactive initialization:
21
+
22
+ ```bash
23
+ code-workspace init .
24
+ ```
25
+
26
+ Non-interactive initialization:
27
+
28
+ ```bash
29
+ code-workspace init . \
30
+ --tools claude,codex \
31
+ --extensions none \
32
+ --language en-US \
33
+ --yes
34
+ ```
35
+
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
+
38
+ Initialization writes only Workspace-owned state and integrations:
39
+
40
+ - `.code-workspace/config.yaml` and `.code-workspace/state.json`
41
+ - `USER_GUIDE.md`
42
+ - `CLAUDE.md` and/or `AGENTS.md`
43
+ - Workspace-specific commands and skills whose names start with `code-workspace-` or use the `/code-workspace` namespace
44
+ - `.codex/hooks.json` when monitoring is enabled
45
+
46
+ It does not create `openspec/`, install native `/opsx` commands, or install native `openspec-*` skills.
47
+
48
+ ### Experimental built-in extensions
49
+
50
+ `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
+ ```bash
53
+ code-w init . --extensions openspec-workspace --yes
54
+ code-w init . --extensions none --yes
55
+ code-w extension install
56
+ code-w extension install openspec-workspace --yes
57
+ code-w extension uninstall openspec-workspace --yes
58
+ ```
59
+
60
+ 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
+ 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
+
64
+ `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
+ 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
+
68
+ 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
+ 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
+
72
+ 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
+
74
+ ## Register projects
75
+
76
+ Inspecting a repository is read-only:
77
+
78
+ ```bash
79
+ code-workspace project inspect /absolute/path/to/project --json
80
+ ```
81
+
82
+ Claude Code users can invoke:
83
+
84
+ ```text
85
+ /code-workspace:add-projects /absolute/path/to/project-a /absolute/path/to/project-b
86
+ ```
87
+
88
+ Codex users can invoke `$code-workspace-add-projects` with the same explicit paths. For low-level automation, prepare a complete project record and run:
89
+
90
+ ```bash
91
+ code-workspace project add --projects-file projects.json --yes --json
92
+ ```
93
+
94
+ 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
+
96
+ ## Daily commands
97
+
98
+ ```bash
99
+ code-workspace project list --json
100
+ code-workspace project show payments --json
101
+ code-workspace project verify payments --json
102
+ code-workspace project branch inspect payments --json
103
+ code-workspace project branch verify payments --json
104
+ code-workspace project branch use-registered payments --yes --json
105
+ code-workspace project branch accept-actual payments --yes --json
106
+ code-workspace project branch update-latest payments --json
107
+ code-workspace permissions apply --yes --json
108
+ code-workspace doctor --json
109
+ ```
110
+
111
+ `project branch inspect` reports `registeredBranch`, `actualBranch`, whether they match, worktree cleanliness, local registered-branch availability, and remote-tracking candidates for only the named project. `project branch verify` is the narrower assertion used after reconciliation: it checks only whether the registered and actual branches match, without running overall project-health validation. A `PROJECT_BRANCH_MISMATCH` diagnostic uses `registeredBranch`, `actualBranch`, and `location`; consumers of older branch diagnostic/result fields must migrate to this canonical state contract.
112
+
113
+ The two reconciliation directions are deliberately separate:
114
+
115
+ - `project branch use-registered` switches the selected worktree to its registered branch. By default it requires confirmation, a clean worktree, and an existing local branch. `--allow-remote` permits creating a local tracking branch from one existing remote-tracking branch; `--remote <name>` explicitly authorizes fetching the registered branch from that remote before creating and switching the local tracking branch.
116
+ - `project branch accept-actual` updates only the selected registry record so its registered branch accepts the actual branch. Existing branch-adoption scripts should migrate to this command.
117
+
118
+ 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
+
120
+ Users may manually set the optional project policy in `.code-workspace/config.yaml`:
121
+
122
+ ```yaml
123
+ projects:
124
+ - name: payments
125
+ updateLatest: true
126
+ ```
127
+
128
+ AI/Agent must not directly edit this file. They may read the policy and invoke the registered CLI command; users remain responsible for manual configuration changes.
129
+
130
+ `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
+
132
+ ## Update and language
133
+
134
+ ```bash
135
+ code-workspace update --json
136
+ code-workspace update --language zh-CN --json
137
+ code-workspace language --json
138
+ ```
139
+
140
+ `update` refreshes only Workspace-owned managed assets and never changes Agent directory authorization. Unknown local edits stop the batch before writes; review them or pass `--force` explicitly.
141
+
142
+ ## Monitor
143
+
144
+ ```bash
145
+ code-workspace monitor --port 3211
146
+ ```
147
+
148
+ The monitor binds to loopback, combines events from multiple initialized workspaces, and keeps hook reporting failure-open. Review and trust project hooks in Codex before relying on reports.
149
+
150
+ ## Completion
151
+
152
+ ```bash
153
+ code-workspace completion --shell zsh
154
+ code-workspace completion --shell bash
155
+ ```
156
+
157
+ `completion` prints a script generated from the full command registry, including subcommands and command-specific options. It does not install the script or modify shell configuration. With `--json`, the script is returned in `data.script`.
158
+
159
+ ## Development
160
+
161
+ ```bash
162
+ npm install
163
+ npm test
164
+ npm run check
165
+ npm run pack:check
166
+ ```
167
+
168
+ The release manifest contains only Workspace-owned asset sources and managed files. Checksums make installation and update deterministic.
@@ -0,0 +1,168 @@
1
+ # Code Workspace
2
+
3
+ Code Workspace 是面向 Claude Code 与 Codex 的本地多项目注册表和安全边界层,负责工作区身份、项目路径与分支、Agent 指令、可写目录权限、校验以及可选监控。
4
+
5
+ ## 环境要求
6
+
7
+ - Node.js 20.19.0 或更高版本
8
+ - 待注册项目是 Git 仓库
9
+
10
+ ## 安装
11
+
12
+ ```bash
13
+ npm install -g @icebearx-ai/code-workspace
14
+ ```
15
+
16
+ 软件包提供 `code-workspace` 命令及短别名 `code-w`。
17
+
18
+ ## 初始化
19
+
20
+ 交互式初始化:
21
+
22
+ ```bash
23
+ code-workspace init .
24
+ ```
25
+
26
+ 非交互式初始化:
27
+
28
+ ```bash
29
+ code-workspace init . \
30
+ --tools claude,codex \
31
+ --extensions none \
32
+ --language zh-CN \
33
+ --yes
34
+ ```
35
+
36
+ 可用 `--tools claude`、`--tools codex` 或 `--tools none` 覆盖默认工具选择。选择 Codex 时默认启用监控;可传 `--no-monitor` 关闭。
37
+
38
+ 初始化只写入 Workspace 自有状态和集成:
39
+
40
+ - `.code-workspace/config.yaml` 与 `.code-workspace/state.json`
41
+ - `USER_GUIDE.md`
42
+ - `CLAUDE.md` 和/或 `AGENTS.md`
43
+ - 名称以 `code-workspace-` 开头或使用 `/code-workspace` 命名空间的 Workspace 专用命令与 Skill
44
+ - 启用监控时的 `.codex/hooks.json`
45
+
46
+ 它不会创建 `openspec/`,不会安装原生 `/opsx` 命令,也不会安装原生 `openspec-*` Skill。
47
+
48
+ ### 试验性内置扩展
49
+
50
+ `init` 可以从 npm 包内随附的版本化 `extensions/` 仓库安装集成。交互模式按扩展名多选;非交互模式传入逗号分隔的扩展名。独立安装命令接受一个或多个扩展名;不传名称时打开内置扩展多选,按 ESC 可无修改退出:
51
+
52
+ ```bash
53
+ code-w init . --extensions openspec-workspace --yes
54
+ code-w init . --extensions none --yes
55
+ code-w extension install
56
+ code-w extension install openspec-workspace --yes
57
+ code-w extension uninstall openspec-workspace --yes
58
+ ```
59
+
60
+ `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
+ 用户只选择扩展名,不能选择版本;`openspec-workspace@1.0.0` 会被明确拒绝。Code Workspace 在确认前,从 Host 明确支持的 Extension Spec 实现中解析最高扩展 SemVer。新 Workspace 非交互初始化时,未传 `--extensions` 就不安装扩展;已有 Workspace 重新初始化时,默认选择已安装扩展,并在存在更高受支持内置版本时升级。`none` 只跳过本次扩展初始化,不会卸载已有制品。
63
+
64
+ `extension install` 不会重新执行 Workspace 核心初始化。在 JSON、非 TTY 或 `--yes` 模式下,必须至少提供一个扩展名。多个名称按顺序安装,只确认一次且各自使用独立事务;任一扩展失败会使安装命令失败,但后续扩展仍会继续执行。
65
+
66
+ 内置 `openspec-workspace` 扩展会为选中的 Agent 工具安装命名空间为 `code-workspace-openspec-propose` 的 Skill;它不会创建 `openspec/` 目录,也不会安装 OpenSpec 原生命令。
67
+
68
+ 扩展入口在独立 Node 进程中运行,只向临时 staging 目录生成文件。Host 会在事务安装前拒绝未声明、缺失、符号链接、非文件、路径逃逸、目标冲突和 hash 不匹配的制品。Workspace 状态存放在 `.code-workspace/ext-manifest.json`。扩展失败以 warning 报告,不回滚已成功的核心初始化,也不阻止后续扩展;升级失败会恢复并保留旧的已安装版本。
69
+
70
+ 扩展可以独占完整文件,也可以贡献由 Host 管理的 Codex TOML 配置块和 Hook 片段。共享目标由 Code Workspace 合成和验证;扩展不会直接 patch 真实 Workspace。卸载只使用已安装状态,不执行扩展代码;扩展所有的文件或贡献存在未知修改时会拒绝覆盖或删除。
71
+
72
+ 这是故障隔离,不是恶意代码安全沙箱。试验版本只信任随 Code Workspace 发布的扩展代码;暂不支持网络源、外部扩展目录、扩展依赖、任意 patch、强制卸载、禁用命令,也不会通过 `code-w update` 自动更新扩展。开发契约见 `docs/extensions.zh-CN.md`。
73
+
74
+ ## 注册项目
75
+
76
+ 项目检查是只读操作:
77
+
78
+ ```bash
79
+ code-workspace project inspect /absolute/path/to/project --json
80
+ ```
81
+
82
+ Claude Code 用户可显式调用:
83
+
84
+ ```text
85
+ /code-workspace:add-projects /absolute/path/to/project-a /absolute/path/to/project-b
86
+ ```
87
+
88
+ Codex 用户可对相同的显式路径调用 `$code-workspace-add-projects`。底层自动化可准备完整项目记录,然后运行:
89
+
90
+ ```bash
91
+ code-workspace project add --projects-file projects.json --yes --json
92
+ ```
93
+
94
+ 注册表保存项目名称、真实路径、注册分支、类型和上下文。注册分支是 Code Workspace 的期望状态,实际分支是从选中 Git worktree 观测到的状态。Workspace 不会根据对话猜测路径,也不会自动判断哪一侧分支更权威。
95
+
96
+ ## 日常命令
97
+
98
+ ```bash
99
+ code-workspace project list --json
100
+ code-workspace project show payments --json
101
+ code-workspace project verify payments --json
102
+ code-workspace project branch inspect payments --json
103
+ code-workspace project branch verify payments --json
104
+ code-workspace project branch use-registered payments --yes --json
105
+ code-workspace project branch accept-actual payments --yes --json
106
+ code-workspace project branch update-latest payments --json
107
+ code-workspace permissions apply --yes --json
108
+ code-workspace doctor --json
109
+ ```
110
+
111
+ `project branch inspect` 只检查命名项目,返回 `registeredBranch`、`actualBranch`、是否一致、worktree 是否干净、注册分支是否在本地存在以及远程跟踪候选。`project branch verify` 是协调后的窄范围断言,只检查注册分支和实际分支是否一致,不执行项目整体健康校验。`PROJECT_BRANCH_MISMATCH` 诊断使用 `registeredBranch`、`actualBranch` 和 `location`;使用旧分支诊断或结果字段的调用方必须迁移到这套规范状态合同。
112
+
113
+ 两个协调方向通过独立命令表达:
114
+
115
+ - `project branch use-registered` 将选中 worktree 切换到注册分支,默认要求确认、干净 worktree 和已存在的本地注册分支。提供 `--allow-remote` 时,可以从唯一已有的远程跟踪分支创建本地 tracking 分支;提供 `--remote <name>` 时,可以在确认后仅 fetch 指定远程的注册分支,再创建本地 tracking 分支并切换。
116
+ - `project branch accept-actual` 只更新选中项目的注册记录,让注册分支接受实际分支;已有“接受实际分支”脚本应迁移到该命令。
117
+
118
+ 两条命令都会检查计划漂移并验证后置条件。`project branch update-latest` 是独立的显式配置路径:仅当项目 `updateLatest: true` 时,才对干净且分支一致的 worktree fetch upstream 并 fast-forward。Code Workspace 不会创建或下载分支,也不会执行 stash、reset、rebase、非 fast-forward merge、生产代码编辑或冲突处理。
119
+
120
+ 用户可以手动在 `.code-workspace/config.yaml` 中设置项目策略:
121
+
122
+ ```yaml
123
+ projects:
124
+ - name: payments
125
+ updateLatest: true
126
+ ```
127
+
128
+ AI/Agent 不得直接编辑该文件;可以读取策略并调用已注册的 CLI,手动配置结果由用户负责。
129
+
130
+ `permissions apply` 会展示选中 Agent 工具的完整授权计划,在需要修改时要求确认,实施并验证请求的授权,并按工具报告结果。Agent 目录访问仍属于用户授权。该命令只补齐已注册项目缺失的访问权限,不撤销额外目录;如需撤销,请使用 `project remove` 或显式编辑 Agent 设置。
131
+
132
+ ## 更新与语言
133
+
134
+ ```bash
135
+ code-workspace update --json
136
+ code-workspace update --language en-US --json
137
+ code-workspace language --json
138
+ ```
139
+
140
+ `update` 只刷新 Workspace 自有托管资产,绝不会修改 Agent 目录授权。遇到未知本地修改时,会在任何写入前终止批次;请先审查修改,或显式传入 `--force`。
141
+
142
+ ## 监控
143
+
144
+ ```bash
145
+ code-workspace monitor --port 3211
146
+ ```
147
+
148
+ 监控服务仅绑定 loopback,可汇总多个已初始化工作区的事件;hook 上报失败不会阻断 Agent。依赖监控前,请在 Codex 中检查并信任项目 hook。
149
+
150
+ ## 命令补全
151
+
152
+ ```bash
153
+ code-workspace completion --shell zsh
154
+ code-workspace completion --shell bash
155
+ ```
156
+
157
+ `completion` 会根据完整命令注册表输出脚本,包括子命令和各命令专属选项;它不会安装脚本或修改 Shell 配置。使用 `--json` 时,脚本位于 `data.script`。
158
+
159
+ ## 开发
160
+
161
+ ```bash
162
+ npm install
163
+ npm test
164
+ npm run check
165
+ npm run pack:check
166
+ ```
167
+
168
+ 发布清单只包含 Workspace 自有资产源和托管文件,并通过校验和保证安装与更新的确定性。
@@ -0,0 +1,183 @@
1
+ {
2
+ "schemaVersion": 2,
3
+ "releaseVersion": "0.1.0-beta.1",
4
+ "requirements": {
5
+ "node": ">=20.19.0"
6
+ },
7
+ "tools": [
8
+ "claude",
9
+ "codex"
10
+ ],
11
+ "sources": [
12
+ {
13
+ "id": "workspace-user-guide-en-US",
14
+ "kind": "asset",
15
+ "path": "templates/user-guide/en-US.md",
16
+ "sha256": "d6e3f59fc86262c4e71d2320fb2fba21394d7b4f099ef465fdec765d0b6c7754"
17
+ },
18
+ {
19
+ "id": "workspace-user-guide-zh-CN",
20
+ "kind": "asset",
21
+ "path": "templates/user-guide/zh-CN.md",
22
+ "sha256": "4dc207305a3975ab7272addedf3bc2930054e860c2b0b2b6e0e102f4457f5cc0"
23
+ }
24
+ ],
25
+ "managedFiles": [
26
+ {
27
+ "id": "workspace-user-guide",
28
+ "target": "USER_GUIDE.md",
29
+ "allowMissing": true,
30
+ "desired": {
31
+ "source": "templates/USER_GUIDE.template.md",
32
+ "sha256": "79d635871bd3917ba2a99ad7aa6d68794a4f1c4b2b6da482f227b1437bd7114c"
33
+ },
34
+ "render": {
35
+ "variables": [
36
+ "WORKSPACE_USER_GUIDE"
37
+ ]
38
+ },
39
+ "provenance": {
40
+ "kind": "template"
41
+ }
42
+ },
43
+ {
44
+ "id": "workspace-claude-instructions",
45
+ "target": "CLAUDE.md",
46
+ "tools": [
47
+ "claude"
48
+ ],
49
+ "allowMissing": true,
50
+ "desired": {
51
+ "source": "templates/agents/WORKSPACE_GUARD.md.template",
52
+ "sha256": "6510cce83138fad46330d2c175506e56e9c98d5086195a699eafc7cc74163bf3"
53
+ },
54
+ "render": {
55
+ "variables": [
56
+ "ADD_PROJECTS_INVOCATION"
57
+ ],
58
+ "values": {
59
+ "ADD_PROJECTS_INVOCATION": "/code-workspace:add-projects /absolute/path/to/project"
60
+ }
61
+ },
62
+ "provenance": {
63
+ "kind": "template"
64
+ }
65
+ },
66
+ {
67
+ "id": "workspace-codex-instructions",
68
+ "target": "AGENTS.md",
69
+ "tools": [
70
+ "codex"
71
+ ],
72
+ "allowMissing": true,
73
+ "desired": {
74
+ "source": "templates/agents/WORKSPACE_GUARD.md.template",
75
+ "sha256": "6510cce83138fad46330d2c175506e56e9c98d5086195a699eafc7cc74163bf3"
76
+ },
77
+ "render": {
78
+ "variables": [
79
+ "ADD_PROJECTS_INVOCATION"
80
+ ],
81
+ "values": {
82
+ "ADD_PROJECTS_INVOCATION": "$code-workspace-add-projects /absolute/path/to/project"
83
+ }
84
+ },
85
+ "provenance": {
86
+ "kind": "template"
87
+ }
88
+ },
89
+ {
90
+ "id": "workspace-codex-monitor-hooks",
91
+ "target": ".codex/hooks.json",
92
+ "tools": [
93
+ "codex"
94
+ ],
95
+ "capabilities": [
96
+ "monitor"
97
+ ],
98
+ "allowMissing": true,
99
+ "desired": {
100
+ "source": "templates/codex/hooks.json",
101
+ "sha256": "64d68809a2681b11d4b50bee3ca711fa8f5ea0a297c2281e5c7f8937e968e22e"
102
+ },
103
+ "provenance": {
104
+ "kind": "template"
105
+ }
106
+ },
107
+ {
108
+ "id": "workspace-claude-add-projects-command",
109
+ "target": ".claude/commands/code-workspace/add-projects.md",
110
+ "tools": [
111
+ "claude"
112
+ ],
113
+ "allowMissing": true,
114
+ "desired": {
115
+ "source": "templates/claude/commands/code-workspace/add-projects.md",
116
+ "sha256": "7cd5a47c88185d276c0c4c38e18577e009e5e6d4ed99062554ff116b7e8d1812"
117
+ },
118
+ "provenance": {
119
+ "kind": "template"
120
+ }
121
+ },
122
+ {
123
+ "id": "workspace-claude-add-projects-skill",
124
+ "target": ".claude/skills/code-workspace-add-projects/SKILL.md",
125
+ "tools": [
126
+ "claude"
127
+ ],
128
+ "allowMissing": true,
129
+ "desired": {
130
+ "source": "templates/codex/skills/code-workspace-add-projects/SKILL.md",
131
+ "sha256": "f95847b00c93c2dd287247e226fecd6953286064dfde99b8ede830d181ef276f"
132
+ },
133
+ "provenance": {
134
+ "kind": "template"
135
+ }
136
+ },
137
+ {
138
+ "id": "workspace-codex-add-projects-skill",
139
+ "target": ".codex/skills/code-workspace-add-projects/SKILL.md",
140
+ "tools": [
141
+ "codex"
142
+ ],
143
+ "allowMissing": true,
144
+ "desired": {
145
+ "source": "templates/codex/skills/code-workspace-add-projects/SKILL.md",
146
+ "sha256": "f95847b00c93c2dd287247e226fecd6953286064dfde99b8ede830d181ef276f"
147
+ },
148
+ "provenance": {
149
+ "kind": "template"
150
+ }
151
+ },
152
+ {
153
+ "id": "workspace-claude-resolve-branch-skill",
154
+ "target": ".claude/skills/code-workspace-resolve-branch/SKILL.md",
155
+ "tools": [
156
+ "claude"
157
+ ],
158
+ "allowMissing": true,
159
+ "desired": {
160
+ "source": "templates/agents/skills/code-workspace-resolve-branch/SKILL.md",
161
+ "sha256": "d09b0e1847f5b39e6409ba3ac43f26fa5829a15690a3e216576e51535fb6b161"
162
+ },
163
+ "provenance": {
164
+ "kind": "template"
165
+ }
166
+ },
167
+ {
168
+ "id": "workspace-codex-resolve-branch-skill",
169
+ "target": ".codex/skills/code-workspace-resolve-branch/SKILL.md",
170
+ "tools": [
171
+ "codex"
172
+ ],
173
+ "allowMissing": true,
174
+ "desired": {
175
+ "source": "templates/agents/skills/code-workspace-resolve-branch/SKILL.md",
176
+ "sha256": "d09b0e1847f5b39e6409ba3ac43f26fa5829a15690a3e216576e51535fb6b161"
177
+ },
178
+ "provenance": {
179
+ "kind": "template"
180
+ }
181
+ }
182
+ ]
183
+ }
@@ -0,0 +1 @@
1
+ {{WORKSPACE_USER_GUIDE}}
@@ -0,0 +1,73 @@
1
+ # Workspace Context
2
+
3
+ This directory is the Code Workspace control plane for multiple independent software projects. The workspace is not a project and is not the default location for production code.
4
+
5
+ The registry is authoritative for project identity, ownership, location, and the registered branch. A project's `registeredBranch` is the Code Workspace expected state; its `actualBranch` is the selected Git worktree's observed state. A mismatch does not make either side automatically authoritative—the user chooses the reconciliation direction, and the CLI enforces it safely.
6
+
7
+ ## Select One Project Scope
8
+
9
+ If the user explicitly names a registered project, resolve it directly:
10
+
11
+ ```bash
12
+ code-w project show "<project.name>" --json
13
+ ```
14
+
15
+ Only when project ownership cannot be determined, list registry metadata:
16
+
17
+ ```bash
18
+ code-w project list --json
19
+ ```
20
+
21
+ Use `name`, `type`, and `context` only to identify relevant candidates and ask the user to choose. Do not inspect candidate repositories while selecting.
22
+
23
+ - You MUST NOT guess a project path or scan parent/sibling directories for projects.
24
+ - If the registry is empty, ask which projects to manage and tell the user to run `{{ADD_PROJECTS_INVOCATION}}`.
25
+ - If the user names an unregistered project, require registration before using its path.
26
+ - Once selected, freeze the scope to that project. Do not read, verify, modify, repair, or comment on another registered project unless the user explicitly expands the request.
27
+ - If multiple projects are explicitly included, pass their names as separate arguments to one targeted `project verify` invocation. When two or more results report `PROJECT_BRANCH_MISMATCH`, the branch Skill may present them in one combined choice. Batch CLI invocations are allowed, but their effects, diagnostics, transactions, and verification results remain project-isolated.
28
+
29
+ Meta, help, or workspace-tool maintenance tasks that do not depend on registered project ownership do not require project selection.
30
+
31
+ ## Verify the Selected Project
32
+
33
+ Before reading or modifying selected project code, run:
34
+
35
+ ```bash
36
+ code-w project verify "<project.name>" --json
37
+ ```
38
+
39
+ For several explicitly selected projects, use:
40
+
41
+ ```bash
42
+ code-w project verify "<project-a>" "<project-b>" --json
43
+ ```
44
+
45
+ - For one project, continue only when the targeted result has `ok: true`. For a multi-project result, evaluate every ordered project result independently: continue passed projects and keep failed projects paused even when the top-level `ok` is false.
46
+ - On `PROJECT_BRANCH_MISMATCH`, pause affected project work and invoke the installed `code-workspace-resolve-branch` Skill. The Skill may combine mismatches from the explicitly selected scope into one concise question; do not choose a branch direction yourself.
47
+ - For any other failure, report the targeted diagnostics and wait for user direction for the affected project; a failure in one batch result does not block unrelated successful selected projects. Do not escalate to full-workspace validation.
48
+ - The branch Skill completes after `project branch verify` confirms alignment; it does not own overall project readiness. After its handoff, discard branch-dependent context and rerun targeted `project verify` for the successfully reconciled projects before resuming work.
49
+ - If that overall verification fails for a non-branch reason, keep the affected project paused and handle the project-level diagnostic here without treating the branch Skill as failed. If a new `PROJECT_BRANCH_MISMATCH` appears because the branch drifted again, re-enter the Skill. Do not list or verify unrelated projects.
50
+ - After branch verification succeeds—including projects whose branches were already aligned—run `project branch update-latest` for the selected projects:
51
+
52
+ ```bash
53
+ code-w project branch update-latest "<project-a>" "<project-b>" --json
54
+ ```
55
+
56
+ Pass each selected project name as a separate argument; for a single project, pass only that project name. Evaluate each project result independently, including when the batch-level `ok` is `false`: continue only for projects whose individual result has `ok: true`, and treat `disabled` and `already-latest` as successful skips. If an update fails, keep that project paused and do not run ad-hoc `fetch`, `pull`, `reset`, `stash`, or `rebase` commands. For each successful or skipped project, discard pre-update context and rerun targeted `project verify` before starting project work.
57
+
58
+ ## Workspace Write Boundary
59
+
60
+ The AI/Agent MUST NOT directly create, edit, move, or delete Workspace-owned files under the workspace root, including:
61
+
62
+ - `.code-workspace/config.yaml` or `.code-workspace/state.json`
63
+ - `.codex/config.toml`
64
+ - `CLAUDE.md`, `AGENTS.md`, or other managed workspace files
65
+
66
+ AI/Agent registry changes must use an approved `code-w` command. Users may manually edit `.code-workspace/config.yaml` and are responsible for the resulting configuration; AI/Agent must not imitate that edit with a script or direct file write. The CLI owns confirmation, concurrency checks, persistence or safe external effects, postconditions, rollback/compensation, and structured output. This boundary does not prevent user-requested production-code changes inside the selected external `project.location`.
67
+
68
+ ## Responsibilities
69
+
70
+ - The CLI collects and verifies branch facts, performs safe reconciliation, and executes the explicitly configured latest-branch fast-forward.
71
+ - The Agent explains facts, invokes the branch Skill, follows the user's selected direction, and invokes `project branch update-latest` after branch alignment.
72
+ - The user decides whether to use the registered branch, accept the actual branch, or resolve manually.
73
+ - Code Workspace does not edit production code, create branches, or resolve conflicts. Only `project branch update-latest` may fetch and fast-forward an explicitly enabled project; it never runs reset, stash, rebase, or non-fast-forward merge.