@danypops/jittor 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.
@@ -150,39 +150,33 @@ function usageSegment(context: FooterContext): string {
150
150
  return parts.join(" ");
151
151
  }
152
152
 
153
- function identityLines(context: FooterContext, footerData: FooterData, theme: FooterTheme, thinkingLevel: string, width: number): string[] {
153
+ function repositorySegment(context: FooterContext, footerData: FooterData, theme: FooterTheme): string {
154
154
  let cwd = footerCwd(context.sessionManager.getCwd(), process.env.HOME ?? process.env.USERPROFILE);
155
155
  const branch = footerData.getGitBranch();
156
156
  if (branch) cwd += ` (${branch})`;
157
157
  const sessionName = context.sessionManager.getSessionName();
158
158
  if (sessionName) cwd += ` · ${sessionName}`;
159
- const repo = `${theme.bold("Repo")} ${theme.fg("dim", cwd)}`;
159
+ return theme.fg("dim", cwd);
160
+ }
160
161
 
162
+ function modelSegments(context: FooterContext, footerData: FooterData, theme: FooterTheme, thinkingLevel: string): { full: string; compact: string } {
161
163
  const model = context.model;
164
+ const modelName = theme.bold(model?.id ?? "no-model");
162
165
  const provider = model && footerData.getAvailableProviderCount() > 1 ? `(${model.provider}) ` : "";
163
166
  const thinking = model?.reasoning ? ` · ${thinkingLevel === "off" ? "thinking off" : thinkingLevel}` : "";
164
- const ai = `${theme.bold("AI")} ${provider}${model?.id ?? "no-model"}${thinking}`;
165
- const gap = width - visibleWidth(repo) - visibleWidth(ai);
166
- if (gap >= 2) return [`${repo}${" ".repeat(gap)}${ai}`];
167
- return [truncateToWidth(repo, width, "…"), truncateToWidth(ai, width, "…")];
167
+ return { full: `${provider}${modelName}${thinking}`, compact: modelName };
168
168
  }
169
169
 
170
- function statusLines(context: FooterContext, budget: ProviderBudget | null, theme: FooterTheme, width: number, now: number): string[] {
171
- const usage = usageSegment(context);
172
- const fullContext = contextSegment(context, theme, width, false);
173
- const fullBudget = budgetSegment(budget, theme, width, false, now);
174
- const fullParts = [usage, fullContext, fullBudget].filter(Boolean);
175
- const full = `${theme.bold("LLM")} ${fullParts.join(" · ")}`;
176
- if (visibleWidth(full) <= width) return [full];
177
-
178
- const compactContext = contextSegment(context, theme, width, true);
179
- const compactBudget = budgetSegment(budget, theme, width, true, now);
180
- const compact = `${theme.bold("LLM")} ${compactContext} · ${compactBudget}`;
181
- if (visibleWidth(compact) <= width) return [compact];
182
- return [
183
- truncateToWidth(`${theme.bold("LLM")} ${compactContext}`, width, ""),
184
- truncateToWidth(`${theme.bold("LLM")} ${compactBudget}`, width, ""),
185
- ];
170
+ function compactUsageSegment(context: FooterContext): string {
171
+ const totals = usageTotals(context);
172
+ const parts: string[] = [];
173
+ if (totals.input) parts.push(`↑${formatTokens(totals.input)}`);
174
+ if (totals.output) parts.push(`↓${formatTokens(totals.output)}`);
175
+ return parts.join(" ");
176
+ }
177
+
178
+ function joinSegments(segments: Array<string | undefined>): string {
179
+ return segments.filter((segment): segment is string => Boolean(segment)).join(" · ");
186
180
  }
187
181
 
188
182
  export function renderFooterLines(
@@ -195,16 +189,31 @@ export function renderFooterLines(
195
189
  now = Date.now(),
196
190
  ): string[] {
197
191
  const safeWidth = Math.max(1, width);
198
- const lines = [
199
- ...identityLines(context, footerData, theme, thinkingLevel, safeWidth),
200
- ...statusLines(context, providerBudget, theme, safeWidth, now),
201
- ];
192
+ const repository = repositorySegment(context, footerData, theme);
193
+ const model = modelSegments(context, footerData, theme, thinkingLevel);
194
+ const usage = usageSegment(context);
195
+ const compactUsage = compactUsageSegment(context);
196
+ const fullContext = contextSegment(context, theme, safeWidth, false);
197
+ const compactContext = contextSegment(context, theme, safeWidth, true);
198
+ const fullBudget = budgetSegment(providerBudget, theme, safeWidth, false, now);
199
+ const compactBudget = budgetSegment(providerBudget, theme, safeWidth, true, now);
202
200
  const statuses = [...footerData.getExtensionStatuses().entries()]
203
201
  .filter(([key]) => key !== "jittor")
204
202
  .sort(([leftKey], [rightKey]) => leftKey.localeCompare(rightKey))
205
- .map(([, text]) => sanitize(text));
206
- if (statuses.length > 0) lines.push(truncateToWidth(statuses.join(" "), safeWidth, theme.fg("dim", "…")));
207
- return lines.map((line) => truncateToWidth(line, safeWidth, ""));
203
+ .map(([, text]) => sanitize(text))
204
+ .join(" ");
205
+
206
+ const candidates = [
207
+ joinSegments([repository, model.full, usage, fullContext, fullBudget, statuses]),
208
+ joinSegments([repository, model.full, usage, fullContext, fullBudget]),
209
+ joinSegments([model.full, usage, compactContext, compactBudget, statuses]),
210
+ joinSegments([model.full, usage, compactContext, compactBudget]),
211
+ joinSegments([model.full, compactUsage, compactContext, compactBudget]),
212
+ joinSegments([model.compact, compactUsage, compactContext, compactBudget]),
213
+ joinSegments([model.compact, compactContext, compactBudget]),
214
+ ];
215
+ const line = candidates.find((candidate) => visibleWidth(candidate) <= safeWidth) ?? candidates.at(-1) ?? "";
216
+ return [truncateToWidth(line, safeWidth, "")];
208
217
  }
209
218
 
210
219
  export interface IntegratedFooterState {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danypops/jittor",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Just-in-Time Token Optimizing Router for Pi",
5
5
  "type": "module",
6
6
  "keywords": ["pi-package", "llm-router", "token-budget"],
package/src/constants.ts CHANGED
@@ -1,4 +1,4 @@
1
- export const VERSION = "0.1.0";
1
+ export const VERSION = "0.1.1";
2
2
  export const SQLITE_SCHEMA_VERSION = 1;
3
3
  export const SQLITE_BUSY_TIMEOUT_MS = 5_000;
4
4
  export const DEFAULT_QUERY_LIMIT = 1_000;