@zhang6hk/dsh-codex 0.0.0-stage → 0.1.0
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.
- package/LICENSE +201 -0
- package/NOTICE +18 -0
- package/README.md +75 -2
- package/README.zh.md +78 -0
- package/cordis.patch.yml +7 -0
- package/lib/args.js +118 -0
- package/lib/codex-path.js +31 -0
- package/lib/commands.js +242 -0
- package/lib/companion.js +177 -0
- package/lib/index.js +105 -0
- package/lib/render.js +114 -0
- package/lib/tool.js +103 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +49 -4
- package/vendor/codex/.claude-plugin/plugin.json +8 -0
- package/vendor/codex/prompts/adversarial-review.md +84 -0
- package/vendor/codex/prompts/stop-review-gate.md +36 -0
- package/vendor/codex/schemas/review-output.schema.json +87 -0
- package/vendor/codex/scripts/app-server-broker.mjs +252 -0
- package/vendor/codex/scripts/codex-companion.mjs +1073 -0
- package/vendor/codex/scripts/lib/app-server-protocol.d.ts +75 -0
- package/vendor/codex/scripts/lib/app-server.mjs +354 -0
- package/vendor/codex/scripts/lib/args.mjs +128 -0
- package/vendor/codex/scripts/lib/broker-endpoint.mjs +41 -0
- package/vendor/codex/scripts/lib/broker-lifecycle.mjs +209 -0
- package/vendor/codex/scripts/lib/claude-session-transfer.mjs +44 -0
- package/vendor/codex/scripts/lib/codex.mjs +1219 -0
- package/vendor/codex/scripts/lib/fs.mjs +40 -0
- package/vendor/codex/scripts/lib/git.mjs +347 -0
- package/vendor/codex/scripts/lib/job-control.mjs +308 -0
- package/vendor/codex/scripts/lib/process.mjs +135 -0
- package/vendor/codex/scripts/lib/prompts.mjs +13 -0
- package/vendor/codex/scripts/lib/render.mjs +465 -0
- package/vendor/codex/scripts/lib/state.mjs +191 -0
- package/vendor/codex/scripts/lib/tracked-jobs.mjs +204 -0
- package/vendor/codex/scripts/lib/workspace.mjs +9 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Copyright 2026 OpenAI
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
|
14
|
+
|
|
15
|
+
This distribution (dsh-codex) vendors the unmodified contents of
|
|
16
|
+
https://github.com/openai/codex-plugin-cc (plugins/codex/) under vendor/codex/,
|
|
17
|
+
and adds a DeepSeek Harness adapter in lib/. Copyright 2026 OpenAI; the adapter
|
|
18
|
+
is Copyright 2026 zhang6hk and licensed under the same Apache License, Version 2.0.
|
package/README.md
CHANGED
|
@@ -1,3 +1,76 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-codex
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Bring [openai/codex-plugin-cc](https://github.com/openai/codex-plugin-cc) into [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness): let your local Codex CLI review your changes, or hand investigation and fix tasks to it.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# straight from GitHub
|
|
9
|
+
dsh plugin add github:zhang6hk/dsh-codex
|
|
10
|
+
|
|
11
|
+
# or from npm
|
|
12
|
+
dsh plugin add @zhang6hk/dsh-codex
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Desktop: Plugins → Add plugin, then paste either spec. Restart the session and run `/codex-setup` to confirm Codex is ready.
|
|
16
|
+
|
|
17
|
+
## Requirements
|
|
18
|
+
|
|
19
|
+
- [Codex CLI](https://github.com/openai/codex): `npm install -g @openai/codex`
|
|
20
|
+
- Logged in: `codex login` (ChatGPT account or API key)
|
|
21
|
+
- Node.js ≥ 22 (DSH's bundled runtime is enough)
|
|
22
|
+
|
|
23
|
+
## Commands
|
|
24
|
+
|
|
25
|
+
| Command | What it does |
|
|
26
|
+
|---|---|
|
|
27
|
+
| `/codex-review` | Review the current git diff (native review, never edits code) |
|
|
28
|
+
| `/codex-adversarial-review <focus>` | Adversarial review: challenge the approach, tradeoffs, assumptions |
|
|
29
|
+
| `/codex-rescue <task>` | Hand investigation or fixes to Codex, staying in one thread |
|
|
30
|
+
| `/codex-status [job-id]` | Check progress |
|
|
31
|
+
| `/codex-result <job-id>` | Read the full result |
|
|
32
|
+
| `/codex-cancel <job-id>` | Cancel a task |
|
|
33
|
+
| `/codex-setup` | Check CLI, login, and runtime |
|
|
34
|
+
|
|
35
|
+
Reviews run in the foreground and print Codex's report directly (the upstream engine has no review background mode). `/codex-rescue` runs in the background by default and returns a job id. Flags: `--base <ref>`, `--scope auto|working-tree|branch`, `--model`, `--effort`.
|
|
36
|
+
|
|
37
|
+
There is also a `codex_task` tool, so the model can delegate a task to Codex inside a conversation.
|
|
38
|
+
|
|
39
|
+
## Configuration
|
|
40
|
+
|
|
41
|
+
Edit `config` in `cordis.patch.yml`:
|
|
42
|
+
|
|
43
|
+
```yaml
|
|
44
|
+
- insert:
|
|
45
|
+
- id: dsh-codex
|
|
46
|
+
name: '@zhang6hk/dsh-codex'
|
|
47
|
+
config:
|
|
48
|
+
codexPath: codex # Codex binary; use an absolute path if it is not on PATH
|
|
49
|
+
model: '' # default model, forwarded as --model
|
|
50
|
+
effort: '' # default reasoning effort, forwarded as --effort
|
|
51
|
+
defaultBase: '' # default review base, e.g. origin/main
|
|
52
|
+
maxConcurrent: 2 # concurrent Codex tasks
|
|
53
|
+
timeoutMs: 1800000 # per-run timeout (30 minutes)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Differences from upstream
|
|
57
|
+
|
|
58
|
+
Upstream is a Claude Code plugin; DSH has no slash-command files, shell hooks, or markdown subagents, so the port differs in a few places:
|
|
59
|
+
|
|
60
|
+
- **Command names drop the colon**: `/codex:review` → `/codex-review` (DSH command names cannot contain `:`).
|
|
61
|
+
- **rescue becomes a tool**: the `codex:codex-rescue` subagent maps to the `codex_task` tool plus `/codex-rescue`.
|
|
62
|
+
- **No `/codex:transfer`**: it reads `~/.claude/projects`, which has no DSH equivalent.
|
|
63
|
+
- **No Stop review gate**: DSH has no shell hooks, so the gate toggle in `setup` is inert.
|
|
64
|
+
- **Engine untouched**: `vendor/codex/` is a verbatim copy of upstream `plugins/codex/`, adapted only through `CLAUDE_PLUGIN_DATA`, `CODEX_COMPANION_SESSION_ID`, and PATH injection.
|
|
65
|
+
|
|
66
|
+
## Development
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
node --test # unit tests
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
`lib/args.js` parses flags, `lib/companion.js` runs the child process, `lib/commands.js` assembles commands, `lib/tool.js` defines the tool, `lib/index.js` wires everything.
|
|
73
|
+
|
|
74
|
+
## License
|
|
75
|
+
|
|
76
|
+
Apache-2.0. `vendor/codex/` is derived from OpenAI's codex-plugin-cc; copyright OpenAI, with the original `LICENSE` and `NOTICE` preserved.
|
package/README.zh.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# dsh-codex
|
|
2
|
+
|
|
3
|
+
把 [openai/codex-plugin-cc](https://github.com/openai/codex-plugin-cc) 的能力搬进 [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness):让本机 Codex CLI 审查你的改动,或直接把调查/修复任务交给它。
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# 从 GitHub 直接装
|
|
9
|
+
dsh plugin add github:zhang6hk/dsh-codex
|
|
10
|
+
|
|
11
|
+
# 或从 npm(@zhang6hk scope)
|
|
12
|
+
dsh plugin add @zhang6hk/dsh-codex
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
桌面端:Plugins → Add plugin,粘贴上面的 spec。
|
|
16
|
+
|
|
17
|
+
装完重启会话,输入 `/codex-setup` 确认 Codex 就绪。
|
|
18
|
+
|
|
19
|
+
## 前置条件
|
|
20
|
+
|
|
21
|
+
- [Codex CLI](https://github.com/openai/codex):`npm install -g @openai/codex`
|
|
22
|
+
- 已登录:`codex login`(ChatGPT 账号或 API key 均可)
|
|
23
|
+
- Node.js ≥ 22(DSH 自带运行时即可)
|
|
24
|
+
|
|
25
|
+
## 命令
|
|
26
|
+
|
|
27
|
+
| 命令 | 作用 |
|
|
28
|
+
|---|---|
|
|
29
|
+
| `/codex-review` | 审查当前 git 改动(原生 review,不修改代码) |
|
|
30
|
+
| `/codex-adversarial-review <关注点>` | 对抗式审查:质疑方案、取舍与假设 |
|
|
31
|
+
| `/codex-rescue <任务>` | 把调查/修复交给 Codex,保持同一线程 |
|
|
32
|
+
| `/codex-status [job-id]` | 查看任务进度 |
|
|
33
|
+
| `/codex-result <job-id>` | 取回完整结果 |
|
|
34
|
+
| `/codex-cancel <job-id>` | 取消任务 |
|
|
35
|
+
| `/codex-setup` | 检查 CLI、登录与运行时 |
|
|
36
|
+
|
|
37
|
+
审查类命令在前台运行,Codex 直接在会话里输出审查结论(上游引擎的 review 没有后台模式)。`/codex-rescue` 默认后台执行并返回任务 ID。常用参数:`--base <ref>`、`--scope auto|working-tree|branch`、`--model`、`--effort`。
|
|
38
|
+
|
|
39
|
+
除命令外还有一个 `codex_task` 工具,模型可以在对话里自行调用它把任务转给 Codex。
|
|
40
|
+
|
|
41
|
+
## 配置
|
|
42
|
+
|
|
43
|
+
在 `cordis.patch.yml` 的 `config` 里改:
|
|
44
|
+
|
|
45
|
+
```yaml
|
|
46
|
+
- insert:
|
|
47
|
+
- id: dsh-codex
|
|
48
|
+
name: '@zhang6hk/dsh-codex'
|
|
49
|
+
config:
|
|
50
|
+
codexPath: codex # Codex 可执行文件;非标准位置填绝对路径
|
|
51
|
+
model: '' # 默认模型,透传 --model
|
|
52
|
+
effort: '' # 默认推理力度,透传 --effort
|
|
53
|
+
defaultBase: '' # 默认审查基线,如 origin/main
|
|
54
|
+
maxConcurrent: 2 # 同时运行的 Codex 任务上限
|
|
55
|
+
timeoutMs: 1800000 # 单次任务超时(30 分钟)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## 和原版有什么不同
|
|
59
|
+
|
|
60
|
+
原版是 Claude Code 插件,DSH 没有斜杠命令文件、shell hooks 和 markdown 子代理,所以移植方式不同:
|
|
61
|
+
|
|
62
|
+
- **命令名去掉冒号**:`/codex:review` → `/codex-review`(DSH 命令名不允许 `:`)。
|
|
63
|
+
- **rescue 变成工具**:Claude 的 `codex:codex-rescue` 子代理改为 `codex_task` 工具 + `/codex-rescue` 命令。
|
|
64
|
+
- **不做 `/codex:transfer`**:它读取 `~/.claude/projects`,DSH 没有对应概念。
|
|
65
|
+
- **不做 Stop 审查闸门**:DSH 没有 shell hooks,`setup` 里的闸门开关不再生效。
|
|
66
|
+
- **引擎零改动**:`vendor/codex/` 是上游 `plugins/codex/` 原样拷贝,只通过 `CLAUDE_PLUGIN_DATA`、`CODEX_COMPANION_SESSION_ID` 和 PATH 注入适配。
|
|
67
|
+
|
|
68
|
+
## 开发
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
node --test # 全部单测
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
单个命令文件职责:`lib/args.js` 解析参数、`lib/companion.js` 起子进程、`lib/commands.js` 组装命令、`lib/tool.js` 定义工具、`lib/index.js` 接线。
|
|
75
|
+
|
|
76
|
+
## 许可
|
|
77
|
+
|
|
78
|
+
Apache-2.0。`vendor/codex/` 派生自 OpenAI 的 codex-plugin-cc,版权归 OpenAI,保留原 `LICENSE` 与 `NOTICE`。
|
package/cordis.patch.yml
ADDED
package/lib/args.js
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Translate a DSH command's raw text input into arguments for the vendored
|
|
3
|
+
* `codex-companion.mjs` engine.
|
|
4
|
+
*
|
|
5
|
+
* Commands arrive as free text (`--base main 看下并发`), while the engine wants
|
|
6
|
+
* a strict argv. Only flags the engine understands are extracted; anything
|
|
7
|
+
* else stays part of the prompt so a user can mention `--weird` in prose.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const REVIEW_FLAGS = ['base', 'scope', 'model', 'effort']
|
|
11
|
+
const TASK_FLAGS = ['resume', 'fresh', 'resume-last', 'write', 'model', 'effort']
|
|
12
|
+
const BOOLEAN_FLAGS = new Set(['resume', 'fresh', 'resume-last', 'write'])
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @param {string} raw
|
|
16
|
+
* @param {string[]} [allowed]
|
|
17
|
+
* @returns {{flags: Record<string, string | true>, positional: string[]}}
|
|
18
|
+
*/
|
|
19
|
+
export function splitFlags(raw, allowed = [...REVIEW_FLAGS, ...TASK_FLAGS]) {
|
|
20
|
+
const allowedSet = new Set(allowed)
|
|
21
|
+
const tokens = String(raw ?? '').trim().split(/\s+/u).filter(Boolean)
|
|
22
|
+
/** @type {Record<string, string | true>} */
|
|
23
|
+
const flags = {}
|
|
24
|
+
/** @type {string[]} */
|
|
25
|
+
const positional = []
|
|
26
|
+
|
|
27
|
+
for (let index = 0; index < tokens.length; index += 1) {
|
|
28
|
+
const token = tokens[index]
|
|
29
|
+
if (!token.startsWith('--') || token.length === 2) {
|
|
30
|
+
positional.push(token)
|
|
31
|
+
continue
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const equals = token.indexOf('=')
|
|
35
|
+
const key = (equals > 0 ? token.slice(2, equals) : token.slice(2)).toLowerCase()
|
|
36
|
+
if (!allowedSet.has(key)) {
|
|
37
|
+
positional.push(token)
|
|
38
|
+
continue
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (equals > 0) {
|
|
42
|
+
flags[key] = token.slice(equals + 1)
|
|
43
|
+
continue
|
|
44
|
+
}
|
|
45
|
+
if (BOOLEAN_FLAGS.has(key)) {
|
|
46
|
+
flags[key] = true
|
|
47
|
+
continue
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const value = tokens[index + 1]
|
|
51
|
+
if (value !== undefined && !value.startsWith('--')) {
|
|
52
|
+
flags[key] = value
|
|
53
|
+
index += 1
|
|
54
|
+
continue
|
|
55
|
+
}
|
|
56
|
+
flags[key] = true
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return { flags, positional }
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* @param {string} kind `review` or `adversarial-review`
|
|
64
|
+
* @param {string} raw
|
|
65
|
+
* @param {{base?: string, model?: string, effort?: string}} defaults
|
|
66
|
+
* @returns {{argv: string[], prompt: string}}
|
|
67
|
+
*/
|
|
68
|
+
export function buildReviewArgv(kind, raw, defaults = {}) {
|
|
69
|
+
const { flags, positional } = splitFlags(raw, REVIEW_FLAGS)
|
|
70
|
+
const argv = [kind]
|
|
71
|
+
|
|
72
|
+
for (const [flag, fallback] of [
|
|
73
|
+
['base', defaults.base],
|
|
74
|
+
['scope', undefined],
|
|
75
|
+
['model', defaults.model],
|
|
76
|
+
['effort', defaults.effort],
|
|
77
|
+
]) {
|
|
78
|
+
const value = typeof flags[flag] === 'string' ? flags[flag] : fallback
|
|
79
|
+
if (typeof value === 'string' && value.length > 0) {
|
|
80
|
+
argv.push(`--${flag}`, value)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return { argv, prompt: positional.join(' ') }
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* @param {string} raw
|
|
89
|
+
* @param {{model?: string, effort?: string}} defaults
|
|
90
|
+
* @returns {{argv: string[], prompt: string}}
|
|
91
|
+
*/
|
|
92
|
+
export function buildTaskArgv(raw, defaults = {}) {
|
|
93
|
+
const { flags, positional } = splitFlags(raw, TASK_FLAGS)
|
|
94
|
+
const argv = ['task']
|
|
95
|
+
|
|
96
|
+
if (flags.resume === true) {
|
|
97
|
+
argv.push('--resume')
|
|
98
|
+
} else if (flags['resume-last'] === true) {
|
|
99
|
+
argv.push('--resume-last')
|
|
100
|
+
} else {
|
|
101
|
+
argv.push('--fresh')
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (flags.write === true) {
|
|
105
|
+
argv.push('--write')
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const model = typeof flags.model === 'string' ? flags.model : defaults.model
|
|
109
|
+
if (typeof model === 'string' && model.length > 0) {
|
|
110
|
+
argv.push('--model', model)
|
|
111
|
+
}
|
|
112
|
+
const effort = typeof flags.effort === 'string' ? flags.effort : defaults.effort
|
|
113
|
+
if (typeof effort === 'string' && effort.length > 0) {
|
|
114
|
+
argv.push('--effort', effort)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return { argv, prompt: positional.join(' ') }
|
|
118
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import fs from 'node:fs'
|
|
2
|
+
import path from 'node:path'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The engine always spawns a binary literally named `codex`. When the user
|
|
6
|
+
* configures a different absolute path, expose it as `codex` through a private
|
|
7
|
+
* bin directory prepended to PATH — no engine patch needed.
|
|
8
|
+
*
|
|
9
|
+
* @param {{codexPath?: string, dataDir: string}} options
|
|
10
|
+
* @returns {string | null} Directory to prepend to PATH, if any.
|
|
11
|
+
*/
|
|
12
|
+
export function prepareCodexBinDir({ codexPath, dataDir }) {
|
|
13
|
+
const value = String(codexPath ?? '').trim()
|
|
14
|
+
if (value.length === 0 || value === 'codex' || !path.isAbsolute(value)) {
|
|
15
|
+
return null
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const binDir = path.join(dataDir, 'bin')
|
|
19
|
+
fs.mkdirSync(binDir, { recursive: true })
|
|
20
|
+
const link = path.join(binDir, 'codex')
|
|
21
|
+
try {
|
|
22
|
+
if (fs.readlinkSync(link) === value) {
|
|
23
|
+
return binDir
|
|
24
|
+
}
|
|
25
|
+
fs.unlinkSync(link)
|
|
26
|
+
} catch {
|
|
27
|
+
// no existing link
|
|
28
|
+
}
|
|
29
|
+
fs.symlinkSync(value, link)
|
|
30
|
+
return binDir
|
|
31
|
+
}
|