opc-agent 5.0.0-rc.21 → 5.0.0-rc.22
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/TASK.md +38 -42
- package/package.json +1 -1
package/TASK.md
CHANGED
|
@@ -1,42 +1,38 @@
|
|
|
1
|
-
# TASK
|
|
2
|
-
|
|
3
|
-
##
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
|
|
16
|
-
### 2.
|
|
17
|
-
`
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
- 每个功能改完后 `npx tsc --noEmit` 必须通过
|
|
40
|
-
- 不引入新依赖
|
|
41
|
-
- 每个功能完成后 `git add -A && git commit`
|
|
42
|
-
- 不修改测试文件(避免破坏现有测试)
|
|
1
|
+
# TASK: Add read_file + write_file builtin tools
|
|
2
|
+
|
|
3
|
+
## Goal
|
|
4
|
+
Add two new builtin tools so the Agent can read and write files on the local filesystem during conversations.
|
|
5
|
+
|
|
6
|
+
## Requirements
|
|
7
|
+
|
|
8
|
+
### 1. `read_file` tool (`src/tools/builtin/read-file.ts`)
|
|
9
|
+
- Parameters: `path` (string, required), `offset` (number, optional, line to start from), `limit` (number, optional, max lines)
|
|
10
|
+
- Returns file content as string
|
|
11
|
+
- Security: resolve path relative to agent workspace (cwd), reject `..` traversal outside workspace
|
|
12
|
+
- Handle errors gracefully (file not found, permission denied)
|
|
13
|
+
- For binary files, return a message saying "Binary file, cannot display"
|
|
14
|
+
- Max read size: 100KB, truncate with message if exceeded
|
|
15
|
+
|
|
16
|
+
### 2. `write_file` tool (`src/tools/builtin/write-file.ts`)
|
|
17
|
+
- Parameters: `path` (string, required), `content` (string, required), `append` (boolean, optional, default false)
|
|
18
|
+
- Creates parent directories automatically (`mkdirSync recursive`)
|
|
19
|
+
- Security: same path restriction as read_file
|
|
20
|
+
- Returns confirmation with bytes written and absolute path
|
|
21
|
+
|
|
22
|
+
### 3. Register both tools
|
|
23
|
+
- Add to the builtin tools registry (check how existing tools like `web_search.ts`, `execute_code.ts` are registered)
|
|
24
|
+
- Follow the exact same pattern/interface as existing builtin tools
|
|
25
|
+
|
|
26
|
+
### 4. Format
|
|
27
|
+
- Follow the existing builtin tool format in `src/tools/builtin/`
|
|
28
|
+
- Use `BuiltinTool` interface (or whatever interface the existing tools use)
|
|
29
|
+
- CommonJS compatible (module.exports or export)
|
|
30
|
+
|
|
31
|
+
## Constraints
|
|
32
|
+
- TypeScript, CommonJS (module: commonjs, target: ES2022)
|
|
33
|
+
- No new dependencies
|
|
34
|
+
- Must pass `npx tsc --noEmit`
|
|
35
|
+
|
|
36
|
+
## After completing
|
|
37
|
+
1. Run `npx tsc --noEmit` to verify
|
|
38
|
+
2. Run `git add -A && git commit -m "feat: read_file + write_file builtin tools"`
|