@0xkahi/pi-qol 0.1.0 → 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.
@@ -131,6 +131,17 @@
131
131
  "minLength": 1
132
132
  }
133
133
  },
134
+ "default_reasoning": {
135
+ "type": "string",
136
+ "enum": [
137
+ "off",
138
+ "minimal",
139
+ "low",
140
+ "medium",
141
+ "high",
142
+ "xhigh"
143
+ ]
144
+ },
134
145
  "layout": {
135
146
  "default": "inline",
136
147
  "type": "string",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xkahi/pi-qol",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "quality of life pi extensions",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -1,22 +1,27 @@
1
- import type { Api, Model } from '@earendil-works/pi-ai';
1
+ import { type Api, getSupportedThinkingLevels, type Model } from '@earendil-works/pi-ai';
2
2
  import type { ExtensionAPI, ExtensionCommandContext, ExtensionContext } from '@earendil-works/pi-coding-agent';
3
3
  import type { ConfigLoader } from '../../config-loader';
4
+ import type { ModelSelectConfig } from '../../schemas/model-select.config.schema';
4
5
  import { COMMAND_NAME, PI_VIM_KEY_EVENT_ID } from './constants';
5
6
  import { ModelFormatter } from './model-formatter';
6
7
  import { buildModelLists, findExactModel } from './model-lists';
7
8
  import { ModelSelectDialog } from './model-select-dialog';
8
9
  import type { DialogResult } from './types';
9
10
 
10
- async function applySelectedModel(pi: ExtensionAPI, ctx: ExtensionContext, model: Model<Api>): Promise<void> {
11
+ export async function applySelectedModel(pi: ExtensionAPI, ctx: ExtensionContext, model: Model<Api>, config: ModelSelectConfig): Promise<void> {
11
12
  const success = await pi.setModel(model);
12
13
  if (success) {
14
+ const defaultReasoning = config.default_reasoning;
15
+ if (defaultReasoning && getSupportedThinkingLevels(model).includes(defaultReasoning)) {
16
+ pi.setThinkingLevel(defaultReasoning);
17
+ }
13
18
  ctx.ui.notify(`Model set to ${ModelFormatter.modelLabel(model)}`, 'info');
14
19
  } else {
15
20
  ctx.ui.notify(`No configured auth for ${ModelFormatter.modelLabel(model)}`, 'error');
16
21
  }
17
22
  }
18
23
 
19
- async function showModelSelector(pi: ExtensionAPI, args: string, ctx: ExtensionContext, configLoader: ConfigLoader): Promise<void> {
24
+ export async function showModelSelector(pi: ExtensionAPI, args: string, ctx: ExtensionContext, configLoader: ConfigLoader): Promise<void> {
20
25
  // `waitForIdle` only exists on command contexts. When invoked from the event
21
26
  // bus we get a plain ExtensionContext, so fall back to a best-effort guard.
22
27
  if ('waitForIdle' in ctx && typeof ctx.waitForIdle === 'function') {
@@ -24,9 +29,10 @@ async function showModelSelector(pi: ExtensionAPI, args: string, ctx: ExtensionC
24
29
  }
25
30
  ctx.modelRegistry.refresh();
26
31
 
32
+ const config = configLoader.getModelSelect();
27
33
  const exactModel = findExactModel(ctx, args);
28
34
  if (exactModel) {
29
- await applySelectedModel(pi, ctx, exactModel);
35
+ await applySelectedModel(pi, ctx, exactModel, config);
30
36
  return;
31
37
  }
32
38
 
@@ -35,7 +41,6 @@ async function showModelSelector(pi: ExtensionAPI, args: string, ctx: ExtensionC
35
41
  return;
36
42
  }
37
43
 
38
- const config = configLoader.getModelSelect();
39
44
  const modelLists = await buildModelLists(ctx, config);
40
45
  const registryError = ctx.modelRegistry.getError();
41
46
 
@@ -51,6 +56,7 @@ async function showModelSelector(pi: ExtensionAPI, args: string, ctx: ExtensionC
51
56
  hideGroupTabs: config.hide_tabs.groups,
52
57
  hideSearchTab: config.hide_tabs.search,
53
58
  providerFilter: config.provider_filter,
59
+ defaultReasoning: config.default_reasoning,
54
60
  configWarnings: registryError ? [`models.json: ${registryError}`] : [],
55
61
  initialSearch: args.trim(),
56
62
  layout: config.layout,
@@ -69,7 +75,7 @@ async function showModelSelector(pi: ExtensionAPI, args: string, ctx: ExtensionC
69
75
  );
70
76
 
71
77
  if (selected) {
72
- await applySelectedModel(pi, ctx, selected);
78
+ await applySelectedModel(pi, ctx, selected, config);
73
79
  }
74
80
  }
75
81
 
@@ -217,7 +217,8 @@ export class ModelSelectDialog implements Component, Focusable {
217
217
 
218
218
  private renderTitle(): string {
219
219
  const current = this.options.currentModel ? ModelFormatter.modelLabel(this.options.currentModel) : 'none';
220
- return `${this.theme.fg('customMessageLabel', this.theme.bold('Select Model'))} ${this.theme.fg('muted', `current: ${current}`)}`;
220
+ const reasoning = this.options.defaultReasoning ? ` • reasoning: ${this.options.defaultReasoning}` : '';
221
+ return `${this.theme.fg('customMessageLabel', this.theme.bold('Select Model'))} ${this.theme.fg('muted', `current: ${current}${reasoning}`)}`;
221
222
  }
222
223
 
223
224
  private renderTabs(width: number): string {
@@ -1,5 +1,6 @@
1
1
  import type { Api, Model } from '@earendil-works/pi-ai';
2
2
  import type { ModelSelectLayout } from '../../schemas/model-select.config.schema';
3
+ import type { ReasoningLevel } from '../../schemas/shared-config.schema';
3
4
 
4
5
  export type ModelItem = {
5
6
  model: Model<Api>;
@@ -33,6 +34,7 @@ export type DialogOptions = {
33
34
  hideGroupTabs: boolean;
34
35
  hideSearchTab: boolean;
35
36
  providerFilter: string[];
37
+ defaultReasoning?: ReasoningLevel;
36
38
  configWarnings: string[];
37
39
  initialSearch: string;
38
40
  layout: ModelSelectLayout;
@@ -1,5 +1,5 @@
1
1
  import z from 'zod';
2
- import { ModelConfigSchema } from './shared-config.schema';
2
+ import { ModelConfigSchema, ReasoningLevelSchema } from './shared-config.schema';
3
3
 
4
4
  const NonEmptyNameSchema = z.string().min(1);
5
5
 
@@ -22,6 +22,7 @@ export const ModelSelectConfigSchema = z.object({
22
22
  groups: z.array(NonEmptyNameSchema).default([]),
23
23
  hide_tabs: HideTabsSchema.default({ groups: false, search: false }),
24
24
  provider_filter: z.array(NonEmptyNameSchema).default([]),
25
+ default_reasoning: ReasoningLevelSchema.optional(),
25
26
  layout: ModelSelectLayoutSchema.default('inline'),
26
27
  });
27
28
  export type ModelSelectConfig = z.infer<typeof ModelSelectConfigSchema>;
@@ -44,6 +45,7 @@ export const PartialModelSelectConfigSchema = z.object({
44
45
  })
45
46
  .optional(),
46
47
  provider_filter: z.array(NonEmptyNameSchema).optional(),
48
+ default_reasoning: ReasoningLevelSchema.optional(),
47
49
  layout: ModelSelectLayoutSchema.optional(),
48
50
  });
49
51
  export type PartialModelSelectConfig = z.infer<typeof PartialModelSelectConfigSchema>;