@nikcli-ai/plugin 0.0.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.
@@ -0,0 +1,2 @@
1
+ import { Plugin } from "./index";
2
+ export declare const ExamplePlugin: Plugin;
@@ -0,0 +1,16 @@
1
+ import { tool } from "./tool";
2
+ export const ExamplePlugin = async (ctx) => {
3
+ return {
4
+ tool: {
5
+ mytool: tool({
6
+ description: "This is a custom tool",
7
+ args: {
8
+ foo: tool.schema.string().describe("foo"),
9
+ },
10
+ async execute(args) {
11
+ return `Hello ${args.foo}!`;
12
+ },
13
+ }),
14
+ },
15
+ };
16
+ };
@@ -0,0 +1,214 @@
1
+ import type { Event, createNikcliClient, Project, Model, Provider, Permission, UserMessage, Message, Part, Auth, Config as SDKConfig } from "@nikcli-ai/sdk";
2
+ import type { BunShell } from "./shell";
3
+ import { type ToolDefinition } from "./tool";
4
+ export * from "./tool";
5
+ export type PluginOptions = Record<string, unknown>;
6
+ export type Config = Omit<SDKConfig, "plugin"> & {
7
+ plugin?: Array<string | [string, PluginOptions]>;
8
+ };
9
+ export type ProviderContext = {
10
+ source: "env" | "config" | "custom" | "api";
11
+ info: Provider;
12
+ options: Record<string, any>;
13
+ };
14
+ export type PluginInput = {
15
+ client: ReturnType<typeof createNikcliClient>;
16
+ project: Project;
17
+ directory: string;
18
+ worktree: string;
19
+ serverUrl: URL;
20
+ $: BunShell;
21
+ };
22
+ export type Plugin = (input: PluginInput, options?: PluginOptions) => Promise<Hooks>;
23
+ export type PluginModule = {
24
+ id?: string;
25
+ server: Plugin;
26
+ tui?: never;
27
+ };
28
+ export type AuthHook = {
29
+ provider: string;
30
+ loader?: (auth: () => Promise<Auth>, provider: Provider) => Promise<Record<string, any>>;
31
+ methods: ({
32
+ type: "oauth";
33
+ label: string;
34
+ prompts?: Array<{
35
+ type: "text";
36
+ key: string;
37
+ message: string;
38
+ placeholder?: string;
39
+ validate?: (value: string) => string | undefined;
40
+ condition?: (inputs: Record<string, string>) => boolean;
41
+ } | {
42
+ type: "select";
43
+ key: string;
44
+ message: string;
45
+ options: Array<{
46
+ label: string;
47
+ value: string;
48
+ hint?: string;
49
+ }>;
50
+ condition?: (inputs: Record<string, string>) => boolean;
51
+ }>;
52
+ authorize(inputs?: Record<string, string>): Promise<AuthOuathResult>;
53
+ } | {
54
+ type: "api";
55
+ label: string;
56
+ prompts?: Array<{
57
+ type: "text";
58
+ key: string;
59
+ message: string;
60
+ placeholder?: string;
61
+ validate?: (value: string) => string | undefined;
62
+ condition?: (inputs: Record<string, string>) => boolean;
63
+ } | {
64
+ type: "select";
65
+ key: string;
66
+ message: string;
67
+ options: Array<{
68
+ label: string;
69
+ value: string;
70
+ hint?: string;
71
+ }>;
72
+ condition?: (inputs: Record<string, string>) => boolean;
73
+ }>;
74
+ authorize?(inputs?: Record<string, string>): Promise<{
75
+ type: "success";
76
+ key: string;
77
+ provider?: string;
78
+ } | {
79
+ type: "failed";
80
+ }>;
81
+ })[];
82
+ };
83
+ export type AuthOuathResult = {
84
+ url: string;
85
+ instructions: string;
86
+ } & ({
87
+ method: "auto";
88
+ callback(): Promise<({
89
+ type: "success";
90
+ provider?: string;
91
+ } & ({
92
+ refresh: string;
93
+ access: string;
94
+ expires: number;
95
+ accountId?: string;
96
+ } | {
97
+ key: string;
98
+ })) | {
99
+ type: "failed";
100
+ }>;
101
+ } | {
102
+ method: "code";
103
+ callback(code: string): Promise<({
104
+ type: "success";
105
+ provider?: string;
106
+ } & ({
107
+ refresh: string;
108
+ access: string;
109
+ expires: number;
110
+ accountId?: string;
111
+ } | {
112
+ key: string;
113
+ })) | {
114
+ type: "failed";
115
+ }>;
116
+ });
117
+ export interface Hooks {
118
+ event?: (input: {
119
+ event: Event;
120
+ }) => Promise<void>;
121
+ config?: (input: Config) => Promise<void>;
122
+ tool?: {
123
+ [key: string]: ToolDefinition;
124
+ };
125
+ auth?: AuthHook;
126
+ /**
127
+ * Called when a new message is received
128
+ */
129
+ "chat.message"?: (input: {
130
+ sessionID: string;
131
+ agent?: string;
132
+ model?: {
133
+ providerID: string;
134
+ modelID: string;
135
+ };
136
+ messageID?: string;
137
+ variant?: string;
138
+ }, output: {
139
+ message: UserMessage;
140
+ parts: Part[];
141
+ }) => Promise<void>;
142
+ /**
143
+ * Modify parameters sent to LLM
144
+ */
145
+ "chat.params"?: (input: {
146
+ sessionID: string;
147
+ agent: string;
148
+ model: Model;
149
+ provider: ProviderContext;
150
+ message: UserMessage;
151
+ }, output: {
152
+ temperature: number;
153
+ topP: number;
154
+ topK: number;
155
+ options: Record<string, any>;
156
+ }) => Promise<void>;
157
+ "permission.ask"?: (input: Permission, output: {
158
+ status: "ask" | "deny" | "allow";
159
+ }) => Promise<void>;
160
+ "command.execute.before"?: (input: {
161
+ command: string;
162
+ sessionID: string;
163
+ arguments: string;
164
+ }, output: {
165
+ parts: Part[];
166
+ }) => Promise<void>;
167
+ "tool.execute.before"?: (input: {
168
+ tool: string;
169
+ sessionID: string;
170
+ callID: string;
171
+ }, output: {
172
+ args: any;
173
+ }) => Promise<void>;
174
+ "tool.execute.after"?: (input: {
175
+ tool: string;
176
+ sessionID: string;
177
+ callID: string;
178
+ }, output: {
179
+ title: string;
180
+ output: string;
181
+ metadata: any;
182
+ }) => Promise<void>;
183
+ "experimental.chat.messages.transform"?: (input: {}, output: {
184
+ messages: {
185
+ info: Message;
186
+ parts: Part[];
187
+ }[];
188
+ }) => Promise<void>;
189
+ "experimental.chat.system.transform"?: (input: {
190
+ sessionID: string;
191
+ }, output: {
192
+ system: string[];
193
+ }) => Promise<void>;
194
+ /**
195
+ * Called before session compaction starts. Allows plugins to customize
196
+ * the compaction prompt.
197
+ *
198
+ * - `context`: Additional context strings appended to the default prompt
199
+ * - `prompt`: If set, replaces the default compaction prompt entirely
200
+ */
201
+ "experimental.session.compacting"?: (input: {
202
+ sessionID: string;
203
+ }, output: {
204
+ context: string[];
205
+ prompt?: string;
206
+ }) => Promise<void>;
207
+ "experimental.text.complete"?: (input: {
208
+ sessionID: string;
209
+ messageID: string;
210
+ partID: string;
211
+ }, output: {
212
+ text: string;
213
+ }) => Promise<void>;
214
+ }
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ export * from "./tool";
@@ -0,0 +1,109 @@
1
+ export type ShellFunction = (input: Uint8Array) => Uint8Array;
2
+ export type ShellExpression = {
3
+ toString(): string;
4
+ } | Array<ShellExpression> | string | {
5
+ raw: string;
6
+ } | ReadableStream;
7
+ export interface BunShell {
8
+ (strings: TemplateStringsArray, ...expressions: ShellExpression[]): BunShellPromise;
9
+ /**
10
+ * Perform bash-like brace expansion on the given pattern.
11
+ * @param pattern - Brace pattern to expand
12
+ */
13
+ braces(pattern: string): string[];
14
+ /**
15
+ * Escape strings for input into shell commands.
16
+ */
17
+ escape(input: string): string;
18
+ /**
19
+ * Change the default environment variables for shells created by this instance.
20
+ */
21
+ env(newEnv?: Record<string, string | undefined>): BunShell;
22
+ /**
23
+ * Default working directory to use for shells created by this instance.
24
+ */
25
+ cwd(newCwd?: string): BunShell;
26
+ /**
27
+ * Configure the shell to not throw an exception on non-zero exit codes.
28
+ */
29
+ nothrow(): BunShell;
30
+ /**
31
+ * Configure whether or not the shell should throw an exception on non-zero exit codes.
32
+ */
33
+ throws(shouldThrow: boolean): BunShell;
34
+ }
35
+ export interface BunShellPromise extends Promise<BunShellOutput> {
36
+ readonly stdin: WritableStream;
37
+ /**
38
+ * Change the current working directory of the shell.
39
+ */
40
+ cwd(newCwd: string): this;
41
+ /**
42
+ * Set environment variables for the shell.
43
+ */
44
+ env(newEnv: Record<string, string> | undefined): this;
45
+ /**
46
+ * By default, the shell will write to the current process's stdout and stderr, as well as buffering that output.
47
+ * This configures the shell to only buffer the output.
48
+ */
49
+ quiet(): this;
50
+ /**
51
+ * Read from stdout as a string, line by line
52
+ * Automatically calls quiet() to disable echoing to stdout.
53
+ */
54
+ lines(): AsyncIterable<string>;
55
+ /**
56
+ * Read from stdout as a string.
57
+ * Automatically calls quiet() to disable echoing to stdout.
58
+ */
59
+ text(encoding?: BufferEncoding): Promise<string>;
60
+ /**
61
+ * Read from stdout as a JSON object
62
+ * Automatically calls quiet()
63
+ */
64
+ json(): Promise<any>;
65
+ /**
66
+ * Read from stdout as an ArrayBuffer
67
+ * Automatically calls quiet()
68
+ */
69
+ arrayBuffer(): Promise<ArrayBuffer>;
70
+ /**
71
+ * Read from stdout as a Blob
72
+ * Automatically calls quiet()
73
+ */
74
+ blob(): Promise<Blob>;
75
+ /**
76
+ * Configure the shell to not throw an exception on non-zero exit codes.
77
+ */
78
+ nothrow(): this;
79
+ /**
80
+ * Configure whether or not the shell should throw an exception on non-zero exit codes.
81
+ */
82
+ throws(shouldThrow: boolean): this;
83
+ }
84
+ export interface BunShellOutput {
85
+ readonly stdout: Buffer;
86
+ readonly stderr: Buffer;
87
+ readonly exitCode: number;
88
+ /**
89
+ * Read from stdout as a string
90
+ */
91
+ text(encoding?: BufferEncoding): string;
92
+ /**
93
+ * Read from stdout as a JSON object
94
+ */
95
+ json(): any;
96
+ /**
97
+ * Read from stdout as an ArrayBuffer
98
+ */
99
+ arrayBuffer(): ArrayBuffer;
100
+ /**
101
+ * Read from stdout as an Uint8Array
102
+ */
103
+ bytes(): Uint8Array;
104
+ /**
105
+ * Read from stdout as a Blob
106
+ */
107
+ blob(): Blob;
108
+ }
109
+ export type BunShellError = Error & BunShellOutput;
package/dist/shell.js ADDED
File without changes
package/dist/tool.d.ts ADDED
@@ -0,0 +1,36 @@
1
+ import { z } from "zod";
2
+ export type ToolContext = {
3
+ sessionID: string;
4
+ messageID: string;
5
+ agent: string;
6
+ abort: AbortSignal;
7
+ metadata(input: {
8
+ title?: string;
9
+ metadata?: {
10
+ [key: string]: any;
11
+ };
12
+ }): void;
13
+ ask(input: AskInput): Promise<void>;
14
+ };
15
+ type AskInput = {
16
+ permission: string;
17
+ patterns: string[];
18
+ always: string[];
19
+ metadata: {
20
+ [key: string]: any;
21
+ };
22
+ };
23
+ export declare function tool<Args extends z.ZodRawShape>(input: {
24
+ description: string;
25
+ args: Args;
26
+ execute(args: z.infer<z.ZodObject<Args>>, context: ToolContext): Promise<string>;
27
+ }): {
28
+ description: string;
29
+ args: Args;
30
+ execute(args: z.infer<z.ZodObject<Args>>, context: ToolContext): Promise<string>;
31
+ };
32
+ export declare namespace tool {
33
+ var schema: typeof z;
34
+ }
35
+ export type ToolDefinition = ReturnType<typeof tool>;
36
+ export {};
package/dist/tool.js ADDED
@@ -0,0 +1,5 @@
1
+ import { z } from "zod";
2
+ export function tool(input) {
3
+ return input;
4
+ }
5
+ tool.schema = z;
package/dist/tui.d.ts ADDED
@@ -0,0 +1,361 @@
1
+ import type { NikcliClient, Event, LspStatus, McpStatus, Todo, Message, Part, Provider, PermissionRequest, QuestionRequest, SessionStatus, Workspace, Config as SdkConfig } from "@nikcli-ai/sdk/v2";
2
+ import type { CliRenderer, ParsedKey, RGBA } from "@opentui/core";
3
+ import type { JSX, SolidPlugin } from "@opentui/solid";
4
+ import type { Config as PluginConfig, PluginOptions } from "./index.js";
5
+ export type { CliRenderer, SlotMode } from "@opentui/core";
6
+ export type TuiRouteCurrent = {
7
+ name: "home";
8
+ } | {
9
+ name: "session";
10
+ params: {
11
+ sessionID: string;
12
+ initialPrompt?: unknown;
13
+ };
14
+ } | {
15
+ name: string;
16
+ params?: Record<string, unknown>;
17
+ };
18
+ export type TuiRouteDefinition = {
19
+ name: string;
20
+ render: (input: {
21
+ params?: Record<string, unknown>;
22
+ }) => JSX.Element;
23
+ };
24
+ export type TuiCommand = {
25
+ title: string;
26
+ value: string;
27
+ description?: string;
28
+ category?: string;
29
+ keybind?: string;
30
+ suggested?: boolean;
31
+ hidden?: boolean;
32
+ enabled?: boolean;
33
+ slash?: {
34
+ name: string;
35
+ aliases?: string[];
36
+ };
37
+ onSelect?: () => void;
38
+ };
39
+ export type TuiKeybind = {
40
+ name: string;
41
+ ctrl: boolean;
42
+ meta: boolean;
43
+ shift: boolean;
44
+ super?: boolean;
45
+ leader: boolean;
46
+ };
47
+ export type TuiKeybindMap = Record<string, string>;
48
+ export type TuiKeybindSet = {
49
+ readonly all: TuiKeybindMap;
50
+ get: (name: string) => string;
51
+ match: (name: string, evt: ParsedKey) => boolean;
52
+ print: (name: string) => string;
53
+ };
54
+ export type TuiDialogProps = {
55
+ size?: "medium" | "large" | "xlarge";
56
+ onClose: () => void;
57
+ children?: JSX.Element;
58
+ };
59
+ export type TuiDialogStack = {
60
+ replace: (render: () => JSX.Element, onClose?: () => void) => void;
61
+ clear: () => void;
62
+ setSize: (size: "medium" | "large" | "xlarge") => void;
63
+ readonly size: "medium" | "large" | "xlarge";
64
+ readonly depth: number;
65
+ readonly open: boolean;
66
+ };
67
+ export type TuiDialogAlertProps = {
68
+ title: string;
69
+ message: string;
70
+ onConfirm?: () => void;
71
+ };
72
+ export type TuiDialogConfirmProps = {
73
+ title: string;
74
+ message: string;
75
+ onConfirm?: () => void;
76
+ onCancel?: () => void;
77
+ };
78
+ export type TuiDialogPromptProps = {
79
+ title: string;
80
+ description?: () => JSX.Element;
81
+ placeholder?: string;
82
+ value?: string;
83
+ busy?: boolean;
84
+ busyText?: string;
85
+ onConfirm?: (value: string) => void;
86
+ onCancel?: () => void;
87
+ };
88
+ export type TuiDialogSelectOption<Value = unknown> = {
89
+ title: string;
90
+ value: Value;
91
+ description?: string;
92
+ footer?: JSX.Element | string;
93
+ category?: string;
94
+ disabled?: boolean;
95
+ onSelect?: () => void;
96
+ };
97
+ export type TuiDialogSelectProps<Value = unknown> = {
98
+ title: string;
99
+ placeholder?: string;
100
+ options: TuiDialogSelectOption<Value>[];
101
+ flat?: boolean;
102
+ onMove?: (option: TuiDialogSelectOption<Value>) => void;
103
+ onFilter?: (query: string) => void;
104
+ onSelect?: (option: TuiDialogSelectOption<Value>) => void;
105
+ skipFilter?: boolean;
106
+ current?: Value;
107
+ };
108
+ export type TuiToast = {
109
+ variant?: "info" | "success" | "warning" | "error";
110
+ title?: string;
111
+ message: string;
112
+ duration?: number;
113
+ };
114
+ export type TuiThemeCurrent = {
115
+ readonly primary: RGBA;
116
+ readonly secondary: RGBA;
117
+ readonly accent: RGBA;
118
+ readonly error: RGBA;
119
+ readonly warning: RGBA;
120
+ readonly success: RGBA;
121
+ readonly info: RGBA;
122
+ readonly text: RGBA;
123
+ readonly textMuted: RGBA;
124
+ readonly selectedListItemText: RGBA;
125
+ readonly background: RGBA;
126
+ readonly backgroundPanel: RGBA;
127
+ readonly backgroundElement: RGBA;
128
+ readonly backgroundMenu: RGBA;
129
+ readonly border: RGBA;
130
+ readonly borderActive: RGBA;
131
+ readonly borderSubtle: RGBA;
132
+ readonly diffAdded: RGBA;
133
+ readonly diffRemoved: RGBA;
134
+ readonly diffContext: RGBA;
135
+ readonly diffHunkHeader: RGBA;
136
+ readonly diffHighlightAdded: RGBA;
137
+ readonly diffHighlightRemoved: RGBA;
138
+ readonly diffAddedBg: RGBA;
139
+ readonly diffRemovedBg: RGBA;
140
+ readonly diffContextBg: RGBA;
141
+ readonly diffLineNumber: RGBA;
142
+ readonly diffAddedLineNumberBg: RGBA;
143
+ readonly diffRemovedLineNumberBg: RGBA;
144
+ readonly markdownText: RGBA;
145
+ readonly markdownHeading: RGBA;
146
+ readonly markdownLink: RGBA;
147
+ readonly markdownLinkText: RGBA;
148
+ readonly markdownCode: RGBA;
149
+ readonly markdownBlockQuote: RGBA;
150
+ readonly markdownEmph: RGBA;
151
+ readonly markdownStrong: RGBA;
152
+ readonly markdownHorizontalRule: RGBA;
153
+ readonly markdownListItem: RGBA;
154
+ readonly markdownListEnumeration: RGBA;
155
+ readonly markdownImage: RGBA;
156
+ readonly markdownImageText: RGBA;
157
+ readonly markdownCodeBlock: RGBA;
158
+ readonly syntaxComment: RGBA;
159
+ readonly syntaxKeyword: RGBA;
160
+ readonly syntaxFunction: RGBA;
161
+ readonly syntaxVariable: RGBA;
162
+ readonly syntaxString: RGBA;
163
+ readonly syntaxNumber: RGBA;
164
+ readonly syntaxType: RGBA;
165
+ readonly syntaxOperator: RGBA;
166
+ readonly syntaxPunctuation: RGBA;
167
+ readonly thinkingOpacity: number;
168
+ };
169
+ export type TuiTheme = {
170
+ readonly current: TuiThemeCurrent;
171
+ readonly selected: string;
172
+ has: (name: string) => boolean;
173
+ set: (name: string) => void;
174
+ install: (jsonPath: string) => Promise<void>;
175
+ mode: () => "dark" | "light";
176
+ readonly ready: boolean;
177
+ };
178
+ export type TuiKV = {
179
+ get: <Value = unknown>(key: string, fallback?: Value) => Value;
180
+ set: (key: string, value: unknown) => void;
181
+ readonly ready: boolean;
182
+ };
183
+ export type TuiState = {
184
+ readonly ready: boolean;
185
+ readonly config: SdkConfig;
186
+ readonly provider: ReadonlyArray<Provider>;
187
+ readonly path: {
188
+ state: string;
189
+ config: string;
190
+ worktree: string;
191
+ directory: string;
192
+ };
193
+ readonly vcs: {
194
+ branch?: string;
195
+ } | undefined;
196
+ readonly workspace: {
197
+ list: () => ReadonlyArray<Workspace>;
198
+ get: (workspaceID: string) => Workspace | undefined;
199
+ };
200
+ session: {
201
+ count: () => number;
202
+ diff: (sessionID: string) => ReadonlyArray<TuiSidebarFileItem>;
203
+ todo: (sessionID: string) => ReadonlyArray<TuiSidebarTodoItem>;
204
+ messages: (sessionID: string) => ReadonlyArray<Message>;
205
+ status: (sessionID: string) => SessionStatus | undefined;
206
+ permission: (sessionID: string) => ReadonlyArray<PermissionRequest>;
207
+ question: (sessionID: string) => ReadonlyArray<QuestionRequest>;
208
+ };
209
+ part: (messageID: string) => ReadonlyArray<Part>;
210
+ lsp: () => ReadonlyArray<TuiSidebarLspItem>;
211
+ mcp: () => ReadonlyArray<TuiSidebarMcpItem>;
212
+ };
213
+ type TuiConfigView = Pick<PluginConfig, "$schema" | "theme" | "keybinds" | "plugin"> & NonNullable<PluginConfig["tui"]> & {
214
+ plugin_enabled?: Record<string, boolean>;
215
+ };
216
+ export type TuiApp = {
217
+ readonly version: string;
218
+ };
219
+ type Frozen<Value> = Value extends (...args: never[]) => unknown ? Value : Value extends ReadonlyArray<infer Item> ? ReadonlyArray<Frozen<Item>> : Value extends object ? {
220
+ readonly [Key in keyof Value]: Frozen<Value[Key]>;
221
+ } : Value;
222
+ export type TuiSidebarMcpItem = {
223
+ name: string;
224
+ status: McpStatus["status"];
225
+ error?: string;
226
+ };
227
+ export type TuiSidebarLspItem = Pick<LspStatus, "id" | "root" | "status">;
228
+ export type TuiSidebarTodoItem = Pick<Todo, "content" | "status">;
229
+ export type TuiSidebarFileItem = {
230
+ file: string;
231
+ additions: number;
232
+ deletions: number;
233
+ };
234
+ export type TuiSlotMap = {
235
+ app: {};
236
+ home_logo: {};
237
+ home_bottom: {};
238
+ sidebar_title: {
239
+ session_id: string;
240
+ title: string;
241
+ share_url?: string;
242
+ };
243
+ sidebar_content: {
244
+ session_id: string;
245
+ };
246
+ sidebar_footer: {
247
+ session_id: string;
248
+ };
249
+ };
250
+ export type TuiSlotContext = {
251
+ theme: TuiTheme;
252
+ };
253
+ type SlotCore = SolidPlugin<TuiSlotMap, TuiSlotContext>;
254
+ export type TuiSlotPlugin = Omit<SlotCore, "id"> & {
255
+ id?: never;
256
+ };
257
+ export type TuiSlots = {
258
+ register: (plugin: TuiSlotPlugin) => string;
259
+ };
260
+ export type TuiEventBus = {
261
+ on: <Type extends Event["type"]>(type: Type, handler: (event: Extract<Event, {
262
+ type: Type;
263
+ }>) => void) => () => void;
264
+ };
265
+ export type TuiDispose = () => void | Promise<void>;
266
+ export type TuiLifecycle = {
267
+ readonly signal: AbortSignal;
268
+ onDispose: (fn: TuiDispose) => () => void;
269
+ };
270
+ export type TuiPluginState = "first" | "updated" | "same";
271
+ export type TuiPluginEntry = {
272
+ id: string;
273
+ source: "file" | "npm" | "internal";
274
+ spec: string;
275
+ target: string;
276
+ requested?: string;
277
+ version?: string;
278
+ modified?: number;
279
+ first_time: number;
280
+ last_time: number;
281
+ time_changed: number;
282
+ load_count: number;
283
+ fingerprint: string;
284
+ };
285
+ export type TuiPluginMeta = TuiPluginEntry & {
286
+ state: TuiPluginState;
287
+ };
288
+ export type TuiPluginStatus = {
289
+ id: string;
290
+ source: TuiPluginEntry["source"];
291
+ spec: string;
292
+ target: string;
293
+ enabled: boolean;
294
+ active: boolean;
295
+ };
296
+ export type TuiPluginInstallOptions = {
297
+ global?: boolean;
298
+ };
299
+ export type TuiPluginInstallResult = {
300
+ ok: true;
301
+ dir: string;
302
+ tui: boolean;
303
+ } | {
304
+ ok: false;
305
+ message: string;
306
+ missing?: boolean;
307
+ };
308
+ export type TuiWorkspace = {
309
+ current: () => string | undefined;
310
+ set: (workspaceID?: string) => void;
311
+ };
312
+ export type TuiPluginApi = {
313
+ app: TuiApp;
314
+ command: {
315
+ register: (cb: () => TuiCommand[]) => () => void;
316
+ trigger: (value: string) => void;
317
+ };
318
+ route: {
319
+ register: (routes: TuiRouteDefinition[]) => () => void;
320
+ navigate: (name: string, params?: Record<string, unknown>) => void;
321
+ readonly current: TuiRouteCurrent;
322
+ };
323
+ ui: {
324
+ Dialog: (props: TuiDialogProps) => JSX.Element;
325
+ DialogAlert: (props: TuiDialogAlertProps) => JSX.Element;
326
+ DialogConfirm: (props: TuiDialogConfirmProps) => JSX.Element;
327
+ DialogPrompt: (props: TuiDialogPromptProps) => JSX.Element;
328
+ DialogSelect: <Value = unknown>(props: TuiDialogSelectProps<Value>) => JSX.Element;
329
+ toast: (input: TuiToast) => void;
330
+ dialog: TuiDialogStack;
331
+ };
332
+ keybind: {
333
+ match: (key: string, evt: ParsedKey) => boolean;
334
+ print: (key: string) => string;
335
+ create: (defaults: TuiKeybindMap, overrides?: Record<string, unknown>) => TuiKeybindSet;
336
+ };
337
+ readonly tuiConfig: Frozen<TuiConfigView>;
338
+ kv: TuiKV;
339
+ state: TuiState;
340
+ theme: TuiTheme;
341
+ client: NikcliClient;
342
+ scopedClient: (workspaceID?: string) => NikcliClient;
343
+ workspace: TuiWorkspace;
344
+ event: TuiEventBus;
345
+ renderer: CliRenderer;
346
+ slots: TuiSlots;
347
+ plugins: {
348
+ list: () => ReadonlyArray<TuiPluginStatus>;
349
+ activate: (id: string) => Promise<boolean>;
350
+ deactivate: (id: string) => Promise<boolean>;
351
+ add: (spec: string) => Promise<boolean>;
352
+ install: (spec: string, options?: TuiPluginInstallOptions) => Promise<TuiPluginInstallResult>;
353
+ };
354
+ lifecycle: TuiLifecycle;
355
+ };
356
+ export type TuiPlugin = (api: TuiPluginApi, options: PluginOptions | undefined, meta: TuiPluginMeta) => Promise<void>;
357
+ export type TuiPluginModule = {
358
+ id?: string;
359
+ tui: TuiPlugin;
360
+ server?: never;
361
+ };
package/dist/tui.js ADDED
File without changes
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/package.json",
3
+ "name": "@nikcli-ai/plugin",
4
+ "version": "0.0.6",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "scripts": {
8
+ "typecheck": "tsgo --noEmit",
9
+ "build": "tsc",
10
+ "build:plugins": "bun run script/build-plugins.ts",
11
+ "publish:plugins": "bun run script/publish-plugins.ts"
12
+ },
13
+ "exports": {
14
+ ".": {
15
+ "import": "./dist/index.js",
16
+ "types": "./dist/index.d.ts"
17
+ },
18
+ "./tool": {
19
+ "import": "./dist/tool.js",
20
+ "types": "./dist/tool.d.ts"
21
+ },
22
+ "./tui": {
23
+ "import": "./dist/tui.js",
24
+ "types": "./dist/tui.d.ts"
25
+ }
26
+ },
27
+ "files": [
28
+ "dist"
29
+ ],
30
+ "publishConfig": {
31
+ "exports": {
32
+ ".": "./dist/index.js",
33
+ "./tool": "./dist/tool.js",
34
+ "./tui": "./dist/tui.js"
35
+ }
36
+ },
37
+ "dependencies": {
38
+ "@nikcli-ai/sdk": "0.0.6",
39
+ "@opentui/core": "0.1.91",
40
+ "@opentui/solid": "0.1.91",
41
+ "zod": "4.1.8"
42
+ },
43
+ "devDependencies": {
44
+ "@tsconfig/node22": "22.0.2",
45
+ "@types/node": "22.13.9",
46
+ "typescript": "5.8.2",
47
+ "@typescript/native-preview": "7.0.0-dev.20251207.1"
48
+ }
49
+ }