codeburn/docs/providers/openclaw.md
Resham Joshi 6746ecc22f
Add CONTRIBUTING.md, docs/architecture.md, and per-provider docs (#284)
Document the contributor onboarding path:
- CONTRIBUTING.md: setup, npm scripts, coding conventions, PR process,
  the block-claude-coauthor enforcement, and the five providers without
  test coverage today (claude, gemini, goose, qwen, antigravity).
- docs/architecture.md: 12-command CLI surface, parser pipeline, three
  cache layers, 14 optimize detectors, and the mac / gnome / build
  layouts with cited line numbers.
- docs/providers/: one file per provider (17 providers plus the shared
  vscode-cline-parser helper). Each covers data path, storage format,
  caching, dedup key, quirks, and a "when fixing a bug here" checklist.

Also fix two pre-existing documentation issues surfaced while writing
the new docs:
- RELEASING.md claimed GitHub Actions auto-publishes the CLI when a
  v* tag is pushed. There is no such workflow; CLI publishing is
  manual via npm publish. Updated the CLI section to reflect reality
  and kept the menubar (mac-v* tag) automation accurate.
- .gitignore had CLAUDE.md unanchored, which on case-insensitive
  filesystems also matched docs/providers/claude.md. Anchored to
  /CLAUDE.md so the root-level memory file stays ignored without
  affecting subdirectory docs.

All cited file paths, line numbers, function names, and test counts
were verified against current code (41 test files, 558 tests passing).
2026-05-09 18:39:41 -07:00

1.6 KiB

OpenClaw

OpenClaw, plus the older Clawdbot / Moltbot / Moldbot lineage.

  • Source: src/providers/openclaw.ts
  • Loading: eager (src/providers/index.ts:8)
  • Test: tests/providers/openclaw.test.ts (192 lines)

Where it reads from

Four directories, all checked on every run (openclaw.ts:62-70):

  • ~/.openclaw/agents
  • ~/.clawdbot/agents
  • ~/.moltbot/agents
  • ~/.moldbot/agents

The legacy directories are kept for users who upgraded from older builds.

Storage format

JSONL (openclaw.ts:242). Each agents directory has a sessions.json index file plus per-session .jsonl files. The parser reads the index when present and falls back to a directory scan if it is missing or stale (openclaw.ts:220-247).

Caching

None.

Deduplication

Per <sessionId>:<dedupId> (openclaw.ts:169).

Quirks

  • Cost is preferred from the provider when reported. OpenClaw emits costUSD in message.usage; the parser uses it directly when present (openclaw.ts:174-177) and only computes from tokens when it is missing.
  • Tokens are reported across input, output, cacheRead, and cacheWrite. Anthropic semantics throughout, no normalization needed.

When fixing a bug here

  1. If the bug is "session not found", check the four legacy dirs. A user might have a stray ~/.moltbot/ that the parser is reading instead of the real ~/.openclaw/.
  2. If the bug is "wrong cost", confirm whether costUSD is present in the source data; the parser trusts it over its own calculation.
  3. The sessions.json index can drift when the user crashes mid-session. Make sure the directory-scan fallback triggers in those cases.