zcode-expert-system 0.0.0-stage → 3.2.2

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 (457) hide show
  1. package/.zcode-plugin/plugin.json +25 -0
  2. package/LICENSE +30 -0
  3. package/README.md +680 -2
  4. package/README_CN.md +587 -0
  5. package/SKILL.md +357 -0
  6. package/agents/expert-academic-anthropologist.md +124 -0
  7. package/agents/expert-academic-geographer.md +126 -0
  8. package/agents/expert-academic-historian.md +122 -0
  9. package/agents/expert-academic-narratologist.md +117 -0
  10. package/agents/expert-academic-psychologist.md +117 -0
  11. package/agents/expert-academic-statistician.md +40 -0
  12. package/agents/expert-academic-study-planner.md +262 -0
  13. package/agents/expert-accounts-payable-agent.md +102 -0
  14. package/agents/expert-agentic-identity-trust.md +388 -0
  15. package/agents/expert-agents-orchestrator.md +366 -0
  16. package/agents/expert-authenticity-appraiser.md +38 -0
  17. package/agents/expert-automation-governance-architect.md +215 -0
  18. package/agents/expert-blender-addon-engineer.md +233 -0
  19. package/agents/expert-business-strategist.md +487 -0
  20. package/agents/expert-change-management-consultant.md +495 -0
  21. package/agents/expert-chief-executive-officer.md +104 -0
  22. package/agents/expert-chief-financial-officer.md +390 -0
  23. package/agents/expert-chief-marketing-officer.md +95 -0
  24. package/agents/expert-chief-of-staff.md +278 -0
  25. package/agents/expert-chief-operating-officer.md +88 -0
  26. package/agents/expert-chief-product-officer.md +91 -0
  27. package/agents/expert-chief-technology-officer.md +98 -0
  28. package/agents/expert-corporate-training-designer.md +191 -0
  29. package/agents/expert-customer-service.md +40 -0
  30. package/agents/expert-customer-success-manager.md +458 -0
  31. package/agents/expert-data-consolidation-agent.md +327 -0
  32. package/agents/expert-data-privacy-officer.md +411 -0
  33. package/agents/expert-design-brand-guardian.md +321 -0
  34. package/agents/expert-design-image-prompt-engineer.md +255 -0
  35. package/agents/expert-design-inclusive-visuals-specialist.md +177 -0
  36. package/agents/expert-design-persona-walkthrough.md +271 -0
  37. package/agents/expert-design-ui-designer.md +382 -0
  38. package/agents/expert-design-ui-finish-gate-reviewer.md +40 -0
  39. package/agents/expert-design-ux-architect.md +482 -0
  40. package/agents/expert-design-ux-researcher.md +328 -0
  41. package/agents/expert-design-video-prompt-engineer.md +110 -0
  42. package/agents/expert-design-visual-storyteller.md +159 -0
  43. package/agents/expert-design-whimsy-injector.md +453 -0
  44. package/agents/expert-economy-designer.md +40 -0
  45. package/agents/expert-engineering-ai-data-remediation-engineer.md +209 -0
  46. package/agents/expert-engineering-ai-engineer.md +161 -0
  47. package/agents/expert-engineering-api-platform-engineer.md +40 -0
  48. package/agents/expert-engineering-ats-validator-architect.md +38 -0
  49. package/agents/expert-engineering-autonomous-optimization-architect.md +115 -0
  50. package/agents/expert-engineering-backend-architect.md +234 -0
  51. package/agents/expert-engineering-china-network-engineer.md +33 -0
  52. package/agents/expert-engineering-cms-developer.md +534 -0
  53. package/agents/expert-engineering-code-reviewer.md +172 -0
  54. package/agents/expert-engineering-codebase-onboarding-engineer.md +172 -0
  55. package/agents/expert-engineering-data-engineer.md +324 -0
  56. package/agents/expert-engineering-data-visualization-engineer.md +40 -0
  57. package/agents/expert-engineering-database-optimizer.md +175 -0
  58. package/agents/expert-engineering-database-reliability-engineer.md +40 -0
  59. package/agents/expert-engineering-desktop-app-engineer.md +40 -0
  60. package/agents/expert-engineering-developer-tooling-engineer.md +40 -0
  61. package/agents/expert-engineering-devops-automator.md +375 -0
  62. package/agents/expert-engineering-dingtalk-integration-developer.md +574 -0
  63. package/agents/expert-engineering-drupal-performance.md +40 -0
  64. package/agents/expert-engineering-drupal-shopping-cart.md +359 -0
  65. package/agents/expert-engineering-email-intelligence-engineer.md +349 -0
  66. package/agents/expert-engineering-embedded-firmware-engineer.md +168 -0
  67. package/agents/expert-engineering-embedded-linux-driver-engineer.md +255 -0
  68. package/agents/expert-engineering-feishu-integration-developer.md +597 -0
  69. package/agents/expert-engineering-filament-optimization-specialist.md +283 -0
  70. package/agents/expert-engineering-finops-engineer.md +40 -0
  71. package/agents/expert-engineering-fpga-digital-design-engineer.md +227 -0
  72. package/agents/expert-engineering-frontend-developer.md +224 -0
  73. package/agents/expert-engineering-gaussdb-expert.md +40 -0
  74. package/agents/expert-engineering-git-workflow-master.md +220 -0
  75. package/agents/expert-engineering-i18n-engineer.md +40 -0
  76. package/agents/expert-engineering-identity-access-engineer.md +40 -0
  77. package/agents/expert-engineering-incident-response-commander.md +465 -0
  78. package/agents/expert-engineering-iot-fleet-engineer.md +40 -0
  79. package/agents/expert-engineering-iot-solution-architect.md +220 -0
  80. package/agents/expert-engineering-it-service-manager.md +560 -0
  81. package/agents/expert-engineering-knowledge-graph-engineer.md +40 -0
  82. package/agents/expert-engineering-llm-post-training-engineer.md +40 -0
  83. package/agents/expert-engineering-mechanical-design-engineer.md +311 -0
  84. package/agents/expert-engineering-minimal-change-engineer.md +206 -0
  85. package/agents/expert-engineering-mobile-app-builder.md +434 -0
  86. package/agents/expert-engineering-mobile-release-engineer.md +40 -0
  87. package/agents/expert-engineering-multi-agent-systems-architect.md +599 -0
  88. package/agents/expert-engineering-network-engineer-china.md +162 -0
  89. package/agents/expert-engineering-network-engineer.md +40 -0
  90. package/agents/expert-engineering-orgscript-engineer.md +112 -0
  91. package/agents/expert-engineering-payments-billing-engineer.md +40 -0
  92. package/agents/expert-engineering-pc-host-engineer.md +231 -0
  93. package/agents/expert-engineering-pdf-engine-architect.md +32 -0
  94. package/agents/expert-engineering-platform-engineer.md +32 -0
  95. package/agents/expert-engineering-privacy-engineer.md +40 -0
  96. package/agents/expert-engineering-prompt-engineer.md +203 -0
  97. package/agents/expert-engineering-rag-pipeline-engineer.md +40 -0
  98. package/agents/expert-engineering-rapid-prototyper.md +461 -0
  99. package/agents/expert-engineering-realtime-collaboration-engineer.md +40 -0
  100. package/agents/expert-engineering-rust-refactoring-specialist.md +40 -0
  101. package/agents/expert-engineering-search-relevance-engineer.md +40 -0
  102. package/agents/expert-engineering-section-508-specialist.md +40 -0
  103. package/agents/expert-engineering-security-engineer.md +303 -0
  104. package/agents/expert-engineering-senior-developer.md +177 -0
  105. package/agents/expert-engineering-servicenow-developer-mentor.md +32 -0
  106. package/agents/expert-engineering-software-architect.md +200 -0
  107. package/agents/expert-engineering-solidity-smart-contract-engineer.md +541 -0
  108. package/agents/expert-engineering-sre.md +233 -0
  109. package/agents/expert-engineering-technical-writer.md +409 -0
  110. package/agents/expert-engineering-threat-detection-engineer.md +553 -0
  111. package/agents/expert-engineering-universal-document-compiler.md +32 -0
  112. package/agents/expert-engineering-uswds-developer.md +40 -0
  113. package/agents/expert-engineering-video-streaming-engineer.md +40 -0
  114. package/agents/expert-engineering-voice-ai-integration-engineer.md +560 -0
  115. package/agents/expert-engineering-webassembly-engineer.md +40 -0
  116. package/agents/expert-engineering-wechat-mini-program-developer.md +288 -0
  117. package/agents/expert-engineering-wordpress-performance.md +40 -0
  118. package/agents/expert-engineering-wordpress-shopping-cart.md +345 -0
  119. package/agents/expert-esg-sustainability-officer.md +395 -0
  120. package/agents/expert-finance-bookkeeper-controller.md +271 -0
  121. package/agents/expert-finance-financial-analyst.md +244 -0
  122. package/agents/expert-finance-financial-forecaster.md +213 -0
  123. package/agents/expert-finance-fpa-analyst.md +272 -0
  124. package/agents/expert-finance-fraud-detector.md +241 -0
  125. package/agents/expert-finance-hk-stock-compliance-reviewer.md +316 -0
  126. package/agents/expert-finance-investment-researcher.md +283 -0
  127. package/agents/expert-finance-invoice-manager.md +242 -0
  128. package/agents/expert-finance-tax-strategist.md +250 -0
  129. package/agents/expert-game-audio-engineer.md +265 -0
  130. package/agents/expert-game-designer.md +168 -0
  131. package/agents/expert-gaokao-college-advisor.md +333 -0
  132. package/agents/expert-gis-3d-scene-developer.md +110 -0
  133. package/agents/expert-gis-analyst.md +90 -0
  134. package/agents/expert-gis-bim-specialist.md +107 -0
  135. package/agents/expert-gis-cartography-designer.md +149 -0
  136. package/agents/expert-gis-drone-reality-mapping.md +119 -0
  137. package/agents/expert-gis-geoai-ml-engineer.md +104 -0
  138. package/agents/expert-gis-geoprocessing-specialist.md +96 -0
  139. package/agents/expert-gis-qa-engineer.md +132 -0
  140. package/agents/expert-gis-solution-engineer.md +100 -0
  141. package/agents/expert-gis-spatial-data-engineer.md +96 -0
  142. package/agents/expert-gis-spatial-data-scientist.md +110 -0
  143. package/agents/expert-gis-technical-consultant.md +85 -0
  144. package/agents/expert-gis-web-gis-developer.md +107 -0
  145. package/agents/expert-godot-gameplay-scripter.md +335 -0
  146. package/agents/expert-godot-multiplayer-engineer.md +296 -0
  147. package/agents/expert-godot-shader-developer.md +267 -0
  148. package/agents/expert-government-digital-presales-consultant.md +362 -0
  149. package/agents/expert-grant-writer.md +510 -0
  150. package/agents/expert-healthcare-aging-parent-care-companion.md +40 -0
  151. package/agents/expert-healthcare-clinical-evidence-agent.md +40 -0
  152. package/agents/expert-healthcare-customer-service.md +388 -0
  153. package/agents/expert-healthcare-innovation-strategist.md +40 -0
  154. package/agents/expert-healthcare-marketing-compliance.md +394 -0
  155. package/agents/expert-healthcare-sovereign-health-systems-agent.md +40 -0
  156. package/agents/expert-hospitality-guest-services.md +597 -0
  157. package/agents/expert-hr-onboarding.md +450 -0
  158. package/agents/expert-hr-performance-reviewer.md +248 -0
  159. package/agents/expert-hr-recruiter.md +232 -0
  160. package/agents/expert-identity-graph-operator.md +270 -0
  161. package/agents/expert-language-translator.md +275 -0
  162. package/agents/expert-legal-billing-time-tracking.md +566 -0
  163. package/agents/expert-legal-client-intake.md +487 -0
  164. package/agents/expert-legal-contract-reviewer.md +240 -0
  165. package/agents/expert-legal-document-review.md +452 -0
  166. package/agents/expert-legal-policy-writer.md +308 -0
  167. package/agents/expert-level-designer.md +209 -0
  168. package/agents/expert-livestock-archive-auditor.md +135 -0
  169. package/agents/expert-loan-officer-assistant.md +549 -0
  170. package/agents/expert-lsp-index-engineer.md +334 -0
  171. package/agents/expert-ma-integration-manager.md +426 -0
  172. package/agents/expert-macos-spatial-metal-engineer.md +337 -0
  173. package/agents/expert-marketing-aeo-foundations.md +263 -0
  174. package/agents/expert-marketing-agentic-search-optimizer.md +312 -0
  175. package/agents/expert-marketing-ai-citation-strategist.md +169 -0
  176. package/agents/expert-marketing-app-store-optimizer.md +319 -0
  177. package/agents/expert-marketing-baidu-seo-specialist.md +220 -0
  178. package/agents/expert-marketing-bilibili-content-strategist.md +40 -0
  179. package/agents/expert-marketing-bilibili-strategist.md +194 -0
  180. package/agents/expert-marketing-book-co-author.md +109 -0
  181. package/agents/expert-marketing-carousel-growth-engine.md +215 -0
  182. package/agents/expert-marketing-china-ecommerce-operator.md +277 -0
  183. package/agents/expert-marketing-china-market-localization-strategist.md +282 -0
  184. package/agents/expert-marketing-content-creator.md +145 -0
  185. package/agents/expert-marketing-cross-border-ecommerce.md +260 -0
  186. package/agents/expert-marketing-daily-news-briefing.md +303 -0
  187. package/agents/expert-marketing-developer-community-builder.md +32 -0
  188. package/agents/expert-marketing-douyin-strategist.md +150 -0
  189. package/agents/expert-marketing-ecommerce-operator.md +216 -0
  190. package/agents/expert-marketing-email-strategist.md +248 -0
  191. package/agents/expert-marketing-global-podcast-strategist.md +204 -0
  192. package/agents/expert-marketing-growth-hacker.md +121 -0
  193. package/agents/expert-marketing-instagram-curator.md +179 -0
  194. package/agents/expert-marketing-knowledge-commerce-strategist.md +384 -0
  195. package/agents/expert-marketing-kuaishou-strategist.md +182 -0
  196. package/agents/expert-marketing-linkedin-content-creator.md +232 -0
  197. package/agents/expert-marketing-livestream-commerce-coach.md +303 -0
  198. package/agents/expert-marketing-multi-platform-publisher.md +216 -0
  199. package/agents/expert-marketing-podcast-strategist.md +278 -0
  200. package/agents/expert-marketing-pr-communications-manager.md +472 -0
  201. package/agents/expert-marketing-private-domain-operator.md +309 -0
  202. package/agents/expert-marketing-reddit-community-builder.md +127 -0
  203. package/agents/expert-marketing-search-growth-orchestrator.md +372 -0
  204. package/agents/expert-marketing-seo-specialist.md +298 -0
  205. package/agents/expert-marketing-short-video-editing-coach.md +413 -0
  206. package/agents/expert-marketing-social-media-strategist.md +118 -0
  207. package/agents/expert-marketing-tiktok-strategist.md +124 -0
  208. package/agents/expert-marketing-twitter-engager.md +132 -0
  209. package/agents/expert-marketing-video-optimization-specialist.md +128 -0
  210. package/agents/expert-marketing-wechat-official-account.md +158 -0
  211. package/agents/expert-marketing-wechat-operator.md +156 -0
  212. package/agents/expert-marketing-weibo-strategist.md +241 -0
  213. package/agents/expert-marketing-weixin-channels-strategist.md +297 -0
  214. package/agents/expert-marketing-x-twitter-intelligence-analyst.md +160 -0
  215. package/agents/expert-marketing-xiaohongshu-operator.md +139 -0
  216. package/agents/expert-marketing-xiaohongshu-specialist.md +151 -0
  217. package/agents/expert-marketing-zhihu-strategist.md +175 -0
  218. package/agents/expert-medical-billing-coding-specialist.md +489 -0
  219. package/agents/expert-narrative-designer.md +244 -0
  220. package/agents/expert-operations-manager.md +398 -0
  221. package/agents/expert-organizational-psychologist.md +390 -0
  222. package/agents/expert-paid-media-auditor.md +170 -0
  223. package/agents/expert-paid-media-creative-strategist.md +173 -0
  224. package/agents/expert-paid-media-paid-social-strategist.md +180 -0
  225. package/agents/expert-paid-media-ppc-strategist.md +180 -0
  226. package/agents/expert-paid-media-programmatic-buyer.md +177 -0
  227. package/agents/expert-paid-media-search-query-analyst.md +182 -0
  228. package/agents/expert-paid-media-tracking-specialist.md +199 -0
  229. package/agents/expert-personal-growth-mentor.md +158 -0
  230. package/agents/expert-product-behavioral-nudge-engine.md +246 -0
  231. package/agents/expert-product-dx-engineer.md +32 -0
  232. package/agents/expert-product-feedback-synthesizer.md +175 -0
  233. package/agents/expert-product-manager.md +474 -0
  234. package/agents/expert-product-sprint-prioritizer.md +133 -0
  235. package/agents/expert-product-trend-researcher.md +143 -0
  236. package/agents/expert-project-management-experiment-tracker.md +206 -0
  237. package/agents/expert-project-management-jira-workflow-steward.md +249 -0
  238. package/agents/expert-project-management-meeting-notes-specialist.md +94 -0
  239. package/agents/expert-project-management-project-shepherd.md +202 -0
  240. package/agents/expert-project-management-studio-operations.md +208 -0
  241. package/agents/expert-project-management-studio-producer.md +211 -0
  242. package/agents/expert-project-manager-senior.md +135 -0
  243. package/agents/expert-prompt-engineer.md +176 -0
  244. package/agents/expert-real-estate-buyer-seller.md +594 -0
  245. package/agents/expert-recruitment-specialist.md +49 -0
  246. package/agents/expert-report-distribution-agent.md +354 -0
  247. package/agents/expert-research-synthesist.md +40 -0
  248. package/agents/expert-resume-tailor.md +40 -0
  249. package/agents/expert-retail-customer-returns.md +564 -0
  250. package/agents/expert-roblox-avatar-creator.md +298 -0
  251. package/agents/expert-roblox-experience-designer.md +306 -0
  252. package/agents/expert-roblox-systems-scripter.md +325 -0
  253. package/agents/expert-sales-account-strategist.md +243 -0
  254. package/agents/expert-sales-coach.md +291 -0
  255. package/agents/expert-sales-data-extraction-agent.md +159 -0
  256. package/agents/expert-sales-deal-strategist.md +204 -0
  257. package/agents/expert-sales-discovery-coach.md +230 -0
  258. package/agents/expert-sales-engineer.md +200 -0
  259. package/agents/expert-sales-offer-lead-gen-strategist.md +256 -0
  260. package/agents/expert-sales-outbound-strategist.md +208 -0
  261. package/agents/expert-sales-outreach.md +40 -0
  262. package/agents/expert-sales-pipeline-analyst.md +284 -0
  263. package/agents/expert-sales-proposal-strategist.md +233 -0
  264. package/agents/expert-security-ai-generated-code-auditor.md +40 -0
  265. package/agents/expert-security-appsec-engineer.md +490 -0
  266. package/agents/expert-security-architect.md +303 -0
  267. package/agents/expert-security-blockchain-security-auditor.md +462 -0
  268. package/agents/expert-security-cloud-security-architect.md +522 -0
  269. package/agents/expert-security-compliance-auditor.md +157 -0
  270. package/agents/expert-security-incident-responder.md +436 -0
  271. package/agents/expert-security-penetration-tester.md +398 -0
  272. package/agents/expert-security-secrets-credential-engineer.md +40 -0
  273. package/agents/expert-security-senior-secops.md +751 -0
  274. package/agents/expert-security-threat-detection-engineer.md +533 -0
  275. package/agents/expert-security-threat-intelligence-analyst.md +643 -0
  276. package/agents/expert-specialized-ai-policy-writer.md +217 -0
  277. package/agents/expert-specialized-chief-of-staff.md +40 -0
  278. package/agents/expert-specialized-civil-engineer.md +355 -0
  279. package/agents/expert-specialized-codebase-archaeologist.md +40 -0
  280. package/agents/expert-specialized-cultural-intelligence-strategist.md +168 -0
  281. package/agents/expert-specialized-developer-advocate.md +334 -0
  282. package/agents/expert-specialized-document-generator.md +346 -0
  283. package/agents/expert-specialized-fedramp-rmf-compliance.md +40 -0
  284. package/agents/expert-specialized-focus-music-architect.md +32 -0
  285. package/agents/expert-specialized-french-consulting-market.md +46 -0
  286. package/agents/expert-specialized-korean-business-navigator.md +46 -0
  287. package/agents/expert-specialized-master-plan-architect.md +40 -0
  288. package/agents/expert-specialized-mcp-builder.md +351 -0
  289. package/agents/expert-specialized-meeting-assistant.md +236 -0
  290. package/agents/expert-specialized-model-qa.md +507 -0
  291. package/agents/expert-specialized-pricing-analyst.md +242 -0
  292. package/agents/expert-specialized-pricing-optimizer.md +254 -0
  293. package/agents/expert-specialized-risk-assessor.md +240 -0
  294. package/agents/expert-specialized-salesforce-architect.md +179 -0
  295. package/agents/expert-specialized-strategy-duel-agent.md +129 -0
  296. package/agents/expert-specialized-workflow-architect.md +596 -0
  297. package/agents/expert-study-abroad-advisor.md +281 -0
  298. package/agents/expert-supply-chain-garment-factory-planning-engineer.md +262 -0
  299. package/agents/expert-supply-chain-inventory-forecaster.md +212 -0
  300. package/agents/expert-supply-chain-route-optimizer.md +224 -0
  301. package/agents/expert-supply-chain-strategist.md +581 -0
  302. package/agents/expert-supply-chain-vendor-evaluator.md +232 -0
  303. package/agents/expert-support-analytics-reporter.md +364 -0
  304. package/agents/expert-support-executive-summary-generator.md +217 -0
  305. package/agents/expert-support-finance-tracker.md +447 -0
  306. package/agents/expert-support-infrastructure-maintainer.md +623 -0
  307. package/agents/expert-support-legal-compliance-checker.md +587 -0
  308. package/agents/expert-support-recruitment-specialist.md +508 -0
  309. package/agents/expert-support-support-responder.md +584 -0
  310. package/agents/expert-technical-artist.md +230 -0
  311. package/agents/expert-technical-translator-agent.md +167 -0
  312. package/agents/expert-terminal-integration-specialist.md +236 -0
  313. package/agents/expert-testing-accessibility-auditor.md +329 -0
  314. package/agents/expert-testing-api-tester.md +305 -0
  315. package/agents/expert-testing-embedded-qa-engineer.md +258 -0
  316. package/agents/expert-testing-evidence-collector.md +153 -0
  317. package/agents/expert-testing-performance-benchmarker.md +196 -0
  318. package/agents/expert-testing-reality-checker.md +235 -0
  319. package/agents/expert-testing-test-automation-engineer.md +40 -0
  320. package/agents/expert-testing-test-results-analyzer.md +313 -0
  321. package/agents/expert-testing-tool-evaluator.md +402 -0
  322. package/agents/expert-testing-workflow-optimizer.md +458 -0
  323. package/agents/expert-travel-planner.md +38 -0
  324. package/agents/expert-unity-architect.md +272 -0
  325. package/agents/expert-unity-editor-tool-developer.md +300 -0
  326. package/agents/expert-unity-multiplayer-engineer.md +238 -0
  327. package/agents/expert-unity-shader-graph-artist.md +270 -0
  328. package/agents/expert-unreal-multiplayer-architect.md +314 -0
  329. package/agents/expert-unreal-systems-engineer.md +311 -0
  330. package/agents/expert-unreal-technical-artist.md +256 -0
  331. package/agents/expert-unreal-world-builder.md +274 -0
  332. package/agents/expert-visionos-spatial-engineer.md +282 -0
  333. package/agents/expert-xr-cockpit-interaction-specialist.md +220 -0
  334. package/agents/expert-xr-immersive-developer.md +229 -0
  335. package/agents/expert-xr-interface-architect.md +253 -0
  336. package/agents/expert-zk-steward.md +228 -0
  337. package/agents/manager-academic-research.md +96 -0
  338. package/agents/manager-agent-governance.md +90 -0
  339. package/agents/manager-ai-llm.md +94 -0
  340. package/agents/manager-backend-architecture.md +106 -0
  341. package/agents/manager-business-strategy.md +102 -0
  342. package/agents/manager-business-support.md +96 -0
  343. package/agents/manager-customer-support.md +95 -0
  344. package/agents/manager-data-database.md +92 -0
  345. package/agents/manager-data-knowledge.md +88 -0
  346. package/agents/manager-data-testing.md +105 -0
  347. package/agents/manager-design-creative.md +103 -0
  348. package/agents/manager-devops-operations.md +92 -0
  349. package/agents/manager-embedded-iot.md +90 -0
  350. package/agents/manager-engineering-quality.md +94 -0
  351. package/agents/manager-finance-tax.md +99 -0
  352. package/agents/manager-frontend-client.md +116 -0
  353. package/agents/manager-game-dev.md +120 -0
  354. package/agents/manager-gis.md +104 -0
  355. package/agents/manager-government-public.md +84 -0
  356. package/agents/manager-healthcare.md +88 -0
  357. package/agents/manager-hr.md +87 -0
  358. package/agents/manager-language-translation.md +82 -0
  359. package/agents/manager-legal-compliance.md +86 -0
  360. package/agents/manager-marketing-growth.md +138 -0
  361. package/agents/manager-network-engineering.md +83 -0
  362. package/agents/manager-paid-media.md +92 -0
  363. package/agents/manager-product-management.md +90 -0
  364. package/agents/manager-project-management.md +94 -0
  365. package/agents/manager-sales-customer.md +97 -0
  366. package/agents/manager-security-compliance.md +109 -0
  367. package/agents/manager-spatial-computing.md +90 -0
  368. package/agents/manager-supply-chain.md +87 -0
  369. package/bin/cli.js +84 -0
  370. package/commands/wf/archive.md +111 -0
  371. package/commands/wf/check.md +68 -0
  372. package/commands/wf/deliver.md +76 -0
  373. package/commands/wf/design.md +56 -0
  374. package/commands/wf/dispatch.md +90 -0
  375. package/commands/wf/env.md +81 -0
  376. package/commands/wf/implement.md +96 -0
  377. package/commands/wf/plan.md +78 -0
  378. package/commands/wf/resume.md +59 -0
  379. package/commands/wf/spec.md +88 -0
  380. package/commands/wf/triage.md +50 -0
  381. package/commands/wf/verify.md +93 -0
  382. package/config/categories.json +557 -0
  383. package/config/experts.json +3318 -0
  384. package/config/workflow.json +848 -0
  385. package/context/context-manager.py +339 -0
  386. package/docs/workflow-fusion-design.md +239 -0
  387. package/hooks/claude-hooks.json +16 -0
  388. package/hooks/hooks.json +20 -0
  389. package/hooks/prepend-global-rules-reminder.mjs +342 -0
  390. package/icon.png +0 -0
  391. package/package.json +61 -3
  392. package/references/openspec-manual-mode.md +97 -0
  393. package/references/roles/analyst.md +62 -0
  394. package/references/roles/implementer.md +67 -0
  395. package/references/roles/investigator.md +88 -0
  396. package/references/roles/orchestrator.md +66 -0
  397. package/references/roles/reviewer.md +103 -0
  398. package/references/stage-S0-triage.md +68 -0
  399. package/references/stage-S1-design.md +53 -0
  400. package/references/stage-S2-spec.md +135 -0
  401. package/references/stage-S3-plan.md +84 -0
  402. package/references/stage-S4-env-baseline.md +81 -0
  403. package/references/stage-S5-implement.md +139 -0
  404. package/references/stage-S6-verify-review.md +80 -0
  405. package/references/stage-S7-deliver.md +81 -0
  406. package/references/stage-S8-sync-archive.md +168 -0
  407. package/references/workflow-tree.md +98 -0
  408. package/scripts/cc-uninstall.js +123 -0
  409. package/scripts/embedding_client.py +44 -0
  410. package/scripts/install-claude-code.js +477 -0
  411. package/scripts/install.js +1592 -0
  412. package/scripts/llm_client.py +202 -0
  413. package/scripts/openspec_engine.py +707 -0
  414. package/scripts/sdd/review-package +65 -0
  415. package/scripts/sdd/sdd-workspace +108 -0
  416. package/scripts/sdd/task-brief +49 -0
  417. package/scripts/target-menu.js +125 -0
  418. package/scripts/workflow_check.py +1955 -0
  419. package/skill_entry.py +193 -0
  420. package/templates/bug-report.md +86 -0
  421. package/templates/minimal-contract.md +54 -0
  422. package/templates/plan-sections.md +190 -0
  423. package/templates/progress.md +89 -0
  424. package/templates/review-report.md +51 -0
  425. package/templates/task-report.md +84 -0
  426. package/vendor/skills/LICENSE +21 -0
  427. package/vendor/skills/PROVENANCE.md +79 -0
  428. package/vendor/skills/zes-brainstorming/SKILL.md +302 -0
  429. package/vendor/skills/zes-brainstorming/builder-check-prompt.md +23 -0
  430. package/vendor/skills/zes-code-review/SKILL.md +103 -0
  431. package/vendor/skills/zes-finishing/SKILL.md +233 -0
  432. package/vendor/skills/zes-openspec-apply-change/SKILL.md +206 -0
  433. package/vendor/skills/zes-openspec-archive-change/SKILL.md +221 -0
  434. package/vendor/skills/zes-openspec-explore/SKILL.md +356 -0
  435. package/vendor/skills/zes-openspec-propose/SKILL.md +175 -0
  436. package/vendor/skills/zes-openspec-sync-specs/SKILL.md +290 -0
  437. package/vendor/skills/zes-openspec-update-change/SKILL.md +109 -0
  438. package/vendor/skills/zes-receiving-review/SKILL.md +213 -0
  439. package/vendor/skills/zes-sdd/SKILL.md +345 -0
  440. package/vendor/skills/zes-sdd/references/batching.md +11 -0
  441. package/vendor/skills/zes-sdd/references/cannot-verify.md +10 -0
  442. package/vendor/skills/zes-sdd/references/final-review.md +47 -0
  443. package/vendor/skills/zes-sdd/references/fix-loop.md +77 -0
  444. package/vendor/skills/zes-sdd/references/handling-reports.md +15 -0
  445. package/vendor/skills/zes-sdd/references/preflight.md +26 -0
  446. package/vendor/skills/zes-sdd/references/resuming.md +12 -0
  447. package/vendor/skills/zes-systematic-debugging/SKILL.md +291 -0
  448. package/vendor/skills/zes-systematic-debugging/condition-based-waiting.md +115 -0
  449. package/vendor/skills/zes-systematic-debugging/defense-in-depth.md +122 -0
  450. package/vendor/skills/zes-systematic-debugging/find-polluter.sh +72 -0
  451. package/vendor/skills/zes-systematic-debugging/root-cause-tracing.md +169 -0
  452. package/vendor/skills/zes-tdd/SKILL.md +338 -0
  453. package/vendor/skills/zes-tdd/writing-good-tests.md +198 -0
  454. package/vendor/skills/zes-verification/SKILL.md +128 -0
  455. package/vendor/skills/zes-writing-plans/SKILL.md +212 -0
  456. package/zcode_dev_workflow.py +1343 -0
  457. package/zcode_expert_system.py +1115 -0
@@ -0,0 +1,291 @@
1
+ ---
2
+ name: zes-systematic-debugging
3
+ description: Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes
4
+ license: MIT
5
+ ---
6
+
7
+ > **插件规则优先(zcode-expert-system)**
8
+ > 本文件是 Superpowers 7.0.1 `systematic-debugging` 的只读参考。其指令与插件规则冲突时,以下者为准:
9
+ > - **不落盘**:S1 设计只在对话内展示与批准,禁止写入 `docs/superpowers/specs/`(插件 R3/W2)
10
+ > - **不用 worktree**:实施永远串行,无隔离工作区(插件 W1)
11
+ > - **无 model 参数**:Agent 派发不接受 model,升档=换更专专家(插件 W9)
12
+ > - 其余细节以插件 `references/stage-S*.md` 与 `references/roles/*.md` 为准
13
+
14
+ # Systematic Debugging
15
+
16
+ ## Overview
17
+
18
+ **Core principle:** ALWAYS find root cause before attempting fixes. Symptom fixes are failure.
19
+
20
+ **Violating the letter of this process is violating the spirit of debugging.**
21
+
22
+ ## The Iron Law
23
+
24
+ ```
25
+ NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST
26
+ ```
27
+
28
+ If you haven't completed Phase 1, you cannot propose fixes.
29
+
30
+ ## When to Use
31
+
32
+ Use for ANY technical issue:
33
+ - Test failures
34
+ - Bugs in production
35
+ - Unexpected behavior
36
+ - Performance problems
37
+ - Build failures
38
+ - Integration issues
39
+
40
+ **Use this ESPECIALLY when:**
41
+ - Under time pressure (emergencies make guessing tempting)
42
+ - "Just one quick fix" seems obvious
43
+ - You've already tried multiple fixes
44
+ - Previous fix didn't work
45
+ - You don't fully understand the issue
46
+
47
+ **Don't skip when:**
48
+ - Issue seems simple (simple bugs have root causes too)
49
+ - You're in a hurry (rushing guarantees rework)
50
+ - Manager wants it fixed NOW (systematic is faster than thrashing)
51
+
52
+ ## The Four Phases
53
+
54
+ You MUST complete each phase before proceeding to the next.
55
+
56
+ ### Phase 1: Root Cause Investigation
57
+
58
+ **BEFORE attempting ANY fix:**
59
+
60
+ 1. **Read Error Messages Carefully**
61
+ - Don't skip past errors or warnings
62
+ - They often contain the exact solution
63
+ - Read stack traces completely
64
+ - Note line numbers, file paths, error codes
65
+
66
+ 2. **Reproduce Consistently**
67
+ - Can you trigger it reliably?
68
+ - What are the exact steps?
69
+ - Does it happen every time?
70
+ - If not reproducible → gather more data, don't guess
71
+
72
+ 3. **Check Recent Changes**
73
+ - What changed that could cause this?
74
+ - Git diff, recent commits
75
+ - New dependencies, config changes
76
+ - Environmental differences
77
+
78
+ 4. **Gather Evidence in Multi-Component Systems**
79
+
80
+ **WHEN system has multiple components (CI → build → signing, API → service → database):**
81
+
82
+ **BEFORE proposing fixes, add diagnostic instrumentation:**
83
+ ```
84
+ For EACH component boundary:
85
+ - Log what data enters component
86
+ - Log what data exits component
87
+ - Verify environment/config propagation
88
+ - Check state at each layer
89
+
90
+ Run once to gather evidence showing WHERE it breaks
91
+ THEN analyze evidence to identify failing component
92
+ THEN investigate that specific component
93
+ ```
94
+
95
+ **Example (multi-layer system):**
96
+ ```bash
97
+ # Layer 1: Workflow
98
+ echo "=== Secrets available in workflow: ==="
99
+ echo "IDENTITY: $([ -n "${IDENTITY:-}" ] && echo SET || echo UNSET)"
100
+
101
+ # Layer 2: Build script
102
+ echo "=== Env vars in build script: ==="
103
+ printenv IDENTITY >/dev/null 2>&1 && echo "IDENTITY in environment" || echo "IDENTITY not in environment"
104
+
105
+ # Layer 3: Signing script
106
+ echo "=== Keychain state: ==="
107
+ security list-keychains
108
+ security find-identity -v
109
+
110
+ # Layer 4: Actual signing
111
+ codesign --sign "$IDENTITY" --verbose=4 "$APP"
112
+ ```
113
+
114
+ **This reveals:** Which layer fails (secrets → workflow ✓, workflow → build ✗)
115
+
116
+ 5. **Trace Data Flow**
117
+
118
+ **WHEN error is deep in call stack:**
119
+
120
+ See `root-cause-tracing.md` in this directory for the complete backward tracing technique.
121
+
122
+ **Quick version:**
123
+ - Where does bad value originate?
124
+ - What called this with bad value?
125
+ - Keep tracing up until you find the source
126
+ - Fix at source, not at symptom
127
+
128
+ ### Phase 2: Pattern Analysis
129
+
130
+ **Find the pattern before fixing:**
131
+
132
+ 1. **Find Working Examples**
133
+ - Locate similar working code in same codebase
134
+ - What works that's similar to what's broken?
135
+
136
+ 2. **Compare Against References**
137
+ - If implementing pattern, read reference implementation COMPLETELY
138
+ - Don't skim - read every line
139
+ - Understand the pattern fully before applying
140
+
141
+ 3. **Identify Differences**
142
+ - What's different between working and broken?
143
+ - List every difference, however small
144
+ - Don't assume "that can't matter"
145
+
146
+ 4. **Understand Dependencies**
147
+ - What other components does this need?
148
+ - What settings, config, environment?
149
+ - What assumptions does it make?
150
+
151
+ ### Phase 3: Hypothesis and Testing
152
+
153
+ **Scientific method:**
154
+
155
+ 1. **Form Single Hypothesis**
156
+ - State clearly: "I think X is the root cause because Y"
157
+ - Write it down
158
+ - Be specific, not vague
159
+
160
+ 2. **Test Minimally**
161
+ - Make the SMALLEST possible change to test hypothesis
162
+ - One variable at a time
163
+ - Don't fix multiple things at once
164
+
165
+ 3. **Verify Before Continuing**
166
+ - Did it work? Yes → Phase 4
167
+ - Didn't work? Form NEW hypothesis
168
+ - DON'T add more fixes on top
169
+
170
+ 4. **When You Don't Know**
171
+ - Say "I don't understand X"
172
+ - Don't pretend to know
173
+ - Ask for help
174
+ - Research more
175
+
176
+ ### Phase 4: Implementation
177
+
178
+ **Fix the root cause, not the symptom:**
179
+
180
+ 1. **Create Failing Test Case**
181
+ - Simplest possible reproduction
182
+ - Automated test if possible
183
+ - One-off test script if no framework
184
+ - MUST have before fixing
185
+ - Use the `superpowers:test-driven-development` skill for writing proper failing tests
186
+
187
+ 2. **Implement Single Fix**
188
+ - Address the root cause identified
189
+ - ONE change at a time
190
+ - No "while I'm here" improvements
191
+ - No bundled refactoring
192
+
193
+ 3. **Verify Fix**
194
+ - Test passes now?
195
+ - No other tests broken?
196
+ - Issue actually resolved?
197
+ - Use the `superpowers:verification-before-completion` skill before claiming success
198
+
199
+ 4. **If Fix Doesn't Work**
200
+ - STOP
201
+ - Count: How many fixes have you tried?
202
+ - If < 3: Return to Phase 1, re-analyze with new information
203
+ - **If ≥ 3: STOP and question the architecture (step 5 below)**
204
+ - DON'T attempt Fix #4 without architectural discussion
205
+
206
+ 5. **If 3+ Fixes Failed: Question Architecture**
207
+
208
+ **Pattern indicating architectural problem:**
209
+ - Each fix reveals new shared state/coupling/problem in different place
210
+ - Fixes require "massive refactoring" to implement
211
+ - Each fix creates new symptoms elsewhere
212
+
213
+ **STOP and question fundamentals:**
214
+ - Is this pattern fundamentally sound?
215
+ - Are we "sticking with it through sheer inertia"?
216
+ - Should we refactor architecture vs. continue fixing symptoms?
217
+
218
+ **Discuss with your human partner before attempting more fixes**
219
+
220
+ This is NOT a failed hypothesis - this is a wrong architecture.
221
+
222
+ ## Red Flags - STOP and Follow Process
223
+
224
+ If you catch yourself thinking:
225
+ - "Quick fix for now, investigate later"
226
+ - "Just try changing X and see if it works"
227
+ - "Add multiple changes, run tests"
228
+ - "Skip the test, I'll manually verify"
229
+ - "It's probably X, let me fix that"
230
+ - "I don't fully understand but this might work"
231
+ - "Pattern says X but I'll adapt it differently"
232
+ - "Here are the main problems: [lists fixes without investigation]"
233
+ - Proposing solutions before tracing data flow
234
+ - **"One more fix attempt" (when already tried 2+)**
235
+ - **Each fix reveals new problem in different place**
236
+
237
+ **ALL of these mean: STOP. Return to Phase 1.**
238
+
239
+ **If 3+ fixes failed:** Question the architecture (see Phase 4.5)
240
+
241
+ ## your human partner's Signals You're Doing It Wrong
242
+
243
+ **Watch for these redirections:**
244
+ - "Is that not happening?" - You assumed without verifying
245
+ - "Will it show us...?" - You should have added evidence gathering
246
+ - "Stop guessing" - You're proposing fixes without understanding
247
+ - "Ultra-think this" - Question fundamentals, not just symptoms
248
+ - "We're stuck?" (frustrated) - Your approach isn't working
249
+
250
+ **When you see these:** STOP. Return to Phase 1.
251
+
252
+ ## Common Rationalizations
253
+
254
+ | Excuse | Reality |
255
+ |--------|---------|
256
+ | "Issue is simple, don't need process" | Simple issues have root causes too. Process is fast for simple bugs. |
257
+ | "Emergency, no time for process" | Systematic debugging is FASTER than guess-and-check thrashing. |
258
+ | "Just try this first, then investigate" | First fix sets the pattern. Do it right from the start. |
259
+ | "I'll write test after confirming fix works" | Untested fixes don't stick. Test first proves it. |
260
+ | "Multiple fixes at once saves time" | Can't isolate what worked. Causes new bugs. |
261
+ | "Reference too long, I'll adapt the pattern" | Partial understanding guarantees bugs. Read it completely. |
262
+ | "I see the problem, let me fix it" | Seeing symptoms ≠ understanding root cause. |
263
+ | "One more fix attempt" (after 2+ failures) | 3+ failures = architectural problem. Question pattern, don't fix again. |
264
+
265
+ ## Quick Reference
266
+
267
+ | Phase | Key Activities | Success Criteria |
268
+ |-------|---------------|------------------|
269
+ | **1. Root Cause** | Read errors, reproduce, check changes, gather evidence | Understand WHAT and WHY |
270
+ | **2. Pattern** | Find working examples, compare | Identify differences |
271
+ | **3. Hypothesis** | Form theory, test minimally | Confirmed or new hypothesis |
272
+ | **4. Implementation** | Create test, fix, verify | Bug resolved, tests pass |
273
+
274
+ ## When Process Reveals "No Root Cause"
275
+
276
+ If systematic investigation reveals issue is truly environmental, timing-dependent, or external:
277
+
278
+ 1. You've completed the process
279
+ 2. Document what you investigated
280
+ 3. Implement appropriate handling (retry, timeout, error message)
281
+ 4. Add monitoring/logging for future investigation
282
+
283
+ **But:** 95% of "no root cause" cases are incomplete investigation.
284
+
285
+ ## Supporting Techniques
286
+
287
+ These techniques are part of systematic debugging and available in this directory:
288
+
289
+ - **`root-cause-tracing.md`** - Trace bugs backward through call stack to find original trigger
290
+ - **`defense-in-depth.md`** - Add validation at multiple layers after finding root cause
291
+ - **`condition-based-waiting.md`** - Replace arbitrary timeouts with condition polling
@@ -0,0 +1,115 @@
1
+ # Condition-Based Waiting
2
+
3
+ ## Overview
4
+
5
+ Flaky tests often guess at timing with arbitrary delays. This creates race conditions where tests pass on fast machines but fail under load or in CI.
6
+
7
+ **Core principle:** Wait for the actual condition you care about, not a guess about how long it takes.
8
+
9
+ ## When to Use
10
+
11
+ ```dot
12
+ digraph when_to_use {
13
+ "Test uses setTimeout/sleep?" [shape=diamond];
14
+ "Testing timing behavior?" [shape=diamond];
15
+ "Document WHY timeout needed" [shape=box];
16
+ "Use condition-based waiting" [shape=box];
17
+
18
+ "Test uses setTimeout/sleep?" -> "Testing timing behavior?" [label="yes"];
19
+ "Testing timing behavior?" -> "Document WHY timeout needed" [label="yes"];
20
+ "Testing timing behavior?" -> "Use condition-based waiting" [label="no"];
21
+ }
22
+ ```
23
+
24
+ **Use when:**
25
+ - Tests have arbitrary delays (`setTimeout`, `sleep`, `time.sleep()`)
26
+ - Tests are flaky (pass sometimes, fail under load)
27
+ - Tests timeout when run in parallel
28
+ - Waiting for async operations to complete
29
+
30
+ **Don't use when:**
31
+ - Testing actual timing behavior (debounce, throttle intervals)
32
+ - Always document WHY if using arbitrary timeout
33
+
34
+ ## Core Pattern
35
+
36
+ ```typescript
37
+ // ❌ BEFORE: Guessing at timing
38
+ await new Promise(r => setTimeout(r, 50));
39
+ const result = getResult();
40
+ expect(result).toBeDefined();
41
+
42
+ // ✅ AFTER: Waiting for condition
43
+ await waitFor(() => getResult() !== undefined);
44
+ const result = getResult();
45
+ expect(result).toBeDefined();
46
+ ```
47
+
48
+ ## Quick Patterns
49
+
50
+ | Scenario | Pattern |
51
+ |----------|---------|
52
+ | Wait for event | `waitFor(() => events.find(e => e.type === 'DONE'))` |
53
+ | Wait for state | `waitFor(() => machine.state === 'ready')` |
54
+ | Wait for count | `waitFor(() => items.length >= 5)` |
55
+ | Wait for file | `waitFor(() => fs.existsSync(path))` |
56
+ | Complex condition | `waitFor(() => obj.ready && obj.value > 10)` |
57
+
58
+ ## Implementation
59
+
60
+ Generic polling function:
61
+ ```typescript
62
+ async function waitFor<T>(
63
+ condition: () => T | undefined | null | false,
64
+ description: string,
65
+ timeoutMs = 5000
66
+ ): Promise<T> {
67
+ const startTime = Date.now();
68
+
69
+ while (true) {
70
+ const result = condition();
71
+ if (result) return result;
72
+
73
+ if (Date.now() - startTime > timeoutMs) {
74
+ throw new Error(`Timeout waiting for ${description} after ${timeoutMs}ms`);
75
+ }
76
+
77
+ await new Promise(r => setTimeout(r, 10)); // Poll every 10ms
78
+ }
79
+ }
80
+ ```
81
+
82
+ See `condition-based-waiting-example.ts` in this directory for complete implementation with domain-specific helpers (`waitForEvent`, `waitForEventCount`, `waitForEventMatch`) from actual debugging session.
83
+
84
+ ## Common Mistakes
85
+
86
+ **❌ Polling too fast:** `setTimeout(check, 1)` - wastes CPU
87
+ **✅ Fix:** Poll every 10ms
88
+
89
+ **❌ No timeout:** Loop forever if condition never met
90
+ **✅ Fix:** Always include timeout with clear error
91
+
92
+ **❌ Stale data:** Cache state before loop
93
+ **✅ Fix:** Call getter inside loop for fresh data
94
+
95
+ ## When Arbitrary Timeout IS Correct
96
+
97
+ ```typescript
98
+ // Tool ticks every 100ms - need 2 ticks to verify partial output
99
+ await waitForEvent(manager, 'TOOL_STARTED'); // First: wait for condition
100
+ await new Promise(r => setTimeout(r, 200)); // Then: wait for timed behavior
101
+ // 200ms = 2 ticks at 100ms intervals - documented and justified
102
+ ```
103
+
104
+ **Requirements:**
105
+ 1. First wait for triggering condition
106
+ 2. Based on known timing (not guessing)
107
+ 3. Comment explaining WHY
108
+
109
+ ## Real-World Impact
110
+
111
+ From debugging session (2025-10-03):
112
+ - Fixed 15 flaky tests across 3 files
113
+ - Pass rate: 60% → 100%
114
+ - Execution time: 40% faster
115
+ - No more race conditions
@@ -0,0 +1,122 @@
1
+ # Defense-in-Depth Validation
2
+
3
+ ## Overview
4
+
5
+ When you fix a bug caused by invalid data, adding validation at one place feels sufficient. But that single check can be bypassed by different code paths, refactoring, or mocks.
6
+
7
+ **Core principle:** Validate at EVERY layer data passes through. Make the bug structurally impossible.
8
+
9
+ ## Why Multiple Layers
10
+
11
+ Single validation: "We fixed the bug"
12
+ Multiple layers: "We made the bug impossible"
13
+
14
+ Different layers catch different cases:
15
+ - Entry validation catches most bugs
16
+ - Business logic catches edge cases
17
+ - Environment guards prevent context-specific dangers
18
+ - Debug logging helps when other layers fail
19
+
20
+ ## The Four Layers
21
+
22
+ ### Layer 1: Entry Point Validation
23
+ **Purpose:** Reject obviously invalid input at API boundary
24
+
25
+ ```typescript
26
+ function createProject(name: string, workingDirectory: string) {
27
+ if (!workingDirectory || workingDirectory.trim() === '') {
28
+ throw new Error('workingDirectory cannot be empty');
29
+ }
30
+ if (!existsSync(workingDirectory)) {
31
+ throw new Error(`workingDirectory does not exist: ${workingDirectory}`);
32
+ }
33
+ if (!statSync(workingDirectory).isDirectory()) {
34
+ throw new Error(`workingDirectory is not a directory: ${workingDirectory}`);
35
+ }
36
+ // ... proceed
37
+ }
38
+ ```
39
+
40
+ ### Layer 2: Business Logic Validation
41
+ **Purpose:** Ensure data makes sense for this operation
42
+
43
+ ```typescript
44
+ function initializeWorkspace(projectDir: string, sessionId: string) {
45
+ if (!projectDir) {
46
+ throw new Error('projectDir required for workspace initialization');
47
+ }
48
+ // ... proceed
49
+ }
50
+ ```
51
+
52
+ ### Layer 3: Environment Guards
53
+ **Purpose:** Prevent dangerous operations in specific contexts
54
+
55
+ ```typescript
56
+ async function gitInit(directory: string) {
57
+ // In tests, refuse git init outside temp directories
58
+ if (process.env.NODE_ENV === 'test') {
59
+ const normalized = normalize(resolve(directory));
60
+ const tmpDir = normalize(resolve(tmpdir()));
61
+
62
+ if (!normalized.startsWith(tmpDir)) {
63
+ throw new Error(
64
+ `Refusing git init outside temp dir during tests: ${directory}`
65
+ );
66
+ }
67
+ }
68
+ // ... proceed
69
+ }
70
+ ```
71
+
72
+ ### Layer 4: Debug Instrumentation
73
+ **Purpose:** Capture context for forensics
74
+
75
+ ```typescript
76
+ async function gitInit(directory: string) {
77
+ const stack = new Error().stack;
78
+ logger.debug('About to git init', {
79
+ directory,
80
+ cwd: process.cwd(),
81
+ stack,
82
+ });
83
+ // ... proceed
84
+ }
85
+ ```
86
+
87
+ ## Applying the Pattern
88
+
89
+ When you find a bug:
90
+
91
+ 1. **Trace the data flow** - Where does bad value originate? Where used?
92
+ 2. **Map all checkpoints** - List every point data passes through
93
+ 3. **Add validation at each layer** - Entry, business, environment, debug
94
+ 4. **Test each layer** - Try to bypass layer 1, verify layer 2 catches it
95
+
96
+ ## Example from Session
97
+
98
+ Bug: Empty `projectDir` caused `git init` in source code
99
+
100
+ **Data flow:**
101
+ 1. Test setup → empty string
102
+ 2. `Project.create(name, '')`
103
+ 3. `WorkspaceManager.createWorkspace('')`
104
+ 4. `git init` runs in `process.cwd()`
105
+
106
+ **Four layers added:**
107
+ - Layer 1: `Project.create()` validates not empty/exists/writable
108
+ - Layer 2: `WorkspaceManager` validates projectDir not empty
109
+ - Layer 3: `WorktreeManager` refuses git init outside tmpdir in tests
110
+ - Layer 4: Stack trace logging before git init
111
+
112
+ **Result:** All 1847 tests passed, bug impossible to reproduce
113
+
114
+ ## Key Insight
115
+
116
+ All four layers were necessary. During testing, each layer caught bugs the others missed:
117
+ - Different code paths bypassed entry validation
118
+ - Mocks bypassed business logic checks
119
+ - Edge cases on different platforms needed environment guards
120
+ - Debug logging identified structural misuse
121
+
122
+ **Don't stop at one validation point.** Add checks at every layer.
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env bash
2
+ # Bisection script to find which test creates unwanted files/state
3
+ # Usage: ./find-polluter.sh <file_or_dir_to_check> <test_pattern>
4
+ # Example: ./find-polluter.sh '.git' 'src/**/*.test.ts'
5
+
6
+ set -e
7
+
8
+ if [ $# -ne 2 ]; then
9
+ echo "Usage: $0 <file_to_check> <test_pattern>"
10
+ echo "Example: $0 '.git' 'src/**/*.test.ts'"
11
+ exit 1
12
+ fi
13
+
14
+ POLLUTION_CHECK="$1"
15
+ TEST_PATTERN="$2"
16
+
17
+ echo "🔍 Searching for test that creates: $POLLUTION_CHECK"
18
+ echo "Test pattern: $TEST_PATTERN"
19
+ echo ""
20
+
21
+ # Get list of test files (find . emits ./-prefixed paths, so accept the
22
+ # pattern written with or without a leading ./)
23
+ TEST_PATTERN="${TEST_PATTERN#./}"
24
+ # find -path can't match '**/' against zero directory levels, so a pattern
25
+ # like src/**/*.test.ts would skip src/top.test.ts; also try the pattern
26
+ # with '**/' collapsed to cover files directly under the base directory.
27
+ TEST_FILES=$(find . \( -path "./$TEST_PATTERN" -o -path "./${TEST_PATTERN//\*\*\//}" \) | sort -u)
28
+ if [ -z "$TEST_FILES" ]; then
29
+ TOTAL=0
30
+ else
31
+ TOTAL=$(printf '%s\n' "$TEST_FILES" | wc -l | tr -d ' ')
32
+ fi
33
+
34
+ echo "Found $TOTAL test files"
35
+ echo ""
36
+
37
+ COUNT=0
38
+ for TEST_FILE in $TEST_FILES; do
39
+ COUNT=$((COUNT + 1))
40
+
41
+ # Skip if pollution already exists
42
+ if [ -e "$POLLUTION_CHECK" ]; then
43
+ echo "⚠️ Pollution already exists before test $COUNT/$TOTAL"
44
+ echo " Skipping: $TEST_FILE"
45
+ continue
46
+ fi
47
+
48
+ echo "[$COUNT/$TOTAL] Testing: $TEST_FILE"
49
+
50
+ # Run the test
51
+ npm test "$TEST_FILE" > /dev/null 2>&1 || true
52
+
53
+ # Check if pollution appeared
54
+ if [ -e "$POLLUTION_CHECK" ]; then
55
+ echo ""
56
+ echo "🎯 FOUND POLLUTER!"
57
+ echo " Test: $TEST_FILE"
58
+ echo " Created: $POLLUTION_CHECK"
59
+ echo ""
60
+ echo "Pollution details:"
61
+ ls -la "$POLLUTION_CHECK"
62
+ echo ""
63
+ echo "To investigate:"
64
+ echo " npm test $TEST_FILE # Run just this test"
65
+ echo " cat $TEST_FILE # Review test code"
66
+ exit 1
67
+ fi
68
+ done
69
+
70
+ echo ""
71
+ echo "✅ No polluter found - all tests clean!"
72
+ exit 0