tarsk 0.4.4 → 0.4.6
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.js +447375 -37
- package/package.json +2 -2
- package/dist/agent/agent.error-utils.d.ts +0 -14
- package/dist/agent/agent.error-utils.js +0 -52
- package/dist/agent/agent.event-transformer.d.ts +0 -55
- package/dist/agent/agent.event-transformer.js +0 -175
- package/dist/agent/agent.executor.d.ts +0 -26
- package/dist/agent/agent.executor.js +0 -286
- package/dist/agent/agent.model-resolver.d.ts +0 -22
- package/dist/agent/agent.model-resolver.js +0 -67
- package/dist/agent/agent.process-manager.d.ts +0 -57
- package/dist/agent/agent.process-manager.js +0 -262
- package/dist/agent/agent.processing-state-manager.d.ts +0 -74
- package/dist/agent/agent.processing-state-manager.js +0 -87
- package/dist/agent/agent.prompt-loader.d.ts +0 -16
- package/dist/agent/agent.prompt-loader.js +0 -227
- package/dist/agent/agent.subagent-executor.d.ts +0 -35
- package/dist/agent/agent.subagent-executor.js +0 -135
- package/dist/bun/index.d.ts +0 -2
- package/dist/bun/index.js +0 -165
- package/dist/cli.d.ts +0 -3
- package/dist/cli.js +0 -22
- package/dist/core/crypto.d.ts +0 -29
- package/dist/core/crypto.js +0 -166
- package/dist/core/dev-server-cache.d.ts +0 -46
- package/dist/core/dev-server-cache.js +0 -59
- package/dist/core/env-manager.d.ts +0 -3
- package/dist/core/env-manager.js +0 -60
- package/dist/core/error-responses.d.ts +0 -61
- package/dist/core/error-responses.js +0 -64
- package/dist/core/logger.d.ts +0 -10
- package/dist/core/logger.js +0 -47
- package/dist/core/paths.d.ts +0 -22
- package/dist/core/paths.js +0 -26
- package/dist/core/random-words.d.ts +0 -18
- package/dist/core/random-words.js +0 -135
- package/dist/core/response-builder.d.ts +0 -50
- package/dist/core/response-builder.js +0 -56
- package/dist/core/route-helpers.d.ts +0 -47
- package/dist/core/route-helpers.js +0 -54
- package/dist/core/run-command-detector.d.ts +0 -26
- package/dist/core/run-command-detector.js +0 -98
- package/dist/core/stream-helper.d.ts +0 -44
- package/dist/core/stream-helper.js +0 -50
- package/dist/core/utils.d.ts +0 -43
- package/dist/core/utils.js +0 -113
- package/dist/core/validation.d.ts +0 -10
- package/dist/core/validation.js +0 -20
- package/dist/database/database.d.ts +0 -40
- package/dist/database/database.encryption.d.ts +0 -33
- package/dist/database/database.encryption.js +0 -62
- package/dist/database/database.js +0 -480
- package/dist/database/database.state.d.ts +0 -52
- package/dist/database/database.state.js +0 -119
- package/dist/database/database.test-utils.d.ts +0 -22
- package/dist/database/database.test-utils.js +0 -39
- package/dist/database/database.types.d.ts +0 -3
- package/dist/database/database.types.js +0 -2
- package/dist/features/agents/agents.manager.d.ts +0 -24
- package/dist/features/agents/agents.manager.js +0 -200
- package/dist/features/ask-user/ask-user.routes.d.ts +0 -9
- package/dist/features/ask-user/ask-user.routes.js +0 -35
- package/dist/features/chat/chat-delete.route.d.ts +0 -15
- package/dist/features/chat/chat-delete.route.js +0 -36
- package/dist/features/chat/chat-post.route.d.ts +0 -11
- package/dist/features/chat/chat-post.route.js +0 -270
- package/dist/features/chat/chat-stop.route.d.ts +0 -21
- package/dist/features/chat/chat-stop.route.js +0 -22
- package/dist/features/chat/chat-subscribe.route.d.ts +0 -9
- package/dist/features/chat/chat-subscribe.route.js +0 -71
- package/dist/features/chat/chat.routes.d.ts +0 -22
- package/dist/features/chat/chat.routes.js +0 -29
- package/dist/features/conversations/conversations-delete.route.d.ts +0 -16
- package/dist/features/conversations/conversations-delete.route.js +0 -34
- package/dist/features/conversations/conversations-get-all.route.d.ts +0 -16
- package/dist/features/conversations/conversations-get-all.route.js +0 -39
- package/dist/features/conversations/conversations-get-by-id.route.d.ts +0 -16
- package/dist/features/conversations/conversations-get-by-id.route.js +0 -38
- package/dist/features/conversations/conversations-get-deleted.route.d.ts +0 -15
- package/dist/features/conversations/conversations-get-deleted.route.js +0 -34
- package/dist/features/conversations/conversations-get-messages.route.d.ts +0 -16
- package/dist/features/conversations/conversations-get-messages.route.js +0 -49
- package/dist/features/conversations/conversations.content.d.ts +0 -28
- package/dist/features/conversations/conversations.content.js +0 -142
- package/dist/features/conversations/conversations.database.d.ts +0 -108
- package/dist/features/conversations/conversations.database.js +0 -373
- package/dist/features/conversations/conversations.manager.d.ts +0 -130
- package/dist/features/conversations/conversations.manager.js +0 -162
- package/dist/features/conversations/conversations.routes.d.ts +0 -21
- package/dist/features/conversations/conversations.routes.js +0 -38
- package/dist/features/conversations/token-usage.route.d.ts +0 -41
- package/dist/features/conversations/token-usage.route.js +0 -419
- package/dist/features/git/git-commit.route.d.ts +0 -12
- package/dist/features/git/git-commit.route.js +0 -39
- package/dist/features/git/git-create-branch.route.d.ts +0 -28
- package/dist/features/git/git-create-branch.route.js +0 -119
- package/dist/features/git/git-create-pr.route.d.ts +0 -13
- package/dist/features/git/git-create-pr.route.js +0 -50
- package/dist/features/git/git-create-repo.route.d.ts +0 -14
- package/dist/features/git/git-create-repo.route.js +0 -108
- package/dist/features/git/git-diff.route.d.ts +0 -30
- package/dist/features/git/git-diff.route.js +0 -189
- package/dist/features/git/git-fetch.route.d.ts +0 -12
- package/dist/features/git/git-fetch.route.js +0 -31
- package/dist/features/git/git-generate-commit-message.route.d.ts +0 -12
- package/dist/features/git/git-generate-commit-message.route.js +0 -76
- package/dist/features/git/git-generate-pr-info.route.d.ts +0 -13
- package/dist/features/git/git-generate-pr-info.route.js +0 -147
- package/dist/features/git/git-github-status.route.d.ts +0 -16
- package/dist/features/git/git-github-status.route.js +0 -68
- package/dist/features/git/git-log.route.d.ts +0 -17
- package/dist/features/git/git-log.route.js +0 -33
- package/dist/features/git/git-pr-status.route.d.ts +0 -15
- package/dist/features/git/git-pr-status.route.js +0 -33
- package/dist/features/git/git-pull.route.d.ts +0 -12
- package/dist/features/git/git-pull.route.js +0 -35
- package/dist/features/git/git-push.route.d.ts +0 -12
- package/dist/features/git/git-push.route.js +0 -46
- package/dist/features/git/git-status-cache.database.d.ts +0 -7
- package/dist/features/git/git-status-cache.database.js +0 -53
- package/dist/features/git/git-status.route.d.ts +0 -15
- package/dist/features/git/git-status.route.js +0 -62
- package/dist/features/git/git-sync-branch.route.d.ts +0 -4
- package/dist/features/git/git-sync-branch.route.js +0 -208
- package/dist/features/git/git-unified-status.route.d.ts +0 -30
- package/dist/features/git/git-unified-status.route.js +0 -165
- package/dist/features/git/git-username.route.d.ts +0 -3
- package/dist/features/git/git-username.route.js +0 -24
- package/dist/features/git/git.manager.d.ts +0 -139
- package/dist/features/git/git.manager.js +0 -352
- package/dist/features/git/git.routes.d.ts +0 -4
- package/dist/features/git/git.routes.js +0 -116
- package/dist/features/git/git.utils.d.ts +0 -82
- package/dist/features/git/git.utils.js +0 -1040
- package/dist/features/mcp/mcp.config.d.ts +0 -27
- package/dist/features/mcp/mcp.config.js +0 -148
- package/dist/features/mcp/mcp.manager.d.ts +0 -61
- package/dist/features/mcp/mcp.manager.js +0 -254
- package/dist/features/mcp/mcp.popular.json +0 -103
- package/dist/features/mcp/mcp.routes.d.ts +0 -13
- package/dist/features/mcp/mcp.routes.js +0 -159
- package/dist/features/mcp/mcp.types.d.ts +0 -80
- package/dist/features/mcp/mcp.types.js +0 -8
- package/dist/features/metadata/metadata.manager.d.ts +0 -126
- package/dist/features/metadata/metadata.manager.js +0 -423
- package/dist/features/models/model-info-aihubmix.d.ts +0 -25
- package/dist/features/models/model-info-aihubmix.js +0 -117
- package/dist/features/models/model-info-openrouter.d.ts +0 -25
- package/dist/features/models/model-info-openrouter.js +0 -104
- package/dist/features/models/model-info.d.ts +0 -37
- package/dist/features/models/model-info.js +0 -39
- package/dist/features/models/models-catalog.d.ts +0 -49
- package/dist/features/models/models-catalog.js +0 -80
- package/dist/features/models/models-catalog.route.d.ts +0 -43
- package/dist/features/models/models-catalog.route.js +0 -15
- package/dist/features/models/models-get-available.route.d.ts +0 -36
- package/dist/features/models/models-get-available.route.js +0 -66
- package/dist/features/models/models-get-enabled.route.d.ts +0 -33
- package/dist/features/models/models-get-enabled.route.js +0 -45
- package/dist/features/models/models-get-model-info.route.d.ts +0 -31
- package/dist/features/models/models-get-model-info.route.js +0 -84
- package/dist/features/models/models-model-disable.route.d.ts +0 -15
- package/dist/features/models/models-model-disable.route.js +0 -20
- package/dist/features/models/models-model-enable.route.d.ts +0 -13
- package/dist/features/models/models-model-enable.route.js +0 -20
- package/dist/features/models/models-provider-refresh.route.d.ts +0 -17
- package/dist/features/models/models-provider-refresh.route.js +0 -20
- package/dist/features/models/models.manager.d.ts +0 -58
- package/dist/features/models/models.manager.js +0 -138
- package/dist/features/models/models.routes.d.ts +0 -18
- package/dist/features/models/models.routes.js +0 -83
- package/dist/features/models/open-router-models.d.ts +0 -38
- package/dist/features/models/open-router-models.js +0 -73
- package/dist/features/models/openai-models.d.ts +0 -63
- package/dist/features/models/openai-models.js +0 -150
- package/dist/features/onboarding/onboarding-get-git-check.route.d.ts +0 -11
- package/dist/features/onboarding/onboarding-get-git-check.route.js +0 -28
- package/dist/features/onboarding/onboarding-get-status.route.d.ts +0 -12
- package/dist/features/onboarding/onboarding-get-status.route.js +0 -15
- package/dist/features/onboarding/onboarding-post-complete.route.d.ts +0 -12
- package/dist/features/onboarding/onboarding-post-complete.route.js +0 -15
- package/dist/features/onboarding/onboarding-post-reset.route.d.ts +0 -12
- package/dist/features/onboarding/onboarding-post-reset.route.js +0 -15
- package/dist/features/onboarding/onboarding.routes.d.ts +0 -18
- package/dist/features/onboarding/onboarding.routes.js +0 -28
- package/dist/features/project-todos/project-todos.database.d.ts +0 -38
- package/dist/features/project-todos/project-todos.database.js +0 -91
- package/dist/features/project-todos/project-todos.routes.d.ts +0 -4
- package/dist/features/project-todos/project-todos.routes.js +0 -94
- package/dist/features/projects/projects-ai-files.route.d.ts +0 -148
- package/dist/features/projects/projects-ai-files.route.js +0 -425
- package/dist/features/projects/projects-commands.route.d.ts +0 -27
- package/dist/features/projects/projects-commands.route.js +0 -39
- package/dist/features/projects/projects-create.route.d.ts +0 -19
- package/dist/features/projects/projects-create.route.js +0 -37
- package/dist/features/projects/projects-delete.route.d.ts +0 -24
- package/dist/features/projects/projects-delete.route.js +0 -34
- package/dist/features/projects/projects-get.route.d.ts +0 -47
- package/dist/features/projects/projects-get.route.js +0 -36
- package/dist/features/projects/projects-list.route.d.ts +0 -58
- package/dist/features/projects/projects-list.route.js +0 -59
- package/dist/features/projects/projects-open-folder.route.d.ts +0 -10
- package/dist/features/projects/projects-open-folder.route.js +0 -11
- package/dist/features/projects/projects-open.route.d.ts +0 -26
- package/dist/features/projects/projects-open.route.js +0 -49
- package/dist/features/projects/projects-package-scripts.route.d.ts +0 -15
- package/dist/features/projects/projects-package-scripts.route.js +0 -96
- package/dist/features/projects/projects-run-command.route.d.ts +0 -8
- package/dist/features/projects/projects-run-command.route.js +0 -21
- package/dist/features/projects/projects-run.route.d.ts +0 -51
- package/dist/features/projects/projects-run.route.js +0 -74
- package/dist/features/projects/projects-update.route.d.ts +0 -24
- package/dist/features/projects/projects-update.route.js +0 -81
- package/dist/features/projects/projects.creator.d.ts +0 -33
- package/dist/features/projects/projects.creator.js +0 -555
- package/dist/features/projects/projects.database.d.ts +0 -61
- package/dist/features/projects/projects.database.js +0 -212
- package/dist/features/projects/projects.manager.d.ts +0 -291
- package/dist/features/projects/projects.manager.js +0 -426
- package/dist/features/projects/projects.open-with.d.ts +0 -27
- package/dist/features/projects/projects.open-with.js +0 -156
- package/dist/features/projects/projects.routes.d.ts +0 -20
- package/dist/features/projects/projects.routes.js +0 -255
- package/dist/features/projects/terminal-session-manager.d.ts +0 -55
- package/dist/features/projects/terminal-session-manager.js +0 -90
- package/dist/features/providers/provider-resolver.d.ts +0 -13
- package/dist/features/providers/provider-resolver.js +0 -22
- package/dist/features/providers/providers-get-credits.route.d.ts +0 -15
- package/dist/features/providers/providers-get-credits.route.js +0 -51
- package/dist/features/providers/providers-get.route.d.ts +0 -16
- package/dist/features/providers/providers-get.route.js +0 -32
- package/dist/features/providers/providers-open-external.route.d.ts +0 -15
- package/dist/features/providers/providers-open-external.route.js +0 -49
- package/dist/features/providers/providers-post-bulk-keys.route.d.ts +0 -14
- package/dist/features/providers/providers-post-bulk-keys.route.js +0 -31
- package/dist/features/providers/providers-post-keys.route.d.ts +0 -14
- package/dist/features/providers/providers-post-keys.route.js +0 -25
- package/dist/features/providers/providers.routes.d.ts +0 -19
- package/dist/features/providers/providers.routes.js +0 -31
- package/dist/features/rules/rules-post.route.d.ts +0 -43
- package/dist/features/rules/rules-post.route.js +0 -89
- package/dist/features/rules/rules.manager.d.ts +0 -36
- package/dist/features/rules/rules.manager.js +0 -203
- package/dist/features/rules/rules.routes.d.ts +0 -12
- package/dist/features/rules/rules.routes.js +0 -13
- package/dist/features/run/run-get-running.route.d.ts +0 -15
- package/dist/features/run/run-get-running.route.js +0 -21
- package/dist/features/run/run-post-start.route.d.ts +0 -8
- package/dist/features/run/run-post-start.route.js +0 -21
- package/dist/features/run/run-post-stop.route.d.ts +0 -15
- package/dist/features/run/run-post-stop.route.js +0 -24
- package/dist/features/run/run-post-suggest.route.d.ts +0 -15
- package/dist/features/run/run-post-suggest.route.js +0 -21
- package/dist/features/run/run-put-command.route.d.ts +0 -15
- package/dist/features/run/run-put-command.route.js +0 -24
- package/dist/features/run/run.routes.d.ts +0 -19
- package/dist/features/run/run.routes.js +0 -31
- package/dist/features/scaffold/index.d.ts +0 -7
- package/dist/features/scaffold/index.js +0 -5
- package/dist/features/scaffold/scaffold-get-templates.route.d.ts +0 -27
- package/dist/features/scaffold/scaffold-get-templates.route.js +0 -17
- package/dist/features/scaffold/scaffold-post.route.d.ts +0 -8
- package/dist/features/scaffold/scaffold-post.route.js +0 -30
- package/dist/features/scaffold/scaffold.routes.d.ts +0 -10
- package/dist/features/scaffold/scaffold.routes.js +0 -16
- package/dist/features/scaffold/scaffold.runner.d.ts +0 -48
- package/dist/features/scaffold/scaffold.runner.js +0 -475
- package/dist/features/scaffold/scaffold.types.d.ts +0 -26
- package/dist/features/scaffold/scaffold.types.js +0 -5
- package/dist/features/skills/skills.activation.d.ts +0 -31
- package/dist/features/skills/skills.activation.js +0 -155
- package/dist/features/skills/skills.manager.d.ts +0 -35
- package/dist/features/skills/skills.manager.js +0 -251
- package/dist/features/slash-commands/slash-commands-delete.route.d.ts +0 -23
- package/dist/features/slash-commands/slash-commands-delete.route.js +0 -36
- package/dist/features/slash-commands/slash-commands-get.route.d.ts +0 -53
- package/dist/features/slash-commands/slash-commands-get.route.js +0 -54
- package/dist/features/slash-commands/slash-commands-post.route.d.ts +0 -39
- package/dist/features/slash-commands/slash-commands-post.route.js +0 -70
- package/dist/features/slash-commands/slash-commands-put.route.d.ts +0 -23
- package/dist/features/slash-commands/slash-commands-put.route.js +0 -36
- package/dist/features/slash-commands/slash-commands.manager.d.ts +0 -46
- package/dist/features/slash-commands/slash-commands.manager.js +0 -265
- package/dist/features/slash-commands/slash-commands.routes.d.ts +0 -13
- package/dist/features/slash-commands/slash-commands.routes.js +0 -20
- package/dist/features/threads/threads-ai-files.route.d.ts +0 -153
- package/dist/features/threads/threads-ai-files.route.js +0 -287
- package/dist/features/threads/threads-conversation-folder-path.route.d.ts +0 -14
- package/dist/features/threads/threads-conversation-folder-path.route.js +0 -23
- package/dist/features/threads/threads-create.route.d.ts +0 -22
- package/dist/features/threads/threads-create.route.js +0 -60
- package/dist/features/threads/threads-delete.route.d.ts +0 -25
- package/dist/features/threads/threads-delete.route.js +0 -35
- package/dist/features/threads/threads-files.route.d.ts +0 -15
- package/dist/features/threads/threads-files.route.js +0 -20
- package/dist/features/threads/threads-fix-comments.route.d.ts +0 -26
- package/dist/features/threads/threads-fix-comments.route.js +0 -45
- package/dist/features/threads/threads-get.route.d.ts +0 -30
- package/dist/features/threads/threads-get.route.js +0 -38
- package/dist/features/threads/threads-list.route.d.ts +0 -56
- package/dist/features/threads/threads-list.route.js +0 -58
- package/dist/features/threads/threads-messages.route.d.ts +0 -28
- package/dist/features/threads/threads-messages.route.js +0 -110
- package/dist/features/threads/threads-open.route.d.ts +0 -26
- package/dist/features/threads/threads-open.route.js +0 -62
- package/dist/features/threads/threads-select.route.d.ts +0 -25
- package/dist/features/threads/threads-select.route.js +0 -35
- package/dist/features/threads/threads-update.route.d.ts +0 -15
- package/dist/features/threads/threads-update.route.js +0 -30
- package/dist/features/threads/threads.database.d.ts +0 -68
- package/dist/features/threads/threads.database.js +0 -215
- package/dist/features/threads/threads.manager.d.ts +0 -204
- package/dist/features/threads/threads.manager.js +0 -505
- package/dist/features/threads/threads.routes.d.ts +0 -20
- package/dist/features/threads/threads.routes.js +0 -230
- package/dist/features/todos/todos.database.d.ts +0 -14
- package/dist/features/todos/todos.database.js +0 -31
- package/dist/features/updates/updates.routes.d.ts +0 -13
- package/dist/features/updates/updates.routes.js +0 -40
- package/dist/index.d.ts +0 -3
- package/dist/project-analyzer.d.ts +0 -26
- package/dist/project-analyzer.js +0 -307
- package/dist/server.d.ts +0 -12
- package/dist/server.js +0 -142
- package/dist/tools/agent-tool.d.ts +0 -49
- package/dist/tools/agent-tool.js +0 -131
- package/dist/tools/ask-user.d.ts +0 -25
- package/dist/tools/ask-user.js +0 -74
- package/dist/tools/ast-grep.d.ts +0 -28
- package/dist/tools/ast-grep.js +0 -273
- package/dist/tools/bash.d.ts +0 -33
- package/dist/tools/bash.js +0 -186
- package/dist/tools/edit-diff.d.ts +0 -24
- package/dist/tools/edit-diff.js +0 -136
- package/dist/tools/edit.d.ts +0 -28
- package/dist/tools/edit.js +0 -78
- package/dist/tools/find.d.ts +0 -31
- package/dist/tools/find.js +0 -117
- package/dist/tools/grep.d.ts +0 -37
- package/dist/tools/grep.js +0 -231
- package/dist/tools/index.d.ts +0 -93
- package/dist/tools/index.js +0 -110
- package/dist/tools/ls.d.ts +0 -31
- package/dist/tools/ls.js +0 -108
- package/dist/tools/mcp-tools.d.ts +0 -31
- package/dist/tools/mcp-tools.js +0 -59
- package/dist/tools/path-utils.d.ts +0 -14
- package/dist/tools/path-utils.js +0 -87
- package/dist/tools/read.d.ts +0 -27
- package/dist/tools/read.js +0 -86
- package/dist/tools/resolve-bin.d.ts +0 -5
- package/dist/tools/resolve-bin.js +0 -28
- package/dist/tools/shell.d.ts +0 -7
- package/dist/tools/shell.js +0 -143
- package/dist/tools/skill-reference-tool.d.ts +0 -30
- package/dist/tools/skill-reference-tool.js +0 -171
- package/dist/tools/skill-tool.d.ts +0 -33
- package/dist/tools/skill-tool.js +0 -213
- package/dist/tools/todo.d.ts +0 -20
- package/dist/tools/todo.js +0 -168
- package/dist/tools/tool-helpers.d.ts +0 -78
- package/dist/tools/tool-helpers.js +0 -109
- package/dist/tools/truncate.d.ts +0 -31
- package/dist/tools/truncate.js +0 -164
- package/dist/tools/write.d.ts +0 -21
- package/dist/tools/write.js +0 -65
package/dist/tools/edit.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { AgentTool } from "@mariozechner/pi-agent-core";
|
|
2
|
-
import { type Static } from "@sinclair/typebox";
|
|
3
|
-
declare const editSchema: import("@sinclair/typebox").TObject<{
|
|
4
|
-
path: import("@sinclair/typebox").TString;
|
|
5
|
-
oldText: import("@sinclair/typebox").TString;
|
|
6
|
-
newText: import("@sinclair/typebox").TString;
|
|
7
|
-
}>;
|
|
8
|
-
export type EditToolInput = Static<typeof editSchema>;
|
|
9
|
-
export interface EditToolDetails {
|
|
10
|
-
diff: string;
|
|
11
|
-
firstChangedLine?: number;
|
|
12
|
-
}
|
|
13
|
-
export interface EditOperations {
|
|
14
|
-
readFile: (absolutePath: string) => Promise<Buffer>;
|
|
15
|
-
writeFile: (absolutePath: string, content: string) => Promise<void>;
|
|
16
|
-
access: (absolutePath: string) => Promise<void>;
|
|
17
|
-
}
|
|
18
|
-
export interface EditToolOptions {
|
|
19
|
-
operations?: EditOperations;
|
|
20
|
-
}
|
|
21
|
-
export declare function createEditTool(cwd: string, options?: EditToolOptions): AgentTool<typeof editSchema>;
|
|
22
|
-
export declare const editTool: AgentTool<import("@sinclair/typebox").TObject<{
|
|
23
|
-
path: import("@sinclair/typebox").TString;
|
|
24
|
-
oldText: import("@sinclair/typebox").TString;
|
|
25
|
-
newText: import("@sinclair/typebox").TString;
|
|
26
|
-
}>, any>;
|
|
27
|
-
export {};
|
|
28
|
-
//# sourceMappingURL=edit.d.ts.map
|
package/dist/tools/edit.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { Type } from "@sinclair/typebox";
|
|
2
|
-
import { constants } from "fs";
|
|
3
|
-
import { access as fsAccess, readFile as fsReadFile, writeFile as fsWriteFile } from "fs/promises";
|
|
4
|
-
import { detectLineEnding, fuzzyFindText, generateDiffString, normalizeForFuzzyMatch, normalizeToLF, restoreLineEndings, stripBom, } from "./edit-diff.js";
|
|
5
|
-
import { resolveToCwd, validatePathWithinCwd } from "./path-utils.js";
|
|
6
|
-
import { withAbortSignal } from "./tool-helpers.js";
|
|
7
|
-
const editSchema = Type.Object({
|
|
8
|
-
path: Type.String({ description: "Path to the file to edit (relative or absolute)" }),
|
|
9
|
-
oldText: Type.String({ description: "Exact text to find and replace (must match exactly)" }),
|
|
10
|
-
newText: Type.String({ description: "New text to replace the old text with" }),
|
|
11
|
-
});
|
|
12
|
-
const defaultEditOperations = {
|
|
13
|
-
readFile: (path) => fsReadFile(path),
|
|
14
|
-
writeFile: (path, content) => fsWriteFile(path, content, "utf-8"),
|
|
15
|
-
access: (path) => fsAccess(path, constants.R_OK | constants.W_OK),
|
|
16
|
-
};
|
|
17
|
-
export function createEditTool(cwd, options) {
|
|
18
|
-
const ops = options?.operations ?? defaultEditOperations;
|
|
19
|
-
return {
|
|
20
|
-
name: "edit",
|
|
21
|
-
label: "edit",
|
|
22
|
-
description: "Edit a file by replacing exact text. The oldText must match exactly (including whitespace). Use this for precise, surgical edits.",
|
|
23
|
-
parameters: editSchema,
|
|
24
|
-
execute: async (_toolCallId, { path, oldText, newText }, signal) => {
|
|
25
|
-
const absolutePath = resolveToCwd(path, cwd);
|
|
26
|
-
validatePathWithinCwd(absolutePath, cwd);
|
|
27
|
-
return withAbortSignal(signal, async (isAborted) => {
|
|
28
|
-
try {
|
|
29
|
-
await ops.access(absolutePath);
|
|
30
|
-
}
|
|
31
|
-
catch {
|
|
32
|
-
throw new Error(`File not found: ${path}`);
|
|
33
|
-
}
|
|
34
|
-
if (isAborted())
|
|
35
|
-
return { content: [], details: undefined };
|
|
36
|
-
const buffer = await ops.readFile(absolutePath);
|
|
37
|
-
const rawContent = buffer.toString("utf-8");
|
|
38
|
-
if (isAborted())
|
|
39
|
-
return { content: [], details: undefined };
|
|
40
|
-
const { bom, text: content } = stripBom(rawContent);
|
|
41
|
-
const originalEnding = detectLineEnding(content);
|
|
42
|
-
const normalizedContent = normalizeToLF(content);
|
|
43
|
-
const normalizedOldText = normalizeToLF(oldText);
|
|
44
|
-
const normalizedNewText = normalizeToLF(newText);
|
|
45
|
-
const matchResult = fuzzyFindText(normalizedContent, normalizedOldText);
|
|
46
|
-
if (!matchResult.found) {
|
|
47
|
-
throw new Error(`Could not find the exact text in ${path}. The old text must match exactly including all whitespace and newlines.`);
|
|
48
|
-
}
|
|
49
|
-
const fuzzyContent = normalizeForFuzzyMatch(normalizedContent);
|
|
50
|
-
const fuzzyOldText = normalizeForFuzzyMatch(normalizedOldText);
|
|
51
|
-
const occurrences = fuzzyContent.split(fuzzyOldText).length - 1;
|
|
52
|
-
if (occurrences > 1) {
|
|
53
|
-
throw new Error(`Found ${occurrences} occurrences of the text in ${path}. The text must be unique. Please provide more context to make it unique.`);
|
|
54
|
-
}
|
|
55
|
-
if (isAborted())
|
|
56
|
-
return { content: [], details: undefined };
|
|
57
|
-
const baseContent = matchResult.contentForReplacement;
|
|
58
|
-
const newContent = baseContent.substring(0, matchResult.index) +
|
|
59
|
-
normalizedNewText +
|
|
60
|
-
baseContent.substring(matchResult.index + matchResult.matchLength);
|
|
61
|
-
if (baseContent === newContent) {
|
|
62
|
-
throw new Error(`No changes made to ${path}. The replacement produced identical content.`);
|
|
63
|
-
}
|
|
64
|
-
const finalContent = bom + restoreLineEndings(newContent, originalEnding);
|
|
65
|
-
await ops.writeFile(absolutePath, finalContent);
|
|
66
|
-
if (isAborted())
|
|
67
|
-
return { content: [], details: undefined };
|
|
68
|
-
const diffResult = generateDiffString(baseContent, newContent);
|
|
69
|
-
return {
|
|
70
|
-
content: [{ type: "text", text: `Successfully replaced text in ${path}.` }],
|
|
71
|
-
details: { diff: diffResult.diff, firstChangedLine: diffResult.firstChangedLine },
|
|
72
|
-
};
|
|
73
|
-
});
|
|
74
|
-
},
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
export const editTool = createEditTool(process.cwd());
|
|
78
|
-
//# sourceMappingURL=edit.js.map
|
package/dist/tools/find.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { AgentTool } from "@mariozechner/pi-agent-core";
|
|
2
|
-
import { type Static } from "@sinclair/typebox";
|
|
3
|
-
import { type TruncationResult } from "./truncate.js";
|
|
4
|
-
declare const findSchema: import("@sinclair/typebox").TObject<{
|
|
5
|
-
pattern: import("@sinclair/typebox").TString;
|
|
6
|
-
path: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
7
|
-
limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
8
|
-
}>;
|
|
9
|
-
export type FindToolInput = Static<typeof findSchema>;
|
|
10
|
-
export interface FindToolDetails {
|
|
11
|
-
truncation?: TruncationResult;
|
|
12
|
-
resultLimitReached?: number;
|
|
13
|
-
}
|
|
14
|
-
export interface FindOperations {
|
|
15
|
-
exists: (absolutePath: string) => Promise<boolean> | boolean;
|
|
16
|
-
glob: (pattern: string, cwd: string, options: {
|
|
17
|
-
ignore: string[];
|
|
18
|
-
limit: number;
|
|
19
|
-
}) => Promise<string[]> | string[];
|
|
20
|
-
}
|
|
21
|
-
export interface FindToolOptions {
|
|
22
|
-
operations?: FindOperations;
|
|
23
|
-
}
|
|
24
|
-
export declare function createFindTool(cwd: string, options?: FindToolOptions): AgentTool<typeof findSchema>;
|
|
25
|
-
export declare const findTool: AgentTool<import("@sinclair/typebox").TObject<{
|
|
26
|
-
pattern: import("@sinclair/typebox").TString;
|
|
27
|
-
path: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
28
|
-
limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
29
|
-
}>, any>;
|
|
30
|
-
export {};
|
|
31
|
-
//# sourceMappingURL=find.d.ts.map
|
package/dist/tools/find.js
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { Type } from "@sinclair/typebox";
|
|
2
|
-
import { existsSync } from "fs";
|
|
3
|
-
import os from "node:os";
|
|
4
|
-
import path from "path";
|
|
5
|
-
import { globSync } from "glob";
|
|
6
|
-
import { resolveToCwd, validatePathWithinCwd } from "./path-utils.js";
|
|
7
|
-
import { DEFAULT_MAX_BYTES, formatSize, truncateHead } from "./truncate.js";
|
|
8
|
-
const findSchema = Type.Object({
|
|
9
|
-
pattern: Type.String({
|
|
10
|
-
description: "Glob pattern to match files, e.g. '*.ts', '**/*.json', or 'src/**/*.spec.ts'",
|
|
11
|
-
}),
|
|
12
|
-
path: Type.Optional(Type.String({ description: "Directory to search in (default: current directory)" })),
|
|
13
|
-
limit: Type.Optional(Type.Number({ description: "Maximum number of results (default: 1000)" })),
|
|
14
|
-
});
|
|
15
|
-
const DEFAULT_LIMIT = 1000;
|
|
16
|
-
const defaultFindOperations = {
|
|
17
|
-
exists: existsSync,
|
|
18
|
-
glob: async (pattern, searchCwd, { ignore, limit }) => {
|
|
19
|
-
const results = [];
|
|
20
|
-
try {
|
|
21
|
-
const found = globSync(pattern, {
|
|
22
|
-
cwd: searchCwd,
|
|
23
|
-
dot: true,
|
|
24
|
-
ignore: ["**/node_modules/**", "**/.git/**", ...ignore],
|
|
25
|
-
mark: false,
|
|
26
|
-
});
|
|
27
|
-
for (let i = 0; i < Math.min(found.length, limit); i++) {
|
|
28
|
-
results.push(path.join(searchCwd, found[i]));
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
catch {
|
|
32
|
-
// return empty on error
|
|
33
|
-
}
|
|
34
|
-
return results;
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
export function createFindTool(cwd, options) {
|
|
38
|
-
const customOps = options?.operations;
|
|
39
|
-
return {
|
|
40
|
-
name: "find",
|
|
41
|
-
label: "find",
|
|
42
|
-
description: `Search for files by glob pattern. Returns matching file paths relative to the search directory. Output truncated to ${DEFAULT_LIMIT} results or ${DEFAULT_MAX_BYTES / 1024}KB.`,
|
|
43
|
-
parameters: findSchema,
|
|
44
|
-
execute: async (_toolCallId, { pattern, path: searchDir, limit }, signal) => {
|
|
45
|
-
return new Promise((resolve, reject) => {
|
|
46
|
-
if (signal?.aborted) {
|
|
47
|
-
reject(new Error("Operation aborted"));
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
const onAbort = () => reject(new Error("Operation aborted"));
|
|
51
|
-
signal?.addEventListener("abort", onAbort, { once: true });
|
|
52
|
-
void (async () => {
|
|
53
|
-
try {
|
|
54
|
-
const searchPath = resolveToCwd(searchDir ?? ".", cwd);
|
|
55
|
-
const normalizedSearchPath = path.resolve(searchPath);
|
|
56
|
-
const homeDir = path.resolve(os.homedir());
|
|
57
|
-
if (normalizedSearchPath === homeDir) {
|
|
58
|
-
reject(new Error("Access denied: Searching the home directory is not allowed. Use a subdirectory instead."));
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
validatePathWithinCwd(searchPath, cwd);
|
|
62
|
-
const effectiveLimit = limit ?? DEFAULT_LIMIT;
|
|
63
|
-
const ops = customOps ?? defaultFindOperations;
|
|
64
|
-
if (!(await ops.exists(searchPath))) {
|
|
65
|
-
reject(new Error(`Path not found: ${searchPath}`));
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
const results = await ops.glob(pattern, searchPath, {
|
|
69
|
-
ignore: ["**/node_modules/**", "**/.git/**"],
|
|
70
|
-
limit: effectiveLimit,
|
|
71
|
-
});
|
|
72
|
-
signal?.removeEventListener("abort", onAbort);
|
|
73
|
-
if (results.length === 0) {
|
|
74
|
-
resolve({
|
|
75
|
-
content: [{ type: "text", text: "No files found matching pattern" }],
|
|
76
|
-
details: undefined,
|
|
77
|
-
});
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
const relativized = results.map((p) => {
|
|
81
|
-
if (p.startsWith(searchPath + path.sep) || p.startsWith(searchPath + "/")) {
|
|
82
|
-
return p.slice(searchPath.length + 1).replace(/\\/g, "/");
|
|
83
|
-
}
|
|
84
|
-
return path.relative(searchPath, p).replace(/\\/g, "/");
|
|
85
|
-
});
|
|
86
|
-
const resultLimitReached = relativized.length >= effectiveLimit;
|
|
87
|
-
const rawOutput = relativized.join("\n");
|
|
88
|
-
const truncation = truncateHead(rawOutput, { maxLines: Number.MAX_SAFE_INTEGER });
|
|
89
|
-
let resultOutput = truncation.content;
|
|
90
|
-
const details = {};
|
|
91
|
-
const notices = [];
|
|
92
|
-
if (resultLimitReached) {
|
|
93
|
-
notices.push(`${effectiveLimit} results limit reached. Use limit=${effectiveLimit * 2} for more, or refine pattern`);
|
|
94
|
-
details.resultLimitReached = effectiveLimit;
|
|
95
|
-
}
|
|
96
|
-
if (truncation.truncated) {
|
|
97
|
-
notices.push(`${formatSize(DEFAULT_MAX_BYTES)} limit reached`);
|
|
98
|
-
details.truncation = truncation;
|
|
99
|
-
}
|
|
100
|
-
if (notices.length > 0)
|
|
101
|
-
resultOutput += `\n\n[${notices.join(". ")}]`;
|
|
102
|
-
resolve({
|
|
103
|
-
content: [{ type: "text", text: resultOutput }],
|
|
104
|
-
details: Object.keys(details).length > 0 ? details : undefined,
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
catch (e) {
|
|
108
|
-
signal?.removeEventListener("abort", onAbort);
|
|
109
|
-
reject(e);
|
|
110
|
-
}
|
|
111
|
-
})();
|
|
112
|
-
});
|
|
113
|
-
},
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
export const findTool = createFindTool(process.cwd());
|
|
117
|
-
//# sourceMappingURL=find.js.map
|
package/dist/tools/grep.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { AgentTool } from "@mariozechner/pi-agent-core";
|
|
2
|
-
import { type Static } from "@sinclair/typebox";
|
|
3
|
-
import { type TruncationResult } from "./truncate.js";
|
|
4
|
-
declare const grepSchema: import("@sinclair/typebox").TObject<{
|
|
5
|
-
pattern: import("@sinclair/typebox").TString;
|
|
6
|
-
path: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
7
|
-
glob: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
8
|
-
ignoreCase: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
9
|
-
literal: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
10
|
-
context: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
11
|
-
limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
12
|
-
}>;
|
|
13
|
-
export type GrepToolInput = Static<typeof grepSchema>;
|
|
14
|
-
export interface GrepToolDetails {
|
|
15
|
-
truncation?: TruncationResult;
|
|
16
|
-
matchLimitReached?: number;
|
|
17
|
-
linesTruncated?: boolean;
|
|
18
|
-
}
|
|
19
|
-
export interface GrepOperations {
|
|
20
|
-
isDirectory: (absolutePath: string) => Promise<boolean> | boolean;
|
|
21
|
-
readFile: (absolutePath: string) => Promise<string> | string;
|
|
22
|
-
}
|
|
23
|
-
export interface GrepToolOptions {
|
|
24
|
-
operations?: GrepOperations;
|
|
25
|
-
}
|
|
26
|
-
export declare function createGrepTool(cwd: string, options?: GrepToolOptions): AgentTool<typeof grepSchema>;
|
|
27
|
-
export declare const grepTool: AgentTool<import("@sinclair/typebox").TObject<{
|
|
28
|
-
pattern: import("@sinclair/typebox").TString;
|
|
29
|
-
path: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
30
|
-
glob: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
31
|
-
ignoreCase: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
32
|
-
literal: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
33
|
-
context: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
34
|
-
limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
35
|
-
}>, any>;
|
|
36
|
-
export {};
|
|
37
|
-
//# sourceMappingURL=grep.d.ts.map
|
package/dist/tools/grep.js
DELETED
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
import { createInterface } from "node:readline";
|
|
2
|
-
import { Type } from "@sinclair/typebox";
|
|
3
|
-
import { spawnProcess } from "../core/utils.js";
|
|
4
|
-
import { readFileSync, statSync } from "fs";
|
|
5
|
-
import path from "path";
|
|
6
|
-
import { resolveBin } from "./resolve-bin.js";
|
|
7
|
-
import { resolveToCwd, validatePathWithinCwd } from "./path-utils.js";
|
|
8
|
-
import { DEFAULT_MAX_BYTES, formatSize, GREP_MAX_LINE_LENGTH, truncateHead, truncateLine, } from "./truncate.js";
|
|
9
|
-
const grepSchema = Type.Object({
|
|
10
|
-
pattern: Type.String({ description: "Search pattern (regex or literal string)" }),
|
|
11
|
-
path: Type.Optional(Type.String({ description: "Directory or file to search (default: current directory)" })),
|
|
12
|
-
glob: Type.Optional(Type.String({ description: "Filter files by glob pattern, e.g. '*.ts'" })),
|
|
13
|
-
ignoreCase: Type.Optional(Type.Boolean({ description: "Case-insensitive search (default: false)" })),
|
|
14
|
-
literal: Type.Optional(Type.Boolean({
|
|
15
|
-
description: "Treat pattern as literal string instead of regex (default: false)",
|
|
16
|
-
})),
|
|
17
|
-
context: Type.Optional(Type.Number({ description: "Number of lines before/after each match (default: 0)" })),
|
|
18
|
-
limit: Type.Optional(Type.Number({ description: "Maximum number of matches to return (default: 100)" })),
|
|
19
|
-
});
|
|
20
|
-
const DEFAULT_LIMIT = 100;
|
|
21
|
-
const defaultGrepOperations = {
|
|
22
|
-
isDirectory: (p) => statSync(p).isDirectory(),
|
|
23
|
-
readFile: (p) => readFileSync(p, "utf-8"),
|
|
24
|
-
};
|
|
25
|
-
export function createGrepTool(cwd, options) {
|
|
26
|
-
const customOps = options?.operations;
|
|
27
|
-
return {
|
|
28
|
-
name: "grep",
|
|
29
|
-
label: "grep",
|
|
30
|
-
description: `Search file contents for a pattern. Returns matching lines with file paths and line numbers. Respects .gitignore. Output truncated to ${DEFAULT_LIMIT} matches or ${DEFAULT_MAX_BYTES / 1024}KB. Long lines truncated to ${GREP_MAX_LINE_LENGTH} chars.`,
|
|
31
|
-
parameters: grepSchema,
|
|
32
|
-
execute: async (_toolCallId, { pattern, path: searchDir, glob, ignoreCase, literal, context, limit }, signal) => {
|
|
33
|
-
return new Promise((resolve, reject) => {
|
|
34
|
-
if (signal?.aborted) {
|
|
35
|
-
reject(new Error("Operation aborted"));
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
let settled = false;
|
|
39
|
-
const settle = (fn) => {
|
|
40
|
-
if (!settled) {
|
|
41
|
-
settled = true;
|
|
42
|
-
fn();
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
void (async () => {
|
|
46
|
-
try {
|
|
47
|
-
const rgPath = await resolveBin("rg");
|
|
48
|
-
if (!rgPath) {
|
|
49
|
-
settle(() => reject(new Error("ripgrep (rg) is not available. Install rg or add it to PATH.")));
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
const searchPath = resolveToCwd(searchDir ?? ".", cwd);
|
|
53
|
-
validatePathWithinCwd(searchPath, cwd);
|
|
54
|
-
const ops = customOps ?? defaultGrepOperations;
|
|
55
|
-
let isDirectory;
|
|
56
|
-
try {
|
|
57
|
-
isDirectory = await ops.isDirectory(searchPath);
|
|
58
|
-
}
|
|
59
|
-
catch {
|
|
60
|
-
settle(() => reject(new Error(`Path not found: ${searchPath}`)));
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
const contextValue = context && context > 0 ? context : 0;
|
|
64
|
-
const effectiveLimit = Math.max(1, limit ?? DEFAULT_LIMIT);
|
|
65
|
-
const formatPath = (filePath) => {
|
|
66
|
-
if (isDirectory) {
|
|
67
|
-
const relative = path.relative(searchPath, filePath);
|
|
68
|
-
if (relative && !relative.startsWith("..")) {
|
|
69
|
-
return relative.replace(/\\/g, "/");
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return path.basename(filePath);
|
|
73
|
-
};
|
|
74
|
-
const fileCache = new Map();
|
|
75
|
-
const getFileLines = async (filePath) => {
|
|
76
|
-
let lines = fileCache.get(filePath);
|
|
77
|
-
if (!lines) {
|
|
78
|
-
try {
|
|
79
|
-
const content = await ops.readFile(filePath);
|
|
80
|
-
lines = content.replace(/\r\n/g, "\n").replace(/\r/g, "\n").split("\n");
|
|
81
|
-
}
|
|
82
|
-
catch {
|
|
83
|
-
lines = [];
|
|
84
|
-
}
|
|
85
|
-
fileCache.set(filePath, lines);
|
|
86
|
-
}
|
|
87
|
-
return lines;
|
|
88
|
-
};
|
|
89
|
-
const args = ["--json", "--line-number", "--color=never", "--hidden"];
|
|
90
|
-
if (ignoreCase)
|
|
91
|
-
args.push("--ignore-case");
|
|
92
|
-
if (literal)
|
|
93
|
-
args.push("--fixed-strings");
|
|
94
|
-
if (glob)
|
|
95
|
-
args.push("--glob", glob);
|
|
96
|
-
args.push(pattern, searchPath);
|
|
97
|
-
const child = spawnProcess(rgPath, args, { stdio: ["ignore", "pipe", "pipe"] });
|
|
98
|
-
const rl = createInterface({ input: child.stdout });
|
|
99
|
-
let stderr = "";
|
|
100
|
-
let matchCount = 0;
|
|
101
|
-
let matchLimitReached = false;
|
|
102
|
-
let linesTruncated = false;
|
|
103
|
-
let aborted = false;
|
|
104
|
-
let killedDueToLimit = false;
|
|
105
|
-
const outputLines = [];
|
|
106
|
-
const cleanup = () => {
|
|
107
|
-
rl.close();
|
|
108
|
-
signal?.removeEventListener("abort", onAbort);
|
|
109
|
-
};
|
|
110
|
-
const stopChild = (dueToLimit = false) => {
|
|
111
|
-
if (!child.killed) {
|
|
112
|
-
killedDueToLimit = dueToLimit;
|
|
113
|
-
child.kill();
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
const onAbort = () => {
|
|
117
|
-
aborted = true;
|
|
118
|
-
stopChild();
|
|
119
|
-
};
|
|
120
|
-
signal?.addEventListener("abort", onAbort, { once: true });
|
|
121
|
-
child.stderr?.on("data", (chunk) => {
|
|
122
|
-
stderr += chunk.toString();
|
|
123
|
-
});
|
|
124
|
-
const formatBlock = async (filePath, lineNumber) => {
|
|
125
|
-
const relativePath = formatPath(filePath);
|
|
126
|
-
const lines = await getFileLines(filePath);
|
|
127
|
-
if (!lines.length) {
|
|
128
|
-
return [`${relativePath}:${lineNumber}: (unable to read file)`];
|
|
129
|
-
}
|
|
130
|
-
const block = [];
|
|
131
|
-
const start = contextValue > 0 ? Math.max(1, lineNumber - contextValue) : lineNumber;
|
|
132
|
-
const end = contextValue > 0 ? Math.min(lines.length, lineNumber + contextValue) : lineNumber;
|
|
133
|
-
for (let current = start; current <= end; current++) {
|
|
134
|
-
const lineText = lines[current - 1] ?? "";
|
|
135
|
-
const sanitized = lineText.replace(/\r/g, "");
|
|
136
|
-
const { text: truncatedText, wasTruncated } = truncateLine(sanitized);
|
|
137
|
-
if (wasTruncated)
|
|
138
|
-
linesTruncated = true;
|
|
139
|
-
const isMatchLine = current === lineNumber;
|
|
140
|
-
if (isMatchLine) {
|
|
141
|
-
block.push(`${relativePath}:${current}: ${truncatedText}`);
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
block.push(`${relativePath}-${current}- ${truncatedText}`);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
return block;
|
|
148
|
-
};
|
|
149
|
-
const matches = [];
|
|
150
|
-
rl.on("line", (line) => {
|
|
151
|
-
if (!line.trim() || matchCount >= effectiveLimit)
|
|
152
|
-
return;
|
|
153
|
-
try {
|
|
154
|
-
const event = JSON.parse(line);
|
|
155
|
-
if (event.type === "match") {
|
|
156
|
-
matchCount++;
|
|
157
|
-
const filePath = event.data?.path?.text;
|
|
158
|
-
const lineNumber = event.data?.line_number;
|
|
159
|
-
if (filePath != null && typeof lineNumber === "number") {
|
|
160
|
-
matches.push({ filePath, lineNumber });
|
|
161
|
-
}
|
|
162
|
-
if (matchCount >= effectiveLimit) {
|
|
163
|
-
matchLimitReached = true;
|
|
164
|
-
stopChild(true);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
catch {
|
|
169
|
-
// ignore non-JSON lines
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
child.on("error", (error) => {
|
|
173
|
-
cleanup();
|
|
174
|
-
settle(() => reject(new Error(`Failed to run ripgrep: ${error.message}`)));
|
|
175
|
-
});
|
|
176
|
-
child.on("close", async (code) => {
|
|
177
|
-
cleanup();
|
|
178
|
-
if (aborted) {
|
|
179
|
-
settle(() => reject(new Error("Operation aborted")));
|
|
180
|
-
return;
|
|
181
|
-
}
|
|
182
|
-
if (!killedDueToLimit && code !== 0 && code !== 1) {
|
|
183
|
-
settle(() => reject(new Error(stderr.trim() || `ripgrep exited with code ${code}`)));
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
if (matchCount === 0) {
|
|
187
|
-
settle(() => resolve({
|
|
188
|
-
content: [{ type: "text", text: "No matches found" }],
|
|
189
|
-
details: undefined,
|
|
190
|
-
}));
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
for (const match of matches) {
|
|
194
|
-
const block = await formatBlock(match.filePath, match.lineNumber);
|
|
195
|
-
outputLines.push(...block);
|
|
196
|
-
}
|
|
197
|
-
const rawOutput = outputLines.join("\n");
|
|
198
|
-
const truncation = truncateHead(rawOutput, { maxLines: Number.MAX_SAFE_INTEGER });
|
|
199
|
-
let output = truncation.content;
|
|
200
|
-
const details = {};
|
|
201
|
-
const notices = [];
|
|
202
|
-
if (matchLimitReached) {
|
|
203
|
-
notices.push(`${effectiveLimit} matches limit reached. Use limit=${effectiveLimit * 2} for more, or refine pattern`);
|
|
204
|
-
details.matchLimitReached = effectiveLimit;
|
|
205
|
-
}
|
|
206
|
-
if (truncation.truncated) {
|
|
207
|
-
notices.push(`${formatSize(DEFAULT_MAX_BYTES)} limit reached`);
|
|
208
|
-
details.truncation = truncation;
|
|
209
|
-
}
|
|
210
|
-
if (linesTruncated) {
|
|
211
|
-
notices.push(`Some lines truncated to ${GREP_MAX_LINE_LENGTH} chars. Use read tool to see full lines`);
|
|
212
|
-
details.linesTruncated = true;
|
|
213
|
-
}
|
|
214
|
-
if (notices.length > 0)
|
|
215
|
-
output += `\n\n[${notices.join(". ")}]`;
|
|
216
|
-
settle(() => resolve({
|
|
217
|
-
content: [{ type: "text", text: output }],
|
|
218
|
-
details: Object.keys(details).length > 0 ? details : undefined,
|
|
219
|
-
}));
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
catch {
|
|
223
|
-
settle(() => reject(new Error("Error processing grep request")));
|
|
224
|
-
}
|
|
225
|
-
})();
|
|
226
|
-
});
|
|
227
|
-
},
|
|
228
|
-
};
|
|
229
|
-
}
|
|
230
|
-
export const grepTool = createGrepTool(process.cwd());
|
|
231
|
-
//# sourceMappingURL=grep.js.map
|
package/dist/tools/index.d.ts
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Coding tools for the Pi agent (read, bash, edit, write, grep, find, ls).
|
|
3
|
-
* Mirrors pi-mono-main/packages/coding-agent/src/core/tools.
|
|
4
|
-
*/
|
|
5
|
-
import type { AgentTool } from "@mariozechner/pi-agent-core";
|
|
6
|
-
import type { Skill } from "@tarsk/shared";
|
|
7
|
-
import { type BashToolOptions } from "./bash.js";
|
|
8
|
-
import { type ReadToolOptions } from "./read.js";
|
|
9
|
-
export type Tool = AgentTool<any>;
|
|
10
|
-
/** Default tools for full access (read, bash, edit, write, ask_user, todo) - using process.cwd() */
|
|
11
|
-
export declare const codingTools: Tool[];
|
|
12
|
-
/** Read-only tools (read, grep, find, ls) - using process.cwd() */
|
|
13
|
-
export declare const readOnlyTools: Tool[];
|
|
14
|
-
/** All tools by name - using process.cwd() */
|
|
15
|
-
export declare const allTools: {
|
|
16
|
-
read: AgentTool<import("@sinclair/typebox").TObject<{
|
|
17
|
-
path: import("@sinclair/typebox").TString;
|
|
18
|
-
offset: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
19
|
-
limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
20
|
-
}>, any>;
|
|
21
|
-
bash: AgentTool<import("@sinclair/typebox").TObject<{
|
|
22
|
-
command: import("@sinclair/typebox").TString;
|
|
23
|
-
timeout: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
24
|
-
}>, any>;
|
|
25
|
-
edit: AgentTool<import("@sinclair/typebox").TObject<{
|
|
26
|
-
path: import("@sinclair/typebox").TString;
|
|
27
|
-
oldText: import("@sinclair/typebox").TString;
|
|
28
|
-
newText: import("@sinclair/typebox").TString;
|
|
29
|
-
}>, any>;
|
|
30
|
-
write: AgentTool<import("@sinclair/typebox").TObject<{
|
|
31
|
-
path: import("@sinclair/typebox").TString;
|
|
32
|
-
content: import("@sinclair/typebox").TString;
|
|
33
|
-
}>, any>;
|
|
34
|
-
grep: AgentTool<import("@sinclair/typebox").TObject<{
|
|
35
|
-
pattern: import("@sinclair/typebox").TString;
|
|
36
|
-
path: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
37
|
-
glob: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
38
|
-
ignoreCase: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
39
|
-
literal: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
40
|
-
context: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
41
|
-
limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
42
|
-
}>, any>;
|
|
43
|
-
ast_grep: AgentTool<import("@sinclair/typebox").TObject<{
|
|
44
|
-
command: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"run">, import("@sinclair/typebox").TLiteral<"scan">]>;
|
|
45
|
-
pattern: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
46
|
-
lang: import("@sinclair/typebox").TString;
|
|
47
|
-
rule: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
48
|
-
path: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
49
|
-
limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
50
|
-
}>, any>;
|
|
51
|
-
find: AgentTool<import("@sinclair/typebox").TObject<{
|
|
52
|
-
pattern: import("@sinclair/typebox").TString;
|
|
53
|
-
path: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
54
|
-
limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
55
|
-
}>, any>;
|
|
56
|
-
ls: AgentTool<import("@sinclair/typebox").TObject<{
|
|
57
|
-
path: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
58
|
-
limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
59
|
-
}>, any>;
|
|
60
|
-
ask_user: AgentTool<import("@sinclair/typebox").TObject<{
|
|
61
|
-
question: import("@sinclair/typebox").TString;
|
|
62
|
-
options: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
|
|
63
|
-
context: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
64
|
-
}>, any>;
|
|
65
|
-
};
|
|
66
|
-
export type ToolName = keyof typeof allTools;
|
|
67
|
-
/**
|
|
68
|
-
* Tools options interface
|
|
69
|
-
*/
|
|
70
|
-
export interface ToolsOptions {
|
|
71
|
-
read?: ReadToolOptions;
|
|
72
|
-
bash?: BashToolOptions;
|
|
73
|
-
skills?: Skill[];
|
|
74
|
-
threadId?: string;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Create coding tools (read, bash, edit, write) configured for a specific working directory.
|
|
78
|
-
* Optionally includes skill tools if skills are provided.
|
|
79
|
-
* Optionally includes MCP tools if project path is provided.
|
|
80
|
-
*/
|
|
81
|
-
export declare function createCodingTools(cwd: string, options?: ToolsOptions): Promise<Tool[]>;
|
|
82
|
-
/**
|
|
83
|
-
* Create read-only tools configured for a specific working directory.
|
|
84
|
-
*/
|
|
85
|
-
export declare function createReadOnlyTools(cwd: string, options?: ToolsOptions): Tool[];
|
|
86
|
-
/**
|
|
87
|
-
* Create all tools configured for a specific working directory.
|
|
88
|
-
*/
|
|
89
|
-
export declare function createAllTools(cwd: string, options?: ToolsOptions): Record<ToolName, Tool>;
|
|
90
|
-
export { createSkillScriptTool, listSkillScripts } from "./skill-tool.js";
|
|
91
|
-
export { createSkillReferenceTool, listSkillReferences } from "./skill-reference-tool.js";
|
|
92
|
-
export { createAskUserTool, submitAnswer, cancelPendingQuestion } from "./ask-user.js";
|
|
93
|
-
//# sourceMappingURL=index.d.ts.map
|