Skip to content

feat: reliable+free capture, pluggable AI backend, complete, conventions→CLAUDE.md (0.21.0)#38

Merged
Shahinyanm merged 6 commits into
mainfrom
feat/reliable-capture-multibackend
Jun 13, 2026
Merged

feat: reliable+free capture, pluggable AI backend, complete, conventions→CLAUDE.md (0.21.0)#38
Shahinyanm merged 6 commits into
mainfrom
feat/reliable-capture-multibackend

Conversation

@Shahinyanm

Copy link
Copy Markdown
Member

One branch, one release (as requested) — the capture-reliability + multi-backend + always-on-conventions work.

What's in it

  1. Adaptive self-tagging nudge — base "record as you go" reminder always, escalates when a session did substantial work but logged little. Caveman-style constant context injection, non-blocking, free.
  2. Capture kill-switchtask-journal capture off no-ops the realtime ingest-hook capture path (resume still runs) even in a running session (the hook re-invokes the on-disk binary). Silences a stale auto-capture hook without a restart.
  3. Pluggable LLM backendLlmBackend trait + adapters; default claude-p (subscription, no key), or --backend/TJ_BACKEND: anthropic, openai (OpenAI/Codex), ollama (free, local). One OpenAI-compatible adapter covers OpenAI/Codex/Ollama via base_url. Heuristic dropped — AI-only, skip when no backend (never fabricate). consolidate & dream route through it.
  4. complete <task> — "make this task complete from its transcripts" (alias for dream --task); free with --backend ollama.
  5. Conventions → always-onconsolidate --write-claude-md writes the distilled conventions into a managed, regenerable block in ./CLAUDE.md, so every session sees them guaranteed.

Tests

New: nudge escalation thresholds, capture kill-switch, 6 llm-factory/adapter (mockito OpenAI+Anthropic), dream LlmDreamBackend, complete, conventions-block append/replace, consolidate --write-claude-md. fmt + clippy clean on default and --no-default-features. (Pre-existing WSL-only migrate_project /tmp-collision failures unrelated; green in CI.)

Notes

No hook-wiring change — the existing nudge hook gains the adaptive behavior automatically. Default everyday experience stays free; paid ops (consolidate/dream/complete) are manual, one call each, and free via Ollama.

🤖 Generated with Claude Code

Shahinyanm and others added 6 commits June 13, 2026 15:57
Reliable, free, non-blocking capture (epic claude-memory-isg, build order:
self-tagging first).

The UserPromptSubmit nudge is now adaptive: it always emits the base
"record as you go" reminder, and — when the session has done substantial work
(transcript ≥60KB) but logged few journal entries (<2 stamped with this
session_id, counted from the JSONL tail) — it escalates with a ⚠ "log the key
decisions NOW" line. Same proven mechanism as the active caveman mode:
constant lightweight context injection every turn, never a blocking gate.

- run_nudge / nudge_escalation_text (pure, unit-tested thresholds) /
  count_session_events_tail. is_terminal guard so manual runs don't block on
  stdin. No model, no spawn, no cost.

Next pieces (same branch, one release at end): unified pluggable LLM backend
(claude -p default / API / Agent SDK / Codex / Ollama-free), heuristic dropped,
dream/consolidate routed through it, conventions → CLAUDE.md.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…te consolidate — piece 2/5

A small LlmBackend trait + adapters so this public package grows new providers
without touching callers (epic claude-memory-isg). Default claude-p
(subscription, no key); pick others via TJ_BACKEND / --backend.

- tj-core::llm: LlmBackend { complete, name }, backend_from_env(explicit) →
  Some(usable) / None(unavailable→skip) / Err(unknown name). Adapters:
  ClaudeCliBackend (default, run_claude_json), AnthropicBackend (API), and one
  OpenAiBackend covering OpenAI, Codex, and **Ollama** (free local — Ollama's
  OpenAI-compatible /v1) by pointing base_url + optional key.
- consolidate refactored: heuristic-free already; summarize() now routes through
  llm::backend_from_env, drops its bespoke Anthropic client + claude-p path.
  `consolidate --backend <name>`; default claude-p.
- Tests: factory resolution (unknown errs, no-key None, ollama always, etc.),
  mockito for OpenAI + Anthropic adapters (6 llm); consolidate parse/build/skip
  (4); CLI consolidate forces TJ_BACKEND=anthropic against the mock. Green on
  default and --no-default-features.

Next: route dream through llm + `complete` command; conventions → CLAUDE.md.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ngest-hook

A `.capture-disabled` marker in the data dir makes ingest-hook skip the
realtime capture path (the read-only SessionStart resume still runs). Because
the hook re-invokes the on-disk binary on every event, dropping the marker
stops a stale auto-capture hook in an ALREADY-RUNNING session without a
restart — env vars don't propagate into hook subprocesses, and a restart loses
the session.

- `task-journal capture off` writes the marker; `capture on` removes it.
- ingest-hook checks it right after resolving the hook kind, before any
  capture, skipping everything except SessionStart resume.

Motivated live: this long session still ran the pre-0.14.4 plugin's
PostToolUse hook, which was recording Edit/MCP tool calls as junk "rejection"
events; `capture off` silenced it immediately.

Test: capture off → an auto-opening prompt records no task; capture on clears.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… — piece 3/5

dream now gets the same backend choice as everything else, and there's a
friendly per-task alias (epic claude-memory-isg).

- tj-core::dream::llm_backend::LlmDreamBackend adapts any llm::LlmBackend into a
  DreamBackend: build the dream prompt → one completion → parse the JSON array
  of missed events (shared fence-stripping parser).
- tj-cli: dream selection refactored into run_dream_op(), routed through
  llm::backend_from_env (default claude-p; --backend / TJ_BACKEND for anthropic
  / openai / ollama-free); skips cleanly when no backend is available.
- New `task-journal complete <task> [--dry-run] [--backend]` = dream scoped to a
  task's sessions — "make this task complete from its transcripts" in one
  obvious command. Free with `--backend ollama`.

Tests: parse fence/empty + LlmDreamBackend over a fake llm (3 core); complete
exits cleanly with no sessions (1 cli). Clean on default and
--no-default-features.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… piece 5/5

Closes the gap where auto-derived project conventions were only available
on-demand (search/resume), never guaranteed like hand-written CLAUDE.md rules
(epic claude-memory-isg).

- tj-core::consolidate: render_conventions_block / upsert_conventions_block —
  a managed block delimited by `<!-- task-journal:conventions:start/end -->`
  that's inserted or regenerated in place, never touching hand-written content.
- tj-cli: `consolidate --write-claude-md` writes this run's distilled
  conventions into ./CLAUDE.md so every future session sees them on the same
  guaranteed always-on path as your hand rules. Re-running regenerates the
  block (idempotent, no duplication).

Tests: block append-then-replace keeps hand content + single block (core);
CLI --write-claude-md produces the managed block with a fact (cli). Clean on
default and --no-default-features.

All functional pieces of the epic done; next is the single release.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… complete, conventions→CLAUDE.md

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Shahinyanm Shahinyanm merged commit cf1c011 into main Jun 13, 2026
7 checks passed
@Shahinyanm Shahinyanm deleted the feat/reliable-capture-multibackend branch June 13, 2026 12:35
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