liteagents 2.4.7 → 2.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +24 -8
  2. package/docs/LONG_TERM_MEMORY.md +449 -0
  3. package/installer/cli.js +1 -1
  4. package/package.json +2 -2
  5. package/packages/ampcode/AGENT.md +3 -1
  6. package/packages/ampcode/agents/context-builder.md +14 -12
  7. package/packages/ampcode/commands/docs-builder/templates.md +29 -0
  8. package/packages/ampcode/commands/docs-builder.md +54 -3
  9. package/packages/ampcode/commands/friction/friction.js +2168 -0
  10. package/packages/ampcode/commands/friction.md +139 -0
  11. package/packages/ampcode/commands/remember.md +110 -0
  12. package/packages/claude/CLAUDE.md +3 -1
  13. package/packages/claude/agents/context-builder.md +7 -4
  14. package/packages/claude/commands/friction/friction.js +2168 -0
  15. package/packages/claude/commands/friction.md +139 -0
  16. package/packages/claude/commands/remember.md +110 -0
  17. package/packages/claude/skills/docs-builder/SKILL.md +53 -2
  18. package/packages/claude/skills/docs-builder/references/templates.md +29 -0
  19. package/packages/droid/AGENTS.md +3 -1
  20. package/packages/droid/commands/docs-builder/templates.md +29 -0
  21. package/packages/droid/commands/docs-builder.md +54 -3
  22. package/packages/droid/commands/friction/friction.js +2168 -0
  23. package/packages/droid/commands/friction.md +139 -0
  24. package/packages/droid/commands/remember.md +110 -0
  25. package/packages/droid/droids/context-builder.md +15 -13
  26. package/packages/opencode/AGENTS.md +3 -1
  27. package/packages/opencode/agent/context-builder.md +14 -12
  28. package/packages/opencode/command/docs-builder/templates.md +29 -0
  29. package/packages/opencode/command/docs-builder.md +54 -3
  30. package/packages/opencode/command/friction/friction.js +2168 -0
  31. package/packages/opencode/command/friction.md +139 -0
  32. package/packages/opencode/command/remember.md +110 -0
  33. package/packages/opencode/opencode.jsonc +8 -0
  34. package/packages/subagentic-manual.md +33 -15
  35. package/packages/ampcode/README.md +0 -17
  36. package/packages/claude/README.md +0 -23
  37. package/packages/droid/README.md +0 -17
  38. package/packages/opencode/README.md +0 -17
@@ -0,0 +1,139 @@
1
+ ---
2
+ name: friction
3
+ description: Analyze session behavior patterns
4
+ usage: /friction <sessions-path>
5
+ argument-hint: <sessions-path>
6
+ ---
7
+
8
+ Analyze Claude Code session logs for friction signals, behavioral patterns, and failure antigens.
9
+
10
+ **Guardrails**
11
+ - Favor straightforward, minimal implementations first and add complexity only when requested or clearly required.
12
+ - Keep changes tightly scoped to the requested outcome.
13
+
14
+ **Argument: sessions-path (required)**
15
+
16
+ Path to the Amp sessions directory containing JSONL files.
17
+ - Example: `/friction ~/.config/amp/projects/-home-hamr-PycharmProjects-aurora/`
18
+ - If no argument provided, ask the user for the path. Do NOT guess.
19
+
20
+ **What it does**
21
+
22
+ Runs friction analysis on session JSONL files and writes results to `.amp/friction/` in the current project.
23
+
24
+ **Steps**
25
+
26
+ 1. **Validate path**
27
+ - The argument `$ARGUMENTS` is the sessions path
28
+ - Verify the path exists and contains `.jsonl` files
29
+ - If path doesn't exist or has no JSONL files, tell the user and stop
30
+ - Count total session files found
31
+
32
+ 2. **Run friction.js** (bundled at `commands/friction/friction.js`)
33
+ - Look for friction.js in order:
34
+ 1. `~/.config/amp/commands/friction/friction.js` (installed)
35
+ 2. `packages/ampcode/commands/friction/friction.js` (package development)
36
+ - If found, run: `node <path-to-friction.js> "$ARGUMENTS"`
37
+ - If it does NOT exist anywhere, fall back to running the analysis manually (step 3)
38
+ - If friction.js succeeds, skip to step 7
39
+
40
+ 3. **Manual analysis fallback** (only if friction.js not available)
41
+ - For each `.jsonl` session file in the path:
42
+ - Read the file
43
+ - Extract signals using these patterns:
44
+
45
+ | Signal | Weight | How to detect |
46
+ |---|---|---|
47
+ | `user_intervention` | 10 | User message contains `/stash` |
48
+ | `session_abandoned` | 10 | Last 3 turns have friction > 15 and no `exit_success` |
49
+ | `false_success` | 8 | LLM text contains "done"/"complete"/"fixed" AND next tool result has error |
50
+ | `no_resolution` | 8 | Session has `exit_error` signals but no `exit_success` after them |
51
+ | `tool_loop` | 6 | Same tool called 3+ times with identical arguments |
52
+ | `rapid_exit` | 6 | <3 turns AND ends with error |
53
+ | `interrupt_cascade` | 5 | Multiple `request_interrupted` within 60 seconds |
54
+ | `user_curse` | 5 | User message matches profanity patterns |
55
+ | `request_interrupted` | 2.5 | Turn has `is_interrupted: true` or ESC/Ctrl+C signal |
56
+ | `exit_error` | 1 | Tool result has non-zero exit code |
57
+ | `repeated_question` | 1 | User asks same question twice (fuzzy match) |
58
+ | `long_silence` | 0.5 | >10 minute gap between turns |
59
+ | `user_negation` | 0.5 | User message starts with "no", "wrong", "didn't work" |
60
+ | `compaction` | 0.5 | System message indicates context compaction |
61
+
62
+ 4. **Score each session**
63
+ - Accumulate weighted signal scores (no subtraction, only accumulation)
64
+ - Track peak friction score
65
+ - Classify session quality:
66
+ - **BAD**: has `user_intervention` or `session_abandoned`
67
+ - **FRICTION**: has `user_curse` or `false_success`
68
+ - **ROUGH**: peak friction >= 15, no intervention
69
+ - **OK**: low friction, completed normally
70
+ - **ONE-SHOT**: single turn, not interactive (filter out)
71
+
72
+ 5. **Aggregate stats**
73
+ - Count sessions by quality
74
+ - Calculate BAD rate
75
+ - Identify worst and best sessions
76
+ - Daily trend if sessions span multiple days
77
+
78
+ 6. **Extract antigen candidates from BAD sessions**
79
+ - For each BAD session, extract:
80
+ - Anchor signal (what triggered BAD classification)
81
+ - Tool sequence around the failure
82
+ - Error messages
83
+ - Pattern description
84
+ - Write as antigen candidates
85
+
86
+ 7. **Write output to `.amp/friction/`**
87
+ - Create `.amp/friction/` directory if it doesn't exist
88
+ - Write these files:
89
+ - `friction_analysis.json` — per-session breakdown (quality, peak, signals)
90
+ - `friction_summary.json` — aggregate stats, verdict, daily trend
91
+ - `friction_raw.jsonl` — all raw signals with timestamps
92
+ - `antigen_candidates.json` — raw extracted failure patterns
93
+ - `antigen_clusters.json` — clustered patterns (primary artifact for /remember)
94
+ - `antigen_review.md` — human-readable clustered review
95
+
96
+ 8. **Report to user**
97
+ - Sessions analyzed count
98
+ - BAD / FRICTION / ROUGH / OK counts
99
+ - BAD rate percentage
100
+ - Worst session ID and peak friction
101
+ - Path to `antigen_review.md` for review
102
+ - Remind: run `/remember` to consolidate into project memory
103
+
104
+ **Output format for antigen_review.md**
105
+
106
+ ```markdown
107
+ # Friction Antigen Clusters
108
+
109
+ Generated: [date]
110
+ BAD sessions: [count] | Raw candidates: [count] | Clusters: [count]
111
+
112
+ ## Cluster Summary
113
+
114
+ | # | Signal | Tool Pattern | Count | Sessions | Score | Median Peak |
115
+ |---|--------|-------------|-------|----------|-------|-------------|
116
+ | 1 | false_success | Bash,Bash | 35 | 23 | 280 | 73 |
117
+ | 2 | user_intervention | (none) | 34 | 24 | 340 | 65 |
118
+
119
+ ## Cluster 1: false_success | Bash,Bash
120
+
121
+ **Occurrences:** 35 across 23 sessions | **Score:** 280
122
+
123
+ ### User Context (what the user said)
124
+ > [actual user quote from session]
125
+
126
+ ### Errors
127
+ [error messages if any]
128
+
129
+ ### Files involved
130
+ - [file paths]
131
+ ```
132
+
133
+ **File locations**
134
+ - Design doc: `docs/02-features/memory/LONG_TERM_MEMORY.md`
135
+ - Input: JSONL session files from `$ARGUMENTS` path
136
+ - Output: `.amp/friction/` (project-local)
137
+ - JS script: `commands/friction/friction.js` (bundled alongside this command)
138
+ - Python equivalent: `scripts/friction.py` (aurora users, same logic)
139
+ - Manual fallback: built into this command if friction.js unavailable
@@ -0,0 +1,110 @@
1
+ ---
2
+ name: remember
3
+ description: Consolidate stashes + friction into project memory
4
+ usage: /remember
5
+ ---
6
+
7
+ Consolidate session stashes and friction analysis into a single project-local MEMORY.md, then inject into AGENT.md.
8
+
9
+ **Guardrails**
10
+ - Favor straightforward, minimal implementations first and add complexity only when requested or clearly required.
11
+ - Keep changes tightly scoped to the requested outcome.
12
+
13
+ **What it does**
14
+
15
+ Reads all raw material (`.amp/stash/*.md` + `.amp/friction/antigen_clusters.json`), extracts durable facts, episodes, and behavioral preferences into a single `.amp/memory/MEMORY.md`, then injects a managed memory section into `AGENT.md`.
16
+
17
+ **Steps**
18
+
19
+ 1. **Gather sources**
20
+ - Read all `.amp/stash/*.md` files in the current project
21
+ - Check for friction output at `.amp/friction/antigen_clusters.json` (preferred) or `.amp/friction/antigen_review.md` (fallback)
22
+ - Read existing `.amp/memory/MEMORY.md` if it exists — create dir if missing
23
+ - Read processed manifest at `.amp/memory/.processed` — skip already-processed stashes
24
+ - If no unprocessed stashes, report "nothing to consolidate" and stop
25
+
26
+ 2. **Extract from unprocessed stashes** (use Task tool with sonnet model for each)
27
+ - For each unprocessed stash, call sonnet to extract:
28
+ - **FACTS** (atomic, one-line): stable preferences, decisions, corrections, explicit "remember this"
29
+ - **EPISODE** (3-5 bullet narrative): what was the goal, what was tried, outcome, lesson
30
+ - **SKIP**: code details, file paths, errors, mechanical steps, LLM responses
31
+ - Collect all new facts and episodes
32
+
33
+ 3. **Merge into MEMORY.md**
34
+ - Read existing `.amp/memory/MEMORY.md` and parse its three sections (## Facts, ## Episodes, ## Preferences)
35
+ - **Facts section**: call sonnet with existing facts + newly extracted facts
36
+ - Rules: new updates replace old, contradictions keep new version, duplicates dropped
37
+ - Keep facts atomic, one line each
38
+ - **Episodes section**: append new episode entries (append-only, timestamped, no dedup)
39
+ - **Preferences section**: only update if friction output exists (step 4)
40
+ - Write merged result to `.amp/memory/MEMORY.md` in this format:
41
+
42
+ ```markdown
43
+ # Project Memory
44
+ > Auto-generated by /remember. Do not edit manually.
45
+
46
+ ## Facts
47
+ - [atomic fact 1]
48
+ - [atomic fact 2]
49
+
50
+ ## Episodes
51
+ ### YYYY-MM-DD - [title]
52
+ - [bullet narrative]
53
+
54
+ ### YYYY-MM-DD - [title]
55
+ - [bullet narrative]
56
+
57
+ ## Preferences
58
+ ### High Confidence
59
+ - [pattern] (evidence: [count] observations)
60
+
61
+ ### Medium Confidence
62
+ - [pattern] (evidence: [count] observations)
63
+
64
+ ### Low Confidence
65
+ - [pattern] (evidence: [count] observations)
66
+ ```
67
+
68
+ 4. **Distill friction into preferences** (only if friction output exists)
69
+ - Read `.amp/friction/antigen_clusters.json` — this contains clustered failure patterns with counts, user_context quotes, and tool sequences
70
+ - For the **top 10 clusters** (by score), extract the `contexts` field — these are the actual user messages that show behavioral patterns
71
+ - Call sonnet with:
72
+ - The top 10 clusters (signal, tool_pattern, count, sessions, contexts, errors)
73
+ - Existing Preferences section from MEMORY.md
74
+ - Extract BEHAVIORAL preferences (patterns demonstrated, not stated) — the user_context quotes are the primary evidence
75
+ - Confidence tiers:
76
+ - **High Confidence**: 5+ observations — available via @MEMORY.md
77
+ - **Medium Confidence**: 3+ observations — observing, not loaded
78
+ - **Low Confidence**: <3 observations — needs more data
79
+ - Promote/demote based on new evidence
80
+ - Update the Preferences section in MEMORY.md
81
+
82
+ 5. **Inject memory reference into AGENT.md**
83
+ - Compose the section between `<!-- MEMORY:START -->` and `<!-- MEMORY:END -->` markers:
84
+ ```
85
+ <!-- MEMORY:START -->
86
+ @MEMORY.md
87
+ <!-- MEMORY:END -->
88
+ ```
89
+ - The `@MEMORY.md` reference points to `.amp/memory/MEMORY.md` — Claude loads the full file directly, so no inline duplication is needed
90
+ - If AGENT.md already has MEMORY markers, replace the section between them
91
+ - If AGENT.md has no MEMORY markers, append the section at the end
92
+ - If no AGENT.md exists, create one with just the memory section
93
+
94
+ 6. **Update processed manifest**
95
+ - Append paths of newly processed stashes to `.amp/memory/.processed`
96
+
97
+ 7. **Report to user**
98
+ - Number of stashes processed
99
+ - Facts count (total, new)
100
+ - Episodes count (total, new)
101
+ - Preferences count by confidence tier
102
+ - Confirm MEMORY.md and AGENT.md updated
103
+
104
+ **File locations (all project-local)**
105
+ - Memory file: `.amp/memory/MEMORY.md` (single source of truth, referenced as @MEMORY.md)
106
+ - Stash files: `.amp/stash/*.md`
107
+ - Friction output: `.amp/friction/antigen_clusters.json` (clustered patterns with user contexts)
108
+ - Friction fallback: `.amp/friction/antigen_review.md` (human-readable clusters)
109
+ - Processed manifest: `.amp/memory/.processed`
110
+ - Output: `AGENT.md` (managed MEMORY section with @MEMORY.md reference)
@@ -37,15 +37,17 @@ These subagents are available when using Claude Code CLI. Droid can reference th
37
37
  | testing-anti-patterns | Prevents testing mock behavior and production pollution with test-only methods | /testing-anti-patterns <testing-scenario> | true |
38
38
  | verification-before-completion | Requires running verification commands before making any success claims | /verification-before-completion <work-to-verify> | true |
39
39
 
40
- ### Commands (10 total)
40
+ ### Commands (12 total)
41
41
 
42
42
  | ID | Description | Usage |
43
43
  |---|---|---|
44
44
  | debug | Debug an issue systematically using structured investigation techniques | /debug <issue-description> |
45
45
  | explain | Explain code for someone new to the codebase | /explain <code-section> |
46
+ | friction | Analyze session logs for failure patterns and behavioral signals | /friction <sessions-path> |
46
47
  | git-commit | Analyze changes and create intelligent git commits | /git-commit |
47
48
  | optimize | Analyze and optimize performance issues | /optimize <target-area> |
48
49
  | refactor | Refactor code while maintaining behavior and tests | /refactor <code-section> |
50
+ | remember | Consolidate stashes + friction into project memory | /remember |
49
51
  | review | Comprehensive code review including quality, tests, and architecture | /review |
50
52
  | security | Security vulnerability scan and analysis | /security |
51
53
  | ship | Pre-deployment verification checklist | /ship |
@@ -91,13 +91,15 @@ digraph ContextBuilder {
91
91
 
92
92
  **Flow:** CLAUDE.md → KNOWLEDGE_BASE.md → docs/*.md (progressive disclosure)
93
93
 
94
- **Rule:** Plain text paths only (no @ triggers) in Tier 1 and 2
94
+ **Rule:** Plain text paths only (no @ triggers) in Tier 1 and 2, with ONE exception:
95
+
96
+ **Permanent reference:** `@MEMORY.md` from `.claude/memory/MEMORY.md` — this is the only file allowed to use @ for direct loading. It contains project memory (facts, episodes, preferences) auto-generated by `/remember`. Always check for it during discovery. If it exists, include it as a source and ensure CLAUDE.md references it.
95
97
 
96
98
  # Anti-Patterns
97
99
 
98
100
  | Don't | Why |
99
101
  |-------|-----|
100
- | @ triggers in markdown | Bloats context window |
102
+ | @ triggers in markdown (except @MEMORY.md) | Bloats context window |
101
103
  | Comprehensive content in KNOWLEDGE_BASE.md | It's a TOC, not a database |
102
104
  | Embedded agent/skill definitions | Don't duplicate ~/.claude/ |
103
105
  | ASCII trees (├─ └─) | Use arrows (→) or tables |
@@ -106,7 +108,8 @@ digraph ContextBuilder {
106
108
  # Workflow
107
109
 
108
110
  ## 1. Discovery
109
- Scan: README, /docs, *.md → Identify project type (app, lib, monorepo) → Ask what's needed every session
111
+ Scan: README, /docs, *.md, `.claude/memory/MEMORY.md` → Identify project type (app, lib, monorepo) → Ask what's needed every session
112
+ If `.claude/memory/MEMORY.md` exists, read it first — it contains accumulated project knowledge from previous sessions.
110
113
 
111
114
  ## 2. Tier 3: docs/*.md (Comprehensive)
112
115
  Create detailed docs: `architecture.md`, `development.md`, `api-reference.md`, `troubleshooting.md`
@@ -115,7 +118,7 @@ Create detailed docs: `architecture.md`, `development.md`, `api-reference.md`, `
115
118
  Format: `## Topic` + 1-2 sentence summary + `→ docs/file.md`
116
119
 
117
120
  ## 4. Tier 1: CLAUDE.md (Essentials)
118
- Include: Project summary (2-3 sentences), Tech stack (list), Commands (essential only), Key patterns (top 3), Pointer to `docs/KNOWLEDGE_BASE.md`
121
+ Include: Project summary (2-3 sentences), Tech stack (list), Commands (essential only), Key patterns (top 3), Pointer to `docs/KNOWLEDGE_BASE.md`, `@MEMORY.md` reference (if `.claude/memory/MEMORY.md` exists)
119
122
 
120
123
  ## 5. Update Existing (when CLAUDE.md exists)
121
124
  Read existing → Preserve structure → Merge new info → Update Tier 2/3 if needed → Validate limits