hoomanjs 1.18.0 → 1.18.1
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.
- package/README.md +22 -26
- package/dist/acp/acp-agent.d.ts +69 -0
- package/dist/acp/acp-agent.js +628 -0
- package/dist/acp/acp-agent.js.map +1 -0
- package/dist/acp/approvals.d.ts +5 -0
- package/dist/acp/approvals.js +130 -0
- package/dist/acp/approvals.js.map +1 -0
- package/dist/acp/index.d.ts +1 -0
- package/dist/acp/index.js +2 -0
- package/dist/acp/index.js.map +1 -0
- package/dist/acp/mcp-servers.d.ts +7 -0
- package/dist/acp/mcp-servers.js +57 -0
- package/dist/acp/mcp-servers.js.map +1 -0
- package/dist/acp/meta/system-prompt.d.ts +12 -0
- package/dist/acp/meta/system-prompt.js +41 -0
- package/dist/acp/meta/system-prompt.js.map +1 -0
- package/dist/acp/meta/user-id.d.ts +12 -0
- package/dist/acp/meta/user-id.js +43 -0
- package/dist/acp/meta/user-id.js.map +1 -0
- package/dist/acp/prompt-invoke.d.ts +10 -0
- package/dist/acp/prompt-invoke.js +131 -0
- package/dist/acp/prompt-invoke.js.map +1 -0
- package/dist/acp/sessions/config-options.d.ts +7 -0
- package/dist/acp/sessions/config-options.js +101 -0
- package/dist/acp/sessions/config-options.js.map +1 -0
- package/dist/acp/sessions/replay.d.ts +7 -0
- package/dist/acp/sessions/replay.js +117 -0
- package/dist/acp/sessions/replay.js.map +1 -0
- package/dist/acp/sessions/store.d.ts +24 -0
- package/dist/acp/sessions/store.js +96 -0
- package/dist/acp/sessions/store.js.map +1 -0
- package/dist/acp/sessions/title.d.ts +5 -0
- package/dist/acp/sessions/title.js +22 -0
- package/dist/acp/sessions/title.js.map +1 -0
- package/dist/acp/utils/paths.d.ts +2 -0
- package/{src/acp/utils/paths.ts → dist/acp/utils/paths.js} +2 -2
- package/dist/acp/utils/paths.js.map +1 -0
- package/dist/acp/utils/tool-kind.d.ts +6 -0
- package/dist/acp/utils/tool-kind.js +53 -0
- package/dist/acp/utils/tool-kind.js.map +1 -0
- package/dist/acp/utils/tool-locations.d.ts +3 -0
- package/dist/acp/utils/tool-locations.js +44 -0
- package/dist/acp/utils/tool-locations.js.map +1 -0
- package/dist/acp/utils/tool-result-content.d.ts +8 -0
- package/dist/acp/utils/tool-result-content.js +14 -0
- package/dist/acp/utils/tool-result-content.js.map +1 -0
- package/dist/chat/app.d.ts +15 -0
- package/dist/chat/app.js +458 -0
- package/dist/chat/app.js.map +1 -0
- package/dist/chat/approvals.d.ts +15 -0
- package/dist/chat/approvals.js +74 -0
- package/dist/chat/approvals.js.map +1 -0
- package/dist/chat/components/ApprovalPrompt.d.ts +6 -0
- package/dist/chat/components/ApprovalPrompt.js +11 -0
- package/dist/chat/components/ApprovalPrompt.js.map +1 -0
- package/dist/chat/components/ChatMessage.d.ts +7 -0
- package/dist/chat/components/ChatMessage.js +19 -0
- package/dist/chat/components/ChatMessage.js.map +1 -0
- package/dist/chat/components/Composer.d.ts +11 -0
- package/dist/chat/components/Composer.js +9 -0
- package/dist/chat/components/Composer.js.map +1 -0
- package/dist/chat/components/EmptyChatBanner.d.ts +2 -0
- package/dist/chat/components/EmptyChatBanner.js +8 -0
- package/dist/chat/components/EmptyChatBanner.js.map +1 -0
- package/dist/chat/components/PromptInput.d.ts +11 -0
- package/dist/chat/components/PromptInput.js +26 -0
- package/dist/chat/components/PromptInput.js.map +1 -0
- package/dist/chat/components/QueuedPrompts.d.ts +10 -0
- package/dist/chat/components/QueuedPrompts.js +38 -0
- package/dist/chat/components/QueuedPrompts.js.map +1 -0
- package/dist/chat/components/ReasoningStrip.d.ts +6 -0
- package/dist/chat/components/ReasoningStrip.js +13 -0
- package/dist/chat/components/ReasoningStrip.js.map +1 -0
- package/dist/chat/components/ScrollView.d.ts +101 -0
- package/dist/chat/components/ScrollView.js +74 -0
- package/dist/chat/components/ScrollView.js.map +1 -0
- package/dist/chat/components/Spinner.d.ts +8 -0
- package/dist/chat/components/Spinner.js +19 -0
- package/dist/chat/components/Spinner.js.map +1 -0
- package/dist/chat/components/StatusBar.d.ts +20 -0
- package/dist/chat/components/StatusBar.js +20 -0
- package/dist/chat/components/StatusBar.js.map +1 -0
- package/dist/chat/components/ThinkingStatus.d.ts +1 -0
- package/dist/chat/components/ThinkingStatus.js +119 -0
- package/dist/chat/components/ThinkingStatus.js.map +1 -0
- package/dist/chat/components/TodoPanel.d.ts +6 -0
- package/dist/chat/components/TodoPanel.js +27 -0
- package/dist/chat/components/TodoPanel.js.map +1 -0
- package/dist/chat/components/ToolEvent.d.ts +6 -0
- package/dist/chat/components/ToolEvent.js +18 -0
- package/dist/chat/components/ToolEvent.js.map +1 -0
- package/dist/chat/components/ToolEventFileResult.d.ts +9 -0
- package/dist/chat/components/ToolEventFileResult.js +50 -0
- package/dist/chat/components/ToolEventFileResult.js.map +1 -0
- package/dist/chat/components/Transcript.d.ts +7 -0
- package/dist/chat/components/Transcript.js +9 -0
- package/dist/chat/components/Transcript.js.map +1 -0
- package/dist/chat/components/TranscriptViewport.d.ts +9 -0
- package/dist/chat/components/TranscriptViewport.js +124 -0
- package/dist/chat/components/TranscriptViewport.js.map +1 -0
- package/dist/chat/components/ascii-logo.d.ts +1 -0
- package/{src/chat/components/ascii-logo.ts → dist/chat/components/ascii-logo.js} +3 -2
- package/dist/chat/components/ascii-logo.js.map +1 -0
- package/dist/chat/components/file-tool-diff/file-tool-result.d.ts +26 -0
- package/dist/chat/components/file-tool-diff/file-tool-result.js +73 -0
- package/dist/chat/components/file-tool-diff/file-tool-result.js.map +1 -0
- package/dist/chat/components/markdown/BlockRenderer.d.ts +8 -0
- package/dist/chat/components/markdown/BlockRenderer.js +87 -0
- package/dist/chat/components/markdown/BlockRenderer.js.map +1 -0
- package/dist/chat/components/markdown/CodeBlock.d.ts +7 -0
- package/dist/chat/components/markdown/CodeBlock.js +55 -0
- package/dist/chat/components/markdown/CodeBlock.js.map +1 -0
- package/dist/chat/components/markdown/InlineRenderer.d.ts +8 -0
- package/dist/chat/components/markdown/InlineRenderer.js +96 -0
- package/dist/chat/components/markdown/InlineRenderer.js.map +1 -0
- package/dist/chat/components/markdown/MarkdownMessage.d.ts +6 -0
- package/dist/chat/components/markdown/MarkdownMessage.js +13 -0
- package/dist/chat/components/markdown/MarkdownMessage.js.map +1 -0
- package/dist/chat/components/markdown/MarkdownTable.d.ts +6 -0
- package/dist/chat/components/markdown/MarkdownTable.js +12 -0
- package/dist/chat/components/markdown/MarkdownTable.js.map +1 -0
- package/dist/chat/components/markdown/hooks/useMarkdownTableLayout.d.ts +7 -0
- package/dist/chat/components/markdown/hooks/useMarkdownTableLayout.js +186 -0
- package/dist/chat/components/markdown/hooks/useMarkdownTableLayout.js.map +1 -0
- package/dist/chat/components/markdown/hooks/useMarkdownTokens.d.ts +9 -0
- package/dist/chat/components/markdown/hooks/useMarkdownTokens.js +25 -0
- package/dist/chat/components/markdown/hooks/useMarkdownTokens.js.map +1 -0
- package/dist/chat/components/markdown/lexer.d.ts +7 -0
- package/dist/chat/components/markdown/lexer.js +89 -0
- package/dist/chat/components/markdown/lexer.js.map +1 -0
- package/dist/chat/components/prompt-input/clipboard-image.d.ts +1 -0
- package/dist/chat/components/prompt-input/clipboard-image.js +112 -0
- package/dist/chat/components/prompt-input/clipboard-image.js.map +1 -0
- package/dist/chat/components/prompt-input/hooks/usePromptInputController.d.ts +1 -0
- package/dist/chat/components/prompt-input/hooks/usePromptInputController.js +2 -0
- package/dist/chat/components/prompt-input/hooks/usePromptInputController.js.map +1 -0
- package/dist/chat/components/prompt-input/input-model.d.ts +28 -0
- package/dist/chat/components/prompt-input/input-model.js +231 -0
- package/dist/chat/components/prompt-input/input-model.js.map +1 -0
- package/dist/chat/components/prompt-input/paste.d.ts +11 -0
- package/dist/chat/components/prompt-input/paste.js +85 -0
- package/dist/chat/components/prompt-input/paste.js.map +1 -0
- package/dist/chat/components/prompt-input/render.d.ts +13 -0
- package/dist/chat/components/prompt-input/render.js +54 -0
- package/dist/chat/components/prompt-input/render.js.map +1 -0
- package/dist/chat/components/prompt-input/usePromptInputController.d.ts +17 -0
- package/dist/chat/components/prompt-input/usePromptInputController.js +366 -0
- package/dist/chat/components/prompt-input/usePromptInputController.js.map +1 -0
- package/dist/chat/components/shared.d.ts +6 -0
- package/dist/chat/components/shared.js +66 -0
- package/dist/chat/components/shared.js.map +1 -0
- package/dist/chat/index.d.ts +13 -0
- package/dist/chat/index.js +18 -0
- package/dist/chat/index.js.map +1 -0
- package/dist/chat/mouse.d.ts +5 -0
- package/dist/chat/mouse.js +9 -0
- package/dist/chat/mouse.js.map +1 -0
- package/dist/chat/types.d.ts +20 -0
- package/dist/chat/types.js +2 -0
- package/dist/chat/types.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +126 -0
- package/dist/cli.js.map +1 -0
- package/dist/configure/app.d.ts +3 -0
- package/dist/configure/app.js +1036 -0
- package/dist/configure/app.js.map +1 -0
- package/dist/configure/components/BusyScreen.d.ts +6 -0
- package/dist/configure/components/BusyScreen.js +7 -0
- package/dist/configure/components/BusyScreen.js.map +1 -0
- package/dist/configure/components/HomeScreen.d.ts +12 -0
- package/dist/configure/components/HomeScreen.js +7 -0
- package/dist/configure/components/HomeScreen.js.map +1 -0
- package/dist/configure/components/MenuScreen.d.ts +10 -0
- package/dist/configure/components/MenuScreen.js +15 -0
- package/dist/configure/components/MenuScreen.js.map +1 -0
- package/dist/configure/components/PromptForm.d.ts +8 -0
- package/dist/configure/components/PromptForm.js +12 -0
- package/dist/configure/components/PromptForm.js.map +1 -0
- package/dist/configure/components/SelectMenuItem.d.ts +7 -0
- package/dist/configure/components/SelectMenuItem.js +18 -0
- package/dist/configure/components/SelectMenuItem.js.map +1 -0
- package/dist/configure/index.d.ts +1 -0
- package/dist/configure/index.js +28 -0
- package/dist/configure/index.js.map +1 -0
- package/dist/configure/open-in-editor.d.ts +8 -0
- package/dist/configure/open-in-editor.js +120 -0
- package/dist/configure/open-in-editor.js.map +1 -0
- package/dist/configure/types.d.ts +63 -0
- package/dist/configure/types.js +2 -0
- package/dist/configure/types.js.map +1 -0
- package/dist/configure/utils.d.ts +19 -0
- package/dist/configure/utils.js +108 -0
- package/dist/configure/utils.js.map +1 -0
- package/dist/core/agent/index.d.ts +13 -0
- package/dist/core/agent/index.js +70 -0
- package/dist/core/agent/index.js.map +1 -0
- package/dist/core/agents/definitions.d.ts +12 -0
- package/dist/core/agents/definitions.js +35 -0
- package/dist/core/agents/definitions.js.map +1 -0
- package/dist/core/agents/index.d.ts +4 -0
- package/dist/core/agents/index.js +5 -0
- package/dist/core/agents/index.js.map +1 -0
- package/dist/core/agents/registry.d.ts +5 -0
- package/dist/core/agents/registry.js +84 -0
- package/dist/core/agents/registry.js.map +1 -0
- package/dist/core/agents/runner.d.ts +36 -0
- package/dist/core/agents/runner.js +275 -0
- package/dist/core/agents/runner.js.map +1 -0
- package/dist/core/agents/tools.d.ts +20 -0
- package/dist/core/agents/tools.js +66 -0
- package/dist/core/agents/tools.js.map +1 -0
- package/dist/core/config.d.ts +272 -0
- package/dist/core/config.js +334 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/index.d.ts +23 -0
- package/dist/core/index.js +21 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/mcp/config.d.ts +44 -0
- package/dist/core/mcp/config.js +65 -0
- package/dist/core/mcp/config.js.map +1 -0
- package/dist/core/mcp/index.d.ts +8 -0
- package/dist/core/mcp/index.js +12 -0
- package/dist/core/mcp/index.js.map +1 -0
- package/dist/core/mcp/manager.d.ts +69 -0
- package/dist/core/mcp/manager.js +376 -0
- package/dist/core/mcp/manager.js.map +1 -0
- package/dist/core/mcp/prefixed-mcp-tool.d.ts +14 -0
- package/dist/core/mcp/prefixed-mcp-tool.js +38 -0
- package/dist/core/mcp/prefixed-mcp-tool.js.map +1 -0
- package/dist/core/mcp/tools.d.ts +5 -0
- package/dist/core/mcp/tools.js +82 -0
- package/dist/core/mcp/tools.js.map +1 -0
- package/dist/core/mcp/types.d.ts +40 -0
- package/dist/core/mcp/types.js +28 -0
- package/dist/core/mcp/types.js.map +1 -0
- package/dist/core/memory/index.d.ts +3 -0
- package/dist/core/memory/index.js +3 -0
- package/dist/core/memory/index.js.map +1 -0
- package/dist/core/memory/ltm/embed.d.ts +16 -0
- package/dist/core/memory/ltm/embed.js +49 -0
- package/dist/core/memory/ltm/embed.js.map +1 -0
- package/dist/core/memory/ltm/index.d.ts +3 -0
- package/dist/core/memory/ltm/index.js +3 -0
- package/dist/core/memory/ltm/index.js.map +1 -0
- package/dist/core/memory/ltm/store.d.ts +20 -0
- package/dist/core/memory/ltm/store.js +271 -0
- package/dist/core/memory/ltm/store.js.map +1 -0
- package/dist/core/memory/ltm/tools.d.ts +21 -0
- package/dist/core/memory/ltm/tools.js +127 -0
- package/dist/core/memory/ltm/tools.js.map +1 -0
- package/dist/core/memory/ltm/types.d.ts +79 -0
- package/dist/core/memory/ltm/types.js +2 -0
- package/dist/core/memory/ltm/types.js.map +1 -0
- package/dist/core/memory/ltm/utils.d.ts +40 -0
- package/dist/core/memory/ltm/utils.js +145 -0
- package/dist/core/memory/ltm/utils.js.map +1 -0
- package/dist/core/memory/stm/flat-file-storage.d.ts +27 -0
- package/dist/core/memory/stm/flat-file-storage.js +63 -0
- package/dist/core/memory/stm/flat-file-storage.js.map +1 -0
- package/dist/core/memory/stm/index.d.ts +13 -0
- package/dist/core/memory/stm/index.js +24 -0
- package/dist/core/memory/stm/index.js.map +1 -0
- package/dist/core/memory/stm/lazy-session-manager.d.ts +37 -0
- package/dist/core/memory/stm/lazy-session-manager.js +163 -0
- package/dist/core/memory/stm/lazy-session-manager.js.map +1 -0
- package/dist/core/models/anthropic.d.ts +10 -0
- package/dist/core/models/anthropic.js +38 -0
- package/dist/core/models/anthropic.js.map +1 -0
- package/dist/core/models/bedrock.d.ts +21 -0
- package/dist/core/models/bedrock.js +24 -0
- package/dist/core/models/bedrock.js.map +1 -0
- package/dist/core/models/google.d.ts +10 -0
- package/dist/core/models/google.js +36 -0
- package/dist/core/models/google.js.map +1 -0
- package/dist/core/models/groq.d.ts +10 -0
- package/dist/core/models/groq.js +33 -0
- package/dist/core/models/groq.js.map +1 -0
- package/dist/core/models/index.d.ts +5 -0
- package/dist/core/models/index.js +11 -0
- package/dist/core/models/index.js.map +1 -0
- package/dist/core/models/moonshot.d.ts +11 -0
- package/dist/core/models/moonshot.js +39 -0
- package/dist/core/models/moonshot.js.map +1 -0
- package/dist/core/models/ollama/index.d.ts +3 -0
- package/dist/core/models/ollama/index.js +9 -0
- package/dist/core/models/ollama/index.js.map +1 -0
- package/dist/core/models/ollama/strands-ollama.d.ts +30 -0
- package/dist/core/models/ollama/strands-ollama.js +336 -0
- package/dist/core/models/ollama/strands-ollama.js.map +1 -0
- package/dist/core/models/openai.d.ts +4 -0
- package/dist/core/models/openai.js +9 -0
- package/dist/core/models/openai.js.map +1 -0
- package/dist/core/models/xai.d.ts +10 -0
- package/dist/core/models/xai.js +33 -0
- package/dist/core/models/xai.js.map +1 -0
- package/dist/core/prompts/environment.d.ts +11 -0
- package/dist/core/prompts/environment.js +51 -0
- package/dist/core/prompts/environment.js.map +1 -0
- package/dist/core/prompts/index.d.ts +7 -0
- package/dist/core/prompts/index.js +14 -0
- package/dist/core/prompts/index.js.map +1 -0
- package/dist/core/prompts/skills.d.ts +15 -0
- package/dist/core/prompts/skills.js +86 -0
- package/dist/core/prompts/skills.js.map +1 -0
- package/dist/core/prompts/system.d.ts +22 -0
- package/dist/core/prompts/system.js +164 -0
- package/dist/core/prompts/system.js.map +1 -0
- package/dist/core/skills/built-in/hooman-config/SKILL.md +9 -0
- package/dist/core/skills/index.d.ts +2 -0
- package/dist/core/skills/index.js +3 -0
- package/dist/core/skills/index.js.map +1 -0
- package/dist/core/skills/metadata.d.ts +8 -0
- package/dist/core/skills/metadata.js +20 -0
- package/dist/core/skills/metadata.js.map +1 -0
- package/dist/core/skills/registry.d.ts +38 -0
- package/dist/core/skills/registry.js +165 -0
- package/dist/core/skills/registry.js.map +1 -0
- package/dist/core/skills/tools.d.ts +9 -0
- package/dist/core/skills/tools.js +73 -0
- package/dist/core/skills/tools.js.map +1 -0
- package/dist/core/state/file-tool-display.d.ts +20 -0
- package/dist/core/state/file-tool-display.js +35 -0
- package/dist/core/state/file-tool-display.js.map +1 -0
- package/dist/core/state/thought-process.d.ts +18 -0
- package/dist/core/state/thought-process.js +21 -0
- package/dist/core/state/thought-process.js.map +1 -0
- package/dist/core/state/todos.d.ts +39 -0
- package/dist/core/state/todos.js +53 -0
- package/dist/core/state/todos.js.map +1 -0
- package/dist/core/state/tool-approvals.d.ts +12 -0
- package/dist/core/state/tool-approvals.js +81 -0
- package/dist/core/state/tool-approvals.js.map +1 -0
- package/dist/core/tools/fetch.d.ts +9 -0
- package/dist/core/tools/fetch.js +228 -0
- package/dist/core/tools/fetch.js.map +1 -0
- package/dist/core/tools/filesystem.d.ts +35 -0
- package/dist/core/tools/filesystem.js +791 -0
- package/dist/core/tools/filesystem.js.map +1 -0
- package/dist/core/tools/index.d.ts +9 -0
- package/dist/core/tools/index.js +10 -0
- package/dist/core/tools/index.js.map +1 -0
- package/dist/core/tools/shell.d.ts +18 -0
- package/dist/core/tools/shell.js +308 -0
- package/dist/core/tools/shell.js.map +1 -0
- package/dist/core/tools/sleep.d.ts +4 -0
- package/dist/core/tools/sleep.js +46 -0
- package/dist/core/tools/sleep.js.map +1 -0
- package/dist/core/tools/thinking.d.ts +12 -0
- package/dist/core/tools/thinking.js +119 -0
- package/dist/core/tools/thinking.js.map +1 -0
- package/dist/core/tools/time.d.ts +8 -0
- package/dist/core/tools/time.js +94 -0
- package/dist/core/tools/time.js.map +1 -0
- package/dist/core/tools/todo.d.ts +9 -0
- package/dist/core/tools/todo.js +33 -0
- package/dist/core/tools/todo.js.map +1 -0
- package/dist/core/tools/web-search.d.ts +11 -0
- package/dist/core/tools/web-search.js +211 -0
- package/dist/core/tools/web-search.js.map +1 -0
- package/dist/core/tools/wiki.d.ts +11 -0
- package/dist/core/tools/wiki.js +566 -0
- package/dist/core/tools/wiki.js.map +1 -0
- package/dist/core/utils/attachments.d.ts +23 -0
- package/dist/core/utils/attachments.js +125 -0
- package/dist/core/utils/attachments.js.map +1 -0
- package/dist/core/utils/cwd-context.d.ts +2 -0
- package/dist/core/utils/cwd-context.js +9 -0
- package/dist/core/utils/cwd-context.js.map +1 -0
- package/dist/core/utils/file-formats.d.ts +4 -0
- package/dist/core/utils/file-formats.js +48 -0
- package/dist/core/utils/file-formats.js.map +1 -0
- package/dist/core/utils/paths.d.ts +7 -0
- package/dist/core/utils/paths.js +25 -0
- package/dist/core/utils/paths.js.map +1 -0
- package/dist/daemon/approvals.d.ts +5 -0
- package/dist/daemon/approvals.js +95 -0
- package/dist/daemon/approvals.js.map +1 -0
- package/dist/daemon/index.d.ts +11 -0
- package/dist/daemon/index.js +106 -0
- package/dist/daemon/index.js.map +1 -0
- package/dist/daemon/queue.d.ts +5 -0
- package/dist/daemon/queue.js +38 -0
- package/dist/daemon/queue.js.map +1 -0
- package/dist/exec/approvals.d.ts +6 -0
- package/dist/exec/approvals.js +74 -0
- package/dist/exec/approvals.js.map +1 -0
- package/package.json +20 -9
- package/.github/screenshot.png +0 -0
- package/.github/workflows/build-publish.yml +0 -49
- package/docker-compose.yml +0 -13
- package/src/acp/acp-agent.ts +0 -814
- package/src/acp/approvals.ts +0 -146
- package/src/acp/index.ts +0 -1
- package/src/acp/mcp-servers.ts +0 -64
- package/src/acp/meta/system-prompt.ts +0 -44
- package/src/acp/meta/user-id.ts +0 -44
- package/src/acp/prompt-invoke.ts +0 -149
- package/src/acp/sessions/config-options.ts +0 -120
- package/src/acp/sessions/replay.ts +0 -131
- package/src/acp/sessions/store.ts +0 -161
- package/src/acp/sessions/title.ts +0 -22
- package/src/acp/utils/tool-kind.ts +0 -61
- package/src/acp/utils/tool-locations.ts +0 -48
- package/src/acp/utils/tool-result-content.ts +0 -27
- package/src/chat/app.tsx +0 -636
- package/src/chat/approvals.ts +0 -97
- package/src/chat/components/ApprovalPrompt.tsx +0 -25
- package/src/chat/components/ChatMessage.tsx +0 -50
- package/src/chat/components/Composer.tsx +0 -45
- package/src/chat/components/EmptyChatBanner.tsx +0 -26
- package/src/chat/components/PromptInput.tsx +0 -62
- package/src/chat/components/QueuedPrompts.tsx +0 -76
- package/src/chat/components/ReasoningStrip.tsx +0 -30
- package/src/chat/components/Spinner.tsx +0 -34
- package/src/chat/components/StatusBar.tsx +0 -67
- package/src/chat/components/ThinkingStatus.tsx +0 -128
- package/src/chat/components/TodoPanel.tsx +0 -49
- package/src/chat/components/ToolEvent.tsx +0 -41
- package/src/chat/components/ToolEventFileResult.tsx +0 -116
- package/src/chat/components/Transcript.tsx +0 -34
- package/src/chat/components/TranscriptViewport.tsx +0 -170
- package/src/chat/components/file-tool-diff/file-tool-result.ts +0 -155
- package/src/chat/components/markdown/BlockRenderer.tsx +0 -207
- package/src/chat/components/markdown/CodeBlock.tsx +0 -100
- package/src/chat/components/markdown/InlineRenderer.tsx +0 -122
- package/src/chat/components/markdown/MarkdownMessage.tsx +0 -35
- package/src/chat/components/markdown/MarkdownTable.tsx +0 -23
- package/src/chat/components/markdown/hooks/useMarkdownTableLayout.ts +0 -242
- package/src/chat/components/markdown/hooks/useMarkdownTokens.ts +0 -46
- package/src/chat/components/markdown/lexer.ts +0 -100
- package/src/chat/components/prompt-input/clipboard-image.ts +0 -119
- package/src/chat/components/prompt-input/hooks/usePromptInputController.ts +0 -4
- package/src/chat/components/prompt-input/input-model.ts +0 -294
- package/src/chat/components/prompt-input/paste.ts +0 -105
- package/src/chat/components/prompt-input/render.ts +0 -83
- package/src/chat/components/prompt-input/usePromptInputController.ts +0 -498
- package/src/chat/components/shared.ts +0 -70
- package/src/chat/index.tsx +0 -41
- package/src/chat/mouse.ts +0 -17
- package/src/chat/types.ts +0 -24
- package/src/cli.ts +0 -181
- package/src/configure/app.tsx +0 -1349
- package/src/configure/components/BusyScreen.tsx +0 -22
- package/src/configure/components/HomeScreen.tsx +0 -43
- package/src/configure/components/MenuScreen.tsx +0 -44
- package/src/configure/components/PromptForm.tsx +0 -40
- package/src/configure/components/SelectMenuItem.tsx +0 -30
- package/src/configure/index.tsx +0 -43
- package/src/configure/open-in-editor.ts +0 -133
- package/src/configure/types.ts +0 -51
- package/src/configure/utils.ts +0 -134
- package/src/core/agent/index.ts +0 -108
- package/src/core/agents/definitions.ts +0 -48
- package/src/core/agents/index.ts +0 -15
- package/src/core/agents/registry.ts +0 -106
- package/src/core/agents/runner.ts +0 -375
- package/src/core/agents/tools.ts +0 -100
- package/src/core/config.ts +0 -377
- package/src/core/index.ts +0 -60
- package/src/core/mcp/config.ts +0 -80
- package/src/core/mcp/index.ts +0 -33
- package/src/core/mcp/manager.ts +0 -491
- package/src/core/mcp/prefixed-mcp-tool.ts +0 -45
- package/src/core/mcp/tools.ts +0 -92
- package/src/core/mcp/types.ts +0 -37
- package/src/core/memory/index.ts +0 -17
- package/src/core/memory/ltm/embed.ts +0 -67
- package/src/core/memory/ltm/index.ts +0 -18
- package/src/core/memory/ltm/store.ts +0 -376
- package/src/core/memory/ltm/tools.ts +0 -146
- package/src/core/memory/ltm/types.ts +0 -111
- package/src/core/memory/ltm/utils.ts +0 -218
- package/src/core/memory/stm/flat-file-storage.ts +0 -89
- package/src/core/memory/stm/index.ts +0 -32
- package/src/core/memory/stm/lazy-session-manager.ts +0 -220
- package/src/core/models/anthropic.ts +0 -53
- package/src/core/models/bedrock.ts +0 -54
- package/src/core/models/google.ts +0 -51
- package/src/core/models/groq.ts +0 -48
- package/src/core/models/index.ts +0 -19
- package/src/core/models/moonshot.ts +0 -54
- package/src/core/models/ollama/index.ts +0 -13
- package/src/core/models/ollama/strands-ollama.ts +0 -439
- package/src/core/models/openai.ts +0 -12
- package/src/core/models/xai.ts +0 -47
- package/src/core/prompts/environment.ts +0 -71
- package/src/core/prompts/index.ts +0 -22
- package/src/core/prompts/skills.ts +0 -66
- package/src/core/prompts/system.ts +0 -183
- package/src/core/skills/index.ts +0 -2
- package/src/core/skills/registry.ts +0 -239
- package/src/core/skills/tools.ts +0 -80
- package/src/core/state/file-tool-display.ts +0 -70
- package/src/core/state/thought-process.ts +0 -49
- package/src/core/state/todos.ts +0 -84
- package/src/core/state/tool-approvals.ts +0 -100
- package/src/core/tools/fetch.ts +0 -288
- package/src/core/tools/filesystem.ts +0 -1105
- package/src/core/tools/index.ts +0 -9
- package/src/core/tools/shell.ts +0 -426
- package/src/core/tools/sleep.ts +0 -51
- package/src/core/tools/thinking.ts +0 -149
- package/src/core/tools/time.ts +0 -121
- package/src/core/tools/todo.ts +0 -44
- package/src/core/tools/web-search.ts +0 -278
- package/src/core/tools/wiki.ts +0 -703
- package/src/core/utils/attachments.ts +0 -201
- package/src/core/utils/cwd-context.ts +0 -11
- package/src/core/utils/file-formats.ts +0 -60
- package/src/core/utils/paths.ts +0 -37
- package/src/daemon/approvals.ts +0 -127
- package/src/daemon/index.ts +0 -153
- package/src/daemon/queue.ts +0 -48
- package/src/exec/approvals.ts +0 -90
- package/tsconfig.json +0 -30
- /package/{src → dist}/core/prompts/agents/plan.md +0 -0
- /package/{src → dist}/core/prompts/agents/research.md +0 -0
- /package/{src → dist}/core/prompts/harness/behaviour.md +0 -0
- /package/{src → dist}/core/prompts/harness/communication.md +0 -0
- /package/{src → dist}/core/prompts/harness/engineering.md +0 -0
- /package/{src → dist}/core/prompts/harness/execution.md +0 -0
- /package/{src → dist}/core/prompts/harness/guardrails.md +0 -0
- /package/{src → dist}/core/prompts/static/daemon.md +0 -0
- /package/{src → dist}/core/prompts/static/environment.md +0 -0
- /package/{src → dist}/core/prompts/static/fetch.md +0 -0
- /package/{src → dist}/core/prompts/static/filesystem.md +0 -0
- /package/{src → dist}/core/prompts/static/identity.md +0 -0
- /package/{src → dist}/core/prompts/static/ltm.md +0 -0
- /package/{src → dist}/core/prompts/static/shell.md +0 -0
- /package/{src → dist}/core/prompts/static/skills.md +0 -0
- /package/{src → dist}/core/prompts/static/sleep.md +0 -0
- /package/{src → dist}/core/prompts/static/subagents.md +0 -0
- /package/{src → dist}/core/prompts/static/thinking.md +0 -0
- /package/{src → dist}/core/prompts/static/todo.md +0 -0
- /package/{src → dist}/core/prompts/static/web-search.md +0 -0
- /package/{src → dist}/core/prompts/static/wiki.md +0 -0
package/src/core/tools/wiki.ts
DELETED
|
@@ -1,703 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs/promises";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { ChromaClient } from "chromadb";
|
|
4
|
-
import matter from "gray-matter";
|
|
5
|
-
import { tool } from "@strands-agents/sdk";
|
|
6
|
-
import type { JSONValue } from "@strands-agents/sdk";
|
|
7
|
-
import { z } from "zod";
|
|
8
|
-
import type { Config } from "../config.ts";
|
|
9
|
-
import { HFEmbedding } from "../memory/ltm/embed.ts";
|
|
10
|
-
import { chromaClientArgsFromUrl } from "../memory/ltm/utils.ts";
|
|
11
|
-
import { getCwd } from "../utils/cwd-context.ts";
|
|
12
|
-
|
|
13
|
-
const WIKI_DIR = "wiki";
|
|
14
|
-
const PAGES_DIR = "pages";
|
|
15
|
-
const INDEX_FILE = "index.md";
|
|
16
|
-
const LOG_FILE = "log.md";
|
|
17
|
-
const SCHEMA_FILE = "schema.md";
|
|
18
|
-
const DEFAULT_SEARCH_LIMIT = 5;
|
|
19
|
-
const MAX_SEARCH_LIMIT = 20;
|
|
20
|
-
|
|
21
|
-
type PageFrontmatter = {
|
|
22
|
-
title?: string;
|
|
23
|
-
summary?: string;
|
|
24
|
-
tags?: string[];
|
|
25
|
-
related?: string[];
|
|
26
|
-
type?: string;
|
|
27
|
-
created?: string;
|
|
28
|
-
updated?: string;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
type PageRecord = {
|
|
32
|
-
path: string;
|
|
33
|
-
absolutePath: string;
|
|
34
|
-
title: string;
|
|
35
|
-
summary: string;
|
|
36
|
-
tags: string[];
|
|
37
|
-
related: string[];
|
|
38
|
-
type: string | null;
|
|
39
|
-
created: string | null;
|
|
40
|
-
updated: string | null;
|
|
41
|
-
wordCount: number;
|
|
42
|
-
mtime: string;
|
|
43
|
-
content: string;
|
|
44
|
-
body: string;
|
|
45
|
-
frontmatter: PageFrontmatter;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
type Collection = Awaited<ReturnType<ChromaClient["getOrCreateCollection"]>>;
|
|
49
|
-
|
|
50
|
-
function toJsonValue(value: unknown): JSONValue {
|
|
51
|
-
return JSON.parse(JSON.stringify(value)) as JSONValue;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function wikiRoot(): string {
|
|
55
|
-
return path.join(getCwd(), WIKI_DIR);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function stripLeadingSlashes(value: string): string {
|
|
59
|
-
return value.replace(/^[/\\]+/, "");
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function pageRelativePath(inputPath: string): string {
|
|
63
|
-
const normalized = stripLeadingSlashes(inputPath.trim().replace(/\\/g, "/"));
|
|
64
|
-
if (!normalized) {
|
|
65
|
-
throw new Error("Page path is required.");
|
|
66
|
-
}
|
|
67
|
-
const withPrefix = normalized.startsWith(`${PAGES_DIR}/`)
|
|
68
|
-
? normalized
|
|
69
|
-
: `${PAGES_DIR}/${normalized}`;
|
|
70
|
-
if (!withPrefix.toLowerCase().endsWith(".md")) {
|
|
71
|
-
throw new Error("Page paths must end with .md");
|
|
72
|
-
}
|
|
73
|
-
return withPrefix;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function resolveWithinRoot(root: string, relativePath: string): string {
|
|
77
|
-
const abs = path.resolve(root, relativePath);
|
|
78
|
-
const normalizedRoot = path.resolve(root);
|
|
79
|
-
if (
|
|
80
|
-
abs !== normalizedRoot &&
|
|
81
|
-
!abs.startsWith(`${normalizedRoot}${path.sep}`) &&
|
|
82
|
-
!(
|
|
83
|
-
process.platform === "win32" &&
|
|
84
|
-
abs.toLowerCase().startsWith(`${normalizedRoot.toLowerCase()}${path.sep}`)
|
|
85
|
-
)
|
|
86
|
-
) {
|
|
87
|
-
throw new Error(`Path escapes wiki root: ${relativePath}`);
|
|
88
|
-
}
|
|
89
|
-
return abs;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
async function fileExists(filePath: string): Promise<boolean> {
|
|
93
|
-
try {
|
|
94
|
-
await fs.access(filePath);
|
|
95
|
-
return true;
|
|
96
|
-
} catch {
|
|
97
|
-
return false;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function firstSentence(value: string, maxLength: number = 180): string {
|
|
102
|
-
const clean = value.replace(/\s+/g, " ").trim();
|
|
103
|
-
if (!clean) {
|
|
104
|
-
return "";
|
|
105
|
-
}
|
|
106
|
-
return clean.length > maxLength
|
|
107
|
-
? `${clean.slice(0, maxLength - 1).trimEnd()}…`
|
|
108
|
-
: clean;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function safeString(value: unknown): string | null {
|
|
112
|
-
return typeof value === "string" && value.trim().length > 0
|
|
113
|
-
? value.trim()
|
|
114
|
-
: null;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function safeStringArray(value: unknown): string[] {
|
|
118
|
-
if (!Array.isArray(value)) {
|
|
119
|
-
return [];
|
|
120
|
-
}
|
|
121
|
-
return value
|
|
122
|
-
.filter((item): item is string => typeof item === "string")
|
|
123
|
-
.map((item) => item.trim())
|
|
124
|
-
.filter((item) => item.length > 0);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function parseFrontmatter(content: string): {
|
|
128
|
-
frontmatter: PageFrontmatter;
|
|
129
|
-
body: string;
|
|
130
|
-
} {
|
|
131
|
-
const parsed = matter(content);
|
|
132
|
-
const data = parsed.data as Record<string, unknown>;
|
|
133
|
-
return {
|
|
134
|
-
frontmatter: {
|
|
135
|
-
title: safeString(data.title) ?? undefined,
|
|
136
|
-
summary: safeString(data.summary) ?? undefined,
|
|
137
|
-
tags: safeStringArray(data.tags),
|
|
138
|
-
related: safeStringArray(data.related),
|
|
139
|
-
type: safeString(data.type) ?? undefined,
|
|
140
|
-
created: safeString(data.created) ?? undefined,
|
|
141
|
-
updated: safeString(data.updated) ?? undefined,
|
|
142
|
-
},
|
|
143
|
-
body: parsed.content.trim(),
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
function wordCount(content: string): number {
|
|
148
|
-
const words = content.trim().match(/\S+/g);
|
|
149
|
-
return words ? words.length : 0;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
function normalizeRelatedPath(value: string): string {
|
|
153
|
-
let item = value.trim().replace(/\\/g, "/");
|
|
154
|
-
item = item.replace(/^\[\[|\]\]$/g, "");
|
|
155
|
-
item = stripLeadingSlashes(item);
|
|
156
|
-
if (!item.endsWith(".md")) {
|
|
157
|
-
item = `${item}.md`;
|
|
158
|
-
}
|
|
159
|
-
if (!item.startsWith(`${PAGES_DIR}/`)) {
|
|
160
|
-
item = `${PAGES_DIR}/${item}`;
|
|
161
|
-
}
|
|
162
|
-
return item;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
function deriveTitle(
|
|
166
|
-
relativePath: string,
|
|
167
|
-
frontmatter: PageFrontmatter,
|
|
168
|
-
): string {
|
|
169
|
-
const fromFrontmatter = safeString(frontmatter.title);
|
|
170
|
-
if (fromFrontmatter) {
|
|
171
|
-
return fromFrontmatter;
|
|
172
|
-
}
|
|
173
|
-
return path.basename(relativePath, ".md").replace(/[-_]+/g, " ").trim();
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
function deriveSummary(
|
|
177
|
-
frontmatter: PageFrontmatter,
|
|
178
|
-
body: string,
|
|
179
|
-
fallback: string,
|
|
180
|
-
): string {
|
|
181
|
-
const fromFrontmatter = safeString(frontmatter.summary);
|
|
182
|
-
if (fromFrontmatter) {
|
|
183
|
-
return firstSentence(fromFrontmatter);
|
|
184
|
-
}
|
|
185
|
-
const bodySummary = firstSentence(body);
|
|
186
|
-
return bodySummary || firstSentence(fallback) || "No summary available.";
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
async function readPageRecord(
|
|
190
|
-
root: string,
|
|
191
|
-
relativePath: string,
|
|
192
|
-
): Promise<PageRecord> {
|
|
193
|
-
const absolutePath = resolveWithinRoot(root, relativePath);
|
|
194
|
-
const content = await fs.readFile(absolutePath, "utf8");
|
|
195
|
-
const stat = await fs.stat(absolutePath);
|
|
196
|
-
const parsed = parseFrontmatter(content);
|
|
197
|
-
const title = deriveTitle(relativePath, parsed.frontmatter);
|
|
198
|
-
const summary = deriveSummary(parsed.frontmatter, parsed.body, title);
|
|
199
|
-
return {
|
|
200
|
-
path: relativePath.replace(/\\/g, "/"),
|
|
201
|
-
absolutePath,
|
|
202
|
-
title,
|
|
203
|
-
summary,
|
|
204
|
-
tags: parsed.frontmatter.tags ?? [],
|
|
205
|
-
related: (parsed.frontmatter.related ?? []).map(normalizeRelatedPath),
|
|
206
|
-
type: parsed.frontmatter.type ?? null,
|
|
207
|
-
created: parsed.frontmatter.created ?? null,
|
|
208
|
-
updated: parsed.frontmatter.updated ?? null,
|
|
209
|
-
wordCount: wordCount(parsed.body),
|
|
210
|
-
mtime: stat.mtime.toISOString(),
|
|
211
|
-
content,
|
|
212
|
-
body: parsed.body,
|
|
213
|
-
frontmatter: parsed.frontmatter,
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
async function listPagePaths(root: string): Promise<string[]> {
|
|
218
|
-
const pagesRoot = resolveWithinRoot(root, PAGES_DIR);
|
|
219
|
-
const out: string[] = [];
|
|
220
|
-
|
|
221
|
-
const walk = async (dirPath: string): Promise<void> => {
|
|
222
|
-
const entries = await fs.readdir(dirPath, { withFileTypes: true });
|
|
223
|
-
for (const entry of entries) {
|
|
224
|
-
const fullPath = path.join(dirPath, entry.name);
|
|
225
|
-
if (entry.isDirectory()) {
|
|
226
|
-
await walk(fullPath);
|
|
227
|
-
continue;
|
|
228
|
-
}
|
|
229
|
-
if (!entry.isFile() || !entry.name.toLowerCase().endsWith(".md")) {
|
|
230
|
-
continue;
|
|
231
|
-
}
|
|
232
|
-
const relFromRoot = path.relative(root, fullPath).replace(/\\/g, "/");
|
|
233
|
-
out.push(relFromRoot);
|
|
234
|
-
}
|
|
235
|
-
};
|
|
236
|
-
|
|
237
|
-
if (await fileExists(pagesRoot)) {
|
|
238
|
-
await walk(pagesRoot);
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
out.sort((a, b) => a.localeCompare(b));
|
|
242
|
-
return out;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
async function listPages(root: string): Promise<PageRecord[]> {
|
|
246
|
-
const paths = await listPagePaths(root);
|
|
247
|
-
return Promise.all(
|
|
248
|
-
paths.map((relativePath) => readPageRecord(root, relativePath)),
|
|
249
|
-
);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
function buildIndexMarkdown(pages: PageRecord[]): string {
|
|
253
|
-
const sorted = [...pages].sort((a, b) => a.title.localeCompare(b.title));
|
|
254
|
-
const lines: string[] = [
|
|
255
|
-
"# Wiki Index",
|
|
256
|
-
"",
|
|
257
|
-
"<!-- Auto-generated by wiki_write_file. -->",
|
|
258
|
-
"",
|
|
259
|
-
`Updated: ${new Date().toISOString()}`,
|
|
260
|
-
"",
|
|
261
|
-
"## Pages",
|
|
262
|
-
];
|
|
263
|
-
|
|
264
|
-
if (sorted.length === 0) {
|
|
265
|
-
lines.push("- _No wiki pages yet._");
|
|
266
|
-
return `${lines.join("\n")}\n`;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
for (const page of sorted) {
|
|
270
|
-
const tags = page.tags.length > 0 ? ` | tags: ${page.tags.join(", ")}` : "";
|
|
271
|
-
lines.push(`- [${page.title}](${page.path}): ${page.summary}${tags}`);
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
return `${lines.join("\n")}\n`;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
function buildLogEntry(
|
|
278
|
-
operation: string,
|
|
279
|
-
details: Record<string, string>,
|
|
280
|
-
): string {
|
|
281
|
-
const lines: string[] = [
|
|
282
|
-
`## [${new Date().toISOString()}] ${operation}`,
|
|
283
|
-
...Object.entries(details).map(([key, value]) => `- ${key}: ${value}`),
|
|
284
|
-
"",
|
|
285
|
-
];
|
|
286
|
-
return `${lines.join("\n")}\n`;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
const DEFAULT_SCHEMA = `# Wiki Schema
|
|
290
|
-
|
|
291
|
-
This wiki is maintained by the agent through wiki tools.
|
|
292
|
-
|
|
293
|
-
## Structure
|
|
294
|
-
- \`pages/\`: markdown knowledge pages
|
|
295
|
-
- \`index.md\`: derived index (tool-managed)
|
|
296
|
-
- \`log.md\`: append-only activity log (tool-managed)
|
|
297
|
-
|
|
298
|
-
## Page conventions
|
|
299
|
-
- Use markdown files under \`pages/\`
|
|
300
|
-
- Prefer concise titles and summaries
|
|
301
|
-
- Add frontmatter when helpful (\`title\`, \`summary\`, \`tags\`, \`related\`, \`type\`)
|
|
302
|
-
- Use relative links to other pages when appropriate
|
|
303
|
-
`;
|
|
304
|
-
|
|
305
|
-
async function ensureWikiLayout(root: string): Promise<void> {
|
|
306
|
-
const pagesRoot = resolveWithinRoot(root, PAGES_DIR);
|
|
307
|
-
await fs.mkdir(pagesRoot, { recursive: true });
|
|
308
|
-
|
|
309
|
-
const indexPath = resolveWithinRoot(root, INDEX_FILE);
|
|
310
|
-
const logPath = resolveWithinRoot(root, LOG_FILE);
|
|
311
|
-
const schemaPath = resolveWithinRoot(root, SCHEMA_FILE);
|
|
312
|
-
|
|
313
|
-
if (!(await fileExists(indexPath))) {
|
|
314
|
-
await fs.writeFile(indexPath, buildIndexMarkdown([]), "utf8");
|
|
315
|
-
}
|
|
316
|
-
if (!(await fileExists(logPath))) {
|
|
317
|
-
await fs.writeFile(logPath, "# Wiki Log\n\n", "utf8");
|
|
318
|
-
}
|
|
319
|
-
if (!(await fileExists(schemaPath))) {
|
|
320
|
-
await fs.writeFile(schemaPath, `${DEFAULT_SCHEMA}\n`, "utf8");
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
async function writeIndex(root: string, pages: PageRecord[]): Promise<void> {
|
|
325
|
-
const indexPath = resolveWithinRoot(root, INDEX_FILE);
|
|
326
|
-
await fs.writeFile(indexPath, buildIndexMarkdown(pages), "utf8");
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
async function appendLog(
|
|
330
|
-
root: string,
|
|
331
|
-
operation: string,
|
|
332
|
-
details: Record<string, string>,
|
|
333
|
-
): Promise<void> {
|
|
334
|
-
const logPath = resolveWithinRoot(root, LOG_FILE);
|
|
335
|
-
await fs.appendFile(logPath, buildLogEntry(operation, details), "utf8");
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
function pageIndexId(relativePath: string): string {
|
|
339
|
-
return `wiki:page:${relativePath}`;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
function searchMetadata(page: PageRecord): Record<string, string | number> {
|
|
343
|
-
return {
|
|
344
|
-
kind: "page",
|
|
345
|
-
path: page.path,
|
|
346
|
-
title: page.title,
|
|
347
|
-
summary: page.summary,
|
|
348
|
-
tags: page.tags.join(","),
|
|
349
|
-
word_count: page.wordCount,
|
|
350
|
-
};
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
export function createWikiTools(config: Config) {
|
|
354
|
-
const root = wikiRoot();
|
|
355
|
-
const client = new ChromaClient({
|
|
356
|
-
...chromaClientArgsFromUrl(config.tools.wiki.chroma.url),
|
|
357
|
-
});
|
|
358
|
-
let collectionPromise: Promise<Collection> | null = null;
|
|
359
|
-
|
|
360
|
-
const collection = async (): Promise<Collection> => {
|
|
361
|
-
if (!collectionPromise) {
|
|
362
|
-
collectionPromise = client.getOrCreateCollection({
|
|
363
|
-
name: config.tools.wiki.chroma.collection.wiki,
|
|
364
|
-
embeddingFunction: new HFEmbedding(),
|
|
365
|
-
});
|
|
366
|
-
}
|
|
367
|
-
return collectionPromise;
|
|
368
|
-
};
|
|
369
|
-
|
|
370
|
-
const upsertPageSearch = async (page: PageRecord): Promise<void> => {
|
|
371
|
-
const c = await collection();
|
|
372
|
-
const id = pageIndexId(page.path);
|
|
373
|
-
try {
|
|
374
|
-
await c.delete({ ids: [id] });
|
|
375
|
-
} catch {
|
|
376
|
-
// best-effort cleanup
|
|
377
|
-
}
|
|
378
|
-
await c.add({
|
|
379
|
-
ids: [id],
|
|
380
|
-
documents: [page.body || page.content],
|
|
381
|
-
metadatas: [searchMetadata(page)],
|
|
382
|
-
});
|
|
383
|
-
};
|
|
384
|
-
|
|
385
|
-
return [
|
|
386
|
-
tool({
|
|
387
|
-
name: "wiki_list_files",
|
|
388
|
-
description:
|
|
389
|
-
"List wiki files by type. Supports `page` and returns frontmatter-aware summaries.",
|
|
390
|
-
inputSchema: z.object({
|
|
391
|
-
type: z.enum(["page"]).default("page"),
|
|
392
|
-
}),
|
|
393
|
-
callback: async () => {
|
|
394
|
-
await ensureWikiLayout(root);
|
|
395
|
-
const pages = await listPages(root);
|
|
396
|
-
return toJsonValue({
|
|
397
|
-
root,
|
|
398
|
-
type: "page",
|
|
399
|
-
count: pages.length,
|
|
400
|
-
files: pages.map((page) => ({
|
|
401
|
-
path: page.path,
|
|
402
|
-
title: page.title,
|
|
403
|
-
summary: page.summary,
|
|
404
|
-
tags: page.tags,
|
|
405
|
-
related: page.related,
|
|
406
|
-
type: page.type,
|
|
407
|
-
created: page.created,
|
|
408
|
-
updated: page.updated,
|
|
409
|
-
word_count: page.wordCount,
|
|
410
|
-
modified_at: page.mtime,
|
|
411
|
-
})),
|
|
412
|
-
});
|
|
413
|
-
},
|
|
414
|
-
}),
|
|
415
|
-
tool({
|
|
416
|
-
name: "wiki_read_file",
|
|
417
|
-
description:
|
|
418
|
-
"Read wiki files. Kinds: index, log, schema, or a specific page.",
|
|
419
|
-
inputSchema: z.object({
|
|
420
|
-
kind: z.enum(["index", "log", "schema", "page"]),
|
|
421
|
-
path: z.string().optional(),
|
|
422
|
-
}),
|
|
423
|
-
callback: async (input) => {
|
|
424
|
-
await ensureWikiLayout(root);
|
|
425
|
-
|
|
426
|
-
if (input.kind === "page") {
|
|
427
|
-
if (!input.path) {
|
|
428
|
-
throw new Error("`path` is required when kind is `page`.");
|
|
429
|
-
}
|
|
430
|
-
const relativePath = pageRelativePath(input.path);
|
|
431
|
-
const page = await readPageRecord(root, relativePath);
|
|
432
|
-
return toJsonValue({
|
|
433
|
-
root,
|
|
434
|
-
kind: input.kind,
|
|
435
|
-
path: page.path,
|
|
436
|
-
frontmatter: page.frontmatter,
|
|
437
|
-
title: page.title,
|
|
438
|
-
summary: page.summary,
|
|
439
|
-
word_count: page.wordCount,
|
|
440
|
-
content: page.content,
|
|
441
|
-
});
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
if (input.path) {
|
|
445
|
-
throw new Error(
|
|
446
|
-
"`path` is only valid when kind is `page` and should be omitted otherwise.",
|
|
447
|
-
);
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
const target =
|
|
451
|
-
input.kind === "index"
|
|
452
|
-
? INDEX_FILE
|
|
453
|
-
: input.kind === "log"
|
|
454
|
-
? LOG_FILE
|
|
455
|
-
: SCHEMA_FILE;
|
|
456
|
-
const absolutePath = resolveWithinRoot(root, target);
|
|
457
|
-
const content = await fs.readFile(absolutePath, "utf8");
|
|
458
|
-
return toJsonValue({
|
|
459
|
-
root,
|
|
460
|
-
kind: input.kind,
|
|
461
|
-
path: target,
|
|
462
|
-
content,
|
|
463
|
-
});
|
|
464
|
-
},
|
|
465
|
-
}),
|
|
466
|
-
tool({
|
|
467
|
-
name: "wiki_write_file",
|
|
468
|
-
description:
|
|
469
|
-
"Write wiki files. Page writes automatically maintain index, log, and search index.",
|
|
470
|
-
inputSchema: z.object({
|
|
471
|
-
kind: z.enum(["page", "schema"]),
|
|
472
|
-
path: z.string().optional(),
|
|
473
|
-
content: z.string().min(1),
|
|
474
|
-
}),
|
|
475
|
-
callback: async (input) => {
|
|
476
|
-
await ensureWikiLayout(root);
|
|
477
|
-
const content = input.content;
|
|
478
|
-
|
|
479
|
-
if (input.kind === "schema") {
|
|
480
|
-
if (input.path) {
|
|
481
|
-
throw new Error("`path` is not valid when kind is `schema`.");
|
|
482
|
-
}
|
|
483
|
-
const schemaPath = resolveWithinRoot(root, SCHEMA_FILE);
|
|
484
|
-
await fs.writeFile(schemaPath, content, "utf8");
|
|
485
|
-
await appendLog(root, "schema_update", { path: SCHEMA_FILE });
|
|
486
|
-
return toJsonValue({
|
|
487
|
-
root,
|
|
488
|
-
kind: input.kind,
|
|
489
|
-
path: SCHEMA_FILE,
|
|
490
|
-
bytes_written: Buffer.byteLength(content, "utf8"),
|
|
491
|
-
index_updated: false,
|
|
492
|
-
log_updated: true,
|
|
493
|
-
search_index_updated: false,
|
|
494
|
-
});
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
if (!input.path) {
|
|
498
|
-
throw new Error("`path` is required when kind is `page`.");
|
|
499
|
-
}
|
|
500
|
-
const relativePath = pageRelativePath(input.path);
|
|
501
|
-
const absolutePath = resolveWithinRoot(root, relativePath);
|
|
502
|
-
const existed = await fileExists(absolutePath);
|
|
503
|
-
|
|
504
|
-
await fs.mkdir(path.dirname(absolutePath), { recursive: true });
|
|
505
|
-
await fs.writeFile(absolutePath, content, "utf8");
|
|
506
|
-
|
|
507
|
-
const page = await readPageRecord(root, relativePath);
|
|
508
|
-
await upsertPageSearch(page);
|
|
509
|
-
|
|
510
|
-
const pages = await listPages(root);
|
|
511
|
-
await writeIndex(root, pages);
|
|
512
|
-
await appendLog(root, existed ? "page_update" : "page_create", {
|
|
513
|
-
path: page.path,
|
|
514
|
-
title: page.title,
|
|
515
|
-
});
|
|
516
|
-
|
|
517
|
-
return toJsonValue({
|
|
518
|
-
root,
|
|
519
|
-
kind: input.kind,
|
|
520
|
-
path: page.path,
|
|
521
|
-
title: page.title,
|
|
522
|
-
summary: page.summary,
|
|
523
|
-
bytes_written: Buffer.byteLength(content, "utf8"),
|
|
524
|
-
index_updated: true,
|
|
525
|
-
log_updated: true,
|
|
526
|
-
search_index_updated: true,
|
|
527
|
-
});
|
|
528
|
-
},
|
|
529
|
-
}),
|
|
530
|
-
tool({
|
|
531
|
-
name: "wiki_knowledge_graph",
|
|
532
|
-
description:
|
|
533
|
-
"Build the wiki knowledge graph from page frontmatter links and shared tags.",
|
|
534
|
-
inputSchema: z.object({}),
|
|
535
|
-
callback: async () => {
|
|
536
|
-
await ensureWikiLayout(root);
|
|
537
|
-
const pages = await listPages(root);
|
|
538
|
-
const nodes = pages.map((page) => ({
|
|
539
|
-
path: page.path,
|
|
540
|
-
title: page.title,
|
|
541
|
-
tags: page.tags,
|
|
542
|
-
type: page.type ?? "page",
|
|
543
|
-
word_count: page.wordCount,
|
|
544
|
-
}));
|
|
545
|
-
|
|
546
|
-
const edges: Array<{
|
|
547
|
-
source: string;
|
|
548
|
-
target: string;
|
|
549
|
-
type: "related" | "shared-tag";
|
|
550
|
-
tag?: string;
|
|
551
|
-
}> = [];
|
|
552
|
-
const inbound = new Map<string, number>();
|
|
553
|
-
const relatedOut = new Map<string, number>();
|
|
554
|
-
|
|
555
|
-
for (const page of pages) {
|
|
556
|
-
relatedOut.set(page.path, page.related.length);
|
|
557
|
-
for (const related of page.related) {
|
|
558
|
-
edges.push({
|
|
559
|
-
source: page.path,
|
|
560
|
-
target: related,
|
|
561
|
-
type: "related",
|
|
562
|
-
});
|
|
563
|
-
inbound.set(related, (inbound.get(related) ?? 0) + 1);
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
const tagClusters = new Map<string, string[]>();
|
|
568
|
-
for (const page of pages) {
|
|
569
|
-
for (const tag of page.tags) {
|
|
570
|
-
if (!tagClusters.has(tag)) {
|
|
571
|
-
tagClusters.set(tag, []);
|
|
572
|
-
}
|
|
573
|
-
tagClusters.get(tag)!.push(page.path);
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
for (const [tag, members] of tagClusters.entries()) {
|
|
578
|
-
if (members.length < 2) {
|
|
579
|
-
continue;
|
|
580
|
-
}
|
|
581
|
-
for (let i = 0; i < members.length; i += 1) {
|
|
582
|
-
for (let j = i + 1; j < members.length; j += 1) {
|
|
583
|
-
const source = members[i]!;
|
|
584
|
-
const target = members[j]!;
|
|
585
|
-
edges.push({ source, target, type: "shared-tag", tag });
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
const orphans = pages.filter((page) => {
|
|
591
|
-
const incoming = inbound.get(page.path) ?? 0;
|
|
592
|
-
const outgoing = relatedOut.get(page.path) ?? 0;
|
|
593
|
-
return incoming === 0 && outgoing === 0;
|
|
594
|
-
});
|
|
595
|
-
|
|
596
|
-
return toJsonValue({
|
|
597
|
-
nodes,
|
|
598
|
-
edges,
|
|
599
|
-
tag_clusters: Object.fromEntries(tagClusters.entries()),
|
|
600
|
-
stats: {
|
|
601
|
-
pages: pages.length,
|
|
602
|
-
links: edges.length,
|
|
603
|
-
orphans: orphans.length,
|
|
604
|
-
},
|
|
605
|
-
});
|
|
606
|
-
},
|
|
607
|
-
}),
|
|
608
|
-
tool({
|
|
609
|
-
name: "wiki_stats",
|
|
610
|
-
description: "Return wiki health and usage statistics for page content.",
|
|
611
|
-
inputSchema: z.object({}),
|
|
612
|
-
callback: async () => {
|
|
613
|
-
await ensureWikiLayout(root);
|
|
614
|
-
const pages = await listPages(root);
|
|
615
|
-
const totalWords = pages.reduce((sum, page) => sum + page.wordCount, 0);
|
|
616
|
-
const tags = new Set<string>();
|
|
617
|
-
const types: Record<string, number> = {};
|
|
618
|
-
const inbound = new Map<string, number>();
|
|
619
|
-
for (const page of pages) {
|
|
620
|
-
for (const tag of page.tags) {
|
|
621
|
-
tags.add(tag);
|
|
622
|
-
}
|
|
623
|
-
const type = page.type ?? "page";
|
|
624
|
-
types[type] = (types[type] ?? 0) + 1;
|
|
625
|
-
for (const related of page.related) {
|
|
626
|
-
inbound.set(related, (inbound.get(related) ?? 0) + 1);
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
const orphans = pages.filter(
|
|
630
|
-
(page) =>
|
|
631
|
-
(inbound.get(page.path) ?? 0) === 0 && page.related.length === 0,
|
|
632
|
-
);
|
|
633
|
-
const lastActivity = pages
|
|
634
|
-
.map((page) => page.mtime)
|
|
635
|
-
.sort()
|
|
636
|
-
.at(-1);
|
|
637
|
-
|
|
638
|
-
return toJsonValue({
|
|
639
|
-
pages: pages.length,
|
|
640
|
-
links: pages.reduce((sum, page) => sum + page.related.length, 0),
|
|
641
|
-
orphans: orphans.length,
|
|
642
|
-
total_words: totalWords,
|
|
643
|
-
avg_words_per_page: pages.length > 0 ? totalWords / pages.length : 0,
|
|
644
|
-
tags: tags.size,
|
|
645
|
-
types,
|
|
646
|
-
last_activity: lastActivity ?? null,
|
|
647
|
-
});
|
|
648
|
-
},
|
|
649
|
-
}),
|
|
650
|
-
tool({
|
|
651
|
-
name: "wiki_search",
|
|
652
|
-
description:
|
|
653
|
-
"Semantic search over indexed wiki pages using the configured wiki Chroma collection.",
|
|
654
|
-
inputSchema: z.object({
|
|
655
|
-
query: z.string().min(1),
|
|
656
|
-
k: z.number().int().min(1).max(MAX_SEARCH_LIMIT).optional(),
|
|
657
|
-
}),
|
|
658
|
-
callback: async (input) => {
|
|
659
|
-
await ensureWikiLayout(root);
|
|
660
|
-
const c = await collection();
|
|
661
|
-
const result = await c.query<Record<string, string | number>>({
|
|
662
|
-
queryTexts: [input.query],
|
|
663
|
-
nResults: input.k ?? DEFAULT_SEARCH_LIMIT,
|
|
664
|
-
include: ["documents", "metadatas", "distances"],
|
|
665
|
-
});
|
|
666
|
-
|
|
667
|
-
const rows = result.rows()[0] ?? [];
|
|
668
|
-
const matches = rows
|
|
669
|
-
.filter(
|
|
670
|
-
(
|
|
671
|
-
row,
|
|
672
|
-
): row is (typeof rows)[number] & {
|
|
673
|
-
document: string;
|
|
674
|
-
metadata: Record<string, string | number>;
|
|
675
|
-
} => typeof row.document === "string" && !!row.metadata,
|
|
676
|
-
)
|
|
677
|
-
.map((row) => ({
|
|
678
|
-
id: row.id,
|
|
679
|
-
path:
|
|
680
|
-
typeof row.metadata.path === "string" ? row.metadata.path : null,
|
|
681
|
-
title:
|
|
682
|
-
typeof row.metadata.title === "string"
|
|
683
|
-
? row.metadata.title
|
|
684
|
-
: null,
|
|
685
|
-
summary:
|
|
686
|
-
typeof row.metadata.summary === "string"
|
|
687
|
-
? row.metadata.summary
|
|
688
|
-
: null,
|
|
689
|
-
tags:
|
|
690
|
-
typeof row.metadata.tags === "string" ? row.metadata.tags : "",
|
|
691
|
-
distance: row.distance ?? null,
|
|
692
|
-
content: row.document,
|
|
693
|
-
}));
|
|
694
|
-
|
|
695
|
-
return toJsonValue({
|
|
696
|
-
query: input.query,
|
|
697
|
-
count: matches.length,
|
|
698
|
-
matches,
|
|
699
|
-
});
|
|
700
|
-
},
|
|
701
|
-
}),
|
|
702
|
-
];
|
|
703
|
-
}
|