@machina.ai/cell-cli-core 1.6.1-rc2 → 1.10.0-rc1
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/dist/index.d.ts +4 -3
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/src/agents/codebase-investigator.d.ts +46 -0
- package/dist/src/agents/codebase-investigator.js +135 -0
- package/dist/src/agents/codebase-investigator.js.map +1 -0
- package/dist/src/agents/executor.d.ts +92 -0
- package/dist/src/agents/executor.js +579 -0
- package/dist/src/agents/executor.js.map +1 -0
- package/dist/src/agents/executor.test.d.ts +6 -0
- package/dist/src/agents/executor.test.js +680 -0
- package/dist/src/agents/executor.test.js.map +1 -0
- package/dist/src/agents/invocation.d.ts +46 -0
- package/dist/src/agents/invocation.js +102 -0
- package/dist/src/agents/invocation.js.map +1 -0
- package/dist/src/agents/invocation.test.d.ts +6 -0
- package/dist/src/agents/invocation.test.js +215 -0
- package/dist/src/agents/invocation.test.js.map +1 -0
- package/dist/src/agents/registry.d.ts +36 -0
- package/dist/src/agents/registry.js +81 -0
- package/dist/src/agents/registry.js.map +1 -0
- package/dist/src/agents/registry.test.d.ts +6 -0
- package/dist/src/agents/registry.test.js +146 -0
- package/dist/src/agents/registry.test.js.map +1 -0
- package/dist/src/agents/schema-utils.d.ts +39 -0
- package/dist/src/agents/schema-utils.js +57 -0
- package/dist/src/agents/schema-utils.js.map +1 -0
- package/dist/src/agents/schema-utils.test.d.ts +6 -0
- package/dist/src/agents/schema-utils.test.js +144 -0
- package/dist/src/agents/schema-utils.test.js.map +1 -0
- package/dist/src/agents/subagent-tool-wrapper.d.ts +38 -0
- package/dist/src/agents/subagent-tool-wrapper.js +48 -0
- package/dist/src/agents/subagent-tool-wrapper.js.map +1 -0
- package/dist/src/agents/subagent-tool-wrapper.test.d.ts +6 -0
- package/dist/src/agents/subagent-tool-wrapper.test.js +112 -0
- package/dist/src/agents/subagent-tool-wrapper.test.js.map +1 -0
- package/dist/src/agents/types.d.ts +145 -0
- package/dist/src/agents/types.js +18 -0
- package/dist/src/agents/types.js.map +1 -0
- package/dist/src/agents/utils.d.ts +15 -0
- package/dist/src/agents/utils.js +29 -0
- package/dist/src/agents/utils.js.map +1 -0
- package/dist/src/agents/utils.test.d.ts +6 -0
- package/dist/src/agents/utils.test.js +87 -0
- package/dist/src/agents/utils.test.js.map +1 -0
- package/dist/src/code_assist/oauth-credential-storage.js +1 -1
- package/dist/src/code_assist/oauth-credential-storage.js.map +1 -1
- package/dist/src/code_assist/oauth-credential-storage.test.js +1 -1
- package/dist/src/code_assist/oauth-credential-storage.test.js.map +1 -1
- package/dist/src/code_assist/oauth2.test.js +14 -13
- package/dist/src/code_assist/oauth2.test.js.map +1 -1
- package/dist/src/code_assist/setup.js +4 -2
- package/dist/src/code_assist/setup.js.map +1 -1
- package/dist/src/config/config.d.ts +61 -15
- package/dist/src/config/config.js +132 -28
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/config.test.js +67 -3
- package/dist/src/config/config.test.js.map +1 -1
- package/dist/src/config/constants.d.ts +11 -0
- package/dist/src/config/constants.js +16 -0
- package/dist/src/config/constants.js.map +1 -0
- package/dist/src/config/storage.d.ts +0 -1
- package/dist/src/config/storage.js +2 -2
- package/dist/src/config/storage.js.map +1 -1
- package/dist/src/config/storage.test.js +7 -6
- package/dist/src/config/storage.test.js.map +1 -1
- package/dist/src/core/baseLlmClient.d.ts +4 -0
- package/dist/src/core/baseLlmClient.js +24 -23
- package/dist/src/core/baseLlmClient.js.map +1 -1
- package/dist/src/core/baseLlmClient.test.js +76 -13
- package/dist/src/core/baseLlmClient.test.js.map +1 -1
- package/dist/src/core/client.d.ts +6 -3
- package/dist/src/core/client.js +103 -64
- package/dist/src/core/client.js.map +1 -1
- package/dist/src/core/client.test.js +470 -118
- package/dist/src/core/client.test.js.map +1 -1
- package/dist/src/core/contentGenerator.js +3 -1
- package/dist/src/core/contentGenerator.js.map +1 -1
- package/dist/src/core/coreToolScheduler.js +12 -12
- package/dist/src/core/coreToolScheduler.js.map +1 -1
- package/dist/src/core/coreToolScheduler.test.js +260 -23
- package/dist/src/core/coreToolScheduler.test.js.map +1 -1
- package/dist/src/core/geminiChat.d.ts +11 -14
- package/dist/src/core/geminiChat.js +80 -124
- package/dist/src/core/geminiChat.js.map +1 -1
- package/dist/src/core/geminiChat.test.js +316 -239
- package/dist/src/core/geminiChat.test.js.map +1 -1
- package/dist/src/core/logger.test.js +16 -16
- package/dist/src/core/logger.test.js.map +1 -1
- package/dist/src/core/nonInteractiveToolExecutor.d.ts +3 -2
- package/dist/src/core/nonInteractiveToolExecutor.js +2 -2
- package/dist/src/core/nonInteractiveToolExecutor.js.map +1 -1
- package/dist/src/core/nonInteractiveToolExecutor.test.js +19 -19
- package/dist/src/core/nonInteractiveToolExecutor.test.js.map +1 -1
- package/dist/src/core/prompts.d.ts +2 -1
- package/dist/src/core/prompts.js +53 -111
- package/dist/src/core/prompts.js.map +1 -1
- package/dist/src/core/prompts.test.js +83 -29
- package/dist/src/core/prompts.test.js.map +1 -1
- package/dist/src/core/subagent.js +1 -1
- package/dist/src/core/subagent.js.map +1 -1
- package/dist/src/core/subagent.test.js +38 -12
- package/dist/src/core/subagent.test.js.map +1 -1
- package/dist/src/core/turn.d.ts +15 -6
- package/dist/src/core/turn.js +14 -13
- package/dist/src/core/turn.js.map +1 -1
- package/dist/src/core/turn.test.js +14 -2
- package/dist/src/core/turn.test.js.map +1 -1
- package/dist/src/generated/git-commit.d.ts +2 -2
- package/dist/src/generated/git-commit.js +2 -2
- package/dist/src/generated/git-commit.js.map +1 -1
- package/dist/src/ide/detect-ide.d.ts +45 -14
- package/dist/src/ide/detect-ide.js +32 -69
- package/dist/src/ide/detect-ide.js.map +1 -1
- package/dist/src/ide/detect-ide.test.js +40 -46
- package/dist/src/ide/detect-ide.test.js.map +1 -1
- package/dist/src/ide/ide-client.d.ts +4 -4
- package/dist/src/ide/ide-client.js +33 -32
- package/dist/src/ide/ide-client.js.map +1 -1
- package/dist/src/ide/ide-client.test.js +12 -25
- package/dist/src/ide/ide-client.test.js.map +1 -1
- package/dist/src/ide/ide-installer.d.ts +2 -2
- package/dist/src/ide/ide-installer.js +8 -10
- package/dist/src/ide/ide-installer.js.map +1 -1
- package/dist/src/ide/ide-installer.test.js +33 -14
- package/dist/src/ide/ide-installer.test.js.map +1 -1
- package/dist/src/ide/process-utils.js +85 -75
- package/dist/src/ide/process-utils.js.map +1 -1
- package/dist/src/ide/process-utils.test.js +83 -90
- package/dist/src/ide/process-utils.test.js.map +1 -1
- package/dist/src/index.d.ts +7 -2
- package/dist/src/index.js +7 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/mcp/oauth-provider.d.ts +4 -1
- package/dist/src/mcp/oauth-provider.js +31 -25
- package/dist/src/mcp/oauth-provider.js.map +1 -1
- package/dist/src/mcp/sa-impersonation-provider.d.ts +33 -0
- package/dist/src/mcp/sa-impersonation-provider.js +130 -0
- package/dist/src/mcp/sa-impersonation-provider.js.map +1 -0
- package/dist/src/mcp/sa-impersonation-provider.test.d.ts +6 -0
- package/dist/src/mcp/sa-impersonation-provider.test.js +117 -0
- package/dist/src/mcp/sa-impersonation-provider.test.js.map +1 -0
- package/dist/src/mcp/token-storage/file-token-storage.js +2 -1
- package/dist/src/mcp/token-storage/file-token-storage.js.map +1 -1
- package/dist/src/mcp/token-storage/file-token-storage.test.js +4 -3
- package/dist/src/mcp/token-storage/file-token-storage.test.js.map +1 -1
- package/dist/src/policy/policy-engine.js +11 -2
- package/dist/src/policy/policy-engine.js.map +1 -1
- package/dist/src/policy/policy-engine.test.js +45 -0
- package/dist/src/policy/policy-engine.test.js.map +1 -1
- package/dist/src/routing/strategies/compositeStrategy.js +4 -3
- package/dist/src/routing/strategies/compositeStrategy.js.map +1 -1
- package/dist/src/services/chatRecordingService.d.ts +3 -2
- package/dist/src/services/chatRecordingService.js +3 -2
- package/dist/src/services/chatRecordingService.js.map +1 -1
- package/dist/src/services/fileSystemService.d.ts +9 -0
- package/dist/src/services/fileSystemService.js +11 -0
- package/dist/src/services/fileSystemService.js.map +1 -1
- package/dist/src/services/shellExecutionService.d.ts +3 -0
- package/dist/src/services/shellExecutionService.js +165 -49
- package/dist/src/services/shellExecutionService.js.map +1 -1
- package/dist/src/services/shellExecutionService.test.js +74 -5
- package/dist/src/services/shellExecutionService.test.js.map +1 -1
- package/dist/src/telemetry/activity-detector.d.ts +41 -0
- package/dist/src/telemetry/activity-detector.js +61 -0
- package/dist/src/telemetry/activity-detector.js.map +1 -0
- package/dist/src/telemetry/activity-detector.test.d.ts +6 -0
- package/dist/src/telemetry/activity-detector.test.js +136 -0
- package/dist/src/telemetry/activity-detector.test.js.map +1 -0
- package/dist/src/telemetry/activity-types.d.ts +19 -0
- package/dist/src/telemetry/activity-types.js +21 -0
- package/dist/src/telemetry/activity-types.js.map +1 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.d.ts +18 -2
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +257 -108
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.d.ts +1 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js +258 -33
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.d.ts +118 -100
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +146 -103
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js.map +1 -1
- package/dist/src/telemetry/config.d.ts +31 -0
- package/dist/src/telemetry/config.js +74 -0
- package/dist/src/telemetry/config.js.map +1 -0
- package/dist/src/telemetry/config.test.d.ts +6 -0
- package/dist/src/telemetry/config.test.js +124 -0
- package/dist/src/telemetry/config.test.js.map +1 -0
- package/dist/src/telemetry/constants.d.ts +0 -34
- package/dist/src/telemetry/constants.js +0 -34
- package/dist/src/telemetry/constants.js.map +1 -1
- package/dist/src/telemetry/index.d.ts +9 -3
- package/dist/src/telemetry/index.js +19 -2
- package/dist/src/telemetry/index.js.map +1 -1
- package/dist/src/telemetry/loggers.d.ts +10 -2
- package/dist/src/telemetry/loggers.js +206 -273
- package/dist/src/telemetry/loggers.js.map +1 -1
- package/dist/src/telemetry/loggers.test.circular.js +3 -3
- package/dist/src/telemetry/loggers.test.circular.js.map +1 -1
- package/dist/src/telemetry/loggers.test.js +316 -13
- package/dist/src/telemetry/loggers.test.js.map +1 -1
- package/dist/src/telemetry/memory-monitor.d.ts +149 -0
- package/dist/src/telemetry/memory-monitor.js +335 -0
- package/dist/src/telemetry/memory-monitor.js.map +1 -0
- package/dist/src/telemetry/memory-monitor.test.d.ts +6 -0
- package/dist/src/telemetry/memory-monitor.test.js +472 -0
- package/dist/src/telemetry/memory-monitor.test.js.map +1 -0
- package/dist/src/telemetry/metrics.d.ts +436 -11
- package/dist/src/telemetry/metrics.js +600 -110
- package/dist/src/telemetry/metrics.js.map +1 -1
- package/dist/src/telemetry/metrics.test.js +898 -16
- package/dist/src/telemetry/metrics.test.js.map +1 -1
- package/dist/src/telemetry/sdk.js +1 -1
- package/dist/src/telemetry/sdk.js.map +1 -1
- package/dist/src/telemetry/sdk.test.js +13 -0
- package/dist/src/telemetry/sdk.test.js.map +1 -1
- package/dist/src/telemetry/telemetryAttributes.d.ts +8 -0
- package/dist/src/telemetry/telemetryAttributes.js +18 -0
- package/dist/src/telemetry/telemetryAttributes.js.map +1 -0
- package/dist/src/telemetry/types.d.ts +168 -5
- package/dist/src/telemetry/types.js +696 -34
- package/dist/src/telemetry/types.js.map +1 -1
- package/dist/src/telemetry/uiTelemetry.d.ts +2 -2
- package/dist/src/telemetry/uiTelemetry.js +3 -4
- package/dist/src/telemetry/uiTelemetry.js.map +1 -1
- package/dist/src/telemetry/uiTelemetry.test.js +14 -14
- package/dist/src/telemetry/uiTelemetry.test.js.map +1 -1
- package/dist/src/test-utils/mock-tool.d.ts +28 -3
- package/dist/src/test-utils/mock-tool.js +71 -1
- package/dist/src/test-utils/mock-tool.js.map +1 -1
- package/dist/src/tools/glob.js +4 -2
- package/dist/src/tools/glob.js.map +1 -1
- package/dist/src/tools/ls.js +1 -1
- package/dist/src/tools/ls.js.map +1 -1
- package/dist/src/tools/mcp-client.d.ts +5 -14
- package/dist/src/tools/mcp-client.js +51 -98
- package/dist/src/tools/mcp-client.js.map +1 -1
- package/dist/src/tools/mcp-client.test.js +175 -157
- package/dist/src/tools/mcp-client.test.js.map +1 -1
- package/dist/src/tools/memoryTool.d.ts +1 -1
- package/dist/src/tools/memoryTool.js +1 -2
- package/dist/src/tools/memoryTool.js.map +1 -1
- package/dist/src/tools/memoryTool.test.js +9 -8
- package/dist/src/tools/memoryTool.test.js.map +1 -1
- package/dist/src/tools/message-bus-integration.test.d.ts +6 -0
- package/dist/src/tools/message-bus-integration.test.js +183 -0
- package/dist/src/tools/message-bus-integration.test.js.map +1 -0
- package/dist/src/tools/shell.js +60 -4
- package/dist/src/tools/shell.js.map +1 -1
- package/dist/src/tools/shell.test.js +2 -1
- package/dist/src/tools/shell.test.js.map +1 -1
- package/dist/src/tools/smart-edit.d.ts +1 -1
- package/dist/src/tools/smart-edit.js +116 -12
- package/dist/src/tools/smart-edit.js.map +1 -1
- package/dist/src/tools/smart-edit.test.js +91 -29
- package/dist/src/tools/smart-edit.test.js.map +1 -1
- package/dist/src/tools/tool-error.d.ts +22 -0
- package/dist/src/tools/tool-error.js +28 -0
- package/dist/src/tools/tool-error.js.map +1 -1
- package/dist/src/tools/tool-names.d.ts +9 -0
- package/dist/src/tools/tool-names.js +18 -0
- package/dist/src/tools/tool-names.js.map +1 -0
- package/dist/src/tools/tool-registry.test.js +10 -10
- package/dist/src/tools/tool-registry.test.js.map +1 -1
- package/dist/src/tools/tools.d.ts +11 -3
- package/dist/src/tools/tools.js +94 -3
- package/dist/src/tools/tools.js.map +1 -1
- package/dist/src/tools/web-fetch.d.ts +7 -0
- package/dist/src/tools/web-fetch.js +42 -10
- package/dist/src/tools/web-fetch.js.map +1 -1
- package/dist/src/tools/web-fetch.test.js +127 -8
- package/dist/src/tools/web-fetch.test.js.map +1 -1
- package/dist/src/tools/web-search.js +2 -1
- package/dist/src/tools/web-search.js.map +1 -1
- package/dist/src/tools/write-file.js +2 -1
- package/dist/src/tools/write-file.js.map +1 -1
- package/dist/src/tools/write-todos.d.ts +25 -0
- package/dist/src/tools/write-todos.js +151 -0
- package/dist/src/tools/write-todos.js.map +1 -0
- package/dist/src/tools/write-todos.test.d.ts +6 -0
- package/dist/src/tools/write-todos.test.js +89 -0
- package/dist/src/tools/write-todos.test.js.map +1 -0
- package/dist/src/utils/bfsFileSearch.d.ts +1 -1
- package/dist/src/utils/editCorrector.js +2 -2
- package/dist/src/utils/editCorrector.js.map +1 -1
- package/dist/src/utils/editor.js +1 -0
- package/dist/src/utils/editor.js.map +1 -1
- package/dist/src/utils/editor.test.js +1 -0
- package/dist/src/utils/editor.test.js.map +1 -1
- package/dist/src/utils/flashFallback.test.js +2 -2
- package/dist/src/utils/flashFallback.test.js.map +1 -1
- package/dist/src/utils/formatters.d.ts +1 -0
- package/dist/src/utils/formatters.js +2 -1
- package/dist/src/utils/formatters.js.map +1 -1
- package/dist/src/utils/formatters.test.d.ts +6 -0
- package/dist/src/utils/formatters.test.js +26 -0
- package/dist/src/utils/formatters.test.js.map +1 -0
- package/dist/src/utils/getFolderStructure.d.ts +1 -1
- package/dist/src/utils/getFolderStructure.js +1 -1
- package/dist/src/utils/getFolderStructure.js.map +1 -1
- package/dist/src/utils/getFolderStructure.test.js +7 -6
- package/dist/src/utils/getFolderStructure.test.js.map +1 -1
- package/dist/src/utils/installationManager.test.js +2 -1
- package/dist/src/utils/installationManager.test.js.map +1 -1
- package/dist/src/utils/llm-edit-fixer.js +14 -4
- package/dist/src/utils/llm-edit-fixer.js.map +1 -1
- package/dist/src/utils/llm-edit-fixer.test.js +81 -0
- package/dist/src/utils/llm-edit-fixer.test.js.map +1 -1
- package/dist/src/utils/memoryDiscovery.d.ts +2 -1
- package/dist/src/utils/memoryDiscovery.js +3 -2
- package/dist/src/utils/memoryDiscovery.js.map +1 -1
- package/dist/src/utils/memoryDiscovery.test.js +99 -21
- package/dist/src/utils/memoryDiscovery.test.js.map +1 -1
- package/dist/src/utils/memoryImportProcessor.js +13 -20
- package/dist/src/utils/memoryImportProcessor.js.map +1 -1
- package/dist/src/utils/memoryImportProcessor.test.js +14 -0
- package/dist/src/utils/memoryImportProcessor.test.js.map +1 -1
- package/dist/src/utils/pathCorrector.d.ts +25 -0
- package/dist/src/utils/pathCorrector.js +33 -0
- package/dist/src/utils/pathCorrector.js.map +1 -0
- package/dist/src/utils/pathCorrector.test.d.ts +6 -0
- package/dist/src/utils/pathCorrector.test.js +83 -0
- package/dist/src/utils/pathCorrector.test.js.map +1 -0
- package/dist/src/utils/retry.d.ts +4 -1
- package/dist/src/utils/retry.js +40 -17
- package/dist/src/utils/retry.js.map +1 -1
- package/dist/src/utils/retry.test.js +104 -31
- package/dist/src/utils/retry.test.js.map +1 -1
- package/dist/src/utils/schemaValidator.js +11 -1
- package/dist/src/utils/schemaValidator.js.map +1 -1
- package/dist/src/utils/schemaValidator.test.d.ts +6 -0
- package/dist/src/utils/schemaValidator.test.js +113 -0
- package/dist/src/utils/schemaValidator.test.js.map +1 -0
- package/dist/src/utils/shell-utils.d.ts +1 -0
- package/dist/src/utils/shell-utils.js +6 -2
- package/dist/src/utils/shell-utils.js.map +1 -1
- package/dist/src/utils/shell-utils.test.js +5 -0
- package/dist/src/utils/shell-utils.test.js.map +1 -1
- package/dist/src/utils/terminalSerializer.d.ts +1 -4
- package/dist/src/utils/terminalSerializer.js +3 -3
- package/dist/src/utils/terminalSerializer.js.map +1 -1
- package/dist/src/utils/thoughtUtils.d.ts +21 -0
- package/dist/src/utils/thoughtUtils.js +39 -0
- package/dist/src/utils/thoughtUtils.js.map +1 -0
- package/dist/src/utils/thoughtUtils.test.d.ts +6 -0
- package/dist/src/utils/thoughtUtils.test.js +78 -0
- package/dist/src/utils/thoughtUtils.test.js.map +1 -0
- package/dist/src/utils/tool-utils.js +2 -2
- package/dist/src/utils/tool-utils.js.map +1 -1
- package/dist/src/utils/tool-utils.test.js +8 -0
- package/dist/src/utils/tool-utils.test.js.map +1 -1
- package/dist/src/utils/userAccountManager.test.js +2 -1
- package/dist/src/utils/userAccountManager.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/dist/src/test-utils/tools.d.ts +0 -45
- package/dist/src/test-utils/tools.js +0 -105
- package/dist/src/test-utils/tools.js.map +0 -1
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
* Copyright 2025 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
+
import type { Config } from '../config/config.js';
|
|
6
7
|
export declare function resolvePathFromEnv(envVar?: string): {
|
|
7
8
|
isSwitch: boolean;
|
|
8
9
|
value: string | null;
|
|
9
10
|
isDisabled: boolean;
|
|
10
11
|
};
|
|
11
|
-
export declare function getCoreSystemPrompt(userMemory?: string): string;
|
|
12
|
+
export declare function getCoreSystemPrompt(config: Config, userMemory?: string): string;
|
|
12
13
|
/**
|
|
13
14
|
* Provides the system prompt for the history compression process.
|
|
14
15
|
* This prompt instructs the model to act as a specialized state manager,
|
package/dist/src/core/prompts.js
CHANGED
|
@@ -6,17 +6,18 @@
|
|
|
6
6
|
import path from 'node:path';
|
|
7
7
|
import fs from 'node:fs';
|
|
8
8
|
import os from 'node:os';
|
|
9
|
-
import { LSTool } from '../tools/ls.js';
|
|
10
9
|
import { EditTool } from '../tools/edit.js';
|
|
11
10
|
import { GlobTool } from '../tools/glob.js';
|
|
12
11
|
import { GrepTool } from '../tools/grep.js';
|
|
13
12
|
import { ReadFileTool } from '../tools/read-file.js';
|
|
14
13
|
import { ReadManyFilesTool } from '../tools/read-many-files.js';
|
|
15
14
|
import { ShellTool } from '../tools/shell.js';
|
|
16
|
-
import {
|
|
15
|
+
import { WRITE_FILE_TOOL_NAME } from '../tools/tool-names.js';
|
|
17
16
|
import process from 'node:process';
|
|
18
17
|
import { isGitRepository } from '../utils/gitUtils.js';
|
|
19
|
-
import { MemoryTool
|
|
18
|
+
import { MemoryTool } from '../tools/memoryTool.js';
|
|
19
|
+
import { CodebaseInvestigatorAgent } from '../agents/codebase-investigator.js';
|
|
20
|
+
import { CELL_DIR } from '../utils/paths.js';
|
|
20
21
|
export function resolvePathFromEnv(envVar) {
|
|
21
22
|
// Handle the case where the environment variable is not set, empty, or just whitespace.
|
|
22
23
|
const trimmedEnvVar = envVar?.trim();
|
|
@@ -57,11 +58,11 @@ export function resolvePathFromEnv(envVar) {
|
|
|
57
58
|
isDisabled: false,
|
|
58
59
|
};
|
|
59
60
|
}
|
|
60
|
-
export function getCoreSystemPrompt(userMemory) {
|
|
61
|
+
export function getCoreSystemPrompt(config, userMemory) {
|
|
61
62
|
// A flag to indicate whether the system prompt override is active.
|
|
62
63
|
let systemMdEnabled = false;
|
|
63
64
|
// The default path for the system prompt file. This can be overridden.
|
|
64
|
-
let systemMdPath = path.resolve(path.join(
|
|
65
|
+
let systemMdPath = path.resolve(path.join(CELL_DIR, 'system.md'));
|
|
65
66
|
// Resolve the environment variable to get either a path or a switch value.
|
|
66
67
|
const systemMdResolution = resolvePathFromEnv(process.env['CELL_SYSTEM_MD']);
|
|
67
68
|
// Proceed only if the environment variable is set and is not disabled.
|
|
@@ -76,10 +77,13 @@ export function getCoreSystemPrompt(userMemory) {
|
|
|
76
77
|
throw new Error(`missing system prompt file '${systemMdPath}'`);
|
|
77
78
|
}
|
|
78
79
|
}
|
|
80
|
+
const enableCodebaseInvestigator = config
|
|
81
|
+
.getToolRegistry()
|
|
82
|
+
.getAllToolNames()
|
|
83
|
+
.includes(CodebaseInvestigatorAgent.name);
|
|
79
84
|
const basePrompt = systemMdEnabled
|
|
80
85
|
? fs.readFileSync(systemMdPath, 'utf8')
|
|
81
|
-
: `
|
|
82
|
-
You are an interactive CLI agent specializing in software engineering tasks. Your primary goal is to help users safely and efficiently, adhering strictly to the following instructions and utilizing your available tools.
|
|
86
|
+
: `You are an interactive CLI agent specializing in software engineering tasks. Your primary goal is to help users safely and efficiently, adhering strictly to the following instructions and utilizing your available tools.
|
|
83
87
|
|
|
84
88
|
# Core Mandates
|
|
85
89
|
|
|
@@ -88,25 +92,35 @@ You are an interactive CLI agent specializing in software engineering tasks. You
|
|
|
88
92
|
- **Style & Structure:** Mimic the style (formatting, naming), structure, framework choices, typing, and architectural patterns of existing code in the project.
|
|
89
93
|
- **Idiomatic Changes:** When editing, understand the local context (imports, functions/classes) to ensure your changes integrate naturally and idiomatically.
|
|
90
94
|
- **Comments:** Add code comments sparingly. Focus on *why* something is done, especially for complex logic, rather than *what* is done. Only add high-value comments if necessary for clarity or if requested by the user. Do not edit comments that are separate from the code you are changing. *NEVER* talk to the user or describe your changes through comments.
|
|
91
|
-
- **Proactiveness:** Fulfill the user's request thoroughly,
|
|
95
|
+
- **Proactiveness:** Fulfill the user's request thoroughly. When adding features or fixing bugs, this includes adding tests to ensure quality. Consider all created files, especially tests, to be permanent artifacts unless the user says otherwise.
|
|
92
96
|
- **Confirm Ambiguity/Expansion:** Do not take significant actions beyond the clear scope of the request without confirming with the user. If asked *how* to do something, explain first, don't just do it.
|
|
93
97
|
- **Explaining Changes:** After completing a code modification or file operation *do not* provide summaries unless asked.
|
|
94
|
-
- **Path Construction:** Before using any file system tool (e.g., ${ReadFileTool.Name}' or '${
|
|
98
|
+
- **Path Construction:** Before using any file system tool (e.g., ${ReadFileTool.Name}' or '${WRITE_FILE_TOOL_NAME}'), you must construct the full absolute path for the file_path argument. Always combine the absolute path of the project's root directory with the file's path relative to the root. For example, if the project root is /path/to/project/ and the file is foo/bar/baz.txt, the final path you must use is /path/to/project/foo/bar/baz.txt. If the user provides a relative path, you must resolve it against the root directory to create an absolute path.
|
|
95
99
|
- **Do Not revert changes:** Do not revert changes to the codebase unless asked to do so by the user. Only revert changes made by you if they have resulted in an error or if the user has explicitly asked you to revert the changes.
|
|
96
100
|
|
|
101
|
+
|
|
97
102
|
# Primary Workflows
|
|
98
103
|
|
|
99
104
|
## Software Engineering Tasks
|
|
100
105
|
When requested to perform tasks like fixing bugs, adding features, refactoring, or explaining code, follow this sequence:
|
|
106
|
+
${(function () {
|
|
107
|
+
if (enableCodebaseInvestigator) {
|
|
108
|
+
return `
|
|
109
|
+
1. **Understand & Strategize:** Think about the user's request and the relevant codebase context. When the task involves **complex refactoring, codebase exploration or system-wide analysis**, your **first and primary tool** must be '${CodebaseInvestigatorAgent.name}'. Use it to build a comprehensive understanding of the code, its structure, and dependencies. For **simple, targeted searches** (like finding a specific function name, file path, or variable declaration), you should use '${GrepTool.Name}' or '${GlobTool.Name}' directly.
|
|
110
|
+
2. **Plan:** Build a coherent and grounded (based on the understanding in step 1) plan for how you intend to resolve the user's task. If '${CodebaseInvestigatorAgent.name}' was used, do not ignore the output of '${CodebaseInvestigatorAgent.name}', you must use it as the foundation of your plan. Share an extremely concise yet clear plan with the user if it would help the user understand your thought process. As part of the plan, you should use an iterative development process that includes writing unit tests to verify your changes. Use output logs or debug statements as part of this process to arrive at a solution.`;
|
|
111
|
+
}
|
|
112
|
+
return `
|
|
101
113
|
1. **Understand:** Think about the user's request and the relevant codebase context. Use '${GrepTool.Name}' and '${GlobTool.Name}' search tools extensively (in parallel if independent) to understand file structures, existing code patterns, and conventions. Use '${ReadFileTool.Name}' and '${ReadManyFilesTool.Name}' to understand context and validate any assumptions you may have.
|
|
102
|
-
2. **Plan:** Build a coherent and grounded (based on the understanding in step 1) plan for how you intend to resolve the user's task. Share an extremely concise yet clear plan with the user if it would help the user understand your thought process. As part of the plan, you should
|
|
103
|
-
|
|
114
|
+
2. **Plan:** Build a coherent and grounded (based on the understanding in step 1) plan for how you intend to resolve the user's task. Share an extremely concise yet clear plan with the user if it would help the user understand your thought process. As part of the plan, you should use an iterative development process that includes writing unit tests to verify your changes. Use output logs or debug statements as part of this process to arrive at a solution.`;
|
|
115
|
+
})()}
|
|
116
|
+
3. **Implement:** Use the available tools (e.g., '${EditTool.Name}', '${WRITE_FILE_TOOL_NAME}' '${ShellTool.Name}' ...) to act on the plan, strictly adhering to the project's established conventions (detailed under 'Core Mandates').
|
|
104
117
|
4. **Verify (Tests):** If applicable and feasible, verify the changes using the project's testing procedures. Identify the correct test commands and frameworks by examining 'README' files, build/package configuration (e.g., 'package.json'), or existing test execution patterns. NEVER assume standard test commands.
|
|
105
118
|
5. **Verify (Standards):** VERY IMPORTANT: After making code changes, execute the project-specific build, linting and type-checking commands (e.g., 'tsc', 'npm run lint', 'ruff check .') that you have identified for this project (or obtained from the user). This ensures code quality and adherence to standards. If unsure about these commands, you can ask the user if they'd like you to run them and if so how to.
|
|
119
|
+
6. **Finalize:** After all verification passes, consider the task complete. Do not remove or revert any changes or created files (like tests). Await the user's next instruction.
|
|
106
120
|
|
|
107
121
|
## New Applications
|
|
108
122
|
|
|
109
|
-
**Goal:** Autonomously implement and deliver a visually appealing, substantially complete, and functional prototype. Utilize all tools at your disposal to implement the application. Some tools you may especially find useful are '${
|
|
123
|
+
**Goal:** Autonomously implement and deliver a visually appealing, substantially complete, and functional prototype. Utilize all tools at your disposal to implement the application. Some tools you may especially find useful are '${WRITE_FILE_TOOL_NAME}', '${EditTool.Name}' and '${ShellTool.Name}'.
|
|
110
124
|
|
|
111
125
|
1. **Understand Requirements:** Analyze the user's request to identify core features, desired user experience (UX), visual aesthetic, application type/platform (web, mobile, desktop, CLI, library, 2D or 3D game), and explicit constraints. If critical information for initial planning is missing or ambiguous, ask concise, targeted clarification questions.
|
|
112
126
|
2. **Propose Plan:** Formulate an internal development plan. Present a clear, concise, high-level summary to the user. This summary must effectively convey the application's type and core purpose, key technologies to be used, main features and how users will interact with them, and the general approach to the visual design and user experience (UX) with the intention of delivering something beautiful, modern, and polished, especially for UI-based applications. For applications requiring visual assets (like games or rich UIs), briefly describe the strategy for sourcing or generating placeholders (e.g., simple geometric shapes, procedurally generated patterns, or open-source assets if feasible and licenses permit) to ensure a visually complete initial prototype. Ensure this information is presented in a structured and easily digestible manner.
|
|
@@ -124,6 +138,24 @@ When requested to perform tasks like fixing bugs, adding features, refactoring,
|
|
|
124
138
|
6. **Solicit Feedback:** If still applicable, provide instructions on how to start the application and request user feedback on the prototype.
|
|
125
139
|
|
|
126
140
|
# Operational Guidelines
|
|
141
|
+
${(function () {
|
|
142
|
+
if (config.getEnableShellOutputEfficiency()) {
|
|
143
|
+
const tempDir = config.storage.getProjectTempDir();
|
|
144
|
+
return `
|
|
145
|
+
## Shell tool output token efficiency:
|
|
146
|
+
|
|
147
|
+
IT IS CRITICAL TO FOLLOW THESE GUIDELINES TO AVOID EXCESSIVE TOKEN CONSUMPTION.
|
|
148
|
+
|
|
149
|
+
- Always prefer command flags that reduce output verbosity when using '${ShellTool.Name}'.
|
|
150
|
+
- Aim to minimize tool output tokens while still capturing necessary information.
|
|
151
|
+
- If a command is expected to produce a lot of output, use quiet or silent flags where available and appropriate.
|
|
152
|
+
- Always consider the trade-off between output verbosity and the need for information. If a command's full output is essential for understanding the result, avoid overly aggressive quieting that might obscure important details.
|
|
153
|
+
- If a command does not have quiet/silent flags or for commands with potentially long output that may not be useful, redirect stdout and stderr to temp files in the project's temporary directory: ${tempDir}. For example: 'command > ${path.posix.join(tempDir, 'out.log')} 2> ${path.posix.join(tempDir, 'err.log')}'.
|
|
154
|
+
- After the command runs, inspect the temp files (e.g. '${path.posix.join(tempDir, 'out.log')}' and '${path.posix.join(tempDir, 'err.log')}') using commands like 'grep', 'tail', 'head', ... (or platform equivalents). Remove the temp files when done.
|
|
155
|
+
`;
|
|
156
|
+
}
|
|
157
|
+
return '';
|
|
158
|
+
})()}
|
|
127
159
|
|
|
128
160
|
## Tone and Style (CLI Interaction)
|
|
129
161
|
- **Concise & Direct:** Adopt a professional, direct, and concise tone suitable for a CLI environment.
|
|
@@ -140,11 +172,18 @@ When requested to perform tasks like fixing bugs, adding features, refactoring,
|
|
|
140
172
|
- **Security First:** Always apply security best practices. Never introduce code that exposes, logs, or commits secrets, API keys, or other sensitive information.
|
|
141
173
|
|
|
142
174
|
## Tool Usage
|
|
143
|
-
- **File Paths:** Always use absolute paths when referring to files with tools like '${ReadFileTool.Name}' or '${
|
|
175
|
+
- **File Paths:** Always use absolute paths when referring to files with tools like '${ReadFileTool.Name}' or '${WRITE_FILE_TOOL_NAME}'. Relative paths are not supported. You must provide an absolute path.
|
|
144
176
|
- **Parallelism:** Execute multiple independent tool calls in parallel when feasible (i.e. searching the codebase).
|
|
145
177
|
- **Command Execution:** Use the '${ShellTool.Name}' tool for running shell commands, remembering the safety rule to explain modifying commands first.
|
|
146
178
|
- **Background Processes:** Use background processes (via \`&\`) for commands that are unlikely to stop on their own, e.g. \`node server.js &\`. If unsure, ask the user.
|
|
147
|
-
|
|
179
|
+
${(function () {
|
|
180
|
+
if (!config.isInteractiveShellEnabled()) {
|
|
181
|
+
return `- **Interactive Commands:** Some commands are interactive, meaning they can accept user input during their execution (e.g. ssh, vim). Only execute non-interactive commands. Use non-interactive versions of commands (e.g. \`npm init -y\` instead of \`npm init\`) when available. Interactive shell commands are not supported and may cause hangs until canceled by the user.`;
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
return `- **Interactive Commands:** Prefer non-interactive commands when it makes sense; however, some commands are only interactive and expect user input during their execution (e.g. ssh, vim). If you choose to execute an interactive command consider letting the user know they can press \`ctrl + f\` to focus into the shell to provide input.`;
|
|
185
|
+
}
|
|
186
|
+
})()}
|
|
148
187
|
- **Remembering Facts:** Use the '${MemoryTool.Name}' tool to remember specific, *user-related* facts or preferences when the user explicitly asks, or when they state a clear, concise piece of information that would help personalize or streamline *your future interactions with them* (e.g., preferred coding style, common project paths they use, personal tool aliases). This tool is for user-specific information that should persist across sessions. Do *not* use it for general project context or information. If unsure whether to save something, you can ask the user, "Should I remember that for you?"
|
|
149
188
|
- **Respect User Confirmations:** Most tool calls (also denoted as 'function calls') will first require confirmation from the user, where they will either approve or cancel the function call. If a user cancels a function call, respect their choice and do _not_ try to make the function call again. It is okay to request the tool call again _only_ if the user requests that same tool call on a subsequent prompt. When a user cancels a function call, assume best intentions from the user and consider inquiring if they prefer any alternative paths forward.
|
|
150
189
|
|
|
@@ -198,103 +237,6 @@ ${(function () {
|
|
|
198
237
|
return '';
|
|
199
238
|
})()}
|
|
200
239
|
|
|
201
|
-
# Examples (Illustrating Tone and Workflow)
|
|
202
|
-
<example>
|
|
203
|
-
user: 1 + 2
|
|
204
|
-
model: 3
|
|
205
|
-
</example>
|
|
206
|
-
|
|
207
|
-
<example>
|
|
208
|
-
user: is 13 a prime number?
|
|
209
|
-
model: true
|
|
210
|
-
</example>
|
|
211
|
-
|
|
212
|
-
<example>
|
|
213
|
-
user: list files here.
|
|
214
|
-
model: [tool_call: ${LSTool.Name} for path '/path/to/project']
|
|
215
|
-
</example>
|
|
216
|
-
|
|
217
|
-
<example>
|
|
218
|
-
user: start the server implemented in server.js
|
|
219
|
-
model: [tool_call: ${ShellTool.Name} for 'node server.js &' because it must run in the background]
|
|
220
|
-
</example>
|
|
221
|
-
|
|
222
|
-
<example>
|
|
223
|
-
user: Refactor the auth logic in src/auth.py to use the requests library instead of urllib.
|
|
224
|
-
model: Okay, I can refactor 'src/auth.py'.
|
|
225
|
-
First, I'll analyze the code and check for a test safety net before planning any changes.
|
|
226
|
-
[tool_call: ${GlobTool.Name} for path 'tests/test_auth.py']
|
|
227
|
-
[tool_call: ${ReadFileTool.Name} for absolute_path '/path/to/tests/test_auth.py']
|
|
228
|
-
(After analysis)
|
|
229
|
-
Great, 'tests/test_auth.py' exists and covers the core authentication logic. With this safety net in place, I can safely plan the refactoring.
|
|
230
|
-
I'll also confirm 'requests' is a dependency.
|
|
231
|
-
[tool_call: ${ReadFileTool.Name} for absolute_path '/path/to/requirements.txt']
|
|
232
|
-
(After analysis)
|
|
233
|
-
Looks good, 'requests' is available.
|
|
234
|
-
|
|
235
|
-
Here's the plan:
|
|
236
|
-
1. Replace the 'urllib' calls with 'requests'.
|
|
237
|
-
2. Add proper 'try...except' error handling for the new network calls.
|
|
238
|
-
3. Remove the old 'urllib' import.
|
|
239
|
-
4. Run the project's linter and tests to verify the changes.
|
|
240
|
-
|
|
241
|
-
Should I proceed?
|
|
242
|
-
user: Yes
|
|
243
|
-
model:
|
|
244
|
-
[tool_call: ${WriteFileTool.Name} or ${EditTool.Name} to apply the refactoring to 'src/auth.py']
|
|
245
|
-
Refactoring complete. Running verification...
|
|
246
|
-
[tool_call: ${ShellTool.Name} for 'ruff check src/auth.py && pytest']
|
|
247
|
-
(After verification passes)
|
|
248
|
-
All checks passed. This is a stable checkpoint.
|
|
249
|
-
${(function () {
|
|
250
|
-
if (isGitRepository(process.cwd())) {
|
|
251
|
-
return `Would you like me to write a commit message and commit these changes?`;
|
|
252
|
-
}
|
|
253
|
-
return '';
|
|
254
|
-
})()}
|
|
255
|
-
</example>
|
|
256
|
-
|
|
257
|
-
<example>
|
|
258
|
-
user: Delete the temp directory.
|
|
259
|
-
model: I can run \`rm -rf /path/to/project/temp\`. This will permanently delete the directory and all its contents.
|
|
260
|
-
</example>
|
|
261
|
-
|
|
262
|
-
<example>
|
|
263
|
-
user: Write tests for someFile.ts
|
|
264
|
-
model:
|
|
265
|
-
Okay, I can write those tests. First, I'll read \`someFile.ts\` to understand its functionality.
|
|
266
|
-
[tool_call: ${ReadFileTool.Name} for absolute_path '/path/to/someFile.ts' or use ${GlobTool.Name} to find \`someFile.ts\` if its location is unknown]
|
|
267
|
-
Now I'll look for existing or related test files to understand current testing conventions and dependencies.
|
|
268
|
-
[tool_call: ${ReadManyFilesTool.Name} for paths ['**/*.test.ts', 'src/**/*.spec.ts'] assuming someFile.ts is in the src directory]
|
|
269
|
-
(After reviewing existing tests and the file content)
|
|
270
|
-
[tool_call: ${WriteFileTool.Name} to create /path/to/someFile.test.ts with the test code]
|
|
271
|
-
I've written the tests. Now I'll run the project's test command to verify them.
|
|
272
|
-
[tool_call: ${ShellTool.Name} for 'npm run test']
|
|
273
|
-
</example>
|
|
274
|
-
|
|
275
|
-
<example>
|
|
276
|
-
user: How do I update the user's profile information in this system?
|
|
277
|
-
model:
|
|
278
|
-
I'm not immediately sure how user profile information is updated. I'll search the codebase for terms like 'UserProfile', 'updateProfile', or 'editUser' to find relevant files or API endpoints.
|
|
279
|
-
[tool_call: ${GrepTool.Name} for pattern 'UserProfile|updateProfile|editUser']
|
|
280
|
-
(After reviewing search results, assuming a relevant file like '/path/to/UserProfileService.java' was found)
|
|
281
|
-
Okay, \`/path/to/UserProfileService.java\` seems like the most relevant file. I'll read its content to understand how updates are handled.
|
|
282
|
-
[tool_call: ${ReadFileTool.Name} for absolute_path '/path/to/UserProfileService.java']
|
|
283
|
-
(After reading the file)
|
|
284
|
-
It appears the \`updateUserProfile\` method in \`UserProfileService.java\` is responsible for this. It expects a user ID and a \`UserProfileDTO\` object...
|
|
285
|
-
</example>
|
|
286
|
-
|
|
287
|
-
<example>
|
|
288
|
-
user: Where are all the 'app.config' files in this project? I need to check their settings.
|
|
289
|
-
model:
|
|
290
|
-
[tool_call: ${GlobTool.Name} for pattern '**/app.config']
|
|
291
|
-
(Assuming GlobTool returns a list of paths like ['/path/to/moduleA/app.config', '/path/to/moduleB/app.config'])
|
|
292
|
-
I found the following 'app.config' files:
|
|
293
|
-
- /path/to/moduleA/app.config
|
|
294
|
-
- /path/to/moduleB/app.config
|
|
295
|
-
To help you check their settings, I can read their contents. Which one would you like to start with, or should I read all of them?
|
|
296
|
-
</example>
|
|
297
|
-
|
|
298
240
|
# Final Reminder
|
|
299
241
|
Your core function is efficient and safe assistance. Balance extreme conciseness with the crucial need for clarity, especially regarding safety and potential system modifications. Always prioritize user control and project conventions. Never make assumptions about the contents of files; instead use '${ReadFileTool.Name}' or '${ReadManyFilesTool.Name}' to ensure you aren't making broad assumptions. Finally, you are an agent - please keep going until the user's query is completely resolved.
|
|
300
242
|
`.trim();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../../src/core/prompts.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../../src/core/prompts.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAE/E,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,MAAM,UAAU,kBAAkB,CAAC,MAAe;IAKhD,wFAAwF;IACxF,MAAM,aAAa,GAAG,MAAM,EAAE,IAAI,EAAE,CAAC;IACrC,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,K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AAS,EAAE,UAAU,CAAC,CAAC;IAC1C,CAAC;IAED,MAAM,YAAY,GAChB,UAAU,IAAI,UAAU,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC;QACxC,CAAC,CAAC,cAAc,UAAU,CAAC,IAAI,EAAE,EAAE;QACnC,CAAC,CAAC,EAAE,CAAC;IAET,OAAO,GAAG,UAAU,GAAG,YAAY,EAAE,CAAC;AACxC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB;IAClC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwDR,CAAC,IAAI,EAAE,CAAC;AACT,CAAC"}
|
|
@@ -9,7 +9,8 @@ import { isGitRepository } from '../utils/gitUtils.js';
|
|
|
9
9
|
import fs from 'node:fs';
|
|
10
10
|
import os from 'node:os';
|
|
11
11
|
import path from 'node:path';
|
|
12
|
-
import {
|
|
12
|
+
import { CodebaseInvestigatorAgent } from '../agents/codebase-investigator.js';
|
|
13
|
+
import { CELL_DIR } from '../utils/paths.js';
|
|
13
14
|
// Mock tool names if they are dynamically generated or complex
|
|
14
15
|
vi.mock('../tools/ls', () => ({ LSTool: { Name: 'list_directory' } }));
|
|
15
16
|
vi.mock('../tools/edit', () => ({ EditTool: { Name: 'replace' } }));
|
|
@@ -25,33 +26,48 @@ vi.mock('../tools/shell', () => ({
|
|
|
25
26
|
vi.mock('../tools/write-file', () => ({
|
|
26
27
|
WriteFileTool: { Name: 'write_file' },
|
|
27
28
|
}));
|
|
29
|
+
vi.mock('../agents/codebase-investigator.js', () => ({
|
|
30
|
+
CodebaseInvestigatorAgent: { name: 'codebase_investigator' },
|
|
31
|
+
}));
|
|
28
32
|
vi.mock('../utils/gitUtils', () => ({
|
|
29
33
|
isGitRepository: vi.fn(),
|
|
30
34
|
}));
|
|
31
35
|
vi.mock('node:fs');
|
|
32
36
|
describe('Core System Prompt (prompts.ts)', () => {
|
|
37
|
+
let mockConfig;
|
|
33
38
|
beforeEach(() => {
|
|
34
39
|
vi.resetAllMocks();
|
|
35
40
|
vi.stubEnv('CELL_SYSTEM_MD', undefined);
|
|
36
41
|
vi.stubEnv('CELL_WRITE_SYSTEM_MD', undefined);
|
|
42
|
+
mockConfig = {
|
|
43
|
+
getToolRegistry: vi.fn().mockReturnValue({
|
|
44
|
+
getAllToolNames: vi.fn().mockReturnValue([]),
|
|
45
|
+
}),
|
|
46
|
+
getEnableShellOutputEfficiency: vi.fn().mockReturnValue(true),
|
|
47
|
+
storage: {
|
|
48
|
+
getProjectTempDir: vi.fn().mockReturnValue('/tmp/project-temp'),
|
|
49
|
+
},
|
|
50
|
+
isInteractive: vi.fn().mockReturnValue(true),
|
|
51
|
+
isInteractiveShellEnabled: vi.fn().mockReturnValue(true),
|
|
52
|
+
};
|
|
37
53
|
});
|
|
38
54
|
it('should return the base prompt when no userMemory is provided', () => {
|
|
39
55
|
vi.stubEnv('SANDBOX', undefined);
|
|
40
|
-
const prompt = getCoreSystemPrompt();
|
|
56
|
+
const prompt = getCoreSystemPrompt(mockConfig, '');
|
|
41
57
|
expect(prompt).not.toContain('---\n\n'); // Separator should not be present
|
|
42
58
|
expect(prompt).toContain('You are an interactive CLI agent'); // Check for core content
|
|
43
59
|
expect(prompt).toMatchSnapshot(); // Use snapshot for base prompt structure
|
|
44
60
|
});
|
|
45
61
|
it('should return the base prompt when userMemory is empty string', () => {
|
|
46
62
|
vi.stubEnv('SANDBOX', undefined);
|
|
47
|
-
const prompt = getCoreSystemPrompt('');
|
|
63
|
+
const prompt = getCoreSystemPrompt(mockConfig, '');
|
|
48
64
|
expect(prompt).not.toContain('---\n\n');
|
|
49
65
|
expect(prompt).toContain('You are an interactive CLI agent');
|
|
50
66
|
expect(prompt).toMatchSnapshot();
|
|
51
67
|
});
|
|
52
68
|
it('should return the base prompt when userMemory is whitespace only', () => {
|
|
53
69
|
vi.stubEnv('SANDBOX', undefined);
|
|
54
|
-
const prompt = getCoreSystemPrompt(' \n \t ');
|
|
70
|
+
const prompt = getCoreSystemPrompt(mockConfig, ' \n \t ');
|
|
55
71
|
expect(prompt).not.toContain('---\n\n');
|
|
56
72
|
expect(prompt).toContain('You are an interactive CLI agent');
|
|
57
73
|
expect(prompt).toMatchSnapshot();
|
|
@@ -60,14 +76,14 @@ describe('Core System Prompt (prompts.ts)', () => {
|
|
|
60
76
|
vi.stubEnv('SANDBOX', undefined);
|
|
61
77
|
const memory = 'This is custom user memory.\nBe extra polite.';
|
|
62
78
|
const expectedSuffix = `\n\n---\n\n${memory}`;
|
|
63
|
-
const prompt = getCoreSystemPrompt(memory);
|
|
79
|
+
const prompt = getCoreSystemPrompt(mockConfig, memory);
|
|
64
80
|
expect(prompt.endsWith(expectedSuffix)).toBe(true);
|
|
65
81
|
expect(prompt).toContain('You are an interactive CLI agent'); // Ensure base prompt follows
|
|
66
82
|
expect(prompt).toMatchSnapshot(); // Snapshot the combined prompt
|
|
67
83
|
});
|
|
68
84
|
it('should include sandbox-specific instructions when SANDBOX env var is set', () => {
|
|
69
85
|
vi.stubEnv('SANDBOX', 'true'); // Generic sandbox value
|
|
70
|
-
const prompt = getCoreSystemPrompt();
|
|
86
|
+
const prompt = getCoreSystemPrompt(mockConfig);
|
|
71
87
|
expect(prompt).toContain('# Sandbox');
|
|
72
88
|
expect(prompt).not.toContain('# macOS Seatbelt');
|
|
73
89
|
expect(prompt).not.toContain('# Outside of Sandbox');
|
|
@@ -75,15 +91,15 @@ describe('Core System Prompt (prompts.ts)', () => {
|
|
|
75
91
|
});
|
|
76
92
|
it('should include seatbelt-specific instructions when SANDBOX env var is "sandbox-exec"', () => {
|
|
77
93
|
vi.stubEnv('SANDBOX', 'sandbox-exec');
|
|
78
|
-
const prompt = getCoreSystemPrompt();
|
|
94
|
+
const prompt = getCoreSystemPrompt(mockConfig);
|
|
79
95
|
expect(prompt).toContain('# macOS Seatbelt');
|
|
80
96
|
expect(prompt).not.toContain('# Sandbox');
|
|
81
97
|
expect(prompt).not.toContain('# Outside of Sandbox');
|
|
82
98
|
expect(prompt).toMatchSnapshot();
|
|
83
99
|
});
|
|
84
100
|
it('should include non-sandbox instructions when SANDBOX env var is not set', () => {
|
|
85
|
-
vi.stubEnv('SANDBOX', undefined); // Ensure it's not set
|
|
86
|
-
const prompt = getCoreSystemPrompt();
|
|
101
|
+
vi.stubEnv('SANDBOX', undefined); // Ensure it\'s not set
|
|
102
|
+
const prompt = getCoreSystemPrompt(mockConfig);
|
|
87
103
|
expect(prompt).toContain('# Outside of Sandbox');
|
|
88
104
|
expect(prompt).not.toContain('# Sandbox');
|
|
89
105
|
expect(prompt).not.toContain('# macOS Seatbelt');
|
|
@@ -92,27 +108,65 @@ describe('Core System Prompt (prompts.ts)', () => {
|
|
|
92
108
|
it('should include git instructions when in a git repo', () => {
|
|
93
109
|
vi.stubEnv('SANDBOX', undefined);
|
|
94
110
|
vi.mocked(isGitRepository).mockReturnValue(true);
|
|
95
|
-
const prompt = getCoreSystemPrompt();
|
|
111
|
+
const prompt = getCoreSystemPrompt(mockConfig);
|
|
96
112
|
expect(prompt).toContain('# Git Repository');
|
|
97
113
|
expect(prompt).toMatchSnapshot();
|
|
98
114
|
});
|
|
99
115
|
it('should not include git instructions when not in a git repo', () => {
|
|
100
116
|
vi.stubEnv('SANDBOX', undefined);
|
|
101
117
|
vi.mocked(isGitRepository).mockReturnValue(false);
|
|
102
|
-
const prompt = getCoreSystemPrompt();
|
|
118
|
+
const prompt = getCoreSystemPrompt(mockConfig);
|
|
103
119
|
expect(prompt).not.toContain('# Git Repository');
|
|
104
120
|
expect(prompt).toMatchSnapshot();
|
|
105
121
|
});
|
|
122
|
+
it('should return the interactive avoidance prompt when in non-interactive mode', () => {
|
|
123
|
+
vi.stubEnv('SANDBOX', undefined);
|
|
124
|
+
mockConfig.isInteractive = vi.fn().mockReturnValue(false);
|
|
125
|
+
const prompt = getCoreSystemPrompt(mockConfig, '');
|
|
126
|
+
expect(prompt).toContain('**Interactive Commands:**'); // Check for interactive prompt
|
|
127
|
+
expect(prompt).toMatchSnapshot(); // Use snapshot for base prompt structure
|
|
128
|
+
});
|
|
129
|
+
describe('with CodebaseInvestigator enabled', () => {
|
|
130
|
+
beforeEach(() => {
|
|
131
|
+
mockConfig = {
|
|
132
|
+
getToolRegistry: vi.fn().mockReturnValue({
|
|
133
|
+
getAllToolNames: vi
|
|
134
|
+
.fn()
|
|
135
|
+
.mockReturnValue([CodebaseInvestigatorAgent.name]),
|
|
136
|
+
}),
|
|
137
|
+
getEnableShellOutputEfficiency: vi.fn().mockReturnValue(true),
|
|
138
|
+
storage: {
|
|
139
|
+
getProjectTempDir: vi.fn().mockReturnValue('/tmp/project-temp'),
|
|
140
|
+
},
|
|
141
|
+
isInteractive: vi.fn().mockReturnValue(false),
|
|
142
|
+
isInteractiveShellEnabled: vi.fn().mockReturnValue(false),
|
|
143
|
+
};
|
|
144
|
+
});
|
|
145
|
+
it('should include CodebaseInvestigator instructions in the prompt', () => {
|
|
146
|
+
const prompt = getCoreSystemPrompt(mockConfig);
|
|
147
|
+
expect(prompt).toContain(`your **first and primary tool** must be '${CodebaseInvestigatorAgent.name}'`);
|
|
148
|
+
expect(prompt).toContain(`do not ignore the output of '${CodebaseInvestigatorAgent.name}'`);
|
|
149
|
+
expect(prompt).not.toContain("Use 'search_file_content' and 'glob' search tools extensively");
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
describe('with CodebaseInvestigator disabled', () => {
|
|
153
|
+
// No beforeEach needed, will use the default from the parent describe
|
|
154
|
+
it('should include standard tool instructions in the prompt', () => {
|
|
155
|
+
const prompt = getCoreSystemPrompt(mockConfig);
|
|
156
|
+
expect(prompt).not.toContain(`your **first and primary tool** must be '${CodebaseInvestigatorAgent.name}'`);
|
|
157
|
+
expect(prompt).toContain("Use 'search_file_content' and 'glob' search tools extensively");
|
|
158
|
+
});
|
|
159
|
+
});
|
|
106
160
|
describe('CELL_SYSTEM_MD environment variable', () => {
|
|
107
161
|
it('should use default prompt when CELL_SYSTEM_MD is "false"', () => {
|
|
108
162
|
vi.stubEnv('CELL_SYSTEM_MD', 'false');
|
|
109
|
-
const prompt = getCoreSystemPrompt();
|
|
163
|
+
const prompt = getCoreSystemPrompt(mockConfig);
|
|
110
164
|
expect(fs.readFileSync).not.toHaveBeenCalled();
|
|
111
165
|
expect(prompt).not.toContain('custom system prompt');
|
|
112
166
|
});
|
|
113
167
|
it('should use default prompt when CELL_SYSTEM_MD is "0"', () => {
|
|
114
168
|
vi.stubEnv('CELL_SYSTEM_MD', '0');
|
|
115
|
-
const prompt = getCoreSystemPrompt();
|
|
169
|
+
const prompt = getCoreSystemPrompt(mockConfig);
|
|
116
170
|
expect(fs.readFileSync).not.toHaveBeenCalled();
|
|
117
171
|
expect(prompt).not.toContain('custom system prompt');
|
|
118
172
|
});
|
|
@@ -120,23 +174,23 @@ describe('Core System Prompt (prompts.ts)', () => {
|
|
|
120
174
|
const customPath = '/non/existent/path/system.md';
|
|
121
175
|
vi.stubEnv('CELL_SYSTEM_MD', customPath);
|
|
122
176
|
vi.mocked(fs.existsSync).mockReturnValue(false);
|
|
123
|
-
expect(() => getCoreSystemPrompt()).toThrow(`missing system prompt file '${path.resolve(customPath)}'`);
|
|
177
|
+
expect(() => getCoreSystemPrompt(mockConfig)).toThrow(`missing system prompt file '${path.resolve(customPath)}'`);
|
|
124
178
|
});
|
|
125
179
|
it('should read from default path when CELL_SYSTEM_MD is "true"', () => {
|
|
126
|
-
const defaultPath = path.resolve(path.join(
|
|
180
|
+
const defaultPath = path.resolve(path.join(CELL_DIR, 'system.md'));
|
|
127
181
|
vi.stubEnv('CELL_SYSTEM_MD', 'true');
|
|
128
182
|
vi.mocked(fs.existsSync).mockReturnValue(true);
|
|
129
183
|
vi.mocked(fs.readFileSync).mockReturnValue('custom system prompt');
|
|
130
|
-
const prompt = getCoreSystemPrompt();
|
|
184
|
+
const prompt = getCoreSystemPrompt(mockConfig);
|
|
131
185
|
expect(fs.readFileSync).toHaveBeenCalledWith(defaultPath, 'utf8');
|
|
132
186
|
expect(prompt).toBe('custom system prompt');
|
|
133
187
|
});
|
|
134
188
|
it('should read from default path when CELL_SYSTEM_MD is "1"', () => {
|
|
135
|
-
const defaultPath = path.resolve(path.join(
|
|
189
|
+
const defaultPath = path.resolve(path.join(CELL_DIR, 'system.md'));
|
|
136
190
|
vi.stubEnv('CELL_SYSTEM_MD', '1');
|
|
137
191
|
vi.mocked(fs.existsSync).mockReturnValue(true);
|
|
138
192
|
vi.mocked(fs.readFileSync).mockReturnValue('custom system prompt');
|
|
139
|
-
const prompt = getCoreSystemPrompt();
|
|
193
|
+
const prompt = getCoreSystemPrompt(mockConfig);
|
|
140
194
|
expect(fs.readFileSync).toHaveBeenCalledWith(defaultPath, 'utf8');
|
|
141
195
|
expect(prompt).toBe('custom system prompt');
|
|
142
196
|
});
|
|
@@ -145,7 +199,7 @@ describe('Core System Prompt (prompts.ts)', () => {
|
|
|
145
199
|
vi.stubEnv('CELL_SYSTEM_MD', customPath);
|
|
146
200
|
vi.mocked(fs.existsSync).mockReturnValue(true);
|
|
147
201
|
vi.mocked(fs.readFileSync).mockReturnValue('custom system prompt');
|
|
148
|
-
const prompt = getCoreSystemPrompt();
|
|
202
|
+
const prompt = getCoreSystemPrompt(mockConfig);
|
|
149
203
|
expect(fs.readFileSync).toHaveBeenCalledWith(customPath, 'utf8');
|
|
150
204
|
expect(prompt).toBe('custom system prompt');
|
|
151
205
|
});
|
|
@@ -157,7 +211,7 @@ describe('Core System Prompt (prompts.ts)', () => {
|
|
|
157
211
|
vi.stubEnv('CELL_SYSTEM_MD', customPath);
|
|
158
212
|
vi.mocked(fs.existsSync).mockReturnValue(true);
|
|
159
213
|
vi.mocked(fs.readFileSync).mockReturnValue('custom system prompt');
|
|
160
|
-
const prompt = getCoreSystemPrompt();
|
|
214
|
+
const prompt = getCoreSystemPrompt(mockConfig);
|
|
161
215
|
expect(fs.readFileSync).toHaveBeenCalledWith(path.resolve(expectedPath), 'utf8');
|
|
162
216
|
expect(prompt).toBe('custom system prompt');
|
|
163
217
|
});
|
|
@@ -165,30 +219,30 @@ describe('Core System Prompt (prompts.ts)', () => {
|
|
|
165
219
|
describe('CELL_WRITE_SYSTEM_MD environment variable', () => {
|
|
166
220
|
it('should not write to file when CELL_WRITE_SYSTEM_MD is "false"', () => {
|
|
167
221
|
vi.stubEnv('CELL_WRITE_SYSTEM_MD', 'false');
|
|
168
|
-
getCoreSystemPrompt();
|
|
222
|
+
getCoreSystemPrompt(mockConfig);
|
|
169
223
|
expect(fs.writeFileSync).not.toHaveBeenCalled();
|
|
170
224
|
});
|
|
171
225
|
it('should not write to file when CELL_WRITE_SYSTEM_MD is "0"', () => {
|
|
172
226
|
vi.stubEnv('CELL_WRITE_SYSTEM_MD', '0');
|
|
173
|
-
getCoreSystemPrompt();
|
|
227
|
+
getCoreSystemPrompt(mockConfig);
|
|
174
228
|
expect(fs.writeFileSync).not.toHaveBeenCalled();
|
|
175
229
|
});
|
|
176
230
|
it('should write to default path when CELL_WRITE_SYSTEM_MD is "true"', () => {
|
|
177
|
-
const defaultPath = path.resolve(path.join(
|
|
231
|
+
const defaultPath = path.resolve(path.join(CELL_DIR, 'system.md'));
|
|
178
232
|
vi.stubEnv('CELL_WRITE_SYSTEM_MD', 'true');
|
|
179
|
-
getCoreSystemPrompt();
|
|
233
|
+
getCoreSystemPrompt(mockConfig);
|
|
180
234
|
expect(fs.writeFileSync).toHaveBeenCalledWith(defaultPath, expect.any(String));
|
|
181
235
|
});
|
|
182
236
|
it('should write to default path when CELL_WRITE_SYSTEM_MD is "1"', () => {
|
|
183
|
-
const defaultPath = path.resolve(path.join(
|
|
237
|
+
const defaultPath = path.resolve(path.join(CELL_DIR, 'system.md'));
|
|
184
238
|
vi.stubEnv('CELL_WRITE_SYSTEM_MD', '1');
|
|
185
|
-
getCoreSystemPrompt();
|
|
239
|
+
getCoreSystemPrompt(mockConfig);
|
|
186
240
|
expect(fs.writeFileSync).toHaveBeenCalledWith(defaultPath, expect.any(String));
|
|
187
241
|
});
|
|
188
242
|
it('should write to custom path when CELL_WRITE_SYSTEM_MD provides one', () => {
|
|
189
243
|
const customPath = path.resolve('/custom/path/system.md');
|
|
190
244
|
vi.stubEnv('CELL_WRITE_SYSTEM_MD', customPath);
|
|
191
|
-
getCoreSystemPrompt();
|
|
245
|
+
getCoreSystemPrompt(mockConfig);
|
|
192
246
|
expect(fs.writeFileSync).toHaveBeenCalledWith(customPath, expect.any(String));
|
|
193
247
|
});
|
|
194
248
|
it('should expand tilde in custom path when CELL_WRITE_SYSTEM_MD is set', () => {
|
|
@@ -197,7 +251,7 @@ describe('Core System Prompt (prompts.ts)', () => {
|
|
|
197
251
|
const customPath = '~/custom/system.md';
|
|
198
252
|
const expectedPath = path.join(homeDir, 'custom/system.md');
|
|
199
253
|
vi.stubEnv('CELL_WRITE_SYSTEM_MD', customPath);
|
|
200
|
-
getCoreSystemPrompt();
|
|
254
|
+
getCoreSystemPrompt(mockConfig);
|
|
201
255
|
expect(fs.writeFileSync).toHaveBeenCalledWith(path.resolve(expectedPath), expect.any(String));
|
|
202
256
|
});
|
|
203
257
|
it('should expand tilde in custom path when CELL_WRITE_SYSTEM_MD is just ~', () => {
|
|
@@ -206,7 +260,7 @@ describe('Core System Prompt (prompts.ts)', () => {
|
|
|
206
260
|
const customPath = '~';
|
|
207
261
|
const expectedPath = homeDir;
|
|
208
262
|
vi.stubEnv('CELL_WRITE_SYSTEM_MD', customPath);
|
|
209
|
-
getCoreSystemPrompt();
|
|
263
|
+
getCoreSystemPrompt(mockConfig);
|
|
210
264
|
expect(fs.writeFileSync).toHaveBeenCalledWith(path.resolve(expectedPath), expect.any(String));
|
|
211
265
|
});
|
|
212
266
|
});
|