@danypops/pi-jittor 0.6.0 → 0.7.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.
@@ -52,7 +52,12 @@ import {
52
52
  import { ContextGrowthCapability } from "./observability/context-growth.ts";
53
53
  import { ContextHubCapability } from "./observability/context-hub.ts";
54
54
  import { showContextView } from "./observability/context-view.ts";
55
- import { type CompactionProgress, type IntegratedFooterState, installIntegratedFooter } from "./observability/footer.ts";
55
+ import {
56
+ type CompactionProgress,
57
+ type IntegratedFooterState,
58
+ installIntegratedFooter,
59
+ type RouterFooterInfo,
60
+ } from "./observability/footer.ts";
56
61
  import { LocalRunTelemetry } from "./observability/model-run.ts";
57
62
  import { captureProviderContextSnapshot } from "./observability/provider-context-snapshot.ts";
58
63
  import { ProviderResponseTelemetry } from "./observability/provider-response.ts";
@@ -623,7 +628,13 @@ export function registerJittorExtension(
623
628
  else footerState.requestRender?.();
624
629
  };
625
630
  const showFooter = (ctx: ExtensionContext): void => {
626
- if (enforcement.isFooterEnabled()) installIntegratedFooter(ctx, footerState, () => pi.getThinkingLevel());
631
+ if (enforcement.isFooterEnabled())
632
+ installIntegratedFooter(
633
+ ctx,
634
+ footerState,
635
+ () => pi.getThinkingLevel(),
636
+ (): RouterFooterInfo => ({ autoMode: autoMode.getAutoMode() }),
637
+ );
627
638
  else ctx.ui.setFooter(undefined);
628
639
  };
629
640
  const disable = async (ctx: ExtensionContext): Promise<void> => {
@@ -69,6 +69,11 @@ export type ProviderBudget =
69
69
  valueText: string;
70
70
  };
71
71
 
72
+ /** Compact, always-visible state of Jittor's effort-based Auto mode -- the newer, effort-driven router, distinct from the existing budget-pressure route already reflected by the model/budget segments. */
73
+ export interface RouterFooterInfo {
74
+ autoMode: "off" | "suggest" | "auto-switch";
75
+ }
76
+
72
77
  export interface CompactionProgress {
73
78
  startedAt: number;
74
79
  initialFraction: number;
@@ -238,6 +243,19 @@ function budgetSegment(
238
243
  return `${budget.label} ${bar} ${value}${reset ? ` · ${reset}` : ""}${staleText}`;
239
244
  }
240
245
 
246
+ /**
247
+ * "off" is dim (nothing happening); "suggest" is plain/unstyled -- it evaluates and may prompt,
248
+ * but only ever acts on explicit confirmation; "auto-switch" alone gets the eye-catching accent
249
+ * color, since it is the only state that can change the active model without asking first --
250
+ * the same distinction that already gates entering it behind an explicit settings confirmation.
251
+ */
252
+ function routerSegment(info: RouterFooterInfo | undefined, theme: FooterTheme): string | undefined {
253
+ if (!info) return undefined;
254
+ if (info.autoMode === "off") return `auto ${theme.fg("dim", info.autoMode)}`;
255
+ if (info.autoMode === "auto-switch") return `auto ${theme.fg("accent", info.autoMode)}`;
256
+ return `auto ${info.autoMode}`;
257
+ }
258
+
241
259
  function usageSegment(context: FooterContext): string {
242
260
  const totals = usageTotals(context);
243
261
  const parts: string[] = [];
@@ -295,6 +313,7 @@ export function renderFooterLines(
295
313
  width: number,
296
314
  now = Date.now(),
297
315
  compaction?: CompactionProgress,
316
+ router?: RouterFooterInfo,
298
317
  ): string[] {
299
318
  const safeWidth = Math.max(1, width);
300
319
  const repository = repositorySegment(context, footerData, theme);
@@ -306,6 +325,7 @@ export function renderFooterLines(
306
325
  const minimalContext = minimalContextSegment(context, theme, safeWidth, now, compaction);
307
326
  const fullBudget = budgetSegment(providerBudget, theme, safeWidth, false, now);
308
327
  const compactBudget = budgetSegment(providerBudget, theme, safeWidth, true, now);
328
+ const routerInfo = routerSegment(router, theme);
309
329
  const statuses = [...footerData.getExtensionStatuses().entries()]
310
330
  .filter(([key]) => key !== "jittor")
311
331
  .sort(([leftKey], [rightKey]) => leftKey.localeCompare(rightKey))
@@ -313,8 +333,11 @@ export function renderFooterLines(
313
333
  .join(" ");
314
334
 
315
335
  const candidates = [
336
+ joinSegments([repository, model.full, usage, fullContext, fullBudget, routerInfo, statuses]),
337
+ joinSegments([repository, model.full, usage, fullContext, fullBudget, routerInfo]),
316
338
  joinSegments([repository, model.full, usage, fullContext, fullBudget, statuses]),
317
339
  joinSegments([repository, model.full, usage, fullContext, fullBudget]),
340
+ joinSegments([model.full, usage, compactContext, compactBudget, routerInfo, statuses]),
318
341
  joinSegments([model.full, usage, compactContext, compactBudget, statuses]),
319
342
  joinSegments([model.full, usage, compactContext, compactBudget]),
320
343
  joinSegments([model.full, compactUsage, compactContext, compactBudget]),
@@ -332,7 +355,14 @@ export interface IntegratedFooterState {
332
355
  requestRender?: () => void;
333
356
  }
334
357
 
335
- export function installIntegratedFooter(ctx: ExtensionContext, state: IntegratedFooterState, getThinkingLevel: () => string): void {
358
+ export function installIntegratedFooter(
359
+ ctx: ExtensionContext,
360
+ state: IntegratedFooterState,
361
+ getThinkingLevel: () => string,
362
+ // Called fresh every render, the same as getThinkingLevel -- Auto mode's setting can change at
363
+ // any time via /jittor settings, so the footer must never cache a stale snapshot of it.
364
+ getRouterInfo: () => RouterFooterInfo | undefined = () => undefined,
365
+ ): void {
336
366
  ctx.ui.setStatus("jittor", undefined);
337
367
  ctx.ui.setFooter((tui, theme, footerData) => {
338
368
  state.requestRender = () => tui.requestRender();
@@ -349,6 +379,7 @@ export function installIntegratedFooter(ctx: ExtensionContext, state: Integrated
349
379
  width,
350
380
  Date.now(),
351
381
  state.compaction,
382
+ getRouterInfo(),
352
383
  );
353
384
  },
354
385
  dispose() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danypops/pi-jittor",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Pi extension for Jittor token and context observability with optimization controls backed by the @danypops/jittor daemon",
5
5
  "license": "MIT",
6
6
  "type": "module",