@jaybeeuu/agent-cortex 1.20.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 (154) hide show
  1. package/.beads/README.md +81 -0
  2. package/.beads/config.yaml +1 -0
  3. package/.beads/issues.jsonl +236 -0
  4. package/.beads/metadata.json +7 -0
  5. package/.claude-plugin/marketplace.json +16 -0
  6. package/.github/workflows/ci.test.ts +217 -0
  7. package/.github/workflows/ci.yml +35 -0
  8. package/.github/workflows/publish.yml +36 -0
  9. package/.junie/guidelines.md +87 -0
  10. package/.junie/mcp/mcp.json +10 -0
  11. package/AGENTS.md +102 -0
  12. package/CHANGELOG.md +705 -0
  13. package/README.md +209 -0
  14. package/agents/README.md +235 -0
  15. package/agents/plan.agent.md +56 -0
  16. package/agents/ralph-plan.agent.md +119 -0
  17. package/agents/ralph.agent.md +305 -0
  18. package/agents/strategy.agent.md +109 -0
  19. package/agents-native/ralph.md +193 -0
  20. package/bin/agent-cortex.mjs +27 -0
  21. package/claude/.claude-plugin/plugin.json +11 -0
  22. package/claude/.mcp.json +18 -0
  23. package/claude/agents/plan.md +56 -0
  24. package/claude/agents/ralph-plan.md +119 -0
  25. package/claude/agents/ralph.md +193 -0
  26. package/claude/agents/strategy.md +109 -0
  27. package/claude/hooks.json +23 -0
  28. package/claude/scripts/statusline-command.sh +124 -0
  29. package/docs/ideas/auto-model-selection.md +75 -0
  30. package/docs/ideas/improve-pi-system-prompt.md +34 -0
  31. package/docs/ideas/model-selector.md +40 -0
  32. package/docs/ideas/pi-task-memory.md +34 -0
  33. package/docs/ideas/qa-extension.md +43 -0
  34. package/docs/inspirations.md +33 -0
  35. package/docs/research/gas-city-research.md +256 -0
  36. package/docs/research/skill-design-research.md +286 -0
  37. package/docs/research/skill-improvements-analysis.md +117 -0
  38. package/docs/research/skill-patterns-research.md +24 -0
  39. package/docs/skills/skill-anatomy.md +149 -0
  40. package/docs/user-preferences.md +17 -0
  41. package/extensions/agent-modes/index.ts +507 -0
  42. package/extensions/auto-name.ts +107 -0
  43. package/extensions/context-loader.md +35 -0
  44. package/extensions/context-loader.ts +65 -0
  45. package/extensions/lib/tiny-model.ts +212 -0
  46. package/extensions/notify/index.ts +293 -0
  47. package/extensions/session-start.ts +44 -0
  48. package/extensions/skill-stats/README.md +74 -0
  49. package/extensions/skill-stats/context-loader.test.ts +107 -0
  50. package/extensions/skill-stats/discover.ts +119 -0
  51. package/extensions/skill-stats/format.ts +13 -0
  52. package/extensions/skill-stats/index.test.ts +452 -0
  53. package/extensions/skill-stats/index.ts +222 -0
  54. package/extensions/skill-stats/package.json +19 -0
  55. package/extensions/skill-stats/pnpm-lock.yaml +329 -0
  56. package/extensions/skill-stats/record.ts +48 -0
  57. package/extensions/skill-stats/store.ts +104 -0
  58. package/extensions/skill-stats/tsconfig.json +12 -0
  59. package/extensions/subagent/README.md +175 -0
  60. package/extensions/subagent/agents/planner.md +37 -0
  61. package/extensions/subagent/agents/reviewer.md +35 -0
  62. package/extensions/subagent/agents/scout.md +50 -0
  63. package/extensions/subagent/agents/worker.md +24 -0
  64. package/extensions/subagent/agents.ts +126 -0
  65. package/extensions/subagent/index.ts +1138 -0
  66. package/extensions/subagent/prompts/implement-and-review.md +10 -0
  67. package/extensions/subagent/prompts/implement.md +10 -0
  68. package/extensions/subagent/prompts/scout-and-plan.md +9 -0
  69. package/hooks.json +10 -0
  70. package/lib/cli.mjs +37 -0
  71. package/package.json +39 -0
  72. package/pi/keybindings.json +3 -0
  73. package/pi/settings.json +29 -0
  74. package/plugin.json +35 -0
  75. package/pnpm-workspace.yaml +7 -0
  76. package/scripts/build-claude-agents.mjs +179 -0
  77. package/scripts/install-instructions.sh +82 -0
  78. package/skills/engineering/design-an-interface/SKILL.md +94 -0
  79. package/skills/engineering/grill-with-docs/SKILL.md +88 -0
  80. package/skills/engineering/improve-codebase-architecture/REFERENCE.md +78 -0
  81. package/skills/engineering/improve-codebase-architecture/SKILL.md +81 -0
  82. package/skills/engineering/tdd/SKILL.md +150 -0
  83. package/skills/engineering/tdd/deep-modules.md +33 -0
  84. package/skills/engineering/tdd/interface-design.md +31 -0
  85. package/skills/engineering/tdd/mocking.md +59 -0
  86. package/skills/engineering/tdd/refactoring.md +10 -0
  87. package/skills/engineering/tdd/tests.md +61 -0
  88. package/skills/engineering/technical-direction/SKILL.md +86 -0
  89. package/skills/planning/classify-bead/SKILL.md +67 -0
  90. package/skills/planning/create-task/SKILL.md +96 -0
  91. package/skills/planning/create-task/pipeline.json +33 -0
  92. package/skills/planning/create-task/scripts/create-chores.ts +112 -0
  93. package/skills/planning/create-task/scripts/package.json +14 -0
  94. package/skills/planning/create-task/scripts/pnpm-lock.yaml +342 -0
  95. package/skills/planning/create-task/scripts/tsconfig.json +12 -0
  96. package/skills/planning/create-task/templates/code.md +40 -0
  97. package/skills/planning/create-task/templates/document.md +40 -0
  98. package/skills/planning/create-task/templates/fix.md +27 -0
  99. package/skills/planning/create-task/templates/review.md +36 -0
  100. package/skills/planning/create-task/templates/verify.md +43 -0
  101. package/skills/planning/prd-to-tasks/SKILL.md +227 -0
  102. package/skills/planning/record-idea/SKILL.md +62 -0
  103. package/skills/planning/record-idea/scripts/new-idea.sh +89 -0
  104. package/skills/planning/request-refactor-plan/SKILL.md +73 -0
  105. package/skills/planning/write-a-prd/SKILL.md +74 -0
  106. package/skills/planning/write-a-ticket/SKILL.md +97 -0
  107. package/skills/productivity/bd-tool/SKILL.md +90 -0
  108. package/skills/productivity/grill-me/SKILL.md +10 -0
  109. package/skills/productivity/handoff/SKILL.md +15 -0
  110. package/skills/productivity/init-beads/SKILL.md +93 -0
  111. package/skills/productivity/teach/GLOSSARY-FORMAT.md +35 -0
  112. package/skills/productivity/teach/LEARNING-RECORD-FORMAT.md +46 -0
  113. package/skills/productivity/teach/MISSION-FORMAT.md +31 -0
  114. package/skills/productivity/teach/RESOURCES-FORMAT.md +32 -0
  115. package/skills/productivity/teach/SKILL.md +109 -0
  116. package/skills/productivity/validate-agent-dir/scripts/package.json +15 -0
  117. package/skills/productivity/validate-agent-dir/scripts/pnpm-lock.yaml +329 -0
  118. package/skills/productivity/validate-agent-dir/scripts/pnpm-workspace.yaml +2 -0
  119. package/skills/productivity/validate-agent-dir/scripts/tsconfig.json +19 -0
  120. package/skills/productivity/validate-agent-dir/scripts/validate-agent-dir.test.ts +317 -0
  121. package/skills/productivity/validate-agent-dir/scripts/validate-agent-dir.ts +127 -0
  122. package/skills/productivity/write-a-skill/SKILL.md +74 -0
  123. package/skills/review/maintain-agent-docs/REFERENCE.md +246 -0
  124. package/skills/review/maintain-agent-docs/SKILL.md +83 -0
  125. package/skills/review/refactor-skill/EXAMPLES.md +20 -0
  126. package/skills/review/refactor-skill/SKILL.md +148 -0
  127. package/skills/review/review-security/SKILL.md +107 -0
  128. package/skills/review/review-security/scripts/install-gitleaks.sh +43 -0
  129. package/skills/style/style-code/REFERENCE.md +38 -0
  130. package/skills/style/style-code/SKILL.md +113 -0
  131. package/skills/style/style-comms/SKILL.md +93 -0
  132. package/skills/style/style-documentation/SKILL.md +112 -0
  133. package/skills/style/style-tests/SKILL.md +97 -0
  134. package/skills/workflow/git-workflow/SKILL.md +85 -0
  135. package/skills/workflow/hitl-collab/SKILL.md +29 -0
  136. package/skills/workflow/plan/SKILL.md +272 -0
  137. package/skills/workflow/ralph/REFERENCE.md +202 -0
  138. package/skills/workflow/ralph/SKILL.md +105 -0
  139. package/skills/workflow/run-pipeline-stage/SKILL.md +151 -0
  140. package/skills/workflow/run-pipeline-stage/playbooks/code.md +17 -0
  141. package/skills/workflow/run-pipeline-stage/playbooks/document.md +18 -0
  142. package/skills/workflow/run-pipeline-stage/playbooks/fix.md +17 -0
  143. package/skills/workflow/run-pipeline-stage/playbooks/review.md +19 -0
  144. package/skills/workflow/run-pipeline-stage/playbooks/verify.md +14 -0
  145. package/skills/workflow/run-pipeline-stage/prompts/stage-runner.md +20 -0
  146. package/skills/workflow/run-pipeline-stage/scripts/generate-progress.test.ts +783 -0
  147. package/skills/workflow/run-pipeline-stage/scripts/generate-progress.ts +586 -0
  148. package/skills/workflow/run-pipeline-stage/scripts/package.json +15 -0
  149. package/skills/workflow/run-pipeline-stage/scripts/pnpm-lock.yaml +342 -0
  150. package/skills/workflow/run-pipeline-stage/scripts/pnpm-workspace.yaml +2 -0
  151. package/skills/workflow/run-pipeline-stage/scripts/tsconfig.json +12 -0
  152. package/skills/workflow/using-agent-skills/SKILL.md +109 -0
  153. package/skills/workflow/using-agent-skills/scripts/validate-skill-structure.test.ts +73 -0
  154. package/test/cli.test.mjs +149 -0
@@ -0,0 +1,75 @@
1
+ # Idea: Auto-Model Selection Plugin
2
+
3
+ ## Status
4
+ Backlog idea (not implementation-ready) — **direction: evaluate and adopt existing package**
5
+
6
+ ## Why it might be useful
7
+ PI has no intelligent model selection. Users must manually choose models, which means they either over-provision (expensive models for simple tasks) or under-provision (weak models for complex work). Rate limits hit without warning, forcing manual model switching mid-session. An auto-selection plugin would optimize cost/performance by matching model capability to task complexity, and provide seamless fallbacks when rate limits are hit.
8
+
9
+ ## How we might do it
10
+ **Evaluate and adopt an existing PI extension** rather than building from scratch. The ecosystem already has well-maintained packages that cover task-based routing and rate-limit fallbacks. The goal is to:
11
+
12
+ 1. **Evaluate the top candidates** (see "Packages to evaluate" below)
13
+ 2. **Pick the best fit** for agent-cortex's workflow (beads, pipeline stages, HITL/AFK classification)
14
+ 3. **Install and configure** it, possibly with light customisation if needed
15
+ 4. **Document** the chosen package and configuration in agent-cortex docs
16
+
17
+ ## Packages to evaluate (in priority order)
18
+ **Top candidates — cover both task-based routing AND fallbacks:**
19
+ 1. **`@kylebrodeur/pi-model-router`** — per-turn routing to high/medium/low tiers based on task intent, context size, budget, with automatic fallback chains and rate-limit recovery. Well-documented fork of yeliu84's original.
20
+ 2. **`pi-auto-router`** — multi-provider routing with same-request failover, budget-aware policies, and quota-aware fallback.
21
+ 3. **`pi-tiered-router`** — routes different *phases* (planner/validator/executor/tool-parser) to different models. Quality-first, not cost-saving.
22
+
23
+ **Fallback-only (simpler, if routing is overkill):**
24
+ - **`pi-auto-models`** — Claude→Codex quota switching with 429/529 recovery
25
+ - **`pi-provider-fallback`** — cross-provider fallback chain with TUI config
26
+
27
+ **Evaluation criteria:**
28
+ - Does it integrate cleanly with PI's existing provider/model system?
29
+ - Does it respect user's explicit model choice, or override it?
30
+ - How does it handle context window mismatches on fallback?
31
+ - Is it configurable per-project?
32
+ - Does it have fallback chains or just single fallback?
33
+ - Rate-limit detection and retry logic
34
+ - Documentation quality and maintenance status
35
+
36
+ ## When to think about it
37
+ - After current feature stabilisation (refactor-to-template epic, npm publishing, system prompt improvements)
38
+ - Not blocked, but benefits from stable extension infrastructure
39
+
40
+ ## Priority
41
+ Medium / backlog — valuable for cost optimisation and reliability, but not urgent. Current manual model selection works, just isn't optimal.
42
+
43
+ ## Open questions
44
+ - How to classify task complexity? Heuristics (file count, prompt length, keywords)? Or let user tag tasks?
45
+ - What defines a "model class"? Cost tier, context window size, reasoning capability, speed?
46
+ - Should the plugin override the user's explicit model choice, or only activate when no model is selected?
47
+ - How to handle context window mismatches when falling back (e.g., 200k → 128k)?
48
+ - Should this be configurable per-project (different policies for different repos)?
49
+
50
+ ## Existing packages in the ecosystem
51
+ Several published packages already address parts of this problem:
52
+
53
+ ### Fallback / rate-limit recovery
54
+ - **`pi-provider-fallback`** — cross-provider fallback with interactive TUI config
55
+ - **`pi-auto-models`** — primary/fallback switching on quota (Claude→Codex default), 429/529 recovery
56
+
57
+ ### Task-based / tier routing
58
+ - **`pi-model-router`** (yeliu84, forked by @kdejaeger and @kylebrodeur) — per-turn routing to high/medium/low tiers based on task intent, context size, budget, with automatic fallbacks
59
+ - **`pi-model-auto`** — routes by Low/Medium/High/Ultra capability modes per turn
60
+ - **`pi-tiered-router`** — routes different phases (planner/validator/executor/tool-parser) to different models
61
+
62
+ ### Full auto-router with failover
63
+ - **`pi-auto-router`** — multi-provider routing with same-request failover, budget-aware policies
64
+ - **`@ifi/pi-extension-adaptive-routing`** — adaptive routing with local telemetry persistence
65
+
66
+ ### Model selection (manual)
67
+ - **`pi-model-switch`** — direct model switching tool
68
+ - **`pi-model-select`** — `/select-model` with favourites and fuzzy search
69
+
70
+ ## Notes
71
+ - **The ecosystem is active** — this space is already well-served. Before building, evaluate whether an existing package (especially `pi-model-router` or `pi-auto-router`) already meets the need.
72
+ - **Gap analysis needed**: compare existing packages against the original requirements (task-based class selection + rate-limit fallbacks) to see if anything is genuinely missing.
73
+ - **Partial solutions exist in PI core**: OpenRouter's routing config supports fallbacks and provider ordering, but only within OpenRouter. Cross-provider fallback requires an extension.
74
+ - **Implementation approach** (if building): likely a PI extension that registers a "smart-router" provider, which internally delegates to real providers based on task classification and availability.
75
+ - **Research done**: reviewed PI docs on providers, models, and extensions. Searched npm and pi.dev for existing packages.
@@ -0,0 +1,34 @@
1
+ # Idea: Improve PI System Prompt
2
+
3
+ ## Status
4
+ Backlog idea (not implementation-ready)
5
+
6
+ ## Why it might be useful
7
+ 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.
8
+
9
+ ## How we might do it
10
+ Build improved behavioural instructions into agent-cortex — layered on top of or replacing PI's default system prompt. Key improvements:
11
+
12
+ 1. **Loop prevention / circuit-breakers** — hard limits on retry attempts (e.g. 2-attempt limit before stopping and asking), no repeated tool execution without rationale
13
+ 2. **Task-focus discipline** — stronger scoping instructions, no tangential refactoring, atomic changes
14
+ 3. **Check-in triggers** — explicit rules for when the agent must stop and present options to the user
15
+
16
+ A Gemini-generated execution protocol prompt exists as a possible starting point (see Notes), but will need significant customisation for agent-cortex.
17
+
18
+ ## When to think about it
19
+ - Land the current work first (refactor-to-template epic, bead workflow polish, CI/CD pipeline)
20
+ - **Next priority after current work** — this is urgent-ish
21
+
22
+ ## Priority
23
+ High — after current work lands. Directly impacts daily productivity and token efficiency.
24
+
25
+ ## Open questions
26
+ - Layer on top of PI's default prompt, or replace it entirely?
27
+ - Should PI's current system prompt be reviewed for nonsense that can be chopped out?
28
+ - 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
+ ## Notes
32
+ - **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
+ - **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
+ - **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,40 @@
1
+ # Idea: model-selector
2
+
3
+ ## Status
4
+ Backlog idea (not implementation-ready)
5
+
6
+ ## Created
7
+ 2026-07-12
8
+
9
+ ## Problem
10
+ Selecting the right model for a task is manual and brittle. When a model is unavailable (rate-limited, down, or lacking capability), there's no automatic fallback. You have to know which model IDs to type into `/model` and remember which providers offer which capabilities.
11
+
12
+ ## Who benefits
13
+ Anyone using PI who runs multiple models/providers. The extension makes model selection declarative: "I want to write code" → extension picks the best available model (and falls back if limits are hit).
14
+
15
+ ## Proposed outcome
16
+ A PI extension that defines an abstraction for selecting models based on task/use case. Users declare "use case → model(s) with fallbacks" in config, and the extension handles selection and failover automatically.
17
+
18
+ Key capabilities:
19
+ - **Use-case profiles**: e.g. `code`, `chat`, `review`, `architect` — each maps to a primary model + ordered fallbacks
20
+ - **Automatic fallback**: if the primary model returns a 429 or error, drop to the next in the chain
21
+ - **Task-based selection**: think "I want this model to write code" instead of choosing a specific model ID
22
+ - **Configurable**: profiles defined in settings.json or a dedicated config file
23
+
24
+ ## Validity check
25
+ - Evidence we already have: The existing `tiny-model.ts` lib in this repo already shows the pattern of configuring a model by provider/id string and looking it up via `modelRegistry.find()`. The PI extension API supports `before_provider_response` (for catching 429s) and `model_select` events.
26
+ - Riskiest assumption: That use-case profiles are a useful abstraction — users may prefer to just name a model family and let fallback be implicit.
27
+ - What would invalidate this idea: If PI adds built-in model routing/fallback, or if users find the abstraction adds confusion rather than removing it.
28
+
29
+ ## Constraints
30
+ - Must not add LLM calls internally (per extension conventions in AGENTS.md)
31
+ - Must work with the existing `modelRegistry` API — no monkey-patching
32
+ - Storage/config should go in settings.json or `~/.pi/agent-cortex/` (global, cross-project)
33
+
34
+ ## Next validation step
35
+ Sketch the config schema and test it against real usage patterns. Does the profile abstraction hold up for the models/providers you actually use?
36
+
37
+ ## Notes
38
+ - Initial conversation during planning session 2026-07-12. Idea recorded as backlog, to be fleshed out when time permits.
39
+ - Could draw on patterns from OpenRouter's routing and the existing `modelOverrides` in models.json.
40
+ - The `notify` extension already intercepts provider responses — similar pattern for catching rate limits.
@@ -0,0 +1,34 @@
1
+ # Idea: PI Task Memory Skill
2
+
3
+ ## Status
4
+ Backlog idea (not implementation-ready)
5
+
6
+ ## Why it might be useful
7
+ PI has no built-in task memory. Agents lose context between sessions — they can't track what a task has done, what decisions were made, or where they left off. A skill that persists task-scoped knowledge in structured markdown would let agents pick up work without re-discovering context from scratch, and give humans a readable audit trail they can review or promote into real documentation.
8
+
9
+ ## How we might do it
10
+ **Possibly build on top of `bd remember`** rather than creating a separate storage system. Worth exploring whether `bd remember`'s existing infrastructure (persistence, cross-session survival, auto-injection) could be extended with task-scoping and structure, vs building something standalone.
11
+ - **Task-linked** — memories keyed to specific bead/task IDs so they can be retrieved in context
12
+ - **Progressively discoverable** — the agent recalls relevant memories as it picks up work, not all at once
13
+ - **Structured** — consistent format that's easy to scan, edit, or promote
14
+ - **Promotable** — easy to elevate a memory into real repo documentation (e.g. `docs/`, `AGENTS.md`) once it's proven stable
15
+
16
+ If `bd remember` turns out to be the right foundation, the skill would add **task-scoping discipline, structure, and a promotion workflow** on top. But that's to be determined.
17
+
18
+ ## When to think about it
19
+ - After the current skill set stabilises (refactor-to-template work, bead workflow, CI/CD pipeline)
20
+ - Not blocked by anything, but benefits from a stable foundation
21
+
22
+ ## Priority
23
+ Low / backlog — useful but not urgent. Current memory surfaces (bd remember, context-mode) cover some of the gap already.
24
+
25
+ ## Open questions
26
+ - What triggers writing a memory? (Agent decides? Skill hook on task close? Specific prompts?)
27
+ - What does "progressively discoverable" mean in practice — agent reads task memories at session start, or on-demand when picking up a task?
28
+ - What does "elevate into docs" look like — export memory to markdown file, or just reference the memory in docs?
29
+ - How to structure memory keys for task-scoping? (e.g. `task-<bead-id>-<topic>`, or a naming convention?)
30
+
31
+ ## Notes
32
+ - **What bd remember already provides**: persistent cross-session memories, auto-injection at `bd prime`, searchable via `bd memories <keyword>`, stored in Dolt database.
33
+ - **Worth exploring**: could this skill layer task-scoping discipline (memories keyed to bead IDs), structured format, progressive discovery (not all memories at once), and a promotion workflow on top of `bd remember`? Or does it need its own system?
34
+ - Could be a **PI extension** (event hooks) rather than a skill (invoked on-demand) if memories should be written automatically during task work.
@@ -0,0 +1,43 @@
1
+ # Idea: qa-extension
2
+
3
+ ## Status
4
+ Backlog idea (not implementation-ready)
5
+
6
+ ## Created
7
+ 2026-07-12
8
+
9
+ ## Problem
10
+ When an agent needs clarification during a task (e.g. during a grilling session, resolving ambiguity, or making a recommendation), it has no structured way to ask the user a question and wait for an answer. The current workaround is unstructured prompting — the agent guesses, rambles, or proceeds with incomplete information. This makes grilling sessions less productive and wastes turns.
11
+
12
+ ## Who benefits
13
+ Anyone using PI agents for interactive work — especially during planning, grilling, and design sessions where the model needs to ask a series of questions one at a time and get focused answers.
14
+
15
+ ## Proposed outcome
16
+ A PI extension that registers a `qa` or `ask` tool that the LLM can call to ask the user a question. The tool:
17
+ - Presents the question (and optionally multiple-choice options or a recommendation)
18
+ - Pauses the agent and waits for the user's response
19
+ - Returns the user's answer to the model so it can continue
20
+ - Supports multi-turn Q&A sessions (series of questions)
21
+
22
+ This mirrors the built-in `ask_clarification` / `question` tools in Claude Code, GitHub Copilot Chat, and similar coding agents.
23
+
24
+ ## Validity check
25
+ - Evidence we already have: The PI extension API supports custom tools with user interaction via `ctx.ui` (input, confirm, select). The `subagent` extension already demonstrates complex async tool patterns. Claude Code and Copilot both ship this — it's a proven pattern.
26
+ - Riskiest assumption: That the tool execution model in PI can support a "pause and wait for user input" flow without blocking the agent loop awkwardly.
27
+ - What would invalidate this idea: If PI adds a built-in `ask_user` tool, or if the UX of blocking the agent loop for input feels worse than the current unstructured approach.
28
+
29
+ ## Constraints
30
+ - Must work in both TUI and RPC modes (graceful fallback in non-interactive modes)
31
+ - Should support at minimum: free-text input, confirm/deny, and multiple-choice selection
32
+ - Questions and answers should be visible in the session history so they survive compaction
33
+ - Must handle abort (Ctrl+C mid-question) gracefully
34
+
35
+ ## Next validation step
36
+ 1. **Investigate existing extensions first** — search PI's built-in tools, extension registry, and community repos for an existing `ask`/`qa`/`question` tool before building. May already be available.
37
+ 2. If no existing extension: check the PI tool execution model to see if a custom tool can return a partial result and then receive follow-up input from the user. Look at how `ctx.ui.input()` and `ctx.ui.confirm()` behave inside tool execution — can they block and return, or do they need a different pattern?
38
+
39
+ ## Notes
40
+ - **Needs investigation** — check for existing PI extensions/tools before building.
41
+ - Initial conversation 2026-07-12. Motivated by making grilling sessions more efficient — the grill-me skill asks one question at a time, and a structured Q&A tool would make that flow tighter.
42
+ - Related to `grill-me` skill (`skills/productivity/grill-me/SKILL.md`) — this extension could become the runtime that grill-me delegates its questioning to.
43
+ - Possible names: `/ask`, `qa`, `question` tool.
@@ -0,0 +1,33 @@
1
+ # Inspirations
2
+
3
+ A living record of external repos and promoted internal research that inform agent-cortex skill and agent design.
4
+
5
+ ## Internal research docs
6
+
7
+ - [Gas City research](research/gas-city-research.md)
8
+ - [Skill pattern research notes](research/skill-patterns-research.md)
9
+ - [Skill design research](research/skill-design-research.md)
10
+ - [Skill improvements analysis](research/skill-improvements-analysis.md)
11
+
12
+ ## addyosmani/agent-skills
13
+
14
+ **URL**: https://github.com/addyosmani/agent-skills
15
+ **Last reviewed**: 2026-05-26
16
+ **Type**: Public skill collection (Claude Code / OpenCode)
17
+
18
+ ### Structure patterns worth noting
19
+
20
+ | Pattern | Description | Adopted? |
21
+ |---|---|---|
22
+ | Consistent skeleton | Every skill follows a shared, predictable section model | Partially |
23
+ | "When NOT to use" | Explicit out-of-scope conditions in every skill | Planned |
24
+ | "Common Rationalizations" | Debunks excuses for skipping process steps | Planned |
25
+ | "Red Flags" | Concrete anti-patterns to detect during execution | Planned |
26
+ | Verification checklist | Completion gate in each skill | Planned |
27
+ | Cross-references | `See Also` links to related skills | Planned |
28
+
29
+ ## Matt Pocock — skills repo
30
+
31
+ **URL**: https://github.com/mattpocock/skills
32
+ **Last reviewed**: 2026-05-26
33
+ **Type**: Public skill collection
@@ -0,0 +1,256 @@
1
+ # Gas City Research Notes
2
+
3
+ This is a promoted research note.
4
+
5
+
6
+ Research conducted 2026-05-03/04. Source: `gastownhall/gascity` and related `gastownhall/*` repos.
7
+
8
+ ---
9
+
10
+ ## What is Gas City?
11
+
12
+ Gas City is a Go-based multi-agent orchestration SDK (`gc` CLI, v1.0.0, released 2026-04-21, MIT licence).
13
+ It manages **live interactive agent sessions** (Claude Code, Codex CLI, etc. running in tmux) rather than
14
+ making raw LLM API calls. It is not a replacement for LLM API access — it is a rack manager for persistent
15
+ agent processes.
16
+
17
+ Gas City is built on the **MEOW stack** (Molecular Expression of Work) — the same `bd` (beads) tooling
18
+ already in use in this repo.
19
+
20
+ ---
21
+
22
+ ## The MEOW Stack
23
+
24
+ MEOW = **Molecular Expression of Work**. A layered work-decomposition and tracking infrastructure:
25
+
26
+ ```
27
+ Formulas / Orders ← TOML templates defining workflow shape + when it fires
28
+ ↑
29
+ Molecules / Wisps ← durable chained bead workflows; instances of formulas
30
+ ↑
31
+ Epics ← hierarchical bead grouping (parent/child beads)
32
+ ↑
33
+ Beads ← atomic git-backed work units (the bd CLI)
34
+ ```
35
+
36
+ **Core insight:** work is the primitive, not orchestration. The controller is a thin layer on top of the
37
+ MEOW stack. Work definition and tracking is what matters; orchestration shape is configurable on top.
38
+
39
+ **GUPP (Gas Town Universal Propulsion Principle):** *"If you find something on your hook, you run it."*
40
+ Agents are stateless pistons; the bead store is the engine.
41
+
42
+ ---
43
+
44
+ ## Key Concepts
45
+
46
+ ### Rigs
47
+ A **rig** is an external project directory (git repo) registered with a city. Each rig gets its own beads
48
+ database, agent hooks, and pack expansion. One city can manage multiple rigs (multiple repos) — this is
49
+ the primary multi-repo use case.
50
+
51
+ ```toml
52
+ # city.toml
53
+ [[rigs]]
54
+ name = "my-api"
55
+
56
+ [[rigs]]
57
+ name = "my-frontend"
58
+ ```
59
+
60
+ ### City
61
+ A deployment of packs + rigs under one controller. The controller runs as a persistent Go process managing
62
+ all sessions in all rigs.
63
+
64
+ ### Packs / Formulas
65
+ Reusable TOML configuration bundles. A **formula** is a TOML workflow template defining steps and
66
+ dependencies. A **molecule** is an instance of a formula — materialised as beads in the store.
67
+
68
+ ### Convergence
69
+ The outer retry loop. When a wisp closes, the controller's `HandleWispClosed()` (a 9-step deterministic
70
+ Go algorithm) evaluates a gate and decides: `iterate` (new wisp), `approved` (done), `no_convergence`
71
+ (blocked), or `waiting_manual` (human required).
72
+
73
+ ### Orders
74
+ Scheduled formula dispatch. Five trigger types: `cooldown`, `cron`, `condition` (shell exit 0), `event`
75
+ (bead.closed on city bus), `manual`. Can dispatch a formula to an agent pool, or run a shell script
76
+ directly (`exec` orders — no LLM involved).
77
+
78
+ ---
79
+
80
+ ## What Gas City Gives Us
81
+
82
+ | Capability | Status |
83
+ |---|---|
84
+ | Multi-repo orchestration (rigs) | ✅ Native — primary use case |
85
+ | Rack / dashboard (`gc status`, SPA) | ✅ Built-in |
86
+ | Agent lifecycle (crash recovery, idle-kill, restart) | ✅ Built-in |
87
+ | Worktree isolation (per-agent git branch) | ✅ `isolation = "worktree"` in agent config |
88
+ | Concurrent feature work (multiple agents, multiple branches) | ✅ Via pool + worktree isolation |
89
+ | Scheduling / reactive triggers (Orders) | ✅ 5 trigger types |
90
+ | Deterministic workflow routing | ✅ Controller is Go state machine (no LLM in routing path) |
91
+ | Formula-based step sequencing | ✅ TOML DAG, `needs` dependencies, executed by `bd` |
92
+ | Feature backlog isolation (separate bead stores) | ⚠️ Requires separate rigs; not automatic |
93
+ | Cross-repo bead dependencies | ❌ Not supported — issue #587, milestone `1.0+`, no timeline |
94
+ | Native loops in formulas | ❌ Formulas are DAGs; loops require the convergence engine |
95
+
96
+ ---
97
+
98
+ ## Architecture: Determinism vs. Agents
99
+
100
+ Gas City has a sharp boundary. The Go controller owns all routing; LLMs only do work and emit a verdict.
101
+
102
+ ```
103
+ Agent works through formula steps
104
+ → writes convergence.agent_verdict = "approve" | "block"
105
+ → closes wisp
106
+
107
+ Controller HandleWispClosed() [pure Go, 9-step algorithm]
108
+ → reads verdict (scoped to this wisp by agent_verdict_wisp)
109
+ → runs gate shell script (exit 0 = pass, exit 1 = fail)
110
+ → ActionApproved → state=terminated, done
111
+ → ActionIterate → pour new wisp, re-dispatch to agent
112
+ → ActionNoConvergence → state=terminated, blocked
113
+ → ActionWaitingManual → human must gc conv approve
114
+ ```
115
+
116
+ **ACL enforcement:** agents can only write `convergence.agent_verdict` and
117
+ `convergence.agent_verdict_wisp`. All other `convergence.*` keys require a controller token — agents
118
+ cannot fake state transitions.
119
+
120
+ **Exec orders** bypass agents entirely — a shell script runs directly on the controller. Fully
121
+ deterministic, no LLM.
122
+
123
+ ### Compared to LangGraph / Temporal
124
+
125
+ - Like Temporal: the convergence handler is crash-safe and idempotent (speculative-pour-before-commit).
126
+ - Unlike LangGraph: there is no Go-level `add_edge(A, B)` for application steps. Step ordering is
127
+ declared in TOML and executed by `bd`'s dependency graph — static, not dynamic code.
128
+ - The session reconciler and convergence state machine are code-defined graphs; the intra-molecule step
129
+ DAG is `bd`-managed.
130
+
131
+ ---
132
+
133
+ ## Multi-Feature Concurrent Work
134
+
135
+ **Three Jira tickets, one repo:**
136
+
137
+ 1. Create a bead per ticket
138
+ 2. Configure a coder pool with `isolation = "worktree"`
139
+ 3. Gas City auto-creates a git worktree per agent instance (`.gc/worktrees/<rig>/<agent>/`) on a unique
140
+ branch (`gc/coder-<timestamp>`)
141
+ 4. Agents work concurrently on separate branches; beads are in the shared rig store
142
+ 5. Each branch → PR → merge independently; git resolves file conflicts at merge time
143
+
144
+ **Sub-task breakdown (architect → coder pattern):**
145
+
146
+ 1. Create an epic bead for the ticket (HITL: spend time with an agent decomposing into child beads)
147
+ 2. Child beads are labelled for the coder pool
148
+ 3. One coder agent claims the epic, works child beads sequentially in its worktree/branch
149
+ 4. Separate agents handle other tickets concurrently
150
+
151
+ **True backlog isolation** (separate bead stores per feature) requires registering each feature worktree
152
+ as its own rig — doable, more setup, only needed for truly independent multi-ticket sub-backlogs.
153
+
154
+ ---
155
+
156
+ ## Worktrees: What's Automatic vs. Manual
157
+
158
+ `isolation = "worktree"` in an agent's config causes Gas City to automatically:
159
+ - Run `git worktree add .gc/worktrees/<rig>/<agent>/ -b gc/<agent>-<timestamp>`
160
+ - Place a `.beads/redirect` file in the worktree pointing back to the shared rig bead store
161
+ - Store `work_dir` in the bead metadata for restart recovery
162
+
163
+ You do NOT manually run `git worktree add`. The controller handles it.
164
+
165
+ ---
166
+
167
+ ## Bead Store Isolation Notes
168
+
169
+ - One `.beads/` database per rig directory — strictly enforced
170
+ - Worktrees share the parent rig's bead store via `.beads/redirect`
171
+ - Two cities registering the same rig path silently share the same bead DB (acknowledged bug, issue #587)
172
+ - `dolt_host`/`dolt_port` overrides exist as a manual escape hatch for pointing rigs at different stores
173
+ - Concurrent workstreams within one rig: use labels (`pool:feature-a`, `pool:feature-b`) — same DB,
174
+ logically partitioned
175
+
176
+ ---
177
+
178
+ ## Implications for agent-cortex / ralph / run-beads
179
+
180
+ ### Formulas for the TDD pipeline
181
+
182
+ The run-beads TDD pipeline (test-writing → coding → test-reviewing → verifying → reviewing → fixing →
183
+ documenting) maps naturally to a formula:
184
+
185
+ ```toml
186
+ [[steps]]
187
+ id = "test-writing"
188
+ title = "Write failing tests"
189
+
190
+ [[steps]]
191
+ id = "coding"
192
+ title = "Make the tests pass"
193
+ needs = ["test-writing"]
194
+
195
+ [[steps]]
196
+ id = "test-reviewing"
197
+ title = "Review the tests"
198
+ needs = ["coding"]
199
+
200
+ [[steps]]
201
+ id = "verifying"
202
+ title = "Run the test suite"
203
+ needs = ["test-reviewing"]
204
+
205
+ [[steps]]
206
+ id = "reviewing"
207
+ title = "Code review"
208
+ needs = ["verifying"]
209
+
210
+ [[steps]]
211
+ id = "documenting"
212
+ title = "Document the changes"
213
+ needs = ["reviewing"]
214
+ ```
215
+
216
+ `bd` handles the step ordering via the dependency graph. Each step is a bead that unlocks when the
217
+ previous closes. No LLM in the sequencing path.
218
+
219
+ **The loop** (retry if gate fails) requires Gas City's convergence engine — `bd` alone executes DAGs, not
220
+ loops. Until Gas City is adopted, ralph (or an equivalent outer loop) is still needed for this.
221
+
222
+ ### What moves to the deterministic layer
223
+
224
+ With Gas City:
225
+ - Step sequencing → formula `needs` dependencies (TOML, `bd`)
226
+ - Pass/fail routing → gate shell scripts (run tests, typecheck, lint)
227
+ - Retry loop → convergence engine (Go, deterministic)
228
+ - `generate-progress.ts` → largely replaceable by `gc status` / `bd` queries
229
+ - Ralph's dispatch table → formula + gate config
230
+
231
+ ### The remaining gap
232
+
233
+ Cross-repo dependencies (e.g. "don't merge the API until the frontend bead closes") are not natively
234
+ supported. Workaround: a `condition` Order that shell-polls the upstream rig's `bd` state.
235
+
236
+ ---
237
+
238
+ ## Community / Maturity
239
+
240
+ - Version: v1.0.0 (stable, 2026-04-21) — 610 commits in the v0.15.1→1.0.0 sprint
241
+ - Language: Go (1.25+)
242
+ - `gastownhall/beads` (the `bd` CLI): 23,049 ⭐, 1,510 forks
243
+ - Daily commit cadence; team self-hosts using Gas City (highest-signal feedback loop)
244
+ - MIT licence
245
+ - Active milestones: `1.0+`
246
+
247
+ ---
248
+
249
+ ## Open Issues Relevant to Us
250
+
251
+ | Issue | Title | Status |
252
+ |---|---|---|
253
+ | #587 | Multi-city rig and bead-state separation (Pack/City v2) | Open, accepted, no design yet |
254
+ | #907 | Hardcoded 'hq' DB name prevents multi-city Dolt sharing | Open, `1.0+` |
255
+
256
+ [Inspirations](../inspirations.md)