agent-toolkit-cli 1.11.0__py3-none-win_amd64.whl

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 (438) hide show
  1. agent_toolkit/__init__.py +4 -0
  2. agent_toolkit/__main__.py +5 -0
  3. agent_toolkit/_paths.py +145 -0
  4. agent_toolkit/bin/.gitkeep +0 -0
  5. agent_toolkit/bin/agent-toolkit.exe +0 -0
  6. agent_toolkit/cli/__init__.py +0 -0
  7. agent_toolkit/cli/__main__.py +5 -0
  8. agent_toolkit/cli/build.py +278 -0
  9. agent_toolkit/cli/completion.py +297 -0
  10. agent_toolkit/cli/context_budget.py +455 -0
  11. agent_toolkit/cli/devcompanion.py +923 -0
  12. agent_toolkit/cli/devcompanion_queue.py +235 -0
  13. agent_toolkit/cli/diff.py +176 -0
  14. agent_toolkit/cli/doctor.py +1052 -0
  15. agent_toolkit/cli/insights.py +771 -0
  16. agent_toolkit/cli/install.py +706 -0
  17. agent_toolkit/cli/main.py +171 -0
  18. agent_toolkit/cli/mcp.py +537 -0
  19. agent_toolkit/cli/memory.py +739 -0
  20. agent_toolkit/cli/plugin.py +224 -0
  21. agent_toolkit/cli/project.py +459 -0
  22. agent_toolkit/cli/release.py +178 -0
  23. agent_toolkit/cli/skills.py +461 -0
  24. agent_toolkit/cli/uninstall.py +166 -0
  25. agent_toolkit/cli/update.py +298 -0
  26. agent_toolkit/cli/workspace.py +1713 -0
  27. agent_toolkit/compiler/hook_registry.py +110 -0
  28. agent_toolkit/compiler/loader.py +338 -0
  29. agent_toolkit/compiler/mcp_registry.py +87 -0
  30. agent_toolkit/compiler/model.py +182 -0
  31. agent_toolkit/compiler/provenance.py +140 -0
  32. agent_toolkit/compiler/registry_emit.py +263 -0
  33. agent_toolkit/compiler/target_registry.py +122 -0
  34. agent_toolkit/compiler/targets/__init__.py +1 -0
  35. agent_toolkit/compiler/targets/agent_plugins.py +160 -0
  36. agent_toolkit/compiler/targets/base.py +229 -0
  37. agent_toolkit/compiler/targets/claude_code.py +241 -0
  38. agent_toolkit/compiler/targets/codex.py +261 -0
  39. agent_toolkit/compiler/targets/copilot.py +275 -0
  40. agent_toolkit/compiler/targets/cursor.py +207 -0
  41. agent_toolkit/compiler/targets/gemini_cli.py +213 -0
  42. agent_toolkit/compiler/targets/muse_code.py +113 -0
  43. agent_toolkit/compiler/targets/opencode.py +204 -0
  44. agent_toolkit/compiler/targets/pi.py +263 -0
  45. agent_toolkit/compiler/targets/windsurf.py +267 -0
  46. agent_toolkit/compiler/tool_mapping.py +83 -0
  47. agent_toolkit/data/.gitignore +4 -0
  48. agent_toolkit/data/__init__.py +1 -0
  49. agent_toolkit/data/agents/agentic-security-reviewer/AGENT.md +60 -0
  50. agent_toolkit/data/agents/architect/AGENT.md +30 -0
  51. agent_toolkit/data/agents/assistant/AGENT.md +59 -0
  52. agent_toolkit/data/agents/build-error-resolver/AGENT.md +30 -0
  53. agent_toolkit/data/agents/client-workflow-bootstrap/AGENT.md +60 -0
  54. agent_toolkit/data/agents/code-reviewer/AGENT.md +49 -0
  55. agent_toolkit/data/agents/database-reviewer/AGENT.md +44 -0
  56. agent_toolkit/data/agents/docs-lookup/AGENT.md +28 -0
  57. agent_toolkit/data/agents/e2e-runner/AGENT.md +38 -0
  58. agent_toolkit/data/agents/performance-optimizer/AGENT.md +52 -0
  59. agent_toolkit/data/agents/planner/AGENT.md +41 -0
  60. agent_toolkit/data/agents/refactor-cleaner/AGENT.md +43 -0
  61. agent_toolkit/data/agents/reference-lookup/AGENT.md +33 -0
  62. agent_toolkit/data/agents/security-reviewer/AGENT.md +47 -0
  63. agent_toolkit/data/agents/tdd-guide/AGENT.md +58 -0
  64. agent_toolkit/data/agents/tech-assistant/AGENT.md +11 -0
  65. agent_toolkit/data/agents/typescript-reviewer/AGENT.md +61 -0
  66. agent_toolkit/data/capabilities/hooks/README.md +6 -0
  67. agent_toolkit/data/capabilities/hooks/pre-commit-validate.yaml +26 -0
  68. agent_toolkit/data/capabilities/hooks/scripts/pre-commit-validate.sh +41 -0
  69. agent_toolkit/data/capabilities/hooks/scripts/session-start-context.sh +11 -0
  70. agent_toolkit/data/capabilities/hooks/session-start-context.yaml +23 -0
  71. agent_toolkit/data/capabilities/targets/registry.yaml +90 -0
  72. agent_toolkit/data/capabilities/upstream.lock +118 -0
  73. agent_toolkit/data/catalogs/agent-catalog.yaml +81 -0
  74. agent_toolkit/data/catalogs/loop-catalog.yaml +55 -0
  75. agent_toolkit/data/catalogs/skill-catalog.yaml +520 -0
  76. agent_toolkit/data/catalogs/skills-layout.json +391 -0
  77. agent_toolkit/data/distributions/products.yaml +190 -0
  78. agent_toolkit/data/distributions/targets/claude-code.yaml +47 -0
  79. agent_toolkit/data/distributions/targets/cursor.yaml +42 -0
  80. agent_toolkit/data/distributions/targets/opencode.yaml +55 -0
  81. agent_toolkit/data/loops/changelog-drafter/loop.yaml +40 -0
  82. agent_toolkit/data/loops/ci-sweeper/loop.yaml +53 -0
  83. agent_toolkit/data/loops/daily-triage/loop.yaml +47 -0
  84. agent_toolkit/data/loops/dep-sweeper/loop.yaml +46 -0
  85. agent_toolkit/data/loops/issue-triage/loop.yaml +40 -0
  86. agent_toolkit/data/loops/oss-daily-briefing/loop.yaml +65 -0
  87. agent_toolkit/data/loops/oss-pr-monitor/loop.yaml +86 -0
  88. agent_toolkit/data/loops/oss-triage/loop.yaml +67 -0
  89. agent_toolkit/data/loops/post-merge-cleanup/loop.yaml +44 -0
  90. agent_toolkit/data/loops/pr-babysitter/loop.yaml +46 -0
  91. agent_toolkit/data/mcp/registry/chrome-devtools.yaml +61 -0
  92. agent_toolkit/data/mcp/registry/clickup.yaml +48 -0
  93. agent_toolkit/data/mcp/registry/figma.yaml +44 -0
  94. agent_toolkit/data/mcp/registry/github.yaml +52 -0
  95. agent_toolkit/data/mcp/registry/linear.yaml +47 -0
  96. agent_toolkit/data/mcp/registry/notion.yaml +48 -0
  97. agent_toolkit/data/mcp/registry/slack.yaml +46 -0
  98. agent_toolkit/data/mcp/templates/chrome-devtools/README.md +57 -0
  99. agent_toolkit/data/mcp/templates/chrome-devtools/config.template.json +6 -0
  100. agent_toolkit/data/mcp/templates/clickup/README.md +45 -0
  101. agent_toolkit/data/mcp/templates/clickup/config.template.json +8 -0
  102. agent_toolkit/data/mcp/templates/clickup/wrapper.sh +23 -0
  103. agent_toolkit/data/mcp/templates/figma/README.md +54 -0
  104. agent_toolkit/data/mcp/templates/figma/config.template.json +9 -0
  105. agent_toolkit/data/mcp/templates/github/README.md +16 -0
  106. agent_toolkit/data/mcp/templates/github/config.template.json +15 -0
  107. agent_toolkit/data/mcp/templates/github/wrapper.sh +6 -0
  108. agent_toolkit/data/mcp/templates/linear/README.md +49 -0
  109. agent_toolkit/data/mcp/templates/linear/config.template.json +10 -0
  110. agent_toolkit/data/mcp/templates/notion/README.md +7 -0
  111. agent_toolkit/data/mcp/templates/notion/config.template.json +8 -0
  112. agent_toolkit/data/mcp/templates/notion/wrapper.sh +23 -0
  113. agent_toolkit/data/mcp/templates/slack/README.md +8 -0
  114. agent_toolkit/data/mcp/templates/slack/config.template.json +9 -0
  115. agent_toolkit/data/mcp/templates/slack/wrapper.sh +23 -0
  116. agent_toolkit/data/packs/README.md +66 -0
  117. agent_toolkit/data/packs/agentic-security/README.md +19 -0
  118. agent_toolkit/data/packs/agentic-security/config.yaml +25 -0
  119. agent_toolkit/data/packs/architecture/README.md +22 -0
  120. agent_toolkit/data/packs/architecture/config.yaml +27 -0
  121. agent_toolkit/data/packs/code-quality/README.md +19 -0
  122. agent_toolkit/data/packs/code-quality/config.yaml +21 -0
  123. agent_toolkit/data/packs/delivery-discipline/README.md +19 -0
  124. agent_toolkit/data/packs/delivery-discipline/config.yaml +42 -0
  125. agent_toolkit/data/packs/design-engineering/README.md +19 -0
  126. agent_toolkit/data/packs/design-engineering/config.yaml +41 -0
  127. agent_toolkit/data/packs/engineering-workflow/README.md +21 -0
  128. agent_toolkit/data/packs/engineering-workflow/config.yaml +57 -0
  129. agent_toolkit/data/packs/oss-maintenance/README.md +245 -0
  130. agent_toolkit/data/packs/oss-maintenance/config.yaml +75 -0
  131. agent_toolkit/data/profiles/claude-code/CLAUDE.md +110 -0
  132. agent_toolkit/data/profiles/claude-code/agents/assistant.md +59 -0
  133. agent_toolkit/data/profiles/claude-code/agents/build-error-resolver.md +30 -0
  134. agent_toolkit/data/profiles/claude-code/agents/client-workflow-bootstrap.md +60 -0
  135. agent_toolkit/data/profiles/claude-code/agents/contribution-planner.md +39 -0
  136. agent_toolkit/data/profiles/claude-code/agents/database-reviewer.md +44 -0
  137. agent_toolkit/data/profiles/claude-code/agents/docs-lookup.md +28 -0
  138. agent_toolkit/data/profiles/claude-code/agents/e2e-runner.md +38 -0
  139. agent_toolkit/data/profiles/claude-code/agents/performance-optimizer.md +52 -0
  140. agent_toolkit/data/profiles/claude-code/agents/planner.md +41 -0
  141. agent_toolkit/data/profiles/claude-code/agents/refactor-cleaner.md +43 -0
  142. agent_toolkit/data/profiles/claude-code/agents/reference-lookup.md +33 -0
  143. agent_toolkit/data/profiles/claude-code/agents/security-reviewer.md +47 -0
  144. agent_toolkit/data/profiles/claude-code/agents/tdd-guide.md +58 -0
  145. agent_toolkit/data/profiles/claude-code/agents/typescript-reviewer.md +61 -0
  146. agent_toolkit/data/profiles/claude-code/settings.json +86 -0
  147. agent_toolkit/data/profiles/copilot/copilot-instructions.md +15 -0
  148. agent_toolkit/data/profiles/cursor/README.md +33 -0
  149. agent_toolkit/data/profiles/cursor/rules/architect.mdc +23 -0
  150. agent_toolkit/data/profiles/cursor/rules/assistant.mdc +61 -0
  151. agent_toolkit/data/profiles/cursor/rules/build-error-resolver.mdc +20 -0
  152. agent_toolkit/data/profiles/cursor/rules/code-reviewer.mdc +21 -0
  153. agent_toolkit/data/profiles/cursor/rules/database-reviewer.mdc +29 -0
  154. agent_toolkit/data/profiles/cursor/rules/docs-lookup.mdc +15 -0
  155. agent_toolkit/data/profiles/cursor/rules/e2e-runner.mdc +30 -0
  156. agent_toolkit/data/profiles/cursor/rules/performance-optimizer.mdc +27 -0
  157. agent_toolkit/data/profiles/cursor/rules/planner.mdc +28 -0
  158. agent_toolkit/data/profiles/cursor/rules/refactor-cleaner.mdc +26 -0
  159. agent_toolkit/data/profiles/cursor/rules/reference-lookup.mdc +20 -0
  160. agent_toolkit/data/profiles/cursor/rules/security-reviewer.mdc +20 -0
  161. agent_toolkit/data/profiles/cursor/rules/tdd-guide.mdc +26 -0
  162. agent_toolkit/data/profiles/cursor/rules/typescript-reviewer.mdc +28 -0
  163. agent_toolkit/data/profiles/muse-code/README.md +35 -0
  164. agent_toolkit/data/profiles/opencode/README.md +44 -0
  165. agent_toolkit/data/profiles/opencode/agents/architect.md +30 -0
  166. agent_toolkit/data/profiles/opencode/agents/assistant.md +96 -0
  167. agent_toolkit/data/profiles/opencode/agents/build-error-resolver.md +31 -0
  168. agent_toolkit/data/profiles/opencode/agents/client-workflow-bootstrap.md +66 -0
  169. agent_toolkit/data/profiles/opencode/agents/code-reviewer.md +47 -0
  170. agent_toolkit/data/profiles/opencode/agents/contribution-planner.md +44 -0
  171. agent_toolkit/data/profiles/opencode/agents/database-reviewer.md +43 -0
  172. agent_toolkit/data/profiles/opencode/agents/docs-lookup.md +28 -0
  173. agent_toolkit/data/profiles/opencode/agents/e2e-runner.md +33 -0
  174. agent_toolkit/data/profiles/opencode/agents/performance-optimizer.md +34 -0
  175. agent_toolkit/data/profiles/opencode/agents/planner.md +27 -0
  176. agent_toolkit/data/profiles/opencode/agents/refactor-cleaner.md +27 -0
  177. agent_toolkit/data/profiles/opencode/agents/reference-lookup.md +27 -0
  178. agent_toolkit/data/profiles/opencode/agents/security-reviewer.md +27 -0
  179. agent_toolkit/data/profiles/opencode/agents/tdd-guide.md +27 -0
  180. agent_toolkit/data/profiles/opencode/agents/typescript-reviewer.md +30 -0
  181. agent_toolkit/data/profiles/opencode/opencode.json +3 -0
  182. agent_toolkit/data/profiles/pi/skills/architect/skill.md +5 -0
  183. agent_toolkit/data/profiles/pi/skills/assistant/skill.md +3 -0
  184. agent_toolkit/data/profiles/pi/skills/code-reviewer/skill.md +5 -0
  185. agent_toolkit/data/profiles/pi/skills/planner/skill.md +3 -0
  186. agent_toolkit/data/profiles/pi/skills/security-reviewer/skill.md +3 -0
  187. agent_toolkit/data/profiles/windsurf/memories/global_rules.md +114 -0
  188. agent_toolkit/data/profiles/windsurf/rules/architect.mdc +23 -0
  189. agent_toolkit/data/profiles/windsurf/rules/assistant.mdc +61 -0
  190. agent_toolkit/data/profiles/windsurf/rules/build-error-resolver.mdc +20 -0
  191. agent_toolkit/data/profiles/windsurf/rules/code-reviewer.mdc +21 -0
  192. agent_toolkit/data/profiles/windsurf/rules/database-reviewer.mdc +29 -0
  193. agent_toolkit/data/profiles/windsurf/rules/docs-lookup.mdc +15 -0
  194. agent_toolkit/data/profiles/windsurf/rules/e2e-runner.mdc +30 -0
  195. agent_toolkit/data/profiles/windsurf/rules/performance-optimizer.mdc +27 -0
  196. agent_toolkit/data/profiles/windsurf/rules/planner.mdc +28 -0
  197. agent_toolkit/data/profiles/windsurf/rules/refactor-cleaner.mdc +26 -0
  198. agent_toolkit/data/profiles/windsurf/rules/reference-lookup.mdc +20 -0
  199. agent_toolkit/data/profiles/windsurf/rules/security-reviewer.mdc +20 -0
  200. agent_toolkit/data/profiles/windsurf/rules/tdd-guide.mdc +26 -0
  201. agent_toolkit/data/profiles/windsurf/rules/typescript-reviewer.mdc +28 -0
  202. agent_toolkit/data/skills/accessibility/review/SKILL.md +116 -0
  203. agent_toolkit/data/skills/accessibility/review/references/a11y-checklist.md +25 -0
  204. agent_toolkit/data/skills/accessibility/review/references/a11y-findings-template.md +56 -0
  205. agent_toolkit/data/skills/accessibility/review/references/research.md +47 -0
  206. agent_toolkit/data/skills/agentic-security/mcp-audit/SKILL.md +116 -0
  207. agent_toolkit/data/skills/agentic-security/mcp-audit/references/mcp-audit-template.md +51 -0
  208. agent_toolkit/data/skills/agentic-security/owasp-agentic-review/SKILL.md +73 -0
  209. agent_toolkit/data/skills/agentic-security/owasp-agentic-review/references/owasp-agentic-template.md +32 -0
  210. agent_toolkit/data/skills/agentic-security/supply-chain-audit/SKILL.md +142 -0
  211. agent_toolkit/data/skills/agentic-security/threat-modeling/SKILL.md +100 -0
  212. agent_toolkit/data/skills/agentic-security/threat-modeling/references/threat-model-template.md +55 -0
  213. agent_toolkit/data/skills/architecture/c4-model/SKILL.md +49 -0
  214. agent_toolkit/data/skills/cloud/aws-well-architected-review/SKILL.md +37 -0
  215. agent_toolkit/data/skills/cloud/cloud-design-patterns/SKILL.md +38 -0
  216. agent_toolkit/data/skills/core/assistant/SKILL.md +216 -0
  217. agent_toolkit/data/skills/core/assistant/references/AGENTS_TEMPLATE.md +0 -0
  218. agent_toolkit/data/skills/core/assistant/references/ORCHESTRATION.md +0 -0
  219. agent_toolkit/data/skills/core/assistant/references/REPO_INSPECTION.md +0 -0
  220. agent_toolkit/data/skills/core/dev-companion/SKILL.md +65 -0
  221. agent_toolkit/data/skills/core/dev-companion/references/LOOP_GUARDRAILS.md +0 -0
  222. agent_toolkit/data/skills/core/onboarding/SKILL.md +122 -0
  223. agent_toolkit/data/skills/core/output-handshake/SKILL.md +26 -0
  224. agent_toolkit/data/skills/core/pr-fallback/SKILL.md +35 -0
  225. agent_toolkit/data/skills/core/pr-fallback/references/pr-body-default.md +0 -0
  226. agent_toolkit/data/skills/core/project/SKILL.md +89 -0
  227. agent_toolkit/data/skills/core/workspace/SKILL.md +103 -0
  228. agent_toolkit/data/skills/core/workspace-knowledge-sync/SKILL.md +140 -0
  229. agent_toolkit/data/skills/data/dbt-validation/SKILL.md +41 -0
  230. agent_toolkit/data/skills/data/snowflake-validation/SKILL.md +38 -0
  231. agent_toolkit/data/skills/delivery/adr/SKILL.md +56 -0
  232. agent_toolkit/data/skills/delivery/adr/references/default-template.md +35 -0
  233. agent_toolkit/data/skills/delivery/adr/references/example-001-graphql-adoption.md +66 -0
  234. agent_toolkit/data/skills/delivery/agreement/SKILL.md +24 -0
  235. agent_toolkit/data/skills/delivery/agreement/references/default-template.md +17 -0
  236. agent_toolkit/data/skills/delivery/agreement/references/example-api-versioning.md +29 -0
  237. agent_toolkit/data/skills/delivery/bug/SKILL.md +26 -0
  238. agent_toolkit/data/skills/delivery/bug/references/default-template.md +26 -0
  239. agent_toolkit/data/skills/delivery/bug/references/example-search-filter-bug.md +58 -0
  240. agent_toolkit/data/skills/delivery/decision-log/SKILL.md +28 -0
  241. agent_toolkit/data/skills/delivery/decision-log/references/default-template.md +17 -0
  242. agent_toolkit/data/skills/delivery/decision-log/references/example-repository-pattern.md +27 -0
  243. agent_toolkit/data/skills/delivery/development-workflow/SKILL.md +34 -0
  244. agent_toolkit/data/skills/delivery/development-workflow/references/default-workflow-checklist.md +44 -0
  245. agent_toolkit/data/skills/delivery/epic/SKILL.md +22 -0
  246. agent_toolkit/data/skills/delivery/epic/references/default-template.md +26 -0
  247. agent_toolkit/data/skills/delivery/epic/references/example-unified-dashboard.md +40 -0
  248. agent_toolkit/data/skills/delivery/incident/SKILL.md +24 -0
  249. agent_toolkit/data/skills/delivery/incident/references/default-template.md +29 -0
  250. agent_toolkit/data/skills/delivery/incident/references/example-payment-outage.md +62 -0
  251. agent_toolkit/data/skills/delivery/management-unit-assessment/SKILL.md +104 -0
  252. agent_toolkit/data/skills/delivery/management-unit-assessment/references/default-template.md +24 -0
  253. agent_toolkit/data/skills/delivery/management-unit-assessment/references/example-team-assessment.md +126 -0
  254. agent_toolkit/data/skills/delivery/meeting-minutes/SKILL.md +25 -0
  255. agent_toolkit/data/skills/delivery/meeting-minutes/references/default-template.md +22 -0
  256. agent_toolkit/data/skills/delivery/meeting-minutes/references/example-weekly-sync.md +72 -0
  257. agent_toolkit/data/skills/delivery/planning/SKILL.md +31 -0
  258. agent_toolkit/data/skills/delivery/planning/references/default-template.md +25 -0
  259. agent_toolkit/data/skills/delivery/planning/references/example-sprint-planning.md +62 -0
  260. agent_toolkit/data/skills/delivery/prd/SKILL.md +46 -0
  261. agent_toolkit/data/skills/delivery/prd/references/default-template.md +31 -0
  262. agent_toolkit/data/skills/delivery/prd/references/example-unified-api.md +71 -0
  263. agent_toolkit/data/skills/delivery/project-assessment/SKILL.md +90 -0
  264. agent_toolkit/data/skills/delivery/project-assessment/references/default-template.md +26 -0
  265. agent_toolkit/data/skills/delivery/project-assessment/references/example-platform-assessment.md +122 -0
  266. agent_toolkit/data/skills/delivery/project-assessment-evidence/SKILL.md +88 -0
  267. agent_toolkit/data/skills/delivery/project-assessment-evidence/references/default-template.md +24 -0
  268. agent_toolkit/data/skills/delivery/project-assessment-evidence/references/example-evidence-map.md +46 -0
  269. agent_toolkit/data/skills/delivery/spike/SKILL.md +24 -0
  270. agent_toolkit/data/skills/delivery/spike/references/default-template.md +29 -0
  271. agent_toolkit/data/skills/delivery/spike/references/example-graphql-federation.md +79 -0
  272. agent_toolkit/data/skills/delivery/task/SKILL.md +21 -0
  273. agent_toolkit/data/skills/delivery/task/references/default-template.md +21 -0
  274. agent_toolkit/data/skills/delivery/task/references/example-nav-system.md +33 -0
  275. agent_toolkit/data/skills/delivery/technical-unit-assessment/SKILL.md +58 -0
  276. agent_toolkit/data/skills/delivery/technical-unit-assessment/references/default-template.md +26 -0
  277. agent_toolkit/data/skills/delivery/technical-unit-assessment/references/example-frontend-assessment.md +112 -0
  278. agent_toolkit/data/skills/delivery/technical-unit-assessment/references/indicator-groups.md +65 -0
  279. agent_toolkit/data/skills/delivery/trd/SKILL.md +49 -0
  280. agent_toolkit/data/skills/delivery/trd/references/default-template.md +31 -0
  281. agent_toolkit/data/skills/delivery/trd/references/example-api-migration.md +122 -0
  282. agent_toolkit/data/skills/delivery/user-story/SKILL.md +21 -0
  283. agent_toolkit/data/skills/delivery/user-story/references/default-template.md +21 -0
  284. agent_toolkit/data/skills/delivery/user-story/references/example-advanced-filtering.md +37 -0
  285. agent_toolkit/data/skills/delivery/work-item/SKILL.md +31 -0
  286. agent_toolkit/data/skills/delivery/work-item/references/default-template.md +21 -0
  287. agent_toolkit/data/skills/delivery/work-item/references/example-routing-dashboard.md +23 -0
  288. agent_toolkit/data/skills/delivery/workflow-client-bootstrap/SKILL.md +148 -0
  289. agent_toolkit/data/skills/delivery/workflow-client-bootstrap/questions.yaml +165 -0
  290. agent_toolkit/data/skills/delivery/workflow-generic-project/SKILL.md +79 -0
  291. agent_toolkit/data/skills/design/design-assessment/SKILL.md +150 -0
  292. agent_toolkit/data/skills/design/design-assessment/references/design-scorecard-template.md +78 -0
  293. agent_toolkit/data/skills/design/design-improvement/SKILL.md +167 -0
  294. agent_toolkit/data/skills/design/design-improvement/references/improvement-plan-template.md +113 -0
  295. agent_toolkit/data/skills/design/figma/LICENSE.txt +2 -0
  296. agent_toolkit/data/skills/design/figma/NOTICE.txt +25 -0
  297. agent_toolkit/data/skills/design/figma/SKILL.md +98 -0
  298. agent_toolkit/data/skills/design/figma/references/figma-mcp-config.md +82 -0
  299. agent_toolkit/data/skills/design/figma/references/figma-tools-and-prompts.md +34 -0
  300. agent_toolkit/data/skills/design/figma-code-connect-components/LICENSE.txt +2 -0
  301. agent_toolkit/data/skills/design/figma-code-connect-components/NOTICE.txt +18 -0
  302. agent_toolkit/data/skills/design/figma-code-connect-components/SKILL.md +354 -0
  303. agent_toolkit/data/skills/design/figma-code-connect-components/references/mapping-checklist.md +7 -0
  304. agent_toolkit/data/skills/design/figma-code-connect-components/scripts/normalize_node_id.py +25 -0
  305. agent_toolkit/data/skills/design/figma-create-design-system-rules/LICENSE.txt +2 -0
  306. agent_toolkit/data/skills/design/figma-create-design-system-rules/NOTICE.txt +19 -0
  307. agent_toolkit/data/skills/design/figma-create-design-system-rules/SKILL.md +554 -0
  308. agent_toolkit/data/skills/design/figma-create-design-system-rules/references/rule-template.md +15 -0
  309. agent_toolkit/data/skills/design/figma-create-design-system-rules/scripts/check_agents_md.sh +9 -0
  310. agent_toolkit/data/skills/design/figma-create-new-file/LICENSE.txt +2 -0
  311. agent_toolkit/data/skills/design/figma-create-new-file/NOTICE.txt +17 -0
  312. agent_toolkit/data/skills/design/figma-create-new-file/SKILL.md +72 -0
  313. agent_toolkit/data/skills/design/figma-implement-design/LICENSE.txt +2 -0
  314. agent_toolkit/data/skills/design/figma-implement-design/NOTICE.txt +19 -0
  315. agent_toolkit/data/skills/design/figma-implement-design/SKILL.md +268 -0
  316. agent_toolkit/data/skills/design/frontend-design/LICENSE.txt +177 -0
  317. agent_toolkit/data/skills/design/frontend-design/SKILL.md +82 -0
  318. agent_toolkit/data/skills/design/frontend-design/UPSTREAM.md +14 -0
  319. agent_toolkit/data/skills/design/frontend-design-review/LICENSE +21 -0
  320. agent_toolkit/data/skills/design/frontend-design-review/SKILL.md +194 -0
  321. agent_toolkit/data/skills/design/frontend-design-review/references/pattern-examples.md +21 -0
  322. agent_toolkit/data/skills/design/frontend-design-review/references/quick-checklist.md +38 -0
  323. agent_toolkit/data/skills/design/frontend-design-review/references/review-output-format.md +68 -0
  324. agent_toolkit/data/skills/design/frontend-design-review/references/review-type-modifiers.md +31 -0
  325. agent_toolkit/data/skills/design/web-design-guidelines/SKILL.md +78 -0
  326. agent_toolkit/data/skills/design/web-design-guidelines/references/LICENSE +21 -0
  327. agent_toolkit/data/skills/design/web-design-guidelines/references/web-interface-guidelines.md +180 -0
  328. agent_toolkit/data/skills/forge/gh-address-comments/LICENSE.txt +202 -0
  329. agent_toolkit/data/skills/forge/gh-address-comments/NOTICE.txt +20 -0
  330. agent_toolkit/data/skills/forge/gh-address-comments/SKILL.md +72 -0
  331. agent_toolkit/data/skills/forge/gh-address-comments/scripts/fetch_comments.py +239 -0
  332. agent_toolkit/data/skills/forge/gh-contribution-planner/SKILL.md +160 -0
  333. agent_toolkit/data/skills/forge/gh-contribution-planner/scripts/inspect_contributions.py +818 -0
  334. agent_toolkit/data/skills/forge/gh-fix-ci/LICENSE.txt +201 -0
  335. agent_toolkit/data/skills/forge/gh-fix-ci/NOTICE.txt +20 -0
  336. agent_toolkit/data/skills/forge/gh-fix-ci/SKILL.md +74 -0
  337. agent_toolkit/data/skills/forge/gh-fix-ci/scripts/inspect_pr_checks.py +509 -0
  338. agent_toolkit/data/skills/forge/github-cli-workflow/SKILL.md +49 -0
  339. agent_toolkit/data/skills/forge/gitlab-cli-workflow/SKILL.md +44 -0
  340. agent_toolkit/data/skills/forge/workflow-client-bootstrap/SKILL.md +14 -0
  341. agent_toolkit/data/skills/forge/workflow-generic-project/SKILL.md +14 -0
  342. agent_toolkit/data/skills/forge/worktree/SKILL.md +113 -0
  343. agent_toolkit/data/skills/integrations/clickup-cli/SKILL.md +78 -0
  344. agent_toolkit/data/skills/integrations/clickup-cli/references/docs-management.md +57 -0
  345. agent_toolkit/data/skills/integrations/clickup-cli/references/task-management.md +131 -0
  346. agent_toolkit/data/skills/integrations/clickup-cli/references/time-tracking.md +38 -0
  347. agent_toolkit/data/skills/integrations/linear/LICENSE.txt +202 -0
  348. agent_toolkit/data/skills/integrations/linear/NOTICE.txt +23 -0
  349. agent_toolkit/data/skills/integrations/linear/SKILL.md +134 -0
  350. agent_toolkit/data/skills/integrations/mcp/SKILL.md +88 -0
  351. agent_toolkit/data/skills/integrations/slack-assistant/SKILL.md +138 -0
  352. agent_toolkit/data/skills/integrations/slack-cli/SKILL.md +109 -0
  353. agent_toolkit/data/skills/integrations/slack-cli/references/INSTALLATION.md +42 -0
  354. agent_toolkit/data/skills/loops/loop-runner/SKILL.md +92 -0
  355. agent_toolkit/data/skills/ops/docs-generator/SKILL.md +120 -0
  356. agent_toolkit/data/skills/ops/llm-cost-advisor/SKILL.md +87 -0
  357. agent_toolkit/data/skills/ops/swarm/SKILL.md +108 -0
  358. agent_toolkit/data/skills/ops/swarm-handoff/SKILL.md +112 -0
  359. agent_toolkit/data/skills/ops/swarm-observer/SKILL.md +102 -0
  360. agent_toolkit/data/skills/ops/triage/SKILL.md +119 -0
  361. agent_toolkit/data/skills/quality/codeql/SKILL.md +106 -0
  362. agent_toolkit/data/skills/quality/codeql/references/codeql-queries.md +43 -0
  363. agent_toolkit/data/skills/quality/megalinter/SKILL.md +162 -0
  364. agent_toolkit/data/skills/quality/megalinter/references/megalinter-images.md +36 -0
  365. agent_toolkit/data/skills/quality/megalinter/references/megalinter-license.md +41 -0
  366. agent_toolkit/data/skills/quality/megalinter/references/megalinter-targets.md +66 -0
  367. agent_toolkit/data/skills/tooling/chrome-devtools/SKILL.md +146 -0
  368. agent_toolkit/data/skills/tooling/herdr/SKILL.md +109 -0
  369. agent_toolkit/data/skills/tooling/inventory/SKILL.md +81 -0
  370. agent_toolkit/data/skills/tooling/jupyter-notebook/LICENSE.txt +201 -0
  371. agent_toolkit/data/skills/tooling/jupyter-notebook/NOTICE.txt +27 -0
  372. agent_toolkit/data/skills/tooling/jupyter-notebook/SKILL.md +145 -0
  373. agent_toolkit/data/skills/tooling/jupyter-notebook/assets/experiment-template.ipynb +117 -0
  374. agent_toolkit/data/skills/tooling/jupyter-notebook/assets/tutorial-template.ipynb +115 -0
  375. agent_toolkit/data/skills/tooling/jupyter-notebook/references/experiment-patterns.md +10 -0
  376. agent_toolkit/data/skills/tooling/jupyter-notebook/references/notebook-structure.md +17 -0
  377. agent_toolkit/data/skills/tooling/jupyter-notebook/references/quality-checklist.md +11 -0
  378. agent_toolkit/data/skills/tooling/jupyter-notebook/references/tutorial-patterns.md +9 -0
  379. agent_toolkit/data/skills/tooling/jupyter-notebook/scripts/new_notebook.py +132 -0
  380. agent_toolkit/data/skills/tooling/mermaid/SKILL.md +36 -0
  381. agent_toolkit/data/skills/tooling/playwright-cli/LICENSE.txt +201 -0
  382. agent_toolkit/data/skills/tooling/playwright-cli/NOTICE.txt +29 -0
  383. agent_toolkit/data/skills/tooling/playwright-cli/SKILL.md +154 -0
  384. agent_toolkit/data/skills/tooling/playwright-cli/references/cli.md +116 -0
  385. agent_toolkit/data/skills/tooling/playwright-cli/references/workflows.md +98 -0
  386. agent_toolkit/data/skills/tooling/playwright-cli/scripts/executable_playwright_cli.sh +25 -0
  387. agent_toolkit/data_cache.py +79 -0
  388. agent_toolkit/data_sync.py +144 -0
  389. agent_toolkit/installer/__init__.py +0 -0
  390. agent_toolkit/installer/merge.py +59 -0
  391. agent_toolkit/installer/receipt.py +89 -0
  392. agent_toolkit/installer/sources.py +92 -0
  393. agent_toolkit/installer/tracking.py +63 -0
  394. agent_toolkit/launcher.py +69 -0
  395. agent_toolkit/loop/__init__.py +0 -0
  396. agent_toolkit/loop/budget.py +107 -0
  397. agent_toolkit/loop/gh_gate.py +923 -0
  398. agent_toolkit/loop/loop-gh-gate +923 -0
  399. agent_toolkit/loop/pack.py +65 -0
  400. agent_toolkit/loop/runner.py +2722 -0
  401. agent_toolkit/runner/__init__.py +0 -0
  402. agent_toolkit/runner/dispatcher.py +163 -0
  403. agent_toolkit/runner/policy.py +356 -0
  404. agent_toolkit/runner/providers/__init__.py +21 -0
  405. agent_toolkit/runner/providers/anthropic_provider.py +109 -0
  406. agent_toolkit/runner/providers/base.py +53 -0
  407. agent_toolkit/runner/providers/ollama_provider.py +108 -0
  408. agent_toolkit/runner/providers/openai_provider.py +103 -0
  409. agent_toolkit/runner/providers/opencode_provider.py +127 -0
  410. agent_toolkit/swarm/__init__.py +5 -0
  411. agent_toolkit/swarm/approvals.py +121 -0
  412. agent_toolkit/swarm/backends/__init__.py +596 -0
  413. agent_toolkit/swarm/budget.py +83 -0
  414. agent_toolkit/swarm/cli.py +2448 -0
  415. agent_toolkit/swarm/config.py +351 -0
  416. agent_toolkit/swarm/handoff.py +174 -0
  417. agent_toolkit/swarm/models.py +230 -0
  418. agent_toolkit/swarm/prompts.py +177 -0
  419. agent_toolkit/swarm/recipes.py +304 -0
  420. agent_toolkit/swarm/runner.py +267 -0
  421. agent_toolkit/swarm/state.py +93 -0
  422. agent_toolkit/swarm/store.py +148 -0
  423. agent_toolkit/swarm/worktree.py +105 -0
  424. agent_toolkit/templates/workspace/.gitignore +19 -0
  425. agent_toolkit/templates/workspace/AGENTS.md +82 -0
  426. agent_toolkit/templates/workspace/knowledge/README.md +22 -0
  427. agent_toolkit/templates/workspace/knowledge/learnings/general.md +3 -0
  428. agent_toolkit/templates/workspace/knowledge/todos/pending.md +7 -0
  429. agent_toolkit/templates/workspace/packs/README.md +24 -0
  430. agent_toolkit/templates/workspace/personas/architect.md +12 -0
  431. agent_toolkit/templates/workspace/personas/implementer.md +12 -0
  432. agent_toolkit/templates/workspace/personas/researcher.md +12 -0
  433. agent_toolkit/templates/workspace/personas/reviewer.md +12 -0
  434. agent_toolkit_cli-1.11.0.dist-info/METADATA +363 -0
  435. agent_toolkit_cli-1.11.0.dist-info/RECORD +438 -0
  436. agent_toolkit_cli-1.11.0.dist-info/WHEEL +4 -0
  437. agent_toolkit_cli-1.11.0.dist-info/entry_points.txt +4 -0
  438. agent_toolkit_cli-1.11.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,739 @@
1
+ """
2
+ memory — Persistent knowledge base management.
3
+
4
+ Usage:
5
+ agent-toolkit memory <subcommand> [args]
6
+
7
+ Subcommands:
8
+ add --type <type> [--title TITLE] [--workspace PATH] "content"
9
+ Add a learning, process, or todo entry
10
+ search "query" Case-insensitive search across all knowledge files
11
+ inject Output full knowledge base for AI session injection
12
+ review [--fix] [--stale-after N]
13
+ Detect duplicates, stale/orphan refs, and contradictions
14
+ todo List unchecked todos
15
+
16
+ Types for add:
17
+ learning Factual session learning (knowledge/learnings/general.md)
18
+ process How-to procedure (knowledge/processes/<topic>.md)
19
+ todo Follow-up item (knowledge/todos/pending.md)
20
+
21
+ Options:
22
+ --workspace PATH Override workspace root
23
+ --help Show this help message
24
+ """
25
+
26
+ from __future__ import annotations
27
+
28
+ import os
29
+ import re
30
+ import sys
31
+ import sys as _sys
32
+ from dataclasses import dataclass
33
+ from datetime import date, datetime, timedelta, timezone
34
+ from difflib import SequenceMatcher
35
+ from pathlib import Path
36
+
37
+ if _sys.platform == "win32":
38
+ try:
39
+ _sys.stdout.reconfigure(encoding="utf-8", errors="replace")
40
+ _sys.stderr.reconfigure(encoding="utf-8", errors="replace")
41
+ except Exception:
42
+ pass
43
+
44
+
45
+ # ---------------------------------------------------------------------------
46
+ # Color helpers
47
+ # ---------------------------------------------------------------------------
48
+
49
+ _USE_COLOR = sys.stdout.isatty() and not os.environ.get("NO_COLOR")
50
+
51
+
52
+ def _c(code: str, text: str) -> str:
53
+ return f"\033[{code}m{text}\033[0m" if _USE_COLOR else text
54
+
55
+
56
+ def _blue(t: str) -> str:
57
+ return _c("1;34", t)
58
+
59
+
60
+ def _green(t: str) -> str:
61
+ return _c("1;32", t)
62
+
63
+
64
+ def _yellow(t: str) -> str:
65
+ return _c("1;33", t)
66
+
67
+
68
+ def _cyan(t: str) -> str:
69
+ return _c("0;36", t)
70
+
71
+
72
+ def _dim(t: str) -> str:
73
+ return _c("0;37", t)
74
+
75
+
76
+ # ---------------------------------------------------------------------------
77
+ # Workspace root detection
78
+ # ---------------------------------------------------------------------------
79
+
80
+
81
+ def _find_workspace(override: str | None = None) -> Path | None:
82
+ """Locate workspace root via env, override, or walking up from CWD."""
83
+ from agent_toolkit._paths import find_workspace_root
84
+
85
+ return find_workspace_root(override=override)
86
+
87
+
88
+ # ---------------------------------------------------------------------------
89
+ # File helpers
90
+ # ---------------------------------------------------------------------------
91
+
92
+
93
+ def _read(path: Path) -> str:
94
+ return path.read_text(encoding="utf-8") if path.exists() else ""
95
+
96
+
97
+ def _write(path: Path, content: str) -> None:
98
+ path.parent.mkdir(parents=True, exist_ok=True)
99
+ path.write_text(content, encoding="utf-8")
100
+
101
+
102
+ def _prepend_after_marker(path: Path, marker: str, entry: str) -> None:
103
+ """Insert entry immediately after the first occurrence of marker."""
104
+ content = _read(path)
105
+ if marker not in content:
106
+ _write(path, content + "\n" + entry)
107
+ return
108
+ idx = content.index(marker) + len(marker)
109
+ _write(path, content[:idx] + "\n" + entry + content[idx:])
110
+
111
+
112
+ def _prepend_table_row(path: Path, header_row: str, new_row: str) -> None:
113
+ """Insert new_row right after the header+separator of a markdown table."""
114
+ content = _read(path)
115
+ if header_row not in content:
116
+ _write(path, content + "\n" + new_row + "\n")
117
+ return
118
+ idx = content.index(header_row) + len(header_row)
119
+ rest = content[idx:]
120
+ sep_match = re.match(r"\n\|[-| :]+\|", rest)
121
+ if sep_match:
122
+ idx += sep_match.end()
123
+ _write(path, content[:idx] + "\n" + new_row + content[idx:])
124
+
125
+
126
+ # ---------------------------------------------------------------------------
127
+ # Subcommands
128
+ # ---------------------------------------------------------------------------
129
+
130
+
131
+ def cmd_add(args: list[str], knowledge: Path) -> int:
132
+ """Add a new entry to the knowledge base."""
133
+ type_ = ""
134
+ title = ""
135
+ content = ""
136
+ i = 0
137
+ while i < len(args):
138
+ match args[i]:
139
+ case "--type" if i + 1 < len(args):
140
+ type_ = args[i + 1]
141
+ i += 2
142
+ case "--title" if i + 1 < len(args):
143
+ title = args[i + 1]
144
+ i += 2
145
+ case "--help" | "-h":
146
+ print('Usage: agent-toolkit memory add --type <type> [--title TITLE] "content"')
147
+ print("Types: learning, process, todo")
148
+ return 0
149
+ case _:
150
+ content = args[i]
151
+ i += 1
152
+
153
+ if not type_ or not content:
154
+ print('Usage: agent-toolkit memory add --type <type> "content"', file=sys.stderr)
155
+ print("Types: learning, process, todo", file=sys.stderr)
156
+ return 1
157
+
158
+ today = date.today().isoformat()
159
+
160
+ match type_:
161
+ case "learning":
162
+ path = knowledge / "learnings" / "general.md"
163
+ if not path.exists():
164
+ _write(
165
+ path,
166
+ "# General Learnings\n\n| Date | Learning | Context |\n|------|----------|---------|",
167
+ )
168
+ row = f"| {today} | {content} | Session |"
169
+ _prepend_table_row(path, "| Date | Learning | Context |", row)
170
+ print(_green(f"Added learning to {path.relative_to(knowledge.parent)}"))
171
+
172
+ case "process":
173
+ topic = re.sub(r"[^a-z0-9-]", "-", (title or "general").lower()).strip("-") or "general"
174
+ path = knowledge / "processes" / f"{topic}.md"
175
+ if not path.exists():
176
+ _write(path, f"# Process: {title or topic}\n\n<!-- How-to procedures -->\n")
177
+ entry = f"\n## {today}\n\n{content}\n"
178
+ _write(path, _read(path) + entry)
179
+ print(_green(f"Added process to {path.relative_to(knowledge.parent)}"))
180
+
181
+ case "todo":
182
+ path = knowledge / "todos" / "pending.md"
183
+ if not path.exists():
184
+ _write(path, "# Pending Todos\n\n<!-- Add pending items with date added -->\n")
185
+ marker = "<!-- Add pending items with date added -->"
186
+ entry = f"- [ ] {today} - {content}\n"
187
+ _prepend_after_marker(path, marker, entry)
188
+ print(_green(f"Added todo to {path.relative_to(knowledge.parent)}"))
189
+
190
+ case _:
191
+ print(f"Unknown type: {type_}", file=sys.stderr)
192
+ print("Valid types: learning, process, todo", file=sys.stderr)
193
+ return 1
194
+
195
+ return 0
196
+
197
+
198
+ def cmd_search(args: list[str], knowledge: Path) -> int:
199
+ """Case-insensitive search across all knowledge files."""
200
+ query_parts: list[str] = []
201
+ i = 0
202
+ while i < len(args):
203
+ match args[i]:
204
+ case "--help" | "-h":
205
+ print('Usage: agent-toolkit memory search "query"')
206
+ return 0
207
+ case _:
208
+ query_parts.append(args[i])
209
+ i += 1
210
+
211
+ query = " ".join(query_parts)
212
+ if not query:
213
+ print('Usage: agent-toolkit memory search "query"', file=sys.stderr)
214
+ return 1
215
+
216
+ query_lower = query.lower()
217
+ print(f"\n{_blue(f'=== Searching: {query} ===')}\n")
218
+ found_any = False
219
+
220
+ if not knowledge.is_dir():
221
+ print(_dim(" (knowledge/ directory not found)"))
222
+ print()
223
+ return 0
224
+
225
+ for md_file in sorted(knowledge.rglob("*.md")):
226
+ content = _read(md_file)
227
+ lines = content.splitlines()
228
+ matched: list[tuple[int, str]] = [
229
+ (i + 1, line) for i, line in enumerate(lines) if query_lower in line.lower()
230
+ ]
231
+ if not matched:
232
+ continue
233
+
234
+ found_any = True
235
+ try:
236
+ rel = md_file.relative_to(knowledge.parent)
237
+ except ValueError:
238
+ rel = md_file
239
+
240
+ print(f" {_cyan(str(rel))}:")
241
+ for lineno, line in matched[:5]:
242
+ # Show 1 line of context before and after if possible
243
+ ctx_start = max(0, lineno - 2)
244
+ ctx_end = min(len(lines), lineno + 1)
245
+ for ci in range(ctx_start, ctx_end):
246
+ _dim(f" {ci + 1}:") + " "
247
+ text = lines[ci].strip()
248
+ if ci == lineno - 1:
249
+ # Highlight the matching line
250
+ print(f" {_yellow(f'{ci + 1}:')} {text}")
251
+ else:
252
+ print(f" {_dim(f'{ci + 1}:')} {_dim(text)}")
253
+ if len(matched) > 5:
254
+ print(_dim(f" ... and {len(matched) - 5} more matches"))
255
+ print()
256
+
257
+ if not found_any:
258
+ print(_dim(" (no results found)"))
259
+ print()
260
+ return 0
261
+
262
+
263
+ def cmd_inject(args: list[str], knowledge: Path) -> int:
264
+ """Output full knowledge base as a formatted block for AI session injection."""
265
+ for arg in args:
266
+ if arg in ("--help", "-h"):
267
+ print("Usage: agent-toolkit memory inject [--workspace PATH]")
268
+ return 0
269
+
270
+ print("<!-- agent-toolkit memory inject -->\n")
271
+ print("## Knowledge Base Summary\n")
272
+
273
+ has_output = False
274
+
275
+ # Todos
276
+ todos_path = knowledge / "todos" / "pending.md"
277
+ if todos_path.exists():
278
+ content = todos_path.read_text(encoding="utf-8")
279
+ unchecked = [line for line in content.splitlines() if line.startswith("- [ ]")]
280
+ if unchecked:
281
+ print("### Pending Todos\n")
282
+ for item in unchecked[:15]:
283
+ print(item)
284
+ print()
285
+ has_output = True
286
+
287
+ # Recent learnings
288
+ learnings_path = knowledge / "learnings" / "general.md"
289
+ if learnings_path.exists():
290
+ content = learnings_path.read_text(encoding="utf-8")
291
+ rows = [line for line in content.splitlines() if re.match(r"^\| \d{4}", line)]
292
+ if rows:
293
+ print("### Recent Learnings\n")
294
+ print("| Date | Learning | Context |")
295
+ print("|------|----------|---------|")
296
+ for row in rows[:10]:
297
+ print(row)
298
+ print()
299
+ has_output = True
300
+
301
+ # Processes index
302
+ procs_dir = knowledge / "processes"
303
+ if procs_dir.is_dir():
304
+ proc_files = sorted(
305
+ p.stem for p in procs_dir.iterdir() if p.is_file() and p.suffix == ".md"
306
+ )
307
+ if proc_files:
308
+ print("### Known Processes\n")
309
+ for name in proc_files:
310
+ print(f"- `knowledge/processes/{name}.md`")
311
+ print()
312
+ has_output = True
313
+
314
+ if not has_output:
315
+ print(_dim("(knowledge base is empty)"))
316
+
317
+ print("<!-- end agent-toolkit memory inject -->")
318
+ return 0
319
+
320
+
321
+ @dataclass(frozen=True)
322
+ class KnowledgeEntry:
323
+ """A reviewable knowledge snippet with location metadata."""
324
+
325
+ path: Path
326
+ line_no: int
327
+ text: str
328
+ dated: date | None = None
329
+
330
+
331
+ _PATH_REF_RE = re.compile(
332
+ r"(?<![\w])("
333
+ r"(?:~/|\.{1,2}/|/)?"
334
+ r"(?:[A-Za-z0-9_.-]+/)+[A-Za-z0-9_.-]+\.[A-Za-z0-9]+"
335
+ r")"
336
+ )
337
+ _CONTRACTION_PAIR_RE = re.compile(
338
+ r"\b(?:do\s+not|don't|dont|never|avoid)\s+(?:use|call|run|install)\s+([A-Za-z0-9_./-]+)",
339
+ re.I,
340
+ )
341
+ _USE_RE = re.compile(
342
+ r"\b(?:use|prefer|always\s+use|should\s+use)\s+([A-Za-z0-9_./-]+)",
343
+ re.I,
344
+ )
345
+
346
+
347
+ def _similarity(a: str, b: str) -> float:
348
+ """Return normalized similarity in [0, 1] (SequenceMatcher ≈ Levenshtein ratio)."""
349
+ a_n = re.sub(r"\s+", " ", a.strip().lower())
350
+ b_n = re.sub(r"\s+", " ", b.strip().lower())
351
+ if not a_n or not b_n:
352
+ return 0.0
353
+ return SequenceMatcher(None, a_n, b_n).ratio()
354
+
355
+
356
+ def _parse_entry_date(text: str) -> date | None:
357
+ m = re.search(r"\b(\d{4}-\d{2}-\d{2})\b", text)
358
+ if not m:
359
+ return None
360
+ try:
361
+ return date.fromisoformat(m.group(1))
362
+ except ValueError:
363
+ return None
364
+
365
+
366
+ def _collect_entries(knowledge: Path) -> list[KnowledgeEntry]:
367
+ """Extract reviewable lines/sections from knowledge markdown files."""
368
+ entries: list[KnowledgeEntry] = []
369
+ if not knowledge.is_dir():
370
+ return entries
371
+
372
+ for md_file in sorted(knowledge.rglob("*.md")):
373
+ lines = _read(md_file).splitlines()
374
+ for i, line in enumerate(lines, start=1):
375
+ stripped = line.strip()
376
+ if not stripped or stripped.startswith("#") or stripped.startswith("<!--"):
377
+ continue
378
+ # Table separator / header
379
+ if re.match(r"^\|[-:| ]+\|$", stripped):
380
+ continue
381
+ if stripped.startswith("| Date |") or stripped.startswith("|------"):
382
+ continue
383
+ # Prefer meaningful content rows / bullets / process body lines
384
+ if stripped.startswith("|") or stripped.startswith("- ") or len(stripped) >= 24:
385
+ text = stripped
386
+ if stripped.startswith("|"):
387
+ cells = [c.strip() for c in stripped.strip("|").split("|")]
388
+ text = " — ".join(c for c in cells if c)
389
+ entries.append(
390
+ KnowledgeEntry(
391
+ path=md_file,
392
+ line_no=i,
393
+ text=text,
394
+ dated=_parse_entry_date(stripped),
395
+ )
396
+ )
397
+ return entries
398
+
399
+
400
+ def _extract_path_refs(text: str) -> list[str]:
401
+ refs: list[str] = []
402
+ for m in _PATH_REF_RE.finditer(text):
403
+ refs.append(m.group(1))
404
+ for m in re.finditer(r"`([^`]+)`", text):
405
+ raw = m.group(1).strip()
406
+ if "://" in raw or raw.startswith("http"):
407
+ continue
408
+ if "/" in raw or raw.startswith((".", "~")):
409
+ refs.append(raw)
410
+ # Deduplicate preserving order
411
+ seen: set[str] = set()
412
+ out: list[str] = []
413
+ for ref in refs:
414
+ if ref not in seen:
415
+ seen.add(ref)
416
+ out.append(ref)
417
+ return out
418
+
419
+
420
+ def _resolve_ref(ref: str, workspace: Path) -> Path:
421
+ if ref.startswith("~/"):
422
+ return Path.home() / ref[2:]
423
+ p = Path(ref)
424
+ if p.is_absolute():
425
+ return p
426
+ return (workspace / ref).resolve()
427
+
428
+
429
+ def _find_duplicates(
430
+ entries: list[KnowledgeEntry], *, threshold: float = 0.8
431
+ ) -> list[tuple[KnowledgeEntry, KnowledgeEntry, float]]:
432
+ dupes: list[tuple[KnowledgeEntry, KnowledgeEntry, float]] = []
433
+ for i, left in enumerate(entries):
434
+ for right in entries[i + 1 :]:
435
+ if left.path == right.path and left.line_no == right.line_no:
436
+ continue
437
+ ratio = _similarity(left.text, right.text)
438
+ if ratio >= threshold:
439
+ dupes.append((left, right, ratio))
440
+ return dupes
441
+
442
+
443
+ def _find_contradictions(
444
+ entries: list[KnowledgeEntry],
445
+ ) -> list[tuple[KnowledgeEntry, KnowledgeEntry, str]]:
446
+ """Detect 'use X' vs 'don't use X' pairs across the knowledge base."""
447
+ use_map: dict[str, list[KnowledgeEntry]] = {}
448
+ avoid_map: dict[str, list[KnowledgeEntry]] = {}
449
+ for entry in entries:
450
+ for m in _USE_RE.finditer(entry.text):
451
+ # Skip if the match is actually a negation captured loosely
452
+ start = max(0, m.start() - 12)
453
+ window = entry.text[start : m.start()].lower()
454
+ if any(neg in window for neg in ("don't", "dont", "do not", "never", "avoid")):
455
+ continue
456
+ use_map.setdefault(m.group(1).lower(), []).append(entry)
457
+ for m in _CONTRACTION_PAIR_RE.finditer(entry.text):
458
+ avoid_map.setdefault(m.group(1).lower(), []).append(entry)
459
+
460
+ hits: list[tuple[KnowledgeEntry, KnowledgeEntry, str]] = []
461
+ for key, avoiders in avoid_map.items():
462
+ for user in use_map.get(key, []):
463
+ for avoider in avoiders:
464
+ if user is avoider:
465
+ continue
466
+ hits.append((user, avoider, key))
467
+ return hits
468
+
469
+
470
+ def _find_stale_and_orphans(
471
+ entries: list[KnowledgeEntry],
472
+ knowledge: Path,
473
+ *,
474
+ stale_after: int,
475
+ ) -> tuple[list[tuple[KnowledgeEntry, str]], list[tuple[KnowledgeEntry, str]]]:
476
+ """Return (stale, orphaned) findings.
477
+
478
+ Stale: entry older than threshold AND a referenced path/tool is missing.
479
+ Orphaned: any referenced path that no longer exists (regardless of age).
480
+ """
481
+ workspace = knowledge.parent
482
+ cutoff = date.today() - timedelta(days=stale_after)
483
+ stale: list[tuple[KnowledgeEntry, str]] = []
484
+ orphans: list[tuple[KnowledgeEntry, str]] = []
485
+
486
+ for entry in entries:
487
+ refs = _extract_path_refs(entry.text)
488
+ missing: list[str] = []
489
+ for ref in refs:
490
+ target = _resolve_ref(ref, workspace)
491
+ if not target.exists():
492
+ missing.append(ref)
493
+
494
+ mtime_date: date | None = entry.dated
495
+ if mtime_date is None:
496
+ try:
497
+ mtime_date = datetime.fromtimestamp(
498
+ entry.path.stat().st_mtime, tz=timezone.utc
499
+ ).date()
500
+ except OSError:
501
+ mtime_date = None
502
+
503
+ for ref in missing:
504
+ orphans.append((entry, f"missing path `{ref}`"))
505
+
506
+ if missing and mtime_date is not None and mtime_date < cutoff:
507
+ stale.append(
508
+ (
509
+ entry,
510
+ f"last seen {mtime_date.isoformat()} (>{stale_after}d) and refs missing: "
511
+ + ", ".join(f"`{r}`" for r in missing),
512
+ )
513
+ )
514
+
515
+ return stale, orphans
516
+
517
+
518
+ def cmd_review(args: list[str], knowledge: Path) -> int:
519
+ """Detect duplicates, stale/orphan refs, and contradictions (#226).
520
+
521
+ Exit codes: 0 if clean, 1 if any issues found.
522
+ """
523
+ stale_after = 90
524
+ fix = False
525
+ i = 0
526
+ while i < len(args):
527
+ match args[i]:
528
+ case "--stale-after" | "--stale-days" if i + 1 < len(args):
529
+ try:
530
+ stale_after = int(args[i + 1])
531
+ except ValueError:
532
+ print(f"Invalid --stale-after value: {args[i + 1]}", file=sys.stderr)
533
+ return 1
534
+ i += 2
535
+ case "--fix":
536
+ fix = True
537
+ i += 1
538
+ case "--help" | "-h":
539
+ print(
540
+ "Usage: agent-toolkit memory review [--fix] [--stale-after N]\n"
541
+ "\n"
542
+ "Detects duplicates (similarity ≥ 80%), stale entries, contradictions,\n"
543
+ "and orphaned path references. Exit 1 when issues are found.\n"
544
+ "\n"
545
+ " --stale-after N Age threshold in days (default: 90)\n"
546
+ " --fix Print merge/fix suggestions (does not mutate files)\n"
547
+ )
548
+ return 0
549
+ case _:
550
+ print(f"Unknown review option: {args[i]}", file=sys.stderr)
551
+ return 1
552
+
553
+ entries = _collect_entries(knowledge)
554
+ duplicates = _find_duplicates(entries)
555
+ contradictions = _find_contradictions(entries)
556
+ stale, orphans = _find_stale_and_orphans(entries, knowledge, stale_after=stale_after)
557
+
558
+ print(f"\n{_blue('=== Memory Review ===')}\n")
559
+ print(_dim(f"Scanned {len(entries)} entries under {knowledge} (stale-after={stale_after}d)"))
560
+ print()
561
+
562
+ issue_count = 0
563
+
564
+ print(f"{_cyan('Duplicates')} (similarity ≥ 80%):")
565
+ if duplicates:
566
+ for left, right, ratio in duplicates[:20]:
567
+ issue_count += 1
568
+ rel_l = left.path.name
569
+ rel_r = right.path.name
570
+ print(f" • {ratio:.0%} {rel_l}:{left.line_no} ↔ {rel_r}:{right.line_no}")
571
+ print(_dim(f" A: {left.text[:100]}"))
572
+ print(_dim(f" B: {right.text[:100]}"))
573
+ if fix:
574
+ print(
575
+ _yellow(
576
+ f" suggestion: merge into one entry and delete the weaker duplicate "
577
+ f"({rel_r}:{right.line_no})"
578
+ )
579
+ )
580
+ else:
581
+ print(_dim(" (none)"))
582
+ print()
583
+
584
+ print(f"{_cyan('Contradictions')} (use X vs don't use X):")
585
+ if contradictions:
586
+ seen: set[tuple[int, int, str]] = set()
587
+ for user, avoider, key in contradictions:
588
+ sig = (user.line_no, avoider.line_no, key)
589
+ if sig in seen:
590
+ continue
591
+ seen.add(sig)
592
+ issue_count += 1
593
+ print(f" • subject `{key}`")
594
+ print(_dim(f" use: {user.path.name}:{user.line_no} — {user.text[:100]}"))
595
+ print(
596
+ _dim(f" avoid: {avoider.path.name}:{avoider.line_no} — {avoider.text[:100]}")
597
+ )
598
+ if fix:
599
+ print(
600
+ _yellow(
601
+ " suggestion: reconcile guidance; keep a single current recommendation"
602
+ )
603
+ )
604
+ else:
605
+ print(_dim(" (none)"))
606
+ print()
607
+
608
+ print(f"{_cyan('Stale')} (older than {stale_after}d AND missing refs):")
609
+ if stale:
610
+ for entry, detail in stale[:20]:
611
+ issue_count += 1
612
+ print(f" • {entry.path.name}:{entry.line_no} — {detail}")
613
+ print(_dim(f" {entry.text[:100]}"))
614
+ if fix:
615
+ print(_yellow(" suggestion: update the entry or remove obsolete guidance"))
616
+ else:
617
+ print(_dim(" (none)"))
618
+ print()
619
+
620
+ print(f"{_cyan('Orphaned references')} (path no longer exists):")
621
+ if orphans:
622
+ # Deduplicate by path+ref for display
623
+ seen_o: set[tuple[str, int, str]] = set()
624
+ for entry, detail in orphans[:30]:
625
+ sig = (str(entry.path), entry.line_no, detail)
626
+ if sig in seen_o:
627
+ continue
628
+ seen_o.add(sig)
629
+ issue_count += 1
630
+ print(f" • {entry.path.name}:{entry.line_no} — {detail}")
631
+ if fix:
632
+ print(_yellow(" suggestion: fix the path or delete the orphaned note"))
633
+ else:
634
+ print(_dim(" (none)"))
635
+ print()
636
+
637
+ if issue_count == 0:
638
+ print(_green("Knowledge base looks clean — no issues found."))
639
+ return 0
640
+
641
+ print(_yellow(f"Found {issue_count} issue(s)."))
642
+ if not fix:
643
+ print(_dim("Re-run with --fix for merge/update suggestions."))
644
+ return 1
645
+
646
+
647
+ def cmd_todo(args: list[str], knowledge: Path) -> int:
648
+ """List unchecked todos from pending.md."""
649
+ show_done = False
650
+ for arg in args:
651
+ match arg:
652
+ case "--done":
653
+ show_done = True
654
+ case "--help" | "-h":
655
+ print("Usage: agent-toolkit memory todo [--done]")
656
+ return 0
657
+
658
+ path = knowledge / "todos" / "pending.md"
659
+ if not path.exists():
660
+ print(_dim("(no todos file found)"))
661
+ return 0
662
+
663
+ content = path.read_text(encoding="utf-8")
664
+ lines = content.splitlines()
665
+
666
+ unchecked = [line for line in lines if line.startswith("- [ ]")]
667
+ done = [line for line in lines if line.startswith("- [x]") or line.startswith("- [X]")]
668
+
669
+ if not unchecked and not done:
670
+ print(_dim("(no todos found)"))
671
+ return 0
672
+
673
+ if unchecked:
674
+ print(f"\n{_cyan('Pending Todos:')}\n")
675
+ for item in unchecked:
676
+ print(f" {item}")
677
+ print()
678
+
679
+ if show_done and done:
680
+ print(f"\n{_dim('Completed Todos:')}\n")
681
+ for item in done:
682
+ print(f" {_dim(item)}")
683
+ print()
684
+ elif not unchecked:
685
+ print(_dim("(no pending todos)"))
686
+
687
+ return 0
688
+
689
+
690
+ # ---------------------------------------------------------------------------
691
+ # Entry point
692
+ # ---------------------------------------------------------------------------
693
+
694
+
695
+ def cmd_memory(args: list[str]) -> int:
696
+ """Router for memory subcommands."""
697
+ # Extract --workspace before routing
698
+ workspace_path: str | None = None
699
+ filtered_args: list[str] = []
700
+ i = 0
701
+ while i < len(args):
702
+ if args[i] == "--workspace" and i + 1 < len(args):
703
+ workspace_path = args[i + 1]
704
+ i += 2
705
+ else:
706
+ filtered_args.append(args[i])
707
+ i += 1
708
+
709
+ if not filtered_args or filtered_args[0] in ("-h", "--help", "help"):
710
+ print(__doc__)
711
+ return 0
712
+
713
+ ws = _find_workspace(workspace_path)
714
+ if ws is None:
715
+ print("Error: workspace not found.", file=sys.stderr)
716
+ print(
717
+ "Set AGENT_TOOLKIT_WORKSPACE or run from inside a workspace directory.", file=sys.stderr
718
+ )
719
+ return 1
720
+
721
+ knowledge = ws / "knowledge"
722
+ sub = filtered_args[0]
723
+ rest = filtered_args[1:]
724
+
725
+ match sub:
726
+ case "add":
727
+ return cmd_add(rest, knowledge)
728
+ case "search":
729
+ return cmd_search(rest, knowledge)
730
+ case "inject":
731
+ return cmd_inject(rest, knowledge)
732
+ case "review":
733
+ return cmd_review(rest, knowledge)
734
+ case "todo":
735
+ return cmd_todo(rest, knowledge)
736
+ case _:
737
+ print(f"Unknown memory subcommand: {sub}", file=sys.stderr)
738
+ print("Run 'agent-toolkit memory --help' for usage.", file=sys.stderr)
739
+ return 1