pi-sage 0.2.5 → 0.2.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.
- package/.pi/extensions/sage/index.ts +45 -3
- package/package.json +1 -1
|
@@ -372,7 +372,7 @@ async function runSettingsWizard(ctx: ExtensionCommandContext): Promise<void> {
|
|
|
372
372
|
let scope: SettingsScope = loaded.source === "global" ? "global" : "project";
|
|
373
373
|
|
|
374
374
|
while (true) {
|
|
375
|
-
const action = await ctx
|
|
375
|
+
const action = await selectPaged(ctx, "Sage settings", [
|
|
376
376
|
`Enabled: ${onOff(draft.enabled)}`,
|
|
377
377
|
`Autonomous mode: ${onOff(draft.autonomousEnabled)}`,
|
|
378
378
|
`Explicit requests bypass soft limits: ${onOff(draft.explicitRequestAlwaysAllowed)}`,
|
|
@@ -556,7 +556,7 @@ async function pickModel(ctx: ExtensionContext, currentModel: string): Promise<s
|
|
|
556
556
|
})
|
|
557
557
|
];
|
|
558
558
|
|
|
559
|
-
const providerChoice = await ctx
|
|
559
|
+
const providerChoice = await selectPaged(ctx, "Choose Sage model provider", providerOptions);
|
|
560
560
|
if (!providerChoice) return undefined;
|
|
561
561
|
|
|
562
562
|
if (providerChoice.startsWith(MODEL_INHERIT_VALUE)) {
|
|
@@ -587,7 +587,7 @@ async function pickModel(ctx: ExtensionContext, currentModel: string): Promise<s
|
|
|
587
587
|
modelOptionMap.set(option, composite);
|
|
588
588
|
}
|
|
589
589
|
|
|
590
|
-
const modelChoice = await ctx
|
|
590
|
+
const modelChoice = await selectPaged(ctx, `Choose Sage model (${provider})`, modelOptions);
|
|
591
591
|
if (!modelChoice) return undefined;
|
|
592
592
|
if (modelChoice === "← Back to providers") continue;
|
|
593
593
|
|
|
@@ -662,6 +662,48 @@ function resolveModelSpec(
|
|
|
662
662
|
return { modelArg: `${first.provider}/${first.id}`, reason: "first available fallback" };
|
|
663
663
|
}
|
|
664
664
|
|
|
665
|
+
type HasUIContext = { ui: ExtensionContext["ui"] };
|
|
666
|
+
|
|
667
|
+
async function selectPaged(
|
|
668
|
+
ctx: HasUIContext,
|
|
669
|
+
title: string,
|
|
670
|
+
options: string[],
|
|
671
|
+
pageSize = 10
|
|
672
|
+
): Promise<string | undefined> {
|
|
673
|
+
if (options.length <= pageSize) {
|
|
674
|
+
return await ctx.ui.select(title, options);
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
let page = 0;
|
|
678
|
+
const totalPages = Math.max(1, Math.ceil(options.length / pageSize));
|
|
679
|
+
const PREV = "← Previous page";
|
|
680
|
+
const NEXT = "→ Next page";
|
|
681
|
+
|
|
682
|
+
while (true) {
|
|
683
|
+
const start = page * pageSize;
|
|
684
|
+
const end = Math.min(start + pageSize, options.length);
|
|
685
|
+
const pageOptions = options.slice(start, end);
|
|
686
|
+
|
|
687
|
+
if (page > 0) pageOptions.push(PREV);
|
|
688
|
+
if (page < totalPages - 1) pageOptions.push(NEXT);
|
|
689
|
+
|
|
690
|
+
const selected = await ctx.ui.select(`${title} (${start + 1}-${end} of ${options.length})`, pageOptions);
|
|
691
|
+
if (!selected) return undefined;
|
|
692
|
+
|
|
693
|
+
if (selected === PREV && page > 0) {
|
|
694
|
+
page -= 1;
|
|
695
|
+
continue;
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
if (selected === NEXT && page < totalPages - 1) {
|
|
699
|
+
page += 1;
|
|
700
|
+
continue;
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
return selected;
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
|
|
665
707
|
function onOff(value: boolean): string {
|
|
666
708
|
return value ? "on" : "off";
|
|
667
709
|
}
|