tachibot-mcp 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (214) hide show
  1. package/.env.example +260 -0
  2. package/CHANGELOG.md +54 -0
  3. package/CODE_OF_CONDUCT.md +56 -0
  4. package/CONTRIBUTING.md +54 -0
  5. package/Dockerfile +36 -0
  6. package/LICENSE +644 -0
  7. package/README.md +201 -0
  8. package/SECURITY.md +95 -0
  9. package/dist/personality/komaai-expressions.js +12 -0
  10. package/dist/profiles/balanced.json +33 -0
  11. package/dist/profiles/code_focus.json +33 -0
  12. package/dist/profiles/full.json +33 -0
  13. package/dist/profiles/minimal.json +33 -0
  14. package/dist/profiles/research_power.json +33 -0
  15. package/dist/scripts/build-profiles.js +46 -0
  16. package/dist/src/application/services/focus/FocusModeRegistry.js +46 -0
  17. package/dist/src/application/services/focus/FocusTool.service.js +109 -0
  18. package/dist/src/application/services/focus/ModeRegistry.js +46 -0
  19. package/dist/src/application/services/focus/modes/focus-deep.mode.js +27 -0
  20. package/dist/src/application/services/focus/modes/status.mode.js +50 -0
  21. package/dist/src/application/services/focus/modes/tachibot-status.mode.js +50 -0
  22. package/dist/src/collaborative-orchestrator.js +391 -0
  23. package/dist/src/config/model-constants.js +188 -0
  24. package/dist/src/config/model-defaults.js +57 -0
  25. package/dist/src/config/model-preferences.js +382 -0
  26. package/dist/src/config/timeout-config.js +130 -0
  27. package/dist/src/config.js +173 -0
  28. package/dist/src/domain/interfaces/IFocusMode.js +5 -0
  29. package/dist/src/domain/interfaces/IProvider.js +6 -0
  30. package/dist/src/domain/interfaces/ITool.js +5 -0
  31. package/dist/src/focus-deep.js +245 -0
  32. package/dist/src/infrastructure/ascii/art/robots.ascii.js +16 -0
  33. package/dist/src/mcp-client.js +90 -0
  34. package/dist/src/memory/index.js +17 -0
  35. package/dist/src/memory/memory-config.js +135 -0
  36. package/dist/src/memory/memory-interface.js +174 -0
  37. package/dist/src/memory/memory-manager.js +383 -0
  38. package/dist/src/memory/providers/devlog-provider.js +385 -0
  39. package/dist/src/memory/providers/hybrid-provider.js +399 -0
  40. package/dist/src/memory/providers/local-provider.js +388 -0
  41. package/dist/src/memory/providers/mem0-provider.js +337 -0
  42. package/dist/src/modes/architect.js +477 -0
  43. package/dist/src/modes/auditor.js +362 -0
  44. package/dist/src/modes/challenger.js +841 -0
  45. package/dist/src/modes/code-reviewer.js +382 -0
  46. package/dist/src/modes/commit-guardian.js +424 -0
  47. package/dist/src/modes/documentation-writer.js +572 -0
  48. package/dist/src/modes/scout.js +587 -0
  49. package/dist/src/modes/shared/helpers/challenger-helpers.js +454 -0
  50. package/dist/src/modes/shared/helpers/index.js +17 -0
  51. package/dist/src/modes/shared/helpers/scout-helpers.js +270 -0
  52. package/dist/src/modes/shared/helpers/verifier-helpers.js +332 -0
  53. package/dist/src/modes/test-architect.js +767 -0
  54. package/dist/src/modes/verifier.js +378 -0
  55. package/dist/src/monitoring/performance-monitor.js +435 -0
  56. package/dist/src/optimization/batch-executor.js +121 -0
  57. package/dist/src/optimization/context-pruner.js +196 -0
  58. package/dist/src/optimization/cost-monitor.js +338 -0
  59. package/dist/src/optimization/index.js +65 -0
  60. package/dist/src/optimization/model-router.js +264 -0
  61. package/dist/src/optimization/result-cache.js +114 -0
  62. package/dist/src/optimization/token-optimizer.js +257 -0
  63. package/dist/src/optimization/token-tracker.js +118 -0
  64. package/dist/src/orchestrator-instructions.js +128 -0
  65. package/dist/src/orchestrator-lite.js +139 -0
  66. package/dist/src/orchestrator.js +191 -0
  67. package/dist/src/orchestrators/collaborative/interfaces/IToolExecutionEngine.js +1 -0
  68. package/dist/src/orchestrators/collaborative/interfaces/IToolExecutionStrategy.js +5 -0
  69. package/dist/src/orchestrators/collaborative/interfaces/IVisualizationRenderer.js +1 -0
  70. package/dist/src/orchestrators/collaborative/registries/ModelProviderRegistry.js +95 -0
  71. package/dist/src/orchestrators/collaborative/registries/ToolAdapterRegistry.js +64 -0
  72. package/dist/src/orchestrators/collaborative/services/tool-execution/ToolExecutionService.js +502 -0
  73. package/dist/src/orchestrators/collaborative/services/visualization/VisualizationService.js +206 -0
  74. package/dist/src/orchestrators/collaborative/types/session-types.js +5 -0
  75. package/dist/src/profiles/balanced.js +37 -0
  76. package/dist/src/profiles/code_focus.js +37 -0
  77. package/dist/src/profiles/debug_intensive.js +59 -0
  78. package/dist/src/profiles/full.js +37 -0
  79. package/dist/src/profiles/minimal.js +37 -0
  80. package/dist/src/profiles/research_code.js +59 -0
  81. package/dist/src/profiles/research_power.js +37 -0
  82. package/dist/src/profiles/types.js +5 -0
  83. package/dist/src/profiles/workflow_builder.js +53 -0
  84. package/dist/src/prompt-engineer-lite.js +78 -0
  85. package/dist/src/prompt-engineer.js +399 -0
  86. package/dist/src/reasoning-chain.js +508 -0
  87. package/dist/src/sequential-thinking.js +291 -0
  88. package/dist/src/server-diagnostic.js +74 -0
  89. package/dist/src/server-raw.js +158 -0
  90. package/dist/src/server-simple.js +58 -0
  91. package/dist/src/server.js +514 -0
  92. package/dist/src/session/session-logger.js +617 -0
  93. package/dist/src/session/session-manager.js +571 -0
  94. package/dist/src/session/session-tools.js +400 -0
  95. package/dist/src/tools/advanced-modes.js +200 -0
  96. package/dist/src/tools/claude-integration.js +356 -0
  97. package/dist/src/tools/consolidated/ai-router.js +174 -0
  98. package/dist/src/tools/consolidated/ai-tool.js +48 -0
  99. package/dist/src/tools/consolidated/brainstorm-tool.js +87 -0
  100. package/dist/src/tools/consolidated/environment-detector.js +80 -0
  101. package/dist/src/tools/consolidated/index.js +50 -0
  102. package/dist/src/tools/consolidated/search-tool.js +110 -0
  103. package/dist/src/tools/consolidated/workflow-tool.js +238 -0
  104. package/dist/src/tools/gemini-tools.js +329 -0
  105. package/dist/src/tools/grok-enhanced.js +376 -0
  106. package/dist/src/tools/grok-tools.js +299 -0
  107. package/dist/src/tools/lmstudio-tools.js +223 -0
  108. package/dist/src/tools/openai-tools.js +498 -0
  109. package/dist/src/tools/openrouter-tools.js +317 -0
  110. package/dist/src/tools/optimized-wrapper.js +204 -0
  111. package/dist/src/tools/perplexity-tools.js +294 -0
  112. package/dist/src/tools/pingpong-tool.js +343 -0
  113. package/dist/src/tools/qwen-wrapper.js +74 -0
  114. package/dist/src/tools/tool-router.js +444 -0
  115. package/dist/src/tools/unified-ai-provider.js +260 -0
  116. package/dist/src/tools/workflow-runner.js +425 -0
  117. package/dist/src/tools/workflow-validator-tool.js +107 -0
  118. package/dist/src/types.js +23 -0
  119. package/dist/src/utils/input-validator.js +130 -0
  120. package/dist/src/utils/model-router.js +91 -0
  121. package/dist/src/utils/progress-stream.js +255 -0
  122. package/dist/src/utils/provider-router.js +88 -0
  123. package/dist/src/utils/smart-api-client.js +146 -0
  124. package/dist/src/utils/table-builder.js +218 -0
  125. package/dist/src/utils/timestamp-formatter.js +134 -0
  126. package/dist/src/utils/tool-compressor.js +257 -0
  127. package/dist/src/utils/tool-config.js +201 -0
  128. package/dist/src/validators/dependency-graph-validator.js +147 -0
  129. package/dist/src/validators/interpolation-validator.js +222 -0
  130. package/dist/src/validators/output-usage-validator.js +151 -0
  131. package/dist/src/validators/syntax-validator.js +102 -0
  132. package/dist/src/validators/tool-registry-validator.js +123 -0
  133. package/dist/src/validators/tool-types.js +97 -0
  134. package/dist/src/validators/types.js +8 -0
  135. package/dist/src/validators/workflow-validator.js +134 -0
  136. package/dist/src/visualizer-lite.js +42 -0
  137. package/dist/src/visualizer.js +179 -0
  138. package/dist/src/workflows/circuit-breaker.js +199 -0
  139. package/dist/src/workflows/custom-workflows.js +451 -0
  140. package/dist/src/workflows/engine/AutoSynthesizer.js +97 -0
  141. package/dist/src/workflows/engine/StepParameterResolver.js +74 -0
  142. package/dist/src/workflows/engine/VariableInterpolator.js +123 -0
  143. package/dist/src/workflows/engine/WorkflowDiscovery.js +125 -0
  144. package/dist/src/workflows/engine/WorkflowExecutionEngine.js +485 -0
  145. package/dist/src/workflows/engine/WorkflowExecutor.js +113 -0
  146. package/dist/src/workflows/engine/WorkflowFileManager.js +244 -0
  147. package/dist/src/workflows/engine/WorkflowHelpers.js +114 -0
  148. package/dist/src/workflows/engine/WorkflowOutputFormatter.js +83 -0
  149. package/dist/src/workflows/engine/events/WorkflowEventBus.js +132 -0
  150. package/dist/src/workflows/engine/events/interfaces/IEventBus.js +5 -0
  151. package/dist/src/workflows/engine/handlers/ErrorRecoveryHandler.js +162 -0
  152. package/dist/src/workflows/engine/handlers/PromptEnhancementHandler.js +115 -0
  153. package/dist/src/workflows/engine/handlers/SessionPersistenceHandler.js +167 -0
  154. package/dist/src/workflows/engine/handlers/StepExecutionHandler.js +231 -0
  155. package/dist/src/workflows/engine/handlers/ToolInvocationHandler.js +46 -0
  156. package/dist/src/workflows/engine/interfaces/IAutoSynthesizer.js +5 -0
  157. package/dist/src/workflows/engine/interfaces/IStepParameterResolver.js +5 -0
  158. package/dist/src/workflows/engine/interfaces/IVariableInterpolator.js +5 -0
  159. package/dist/src/workflows/engine/interfaces/IWorkflowDiscovery.js +4 -0
  160. package/dist/src/workflows/engine/interfaces/IWorkflowFileManager.js +5 -0
  161. package/dist/src/workflows/engine/interfaces/IWorkflowOutputFormatter.js +5 -0
  162. package/dist/src/workflows/engine/state/WorkflowStateMachine.js +194 -0
  163. package/dist/src/workflows/engine/state/interfaces/IStateMachine.js +17 -0
  164. package/dist/src/workflows/fallback-strategies.js +373 -0
  165. package/dist/src/workflows/message-queue.js +455 -0
  166. package/dist/src/workflows/model-router.js +189 -0
  167. package/dist/src/workflows/orchestrator-examples.js +174 -0
  168. package/dist/src/workflows/orchestrator-integration.js +200 -0
  169. package/dist/src/workflows/self-healing.js +524 -0
  170. package/dist/src/workflows/tool-mapper.js +407 -0
  171. package/dist/src/workflows/tool-orchestrator.js +796 -0
  172. package/dist/src/workflows/workflow-engine.js +573 -0
  173. package/dist/src/workflows/workflow-parser.js +283 -0
  174. package/dist/src/workflows/workflow-types.js +95 -0
  175. package/dist/src/workflows.js +568 -0
  176. package/dist/test-workflow-file-output.js +93 -0
  177. package/docs/API_KEYS.md +570 -0
  178. package/docs/CLAUDE_CODE_SETUP.md +181 -0
  179. package/docs/CLAUDE_DESKTOP_MANUAL.md +127 -0
  180. package/docs/CONFIGURATION.md +745 -0
  181. package/docs/FOCUS_MODES.md +240 -0
  182. package/docs/INSTALLATION_BOTH.md +145 -0
  183. package/docs/TERMS.md +352 -0
  184. package/docs/TOOLS_REFERENCE.md +1622 -0
  185. package/docs/TOOL_PARAMETERS.md +496 -0
  186. package/docs/TOOL_PROFILES.md +236 -0
  187. package/docs/WORKFLOWS.md +987 -0
  188. package/docs/WORKFLOW_OUTPUT.md +198 -0
  189. package/docs/WORKFLOW_PROGRESS_TRACKING.md +305 -0
  190. package/docs/workflows/design-brainstorm.md +335 -0
  191. package/package.json +97 -0
  192. package/profiles/balanced.json +37 -0
  193. package/profiles/code_focus.json +37 -0
  194. package/profiles/debug_intensive.json +34 -0
  195. package/profiles/full.json +37 -0
  196. package/profiles/minimal.json +37 -0
  197. package/profiles/research_power.json +37 -0
  198. package/profiles/workflow_builder.json +37 -0
  199. package/smithery.yaml +66 -0
  200. package/start.sh +8 -0
  201. package/tools.config.json +81 -0
  202. package/tsconfig.json +18 -0
  203. package/workflows/accessibility-code-audit.yaml +92 -0
  204. package/workflows/code-architecture-review.yaml +202 -0
  205. package/workflows/code-review.yaml +142 -0
  206. package/workflows/core/iterative-problem-solver.yaml +283 -0
  207. package/workflows/creative-brainstorm-yaml.yaml +215 -0
  208. package/workflows/pingpong.yaml +141 -0
  209. package/workflows/system/README.md +412 -0
  210. package/workflows/system/challenger.yaml +175 -0
  211. package/workflows/system/scout.yaml +164 -0
  212. package/workflows/system/verifier.yaml +133 -0
  213. package/workflows/ultra-creative-brainstorm.yaml +318 -0
  214. package/workflows/ux-research-flow.yaml +92 -0
@@ -0,0 +1,400 @@
1
+ /**
2
+ * Session-related MCP tools for Focus MCP Server
3
+ * Provides tools for managing, analyzing, and exporting sessions
4
+ */
5
+ import { z } from "zod";
6
+ import { sessionLogger } from "./session-logger.js";
7
+ import { sessionManager } from "./session-manager.js";
8
+ // Define schemas for each tool's parameters
9
+ const ListSessionsSchema = z.object({
10
+ filter: z.string().optional().describe("Filter by mode, date, or query text"),
11
+ limit: z.number().optional().default(10).describe("Maximum number of sessions to return"),
12
+ sortBy: z.enum(["date", "duration", "steps", "mode"]).optional().default("date")
13
+ .describe("Sort criteria for results")
14
+ });
15
+ const ReplaySessionSchema = z.object({
16
+ sessionId: z.string().describe("Session ID or filename to replay"),
17
+ format: z.enum(["full", "summary"]).optional().default("full")
18
+ .describe("Output format - full shows all steps, summary shows key points")
19
+ });
20
+ const ExportSessionSchema = z.object({
21
+ sessionId: z.string().describe("Session ID to export"),
22
+ format: z.enum(["markdown", "json", "html", "pdf"])
23
+ .describe("Export format"),
24
+ outputPath: z.string().optional()
25
+ .describe("Custom output path (optional)")
26
+ });
27
+ const AnalyzeSessionsSchema = z.object({
28
+ dateRange: z.object({
29
+ start: z.string().describe("Start date (YYYY-MM-DD)"),
30
+ end: z.string().describe("End date (YYYY-MM-DD)")
31
+ }).optional().describe("Date range to analyze"),
32
+ mode: z.string().optional().describe("Filter by specific mode"),
33
+ metrics: z.array(z.enum([
34
+ "model-usage",
35
+ "response-time",
36
+ "token-usage",
37
+ "consensus-rate",
38
+ "topic-clustering"
39
+ ])).optional().default(["model-usage", "response-time", "consensus-rate"])
40
+ .describe("Metrics to calculate"),
41
+ exportReport: z.boolean().optional().default(false)
42
+ .describe("Export analytics report to file")
43
+ });
44
+ const FindSimilarSchema = z.object({
45
+ query: z.string().describe("Query to find similar sessions for"),
46
+ limit: z.number().optional().default(5)
47
+ .describe("Maximum number of similar sessions to return")
48
+ });
49
+ const RecommendSchema = z.object({
50
+ query: z.string().describe("Query to get recommendations for")
51
+ });
52
+ const ClearOldSessionsSchema = z.object({
53
+ daysToKeep: z.number().default(30)
54
+ .describe("Keep sessions from the last N days")
55
+ });
56
+ const SessionStatusSchema = z.object({});
57
+ /**
58
+ * Register all session-related tools with the MCP server
59
+ */
60
+ export function registerSessionTools(server) {
61
+ // List saved sessions
62
+ server.addTool({
63
+ name: "focus_list_sessions",
64
+ description: "List all saved Focus MCP brainstorming sessions with metadata",
65
+ parameters: ListSessionsSchema,
66
+ execute: async (args) => {
67
+ try {
68
+ const sessions = await sessionLogger.listSessions(args.filter, args.limit);
69
+ if (sessions.length === 0) {
70
+ return {
71
+ content: [{
72
+ type: "text",
73
+ text: "No sessions found matching the criteria."
74
+ }]
75
+ };
76
+ }
77
+ // Format sessions as a table
78
+ const lines = [
79
+ "# Focus MCP Sessions\n",
80
+ "| Date | Mode | Query | Session ID |",
81
+ "|------|------|-------|------------|"
82
+ ];
83
+ for (const session of sessions) {
84
+ const date = session.date.toISOString().split('T')[0];
85
+ const query = session.query.length > 50
86
+ ? session.query.substring(0, 47) + "..."
87
+ : session.query;
88
+ lines.push(`| ${date} | ${session.mode} | ${query} | ${session.id} |`);
89
+ }
90
+ lines.push(`\n**Total sessions found**: ${sessions.length}`);
91
+ return {
92
+ content: [{
93
+ type: "text",
94
+ text: lines.join("\n")
95
+ }]
96
+ };
97
+ }
98
+ catch (error) {
99
+ return {
100
+ content: [{
101
+ type: "text",
102
+ text: `Error listing sessions: ${error}`
103
+ }],
104
+ isError: true
105
+ };
106
+ }
107
+ }
108
+ });
109
+ // Replay a saved session
110
+ server.addTool({
111
+ name: "focus_replay_session",
112
+ description: "Replay a saved session to see all model responses and synthesis",
113
+ parameters: ReplaySessionSchema,
114
+ execute: async (args) => {
115
+ try {
116
+ const content = await sessionLogger.replaySession(args.sessionId, args.format);
117
+ return {
118
+ content: [{
119
+ type: "text",
120
+ text: content
121
+ }]
122
+ };
123
+ }
124
+ catch (error) {
125
+ return {
126
+ content: [{
127
+ type: "text",
128
+ text: `Error replaying session: ${error}`
129
+ }],
130
+ isError: true
131
+ };
132
+ }
133
+ }
134
+ });
135
+ // Export session in different format
136
+ server.addTool({
137
+ name: "focus_export_session",
138
+ description: "Export a session in different formats for sharing or archiving",
139
+ parameters: ExportSessionSchema,
140
+ execute: async (args) => {
141
+ try {
142
+ const filepath = await sessionLogger.exportSession(args.sessionId, args.format, args.outputPath);
143
+ return {
144
+ content: [{
145
+ type: "text",
146
+ text: `Session exported successfully to: ${filepath}`
147
+ }]
148
+ };
149
+ }
150
+ catch (error) {
151
+ return {
152
+ content: [{
153
+ type: "text",
154
+ text: `Error exporting session: ${error}`
155
+ }],
156
+ isError: true
157
+ };
158
+ }
159
+ }
160
+ });
161
+ // Analyze sessions for patterns and insights
162
+ server.addTool({
163
+ name: "focus_analyze_sessions",
164
+ description: "Analyze multiple sessions for patterns, model performance, and insights",
165
+ parameters: AnalyzeSessionsSchema,
166
+ execute: async (args) => {
167
+ try {
168
+ // Parse date range if provided
169
+ let dateRange;
170
+ if (args.dateRange) {
171
+ dateRange = {
172
+ start: new Date(args.dateRange.start),
173
+ end: new Date(args.dateRange.end)
174
+ };
175
+ }
176
+ // Analyze sessions
177
+ const analytics = await sessionManager.analyzeSessions(dateRange, args.mode, args.metrics);
178
+ // Format analytics report
179
+ const lines = [
180
+ "# Session Analytics Report\n",
181
+ "## Overview",
182
+ `- **Total Sessions**: ${analytics.totalSessions}`,
183
+ `- **Average Duration**: ${(analytics.averageDuration / 1000).toFixed(1)}s`,
184
+ `- **Average Steps**: ${analytics.averageSteps.toFixed(1)}`,
185
+ `- **Consensus Rate**: ${(analytics.consensusRate * 100).toFixed(1)}%\n`
186
+ ];
187
+ if (analytics.modelUsageStats.size > 0) {
188
+ lines.push("## Model Usage");
189
+ for (const [model, stats] of analytics.modelUsageStats.entries()) {
190
+ lines.push(`- **${model}**: ${stats.count} uses, ${(stats.averageDuration / 1000).toFixed(1)}s avg, ${stats.totalTokens} tokens`);
191
+ }
192
+ lines.push("");
193
+ }
194
+ if (analytics.topicClusters.length > 0) {
195
+ lines.push("## Topic Clusters");
196
+ for (const cluster of analytics.topicClusters) {
197
+ lines.push(`- **${cluster.topic}**: ${cluster.sessions.length} sessions`);
198
+ if (cluster.commonPatterns.length > 0) {
199
+ lines.push(` Patterns: ${cluster.commonPatterns.join(", ")}`);
200
+ }
201
+ }
202
+ lines.push("");
203
+ }
204
+ // Export if requested
205
+ if (args.exportReport) {
206
+ const filepath = await sessionManager.exportAnalyticsReport("markdown");
207
+ lines.push(`\n📊 Full report exported to: ${filepath}`);
208
+ }
209
+ return {
210
+ content: [{
211
+ type: "text",
212
+ text: lines.join("\n")
213
+ }]
214
+ };
215
+ }
216
+ catch (error) {
217
+ return {
218
+ content: [{
219
+ type: "text",
220
+ text: `Error analyzing sessions: ${error}`
221
+ }],
222
+ isError: true
223
+ };
224
+ }
225
+ }
226
+ });
227
+ // Find similar sessions
228
+ server.addTool({
229
+ name: "focus_find_similar",
230
+ description: "Find sessions similar to a given query for learning from past interactions",
231
+ parameters: FindSimilarSchema,
232
+ execute: async (args) => {
233
+ try {
234
+ const similar = await sessionManager.findSimilarSessions(args.query, args.limit);
235
+ if (similar.length === 0) {
236
+ return {
237
+ content: [{
238
+ type: "text",
239
+ text: "No similar sessions found."
240
+ }]
241
+ };
242
+ }
243
+ const lines = [
244
+ `# Similar Sessions for: "${args.query}"\n`
245
+ ];
246
+ for (const { session, similarity } of similar) {
247
+ lines.push(`## ${session.id}`);
248
+ lines.push(`- **Query**: ${session.query}`);
249
+ lines.push(`- **Mode**: ${session.mode}`);
250
+ lines.push(`- **Similarity**: ${(similarity * 100).toFixed(1)}%`);
251
+ lines.push(`- **Date**: ${session.timestamp}`);
252
+ if (session.synthesis) {
253
+ lines.push(`- **Key Insight**: ${session.synthesis.substring(0, 200)}${session.synthesis.length > 200 ? "..." : ""}`);
254
+ }
255
+ lines.push("");
256
+ }
257
+ return {
258
+ content: [{
259
+ type: "text",
260
+ text: lines.join("\n")
261
+ }]
262
+ };
263
+ }
264
+ catch (error) {
265
+ return {
266
+ content: [{
267
+ type: "text",
268
+ text: `Error finding similar sessions: ${error}`
269
+ }],
270
+ isError: true
271
+ };
272
+ }
273
+ }
274
+ });
275
+ // Get recommendations based on history
276
+ server.addTool({
277
+ name: "focus_recommend",
278
+ description: "Get mode and model recommendations based on session history",
279
+ parameters: RecommendSchema,
280
+ execute: async (args) => {
281
+ try {
282
+ const recommendations = await sessionManager.getRecommendations(args.query);
283
+ const lines = [
284
+ `# Recommendations for: "${args.query}"\n`,
285
+ `## Suggested Mode: **${recommendations.suggestedMode}**\n`
286
+ ];
287
+ if (recommendations.suggestedModels.length > 0) {
288
+ lines.push("## Suggested Models:");
289
+ for (const model of recommendations.suggestedModels) {
290
+ lines.push(`- ${model}`);
291
+ }
292
+ lines.push("");
293
+ }
294
+ if (recommendations.similarSessions.length > 0) {
295
+ lines.push("## Similar Past Sessions:");
296
+ for (const session of recommendations.similarSessions) {
297
+ lines.push(`- **${session.id}**`);
298
+ lines.push(` Query: "${session.query}"`);
299
+ lines.push(` Similarity: ${(session.similarity * 100).toFixed(1)}%`);
300
+ }
301
+ }
302
+ return {
303
+ content: [{
304
+ type: "text",
305
+ text: lines.join("\n")
306
+ }]
307
+ };
308
+ }
309
+ catch (error) {
310
+ return {
311
+ content: [{
312
+ type: "text",
313
+ text: `Error getting recommendations: ${error}`
314
+ }],
315
+ isError: true
316
+ };
317
+ }
318
+ }
319
+ });
320
+ // Clear old sessions
321
+ server.addTool({
322
+ name: "focus_clear_old_sessions",
323
+ description: "Clean up old session files to save disk space",
324
+ parameters: ClearOldSessionsSchema,
325
+ execute: async (args) => {
326
+ try {
327
+ const deletedCount = await sessionLogger.clearOldSessions(args.daysToKeep);
328
+ return {
329
+ content: [{
330
+ type: "text",
331
+ text: `Successfully deleted ${deletedCount} old session files (kept last ${args.daysToKeep} days).`
332
+ }]
333
+ };
334
+ }
335
+ catch (error) {
336
+ return {
337
+ content: [{
338
+ type: "text",
339
+ text: `Error clearing old sessions: ${error}`
340
+ }],
341
+ isError: true
342
+ };
343
+ }
344
+ }
345
+ });
346
+ // Get session status
347
+ server.addTool({
348
+ name: "focus_session_status",
349
+ description: "Get the status of the current active session",
350
+ parameters: SessionStatusSchema,
351
+ execute: async (args) => {
352
+ try {
353
+ const currentSession = sessionManager.getCurrentSession();
354
+ if (!currentSession) {
355
+ return {
356
+ content: [{
357
+ type: "text",
358
+ text: "No active session."
359
+ }]
360
+ };
361
+ }
362
+ const lines = [
363
+ "# Current Session Status\n",
364
+ `- **ID**: ${currentSession.id}`,
365
+ `- **Mode**: ${currentSession.mode}`,
366
+ `- **Query**: ${currentSession.query}`,
367
+ `- **Status**: ${currentSession.status}`,
368
+ `- **Steps Completed**: ${currentSession.steps.length}`,
369
+ `- **Started**: ${currentSession.timestamp}`
370
+ ];
371
+ if (currentSession.totalDuration) {
372
+ lines.push(`- **Duration**: ${(currentSession.totalDuration / 1000).toFixed(1)}s`);
373
+ }
374
+ if (currentSession.steps.length > 0) {
375
+ lines.push("\n## Recent Steps:");
376
+ const recentSteps = currentSession.steps.slice(-3);
377
+ for (const step of recentSteps) {
378
+ lines.push(`- Step ${step.stepNumber}: ${step.mode} (${step.model})`);
379
+ }
380
+ }
381
+ return {
382
+ content: [{
383
+ type: "text",
384
+ text: lines.join("\n")
385
+ }]
386
+ };
387
+ }
388
+ catch (error) {
389
+ return {
390
+ content: [{
391
+ type: "text",
392
+ text: `Error getting session status: ${error}`
393
+ }],
394
+ isError: true
395
+ };
396
+ }
397
+ }
398
+ });
399
+ console.error("✅ Session tools registered successfully");
400
+ }
@@ -0,0 +1,200 @@
1
+ import { z } from "zod";
2
+ import { Auditor } from "../modes/auditor.js";
3
+ import { CommitGuardian } from "../modes/commit-guardian.js";
4
+ import { Architect } from "../modes/architect.js";
5
+ import { CodeReviewer } from "../modes/code-reviewer.js";
6
+ import { DocumentationWriter } from "../modes/documentation-writer.js";
7
+ import { TestArchitect } from "../modes/test-architect.js";
8
+ // Workflow tools removed - using workflow-runner.ts instead
9
+ const auditor = new Auditor();
10
+ const commitGuardian = new CommitGuardian();
11
+ const architect = new Architect();
12
+ const codeReviewer = new CodeReviewer();
13
+ const documentationWriter = new DocumentationWriter();
14
+ const testArchitect = new TestArchitect();
15
+ // Auditor Tool
16
+ export const auditorTool = {
17
+ name: "auditor",
18
+ description: `Evidence-based audit`,
19
+ parameters: z.object({
20
+ context: z.string(),
21
+ evidenceRequired: z.boolean().optional()
22
+ }),
23
+ execute: async (args, { log }) => {
24
+ log.info("Starting audit");
25
+ const result = await auditor.audit(args.context, {
26
+ evidenceRequired: args.evidenceRequired
27
+ });
28
+ log.info("Audit complete", {
29
+ verified: result.verificationStatus.verified,
30
+ disputed: result.verificationStatus.disputed
31
+ });
32
+ return result.synthesis;
33
+ }
34
+ };
35
+ // Commit Guardian Tool
36
+ export const commitGuardianTool = {
37
+ name: "commit_guardian",
38
+ description: `Pre-commit validation`,
39
+ parameters: z.object({
40
+ context: z.string(),
41
+ strict: z.boolean().optional(),
42
+ checkSecurity: z.boolean().optional(),
43
+ checkQuality: z.boolean().optional(),
44
+ checkTests: z.boolean().optional()
45
+ }),
46
+ execute: async (args, { log }) => {
47
+ log.info("Validating commit");
48
+ const result = await commitGuardian.validate(args.context, {
49
+ strict: args.strict,
50
+ checkSecurity: args.checkSecurity,
51
+ checkQuality: args.checkQuality,
52
+ checkTests: args.checkTests
53
+ });
54
+ log.info("Validation complete", {
55
+ passed: result.passed,
56
+ score: result.score,
57
+ blockers: result.blockers.length
58
+ });
59
+ return result.summary;
60
+ }
61
+ };
62
+ // Architect Tool
63
+ export const architectTool = {
64
+ name: "architect",
65
+ description: `Full codebase analysis with Gemini 2.5 Pro (1M tokens) and specialized verification.
66
+
67
+ Parameters:
68
+ - query (required): What to analyze in the codebase
69
+ - path (optional): Path to codebase
70
+ - depth (optional, default: normal): shallow|normal|deep
71
+ - focusAreas (optional): Specific areas to focus on`,
72
+ parameters: z.object({
73
+ query: z.string(),
74
+ path: z.string().optional(),
75
+ depth: z.enum(["shallow", "normal", "deep"]).optional(),
76
+ focusAreas: z.array(z.string()).optional()
77
+ }),
78
+ execute: async (args, { log }) => {
79
+ log.info("Starting architecture analysis", {
80
+ depth: args.depth || "normal",
81
+ path: args.path
82
+ });
83
+ const result = await architect.analyze(args.query, {
84
+ path: args.path,
85
+ depth: args.depth,
86
+ focusAreas: args.focusAreas
87
+ });
88
+ log.info("Architecture analysis complete", {
89
+ hotspots: result.hotspots.length,
90
+ recommendations: result.recommendations.length,
91
+ tokensUsed: result.tokensUsed,
92
+ cost: result.cost
93
+ });
94
+ return result.synthesis;
95
+ }
96
+ };
97
+ // Workflow tools removed - handled by workflow-runner.ts
98
+ // Code Reviewer Tool
99
+ export const codeReviewerTool = {
100
+ name: "code_reviewer",
101
+ description: `Code review`,
102
+ parameters: z.object({
103
+ code: z.string(),
104
+ language: z.string().optional(),
105
+ focusAreas: z.array(z.enum(['security', 'performance', 'readability', 'bugs', 'best-practices'])).optional(),
106
+ severity: z.enum(['low', 'medium', 'high']).optional(),
107
+ model: z.string().optional()
108
+ }),
109
+ execute: async (args, { log }) => {
110
+ log.info("Starting code review", {
111
+ language: args.language || 'auto-detect',
112
+ focusAreas: args.focusAreas || 'all'
113
+ });
114
+ const result = await codeReviewer.review(args.code, {
115
+ language: args.language,
116
+ focusAreas: args.focusAreas,
117
+ severity: args.severity,
118
+ model: args.model
119
+ });
120
+ log.info("Code review complete", {
121
+ issuesFound: result.issues.length,
122
+ suggestions: result.suggestions.length,
123
+ maintainabilityScore: result.metrics.maintainabilityScore
124
+ });
125
+ return result.synthesis;
126
+ }
127
+ };
128
+ // Documentation Writer Tool
129
+ export const documentationWriterTool = {
130
+ name: "documentation_writer",
131
+ description: `Documentation generation`,
132
+ parameters: z.object({
133
+ code: z.string(),
134
+ style: z.enum(['narrative', 'technical', 'beginner-friendly', 'api-reference']).optional(),
135
+ includeExamples: z.boolean().optional(),
136
+ generateToc: z.boolean().optional(),
137
+ format: z.enum(['markdown', 'html', 'plain']).optional()
138
+ }),
139
+ execute: async (args, { log }) => {
140
+ log.info("Generating documentation", {
141
+ style: args.style || 'narrative',
142
+ format: args.format || 'markdown'
143
+ });
144
+ const result = await documentationWriter.generateDocs(args.code, {
145
+ style: args.style,
146
+ includeExamples: args.includeExamples,
147
+ generateToc: args.generateToc,
148
+ format: args.format
149
+ });
150
+ log.info("Documentation generation complete", {
151
+ readmeLength: result.readme.split('\n').length,
152
+ apiDocs: result.apiDocs.length,
153
+ inlineComments: result.inlineComments.length,
154
+ hasNarrativeDoc: !!result.narrativeDoc
155
+ });
156
+ return result.synthesis;
157
+ }
158
+ };
159
+ // Test Architect Tool
160
+ export const testArchitectTool = {
161
+ name: "test_architect",
162
+ description: `Test suite design`,
163
+ parameters: z.object({
164
+ code: z.string(),
165
+ testFramework: z.enum(['jest', 'mocha', 'vitest', 'cypress', 'playwright']).optional(),
166
+ testTypes: z.array(z.enum(['unit', 'integration', 'e2e', 'performance', 'security'])).optional(),
167
+ coverage: z.enum(['basic', 'thorough', 'comprehensive']).optional(),
168
+ generateMocks: z.boolean().optional()
169
+ }),
170
+ execute: async (args, { log }) => {
171
+ log.info("Architecting test suite", {
172
+ framework: args.testFramework || 'jest',
173
+ testTypes: args.testTypes || ['unit', 'integration', 'e2e'],
174
+ coverage: args.coverage || 'thorough'
175
+ });
176
+ const result = await testArchitect.architectTests(args.code, {
177
+ testFramework: args.testFramework,
178
+ testTypes: args.testTypes,
179
+ coverage: args.coverage,
180
+ generateMocks: args.generateMocks
181
+ });
182
+ log.info("Test architecture complete", {
183
+ totalTests: result.testSuite.totalTests,
184
+ testFiles: result.testFiles.length,
185
+ mockFiles: result.mockFiles.length,
186
+ estimatedCoverage: result.testSuite.estimatedCoverage,
187
+ edgeCases: result.edgeCases.length
188
+ });
189
+ return result.synthesis;
190
+ }
191
+ };
192
+ export function getAllAdvancedTools() {
193
+ // Scout, Verifier, Challenger have been migrated to system workflows
194
+ // See workflows/system/ for the new YAML-based implementations
195
+ return [];
196
+ }
197
+ // Check if advanced modes are available (always true for now)
198
+ export function areAdvancedModesAvailable() {
199
+ return true;
200
+ }