mirror of
https://github.com/lukaszraczylo/claude-adam.git
synced 2026-07-14 04:27:06 +00:00
6d8ff37cb2
Bug fixes (HIGH):
- adam-observe.mjs: errorFingerprint no longer false-positives when
toolResponse.is_error === false; ERROR_RE only used as fallback when
is_error is undefined.
- adam-observe.mjs: resetSessionLocal now clears tool_window so retry_loop
cannot fire on the first tool of a new session by matching prior session.
- adam-archive.mjs: ts dedup uses Map<ts, count> instead of Set<ts>; two
journal entries sharing a millisecond are no longer both archived when
only one is referenced in source_entries.
- adam-nudge.mjs: only counts proposal filenames matching
/^\d{4}-\d{2}-\d{3}-/ pattern; README/notes in proposals/ no longer bump.
- skills/adam-self-improvement/SKILL.md: contradiction_flag veto now applied
at apply time (carry-over from earlier review).
Test isolation:
- adam/tests/run-tests.sh: ALWAYS runs against an isolated $HOME under
mktemp -d. Previously truncated live ~/.claude/adam/journal.jsonl on
every run — destructive on production state.
Conciseness:
- agents/adam.md: -19 LOC (cuts: vestigial cursor sentence, duplicate
not-do bullets, blast-radius bullet collapse, Inputs paths delegate to
SKILL.md, win-cluster-vs-struggle-cluster commentary already enforced
by cluster-key separation, # Overlap section spec compressed).
- skills/adam-self-improvement/SKILL.md: -4 LOC (framing paragraph, dead
catch-all bullet for non-eligible types).
Auto-prune script DELETED:
- The cumulative-count primitive cannot distinguish "never used" from
"used before tracking began"; mtime gate is meaningless for installed
files. Auto-prune deferred to v0.4 with a per-key lastSeen schema.
Cross-platform:
- macOS (BSD coreutils) and Linux (Alpine, glibc + musl) verified.
- All scripts use portable forms (stat -f || stat -c, mktemp -d -t).
- README documents platform support explicitly.
DX overhaul:
- install.sh: hardened — supports `curl | bash` via auto-clone,
--version=vX.Y.Z pinning, --yes / --dry-run flags, jq-based
settings.json merge with diff prompt and backup, conservative file
copy that detects local mtime drift and writes <file>.adam-new
instead of clobbering, idempotent across re-runs.
- adam-uninstall.sh: NEW. Soft-archives ~/.claude/adam/ to .bak.<ts>/
by default; --purge to delete; --yes for non-interactive; jq-based
settings.json cleanup with diff prompt.
- README.md: curl one-liner install + version-pinned variant at top,
What's New section through v0.3.1, upgrade-safe data files callout,
uninstaller documentation, platform support note, expanded rubric
showing skill_edit gate.
Test count: 27 passed, 0 failed (was 27 — no regression).
8.1 KiB
8.1 KiB
name, description
| name | description |
|---|---|
| adam-self-improvement | Use when the user types /reflect, asks "what has adam learned", asks to "review proposals", or wants to inspect the self-improvement queue. Dispatches the adam subagent to analyse the observation journal and presents proposals for approve/reject/edit. |
adam-self-improvement
When to invoke
- User types
/reflect - User asks: "what has adam learned", "any proposals", "review the queue"
- SessionStart nudge said proposals are pending and user wants to act on it
Protocol
1. Dispatch the analyst
Use the Agent tool with subagent_type: "adam" and prompt:
Run a single analysis pass.
Inputs:
- journal_path: ~/.claude/adam/journal.jsonl
- state_path: ~/.claude/adam/state.json
- usage_path: ~/.claude/adam/usage.json
- proposals_dir: ~/.claude/adam/proposals/
- applied_dir: ~/.claude/adam/applied/
- rejected_dir: ~/.claude/adam/rejected/
- transcripts_root: ~/.claude/projects/
- skills_root: ~/.claude/skills/
Follow your system prompt exactly. Emit a single JSON punch list as your final message.
Wait for return.
2. Auto-apply high-confidence items
For each id in high_confidence:
- Read the proposal file from
~/.claude/adam/proposals/<id>-*.md. - Verify in front of the user: print
id,target,confidence,blast_radius,cross_session_evidence,auto_apply_eligible. - Apply the change:
- For
skill_new:mkdir -p ~/.claude/skills/<slug>/, thenWritethe proposal's# Proposed changebody to~/.claude/skills/<slug>/SKILL.md. After write, print: "skill<slug>written to~/.claude/skills/<slug>/SKILL.md— activates immediately — Claude Code v2.1.0+ auto-hot-reloads user-level skills, no restart needed." - For
memory:Writethe proposal's# Proposed changebody (which MUST include the auto-memory frontmatter — see "Memory drafting protocol" inagents/adam.md) to the path intarget. Then updateMEMORY.mdindex with a one-line pointer. - For
skill_edit: enforce the apply-time gate before writing.- Verify proposal frontmatter has
auto_apply_eligible: true. If not, abort and queue for review. - Read
targetSKILL.md, capturecurrent_bytesfrom a fresh stat — do NOT trust frontmatterbytes_before. - Verify diff in
# Proposed change:- Unified-diff format.
- Zero
-lines on existing SKILL.md content (additions only). - Total
+lines ≤ 30. If any check fails, print one-line refusal reason, leave proposal inproposals/, continue.
- Cooldown re-check: scan
applied/frontmatter fortargetmatching this andlast_auto_editnewer than 7 days ago. Refuse if found. - Blacklist re-check: scan
rejected/frontmatter fortargetmatching this andauto_apply_blacklist: truenewer than 30 days ago. Refuse if found. - Apply via
Edittool (append the new section per the diff). Never useWriteon existing SKILL.md. - Re-stat target. If new size exceeds
2 * current_bytes(captured in step 2), revert viaEdit(remove the just-appended section) and refuse — print refusal reason. - Add
last_auto_edit: <iso8601 utc now>to the proposal frontmatter before moving it. - Tell user: "skill
<slug>extended (added lines) — auto-applied via win-evidence gate."
- Verify proposal frontmatter has
- For
- Move proposal to
~/.claude/adam/applied/<UTC-ts>-<id>.md. - Archive consumed journal entries:
node ~/.claude/adam/scripts/adam-archive.mjs ~/.claude/adam/applied/<UTC-ts>-<id>.md— moves entries listed in proposal'ssource_entriesfromjournal.jsonltojournal/actioned-<id>.jsonlso subsequent/reflectruns do not re-cluster them.
Print: auto-applied N proposals: [ids].
3. Walk the queue
For each id in queued:
a. Read and display the proposal in full (frontmatter + body). b. Ask the user: approve / reject / edit. c. On approve:
- For
claude_md_edit: backupcp ~/.claude/CLAUDE.md ~/.claude/adam/applied/<ts>-claude-md-backup.mdfirst. - For
deletion:mkdir -p ~/.claude/adam/trash/<ts>thenmvthe artifact into it. Print restoration command. - For
skill_new:mkdir -p ~/.claude/skills/<slug>/, then write# Proposed changebody to<slug>/SKILL.md. Tell user: "skill<slug>written — activates immediately (CC v2.1.0+ auto-hot-reload)." - For
skill_edit: apply the unified diff in# Proposed changeto the existing SKILL.md attarget(append-only — never replace existing content). - For
memory: write# Proposed changebody (must include auto-memory frontmatter) totargetand updateMEMORY.mdindex with a one-line pointer. - For all others: apply via Write/Edit per the proposal's
# Proposed change. - Move proposal to
~/.claude/adam/applied/<ts>-<id>.md. - Archive:
node ~/.claude/adam/scripts/adam-archive.mjs ~/.claude/adam/applied/<ts>-<id>.md. d. On reject: ask for reason in one line. Append# Reason\n<reason>to proposal body. If the proposaltypeisskill_edit, ALSO addauto_apply_blacklist: trueto its frontmatter (so future reflects skip auto-apply on this target for 30 days). Move to~/.claude/adam/rejected/<id>.md. Archive:node ~/.claude/adam/scripts/adam-archive.mjs ~/.claude/adam/rejected/<id>.md. e. On edit: ask the user for the change, edit the proposal in place, then loop back to step 3a for that same id.
4. Handle failures
If apply fails (file write error, target missing): leave proposal in proposals/, append # Apply error\n<error> to its body. Tell the user. Do not move it.
5. Summary
End with one block:
adam reflect summary:
observations processed: <new>
auto-applied: <N>
approved: <N>
rejected: <N>
edited+approved: <N>
failed: <N>
Karpathy constraints (you must enforce on each apply)
Before writing any proposal:
- Confirm
# Assumptionssection is non-empty. - Confirm
# Diagnosissection exists and contains all four labelled lines (Trigger:,Action:,Mismatch:,Outcome:) AND at least one backtick-wrapped quote ≤80 chars in the Outcome line. Refuse if missing or malformed — agent must redraft per the "Diagnosis drafting protocol" inagents/adam.md. - Confirm
# Success criterionsection is non-empty and runnable. - Confirm change is ≤50 LOC for non-
skill_new, or ≤80 LOC forskill_newbody. If larger, ask the user once: "this proposal is N LOC — proceed?" - For
claude_md_edit: confirm 3+ distinct cwds in the# Whysection. - For
deletion: confirm both criteria (a) and (b) from the agent's special handling are documented in the proposal. - For
skill_new: confirm the slug doesn't collide with any existing skill in~/.claude/skills/. If it does, refuse and ask user to rename. - For
skill_edit: confirm the diff is append-only (no-lines that remove existing content) and that target SKILL.md exists. When auto-applying, ALSO re-verify the eligibility gate steps in §2 (cooldown, blacklist, byte cap) before anyEditcall — never trust frontmatter alone. - For
skill_editwithauto_apply_eligible: true: confirmcontradiction_flagis absent or null in frontmatter. Refuse auto-apply ifcontradiction_flagis set with any non-empty value (treat the agent's flag as a hard veto on auto-apply; user can still manually approve in walk-the-queue if they disagree with the heuristic). - For
memory: confirm# Proposed changebody starts with---frontmatter containing required fieldsname,description,type,originSessionId. Refuse if frontmatter missing — agent must redraft per the Memory drafting protocol. - Confirm
source_entriesis present in proposal frontmatter as a non-empty list (used for archive). Warn (do not refuse) if missing — legacy proposals from before v0.2.0 won't have it.
If any check fails, refuse to apply and ask the user how to proceed.
Things you MUST NOT do
- Do not auto-apply anything not in
high_confidence. - Do not invoke other skills during a
/reflectrun. - Do not modify
settings.jsonwithout explicit user yes. - Do not hard-delete anything. Use
mvto~/.claude/adam/trash/<ts>/. - Do not bypass the rubric (
auto_apply_eligible: falsemeans queue, full stop).