@mirrowel/opencode-openshare 0.0.0-stage → 0.1.1

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 (51) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +181 -2
  3. package/ci/README.md +56 -0
  4. package/ci/openshare.config.json +10 -0
  5. package/ci/openshare.js +2270 -0
  6. package/dist/commands.d.ts +7 -0
  7. package/dist/commands.js +440 -0
  8. package/dist/config.d.ts +138 -0
  9. package/dist/config.js +524 -0
  10. package/dist/core.d.ts +117 -0
  11. package/dist/core.js +1944 -0
  12. package/dist/dialogs.d.ts +94 -0
  13. package/dist/dialogs.js +725 -0
  14. package/dist/server.d.ts +64 -0
  15. package/dist/server.js +30 -0
  16. package/dist/settings.d.ts +24 -0
  17. package/dist/settings.js +1226 -0
  18. package/dist/share-flow.d.ts +287 -0
  19. package/dist/share-flow.js +516 -0
  20. package/dist/sidebar.d.ts +19 -0
  21. package/dist/sidebar.js +144 -0
  22. package/dist/tui-host.d.ts +158 -0
  23. package/dist/tui-host.js +6 -0
  24. package/dist/tui.d.ts +17 -0
  25. package/dist/tui.js +4719 -0
  26. package/dist/ui-prefs.d.ts +16 -0
  27. package/dist/ui-prefs.js +27 -0
  28. package/dist/v2-server.d.ts +81 -0
  29. package/dist/v2-server.js +402 -0
  30. package/dist/v2-tui.d.ts +24 -0
  31. package/dist/v2-tui.js +313 -0
  32. package/dist/v2-types.d.ts +134 -0
  33. package/dist/v2-types.js +8 -0
  34. package/openshare.config.json +16 -0
  35. package/package.json +98 -4
  36. package/src/banner.txt +25 -0
  37. package/src/commands.ts +452 -0
  38. package/src/config.ts +524 -0
  39. package/src/core.ts +1997 -0
  40. package/src/dialogs.tsx +971 -0
  41. package/src/server.ts +47 -0
  42. package/src/settings.ts +1239 -0
  43. package/src/share-flow.ts +551 -0
  44. package/src/sidebar.tsx +187 -0
  45. package/src/tui-host.ts +134 -0
  46. package/src/tui.tsx +318 -0
  47. package/src/ui-prefs.ts +36 -0
  48. package/src/v2-server.ts +438 -0
  49. package/src/v2-tui.ts +315 -0
  50. package/src/v2-types.ts +102 -0
  51. package/tsconfig.json +18 -0
@@ -0,0 +1,158 @@
1
+ import type { ClientApi, SessionInfo, SessionOpts } from "./core.js";
2
+ export type ShareDialogSelectOption<Value = string> = {
3
+ title: string;
4
+ value: Value;
5
+ description?: string;
6
+ category?: string;
7
+ disabled?: boolean;
8
+ /** long-form detail shown in the [i] pane (v1 menus; other hosts ignore).
9
+ * "## Header" lines split paged sections. */
10
+ help?: string;
11
+ /** destructive action — renders red (v1 menus) */
12
+ danger?: boolean;
13
+ /** pending/edited — renders green (v1 menus) */
14
+ edited?: boolean;
15
+ /** non-interactive separator row (v1 menus) */
16
+ divider?: boolean;
17
+ };
18
+ export type ShareHostKeyContext = {
19
+ event?: {
20
+ preventDefault?: () => void;
21
+ stopPropagation?: () => void;
22
+ };
23
+ };
24
+ export type ShareHostLayerCommand = {
25
+ name: string;
26
+ title?: string;
27
+ desc?: string;
28
+ slashName?: string;
29
+ slashAliases?: string[];
30
+ suggested?: boolean;
31
+ hidden?: boolean;
32
+ enabled?: boolean | (() => boolean);
33
+ category?: string;
34
+ group?: string;
35
+ run: (ctx: ShareHostKeyContext) => void | Promise<void>;
36
+ };
37
+ export type ShareHostKeymapLayer = {
38
+ /** v2 adapter only (v2 keymap layers are natively mode-scoped "global").
39
+ * The v1 registration deliberately ignores this: a v1 plugin layer with
40
+ * a declared mode is gated on the mode stack and never reachable. */
41
+ mode?: string;
42
+ priority?: number;
43
+ commands: readonly ShareHostLayerCommand[];
44
+ bindings: readonly {
45
+ key: string;
46
+ cmd: string;
47
+ desc?: string;
48
+ }[];
49
+ };
50
+ export type ShareHostApi = {
51
+ /** Host version marker (v2 adapter sets 2; v1 leaves undefined). */
52
+ hostVersion?: 1 | 2;
53
+ app?: {
54
+ version?: string;
55
+ };
56
+ /** Raw SDK client; metadata PATCH/GET go through it. */
57
+ client?: ClientApi;
58
+ kv: {
59
+ get<Value = unknown>(key: string, fallback?: Value): Value;
60
+ set(key: string, value: unknown): void;
61
+ };
62
+ lifecycle: {
63
+ onDispose(fn: () => void): void;
64
+ };
65
+ theme: {
66
+ current: {
67
+ success: unknown;
68
+ info: unknown;
69
+ error: unknown;
70
+ warning: unknown;
71
+ textMuted: unknown;
72
+ };
73
+ };
74
+ ui: {
75
+ toast(input: {
76
+ variant?: "info" | "success" | "warning" | "error";
77
+ title?: string;
78
+ message: string;
79
+ duration?: number;
80
+ }): void;
81
+ dialog: {
82
+ replace(renderer: unknown, onClose?: () => void): void;
83
+ clear(): void;
84
+ setSize(size: string): void;
85
+ };
86
+ /** Promise menus (the family showMenuOnce pattern). Preferred UI on v1. */
87
+ showMenu<Value = string>(props: {
88
+ title: string;
89
+ options: ShareDialogSelectOption<Value>[];
90
+ current?: Value;
91
+ hint?: string;
92
+ }): Promise<Value | undefined>;
93
+ showConfirm(props: {
94
+ title: string;
95
+ message: string;
96
+ confirmLabel?: string;
97
+ danger?: boolean;
98
+ }): Promise<boolean>;
99
+ showAlert(props: {
100
+ title: string;
101
+ message: string;
102
+ }): Promise<void>;
103
+ showPrompt(props: {
104
+ title: string;
105
+ placeholder?: string;
106
+ value?: string;
107
+ }): Promise<string | undefined>;
108
+ /** Combined menu-size picker (v1 facade only; feature-detected). */
109
+ showSizePicker?(current: {
110
+ width: string;
111
+ heightPercent: number;
112
+ }): Promise<{
113
+ width: string;
114
+ heightPercent: number;
115
+ } | undefined>;
116
+ /** Non-cancelable busy dialog; returns the done() that clears it. */
117
+ showBusy?(title: string): (() => void) | undefined;
118
+ DialogSelect<Value = string>(props: {
119
+ title: string;
120
+ placeholder?: string;
121
+ options: ShareDialogSelectOption<Value>[];
122
+ current?: Value;
123
+ flat?: boolean;
124
+ onSelect: (option: ShareDialogSelectOption<Value>) => void;
125
+ }): unknown;
126
+ DialogPrompt(props: {
127
+ title: string;
128
+ placeholder?: string;
129
+ value?: string;
130
+ onConfirm: (value: string) => void;
131
+ onCancel?: () => void;
132
+ }): unknown;
133
+ DialogConfirm(props: {
134
+ title: string;
135
+ message: string;
136
+ confirmLabel?: string;
137
+ onConfirm: () => void;
138
+ onCancel?: () => void;
139
+ }): unknown;
140
+ DialogAlert(props: {
141
+ title: string;
142
+ message: string;
143
+ onConfirm?: () => void;
144
+ }): unknown;
145
+ };
146
+ keymap: {
147
+ registerLayer(layer: ShareHostKeymapLayer): () => void;
148
+ };
149
+ /** Live session lookup (v1: reactive state store; v2: client GET). */
150
+ sessionInfo(sessionID: string): SessionInfo | undefined;
151
+ /** Currently focused/open session id, when the host can tell. */
152
+ currentSessionID?: () => string | undefined;
153
+ /** Clipboard write; resolves false when unavailable. */
154
+ clipboard: {
155
+ write(text: string): Promise<boolean>;
156
+ };
157
+ };
158
+ export type { ClientApi, SessionInfo, SessionOpts };
@@ -0,0 +1,6 @@
1
+ // Host-agnostic TUI API surface for OpenShare. The exact bounded subset of
2
+ // the OpenCode v1 `TuiPluginApi` the share flows and settings dialog use;
3
+ // a v1 api instance satisfies it structurally, and v2-tui.ts implements it
4
+ // over the OpenCode v2 TUI plugin context. Flows never touch anything
5
+ // outside this interface — one compiled bundle runs on both hosts.
6
+ export {};
package/dist/tui.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ /** @jsxImportSource @opentui/solid */
2
+ import type { TuiPlugin, TuiPluginApi } from "@opencode-ai/plugin/tui";
3
+ import type { ShareHostApi } from "./tui-host.js";
4
+ export declare function buildV1HostApi(api: TuiPluginApi): ShareHostApi;
5
+ /**
6
+ * Dual-target TUI entry.
7
+ *
8
+ * - OpenCode v1 (strict loader) requires `default.tui` to be a function;
9
+ * excess keys are ignored.
10
+ * - OpenCode v2 requires `default` to be `{ id, setup }`.
11
+ */
12
+ declare const _default: {
13
+ id: string;
14
+ tui: TuiPlugin;
15
+ setup: import("./v2-types.js").V2TuiSetup;
16
+ };
17
+ export default _default;