agent: move TokenUsage/SkillEvent to leaf types package (detangle)#1482
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR detangles the checkpoint contract from the heavier agent package by relocating the TokenUsage and SkillEvent DTOs into the leaf cmd/entire/cli/agent/types package, while preserving backward compatibility via type aliases in agent.
Changes:
- Updated checkpoint metadata DTOs to use
types.TokenUsage/types.SkillEventand removed theagentimport from the checkpoint contract. - Added
TokenUsageand theSkillEventstruct family tocmd/entire/cli/agent/types. - Kept existing call sites compiling by adding transparent aliases in
cmd/entire/cli/agent.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| cmd/entire/cli/checkpoint/checkpoint.go | Switches checkpoint DTO fields from agent.* to leaf types.*, dropping the heavy agent import. |
| cmd/entire/cli/agent/types/token_usage.go | Introduces the leaf types.TokenUsage DTO (JSON schema preserved). |
| cmd/entire/cli/agent/types/skill_events.go | Introduces the leaf types.SkillEvent DTO family (JSON schema preserved). |
| cmd/entire/cli/agent/types.go | Replaces in-package TokenUsage definition with an alias to types.TokenUsage. |
| cmd/entire/cli/agent/skill_events.go | Replaces in-package SkillEvent definitions with aliases to types.* while retaining constants/interfaces in agent. |
61d2fb5 to
7017397
Compare
The checkpoint contract DTOs embed TokenUsage and SkillEvent, but both lived in the heavy agent package — so any package referencing the checkpoint metadata types transitively pulled in agent (and its TUI/launch/review dependencies). That blocks relocating the contract to a standalone api/checkpoint package. Move the type definitions (and the SkillEvent string constants) into the existing leaf agent/types package (which has no imports) and leave transparent aliases in agent: type TokenUsage = types.TokenUsage type SkillEvent = types.SkillEvent (+ the four Skill* sub-types) const SkillEventTypePromptInvocation = types.SkillEventTypePromptInvocation (+ the rest) All ~34 existing agent.TokenUsage / agent.SkillEvent references keep compiling unchanged via the aliases. The SkillEventExtractor interface stays in agent (it's agent-implementation behavior, not contract data); the constants move alongside the structs so the leaf package is self-contained for constructing skill events. checkpoint.go now references types.* and no longer imports agent — the prerequisite for the api/checkpoint relocation (next in the stack). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Entire-Checkpoint: 44f690c46059
7017397 to
8ff1f70
Compare
pjbgf
previously approved these changes
Jun 22, 2026
pjbgf
approved these changes
Jun 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://entire.io/gh/entireio/cli/trails/624
What
Dependency detangle that unblocks relocating the checkpoint contract to
api/checkpoint(#1433).TokenUsageand theSkillEventcluster move from the heavyagentpackage into the existing leafagent/typespackage; transparent aliases stay behind inagent.Why
The checkpoint metadata DTOs (
CommittedMetadata,CheckpointSummary, …) embedTokenUsage/SkillEvent. While those types lived inagent, any consumer of the checkpoint contract transitively importedagentand its TUI/launch/review fan-out — so the contract could never become a clean standalone package. After this move,checkpoint.goreferencestypes.*and drops itsagentimport.Blast radius: zero behavioral change
agent.TokenUsage/agent.SkillEventkeep compiling unchanged — the aliases are identical types, JSON tags are preserved verbatim, no method sets involved.SkillEventType*,SkillSignal*, …) and theSkillEventExtractorinterface stay inagent.CalculateTokenUsagestays inagent, still returns*TokenUsage(the alias).Next in the stack
PR3b (stacked on this): relocate the now-
agent-free contract (interfaces + DTOs) togithub.com/entireio/cli/api/checkpointand rewrite import paths.Verification
go build ./..., all tests compile,mise run fmt(clean),mise run lint(0 issues), and suites foragent/...,checkpoint/...,cmd/entire/cli,strategy,sessionall green.Note
Low Risk
Pure type relocation with identical JSON tags and aliases; no runtime or serialization behavior change.
Overview
Moves
TokenUsageand theSkillEventstruct family out ofagentinto the leafagent/typespackage so checkpoint metadata can depend on those DTOs without pulling in the fullagentpackage.checkpointnow typesTokenUsage/SkillEventfields astypes.*and drops itsagentimport.agentkeeps transparent type aliases (type TokenUsage = types.TokenUsage, same forSkillEventand related types) so existingagent.TokenUsage/agent.SkillEventcall sites keep compiling unchanged. Skill constants andSkillEventExtractorstay inagent.Reviewed by Cursor Bugbot for commit 61d2fb5. Configure here.