goke 6.8.0 → 6.10.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/dist/__test__/completions.test.d.ts +9 -0
- package/dist/__test__/completions.test.d.ts.map +1 -0
- package/dist/__test__/completions.test.js +774 -0
- package/dist/__test__/index.test.js +188 -0
- package/dist/__test__/just-bash.test.js +19 -0
- package/dist/__test__/readme-examples.test.js +141 -5
- package/dist/__test__/types.test-d.js +64 -0
- package/dist/agents.d.ts +38 -0
- package/dist/agents.d.ts.map +1 -0
- package/dist/agents.js +63 -0
- package/dist/completions.d.ts +88 -0
- package/dist/completions.d.ts.map +1 -0
- package/dist/completions.js +315 -0
- package/dist/goke.d.ts +115 -2
- package/dist/goke.d.ts.map +1 -1
- package/dist/goke.js +487 -25
- package/dist/index.d.ts +9 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -1
- package/dist/just-bash.d.ts +1 -1
- package/dist/just-bash.d.ts.map +1 -1
- package/dist/just-bash.js +80 -15
- package/dist/runtime-browser.d.ts +1 -1
- package/dist/runtime-browser.d.ts.map +1 -1
- package/dist/runtime-browser.js +1 -1
- package/dist/runtime-node.d.ts +1 -1
- package/dist/runtime-node.d.ts.map +1 -1
- package/dist/runtime-node.js +22 -13
- package/package.json +1 -1
- package/src/__test__/completions.test.ts +902 -0
- package/src/__test__/index.test.ts +241 -0
- package/src/__test__/just-bash.test.ts +24 -0
- package/src/__test__/readme-examples.test.ts +153 -5
- package/src/__test__/types.test-d.ts +68 -0
- package/src/agents.ts +101 -0
- package/src/completions.ts +363 -0
- package/src/goke.ts +564 -3
- package/src/index.ts +11 -2
- package/src/just-bash.ts +92 -18
- package/src/runtime-browser.ts +1 -1
- package/src/runtime-node.ts +19 -11
- package/README.md +0 -1254
package/dist/just-bash.js
CHANGED
|
@@ -8,14 +8,78 @@
|
|
|
8
8
|
import { Buffer } from 'node:buffer';
|
|
9
9
|
import { fileURLToPath } from 'node:url';
|
|
10
10
|
import { GokeProcessExit } from './goke.js';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
const TRUNCATION_MESSAGE = '\n[output truncated]\n';
|
|
12
|
+
function createTextCaptureStreams(maxLength) {
|
|
13
|
+
const stdoutChunks = [];
|
|
14
|
+
const stderrChunks = [];
|
|
15
|
+
const limit = maxLength != null && maxLength > 0 ? maxLength : Number.POSITIVE_INFINITY;
|
|
16
|
+
let totalLength = 0;
|
|
17
|
+
let stdoutTruncated = false;
|
|
18
|
+
let stderrTruncated = false;
|
|
19
|
+
const createStream = (stream) => ({
|
|
17
20
|
write(data) {
|
|
18
|
-
|
|
21
|
+
if (totalLength >= limit) {
|
|
22
|
+
if (stream === 'stdout') {
|
|
23
|
+
stdoutTruncated = true;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
stderrTruncated = true;
|
|
27
|
+
}
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const remaining = limit - totalLength;
|
|
31
|
+
const text = data.length <= remaining ? data : data.slice(0, remaining);
|
|
32
|
+
if (stream === 'stdout') {
|
|
33
|
+
stdoutChunks.push(text);
|
|
34
|
+
stdoutTruncated ||= text.length !== data.length;
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
stderrChunks.push(text);
|
|
38
|
+
stderrTruncated ||= text.length !== data.length;
|
|
39
|
+
}
|
|
40
|
+
totalLength += text.length;
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
const trimEnd = (value, count) => value.slice(0, Math.max(0, value.length - count));
|
|
44
|
+
return {
|
|
45
|
+
stdout: createStream('stdout'),
|
|
46
|
+
stderr: createStream('stderr'),
|
|
47
|
+
getResult() {
|
|
48
|
+
let stdout = stdoutChunks.join('');
|
|
49
|
+
let stderr = stderrChunks.join('');
|
|
50
|
+
if (!stdoutTruncated && !stderrTruncated) {
|
|
51
|
+
return { stdout, stderr };
|
|
52
|
+
}
|
|
53
|
+
const target = stderrTruncated ? 'stderr' : 'stdout';
|
|
54
|
+
const message = limit === Number.POSITIVE_INFINITY
|
|
55
|
+
? TRUNCATION_MESSAGE
|
|
56
|
+
: TRUNCATION_MESSAGE.slice(0, Math.min(TRUNCATION_MESSAGE.length, limit));
|
|
57
|
+
let overflow = stdout.length + stderr.length + message.length - limit;
|
|
58
|
+
if (Number.isFinite(limit) && overflow > 0) {
|
|
59
|
+
if (target === 'stderr') {
|
|
60
|
+
const stderrTrim = Math.min(overflow, stderr.length);
|
|
61
|
+
stderr = trimEnd(stderr, stderrTrim);
|
|
62
|
+
overflow -= stderrTrim;
|
|
63
|
+
if (overflow > 0) {
|
|
64
|
+
stdout = trimEnd(stdout, overflow);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
const stdoutTrim = Math.min(overflow, stdout.length);
|
|
69
|
+
stdout = trimEnd(stdout, stdoutTrim);
|
|
70
|
+
overflow -= stdoutTrim;
|
|
71
|
+
if (overflow > 0) {
|
|
72
|
+
stderr = trimEnd(stderr, overflow);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (target === 'stderr') {
|
|
77
|
+
stderr += message;
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
stdout += message;
|
|
81
|
+
}
|
|
82
|
+
return { stdout, stderr };
|
|
19
83
|
},
|
|
20
84
|
};
|
|
21
85
|
}
|
|
@@ -187,16 +251,15 @@ export function createJustBashCommand(cli, options) {
|
|
|
187
251
|
name,
|
|
188
252
|
trusted: true,
|
|
189
253
|
async execute(args, context) {
|
|
190
|
-
const
|
|
191
|
-
const stderr = createTextCaptureStream();
|
|
254
|
+
const output = createTextCaptureStreams(context?.limits?.maxOutputSize);
|
|
192
255
|
const argv = ['node', name, ...args];
|
|
193
256
|
const cloned = cli.clone({
|
|
194
257
|
cwd: context?.cwd,
|
|
195
258
|
env: context ? createJustBashEnvProxy(context.env) : cli.env,
|
|
196
259
|
fs: context ? createJustBashFs(context.fs, context.cwd) : cli.fs,
|
|
197
260
|
stdin: context?.stdin,
|
|
198
|
-
stdout,
|
|
199
|
-
stderr,
|
|
261
|
+
stdout: output.stdout,
|
|
262
|
+
stderr: output.stderr,
|
|
200
263
|
argv,
|
|
201
264
|
exit: (code) => {
|
|
202
265
|
throw new GokeProcessExit(code);
|
|
@@ -206,17 +269,19 @@ export function createJustBashCommand(cli, options) {
|
|
|
206
269
|
try {
|
|
207
270
|
cloned.parse(argv, { run: false });
|
|
208
271
|
await cloned.runMatchedCommand();
|
|
272
|
+
const result = output.getResult();
|
|
209
273
|
return {
|
|
210
|
-
stdout: stdout
|
|
211
|
-
stderr: stderr
|
|
274
|
+
stdout: result.stdout,
|
|
275
|
+
stderr: result.stderr,
|
|
212
276
|
exitCode: 0,
|
|
213
277
|
};
|
|
214
278
|
}
|
|
215
279
|
catch (error) {
|
|
216
280
|
if (error instanceof GokeProcessExit) {
|
|
281
|
+
const result = output.getResult();
|
|
217
282
|
return {
|
|
218
|
-
stdout: stdout
|
|
219
|
-
stderr: stderr
|
|
283
|
+
stdout: result.stdout,
|
|
284
|
+
stderr: result.stderr,
|
|
220
285
|
exitCode: error.code,
|
|
221
286
|
};
|
|
222
287
|
}
|
|
@@ -30,6 +30,6 @@ declare const process: {
|
|
|
30
30
|
exit(code: number): never;
|
|
31
31
|
};
|
|
32
32
|
declare const fs: GokeFs;
|
|
33
|
-
declare function openInBrowser(_url: string): void
|
|
33
|
+
declare function openInBrowser(_url: string): Promise<void>;
|
|
34
34
|
export { EventEmitter, fs, openInBrowser, process };
|
|
35
35
|
//# sourceMappingURL=runtime-browser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-browser.d.ts","sourceRoot":"","sources":["../src/runtime-browser.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAE1C,KAAK,QAAQ,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ED,iBAAe,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAExD;AAED,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,aAAa,EAAE,OAAO,EAAE,CAAA"}
|
package/dist/runtime-browser.js
CHANGED
|
@@ -68,7 +68,7 @@ const fs = {
|
|
|
68
68
|
utimes: createUnsupportedFsMethod('utimes'),
|
|
69
69
|
writeFile: createUnsupportedFsMethod('writeFile'),
|
|
70
70
|
};
|
|
71
|
-
function openInBrowser(_url) {
|
|
71
|
+
async function openInBrowser(_url) {
|
|
72
72
|
// Browser builds should decide how to surface URLs themselves.
|
|
73
73
|
}
|
|
74
74
|
export { EventEmitter, fs, openInBrowser, process };
|
package/dist/runtime-node.d.ts
CHANGED
|
@@ -5,6 +5,6 @@ import { EventEmitter } from 'events';
|
|
|
5
5
|
import type { GokeFs } from './goke-fs.js';
|
|
6
6
|
declare const process: NodeJS.Process;
|
|
7
7
|
declare const fs: GokeFs;
|
|
8
|
-
declare function openInBrowser(url: string): void
|
|
8
|
+
declare function openInBrowser(url: string): Promise<void>;
|
|
9
9
|
export { EventEmitter, fs, openInBrowser, process };
|
|
10
10
|
//# sourceMappingURL=runtime-node.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-node.d.ts","sourceRoot":"","sources":["../src/runtime-node.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAErC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAE1C,QAAA,MAAM,OAAO,gBAAqB,CAAA;AAClC,QAAA,MAAM,EAAE,EAAE,MAAe,CAAA;AAEzB,
|
|
1
|
+
{"version":3,"file":"runtime-node.d.ts","sourceRoot":"","sources":["../src/runtime-node.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAErC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAE1C,QAAA,MAAM,OAAO,gBAAqB,CAAA;AAClC,QAAA,MAAM,EAAE,EAAE,MAAe,CAAA;AAEzB,iBAAe,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAyBvD;AAED,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,aAAa,EAAE,OAAO,EAAE,CAAA"}
|
package/dist/runtime-node.js
CHANGED
|
@@ -1,29 +1,38 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Node.js runtime bindings for goke core.
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { exec } from 'child_process';
|
|
5
5
|
import { EventEmitter } from 'events';
|
|
6
6
|
import * as nodeFs from 'node:fs/promises';
|
|
7
7
|
const process = globalThis.process;
|
|
8
8
|
const fs = nodeFs;
|
|
9
|
-
function openInBrowser(url) {
|
|
9
|
+
async function openInBrowser(url) {
|
|
10
10
|
if (!process.stdout.isTTY) {
|
|
11
|
-
process.
|
|
11
|
+
process.stderr.write(url + '\n');
|
|
12
12
|
return;
|
|
13
13
|
}
|
|
14
|
+
let cmd;
|
|
15
|
+
if (process.platform === 'darwin') {
|
|
16
|
+
cmd = `open ${JSON.stringify(url)}`;
|
|
17
|
+
}
|
|
18
|
+
else if (process.platform === 'win32') {
|
|
19
|
+
cmd = `start "" ${JSON.stringify(url)}`;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
cmd = `xdg-open ${JSON.stringify(url)}`;
|
|
23
|
+
}
|
|
14
24
|
try {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
25
|
+
await new Promise((resolve, reject) => {
|
|
26
|
+
exec(cmd, { stdio: 'ignore' }, (err) => {
|
|
27
|
+
if (err)
|
|
28
|
+
reject(err);
|
|
29
|
+
else
|
|
30
|
+
resolve();
|
|
31
|
+
});
|
|
32
|
+
});
|
|
24
33
|
}
|
|
25
34
|
catch {
|
|
26
|
-
process.
|
|
35
|
+
process.stderr.write(url + '\n');
|
|
27
36
|
}
|
|
28
37
|
}
|
|
29
38
|
export { EventEmitter, fs, openInBrowser, process };
|