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,619 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI Command - Unified CLI tool executor command
|
|
3
|
+
* Provides interface for executing Gemini, Qwen, and Codex
|
|
4
|
+
*/
|
|
5
|
+
import chalk from 'chalk';
|
|
6
|
+
import http from 'http';
|
|
7
|
+
import { cliExecutorTool, getCliToolsStatus, getExecutionHistoryAsync, getConversationDetail } from '../tools/cli-executor.js';
|
|
8
|
+
import { getStorageStats, getStorageConfig, cleanProjectStorage, cleanAllStorage, formatBytes, formatTimeAgo, resolveProjectId, projectExists, getStorageLocationInstructions } from '../tools/storage-manager.js';
|
|
9
|
+
// Dashboard notification settings
|
|
10
|
+
const DASHBOARD_PORT = process.env.CCW_PORT || 3456;
|
|
11
|
+
/**
|
|
12
|
+
* Notify dashboard of CLI execution events (fire and forget)
|
|
13
|
+
*/
|
|
14
|
+
function notifyDashboard(data) {
|
|
15
|
+
const payload = JSON.stringify({
|
|
16
|
+
type: 'cli_execution',
|
|
17
|
+
...data,
|
|
18
|
+
timestamp: new Date().toISOString()
|
|
19
|
+
});
|
|
20
|
+
const req = http.request({
|
|
21
|
+
hostname: 'localhost',
|
|
22
|
+
port: Number(DASHBOARD_PORT),
|
|
23
|
+
path: '/api/hook',
|
|
24
|
+
method: 'POST',
|
|
25
|
+
timeout: 2000, // 2 second timeout to prevent hanging
|
|
26
|
+
headers: {
|
|
27
|
+
'Content-Type': 'application/json',
|
|
28
|
+
'Content-Length': Buffer.byteLength(payload)
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
// Fire and forget - don't block process exit
|
|
32
|
+
req.on('socket', (socket) => {
|
|
33
|
+
socket.unref(); // Allow process to exit even if socket is open
|
|
34
|
+
});
|
|
35
|
+
req.on('error', (err) => {
|
|
36
|
+
if (process.env.DEBUG)
|
|
37
|
+
console.error('[Dashboard] CLI notification failed:', err.message);
|
|
38
|
+
});
|
|
39
|
+
req.on('timeout', () => {
|
|
40
|
+
req.destroy();
|
|
41
|
+
if (process.env.DEBUG)
|
|
42
|
+
console.error('[Dashboard] CLI notification timed out');
|
|
43
|
+
});
|
|
44
|
+
req.write(payload);
|
|
45
|
+
req.end();
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Show storage information and management options
|
|
49
|
+
*/
|
|
50
|
+
async function storageAction(subAction, options) {
|
|
51
|
+
switch (subAction) {
|
|
52
|
+
case 'info':
|
|
53
|
+
case undefined:
|
|
54
|
+
await showStorageInfo();
|
|
55
|
+
break;
|
|
56
|
+
case 'clean':
|
|
57
|
+
await cleanStorage(options);
|
|
58
|
+
break;
|
|
59
|
+
case 'config':
|
|
60
|
+
showStorageConfig();
|
|
61
|
+
break;
|
|
62
|
+
default:
|
|
63
|
+
showStorageHelp();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Show storage information
|
|
68
|
+
*/
|
|
69
|
+
async function showStorageInfo() {
|
|
70
|
+
console.log(chalk.bold.cyan('\n CCW Storage Information\n'));
|
|
71
|
+
const config = getStorageConfig();
|
|
72
|
+
const stats = getStorageStats();
|
|
73
|
+
// Configuration
|
|
74
|
+
console.log(chalk.bold.white(' Location:'));
|
|
75
|
+
console.log(` ${chalk.cyan(stats.rootPath)}`);
|
|
76
|
+
if (config.isCustom) {
|
|
77
|
+
console.log(chalk.gray(` (Custom: CCW_DATA_DIR=${config.envVar})`));
|
|
78
|
+
}
|
|
79
|
+
console.log();
|
|
80
|
+
// Summary
|
|
81
|
+
console.log(chalk.bold.white(' Summary:'));
|
|
82
|
+
console.log(` Total Size: ${chalk.yellow(formatBytes(stats.totalSize))}`);
|
|
83
|
+
console.log(` Projects: ${chalk.yellow(stats.projectCount.toString())}`);
|
|
84
|
+
console.log(` Global DB: ${stats.globalDb.exists ? chalk.green(formatBytes(stats.globalDb.size)) : chalk.gray('Not created')}`);
|
|
85
|
+
console.log();
|
|
86
|
+
// Projects breakdown
|
|
87
|
+
if (stats.projects.length > 0) {
|
|
88
|
+
console.log(chalk.bold.white(' Projects:'));
|
|
89
|
+
console.log(chalk.gray(' ID Size History Last Used'));
|
|
90
|
+
console.log(chalk.gray(' ─────────────────────────────────────────────────────'));
|
|
91
|
+
for (const project of stats.projects) {
|
|
92
|
+
const historyInfo = project.cliHistory.recordCount !== undefined
|
|
93
|
+
? `${project.cliHistory.recordCount} records`
|
|
94
|
+
: (project.cliHistory.exists ? 'Yes' : '-');
|
|
95
|
+
console.log(` ${chalk.dim(project.projectId)} ` +
|
|
96
|
+
`${formatBytes(project.totalSize).padStart(8)} ` +
|
|
97
|
+
`${historyInfo.padStart(10)} ` +
|
|
98
|
+
`${chalk.gray(formatTimeAgo(project.lastModified))}`);
|
|
99
|
+
}
|
|
100
|
+
console.log();
|
|
101
|
+
}
|
|
102
|
+
// Usage tips
|
|
103
|
+
console.log(chalk.gray(' Commands:'));
|
|
104
|
+
console.log(chalk.gray(' ccw cli storage clean Clean all storage'));
|
|
105
|
+
console.log(chalk.gray(' ccw cli storage clean --project <path> Clean specific project'));
|
|
106
|
+
console.log(chalk.gray(' ccw cli storage config Show location config'));
|
|
107
|
+
console.log();
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Clean storage
|
|
111
|
+
*/
|
|
112
|
+
async function cleanStorage(options) {
|
|
113
|
+
const { all, project, force, cliHistory, memory, cache, config } = options;
|
|
114
|
+
// Determine what to clean
|
|
115
|
+
const cleanTypes = {
|
|
116
|
+
cliHistory: cliHistory || (!cliHistory && !memory && !cache && !config),
|
|
117
|
+
memory: memory || (!cliHistory && !memory && !cache && !config),
|
|
118
|
+
cache: cache || (!cliHistory && !memory && !cache && !config),
|
|
119
|
+
config: config || false, // Config requires explicit flag
|
|
120
|
+
all: !cliHistory && !memory && !cache && !config
|
|
121
|
+
};
|
|
122
|
+
if (project) {
|
|
123
|
+
// Clean specific project
|
|
124
|
+
const projectId = resolveProjectId(project);
|
|
125
|
+
if (!projectExists(projectId)) {
|
|
126
|
+
console.log(chalk.yellow(`\n No storage found for project: ${project}`));
|
|
127
|
+
console.log(chalk.gray(` (Project ID: ${projectId})\n`));
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
if (!force) {
|
|
131
|
+
console.log(chalk.bold.yellow('\n Warning: This will delete storage for project:'));
|
|
132
|
+
console.log(` Path: ${project}`);
|
|
133
|
+
console.log(` ID: ${projectId}`);
|
|
134
|
+
console.log(chalk.gray('\n Use --force to confirm deletion.\n'));
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
console.log(chalk.bold.cyan('\n Cleaning project storage...\n'));
|
|
138
|
+
const result = cleanProjectStorage(projectId, cleanTypes);
|
|
139
|
+
if (result.success) {
|
|
140
|
+
console.log(chalk.green(` ✓ Cleaned ${formatBytes(result.freedBytes)}`));
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
console.log(chalk.red(' ✗ Cleanup completed with errors:'));
|
|
144
|
+
for (const err of result.errors) {
|
|
145
|
+
console.log(chalk.red(` - ${err}`));
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
// Clean all storage
|
|
151
|
+
const stats = getStorageStats();
|
|
152
|
+
if (stats.projectCount === 0) {
|
|
153
|
+
console.log(chalk.yellow('\n No storage to clean.\n'));
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
if (!force) {
|
|
157
|
+
console.log(chalk.bold.yellow('\n Warning: This will delete ALL CCW storage:'));
|
|
158
|
+
console.log(` Location: ${stats.rootPath}`);
|
|
159
|
+
console.log(` Projects: ${stats.projectCount}`);
|
|
160
|
+
console.log(` Size: ${formatBytes(stats.totalSize)}`);
|
|
161
|
+
console.log(chalk.gray('\n Use --force to confirm deletion.\n'));
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
console.log(chalk.bold.cyan('\n Cleaning all storage...\n'));
|
|
165
|
+
const result = cleanAllStorage(cleanTypes);
|
|
166
|
+
if (result.success) {
|
|
167
|
+
console.log(chalk.green(` ✓ Cleaned ${result.projectsCleaned} projects, freed ${formatBytes(result.freedBytes)}`));
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
console.log(chalk.yellow(` ⚠ Cleaned ${result.projectsCleaned} projects with some errors:`));
|
|
171
|
+
for (const err of result.errors) {
|
|
172
|
+
console.log(chalk.red(` - ${err}`));
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
console.log();
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Show storage configuration
|
|
180
|
+
*/
|
|
181
|
+
function showStorageConfig() {
|
|
182
|
+
console.log(getStorageLocationInstructions());
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Show storage help
|
|
186
|
+
*/
|
|
187
|
+
function showStorageHelp() {
|
|
188
|
+
console.log(chalk.bold.cyan('\n CCW Storage Management\n'));
|
|
189
|
+
console.log(' Subcommands:');
|
|
190
|
+
console.log(chalk.gray(' info Show storage information (default)'));
|
|
191
|
+
console.log(chalk.gray(' clean Clean storage'));
|
|
192
|
+
console.log(chalk.gray(' config Show configuration instructions'));
|
|
193
|
+
console.log();
|
|
194
|
+
console.log(' Clean Options:');
|
|
195
|
+
console.log(chalk.gray(' --project <path> Clean specific project storage'));
|
|
196
|
+
console.log(chalk.gray(' --force Confirm deletion'));
|
|
197
|
+
console.log(chalk.gray(' --cli-history Clean only CLI history'));
|
|
198
|
+
console.log(chalk.gray(' --memory Clean only memory store'));
|
|
199
|
+
console.log(chalk.gray(' --cache Clean only cache'));
|
|
200
|
+
console.log(chalk.gray(' --config Clean config (requires explicit flag)'));
|
|
201
|
+
console.log();
|
|
202
|
+
console.log(' Examples:');
|
|
203
|
+
console.log(chalk.gray(' ccw cli storage # Show storage info'));
|
|
204
|
+
console.log(chalk.gray(' ccw cli storage clean --force # Clean all storage'));
|
|
205
|
+
console.log(chalk.gray(' ccw cli storage clean --project . --force # Clean current project'));
|
|
206
|
+
console.log(chalk.gray(' ccw cli storage config # Show config instructions'));
|
|
207
|
+
console.log();
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Test endpoint for debugging multi-line prompt parsing
|
|
211
|
+
* Shows exactly how Commander.js parsed the arguments
|
|
212
|
+
*/
|
|
213
|
+
function testParseAction(args, options) {
|
|
214
|
+
console.log(chalk.bold.cyan('\n ═══════════════════════════════════════════════'));
|
|
215
|
+
console.log(chalk.bold.cyan(' │ CLI PARSE TEST ENDPOINT │'));
|
|
216
|
+
console.log(chalk.bold.cyan(' ═══════════════════════════════════════════════\n'));
|
|
217
|
+
// Show args array parsing
|
|
218
|
+
console.log(chalk.bold.yellow('📦 Positional Arguments (args[]):'));
|
|
219
|
+
console.log(chalk.gray(' Length: ') + chalk.white(args.length));
|
|
220
|
+
if (args.length === 0) {
|
|
221
|
+
console.log(chalk.gray(' (empty)'));
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
args.forEach((arg, i) => {
|
|
225
|
+
console.log(chalk.gray(` [${i}]: `) + chalk.green(`"${arg}"`));
|
|
226
|
+
// Show if multiline
|
|
227
|
+
if (arg.includes('\n')) {
|
|
228
|
+
console.log(chalk.yellow(` ↳ Contains ${arg.split('\n').length} lines`));
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
console.log();
|
|
233
|
+
// Show options parsing
|
|
234
|
+
console.log(chalk.bold.yellow('⚙️ Options:'));
|
|
235
|
+
const optionEntries = Object.entries(options).filter(([_, v]) => v !== undefined);
|
|
236
|
+
if (optionEntries.length === 0) {
|
|
237
|
+
console.log(chalk.gray(' (none)'));
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
optionEntries.forEach(([key, value]) => {
|
|
241
|
+
const displayValue = typeof value === 'string' && value.includes('\n')
|
|
242
|
+
? `"${value.substring(0, 50)}..." (${value.split('\n').length} lines)`
|
|
243
|
+
: JSON.stringify(value);
|
|
244
|
+
console.log(chalk.gray(` --${key}: `) + chalk.cyan(displayValue));
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
console.log();
|
|
248
|
+
// Show what would be used as prompt
|
|
249
|
+
console.log(chalk.bold.yellow('🎯 Final Prompt Resolution:'));
|
|
250
|
+
const { prompt: optionPrompt, file } = options;
|
|
251
|
+
if (file) {
|
|
252
|
+
console.log(chalk.gray(' Source: ') + chalk.magenta('--file/-f option'));
|
|
253
|
+
console.log(chalk.gray(' File: ') + chalk.cyan(file));
|
|
254
|
+
}
|
|
255
|
+
else if (optionPrompt) {
|
|
256
|
+
console.log(chalk.gray(' Source: ') + chalk.magenta('--prompt/-p option'));
|
|
257
|
+
console.log(chalk.gray(' Value: ') + chalk.green(`"${optionPrompt.substring(0, 100)}${optionPrompt.length > 100 ? '...' : ''}"`));
|
|
258
|
+
if (optionPrompt.includes('\n')) {
|
|
259
|
+
console.log(chalk.yellow(` ↳ Multiline: ${optionPrompt.split('\n').length} lines`));
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
else if (args[0]) {
|
|
263
|
+
console.log(chalk.gray(' Source: ') + chalk.magenta('positional argument (args[0])'));
|
|
264
|
+
console.log(chalk.gray(' Value: ') + chalk.green(`"${args[0].substring(0, 100)}${args[0].length > 100 ? '...' : ''}"`));
|
|
265
|
+
if (args[0].includes('\n')) {
|
|
266
|
+
console.log(chalk.yellow(` ↳ Multiline: ${args[0].split('\n').length} lines`));
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
else {
|
|
270
|
+
console.log(chalk.red(' No prompt found!'));
|
|
271
|
+
}
|
|
272
|
+
console.log();
|
|
273
|
+
// Show raw debug info
|
|
274
|
+
console.log(chalk.bold.yellow('🔍 Raw Debug Info:'));
|
|
275
|
+
console.log(chalk.gray(' process.argv:'));
|
|
276
|
+
process.argv.forEach((arg, i) => {
|
|
277
|
+
console.log(chalk.gray(` [${i}]: `) + chalk.dim(arg.length > 60 ? arg.substring(0, 60) + '...' : arg));
|
|
278
|
+
});
|
|
279
|
+
console.log(chalk.bold.cyan('\n ═══════════════════════════════════════════════\n'));
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Show CLI tool status
|
|
283
|
+
*/
|
|
284
|
+
async function statusAction() {
|
|
285
|
+
console.log(chalk.bold.cyan('\n CLI Tools Status\n'));
|
|
286
|
+
const status = await getCliToolsStatus();
|
|
287
|
+
for (const [tool, info] of Object.entries(status)) {
|
|
288
|
+
const statusIcon = info.available ? chalk.green('●') : chalk.red('○');
|
|
289
|
+
const statusText = info.available ? chalk.green('Available') : chalk.red('Not Found');
|
|
290
|
+
console.log(` ${statusIcon} ${chalk.bold.white(tool.padEnd(10))} ${statusText}`);
|
|
291
|
+
if (info.available && info.path) {
|
|
292
|
+
console.log(chalk.gray(` ${info.path}`));
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
console.log();
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Execute a CLI tool
|
|
299
|
+
* @param {string} prompt - Prompt to execute
|
|
300
|
+
* @param {Object} options - CLI options
|
|
301
|
+
*/
|
|
302
|
+
async function execAction(positionalPrompt, options) {
|
|
303
|
+
const { prompt: optionPrompt, file, tool = 'gemini', mode = 'analysis', model, cd, includeDirs, timeout, noStream, resume, id, noNative } = options;
|
|
304
|
+
// Priority: 1. --file, 2. --prompt/-p option, 3. positional argument
|
|
305
|
+
let finalPrompt;
|
|
306
|
+
if (file) {
|
|
307
|
+
// Read from file
|
|
308
|
+
const { readFileSync, existsSync } = await import('fs');
|
|
309
|
+
const { resolve } = await import('path');
|
|
310
|
+
const filePath = resolve(file);
|
|
311
|
+
if (!existsSync(filePath)) {
|
|
312
|
+
console.error(chalk.red(`Error: File not found: ${filePath}`));
|
|
313
|
+
process.exit(1);
|
|
314
|
+
}
|
|
315
|
+
finalPrompt = readFileSync(filePath, 'utf8').trim();
|
|
316
|
+
if (!finalPrompt) {
|
|
317
|
+
console.error(chalk.red('Error: File is empty'));
|
|
318
|
+
process.exit(1);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
else if (optionPrompt) {
|
|
322
|
+
// Use --prompt/-p option (preferred for multi-line)
|
|
323
|
+
finalPrompt = optionPrompt;
|
|
324
|
+
}
|
|
325
|
+
else {
|
|
326
|
+
// Fall back to positional argument
|
|
327
|
+
finalPrompt = positionalPrompt;
|
|
328
|
+
}
|
|
329
|
+
// Prompt is required unless resuming
|
|
330
|
+
if (!finalPrompt && !resume) {
|
|
331
|
+
console.error(chalk.red('Error: Prompt is required'));
|
|
332
|
+
console.error(chalk.gray('Usage: ccw cli -p "<prompt>" --tool gemini'));
|
|
333
|
+
console.error(chalk.gray(' or: ccw cli -f prompt.txt --tool codex'));
|
|
334
|
+
console.error(chalk.gray(' or: ccw cli --resume --tool gemini'));
|
|
335
|
+
process.exit(1);
|
|
336
|
+
}
|
|
337
|
+
const prompt_to_use = finalPrompt || '';
|
|
338
|
+
// Parse resume IDs for merge scenario
|
|
339
|
+
const resumeIds = resume && typeof resume === 'string' ? resume.split(',').map(s => s.trim()).filter(Boolean) : [];
|
|
340
|
+
const isMerge = resumeIds.length > 1;
|
|
341
|
+
// Show execution mode
|
|
342
|
+
let resumeInfo = '';
|
|
343
|
+
if (isMerge) {
|
|
344
|
+
resumeInfo = ` merging ${resumeIds.length} conversations`;
|
|
345
|
+
}
|
|
346
|
+
else if (resume) {
|
|
347
|
+
resumeInfo = typeof resume === 'string' ? ` resuming ${resume}` : ' resuming last';
|
|
348
|
+
}
|
|
349
|
+
const nativeMode = noNative ? ' (prompt-concat)' : '';
|
|
350
|
+
const idInfo = id ? ` [${id}]` : '';
|
|
351
|
+
console.log(chalk.cyan(`\n Executing ${tool} (${mode} mode${resumeInfo}${nativeMode})${idInfo}...\n`));
|
|
352
|
+
// Show merge details
|
|
353
|
+
if (isMerge) {
|
|
354
|
+
console.log(chalk.gray(' Merging conversations:'));
|
|
355
|
+
for (const rid of resumeIds) {
|
|
356
|
+
console.log(chalk.gray(` • ${rid}`));
|
|
357
|
+
}
|
|
358
|
+
console.log();
|
|
359
|
+
}
|
|
360
|
+
// Notify dashboard: execution started
|
|
361
|
+
notifyDashboard({
|
|
362
|
+
event: 'started',
|
|
363
|
+
tool,
|
|
364
|
+
mode,
|
|
365
|
+
prompt_preview: prompt_to_use.substring(0, 100) + (prompt_to_use.length > 100 ? '...' : ''),
|
|
366
|
+
custom_id: id || null
|
|
367
|
+
});
|
|
368
|
+
// Streaming output handler
|
|
369
|
+
const onOutput = noStream ? null : (chunk) => {
|
|
370
|
+
process.stdout.write(chunk.data);
|
|
371
|
+
};
|
|
372
|
+
try {
|
|
373
|
+
const result = await cliExecutorTool.execute({
|
|
374
|
+
tool,
|
|
375
|
+
prompt: prompt_to_use,
|
|
376
|
+
mode,
|
|
377
|
+
model,
|
|
378
|
+
cd,
|
|
379
|
+
includeDirs,
|
|
380
|
+
timeout: timeout ? parseInt(timeout, 10) : 300000,
|
|
381
|
+
resume,
|
|
382
|
+
id, // custom execution ID
|
|
383
|
+
noNative
|
|
384
|
+
}, onOutput);
|
|
385
|
+
// If not streaming, print output now
|
|
386
|
+
if (noStream && result.stdout) {
|
|
387
|
+
console.log(result.stdout);
|
|
388
|
+
}
|
|
389
|
+
// Print summary with execution ID and turn info
|
|
390
|
+
console.log();
|
|
391
|
+
if (result.success) {
|
|
392
|
+
const turnInfo = result.conversation.turn_count > 1
|
|
393
|
+
? ` (turn ${result.conversation.turn_count})`
|
|
394
|
+
: '';
|
|
395
|
+
console.log(chalk.green(` ✓ Completed in ${(result.execution.duration_ms / 1000).toFixed(1)}s${turnInfo}`));
|
|
396
|
+
console.log(chalk.gray(` ID: ${result.execution.id}`));
|
|
397
|
+
if (isMerge && !id) {
|
|
398
|
+
// Merge without custom ID: updated all source conversations
|
|
399
|
+
console.log(chalk.gray(` Updated ${resumeIds.length} conversations: ${resumeIds.join(', ')}`));
|
|
400
|
+
}
|
|
401
|
+
else if (isMerge && id) {
|
|
402
|
+
// Merge with custom ID: created new merged conversation
|
|
403
|
+
console.log(chalk.gray(` Created merged conversation from ${resumeIds.length} sources`));
|
|
404
|
+
}
|
|
405
|
+
if (result.conversation.turn_count > 1) {
|
|
406
|
+
console.log(chalk.gray(` Total: ${result.conversation.turn_count} turns, ${(result.conversation.total_duration_ms / 1000).toFixed(1)}s`));
|
|
407
|
+
}
|
|
408
|
+
console.log(chalk.dim(` Continue: ccw cli -p "..." --resume ${result.execution.id}`));
|
|
409
|
+
// Notify dashboard: execution completed
|
|
410
|
+
notifyDashboard({
|
|
411
|
+
event: 'completed',
|
|
412
|
+
tool,
|
|
413
|
+
mode,
|
|
414
|
+
execution_id: result.execution.id,
|
|
415
|
+
success: true,
|
|
416
|
+
duration_ms: result.execution.duration_ms,
|
|
417
|
+
turn_count: result.conversation.turn_count
|
|
418
|
+
});
|
|
419
|
+
// Ensure clean exit after successful execution
|
|
420
|
+
process.exit(0);
|
|
421
|
+
}
|
|
422
|
+
else {
|
|
423
|
+
console.log(chalk.red(` ✗ Failed (${result.execution.status})`));
|
|
424
|
+
console.log(chalk.gray(` ID: ${result.execution.id}`));
|
|
425
|
+
if (result.stderr) {
|
|
426
|
+
console.error(chalk.red(result.stderr));
|
|
427
|
+
}
|
|
428
|
+
// Notify dashboard: execution failccw cli -p
|
|
429
|
+
notifyDashboard({
|
|
430
|
+
event: 'completed',
|
|
431
|
+
tool,
|
|
432
|
+
mode,
|
|
433
|
+
execution_id: result.execution.id,
|
|
434
|
+
success: false,
|
|
435
|
+
status: result.execution.status,
|
|
436
|
+
duration_ms: result.execution.duration_ms
|
|
437
|
+
});
|
|
438
|
+
process.exit(1);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
catch (error) {
|
|
442
|
+
const err = error;
|
|
443
|
+
console.error(chalk.red(` Error: ${err.message}`));
|
|
444
|
+
// Notify dashboard: execution error
|
|
445
|
+
notifyDashboard({
|
|
446
|
+
event: 'error',
|
|
447
|
+
tool,
|
|
448
|
+
mode,
|
|
449
|
+
error: err.message
|
|
450
|
+
});
|
|
451
|
+
process.exit(1);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Show execution history
|
|
456
|
+
* @param {Object} options - CLI options
|
|
457
|
+
*/
|
|
458
|
+
async function historyAction(options) {
|
|
459
|
+
const { limit = '20', tool, status } = options;
|
|
460
|
+
console.log(chalk.bold.cyan('\n CLI Execution History\n'));
|
|
461
|
+
const history = await getExecutionHistoryAsync(process.cwd(), { limit: parseInt(limit, 10), tool, status });
|
|
462
|
+
if (history.executions.length === 0) {
|
|
463
|
+
console.log(chalk.gray(' No executions found.\n'));
|
|
464
|
+
return;
|
|
465
|
+
}
|
|
466
|
+
console.log(chalk.gray(` Total executions: ${history.total}\n`));
|
|
467
|
+
for (const exec of history.executions) {
|
|
468
|
+
const statusIcon = exec.status === 'success' ? chalk.green('●') :
|
|
469
|
+
exec.status === 'timeout' ? chalk.yellow('●') : chalk.red('●');
|
|
470
|
+
const duration = exec.duration_ms >= 1000
|
|
471
|
+
? `${(exec.duration_ms / 1000).toFixed(1)}s`
|
|
472
|
+
: `${exec.duration_ms}ms`;
|
|
473
|
+
const timeAgo = getTimeAgo(new Date(exec.updated_at || exec.timestamp));
|
|
474
|
+
const turnInfo = exec.turn_count && exec.turn_count > 1 ? chalk.cyan(` [${exec.turn_count} turns]`) : '';
|
|
475
|
+
console.log(` ${statusIcon} ${chalk.bold.white(exec.tool.padEnd(8))} ${chalk.gray(timeAgo.padEnd(12))} ${chalk.gray(duration.padEnd(8))}${turnInfo}`);
|
|
476
|
+
console.log(chalk.gray(` ${exec.prompt_preview}`));
|
|
477
|
+
console.log(chalk.dim(` ID: ${exec.id}`));
|
|
478
|
+
console.log();
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* Show conversation detail with all turns
|
|
483
|
+
* @param {string} conversationId - Conversation ID
|
|
484
|
+
*/
|
|
485
|
+
async function detailAction(conversationId) {
|
|
486
|
+
if (!conversationId) {
|
|
487
|
+
console.error(chalk.red('Error: Conversation ID is required'));
|
|
488
|
+
console.error(chalk.gray('Usage: ccw cli detail <conversation-id>'));
|
|
489
|
+
process.exit(1);
|
|
490
|
+
}
|
|
491
|
+
const conversation = getConversationDetail(process.cwd(), conversationId);
|
|
492
|
+
if (!conversation) {
|
|
493
|
+
console.error(chalk.red(`Error: Conversation not found: ${conversationId}`));
|
|
494
|
+
process.exit(1);
|
|
495
|
+
}
|
|
496
|
+
console.log(chalk.bold.cyan('\n Conversation Detail\n'));
|
|
497
|
+
console.log(` ${chalk.gray('ID:')} ${conversation.id}`);
|
|
498
|
+
console.log(` ${chalk.gray('Tool:')} ${conversation.tool}`);
|
|
499
|
+
console.log(` ${chalk.gray('Model:')} ${conversation.model}`);
|
|
500
|
+
console.log(` ${chalk.gray('Mode:')} ${conversation.mode}`);
|
|
501
|
+
console.log(` ${chalk.gray('Status:')} ${conversation.latest_status}`);
|
|
502
|
+
console.log(` ${chalk.gray('Turns:')} ${conversation.turn_count}`);
|
|
503
|
+
console.log(` ${chalk.gray('Duration:')} ${(conversation.total_duration_ms / 1000).toFixed(1)}s total`);
|
|
504
|
+
console.log(` ${chalk.gray('Created:')} ${conversation.created_at}`);
|
|
505
|
+
if (conversation.turn_count > 1) {
|
|
506
|
+
console.log(` ${chalk.gray('Updated:')} ${conversation.updated_at}`);
|
|
507
|
+
}
|
|
508
|
+
// Show all turns
|
|
509
|
+
for (const turn of conversation.turns) {
|
|
510
|
+
console.log(chalk.bold.cyan(`\n ═══ Turn ${turn.turn} ═══`));
|
|
511
|
+
console.log(chalk.gray(` ${turn.timestamp} | ${turn.status} | ${(turn.duration_ms / 1000).toFixed(1)}s`));
|
|
512
|
+
console.log(chalk.bold.white('\n Prompt:'));
|
|
513
|
+
console.log(chalk.gray(' ' + turn.prompt.split('\n').join('\n ')));
|
|
514
|
+
if (turn.output.stdout) {
|
|
515
|
+
console.log(chalk.bold.white('\n Output:'));
|
|
516
|
+
console.log(turn.output.stdout);
|
|
517
|
+
}
|
|
518
|
+
if (turn.output.stderr) {
|
|
519
|
+
console.log(chalk.bold.red('\n Errors:'));
|
|
520
|
+
console.log(turn.output.stderr);
|
|
521
|
+
}
|
|
522
|
+
if (turn.output.truncated) {
|
|
523
|
+
console.log(chalk.yellow('\n Note: Output was truncated due to size.'));
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
console.log(chalk.dim(`\n Continue: ccw cli -p "..." --resume ${conversation.id}`));
|
|
527
|
+
console.log();
|
|
528
|
+
}
|
|
529
|
+
/**
|
|
530
|
+
* Get human-readable time ago string
|
|
531
|
+
* @param {Date} date
|
|
532
|
+
* @returns {string}
|
|
533
|
+
*/
|
|
534
|
+
function getTimeAgo(date) {
|
|
535
|
+
const seconds = Math.floor((new Date().getTime() - date.getTime()) / 1000);
|
|
536
|
+
if (seconds < 60)
|
|
537
|
+
return 'just now';
|
|
538
|
+
if (seconds < 3600)
|
|
539
|
+
return `${Math.floor(seconds / 60)}m ago`;
|
|
540
|
+
if (seconds < 86400)
|
|
541
|
+
return `${Math.floor(seconds / 3600)}h ago`;
|
|
542
|
+
if (seconds < 604800)
|
|
543
|
+
return `${Math.floor(seconds / 86400)}d ago`;
|
|
544
|
+
return date.toLocaleDateString();
|
|
545
|
+
}
|
|
546
|
+
/**ccw cli -p
|
|
547
|
+
* CLI command entry point
|
|
548
|
+
* @param {string} subcommand - Subcommand (status, exec, history, detail)
|
|
549
|
+
* @param {string[]} args - Arguments array
|
|
550
|
+
* @param {Object} options - CLI options
|
|
551
|
+
*/
|
|
552
|
+
export async function cliCommand(subcommand, args, options) {
|
|
553
|
+
const argsArray = Array.isArray(args) ? args : (args ? [args] : []);
|
|
554
|
+
switch (subcommand) {
|
|
555
|
+
case 'status':
|
|
556
|
+
await statusAction();
|
|
557
|
+
break;
|
|
558
|
+
case 'history':
|
|
559
|
+
await historyAction(options);
|
|
560
|
+
break;
|
|
561
|
+
case 'detail':
|
|
562
|
+
await detailAction(argsArray[0]);
|
|
563
|
+
break;
|
|
564
|
+
case 'storage':
|
|
565
|
+
await storageAction(argsArray[0], options);
|
|
566
|
+
break;
|
|
567
|
+
case 'test-parse':
|
|
568
|
+
// Test endpoint to debug multi-line prompt parsing
|
|
569
|
+
testParseAction(argsArray, options);
|
|
570
|
+
break;
|
|
571
|
+
default: {
|
|
572
|
+
const execOptions = options;
|
|
573
|
+
// Auto-exec if: has -p/--prompt, has -f/--file, has --resume, or subcommand looks like a prompt
|
|
574
|
+
const hasPromptOption = !!execOptions.prompt;
|
|
575
|
+
const hasFileOption = !!execOptions.file;
|
|
576
|
+
const hasResume = execOptions.resume !== undefined;
|
|
577
|
+
const subcommandIsPrompt = subcommand && !subcommand.startsWith('-');
|
|
578
|
+
if (hasPromptOption || hasFileOption || hasResume || subcommandIsPrompt) {
|
|
579
|
+
// Treat as exec: use subcommand as positional prompt if no -p/-f option
|
|
580
|
+
const positionalPrompt = subcommandIsPrompt ? subcommand : undefined;
|
|
581
|
+
await execAction(positionalPrompt, execOptions);
|
|
582
|
+
}
|
|
583
|
+
else {
|
|
584
|
+
// Show help
|
|
585
|
+
console.log(chalk.bold.cyan('\n CCW CLI Tool Executor\n'));
|
|
586
|
+
console.log(' Unified interface for Gemini, Qwen, and Codex CLI tools.\n');
|
|
587
|
+
console.log(' Usage:');
|
|
588
|
+
console.log(chalk.gray(' ccw cli -p "<prompt>" --tool <tool> Execute with prompt'));
|
|
589
|
+
console.log(chalk.gray(' ccw cli -f prompt.txt --tool <tool> Execute from file'));
|
|
590
|
+
console.log();
|
|
591
|
+
console.log(' Subcommands:');
|
|
592
|
+
console.log(chalk.gray(' status Check CLI tools availability'));
|
|
593
|
+
console.log(chalk.gray(' storage [cmd] Manage CCW storage (info/clean/config)'));
|
|
594
|
+
console.log(chalk.gray(' history Show execution history'));
|
|
595
|
+
console.log(chalk.gray(' detail <id> Show execution detail'));
|
|
596
|
+
console.log(chalk.gray(' test-parse [args] Debug CLI argument parsing'));
|
|
597
|
+
console.log();
|
|
598
|
+
console.log(' Options:');
|
|
599
|
+
console.log(chalk.gray(' -p, --prompt <text> Prompt text'));
|
|
600
|
+
console.log(chalk.gray(' -f, --file <file> Read prompt from file'));
|
|
601
|
+
console.log(chalk.gray(' --tool <tool> Tool: gemini, qwen, codex (default: gemini)'));
|
|
602
|
+
console.log(chalk.gray(' --mode <mode> Mode: analysis, write, auto (default: analysis)'));
|
|
603
|
+
console.log(chalk.gray(' --model <model> Model override'));
|
|
604
|
+
console.log(chalk.gray(' --cd <path> Working directory'));
|
|
605
|
+
console.log(chalk.gray(' --includeDirs <dirs> Additional directories'));
|
|
606
|
+
console.log(chalk.gray(' --timeout <ms> Timeout (default: 300000)'));
|
|
607
|
+
console.log(chalk.gray(' --resume [id] Resume previous session'));
|
|
608
|
+
console.log();
|
|
609
|
+
console.log(' Examples:');
|
|
610
|
+
console.log(chalk.gray(' ccw cli -p "Analyze auth module" --tool gemini'));
|
|
611
|
+
console.log(chalk.gray(' ccw cli -f prompt.txt --tool codex --mode write'));
|
|
612
|
+
console.log(chalk.gray(' ccw cli -p "$(cat template.md)" --tool gemini'));
|
|
613
|
+
console.log(chalk.gray(' ccw cli --resume --tool gemini'));
|
|
614
|
+
console.log();
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
//# sourceMappingURL=cli.js.map
|