feat: reliable+free capture, pluggable AI backend, complete, conventions→CLAUDE.md (0.21.0)#38
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
One branch, one release (as requested) — the capture-reliability + multi-backend + always-on-conventions work.
What's in it
task-journal capture offno-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.LlmBackendtrait + adapters; defaultclaude-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&dreamroute through it.complete <task>— "make this task complete from its transcripts" (alias fordream --task); free with--backend ollama.consolidate --write-claude-mdwrites 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-onlymigrate_project/tmp-collision failures unrelated; green in CI.)Notes
No hook-wiring change — the existing
nudgehook 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