diff --git a/ai/chatgpt/CHANGELOG.md b/ai/chatgpt/CHANGELOG.md index 6c401b4..5512b13 100644 --- a/ai/chatgpt/CHANGELOG.md +++ b/ai/chatgpt/CHANGELOG.md @@ -1,5 +1,23 @@ # Changelog +## [1.2.2] - 2026-11-10 + +### Changed + +- Merged quota observations and recovery scenarios into Usage Quota V2. +- Removed the separate Quota Insights feature registration while preserving stored observations. +- Added GitHub-like light and dark code palettes that follow explicit site themes. +- Expanded language labels, detection signatures and colored typographic badges. +- Scoped composer tools to a single toolbar after native mode controls. +- Bounded full-width content with border-box sizing and a small outer gutter. + +### Fixed + +- Known positive usage counts with unknown capacity are labelled Reported. +- Usage headers and detailed dialogs use the same quota-ledger summaries. +- Sidebar visibility restores original inline display styles. +- Nested width wrappers no longer accumulate gutters after navigation. + ## [1.2.1] - 2026-11-10 ### Added diff --git a/ai/chatgpt/README.md b/ai/chatgpt/README.md index cce8f06..6363129 100644 --- a/ai/chatgpt/README.md +++ b/ai/chatgpt/README.md @@ -16,8 +16,7 @@ Updates arrive automatically. The script also checks on its own and offers to up | Feature | What you get | | ----------------- | ---------------------------------------------------------------------------------------------------------------------- | -| Usage Status | Remaining counts reported by ChatGPT, your plan, and low/empty alerts; totals and reset schedules are not inferred | -| Quota Insights | Persistent counter observations, observed capacity lower bounds, last net increase, and conditional recovery scenarios | +| Usage Quota V2 | Remaining counts reported by ChatGPT, your plan, and low/empty alerts; totals and reset schedules are not inferred | | Code Blocks V2 | Language badges, syntax colours, line numbers, wrap, fold, download, indentation-safe copy | | Message Splitter | Paste any amount of text; split into parts or attach as a file only when needed | | Prompt Library | Your prompts plus community prompts, with a form for placeholders | @@ -45,7 +44,7 @@ Updates arrive automatically. The script also checks on its own and offers to up All of them can be changed from the settings dialog. -Usage Status shows reported remaining counts only; it does not invent totals or reset schedules. The `/wham/usage` endpoint is not displayed as the ordinary chat quota. +Usage Quota V2 shows reported remaining counts only; it does not invent totals or reset schedules. The `/wham/usage` endpoint is not displayed as the ordinary chat quota. ## Privacy @@ -80,3 +79,7 @@ bun run build # minified userscript in dist/ ## PDF reports PDF export opens a print-ready preview with a contents list, readable sections, code panels and tables. Use Print / Save as PDF in the preview. See [PDF reports](docs/pdf-reports.md) for print settings and machine-reading limitations. + +## Usage Quota V2 + +The header usage dialog combines reported allowances, capacity evidence and observation-based recovery scenarios. See [Usage Quota V2](docs/usage-quota-v2.md). diff --git a/ai/chatgpt/docs/code-blocks-v2.md b/ai/chatgpt/docs/code-blocks-v2.md index 8cca0f6..653deaf 100644 --- a/ai/chatgpt/docs/code-blocks-v2.md +++ b/ai/chatgpt/docs/code-blocks-v2.md @@ -33,3 +33,9 @@ Open Help and select Code blocks. The tour highlights the block and its toolbar. ## Verification Copy a selection containing blank lines, tabs and nested indentation into a plain-text editor. Verify the result before using copied code in a project. + +## Themes and language badges + +Code panels follow the site's explicit light/dark theme, with a GitHub-like syntax palette. Language badges retain their language-associated colors. Badges are typographic representations, not official logo artwork. + +Additional filename labels and conservative content signatures improve detection. New language labels may use an approximate syntax palette or plain text; the original source remains authoritative. diff --git a/ai/chatgpt/docs/quota-insights.md b/ai/chatgpt/docs/quota-insights.md index 078b910..d373042 100644 --- a/ai/chatgpt/docs/quota-insights.md +++ b/ai/chatgpt/docs/quota-insights.md @@ -1,48 +1,14 @@ --- -title: Quota insights -description: Capacity evidence, observed recovery and conditional forecasts. -section: Guides -order: 25 +title: Quota Insights migration +description: Quota Insights is now part of Usage Quota V2. +section: Reference +order: 810 --- -# Quota insights +# Quota Insights is now Usage Quota V2 -Open Settings → Quota Insights → Open Quota Insights, or find it in the command palette. +The separate feature has been removed. Its observation ledger and saved history remain in use. -## What is recorded +Open the header usage dialog to see reported counts and recovery scenarios together. -The feature stores remaining counts, observation times, explicit API caps and reported reset timestamps. It does not store conversation text. - -History is limited to 30 days and 2,000 observations per counter. - -## Maximum allowance - -An observed peak means capacity is at least that large. A plateau does not prove the maximum. - -Full-recovery scenarios require an explicit API cap. A reported reset timestamp alone does not establish the refill amount. - -## Recovery calculations - -Positive changes are observed net recovery. Additional spending between observations can hide refill. - -The engine calculates an observed net recovery rate across comparable intervals. It excludes gaps longer than five minutes and intervals known to be cap-bound. - -Rate scenarios require 30 minutes of comparable observations, at least three positive intervals and a recent observation. - -## Forecasts - -The panel can show conditional +1, +5, full recovery and recovery within a selected number of minutes. - -These scenarios assume the observed net recovery rate continues and no additional units are spent. They are not guaranteed refill schedules or calibrated confidence intervals. - -Rolling-window recovery and batch resets can behave differently. The existing Perplexity rolling estimator remains separate. - -## Privacy and account changes - -Saved observations are local to each userscript. - -Perplexity uses its existing account/tier namespace. ChatGPT currently partitions by reported plan, not a verified account id. Do not mix accounts in the same userscript storage when evaluating its history. - -## Tutorial - -The Help menu includes a Quota insights walkthrough explaining observations, lower bounds and projections. +See [Usage Quota V2](usage-quota-v2.md). diff --git a/ai/chatgpt/docs/usage-quota-v2.md b/ai/chatgpt/docs/usage-quota-v2.md new file mode 100644 index 0000000..81d6d35 --- /dev/null +++ b/ai/chatgpt/docs/usage-quota-v2.md @@ -0,0 +1,40 @@ +--- +title: Usage Quota V2 +description: Reported counts, capacity evidence and recovery scenarios in one usage feature. +section: Guides +order: 25 +--- + +# Usage Quota V2 + +Click the usage control in the header. The main usage dialog now contains the observation engine previously shown separately as Quota Insights. + +## Reported counts and capacity + +A known count is labelled Reported even when capacity is unknown. + +API-reported capacity is shown separately from the observed maximum. An observed maximum is only a lower bound. It does not prove the account's maximum allowance. + +## Recovery calculations + +The dialog shows the last observed net increase, comparable sampling time, net recovery, net spending and conditional recovery scenarios. + +You can choose a recovery horizon. When sufficient observations exist, the same engine supplies +1, +5, recovery within that horizon and full-recovery scenarios. + +Full recovery requires an explicit API capacity. A reset timestamp alone does not establish the refill amount. + +## Interpretation + +Rate scenarios assume no additional spending and an unchanged observed net recovery rate. They are not guarantees or calibrated confidence intervals. + +Long gaps, hidden spending, cap changes and activity in other clients affect the calculation. Unknown results are not replaced with invented countdowns. + +## Storage and account scope + +Existing quota observations are preserved. + +Perplexity reports are requested using its current account/tier namespace. ChatGPT currently partitions by reported plan rather than a verified account id. Avoid mixing ChatGPT accounts in the same userscript storage. + +## Tutorial + +Open Help and choose Usage Quota V2. There is no separate Quota Insights module to enable. diff --git a/ai/chatgpt/package.json b/ai/chatgpt/package.json index 881c49f..36e4211 100644 --- a/ai/chatgpt/package.json +++ b/ai/chatgpt/package.json @@ -1,6 +1,6 @@ { "name": "@nolly/ai-chatgpt", - "version": "1.2.1", + "version": "1.2.2", "private": true, "type": "module", "license": "PolyForm-Strict-1.0.0", diff --git a/ai/chatgpt/src/features/usage.ts b/ai/chatgpt/src/features/usage.ts index 45baaa3..7d9dc8d 100644 --- a/ai/chatgpt/src/features/usage.ts +++ b/ai/chatgpt/src/features/usage.ts @@ -1,4 +1,5 @@ -import { Tooltip, createButton, createDataRow, createDialog, createSection, ensureUiStyles, markUi, showToast, uiConfig } from '@nolly/ai' +import { Tooltip, createButton, createDataRow, createDialog, createQuotaPanel, ensureUiStyles, markUi, quotaSummary, showToast, uiConfig } from '@nolly/ai' +import type { QuotaPanel } from '@nolly/ai' import { Feature, createElement, injectStyle } from '@nolly/core' import type { MenuEntry, ScriptContext } from '@nolly/core' import { placeTool } from '../header-tools' @@ -34,12 +35,13 @@ const expired = (iso: string | null): boolean => { export class UsageFeature extends Feature { readonly id = 'usage-status' - readonly name = 'Usage Status' + readonly name = 'Usage Quota V2' readonly description = 'Shows reported tool allowances without inventing a chat-message quota.' private readonly pill = markUi(createElement('button', `${PILL_BUTTON_CLASS} bp-usage-pill bp-themed`)) private readonly label = createElement('span') private readonly tooltip: Tooltip + private panel: QuotaPanel | null = null constructor(context: ScriptContext) { super(context) @@ -101,6 +103,8 @@ export class UsageFeature extends Feature { const entry = session.limit(this.primary) const stale = entry ? expired(entry.resetAfter) : false this.label.textContent = entry ? `${labelOf(entry.feature)} ${stale ? '—' : entry.remaining}` : 'Tool usage' + const report = session.getQuotaReports().find((item) => item.key === this.primary) ?? null + this.pill.title = quotaSummary(report) this.pill.dataset['level'] = !entry || stale ? 'ok' : entry.remaining <= 0 ? 'empty' : entry.remaining <= LOW ? 'low' : 'ok' this.tooltip.refresh() } @@ -127,29 +131,8 @@ export class UsageFeature extends Feature { return list } - private body(): HTMLElement[] { - const limits = createSection('Reported tool allowances') - limits.appendChild(this.rows()) - const explanation = createElement('p', 'bp-hint', 'These are tool counters returned by ChatGPT, not a verified total chat-message allowance. Totals are not supplied. Counts refresh when ChatGPT returns new data; elapsed reset times do not imply a confirmed refill.') - const nodes = [limits, explanation] - if (session.maxFileMb !== null) { - const files = createSection('Reported attachment ceiling') - files.appendChild(createDataRow('General file ceiling', `${session.maxFileMb} MB`)) - files.appendChild(createElement('p', 'bp-hint', 'File-type and account restrictions can be lower.')) - nodes.push(files) - } - if (session.usage) nodes.push(createElement('p', 'bp-hint', 'The separate /wham/usage window is excluded because it has not been established as the quota for this chat.')) - return nodes - } - private renderOpenDialog(): void { - const dialog = document.getElementById(this.dialogId) - if (!(dialog instanceof HTMLDialogElement) || !dialog.open) return - const body = dialog.querySelector('.bp-dialog-body') - if (!body) return - const top = body.scrollTop - body.replaceChildren(...this.body()) - body.scrollTop = top + this.panel?.refresh() } private open(): void { @@ -158,8 +141,16 @@ export class UsageFeature extends Feature { existing.close() return } - const ui = createDialog({ id: this.dialogId, title: 'Usage', description: session.plan ? `Reported plan: ${session.plan}` : 'Plan not reported', width: 600 }) - ui.body.append(...this.body()) + const ui = createDialog({ id: this.dialogId, title: this.name, description: session.plan ? `Reported plan: ${session.plan}` : 'Plan not reported', width: 760 }) + this.panel = createQuotaPanel(() => session.getQuotaReports()) + const panel = this.panel + ui.body.appendChild(panel.element) + if (session.maxFileMb !== null) ui.body.appendChild(createDataRow('API-reported general attachment ceiling', `${session.maxFileMb} MB · type-specific restrictions may be lower`)) + ui.body.appendChild(createElement('p', 'bp-hint', 'ChatGPT history is currently separated by reported plan, not a verified account id. Do not mix accounts in the same userscript storage. The unrelated /wham usage window is not treated as this chat’s quota.')) + ui.dialog.addEventListener('close', () => { + panel.destroy() + if (this.panel === panel) this.panel = null + }, { once: true }) ui.footer.append(createButton('Close', { primary: true, onClick: ui.close })) ui.show() } diff --git a/ai/chatgpt/src/main.ts b/ai/chatgpt/src/main.ts index bf17480..4d184e1 100644 --- a/ai/chatgpt/src/main.ts +++ b/ai/chatgpt/src/main.ts @@ -16,7 +16,6 @@ import { UpdatesFeature, configurePlatform, configureUi, - QuotaInsightsFeature } from '@nolly/ai' import { App } from './app' import { fileBudget } from './budget' @@ -92,7 +91,6 @@ whenReady(() => { .register((context) => new ExporterFeature(context)) .register((context) => new UpdatesFeature(context)) .register((context) => new UsageFeature(context)) - .register((context) => new QuotaInsightsFeature(context)) .register((context) => new TutorialFeature(context)) .register((context) => new DiagnosticsFeature(context)) .start() diff --git a/ai/chatgpt/src/session.ts b/ai/chatgpt/src/session.ts index c663a0a..126c25c 100644 --- a/ai/chatgpt/src/session.ts +++ b/ai/chatgpt/src/session.ts @@ -7,6 +7,7 @@ import { interpret } from './stream' import type { ChatEvent } from './stream' import { QuotaLedger } from '@nolly/ai' import { storage } from './storage' +import type { QuotaReport } from '@nolly/ai' export type SessionEvent = 'generation-start' | 'generation-end' | 'conversation' | 'model' | 'limits' | 'usage' | 'plan' | 'user-message' @@ -55,6 +56,10 @@ export class ChatSession { } } + getQuotaReports(): QuotaReport[] { + return this.quotaLedger.reports(Date.now(), `chatgpt:${this.plan ?? 'unidentified'}`) + } + private emit(event: SessionEvent): void { for (const listener of this.listeners) { try { diff --git a/ai/chatgpt/src/tours.ts b/ai/chatgpt/src/tours.ts index fd5b3be..ec4a139 100644 --- a/ai/chatgpt/src/tours.ts +++ b/ai/chatgpt/src/tours.ts @@ -99,8 +99,8 @@ const codeBlocks: Tour = { find('.bp-code-v2 .bp-code-actions') ), info( - 'Visual wrapping is not a source change', - 'Wrapping hides the gutter to avoid misleading visual line numbers. Blank lines, tabs and indentation remain part of the source.' + 'Themes and language detection', + 'Code panels follow the site light/dark theme. Language-colored badges remain colored. Filename labels and conservative signatures identify more languages; highlighting remains approximate and never changes the source text.' ) ] } diff --git a/ai/perplexity/CHANGELOG.md b/ai/perplexity/CHANGELOG.md index 44e682f..78563bf 100644 --- a/ai/perplexity/CHANGELOG.md +++ b/ai/perplexity/CHANGELOG.md @@ -2,6 +2,24 @@ All notable changes to Better Perplexity are documented here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project uses [Semantic Versioning](https://semver.org/). +## [1.2.2] - 2026-11-10 + +### Changed + +- Merged quota observations and recovery scenarios into Usage Quota V2. +- Removed the separate Quota Insights feature registration while preserving stored observations. +- Added GitHub-like light and dark code palettes that follow explicit site themes. +- Expanded language labels, detection signatures and colored typographic badges. +- Scoped composer tools to a single toolbar after native mode controls. +- Bounded full-width content with border-box sizing and a small outer gutter. + +### Fixed + +- Known positive usage counts with unknown capacity are labelled Reported. +- Usage headers and detailed dialogs use the same quota-ledger summaries. +- Sidebar visibility restores original inline display styles. +- Nested width wrappers no longer accumulate gutters after navigation. + ## [1.2.1] - 2026-11-10 ### Added diff --git a/ai/perplexity/README.md b/ai/perplexity/README.md index a6af04b..eae1ae6 100644 --- a/ai/perplexity/README.md +++ b/ai/perplexity/README.md @@ -17,7 +17,6 @@ Updates arrive automatically. The script also checks on its own and offers to up | Feature | What you get | | ----------------- | ------------------------------------------------------------------------------------------------------------------------------- | | Usage status | Reported remaining counts per mode in the header, hover summary and details dialog; totals and reset schedules are not invented | -| Quota Insights | Persistent counter observations, observed capacity lower bounds, last net increase and conditional recovery scenarios | | Code Blocks V2 | Language badges, syntax colours, line numbers, wrap, fold, download, indentation-safe selection copy | | Big messages | Paste any amount of text; split into parts or attach as a file only when needed | | Prompt library | Your prompts plus community prompts, with a form for placeholders | @@ -88,3 +87,7 @@ Building needs the `core/` and `core/ai/` folders at the repository root. See [C ## PDF reports PDF export opens a print-ready preview with a contents list, readable sections, code panels and tables. Use Print / Save as PDF in the preview. See [PDF reports](docs/pdf-reports.md) for print settings and machine-reading limitations. + +## Usage Quota V2 + +The header usage dialog combines reported allowances, capacity evidence and observation-based recovery scenarios. See [Usage Quota V2](docs/usage-quota-v2.md). diff --git a/ai/perplexity/docs/code-blocks-v2.md b/ai/perplexity/docs/code-blocks-v2.md index 8cca0f6..653deaf 100644 --- a/ai/perplexity/docs/code-blocks-v2.md +++ b/ai/perplexity/docs/code-blocks-v2.md @@ -33,3 +33,9 @@ Open Help and select Code blocks. The tour highlights the block and its toolbar. ## Verification Copy a selection containing blank lines, tabs and nested indentation into a plain-text editor. Verify the result before using copied code in a project. + +## Themes and language badges + +Code panels follow the site's explicit light/dark theme, with a GitHub-like syntax palette. Language badges retain their language-associated colors. Badges are typographic representations, not official logo artwork. + +Additional filename labels and conservative content signatures improve detection. New language labels may use an approximate syntax palette or plain text; the original source remains authoritative. diff --git a/ai/perplexity/docs/getting-started.md b/ai/perplexity/docs/getting-started.md index d65ba3a..b7db492 100644 --- a/ai/perplexity/docs/getting-started.md +++ b/ai/perplexity/docs/getting-started.md @@ -31,4 +31,4 @@ Click the **?** button in the header for guided tours. Each tour highlights real Open the settings dialog (the sliders button). Every feature is a module with its own switch and its own settings. Disabled modules stay completely idle. > [!NOTE] -> The header buttons attach to the usage badge. If you disable **Usage Status**, those buttons disappear, but every action is still in the command palette. +> The header buttons attach to the usage badge. If you disable **Usage Quota V2**, those buttons disappear, but every action is still in the command palette. diff --git a/ai/perplexity/docs/quota-insights.md b/ai/perplexity/docs/quota-insights.md index 078b910..d373042 100644 --- a/ai/perplexity/docs/quota-insights.md +++ b/ai/perplexity/docs/quota-insights.md @@ -1,48 +1,14 @@ --- -title: Quota insights -description: Capacity evidence, observed recovery and conditional forecasts. -section: Guides -order: 25 +title: Quota Insights migration +description: Quota Insights is now part of Usage Quota V2. +section: Reference +order: 810 --- -# Quota insights +# Quota Insights is now Usage Quota V2 -Open Settings → Quota Insights → Open Quota Insights, or find it in the command palette. +The separate feature has been removed. Its observation ledger and saved history remain in use. -## What is recorded +Open the header usage dialog to see reported counts and recovery scenarios together. -The feature stores remaining counts, observation times, explicit API caps and reported reset timestamps. It does not store conversation text. - -History is limited to 30 days and 2,000 observations per counter. - -## Maximum allowance - -An observed peak means capacity is at least that large. A plateau does not prove the maximum. - -Full-recovery scenarios require an explicit API cap. A reported reset timestamp alone does not establish the refill amount. - -## Recovery calculations - -Positive changes are observed net recovery. Additional spending between observations can hide refill. - -The engine calculates an observed net recovery rate across comparable intervals. It excludes gaps longer than five minutes and intervals known to be cap-bound. - -Rate scenarios require 30 minutes of comparable observations, at least three positive intervals and a recent observation. - -## Forecasts - -The panel can show conditional +1, +5, full recovery and recovery within a selected number of minutes. - -These scenarios assume the observed net recovery rate continues and no additional units are spent. They are not guaranteed refill schedules or calibrated confidence intervals. - -Rolling-window recovery and batch resets can behave differently. The existing Perplexity rolling estimator remains separate. - -## Privacy and account changes - -Saved observations are local to each userscript. - -Perplexity uses its existing account/tier namespace. ChatGPT currently partitions by reported plan, not a verified account id. Do not mix accounts in the same userscript storage when evaluating its history. - -## Tutorial - -The Help menu includes a Quota insights walkthrough explaining observations, lower bounds and projections. +See [Usage Quota V2](usage-quota-v2.md). diff --git a/ai/perplexity/docs/usage-quota-v2.md b/ai/perplexity/docs/usage-quota-v2.md new file mode 100644 index 0000000..81d6d35 --- /dev/null +++ b/ai/perplexity/docs/usage-quota-v2.md @@ -0,0 +1,40 @@ +--- +title: Usage Quota V2 +description: Reported counts, capacity evidence and recovery scenarios in one usage feature. +section: Guides +order: 25 +--- + +# Usage Quota V2 + +Click the usage control in the header. The main usage dialog now contains the observation engine previously shown separately as Quota Insights. + +## Reported counts and capacity + +A known count is labelled Reported even when capacity is unknown. + +API-reported capacity is shown separately from the observed maximum. An observed maximum is only a lower bound. It does not prove the account's maximum allowance. + +## Recovery calculations + +The dialog shows the last observed net increase, comparable sampling time, net recovery, net spending and conditional recovery scenarios. + +You can choose a recovery horizon. When sufficient observations exist, the same engine supplies +1, +5, recovery within that horizon and full-recovery scenarios. + +Full recovery requires an explicit API capacity. A reset timestamp alone does not establish the refill amount. + +## Interpretation + +Rate scenarios assume no additional spending and an unchanged observed net recovery rate. They are not guarantees or calibrated confidence intervals. + +Long gaps, hidden spending, cap changes and activity in other clients affect the calculation. Unknown results are not replaced with invented countdowns. + +## Storage and account scope + +Existing quota observations are preserved. + +Perplexity reports are requested using its current account/tier namespace. ChatGPT currently partitions by reported plan rather than a verified account id. Avoid mixing ChatGPT accounts in the same userscript storage. + +## Tutorial + +Open Help and choose Usage Quota V2. There is no separate Quota Insights module to enable. diff --git a/ai/perplexity/package.json b/ai/perplexity/package.json index 2873773..69777b2 100644 --- a/ai/perplexity/package.json +++ b/ai/perplexity/package.json @@ -1,6 +1,6 @@ { "name": "@nolly/ai-perplexity", - "version": "1.2.1", + "version": "1.2.2", "private": true, "type": "module", "license": "PolyForm-Strict-1.0.0", diff --git a/ai/perplexity/src/main.ts b/ai/perplexity/src/main.ts index 83288c7..6da0e23 100644 --- a/ai/perplexity/src/main.ts +++ b/ai/perplexity/src/main.ts @@ -16,7 +16,6 @@ import { UpdatesFeature, configurePlatform, configureUi, - QuotaInsightsFeature } from '@nolly/ai' import { App } from './core/app' import { composerKit } from './core/composer' @@ -71,7 +70,6 @@ new App() .register((context) => new ExporterFeature(context)) .register((context) => new UsageStatusModule(context)) .register((context) => new GlobalSettingsModule(context)) - .register((context) => new QuotaInsightsFeature(context)) .register((context) => new TutorialFeature(context)) .register((context) => new UpdatesFeature(context)) .register((context) => new PromptQueueFeature(context)) diff --git a/ai/perplexity/src/modules/usage-status/definitions.ts b/ai/perplexity/src/modules/usage-status/definitions.ts index 6aa412e..e712500 100644 --- a/ai/perplexity/src/modules/usage-status/definitions.ts +++ b/ai/perplexity/src/modules/usage-status/definitions.ts @@ -3,80 +3,81 @@ import type { LimitDefinition, LimitKey, SettingField, Status } from './types' const DAY = 86_400_000 export const LIMITS: Readonly> = { - remaining_pro: { label: 'Pro Search', total: 200, period: 'Reset schedule not supplied', window: 7 * DAY }, - remaining_research: { label: 'Deep Research', total: 20, period: 'Reset schedule not supplied', window: 30 * DAY }, - remaining_agentic_research: { label: 'Computer / Agentic', total: null, period: 'Reset schedule not supplied', window: 7 * DAY }, - remaining_labs: { label: 'Labs', total: 25, period: 'Reset schedule not supplied', window: 30 * DAY } + remaining_pro: { label: 'Pro Search', total: 200, period: 'Reset schedule not supplied', window: 7 * DAY }, + remaining_research: { label: 'Deep Research', total: 20, period: 'Reset schedule not supplied', window: 30 * DAY }, + remaining_agentic_research: { label: 'Computer / Agentic', total: null, period: 'Reset schedule not supplied', window: 7 * DAY }, + remaining_labs: { label: 'Labs', total: 25, period: 'Reset schedule not supplied', window: 30 * DAY } } export const LIMIT_KEYS = Object.keys(LIMITS) as LimitKey[] export const MODE_MAP: readonly { readonly match: RegExp; readonly key: LimitKey }[] = [ - { match: /deep\s*research|research/i, key: 'remaining_research' }, - { match: /computer|agentic/i, key: 'remaining_agentic_research' }, - { match: /\blabs?\b/i, key: 'remaining_labs' }, - { match: /pro|search/i, key: 'remaining_pro' } + { match: /deep\s*research|research/i, key: 'remaining_research' }, + { match: /computer|agentic/i, key: 'remaining_agentic_research' }, + { match: /\blabs?\b/i, key: 'remaining_labs' }, + { match: /pro|search/i, key: 'remaining_pro' } ] export const STATUS_LABELS: Readonly> = { - healthy: 'Healthy', - low: 'Low', - critical: 'Critical', - empty: 'Empty', - unavailable: 'Unavailable' + healthy: 'Healthy', + low: 'Low', + critical: 'Critical', + empty: 'Empty', + unavailable: 'Unavailable', + reported: 'Reported', } export const SETTINGS_FIELDS: readonly SettingField[] = [ - { key: 'subscription_status', label: 'Subscription status', type: 'string' }, - { key: 'subscription_source', label: 'Subscription source', type: 'string' }, - { key: 'upload_limit', label: 'Upload Limit', type: 'number' }, - { key: 'pages_limit', label: 'Pages Limit', type: 'number' }, - { key: 'create_limit', label: 'Create Limit', type: 'number' }, - { key: 'article_image_upload_limit', label: 'Image Upload Limit', type: 'number' }, - { key: 'daily_attachment_limit', label: 'Daily Attachments', type: 'number' }, - { key: 'disable_training', label: 'Training Disabled', type: 'bool' }, - { key: 'has_ai_profile', label: 'AI Profile', type: 'bool' }, - { key: 'default_model', label: 'Default Model', type: 'string' }, - { key: 'default_image_generation_model', label: 'Image Model', type: 'string' }, - { key: 'default_video_generation_model', label: 'Video Model', type: 'string' }, - { key: 'subscription_tier', label: 'Plan tier', type: 'string' }, - { key: 'stripe_status', label: 'Stripe status', type: 'string' }, - { key: 'revenuecat_status', label: 'RevenueCat status', type: 'string' }, - { key: 'query_count', label: 'Queries (total)', type: 'number' }, - { key: 'query_count_copilot', label: 'Copilot queries (total)', type: 'number' }, + { key: 'subscription_status', label: 'Subscription status', type: 'string' }, + { key: 'subscription_source', label: 'Subscription source', type: 'string' }, + { key: 'upload_limit', label: 'Upload Limit', type: 'number' }, + { key: 'pages_limit', label: 'Pages Limit', type: 'number' }, + { key: 'create_limit', label: 'Create Limit', type: 'number' }, + { key: 'article_image_upload_limit', label: 'Image Upload Limit', type: 'number' }, + { key: 'daily_attachment_limit', label: 'Daily Attachments', type: 'number' }, + { key: 'disable_training', label: 'Training Disabled', type: 'bool' }, + { key: 'has_ai_profile', label: 'AI Profile', type: 'bool' }, + { key: 'default_model', label: 'Default Model', type: 'string' }, + { key: 'default_image_generation_model', label: 'Image Model', type: 'string' }, + { key: 'default_video_generation_model', label: 'Video Model', type: 'string' }, + { key: 'subscription_tier', label: 'Plan tier', type: 'string' }, + { key: 'stripe_status', label: 'Stripe status', type: 'string' }, + { key: 'revenuecat_status', label: 'RevenueCat status', type: 'string' }, + { key: 'query_count', label: 'Queries (total)', type: 'number' }, + { key: 'query_count_copilot', label: 'Copilot queries (total)', type: 'number' }, ] export const SOURCE_LABELS: Readonly> = { - apple_healthkit: 'Apple Health', - asana_mcp_merge: 'Asana', - bmj: 'BMJ', - box: 'Box', - cbinsights_mcp_cashmere: 'CBInsights', - confluence_mcp_merge: 'Confluence', - crunchbase: 'Crunchbase', - dropbox: 'Dropbox', - factset: 'FactSet', - gcal: 'Google Calendar', - github_mcp_direct: 'GitHub', - google_drive: 'Google Drive', - jira_mcp_merge: 'Jira', - linear_alt: 'Linear', - microsoft_teams_mcp_merge: 'Microsoft Teams', - midpage: 'Midpage', - nejm: 'NEJM', - notion_mcp: 'Notion', - onedrive: 'OneDrive', - openrouter: 'OpenRouter', - org: 'Organization', - outlook: 'Outlook', - pitchbook_mcp_cashmere: 'Pitchbook', - rsc: 'RSC', - scholar: 'Scholar', - sharepoint: 'SharePoint', - slack_direct: 'Slack', - social: 'Social', - statista_mcp_cashmere: 'Statista', - visualdx: 'VisualDx', - web: 'Web', - wiley_mcp_cashmere: 'Wiley' + apple_healthkit: 'Apple Health', + asana_mcp_merge: 'Asana', + bmj: 'BMJ', + box: 'Box', + cbinsights_mcp_cashmere: 'CBInsights', + confluence_mcp_merge: 'Confluence', + crunchbase: 'Crunchbase', + dropbox: 'Dropbox', + factset: 'FactSet', + gcal: 'Google Calendar', + github_mcp_direct: 'GitHub', + google_drive: 'Google Drive', + jira_mcp_merge: 'Jira', + linear_alt: 'Linear', + microsoft_teams_mcp_merge: 'Microsoft Teams', + midpage: 'Midpage', + nejm: 'NEJM', + notion_mcp: 'Notion', + onedrive: 'OneDrive', + openrouter: 'OpenRouter', + org: 'Organization', + outlook: 'Outlook', + pitchbook_mcp_cashmere: 'Pitchbook', + rsc: 'RSC', + scholar: 'Scholar', + sharepoint: 'SharePoint', + slack_direct: 'Slack', + social: 'Social', + statista_mcp_cashmere: 'Statista', + visualdx: 'VisualDx', + web: 'Web', + wiley_mcp_cashmere: 'Wiley' } diff --git a/ai/perplexity/src/modules/usage-status/dialog.ts b/ai/perplexity/src/modules/usage-status/dialog.ts index 15c4303..832ad6e 100644 --- a/ai/perplexity/src/modules/usage-status/dialog.ts +++ b/ai/perplexity/src/modules/usage-status/dialog.ts @@ -1,23 +1,15 @@ import { createElement } from '@nolly/core' -import { createButton, createDataRow, createSection, createDialog } from '@nolly/ai' -import { createStatusBar, createTimerBlock } from './components' -import { LIMITS, LIMIT_KEYS, SETTINGS_FIELDS, SOURCE_LABELS, STATUS_LABELS } from './definitions' -import { getStatus } from './format' -import { updateLive } from './live' +import { createButton, createDataRow, createDialog, createQuotaPanel, createSection } from '@nolly/ai' +import type { QuotaPanel } from '@nolly/ai' +import { LIMITS } from './definitions' import type { UsageService } from './service' import { ensureUsageStyles } from './styles' -import type { ActiveUsage, SettingField } from './types' const DIALOG_ID = 'better-perplexity-usage-dialog' -const formatSetting = (value: unknown, type: SettingField['type']): string => { - if (value === null || value === undefined) return '—' - if (type === 'bool') return value ? 'Yes' : 'No' - return String(value) -} - export class UsageDialog { - private readonly openSections = new Set() + private panel: QuotaPanel | null = null + private heading: HTMLElement | null = null constructor( private readonly service: UsageService, @@ -30,20 +22,37 @@ export class UsageDialog { } open(): void { - const existing = this.element - if (existing) { - if (!existing.open) existing.showModal() + if (this.element?.open) { this.render() return } ensureUsageStyles() - const ui = createDialog({ id: DIALOG_ID, title: 'Usage & account', description: 'Live limits, estimated replenishment and account details.', width: 680 }) - ui.dialog.classList.add('bp-usage-dialog') - const updated = createElement('span', 'bp-updated', 'Loading usage data…') - updated.dataset['bpUpdated'] = '' - const refresh = createButton('Refresh', { primary: true, onClick: () => void this.service.refresh() }) - refresh.dataset['bpRefresh'] = '' - ui.footer.append(updated, createButton('Settings', { onClick: this.openSettings }), refresh) + const ui = createDialog({ id: DIALOG_ID, title: 'Usage Quota V2', description: 'Reported allowances, recovery observations and conditional forecasts.', width: 760 }) + this.heading = createElement('div', 'bp-data-list') + this.panel = createQuotaPanel(() => this.service.getQuotaReports()) + const account = createSection('Account and diagnostics') + const details = createElement('details', 'bp-details') + details.dataset['quotaDiagnostics'] = '' + details.appendChild(createElement('summary', 'bp-details-summary', 'Raw API data · may contain private account information')) + details.appendChild(createElement('pre', 'bp-raw')) + account.appendChild(details) + ui.body.append(this.heading, this.panel.element, account) + const refresh = createButton('Refresh usage', { primary: true, onClick: () => void this.service.refresh() }) + refresh.dataset['quotaRefresh'] = '' + ui.footer.append(createButton('Settings', { + onClick: () => { + ui.close() + window.setTimeout(this.openSettings, 0) + } + }), refresh, createButton('Close', { onClick: ui.close })) + const panel = this.panel + ui.dialog.addEventListener('close', () => { + panel.destroy() + if (this.panel === panel) { + this.panel = null + this.heading = null + } + }, { once: true }) ui.show() this.render() if (!this.service.initialized && !this.service.fetching) void this.service.refresh() @@ -56,131 +65,27 @@ export class UsageDialog { render(): void { const dialog = this.element if (!dialog?.open) return - const body = dialog.querySelector('.bp-dialog-body') - if (!body) return - const scrollTop = body.scrollTop - const nodes: HTMLElement[] = [] - if (this.service.lastError && !this.service.rate && !this.service.settings) nodes.push(createElement('div', 'bp-error', `Unable to retrieve usage data: ${this.service.lastError.message}`)) - const notice = this.service.getNotice() - if (notice) nodes.push(createElement('div', 'bp-notice', notice)) - const current = createSection('Current mode') - current.appendChild(this.renderHero(this.service.getActive())) - const details = createSection('Details') - details.append(this.renderMcp(), ...this.renderModelLimits(), this.renderSettings(), this.renderRaw()) - nodes.push(current, this.renderLimits(), details) - body.replaceChildren(...nodes) - body.scrollTop = scrollTop - const refresh = dialog.querySelector('[data-bp-refresh]') + const active = this.service.getActive() + this.heading?.replaceChildren( + createDataRow('Selected counter', active.key ? LIMITS[active.key].label : active.label), + createDataRow('Plan · reported', this.service.formatPlan()), + createDataRow('Free queries · reported', this.service.formatFreeQueries()), + createDataRow('Updated', this.service.lastFetchedAt ? new Date(this.service.lastFetchedAt).toLocaleString() : 'Waiting for a response') + ) + const refresh = dialog.querySelector('[data-quota-refresh]') if (refresh) { refresh.disabled = this.service.fetching - refresh.textContent = this.service.fetching ? 'Refreshing…' : 'Refresh' - } - updateLive(this.service) - } - - private renderHero(active: ActiveUsage | null): HTMLElement { - const hero = createElement('section', 'bp-hero') - if (!active) { - hero.appendChild(createElement('div', 'bp-empty', 'The selected mode could not be identified.')) - return hero - } - const title = createElement('div', 'bp-hero-title') - title.append(createElement('span', 'bp-hero-label', 'Selected mode'), createElement('span', 'bp-hero-mode', active.label)) - const top = createElement('div', 'bp-hero-top') - top.append(title, createElement('span', `bp-badge ${active.status}`, active.freeFallback ? 'Free queries' : STATUS_LABELS[active.status])) - const count = createElement('div', 'bp-hero-count', active.remaining === null ? '—' : String(active.remaining)) - const heroTotal = this.service.formatTotal(active.key) - if (heroTotal) count.appendChild(createElement('span', 'bp-hero-total', ` / ${heroTotal}`)) - hero.append(top, count) - if (active.total !== null && active.remaining !== null) hero.appendChild(createStatusBar(active.remaining, active.total, active.status)) - hero.appendChild(active.key ? createTimerBlock(this.service, active.key) : createElement('div', 'bp-timer-text', active.reset)) - const meta = createElement('div', 'bp-hero-meta') - meta.append(createElement('span', undefined, `Plan: ${this.service.formatPlan()}`), createElement('span', undefined, `Free queries: ${this.service.formatFreeQueries()}`)) - hero.appendChild(meta) - const pace = this.service.formatPace(active.key) - if (pace) hero.appendChild(createElement('div', 'bp-timer-text', pace)) - return hero - } - - private renderLimits(): HTMLElement { - const section = createSection('All limits') - const grid = createElement('div', 'bp-usage-grid') - for (const key of LIMIT_KEYS) { - const remaining = this.service.getRemaining(key) - const total = this.service.resolveTotal(key) - const status = getStatus(remaining, total) - const card = createElement('article', 'bp-card') - const top = createElement('div', 'bp-card-top') - top.append(createElement('span', 'bp-card-name', LIMITS[key].label), createElement('span', `bp-dot ${status}`)) - const count = createElement('div', 'bp-card-count', remaining === null ? '—' : String(remaining)) - const cardTotal = this.service.formatTotal(key) - if (cardTotal) count.appendChild(createElement('span', 'bp-card-total', ` / ${cardTotal}`)) - card.append(top, count, createElement('div', 'bp-card-period', LIMITS[key].period)) - if (total !== null && remaining !== null) card.appendChild(createStatusBar(remaining, total, status)) - card.appendChild(createTimerBlock(this.service, key)) - grid.appendChild(card) - } - section.appendChild(grid) - return section - } - - private createDetails(id: string, title: string, count: string, content: HTMLElement): HTMLElement { - const details = createElement('details', 'bp-details') - details.open = this.openSections.has(id) - const summary = createElement('summary', 'bp-details-summary') - summary.append(createElement('span', 'bp-details-title', title), createElement('span', 'bp-details-count', count)) - details.append(summary, content) - details.addEventListener('toggle', () => { - if (details.open) this.openSections.add(id) - else this.openSections.delete(id) - }) - return details - } - - private renderMcp(): HTMLElement { - const sources = this.service.rate?.sources?.source_to_limit - if (!sources) return this.createDetails('mcp', 'MCP sources', 'unavailable', createElement('div', 'bp-empty', 'No MCP usage data available.')) - const list = createElement('div', 'bp-data-list') - let metered = 0 - for (const [key, value] of Object.entries(sources)) { - if (!value) continue - const label = SOURCE_LABELS[key] ?? key - if (value.monthly_limit === null || value.monthly_limit === undefined) { - list.appendChild(createDataRow(label, 'Unmetered')) - continue - } - if (value.monthly_limit === 0) continue - metered++ - list.appendChild(createDataRow(label, `${value.remaining ?? '—'} / ${value.monthly_limit}`)) + refresh.textContent = this.service.fetching ? 'Refreshing…' : 'Refresh usage' } - const content = list.childElementCount ? list : createElement('div', 'bp-empty', 'No active MCP sources.') - return this.createDetails('mcp', 'MCP sources', `${metered} metered`, content) - } - - private renderModelLimits(): HTMLElement[] { - const limits = this.service.rate?.model_specific_limits - if (!limits || !Object.keys(limits).length) return [] - const list = createElement('div', 'bp-data-list') - for (const [key, value] of Object.entries(limits)) list.appendChild(createDataRow(key, typeof value === 'object' ? JSON.stringify(value) : String(value))) - return [this.createDetails('models', 'Model limits', String(Object.keys(limits).length), list)] - } - - private renderSettings(): HTMLElement { - const settings = this.service.settings - if (!settings) return this.createDetails('settings', 'Account settings', 'unavailable', createElement('div', 'bp-empty', 'Settings data unavailable.')) - const list = createElement('div', 'bp-data-list') - for (const field of SETTINGS_FIELDS) { - const value = settings[field.key] - if (value === undefined) continue - const className = field.type === 'bool' ? (value ? 'positive' : 'negative') : '' - list.appendChild(createDataRow(field.label, formatSetting(value, field.type), className)) + const pre = dialog.querySelector('[data-quota-diagnostics] pre') + if (pre) { + pre.textContent = JSON.stringify({ + diagnostics: this.service.diagnostics, + rateLimits: this.service.rate, + settings: this.service.settings, + error: this.service.lastError?.message ?? null + }, null, 2) } - const content = list.childElementCount ? list : createElement('div', 'bp-empty', 'No account settings were returned.') - return this.createDetails('settings', 'Account settings', String(list.childElementCount), content) - } - - private renderRaw(): HTMLElement { - const payload = { diagnostics: this.service.diagnostics, rateLimits: this.service.rate, settings: this.service.settings } - return this.createDetails('raw', 'Raw API data', 'debug', createElement('pre', 'bp-raw', JSON.stringify(payload, null, 2))) + this.panel?.refresh() } } diff --git a/ai/perplexity/src/modules/usage-status/format.ts b/ai/perplexity/src/modules/usage-status/format.ts index 8a1d01b..8f66459 100644 --- a/ai/perplexity/src/modules/usage-status/format.ts +++ b/ai/perplexity/src/modules/usage-status/format.ts @@ -22,8 +22,8 @@ export const formatAgo = (milliseconds: number): string => { export const getStatus = (remaining: number | null, total: number | null): Status => { if (remaining === null) return 'unavailable' if (remaining <= 0) return 'empty' - if (!total) return 'healthy' + if (!total) return 'reported' const ratio = remaining / total if (ratio > 0.6) return 'healthy' return ratio > 0.25 ? 'low' : 'critical' -} \ No newline at end of file +} diff --git a/ai/perplexity/src/modules/usage-status/index.ts b/ai/perplexity/src/modules/usage-status/index.ts index 09a4739..9838c33 100644 --- a/ai/perplexity/src/modules/usage-status/index.ts +++ b/ai/perplexity/src/modules/usage-status/index.ts @@ -15,8 +15,8 @@ import { UsageService } from './service' export class UsageStatusModule extends Feature { readonly id = 'usage-status' - readonly name = 'Usage Status' - readonly description = 'Display account usage and limits directly in the Perplexity header, with refill alerts and pace.' + readonly name = 'Usage Quota V2' + readonly description = 'Reported allowances and observation-based recovery estimates in one usage feature.' private readonly service = new UsageService() private readonly dialog = new UsageDialog(this.service, () => this.context.openSettings()) diff --git a/ai/perplexity/src/modules/usage-status/service.ts b/ai/perplexity/src/modules/usage-status/service.ts index 9a9621e..55eb1a1 100644 --- a/ai/perplexity/src/modules/usage-status/service.ts +++ b/ai/perplexity/src/modules/usage-status/service.ts @@ -11,7 +11,8 @@ import type { Send } from './model' import { resolvePlan } from './plan' import { findResetTimestamp } from './server-reset' import { ResetTracker } from './tracker' -import { QuotaLedger } from '@nolly/ai' +import { QuotaLedger, quotaSummary } from '@nolly/ai' +import type { QuotaReport } from '@nolly/ai' import type { ActiveUsage, ApiDiagnostics, Forecast, FreeQueriesInfo, LimitKey, Plan, RateLimitResponse, SettingsResponse, Pace } from './types' type Listener = () => void @@ -54,6 +55,10 @@ export class UsageService { this.modes.setFallback(() => this.lastUsedKey) } + getQuotaReports(): QuotaReport[] { + return this.quotaLedger.reports(Date.now(), this.namespace()) + } + subscribe(listener: Listener): () => void { this.listeners.add(listener) return () => this.listeners.delete(listener) @@ -178,22 +183,9 @@ export class UsageService { } formatForecast(key: LimitKey | null): string { - if (!key) return 'No limit tracked for this mode' - const remaining = this.getRemaining(key) - if (remaining === null) return 'Reset time unavailable' - const forecast = this.getForecast(key) - if (!forecast) { - const total = this.resolveTotal(key) - return total && remaining >= total ? 'Full allowance available' : 'Refill time unconfirmed · collecting matched uses and refills' - } - const now = Date.now() - if (forecast.source === 'server') return `Resets in ${formatDuration(forecast.next - now)}` - const confidence = `${Math.round(forecast.confidence * 100)}% conf.` - if (forecast.overdue) return 'Refill estimate expired · waiting for a confirmed increase' - const margin = forecast.margin >= 60_000 ? ` ±${formatDuration(forecast.margin)}` : '' - if (forecast.regime === 'reset') return `Full reset in ${formatDuration(forecast.next - now)}${margin} · ${confidence}` - const lead = forecast.complete ? 'Next +1 in' : 'Next +1 within' - return `${lead} ${formatDuration(forecast.next - now)}${margin} · full in ${formatDuration(forecast.full - now)} · ${confidence}` + if (!key) return 'No counter identified for this mode' + const report = this.getQuotaReports().find((entry) => entry.key === key) ?? null + return quotaSummary(report) } getFreeQueries(): FreeQueriesInfo | null { @@ -225,7 +217,7 @@ export class UsageService { freeFallback, period: mode.key ? LIMITS[mode.key].period : 'Unknown', reset: this.formatForecast(mode.key), - status: freeFallback ? 'low' : remaining === null ? 'unavailable' : remaining === 0 ? 'empty' : total === null ? 'unavailable' : getStatus(remaining, total) + status: freeFallback ? 'low' : remaining === null ? 'unavailable' : remaining <= 0 ? 'empty' : total === null ? 'reported' : getStatus(remaining, total) } } diff --git a/ai/perplexity/src/modules/usage-status/styles.ts b/ai/perplexity/src/modules/usage-status/styles.ts index c0fe5ac..86a3631 100644 --- a/ai/perplexity/src/modules/usage-status/styles.ts +++ b/ai/perplexity/src/modules/usage-status/styles.ts @@ -162,6 +162,9 @@ const USAGE_CSS = ` white-space: pre-wrap; word-break: break-word; } + +.bp-badge.reported { color: var(--bp-muted); background: var(--bp-accent); } +.bp-dot.reported { background: var(--bp-muted); } ` export const ensureUsageStyles = (): void => injectStyle('better-perplexity-usage-styles', USAGE_CSS) diff --git a/ai/perplexity/src/modules/usage-status/types.ts b/ai/perplexity/src/modules/usage-status/types.ts index 99f2c4b..a370af1 100644 --- a/ai/perplexity/src/modules/usage-status/types.ts +++ b/ai/perplexity/src/modules/usage-status/types.ts @@ -1,5 +1,5 @@ export type LimitKey = 'remaining_pro' | 'remaining_research' | 'remaining_agentic_research' | 'remaining_labs' -export type Status = 'healthy' | 'low' | 'critical' | 'empty' | 'unavailable' +export type Status = 'healthy' | 'low' | 'critical' | 'empty' | 'unavailable' | 'reported' export type Plan = 'paid' | 'free' | 'unknown' export type ModeSource = 'dom' | 'url' | 'learned' | 'default' diff --git a/ai/perplexity/src/tours.ts b/ai/perplexity/src/tours.ts index 2a5e55b..43487b1 100644 --- a/ai/perplexity/src/tours.ts +++ b/ai/perplexity/src/tours.ts @@ -92,8 +92,8 @@ const codeBlocks: Tour = { find('.bp-code-v2 .bp-code-actions') ), info( - 'Visual wrapping is not a source change', - 'Wrapping hides the gutter to avoid misleading visual line numbers. Blank lines, tabs and indentation remain part of the source.' + 'Themes and language detection', + 'Code panels follow the site light/dark theme. Language-colored badges remain colored. Filename labels and conservative signatures identify more languages; highlighting remains approximate and never changes the source text.' ) ] } diff --git a/bun.lock b/bun.lock index 0000c64..9f90ba6 100644 --- a/bun.lock +++ b/bun.lock @@ -7,7 +7,7 @@ }, "ai/chatgpt": { "name": "@nolly/ai-chatgpt", - "version": "1.2.1", + "version": "1.2.2", "dependencies": { "@nolly/ai": "workspace:*", "@nolly/core": "workspace:*", @@ -19,7 +19,7 @@ }, "ai/perplexity": { "name": "@nolly/ai-perplexity", - "version": "1.2.1", + "version": "1.2.2", "dependencies": { "@nolly/ai": "workspace:*", "@nolly/core": "workspace:*", @@ -39,7 +39,7 @@ }, "core/ai": { "name": "@nolly/ai", - "version": "0.2.1", + "version": "0.2.2", "dependencies": { "@nolly/core": "workspace:*", }, diff --git a/core/ai/CHANGELOG.md b/core/ai/CHANGELOG.md index ad3e239..6c62a5a 100644 --- a/core/ai/CHANGELOG.md +++ b/core/ai/CHANGELOG.md @@ -3,6 +3,11 @@ ## [0.2.2] - 2026-11-10 +- Integrated the quota-ledger panel and summaries into platform usage features. +- Improved composer scoping, bounded layout, code themes and language metadata. + +## [0.2.2] - 2026-11-10 + - Added the V2 renderer and shared UI changes. ## [0.2.1] - 2026-11-10 diff --git a/core/ai/package.json b/core/ai/package.json index cfb2ecc..c6d2db2 100644 --- a/core/ai/package.json +++ b/core/ai/package.json @@ -1,6 +1,6 @@ { "name": "@nolly/ai", - "version": "0.2.1", + "version": "0.2.2", "private": true, "type": "module", "license": "PolyForm-Strict-1.0.0", diff --git a/core/ai/src/features/code-blocks/badges.ts b/core/ai/src/features/code-blocks/badges.ts index d6060a2..d250252 100644 --- a/core/ai/src/features/code-blocks/badges.ts +++ b/core/ai/src/features/code-blocks/badges.ts @@ -19,7 +19,13 @@ const BADGES: Readonly> = { solidity: ['SOL', '#363636', '#fff'], assembly: ['ASM', '#6e4c13', '#fff'], vim: ['VIM', '#019733', '#fff'], nginx: ['NGX', '#009639', '#fff'], makefile: ['MK', '#6d8086', '#fff'], dockerfile: ['DK', '#2496ed', '#fff'], latex: ['TEX', '#008080', '#fff'], markdown: ['M↓', '#083fa1', '#fff'], diff: ['±', '#6f42c1', '#fff'], - regex: ['.*', '#6f42c1', '#fff'], http: ['HTTP', '#1f6feb', '#fff'], log: ['LOG', '#6e7681', '#fff'], csv: ['CSV', '#217346', '#fff'] + regex: ['.*', '#6f42c1', '#fff'], http: ['HTTP', '#1f6feb', '#fff'], log: ['LOG', '#6e7681', '#fff'], csv: ['CSV', '#217346', '#fff'], + jsx: ['JSX', '#149eca', '#ffffff'], tsx: ['TSX', '#3178c6', '#ffffff'], vue: ['V', '#42b883', '#172554'], svelte: ['S', '#ff3e00', '#ffffff'], + scss: ['Sass', '#cc6699', '#ffffff'], fsharp: ['F#', '#378bba', '#ffffff'], erlang: ['ERL', '#a90533', '#ffffff'], ocaml: ['ML', '#ec6813', '#ffffff'], + nix: ['NIX', '#5277c3', '#ffffff'], terraform: ['TF', '#7b42bc', '#ffffff'], hcl: ['HCL', '#7b42bc', '#ffffff'], prisma: ['P', '#2d3748', '#ffffff'], + astro: ['A', '#bc52ee', '#ffffff'], fish: ['>_', '#4aa3df', '#ffffff'], glsl: ['GL', '#5586a4', '#ffffff'], hlsl: ['HL', '#5586a4', '#ffffff'], + wgsl: ['WG', '#005a9c', '#ffffff'], jupyter: ['J', '#f37626', '#ffffff'], mermaid: ['MM', '#ff3670', '#ffffff'], plantuml: ['UML', '#d9b34c', '#18181b'], + cobol: ['COB', '#005ca9', '#ffffff'], fortran: ['F', '#734f96', '#ffffff'], } export const createLanguageIcon = (language: string): HTMLElement => { diff --git a/core/ai/src/features/code-blocks/extra-detect.ts b/core/ai/src/features/code-blocks/extra-detect.ts new file mode 100644 index 0000000..37cf3a3 --- /dev/null +++ b/core/ai/src/features/code-blocks/extra-detect.ts @@ -0,0 +1,35 @@ +const signatures: readonly [string, string][] = [ + ['prisma', 'generator client {'], + ['prisma', 'datasource db {'], + ['terraform', 'terraform {'], + ['terraform', 'resource "'], + ['terraform', 'provider "'], + ['vue', '