@defai.digital/ax-cli 4.4.6 → 4.4.10
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/bin/ax-cli +1 -5
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +158 -9
- package/dist/index.js.map +1 -1
- package/dist/setup.d.ts +27 -0
- package/dist/setup.d.ts.map +1 -0
- package/dist/setup.js +591 -0
- package/dist/setup.js.map +1 -0
- package/package.json +43 -135
- package/LICENSE +0 -22
- package/README.md +0 -387
- package/config-defaults/messages.yaml +0 -75
- package/config-defaults/models.yaml +0 -57
- package/config-defaults/prompts.yaml +0 -948
- package/config-defaults/settings.yaml +0 -157
- package/dist/agent/agent-executor.d.ts +0 -61
- package/dist/agent/agent-executor.js +0 -194
- package/dist/agent/agent-executor.js.map +0 -1
- package/dist/agent/agent-router.d.ts +0 -68
- package/dist/agent/agent-router.js +0 -242
- package/dist/agent/agent-router.js.map +0 -1
- package/dist/agent/context-manager.d.ts +0 -122
- package/dist/agent/context-manager.js +0 -406
- package/dist/agent/context-manager.js.map +0 -1
- package/dist/agent/core/index.d.ts +0 -8
- package/dist/agent/core/index.js +0 -9
- package/dist/agent/core/index.js.map +0 -1
- package/dist/agent/core/types.d.ts +0 -92
- package/dist/agent/core/types.js +0 -11
- package/dist/agent/core/types.js.map +0 -1
- package/dist/agent/dependency-resolver.d.ts +0 -90
- package/dist/agent/dependency-resolver.js +0 -366
- package/dist/agent/dependency-resolver.js.map +0 -1
- package/dist/agent/execution/index.d.ts +0 -9
- package/dist/agent/execution/index.js +0 -9
- package/dist/agent/execution/index.js.map +0 -1
- package/dist/agent/execution/tool-executor.d.ts +0 -93
- package/dist/agent/execution/tool-executor.js +0 -552
- package/dist/agent/execution/tool-executor.js.map +0 -1
- package/dist/agent/index.d.ts +0 -14
- package/dist/agent/index.js +0 -145
- package/dist/agent/index.js.map +0 -1
- package/dist/agent/llm-agent.d.ts +0 -368
- package/dist/agent/llm-agent.js +0 -1931
- package/dist/agent/llm-agent.js.map +0 -1
- package/dist/agent/loop-detector.d.ts +0 -72
- package/dist/agent/loop-detector.js +0 -335
- package/dist/agent/loop-detector.js.map +0 -1
- package/dist/agent/parallel-tools.d.ts +0 -69
- package/dist/agent/parallel-tools.js +0 -188
- package/dist/agent/parallel-tools.js.map +0 -1
- package/dist/agent/planning/index.d.ts +0 -9
- package/dist/agent/planning/index.js +0 -9
- package/dist/agent/planning/index.js.map +0 -1
- package/dist/agent/planning/plan-executor.d.ts +0 -79
- package/dist/agent/planning/plan-executor.js +0 -240
- package/dist/agent/planning/plan-executor.js.map +0 -1
- package/dist/agent/progress-tracker.d.ts +0 -94
- package/dist/agent/progress-tracker.js +0 -225
- package/dist/agent/progress-tracker.js.map +0 -1
- package/dist/agent/specialized/analysis-agent.d.ts +0 -11
- package/dist/agent/specialized/analysis-agent.js +0 -24
- package/dist/agent/specialized/analysis-agent.js.map +0 -1
- package/dist/agent/specialized/debug-agent.d.ts +0 -11
- package/dist/agent/specialized/debug-agent.js +0 -46
- package/dist/agent/specialized/debug-agent.js.map +0 -1
- package/dist/agent/specialized/documentation-agent.d.ts +0 -11
- package/dist/agent/specialized/documentation-agent.js +0 -24
- package/dist/agent/specialized/documentation-agent.js.map +0 -1
- package/dist/agent/specialized/index.d.ts +0 -11
- package/dist/agent/specialized/index.js +0 -12
- package/dist/agent/specialized/index.js.map +0 -1
- package/dist/agent/specialized/performance-agent.d.ts +0 -11
- package/dist/agent/specialized/performance-agent.js +0 -24
- package/dist/agent/specialized/performance-agent.js.map +0 -1
- package/dist/agent/specialized/refactoring-agent.d.ts +0 -11
- package/dist/agent/specialized/refactoring-agent.js +0 -24
- package/dist/agent/specialized/refactoring-agent.js.map +0 -1
- package/dist/agent/specialized/testing-agent.d.ts +0 -11
- package/dist/agent/specialized/testing-agent.js +0 -24
- package/dist/agent/specialized/testing-agent.js.map +0 -1
- package/dist/agent/status-reporter.d.ts +0 -114
- package/dist/agent/status-reporter.js +0 -335
- package/dist/agent/status-reporter.js.map +0 -1
- package/dist/agent/streaming/index.d.ts +0 -9
- package/dist/agent/streaming/index.js +0 -9
- package/dist/agent/streaming/index.js.map +0 -1
- package/dist/agent/streaming/stream-handler.d.ts +0 -62
- package/dist/agent/streaming/stream-handler.js +0 -217
- package/dist/agent/streaming/stream-handler.js.map +0 -1
- package/dist/agent/subagent-orchestrator.d.ts +0 -166
- package/dist/agent/subagent-orchestrator.js +0 -487
- package/dist/agent/subagent-orchestrator.js.map +0 -1
- package/dist/agent/subagent-types.d.ts +0 -261
- package/dist/agent/subagent-types.js +0 -257
- package/dist/agent/subagent-types.js.map +0 -1
- package/dist/agent/subagent.d.ts +0 -116
- package/dist/agent/subagent.js +0 -507
- package/dist/agent/subagent.js.map +0 -1
- package/dist/checkpoint/index.d.ts +0 -9
- package/dist/checkpoint/index.js +0 -11
- package/dist/checkpoint/index.js.map +0 -1
- package/dist/checkpoint/manager.d.ts +0 -101
- package/dist/checkpoint/manager.js +0 -407
- package/dist/checkpoint/manager.js.map +0 -1
- package/dist/checkpoint/storage.d.ts +0 -39
- package/dist/checkpoint/storage.js +0 -350
- package/dist/checkpoint/storage.js.map +0 -1
- package/dist/checkpoint/types.d.ts +0 -111
- package/dist/checkpoint/types.js +0 -17
- package/dist/checkpoint/types.js.map +0 -1
- package/dist/commands/cache.d.ts +0 -7
- package/dist/commands/cache.js +0 -284
- package/dist/commands/cache.js.map +0 -1
- package/dist/commands/custom-commands.d.ts +0 -77
- package/dist/commands/custom-commands.js +0 -251
- package/dist/commands/custom-commands.js.map +0 -1
- package/dist/commands/design.d.ts +0 -18
- package/dist/commands/design.js +0 -511
- package/dist/commands/design.js.map +0 -1
- package/dist/commands/doctor.d.ts +0 -6
- package/dist/commands/doctor.js +0 -773
- package/dist/commands/doctor.js.map +0 -1
- package/dist/commands/frontend.d.ts +0 -9
- package/dist/commands/frontend.js +0 -645
- package/dist/commands/frontend.js.map +0 -1
- package/dist/commands/init/wizard.d.ts +0 -55
- package/dist/commands/init/wizard.js +0 -189
- package/dist/commands/init/wizard.js.map +0 -1
- package/dist/commands/init.d.ts +0 -8
- package/dist/commands/init.js +0 -195
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/mcp-migrate.d.ts +0 -9
- package/dist/commands/mcp-migrate.js +0 -175
- package/dist/commands/mcp-migrate.js.map +0 -1
- package/dist/commands/mcp.d.ts +0 -2
- package/dist/commands/mcp.js +0 -1292
- package/dist/commands/mcp.js.map +0 -1
- package/dist/commands/memory.d.ts +0 -6
- package/dist/commands/memory.js +0 -555
- package/dist/commands/memory.js.map +0 -1
- package/dist/commands/models.d.ts +0 -5
- package/dist/commands/models.js +0 -213
- package/dist/commands/models.js.map +0 -1
- package/dist/commands/plan.d.ts +0 -43
- package/dist/commands/plan.js +0 -362
- package/dist/commands/plan.js.map +0 -1
- package/dist/commands/rewind.d.ts +0 -19
- package/dist/commands/rewind.js +0 -221
- package/dist/commands/rewind.js.map +0 -1
- package/dist/commands/setup.d.ts +0 -14
- package/dist/commands/setup.js +0 -733
- package/dist/commands/setup.js.map +0 -1
- package/dist/commands/status.d.ts +0 -7
- package/dist/commands/status.js +0 -437
- package/dist/commands/status.js.map +0 -1
- package/dist/commands/templates.d.ts +0 -5
- package/dist/commands/templates.js +0 -245
- package/dist/commands/templates.js.map +0 -1
- package/dist/commands/update.d.ts +0 -49
- package/dist/commands/update.js +0 -366
- package/dist/commands/update.js.map +0 -1
- package/dist/commands/usage.d.ts +0 -8
- package/dist/commands/usage.js +0 -264
- package/dist/commands/usage.js.map +0 -1
- package/dist/commands/vscode.d.ts +0 -7
- package/dist/commands/vscode.js +0 -419
- package/dist/commands/vscode.js.map +0 -1
- package/dist/constants.d.ts +0 -236
- package/dist/constants.js +0 -288
- package/dist/constants.js.map +0 -1
- package/dist/design/figma-alias.d.ts +0 -170
- package/dist/design/figma-alias.js +0 -577
- package/dist/design/figma-alias.js.map +0 -1
- package/dist/design/figma-audit.d.ts +0 -40
- package/dist/design/figma-audit.js +0 -383
- package/dist/design/figma-audit.js.map +0 -1
- package/dist/design/figma-client.d.ts +0 -131
- package/dist/design/figma-client.js +0 -369
- package/dist/design/figma-client.js.map +0 -1
- package/dist/design/figma-map.d.ts +0 -29
- package/dist/design/figma-map.js +0 -346
- package/dist/design/figma-map.js.map +0 -1
- package/dist/design/figma-tokens.d.ts +0 -73
- package/dist/design/figma-tokens.js +0 -448
- package/dist/design/figma-tokens.js.map +0 -1
- package/dist/design/index.d.ts +0 -13
- package/dist/design/index.js +0 -20
- package/dist/design/index.js.map +0 -1
- package/dist/design/types.d.ts +0 -98
- package/dist/design/types.js +0 -9
- package/dist/design/types.js.map +0 -1
- package/dist/hooks/hook-runner.d.ts +0 -142
- package/dist/hooks/hook-runner.js +0 -436
- package/dist/hooks/hook-runner.js.map +0 -1
- package/dist/hooks/index.d.ts +0 -9
- package/dist/hooks/index.js +0 -10
- package/dist/hooks/index.js.map +0 -1
- package/dist/hooks/manager.d.ts +0 -84
- package/dist/hooks/manager.js +0 -348
- package/dist/hooks/manager.js.map +0 -1
- package/dist/hooks/types.d.ts +0 -134
- package/dist/hooks/types.js +0 -9
- package/dist/hooks/types.js.map +0 -1
- package/dist/index.d.ts +0 -2
- package/dist/ipc/index.d.ts +0 -9
- package/dist/ipc/index.js +0 -10
- package/dist/ipc/index.js.map +0 -1
- package/dist/ipc/vscode-client.d.ts +0 -200
- package/dist/ipc/vscode-client.js +0 -495
- package/dist/ipc/vscode-client.js.map +0 -1
- package/dist/llm/client.d.ts +0 -205
- package/dist/llm/client.js +0 -735
- package/dist/llm/client.js.map +0 -1
- package/dist/llm/tools.d.ts +0 -102
- package/dist/llm/tools.js +0 -275
- package/dist/llm/tools.js.map +0 -1
- package/dist/llm/types.d.ts +0 -428
- package/dist/llm/types.js +0 -194
- package/dist/llm/types.js.map +0 -1
- package/dist/mcp/automatosx-auto-discovery.d.ts +0 -66
- package/dist/mcp/automatosx-auto-discovery.js +0 -169
- package/dist/mcp/automatosx-auto-discovery.js.map +0 -1
- package/dist/mcp/automatosx-loader.d.ts +0 -99
- package/dist/mcp/automatosx-loader.js +0 -250
- package/dist/mcp/automatosx-loader.js.map +0 -1
- package/dist/mcp/cancellation.d.ts +0 -182
- package/dist/mcp/cancellation.js +0 -275
- package/dist/mcp/cancellation.js.map +0 -1
- package/dist/mcp/client-v2.d.ts +0 -500
- package/dist/mcp/client-v2.js +0 -1433
- package/dist/mcp/client-v2.js.map +0 -1
- package/dist/mcp/client.d.ts +0 -170
- package/dist/mcp/client.js +0 -232
- package/dist/mcp/client.js.map +0 -1
- package/dist/mcp/config-detector.d.ts +0 -90
- package/dist/mcp/config-detector.js +0 -250
- package/dist/mcp/config-detector.js.map +0 -1
- package/dist/mcp/config-migrator.d.ts +0 -68
- package/dist/mcp/config-migrator.js +0 -291
- package/dist/mcp/config-migrator.js.map +0 -1
- package/dist/mcp/config.d.ts +0 -24
- package/dist/mcp/config.js +0 -273
- package/dist/mcp/config.js.map +0 -1
- package/dist/mcp/constants.d.ts +0 -66
- package/dist/mcp/constants.js +0 -85
- package/dist/mcp/constants.js.map +0 -1
- package/dist/mcp/content-length-transport.d.ts +0 -106
- package/dist/mcp/content-length-transport.js +0 -413
- package/dist/mcp/content-length-transport.js.map +0 -1
- package/dist/mcp/debug.d.ts +0 -211
- package/dist/mcp/debug.js +0 -404
- package/dist/mcp/debug.js.map +0 -1
- package/dist/mcp/error-formatter.d.ts +0 -40
- package/dist/mcp/error-formatter.js +0 -207
- package/dist/mcp/error-formatter.js.map +0 -1
- package/dist/mcp/error-remediation.d.ts +0 -45
- package/dist/mcp/error-remediation.js +0 -291
- package/dist/mcp/error-remediation.js.map +0 -1
- package/dist/mcp/health.d.ts +0 -120
- package/dist/mcp/health.js +0 -267
- package/dist/mcp/health.js.map +0 -1
- package/dist/mcp/index.d.ts +0 -56
- package/dist/mcp/index.js +0 -89
- package/dist/mcp/index.js.map +0 -1
- package/dist/mcp/invariants.d.ts +0 -141
- package/dist/mcp/invariants.js +0 -243
- package/dist/mcp/invariants.js.map +0 -1
- package/dist/mcp/mutex-safe.d.ts +0 -151
- package/dist/mcp/mutex-safe.js +0 -260
- package/dist/mcp/mutex-safe.js.map +0 -1
- package/dist/mcp/progress.d.ts +0 -155
- package/dist/mcp/progress.js +0 -252
- package/dist/mcp/progress.js.map +0 -1
- package/dist/mcp/prompts.d.ts +0 -68
- package/dist/mcp/prompts.js +0 -129
- package/dist/mcp/prompts.js.map +0 -1
- package/dist/mcp/provider-mcp-loader.d.ts +0 -130
- package/dist/mcp/provider-mcp-loader.js +0 -292
- package/dist/mcp/provider-mcp-loader.js.map +0 -1
- package/dist/mcp/reconnection.d.ts +0 -101
- package/dist/mcp/reconnection.js +0 -253
- package/dist/mcp/reconnection.js.map +0 -1
- package/dist/mcp/registry.d.ts +0 -75
- package/dist/mcp/registry.js +0 -276
- package/dist/mcp/registry.js.map +0 -1
- package/dist/mcp/resources.d.ts +0 -58
- package/dist/mcp/resources.js +0 -144
- package/dist/mcp/resources.js.map +0 -1
- package/dist/mcp/schema-validator.d.ts +0 -82
- package/dist/mcp/schema-validator.js +0 -161
- package/dist/mcp/schema-validator.js.map +0 -1
- package/dist/mcp/ssrf-protection.d.ts +0 -86
- package/dist/mcp/ssrf-protection.js +0 -311
- package/dist/mcp/ssrf-protection.js.map +0 -1
- package/dist/mcp/subscriptions.d.ts +0 -168
- package/dist/mcp/subscriptions.js +0 -248
- package/dist/mcp/subscriptions.js.map +0 -1
- package/dist/mcp/templates.d.ts +0 -52
- package/dist/mcp/templates.js +0 -627
- package/dist/mcp/templates.js.map +0 -1
- package/dist/mcp/transports.d.ts +0 -80
- package/dist/mcp/transports.js +0 -237
- package/dist/mcp/transports.js.map +0 -1
- package/dist/mcp/type-safety.d.ts +0 -225
- package/dist/mcp/type-safety.js +0 -237
- package/dist/mcp/type-safety.js.map +0 -1
- package/dist/mcp/validation.d.ts +0 -29
- package/dist/mcp/validation.js +0 -339
- package/dist/mcp/validation.js.map +0 -1
- package/dist/mcp/zai-detector.d.ts +0 -63
- package/dist/mcp/zai-detector.js +0 -193
- package/dist/mcp/zai-detector.js.map +0 -1
- package/dist/mcp/zai-templates.d.ts +0 -90
- package/dist/mcp/zai-templates.js +0 -157
- package/dist/mcp/zai-templates.js.map +0 -1
- package/dist/memory/context-generator.d.ts +0 -84
- package/dist/memory/context-generator.js +0 -546
- package/dist/memory/context-generator.js.map +0 -1
- package/dist/memory/context-injector.d.ts +0 -97
- package/dist/memory/context-injector.js +0 -159
- package/dist/memory/context-injector.js.map +0 -1
- package/dist/memory/context-store.d.ts +0 -103
- package/dist/memory/context-store.js +0 -264
- package/dist/memory/context-store.js.map +0 -1
- package/dist/memory/index.d.ts +0 -43
- package/dist/memory/index.js +0 -49
- package/dist/memory/index.js.map +0 -1
- package/dist/memory/provider-context-store.d.ts +0 -127
- package/dist/memory/provider-context-store.js +0 -385
- package/dist/memory/provider-context-store.js.map +0 -1
- package/dist/memory/schemas.d.ts +0 -118
- package/dist/memory/schemas.js +0 -106
- package/dist/memory/schemas.js.map +0 -1
- package/dist/memory/stats-collector.d.ts +0 -73
- package/dist/memory/stats-collector.js +0 -170
- package/dist/memory/stats-collector.js.map +0 -1
- package/dist/memory/types.d.ts +0 -177
- package/dist/memory/types.js +0 -73
- package/dist/memory/types.js.map +0 -1
- package/dist/permissions/index.d.ts +0 -6
- package/dist/permissions/index.js +0 -7
- package/dist/permissions/index.js.map +0 -1
- package/dist/permissions/permission-manager.d.ts +0 -149
- package/dist/permissions/permission-manager.js +0 -410
- package/dist/permissions/permission-manager.js.map +0 -1
- package/dist/planner/dependency-resolver.d.ts +0 -72
- package/dist/planner/dependency-resolver.js +0 -272
- package/dist/planner/dependency-resolver.js.map +0 -1
- package/dist/planner/index.d.ts +0 -12
- package/dist/planner/index.js +0 -28
- package/dist/planner/index.js.map +0 -1
- package/dist/planner/plan-generator.d.ts +0 -74
- package/dist/planner/plan-generator.js +0 -244
- package/dist/planner/plan-generator.js.map +0 -1
- package/dist/planner/plan-storage.d.ts +0 -113
- package/dist/planner/plan-storage.js +0 -398
- package/dist/planner/plan-storage.js.map +0 -1
- package/dist/planner/prompts/planning-prompt.d.ts +0 -62
- package/dist/planner/prompts/planning-prompt.js +0 -414
- package/dist/planner/prompts/planning-prompt.js.map +0 -1
- package/dist/planner/task-planner.d.ts +0 -139
- package/dist/planner/task-planner.js +0 -532
- package/dist/planner/task-planner.js.map +0 -1
- package/dist/planner/token-estimator.d.ts +0 -63
- package/dist/planner/token-estimator.js +0 -295
- package/dist/planner/token-estimator.js.map +0 -1
- package/dist/planner/types.d.ts +0 -425
- package/dist/planner/types.js +0 -213
- package/dist/planner/types.js.map +0 -1
- package/dist/provider/config.d.ts +0 -227
- package/dist/provider/config.js +0 -430
- package/dist/provider/config.js.map +0 -1
- package/dist/schemas/api-schemas.d.ts +0 -45
- package/dist/schemas/api-schemas.js +0 -129
- package/dist/schemas/api-schemas.js.map +0 -1
- package/dist/schemas/confirmation-schemas.d.ts +0 -39
- package/dist/schemas/confirmation-schemas.js +0 -48
- package/dist/schemas/confirmation-schemas.js.map +0 -1
- package/dist/schemas/index-unified.d.ts +0 -12
- package/dist/schemas/index-unified.js +0 -17
- package/dist/schemas/index-unified.js.map +0 -1
- package/dist/schemas/index.d.ts +0 -83
- package/dist/schemas/index.js +0 -139
- package/dist/schemas/index.js.map +0 -1
- package/dist/schemas/settings-schemas.d.ts +0 -186
- package/dist/schemas/settings-schemas.js +0 -324
- package/dist/schemas/settings-schemas.js.map +0 -1
- package/dist/schemas/tool-schemas.d.ts +0 -127
- package/dist/schemas/tool-schemas.js +0 -84
- package/dist/schemas/tool-schemas.js.map +0 -1
- package/dist/schemas/yaml-schemas.d.ts +0 -231
- package/dist/schemas/yaml-schemas.js +0 -199
- package/dist/schemas/yaml-schemas.js.map +0 -1
- package/dist/sdk/errors.d.ts +0 -100
- package/dist/sdk/errors.js +0 -138
- package/dist/sdk/errors.js.map +0 -1
- package/dist/sdk/index.d.ts +0 -901
- package/dist/sdk/index.js +0 -1272
- package/dist/sdk/index.js.map +0 -1
- package/dist/sdk/progress-reporter.d.ts +0 -123
- package/dist/sdk/progress-reporter.js +0 -220
- package/dist/sdk/progress-reporter.js.map +0 -1
- package/dist/sdk/testing.d.ts +0 -427
- package/dist/sdk/testing.js +0 -725
- package/dist/sdk/testing.js.map +0 -1
- package/dist/sdk/tool-registry.d.ts +0 -194
- package/dist/sdk/tool-registry.js +0 -326
- package/dist/sdk/tool-registry.js.map +0 -1
- package/dist/sdk/types.d.ts +0 -53
- package/dist/sdk/types.js +0 -8
- package/dist/sdk/types.js.map +0 -1
- package/dist/sdk/unified-logger.d.ts +0 -173
- package/dist/sdk/unified-logger.js +0 -327
- package/dist/sdk/unified-logger.js.map +0 -1
- package/dist/sdk/version.d.ts +0 -163
- package/dist/sdk/version.js +0 -205
- package/dist/sdk/version.js.map +0 -1
- package/dist/tools/ask-user.d.ts +0 -126
- package/dist/tools/ask-user.js +0 -290
- package/dist/tools/ask-user.js.map +0 -1
- package/dist/tools/ax-agent.d.ts +0 -71
- package/dist/tools/ax-agent.js +0 -283
- package/dist/tools/ax-agent.js.map +0 -1
- package/dist/tools/bash-output.d.ts +0 -25
- package/dist/tools/bash-output.js +0 -146
- package/dist/tools/bash-output.js.map +0 -1
- package/dist/tools/bash.d.ts +0 -67
- package/dist/tools/bash.js +0 -522
- package/dist/tools/bash.js.map +0 -1
- package/dist/tools/confirmation-tool.d.ts +0 -16
- package/dist/tools/confirmation-tool.js +0 -76
- package/dist/tools/confirmation-tool.js.map +0 -1
- package/dist/tools/definitions/ask-user.d.ts +0 -8
- package/dist/tools/definitions/ask-user.js +0 -168
- package/dist/tools/definitions/ask-user.js.map +0 -1
- package/dist/tools/definitions/ax-agent.d.ts +0 -8
- package/dist/tools/definitions/ax-agent.js +0 -276
- package/dist/tools/definitions/ax-agent.js.map +0 -1
- package/dist/tools/definitions/bash-output.d.ts +0 -7
- package/dist/tools/definitions/bash-output.js +0 -78
- package/dist/tools/definitions/bash-output.js.map +0 -1
- package/dist/tools/definitions/bash.d.ts +0 -8
- package/dist/tools/definitions/bash.js +0 -152
- package/dist/tools/definitions/bash.js.map +0 -1
- package/dist/tools/definitions/create-file.d.ts +0 -7
- package/dist/tools/definitions/create-file.js +0 -129
- package/dist/tools/definitions/create-file.js.map +0 -1
- package/dist/tools/definitions/design.d.ts +0 -12
- package/dist/tools/definitions/design.js +0 -368
- package/dist/tools/definitions/design.js.map +0 -1
- package/dist/tools/definitions/index.d.ts +0 -49
- package/dist/tools/definitions/index.js +0 -87
- package/dist/tools/definitions/index.js.map +0 -1
- package/dist/tools/definitions/multi-edit.d.ts +0 -7
- package/dist/tools/definitions/multi-edit.js +0 -123
- package/dist/tools/definitions/multi-edit.js.map +0 -1
- package/dist/tools/definitions/search.d.ts +0 -7
- package/dist/tools/definitions/search.js +0 -159
- package/dist/tools/definitions/search.js.map +0 -1
- package/dist/tools/definitions/str-replace-editor.d.ts +0 -7
- package/dist/tools/definitions/str-replace-editor.js +0 -145
- package/dist/tools/definitions/str-replace-editor.js.map +0 -1
- package/dist/tools/definitions/todo.d.ts +0 -8
- package/dist/tools/definitions/todo.js +0 -261
- package/dist/tools/definitions/todo.js.map +0 -1
- package/dist/tools/definitions/view-file.d.ts +0 -7
- package/dist/tools/definitions/view-file.js +0 -111
- package/dist/tools/definitions/view-file.js.map +0 -1
- package/dist/tools/design-tool.d.ts +0 -68
- package/dist/tools/design-tool.js +0 -299
- package/dist/tools/design-tool.js.map +0 -1
- package/dist/tools/format-generators.d.ts +0 -62
- package/dist/tools/format-generators.js +0 -291
- package/dist/tools/format-generators.js.map +0 -1
- package/dist/tools/index.d.ts +0 -8
- package/dist/tools/index.js +0 -11
- package/dist/tools/index.js.map +0 -1
- package/dist/tools/priority-registry.d.ts +0 -124
- package/dist/tools/priority-registry.js +0 -401
- package/dist/tools/priority-registry.js.map +0 -1
- package/dist/tools/priority.d.ts +0 -158
- package/dist/tools/priority.js +0 -350
- package/dist/tools/priority.js.map +0 -1
- package/dist/tools/registry.d.ts +0 -146
- package/dist/tools/registry.js +0 -171
- package/dist/tools/registry.js.map +0 -1
- package/dist/tools/search.d.ts +0 -85
- package/dist/tools/search.js +0 -430
- package/dist/tools/search.js.map +0 -1
- package/dist/tools/text-editor.d.ts +0 -87
- package/dist/tools/text-editor.js +0 -1369
- package/dist/tools/text-editor.js.map +0 -1
- package/dist/tools/todo-tool.d.ts +0 -20
- package/dist/tools/todo-tool.js +0 -186
- package/dist/tools/todo-tool.js.map +0 -1
- package/dist/tools/types.d.ts +0 -175
- package/dist/tools/types.js +0 -11
- package/dist/tools/types.js.map +0 -1
- package/dist/types/index.d.ts +0 -30
- package/dist/types/index.js +0 -2
- package/dist/types/index.js.map +0 -1
- package/dist/types/project-analysis.d.ts +0 -84
- package/dist/types/project-analysis.js +0 -5
- package/dist/types/project-analysis.js.map +0 -1
- package/dist/types/template.d.ts +0 -53
- package/dist/types/template.js +0 -5
- package/dist/types/template.js.map +0 -1
- package/dist/ui/app.d.ts +0 -7
- package/dist/ui/app.js +0 -102
- package/dist/ui/app.js.map +0 -1
- package/dist/ui/components/api-key-input.d.ts +0 -7
- package/dist/ui/components/api-key-input.js +0 -92
- package/dist/ui/components/api-key-input.js.map +0 -1
- package/dist/ui/components/chat-history.d.ts +0 -12
- package/dist/ui/components/chat-history.js +0 -391
- package/dist/ui/components/chat-history.js.map +0 -1
- package/dist/ui/components/chat-input.d.ts +0 -13
- package/dist/ui/components/chat-input.js +0 -179
- package/dist/ui/components/chat-input.js.map +0 -1
- package/dist/ui/components/chat-interface.d.ts +0 -11
- package/dist/ui/components/chat-interface.js +0 -830
- package/dist/ui/components/chat-interface.js.map +0 -1
- package/dist/ui/components/collapsible-tool-result.d.ts +0 -42
- package/dist/ui/components/collapsible-tool-result.js +0 -216
- package/dist/ui/components/collapsible-tool-result.js.map +0 -1
- package/dist/ui/components/command-suggestions.d.ts +0 -29
- package/dist/ui/components/command-suggestions.js +0 -88
- package/dist/ui/components/command-suggestions.js.map +0 -1
- package/dist/ui/components/confirmation-dialog.d.ts +0 -11
- package/dist/ui/components/confirmation-dialog.js +0 -100
- package/dist/ui/components/confirmation-dialog.js.map +0 -1
- package/dist/ui/components/context-breakdown.d.ts +0 -23
- package/dist/ui/components/context-breakdown.js +0 -124
- package/dist/ui/components/context-breakdown.js.map +0 -1
- package/dist/ui/components/diff-renderer.d.ts +0 -13
- package/dist/ui/components/diff-renderer.js +0 -192
- package/dist/ui/components/diff-renderer.js.map +0 -1
- package/dist/ui/components/index.d.ts +0 -18
- package/dist/ui/components/index.js +0 -20
- package/dist/ui/components/index.js.map +0 -1
- package/dist/ui/components/keyboard-help.d.ts +0 -17
- package/dist/ui/components/keyboard-help.js +0 -122
- package/dist/ui/components/keyboard-help.js.map +0 -1
- package/dist/ui/components/keyboard-hints.d.ts +0 -35
- package/dist/ui/components/keyboard-hints.js +0 -142
- package/dist/ui/components/keyboard-hints.js.map +0 -1
- package/dist/ui/components/loading-spinner.d.ts +0 -9
- package/dist/ui/components/loading-spinner.js +0 -120
- package/dist/ui/components/loading-spinner.js.map +0 -1
- package/dist/ui/components/mcp-dashboard.d.ts +0 -15
- package/dist/ui/components/mcp-dashboard.js +0 -520
- package/dist/ui/components/mcp-dashboard.js.map +0 -1
- package/dist/ui/components/mcp-status.d.ts +0 -5
- package/dist/ui/components/mcp-status.js +0 -58
- package/dist/ui/components/mcp-status.js.map +0 -1
- package/dist/ui/components/model-selection.d.ts +0 -12
- package/dist/ui/components/model-selection.js +0 -17
- package/dist/ui/components/model-selection.js.map +0 -1
- package/dist/ui/components/phase-progress.d.ts +0 -21
- package/dist/ui/components/phase-progress.js +0 -185
- package/dist/ui/components/phase-progress.js.map +0 -1
- package/dist/ui/components/question-dialog.d.ts +0 -17
- package/dist/ui/components/question-dialog.js +0 -181
- package/dist/ui/components/question-dialog.js.map +0 -1
- package/dist/ui/components/quick-actions.d.ts +0 -12
- package/dist/ui/components/quick-actions.js +0 -171
- package/dist/ui/components/quick-actions.js.map +0 -1
- package/dist/ui/components/reasoning-display.d.ts +0 -36
- package/dist/ui/components/reasoning-display.js +0 -46
- package/dist/ui/components/reasoning-display.js.map +0 -1
- package/dist/ui/components/status-bar.d.ts +0 -47
- package/dist/ui/components/status-bar.js +0 -310
- package/dist/ui/components/status-bar.js.map +0 -1
- package/dist/ui/components/subagent-monitor.d.ts +0 -41
- package/dist/ui/components/subagent-monitor.js +0 -122
- package/dist/ui/components/subagent-monitor.js.map +0 -1
- package/dist/ui/components/toast-notification.d.ts +0 -197
- package/dist/ui/components/toast-notification.js +0 -190
- package/dist/ui/components/toast-notification.js.map +0 -1
- package/dist/ui/components/tool-group-display.d.ts +0 -19
- package/dist/ui/components/tool-group-display.js +0 -222
- package/dist/ui/components/tool-group-display.js.map +0 -1
- package/dist/ui/components/virtualized-chat-history.d.ts +0 -33
- package/dist/ui/components/virtualized-chat-history.js +0 -182
- package/dist/ui/components/virtualized-chat-history.js.map +0 -1
- package/dist/ui/components/welcome-panel.d.ts +0 -11
- package/dist/ui/components/welcome-panel.js +0 -225
- package/dist/ui/components/welcome-panel.js.map +0 -1
- package/dist/ui/hooks/use-chat-reducer.d.ts +0 -69
- package/dist/ui/hooks/use-chat-reducer.js +0 -118
- package/dist/ui/hooks/use-chat-reducer.js.map +0 -1
- package/dist/ui/hooks/use-enhanced-input.d.ts +0 -53
- package/dist/ui/hooks/use-enhanced-input.js +0 -1275
- package/dist/ui/hooks/use-enhanced-input.js.map +0 -1
- package/dist/ui/hooks/use-input-handler.d.ts +0 -79
- package/dist/ui/hooks/use-input-handler.js +0 -2251
- package/dist/ui/hooks/use-input-handler.js.map +0 -1
- package/dist/ui/hooks/use-input-history.d.ts +0 -9
- package/dist/ui/hooks/use-input-history.js +0 -168
- package/dist/ui/hooks/use-input-history.js.map +0 -1
- package/dist/ui/shared/max-sized-box.d.ts +0 -17
- package/dist/ui/shared/max-sized-box.js +0 -14
- package/dist/ui/shared/max-sized-box.js.map +0 -1
- package/dist/ui/themes/index.d.ts +0 -5
- package/dist/ui/themes/index.js +0 -5
- package/dist/ui/themes/index.js.map +0 -1
- package/dist/ui/themes/theme-registry.d.ts +0 -55
- package/dist/ui/themes/theme-registry.js +0 -202
- package/dist/ui/themes/theme-registry.js.map +0 -1
- package/dist/ui/utils/bracketed-paste-handler.d.ts +0 -97
- package/dist/ui/utils/bracketed-paste-handler.js +0 -322
- package/dist/ui/utils/bracketed-paste-handler.js.map +0 -1
- package/dist/ui/utils/change-summarizer.d.ts +0 -20
- package/dist/ui/utils/change-summarizer.js +0 -282
- package/dist/ui/utils/change-summarizer.js.map +0 -1
- package/dist/ui/utils/code-colorizer.d.ts +0 -9
- package/dist/ui/utils/code-colorizer.js +0 -13
- package/dist/ui/utils/code-colorizer.js.map +0 -1
- package/dist/ui/utils/colors.d.ts +0 -41
- package/dist/ui/utils/colors.js +0 -80
- package/dist/ui/utils/colors.js.map +0 -1
- package/dist/ui/utils/image-handler.d.ts +0 -29
- package/dist/ui/utils/image-handler.js +0 -129
- package/dist/ui/utils/image-handler.js.map +0 -1
- package/dist/ui/utils/markdown-renderer.d.ts +0 -4
- package/dist/ui/utils/markdown-renderer.js +0 -40
- package/dist/ui/utils/markdown-renderer.js.map +0 -1
- package/dist/ui/utils/semantic-action-detector.d.ts +0 -49
- package/dist/ui/utils/semantic-action-detector.js +0 -339
- package/dist/ui/utils/semantic-action-detector.js.map +0 -1
- package/dist/ui/utils/tool-grouper.d.ts +0 -94
- package/dist/ui/utils/tool-grouper.js +0 -618
- package/dist/ui/utils/tool-grouper.js.map +0 -1
- package/dist/utils/api-error.d.ts +0 -61
- package/dist/utils/api-error.js +0 -176
- package/dist/utils/api-error.js.map +0 -1
- package/dist/utils/audit-logger.d.ts +0 -206
- package/dist/utils/audit-logger.js +0 -286
- package/dist/utils/audit-logger.js.map +0 -1
- package/dist/utils/auto-accept-logger.d.ts +0 -175
- package/dist/utils/auto-accept-logger.js +0 -423
- package/dist/utils/auto-accept-logger.js.map +0 -1
- package/dist/utils/automatosx-detector.d.ts +0 -19
- package/dist/utils/automatosx-detector.js +0 -52
- package/dist/utils/automatosx-detector.js.map +0 -1
- package/dist/utils/background-task-manager.d.ts +0 -114
- package/dist/utils/background-task-manager.js +0 -470
- package/dist/utils/background-task-manager.js.map +0 -1
- package/dist/utils/cache.d.ts +0 -77
- package/dist/utils/cache.js +0 -180
- package/dist/utils/cache.js.map +0 -1
- package/dist/utils/command-security.d.ts +0 -85
- package/dist/utils/command-security.js +0 -210
- package/dist/utils/command-security.js.map +0 -1
- package/dist/utils/config-loader.d.ts +0 -190
- package/dist/utils/config-loader.js +0 -108
- package/dist/utils/config-loader.js.map +0 -1
- package/dist/utils/confirmation-service.d.ts +0 -51
- package/dist/utils/confirmation-service.js +0 -220
- package/dist/utils/confirmation-service.js.map +0 -1
- package/dist/utils/console-messenger.d.ts +0 -80
- package/dist/utils/console-messenger.js +0 -142
- package/dist/utils/console-messenger.js.map +0 -1
- package/dist/utils/custom-instructions.d.ts +0 -1
- package/dist/utils/custom-instructions.js +0 -24
- package/dist/utils/custom-instructions.js.map +0 -1
- package/dist/utils/encryption.d.ts +0 -86
- package/dist/utils/encryption.js +0 -236
- package/dist/utils/encryption.js.map +0 -1
- package/dist/utils/enhanced-error-messages.d.ts +0 -33
- package/dist/utils/enhanced-error-messages.js +0 -440
- package/dist/utils/enhanced-error-messages.js.map +0 -1
- package/dist/utils/error-handler.d.ts +0 -65
- package/dist/utils/error-handler.js +0 -148
- package/dist/utils/error-handler.js.map +0 -1
- package/dist/utils/error-translator.d.ts +0 -25
- package/dist/utils/error-translator.js +0 -203
- package/dist/utils/error-translator.js.map +0 -1
- package/dist/utils/external-editor.d.ts +0 -47
- package/dist/utils/external-editor.js +0 -179
- package/dist/utils/external-editor.js.map +0 -1
- package/dist/utils/file-cache.d.ts +0 -148
- package/dist/utils/file-cache.js +0 -413
- package/dist/utils/file-cache.js.map +0 -1
- package/dist/utils/file-lock.d.ts +0 -141
- package/dist/utils/file-lock.js +0 -554
- package/dist/utils/file-lock.js.map +0 -1
- package/dist/utils/file-mentions.d.ts +0 -68
- package/dist/utils/file-mentions.js +0 -225
- package/dist/utils/file-mentions.js.map +0 -1
- package/dist/utils/history-manager.d.ts +0 -52
- package/dist/utils/history-manager.js +0 -211
- package/dist/utils/history-manager.js.map +0 -1
- package/dist/utils/history-migration.d.ts +0 -9
- package/dist/utils/history-migration.js +0 -37
- package/dist/utils/history-migration.js.map +0 -1
- package/dist/utils/image-processor.d.ts +0 -33
- package/dist/utils/image-processor.js +0 -124
- package/dist/utils/image-processor.js.map +0 -1
- package/dist/utils/index.d.ts +0 -92
- package/dist/utils/index.js +0 -111
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/init-previewer.d.ts +0 -56
- package/dist/utils/init-previewer.js +0 -239
- package/dist/utils/init-previewer.js.map +0 -1
- package/dist/utils/init-validator.d.ts +0 -65
- package/dist/utils/init-validator.js +0 -252
- package/dist/utils/init-validator.js.map +0 -1
- package/dist/utils/input-sanitizer.d.ts +0 -210
- package/dist/utils/input-sanitizer.js +0 -362
- package/dist/utils/input-sanitizer.js.map +0 -1
- package/dist/utils/instruction-generator.d.ts +0 -21
- package/dist/utils/instruction-generator.js +0 -233
- package/dist/utils/instruction-generator.js.map +0 -1
- package/dist/utils/json-utils.d.ts +0 -72
- package/dist/utils/json-utils.js +0 -226
- package/dist/utils/json-utils.js.map +0 -1
- package/dist/utils/llm-optimized-instruction-generator.d.ts +0 -36
- package/dist/utils/llm-optimized-instruction-generator.js +0 -365
- package/dist/utils/llm-optimized-instruction-generator.js.map +0 -1
- package/dist/utils/message-optimizer.d.ts +0 -100
- package/dist/utils/message-optimizer.js +0 -297
- package/dist/utils/message-optimizer.js.map +0 -1
- package/dist/utils/onboarding-manager.d.ts +0 -45
- package/dist/utils/onboarding-manager.js +0 -131
- package/dist/utils/onboarding-manager.js.map +0 -1
- package/dist/utils/parallel-analyzer.d.ts +0 -123
- package/dist/utils/parallel-analyzer.js +0 -241
- package/dist/utils/parallel-analyzer.js.map +0 -1
- package/dist/utils/paste-utils.d.ts +0 -99
- package/dist/utils/paste-utils.js +0 -295
- package/dist/utils/paste-utils.js.map +0 -1
- package/dist/utils/path-helpers.d.ts +0 -8
- package/dist/utils/path-helpers.js +0 -35
- package/dist/utils/path-helpers.js.map +0 -1
- package/dist/utils/path-security.d.ts +0 -92
- package/dist/utils/path-security.js +0 -300
- package/dist/utils/path-security.js.map +0 -1
- package/dist/utils/path-utils.d.ts +0 -83
- package/dist/utils/path-utils.js +0 -122
- package/dist/utils/path-utils.js.map +0 -1
- package/dist/utils/path-validator.d.ts +0 -66
- package/dist/utils/path-validator.js +0 -141
- package/dist/utils/path-validator.js.map +0 -1
- package/dist/utils/performance.d.ts +0 -74
- package/dist/utils/performance.js +0 -133
- package/dist/utils/performance.js.map +0 -1
- package/dist/utils/process-pool.d.ts +0 -109
- package/dist/utils/process-pool.js +0 -332
- package/dist/utils/process-pool.js.map +0 -1
- package/dist/utils/progress-tracker.d.ts +0 -51
- package/dist/utils/progress-tracker.js +0 -152
- package/dist/utils/progress-tracker.js.map +0 -1
- package/dist/utils/project-analyzer.d.ts +0 -49
- package/dist/utils/project-analyzer.js +0 -396
- package/dist/utils/project-analyzer.js.map +0 -1
- package/dist/utils/prompt-builder.d.ts +0 -14
- package/dist/utils/prompt-builder.js +0 -100
- package/dist/utils/prompt-builder.js.map +0 -1
- package/dist/utils/provider-context.d.ts +0 -243
- package/dist/utils/provider-context.js +0 -421
- package/dist/utils/provider-context.js.map +0 -1
- package/dist/utils/provider-file-cache.d.ts +0 -91
- package/dist/utils/provider-file-cache.js +0 -165
- package/dist/utils/provider-file-cache.js.map +0 -1
- package/dist/utils/provider-settings.d.ts +0 -181
- package/dist/utils/provider-settings.js +0 -450
- package/dist/utils/provider-settings.js.map +0 -1
- package/dist/utils/rate-limiter.d.ts +0 -222
- package/dist/utils/rate-limiter.js +0 -338
- package/dist/utils/rate-limiter.js.map +0 -1
- package/dist/utils/retry-helper.d.ts +0 -81
- package/dist/utils/retry-helper.js +0 -244
- package/dist/utils/retry-helper.js.map +0 -1
- package/dist/utils/safety-rules.d.ts +0 -64
- package/dist/utils/safety-rules.js +0 -225
- package/dist/utils/safety-rules.js.map +0 -1
- package/dist/utils/settings-manager.d.ts +0 -256
- package/dist/utils/settings-manager.js +0 -967
- package/dist/utils/settings-manager.js.map +0 -1
- package/dist/utils/setup-validator.d.ts +0 -47
- package/dist/utils/setup-validator.js +0 -304
- package/dist/utils/setup-validator.js.map +0 -1
- package/dist/utils/string-utils.d.ts +0 -19
- package/dist/utils/string-utils.js +0 -28
- package/dist/utils/string-utils.js.map +0 -1
- package/dist/utils/template-manager.d.ts +0 -62
- package/dist/utils/template-manager.js +0 -366
- package/dist/utils/template-manager.js.map +0 -1
- package/dist/utils/text-utils.d.ts +0 -82
- package/dist/utils/text-utils.js +0 -203
- package/dist/utils/text-utils.js.map +0 -1
- package/dist/utils/token-counter.d.ts +0 -76
- package/dist/utils/token-counter.js +0 -231
- package/dist/utils/token-counter.js.map +0 -1
- package/dist/utils/usage-tracker.d.ts +0 -78
- package/dist/utils/usage-tracker.js +0 -126
- package/dist/utils/usage-tracker.js.map +0 -1
- package/dist/utils/version.d.ts +0 -14
- package/dist/utils/version.js +0 -70
- package/dist/utils/version.js.map +0 -1
package/dist/tools/registry.js
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tool Registry for dynamic tool management
|
|
3
|
-
*
|
|
4
|
-
* Provides a centralized registry for tools, enabling:
|
|
5
|
-
* - Dynamic tool registration/unregistration
|
|
6
|
-
* - Dependency validation
|
|
7
|
-
* - Category-based organization
|
|
8
|
-
* - Custom tool development
|
|
9
|
-
*/
|
|
10
|
-
import { Ok, Err } from '../mcp/type-safety.js';
|
|
11
|
-
import { extractErrorMessage } from '../utils/error-handler.js';
|
|
12
|
-
/**
|
|
13
|
-
* Tool Registry for dynamic tool management
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```typescript
|
|
17
|
-
* const registry = new ToolRegistry();
|
|
18
|
-
*
|
|
19
|
-
* registry.register({
|
|
20
|
-
* name: 'my_tool',
|
|
21
|
-
* description: 'Does something',
|
|
22
|
-
* version: '1.0.0',
|
|
23
|
-
* category: 'custom',
|
|
24
|
-
* async execute(args) {
|
|
25
|
-
* return { success: true, output: 'Done!' };
|
|
26
|
-
* },
|
|
27
|
-
* schema: {
|
|
28
|
-
* type: 'object',
|
|
29
|
-
* properties: {
|
|
30
|
-
* input: { type: 'string' }
|
|
31
|
-
* }
|
|
32
|
-
* }
|
|
33
|
-
* });
|
|
34
|
-
* ```
|
|
35
|
-
*/
|
|
36
|
-
export class ToolRegistry {
|
|
37
|
-
tools = new Map();
|
|
38
|
-
/**
|
|
39
|
-
* Register a new tool
|
|
40
|
-
*
|
|
41
|
-
* Validates:
|
|
42
|
-
* - Tool name format (lowercase with underscores)
|
|
43
|
-
* - No duplicate names
|
|
44
|
-
* - All dependencies exist
|
|
45
|
-
* - Schema is valid
|
|
46
|
-
*
|
|
47
|
-
* @param tool Tool definition to register
|
|
48
|
-
* @returns Ok(void) on success, Err(Error) on failure
|
|
49
|
-
*/
|
|
50
|
-
register(tool) {
|
|
51
|
-
// Validate tool name format
|
|
52
|
-
if (!tool.name || !/^[a-z][a-z0-9_]*$/.test(tool.name)) {
|
|
53
|
-
return Err(new Error(`Invalid tool name: ${tool.name}. Must be lowercase with underscores.`));
|
|
54
|
-
}
|
|
55
|
-
// Check for conflicts
|
|
56
|
-
if (this.tools.has(tool.name)) {
|
|
57
|
-
return Err(new Error(`Tool ${tool.name} already registered`));
|
|
58
|
-
}
|
|
59
|
-
// Validate dependencies exist
|
|
60
|
-
if (tool.dependencies) {
|
|
61
|
-
for (const dep of tool.dependencies) {
|
|
62
|
-
if (!this.tools.has(dep)) {
|
|
63
|
-
return Err(new Error(`Missing dependency: ${dep} required by ${tool.name}`));
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
// Validate schema
|
|
68
|
-
if (!tool.schema || tool.schema.type !== 'object') {
|
|
69
|
-
return Err(new Error(`Tool ${tool.name} must have object schema`));
|
|
70
|
-
}
|
|
71
|
-
this.tools.set(tool.name, tool);
|
|
72
|
-
return Ok(undefined);
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Unregister a tool
|
|
76
|
-
*
|
|
77
|
-
* Validates that no other tools depend on this tool before removal.
|
|
78
|
-
*
|
|
79
|
-
* @param name Tool name to unregister
|
|
80
|
-
* @returns Ok(void) on success, Err(Error) on failure
|
|
81
|
-
*/
|
|
82
|
-
unregister(name) {
|
|
83
|
-
// Check if any tool depends on this
|
|
84
|
-
for (const [toolName, tool] of this.tools.entries()) {
|
|
85
|
-
if (tool.dependencies?.includes(name)) {
|
|
86
|
-
return Err(new Error(`Cannot remove ${name}: ${toolName} depends on it`));
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
if (!this.tools.delete(name)) {
|
|
90
|
-
return Err(new Error(`Tool ${name} not found`));
|
|
91
|
-
}
|
|
92
|
-
return Ok(undefined);
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Get a tool by name
|
|
96
|
-
*
|
|
97
|
-
* @param name Tool name
|
|
98
|
-
* @returns Tool definition or undefined if not found
|
|
99
|
-
*/
|
|
100
|
-
get(name) {
|
|
101
|
-
return this.tools.get(name);
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* List all tools, optionally filtered by category
|
|
105
|
-
*
|
|
106
|
-
* @param category Optional category filter
|
|
107
|
-
* @returns Array of tool definitions
|
|
108
|
-
*/
|
|
109
|
-
list(category) {
|
|
110
|
-
const allTools = Array.from(this.tools.values());
|
|
111
|
-
if (category) {
|
|
112
|
-
return allTools.filter(t => t.category === category);
|
|
113
|
-
}
|
|
114
|
-
return allTools;
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Convert registered tools to LLM tool format
|
|
118
|
-
*
|
|
119
|
-
* Transforms internal ToolDefinition format to OpenAI function calling format.
|
|
120
|
-
*
|
|
121
|
-
* @returns Array of LLM tools
|
|
122
|
-
*/
|
|
123
|
-
toLLMTools() {
|
|
124
|
-
return Array.from(this.tools.values()).map(tool => ({
|
|
125
|
-
type: 'function',
|
|
126
|
-
function: {
|
|
127
|
-
name: tool.name,
|
|
128
|
-
description: `${tool.description} (v${tool.version})`,
|
|
129
|
-
parameters: tool.schema
|
|
130
|
-
}
|
|
131
|
-
}));
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Execute a tool by name
|
|
135
|
-
*
|
|
136
|
-
* @param name Tool name
|
|
137
|
-
* @param args Tool arguments
|
|
138
|
-
* @returns Tool result
|
|
139
|
-
*/
|
|
140
|
-
async execute(name, args) {
|
|
141
|
-
const tool = this.tools.get(name);
|
|
142
|
-
if (!tool) {
|
|
143
|
-
return {
|
|
144
|
-
success: false,
|
|
145
|
-
error: `Tool not found: ${name}`
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
try {
|
|
149
|
-
return await tool.execute(args);
|
|
150
|
-
}
|
|
151
|
-
catch (error) {
|
|
152
|
-
return {
|
|
153
|
-
success: false,
|
|
154
|
-
error: extractErrorMessage(error)
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Get tool count
|
|
160
|
-
*/
|
|
161
|
-
get size() {
|
|
162
|
-
return this.tools.size;
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Clear all tools
|
|
166
|
-
*/
|
|
167
|
-
clear() {
|
|
168
|
-
this.tools.clear();
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
//# sourceMappingURL=registry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/tools/registry.ts"],"names":[],"mappings":"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"}
|
package/dist/tools/search.d.ts
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { ToolResult } from "../types/index.js";
|
|
2
|
-
export interface SearchResult {
|
|
3
|
-
file: string;
|
|
4
|
-
line: number;
|
|
5
|
-
column: number;
|
|
6
|
-
text: string;
|
|
7
|
-
match: string;
|
|
8
|
-
}
|
|
9
|
-
export interface FileSearchResult {
|
|
10
|
-
path: string;
|
|
11
|
-
name: string;
|
|
12
|
-
score: number;
|
|
13
|
-
}
|
|
14
|
-
export interface UnifiedSearchResult {
|
|
15
|
-
type: "text" | "file";
|
|
16
|
-
file: string;
|
|
17
|
-
line?: number;
|
|
18
|
-
column?: number;
|
|
19
|
-
text?: string;
|
|
20
|
-
match?: string;
|
|
21
|
-
score?: number;
|
|
22
|
-
}
|
|
23
|
-
export declare class SearchTool {
|
|
24
|
-
private static readonly DEFAULT_MAX_RESULTS;
|
|
25
|
-
private static readonly MAX_RECURSION_DEPTH;
|
|
26
|
-
private static readonly MAX_DISPLAY_RESULTS;
|
|
27
|
-
private static readonly SCORE_EXACT_MATCH;
|
|
28
|
-
private static readonly SCORE_CONTAINS_MATCH;
|
|
29
|
-
private static readonly SCORE_PATH_MATCH;
|
|
30
|
-
private static readonly SCORE_FUZZY_BASE;
|
|
31
|
-
private static readonly SCORE_FUZZY_MIN;
|
|
32
|
-
private static readonly SKIP_DIRECTORIES;
|
|
33
|
-
private currentDirectory;
|
|
34
|
-
/**
|
|
35
|
-
* Unified search method that can search for text content or find files
|
|
36
|
-
*/
|
|
37
|
-
search(query: string, options?: {
|
|
38
|
-
searchType?: "text" | "files" | "both";
|
|
39
|
-
includePattern?: string;
|
|
40
|
-
excludePattern?: string;
|
|
41
|
-
caseSensitive?: boolean;
|
|
42
|
-
wholeWord?: boolean;
|
|
43
|
-
regex?: boolean;
|
|
44
|
-
maxResults?: number;
|
|
45
|
-
fileTypes?: string[];
|
|
46
|
-
excludeFiles?: string[];
|
|
47
|
-
includeHidden?: boolean;
|
|
48
|
-
}): Promise<ToolResult>;
|
|
49
|
-
/**
|
|
50
|
-
* Execute ripgrep command with specified options using process pool (REQ-ARCH-002)
|
|
51
|
-
*/
|
|
52
|
-
private executeRipgrep;
|
|
53
|
-
/**
|
|
54
|
-
* Type guard for ripgrep match data with proper type narrowing
|
|
55
|
-
*/
|
|
56
|
-
private isRipgrepMatch;
|
|
57
|
-
/**
|
|
58
|
-
* Parse ripgrep JSON output into SearchResult objects with full type safety
|
|
59
|
-
*/
|
|
60
|
-
private parseRipgrepOutput;
|
|
61
|
-
/**
|
|
62
|
-
* Find files by pattern using a simple file walking approach
|
|
63
|
-
*/
|
|
64
|
-
private findFilesByPattern;
|
|
65
|
-
/**
|
|
66
|
-
* Calculate fuzzy match score for file names
|
|
67
|
-
*/
|
|
68
|
-
private calculateFileScore;
|
|
69
|
-
/**
|
|
70
|
-
* Calculate fuzzy match score for character sequence matching
|
|
71
|
-
*/
|
|
72
|
-
private calculateFuzzyScore;
|
|
73
|
-
/**
|
|
74
|
-
* Format unified search results for display
|
|
75
|
-
*/
|
|
76
|
-
private formatUnifiedResults;
|
|
77
|
-
/**
|
|
78
|
-
* Update current working directory
|
|
79
|
-
*/
|
|
80
|
-
setCurrentDirectory(directory: string): void;
|
|
81
|
-
/**
|
|
82
|
-
* Get current working directory
|
|
83
|
-
*/
|
|
84
|
-
getCurrentDirectory(): string;
|
|
85
|
-
}
|
package/dist/tools/search.js
DELETED
|
@@ -1,430 +0,0 @@
|
|
|
1
|
-
import fs from "fs-extra";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { getRipgrepPool } from "../utils/process-pool.js";
|
|
4
|
-
import { sanitizeSearchQuery, validateRegexPattern } from "../utils/input-sanitizer.js";
|
|
5
|
-
import { getAuditLogger, AuditCategory } from "../utils/audit-logger.js";
|
|
6
|
-
import { extractErrorMessage } from "../utils/error-handler.js";
|
|
7
|
-
import { TIMEOUT_CONFIG } from "../constants.js";
|
|
8
|
-
export class SearchTool {
|
|
9
|
-
static DEFAULT_MAX_RESULTS = 50;
|
|
10
|
-
static MAX_RECURSION_DEPTH = 10;
|
|
11
|
-
static MAX_DISPLAY_RESULTS = 8;
|
|
12
|
-
static SCORE_EXACT_MATCH = 100;
|
|
13
|
-
static SCORE_CONTAINS_MATCH = 80;
|
|
14
|
-
static SCORE_PATH_MATCH = 60;
|
|
15
|
-
static SCORE_FUZZY_BASE = 40;
|
|
16
|
-
static SCORE_FUZZY_MIN = 10;
|
|
17
|
-
static SKIP_DIRECTORIES = [
|
|
18
|
-
"node_modules",
|
|
19
|
-
".git",
|
|
20
|
-
".svn",
|
|
21
|
-
".hg",
|
|
22
|
-
"dist",
|
|
23
|
-
"build",
|
|
24
|
-
".next",
|
|
25
|
-
".cache",
|
|
26
|
-
];
|
|
27
|
-
currentDirectory = process.cwd();
|
|
28
|
-
/**
|
|
29
|
-
* Unified search method that can search for text content or find files
|
|
30
|
-
*/
|
|
31
|
-
async search(query, options = {}) {
|
|
32
|
-
try {
|
|
33
|
-
// REQ-SEC-007: Sanitize search query to prevent ReDoS and injection
|
|
34
|
-
const sanitizedQuery = sanitizeSearchQuery(query);
|
|
35
|
-
if (!sanitizedQuery.valid || !sanitizedQuery.value) {
|
|
36
|
-
// REQ-SEC-008: Audit log input validation failure
|
|
37
|
-
// Wrap in try/catch to prevent audit logging failures from masking validation errors
|
|
38
|
-
try {
|
|
39
|
-
const auditLogger = getAuditLogger();
|
|
40
|
-
auditLogger.logWarning({
|
|
41
|
-
category: AuditCategory.INPUT_VALIDATION,
|
|
42
|
-
action: 'search_query_validation_failed',
|
|
43
|
-
resource: 'search_tool',
|
|
44
|
-
outcome: 'failure',
|
|
45
|
-
error: sanitizedQuery.error,
|
|
46
|
-
details: { queryLength: query.length },
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
catch {
|
|
50
|
-
// Audit logging is secondary - continue with validation error response
|
|
51
|
-
}
|
|
52
|
-
return {
|
|
53
|
-
success: false,
|
|
54
|
-
error: `Invalid search query: ${sanitizedQuery.error}`,
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
// REDOS FIX: Always validate patterns that could be interpreted as regex
|
|
58
|
-
// Even in fixed-string mode, validate to prevent accidental regex usage
|
|
59
|
-
const regexValidation = validateRegexPattern(sanitizedQuery.value);
|
|
60
|
-
if (options.regex) {
|
|
61
|
-
// Strict validation when regex mode is explicitly enabled
|
|
62
|
-
if (!regexValidation.valid) {
|
|
63
|
-
// REQ-SEC-008: Audit log ReDoS protection trigger
|
|
64
|
-
// Wrap in try/catch to prevent audit logging failures from masking validation errors
|
|
65
|
-
try {
|
|
66
|
-
const auditLogger = getAuditLogger();
|
|
67
|
-
auditLogger.logCritical({
|
|
68
|
-
category: AuditCategory.INPUT_VALIDATION,
|
|
69
|
-
action: 'redos_pattern_detected',
|
|
70
|
-
resource: 'search_tool',
|
|
71
|
-
outcome: 'failure',
|
|
72
|
-
error: regexValidation.error,
|
|
73
|
-
details: { pattern: sanitizedQuery.value },
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
catch {
|
|
77
|
-
// Audit logging is secondary - continue with validation error response
|
|
78
|
-
}
|
|
79
|
-
return {
|
|
80
|
-
success: false,
|
|
81
|
-
error: `Invalid regex pattern: ${regexValidation.error}`,
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
// Log warnings if any
|
|
85
|
-
if (regexValidation.warnings && regexValidation.warnings.length > 0) {
|
|
86
|
-
console.warn(`Search regex warnings: ${regexValidation.warnings.join(', ')}`);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
// REDOS FIX: In fixed-string mode, warn if pattern looks like dangerous regex
|
|
91
|
-
// This prevents accidental ReDoS if fixed-string flag is forgotten
|
|
92
|
-
// But skip warning for glob-like patterns (they have ** or {})
|
|
93
|
-
const looksLikeGlob = /\*\*|{[^}]+}/.test(sanitizedQuery.value);
|
|
94
|
-
if (!regexValidation.valid && !looksLikeGlob) {
|
|
95
|
-
console.warn(`Search pattern contains regex metacharacters that could be dangerous: ${regexValidation.error}. ` +
|
|
96
|
-
`Using fixed-string mode (safe), but pattern may not match as expected.`);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
const searchType = options.searchType || "both";
|
|
100
|
-
const results = [];
|
|
101
|
-
// sanitizedQuery.value is guaranteed to exist after the validation check above
|
|
102
|
-
const cleanQuery = sanitizedQuery.value;
|
|
103
|
-
// Search for text content if requested
|
|
104
|
-
if (searchType === "text" || searchType === "both") {
|
|
105
|
-
const textResults = await this.executeRipgrep(cleanQuery, options);
|
|
106
|
-
results.push(...textResults.map((r) => ({
|
|
107
|
-
type: "text",
|
|
108
|
-
file: r.file,
|
|
109
|
-
line: r.line,
|
|
110
|
-
column: r.column,
|
|
111
|
-
text: r.text,
|
|
112
|
-
match: r.match,
|
|
113
|
-
})));
|
|
114
|
-
}
|
|
115
|
-
// Search for files if requested
|
|
116
|
-
if (searchType === "files" || searchType === "both") {
|
|
117
|
-
const fileResults = await this.findFilesByPattern(cleanQuery, options);
|
|
118
|
-
results.push(...fileResults.map((r) => ({
|
|
119
|
-
type: "file",
|
|
120
|
-
file: r.path,
|
|
121
|
-
score: r.score,
|
|
122
|
-
})));
|
|
123
|
-
}
|
|
124
|
-
if (results.length === 0) {
|
|
125
|
-
return {
|
|
126
|
-
success: true,
|
|
127
|
-
output: `No results found for "${cleanQuery}"`,
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
const formattedOutput = this.formatUnifiedResults(results, cleanQuery, searchType);
|
|
131
|
-
return {
|
|
132
|
-
success: true,
|
|
133
|
-
output: formattedOutput,
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
catch (error) {
|
|
137
|
-
const errorMsg = extractErrorMessage(error);
|
|
138
|
-
return {
|
|
139
|
-
success: false,
|
|
140
|
-
error: `Search error: ${errorMsg}`,
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Execute ripgrep command with specified options using process pool (REQ-ARCH-002)
|
|
146
|
-
*/
|
|
147
|
-
async executeRipgrep(query, options) {
|
|
148
|
-
const args = [
|
|
149
|
-
"--json",
|
|
150
|
-
"--with-filename",
|
|
151
|
-
"--line-number",
|
|
152
|
-
"--column",
|
|
153
|
-
"--no-heading",
|
|
154
|
-
"--color=never",
|
|
155
|
-
];
|
|
156
|
-
// Add case sensitivity
|
|
157
|
-
if (!options.caseSensitive) {
|
|
158
|
-
args.push("--ignore-case");
|
|
159
|
-
}
|
|
160
|
-
// Add whole word matching
|
|
161
|
-
if (options.wholeWord) {
|
|
162
|
-
args.push("--word-regexp");
|
|
163
|
-
}
|
|
164
|
-
// Add regex mode
|
|
165
|
-
if (!options.regex) {
|
|
166
|
-
args.push("--fixed-strings");
|
|
167
|
-
}
|
|
168
|
-
// Add max results limit
|
|
169
|
-
if (options.maxResults !== undefined) {
|
|
170
|
-
// Validate maxResults is a positive integer
|
|
171
|
-
if (!Number.isInteger(options.maxResults) || options.maxResults < 1) {
|
|
172
|
-
throw new Error(`maxResults must be a positive integer, got: ${options.maxResults}`);
|
|
173
|
-
}
|
|
174
|
-
args.push("--max-count", options.maxResults.toString());
|
|
175
|
-
}
|
|
176
|
-
// Add file type filters
|
|
177
|
-
// Note: ripgrep's --type only supports built-in types (js, py, rust, etc.)
|
|
178
|
-
// For custom extensions like tsx, we use --glob instead
|
|
179
|
-
if (options.fileTypes) {
|
|
180
|
-
const builtinTypes = new Set([
|
|
181
|
-
'js', 'ts', 'py', 'rust', 'go', 'java', 'c', 'cpp', 'cs', 'rb', 'php',
|
|
182
|
-
'html', 'css', 'json', 'xml', 'yaml', 'yml', 'md', 'txt', 'sh', 'sql'
|
|
183
|
-
]);
|
|
184
|
-
options.fileTypes.forEach((type) => {
|
|
185
|
-
if (builtinTypes.has(type)) {
|
|
186
|
-
args.push("--type", type);
|
|
187
|
-
}
|
|
188
|
-
else {
|
|
189
|
-
// Use glob pattern for non-builtin types (tsx, jsx, vue, svelte, etc.)
|
|
190
|
-
args.push("--glob", `*.${type}`);
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
// Add include pattern
|
|
195
|
-
if (options.includePattern) {
|
|
196
|
-
args.push("--glob", options.includePattern);
|
|
197
|
-
}
|
|
198
|
-
// Add exclude pattern
|
|
199
|
-
if (options.excludePattern) {
|
|
200
|
-
args.push("--glob", `!${options.excludePattern}`);
|
|
201
|
-
}
|
|
202
|
-
// Add exclude files
|
|
203
|
-
if (options.excludeFiles) {
|
|
204
|
-
options.excludeFiles.forEach((file) => {
|
|
205
|
-
args.push("--glob", `!${file}`);
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
// Respect gitignore and common ignore patterns
|
|
209
|
-
args.push("--no-require-git", "--follow", "--glob", "!.git/**", "--glob", "!node_modules/**", "--glob", "!.DS_Store", "--glob", "!*.log");
|
|
210
|
-
// Add query and search directory
|
|
211
|
-
args.push(query, this.currentDirectory);
|
|
212
|
-
// MEMORY LEAK FIX (REQ-ARCH-002): Use process pool instead of spawning directly
|
|
213
|
-
const pool = getRipgrepPool();
|
|
214
|
-
try {
|
|
215
|
-
const result = await pool.execute({
|
|
216
|
-
command: "rg",
|
|
217
|
-
args,
|
|
218
|
-
cwd: this.currentDirectory,
|
|
219
|
-
timeout: TIMEOUT_CONFIG.SEARCH_DEFAULT,
|
|
220
|
-
});
|
|
221
|
-
// Handle ripgrep exit codes: 0 = found, 1 = not found, others = error
|
|
222
|
-
if (result.exitCode === 0 || result.exitCode === 1) {
|
|
223
|
-
return this.parseRipgrepOutput(result.stdout);
|
|
224
|
-
}
|
|
225
|
-
else {
|
|
226
|
-
throw new Error(`Ripgrep failed with code ${result.exitCode}: ${result.stderr}`);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
catch (error) {
|
|
230
|
-
throw error instanceof Error
|
|
231
|
-
? error
|
|
232
|
-
: new Error(`Ripgrep execution failed: ${String(error)}`);
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
* Type guard for ripgrep match data with proper type narrowing
|
|
237
|
-
*/
|
|
238
|
-
isRipgrepMatch(parsed) {
|
|
239
|
-
if (typeof parsed !== 'object' || parsed === null)
|
|
240
|
-
return false;
|
|
241
|
-
const obj = parsed;
|
|
242
|
-
return (obj.type === 'match' &&
|
|
243
|
-
typeof obj.data?.path?.text === 'string' &&
|
|
244
|
-
typeof obj.data?.line_number === 'number' &&
|
|
245
|
-
typeof obj.data?.lines?.text === 'string');
|
|
246
|
-
}
|
|
247
|
-
/**
|
|
248
|
-
* Parse ripgrep JSON output into SearchResult objects with full type safety
|
|
249
|
-
*/
|
|
250
|
-
parseRipgrepOutput(output) {
|
|
251
|
-
if (!output.trim())
|
|
252
|
-
return [];
|
|
253
|
-
const results = [];
|
|
254
|
-
const lines = output.trim().split("\n");
|
|
255
|
-
for (const line of lines) {
|
|
256
|
-
try {
|
|
257
|
-
const parsed = JSON.parse(line);
|
|
258
|
-
if (this.isRipgrepMatch(parsed)) {
|
|
259
|
-
// TypeScript now knows parsed has the correct structure
|
|
260
|
-
results.push({
|
|
261
|
-
file: parsed.data.path.text,
|
|
262
|
-
line: parsed.data.line_number,
|
|
263
|
-
column: parsed.data.submatches?.[0]?.start ?? 0,
|
|
264
|
-
text: parsed.data.lines.text.trim(),
|
|
265
|
-
match: parsed.data.submatches?.[0]?.match?.text ?? '',
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
catch {
|
|
270
|
-
// Skip invalid JSON lines
|
|
271
|
-
continue;
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
return results;
|
|
275
|
-
}
|
|
276
|
-
/**
|
|
277
|
-
* Find files by pattern using a simple file walking approach
|
|
278
|
-
*/
|
|
279
|
-
async findFilesByPattern(pattern, options) {
|
|
280
|
-
const files = [];
|
|
281
|
-
const maxResults = options.maxResults || SearchTool.DEFAULT_MAX_RESULTS;
|
|
282
|
-
const searchPattern = pattern.toLowerCase(); // Cache once for all comparisons
|
|
283
|
-
const walkDir = async (dir, depth = 0) => {
|
|
284
|
-
// Early exit if we've found enough results or exceeded depth
|
|
285
|
-
if (files.length >= maxResults)
|
|
286
|
-
return;
|
|
287
|
-
if (depth > SearchTool.MAX_RECURSION_DEPTH)
|
|
288
|
-
return;
|
|
289
|
-
try {
|
|
290
|
-
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
291
|
-
// Separate files and directories for better search ordering
|
|
292
|
-
const fileEntries = [];
|
|
293
|
-
const dirEntries = [];
|
|
294
|
-
for (const entry of entries) {
|
|
295
|
-
// Skip hidden files unless explicitly included
|
|
296
|
-
if (!options.includeHidden && entry.name.startsWith(".")) {
|
|
297
|
-
continue;
|
|
298
|
-
}
|
|
299
|
-
// Skip common directories
|
|
300
|
-
if (entry.isDirectory() && SearchTool.SKIP_DIRECTORIES.includes(entry.name)) {
|
|
301
|
-
continue;
|
|
302
|
-
}
|
|
303
|
-
if (entry.isFile()) {
|
|
304
|
-
fileEntries.push(entry);
|
|
305
|
-
}
|
|
306
|
-
else if (entry.isDirectory()) {
|
|
307
|
-
dirEntries.push(entry);
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
// Process files first (better for finding matches quickly)
|
|
311
|
-
for (const entry of fileEntries) {
|
|
312
|
-
if (files.length >= maxResults)
|
|
313
|
-
return; // Early exit
|
|
314
|
-
const fullPath = path.join(dir, entry.name);
|
|
315
|
-
const relativePath = path.relative(this.currentDirectory, fullPath);
|
|
316
|
-
// Apply exclude pattern
|
|
317
|
-
if (options.excludePattern &&
|
|
318
|
-
relativePath.includes(options.excludePattern)) {
|
|
319
|
-
continue;
|
|
320
|
-
}
|
|
321
|
-
const score = this.calculateFileScore(entry.name, relativePath, searchPattern);
|
|
322
|
-
if (score > 0) {
|
|
323
|
-
files.push({
|
|
324
|
-
path: relativePath,
|
|
325
|
-
name: entry.name,
|
|
326
|
-
score,
|
|
327
|
-
});
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
// Process directories last
|
|
331
|
-
for (const entry of dirEntries) {
|
|
332
|
-
if (files.length >= maxResults)
|
|
333
|
-
return; // Early exit before recursion
|
|
334
|
-
const fullPath = path.join(dir, entry.name);
|
|
335
|
-
const relativePath = path.relative(this.currentDirectory, fullPath);
|
|
336
|
-
// Apply exclude pattern
|
|
337
|
-
if (options.excludePattern &&
|
|
338
|
-
relativePath.includes(options.excludePattern)) {
|
|
339
|
-
continue;
|
|
340
|
-
}
|
|
341
|
-
await walkDir(fullPath, depth + 1);
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
catch {
|
|
345
|
-
// Skip directories we can't read
|
|
346
|
-
}
|
|
347
|
-
};
|
|
348
|
-
await walkDir(this.currentDirectory);
|
|
349
|
-
// Sort by score (descending) and return top results
|
|
350
|
-
return files.sort((a, b) => b.score - a.score).slice(0, maxResults);
|
|
351
|
-
}
|
|
352
|
-
/**
|
|
353
|
-
* Calculate fuzzy match score for file names
|
|
354
|
-
*/
|
|
355
|
-
calculateFileScore(fileName, filePath, pattern) {
|
|
356
|
-
const lowerFileName = fileName.toLowerCase();
|
|
357
|
-
const lowerFilePath = filePath.toLowerCase();
|
|
358
|
-
// Exact matches get highest score
|
|
359
|
-
if (lowerFileName === pattern)
|
|
360
|
-
return SearchTool.SCORE_EXACT_MATCH;
|
|
361
|
-
if (lowerFileName.includes(pattern))
|
|
362
|
-
return SearchTool.SCORE_CONTAINS_MATCH;
|
|
363
|
-
if (lowerFilePath.includes(pattern))
|
|
364
|
-
return SearchTool.SCORE_PATH_MATCH;
|
|
365
|
-
// Fuzzy matching - check if all characters of pattern exist in order
|
|
366
|
-
return this.calculateFuzzyScore(lowerFileName, pattern, fileName.length);
|
|
367
|
-
}
|
|
368
|
-
/**
|
|
369
|
-
* Calculate fuzzy match score for character sequence matching
|
|
370
|
-
*/
|
|
371
|
-
calculateFuzzyScore(text, pattern, originalLength) {
|
|
372
|
-
let patternIndex = 0;
|
|
373
|
-
for (let i = 0; i < text.length && patternIndex < pattern.length; i++) {
|
|
374
|
-
if (text[i] === pattern[patternIndex]) {
|
|
375
|
-
patternIndex++;
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
// All characters found in order - score based on how close they are
|
|
379
|
-
return patternIndex === pattern.length
|
|
380
|
-
? Math.max(SearchTool.SCORE_FUZZY_MIN, SearchTool.SCORE_FUZZY_BASE - (originalLength - pattern.length))
|
|
381
|
-
: 0;
|
|
382
|
-
}
|
|
383
|
-
/**
|
|
384
|
-
* Format unified search results for display
|
|
385
|
-
*/
|
|
386
|
-
formatUnifiedResults(results, query, _searchType) {
|
|
387
|
-
if (results.length === 0) {
|
|
388
|
-
return `No results found for "${query}"`;
|
|
389
|
-
}
|
|
390
|
-
let output = `Search results for "${query}":\n`;
|
|
391
|
-
// Build file set and per-file match counts in a single pass to avoid O(n²) filters
|
|
392
|
-
const allFiles = new Set();
|
|
393
|
-
const matchCounts = new Map();
|
|
394
|
-
for (const result of results) {
|
|
395
|
-
allFiles.add(result.file);
|
|
396
|
-
if (result.type === 'text') {
|
|
397
|
-
const current = matchCounts.get(result.file) ?? 0;
|
|
398
|
-
matchCounts.set(result.file, current + 1);
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
const fileList = Array.from(allFiles);
|
|
402
|
-
const displayLimit = SearchTool.MAX_DISPLAY_RESULTS;
|
|
403
|
-
// Show files in compact format
|
|
404
|
-
fileList.slice(0, displayLimit).forEach((file) => {
|
|
405
|
-
// Count matches in this file for text results
|
|
406
|
-
const matchCount = matchCounts.get(file) ?? 0;
|
|
407
|
-
const matchIndicator = matchCount > 0 ? ` (${matchCount} matches)` : "";
|
|
408
|
-
output += ` ${file}${matchIndicator}\n`;
|
|
409
|
-
});
|
|
410
|
-
// Show "+X more" if there are additional results
|
|
411
|
-
if (fileList.length > displayLimit) {
|
|
412
|
-
const remaining = fileList.length - displayLimit;
|
|
413
|
-
output += ` ... +${remaining} more\n`;
|
|
414
|
-
}
|
|
415
|
-
return output.trim();
|
|
416
|
-
}
|
|
417
|
-
/**
|
|
418
|
-
* Update current working directory
|
|
419
|
-
*/
|
|
420
|
-
setCurrentDirectory(directory) {
|
|
421
|
-
this.currentDirectory = directory;
|
|
422
|
-
}
|
|
423
|
-
/**
|
|
424
|
-
* Get current working directory
|
|
425
|
-
*/
|
|
426
|
-
getCurrentDirectory() {
|
|
427
|
-
return this.currentDirectory;
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
//# sourceMappingURL=search.js.map
|