@gajae-code/tui 0.2.1 → 0.2.3
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 +6 -0
- package/dist/types/autocomplete.d.ts +5 -0
- package/package.json +3 -3
- package/src/autocomplete.ts +14 -5
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,11 @@ export interface SlashCommand {
|
|
|
10
10
|
name: string;
|
|
11
11
|
description?: string;
|
|
12
12
|
argumentHint?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Higher values surface first in autocomplete, ahead of fuzzy-score ordering.
|
|
15
|
+
* Use this to pin first-class commands (e.g. bundled GJC skills) to the top.
|
|
16
|
+
*/
|
|
17
|
+
priority?: number;
|
|
13
18
|
getArgumentCompletions?(argumentPrefix: string): Awaitable<AutocompleteItem[] | null>;
|
|
14
19
|
/** Return inline hint text for the current argument state (shown as dim ghost text after cursor) */
|
|
15
20
|
getInlineHint?(argumentText: string): string | null;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@gajae-code/tui",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.3",
|
|
5
5
|
"description": "Terminal User Interface library with differential rendering for efficient text-based applications",
|
|
6
6
|
"homepage": "https://gaebal-gajae.dev",
|
|
7
7
|
"author": "Yeachan-Heo",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"fmt": "biome format --write ."
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@gajae-code/natives": "0.2.
|
|
41
|
-
"@gajae-code/utils": "0.2.
|
|
40
|
+
"@gajae-code/natives": "0.2.3",
|
|
41
|
+
"@gajae-code/utils": "0.2.3",
|
|
42
42
|
"lru-cache": "11.3.6",
|
|
43
43
|
"marked": "^18.0.3"
|
|
44
44
|
},
|
package/src/autocomplete.ts
CHANGED
|
@@ -162,6 +162,11 @@ export interface SlashCommand {
|
|
|
162
162
|
name: string;
|
|
163
163
|
description?: string;
|
|
164
164
|
argumentHint?: string;
|
|
165
|
+
/**
|
|
166
|
+
* Higher values surface first in autocomplete, ahead of fuzzy-score ordering.
|
|
167
|
+
* Use this to pin first-class commands (e.g. bundled GJC skills) to the top.
|
|
168
|
+
*/
|
|
169
|
+
priority?: number;
|
|
165
170
|
// Function to get argument completions for this command
|
|
166
171
|
// Returns null if no argument completion is available
|
|
167
172
|
getArgumentCompletions?(argumentPrefix: string): Awaitable<AutocompleteItem[] | null>;
|
|
@@ -283,15 +288,17 @@ export class CombinedAutocompleteProvider implements AutocompleteProvider {
|
|
|
283
288
|
const hint = "argumentHint" in cmd && cmd.argumentHint ? cmd.argumentHint : undefined;
|
|
284
289
|
const desc = cmd.description ?? "";
|
|
285
290
|
const fullDesc = hint ? (desc ? `${hint} — ${desc}` : hint) : desc;
|
|
291
|
+
const priority = "priority" in cmd && typeof cmd.priority === "number" ? cmd.priority : 0;
|
|
286
292
|
return {
|
|
287
293
|
value: name,
|
|
288
294
|
label: "name" in cmd ? cmd.name : cmd.label,
|
|
289
295
|
score: Math.max(nameScore, descScore),
|
|
296
|
+
priority,
|
|
290
297
|
...(fullDesc && { description: fullDesc }),
|
|
291
298
|
};
|
|
292
299
|
})
|
|
293
|
-
.sort((a, b) => b.score - a.score)
|
|
294
|
-
.map(({ score:
|
|
300
|
+
.sort((a, b) => b.priority - a.priority || b.score - a.score)
|
|
301
|
+
.map(({ score: _score, priority: _priority, ...rest }) => rest);
|
|
295
302
|
|
|
296
303
|
if (matches.length === 0) return null;
|
|
297
304
|
|
|
@@ -820,15 +827,17 @@ export class CombinedAutocompleteProvider implements AutocompleteProvider {
|
|
|
820
827
|
const hint = "argumentHint" in cmd && cmd.argumentHint ? cmd.argumentHint : undefined;
|
|
821
828
|
const desc = cmd.description ?? "";
|
|
822
829
|
const fullDesc = hint ? (desc ? `${hint} — ${desc}` : hint) : desc;
|
|
830
|
+
const priority = "priority" in cmd && typeof cmd.priority === "number" ? cmd.priority : 0;
|
|
823
831
|
return {
|
|
824
832
|
value: name,
|
|
825
833
|
label: "name" in cmd ? cmd.name : cmd.label,
|
|
826
834
|
score: Math.max(nameScore, descScore),
|
|
835
|
+
priority,
|
|
827
836
|
...(fullDesc && { description: fullDesc }),
|
|
828
|
-
} as AutocompleteItem & { score: number };
|
|
837
|
+
} as AutocompleteItem & { score: number; priority: number };
|
|
829
838
|
})
|
|
830
|
-
.sort((a, b) => b.score - a.score)
|
|
831
|
-
.map(({ score:
|
|
839
|
+
.sort((a, b) => b.priority - a.priority || b.score - a.score)
|
|
840
|
+
.map(({ score: _score, priority: _priority, ...rest }) => rest);
|
|
832
841
|
|
|
833
842
|
if (matches.length === 0) return null;
|
|
834
843
|
return { items: matches, prefix: textBeforeCursor };
|