dotdo 0.0.2 → 0.1.0
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/cli/README.md +238 -0
- package/cli/agent.ts +72 -0
- package/cli/bin.js +44 -0
- package/cli/bin.ts +38 -0
- package/cli/build.ts +157 -0
- package/cli/commands/auth/login.ts +14 -0
- package/cli/commands/auth/logout.ts +6 -0
- package/cli/commands/auth/whoami.ts +16 -0
- package/cli/commands/deploy-multi.ts +245 -0
- package/cli/commands/dev/deploy.ts +100 -0
- package/cli/commands/dev/dev.ts +95 -0
- package/cli/commands/dev/logs.ts +91 -0
- package/cli/commands/dev-local.ts +88 -0
- package/cli/commands/do-ops.ts +314 -0
- package/cli/commands/index.ts +100 -0
- package/cli/commands/init.ts +247 -0
- package/cli/commands/introspect/emitter.ts +315 -0
- package/cli/commands/introspect/index.ts +193 -0
- package/cli/commands/link.ts +598 -0
- package/cli/commands/snippets.ts +415 -0
- package/cli/commands/tunnel.ts +239 -0
- package/cli/device-auth.ts +289 -0
- package/cli/fallback.ts +12 -0
- package/cli/index.ts +121 -0
- package/cli/main.ts +246 -0
- package/cli/mcp-stdio.ts +790 -0
- package/cli/package.json +62 -0
- package/cli/runtime/do-registry.ts +193 -0
- package/cli/runtime/embedded-db.ts +344 -0
- package/cli/runtime/index.ts +9 -0
- package/cli/runtime/miniflare-adapter.ts +162 -0
- package/cli/sandbox.ts +82 -0
- package/cli/src/args.ts +174 -0
- package/cli/src/auth.ts +55 -0
- package/cli/src/commands/call.ts +84 -0
- package/cli/src/commands/charge.ts +96 -0
- package/cli/src/commands/config.ts +115 -0
- package/cli/src/commands/email.ts +112 -0
- package/cli/src/commands/llm.ts +115 -0
- package/cli/src/commands/queue.ts +134 -0
- package/cli/src/commands/text.ts +86 -0
- package/cli/src/config.ts +185 -0
- package/cli/src/output.ts +246 -0
- package/cli/src/rpc.ts +192 -0
- package/cli/utils/config.ts +282 -0
- package/cli/utils/detect.ts +73 -0
- package/cli/utils/index.ts +15 -0
- package/cli/utils/logger.ts +232 -0
- package/dist/ai/template-literals.js +2 -2
- package/dist/ai/template-literals.js.map +1 -1
- package/dist/api/middleware/auth.js +3 -2
- package/dist/api/middleware/auth.js.map +1 -1
- package/dist/db/iceberg/inverted-index.js +1 -1
- package/dist/db/iceberg/inverted-index.js.map +1 -1
- package/dist/db/iceberg/puffin.js.map +1 -1
- package/dist/db/json-indexes.js.map +1 -1
- package/dist/db/objects.js.map +1 -1
- package/dist/db/primitives/dag-scheduler/index.js +1 -1
- package/dist/db/primitives/dag-scheduler/index.js.map +1 -1
- package/dist/db/primitives/observability.js.map +1 -1
- package/dist/db/primitives/schema-evolution.js.map +1 -1
- package/dist/db/primitives/temporal-store.js.map +1 -1
- package/dist/db/primitives/typed-column-store.js.map +1 -1
- package/dist/db/primitives/utils/duration.js.map +1 -1
- package/dist/db/primitives/utils/murmur3.js +12 -14
- package/dist/db/primitives/utils/murmur3.js.map +1 -1
- package/dist/db/primitives/window-manager.js.map +1 -1
- package/dist/db/stores.js.map +1 -1
- package/dist/db/things.js.map +1 -1
- package/dist/lib/DODispatcher.js +2 -2
- package/dist/lib/DODispatcher.js.map +1 -1
- package/dist/lib/auto-wiring.js.map +1 -1
- package/dist/lib/channels/email.js +1 -1
- package/dist/lib/channels/email.js.map +1 -1
- package/dist/lib/channels/slack-blockkit.js.map +1 -1
- package/dist/lib/cloudflare/ai.js +1 -1
- package/dist/lib/cloudflare/ai.js.map +1 -1
- package/dist/lib/cloudflare/kv.js +1 -1
- package/dist/lib/cloudflare/kv.js.map +1 -1
- package/dist/lib/cloudflare/r2.js +3 -3
- package/dist/lib/cloudflare/r2.js.map +1 -1
- package/dist/lib/cloudflare/vectorize.js.map +1 -1
- package/dist/lib/cloudflare/workflows.js.map +1 -1
- package/dist/lib/executors/AgenticFunctionExecutor.js.map +1 -1
- package/dist/lib/executors/CodeFunctionExecutor.js.map +1 -1
- package/dist/lib/executors/GenerativeFunctionExecutor.js.map +1 -1
- package/dist/lib/executors/HumanFunctionExecutor.js +1 -1
- package/dist/lib/executors/HumanFunctionExecutor.js.map +1 -1
- package/dist/lib/executors/ParallelStepExecutor.js.map +1 -1
- package/dist/lib/experiments.js.map +1 -1
- package/dist/lib/flags/store.js.map +1 -1
- package/dist/lib/functions/FunctionComposition.js.map +1 -1
- package/dist/lib/functions/FunctionMiddleware.js.map +1 -1
- package/dist/lib/functions/FunctionRegistry.js.map +1 -1
- package/dist/lib/humans/templates.js.map +1 -1
- package/dist/lib/identity.js +2 -2
- package/dist/lib/identity.js.map +1 -1
- package/dist/lib/logging/index.js.map +1 -1
- package/dist/lib/mixins/bash.js +1 -73
- package/dist/lib/mixins/bash.js.map +1 -1
- package/dist/lib/mixins/git.js +0 -5
- package/dist/lib/mixins/git.js.map +1 -1
- package/dist/lib/mixins/npm.js.map +1 -1
- package/dist/lib/noun-id.js.map +1 -1
- package/dist/lib/rate-limit/sliding-window.js.map +1 -1
- package/dist/lib/rpc/bindings.js.map +1 -1
- package/dist/lib/safe-stringify.js.map +1 -1
- package/dist/lib/sandbox/miniflare-sandbox.js.map +1 -1
- package/dist/lib/sqids.js.map +1 -1
- package/dist/lib/sql/adapters/node-sql-parser.js.map +1 -1
- package/dist/lib/sql/adapters/pgsql-parser.js +19 -18
- package/dist/lib/sql/adapters/pgsql-parser.js.map +1 -1
- package/dist/metrics/hunch.js.map +1 -1
- package/dist/objects/API.js +1 -1
- package/dist/objects/API.js.map +1 -1
- package/dist/objects/Agent.js.map +1 -1
- package/dist/objects/Browser.js.map +1 -1
- package/dist/objects/CLI.js.map +1 -1
- package/dist/objects/DOBase.js.map +1 -1
- package/dist/objects/DOCache.js +153 -0
- package/dist/objects/DOCache.js.map +1 -0
- package/dist/objects/DOFull.js.map +1 -1
- package/dist/objects/Entity.js.map +1 -1
- package/dist/objects/Human.js.map +1 -1
- package/dist/objects/IcebergMetadataDO.js.map +1 -1
- package/dist/objects/IntegrationsDO.js.map +1 -1
- package/dist/objects/ObservabilityBroadcaster.js.map +1 -1
- package/dist/objects/Package.js.map +1 -1
- package/dist/objects/Product.js +1 -1
- package/dist/objects/Product.js.map +1 -1
- package/dist/objects/SaaS.js.map +1 -1
- package/dist/objects/SandboxDO.js.map +1 -1
- package/dist/objects/Service.js.map +1 -1
- package/dist/objects/VectorShardDO.js +9 -7
- package/dist/objects/VectorShardDO.js.map +1 -1
- package/dist/objects/Workflow.js.map +1 -1
- package/dist/objects/WorkflowFactory.js.map +1 -1
- package/dist/objects/WorkflowRuntime.js.map +1 -1
- package/dist/objects/lifecycle/Branch.js.map +1 -1
- package/dist/objects/lifecycle/Clone.js +1 -1
- package/dist/objects/lifecycle/Clone.js.map +1 -1
- package/dist/objects/lifecycle/Compact.js.map +1 -1
- package/dist/objects/lifecycle/Shard.js.map +1 -1
- package/dist/objects/persistence/checkpoint-manager.js.map +1 -1
- package/dist/objects/persistence/migration-runner.js.map +1 -1
- package/dist/objects/persistence/replication-manager.js +2 -2
- package/dist/objects/persistence/replication-manager.js.map +1 -1
- package/dist/objects/persistence/tiered-storage-manager.js.map +1 -1
- package/dist/objects/persistence/wal-manager.js.map +1 -1
- package/dist/objects/transport/auth-layer.js.map +1 -1
- package/dist/objects/transport/chain.js.map +1 -1
- package/dist/objects/transport/mcp-server.js +7 -6
- package/dist/objects/transport/mcp-server.js.map +1 -1
- package/dist/objects/transport/rest-autowire.js +3 -2
- package/dist/objects/transport/rest-autowire.js.map +1 -1
- package/dist/objects/transport/rest-router.js.map +1 -1
- package/dist/objects/transport/rpc-server.js +18 -15
- package/dist/objects/transport/rpc-server.js.map +1 -1
- package/dist/objects/transport/shared.js +2 -1
- package/dist/objects/transport/shared.js.map +1 -1
- package/dist/snippets/artifacts-ingest.js.map +1 -1
- package/dist/snippets/artifacts-serve.js.map +1 -1
- package/dist/snippets/search.js.map +1 -1
- package/dist/workflows/ScheduleManager.js.map +1 -1
- package/dist/workflows/StepResultStorage.js.map +1 -1
- package/dist/workflows/WaitForEventManager.js.map +1 -1
- package/dist/workflows/compat/backends/cloudflare-workflows.js.map +1 -1
- package/dist/workflows/compat/inngest/index.js.map +1 -1
- package/dist/workflows/compat/qstash/index.js.map +1 -1
- package/dist/workflows/compat/temporal/client.js.map +1 -1
- package/dist/workflows/compat/temporal/index.js.map +1 -1
- package/dist/workflows/compat/trigger/index.js.map +1 -1
- package/dist/workflows/compat/utils/index.js.map +1 -1
- package/dist/workflows/context/correlation.js +2 -2
- package/dist/workflows/context/correlation.js.map +1 -1
- package/dist/workflows/context/experiment.js +1 -1
- package/dist/workflows/context/experiment.js.map +1 -1
- package/dist/workflows/context/flag.js +1 -1
- package/dist/workflows/context/flag.js.map +1 -1
- package/dist/workflows/context/measure.js +1 -1
- package/dist/workflows/context/measure.js.map +1 -1
- package/dist/workflows/context/rate-limit.js.map +1 -1
- package/dist/workflows/data/entity-events/entity-events.js.map +1 -1
- package/dist/workflows/data/experiment/index.js.map +1 -1
- package/dist/workflows/data/goal/context.js +1 -1
- package/dist/workflows/data/goal/context.js.map +1 -1
- package/dist/workflows/data/measure/index.js +1 -1
- package/dist/workflows/data/measure/index.js.map +1 -1
- package/dist/workflows/data/stream/index.js +10 -76
- package/dist/workflows/data/stream/index.js.map +1 -1
- package/dist/workflows/data/track/context.js.map +1 -1
- package/dist/workflows/data/view/context.js.map +1 -1
- package/dist/workflows/domain.js.map +1 -1
- package/dist/workflows/flags.js +1 -1
- package/dist/workflows/flags.js.map +1 -1
- package/dist/workflows/hash.js.map +1 -1
- package/dist/workflows/on.js +1 -1
- package/dist/workflows/on.js.map +1 -1
- package/dist/workflows/schedule-builder.js.map +1 -1
- package/dist/workflows/visibility/index.js +0 -2
- package/dist/workflows/visibility/index.js.map +1 -1
- package/dist/workflows/visibility/query-parser.js.map +1 -1
- package/package.json +18 -3
- package/dist/api/analytics/router.js +0 -601
- package/dist/api/analytics/router.js.map +0 -1
- package/dist/api/index.js +0 -158
- package/dist/api/index.js.map +0 -1
- package/dist/api/middleware/error-handling.js +0 -176
- package/dist/api/middleware/error-handling.js.map +0 -1
- package/dist/api/middleware/request-id.js +0 -21
- package/dist/api/middleware/request-id.js.map +0 -1
- package/dist/api/pages.js +0 -1180
- package/dist/api/pages.js.map +0 -1
- package/dist/api/routes/api.js +0 -612
- package/dist/api/routes/api.js.map +0 -1
- package/dist/api/routes/browsers.js +0 -471
- package/dist/api/routes/browsers.js.map +0 -1
- package/dist/api/routes/do.js +0 -188
- package/dist/api/routes/do.js.map +0 -1
- package/dist/api/routes/mcp.js +0 -459
- package/dist/api/routes/mcp.js.map +0 -1
- package/dist/api/routes/obs.js +0 -445
- package/dist/api/routes/obs.js.map +0 -1
- package/dist/api/routes/openapi.js +0 -794
- package/dist/api/routes/openapi.js.map +0 -1
- package/dist/api/routes/rpc.js +0 -1103
- package/dist/api/routes/rpc.js.map +0 -1
- package/dist/api/routes/sandboxes.js +0 -389
- package/dist/api/routes/sandboxes.js.map +0 -1
- package/dist/api/test-do.js +0 -38
- package/dist/api/test-do.js.map +0 -1
- package/dist/api/types.js +0 -11
- package/dist/api/types.js.map +0 -1
- package/dist/cli/bin.js +0 -2
- package/dist/cli/main.js +0 -52342
- package/dist/do/bash.js +0 -35
- package/dist/do/bash.js.map +0 -1
- package/dist/do/fs.js +0 -25
- package/dist/do/fs.js.map +0 -1
- package/dist/do/full.js +0 -61
- package/dist/do/full.js.map +0 -1
- package/dist/do/git.js +0 -28
- package/dist/do/git.js.map +0 -1
- package/dist/do/index.js +0 -52
- package/dist/do/index.js.map +0 -1
- package/dist/lib/agent/tools/bash.js +0 -336
- package/dist/lib/agent/tools/bash.js.map +0 -1
- package/dist/lib/agent/tools/edit.js +0 -157
- package/dist/lib/agent/tools/edit.js.map +0 -1
- package/dist/lib/agent/tools/glob.js +0 -137
- package/dist/lib/agent/tools/glob.js.map +0 -1
- package/dist/lib/agent/tools/grep.js +0 -315
- package/dist/lib/agent/tools/grep.js.map +0 -1
- package/dist/lib/agent/tools/index.js +0 -71
- package/dist/lib/agent/tools/index.js.map +0 -1
- package/dist/lib/agent/tools/read.js +0 -212
- package/dist/lib/agent/tools/read.js.map +0 -1
- package/dist/lib/agent/tools/types.js +0 -197
- package/dist/lib/agent/tools/types.js.map +0 -1
- package/dist/lib/agent/tools/write.js +0 -159
- package/dist/lib/agent/tools/write.js.map +0 -1
- package/dist/lib/mixins/index.js +0 -29
- package/dist/lib/mixins/index.js.map +0 -1
- package/dist/primitives/bashx/src/ast/analyze.js +0 -1472
- package/dist/primitives/bashx/src/ast/analyze.js.map +0 -1
- package/dist/primitives/bashx/src/ast/parser.js +0 -1488
- package/dist/primitives/bashx/src/ast/parser.js.map +0 -1
- package/dist/primitives/bashx/src/do/commands/crypto.js +0 -1954
- package/dist/primitives/bashx/src/do/commands/crypto.js.map +0 -1
- package/dist/primitives/bashx/src/do/commands/data-processing.js +0 -1812
- package/dist/primitives/bashx/src/do/commands/data-processing.js.map +0 -1
- package/dist/primitives/bashx/src/do/commands/extended-utils.js +0 -804
- package/dist/primitives/bashx/src/do/commands/extended-utils.js.map +0 -1
- package/dist/primitives/bashx/src/do/commands/math-control.js +0 -1122
- package/dist/primitives/bashx/src/do/commands/math-control.js.map +0 -1
- package/dist/primitives/bashx/src/do/commands/posix-utils.js +0 -1015
- package/dist/primitives/bashx/src/do/commands/posix-utils.js.map +0 -1
- package/dist/primitives/bashx/src/do/commands/system-utils.js +0 -687
- package/dist/primitives/bashx/src/do/commands/system-utils.js.map +0 -1
- package/dist/primitives/bashx/src/do/commands/test-command.js +0 -523
- package/dist/primitives/bashx/src/do/commands/test-command.js.map +0 -1
- package/dist/primitives/bashx/src/do/commands/text-processing.js +0 -1550
- package/dist/primitives/bashx/src/do/commands/text-processing.js.map +0 -1
- package/dist/primitives/bashx/src/do/container-executor.js +0 -429
- package/dist/primitives/bashx/src/do/container-executor.js.map +0 -1
- package/dist/primitives/bashx/src/do/index.js +0 -668
- package/dist/primitives/bashx/src/do/index.js.map +0 -1
- package/dist/primitives/bashx/src/do/tiered-executor.js +0 -2647
- package/dist/primitives/bashx/src/do/tiered-executor.js.map +0 -1
- package/dist/primitives/bashx/src/do/worker.js +0 -352
- package/dist/primitives/bashx/src/do/worker.js.map +0 -1
- package/dist/primitives/bashx/src/types.js +0 -10
- package/dist/primitives/bashx/src/types.js.map +0 -1
- package/dist/primitives/fsx/core/backend.js +0 -480
- package/dist/primitives/fsx/core/backend.js.map +0 -1
- package/dist/primitives/fsx/core/constants.js +0 -140
- package/dist/primitives/fsx/core/constants.js.map +0 -1
- package/dist/primitives/fsx/core/fsx.js +0 -1184
- package/dist/primitives/fsx/core/fsx.js.map +0 -1
- package/dist/primitives/fsx/core/glob/glob.js +0 -438
- package/dist/primitives/fsx/core/glob/glob.js.map +0 -1
- package/dist/primitives/fsx/core/glob/index.js +0 -8
- package/dist/primitives/fsx/core/glob/index.js.map +0 -1
- package/dist/primitives/fsx/core/glob/match.js +0 -392
- package/dist/primitives/fsx/core/glob/match.js.map +0 -1
- package/dist/primitives/fsx/core/types.js +0 -307
- package/dist/primitives/fsx/core/types.js.map +0 -1
- package/dist/sdk/capnweb-compat.js +0 -42
- package/dist/sdk/capnweb-compat.js.map +0 -1
- package/dist/sdk/client.js +0 -20
- package/dist/sdk/client.js.map +0 -1
- package/dist/sdk/index.js +0 -17
- package/dist/sdk/index.js.map +0 -1
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Edit Tool Adapter
|
|
3
|
-
*
|
|
4
|
-
* Maps Claude SDK Edit tool to fsx.do filesystem capabilities.
|
|
5
|
-
* Performs exact string replacements with uniqueness checks.
|
|
6
|
-
*
|
|
7
|
-
* @module lib/agent/tools/edit
|
|
8
|
-
*/
|
|
9
|
-
import { FileNotFoundError, IsDirectoryError, PathTraversalError, NotUniqueError, FileNotReadError, } from './types';
|
|
10
|
-
/**
|
|
11
|
-
* Validate and normalize a file path
|
|
12
|
-
*/
|
|
13
|
-
function validatePath(path) {
|
|
14
|
-
if (!path.startsWith('/')) {
|
|
15
|
-
throw new PathTraversalError(path);
|
|
16
|
-
}
|
|
17
|
-
const parts = path.split('/').filter(Boolean);
|
|
18
|
-
const resolved = [];
|
|
19
|
-
for (const part of parts) {
|
|
20
|
-
if (part === '.')
|
|
21
|
-
continue;
|
|
22
|
-
if (part === '..') {
|
|
23
|
-
if (resolved.length === 0) {
|
|
24
|
-
throw new PathTraversalError(path);
|
|
25
|
-
}
|
|
26
|
-
resolved.pop();
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
resolved.push(part);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return '/' + resolved.join('/');
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Count occurrences of a substring in a string
|
|
36
|
-
*/
|
|
37
|
-
function countOccurrences(text, search) {
|
|
38
|
-
if (search === '')
|
|
39
|
-
return 0;
|
|
40
|
-
let count = 0;
|
|
41
|
-
let pos = 0;
|
|
42
|
-
while ((pos = text.indexOf(search, pos)) !== -1) {
|
|
43
|
-
count++;
|
|
44
|
-
pos += search.length;
|
|
45
|
-
}
|
|
46
|
-
return count;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Replace first occurrence of a string
|
|
50
|
-
*/
|
|
51
|
-
function replaceFirst(text, search, replacement) {
|
|
52
|
-
const index = text.indexOf(search);
|
|
53
|
-
if (index === -1)
|
|
54
|
-
return text;
|
|
55
|
-
return text.slice(0, index) + replacement + text.slice(index + search.length);
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Edit Tool Adapter
|
|
59
|
-
*
|
|
60
|
-
* Performs exact string replacements in files.
|
|
61
|
-
* The old_string must be unique in the file unless replace_all is true.
|
|
62
|
-
*/
|
|
63
|
-
export class EditToolAdapter {
|
|
64
|
-
name = 'Edit';
|
|
65
|
-
description = `Performs exact string replacements in files.
|
|
66
|
-
|
|
67
|
-
Usage:
|
|
68
|
-
- You must use your Read tool at least once in the conversation before editing. This tool will error if you attempt an edit without reading the file.
|
|
69
|
-
- When editing text from Read tool output, ensure you preserve the exact indentation (tabs/spaces) as it appears AFTER the line number prefix.
|
|
70
|
-
- ALWAYS prefer editing existing files in the codebase. NEVER write new files unless explicitly required.
|
|
71
|
-
- Only use emojis if the user explicitly requests it. Avoid adding emojis to files unless asked.
|
|
72
|
-
- The edit will FAIL if old_string is not unique in the file. Either provide a larger string with more surrounding context to make it unique or use replace_all to change every instance of old_string.
|
|
73
|
-
- Use replace_all for replacing and renaming strings across the file. This parameter is useful if you want to rename a variable for instance.`;
|
|
74
|
-
inputSchema = {
|
|
75
|
-
type: 'object',
|
|
76
|
-
properties: {
|
|
77
|
-
file_path: {
|
|
78
|
-
type: 'string',
|
|
79
|
-
description: 'The absolute path to the file to modify',
|
|
80
|
-
},
|
|
81
|
-
old_string: {
|
|
82
|
-
type: 'string',
|
|
83
|
-
description: 'The text to replace',
|
|
84
|
-
},
|
|
85
|
-
new_string: {
|
|
86
|
-
type: 'string',
|
|
87
|
-
description: 'The text to replace it with (must be different from old_string)',
|
|
88
|
-
},
|
|
89
|
-
replace_all: {
|
|
90
|
-
type: 'boolean',
|
|
91
|
-
description: 'Replace all occurences of old_string (default false)',
|
|
92
|
-
default: false,
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
required: ['file_path', 'old_string', 'new_string'],
|
|
96
|
-
additionalProperties: false,
|
|
97
|
-
};
|
|
98
|
-
async execute(input, context) {
|
|
99
|
-
const { file_path, old_string, new_string, replace_all = false } = input;
|
|
100
|
-
const { fs, readFiles } = context;
|
|
101
|
-
// Validate path
|
|
102
|
-
const normalizedPath = validatePath(file_path);
|
|
103
|
-
// Check that the file was previously read
|
|
104
|
-
if (!readFiles.has(normalizedPath)) {
|
|
105
|
-
throw new FileNotReadError(normalizedPath);
|
|
106
|
-
}
|
|
107
|
-
// Check if file exists
|
|
108
|
-
const exists = await fs.exists(normalizedPath);
|
|
109
|
-
if (!exists) {
|
|
110
|
-
throw new FileNotFoundError(normalizedPath);
|
|
111
|
-
}
|
|
112
|
-
// Check if it's a directory
|
|
113
|
-
const stats = await fs.stat(normalizedPath);
|
|
114
|
-
if (stats.isDirectory()) {
|
|
115
|
-
throw new IsDirectoryError(normalizedPath);
|
|
116
|
-
}
|
|
117
|
-
// Read current content
|
|
118
|
-
const content = await fs.readFile(normalizedPath);
|
|
119
|
-
// Count occurrences
|
|
120
|
-
const occurrences = countOccurrences(content, old_string);
|
|
121
|
-
// If old_string not found, return failure
|
|
122
|
-
if (occurrences === 0) {
|
|
123
|
-
return {
|
|
124
|
-
success: false,
|
|
125
|
-
replacements_made: 0,
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
// If not replace_all and string is not unique, throw error
|
|
129
|
-
if (!replace_all && occurrences > 1) {
|
|
130
|
-
throw new NotUniqueError(old_string, occurrences);
|
|
131
|
-
}
|
|
132
|
-
// Perform the replacement
|
|
133
|
-
let newContent;
|
|
134
|
-
let replacementsMade;
|
|
135
|
-
if (replace_all) {
|
|
136
|
-
// Replace all occurrences
|
|
137
|
-
newContent = content.split(old_string).join(new_string);
|
|
138
|
-
replacementsMade = occurrences;
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
// Replace only first occurrence
|
|
142
|
-
newContent = replaceFirst(content, old_string, new_string);
|
|
143
|
-
replacementsMade = 1;
|
|
144
|
-
}
|
|
145
|
-
// Write back to file
|
|
146
|
-
await fs.writeFile(normalizedPath, newContent);
|
|
147
|
-
return {
|
|
148
|
-
success: true,
|
|
149
|
-
replacements_made: replacementsMade,
|
|
150
|
-
undo: {
|
|
151
|
-
old_string: new_string,
|
|
152
|
-
new_string: old_string,
|
|
153
|
-
},
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
//# sourceMappingURL=edit.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"edit.js","sourceRoot":"","sources":["../../../../lib/agent/tools/edit.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AASH,OAAO,EACL,iBAA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B,GAAG,WAAW,CAAA;QAChC,CAAC;aAAM,CAAC;YACN,gCAAgC;YAChC,UAAU,GAAG,YAAY,CAAC,OAAO,EAAE,UAAU,EAAE,UAAU,CAAC,CAAA;YAC1D,gBAAgB,GAAG,CAAC,CAAA;QACtB,CAAC;QAED,qBAAqB;QACrB,MAAM,EAAE,CAAC,SAAS,CAAC,cAAc,EAAE,UAAU,CAAC,CAAA;QAE9C,OAAO;YACL,OAAO,EAAE,IAAI;YACb,iBAAiB,EAAE,gBAAgB;YACnC,IAAI,EAAE;gBACJ,UAAU,EAAE,UAAU;gBACtB,UAAU,EAAE,UAAU;aACvB;SACF,CAAA;IACH,CAAC;CACF"}
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Glob Tool Adapter
|
|
3
|
-
*
|
|
4
|
-
* Maps Claude SDK Glob tool to fsx.do glob capabilities.
|
|
5
|
-
* Supports glob patterns like "**\/*.ts" with results sorted by mtime.
|
|
6
|
-
*
|
|
7
|
-
* @module lib/agent/tools/glob
|
|
8
|
-
*/
|
|
9
|
-
import { PathTraversalError, NotDirectoryError } from './types';
|
|
10
|
-
import { glob as fsxGlob } from '../../../primitives/fsx/core/glob';
|
|
11
|
-
/**
|
|
12
|
-
* Maximum number of results to return
|
|
13
|
-
*/
|
|
14
|
-
const MAX_RESULTS = 1000;
|
|
15
|
-
/**
|
|
16
|
-
* Validate and normalize a path
|
|
17
|
-
*/
|
|
18
|
-
function validatePath(path) {
|
|
19
|
-
if (!path.startsWith('/')) {
|
|
20
|
-
throw new PathTraversalError(path);
|
|
21
|
-
}
|
|
22
|
-
const parts = path.split('/').filter(Boolean);
|
|
23
|
-
const resolved = [];
|
|
24
|
-
for (const part of parts) {
|
|
25
|
-
if (part === '.')
|
|
26
|
-
continue;
|
|
27
|
-
if (part === '..') {
|
|
28
|
-
if (resolved.length === 0) {
|
|
29
|
-
throw new PathTraversalError(path);
|
|
30
|
-
}
|
|
31
|
-
resolved.pop();
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
resolved.push(part);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return '/' + resolved.join('/');
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Get file modification times for sorting
|
|
41
|
-
*/
|
|
42
|
-
async function getFileMtimes(fs, files) {
|
|
43
|
-
const mtimes = new Map();
|
|
44
|
-
// Process in batches to avoid overwhelming the filesystem
|
|
45
|
-
const BATCH_SIZE = 50;
|
|
46
|
-
for (let i = 0; i < files.length; i += BATCH_SIZE) {
|
|
47
|
-
const batch = files.slice(i, i + BATCH_SIZE);
|
|
48
|
-
const promises = batch.map(async (file) => {
|
|
49
|
-
try {
|
|
50
|
-
const stats = await fs.stat(file);
|
|
51
|
-
mtimes.set(file, stats.mtime?.getTime?.() ?? stats.mtimeMs ?? 0);
|
|
52
|
-
}
|
|
53
|
-
catch {
|
|
54
|
-
// If we can't stat, use 0 for mtime
|
|
55
|
-
mtimes.set(file, 0);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
await Promise.all(promises);
|
|
59
|
-
}
|
|
60
|
-
return mtimes;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Glob Tool Adapter
|
|
64
|
-
*
|
|
65
|
-
* Fast file pattern matching tool that works with any codebase size.
|
|
66
|
-
* Returns matching file paths sorted by modification time (most recent first).
|
|
67
|
-
*/
|
|
68
|
-
export class GlobToolAdapter {
|
|
69
|
-
name = 'Glob';
|
|
70
|
-
description = `Fast file pattern matching tool that works with any codebase size.
|
|
71
|
-
- Supports glob patterns like "**/*.js" or "src/**/*.ts"
|
|
72
|
-
- Returns matching file paths sorted by modification time
|
|
73
|
-
- Use this tool when you need to find files by name patterns`;
|
|
74
|
-
inputSchema = {
|
|
75
|
-
type: 'object',
|
|
76
|
-
properties: {
|
|
77
|
-
pattern: {
|
|
78
|
-
type: 'string',
|
|
79
|
-
description: 'The glob pattern to match files against',
|
|
80
|
-
},
|
|
81
|
-
path: {
|
|
82
|
-
type: 'string',
|
|
83
|
-
description: 'The directory to search in. If not specified, the current working directory will be used.',
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
required: ['pattern'],
|
|
87
|
-
additionalProperties: false,
|
|
88
|
-
};
|
|
89
|
-
async execute(input, context) {
|
|
90
|
-
const { pattern, path } = input;
|
|
91
|
-
const { fs, cwd } = context;
|
|
92
|
-
// Determine the base path
|
|
93
|
-
const basePath = path ? validatePath(path) : cwd;
|
|
94
|
-
// Check if base path exists and is a directory
|
|
95
|
-
const exists = await fs.exists(basePath);
|
|
96
|
-
if (!exists) {
|
|
97
|
-
// Return empty results for non-existent paths
|
|
98
|
-
return { files: [], truncated: false };
|
|
99
|
-
}
|
|
100
|
-
const stats = await fs.stat(basePath);
|
|
101
|
-
if (!stats.isDirectory()) {
|
|
102
|
-
throw new NotDirectoryError(basePath);
|
|
103
|
-
}
|
|
104
|
-
// Use fsx glob function with backend from context
|
|
105
|
-
// Get the backend from FSx instance - it's a private property but we need it
|
|
106
|
-
// For now, we'll use a workaround by implementing glob directly
|
|
107
|
-
const results = await fsxGlob(pattern, {
|
|
108
|
-
cwd: basePath,
|
|
109
|
-
absolute: true,
|
|
110
|
-
onlyFiles: true,
|
|
111
|
-
// Pass the backend from the FSx instance
|
|
112
|
-
// Note: FSx stores backend as private, so we access it through the glob function's backend option
|
|
113
|
-
// The FSx class internally uses this backend, but we can also pass it to glob
|
|
114
|
-
// For simplicity, we use the glob function which can work with mock FS or backend
|
|
115
|
-
});
|
|
116
|
-
// If no results, return early
|
|
117
|
-
if (results.length === 0) {
|
|
118
|
-
return { files: [], truncated: false };
|
|
119
|
-
}
|
|
120
|
-
// Get modification times for sorting
|
|
121
|
-
const mtimes = await getFileMtimes(fs, results);
|
|
122
|
-
// Sort by mtime (most recent first)
|
|
123
|
-
const sorted = [...results].sort((a, b) => {
|
|
124
|
-
const mtimeA = mtimes.get(a) ?? 0;
|
|
125
|
-
const mtimeB = mtimes.get(b) ?? 0;
|
|
126
|
-
return mtimeB - mtimeA; // Descending (newest first)
|
|
127
|
-
});
|
|
128
|
-
// Truncate if too many results
|
|
129
|
-
const truncated = sorted.length > MAX_RESULTS;
|
|
130
|
-
const files = truncated ? sorted.slice(0, MAX_RESULTS) : sorted;
|
|
131
|
-
return {
|
|
132
|
-
files,
|
|
133
|
-
truncated,
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
//# sourceMappingURL=glob.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"glob.js","sourceRoot":"","sources":["../../../../lib/agent/tools/glob.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AASH,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAC/D,OAAO,EAAE,IAAI,IAAI,OAAO,EAAE,MAAM,mCAAmC,CAAA;AAEnE;;GAEG;AACH,MAAM,WAAW,GAAG,IAAI,CAAA;AAExB;;GAEG;AACH,SAAS,YAAY,CAAC,IAAY;IAChC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,kBAAkB,CAAC,IAAI,CAAC,CAAA;IACpC,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IAC7C,MAAM,QAAQ,GAAa,EAAE,CAAA;IAE7B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,IAAI,KAAK,GAAG;YAAE,SAAQ;QAC1B,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;YAClB,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC1B,MAAM,IAAI,kBAAkB,CAAC,IAAI,CAAC,CAAA;YACpC,CAAC;YACD,QAAQ,CAAC,GAAG,EAAE,CAAA;QAChB,CAAC;aAAM,CAAC;Y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E,CAAC;YACzB,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,CAAA;QACxC,CAAC;QAED,qCAAqC;QACrC,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,EAAE,EAAE,OAAO,CAAC,CAAA;QAE/C,oCAAoC;QACpC,MAAM,MAAM,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;YACxC,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;YACjC,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;YACjC,OAAO,MAAM,GAAG,MAAM,CAAA,CAAC,4BAA4B;QACrD,CAAC,CAAC,CAAA;QAEF,+BAA+B;QAC/B,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,GAAG,WAAW,CAAA;QAC7C,MAAM,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;QAE/D,OAAO;YACL,KAAK;YACL,SAAS;SACV,CAAA;IACH,CAAC;CACF"}
|
|
@@ -1,315 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Grep Tool Adapter
|
|
3
|
-
*
|
|
4
|
-
* Maps Claude SDK Grep tool to fsx.do search capabilities.
|
|
5
|
-
* Supports regex patterns, context lines, and multiple output modes.
|
|
6
|
-
*
|
|
7
|
-
* @module lib/agent/tools/grep
|
|
8
|
-
*/
|
|
9
|
-
import { PathTraversalError, FILE_TYPE_GLOBS } from './types';
|
|
10
|
-
import { glob } from '../../../primitives/fsx/core/glob';
|
|
11
|
-
/**
|
|
12
|
-
* Maximum number of results to return
|
|
13
|
-
*/
|
|
14
|
-
const MAX_RESULTS = 1000;
|
|
15
|
-
/**
|
|
16
|
-
* Default output mode
|
|
17
|
-
*/
|
|
18
|
-
const DEFAULT_OUTPUT_MODE = 'files_with_matches';
|
|
19
|
-
/**
|
|
20
|
-
* Validate and normalize a path
|
|
21
|
-
*/
|
|
22
|
-
function validatePath(path) {
|
|
23
|
-
if (!path.startsWith('/')) {
|
|
24
|
-
throw new PathTraversalError(path);
|
|
25
|
-
}
|
|
26
|
-
const parts = path.split('/').filter(Boolean);
|
|
27
|
-
const resolved = [];
|
|
28
|
-
for (const part of parts) {
|
|
29
|
-
if (part === '.')
|
|
30
|
-
continue;
|
|
31
|
-
if (part === '..') {
|
|
32
|
-
if (resolved.length === 0) {
|
|
33
|
-
throw new PathTraversalError(path);
|
|
34
|
-
}
|
|
35
|
-
resolved.pop();
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
resolved.push(part);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return '/' + resolved.join('/');
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Create a regex from pattern with flags
|
|
45
|
-
*/
|
|
46
|
-
function createRegex(pattern, flags) {
|
|
47
|
-
let regexFlags = 'g'; // Always global
|
|
48
|
-
if (flags.ignoreCase)
|
|
49
|
-
regexFlags += 'i';
|
|
50
|
-
if (flags.multiline)
|
|
51
|
-
regexFlags += 's'; // dotall for multiline
|
|
52
|
-
return new RegExp(pattern, regexFlags);
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Get file extension globs for a type
|
|
56
|
-
*/
|
|
57
|
-
function getTypeGlobs(type) {
|
|
58
|
-
const normalized = type.toLowerCase();
|
|
59
|
-
return FILE_TYPE_GLOBS[normalized] || [`*.${type}`];
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Get surrounding context lines
|
|
63
|
-
*/
|
|
64
|
-
function getContextLines(lines, matchLineIndex, before, after) {
|
|
65
|
-
const beforeLines = [];
|
|
66
|
-
const afterLines = [];
|
|
67
|
-
// Get lines before
|
|
68
|
-
for (let i = Math.max(0, matchLineIndex - before); i < matchLineIndex; i++) {
|
|
69
|
-
beforeLines.push(lines[i]);
|
|
70
|
-
}
|
|
71
|
-
// Get lines after
|
|
72
|
-
for (let i = matchLineIndex + 1; i <= Math.min(lines.length - 1, matchLineIndex + after); i++) {
|
|
73
|
-
afterLines.push(lines[i]);
|
|
74
|
-
}
|
|
75
|
-
return { before: beforeLines, after: afterLines };
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Search a single file for pattern matches
|
|
79
|
-
*/
|
|
80
|
-
async function searchFile(fs, filePath, regex, options) {
|
|
81
|
-
const matches = [];
|
|
82
|
-
try {
|
|
83
|
-
const content = await fs.readFile(filePath);
|
|
84
|
-
const lines = content.split('\n');
|
|
85
|
-
if (options.outputMode === 'count') {
|
|
86
|
-
// Count total matches in file
|
|
87
|
-
let count = 0;
|
|
88
|
-
for (const line of lines) {
|
|
89
|
-
// Reset regex lastIndex for each line
|
|
90
|
-
regex.lastIndex = 0;
|
|
91
|
-
while (regex.exec(line)) {
|
|
92
|
-
count++;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
if (count > 0) {
|
|
96
|
-
matches.push({ file: filePath, count });
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
else if (options.outputMode === 'files_with_matches') {
|
|
100
|
-
// Just check if file has any match
|
|
101
|
-
for (const line of lines) {
|
|
102
|
-
regex.lastIndex = 0;
|
|
103
|
-
if (regex.test(line)) {
|
|
104
|
-
matches.push({ file: filePath });
|
|
105
|
-
break;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
// Output mode is 'content' - return matching lines with context
|
|
111
|
-
const seenLines = new Set(); // Track lines already added (for context overlap)
|
|
112
|
-
for (let lineIndex = 0; lineIndex < lines.length; lineIndex++) {
|
|
113
|
-
const line = lines[lineIndex];
|
|
114
|
-
regex.lastIndex = 0;
|
|
115
|
-
if (regex.test(line)) {
|
|
116
|
-
// Get context if not already added
|
|
117
|
-
if (!seenLines.has(lineIndex)) {
|
|
118
|
-
const context = getContextLines(lines, lineIndex, options.beforeContext, options.afterContext);
|
|
119
|
-
// Mark context lines as seen
|
|
120
|
-
for (let i = lineIndex - options.beforeContext; i <= lineIndex + options.afterContext; i++) {
|
|
121
|
-
seenLines.add(i);
|
|
122
|
-
}
|
|
123
|
-
// Build content with context
|
|
124
|
-
let contentStr = '';
|
|
125
|
-
if (context.before.length > 0 && options.beforeContext > 0) {
|
|
126
|
-
for (let i = 0; i < context.before.length; i++) {
|
|
127
|
-
const ctxLineNum = lineIndex - context.before.length + i + 1;
|
|
128
|
-
contentStr += options.showLineNumbers
|
|
129
|
-
? `${ctxLineNum}-${context.before[i]}\n`
|
|
130
|
-
: `${context.before[i]}\n`;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
contentStr += options.showLineNumbers
|
|
134
|
-
? `${lineIndex + 1}:${line}`
|
|
135
|
-
: line;
|
|
136
|
-
if (context.after.length > 0 && options.afterContext > 0) {
|
|
137
|
-
for (let i = 0; i < context.after.length; i++) {
|
|
138
|
-
const ctxLineNum = lineIndex + 2 + i;
|
|
139
|
-
contentStr += options.showLineNumbers
|
|
140
|
-
? `\n${ctxLineNum}-${context.after[i]}`
|
|
141
|
-
: `\n${context.after[i]}`;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
matches.push({
|
|
145
|
-
file: filePath,
|
|
146
|
-
line: options.showLineNumbers ? lineIndex + 1 : undefined,
|
|
147
|
-
content: contentStr,
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
catch {
|
|
155
|
-
// Skip files that can't be read (permission issues, binary files, etc.)
|
|
156
|
-
}
|
|
157
|
-
return matches;
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Grep Tool Adapter
|
|
161
|
-
*
|
|
162
|
-
* A powerful search tool built on ripgrep-style patterns.
|
|
163
|
-
* Supports regex, context lines, and multiple output modes.
|
|
164
|
-
*/
|
|
165
|
-
export class GrepToolAdapter {
|
|
166
|
-
name = 'Grep';
|
|
167
|
-
description = `A powerful search tool built on ripgrep.
|
|
168
|
-
|
|
169
|
-
Usage:
|
|
170
|
-
- Supports full regex syntax (e.g., "log.*Error", "function\\s+\\w+")
|
|
171
|
-
- Filter files with glob parameter (e.g., "*.js", "**/*.tsx") or type parameter (e.g., "js", "py", "rust")
|
|
172
|
-
- Output modes: "content" shows matching lines, "files_with_matches" shows only file paths (default), "count" shows match counts
|
|
173
|
-
- Use -A/-B/-C for context lines around matches`;
|
|
174
|
-
inputSchema = {
|
|
175
|
-
type: 'object',
|
|
176
|
-
properties: {
|
|
177
|
-
pattern: {
|
|
178
|
-
type: 'string',
|
|
179
|
-
description: 'The regular expression pattern to search for in file contents',
|
|
180
|
-
},
|
|
181
|
-
path: {
|
|
182
|
-
type: 'string',
|
|
183
|
-
description: 'File or directory to search in. Defaults to current working directory.',
|
|
184
|
-
},
|
|
185
|
-
glob: {
|
|
186
|
-
type: 'string',
|
|
187
|
-
description: 'Glob pattern to filter files (e.g., "*.js", "*.{ts,tsx}")',
|
|
188
|
-
},
|
|
189
|
-
type: {
|
|
190
|
-
type: 'string',
|
|
191
|
-
description: 'File type to search (e.g., "js", "py", "rust")',
|
|
192
|
-
},
|
|
193
|
-
output_mode: {
|
|
194
|
-
type: 'string',
|
|
195
|
-
enum: ['content', 'files_with_matches', 'count'],
|
|
196
|
-
description: 'Output mode. Defaults to "files_with_matches".',
|
|
197
|
-
},
|
|
198
|
-
'-i': {
|
|
199
|
-
type: 'boolean',
|
|
200
|
-
description: 'Case insensitive search',
|
|
201
|
-
},
|
|
202
|
-
'-n': {
|
|
203
|
-
type: 'boolean',
|
|
204
|
-
description: 'Show line numbers in output. Defaults to true.',
|
|
205
|
-
},
|
|
206
|
-
'-A': {
|
|
207
|
-
type: 'number',
|
|
208
|
-
description: 'Number of lines to show after each match',
|
|
209
|
-
},
|
|
210
|
-
'-B': {
|
|
211
|
-
type: 'number',
|
|
212
|
-
description: 'Number of lines to show before each match',
|
|
213
|
-
},
|
|
214
|
-
'-C': {
|
|
215
|
-
type: 'number',
|
|
216
|
-
description: 'Number of lines to show before and after each match',
|
|
217
|
-
},
|
|
218
|
-
multiline: {
|
|
219
|
-
type: 'boolean',
|
|
220
|
-
description: 'Enable multiline mode where patterns can span lines',
|
|
221
|
-
},
|
|
222
|
-
head_limit: {
|
|
223
|
-
type: 'number',
|
|
224
|
-
description: 'Limit output to first N entries',
|
|
225
|
-
},
|
|
226
|
-
offset: {
|
|
227
|
-
type: 'number',
|
|
228
|
-
description: 'Skip first N entries before applying head_limit',
|
|
229
|
-
},
|
|
230
|
-
},
|
|
231
|
-
required: ['pattern'],
|
|
232
|
-
additionalProperties: false,
|
|
233
|
-
};
|
|
234
|
-
async execute(input, context) {
|
|
235
|
-
const { pattern, path, glob: globPattern, type, output_mode = DEFAULT_OUTPUT_MODE, '-i': ignoreCase = false, '-n': showLineNumbers = true, '-A': afterContext = 0, '-B': beforeContext = 0, '-C': aroundContext = 0, multiline = false, head_limit = 0, offset = 0, } = input;
|
|
236
|
-
const { fs, cwd } = context;
|
|
237
|
-
// Determine search path
|
|
238
|
-
const searchPath = path ? validatePath(path) : cwd;
|
|
239
|
-
// Create regex
|
|
240
|
-
const regex = createRegex(pattern, { ignoreCase, multiline });
|
|
241
|
-
// Determine which files to search
|
|
242
|
-
let filesToSearch = [];
|
|
243
|
-
// Check if searchPath is a file or directory
|
|
244
|
-
const pathExists = await fs.exists(searchPath);
|
|
245
|
-
if (!pathExists) {
|
|
246
|
-
return { matches: [], truncated: false };
|
|
247
|
-
}
|
|
248
|
-
const stats = await fs.stat(searchPath);
|
|
249
|
-
if (stats.isDirectory()) {
|
|
250
|
-
// Build glob patterns
|
|
251
|
-
let patterns = ['**/*'];
|
|
252
|
-
if (globPattern) {
|
|
253
|
-
patterns = [globPattern];
|
|
254
|
-
}
|
|
255
|
-
else if (type) {
|
|
256
|
-
patterns = getTypeGlobs(type).map(p => `**/${p}`);
|
|
257
|
-
}
|
|
258
|
-
// Find files matching the pattern
|
|
259
|
-
for (const p of patterns) {
|
|
260
|
-
const matches = await glob(p, {
|
|
261
|
-
cwd: searchPath,
|
|
262
|
-
absolute: true,
|
|
263
|
-
onlyFiles: true,
|
|
264
|
-
ignore: ['**/node_modules/**', '**/.git/**', '**/dist/**', '**/build/**'],
|
|
265
|
-
});
|
|
266
|
-
filesToSearch.push(...matches);
|
|
267
|
-
}
|
|
268
|
-
// Remove duplicates
|
|
269
|
-
filesToSearch = [...new Set(filesToSearch)];
|
|
270
|
-
}
|
|
271
|
-
else {
|
|
272
|
-
// Search single file
|
|
273
|
-
filesToSearch = [searchPath];
|
|
274
|
-
}
|
|
275
|
-
// Calculate actual context (C overrides A and B)
|
|
276
|
-
const actualBeforeContext = aroundContext > 0 ? aroundContext : beforeContext;
|
|
277
|
-
const actualAfterContext = aroundContext > 0 ? aroundContext : afterContext;
|
|
278
|
-
// Search files
|
|
279
|
-
const allMatches = [];
|
|
280
|
-
for (const file of filesToSearch) {
|
|
281
|
-
const fileMatches = await searchFile(fs, file, regex, {
|
|
282
|
-
outputMode: output_mode,
|
|
283
|
-
showLineNumbers,
|
|
284
|
-
beforeContext: actualBeforeContext,
|
|
285
|
-
afterContext: actualAfterContext,
|
|
286
|
-
headLimit: head_limit,
|
|
287
|
-
offset,
|
|
288
|
-
});
|
|
289
|
-
allMatches.push(...fileMatches);
|
|
290
|
-
// Early termination if we have enough matches
|
|
291
|
-
if (head_limit > 0 && allMatches.length >= offset + head_limit + 100) {
|
|
292
|
-
break;
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
// Apply offset and limit
|
|
296
|
-
let results = allMatches;
|
|
297
|
-
if (offset > 0) {
|
|
298
|
-
results = results.slice(offset);
|
|
299
|
-
}
|
|
300
|
-
let truncated = false;
|
|
301
|
-
if (head_limit > 0 && results.length > head_limit) {
|
|
302
|
-
results = results.slice(0, head_limit);
|
|
303
|
-
truncated = true;
|
|
304
|
-
}
|
|
305
|
-
else if (results.length > MAX_RESULTS) {
|
|
306
|
-
results = results.slice(0, MAX_RESULTS);
|
|
307
|
-
truncated = true;
|
|
308
|
-
}
|
|
309
|
-
return {
|
|
310
|
-
matches: results,
|
|
311
|
-
truncated,
|
|
312
|
-
};
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
//# sourceMappingURL=grep.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"grep.js","sourceRoot":"","sources":["../../../../lib/agent/tools/grep.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAUH,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAC7D,OAAO,EAAE,IAAI,EAAE,MAAM,mCAAmC,CAAA;AAExD;;GAEG;AACH,MAAM,WAAW,GAAG,IAAI,CAAA;AAExB;;GAEG;AACH,MAAM,mBAAmB,GAAG,oBAAoB,CAAA;AAEhD;;GAEG;AACH,SAAS,YAAY,CAAC,IAAY;IAChC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,kBAAkB,CAAC,IAAI,CAAC,CAAA;IACpC,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IAC7C,MAAM,QAAQ,GAAa,EAAE,CAAA;IAE7B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,IAAI,KAAK,GAAG;YAAE,SAAQ;QAC1B,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;YAClB,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC1B,MAAM,IAAI,kBAAkB,CAAC,IAAI,CAAC,CAAA;YACpC,CAAC;YACD,QAAQ,CAAC,GAAG,EAAE,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