Skip to content

Add --worktree flag to llm-cost for path-based cost attribution#10

Merged
github-actions[bot] merged 1 commit into
mainfrom
llm-cost-worktree-flag
May 29, 2026
Merged

Add --worktree flag to llm-cost for path-based cost attribution#10
github-actions[bot] merged 1 commit into
mainfrom
llm-cost-worktree-flag

Conversation

@riddim-developer-bot
Copy link
Copy Markdown
Contributor

Summary

  • Adds computeWorktreeCost(worktreePath, options) to src/index.mjs — finds all Claude and Codex sessions run from a given directory without requiring a Linear issue ID or Symphony workspace convention
  • Adds --worktree <path> flag to bin/llm-cost.mjs — resolves the path to absolute, calls the new function, reuses the existing output format
  • No existing behaviour changed; all 66 tests pass

How it works

  • Claude: encodes the path directly (/ and .-) to look up ~/.claude/projects/<encoded>/ — no regex needed
  • Codex: scans rollouts and filters where session_meta.cwd === worktreePath exactly

Test plan

  • llm-cost --help shows --worktree in usage
  • llm-cost --worktree <path> produces token/turn/cost output for a real worktree
  • llm-cost --worktree <nonexistent-path> shows zero sessions gracefully
  • Existing llm-cost <ISSUE-ID> flow unchanged

Adds computeWorktreeCost() to the library and a --worktree <path> CLI flag
so users can measure session cost for any directory they ran an agent in,
without needing a Linear issue ID or Symphony workspace convention.
@github-actions github-actions Bot enabled auto-merge (squash) May 29, 2026 16:42
@github-actions github-actions Bot merged commit 4de9230 into main May 29, 2026
2 checks passed
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