@namewta/speculo 0.7.0 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -6
- package/dist/src/cli.js +12 -0
- package/dist/src/cli.js.map +1 -1
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +56 -58
- package/dist/src/index.js.map +1 -1
- package/dist/src/migrations.d.ts +23 -0
- package/dist/src/migrations.js +470 -0
- package/dist/src/migrations.js.map +1 -0
- package/package.json +2 -2
- package/template/.speculo/README.md +13 -6
- package/template/canonical/canonical-specdev-engineering-cognitive-mentor.md +178 -0
- package/template/canonical/canonical-specdev-goal-plan.md +386 -74
- package/template/canonical/canonical-specdev-grill-with-docs.md +178 -0
- package/template/canonical/canonical-specdev-spec.md +178 -0
- package/template/canonical/canonical-specdev-tickets.md +247 -21
- package/template/canonical/canonical-specdev-wayfinder.md +178 -0
- package/template/commands/migrate-runtime-state.md +43 -0
- package/template/skills/github-npm-ops/references/preflight-checklist.md +1 -1
- package/template/skills/migrate-runtime-state/SKILL.md +93 -0
- package/template/skills/migrate-runtime-state/references/migration-contract.md +58 -0
- package/template/skills/migrate-runtime-state/scripts/migrate-runtime-state.mjs +545 -0
- package/template/skills/optimize-codex-config/SKILL.md +81 -0
- package/template/skills/optimize-codex-config/references/configuration-contract.md +103 -0
- package/template/skills/optimize-codex-config/references/troubleshooting.md +79 -0
- package/template/skills/optimize-codex-config/scripts/audit-codex-config.mjs +747 -0
- package/template/workflows/specdev/I-implement/I-implement.md +11 -10
- package/template/workflows/specdev/I-implement/delegated-evidence-template.md +2 -1
- package/template/workflows/specdev/I-implement/execution-preflight.md +5 -3
- package/template/workflows/specdev/I-implement/merge-conflict-protocol.md +6 -5
- package/template/workflows/specdev/I-init-setup/I-init-setup.md +1 -1
- package/template/workflows/specdev/INDEX.md +13 -9
- package/template/workflows/specdev/P-goal-plan/P-goal-plan.md +27 -18
- package/template/workflows/specdev/P-goal-plan/completion-control.md +3 -3
- package/template/workflows/specdev/P-goal-plan/delegated-execution-template.md +6 -4
- package/template/workflows/specdev/P-goal-plan/delegated-execution.md +13 -7
- package/template/workflows/specdev/P-goal-plan/goal-plan-template.md +11 -2
- package/template/workflows/specdev/P-goal-plan/orchestration-protocol.md +7 -3
- package/template/workflows/specdev/P-goal-plan/planning-modes.md +23 -8
- package/template/workflows/specdev/P-goal-plan/workspace-execution-template.md +24 -0
- package/template/workflows/specdev/common/README.md +2 -2
- package/template/workflows/specdev/common/rules/change-completion.md +3 -2
- package/template/workflows/specdev/common/rules/path-ownership.md +2 -2
- package/template/workflows/specdev/common/schemas/change-status.schema.json +178 -0
- package/template/workflows/specdev/common/schemas/goal-plan.schema.json +10 -0
- package/template/workflows/specdev/common/skills/dev-worktree/SKILL.md +11 -11
- package/template/workflows/specdev/common/skills/dev-worktree/references/create.md +19 -4
- package/template/workflows/specdev/common/skills/dev-worktree/references/finalize.md +12 -5
- package/template/workflows/specdev/common/skills/subagent-delivery/SKILL.md +4 -3
- package/template/workflows/specdev/common/skills/subagent-delivery/references/external-web-subagent.md +1 -1
- package/template/workflows/specdev/common/skills/subagent-delivery/references/native-subagent.md +2 -3
- package/template/workflows/specdev/common/tools/validate-specdev.mjs +218 -5
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# Codex Configuration Contract
|
|
2
|
+
|
|
3
|
+
在设计或修改 `config.toml`、`auth.json`、模型供应商、权限、Agent、MCP、Hook 或历史配置时完整应用本契约。配置键会随 Codex 版本变化;以已安装 CLI 和当前 [Configuration Reference](https://learn.chatgpt.com/docs/config-file/config-reference) 为最终事实源。
|
|
4
|
+
|
|
5
|
+
## 1. 配置归属与事实优先级
|
|
6
|
+
|
|
7
|
+
1. 用户级配置位于 `$CODEX_HOME/config.toml`;profile 文件位于同一目录并通过 `--profile` 选择。
|
|
8
|
+
2. 受信任项目可以使用 `.codex/config.toml` 覆盖项目设置,但 provider、auth、host metadata、通知、profile 选择和 telemetry 等机器级键会被忽略,必须留在用户级配置。
|
|
9
|
+
3. 先读取现有配置、`codex doctor --json`、`codex features list` 和 `codex debug models --bundled`,再核对当前官方参考。API 模型网页上的最大上下文不是本机 Codex 目录的替代品。
|
|
10
|
+
4. 只更改与目标直接相关的键。MCP、Hook、profile、插件、历史兼容项和未知集成默认原样保留,直到有证据证明无效且用户确认删除。
|
|
11
|
+
|
|
12
|
+
## 2. 模型与推理
|
|
13
|
+
|
|
14
|
+
- 从已安装模型目录选择 model,并确认所选 reasoning effort 受支持。常规工作可以从 `medium` 或现有值开始;`high`、`xhigh` 和更高等级只在质量收益能够覆盖延迟与成本时采用。
|
|
15
|
+
- `plan_mode_reasoning_effort` 独立于普通 `model_reasoning_effort`;未设置时使用 Codex 内置 Plan preset。
|
|
16
|
+
- 仅在自定义模型目录确实需要时设置 `model_context_window`。不得为了绕过 compaction 或代理限制而夸大它。
|
|
17
|
+
- `model_auto_compact_token_limit` 是触发阈值,不是服务端请求体限制。降低它会更早、更频繁地压缩,并可能改变成本和上下文质量。
|
|
18
|
+
- `model_auto_compact_token_limit_scope` 默认是 `total`;只有理解 carried prefix 行为后才选择 `body_after_prefix`。
|
|
19
|
+
|
|
20
|
+
## 3. 第三方 Responses 供应商
|
|
21
|
+
|
|
22
|
+
Codex 当前自定义供应商只支持 `responses` wire API。供应商必须兼容 Codex 实际使用的 Responses 请求、SSE 输出、工具项和 compaction 路径;仅兼容 Chat Completions 不够。
|
|
23
|
+
|
|
24
|
+
使用存储在 `auth.json` 的 OpenAI-style API key 时,可以采用:
|
|
25
|
+
|
|
26
|
+
```toml
|
|
27
|
+
model = "gpt-5.6-sol"
|
|
28
|
+
model_provider = "third-party"
|
|
29
|
+
model_reasoning_effort = "high"
|
|
30
|
+
plan_mode_reasoning_effort = "xhigh"
|
|
31
|
+
cli_auth_credentials_store = "file"
|
|
32
|
+
|
|
33
|
+
[model_providers.third-party]
|
|
34
|
+
name = "Third Party Responses"
|
|
35
|
+
base_url = "https://relay.example/api-root"
|
|
36
|
+
wire_api = "responses"
|
|
37
|
+
requires_openai_auth = true
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
`base_url` 必须是供应商声明的 API root。先确认 Codex 最终请求路径,不能机械添加或删除 `/v1`。生产连接优先 HTTPS;HTTP 会在主机到中转之间明文传输凭据和内容。
|
|
41
|
+
|
|
42
|
+
供应商使用独立环境变量时改用:
|
|
43
|
+
|
|
44
|
+
```toml
|
|
45
|
+
[model_providers.third-party]
|
|
46
|
+
name = "Third Party Responses"
|
|
47
|
+
base_url = "https://relay.example/api-root"
|
|
48
|
+
wire_api = "responses"
|
|
49
|
+
env_key = "THIRD_PARTY_API_KEY"
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
动态 token 可以使用 `[model_providers.<id>.auth]` 下的 command、args、cwd、timeout 和 refresh interval。`auth`、`env_key`、`experimental_bearer_token` 与 `requires_openai_auth` 是互斥认证路线;每个供应商只保留一条。
|
|
53
|
+
|
|
54
|
+
仅在证据要求时调整 `request_max_retries`、`stream_max_retries` 或 `stream_idle_timeout_ms`。重试不能修复稳定的 401、403、404 或 413。
|
|
55
|
+
|
|
56
|
+
## 4. 认证存储
|
|
57
|
+
|
|
58
|
+
- `cli_auth_credentials_store = "file"` 正式选择 `$CODEX_HOME/auth.json`;`keyring` 选择系统钥匙串;`auto` 由 Codex 决定。三者是偏好,不是安全等级排序。
|
|
59
|
+
- 文件模式下,验证 `auth.json` 是普通文件、权限为 `0600` 且 `codex doctor --json` 报告认证可用。不要读取、打印、diff 或记录其中的 key。
|
|
60
|
+
- 保留已安装 Codex 创建并验证过的 JSON schema。需要重新登录时优先通过 stdin 使用 `codex login --with-api-key`;手工修改只有在当前 schema 已被可靠确认时进行。
|
|
61
|
+
- 自定义 provider 的 command-backed token 和 `env_key` 不应同时把同一 secret 写入 `auth.json` 或 `config.toml`。
|
|
62
|
+
|
|
63
|
+
## 5. 权限、沙箱与网络
|
|
64
|
+
|
|
65
|
+
一个保守、可交互的本机基线是:
|
|
66
|
+
|
|
67
|
+
```toml
|
|
68
|
+
approval_policy = "on-request"
|
|
69
|
+
approvals_reviewer = "auto_review"
|
|
70
|
+
sandbox_mode = "workspace-write"
|
|
71
|
+
|
|
72
|
+
[sandbox_workspace_write]
|
|
73
|
+
network_access = false
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
这只是安全起点,不是固定默认。`approval_policy = "never"` 和 `sandbox_mode = "danger-full-access"` 适合用户明确接受风险的受控环境;不要通过 profile 名称暗示它们更安全。
|
|
77
|
+
|
|
78
|
+
`default_permissions` 与 `sandbox_mode` / `[sandbox_workspace_write]` 是两套选择,不能混合。网络访问只按实际工具需求开放;第三方模型请求由 Codex host 发出,不等同于给沙箱内命令开放任意网络。
|
|
79
|
+
|
|
80
|
+
## 6. Agent、MCP、Hook 与历史
|
|
81
|
+
|
|
82
|
+
Agent 配置先确认当前 CLI 支持的键:
|
|
83
|
+
|
|
84
|
+
```toml
|
|
85
|
+
[agents]
|
|
86
|
+
enabled = true
|
|
87
|
+
max_concurrent_threads_per_session = 4
|
|
88
|
+
default_subagent_model = "gpt-5.6-terra"
|
|
89
|
+
default_subagent_reasoning_effort = "medium"
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
并发数由 CPU、内存、供应商速率限制和成本共同决定。不要假定四个线程适合所有机器或接口。
|
|
93
|
+
|
|
94
|
+
- 对每个 MCP 逐项验证 command/path、启动、tool discovery 和审批策略;不因某个 MCP 失败而清理其他 MCP。
|
|
95
|
+
- Hook 按事件和集成所有者保留。两个 Hook 调用不同集成时不是重复;只有调用链、输入和副作用等价时才合并。
|
|
96
|
+
- `history.persistence` 和 `history.max_bytes` 由隐私、恢复需求和磁盘预算决定。修改前验证旧会话与数据库兼容。
|
|
97
|
+
- 审计期间 `config.toml` 指纹变化或目标文件存在已证明的可写句柄时,先关闭写入来源并重新审计;进程名本身不是 writer 证据。修改任务无法取得精确 writer 观测时保持 blocked,且不得覆盖竞争写入。
|
|
98
|
+
|
|
99
|
+
## 7. 确认包与写入契约
|
|
100
|
+
|
|
101
|
+
确认包必须列出当前值、目标值、理由、脱敏 diff、保留项、备份路径、验证和回滚。对每个 secret 只写 `<redacted>` 或“存在/不存在”。
|
|
102
|
+
|
|
103
|
+
确认后在目标目录创建权限正确的临时文件,完成 TOML/JSON 和 Codex 加载验证后原子 rename。写入前再次比较哈希、大小和 mtime;任一变化都使原确认失效。验证失败时恢复备份并重复验证,不留下部分应用状态。
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Codex Provider Troubleshooting
|
|
2
|
+
|
|
3
|
+
当 Codex 出现 HTTP 状态码、SSE、超时或 compaction 故障时完整应用本手册。官方事实分别来自 [Configuration Reference](https://learn.chatgpt.com/docs/config-file/config-reference)、[Authentication](https://learn.chatgpt.com/docs/auth) 和 [Compaction](https://developers.openai.com/api/docs/guides/compaction)。
|
|
4
|
+
|
|
5
|
+
## 1. 证据梯度
|
|
6
|
+
|
|
7
|
+
按以下顺序收集并停止在能够唯一归因的位置:
|
|
8
|
+
|
|
9
|
+
1. 已安装 Codex 版本、active provider、认证模式和配置加载结果;
|
|
10
|
+
2. 错误状态、响应 content type、代理签名和最终 path 的脱敏形态;
|
|
11
|
+
3. 错误前最近一次 `last_token_usage` 与 `model_context_window`;
|
|
12
|
+
4. 同一接口的最小 Responses 请求、SSE 行为和重试一致性;
|
|
13
|
+
5. 只有具备服务器权限时才查看反向代理与上游日志。
|
|
14
|
+
|
|
15
|
+
报告原始事实和推断的边界。不得用接口 URL、API key、提示词或工具输出充当证据附件。
|
|
16
|
+
|
|
17
|
+
## 2. 状态路由
|
|
18
|
+
|
|
19
|
+
| 症状 | 主要归属 | 首要检查 | 无效做法 |
|
|
20
|
+
|---|---|---|---|
|
|
21
|
+
| 401 | 认证 | provider 选择、认证路线、header 格式、key 是否属于该服务 | 增加 HTTP 重试 |
|
|
22
|
+
| 403 | 授权或策略 | 模型权限、账户策略、代理 ACL、来源限制 | 重写 prompt |
|
|
23
|
+
| 404 | endpoint / wire API | `base_url`、最终 `/responses` path、是否错误叠加 `/v1`、Responses 兼容性 | 更换 reasoning effort |
|
|
24
|
+
| 413 | 供应商或网关,待证据归因 | 响应类型、HTML/Server header、请求体边界、代理 location 继承 | 提高模型上下文或反复重试 |
|
|
25
|
+
| 429 | 服务限流 | RPM/TPM、并发 Agent、retry-after、账户额度 | 无限并发重试 |
|
|
26
|
+
| SSE 中断 | 流式传输 | content type、代理 buffering、idle timeout、上游心跳 | 把稳定 4xx 当瞬时网络错误 |
|
|
27
|
+
| 超时 | 客户端、代理或模型 | 发生阶段、首 token 时间、idle/total timeout、服务日志 | 同时扩大所有 timeout |
|
|
28
|
+
|
|
29
|
+
## 3. 413 与 remote compact
|
|
30
|
+
|
|
31
|
+
Standalone compaction 会发送完整上下文窗口;长会话因此可能产生远大于普通请求的 JSON body。`/responses/compact` 返回的窗口是后续请求的权威上下文,不应自行裁剪。
|
|
32
|
+
|
|
33
|
+
自动审计只有在 413 响应带有 Nginx、Envoy、HAProxy、Cloudflare、Varnish 等明确代理签名时,才把主要归属标为 `external_proxy_body_limit`。供应商 JSON 413 或没有代理签名的响应保持 `request_body_limit_unattributed`,不得直接交接给代理管理员。
|
|
34
|
+
|
|
35
|
+
满足以下证据时,才把代理限制标记为已确认并完成服务器交接:
|
|
36
|
+
|
|
37
|
+
- Codex 报告 remote compact 或 `/responses` 请求返回 413;
|
|
38
|
+
- 响应是 Nginx 等代理生成的 HTML,而不是模型服务 JSON;
|
|
39
|
+
- 较小请求能进入上游,超过稳定字节边界后始终 413。
|
|
40
|
+
|
|
41
|
+
Nginx 的 `client_max_body_size` 默认是 `1m`。只有实测边界或 `nginx -T` 能证明配置时,才把“1 MiB”写成确定结论;否则写成最可能原因。
|
|
42
|
+
|
|
43
|
+
本机临时缓解按优先级为:
|
|
44
|
+
|
|
45
|
+
1. 生成脱敏 handoff 后开启新会话;
|
|
46
|
+
2. 依据失败时 token 规模试验性降低 `model_auto_compact_token_limit`,并说明压缩频率、成本和上下文质量代价;
|
|
47
|
+
3. 仅当当前 `codex features list` 确认该 feature 存在时,临时关闭 `remote_compaction_v2` 作为诊断,并验证本地压缩是否可用。
|
|
48
|
+
|
|
49
|
+
不得把 `model_context_window` 改成 API 模型网页的最大值来解决 413;更晚触发压缩通常会制造更大的 body。
|
|
50
|
+
|
|
51
|
+
服务器交接建议包含:在实际命中的 `server` 或 `/responses` location 设置足够的 `client_max_body_size`(当前约 272k Codex 上下文可从 `32m` 起步)、用 `nginx -T` 确认继承、`nginx -t` 校验并平滑 reload。SSE 仍异常时再单独检查 buffering 与 timeout。Skill 只交接,不执行这些服务器动作。
|
|
52
|
+
|
|
53
|
+
## 4. Compaction 判定
|
|
54
|
+
|
|
55
|
+
- 以 `codex debug models --bundled` 的 active model 窗口为本机事实,不从 API 产品页反推 Codex 客户端阈值。
|
|
56
|
+
- `total_token_usage` 是会话累计量;诊断某次失败应使用此前最近一次 `last_token_usage`。
|
|
57
|
+
- `model_auto_compact_token_limit` 未设置时使用模型默认;`total` 与 `body_after_prefix` 的计数语义不同,变更时必须记录原值。
|
|
58
|
+
- 远程压缩失败但普通请求成功,优先比较 body 大小、compact 能力和代理路径,不重新认证全部配置。
|
|
59
|
+
|
|
60
|
+
## 5. SSE 与超时
|
|
61
|
+
|
|
62
|
+
先确认响应是 `text/event-stream` 且事件格式与 Responses API 兼容。把“连接前超时”“首 token 超时”“流式 idle 超时”分开记录;只调整命中的那一层。
|
|
63
|
+
|
|
64
|
+
`stream_idle_timeout_ms` 和 `stream_max_retries` 属于 provider 设置。代理层需要管理员核对 streaming buffering、read timeout 和连接关闭行为;本机重试仅适用于已证明的瞬时中断。
|
|
65
|
+
|
|
66
|
+
## 6. 交付格式
|
|
67
|
+
|
|
68
|
+
每个故障报告固定包含:
|
|
69
|
+
|
|
70
|
+
```text
|
|
71
|
+
classification: <local_config|authentication|provider_contract|external_proxy|upstream_service>
|
|
72
|
+
evidence: <status, content type/proxy signature, token metadata, reproducible boundary>
|
|
73
|
+
local_action: <none or confirmed mitigation>
|
|
74
|
+
tradeoff: <quality/cost/frequency/security impact>
|
|
75
|
+
external_handoff: <owner, exact check, success condition>
|
|
76
|
+
verification: <command, exit code, redacted result>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
只有证据支持的层级可以标记为已解决;其余保持 blocker 或 unknown。
|