@jaybeeuu/agent-cortex 1.40.0 → 1.41.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 (74) hide show
  1. package/AGENTS.md +21 -8
  2. package/CHANGELOG.md +85 -0
  3. package/README.md +78 -38
  4. package/agents/README.md +5 -3
  5. package/bin/agent-cortex.mjs +36 -4
  6. package/bin/installers/claude.mjs +171 -21
  7. package/bin/installers/copilot.mjs +2 -17
  8. package/bin/installers/pi.mjs +261 -22
  9. package/claude/settings.json +4 -0
  10. package/claude-extras/scripts/statusline-command.sh +32 -4
  11. package/docs/claude-hooks.md +12 -0
  12. package/docs/ideas/ban-content-assertion-tests.md +73 -0
  13. package/docs/ideas/bead-progress-notes-for-session-resumption.md +75 -0
  14. package/docs/ideas/classify-beads-via-deterministic-script-with-agent-fallback.md +70 -0
  15. package/docs/ideas/ctx-alias-version-and-update-commands.md +65 -0
  16. package/docs/ideas/ctx-feedback-command-for-capturing-ideas-from-any-machine.md +67 -0
  17. package/docs/ideas/deployment-beads-for-post-merge-pipelines.md +36 -0
  18. package/docs/ideas/design-and-delivery-as-separate-bead-trees/design-and-delivery-as-separate-bead-trees.md +99 -0
  19. package/docs/ideas/enable-signed-commit-enforcement-changesets-bot-commits-must-be-signed.md +33 -0
  20. package/docs/ideas/extension-manifests.md +55 -14
  21. package/docs/ideas/improve-pi-system-prompt.md +5 -2
  22. package/docs/ideas/map-every-cortex-tool-to-a-real-pi-equivalent.md +95 -0
  23. package/docs/ideas/record-idea-implementation-questions.md +68 -0
  24. package/docs/ideas/self-flushing-session.md +72 -0
  25. package/docs/ideas/state-in-beads-not-md.md +69 -0
  26. package/docs/ideas/task-session-context.local.md +95 -0
  27. package/docs/ideas/test-data-creation-helpers.md +92 -0
  28. package/docs/ideas/test-planning-stage-bead-in-feature-planning.md +68 -0
  29. package/docs/ideas/worktree-housekeeping-for-closed-beads.md +39 -0
  30. package/docs/technical-direction/harness-config.md +161 -0
  31. package/docs/technical-direction/migration-execution-labels.md +60 -23
  32. package/extensions/agent-guardrails/README.md +45 -0
  33. package/extensions/agent-guardrails/guardrails.test.ts +42 -0
  34. package/extensions/agent-guardrails/guardrails.ts +66 -0
  35. package/extensions/agent-guardrails/index.ts +22 -0
  36. package/extensions/agent-guardrails/node_modules/.bin/pi +21 -0
  37. package/extensions/agent-guardrails/node_modules/.bin/tsc +21 -0
  38. package/extensions/agent-guardrails/node_modules/.bin/tsserver +21 -0
  39. package/extensions/agent-guardrails/node_modules/.bin/tsx +21 -0
  40. package/extensions/agent-guardrails/package.json +19 -0
  41. package/extensions/agent-guardrails/tsconfig.json +12 -0
  42. package/extensions/agent-modes/README.md +9 -3
  43. package/extensions/agent-modes/index.test.ts +208 -0
  44. package/extensions/agent-modes/index.ts +23 -6
  45. package/extensions/agent-modes/package.json +1 -1
  46. package/lib/cli.mjs +8 -2
  47. package/lib/pi-packages.mjs +169 -0
  48. package/package.json +5 -1
  49. package/pi/settings.json +23 -12
  50. package/plugin.json +1 -1
  51. package/scripts/lib/fs.mjs +31 -0
  52. package/skills/planning/classify-bead/REFERENCE.md +85 -0
  53. package/skills/planning/classify-bead/SKILL.md +32 -36
  54. package/skills/planning/classify-bead/scripts/classify-bead.mjs +292 -0
  55. package/skills/planning/create-task/REFERENCE.md +1 -1
  56. package/skills/planning/create-task/SKILL.md +20 -11
  57. package/skills/planning/create-task/scripts/create-chores.ts +4 -0
  58. package/skills/planning/write-a-prd/SKILL.md +2 -2
  59. package/skills/style/style-code/REFERENCE.md +32 -2
  60. package/skills/style/style-code/SKILL.md +9 -21
  61. package/skills/style/style-tests/EXAMPLES.md +548 -0
  62. package/skills/style/style-tests/SKILL.md +84 -33
  63. package/skills/workflow/run-pipeline-stage/SKILL.md +13 -1
  64. package/skills/workflow/run-pipeline-stage/prompts/stage-runner.md +12 -0
  65. package/test/classify-bead.test.mjs +277 -0
  66. package/test/cli.test.mjs +55 -11
  67. package/test/create-chores.test.mjs +73 -0
  68. package/test/fs.test.mjs +76 -0
  69. package/test/helpers/fake-bd.mjs +67 -0
  70. package/test/installer.test.mjs +237 -4
  71. package/test/pi-installer.test.mjs +343 -4
  72. package/test/pi-packages.test.mjs +295 -0
  73. package/token-map.README.md +4 -2
  74. package/token-map.json +3 -3
@@ -1,7 +1,11 @@
1
1
  # Idea: extension-manifests
2
2
 
3
3
  ## Status
4
- Backlog idea (not implementation-ready)
4
+ **Superseded (2026-09-22)** — the bespoke per-harness manifest model was replaced by each
5
+ harness's native dependency fields plus committed settings templates. See the decision memo
6
+ [`docs/technical-direction/harness-config.md`](../technical-direction/harness-config.md). The
7
+ prune TUI was rejected (see "Prune rejected") and the proposed declared-vs-installed diff was
8
+ dropped — `agent-cortex install <harness>` reconciles instead.
5
9
 
6
10
  ## Created
7
11
  2026-08-25
@@ -12,12 +16,13 @@ live implicit in the machine's state (`~/.pi/agent/extensions/`) with no declare
12
16
  what the author uses or where it came from. A fresh machine, clean `~/.pi`, or a failed update
13
17
  leaves the environment without the expected extensions. The toolset isn't reproducible and
14
18
  isn't documented anywhere in the author's repos. Experimenting with an extension (install, try,
15
- remove) is also all manual, and there's no way to uninstall cleanly.
19
+ remove) is also all manual, and there is no view of how the machine differs from the declared set.
16
20
 
17
21
  ## Who benefits
18
22
  The author. Installing/updating agent-cortex becomes a reliable way to restore a known PI +
19
23
  Claude environment (agent-cortex + declared extensions in one step). The manifests document and
20
- reproduce the toolset across machines. A prune CLI makes extension experimentation fast and safe.
24
+ reproduce the toolset across machines. A declared-vs-installed diff makes drift visible and
25
+ repairable.
21
26
 
22
27
  ## Proposed outcome
23
28
  agent-cortex ships **committed extension manifests** (reviewed and stored on GitHub) declaring
@@ -37,10 +42,41 @@ Key decisions from the interview:
37
42
  TUI listing locally-installed extensions; selecting one **uninstalls** it from the local
38
43
  environment. Removing from the manifest is done manually on GitHub. This supports the
39
44
  experimentation loop: install → try → prune locally, then curate the manifest separately.
45
+ **Reversed 2026-09-21** — the harnesses already provide uninstall; see "Prune rejected".
40
46
 
41
47
  agent-cortex's own bundled extensions (auto-discovered via `pi install`, e.g. `skill-stats`)
42
48
  are deliberately excluded from the manifests — only third-party extensions are declared.
43
49
 
50
+ ## What shipped (2026-09-18)
51
+
52
+ The pi half of the problem is solved without a new manifest file: the packages agent-cortex
53
+ needs are declared in the **existing** package manifest at `package.json` → `pi.packages`, and
54
+ `agent-cortex install pi` provisions them through the `pi` CLI into the pi user scope
55
+ (`lib/pi-packages.mjs`). Reusing the shipped manifest beat introducing a parallel per-harness
56
+ manifest file, which would have duplicated a declaration agent-cortex already publishes.
57
+
58
+ Three properties are deliberate and should survive future changes: provisioning is
59
+ **idempotent** (a package both declared in `~/.pi/agent/settings.json` and present in the pi npm
60
+ store is skipped), **degrades gracefully** (a missing `pi` CLI or a failed install warns and the
61
+ agent install still succeeds), and is **opt-out** via `--no-provision` — automatically off for the
62
+ `--output` generate-only form, and never run on `--dry-run`.
63
+
64
+ Still unbuilt: the Claude/Copilot manifest. `pi/settings.json` also lists these
65
+ packages for the symlinked-checkout workflow (where pi auto-installs them); that redundancy is
66
+ intentional until the manifest model is extended to both harnesses.
67
+
68
+ ## Prune rejected (2026-09-21)
69
+
70
+ The prune half was implemented (F6, `agnt-ctx-17hc`) and then rejected: PR #142 was closed
71
+ unmerged and its branch deleted. The harnesses already own extension package management —
72
+ `pi install/remove/list` and `claude plugin install/uninstall/list --json` — so an interactive
73
+ wrapper around uninstall added no capability. The implementation's recorded justification that
74
+ "pi does not have a listing API" is **wrong**: `pi list` exists (verified on pi 0.85.1) and lists
75
+ installed packages from user and project settings, so the hand-rolled settings reader duplicated
76
+ it. What is genuinely missing is not an uninstall UI but reconciliation between the declared set
77
+ and the installed set — now delivered by materialising the committed settings template at
78
+ install time (see the [harness-config memo](../technical-direction/harness-config.md)).
79
+
44
80
  ## Validity check
45
81
  - Evidence we already have: agent-cortex already has an install surface to hang this on
46
82
  (`pi install` package discovery for the pi harness, plus the existing `bin/agent-cortex.mjs`
@@ -48,11 +84,11 @@ are deliberately excluded from the manifests — only third-party extensions are
48
84
  harness) alongside `package.json` (pi harness), showing the per-harness split is natural.
49
85
  - Riskiest assumption: that an automated install-on-update of declared extensions is safe and
50
86
  desirable (auto-installing on every update could surprise, or fail mid-flight on a new
51
- machine lacking auth/network). Also, the TUI prune needs the local extension store's shape
52
- (`~/.pi/agent/extensions/` for pi; whatever Claude uses) to be introspectable.
87
+ machine lacking auth/network). The store-shape question that gated the (now rejected) prune
88
+ TUI is resolved: both harnesses expose a listing API (`pi list`; `claude plugin list --json`).
53
89
  - What would invalidate this idea: if auto-install-on-update proves too disruptive (better as
54
- an explicit `agent-cortex ext install` command), or if the pi/Claude installers don't expose
55
- the store in a way that supports listing + uninstall for the TUI.
90
+ an explicit `agent-cortex ext install` command). The prune half is already invalidated — see
91
+ "Prune rejected".
56
92
 
57
93
  ## Constraints
58
94
  - Manifests live in this repo, committed via the normal PR flow — the CLI never edits them.
@@ -62,14 +98,19 @@ are deliberately excluded from the manifests — only third-party extensions are
62
98
  - If any local data is persisted (e.g. prune history), write to `~/.pi/agent-cortex/`.
63
99
 
64
100
  ## Next validation step
65
- Confirm the install surface for each harness: how `pi install <source>` works for the pi side,
66
- and how Claude/Copilot plugins get installed, plus whether each store can be listed and
67
- uninstalled programmatically (needed for the prune TUI). Then prototype the manifest + one
68
- harness's install-on-update path.
101
+ None — the direction is settled. The store question is answered (both harnesses expose a listing
102
+ API: `pi list`; `claude plugin list --json`), and the manifest model is superseded by native
103
+ dependency fields plus committed settings templates. See the
104
+ [harness-config memo](../technical-direction/harness-config.md) for the replacement.
69
105
 
70
106
  ## Notes
71
107
  Recorded 2026-08-25. The idea was refined during the interview: initially framed as
72
108
  "record the extensions I use" (observer-based), corrected to a **committed manifest** model —
73
- recording happens by editing + committing, not by monitoring. Prune uninstalls locally only;
74
- the manifest stays GitHub-managed. This idea is adjacent to `record-ideas-as-beads`: both make
75
- agent-cortex the declared source of truth for the author's environment and workflow.
109
+ recording happens by editing + committing, not by monitoring. The manifest stays GitHub-managed
110
+ (the CLI never writes it); the prune CLI was rejected, so local uninstall stays with the
111
+ harnesses' own commands. This idea is adjacent to `record-ideas-as-beads`: both make
112
+ agent-cortex the declared source of truth for the author's environment and workflow.
113
+
114
+ **Superseded 2026-09-22.** The declared toolset is now expressed through `package.json`
115
+ dependencies (required) and committed settings templates (optional), not a bespoke manifest —
116
+ see the [harness-config memo](../technical-direction/harness-config.md).
@@ -1,7 +1,9 @@
1
1
  # Idea: Improve PI System Prompt
2
2
 
3
3
  ## Status
4
- Backlog idea (not implementation-ready)
4
+ Backlog idea (not implementation-ready) — first slice (circuit-breakers, check-in triggers,
5
+ atomic-change discipline) implemented as the `agent-guardrails` pi extension; the rest of the
6
+ idea is unscoped.
5
7
 
6
8
  ## Why it might be useful
7
9
  PI's current system prompt is weak. Agents consistently get off track, spend excessive tokens spinning their wheels or going off on tangents, fail to check in when problems are hit, and generally behave like inexperienced code goblins. This wastes tokens, slows down task completion, and forces the user to constantly redirect the agent. A stronger system prompt would produce more focused, disciplined agents that know when to stop and ask.
@@ -26,9 +28,10 @@ High — after current work lands. Directly impacts daily productivity and token
26
28
  - Layer on top of PI's default prompt, or replace it entirely?
27
29
  - Should PI's current system prompt be reviewed for nonsense that can be chopped out?
28
30
  - Which guardrails from the Gemini starter are genuinely useful vs redundant with existing skills (e.g. `git-workflow` already covers destructive commands, `style-code` covers scope discipline)?
29
- - How should circuit-breakers interact with skills like `run-pipeline-stage` that already have structured workflows?
30
31
 
31
32
  ## Notes
33
+ - **Precedence (settled by the first slice)**: the generic circuit-breakers yield to a structured
34
+ workflow — a skill or pipeline stage with its own explicit retry and check-in rules wins.
32
35
  - **Gemini starter prompt** exists (see conversation from 2026-08-05) covering loop prevention, action scope, context management, execution workflow order, and working state maintenance. Useful starting material but needs heavy customisation.
33
36
  - **Incompatibility to fix**: the starter's "Working State Maintenance" section proposes `.pi/PLAN.md` files for complex tasks. This is incompatible with agent-cortex — we use **beads (bd)** for task tracking and pipeline stages, not flat markdown plan files. This section needs to be replaced with bead-aware equivalents (e.g. updating bead notes, using pipeline stage state).
34
37
  - **Overlap with existing skills**: several guardrails already exist in agent-cortex skills (`git-workflow`, `style-code`, `run-pipeline-stage`). The biggest gaps are **loop prevention / circuit-breakers** and **check-in discipline** — these aren't enforced anywhere today.
@@ -0,0 +1,95 @@
1
+ # Idea: Map every cortex tool to a real PI equivalent
2
+
3
+ ## Status
4
+ Slice 1 shipped 2026-09 via bead agnt-ctx-f4au: `ask_user` → `ask_questions` and
5
+ `skill` → `read` remapped in `token-map.json`; agent-modes startup warnings gone,
6
+ verified in real pi sessions. Open follow-ons: full coverage audit of every frontmatter
7
+ tool; dedicated skill-tool candidate if prompting proves insufficient.
8
+
9
+ ## Created
10
+ 2026-09-08
11
+
12
+ ## Problem
13
+ On every pi startup, agent-modes warns once per declared tool that has no pi mapping:
14
+ `[agent-modes] Tool "ask_user" has no PI equivalent — omitted from the tool set` (plus
15
+ `{{TOOL:ask_user}}` token drops). Today `ask_user` and `skill` produce this noise across
16
+ the `ralph-plan`, `plan`, and `strategy` modes.
17
+
18
+ Worse than noise: dropping `ask_user` **silently removes interactive grilling** from
19
+ `ralph-plan`/`plan` in pi — a functional gap disguised as a warning. The root cause is
20
+ that `token-map.json` declares `pi: null` for `ask_user` and `skill`, and agent-modes
21
+ omits null-mapped tools rather than mapping them to the real pi equivalent.
22
+
23
+ ## Who benefits
24
+ - The author, in every pi session: clean startup, no recurring warnings.
25
+ - `plan`/`strategy`/`ralph-plan` in pi: regain interactive user questioning (via
26
+ `ask_questions`) and a documented, reliable skill-loading path.
27
+ - Anyone maintaining cortex: a codified principle so future harness gaps surface loudly
28
+ and are resolved deliberately instead of silently degrading agent capability.
29
+
30
+ ## Proposed outcome
31
+ - **Principle**: every tool a cortex agent declares in its frontmatter must have a real
32
+ pi-side representation — either a native pi tool (mapped in `token-map.json`) or a pi
33
+ tool-extension package (found, adopted, or designed). An unmapped tool should be a
34
+ loud error, not a startup warning. "If pi needs more extensions to work, we add more."
35
+ - **Coverage audit**: every tool across `agents/*/pi/frontmatter.json` checked against
36
+ the pi toolset; each gap resolved by mapping or by adopting/designing an extension.
37
+ - **Immediate remaps**: `ask_user` → `ask_questions` (pi's native structured-questions
38
+ tool); `skill` → documented as "read the listed SKILL.md path" for now (pi has no
39
+ skill tool — skills are context-listed + read-loaded), with a dedicated skill tool
40
+ recorded as a follow-on design candidate if prompting proves insufficient.
41
+
42
+ ## Validity check
43
+ - Evidence we already have:
44
+ - The warnings reproduce on every pi startup in agent-nexus (seen 2026-09-08).
45
+ `token-map.json` maps both `ask_user` and `skill` to `pi: null`, and its notes claim
46
+ pi ships no ask tool and no skill tool.
47
+ - That note is outdated for the questioning case: pi's equivalent is `ask_questions`, a
48
+ structured user-question tool provided by the **pi-questions** package (`pi install
49
+ npm:pi-questions`; declared in the author's pi/settings.json) — present in this session's
50
+ toolset, but extension-provided, not native to pi. Mapping `ask_user` to it restores
51
+ grilling in pi modes *when the package is installed*; making the package install
52
+ reproducible is the extension-manifests idea (see `extension-manifests.md`).
53
+ - pi's own skills docs (skills.md, step 3) confirm skills load via `read` and concede
54
+ "models don't always do this" — so a doc-now mapping is legitimate but the
55
+ self-invocation gap is real and acknowledged upstream.
56
+ - Precedent for external tools on pi exists: the pi-hypa package adds `hypa_*` tools
57
+ and context-mode adds `ctx_*` tools; distribution is `pi install npm:@...`.
58
+ - Riskiest assumption: that `ask_questions` is a faithful-enough substitute inside
59
+ restricted mode tool lists — i.e. that mode tool filters will admit it and the
60
+ agents actually exercise mid-run questioning in pi.
61
+ - What would invalidate this idea:
62
+ - If remapping `ask_user` → `ask_questions` does not restore questioning in pi modes
63
+ (e.g. mode tool lists are a hard allow-list that excludes it), the headline fix is
64
+ a no-op and the problem needs a different shape.
65
+ - If a package scan finds no existing skill tool AND prompting proves sufficient in
66
+ practice, the "skill tool later" half should be dropped or demoted to a note.
67
+
68
+ ## Constraints
69
+ - Cortex conventions: extensions stay lightweight (no internal LLM calls); agents/skills
70
+ come from composable sources; `token-map.json` is the single source of truth for
71
+ cross-harness tool naming; changes ship via `pnpm changeset`.
72
+ - pi intentionally has no permission popups — the mapping must map onto what pi is, not
73
+ force pi semantics to change.
74
+ - agent-modes currently warns-and-omits null tools and passes unknown names through;
75
+ flipping gaps to loud errors changes that contract, and generated copilot/claude
76
+ output (which already has real mappings) must stay stable.
77
+
78
+ ## Next validation step
79
+ - (done — shipped via agnt-ctx-f4au) Remap `ask_user` → `ask_questions` in `token-map.json`, then run a pi session in
80
+ `ralph-plan`/`plan` mode and confirm the tool is available and the startup warning is
81
+ gone. If it works, ship that remap first (smallest verifiable slice).
82
+ - Scan npm/pi packages for an existing skill-invocation tool before designing one —
83
+ adopt over invent (same stance as the user's marketplace instinct).
84
+ - Run the audit: list every tool across `agents/*/pi/frontmatter.json` and mark each as
85
+ mapped-native / mapped-extension / unmapped.
86
+
87
+ ## Notes
88
+ - Current pi-mode declarations: `ralph-plan` = bash view edit create grep glob ask_user;
89
+ `plan` adds task read_agent skill; `strategy` adds ask_user skill web_fetch.
90
+ - `token-map.json` notes for `ask_user` ("pi intentionally ships no permission-popup/ask
91
+ tool") and `skill` ("pi discovers skills but the agent loads them via read and
92
+ /skill:name") both need updating if the mappings change.
93
+ - pi keeps skill affordances present without a skill tool via the always-listed
94
+ "Available skills — invoke when relevant" context block; the doc-now `skill` mapping
95
+ builds on that existing mechanism.
@@ -0,0 +1,68 @@
1
+ # Idea: record-idea-implementation-questions
2
+
3
+ ## Status
4
+ Folded into bead `agnt-ctx-s5xd.2.2` (2026-09-22) — the `record-idea` bead rewrite absorbs these
5
+ questions and the `## Design so far / provenance` section. Not a standalone bead.
6
+
7
+ ## Created
8
+ 2026-08-30
9
+
10
+ ## Problem
11
+ The `record-idea` interview captures *why / how / when / priority* but not enough about the
12
+ implementation to give a recorded idea a sufficient shape. Ideas often arrive with backstory —
13
+ they've come from somewhere (a previous session, a conversation, a pain point in another
14
+ skill), they carry partial design thoughts or ruled-out approaches, and a bare title plus
15
+ "how we might do it" loses that detail. The record ends up thinner than the thinking that
16
+ produced it.
17
+
18
+ ## Who benefits
19
+ Anyone reading an idea record later (the author, plan agents, ralph) — a record with an
20
+ implementation shape and its provenance is far easier to pick up than one that restates the
21
+ title. The author also saves re-explaining context: capture it once, at the source.
22
+
23
+ ## Proposed outcome
24
+ Extend the `record-idea` interview and template:
25
+
26
+ 1. **A fixed, short set of implementation questions** baked into the interview — roughly:
27
+ - Rough mechanism: what shape would the implementation take (skill / extension / agent /
28
+ script / convention)?
29
+ - Known constraints or tradeoffs already spotted?
30
+ - Existing design thoughts: anything already designed, sketched, or ruled out?
31
+ 2. **A couple of adaptive follow-ups** when the fixed answers open a thread worth pulling —
32
+ but explicitly bounded: this is capture, not solutionising. The moment the conversation
33
+ drifts into implementation detail, stop and record.
34
+ 3. **New template section** — e.g. `## Design so far / provenance` — where pre-existing
35
+ thoughts (where the idea came from, partial designs, discarded options) are recorded so
36
+ they survive under the title instead of being lost.
37
+
38
+ ## Validity check
39
+ - Evidence we already have: the last few recorded ideas (self-flushing-session,
40
+ state-in-beads-not-md) arrived with real backstory — provenance and pre-existing design
41
+ choices were captured only because the session happened to cover them; the skill itself
42
+ doesn't ask. The existing interview already draws out why/how/when/priority, so adding two
43
+ more question groups is a small, natural extension.
44
+ - Riskiest assumption: the balance between "capture shape" and "solutionising session".
45
+ Too many follow-ups and the interview bloats; the record becomes a design doc and the
46
+ author resists using the skill. Needs an explicit off-ramp ("enough — record it").
47
+ - What would invalidate this idea: if the fixed questions mostly produce "unknown / not
48
+ thought about yet" answers — then the added friction isn't buying anything and the template
49
+ section stays empty. Watch whether follow-ups actually surface design thoughts in practice.
50
+
51
+ ## Constraints
52
+ - Keep the interview fast: a couple of questions, a couple of bounded follow-ups, then record.
53
+ - Must not turn into a solutionising session — capture existing thinking, don't generate new
54
+ design.
55
+ - Lands naturally alongside the `record-ideas-as-beads` rewrite of `record-idea` (bead-based
56
+ creation): this skill change rides that migration rather than forking it.
57
+
58
+ ## Next validation step
59
+ Fold the fixed questions + `## Design so far / provenance` section into `record-idea` next
60
+ time it's exercised (or during the record-ideas-as-beads rewrite), then check the next few
61
+ records: did they capture backstory that would otherwise have been lost, and did the
62
+ interview stay short?
63
+
64
+ ## Notes
65
+ Recorded 2026-08-30 (P2). Applies to the current file-based flow and the future bead-based
66
+ flow (`record-ideas-as-beads` plans interview → `bd create --notes ...`; the provenance
67
+ section maps into `--notes` with markers). Explicitly a capture improvement, not a design
68
+ step — the line is: record what the user already thinks, don't co-design with them.
@@ -0,0 +1,72 @@
1
+ # Idea: self-flushing-session
2
+
3
+ ## Status
4
+ Backlog idea (not implementation-ready) — priority P1 (high)
5
+
6
+ ## Created
7
+ 2026-08-30
8
+
9
+ ## Problem
10
+ Sessions hold context far longer than needed. Every turn, tangent, and tool call stays in
11
+ the window until a human notices the bloat and compacts or resets. The opposite of the
12
+ current default: the agent should own its context lifecycle. It holds context *just long
13
+ enough* to record the immediate outcome — as a bead — and then dumps everything, keeping
14
+ only the bead ID. State is the enemy: no more than the immediately useful context is kept
15
+ at any moment.
16
+
17
+ ## Who benefits
18
+ The author daily (token cost + focus — sessions never bloat, ever, regardless of how long
19
+ the overall thread runs), and every future agent that must run long-lived threads. Beads
20
+ become the entire memory surface: searchable, syncable, dependency-aware — no separate
21
+ transcript or memory file to maintain.
22
+
23
+ ## Proposed outcome
24
+ A session model where:
25
+ 1. **The agent decides when to flush.** No human noticing bloat and intervening — the agent
26
+ watches for task completion and purges its own context.
27
+ 2. **Hold just enough** to write the immediate outcome as a bead, then **dump all context,
28
+ keeping the bead ID**. The ID is the only thing that survives the flush.
29
+ 3. **Beads are the memories.** No separate memory store; the beads *are* the session memory.
30
+ Progressively discovered — a fresh context pulls in relevant beads on demand (by ID/deps/
31
+ labels) rather than exchanging the whole history every turn.
32
+ 4. **A parent bead represents the session.** One session bead per conversation; the child
33
+ memory beads (outcomes) hang under it, discovered progressively rather than loaded whole.
34
+
35
+ Flush trigger to be fleshed out at design time: *"once a task is complete — that probably
36
+ means a bead is written, but might not."* So: task completion is the event; bead-writing is
37
+ the expected (but not guaranteed) artifact of it.
38
+
39
+ ## Validity check
40
+ - Evidence we already have: beads natively support parent/child hierarchy (`--parent`), labels,
41
+ deps, search (`bd label`, `bd list`), and the ralph pipeline already treats beads as
42
+ self-contained executable units. `task-session-context` (recorded 2026-08-25) establishes the
43
+ "session is disposable, bead is the artifact" principle — this idea is the mechanism for it.
44
+ - Riskiest assumption: an agent deciding to purge its *own* context is self-referential —
45
+ mid-flush failures, deciding to dump while in-flight state matters, or dumping too early
46
+ would lose work. Also: whether the harness (pi/Copilot CLI) exposes enough session-lifecycle
47
+ control (start/stop/seed context, hard reset mid-thread) to make the flush mechanical rather
48
+ than prompt-instructed.
49
+ - What would invalidate this idea: if flush can't be made reliable as a mechanism (prompt-level
50
+ "now clear your context" is fragile — the harness may not actually drop context), or if
51
+ progressive discovery from beads proves lossy enough that flushed tasks mis-execute.
52
+
53
+ ## Constraints
54
+ - State minimisation is the point: keep only what the current task needs.
55
+ - The bead ID is the only cross-flush pointer — everything else must be re-discoverable.
56
+ - Must compose with existing loops: ralph stages, HITL handoffs, record-idea flow.
57
+ - Extension vs agent is unresolved by design: an **extension** could mechanize flush + bead
58
+ write via event hooks; an **agent** could own the session lifecycle and decide. Both recorded
59
+ as candidate shapes — decide at design time.
60
+
61
+ ## Next validation step
62
+ Design-time fleshing-out: nail the flush trigger rules, the parent-session-bead structure,
63
+ how a fresh context seeds itself (pull-by-ID vs pull-by-label), and whether pi/Copilot expose
64
+ enough lifecycle control for a mechanical flush. Then a spike: one task completing → bead
65
+ written → flush → fresh context re-seeding from the bead ID without losing the thread.
66
+
67
+ ## Notes
68
+ Recorded 2026-08-30 (P1, high). Cross-linked with `task-session-context` (principle) — this
69
+ record is the sharper mechanism: autonomous flush, beads-as-memory (no separate store), parent
70
+ session bead. Also adjacent to `pi-task-memory` (progressive discovery of memories) and
71
+ `state-in-beads-not-md` (notes/state live in beads, not files) — the three records converge on
72
+ "beads are the durable unit; context is a disposable implementation detail".
@@ -0,0 +1,69 @@
1
+ # Idea: state-in-beads-not-md
2
+
3
+ ## Status
4
+ Recorded as bead `agnt-ctx-ul91` (2026-09-22) — awaiting `plan`. Merged with
5
+ `bead-progress-notes-for-session-resumption.md` into one bead state model design (this file is
6
+ Part 1: WHERE state lives).
7
+
8
+ ## Created
9
+ 2026-08-30
10
+
11
+ ## Problem
12
+ Skills write a lot of operational documents that are never meant to be committed or read
13
+ by humans at rest — they describe transient notes/current state. Today they land as md files:
14
+ - `hitl-collab` writes `.agent-cortex/working-docs/hitl/<bead-id>/handoff.md` — one file per
15
+ bead, near-duplicating information that already lives (or should live) on the bead.
16
+ - `run-pipeline-stage` / `ralph` write `.agent-cortex/ralph/ralph-{bead-id}.log` and
17
+ `.agent-cortex/ralph/progress.md` for live progress surfacing.
18
+ These files duplicate bead state, rot as the bead changes, and fragment context across
19
+ files + beads. They're also invisible to `bd` tooling (search, deps, sync).
20
+
21
+ ## Who benefits
22
+ Every agent skill run that produces state (hitl-collab, ralph, run-pipeline-stage, plan,
23
+ and any future skill that takes notes). The author benefits from a single source of truth,
24
+ and ralph/pipeline state stops living in a `.agent-cortex` attic that drifts from the beads.
25
+
26
+ ## Proposed outcome
27
+ A general rule stored in agent docs: **any artifact that is notes/current state — not
28
+ intended as committable durable documentation — lives in the bead's fields** (`--notes`,
29
+ `--context`, `--design`), not in md files.
30
+ - Durable, committable docs (SKILL.md, REFERENCE.md, playbooks/, prompts/, docs/) stay files.
31
+ - `hitl-collab` handoff: write the handoff content into the HITL bead (`--context`/`--notes`),
32
+ drop the `.agent-cortex/working-docs/hitl/<bead-id>/handoff.md` file flow.
33
+ - ralph progress/log lines: feed a live progress view off the beads (or a temp/log file kept
34
+ explicitly out of the `working-docs` convention) — spike details during planning.
35
+ - `record-idea`'s caveat: this same principle is what `record-ideas-as-beads` already applies
36
+ to idea records; this idea generalises it to operational/state artifacts.
37
+
38
+ ## Validity check
39
+ - Evidence we already have: `bd` fields (`--notes`, `--context`, `--design`) support the content
40
+ model; `record-ideas-as-beads` already proves bead-field content is workable for structured
41
+ records (design decided 2026-08-25). Bead notes are multi-line and markdown-capable.
42
+ - Riskiest assumption: live progress surfacing (ralph's log tail / progress.md) can be
43
+ satisfied without a scratch file — the bead-update round-trip may be too slow/chatty for
44
+ high-frequency log lines; may need a per-run scratch log that is explicitly ephemeral and
45
+ deleted on close, rather than a persistent working doc.
46
+ - What would invalidate this idea: if bead fields become unwieldy for large attachments (e.g.
47
+ long PR summaries), or if a future agent needs shared state that must not be per-bead
48
+ (cross-bead coordination) — that's a different problem, not a per-bead note.
49
+
50
+ ## Constraints
51
+ - Bead content is portable and searchable: `bd show <id>` must remain a comfortable read
52
+ surface for handoff/notes.
53
+ - Never regress committable docs into beads (AGENTS.md/skills stay in-repo markdown).
54
+ - P2 (medium): actively annoying today — hitl-collab handoff docs are already duplicating
55
+ bead state.
56
+
57
+ ## Next validation step
58
+ Pick one skill (hitl-collab is the smallest, clearest case): prototype writing the handoff
59
+ into the bead's `--context` (or `--notes`) and read it back with `bd show`, confirm the
60
+ HITL reader (ralph/plan/handoff skill) can consume bead-stored handoffs; then extend the
61
+ rule to ralph progress with an ephemeral-scratch-log fallback if needed.
62
+
63
+ ## Notes
64
+ Cross-link: sibling idea `record-ideas-as-beads` (fleshed out 2026-08-25) covers ideas
65
+ specifically — once it lands, docs/ideas/ disappears and this record becomes a bead too.
66
+ The rule here is the generalisation: beads are for state, files are for durable docs.
67
+ Skills that currently write working docs: `hitl-collab` (handoff.md), `ralph` +
68
+ `run-pipeline-stage` (ralph-*.log, progress.md). Update `bd-tool`/`git-workflow`/AGENTS.md
69
+ conventions if the rule lands.
@@ -0,0 +1,95 @@
1
+ # Idea: task-session-context
2
+
3
+ ## Status
4
+ Backlog idea (not implementation-ready)
5
+
6
+ ## Created
7
+ 2026-08-25
8
+
9
+ ## Problem
10
+ Coding sessions accumulate context turn by turn: every question, every tool call, every
11
+ tangent stays in the window until it's manually compacted or the session is restarted. Keeping
12
+ the context small and relevant is an active management burden — the author has to notice the
13
+ bloat, decide what matters, and intervene. Long conversations either burn tokens or require
14
+ frequent manual resets that drop useful memory.
15
+
16
+ ## Who benefits
17
+ The author, daily. Removing context management from the loop means sessions stay small and
18
+ focused no matter how long the overall thread runs. It also produces a durable, reviewable log
19
+ of work: each task's bead + summary memory is an audit trail of what was done and why.
20
+
21
+ ## Proposed outcome
22
+ A workflow organised around **tasks** instead of sessions. Whenever the user does something
23
+ discrete — asks a new question, records an idea, fleshes out a piece of work — it **begins a
24
+ task**:
25
+
26
+ 1. **Task = blank session with memory context.** The task starts a fresh, self-contained
27
+ session. It does NOT get every turn and tool call of the parent conversation — only access
28
+ to the accumulated **memories** of what came before (a summary/compressed view, not the raw
29
+ transcript).
30
+ 2. **Self-contained execution.** The task works on its own: it takes action, and **records
31
+ memories along the way** as it produces outcomes.
32
+ 3. **Single summary memory on completion.** The last thing a task does is write one summary
33
+ memory capturing its outcome. These memories are additive — the running memory store grows as
34
+ tasks complete.
35
+ 4. **Fresh session continues the thread.** Once the task completes, a new session starts with
36
+ access to the memories — including the new summary — so to the user it feels like one
37
+ continuous thread, but each underlying session stays small.
38
+
39
+ **Ties into beads (bd):** "the completion of a bead is the completion of a task". A bead becomes
40
+ the log of work completed: the task's outcome is recorded on/with the bead, the fresh session
41
+ starts, and the bead is accompanied by **referential memory** (a pointer/memory entry that links
42
+ the outcome to the bead). So the bead doubles as the durable record AND the context-boundary
43
+ marker: starting a bead is the trigger for task-session separation.
44
+
45
+ **The bead is the artifact — the session is disposable.** Once a task is complete, the whole
46
+ conversation context is no longer needed; the bead is the artifact. The current conversation is
47
+ the live example: recording this idea is a task, and when it's done the transcript of every turn
48
+ and tool call can be discarded — what remains is the record plus its summary/referential memory.
49
+ This is the load-bearing philosophical point of the idea: sessions exist to serve tasks, not the
50
+ other way around. Context is an implementation detail of a single task; the bead is the durable
51
+ unit of history.
52
+
53
+ The mechanism likely needs: a memory store (per-project, e.g. under `~/.pi/agent-cortex/` or a
54
+ records convention), a session-scoping rule (what memories a fresh task session is seeded with),
55
+ the summary-writing step, and the bead ↔ memory linkage.
56
+
57
+ ## Validity check
58
+ - Evidence we already have: the repo already runs on beads as the unit of work (bd), and the
59
+ ralph pipeline already treats beads as self-contained executable units — so task-per-bead
60
+ separation is a natural extension of an existing pattern. Existing ideas
61
+ (`record-ideas-as-beads`, `pi-task-memory`, `extension-manifests`) all push in the direction of
62
+ making agent-cortex the declared, memory-rich source of truth.
63
+ - Riskiest assumption: that a fresh session seeded with *memories only* (no raw transcript) is
64
+ sufficient context for a task — the compression of a conversation into memories must not lose
65
+ the specifics a task needs. Also: whether the harness (pi/Claude) even supports programmatic
66
+ session spawning with a seed context cleanly enough for this to feel seamless.
67
+ - What would invalidate this idea: if memory-as-context proves lossy in a way that keeps tasks
68
+ mis-executing (then the blank-session model needs the raw transcript after all, defeating the
69
+ point); or if the session boundary machinery (start/stop/spawn with seed) fights the harness.
70
+
71
+ ## Constraints
72
+ - Sessions must stay small — this is the whole point; memory is the interface, not the transcript.
73
+ - Memories are additive and durable; the summary memory is the handoff contract between tasks.
74
+ - The bead is the work log AND the context boundary: no task completion without its summary
75
+ memory and bead record.
76
+ - Must not break the existing task loops (ralph pipeline stages, HITL handoffs) — it should
77
+ compose with them, not fork them.
78
+
79
+ ## Next validation step
80
+ Flesh-out session (proposed by the author): nail down the trigger rules (what counts as "begin a
81
+ task"), the memory store schema and what a "memory" is vs a summary, how a fresh session gets
82
+ seeded, and how the bead carries the summary + referential memory. Then a spike: one task
83
+ completing with summary → fresh session seeded → verify the thread feels continuous.
84
+
85
+ ## Notes
86
+ Recorded 2026-08-25. The author explicitly wants to flesh this out later — this record captures
87
+ the working concept. It connects several existing ideas: `record-ideas-as-beads` (beads as the
88
+ unit of everything), `pi-task-memory` (memory as a first-class mechanism), and
89
+ `subagent-visibility` (visibility into what task sessions do).
90
+
91
+ **Amendment (2026-08-30):** see `self-flushing-session` — the sharper mechanism record for this
92
+ principle: agent autonomously decides when to flush, beads *are* the memory store (no separate
93
+ system), a parent session bead holds the conversation with child outcome beads discovered
94
+ progressively, and the bead ID is the only thing kept across a flush. This record remains the
95
+ principle; `self-flushing-session` is the mechanism.
@@ -0,0 +1,92 @@
1
+ # Idea: Test data creation helpers
2
+
3
+ ## Status
4
+ Backlog idea (not implementation-ready) — priority P2 (moderate)
5
+
6
+ ## Created
7
+ 2026-09-14
8
+
9
+ ## Problem
10
+ Agents writing tests reach for test data the lazy way, in three shapes:
11
+
12
+ 1. **Shared module-scope objects used as fixtures.** Because the object is built once at
13
+ top-level scope and reused, every test mutates the same instance — state leaks between
14
+ tests, and a passing test can depend on the order in which others ran. Failures are
15
+ order-dependent and hard to reproduce in isolation.
16
+ 2. **Data built outside the test rather than inline.** The reader — and the next agent — must
17
+ scroll away from the assertion to find what the input actually was, so the test stops
18
+ reading as an example of the behaviour under test.
19
+ 3. **No small configurable helper.** Instead of a factory with sensible defaults and an
20
+ overrides argument, each test re-spells the entire literal. One field change means editing
21
+ every call site, and the tests silently drift apart from one another.
22
+
23
+ Net effect: tests that are annoying to read, annoying to change, and occasionally lie. The
24
+ cost is paid again on every subsequent edit.
25
+
26
+ ## Who benefits
27
+ Everyone who reads or changes the suite: the author reviewing a diff, the reviewer agent
28
+ auditing a PR, and later agents picking the code up cold. It also cuts churn in ralph pipeline
29
+ runs, where agents write tests unattended and nobody corrects a sloppy fixture habit in the
30
+ moment. Test authors write less boilerplate; reviewers have less to query.
31
+
32
+ ## Proposed outcome
33
+ Skill-only guidance (no shipped helper code) telling the agent how to create test data:
34
+
35
+ - **Build data inline in the test** (or in a helper called from it), so the test body shows the
36
+ shape of its own input.
37
+ - **No shared mutable top-level fixture.** If data must be reused, it is produced fresh per
38
+ test by a function — a factory, not a constant. Module-scope constants are acceptable only
39
+ when genuinely immutable and read-only.
40
+ - **Prefer a small configurable helper** — a factory taking partial overrides with defaults for
41
+ the rest — over repeated full literals. Build the helper only when reuse justifies it; a
42
+ single test's data stays a plain inline object.
43
+ - **Name and locate the helper conventionally** so the next agent finds it (colocated with the
44
+ tests, named for what it builds).
45
+
46
+ Landing: the rule belongs in `style-tests`, the skill that already governs test-writing
47
+ conventions, with `tdd` and `engineering` pointing at it so the habit lands at authoring time.
48
+ Per the repo's keep-skill-bodies-small convention it is a red-flag row plus a checklist item,
49
+ not a new essay.
50
+
51
+ ## Validity check
52
+ - Evidence we already have: the pattern is observed repeatedly in agent-authored tests
53
+ (module-scope fixtures mutated across tests, full literals duplicated per test); `style-tests`
54
+ already asserts behaviour-over-structure and mock discipline, so a data-construction rule fits
55
+ its existing remit without new philosophy; and the sibling idea `ban-content-assertion-tests`
56
+ shows this class of test-quality gap is real and gets fixed the same way — skill-only, red flag
57
+ plus checklist item. The repo already ships skills governing how tests are written, so there is
58
+ a known enforcement point and no new mechanism to invent.
59
+ - Riskiest assumption: that a prose rule actually changes agent behaviour. The content-assertion
60
+ idea rests on the same assumption; if agents keep reaching for module-scope fixtures after the
61
+ rule lands, the fix is a review gate rather than more wording. Second-riskiest: that "no shared
62
+ top-level fixture" is not overly absolute — a genuinely immutable shared constant (a frozen
63
+ canonical example) is fine, so the wording must target mutability and per-test freshness, not
64
+ top-level scope by itself.
65
+ - What would invalidate this idea: finding that the real cause is not agent habit but a missing
66
+ convention in the target projects (nowhere for a helper to live, so inline literals are the only
67
+ option), or that a project's test framework already ships builders the agent simply fails to
68
+ find — either would move the fix to discoverability or enforcement rather than a style rule.
69
+
70
+ ## Constraints
71
+ - **Skill-only.** No helper library shipped from this plugin — each project owns its factories.
72
+ - Keep `style-tests` at ~100 lines: add a red-flag row and a verification-checklist item; do not
73
+ expand the skill's philosophy.
74
+ - Do not ban top-level constants outright — the rule targets mutable shared state and per-test
75
+ freshness.
76
+ - Small scope: no pipeline changes beyond pointing `tdd`/`engineering` at the rule.
77
+
78
+ ## Next validation step
79
+ Before implementing, grep the agent-authored tests in this repo (and one or two target projects)
80
+ for module-scope fixture objects versus inline/per-test construction, to confirm the pattern is as
81
+ frequent as the anecdote suggests and to capture two or three concrete before/after examples. If
82
+ it is real, land the red-flag row in `style-tests`, add the pointer lines in `tdd`/`engineering`,
83
+ then check the next ralph run's tests for it.
84
+
85
+ ## Notes
86
+ Recorded 2026-09-14 (P2). Interview was deliberately short — this is a capture, not a spec. Timing
87
+ signal: "it's annoying" — a recurring, low-severity papercut that costs a little on every test
88
+ edit rather than a project-breaking defect, hence P2 rather than the P1 carried by adjacent
89
+ content-assertion work. Stance locked in interview: skill-only guidance, no shipped helper code;
90
+ the fix is teaching the agent the pattern, not providing a library. Related:
91
+ `ban-content-assertion-tests.md` (same enforcement point, same shape of fix),
92
+ `test-planning-stage-bead-in-feature-planning.md` (test-stage quality in the pipeline).