pi-mono-simplify 1.3.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/CHANGELOG.md ADDED
@@ -0,0 +1,30 @@
1
+ # pi-mono-simplify
2
+
3
+ ## 1.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - ### New Extensions
8
+
9
+ #### `loop`
10
+
11
+ New extension that runs a prompt or slash command on a recurring interval. Useful for periodic tasks, polling, and automated repeated actions within a pi session.
12
+
13
+ #### `simplify`
14
+
15
+ New extension that reviews changed code for reuse, quality, and efficiency, then automatically fixes any issues found. Integrates with `git diff` to scope the review to recent changes.
16
+
17
+ ***
18
+
19
+ ### Bug Fixes
20
+
21
+ #### `multi-edit`
22
+
23
+ - **Broader unicode normalization**: `findActualString` now handles the full range of Unicode single-quote variants (`\u2018\u2019\u201A\u201B`) and double-quote variants (`\u201C\u201D\u201E\u201F`) when falling back from exact match — fixes more curly-quote mismatch cases
24
+ - **Parallel write-access preflight**: `checkWriteAccess` calls are now issued concurrently via `Promise.all` instead of sequentially — faster batch preflight on large edit sets
25
+ - **Removed redundant `editOrder` array**: `Map` insertion order is now relied upon directly, simplifying the grouping loop
26
+
27
+ #### `team-mode`
28
+
29
+ - **Stall detection hardened**: introduced `STALL_BLOCKER_MARKER` / `STALL_BLOCKER_MESSAGE` constants so the marker used to detect and record abnormal process exits stays in sync — prevents duplicate stall reports
30
+ - **Leader cycle guard comment clarified**: `cycleRunning` guard comment now explicitly calls out the race between the poll interval and teammate-completion handlers
package/LICENCE.md ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2026 Emanuel Casco
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,56 @@
1
+ # Simplify Extension
2
+
3
+ Registers a `/simplify` command that reviews all git-changed files for code reuse, quality, and efficiency — then fixes any issues found.
4
+
5
+ Ported from the [`simplify` skill](https://github.com/emanuelcasco/claude-code/blob/main/src/skills/bundled/simplify.ts) for Claude Code.
6
+
7
+ ## Usage
8
+
9
+ ```
10
+ /simplify
11
+ /simplify <additional focus>
12
+ ```
13
+
14
+ **Examples:**
15
+
16
+ ```
17
+ /simplify
18
+ /simplify focus on performance and memory usage
19
+ /simplify pay extra attention to React re-renders
20
+ ```
21
+
22
+ ## Structure
23
+
24
+ - `index.ts` — extension entrypoint, registers the `/simplify` command
25
+
26
+ ## How It Works
27
+
28
+ Running `/simplify` injects a structured prompt into the conversation that drives a three-phase review:
29
+
30
+ ### Phase 1 — Identify Changes
31
+
32
+ Runs `git diff` (or `git diff HEAD` for staged changes) to get the full diff. Falls back to recently modified files if no git changes are present.
33
+
34
+ ### Phase 2 — Parallel Review (3 agents)
35
+
36
+ Three sub-agents run concurrently, each receiving the full diff:
37
+
38
+ | Agent | Focus |
39
+ |-------|-------|
40
+ | **Code Reuse** | Flags duplicated logic, hand-rolled utilities that shadow existing helpers, and inline patterns that should use shared abstractions |
41
+ | **Code Quality** | Detects redundant state, parameter sprawl, copy-paste blocks, leaky abstractions, stringly-typed code, unnecessary JSX nesting, and low-value comments |
42
+ | **Efficiency** | Catches unnecessary work, missed concurrency, hot-path bloat, recurring no-op updates, TOCTOU existence checks, memory leaks, and overly broad data fetches |
43
+
44
+ ### Phase 3 — Fix & Summarize
45
+
46
+ Aggregates findings from all three agents, applies fixes directly, skips false positives, and prints a brief summary of what changed (or confirms the code was already clean).
47
+
48
+ ## Optional Focus
49
+
50
+ Pass extra instructions after the command to steer the review:
51
+
52
+ ```
53
+ /simplify pay close attention to SQL query efficiency
54
+ ```
55
+
56
+ This appends an **Additional Focus** section to the prompt, which all agents will take into account.
package/index.ts ADDED
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Simplify — reviews changed code for reuse, quality, and efficiency,
3
+ * then fixes any issues found.
4
+ *
5
+ * Ported from: https://github.com/emanuelcasco/claude-code/blob/main/src/skills/bundled/simplify.ts
6
+ *
7
+ * Usage:
8
+ * /simplify — review all git-changed files
9
+ * /simplify focus on perf — review with additional focus
10
+ */
11
+
12
+ import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
13
+
14
+ const SIMPLIFY_PROMPT = `# Simplify: Code Review and Cleanup
15
+
16
+ Review all changed files for reuse, quality, and efficiency. Fix any issues found.
17
+
18
+ ## Phase 1: Identify Changes
19
+
20
+ Run \`git diff\` (or \`git diff HEAD\` if there are staged changes) to see what changed. If there are no git changes, review the most recently modified files that the user mentioned or that you edited earlier in this conversation.
21
+
22
+ ## Phase 2: Launch Three Review Agents in Parallel
23
+
24
+ Use the agent tool to launch all three agents concurrently in a single message. Pass each agent the full diff so it has the complete context.
25
+
26
+ ### Agent 1: Code Reuse Review
27
+
28
+ For each change:
29
+
30
+ 1. **Search for existing utilities and helpers** that could replace newly written code. Look for similar patterns elsewhere in the codebase — common locations are utility directories, shared modules, and files adjacent to the changed ones.
31
+ 2. **Flag any new function that duplicates existing functionality.** Suggest the existing function to use instead.
32
+ 3. **Flag any inline logic that could use an existing utility** — hand-rolled string manipulation, manual path handling, custom environment checks, ad-hoc type guards, and similar patterns are common candidates.
33
+
34
+ ### Agent 2: Code Quality Review
35
+
36
+ Review the same changes for hacky patterns:
37
+
38
+ 1. **Redundant state**: state that duplicates existing state, cached values that could be derived, observers/effects that could be direct calls
39
+ 2. **Parameter sprawl**: adding new parameters to a function instead of generalizing or restructuring existing ones
40
+ 3. **Copy-paste with slight variation**: near-duplicate code blocks that should be unified with a shared abstraction
41
+ 4. **Leaky abstractions**: exposing internal details that should be encapsulated, or breaking existing abstraction boundaries
42
+ 5. **Stringly-typed code**: using raw strings where constants, enums (string unions), or branded types already exist in the codebase
43
+ 6. **Unnecessary JSX nesting**: wrapper Boxes/elements that add no layout value — check if inner component props (flexShrink, alignItems, etc.) already provide the needed behavior
44
+ 7. **Unnecessary comments**: comments explaining WHAT the code does (well-named identifiers already do that), narrating the change, or referencing the task/caller — delete; keep only non-obvious WHY (hidden constraints, subtle invariants, workarounds)
45
+
46
+ ### Agent 3: Efficiency Review
47
+
48
+ Review the same changes for efficiency:
49
+
50
+ 1. **Unnecessary work**: redundant computations, repeated file reads, duplicate network/API calls, N+1 patterns
51
+ 2. **Missed concurrency**: independent operations run sequentially when they could run in parallel
52
+ 3. **Hot-path bloat**: new blocking work added to startup or per-request/per-render hot paths
53
+ 4. **Recurring no-op updates**: state/store updates inside polling loops, intervals, or event handlers that fire unconditionally — add a change-detection guard so downstream consumers aren't notified when nothing changed. Also: if a wrapper function takes an updater/reducer callback, verify it honors same-reference returns (or whatever the "no change" signal is) — otherwise callers' early-return no-ops are silently defeated
54
+ 5. **Unnecessary existence checks**: pre-checking file/resource existence before operating (TOCTOU anti-pattern) — operate directly and handle the error
55
+ 6. **Memory**: unbounded data structures, missing cleanup, event listener leaks
56
+ 7. **Overly broad operations**: reading entire files when only a portion is needed, loading all items when filtering for one
57
+
58
+ ## Phase 3: Fix Issues
59
+
60
+ Wait for all three agents to complete. Aggregate their findings and fix each issue directly. If a finding is a false positive or not worth addressing, note it and move on — do not argue with the finding, just skip it.
61
+
62
+ When done, briefly summarize what was fixed (or confirm the code was already clean).
63
+ `;
64
+
65
+ export default function simplifyExtension(pi: ExtensionAPI): void {
66
+ pi.registerCommand("simplify", {
67
+ description: "Review changed code for reuse, quality, and efficiency, then fix any issues found.",
68
+ handler: async (args, ctx) => {
69
+ let prompt = SIMPLIFY_PROMPT;
70
+
71
+ if (args?.trim()) {
72
+ prompt += `\n\n## Additional Focus\n\n${args.trim()}`;
73
+ }
74
+
75
+ pi.sendUserMessage(prompt);
76
+ },
77
+ });
78
+ }
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "pi-mono-simplify",
3
+ "version": "1.3.0",
4
+ "description": "Pi extension that reviews changed code for reuse, quality, and efficiency, then fixes any issues found",
5
+ "keywords": [
6
+ "pi-package",
7
+ "pi-extension"
8
+ ],
9
+ "peerDependencies": {
10
+ "@mariozechner/pi-ai": "*",
11
+ "@mariozechner/pi-coding-agent": "*",
12
+ "@mariozechner/pi-tui": "*",
13
+ "@sinclair/typebox": "*"
14
+ },
15
+ "pi": {
16
+ "extensions": [
17
+ "./index.ts"
18
+ ]
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/emanuelcasco/pi-extensions.git",
23
+ "directory": "extensions/simplify"
24
+ },
25
+ "bugs": {
26
+ "url": "https://github.com/emanuelcasco/pi-extensions/issues"
27
+ },
28
+ "homepage": "https://github.com/emanuelcasco/pi-extensions#readme"
29
+ }