@cursor/july 0.1.103 → 0.1.105
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/channels/change-monitors/change-monitors-channel.d.ts +5 -0
- package/dist/channels/change-monitors/change-monitors-channel.d.ts.map +1 -0
- package/dist/channels/change-monitors/change-monitors-channel.js +41 -0
- package/dist/channels/change-monitors/index.d.ts +4 -0
- package/dist/channels/change-monitors/index.d.ts.map +1 -0
- package/dist/channels/change-monitors/index.js +2 -0
- package/dist/channels/change-monitors/types.d.ts +39 -0
- package/dist/channels/change-monitors/types.d.ts.map +1 -0
- package/dist/channels/change-monitors/types.js +1 -0
- package/dist/channels/deployments/deployments-channel.d.ts.map +1 -1
- package/dist/channels/deployments/deployments-channel.js +1 -0
- package/dist/channels/deployments/types.d.ts +2 -0
- package/dist/channels/deployments/types.d.ts.map +1 -1
- package/dist/channels/github/defaults.d.ts.map +1 -1
- package/dist/channels/github/defaults.js +4 -0
- package/dist/channels/github/progress.d.ts +22 -0
- package/dist/channels/github/progress.d.ts.map +1 -1
- package/dist/channels/github/progress.js +32 -5
- package/dist/channels/issues/index.d.ts +4 -0
- package/dist/channels/issues/index.d.ts.map +1 -0
- package/dist/channels/issues/index.js +2 -0
- package/dist/channels/issues/issues-channel.d.ts +5 -0
- package/dist/channels/issues/issues-channel.d.ts.map +1 -0
- package/dist/channels/issues/issues-channel.js +37 -0
- package/dist/channels/issues/types.d.ts +33 -0
- package/dist/channels/issues/types.d.ts.map +1 -0
- package/dist/channels/issues/types.js +1 -0
- package/dist/docs/404.html +2 -2
- package/dist/docs/ab.html +4 -4
- package/dist/docs/assets/{app.DW9pXkpL.js → app.BVwaffdK.js} +1 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.CJxMklAy.js +1 -0
- package/dist/docs/assets/chunks/{VPLocalSearchBox.CdEIUwDg.js → VPLocalSearchBox.WuWTZ1x8.js} +1 -1
- package/dist/docs/assets/chunks/{theme.YZMHgPgg.js → theme.BYdI_6sF.js} +2 -2
- package/dist/docs/assets/{guides_github.md.DKYiT9do.js → guides_github.md.c0gdGJ-D.js} +1 -1
- package/dist/docs/assets/{guides_github.md.DKYiT9do.lean.js → guides_github.md.c0gdGJ-D.lean.js} +1 -1
- package/dist/docs/assets/guides_grokbot-agents.md.DVqdhBKb.js +9 -0
- package/dist/docs/assets/guides_grokbot-agents.md.DVqdhBKb.lean.js +1 -0
- package/dist/docs/assets/index.md.BW_6tOgR.js +5 -0
- package/dist/docs/assets/index.md.BW_6tOgR.lean.js +1 -0
- package/dist/docs/assets/{reference_channels.md.Dz8Cnudp.js → reference_channels.md.DBGcaB7m.js} +2 -2
- package/dist/docs/assets/{reference_channels.md.Dz8Cnudp.lean.js → reference_channels.md.DBGcaB7m.lean.js} +1 -1
- package/dist/docs/assets/{reference_cli.md.CJNc_xYK.js → reference_cli.md.C6Lo8SEd.js} +2 -1
- package/dist/docs/assets/{reference_extensions.md.DykHW3qL.js → reference_extensions.md.CGmMLblt.js} +1 -1
- package/dist/docs/assets/templates_grokbot-agents.md.c1s6Flp9.js +3 -0
- package/dist/docs/assets/templates_grokbot-agents.md.c1s6Flp9.lean.js +1 -0
- package/dist/docs/building-with-agents.html +4 -4
- package/dist/docs/concepts.html +4 -4
- package/dist/docs/deployment.html +4 -4
- package/dist/docs/design/filesystem.md +376 -0
- package/dist/docs/evals.html +4 -4
- package/dist/docs/guides/agent-to-agent.html +4 -4
- package/dist/docs/guides/cloud-agents.html +5 -5
- package/dist/docs/guides/convert-automation.html +4 -4
- package/dist/docs/guides/github.html +6 -6
- package/dist/docs/guides/github.md +5 -0
- package/dist/docs/guides/grokbot-agents.html +35 -0
- package/dist/docs/guides/grokbot-agents.md +88 -0
- package/dist/docs/guides/human-in-the-loop.html +4 -4
- package/dist/docs/guides/mcp-oauth.html +4 -4
- package/dist/docs/guides/opentelemetry.html +5 -5
- package/dist/docs/guides/slack.html +4 -4
- package/dist/docs/guides/webhooks.html +4 -4
- package/dist/docs/hashmap.json +1 -1
- package/dist/docs/hillclimbing.html +4 -4
- package/dist/docs/index.html +6 -6
- package/dist/docs/index.md +6 -1
- package/dist/docs/llms-full.txt +562 -2
- package/dist/docs/llms.txt +3 -0
- package/dist/docs/quickstart.html +4 -4
- package/dist/docs/reference/agent-config.html +4 -4
- package/dist/docs/reference/artifacts.html +4 -4
- package/dist/docs/reference/channels.html +6 -6
- package/dist/docs/reference/channels.md +20 -0
- package/dist/docs/reference/cli.html +7 -6
- package/dist/docs/reference/cli.md +2 -1
- package/dist/docs/reference/connections.html +4 -4
- package/dist/docs/reference/extensions.html +6 -6
- package/dist/docs/reference/extensions.md +2 -0
- package/dist/docs/reference/hooks.html +4 -4
- package/dist/docs/reference/http-api.html +4 -4
- package/dist/docs/reference/instructions.html +4 -4
- package/dist/docs/reference/playground.html +4 -4
- package/dist/docs/reference/project-layout.html +4 -4
- package/dist/docs/reference/prompt.html +4 -4
- package/dist/docs/reference/result.html +4 -4
- package/dist/docs/reference/schedules.html +4 -4
- package/dist/docs/reference/sessions.html +4 -4
- package/dist/docs/reference/skills.html +4 -4
- package/dist/docs/reference/subagents.html +4 -4
- package/dist/docs/reference/tools.html +4 -4
- package/dist/docs/scaffolding-agents.html +4 -4
- package/dist/docs/skills/ab.html +4 -4
- package/dist/docs/skills/create-agent.html +4 -4
- package/dist/docs/skills/debug.html +4 -4
- package/dist/docs/skills/evals.html +4 -4
- package/dist/docs/skills/framework-map.html +4 -4
- package/dist/docs/skills/github.html +4 -4
- package/dist/docs/skills/hillclimb.html +4 -4
- package/dist/docs/skills/index.html +4 -4
- package/dist/docs/skills/mcp-auth.html +4 -4
- package/dist/docs/skills/otel.html +4 -4
- package/dist/docs/skills/setup-slack.html +4 -4
- package/dist/docs/storage.html +4 -4
- package/dist/docs/templates/agentic-owners.html +4 -4
- package/dist/docs/templates/agents-md.html +4 -4
- package/dist/docs/templates/code-wiki.html +5 -5
- package/dist/docs/templates/demo.html +5 -5
- package/dist/docs/templates/grokbot-agents.html +29 -0
- package/dist/docs/templates/grokbot-agents.md +48 -0
- package/dist/docs/templates/pr-autofixer.html +4 -4
- package/dist/docs/templates/security-help.html +4 -4
- package/dist/docs/templates/security-reviewer.html +4 -4
- package/dist/docs/templates/triage.html +4 -4
- package/dist/docs/troubleshooting.html +4 -4
- package/dist/files.d.ts +7 -2
- package/dist/files.d.ts.map +1 -1
- package/dist/files.js +7 -2
- package/dist/filesystem.d.ts +440 -0
- package/dist/filesystem.d.ts.map +1 -0
- package/dist/filesystem.js +1694 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/internal/continuation-channel.d.ts +4 -2
- package/dist/internal/continuation-channel.d.ts.map +1 -1
- package/dist/internal/continuation-channel.js +21 -12
- package/dist/internal/continuation-identity.d.ts +13 -5
- package/dist/internal/continuation-identity.d.ts.map +1 -1
- package/dist/internal/continuation-identity.js +74 -35
- package/dist/internal/cursor-agent-template.d.ts +1 -1
- package/dist/internal/cursor-agent-template.d.ts.map +1 -1
- package/dist/internal/cursor-agent-template.js +1 -0
- package/dist/internal/discovery/agent.d.ts.map +1 -1
- package/dist/internal/discovery/agent.js +80 -8
- package/dist/internal/discovery/info.d.ts.map +1 -1
- package/dist/internal/discovery/info.js +3 -0
- package/dist/internal/factory-resource-channel.d.ts +33 -0
- package/dist/internal/factory-resource-channel.d.ts.map +1 -0
- package/dist/internal/factory-resource-channel.js +77 -0
- package/dist/internal/filesystem/errors.d.ts +64 -0
- package/dist/internal/filesystem/errors.d.ts.map +1 -0
- package/dist/internal/filesystem/errors.js +175 -0
- package/dist/internal/filesystem/format.d.ts +28 -0
- package/dist/internal/filesystem/format.d.ts.map +1 -0
- package/dist/internal/filesystem/format.js +213 -0
- package/dist/internal/filesystem/merge.d.ts +34 -0
- package/dist/internal/filesystem/merge.d.ts.map +1 -0
- package/dist/internal/filesystem/merge.js +196 -0
- package/dist/internal/filesystem/scratch.d.ts +59 -0
- package/dist/internal/filesystem/scratch.d.ts.map +1 -0
- package/dist/internal/filesystem/scratch.js +212 -0
- package/dist/internal/filesystem/sdk-schemas.d.ts +29 -0
- package/dist/internal/filesystem/sdk-schemas.d.ts.map +1 -0
- package/dist/internal/filesystem/sdk-schemas.js +153 -0
- package/dist/internal/filesystem/tools.d.ts +42 -0
- package/dist/internal/filesystem/tools.d.ts.map +1 -0
- package/dist/internal/filesystem/tools.js +618 -0
- package/dist/internal/filesystem/walk.d.ts +74 -0
- package/dist/internal/filesystem/walk.d.ts.map +1 -0
- package/dist/internal/filesystem/walk.js +339 -0
- package/dist/internal/framework-file-storage.d.ts +3 -1
- package/dist/internal/framework-file-storage.d.ts.map +1 -1
- package/dist/internal/framework-file-storage.js +3 -1
- package/dist/internal/guest-network.d.ts +5 -2
- package/dist/internal/guest-network.d.ts.map +1 -1
- package/dist/internal/guest-network.js +7 -2
- package/dist/internal/hosted-delivery.d.ts +7 -0
- package/dist/internal/hosted-delivery.d.ts.map +1 -1
- package/dist/internal/hosted-delivery.js +41 -3
- package/dist/internal/hosted-managed-automation.d.ts.map +1 -1
- package/dist/internal/hosted-managed-automation.js +27 -2
- package/dist/internal/init-project.d.ts.map +1 -1
- package/dist/internal/init-project.js +4 -1
- package/dist/internal/sdk-runner.d.ts +13 -1
- package/dist/internal/sdk-runner.d.ts.map +1 -1
- package/dist/internal/sdk-runner.js +21 -1
- package/dist/internal/server.d.ts.map +1 -1
- package/dist/internal/server.js +11 -3
- package/dist/internal/session-engine.d.ts +30 -0
- package/dist/internal/session-engine.d.ts.map +1 -1
- package/dist/internal/session-engine.js +484 -82
- package/dist/internal/store-mirror.d.ts +2 -2
- package/dist/internal/store-mirror.js +2 -2
- package/dist/internal/tenant-slack/relay.d.ts +2 -0
- package/dist/internal/tenant-slack/relay.d.ts.map +1 -1
- package/dist/internal/tenant-slack/relay.js +18 -8
- package/dist/internal/testing/factory-resource-fixtures.d.ts +48 -0
- package/dist/internal/testing/factory-resource-fixtures.d.ts.map +1 -0
- package/dist/internal/testing/factory-resource-fixtures.js +41 -0
- package/dist/internal/workspace-sync.d.ts +31 -6
- package/dist/internal/workspace-sync.d.ts.map +1 -1
- package/dist/internal/workspace-sync.js +67 -12
- package/dist/internal/workspace.d.ts +9 -0
- package/dist/internal/workspace.d.ts.map +1 -1
- package/dist/internal/workspace.js +16 -0
- package/dist/playground/assets/{index-59KvgREd.js → index-BaQzjaNK.js} +40 -40
- package/dist/playground/assets/index-CceqnLTX.css +1 -0
- package/dist/playground/index.html +2 -2
- package/dist/types.d.ts +60 -11
- package/dist/types.d.ts.map +1 -1
- package/docs/README.md +6 -1
- package/docs/design/filesystem.md +376 -0
- package/docs/guides/github.md +5 -0
- package/docs/guides/grokbot-agents.md +93 -0
- package/docs/reference/channels.md +20 -0
- package/docs/reference/cli.md +2 -1
- package/docs/reference/extensions.md +2 -0
- package/docs/templates/grokbot-agents.md +53 -0
- package/package.json +25 -2
- package/src/channels/change-monitors/change-monitors-channel.ts +62 -0
- package/src/channels/change-monitors/index.ts +8 -0
- package/src/channels/change-monitors/types.ts +44 -0
- package/src/channels/deployments/deployments-channel.ts +1 -0
- package/src/channels/deployments/types.ts +2 -0
- package/src/channels/github/defaults.ts +4 -0
- package/src/channels/github/progress.ts +76 -10
- package/src/channels/issues/index.ts +9 -0
- package/src/channels/issues/issues-channel.ts +51 -0
- package/src/channels/issues/types.ts +41 -0
- package/src/files.ts +9 -2
- package/src/filesystem.ts +2074 -0
- package/src/index.ts +28 -0
- package/src/internal/continuation-channel.ts +29 -12
- package/src/internal/continuation-identity.ts +122 -37
- package/src/internal/cursor-agent-template.ts +1 -0
- package/src/internal/discovery/agent.ts +87 -1
- package/src/internal/discovery/info.ts +3 -0
- package/src/internal/factory-resource-channel.ts +122 -0
- package/src/internal/filesystem/errors.ts +220 -0
- package/src/internal/filesystem/format.ts +276 -0
- package/src/internal/filesystem/merge.ts +195 -0
- package/src/internal/filesystem/scratch.ts +255 -0
- package/src/internal/filesystem/sdk-schemas.ts +204 -0
- package/src/internal/filesystem/tools.ts +821 -0
- package/src/internal/filesystem/walk.ts +369 -0
- package/src/internal/framework-file-storage.ts +3 -1
- package/src/internal/guest-network.ts +8 -2
- package/src/internal/hosted-delivery.ts +71 -2
- package/src/internal/hosted-managed-automation.ts +49 -5
- package/src/internal/init-project.ts +4 -1
- package/src/internal/sdk-runner.ts +23 -0
- package/src/internal/server.ts +16 -0
- package/src/internal/session-engine.ts +595 -73
- package/src/internal/store-mirror.ts +2 -2
- package/src/internal/tenant-slack/relay.ts +28 -4
- package/src/internal/testing/factory-resource-fixtures.ts +85 -0
- package/src/internal/workspace-sync.ts +84 -12
- package/src/internal/workspace.ts +20 -0
- package/src/types.ts +58 -11
- package/templates/grokbot-agents/README.md +26 -0
- package/templates/grokbot-agents/agent/agent.ts +6 -0
- package/templates/grokbot-agents/agent/extensions/grokbot.ts +5 -0
- package/templates/grokbot-agents/agent/instructions.md +7 -0
- package/templates/grokbot-agents/evals/evals.config.ts +5 -0
- package/templates/grokbot-agents/evals/grokbot-agents.eval.ts +18 -0
- package/templates/grokbot-agents/init.json +18 -0
- package/templates/grokbot-agents/package.json +17 -0
- package/templates/grokbot-agents/tsconfig.json +12 -0
- package/dist/docs/assets/chunks/@localSearchIndexroot.nrl1ifBq.js +0 -1
- package/dist/docs/assets/index.md.D75GWhPl.js +0 -5
- package/dist/docs/assets/index.md.D75GWhPl.lean.js +0 -1
- package/dist/playground/assets/index-MbMxXg-y.css +0 -1
- /package/dist/docs/assets/{reference_cli.md.CJNc_xYK.lean.js → reference_cli.md.C6Lo8SEd.lean.js} +0 -0
- /package/dist/docs/assets/{reference_extensions.md.DykHW3qL.lean.js → reference_extensions.md.CGmMLblt.lean.js} +0 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { defineChannel, localDevStrict, POST } from "../channels.js";
|
|
11
|
+
import { tagOutcome } from "./channel-dispatch.js";
|
|
12
|
+
import { attachHostedAdmissionAdapter } from "./hosted-admission-adapter.js";
|
|
13
|
+
import { bindLocalIngressSend } from "./local-ingress.js";
|
|
14
|
+
/**
|
|
15
|
+
* Shared pack for Factory resource channels that have one event type, no
|
|
16
|
+
* subscription filter, and the same local-replay / hosted-admission path.
|
|
17
|
+
*/
|
|
18
|
+
export function createFactoryResourceChannel(spec) {
|
|
19
|
+
const optionsByDefinition = new WeakMap();
|
|
20
|
+
function dispatchEvent(input) {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
yield input.options.onEvent(input.event, bindLocalIngressSend(input.args, {
|
|
23
|
+
identity: input.options.continuation,
|
|
24
|
+
kind: spec.kind,
|
|
25
|
+
eventType: input.event.eventType,
|
|
26
|
+
payload: input.event,
|
|
27
|
+
}));
|
|
28
|
+
return tagOutcome(Response.json({ ok: true }), "task");
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function channel(options) {
|
|
32
|
+
var _a, _b;
|
|
33
|
+
const routePath = (_a = options.path) !== null && _a !== void 0 ? _a : "/";
|
|
34
|
+
const definition = defineChannel({
|
|
35
|
+
auth: (_b = options.auth) !== null && _b !== void 0 ? _b : [localDevStrict()],
|
|
36
|
+
meta: {
|
|
37
|
+
kind: spec.kind,
|
|
38
|
+
factoryEventTypes: spec.eventTypes,
|
|
39
|
+
},
|
|
40
|
+
onStart: options.onStart,
|
|
41
|
+
onStop: options.onStop,
|
|
42
|
+
routes: [
|
|
43
|
+
POST(routePath, {
|
|
44
|
+
description: spec.replayDescription,
|
|
45
|
+
bodySchema: spec.eventSchema,
|
|
46
|
+
handler: (_request, args) => __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
return dispatchEvent({
|
|
48
|
+
options,
|
|
49
|
+
event: args.body,
|
|
50
|
+
args,
|
|
51
|
+
});
|
|
52
|
+
}),
|
|
53
|
+
}),
|
|
54
|
+
],
|
|
55
|
+
});
|
|
56
|
+
optionsByDefinition.set(definition, options);
|
|
57
|
+
attachHostedAdmissionAdapter(definition, {
|
|
58
|
+
kind: spec.kind,
|
|
59
|
+
dispatch: (_a) => __awaiter(this, [_a], void 0, function* ({ payload, args }) {
|
|
60
|
+
const parsed = spec.eventSchema.safeParse(payload);
|
|
61
|
+
if (!parsed.success) {
|
|
62
|
+
return Response.json({ ok: false, error: spec.invalidError }, { status: 400 });
|
|
63
|
+
}
|
|
64
|
+
return dispatchEvent({
|
|
65
|
+
options,
|
|
66
|
+
event: parsed.data,
|
|
67
|
+
args,
|
|
68
|
+
});
|
|
69
|
+
}),
|
|
70
|
+
});
|
|
71
|
+
return definition;
|
|
72
|
+
}
|
|
73
|
+
function getOptions(definition) {
|
|
74
|
+
return optionsByDefinition.get(definition);
|
|
75
|
+
}
|
|
76
|
+
return { channel, getOptions };
|
|
77
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed FileSystem throws. Every method error is a {@link PathError}
|
|
3
|
+
* so composers (`unionFs`) can rewrite `path` without scraping
|
|
4
|
+
* `error.message`.
|
|
5
|
+
*
|
|
6
|
+
* Messages stay the FileSystem contract strings. `path` is the
|
|
7
|
+
* absolute posix path the error is about (child-root on a mount,
|
|
8
|
+
* namespace path after `unionFs` remaps it).
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Base of every FileSystem method throw. Config / factory errors
|
|
12
|
+
* (`FileSystemConfigError`, empty `overlayFs`) are not PathErrors.
|
|
13
|
+
*/
|
|
14
|
+
export declare class PathError extends Error {
|
|
15
|
+
readonly path: string;
|
|
16
|
+
constructor(path: string, message: string);
|
|
17
|
+
/**
|
|
18
|
+
* Same error at a rewritten path. `unionFs` prepends the mount
|
|
19
|
+
* prefix this way. Subclass identity and extra fields stay.
|
|
20
|
+
*/
|
|
21
|
+
withPath(path: string): this;
|
|
22
|
+
protected recreate(path: string, message: string): this;
|
|
23
|
+
}
|
|
24
|
+
export declare class FileNotFoundError extends PathError {
|
|
25
|
+
constructor(path: string, message?: string);
|
|
26
|
+
protected recreate(path: string, message: string): this;
|
|
27
|
+
}
|
|
28
|
+
export declare class ReadOnlyMountError extends PathError {
|
|
29
|
+
constructor(path: string, message?: string);
|
|
30
|
+
protected recreate(path: string, message: string): this;
|
|
31
|
+
}
|
|
32
|
+
export declare class NoMountError extends PathError {
|
|
33
|
+
constructor(path: string, message?: string);
|
|
34
|
+
protected recreate(path: string, message: string): this;
|
|
35
|
+
}
|
|
36
|
+
export declare class WriteFailedError extends PathError {
|
|
37
|
+
constructor(path: string, message?: string);
|
|
38
|
+
protected recreate(path: string, message: string): this;
|
|
39
|
+
}
|
|
40
|
+
export declare class DeleteNotSupportedError extends PathError {
|
|
41
|
+
constructor(path: string, message?: string);
|
|
42
|
+
protected recreate(path: string, message: string): this;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Exact-edit contract failures (`oldText is empty`, uniqueness).
|
|
46
|
+
* `message` is the contract string; it does not embed `path`.
|
|
47
|
+
*/
|
|
48
|
+
export declare class EditError extends PathError {
|
|
49
|
+
protected recreate(path: string, message: string): this;
|
|
50
|
+
}
|
|
51
|
+
export declare class InvalidGrepPatternError extends PathError {
|
|
52
|
+
readonly pattern: string;
|
|
53
|
+
constructor(pattern: string, path?: string, message?: string);
|
|
54
|
+
protected recreate(path: string, message: string): this;
|
|
55
|
+
}
|
|
56
|
+
export declare function isFileNotFoundError(error: unknown): boolean;
|
|
57
|
+
export declare function isInvalidGrepPatternError(error: unknown): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Remap a child throw onto a mount prefix. Typed {@link PathError}
|
|
60
|
+
* keeps its class and rewrites `path`. Untyped `Error` still gets
|
|
61
|
+
* a best-effort message rewrite so older custom trees keep working.
|
|
62
|
+
*/
|
|
63
|
+
export declare function remapPathError(error: unknown, prefix: string): Error;
|
|
64
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/internal/filesystem/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAoCH;;;GAGG;AACH,qBAAa,SAAU,SAAQ,KAAK;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,YAAY,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAIxC;IAED;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAS3B;IAED,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAEtD;CACF;AAED,qBAAa,iBAAkB,SAAQ,SAAS;IAC9C,YAAY,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAEzC;IAED,UAAmB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAE/D;CACF;AAED,qBAAa,kBAAmB,SAAQ,SAAS;IAC/C,YAAY,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAEzC;IAED,UAAmB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAE/D;CACF;AAED,qBAAa,YAAa,SAAQ,SAAS;IACzC,YAAY,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAEzC;IAED,UAAmB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAE/D;CACF;AAED,qBAAa,gBAAiB,SAAQ,SAAS;IAC7C,YAAY,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAEzC;IAED,UAAmB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAE/D;CACF;AAED,qBAAa,uBAAwB,SAAQ,SAAS;IACpD,YAAY,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAKzC;IAED,UAAmB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAE/D;CACF;AAED;;;GAGG;AACH,qBAAa,SAAU,SAAQ,SAAS;IACtC,UAAmB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAE/D;CACF;AAED,qBAAa,uBAAwB,SAAQ,SAAS;IACpD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB,YAAY,OAAO,EAAE,MAAM,EAAE,IAAI,SAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAGxD;IAED,UAAmB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAE/D;CACF;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAK3D;AAED,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAMjE;AAWD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,KAAK,CAQpE"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed FileSystem throws. Every method error is a {@link PathError}
|
|
3
|
+
* so composers (`unionFs`) can rewrite `path` without scraping
|
|
4
|
+
* `error.message`.
|
|
5
|
+
*
|
|
6
|
+
* Messages stay the FileSystem contract strings. `path` is the
|
|
7
|
+
* absolute posix path the error is about (child-root on a mount,
|
|
8
|
+
* namespace path after `unionFs` remaps it).
|
|
9
|
+
*/
|
|
10
|
+
import path from "node:path";
|
|
11
|
+
function normalizeErrorPath(input) {
|
|
12
|
+
const slashes = input.replace(/\\/g, "/");
|
|
13
|
+
if (slashes === "") {
|
|
14
|
+
return "/";
|
|
15
|
+
}
|
|
16
|
+
const withSlash = slashes.startsWith("/") ? slashes : `/${slashes}`;
|
|
17
|
+
const resolved = path.posix.normalize(withSlash);
|
|
18
|
+
if (resolved.length > 1 && resolved.endsWith("/")) {
|
|
19
|
+
return resolved.slice(0, -1);
|
|
20
|
+
}
|
|
21
|
+
return resolved === "." || resolved === "" ? "/" : resolved;
|
|
22
|
+
}
|
|
23
|
+
const ROOT_MESSAGE_PREFIX = /^(not found|read-only mount|write failed|edit failed|no mount for path|delete is not supported): \/$/;
|
|
24
|
+
function rewritePathInMessage(message, from, to) {
|
|
25
|
+
if (from === to) {
|
|
26
|
+
return message;
|
|
27
|
+
}
|
|
28
|
+
if (from === "/") {
|
|
29
|
+
return ROOT_MESSAGE_PREFIX.test(message)
|
|
30
|
+
? message.replace(/\/$/, to)
|
|
31
|
+
: message;
|
|
32
|
+
}
|
|
33
|
+
return message.includes(from) ? message.split(from).join(to) : message;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Base of every FileSystem method throw. Config / factory errors
|
|
37
|
+
* (`FileSystemConfigError`, empty `overlayFs`) are not PathErrors.
|
|
38
|
+
*/
|
|
39
|
+
export class PathError extends Error {
|
|
40
|
+
constructor(path, message) {
|
|
41
|
+
super(message);
|
|
42
|
+
this.name = new.target.name;
|
|
43
|
+
this.path = normalizeErrorPath(path);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Same error at a rewritten path. `unionFs` prepends the mount
|
|
47
|
+
* prefix this way. Subclass identity and extra fields stay.
|
|
48
|
+
*/
|
|
49
|
+
withPath(path) {
|
|
50
|
+
const next = normalizeErrorPath(path);
|
|
51
|
+
if (next === this.path) {
|
|
52
|
+
return this;
|
|
53
|
+
}
|
|
54
|
+
return this.recreate(next, rewritePathInMessage(this.message, this.path, next));
|
|
55
|
+
}
|
|
56
|
+
recreate(path, message) {
|
|
57
|
+
return new PathError(path, message);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
export class FileNotFoundError extends PathError {
|
|
61
|
+
constructor(path, message) {
|
|
62
|
+
super(path, message !== null && message !== void 0 ? message : `not found: ${normalizeErrorPath(path)}`);
|
|
63
|
+
}
|
|
64
|
+
recreate(path, message) {
|
|
65
|
+
return new FileNotFoundError(path, message);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
export class ReadOnlyMountError extends PathError {
|
|
69
|
+
constructor(path, message) {
|
|
70
|
+
super(path, message !== null && message !== void 0 ? message : `read-only mount: ${normalizeErrorPath(path)}`);
|
|
71
|
+
}
|
|
72
|
+
recreate(path, message) {
|
|
73
|
+
return new ReadOnlyMountError(path, message);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
export class NoMountError extends PathError {
|
|
77
|
+
constructor(path, message) {
|
|
78
|
+
super(path, message !== null && message !== void 0 ? message : `no mount for path: ${normalizeErrorPath(path)}`);
|
|
79
|
+
}
|
|
80
|
+
recreate(path, message) {
|
|
81
|
+
return new NoMountError(path, message);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
export class WriteFailedError extends PathError {
|
|
85
|
+
constructor(path, message) {
|
|
86
|
+
super(path, message !== null && message !== void 0 ? message : `write failed: ${normalizeErrorPath(path)}`);
|
|
87
|
+
}
|
|
88
|
+
recreate(path, message) {
|
|
89
|
+
return new WriteFailedError(path, message);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
export class DeleteNotSupportedError extends PathError {
|
|
93
|
+
constructor(path, message) {
|
|
94
|
+
super(path, message !== null && message !== void 0 ? message : `delete is not supported: ${normalizeErrorPath(path)}`);
|
|
95
|
+
}
|
|
96
|
+
recreate(path, message) {
|
|
97
|
+
return new DeleteNotSupportedError(path, message);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Exact-edit contract failures (`oldText is empty`, uniqueness).
|
|
102
|
+
* `message` is the contract string; it does not embed `path`.
|
|
103
|
+
*/
|
|
104
|
+
export class EditError extends PathError {
|
|
105
|
+
recreate(path, message) {
|
|
106
|
+
return new EditError(path, message);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
export class InvalidGrepPatternError extends PathError {
|
|
110
|
+
constructor(pattern, path = "/", message) {
|
|
111
|
+
super(path, message !== null && message !== void 0 ? message : `invalid grep pattern: ${pattern}`);
|
|
112
|
+
this.pattern = pattern;
|
|
113
|
+
}
|
|
114
|
+
recreate(path, message) {
|
|
115
|
+
return new InvalidGrepPatternError(this.pattern, path, message);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
export function isFileNotFoundError(error) {
|
|
119
|
+
return (error instanceof FileNotFoundError ||
|
|
120
|
+
(error instanceof Error && error.message.startsWith("not found:")));
|
|
121
|
+
}
|
|
122
|
+
export function isInvalidGrepPatternError(error) {
|
|
123
|
+
return (error instanceof InvalidGrepPatternError ||
|
|
124
|
+
(error instanceof Error &&
|
|
125
|
+
error.message.startsWith("invalid grep pattern:")));
|
|
126
|
+
}
|
|
127
|
+
const CONTRACT_PATH_LABELS = [
|
|
128
|
+
"not found: ",
|
|
129
|
+
"read-only mount: ",
|
|
130
|
+
"write failed: ",
|
|
131
|
+
"edit failed: ",
|
|
132
|
+
"no mount for path: ",
|
|
133
|
+
"delete is not supported: ",
|
|
134
|
+
];
|
|
135
|
+
/**
|
|
136
|
+
* Remap a child throw onto a mount prefix. Typed {@link PathError}
|
|
137
|
+
* keeps its class and rewrites `path`. Untyped `Error` still gets
|
|
138
|
+
* a best-effort message rewrite so older custom trees keep working.
|
|
139
|
+
*/
|
|
140
|
+
export function remapPathError(error, prefix) {
|
|
141
|
+
if (error instanceof PathError) {
|
|
142
|
+
return error.withPath(joinMountPath(error.path, prefix));
|
|
143
|
+
}
|
|
144
|
+
if (!(error instanceof Error)) {
|
|
145
|
+
return new PathError(prefix, String(error));
|
|
146
|
+
}
|
|
147
|
+
return rewriteUntypedMountError(error, prefix);
|
|
148
|
+
}
|
|
149
|
+
function joinMountPath(childPath, prefix) {
|
|
150
|
+
const mount = normalizeErrorPath(prefix);
|
|
151
|
+
const child = normalizeErrorPath(childPath);
|
|
152
|
+
if (mount === "/") {
|
|
153
|
+
return child;
|
|
154
|
+
}
|
|
155
|
+
if (child === "/") {
|
|
156
|
+
return mount;
|
|
157
|
+
}
|
|
158
|
+
return `${mount}${child}`;
|
|
159
|
+
}
|
|
160
|
+
function rewriteUntypedMountError(error, prefix) {
|
|
161
|
+
for (const label of CONTRACT_PATH_LABELS) {
|
|
162
|
+
if (!error.message.startsWith(label)) {
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
const childPath = error.message.slice(label.length);
|
|
166
|
+
const next = `${label}${joinMountPath(childPath, prefix)}`;
|
|
167
|
+
if (next === error.message) {
|
|
168
|
+
return error;
|
|
169
|
+
}
|
|
170
|
+
const rewritten = new Error(next);
|
|
171
|
+
rewritten.name = error.name;
|
|
172
|
+
return rewritten;
|
|
173
|
+
}
|
|
174
|
+
return error;
|
|
175
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model-facing strings that match Cursor SDK native tool output
|
|
3
|
+
* (LocalLsExecutor / read / grep / glob formatters).
|
|
4
|
+
*/
|
|
5
|
+
import type { GrepUnionResult } from "../../filesystem.js";
|
|
6
|
+
import type { LsDirectoryTreeNode } from "./walk.js";
|
|
7
|
+
/**
|
|
8
|
+
* Number already-sliced Read content. `FileSystem.read` applies offset/
|
|
9
|
+
* limit; do not window again or line numbers restart at 1.
|
|
10
|
+
*/
|
|
11
|
+
export declare function slicedReadStartLine(totalLines: number, offset?: number): number;
|
|
12
|
+
export declare function formatNumberedLines(content: string, options?: {
|
|
13
|
+
offset?: number;
|
|
14
|
+
limit?: number;
|
|
15
|
+
/** When set, `content` is already the window; number from this line. */
|
|
16
|
+
startLine?: number;
|
|
17
|
+
totalLines?: number;
|
|
18
|
+
}): string;
|
|
19
|
+
export declare function formatLsTree(result: LsDirectoryTreeNode): string;
|
|
20
|
+
export declare function formatGlobOutput(dir: string, files: readonly string[]): string;
|
|
21
|
+
export declare function formatGrepOutput(union: GrepUnionResult | undefined): string;
|
|
22
|
+
export declare function formatWriteOutput(path: string): string;
|
|
23
|
+
export declare function formatStrReplaceOutput(args: {
|
|
24
|
+
path: string;
|
|
25
|
+
replaceAll: boolean;
|
|
26
|
+
occurrencesModified: number;
|
|
27
|
+
}): string;
|
|
28
|
+
//# sourceMappingURL=format.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../src/internal/filesystem/format.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAKrD;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,MAAM,EAClB,MAAM,CAAC,EAAE,MAAM,GACd,MAAM,CAQR;AAED,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,MAAM,EACf,OAAO,GAAE;IACP,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wEAAwE;IACxE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CAChB,GACL,MAAM,CAuBR;AAqBD,wBAAgB,YAAY,CAAC,MAAM,EAAE,mBAAmB,GAAG,MAAM,CAsChE;AAsED,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,SAAS,MAAM,EAAE,GACvB,MAAM,CAmBR;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,eAAe,GAAG,SAAS,GAAG,MAAM,CA0C3E;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,OAAO,CAAC;IACpB,mBAAmB,EAAE,MAAM,CAAC;CAC7B,GAAG,MAAM,CAQT"}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model-facing strings that match Cursor SDK native tool output
|
|
3
|
+
* (LocalLsExecutor / read / grep / glob formatters).
|
|
4
|
+
*/
|
|
5
|
+
import { posix } from "node:path";
|
|
6
|
+
const LS_RENDER_CHARACTER_BUDGET = 10000;
|
|
7
|
+
const GLOB_TOTAL_CHARACTER_BUDGET = 5000;
|
|
8
|
+
/**
|
|
9
|
+
* Number already-sliced Read content. `FileSystem.read` applies offset/
|
|
10
|
+
* limit; do not window again or line numbers restart at 1.
|
|
11
|
+
*/
|
|
12
|
+
export function slicedReadStartLine(totalLines, offset) {
|
|
13
|
+
if (offset === undefined) {
|
|
14
|
+
return 1;
|
|
15
|
+
}
|
|
16
|
+
if (offset < 0) {
|
|
17
|
+
return Math.max(1, totalLines + offset + 1);
|
|
18
|
+
}
|
|
19
|
+
return Math.max(1, offset);
|
|
20
|
+
}
|
|
21
|
+
export function formatNumberedLines(content, options = {}) {
|
|
22
|
+
var _a;
|
|
23
|
+
const lines = content === "" ? [] : content.split("\n");
|
|
24
|
+
if (lines.length === 0) {
|
|
25
|
+
return "";
|
|
26
|
+
}
|
|
27
|
+
const { offset, limit, startLine } = options;
|
|
28
|
+
let start = 1;
|
|
29
|
+
let window = lines;
|
|
30
|
+
const total = (_a = options.totalLines) !== null && _a !== void 0 ? _a : lines.length;
|
|
31
|
+
if (startLine !== undefined) {
|
|
32
|
+
start = startLine;
|
|
33
|
+
}
|
|
34
|
+
else if (offset !== undefined || limit !== undefined) {
|
|
35
|
+
const effectiveOffset = offset !== null && offset !== void 0 ? offset : 1;
|
|
36
|
+
const effectiveLimit = limit !== null && limit !== void 0 ? limit : (effectiveOffset < 0 ? Math.abs(effectiveOffset) : total);
|
|
37
|
+
start =
|
|
38
|
+
effectiveOffset < 0
|
|
39
|
+
? Math.max(1, total + effectiveOffset + 1)
|
|
40
|
+
: Math.max(1, effectiveOffset);
|
|
41
|
+
const end = Math.min(total, start + effectiveLimit - 1);
|
|
42
|
+
window = lines.slice(start - 1, end);
|
|
43
|
+
}
|
|
44
|
+
return renderNumberedWindow(window, start, total);
|
|
45
|
+
}
|
|
46
|
+
function renderNumberedWindow(window, start, total) {
|
|
47
|
+
const numbered = window.map((line, index) => `${String(start + index).padStart(6, " ")}|${line}`);
|
|
48
|
+
let result = numbered.join("\n");
|
|
49
|
+
if (start > 1) {
|
|
50
|
+
result = `... ${start - 1} ${start - 1 === 1 ? "line" : "lines"} not shown ...\n${result}`;
|
|
51
|
+
}
|
|
52
|
+
const end = start + window.length - 1;
|
|
53
|
+
if (end < total) {
|
|
54
|
+
result += `\n... ${total - end} ${total - end === 1 ? "line" : "lines"} not shown ...`;
|
|
55
|
+
}
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
58
|
+
export function formatLsTree(result) {
|
|
59
|
+
if (result.childrenWereProcessed &&
|
|
60
|
+
result.childrenDirs.length === 0 &&
|
|
61
|
+
result.childrenFiles.length === 0) {
|
|
62
|
+
const trailingSlash = result.absPath.endsWith("/") ? "" : "/";
|
|
63
|
+
return `${result.absPath}${trailingSlash}\n... no children found ...`;
|
|
64
|
+
}
|
|
65
|
+
const characterBudget = LS_RENDER_CHARACTER_BUDGET;
|
|
66
|
+
let toolResponse = renderDirectoryTree(result).result;
|
|
67
|
+
if (toolResponse.length > characterBudget) {
|
|
68
|
+
toolResponse = renderDirectoryTree(result, true, 0).result;
|
|
69
|
+
if (toolResponse.length > characterBudget) {
|
|
70
|
+
toolResponse = renderDirectoryTree(result, false, 0).result;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const notes = [];
|
|
74
|
+
if (!result.childrenWereProcessed || toolResponse.length > characterBudget) {
|
|
75
|
+
if (toolResponse.length > characterBudget) {
|
|
76
|
+
toolResponse = toolResponse.slice(0, characterBudget);
|
|
77
|
+
const lastNewlineIndex = toolResponse.lastIndexOf("\n");
|
|
78
|
+
if (lastNewlineIndex > 0) {
|
|
79
|
+
toolResponse = toolResponse.slice(0, lastNewlineIndex + 1);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
toolResponse += " ...\n";
|
|
83
|
+
notes.push(`target_directory is too large (either too many children or their names are too long).` +
|
|
84
|
+
` Immediate children were truncated. Try doing more specific search or use the script tool.`);
|
|
85
|
+
}
|
|
86
|
+
if (notes.length === 1) {
|
|
87
|
+
toolResponse += `\nNote: ${notes[0]}`;
|
|
88
|
+
}
|
|
89
|
+
return toolResponse;
|
|
90
|
+
}
|
|
91
|
+
function renderDirectoryTree(rootDirectory, renderExtensionCounts = true, renderDepthLimit) {
|
|
92
|
+
function render(dir, depth) {
|
|
93
|
+
const indent = " ".repeat(depth);
|
|
94
|
+
let result;
|
|
95
|
+
if (depth === 0) {
|
|
96
|
+
const trailingSep = dir.absPath.endsWith("/") ? "" : "/";
|
|
97
|
+
result = `${dir.absPath}${trailingSep}\n`;
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
result = `${indent}- ${posix.basename(dir.absPath)}/\n`;
|
|
101
|
+
}
|
|
102
|
+
const allChildren = [
|
|
103
|
+
...dir.childrenFiles.map((file) => ({ type: "file", name: file.name })),
|
|
104
|
+
...dir.childrenDirs.map((childDir) => ({
|
|
105
|
+
type: "dir",
|
|
106
|
+
name: posix.basename(childDir.absPath),
|
|
107
|
+
dir: childDir,
|
|
108
|
+
})),
|
|
109
|
+
];
|
|
110
|
+
allChildren.sort((left, right) => left.name.localeCompare(right.name));
|
|
111
|
+
const childIndent = " ".repeat(depth + 1);
|
|
112
|
+
for (const child of allChildren) {
|
|
113
|
+
if (child.type === "file") {
|
|
114
|
+
result += `${childIndent}- ${child.name}\n`;
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
const childDir = child.dir;
|
|
118
|
+
if (childDir.childrenWereProcessed &&
|
|
119
|
+
(renderDepthLimit === undefined || depth < renderDepthLimit)) {
|
|
120
|
+
result += render(childDir, depth + 1);
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
const extensionCounts = Object.entries(childDir.fullSubtreeExtensionCounts);
|
|
124
|
+
if (extensionCounts.length > 0 && renderExtensionCounts) {
|
|
125
|
+
const sorted = [...extensionCounts].sort(([, countA], [, countB]) => countB - countA);
|
|
126
|
+
const shown = sorted.slice(0, 3);
|
|
127
|
+
const summary = shown
|
|
128
|
+
.map(([ext, count]) => `${count} *${ext === "" ? "" : ext}`)
|
|
129
|
+
.join(", ");
|
|
130
|
+
result += `${childIndent}- ${child.name}/ (${childDir.numFiles} files: ${summary})\n`;
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
result += `${childIndent}- ${child.name}/\n`;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return result;
|
|
137
|
+
}
|
|
138
|
+
return { result: render(rootDirectory, 0) };
|
|
139
|
+
}
|
|
140
|
+
export function formatGlobOutput(dir, files) {
|
|
141
|
+
var _a;
|
|
142
|
+
const normalizedRoot = dir.replace(/\/+$/, "") || "/";
|
|
143
|
+
const prefix = normalizedRoot === "/" ? "/" : `${normalizedRoot}/`;
|
|
144
|
+
const relative = files.map((filePath) => filePath.startsWith(prefix) ? filePath.slice(prefix.length) : filePath);
|
|
145
|
+
if (relative.length === 0) {
|
|
146
|
+
return `Result of search in '${dir}': 0 files found\n`;
|
|
147
|
+
}
|
|
148
|
+
let output = `Result of search in '${dir}' (total ${relative.length} file${relative.length === 1 ? "" : "s"}):\n`;
|
|
149
|
+
for (let i = 0; i < relative.length; i++) {
|
|
150
|
+
const file = (_a = relative[i]) !== null && _a !== void 0 ? _a : "";
|
|
151
|
+
if (output.length + file.length > GLOB_TOTAL_CHARACTER_BUDGET) {
|
|
152
|
+
output += `... ${relative.length - i} more files ... (Do a more specific search if needed)\n`;
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
output += `- ${file}\n`;
|
|
156
|
+
}
|
|
157
|
+
return output;
|
|
158
|
+
}
|
|
159
|
+
export function formatGrepOutput(union) {
|
|
160
|
+
var _a, _b, _c, _d;
|
|
161
|
+
if (union === undefined) {
|
|
162
|
+
return "No matches found";
|
|
163
|
+
}
|
|
164
|
+
if (union.type === "files") {
|
|
165
|
+
if (union.output.files.length === 0) {
|
|
166
|
+
return "No files with matches found";
|
|
167
|
+
}
|
|
168
|
+
return union.output.files.join("\n");
|
|
169
|
+
}
|
|
170
|
+
if (union.type === "count") {
|
|
171
|
+
if (union.output.counts.length === 0) {
|
|
172
|
+
return "No matches found";
|
|
173
|
+
}
|
|
174
|
+
return union.output.counts
|
|
175
|
+
.map((row) => `${row.file}:${row.count}`)
|
|
176
|
+
.join("\n");
|
|
177
|
+
}
|
|
178
|
+
if (union.output.matches.length === 0) {
|
|
179
|
+
return "No matches found";
|
|
180
|
+
}
|
|
181
|
+
const lines = [];
|
|
182
|
+
let currentFile;
|
|
183
|
+
for (const match of union.output.matches) {
|
|
184
|
+
if (match.file !== currentFile) {
|
|
185
|
+
if (currentFile !== undefined) {
|
|
186
|
+
lines.push("");
|
|
187
|
+
}
|
|
188
|
+
currentFile = match.file;
|
|
189
|
+
lines.push(match.file);
|
|
190
|
+
}
|
|
191
|
+
const before = (_a = match.beforeContext) !== null && _a !== void 0 ? _a : [];
|
|
192
|
+
const matchLine = (_b = match.lineNumber) !== null && _b !== void 0 ? _b : 1;
|
|
193
|
+
before.forEach((line, index) => {
|
|
194
|
+
lines.push(` ${matchLine - before.length + index}-${line}`);
|
|
195
|
+
});
|
|
196
|
+
lines.push(` ${(_c = match.lineNumber) !== null && _c !== void 0 ? _c : ""}:${match.line}`);
|
|
197
|
+
((_d = match.afterContext) !== null && _d !== void 0 ? _d : []).forEach((line, index) => {
|
|
198
|
+
lines.push(` ${matchLine + 1 + index}-${line}`);
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
return lines.join("\n");
|
|
202
|
+
}
|
|
203
|
+
export function formatWriteOutput(path) {
|
|
204
|
+
return `Wrote contents to ${path}`;
|
|
205
|
+
}
|
|
206
|
+
export function formatStrReplaceOutput(args) {
|
|
207
|
+
if (!args.replaceAll) {
|
|
208
|
+
return `The file ${args.path} has been updated.`;
|
|
209
|
+
}
|
|
210
|
+
const occurrenceLabel = args.occurrencesModified === 1 ? "occurrence" : "occurrences";
|
|
211
|
+
const verb = args.occurrencesModified === 1 ? "has" : "have";
|
|
212
|
+
return `${args.occurrencesModified} ${occurrenceLabel} in file ${args.path} ${verb} been updated.`;
|
|
213
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* K-way merge of already-sorted streams. Each source must be ordered
|
|
3
|
+
* under the same `compare`; the merge does not re-sort a source.
|
|
4
|
+
*
|
|
5
|
+
* A binary heap of heads keeps the next yield O(log k) in the number of
|
|
6
|
+
* sources. `unique` skips later copies of a key so an earlier source can
|
|
7
|
+
* shadow a later one (the union rule).
|
|
8
|
+
*/
|
|
9
|
+
export interface MergeSortedOptions<T> {
|
|
10
|
+
compare: (left: T, right: T) => number;
|
|
11
|
+
unique?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Merge already-sorted iterables / async iterables under `compare`.
|
|
15
|
+
* Equal keys (`compare === 0`) keep source order: earlier `sources`
|
|
16
|
+
* index wins. With `unique`, those later copies are skipped.
|
|
17
|
+
*/
|
|
18
|
+
export declare function mergeSorted<T>(sources: Array<Iterable<T> | AsyncIterable<T>>, options: MergeSortedOptions<T>): AsyncGenerator<T>;
|
|
19
|
+
/**
|
|
20
|
+
* Binary min-heap. `compare(a, b) < 0` means `a` is before `b`.
|
|
21
|
+
* Exported for the invariant tests; composers use {@link mergeSorted}.
|
|
22
|
+
*/
|
|
23
|
+
export declare class MinHeap<T> {
|
|
24
|
+
private readonly compare;
|
|
25
|
+
private readonly items;
|
|
26
|
+
constructor(compare: (left: T, right: T) => number);
|
|
27
|
+
get size(): number;
|
|
28
|
+
peek(): T | undefined;
|
|
29
|
+
push(item: T): void;
|
|
30
|
+
pop(): T | undefined;
|
|
31
|
+
private bubbleUp;
|
|
32
|
+
private bubbleDown;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=merge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../../src/internal/filesystem/merge.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,WAAW,kBAAkB,CAAC,CAAC;IACnC,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,MAAM,CAAC;IACvC,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAQD;;;;GAIG;AACH,wBAAuB,WAAW,CAAC,CAAC,EAClC,OAAO,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,EAC9C,OAAO,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAC7B,cAAc,CAAC,CAAC,CAAC,CAsCnB;AAoCD;;;GAGG;AACH,qBAAa,OAAO,CAAC,CAAC;IAGR,OAAO,CAAC,QAAQ,CAAC,OAAO;IAFpC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAW;IAEjC,YAA6B,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,MAAM,EAAI;IAEvE,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,IAAI,CAAC,GAAG,SAAS,CAEpB;IAED,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,CAGlB;IAED,GAAG,IAAI,CAAC,GAAG,SAAS,CAYnB;IAED,OAAO,CAAC,QAAQ;IAmBhB,OAAO,CAAC,UAAU;CAqCnB"}
|