@matyah00/openpi 0.1.5 → 0.2.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/README.md +29 -11
- package/agents/agent-chain.yaml +50 -0
- package/agents/api-designer.md +58 -0
- package/agents/docs-writer.md +38 -0
- package/agents/migration-expert.md +62 -0
- package/agents/perf-auditor.md +64 -0
- package/agents/teams.yaml +23 -0
- package/damage-control-rules.yaml +153 -0
- package/extensions/agent-chain.ts +101 -12
- package/extensions/agent-team.ts +11 -0
- package/extensions/audit-tools.ts +125 -6
- package/extensions/lib/auditLogger.ts +29 -0
- package/extensions/openpi.ts +169 -21
- package/extensions/search-tools.ts +21 -3
- package/extensions/workflow.ts +77 -5
- package/package.json +7 -3
- package/prompts/docs.md +37 -0
- package/prompts/migrate.md +44 -0
- package/prompts/perf.md +52 -0
- package/prompts/refactor.md +53 -0
- package/scripts/validate-package.mjs +28 -1
- package/skills/perf-auditor/SKILL.md +49 -0
- package/skills/refactor-guide/SKILL.md +39 -0
- package/tsconfig.json +2 -1
package/prompts/perf.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Performance audit with bottleneck identification and improvement prioritization
|
|
3
|
+
category: quality
|
|
4
|
+
aliases:
|
|
5
|
+
- performance
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
Run a performance audit for:
|
|
9
|
+
|
|
10
|
+
$ARGUMENTS
|
|
11
|
+
|
|
12
|
+
Process:
|
|
13
|
+
|
|
14
|
+
1. Use `env_scan` to identify the stack and build tooling.
|
|
15
|
+
2. Use `project_tree` to understand project structure and identify hot paths.
|
|
16
|
+
3. Use `code_search_batch` for known performance anti-patterns:
|
|
17
|
+
- N+1 queries, missing indexes, synchronous I/O in async code
|
|
18
|
+
- Large bundle imports, missing tree-shaking, barrel re-exports
|
|
19
|
+
- Missing memoization, inline closures in render, unstable keys
|
|
20
|
+
- O(n²) loops, repeated serialization, missing caching
|
|
21
|
+
4. Use `spawn_agents` with `perf-auditor` for in-depth analysis when useful.
|
|
22
|
+
5. Categorize findings by impact and effort.
|
|
23
|
+
|
|
24
|
+
Output:
|
|
25
|
+
|
|
26
|
+
```text
|
|
27
|
+
Performance Audit: {scope}
|
|
28
|
+
|
|
29
|
+
Risk Level: low | medium | high | critical
|
|
30
|
+
|
|
31
|
+
Quick Wins (< 1 hour):
|
|
32
|
+
1. file:line - issue - estimated improvement
|
|
33
|
+
|
|
34
|
+
Medium Effort (1-4 hours):
|
|
35
|
+
1. file:line - issue - estimated improvement
|
|
36
|
+
|
|
37
|
+
Architecture Changes:
|
|
38
|
+
1. description - estimated improvement - effort
|
|
39
|
+
|
|
40
|
+
Bundle Analysis:
|
|
41
|
+
- Total: ...
|
|
42
|
+
- Largest deps: ...
|
|
43
|
+
|
|
44
|
+
Query Analysis:
|
|
45
|
+
- Hot paths: ...
|
|
46
|
+
- N+1 patterns: ...
|
|
47
|
+
|
|
48
|
+
Recommendations:
|
|
49
|
+
1. ...
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Do not optimize prematurely. Focus on measured or evidenced bottlenecks.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Structured refactoring workflow with smell detection, test verification, and safe execution
|
|
3
|
+
category: quality
|
|
4
|
+
aliases:
|
|
5
|
+
- cleanup
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
Refactor the following:
|
|
9
|
+
|
|
10
|
+
$ARGUMENTS
|
|
11
|
+
|
|
12
|
+
Do not change behavior. The output of the code before and after must be identical for all inputs.
|
|
13
|
+
|
|
14
|
+
Process:
|
|
15
|
+
|
|
16
|
+
1. Use `code_search_batch` and `project_tree` to map the scope.
|
|
17
|
+
2. Identify the code smell or structural problem. Name it:
|
|
18
|
+
- duplicate code, long method, large class, feature envy, data clump,
|
|
19
|
+
- shotgun surgery, divergent change, primitive obsession, dead code,
|
|
20
|
+
- inappropriate intimacy, message chain, speculative generality.
|
|
21
|
+
3. Check for existing tests covering the target code. If tests exist, run them before refactoring.
|
|
22
|
+
4. If no tests exist and the change is risky, write a characterization test first.
|
|
23
|
+
5. Plan the refactoring as a series of small, independently verifiable steps.
|
|
24
|
+
6. Execute one step at a time. Re-run tests after each step.
|
|
25
|
+
7. If any test fails after a step, revert that step and investigate.
|
|
26
|
+
8. Use `spawn_agents` with `reviewer` to verify the refactoring preserves behavior.
|
|
27
|
+
|
|
28
|
+
Output:
|
|
29
|
+
|
|
30
|
+
```text
|
|
31
|
+
Refactoring: {smell} in {scope}
|
|
32
|
+
|
|
33
|
+
Before:
|
|
34
|
+
- Structure: ...
|
|
35
|
+
- Issues: ...
|
|
36
|
+
|
|
37
|
+
Steps:
|
|
38
|
+
1. {step} - verified by {test or check}
|
|
39
|
+
2. ...
|
|
40
|
+
|
|
41
|
+
After:
|
|
42
|
+
- Structure: ...
|
|
43
|
+
- Behavior change: NONE
|
|
44
|
+
|
|
45
|
+
Test results:
|
|
46
|
+
- Before: ...
|
|
47
|
+
- After: ...
|
|
48
|
+
|
|
49
|
+
Remaining smells:
|
|
50
|
+
- ...
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Do not combine refactoring with feature work. Refactoring is behavior-preserving only.
|
|
@@ -88,11 +88,38 @@ for (const [chainName, chain] of Object.entries(chains)) {
|
|
|
88
88
|
continue;
|
|
89
89
|
}
|
|
90
90
|
if (!agentNames.has(step.agent)) fail(`agents/agent-chain.yaml: ${chainName} references unknown agent ${step.agent}`);
|
|
91
|
-
if (typeof step.prompt !== "string" || !step.prompt.trim())
|
|
91
|
+
if (typeof step.prompt !== "string" || !step.prompt.trim()) {
|
|
92
|
+
fail(`agents/agent-chain.yaml: ${chainName} step ${index + 1} missing prompt`);
|
|
93
|
+
} else if (!step.prompt.includes("$INPUT") && !step.prompt.includes("$ORIGINAL") && !/\$STEP_\d+/.test(step.prompt)) {
|
|
94
|
+
fail(`agents/agent-chain.yaml: ${chainName} step ${index + 1} prompt must contain either $INPUT, $ORIGINAL or $STEP_N`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// 2. Validate skill directories
|
|
100
|
+
const skillsAbsolute = join(root, "skills");
|
|
101
|
+
if (existsSync(skillsAbsolute)) {
|
|
102
|
+
for (const entry of readdirSync(skillsAbsolute, { withFileTypes: true })) {
|
|
103
|
+
if (entry.isDirectory()) {
|
|
104
|
+
const skillFile = join(skillsAbsolute, entry.name, "SKILL.md");
|
|
105
|
+
if (!existsSync(skillFile)) {
|
|
106
|
+
fail(`skills/${entry.name}: missing SKILL.md`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// 3. Validate theme JSON files
|
|
113
|
+
for (const file of walk("themes", (name) => name.endsWith(".json"))) {
|
|
114
|
+
try {
|
|
115
|
+
JSON.parse(read(file));
|
|
116
|
+
} catch (err) {
|
|
117
|
+
fail(`${file}: invalid JSON theme file: ${err.message}`);
|
|
92
118
|
}
|
|
93
119
|
}
|
|
94
120
|
|
|
95
121
|
if (failures.length) {
|
|
122
|
+
|
|
96
123
|
console.error(failures.map((item) => `- ${item}`).join("\n"));
|
|
97
124
|
process.exit(1);
|
|
98
125
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: perf-auditor
|
|
3
|
+
description: Use when diagnosing performance issues, optimizing bundle size, fixing slow queries, reducing memory usage, or auditing hot paths.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Performance Auditor
|
|
7
|
+
|
|
8
|
+
Focus on measured or evidenced bottlenecks. Do not optimize prematurely.
|
|
9
|
+
|
|
10
|
+
## Frontend Performance
|
|
11
|
+
|
|
12
|
+
Check for:
|
|
13
|
+
- Large bundle imports (`import _ from 'lodash'` instead of `import get from 'lodash/get'`)
|
|
14
|
+
- Barrel file re-exports that prevent tree-shaking
|
|
15
|
+
- Missing `React.memo`, `useMemo`, `useCallback` on expensive renders
|
|
16
|
+
- Inline object/function props causing unnecessary re-renders
|
|
17
|
+
- Unoptimized images, missing lazy loading
|
|
18
|
+
- Blocking synchronous scripts in `<head>`
|
|
19
|
+
- Layout thrashing from synchronous DOM read/write cycles
|
|
20
|
+
|
|
21
|
+
## Backend Performance
|
|
22
|
+
|
|
23
|
+
Check for:
|
|
24
|
+
- N+1 query patterns in ORM usage (loop with `.find()` or `.get()`)
|
|
25
|
+
- Missing database indexes on filtered/sorted columns
|
|
26
|
+
- Synchronous file I/O in async request handlers
|
|
27
|
+
- Unclosed database connections or missing connection pooling
|
|
28
|
+
- CPU-bound work blocking the event loop
|
|
29
|
+
- Unbounded in-memory caches
|
|
30
|
+
- Missing pagination on list endpoints
|
|
31
|
+
|
|
32
|
+
## General
|
|
33
|
+
|
|
34
|
+
Check for:
|
|
35
|
+
- O(n²) or worse algorithmic complexity in hot paths
|
|
36
|
+
- Repeated JSON serialization/deserialization
|
|
37
|
+
- Missing HTTP caching headers
|
|
38
|
+
- Unnecessary network roundtrips
|
|
39
|
+
- Cold start overhead from eager loading
|
|
40
|
+
|
|
41
|
+
## Tools
|
|
42
|
+
|
|
43
|
+
Use `code_search_batch` with patterns:
|
|
44
|
+
- `\.find\(`, `\.findOne\(`, `\.get\(` inside loops for N+1
|
|
45
|
+
- `import .* from ['"]lodash['"]` for barrel imports
|
|
46
|
+
- `fs\.readFileSync`, `fs\.writeFileSync` for sync I/O
|
|
47
|
+
- `JSON\.parse.*JSON\.stringify` for repeated serialization
|
|
48
|
+
|
|
49
|
+
Report findings with `file:line`, estimated impact, and effort to fix.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: refactor-guide
|
|
3
|
+
description: Use when refactoring code, cleaning up technical debt, removing code smells, extracting modules, or restructuring without changing behavior.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Refactor Guide
|
|
7
|
+
|
|
8
|
+
Refactoring preserves behavior. Never combine refactoring with feature work.
|
|
9
|
+
|
|
10
|
+
## Before Refactoring
|
|
11
|
+
|
|
12
|
+
1. Identify the code smell by name:
|
|
13
|
+
- Duplicate code, long method, large class, feature envy, data clump,
|
|
14
|
+
- shotgun surgery, divergent change, primitive obsession, dead code,
|
|
15
|
+
- inappropriate intimacy, message chain, speculative generality.
|
|
16
|
+
2. Find existing tests covering the target. Run them. They must pass.
|
|
17
|
+
3. If no tests exist and the change is risky, write a characterization test first.
|
|
18
|
+
|
|
19
|
+
## During Refactoring
|
|
20
|
+
|
|
21
|
+
1. Plan as a series of small, independently verifiable steps.
|
|
22
|
+
2. Execute one step at a time.
|
|
23
|
+
3. Re-run relevant tests after each step.
|
|
24
|
+
4. If any test fails, revert that step and investigate.
|
|
25
|
+
5. Do not refactor and add features in the same change.
|
|
26
|
+
|
|
27
|
+
## After Refactoring
|
|
28
|
+
|
|
29
|
+
1. Run the full relevant test suite.
|
|
30
|
+
2. Use `ghost_test_scan` before trusting green tests.
|
|
31
|
+
3. Verify no behavior change with concrete before/after evidence.
|
|
32
|
+
4. Use `spawn_agents` with `reviewer` to validate the diff preserves behavior.
|
|
33
|
+
|
|
34
|
+
## Anti-Patterns to Avoid
|
|
35
|
+
|
|
36
|
+
- Refactoring without tests as a safety net.
|
|
37
|
+
- "While I'm in here" feature additions.
|
|
38
|
+
- Speculative abstraction (don't extract what you don't need yet).
|
|
39
|
+
- Renaming for style without consensus.
|