claude2codex 0.3.4 → 0.3.6

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 CHANGED
@@ -143,6 +143,11 @@ The workflow reaches Claude in two layers. Neither needs extra installation.
143
143
 
144
144
  The MCP server handles the workflow protocol. Your project files only need to carry **project-specific context** — don't repeat what the server already provides.
145
145
 
146
+ To see exactly what the server already provides, read the verbatim prompts (generated from the code, so they never drift):
147
+
148
+ - **[What Claude sees](https://github.com/PrestoOverture/c2c/blob/main/prompts/what-claude-sees.md)** — server instructions, the `c2c-workflow` Prompt, and tool descriptions. Read before writing `CLAUDE.md`.
149
+ - **[What Codex sees](https://github.com/PrestoOverture/c2c/blob/main/prompts/what-codex-sees.md)** — the protocol, rendered Goal/Delta Contracts, and the thread-goal objective. Read before writing `AGENTS.md`.
150
+
146
151
  **`CLAUDE.md`** (for Claude — the architect/reviewer):
147
152
 
148
153
  ```markdown
package/README.zh-CN.md CHANGED
@@ -157,6 +157,11 @@ npx claude2codex
157
157
 
158
158
  MCP 服务器负责工作流协议。你的项目文件只需要放**项目特有的上下文**——不要重复服务器已经提供的内容。
159
159
 
160
+ 服务器具体提供了哪些内容,可以直接看原文(由代码生成,与实际发送的内容始终一致,英文):
161
+
162
+ - **[What Claude sees](https://github.com/PrestoOverture/c2c/blob/main/prompts/what-claude-sees.md)**:服务器 instructions、`c2c-workflow` Prompt 和工具描述。写 `CLAUDE.md` 之前先读这份。
163
+ - **[What Codex sees](https://github.com/PrestoOverture/c2c/blob/main/prompts/what-codex-sees.md)**:协议、渲染后的 Goal/Delta Contract 和 thread-goal objective。写 `AGENTS.md` 之前先读这份。
164
+
160
165
  `CLAUDE.md`(给 Claude——架构师/审查者):
161
166
 
162
167
  ```markdown
package/dist/server.js CHANGED
@@ -262,7 +262,7 @@ var CodexAppServer = class {
262
262
  */
263
263
  async initialize() {
264
264
  const result = await this.request("initialize", {
265
- clientInfo: { name: "claude2codex", title: "Claude\u2194Codex Contract Bridge", version: "0.3.4" },
265
+ clientInfo: { name: "claude2codex", title: "Claude\u2194Codex Contract Bridge", version: "0.3.6" },
266
266
  capabilities: { experimentalApi: true }
267
267
  });
268
268
  this.notify("initialized", {});
@@ -714,6 +714,10 @@ async function runAttempt(job, opts, timeoutMs) {
714
714
  }
715
715
  function finalize(state, error) {
716
716
  clearStallTimer();
717
+ if (state === "done" && job.turns === 0) {
718
+ state = "error";
719
+ error = "job ended without running a turn";
720
+ }
717
721
  finish(job, state, client, error);
718
722
  }
719
723
  function handleNotification(method, params) {
@@ -767,7 +771,7 @@ async function runAttempt(job, opts, timeoutMs) {
767
771
  tokens_used: job.goal?.tokensUsed ?? null
768
772
  });
769
773
  progress("goal_updated", `goal status=${job.goal?.status ?? "unknown"}`);
770
- if (job.goal?.status && TERMINAL_GOAL_STATUSES.has(job.goal.status) && !activeTurn) {
774
+ if (job.goal?.status && TERMINAL_GOAL_STATUSES.has(job.goal.status) && !activeTurn && job.turns > 0) {
771
775
  finalize("done");
772
776
  settle();
773
777
  }
@@ -858,11 +862,11 @@ async function runAttempt(job, opts, timeoutMs) {
858
862
  if (!job.threadId) throw new Error(`could not determine thread id from ${JSON.stringify(threadRes).slice(0, 300)}`);
859
863
  store.save(job);
860
864
  log(job, "thread", `thread ${job.threadId} ${opts.resumeThreadId ? "resumed" : "started"}`);
861
- if (opts.objective) {
865
+ if (opts.objective || opts.resumeThreadId) {
862
866
  try {
863
867
  const goalRes = await client.request("thread/goal/set", {
864
868
  threadId: job.threadId,
865
- objective: opts.objective,
869
+ ...opts.objective ? { objective: opts.objective } : { status: "active" },
866
870
  ...opts.tokenBudget ? { tokenBudget: opts.tokenBudget } : {}
867
871
  });
868
872
  job.goalSet = true;
@@ -968,7 +972,7 @@ var SERVER_INSTRUCTIONS = `When the user asks to delegate work to Codex (or to u
968
972
  If a Codex job itself fails (error, 0 tokens, no handoff), report it and wait; don't implement the task yourself unless the user explicitly asks.
969
973
  Full formats: the c2c-workflow prompt.`;
970
974
  var server = new McpServer(
971
- { name: "c2c-codex", version: "0.3.4" },
975
+ { name: "c2c-codex", version: "0.3.6" },
972
976
  { instructions: SERVER_INSTRUCTIONS }
973
977
  );
974
978
  var reasoningEffort = z.enum(["low", "medium", "high", "xhigh", "max", "ultra"]);
@@ -1038,8 +1042,8 @@ server.registerTool(
1038
1042
  description: "Start a Codex implementation job for a Goal Contract. Sets the contract as a Codex thread goal (the /goal loop keeps Codex iterating until the objective is achieved or the token budget is hit) and sends the full contract as the first turn. Returns a job_id immediately; poll codex_status, then fetch codex_result when done. Language-agnostic: verification commands come from the contract's Success Conditions, not from this server.",
1039
1043
  inputSchema: {
1040
1044
  goal: z.string().min(1).describe(`What the code must do when this task is done. ${objectiveBudgetDescription}`),
1041
- constraints: z.array(z.string()).describe("Technical boundaries: files to touch, patterns to follow, 'Do not modify' lists."),
1042
- success_conditions: z.array(z.string()).min(1).describe(`Checkable criteria proving the goal is met. At least one must be a runnable command/test. ${objectiveBudgetDescription}`),
1045
+ constraints: z.array(z.string()).describe("Only what Codex would get wrong without being told: genuine risks, not a review checklist."),
1046
+ success_conditions: z.array(z.string()).min(1).describe(`Checkable criteria proving the goal is met. At least one must be a runnable command/test; command-based ones should say how they fail when the defect exists. ${objectiveBudgetDescription}`),
1043
1047
  token_budget: z.number().int().positive().optional().describe("Optional token budget for the Codex goal loop (thread/goal/set tokenBudget)."),
1044
1048
  cwd: z.string().optional().describe("Working directory for Codex. Defaults to the project directory."),
1045
1049
  context_files: contextFiles.optional().describe("Files or directories Codex should read before implementing."),
@@ -1091,8 +1095,8 @@ server.registerTool(
1091
1095
  description: "Read-only estimate made before starting a job. Measures the fully rendered Goal Contract prompt and returns approx_prompt_tokens using an approximate characters/4 heuristic, plus local completed-job history.",
1092
1096
  inputSchema: {
1093
1097
  goal: z.string().min(1).describe(`What the code must do when this task is done. ${objectiveBudgetDescription}`),
1094
- constraints: z.array(z.string()).describe("Technical boundaries: files to touch, patterns to follow, 'Do not modify' lists."),
1095
- success_conditions: z.array(z.string()).min(1).describe(`Checkable criteria proving the goal is met. At least one must be a runnable command/test. ${objectiveBudgetDescription}`),
1098
+ constraints: z.array(z.string()).describe("Only what Codex would get wrong without being told: genuine risks, not a review checklist."),
1099
+ success_conditions: z.array(z.string()).min(1).describe(`Checkable criteria proving the goal is met. At least one must be a runnable command/test; command-based ones should say how they fail when the defect exists. ${objectiveBudgetDescription}`),
1096
1100
  cwd: z.string().optional().describe("Working directory used to resolve relative context_files paths. Defaults to the project directory."),
1097
1101
  context_files: contextFiles.optional().describe("Files or directories included in the rendered prompt.")
1098
1102
  },
@@ -1127,7 +1131,7 @@ server.registerTool(
1127
1131
  "codex_rework",
1128
1132
  {
1129
1133
  title: "Send a Delta Contract to Codex",
1130
- description: "Resume the Codex thread from a previous implement job and hand it a Delta Contract (review findings + failed success conditions). The existing thread goal re-engages, so the /goal loop continues until the objective passes. Returns a new job_id.",
1134
+ description: "Resume the Codex thread from a previous implement job and hand it a Delta Contract (review findings + failed success conditions). The existing thread goal is reactivated, so the /goal loop continues until the objective passes. Returns a new job_id.",
1131
1135
  inputSchema: {
1132
1136
  job_id: z.string().optional().describe("The original implement job's id (preferred; resolves the thread to resume)."),
1133
1137
  thread_id: z.string().optional().describe("Codex thread id, if the job registry is gone (e.g. after a restart)."),
@@ -1229,9 +1233,7 @@ server.registerPrompt("c2c-workflow", {
1229
1233
  messages: [{
1230
1234
  role: "user",
1231
1235
  content: { type: "text", text: `
1232
- You are the **architect and reviewer**. Codex is the **implementer**. You draft contracts, delegate via the \`codex\` MCP server, and review the output. You do not implement the task yourself.
1233
-
1234
- If \`codex_config\` errors, tell the user to install the MCP server (npm: \`claude2codex\`).
1236
+ You are the **architect and reviewer**. Codex is the **implementer**. You draft contracts, delegate via the \`codex_*\` tools, and review the output. You do not implement the task yourself.
1235
1237
 
1236
1238
  ## Workflow
1237
1239
 
@@ -1257,7 +1259,6 @@ Only what Codex would get wrong without being told. One line of
1257
1259
  ### Success Conditions
1258
1260
  - [ ] Assertions, not paragraphs. At least one is a command whose exit code decides.
1259
1261
  - [ ] Command-based conditions must be falsifiable: describe how they fail when the defect exists. Subjective criteria should be marked as needing reviewer judgment.
1260
- - [ ] Handoff includes: Changed Files, Validation, Success Conditions, Risks & Deviations.
1261
1262
  \`\`\`
1262
1263
 
1263
1264
  **Write lean contracts.** Goal and Success Conditions are what Codex acts on. Constraints are for genuine risks only \u2014 don't front-load your review checklist into the contract.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude2codex",
3
- "version": "0.3.4",
3
+ "version": "0.3.6",
4
4
  "type": "module",
5
5
  "description": "MCP server bridging Claude (architect/reviewer) and Codex (implementer) via Goal/Delta Contracts and Codex's thread-goal loop.",
6
6
  "bin": {
@@ -30,6 +30,7 @@
30
30
  "start": "bun src/server.ts",
31
31
  "build": "tsup",
32
32
  "test": "bun test",
33
+ "gen:prompt-docs": "bun scripts/gen-prompt-docs.ts",
33
34
  "prepack": "cp ../README.md ../README.zh-CN.md ../PATTERNS.md ../PATTERNS.zh-CN.md .",
34
35
  "postpack": "rm -f README.md README.zh-CN.md PATTERNS.md PATTERNS.zh-CN.md"
35
36
  },