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.
Files changed (134) hide show
  1. package/autopm/.claude/agents/cloud/gcp-cloud-functions-engineer.md +5 -10
  2. package/autopm/.claude/agents/cloud/gemini-api-expert.md +1 -1
  3. package/autopm/.claude/agents/cloud/openai-python-expert.md +1 -1
  4. package/autopm/.claude/agents/cloud/terraform-infrastructure-expert.md +7 -11
  5. package/autopm/.claude/agents/core/mcp-manager.md +7 -0
  6. package/autopm/.claude/agents/data/airflow-orchestration-expert.md +1 -1
  7. package/autopm/.claude/agents/data/kedro-pipeline-expert.md +1 -1
  8. package/autopm/.claude/agents/data/langgraph-workflow-expert.md +1 -1
  9. package/autopm/.claude/agents/databases/bigquery-expert.md +1 -1
  10. package/autopm/.claude/agents/databases/cosmosdb-expert.md +1 -1
  11. package/autopm/.claude/agents/databases/mongodb-expert.md +1 -1
  12. package/autopm/.claude/agents/databases/postgresql-expert.md +1 -1
  13. package/autopm/.claude/agents/databases/redis-expert.md +1 -1
  14. package/autopm/.claude/agents/decision-matrices/playwright-testing-selection.md +6 -0
  15. package/autopm/.claude/agents/decision-matrices/python-backend-selection.md +7 -0
  16. package/autopm/.claude/agents/decision-matrices/ui-framework-selection.md +7 -0
  17. package/autopm/.claude/agents/devops/azure-devops-specialist.md +1 -1
  18. package/autopm/.claude/agents/devops/github-operations-specialist.md +7 -0
  19. package/autopm/.claude/agents/devops/mcp-context-manager.md +7 -0
  20. package/autopm/.claude/agents/devops/ssh-operations-expert.md +1 -1
  21. package/autopm/.claude/agents/devops/traefik-proxy-expert.md +1 -1
  22. package/autopm/.claude/agents/frameworks/nats-messaging-expert.md +1 -1
  23. package/autopm/.claude/agents/frameworks/react-frontend-engineer.md +1 -1
  24. package/autopm/.claude/agents/languages/bash-scripting-expert.md +1 -1
  25. package/autopm/.claude/agents/languages/javascript-frontend-engineer.md +1 -1
  26. package/autopm/.claude/agents/languages/nodejs-backend-engineer.md +9 -6
  27. package/autopm/.claude/agents/languages/python-backend-engineer.md +1 -1
  28. package/autopm/.claude/commands/ai/langgraph-workflow.md +17 -0
  29. package/autopm/.claude/commands/ai/openai-chat.md +17 -0
  30. package/autopm/.claude/commands/azure/active-work.md +17 -0
  31. package/autopm/.claude/commands/azure/aliases.md +17 -0
  32. package/autopm/.claude/commands/azure/blocked-items.md +17 -0
  33. package/autopm/.claude/commands/azure/clean.md +17 -0
  34. package/autopm/.claude/commands/azure/docs-query.md +17 -0
  35. package/autopm/.claude/commands/azure/feature-decompose.md +17 -0
  36. package/autopm/.claude/commands/azure/feature-list.md +17 -0
  37. package/autopm/.claude/commands/azure/feature-new.md +17 -0
  38. package/autopm/.claude/commands/azure/feature-show.md +17 -0
  39. package/autopm/.claude/commands/azure/feature-start.md +17 -0
  40. package/autopm/.claude/commands/azure/fix-integration-example.md +17 -0
  41. package/autopm/.claude/commands/azure/help.md +17 -0
  42. package/autopm/.claude/commands/azure/import-us.md +17 -0
  43. package/autopm/.claude/commands/azure/init.md +17 -0
  44. package/autopm/.claude/commands/azure/next-task.md +17 -0
  45. package/autopm/.claude/commands/azure/search.md +17 -0
  46. package/autopm/.claude/commands/azure/sprint-status.md +17 -0
  47. package/autopm/.claude/commands/azure/standup.md +17 -0
  48. package/autopm/.claude/commands/azure/sync-all.md +17 -0
  49. package/autopm/.claude/commands/azure/task-analyze.md +17 -0
  50. package/autopm/.claude/commands/azure/task-close.md +17 -0
  51. package/autopm/.claude/commands/azure/task-edit.md +17 -0
  52. package/autopm/.claude/commands/azure/task-list.md +17 -0
  53. package/autopm/.claude/commands/azure/task-new.md +17 -0
  54. package/autopm/.claude/commands/azure/task-reopen.md +17 -0
  55. package/autopm/.claude/commands/azure/task-show.md +17 -0
  56. package/autopm/.claude/commands/azure/task-start.md +17 -0
  57. package/autopm/.claude/commands/azure/task-status.md +17 -0
  58. package/autopm/.claude/commands/azure/task-sync.md +17 -0
  59. package/autopm/.claude/commands/azure/us-edit.md +17 -0
  60. package/autopm/.claude/commands/azure/us-list.md +17 -0
  61. package/autopm/.claude/commands/azure/us-new.md +17 -0
  62. package/autopm/.claude/commands/azure/us-parse.md +17 -0
  63. package/autopm/.claude/commands/azure/us-show.md +17 -0
  64. package/autopm/.claude/commands/azure/us-status.md +17 -0
  65. package/autopm/.claude/commands/azure/validate.md +17 -0
  66. package/autopm/.claude/commands/azure/work-item-sync.md +17 -0
  67. package/autopm/.claude/commands/cloud/infra-deploy.md +17 -0
  68. package/autopm/.claude/commands/config/toggle-features.md +15 -0
  69. package/autopm/.claude/commands/context/create.md +16 -0
  70. package/autopm/.claude/commands/context/prime.md +16 -0
  71. package/autopm/.claude/commands/context/update.md +16 -0
  72. package/autopm/.claude/commands/github/workflow-create.md +17 -0
  73. package/autopm/.claude/commands/infrastructure/ssh-security.md +17 -0
  74. package/autopm/.claude/commands/infrastructure/traefik-setup.md +17 -0
  75. package/autopm/.claude/commands/kubernetes/deploy.md +16 -0
  76. package/autopm/.claude/commands/mcp/context-setup.md +17 -0
  77. package/autopm/.claude/commands/mcp/docs-refresh.md +17 -0
  78. package/autopm/.claude/commands/playwright/test-scaffold.md +17 -0
  79. package/autopm/.claude/commands/pm/blocked.md +17 -0
  80. package/autopm/.claude/commands/pm/clean.md +17 -0
  81. package/autopm/.claude/commands/pm/context.md +17 -0
  82. package/autopm/.claude/commands/pm/epic-close.md +17 -0
  83. package/autopm/.claude/commands/pm/epic-decompose.md +16 -0
  84. package/autopm/.claude/commands/pm/epic-edit.md +17 -0
  85. package/autopm/.claude/commands/pm/epic-list.md +17 -0
  86. package/autopm/.claude/commands/pm/epic-merge.md +17 -0
  87. package/autopm/.claude/commands/pm/epic-oneshot.md +17 -0
  88. package/autopm/.claude/commands/pm/epic-refresh.md +17 -0
  89. package/autopm/.claude/commands/pm/epic-show.md +17 -0
  90. package/autopm/.claude/commands/pm/epic-split.md +17 -0
  91. package/autopm/.claude/commands/pm/epic-start.md +17 -0
  92. package/autopm/.claude/commands/pm/epic-status.md +17 -0
  93. package/autopm/.claude/commands/pm/epic-sync-modular.md +17 -0
  94. package/autopm/.claude/commands/pm/epic-sync-original.md +17 -0
  95. package/autopm/.claude/commands/pm/epic-sync.md +17 -0
  96. package/autopm/.claude/commands/pm/help.md +17 -0
  97. package/autopm/.claude/commands/pm/import.md +17 -0
  98. package/autopm/.claude/commands/pm/in-progress.md +17 -0
  99. package/autopm/.claude/commands/pm/init.md +17 -0
  100. package/autopm/.claude/commands/pm/issue-analyze.md +17 -0
  101. package/autopm/.claude/commands/pm/issue-close.md +17 -0
  102. package/autopm/.claude/commands/pm/issue-edit.md +17 -0
  103. package/autopm/.claude/commands/pm/issue-reopen.md +17 -0
  104. package/autopm/.claude/commands/pm/issue-show.md +17 -0
  105. package/autopm/.claude/commands/pm/issue-start.md +16 -0
  106. package/autopm/.claude/commands/pm/issue-status.md +17 -0
  107. package/autopm/.claude/commands/pm/issue-sync.md +17 -0
  108. package/autopm/.claude/commands/pm/next.md +17 -0
  109. package/autopm/.claude/commands/pm/prd-edit.md +17 -0
  110. package/autopm/.claude/commands/pm/prd-list.md +17 -0
  111. package/autopm/.claude/commands/pm/prd-new.md +16 -0
  112. package/autopm/.claude/commands/pm/prd-parse.md +17 -0
  113. package/autopm/.claude/commands/pm/prd-status.md +17 -0
  114. package/autopm/.claude/commands/pm/search.md +17 -0
  115. package/autopm/.claude/commands/pm/standup.md +17 -0
  116. package/autopm/.claude/commands/pm/status.md +17 -0
  117. package/autopm/.claude/commands/pm/sync.md +17 -0
  118. package/autopm/.claude/commands/pm/test-reference-update.md +17 -0
  119. package/autopm/.claude/commands/pm/validate.md +17 -0
  120. package/autopm/.claude/commands/pm/what-next.md +17 -0
  121. package/autopm/.claude/commands/python/api-scaffold.md +17 -0
  122. package/autopm/.claude/commands/python/docs-query.md +17 -0
  123. package/autopm/.claude/commands/react/app-scaffold.md +17 -0
  124. package/autopm/.claude/commands/testing/prime.md +17 -0
  125. package/autopm/.claude/commands/testing/run.md +17 -0
  126. package/autopm/.claude/commands/ui/bootstrap-scaffold.md +17 -0
  127. package/autopm/.claude/commands/ui/tailwind-system.md +17 -0
  128. package/autopm/.claude/hooks/context7-reminder.md +29 -0
  129. package/autopm/.claude/hooks/pre-agent-context7.js +224 -0
  130. package/autopm/.claude/hooks/pre-command-context7.js +229 -0
  131. package/autopm/.claude/hooks/unified-context7-enforcement.sh +38 -0
  132. package/autopm/.claude/rules/context7-enforcement.md +327 -0
  133. package/package.json +1 -1
  134. 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,29 @@
1
+ # šŸ”“ MANDATORY: Context7 Query Required
2
+
3
+ **BEFORE proceeding with this command/agent, you MUST:**
4
+
5
+ 1. **Read** the command/agent file to find `**Documentation Queries:**` section
6
+ 2. **Query Context7 MCP** for EACH listed topic
7
+ 3. **Verify** patterns against live documentation
8
+ 4. **Apply** Context7 guidance in your implementation
9
+
10
+ ## Why This Matters
11
+
12
+ - **Training data is STALE** - APIs change, best practices evolve
13
+ - **Context7 is CURRENT** - Live documentation, latest versions
14
+ - **Hallucinations PREVENTED** - Real examples, verified patterns
15
+ - **Quality GUARANTEED** - Industry-standard approaches
16
+
17
+ ## Zero Tolerance Policy
18
+
19
+ āŒ **NO** implementation without Context7 verification
20
+ āŒ **NO** "I remember how this works"
21
+ āŒ **NO** assumptions about API signatures
22
+ āœ… **ALWAYS** query Context7 first
23
+ āœ… **ALWAYS** verify against live docs
24
+ āœ… **ALWAYS** apply documented patterns
25
+
26
+ ---
27
+
28
+ *This reminder is shown by `.claude/hooks/` enforcement system*
29
+ *Defined in: `.claude/rules/context7-enforcement.md`*
@@ -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
+ };