claude-code-workflow 6.2.2 → 6.2.4
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/ccw/dist/cli.d.ts +2 -0
- package/ccw/dist/cli.d.ts.map +1 -0
- package/ccw/dist/cli.js +219 -0
- package/ccw/dist/cli.js.map +1 -0
- package/ccw/dist/commands/cli.d.ts +32 -0
- package/ccw/dist/commands/cli.d.ts.map +1 -0
- package/ccw/dist/commands/cli.js +619 -0
- package/ccw/dist/commands/cli.js.map +1 -0
- package/ccw/dist/commands/core-memory.d.ts +32 -0
- package/ccw/dist/commands/core-memory.d.ts.map +1 -0
- package/ccw/dist/commands/core-memory.js +640 -0
- package/ccw/dist/commands/core-memory.js.map +1 -0
- package/ccw/dist/commands/hook.d.ts +16 -0
- package/ccw/dist/commands/hook.d.ts.map +1 -0
- package/ccw/dist/commands/hook.js +276 -0
- package/ccw/dist/commands/hook.js.map +1 -0
- package/ccw/dist/commands/install.d.ts +12 -0
- package/ccw/dist/commands/install.d.ts.map +1 -0
- package/ccw/dist/commands/install.js +443 -0
- package/ccw/dist/commands/install.js.map +1 -0
- package/ccw/dist/commands/list.d.ts +5 -0
- package/ccw/dist/commands/list.d.ts.map +1 -0
- package/ccw/dist/commands/list.js +32 -0
- package/ccw/dist/commands/list.js.map +1 -0
- package/ccw/dist/commands/memory.d.ts +57 -0
- package/ccw/dist/commands/memory.d.ts.map +1 -0
- package/ccw/dist/commands/memory.js +890 -0
- package/ccw/dist/commands/memory.js.map +1 -0
- package/ccw/dist/commands/serve.d.ts +12 -0
- package/ccw/dist/commands/serve.d.ts.map +1 -0
- package/ccw/dist/commands/serve.js +63 -0
- package/ccw/dist/commands/serve.js.map +1 -0
- package/ccw/dist/commands/session-path-resolver.d.ts +45 -0
- package/ccw/dist/commands/session-path-resolver.d.ts.map +1 -0
- package/ccw/dist/commands/session-path-resolver.js +302 -0
- package/ccw/dist/commands/session-path-resolver.js.map +1 -0
- package/ccw/dist/commands/session.d.ts +12 -0
- package/ccw/dist/commands/session.d.ts.map +1 -0
- package/ccw/dist/commands/session.js +954 -0
- package/ccw/dist/commands/session.js.map +1 -0
- package/ccw/dist/commands/stop.d.ts +11 -0
- package/ccw/dist/commands/stop.d.ts.map +1 -0
- package/ccw/dist/commands/stop.js +96 -0
- package/ccw/dist/commands/stop.js.map +1 -0
- package/ccw/dist/commands/tool.d.ts +29 -0
- package/ccw/dist/commands/tool.d.ts.map +1 -0
- package/ccw/dist/commands/tool.js +173 -0
- package/ccw/dist/commands/tool.js.map +1 -0
- package/ccw/dist/commands/uninstall.d.ts +9 -0
- package/ccw/dist/commands/uninstall.d.ts.map +1 -0
- package/ccw/dist/commands/uninstall.js +239 -0
- package/ccw/dist/commands/uninstall.js.map +1 -0
- package/ccw/dist/commands/upgrade.d.ts +10 -0
- package/ccw/dist/commands/upgrade.d.ts.map +1 -0
- package/ccw/dist/commands/upgrade.js +288 -0
- package/ccw/dist/commands/upgrade.js.map +1 -0
- package/ccw/dist/commands/view.d.ts +14 -0
- package/ccw/dist/commands/view.d.ts.map +1 -0
- package/ccw/dist/commands/view.js +100 -0
- package/ccw/dist/commands/view.js.map +1 -0
- package/ccw/dist/config/storage-paths.d.ts +184 -0
- package/ccw/dist/config/storage-paths.d.ts.map +1 -0
- package/ccw/dist/config/storage-paths.js +536 -0
- package/ccw/dist/config/storage-paths.js.map +1 -0
- package/ccw/dist/core/cache-manager.d.ts +80 -0
- package/ccw/dist/core/cache-manager.d.ts.map +1 -0
- package/ccw/dist/core/cache-manager.js +260 -0
- package/ccw/dist/core/cache-manager.js.map +1 -0
- package/ccw/dist/core/claude-freshness.d.ts +53 -0
- package/ccw/dist/core/claude-freshness.d.ts.map +1 -0
- package/ccw/dist/core/claude-freshness.js +232 -0
- package/ccw/dist/core/claude-freshness.js.map +1 -0
- package/ccw/dist/core/core-memory-store.d.ts +320 -0
- package/ccw/dist/core/core-memory-store.d.ts.map +1 -0
- package/ccw/dist/core/core-memory-store.js +1177 -0
- package/ccw/dist/core/core-memory-store.js.map +1 -0
- package/ccw/dist/core/dashboard-generator-patch.d.ts +2 -0
- package/ccw/dist/core/dashboard-generator-patch.d.ts.map +1 -0
- package/ccw/dist/core/dashboard-generator-patch.js +48 -0
- package/ccw/dist/core/dashboard-generator-patch.js.map +1 -0
- package/ccw/dist/core/dashboard-generator.d.ts +8 -0
- package/ccw/dist/core/dashboard-generator.d.ts.map +1 -0
- package/ccw/dist/core/dashboard-generator.js +695 -0
- package/ccw/dist/core/dashboard-generator.js.map +1 -0
- package/ccw/dist/core/data-aggregator.d.ts +145 -0
- package/ccw/dist/core/data-aggregator.d.ts.map +1 -0
- package/ccw/dist/core/data-aggregator.js +416 -0
- package/ccw/dist/core/data-aggregator.js.map +1 -0
- package/ccw/dist/core/history-importer.d.ts +102 -0
- package/ccw/dist/core/history-importer.d.ts.map +1 -0
- package/ccw/dist/core/history-importer.js +493 -0
- package/ccw/dist/core/history-importer.js.map +1 -0
- package/ccw/dist/core/lite-scanner-complete.d.ts +81 -0
- package/ccw/dist/core/lite-scanner-complete.d.ts.map +1 -0
- package/ccw/dist/core/lite-scanner-complete.js +368 -0
- package/ccw/dist/core/lite-scanner-complete.js.map +1 -0
- package/ccw/dist/core/lite-scanner.d.ts +81 -0
- package/ccw/dist/core/lite-scanner.d.ts.map +1 -0
- package/ccw/dist/core/lite-scanner.js +368 -0
- package/ccw/dist/core/lite-scanner.js.map +1 -0
- package/ccw/dist/core/manifest.d.ts +88 -0
- package/ccw/dist/core/manifest.d.ts.map +1 -0
- package/ccw/dist/core/manifest.js +214 -0
- package/ccw/dist/core/manifest.js.map +1 -0
- package/ccw/dist/core/memory-embedder-bridge.d.ts +83 -0
- package/ccw/dist/core/memory-embedder-bridge.d.ts.map +1 -0
- package/ccw/dist/core/memory-embedder-bridge.js +181 -0
- package/ccw/dist/core/memory-embedder-bridge.js.map +1 -0
- package/ccw/dist/core/memory-store.d.ts +249 -0
- package/ccw/dist/core/memory-store.d.ts.map +1 -0
- package/ccw/dist/core/memory-store.js +781 -0
- package/ccw/dist/core/memory-store.js.map +1 -0
- package/ccw/dist/core/routes/ccw-routes.d.ts +20 -0
- package/ccw/dist/core/routes/ccw-routes.d.ts.map +1 -0
- package/ccw/dist/core/routes/ccw-routes.js +70 -0
- package/ccw/dist/core/routes/ccw-routes.js.map +1 -0
- package/ccw/dist/core/routes/claude-routes.d.ts +19 -0
- package/ccw/dist/core/routes/claude-routes.d.ts.map +1 -0
- package/ccw/dist/core/routes/claude-routes.js +1017 -0
- package/ccw/dist/core/routes/claude-routes.js.map +1 -0
- package/ccw/dist/core/routes/cli-routes.d.ts +20 -0
- package/ccw/dist/core/routes/cli-routes.d.ts.map +1 -0
- package/ccw/dist/core/routes/cli-routes.js +468 -0
- package/ccw/dist/core/routes/cli-routes.js.map +1 -0
- package/ccw/dist/core/routes/codexlens-routes.d.ts +20 -0
- package/ccw/dist/core/routes/codexlens-routes.d.ts.map +1 -0
- package/ccw/dist/core/routes/codexlens-routes.js +754 -0
- package/ccw/dist/core/routes/codexlens-routes.js.map +1 -0
- package/ccw/dist/core/routes/core-memory-routes.d.ts +21 -0
- package/ccw/dist/core/routes/core-memory-routes.d.ts.map +1 -0
- package/ccw/dist/core/routes/core-memory-routes.js +520 -0
- package/ccw/dist/core/routes/core-memory-routes.js.map +1 -0
- package/ccw/dist/core/routes/files-routes.d.ts +20 -0
- package/ccw/dist/core/routes/files-routes.d.ts.map +1 -0
- package/ccw/dist/core/routes/files-routes.js +374 -0
- package/ccw/dist/core/routes/files-routes.js.map +1 -0
- package/ccw/dist/core/routes/graph-routes.d.ts +20 -0
- package/ccw/dist/core/routes/graph-routes.d.ts.map +1 -0
- package/ccw/dist/core/routes/graph-routes.js +517 -0
- package/ccw/dist/core/routes/graph-routes.js.map +1 -0
- package/ccw/dist/core/routes/help-routes.d.ts +20 -0
- package/ccw/dist/core/routes/help-routes.d.ts.map +1 -0
- package/ccw/dist/core/routes/help-routes.js +250 -0
- package/ccw/dist/core/routes/help-routes.js.map +1 -0
- package/ccw/dist/core/routes/hooks-routes.d.ts +21 -0
- package/ccw/dist/core/routes/hooks-routes.d.ts.map +1 -0
- package/ccw/dist/core/routes/hooks-routes.js +346 -0
- package/ccw/dist/core/routes/hooks-routes.js.map +1 -0
- package/ccw/dist/core/routes/mcp-routes.d.ts +20 -0
- package/ccw/dist/core/routes/mcp-routes.d.ts.map +1 -0
- package/ccw/dist/core/routes/mcp-routes.js +1129 -0
- package/ccw/dist/core/routes/mcp-routes.js.map +1 -0
- package/ccw/dist/core/routes/mcp-templates-db.d.ts +54 -0
- package/ccw/dist/core/routes/mcp-templates-db.d.ts.map +1 -0
- package/ccw/dist/core/routes/mcp-templates-db.js +226 -0
- package/ccw/dist/core/routes/mcp-templates-db.js.map +1 -0
- package/ccw/dist/core/routes/memory-routes.d.ts +21 -0
- package/ccw/dist/core/routes/memory-routes.d.ts.map +1 -0
- package/ccw/dist/core/routes/memory-routes.js +1095 -0
- package/ccw/dist/core/routes/memory-routes.js.map +1 -0
- package/ccw/dist/core/routes/rules-routes.d.ts +20 -0
- package/ccw/dist/core/routes/rules-routes.d.ts.map +1 -0
- package/ccw/dist/core/routes/rules-routes.js +442 -0
- package/ccw/dist/core/routes/rules-routes.js.map +1 -0
- package/ccw/dist/core/routes/session-routes.d.ts +20 -0
- package/ccw/dist/core/routes/session-routes.d.ts.map +1 -0
- package/ccw/dist/core/routes/session-routes.js +423 -0
- package/ccw/dist/core/routes/session-routes.js.map +1 -0
- package/ccw/dist/core/routes/skills-routes.d.ts +20 -0
- package/ccw/dist/core/routes/skills-routes.d.ts.map +1 -0
- package/ccw/dist/core/routes/skills-routes.js +533 -0
- package/ccw/dist/core/routes/skills-routes.js.map +1 -0
- package/ccw/dist/core/routes/status-routes.d.ts +20 -0
- package/ccw/dist/core/routes/status-routes.d.ts.map +1 -0
- package/ccw/dist/core/routes/status-routes.js +38 -0
- package/ccw/dist/core/routes/status-routes.js.map +1 -0
- package/ccw/dist/core/routes/system-routes.d.ts +22 -0
- package/ccw/dist/core/routes/system-routes.d.ts.map +1 -0
- package/ccw/dist/core/routes/system-routes.js +354 -0
- package/ccw/dist/core/routes/system-routes.js.map +1 -0
- package/ccw/dist/core/server.d.ts +17 -0
- package/ccw/dist/core/server.d.ts.map +1 -0
- package/ccw/dist/core/server.js +386 -0
- package/ccw/dist/core/server.js.map +1 -0
- package/ccw/dist/core/session-clustering-service.d.ts +153 -0
- package/ccw/dist/core/session-clustering-service.d.ts.map +1 -0
- package/ccw/dist/core/session-clustering-service.js +1065 -0
- package/ccw/dist/core/session-clustering-service.js.map +1 -0
- package/ccw/dist/core/session-scanner.d.ts +32 -0
- package/ccw/dist/core/session-scanner.d.ts.map +1 -0
- package/ccw/dist/core/session-scanner.js +253 -0
- package/ccw/dist/core/session-scanner.js.map +1 -0
- package/ccw/dist/core/websocket.d.ts +23 -0
- package/ccw/dist/core/websocket.d.ts.map +1 -0
- package/ccw/dist/core/websocket.js +168 -0
- package/ccw/dist/core/websocket.js.map +1 -0
- package/ccw/dist/index.d.ts +10 -0
- package/ccw/dist/index.d.ts.map +1 -0
- package/ccw/dist/index.js +10 -0
- package/ccw/dist/index.js.map +1 -0
- package/ccw/dist/mcp-server/index.d.ts +7 -0
- package/ccw/dist/mcp-server/index.d.ts.map +1 -0
- package/ccw/dist/mcp-server/index.js +157 -0
- package/ccw/dist/mcp-server/index.js.map +1 -0
- package/ccw/dist/tools/classify-folders.d.ts +26 -0
- package/ccw/dist/tools/classify-folders.d.ts.map +1 -0
- package/ccw/dist/tools/classify-folders.js +201 -0
- package/ccw/dist/tools/classify-folders.js.map +1 -0
- package/ccw/dist/tools/cli-config-manager.d.ts +62 -0
- package/ccw/dist/tools/cli-config-manager.d.ts.map +1 -0
- package/ccw/dist/tools/cli-config-manager.js +221 -0
- package/ccw/dist/tools/cli-config-manager.js.map +1 -0
- package/ccw/dist/tools/cli-executor.d.ts +373 -0
- package/ccw/dist/tools/cli-executor.d.ts.map +1 -0
- package/ccw/dist/tools/cli-executor.js +1625 -0
- package/ccw/dist/tools/cli-executor.js.map +1 -0
- package/ccw/dist/tools/cli-history-store.d.ts +330 -0
- package/ccw/dist/tools/cli-history-store.d.ts.map +1 -0
- package/ccw/dist/tools/cli-history-store.js +916 -0
- package/ccw/dist/tools/cli-history-store.js.map +1 -0
- package/ccw/dist/tools/codex-lens.d.ts +118 -0
- package/ccw/dist/tools/codex-lens.d.ts.map +1 -0
- package/ccw/dist/tools/codex-lens.js +962 -0
- package/ccw/dist/tools/codex-lens.js.map +1 -0
- package/ccw/dist/tools/convert-tokens-to-css.d.ts +14 -0
- package/ccw/dist/tools/convert-tokens-to-css.d.ts.map +1 -0
- package/ccw/dist/tools/convert-tokens-to-css.js +244 -0
- package/ccw/dist/tools/convert-tokens-to-css.js.map +1 -0
- package/ccw/dist/tools/core-memory.d.ts +66 -0
- package/ccw/dist/tools/core-memory.d.ts.map +1 -0
- package/ccw/dist/tools/core-memory.js +324 -0
- package/ccw/dist/tools/core-memory.js.map +1 -0
- package/ccw/dist/tools/detect-changed-modules.d.ts +24 -0
- package/ccw/dist/tools/detect-changed-modules.d.ts.map +1 -0
- package/ccw/dist/tools/detect-changed-modules.js +277 -0
- package/ccw/dist/tools/detect-changed-modules.js.map +1 -0
- package/ccw/dist/tools/discover-design-files.d.ts +36 -0
- package/ccw/dist/tools/discover-design-files.d.ts.map +1 -0
- package/ccw/dist/tools/discover-design-files.js +147 -0
- package/ccw/dist/tools/discover-design-files.js.map +1 -0
- package/ccw/dist/tools/edit-file.d.ts +28 -0
- package/ccw/dist/tools/edit-file.d.ts.map +1 -0
- package/ccw/dist/tools/edit-file.js +479 -0
- package/ccw/dist/tools/edit-file.js.map +1 -0
- package/ccw/dist/tools/generate-module-docs.d.ts +22 -0
- package/ccw/dist/tools/generate-module-docs.d.ts.map +1 -0
- package/ccw/dist/tools/generate-module-docs.js +379 -0
- package/ccw/dist/tools/generate-module-docs.js.map +1 -0
- package/ccw/dist/tools/get-modules-by-depth.d.ts +15 -0
- package/ccw/dist/tools/get-modules-by-depth.d.ts.map +1 -0
- package/ccw/dist/tools/get-modules-by-depth.js +296 -0
- package/ccw/dist/tools/get-modules-by-depth.js.map +1 -0
- package/ccw/dist/tools/index.d.ts +55 -0
- package/ccw/dist/tools/index.d.ts.map +1 -0
- package/ccw/dist/tools/index.js +304 -0
- package/ccw/dist/tools/index.js.map +1 -0
- package/ccw/dist/tools/native-session-discovery.d.ts +97 -0
- package/ccw/dist/tools/native-session-discovery.d.ts.map +1 -0
- package/ccw/dist/tools/native-session-discovery.js +700 -0
- package/ccw/dist/tools/native-session-discovery.js.map +1 -0
- package/ccw/dist/tools/notifier.d.ts +50 -0
- package/ccw/dist/tools/notifier.d.ts.map +1 -0
- package/ccw/dist/tools/notifier.js +90 -0
- package/ccw/dist/tools/notifier.js.map +1 -0
- package/ccw/dist/tools/read-file.d.ts +32 -0
- package/ccw/dist/tools/read-file.d.ts.map +1 -0
- package/ccw/dist/tools/read-file.js +329 -0
- package/ccw/dist/tools/read-file.js.map +1 -0
- package/ccw/dist/tools/resume-strategy.d.ts +48 -0
- package/ccw/dist/tools/resume-strategy.d.ts.map +1 -0
- package/ccw/dist/tools/resume-strategy.js +248 -0
- package/ccw/dist/tools/resume-strategy.js.map +1 -0
- package/ccw/dist/tools/session-content-parser.d.ts +58 -0
- package/ccw/dist/tools/session-content-parser.d.ts.map +1 -0
- package/ccw/dist/tools/session-content-parser.js +420 -0
- package/ccw/dist/tools/session-content-parser.js.map +1 -0
- package/ccw/dist/tools/session-manager.d.ts +9 -0
- package/ccw/dist/tools/session-manager.d.ts.map +1 -0
- package/ccw/dist/tools/session-manager.js +834 -0
- package/ccw/dist/tools/session-manager.js.map +1 -0
- package/ccw/dist/tools/smart-context.d.ts +35 -0
- package/ccw/dist/tools/smart-context.d.ts.map +1 -0
- package/ccw/dist/tools/smart-context.js +182 -0
- package/ccw/dist/tools/smart-context.js.map +1 -0
- package/ccw/dist/tools/smart-search.d.ts +105 -0
- package/ccw/dist/tools/smart-search.d.ts.map +1 -0
- package/ccw/dist/tools/smart-search.js +1753 -0
- package/ccw/dist/tools/smart-search.js.map +1 -0
- package/ccw/dist/tools/storage-manager.d.ts +114 -0
- package/ccw/dist/tools/storage-manager.d.ts.map +1 -0
- package/ccw/dist/tools/storage-manager.js +392 -0
- package/ccw/dist/tools/storage-manager.js.map +1 -0
- package/ccw/dist/tools/ui-generate-preview.d.ts +39 -0
- package/ccw/dist/tools/ui-generate-preview.d.ts.map +1 -0
- package/ccw/dist/tools/ui-generate-preview.js +300 -0
- package/ccw/dist/tools/ui-generate-preview.js.map +1 -0
- package/ccw/dist/tools/ui-instantiate-prototypes.d.ts +75 -0
- package/ccw/dist/tools/ui-instantiate-prototypes.d.ts.map +1 -0
- package/ccw/dist/tools/ui-instantiate-prototypes.js +256 -0
- package/ccw/dist/tools/ui-instantiate-prototypes.js.map +1 -0
- package/ccw/dist/tools/update-module-claude.d.ts +80 -0
- package/ccw/dist/tools/update-module-claude.d.ts.map +1 -0
- package/ccw/dist/tools/update-module-claude.js +351 -0
- package/ccw/dist/tools/update-module-claude.js.map +1 -0
- package/ccw/dist/tools/write-file.d.ts +19 -0
- package/ccw/dist/tools/write-file.d.ts.map +1 -0
- package/ccw/dist/tools/write-file.js +193 -0
- package/ccw/dist/tools/write-file.js.map +1 -0
- package/ccw/dist/types/config.d.ts +11 -0
- package/ccw/dist/types/config.d.ts.map +1 -0
- package/ccw/dist/types/config.js +2 -0
- package/ccw/dist/types/config.js.map +1 -0
- package/ccw/dist/types/index.d.ts +4 -0
- package/ccw/dist/types/index.d.ts.map +1 -0
- package/ccw/dist/types/index.js +4 -0
- package/ccw/dist/types/index.js.map +1 -0
- package/ccw/dist/types/session.d.ts +20 -0
- package/ccw/dist/types/session.d.ts.map +1 -0
- package/ccw/dist/types/session.js +2 -0
- package/ccw/dist/types/session.js.map +1 -0
- package/ccw/dist/types/tool.d.ts +36 -0
- package/ccw/dist/types/tool.d.ts.map +1 -0
- package/ccw/dist/types/tool.js +11 -0
- package/ccw/dist/types/tool.js.map +1 -0
- package/ccw/dist/utils/browser-launcher.d.ts +13 -0
- package/ccw/dist/utils/browser-launcher.d.ts.map +1 -0
- package/ccw/dist/utils/browser-launcher.js +60 -0
- package/ccw/dist/utils/browser-launcher.js.map +1 -0
- package/ccw/dist/utils/file-utils.d.ts +25 -0
- package/ccw/dist/utils/file-utils.d.ts.map +1 -0
- package/ccw/dist/utils/file-utils.js +48 -0
- package/ccw/dist/utils/file-utils.js.map +1 -0
- package/ccw/dist/utils/path-resolver.d.ts +80 -0
- package/ccw/dist/utils/path-resolver.d.ts.map +1 -0
- package/ccw/dist/utils/path-resolver.js +260 -0
- package/ccw/dist/utils/path-resolver.js.map +1 -0
- package/ccw/dist/utils/path-validator.d.ts +49 -0
- package/ccw/dist/utils/path-validator.d.ts.map +1 -0
- package/ccw/dist/utils/path-validator.js +123 -0
- package/ccw/dist/utils/path-validator.js.map +1 -0
- package/ccw/dist/utils/ui.d.ts +62 -0
- package/ccw/dist/utils/ui.d.ts.map +1 -0
- package/ccw/dist/utils/ui.js +129 -0
- package/ccw/dist/utils/ui.js.map +1 -0
- package/ccw/package.json +1 -1
- package/package.json +5 -2
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get Modules by Depth Tool
|
|
3
|
+
* Scan project structure and organize modules by directory depth (deepest first)
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { readdirSync, statSync, existsSync, readFileSync } from 'fs';
|
|
7
|
+
import { join, resolve, relative, extname } from 'path';
|
|
8
|
+
// System/cache directories to always exclude
|
|
9
|
+
const SYSTEM_EXCLUDES = [
|
|
10
|
+
// Version control and IDE
|
|
11
|
+
'.git', '.gitignore', '.gitmodules', '.gitattributes',
|
|
12
|
+
'.svn', '.hg', '.bzr',
|
|
13
|
+
'.history', '.vscode', '.idea', '.vs', '.vscode-test',
|
|
14
|
+
'.sublime-text', '.atom',
|
|
15
|
+
// Python
|
|
16
|
+
'__pycache__', '.pytest_cache', '.mypy_cache', '.tox',
|
|
17
|
+
'.coverage', 'htmlcov', '.nox', '.venv', 'venv', 'env',
|
|
18
|
+
'.egg-info', '.eggs', '.wheel',
|
|
19
|
+
'site-packages', '.python-version',
|
|
20
|
+
// Node.js/JavaScript
|
|
21
|
+
'node_modules', '.npm', '.yarn', '.pnpm', 'yarn-error.log',
|
|
22
|
+
'.nyc_output', 'coverage', '.next', '.nuxt',
|
|
23
|
+
'.cache', '.parcel-cache', '.vite', 'dist', 'build',
|
|
24
|
+
'.turbo', '.vercel', '.netlify',
|
|
25
|
+
// Build/compile outputs
|
|
26
|
+
'out', 'output', '_site', 'public',
|
|
27
|
+
'.output', '.generated', 'generated', 'gen',
|
|
28
|
+
'bin', 'obj', 'Debug', 'Release',
|
|
29
|
+
// Testing
|
|
30
|
+
'test-results', 'junit.xml', 'test_results',
|
|
31
|
+
'cypress', 'playwright-report', '.playwright',
|
|
32
|
+
// Logs and temp files
|
|
33
|
+
'logs', 'log', 'tmp', 'temp', '.tmp', '.temp',
|
|
34
|
+
// Documentation build outputs
|
|
35
|
+
'_book', 'docs/_build', 'site', 'gh-pages',
|
|
36
|
+
'.docusaurus', '.vuepress', '.gitbook',
|
|
37
|
+
// Cloud and deployment
|
|
38
|
+
'.serverless', '.terraform',
|
|
39
|
+
'.aws', '.azure', '.gcp',
|
|
40
|
+
// Mobile development
|
|
41
|
+
'.gradle', '.expo', '.metro',
|
|
42
|
+
'DerivedData',
|
|
43
|
+
// Game development
|
|
44
|
+
'Library', 'Temp', 'ProjectSettings',
|
|
45
|
+
'MemoryCaptures', 'UserSettings'
|
|
46
|
+
];
|
|
47
|
+
// Define Zod schema for validation
|
|
48
|
+
const ParamsSchema = z.object({
|
|
49
|
+
format: z.enum(['list', 'grouped', 'json']).default('list'),
|
|
50
|
+
path: z.string().default('.'),
|
|
51
|
+
});
|
|
52
|
+
/**
|
|
53
|
+
* Parse .gitignore file and return patterns
|
|
54
|
+
*/
|
|
55
|
+
function parseGitignore(basePath) {
|
|
56
|
+
const gitignorePath = join(basePath, '.gitignore');
|
|
57
|
+
const patterns = [];
|
|
58
|
+
if (existsSync(gitignorePath)) {
|
|
59
|
+
const content = readFileSync(gitignorePath, 'utf8');
|
|
60
|
+
content.split('\n').forEach(line => {
|
|
61
|
+
line = line.trim();
|
|
62
|
+
// Skip empty lines and comments
|
|
63
|
+
if (!line || line.startsWith('#'))
|
|
64
|
+
return;
|
|
65
|
+
// Remove trailing slash
|
|
66
|
+
line = line.replace(/\/$/, '');
|
|
67
|
+
patterns.push(line);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return patterns;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Check if a path should be excluded
|
|
74
|
+
*/
|
|
75
|
+
function shouldExclude(name, gitignorePatterns) {
|
|
76
|
+
// Check system excludes
|
|
77
|
+
if (SYSTEM_EXCLUDES.includes(name))
|
|
78
|
+
return true;
|
|
79
|
+
// Check gitignore patterns (simple matching)
|
|
80
|
+
for (const pattern of gitignorePatterns) {
|
|
81
|
+
if (name === pattern)
|
|
82
|
+
return true;
|
|
83
|
+
// Simple wildcard matching
|
|
84
|
+
if (pattern.includes('*')) {
|
|
85
|
+
const regex = new RegExp('^' + pattern.replace(/\*/g, '.*') + '$');
|
|
86
|
+
if (regex.test(name))
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Get file types in a directory
|
|
94
|
+
*/
|
|
95
|
+
function getFileTypes(dirPath) {
|
|
96
|
+
const types = new Set();
|
|
97
|
+
try {
|
|
98
|
+
const entries = readdirSync(dirPath, { withFileTypes: true });
|
|
99
|
+
entries.forEach(entry => {
|
|
100
|
+
if (entry.isFile()) {
|
|
101
|
+
const ext = extname(entry.name).slice(1);
|
|
102
|
+
if (ext)
|
|
103
|
+
types.add(ext);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
catch (e) {
|
|
108
|
+
// Ignore errors
|
|
109
|
+
}
|
|
110
|
+
return Array.from(types);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Count files in a directory (non-recursive)
|
|
114
|
+
*/
|
|
115
|
+
function countFiles(dirPath) {
|
|
116
|
+
try {
|
|
117
|
+
const entries = readdirSync(dirPath, { withFileTypes: true });
|
|
118
|
+
return entries.filter(e => e.isFile()).length;
|
|
119
|
+
}
|
|
120
|
+
catch (e) {
|
|
121
|
+
return 0;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Recursively scan directories and collect info
|
|
126
|
+
*/
|
|
127
|
+
function scanDirectories(basePath, currentPath, depth, gitignorePatterns, results) {
|
|
128
|
+
try {
|
|
129
|
+
const entries = readdirSync(currentPath, { withFileTypes: true });
|
|
130
|
+
for (const entry of entries) {
|
|
131
|
+
if (!entry.isDirectory())
|
|
132
|
+
continue;
|
|
133
|
+
if (shouldExclude(entry.name, gitignorePatterns))
|
|
134
|
+
continue;
|
|
135
|
+
const fullPath = join(currentPath, entry.name);
|
|
136
|
+
const relPath = './' + relative(basePath, fullPath).replace(/\\/g, '/');
|
|
137
|
+
const fileCount = countFiles(fullPath);
|
|
138
|
+
// Only include directories with files
|
|
139
|
+
if (fileCount > 0) {
|
|
140
|
+
const types = getFileTypes(fullPath);
|
|
141
|
+
const hasClaude = existsSync(join(fullPath, 'CLAUDE.md'));
|
|
142
|
+
results.push({
|
|
143
|
+
depth: depth + 1,
|
|
144
|
+
path: relPath,
|
|
145
|
+
files: fileCount,
|
|
146
|
+
types,
|
|
147
|
+
has_claude: hasClaude
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
// Recurse into subdirectories
|
|
151
|
+
scanDirectories(basePath, fullPath, depth + 1, gitignorePatterns, results);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
catch (e) {
|
|
155
|
+
// Ignore permission errors, etc.
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Format output as list (default)
|
|
160
|
+
*/
|
|
161
|
+
function formatList(results) {
|
|
162
|
+
// Sort by depth descending (deepest first)
|
|
163
|
+
results.sort((a, b) => b.depth - a.depth);
|
|
164
|
+
return results.map(r => `depth:${r.depth}|path:${r.path}|files:${r.files}|types:[${r.types.join(',')}]|has_claude:${r.has_claude ? 'yes' : 'no'}`).join('\n');
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Format output as grouped
|
|
168
|
+
*/
|
|
169
|
+
function formatGrouped(results) {
|
|
170
|
+
// Sort by depth descending
|
|
171
|
+
results.sort((a, b) => b.depth - a.depth);
|
|
172
|
+
const maxDepth = results.length > 0 ? Math.max(...results.map(r => r.depth)) : 0;
|
|
173
|
+
const lines = ['Modules by depth (deepest first):'];
|
|
174
|
+
for (let d = maxDepth; d >= 0; d--) {
|
|
175
|
+
const atDepth = results.filter(r => r.depth === d);
|
|
176
|
+
if (atDepth.length > 0) {
|
|
177
|
+
lines.push(` Depth ${d}:`);
|
|
178
|
+
atDepth.forEach(r => {
|
|
179
|
+
const claudeIndicator = r.has_claude ? ' [OK]' : '';
|
|
180
|
+
lines.push(` - ${r.path}${claudeIndicator}`);
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return lines.join('\n');
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Format output as JSON
|
|
188
|
+
*/
|
|
189
|
+
function formatJson(results) {
|
|
190
|
+
// Sort by depth descending
|
|
191
|
+
results.sort((a, b) => b.depth - a.depth);
|
|
192
|
+
const maxDepth = results.length > 0 ? Math.max(...results.map(r => r.depth)) : 0;
|
|
193
|
+
const modules = {};
|
|
194
|
+
for (let d = maxDepth; d >= 0; d--) {
|
|
195
|
+
const atDepth = results.filter(r => r.depth === d);
|
|
196
|
+
if (atDepth.length > 0) {
|
|
197
|
+
modules[d] = atDepth.map(r => ({
|
|
198
|
+
path: r.path,
|
|
199
|
+
has_claude: r.has_claude
|
|
200
|
+
}));
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return JSON.stringify({
|
|
204
|
+
max_depth: maxDepth,
|
|
205
|
+
modules
|
|
206
|
+
}, null, 2);
|
|
207
|
+
}
|
|
208
|
+
// Tool schema for MCP
|
|
209
|
+
export const schema = {
|
|
210
|
+
name: 'get_modules_by_depth',
|
|
211
|
+
description: `Scan project structure and organize modules by directory depth (deepest first).
|
|
212
|
+
Respects .gitignore patterns and excludes common system directories.
|
|
213
|
+
Output formats: list (pipe-delimited), grouped (human-readable), json.`,
|
|
214
|
+
inputSchema: {
|
|
215
|
+
type: 'object',
|
|
216
|
+
properties: {
|
|
217
|
+
format: {
|
|
218
|
+
type: 'string',
|
|
219
|
+
enum: ['list', 'grouped', 'json'],
|
|
220
|
+
description: 'Output format (default: list)',
|
|
221
|
+
default: 'list'
|
|
222
|
+
},
|
|
223
|
+
path: {
|
|
224
|
+
type: 'string',
|
|
225
|
+
description: 'Target directory path (default: current directory)',
|
|
226
|
+
default: '.'
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
required: []
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
// Handler function
|
|
233
|
+
export async function handler(params) {
|
|
234
|
+
const parsed = ParamsSchema.safeParse(params);
|
|
235
|
+
if (!parsed.success) {
|
|
236
|
+
return { success: false, error: `Invalid params: ${parsed.error.message}` };
|
|
237
|
+
}
|
|
238
|
+
const { format, path: targetPath } = parsed.data;
|
|
239
|
+
try {
|
|
240
|
+
const basePath = resolve(process.cwd(), targetPath);
|
|
241
|
+
if (!existsSync(basePath)) {
|
|
242
|
+
return { success: false, error: `Directory not found: ${basePath}` };
|
|
243
|
+
}
|
|
244
|
+
const stat = statSync(basePath);
|
|
245
|
+
if (!stat.isDirectory()) {
|
|
246
|
+
return { success: false, error: `Not a directory: ${basePath}` };
|
|
247
|
+
}
|
|
248
|
+
// Parse gitignore
|
|
249
|
+
const gitignorePatterns = parseGitignore(basePath);
|
|
250
|
+
// Collect results
|
|
251
|
+
const results = [];
|
|
252
|
+
// Check root directory
|
|
253
|
+
const rootFileCount = countFiles(basePath);
|
|
254
|
+
if (rootFileCount > 0) {
|
|
255
|
+
results.push({
|
|
256
|
+
depth: 0,
|
|
257
|
+
path: '.',
|
|
258
|
+
files: rootFileCount,
|
|
259
|
+
types: getFileTypes(basePath),
|
|
260
|
+
has_claude: existsSync(join(basePath, 'CLAUDE.md'))
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
// Scan subdirectories
|
|
264
|
+
scanDirectories(basePath, basePath, 0, gitignorePatterns, results);
|
|
265
|
+
// Format output
|
|
266
|
+
let output;
|
|
267
|
+
switch (format) {
|
|
268
|
+
case 'grouped':
|
|
269
|
+
output = formatGrouped(results);
|
|
270
|
+
break;
|
|
271
|
+
case 'json':
|
|
272
|
+
output = formatJson(results);
|
|
273
|
+
break;
|
|
274
|
+
case 'list':
|
|
275
|
+
default:
|
|
276
|
+
output = formatList(results);
|
|
277
|
+
break;
|
|
278
|
+
}
|
|
279
|
+
return {
|
|
280
|
+
success: true,
|
|
281
|
+
result: {
|
|
282
|
+
format,
|
|
283
|
+
total_modules: results.length,
|
|
284
|
+
max_depth: results.length > 0 ? Math.max(...results.map(r => r.depth)) : 0,
|
|
285
|
+
output
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
catch (error) {
|
|
290
|
+
return {
|
|
291
|
+
success: false,
|
|
292
|
+
error: `Failed to scan modules: ${error.message}`
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
//# sourceMappingURL=get-modules-by-depth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-modules-by-depth.js","sourceRoot":"","sources":["../../src/tools/get-modules-by-depth.ts"],"names":[],"mappings":"AAAA;;;GAGG;A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E,iBAAiB,EAAE,OAAO,CAAC,CAAC;QAEnE,gBAAgB;QAChB,IAAI,MAAc,CAAC;QACnB,QAAQ,MAAM,EAAE,CAAC;YACf,KAAK,SAAS;gBACZ,MAAM,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;gBAChC,MAAM;YACR,KAAK,MAAM;gBACT,MAAM,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;gBAC7B,MAAM;YACR,KAAK,MAAM,CAAC;YACZ;gBACE,MAAM,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;gBAC7B,MAAM;QACV,CAAC;QAED,OAAO;YACL,OAAO,EAAE,IAAI;YACb,MAAM,EAAE;gBACN,MAAM;gBACN,aAAa,EAAE,OAAO,CAAC,MAAM;gBAC7B,SAAS,EAAE,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC1E,MAAM;aACP;SACF,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,2BAA4B,KAAe,CAAC,OAAO,EAAE;SAC7D,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Registry - MCP-like tool system for CCW
|
|
3
|
+
* Provides tool discovery, validation, and execution
|
|
4
|
+
*/
|
|
5
|
+
import type { ToolSchema } from '../types/tool.js';
|
|
6
|
+
import type { ProgressInfo } from './codex-lens.js';
|
|
7
|
+
interface LegacyTool {
|
|
8
|
+
name: string;
|
|
9
|
+
description: string;
|
|
10
|
+
parameters: {
|
|
11
|
+
type: string;
|
|
12
|
+
properties: Record<string, unknown>;
|
|
13
|
+
required?: string[];
|
|
14
|
+
};
|
|
15
|
+
execute: (params: Record<string, unknown>) => Promise<unknown>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Register a tool in the registry
|
|
19
|
+
*/
|
|
20
|
+
declare function registerTool(tool: LegacyTool): void;
|
|
21
|
+
/**
|
|
22
|
+
* Get all registered tools
|
|
23
|
+
*/
|
|
24
|
+
export declare function listTools(): Array<Omit<LegacyTool, 'execute'>>;
|
|
25
|
+
/**
|
|
26
|
+
* Get a specific tool by name
|
|
27
|
+
*/
|
|
28
|
+
export declare function getTool(name: string): LegacyTool | null;
|
|
29
|
+
/**
|
|
30
|
+
* Execute a tool with given parameters
|
|
31
|
+
*/
|
|
32
|
+
export declare function executeTool(name: string, params?: Record<string, unknown>): Promise<{
|
|
33
|
+
success: boolean;
|
|
34
|
+
result?: unknown;
|
|
35
|
+
error?: string;
|
|
36
|
+
}>;
|
|
37
|
+
/**
|
|
38
|
+
* Execute a tool with progress callback (for init actions)
|
|
39
|
+
*/
|
|
40
|
+
export declare function executeToolWithProgress(name: string, params?: Record<string, unknown>, onProgress?: (progress: ProgressInfo) => void): Promise<{
|
|
41
|
+
success: boolean;
|
|
42
|
+
result?: unknown;
|
|
43
|
+
error?: string;
|
|
44
|
+
}>;
|
|
45
|
+
/**
|
|
46
|
+
* Get tool schema in MCP-compatible format
|
|
47
|
+
*/
|
|
48
|
+
export declare function getToolSchema(name: string): ToolSchema | null;
|
|
49
|
+
/**
|
|
50
|
+
* Get all tool schemas in MCP-compatible format
|
|
51
|
+
*/
|
|
52
|
+
export declare function getAllToolSchemas(): ToolSchema[];
|
|
53
|
+
export { registerTool };
|
|
54
|
+
export type { ToolSchema };
|
|
55
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAc,MAAM,kBAAkB,CAAC;AAkB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yCD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAa7D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,UAAU,EAAE,CAEhD;AAwBD,OAAO,EAAE,YAAY,EAAE,CAAC;AAGxB,YAAY,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Registry - MCP-like tool system for CCW
|
|
3
|
+
* Provides tool discovery, validation, and execution
|
|
4
|
+
*/
|
|
5
|
+
import http from 'http';
|
|
6
|
+
// Import TypeScript migrated tools (schema + handler)
|
|
7
|
+
import * as editFileMod from './edit-file.js';
|
|
8
|
+
import * as writeFileMod from './write-file.js';
|
|
9
|
+
import * as getModulesByDepthMod from './get-modules-by-depth.js';
|
|
10
|
+
import * as classifyFoldersMod from './classify-folders.js';
|
|
11
|
+
import * as detectChangedModulesMod from './detect-changed-modules.js';
|
|
12
|
+
import * as discoverDesignFilesMod from './discover-design-files.js';
|
|
13
|
+
import * as generateModuleDocsMod from './generate-module-docs.js';
|
|
14
|
+
import * as convertTokensToCssMod from './convert-tokens-to-css.js';
|
|
15
|
+
import * as sessionManagerMod from './session-manager.js';
|
|
16
|
+
import * as cliExecutorMod from './cli-executor.js';
|
|
17
|
+
import * as smartSearchMod from './smart-search.js';
|
|
18
|
+
import { executeInitWithProgress } from './smart-search.js';
|
|
19
|
+
// codex_lens removed - functionality integrated into smart_search
|
|
20
|
+
import * as readFileMod from './read-file.js';
|
|
21
|
+
import * as coreMemoryMod from './core-memory.js';
|
|
22
|
+
// Import legacy JS tools
|
|
23
|
+
import { uiGeneratePreviewTool } from './ui-generate-preview.js';
|
|
24
|
+
import { uiInstantiatePrototypesTool } from './ui-instantiate-prototypes.js';
|
|
25
|
+
import { updateModuleClaudeTool } from './update-module-claude.js';
|
|
26
|
+
// Tool registry
|
|
27
|
+
const tools = new Map();
|
|
28
|
+
// Dashboard notification settings
|
|
29
|
+
const DASHBOARD_PORT = process.env.CCW_PORT || 3456;
|
|
30
|
+
/**
|
|
31
|
+
* Notify dashboard of tool execution events (fire and forget)
|
|
32
|
+
*/
|
|
33
|
+
function notifyDashboard(data) {
|
|
34
|
+
const payload = JSON.stringify({
|
|
35
|
+
type: 'tool_execution',
|
|
36
|
+
...data,
|
|
37
|
+
timestamp: new Date().toISOString()
|
|
38
|
+
});
|
|
39
|
+
const req = http.request({
|
|
40
|
+
hostname: 'localhost',
|
|
41
|
+
port: Number(DASHBOARD_PORT),
|
|
42
|
+
path: '/api/hook',
|
|
43
|
+
method: 'POST',
|
|
44
|
+
headers: {
|
|
45
|
+
'Content-Type': 'application/json',
|
|
46
|
+
'Content-Length': Buffer.byteLength(payload)
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
// Fire and forget - log errors only in debug mode
|
|
50
|
+
req.on('error', (err) => {
|
|
51
|
+
if (process.env.DEBUG)
|
|
52
|
+
console.error('[Dashboard] Tool notification failed:', err.message);
|
|
53
|
+
});
|
|
54
|
+
req.write(payload);
|
|
55
|
+
req.end();
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Convert new-style tool (schema + handler) to legacy format
|
|
59
|
+
*/
|
|
60
|
+
function toLegacyTool(mod) {
|
|
61
|
+
return {
|
|
62
|
+
name: mod.schema.name,
|
|
63
|
+
description: mod.schema.description,
|
|
64
|
+
parameters: {
|
|
65
|
+
type: 'object',
|
|
66
|
+
properties: mod.schema.inputSchema?.properties || {},
|
|
67
|
+
required: mod.schema.inputSchema?.required || []
|
|
68
|
+
},
|
|
69
|
+
execute: async (params) => {
|
|
70
|
+
const result = await mod.handler(params);
|
|
71
|
+
if (!result.success) {
|
|
72
|
+
throw new Error(result.error);
|
|
73
|
+
}
|
|
74
|
+
return result.result;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Register a tool in the registry
|
|
80
|
+
*/
|
|
81
|
+
function registerTool(tool) {
|
|
82
|
+
if (!tool.name || !tool.execute) {
|
|
83
|
+
throw new Error('Tool must have name and execute function');
|
|
84
|
+
}
|
|
85
|
+
tools.set(tool.name, tool);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Get all registered tools
|
|
89
|
+
*/
|
|
90
|
+
export function listTools() {
|
|
91
|
+
return Array.from(tools.values()).map(tool => ({
|
|
92
|
+
name: tool.name,
|
|
93
|
+
description: tool.description,
|
|
94
|
+
parameters: tool.parameters
|
|
95
|
+
}));
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Get a specific tool by name
|
|
99
|
+
*/
|
|
100
|
+
export function getTool(name) {
|
|
101
|
+
return tools.get(name) || null;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Validate parameters against tool schema
|
|
105
|
+
*/
|
|
106
|
+
function validateParams(tool, params) {
|
|
107
|
+
const errors = [];
|
|
108
|
+
const schema = tool.parameters;
|
|
109
|
+
if (!schema || !schema.properties) {
|
|
110
|
+
return { valid: true, errors: [] };
|
|
111
|
+
}
|
|
112
|
+
// Check required parameters
|
|
113
|
+
const required = schema.required || [];
|
|
114
|
+
for (const req of required) {
|
|
115
|
+
if (params[req] === undefined || params[req] === null) {
|
|
116
|
+
errors.push(`Missing required parameter: ${req}`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
// Type validation
|
|
120
|
+
for (const [key, value] of Object.entries(params)) {
|
|
121
|
+
const propSchema = schema.properties[key];
|
|
122
|
+
if (!propSchema) {
|
|
123
|
+
continue; // Allow extra params
|
|
124
|
+
}
|
|
125
|
+
if (propSchema.type === 'string' && typeof value !== 'string') {
|
|
126
|
+
errors.push(`Parameter '${key}' must be a string`);
|
|
127
|
+
}
|
|
128
|
+
if (propSchema.type === 'boolean' && typeof value !== 'boolean') {
|
|
129
|
+
errors.push(`Parameter '${key}' must be a boolean`);
|
|
130
|
+
}
|
|
131
|
+
if (propSchema.type === 'number' && typeof value !== 'number') {
|
|
132
|
+
errors.push(`Parameter '${key}' must be a number`);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return { valid: errors.length === 0, errors };
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Execute a tool with given parameters
|
|
139
|
+
*/
|
|
140
|
+
export async function executeTool(name, params = {}) {
|
|
141
|
+
const tool = tools.get(name);
|
|
142
|
+
if (!tool) {
|
|
143
|
+
return {
|
|
144
|
+
success: false,
|
|
145
|
+
error: `Tool not found: ${name}`
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
// Validate parameters
|
|
149
|
+
const validation = validateParams(tool, params);
|
|
150
|
+
if (!validation.valid) {
|
|
151
|
+
return {
|
|
152
|
+
success: false,
|
|
153
|
+
error: `Parameter validation failed: ${validation.errors.join(', ')}`
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
// Notify dashboard - execution started
|
|
157
|
+
notifyDashboard({
|
|
158
|
+
toolName: name,
|
|
159
|
+
status: 'started',
|
|
160
|
+
params: sanitizeParams(params)
|
|
161
|
+
});
|
|
162
|
+
// Execute tool
|
|
163
|
+
try {
|
|
164
|
+
const result = await tool.execute(params);
|
|
165
|
+
// Notify dashboard - execution completed
|
|
166
|
+
notifyDashboard({
|
|
167
|
+
toolName: name,
|
|
168
|
+
status: 'completed',
|
|
169
|
+
result: sanitizeResult(result)
|
|
170
|
+
});
|
|
171
|
+
return {
|
|
172
|
+
success: true,
|
|
173
|
+
result
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
catch (error) {
|
|
177
|
+
// Notify dashboard - execution failed
|
|
178
|
+
notifyDashboard({
|
|
179
|
+
toolName: name,
|
|
180
|
+
status: 'failed',
|
|
181
|
+
error: error.message || 'Tool execution failed'
|
|
182
|
+
});
|
|
183
|
+
return {
|
|
184
|
+
success: false,
|
|
185
|
+
error: error.message || 'Tool execution failed'
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Sanitize params for notification (truncate large values)
|
|
191
|
+
*/
|
|
192
|
+
function sanitizeParams(params) {
|
|
193
|
+
const sanitized = {};
|
|
194
|
+
for (const [key, value] of Object.entries(params)) {
|
|
195
|
+
if (typeof value === 'string' && value.length > 200) {
|
|
196
|
+
sanitized[key] = value.substring(0, 200) + '...';
|
|
197
|
+
}
|
|
198
|
+
else if (typeof value === 'object' && value !== null) {
|
|
199
|
+
sanitized[key] = '[Object]';
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
sanitized[key] = value;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return sanitized;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Sanitize result for notification (truncate large values)
|
|
209
|
+
*/
|
|
210
|
+
function sanitizeResult(result) {
|
|
211
|
+
if (result === null || result === undefined)
|
|
212
|
+
return result;
|
|
213
|
+
const str = JSON.stringify(result);
|
|
214
|
+
if (str.length > 500) {
|
|
215
|
+
return { _truncated: true, preview: str.substring(0, 500) + '...' };
|
|
216
|
+
}
|
|
217
|
+
return result;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Execute a tool with progress callback (for init actions)
|
|
221
|
+
*/
|
|
222
|
+
export async function executeToolWithProgress(name, params = {}, onProgress) {
|
|
223
|
+
// For smart_search init, use special progress-aware execution
|
|
224
|
+
if (name === 'smart_search' && params.action === 'init') {
|
|
225
|
+
try {
|
|
226
|
+
// Notify dashboard - execution started
|
|
227
|
+
notifyDashboard({
|
|
228
|
+
toolName: name,
|
|
229
|
+
status: 'started',
|
|
230
|
+
params: sanitizeParams(params)
|
|
231
|
+
});
|
|
232
|
+
const result = await executeInitWithProgress(params, onProgress);
|
|
233
|
+
// Notify dashboard - execution completed
|
|
234
|
+
notifyDashboard({
|
|
235
|
+
toolName: name,
|
|
236
|
+
status: 'completed',
|
|
237
|
+
result: sanitizeResult(result)
|
|
238
|
+
});
|
|
239
|
+
return {
|
|
240
|
+
success: result.success,
|
|
241
|
+
result,
|
|
242
|
+
error: result.error
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
catch (error) {
|
|
246
|
+
notifyDashboard({
|
|
247
|
+
toolName: name,
|
|
248
|
+
status: 'failed',
|
|
249
|
+
error: error.message || 'Tool execution failed'
|
|
250
|
+
});
|
|
251
|
+
return {
|
|
252
|
+
success: false,
|
|
253
|
+
error: error.message || 'Tool execution failed'
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
// Fall back to regular execution for other tools
|
|
258
|
+
return executeTool(name, params);
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Get tool schema in MCP-compatible format
|
|
262
|
+
*/
|
|
263
|
+
export function getToolSchema(name) {
|
|
264
|
+
const tool = tools.get(name);
|
|
265
|
+
if (!tool)
|
|
266
|
+
return null;
|
|
267
|
+
return {
|
|
268
|
+
name: tool.name,
|
|
269
|
+
description: tool.description,
|
|
270
|
+
inputSchema: {
|
|
271
|
+
type: 'object',
|
|
272
|
+
properties: tool.parameters?.properties || {},
|
|
273
|
+
required: tool.parameters?.required || []
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Get all tool schemas in MCP-compatible format
|
|
279
|
+
*/
|
|
280
|
+
export function getAllToolSchemas() {
|
|
281
|
+
return Array.from(tools.keys()).map(name => getToolSchema(name)).filter((s) => s !== null);
|
|
282
|
+
}
|
|
283
|
+
// Register TypeScript migrated tools
|
|
284
|
+
registerTool(toLegacyTool(editFileMod));
|
|
285
|
+
registerTool(toLegacyTool(writeFileMod));
|
|
286
|
+
registerTool(toLegacyTool(getModulesByDepthMod));
|
|
287
|
+
registerTool(toLegacyTool(classifyFoldersMod));
|
|
288
|
+
registerTool(toLegacyTool(detectChangedModulesMod));
|
|
289
|
+
registerTool(toLegacyTool(discoverDesignFilesMod));
|
|
290
|
+
registerTool(toLegacyTool(generateModuleDocsMod));
|
|
291
|
+
registerTool(toLegacyTool(convertTokensToCssMod));
|
|
292
|
+
registerTool(toLegacyTool(sessionManagerMod));
|
|
293
|
+
registerTool(toLegacyTool(cliExecutorMod));
|
|
294
|
+
registerTool(toLegacyTool(smartSearchMod));
|
|
295
|
+
// codex_lens removed - functionality integrated into smart_search
|
|
296
|
+
registerTool(toLegacyTool(readFileMod));
|
|
297
|
+
registerTool(toLegacyTool(coreMemoryMod));
|
|
298
|
+
// Register legacy JS tools
|
|
299
|
+
registerTool(uiGeneratePreviewTool);
|
|
300
|
+
registerTool(uiInstantiatePrototypesTool);
|
|
301
|
+
registerTool(updateModuleClaudeTool);
|
|
302
|
+
// Export for external tool registration
|
|
303
|
+
export { registerTool };
|
|
304
|
+
//# sourceMappingURL=index.js.map
|