Skip to content

Add import tool for sessions prior to enabling Entire#1527

Merged
computermode merged 19 commits into
mainfrom
import-existing-claude-projects
Jun 26, 2026
Merged

Add import tool for sessions prior to enabling Entire#1527
computermode merged 19 commits into
mainfrom
import-existing-claude-projects

Conversation

@computermode

@computermode computermode commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

https://entire.io/gh/entireio/cli/trails/668

What

Adds the ability to import a coding agent's pre-existing local transcripts into Entire as read-only checkpoints, so a repo adopting Entire isn't starting from zero (checkpoint list/explain, search, tokens, and server-side recap/UI work on day-one history). Supports #1336 (enable doesn't prompt to import yet - requires manual kickoff for validation first). Claude Code is the only agent implemented; the package is structured so others can be added.

Surface: a hidden command, discoverable via entire labs:

entire import claude-code [--path DIR] [--dry-run] [--session ID]...

There is intentionally no enable-time prompt this pass — importing is an explicit, opt-in command.

How

  • New cmd/entire/cli/agentimport/ package. The orchestration (discovery loop, idempotent per-turn IDs, redaction, checkpoint write) is agent-agnostic; each agent plugs in an Importer (Discover + SplitTurns). A static list of supported importers backs entire import <agent> — adding an agent is a new Importer, no command wiring.
  • Discovers ~/.claude/projects/<sanitized-repo-path>/*.jsonl (fixed one-month lookback), splits each session into per-user-prompt turns, and writes one checkpoint per turn — reusing existing transcript parsing, per-turn token accounting (incl. subagent rollups), and redaction (redact.JSONLBytes).
  • Imported checkpoints are stored on the normal entire/checkpoints/v1 metadata branch, tagged Kind:"imported" with provenance (source, session/turn UUIDs, line range, content hash, import version). They're commit-less (no Entire-Checkpoint trailer) and surface in list/explain via an Imported flag, labeled [imported].
  • Idempotent: per-turn checkpoint IDs are sha256(sessionID + "/" + turnUUID), so re-running skips already-imported turns.
  • Not rewindable: checkpoint rewind refuses imported checkpoints with a clear read-only message.

Tradeoffs / known limitations (do later)

  • Import is manual. It is not offered during entire enable (an earlier iteration prompted at enable time; removed for now). Users run entire import claude-code when they want it.
  • Imported history is pushed to the backend like normal checkpoints (it's what lights up server-side search/recap/UI). Privacy note: up to a month of old conversations (and provenance such as transcript_path) sync on the next push, unless checkpoint pushing is disabled. (An earlier iteration kept imports local-only on a separate entire/imports/v1 ref; reverted — it caused explain-by-id and [temporary]-duplication bugs and was a cross-cutting overhaul. Single-ref is simpler; a local-only/opt-in-to-push mode could be revisited.)
  • Read-only by design: imported checkpoints have no working-tree snapshot, so they are not rewindable.
  • Claude Code only this pass (the package and entire import <agent> surface leave room for others).

Reviewer notes

  • Kind:"imported" + Provenance + an Imported umbrella flag were added to the checkpoint metadata contract (api/checkpoint).
  • Verified locally: mise run lint (0 issues) and mise run test:ci (unit + integration + e2e canary) green; an end-to-end integration test covers dry-run, import, [imported] labeling (no [temporary] duplication), explain-by-id, idempotency, and rewind refusal.

computermode and others added 14 commits June 25, 2026 11:01
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Entire-Checkpoint: 3d478cdad9c1
…tadata

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Entire-Checkpoint: 5d96dcf7065b
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Entire-Checkpoint: f85986b0716e
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Entire-Checkpoint: d027d2f148a0
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Entire-Checkpoint: 487abe46ddad
…sage

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Entire-Checkpoint: 3866c6eb201d
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Entire-Checkpoint: 8db9350e70f6
…h label

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Entire-Checkpoint: 132601907855
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Entire-Checkpoint: 9643642e02f9
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Entire-Checkpoint: dc1cf8d69df4
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Entire-Checkpoint: 996ef1f5522c
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Entire-Checkpoint: 412f636a521e
…-store access

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Entire-Checkpoint: f2e9d10c5908
Imported checkpoints now live on entire/checkpoints/v1 (tagged Kind:imported)
instead of a local-only entire/imports/v1 ref. They are redacted and pushed
like normal checkpoints, which is what lights up server-side search/recap/UI.

This collapses the read paths back to a single store and fixes two bugs that
came from the two-ref design:
- explain <imported-id> now resolves (was: not found, only consulted v1+shadow)
- imported checkpoints no longer duplicate as [temporary] (shadow-branch
  scanner no longer mis-reads a second metadata ref)

Removes ImportsRefs/OpenImports/ImportsBranchName and the read-path unions;
keeps Kind:imported, provenance, the [imported] label, rewind refusal, and the
deterministic-ID idempotency.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Entire-Checkpoint: fb2f7d9f9b04
Copilot AI review requested due to automatic review settings June 25, 2026 21:52

@cursor cursor Bot left a comment

Copy link
Copy Markdown

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 4 potential issues.

Fix All in Cursor

❌ 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

Reviewed by Cursor Bugbot for commit 241ac12. Configure here.

Comment thread cmd/entire/cli/setup.go Outdated
Comment thread cmd/entire/cli/setup.go Outdated
Comment thread cmd/entire/cli/setup.go Outdated
Comment thread cmd/entire/cli/explain.go Outdated
@computermode computermode changed the title Import existing Claude Code transcripts Add import tool for sessions prior to enabling Entire Jun 25, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a new “import existing Claude Code transcripts” pathway so a repo adopting Entire can populate checkpoint history from past Claude sessions. The PR introduces an importclaude package, a hidden entire import claude-code command, an enable-time prompt, and extends the checkpoint metadata contract to represent imported (read-only) checkpoints with provenance.

Changes:

  • Add import orchestration (importclaude) that discovers recent Claude session JSONL files, splits them into per-user-prompt turns, derives deterministic checkpoint IDs, and writes them as imported checkpoints.
  • Extend checkpoint metadata to carry Imported and Provenance, and surface imported checkpoints in list/explain flows while refusing rewind.
  • Add CLI entry points (hidden import command + entire enable prompt) and integration/unit tests covering the end-to-end behavior.

Reviewed changes

Copilot reviewed 27 out of 27 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
cmd/entire/cli/strategy/strategy.go Adds RewindPoint.Imported flag to represent imported checkpoints in rewind/list presentation.
cmd/entire/cli/strategy/manual_commit_types.go Adds Imported field to checkpoint info struct used by strategy/UI plumbing.
cmd/entire/cli/strategy/common.go Propagates Imported from checkpoint store info into strategy-level info.
cmd/entire/cli/setup.go Adds enable-time prompt that optionally imports recent Claude transcripts.
cmd/entire/cli/setup_import_prompt_test.go Tests prompt skipping behavior in non-interactive / no-transcript scenarios.
cmd/entire/cli/session/state.go Introduces KindImported to tag imported checkpoints.
cmd/entire/cli/root.go Registers new hidden import command group.
cmd/entire/cli/rewind.go Refuses rewinding to imported checkpoints with a clear message.
cmd/entire/cli/rewind_imports_test.go Tests the imported-checkpoint rewind refusal behavior.
cmd/entire/cli/labs.go Adds entire import claude-code to labs-discoverable experimental commands.
cmd/entire/cli/integration_test/import_claude_test.go End-to-end integration test for import, labeling, explain-by-id, idempotency, and rewind refusal.
cmd/entire/cli/importclaude/turns.go Implements transcript splitting into turns + per-turn token/model extraction.
cmd/entire/cli/importclaude/turns_test.go Unit tests for turn splitting and tool_result exclusion.
cmd/entire/cli/importclaude/importer.go Implements discovery + idempotent write of imported checkpoints into persistent store.
cmd/entire/cli/importclaude/importer_test.go Unit tests for import/idempotency and dry-run behavior.
cmd/entire/cli/importclaude/id.go Deterministic checkpoint ID derivation for imported turns.
cmd/entire/cli/importclaude/id_test.go Unit test for deterministic/distinct imported IDs.
cmd/entire/cli/importclaude/discover.go Discovers recent transcript files with a fixed lookback + optional filtering.
cmd/entire/cli/importclaude/discover_test.go Unit tests for lookback and session filtering behavior.
cmd/entire/cli/import_cmd.go Adds hidden entire import claude-code command and flags.
cmd/entire/cli/import_cmd_test.go CLI-level test ensuring dry-run reports counts.
cmd/entire/cli/explain.go Includes imported checkpoints in checkpoint list grouping + blocks summary generation for imported checkpoints.
cmd/entire/cli/checkpoint/persistent.go Persists Provenance and carries forward an Imported summary umbrella flag.
cmd/entire/cli/checkpoint/persistent_imported_test.go Tests that imported checkpoints surface on list as imported.
cmd/entire/cli/checkpoint/aliases.go Exposes Provenance via alias for CLI checkpoint package.
api/checkpoint/metadata.go Adds Provenance type and Imported fields to metadata contract.
api/checkpoint/metadata_test.go Tests JSON round-trip for provenance and imported flags.

Comment thread cmd/entire/cli/setup.go Outdated
Comment thread cmd/entire/cli/importclaude/id.go Outdated
Comment thread cmd/entire/cli/importclaude/importer.go Outdated
Comment thread cmd/entire/cli/importclaude/importer.go Outdated
Comment thread cmd/entire/cli/session/state.go
Comment thread cmd/entire/cli/strategy/strategy.go
Comment thread cmd/entire/cli/explain.go Outdated
Comment thread cmd/entire/cli/setup.go Outdated
Comment thread cmd/entire/cli/import_cmd.go Outdated
computermode and others added 3 commits June 25, 2026 15:03
Renames cmd/entire/cli/importclaude -> cmd/entire/cli/agentimport with an
Importer seam (Discover + SplitTurns) and a static set of supported agents,
so other agents can be added without touching the orchestration. Claude Code
is the only implementation today.

Also drops the enable-time import prompt; importing is a hidden command only
(entire import <agent>, discoverable via entire labs).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Entire-Checkpoint: e58fc114f6a9
- explain: cap live (commit-linked + temporary) checkpoints to the limit
  before appending imported ones, so a large import can't evict recent
  checkpoints from 'checkpoint list'
- agentimport: redact each session transcript once per file instead of once
  per turn (O(files) not O(turns))
- correct stale 'local-only'/'entire/imports/v1' wording in Kind/flag/field
  comments — imported checkpoints live on v1 and push like normal checkpoints

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Entire-Checkpoint: f553c0e9a83c
…points

Address review findings on imported-checkpoint history:

- Call strategy.EnsureRedactionConfigured() before import writes so
  imported transcripts honor opt-in PII, custom_redactions, and redactor
  packs, not just always-on secret scanning. Covered by a custom-redaction
  test.
- Store only the transcript basename (transcript_file) in provenance
  instead of the absolute path, which leaked local usernames/repo layout
  onto the shared v1 branch.
- Hash the redacted turn slice instead of raw bytes, closing a
  confirmation attack against guessed raw prompt/output content.
- Gate the explain "--generate" hint on summary.Imported, since imported
  history is read-only and --generate is refused.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Entire-Checkpoint: 3e645399c3f3
@computermode computermode marked this pull request as ready for review June 25, 2026 23:07
@computermode computermode requested a review from a team as a code owner June 25, 2026 23:07
Comment thread api/checkpoint/metadata.go Outdated
Comment thread api/checkpoint/metadata.go
Comment thread api/checkpoint/metadata.go Outdated
Provenance was written to metadata.json but never read: idempotency comes from
the deterministic checkpoint ID (sha256(sessionID/turnUUID)), and explain never
cited it. Removing the Provenance struct/field and the now-dead Turn fields
(ParentUUID) and import-version constant. Imported checkpoints keep Kind and the
Imported flag.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Entire-Checkpoint: 4315ab0b3062
@computermode computermode merged commit 3efa5fa into main Jun 26, 2026
9 checks passed
@computermode computermode deleted the import-existing-claude-projects branch June 26, 2026 00:53
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.

3 participants