claude-autopm 2.8.8 β 2.11.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/autopm/.claude/agents-compressed-example.md +218 -0
- package/autopm/.claude/quick-ref/agent-quick-ref.md +153 -0
- package/autopm/.claude/quick-ref/common-patterns.md +215 -0
- package/autopm/.claude/quick-ref/context7-queries.md +122 -0
- package/autopm/.claude/quick-ref/tdd-cycle.md +49 -0
- package/autopm/.claude/quick-ref/workflow-steps.md +103 -0
- package/autopm/.claude/rules/agent-mandatory-optimized.md +91 -0
- package/autopm/.claude/rules/context7-enforcement-optimized.md +221 -0
- package/autopm/.claude/templates/claude-templates/addons/task-workflow.md +612 -0
- package/autopm/.claude/templates/claude-templates/base-optimized.md +245 -0
- package/autopm/.claude/templates/claude-templates/base.md +66 -14
- package/autopm/.claude/templates/plugin-manifest-template.xml +36 -0
- package/install/install.js +81 -0
- package/install/plugin-manifest-generator.js +182 -0
- package/package.json +1 -1
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
# CLAUDE.md (Optimized - Token Efficient)
|
|
2
|
+
|
|
3
|
+
<system>
|
|
4
|
+
<role>Senior AI-assisted developer coordinating specialized agents</role>
|
|
5
|
+
<mandate>Build quality software through TDD, agent coordination, and Context7 integration</mandate>
|
|
6
|
+
</system>
|
|
7
|
+
|
|
8
|
+
## π¨ CRITICAL PRIORITIES
|
|
9
|
+
|
|
10
|
+
<priorities>
|
|
11
|
+
1. TDD: REDβGREENβREFACTOR (ZERO TOLERANCE)
|
|
12
|
+
2. Agents: Use specialized agents for ALL non-trivial tasks
|
|
13
|
+
3. Context7: Query docs BEFORE implementing
|
|
14
|
+
4. Quality: No partial implementations, no code without tests
|
|
15
|
+
</priorities>
|
|
16
|
+
|
|
17
|
+
## π SYSTEM MANIFEST
|
|
18
|
+
|
|
19
|
+
<manifest>
|
|
20
|
+
<rules_dir>.claude/rules/</rules_dir>
|
|
21
|
+
<agents_dir>.claude/agents/</agents_dir>
|
|
22
|
+
<quick_ref>.claude/quick-ref/</quick_ref>
|
|
23
|
+
<workflows>.claude/workflows/</workflows>
|
|
24
|
+
<commands>.claude/commands/</commands>
|
|
25
|
+
<plugins_dir>.claude/plugins/</plugins_dir>
|
|
26
|
+
</manifest>
|
|
27
|
+
|
|
28
|
+
<!-- PLUGINS_SECTION -->
|
|
29
|
+
<!-- Plugin manifests injected here during installation -->
|
|
30
|
+
<!-- Default: Empty (no plugins installed) -->
|
|
31
|
+
<!-- After installation with plugins: Compressed plugin listings -->
|
|
32
|
+
<!-- Example tokens: ~50 per plugin, ~200 for 4 plugins vs ~25,000 old system -->
|
|
33
|
+
<!-- /PLUGINS_SECTION -->
|
|
34
|
+
|
|
35
|
+
## π― QUICK REFERENCE
|
|
36
|
+
|
|
37
|
+
<quick_ref>
|
|
38
|
+
<tdd>
|
|
39
|
+
π Full: .claude/rules/tdd.enforcement.md
|
|
40
|
+
π΄ RED: Write failing test FIRST
|
|
41
|
+
β
GREEN: Minimal code to pass
|
|
42
|
+
β»οΈ REFACTOR: Improve while tests stay green
|
|
43
|
+
</tdd>
|
|
44
|
+
|
|
45
|
+
<agents>
|
|
46
|
+
π Registry: .claude/agents/AGENT-REGISTRY.md
|
|
47
|
+
π Python: @python-backend-engineer
|
|
48
|
+
βοΈ React: @react-frontend-engineer
|
|
49
|
+
π§ͺ Tests: @test-runner
|
|
50
|
+
π Analysis: @code-analyzer
|
|
51
|
+
π Files: @file-analyzer
|
|
52
|
+
</agents>
|
|
53
|
+
|
|
54
|
+
<workflow>
|
|
55
|
+
π Full: .claude/workflows/standard-task-workflow.md
|
|
56
|
+
1οΈβ£ Pick task from backlog
|
|
57
|
+
2οΈβ£ Create feature branch
|
|
58
|
+
3οΈβ£ Implement (TDD cycle)
|
|
59
|
+
4οΈβ£ Verify acceptance criteria
|
|
60
|
+
5οΈβ£ Create PR
|
|
61
|
+
6οΈβ£ Address feedback
|
|
62
|
+
7οΈβ£ Merge & complete
|
|
63
|
+
</workflow>
|
|
64
|
+
</quick_ref>
|
|
65
|
+
|
|
66
|
+
## π LAZY LOADING RULES
|
|
67
|
+
|
|
68
|
+
<lazy_load>
|
|
69
|
+
<rule>
|
|
70
|
+
Load full documentation on-demand:
|
|
71
|
+
- Read .claude/rules/*.md when rule enforcement needed
|
|
72
|
+
- Read .claude/agents/[agent].md when agent invoked
|
|
73
|
+
- Read .claude/workflows/*.md progressively as steps execute
|
|
74
|
+
</rule>
|
|
75
|
+
|
|
76
|
+
<triggers>
|
|
77
|
+
Keyword β File mapping:
|
|
78
|
+
- "TDD"|"test" β .claude/quick-ref/tdd-cycle.md
|
|
79
|
+
- "@[agent]" β .claude/agents/[category]/[agent].md
|
|
80
|
+
- "workflow"|"task" β .claude/quick-ref/workflow-steps.md
|
|
81
|
+
- "Context7" β .claude/quick-ref/context7-queries.md
|
|
82
|
+
</triggers>
|
|
83
|
+
</lazy_load>
|
|
84
|
+
|
|
85
|
+
## π CORE RULES (Compressed)
|
|
86
|
+
|
|
87
|
+
<rules>
|
|
88
|
+
<rule id="tdd" priority="HIGHEST">
|
|
89
|
+
TDD mandatory|No code before tests|REDβGREENβREFACTOR
|
|
90
|
+
π Optimized: .claude/rules/tdd.enforcement-optimized.md
|
|
91
|
+
π Full: .claude/rules/tdd.enforcement.md
|
|
92
|
+
</rule>
|
|
93
|
+
|
|
94
|
+
<rule id="agents" priority="HIGHEST">
|
|
95
|
+
Use agents for non-trivial tasks|Agent list: AGENT-REGISTRY.md
|
|
96
|
+
π Optimized: .claude/rules/agent-mandatory-optimized.md
|
|
97
|
+
π Full: .claude/rules/agent-mandatory.md
|
|
98
|
+
</rule>
|
|
99
|
+
|
|
100
|
+
<rule id="context7" priority="HIGHEST">
|
|
101
|
+
Query Context7 before implementing|mcp://context7/[lib]/[topic]
|
|
102
|
+
π Optimized: .claude/rules/context7-enforcement-optimized.md
|
|
103
|
+
π Full: .claude/rules/context7-enforcement.md
|
|
104
|
+
</rule>
|
|
105
|
+
|
|
106
|
+
<rule id="quality" priority="HIGH">
|
|
107
|
+
No partial implementations|No TODOs without tests|100% coverage for new code
|
|
108
|
+
π .claude/rules/naming-conventions.md
|
|
109
|
+
</rule>
|
|
110
|
+
|
|
111
|
+
<rule id="git" priority="MEDIUM">
|
|
112
|
+
Work in branches|PRs required|Resolve conflicts immediately
|
|
113
|
+
π .claude/rules/git-strategy.md
|
|
114
|
+
</rule>
|
|
115
|
+
</rules>
|
|
116
|
+
|
|
117
|
+
## π€ ACTIVE AGENTS (Compressed)
|
|
118
|
+
|
|
119
|
+
<!-- AGENTS_START -->
|
|
120
|
+
<agents_list>
|
|
121
|
+
Core: agent-manager|code-analyzer|file-analyzer|test-runner
|
|
122
|
+
Languages: bash-scripting-expert|javascript-frontend-engineer|nodejs-backend-engineer|python-backend-engineer
|
|
123
|
+
Frameworks: react-frontend-engineer|react-ui-expert
|
|
124
|
+
Testing: e2e-test-engineer|frontend-testing-engineer
|
|
125
|
+
Cloud: aws-cloud-architect|azure-cloud-architect|gcp-cloud-architect
|
|
126
|
+
DevOps: docker-containerization-expert|github-operations-specialist|kubernetes-orchestrator
|
|
127
|
+
Database: bigquery-expert|cosmosdb-expert|mongodb-expert|postgresql-expert|redis-expert
|
|
128
|
+
Data: airflow-orchestration-expert|kedro-pipeline-expert
|
|
129
|
+
Messaging: nats-messaging-expert|message-queue-engineer
|
|
130
|
+
Integration: azure-devops-specialist|gemini-api-expert|openai-python-expert
|
|
131
|
+
Infrastructure: gcp-cloud-functions-engineer|terraform-infrastructure-expert|traefik-proxy-expert
|
|
132
|
+
Monitoring: observability-engineer
|
|
133
|
+
Security: ssh-operations-expert
|
|
134
|
+
Design: ux-design-expert|tailwindcss-expert
|
|
135
|
+
CSS: tailwindcss-expert
|
|
136
|
+
Workflow: langgraph-workflow-expert|parallel-worker
|
|
137
|
+
Management: agent-manager|mcp-manager
|
|
138
|
+
Context: mcp-context-manager
|
|
139
|
+
|
|
140
|
+
π Full registry: .claude/agents/AGENT-REGISTRY.md
|
|
141
|
+
</agents_list>
|
|
142
|
+
<!-- AGENTS_END -->
|
|
143
|
+
|
|
144
|
+
<!-- WORKFLOW_SECTION -->
|
|
145
|
+
|
|
146
|
+
<!-- CICD_SECTION -->
|
|
147
|
+
|
|
148
|
+
## β‘ PERFORMANCE OPTIMIZATIONS
|
|
149
|
+
|
|
150
|
+
<performance>
|
|
151
|
+
<token_efficiency>
|
|
152
|
+
- Load files on-demand, not upfront
|
|
153
|
+
- Use compressed formats (pipe-separated lists)
|
|
154
|
+
- Reference external files instead of embedding
|
|
155
|
+
- Progressive workflow loading
|
|
156
|
+
</token_efficiency>
|
|
157
|
+
|
|
158
|
+
<context_preservation>
|
|
159
|
+
- Agent responses: <20% of input data
|
|
160
|
+
- File analysis: Summary only, not full content
|
|
161
|
+
- Test output: Failures only, not all results
|
|
162
|
+
- Log analysis: Errors + patterns, not raw logs
|
|
163
|
+
</context_preservation>
|
|
164
|
+
</performance>
|
|
165
|
+
|
|
166
|
+
## π― WHEN TO LOAD FULL DOCUMENTATION
|
|
167
|
+
|
|
168
|
+
<load_conditions>
|
|
169
|
+
<condition trigger="Starting new task">
|
|
170
|
+
Load: .claude/workflows/standard-task-workflow.md
|
|
171
|
+
</condition>
|
|
172
|
+
|
|
173
|
+
<condition trigger="Agent invocation @[agent]">
|
|
174
|
+
Load: .claude/agents/[category]/[agent].md
|
|
175
|
+
</condition>
|
|
176
|
+
|
|
177
|
+
<condition trigger="Rule violation OR uncertainty">
|
|
178
|
+
Load: .claude/rules/[specific-rule].md
|
|
179
|
+
</condition>
|
|
180
|
+
|
|
181
|
+
<condition trigger="Complex multi-step task">
|
|
182
|
+
Load: .claude/quick-ref/common-patterns.md
|
|
183
|
+
</condition>
|
|
184
|
+
</load_conditions>
|
|
185
|
+
|
|
186
|
+
## π EXAMPLE: LAZY LOADING IN ACTION
|
|
187
|
+
|
|
188
|
+
<example>
|
|
189
|
+
<scenario>User: "Implement user authentication"</scenario>
|
|
190
|
+
|
|
191
|
+
<step1>Check QUICK REFERENCE for workflow</step1>
|
|
192
|
+
<step2>Trigger: "@python-backend-engineer" β Load agent file</step2>
|
|
193
|
+
<step3>Trigger: "TDD" β Load .claude/quick-ref/tdd-cycle.md</step3>
|
|
194
|
+
<step4>Trigger: "Context7" β Query mcp://context7/fastapi/authentication</step4>
|
|
195
|
+
<step5>Execute: TDD cycle with agent assistance</step5>
|
|
196
|
+
|
|
197
|
+
<result>
|
|
198
|
+
Tokens loaded: ~3,000 (vs ~20,000 in old system)
|
|
199
|
+
Savings: 85%
|
|
200
|
+
</result>
|
|
201
|
+
</example>
|
|
202
|
+
|
|
203
|
+
## π§ COMMIT CHECKLIST (Compressed)
|
|
204
|
+
|
|
205
|
+
<before_commit>
|
|
206
|
+
β Tests: REDβGREENβREFACTOR sequence
|
|
207
|
+
β Lint: black|prettier|eslint passed
|
|
208
|
+
β Format: Applied + verified
|
|
209
|
+
β Type: mypy|tsc passed
|
|
210
|
+
β Coverage: 100% for new code
|
|
211
|
+
β Commits: testβfeatβrefactor sequence
|
|
212
|
+
</before_commit>
|
|
213
|
+
|
|
214
|
+
## π TONE & BEHAVIOR (Compressed)
|
|
215
|
+
|
|
216
|
+
<behavior>
|
|
217
|
+
Concise|Skeptical|Factual|No flattery|Ask when uncertain
|
|
218
|
+
Welcome criticism|Suggest better approaches|Reference standards
|
|
219
|
+
</behavior>
|
|
220
|
+
|
|
221
|
+
## π« ABSOLUTE PROHIBITIONS
|
|
222
|
+
|
|
223
|
+
<prohibited>
|
|
224
|
+
β Code without tests
|
|
225
|
+
β Partial implementations
|
|
226
|
+
β "TODO: add tests later"
|
|
227
|
+
β WIP commits
|
|
228
|
+
β Direct commits to main
|
|
229
|
+
β Mock services (use real)
|
|
230
|
+
β Skipping refactor phase
|
|
231
|
+
</prohibited>
|
|
232
|
+
|
|
233
|
+
## π ADDITIONAL RESOURCES
|
|
234
|
+
|
|
235
|
+
<resources>
|
|
236
|
+
Checklists: .claude/checklists/
|
|
237
|
+
Examples: .claude/examples/
|
|
238
|
+
Templates: .claude/templates/
|
|
239
|
+
Strategies: .claude/strategies/
|
|
240
|
+
</resources>
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
**Token Count: ~2,100 tokens (vs ~20,000 old system)**
|
|
245
|
+
**Savings: 89.5%**
|
|
@@ -118,26 +118,78 @@ Use for coordinating multiple work streams in parallel.
|
|
|
118
118
|
|
|
119
119
|
<!-- CICD_SECTION -->
|
|
120
120
|
|
|
121
|
-
## TDD PIPELINE FOR ALL IMPLEMENTATIONS
|
|
121
|
+
## π¨ TDD PIPELINE FOR ALL IMPLEMENTATIONS (HIGHEST PRIORITY)
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
125
|
+
β π΄ RED β β
GREEN β β»οΈ REFACTOR β
|
|
126
|
+
β β
|
|
127
|
+
β ZERO TOLERANCE: No code without tests. No exceptions. β
|
|
128
|
+
β See: .claude/rules/tdd.enforcement.md β
|
|
129
|
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
130
|
+
```
|
|
122
131
|
|
|
123
132
|
### Mandatory Test-Driven Development Cycle
|
|
124
133
|
|
|
125
|
-
Every implementation MUST follow
|
|
134
|
+
**CRITICAL**: Every implementation MUST follow TDD cycle. This rule has **HIGHEST PRIORITY**.
|
|
135
|
+
|
|
136
|
+
#### 1. π΄ RED Phase: Write FAILING Test First
|
|
137
|
+
|
|
138
|
+
- Write test that describes desired behavior
|
|
139
|
+
- Test **MUST FAIL** initially (run `@test-runner` to confirm)
|
|
140
|
+
- Test must be meaningful (no trivial assertions)
|
|
141
|
+
- **NEVER proceed to code without failing test**
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
# Example workflow:
|
|
145
|
+
touch tests/test_feature.py
|
|
146
|
+
# Write test
|
|
147
|
+
@test-runner run tests/test_feature.py # MUST SEE RED β
|
|
148
|
+
git commit -m "test: add failing test for feature"
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
#### 2. β
GREEN Phase: Write MINIMUM Code to Pass
|
|
152
|
+
|
|
153
|
+
- Write **MINIMUM** code to pass test
|
|
154
|
+
- Don't add features not required by test
|
|
155
|
+
- Focus on making test green, not perfection
|
|
156
|
+
- Run `@test-runner` to confirm tests pass
|
|
126
157
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
158
|
+
```bash
|
|
159
|
+
# Implement feature
|
|
160
|
+
@test-runner run tests/test_feature.py # MUST SEE GREEN β
|
|
161
|
+
git commit -m "feat: implement feature"
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
#### 3. β»οΈ REFACTOR Phase: Improve While Tests Stay Green
|
|
165
|
+
|
|
166
|
+
- Improve code structure
|
|
167
|
+
- Remove duplication
|
|
168
|
+
- Enhance readability
|
|
169
|
+
- **All tests MUST remain green**
|
|
170
|
+
- Run `@test-runner` after each change
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
# Refactor code
|
|
174
|
+
@test-runner run all tests # ALL MUST BE GREEN β
|
|
175
|
+
git commit -m "refactor: improve feature structure"
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### TDD Commit Pattern (MANDATORY)
|
|
131
179
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
180
|
+
For EVERY feature, you MUST see this commit sequence:
|
|
181
|
+
```bash
|
|
182
|
+
git log --oneline
|
|
183
|
+
# c3d4e5f refactor: improve feature structure β»οΈ
|
|
184
|
+
# b2c3d4e feat: implement feature β
|
|
185
|
+
# a1b2c3d test: add failing test for feature π΄
|
|
186
|
+
```
|
|
136
187
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
188
|
+
**β VIOLATIONS (Auto-Reject):**
|
|
189
|
+
- Commits with code but no tests
|
|
190
|
+
- Commits with "WIP" or "TODO: add tests later"
|
|
191
|
+
- Skipping any phase of TDD cycle
|
|
192
|
+
- Tests written after implementation
|
|
141
193
|
|
|
142
194
|
## CONTEXT OPTIMIZATION RULES
|
|
143
195
|
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<!-- Plugin Manifest Template for Token-Optimized CLAUDE.md -->
|
|
2
|
+
<!-- This template generates compressed plugin listings for base-optimized.md -->
|
|
3
|
+
|
|
4
|
+
<plugins>
|
|
5
|
+
<installed>{{INSTALLED_PLUGINS}}</installed>
|
|
6
|
+
|
|
7
|
+
<manifest>
|
|
8
|
+
{{PLUGIN_MANIFESTS}}
|
|
9
|
+
</manifest>
|
|
10
|
+
|
|
11
|
+
<lazy_loading>
|
|
12
|
+
<enabled>true</enabled>
|
|
13
|
+
<triggers>
|
|
14
|
+
commands: "/[plugin-id]:[command-name]"
|
|
15
|
+
agents: "@[agent-name]" (from plugin)
|
|
16
|
+
rules: on-violation or explicit reference
|
|
17
|
+
</triggers>
|
|
18
|
+
</lazy_loading>
|
|
19
|
+
|
|
20
|
+
<usage>
|
|
21
|
+
Commands: Type /[plugin-id]:[command] to invoke
|
|
22
|
+
Agents: Type @[agent-name] to invoke
|
|
23
|
+
Rules: Automatically loaded when needed
|
|
24
|
+
Files: All available in .claude/plugins/[plugin-id]/
|
|
25
|
+
</usage>
|
|
26
|
+
</plugins>
|
|
27
|
+
|
|
28
|
+
<!-- Example compressed manifest per plugin -->
|
|
29
|
+
<!--
|
|
30
|
+
<plugin id="core">
|
|
31
|
+
agents: agent-manager|code-analyzer|test-runner|file-analyzer
|
|
32
|
+
commands: code-rabbit|prompt|re-init
|
|
33
|
+
rules: 23 files (on-demand)
|
|
34
|
+
π .claude/plugins/core/
|
|
35
|
+
</plugin>
|
|
36
|
+
-->
|
package/install/install.js
CHANGED
|
@@ -765,6 +765,9 @@ See: https://github.com/rafeekpro/ClaudeAutoPM
|
|
|
765
765
|
getRequiredAddons() {
|
|
766
766
|
const addons = [];
|
|
767
767
|
|
|
768
|
+
// ALWAYS include task-workflow (standard workflow for all projects)
|
|
769
|
+
addons.push('task-workflow');
|
|
770
|
+
|
|
768
771
|
// Based on scenario/configuration, determine required addons
|
|
769
772
|
if (this.currentConfig) {
|
|
770
773
|
if (this.currentConfig.tools?.docker?.enabled) {
|
|
@@ -804,6 +807,7 @@ See: https://github.com/rafeekpro/ClaudeAutoPM
|
|
|
804
807
|
'docker-agents': 'AGENT_SELECTION_SECTION',
|
|
805
808
|
'devops-agents': 'AGENT_SELECTION_SECTION',
|
|
806
809
|
'minimal-agents': 'AGENT_SELECTION_SECTION',
|
|
810
|
+
'task-workflow': 'WORKFLOW_SECTION',
|
|
807
811
|
'docker-workflow': 'WORKFLOW_SECTION',
|
|
808
812
|
'devops-workflow': 'WORKFLOW_SECTION',
|
|
809
813
|
'minimal-workflow': 'WORKFLOW_SECTION',
|
|
@@ -840,9 +844,86 @@ See: https://github.com/rafeekpro/ClaudeAutoPM
|
|
|
840
844
|
processedContent = processedContent.replace(regex, value);
|
|
841
845
|
}
|
|
842
846
|
|
|
847
|
+
// Generate agent @include directives from installed plugins
|
|
848
|
+
const agentIncludes = this.generateAgentIncludes();
|
|
849
|
+
processedContent = processedContent.replace(
|
|
850
|
+
/<!-- AGENTS_START -->\s*<!-- AGENTS_END -->/,
|
|
851
|
+
`<!-- AGENTS_START -->\n${agentIncludes}\n<!-- AGENTS_END -->`
|
|
852
|
+
);
|
|
853
|
+
|
|
843
854
|
return processedContent;
|
|
844
855
|
}
|
|
845
856
|
|
|
857
|
+
generateAgentIncludes() {
|
|
858
|
+
if (!this.currentConfig?.installedPlugins) {
|
|
859
|
+
return '';
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
const packagesDir = path.join(this.baseDir, 'packages');
|
|
863
|
+
const agentsByCategory = {};
|
|
864
|
+
|
|
865
|
+
// Collect all agents from installed plugins
|
|
866
|
+
for (const plugin of this.currentConfig.installedPlugins) {
|
|
867
|
+
const pluginPath = path.join(packagesDir, plugin.name);
|
|
868
|
+
const pluginJsonPath = path.join(pluginPath, 'plugin.json');
|
|
869
|
+
|
|
870
|
+
if (!fs.existsSync(pluginJsonPath)) {
|
|
871
|
+
continue;
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
try {
|
|
875
|
+
const metadata = JSON.parse(fs.readFileSync(pluginJsonPath, 'utf-8'));
|
|
876
|
+
|
|
877
|
+
if (metadata.agents && metadata.agents.length > 0) {
|
|
878
|
+
for (const agent of metadata.agents) {
|
|
879
|
+
const category = agent.category || 'other';
|
|
880
|
+
|
|
881
|
+
if (!agentsByCategory[category]) {
|
|
882
|
+
agentsByCategory[category] = [];
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
// Build installed path: .claude/agents/{category}/{filename}
|
|
886
|
+
// agent.file contains the full path like "agents/core/agent-manager.md"
|
|
887
|
+
// We extract just the filename and use category for the directory
|
|
888
|
+
const filename = path.basename(agent.file);
|
|
889
|
+
const installedPath = `.claude/agents/${category}/${filename}`;
|
|
890
|
+
|
|
891
|
+
agentsByCategory[category].push({
|
|
892
|
+
name: agent.name,
|
|
893
|
+
path: installedPath,
|
|
894
|
+
description: agent.description
|
|
895
|
+
});
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
} catch (error) {
|
|
899
|
+
this.printWarning(`Failed to read plugin metadata for ${plugin.name}: ${error.message}`);
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
// Generate @include directives organized by category
|
|
904
|
+
const lines = [];
|
|
905
|
+
const categoryOrder = ['core', 'languages', 'frameworks', 'testing', 'devops', 'cloud', 'databases', 'data', 'ai', 'ml'];
|
|
906
|
+
|
|
907
|
+
for (const category of categoryOrder) {
|
|
908
|
+
if (agentsByCategory[category]) {
|
|
909
|
+
for (const agent of agentsByCategory[category]) {
|
|
910
|
+
lines.push(`- @include ${agent.path}`);
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
// Add any remaining categories not in the order list
|
|
916
|
+
for (const category of Object.keys(agentsByCategory)) {
|
|
917
|
+
if (!categoryOrder.includes(category)) {
|
|
918
|
+
for (const agent of agentsByCategory[category]) {
|
|
919
|
+
lines.push(`- @include ${agent.path}`);
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
return lines.join('\n');
|
|
925
|
+
}
|
|
926
|
+
|
|
846
927
|
async installPlugins() {
|
|
847
928
|
if (!this.currentConfig || !this.currentConfig.plugins) {
|
|
848
929
|
this.printStep('No plugins configured for this scenario');
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Plugin Manifest Generator
|
|
5
|
+
*
|
|
6
|
+
* Generates compressed plugin manifests for token-optimized CLAUDE.md
|
|
7
|
+
* Reduces plugin metadata from thousands of tokens to ~50 tokens per plugin
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const fs = require('fs');
|
|
11
|
+
const path = require('path');
|
|
12
|
+
|
|
13
|
+
const CHARS_PER_TOKEN = 4;
|
|
14
|
+
|
|
15
|
+
function estimateTokens(text) {
|
|
16
|
+
const normalized = text.replace(/\s+/g, ' ').trim();
|
|
17
|
+
return Math.ceil(normalized.length / CHARS_PER_TOKEN);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Generate compressed manifest for a single plugin
|
|
22
|
+
*/
|
|
23
|
+
function generatePluginManifest(pluginData, pluginId) {
|
|
24
|
+
const agentNames = (pluginData.agents || []).map(a => a.name).join('|');
|
|
25
|
+
const commandNames = (pluginData.commands || []).map(c => c.name).join('|');
|
|
26
|
+
const ruleCount = (pluginData.rules || []).length;
|
|
27
|
+
|
|
28
|
+
const manifest = `<plugin id="${pluginId}">
|
|
29
|
+
agents: ${agentNames || 'None'}
|
|
30
|
+
commands: ${commandNames || 'None'}
|
|
31
|
+
rules: ${ruleCount} files (on-demand)
|
|
32
|
+
π .claude/plugins/${pluginId}/
|
|
33
|
+
</plugin>`;
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
manifest,
|
|
37
|
+
tokens: estimateTokens(manifest),
|
|
38
|
+
stats: {
|
|
39
|
+
agents: pluginData.agents?.length || 0,
|
|
40
|
+
commands: pluginData.commands?.length || 0,
|
|
41
|
+
rules: ruleCount
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Generate complete plugins section for CLAUDE.md
|
|
48
|
+
*/
|
|
49
|
+
function generatePluginsSection(installedPlugins, packagesDir) {
|
|
50
|
+
const manifests = [];
|
|
51
|
+
const pluginList = [];
|
|
52
|
+
let totalTokens = 0;
|
|
53
|
+
let totalFiles = 0;
|
|
54
|
+
|
|
55
|
+
installedPlugins.forEach(pluginId => {
|
|
56
|
+
const pluginPath = path.join(packagesDir, `plugin-${pluginId}`, 'plugin.json');
|
|
57
|
+
|
|
58
|
+
if (!fs.existsSync(pluginPath)) {
|
|
59
|
+
console.warn(`β οΈ Plugin ${pluginId} not found at ${pluginPath}`);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
try {
|
|
64
|
+
const pluginData = JSON.parse(fs.readFileSync(pluginPath, 'utf-8'));
|
|
65
|
+
const result = generatePluginManifest(pluginData, pluginId);
|
|
66
|
+
|
|
67
|
+
manifests.push(result.manifest);
|
|
68
|
+
pluginList.push(pluginId);
|
|
69
|
+
totalTokens += result.tokens;
|
|
70
|
+
totalFiles += result.stats.agents + result.stats.commands + result.stats.rules;
|
|
71
|
+
|
|
72
|
+
console.log(`β
${pluginId}: ${result.tokens} tokens (${result.stats.agents} agents, ${result.stats.commands} commands, ${result.stats.rules} rules)`);
|
|
73
|
+
} catch (error) {
|
|
74
|
+
console.error(`β Error processing ${pluginId}:`, error.message);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
const pluginsSection = `<plugins>
|
|
79
|
+
<installed>${pluginList.join('|')}</installed>
|
|
80
|
+
|
|
81
|
+
<manifest>
|
|
82
|
+
${manifests.join('\n\n')}
|
|
83
|
+
</manifest>
|
|
84
|
+
|
|
85
|
+
<lazy_loading>
|
|
86
|
+
<enabled>true</enabled>
|
|
87
|
+
<triggers>
|
|
88
|
+
commands: "/[plugin-id]:[command-name]"
|
|
89
|
+
agents: "@[agent-name]" (from plugin)
|
|
90
|
+
rules: on-violation or explicit reference
|
|
91
|
+
</triggers>
|
|
92
|
+
</lazy_loading>
|
|
93
|
+
|
|
94
|
+
<usage>
|
|
95
|
+
Commands: Type /[plugin-id]:[command] to invoke
|
|
96
|
+
Agents: Type @[agent-name] to invoke
|
|
97
|
+
Rules: Automatically loaded when needed
|
|
98
|
+
Files: All available in .claude/plugins/[plugin-id]/
|
|
99
|
+
</usage>
|
|
100
|
+
</plugins>`;
|
|
101
|
+
|
|
102
|
+
return {
|
|
103
|
+
section: pluginsSection,
|
|
104
|
+
tokens: estimateTokens(pluginsSection),
|
|
105
|
+
totalFiles,
|
|
106
|
+
pluginCount: pluginList.length
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Calculate token savings
|
|
112
|
+
*/
|
|
113
|
+
function calculateSavings(optimizedTokens, totalFiles) {
|
|
114
|
+
// Estimate: average 600 tokens per agent, 300 per command, 1500 per rule
|
|
115
|
+
const estimatedOldTokens = totalFiles * 800; // Conservative average
|
|
116
|
+
const savings = estimatedOldTokens - optimizedTokens;
|
|
117
|
+
const percent = ((savings / estimatedOldTokens) * 100).toFixed(1);
|
|
118
|
+
|
|
119
|
+
return {
|
|
120
|
+
old: estimatedOldTokens,
|
|
121
|
+
new: optimizedTokens,
|
|
122
|
+
saved: savings,
|
|
123
|
+
percent
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Main function
|
|
129
|
+
*/
|
|
130
|
+
function main() {
|
|
131
|
+
const args = process.argv.slice(2);
|
|
132
|
+
|
|
133
|
+
if (args.length < 2) {
|
|
134
|
+
console.log('Usage: node plugin-manifest-generator.js <packages-dir> <plugin1,plugin2,...>');
|
|
135
|
+
console.log('Example: node plugin-manifest-generator.js ./packages core,pm,cloud');
|
|
136
|
+
process.exit(1);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const packagesDir = path.resolve(args[0]);
|
|
140
|
+
const pluginIds = args[1].split(',').map(p => p.trim());
|
|
141
|
+
|
|
142
|
+
console.log('\nπ§ Plugin Manifest Generator');
|
|
143
|
+
console.log('='.repeat(70));
|
|
144
|
+
console.log(`Packages directory: ${packagesDir}`);
|
|
145
|
+
console.log(`Plugins to process: ${pluginIds.join(', ')}`);
|
|
146
|
+
console.log('');
|
|
147
|
+
|
|
148
|
+
const result = generatePluginsSection(pluginIds, packagesDir);
|
|
149
|
+
|
|
150
|
+
console.log('\n' + '='.repeat(70));
|
|
151
|
+
console.log('π Generation Complete');
|
|
152
|
+
console.log('='.repeat(70));
|
|
153
|
+
console.log(`Plugins processed: ${result.pluginCount}`);
|
|
154
|
+
console.log(`Total files: ${result.totalFiles}`);
|
|
155
|
+
console.log(`Manifest tokens: ${result.tokens}`);
|
|
156
|
+
|
|
157
|
+
const savings = calculateSavings(result.tokens, result.totalFiles);
|
|
158
|
+
console.log(`\nπ° Token Savings:`);
|
|
159
|
+
console.log(` Old system (est): ${savings.old.toLocaleString()} tokens`);
|
|
160
|
+
console.log(` New manifest: ${savings.new.toLocaleString()} tokens`);
|
|
161
|
+
console.log(` Savings: ${savings.saved.toLocaleString()} tokens (${savings.percent}%)`);
|
|
162
|
+
|
|
163
|
+
console.log('\nπ Generated Manifest:');
|
|
164
|
+
console.log('='.repeat(70));
|
|
165
|
+
console.log(result.section);
|
|
166
|
+
console.log('='.repeat(70));
|
|
167
|
+
|
|
168
|
+
return result;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Export for use in other scripts
|
|
172
|
+
module.exports = {
|
|
173
|
+
generatePluginManifest,
|
|
174
|
+
generatePluginsSection,
|
|
175
|
+
calculateSavings,
|
|
176
|
+
estimateTokens
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
// Run if called directly
|
|
180
|
+
if (require.main === module) {
|
|
181
|
+
main();
|
|
182
|
+
}
|
package/package.json
CHANGED