@techwavedev/agi-agent-kit 1.1.3

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 (196) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/README.md +147 -0
  3. package/bin/init.js +471 -0
  4. package/package.json +36 -0
  5. package/templates/.agent/agents/backend-specialist.md +263 -0
  6. package/templates/.agent/agents/code-archaeologist.md +106 -0
  7. package/templates/.agent/agents/database-architect.md +226 -0
  8. package/templates/.agent/agents/debugger.md +225 -0
  9. package/templates/.agent/agents/devops-engineer.md +242 -0
  10. package/templates/.agent/agents/documentation-writer.md +104 -0
  11. package/templates/.agent/agents/explorer-agent.md +73 -0
  12. package/templates/.agent/agents/frontend-specialist.md +556 -0
  13. package/templates/.agent/agents/game-developer.md +162 -0
  14. package/templates/.agent/agents/mobile-developer.md +377 -0
  15. package/templates/.agent/agents/orchestrator.md +416 -0
  16. package/templates/.agent/agents/penetration-tester.md +188 -0
  17. package/templates/.agent/agents/performance-optimizer.md +187 -0
  18. package/templates/.agent/agents/product-manager.md +112 -0
  19. package/templates/.agent/agents/project-planner.md +403 -0
  20. package/templates/.agent/agents/qa-automation-engineer.md +109 -0
  21. package/templates/.agent/agents/security-auditor.md +170 -0
  22. package/templates/.agent/agents/seo-specialist.md +111 -0
  23. package/templates/.agent/agents/test-engineer.md +158 -0
  24. package/templates/.agent/rules/GEMINI.md +253 -0
  25. package/templates/.agent/workflows/brainstorm.md +113 -0
  26. package/templates/.agent/workflows/create.md +59 -0
  27. package/templates/.agent/workflows/debug.md +103 -0
  28. package/templates/.agent/workflows/deploy.md +176 -0
  29. package/templates/.agent/workflows/enhance.md +63 -0
  30. package/templates/.agent/workflows/orchestrate.md +237 -0
  31. package/templates/.agent/workflows/plan.md +89 -0
  32. package/templates/.agent/workflows/preview.md +81 -0
  33. package/templates/.agent/workflows/status.md +86 -0
  34. package/templates/.agent/workflows/test.md +144 -0
  35. package/templates/.agent/workflows/ui-ux-pro-max.md +296 -0
  36. package/templates/base/.env.example +54 -0
  37. package/templates/base/AGENTS.md +463 -0
  38. package/templates/base/requirements.txt +6 -0
  39. package/templates/base/skill-creator/LICENSE.txt +202 -0
  40. package/templates/base/skill-creator/SKILL_skillcreator.md +389 -0
  41. package/templates/base/skill-creator/references/output-patterns.md +82 -0
  42. package/templates/base/skill-creator/references/workflows.md +28 -0
  43. package/templates/base/skill-creator/scripts/init_skill.py +304 -0
  44. package/templates/base/skill-creator/scripts/package_skill.py +110 -0
  45. package/templates/base/skill-creator/scripts/quick_validate.py +95 -0
  46. package/templates/base/skill-creator/scripts/update_catalog.py +371 -0
  47. package/templates/skills/core/README.md +21 -0
  48. package/templates/skills/core/documentation/SKILL.md +351 -0
  49. package/templates/skills/core/documentation/references/best_practices.md +201 -0
  50. package/templates/skills/core/documentation/scripts/analyze_code.py +307 -0
  51. package/templates/skills/core/documentation/scripts/detect_changes.py +460 -0
  52. package/templates/skills/core/documentation/scripts/generate_changelog.py +312 -0
  53. package/templates/skills/core/documentation/scripts/sync_docs.py +272 -0
  54. package/templates/skills/core/documentation/scripts/update_skill_docs.py +366 -0
  55. package/templates/skills/core/pdf-reader/SKILL.md +104 -0
  56. package/templates/skills/core/pdf-reader/references/pdf_libraries.md +83 -0
  57. package/templates/skills/core/pdf-reader/scripts/extract_text.py +295 -0
  58. package/templates/skills/core/qdrant-memory/SKILL.md +435 -0
  59. package/templates/skills/core/qdrant-memory/references/advanced_patterns.md +375 -0
  60. package/templates/skills/core/qdrant-memory/references/collection_schemas.md +229 -0
  61. package/templates/skills/core/qdrant-memory/references/complete_guide.md +724 -0
  62. package/templates/skills/core/qdrant-memory/references/embedding_models.md +325 -0
  63. package/templates/skills/core/qdrant-memory/scripts/benchmark_token_savings.py +640 -0
  64. package/templates/skills/core/qdrant-memory/scripts/embedding_utils.py +323 -0
  65. package/templates/skills/core/qdrant-memory/scripts/hybrid_search.py +214 -0
  66. package/templates/skills/core/qdrant-memory/scripts/init_collection.py +193 -0
  67. package/templates/skills/core/qdrant-memory/scripts/memory_retrieval.py +345 -0
  68. package/templates/skills/core/qdrant-memory/scripts/semantic_cache.py +282 -0
  69. package/templates/skills/core/qdrant-memory/scripts/test_skill.py +655 -0
  70. package/templates/skills/core/webcrawler/SKILL.md +292 -0
  71. package/templates/skills/core/webcrawler/references/advanced_crawling.md +181 -0
  72. package/templates/skills/core/webcrawler/scripts/crawl_docs.py +532 -0
  73. package/templates/skills/core/webcrawler/scripts/extract_page.py +189 -0
  74. package/templates/skills/core/webcrawler/scripts/filter_docs.py +200 -0
  75. package/templates/skills/knowledge/api-patterns/SKILL.md +81 -0
  76. package/templates/skills/knowledge/api-patterns/api-style.md +42 -0
  77. package/templates/skills/knowledge/api-patterns/auth.md +24 -0
  78. package/templates/skills/knowledge/api-patterns/documentation.md +26 -0
  79. package/templates/skills/knowledge/api-patterns/graphql.md +41 -0
  80. package/templates/skills/knowledge/api-patterns/rate-limiting.md +31 -0
  81. package/templates/skills/knowledge/api-patterns/response.md +37 -0
  82. package/templates/skills/knowledge/api-patterns/rest.md +40 -0
  83. package/templates/skills/knowledge/api-patterns/scripts/api_validator.py +211 -0
  84. package/templates/skills/knowledge/api-patterns/security-testing.md +122 -0
  85. package/templates/skills/knowledge/api-patterns/trpc.md +41 -0
  86. package/templates/skills/knowledge/api-patterns/versioning.md +22 -0
  87. package/templates/skills/knowledge/app-builder/SKILL.md +75 -0
  88. package/templates/skills/knowledge/app-builder/agent-coordination.md +71 -0
  89. package/templates/skills/knowledge/app-builder/feature-building.md +53 -0
  90. package/templates/skills/knowledge/app-builder/project-detection.md +34 -0
  91. package/templates/skills/knowledge/app-builder/scaffolding.md +118 -0
  92. package/templates/skills/knowledge/app-builder/tech-stack.md +40 -0
  93. package/templates/skills/knowledge/app-builder/templates/SKILL.md +39 -0
  94. package/templates/skills/knowledge/app-builder/templates/astro-static/TEMPLATE.md +76 -0
  95. package/templates/skills/knowledge/app-builder/templates/chrome-extension/TEMPLATE.md +92 -0
  96. package/templates/skills/knowledge/app-builder/templates/cli-tool/TEMPLATE.md +88 -0
  97. package/templates/skills/knowledge/app-builder/templates/electron-desktop/TEMPLATE.md +88 -0
  98. package/templates/skills/knowledge/app-builder/templates/express-api/TEMPLATE.md +83 -0
  99. package/templates/skills/knowledge/app-builder/templates/flutter-app/TEMPLATE.md +90 -0
  100. package/templates/skills/knowledge/app-builder/templates/monorepo-turborepo/TEMPLATE.md +90 -0
  101. package/templates/skills/knowledge/app-builder/templates/nextjs-fullstack/TEMPLATE.md +82 -0
  102. package/templates/skills/knowledge/app-builder/templates/nextjs-saas/TEMPLATE.md +100 -0
  103. package/templates/skills/knowledge/app-builder/templates/nextjs-static/TEMPLATE.md +106 -0
  104. package/templates/skills/knowledge/app-builder/templates/nuxt-app/TEMPLATE.md +101 -0
  105. package/templates/skills/knowledge/app-builder/templates/python-fastapi/TEMPLATE.md +83 -0
  106. package/templates/skills/knowledge/app-builder/templates/react-native-app/TEMPLATE.md +93 -0
  107. package/templates/skills/knowledge/architecture/SKILL.md +55 -0
  108. package/templates/skills/knowledge/architecture/context-discovery.md +43 -0
  109. package/templates/skills/knowledge/architecture/examples.md +94 -0
  110. package/templates/skills/knowledge/architecture/pattern-selection.md +68 -0
  111. package/templates/skills/knowledge/architecture/patterns-reference.md +50 -0
  112. package/templates/skills/knowledge/architecture/trade-off-analysis.md +77 -0
  113. package/templates/skills/knowledge/bash-linux/SKILL.md +199 -0
  114. package/templates/skills/knowledge/behavioral-modes/SKILL.md +242 -0
  115. package/templates/skills/knowledge/brainstorming/SKILL.md +163 -0
  116. package/templates/skills/knowledge/brainstorming/dynamic-questioning.md +350 -0
  117. package/templates/skills/knowledge/clean-code/SKILL.md +201 -0
  118. package/templates/skills/knowledge/code-review-checklist/SKILL.md +109 -0
  119. package/templates/skills/knowledge/database-design/SKILL.md +52 -0
  120. package/templates/skills/knowledge/database-design/database-selection.md +43 -0
  121. package/templates/skills/knowledge/database-design/indexing.md +39 -0
  122. package/templates/skills/knowledge/database-design/migrations.md +48 -0
  123. package/templates/skills/knowledge/database-design/optimization.md +36 -0
  124. package/templates/skills/knowledge/database-design/orm-selection.md +30 -0
  125. package/templates/skills/knowledge/database-design/schema-design.md +56 -0
  126. package/templates/skills/knowledge/database-design/scripts/schema_validator.py +172 -0
  127. package/templates/skills/knowledge/deployment-procedures/SKILL.md +241 -0
  128. package/templates/skills/knowledge/doc.md +177 -0
  129. package/templates/skills/knowledge/documentation-templates/SKILL.md +194 -0
  130. package/templates/skills/knowledge/frontend-design/SKILL.md +396 -0
  131. package/templates/skills/knowledge/frontend-design/animation-guide.md +331 -0
  132. package/templates/skills/knowledge/frontend-design/color-system.md +311 -0
  133. package/templates/skills/knowledge/frontend-design/decision-trees.md +418 -0
  134. package/templates/skills/knowledge/frontend-design/motion-graphics.md +306 -0
  135. package/templates/skills/knowledge/frontend-design/scripts/accessibility_checker.py +183 -0
  136. package/templates/skills/knowledge/frontend-design/scripts/ux_audit.py +722 -0
  137. package/templates/skills/knowledge/frontend-design/typography-system.md +345 -0
  138. package/templates/skills/knowledge/frontend-design/ux-psychology.md +541 -0
  139. package/templates/skills/knowledge/frontend-design/visual-effects.md +383 -0
  140. package/templates/skills/knowledge/game-development/2d-games/SKILL.md +119 -0
  141. package/templates/skills/knowledge/game-development/3d-games/SKILL.md +135 -0
  142. package/templates/skills/knowledge/game-development/SKILL.md +167 -0
  143. package/templates/skills/knowledge/game-development/game-art/SKILL.md +185 -0
  144. package/templates/skills/knowledge/game-development/game-audio/SKILL.md +190 -0
  145. package/templates/skills/knowledge/game-development/game-design/SKILL.md +129 -0
  146. package/templates/skills/knowledge/game-development/mobile-games/SKILL.md +108 -0
  147. package/templates/skills/knowledge/game-development/multiplayer/SKILL.md +132 -0
  148. package/templates/skills/knowledge/game-development/pc-games/SKILL.md +144 -0
  149. package/templates/skills/knowledge/game-development/vr-ar/SKILL.md +123 -0
  150. package/templates/skills/knowledge/game-development/web-games/SKILL.md +150 -0
  151. package/templates/skills/knowledge/geo-fundamentals/SKILL.md +156 -0
  152. package/templates/skills/knowledge/geo-fundamentals/scripts/geo_checker.py +289 -0
  153. package/templates/skills/knowledge/i18n-localization/SKILL.md +154 -0
  154. package/templates/skills/knowledge/i18n-localization/scripts/i18n_checker.py +241 -0
  155. package/templates/skills/knowledge/intelligent-routing/SKILL.md +334 -0
  156. package/templates/skills/knowledge/lint-and-validate/SKILL.md +45 -0
  157. package/templates/skills/knowledge/lint-and-validate/scripts/lint_runner.py +172 -0
  158. package/templates/skills/knowledge/lint-and-validate/scripts/type_coverage.py +173 -0
  159. package/templates/skills/knowledge/mcp-builder/SKILL.md +176 -0
  160. package/templates/skills/knowledge/mobile-design/SKILL.md +394 -0
  161. package/templates/skills/knowledge/mobile-design/decision-trees.md +516 -0
  162. package/templates/skills/knowledge/mobile-design/mobile-backend.md +491 -0
  163. package/templates/skills/knowledge/mobile-design/mobile-color-system.md +420 -0
  164. package/templates/skills/knowledge/mobile-design/mobile-debugging.md +122 -0
  165. package/templates/skills/knowledge/mobile-design/mobile-design-thinking.md +357 -0
  166. package/templates/skills/knowledge/mobile-design/mobile-navigation.md +458 -0
  167. package/templates/skills/knowledge/mobile-design/mobile-performance.md +767 -0
  168. package/templates/skills/knowledge/mobile-design/mobile-testing.md +356 -0
  169. package/templates/skills/knowledge/mobile-design/mobile-typography.md +433 -0
  170. package/templates/skills/knowledge/mobile-design/platform-android.md +666 -0
  171. package/templates/skills/knowledge/mobile-design/platform-ios.md +561 -0
  172. package/templates/skills/knowledge/mobile-design/scripts/mobile_audit.py +670 -0
  173. package/templates/skills/knowledge/mobile-design/touch-psychology.md +537 -0
  174. package/templates/skills/knowledge/nextjs-best-practices/SKILL.md +203 -0
  175. package/templates/skills/knowledge/nodejs-best-practices/SKILL.md +333 -0
  176. package/templates/skills/knowledge/parallel-agents/SKILL.md +175 -0
  177. package/templates/skills/knowledge/performance-profiling/SKILL.md +143 -0
  178. package/templates/skills/knowledge/performance-profiling/scripts/lighthouse_audit.py +76 -0
  179. package/templates/skills/knowledge/plan-writing/SKILL.md +152 -0
  180. package/templates/skills/knowledge/powershell-windows/SKILL.md +167 -0
  181. package/templates/skills/knowledge/python-patterns/SKILL.md +441 -0
  182. package/templates/skills/knowledge/react-patterns/SKILL.md +198 -0
  183. package/templates/skills/knowledge/red-team-tactics/SKILL.md +199 -0
  184. package/templates/skills/knowledge/seo-fundamentals/SKILL.md +129 -0
  185. package/templates/skills/knowledge/seo-fundamentals/scripts/seo_checker.py +219 -0
  186. package/templates/skills/knowledge/server-management/SKILL.md +161 -0
  187. package/templates/skills/knowledge/systematic-debugging/SKILL.md +109 -0
  188. package/templates/skills/knowledge/tailwind-patterns/SKILL.md +269 -0
  189. package/templates/skills/knowledge/tdd-workflow/SKILL.md +149 -0
  190. package/templates/skills/knowledge/testing-patterns/SKILL.md +178 -0
  191. package/templates/skills/knowledge/testing-patterns/scripts/test_runner.py +219 -0
  192. package/templates/skills/knowledge/vulnerability-scanner/SKILL.md +276 -0
  193. package/templates/skills/knowledge/vulnerability-scanner/checklists.md +121 -0
  194. package/templates/skills/knowledge/vulnerability-scanner/scripts/security_scan.py +458 -0
  195. package/templates/skills/knowledge/webapp-testing/SKILL.md +187 -0
  196. package/templates/skills/knowledge/webapp-testing/scripts/playwright_runner.py +173 -0
@@ -0,0 +1,189 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Script: extract_page.py
4
+ Purpose: Extract content from a single documentation page.
5
+
6
+ Usage:
7
+ python extract_page.py --url <page-url> [options]
8
+
9
+ Arguments:
10
+ --url, -u Page URL to extract (required)
11
+ --output, -o Output file (default: stdout)
12
+ --format, -f Output format: md or json (default: md)
13
+ --include-links Include internal links (default: true)
14
+
15
+ Exit Codes:
16
+ 0 - Success
17
+ 1 - Invalid arguments
18
+ 2 - Network error
19
+ 3 - No content found
20
+ """
21
+
22
+ import argparse
23
+ import json
24
+ import re
25
+ import sys
26
+ from datetime import datetime
27
+ from urllib.parse import urljoin, urlparse
28
+
29
+ try:
30
+ import requests
31
+ from bs4 import BeautifulSoup
32
+ import html2text
33
+ except ImportError as e:
34
+ print(json.dumps({
35
+ "status": "error",
36
+ "message": f"Missing dependency: {e}. Install with: pip install requests beautifulsoup4 html2text lxml"
37
+ }), file=sys.stderr)
38
+ sys.exit(1)
39
+
40
+
41
+ def extract_main_content(soup: BeautifulSoup) -> BeautifulSoup:
42
+ """Extract the main content area, removing navigation/sidebars."""
43
+ content_selectors = [
44
+ 'main', 'article', '[role="main"]', '.main-content', '.content',
45
+ '.documentation', '.docs-content', '.markdown-body', '#content',
46
+ '#main-content', '.post-content',
47
+ ]
48
+
49
+ for selector in content_selectors:
50
+ content = soup.select_one(selector)
51
+ if content:
52
+ return content
53
+
54
+ body = soup.find('body')
55
+ if body:
56
+ for selector in ['nav', 'header', 'footer', 'aside', '.sidebar',
57
+ '.navigation', '.nav', '.toc', '.menu']:
58
+ for element in body.select(selector):
59
+ element.decompose()
60
+ return body
61
+
62
+ return soup
63
+
64
+
65
+ def extract_title(soup: BeautifulSoup) -> str:
66
+ """Extract page title."""
67
+ h1 = soup.find('h1')
68
+ if h1:
69
+ return h1.get_text(strip=True)
70
+ title = soup.find('title')
71
+ if title:
72
+ text = title.get_text(strip=True)
73
+ for sep in [' |', ' -', ' ::']:
74
+ if sep in text:
75
+ text = text.split(sep)[0].strip()
76
+ return text
77
+ return 'Untitled'
78
+
79
+
80
+ def html_to_markdown(soup: BeautifulSoup, url: str) -> str:
81
+ """Convert HTML content to clean markdown."""
82
+ converter = html2text.HTML2Text()
83
+ converter.ignore_links = False
84
+ converter.ignore_images = False
85
+ converter.body_width = 0
86
+ converter.unicode_snob = True
87
+
88
+ html_content = str(soup)
89
+ markdown = converter.handle(html_content)
90
+
91
+ # Clean up excessive whitespace
92
+ markdown = re.sub(r'\n{3,}', '\n\n', markdown)
93
+
94
+ # Add source metadata
95
+ header = f"---\nsource: {url}\ncrawled: {datetime.now().isoformat()}\n---\n\n"
96
+
97
+ return header + markdown.strip()
98
+
99
+
100
+ def fetch_and_extract(url: str, include_links: bool = True) -> dict:
101
+ """Fetch a page and extract its content."""
102
+ headers = {
103
+ 'User-Agent': 'DocumentationHarvester/1.0',
104
+ 'Accept': 'text/html,application/xhtml+xml',
105
+ }
106
+
107
+ response = requests.get(url, headers=headers, timeout=30)
108
+ response.raise_for_status()
109
+
110
+ soup = BeautifulSoup(response.content, 'lxml')
111
+ title = extract_title(soup)
112
+ main_content = extract_main_content(soup)
113
+ markdown = html_to_markdown(main_content, url)
114
+
115
+ # Extract links if requested
116
+ links = []
117
+ if include_links:
118
+ domain = urlparse(url).netloc
119
+ for anchor in main_content.find_all('a', href=True):
120
+ href = anchor['href']
121
+ if href.startswith('#'):
122
+ continue
123
+ absolute_url = urljoin(url, href)
124
+ if urlparse(absolute_url).netloc == domain:
125
+ links.append({
126
+ 'url': absolute_url,
127
+ 'text': anchor.get_text(strip=True),
128
+ })
129
+
130
+ return {
131
+ 'url': url,
132
+ 'title': title,
133
+ 'content': markdown,
134
+ 'word_count': len(markdown.split()),
135
+ 'links': links,
136
+ 'timestamp': datetime.now().isoformat(),
137
+ }
138
+
139
+
140
+ def main():
141
+ parser = argparse.ArgumentParser(description='Extract content from a documentation page.')
142
+ parser.add_argument('--url', '-u', required=True, help='Page URL to extract')
143
+ parser.add_argument('--output', '-o', help='Output file (default: stdout)')
144
+ parser.add_argument('--format', '-f', choices=['md', 'json'], default='md', help='Output format')
145
+ parser.add_argument('--include-links', action='store_true', default=True, help='Include internal links')
146
+
147
+ args = parser.parse_args()
148
+
149
+ try:
150
+ result = fetch_and_extract(args.url, args.include_links)
151
+
152
+ if args.format == 'md':
153
+ output = result['content']
154
+ else:
155
+ output = json.dumps(result, indent=2, ensure_ascii=False)
156
+
157
+ if args.output:
158
+ with open(args.output, 'w', encoding='utf-8') as f:
159
+ f.write(output)
160
+ print(json.dumps({
161
+ "status": "success",
162
+ "title": result['title'],
163
+ "word_count": result['word_count'],
164
+ "output": args.output
165
+ }))
166
+ else:
167
+ print(output)
168
+
169
+ sys.exit(0)
170
+
171
+ except requests.exceptions.RequestException as e:
172
+ print(json.dumps({
173
+ "status": "error",
174
+ "type": "network_error",
175
+ "message": str(e)
176
+ }), file=sys.stderr)
177
+ sys.exit(2)
178
+
179
+ except Exception as e:
180
+ print(json.dumps({
181
+ "status": "error",
182
+ "type": type(e).__name__,
183
+ "message": str(e)
184
+ }), file=sys.stderr)
185
+ sys.exit(3)
186
+
187
+
188
+ if __name__ == '__main__':
189
+ main()
@@ -0,0 +1,200 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Script: filter_docs.py
4
+ Purpose: Filter already-crawled documentation by subject or pattern.
5
+
6
+ Usage:
7
+ python filter_docs.py --input <crawl-dir> --subject <topic> --output <output-dir>
8
+
9
+ Arguments:
10
+ --input, -i Crawled docs directory (required)
11
+ --subject, -s Subject to filter for (required)
12
+ --output, -o Filtered output directory (required)
13
+ --threshold, -t Relevance threshold 0.0-1.0 (default: 0.3)
14
+
15
+ Exit Codes:
16
+ 0 - Success
17
+ 1 - Invalid arguments
18
+ 2 - Input not found
19
+ 3 - No matching content
20
+ """
21
+
22
+ import argparse
23
+ import json
24
+ import re
25
+ import sys
26
+ from pathlib import Path
27
+ from datetime import datetime
28
+
29
+
30
+ def calculate_relevance(content: str, title: str, subject: str) -> float:
31
+ """Calculate relevance score based on subject keywords."""
32
+ subject_lower = subject.lower()
33
+ subject_words = [w for w in subject_lower.split() if len(w) > 2]
34
+
35
+ if not subject_words:
36
+ return 0.0
37
+
38
+ text = (title + ' ' + content).lower()
39
+ total_words = len(text.split())
40
+
41
+ if total_words == 0:
42
+ return 0.0
43
+
44
+ # Count keyword occurrences
45
+ keyword_count = 0
46
+ for word in subject_words:
47
+ keyword_count += len(re.findall(r'\b' + re.escape(word) + r'\b', text))
48
+
49
+ # Calculate density-based score
50
+ density = keyword_count / total_words
51
+
52
+ # Bonus for title matches
53
+ title_lower = title.lower()
54
+ title_bonus = 0.3 if any(w in title_lower for w in subject_words) else 0.0
55
+
56
+ # Normalize to 0-1 range
57
+ score = min(1.0, (density * 100) + title_bonus)
58
+
59
+ return score
60
+
61
+
62
+ def filter_crawled_docs(input_dir: Path, subject: str, threshold: float) -> list:
63
+ """Filter documents based on relevance to subject."""
64
+ pages_dir = input_dir / 'pages'
65
+
66
+ if not pages_dir.exists():
67
+ raise FileNotFoundError(f"Pages directory not found: {pages_dir}")
68
+
69
+ filtered = []
70
+
71
+ for md_file in pages_dir.glob('*.md'):
72
+ content = md_file.read_text(encoding='utf-8')
73
+
74
+ # Extract title from frontmatter or first heading
75
+ title = 'Untitled'
76
+ if content.startswith('---'):
77
+ # Has frontmatter
78
+ end = content.find('---', 3)
79
+ if end > 0:
80
+ body = content[end + 3:].strip()
81
+ # Try to get first heading
82
+ match = re.search(r'^#\s+(.+)$', body, re.MULTILINE)
83
+ if match:
84
+ title = match.group(1)
85
+ else:
86
+ match = re.search(r'^#\s+(.+)$', content, re.MULTILINE)
87
+ if match:
88
+ title = match.group(1)
89
+
90
+ score = calculate_relevance(content, title, subject)
91
+
92
+ if score >= threshold:
93
+ filtered.append({
94
+ 'file': md_file.name,
95
+ 'title': title,
96
+ 'score': score,
97
+ 'content': content,
98
+ 'word_count': len(content.split()),
99
+ })
100
+
101
+ # Sort by relevance
102
+ filtered.sort(key=lambda x: x['score'], reverse=True)
103
+
104
+ return filtered
105
+
106
+
107
+ def save_filtered(filtered: list, output_dir: Path, subject: str, input_dir: Path):
108
+ """Save filtered documents to output directory."""
109
+ output_dir.mkdir(parents=True, exist_ok=True)
110
+ pages_dir = output_dir / 'pages'
111
+ pages_dir.mkdir(exist_ok=True)
112
+
113
+ # Copy filtered pages
114
+ for page in filtered:
115
+ (pages_dir / page['file']).write_text(page['content'], encoding='utf-8')
116
+
117
+ # Generate new index
118
+ index_lines = [
119
+ f"# {subject} (Filtered Documentation)",
120
+ "",
121
+ f"> Filtered from: {input_dir}",
122
+ f"> Pages: {len(filtered)}",
123
+ f"> Date: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}",
124
+ "",
125
+ "## Table of Contents",
126
+ "",
127
+ ]
128
+
129
+ for page in filtered:
130
+ index_lines.append(f"- [{page['title']}](pages/{page['file']}) (relevance: {page['score']:.2f})")
131
+
132
+ (output_dir / 'index.md').write_text('\n'.join(index_lines), encoding='utf-8')
133
+
134
+ # Save metadata
135
+ metadata = {
136
+ 'subject': subject,
137
+ 'source': str(input_dir),
138
+ 'pages_filtered': len(filtered),
139
+ 'timestamp': datetime.now().isoformat(),
140
+ 'pages': [{k: v for k, v in p.items() if k != 'content'} for p in filtered]
141
+ }
142
+ (output_dir / 'metadata.json').write_text(json.dumps(metadata, indent=2), encoding='utf-8')
143
+
144
+
145
+ def main():
146
+ parser = argparse.ArgumentParser(description='Filter crawled documentation by subject.')
147
+ parser.add_argument('--input', '-i', required=True, help='Crawled docs directory')
148
+ parser.add_argument('--subject', '-s', required=True, help='Subject to filter for')
149
+ parser.add_argument('--output', '-o', required=True, help='Filtered output directory')
150
+ parser.add_argument('--threshold', '-t', type=float, default=0.3, help='Relevance threshold')
151
+
152
+ args = parser.parse_args()
153
+
154
+ input_dir = Path(args.input)
155
+ output_dir = Path(args.output)
156
+
157
+ if not input_dir.exists():
158
+ print(json.dumps({
159
+ "status": "error",
160
+ "message": f"Input directory not found: {input_dir}"
161
+ }), file=sys.stderr)
162
+ sys.exit(2)
163
+
164
+ try:
165
+ print(f"🔍 Filtering docs for: {args.subject}")
166
+ print(f" Source: {input_dir}")
167
+ print(f" Threshold: {args.threshold}")
168
+ print()
169
+
170
+ filtered = filter_crawled_docs(input_dir, args.subject, args.threshold)
171
+
172
+ if not filtered:
173
+ print(json.dumps({
174
+ "status": "error",
175
+ "message": "No pages matched the filter criteria"
176
+ }), file=sys.stderr)
177
+ sys.exit(3)
178
+
179
+ save_filtered(filtered, output_dir, args.subject, input_dir)
180
+
181
+ print(f"✅ Filtered {len(filtered)} pages")
182
+ print()
183
+ print(json.dumps({
184
+ "status": "success",
185
+ "pages_filtered": len(filtered),
186
+ "output": str(output_dir)
187
+ }, indent=2))
188
+ sys.exit(0)
189
+
190
+ except Exception as e:
191
+ print(json.dumps({
192
+ "status": "error",
193
+ "type": type(e).__name__,
194
+ "message": str(e)
195
+ }), file=sys.stderr)
196
+ sys.exit(1)
197
+
198
+
199
+ if __name__ == '__main__':
200
+ main()
@@ -0,0 +1,81 @@
1
+ ---
2
+ name: api-patterns
3
+ description: API design principles and decision-making. REST vs GraphQL vs tRPC selection, response formats, versioning, pagination.
4
+ allowed-tools: Read, Write, Edit, Glob, Grep
5
+ ---
6
+
7
+ # API Patterns
8
+
9
+ > API design principles and decision-making for 2025.
10
+ > **Learn to THINK, not copy fixed patterns.**
11
+
12
+ ## 🎯 Selective Reading Rule
13
+
14
+ **Read ONLY files relevant to the request!** Check the content map, find what you need.
15
+
16
+ ---
17
+
18
+ ## 📑 Content Map
19
+
20
+ | File | Description | When to Read |
21
+ |------|-------------|--------------|
22
+ | `api-style.md` | REST vs GraphQL vs tRPC decision tree | Choosing API type |
23
+ | `rest.md` | Resource naming, HTTP methods, status codes | Designing REST API |
24
+ | `response.md` | Envelope pattern, error format, pagination | Response structure |
25
+ | `graphql.md` | Schema design, when to use, security | Considering GraphQL |
26
+ | `trpc.md` | TypeScript monorepo, type safety | TS fullstack projects |
27
+ | `versioning.md` | URI/Header/Query versioning | API evolution planning |
28
+ | `auth.md` | JWT, OAuth, Passkey, API Keys | Auth pattern selection |
29
+ | `rate-limiting.md` | Token bucket, sliding window | API protection |
30
+ | `documentation.md` | OpenAPI/Swagger best practices | Documentation |
31
+ | `security-testing.md` | OWASP API Top 10, auth/authz testing | Security audits |
32
+
33
+ ---
34
+
35
+ ## 🔗 Related Skills
36
+
37
+ | Need | Skill |
38
+ |------|-------|
39
+ | API implementation | `@[skills/backend-development]` |
40
+ | Data structure | `@[skills/database-design]` |
41
+ | Security details | `@[skills/security-hardening]` |
42
+
43
+ ---
44
+
45
+ ## ✅ Decision Checklist
46
+
47
+ Before designing an API:
48
+
49
+ - [ ] **Asked user about API consumers?**
50
+ - [ ] **Chosen API style for THIS context?** (REST/GraphQL/tRPC)
51
+ - [ ] **Defined consistent response format?**
52
+ - [ ] **Planned versioning strategy?**
53
+ - [ ] **Considered authentication needs?**
54
+ - [ ] **Planned rate limiting?**
55
+ - [ ] **Documentation approach defined?**
56
+
57
+ ---
58
+
59
+ ## ❌ Anti-Patterns
60
+
61
+ **DON'T:**
62
+ - Default to REST for everything
63
+ - Use verbs in REST endpoints (/getUsers)
64
+ - Return inconsistent response formats
65
+ - Expose internal errors to clients
66
+ - Skip rate limiting
67
+
68
+ **DO:**
69
+ - Choose API style based on context
70
+ - Ask about client requirements
71
+ - Document thoroughly
72
+ - Use appropriate status codes
73
+
74
+ ---
75
+
76
+ ## Script
77
+
78
+ | Script | Purpose | Command |
79
+ |--------|---------|---------|
80
+ | `scripts/api_validator.py` | API endpoint validation | `python scripts/api_validator.py <project_path>` |
81
+
@@ -0,0 +1,42 @@
1
+ # API Style Selection (2025)
2
+
3
+ > REST vs GraphQL vs tRPC - Hangi durumda hangisi?
4
+
5
+ ## Decision Tree
6
+
7
+ ```
8
+ Who are the API consumers?
9
+
10
+ ├── Public API / Multiple platforms
11
+ │ └── REST + OpenAPI (widest compatibility)
12
+
13
+ ├── Complex data needs / Multiple frontends
14
+ │ └── GraphQL (flexible queries)
15
+
16
+ ├── TypeScript frontend + backend (monorepo)
17
+ │ └── tRPC (end-to-end type safety)
18
+
19
+ ├── Real-time / Event-driven
20
+ │ └── WebSocket + AsyncAPI
21
+
22
+ └── Internal microservices
23
+ └── gRPC (performance) or REST (simplicity)
24
+ ```
25
+
26
+ ## Comparison
27
+
28
+ | Factor | REST | GraphQL | tRPC |
29
+ |--------|------|---------|------|
30
+ | **Best for** | Public APIs | Complex apps | TS monorepos |
31
+ | **Learning curve** | Low | Medium | Low (if TS) |
32
+ | **Over/under fetching** | Common | Solved | Solved |
33
+ | **Type safety** | Manual (OpenAPI) | Schema-based | Automatic |
34
+ | **Caching** | HTTP native | Complex | Client-based |
35
+
36
+ ## Selection Questions
37
+
38
+ 1. Who are the API consumers?
39
+ 2. Is the frontend TypeScript?
40
+ 3. How complex are the data relationships?
41
+ 4. Is caching critical?
42
+ 5. Public or internal API?
@@ -0,0 +1,24 @@
1
+ # Authentication Patterns
2
+
3
+ > Choose auth pattern based on use case.
4
+
5
+ ## Selection Guide
6
+
7
+ | Pattern | Best For |
8
+ |---------|----------|
9
+ | **JWT** | Stateless, microservices |
10
+ | **Session** | Traditional web, simple |
11
+ | **OAuth 2.0** | Third-party integration |
12
+ | **API Keys** | Server-to-server, public APIs |
13
+ | **Passkey** | Modern passwordless (2025+) |
14
+
15
+ ## JWT Principles
16
+
17
+ ```
18
+ Important:
19
+ ├── Always verify signature
20
+ ├── Check expiration
21
+ ├── Include minimal claims
22
+ ├── Use short expiry + refresh tokens
23
+ └── Never store sensitive data in JWT
24
+ ```
@@ -0,0 +1,26 @@
1
+ # API Documentation Principles
2
+
3
+ > Good docs = happy developers = API adoption.
4
+
5
+ ## OpenAPI/Swagger Essentials
6
+
7
+ ```
8
+ Include:
9
+ ├── All endpoints with examples
10
+ ├── Request/response schemas
11
+ ├── Authentication requirements
12
+ ├── Error response formats
13
+ └── Rate limiting info
14
+ ```
15
+
16
+ ## Good Documentation Has
17
+
18
+ ```
19
+ Essentials:
20
+ ├── Quick start / Getting started
21
+ ├── Authentication guide
22
+ ├── Complete API reference
23
+ ├── Error handling guide
24
+ ├── Code examples (multiple languages)
25
+ └── Changelog
26
+ ```
@@ -0,0 +1,41 @@
1
+ # GraphQL Principles
2
+
3
+ > Flexible queries for complex, interconnected data.
4
+
5
+ ## When to Use
6
+
7
+ ```
8
+ ✅ Good fit:
9
+ ├── Complex, interconnected data
10
+ ├── Multiple frontend platforms
11
+ ├── Clients need flexible queries
12
+ ├── Evolving data requirements
13
+ └── Reducing over-fetching matters
14
+
15
+ ❌ Poor fit:
16
+ ├── Simple CRUD operations
17
+ ├── File upload heavy
18
+ ├── HTTP caching important
19
+ └── Team unfamiliar with GraphQL
20
+ ```
21
+
22
+ ## Schema Design Principles
23
+
24
+ ```
25
+ Principles:
26
+ ├── Think in graphs, not endpoints
27
+ ├── Design for evolvability (no versions)
28
+ ├── Use connections for pagination
29
+ ├── Be specific with types (not generic "data")
30
+ └── Handle nullability thoughtfully
31
+ ```
32
+
33
+ ## Security Considerations
34
+
35
+ ```
36
+ Protect against:
37
+ ├── Query depth attacks → Set max depth
38
+ ├── Query complexity → Calculate cost
39
+ ├── Batching abuse → Limit batch size
40
+ ├── Introspection → Disable in production
41
+ ```
@@ -0,0 +1,31 @@
1
+ # Rate Limiting Principles
2
+
3
+ > Protect your API from abuse and overload.
4
+
5
+ ## Why Rate Limit
6
+
7
+ ```
8
+ Protect against:
9
+ ├── Brute force attacks
10
+ ├── Resource exhaustion
11
+ ├── Cost overruns (if pay-per-use)
12
+ └── Unfair usage
13
+ ```
14
+
15
+ ## Strategy Selection
16
+
17
+ | Type | How | When |
18
+ |------|-----|------|
19
+ | **Token bucket** | Burst allowed, refills over time | Most APIs |
20
+ | **Sliding window** | Smooth distribution | Strict limits |
21
+ | **Fixed window** | Simple counters per window | Basic needs |
22
+
23
+ ## Response Headers
24
+
25
+ ```
26
+ Include in headers:
27
+ ├── X-RateLimit-Limit (max requests)
28
+ ├── X-RateLimit-Remaining (requests left)
29
+ ├── X-RateLimit-Reset (when limit resets)
30
+ └── Return 429 when exceeded
31
+ ```
@@ -0,0 +1,37 @@
1
+ # Response Format Principles
2
+
3
+ > Consistency is key - choose a format and stick to it.
4
+
5
+ ## Common Patterns
6
+
7
+ ```
8
+ Choose one:
9
+ ├── Envelope pattern ({ success, data, error })
10
+ ├── Direct data (just return the resource)
11
+ └── HAL/JSON:API (hypermedia)
12
+ ```
13
+
14
+ ## Error Response
15
+
16
+ ```
17
+ Include:
18
+ ├── Error code (for programmatic handling)
19
+ ├── User message (for display)
20
+ ├── Details (for debugging, field-level errors)
21
+ ├── Request ID (for support)
22
+ └── NOT internal details (security!)
23
+ ```
24
+
25
+ ## Pagination Types
26
+
27
+ | Type | Best For | Trade-offs |
28
+ |------|----------|------------|
29
+ | **Offset** | Simple, jumpable | Performance on large datasets |
30
+ | **Cursor** | Large datasets | Can't jump to page |
31
+ | **Keyset** | Performance critical | Requires sortable key |
32
+
33
+ ### Selection Questions
34
+
35
+ 1. How large is the dataset?
36
+ 2. Do users need to jump to specific pages?
37
+ 3. Is data frequently changing?