@lune_99/pi-lune-extensions-core 0.1.0 → 0.2.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/CHANGELOG.md +40 -0
- package/README.md +100 -34
- package/dist/dock/registry.js +1 -0
- package/dist/extension.js +6 -2
- package/dist/mention/autocomplete.d.ts +23 -0
- package/dist/mention/autocomplete.js +135 -0
- package/dist/mention/catalog.d.ts +26 -0
- package/dist/mention/catalog.js +76 -0
- package/dist/mention/claude.d.ts +2 -0
- package/dist/mention/claude.js +118 -0
- package/dist/mention/codex.d.ts +3 -0
- package/dist/mention/codex.js +135 -0
- package/dist/mention/external.d.ts +15 -0
- package/dist/mention/external.js +151 -0
- package/dist/mention/index.d.ts +8 -0
- package/dist/mention/index.js +150 -0
- package/dist/mention/jsonl.d.ts +9 -0
- package/dist/mention/jsonl.js +54 -0
- package/dist/mention/mention.d.ts +19 -0
- package/dist/mention/mention.js +60 -0
- package/dist/mention/session.d.ts +18 -0
- package/dist/mention/session.js +8 -0
- package/dist/mention/text.d.ts +12 -0
- package/dist/mention/text.js +47 -0
- package/dist/mention/transcript.d.ts +10 -0
- package/dist/mention/transcript.js +129 -0
- package/dist/panel/defined-section.js +34 -8
- package/dist/panel/definition.d.ts +26 -1
- package/dist/panel/definition.js +32 -2
- package/dist/panel/index.d.ts +3 -2
- package/dist/panel/index.js +1 -0
- package/dist/panel/panel.js +100 -24
- package/dist/panel/section.d.ts +49 -3
- package/dist/panel/section.js +59 -12
- package/dist/resources/scoped-extension.js +1 -0
- package/dist/settings/file-store.js +1 -0
- package/docs/dock.md +9 -3
- package/docs/panel.md +69 -2
- package/docs/public-api-design.md +9 -9
- package/docs/recipes.md +3 -8
- package/docs/settings.md +1 -1
- package/package.json +4 -4
- package/src/dock/registry.ts +1 -0
- package/src/extension.ts +6 -2
- package/src/mention/autocomplete.ts +173 -0
- package/src/mention/catalog.ts +84 -0
- package/src/mention/claude.ts +127 -0
- package/src/mention/codex.ts +144 -0
- package/src/mention/external.ts +191 -0
- package/src/mention/index.ts +173 -0
- package/src/mention/jsonl.ts +56 -0
- package/src/mention/mention.ts +90 -0
- package/src/mention/session.ts +27 -0
- package/src/mention/text.ts +52 -0
- package/src/mention/transcript.ts +155 -0
- package/src/panel/defined-section.ts +40 -7
- package/src/panel/definition.ts +67 -2
- package/src/panel/index.ts +4 -0
- package/src/panel/panel.ts +105 -23
- package/src/panel/section.ts +111 -15
- package/src/resources/scoped-extension.ts +1 -0
- package/src/settings/file-store.ts +1 -0
package/src/panel/section.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* candidates only in clones. Validation/editor resolution stays usable without TUI.
|
|
8
8
|
*/
|
|
9
9
|
import { Value } from "typebox/value";
|
|
10
|
-
import type
|
|
10
|
+
import { Type, type Static, type TObject, type TSchema } from "typebox";
|
|
11
11
|
import type { ExtensionContext, Theme } from "@earendil-works/pi-coding-agent";
|
|
12
12
|
import type { Component } from "@earendil-works/pi-tui";
|
|
13
13
|
import type {
|
|
@@ -121,13 +121,26 @@ export type SettingsCustomEditor<T, TValues> = (
|
|
|
121
121
|
context: SettingsCustomEditorContext<T, TValues>,
|
|
122
122
|
) => SettingsEditorComponent;
|
|
123
123
|
|
|
124
|
+
/**
|
|
125
|
+
* A secondary menu: a page of fields that one row opens inside the panel frame.
|
|
126
|
+
* Renderers build it again on every refresh, so its fields can follow changes made
|
|
127
|
+
* outside Settings, such as files the menu edits. Its fields may open further menus.
|
|
128
|
+
*/
|
|
129
|
+
export interface SettingsMenu {
|
|
130
|
+
/** Unique IDs within the menu; a renderer keeps an open menu by the IDs on its path. */
|
|
131
|
+
readonly fields: readonly SettingsPanelField[];
|
|
132
|
+
/** Shown instead of the list when fields is empty. */
|
|
133
|
+
readonly emptyMessage?: string;
|
|
134
|
+
}
|
|
135
|
+
|
|
124
136
|
/**
|
|
125
137
|
* cycle commits static choices immediately; select confirms a candidate list.
|
|
126
138
|
* text accepts raw strings only; number accepts one finite number for number/integer
|
|
127
139
|
* schemas; json parses then validates complete JSON values; custom hands editing to
|
|
128
|
-
* the field's customEditor
|
|
140
|
+
* the field's customEditor; menu opens the field's secondary menu. Preview
|
|
141
|
+
* availability does not determine the editor.
|
|
129
142
|
*/
|
|
130
|
-
export type SettingsEditor = "cycle" | "select" | "text" | "number" | "json" | "custom";
|
|
143
|
+
export type SettingsEditor = "cycle" | "select" | "text" | "number" | "json" | "custom" | "menu";
|
|
131
144
|
|
|
132
145
|
/**
|
|
133
146
|
* Field presentation/editing metadata, not storage policy.
|
|
@@ -143,6 +156,11 @@ export type SettingsFieldOptions<T, TValues> = {
|
|
|
143
156
|
* ungrouped fields come before every group.
|
|
144
157
|
*/
|
|
145
158
|
group?: string;
|
|
159
|
+
/**
|
|
160
|
+
* ID of a menu of the same panel that lists the field on its page instead of in the
|
|
161
|
+
* section. That menu declares no open function; see SettingsMenuDefinition.
|
|
162
|
+
*/
|
|
163
|
+
inMenu?: string;
|
|
146
164
|
/**
|
|
147
165
|
* Hide the field while this returns false, e.g. options of a disabled feature.
|
|
148
166
|
* Hidden fields keep their stored values. Runs on every refresh: keep it cheap and pure.
|
|
@@ -218,6 +236,12 @@ export interface SettingsPanelField {
|
|
|
218
236
|
customEditor?(
|
|
219
237
|
context: Omit<SettingsCustomEditorContext<unknown, unknown>, "values">,
|
|
220
238
|
): SettingsEditorComponent;
|
|
239
|
+
/**
|
|
240
|
+
* Present exactly when editor is "menu". A menu row holds no value: renderers show
|
|
241
|
+
* formatValue(undefined) as its summary and never inspect, set or reset it.
|
|
242
|
+
* createSettingsMenuField builds such a field.
|
|
243
|
+
*/
|
|
244
|
+
menu?(context: ExtensionContext, scope: SettingsScope): SettingsMenu;
|
|
221
245
|
/** Current precedence explanation; renderers use explicit scope overrides for editing. */
|
|
222
246
|
inspect(): SettingInspection<unknown>;
|
|
223
247
|
/** Validate/commit a candidate at this explicit persistence scope, not a candidate range. */
|
|
@@ -286,21 +310,24 @@ function schemaChoices(schema: SettingsPanelSchema): SettingsChoice[] | undefine
|
|
|
286
310
|
export function settingsEditor(
|
|
287
311
|
field: Pick<SettingsPanelField, "editor" | "choiceSource" | "choices" | "schema"> & {
|
|
288
312
|
customEditor?: unknown;
|
|
313
|
+
menu?: unknown;
|
|
289
314
|
},
|
|
290
315
|
): SettingsEditor {
|
|
291
316
|
return (
|
|
292
317
|
field.editor ??
|
|
293
|
-
(field.
|
|
294
|
-
? "
|
|
295
|
-
: field.
|
|
296
|
-
? "
|
|
297
|
-
: field.
|
|
298
|
-
? "
|
|
299
|
-
: field.
|
|
300
|
-
? "
|
|
301
|
-
: field.schema.type === "
|
|
302
|
-
? "
|
|
303
|
-
: "
|
|
318
|
+
(field.menu
|
|
319
|
+
? "menu"
|
|
320
|
+
: field.customEditor
|
|
321
|
+
? "custom"
|
|
322
|
+
: field.choiceSource
|
|
323
|
+
? "select"
|
|
324
|
+
: field.choices?.length
|
|
325
|
+
? "cycle"
|
|
326
|
+
: field.schema.type === "string"
|
|
327
|
+
? "text"
|
|
328
|
+
: field.schema.type === "number" || field.schema.type === "integer"
|
|
329
|
+
? "number"
|
|
330
|
+
: "json")
|
|
304
331
|
);
|
|
305
332
|
}
|
|
306
333
|
|
|
@@ -321,6 +348,7 @@ export function resolveSettingsFieldOptions(
|
|
|
321
348
|
visible?: unknown;
|
|
322
349
|
disabled?: unknown;
|
|
323
350
|
customEditor?: unknown;
|
|
351
|
+
menu?: unknown;
|
|
324
352
|
},
|
|
325
353
|
) {
|
|
326
354
|
if (metadata?.presentation && !metadata.preview) {
|
|
@@ -331,9 +359,24 @@ export function resolveSettingsFieldOptions(
|
|
|
331
359
|
(typeof metadata.group !== "string" || !metadata.group.trim())
|
|
332
360
|
)
|
|
333
361
|
throw new TypeError(`Settings group for "${id}" must be a non-empty string`);
|
|
334
|
-
for (const name of ["visible", "disabled", "customEditor"] as const)
|
|
362
|
+
for (const name of ["visible", "disabled", "customEditor", "menu"] as const)
|
|
335
363
|
if (metadata?.[name] !== undefined && typeof metadata[name] !== "function")
|
|
336
364
|
throw new TypeError(`Settings ${name} for "${id}" must be a function`);
|
|
365
|
+
if (metadata?.menu) {
|
|
366
|
+
if ((metadata.editor ?? "menu") !== "menu")
|
|
367
|
+
throw new TypeError(`Menu "${id}" conflicts with editor "${metadata.editor}"`);
|
|
368
|
+
if (
|
|
369
|
+
metadata.customEditor ||
|
|
370
|
+
metadata.choices ||
|
|
371
|
+
metadata.choiceSource ||
|
|
372
|
+
metadata.secret ||
|
|
373
|
+
metadata.preview
|
|
374
|
+
)
|
|
375
|
+
throw new TypeError(
|
|
376
|
+
`Menu "${id}" cannot use a custom editor, choices, secret or a preview; it opens its own fields`,
|
|
377
|
+
);
|
|
378
|
+
} else if (metadata?.editor === "menu")
|
|
379
|
+
throw new TypeError(`Editor "menu" requires a menu for "${id}"`);
|
|
337
380
|
if (metadata?.customEditor) {
|
|
338
381
|
if ((metadata.editor ?? "custom") !== "custom")
|
|
339
382
|
throw new TypeError(
|
|
@@ -359,6 +402,7 @@ export function resolveSettingsFieldOptions(
|
|
|
359
402
|
const editor = settingsEditor({
|
|
360
403
|
editor: metadata?.editor,
|
|
361
404
|
customEditor: metadata?.customEditor,
|
|
405
|
+
menu: metadata?.menu,
|
|
362
406
|
choiceSource: metadata?.choiceSource,
|
|
363
407
|
choices,
|
|
364
408
|
schema,
|
|
@@ -411,6 +455,58 @@ export function assertSettingsGroups(fields: readonly { group?: string }[]): voi
|
|
|
411
455
|
}
|
|
412
456
|
}
|
|
413
457
|
|
|
458
|
+
/** A row that opens a secondary menu; see createSettingsMenuField. */
|
|
459
|
+
export interface SettingsMenuFieldOptions {
|
|
460
|
+
/** Unique among the fields of the section or menu that lists the row. */
|
|
461
|
+
id: string;
|
|
462
|
+
label: string;
|
|
463
|
+
description?: string;
|
|
464
|
+
group?: string;
|
|
465
|
+
/** Scopes at which the menu can open; its own fields keep their own scopes. */
|
|
466
|
+
scopes: readonly SettingsScope[];
|
|
467
|
+
/** Text beside the label, such as a count of the menu's entries. */
|
|
468
|
+
summary?(context: ExtensionContext, scope: SettingsScope): string;
|
|
469
|
+
visible?(context: ExtensionContext, scope: SettingsScope): boolean;
|
|
470
|
+
disabled?(context: ExtensionContext, scope: SettingsScope): string | undefined;
|
|
471
|
+
/** Build the page; renderers call it again on every refresh while it is open. */
|
|
472
|
+
menu(context: ExtensionContext, scope: SettingsScope): SettingsMenu;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* Build a field whose row opens a secondary menu. The row has no value of its own, so
|
|
477
|
+
* set and reset reject: the menu's fields hold the values.
|
|
478
|
+
*/
|
|
479
|
+
export function createSettingsMenuField(options: SettingsMenuFieldOptions): SettingsPanelField {
|
|
480
|
+
const schema = Type.Null() as SettingsPanelSchema;
|
|
481
|
+
resolveSettingsFieldOptions(options.id, schema, options);
|
|
482
|
+
const refuse = () =>
|
|
483
|
+
Promise.reject(
|
|
484
|
+
new TypeError(`${options.label} is a menu; change the settings inside it instead`),
|
|
485
|
+
);
|
|
486
|
+
return {
|
|
487
|
+
id: options.id,
|
|
488
|
+
label: options.label,
|
|
489
|
+
description: options.description,
|
|
490
|
+
schema,
|
|
491
|
+
editor: "menu",
|
|
492
|
+
group: options.group,
|
|
493
|
+
scopes: options.scopes,
|
|
494
|
+
visible: options.visible,
|
|
495
|
+
disabled: options.disabled,
|
|
496
|
+
menu: options.menu,
|
|
497
|
+
formatValue: (_value, context, scope) => options.summary?.(context, scope) ?? "",
|
|
498
|
+
inspect: () => ({
|
|
499
|
+
defaultValue: null,
|
|
500
|
+
globalValue: undefined,
|
|
501
|
+
projectValue: undefined,
|
|
502
|
+
value: null,
|
|
503
|
+
source: "default",
|
|
504
|
+
}),
|
|
505
|
+
set: refuse,
|
|
506
|
+
reset: refuse,
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
|
|
414
510
|
/**
|
|
415
511
|
* Adapt top-level Settings keys to a custom section; no acquisition/hooks are installed.
|
|
416
512
|
*
|
|
@@ -35,6 +35,7 @@ export function scopedExtension(
|
|
|
35
35
|
try {
|
|
36
36
|
await resources.dispose();
|
|
37
37
|
} catch (cleanupError) {
|
|
38
|
+
// eslint-disable-next-line preserve-caught-error -- AggregateError.errors retains both failures.
|
|
38
39
|
throw new AggregateError(
|
|
39
40
|
[error, cleanupError],
|
|
40
41
|
"Extension setup and cleanup failed",
|
|
@@ -117,6 +117,7 @@ async function writeStored(file: string, stored: StoredSettings): Promise<void>
|
|
|
117
117
|
try {
|
|
118
118
|
await fs.rm(tmpPath, { force: true });
|
|
119
119
|
} catch (cleanupError) {
|
|
120
|
+
// eslint-disable-next-line preserve-caught-error -- AggregateError.errors retains both failures.
|
|
120
121
|
throw new AggregateError(
|
|
121
122
|
[error, cleanupError],
|
|
122
123
|
"Settings write and temporary file cleanup failed",
|