opencode-landstrip 0.3.5 → 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.
Files changed (3) hide show
  1. package/index.ts +33 -10
  2. package/package.json +1 -1
  3. package/tui.ts +45 -13
package/index.ts CHANGED
@@ -725,7 +725,7 @@ function assertApplyPatchAllowed(
725
725
  assertWriteAllowed(path, config, baseDirectory);
726
726
  }
727
727
 
728
- export default (async ({ client, directory }: PluginInput, options?: PluginOptions) => {
728
+ const plugin: Plugin = async ({ client, directory }: PluginInput, options?: PluginOptions) => {
729
729
  const optionOverrides = normalizeOptions(options);
730
730
  const activeBash = new Map<string, BashSandboxState>();
731
731
  const notified = new Set<string>();
@@ -733,6 +733,28 @@ export default (async ({ client, directory }: PluginInput, options?: PluginOptio
733
733
  let configuredShell: string | undefined;
734
734
  let landstripCheck: { ok: true; version: string } | { ok: false; reason: string } | undefined;
735
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
+
736
758
  async function notifyOnce(key: string, message: string, variant: ToastVariant): Promise<void> {
737
759
  if (notified.has(key)) return;
738
760
  notified.add(key);
@@ -1007,17 +1029,16 @@ export default (async ({ client, directory }: PluginInput, options?: PluginOptio
1007
1029
  },
1008
1030
 
1009
1031
  'command.execute.before': async (input, output) => {
1010
- if (input.command !== 'sandbox') return;
1032
+ if (input.command !== 'sandbox' && input.command !== '/sandbox') return;
1011
1033
 
1012
1034
  const config = loadConfig(directory, optionOverrides);
1013
1035
  const summary = buildConfigSummary(config);
1014
- output.parts.unshift({
1015
- id: `landstrip-sandbox-${Date.now()}`,
1016
- sessionID: input.sessionID,
1017
- messageID: input.sessionID,
1018
- type: 'text',
1019
- text: `\n${summary}\n`,
1020
- });
1036
+ await client.tui
1037
+ .showToast({
1038
+ body: { title: 'Sandbox', message: summary, variant: 'info', duration: 15000 },
1039
+ query: { directory },
1040
+ })
1041
+ .catch(() => undefined);
1021
1042
  },
1022
1043
 
1023
1044
  dispose: async () => {
@@ -1026,4 +1047,6 @@ export default (async ({ client, directory }: PluginInput, options?: PluginOptio
1026
1047
  };
1027
1048
 
1028
1049
  return hooks;
1029
- }) satisfies Plugin;
1050
+ };
1051
+
1052
+ export default plugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-landstrip",
3
- "version": "0.3.5",
3
+ "version": "0.3.6",
4
4
  "description": "Landlock-based sandboxing for opencode with landstrip",
5
5
  "keywords": [
6
6
  "landlock",
package/tui.ts CHANGED
@@ -1,20 +1,52 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  // Copyright (C) Jarkko Sakkinen 2026
3
3
 
4
- import type { TuiPlugin } from '@opencode-ai/plugin/tui';
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 tui: TuiPlugin = async (api) => {
7
- api.command?.register(() => [
8
- {
9
- title: 'Sandbox',
10
- value: 'sandbox',
11
- description: 'Show sandbox configuration',
12
- category: 'plugin',
13
- slash: {
14
- name: 'sandbox',
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 };