@iamnishankhan/opencode-kit-grok 1.0.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.
Files changed (198) hide show
  1. package/bin/cli.js +46 -0
  2. package/kit/.opencode/AGENTS.md +392 -0
  3. package/kit/.opencode/README.md +71 -0
  4. package/kit/.opencode/USAGE.md +405 -0
  5. package/kit/.opencode/agents/backend-specialist.md +278 -0
  6. package/kit/.opencode/agents/code-archaeologist.md +114 -0
  7. package/kit/.opencode/agents/database-architect.md +233 -0
  8. package/kit/.opencode/agents/debugger.md +234 -0
  9. package/kit/.opencode/agents/devops-engineer.md +252 -0
  10. package/kit/.opencode/agents/documentation-writer.md +111 -0
  11. package/kit/.opencode/agents/explorer-agent.md +83 -0
  12. package/kit/.opencode/agents/frontend-specialist.md +606 -0
  13. package/kit/.opencode/agents/game-developer.md +169 -0
  14. package/kit/.opencode/agents/mobile-developer.md +385 -0
  15. package/kit/.opencode/agents/orchestrator.md +213 -0
  16. package/kit/.opencode/agents/penetration-tester.md +197 -0
  17. package/kit/.opencode/agents/performance-optimizer.md +194 -0
  18. package/kit/.opencode/agents/product-manager.md +120 -0
  19. package/kit/.opencode/agents/product-owner.md +103 -0
  20. package/kit/.opencode/agents/project-planner.md +418 -0
  21. package/kit/.opencode/agents/qa-automation-engineer.md +113 -0
  22. package/kit/.opencode/agents/security-auditor.md +179 -0
  23. package/kit/.opencode/agents/seo-specialist.md +119 -0
  24. package/kit/.opencode/agents/test-engineer.md +169 -0
  25. package/kit/.opencode/commands/brainstorm.md +113 -0
  26. package/kit/.opencode/commands/coordinate.md +72 -0
  27. package/kit/.opencode/commands/create.md +63 -0
  28. package/kit/.opencode/commands/debug.md +102 -0
  29. package/kit/.opencode/commands/deploy.md +175 -0
  30. package/kit/.opencode/commands/enhance.md +62 -0
  31. package/kit/.opencode/commands/orchestrate.md +241 -0
  32. package/kit/.opencode/commands/plan.md +89 -0
  33. package/kit/.opencode/commands/preview.md +80 -0
  34. package/kit/.opencode/commands/remember.md +67 -0
  35. package/kit/.opencode/commands/status.md +86 -0
  36. package/kit/.opencode/commands/test.md +143 -0
  37. package/kit/.opencode/commands/verify.md +71 -0
  38. package/kit/.opencode/memory/MEMORY.md +6 -0
  39. package/kit/.opencode/memory/feedback-history.md +9 -0
  40. package/kit/.opencode/memory/project-conventions.md +16 -0
  41. package/kit/.opencode/memory/tech-decisions.md +10 -0
  42. package/kit/.opencode/memory/user-preferences.md +9 -0
  43. package/kit/.opencode/opencode.json +15 -0
  44. package/kit/.opencode/scripts/README.md +95 -0
  45. package/kit/.opencode/scripts/auto_preview.py +149 -0
  46. package/kit/.opencode/scripts/checklist.py +75 -0
  47. package/kit/.opencode/scripts/component_registry.py +238 -0
  48. package/kit/.opencode/scripts/dependency_graph.py +73 -0
  49. package/kit/.opencode/scripts/generate_manifest.py +44 -0
  50. package/kit/.opencode/scripts/session_manager.py +120 -0
  51. package/kit/.opencode/scripts/tests/test_toolkit.py +238 -0
  52. package/kit/.opencode/scripts/validate_kit.py +397 -0
  53. package/kit/.opencode/scripts/validation_runner.py +216 -0
  54. package/kit/.opencode/scripts/verify_all.py +85 -0
  55. package/kit/.opencode/skills/api-patterns/SKILL.md +83 -0
  56. package/kit/.opencode/skills/api-patterns/api-style.md +42 -0
  57. package/kit/.opencode/skills/api-patterns/auth.md +24 -0
  58. package/kit/.opencode/skills/api-patterns/documentation.md +26 -0
  59. package/kit/.opencode/skills/api-patterns/graphql.md +41 -0
  60. package/kit/.opencode/skills/api-patterns/rate-limiting.md +31 -0
  61. package/kit/.opencode/skills/api-patterns/response.md +37 -0
  62. package/kit/.opencode/skills/api-patterns/rest.md +40 -0
  63. package/kit/.opencode/skills/api-patterns/scripts/api_validator.py +211 -0
  64. package/kit/.opencode/skills/api-patterns/security-testing.md +122 -0
  65. package/kit/.opencode/skills/api-patterns/trpc.md +41 -0
  66. package/kit/.opencode/skills/api-patterns/versioning.md +22 -0
  67. package/kit/.opencode/skills/app-builder/SKILL.md +78 -0
  68. package/kit/.opencode/skills/app-builder/agent-coordination.md +71 -0
  69. package/kit/.opencode/skills/app-builder/feature-building.md +53 -0
  70. package/kit/.opencode/skills/app-builder/project-detection.md +45 -0
  71. package/kit/.opencode/skills/app-builder/scaffolding.md +110 -0
  72. package/kit/.opencode/skills/app-builder/tech-stack.md +41 -0
  73. package/kit/.opencode/skills/app-builder/templates/SKILL.md +39 -0
  74. package/kit/.opencode/skills/app-builder/templates/astro-static/TEMPLATE.md +78 -0
  75. package/kit/.opencode/skills/app-builder/templates/chrome-extension/TEMPLATE.md +96 -0
  76. package/kit/.opencode/skills/app-builder/templates/cli-tool/TEMPLATE.md +88 -0
  77. package/kit/.opencode/skills/app-builder/templates/electron-desktop/TEMPLATE.md +97 -0
  78. package/kit/.opencode/skills/app-builder/templates/express-api/TEMPLATE.md +89 -0
  79. package/kit/.opencode/skills/app-builder/templates/flutter-app/TEMPLATE.md +93 -0
  80. package/kit/.opencode/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +97 -0
  81. package/kit/.opencode/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +126 -0
  82. package/kit/.opencode/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +125 -0
  83. package/kit/.opencode/skills/app-builder/templates/nextjs-static/TEMPLATE.md +174 -0
  84. package/kit/.opencode/skills/app-builder/templates/nuxt-app/TEMPLATE.md +127 -0
  85. package/kit/.opencode/skills/app-builder/templates/python-fastapi/TEMPLATE.md +94 -0
  86. package/kit/.opencode/skills/app-builder/templates/react-native-app/TEMPLATE.md +121 -0
  87. package/kit/.opencode/skills/architecture/SKILL.md +57 -0
  88. package/kit/.opencode/skills/architecture/context-discovery.md +43 -0
  89. package/kit/.opencode/skills/architecture/examples.md +94 -0
  90. package/kit/.opencode/skills/architecture/pattern-selection.md +68 -0
  91. package/kit/.opencode/skills/architecture/patterns-reference.md +50 -0
  92. package/kit/.opencode/skills/architecture/trade-off-analysis.md +77 -0
  93. package/kit/.opencode/skills/bash-linux/SKILL.md +201 -0
  94. package/kit/.opencode/skills/batch-operations/SKILL.md +105 -0
  95. package/kit/.opencode/skills/behavioral-modes/SKILL.md +253 -0
  96. package/kit/.opencode/skills/brainstorming/SKILL.md +178 -0
  97. package/kit/.opencode/skills/brainstorming/dynamic-questioning.md +350 -0
  98. package/kit/.opencode/skills/clean-code/SKILL.md +201 -0
  99. package/kit/.opencode/skills/code-review-checklist/SKILL.md +111 -0
  100. package/kit/.opencode/skills/code-review-graph/SKILL.md +305 -0
  101. package/kit/.opencode/skills/context-compression/SKILL.md +145 -0
  102. package/kit/.opencode/skills/coordinator-mode/SKILL.md +208 -0
  103. package/kit/.opencode/skills/database-design/SKILL.md +54 -0
  104. package/kit/.opencode/skills/database-design/database-selection.md +43 -0
  105. package/kit/.opencode/skills/database-design/indexing.md +39 -0
  106. package/kit/.opencode/skills/database-design/migrations.md +48 -0
  107. package/kit/.opencode/skills/database-design/optimization.md +36 -0
  108. package/kit/.opencode/skills/database-design/orm-selection.md +30 -0
  109. package/kit/.opencode/skills/database-design/schema-design.md +56 -0
  110. package/kit/.opencode/skills/database-design/scripts/schema_validator.py +172 -0
  111. package/kit/.opencode/skills/deployment-procedures/SKILL.md +243 -0
  112. package/kit/.opencode/skills/design-spec/SKILL.md +185 -0
  113. package/kit/.opencode/skills/design-spec/collection.md +106 -0
  114. package/kit/.opencode/skills/documentation-templates/SKILL.md +196 -0
  115. package/kit/.opencode/skills/frontend-architecture/SKILL.md +245 -0
  116. package/kit/.opencode/skills/frontend-design/SKILL.md +1222 -0
  117. package/kit/.opencode/skills/frontend-design/redesign.md +178 -0
  118. package/kit/.opencode/skills/frontend-design/scripts/accessibility_checker.py +145 -0
  119. package/kit/.opencode/skills/frontend-design/scripts/ux_audit.py +722 -0
  120. package/kit/.opencode/skills/frontend-design/style-brutalist.md +92 -0
  121. package/kit/.opencode/skills/frontend-design/style-minimalist.md +85 -0
  122. package/kit/.opencode/skills/game-development/2d-games/SKILL.md +118 -0
  123. package/kit/.opencode/skills/game-development/3d-games/SKILL.md +134 -0
  124. package/kit/.opencode/skills/game-development/SKILL.md +169 -0
  125. package/kit/.opencode/skills/game-development/game-art/SKILL.md +184 -0
  126. package/kit/.opencode/skills/game-development/game-audio/SKILL.md +189 -0
  127. package/kit/.opencode/skills/game-development/game-design/SKILL.md +128 -0
  128. package/kit/.opencode/skills/game-development/mobile-games/SKILL.md +107 -0
  129. package/kit/.opencode/skills/game-development/multiplayer/SKILL.md +131 -0
  130. package/kit/.opencode/skills/game-development/pc-games/SKILL.md +143 -0
  131. package/kit/.opencode/skills/game-development/vr-ar/SKILL.md +122 -0
  132. package/kit/.opencode/skills/game-development/web-games/SKILL.md +149 -0
  133. package/kit/.opencode/skills/geo-fundamentals/SKILL.md +158 -0
  134. package/kit/.opencode/skills/geo-fundamentals/scripts/geo_checker.py +273 -0
  135. package/kit/.opencode/skills/i18n-localization/SKILL.md +156 -0
  136. package/kit/.opencode/skills/i18n-localization/scripts/i18n_checker.py +223 -0
  137. package/kit/.opencode/skills/intelligent-routing/SKILL.md +337 -0
  138. package/kit/.opencode/skills/lint-and-validate/SKILL.md +47 -0
  139. package/kit/.opencode/skills/lint-and-validate/scripts/lint_runner.py +184 -0
  140. package/kit/.opencode/skills/lint-and-validate/scripts/type_coverage.py +245 -0
  141. package/kit/.opencode/skills/mcp-builder/SKILL.md +205 -0
  142. package/kit/.opencode/skills/memory-system/SKILL.md +181 -0
  143. package/kit/.opencode/skills/mobile-design/SKILL.md +396 -0
  144. package/kit/.opencode/skills/mobile-design/decision-trees.md +516 -0
  145. package/kit/.opencode/skills/mobile-design/mobile-backend.md +491 -0
  146. package/kit/.opencode/skills/mobile-design/mobile-color-system.md +420 -0
  147. package/kit/.opencode/skills/mobile-design/mobile-debugging.md +122 -0
  148. package/kit/.opencode/skills/mobile-design/mobile-design-thinking.md +357 -0
  149. package/kit/.opencode/skills/mobile-design/mobile-navigation.md +458 -0
  150. package/kit/.opencode/skills/mobile-design/mobile-performance.md +767 -0
  151. package/kit/.opencode/skills/mobile-design/mobile-testing.md +356 -0
  152. package/kit/.opencode/skills/mobile-design/mobile-typography.md +433 -0
  153. package/kit/.opencode/skills/mobile-design/platform-android.md +666 -0
  154. package/kit/.opencode/skills/mobile-design/platform-ios.md +561 -0
  155. package/kit/.opencode/skills/mobile-design/scripts/mobile_audit.py +670 -0
  156. package/kit/.opencode/skills/mobile-design/touch-psychology.md +537 -0
  157. package/kit/.opencode/skills/nextjs-react-expert/1-async-eliminating-waterfalls.md +351 -0
  158. package/kit/.opencode/skills/nextjs-react-expert/2-bundle-bundle-size-optimization.md +240 -0
  159. package/kit/.opencode/skills/nextjs-react-expert/3-server-server-side-performance.md +490 -0
  160. package/kit/.opencode/skills/nextjs-react-expert/4-client-client-side-data-fetching.md +264 -0
  161. package/kit/.opencode/skills/nextjs-react-expert/5-rerender-re-render-optimization.md +581 -0
  162. package/kit/.opencode/skills/nextjs-react-expert/6-rendering-rendering-performance.md +432 -0
  163. package/kit/.opencode/skills/nextjs-react-expert/7-js-javascript-performance.md +684 -0
  164. package/kit/.opencode/skills/nextjs-react-expert/8-advanced-advanced-patterns.md +150 -0
  165. package/kit/.opencode/skills/nextjs-react-expert/9-cache-components.md +103 -0
  166. package/kit/.opencode/skills/nextjs-react-expert/SKILL.md +293 -0
  167. package/kit/.opencode/skills/nextjs-react-expert/scripts/convert_rules.py +222 -0
  168. package/kit/.opencode/skills/nextjs-react-expert/scripts/react_performance_checker.py +281 -0
  169. package/kit/.opencode/skills/nodejs-best-practices/SKILL.md +336 -0
  170. package/kit/.opencode/skills/parallel-agents/SKILL.md +192 -0
  171. package/kit/.opencode/skills/performance-profiling/SKILL.md +145 -0
  172. package/kit/.opencode/skills/performance-profiling/scripts/bundle_analyzer.py +120 -0
  173. package/kit/.opencode/skills/performance-profiling/scripts/lighthouse_audit.py +108 -0
  174. package/kit/.opencode/skills/plan-writing/SKILL.md +153 -0
  175. package/kit/.opencode/skills/powershell-windows/SKILL.md +169 -0
  176. package/kit/.opencode/skills/python-patterns/SKILL.md +443 -0
  177. package/kit/.opencode/skills/red-team-tactics/SKILL.md +201 -0
  178. package/kit/.opencode/skills/rust-pro/SKILL.md +177 -0
  179. package/kit/.opencode/skills/seo-fundamentals/SKILL.md +131 -0
  180. package/kit/.opencode/skills/seo-fundamentals/scripts/seo_checker.py +219 -0
  181. package/kit/.opencode/skills/server-management/SKILL.md +163 -0
  182. package/kit/.opencode/skills/simplify-code/SKILL.md +131 -0
  183. package/kit/.opencode/skills/skillify/SKILL.md +115 -0
  184. package/kit/.opencode/skills/systematic-debugging/SKILL.md +111 -0
  185. package/kit/.opencode/skills/tailwind-patterns/SKILL.md +271 -0
  186. package/kit/.opencode/skills/tdd-workflow/SKILL.md +151 -0
  187. package/kit/.opencode/skills/testing-patterns/SKILL.md +180 -0
  188. package/kit/.opencode/skills/testing-patterns/scripts/test_runner.py +219 -0
  189. package/kit/.opencode/skills/verify-changes/SKILL.md +127 -0
  190. package/kit/.opencode/skills/vulnerability-scanner/SKILL.md +278 -0
  191. package/kit/.opencode/skills/vulnerability-scanner/checklists.md +124 -0
  192. package/kit/.opencode/skills/vulnerability-scanner/scripts/dependency_analyzer.py +144 -0
  193. package/kit/.opencode/skills/vulnerability-scanner/scripts/security_scan.py +410 -0
  194. package/kit/.opencode/skills/web-design-guidelines/SKILL.md +56 -0
  195. package/kit/.opencode/skills/webapp-testing/SKILL.md +189 -0
  196. package/kit/.opencode/skills/webapp-testing/scripts/playwright_runner.py +123 -0
  197. package/lib/init.js +61 -0
  198. package/package.json +21 -0
@@ -0,0 +1,245 @@
1
+ #!/usr/bin/env python3
2
+ """Pragmatic TypeScript and Python type-safety checker.
3
+
4
+ The checker prefers real compiler output when a local TypeScript compiler is
5
+ available. Its source fallback focuses on explicit escape hatches such as
6
+ ``any`` and ``@ts-ignore``; inferred TypeScript return types are not treated as
7
+ coverage failures.
8
+ """
9
+ from __future__ import annotations
10
+
11
+ import ast
12
+ import json
13
+ import math
14
+ import re
15
+ import subprocess
16
+ import sys
17
+ from pathlib import Path
18
+ from typing import Any
19
+
20
+ SKIP_DIRS = {
21
+ ".git",
22
+ ".next",
23
+ ".venv",
24
+ "build",
25
+ "coverage",
26
+ "dist",
27
+ "node_modules",
28
+ "out",
29
+ "venv",
30
+ "__pycache__",
31
+ }
32
+
33
+
34
+ def _source_files(project: Path, suffixes: set[str]) -> list[Path]:
35
+ files: list[Path] = []
36
+ for path in project.rglob("*"):
37
+ if not path.is_file() or path.suffix.lower() not in suffixes:
38
+ continue
39
+ if any(part in SKIP_DIRS for part in path.parts):
40
+ continue
41
+ if path.name.endswith(".d.ts"):
42
+ continue
43
+ files.append(path)
44
+ return sorted(files)
45
+
46
+
47
+ def _local_tsc(tsconfig: Path) -> Path | None:
48
+ executable = "tsc.cmd" if sys.platform == "win32" else "tsc"
49
+ for parent in (tsconfig.parent, *tsconfig.parents):
50
+ candidate = parent / "node_modules" / ".bin" / executable
51
+ if candidate.is_file():
52
+ return candidate
53
+ return None
54
+
55
+
56
+ def _run_typescript_compilers(project: Path) -> list[dict[str, Any]]:
57
+ runs: list[dict[str, Any]] = []
58
+ tsconfigs = [
59
+ path
60
+ for path in project.rglob("tsconfig.json")
61
+ if not any(part in SKIP_DIRS for part in path.parts)
62
+ ]
63
+ for tsconfig in sorted(tsconfigs):
64
+ compiler = _local_tsc(tsconfig)
65
+ if compiler is None:
66
+ runs.append({"config": str(tsconfig), "status": "skipped", "reason": "local tsc not installed"})
67
+ continue
68
+ proc = subprocess.run(
69
+ [str(compiler), "--noEmit", "--pretty", "false", "-p", str(tsconfig)],
70
+ cwd=tsconfig.parent,
71
+ capture_output=True,
72
+ text=True,
73
+ check=False,
74
+ timeout=180,
75
+ )
76
+ runs.append(
77
+ {
78
+ "config": str(tsconfig),
79
+ "status": "passed" if proc.returncode == 0 else "failed",
80
+ "returncode": proc.returncode,
81
+ "output": "\n".join(part.strip() for part in (proc.stdout, proc.stderr) if part.strip())[-4000:],
82
+ }
83
+ )
84
+ return runs
85
+
86
+
87
+ def check_typescript_coverage(project_path: Path) -> dict[str, Any]:
88
+ issues: list[str] = []
89
+ passed: list[str] = []
90
+ files = _source_files(project_path, {".ts", ".tsx"})
91
+ stats: dict[str, Any] = {
92
+ "any_count": 0,
93
+ "suppression_count": 0,
94
+ "files_with_any": 0,
95
+ "compiler_runs": [],
96
+ }
97
+
98
+ if not files:
99
+ return {"type": "typescript", "files": 0, "passed": [], "issues": ["[!] No TypeScript files found"], "stats": stats}
100
+
101
+ any_pattern = re.compile(r"(?::\s*any\b|\bas\s+any\b|<any>)")
102
+ suppression_pattern = re.compile(r"@ts-(?:ignore|nocheck)")
103
+ for file_path in files:
104
+ content = file_path.read_text("utf-8", errors="ignore")
105
+ any_count = len(any_pattern.findall(content))
106
+ stats["any_count"] += any_count
107
+ stats["files_with_any"] += int(any_count > 0)
108
+ stats["suppression_count"] += len(suppression_pattern.findall(content))
109
+
110
+ any_fail_threshold = max(10, math.ceil(len(files) * 0.25))
111
+ suppression_fail_threshold = max(3, math.ceil(len(files) * 0.05))
112
+
113
+ if stats["any_count"] == 0:
114
+ passed.append("[OK] No explicit 'any' escape hatches found")
115
+ elif stats["any_count"] > any_fail_threshold:
116
+ issues.append(
117
+ f"[X] {stats['any_count']} explicit 'any' usages exceed the project threshold of {any_fail_threshold}"
118
+ )
119
+ else:
120
+ issues.append(
121
+ f"[!] {stats['any_count']} explicit 'any' usages across {stats['files_with_any']} file(s)"
122
+ )
123
+
124
+ if stats["suppression_count"] > suppression_fail_threshold:
125
+ issues.append(
126
+ f"[X] {stats['suppression_count']} TypeScript suppression comments exceed the threshold of {suppression_fail_threshold}"
127
+ )
128
+ elif stats["suppression_count"]:
129
+ issues.append(f"[!] {stats['suppression_count']} TypeScript suppression comment(s) found")
130
+ else:
131
+ passed.append("[OK] No @ts-ignore or @ts-nocheck suppressions found")
132
+
133
+ stats["compiler_runs"] = _run_typescript_compilers(project_path)
134
+ failed_runs = [run for run in stats["compiler_runs"] if run["status"] == "failed"]
135
+ completed_runs = [run for run in stats["compiler_runs"] if run["status"] == "passed"]
136
+ if failed_runs:
137
+ issues.append(f"[X] TypeScript compiler failed for {len(failed_runs)} project(s)")
138
+ elif completed_runs:
139
+ passed.append(f"[OK] TypeScript compiler passed for {len(completed_runs)} project(s)")
140
+ elif stats["compiler_runs"]:
141
+ passed.append("[OK] Compiler check skipped because project-local tsc is not installed")
142
+
143
+ passed.append(f"[OK] Analyzed {len(files)} TypeScript files")
144
+ return {"type": "typescript", "files": len(files), "passed": passed, "issues": issues, "stats": stats}
145
+
146
+
147
+ def _annotation_complete(node: ast.FunctionDef | ast.AsyncFunctionDef) -> bool:
148
+ positional = [*node.args.posonlyargs, *node.args.args, *node.args.kwonlyargs]
149
+ relevant = [arg for arg in positional if arg.arg not in {"self", "cls"}]
150
+ args_typed = all(arg.annotation is not None for arg in relevant)
151
+ varargs_typed = node.args.vararg is None or node.args.vararg.annotation is not None
152
+ kwargs_typed = node.args.kwarg is None or node.args.kwarg.annotation is not None
153
+ return args_typed and varargs_typed and kwargs_typed and node.returns is not None
154
+
155
+
156
+ def check_python_coverage(project_path: Path) -> dict[str, Any]:
157
+ issues: list[str] = []
158
+ passed: list[str] = []
159
+ files = _source_files(project_path, {".py"})
160
+ stats = {"typed_functions": 0, "untyped_functions": 0, "any_count": 0, "parse_errors": 0}
161
+
162
+ if not files:
163
+ return {"type": "python", "files": 0, "passed": [], "issues": ["[!] No Python files found"], "stats": stats}
164
+
165
+ for file_path in files:
166
+ try:
167
+ tree = ast.parse(file_path.read_text("utf-8", errors="ignore"), filename=str(file_path))
168
+ except SyntaxError:
169
+ stats["parse_errors"] += 1
170
+ continue
171
+ for node in ast.walk(tree):
172
+ if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)):
173
+ key = "typed_functions" if _annotation_complete(node) else "untyped_functions"
174
+ stats[key] += 1
175
+ elif isinstance(node, ast.Name) and node.id == "Any":
176
+ stats["any_count"] += 1
177
+
178
+ total = stats["typed_functions"] + stats["untyped_functions"]
179
+ typed_ratio = (stats["typed_functions"] / total * 100) if total else 100.0
180
+ stats["typed_ratio"] = round(typed_ratio, 2)
181
+
182
+ if stats["parse_errors"]:
183
+ issues.append(f"[X] {stats['parse_errors']} Python file(s) could not be parsed")
184
+ if typed_ratio >= 65:
185
+ passed.append(f"[OK] Fully annotated Python functions: {typed_ratio:.0f}%")
186
+ elif typed_ratio >= 40:
187
+ issues.append(f"[!] Fully annotated Python functions: {typed_ratio:.0f}%")
188
+ else:
189
+ issues.append(f"[X] Fully annotated Python functions: {typed_ratio:.0f}%")
190
+
191
+ any_fail_threshold = max(50, len(files) * 3)
192
+ if stats["any_count"] == 0:
193
+ passed.append("[OK] No Python Any references found")
194
+ elif stats["any_count"] > any_fail_threshold:
195
+ issues.append(
196
+ f"[X] {stats['any_count']} Python Any references exceed the project threshold of {any_fail_threshold}"
197
+ )
198
+ else:
199
+ issues.append(f"[!] {stats['any_count']} Python Any reference(s) found")
200
+
201
+ passed.append(f"[OK] Analyzed {len(files)} Python files")
202
+ return {"type": "python", "files": len(files), "passed": passed, "issues": issues, "stats": stats}
203
+
204
+
205
+ def main() -> int:
206
+ project_path = Path(sys.argv[1] if len(sys.argv) > 1 else ".").resolve()
207
+ if not project_path.is_dir():
208
+ print(json.dumps({"error": f"Directory not found: {project_path}"}))
209
+ return 2
210
+
211
+ print("\n" + "=" * 60)
212
+ print(" TYPE SAFETY CHECKER")
213
+ print("=" * 60 + "\n")
214
+
215
+ results = [
216
+ result
217
+ for result in (
218
+ check_typescript_coverage(project_path),
219
+ check_python_coverage(project_path),
220
+ )
221
+ if result["files"] > 0
222
+ ]
223
+ if not results:
224
+ print("[!] No TypeScript or Python files found.")
225
+ return 0
226
+
227
+ critical_issues = 0
228
+ for result in results:
229
+ print(f"\n[{result['type'].upper()}]\n" + "-" * 40)
230
+ for item in result["passed"]:
231
+ print(f" {item}")
232
+ for item in result["issues"]:
233
+ print(f" {item}")
234
+ critical_issues += int(item.startswith("[X]"))
235
+
236
+ print("\n" + "=" * 60)
237
+ if critical_issues:
238
+ print(f"[X] TYPE SAFETY: {critical_issues} blocking issue(s)")
239
+ return 1
240
+ print("[OK] TYPE SAFETY: ACCEPTABLE")
241
+ return 0
242
+
243
+
244
+ if __name__ == "__main__":
245
+ raise SystemExit(main())
@@ -0,0 +1,205 @@
1
+ ---
2
+ name: mcp-builder
3
+ description: MCP (Model Context Protocol) server and client engineering. Protocol design, schemas, transports, extensions, security, and migration.
4
+ compatibility: opencode
5
+ metadata:
6
+ when_to_use: "\"When building or reviewing MCP servers or clients, designing MCP tools/resources/prompts, migrating protocol versions, or validating MCP security and interoperability.\""
7
+ version: "1.0.0"
8
+ ---
9
+ # MCP Builder
10
+
11
+ > Build interoperable MCP implementations against the stable **2026-07-28** specification. Treat extensions as negotiated, opt-in capabilities rather than core protocol guarantees.
12
+
13
+ ---
14
+
15
+ ## 1. Stable baseline and compatibility
16
+
17
+ - The authoritative stable baseline is MCP **2026-07-28**.
18
+ - Core requests are stateless and self-contained. Do not infer protocol version, client capabilities, identity, conversation, or task state from a transport connection or process lifetime.
19
+ - Put cross-request state behind explicit identifiers supplied on every relevant request.
20
+ - Negotiate the protocol version and capabilities; do not assume that a client or server implements every optional feature.
21
+ - Preserve compatibility with earlier peers where the specification requires it, including accepting legacy resource-not-found error code `-32002` while emitting `-32602` for invalid parameters in the current protocol.
22
+
23
+ ### Core versus extensions
24
+
25
+ | Layer | Status | Engineering rule |
26
+ | --- | --- | --- |
27
+ | Base protocol, versioning, message patterns | Stable core | Required for every implementation |
28
+ | Resources, prompts, tools, elicitation | Optional core features | Advertise and check capabilities before use |
29
+ | Tasks, Skills over MCP, MCP Apps | Extensions | Opt-in; require explicit support from both peers |
30
+ | Draft or vendor extensions | Experimental/vendor-specific | Isolate behind adapters and feature flags |
31
+
32
+ Never label an extension as stable merely because one SDK or host supports it. Check the extension's own official status and version.
33
+
34
+ ---
35
+
36
+ ## 2. Architecture
37
+
38
+ MCP uses JSON-RPC 2.0 between hosts, clients, and servers.
39
+
40
+ ```text
41
+ host application
42
+ └─ MCP client / runtime adapter
43
+ ├─ stdio transport
44
+ └─ Streamable HTTP transport
45
+ └─ MCP server
46
+ ├─ resources
47
+ ├─ prompts
48
+ └─ tools
49
+ ```
50
+
51
+ ### Stateless request model
52
+
53
+ Every request must carry the protocol metadata required by the negotiated version. For 2026-07-28 this includes per-request protocol version and client capability metadata under reserved `_meta` keys.
54
+
55
+ Servers must implement `server/discover` for protocol-version and capability discovery. Clients may call it before normal requests or use it as a backward-compatibility probe for stdio peers.
56
+
57
+ Do not:
58
+
59
+ - use a stdio process as a conversation or session boundary;
60
+ - depend on request ordering to establish capabilities or identity;
61
+ - keep hidden mutable state without an explicit handle;
62
+ - use self-reported client/server information for authorization decisions.
63
+
64
+ Do:
65
+
66
+ - make task, thread, workspace, or subscription handles explicit;
67
+ - validate every request independently;
68
+ - tolerate interleaved requests from unrelated tasks;
69
+ - document lifecycle, expiry, and cleanup for durable handles.
70
+
71
+ ---
72
+
73
+ ## 3. Transports and authentication
74
+
75
+ | Transport | Typical use | Security baseline |
76
+ | --- | --- | --- |
77
+ | `stdio` | Local process integration | Read credentials from the environment; constrain process and filesystem access |
78
+ | Streamable HTTP | Remote or shared service | Use the MCP HTTP authorization framework, validate origins where applicable, and enforce network boundaries |
79
+
80
+ WebSocket is not a standard MCP transport unless defined by a separately negotiated extension or vendor adapter.
81
+
82
+ Transport concerns must not leak into protocol semantics. Reconnection or process replacement must not destroy logical state that is represented by an explicit durable handle.
83
+
84
+ ---
85
+
86
+ ## 4. Schema design and validation
87
+
88
+ MCP defaults to **JSON Schema 2020-12** when `$schema` is absent. Implementations must support that dialect and should document any additional dialects.
89
+
90
+ ### Tool input schemas
91
+
92
+ - Use an object root for tool arguments.
93
+ - Give every property a clear, action-oriented description.
94
+ - Declare required fields explicitly.
95
+ - Prefer narrow enums, bounds, formats, and `additionalProperties: false` where forward compatibility does not require open objects.
96
+ - Validate both the schema and each invocation payload.
97
+
98
+ ### Tool output schemas
99
+
100
+ Use structured content and `outputSchema` when consumers need typed, predictable results. Keep human-readable text concise and ensure structured output remains the source of truth for automation.
101
+
102
+ ### `$ref` and validator safety
103
+
104
+ - Never dereference network `$ref` values automatically.
105
+ - If remote dereferencing is explicitly enabled, use a host allowlist; reject loopback, link-local, and private addresses; apply timeouts and response-size limits; and log resolved URIs without secrets.
106
+ - Reject schemas with unresolved external references instead of treating them as permissive.
107
+ - Bound schema depth, total subschemas, and validation time to prevent denial-of-service through composition keywords or recursive references.
108
+
109
+ ---
110
+
111
+ ## 5. Tool, resource, and prompt design
112
+
113
+ ### Tools
114
+
115
+ - Use clear action names and a single responsibility.
116
+ - Mark read-only, destructive, idempotent, or open-world behavior with annotations when useful, but treat annotations as untrusted hints unless the server itself is trusted.
117
+ - Require explicit user approval for consequential actions.
118
+ - Return stable machine-readable errors without internal stack traces or secrets.
119
+
120
+ ### Resources
121
+
122
+ - Use stable URIs and MIME types.
123
+ - Separate discovery metadata from resource content.
124
+ - Apply authorization per resource, not only per server connection.
125
+ - Avoid silently forwarding resource data to another server or model without user consent.
126
+
127
+ ### Prompts
128
+
129
+ - Treat prompts as user-visible templates, not hidden authority.
130
+ - Keep tool permissions and policy enforcement outside prompt text.
131
+ - Validate prompt arguments and clearly identify any data sources included in generated messages.
132
+
133
+ ---
134
+
135
+ ## 6. Security requirements
136
+
137
+ 1. **Consent and least privilege** — expose only required data and obtain explicit approval before tool execution or data sharing.
138
+ 2. **Untrusted metadata** — do not use tool descriptions, annotations, client info, server info, or model-produced arguments as authorization evidence.
139
+ 3. **Input and output validation** — validate schemas, arguments, structured results, URIs, and content types at trust boundaries.
140
+ 4. **Secret handling** — load credentials from environment or a secret manager; never place real keys in repository configuration, logs, traces, prompts, or error payloads.
141
+ 5. **Network controls** — defend remote schema/resource fetching against SSRF, redirect abuse, oversized responses, and slow responses.
142
+ 6. **Execution isolation** — sandbox subprocesses and filesystem access; use explicit path grants and reject archive or symlink escapes.
143
+ 7. **Auditability** — record security-relevant decisions, approvals, tool identity, and result status without storing sensitive payloads unnecessarily.
144
+
145
+ ---
146
+
147
+ ## 7. Extensions
148
+
149
+ Extensions are negotiated independently from the core protocol.
150
+
151
+ | Extension | Use | Guardrail |
152
+ | --- | --- | --- |
153
+ | Tasks | Long-running work, polling, durable handles, mid-flight input | Do not use the older experimental task API; negotiate the extension |
154
+ | Skills over MCP | Discoverable structured agent instructions | Treat skill content as untrusted input and apply host policy |
155
+ | MCP Apps | Interactive UI rendered in conversations | Constrain origins, content, data access, and action permissions |
156
+
157
+ An adapter must fail gracefully when an extension is absent. Never silently downgrade a security requirement to preserve feature parity.
158
+
159
+ ---
160
+
161
+ ## 8. Deprecated features and migration
162
+
163
+ The 2026-07-28 specification deprecates legacy roots, sampling, and logging shapes while keeping a compatibility window. Do not remove compatibility abruptly, but avoid designing new architecture around deprecated forms.
164
+
165
+ ### Migration checklist from 2025-era implementations
166
+
167
+ - [ ] Replace connection-scoped sessions and the `initialize` handshake with stateless per-request metadata.
168
+ - [ ] Implement or consume `server/discover` for version and capability selection.
169
+ - [ ] Move durable state behind explicit task, thread, workspace, or application handles.
170
+ - [ ] Send and validate negotiated protocol version and client capabilities on every request.
171
+ - [ ] Upgrade schema validation to JSON Schema 2020-12 by default.
172
+ - [ ] Disable network `$ref` resolution by default and add validation resource limits.
173
+ - [ ] Move experimental Tasks usage to the negotiated Tasks extension.
174
+ - [ ] Accept legacy `-32002` resource-not-found responses, but emit current error semantics.
175
+ - [ ] Treat a missing `resultType` from older servers as `"complete"`; require it for current-version results.
176
+ - [ ] Audit roots, sampling, and logging integrations for their documented replacements and deprecation timeline.
177
+ - [ ] Add interoperability tests against at least one older peer and one 2026-07-28 peer.
178
+
179
+ ---
180
+
181
+ ## 9. Testing matrix
182
+
183
+ | Test | Expected evidence |
184
+ | --- | --- |
185
+ | Contract | Invalid JSON-RPC, missing metadata, unsupported version/capability, schema dialect handling |
186
+ | Statelessness | Interleaved requests, reconnects, process reuse, explicit-handle recovery |
187
+ | Schema security | External `$ref`, recursive/composed schemas, depth/count/time limits |
188
+ | Authorization | Denied resource/tool access, approval gates, credential isolation |
189
+ | Extension negotiation | Extension absent, version mismatch, feature enabled, graceful fallback |
190
+ | Compatibility | Current peer plus supported older protocol revision |
191
+ | Failure handling | Timeouts, cancellation, partial results, structured errors, no secret leakage |
192
+
193
+ ---
194
+
195
+ ## 10. Review checklist
196
+
197
+ - [ ] Stable protocol version and extension status are documented.
198
+ - [ ] Requests are stateless; cross-request state uses explicit handles.
199
+ - [ ] Capabilities are negotiated and checked before optional operations.
200
+ - [ ] JSON Schema 2020-12 is supported and validator resource use is bounded.
201
+ - [ ] Network `$ref` resolution is disabled by default.
202
+ - [ ] Tool annotations are not trusted as authorization.
203
+ - [ ] User approval, least privilege, secret handling, and execution isolation are enforced outside prompts.
204
+ - [ ] Deprecated features have a compatibility and migration plan.
205
+ - [ ] Contract, security, extension, and cross-version tests pass.
@@ -0,0 +1,181 @@
1
+ ---
2
+ name: memory-system
3
+ description: Persistent cross-session memory management. Enables agents to remember user preferences, project conventions, and past decisions across different sessions using a structured MEMORY.md index and topic files.
4
+ compatibility: opencode
5
+ metadata:
6
+ when_to_use: "\"When the user says 'remember this', 'save this for later', 'don't forget', or when starting a new session and needing to recall past context. Also when /remember workflow is invoked.\""
7
+ version: "1.0.0"
8
+ ---
9
+ # Memory System — Persistent Cross-Session Memory
10
+
11
+ > Enables agents to remember across sessions. Never re-discover what was already learned.
12
+
13
+ ## Overview
14
+
15
+ The Memory System provides **persistent, searchable memory** that survives across sessions. Instead of re-explaining preferences, conventions, and past decisions every time, agents read a structured MEMORY.md index and topic files.
16
+
17
+ **Token Impact:** +1,000 tokens to load index, but saves 3,000-10,000 tokens by eliminating re-discovery.
18
+
19
+ ---
20
+
21
+ ## Architecture
22
+
23
+ ```
24
+ .opencode/memory/
25
+ ├── MEMORY.md ← Lightweight index (max 200 lines)
26
+ ├── user-preferences.md ← Topic file: user role, style, tools
27
+ ├── project-conventions.md ← Topic file: coding standards, patterns
28
+ ├── tech-decisions.md ← Topic file: past architectural decisions
29
+ ├── feedback-history.md ← Topic file: what user liked/disliked
30
+ └── [topic-name].md ← Additional topic files as needed
31
+ ```
32
+
33
+ ---
34
+
35
+ ## MEMORY.md Index Format
36
+
37
+ The index is a **lightweight pointer file** — short entries that reference topic files for details.
38
+
39
+ **Rules:**
40
+ - Maximum **200 lines** total
41
+ - Each entry: **~150 characters max**
42
+ - Format: `- [type] summary → topic-file.md`
43
+ - Types: `[user]` `[feedback]` `[project]` `[reference]`
44
+
45
+ **Example:**
46
+ ```markdown
47
+ # Memory Index
48
+
49
+ ## User
50
+ - [user] Prefers dark mode, uses Windows 11, PowerShell → user-preferences.md
51
+ - [user] Senior DevOps engineer, 8 years experience → user-preferences.md
52
+ - [user] Primary language: English, sometimes Turkish → user-preferences.md
53
+
54
+ ## Project
55
+ - [project] Always use bun instead of npm → project-conventions.md
56
+ - [project] Tailwind v4 preferred, no v3 → tech-decisions.md
57
+ - [project] No purple/violet colors in UI → project-conventions.md
58
+
59
+ ## Feedback
60
+ - [feedback] User likes concise responses, no filler → feedback-history.md
61
+ - [feedback] User dislikes verbose explanations → feedback-history.md
62
+ - [feedback] User prefers tables over bullet lists → feedback-history.md
63
+
64
+ ## Reference
65
+ - [reference] Squid proxy runs on port 3128 → infrastructure-notes.md
66
+ - [reference] Git workflow: feature branches → main → project-conventions.md
67
+ ```
68
+
69
+ ---
70
+
71
+ ## Topic File Format
72
+
73
+ Each topic file has **frontmatter** and **structured content**:
74
+
75
+ ```markdown
76
+ ---
77
+ type: user | feedback | project | reference
78
+ created: 2026-04-01
79
+ updated: 2026-04-01
80
+ ---
81
+
82
+ # User Preferences
83
+
84
+ ## Development Environment
85
+ - OS: Windows 11
86
+ - Shell: PowerShell
87
+ - Editor: Cursor / Windsurf
88
+ - Package Manager: bun (NOT npm)
89
+
90
+ ## Communication Style
91
+ - Prefers concise responses
92
+ - Likes tables for comparisons
93
+ - Dislikes verbose explanations
94
+ ```
95
+
96
+ ---
97
+
98
+ ## Memory Taxonomy
99
+
100
+ | Type | What to Store | Example |
101
+ |------|--------------|---------|
102
+ | **user** | Role, preferences, tools, communication style | "Senior DevOps, prefers dark mode" |
103
+ | **feedback** | What user liked/disliked about agent output | "User said 'too verbose', prefers tables" |
104
+ | **project** | Coding standards, tech choices, conventions | "Use bun not npm, Tailwind v4" |
105
+ | **reference** | Non-sensitive infrastructure notes, public URLs, configs | "Prod API hostname and port" |
106
+
107
+ ---
108
+
109
+ ## What NOT to Save
110
+
111
+ | Don't Save | Why |
112
+ |---|---|
113
+ | Secrets, credentials, tokens, passwords, private keys, or API keys | Memory is persistent and may be shared across sessions |
114
+ | Information derivable from code | Read `package.json` instead of memorizing deps |
115
+ | Temporary debug context | Clutters memory, not useful later |
116
+ | Exact code snippets | Code changes — memory becomes stale |
117
+ | File paths that may move | Use glob patterns or descriptions instead |
118
+ | Entire conversation transcripts | Memory is for distilled insights only |
119
+
120
+ ---
121
+
122
+ ## Operations
123
+
124
+ ### Save (Trigger: user says "remember", "save", "don't forget")
125
+
126
+ 1. Identify the information type (user/feedback/project/reference)
127
+ 2. Check if relevant topic file exists
128
+ 3. If yes → append to existing topic file
129
+ 4. If no → create new topic file with frontmatter
130
+ 5. Update MEMORY.md index with one-line pointer
131
+ 6. Confirm to user: "Saved to memory: [summary]"
132
+
133
+ ### Recall (Trigger: session start, or "what do you remember about X")
134
+
135
+ 1. Read `.opencode/memory/MEMORY.md` index
136
+ 2. Scan for relevant entries matching the current task
137
+ 3. If match found → read the referenced topic file
138
+ 4. Apply recalled context silently (don't recite memories unless asked)
139
+
140
+ ### Search (Trigger: "do I have any notes about X")
141
+
142
+ 1. Grep across `.opencode/memory/*.md` for the search term
143
+ 2. Return matching entries with file references
144
+ 3. Offer to read full topic file if user wants details
145
+
146
+ ### Prune (Trigger: index exceeds 200 lines)
147
+
148
+ 1. Warn: "Memory index is getting large (X lines). Review recommended."
149
+ 2. Suggest merging related entries
150
+ 3. Suggest archiving old entries to `.opencode/memory/archive/`
151
+ 4. Never auto-delete — always ask user first
152
+
153
+ ---
154
+
155
+ ## Session Start Protocol
156
+
157
+ At the start of every session:
158
+
159
+ ```
160
+ 1. Check: Does `.opencode/memory/MEMORY.md` exist?
161
+ → YES: Read index. Apply relevant context silently.
162
+ → NO: Continue without memory. Create on first "remember" trigger.
163
+
164
+ 2. Apply memory WITHOUT reciting it.
165
+ ❌ WRONG: "I remember you prefer dark mode and use bun..."
166
+ ✅ RIGHT: (silently apply preferences, use bun in commands)
167
+
168
+ 3. Exception: If user asks "what do you remember?" → recite relevant memories.
169
+ ```
170
+
171
+ ---
172
+
173
+ ## Memory vs. Plan vs. Task
174
+
175
+ | Artifact | Purpose | Lifespan | Location |
176
+ |----------|---------|----------|----------|
177
+ | **Memory** | Cross-session knowledge | Permanent until pruned | `.opencode/memory/` |
178
+ | **Plan** | Task breakdown for current project | Until project complete | Project root |
179
+ | **Task** | Progress tracker for current session | Until session ends | Artifact directory |
180
+
181
+ > Memory = what you KNOW. Plan = what you'll DO. Task = what you're DOING NOW.