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/index.js
DELETED
|
@@ -1,110 +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 { bashTool, createBashTool } from "./bash.js";
|
|
6
|
-
import { createEditTool, editTool } from "./edit.js";
|
|
7
|
-
import { createFindTool, findTool } from "./find.js";
|
|
8
|
-
import { createGrepTool, grepTool } from "./grep.js";
|
|
9
|
-
import { createAstGrepTool, astGrepTool } from "./ast-grep.js";
|
|
10
|
-
import { createLsTool, lsTool } from "./ls.js";
|
|
11
|
-
import { createReadTool, readTool } from "./read.js";
|
|
12
|
-
import { createWriteTool, writeTool } from "./write.js";
|
|
13
|
-
import { createSkillScriptTool } from "./skill-tool.js";
|
|
14
|
-
import { createSkillReferenceTool } from "./skill-reference-tool.js";
|
|
15
|
-
import { askUserTool, createAskUserTool } from "./ask-user.js";
|
|
16
|
-
import { createTodoTool, todoTool } from "./todo.js";
|
|
17
|
-
import { createMCPTools } from "./mcp-tools.js";
|
|
18
|
-
/** Default tools for full access (read, bash, edit, write, ask_user, todo) - using process.cwd() */
|
|
19
|
-
export const codingTools = [
|
|
20
|
-
readTool,
|
|
21
|
-
bashTool,
|
|
22
|
-
editTool,
|
|
23
|
-
writeTool,
|
|
24
|
-
askUserTool,
|
|
25
|
-
todoTool,
|
|
26
|
-
findTool,
|
|
27
|
-
astGrepTool,
|
|
28
|
-
];
|
|
29
|
-
/** Read-only tools (read, grep, find, ls) - using process.cwd() */
|
|
30
|
-
export const readOnlyTools = [readTool, grepTool, astGrepTool, findTool, lsTool];
|
|
31
|
-
/** All tools by name - using process.cwd() */
|
|
32
|
-
export const allTools = {
|
|
33
|
-
read: readTool,
|
|
34
|
-
bash: bashTool,
|
|
35
|
-
edit: editTool,
|
|
36
|
-
write: writeTool,
|
|
37
|
-
grep: grepTool,
|
|
38
|
-
ast_grep: astGrepTool,
|
|
39
|
-
find: findTool,
|
|
40
|
-
ls: lsTool,
|
|
41
|
-
ask_user: askUserTool,
|
|
42
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* Create coding tools (read, bash, edit, write) configured for a specific working directory.
|
|
45
|
-
* Optionally includes skill tools if skills are provided.
|
|
46
|
-
* Optionally includes MCP tools if project path is provided.
|
|
47
|
-
*/
|
|
48
|
-
export async function createCodingTools(cwd, options) {
|
|
49
|
-
const baseTools = [
|
|
50
|
-
createReadTool(cwd, options?.read),
|
|
51
|
-
createBashTool(cwd, options?.bash),
|
|
52
|
-
createEditTool(cwd),
|
|
53
|
-
createWriteTool(cwd),
|
|
54
|
-
createAskUserTool(),
|
|
55
|
-
createTodoTool(options?.threadId ?? ""),
|
|
56
|
-
createFindTool(cwd),
|
|
57
|
-
createAstGrepTool(cwd),
|
|
58
|
-
];
|
|
59
|
-
// Add skill tools if skills are provided
|
|
60
|
-
const toolsWithSkills = [...baseTools];
|
|
61
|
-
if (options?.skills && options.skills.length > 0) {
|
|
62
|
-
const skillTools = [
|
|
63
|
-
createSkillScriptTool(options.skills, cwd),
|
|
64
|
-
createSkillReferenceTool(options.skills),
|
|
65
|
-
];
|
|
66
|
-
toolsWithSkills.push(...skillTools);
|
|
67
|
-
}
|
|
68
|
-
// Add MCP tools if we have a project path
|
|
69
|
-
try {
|
|
70
|
-
const mcpTools = await createMCPTools(cwd);
|
|
71
|
-
toolsWithSkills.push(...mcpTools);
|
|
72
|
-
}
|
|
73
|
-
catch (error) {
|
|
74
|
-
console.warn(`[Tools] Failed to load MCP tools for ${cwd}:`, error);
|
|
75
|
-
}
|
|
76
|
-
return toolsWithSkills;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Create read-only tools configured for a specific working directory.
|
|
80
|
-
*/
|
|
81
|
-
export function createReadOnlyTools(cwd, options) {
|
|
82
|
-
return [
|
|
83
|
-
createReadTool(cwd, options?.read),
|
|
84
|
-
createGrepTool(cwd),
|
|
85
|
-
createFindTool(cwd),
|
|
86
|
-
createAstGrepTool(cwd),
|
|
87
|
-
createLsTool(cwd),
|
|
88
|
-
];
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Create all tools configured for a specific working directory.
|
|
92
|
-
*/
|
|
93
|
-
export function createAllTools(cwd, options) {
|
|
94
|
-
return {
|
|
95
|
-
read: createReadTool(cwd, options?.read),
|
|
96
|
-
bash: createBashTool(cwd, options?.bash),
|
|
97
|
-
edit: createEditTool(cwd),
|
|
98
|
-
write: createWriteTool(cwd),
|
|
99
|
-
grep: createGrepTool(cwd),
|
|
100
|
-
ast_grep: createAstGrepTool(cwd),
|
|
101
|
-
find: createFindTool(cwd),
|
|
102
|
-
ask_user: createAskUserTool(),
|
|
103
|
-
ls: createLsTool(cwd),
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
// Re-export skill tool functions for direct use
|
|
107
|
-
export { createSkillScriptTool, listSkillScripts } from "./skill-tool.js";
|
|
108
|
-
export { createSkillReferenceTool, listSkillReferences } from "./skill-reference-tool.js";
|
|
109
|
-
export { createAskUserTool, submitAnswer, cancelPendingQuestion } from "./ask-user.js";
|
|
110
|
-
//# sourceMappingURL=index.js.map
|
package/dist/tools/ls.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 lsSchema: import("@sinclair/typebox").TObject<{
|
|
5
|
-
path: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
6
|
-
limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
7
|
-
}>;
|
|
8
|
-
export type LsToolInput = Static<typeof lsSchema>;
|
|
9
|
-
export interface LsToolDetails {
|
|
10
|
-
truncation?: TruncationResult;
|
|
11
|
-
entryLimitReached?: number;
|
|
12
|
-
}
|
|
13
|
-
export interface LsOperations {
|
|
14
|
-
exists: (absolutePath: string) => Promise<boolean> | boolean;
|
|
15
|
-
stat: (absolutePath: string) => Promise<{
|
|
16
|
-
isDirectory: () => boolean;
|
|
17
|
-
}> | {
|
|
18
|
-
isDirectory: () => boolean;
|
|
19
|
-
};
|
|
20
|
-
readdir: (absolutePath: string) => Promise<string[]> | string[];
|
|
21
|
-
}
|
|
22
|
-
export interface LsToolOptions {
|
|
23
|
-
operations?: LsOperations;
|
|
24
|
-
}
|
|
25
|
-
export declare function createLsTool(cwd: string, options?: LsToolOptions): AgentTool<typeof lsSchema>;
|
|
26
|
-
export declare const lsTool: AgentTool<import("@sinclair/typebox").TObject<{
|
|
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=ls.d.ts.map
|
package/dist/tools/ls.js
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { Type } from "@sinclair/typebox";
|
|
2
|
-
import { existsSync, readdirSync, statSync } from "fs";
|
|
3
|
-
import nodePath from "path";
|
|
4
|
-
import { resolveToCwd, validatePathWithinCwd } from "./path-utils.js";
|
|
5
|
-
import { DEFAULT_MAX_BYTES, formatSize, truncateHead } from "./truncate.js";
|
|
6
|
-
const lsSchema = Type.Object({
|
|
7
|
-
path: Type.Optional(Type.String({ description: "Directory to list (default: current directory)" })),
|
|
8
|
-
limit: Type.Optional(Type.Number({ description: "Maximum number of entries to return (default: 500)" })),
|
|
9
|
-
});
|
|
10
|
-
const DEFAULT_LIMIT = 500;
|
|
11
|
-
const defaultLsOperations = {
|
|
12
|
-
exists: existsSync,
|
|
13
|
-
stat: statSync,
|
|
14
|
-
readdir: readdirSync,
|
|
15
|
-
};
|
|
16
|
-
export function createLsTool(cwd, options) {
|
|
17
|
-
const ops = options?.operations ?? defaultLsOperations;
|
|
18
|
-
return {
|
|
19
|
-
name: "ls",
|
|
20
|
-
label: "ls",
|
|
21
|
-
description: `List directory contents. Returns entries sorted alphabetically, with '/' suffix for directories. Output truncated to ${DEFAULT_LIMIT} entries or ${DEFAULT_MAX_BYTES / 1024}KB.`,
|
|
22
|
-
parameters: lsSchema,
|
|
23
|
-
execute: async (_toolCallId, { path: dirPathArg, limit }, signal) => {
|
|
24
|
-
return new Promise((resolve, reject) => {
|
|
25
|
-
if (signal?.aborted) {
|
|
26
|
-
reject(new Error("Operation aborted"));
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
const onAbort = () => reject(new Error("Operation aborted"));
|
|
30
|
-
signal?.addEventListener("abort", onAbort, { once: true });
|
|
31
|
-
void (async () => {
|
|
32
|
-
try {
|
|
33
|
-
const dirPath = resolveToCwd(dirPathArg ?? ".", cwd);
|
|
34
|
-
validatePathWithinCwd(dirPath, cwd);
|
|
35
|
-
const effectiveLimit = limit ?? DEFAULT_LIMIT;
|
|
36
|
-
if (!(await ops.exists(dirPath))) {
|
|
37
|
-
reject(new Error(`Path not found: ${dirPath}`));
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
const stat = await ops.stat(dirPath);
|
|
41
|
-
if (!stat.isDirectory()) {
|
|
42
|
-
reject(new Error(`Not a directory: ${dirPath}`));
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
let entries;
|
|
46
|
-
try {
|
|
47
|
-
entries = await ops.readdir(dirPath);
|
|
48
|
-
}
|
|
49
|
-
catch (e) {
|
|
50
|
-
reject(new Error(`Cannot read directory: ${e instanceof Error ? e.message : String(e)}`));
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
entries.sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()));
|
|
54
|
-
const results = [];
|
|
55
|
-
let entryLimitReached = false;
|
|
56
|
-
for (const entry of entries) {
|
|
57
|
-
if (results.length >= effectiveLimit) {
|
|
58
|
-
entryLimitReached = true;
|
|
59
|
-
break;
|
|
60
|
-
}
|
|
61
|
-
const fullPath = nodePath.join(dirPath, entry);
|
|
62
|
-
try {
|
|
63
|
-
const entryStat = await ops.stat(fullPath);
|
|
64
|
-
results.push(entry + (entryStat.isDirectory() ? "/" : ""));
|
|
65
|
-
}
|
|
66
|
-
catch {
|
|
67
|
-
continue;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
signal?.removeEventListener("abort", onAbort);
|
|
71
|
-
if (results.length === 0) {
|
|
72
|
-
resolve({
|
|
73
|
-
content: [{ type: "text", text: "(empty directory)" }],
|
|
74
|
-
details: undefined,
|
|
75
|
-
});
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
const rawOutput = results.join("\n");
|
|
79
|
-
const truncation = truncateHead(rawOutput, { maxLines: Number.MAX_SAFE_INTEGER });
|
|
80
|
-
let output = truncation.content;
|
|
81
|
-
const details = {};
|
|
82
|
-
const notices = [];
|
|
83
|
-
if (entryLimitReached) {
|
|
84
|
-
notices.push(`${effectiveLimit} entries limit reached. Use limit=${effectiveLimit * 2} for more`);
|
|
85
|
-
details.entryLimitReached = effectiveLimit;
|
|
86
|
-
}
|
|
87
|
-
if (truncation.truncated) {
|
|
88
|
-
notices.push(`${formatSize(DEFAULT_MAX_BYTES)} limit reached`);
|
|
89
|
-
details.truncation = truncation;
|
|
90
|
-
}
|
|
91
|
-
if (notices.length > 0)
|
|
92
|
-
output += `\n\n[${notices.join(". ")}]`;
|
|
93
|
-
resolve({
|
|
94
|
-
content: [{ type: "text", text: output }],
|
|
95
|
-
details: Object.keys(details).length > 0 ? details : undefined,
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
catch (e) {
|
|
99
|
-
signal?.removeEventListener("abort", onAbort);
|
|
100
|
-
reject(e);
|
|
101
|
-
}
|
|
102
|
-
})();
|
|
103
|
-
});
|
|
104
|
-
},
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
export const lsTool = createLsTool(process.cwd());
|
|
108
|
-
//# sourceMappingURL=ls.js.map
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MCP Tools integration
|
|
3
|
-
*
|
|
4
|
-
* This file provides MCP tool integration for the Pi Agent,
|
|
5
|
-
* converting MCP tools into Pi Agent compatible tools.
|
|
6
|
-
*/
|
|
7
|
-
import type { AgentTool } from "@mariozechner/pi-agent-core";
|
|
8
|
-
/**
|
|
9
|
-
* Create MCP tools for a given project path
|
|
10
|
-
* @param projectPath - Path to the project directory
|
|
11
|
-
* @returns Promise resolving to array of MCP tools
|
|
12
|
-
*/
|
|
13
|
-
export declare function createMCPTools(projectPath: string): Promise<AgentTool<any>[]>;
|
|
14
|
-
/**
|
|
15
|
-
* Get MCP tool names for a project
|
|
16
|
-
* @param projectPath - Path to the project directory
|
|
17
|
-
* @returns Promise resolving to array of tool names
|
|
18
|
-
*/
|
|
19
|
-
export declare function getMCPToolNames(projectPath: string): Promise<string[]>;
|
|
20
|
-
/**
|
|
21
|
-
* Check if MCP tools are available for a project
|
|
22
|
-
* @param projectPath - Path to the project directory
|
|
23
|
-
* @returns Promise resolving to true if MCP tools are available
|
|
24
|
-
*/
|
|
25
|
-
export declare function hasMCPTools(projectPath: string): Promise<boolean>;
|
|
26
|
-
/**
|
|
27
|
-
* Clear MCP tool cache for a project
|
|
28
|
-
* @param projectPath - Path to the project directory
|
|
29
|
-
*/
|
|
30
|
-
export declare function clearMCPToolCache(projectPath: string): void;
|
|
31
|
-
//# sourceMappingURL=mcp-tools.d.ts.map
|
package/dist/tools/mcp-tools.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MCP Tools integration
|
|
3
|
-
*
|
|
4
|
-
* This file provides MCP tool integration for the Pi Agent,
|
|
5
|
-
* converting MCP tools into Pi Agent compatible tools.
|
|
6
|
-
*/
|
|
7
|
-
import { MCPManagerImpl } from "../features/mcp/mcp.manager.js";
|
|
8
|
-
/**
|
|
9
|
-
* Create MCP tools for a given project path
|
|
10
|
-
* @param projectPath - Path to the project directory
|
|
11
|
-
* @returns Promise resolving to array of MCP tools
|
|
12
|
-
*/
|
|
13
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
-
export async function createMCPTools(projectPath) {
|
|
15
|
-
const mcpManager = new MCPManagerImpl();
|
|
16
|
-
try {
|
|
17
|
-
const mcpTools = await mcpManager.createToolWrappers(projectPath);
|
|
18
|
-
console.log(`[MCP Tools] Created ${mcpTools.length} MCP tools for project: ${projectPath}`);
|
|
19
|
-
return mcpTools;
|
|
20
|
-
}
|
|
21
|
-
catch (error) {
|
|
22
|
-
console.error(`[MCP Tools] Failed to create MCP tools for project ${projectPath}:`, error);
|
|
23
|
-
return [];
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Get MCP tool names for a project
|
|
28
|
-
* @param projectPath - Path to the project directory
|
|
29
|
-
* @returns Promise resolving to array of tool names
|
|
30
|
-
*/
|
|
31
|
-
export async function getMCPToolNames(projectPath) {
|
|
32
|
-
const mcpManager = new MCPManagerImpl();
|
|
33
|
-
try {
|
|
34
|
-
const mcpTools = await mcpManager.getTools(projectPath);
|
|
35
|
-
return mcpTools.map((tool) => tool.name);
|
|
36
|
-
}
|
|
37
|
-
catch (error) {
|
|
38
|
-
console.error(`[MCP Tools] Failed to get MCP tool names for project ${projectPath}:`, error);
|
|
39
|
-
return [];
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Check if MCP tools are available for a project
|
|
44
|
-
* @param projectPath - Path to the project directory
|
|
45
|
-
* @returns Promise resolving to true if MCP tools are available
|
|
46
|
-
*/
|
|
47
|
-
export async function hasMCPTools(projectPath) {
|
|
48
|
-
const toolNames = await getMCPToolNames(projectPath);
|
|
49
|
-
return toolNames.length > 0;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Clear MCP tool cache for a project
|
|
53
|
-
* @param projectPath - Path to the project directory
|
|
54
|
-
*/
|
|
55
|
-
export function clearMCPToolCache(projectPath) {
|
|
56
|
-
const mcpManager = new MCPManagerImpl();
|
|
57
|
-
mcpManager.clearCache(projectPath);
|
|
58
|
-
}
|
|
59
|
-
//# sourceMappingURL=mcp-tools.js.map
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export declare function expandPath(filePath: string): string;
|
|
2
|
-
/**
|
|
3
|
-
* Resolve a path relative to the given cwd.
|
|
4
|
-
* Handles ~ expansion and absolute paths.
|
|
5
|
-
*/
|
|
6
|
-
export declare function resolveToCwd(filePath: string, cwd: string): string;
|
|
7
|
-
/**
|
|
8
|
-
* Validates that a resolved path is within the allowed cwd directory.
|
|
9
|
-
* Prevents directory traversal attacks and access to files outside the project.
|
|
10
|
-
* @throws Error if the path is outside the cwd
|
|
11
|
-
*/
|
|
12
|
-
export declare function validatePathWithinCwd(resolvedPath: string, cwd: string): void;
|
|
13
|
-
export declare function resolveReadPath(filePath: string, cwd: string): string;
|
|
14
|
-
//# sourceMappingURL=path-utils.d.ts.map
|
package/dist/tools/path-utils.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { accessSync, constants } from "node:fs";
|
|
2
|
-
import * as os from "node:os";
|
|
3
|
-
import { isAbsolute, resolve as resolvePath, relative } from "node:path";
|
|
4
|
-
const UNICODE_SPACES = /[\u00A0\u2000-\u200A\u202F\u205F\u3000]/g;
|
|
5
|
-
const NARROW_NO_BREAK_SPACE = "\u202F";
|
|
6
|
-
function normalizeUnicodeSpaces(str) {
|
|
7
|
-
return str.replace(UNICODE_SPACES, " ");
|
|
8
|
-
}
|
|
9
|
-
function tryMacOSScreenshotPath(filePath) {
|
|
10
|
-
return filePath.replace(/ (AM|PM)\./g, `${NARROW_NO_BREAK_SPACE}$1.`);
|
|
11
|
-
}
|
|
12
|
-
function tryNFDVariant(filePath) {
|
|
13
|
-
return filePath.normalize("NFD");
|
|
14
|
-
}
|
|
15
|
-
function tryCurlyQuoteVariant(filePath) {
|
|
16
|
-
return filePath.replace(/'/g, "\u2019");
|
|
17
|
-
}
|
|
18
|
-
function fileExists(filePath) {
|
|
19
|
-
try {
|
|
20
|
-
accessSync(filePath, constants.F_OK);
|
|
21
|
-
return true;
|
|
22
|
-
}
|
|
23
|
-
catch {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
function normalizeAtPrefix(filePath) {
|
|
28
|
-
return filePath.startsWith("@") ? filePath.slice(1) : filePath;
|
|
29
|
-
}
|
|
30
|
-
export function expandPath(filePath) {
|
|
31
|
-
const normalized = normalizeUnicodeSpaces(normalizeAtPrefix(filePath));
|
|
32
|
-
if (normalized === "~") {
|
|
33
|
-
return os.homedir();
|
|
34
|
-
}
|
|
35
|
-
if (normalized.startsWith("~/")) {
|
|
36
|
-
return os.homedir() + normalized.slice(1);
|
|
37
|
-
}
|
|
38
|
-
return normalized;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Resolve a path relative to the given cwd.
|
|
42
|
-
* Handles ~ expansion and absolute paths.
|
|
43
|
-
*/
|
|
44
|
-
export function resolveToCwd(filePath, cwd) {
|
|
45
|
-
const expanded = expandPath(filePath);
|
|
46
|
-
if (isAbsolute(expanded)) {
|
|
47
|
-
return expanded;
|
|
48
|
-
}
|
|
49
|
-
return resolvePath(cwd, expanded);
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Validates that a resolved path is within the allowed cwd directory.
|
|
53
|
-
* Prevents directory traversal attacks and access to files outside the project.
|
|
54
|
-
* @throws Error if the path is outside the cwd
|
|
55
|
-
*/
|
|
56
|
-
export function validatePathWithinCwd(resolvedPath, cwd) {
|
|
57
|
-
const relativePath = relative(cwd, resolvedPath);
|
|
58
|
-
// If relative path starts with "..", it's outside the cwd
|
|
59
|
-
if (relativePath.startsWith("..") || isAbsolute(relativePath)) {
|
|
60
|
-
throw new Error(`Access denied: Path is outside the allowed directory. ` +
|
|
61
|
-
`Requested: ${resolvedPath}, Allowed root: ${cwd}`);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
export function resolveReadPath(filePath, cwd) {
|
|
65
|
-
const resolved = resolveToCwd(filePath, cwd);
|
|
66
|
-
if (fileExists(resolved)) {
|
|
67
|
-
return resolved;
|
|
68
|
-
}
|
|
69
|
-
const amPmVariant = tryMacOSScreenshotPath(resolved);
|
|
70
|
-
if (amPmVariant !== resolved && fileExists(amPmVariant)) {
|
|
71
|
-
return amPmVariant;
|
|
72
|
-
}
|
|
73
|
-
const nfdVariant = tryNFDVariant(resolved);
|
|
74
|
-
if (nfdVariant !== resolved && fileExists(nfdVariant)) {
|
|
75
|
-
return nfdVariant;
|
|
76
|
-
}
|
|
77
|
-
const curlyVariant = tryCurlyQuoteVariant(resolved);
|
|
78
|
-
if (curlyVariant !== resolved && fileExists(curlyVariant)) {
|
|
79
|
-
return curlyVariant;
|
|
80
|
-
}
|
|
81
|
-
const nfdCurlyVariant = tryCurlyQuoteVariant(nfdVariant);
|
|
82
|
-
if (nfdCurlyVariant !== resolved && fileExists(nfdCurlyVariant)) {
|
|
83
|
-
return nfdCurlyVariant;
|
|
84
|
-
}
|
|
85
|
-
return resolved;
|
|
86
|
-
}
|
|
87
|
-
//# sourceMappingURL=path-utils.js.map
|
package/dist/tools/read.d.ts
DELETED
|
@@ -1,27 +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 readSchema: import("@sinclair/typebox").TObject<{
|
|
5
|
-
path: import("@sinclair/typebox").TString;
|
|
6
|
-
offset: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
7
|
-
limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
8
|
-
}>;
|
|
9
|
-
export type ReadToolInput = Static<typeof readSchema>;
|
|
10
|
-
export interface ReadToolDetails {
|
|
11
|
-
truncation?: TruncationResult;
|
|
12
|
-
}
|
|
13
|
-
export interface ReadOperations {
|
|
14
|
-
readFile: (absolutePath: string) => Promise<Buffer>;
|
|
15
|
-
access: (absolutePath: string) => Promise<void>;
|
|
16
|
-
}
|
|
17
|
-
export interface ReadToolOptions {
|
|
18
|
-
operations?: ReadOperations;
|
|
19
|
-
}
|
|
20
|
-
export declare function createReadTool(cwd: string, options?: ReadToolOptions): AgentTool<typeof readSchema>;
|
|
21
|
-
export declare const readTool: AgentTool<import("@sinclair/typebox").TObject<{
|
|
22
|
-
path: import("@sinclair/typebox").TString;
|
|
23
|
-
offset: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
24
|
-
limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
25
|
-
}>, any>;
|
|
26
|
-
export {};
|
|
27
|
-
//# sourceMappingURL=read.d.ts.map
|
package/dist/tools/read.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { Type } from "@sinclair/typebox";
|
|
2
|
-
import { constants } from "fs";
|
|
3
|
-
import { access as fsAccess, readFile as fsReadFile } from "fs/promises";
|
|
4
|
-
import { resolveReadPath, validatePathWithinCwd } from "./path-utils.js";
|
|
5
|
-
import { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize, truncateHead, } from "./truncate.js";
|
|
6
|
-
import { withAbortSignal } from "./tool-helpers.js";
|
|
7
|
-
const readSchema = Type.Object({
|
|
8
|
-
path: Type.String({ description: "Path to the file to read (relative or absolute)" }),
|
|
9
|
-
offset: Type.Optional(Type.Number({ description: "Line number to start reading from (1-indexed)" })),
|
|
10
|
-
limit: Type.Optional(Type.Number({ description: "Maximum number of lines to read" })),
|
|
11
|
-
});
|
|
12
|
-
const defaultReadOperations = {
|
|
13
|
-
readFile: (path) => fsReadFile(path),
|
|
14
|
-
access: (path) => fsAccess(path, constants.R_OK),
|
|
15
|
-
};
|
|
16
|
-
export function createReadTool(cwd, options) {
|
|
17
|
-
const ops = options?.operations ?? defaultReadOperations;
|
|
18
|
-
return {
|
|
19
|
-
name: "read",
|
|
20
|
-
label: "read",
|
|
21
|
-
description: `Read the contents of a text file. Output is truncated to ${DEFAULT_MAX_LINES} lines or ${DEFAULT_MAX_BYTES / 1024}KB (whichever is hit first). Use offset/limit for large files.`,
|
|
22
|
-
parameters: readSchema,
|
|
23
|
-
execute: async (_toolCallId, { path, offset, limit }, signal) => {
|
|
24
|
-
const absolutePath = resolveReadPath(path, cwd);
|
|
25
|
-
validatePathWithinCwd(absolutePath, cwd);
|
|
26
|
-
return withAbortSignal(signal, async (isAborted) => {
|
|
27
|
-
await ops.access(absolutePath);
|
|
28
|
-
if (isAborted())
|
|
29
|
-
return { content: [], details: undefined };
|
|
30
|
-
const buffer = await ops.readFile(absolutePath);
|
|
31
|
-
const textContent = buffer.toString("utf-8");
|
|
32
|
-
const allLines = textContent.split("\n");
|
|
33
|
-
const totalFileLines = allLines.length;
|
|
34
|
-
const startLine = offset ? Math.max(0, offset - 1) : 0;
|
|
35
|
-
const startLineDisplay = startLine + 1;
|
|
36
|
-
if (startLine >= allLines.length) {
|
|
37
|
-
throw new Error(`Offset ${offset} is beyond end of file (${allLines.length} lines total)`);
|
|
38
|
-
}
|
|
39
|
-
let selectedContent;
|
|
40
|
-
let userLimitedLines;
|
|
41
|
-
if (limit !== undefined) {
|
|
42
|
-
const endLine = Math.min(startLine + limit, allLines.length);
|
|
43
|
-
selectedContent = allLines.slice(startLine, endLine).join("\n");
|
|
44
|
-
userLimitedLines = endLine - startLine;
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
selectedContent = allLines.slice(startLine).join("\n");
|
|
48
|
-
}
|
|
49
|
-
const truncation = truncateHead(selectedContent);
|
|
50
|
-
let outputText;
|
|
51
|
-
let details;
|
|
52
|
-
if (truncation.firstLineExceedsLimit) {
|
|
53
|
-
outputText = `[Line ${startLineDisplay} is ${formatSize(Buffer.byteLength(allLines[startLine], "utf-8"))}, exceeds ${formatSize(DEFAULT_MAX_BYTES)} limit. Use bash: sed -n '${startLineDisplay}p' ${path} | head -c ${DEFAULT_MAX_BYTES}]`;
|
|
54
|
-
details = { truncation };
|
|
55
|
-
}
|
|
56
|
-
else if (truncation.truncated) {
|
|
57
|
-
const endLineDisplay = startLineDisplay + truncation.outputLines - 1;
|
|
58
|
-
const nextOffset = endLineDisplay + 1;
|
|
59
|
-
outputText = truncation.content;
|
|
60
|
-
if (truncation.truncatedBy === "lines") {
|
|
61
|
-
outputText += `\n\n[Showing lines ${startLineDisplay}-${endLineDisplay} of ${totalFileLines}. Use offset=${nextOffset} to continue.]`;
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
outputText += `\n\n[Showing lines ${startLineDisplay}-${endLineDisplay} of ${totalFileLines} (${formatSize(DEFAULT_MAX_BYTES)} limit). Use offset=${nextOffset} to continue.]`;
|
|
65
|
-
}
|
|
66
|
-
details = { truncation };
|
|
67
|
-
}
|
|
68
|
-
else if (userLimitedLines !== undefined &&
|
|
69
|
-
startLine + userLimitedLines < allLines.length) {
|
|
70
|
-
const remaining = allLines.length - (startLine + userLimitedLines);
|
|
71
|
-
const nextOffset = startLine + userLimitedLines + 1;
|
|
72
|
-
outputText = truncation.content;
|
|
73
|
-
outputText += `\n\n[${remaining} more lines in file. Use offset=${nextOffset} to continue.]`;
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
outputText = truncation.content;
|
|
77
|
-
}
|
|
78
|
-
if (isAborted())
|
|
79
|
-
return { content: [], details: undefined };
|
|
80
|
-
return { content: [{ type: "text", text: outputText }], details };
|
|
81
|
-
});
|
|
82
|
-
},
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
export const readTool = createReadTool(process.cwd());
|
|
86
|
-
//# sourceMappingURL=read.js.map
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { spawnSyncProcess } from "../core/utils.js";
|
|
2
|
-
/**
|
|
3
|
-
* Resolve path to an executable on PATH. Returns the command name if found, null otherwise.
|
|
4
|
-
*/
|
|
5
|
-
export function resolveBin(name) {
|
|
6
|
-
return new Promise((resolve) => {
|
|
7
|
-
const cmd = process.platform === "win32" ? "where" : "which";
|
|
8
|
-
const args = process.platform === "win32" ? [name + ".exe", name] : [name];
|
|
9
|
-
try {
|
|
10
|
-
const result = spawnSyncProcess(cmd, args, { encoding: "utf-8", timeout: 5000 });
|
|
11
|
-
if (result.status === 0 && result.stdout) {
|
|
12
|
-
const first = (typeof result.stdout === "string" ? result.stdout : result.stdout?.toString() || "")
|
|
13
|
-
.trim()
|
|
14
|
-
.split(/\r?\n/)[0]
|
|
15
|
-
?.trim();
|
|
16
|
-
if (first) {
|
|
17
|
-
resolve(first);
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
catch {
|
|
23
|
-
// ignore
|
|
24
|
-
}
|
|
25
|
-
resolve(null);
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=resolve-bin.js.map
|
package/dist/tools/shell.d.ts
DELETED