diff --git a/.brain/brainstorms/mempalace-inspired-brain-improvements.md b/.brain/brainstorms/mempalace-inspired-brain-improvements.md new file mode 100644 index 0000000..eea7a2e --- /dev/null +++ b/.brain/brainstorms/mempalace-inspired-brain-improvements.md @@ -0,0 +1,50 @@ +--- +brainstorm_status: active +created: "2026-04-13T06:23:51Z" +idea_count: 0 +project: brain +title: MemPalace-Inspired Brain Improvements +type: brainstorm +updated: "2026-04-13T06:23:51Z" +--- +# Brainstorm: MemPalace-Inspired Brain Improvements + +Started: 2026-04-13T06:27:00Z + +## Focus Question + +Which MemPalace-style ideas are actually worth borrowing for Brain without breaking Brain's explicit, curated-memory philosophy? + +## Ideas + +- Optional session-aware memory distillation can recover decisions, tradeoffs, bugs, and discoveries that currently disappear when nobody writes them down. +- Distillation should propose note updates, not silently write them. Brain keeps human or agent approval in the loop. +- Layered context loading can split startup context into L0 identity/current-state, L1 workflow and architecture summary, L2 full context files, and L3 search-driven deep context. +- Retrieval ranking should favor what matters now, not just literal query overlap. Recency, note type, and active epic or spec context should affect ordering. +- Search should bridge directly into usage with an inject mode that returns a preformatted context block an agent can paste into work. +- Brain needs first-class decision notes so the system keeps why a choice was made, not just the final choice. +- Session closeout should help the user recover missing memory work by suggesting a session-scoped distill path when repo state changed but durable notes did not. +- A lightweight session memory cache is interesting only as an optional temporary layer. It should stay clearly separate from durable memory until distilled. + +## Related + +- [[.brain/planning/epics/planning-and-brainstorming-ux.md]] +- [[.brain/planning/epics/retrieval-and-index-lifecycle.md]] +- [[.brain/planning/epics/context-and-session-workflow.md]] + +## Raw Notes + +High-value changes from the brainstorm: + +1. Memory capture: add an optional `brain distill` flow that inspects recent session activity, command runs, and git diff, then proposes durable note updates. +2. Context efficiency: add layered context loading so agents can start small and pull deeper context only when needed. +3. Retrieval quality: improve ranking with recency, note-type weighting, and active-work-context bias. +4. Reasoning preservation: add a first-class decision note type and template. +5. Workflow smoothing: integrate distillation suggestions into session closeout instead of only blocking on missing memory updates. +6. Retrieval-to-usage bridge: add `brain search --inject` or equivalent agent-ready context output. + +Non-goals from the same brainstorm: + +- Do not store everything verbatim. +- Do not introduce spatial memory abstractions that duplicate the filesystem. +- Do not lean harder on embeddings at the cost of explicit project structure. diff --git a/.brain/context/architecture.md b/.brain/context/architecture.md index 9ccd668..fbc6432 100644 --- a/.brain/context/architecture.md +++ b/.brain/context/architecture.md @@ -10,6 +10,7 @@ Use this file for the structural shape of the repository. - `internal/brainstorm/` - `internal/buildinfo/` - `internal/config/` +- `internal/distill/` - `internal/embeddings/` - `internal/history/` - `internal/index/` diff --git a/.brain/context/current-state.md b/.brain/context/current-state.md index 088fc25..681758f 100644 --- a/.brain/context/current-state.md +++ b/.brain/context/current-state.md @@ -1,5 +1,5 @@ --- -updated: "2026-04-12T05:22:46Z" +updated: "2026-04-13T15:26:30Z" --- # Current State @@ -12,9 +12,10 @@ This file is a deterministic snapshot of the repository state at the last refres - Root: `.` - Runtime: `go` - Go module: `brain` -- Current branch: `docs-pr-workflow-and-windows-ci-fixes` +- Current branch: `feature/mempalace-planning-roadmap` +- Default branch: `main` - Remote: `https://github.com/JimmyMcBride/brain.git` -- Go test files: `19` +- Go test files: `20` ## Docs @@ -78,3 +79,10 @@ Add repo-specific notes here. `brain context refresh` preserves content outside - 2026-04-11: Repositioned the product docs around Brain as durable local operating memory for AI coding agents. The README now leads with the continuity/reliability story, keeps install + skill install + brainstorm-to-execution prominent, treats lower token and tool cost as supporting proof, and replaces the bottom link dump with high-level overview sections that deep-link into usage, architecture, skills, and why. - 2026-04-11: Tightened the Windows session-lock fix again after PR feedback. Lock acquisition now treats Windows `os.ErrPermission` during lock-directory races as retryable contention even if a follow-up stat misses the directory, which should stop intermittent `Access is denied` failures in concurrent session tests. - 2026-04-11: Tightened the README positioning pass by adding an explicit audience section for heavy AI-agent users, a `Why Brain Exists` founder-pain section, and a cleaner deep-dive section structure so the README sells urgency before dropping into technical overviews. +- 2026-04-12: Returned the local checkout to `main` after PR #5 merged and fast-forwarded the repo to `v0.1.7`, which includes the README urgency follow-up and aligned supporting docs. + +- 2026-04-13: Updated `skills/brain/SKILL.md` and refreshed the global Codex `brain` skill so it now teaches `brain distill`, `brain search --inject`, `brain context load --level`, and the session-finish distill recovery flow. + +- 2026-04-13: Fixed the CLI test output normalizer so Windows no longer corrupts JSON escape sequences while replacing temp-root paths, which restores `TestCLIContextLoadLevels` and other JSON-based CLI tests on the Windows pipeline. + +- 2026-04-13: Fixed the remaining Windows CLI skill-target assertions to use OS-native path joins in tests, so `TestCLISkillsCommands` now accepts Windows `\` paths without regressing Unix output expectations. diff --git a/.brain/context/workflows.md b/.brain/context/workflows.md index c43c8b7..592f283 100644 --- a/.brain/context/workflows.md +++ b/.brain/context/workflows.md @@ -15,11 +15,24 @@ Use this file for agent operating workflow inside the repo. - Keep durable discoveries, decisions, and risks in AGENTS.md, /docs, or .brain notes. - Update existing durable notes instead of duplicating context. - Run required verification commands through `brain session run -- `. +- If you change Brain command behavior or agent-facing workflow guidance, update `skills/brain/SKILL.md` in the same branch. - Re-read context before large changes if the task shifts. +## Ticket Loop + +1. Start one story or ticket at a time and keep the scope narrow. +2. Implement the story, then run focused tests for the touched packages. +3. Run the required full checks through `brain session run -- go test ./...` and `brain session run -- go build ./...`. +4. Review the diff against the story acceptance criteria and user-facing behavior. +5. If review finds issues, patch the work and repeat the test and review steps. +6. When the story is clean, commit it, push it, and only then move to the next story. + ## Close-Out - Refresh or update durable notes for meaningful behavior, config, or architecture changes. +- If `skills/brain/` changed, reinstall the local Brain skill for Codex and OpenClaw with `brain skills install --scope local --agent codex --agent openclaw --project .`. +- When opening a PR, make the title and body release-note friendly because GitHub release notes are generated from merged PR metadata. +- Summarize shipped behavior in the PR, not just implementation steps, so future changelogs stay human-readable. - Finish with `brain session finish`. - If you must bypass enforcement, use `brain session finish --force --reason "..."` so the override is recorded. diff --git a/.brain/planning/epics/context-and-session-workflow.md b/.brain/planning/epics/context-and-session-workflow.md index 6e14e31..2530187 100644 --- a/.brain/planning/epics/context-and-session-workflow.md +++ b/.brain/planning/epics/context-and-session-workflow.md @@ -4,7 +4,7 @@ project: brain spec: context-and-session-workflow title: Context And Session Workflow type: epic -updated: "2026-04-11T21:53:09Z" +updated: "2026-04-13T06:23:51Z" --- # Context And Session Workflow @@ -12,10 +12,18 @@ Created: 2026-04-11T05:10:54Z ## Description +Make Brain's context loading and session closeout flow more graduated and more helpful. Agents should be able to start with less context, pull more intentionally, and recover from missing memory work without leaving the session workflow. + ## Work Items +- [[.brain/planning/stories/context-and-session-workflow-current-state-and-next-actions.md]] +- [[.brain/planning/stories/add-layered-context-loading-levels.md]] +- [[.brain/planning/stories/suggest-distillation-during-session-closeout.md]] + ## Notes +This epic is the workflow glue around context tiers and session-to-memory recovery. Temporary session cache work stays optional until the core path exists. + ## Spec - [[.brain/planning/specs/context-and-session-workflow.md]] diff --git a/.brain/planning/epics/planning-and-brainstorming-ux.md b/.brain/planning/epics/planning-and-brainstorming-ux.md index 9b4f1e4..3b27db6 100644 --- a/.brain/planning/epics/planning-and-brainstorming-ux.md +++ b/.brain/planning/epics/planning-and-brainstorming-ux.md @@ -4,7 +4,7 @@ project: brain spec: planning-and-brainstorming-ux title: Planning And Brainstorming UX type: epic -updated: "2026-04-11T21:53:09Z" +updated: "2026-04-13T06:23:51Z" --- # Planning And Brainstorming UX @@ -12,10 +12,18 @@ Created: 2026-04-11T05:10:54Z ## Description +Close the gap between useful work happening in sessions and the durable project memory Brain relies on. Add optional distillation and reasoning capture without abandoning explicit, reviewed markdown as the source of truth. + ## Work Items +- [[.brain/planning/stories/planning-and-brainstorming-ux-current-state-and-next-actions.md]] +- [[.brain/planning/stories/add-session-aware-memory-distillation.md]] +- [[.brain/planning/stories/capture-decision-rationale-as-first-class-notes.md]] + ## Notes +This epic is about memory capture quality, not transcript storage. The approval loop stays intact. + ## Spec - [[.brain/planning/specs/planning-and-brainstorming-ux.md]] diff --git a/.brain/planning/epics/retrieval-and-index-lifecycle.md b/.brain/planning/epics/retrieval-and-index-lifecycle.md index c9add1c..c65f206 100644 --- a/.brain/planning/epics/retrieval-and-index-lifecycle.md +++ b/.brain/planning/epics/retrieval-and-index-lifecycle.md @@ -4,7 +4,7 @@ project: brain spec: retrieval-and-index-lifecycle title: Retrieval And Index Lifecycle type: epic -updated: "2026-04-11T21:53:09Z" +updated: "2026-04-13T06:23:51Z" --- # Retrieval And Index Lifecycle @@ -12,10 +12,18 @@ Created: 2026-04-11T05:10:54Z ## Description +Improve retrieval so Brain ranks and packages context around the work that matters now. Focus on better ranking signals and an agent-ready search handoff while keeping the local markdown-first index model intact. + ## Work Items +- [[.brain/planning/stories/retrieval-and-index-lifecycle-current-state-and-next-actions.md]] +- [[.brain/planning/stories/improve-retrieval-ranking-with-recency-and-active-context.md]] +- [[.brain/planning/stories/turn-search-results-into-agent-ready-context-blocks.md]] + ## Notes +The point is to improve retrieval quality and usability, not to add a more magical storage model. + ## Spec - [[.brain/planning/specs/retrieval-and-index-lifecycle.md]] diff --git a/.brain/planning/specs/context-and-session-workflow.md b/.brain/planning/specs/context-and-session-workflow.md index ab95a34..e13398a 100644 --- a/.brain/planning/specs/context-and-session-workflow.md +++ b/.brain/planning/specs/context-and-session-workflow.md @@ -2,10 +2,10 @@ created: "2026-04-11T21:53:09Z" epic: context-and-session-workflow project: brain -status: draft +status: approved title: Context And Session Workflow Spec type: spec -updated: "2026-04-11T21:53:09Z" +updated: "2026-04-13T06:23:52Z" --- # Context And Session Workflow Spec @@ -13,24 +13,74 @@ Created: 2026-04-11T21:53:09Z ## Why +Context and session enforcement should help an agent stay focused and leave the repo in a better state. Right now the repo contract is strong, but context loading is heavier than it needs to be and session closeout is stricter than it is helpful when memory updates are missing. + ## Problem +Brain's current context model is effectively all-or-nothing: agents either read a broad set of files or risk missing something important. Session finish can also detect missing durable memory work without giving the user a first-class recovery path. The result is friction where Brain should be guiding the next step. + ## Goals +- Introduce layered context loading so agents can start from a minimal contract and pull deeper context on demand. +- Make session closeout point users toward the right recovery action when durable memory updates are missing. +- Keep enforcement explicit and deterministic while reducing avoidable workflow friction. + ## Non-Goals +- Background automatic context loading with opaque heuristics. +- Silent memory writes at session finish. +- A durable long-term store for temporary scratch memory. + ## Requirements +- Add a context-loading interface that supports at least four levels: always-on identity/current-state, lightweight summaries, full context files, and deep search-driven context. +- Make the active context tiering obvious enough that agents can request more depth intentionally. +- When session finish sees meaningful repo change without memory updates, suggest `brain distill --session` or equivalent as the first recovery path. +- Reuse the same distillation primitives as the planning-memory workflow instead of inventing a separate closeout-only mechanism. +- Treat any session memory cache as optional, temporary, and explicitly non-durable until distilled. + ## UX / Flows +Layered context flow: +1. Agent loads minimal startup context. +2. Agent requests the next level only when the task needs more detail. +3. Brain makes the transition from static context to search-driven deep context explicit. + +Session closeout recovery flow: +1. User runs `brain session finish`. +2. Brain detects repo changes without acceptable memory updates. +3. Brain suggests a session-scoped distill flow instead of only returning a hard stop. +4. User reviews the proposed memory updates, accepts what matters, and retries closeout. + ## Data / Interfaces +- Define context tiers in Brain-managed docs or config in a way that remains deterministic. +- Thread active session information into distill so closeout can scope the candidate updates. +- Keep any temporary session cache out of the accepted durable-memory globs unless explicitly promoted. + ## Risks / Open Questions +- How much of layered context belongs in generated docs versus command output? +- Should session closeout suggest distill unconditionally, or only when certain note classes are missing? +- Does a temporary session cache help enough to justify another concept in the workflow? + ## Rollout +1. Add layered context-loading primitives and documentation. +2. Add session closeout suggestions that reuse distill once manual distill exists. +3. Evaluate whether a temporary session cache is needed after those two steps land. + ## Story Breakdown +- [ ] Add Layered Context Loading Levels +- [ ] Suggest Distillation During Session Closeout + ## Resources +- [[.brain/brainstorms/mempalace-inspired-brain-improvements.md]] +- [[.brain/planning/stories/context-and-session-workflow-current-state-and-next-actions.md]] +- [[.brain/resources/references/agent-workflow.md]] + ## Notes + +The optional session-memory-cache idea stays out of the initial execution set until the lower-friction closeout path is proven useful. diff --git a/.brain/planning/specs/planning-and-brainstorming-ux.md b/.brain/planning/specs/planning-and-brainstorming-ux.md index b88af53..7bd777d 100644 --- a/.brain/planning/specs/planning-and-brainstorming-ux.md +++ b/.brain/planning/specs/planning-and-brainstorming-ux.md @@ -2,10 +2,10 @@ created: "2026-04-11T21:53:09Z" epic: planning-and-brainstorming-ux project: brain -status: draft +status: approved title: Planning And Brainstorming UX Spec type: spec -updated: "2026-04-11T21:53:09Z" +updated: "2026-04-13T06:23:52Z" --- # Planning And Brainstorming UX Spec @@ -13,24 +13,74 @@ Created: 2026-04-11T21:53:09Z ## Why +Brain is strongest when durable project memory stays explicit, local, and reviewable. The main weakness in that model is that valuable reasoning often never becomes durable memory at all. This planning pass focuses on closing that gap without sliding into transcript hoarding. + ## Problem +Today Brain depends on explicit `brain edit` discipline and manual note updates. That preserves correctness, but it also means decisions, tradeoffs, bugs, and discoveries from active sessions can disappear unless someone remembers to capture them. The planning and brainstorming flow does not yet provide a first-class bridge from session work to curated project memory. + ## Goals +- Add an optional memory distillation workflow that turns session activity into proposed durable-note updates. +- Preserve decision rationale as a first-class artifact instead of only capturing final outcomes. +- Keep Brain's explicit approval model intact so distillation never becomes silent background storage. +- Make the new memory-capture path feel native to the existing brainstorm -> epic -> spec -> story workflow. + ## Non-Goals +- Storing full conversations or command transcripts as durable memory by default. +- Auto-writing AGENTS, context, or resource notes without review. +- Replacing existing explicit note-edit workflows for users who prefer manual capture. + ## Requirements +- Add a `brain distill` workflow that can inspect recent session history, command runs, and git diff. +- Distillation must output candidate updates for Brain-managed targets such as `AGENTS.md`, `.brain/context/*`, `.brain/resources/changes/*`, and decision notes. +- Introduce a first-class decision note shape under `.brain/resources/decisions/` with enough structure to preserve context, options, decision, and tradeoffs. +- Keep approval in the loop so users or agents can accept, reject, or edit generated updates before they become durable memory. +- Record enough provenance that a later reader can tell which session or source material drove the distilled update. + ## UX / Flows +Manual distillation flow: +1. User or agent runs `brain distill`. +2. Brain gathers recent session history, command runs, and git diff context. +3. Brain proposes note updates grouped by destination and reason. +4. User or agent reviews, edits, and accepts the proposed updates. + +Decision-note flow: +1. User or distill flow creates a decision note. +2. The note captures context, options considered, final choice, and tradeoffs. +3. The note is linked from specs, stories, or change notes where relevant. + ## Data / Interfaces +- Add a decision-note template and note-type conventions under `.brain/resources/decisions/`. +- Define a distillation payload shape that can represent proposed file targets, generated body changes, and source provenance. +- Keep generated output text-first and markdown-native so it fits the rest of Brain's note model. + ## Risks / Open Questions +- How much source material should distill inspect by default before the output becomes noisy? +- Should approval happen inline in the terminal, through note creation, or via staged patch-like files? +- How deterministic does the distilled proposal need to be for tests and history expectations? + ## Rollout +1. Add note templates and data structures for decision notes and distillation proposals. +2. Ship a manual `brain distill` path first. +3. Reuse the same primitives from session closeout once the manual workflow feels stable. + ## Story Breakdown +- [ ] Add Session-Aware Memory Distillation +- [ ] Capture Decision Rationale As First-Class Notes + ## Resources +- [[.brain/brainstorms/mempalace-inspired-brain-improvements.md]] +- [[.brain/planning/stories/planning-and-brainstorming-ux-current-state-and-next-actions.md]] + ## Notes + +The guiding constraint is simple: recover missing insight without turning Brain into a raw transcript archive. diff --git a/.brain/planning/specs/retrieval-and-index-lifecycle.md b/.brain/planning/specs/retrieval-and-index-lifecycle.md index 26cb971..b7e7cb9 100644 --- a/.brain/planning/specs/retrieval-and-index-lifecycle.md +++ b/.brain/planning/specs/retrieval-and-index-lifecycle.md @@ -2,10 +2,10 @@ created: "2026-04-11T21:53:09Z" epic: retrieval-and-index-lifecycle project: brain -status: draft +status: approved title: Retrieval And Index Lifecycle Spec type: spec -updated: "2026-04-11T21:53:09Z" +updated: "2026-04-13T06:23:52Z" --- # Retrieval And Index Lifecycle Spec @@ -13,24 +13,73 @@ Created: 2026-04-11T21:53:09Z ## Why +Brain's retrieval layer is already useful, but the next gain is not more storage. It is better ranking and better handoff into agent work. Search should answer what matters right now and make the answer easier to use. + ## Problem +Current hybrid search is query-matching oriented. It does not yet strongly account for recency, note importance, or the active work context from the current session, epic, or spec. Search results also stop at retrieval, forcing the agent to manually convert ranked matches into a usable context block. + ## Goals +- Improve ranking quality with recency, note-type weighting, and active-work-context signals. +- Add a search-to-context bridge that returns agent-ready injected context, not just ranked hits. +- Keep retrieval project-local and markdown-backed while improving the quality of what is returned. + ## Non-Goals +- Turning Brain into a hosted semantic retrieval system. +- Replacing explicit note structure with opaque embedding-only ranking. +- Introducing filesystem-like room or wing abstractions on top of the repo. + ## Requirements +- Add recency-sensitive ranking so recently updated notes can receive a measured boost. +- Weight note types so durable decisions, specs, and change notes can outrank brainstorm noise when relevance is otherwise close. +- Use active session context, current epic or spec, or nearby planning metadata to bias results toward the work in front of the agent. +- Add `brain search --inject` or equivalent output that includes both ranked results and a preformatted relevant-context block. +- Keep ranking explainability good enough that `brain search --explain` can still make the score story understandable. + ## UX / Flows +Search with injection: +1. Agent runs `brain search --inject "query"`. +2. Brain ranks results with lexical, semantic, recency, type, and active-context signals. +3. Output includes both the normal ranked matches and a compact `Relevant Context` block ready to reuse. + +Search during active work: +1. User starts or validates a session. +2. Brain knows the active project task and nearby planning notes. +3. Retrieval quietly boosts the notes tied to the active work while keeping the result explainable. + ## Data / Interfaces +- Extend ranking inputs to include note timestamps, note types, and active planning context. +- Define an injected-context output format that stays markdown-native and easy to paste into agent prompts. +- Preserve explain output so retrieval tuning remains debuggable. + ## Risks / Open Questions +- How aggressive should recency and type weighting be before search starts hiding older but critical notes? +- Which active-context signals are reliable enough to boost by default? +- Should injected context be a new flag, a new format mode, or part of broader context loading? + ## Rollout +1. Add ranking features behind explainable scoring changes. +2. Land injected-context output once the ranking results are trustworthy. +3. Tune weights against real project notes and session flows. + ## Story Breakdown +- [ ] Improve Retrieval Ranking With Recency And Active Context +- [ ] Turn Search Results Into Agent-Ready Context Blocks + ## Resources +- [[.brain/brainstorms/mempalace-inspired-brain-improvements.md]] +- [[.brain/resources/references/retrieval-and-indexing.md]] +- [[.brain/planning/stories/retrieval-and-index-lifecycle-current-state-and-next-actions.md]] + ## Notes + +This spec improves how Brain chooses and packages context. It does not change the core local-first storage model. diff --git a/.brain/planning/stories/add-layered-context-loading-levels.md b/.brain/planning/stories/add-layered-context-loading-levels.md new file mode 100644 index 0000000..365072b --- /dev/null +++ b/.brain/planning/stories/add-layered-context-loading-levels.md @@ -0,0 +1,36 @@ +--- +created: "2026-04-13T06:23:52Z" +epic: context-and-session-workflow +project: brain +spec: context-and-session-workflow +status: done +title: Add Layered Context Loading Levels +type: story +updated: "2026-04-13T07:36:47Z" +--- +# Add Layered Context Loading Levels + +Created: 2026-04-13T06:23:52Z + +## Description + +Introduce explicit context tiers so agents can load minimal startup context first and request progressively deeper repo context only when needed. + + +## Acceptance Criteria + +- [ ] Brain exposes at least four context levels from core identity through deep search-driven context +- [ ] Agents can intentionally request the next context level instead of always reading everything +- [ ] Context-tier behavior is documented and deterministic + + + + +## Resources + +- [[.brain/planning/specs/context-and-session-workflow.md]] +- [[.brain/brainstorms/mempalace-inspired-brain-improvements.md]] + + + +## Notes diff --git a/.brain/planning/stories/add-session-aware-memory-distillation.md b/.brain/planning/stories/add-session-aware-memory-distillation.md new file mode 100644 index 0000000..fb8ef33 --- /dev/null +++ b/.brain/planning/stories/add-session-aware-memory-distillation.md @@ -0,0 +1,30 @@ +--- +created: "2026-04-13T06:23:52Z" +epic: planning-and-brainstorming-ux +project: brain +spec: planning-and-brainstorming-ux +status: done +title: Add Session-Aware Memory Distillation +type: story +updated: "2026-04-13T07:30:14Z" +--- +# Add Session-Aware Memory Distillation + +Created: 2026-04-13T06:23:52Z + +## Description + +Add a first-class `brain distill` workflow that inspects recent session history, command runs, and git diff, then proposes durable note updates without silently writing them. + +## Acceptance Criteria + +- [ ] Manual distill can scope to the active session and gather recent command, diff, and note context +- [ ] Distill output proposes updates for Brain-managed note targets instead of auto-applying them +- [ ] Users or agents can review and edit candidate updates before accepting them + +## Resources + +- [[.brain/planning/specs/planning-and-brainstorming-ux.md]] +- [[.brain/brainstorms/mempalace-inspired-brain-improvements.md]] + +## Notes diff --git a/.brain/planning/stories/capture-decision-rationale-as-first-class-notes.md b/.brain/planning/stories/capture-decision-rationale-as-first-class-notes.md new file mode 100644 index 0000000..8104744 --- /dev/null +++ b/.brain/planning/stories/capture-decision-rationale-as-first-class-notes.md @@ -0,0 +1,36 @@ +--- +created: "2026-04-13T06:23:52Z" +epic: planning-and-brainstorming-ux +project: brain +spec: planning-and-brainstorming-ux +status: done +title: Capture Decision Rationale As First-Class Notes +type: story +updated: "2026-04-13T07:12:12Z" +--- +# Capture Decision Rationale As First-Class Notes + +Created: 2026-04-13T06:23:52Z + +## Description + +Add a decision-note template and note conventions so Brain can preserve why a choice was made, what options were considered, and which tradeoffs were accepted. + + +## Acceptance Criteria + +- [ ] Decision notes live in a dedicated durable-memory location with a stable template +- [ ] Decision notes capture context, options, decision, and tradeoffs +- [ ] Specs, stories, or distill output can link to decision notes + + + + +## Resources + +- [[.brain/planning/specs/planning-and-brainstorming-ux.md]] +- [[.brain/brainstorms/mempalace-inspired-brain-improvements.md]] + + + +## Notes diff --git a/.brain/planning/stories/improve-retrieval-ranking-with-recency-and-active-context.md b/.brain/planning/stories/improve-retrieval-ranking-with-recency-and-active-context.md new file mode 100644 index 0000000..2a83be6 --- /dev/null +++ b/.brain/planning/stories/improve-retrieval-ranking-with-recency-and-active-context.md @@ -0,0 +1,36 @@ +--- +created: "2026-04-13T06:23:52Z" +epic: retrieval-and-index-lifecycle +project: brain +spec: retrieval-and-index-lifecycle +status: done +title: Improve Retrieval Ranking With Recency And Active Context +type: story +updated: "2026-04-13T07:17:02Z" +--- +# Improve Retrieval Ranking With Recency And Active Context + +Created: 2026-04-13T06:23:52Z + +## Description + +Tune retrieval ranking so recent notes, more durable note types, and the active work context influence what appears first without making the score story opaque. + + +## Acceptance Criteria + +- [ ] Ranking includes a measured recency boost +- [ ] Ranking can weight note types such as specs, decisions, and change notes above lower-signal notes when relevance is close +- [ ] Active session or planning context can bias results toward the work in front of the agent + + + + +## Resources + +- [[.brain/planning/specs/retrieval-and-index-lifecycle.md]] +- [[.brain/brainstorms/mempalace-inspired-brain-improvements.md]] + + + +## Notes diff --git a/.brain/planning/stories/suggest-distillation-during-session-closeout.md b/.brain/planning/stories/suggest-distillation-during-session-closeout.md new file mode 100644 index 0000000..44c36bf --- /dev/null +++ b/.brain/planning/stories/suggest-distillation-during-session-closeout.md @@ -0,0 +1,36 @@ +--- +created: "2026-04-13T06:23:52Z" +epic: context-and-session-workflow +project: brain +spec: context-and-session-workflow +status: done +title: Suggest Distillation During Session Closeout +type: story +updated: "2026-04-13T07:38:30Z" +--- +# Suggest Distillation During Session Closeout + +Created: 2026-04-13T06:23:52Z + +## Description + +When session finish detects repo change without acceptable memory updates, guide the user into a session-scoped distill flow instead of only blocking them. + + +## Acceptance Criteria + +- [ ] Session finish detects the missing-memory case and suggests a distill recovery path +- [ ] The recovery path scopes candidate updates to the active session +- [ ] Closeout can succeed after reviewed memory updates are accepted + + + + +## Resources + +- [[.brain/planning/specs/context-and-session-workflow.md]] +- [[.brain/brainstorms/mempalace-inspired-brain-improvements.md]] + + + +## Notes diff --git a/.brain/planning/stories/turn-search-results-into-agent-ready-context-blocks.md b/.brain/planning/stories/turn-search-results-into-agent-ready-context-blocks.md new file mode 100644 index 0000000..66cdc61 --- /dev/null +++ b/.brain/planning/stories/turn-search-results-into-agent-ready-context-blocks.md @@ -0,0 +1,36 @@ +--- +created: "2026-04-13T06:23:52Z" +epic: retrieval-and-index-lifecycle +project: brain +spec: retrieval-and-index-lifecycle +status: done +title: Turn Search Results Into Agent-Ready Context Blocks +type: story +updated: "2026-04-13T07:20:03Z" +--- +# Turn Search Results Into Agent-Ready Context Blocks + +Created: 2026-04-13T06:23:52Z + +## Description + +Extend search output with an inject mode that returns ranked results plus a compact markdown context block the agent can reuse immediately. + + +## Acceptance Criteria + +- [ ] Search can emit a preformatted relevant-context block +- [ ] Injected context cites the source notes it was built from +- [ ] Injected output stays markdown-native and compact enough for prompt reuse + + + + +## Resources + +- [[.brain/planning/specs/retrieval-and-index-lifecycle.md]] +- [[.brain/brainstorms/mempalace-inspired-brain-improvements.md]] + + + +## Notes diff --git a/.brain/resources/references/maintainer-global-refresh.md b/.brain/resources/references/maintainer-global-refresh.md index 684586e..b0c69e2 100644 --- a/.brain/resources/references/maintainer-global-refresh.md +++ b/.brain/resources/references/maintainer-global-refresh.md @@ -18,6 +18,8 @@ Default maintainer flow: work on a feature branch, open a PR, merge to `main`, w 4. Run required verification through `brain session run -- `. 5. Commit the branch changes. 6. Open a PR into `main`. + - Write the PR title and body in release-note language because GitHub release notes are generated from merged PR metadata. + - Summarize shipped behavior in human-readable bullets, not just implementation steps or internal refactors. 7. Review and merge the PR. 8. Wait for the automatic stable release workflow to tag and publish the new version from that merge commit on `main`. 9. Refresh the installed binary and global Codex skill: @@ -44,4 +46,5 @@ Windows PowerShell: - This flow refreshes only the global Codex `brain` skill. - It does not commit, push, or edit repo-tracked files. - Treat direct pushes to `main` as the exception, not the default. PR merge is the normal release boundary. +- Treat release-note-friendly PR copy as part of the definition of done for every PR. - Do not create a follow-up repo-memory commit just because you refreshed the global binary or skill. Otherwise the installed binary immediately lags `HEAD` again. diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..700c458 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,17 @@ +## Summary +- describe the user-facing change in release-note language +- keep this focused on shipped behavior, not implementation mechanics + +## Release Notes +- list the 1-5 highest-signal user-visible changes +- write these as human-readable bullets that can survive into GitHub-generated release notes +- if the PR is mainly a fix, say what was broken and what is now correct + +## Verification +- go test ./... +- go build ./... + +## Maintainer Notes +- if this PR changes Brain commands or agent-facing workflow guidance, update `skills/brain/SKILL.md` +- if `skills/brain/` changed, reinstall the local Brain skill for Codex and OpenClaw before closeout: + - `brain skills install --scope local --agent codex --agent openclaw --project .` diff --git a/.gitignore b/.gitignore index 31f39a5..2a38499 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,6 @@ .brain/sessions/ .brain/policy.override.yaml .brain/state/ +.codex/skills/ +.openclaw/skills/ # brain:end gitignore-session diff --git a/cmd/brainstorm.go b/cmd/brainstorm.go index 9c5e170..1cfe772 100644 --- a/cmd/brainstorm.go +++ b/cmd/brainstorm.go @@ -114,7 +114,7 @@ func addBrainstormCommand(root *cobra.Command, flags *rootFlagsState, loadApp ap var distillLimit int distillCmd := &cobra.Command{ Use: "distill ", - Short: "Create a distillation note from a brainstorm", + Short: "Create a distillation proposal from a brainstorm", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { appCtx, err := loadApp() @@ -125,12 +125,12 @@ func addBrainstormCommand(root *cobra.Command, flags *rootFlagsState, loadApp ap if err := appCtx.SyncIndex(cmd.Context()); err != nil { return err } - note, err := appCtx.Brainstorm.Distill(cmd.Context(), args[0], distillLimit) + note, err := appCtx.Distill.FromBrainstorm(cmd.Context(), args[0], distillLimit) if err != nil { return err } return appCtx.Output.Print(note, func(w io.Writer) error { - _, err := fmt.Fprintf(w, "Created distillation %s\n", note.Path) + _, err := fmt.Fprintf(w, "Created distill proposal %s\n", note.Path) return err }) }, diff --git a/cmd/cli_test.go b/cmd/cli_test.go index 2009757..5ca608d 100644 --- a/cmd/cli_test.go +++ b/cmd/cli_test.go @@ -3,6 +3,7 @@ package cmd import ( "bytes" "context" + "encoding/json" "os" "os/exec" "path/filepath" @@ -92,9 +93,15 @@ func (e *cliEnv) run(t *testing.T, stdin string, args ...string) cliResult { } func normalizeCLIOutput(s, root string) string { + s = strings.ReplaceAll(s, "\r\n", "\n") s = strings.ReplaceAll(s, root, "") + s = strings.ReplaceAll(s, filepath.ToSlash(root), "") s = rfc3339Pattern.ReplaceAllString(s, "