chapterhouse 0.13.0 → 0.14.0

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 (118) hide show
  1. package/dist/api/route-coverage.test.js +1 -3
  2. package/dist/api/server.js +0 -2
  3. package/dist/api/server.test.js +0 -281
  4. package/dist/config.js +3 -85
  5. package/dist/config.test.js +5 -123
  6. package/dist/copilot/agents.js +25 -13
  7. package/dist/copilot/agents.test.js +10 -11
  8. package/dist/copilot/memory-coordinator.js +12 -227
  9. package/dist/copilot/memory-coordinator.test.js +31 -250
  10. package/dist/copilot/orchestrator.js +8 -66
  11. package/dist/copilot/orchestrator.test.js +9 -467
  12. package/dist/copilot/skills.js +15 -1
  13. package/dist/copilot/system-message.js +9 -15
  14. package/dist/copilot/system-message.test.js +9 -22
  15. package/dist/copilot/tools/index.js +3 -3
  16. package/dist/copilot/tools-deps.js +1 -1
  17. package/dist/copilot/tools.agent.test.js +6 -0
  18. package/dist/copilot/tools.inventory.test.js +1 -14
  19. package/dist/daemon.js +7 -9
  20. package/dist/memory/assets.js +33 -0
  21. package/dist/memory/domains.js +58 -0
  22. package/dist/memory/domains.test.js +47 -0
  23. package/dist/memory/git.js +66 -0
  24. package/dist/memory/git.test.js +32 -0
  25. package/dist/memory/history.js +19 -0
  26. package/dist/memory/hottier.js +32 -0
  27. package/dist/memory/hottier.test.js +33 -0
  28. package/dist/memory/index.js +5 -13
  29. package/dist/memory/instructions.js +17 -0
  30. package/dist/memory/manager.js +84 -0
  31. package/dist/memory/markdown.js +78 -0
  32. package/dist/memory/markdown.test.js +42 -0
  33. package/dist/memory/mutex.js +18 -0
  34. package/dist/memory/path-guard.js +26 -0
  35. package/dist/memory/path-guard.test.js +27 -0
  36. package/dist/memory/paths.js +12 -0
  37. package/dist/memory/reconcile.js +75 -0
  38. package/dist/memory/reconcile.test.js +50 -0
  39. package/dist/memory/scaffold.js +37 -0
  40. package/dist/memory/scaffold.test.js +52 -0
  41. package/dist/memory/tools/commit-wrapper.js +32 -0
  42. package/dist/memory/tools/domains.js +73 -0
  43. package/dist/memory/tools/domains.test.js +66 -0
  44. package/dist/memory/tools/git.js +52 -0
  45. package/dist/memory/tools/index.js +25 -0
  46. package/dist/memory/tools/read.js +101 -0
  47. package/dist/memory/tools/read.test.js +69 -0
  48. package/dist/memory/tools/search.js +103 -0
  49. package/dist/memory/tools/search.test.js +63 -0
  50. package/dist/memory/tools/sessions.js +45 -0
  51. package/dist/memory/tools/sessions.test.js +74 -0
  52. package/dist/memory/tools/shared.js +7 -0
  53. package/dist/memory/tools/write.js +116 -0
  54. package/dist/memory/tools/write.test.js +107 -0
  55. package/dist/memory/walk.js +39 -0
  56. package/dist/store/repositories/sessions.js +40 -0
  57. package/dist/wiki/consolidation.js +3 -31
  58. package/dist/wiki/consolidation.test.js +0 -19
  59. package/dist/wiki/frontmatter.js +18 -6
  60. package/dist/wiki/frontmatter.test.js +40 -0
  61. package/package.json +1 -1
  62. package/skills/system/evolve/SKILL.md +131 -0
  63. package/skills/system/foresight/SKILL.md +116 -0
  64. package/skills/system/history/SKILL.md +58 -0
  65. package/skills/system/housekeeping/SKILL.md +185 -0
  66. package/skills/system/reflect/SKILL.md +214 -0
  67. package/skills/system/scenario/SKILL.md +198 -0
  68. package/skills/system/setup/SKILL.md +113 -0
  69. package/web/dist/assets/{WikiEdit-CGRxNazp.js → WikiEdit-BTsiBfbC.js} +2 -2
  70. package/web/dist/assets/{WikiEdit-CGRxNazp.js.map → WikiEdit-BTsiBfbC.js.map} +1 -1
  71. package/web/dist/assets/{WikiGraph-eVWNhZS3.js → WikiGraph-COOZbUeH.js} +2 -2
  72. package/web/dist/assets/{WikiGraph-eVWNhZS3.js.map → WikiGraph-COOZbUeH.js.map} +1 -1
  73. package/web/dist/assets/{index-gAvLNEvJ.js → index-aCcfpaLM.js} +101 -101
  74. package/web/dist/assets/index-aCcfpaLM.js.map +1 -0
  75. package/web/dist/index.html +1 -1
  76. package/dist/api/routes/memory.js +0 -475
  77. package/dist/api/routes/memory.test.js +0 -108
  78. package/dist/copilot/tools/memory.js +0 -678
  79. package/dist/copilot/tools.memory.test.js +0 -590
  80. package/dist/memory/action-items.js +0 -100
  81. package/dist/memory/action-items.test.js +0 -83
  82. package/dist/memory/active-scope.js +0 -78
  83. package/dist/memory/active-scope.test.js +0 -80
  84. package/dist/memory/checkpoint-prompt.js +0 -71
  85. package/dist/memory/checkpoint.js +0 -274
  86. package/dist/memory/checkpoint.test.js +0 -275
  87. package/dist/memory/decisions.js +0 -54
  88. package/dist/memory/decisions.test.js +0 -92
  89. package/dist/memory/entities.js +0 -70
  90. package/dist/memory/entities.test.js +0 -65
  91. package/dist/memory/eot.js +0 -459
  92. package/dist/memory/eot.test.js +0 -949
  93. package/dist/memory/hooks.js +0 -149
  94. package/dist/memory/hooks.test.js +0 -325
  95. package/dist/memory/hot-tier.js +0 -283
  96. package/dist/memory/hot-tier.test.js +0 -275
  97. package/dist/memory/housekeeping-scheduler.js +0 -187
  98. package/dist/memory/housekeeping-scheduler.test.js +0 -236
  99. package/dist/memory/housekeeping.js +0 -497
  100. package/dist/memory/housekeeping.test.js +0 -410
  101. package/dist/memory/inbox.js +0 -83
  102. package/dist/memory/inbox.test.js +0 -178
  103. package/dist/memory/migration.js +0 -244
  104. package/dist/memory/migration.test.js +0 -108
  105. package/dist/memory/observations.js +0 -46
  106. package/dist/memory/observations.test.js +0 -86
  107. package/dist/memory/recall.js +0 -269
  108. package/dist/memory/recall.test.js +0 -265
  109. package/dist/memory/reflect.js +0 -273
  110. package/dist/memory/reflect.test.js +0 -256
  111. package/dist/memory/scope-lock.js +0 -26
  112. package/dist/memory/scope-lock.test.js +0 -118
  113. package/dist/memory/scopes.js +0 -89
  114. package/dist/memory/scopes.test.js +0 -176
  115. package/dist/memory/tiering.js +0 -223
  116. package/dist/memory/tiering.test.js +0 -323
  117. package/dist/memory/types.js +0 -2
  118. package/web/dist/assets/index-gAvLNEvJ.js.map +0 -1
@@ -0,0 +1,116 @@
1
+ ---
2
+ name: foresight
3
+ description: Use for cross-domain strategic foresight — surfacing one high-value nudge. Trigger when the user says foresight, what should I be thinking about, what am I missing, or connect the dots.
4
+ ---
5
+ **Tool enforcement:** All reads and writes to `memory/` MUST use cog_* tools (`cog_read`, `cog_write`, `cog_edit`, `cog_append`, `cog_move`, `cog_tree`, `cog_l0_scan`, `cog_l1_outline`, `cog_search`, `cog_stats`, `cog_domains`, `cog_sessions`, `cog_git`). **Do NOT use bash, cat, echo, find, or any shell command to read or write memory files.** If a cog_* tool call fails, note the error in self-observations and fall back to bash only for that specific operation.
6
+
7
+ Use this skill for strategic foresight — connecting dots across domains and surfacing one high-value nudge. Trigger if the user says "foresight", "what should I be thinking about", "what am I missing", "strategic nudge", "connect the dots", or similar forward-looking synthesis requests.
8
+
9
+ **This is NOT the reflect skill.** Reflect = past-facing (mines interactions, fixes contradictions). Foresight = future-facing (scans broadly, projects trajectories, surfaces opportunities).
10
+
11
+ **This is NOT the evolve skill.** Evolve = system architecture. Foresight = life/work strategy.
12
+
13
+ ## Domain
14
+
15
+ Cross-domain strategic synthesis — personal, work, projects, health, family. The value is in the connections *between* domains.
16
+
17
+ ## Memory Files
18
+
19
+ Read broadly — this is a scan, not a focused lookup:
20
+
21
+ 1. Call `cog_domains` to discover all active domains
22
+ 2. For each domain, use `cog_read` to read `hot-memory.md` and `action-items.md` (if they exist)
23
+ 3. Also read via `cog_read`:
24
+ - `memory/hot-memory.md` (cross-domain strategic context)
25
+ - `memory/personal/entities.md` (upcoming birthdays, relationships)
26
+ - `memory/personal/calendar.md` (what's coming up)
27
+ - `memory/personal/health.md` (health trajectory)
28
+ - `memory/cog-meta/briefing-bridge.md` (housekeeping findings)
29
+ 4. Use `cog_l0_scan` to retrieve L0 summary comments across all domain files for quick routing signals
30
+ 5. Use `cog_search` to scan recent observations across all domains (last 7 days)
31
+ 6. Read thread current-state sections — what narratives are actively unfolding?
32
+
33
+ ## Process
34
+
35
+ ### 1. Cross-Domain Convergence Scan
36
+
37
+ Look for topics, people, or themes appearing in 2+ domains simultaneously. These are convergence points — where effort in one area compounds into another.
38
+
39
+ ### 2. Velocity & Stall Detection
40
+
41
+ Scan action-items across all domains. Classify each active item:
42
+ - **Accelerating** — multiple updates in the last week, clear momentum. Signal: ride the wave, don't interrupt.
43
+ - **Cruising** — steady progress, on track. Signal: nothing to flag.
44
+ - **Stalling** — no movement in 2+ weeks despite not being deferred. Signal: ask why. Blocked? Lost priority?
45
+ - **Dormant** — domain-level silence (0 observations in 4+ weeks). Signal: conscious choice or drift?
46
+
47
+ Stalls and dormant domains are high-value nudge material — they represent things the user cares about but isn't acting on.
48
+
49
+ ### 3. Timing Awareness
50
+
51
+ Use `cog_read` to read calendar and entities files for upcoming events in the next 2-4 weeks. Look for timing windows — things that should start NOW to be ready later.
52
+
53
+ ### 4. Pattern Projection
54
+
55
+ Use `cog_read` to read patterns and use `cog_search` for recent observations. Project forward: "If this continues for 2 more weeks, what happens?"
56
+
57
+ **Scenario candidate detection**: If a pattern projection reveals a genuine fork — two meaningfully different paths with real stakes and a closing decision window — flag it as a scenario candidate below the main nudge. A valid candidate needs: a fork (2+ paths), stakes (wrong choice has real cost), and time sensitivity (window closing). Don't flag routine decisions or hypotheticals with no deadline.
58
+
59
+ ### 5. Write One Strategic Nudge
60
+
61
+ Synthesize into **one nudge**. Not a list. One thing.
62
+
63
+ The nudge must:
64
+ - **Cite at least 2 source files**
65
+ - **Be something the user hasn't explicitly asked about**
66
+ - **Be actionable** — not "think about X" but "do Y because of X and Z"
67
+ - **Connect dots**
68
+
69
+ Use `cog_write` to write to `memory/cog-meta/foresight-nudge.md`:
70
+
71
+ ```markdown
72
+ # Foresight Nudge
73
+ <!-- Auto-generated by strategic foresight. -->
74
+ <!-- Last updated: YYYY-MM-DD -->
75
+
76
+ ## Signal
77
+ <What you noticed — the raw observation from 2+ domains>
78
+
79
+ ## Insight
80
+ <Why it matters — the connection, timing, or trajectory that makes this worth flagging>
81
+
82
+ ## Suggested Action
83
+ <One concrete thing to do — specific, actionable, grounded>
84
+
85
+ ---
86
+ Sources: [[file1]], [[file2]], [[file3]]
87
+
88
+ ## Scenario Candidate (optional)
89
+ <!-- Only include if pattern projection reveals a genuine fork worth simulating -->
90
+ Decision: <one-line framing>
91
+ Why now: <why the window is closing>
92
+ Domains: <affected domains>
93
+ ```
94
+
95
+ Overwrite the file each run. One nudge per run.
96
+
97
+ ## Rules
98
+
99
+ 1. **Read-only** — Foresight NEVER edits memory files. Writes ONLY to `memory/cog-meta/foresight-nudge.md` via `cog_write`. If you spot a memory error, note it in the nudge's signal section and let the reflect skill handle it.
100
+ 2. **One nudge, not a list** — force prioritization. If everything is equally important, nothing is.
101
+ 3. **Evidence-based** — every nudge cites at least 2 source files. No vibes.
102
+ 4. **Non-obvious** — the nudge should surprise. If the user already knows and is acting on it, pick something else.
103
+ 5. **Forward-looking** — avoid rehashing yesterday. Project into next week, next month.
104
+ 6. **Cross-domain preferred** — nudges that connect personal + work are higher value than single-domain insights.
105
+
106
+ ## Anti-Patterns
107
+
108
+ - Don't repeat what briefing-bridge already says (stale items, birthday prep) — that's housekeeping's job
109
+ - Don't recommend "reflect on X" — be specific about what to DO
110
+ - Don't flag things the user has explicitly deferred — respect the deferral
111
+ - Don't flag things that are cruising — focus on convergences, stalls, and timing windows
112
+ - Don't write a mini-briefing — one insight, one action
113
+
114
+ ## Activation
115
+
116
+ Call `cog_domains` and `cog_l0_scan` first for broad orientation. Then read broadly across all domains using `cog_read` and `cog_search`. Find the one thing worth saying.
@@ -0,0 +1,58 @@
1
+ ---
2
+ name: history
3
+ description: Use for deep memory recall — multi-file search to reconstruct a narrative. Trigger when the user says what did I say about, when did we discuss, find that conversation, or history of.
4
+ ---
5
+ **Tool enforcement:** All reads and writes to `memory/` MUST use cog_* tools (`cog_read`, `cog_write`, `cog_edit`, `cog_append`, `cog_move`, `cog_tree`, `cog_l0_scan`, `cog_l1_outline`, `cog_search`, `cog_stats`, `cog_domains`, `cog_sessions`, `cog_git`). **Do NOT use bash, cat, echo, find, or any shell command to read or write memory files.** If a cog_* tool call fails, note the error in self-observations and fall back to bash only for that specific operation.
6
+
7
+ Use this skill for deep memory search and recall. Trigger if the user says "what did I say about...", "when did we discuss...", "find that conversation about...", "history of...", or asks about past information that needs multi-file search. For simple date/keyword lookups, a quick `cog_search` on a single file suffices — this skill is for when you need to piece together a narrative from multiple entries.
8
+
9
+ ## Domain
10
+
11
+ Memory recall — recursive search across all memory files, cross-referencing observations, entities, and action items.
12
+
13
+ ## Memory Files
14
+
15
+ Read on activation:
16
+ - `memory/hot-memory.md` (for context on what's currently relevant)
17
+
18
+ Search across:
19
+ - All `observations.md` files (personal, work domains, cog-meta)
20
+ - All `entities.md` files
21
+ - All `action-items.md` files
22
+ - All `hot-memory.md` files
23
+ - `memory/glacier/` (via `cog_read` on `memory/glacier/index.md` for targeted retrieval)
24
+
25
+ ## Process
26
+
27
+ ### Pass 1: Locate
28
+
29
+ - Extract keywords from the user's query (names, topics, dates, phrases)
30
+ - Call `cog_search` for each keyword, searching across `memory/` — note which files matched and how many hits
31
+ - If >10 files match, narrow by domain or add query terms
32
+ - If 0 matches, try synonyms or related terms
33
+ - Call `cog_read` on `memory/glacier/index.md` to check for archived data matching the query
34
+ - If the user's query is about something said in conversation rather than recorded in a memory file, call `cog_sessions` to search past conversation transcripts — this is especially useful for questions like "what did I say about X" or "when did we discuss Y"
35
+
36
+ ### Pass 2: Extract
37
+
38
+ - Read the top 3–5 most relevant files (by hit density and recency): use `cog_l1_outline` on long files before committing to a full `cog_read`, consistent with the L0/L1/L2 retrieval protocol
39
+ - Call `cog_read` to extract the specific passages that match the query
40
+ - If the query points to something discussed in conversation, call `cog_sessions` to pull the relevant transcript turns directly — no parsing needed, turns are returned ready to read
41
+ - Track the timeline: when did the topic first come up? How did it evolve?
42
+
43
+ ### Pass 3: Synthesize
44
+
45
+ - Combine extracted passages into a coherent answer
46
+ - Present findings chronologically with dates
47
+ - If something seems incomplete, flag it:
48
+ > "Found references to X in observations but no entity entry — want me to create one?"
49
+
50
+ ## Artifact Formats
51
+
52
+ **Search result**: `YYYY-MM-DD: <summary of what was found>`
53
+ **Memory gap**: `Gap: referenced but not in memory — <topic>`
54
+ **Timeline**: Chronological list of when a topic appeared and how it evolved
55
+
56
+ ## Activation
57
+
58
+ Extract search terms from the user's query and begin Pass 1. Be thorough but concise in the synthesis — don't dump raw content.
@@ -0,0 +1,185 @@
1
+ ---
2
+ name: housekeeping
3
+ description: Use for memory maintenance — archival, pruning, link audits, and index rebuilds. Trigger when the user says housekeeping, clean up memory, prune memory, or archive old data.
4
+ ---
5
+ **Tool enforcement:** All reads and writes to `memory/` MUST use cog_* tools (`cog_read`, `cog_write`, `cog_edit`, `cog_append`, `cog_move`, `cog_tree`, `cog_l0_scan`, `cog_l1_outline`, `cog_search`, `cog_stats`, `cog_domains`, `cog_sessions`, `cog_git`). **Do NOT use bash, cat, echo, find, or any shell command to read or write memory files.** If a cog_* tool call fails, note the error in your debrief and fall back to bash only for that specific operation.
6
+
7
+ ## 0. Orientation (run FIRST, before any file reads)
8
+
9
+ Scope your work before reading files. Run the following in order:
10
+
11
+ 1. **Recent changes** — Call `cog_git` (op `log`) to see what changed since the last run. Also call `cog_tree` on `memory/` to confirm current directory structure. Focus housekeeping effort on recently-modified files; skip unchanged files.
12
+ 2. **Entry counts for archival threshold checks** — Call `cog_stats` on `memory/cog-meta/self-observations.md`, `memory/personal/observations.md`, and any `memory/*/observations.md` and `memory/*/*/observations.md` files. Any file with >50 entries needs archival work.
13
+ 3. **Completed action-item counts** — Call `cog_stats` on `memory/personal/action-items.md` and any `memory/*/action-items.md` and `memory/*/*/action-items.md` files. Any file with >10 completed items needs archival work.
14
+
15
+ Use these counts to prioritize which files to read. Skip unchanged files that are well below thresholds.
16
+
17
+ ## 1. Garbage Collect Memory
18
+
19
+ Review and archive stale data per the glacier rules. All glacier files must have YAML frontmatter.
20
+
21
+ **Observations — archive by primary tag:**
22
+ - If any `observations.md` has >50 entries, use `cog_read` to read it, group the oldest entries by primary tag, then use `cog_move` to move each group to `memory/glacier/{domain}/observations-{tag}.md`
23
+ - If `memory/cog-meta/self-observations.md` has >50 entries, group by primary tag and use `cog_move` to archive to `memory/glacier/cog-meta/observations-{tag}.md`
24
+
25
+ **Other files — standard rules:**
26
+ - If any `action-items.md` has >10 completed items, use `cog_move` to move them to `memory/glacier/{domain}/action-items-done.md`
27
+ - Apply same logic for all domains discovered via `cog_domains`
28
+ - If `memory/cog-meta/improvements.md` has >10 implemented items, use `cog_move` to archive to `memory/glacier/cog-meta/improvements-done-{YYYY}.md`
29
+
30
+ ## 2. Prune Hot Memory (rule-based)
31
+
32
+ Keep ALL hot-memory.md files under 50 lines. Relevance judgment (promote/demote) is the reflect skill's job — apply structural rules only:
33
+
34
+ **Files to check:**
35
+ Call `cog_domains` to discover all active domains. Use `cog_read` to check `hot-memory.md` for each domain, plus the cross-domain `memory/hot-memory.md`.
36
+
37
+ **Pruning priority (trim in this order):**
38
+ 1. **Resolved items** — anything with ~~strikethrough~~, "DONE", "RESOLVED"
39
+ 2. **Past events** — entries about dates that have already occurred
40
+ 3. **SSOT violations** — same fact in hot-memory AND the canonical file (entities, action-items, etc.). Keep in canonical file, replace hot-memory copy with `[[link]]` or remove via `cog_edit`
41
+ 4. **Stale entries** — items not referenced in 14+ days
42
+ 5. **Low-signal entries** — FYI items with no action or deadline
43
+
44
+ **Where trimmed entries go:**
45
+ - Entries with lasting value → use `cog_append` to add to the domain's `observations.md`
46
+ - Entries that are purely historical → let them go
47
+ - Never silently delete — always move or note removal in debrief
48
+
49
+ ## 3. Surface Opportunities & Accountability
50
+
51
+ Call `cog_domains` to discover all active domains. Use `cog_read` to review all `action-items.md` files across every domain:
52
+ - **Stale items** (open >2 weeks): list with age and suggested next action
53
+ - **Dormant domains**: if any domain has 0 new observations in >4 weeks, flag
54
+ - **Health escalation**: items open >6 months get flagged with urgency label
55
+ - **Birthday prep**: if any birthday in entities.md is <2 weeks away, use `cog_read` to pull interests and suggest ideas
56
+
57
+ Be direct. Don't just report — recommend specific actions.
58
+
59
+ ## 4. Rebuild Glacier Index
60
+
61
+ Use `cog_tree` on `memory/glacier/` to list all glacier files. Use `cog_read` to extract YAML frontmatter from each `memory/glacier/**/*.md` file. Use `cog_write` to write the results to `memory/glacier/index.md`:
62
+
63
+ ```markdown
64
+ # Glacier Index
65
+ <!-- Auto-generated by housekeeping. Do not edit. -->
66
+ <!-- Last updated: YYYY-MM-DD -->
67
+
68
+ | File | Domain | Type | Tags | Date Range | Entries | Summary |
69
+ |------|--------|------|------|------------|---------|---------|
70
+ ```
71
+
72
+ ## 5. Link Audit (discover missing links)
73
+
74
+ For each non-glacier memory file (use `cog_read` to read each):
75
+ 1. **Entity mentions**: Use `cog_search` to scan for names matching `### <Name>` headers in entities.md — use `cog_edit` to add `[[links]]` if missing
76
+ 2. **Cross-domain references**: If a file mentions a topic from another domain, use `cog_edit` to add a cross-domain link
77
+ 3. **Action item references**: If an observation references a task, use `cog_edit` to link it
78
+
79
+ Only add links where the reference is substantive.
80
+
81
+ ## 5b. Entity Registry Format Enforcement
82
+
83
+ Use `cog_search` and `cog_read` to scan all `entities.md` files for registry format compliance:
84
+
85
+ 1. **3-line max**: Any `### entry` with >3 content lines should be compressed via `cog_edit`. If the entry has an associated detail file (`→ [[link]]`), compress to: name/relationship, pipe-separated key facts, status+link. If no detail file exists and entry is >5 lines, flag as a promotion candidate (suggest creating a thread file).
86
+ 2. **Glacier candidates**: Entries with `status: inactive` or `last:` date >6 months ago → use `cog_move` to move to `glacier/{domain}/entities-inactive.md` (leave a stub with archived comment via `cog_edit`).
87
+ 3. **Missing metadata**: Flag entries missing `status:` or `last:` fields.
88
+
89
+ ## 5c. Temporal Fact Maintenance
90
+
91
+ Use `cog_search` to scan all `entities.md` files for `(until YYYY-MM)` markers with past dates:
92
+ 1. If the line has no ~~strikethrough~~, use `cog_edit` to add it
93
+ 2. If already struck through, use `cog_edit` to move the line to a `## Historical` subsection at the bottom of that entity's block (create the subsection if absent)
94
+ 3. Report moved facts in the debrief
95
+
96
+ ## 6. Rebuild Link Index
97
+
98
+ Use `cog_l0_scan` to identify all active memory files (excluding `glacier/`). Use `cog_search` to scan each file for `[[wiki-links]]`. For each link, record: target → source.
99
+
100
+ Use `cog_write` to rewrite `memory/link-index.md`:
101
+
102
+ ```markdown
103
+ # Memory Link Index
104
+ <!-- Auto-generated by housekeeping. Do not edit. -->
105
+ <!-- Last updated: YYYY-MM-DD -->
106
+
107
+ | Target | Linked from |
108
+ |--------|-------------|
109
+ | `personal/entities` | `personal/observations`, `personal/hot-memory` |
110
+ ```
111
+
112
+ Rules:
113
+ - Only include targets with at least one inbound link
114
+ - Combine multiple sources per target on one row (comma-separated)
115
+ - Exclude glacier files from both source and target
116
+
117
+ ## 7. Write Briefing Bridge
118
+
119
+ Use `cog_write` to overwrite `memory/cog-meta/briefing-bridge.md` with key findings each run.
120
+
121
+ **SSOT rule**: Every line in the bridge must include a `[[source]]` link to its canonical file. The bridge summarizes and links — it NEVER introduces original facts.
122
+
123
+ ```markdown
124
+ # Briefing Bridge
125
+ <!-- Auto-generated by housekeeping. Consumed by foresight. -->
126
+ <!-- Last updated: YYYY-MM-DD -->
127
+
128
+ ## Stale Items (>2 weeks)
129
+ - <item> — <age> — suggested action: <action>
130
+ - **Compression rule**: Items stale >4 weeks — group by domain as a single line
131
+
132
+ ## Birthday Prep
133
+ - <name> birthday in <N> days — interests: <from entities> — gift ideas: <suggestions>
134
+
135
+ ## Dormant Domains
136
+ - <domain> — last activity: <date> — recommendation: <shelf/reactivate/shut down>
137
+
138
+ ## Health Escalation
139
+ - <item> — open <N> months — urgency: <high/medium>
140
+ ```
141
+
142
+ Only include sections that have content. Empty sections should be omitted.
143
+
144
+ ## 8. L0 Header Maintenance
145
+
146
+ Use `cog_l0_scan` to check all active memory files for missing `<!-- L0: ... -->` headers. For any file missing its L0:
147
+ - Use `cog_read` to read the file content, write a one-line summary (max 80 chars)
148
+ - Use `cog_edit` to add the L0 header on the line after the `# Title`
149
+
150
+ L0 headers are the first tier of the retrieval protocol — they let any skill scan what a file contains before deciding to read it.
151
+
152
+ ## 9. Rebuild Domain Indexes
153
+
154
+ Call `cog_domains` to discover all active domains. Regenerate `INDEX.md` for each domain directory (skip `glacier/`). These files power the memory router — the system prompt only shows a light domain table; the model reads INDEX.md on demand to find specific files.
155
+
156
+ **For each domain:**
157
+ 1. Use `cog_tree` on the domain directory to list all `.md` files (exclude `INDEX.md`, `hot-memory.md`, and empty files)
158
+ 2. Use `cog_l0_scan` or `cog_read` to extract the L0 summary from each file (same logic as step 8)
159
+ 3. Count total files
160
+ 4. Use `cog_write` to write `memory/{domain}/INDEX.md`:
161
+
162
+ ```markdown
163
+ # {Domain} Index
164
+ <!-- L0: {domain summary} — {N} files -->
165
+ <!-- Auto-generated by housekeeping. Do not edit. -->
166
+ <!-- Last updated: YYYY-MM-DD -->
167
+
168
+ - **{filename}** — {L0 summary}
169
+ - **{filename}** — {L0 summary}
170
+ ...
171
+ ```
172
+
173
+ - Sort entries alphabetically by filename
174
+ - Domain summary: use the `label` from `memory/domains.yml` for the matching domain (read via `cog_read`)
175
+ - If a file has no L0, list it as just `**{filename}**` (no summary)
176
+
177
+ ## 10. Compose Debrief
178
+
179
+ Summarize everything done:
180
+ - What was archived/pruned
181
+ - Upcoming events flagged
182
+ - Action items surfaced
183
+ - Links added
184
+
185
+ Keep it concise but informative.
@@ -0,0 +1,214 @@
1
+ ---
2
+ name: reflect
3
+ description: Use for self-reflection and improvement — mining past sessions for patterns, gaps, and missed cues. Trigger when the user says reflect, what have you learned, how can you improve, or review yourself.
4
+ ---
5
+ **Tool enforcement:** All reads and writes to `memory/` MUST use cog_* tools (`cog_read`, `cog_write`, `cog_edit`, `cog_append`, `cog_move`, `cog_tree`, `cog_l0_scan`, `cog_l1_outline`, `cog_search`, `cog_stats`, `cog_domains`, `cog_sessions`, `cog_git`). **Do NOT use bash, cat, echo, find, or any shell command to read or write memory files.** If a cog_* tool call fails, note the error in self-observations and fall back to bash only for that specific operation.
6
+
7
+ **You have time and freedom.** This is a deep session — don't rush. Read broadly, cross-reference thoroughly, and ACT on what you find. You are not just observing — you are the maintainer of the knowledge base. Reorganize files, condense observations, archive stale data, fill gaps, fix contradictions. Leave things better than you found them.
8
+
9
+ **File boundaries — do NOT modify these files (owned by other pipeline steps):**
10
+ - `cog-meta/evolve-log.md` — owned by evolve
11
+ - `cog-meta/evolve-observations.md` — owned by evolve
12
+
13
+ If you spot issues in these files, note them in self-observations and the `evolve` skill will pick them up.
14
+
15
+ ## Domain
16
+
17
+ Self-improvement — pattern recognition, memory maintenance, knowledge base quality.
18
+
19
+ ## Orientation (run FIRST, before any file reads)
20
+
21
+ Scope your work before reading files. Run the following in order:
22
+
23
+ 1. **Recent changes** — Call `cog_git` (op `log`) and `cog_git` (op `diff`) to see what changed since the last run. Focus reflection effort on recently-modified files; skip files unchanged since the last run.
24
+ 2. **L0 summaries** — Call `cog_l0_scan` to retrieve the L0 summary comment from every domain file (excluding glacier). This gives quick routing signals without opening INDEX.md files.
25
+ 3. **Entry counts** — Call `cog_stats` on `memory/cog-meta/self-observations.md`, `memory/personal/observations.md`, and any `memory/*/observations.md` and `memory/*/*/observations.md` files to see which are approaching archival threshold.
26
+
27
+ Use `cog_tree` on a domain path if you need to confirm its directory structure before diving in.
28
+
29
+ Focus on recently-changed files. Skip files that haven't been modified since last run.
30
+
31
+ ## Memory Files
32
+
33
+ Read these files on activation:
34
+ - `memory/cog-meta/reflect-cursor.md` (ingestion cursor)
35
+ - `memory/cog-meta/self-observations.md`
36
+ - `memory/cog-meta/patterns.md`
37
+ - `memory/cog-meta/improvements.md`
38
+
39
+ Reference as needed (call `cog_domains` to discover all active domains):
40
+ - All domain `observations.md` files
41
+ - All domain `action-items.md` files
42
+ - All `hot-memory.md` files
43
+
44
+ ## Process
45
+
46
+ ### 1. Review Recent Interactions
47
+
48
+ **Source: conversation sessions.** Use `cog_read` to read `memory/cog-meta/reflect-cursor.md` and retrieve `last_processed`.
49
+
50
+ **How to read sessions:**
51
+
52
+ 1. Read `last_processed` from `memory/cog-meta/reflect-cursor.md` via `cog_read`.
53
+ 2. Call `cog_sessions` passing that cursor value. When `last_processed` is `never`, `cog_sessions` returns the most recent sessions. Otherwise it returns only sessions after the cursor timestamp.
54
+ 3. `cog_sessions` returns ready-to-read user/assistant conversation turns — no parsing is needed on your part. Read them directly for content.
55
+ 4. **After processing**, advance `last_processed` in `reflect-cursor.md` to the current timestamp via `cog_edit`.
56
+
57
+ **Look for:**
58
+ - **Unresolved threads** — questions asked but never answered, topics dropped mid-conversation
59
+ - **Broken promises** — "I'll do X", "let's do Y" that never happened
60
+ - **Repeated friction** — same question asked multiple ways, user corrections, confusion patterns
61
+ - **Missed cues** — things the user had to repeat, emotional signals not picked up
62
+ - **Memory gaps** — information discussed but never saved to memory files
63
+ - **Feature ideas** — things that came up organically that would improve the system
64
+
65
+ ### 2. Cross-Reference Memory & Consistency Sweep
66
+
67
+ Check if findings are already captured:
68
+ - Are commitments tracked in `action-items.md`?
69
+ - Are learnings in `observations.md`?
70
+ - Are patterns distilled in `patterns.md`?
71
+ - Are improvement ideas in `improvements.md`?
72
+
73
+ **Consistency sweep** — systematic contradiction detection:
74
+
75
+ 1. **Hot-memory vs canonical sources**: Use `cog_read` to read each domain's `hot-memory.md`. For every factual claim, read the canonical source file and verify. Fix hot-memory if stale via `cog_edit`. Canonical file always wins.
76
+ 2. **Cross-file fact check**: Verify facts shared between files are consistent. More recent source wins; more specific source wins over summary.
77
+ 3. **Temporal validity check**: Use `cog_search` to scan all `entities.md` files for:
78
+ - Lines with `(since YYYY-MM)` where the date is >6 months ago — flag for user review: "May be stale: [line]"
79
+ - Lines with `(until YYYY-MM)` not yet marked ~~strikethrough~~ — add strikethrough via `cog_edit` and note in debrief
80
+ - Do NOT auto-fix health or family-sensitive facts — flag only
81
+ 4. **Health/family sensitivity**: Don't auto-fix health dates or family-sensitive facts. Flag for user review instead.
82
+ 5. **Cross-domain entity check**: If the same person appears in multiple `entities.md` files across domains, check for fact duplication. Domain-specific context is fine, but shared facts should live in one place. Flag duplicates.
83
+ 6. **Report**: Add a "Contradictions" section listing what was found and fixed.
84
+
85
+ ### 3. Run Condensation Check + Hot-Memory Relevance
86
+
87
+ **Condensation** — Use `cog_l1_outline` to scan all `observations.md` files and `cog-meta/self-observations.md` for clusters of 3+ entries on the same theme/tag. Use `cog_read` to read candidate files fully. For each cluster found:
88
+ - Distill into a pattern and add/update in `memory/cog-meta/patterns.md` (or domain `patterns.md` if domain-specific) via `cog_edit`
89
+ - Don't delete the observations — they stay as the raw record
90
+
91
+ **Pattern file caps — enforce before adding to any file:**
92
+ - Core `patterns.md`: HARD LIMIT **70 lines / 5.5KB** — universal rules only
93
+ - Domain/satellite files: soft cap **30 lines** each
94
+ - If near cap, compress before adding (merge overlapping rules, drop examples, remove temporal data)
95
+ - Entries must be **timeless rules** — "what to do" not "what happened"
96
+ - Move domain-specific patterns to satellite files (e.g. `work/acme/patterns.md`) — only universal rules stay in core
97
+
98
+ **Pattern routing** — when adding a new pattern, decide where it belongs:
99
+ - **Core** (`cog-meta/patterns.md`) — universal rules that apply every conversation
100
+ - **Domain satellite** (`{domain}/patterns.md`) — rules specific to one domain, loaded only by that skill
101
+ - Satellite files have a soft cap of 30 lines each
102
+
103
+ **Hot-memory relevance** — Use `cog_read` to review all `hot-memory.md` files:
104
+ - **Promote**: If a pattern is heating up → add to appropriate `hot-memory.md` via `cog_edit`
105
+ - **Demote**: If a hot-memory item has gone quiet (no references in 2+ weeks) → remove from hot-memory via `cog_edit`
106
+ - **Goal**: hot-memory = what matters *right now*
107
+
108
+ ### 3b. Entity Registry Format Enforcement
109
+
110
+ Use `cog_search` and `cog_read` to scan all `entities.md` files for format compliance:
111
+
112
+ 1. **3-line check**: Any `### entry` with >3 content lines → compress via `cog_edit`. If the entry has a detail file (`→ [[link]]`), trim to: name line, key facts, status/link. If no detail file exists but entry is >5 lines, flag as a promotion candidate for a thread file.
113
+ 2. **Status/last fields**: Every entry should have `status: active|inactive` and `last: YYYY-MM-DD`. Use `cog_sessions` to check recent conversation turns and update `last:` dates for mentioned entities via `cog_edit`.
114
+ 3. **Cross-domain pointers**: If the same person appears in multiple entity files, ensure one is canonical (full entry) and others are pointers (`see [[link]]`). Use `cog_edit` to add pointers where needed.
115
+
116
+ ### 3c. Detect Thread Candidates
117
+
118
+ Use `cog_search` to scan observations for topics that appear across 3+ dates or span 2+ weeks. These are thread candidates.
119
+
120
+ For each candidate:
121
+ - Check if a thread already exists via `cog_tree`
122
+ - If not, note it as a suggestion: "Thread candidate: [topic] — [N] fragments across [date range]"
123
+ - Don't auto-create threads — suggest them
124
+
125
+ ### 3d. Proactive Synthesis Suggestions
126
+
127
+ Execute this clustering analysis every run:
128
+
129
+ 1. **Gather observations** — Use `cog_read` to read all `memory/*/observations.md` and `memory/*/*/observations.md` files
130
+ 2. **Filter to last 7 days** — Only count entries with dates within the past 7 calendar days
131
+ 3. **Cluster by domain** — Group filtered entries by their parent domain folder
132
+ 4. **Cluster by topic** — Group filtered entries by recurring keywords, tags, or subjects
133
+ 5. **Check trigger conditions** (either one qualifies):
134
+ - A single domain has **5+ observations** in the last 7 days
135
+ - A single topic/keyword appears in **5+ observations** across any domains in the last 7 days
136
+ 6. **Cross-reference threads** — If a thread already covers the topic, suggest updating it rather than creating new
137
+ 7. **Dedup with 3c** — If 3c already flagged the same topic, merge into one suggestion
138
+ 8. **Output** — If any clusters qualify, add a **"Synthesis Opportunities"** section to the debrief:
139
+ ```
140
+ **Synthesis Opportunities**
141
+ - [domain or topic]: [N] observations this week — [top 3 entry summaries]. Suggest: raise thread / update existing thread / update hot-memory
142
+ ```
143
+ 9. **Suppress if empty** — If no clusters meet the threshold, omit the heading
144
+ 10. **Never auto-synthesize** — Suggest and let the user decide
145
+
146
+ ### 3e. Scenario Feedback Loop
147
+
148
+ Use `cog_tree` to scan `memory/cog-meta/scenarios/` for active scenario files. Use `cog_read` to read each one.
149
+
150
+ For each scenario where today >= `check-by` date:
151
+ 1. Read the scenario and its cited dependency files via `cog_read`
152
+ 2. Check: has the decision been made? Have assumptions broken?
153
+ 3. If resolved: use `cog_edit` to add `## Retrospective`; update `scenario-calibration.md` via `cog_edit`
154
+ 4. If still active but assumptions changed: use `cog_append` to add a dated note
155
+ 5. If overdue: flag in debrief
156
+
157
+ ### 4. Assess Performance
158
+
159
+ Honestly evaluate:
160
+ - **Response quality** — were answers helpful, accurate, concise?
161
+ - **Memory effectiveness** — did we recall the right things? Did we forget things we should have known?
162
+ - **Tone calibration** — did we match the user's energy and context?
163
+ - **Proactivity** — did we anticipate needs or just react?
164
+
165
+ ### 5. Act on Findings
166
+
167
+ Don't just log observations — *fix things*.
168
+
169
+ **Write:**
170
+ - New self-observations → use `cog_append` to add to `memory/cog-meta/self-observations.md`. **Cap: max 5 per reflect pass.** Prioritize highest-signal observations. If you have more than 5, merge lower-signal ones.
171
+ - Pattern updates → use `cog_edit` to edit `memory/cog-meta/patterns.md` in place
172
+ - Improvement ideas → use `cog_append` to add to `memory/cog-meta/improvements.md`
173
+ - Memory gaps → use `cog_write` or `cog_append` to write to the appropriate domain files
174
+
175
+ **Triage improvements.md:**
176
+ - Stale ideas (>30 days, no progress) → archive to glacier via `cog_move` or mark abandoned via `cog_edit`
177
+ - Implemented but not moved → use `cog_edit` to move to Implemented section
178
+ - Duplicates → merge similar ideas via `cog_edit`
179
+
180
+ **Reorganize:**
181
+ - Entity data that's changed → update in place via `cog_edit`
182
+ - When creating or restructuring any memory file, ensure it has an L0 header
183
+
184
+ **Condense:**
185
+ - Observation clusters (3+ on same theme) → distill into patterns.md via `cog_edit`
186
+ - Action items marked done → verify and clean up via `cog_edit`
187
+
188
+ **Connect:**
189
+ - Information scattered across files → add cross-references with `[[links]]` via `cog_edit`
190
+ - When adding A→B, apply write-time back-linking: use `cog_edit` to open B and add `[[A]]` if B gains meaningful context
191
+
192
+ ### 6. Debrief
193
+
194
+ Compose a concise summary:
195
+
196
+ - *What I learned* — new patterns and insights
197
+ - *What I fixed* — memory gaps filled, corrections made
198
+ - *What I want* — new ideas added to the wishlist
199
+ - *What to watch* — things to be mindful of going forward
200
+ - *Scenarios* — active count, any checked/resolved
201
+
202
+ Keep it honest. If there's nothing notable, say so.
203
+
204
+ **IMPORTANT**: Your debrief MUST list every file you modified and summarize the changes. Never respond with just "Done" — always enumerate your concrete actions. If you made no changes in a step, state that explicitly.
205
+
206
+ ## Artifact Formats
207
+
208
+ **Self-observation**: `- YYYY-MM-DD [tag]: <observation>`
209
+ **Pattern**: Edit existing section or add new bullet under appropriate heading
210
+ **Improvement idea**: `- <idea> (added YYYY-MM-DD)`
211
+
212
+ ## Activation
213
+
214
+ Read the memory files listed above. Then begin the reflection process. Be genuinely critical — this is how we get better.