@deepseek-ai/dsh-tool-str-replace-editor 0.1.1-rc.2 → 0.1.2-alpha.2
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/README.i18n.yaml +2 -2
- package/README.md +105 -10
- package/README.zh.md +107 -12
- package/lib/index.js +20 -16
- package/package.json +22 -21
package/README.i18n.yaml
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
|
3
3
|
# after editing either side, bring the other along and re-record with:
|
|
4
4
|
# pnpm run verify-translation-pairing --write packages/fs/tool-str-replace-editor/README.md
|
|
5
|
-
README.md:
|
|
6
|
-
README.zh.md:
|
|
5
|
+
README.md: 950ad54b5724a25975b250c3f3e61daa834bec1f
|
|
6
|
+
README.zh.md: 97a5f22cc2563d3fed234971f18a301abd28ad5c
|
package/README.md
CHANGED
|
@@ -1,20 +1,100 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "The standalone str_replace_editor tool over ctx.fs for users and maintainers composing Claude-Code-style file editing for agents."
|
|
3
|
+
kind: "package-reference"
|
|
4
|
+
---
|
|
5
|
+
|
|
1
6
|
# @deepseek-ai/dsh-tool-str-replace-editor
|
|
2
7
|
|
|
3
8
|
English | [中文](README.zh.md)
|
|
4
9
|
|
|
5
|
-
|
|
10
|
+
## Summary
|
|
11
|
+
|
|
12
|
+
`dsh-tool-str-replace-editor` provides a standalone model-facing `str_replace_editor` tool over `ctx.fs`: `view` shows numbered file content or a shallow directory listing, `create` makes a new file, `str_replace` applies a unique literal replacement, and `insert` adds lines at a chosen boundary. It is composable with persistent Bash, one-shot Bash, sandboxed Bash, or another terminal surface. Mutations obey the same read-before-edit policy and sandbox fence as the rest of the fs family, enforced by whichever backend and policy plugins are mounted. Choose it when a deployment wants the Claude-Code-style single editor tool with absolute paths; the `dsh-tool-fs` package provides the alternative `read`/`write`/`edit` suite.
|
|
13
|
+
|
|
14
|
+
## Table of Contents
|
|
15
|
+
|
|
16
|
+
- [Use this package](#use-this-package)
|
|
17
|
+
- [Understand the implementation](#understand-the-implementation)
|
|
18
|
+
- [Further Exploration](#further-exploration)
|
|
19
|
+
- [Model Experience](#model-experience)
|
|
20
|
+
- [Known Limitations and Deferred Work](#known-limitations-and-deferred-work)
|
|
21
|
+
- [Dev Note](#dev-note)
|
|
22
|
+
|
|
23
|
+
-----
|
|
24
|
+
|
|
25
|
+
<a id="use-this-package"></a>
|
|
26
|
+
## Use this package
|
|
27
|
+
|
|
28
|
+
Mount the tool alongside a `ctx.fs` backend (and, for guarded mutations, the policy plugin) when the model should edit files through the familiar `view`/`create`/`str_replace`/`insert` command vocabulary on absolute paths.
|
|
29
|
+
|
|
30
|
+
### Minimal composition
|
|
31
|
+
|
|
32
|
+
A backend, optionally the policy plugin, then the tool; the editor composes with any terminal surface.
|
|
6
33
|
|
|
7
|
-
|
|
34
|
+
```yaml
|
|
35
|
+
- name: '@deepseek-ai/dsh-fs-local'
|
|
36
|
+
- name: '@deepseek-ai/dsh-fs-observation-policy'
|
|
37
|
+
- name: '@deepseek-ai/dsh-tool-str-replace-editor'
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Configuration
|
|
8
41
|
|
|
9
42
|
| Key | Default | Meaning |
|
|
10
|
-
|
|
11
|
-
| `maxOutputChars` | `16000` | Prefix characters retained for file and directory views
|
|
12
|
-
| `description` |
|
|
43
|
+
|---|---|---|
|
|
44
|
+
| `maxOutputChars` | `16000` | Prefix characters retained for file and directory views |
|
|
45
|
+
| `description` | `Custom editing tool for viewing, creating and editing files` (multi-line) | Model-facing tool description |
|
|
46
|
+
|
|
47
|
+
### The commands
|
|
48
|
+
|
|
49
|
+
`view` returns one-based numbered file content (tabs preserved, so displayed text stays valid literal replacement input) or a two-level directory listing that omits hidden, dependency, and Python-cache entries. `create` makes a new file and refuses to overwrite an existing one. Command-specific fields may contain `null` placeholders when the selected command does not use them; required fields stay required, `view_range: null` selects the full view, and `str_replace.new_str: null` is rejected so deletion requires omission. `str_replace` requires one unique literal match, with errors reported in the public `old_str` vocabulary; `insert` follows the selected zero-based insertion boundary without adding an implicit trailing newline. Mutations preserve tabs outside the requested edit.
|
|
50
|
+
|
|
51
|
+
### Failures and recovery
|
|
52
|
+
|
|
53
|
+
A metadata miss from `view`, `str_replace`, or `insert` records confirmed absence before returning `FS_NOT_FOUND`, so a later `create` can recover an externally deleted path through the mounted policy's guarded-create flow; absence never authorizes `str_replace` or `insert`. Guarded mutations inherit the policy plugin's codes and remedies — `FS_NOT_OBSERVED` (read the file, then retry), `FS_STALE_VERSION` (re-read, then retry) — and sandbox denials surface as the `[sandbox: file access denied under <mode> mode]` marker. Paths must be absolute; a relative path is refused with a hint.
|
|
54
|
+
|
|
55
|
+
-----
|
|
56
|
+
|
|
57
|
+
<a id="understand-the-implementation"></a>
|
|
58
|
+
## Understand the implementation
|
|
59
|
+
|
|
60
|
+
<details>
|
|
61
|
+
<summary>Implementation internals — click to expand</summary>
|
|
62
|
+
|
|
63
|
+
This section explains the design decisions behind the editor tool and points at the code that realizes them; the observable behavior is fully covered in [Use this package](#use-this-package).
|
|
13
64
|
|
|
14
|
-
|
|
65
|
+
### Design concept
|
|
15
66
|
|
|
16
|
-
The
|
|
67
|
+
The tool is one schema with four commands over `ctx.fs`. Mutations never touch the provider directly with their own assumptions: each one runs the `fs/write-intent` or `fs/edit-intent` waterfall to obtain the policy plugin's guard, resolves the per-call sandbox policy when the mounted `ctx.fs` confines, and delegates enforcement to the provider. `str_replace` and `insert` additionally re-read the file and use the observed version as the compare-and-swap basis when no policy plugin supplies a guard.
|
|
17
68
|
|
|
69
|
+
### Source map
|
|
70
|
+
|
|
71
|
+
| File | Role |
|
|
72
|
+
|---|---|
|
|
73
|
+
| [`src/index.ts`](src/index.ts) | The whole tool: schema, command dispatch, view rendering, mutation policy |
|
|
74
|
+
|
|
75
|
+
### How each command runs
|
|
76
|
+
|
|
77
|
+
Every command resolves the absolute path first; mutations then follow one shared flow — policy guard, provider enforcement, then an `fs/observed` record on success — while `view` only stats and renders. The entire tool — schema, command dispatch, and view rendering — lives in `src/index.ts`.
|
|
78
|
+
|
|
79
|
+
</details>
|
|
80
|
+
|
|
81
|
+
-----
|
|
82
|
+
|
|
83
|
+
<a id="further-exploration"></a>
|
|
84
|
+
## Further Exploration
|
|
85
|
+
|
|
86
|
+
Read these pages when the package-level contract is not enough. They move from the tool to the contract, policy, and backends it composes with.
|
|
87
|
+
|
|
88
|
+
- [Filesystem subsystem](../../../docs/subsystems/filesystem.md) — exhaustive provider contract, policy events, and error taxonomy.
|
|
89
|
+
- [dsh-fs](../fs/README.md) — the `ctx.fs` contract this tool consumes.
|
|
90
|
+
- [tool-fs](../tool-fs/README.md) — the alternative `read`/`write`/`edit` tool suite.
|
|
91
|
+
- [fs-observation-policy](../fs-observation-policy/README.md) — the policy plugin that guards mutations through the `fs/*` events.
|
|
92
|
+
- [fs-sandbox](../fs-sandbox/README.md) — the sandbox-enforcing backend that fences mutations.
|
|
93
|
+
- [Generated tool catalog](../../../docs/tool-catalog.md#deepseek-aidsh-tool-str-replace-editor) — the exhaustive schema this package registers.
|
|
94
|
+
|
|
95
|
+
-----
|
|
96
|
+
|
|
97
|
+
<a id="model-experience"></a>
|
|
18
98
|
## Model Experience
|
|
19
99
|
|
|
20
100
|
### Tool schema
|
|
@@ -47,6 +127,21 @@ Append-only tool results follow the reusable request prefix.
|
|
|
47
127
|
|
|
48
128
|
## Known Limitations and Deferred Work
|
|
49
129
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
130
|
+
<a id="known-limitations-and-deferred-work"></a>
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
These limits define when the editor tool is a poor fit or needs special operational care. They are current package constraints, not a general editor comparison or a task backlog.
|
|
134
|
+
|
|
135
|
+
- **Operations target UTF-8 text** — binary files are unsupported.
|
|
136
|
+
- **`str_replace` intentionally rejects zero or multiple matches** — it has no `replace_all` argument.
|
|
137
|
+
- **Every mutation goes through the mounted policy and sandbox** — `fs/write-intent` or `fs/edit-intent` resolves the current session sandbox policy and delegates enforcement to the mounted filesystem and policy plugins, so a deployment without them gets unconditional mutations.
|
|
138
|
+
|
|
139
|
+
<a id="dev-note"></a>
|
|
140
|
+
### Dev Note
|
|
141
|
+
|
|
142
|
+
<details>
|
|
143
|
+
<summary>Working context for maintainers — click to expand</summary>
|
|
144
|
+
|
|
145
|
+
None.
|
|
146
|
+
|
|
147
|
+
</details>
|
package/README.zh.md
CHANGED
|
@@ -1,27 +1,107 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "基于 `ctx.fs` 的独立 str_replace_editor 工具:供组合 Claude Code 风格文件编辑能力的用户与维护者使用。"
|
|
3
|
+
kind: "package-reference"
|
|
4
|
+
---
|
|
5
|
+
|
|
1
6
|
# @deepseek-ai/dsh-tool-str-replace-editor
|
|
2
7
|
|
|
3
8
|
[English](README.md) | 中文
|
|
4
9
|
|
|
5
|
-
|
|
10
|
+
## 概述
|
|
11
|
+
|
|
12
|
+
`dsh-tool-str-replace-editor` 提供基于 `ctx.fs` 的独立面向模型 `str_replace_editor` 工具:`view` 显示带行号的文件内容或浅层目录列表,`create` 创建新文件,`str_replace` 应用唯一的字面量替换,`insert` 在选定的边界处插入行。它可以与持久 Bash、一次性 Bash、沙箱 Bash 或其他终端接口组合。修改操作遵守与 fs 家族其余部分相同的编辑前读取策略与沙箱围栏,具体由所挂载的后端与策略插件强制执行。当部署需要 Claude Code 风格、使用绝对路径的单一编辑器工具时选择它;`dsh-tool-fs` 包提供替代的 `read`/`write`/`edit` 套件。
|
|
13
|
+
|
|
14
|
+
## 目录
|
|
15
|
+
|
|
16
|
+
- [使用本包](#use-this-package)
|
|
17
|
+
- [理解实现](#understand-the-implementation)
|
|
18
|
+
- [进一步探索](#further-exploration)
|
|
19
|
+
- [模型体验](#model-experience)
|
|
20
|
+
- [已知限制与延期工作](#known-limitations-and-deferred-work)
|
|
21
|
+
- [开发备注](#dev-note)
|
|
22
|
+
|
|
23
|
+
-----
|
|
24
|
+
|
|
25
|
+
<a id="use-this-package"></a>
|
|
26
|
+
## 使用本包
|
|
27
|
+
|
|
28
|
+
当模型应通过熟悉的 `view`/`create`/`str_replace`/`insert` 命令词汇在绝对路径上编辑文件时,把工具与 `ctx.fs` 后端(以及需要防护变更时的策略插件)一起挂载。
|
|
29
|
+
|
|
30
|
+
### 最小组合
|
|
31
|
+
|
|
32
|
+
一个后端、可选地加策略插件,然后是工具;编辑器可与任何终端接口组合。
|
|
6
33
|
|
|
7
|
-
|
|
34
|
+
```yaml
|
|
35
|
+
- name: '@deepseek-ai/dsh-fs-local'
|
|
36
|
+
- name: '@deepseek-ai/dsh-fs-observation-policy'
|
|
37
|
+
- name: '@deepseek-ai/dsh-tool-str-replace-editor'
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### 配置
|
|
8
41
|
|
|
9
42
|
| 键 | 默认值 | 含义 |
|
|
10
|
-
|
|
11
|
-
| `maxOutputChars` | `16000` |
|
|
12
|
-
| `description` |
|
|
43
|
+
|---|---|---|
|
|
44
|
+
| `maxOutputChars` | `16000` | 文件和目录查看结果保留的前缀字符数 |
|
|
45
|
+
| `description` | `Custom editing tool for viewing, creating and editing files`(多行) | 面向模型的工具描述 |
|
|
46
|
+
|
|
47
|
+
### 命令
|
|
48
|
+
|
|
49
|
+
`view` 返回从 1 开始编号的文件内容(保留制表符,因此显示的文本仍可作为有效的字面量替换输入)或忽略隐藏、依赖与 Python 缓存条目的两层目录列表。`create` 创建新文件,并拒绝覆盖现有文件。选定命令不使用的专用字段可以包含 `null` 占位符;必填字段仍保持必填,`view_range: null` 选择完整视图,`str_replace.new_str: null` 会被拒绝,因此删除内容必须省略该字段。`str_replace` 要求字面量唯一匹配,错误只使用公开的 `old_str` 词汇;`insert` 遵循所选的零基插入边界,不会隐式补尾换行。修改操作会保留请求编辑范围之外的制表符。
|
|
50
|
+
|
|
51
|
+
### 失败与恢复
|
|
52
|
+
|
|
53
|
+
`view`、`str_replace` 或 `insert` 发生元数据未命中时,工具会在返回 `FS_NOT_FOUND` 前记录确认缺失,因此后续 `create` 可以通过已挂载策略的防护创建流程恢复外部删除的路径;缺失状态绝不会授权 `str_replace` 或 `insert`。防护变更继承策略插件的错误码与恢复指令——`FS_NOT_OBSERVED`(先读取文件再重试)、`FS_STALE_VERSION`(先重新读取再重试)——沙箱拒绝则表现为 `[sandbox: file access denied under <mode> mode]` 标记。路径必须是绝对路径;相对路径会被拒绝并给出提示。
|
|
54
|
+
|
|
55
|
+
-----
|
|
56
|
+
|
|
57
|
+
<a id="understand-the-implementation"></a>
|
|
58
|
+
## 理解实现
|
|
59
|
+
|
|
60
|
+
<details>
|
|
61
|
+
<summary>实现细节——点击展开</summary>
|
|
62
|
+
|
|
63
|
+
本节解释编辑器工具背后的设计决策,并指出实现它们的代码位置;可观察行为已在[使用本包](#use-this-package)中完整说明。
|
|
13
64
|
|
|
14
|
-
|
|
65
|
+
### 设计理念
|
|
15
66
|
|
|
16
|
-
|
|
67
|
+
该工具是基于 `ctx.fs` 的单一 schema、四个命令。修改操作绝不带着自己的假设直接触碰提供方:每个操作都运行 `fs/write-intent` 或 `fs/edit-intent` waterfall 以取得策略插件的防护,在已挂载的 `ctx.fs` 实施沙箱限制时解析按调用沙箱策略,并把强制执行委托给提供方。`str_replace` 与 `insert` 还会重新读取文件,并在没有策略插件提供防护时把观察到的版本作为比较并交换的基础。
|
|
17
68
|
|
|
69
|
+
### 源码地图
|
|
70
|
+
|
|
71
|
+
| 文件 | 职责 |
|
|
72
|
+
|---|---|
|
|
73
|
+
| [`src/index.ts`](src/index.ts) | 整个工具:schema、命令分派、查看渲染、修改策略 |
|
|
74
|
+
|
|
75
|
+
### 各命令如何运行
|
|
76
|
+
|
|
77
|
+
每个命令都先解析绝对路径;修改操作随后遵循同一条共享流程——策略防护、提供方强制执行、成功后记录 `fs/observed`——而 `view` 只执行 stat 并渲染。整个工具——schema、命令分派与查看渲染——都位于 `src/index.ts`。
|
|
78
|
+
|
|
79
|
+
</details>
|
|
80
|
+
|
|
81
|
+
-----
|
|
82
|
+
|
|
83
|
+
<a id="further-exploration"></a>
|
|
84
|
+
## 进一步探索
|
|
85
|
+
|
|
86
|
+
当包级约定不够用时阅读以下页面。它们从工具逐步进入它所组合的约定、策略与后端。
|
|
87
|
+
|
|
88
|
+
- [文件系统子系统](../../../docs/subsystems/filesystem.zh.md)——穷尽式提供方约定、策略事件与错误分类体系。
|
|
89
|
+
- [dsh-fs](../fs/README.zh.md)——本工具消费的 `ctx.fs` 约定。
|
|
90
|
+
- [tool-fs](../tool-fs/README.zh.md)——替代的 `read`/`write`/`edit` 工具套件。
|
|
91
|
+
- [fs-observation-policy](../fs-observation-policy/README.zh.md)——通过 `fs/*` 事件防护变更的策略插件。
|
|
92
|
+
- [fs-sandbox](../fs-sandbox/README.zh.md)——围栏变更的沙箱强制后端。
|
|
93
|
+
- [生成工具目录](../../../docs/tool-catalog.zh.md#deepseek-aidsh-tool-str-replace-editor)——本包注册的穷尽式 schema。
|
|
94
|
+
|
|
95
|
+
-----
|
|
96
|
+
|
|
97
|
+
<a id="model-experience"></a>
|
|
18
98
|
## 模型体验
|
|
19
99
|
|
|
20
100
|
### 工具 schema
|
|
21
101
|
|
|
22
102
|
#### 模型看到的内容
|
|
23
103
|
|
|
24
|
-
生成的 [`str_replace_editor` schema](../../../docs/tool-catalog.zh.md#deepseek-aidsh-tool-str-replace-editor)
|
|
104
|
+
生成的 [`str_replace_editor` schema](../../../docs/tool-catalog.zh.md#deepseek-aidsh-tool-str-replace-editor),包含配置的 `description`。本插件不贡献独立系统提示词段。
|
|
25
105
|
|
|
26
106
|
#### Token 影响
|
|
27
107
|
|
|
@@ -45,8 +125,23 @@ schema 提供针对绝对路径的 `view`、`create`、`str_replace` 与 `insert
|
|
|
45
125
|
|
|
46
126
|
工具结果以追加方式位于可复用请求前缀之后。
|
|
47
127
|
|
|
48
|
-
##
|
|
128
|
+
## 已知限制与延期工作
|
|
129
|
+
|
|
130
|
+
<a id="known-limitations-and-deferred-work"></a>
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
这些限制说明编辑器工具何时不合适,或何时需要特别的运维注意。它们是当前包约束,不是通用编辑器对比或任务积压。
|
|
134
|
+
|
|
135
|
+
- **操作面向 UTF-8 文本**——不支持二进制文件。
|
|
136
|
+
- **`str_replace` 刻意拒绝零匹配或多匹配**——它没有 `replace_all` 参数。
|
|
137
|
+
- **每个修改操作都会经过已挂载的策略与沙箱**——`fs/write-intent` 或 `fs/edit-intent` 解析当前会话的沙箱策略,并把强制执行委托给已挂载的文件系统与策略插件,因此未挂载它们的部署会得到无条件变更。
|
|
138
|
+
|
|
139
|
+
<a id="dev-note"></a>
|
|
140
|
+
### 开发备注
|
|
141
|
+
|
|
142
|
+
<details>
|
|
143
|
+
<summary>维护者的工作上下文——点击展开</summary>
|
|
144
|
+
|
|
145
|
+
无。
|
|
49
146
|
|
|
50
|
-
|
|
51
|
-
- `str_replace` 刻意拒绝零匹配或多匹配,且没有 `replace_all` 参数。
|
|
52
|
-
- 每个修改操作都会经过 `fs/write-intent` 或 `fs/edit-intent`,解析当前会话的沙箱策略,并交由挂载的文件系统与策略插件实施约束。
|
|
147
|
+
</details>
|
package/lib/index.js
CHANGED
|
@@ -15,6 +15,7 @@ Custom editing tool for viewing, creating and editing files
|
|
|
15
15
|
* If \`path\` is a file, \`view\` displays the result of applying \`cat -n\`. If \`path\` is a directory, \`view\` lists non-hidden files and directories up to 2 levels deep
|
|
16
16
|
* The \`create\` command cannot be used if the specified \`path\` already exists as a file
|
|
17
17
|
* If a \`command\` generates a long output, it will be truncated and marked with \`<response clipped>\`
|
|
18
|
+
* A null placeholder for a parameter unused by the selected command is treated as omitted. Required parameters still need values; omit \`str_replace.new_str\` rather than setting it to null when deleting a match
|
|
18
19
|
|
|
19
20
|
Notes for using the \`str_replace\` command:
|
|
20
21
|
* The \`old_str\` parameter should match EXACTLY one or more consecutive lines from the original file. Be mindful of whitespaces!
|
|
@@ -154,6 +155,7 @@ async function createFile(ctx, policy, path, fileText, exec) {
|
|
|
154
155
|
return `New file created successfully at: ${target.displayPath}`;
|
|
155
156
|
}
|
|
156
157
|
async function replaceInFile(ctx, policy, path, oldStr, newStr, exec) {
|
|
158
|
+
if (newStr === null) throw new Error("Parameter `new_str` must be omitted or contain a string for command: str_replace");
|
|
157
159
|
const sandboxPolicy = policy.resolve(exec);
|
|
158
160
|
const target = await resolveTarget(ctx, path, exec.signal);
|
|
159
161
|
const intent = await ctx.waterfall("fs/edit-intent", target, exec, () => void 0);
|
|
@@ -252,7 +254,7 @@ function presentEditorCall(args) {
|
|
|
252
254
|
kind: "edit",
|
|
253
255
|
locations: [{
|
|
254
256
|
path: args.path,
|
|
255
|
-
...args.insert_line === void 0 ? {} : { line: Math.max(1, args.insert_line + 1) }
|
|
257
|
+
...args.insert_line === void 0 || args.insert_line === null ? {} : { line: Math.max(1, args.insert_line + 1) }
|
|
256
258
|
}]
|
|
257
259
|
};
|
|
258
260
|
}
|
|
@@ -281,25 +283,27 @@ function registerStrReplaceEditor(ctx, config) {
|
|
|
281
283
|
description: "Absolute path to file or directory, e.g. `/repo/file.py` or `/repo`."
|
|
282
284
|
},
|
|
283
285
|
file_text: {
|
|
284
|
-
type: "string",
|
|
285
|
-
description: "Required parameter of `create` command, with the content of the file to be created."
|
|
286
|
+
oneOf: [{ type: "string" }, { type: "null" }],
|
|
287
|
+
description: "Required string parameter of `create` command, with the content of the file to be created. A null placeholder is treated as omitted by commands that do not use this parameter."
|
|
286
288
|
},
|
|
287
289
|
insert_line: {
|
|
288
|
-
type: "integer",
|
|
289
|
-
description: "Required parameter of `insert` command. The `new_str` will be inserted AFTER the line `insert_line` of `path`."
|
|
290
|
+
oneOf: [{ type: "integer" }, { type: "null" }],
|
|
291
|
+
description: "Required integer parameter of `insert` command. The `new_str` will be inserted AFTER the line `insert_line` of `path`. A null placeholder is treated as omitted by commands that do not use this parameter."
|
|
290
292
|
},
|
|
291
293
|
new_str: {
|
|
292
|
-
type: "string",
|
|
293
|
-
description: "Optional parameter of `str_replace` command containing the new string (if
|
|
294
|
+
oneOf: [{ type: "string" }, { type: "null" }],
|
|
295
|
+
description: "Optional string parameter of `str_replace` command containing the new string (if omitted, no string will be added). Required string parameter of `insert` command containing the string to insert. A null placeholder is accepted only by commands that do not use this parameter."
|
|
294
296
|
},
|
|
295
297
|
old_str: {
|
|
296
|
-
type: "string",
|
|
297
|
-
description: "Required parameter of `str_replace` command containing the string in `path` to replace."
|
|
298
|
+
oneOf: [{ type: "string" }, { type: "null" }],
|
|
299
|
+
description: "Required string parameter of `str_replace` command containing the string in `path` to replace. A null placeholder is treated as omitted by commands that do not use this parameter."
|
|
298
300
|
},
|
|
299
301
|
view_range: {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
302
|
+
oneOf: [{
|
|
303
|
+
type: "array",
|
|
304
|
+
items: { type: "integer" }
|
|
305
|
+
}, { type: "null" }],
|
|
306
|
+
description: "Optional parameter of `view` command when `path` points to a file. If omitted or null, the full file is shown. If provided, the file will be shown in the indicated line number range, e.g. [11, 12] will show lines 11 and 12. Indexing at 1 to start. Setting `[start_line, -1]` shows all lines from `start_line` to the end of the file."
|
|
303
307
|
}
|
|
304
308
|
},
|
|
305
309
|
output: {
|
|
@@ -311,10 +315,10 @@ function registerStrReplaceEditor(ctx, config) {
|
|
|
311
315
|
},
|
|
312
316
|
async execute(args, exec) {
|
|
313
317
|
switch (args.command) {
|
|
314
|
-
case "view": return viewPath(ctx, args.path, args.view_range, config.maxOutputChars, exec);
|
|
315
|
-
case "create": return createFile(ctx, policy, args.path, args.file_text, exec);
|
|
316
|
-
case "str_replace": return replaceInFile(ctx, policy, args.path, args.old_str, args.new_str, exec);
|
|
317
|
-
case "insert": return insertInFile(ctx, policy, args.path, args.insert_line, args.new_str, exec);
|
|
318
|
+
case "view": return viewPath(ctx, args.path, args.view_range ?? void 0, config.maxOutputChars, exec);
|
|
319
|
+
case "create": return createFile(ctx, policy, args.path, args.file_text ?? void 0, exec);
|
|
320
|
+
case "str_replace": return replaceInFile(ctx, policy, args.path, args.old_str ?? void 0, args.new_str, exec);
|
|
321
|
+
case "insert": return insertInFile(ctx, policy, args.path, args.insert_line ?? void 0, args.new_str ?? void 0, exec);
|
|
318
322
|
}
|
|
319
323
|
},
|
|
320
324
|
presentCall: presentEditorCall
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepseek-ai/dsh-tool-str-replace-editor",
|
|
3
3
|
"description": "Model-facing view, create, literal replace, and line insert tool over the Harness filesystem service",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.2-alpha.2",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -31,29 +31,30 @@
|
|
|
31
31
|
],
|
|
32
32
|
"license": "MIT",
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"@deepseek-ai/dsh-fs": "^0.1.
|
|
35
|
-
"@deepseek-ai/dsh-invariants": "^0.1.
|
|
36
|
-
"@deepseek-ai/dsh-sandbox": "^0.1.
|
|
37
|
-
"@deepseek-ai/dsh-sandbox-policy": "^0.1.
|
|
38
|
-
"@deepseek-ai/dsh-tools": "^0.1.
|
|
39
|
-
"@deepseek-ai/cordis": "^4.0.
|
|
34
|
+
"@deepseek-ai/dsh-fs": "^0.1.2-alpha.2",
|
|
35
|
+
"@deepseek-ai/dsh-invariants": "^0.1.2-alpha.2",
|
|
36
|
+
"@deepseek-ai/dsh-sandbox": "^0.1.2-alpha.2",
|
|
37
|
+
"@deepseek-ai/dsh-sandbox-policy": "^0.1.2-alpha.2",
|
|
38
|
+
"@deepseek-ai/dsh-tools": "^0.1.2-alpha.2",
|
|
39
|
+
"@deepseek-ai/cordis": "^4.0.2"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@deepseek-ai/schemastery": "^3.18.
|
|
42
|
+
"@deepseek-ai/schemastery": "^3.18.2"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@deepseek-ai/dsh-agent": "^0.1.
|
|
46
|
-
"@deepseek-ai/dsh-fs": "^0.1.
|
|
47
|
-
"@deepseek-ai/dsh-fs-local": "^0.1.
|
|
48
|
-
"@deepseek-ai/dsh-fs-observation-policy": "^0.1.
|
|
49
|
-
"@deepseek-ai/dsh-fs-sandbox": "^0.1.
|
|
50
|
-
"@deepseek-ai/dsh-invariants": "^0.1.
|
|
51
|
-
"@deepseek-ai/dsh-llm": "^0.1.
|
|
52
|
-
"@deepseek-ai/dsh-sandbox": "^0.1.
|
|
53
|
-
"@deepseek-ai/dsh-sandbox-policy": "^0.1.
|
|
54
|
-
"@deepseek-ai/dsh-
|
|
55
|
-
"@deepseek-ai/dsh-
|
|
56
|
-
"@deepseek-ai/
|
|
57
|
-
"@deepseek-ai/
|
|
45
|
+
"@deepseek-ai/dsh-agent": "^0.1.2-alpha.2",
|
|
46
|
+
"@deepseek-ai/dsh-fs": "^0.1.2-alpha.2",
|
|
47
|
+
"@deepseek-ai/dsh-fs-local": "^0.1.2-alpha.2",
|
|
48
|
+
"@deepseek-ai/dsh-fs-observation-policy": "^0.1.2-alpha.2",
|
|
49
|
+
"@deepseek-ai/dsh-fs-sandbox": "^0.1.2-alpha.2",
|
|
50
|
+
"@deepseek-ai/dsh-invariants": "^0.1.2-alpha.2",
|
|
51
|
+
"@deepseek-ai/dsh-llm": "^0.1.2-alpha.2",
|
|
52
|
+
"@deepseek-ai/dsh-sandbox": "^0.1.2-alpha.2",
|
|
53
|
+
"@deepseek-ai/dsh-sandbox-policy": "^0.1.2-alpha.2",
|
|
54
|
+
"@deepseek-ai/dsh-system-prompt": "^0.1.2-alpha.2",
|
|
55
|
+
"@deepseek-ai/dsh-tools": "^0.1.2-alpha.2",
|
|
56
|
+
"@deepseek-ai/cordis": "^4.0.2",
|
|
57
|
+
"@deepseek-ai/dsh-session-projection": "^0.1.2-alpha.2",
|
|
58
|
+
"@deepseek-ai/dsh-session": "^0.1.2-alpha.2"
|
|
58
59
|
}
|
|
59
60
|
}
|