Commit graph

2 commits

Author SHA1 Message Date
anandghegde
c66c804b67 Merge origin/main into feat/codebuff-provider and scope sessionId by channel
Resolves merge conflicts with main (README.md, src/providers/index.ts,
tests/provider-registry.test.ts, package-lock.json) and addresses PR
review feedback from Qodo-Free-For-OSS:

- Codebuff sessionId now includes the channel root name (manicode,
  manicode-dev, manicode-staging) derived from the chat directory
  structure, preventing the same chatId from colliding across channels
  when downstream aggregation keys by (provider, sessionId, project).
- Uses '/' as the channel/chatId separator to avoid clashing with
  src/parser.ts's colon-delimited session key format.
- Adds tests: collision across channels, channel inclusion, and
  fallback when the path doesn't match the expected shape.
- Updates README dedup paragraph to mention Codebuff's strategy.
2026-05-01 00:14:18 +05:30
Anand Hegde
3c0302b938 feat(providers): add Codebuff provider
Adds the Codebuff provider (formerly Manicode) as a single-file plugin
under src/providers/codebuff.ts, following the conventions used by the
pi and opencode providers.

Data source:
- Walks ~/.config/manicode/projects/<project>/chats/<chatId>/
- chat-messages.json holds the serialized ChatMessage[]
- run-state.json is consulted to recover the real cwd so sessions group
  by the originating project directory
- manicode-dev and manicode-staging channels are walked automatically
- Honors CODEBUFF_DATA_DIR for a custom root

Cost model:
- Codebuff bills in credits, not tokens. Each completed assistant message
  records credits on message.credits; CodeBurn approximates cost using
  the public PAYG rate ($0.01 / credit) as a conservative upper bound.
- When Codebuff routes a call through an upstream provider and the
  stashed RunState records real token totals (providerOptions.usage or
  providerOptions.codebuff.usage in messageHistory), the LiteLLM-based
  calculation takes precedence.

Tool normalization maps Codebuff-native names (read_files, str_replace,
run_terminal_command, spawn_agents, etc.) to the canonical set used by
the classifier (Read, Edit, Bash, Agent, TodoWrite, ...).

Tests:
- 18 provider tests covering discovery, parsing, multi-turn sessions,
  providerOptions fallback, dedup, malformed files, display names
- provider-registry.test.ts updated to assert codebuff is registered
  and its tool/model display names

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
2026-04-21 21:02:58 +05:30