@anyi61/codex-claude-delegate-mcp 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.
Files changed (42) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +262 -0
  3. package/dist/claude-cli.d.ts +84 -0
  4. package/dist/claude-cli.js +3123 -0
  5. package/dist/claude-cli.js.map +1 -0
  6. package/dist/cli.d.ts +61 -0
  7. package/dist/cli.js +334 -0
  8. package/dist/cli.js.map +1 -0
  9. package/dist/codex-config.d.ts +104 -0
  10. package/dist/codex-config.js +446 -0
  11. package/dist/codex-config.js.map +1 -0
  12. package/dist/guard.d.ts +27 -0
  13. package/dist/guard.js +229 -0
  14. package/dist/guard.js.map +1 -0
  15. package/dist/job-runner.d.ts +13 -0
  16. package/dist/job-runner.js +75 -0
  17. package/dist/job-runner.js.map +1 -0
  18. package/dist/jobs.d.ts +46 -0
  19. package/dist/jobs.js +175 -0
  20. package/dist/jobs.js.map +1 -0
  21. package/dist/package-info.d.ts +4 -0
  22. package/dist/package-info.js +14 -0
  23. package/dist/package-info.js.map +1 -0
  24. package/dist/schema.d.ts +779 -0
  25. package/dist/schema.js +325 -0
  26. package/dist/schema.js.map +1 -0
  27. package/dist/server.d.ts +1142 -0
  28. package/dist/server.js +693 -0
  29. package/dist/server.js.map +1 -0
  30. package/dist/session.d.ts +35 -0
  31. package/dist/session.js +109 -0
  32. package/dist/session.js.map +1 -0
  33. package/package.json +49 -0
  34. package/plugins/codex-claude-delegate/.codex-plugin/plugin.json +36 -0
  35. package/plugins/codex-claude-delegate/.mcp.json +9 -0
  36. package/plugins/codex-claude-delegate/hooks/hooks.json +16 -0
  37. package/plugins/codex-claude-delegate/hooks/review-gate-stop.mjs +66 -0
  38. package/plugins/codex-claude-delegate/server/job-runner.js +16999 -0
  39. package/plugins/codex-claude-delegate/server/server.js +28048 -0
  40. package/plugins/codex-claude-delegate/skills/claude-delegate.md +30 -0
  41. package/plugins/codex-claude-delegate/skills/claude-rescue.md +52 -0
  42. package/plugins/codex-claude-delegate/skills/claude-review.md +25 -0
@@ -0,0 +1,30 @@
1
+ # Claude Code Delegate
2
+
3
+ Use `claude_task` for normal read/review/write delegation. After it returns a `job_id`, call `claude_job_wait` for that same job. Respect `recommended_delay_ms` and `next_allowed_poll_at`. If `poll_too_soon=true`, wait until `next_allowed_poll_at` before polling again. Do not start another job or implement locally while `waiting=true`.
4
+ First run sequence: `claude_setup` -> `claude_task` -> `claude_job_wait` -> `claude_result`.
5
+
6
+ `claude_task` does not accept `max_turns`. If the user explicitly asks for a turn cap, use the appropriate Advanced / Debug tool (`claude_query`, `claude_review`, or `claude_implement`) instead of the default high-level entrypoint.
7
+
8
+ For write tasks, `claude_task` produces an isolated git worktree result only — it never directly applies changes to the main workspace. Non-preview `claude_apply` modifies the main workspace. Always run `claude_apply preview=true` first, show or summarize the planned diff, and wait for explicit user approval before calling non-preview `claude_apply` with `confirmed_by_user=true`.
9
+
10
+ `preview=true` and `cleanup=true` must not be combined in a single `claude_apply` call — the server rejects this combination. Workflow `next_actions` from `claude_result` or `claude_job_wait` only suggests `preview=true` actions; it never emits direct non-preview apply suggestions.
11
+
12
+ For normal `claude_task` calls, do not pass `files`. If Claude should read a plan or checklist, use `instruction_files` or mention the file in `task`; these files are context, not modification scope. Use Advanced / Debug `claude_implement.files` only when strict file modification limits are explicitly required.
13
+
14
+ ## When NOT to use claude_implement
15
+
16
+ - Single-line bug fixes
17
+ - Adding a simple function to one file
18
+ - Tasks you can complete correctly in < 3 trivial edits
19
+ - Read-only tasks (use `claude_task mode=read` instead)
20
+
21
+ ## Default workflow
22
+
23
+ 1. Start with `claude_task mode=write` and pass `task`, `cwd`, optional `instruction_files`, `constraints`, `max_cost_usd`, `max_changed_files`.
24
+ 2. Capture the returned `job_id`.
25
+ 3. Poll with `claude_job_wait`, respecting `recommended_delay_ms`.
26
+ 4. When the job finishes terminal, call `claude_result`.
27
+ 5. Preview with `claude_apply preview=true` (no user approval needed for preview).
28
+ 6. Show or summarize the planned diff to the user and ask whether to apply it.
29
+ 7. Only after explicit user approval, apply with `claude_apply cleanup=true confirmed_by_user=true`.
30
+ 8. Use `claude_cleanup` for leftover delegated worktrees.
@@ -0,0 +1,52 @@
1
+ # Claude Code Rescue — Failure Recovery
2
+
3
+ Rescue workflows may use Advanced / Debug tools such as `claude_workspace_status`, `claude_job_result`, `claude_runs`, `claude_run_inspect`, and `claude_job_cancel`. Use them only after the default `claude_job_wait` / `claude_result` path is insufficient or the user explicitly asks for diagnosis.
4
+
5
+ If an apply was refused because a high-level `claude_task` was given a plan file through deprecated `files`, retry the high-level task with `instruction_files` instead. Strict file scope belongs to Advanced / Debug `claude_implement.files`.
6
+
7
+ ## When to use rescue procedures
8
+
9
+ Use these steps when `claude_implement` fails or produces unexpected results:
10
+
11
+ ### 1. Implement failed (timeout / max_turns / error)
12
+
13
+ ```
14
+ claude_status # check if worktree exists
15
+ ```
16
+
17
+ If worktree was created but Claude timed out:
18
+ - Run `claude_query` to inspect the partial worktree state
19
+ - Consider re-running `claude_implement` with a **smaller, more focused task**
20
+ - Use `session_key` if you want Claude to resume (but beware context pollution)
21
+
22
+ ### 2. Changed files exceeded limit
23
+
24
+ If `server_observed.resource_limits.changed_files_exceeded` is true:
25
+ - The worktree contains more changes than expected
26
+ - Run `claude_review` on the worktree diff before deciding
27
+ - Either apply if changes are correct, or discard the worktree
28
+
29
+ ### 3. Apply conflicts
30
+
31
+ If `claude_apply` reports conflicts (uncommitted changes in main workspace):
32
+ - Commit or stash your local changes first
33
+ - Then retry `claude_apply`
34
+ - Do NOT force-apply partial changes (the tool refuses to partially apply)
35
+
36
+ If `claude_apply` reports `No changed source files found`:
37
+ - Confirm the worktree actually changed files under `src/`
38
+ - Remember docs, `dist/`, and root-level files are intentionally ignored
39
+ - Untracked `src/` files should be detected; if not, inspect `git status --short -- src/` inside the worktree
40
+
41
+ ### 4. Stale worktrees
42
+
43
+ If `claude_status` shows leftover worktrees:
44
+ - Run `claude_cleanup` (dry-run first to see what will be removed)
45
+ - Then `claude_cleanup dry_run: false` to remove them
46
+ - This frees disk space and keeps `git worktree list` clean
47
+
48
+ ## General principles
49
+
50
+ - **Never apply blindly**: always review Claude's diff via `server_observed` first
51
+ - **Prefer smaller tasks**: a failed 5-file refactor should be split into 3 single-file tasks
52
+ - **Check worktree state**: use `claude_status` before retrying to understand what was left behind
@@ -0,0 +1,25 @@
1
+ # Claude Code Review
2
+
3
+ For ordinary review requests, prefer `claude_task mode=review` and poll with `claude_job_wait`. Use `instruction_files` for plan/checklist context. Use direct `claude_review` only for Advanced / Debug workflows or when the user explicitly asks for the bottom-level tool.
4
+
5
+ ## When to use review
6
+
7
+ 1. **Before risky implementations** — diff of planned changes before applying to main branch
8
+ 2. **Complex patches** — diffs that touch multiple modules or cross-cutting concerns
9
+ 3. **Security-sensitive changes** — authentication, authorization, input handling, secrets management
10
+ 4. **Unfamiliar code** — when you are not sure about edge cases or idiomatic patterns
11
+ 5. **After claude_implement** — review Claude's diff before calling `claude_apply`
12
+
13
+ ## How it works
14
+
15
+ - Claude runs in read-only mode (cannot modify files)
16
+ - Provide a task description and optional diff/file list
17
+ - Returns structured findings, recommendations, and severity (critical/high/medium/low/none)
18
+
19
+ ## When NOT to use claude_review
20
+
21
+ - Typos or trivial formatting (use linters instead)
22
+ - After you have already applied changes (review before apply)
23
+ - When you just need to understand code (use `claude_query` instead)
24
+
25
+ A review result is not apply approval. After reviewing a delegated worktree, ask the user before any non-preview `claude_apply` call.