perf-skill 0.2.1 → 0.4.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/.claude-plugin/README.md +48 -0
- package/.claude-plugin/marketplace.json +27 -0
- package/.claude-plugin/plugin.json +21 -0
- package/CLAUDE.md +166 -0
- package/README.md +128 -109
- package/dist/cli/init.d.ts +19 -3
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +108 -11
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/main.js +72 -49
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/platforms.d.ts +28 -0
- package/dist/cli/platforms.d.ts.map +1 -0
- package/dist/cli/platforms.js +238 -0
- package/dist/cli/platforms.js.map +1 -0
- package/dist/cli/template.d.ts +16 -0
- package/dist/cli/template.d.ts.map +1 -0
- package/dist/cli/template.js +157 -0
- package/dist/cli/template.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +71 -36
- package/dist/index.js.map +1 -1
- package/dist/llm/client.d.ts +6 -0
- package/dist/llm/client.d.ts.map +1 -1
- package/dist/llm/client.js +11 -2
- package/dist/llm/client.js.map +1 -1
- package/dist/llm/index.d.ts +1 -1
- package/dist/llm/index.d.ts.map +1 -1
- package/dist/llm/index.js +1 -1
- package/dist/llm/index.js.map +1 -1
- package/dist/skill/handler.d.ts +7 -0
- package/dist/skill/handler.d.ts.map +1 -1
- package/dist/skill/handler.js +24 -1
- package/dist/skill/handler.js.map +1 -1
- package/dist/skill/manifest.d.ts +4 -0
- package/dist/skill/manifest.d.ts.map +1 -1
- package/dist/skill/manifest.js +60 -39
- package/dist/skill/manifest.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +13 -10
- package/skills/perf-skill/SKILL.md +194 -0
- package/SKILL.md +0 -238
- package/dist/server/http.d.ts +0 -27
- package/dist/server/http.d.ts.map +0 -1
- package/dist/server/http.js +0 -285
- package/dist/server/http.js.map +0 -1
- package/dist/server/utils.d.ts +0 -15
- package/dist/server/utils.d.ts.map +0 -1
- package/dist/server/utils.js +0 -71
- package/dist/server/utils.js.map +0 -1
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# perf-skill - Claude Code Plugin
|
|
2
|
+
|
|
3
|
+
This directory contains the Claude Code plugin configuration for perf-skill.
|
|
4
|
+
|
|
5
|
+
## Plugin Structure
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
perf-skill/
|
|
9
|
+
.claude-plugin/
|
|
10
|
+
plugin.json # Plugin manifest (metadata only)
|
|
11
|
+
README.md # This file
|
|
12
|
+
skills/
|
|
13
|
+
perf-skill/
|
|
14
|
+
SKILL.md # Skill definition (discovered by Claude Code)
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Claude Code discovers skills via the `skills/` directory convention. The `plugin.json` provides metadata; skill contents are found automatically.
|
|
18
|
+
|
|
19
|
+
## Installation via Marketplace
|
|
20
|
+
|
|
21
|
+
Users install this plugin in two steps:
|
|
22
|
+
|
|
23
|
+
```text
|
|
24
|
+
# 1. Add the marketplace (this repo)
|
|
25
|
+
/plugin marketplace add skillsland/perf-skill
|
|
26
|
+
|
|
27
|
+
# 2. Install the plugin from the marketplace
|
|
28
|
+
/plugin install perf-skill@skillsland-perf
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Alternative: CLI Installation (project-level)
|
|
32
|
+
|
|
33
|
+
For project-level installation (commits skill to repo):
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npx perf-skill init --ai claude
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
This copies the skill to `.claude/skills/perf-skill/SKILL.md` in the current project.
|
|
40
|
+
|
|
41
|
+
## Version Sync
|
|
42
|
+
|
|
43
|
+
Keep `version` in `plugin.json` synchronized with `package.json`.
|
|
44
|
+
|
|
45
|
+
## Support
|
|
46
|
+
|
|
47
|
+
- Issues: https://github.com/skillsland/perf-skill/issues
|
|
48
|
+
- Documentation: https://github.com/skillsland/perf-skill#readme
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "skillsland-perf",
|
|
3
|
+
"owner": {
|
|
4
|
+
"name": "skillsland",
|
|
5
|
+
"email": "nicasio@foxmail.com"
|
|
6
|
+
},
|
|
7
|
+
"metadata": {
|
|
8
|
+
"description": "Performance profiling plugins for Claude Code"
|
|
9
|
+
},
|
|
10
|
+
"plugins": [
|
|
11
|
+
{
|
|
12
|
+
"name": "perf-skill",
|
|
13
|
+
"description": "Analyze pprof CPU and heap profiles and generate evidence-based performance recommendations.",
|
|
14
|
+
"version": "0.3.0",
|
|
15
|
+
"author": {
|
|
16
|
+
"name": "skillsland"
|
|
17
|
+
},
|
|
18
|
+
"source": {
|
|
19
|
+
"source": "github",
|
|
20
|
+
"repo": "skillsland/perf-skill",
|
|
21
|
+
"ref": "main"
|
|
22
|
+
},
|
|
23
|
+
"category": "Development workflows",
|
|
24
|
+
"tags": ["performance", "pprof", "profiling", "cpu", "heap", "optimization"]
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "perf-skill",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Analyze pprof CPU and heap profiles and generate evidence-based performance recommendations.",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "skillsland"
|
|
7
|
+
},
|
|
8
|
+
"repository": "https://github.com/skillsland/perf-skill",
|
|
9
|
+
"homepage": "https://github.com/skillsland/perf-skill",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"keywords": [
|
|
12
|
+
"performance",
|
|
13
|
+
"profiling",
|
|
14
|
+
"pprof",
|
|
15
|
+
"cpu",
|
|
16
|
+
"heap",
|
|
17
|
+
"memory",
|
|
18
|
+
"optimization",
|
|
19
|
+
"analysis"
|
|
20
|
+
]
|
|
21
|
+
}
|
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
# CLAUDE.md - Developer Guide for perf-skill
|
|
2
|
+
|
|
3
|
+
This document provides guidelines for AI agents and developers working with the perf-skill codebase.
|
|
4
|
+
|
|
5
|
+
## Project Overview
|
|
6
|
+
|
|
7
|
+
perf-skill is an AI skill that converts pprof CPU and heap profiles (.pb.gz) into structured Markdown and JSON evidence. It follows a **deterministic, evidence-first** design philosophy - the tool produces factual data without AI dependencies, while AI agents can optionally enhance the output with recommendations.
|
|
8
|
+
|
|
9
|
+
## Repository Structure
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
perf-skill/
|
|
13
|
+
├── src/
|
|
14
|
+
│ ├── cli/ # CLI implementation
|
|
15
|
+
│ │ ├── main.ts # CLI entry point
|
|
16
|
+
│ │ ├── init.ts # Skill installation logic
|
|
17
|
+
│ │ ├── platforms.ts # Multi-platform configurations
|
|
18
|
+
│ │ └── template.ts # Template rendering engine
|
|
19
|
+
│ ├── parser/ # pprof parsing logic
|
|
20
|
+
│ ├── renderer/ # Markdown/JSON output
|
|
21
|
+
│ ├── profile/ # Node.js profiling
|
|
22
|
+
│ └── index.ts # Library exports
|
|
23
|
+
├── test/ # Test files
|
|
24
|
+
├── skills/
|
|
25
|
+
│ └── perf-skill/
|
|
26
|
+
│ └── SKILL.md # Main skill definition (single source of truth)
|
|
27
|
+
├── .claude-plugin/ # Claude Code plugin configs
|
|
28
|
+
├── package.json
|
|
29
|
+
└── README.md
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Key Commands
|
|
33
|
+
|
|
34
|
+
### Development
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# Build
|
|
38
|
+
npm run build
|
|
39
|
+
|
|
40
|
+
# Run CLI in development
|
|
41
|
+
npm run cli -- analyze profile.pb.gz
|
|
42
|
+
|
|
43
|
+
# Run tests
|
|
44
|
+
npm test
|
|
45
|
+
|
|
46
|
+
# Lint
|
|
47
|
+
npm run lint
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### CLI Usage
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
# Analyze a profile
|
|
54
|
+
npx perf-skill analyze cpu.pb.gz -o report.md
|
|
55
|
+
|
|
56
|
+
# Compare profiles
|
|
57
|
+
npx perf-skill diff base.pb.gz current.pb.gz
|
|
58
|
+
|
|
59
|
+
# Profile and analyze a Node.js app
|
|
60
|
+
npx perf-skill run app.js --duration 10s
|
|
61
|
+
|
|
62
|
+
# Install skill for a platform
|
|
63
|
+
npx perf-skill init --ai cursor
|
|
64
|
+
npx perf-skill init --ai claude
|
|
65
|
+
npx perf-skill init --ai all
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Architecture Decisions
|
|
69
|
+
|
|
70
|
+
### Evidence-First Design
|
|
71
|
+
|
|
72
|
+
- The core analyzer produces structured data without AI
|
|
73
|
+
- LLM integration is optional (via `--ai` flag)
|
|
74
|
+
- All outputs are reproducible and deterministic
|
|
75
|
+
|
|
76
|
+
### Multi-Platform Support
|
|
77
|
+
|
|
78
|
+
The `init` command supports 13+ AI platforms:
|
|
79
|
+
- Claude, Cursor, Windsurf, Copilot, Kiro
|
|
80
|
+
- Codex, Qoder, Roo Code, Gemini, Trae
|
|
81
|
+
- OpenCode, Continue, CodeBuddy
|
|
82
|
+
|
|
83
|
+
Each platform has its own configuration in `src/cli/platforms.ts`.
|
|
84
|
+
|
|
85
|
+
### Template System
|
|
86
|
+
|
|
87
|
+
Platform-specific skill files are generated from:
|
|
88
|
+
1. Base `skills/perf-skill/SKILL.md` content
|
|
89
|
+
2. Platform configuration (frontmatter, sections)
|
|
90
|
+
3. Template engine in `src/cli/template.ts`
|
|
91
|
+
|
|
92
|
+
## Contributing Guidelines
|
|
93
|
+
|
|
94
|
+
### Code Style
|
|
95
|
+
|
|
96
|
+
- Use TypeScript strict mode
|
|
97
|
+
- Follow existing patterns for error handling
|
|
98
|
+
- Add tests for new features
|
|
99
|
+
- Update `skills/perf-skill/SKILL.md` for user-facing changes
|
|
100
|
+
|
|
101
|
+
### Testing
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
# Run all tests
|
|
105
|
+
npm test
|
|
106
|
+
|
|
107
|
+
# Run specific test file
|
|
108
|
+
node --test --import tsx test/parser.test.ts
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Pull Request Process
|
|
112
|
+
|
|
113
|
+
1. Create feature branch from `main`
|
|
114
|
+
2. Make changes with descriptive commits
|
|
115
|
+
3. Ensure tests pass: `npm test`
|
|
116
|
+
4. Ensure lint passes: `npm run lint`
|
|
117
|
+
5. Update documentation if needed
|
|
118
|
+
6. Submit PR with clear description
|
|
119
|
+
|
|
120
|
+
## Common Tasks
|
|
121
|
+
|
|
122
|
+
### Adding a New Platform
|
|
123
|
+
|
|
124
|
+
1. Add platform to `AI_PLATFORMS` array in `src/cli/platforms.ts`
|
|
125
|
+
2. Add configuration to `PLATFORM_CONFIGS` object
|
|
126
|
+
3. Test installation: `npm run cli -- init --ai <platform>`
|
|
127
|
+
|
|
128
|
+
### Updating SKILL.md
|
|
129
|
+
|
|
130
|
+
1. Edit `skills/perf-skill/SKILL.md`
|
|
131
|
+
2. Test rendering: `npm run cli -- init --ai claude --dry-run`
|
|
132
|
+
3. Verify frontmatter is valid YAML
|
|
133
|
+
|
|
134
|
+
### Publishing
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
# Bump version
|
|
138
|
+
npm version patch|minor|major
|
|
139
|
+
|
|
140
|
+
# Publish to npm
|
|
141
|
+
npm publish
|
|
142
|
+
|
|
143
|
+
# Sync Claude Marketplace
|
|
144
|
+
# - Update version in .claude-plugin/plugin.json
|
|
145
|
+
# - Submit to marketplace for review
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Debugging
|
|
149
|
+
|
|
150
|
+
### Common Issues
|
|
151
|
+
|
|
152
|
+
1. **Profile parsing fails**: Check file is valid gzip-compressed protobuf
|
|
153
|
+
2. **Source code not included**: Verify `--source-dir` path exists
|
|
154
|
+
3. **Platform install fails**: Check directory permissions
|
|
155
|
+
|
|
156
|
+
### Verbose Mode
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
npx perf-skill analyze profile.pb.gz --verbose
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Security Considerations
|
|
163
|
+
|
|
164
|
+
- Profile data may contain sensitive information
|
|
165
|
+
- Use `--redact` (default) to sanitize paths
|
|
166
|
+
- Never commit real profiles to the repository
|
package/README.md
CHANGED
|
@@ -4,14 +4,23 @@
|
|
|
4
4
|
[](http://badge.fury.io/js/perf-skill)
|
|
5
5
|

|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
**Deterministic** pprof evidence extractor for CPU/heap profiles: convert .pb.gz/.pprof to structured Markdown and JSON, compare profiles for regressions, and produce evidence that any AI agent can use for optimization recommendations.
|
|
8
|
+
|
|
9
|
+
## Philosophy
|
|
10
|
+
|
|
11
|
+
This tool follows the "evidence generator" pattern:
|
|
12
|
+
|
|
13
|
+
1. **Deterministic by default** — All operations produce consistent, reproducible output without external API calls
|
|
14
|
+
2. **LLM-agnostic** — The tool produces structured evidence (hotspots, call paths, metrics); the host agent (Claude, Cursor, etc.) performs reasoning
|
|
15
|
+
3. **No network by default** — No data leaves your machine unless you explicitly enable AI analysis with `--ai`
|
|
16
|
+
4. **Skill-ready** — Designed to work as a Claude Skill / Cursor Agent Skill that provides facts for the agent to interpret
|
|
8
17
|
|
|
9
18
|
## Features
|
|
10
19
|
|
|
11
|
-
- **Convert
|
|
12
|
-
- **Analyze**:
|
|
13
|
-
- **Diff**: Compare two profiles to find regressions
|
|
14
|
-
- **
|
|
20
|
+
- **Convert** (default): Transform pprof profiles to structured Markdown and JSON evidence
|
|
21
|
+
- **Analyze**: Optionally get AI-powered recommendations with `--ai` flag
|
|
22
|
+
- **Diff**: Compare two profiles to find regressions and improvements
|
|
23
|
+
- **Multiple interfaces**: Library API and CLI for direct integration
|
|
15
24
|
|
|
16
25
|
## Installation
|
|
17
26
|
|
|
@@ -25,32 +34,56 @@ Or run directly with npx:
|
|
|
25
34
|
npx perf-skill analyze profile.pb.gz
|
|
26
35
|
```
|
|
27
36
|
|
|
37
|
+
### AI Platform Integration
|
|
38
|
+
|
|
39
|
+
Install perf-skill as a skill for your preferred AI coding assistant:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# Claude Code / Claude Desktop
|
|
43
|
+
npx perf-skill init --ai claude
|
|
44
|
+
|
|
45
|
+
# Cursor
|
|
46
|
+
npx perf-skill init --ai cursor
|
|
47
|
+
|
|
48
|
+
# GitHub Copilot
|
|
49
|
+
npx perf-skill init --ai copilot
|
|
50
|
+
|
|
51
|
+
# All supported platforms at once
|
|
52
|
+
npx perf-skill init --ai all
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
See [Supported Platforms](#supported-platforms) for the full list.
|
|
56
|
+
|
|
28
57
|
## Quick Start
|
|
29
58
|
|
|
30
59
|
### CLI Usage
|
|
31
60
|
|
|
32
61
|
```bash
|
|
33
|
-
#
|
|
34
|
-
perf-skill
|
|
62
|
+
# Analyze profile → structured evidence (default, no LLM, no network)
|
|
63
|
+
perf-skill analyze cpu.pb.gz -o report.md
|
|
64
|
+
|
|
65
|
+
# Analyze with explicit AI recommendations (requires API key)
|
|
66
|
+
perf-skill analyze cpu.pb.gz --ai -o report.md
|
|
35
67
|
|
|
36
|
-
#
|
|
37
|
-
perf-skill
|
|
68
|
+
# Convert-only command (always deterministic)
|
|
69
|
+
perf-skill convert cpu.pb.gz -o report.md
|
|
38
70
|
|
|
39
|
-
# Profile a Node entry (CPU, 10s)
|
|
71
|
+
# Profile a Node entry (CPU, 10s) → evidence output
|
|
40
72
|
perf-skill run slow.mjs --duration 10s
|
|
41
73
|
|
|
74
|
+
# Profile with AI recommendations
|
|
75
|
+
perf-skill run slow.mjs --duration 10s --ai
|
|
76
|
+
|
|
42
77
|
# CPU + Heap profiling (separate reports)
|
|
43
78
|
perf-skill run slow.mjs --heap --output cpu.md --heap-output heap.md
|
|
44
79
|
|
|
45
80
|
# Compare two profiles
|
|
46
81
|
perf-skill diff base.pb.gz current.pb.gz -o diff.md
|
|
47
82
|
|
|
48
|
-
#
|
|
49
|
-
perf-skill
|
|
50
|
-
|
|
51
|
-
# Install
|
|
52
|
-
perf-skill init --cursor
|
|
53
|
-
perf-skill init --cursor --scope project
|
|
83
|
+
# Install skill for your AI platform
|
|
84
|
+
perf-skill init --ai claude
|
|
85
|
+
perf-skill init --ai cursor --scope project
|
|
86
|
+
perf-skill init --ai all # Install to all supported platforms
|
|
54
87
|
|
|
55
88
|
# Install SKILL.md to a custom directory
|
|
56
89
|
perf-skill init ./skills/perf-skill
|
|
@@ -59,14 +92,15 @@ perf-skill init ./skills/perf-skill
|
|
|
59
92
|
### Programmatic Usage
|
|
60
93
|
|
|
61
94
|
```typescript
|
|
62
|
-
import { analyze, diff } from "perf-skill
|
|
95
|
+
import { analyze, diff } from "perf-skill";
|
|
63
96
|
|
|
64
|
-
//
|
|
65
|
-
const result = await analyze("cpu.pb.gz"
|
|
66
|
-
console.log(result.markdown);
|
|
67
|
-
console.log(result.hotspots);
|
|
97
|
+
// Default: deterministic evidence extraction (no LLM, no network)
|
|
98
|
+
const result = await analyze("cpu.pb.gz");
|
|
99
|
+
console.log(result.markdown); // Structured Markdown report
|
|
100
|
+
console.log(result.hotspots); // Array of hotspot objects
|
|
101
|
+
console.log(result.raw.llmStatus); // "skipped" - no LLM was invoked
|
|
68
102
|
|
|
69
|
-
//
|
|
103
|
+
// Explicit AI analysis (requires API key)
|
|
70
104
|
const fullResult = await analyze("cpu.pb.gz", {
|
|
71
105
|
mode: "analyze",
|
|
72
106
|
context: {
|
|
@@ -76,8 +110,9 @@ const fullResult = await analyze("cpu.pb.gz", {
|
|
|
76
110
|
},
|
|
77
111
|
});
|
|
78
112
|
console.log(fullResult.recommendations);
|
|
113
|
+
console.log(fullResult.raw.llmStatus); // "success" or "failed"
|
|
79
114
|
|
|
80
|
-
// Compare two profiles
|
|
115
|
+
// Compare two profiles (always deterministic)
|
|
81
116
|
const diffResult = await diff("base.pb.gz", "current.pb.gz", {
|
|
82
117
|
normalize: "scale-to-base-total",
|
|
83
118
|
});
|
|
@@ -85,43 +120,27 @@ console.log(diffResult.regressions);
|
|
|
85
120
|
console.log(diffResult.improvements);
|
|
86
121
|
```
|
|
87
122
|
|
|
88
|
-
### HTTP API
|
|
89
|
-
|
|
90
|
-
```bash
|
|
91
|
-
# Start server
|
|
92
|
-
perf-skill server
|
|
93
|
-
|
|
94
|
-
# Start server with security overrides
|
|
95
|
-
perf-skill server --no-cors --no-helmet --rate-limit --rate-limit-max 120 --rate-limit-window-ms 60000
|
|
96
|
-
|
|
97
|
-
# Analyze profile
|
|
98
|
-
curl -X POST http://localhost:3000/v1/pprof/analyze \
|
|
99
|
-
-F "file=@cpu.pb.gz"
|
|
100
|
-
|
|
101
|
-
# Compare profiles
|
|
102
|
-
curl -X POST http://localhost:3000/v1/pprof/diff \
|
|
103
|
-
-F "base=@base.pb.gz" \
|
|
104
|
-
-F "current=@current.pb.gz"
|
|
105
|
-
```
|
|
106
|
-
|
|
107
123
|
## CLI Options
|
|
108
124
|
|
|
109
125
|
### `perf-skill analyze <profile.pb.gz>`
|
|
110
126
|
|
|
111
|
-
| Option | Description | Default
|
|
112
|
-
| ---------------------- | ------------------------------------------------ |
|
|
113
|
-
| `-f, --format` | Output format: `summary`, `detailed`, `adaptive` | `adaptive`
|
|
114
|
-
| `-t, --type` | Profile type: `cpu`, `heap`, `auto` | `auto`
|
|
115
|
-
| `-o, --output` | Output markdown file | stdout
|
|
116
|
-
| `-j, --json` | Output JSON results file | -
|
|
117
|
-
| `-m, --mode` | `convert-only` or `analyze` | `
|
|
118
|
-
|
|
|
119
|
-
|
|
|
120
|
-
| `--
|
|
121
|
-
| `--llm-
|
|
122
|
-
| `--
|
|
123
|
-
| `--
|
|
124
|
-
| `--
|
|
127
|
+
| Option | Description | Default |
|
|
128
|
+
| ---------------------- | ------------------------------------------------ | -------------- |
|
|
129
|
+
| `-f, --format` | Output format: `summary`, `detailed`, `adaptive` | `adaptive` |
|
|
130
|
+
| `-t, --type` | Profile type: `cpu`, `heap`, `auto` | `auto` |
|
|
131
|
+
| `-o, --output` | Output markdown file | stdout |
|
|
132
|
+
| `-j, --json` | Output JSON results file | - |
|
|
133
|
+
| `-m, --mode` | `convert-only` or `analyze` | `convert-only` |
|
|
134
|
+
| `--ai` | Enable AI-powered recommendations (requires key) | `false` |
|
|
135
|
+
| `-s, --source-dir` | Source directory for code context | - |
|
|
136
|
+
| `--max-hotspots` | Maximum hotspots to show | `10` |
|
|
137
|
+
| `--llm-provider` | LLM provider: `openai`, `anthropic`, etc. | `openai` |
|
|
138
|
+
| `--llm-model` | LLM model name | `gpt-5.2` |
|
|
139
|
+
| `--service` | Service name for context | - |
|
|
140
|
+
| `--scenario` | Scenario description | - |
|
|
141
|
+
| `--redact/--no-redact` | Redact sensitive information | `true` |
|
|
142
|
+
|
|
143
|
+
> **Note:** By default, `analyze` produces deterministic evidence output (no LLM). Use `--ai` to explicitly enable AI recommendations.
|
|
125
144
|
|
|
126
145
|
### `perf-skill run <entry> [entryArgs...]`
|
|
127
146
|
|
|
@@ -139,7 +158,8 @@ curl -X POST http://localhost:3000/v1/pprof/diff \
|
|
|
139
158
|
| `-t, --type` | Profile type: `cpu`, `heap`, `auto` | `auto` |
|
|
140
159
|
| `-o, --output` | Output markdown file | stdout |
|
|
141
160
|
| `-j, --json` | Output JSON results file | - |
|
|
142
|
-
| `-m, --mode` | `convert-only` or `analyze` | `
|
|
161
|
+
| `-m, --mode` | `convert-only` or `analyze` | `convert-only` |
|
|
162
|
+
| `--ai` | Enable AI-powered recommendations (requires key) | `false` |
|
|
143
163
|
| `-s, --source-dir` | Source directory for code context | - |
|
|
144
164
|
| `--max-hotspots` | Maximum hotspots to show | `10` |
|
|
145
165
|
| `--llm-provider` | LLM provider: `openai`, `anthropic`, etc. | `openai` |
|
|
@@ -150,6 +170,8 @@ curl -X POST http://localhost:3000/v1/pprof/diff \
|
|
|
150
170
|
|
|
151
171
|
When `--heap` is enabled and `--output` is omitted, `perf-skill` writes `cpu.md` and `heap.md` instead of printing to stdout.
|
|
152
172
|
|
|
173
|
+
> **Note:** By default, `run` produces deterministic evidence output (no LLM). Use `--ai` to explicitly enable AI recommendations.
|
|
174
|
+
|
|
153
175
|
### `perf-skill profile <entry> [entryArgs...]`
|
|
154
176
|
|
|
155
177
|
| Option | Description | Default |
|
|
@@ -173,14 +195,49 @@ When `--heap` is enabled and `--output` is omitted, `perf-skill` writes `cpu.md`
|
|
|
173
195
|
|
|
174
196
|
### `perf-skill init [target]`
|
|
175
197
|
|
|
176
|
-
Install the
|
|
198
|
+
Install the `SKILL.md` to a target directory or AI platform.
|
|
199
|
+
|
|
200
|
+
| Option | Description | Default |
|
|
201
|
+
| -------------- | -------------------------------------- | --------- |
|
|
202
|
+
| `-a, --ai` | Target AI platform (see below) | - |
|
|
203
|
+
| `-c, --cursor` | Install into Cursor (legacy) | `false` |
|
|
204
|
+
| `--scope` | Installation scope: `user` or `project`| `project` |
|
|
205
|
+
| `-f, --force` | Overwrite existing `SKILL.md` | `false` |
|
|
206
|
+
| `--dry-run` | Show destination without writing files | `false` |
|
|
207
|
+
| `--offline` | Use bundled assets only | `false` |
|
|
208
|
+
|
|
209
|
+
#### Supported Platforms
|
|
210
|
+
|
|
211
|
+
| Platform | Command | Install Location |
|
|
212
|
+
| ----------- | ------------------------------- | --------------------------------------- |
|
|
213
|
+
| Claude | `--ai claude` | `.claude/skills/perf-skill/SKILL.md` |
|
|
214
|
+
| Cursor | `--ai cursor` | `.cursor/skills/perf-skill/SKILL.md` |
|
|
215
|
+
| Windsurf | `--ai windsurf` | `.windsurf/skills/perf-skill/SKILL.md` |
|
|
216
|
+
| Copilot | `--ai copilot` | `.github/copilot/perf-skill.md` |
|
|
217
|
+
| Kiro | `--ai kiro` | `.kiro/skills/perf-skill/SKILL.md` |
|
|
218
|
+
| Codex | `--ai codex` | `.codex/skills/perf-skill/SKILL.md` |
|
|
219
|
+
| Qoder | `--ai qoder` | `.qodo/skills/perf-skill/SKILL.md` |
|
|
220
|
+
| Roo Code | `--ai roocode` | `.roo/skills/perf-skill/SKILL.md` |
|
|
221
|
+
| Gemini | `--ai gemini` | `.gemini/skills/perf-skill/SKILL.md` |
|
|
222
|
+
| Trae | `--ai trae` | `.trae/skills/perf-skill/SKILL.md` |
|
|
223
|
+
| OpenCode | `--ai opencode` | `.opencode/skills/perf-skill/SKILL.md` |
|
|
224
|
+
| Continue | `--ai continue` | `.continue/skills/perf-skill/SKILL.md` |
|
|
225
|
+
| CodeBuddy | `--ai codebuddy` | `.codebuddy/skills/perf-skill/SKILL.md` |
|
|
226
|
+
| **All** | `--ai all` | Installs to all platforms |
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
# Install for Claude
|
|
230
|
+
npx perf-skill init --ai claude
|
|
231
|
+
|
|
232
|
+
# Install for Cursor (project scope)
|
|
233
|
+
npx perf-skill init --ai cursor --scope project
|
|
177
234
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
235
|
+
# Install for all supported platforms
|
|
236
|
+
npx perf-skill init --ai all
|
|
237
|
+
|
|
238
|
+
# Preview installation without writing
|
|
239
|
+
npx perf-skill init --ai cursor --dry-run
|
|
240
|
+
```
|
|
184
241
|
|
|
185
242
|
## Output Formats
|
|
186
243
|
|
|
@@ -209,9 +266,9 @@ Full context with call trees and source code.
|
|
|
209
266
|
|
|
210
267
|
Summary with drill-down sections and anchor links for navigation.
|
|
211
268
|
|
|
212
|
-
## AI Recommendations
|
|
269
|
+
## AI Recommendations (Optional)
|
|
213
270
|
|
|
214
|
-
When using `--mode analyze
|
|
271
|
+
When using `--ai` (or `--mode analyze`), the tool invokes an LLM to generate structured recommendations:
|
|
215
272
|
|
|
216
273
|
```typescript
|
|
217
274
|
interface Recommendation {
|
|
@@ -226,6 +283,8 @@ interface Recommendation {
|
|
|
226
283
|
|
|
227
284
|
All recommendations must reference evidence from the profile (function names, percentages, locations).
|
|
228
285
|
|
|
286
|
+
> **Note:** For Skill/Agent usage, it is recommended to let the host agent (Claude, Cursor, etc.) generate recommendations based on the deterministic evidence output. This keeps the tool LLM-agnostic and allows the agent to apply its own reasoning.
|
|
287
|
+
|
|
229
288
|
## Profile Diff
|
|
230
289
|
|
|
231
290
|
Compare two profiles to identify performance regressions:
|
|
@@ -288,12 +347,6 @@ writeFileSync("heap.pb.gz", gzipSync(heapProfile.encode()));
|
|
|
288
347
|
| `LLM_RETRY_DELAY_MS` | Base retry delay in ms |
|
|
289
348
|
| `LOG_LEVEL` | Logging level: `debug`, `info`, `warn`, `error` |
|
|
290
349
|
| `LOG_FORMAT` | Log format: `text`, `json` |
|
|
291
|
-
| `CORS_ENABLED` | Enable CORS (`true`/`false`) |
|
|
292
|
-
| `CORS_ORIGIN` | CORS origin(s), comma-separated or `*` |
|
|
293
|
-
| `HELMET_ENABLED` | Enable Helmet (`true`/`false`) |
|
|
294
|
-
| `RATE_LIMIT_ENABLED` | Enable rate limiting (`true`/`false`) |
|
|
295
|
-
| `RATE_LIMIT_MAX` | Rate limit max requests per window |
|
|
296
|
-
| `RATE_LIMIT_WINDOW_MS` | Rate limit window size in ms |
|
|
297
350
|
|
|
298
351
|
Example:
|
|
299
352
|
|
|
@@ -331,47 +384,13 @@ By default, the tool redacts:
|
|
|
331
384
|
|
|
332
385
|
Disable with `--no-redact` or `redact: false`.
|
|
333
386
|
|
|
334
|
-
### Server Mode
|
|
335
|
-
|
|
336
|
-
In HTTP server mode:
|
|
337
|
-
|
|
338
|
-
- Source code inclusion is disabled by default
|
|
339
|
-
- File size limits are enforced
|
|
340
|
-
- Only `.pb.gz` files are accepted
|
|
341
|
-
|
|
342
|
-
Security defaults (configurable via env or server options):
|
|
343
|
-
|
|
344
|
-
- CORS enabled (set `CORS_ENABLED=false` to disable)
|
|
345
|
-
- Helmet enabled (set `HELMET_ENABLED=false` to disable)
|
|
346
|
-
- Rate limiting enabled (default 60 req/min, set `RATE_LIMIT_ENABLED=false` or `RATE_LIMIT_MAX=0` to disable)
|
|
347
|
-
|
|
348
|
-
Server CLI flags (override env defaults):
|
|
349
|
-
|
|
350
|
-
- `--cors/--no-cors`
|
|
351
|
-
- `--cors-origin <origin>` (comma-separated or `*`)
|
|
352
|
-
- `--helmet/--no-helmet`
|
|
353
|
-
- `--rate-limit/--no-rate-limit`
|
|
354
|
-
- `--rate-limit-max <n>`
|
|
355
|
-
- `--rate-limit-window-ms <ms>`
|
|
356
|
-
|
|
357
|
-
ServerOptions (programmatic):
|
|
358
|
-
|
|
359
|
-
```typescript
|
|
360
|
-
const server = await createServer({
|
|
361
|
-
enableCors: true,
|
|
362
|
-
corsOrigin: "https://example.com",
|
|
363
|
-
enableHelmet: true,
|
|
364
|
-
enableRateLimit: true,
|
|
365
|
-
rateLimitMax: 60,
|
|
366
|
-
rateLimitWindowMs: 60_000,
|
|
367
|
-
});
|
|
368
|
-
```
|
|
369
|
-
|
|
370
387
|
## Requirements
|
|
371
388
|
|
|
372
389
|
- Node.js >= 22.6.0
|
|
373
|
-
- For AI analysis: API key for OpenAI, Anthropic, or compatible provider
|
|
374
390
|
- CPU profiling uses bundled `@datadog/pprof` (native module) on supported platforms
|
|
391
|
+
- **Optional:** For AI recommendations (`--ai`), an API key for OpenAI, Anthropic, or compatible provider
|
|
392
|
+
|
|
393
|
+
> **No API key required for default usage.** The tool produces complete, actionable evidence without any external dependencies.
|
|
375
394
|
|
|
376
395
|
## API Reference
|
|
377
396
|
|
package/dist/cli/init.d.ts
CHANGED
|
@@ -1,20 +1,32 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* CLI init command helpers - install SKILL.md into
|
|
2
|
+
* CLI init command helpers - install SKILL.md into target directories for multiple AI platforms
|
|
3
3
|
*/
|
|
4
|
+
import { type AIPlatform } from "./platforms.js";
|
|
4
5
|
export type CursorScope = "user" | "project";
|
|
5
6
|
export interface InitOptions {
|
|
6
7
|
target?: string;
|
|
7
8
|
cursor?: boolean;
|
|
9
|
+
platform?: AIPlatform;
|
|
8
10
|
scope?: CursorScope;
|
|
9
11
|
force?: boolean;
|
|
10
12
|
dryRun?: boolean;
|
|
13
|
+
offline?: boolean;
|
|
11
14
|
}
|
|
12
15
|
export interface InstallTarget {
|
|
13
|
-
|
|
16
|
+
platform: string;
|
|
17
|
+
layout: "cursor" | "flat" | "file" | "platform";
|
|
14
18
|
rootDir: string;
|
|
15
19
|
destDir: string;
|
|
16
20
|
destFile: string;
|
|
17
21
|
}
|
|
22
|
+
export interface InitResult {
|
|
23
|
+
success: boolean;
|
|
24
|
+
targets: InstallTarget[];
|
|
25
|
+
errors: Array<{
|
|
26
|
+
platform: string;
|
|
27
|
+
error: string;
|
|
28
|
+
}>;
|
|
29
|
+
}
|
|
18
30
|
export declare function parseSkillFrontmatterName(markdown: string): string | null;
|
|
19
31
|
export declare function isReservedCursorDir(targetPath: string): boolean;
|
|
20
32
|
export declare function resolveInstallTarget(options: {
|
|
@@ -25,5 +37,9 @@ export declare function resolveInstallTarget(options: {
|
|
|
25
37
|
cwd: string;
|
|
26
38
|
homeDir: string;
|
|
27
39
|
}): InstallTarget;
|
|
28
|
-
|
|
40
|
+
/**
|
|
41
|
+
* Run init command - supports multiple platforms
|
|
42
|
+
*/
|
|
43
|
+
export declare function runInit(options: InitOptions): Promise<InitResult>;
|
|
44
|
+
export { AI_PLATFORMS, type AIPlatform } from "./platforms.js";
|
|
29
45
|
//# sourceMappingURL=init.d.ts.map
|
package/dist/cli/init.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/cli/init.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/cli/init.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,EACL,KAAK,UAAU,EAKhB,MAAM,gBAAgB,CAAC;AAGxB,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,SAAS,CAAC;AAE7C,MAAM,WAAW,WAAW;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,UAAU,CAAC;IACtB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU,CAAC;IAChD,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,MAAM,EAAE,KAAK,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACpD;AAaD,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAczE;AAUD,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAE/D;AASD,wBAAgB,oBAAoB,CAAC,OAAO,EAAE;IAC5C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;CACjB,GAAG,aAAa,CAuDhB;AA4ED;;GAEG;AACH,wBAAsB,OAAO,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CA4FvE;AAGD,OAAO,EAAE,YAAY,EAAE,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC"}
|