From 50ada82a542b6edf66b8103d1a939b31f2cffb08 Mon Sep 17 00:00:00 2001 From: codex Date: Tue, 15 Sep 2026 17:38:59 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=20Codex=20=E5=8E=9F?= =?UTF-8?q?=E7=94=9F=20Luna=20=E5=A7=94=E6=B4=BE=E9=80=9A=E9=81=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 43 ++++++++++++------ README.zh-CN.md | 45 ++++++++++++------- docs/task-routing-pilot-2026-09-15.md | 5 ++- .../.codex-plugin/plugin.json | 12 ++--- plugins/deepseek-code-agent/README.md | 26 ++++++----- .../deepseek-coding-delegation/SKILL.md | 40 +++++++++++------ .../references/model-selection.md | 23 +++++++--- .../deepseek-code-agent/tests/mcp.test.mjs | 4 +- 8 files changed, 129 insertions(+), 69 deletions(-) diff --git a/README.md b/README.md index 5f10a35..5d9f88b 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,9 @@ English | [简体中文](./README.zh-CN.md) -Delegate bounded coding work to DeepSeek or GLM through OpenCode Go, or directly to the official DeepSeek API through the OpenCode runtime. Codex remains the controller, reviewer, and final authority. +Delegate bounded coding work either to Codex-native GPT-5.6 Luna or to DeepSeek/GLM through OpenCode. Codex remains the controller, reviewer, and final authority. -The plugin adds persistent worker sessions, mailbox-style corrections, status waiting, context forks, permission handling, isolated Git worktrees, diff inspection, and scoped repository-instruction manifests. It is designed for coding goals where one worker implements and Codex reviews. +The bundled Skill chooses among direct Codex work, a native Luna subagent, and the plugin's persistent OpenCode worker. The plugin adds mailbox-style corrections, status waiting, context forks, permission handling, isolated Git worktrees, diff inspection, and scoped repository-instruction manifests for the OpenCode lane. ## One-sentence installation with Codex @@ -30,8 +30,10 @@ Start a new Codex task after installation so the MCP tools and Skill are loaded. - Local Codex desktop app or Codex CLI with plugin support - Git - Node.js 18 or newer -- A current OpenCode version (validated with 1.18.30) -- OpenCode Go access for Go models, or separate official DeepSeek API credentials +- A current OpenCode version (validated with 1.18.30) for the DeepSeek/GLM lane +- OpenCode Go access for Go models, or separate official DeepSeek API credentials, when using that lane + +The Codex-native Luna lane uses the host's `gpt-5.6-luna` subagent directly. It does not need OpenCode, `DEEPSEEK_API_KEY`, or another external provider credential. Availability depends on the current Codex host and account. The plugin stores no API keys. Authenticate OpenCode interactively on each computer: @@ -48,9 +50,15 @@ opencode-go/deepseek-v4.1-flash Do not paste provider keys into Codex prompts, GitHub issues, logs, or repository files. -## Select the model +## Select the worker lane and model + +Use ordinary language in Codex. For example, “Use the Codex-native GPT-5.6 Luna subagent with medium reasoning for this bounded implementation” selects the native lane. It does not call `ds_check`, `ds_spawn_agent`, or OpenCode, and it is not a value accepted by the plugin's `provider` field. Luna reasoning can be requested as `none`, `low`, `medium`, `high`, `xhigh`, or `max`; if the host does not offer the requested combination, Codex reports that instead of silently switching lanes. + +The native Luna choice is scoped to the requested work. `ds_model_defaults` stores only OpenCode worker defaults and cannot persist a native Codex model preference. A native subagent uses the model selected when it is created; changing it means creating a new subagent. + +[OpenAI documents GPT-5.6 Luna](https://developers.openai.com/api/docs/models/gpt-5.6-luna) as a cost-sensitive, high-volume model. Published API prices do not establish how a Codex plan meters native subagent usage, so this project does not claim a fixed Luna saving without a matched Codex measurement. -Without saved machine preferences, the built-in default remains `opencode-go/deepseek-v4.1-flash` with `max` reasoning. `ds_check` and `ds_spawn_agent` now accept: +For the OpenCode worker lane, without saved machine preferences, the built-in default remains `opencode-go/deepseek-v4.1-flash` with `max` reasoning. `ds_check` and `ds_spawn_agent` accept: | Route | `provider` | `model` | |---|---|---| @@ -59,7 +67,7 @@ Without saved machine preferences, the built-in default remains `opencode-go/dee | Official Flash | `deepseek` | `deepseek-flash` | | Official Pro | `deepseek` | `deepseek-v4-pro` | -A standalone model/effort-setting request saves the machine default; use “this task only” for a temporary override. Use natural language: “Make OpenCode Go GLM 5.3 Flash with maximum reasoning my machine default,” “Use official DeepSeek Flash just for this task,” “Show my worker defaults,” or “Restore the plugin's original defaults.” Maximum/最高/拉满 map to `max`. +A standalone OpenCode model/effort-setting request saves that lane's machine default; use “this task only” for a temporary override. Use natural language: “Make OpenCode Go GLM 5.3 Flash with maximum reasoning my machine default,” “Use official DeepSeek Flash just for this task,” “Show my OpenCode worker defaults,” or “Restore the plugin's original defaults.” Maximum/最高/拉满 map to `max`. Persistent defaults are saved through `ds_model_defaults`, apply to future workers across Codex tasks on this machine, and survive plugin reinstall. Task-specific choices override them without changing the saved preference. This setting controls plugin workers; the Codex controller model remains an app setting. The selected model persists across follow-ups, queues, restarts and forks. Changing model starts a new worker; errors never silently change providers. @@ -138,25 +146,31 @@ Create a coding goal in Codex, or explicitly invoke the bundled Skill: Use $deepseek-coding-delegation to delegate this implementation and review the result. ``` -Codex selects the relevant repository instructions, passes bounded `scope_paths`, task-specific `required_reads`, and compact `critical_constraints`, then independently reviews the resulting diff and tests. Large rule documents can be limited to named sections instead of being copied into the prompt. +To use the native low-cost lane without external credentials: + +```text +Use Codex-native GPT-5.6 Luna with medium reasoning for the bounded implementation. Do not use OpenCode or external provider credentials; Codex must review and verify the result. +``` + +For native Luna, Codex sends a bounded task and the necessary repository context through native delegation. For the OpenCode lane, Codex passes explicit `scope_paths`, task-specific `required_reads`, and compact `critical_constraints`. In both cases Codex independently reviews the resulting diff and tests. ## Queen token efficiency ### Route by task complexity -Choose the route from reasoning, risk, and exploration/verification burden, not line or file counts. **Small** known edits that take a few minutes stay with Codex. **Medium** mechanical work with clear acceptance criteria prefers one persistent worker. **Large or high-risk** work — state machines, concurrency, permissions, transactions, migrations — may still delegate the labor, but Codex must first fix the design, interfaces, invariants, failure semantics and acceptance cases, then review the actual diff and run independent verification; a worker's self-report or passing self-tests are never acceptance. An explicit user request to delegate or to stay direct overrides these defaults. +Choose the route from reasoning, risk, and exploration/verification burden, not line or file counts. **Small** known edits that take a few minutes stay with Codex. **Medium** mechanical work with clear acceptance criteria prefers delegation: use Codex-native `gpt-5.6-luna` for a bounded, low-risk native subtask when available, or the persistent OpenCode worker when the user selects DeepSeek/GLM or the task benefits from its worktree, correction, and verification lifecycle. **Large or high-risk** work — state machines, concurrency, permissions, transactions, migrations — may delegate only bounded labor to either lane; Codex must first fix the design, interfaces, invariants, failure semantics and acceptance cases, then review the actual diff and run independent verification. A worker's self-report or passing self-tests are never acceptance. An explicit user model or lane choice overrides these defaults, and failures never authorize a silent cross-lane fallback. -A 2026-09-15 pilot paired one direct and one delegated execution per size from the same commit: [task routing pilot](./docs/task-routing-pilot-2026-09-15.md). It ran one execution per cell in parallel without alternating order, so it is not the repeated benchmark the queen protocol asks for, and its numbers neither generalize nor promise a fixed saving. In that pilot, delegated worker non-cached input plus output was 13.78% below the three direct runs, while the controller's own interval was 55.41% below the direct proxy total; the controller interval also covers managing the native control arm and reviewing both runs, so it is not a pure delegation bill. Worker totals including cached reads were higher than direct totals, so combined tokens and latency can still increase; medium and large worker usage is marked incomplete. +A 2026-09-15 pilot paired one direct and one delegated DeepSeek execution per size from the same commit: [task routing pilot](./docs/task-routing-pilot-2026-09-15.md). It did not test Luna. It ran one execution per cell in parallel without alternating order, so it is not the repeated benchmark the queen protocol asks for, and its numbers neither generalize nor promise a fixed saving. In that pilot, delegated worker non-cached input plus output was 13.78% below the three direct runs, while the controller's own interval was 55.41% below the direct proxy total; the controller interval also covers managing the direct Codex control arm and reviewing both runs, so it is not a pure delegation bill. Worker totals including cached reads were higher than direct totals, so combined tokens and latency can still increase; medium and large worker usage is marked incomplete. -### Design, implement, verify, review +### Design, delegate, verify, review -Codex reads the critical call chain and decides interfaces, invariants and acceptance cases before delegation. An optional `task_spec` gives the worker those decisions and the exact check commands. The worker completes implementation, self-tests and routine repairs in one session. Codex reviews the patch and batches feedback; after two unsuccessful correction rounds it can take over after confirming the worker and verification have stopped. +Codex reads the critical call chain and decides interfaces, invariants and acceptance cases before delegation. A native Luna subagent receives one bounded task through Codex's native delegation path. An OpenCode worker can additionally receive a persisted `task_spec`, worktree and exact check commands. In both lanes Codex reviews the actual patch and independently verifies acceptance; the OpenCode correction lifecycle remains unchanged. `ds_verify_agent` runs only the persisted checks while the worker is idle, retaining exit codes and full logs. Verification is bound to the current source, Git index, task specification and instruction identity; edits invalidate earlier evidence. Repeated calls observe the same asynchronous job; `rerun=true` explicitly requests another execution. `ds_wait_agent(return_on="actionable")` absorbs transient retries and escalates a continuous 120-second retry streak. The 55-second wait and 65-second host timeout remain. Existing calls without the new options keep their prior behavior. See the [task and evidence contract](plugins/deepseek-code-agent/skills/deepseek-coding-delegation/references/control-contract.md). This update has local functional tests; no new model comparison was run, so token savings and latency improvements remain unmeasured. -The default workflow reserves **queen (Codex) judgment** for intent, consequential design choices, uncertain diagnoses, risk-focused review and acceptance. The worker handles high-volume discovery, editing, tests, routine fixes, documentation and evidence preparation within scope. Queen token savings should come from offloading labor while preserving quality. Delegate a coherent unit of work and reuse its session for corrections. Tiny known edits can still cost less to do directly. +The default workflow reserves **queen (Codex) judgment** for intent, consequential design choices, uncertain diagnoses, risk-focused review and acceptance. Luna or the OpenCode worker handles high-volume discovery, editing, tests, routine fixes, documentation and evidence preparation within scope. Queen token savings should come from offloading labor while preserving quality. Delegate a coherent unit of work; reuse persistent OpenCode sessions for corrections, while native Luna gets a new subagent when its model selection changes. Tiny known edits can still cost less to do directly. `ds_wait_agent` and `ds_inspect_agent` default to compact responses: status, attention requests, cumulative worker usage and a bounded final handoff. Task echoes, intermediate tool logs and repeated instruction manifests stay out of the queen's normal context. Use `detail="full"` for diagnosis or omitted evidence and `include_diff=true` when the diff is needed. Save the spawn manifest once and reuse returned cursors. @@ -167,7 +181,8 @@ The [earlier 27-result synthetic benchmark](./docs/token-routing-benchmark-2026- ## Safety model - Codex owns scope, authorization, business decisions, review, verification, and goal completion. -- The worker must not commit, push, merge, deploy, alter production data, expose credentials, or discard unrelated changes. +- Neither a native Luna subagent nor an OpenCode worker may commit, push, merge, deploy, alter production data, expose credentials, or discard unrelated changes without the user's authorization. +- Native Luna uses Codex's built-in delegation path and must not receive OpenCode provider fields or external credentials. A lane failure never permits silent fallback to another model or provider. - Isolated worktrees start from committed `HEAD`; they do not include uncommitted files. - Instruction manifests identify the exact paths, hashes, and read scopes selected for the worker. They do not prove semantic compliance, so Codex must still review the patch. - The local OpenCode server binds to `127.0.0.1` and uses a random per-process password. diff --git a/README.zh-CN.md b/README.zh-CN.md index 6ddd2c9..1b75c34 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -2,9 +2,9 @@ [English](./README.md) | 简体中文 -支持通过 OpenCode Go 使用 DeepSeek、GLM,也支持通过 OpenCode 执行器直连 DeepSeek 官方 API。把范围明确的编码实现交给执行者,由 Codex 保持主控、审核和最终决定权。 +支持把范围明确的编码工作交给 Codex 原生 GPT-5.6 Luna 子 Agent,也支持通过 OpenCode Go 使用 DeepSeek、GLM,或通过 OpenCode 执行器直连 DeepSeek 官方 API。Codex 始终保持主控、审核和最终决定权。 -插件提供持久执行者会话、信箱式纠正、状态等待、上下文 fork、权限请求处理、隔离 Git worktree、diff 检查和定向仓库规则清单。它适用于“一个执行者编码、Codex 最终把关”的编码目标。 +随插件提供的 Skill 会在 Codex 直接处理、原生 Luna 子 Agent 和插件的持久 OpenCode Worker 之间选择。插件为 OpenCode 通道提供持久会话、信箱式纠正、状态等待、上下文 fork、权限请求处理、隔离 Git worktree、diff 检查和定向仓库规则清单。 ## 在 Codex 中一句话安装 @@ -30,8 +30,10 @@ codex plugin add deepseek-code-agent@deepseek-code-agent - 支持插件的本地 Codex 桌面应用或 Codex CLI - Git - Node.js 18 或更高版本 -- 当前版本的 OpenCode(已用 1.18.30 验证) -- Go 模型需要 OpenCode Go 权限;官方模型需要单独的 DeepSeek API 凭据 +- DeepSeek/GLM 通道需要当前版本的 OpenCode(已用 1.18.30 验证) +- 使用该通道时,Go 模型需要 OpenCode Go 权限;官方模型需要单独的 DeepSeek API 凭据 + +Codex 原生 Luna 通道直接使用宿主提供的 `gpt-5.6-luna` 子 Agent,不需要 OpenCode、`DEEPSEEK_API_KEY` 或其他外部 Provider 凭据。是否可用以当前 Codex 宿主和账号为准。 插件不保存 API Key。每台电脑都要在本机交互式认证: @@ -48,9 +50,15 @@ opencode-go/deepseek-v4.1-flash 不要把 Provider Key 粘贴到 Codex 提示词、GitHub Issue、日志或仓库文件中。 -## 选择模型 +## 选择执行通道和模型 + +日常可以直接在 Codex 里口述。例如:“这段范围明确的实现使用 Codex 原生 GPT-5.6 Luna 子 Agent,推理开到 medium。”这会选择原生通道,不调用 `ds_check`、`ds_spawn_agent` 或 OpenCode,也不能把 Luna 填进插件的 `provider` 字段。Luna 可请求 `none`、`low`、`medium`、`high`、`xhigh` 或 `max`;如果当前宿主不支持所选组合,Codex 应明确报告,不能静默换通道。 + +Luna 选择只作用于本次要求的工作。`ds_model_defaults` 只保存 OpenCode Worker 默认值,不能持久化 Codex 原生模型偏好。原生子 Agent 创建后固定使用当时选择的模型;换模型要新建子 Agent。 + +[OpenAI 官方将 GPT-5.6 Luna 定位为面向成本敏感、高吞吐工作负载的模型](https://developers.openai.com/api/docs/models/gpt-5.6-luna)。公开 API 价格不能直接证明 Codex 套餐如何计算原生子 Agent 用量,因此本项目不会在缺少同条件 Codex 实测时承诺固定节省比例。 -未保存本机偏好时,内置默认是 `opencode-go/deepseek-v4.1-flash`,推理档位 `max`。`ds_check` 和 `ds_spawn_agent` 现在都可以传入: +对于 OpenCode Worker 通道,未保存本机偏好时,内置默认是 `opencode-go/deepseek-v4.1-flash`,推理档位 `max`。`ds_check` 和 `ds_spawn_agent` 可以传入: | 通道 | `provider` | `model` | |---|---|---| @@ -59,14 +67,14 @@ opencode-go/deepseek-v4.1-flash | 官方 Flash | `deepseek` | `deepseek-flash` | | 官方 Pro | `deepseek` | `deepseek-v4-pro` | -日常建议直接口述。单独提出模型和推理档位设置时,默认保存到本机全局;如果是临时使用,加上“这次”或“仅当前任务”: +OpenCode 模型同样可以直接口述。单独提出该通道的模型和推理档位设置时,默认保存到本机全局;如果是临时使用,加上“这次”或“仅当前任务”: - “以后都用 OpenCode Go 的 GLM 5.3 Flash,推理开到最大”——保存本机全局默认,之后新建的执行者和未来 Codex 任务都继承。 - “这次走 DeepSeek 官方 API,用 Flash,推理最高”——只覆盖当前任务的新执行者。 - “当前默认用什么模型?”——查询实际保存的配置。 - “恢复插件原来的默认模型”——清除本机偏好,恢复内置默认。 -“最大 / 最高 / 拉满”都会映射到 `max`。口述由技能转换成明确的 provider、模型和档位,再通过 `ds_model_defaults` 保存到本机;偏好不写进插件包,重装后仍保留。全局指本插件的新执行者,Codex 主控模型仍由应用设置决定。 +“最大 / 最高 / 拉满”都会映射到 `max`。OpenCode 口述由技能转换成明确的 provider、模型和档位,再通过 `ds_model_defaults` 保存到本机;偏好不写进插件包,重装后仍保留。全局只指本插件的新 OpenCode Worker,Codex 主控模型和原生 Luna 子 Agent 不受它影响。 选定的模型会随会话保存,追加消息、队列、重启和 fork 都保持该选择。更换模型需要新建执行者;出错时不会自动换通道。 @@ -145,25 +153,31 @@ npm --prefix plugins/deepseek-code-agent run test:live 使用 $deepseek-coding-delegation 委派实现,并由 Codex 审核结果。 ``` -Codex 会选择相关仓库规则,传入明确的 `scope_paths`、任务相关 `required_reads` 和精简的 `critical_constraints`,然后独立审核 diff 与测试。较大的规则文档可以只指定相关章节,不需要整份复制进提示词。 +如需完全使用 Codex 原生低成本通道,可以直接说: + +```text +这段范围明确的实现用 Codex 原生 GPT-5.6 Luna,推理开到 medium。不要使用 OpenCode 或外部 Provider 凭据,结果由 Codex 审核并独立验证。 +``` + +使用原生 Luna 时,Codex 通过内置委派传入边界明确的任务和必要仓库上下文;使用 OpenCode 通道时,Codex 传入明确的 `scope_paths`、任务相关 `required_reads` 和精简的 `critical_constraints`。两种通道都由 Codex 独立审核 diff 与测试。 ## Queen Token 优化 ### 按任务复杂度路由 -路由依据判断量、风险以及探索与验证负担,而不是行数或文件数。**小型**已知改动几分钟可完成,由 Codex 直接处理;**中型**机械实现且验收标准清晰,优先交给一个持久执行者;**大型或高风险**任务(状态机、并发、权限、事务、迁移等)可以把实现交给执行者,但 Codex 必须先确定设计、接口、不变量、失败语义和验收案例,再审查实际 diff 并独立验证,绝不按 worker 自报或自测通过来接受。用户明确要求委派或直接处理时,以用户要求为准。 +路由依据判断量、风险以及探索与验证负担,而不是行数或文件数。**小型**已知改动几分钟可完成,由 Codex 直接处理;**中型**机械实现且验收标准清晰时优先委派:范围明确、风险较低的原生子任务可优先使用 `gpt-5.6-luna`,用户指定 DeepSeek/GLM 或任务需要持久会话、worktree、纠错与验证生命周期时使用 OpenCode Worker。**大型或高风险**任务(状态机、并发、权限、事务、迁移等)只能把边界明确的劳动交给任一通道,Codex 必须先确定设计、接口、不变量、失败语义和验收案例,再审查实际 diff 并独立验证。绝不按 Worker 自报或自测通过来接受;用户明确选择优先,任何失败都不能触发静默跨通道降级。 -2026-09-15 的 pilot 在同一基线 commit 上为每个规模各做了一次 direct 与委派执行:[任务分级 pilot](./docs/task-routing-pilot-2026-09-15.md)。每格仅一次、双臂并行、顺序未交替,因此它不是 queen 协议要求的三次重复正式基准,结果不能推广,也不承诺固定节省。该 pilot 中,worker 非缓存输入加输出合计比三次 direct 低 13.78%,controller 自身区间的 proxy 比 direct proxy 合计低 55.41%;controller 区间也包含原生对照管理和两边审查,不能当作纯委派账单。计入缓存后 worker total 高于 direct total,总 Token 和耗时仍可能增加;medium 和 large 的 worker 用量标记为不完整。 +2026-09-15 的 pilot 在同一基线 commit 上为每个规模各做了一次 Codex 直接执行与委派 DeepSeek 执行:[任务分级 pilot](./docs/task-routing-pilot-2026-09-15.md)。它没有测试 Luna。每格仅一次、双臂并行、顺序未交替,因此它不是 queen 协议要求的三次重复正式基准,结果不能推广,也不承诺固定节省。该 pilot 中,worker 非缓存输入加输出合计比三次 direct 低 13.78%,controller 自身区间的 proxy 比 direct proxy 合计低 55.41%;controller 区间也包含管理 Codex 直接执行对照组和审查两组结果,不能当作纯委派账单。计入缓存后 worker total 高于 direct total,总 Token 和耗时仍可能增加;medium 和 large 的 worker 用量标记为不完整。 -### Codex 设计与审核,GLM 实现 +### Codex 设计与审核,Luna 或 OpenCode Worker 实现 -Codex 先阅读关键调用链,明确接口、必须保持的行为和验收案例,通过可选 `task_spec` 一次交付设计决定和检查命令。执行模型在同一会话中完成实现、自测和常规修复,Codex 集中审核并批量反馈;两轮修正仍未通过时,确认 worker 和验收进程停止后再接管。 +Codex 先阅读关键调用链,明确接口、必须保持的行为和验收案例。原生 Luna 子 Agent 通过 Codex 自身的委派通道接收一个边界明确的任务;OpenCode Worker 还可以接收持久化 `task_spec`、worktree 和精确检查命令。两条通道都必须由 Codex 审查实际补丁并独立验收;OpenCode 原有纠错生命周期保持不变。 新增 `ds_verify_agent`:只在 worker 空闲时运行预先保存的检查,保留退出码和完整日志,并将结果绑定到源码、Git 暂存区、任务规范和指令身份。代码变化会使旧证据失效;重复查询只读取同一异步任务,显式设置 `rerun=true` 才重新执行。`ds_wait_agent(return_on="actionable")` 在程序内处理短暂重试,连续重试 120 秒后升级为需处理事件。55 秒等待和 65 秒宿主超时保持不变,旧调用兼容。 详见[任务与验收契约](plugins/deepseek-code-agent/skills/deepseek-coding-delegation/references/control-contract.md)。本次完成本地功能验证,未进行新的模型对比实测,因此尚不声称达到具体的 Token 节省比例或耗时目标。 -默认流程让 **queen(Codex)专注于最影响质量的判断**:理解需求、关键设计与取舍、疑难诊断、风险审查和最终验收。工蜂承担量大的代码探索、实现、测试、常规修复、文档和证据整理。省 queen Token 应该来自把这些工作交出去,同时保持质量。一次委派一个完整行为,纠错复用同一会话;已知的小改动仍可直接完成。 +默认流程让 **queen(Codex)专注于最影响质量的判断**:理解需求、关键设计与取舍、疑难诊断、风险审查和最终验收。Luna 或 OpenCode Worker 承担量大的代码探索、实现、测试、常规修复、文档和证据整理。省 queen Token 应该来自把这些工作交出去,同时保持质量。一次委派一个完整行为;OpenCode 纠错复用持久会话,原生 Luna 更换模型时新建子 Agent。已知的小改动仍可直接完成。 `ds_wait_agent` 和 `ds_inspect_agent` 默认只返回精简状态、待处理请求、执行者累计用量和有长度上限的最终交付摘要。普通等待不再带回任务回声、工具过程日志或重复指令清单。需要诊断或补全证据时使用 `detail="full"`,需要 diff 时显式设置 `include_diff=true`。保存首次 spawn 的清单,并持续复用返回的 cursor。 @@ -174,7 +188,8 @@ Codex 先阅读关键调用链,明确接口、必须保持的行为和验收 ## 安全边界 - Codex 负责范围、授权、业务决定、审核、验证和目标完成状态。 -- 执行者不得自行提交、推送、合并、部署、修改生产数据、暴露凭据或丢弃无关改动。 +- 原生 Luna 子 Agent 和 OpenCode Worker 都不得在没有用户授权时自行提交、推送、合并、部署、修改生产数据、暴露凭据或丢弃无关改动。 +- Luna 使用 Codex 内置委派通道,不接收 OpenCode Provider 字段或外部凭据;任一通道失败都不能静默切换模型或 Provider。 - 隔离 worktree 从已提交的 `HEAD` 创建,不包含未提交文件。 - 指令清单记录执行者收到的准确路径、哈希和读取范围,但不能证明语义上完全服从,因此 Codex 仍须审核补丁。 - 本地 OpenCode 服务只绑定 `127.0.0.1`,每次进程使用随机密码。 diff --git a/docs/task-routing-pilot-2026-09-15.md b/docs/task-routing-pilot-2026-09-15.md index 94ebb9c..810fa71 100644 --- a/docs/task-routing-pilot-2026-09-15.md +++ b/docs/task-routing-pilot-2026-09-15.md @@ -1,6 +1,6 @@ # Task Routing Pilot — 2026-09-15 -A transparent single-pair pilot of the task routing policy. It records one direct Codex execution and one delegated DeepSeek worker execution for each of a small, medium and large task, all from the same baseline commit `90d84be225fe2751ed0583917e7391ff29245559`. The machine-readable source is [task-routing-pilot-2026-09-15.json](./task-routing-pilot-2026-09-15.json); this page summarizes it and adds no new measurements. +A transparent single-pair pilot of the task routing policy. It records one direct Codex execution and one delegated DeepSeek worker execution for each of a small, medium and large task, all from the same baseline commit `90d84be225fe2751ed0583917e7391ff29245559`. It did not test the later-added Codex-native GPT-5.6 Luna lane. The machine-readable source is [task-routing-pilot-2026-09-15.json](./task-routing-pilot-2026-09-15.json); this page summarizes it and adds no new measurements. This is not a formal benchmark. There is exactly one execution per cell, both arms ran in parallel, and the order was not alternated. The queen protocol asks for at least three alternated repetitions per variant, so this pilot does not satisfy it. Do not generalize these numbers, promise a fixed saving, or merge them with the [2026-09-14 combined-token report](./token-routing-benchmark-2026-09-14.md). Combined tokens and latency can still increase. @@ -40,7 +40,7 @@ Worker total = input + cache_read + output + reasoning. Medium and large are mar From launching the six executions through accepting both arms, the controller increment was: input 6358712, cached input 6287488, output 18933, reasoning 6389, total 6377645, non-cached input 71224, proxy 90157. -This interval covers the whole two-arm experiment, including managing the native control arm and reviewing both arms. It is not a pure delegation bill and must not be presented as one. +This interval covers the whole two-arm experiment, including managing the direct Codex control arm and reviewing both arms. It is not a pure delegation bill and must not be presented as one. ### Wall time and independent acceptance @@ -81,3 +81,4 @@ All six executions were accepted. The three direct executions each needed 0 corr - Cache-inclusive worker total exceeded direct total, so combined tokens and latency may increase even when the worker proxy looks lower. - Both arms ran in parallel, so each wall time can include contention for the same machine and provider capacity; the durations are single observations, not a stable performance baseline, and they feed no token reduction calculation. - This pilot is independent of the earlier combined-token benchmark, and the two must not be mixed. +- The delegated arm used DeepSeek through the plugin. These measurements provide no evidence about native Luna cost, quality, latency or token savings. diff --git a/plugins/deepseek-code-agent/.codex-plugin/plugin.json b/plugins/deepseek-code-agent/.codex-plugin/plugin.json index 8c12fa6..7ef6057 100644 --- a/plugins/deepseek-code-agent/.codex-plugin/plugin.json +++ b/plugins/deepseek-code-agent/.codex-plugin/plugin.json @@ -1,7 +1,7 @@ { "name": "deepseek-code-agent", "version": "0.1.0+codex.20260915081857", - "description": "Delegate coding to persistent DeepSeek or GLM workers through OpenCode Go or the official DeepSeek API, with Codex review.", + "description": "Route coding to Codex-native Luna or persistent DeepSeek/GLM workers, with Codex review.", "author": { "name": "Fission21", "url": "https://github.com/Fission21" @@ -15,13 +15,14 @@ "opencode", "coding-agent", "multi-agent", - "glm" + "glm", + "luna" ], "skills": "./skills/", "interface": { "displayName": "DeepSeek Code Agent", - "shortDescription": "Delegate coding to DeepSeek or GLM with Codex review.", - "longDescription": "Adds configurable DeepSeek and GLM coding workers through OpenCode Go or the official DeepSeek API, with natural-language model selection, persistent machine defaults, scoped instruction manifests, queued follow-ups, forks, permissions, diffs and Codex review guidance.", + "shortDescription": "Route work to native Luna or DeepSeek/GLM with Codex review.", + "longDescription": "Routes bounded work to a Codex-native GPT-5.6 Luna subagent or configurable persistent DeepSeek/GLM workers through OpenCode, with natural-language selection, scoped instructions, corrections, diffs and Codex-owned review and verification.", "developerName": "Fission21", "category": "Developer Tools", "websiteURL": "https://github.com/Fission21/deepseek-code-agent", @@ -31,9 +32,10 @@ "Interactive" ], "defaultPrompt": [ + "Use Codex-native GPT-5.6 Luna with medium reasoning for this bounded implementation; do not use OpenCode or external credentials.", "Use DeepSeek or GLM to implement this coding goal, then review and verify its patch.", "Set OpenCode Go GLM 5.3 Flash with maximum reasoning as my machine default for new coding workers.", - "Show the current default worker model and inspect the active coding agent." + "Show the current OpenCode worker default and inspect the active coding agent." ] }, "mcpServers": "./.mcp.json" diff --git a/plugins/deepseek-code-agent/README.md b/plugins/deepseek-code-agent/README.md index 51d3a06..9854946 100644 --- a/plugins/deepseek-code-agent/README.md +++ b/plugins/deepseek-code-agent/README.md @@ -1,6 +1,6 @@ # DeepSeek Code Agent for Codex -This personal Codex plugin keeps Codex as the controller and reviewer while DeepSeek or GLM implements bounded coding tasks through OpenCode Go or the official DeepSeek API. OpenCode remains the agent runtime. +This personal Codex plugin keeps Codex as the controller and reviewer while bounded coding work runs either in a Codex-native GPT-5.6 Luna subagent or in a persistent DeepSeek/GLM worker through OpenCode. OpenCode remains the runtime only for the external worker lane. The plugin contains: @@ -11,9 +11,9 @@ The plugin contains: ## First computer -1. Install OpenCode and confirm `opencode --version` works. -2. Authenticate the `opencode-go` or `deepseek` provider locally. Never store the key in this plugin or a repository. -3. Run `npm run check` in this directory. +1. If you will use the external worker lane, install OpenCode and confirm `opencode --version` works. +2. For that lane, authenticate the `opencode-go` or `deepseek` provider locally. Never store the key in this plugin or a repository. +3. Before the first external worker, run `npm run check` in this directory. Native Luna does not require this provider check. 4. Install the plugin from the personal marketplace and start a new Codex task so its tools and Skill are loaded. 5. Use `/goal` with a coding objective, or explicitly invoke `$deepseek-coding-delegation`. @@ -21,13 +21,17 @@ The plugin contains: Use the Codex plugin Share action, then install the shared plugin on the other computer. Install OpenCode and authenticate the selected provider separately on that computer. Credentials and local DeepSeek session history are intentionally not transferred. -After installation, run the plugin's `ds_check` tool or `npm run check`. Start a new Codex task before testing delegation. +Before using an external worker on the other computer, run the plugin's `ds_check` tool or `npm run check`. Start a new Codex task before testing delegation. -## Model selection +## Worker lane and model selection -The built-in default is `opencode-go/deepseek-v4.1-flash` with variant `max`; a saved machine preference takes precedence. Pass `model="glm-5.3-flash"` for Go GLM, or `provider="deepseek"` for official `deepseek-flash`. `deepseek-v4-pro` and other models in the selected provider's OpenCode catalog are also supported. The saved model pair inherits its saved variant; a different selected model uses its runtime default unless explicitly set; `variant=null` removes the override for any model. +For a bounded, low-risk native task, ask Codex to “use the native GPT-5.6 Luna subagent with medium reasoning.” That route uses the host's `gpt-5.6-luna` directly and does not call `ds_check`, `ds_spawn_agent`, OpenCode, or an external credential. It is task-scoped, is not accepted as a plugin `provider`, and is not persisted by `ds_model_defaults`. Host availability is checked when Codex creates the native subagent; failure never silently switches lanes. -`ds_model_defaults` gets, sets or resets the persistent machine default for future workers across Codex tasks. Natural language such as “make Go GLM 5.3 Flash with maximum reasoning my default” maps to a validated saved selection. `ds_check` and `ds_spawn_agent` inherit it when selection is omitted; explicit selections override it. It persists across queued follow-ups, restarts and forks. Checks report catalog/provider configuration without verifying a key or calling inference. Official API requests use separate DeepSeek credentials; connect through OpenCode `/connect`, or supply `DEEPSEEK_API_KEY` to the host before launch. There is no automatic provider fallback. +[OpenAI describes Luna](https://developers.openai.com/api/docs/models/gpt-5.6-luna) as cost-sensitive and high-volume. API list prices are not a promise about native Codex plan metering, and this project has not benchmarked the Luna lane. + +For the persistent OpenCode worker lane, the built-in default is `opencode-go/deepseek-v4.1-flash` with variant `max`; a saved machine preference takes precedence. Pass `model="glm-5.3-flash"` for Go GLM, or `provider="deepseek"` for official `deepseek-flash`. `deepseek-v4-pro` and other models in the selected provider's OpenCode catalog are also supported. The saved model pair inherits its saved variant; a different selected model uses its runtime default unless explicitly set; `variant=null` removes the override for any model. + +`ds_model_defaults` gets, sets or resets the persistent machine default for future OpenCode workers across Codex tasks. Natural language such as “make Go GLM 5.3 Flash with maximum reasoning my default” maps to a validated saved selection. `ds_check` and `ds_spawn_agent` inherit it when selection is omitted; explicit selections override it. The selected OpenCode model persists across queued follow-ups, restarts and forks. Checks report catalog/provider configuration without verifying a key or calling inference. Official API requests use separate DeepSeek credentials; connect through OpenCode `/connect`, or supply `DEEPSEEK_API_KEY` to the host before launch. There is no automatic provider fallback. See [model setup and examples](skills/deepseek-coding-delegation/references/model-selection.md). @@ -46,11 +50,11 @@ The live test makes a small request to the selected model in a temporary Git rep ## Routing expectation -Route by judgment, risk, and exploration/verification burden, not line counts. Small known edits that take a few minutes stay with Codex. Medium mechanical work with clear acceptance criteria prefers one persistent worker. Large or high-risk work (state machines, concurrency, permissions, transactions, migrations) may delegate the labor, but Codex must first decide the design, interfaces, data flows, invariants, failure semantics and acceptance examples, then review the actual diff and run independent verification; worker self-reports and passing self-tests are never acceptance. An explicit user request overrides these defaults. +Route by judgment, risk, and exploration/verification burden, not line counts. Small known edits that take a few minutes stay with Codex. Medium mechanical work with clear acceptance criteria prefers delegation: use native `gpt-5.6-luna` for a bounded low-risk subtask when available, and use the persistent OpenCode worker when the user selects DeepSeek/GLM or needs its worktree, correction, and verification lifecycle. Large or high-risk work (state machines, concurrency, permissions, transactions, migrations) may delegate only bounded labor to either lane; Codex first decides the design, interfaces, data flows, invariants, failure semantics and acceptance examples, then reviews the actual diff and runs independent verification. Worker self-reports and passing self-tests are never acceptance. An explicit user request overrides these defaults, and lane failures never cause silent fallback. -Codex decides the design, interfaces, invariants and acceptance cases. A persistent worker implements that plan, self-tests and fixes routine failures. Codex reviews the scoped patch and gives one batch of feedback; after two unsuccessful review correction rounds it may take over, after confirming the worker and verification have stopped. +Codex decides the design, interfaces, invariants and acceptance cases. A native Luna subagent receives one bounded task; a persistent OpenCode worker can additionally use the plugin's worktree, correction and verification lifecycle. Codex reviews the actual patch from either lane. After two unsuccessful OpenCode review correction rounds it may take over, after confirming the worker and verification have stopped. -The repository's 2026-09-15 [task routing pilot](../../docs/task-routing-pilot-2026-09-15.md) records one direct/delegated pair per size from one commit. It is a single non-repeated pilot, not a benchmark; its results do not generalize, and combined tokens and latency can still increase. The link targets the source repository layout; a standalone plugin package does not include the `docs/` directory. +The repository's 2026-09-15 [task routing pilot](../../docs/task-routing-pilot-2026-09-15.md) records one direct/delegated DeepSeek pair per size from one commit; it did not test Luna. It is a single non-repeated pilot, not a benchmark; its results do not generalize, and combined tokens and latency can still increase. The link targets the source repository layout; a standalone plugin package does not include the `docs/` directory. `ds_spawn_agent` accepts an optional structured `task_spec`. `ds_verify_agent` runs its preselected commands and preserves full logs, binding results to a source snapshot. Verification can run beyond one MCP wait window; repeated calls observe the same job rather than executing checks again. Inspect remains read-only. Neither worker completion nor passing checks means Codex has accepted the patch. diff --git a/plugins/deepseek-code-agent/skills/deepseek-coding-delegation/SKILL.md b/plugins/deepseek-code-agent/skills/deepseek-coding-delegation/SKILL.md index 9aae7e3..6fe8e03 100644 --- a/plugins/deepseek-code-agent/skills/deepseek-coding-delegation/SKILL.md +++ b/plugins/deepseek-code-agent/skills/deepseek-coding-delegation/SKILL.md @@ -1,44 +1,56 @@ --- name: deepseek-coding-delegation -description: Keep the queen (Codex) on quality-critical engineering decisions while a DeepSeek or GLM worker handles bounded discovery, implementation, tests, routine fixes and evidence preparation. Use for coding tasks, coding goals, supporting engineering work, and selecting, querying or resetting this plugin’s worker model defaults; route small known edits directly, prefer delegation for clear medium work, and keep design, diff review and independent verification for large or high-risk work. +description: Keep the queen (Codex) on quality-critical engineering decisions while Codex-native GPT-5.6 Luna or a persistent DeepSeek/GLM worker handles bounded discovery, implementation, tests, routine fixes and evidence preparation. Use for coding tasks, coding goals, supporting engineering work, native-versus-OpenCode routing, and selecting, querying or resetting this plugin’s external worker defaults; route small known edits directly and keep queen-owned design, diff review and independent verification for risky work. --- # DeepSeek Coding Delegation -Use the queen where its judgment most affects quality: intent, acceptance criteria, architecture and consequential tradeoffs, uncertain failure diagnosis, risk-focused review and final acceptance. The selected model is the worker: own high-volume investigation, implementation and evidence preparation within the agreed bounds. The objective is to preserve the queen’s capability while offloading labor, not to minimize queen involvement at the expense of quality. Combined tokens and latency can increase; do not promise measured savings without a comparable baseline. +Use the queen where its judgment most affects quality: intent, acceptance criteria, architecture and consequential tradeoffs, uncertain failure diagnosis, risk-focused review and final acceptance. Bounded labor can go to a Codex-native `gpt-5.6-luna` subagent or to the plugin's persistent DeepSeek/GLM OpenCode worker. The objective is to preserve the queen’s capability while offloading labor, not to minimize queen involvement at the expense of quality. Combined tokens and latency can increase; do not promise measured savings without a comparable baseline. ## Divide judgment from labor - Queen: decide what is correct, which constraints matter, consequential design choices and whether the evidence supports acceptance. Spend attention on unresolved uncertainty and risky changes. -- Worker: search files, trace calls, inventory dependencies, compare existing patterns, edit code and docs, add/run relevant tests, fix known failures, reduce logs and prepare a diff/evidence summary. Delegate these supporting tasks even when their output is investigation rather than a patch. +- Delegate: search files, trace calls, inventory dependencies, compare existing patterns, edit code and docs, add/run relevant tests, fix known failures, reduce logs and prepare a diff/evidence summary. Delegate these supporting tasks even when their output is investigation rather than a patch. - For a blocking design/business choice, ask the worker for the decision needed, options, tradeoffs and its recommendation, with source paths or test evidence. The queen decides; the worker resumes. Do not interrupt the queen for ordinary implementation choices already covered by scope. -## Select the worker model +## Select the worker lane and model + +- Honor an explicit lane or model choice. “Codex 内置 Luna / 原生 Luna / GPT-5.6 Luna” selects the native `gpt-5.6-luna` subagent lane. “OpenCode Go / Go 套餐”, “官方 DeepSeek / DeepSeek API”, DeepSeek, or GLM selects the external OpenCode worker lane. Never silently switch lanes after unavailability, authentication, quota, or model errors. +- For native Luna, use Codex's native subagent capability with `model="gpt-5.6-luna"` and the requested supported reasoning effort. Do not call any `ds_*` tool, start OpenCode, pass plugin `provider` fields, or read/forward external provider credentials. Native availability comes from the current Codex host; report an unsupported model/effort combination rather than substituting another model. This plugin cannot persist a native Luna default through `ds_model_defaults`; a Luna choice is scoped to the requested work or current thread preference, and changing its model requires a new subagent. +- Map native “推理最大 / 最高 / 拉满 / max” to `reasoning_effort="max"`, “高 / high” to `high`, “中 / medium” to `medium`, “低 / low” to `low`, and “默认档位 / 自动” to omission. Never silently lower an unsupported effort. +- The remaining model-selection rules in this section apply only to the external OpenCode worker lane. - Accept ordinary language. “OpenCode Go / Go 套餐” selects `opencode-go`; “GLM 5.3 Flash” selects `glm-5.3-flash`; “官方 DeepSeek / DeepSeek API” selects `deepseek`, with Flash model `deepseek-flash`. Preserve other explicitly named model IDs and validate the catalog. - Map “推理最大 / 最高 / 拉满 / max” to `variant="max"`, “高 / high” to `high`, “低 / low” to `low`, and “默认档位 / 自动” to `null`. `high` does not satisfy a request for maximum reasoning. Never silently lower an unsupported variant. - The chosen interaction convention is that a standalone model/effort-setting request, such as “使用 OpenCode Go 里面的 GLM 5.3 Flash,推理开到最大”, saves the machine default through `ds_model_defaults(action="set", ...)`. “以后 / 全局 / 所有新执行者” also means persistent. Preserve scope the user already established. “这次 / 当前任务” or a model choice attached to a specific coding task overrides that task's new workers only: pass the full selection on their spawns without saving global defaults. -- After setting a default, report the resolved provider, model, variant and scope briefly. It covers this plugin's subsequently created workers on this machine, including future Codex tasks; existing workers keep their selection. It does not change the Codex controller model. Use `action="get"` for “查看当前默认模型” and `action="reset"` for “恢复插件原来的默认模型”. +- After setting an external default, report the resolved provider, model, variant and scope briefly. It covers this plugin's subsequently created OpenCode workers on this machine, including future Codex tasks; existing workers keep their selection. It does not change the Codex controller model or native Luna. Use `action="get"` for “查看当前 OpenCode Worker 默认模型” and `action="reset"` for “恢复插件原来的默认模型”. - With no explicit task selection, let check/spawn inherit the saved machine default rather than passing hardcoded model arguments. With no saved preference, the built-in default remains `opencode-go/deepseek-v4.1-flash` with `max`. Call `ds_check` with the same overrides and workspace before first use of that configuration; its `ok` means configured and listed, not verified credentials or inference. - Follow-ups, queued messages and forks preserve their own stored selection, including after a global-default change. Start a new worker when the task explicitly changes model. Never silently switch provider or model after a failure or quota limit. -- Both providers use OpenCode as the agent runtime; the official provider uses separate DeepSeek API credentials. Read [model selection and setup](references/model-selection.md) for precedence, authentication, CLI examples or missing models. Keep keys out of prompts and manifests. +- Both external providers use OpenCode as the agent runtime; the official provider uses separate DeepSeek API credentials. Read [worker lane, model selection and setup](references/model-selection.md) for native/external boundaries, precedence, authentication, CLI examples or missing models. Keep keys out of prompts and manifests. ## Route and delegate Choose the route from how much judgment, risk, and exploration/verification burden the task carries — not from line counts or file counts. This is a decision guide for Codex’s situational judgment, not an automatic classifier, and an explicit user request to delegate or to stay direct overrides it. - **Small (direct):** a known, clearly understood change that takes a few minutes and needs neither broad discovery nor risky design. Handle it in Codex directly; briefing and reviewing a worker would cost more than the edit. Report the route as direct. -- **Medium (prefer delegation):** mechanical implementation, or a larger amount of testing, with clear and objective acceptance criteria. Prefer one persistent worker, carrying the design decisions and exact checks in `task_spec`. -- **Large or high-risk (delegated labor, queen-owned design):** state machines, concurrency, permissions, transactions, migrations, or changes where a wrong invariant, interface or failure semantic is expensive. The labor may be delegated, but Codex must first decide the design, interface, data flow, invariants, failure semantics and acceptance examples; then Codex reviews the actual diff and runs independent verification. Never accept a worker’s self-report or passing self-tests as acceptance. +- **Medium (prefer delegation):** mechanical implementation, or a larger amount of testing, with clear and objective acceptance criteria. Prefer native `gpt-5.6-luna` for one bounded, low-risk subtask when the host supports it. Use the persistent OpenCode worker when the user selects DeepSeek/GLM, an applicable worker already exists, or the work benefits from an isolated worktree, persistent correction loop, forks, queued follow-ups, usage reporting, or persisted `task_spec` verification. +- **Large or high-risk (delegated labor, queen-owned design):** state machines, concurrency, permissions, transactions, migrations, or changes where a wrong invariant, interface or failure semantic is expensive. Bounded labor may go to either lane, but Codex must first decide the design, interface, data flow, invariants, failure semantics and acceptance examples; then Codex reviews the actual diff and runs independent verification. Never accept any delegate’s self-report or passing self-tests as acceptance. - Hand off a coherent behavior or investigation with acceptance criteria, rather than one function or tool command per turn. -- Prefer one persistent worker. Avoid additional queen-model workers for ordinary implementation. Reuse the worker for related corrections; use a fresh session for unrelated tasks. +- Prefer one lane and one delegate for a coherent task. Keep Luna prompts bounded and reuse an applicable native subagent only while its task and selected model remain coherent. Reuse a persistent OpenCode worker for related corrections; use a fresh worker for unrelated tasks. - Before spawning, read applicable repository instructions and the critical call chain. Codex must decide the interface, data flow, invariants, failure behavior and acceptance examples that determine correctness. Leave routine implementation and broader discovery to the worker. Do not substitute a vague task restatement for a design, or prewrite every implementation detail. -- Send a `task_spec` with the design decisions, observable acceptance criteria and exact checks selected by Codex. Keep it grounded in existing contracts; do not add speculative constraints. For an unfamiliar subsystem, first request a bounded discovery report from the same worker, then resolve the consequential decisions before implementation. -- Use concrete `scope_paths`, task-relevant `required_reads` (named sections for large files), and a few non-secret `critical_constraints`. Send paths and observable requirements, not full source files or conversation history. -- Prefer `workspace_mode="worktree"` for work starting from HEAD. Use `current` when the worker needs uncommitted changes, after checking status and protecting unrelated edits. Explain that it edits the shared tree. +- For the OpenCode lane, send a `task_spec` with the design decisions, observable acceptance criteria and exact checks selected by Codex. Keep it grounded in existing contracts; do not add speculative constraints. For an unfamiliar subsystem, first request a bounded discovery report from the same worker, then resolve the consequential decisions before implementation. +- For the OpenCode lane, use concrete `scope_paths`, task-relevant `required_reads` (named sections for large files), and a few non-secret `critical_constraints`. Send paths and observable requirements, not full source files or conversation history. Prefer `workspace_mode="worktree"` for work starting from HEAD; use `current` when uncommitted changes are required, after checking status and protecting unrelated edits. ## Keep the queen loop small +### Native Luna lane + +1. Use the host-native subagent tool (`spawn_agent` when available) with `model="gpt-5.6-luna"`, the requested reasoning effort, a bounded objective, scope, design decisions and observable acceptance criteria. This is Skill-level orchestration, not an MCP plugin call. Do not send it provider credentials or use any `ds_*` tool. +2. Wait for that native subagent through the host's native coordination mechanism. Review its actual filesystem changes and relevant surrounding code; its final report is not acceptance. +3. Run independent checks selected by Codex. Send a focused follow-up to the same subagent for a coherent correction when appropriate, or take over after stopping it. Model changes require a new subagent. + +### OpenCode worker lane + 1. Check prerequisites once per environment and selected model configuration. Spawn with the objective, allowed modules, instruction routing and `task_spec`. Ask the worker to implement, self-test and fix ordinary failures continuously before returning one concise handoff. It must escalate a contradictory design, missing consequential decision or out-of-scope requirement rather than guessing. 2. Keep the agent ID, worktree, cursor and instruction manifest. Use `ds_wait_agent(return_on="actionable", timeout_ms=55000)` with the latest cursor. Ordinary timeouts require another bounded wait, not a new diagnosis or transcript replay. Handle real attention events within existing authorization. The host still has a 65-second tool timeout: this workflow does not promise background completion notifications or zero polling. 3. Once the worker is idle, call `ds_verify_agent` to run only the checks preselected by Codex. Poll the same verification job when it is running; do not request `rerun` merely to read its result. Inspect does not execute checks. Read the current patch-bound evidence and actual diff, compare instruction acknowledgements, and examine relevant surrounding code. Actual check success is evidence, not Codex acceptance; stale, unavailable, failed, timed-out or cancelled verification is not a pass. @@ -48,11 +60,11 @@ Choose the route from how much judgment, risk, and exploration/verification burd Use `ds_inspect_agent` with `detail="full"` only for missing/truncated evidence, errors, instruction acknowledgements or a specific diagnosis; `include_diff=true` explicitly requests the diff. Never echo large logs into queen messages just to summarize them again. Do not infer success from idle, a timeout or unavailable usage. -The worker must not commit, push, merge, deploy, modify production data, expose secrets or discard unrelated edits without the user's authorization for that action. If delegation is unavailable, report the limitation and continue locally when authorized. +Neither native Luna nor an OpenCode worker may commit, push, merge, deploy, modify production data, expose secrets or discard unrelated edits without the user's authorization for that action. If the selected lane is unavailable, report the limitation and continue locally when authorized; do not silently route to the other lane. ## Measure the intended outcome -Optimize high-quality-model consumption while preserving design and review quality. Report Codex input, cached input, output and total separately from worker usage. When measuring, distinguish planning, coordination, review and takeover phases; include failed attempts and all correction rounds. Codex noncached input plus output is a useful proxy, not a subscription-quota or billing conversion. Keep model/effort unchanged when testing the workflow. Tiny tasks may route directly and must be reported as direct. +Optimize high-quality-model consumption while preserving design and review quality. Report Codex controller, native Luna, and external worker usage separately when those counters are available. When measuring, distinguish planning, coordination, review and takeover phases; include failed attempts and all correction rounds. API list pricing does not establish Codex subscription or quota consumption. Codex noncached input plus output is a useful proxy, not a subscription-quota or billing conversion. Keep lane/model/effort unchanged when testing the workflow. Tiny tasks may route directly and must be reported as direct. Benchmark or live inference runs require the user's task to include them. Do not start extra comparisons merely to validate a Skill update. Local mocked/unit checks are sufficient to report implementation correctness; they do not prove token savings. diff --git a/plugins/deepseek-code-agent/skills/deepseek-coding-delegation/references/model-selection.md b/plugins/deepseek-code-agent/skills/deepseek-coding-delegation/references/model-selection.md index 7083e8e..56568e8 100644 --- a/plugins/deepseek-code-agent/skills/deepseek-coding-delegation/references/model-selection.md +++ b/plugins/deepseek-code-agent/skills/deepseek-coding-delegation/references/model-selection.md @@ -1,6 +1,6 @@ -# Worker models and authentication +# Worker lanes, models and authentication -Read this when selecting a model, configuring authentication or diagnosing a missing model. The `ds_*` names and plugin ID remain unchanged for compatibility. +Read this when selecting the Codex-native Luna lane or an OpenCode model, configuring external authentication, or diagnosing a missing model. The `ds_*` names and plugin ID remain unchanged for compatibility. ## Natural-language requests and scope @@ -8,16 +8,26 @@ Use normal language with Codex; it translates the request into the plugin's type | Request | Meaning | |---|---| +| “这段实现用 Codex 原生 GPT-5.6 Luna,推理开到 medium” | Create a task-scoped native `gpt-5.6-luna` subagent; do not use `ds_*`, OpenCode or external credentials | +| “不要用外部 Provider,这次改用原生 Luna,推理拉满” | Create a task-scoped native `gpt-5.6-luna / max` subagent; fail explicitly if unavailable | | “使用 OpenCode Go 的 GLM 5.3 Flash,推理开到最大” | Save `opencode-go / glm-5.3-flash / max` as this machine's default | | “这次用官方 DeepSeek Flash,推理最高” | Override the current task's new workers with `deepseek / deepseek-flash / max`; keep the machine default | | “当前默认用什么模型?” | Read and report the stored/effective default | | “恢复插件原来的默认模型” | Reset the machine default to Go DeepSeek Flash/max | -“最大 / 最高 / 拉满 / max” maps to `max`; “高 / high” to `high`; “低 / low” to `low`; “默认档位 / 自动” to `null`. Distinguish a maximum request from `high`. Map provider/model aliases to exact catalog IDs and validate them. If a requested variant is unsupported, report available variants rather than silently lowering it. +“最大 / 最高 / 拉满 / max” maps to `max`; “高 / high” to `high`; “中 / medium” to `medium`; “低 / low” to `low`; “默认档位 / 自动” removes an explicit override. Distinguish a maximum request from `high`. Validate the selected lane's actual model and effort support. If unavailable, report it rather than silently changing effort, model or lane. -“以后 / 全局 / 设为默认 / 所有新执行者” expresses a persistent default. “这次 / 当前任务” expresses a task override. Preserve any established user scope. By the chosen interaction convention, a standalone model/effort-setting request without a scope is a machine-default request; a model choice attached to a specific coding task is task-local unless the user says otherwise. The global setting covers this plugin's new workers on this machine, including future Codex tasks. It does not change the Codex controller model or rewrite existing workers. +For the OpenCode lane, “以后 / 全局 / 设为默认 / 所有新执行者” expresses a persistent plugin-worker default, while “这次 / 当前任务” expresses a task override. A standalone external model/effort request without a scope is a machine-default request. That default covers only this plugin's future OpenCode workers; it does not change the Codex controller or native Luna. -## Persistent defaults +The plugin cannot persist a Codex-native model default. A Luna request applies to the requested task or an explicitly established preference within the current Codex thread. Do not store Luna through `ds_model_defaults` or claim it will carry into future Codex tasks. + +## Codex-native Luna lane + +`gpt-5.6-luna` is a Codex-native subagent model, not an OpenCode catalog model or a third plugin provider. Select it through Codex's native subagent capability and pass the requested reasoning effort there. Do not call `ds_check`, `ds_spawn_agent`, or `ds_model_defaults`; do not start OpenCode; and do not read or forward `DEEPSEEK_API_KEY` or other external credentials. + +The current host determines whether Luna and the requested effort are available. When unavailable, explain the limitation and keep the user's lane choice intact instead of falling back silently. A native subagent retains the model chosen when it was created; create a new subagent to change models. Codex still owns task design, authorization, diff review, independent verification and acceptance. + +## OpenCode worker persistent defaults Use `ds_model_defaults` with `action="get"`, `"set"` or `"reset"`. On `set`, pass the intended provider/model/variant and optional workspace for catalog validation. Report the resolved selection and scope after saving. `get` reports the effective selection, whether it is saved, and the local settings path. `reset` restores the built-in selection even if the saved file is invalid. @@ -35,7 +45,7 @@ node scripts/model-defaults.mjs reset Prefer natural language for ordinary use; these commands are useful for scripts, troubleshooting or verifying the saved values. -## Selection +## OpenCode worker selection Both `ds_check` and `ds_spawn_agent` accept `provider`, `model` and `variant`. `model` is the bare API model ID, without a provider prefix. `ds_check` also accepts `workspace` to read the same project configuration as the planned worker. @@ -86,6 +96,7 @@ If the provider is disconnected, connect the chosen account. If a model is missi ## Sources +- [OpenAI GPT-5.6 Luna model](https://developers.openai.com/api/docs/models/gpt-5.6-luna) - [OpenCode Go models and IDs](https://opencode.ai/docs/go/) - [OpenCode provider authentication](https://opencode.ai/docs/providers/#deepseek) - [OpenCode model configuration and variants](https://opencode.ai/docs/models/) diff --git a/plugins/deepseek-code-agent/tests/mcp.test.mjs b/plugins/deepseek-code-agent/tests/mcp.test.mjs index 5807f8c..adec956 100644 --- a/plugins/deepseek-code-agent/tests/mcp.test.mjs +++ b/plugins/deepseek-code-agent/tests/mcp.test.mjs @@ -58,11 +58,11 @@ after(() => { void fs.rm(stateRoot, { recursive: true, force: true }); }); -test("MCP initializes and lists tools", async () => { +test("MCP initializes and keeps native Luna outside the external provider schema", async () => { const result = await request("tools/list"); assert.ok(result.tools.length >= 10); assert.ok(result.tools.some((tool) => tool.name === "ds_spawn_agent")); - for (const name of ["ds_check", "ds_spawn_agent"]) { + for (const name of ["ds_check", "ds_spawn_agent", "ds_model_defaults"]) { const schema = result.tools.find((tool) => tool.name === name).inputSchema; assert.deepEqual(schema.properties.provider.enum, ["opencode-go", "deepseek"]); assert.deepEqual(schema.properties.variant.type, ["string", "null"]);