@nanocollective/nanocoder
Version:
A local-first CLI coding agent that brings the power of agentic coding tools like Claude Code and Gemini CLI to local models or controlled APIs like OpenRouter
89 lines • 3.46 kB
JavaScript
import { askQuestionTool } from '../tools/ask-question.js';
import { executeBashTool } from '../tools/execute-bash.js';
import { fetchUrlTool } from '../tools/fetch-url.js';
import { getFileOpTools } from '../tools/file-ops/index.js';
import { stringReplaceTool } from '../tools/file-ops/string-replace.js';
import { writeFileTool } from '../tools/file-ops/write-file.js';
import { findFilesTool } from '../tools/find-files.js';
import { getGitTools } from '../tools/git/index.js';
import { listDirectoryTool } from '../tools/list-directory.js';
import { getDiagnosticsTool } from '../tools/lsp-get-diagnostics.js';
import { readFileTool } from '../tools/read-file.js';
import { searchFileContentsTool } from '../tools/search-file-contents.js';
import { createTaskTool, deleteTaskTool, listTasksTool, updateTaskTool, } from '../tools/tasks/index.js';
import { webSearchTool } from '../tools/web-search.js';
// Static tools (always available)
const staticTools = [
readFileTool,
writeFileTool,
stringReplaceTool,
executeBashTool,
webSearchTool,
fetchUrlTool,
findFilesTool,
searchFileContentsTool,
getDiagnosticsTool,
listDirectoryTool,
// Interaction tools
askQuestionTool,
// File operation tools
...getFileOpTools(),
// Task management tools
createTaskTool,
listTasksTool,
updateTaskTool,
deleteTaskTool,
];
// Conditionally available tools (based on system capabilities)
// Git tools are only registered if git is installed
// PR tool additionally requires gh CLI
const conditionalTools = [...getGitTools()];
// Combine all tools
const allTools = [...staticTools, ...conditionalTools];
// Export native AI SDK tools registry (for passing directly to AI SDK)
export const nativeToolsRegistry = Object.fromEntries(allTools.map(t => [t.name, t.tool]));
// Export handlers for manual execution (human-in-the-loop)
// These are extracted from the AI SDK tools' execute functions
export const toolRegistry = Object.fromEntries(allTools.map(t => [
t.name,
// Extract the execute function from the AI SDK tool
// biome-ignore lint/suspicious/noExplicitAny: Dynamic typing required
async (args) => {
// Call the tool's execute function with a dummy options object
// The actual options will be provided by AI SDK during automatic execution
// biome-ignore lint/suspicious/noExplicitAny: Dynamic typing required
return await t.tool.execute(args, {
toolCallId: 'manual',
messages: [],
});
},
]));
// Export formatter registry for the UI
export const toolFormatters = allTools.reduce((acc, t) => {
if ('formatter' in t && t.formatter) {
acc[t.name] = t.formatter;
}
return acc;
}, {});
// Export validator registry
export const toolValidators = allTools.reduce((acc, t) => {
if ('validator' in t && t.validator) {
acc[t.name] = t.validator;
}
return acc;
}, {});
// Export readOnly flags for parallel execution safety
export const toolReadOnlyFlags = allTools.reduce((acc, t) => {
if (t.readOnly) {
acc[t.name] = true;
}
return acc;
}, {});
// Export streaming formatter registry for real-time progress tools
export const toolStreamingFormatters = allTools.reduce((acc, t) => {
if ('streamingFormatter' in t && t.streamingFormatter) {
acc[t.name] = t.streamingFormatter;
}
return acc;
}, {});
//# sourceMappingURL=index.js.map