pi-orchestrator-config 4.1.5

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 (175) hide show
  1. package/README.md +808 -0
  2. package/agents/api-documenter.md +32 -0
  3. package/agents/bash-expert.md +53 -0
  4. package/agents/code-reviewer-docs.md +145 -0
  5. package/agents/code-reviewer-guidelines.md +97 -0
  6. package/agents/code-reviewer-quality.md +142 -0
  7. package/agents/code-reviewer-security.md +107 -0
  8. package/agents/code-reviewer-spec.md +164 -0
  9. package/agents/debugger.md +63 -0
  10. package/agents/docker-expert.md +40 -0
  11. package/agents/docs-fetcher.md +48 -0
  12. package/agents/git-expert.md +63 -0
  13. package/agents/github-expert.md +83 -0
  14. package/agents/go-expert.md +62 -0
  15. package/agents/issue-reviewer-feasibility.md +60 -0
  16. package/agents/issue-reviewer-scope.md +63 -0
  17. package/agents/issue-reviewer-spec.md +77 -0
  18. package/agents/java-expert.md +31 -0
  19. package/agents/jenkins-expert.md +38 -0
  20. package/agents/kubernetes-expert.md +40 -0
  21. package/agents/planner.md +42 -0
  22. package/agents/python-expert.md +61 -0
  23. package/agents/reviewer.md +26 -0
  24. package/agents/scout.md +40 -0
  25. package/agents/security-auditor.md +254 -0
  26. package/agents/technical-documentation-writer.md +37 -0
  27. package/agents/test-automator.md +55 -0
  28. package/agents/test-runner.md +47 -0
  29. package/agents/ts-expert.md +23 -0
  30. package/agents/worker.md +30 -0
  31. package/extensions/acpx-provider/index.ts +104 -0
  32. package/extensions/acpx-provider/load-runtime.ts +99 -0
  33. package/extensions/acpx-provider/runtime-models.ts +40 -0
  34. package/extensions/cli-provider/agents/claude.ts +128 -0
  35. package/extensions/cli-provider/agents/cursor.ts +84 -0
  36. package/extensions/cli-provider/agents/gemini.ts +100 -0
  37. package/extensions/cli-provider/discover.ts +77 -0
  38. package/extensions/cli-provider/index.ts +57 -0
  39. package/extensions/cli-provider/parsers.ts +304 -0
  40. package/extensions/cli-provider/providers.ts +58 -0
  41. package/extensions/cli-provider/runner.ts +225 -0
  42. package/extensions/cli-provider/runtime-models.ts +32 -0
  43. package/extensions/cli-provider/session-reaper.ts +122 -0
  44. package/extensions/cli-provider/sessions.ts +533 -0
  45. package/extensions/cli-provider/shared/discover-cache.ts +235 -0
  46. package/extensions/cli-provider/types.ts +48 -0
  47. package/extensions/coms/coms-net-server.ts +1642 -0
  48. package/extensions/coms/coms-net-wrapper.ts +521 -0
  49. package/extensions/coms/coms-net.ts +1589 -0
  50. package/extensions/coms/coms-p2p.ts +1879 -0
  51. package/extensions/coms/coms-shared.ts +510 -0
  52. package/extensions/coms/coms-wrapper.ts +138 -0
  53. package/extensions/coms/index.ts +20 -0
  54. package/extensions/coms/themeMap.ts +147 -0
  55. package/extensions/image-gen/image-gen.ts +332 -0
  56. package/extensions/image-gen/index.ts +14 -0
  57. package/extensions/orchestrator/agents.ts +134 -0
  58. package/extensions/orchestrator/ask-user.ts +293 -0
  59. package/extensions/orchestrator/async-agents.ts +1037 -0
  60. package/extensions/orchestrator/async-capability.ts +129 -0
  61. package/extensions/orchestrator/async-runner.ts +324 -0
  62. package/extensions/orchestrator/async-status-parse.ts +31 -0
  63. package/extensions/orchestrator/async-status-ui.ts +201 -0
  64. package/extensions/orchestrator/async-wait.ts +36 -0
  65. package/extensions/orchestrator/btw.ts +210 -0
  66. package/extensions/orchestrator/cron-status-format.ts +126 -0
  67. package/extensions/orchestrator/cron-status-ui.ts +132 -0
  68. package/extensions/orchestrator/cron.ts +730 -0
  69. package/extensions/orchestrator/dreaming.ts +355 -0
  70. package/extensions/orchestrator/enforcement-helpers.ts +530 -0
  71. package/extensions/orchestrator/enforcement-rules.ts +329 -0
  72. package/extensions/orchestrator/enforcement.ts +828 -0
  73. package/extensions/orchestrator/extended-autocomplete.ts +593 -0
  74. package/extensions/orchestrator/git-helpers.ts +420 -0
  75. package/extensions/orchestrator/github-autocomplete.ts +250 -0
  76. package/extensions/orchestrator/icons.ts +17 -0
  77. package/extensions/orchestrator/index.ts +100 -0
  78. package/extensions/orchestrator/memory-embeddings.ts +281 -0
  79. package/extensions/orchestrator/memory-promotion.ts +449 -0
  80. package/extensions/orchestrator/memory-provenance.ts +80 -0
  81. package/extensions/orchestrator/memory-query-class.ts +90 -0
  82. package/extensions/orchestrator/memory-scoring.ts +434 -0
  83. package/extensions/orchestrator/memory-tools.ts +883 -0
  84. package/extensions/orchestrator/memory-tree.ts +212 -0
  85. package/extensions/orchestrator/nvim.ts +169 -0
  86. package/extensions/orchestrator/overlay-dashboard-utils.ts +25 -0
  87. package/extensions/orchestrator/overlay-dashboard.ts +512 -0
  88. package/extensions/orchestrator/pi-config-review-state.ts +303 -0
  89. package/extensions/orchestrator/preference-extractor.ts +106 -0
  90. package/extensions/orchestrator/project-settings.ts +468 -0
  91. package/extensions/orchestrator/promotion-queue.ts +311 -0
  92. package/extensions/orchestrator/resolve-agent-model.ts +32 -0
  93. package/extensions/orchestrator/review-ui.ts +204 -0
  94. package/extensions/orchestrator/rule-placeholders.ts +12 -0
  95. package/extensions/orchestrator/rules.ts +481 -0
  96. package/extensions/orchestrator/session-search.ts +243 -0
  97. package/extensions/orchestrator/session-validation.ts +374 -0
  98. package/extensions/orchestrator/situation-report.ts +370 -0
  99. package/extensions/orchestrator/status-bar.ts +31 -0
  100. package/extensions/orchestrator/status-line.ts +192 -0
  101. package/extensions/orchestrator/status.ts +110 -0
  102. package/extensions/orchestrator/subagent-tool.ts +1748 -0
  103. package/extensions/orchestrator/task-lifecycle.ts +88 -0
  104. package/extensions/orchestrator/utils.ts +227 -0
  105. package/extensions/pidash/index.ts +15 -0
  106. package/extensions/pidash/pidash.ts +941 -0
  107. package/extensions/pidiff/index.ts +13 -0
  108. package/extensions/pidiff/pidiff.ts +369 -0
  109. package/extensions/providers/acpx-driver.ts +479 -0
  110. package/extensions/providers/built-in-drivers.ts +52 -0
  111. package/extensions/providers/claude-driver.ts +319 -0
  112. package/extensions/providers/cursor-acpx-driver.ts +398 -0
  113. package/extensions/providers/cursor-cli-driver.ts +484 -0
  114. package/extensions/providers/gemini-driver.ts +302 -0
  115. package/extensions/providers/index.ts +513 -0
  116. package/extensions/shared/build-system-prompt.ts +57 -0
  117. package/extensions/shared/create-runtime-provider.ts +190 -0
  118. package/extensions/shared/daemon-manager.ts +248 -0
  119. package/extensions/shared/file-logger.ts +115 -0
  120. package/extensions/shared/managed-refresh.ts +211 -0
  121. package/extensions/shared/provider-driver.ts +295 -0
  122. package/extensions/shared/provider-errors.ts +305 -0
  123. package/extensions/shared/provider-registry.ts +388 -0
  124. package/extensions/shared/stream-builder.ts +275 -0
  125. package/extensions/shared/types.ts +20 -0
  126. package/extensions/shared/ui/README.md +10 -0
  127. package/extensions/shared/ui/badge.tsx +52 -0
  128. package/extensions/shared/ui/button.tsx +58 -0
  129. package/extensions/shared/ui/collapsible.tsx +21 -0
  130. package/extensions/shared/ui/dropdown-menu.tsx +266 -0
  131. package/extensions/shared/ui/input.tsx +20 -0
  132. package/extensions/shared/ui/popover.tsx +114 -0
  133. package/extensions/shared/ui/resizable.tsx +48 -0
  134. package/extensions/shared/ui/scroll-area.tsx +53 -0
  135. package/extensions/shared/ui/select.tsx +201 -0
  136. package/extensions/shared/ui/separator.tsx +25 -0
  137. package/extensions/shared/ui/tooltip.tsx +64 -0
  138. package/extensions/shared/ws-client.ts +74 -0
  139. package/package.json +59 -0
  140. package/prompts/coderabbit-rate-limit.md +95 -0
  141. package/prompts/create-coms-feature-manager.md +186 -0
  142. package/prompts/create-skill.md +128 -0
  143. package/prompts/domain-model.md +109 -0
  144. package/prompts/external-ai.md +665 -0
  145. package/prompts/implement-and-review.md +25 -0
  146. package/prompts/implement.md +26 -0
  147. package/prompts/issue-review.md +256 -0
  148. package/prompts/pr-review.md +753 -0
  149. package/prompts/query-db.md +154 -0
  150. package/prompts/refine-review.md +208 -0
  151. package/prompts/release.md +235 -0
  152. package/prompts/remember.md +33 -0
  153. package/prompts/review-handler-status.md +27 -0
  154. package/prompts/review-handler.md +677 -0
  155. package/prompts/review-local.md +159 -0
  156. package/prompts/scout-and-plan.md +21 -0
  157. package/rules/00-orchestrator-core.md +42 -0
  158. package/rules/05-issue-first-workflow.md +119 -0
  159. package/rules/10-agent-routing.md +58 -0
  160. package/rules/15-mcp-launchpad.md +46 -0
  161. package/rules/20-code-review-loop.md +234 -0
  162. package/rules/25-documentation-updates.md +15 -0
  163. package/rules/30-prompt-templates.md +19 -0
  164. package/rules/35-memory.md +240 -0
  165. package/rules/40-critical-rules.md +124 -0
  166. package/rules/45-file-preview.md +29 -0
  167. package/rules/50-agent-bug-reporting.md +90 -0
  168. package/rules/55-coms-protocol.md +63 -0
  169. package/rules/60-task-tracking.md +66 -0
  170. package/skills/conflict-resolver/SKILL.md +213 -0
  171. package/skills/skill-creator/SKILL.md +85 -0
  172. package/skills/systematic-debugging/SKILL.md +353 -0
  173. package/skills/test-driven-development/SKILL.md +335 -0
  174. package/skills/update-agents-md/SKILL.md +282 -0
  175. package/templates/coms-feature-manager-prompt.md +313 -0
@@ -0,0 +1,15 @@
1
+ # Documentation Updates (MANDATORY)
2
+
3
+ After ANY code is added, changed, or removed, check if documentation needs updating:
4
+
5
+ | Change | Check these files |
6
+ |--------|-------------------|
7
+ | New feature/command/tool | `README.md` (feature table, usage examples) |
8
+ | New or modified extension module | `dev-docs/repo-structure.md` (repository structure) |
9
+ | New agent added/removed | `dev-docs/repo-structure.md` (structure), `rules/10-agent-routing.md` (routing table), `rules/50-agent-bug-reporting.md` (agent list) |
10
+ | New prompt template | `README.md` (prompt templates table) |
11
+ | Docker/container changes | `README.md` (Docker section, shell alias, mounts), `Dockerfile` |
12
+ | New CLI tool or dependency | `README.md` (tools table), `Dockerfile` |
13
+ | Dev workflow changes | `DEVELOPMENT.md` |
14
+
15
+ **Do not skip this step.** Documentation drift is a bug.
@@ -0,0 +1,19 @@
1
+ # Prompt Template Execution Rules
2
+
3
+ ## When a Prompt Template is Invoked
4
+
5
+ 1. **The prompt template is the authority** — follow its instructions
6
+ 2. **NEVER delegate the prompt template itself** to an agent — the orchestrator executes it
7
+ 3. **The prompt decides** when to run directly and when to delegate to agents
8
+ 4. If the prompt says "run this bash command" — run it directly
9
+ 5. If the prompt says "delegate to X agent" — delegate
10
+ 6. If the prompt doesn't specify — follow normal orchestrator rules (delegate to specialists)
11
+
12
+ ## Key Rules
13
+
14
+ - The orchestrator **maintains control** of the prompt workflow
15
+ - The prompt template's instructions **override** general delegation rules when they conflict
16
+ - **NEVER** delegate the `/command` itself to an agent — only delegate sub-tasks when the prompt says to
17
+
18
+ ❌ **WRONG**: `/mycommand` → delegate entire prompt to an agent
19
+ ✅ **RIGHT**: `/mycommand` → orchestrator follows the prompt → delegates sub-tasks as the prompt instructs
@@ -0,0 +1,240 @@
1
+ # Project Memory
2
+
3
+ Scored, topic-organized memory system with stability-based decay.
4
+ Memories are scored, prioritized, and injected into the system prompt via situation reports.
5
+
6
+ ---
7
+
8
+ ## Memory Tools (MANDATORY)
9
+
10
+ You have five memory tools and one session search tool. **USE THEM PROACTIVELY:**
11
+
12
+ ## Auto-Injection (how memories reach you)
13
+
14
+ Three mechanisms automatically inject relevant context into your system prompt — you don't need to call tools for these:
15
+
16
+ 1. **Situation Report** — token-budgeted summary of scored memories (preferences, lessons, mistakes, patterns, decisions, completions). Always present.
17
+ 2. **Contextual Memory Recall** — vector similarity search against your current message. Entries with similarity > 0.65 appear as "Contextually Relevant Memories."
18
+ 3. **Session History Recall** — keyword search against past conversation summaries. Relevant past sessions appear as "Relevant Past Sessions."
19
+
20
+ **Ground Truth:** All injected memories are authoritative. Use them directly —
21
+ do not re-discover or re-verify information already in your context window.
22
+
23
+ **Social closer gate:** Trivial messages ("ok", "thanks", "👍", < 6 chars) skip vector/session search.
24
+
25
+ ### `memory_search` — Search Before Answering
26
+
27
+ **MANDATORY:** Before answering questions about prior sessions, user preferences, past decisions, or anything mentioned before —
28
+ call `memory_search` first. Supports keyword and category-filtered queries.
29
+
30
+ ### `memory_reinforce` — Reinforce When Relevant
31
+
32
+ **MANDATORY:** When a memory is relevant to the current task, call `memory_reinforce` to bump its evidence count and prevent decay.
33
+
34
+ ### `memory_add` — Add New Memories Proactively
35
+
36
+ **MANDATORY:** When you learn something worth remembering — preferences, corrections, conventions, completed work — add it immediately.
37
+ Keep entries short (~100 chars), specific, actionable.
38
+ Use `pinned: true` ONLY when user explicitly says "remember this". Duplicates are auto-reinforced.
39
+ When a correction is mechanical (can be checked by code), add `trigger` + `action` params — see "Code-Enforced Memories" below.
40
+
41
+ ### `memory_remove` — Remove Outdated Memories
42
+
43
+ Remove entries that are no longer accurate, relevant, or superseded by newer entries.
44
+
45
+ ### `memory_topics` — Inspect Topic Organization
46
+
47
+ List all memory topic files with hotness scores and entry counts.
48
+
49
+ ### `session_search` — Recall Past Conversations
50
+
51
+ Search past conversation summaries for references to previous sessions. Returns matching snippets at zero LLM cost.
52
+
53
+ ---
54
+
55
+ ## Memory Storage
56
+
57
+ ```text
58
+ .pi/memory/
59
+ ├── memory-scores.json # Scoring backend (auto-managed)
60
+ └── topics/
61
+ ├── preferences.md # [preference] entries
62
+ ├── lessons.md # [lesson] entries
63
+ ├── patterns.md # [pattern] entries
64
+ ├── decisions.md # [decision] entries
65
+ ├── completions.md # [done] entries
66
+ └── mistakes.md # [mistake] entries
67
+ ```
68
+
69
+ **Pinned** — user explicitly said "remember this". Dream must NEVER remove these.
70
+ **Learned** — auto-extracted by dreaming. Dream can reorganize, deduplicate, remove.
71
+
72
+ ---
73
+
74
+ ## Scoring System
75
+
76
+ ```text
77
+ stability = cue_weight × exp(-Δt / half_life) × ln(1 + evidence_count)
78
+ ```
79
+
80
+ - Reinforcing bumps evidence count and resets decay. Pinned = 9999 (never decay). Forgotten = 0.
81
+ - **Lifecycle:** active → provisional → candidate → dropped
82
+
83
+ ---
84
+
85
+ ## Capacity Signal
86
+
87
+ The situation report header shows usage: `# Project Memory [72% — 1,224/1,700 tokens]`
88
+
89
+ - **Below 80%** — add freely
90
+ - **Above 80%** — consolidate before adding: merge related entries, remove outdated ones
91
+
92
+ ---
93
+
94
+ ## Memory Quality Rules (CRITICAL)
95
+
96
+ - **One line only** — max ~100 chars, single short sentence
97
+ - **Specific and actionable** — concrete "do X" or "don't do Y", no fluff
98
+ - **Preserve context scope** — if a preference was stated about a specific tool/project/workflow,
99
+ include that scope in the memory. NEVER generalize a context-specific statement into a universal rule.
100
+
101
+ | ❌ Bad | ✅ Good |
102
+ |--------|---------|
103
+ | "We had issues with buildah and Docker caching and tried several approaches" | "buildah chown -R breaks cache mounts — use --mount=type=cache with correct uid" |
104
+ | "User prefers a certain approach to handling processes" | "Attach child processes to pi (no detached:true) — kills on exit" |
105
+ | "Never use gemini-2.5-flash model" (said about a specific tool) | "Never use gemini-2.5-flash for X — unreliable for that use case" |
106
+
107
+ ---
108
+
109
+ ## When to Write
110
+
111
+ | Trigger | Category | Section |
112
+ |---------|----------|--------|
113
+ | User says "remember" / `/remember` | best fit | **Pinned** |
114
+ | PR merged | `done` | Learned |
115
+ | User corrects you | `lesson` | Learned |
116
+ | Multiple fix attempts | `mistake` | Learned |
117
+ | User states a preference | `preference` | Learned |
118
+
119
+ ---
120
+
121
+ ## Code-Enforced Memories (Enforcement Layer)
122
+
123
+ Some memories can be **code-enforced** — the LLM cannot ignore them because runtime hooks
124
+ check and act on them. Use enforcement when a rule is **mechanical** (can be checked by code).
125
+
126
+ Add enforcement by passing `trigger`, `action`, and optionally `verifier` to `memory_add`:
127
+
128
+ ```text
129
+ memory_add(text="...", category="lesson",
130
+ trigger="bash_contains git add .",
131
+ action="block")
132
+ ```
133
+
134
+ **When to add enforcement (AI decides automatically):**
135
+
136
+ | Pattern | Enforcement | Example |
137
+ |---------|-------------|--------|
138
+ | User corrects a specific command/tool usage | `trigger` + `block` | "never use git add ." |
139
+ | User wants something to run after a specific action | `trigger` + `run_after <cmd>` | "always deploy after code changes" |
140
+ | User wants a warning about a specific pattern | `trigger` + `warn` | "warn when modifying config files" |
141
+ | User wants tool A called before tool B | `verifier` | "always ask_user before gh pr merge" |
142
+ | General knowledge / context / facts | **No enforcement** | "buildah chown breaks cache mounts" |
143
+
144
+ **Rule of thumb:** If you can express it as "when X happens, do/block/warn Y" — add enforcement.
145
+ If it's knowledge that informs decisions but can't be checked mechanically — plain memory only.
146
+
147
+ **Trigger types:** `bash_contains <str>`, `bash_regex <pattern>`, `tool_name <name>`, `file_modified <pattern>` (matches file extensions like `*.py` or path substrings like `Dockerfile`)
148
+ **Action types:** `block` (prevent), `run_after <command>` (execute after), `warn` (append warning)
149
+ **Verifier:** `tool_called <tool> before <command>` (checked at turn_end, forces retry on violation)
150
+
151
+ ---
152
+
153
+ ## Per-Turn Self-Improvement (MANDATORY)
154
+
155
+ **After EVERY response, ask:** "Did this turn contain something worth remembering?"
156
+
157
+ | What happened | Action |
158
+ |---------------|--------|
159
+ | User corrected you / said "don't do X" / "always do Y" | `memory_add` as `lesson` or `preference` |
160
+ | Something failed or took multiple attempts | `memory_add` as `mistake` |
161
+ | PR merged / technical decision made / non-obvious pattern found | `memory_add` as `done` / `decision` / `pattern` |
162
+
163
+ **NEVER memorize:**
164
+
165
+ - Ideas or requests the user rejected, abandoned, or said "nevermind" to
166
+ - Unfinished conversations where no conclusion was reached
167
+ - User requirements that were never implemented
168
+
169
+ Only memorize **outcomes** (what happened), not **intentions** (what was discussed but dropped).
170
+
171
+ **Save immediately — do NOT wait for `/dream` or session shutdown.**
172
+
173
+ ---
174
+
175
+ ## CLI
176
+
177
+ ```bash
178
+ uv run myk-pi-tools memory <command> # Commands: add, forget, show, migrate, path, status
179
+ ```
180
+
181
+ **Categories:** `lesson`, `decision`, `mistake`, `pattern`, `done`, `preference`
182
+
183
+ `memory status` — enforcement honesty inventory (code-tier vs injected topic counts + open promotions).
184
+
185
+ ---
186
+
187
+ ## Dreaming (Background Consolidation)
188
+
189
+ Background async agent that reads the session, extracts things worth remembering, adds/deduplicates/reorganizes topic files, and removes stale entries. **NEVER removes Pinned entries.**
190
+ Triggered by `/dream` (manual) or session shutdown (automatic).
191
+ **ALWAYS run as async + fireAndForget** — never block the session.
192
+
193
+ **Dreaming follows the same NEVER memorize rules as per-turn self-improvement:**
194
+ do NOT extract rejected/abandoned ideas, unfinished conversations, or unimplemented requirements.
195
+ Only extract outcomes, not intentions.
196
+
197
+ ---
198
+
199
+ ## Skill Creation (Procedural Memory)
200
+
201
+ Memory stores facts; **skills store procedures.**
202
+ When you complete a multi-step workflow (3+ steps, or doing the same multi-step task for the second time,
203
+ trial-and-error, or non-obvious commands), save it as a skill via `/create-skill <name>`.
204
+ Don't create skills for simple one-step tasks or standard workflows already covered by existing skills.
205
+
206
+ ---
207
+
208
+ ## Promotion Destinations (Correction → Structure)
209
+
210
+ Memories are a staging area. High-evidence or recurring lessons should graduate:
211
+
212
+ | Destination | When | Auto? |
213
+ |-------------|------|-------|
214
+ | `memory` | Stay as a scored topic line | default |
215
+ | `skill` | Multi-step recurring workflow | dream may write `.pi/skills/` |
216
+ | `enforcement` | Mechanical never/always + command/tool | safe auto-apply (`block`/`warn` + clear trigger) |
217
+ | `project_rule` | Project-wide convention, not mechanical | **propose only** — never auto-write `rules/` or `.pi/rules/` |
218
+ | `discard` | Stale / superseded | mark in queue |
219
+
220
+ Queue file: `.pi/memory/promotions.md`. Situation report shows open `proposed` items.
221
+ Thresholds (evidenceCount): enforcement/skill ≥ 3; project_rule ≥ 5.
222
+ On reinforce crossing a threshold, a promotion pass runs automatically.
223
+ `memory_consolidate` and dreaming must write promotion candidates to that queue.
224
+
225
+ ---
226
+
227
+ ## Provenance (optional)
228
+
229
+ `memory_add` / `memory_edit` accept optional `sourceSession`, `derivedFrom`, `informs`.
230
+ Preference extractor sets `sourceSession` when the session id is available.
231
+ Dream may write `.pi/memory/provenance-pending.json`; merge happens on dream complete.
232
+ Stored in `memory-scores.json` only — not injected into the situation report.
233
+ Shown in `memory_search` / `memory_reflect` when present.
234
+
235
+ ---
236
+
237
+ ## Query-class injection (automatic)
238
+
239
+ Injection biases section budgets from the user prompt (no tool call needed):
240
+ `pr_review`, `git_release`, `debug`, or `general`.
@@ -0,0 +1,124 @@
1
+ # Critical Rules
2
+
3
+ ## Questions Are Not Instructions (MANDATORY)
4
+
5
+ When the user asks a question, ONLY answer it. Do not modify files, run state-changing commands,
6
+ create branches/PRs/issues, or take any action beyond reading/searching.
7
+ A question mark means answer only — the user will tell you when to act.
8
+
9
+ ---
10
+
11
+ ## Task Focus (MANDATORY)
12
+
13
+ When executing a multi-step workflow, never abandon it for a side question. Answer the question,
14
+ then immediately resume the workflow from where you left off. After every response, ask yourself:
15
+ was I in a workflow? If yes, what's the next step?
16
+
17
+ ---
18
+
19
+ ## Parallel Execution (MANDATORY)
20
+
21
+ Before every response, identify operations that can run in parallel and execute them all in one message.
22
+
23
+ - Spawn independent agents simultaneously, not sequentially.
24
+ - Only execute sequentially when there's a proven data dependency between operations.
25
+
26
+ ### Async Agents
27
+
28
+ Use `async: true` for independent tasks (reviews, research, polling, monitoring, CI checks) — any task where you don't need the result immediately.
29
+ Only use sync when the very next step depends on this agent's output.
30
+ After spawning async agents, end your turn — results arrive automatically as a follow-up message.
31
+ (`fireAndForget: true` agents are silent — no follow-up.)
32
+
33
+ Do NOT write bash loops, sleep commands, or poll for results after spawning async agents.
34
+
35
+ ❌ Spawn async agent → write bash sleep/poll loop in the same turn
36
+ ✅ Spawn async agent → end your turn — results arrive as follow-up automatically
37
+
38
+ Kill async agents with `asyncKill` when their result is no longer needed.
39
+
40
+ ### Sync Agent Time Estimates
41
+
42
+ Provide `estimatedSeconds` when spawning sync subagents (single, parallel, or chain).
43
+ If the estimated time is 30 seconds or more, use `async: true` instead — the tool enforces this.
44
+ Single: `estimatedSeconds` on top-level. Parallel: per-task (max <30s). Chain: per-step (sum <30s).
45
+
46
+ ### Subagent cwd
47
+
48
+ Always pass `cwd` when delegating to subagents in all modes — omitting it causes enforcement to check the wrong repo.
49
+
50
+ ---
51
+
52
+ ## Multi-PR / Multi-Branch Work
53
+
54
+ **NEVER switch branches in the main worktree** when working on multiple PRs — other agents may be running there.
55
+ Use `git worktree` for each concurrent branch:
56
+
57
+ ```bash
58
+ git worktree add .worktrees/pr-42 origin/fix/issue-42
59
+ git worktree remove .worktrees/pr-42 # when done
60
+ ```
61
+
62
+ ---
63
+
64
+ ## User Interaction
65
+
66
+ When you need user input (approvals, selections, confirmations), always use the `ask_user` tool — never ask via plain text in your response.
67
+ Provide clear options; include 'no'/'cancel' when appropriate.
68
+
69
+ ---
70
+
71
+ ## Technical Honesty
72
+
73
+ When the user proposes an approach, evaluate it critically — if a better technical alternative exists, present it with tradeoffs before proceeding.
74
+ After presenting your analysis, respect the user's decision.
75
+
76
+ ---
77
+
78
+ ## Web Access
79
+
80
+ - Use `web_search` for research and search queries.
81
+ - Use `fetch_content` for extracting content from URLs, YouTube, GitHub repos.
82
+ - Use `agent-browser` CLI for interactive pages requiring clicks, forms, screenshots.
83
+ - **NEVER** use `curl` for reading web pages or SearXNG MCP.
84
+
85
+ ---
86
+
87
+ ## External Code Security Audit
88
+
89
+ Before adopting external code from an untrusted source, delegate a full security audit to `security-auditor`
90
+ and only proceed if verdict is ✅ SAFE or ⚠️ CAUTION with acceptable risks.
91
+ If ❌ UNSAFE — do not use, inform the user with findings.
92
+
93
+ | Source | Audit approach |
94
+ | --------------- | --------------------------------------------------------------------------- |
95
+ | **Git repos** | Clone to `${PROJECT_TMP_DIR}/`, run `security-auditor` |
96
+ | **Pi skills** | Clone/download source to `${PROJECT_TMP_DIR}/`, run `security-auditor` |
97
+ | **PyPI packages** | Clone source repo from PyPI metadata, check install hooks, scan code |
98
+ | **npm packages** | Download source, check `postinstall` scripts, scan code |
99
+ | **MCP servers** | Audit server source code before adding config |
100
+ | **Docker images** | Inspect Dockerfile source, check base image provenance |
101
+ | **Remote scripts** | **ALWAYS block** `curl \| bash` — download first, audit, then run if safe |
102
+
103
+ Skip when the user explicitly says "skip audit", has previously approved the source, or it's a well-known package (e.g., `requests`, `react`, `lodash`).
104
+
105
+ ---
106
+
107
+ ## Temp Files
108
+
109
+ All temp files go to `.pi/tmp/` via `getProjectTmpDir(cwd)` — NEVER create temp files directly in the project tree.
110
+
111
+ ---
112
+
113
+ ## Python Execution with uv
114
+
115
+ Use `uv run --with <package>` for arbitrary Python files with dependencies.
116
+ **NEVER** use `uv run pip install` — the `--with` syntax manages dependencies per-execution without modifying the environment.
117
+
118
+ ---
119
+
120
+ ## External Git Repository Exploration
121
+
122
+ Clone external repos to `${PROJECT_TMP_DIR}/` with `--depth 1` and explore locally using read/bash — not via web fetching.
123
+ Use sparse checkout (`--filter=blob:none --sparse`) when only specific directories are needed.
124
+ For private repos, use SSH or ensure `git config --global credential.helper` is set.
@@ -0,0 +1,29 @@
1
+ # File Preview
2
+
3
+ When generating or modifying HTML, frontend, or any browser-viewable files:
4
+
5
+ 1. Save the file under the project directory (`$PWD`) or `${PROJECT_TMP_DIR}`
6
+ 2. Find a free port and launch the server:
7
+
8
+ ```bash
9
+ HTTPD=~/.pi/agent/git/github.com/myk-org/pi-config/scripts/httpd.py
10
+ PORT=$(uv run python3 $HTTPD --find-port)
11
+ nohup uv run python3 $HTTPD --port $PORT --dir /path/to/serve > ${PROJECT_TMP_DIR}/httpd-$PORT.log 2>&1 &
12
+ disown
13
+ sleep 0.5
14
+ if ! kill -0 $! 2>/dev/null; then echo "Server failed to start:"; cat ${PROJECT_TMP_DIR}/httpd-$PORT.log; fi
15
+ ```
16
+
17
+ Replace `/path/to/serve` with the directory containing the files.
18
+
19
+ 3. Tell the user:
20
+
21
+ > File is being served at `http://localhost:<port>/<filename>` — open this URL in your browser.
22
+
23
+ 4. Keep the server running until the user confirms they're done previewing.
24
+
25
+ **Why `nohup` + `disown`?** `uv run` creates a parent process chain. When bash
26
+ cleans up background jobs, it kills the `uv` parent. `nohup` protects from
27
+ SIGHUP, `disown` removes it from bash's job table.
28
+
29
+ This works in containers (`--network host`) and native installs.
@@ -0,0 +1,90 @@
1
+ # Agent Bug Reporting
2
+
3
+ ## Scope
4
+
5
+ > **If you are a SPECIALIST AGENT:**
6
+ > IGNORE this rule. This is for the ORCHESTRATOR only.
7
+
8
+ When the orchestrator discovers a logic flaw or bug in an agent's configuration or instructions, follow this workflow.
9
+
10
+ ## Agents Covered by This Rule
11
+
12
+ This rule applies ONLY to agents defined in this repository (`agents/` directory):
13
+
14
+ - api-documenter
15
+ - bash-expert
16
+ - code-reviewer-docs
17
+ - code-reviewer-guidelines
18
+ - code-reviewer-quality
19
+ - code-reviewer-security
20
+ - code-reviewer-spec
21
+ - issue-reviewer-spec
22
+ - issue-reviewer-feasibility
23
+ - issue-reviewer-scope
24
+ - debugger
25
+ - docs-fetcher
26
+ - docker-expert
27
+ - ts-expert
28
+ - git-expert
29
+ - github-expert
30
+ - go-expert
31
+ - java-expert
32
+ - jenkins-expert
33
+ - kubernetes-expert
34
+ - planner
35
+ - python-expert
36
+ - reviewer
37
+ - scout
38
+ - security-auditor
39
+ - technical-documentation-writer
40
+ - test-automator
41
+ - test-runner
42
+ - worker
43
+
44
+ **NOT covered:** Built-in pi agents or agents from other sources.
45
+
46
+ ## When to Trigger
47
+
48
+ **Trigger** when you find flawed logic, incorrect results, contradictory behavior, or systematic errors in an agent's instructions (in `agents/` directory — see scope list above).
49
+ **Do NOT trigger** for runtime/external failures, user code bugs, expected behavior the user disagrees with, or bugs in built-in pi agents.
50
+
51
+ ## Workflow
52
+
53
+ 1. **Ask user:** "I found a logic bug in [agent]. Do you want me to create a GitHub issue for this?"
54
+ 2. **If yes:** Delegate to `github-expert` to create the issue in `myk-org/pi-config`.
55
+ 3. **Continue** with the original task (fix bug or apply workaround) regardless of the answer.
56
+
57
+ ## Issue Creation Format
58
+
59
+ **Title:** `bug(agents): [agent-name] - brief description`
60
+
61
+ **Body template:**
62
+
63
+ ```markdown
64
+ ## Agent
65
+ [Agent name from agents/ directory]
66
+
67
+ ## Bug Description
68
+ [Clear description of the logic flaw]
69
+
70
+ ## Expected Behavior
71
+ [What the agent should do]
72
+
73
+ ## Actual Behavior
74
+ [What the agent actually does]
75
+
76
+ ## Suggested Fix
77
+ [Proposed change, if known]
78
+
79
+ ## Impact
80
+ [How this affects users/workflows]
81
+
82
+ ## Context
83
+ [Any additional context about when/how the bug was discovered]
84
+ ```
85
+
86
+ ## Key Rules
87
+
88
+ Always ask user before creating an issue — never auto-create.
89
+ Delegate issue creation to `github-expert` (don't use `gh` commands directly).
90
+ Be specific about which agent and which logic is flawed, and suggest a fix if you know one.
@@ -0,0 +1,63 @@
1
+ # Coms Protocol — Inter-Agent Communication
2
+
3
+ ## Overview
4
+
5
+ Two communication systems are available for talking to other pi sessions:
6
+
7
+ | System | Activation | Tool prefix | Transport |
8
+ |--------|-----------|-------------|-----------|
9
+ | **P2P** (coms) | `/coms start` | `coms_` | Direct peer-to-peer |
10
+ | **Networked** (coms-net) | `/coms-net start` | `coms_net_` | Hub server relay |
11
+
12
+ Both systems can be active. When asked to list peers, send messages, or interact with coms —
13
+ **try both** `coms_list` and `coms_net_list`. If one fails, use the other.
14
+ Don't assume which system is active.
15
+
16
+ ## Activation
17
+
18
+ Tools are unavailable until the user runs `/coms start` (P2P) or `/coms-net start` (networked).
19
+ Use `coms_list` / `coms_net_list` to see connected peers.
20
+
21
+ ## Tool Reference
22
+
23
+ | Action | P2P (coms) | Networked (coms-net) |
24
+ |--------|-----------|---------------------|
25
+ | List peers | `coms_list` | `coms_net_list` |
26
+ | Send message | `coms_send` | `coms_net_send` |
27
+ | Poll for response | `coms_get` | `coms_net_get` |
28
+
29
+ ## Inbound Messages — How to Reply
30
+
31
+ Inbound messages appear as `[from <peer> @ <cwd>] <message>`. Your assistant text IS the reply — the `agent_end` hook captures it and sends it back automatically.
32
+
33
+ ❌ **Never call `coms_send` to reply** — that starts a new outbound conversation instead of replying.
34
+
35
+ ## Outbound Messages — How to Initiate
36
+
37
+ To start a conversation: call the send tool, then **end your turn**.
38
+ The peer's response auto-delivers as a followUp message — no polling needed.
39
+ Use `coms_get` / `coms_net_get` only for non-blocking status checks.
40
+
41
+ ## Message Queue
42
+
43
+ Inbound messages process in FIFO order. If multiple arrive while the peer is busy, they queue — each gets its own turn and response, nothing is dropped.
44
+
45
+ ## Structured Task Delegation
46
+
47
+ Use the `tasks` parameter to delegate structured work items alongside messages. Tasks appear in the peer's task widget (requires `@tintinweb/pi-tasks`):
48
+
49
+ ```text
50
+ coms_send(target="coder", prompt="Implement these features", tasks=[
51
+ {"subject": "Add auth middleware", "description": "JWT validation for all /api routes"},
52
+ {"subject": "Write tests", "description": "Unit tests for auth middleware"}
53
+ ])
54
+ ```
55
+
56
+ ## Key Rules
57
+
58
+ 1. **Responses auto-deliver** — after send, end your turn; the reply arrives as a followUp
59
+ 2. **Never call send tools to reply** to inbound messages — your assistant text is the reply
60
+ 3. **Always check peers first** — use list tools before sending
61
+ 4. **Try both systems** — try `coms_` and `coms_net_` when system isn't specified
62
+ 5. **Messages are never lost** — busy peers queue messages in FIFO order
63
+ 6. **Use tasks for structured work** — use `tasks` parameter instead of prose lists
@@ -0,0 +1,66 @@
1
+ # Task Tracking (MANDATORY)
2
+
3
+ ## Scope
4
+
5
+ > **If you are a SPECIALIST AGENT:**
6
+ > IGNORE this rule. This is for the ORCHESTRATOR only.
7
+
8
+ ---
9
+
10
+ ## When to Create Tasks
11
+
12
+ **BEFORE starting any multi-step workflow (3+ steps)**, use `TaskCreate` to list ALL steps first.
13
+
14
+ **Use tasks for:** feature implementation, bug fixes with multiple files,
15
+ workflows from `rules/05-issue-first-workflow.md` or `rules/20-code-review-loop.md`,
16
+ multi-file refactoring, or any work involving more than 2 actions.
17
+
18
+ **Skip tasks for:** single-step actions, questions/explanations, `/btw` side questions, or trivial fixes.
19
+
20
+ ---
21
+
22
+ ## Task Granularity
23
+
24
+ Tasks MUST be **detailed and specific** — not high-level summaries.
25
+
26
+ - ❌ BAD: `Implement the fix` / `Review code` / `Create PR`
27
+ - ✅ GOOD: `Edit extensions/orchestrator/utils.ts — add timeout parameter to fetchData()` / `Run code review loop (3 async reviewers)` / `Create PR with description`
28
+
29
+ ---
30
+
31
+ ## Task Lifecycle (MANDATORY)
32
+
33
+ Create all tasks BEFORE starting work via `TaskCreate`.
34
+ Mark each `in_progress` before starting and `completed` immediately after finishing via `TaskUpdate`.
35
+ Work through tasks in order — do not skip tasks or start new work while unchecked tasks exist (unless user explicitly pivots).
36
+
37
+ ---
38
+
39
+ ## Side Questions
40
+
41
+ Answer the question, then resume the next unchecked task immediately — the persistent task list tells you exactly where you left off.
42
+
43
+ ---
44
+
45
+ ## Integration & Key Rules
46
+
47
+ Task tracking works alongside existing workflow rules — include issue-first, code review, and documentation steps as individual tasks.
48
+ Tasks are code-enforced (reminders after 4+ ignored turns).
49
+ Never abandon tasks — if scope changes, use `TaskUpdate` with `status: "deleted"` to remove obsolete tasks; the task list is your contract.
50
+
51
+ ---
52
+
53
+ ## Async Agent taskId (MANDATORY — code-enforced)
54
+
55
+ **Every async agent call MUST include `taskId`.** Enforced — calls without it are rejected.
56
+ Pass the task ID (e.g., `"5"`) when linked to a task, or `"-1"` when not.
57
+ Linked tasks auto-complete on agent success — no manual `TaskUpdate` needed.
58
+
59
+ ```text
60
+ subagent(agent="code-reviewer-quality", task="...", cwd="...", async=true, name="Review", taskId="5")
61
+ subagent(agent="worker", task="...", cwd="...", async=true, name="Qodo Poll", taskId="-1")
62
+ ```
63
+
64
+ - ✅ **ALWAYS** pass `taskId` — auto-completes on success, stays `in_progress` on failure
65
+ - ❌ **NEVER** manually `TaskUpdate` a task to `completed` if it has an async agent
66
+ - ❌ **NEVER** omit `taskId` — the call will fail