opencode-fs-plugin 3.3.0 → 3.5.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/src/index.ts CHANGED
@@ -12,7 +12,6 @@ import { JobManager } from "./core/jobs.js";
12
12
  import { PermissionGate, type PermissionAssert } from "./core/permissions.js";
13
13
  import { clampConcurrency } from "./core/parallel.js";
14
14
  import { Sandbox } from "./core/sandbox.js";
15
- import { spillResult } from "./core/spill.js";
16
15
  import { parseSchema } from "./core/schema.js";
17
16
  import type { ToolSpec } from "./core/types.js";
18
17
  import { arTool } from "./tools/ar.js";
@@ -21,8 +20,10 @@ import { catTool } from "./tools/cat.js";
21
20
  import { chmodTool } from "./tools/chmod.js";
22
21
  import { chownTool } from "./tools/chown.js";
23
22
  import { commTool } from "./tools/comm.js";
23
+ import { commandTool } from "./tools/command.js";
24
24
  import { cpTool } from "./tools/cp.js";
25
25
  import { cpioTool } from "./tools/cpio.js";
26
+ import { curlTool } from "./tools/curl.js";
26
27
  import { cutTool } from "./tools/cut.js";
27
28
  import { dateTool } from "./tools/date.js";
28
29
  import { ddTool } from "./tools/dd.js";
@@ -31,18 +32,12 @@ import { diffTool } from "./tools/diff.js";
31
32
  import { duTool } from "./tools/du.js";
32
33
  import { fileTool } from "./tools/file.js";
33
34
  import { findTool } from "./tools/find.js";
34
- import {
35
- execTool,
36
- normalizeExecAllowlist,
37
- normalizeExecNetworkMode,
38
- } from "./tools/exec.js";
39
35
  import { findmntTool } from "./tools/findmnt.js";
40
36
  import { foldTool } from "./tools/fold.js";
41
37
  import { grepTool } from "./tools/grep.js";
42
38
  import { gunzipTool, gzipTool } from "./tools/gzip.js";
43
39
  import { hashTool } from "./tools/hash.js";
44
40
  import { headTool } from "./tools/head.js";
45
- import { httpRequestTool } from "./tools/http_request.js";
46
41
  import { idTool } from "./tools/id.js";
47
42
  import { killTool } from "./tools/kill.js";
48
43
  import { lnTool } from "./tools/ln.js";
@@ -85,70 +80,70 @@ import { unzipTool, zipTool } from "./tools/zip.js";
85
80
  type AnyTool = ToolSpec<any>;
86
81
 
87
82
  const TOOLS: readonly AnyTool[] = [
88
- mkdirTool,
89
- rmdirTool,
90
- rmTool,
91
- cpTool,
92
- mvTool,
93
- lsTool,
94
- statTool,
95
- touchTool,
96
- truncateTool,
97
- lnTool,
98
- readlinkTool,
83
+ arTool,
84
+ base64Tool,
85
+ catTool,
99
86
  chmodTool,
100
- hashTool,
101
- duTool,
87
+ chownTool,
88
+ commTool,
89
+ commandTool,
90
+ cpTool,
91
+ cpioTool,
92
+ curlTool,
93
+ cutTool,
94
+ dateTool,
95
+ ddTool,
102
96
  dfTool,
97
+ diffTool,
98
+ duTool,
99
+ fileTool,
103
100
  findTool,
104
- mktempTool,
105
- trashTool,
106
- gzipTool,
101
+ findmntTool,
102
+ foldTool,
103
+ grepTool,
107
104
  gunzipTool,
108
- tarTool,
109
- zipTool,
110
- unzipTool,
111
- diffTool,
112
- catTool,
105
+ gzipTool,
106
+ hashTool,
113
107
  headTool,
114
- tailTool,
115
- teeTool,
116
- httpRequestTool,
117
- psTool,
118
- pgrepTool,
119
- killTool,
120
- fileTool,
121
- base64Tool,
122
- odTool,
123
- stringsTool,
124
108
  idTool,
125
- unameTool,
126
- uptimeTool,
127
- dateTool,
128
- findmntTool,
109
+ killTool,
110
+ lnTool,
111
+ lsTool,
112
+ mkdirTool,
113
+ mktempTool,
129
114
  mountpointTool,
130
- tacTool,
131
- revTool,
115
+ mvTool,
132
116
  nlTool,
117
+ odTool,
133
118
  pasteTool,
134
- commTool,
135
- splitTool,
119
+ pgrepTool,
120
+ pipeTool,
121
+ psTool,
122
+ readlinkTool,
123
+ revTool,
124
+ rmTool,
125
+ rmdirTool,
126
+ sedTool,
136
127
  shufTool,
137
- foldTool,
138
- chownTool,
139
- syncTool,
140
- ddTool,
141
- cpioTool,
142
- arTool,
143
- wcTool,
144
128
  sortTool,
145
- uniqTool,
146
- cutTool,
129
+ splitTool,
130
+ statTool,
131
+ stringsTool,
132
+ syncTool,
133
+ tacTool,
134
+ tailTool,
135
+ tarTool,
136
+ teeTool,
137
+ touchTool,
147
138
  trTool,
148
- sedTool,
149
- grepTool,
150
- execTool,
151
- pipeTool,
139
+ trashTool,
140
+ truncateTool,
141
+ unameTool,
142
+ uniqTool,
143
+ unzipTool,
144
+ uptimeTool,
145
+ wcTool,
146
+ zipTool,
152
147
  ];
153
148
 
154
149
  function withBackground(schema: TSchema): TSchema {
@@ -200,8 +195,6 @@ export default Plugin.define({
200
195
  const concurrency = clampConcurrency(
201
196
  typeof ctx.options?.concurrency === "number" ? ctx.options.concurrency : undefined,
202
197
  );
203
- const execAllowlist = normalizeExecAllowlist(ctx.options?.execAllowlist);
204
- const execNetworkMode = normalizeExecNetworkMode(ctx.options?.execNetworkMode);
205
198
  const jobs = new JobManager(
206
199
  typeof ctx.options?.jobDir === "string" ? { dir: ctx.options.jobDir } : {},
207
200
  );
@@ -249,13 +242,11 @@ export default Plugin.define({
249
242
  concurrency,
250
243
  signal,
251
244
  tmpdir: os.tmpdir(),
252
- execAllowlist,
253
- execNetworkMode,
254
245
  },
255
246
  parsed,
256
247
  {},
257
248
  );
258
- return renderResult(await spillResult(result, spec.name, os.tmpdir()));
249
+ return renderResult(result);
259
250
  };
260
251
 
261
252
  if ((parsed as { background?: unknown }).background === true) {
package/src/tools/cat.ts CHANGED
@@ -5,9 +5,8 @@
5
5
 
6
6
  import { Type, type Static } from "@sinclair/typebox";
7
7
  import { pathsFrom } from "../core/aliases.js";
8
- import { SpillSink, spillDirectory } from "../core/spill.js";
9
- import { inputStream, lines } from "../core/stream.js";
10
- import type { ToolSpec } from "../core/types.js";
8
+ import { collect, inputStream, lines } from "../core/stream.js";
9
+ import { textResult, type ToolSpec } from "../core/types.js";
11
10
 
12
11
  const Schema = Type.Object(
13
12
  {
@@ -36,52 +35,38 @@ export const catTool: ToolSpec<Input> = {
36
35
  const paths = pathsFrom(input) ?? [];
37
36
  const targets = await resolvePaths(ctx, paths);
38
37
  const stream = inputStream(targets.map((entry) => entry.full), io.stdin);
39
- const sink = new SpillSink(spillDirectory(ctx.tmpdir), "cat", io.piped === true);
40
- try {
41
- if (
42
- input.number !== true &&
43
- input.numberNonBlank !== true &&
44
- input.squeezeBlank !== true &&
45
- input.showEnds !== true &&
46
- input.showTabs !== true &&
47
- input.showNonPrinting !== true
48
- ) {
49
- for await (const chunk of stream) await sink.write(chunk);
38
+ if (
39
+ input.number !== true &&
40
+ input.numberNonBlank !== true &&
41
+ input.squeezeBlank !== true &&
42
+ input.showEnds !== true &&
43
+ input.showTabs !== true &&
44
+ input.showNonPrinting !== true
45
+ ) {
46
+ return { stdout: await collect(stream), exitCode: 0, metadata: { paths } };
47
+ }
48
+
49
+ const output: string[] = [];
50
+ let number = 0;
51
+ let blank = false;
52
+ for await (const line of lines(stream)) {
53
+ if (input.squeezeBlank === true && line.text === "") {
54
+ if (blank) continue;
55
+ blank = true;
50
56
  } else {
51
- let number = 0;
52
- let blank = false;
53
- for await (const line of lines(stream)) {
54
- if (input.squeezeBlank === true && line.text === "") {
55
- if (blank) continue;
56
- blank = true;
57
- } else {
58
- blank = false;
59
- }
60
- let text = line.text;
61
- if (input.showTabs === true || input.showNonPrinting === true) text = text.replaceAll("\t", "^I");
62
- if (input.showNonPrinting === true) text = visible(text);
63
- if (input.showEnds === true) text += "$";
64
- if ((input.number === true || input.numberNonBlank === true) && (input.numberNonBlank !== true || text.length > 0)) {
65
- number++;
66
- text = `${String(number).padStart(6)} ${text}`;
67
- }
68
- await sink.write(Buffer.from(text + (line.newline ? "\n" : "")));
69
- }
57
+ blank = false;
58
+ }
59
+ let text = line.text;
60
+ if (input.showTabs === true || input.showNonPrinting === true) text = text.replaceAll("\t", "^I");
61
+ if (input.showNonPrinting === true) text = visible(text);
62
+ if (input.showEnds === true) text += "$";
63
+ if ((input.number === true || input.numberNonBlank === true) && (input.numberNonBlank !== true || text.length > 0)) {
64
+ number++;
65
+ text = `${String(number).padStart(6)} ${text}`;
70
66
  }
71
- const out = await sink.finish();
72
- return {
73
- stdout: out.preview,
74
- exitCode: 0,
75
- metadata: {
76
- paths,
77
- bytes: out.bytes,
78
- ...(out.path === undefined ? {} : { outputPath: out.path, spilled: true }),
79
- },
80
- };
81
- } catch (error) {
82
- await sink.abort();
83
- throw error;
67
+ output.push(text + (line.newline ? "\n" : ""));
84
68
  }
69
+ return textResult(output.join(""), { paths });
85
70
  },
86
71
  };
87
72