claude-autopm 1.21.0 ā 1.22.1
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/cloud/gcp-cloud-functions-engineer.md +5 -10
- package/autopm/.claude/agents/cloud/gemini-api-expert.md +1 -1
- package/autopm/.claude/agents/cloud/openai-python-expert.md +1 -1
- package/autopm/.claude/agents/cloud/terraform-infrastructure-expert.md +7 -11
- package/autopm/.claude/agents/core/mcp-manager.md +7 -0
- package/autopm/.claude/agents/data/airflow-orchestration-expert.md +1 -1
- package/autopm/.claude/agents/data/kedro-pipeline-expert.md +1 -1
- package/autopm/.claude/agents/data/langgraph-workflow-expert.md +1 -1
- package/autopm/.claude/agents/databases/bigquery-expert.md +1 -1
- package/autopm/.claude/agents/databases/cosmosdb-expert.md +1 -1
- package/autopm/.claude/agents/databases/mongodb-expert.md +1 -1
- package/autopm/.claude/agents/databases/postgresql-expert.md +1 -1
- package/autopm/.claude/agents/databases/redis-expert.md +1 -1
- package/autopm/.claude/agents/decision-matrices/playwright-testing-selection.md +6 -0
- package/autopm/.claude/agents/decision-matrices/python-backend-selection.md +7 -0
- package/autopm/.claude/agents/decision-matrices/ui-framework-selection.md +7 -0
- package/autopm/.claude/agents/devops/azure-devops-specialist.md +1 -1
- package/autopm/.claude/agents/devops/github-operations-specialist.md +7 -0
- package/autopm/.claude/agents/devops/mcp-context-manager.md +7 -0
- package/autopm/.claude/agents/devops/ssh-operations-expert.md +1 -1
- package/autopm/.claude/agents/devops/traefik-proxy-expert.md +1 -1
- package/autopm/.claude/agents/frameworks/nats-messaging-expert.md +1 -1
- package/autopm/.claude/agents/frameworks/react-frontend-engineer.md +1 -1
- package/autopm/.claude/agents/languages/bash-scripting-expert.md +1 -1
- package/autopm/.claude/agents/languages/javascript-frontend-engineer.md +1 -1
- package/autopm/.claude/agents/languages/nodejs-backend-engineer.md +9 -6
- package/autopm/.claude/agents/languages/python-backend-engineer.md +1 -1
- package/autopm/.claude/commands/ai/langgraph-workflow.md +17 -0
- package/autopm/.claude/commands/ai/openai-chat.md +17 -0
- package/autopm/.claude/commands/azure/active-work.md +17 -0
- package/autopm/.claude/commands/azure/aliases.md +17 -0
- package/autopm/.claude/commands/azure/blocked-items.md +17 -0
- package/autopm/.claude/commands/azure/clean.md +17 -0
- package/autopm/.claude/commands/azure/docs-query.md +17 -0
- package/autopm/.claude/commands/azure/feature-decompose.md +17 -0
- package/autopm/.claude/commands/azure/feature-list.md +17 -0
- package/autopm/.claude/commands/azure/feature-new.md +17 -0
- package/autopm/.claude/commands/azure/feature-show.md +17 -0
- package/autopm/.claude/commands/azure/feature-start.md +17 -0
- package/autopm/.claude/commands/azure/fix-integration-example.md +17 -0
- package/autopm/.claude/commands/azure/help.md +17 -0
- package/autopm/.claude/commands/azure/import-us.md +17 -0
- package/autopm/.claude/commands/azure/init.md +17 -0
- package/autopm/.claude/commands/azure/next-task.md +17 -0
- package/autopm/.claude/commands/azure/search.md +17 -0
- package/autopm/.claude/commands/azure/sprint-status.md +17 -0
- package/autopm/.claude/commands/azure/standup.md +17 -0
- package/autopm/.claude/commands/azure/sync-all.md +17 -0
- package/autopm/.claude/commands/azure/task-analyze.md +17 -0
- package/autopm/.claude/commands/azure/task-close.md +17 -0
- package/autopm/.claude/commands/azure/task-edit.md +17 -0
- package/autopm/.claude/commands/azure/task-list.md +17 -0
- package/autopm/.claude/commands/azure/task-new.md +17 -0
- package/autopm/.claude/commands/azure/task-reopen.md +17 -0
- package/autopm/.claude/commands/azure/task-show.md +17 -0
- package/autopm/.claude/commands/azure/task-start.md +17 -0
- package/autopm/.claude/commands/azure/task-status.md +17 -0
- package/autopm/.claude/commands/azure/task-sync.md +17 -0
- package/autopm/.claude/commands/azure/us-edit.md +17 -0
- package/autopm/.claude/commands/azure/us-list.md +17 -0
- package/autopm/.claude/commands/azure/us-new.md +17 -0
- package/autopm/.claude/commands/azure/us-parse.md +17 -0
- package/autopm/.claude/commands/azure/us-show.md +17 -0
- package/autopm/.claude/commands/azure/us-status.md +17 -0
- package/autopm/.claude/commands/azure/validate.md +17 -0
- package/autopm/.claude/commands/azure/work-item-sync.md +17 -0
- package/autopm/.claude/commands/cloud/infra-deploy.md +17 -0
- package/autopm/.claude/commands/config/toggle-features.md +15 -0
- package/autopm/.claude/commands/context/create.md +16 -0
- package/autopm/.claude/commands/context/prime.md +16 -0
- package/autopm/.claude/commands/context/update.md +16 -0
- package/autopm/.claude/commands/github/workflow-create.md +17 -0
- package/autopm/.claude/commands/infrastructure/ssh-security.md +17 -0
- package/autopm/.claude/commands/infrastructure/traefik-setup.md +17 -0
- package/autopm/.claude/commands/kubernetes/deploy.md +16 -0
- package/autopm/.claude/commands/mcp/context-setup.md +17 -0
- package/autopm/.claude/commands/mcp/docs-refresh.md +17 -0
- package/autopm/.claude/commands/playwright/test-scaffold.md +17 -0
- package/autopm/.claude/commands/pm/blocked.md +17 -0
- package/autopm/.claude/commands/pm/clean.md +17 -0
- package/autopm/.claude/commands/pm/context.md +17 -0
- package/autopm/.claude/commands/pm/epic-close.md +17 -0
- package/autopm/.claude/commands/pm/epic-decompose.md +16 -0
- package/autopm/.claude/commands/pm/epic-edit.md +17 -0
- package/autopm/.claude/commands/pm/epic-list.md +17 -0
- package/autopm/.claude/commands/pm/epic-merge.md +17 -0
- package/autopm/.claude/commands/pm/epic-oneshot.md +17 -0
- package/autopm/.claude/commands/pm/epic-refresh.md +17 -0
- package/autopm/.claude/commands/pm/epic-show.md +17 -0
- package/autopm/.claude/commands/pm/epic-split.md +17 -0
- package/autopm/.claude/commands/pm/epic-start.md +17 -0
- package/autopm/.claude/commands/pm/epic-status.md +17 -0
- package/autopm/.claude/commands/pm/epic-sync-modular.md +17 -0
- package/autopm/.claude/commands/pm/epic-sync-original.md +17 -0
- package/autopm/.claude/commands/pm/epic-sync.md +17 -0
- package/autopm/.claude/commands/pm/help.md +17 -0
- package/autopm/.claude/commands/pm/import.md +17 -0
- package/autopm/.claude/commands/pm/in-progress.md +17 -0
- package/autopm/.claude/commands/pm/init.md +17 -0
- package/autopm/.claude/commands/pm/issue-analyze.md +17 -0
- package/autopm/.claude/commands/pm/issue-close.md +17 -0
- package/autopm/.claude/commands/pm/issue-edit.md +17 -0
- package/autopm/.claude/commands/pm/issue-reopen.md +17 -0
- package/autopm/.claude/commands/pm/issue-show.md +17 -0
- package/autopm/.claude/commands/pm/issue-start.md +16 -0
- package/autopm/.claude/commands/pm/issue-status.md +17 -0
- package/autopm/.claude/commands/pm/issue-sync.md +17 -0
- package/autopm/.claude/commands/pm/next.md +17 -0
- package/autopm/.claude/commands/pm/prd-edit.md +17 -0
- package/autopm/.claude/commands/pm/prd-list.md +17 -0
- package/autopm/.claude/commands/pm/prd-new.md +16 -0
- package/autopm/.claude/commands/pm/prd-parse.md +17 -0
- package/autopm/.claude/commands/pm/prd-status.md +17 -0
- package/autopm/.claude/commands/pm/search.md +17 -0
- package/autopm/.claude/commands/pm/standup.md +17 -0
- package/autopm/.claude/commands/pm/status.md +17 -0
- package/autopm/.claude/commands/pm/sync.md +17 -0
- package/autopm/.claude/commands/pm/test-reference-update.md +17 -0
- package/autopm/.claude/commands/pm/validate.md +17 -0
- package/autopm/.claude/commands/pm/what-next.md +17 -0
- package/autopm/.claude/commands/python/api-scaffold.md +17 -0
- package/autopm/.claude/commands/python/docs-query.md +17 -0
- package/autopm/.claude/commands/react/app-scaffold.md +17 -0
- package/autopm/.claude/commands/testing/prime.md +17 -0
- package/autopm/.claude/commands/testing/run.md +17 -0
- package/autopm/.claude/commands/ui/bootstrap-scaffold.md +17 -0
- package/autopm/.claude/commands/ui/tailwind-system.md +17 -0
- package/autopm/.claude/hooks/context7-reminder.md +29 -0
- package/autopm/.claude/hooks/pre-agent-context7.js +224 -0
- package/autopm/.claude/hooks/pre-command-context7.js +229 -0
- package/autopm/.claude/hooks/unified-context7-enforcement.sh +38 -0
- package/autopm/.claude/rules/context7-enforcement.md +327 -0
- package/package.json +1 -1
- package/scripts/add-context7-to-commands.js +351 -0
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Automatically add "Required Documentation Access" section to all commands
|
|
5
|
+
* that don't already have it.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
const { execSync } = require('child_process');
|
|
11
|
+
|
|
12
|
+
// Command categories with their Context7 topic mappings
|
|
13
|
+
const CATEGORY_MAPPINGS = {
|
|
14
|
+
'ai': {
|
|
15
|
+
topics: ['ai/llm-integration', 'ai/workflow-orchestration', 'openai/api', 'langchain/agents'],
|
|
16
|
+
description: 'AI integration and LLM workflows'
|
|
17
|
+
},
|
|
18
|
+
'azure': {
|
|
19
|
+
topics: ['azure-devops/boards', 'agile/user-stories', 'project-management/work-items', 'agile/sprint-planning'],
|
|
20
|
+
description: 'Azure DevOps integration and agile workflows'
|
|
21
|
+
},
|
|
22
|
+
'cloud': {
|
|
23
|
+
topics: ['cloud/infrastructure', 'devops/deployment', 'terraform/best-practices', 'cloud/security'],
|
|
24
|
+
description: 'cloud infrastructure deployment'
|
|
25
|
+
},
|
|
26
|
+
'config': {
|
|
27
|
+
topics: ['configuration-management/best-practices', 'devops/feature-flags'],
|
|
28
|
+
description: 'configuration management'
|
|
29
|
+
},
|
|
30
|
+
'context': {
|
|
31
|
+
topics: ['ai/context-management', 'llm/prompt-engineering', 'ai/rag-systems'],
|
|
32
|
+
description: 'AI context management'
|
|
33
|
+
},
|
|
34
|
+
'github': {
|
|
35
|
+
topics: ['github/workflows', 'ci-cd/github-actions', 'devops/automation'],
|
|
36
|
+
description: 'GitHub workflow creation'
|
|
37
|
+
},
|
|
38
|
+
'infrastructure': {
|
|
39
|
+
topics: ['security/ssh-hardening', 'infrastructure/reverse-proxy', 'security/best-practices', 'devops/traefik'],
|
|
40
|
+
description: 'infrastructure setup and security'
|
|
41
|
+
},
|
|
42
|
+
'kubernetes': {
|
|
43
|
+
topics: ['kubernetes/deployment', 'kubernetes/best-practices', 'devops/container-orchestration'],
|
|
44
|
+
description: 'Kubernetes deployment'
|
|
45
|
+
},
|
|
46
|
+
'mcp': {
|
|
47
|
+
topics: ['mcp/protocol', 'mcp/servers', 'ai/context-management', 'mcp/integration'],
|
|
48
|
+
description: 'MCP server setup and documentation'
|
|
49
|
+
},
|
|
50
|
+
'playwright': {
|
|
51
|
+
topics: ['playwright/testing', 'testing/e2e', 'testing/best-practices', 'playwright/patterns'],
|
|
52
|
+
description: 'Playwright test scaffolding'
|
|
53
|
+
},
|
|
54
|
+
'pm': {
|
|
55
|
+
topics: ['agile/epic-management', 'project-management/issue-tracking', 'agile/task-breakdown', 'project-management/workflow'],
|
|
56
|
+
description: 'project management workflows'
|
|
57
|
+
},
|
|
58
|
+
'python': {
|
|
59
|
+
topics: ['python/api-development', 'fastapi/best-practices', 'python/documentation', 'api-design/rest'],
|
|
60
|
+
description: 'Python API development'
|
|
61
|
+
},
|
|
62
|
+
'react': {
|
|
63
|
+
topics: ['react/application-setup', 'react/best-practices', 'frontend/architecture', 'react/tooling'],
|
|
64
|
+
description: 'React application scaffolding'
|
|
65
|
+
},
|
|
66
|
+
'testing': {
|
|
67
|
+
topics: ['testing/strategy', 'testing/automation', 'tdd/workflow', 'testing/best-practices'],
|
|
68
|
+
description: 'testing workflows'
|
|
69
|
+
},
|
|
70
|
+
'ui': {
|
|
71
|
+
topics: ['ui/bootstrap', 'ui/tailwind', 'frontend/design-systems', 'css/frameworks'],
|
|
72
|
+
description: 'UI framework setup'
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
// Special mappings for specific commands
|
|
77
|
+
const COMMAND_SPECIFIC_MAPPINGS = {
|
|
78
|
+
'epic-decompose': {
|
|
79
|
+
topics: ['agile/epic-decomposition', 'agile/task-sizing', 'agile/user-stories', 'project-management/task-breakdown'],
|
|
80
|
+
description: 'decomposing epics'
|
|
81
|
+
},
|
|
82
|
+
'epic-split': {
|
|
83
|
+
topics: ['agile/epic-splitting', 'project-management/dependency-mapping', 'agile/priority-frameworks', 'architecture/component-analysis'],
|
|
84
|
+
description: 'splitting PRDs into epics'
|
|
85
|
+
},
|
|
86
|
+
'issue-analyze': {
|
|
87
|
+
topics: ['agile/issue-analysis', 'agile/parallel-work', 'project-management/task-dependencies', 'agile/estimation'],
|
|
88
|
+
description: 'analyzing issues'
|
|
89
|
+
},
|
|
90
|
+
'issue-start': {
|
|
91
|
+
topics: ['agile/issue-planning', 'tdd/workflow', 'git/branching', 'collaboration/parallel-work'],
|
|
92
|
+
description: 'starting work on issues'
|
|
93
|
+
},
|
|
94
|
+
'prd-new': {
|
|
95
|
+
topics: ['product-management/prd-templates', 'product-management/requirements', 'agile/user-stories', 'product-management/success-metrics'],
|
|
96
|
+
description: 'creating PRDs'
|
|
97
|
+
},
|
|
98
|
+
'prd-parse': {
|
|
99
|
+
topics: ['product-management/prd-to-epic', 'agile/epic-structure', 'architecture/technical-design', 'project-management/task-breakdown'],
|
|
100
|
+
description: 'converting PRDs to epics'
|
|
101
|
+
},
|
|
102
|
+
'feature-decompose': {
|
|
103
|
+
topics: ['agile/feature-breakdown', 'azure-devops/features', 'agile/task-sizing', 'project-management/work-breakdown'],
|
|
104
|
+
description: 'decomposing Azure features'
|
|
105
|
+
},
|
|
106
|
+
'us-new': {
|
|
107
|
+
topics: ['agile/user-stories', 'agile/invest-criteria', 'azure-devops/user-stories', 'requirements/writing'],
|
|
108
|
+
description: 'creating user stories'
|
|
109
|
+
},
|
|
110
|
+
'task-analyze': {
|
|
111
|
+
topics: ['agile/task-analysis', 'project-management/task-planning', 'agile/estimation', 'azure-devops/tasks'],
|
|
112
|
+
description: 'analyzing tasks'
|
|
113
|
+
},
|
|
114
|
+
'workflow-create': {
|
|
115
|
+
topics: ['github/workflows', 'ci-cd/github-actions', 'devops/pipeline-design', 'ci-cd/best-practices'],
|
|
116
|
+
description: 'creating GitHub workflows'
|
|
117
|
+
},
|
|
118
|
+
'infra-deploy': {
|
|
119
|
+
topics: ['infrastructure/deployment', 'cloud/best-practices', 'devops/automation', 'infrastructure/configuration'],
|
|
120
|
+
description: 'deploying infrastructure'
|
|
121
|
+
},
|
|
122
|
+
'ssh-security': {
|
|
123
|
+
topics: ['security/ssh-hardening', 'security/authentication', 'infrastructure/security', 'security/best-practices'],
|
|
124
|
+
description: 'SSH security hardening'
|
|
125
|
+
},
|
|
126
|
+
'traefik-setup': {
|
|
127
|
+
topics: ['infrastructure/reverse-proxy', 'traefik/configuration', 'devops/networking', 'security/tls'],
|
|
128
|
+
description: 'Traefik setup'
|
|
129
|
+
},
|
|
130
|
+
'test-scaffold': {
|
|
131
|
+
topics: ['playwright/scaffolding', 'testing/e2e', 'testing/page-objects', 'playwright/best-practices'],
|
|
132
|
+
description: 'scaffolding Playwright tests'
|
|
133
|
+
},
|
|
134
|
+
'api-scaffold': {
|
|
135
|
+
topics: ['python/api-scaffolding', 'fastapi/structure', 'api-design/rest', 'python/best-practices'],
|
|
136
|
+
description: 'scaffolding Python APIs'
|
|
137
|
+
},
|
|
138
|
+
'app-scaffold': {
|
|
139
|
+
topics: ['react/project-setup', 'react/application-structure', 'frontend/tooling', 'react/best-practices'],
|
|
140
|
+
description: 'scaffolding React applications'
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
function getCommandCategory(filePath) {
|
|
145
|
+
const parts = filePath.split('/');
|
|
146
|
+
const commandsIndex = parts.indexOf('commands');
|
|
147
|
+
if (commandsIndex >= 0 && commandsIndex < parts.length - 1) {
|
|
148
|
+
return parts[commandsIndex + 1];
|
|
149
|
+
}
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function getCommandName(filePath) {
|
|
154
|
+
return path.basename(filePath, '.md');
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function getTopicsForCommand(filePath) {
|
|
158
|
+
const commandName = getCommandName(filePath);
|
|
159
|
+
const category = getCommandCategory(filePath);
|
|
160
|
+
|
|
161
|
+
// Check for command-specific mapping first
|
|
162
|
+
if (COMMAND_SPECIFIC_MAPPINGS[commandName]) {
|
|
163
|
+
return COMMAND_SPECIFIC_MAPPINGS[commandName];
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// Fall back to category mapping
|
|
167
|
+
if (category && CATEGORY_MAPPINGS[category]) {
|
|
168
|
+
return CATEGORY_MAPPINGS[category];
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Default generic topics
|
|
172
|
+
return {
|
|
173
|
+
topics: ['best-practices/general', 'development/workflow'],
|
|
174
|
+
description: 'executing this command'
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function generateContext7Section(filePath) {
|
|
179
|
+
const mapping = getTopicsForCommand(filePath);
|
|
180
|
+
const { topics, description } = mapping;
|
|
181
|
+
|
|
182
|
+
const documentationQueries = topics
|
|
183
|
+
.map(topic => `- \`mcp://context7/${topic}\` - ${topic.split('/').pop().replace(/-/g, ' ')} best practices`)
|
|
184
|
+
.join('\n');
|
|
185
|
+
|
|
186
|
+
return `## Required Documentation Access
|
|
187
|
+
|
|
188
|
+
**MANDATORY:** Before ${description}, query Context7 for best practices:
|
|
189
|
+
|
|
190
|
+
**Documentation Queries:**
|
|
191
|
+
${documentationQueries}
|
|
192
|
+
|
|
193
|
+
**Why This is Required:**
|
|
194
|
+
- Ensures adherence to current industry standards and best practices
|
|
195
|
+
- Prevents outdated or incorrect implementation patterns
|
|
196
|
+
- Provides access to latest framework/tool documentation
|
|
197
|
+
- Reduces errors from stale knowledge or assumptions
|
|
198
|
+
|
|
199
|
+
`;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function shouldProcessFile(filePath) {
|
|
203
|
+
const fileName = path.basename(filePath);
|
|
204
|
+
|
|
205
|
+
// Skip non-command files
|
|
206
|
+
const skipFiles = [
|
|
207
|
+
'README.md',
|
|
208
|
+
'COMMANDS.md',
|
|
209
|
+
'COMMAND_MAPPING.md',
|
|
210
|
+
'INTEGRATION_FIX.md',
|
|
211
|
+
'ui-framework-commands.md',
|
|
212
|
+
'ux-design-commands.md',
|
|
213
|
+
'code-rabbit.md',
|
|
214
|
+
'prompt.md',
|
|
215
|
+
're-init.md'
|
|
216
|
+
];
|
|
217
|
+
|
|
218
|
+
return !skipFiles.includes(fileName);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function hasContext7Section(content) {
|
|
222
|
+
return content.includes('## Required Documentation Access');
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function findInsertionPoint(content) {
|
|
226
|
+
const lines = content.split('\n');
|
|
227
|
+
|
|
228
|
+
// Look for common section headers where we should insert BEFORE
|
|
229
|
+
const beforeSections = [
|
|
230
|
+
'## Instructions',
|
|
231
|
+
'## Required Rules',
|
|
232
|
+
'## Quick Check',
|
|
233
|
+
'## Description',
|
|
234
|
+
'## Usage Examples',
|
|
235
|
+
'## Overview',
|
|
236
|
+
'## Pre-flight Checks',
|
|
237
|
+
'## Validation',
|
|
238
|
+
'## Steps'
|
|
239
|
+
];
|
|
240
|
+
|
|
241
|
+
for (let i = 0; i < lines.length; i++) {
|
|
242
|
+
for (const section of beforeSections) {
|
|
243
|
+
if (lines[i].trim().startsWith(section)) {
|
|
244
|
+
return i;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// If no known section found, insert after usage block (usually has ```)
|
|
250
|
+
let usageEndIndex = -1;
|
|
251
|
+
let inUsageBlock = false;
|
|
252
|
+
for (let i = 0; i < lines.length; i++) {
|
|
253
|
+
if (lines[i].includes('## Usage') || lines[i].includes('## Example')) {
|
|
254
|
+
inUsageBlock = true;
|
|
255
|
+
}
|
|
256
|
+
if (inUsageBlock && lines[i].trim() === '```') {
|
|
257
|
+
usageEndIndex = i + 1;
|
|
258
|
+
break;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
if (usageEndIndex > 0) {
|
|
263
|
+
return usageEndIndex;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// Last resort: insert after first heading block (after frontmatter and title)
|
|
267
|
+
let headingCount = 0;
|
|
268
|
+
for (let i = 0; i < lines.length; i++) {
|
|
269
|
+
if (lines[i].startsWith('#')) {
|
|
270
|
+
headingCount++;
|
|
271
|
+
if (headingCount >= 2) {
|
|
272
|
+
return i;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
return 10; // Fallback to line 10
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
function addContext7Section(filePath) {
|
|
281
|
+
let content = fs.readFileSync(filePath, 'utf8');
|
|
282
|
+
|
|
283
|
+
if (hasContext7Section(content)) {
|
|
284
|
+
return { modified: false, reason: 'already has section' };
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
const context7Section = generateContext7Section(filePath);
|
|
288
|
+
const insertionLine = findInsertionPoint(content);
|
|
289
|
+
|
|
290
|
+
const lines = content.split('\n');
|
|
291
|
+
lines.splice(insertionLine, 0, context7Section);
|
|
292
|
+
|
|
293
|
+
const newContent = lines.join('\n');
|
|
294
|
+
fs.writeFileSync(filePath, newContent, 'utf8');
|
|
295
|
+
|
|
296
|
+
return { modified: true, insertionLine };
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
function main() {
|
|
300
|
+
const commandsDir = path.join(__dirname, '../autopm/.claude/commands');
|
|
301
|
+
|
|
302
|
+
// Find all .md files recursively
|
|
303
|
+
const findCommand = `find "${commandsDir}" -name "*.md" -type f`;
|
|
304
|
+
const files = execSync(findCommand, { encoding: 'utf8' })
|
|
305
|
+
.trim()
|
|
306
|
+
.split('\n')
|
|
307
|
+
.filter(f => f.length > 0);
|
|
308
|
+
|
|
309
|
+
console.log(`\nš Found ${files.length} command files\n`);
|
|
310
|
+
|
|
311
|
+
const results = {
|
|
312
|
+
modified: [],
|
|
313
|
+
skipped: [],
|
|
314
|
+
alreadyHas: []
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
for (const file of files) {
|
|
318
|
+
const fileName = path.relative(commandsDir, file);
|
|
319
|
+
|
|
320
|
+
if (!shouldProcessFile(file)) {
|
|
321
|
+
results.skipped.push(fileName);
|
|
322
|
+
continue;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
const result = addContext7Section(file);
|
|
326
|
+
|
|
327
|
+
if (result.modified) {
|
|
328
|
+
results.modified.push({ file: fileName, line: result.insertionLine });
|
|
329
|
+
console.log(`ā
Added to: ${fileName} (line ${result.insertionLine})`);
|
|
330
|
+
} else {
|
|
331
|
+
results.alreadyHas.push(fileName);
|
|
332
|
+
console.log(`āļø Skip: ${fileName} (${result.reason})`);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
console.log(`\nš Summary:`);
|
|
337
|
+
console.log(` Modified: ${results.modified.length}`);
|
|
338
|
+
console.log(` Already has Context7: ${results.alreadyHas.length}`);
|
|
339
|
+
console.log(` Skipped (non-command files): ${results.skipped.length}`);
|
|
340
|
+
console.log(` Total processed: ${files.length}\n`);
|
|
341
|
+
|
|
342
|
+
if (results.modified.length > 0) {
|
|
343
|
+
console.log(`⨠Successfully added Context7 sections to ${results.modified.length} commands!\n`);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
if (require.main === module) {
|
|
348
|
+
main();
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
module.exports = { addContext7Section, getTopicsForCommand };
|