claude-autopm 1.21.0 ā 1.22.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/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 +3 -7
- 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/pre-agent-context7.js +224 -0
- package/autopm/.claude/hooks/pre-command-context7.js +229 -0
- package/autopm/.claude/rules/context7-enforcement.md +292 -0
- package/package.json +1 -1
- package/scripts/add-context7-to-commands.js +351 -0
|
@@ -8,4 +8,21 @@ Run `node .claude/scripts/pm/validate.js` using the Bash tool and show me the co
|
|
|
8
8
|
- DO NOT collapse.
|
|
9
9
|
- DO NOT abbreviate.
|
|
10
10
|
- Show ALL lines in full.
|
|
11
|
+
## Required Documentation Access
|
|
12
|
+
|
|
13
|
+
**MANDATORY:** Before project management workflows, query Context7 for best practices:
|
|
14
|
+
|
|
15
|
+
**Documentation Queries:**
|
|
16
|
+
- `mcp://context7/agile/epic-management` - epic management best practices
|
|
17
|
+
- `mcp://context7/project-management/issue-tracking` - issue tracking best practices
|
|
18
|
+
- `mcp://context7/agile/task-breakdown` - task breakdown best practices
|
|
19
|
+
- `mcp://context7/project-management/workflow` - workflow best practices
|
|
20
|
+
|
|
21
|
+
**Why This is Required:**
|
|
22
|
+
- Ensures adherence to current industry standards and best practices
|
|
23
|
+
- Prevents outdated or incorrect implementation patterns
|
|
24
|
+
- Provides access to latest framework/tool documentation
|
|
25
|
+
- Reduces errors from stale knowledge or assumptions
|
|
26
|
+
|
|
27
|
+
|
|
11
28
|
- DO NOT print any other comments.
|
|
@@ -8,4 +8,21 @@ Run `node .claude/scripts/pm/what-next.js` using the Bash tool and show me the c
|
|
|
8
8
|
- DO NOT collapse.
|
|
9
9
|
- DO NOT abbreviate.
|
|
10
10
|
- Show ALL lines in full.
|
|
11
|
+
## Required Documentation Access
|
|
12
|
+
|
|
13
|
+
**MANDATORY:** Before project management workflows, query Context7 for best practices:
|
|
14
|
+
|
|
15
|
+
**Documentation Queries:**
|
|
16
|
+
- `mcp://context7/agile/epic-management` - epic management best practices
|
|
17
|
+
- `mcp://context7/project-management/issue-tracking` - issue tracking best practices
|
|
18
|
+
- `mcp://context7/agile/task-breakdown` - task breakdown best practices
|
|
19
|
+
- `mcp://context7/project-management/workflow` - workflow best practices
|
|
20
|
+
|
|
21
|
+
**Why This is Required:**
|
|
22
|
+
- Ensures adherence to current industry standards and best practices
|
|
23
|
+
- Prevents outdated or incorrect implementation patterns
|
|
24
|
+
- Provides access to latest framework/tool documentation
|
|
25
|
+
- Reduces errors from stale knowledge or assumptions
|
|
26
|
+
|
|
27
|
+
|
|
11
28
|
- DO NOT print any other comments.
|
|
@@ -8,6 +8,23 @@ Creates a complete FastAPI project structure with modern Python tooling.
|
|
|
8
8
|
|
|
9
9
|
**Usage**: `/python:api-scaffold [project-name] [--db=postgresql|mysql|sqlite] [--auth=jwt|oauth2]`
|
|
10
10
|
|
|
11
|
+
## Required Documentation Access
|
|
12
|
+
|
|
13
|
+
**MANDATORY:** Before scaffolding Python APIs, query Context7 for best practices:
|
|
14
|
+
|
|
15
|
+
**Documentation Queries:**
|
|
16
|
+
- `mcp://context7/python/api-scaffolding` - api scaffolding best practices
|
|
17
|
+
- `mcp://context7/fastapi/structure` - structure best practices
|
|
18
|
+
- `mcp://context7/api-design/rest` - rest best practices
|
|
19
|
+
- `mcp://context7/python/best-practices` - best practices best practices
|
|
20
|
+
|
|
21
|
+
**Why This is Required:**
|
|
22
|
+
- Ensures adherence to current industry standards and best practices
|
|
23
|
+
- Prevents outdated or incorrect implementation patterns
|
|
24
|
+
- Provides access to latest framework/tool documentation
|
|
25
|
+
- Reduces errors from stale knowledge or assumptions
|
|
26
|
+
|
|
27
|
+
|
|
11
28
|
**Example**: `/python:api-scaffold task-manager --db=postgresql --auth=jwt`
|
|
12
29
|
|
|
13
30
|
**What this does**:
|
|
@@ -8,6 +8,23 @@ Queries latest Python/FastAPI documentation via context7 before implementation.
|
|
|
8
8
|
|
|
9
9
|
**Usage**: `/python:docs-query [--topic=fastapi|sqlalchemy|pydantic|uv|pytest] [--pattern=search-pattern] [--examples]`
|
|
10
10
|
|
|
11
|
+
## Required Documentation Access
|
|
12
|
+
|
|
13
|
+
**MANDATORY:** Before Python API development, query Context7 for best practices:
|
|
14
|
+
|
|
15
|
+
**Documentation Queries:**
|
|
16
|
+
- `mcp://context7/python/api-development` - api development best practices
|
|
17
|
+
- `mcp://context7/fastapi/best-practices` - best practices best practices
|
|
18
|
+
- `mcp://context7/python/documentation` - documentation best practices
|
|
19
|
+
- `mcp://context7/api-design/rest` - rest best practices
|
|
20
|
+
|
|
21
|
+
**Why This is Required:**
|
|
22
|
+
- Ensures adherence to current industry standards and best practices
|
|
23
|
+
- Prevents outdated or incorrect implementation patterns
|
|
24
|
+
- Provides access to latest framework/tool documentation
|
|
25
|
+
- Reduces errors from stale knowledge or assumptions
|
|
26
|
+
|
|
27
|
+
|
|
11
28
|
**Examples**:
|
|
12
29
|
- `/python:docs-query --topic=fastapi --pattern=authentication`
|
|
13
30
|
- `/python:docs-query --topic=sqlalchemy --pattern=async --examples`
|
|
@@ -8,6 +8,23 @@ Creates a complete React application with TypeScript and modern tooling.
|
|
|
8
8
|
|
|
9
9
|
**Usage**: `/react:app-scaffold [app-name] [--framework=vite|next] [--styling=tailwind|styled] [--state=zustand|redux]`
|
|
10
10
|
|
|
11
|
+
## Required Documentation Access
|
|
12
|
+
|
|
13
|
+
**MANDATORY:** Before scaffolding React applications, query Context7 for best practices:
|
|
14
|
+
|
|
15
|
+
**Documentation Queries:**
|
|
16
|
+
- `mcp://context7/react/project-setup` - project setup best practices
|
|
17
|
+
- `mcp://context7/react/application-structure` - application structure best practices
|
|
18
|
+
- `mcp://context7/frontend/tooling` - tooling best practices
|
|
19
|
+
- `mcp://context7/react/best-practices` - best practices best practices
|
|
20
|
+
|
|
21
|
+
**Why This is Required:**
|
|
22
|
+
- Ensures adherence to current industry standards and best practices
|
|
23
|
+
- Prevents outdated or incorrect implementation patterns
|
|
24
|
+
- Provides access to latest framework/tool documentation
|
|
25
|
+
- Reduces errors from stale knowledge or assumptions
|
|
26
|
+
|
|
27
|
+
|
|
11
28
|
**Example**: `/react:app-scaffold dashboard-app --framework=vite --styling=tailwind --state=zustand`
|
|
12
29
|
|
|
13
30
|
**What this does**:
|
|
@@ -53,6 +53,23 @@ If dependencies missing:
|
|
|
53
53
|
- Tell user: "ā Test dependencies not installed"
|
|
54
54
|
- Suggest: "Run: npm install (or pip install -r requirements.txt)"
|
|
55
55
|
|
|
56
|
+
## Required Documentation Access
|
|
57
|
+
|
|
58
|
+
**MANDATORY:** Before testing workflows, query Context7 for best practices:
|
|
59
|
+
|
|
60
|
+
**Documentation Queries:**
|
|
61
|
+
- `mcp://context7/testing/strategy` - strategy best practices
|
|
62
|
+
- `mcp://context7/testing/automation` - automation best practices
|
|
63
|
+
- `mcp://context7/tdd/workflow` - workflow best practices
|
|
64
|
+
- `mcp://context7/testing/best-practices` - best practices best practices
|
|
65
|
+
|
|
66
|
+
**Why This is Required:**
|
|
67
|
+
- Ensures adherence to current industry standards and best practices
|
|
68
|
+
- Prevents outdated or incorrect implementation patterns
|
|
69
|
+
- Provides access to latest framework/tool documentation
|
|
70
|
+
- Reduces errors from stale knowledge or assumptions
|
|
71
|
+
|
|
72
|
+
|
|
56
73
|
## Instructions
|
|
57
74
|
|
|
58
75
|
### 1. Framework-Specific Configuration
|
|
@@ -17,6 +17,23 @@ Where `test_target` can be:
|
|
|
17
17
|
- Test pattern
|
|
18
18
|
- Test suite name
|
|
19
19
|
|
|
20
|
+
## Required Documentation Access
|
|
21
|
+
|
|
22
|
+
**MANDATORY:** Before testing workflows, query Context7 for best practices:
|
|
23
|
+
|
|
24
|
+
**Documentation Queries:**
|
|
25
|
+
- `mcp://context7/testing/strategy` - strategy best practices
|
|
26
|
+
- `mcp://context7/testing/automation` - automation best practices
|
|
27
|
+
- `mcp://context7/tdd/workflow` - workflow best practices
|
|
28
|
+
- `mcp://context7/testing/best-practices` - best practices best practices
|
|
29
|
+
|
|
30
|
+
**Why This is Required:**
|
|
31
|
+
- Ensures adherence to current industry standards and best practices
|
|
32
|
+
- Prevents outdated or incorrect implementation patterns
|
|
33
|
+
- Provides access to latest framework/tool documentation
|
|
34
|
+
- Reduces errors from stale knowledge or assumptions
|
|
35
|
+
|
|
36
|
+
|
|
20
37
|
## Quick Check
|
|
21
38
|
|
|
22
39
|
```bash
|
|
@@ -31,6 +31,23 @@ Use the react-ui-expert agent with framework=bootstrap to create a complete Boot
|
|
|
31
31
|
|
|
32
32
|
## Example Usage
|
|
33
33
|
```
|
|
34
|
+
## Required Documentation Access
|
|
35
|
+
|
|
36
|
+
**MANDATORY:** Before UI framework setup, query Context7 for best practices:
|
|
37
|
+
|
|
38
|
+
**Documentation Queries:**
|
|
39
|
+
- `mcp://context7/ui/bootstrap` - bootstrap best practices
|
|
40
|
+
- `mcp://context7/ui/tailwind` - tailwind best practices
|
|
41
|
+
- `mcp://context7/frontend/design-systems` - design systems best practices
|
|
42
|
+
- `mcp://context7/css/frameworks` - frameworks best practices
|
|
43
|
+
|
|
44
|
+
**Why This is Required:**
|
|
45
|
+
- Ensures adherence to current industry standards and best practices
|
|
46
|
+
- Prevents outdated or incorrect implementation patterns
|
|
47
|
+
- Provides access to latest framework/tool documentation
|
|
48
|
+
- Reduces errors from stale knowledge or assumptions
|
|
49
|
+
|
|
50
|
+
|
|
34
51
|
Task: Create Bootstrap dashboard with sidebar navigation, responsive cards grid, and contact forms
|
|
35
52
|
Agent: react-ui-expert
|
|
36
53
|
Parameters: framework=bootstrap, theme=corporate, components=navbar,sidebar,cards,forms,modals, responsive=all, features=dark-mode,validation
|
|
@@ -31,6 +31,23 @@ Use the tailwindcss-expert agent to create a comprehensive TailwindCSS design sy
|
|
|
31
31
|
|
|
32
32
|
## Example Usage
|
|
33
33
|
```
|
|
34
|
+
## Required Documentation Access
|
|
35
|
+
|
|
36
|
+
**MANDATORY:** Before UI framework setup, query Context7 for best practices:
|
|
37
|
+
|
|
38
|
+
**Documentation Queries:**
|
|
39
|
+
- `mcp://context7/ui/bootstrap` - bootstrap best practices
|
|
40
|
+
- `mcp://context7/ui/tailwind` - tailwind best practices
|
|
41
|
+
- `mcp://context7/frontend/design-systems` - design systems best practices
|
|
42
|
+
- `mcp://context7/css/frameworks` - frameworks best practices
|
|
43
|
+
|
|
44
|
+
**Why This is Required:**
|
|
45
|
+
- Ensures adherence to current industry standards and best practices
|
|
46
|
+
- Prevents outdated or incorrect implementation patterns
|
|
47
|
+
- Provides access to latest framework/tool documentation
|
|
48
|
+
- Reduces errors from stale knowledge or assumptions
|
|
49
|
+
|
|
50
|
+
|
|
34
51
|
Task: Create TailwindCSS design system with custom color palette, typography scale, and component library
|
|
35
52
|
Agent: tailwindcss-expert
|
|
36
53
|
Parameters: theme=modern, utilities=custom-spacing,gradients,animations, components=buttons,cards,forms, plugins=forms,typography
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Pre-Agent Context7 Hook
|
|
5
|
+
*
|
|
6
|
+
* MANDATORY: This hook enforces Context7 documentation queries BEFORE agent invocation.
|
|
7
|
+
*
|
|
8
|
+
* Workflow:
|
|
9
|
+
* 1. Intercept agent invocation (e.g., @aws-cloud-architect)
|
|
10
|
+
* 2. Extract agent file path from .claude/agents/{category}/{agent}.md
|
|
11
|
+
* 3. Parse "Documentation Queries" section
|
|
12
|
+
* 4. Query Context7 MCP for each link
|
|
13
|
+
* 5. Inject results into agent context
|
|
14
|
+
* 6. Allow agent to proceed with Context7 knowledge
|
|
15
|
+
*
|
|
16
|
+
* Zero Tolerance: If Context7 query fails, agent invocation STOPS.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
const fs = require('fs');
|
|
20
|
+
const path = require('path');
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Parse agent invocation
|
|
24
|
+
* @param {string} agentInvocation - e.g., "@aws-cloud-architect design VPC"
|
|
25
|
+
* @returns {object} { agentName, task }
|
|
26
|
+
*/
|
|
27
|
+
function parseAgentInvocation(agentInvocation) {
|
|
28
|
+
// Remove @ symbol and split
|
|
29
|
+
const cleaned = agentInvocation.replace(/^@/, '');
|
|
30
|
+
const parts = cleaned.split(/\s+/);
|
|
31
|
+
const agentName = parts[0];
|
|
32
|
+
const task = parts.slice(1).join(' ');
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
agentName,
|
|
36
|
+
task,
|
|
37
|
+
fullInvocation: agentInvocation
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Find agent file in .claude/agents/
|
|
43
|
+
* @param {string} agentName - Agent name (aws-cloud-architect, test-runner, etc.)
|
|
44
|
+
* @returns {string|null} - Path to agent file or null
|
|
45
|
+
*/
|
|
46
|
+
function findAgentFile(agentName) {
|
|
47
|
+
const baseDir = path.join(process.cwd(), '.claude', 'agents');
|
|
48
|
+
|
|
49
|
+
// Search recursively in all subdirectories
|
|
50
|
+
function searchDir(dir) {
|
|
51
|
+
if (!fs.existsSync(dir)) return null;
|
|
52
|
+
|
|
53
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
54
|
+
|
|
55
|
+
for (const entry of entries) {
|
|
56
|
+
const fullPath = path.join(dir, entry.name);
|
|
57
|
+
|
|
58
|
+
if (entry.isDirectory()) {
|
|
59
|
+
const found = searchDir(fullPath);
|
|
60
|
+
if (found) return found;
|
|
61
|
+
} else if (entry.isFile() && entry.name.endsWith('.md')) {
|
|
62
|
+
// Check if filename matches (with or without .md extension)
|
|
63
|
+
const basename = path.basename(entry.name, '.md');
|
|
64
|
+
if (basename === agentName || basename.replace(/-/g, '_') === agentName) {
|
|
65
|
+
return fullPath;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return searchDir(baseDir);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Extract Documentation Queries from agent file
|
|
78
|
+
* @param {string} filePath - Path to agent .md file
|
|
79
|
+
* @returns {Array<{url: string, description: string}>}
|
|
80
|
+
*/
|
|
81
|
+
function extractDocumentationQueries(filePath) {
|
|
82
|
+
const content = fs.readFileSync(filePath, 'utf8');
|
|
83
|
+
const queries = [];
|
|
84
|
+
|
|
85
|
+
// Find the Documentation Queries section (agent format)
|
|
86
|
+
const querySection = content.match(/\*\*Documentation Queries:\*\*\s*\n([\s\S]*?)(?=\n\n|\*\*|##|$)/);
|
|
87
|
+
|
|
88
|
+
if (!querySection) {
|
|
89
|
+
return queries; // No Documentation Queries section found
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Extract each mcp://context7/... line
|
|
93
|
+
const lines = querySection[1].split('\n');
|
|
94
|
+
for (const line of lines) {
|
|
95
|
+
const match = line.match(/`(mcp:\/\/context7\/[^`]+)`\s*-\s*(.+)/);
|
|
96
|
+
if (match) {
|
|
97
|
+
queries.push({
|
|
98
|
+
url: match[1],
|
|
99
|
+
description: match[2].trim()
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return queries;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Query Context7 MCP server
|
|
109
|
+
* @param {string} mcpUrl - e.g., "mcp://context7/aws/compute"
|
|
110
|
+
* @returns {Promise<object>} - Context7 response
|
|
111
|
+
*/
|
|
112
|
+
async function queryContext7(mcpUrl) {
|
|
113
|
+
// Parse MCP URL: mcp://context7/category/topic
|
|
114
|
+
const urlMatch = mcpUrl.match(/mcp:\/\/context7\/(.+)/);
|
|
115
|
+
if (!urlMatch) {
|
|
116
|
+
throw new Error(`Invalid Context7 URL format: ${mcpUrl}`);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const topicPath = urlMatch[1]; // e.g., "aws/compute"
|
|
120
|
+
|
|
121
|
+
// In real implementation, this would call the MCP server
|
|
122
|
+
// For now, return a placeholder that instructs Claude to query
|
|
123
|
+
return {
|
|
124
|
+
url: mcpUrl,
|
|
125
|
+
topic: topicPath,
|
|
126
|
+
instruction: `MANDATORY: Query Context7 MCP for topic "${topicPath}" before implementing solution.`,
|
|
127
|
+
placeholder: true
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Main hook execution
|
|
133
|
+
* @param {string} agentInvocation - Full agent invocation from user
|
|
134
|
+
*/
|
|
135
|
+
async function main(agentInvocation) {
|
|
136
|
+
console.log('\nš Context7 Pre-Agent Hook Activated\n');
|
|
137
|
+
|
|
138
|
+
// Parse agent invocation
|
|
139
|
+
const { agentName, task, fullInvocation } = parseAgentInvocation(agentInvocation || process.argv[2] || '');
|
|
140
|
+
|
|
141
|
+
console.log(`š¤ Agent: @${agentName}`);
|
|
142
|
+
if (task) {
|
|
143
|
+
console.log(` Task: ${task}`);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Find agent file
|
|
147
|
+
const agentFile = findAgentFile(agentName);
|
|
148
|
+
if (!agentFile) {
|
|
149
|
+
console.log(`\nā ļø Warning: Agent file not found for @${agentName}`);
|
|
150
|
+
console.log(` Searched: .claude/agents/**/${agentName}.md`);
|
|
151
|
+
console.log(` Proceeding without Context7 enforcement (agent may not exist)\n`);
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
console.log(` File: ${path.relative(process.cwd(), agentFile)}`);
|
|
156
|
+
|
|
157
|
+
// Extract Documentation Queries
|
|
158
|
+
const queries = extractDocumentationQueries(agentFile);
|
|
159
|
+
|
|
160
|
+
if (queries.length === 0) {
|
|
161
|
+
console.log(`\nā CRITICAL: No Documentation Queries found in agent file!`);
|
|
162
|
+
console.log(` This violates Context7 enforcement policy.`);
|
|
163
|
+
console.log(` ALL agents MUST have Documentation Queries section.`);
|
|
164
|
+
console.log(`\n Please add to ${path.basename(agentFile)}:`);
|
|
165
|
+
console.log(` **Documentation Queries:**`);
|
|
166
|
+
console.log(` - \`mcp://context7/...\` - Description`);
|
|
167
|
+
console.log(`\n Blocking agent invocation until fixed.\n`);
|
|
168
|
+
process.exit(1);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
console.log(`\nš Context7 Documentation Queries Required: ${queries.length}\n`);
|
|
172
|
+
|
|
173
|
+
// Query Context7 for each link
|
|
174
|
+
const results = [];
|
|
175
|
+
for (const query of queries) {
|
|
176
|
+
console.log(` ā ${query.url}`);
|
|
177
|
+
console.log(` ${query.description}`);
|
|
178
|
+
|
|
179
|
+
try {
|
|
180
|
+
const result = await queryContext7(query.url);
|
|
181
|
+
results.push(result);
|
|
182
|
+
} catch (error) {
|
|
183
|
+
console.log(`\nā Context7 query FAILED: ${error.message}`);
|
|
184
|
+
console.log(` Cannot proceed without Context7 documentation.`);
|
|
185
|
+
console.log(` Please ensure Context7 MCP server is running.\n`);
|
|
186
|
+
process.exit(1);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
console.log(`\nā
Context7 Queries Complete\n`);
|
|
191
|
+
console.log(`š REMINDER: @${agentName} MUST use Context7 documentation:`);
|
|
192
|
+
console.log(` ⢠Apply patterns from Context7 examples`);
|
|
193
|
+
console.log(` ⢠Verify API signatures against Context7 results`);
|
|
194
|
+
console.log(` ⢠Follow best practices documented in Context7`);
|
|
195
|
+
console.log(` ⢠Flag any conflicts between training data and Context7`);
|
|
196
|
+
console.log(`\nš Proceeding with agent invocation...\n`);
|
|
197
|
+
|
|
198
|
+
// In production, this would inject Context7 results into agent's context
|
|
199
|
+
// For now, we output instruction for Claude to see
|
|
200
|
+
if (results.length > 0 && results[0].placeholder) {
|
|
201
|
+
console.log(`ā” ACTION REQUIRED FOR @${agentName}:`);
|
|
202
|
+
console.log(` Before implementing "${task || 'task'}", you MUST:`);
|
|
203
|
+
for (const result of results) {
|
|
204
|
+
console.log(` ⢠${result.instruction}`);
|
|
205
|
+
}
|
|
206
|
+
console.log();
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// Execute if run directly
|
|
211
|
+
if (require.main === module) {
|
|
212
|
+
const agentInvocation = process.argv.slice(2).join(' ');
|
|
213
|
+
main(agentInvocation).catch(error => {
|
|
214
|
+
console.error('\nā Hook execution failed:', error.message);
|
|
215
|
+
process.exit(1);
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
module.exports = {
|
|
220
|
+
parseAgentInvocation,
|
|
221
|
+
findAgentFile,
|
|
222
|
+
extractDocumentationQueries,
|
|
223
|
+
queryContext7
|
|
224
|
+
};
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Pre-Command Context7 Hook
|
|
5
|
+
*
|
|
6
|
+
* MANDATORY: This hook enforces Context7 documentation queries BEFORE command execution.
|
|
7
|
+
*
|
|
8
|
+
* Workflow:
|
|
9
|
+
* 1. Intercept command execution (e.g., /pm:epic-decompose)
|
|
10
|
+
* 2. Extract command file path from .claude/commands/{category}/{command}.md
|
|
11
|
+
* 3. Parse "Documentation Queries" section
|
|
12
|
+
* 4. Query Context7 MCP for each link
|
|
13
|
+
* 5. Inject results into execution context
|
|
14
|
+
* 6. Allow command to proceed with Context7 knowledge
|
|
15
|
+
*
|
|
16
|
+
* Zero Tolerance: If Context7 query fails, execution STOPS.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
const fs = require('fs');
|
|
20
|
+
const path = require('path');
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Extract command metadata from invocation
|
|
24
|
+
* @param {string} commandInvocation - e.g., "/pm:epic-decompose feature-name"
|
|
25
|
+
* @returns {object} { category, command, args }
|
|
26
|
+
*/
|
|
27
|
+
function parseCommandInvocation(commandInvocation) {
|
|
28
|
+
// Remove leading slash and split
|
|
29
|
+
const cleaned = commandInvocation.replace(/^\//, '');
|
|
30
|
+
const [categoryCommand, ...args] = cleaned.split(/\s+/);
|
|
31
|
+
const [category, command] = categoryCommand.split(':');
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
category: category || 'pm', // Default to pm if no category
|
|
35
|
+
command: command || categoryCommand,
|
|
36
|
+
args: args,
|
|
37
|
+
fullCommand: categoryCommand
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Find command file in .claude/commands/
|
|
43
|
+
* @param {string} category - Command category (pm, azure, cloud, etc.)
|
|
44
|
+
* @param {string} command - Command name (epic-decompose, issue-start, etc.)
|
|
45
|
+
* @returns {string|null} - Path to command file or null
|
|
46
|
+
*/
|
|
47
|
+
function findCommandFile(category, command) {
|
|
48
|
+
const baseDir = path.join(process.cwd(), '.claude', 'commands');
|
|
49
|
+
|
|
50
|
+
// Try exact match first
|
|
51
|
+
let commandPath = path.join(baseDir, category, `${command}.md`);
|
|
52
|
+
if (fs.existsSync(commandPath)) {
|
|
53
|
+
return commandPath;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Try with underscores (epic-decompose ā epic_decompose)
|
|
57
|
+
const underscored = command.replace(/-/g, '_');
|
|
58
|
+
commandPath = path.join(baseDir, category, `${underscored}.md`);
|
|
59
|
+
if (fs.existsSync(commandPath)) {
|
|
60
|
+
return commandPath;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Try without category prefix if command includes it
|
|
64
|
+
if (command.includes('-')) {
|
|
65
|
+
const [, actualCommand] = command.split('-', 2);
|
|
66
|
+
if (actualCommand) {
|
|
67
|
+
commandPath = path.join(baseDir, category, `${actualCommand}.md`);
|
|
68
|
+
if (fs.existsSync(commandPath)) {
|
|
69
|
+
return commandPath;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Extract Documentation Queries from command file
|
|
79
|
+
* @param {string} filePath - Path to command .md file
|
|
80
|
+
* @returns {Array<{url: string, description: string}>}
|
|
81
|
+
*/
|
|
82
|
+
function extractDocumentationQueries(filePath) {
|
|
83
|
+
const content = fs.readFileSync(filePath, 'utf8');
|
|
84
|
+
const queries = [];
|
|
85
|
+
|
|
86
|
+
// Find the Documentation Queries section
|
|
87
|
+
const querySection = content.match(/\*\*Documentation Queries:\*\*\s*\n([\s\S]*?)(?=\n\n|\*\*Why This is Required|\n##|$)/);
|
|
88
|
+
|
|
89
|
+
if (!querySection) {
|
|
90
|
+
return queries; // No Documentation Queries section found
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Extract each mcp://context7/... line
|
|
94
|
+
const lines = querySection[1].split('\n');
|
|
95
|
+
for (const line of lines) {
|
|
96
|
+
const match = line.match(/`(mcp:\/\/context7\/[^`]+)`\s*-\s*(.+)/);
|
|
97
|
+
if (match) {
|
|
98
|
+
queries.push({
|
|
99
|
+
url: match[1],
|
|
100
|
+
description: match[2].trim()
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return queries;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Query Context7 MCP server
|
|
110
|
+
* @param {string} mcpUrl - e.g., "mcp://context7/agile/epic-decomposition"
|
|
111
|
+
* @returns {Promise<object>} - Context7 response
|
|
112
|
+
*/
|
|
113
|
+
async function queryContext7(mcpUrl) {
|
|
114
|
+
// Parse MCP URL: mcp://context7/category/topic
|
|
115
|
+
const urlMatch = mcpUrl.match(/mcp:\/\/context7\/(.+)/);
|
|
116
|
+
if (!urlMatch) {
|
|
117
|
+
throw new Error(`Invalid Context7 URL format: ${mcpUrl}`);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const topicPath = urlMatch[1]; // e.g., "agile/epic-decomposition"
|
|
121
|
+
|
|
122
|
+
// In real implementation, this would call the MCP server
|
|
123
|
+
// For now, return a placeholder that instructs Claude to query
|
|
124
|
+
return {
|
|
125
|
+
url: mcpUrl,
|
|
126
|
+
topic: topicPath,
|
|
127
|
+
instruction: `MANDATORY: Query Context7 MCP for topic "${topicPath}" before proceeding with implementation.`,
|
|
128
|
+
placeholder: true
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Main hook execution
|
|
134
|
+
* @param {string} commandInvocation - Full command string from user
|
|
135
|
+
*/
|
|
136
|
+
async function main(commandInvocation) {
|
|
137
|
+
console.log('\nš Context7 Pre-Command Hook Activated\n');
|
|
138
|
+
|
|
139
|
+
// Parse command
|
|
140
|
+
const { category, command, args, fullCommand } = parseCommandInvocation(commandInvocation || process.argv[2] || '');
|
|
141
|
+
|
|
142
|
+
console.log(`š Command: /${fullCommand}`);
|
|
143
|
+
console.log(` Category: ${category}`);
|
|
144
|
+
console.log(` Command: ${command}`);
|
|
145
|
+
if (args.length > 0) {
|
|
146
|
+
console.log(` Arguments: ${args.join(' ')}`);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Find command file
|
|
150
|
+
const commandFile = findCommandFile(category, command);
|
|
151
|
+
if (!commandFile) {
|
|
152
|
+
console.log(`\nā ļø Warning: Command file not found for /${fullCommand}`);
|
|
153
|
+
console.log(` Searched: .claude/commands/${category}/${command}.md`);
|
|
154
|
+
console.log(` Proceeding without Context7 enforcement (file may not exist yet)\n`);
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
console.log(` File: ${path.relative(process.cwd(), commandFile)}`);
|
|
159
|
+
|
|
160
|
+
// Extract Documentation Queries
|
|
161
|
+
const queries = extractDocumentationQueries(commandFile);
|
|
162
|
+
|
|
163
|
+
if (queries.length === 0) {
|
|
164
|
+
console.log(`\nā CRITICAL: No Documentation Queries found in command file!`);
|
|
165
|
+
console.log(` This violates Context7 enforcement policy.`);
|
|
166
|
+
console.log(` ALL commands MUST have Documentation Queries section.`);
|
|
167
|
+
console.log(`\n Please add to ${path.basename(commandFile)}:`);
|
|
168
|
+
console.log(` ## Required Documentation Access`);
|
|
169
|
+
console.log(` **MANDATORY:** Before [action], query Context7 for best practices:`);
|
|
170
|
+
console.log(` **Documentation Queries:**`);
|
|
171
|
+
console.log(` - \`mcp://context7/...\` - Description`);
|
|
172
|
+
console.log(`\n Blocking execution until fixed.\n`);
|
|
173
|
+
process.exit(1);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
console.log(`\nš Context7 Documentation Queries Required: ${queries.length}\n`);
|
|
177
|
+
|
|
178
|
+
// Query Context7 for each link
|
|
179
|
+
const results = [];
|
|
180
|
+
for (const query of queries) {
|
|
181
|
+
console.log(` ā ${query.url}`);
|
|
182
|
+
console.log(` ${query.description}`);
|
|
183
|
+
|
|
184
|
+
try {
|
|
185
|
+
const result = await queryContext7(query.url);
|
|
186
|
+
results.push(result);
|
|
187
|
+
} catch (error) {
|
|
188
|
+
console.log(`\nā Context7 query FAILED: ${error.message}`);
|
|
189
|
+
console.log(` Cannot proceed without Context7 documentation.`);
|
|
190
|
+
console.log(` Please ensure Context7 MCP server is running.\n`);
|
|
191
|
+
process.exit(1);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
console.log(`\nā
Context7 Queries Complete\n`);
|
|
196
|
+
console.log(`š REMINDER: You MUST use Context7 documentation in your implementation:`);
|
|
197
|
+
console.log(` ⢠Apply patterns from Context7 examples`);
|
|
198
|
+
console.log(` ⢠Verify API signatures against Context7 results`);
|
|
199
|
+
console.log(` ⢠Follow best practices documented in Context7`);
|
|
200
|
+
console.log(` ⢠Flag any conflicts between training data and Context7`);
|
|
201
|
+
console.log(`\nš Proceeding with command execution...\n`);
|
|
202
|
+
|
|
203
|
+
// In production, this would inject Context7 results into Claude's context
|
|
204
|
+
// For now, we output instruction for Claude to see
|
|
205
|
+
if (results.length > 0 && results[0].placeholder) {
|
|
206
|
+
console.log(`ā” ACTION REQUIRED:`);
|
|
207
|
+
console.log(` Before implementing /${fullCommand}, you MUST:`);
|
|
208
|
+
for (const result of results) {
|
|
209
|
+
console.log(` ⢠${result.instruction}`);
|
|
210
|
+
}
|
|
211
|
+
console.log();
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// Execute if run directly
|
|
216
|
+
if (require.main === module) {
|
|
217
|
+
const commandInvocation = process.argv.slice(2).join(' ');
|
|
218
|
+
main(commandInvocation).catch(error => {
|
|
219
|
+
console.error('\nā Hook execution failed:', error.message);
|
|
220
|
+
process.exit(1);
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
module.exports = {
|
|
225
|
+
parseCommandInvocation,
|
|
226
|
+
findCommandFile,
|
|
227
|
+
extractDocumentationQueries,
|
|
228
|
+
queryContext7
|
|
229
|
+
};
|