pi-soly 2.4.2 → 2.5.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-soly",
3
- "version": "2.4.2",
3
+ "version": "2.5.0",
4
4
  "description": "Workflow + project management for pi-coding-agent. Plans, state, MANDATORY rules, self-review, multi-question picker. One npm install, zero config. LLM drives the workflow inline via the soly_workflow tool — no external subagent plugin.",
5
5
  "type": "module",
6
6
  "main": "index.ts",
@@ -0,0 +1,250 @@
1
+ ---
2
+ name: agent-coach
3
+ description: Use when the user complains about how the agent wrote code or behaves — phrases like "переделай X по-другому", "мне не нравится что agent делает Y", "почему опять Z", "не делай так", "agent keeps doing X", "I don't like the agent doing X", "заставь agent-а не делать X", "опять этот god switch". Analyzes the complaint, identifies the missing rule that would have prevented it, and proposes a soly rule draft (.agents/rules/*.md) for the user to confirm via ask_pro. Language-agnostic — works for any codebase. NOT for C#/.NET analyzer rules (use analyzer-coach for that).
4
+ priority: high
5
+ ---
6
+
7
+ # agent-coach
8
+
9
+ Convert a user complaint about agent behavior into a **soly rule** — a
10
+ markdown instruction file in `.agents/rules/` that goes into the system
11
+ prompt and prevents the agent from repeating the mistake.
12
+
13
+ The feedback loop: user corrects → rule persists → agent doesn't repeat.
14
+ Each complaint is a signal that a rule is **missing** (or exists but the
15
+ agent ignored it — investigate which).
16
+
17
+ ## When to use me
18
+
19
+ | Symptom in user's message | Use this skill? |
20
+ |---|---|
21
+ | "переделай X по-другому" / "redo X differently" | **Yes** |
22
+ | "мне не нравится что agent делает Y" / "I don't like the agent doing Y" | **Yes** |
23
+ | "почему опять Z" / "why does it keep doing Z" | **Yes** |
24
+ | "не делай так" / "don't do that" | **Yes** |
25
+ | "agent keeps doing X" / "заставь agent-а не делать X" | **Yes** |
26
+ | Complaint about code style, naming, structure, approach | **Yes** |
27
+ | C#/.NET style complaint (Roslynator/Meziantou/CA-*) | **No** — use `analyzer-coach` |
28
+ | Formatting (indent, EOL, trailing whitespace) | **No** — `.editorconfig` |
29
+ | Code style a linter can check (eslint/biome/prettier) | **No** — linter config |
30
+ | Logic bug in the code | **No** — tests |
31
+ | "this rule fires too much" | **Yes, but inverted** — the rule should go, not be added |
32
+
33
+ ## Mental model
34
+
35
+ A complaint means the agent did X, and the user wanted Y. The rule's job is
36
+ to make the agent do Y next time **without the user having to say it**.
37
+
38
+ **Good rule:** "Use `cancellationToken` not `ct` for C# cancellation tokens.
39
+ The short form is ambiguous in logs and stack traces." → Prevents the mistake.
40
+
41
+ **Bad rule:** "Don't write bad code." → Too vague, not actionable, ignored.
42
+
43
+ The rule must be **specific enough to act on** and **general enough to
44
+ recurring**. One complaint → one rule about the pattern, not about the
45
+ specific instance.
46
+
47
+ ## Workflow (always follow these steps in order)
48
+
49
+ ### Step 1 — Read the complaint + the code
50
+
51
+ Before analyzing, **read**:
52
+ - The user's complaint (what specifically bothers them — extract the
53
+ concrete behavior, not the emotion)
54
+ - The code the agent wrote (the file(s) that triggered the complaint) —
55
+ use `read` / `soly_snippet`
56
+ - The conversation context (what was the agent trying to do?)
57
+
58
+ **Extract the pattern.** "переделай god switch по-другому" is about a
59
+ specific instance, but the underlying pattern might be:
60
+ - "Don't create God classes/switches" (architecture)
61
+ - "Prefer polymorphism over giant switch statements" (design pattern)
62
+ - "Split switches with >5 cases into a dispatch table" (specific threshold)
63
+
64
+ Ask yourself: **what general principle, if the agent had known it, would
65
+ have prevented this?**
66
+
67
+ ### Step 2 — Check existing rules (dedup)
68
+
69
+ Before proposing, **read existing rules** to avoid duplication:
70
+ - Use `soly_doc_search` with keywords from the complaint
71
+ - Or `/rules list` to see all rule files
72
+ - Or `soly_snippet` on `.agents/rules/*.md` files
73
+
74
+ If a rule already covers this but the agent ignored it:
75
+ - The rule may be too vague → propose **strengthening** it (edit, not new)
76
+ - The rule may not apply to the file's glob → propose adding globs
77
+ - The agent may have genuinely missed it → don't create a duplicate
78
+
79
+ If no rule covers it → proceed to Step 3.
80
+
81
+ ### Step 3 — Categorize
82
+
83
+ Pick **one** category (auto-detect from the complaint content):
84
+
85
+ | Category | Path | Complaint is about |
86
+ |---|---|---|
87
+ | `coding` | `.agents/rules/coding/` | Code style, patterns, idioms, language conventions |
88
+ | `architecture` | `.agents/rules/architecture/` | Structure, layering, coupling, dependencies |
89
+ | `process` | `.agents/rules/process/` | Workflow, git hygiene, commit format, review process |
90
+ | `testing` | `.agents/rules/testing/` | Test structure, coverage, naming, fixtures |
91
+ | `naming` | `.agents/rules/naming/` | Identifier names, file names, conventions |
92
+
93
+ If unsure, default to `coding/` — it's the catch-all for code-level rules.
94
+
95
+ If the category directory doesn't exist, the `write` tool creates it
96
+ automatically (it creates parent directories).
97
+
98
+ ### Step 4 — Draft the rule
99
+
100
+ Write the rule in **soly rule format**. Structure:
101
+
102
+ ```markdown
103
+ ---
104
+ description: "[one-line summary — what this rule enforces]"
105
+ globs: ["**/*.ts", "**/*.tsx"] # optional: file patterns this applies to
106
+ priority: high # high | medium | low (default medium)
107
+ ---
108
+
109
+ # [Rule Name]
110
+
111
+ > **[One-line imperative.]** [Why it matters — the cost of violating.]
112
+
113
+ ## The rule
114
+
115
+ [Concrete, actionable instruction. "Do X" not "consider X".
116
+ Reference the specific pattern. Include a threshold if applicable.]
117
+
118
+ [✓ Good example — code block showing the right way]
119
+ [✗ Bad example — code block showing what to avoid]
120
+
121
+ ## Why
122
+
123
+ [The reasoning. Why does the user care? What goes wrong without this rule?
124
+ This section is what convinces the LLM to follow it, not just obey it.]
125
+
126
+ ## Self-audit grep # optional — only for grep-checkable rules
127
+
128
+ [If the violation is detectable by grep/rg, include a command the agent
129
+ can run to self-check. Skip for behavioral/process rules.]
130
+ ```
131
+
132
+ **Writing principles:**
133
+ - **Imperative mood:** "Use X" not "You should use X" or "X is preferred"
134
+ - **Concrete threshold:** "Functions under 50 lines" not "Keep functions short"
135
+ - **Show both sides:** ✓ good + ✗ bad code blocks make it unambiguous
136
+ - **Explain why:** the "## Why" section is what makes the LLM internalize it
137
+ - **No filler:** every line earns its place; rules eat system prompt budget
138
+
139
+ ### Step 5 — Propose via ask_pro
140
+
141
+ **Do not write the file yet.** Show the draft to the user via `ask_pro`:
142
+
143
+ ```
144
+ ask_pro({
145
+ questions: [{
146
+ header: "New rule",
147
+ question: "Create this rule to prevent the agent from repeating the issue?",
148
+ options: [
149
+ {
150
+ label: "Create rule",
151
+ description: "Write to .agents/rules/[category]/[name].md",
152
+ recommended: true,
153
+ preview: "<the full draft markdown in a fenced code block>"
154
+ },
155
+ {
156
+ label: "Edit existing",
157
+ description: "A similar rule exists — strengthen it instead",
158
+ preview: "<diff showing what to add>"
159
+ },
160
+ {
161
+ label: "Skip",
162
+ description: "Don't create a rule — just fix the code this time"
163
+ }
164
+ ]
165
+ }]
166
+ })
167
+ ```
168
+
169
+ The `preview` field is key — it shows the user exactly what they're approving
170
+ in a side panel, formatted as code.
171
+
172
+ ### Step 6 — Write (if confirmed)
173
+
174
+ If the user confirms "Create rule":
175
+ 1. Use `write` to create the file at the chosen path
176
+ 2. The hot-reload watcher picks it up automatically — no `/rules reload` needed
177
+ 3. Emit a confirmation via `emit()` (if in soly context) or just tell the user
178
+
179
+ **File naming:** `kebab-case.md`, descriptive. `no-god-switches.md` not
180
+ `rule1.md` or `architecture-rule.md`.
181
+
182
+ ## Anti-patterns (don't do these)
183
+
184
+ - ❌ **Don't create a rule for a one-off.** If the issue is specific to one
185
+ file and unlikely to recur, just fix the code. Rules are for patterns.
186
+ - ❌ **Don't create vague rules.** "Write clean code" is useless. "Functions
187
+ under 50 lines, extract helpers" is useful.
188
+ - ❌ **Don't duplicate linters.** If eslint/biome/prettier can enforce it,
189
+ point the user there instead. Use `/rulewizard` to decide.
190
+ - ❌ **Don't skip the "## Why" section.** Without reasoning, the LLM treats
191
+ the rule as arbitrary and may argue with it.
192
+ - ❌ **Don't auto-write without confirmation.** The user may want to rephrase,
193
+ recategorize, or decide it's not rule-worthy. Always ask_pro first.
194
+ - ❌ **Don't create multiple rules from one complaint.** One complaint → one
195
+ rule about the underlying pattern. Not five rules about symptoms.
196
+
197
+ ## Integration with soly
198
+
199
+ - Rules created here are loaded by `loadAllRules()` on next session_start
200
+ (or immediately via hot-reload if soly's watcher is active)
201
+ - They appear in `/rules list` and the system prompt's `## ⚠️ MANDATORY` block
202
+ - Priority: project rules (`.agents/rules/`) = 3, local overrides
203
+ (`.agents/rules.local/`) = 5. Suggest `.agents/rules/` for team-shared
204
+ conventions, `.agents/rules.local/` for personal preferences
205
+ - Frontmatter `globs` makes the rule apply only to matching files (saves
206
+ prompt budget — a C# rule doesn't need to load for .ts files)
207
+
208
+ ## Example session
209
+
210
+ **User:** "переделай god switch в customer-service.ts, мне не нравится"
211
+
212
+ **Agent (using this skill):**
213
+
214
+ 1. Reads `customer-service.ts` — finds a 200-line switch on customer type
215
+ 2. Searches existing rules — `/rules list` shows no switch-related rule
216
+ 3. Categorizes → `architecture/` (structural issue, not just style)
217
+ 4. Drafts:
218
+
219
+ ```markdown
220
+ ---
221
+ description: "Avoid giant switch statements — use dispatch maps or polymorphism"
222
+ globs: ["**/*.ts"]
223
+ priority: medium
224
+ ---
225
+
226
+ # No God Switches
227
+
228
+ > **Switches with >5 cases must be refactored to a dispatch table.** Giant
229
+ > switches are unmaintainable and violate the open-closed principle.
230
+
231
+ ## The rule
232
+
233
+ When a `switch` statement exceeds 5 cases (or a single case exceeds 20
234
+ lines), refactor to:
235
+ - A `Record<Case, Handler>` dispatch map (for simple dispatch)
236
+ - Polymorphism (when cases share behavior — subclasses + virtual method)
237
+
238
+ [✓ good: dispatch map example]
239
+ [✗ bad: 50-case switch example]
240
+
241
+ ## Why
242
+
243
+ Giant switches grow linearly with new cases, are hard to test in isolation,
244
+ and make the agent tend to add "just one more case" instead of refactoring.
245
+ The user has to review the entire switch to verify one case is safe.
246
+ ```
247
+
248
+ 5. Shows via ask_pro with the full draft in `preview`
249
+ 6. User confirms → writes to `.agents/rules/architecture/no-god-switches.md`
250
+ 7. Hot-reload picks it up → rule is active for the next turn