agentsys 5.0.3 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (264) hide show
  1. package/.claude-plugin/marketplace.json +21 -14
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/AGENTS.md +2 -1
  4. package/CHANGELOG.md +18 -0
  5. package/README.md +7 -6
  6. package/adapters/codex/skills/agnix/SKILL.md +0 -1
  7. package/adapters/codex/skills/audit-project/SKILL.md +0 -1
  8. package/adapters/codex/skills/audit-project-agents/SKILL.md +0 -1
  9. package/adapters/codex/skills/audit-project-github/SKILL.md +0 -1
  10. package/adapters/codex/skills/consult/SKILL.md +132 -57
  11. package/adapters/codex/skills/debate/SKILL.md +214 -0
  12. package/adapters/codex/skills/delivery-approval/SKILL.md +0 -1
  13. package/adapters/codex/skills/deslop/SKILL.md +0 -1
  14. package/adapters/codex/skills/drift-detect/SKILL.md +0 -1
  15. package/adapters/codex/skills/enhance/SKILL.md +0 -1
  16. package/adapters/codex/skills/learn/SKILL.md +0 -1
  17. package/adapters/codex/skills/next-task/SKILL.md +0 -1
  18. package/adapters/codex/skills/perf/SKILL.md +0 -1
  19. package/adapters/codex/skills/repo-map/SKILL.md +0 -1
  20. package/adapters/codex/skills/ship/SKILL.md +0 -1
  21. package/adapters/codex/skills/ship-ci-review-loop/SKILL.md +0 -1
  22. package/adapters/codex/skills/ship-deployment/SKILL.md +0 -1
  23. package/adapters/codex/skills/ship-error-handling/SKILL.md +0 -1
  24. package/adapters/codex/skills/sync-docs/SKILL.md +0 -1
  25. package/adapters/opencode/agents/agent-enhancer.md +0 -1
  26. package/adapters/opencode/agents/agnix-agent.md +0 -1
  27. package/adapters/opencode/agents/ci-fixer.md +0 -1
  28. package/adapters/opencode/agents/ci-monitor.md +0 -1
  29. package/adapters/opencode/agents/claudemd-enhancer.md +0 -1
  30. package/adapters/opencode/agents/consult-agent.md +122 -30
  31. package/adapters/opencode/agents/cross-file-enhancer.md +0 -1
  32. package/adapters/opencode/agents/debate-orchestrator.md +169 -0
  33. package/adapters/opencode/agents/delivery-validator.md +0 -1
  34. package/adapters/opencode/agents/deslop-agent.md +0 -1
  35. package/adapters/opencode/agents/docs-enhancer.md +0 -1
  36. package/adapters/opencode/agents/exploration-agent.md +0 -1
  37. package/adapters/opencode/agents/hooks-enhancer.md +0 -1
  38. package/adapters/opencode/agents/implementation-agent.md +0 -1
  39. package/adapters/opencode/agents/learn-agent.md +0 -1
  40. package/adapters/opencode/agents/map-validator.md +0 -1
  41. package/adapters/opencode/agents/perf-analyzer.md +0 -1
  42. package/adapters/opencode/agents/perf-code-paths.md +0 -1
  43. package/adapters/opencode/agents/perf-investigation-logger.md +0 -1
  44. package/adapters/opencode/agents/perf-orchestrator.md +0 -1
  45. package/adapters/opencode/agents/perf-theory-gatherer.md +0 -1
  46. package/adapters/opencode/agents/perf-theory-tester.md +0 -1
  47. package/adapters/opencode/agents/plan-synthesizer.md +0 -1
  48. package/adapters/opencode/agents/planning-agent.md +0 -1
  49. package/adapters/opencode/agents/plugin-enhancer.md +0 -1
  50. package/adapters/opencode/agents/prompt-enhancer.md +0 -1
  51. package/adapters/opencode/agents/simple-fixer.md +0 -1
  52. package/adapters/opencode/agents/skills-enhancer.md +0 -1
  53. package/adapters/opencode/agents/sync-docs-agent.md +0 -1
  54. package/adapters/opencode/agents/task-discoverer.md +0 -1
  55. package/adapters/opencode/agents/test-coverage-checker.md +0 -1
  56. package/adapters/opencode/agents/worktree-manager.md +0 -1
  57. package/adapters/opencode/commands/agnix.md +0 -1
  58. package/adapters/opencode/commands/audit-project-agents.md +0 -1
  59. package/adapters/opencode/commands/audit-project-github.md +0 -1
  60. package/adapters/opencode/commands/audit-project.md +0 -1
  61. package/adapters/opencode/commands/consult.md +133 -57
  62. package/adapters/opencode/commands/debate.md +224 -0
  63. package/adapters/opencode/commands/delivery-approval.md +0 -1
  64. package/adapters/opencode/commands/deslop.md +0 -1
  65. package/adapters/opencode/commands/drift-detect.md +0 -1
  66. package/adapters/opencode/commands/enhance.md +0 -1
  67. package/adapters/opencode/commands/learn.md +0 -1
  68. package/adapters/opencode/commands/next-task.md +0 -1
  69. package/adapters/opencode/commands/perf.md +0 -1
  70. package/adapters/opencode/commands/repo-map.md +0 -1
  71. package/adapters/opencode/commands/ship-ci-review-loop.md +0 -1
  72. package/adapters/opencode/commands/ship-deployment.md +0 -1
  73. package/adapters/opencode/commands/ship-error-handling.md +0 -1
  74. package/adapters/opencode/commands/ship.md +0 -1
  75. package/adapters/opencode/commands/sync-docs.md +0 -1
  76. package/adapters/opencode/skills/agnix/SKILL.md +1 -2
  77. package/adapters/opencode/skills/consult/SKILL.md +33 -23
  78. package/adapters/opencode/skills/debate/SKILL.md +245 -0
  79. package/adapters/opencode/skills/deslop/SKILL.md +1 -2
  80. package/adapters/opencode/skills/discover-tasks/SKILL.md +1 -2
  81. package/adapters/opencode/skills/drift-analysis/SKILL.md +1 -2
  82. package/adapters/opencode/skills/enhance-agent-prompts/SKILL.md +1 -2
  83. package/adapters/opencode/skills/enhance-claude-memory/SKILL.md +1 -2
  84. package/adapters/opencode/skills/enhance-cross-file/SKILL.md +1 -2
  85. package/adapters/opencode/skills/enhance-docs/SKILL.md +1 -2
  86. package/adapters/opencode/skills/enhance-hooks/SKILL.md +1 -2
  87. package/adapters/opencode/skills/enhance-orchestrator/SKILL.md +1 -2
  88. package/adapters/opencode/skills/enhance-plugins/SKILL.md +1 -2
  89. package/adapters/opencode/skills/enhance-prompts/SKILL.md +1 -2
  90. package/adapters/opencode/skills/enhance-skills/SKILL.md +1 -2
  91. package/adapters/opencode/skills/learn/SKILL.md +1 -2
  92. package/adapters/opencode/skills/orchestrate-review/SKILL.md +0 -1
  93. package/adapters/opencode/skills/perf-analyzer/SKILL.md +1 -2
  94. package/adapters/opencode/skills/perf-baseline-manager/SKILL.md +1 -2
  95. package/adapters/opencode/skills/perf-benchmarker/SKILL.md +1 -2
  96. package/adapters/opencode/skills/perf-code-paths/SKILL.md +1 -2
  97. package/adapters/opencode/skills/perf-investigation-logger/SKILL.md +1 -2
  98. package/adapters/opencode/skills/perf-profiler/SKILL.md +1 -2
  99. package/adapters/opencode/skills/perf-theory-gatherer/SKILL.md +1 -2
  100. package/adapters/opencode/skills/perf-theory-tester/SKILL.md +1 -2
  101. package/adapters/opencode/skills/repo-mapping/SKILL.md +1 -2
  102. package/adapters/opencode/skills/sync-docs/SKILL.md +1 -2
  103. package/adapters/opencode/skills/validate-delivery/SKILL.md +1 -2
  104. package/lib/adapter-transforms.js +24 -4
  105. package/package.json +1 -1
  106. package/plugins/agnix/.claude-plugin/plugin.json +1 -1
  107. package/plugins/agnix/skills/agnix/SKILL.md +1 -1
  108. package/plugins/audit-project/.claude-plugin/plugin.json +1 -1
  109. package/plugins/audit-project/lib/adapter-transforms.js +24 -4
  110. package/plugins/consult/.claude-plugin/plugin.json +1 -1
  111. package/plugins/consult/agents/consult-agent.md +122 -29
  112. package/plugins/consult/commands/consult.md +135 -58
  113. package/plugins/consult/skills/consult/SKILL.md +31 -20
  114. package/plugins/debate/.claude-plugin/plugin.json +21 -0
  115. package/plugins/debate/agents/debate-orchestrator.md +175 -0
  116. package/plugins/debate/commands/debate.md +221 -0
  117. package/plugins/debate/lib/adapter-transforms.js +298 -0
  118. package/plugins/debate/lib/collectors/codebase.js +392 -0
  119. package/plugins/debate/lib/collectors/docs-patterns.js +713 -0
  120. package/plugins/debate/lib/collectors/documentation.js +219 -0
  121. package/plugins/debate/lib/collectors/github.js +330 -0
  122. package/plugins/debate/lib/collectors/index.js +126 -0
  123. package/plugins/debate/lib/config/index.js +14 -0
  124. package/plugins/debate/lib/cross-platform/index.js +539 -0
  125. package/plugins/debate/lib/discovery/index.js +352 -0
  126. package/plugins/debate/lib/drift-detect/collectors.js +37 -0
  127. package/plugins/debate/lib/enhance/agent-analyzer.js +421 -0
  128. package/plugins/debate/lib/enhance/agent-patterns.js +571 -0
  129. package/plugins/debate/lib/enhance/auto-suppression.js +622 -0
  130. package/plugins/debate/lib/enhance/benchmark.js +417 -0
  131. package/plugins/debate/lib/enhance/cross-file-analyzer.js +930 -0
  132. package/plugins/debate/lib/enhance/cross-file-patterns.js +370 -0
  133. package/plugins/debate/lib/enhance/docs-analyzer.js +325 -0
  134. package/plugins/debate/lib/enhance/docs-patterns.js +671 -0
  135. package/plugins/debate/lib/enhance/fixer.js +721 -0
  136. package/plugins/debate/lib/enhance/hook-analyzer.js +135 -0
  137. package/plugins/debate/lib/enhance/hook-patterns.js +40 -0
  138. package/plugins/debate/lib/enhance/index.js +127 -0
  139. package/plugins/debate/lib/enhance/plugin-analyzer.js +402 -0
  140. package/plugins/debate/lib/enhance/plugin-patterns.js +326 -0
  141. package/plugins/debate/lib/enhance/projectmemory-analyzer.js +551 -0
  142. package/plugins/debate/lib/enhance/projectmemory-patterns.js +617 -0
  143. package/plugins/debate/lib/enhance/prompt-analyzer.js +457 -0
  144. package/plugins/debate/lib/enhance/prompt-patterns.js +1484 -0
  145. package/plugins/debate/lib/enhance/reporter.js +1348 -0
  146. package/plugins/debate/lib/enhance/security-patterns.js +284 -0
  147. package/plugins/debate/lib/enhance/skill-analyzer.js +182 -0
  148. package/plugins/debate/lib/enhance/skill-patterns.js +147 -0
  149. package/plugins/debate/lib/enhance/suppression.js +352 -0
  150. package/plugins/debate/lib/enhance/tool-patterns.js +373 -0
  151. package/plugins/debate/lib/index.js +270 -0
  152. package/plugins/debate/lib/patterns/cli-enhancers.js +611 -0
  153. package/plugins/debate/lib/patterns/pipeline.js +948 -0
  154. package/plugins/debate/lib/patterns/review-patterns.js +558 -0
  155. package/plugins/debate/lib/patterns/slop-analyzers.js +2305 -0
  156. package/plugins/debate/lib/patterns/slop-patterns.js +1187 -0
  157. package/plugins/debate/lib/perf/analyzer/index.js +22 -0
  158. package/plugins/debate/lib/perf/argument-parser.js +105 -0
  159. package/plugins/debate/lib/perf/baseline-comparator.js +50 -0
  160. package/plugins/debate/lib/perf/baseline-store.js +127 -0
  161. package/plugins/debate/lib/perf/benchmark-runner.js +404 -0
  162. package/plugins/debate/lib/perf/breaking-point-finder.js +52 -0
  163. package/plugins/debate/lib/perf/breaking-point-runner.js +60 -0
  164. package/plugins/debate/lib/perf/checkpoint.js +123 -0
  165. package/plugins/debate/lib/perf/code-paths.js +86 -0
  166. package/plugins/debate/lib/perf/consolidation.js +37 -0
  167. package/plugins/debate/lib/perf/constraint-runner.js +71 -0
  168. package/plugins/debate/lib/perf/experiment-runner.js +32 -0
  169. package/plugins/debate/lib/perf/index.js +41 -0
  170. package/plugins/debate/lib/perf/investigation-state.js +874 -0
  171. package/plugins/debate/lib/perf/optimization-runner.js +79 -0
  172. package/plugins/debate/lib/perf/profilers/go.js +22 -0
  173. package/plugins/debate/lib/perf/profilers/index.js +46 -0
  174. package/plugins/debate/lib/perf/profilers/java.js +23 -0
  175. package/plugins/debate/lib/perf/profilers/node.js +27 -0
  176. package/plugins/debate/lib/perf/profilers/python.js +23 -0
  177. package/plugins/debate/lib/perf/profilers/rust.js +23 -0
  178. package/plugins/debate/lib/perf/profiling-runner.js +75 -0
  179. package/plugins/debate/lib/perf/schemas.js +140 -0
  180. package/plugins/debate/lib/platform/detect-platform.js +413 -0
  181. package/plugins/debate/lib/platform/detection-configs.js +93 -0
  182. package/plugins/debate/lib/platform/state-dir.js +132 -0
  183. package/plugins/debate/lib/platform/verify-tools.js +182 -0
  184. package/plugins/debate/lib/repo-map/cache.js +152 -0
  185. package/plugins/debate/lib/repo-map/concurrency.js +29 -0
  186. package/plugins/debate/lib/repo-map/index.js +222 -0
  187. package/plugins/debate/lib/repo-map/installer.js +212 -0
  188. package/plugins/debate/lib/repo-map/queries/go.js +27 -0
  189. package/plugins/debate/lib/repo-map/queries/index.js +100 -0
  190. package/plugins/debate/lib/repo-map/queries/java.js +38 -0
  191. package/plugins/debate/lib/repo-map/queries/javascript.js +55 -0
  192. package/plugins/debate/lib/repo-map/queries/python.js +24 -0
  193. package/plugins/debate/lib/repo-map/queries/rust.js +73 -0
  194. package/plugins/debate/lib/repo-map/queries/typescript.js +38 -0
  195. package/plugins/debate/lib/repo-map/runner.js +1364 -0
  196. package/plugins/debate/lib/repo-map/updater.js +562 -0
  197. package/plugins/debate/lib/repo-map/usage-analyzer.js +407 -0
  198. package/plugins/debate/lib/schemas/plugin-manifest.schema.json +57 -0
  199. package/plugins/debate/lib/schemas/validator.js +247 -0
  200. package/plugins/debate/lib/sources/custom-handler.js +199 -0
  201. package/plugins/debate/lib/sources/policy-questions.js +246 -0
  202. package/plugins/debate/lib/sources/source-cache.js +165 -0
  203. package/plugins/debate/lib/state/workflow-state.js +576 -0
  204. package/plugins/debate/lib/types/agent-frontmatter.d.ts +134 -0
  205. package/plugins/debate/lib/types/command-frontmatter.d.ts +107 -0
  206. package/plugins/debate/lib/types/hook-frontmatter.d.ts +115 -0
  207. package/plugins/debate/lib/types/index.d.ts +84 -0
  208. package/plugins/debate/lib/types/plugin-manifest.d.ts +102 -0
  209. package/plugins/debate/lib/types/skill-frontmatter.d.ts +89 -0
  210. package/plugins/debate/lib/utils/atomic-write.js +94 -0
  211. package/plugins/debate/lib/utils/cache-manager.js +159 -0
  212. package/plugins/debate/lib/utils/command-parser.js +0 -0
  213. package/plugins/debate/lib/utils/context-optimizer.js +300 -0
  214. package/plugins/debate/lib/utils/deprecation.js +37 -0
  215. package/plugins/debate/lib/utils/shell-escape.js +88 -0
  216. package/plugins/debate/lib/utils/state-helpers.js +61 -0
  217. package/plugins/debate/skills/debate/SKILL.md +264 -0
  218. package/plugins/deslop/.claude-plugin/plugin.json +1 -1
  219. package/plugins/deslop/lib/adapter-transforms.js +24 -4
  220. package/plugins/deslop/skills/deslop/SKILL.md +1 -1
  221. package/plugins/drift-detect/.claude-plugin/plugin.json +1 -1
  222. package/plugins/drift-detect/lib/adapter-transforms.js +24 -4
  223. package/plugins/drift-detect/skills/drift-analysis/SKILL.md +1 -1
  224. package/plugins/enhance/.claude-plugin/plugin.json +1 -1
  225. package/plugins/enhance/lib/adapter-transforms.js +24 -4
  226. package/plugins/enhance/skills/enhance-agent-prompts/SKILL.md +1 -1
  227. package/plugins/enhance/skills/enhance-claude-memory/SKILL.md +1 -1
  228. package/plugins/enhance/skills/enhance-cross-file/SKILL.md +1 -1
  229. package/plugins/enhance/skills/enhance-docs/SKILL.md +1 -1
  230. package/plugins/enhance/skills/enhance-hooks/SKILL.md +1 -1
  231. package/plugins/enhance/skills/enhance-orchestrator/SKILL.md +1 -1
  232. package/plugins/enhance/skills/enhance-plugins/SKILL.md +1 -1
  233. package/plugins/enhance/skills/enhance-prompts/SKILL.md +1 -1
  234. package/plugins/enhance/skills/enhance-skills/SKILL.md +1 -1
  235. package/plugins/learn/.claude-plugin/plugin.json +1 -1
  236. package/plugins/learn/agents/learn-agent.md +1 -1
  237. package/plugins/learn/lib/adapter-transforms.js +24 -4
  238. package/plugins/learn/skills/learn/SKILL.md +1 -1
  239. package/plugins/next-task/.claude-plugin/plugin.json +1 -1
  240. package/plugins/next-task/agents/exploration-agent.md +1 -1
  241. package/plugins/next-task/lib/adapter-transforms.js +24 -4
  242. package/plugins/next-task/skills/discover-tasks/SKILL.md +1 -1
  243. package/plugins/next-task/skills/validate-delivery/SKILL.md +1 -1
  244. package/plugins/perf/.claude-plugin/plugin.json +1 -1
  245. package/plugins/perf/lib/adapter-transforms.js +24 -4
  246. package/plugins/perf/skills/perf-analyzer/SKILL.md +1 -1
  247. package/plugins/perf/skills/perf-baseline-manager/SKILL.md +1 -1
  248. package/plugins/perf/skills/perf-benchmarker/SKILL.md +1 -1
  249. package/plugins/perf/skills/perf-code-paths/SKILL.md +1 -1
  250. package/plugins/perf/skills/perf-investigation-logger/SKILL.md +1 -1
  251. package/plugins/perf/skills/perf-profiler/SKILL.md +1 -1
  252. package/plugins/perf/skills/perf-theory-gatherer/SKILL.md +1 -1
  253. package/plugins/perf/skills/perf-theory-tester/SKILL.md +1 -1
  254. package/plugins/repo-map/.claude-plugin/plugin.json +1 -1
  255. package/plugins/repo-map/lib/adapter-transforms.js +24 -4
  256. package/plugins/ship/.claude-plugin/plugin.json +1 -1
  257. package/plugins/ship/lib/adapter-transforms.js +24 -4
  258. package/plugins/sync-docs/.claude-plugin/plugin.json +1 -1
  259. package/plugins/sync-docs/lib/adapter-transforms.js +24 -4
  260. package/plugins/sync-docs/skills/sync-docs/SKILL.md +1 -1
  261. package/scripts/gen-adapters.js +6 -7
  262. package/scripts/generate-docs.js +4 -2
  263. package/scripts/plugins.txt +1 -0
  264. package/site/content.json +6 -6
@@ -0,0 +1,373 @@
1
+ /**
2
+ * MCP Tool Definition Patterns
3
+ * Detection patterns for MCP tool definition issues
4
+ * Based on FUNCTION-CALLING-TOOL-USE-REFERENCE.md best practices
5
+ *
6
+ * @author Avi Fenesh
7
+ * @license MIT
8
+ */
9
+
10
+ /**
11
+ * Tool definition patterns
12
+ */
13
+ const toolPatterns = {
14
+ /**
15
+ * Tool name should be verb + noun
16
+ * MEDIUM certainty - naming convention
17
+ */
18
+ poor_tool_naming: {
19
+ id: 'poor_tool_naming',
20
+ category: 'tool',
21
+ certainty: 'MEDIUM',
22
+ autoFix: false,
23
+ description: 'Tool name should follow verb_noun pattern',
24
+ check: (tool) => {
25
+ if (!tool || !tool.name) return null;
26
+
27
+ const name = tool.name;
28
+ // Check for common verb prefixes
29
+ const verbPrefixes = ['get', 'set', 'create', 'delete', 'update', 'list', 'find', 'search', 'add', 'remove', 'check', 'validate', 'run', 'execute', 'start', 'stop', 'read', 'write'];
30
+ const hasVerb = verbPrefixes.some(v => name.toLowerCase().startsWith(v));
31
+
32
+ if (!hasVerb && name.length > 3) {
33
+ return {
34
+ issue: `Tool name "${name}" doesn't start with a verb`,
35
+ fix: 'Rename to verb_noun pattern (e.g., get_user, create_file)'
36
+ };
37
+ }
38
+ return null;
39
+ }
40
+ },
41
+
42
+ /**
43
+ * Use enums for constrained values
44
+ * MEDIUM certainty - improves reliability
45
+ */
46
+ missing_enum: {
47
+ id: 'missing_enum',
48
+ category: 'tool',
49
+ certainty: 'MEDIUM',
50
+ autoFix: false,
51
+ description: 'Parameter with limited options should use enum',
52
+ check: (schema) => {
53
+ if (!schema || !schema.properties) return null;
54
+
55
+ const issues = [];
56
+ for (const [name, prop] of Object.entries(schema.properties)) {
57
+ // Check for string params that mention specific options in description
58
+ if (prop.type === 'string' && prop.description) {
59
+ const desc = prop.description.toLowerCase();
60
+ if ((desc.includes('one of') || desc.includes('must be') || desc.includes('can be')) &&
61
+ !prop.enum) {
62
+ issues.push({
63
+ param: name,
64
+ issue: `Parameter "${name}" describes options but doesn't use enum`,
65
+ fix: 'Add enum array with valid options'
66
+ });
67
+ }
68
+ }
69
+ }
70
+
71
+ return issues.length > 0 ? issues : null;
72
+ }
73
+ },
74
+
75
+ /**
76
+ * Flat structure preferred
77
+ * MEDIUM certainty - improves LLM reliability
78
+ */
79
+ nested_structure: {
80
+ id: 'nested_structure',
81
+ category: 'tool',
82
+ certainty: 'MEDIUM',
83
+ autoFix: false,
84
+ description: 'Prefer flat parameter structure over nested objects',
85
+ maxDepth: 2,
86
+ check: (schema, depth = 0) => {
87
+ if (!schema || typeof schema !== 'object') return null;
88
+
89
+ if (depth > 2) {
90
+ return {
91
+ issue: `Schema nested ${depth} levels (prefer flat structure)`,
92
+ fix: 'Flatten to max 2 levels for LLM reliability'
93
+ };
94
+ }
95
+
96
+ if (schema.properties) {
97
+ for (const [name, prop] of Object.entries(schema.properties)) {
98
+ if (prop.type === 'object' && prop.properties) {
99
+ const nested = toolPatterns.nested_structure.check(prop, depth + 1);
100
+ if (nested) return { ...nested, param: name };
101
+ }
102
+ }
103
+ }
104
+
105
+ return null;
106
+ }
107
+ },
108
+
109
+ /**
110
+ * Parameter format hints
111
+ * LOW certainty - improves clarity
112
+ */
113
+ missing_format_hints: {
114
+ id: 'missing_format_hints',
115
+ category: 'tool',
116
+ certainty: 'LOW',
117
+ autoFix: false,
118
+ description: 'Parameter description could include format hints',
119
+ check: (schema) => {
120
+ if (!schema || !schema.properties) return null;
121
+
122
+ const issues = [];
123
+ const formatKeywords = ['date', 'time', 'email', 'url', 'path', 'json', 'uuid', 'regex'];
124
+
125
+ for (const [name, prop] of Object.entries(schema.properties)) {
126
+ if (prop.type === 'string' && prop.description) {
127
+ const nameLower = name.toLowerCase();
128
+ const descLower = prop.description.toLowerCase();
129
+
130
+ // Check if name suggests a format but no format/pattern specified
131
+ for (const keyword of formatKeywords) {
132
+ if ((nameLower.includes(keyword) || descLower.includes(keyword)) &&
133
+ !prop.format && !prop.pattern) {
134
+ issues.push({
135
+ param: name,
136
+ issue: `Parameter "${name}" may need format hint`,
137
+ fix: `Consider adding format or pattern for ${keyword} validation`
138
+ });
139
+ break;
140
+ }
141
+ }
142
+ }
143
+ }
144
+
145
+ return issues.length > 0 ? issues : null;
146
+ }
147
+ },
148
+
149
+ /**
150
+ * Required parameters should be explicit
151
+ * HIGH certainty - prevents ambiguity
152
+ */
153
+ implicit_required: {
154
+ id: 'implicit_required',
155
+ category: 'tool',
156
+ certainty: 'HIGH',
157
+ autoFix: true,
158
+ description: 'Parameters should explicitly declare required status',
159
+ check: (schema) => {
160
+ if (!schema || !schema.properties) return null;
161
+
162
+ const propCount = Object.keys(schema.properties).length;
163
+ const requiredCount = schema.required?.length || 0;
164
+
165
+ // If properties exist but no required array
166
+ if (propCount > 0 && !schema.required) {
167
+ return {
168
+ issue: 'No required array defined',
169
+ fix: 'Add required array listing mandatory parameters',
170
+ autoFixFn: (s) => ({
171
+ ...s,
172
+ required: Object.keys(s.properties).filter(k => {
173
+ const prop = s.properties[k];
174
+ // Consider params required unless they have default or are marked optional
175
+ return !prop.default && !/optional/i.test(prop.description || '');
176
+ })
177
+ })
178
+ };
179
+ }
180
+
181
+ return null;
182
+ }
183
+ },
184
+
185
+ /**
186
+ * Strict mode recommended
187
+ * HIGH certainty - prevents undefined behavior
188
+ */
189
+ missing_strict_mode: {
190
+ id: 'missing_strict_mode',
191
+ category: 'tool',
192
+ certainty: 'HIGH',
193
+ autoFix: true,
194
+ description: 'Schema should use strict mode (additionalProperties: false)',
195
+ check: (schema) => {
196
+ if (!schema || schema.type !== 'object') return null;
197
+
198
+ if (schema.additionalProperties !== false) {
199
+ return {
200
+ issue: 'Schema not in strict mode',
201
+ fix: 'Add additionalProperties: false',
202
+ autoFixFn: (s) => ({ ...s, additionalProperties: false })
203
+ };
204
+ }
205
+
206
+ return null;
207
+ }
208
+ },
209
+
210
+ /**
211
+ * Description quality check
212
+ * LOW certainty - stylistic
213
+ */
214
+ poor_description: {
215
+ id: 'poor_description',
216
+ category: 'tool',
217
+ certainty: 'LOW',
218
+ autoFix: false,
219
+ description: 'Tool description could be more descriptive',
220
+ minLength: 20,
221
+ check: (tool) => {
222
+ if (!tool || !tool.description) return null;
223
+
224
+ const desc = tool.description.trim();
225
+
226
+ // Too short
227
+ if (desc.length < 20) {
228
+ return {
229
+ issue: `Description too short (${desc.length} chars)`,
230
+ fix: 'Add more detail about what the tool does'
231
+ };
232
+ }
233
+
234
+ // Just repeats the name
235
+ if (tool.name && desc.toLowerCase().replace(/[_-]/g, ' ') === tool.name.toLowerCase().replace(/[_-]/g, ' ')) {
236
+ return {
237
+ issue: 'Description just repeats tool name',
238
+ fix: 'Describe what the tool does, not its name'
239
+ };
240
+ }
241
+
242
+ return null;
243
+ }
244
+ },
245
+
246
+ /**
247
+ * Redundant tool detection
248
+ * LOW certainty - may be intentional
249
+ */
250
+ redundant_tools: {
251
+ id: 'redundant_tools',
252
+ category: 'tool',
253
+ certainty: 'LOW',
254
+ autoFix: false,
255
+ description: 'Potentially redundant tools with similar functionality',
256
+ check: (tools) => {
257
+ if (!tools || !Array.isArray(tools) || tools.length < 2) return null;
258
+
259
+ const issues = [];
260
+ const seen = new Map();
261
+
262
+ for (const tool of tools) {
263
+ if (!tool.name) continue;
264
+
265
+ // Normalize name for comparison
266
+ const normalized = tool.name.toLowerCase()
267
+ .replace(/[_-]/g, '')
268
+ .replace(/^(get|fetch|retrieve|find|search)/, 'get')
269
+ .replace(/^(set|update|modify|change)/, 'set')
270
+ .replace(/^(create|make|add|new)/, 'create')
271
+ .replace(/^(delete|remove|destroy)/, 'delete');
272
+
273
+ if (seen.has(normalized)) {
274
+ issues.push({
275
+ tool1: seen.get(normalized),
276
+ tool2: tool.name,
277
+ issue: `Tools "${seen.get(normalized)}" and "${tool.name}" may be redundant`,
278
+ fix: 'Consider consolidating into single tool'
279
+ });
280
+ }
281
+ seen.set(normalized, tool.name);
282
+ }
283
+
284
+ return issues.length > 0 ? issues : null;
285
+ }
286
+ }
287
+ };
288
+
289
+ /**
290
+ * Get all tool patterns
291
+ * @returns {Object} All tool patterns
292
+ */
293
+ function getAllPatterns() {
294
+ return toolPatterns;
295
+ }
296
+
297
+ /**
298
+ * Get patterns by certainty level
299
+ * @param {string} certainty - HIGH, MEDIUM, or LOW
300
+ * @returns {Object} Filtered patterns
301
+ */
302
+ function getPatternsByCertainty(certainty) {
303
+ const result = {};
304
+ for (const [name, pattern] of Object.entries(toolPatterns)) {
305
+ if (pattern.certainty === certainty) {
306
+ result[name] = pattern;
307
+ }
308
+ }
309
+ return result;
310
+ }
311
+
312
+ /**
313
+ * Analyze a tool definition
314
+ * @param {Object} tool - Tool definition object
315
+ * @returns {Array} Array of issues found
316
+ */
317
+ function analyzeTool(tool) {
318
+ const issues = [];
319
+
320
+ for (const [name, pattern] of Object.entries(toolPatterns)) {
321
+ if (pattern.check && name !== 'redundant_tools') {
322
+ const result = pattern.check(tool);
323
+ if (result) {
324
+ if (Array.isArray(result)) {
325
+ issues.push(...result.map(r => ({ ...r, patternId: pattern.id, certainty: pattern.certainty })));
326
+ } else {
327
+ issues.push({ ...result, patternId: pattern.id, certainty: pattern.certainty });
328
+ }
329
+ }
330
+ }
331
+ }
332
+
333
+ // Check schema separately
334
+ if (tool.inputSchema || tool.parameters) {
335
+ const schema = tool.inputSchema || tool.parameters;
336
+ for (const [name, pattern] of Object.entries(toolPatterns)) {
337
+ if (pattern.check && ['nested_structure', 'missing_enum', 'missing_format_hints', 'implicit_required', 'missing_strict_mode'].includes(name)) {
338
+ const result = pattern.check(schema);
339
+ if (result) {
340
+ if (Array.isArray(result)) {
341
+ issues.push(...result.map(r => ({ ...r, patternId: pattern.id, certainty: pattern.certainty, tool: tool.name })));
342
+ } else {
343
+ issues.push({ ...result, patternId: pattern.id, certainty: pattern.certainty, tool: tool.name });
344
+ }
345
+ }
346
+ }
347
+ }
348
+ }
349
+
350
+ return issues;
351
+ }
352
+
353
+ /**
354
+ * Check for redundant tools across a set
355
+ * @param {Array} tools - Array of tool definitions
356
+ * @returns {Array} Array of redundancy issues
357
+ */
358
+ function checkRedundancy(tools) {
359
+ const pattern = toolPatterns.redundant_tools;
360
+ const result = pattern.check(tools);
361
+ if (result) {
362
+ return result.map(r => ({ ...r, patternId: pattern.id, certainty: pattern.certainty }));
363
+ }
364
+ return [];
365
+ }
366
+
367
+ module.exports = {
368
+ toolPatterns,
369
+ getAllPatterns,
370
+ getPatternsByCertainty,
371
+ analyzeTool,
372
+ checkRedundancy
373
+ };
@@ -0,0 +1,270 @@
1
+ /**
2
+ * AgentSys Core Library
3
+ *
4
+ * Unified entry point for all core library modules.
5
+ * Provides platform detection, pattern matching, workflow state management,
6
+ * configuration management, and context optimization utilities.
7
+ *
8
+ * @module agentsys/lib
9
+ * @author Avi Fenesh
10
+ * @license MIT
11
+ */
12
+
13
+ const detectPlatform = require('./platform/detect-platform');
14
+ const verifyTools = require('./platform/verify-tools');
15
+ const reviewPatterns = require('./patterns/review-patterns');
16
+ const slopPatterns = require('./patterns/slop-patterns');
17
+ const pipeline = require('./patterns/pipeline');
18
+ const cliEnhancers = require('./patterns/cli-enhancers');
19
+ const workflowState = require('./state/workflow-state');
20
+ const contextOptimizer = require('./utils/context-optimizer');
21
+ const shellEscape = require('./utils/shell-escape');
22
+ const config = require('./config');
23
+ const sourceCache = require('./sources/source-cache');
24
+ const customHandler = require('./sources/custom-handler');
25
+ const policyQuestions = require('./sources/policy-questions');
26
+ const crossPlatform = require('./cross-platform');
27
+ const enhance = require('./enhance');
28
+ const repoMap = require('./repo-map');
29
+ const perf = require('./perf');
30
+ const collectors = require('./collectors');
31
+ const discoveryModule = require('./discovery');
32
+
33
+ /**
34
+ * Platform detection and verification utilities
35
+ */
36
+ const platform = {
37
+ /**
38
+ * Detect project platform configuration
39
+ * @see module:platform/detect-platform
40
+ */
41
+ detect: detectPlatform.detect,
42
+ detectAsync: detectPlatform.detectAsync,
43
+ detectCI: detectPlatform.detectCI,
44
+ detectDeployment: detectPlatform.detectDeployment,
45
+ detectProjectType: detectPlatform.detectProjectType,
46
+ detectPackageManager: detectPlatform.detectPackageManager,
47
+ detectBranchStrategy: detectPlatform.detectBranchStrategy,
48
+ detectMainBranch: detectPlatform.detectMainBranch,
49
+ invalidateCache: detectPlatform.invalidateCache,
50
+
51
+ /**
52
+ * Verify tool availability
53
+ * @see module:platform/verify-tools
54
+ */
55
+ verifyTools: verifyTools.verify,
56
+ verifyToolsAsync: verifyTools.verifyAsync,
57
+ checkTool: verifyTools.checkTool,
58
+ checkToolAsync: verifyTools.checkToolAsync,
59
+ TOOL_DEFINITIONS: verifyTools.TOOL_DEFINITIONS
60
+ };
61
+
62
+ /**
63
+ * Code pattern matching utilities
64
+ */
65
+ const patterns = {
66
+ /**
67
+ * Review patterns for code quality analysis
68
+ * @see module:patterns/review-patterns
69
+ */
70
+ review: reviewPatterns,
71
+
72
+ /**
73
+ * Slop patterns for AI-generated code detection
74
+ * @see module:patterns/slop-patterns
75
+ */
76
+ slop: slopPatterns,
77
+
78
+ /**
79
+ * Slop detection pipeline orchestrator
80
+ * @see module:patterns/pipeline
81
+ */
82
+ pipeline: {
83
+ runPipeline: pipeline.runPipeline,
84
+ CERTAINTY: pipeline.CERTAINTY,
85
+ THOROUGHNESS: pipeline.THOROUGHNESS,
86
+ formatHandoffPrompt: pipeline.formatHandoffPrompt,
87
+ buildSummary: pipeline.buildSummary
88
+ },
89
+
90
+ /**
91
+ * Optional CLI tool enhancers for deep analysis
92
+ * @see module:patterns/cli-enhancers
93
+ */
94
+ cliEnhancers: {
95
+ detectAvailableTools: cliEnhancers.detectAvailableTools,
96
+ runDuplicateDetection: cliEnhancers.runDuplicateDetection,
97
+ runDependencyAnalysis: cliEnhancers.runDependencyAnalysis,
98
+ runComplexityAnalysis: cliEnhancers.runComplexityAnalysis,
99
+ getMissingToolsMessage: cliEnhancers.getMissingToolsMessage,
100
+ CLI_TOOLS: cliEnhancers.CLI_TOOLS
101
+ }
102
+ };
103
+
104
+ /**
105
+ * Workflow state management
106
+ * @see module:state/workflow-state
107
+ */
108
+ const state = {
109
+ // Constants
110
+ SCHEMA_VERSION: workflowState.SCHEMA_VERSION,
111
+ PHASES: workflowState.PHASES,
112
+ DEFAULT_POLICY: workflowState.DEFAULT_POLICY,
113
+
114
+ // Core functions
115
+ generateWorkflowId: workflowState.generateWorkflowId,
116
+ getStatePath: workflowState.getStatePath,
117
+ ensureStateDir: workflowState.ensureStateDir,
118
+ validateStateSchema: workflowState.validateStateSchema,
119
+
120
+ // CRUD operations
121
+ createState: workflowState.createState,
122
+ readState: workflowState.readState,
123
+ writeState: workflowState.writeState,
124
+ updateState: workflowState.updateState,
125
+ deleteState: workflowState.deleteState,
126
+
127
+ // Phase management
128
+ startPhase: workflowState.startPhase,
129
+ completePhase: workflowState.completePhase,
130
+ failPhase: workflowState.failPhase,
131
+ skipToPhase: workflowState.skipToPhase,
132
+
133
+ // Workflow lifecycle
134
+ completeWorkflow: workflowState.completeWorkflow,
135
+ abortWorkflow: workflowState.abortWorkflow,
136
+ hasActiveWorkflow: workflowState.hasActiveWorkflow,
137
+ getWorkflowSummary: workflowState.getWorkflowSummary,
138
+
139
+ // Agent management
140
+ updateAgentResult: workflowState.updateAgentResult,
141
+ incrementIteration: workflowState.incrementIteration
142
+ };
143
+
144
+ /**
145
+ * Git command optimization and string escaping utilities
146
+ * @see module:utils/context-optimizer
147
+ * @see module:utils/shell-escape
148
+ */
149
+ const utils = {
150
+ contextOptimizer,
151
+ shellEscape
152
+ };
153
+
154
+ /**
155
+ * Task source management
156
+ * @see module:sources/source-cache
157
+ * @see module:sources/custom-handler
158
+ * @see module:sources/policy-questions
159
+ */
160
+ const sources = {
161
+ // Main entry point - returns ready-to-use question structure
162
+ getPolicyQuestions: policyQuestions.getPolicyQuestions,
163
+ getCustomTypeQuestions: policyQuestions.getCustomTypeQuestions,
164
+ getCustomNameQuestion: policyQuestions.getCustomNameQuestion,
165
+ parseAndCachePolicy: policyQuestions.parseAndCachePolicy,
166
+ isUsingCached: policyQuestions.isUsingCached,
167
+ needsCustomFollowUp: policyQuestions.needsCustomFollowUp,
168
+ needsOtherDescription: policyQuestions.needsOtherDescription,
169
+
170
+ // Cache operations (direct access if needed)
171
+ getPreference: sourceCache.getPreference,
172
+ savePreference: sourceCache.savePreference,
173
+ getToolCapabilities: sourceCache.getToolCapabilities,
174
+ saveToolCapabilities: sourceCache.saveToolCapabilities,
175
+ clearCache: sourceCache.clearCache,
176
+
177
+ // Custom source handling (direct access if needed)
178
+ SOURCE_TYPES: customHandler.SOURCE_TYPES,
179
+ probeCLI: customHandler.probeCLI,
180
+ buildCustomConfig: customHandler.buildCustomConfig
181
+ };
182
+
183
+ /**
184
+ * Cross-platform utilities for Claude Code, OpenCode, and Codex CLI
185
+ * @see module:cross-platform
186
+ */
187
+ const xplat = {
188
+ // Platform detection
189
+ PLATFORMS: crossPlatform.PLATFORMS,
190
+ STATE_DIRS: crossPlatform.STATE_DIRS,
191
+ getStateDir: crossPlatform.getStateDir,
192
+ detectPlatform: crossPlatform.detectPlatform,
193
+
194
+ // Tool schema helpers
195
+ TOOL_SCHEMA_GUIDELINES: crossPlatform.TOOL_SCHEMA_GUIDELINES,
196
+ createToolDefinition: crossPlatform.createToolDefinition,
197
+
198
+ // Response helpers (MCP-compatible)
199
+ successResponse: crossPlatform.successResponse,
200
+ errorResponse: crossPlatform.errorResponse,
201
+ unknownToolResponse: crossPlatform.unknownToolResponse,
202
+
203
+ // Prompt formatting
204
+ formatBlock: crossPlatform.formatBlock,
205
+ formatList: crossPlatform.formatList,
206
+ formatSection: crossPlatform.formatSection,
207
+
208
+ // Token efficiency
209
+ truncate: crossPlatform.truncate,
210
+ compactSummary: crossPlatform.compactSummary,
211
+
212
+ // Agent prompts
213
+ AGENT_TEMPLATE: crossPlatform.AGENT_TEMPLATE,
214
+ createAgentPrompt: crossPlatform.createAgentPrompt,
215
+
216
+ // Platform configs
217
+ getOpenCodeConfig: crossPlatform.getOpenCodeConfig,
218
+ getCodexConfig: crossPlatform.getCodexConfig,
219
+ getInstructionFiles: crossPlatform.getInstructionFiles,
220
+ INSTRUCTION_FILES: crossPlatform.INSTRUCTION_FILES
221
+ };
222
+
223
+ /**
224
+ * Plugin discovery via filesystem convention
225
+ * @see module:discovery
226
+ */
227
+ const discovery = {
228
+ parseFrontmatter: discoveryModule.parseFrontmatter,
229
+ discoverPlugins: discoveryModule.discoverPlugins,
230
+ discoverCommands: discoveryModule.discoverCommands,
231
+ discoverAgents: discoveryModule.discoverAgents,
232
+ discoverSkills: discoveryModule.discoverSkills,
233
+ discoverAll: discoveryModule.discoverAll,
234
+ getCommandMappings: discoveryModule.getCommandMappings,
235
+ getCodexSkillMappings: discoveryModule.getCodexSkillMappings,
236
+ getPluginPrefixRegex: discoveryModule.getPluginPrefixRegex,
237
+ invalidateCache: discoveryModule.invalidateCache
238
+ };
239
+
240
+ // Main exports
241
+ module.exports = {
242
+ platform,
243
+ patterns,
244
+ state,
245
+ utils,
246
+ config,
247
+ sources,
248
+ xplat,
249
+ enhance,
250
+ repoMap,
251
+ perf,
252
+ collectors,
253
+ discovery,
254
+
255
+ // Direct module access for backward compatibility
256
+ detectPlatform,
257
+ verifyTools,
258
+ reviewPatterns,
259
+ slopPatterns,
260
+ pipeline,
261
+ cliEnhancers,
262
+ workflowState,
263
+ contextOptimizer,
264
+ shellEscape,
265
+ sourceCache,
266
+ customHandler,
267
+ policyQuestions,
268
+ crossPlatform,
269
+ discoveryModule
270
+ };