feat(connectors): add Codebuff (Manicode) connector#6
feat(connectors): add Codebuff (Manicode) connector#6anandghegde wants to merge 2 commits intoDicklesworthstone:mainfrom
Conversation
Adds detection + session scan for Codebuff (formerly Manicode) chat history
stored under ~/.config/manicode/projects/<project>/chats/<chatId>/chat-messages.json
(and the rebranded ~/.config/codebuff layout).
- New connector module: src/connectors/codebuff.rs (~310 lines impl + 12 tests)
- Recovers originating cwd from the sibling run-state.json so sessions group
by real project path rather than the on-disk sanitized basename
- Walks manicode-dev and manicode-staging channels when present
- Honors CODEBUFF_DATA_DIR (and legacy MANICODE_DATA_DIR) env overrides
- Tolerant parser accepts both bare ChatMessage[] and {messages: [...]} shapes,
ISO-8601-or-epoch timestamps, and aliased role names (human/ai/function)
- Preserves Codebuff's per-message 'credits' field in NormalizedMessage.extra
for downstream consumers (e.g. cass's analytics surface)
Wires the new slug through KNOWN_CONNECTORS, canonical_connector_slug,
env_override_roots, default_probe_roots, default_probe_paths_tilde,
get_connector_factories, and the crate-root re-exports.
All 663 existing tests still pass; 12 new tests cover discovery, parsing,
malformed input, RunState cwd recovery, and credits preservation.
Storage layout reverse-engineered from getagentseal/codeburn PR #124.
e7fffb6 to
4b9bf78
Compare
Real-world Codebuff run-state.json files store the originating cwd at
`sessionState.fileContext.cwd` (with `projectRoot` as a sibling), not
at the top-level `cwd` previously probed. Without this, all sessions
fell back to the sanitized `~/.config/manicode/projects/<basename>`
directory name instead of the real project path.
Validated against a live Codebuff install (19 conversations across 18
projects) — sessions now group by their actual cwd.
- Extend JSON pointer chain in cwd_from_run_state with both
/sessionState/fileContext/{cwd,projectRoot} and the bare
/fileContext/{cwd,projectRoot} fallback, plus /projectRoot.
- Add unit test mirroring the real schema.
Tested against a live Codebuff install ✅Validated this branch against a real Findings & one fix pushed:
End-to-end results after the fix:
Sample of recovered project paths (sanitized basename → real cwd): Full-text search also exercised end-to-end via cass (cass PR #207) — returns correctly-snippeted Codebuff hits with proper role/credits attribution. I think this is ready to come out of draft from a correctness standpoint. Happy to tweak naming / split the cwd-fix into a separate commit if you'd prefer. |
|
Thanks for the very thorough connector implementation — the storage-layout reverse-engineering, the role-name normalization, the credit-bucket preservation in Per project policy I don't merge outside contributions, so this PR will get closed without merging. I appreciate you taking the time to write it up at this level of detail; that makes it easy to evaluate the idea on its merits. Codebuff/Manicode coverage isn't currently on my roadmap, but I've noted the discovery layout (the Companion Sorry for the dead end on this — appreciated. |
Summary
Adds Codebuff (formerly Manicode) as a first-class connector, bringing FAD's supported-agent count to 22. Implementation follows the existing single-file connector pattern established by
aider.rsandamp.rs.Storage layout
Codebuff persists per-chat history under (the legacy
manicodedirectory name is still used on disk by the CLI even after the rebrand):chatIdis the chat's ISO-8601 timestamp with:replaced by-.run-state.jsonto recover the realcwdso sessions group by the originating project directory (not the sanitized folder name).manicode-devandmanicode-stagingchannels are walked automatically when present.CODEBUFF_DATA_DIR(and the legacyMANICODE_DATA_DIR) overrides the base directory.~/.config/codebuff— both layouts are accepted.Layout reverse-engineered from getagentseal/codeburn#124.
What's new
src/connectors/codebuff.rs— new connector, ~310 lines impl + 12 unit tests:find_chat_fileswalks all known bases atmax_depth=6and only accepts paths that have achats/ancestor (to avoid false positives from arbitrarychat-messages.jsonfiles).ChatMessage[]and{ "messages": [...] }shapes; ISO-8601-or-epoch timestamps; aliased role names (human/ai/function/tool_result) normalized to the canonical{user, assistant, system, tool}set; multipart content blocks via the sharedflatten_contenthelper.credits(Codebuff bills in credits, not tokens) preserved intoNormalizedMessage.extrafor downstream consumers like cass's analytics surface.started_at/ended_atderived from in-message timestamps, falling back to file mtime.src/lib.rs— registers the slug across all the points existing connectors use:KNOWN_CONNECTORScanonical_connector_slug(aliases:manicode,codebuff-cli)env_override_roots— honorsCODEBUFF_DATA_DIR/ legacyMANICODE_DATA_DIRdefault_probe_rootsdefault_probe_paths_tilde— emits all 8 candidate locationsCodebuffConnectorsrc/connectors/mod.rs— declarespub mod codebuff;and adds the factory entry toget_connector_factories.CHANGELOG.md— Unreleased entry.Tests
connectors::codebuff::tests::*tests pass:new_creates_connectorfind_chat_files_locates_canonical_layoutfind_chat_files_ignores_unrelated_json(asserts thechats/ancestor guard)parse_chat_file_extracts_basic_messagesparse_chat_file_accepts_messages_wrapperparse_chat_file_uses_run_state_cwd_when_presentparse_chat_file_normalizes_aliased_rolesparse_chat_file_handles_empty_arrayparse_chat_file_invalid_json_returns_errorparse_chat_file_preserves_credits_in_extraexternal_id_uses_chat_id_dirscan_returns_empty_when_no_roots_existNotes
serde_json/walkdir/dotenvyalready pulled in by theconnectorsfeature.extra.creditsso a downstream tool can compute approximate USD via the public $0.01/credit pay-as-you-go rate (the same approach used by getagentseal/codeburn#124).Companion PR
Dicklesworthstone/coding_agent_session_search— adds the cass-side connector stub + README + CHANGELOG and bumps this crate's git pin. The cass PR depends on this one merging first.