dsh-patch-edit-plus 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/CHANGELOG.md +16 -0
- package/CHANGELOG.zh.md +16 -0
- package/LICENSE +21 -0
- package/README.ja.md +124 -0
- package/README.ko.md +124 -0
- package/README.md +124 -0
- package/README.zh.md +123 -0
- package/assets/.gitkeep +0 -0
- package/cordis.patch.yml +6 -0
- package/dsh.plugin.json +21 -0
- package/lib/apply/engine.js +160 -0
- package/lib/apply/plan.js +79 -0
- package/lib/apply/seek.js +47 -0
- package/lib/config.js +45 -0
- package/lib/detect.js +29 -0
- package/lib/errors.js +125 -0
- package/lib/fsops.js +51 -0
- package/lib/index.js +39 -0
- package/lib/parse/codex.js +189 -0
- package/lib/parse/types.js +9 -0
- package/lib/parse/unified.js +243 -0
- package/lib/register.js +60 -0
- package/lib/shellops.js +111 -0
- package/lib/tool.js +208 -0
- package/lib/types/apply/engine.d.ts +39 -0
- package/lib/types/apply/plan.d.ts +31 -0
- package/lib/types/apply/seek.d.ts +21 -0
- package/lib/types/config.d.ts +66 -0
- package/lib/types/detect.d.ts +15 -0
- package/lib/types/errors.d.ts +79 -0
- package/lib/types/fsops.d.ts +28 -0
- package/lib/types/index.d.ts +23 -0
- package/lib/types/parse/codex.d.ts +28 -0
- package/lib/types/parse/types.d.ts +58 -0
- package/lib/types/parse/unified.d.ts +17 -0
- package/lib/types/register.d.ts +23 -0
- package/lib/types/shellops.d.ts +41 -0
- package/lib/types/tool.d.ts +46 -0
- package/package.json +103 -0
- package/screenshots.json +3 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shell seam for Delete / Move (the `ctx.fs` contract has no delete/rename).
|
|
3
|
+
*
|
|
4
|
+
* Security posture:
|
|
5
|
+
* - Command templates are CONSTANTS; paths travel only via the environment
|
|
6
|
+
* (`DSH_PATCH_SOURCE` / `DSH_PATCH_TARGET`), never interpolated into the
|
|
7
|
+
* command string — shell metacharacters in a path cannot inject commands.
|
|
8
|
+
* - Every run carries a `sandboxPolicy` so sandboxing executors fence it, and
|
|
9
|
+
* the reported `ShellSandboxInfo` distinguishes "policy denied" from
|
|
10
|
+
* "command failed".
|
|
11
|
+
* @module dsh-patch-edit-plus/shellops
|
|
12
|
+
*/
|
|
13
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
14
|
+
import type { ToolRunContext } from '@deepseek-ai/dsh-tools';
|
|
15
|
+
import type { FsTarget } from '@deepseek-ai/dsh-fs';
|
|
16
|
+
import type { SandboxExecutionPolicy } from '@deepseek-ai/dsh-sandbox';
|
|
17
|
+
import type { ShellExecutor } from '@deepseek-ai/dsh-shell';
|
|
18
|
+
import type { ResolvedConfig } from './config.js';
|
|
19
|
+
/** Constant POSIX templates; paths arrive via env, never via interpolation. */
|
|
20
|
+
export declare const POSIX_REMOVE = "rm -f -- \"$DSH_PATCH_TARGET\"";
|
|
21
|
+
export declare const POSIX_MOVE = "mv -f -- \"$DSH_PATCH_SOURCE\" \"$DSH_PATCH_TARGET\"";
|
|
22
|
+
/** Constant PowerShell templates (Windows default). */
|
|
23
|
+
export declare const PWSH_REMOVE = "Remove-Item -LiteralPath $env:DSH_PATCH_TARGET -Force";
|
|
24
|
+
export declare const PWSH_MOVE = "Move-Item -LiteralPath $env:DSH_PATCH_SOURCE -Destination $env:DSH_PATCH_TARGET -Force";
|
|
25
|
+
export type Dialect = 'posix' | 'pwsh';
|
|
26
|
+
/** Resolve the configured dialect; `auto` picks pwsh on win32, posix elsewhere. */
|
|
27
|
+
export declare function resolveDialect(cfg: ResolvedConfig): Dialect;
|
|
28
|
+
/** The constant delete template for the resolved dialect (config override wins). */
|
|
29
|
+
export declare function deleteTemplate(cfg: ResolvedConfig): string;
|
|
30
|
+
/** The constant move template for the resolved dialect (config override wins). */
|
|
31
|
+
export declare function moveTemplate(cfg: ResolvedConfig): string;
|
|
32
|
+
/** Structurally resolve `ctx.shell` without assuming the service is mounted. */
|
|
33
|
+
export declare function resolveShell(ctx: Context): ShellExecutor | undefined;
|
|
34
|
+
/** True when Delete/Move can run at all under the current configuration. */
|
|
35
|
+
export declare function shellReady(ctx: Context, cfg: ResolvedConfig): boolean;
|
|
36
|
+
/** Throw the precise structured UNSUPPORTED error when Delete/Move cannot run. */
|
|
37
|
+
export declare function assertShellReady(ctx: Context, cfg: ResolvedConfig): void;
|
|
38
|
+
/** Remove one file via the sandbox-aware shell. */
|
|
39
|
+
export declare function removeFile(ctx: Context, exec: ToolRunContext, cfg: ResolvedConfig, target: FsTarget, sandboxPolicy: SandboxExecutionPolicy | undefined): Promise<void>;
|
|
40
|
+
/** Move (rename) one file via the sandbox-aware shell. */
|
|
41
|
+
export declare function moveFile(ctx: Context, exec: ToolRunContext, cfg: ResolvedConfig, source: FsTarget, target: FsTarget, sandboxPolicy: SandboxExecutionPolicy | undefined): Promise<void>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The single model-facing `apply_patch` tool definition.
|
|
3
|
+
*
|
|
4
|
+
* The description carries an explicit routing guide so the model reaches for
|
|
5
|
+
* the native `edit` tool on cheap single-point changes instead of paying for
|
|
6
|
+
* a patch, and reserves `apply_patch` for large-file small edits, cross-file
|
|
7
|
+
* batch edits, creation, deletion and renames.
|
|
8
|
+
* @module dsh-patch-edit-plus/tool
|
|
9
|
+
*/
|
|
10
|
+
import type { ToolDefinition } from '@deepseek-ai/dsh-tools';
|
|
11
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
12
|
+
import type { ResolvedConfig } from './config.js';
|
|
13
|
+
import type { FileAction } from './parse/types.js';
|
|
14
|
+
/** Per-file diff carried in the canonical value (replay-safe presentationMeta source). */
|
|
15
|
+
export type ResultDiff = {
|
|
16
|
+
path: string;
|
|
17
|
+
oldText: string | null;
|
|
18
|
+
newText: string;
|
|
19
|
+
/** True when the diff was dropped because of `maxDiffBytes`. */
|
|
20
|
+
truncated?: boolean;
|
|
21
|
+
};
|
|
22
|
+
/** Canonical tool output value. */
|
|
23
|
+
export type ApplyPatchResult = {
|
|
24
|
+
format: 'unified' | 'codex';
|
|
25
|
+
applied: boolean;
|
|
26
|
+
summary: string;
|
|
27
|
+
files: {
|
|
28
|
+
path: string;
|
|
29
|
+
action: FileAction;
|
|
30
|
+
from?: string;
|
|
31
|
+
}[];
|
|
32
|
+
stats: {
|
|
33
|
+
files: number;
|
|
34
|
+
added: number;
|
|
35
|
+
removed: number;
|
|
36
|
+
};
|
|
37
|
+
wallTimeMs: number;
|
|
38
|
+
diffs: ResultDiff[];
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Build the (frozen) tool definition. The tool name is passed in resolved
|
|
42
|
+
* form so registration-side rename avoidance can mint variant names.
|
|
43
|
+
*/
|
|
44
|
+
export declare function buildApplyPatchTool(toolName: string, ctx: Context, cfg: ResolvedConfig): ToolDefinition;
|
|
45
|
+
/** Model-facing text: grouped added → modified → deleted listing. */
|
|
46
|
+
export declare function formatResultText(value: ApplyPatchResult): string;
|
package/package.json
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "dsh-patch-edit-plus",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Patch-style file editing for DeepSeek Harness: one apply_patch tool accepting git/unified diff (default) and Codex apply_patch syntax (opt-in), with all-or-nothing application, read-before-write intent dance, sandbox-aware delete/move, and 0.1.2-rc.1 ~ 0.1.5-rc.2 compatibility.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/drscrewdriver/dsh-patch-edit-plus.git"
|
|
9
|
+
},
|
|
10
|
+
"main": "lib/index.js",
|
|
11
|
+
"types": "lib/types/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./lib/types/index.d.ts",
|
|
15
|
+
"default": "./lib/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./package.json": "./package.json"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"lib/",
|
|
21
|
+
"cordis.patch.yml",
|
|
22
|
+
"dsh.plugin.json",
|
|
23
|
+
"screenshots.json",
|
|
24
|
+
"README.md",
|
|
25
|
+
"README.zh.md",
|
|
26
|
+
"CHANGELOG.md",
|
|
27
|
+
"CHANGELOG.zh.md",
|
|
28
|
+
"LICENSE",
|
|
29
|
+
"assets/"
|
|
30
|
+
],
|
|
31
|
+
"dsh": {
|
|
32
|
+
"bundle": {
|
|
33
|
+
"patch": "./cordis.patch.yml"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "tsc -p tsconfig.build.json",
|
|
38
|
+
"prepublishOnly": "npm run build",
|
|
39
|
+
"typecheck": "tsc -p tsconfig.json",
|
|
40
|
+
"typecheck:0.1.5": "node scripts/typecheck-0.1.5.mjs",
|
|
41
|
+
"lint": "eslint src tests scripts _smoke",
|
|
42
|
+
"lint:fix": "eslint src tests scripts _smoke --fix",
|
|
43
|
+
"test": "vitest run",
|
|
44
|
+
"verify:source": "node scripts/verify-source.mjs",
|
|
45
|
+
"smoke": "node _smoke/load-smoke.mjs",
|
|
46
|
+
"clean": "node -e \"require('node:fs').rmSync('lib', { recursive: true, force: true })\""
|
|
47
|
+
},
|
|
48
|
+
"engines": {
|
|
49
|
+
"node": ">=20",
|
|
50
|
+
"dsh": ">=0.1.2-rc.1 <0.2.0-0"
|
|
51
|
+
},
|
|
52
|
+
"license": "MIT",
|
|
53
|
+
"keywords": [
|
|
54
|
+
"dsh",
|
|
55
|
+
"dsh-plugin",
|
|
56
|
+
"deepseek-harness",
|
|
57
|
+
"apply-patch",
|
|
58
|
+
"unified-diff",
|
|
59
|
+
"codex",
|
|
60
|
+
"patch",
|
|
61
|
+
"edit"
|
|
62
|
+
],
|
|
63
|
+
"peerDependencies": {
|
|
64
|
+
"@deepseek-ai/cordis": "^4.0.1",
|
|
65
|
+
"@deepseek-ai/dsh-fs": ">=0.1.2-rc.1",
|
|
66
|
+
"@deepseek-ai/dsh-sandbox": ">=0.1.2-rc.1",
|
|
67
|
+
"@deepseek-ai/dsh-shell": ">=0.1.2-rc.1",
|
|
68
|
+
"@deepseek-ai/dsh-tools": ">=0.1.2-rc.1"
|
|
69
|
+
},
|
|
70
|
+
"peerDependenciesMeta": {
|
|
71
|
+
"@deepseek-ai/cordis": {
|
|
72
|
+
"optional": true
|
|
73
|
+
},
|
|
74
|
+
"@deepseek-ai/dsh-fs": {
|
|
75
|
+
"optional": true
|
|
76
|
+
},
|
|
77
|
+
"@deepseek-ai/dsh-sandbox": {
|
|
78
|
+
"optional": true
|
|
79
|
+
},
|
|
80
|
+
"@deepseek-ai/dsh-shell": {
|
|
81
|
+
"optional": true
|
|
82
|
+
},
|
|
83
|
+
"@deepseek-ai/dsh-tools": {
|
|
84
|
+
"optional": true
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
"dependencies": {
|
|
88
|
+
"@deepseek-ai/schemastery": "^3.18.2"
|
|
89
|
+
},
|
|
90
|
+
"devDependencies": {
|
|
91
|
+
"@deepseek-ai/cordis": "^4.0.2",
|
|
92
|
+
"@deepseek-ai/dsh-fs": "0.1.2-rc.1",
|
|
93
|
+
"@deepseek-ai/dsh-sandbox": "0.1.2-rc.1",
|
|
94
|
+
"@deepseek-ai/dsh-shell": "0.1.2-rc.1",
|
|
95
|
+
"@deepseek-ai/dsh-tools": "0.1.2-rc.1",
|
|
96
|
+
"@eslint/js": "^9.0.0",
|
|
97
|
+
"@types/node": "^22.0.0",
|
|
98
|
+
"eslint": "^9.0.0",
|
|
99
|
+
"typescript": "^5.6.0",
|
|
100
|
+
"typescript-eslint": "^8.0.0",
|
|
101
|
+
"vitest": "^3.0.0"
|
|
102
|
+
}
|
|
103
|
+
}
|
package/screenshots.json
ADDED