@swoop111/dsh-tool-fs 0.2.0-rc.2 → 0.2.0-rc.2.1

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.
@@ -1,58 +1,58 @@
1
- /**
2
- * Window completion for reads: the neighbouring lines that give a delivered
3
- * window its structural boundaries. The head is the single line that opened
4
- * the construct the window starts inside; the tail is the run of following
5
- * lines that closes the construct the window ends inside. Neither ever
6
- * modifies, reorders, or drops a delivered line — a window either gains
7
- * context or stays exactly as the caller asked for it.
8
- *
9
- * The head is one line because everything between that opening line and the
10
- * window is the content the caller chose to skip; the tail is a run because
11
- * the construct cannot be called closed until its closer arrives.
12
- * @module @deepseek-ai/dsh-tool-fs/completion
13
- */
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
14
  import type { FileTextLine } from './read-render.ts';
15
15
  import type { CompletionRule } from './structure.ts';
16
- /** Fetches up to `count` lines of the file on one side of the window, in file order. */
16
+
17
17
  export type LineSupplier = (count: number) => Promise<FileTextLine[] | undefined>;
18
- /** Where a completion fetches the lines on each side of the window. */
18
+
19
19
  export interface CompletionLineSuppliers {
20
- /**
21
- * The lines immediately before the window, in file order; the last entry is
22
- * the window's predecessor line. `undefined` signals that no such line exists.
23
- */
20
+
21
+
22
+
23
+
24
24
  preceding: LineSupplier;
25
- /**
26
- * The lines immediately after the window, in file order; the first entry is
27
- * the window's successor line. `undefined` signals end of file.
28
- */
25
+
26
+
27
+
28
+
29
29
  following: LineSupplier;
30
30
  }
31
- /** Configuration for window completion; the only field is a hard cap. */
31
+
32
32
  export interface CompletionTuning {
33
- /**
34
- * Maximum lines appended to close the tail, and how far back the head search
35
- * may reach for the line that opened the construct.
36
- */
33
+
34
+
35
+
36
+
37
37
  maxLines: number;
38
38
  }
39
- /** The neighbouring lines a window gained, and the rules that found them. */
39
+
40
40
  export interface CompletionResult {
41
- /** The line that opened the construct the window starts inside; empty when the window starts at a boundary. */
41
+
42
42
  head: FileTextLine[];
43
- /** The lines that close the construct the window ends inside; empty when the tail is balanced. */
43
+
44
44
  tail: FileTextLine[];
45
- /** The rule that produced `head`; absent when nothing was prepended. */
45
+
46
46
  headRule?: CompletionRule;
47
- /** The rule that produced `tail`; absent when nothing was appended. */
47
+
48
48
  tailRule?: CompletionRule;
49
49
  }
50
- /**
51
- * Complete a window's structural boundaries.
52
- * @param lines - the delivered window lines, in file order.
53
- * @param supply - the line sources on each side of the window.
54
- * @param tuning - the hard caps for the added lines.
55
- * @returns the head and tail lines with the rules that produced them; `undefined` when neither side completes.
56
- */
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
57
  export declare function completeWindow(lines: readonly FileTextLine[], supply: CompletionLineSuppliers, tuning: CompletionTuning): Promise<CompletionResult | undefined>;
58
- //# sourceMappingURL=completion.d.ts.map
58
+
@@ -1,41 +1,41 @@
1
- /**
2
- * Result-time contextual diff presentation for write and edit. Storage returns before/after
3
- * text; this model-facing layer derives one three-line-context card per applied hunk.
4
- * @module @deepseek-ai/dsh-tool-fs/src/diff
5
- */
1
+
2
+
3
+
4
+
5
+
6
6
  import type { FileDiff } from '@deepseek-ai/dsh-tools';
7
- /** Context lines shown on each side of an applied hunk. */
7
+
8
8
  export declare const DIFF_CONTEXT = 3;
9
- /**
10
- * The `write`/`edit` tools' private `tool/result` `meta` payload: the applied
11
- * contextual-diff hunks, and for `write` whether the call created or updated
12
- * the file, which tells an empty hunk list of a create from one of an
13
- * unchanged overwrite. Attached opaquely (as `unknown`) on the tool result and
14
- * persisted with the session log — it must be JSON-serializable (the session
15
- * validates this at `append`), so `presentResult` reproduces the diff card on
16
- * replay. The producing tool owns and narrows this opaque shape.
17
- */
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
18
  export type FsDiffMeta = {
19
19
  diffs: FileDiff[];
20
20
  operation?: 'create' | 'update';
21
21
  };
22
- /**
23
- * Compute one {@link FileDiff} per hunk between `before` and `after`, each carrying the
24
- * applied change plus {@link DIFF_CONTEXT} context lines. Pure insertions use `oldText: null`,
25
- * patch-only no-newline markers are omitted, and scattered replacements remain separate hunks.
26
- *
27
- * @param path - the path stamped on every produced diff (the model-facing `file_path`; the
28
- * bridge relativizes it).
29
- * @param before - the file text before the change (the backend's LF-normalized diff basis).
30
- * @param after - the file text after the change, on the same basis.
31
- * @returns one diff per applied hunk, in file order; empty when the texts are identical.
32
- */
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
33
  export declare function computeHunkDiffs(path: string, before: string, after: string): FileDiff[];
34
- /**
35
- * Narrow opaque live or replayed result metadata to non-empty file diffs. Malformed metadata
36
- * returns `undefined` so presentation can fall back instead of throwing during replay.
37
- * @param meta - result metadata.
38
- * @returns validated hunks, or `undefined` for absent or malformed data.
39
- */
34
+
35
+
36
+
37
+
38
+
39
+
40
40
  export declare function diffsFromMeta(meta: unknown): FileDiff[] | undefined;
41
- //# sourceMappingURL=diff.d.ts.map
41
+
@@ -1,73 +1,73 @@
1
- /**
2
- * Model-facing literal edit, unique-match by default. It obtains an optional guard from the
3
- * single intent slot, calls `ctx.fs.editText` without a separate stat, then records the observed
4
- * version; no policy means an unconditional atomic edit. When the literal match fails or is
5
- * ambiguous, the `@deepseek-ai/dsh-fs-edit-repair` engine re-anchors the pair before the error
6
- * reaches the model.
7
- * @module @deepseek-ai/dsh-tool-fs/src/edit
8
- */
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
9
  import type { Context } from '@deepseek-ai/cordis';
10
10
  import type { Session } from '@deepseek-ai/dsh-session';
11
11
  import type { FsSandboxController } from './sandbox.ts';
12
- /** Repair tuning for failed `edit` matches; rules live in `@deepseek-ai/dsh-fs-edit-repair`. */
12
+
13
13
  export interface EditRepairConfig {
14
- /** Disable the repair engine so failed matches always error (default enabled). */
14
+
15
15
  enabled?: boolean;
16
- /** Content length above which the line-window repair rules are skipped. */
16
+
17
17
  maxFileChars?: number;
18
- /** `old_string` line count above which the line-window repair rules are skipped. */
18
+
19
19
  maxWindowLines?: number;
20
20
  }
21
- /**
22
- * The edit repair tuning after defaulting, plus the session path-history
23
- * source for missing-target re-anchoring.
24
- */
21
+
22
+
23
+
24
+
25
25
  export interface EditRepairTuning {
26
- /** Master switch: failed-match repair and missing-path re-anchoring. */
26
+
27
27
  enabled: boolean;
28
- /** Content length above which the line-window repair rules are skipped. */
28
+
29
29
  maxFileChars: number;
30
- /** `old_string` line count above which the line-window repair rules are skipped. */
30
+
31
31
  maxWindowLines: number;
32
- /**
33
- * Absolute path arguments of the session's prior successful tool calls, most
34
- * recent first — the missing-path re-anchor's history source.
35
- */
32
+
33
+
34
+
35
+
36
36
  priorPaths(session: Session | undefined, limit?: number): string[];
37
37
  }
38
- /** Validated `edit` arguments after defaulting. */
38
+
39
39
  interface EditInput {
40
40
  filePath: string;
41
41
  oldString: string;
42
42
  newString: string;
43
43
  replaceAll: boolean;
44
44
  }
45
- /**
46
- * Validate value constraints the schema DSL can't express: a non-blank
47
- * `file_path`, a non-empty `old_string`, and `old_string !== new_string`
48
- * (an equal pair would be a guaranteed no-op edit).
49
- * @param args - the schema-validated raw tool arguments.
50
- * @returns the camelCased input with `replace_all` defaulted to false.
51
- */
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
52
  export declare function parseEditArgs(args: {
53
53
  file_path: string;
54
54
  old_string: string;
55
55
  new_string: string;
56
56
  replace_all?: boolean;
57
57
  }): EditInput;
58
- /**
59
- * Format an edit success (single-match or replace-all) as a Claude-style model-facing message.
60
- * @param displayPath - the backend-resolved path shown to the model.
61
- * @param replaceAll - selects the all-occurrences wording over the single-replacement one.
62
- * @returns the confirmation sentence the model sees as the tool result.
63
- */
58
+
59
+
60
+
61
+
62
+
63
+
64
64
  export declare function formatEditOutput(displayPath: string, replaceAll: boolean): string;
65
- /**
66
- * Register the `edit` tool and its scope-aware system-prompt guidance.
67
- * @param ctx - the plugin context; registrations are effects scoped to it, and execution uses its `fs` service.
68
- * @param sandbox - the shared sandbox-escalation API (advertisement, mode stamping, denial mapping).
69
- * @param repair - the resolved tuning for the failed-match repair engine and missing-path re-anchoring.
70
- */
65
+
66
+
67
+
68
+
69
+
70
+
71
71
  export declare function applyEditTool(ctx: Context, sandbox: FsSandboxController, repair: EditRepairTuning): void;
72
72
  export {};
73
- //# sourceMappingURL=edit.d.ts.map
73
+
@@ -1,19 +1,19 @@
1
- /**
2
- * Model-facing diagnostics for guarded-mutation failures. Providers and
3
- * policies retain operation-specific causes, while this package owns the
4
- * stable message shown to the model.
5
- * @module @deepseek-ai/dsh-tool-fs/src/error
6
- */
7
- /**
8
- * Render the stable model-facing diagnostic for a guarded-mutation failure.
9
- * `FS_STALE_VERSION` keeps the provider's reason and appends its re-read
10
- * remedy. `FS_NOT_OBSERVED` replaces operation-specific policy/provider text
11
- * with one path-aware reason and read remedy. The original error remains the
12
- * cause, and both diagnostics preserve its code for machine routing. Anything
13
- * else passes through untouched.
14
- * @param error - the caught value from a write/edit execution.
15
- * @param displayPath - the resolved target path shown to the model.
16
- * @returns a remediated `FsError` for the two guarded-mutation codes, else the original value.
17
- */
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
18
  export declare function remediateFsError(error: unknown, displayPath: string): unknown;
19
- //# sourceMappingURL=error.d.ts.map
19
+
@@ -1,36 +1,36 @@
1
- /**
2
- * Model-facing read, read_image, write, and edit tools over `ctx.fs`. This package owns schemas, validation,
3
- * read windows, formatting, and observation events, never a concrete provider. An optional
4
- * event policy supplies mutation guards; without one the tools use unconditional provider calls.
5
- * @module @deepseek-ai/dsh-tool-fs
6
- */
1
+
2
+
3
+
4
+
5
+
6
+
7
7
  import type { Context } from '@deepseek-ai/cordis';
8
8
  import z from '@deepseek-ai/schemastery';
9
9
  import type { ReadRepairConfig } from './read.ts';
10
10
  import type { WriteRepairConfig } from './write.ts';
11
11
  import type { EditRepairConfig } from './edit.ts';
12
- /** Cordis plugin name used by loader diagnostics. */
12
+
13
13
  export declare const name = "tool-fs";
14
- /** Services required by the filesystem tool suite. */
14
+
15
15
  export declare const inject: string[];
16
- /** Plugin config (all optional — `Config` supplies the defaults). */
16
+
17
17
  export interface Config {
18
- /** Default and maximum number of lines returned by one `read` call. */
18
+
19
19
  readLimit?: number;
20
- /** Maximum characters returned for a single line before truncation. */
20
+
21
21
  readMaxLineLength?: number;
22
- /** Maximum bytes returned for the selected lines of one `read` call. */
22
+
23
23
  readMaxBytes?: number;
24
- /** Files at or above this size stream instead of loading whole into memory. */
24
+
25
25
  readStreamMinSize?: number;
26
- /** Repair tuning applied when `edit`'s `old_string` fails to match verbatim (enabled by default). */
26
+
27
27
  editRepair?: EditRepairConfig;
28
- /** Repair tuning for the `read` tool's addressing and path failures (enabled by default). */
28
+
29
29
  readRepair?: ReadRepairConfig;
30
- /** Tuning for the `write` tool's drifted-path hint on creates (enabled by default). */
30
+
31
31
  writeRepair?: WriteRepairConfig;
32
32
  }
33
33
  export declare const Config: z<Config>;
34
- /** Register the full `read`/`write`/`edit` filesystem tool suite, plus `read_image` while `attachments` is mounted. */
34
+
35
35
  export declare function apply(ctx: Context, config: Config): void;
36
- //# sourceMappingURL=index.d.ts.map
36
+
@@ -1,25 +1,25 @@
1
- /**
2
- * The model-facing `read_image` tool commits a PNG/JPEG/WebP/GIF file. A path
3
- * without a file extension is identified from its file signature, while the
4
- * attachment service's full decode stays authoritative. The mounted `ctx.fs`
5
- * backend owns path resolution and read access; names only declare media type.
6
- *
7
- * The route gate is deliberately stricter than the host upload preflight. An
8
- * image-reading tool is useful only when the exact calling route can inspect
9
- * its result, so unknown capability refuses instead of relying on an adapter
10
- * failure after filesystem and attachment work.
11
- * @module @deepseek-ai/dsh-tool-fs/src/read-image
12
- */
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
13
  import type { Context } from '@deepseek-ai/cordis';
14
14
  import type { ImageAttachmentRef, ImageMediaType } from '@deepseek-ai/dsh-attachment';
15
15
  import type { ToolExecution } from '@deepseek-ai/dsh-tools';
16
- /**
17
- * Identify the media type declared by a supported image file signature.
18
- * @param data - file bytes read through the current filesystem backend.
19
- * @returns the detected supported media type, or undefined for other bytes.
20
- */
16
+
17
+
18
+
19
+
20
+
21
21
  export declare function sniffImageMediaType(data: Uint8Array): ImageMediaType | undefined;
22
- /** The structured outcome declared by the `read_image` output schema. */
22
+
23
23
  export interface ImageReadValue {
24
24
  path: string;
25
25
  image: {
@@ -29,52 +29,52 @@ export interface ImageReadValue {
29
29
  width: number;
30
30
  height: number;
31
31
  name?: string;
32
- /** Orientation-applied file dimensions before normalization; present only when storage reduced it. */
32
+
33
33
  originalDimensions?: {
34
34
  width: number;
35
35
  height: number;
36
36
  };
37
37
  };
38
38
  }
39
- /**
40
- * Map a model-supplied path to its declared image media type by extension.
41
- * @param filePath - the raw `file_path` argument (not yet resolved).
42
- * @returns the declared media type, or undefined when the path does not claim an image.
43
- */
39
+
40
+
41
+
42
+
43
+
44
44
  export declare function imageMediaTypeForPath(filePath: string): ImageMediaType | undefined;
45
- /**
46
- * Enforce the strict image-capability gate for the calling route. Resolves the
47
- * session's latest routed provider/model (request header config, then agent
48
- * options) and requires the exact resolved route to declare `image` input explicitly.
49
- * @param ctx - the plugin context used to resolve the optional `llm` service.
50
- * @param exec - the tool-execution context supplying the calling agent.
51
- * @param requestedPath - the raw, not-yet-resolved path rendered in refusal messages.
52
- */
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
53
  export declare function assertImageCapableRoute(ctx: Context, exec: ToolExecution, requestedPath: string): Promise<void>;
54
- /**
55
- * Re-brand a structured image outcome into the durable attachment reference an
56
- * `ImageBlock` carries.
57
- * @param image - the image metadata from the output schema.
58
- * @returns the branded attachment reference.
59
- */
54
+
55
+
56
+
57
+
58
+
59
+
60
60
  export declare function imageRefFromValue(image: ImageReadValue['image']): ImageAttachmentRef;
61
- /**
62
- * Format an image read as the model-facing envelope beside its image block.
63
- * A downscaled read names the on-disk dimensions and the multiplier that maps
64
- * coordinates measured on the attached image back onto the original file.
65
- * @param displayPath - the backend-resolved path rendered in the envelope's `<path>` element.
66
- * @param image - the image metadata to summarize.
67
- * @returns the model-facing envelope; the image itself rides the adjacent image block.
68
- */
61
+
62
+
63
+
64
+
65
+
66
+
67
+
68
+
69
69
  export declare function formatImageReadOutput(displayPath: string, image: ImageReadValue['image']): string;
70
- /**
71
- * Register the `read_image` tool into the given context. The composing plugin
72
- * owns the attachments gate: `src/index.ts` calls this inside
73
- * `ctx.inject(['attachments'], …)` so the tool exists only while a durable
74
- * store is mounted. Execution still re-checks `ctx.get('attachments')` for
75
- * direct callers and gates on the calling route's declared image input.
76
- * @param ctx - the registration scope; execution uses its `fs` service plus
77
- * the optional `attachments`/`llm` services.
78
- */
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
79
  export declare function applyReadImageTool(ctx: Context): void;
80
- //# sourceMappingURL=read-image.d.ts.map
80
+