Skip to content

Remove context.md and scope prompt.txt to checkpoint-only prompts#572

Open
gtrrz-victor wants to merge 5 commits intomainfrom
571-remove-contextmd-and-simplify-prompttxt-to-checkpoint-prompts-only
Open

Remove context.md and scope prompt.txt to checkpoint-only prompts#572
gtrrz-victor wants to merge 5 commits intomainfrom
571-remove-contextmd-and-simplify-prompttxt-to-checkpoint-prompts-only

Conversation

@gtrrz-victor
Copy link
Contributor

@gtrrz-victor gtrrz-victor commented Mar 2, 2026

Closes #571

Summary

  • Remove context.md entirely — it was dead code (written during checkpointing but never consumed by any reader). Removes generation, writing, reading, and all test/doc references across 19 files.
  • Scope prompt.txt to checkpoint-only prompts — previously stored all session prompts joined by ---, but every consumer only used the first or last. Now stores only prompts from the current checkpoint portion of the transcript.
  • Net deletion of 542 lines of unnecessary code and complexity.

What changed

context.md removal:

  • generateContextFromPrompts() function and all callers
  • Context fields from WriteCommittedOptions, UpdateCommittedOptions, SessionContent, SessionFilePaths
  • context.md blob creation/reading in committed.go
  • createContextFile() from lifecycle.go
  • GetSessionContext() and getCheckpointsForSession() (dead code)
  • context.md fallback in getSessionDescriptionFromTree()
  • ContextFileName constant from paths.go

prompt.txt scoping:

  • Added extractCheckpointPrompts() that scopes transcript by agent type (JSONL/Gemini/OpenCode) before extracting prompts
  • Updated extractSessionData() and extractSessionDataFromLiveTranscript() to use it
  • Filesystem path in lifecycle.go was already checkpoint-scoped — no change needed

Backward compatibility:

  • Old context.md files on entire/checkpoints/v1 are simply ignored (no reader)
  • Old prompt.txt with all-session prompts still works with ExtractFirstPrompt()/extractLastPrompt()

Test plan

  • go build ./... compiles cleanly
  • mise run fmt — no formatting changes
  • mise run test:ci — all unit + integration tests pass
  • Manual: entire explain on a repo with existing checkpoints (backward compat)
  • Manual: Create new session, commit, verify no context.md on committed branch
  • Manual: entire rewind to verify session labels display correctly

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings March 2, 2026 04:23
@cursor
Copy link

cursor bot commented Mar 2, 2026

PR Summary

Medium Risk
Changes the persisted checkpoint metadata shape and prompt extraction logic across multiple agents, which could affect checkpoint/rewind behavior and any consumers expecting full-session prompts. Backward compatibility relies on ignoring old context.md and tests covering the new prompt scoping.

Overview
Removes context.md from checkpoint metadata end-to-end (constants, on-disk generation, git blob write/read paths, and related fields in WriteCommittedOptions/UpdateCommittedOptions, SessionContent, and SessionFilePaths), along with associated redaction and tests.

Changes prompt.txt semantics to be checkpoint-scoped rather than full-session: condensation now slices the transcript from CheckpointTranscriptStart (agent-aware for JSONL vs Gemini/OpenCode) via new extractCheckpointPrompts, and integration/unit tests + docs are updated to assert the new behavior.

Written by Cursor Bugbot for commit bd9d181. Configure here.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes the dead-code context.md generation/storage/reading across the entire codebase and scopes prompt.txt to contain only the prompts from the current checkpoint portion of a session transcript (rather than all session prompts). It is a cleanup PR that nets -542 lines.

Changes:

  • Remove context.md entirely: Deletes generateContextFromPrompts(), createContextFile(), GetSessionContext(), getCheckpointsForSession(), the Context fields from WriteCommittedOptions/UpdateCommittedOptions/SessionContent/SessionFilePaths, related git-blob creation/reading in committed.go, and the ContextFileName constant.
  • Scope prompt.txt to checkpoint-only prompts: Introduces extractCheckpointPrompts() that slices the full transcript to the checkpoint portion (via transcript.SliceFromLine for JSONL agents or SliceFromMessage for Gemini/OpenCode) before extracting user prompts; updates extractSessionData() and extractSessionDataFromLiveTranscript() to use it.
  • Update tests and docs: Removes tests for deleted functions, updates integration tests to assert checkpoint-scoped (not full-session) prompt content, and updates architecture docs and CLAUDE.md to reflect the new structure.

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
cmd/entire/cli/strategy/manual_commit_condensation.go Adds extractCheckpointPrompts(); removes generateContextFromPrompts() and getCheckpointsForSession(); updates prompt extraction calls
cmd/entire/cli/strategy/manual_commit_hooks.go Removes context generation and redaction in finalizeAllTurnCheckpoints
cmd/entire/cli/strategy/manual_commit_logs.go Removes dead GetSessionContext() function and its imports
cmd/entire/cli/strategy/manual_commit_types.go Removes Context field from ExtractedSessionData
cmd/entire/cli/strategy/common.go Removes context.md fallback in getSessionDescriptionFromTree and the # markdown prefix stripping
cmd/entire/cli/checkpoint/checkpoint.go Removes Context fields from WriteCommittedOptions, UpdateCommittedOptions, SessionContent, SessionFilePaths
cmd/entire/cli/checkpoint/committed.go Removes context blob creation/reading in writeSessionToSubdirectory, UpdateCommitted, ReadSessionContent
cmd/entire/cli/paths/paths.go Removes ContextFileName constant
cmd/entire/cli/lifecycle.go Removes createContextFile() function and its call
cmd/entire/cli/checkpoint/checkpoint_test.go Removes Context-related test assertions
cmd/entire/cli/checkpoint/committed_update_test.go Removes Context-related test assertions
cmd/entire/cli/strategy/manual_commit_condensation_test.go Removes generateContextFromPrompts tests; updates Gemini multi-checkpoint test
cmd/entire/cli/strategy/manual_commit_test.go Updates assertions to verify checkpoint-scoped prompts instead of full-session prompts
cmd/entire/cli/integration_test/manual_commit_workflow_test.go Updates integration tests to assert checkpoint-scoped prompt content
cmd/entire/cli/lifecycle_test.go Removes createContextFile tests
cmd/entire/cli/benchutil/parse_tree_bench_test.go Updates comment and capacity for 4-file structure
CLAUDE.md Updates architecture doc to remove context.md references
docs/architecture/sessions-and-checkpoints.md Updates checkpoint structure diagrams
docs/architecture/claude-hooks-integration.md Updates hook behavior description

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment @cursor review or bugbot run to trigger another review on this PR

@gtrrz-victor gtrrz-victor force-pushed the 571-remove-contextmd-and-simplify-prompttxt-to-checkpoint-prompts-only branch from 67bd76a to 8f7c3be Compare March 3, 2026 05:08
gtrrz-victor and others added 4 commits March 3, 2026 16:13
context.md was dead code — written during checkpointing but never consumed
by any reader. prompt.txt stored all session prompts, but every consumer
only used the first or last one. This simplifies both by removing context.md
entirely and scoping prompt.txt to only the current checkpoint's prompts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Entire-Checkpoint: 1104437d743e
… transcript

Stop extracting prompts from transcript at TurnEnd — prompts now flow
exclusively through event.Prompt at TurnStart and are appended to the
filesystem prompt.txt. This prevents TurnEnd from overwriting accumulated
prompts. Commit messages use state.LastPrompt instead.

Add filesystem fallback to finalizeAllTurnCheckpoints for cases where the
shadow branch prompt.txt is not yet available. Clear filesystem prompt.txt
after condensation only when all files are committed (preserve for
carry-forward).

Update integration tests to pass prompts through the hook input via new
SimulateUserPromptSubmitWithPrompt helper.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Entire-Checkpoint: 210a036ddee6
ExtractPrompts was removed from the TurnEnd handler in lifecycle.go
but the interface method, all 3 agent implementations, and several
helper functions in cli/transcript.go were left behind. Remove them
along with their tests and now-unused type aliases.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Entire-Checkpoint: a8c2ee703e68
These had zero production callers — only tests exercised them. The generic
AgentSession.GetLastUserPrompt() in agent/session.go already covers all agents.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Entire-Checkpoint: d42a011e0627
@gtrrz-victor gtrrz-victor force-pushed the 571-remove-contextmd-and-simplify-prompttxt-to-checkpoint-prompts-only branch from 8f7c3be to 5aaa28a Compare March 3, 2026 05:16
Entire-Checkpoint: d7b6c5b4032f
@gtrrz-victor gtrrz-victor marked this pull request as ready for review March 3, 2026 05:37
@gtrrz-victor gtrrz-victor requested a review from a team as a code owner March 3, 2026 05:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Remove context.md and simplify prompt.txt to checkpoint prompts only

2 participants