Skip to content

agent: move TokenUsage/SkillEvent to leaf types package (detangle)#1482

Merged
Soph merged 1 commit into
mainfrom
feat/checkpoint-detangle-types
Jun 22, 2026
Merged

agent: move TokenUsage/SkillEvent to leaf types package (detangle)#1482
Soph merged 1 commit into
mainfrom
feat/checkpoint-detangle-types

Conversation

@Soph

@Soph Soph commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

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

Stacked on #1481. Review/merge the lower PRs first; this diff is against that branch.

What

Dependency detangle that unblocks relocating the checkpoint contract to api/checkpoint (#1433). TokenUsage and the SkillEvent cluster move from the heavy agent package into the existing leaf agent/types package; transparent aliases stay behind in agent.

// in agent, after the move:
type TokenUsage = types.TokenUsage
type SkillEvent = types.SkillEvent   // + SkillEventSkill/Source/TranscriptAnchor/Collapse

Why

The checkpoint metadata DTOs (CommittedMetadata, CheckpointSummary, …) embed TokenUsage/SkillEvent. While those types lived in agent, any consumer of the checkpoint contract transitively imported agent and its TUI/launch/review fan-out — so the contract could never become a clean standalone package. After this move, checkpoint.go references types.* and drops its agent import.

Blast radius: zero behavioral change

  • The ~34 files using agent.TokenUsage / agent.SkillEvent keep compiling unchanged — the aliases are identical types, JSON tags are preserved verbatim, no method sets involved.
  • Constants (SkillEventType*, SkillSignal*, …) and the SkillEventExtractor interface stay in agent.
  • CalculateTokenUsage stays in agent, still returns *TokenUsage (the alias).

Next in the stack

PR3b (stacked on this): relocate the now-agent-free contract (interfaces + DTOs) to github.com/entireio/cli/api/checkpoint and rewrite import paths.

Verification

go build ./..., all tests compile, mise run fmt (clean), mise run lint (0 issues), and suites for agent/..., checkpoint/..., cmd/entire/cli, strategy, session all green.


Note

Low Risk
Pure type relocation with identical JSON tags and aliases; no runtime or serialization behavior change.

Overview
Moves TokenUsage and the SkillEvent struct family out of agent into the leaf agent/types package so checkpoint metadata can depend on those DTOs without pulling in the full agent package.

checkpoint now types TokenUsage / SkillEvent fields as types.* and drops its agent import. agent keeps transparent type aliases (type TokenUsage = types.TokenUsage, same for SkillEvent and related types) so existing agent.TokenUsage / agent.SkillEvent call sites keep compiling unchanged. Skill constants and SkillEventExtractor stay in agent.

Reviewed by Cursor Bugbot for commit 61d2fb5. Configure here.

Copilot AI review requested due to automatic review settings June 19, 2026 14:32
@Soph Soph requested a review from a team as a code owner June 19, 2026 14:32

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

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.SkillEvent and removed the agent import from the checkpoint contract.
  • Added TokenUsage and the SkillEvent struct family to cmd/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.

Comment thread cmd/entire/cli/agent/skill_events.go Outdated
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
@Soph Soph force-pushed the feat/checkpoint-detangle-types branch from 7017397 to 8ff1f70 Compare June 19, 2026 16:00
pjbgf
pjbgf previously approved these changes Jun 22, 2026
Base automatically changed from feat/checkpoint-store-write-union to main June 22, 2026 12:07
@Soph Soph dismissed pjbgf’s stale review June 22, 2026 12:07

The base branch was changed.

@Soph Soph merged commit b2f00d5 into main Jun 22, 2026
9 checks passed
@Soph Soph deleted the feat/checkpoint-detangle-types branch June 22, 2026 12:10
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