Skip to content

feat: full Clone MCP session integration (start/record/feedback/stop)#7

Merged
Turtle-Hwan merged 4 commits into
mainfrom
worktree-clone-mcp-full-integration
May 22, 2026
Merged

feat: full Clone MCP session integration (start/record/feedback/stop)#7
Turtle-Hwan merged 4 commits into
mainfrom
worktree-clone-mcp-full-integration

Conversation

@Turtle-Hwan
Copy link
Copy Markdown
Contributor

@Turtle-Hwan Turtle-Hwan commented May 12, 2026

Warning

Review carefully before merge. This PR adds Clone MCP session memory recording in addition to prediction: session tracking, prompt/response recording, feedback submission, and session stop calls. Prediction and local safety gates still follow the latest main behavior.

Summary

  • Add scripts/clone-mcp.mjs as the shared Clone MCP action layer for predict_next_prompt, start_session, stop_session, record_agent_prompt, record_agent_response, and submit_feedback, built on the existing shared MCP client/auth helpers from main.
  • Start a Clone session during /clone:loop, record the initial user prompt, and persist clone_session_id, mcp_session_id, and last_prompt_event_id in local loop state when available.
  • Record what the agent actually did:
    • Stop hook records the current iteration assistant response before prediction.
    • PostToolUse records Write, Edit, MultiEdit, and apply_patch mutation summaries.
    • Accepted Clone-predicted continuation prompts and AskUserQuestion auto-answers are recorded as prompt events.
  • Submit accepted/rejected feedback for predictions and stop the Clone session on terminal loop paths or explicit /clone:cancel-loop.
  • Keep storage-side MCP failures non-fatal: record/bootstrap/feedback/stop failures are logged to local history and do not break the existing loop behavior.

Alignment with merged direction

  • Preserves the stale-loop safety model from PR Prevent stale Clone Loop auto-resume #15 / CLO-46: Stop, AskUserQuestion, and PostToolUse still share validateActiveLoopState, strict session matching, loop-start history validation, and TTL handling.
  • Preserves the shared client/auth/data split from PR Connect API key setup to dashboard session ping #20 and PR Strengthen Clone Interview goal-to-plan flow #21: MCP transport/auth/version identity stay in shared helpers, while clone-mcp.mjs centralizes Clone-specific actions.
  • Preserves the AskUserQuestion threshold/status gating from PR Fix Clone Loop AskUserQuestion threshold gating #22 / CLO-36: low-confidence, non-auto, unmapped, or MCP-failed question predictions defer to the user instead of choosing a fallback answer.
  • Extends the multi-turn/rich-context direction from earlier merged PRs: prior work still feeds prediction context, and this PR adds persistent session memory writes so Clone can learn from prompts, responses, tool use, and feedback.
  • Keeps Codex plugin direction from PR [codex] add Codex Clone Loop hooks #17 intact; this PR focuses on shared Clone Loop memory/session behavior used by the Claude hooks and compatible shared scripts.

Failure behavior

  • start_session / initial record_agent_prompt failure: loop still starts, with a warning.
  • record_agent_response, record_agent_prompt, submit_feedback, or stop_session failure: hook continues its existing control flow and appends an error record to .claude/clone-loop.history.local.jsonl.
  • predict_next_prompt failure: loop does not fabricate a continuation. Stop hook escalates/stops; AskUserQuestion defers to the real user. This matches the latest safe gating behavior on main.

Validation

  • npm test -> 72/72 pass
  • claude plugin validate . -> pass
  • git diff --check -> pass

Manual follow-ups before undrafting

  • Run /clone:loop "..." in a real Claude Code session and confirm state frontmatter receives clone_session_id.
  • Let the loop run for 2+ iterations and confirm record-response, record-prompt, and feedback-sent local history events.
  • Trigger low-confidence escalation and confirm rejected feedback plus session-stopped are logged without prompt injection.
  • Run /clone:cancel-loop and confirm the state file is removed and stop-session errors, if any, are non-fatal.

@Turtle-Hwan Turtle-Hwan marked this pull request as draft May 12, 2026 10:58
@Turtle-Hwan Turtle-Hwan force-pushed the worktree-clone-mcp-full-integration branch 3 times, most recently from 32b6c1b to cc51668 Compare May 22, 2026 17:58
@Turtle-Hwan Turtle-Hwan force-pushed the worktree-clone-mcp-full-integration branch from 4b4072b to ab1b473 Compare May 22, 2026 18:18
@Turtle-Hwan Turtle-Hwan force-pushed the worktree-clone-mcp-full-integration branch from f099de4 to 5b23ef6 Compare May 22, 2026 18:35
@Turtle-Hwan Turtle-Hwan marked this pull request as ready for review May 22, 2026 18:39
@Turtle-Hwan Turtle-Hwan merged commit 9011c9b into main May 22, 2026
@Turtle-Hwan Turtle-Hwan deleted the worktree-clone-mcp-full-integration branch May 22, 2026 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant