opencode-landstrip 0.3.4 → 0.3.6
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/index.ts +34 -13
- package/package.json +1 -1
- package/tui.ts +45 -13
package/index.ts
CHANGED
|
@@ -5,8 +5,6 @@ import type { Hooks, Plugin, PluginInput, PluginOptions } from '@opencode-ai/plu
|
|
|
5
5
|
|
|
6
6
|
import { binaryPath } from '@jarkkojs/landstrip';
|
|
7
7
|
|
|
8
|
-
export { tui } from './tui.js';
|
|
9
|
-
|
|
10
8
|
import { spawnSync } from 'node:child_process';
|
|
11
9
|
import {
|
|
12
10
|
existsSync,
|
|
@@ -478,7 +476,7 @@ function writePolicyFile(
|
|
|
478
476
|
baseDirectory: string,
|
|
479
477
|
proxyPort: number,
|
|
480
478
|
): { dir: string; path: string } {
|
|
481
|
-
const dir = mkdtempSync(join(tmpdir(), 'opencode-landstrip-'));
|
|
479
|
+
const dir = mkdtempSync(join(tmpdir(), 'opencode-landstrip-XXXXXX'));
|
|
482
480
|
const path = join(dir, 'policy.json');
|
|
483
481
|
writeFileSync(
|
|
484
482
|
path,
|
|
@@ -727,7 +725,7 @@ function assertApplyPatchAllowed(
|
|
|
727
725
|
assertWriteAllowed(path, config, baseDirectory);
|
|
728
726
|
}
|
|
729
727
|
|
|
730
|
-
|
|
728
|
+
const plugin: Plugin = async ({ client, directory }: PluginInput, options?: PluginOptions) => {
|
|
731
729
|
const optionOverrides = normalizeOptions(options);
|
|
732
730
|
const activeBash = new Map<string, BashSandboxState>();
|
|
733
731
|
const notified = new Set<string>();
|
|
@@ -735,6 +733,28 @@ export default (async ({ client, directory }: PluginInput, options?: PluginOptio
|
|
|
735
733
|
let configuredShell: string | undefined;
|
|
736
734
|
let landstripCheck: { ok: true; version: string } | { ok: false; reason: string } | undefined;
|
|
737
735
|
|
|
736
|
+
client.app
|
|
737
|
+
.log({
|
|
738
|
+
body: {
|
|
739
|
+
service: 'opencode-landstrip',
|
|
740
|
+
level: 'info',
|
|
741
|
+
message: `plugin loaded for ${directory}`,
|
|
742
|
+
},
|
|
743
|
+
query: { directory },
|
|
744
|
+
})
|
|
745
|
+
.catch(() => undefined);
|
|
746
|
+
|
|
747
|
+
client.tui
|
|
748
|
+
.showToast({
|
|
749
|
+
body: {
|
|
750
|
+
title: 'Sandbox',
|
|
751
|
+
message: `Loaded for ${directory}`,
|
|
752
|
+
variant: 'info',
|
|
753
|
+
duration: 5000,
|
|
754
|
+
},
|
|
755
|
+
})
|
|
756
|
+
.catch(() => undefined);
|
|
757
|
+
|
|
738
758
|
async function notifyOnce(key: string, message: string, variant: ToastVariant): Promise<void> {
|
|
739
759
|
if (notified.has(key)) return;
|
|
740
760
|
notified.add(key);
|
|
@@ -1009,17 +1029,16 @@ export default (async ({ client, directory }: PluginInput, options?: PluginOptio
|
|
|
1009
1029
|
},
|
|
1010
1030
|
|
|
1011
1031
|
'command.execute.before': async (input, output) => {
|
|
1012
|
-
if (input.command !== 'sandbox') return;
|
|
1032
|
+
if (input.command !== 'sandbox' && input.command !== '/sandbox') return;
|
|
1013
1033
|
|
|
1014
1034
|
const config = loadConfig(directory, optionOverrides);
|
|
1015
1035
|
const summary = buildConfigSummary(config);
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
});
|
|
1036
|
+
await client.tui
|
|
1037
|
+
.showToast({
|
|
1038
|
+
body: { title: 'Sandbox', message: summary, variant: 'info', duration: 15000 },
|
|
1039
|
+
query: { directory },
|
|
1040
|
+
})
|
|
1041
|
+
.catch(() => undefined);
|
|
1023
1042
|
},
|
|
1024
1043
|
|
|
1025
1044
|
dispose: async () => {
|
|
@@ -1028,4 +1047,6 @@ export default (async ({ client, directory }: PluginInput, options?: PluginOptio
|
|
|
1028
1047
|
};
|
|
1029
1048
|
|
|
1030
1049
|
return hooks;
|
|
1031
|
-
}
|
|
1050
|
+
};
|
|
1051
|
+
|
|
1052
|
+
export default plugin;
|
package/package.json
CHANGED
package/tui.ts
CHANGED
|
@@ -1,20 +1,52 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
// Copyright (C) Jarkko Sakkinen 2026
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
const tui = async (api: any) => {
|
|
5
|
+
try {
|
|
6
|
+
api.keymap.registerLayer({
|
|
7
|
+
commands: [
|
|
8
|
+
{
|
|
9
|
+
name: 'sandbox',
|
|
10
|
+
title: 'Sandbox',
|
|
11
|
+
description: 'Show sandbox configuration',
|
|
12
|
+
category: 'plugin',
|
|
13
|
+
slash: { name: 'sandbox' },
|
|
14
|
+
run: async () => {
|
|
15
|
+
await api.client.tui.executeCommand({ body: { command: 'sandbox' } });
|
|
16
|
+
return true;
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
});
|
|
5
21
|
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
22
|
+
const client = api.client;
|
|
23
|
+
if (client?.tui?.showToast) {
|
|
24
|
+
client.tui
|
|
25
|
+
.showToast({
|
|
26
|
+
body: {
|
|
27
|
+
title: 'Sandbox',
|
|
28
|
+
message: '/sandbox command registered',
|
|
29
|
+
variant: 'info',
|
|
30
|
+
},
|
|
31
|
+
})
|
|
32
|
+
.catch(() => undefined);
|
|
33
|
+
}
|
|
34
|
+
} catch (err) {
|
|
35
|
+
const client = api.client;
|
|
36
|
+
if (client?.tui?.showToast) {
|
|
37
|
+
client.tui
|
|
38
|
+
.showToast({
|
|
39
|
+
body: {
|
|
40
|
+
title: 'Sandbox error',
|
|
41
|
+
message: err instanceof Error ? err.message : String(err),
|
|
42
|
+
variant: 'error',
|
|
43
|
+
},
|
|
44
|
+
})
|
|
45
|
+
.catch(() => undefined);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return {};
|
|
18
50
|
};
|
|
19
51
|
|
|
20
52
|
export { tui };
|