@molecule/app-ide-panel-logic 0.0.0-stage → 0.0.1-stage
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/LICENSE +202 -0
- package/README.md +2925 -2
- package/dist/chatTimelineOrdering.d.ts +50 -0
- package/dist/chatTimelineOrdering.d.ts.map +1 -0
- package/dist/chatTimelineOrdering.js +46 -0
- package/dist/chatTimelineOrdering.js.map +1 -0
- package/dist/command-metadata.d.ts +117 -0
- package/dist/command-metadata.d.ts.map +1 -0
- package/dist/command-metadata.js +271 -0
- package/dist/command-metadata.js.map +1 -0
- package/dist/components/activity-utilities.d.ts +107 -0
- package/dist/components/activity-utilities.d.ts.map +1 -0
- package/dist/components/activity-utilities.js +154 -0
- package/dist/components/activity-utilities.js.map +1 -0
- package/dist/components/chat-autocommit-utilities.d.ts +172 -0
- package/dist/components/chat-autocommit-utilities.d.ts.map +1 -0
- package/dist/components/chat-autocommit-utilities.js +185 -0
- package/dist/components/chat-autocommit-utilities.js.map +1 -0
- package/dist/components/chat-card-style.d.ts +81 -0
- package/dist/components/chat-card-style.d.ts.map +1 -0
- package/dist/components/chat-card-style.js +78 -0
- package/dist/components/chat-card-style.js.map +1 -0
- package/dist/components/chat-commands.d.ts +17 -0
- package/dist/components/chat-commands.d.ts.map +1 -0
- package/dist/components/chat-commands.js +17 -0
- package/dist/components/chat-commands.js.map +1 -0
- package/dist/components/chat-commit-utilities.d.ts +29 -0
- package/dist/components/chat-commit-utilities.d.ts.map +1 -0
- package/dist/components/chat-commit-utilities.js +31 -0
- package/dist/components/chat-commit-utilities.js.map +1 -0
- package/dist/components/chat-cost-utilities.d.ts +62 -0
- package/dist/components/chat-cost-utilities.d.ts.map +1 -0
- package/dist/components/chat-cost-utilities.js +66 -0
- package/dist/components/chat-cost-utilities.js.map +1 -0
- package/dist/components/chat-effort-utilities.d.ts +104 -0
- package/dist/components/chat-effort-utilities.d.ts.map +1 -0
- package/dist/components/chat-effort-utilities.js +99 -0
- package/dist/components/chat-effort-utilities.js.map +1 -0
- package/dist/components/chat-help-utilities.d.ts +89 -0
- package/dist/components/chat-help-utilities.d.ts.map +1 -0
- package/dist/components/chat-help-utilities.js +131 -0
- package/dist/components/chat-help-utilities.js.map +1 -0
- package/dist/components/chat-model-mode-utilities.d.ts +169 -0
- package/dist/components/chat-model-mode-utilities.d.ts.map +1 -0
- package/dist/components/chat-model-mode-utilities.js +221 -0
- package/dist/components/chat-model-mode-utilities.js.map +1 -0
- package/dist/components/chat-models-utilities.d.ts +162 -0
- package/dist/components/chat-models-utilities.d.ts.map +1 -0
- package/dist/components/chat-models-utilities.js +302 -0
- package/dist/components/chat-models-utilities.js.map +1 -0
- package/dist/components/chat-report-utilities.d.ts +149 -0
- package/dist/components/chat-report-utilities.d.ts.map +1 -0
- package/dist/components/chat-report-utilities.js +151 -0
- package/dist/components/chat-report-utilities.js.map +1 -0
- package/dist/components/chat-scripts-utilities.d.ts +185 -0
- package/dist/components/chat-scripts-utilities.d.ts.map +1 -0
- package/dist/components/chat-scripts-utilities.js +199 -0
- package/dist/components/chat-scripts-utilities.js.map +1 -0
- package/dist/components/chat-settings-utilities.d.ts +72 -0
- package/dist/components/chat-settings-utilities.d.ts.map +1 -0
- package/dist/components/chat-settings-utilities.js +56 -0
- package/dist/components/chat-settings-utilities.js.map +1 -0
- package/dist/components/chat-share-utilities.d.ts +110 -0
- package/dist/components/chat-share-utilities.d.ts.map +1 -0
- package/dist/components/chat-share-utilities.js +90 -0
- package/dist/components/chat-share-utilities.js.map +1 -0
- package/dist/components/chat-skills-utilities.d.ts +242 -0
- package/dist/components/chat-skills-utilities.d.ts.map +1 -0
- package/dist/components/chat-skills-utilities.js +433 -0
- package/dist/components/chat-skills-utilities.js.map +1 -0
- package/dist/components/chat-stream-utilities.d.ts +74 -0
- package/dist/components/chat-stream-utilities.d.ts.map +1 -0
- package/dist/components/chat-stream-utilities.js +103 -0
- package/dist/components/chat-stream-utilities.js.map +1 -0
- package/dist/components/chat-timestamps-utilities.d.ts +123 -0
- package/dist/components/chat-timestamps-utilities.d.ts.map +1 -0
- package/dist/components/chat-timestamps-utilities.js +177 -0
- package/dist/components/chat-timestamps-utilities.js.map +1 -0
- package/dist/components/chat-tips-utilities.d.ts +108 -0
- package/dist/components/chat-tips-utilities.d.ts.map +1 -0
- package/dist/components/chat-tips-utilities.js +137 -0
- package/dist/components/chat-tips-utilities.js.map +1 -0
- package/dist/components/device-cycle.d.ts +84 -0
- package/dist/components/device-cycle.d.ts.map +1 -0
- package/dist/components/device-cycle.js +77 -0
- package/dist/components/device-cycle.js.map +1 -0
- package/dist/components/fileExplorerPersistence.d.ts +50 -0
- package/dist/components/fileExplorerPersistence.d.ts.map +1 -0
- package/dist/components/fileExplorerPersistence.js +63 -0
- package/dist/components/fileExplorerPersistence.js.map +1 -0
- package/dist/components/search-utilities.d.ts +15 -0
- package/dist/components/search-utilities.d.ts.map +1 -0
- package/dist/components/search-utilities.js +26 -0
- package/dist/components/search-utilities.js.map +1 -0
- package/dist/components/tests-bar-utilities.d.ts +106 -0
- package/dist/components/tests-bar-utilities.d.ts.map +1 -0
- package/dist/components/tests-bar-utilities.js +167 -0
- package/dist/components/tests-bar-utilities.js.map +1 -0
- package/dist/components/tests-card-utilities.d.ts +280 -0
- package/dist/components/tests-card-utilities.d.ts.map +1 -0
- package/dist/components/tests-card-utilities.js +591 -0
- package/dist/components/tests-card-utilities.js.map +1 -0
- package/dist/components/tool-call-utilities.d.ts +256 -0
- package/dist/components/tool-call-utilities.d.ts.map +1 -0
- package/dist/components/tool-call-utilities.js +1004 -0
- package/dist/components/tool-call-utilities.js.map +1 -0
- package/dist/components/user-avatar-utilities.d.ts +41 -0
- package/dist/components/user-avatar-utilities.d.ts.map +1 -0
- package/dist/components/user-avatar-utilities.js +56 -0
- package/dist/components/user-avatar-utilities.js.map +1 -0
- package/dist/components/workspace-layout-utilities.d.ts +37 -0
- package/dist/components/workspace-layout-utilities.d.ts.map +1 -0
- package/dist/components/workspace-layout-utilities.js +58 -0
- package/dist/components/workspace-layout-utilities.js.map +1 -0
- package/dist/customEventCards.d.ts +147 -0
- package/dist/customEventCards.d.ts.map +1 -0
- package/dist/customEventCards.js +36 -0
- package/dist/customEventCards.js.map +1 -0
- package/dist/icon-names.d.ts +26 -0
- package/dist/icon-names.d.ts.map +1 -0
- package/dist/icon-names.js +14 -0
- package/dist/icon-names.js.map +1 -0
- package/dist/index.d.ts +51 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +51 -0
- package/dist/index.js.map +1 -0
- package/dist/keyboard-shortcut-utilities.d.ts +63 -0
- package/dist/keyboard-shortcut-utilities.d.ts.map +1 -0
- package/dist/keyboard-shortcut-utilities.js +100 -0
- package/dist/keyboard-shortcut-utilities.js.map +1 -0
- package/dist/panels.d.ts +26 -0
- package/dist/panels.d.ts.map +1 -0
- package/dist/panels.js +26 -0
- package/dist/panels.js.map +1 -0
- package/dist/settings-metadata.d.ts +78 -0
- package/dist/settings-metadata.d.ts.map +1 -0
- package/dist/settings-metadata.js +137 -0
- package/dist/settings-metadata.js.map +1 -0
- package/dist/types.d.ts +588 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +9 -0
- package/dist/types.js.map +1 -0
- package/dist/viewport-queries.d.ts +19 -0
- package/dist/viewport-queries.d.ts.map +1 -0
- package/dist/viewport-queries.js +19 -0
- package/dist/viewport-queries.js.map +1 -0
- package/package.json +74 -4
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared visual treatment for the boxed "info" cards in the Synthase chat
|
|
3
|
+
* timeline (the notice / tip / upgrade card, the activity card, and the `/help`,
|
|
4
|
+
* `/settings`, `/skills`, `/scripts` slash-command cards).
|
|
5
|
+
*
|
|
6
|
+
* These cards used to drift — some sat on a flat gray `surfaceSecondary` surface,
|
|
7
|
+
* others on a tinted background; icon sizes, paddings and radii differed; and the
|
|
8
|
+
* notice card carried a 3px left accent bar while the rest had a plain 1px frame.
|
|
9
|
+
* This module is the single source of truth that makes them one consistent family:
|
|
10
|
+
*
|
|
11
|
+
* - a subtle color-mix **tint** (never a flat gray surface),
|
|
12
|
+
* - a full **1px border on ALL sides** — never a thicker left accent bar,
|
|
13
|
+
* - one padding, one radius, one leading-icon size.
|
|
14
|
+
*
|
|
15
|
+
* A single `accent` colour drives both the border and the background via
|
|
16
|
+
* `color-mix` (works with a CSS var OR a hex), so a semantic card passes its tone
|
|
17
|
+
* colour (success green, upgrade gold, …) and a neutral info card passes the
|
|
18
|
+
* default (the theme's primary). The tint stays subtle and recolors with the
|
|
19
|
+
* active theme/brand instead of clashing with it.
|
|
20
|
+
*
|
|
21
|
+
* Each framework's IDE package builds its cards from these values, so the family looks the
|
|
22
|
+
* same in all of them. React spreads {@link chatCardStyle} into `style` as is; a framework
|
|
23
|
+
* whose style objects take no unitless numbers writes `borderRadius` with `px`.
|
|
24
|
+
*
|
|
25
|
+
* Do NOT layer a `borderLeft` / left-accent override on top of {@link chatCardStyle}
|
|
26
|
+
* — the whole point is a uniform 1px frame. Callers own only layout
|
|
27
|
+
* (`display`/`gap`/`alignItems`) and the bottom-margin timeline rhythm.
|
|
28
|
+
*
|
|
29
|
+
* @module
|
|
30
|
+
*/
|
|
31
|
+
/**
|
|
32
|
+
* Neutral accent for non-semantic info cards: the theme's primary colour, so a
|
|
33
|
+
* card that has no status meaning is still subtly *tinted* (never a flat gray
|
|
34
|
+
* surface) and recolors with the brand.
|
|
35
|
+
*/
|
|
36
|
+
export const CHAT_CARD_NEUTRAL_ACCENT = 'var(--mol-color-primary, #6366f1)';
|
|
37
|
+
/** Uniform leading-icon size (px) for every chat-timeline info card. */
|
|
38
|
+
export const CHAT_CARD_ICON_SIZE = 18;
|
|
39
|
+
/**
|
|
40
|
+
* Build the tinted border colour for a chat info card from its accent.
|
|
41
|
+
*
|
|
42
|
+
* @param accent - Accent source colour (CSS var or hex). Defaults to the theme primary.
|
|
43
|
+
* @param pct - Opacity of the accent in the mix (percent). Defaults to the resting 40.
|
|
44
|
+
* @returns A `color-mix` border colour.
|
|
45
|
+
*/
|
|
46
|
+
export function chatCardBorder(accent = CHAT_CARD_NEUTRAL_ACCENT, pct = 40) {
|
|
47
|
+
return `color-mix(in srgb, ${accent} ${pct}%, transparent)`;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Build the tinted background colour for a chat info card from its accent.
|
|
51
|
+
*
|
|
52
|
+
* @param accent - Accent source colour (CSS var or hex). Defaults to the theme primary.
|
|
53
|
+
* @param pct - Opacity of the accent in the mix (percent). Defaults to the resting 10.
|
|
54
|
+
* @returns A `color-mix` background colour.
|
|
55
|
+
*/
|
|
56
|
+
export function chatCardBg(accent = CHAT_CARD_NEUTRAL_ACCENT, pct = 10) {
|
|
57
|
+
return `color-mix(in srgb, ${accent} ${pct}%, transparent)`;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The single container chrome shared by every boxed info card in the chat
|
|
61
|
+
* timeline: subtle tint, full 1px border on all sides, one padding, one radius.
|
|
62
|
+
*
|
|
63
|
+
* Spread it first, then add layout (`display`/`gap`/`alignItems`) and the
|
|
64
|
+
* bottom-margin rhythm at the call site — e.g.
|
|
65
|
+
* `style={{ display: 'flex', gap: 10, marginBottom: TIMELINE_ITEM_GAP, ...chatCardStyle(accent) }}`.
|
|
66
|
+
*
|
|
67
|
+
* @param accent - Tint/border source colour. Defaults to the theme primary (neutral cards).
|
|
68
|
+
* @returns The container `style` chrome (border, background, padding, radius).
|
|
69
|
+
*/
|
|
70
|
+
export function chatCardStyle(accent = CHAT_CARD_NEUTRAL_ACCENT) {
|
|
71
|
+
return {
|
|
72
|
+
padding: '10px 12px',
|
|
73
|
+
borderRadius: 8,
|
|
74
|
+
border: `1px solid ${chatCardBorder(accent)}`,
|
|
75
|
+
background: chatCardBg(accent),
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=chat-card-style.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-card-style.js","sourceRoot":"","sources":["../../src/components/chat-card-style.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,mCAAmC,CAAA;AAE3E,wEAAwE;AACxE,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,CAAA;AAErC;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,SAAiB,wBAAwB,EAAE,GAAG,GAAG,EAAE;IAChF,OAAO,sBAAsB,MAAM,IAAI,GAAG,iBAAiB,CAAA;AAC7D,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,SAAiB,wBAAwB,EAAE,GAAG,GAAG,EAAE;IAC5E,OAAO,sBAAsB,MAAM,IAAI,GAAG,iBAAiB,CAAA;AAC7D,CAAC;AAiBD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,aAAa,CAAC,SAAiB,wBAAwB;IACrE,OAAO;QACL,OAAO,EAAE,WAAW;QACpB,YAAY,EAAE,CAAC;QACf,MAAM,EAAE,aAAa,cAAc,CAAC,MAAM,CAAC,EAAE;QAC7C,UAAU,EAAE,UAAU,CAAC,MAAM,CAAC;KAC/B,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Slash-command registry for the chat panel.
|
|
3
|
+
*
|
|
4
|
+
* The command definitions themselves now live in the React-free
|
|
5
|
+
* {@link module:../command-metadata | command-metadata} module at the package
|
|
6
|
+
* root, so the **single source of truth** can be imported on either side of the
|
|
7
|
+
* api/app boundary — the IDE chat surfaces read it here, and the molecule.dev
|
|
8
|
+
* API system prompt reads the very same array through the package's
|
|
9
|
+
* `./command-metadata` subpath export. This file re-exports that module so the
|
|
10
|
+
* chat components keep their local `./chat-commands.js` import path; it adds no
|
|
11
|
+
* data of its own (extending the list here instead of in `command-metadata.ts`
|
|
12
|
+
* would re-introduce exactly the duplication SYN15 was about).
|
|
13
|
+
*
|
|
14
|
+
* @module
|
|
15
|
+
*/
|
|
16
|
+
export * from '../command-metadata.js';
|
|
17
|
+
//# sourceMappingURL=chat-commands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-commands.d.ts","sourceRoot":"","sources":["../../src/components/chat-commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,cAAc,wBAAwB,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Slash-command registry for the chat panel.
|
|
3
|
+
*
|
|
4
|
+
* The command definitions themselves now live in the React-free
|
|
5
|
+
* {@link module:../command-metadata | command-metadata} module at the package
|
|
6
|
+
* root, so the **single source of truth** can be imported on either side of the
|
|
7
|
+
* api/app boundary — the IDE chat surfaces read it here, and the molecule.dev
|
|
8
|
+
* API system prompt reads the very same array through the package's
|
|
9
|
+
* `./command-metadata` subpath export. This file re-exports that module so the
|
|
10
|
+
* chat components keep their local `./chat-commands.js` import path; it adds no
|
|
11
|
+
* data of its own (extending the list here instead of in `command-metadata.ts`
|
|
12
|
+
* would re-introduce exactly the duplication SYN15 was about).
|
|
13
|
+
*
|
|
14
|
+
* @module
|
|
15
|
+
*/
|
|
16
|
+
export * from '../command-metadata.js';
|
|
17
|
+
//# sourceMappingURL=chat-commands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-commands.js","sourceRoot":"","sources":["../../src/components/chat-commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,cAAc,wBAAwB,CAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers for rendering commit messages in the chat timeline.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Strips a trailing `Co-authored-by:` attribution trailer (and the blank line
|
|
8
|
+
* that separates it from the message body, per git trailer convention) from a
|
|
9
|
+
* commit message **for display only**.
|
|
10
|
+
*
|
|
11
|
+
* The agent co-authors every commit it makes (e.g. molecule.dev appends
|
|
12
|
+
* `Co-authored-by: Synthase <synthase@molecule.dev>` after a blank line so the
|
|
13
|
+
* commit is truthfully attributed). That trailer belongs in the real git commit
|
|
14
|
+
* object — it must NOT leak into the user-facing commit displays (the commit-bar
|
|
15
|
+
* status line and the expanded commit-card label), where it is noise the user
|
|
16
|
+
* never wrote. Both surfaces show the message returned by the commit endpoint,
|
|
17
|
+
* which is the full message including the trailer, so they call this first.
|
|
18
|
+
*
|
|
19
|
+
* Cuts from the blank line preceding the first `Co-authored-by:` line through the
|
|
20
|
+
* end of the string, so any number of stacked co-author trailers (and any body
|
|
21
|
+
* paragraphs above the blank line) are handled. Case-insensitive so both the
|
|
22
|
+
* `Co-authored-by:` and `Co-Authored-By:` spellings are stripped. Messages with
|
|
23
|
+
* no such trailer are returned unchanged.
|
|
24
|
+
*
|
|
25
|
+
* @param message - The full commit message, possibly including a co-author trailer.
|
|
26
|
+
* @returns The commit message with any trailing co-author trailer removed.
|
|
27
|
+
*/
|
|
28
|
+
export declare function stripCommitCoauthorTrailer(message: string): string;
|
|
29
|
+
//# sourceMappingURL=chat-commit-utilities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-commit-utilities.d.ts","sourceRoot":"","sources":["../../src/components/chat-commit-utilities.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAElE"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers for rendering commit messages in the chat timeline.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Strips a trailing `Co-authored-by:` attribution trailer (and the blank line
|
|
8
|
+
* that separates it from the message body, per git trailer convention) from a
|
|
9
|
+
* commit message **for display only**.
|
|
10
|
+
*
|
|
11
|
+
* The agent co-authors every commit it makes (e.g. molecule.dev appends
|
|
12
|
+
* `Co-authored-by: Synthase <synthase@molecule.dev>` after a blank line so the
|
|
13
|
+
* commit is truthfully attributed). That trailer belongs in the real git commit
|
|
14
|
+
* object — it must NOT leak into the user-facing commit displays (the commit-bar
|
|
15
|
+
* status line and the expanded commit-card label), where it is noise the user
|
|
16
|
+
* never wrote. Both surfaces show the message returned by the commit endpoint,
|
|
17
|
+
* which is the full message including the trailer, so they call this first.
|
|
18
|
+
*
|
|
19
|
+
* Cuts from the blank line preceding the first `Co-authored-by:` line through the
|
|
20
|
+
* end of the string, so any number of stacked co-author trailers (and any body
|
|
21
|
+
* paragraphs above the blank line) are handled. Case-insensitive so both the
|
|
22
|
+
* `Co-authored-by:` and `Co-Authored-By:` spellings are stripped. Messages with
|
|
23
|
+
* no such trailer are returned unchanged.
|
|
24
|
+
*
|
|
25
|
+
* @param message - The full commit message, possibly including a co-author trailer.
|
|
26
|
+
* @returns The commit message with any trailing co-author trailer removed.
|
|
27
|
+
*/
|
|
28
|
+
export function stripCommitCoauthorTrailer(message) {
|
|
29
|
+
return message.replace(/\s*\nCo-authored-by:[\s\S]*$/i, '');
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=chat-commit-utilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-commit-utilities.js","sourceRoot":"","sources":["../../src/components/chat-commit-utilities.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,0BAA0B,CAAC,OAAe;IACxD,OAAO,OAAO,CAAC,OAAO,CAAC,+BAA+B,EAAE,EAAE,CAAC,CAAA;AAC7D,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure helpers backing the `/cost` command card.
|
|
3
|
+
*
|
|
4
|
+
* The card renders what `GET /projects/:id/chat-usage` returns for the current
|
|
5
|
+
* conversation. The one thing that is NOT obvious from the payload — and that
|
|
6
|
+
* made the card look broken next to a provider dashboard — is what
|
|
7
|
+
* `inputTokens` means:
|
|
8
|
+
*
|
|
9
|
+
* - Every AI bond normalizes usage into **disjoint** buckets: `inputTokens`
|
|
10
|
+
* (uncached prompt), `cacheReadInputTokens` (cache hits) and
|
|
11
|
+
* `cacheCreationInputTokens` (cache writes). On OpenAI-compatible APIs
|
|
12
|
+
* (DeepSeek, Alibaba, Moonshot) the wire format is the opposite — `prompt_tokens`
|
|
13
|
+
* is the TOTAL and `prompt_tokens_details.cached_tokens` is a subset of it — so
|
|
14
|
+
* those bonds subtract before reporting. Anthropic already reports them
|
|
15
|
+
* separately and nothing is subtracted.
|
|
16
|
+
* - A provider's usage dashboard reports **total tokens processed**, cache hits
|
|
17
|
+
* included. So `inputTokens` alone is not comparable to it, and in a long
|
|
18
|
+
* agentic turn (where each iteration replays the whole conversation against a
|
|
19
|
+
* warm cache) the cached share is the overwhelming majority of the volume.
|
|
20
|
+
*
|
|
21
|
+
* {@link totalPromptTokens} is therefore the figure to compare against a provider
|
|
22
|
+
* dashboard, and {@link formatTokenTotal} is the shared abbreviation used on the
|
|
23
|
+
* card. Both are deterministic and side-effect free so they can be unit tested
|
|
24
|
+
* without rendering or a real backend; the component supplies `t()`.
|
|
25
|
+
*
|
|
26
|
+
* @module
|
|
27
|
+
*/
|
|
28
|
+
/** The usage-shaped subset of `GET /projects/:id/chat-usage` the cost card reads. */
|
|
29
|
+
export interface ChatUsageTokens {
|
|
30
|
+
/** Uncached prompt tokens. NOT the provider's `prompt_tokens` — cache hits are excluded. */
|
|
31
|
+
inputTokens: number;
|
|
32
|
+
/** Generated tokens. */
|
|
33
|
+
outputTokens: number;
|
|
34
|
+
/** Prompt tokens served from the provider's cache. */
|
|
35
|
+
cacheReadInputTokens?: number;
|
|
36
|
+
/** Prompt tokens written into the provider's cache. */
|
|
37
|
+
cacheCreationInputTokens?: number;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Abbreviate a token count for display (`1.2M`, `340.5K`, `812`).
|
|
41
|
+
*
|
|
42
|
+
* @param n - The token count.
|
|
43
|
+
* @returns The abbreviated string.
|
|
44
|
+
*/
|
|
45
|
+
export declare function formatTokenTotal(n: number): string;
|
|
46
|
+
/**
|
|
47
|
+
* Total CACHED prompt tokens — reads plus writes.
|
|
48
|
+
*
|
|
49
|
+
* @param usage - The usage payload.
|
|
50
|
+
* @returns The combined cached-token count (0 when the provider reports none).
|
|
51
|
+
*/
|
|
52
|
+
export declare function cachedPromptTokens(usage: ChatUsageTokens): number;
|
|
53
|
+
/**
|
|
54
|
+
* Total prompt tokens the provider actually processed — uncached + cached. This
|
|
55
|
+
* is the figure that lines up with a provider usage dashboard; `inputTokens` on
|
|
56
|
+
* its own does not, because the bonds report the buckets disjointly.
|
|
57
|
+
*
|
|
58
|
+
* @param usage - The usage payload.
|
|
59
|
+
* @returns Uncached input plus every cached prompt token.
|
|
60
|
+
*/
|
|
61
|
+
export declare function totalPromptTokens(usage: ChatUsageTokens): number;
|
|
62
|
+
//# sourceMappingURL=chat-cost-utilities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-cost-utilities.d.ts","sourceRoot":"","sources":["../../src/components/chat-cost-utilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,qFAAqF;AACrF,MAAM,WAAW,eAAe;IAC9B,4FAA4F;IAC5F,WAAW,EAAE,MAAM,CAAA;IACnB,wBAAwB;IACxB,YAAY,EAAE,MAAM,CAAA;IACpB,sDAAsD;IACtD,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAC7B,uDAAuD;IACvD,wBAAwB,CAAC,EAAE,MAAM,CAAA;CAClC;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAKlD;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CAIjE;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CAGhE"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure helpers backing the `/cost` command card.
|
|
3
|
+
*
|
|
4
|
+
* The card renders what `GET /projects/:id/chat-usage` returns for the current
|
|
5
|
+
* conversation. The one thing that is NOT obvious from the payload — and that
|
|
6
|
+
* made the card look broken next to a provider dashboard — is what
|
|
7
|
+
* `inputTokens` means:
|
|
8
|
+
*
|
|
9
|
+
* - Every AI bond normalizes usage into **disjoint** buckets: `inputTokens`
|
|
10
|
+
* (uncached prompt), `cacheReadInputTokens` (cache hits) and
|
|
11
|
+
* `cacheCreationInputTokens` (cache writes). On OpenAI-compatible APIs
|
|
12
|
+
* (DeepSeek, Alibaba, Moonshot) the wire format is the opposite — `prompt_tokens`
|
|
13
|
+
* is the TOTAL and `prompt_tokens_details.cached_tokens` is a subset of it — so
|
|
14
|
+
* those bonds subtract before reporting. Anthropic already reports them
|
|
15
|
+
* separately and nothing is subtracted.
|
|
16
|
+
* - A provider's usage dashboard reports **total tokens processed**, cache hits
|
|
17
|
+
* included. So `inputTokens` alone is not comparable to it, and in a long
|
|
18
|
+
* agentic turn (where each iteration replays the whole conversation against a
|
|
19
|
+
* warm cache) the cached share is the overwhelming majority of the volume.
|
|
20
|
+
*
|
|
21
|
+
* {@link totalPromptTokens} is therefore the figure to compare against a provider
|
|
22
|
+
* dashboard, and {@link formatTokenTotal} is the shared abbreviation used on the
|
|
23
|
+
* card. Both are deterministic and side-effect free so they can be unit tested
|
|
24
|
+
* without rendering or a real backend; the component supplies `t()`.
|
|
25
|
+
*
|
|
26
|
+
* @module
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* Abbreviate a token count for display (`1.2M`, `340.5K`, `812`).
|
|
30
|
+
*
|
|
31
|
+
* @param n - The token count.
|
|
32
|
+
* @returns The abbreviated string.
|
|
33
|
+
*/
|
|
34
|
+
export function formatTokenTotal(n) {
|
|
35
|
+
if (!Number.isFinite(n) || n <= 0)
|
|
36
|
+
return '0';
|
|
37
|
+
if (n >= 1_000_000)
|
|
38
|
+
return `${(n / 1_000_000).toFixed(1)}M`;
|
|
39
|
+
if (n >= 1_000)
|
|
40
|
+
return `${(n / 1_000).toFixed(1)}K`;
|
|
41
|
+
return String(Math.round(n));
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Total CACHED prompt tokens — reads plus writes.
|
|
45
|
+
*
|
|
46
|
+
* @param usage - The usage payload.
|
|
47
|
+
* @returns The combined cached-token count (0 when the provider reports none).
|
|
48
|
+
*/
|
|
49
|
+
export function cachedPromptTokens(usage) {
|
|
50
|
+
const read = usage.cacheReadInputTokens ?? 0;
|
|
51
|
+
const write = usage.cacheCreationInputTokens ?? 0;
|
|
52
|
+
return (Number.isFinite(read) ? read : 0) + (Number.isFinite(write) ? write : 0);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Total prompt tokens the provider actually processed — uncached + cached. This
|
|
56
|
+
* is the figure that lines up with a provider usage dashboard; `inputTokens` on
|
|
57
|
+
* its own does not, because the bonds report the buckets disjointly.
|
|
58
|
+
*
|
|
59
|
+
* @param usage - The usage payload.
|
|
60
|
+
* @returns Uncached input plus every cached prompt token.
|
|
61
|
+
*/
|
|
62
|
+
export function totalPromptTokens(usage) {
|
|
63
|
+
const input = Number.isFinite(usage.inputTokens) ? usage.inputTokens : 0;
|
|
64
|
+
return input + cachedPromptTokens(usage);
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=chat-cost-utilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-cost-utilities.js","sourceRoot":"","sources":["../../src/components/chat-cost-utilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAcH;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,CAAS;IACxC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,GAAG,CAAA;IAC7C,IAAI,CAAC,IAAI,SAAS;QAAE,OAAO,GAAG,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAA;IAC3D,IAAI,CAAC,IAAI,KAAK;QAAE,OAAO,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAA;IACnD,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;AAC9B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAsB;IACvD,MAAM,IAAI,GAAG,KAAK,CAAC,oBAAoB,IAAI,CAAC,CAAA;IAC5C,MAAM,KAAK,GAAG,KAAK,CAAC,wBAAwB,IAAI,CAAC,CAAA;IACjD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAClF,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAsB;IACtD,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAA;IACxE,OAAO,KAAK,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAA;AAC1C,CAAC"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure helpers backing the `/effort` command and its status view.
|
|
3
|
+
*
|
|
4
|
+
* Effort is persisted PER MODE (`settings.effortByMode`, with the legacy single
|
|
5
|
+
* `settings.effortLevel` as fallback) as the model's OWN native value — there is
|
|
6
|
+
* no abstract scale. Users see and type the ACTIVE MODEL's own effort values
|
|
7
|
+
* (`xhigh` on Claude Opus 4.8, `medium` on Grok 4.3, `16K` thinking tokens on
|
|
8
|
+
* budget-configurable models …), which vary per model and therefore per mode:
|
|
9
|
+
* plan and execute run different models, so each mode carries its own value
|
|
10
|
+
* chosen from its own model's levels.
|
|
11
|
+
*
|
|
12
|
+
* Command shapes:
|
|
13
|
+
* - `/effort` — open the selectable level picker (mirrors `/model`'s picker).
|
|
14
|
+
* - `/effort ?` — textual status for every mode.
|
|
15
|
+
* - `/effort <value>` — set the CURRENT mode's effort to a native value.
|
|
16
|
+
* - `/effort --plan <value>` / `/effort --execute <value>` — set a specific
|
|
17
|
+
* mode's effort (mirrors `/model --plan` / `--execute`); the flag alone
|
|
18
|
+
* opens the picker scoped to that mode.
|
|
19
|
+
*
|
|
20
|
+
* Deterministic and side-effect free — unit testable without rendering or a
|
|
21
|
+
* backend. User-facing prose lives in the component via `t()`.
|
|
22
|
+
*
|
|
23
|
+
* @module
|
|
24
|
+
*/
|
|
25
|
+
import type { AppModelDefinition, EffortLevel, EffortOption } from '@molecule/app-ai-models';
|
|
26
|
+
export type { EffortLevel, EffortOption };
|
|
27
|
+
export { defaultEffortForModel, effortOptionsForModel, nativeEffortName, } from '@molecule/app-ai-models';
|
|
28
|
+
/**
|
|
29
|
+
* Conversation modes that carry their own effort level. Kept as a plain string
|
|
30
|
+
* union locally (mirrors the chat mode type); future modes extend this without
|
|
31
|
+
* changing the settings shape — `effortByMode` is keyed by mode id.
|
|
32
|
+
*/
|
|
33
|
+
export type EffortMode = 'plan' | 'execute';
|
|
34
|
+
/**
|
|
35
|
+
* The parsed result of an `/effort` command:
|
|
36
|
+
*
|
|
37
|
+
* - `set` — apply the (still-unresolved) native value `arg`, optionally scoped
|
|
38
|
+
* to a specific `mode` via `--plan` / `--execute` (unscoped = current mode).
|
|
39
|
+
* Resolve `arg` against the target model's options with
|
|
40
|
+
* {@link resolveEffortArg} — parsing is purely syntactic because the valid
|
|
41
|
+
* values depend on which model the target mode runs.
|
|
42
|
+
* - `menu` — open the selectable level picker (bare `/effort`, or a bare
|
|
43
|
+
* `--plan` / `--execute` flag scoping it), mirroring how bare `/model`
|
|
44
|
+
* opens the model picker.
|
|
45
|
+
* - `query` — show the textual status view (`/effort ?`).
|
|
46
|
+
* - `invalid` — unrecognized flags/arguments (the caller shows usage).
|
|
47
|
+
*/
|
|
48
|
+
export type EffortCommand = {
|
|
49
|
+
kind: 'set';
|
|
50
|
+
arg: string;
|
|
51
|
+
mode?: EffortMode;
|
|
52
|
+
} | {
|
|
53
|
+
kind: 'menu';
|
|
54
|
+
mode?: EffortMode;
|
|
55
|
+
} | {
|
|
56
|
+
kind: 'query';
|
|
57
|
+
mode?: EffortMode;
|
|
58
|
+
} | {
|
|
59
|
+
kind: 'invalid';
|
|
60
|
+
arg: string;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Parses an `/effort [--plan|--execute] [arg]` command. Purely syntactic — the
|
|
64
|
+
* caller resolves `arg` against the target mode's model via
|
|
65
|
+
* {@link resolveEffortArg}. Returns `null` when the input is not the command.
|
|
66
|
+
*
|
|
67
|
+
* @param input - The raw chat input.
|
|
68
|
+
* @returns The parsed {@link EffortCommand}, or `null`.
|
|
69
|
+
*/
|
|
70
|
+
export declare function parseEffortCommand(input: string): EffortCommand | null;
|
|
71
|
+
/**
|
|
72
|
+
* Resolve a user-typed effort value against a model's selectable options.
|
|
73
|
+
*
|
|
74
|
+
* Matches the model's own native values case-insensitively (`xhigh`, `16K`, …)
|
|
75
|
+
* and returns the canonical value to persist. Returns `null` when the input
|
|
76
|
+
* doesn't name one of the model's levels.
|
|
77
|
+
*
|
|
78
|
+
* @param arg - The raw value the user typed.
|
|
79
|
+
* @param options - The target model's options (see `effortOptionsForModel`).
|
|
80
|
+
* @returns The native value to persist, or `null` when nothing matches.
|
|
81
|
+
*/
|
|
82
|
+
export declare function resolveEffortArg(arg: string, options: readonly EffortOption[]): EffortLevel | null;
|
|
83
|
+
/**
|
|
84
|
+
* The catalog models that expose a *configurable* reasoning/thinking budget —
|
|
85
|
+
* i.e. those where the effort level maps onto a provider reasoning param. Models
|
|
86
|
+
* with no configurable budget still get the agent-loop budget applied by the
|
|
87
|
+
* backend, but these are the ones the `?` view highlights.
|
|
88
|
+
*
|
|
89
|
+
* @param models - The available models from the catalog.
|
|
90
|
+
* @returns The models supporting a configurable reasoning budget, in input order.
|
|
91
|
+
*/
|
|
92
|
+
export declare function modelsSupportingEffort(models: readonly AppModelDefinition[]): AppModelDefinition[];
|
|
93
|
+
/**
|
|
94
|
+
* The effort levels the `/effort` command offers and accepts for a *specific*
|
|
95
|
+
* model — the model's own native values, ascending (e.g.
|
|
96
|
+
* `['low', 'high', 'xhigh', 'max']`, or `['off', 'low', 'high', 'max']` on an
|
|
97
|
+
* opt-in reasoning model where `off` is the local toggle). Empty for a
|
|
98
|
+
* model with no selectable effort levels, or an unknown model.
|
|
99
|
+
*
|
|
100
|
+
* @param model - The active model to read levels from, or `undefined`.
|
|
101
|
+
* @returns The model's effort levels in ascending order (empty when it has none).
|
|
102
|
+
*/
|
|
103
|
+
export declare function effortLevelsForModel(model: AppModelDefinition | undefined): readonly string[];
|
|
104
|
+
//# sourceMappingURL=chat-effort-utilities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-effort-utilities.d.ts","sourceRoot":"","sources":["../../src/components/chat-effort-utilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAE5F,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,CAAA;AACzC,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,yBAAyB,CAAA;AAEhC;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,SAAS,CAAA;AAE3C;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,aAAa,GACrB;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,UAAU,CAAA;CAAE,GAC/C;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,UAAU,CAAA;CAAE,GACnC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,UAAU,CAAA;CAAE,GACpC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAA;AAEpC;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAiBtE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,SAAS,YAAY,EAAE,GAC/B,WAAW,GAAG,IAAI,CAGpB;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,SAAS,kBAAkB,EAAE,GACpC,kBAAkB,EAAE,CAEtB;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,kBAAkB,GAAG,SAAS,GAAG,SAAS,MAAM,EAAE,CAE7F"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure helpers backing the `/effort` command and its status view.
|
|
3
|
+
*
|
|
4
|
+
* Effort is persisted PER MODE (`settings.effortByMode`, with the legacy single
|
|
5
|
+
* `settings.effortLevel` as fallback) as the model's OWN native value — there is
|
|
6
|
+
* no abstract scale. Users see and type the ACTIVE MODEL's own effort values
|
|
7
|
+
* (`xhigh` on Claude Opus 4.8, `medium` on Grok 4.3, `16K` thinking tokens on
|
|
8
|
+
* budget-configurable models …), which vary per model and therefore per mode:
|
|
9
|
+
* plan and execute run different models, so each mode carries its own value
|
|
10
|
+
* chosen from its own model's levels.
|
|
11
|
+
*
|
|
12
|
+
* Command shapes:
|
|
13
|
+
* - `/effort` — open the selectable level picker (mirrors `/model`'s picker).
|
|
14
|
+
* - `/effort ?` — textual status for every mode.
|
|
15
|
+
* - `/effort <value>` — set the CURRENT mode's effort to a native value.
|
|
16
|
+
* - `/effort --plan <value>` / `/effort --execute <value>` — set a specific
|
|
17
|
+
* mode's effort (mirrors `/model --plan` / `--execute`); the flag alone
|
|
18
|
+
* opens the picker scoped to that mode.
|
|
19
|
+
*
|
|
20
|
+
* Deterministic and side-effect free — unit testable without rendering or a
|
|
21
|
+
* backend. User-facing prose lives in the component via `t()`.
|
|
22
|
+
*
|
|
23
|
+
* @module
|
|
24
|
+
*/
|
|
25
|
+
export { defaultEffortForModel, effortOptionsForModel, nativeEffortName, } from '@molecule/app-ai-models';
|
|
26
|
+
/**
|
|
27
|
+
* Parses an `/effort [--plan|--execute] [arg]` command. Purely syntactic — the
|
|
28
|
+
* caller resolves `arg` against the target mode's model via
|
|
29
|
+
* {@link resolveEffortArg}. Returns `null` when the input is not the command.
|
|
30
|
+
*
|
|
31
|
+
* @param input - The raw chat input.
|
|
32
|
+
* @returns The parsed {@link EffortCommand}, or `null`.
|
|
33
|
+
*/
|
|
34
|
+
export function parseEffortCommand(input) {
|
|
35
|
+
const match = input.trim().match(/^\/effort(?:\s+(.*))?$/i);
|
|
36
|
+
if (!match)
|
|
37
|
+
return null;
|
|
38
|
+
const tokens = (match[1] ?? '').trim().split(/\s+/).filter(Boolean);
|
|
39
|
+
let mode;
|
|
40
|
+
const rest = [];
|
|
41
|
+
for (const token of tokens) {
|
|
42
|
+
const lower = token.toLowerCase();
|
|
43
|
+
if (lower === '--plan')
|
|
44
|
+
mode = 'plan';
|
|
45
|
+
else if (lower === '--execute')
|
|
46
|
+
mode = 'execute';
|
|
47
|
+
else
|
|
48
|
+
rest.push(token);
|
|
49
|
+
}
|
|
50
|
+
if (rest.length === 0)
|
|
51
|
+
return { kind: 'menu', mode };
|
|
52
|
+
if (rest.length > 1)
|
|
53
|
+
return { kind: 'invalid', arg: rest.join(' ') };
|
|
54
|
+
const arg = rest[0];
|
|
55
|
+
if (arg === '?')
|
|
56
|
+
return { kind: 'query', mode };
|
|
57
|
+
return { kind: 'set', arg, mode };
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Resolve a user-typed effort value against a model's selectable options.
|
|
61
|
+
*
|
|
62
|
+
* Matches the model's own native values case-insensitively (`xhigh`, `16K`, …)
|
|
63
|
+
* and returns the canonical value to persist. Returns `null` when the input
|
|
64
|
+
* doesn't name one of the model's levels.
|
|
65
|
+
*
|
|
66
|
+
* @param arg - The raw value the user typed.
|
|
67
|
+
* @param options - The target model's options (see `effortOptionsForModel`).
|
|
68
|
+
* @returns The native value to persist, or `null` when nothing matches.
|
|
69
|
+
*/
|
|
70
|
+
export function resolveEffortArg(arg, options) {
|
|
71
|
+
const lower = arg.toLowerCase();
|
|
72
|
+
return options.find((o) => o.value.toLowerCase() === lower)?.value ?? null;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The catalog models that expose a *configurable* reasoning/thinking budget —
|
|
76
|
+
* i.e. those where the effort level maps onto a provider reasoning param. Models
|
|
77
|
+
* with no configurable budget still get the agent-loop budget applied by the
|
|
78
|
+
* backend, but these are the ones the `?` view highlights.
|
|
79
|
+
*
|
|
80
|
+
* @param models - The available models from the catalog.
|
|
81
|
+
* @returns The models supporting a configurable reasoning budget, in input order.
|
|
82
|
+
*/
|
|
83
|
+
export function modelsSupportingEffort(models) {
|
|
84
|
+
return models.filter((m) => m.supportsThinking && m.thinkingConfigurable);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The effort levels the `/effort` command offers and accepts for a *specific*
|
|
88
|
+
* model — the model's own native values, ascending (e.g.
|
|
89
|
+
* `['low', 'high', 'xhigh', 'max']`, or `['off', 'low', 'high', 'max']` on an
|
|
90
|
+
* opt-in reasoning model where `off` is the local toggle). Empty for a
|
|
91
|
+
* model with no selectable effort levels, or an unknown model.
|
|
92
|
+
*
|
|
93
|
+
* @param model - The active model to read levels from, or `undefined`.
|
|
94
|
+
* @returns The model's effort levels in ascending order (empty when it has none).
|
|
95
|
+
*/
|
|
96
|
+
export function effortLevelsForModel(model) {
|
|
97
|
+
return model?.supportedEffortLevels ?? [];
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=chat-effort-utilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-effort-utilities.js","sourceRoot":"","sources":["../../src/components/chat-effort-utilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAKH,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,yBAAyB,CAAA;AA6BhC;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAa;IAC9C,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAA;IAC3D,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAA;IACvB,MAAM,MAAM,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IACnE,IAAI,IAA4B,CAAA;IAChC,MAAM,IAAI,GAAa,EAAE,CAAA;IACzB,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,KAAK,GAAG,KAAK,CAAC,WAAW,EAAE,CAAA;QACjC,IAAI,KAAK,KAAK,QAAQ;YAAE,IAAI,GAAG,MAAM,CAAA;aAChC,IAAI,KAAK,KAAK,WAAW;YAAE,IAAI,GAAG,SAAS,CAAA;;YAC3C,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACvB,CAAC;IACD,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAA;IACpD,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAA;IACpE,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;IACnB,IAAI,GAAG,KAAK,GAAG;QAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;IAC/C,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,CAAA;AACnC,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,gBAAgB,CAC9B,GAAW,EACX,OAAgC;IAEhC,MAAM,KAAK,GAAG,GAAG,CAAC,WAAW,EAAE,CAAA;IAC/B,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,KAAK,CAAC,EAAE,KAAK,IAAI,IAAI,CAAA;AAC5E,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,sBAAsB,CACpC,MAAqC;IAErC,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,gBAAgB,IAAI,CAAC,CAAC,oBAAoB,CAAC,CAAA;AAC3E,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAqC;IACxE,OAAO,KAAK,EAAE,qBAAqB,IAAI,EAAE,CAAA;AAC3C,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `/help` content model + plain-text generation.
|
|
3
|
+
*
|
|
4
|
+
* The help content is a concise high-level guide built from the structured
|
|
5
|
+
* {@link HELP_MODES} / {@link HELP_TIPS} constants below — never a
|
|
6
|
+
* hand-maintained string — so the rich {@link module:./HelpCard | HelpCard} and
|
|
7
|
+
* this plain-text fallback can never drift (both read the SAME constants). It
|
|
8
|
+
* explains the three conversation modes (discovery / plan / execute) and lists
|
|
9
|
+
* efficiency tips. It deliberately does NOT relist the slash commands — typing
|
|
10
|
+
* `/` opens the command menu, which does that better.
|
|
11
|
+
*
|
|
12
|
+
* `buildHelpText` is the i18n plain-text fallback (used as the system card's
|
|
13
|
+
* copy/screen-reader text and in any non-React consumer); `HelpCard` renders the
|
|
14
|
+
* same model as a card matching the `/settings` / `/skills` cards.
|
|
15
|
+
*
|
|
16
|
+
* All prose is i18n-ready via `t(key, values, { defaultValue })`.
|
|
17
|
+
*
|
|
18
|
+
* @module
|
|
19
|
+
*/
|
|
20
|
+
import { type AgentIdentity } from '@molecule/app-ai-chat';
|
|
21
|
+
import type { IconName } from '@molecule/app-icons';
|
|
22
|
+
/**
|
|
23
|
+
* The `/help` intro paragraph (i18n key + English default). Shared by the
|
|
24
|
+
* plain-text {@link buildHelpText} fallback and the rich `HelpCard`. May
|
|
25
|
+
* interpolate the `{{agentName}}` / `{{productName}}` tokens.
|
|
26
|
+
*/
|
|
27
|
+
export declare const HELP_INTRO: {
|
|
28
|
+
/** i18n key for the intro paragraph. */
|
|
29
|
+
readonly key: "ide.chat.help.intro";
|
|
30
|
+
/** English default for {@link HELP_INTRO.key}. */
|
|
31
|
+
readonly defaultValue: "{{agentName}} is {{productName}}'s AI coding agent. Describe what you want to build and it will scaffold, code, and iterate with you.";
|
|
32
|
+
};
|
|
33
|
+
/** A conversation mode shown in `/help`, with its icon-set glyph and i18n copy. */
|
|
34
|
+
export interface HelpMode {
|
|
35
|
+
/** Mode id (also the `data-mol-id` suffix in the card). */
|
|
36
|
+
id: 'discovery' | 'plan' | 'execute';
|
|
37
|
+
/**
|
|
38
|
+
* Icon-set glyph name rendered beside the mode in the rich `HelpCard`
|
|
39
|
+
* (ignored by the plain-text {@link buildHelpText} fallback).
|
|
40
|
+
*/
|
|
41
|
+
icon: IconName;
|
|
42
|
+
/** i18n key for the one-line mode description (may interpolate `{{agentName}}`). */
|
|
43
|
+
key: string;
|
|
44
|
+
/** English default for {@link HelpMode.key}. */
|
|
45
|
+
defaultValue: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The three conversation modes, in the order shown in `/help`. The single
|
|
49
|
+
* source of truth for both the plain-text fallback and the `HelpCard`.
|
|
50
|
+
*/
|
|
51
|
+
export declare const HELP_MODES: readonly HelpMode[];
|
|
52
|
+
/** An efficiency tip shown in `/help`. */
|
|
53
|
+
export interface HelpTip {
|
|
54
|
+
/** Tip id (also the `data-mol-id` suffix in the card). */
|
|
55
|
+
id: string;
|
|
56
|
+
/** i18n key for the tip (may interpolate `{{agentName}}`). */
|
|
57
|
+
key: string;
|
|
58
|
+
/**
|
|
59
|
+
* English default for {@link HelpTip.key}, INCLUDING the leading `•` bullet so
|
|
60
|
+
* it matches the values shipped in the companion locale bonds (and so the
|
|
61
|
+
* plain-text fallback stays byte-identical).
|
|
62
|
+
*/
|
|
63
|
+
defaultValue: string;
|
|
64
|
+
}
|
|
65
|
+
/** The efficiency tips, in the order shown in `/help`. */
|
|
66
|
+
export declare const HELP_TIPS: readonly HelpTip[];
|
|
67
|
+
/** The keyboard-shortcuts footer line shown at the end of `/help`. */
|
|
68
|
+
export declare const HELP_SHORTCUTS: {
|
|
69
|
+
/** i18n key for the shortcuts footer. */
|
|
70
|
+
readonly key: "ide.chat.help.shortcuts";
|
|
71
|
+
/** English default for {@link HELP_SHORTCUTS.key}. */
|
|
72
|
+
readonly defaultValue: "Press Cmd+/ (Ctrl+/ on Windows/Linux) to view all keyboard shortcuts.";
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Builds the `/help` body — a concise high-level guide covering the conversation
|
|
76
|
+
* modes and efficiency tips. It deliberately does NOT relist the slash commands;
|
|
77
|
+
* typing `/` opens the command menu, which does that better. Generated from the
|
|
78
|
+
* shared {@link HELP_MODES} / {@link HELP_TIPS} constants so it stays in sync
|
|
79
|
+
* automatically — and never drifts from the rich `HelpCard`, which renders the
|
|
80
|
+
* same model.
|
|
81
|
+
*
|
|
82
|
+
* @param identity - Agent/product display identity used to interpolate the
|
|
83
|
+
* `{{agentName}}` / `{{productName}}` tokens in the help copy (defaults to the
|
|
84
|
+
* neutral {@link DEFAULT_AGENT_IDENTITY} so the shared package never hardcodes
|
|
85
|
+
* a product name).
|
|
86
|
+
* @returns The fully-formatted, newline-delimited help text.
|
|
87
|
+
*/
|
|
88
|
+
export declare function buildHelpText(identity?: AgentIdentity): string;
|
|
89
|
+
//# sourceMappingURL=chat-help-utilities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-help-utilities.d.ts","sourceRoot":"","sources":["../../src/components/chat-help-utilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,KAAK,aAAa,EAA0B,MAAM,uBAAuB,CAAA;AAElF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAEnD;;;;GAIG;AACH,eAAO,MAAM,UAAU;IACrB,wCAAwC;;IAExC,kDAAkD;;CAG1C,CAAA;AAEV,mFAAmF;AACnF,MAAM,WAAW,QAAQ;IACvB,2DAA2D;IAC3D,EAAE,EAAE,WAAW,GAAG,MAAM,GAAG,SAAS,CAAA;IACpC;;;OAGG;IACH,IAAI,EAAE,QAAQ,CAAA;IACd,oFAAoF;IACpF,GAAG,EAAE,MAAM,CAAA;IACX,gDAAgD;IAChD,YAAY,EAAE,MAAM,CAAA;CACrB;AAED;;;GAGG;AACH,eAAO,MAAM,UAAU,EAAE,SAAS,QAAQ,EAsBhC,CAAA;AAEV,0CAA0C;AAC1C,MAAM,WAAW,OAAO;IACtB,0DAA0D;IAC1D,EAAE,EAAE,MAAM,CAAA;IACV,8DAA8D;IAC9D,GAAG,EAAE,MAAM,CAAA;IACX;;;;OAIG;IACH,YAAY,EAAE,MAAM,CAAA;CACrB;AAED,0DAA0D;AAC1D,eAAO,MAAM,SAAS,EAAE,SAAS,OAAO,EAgC9B,CAAA;AAEV,sEAAsE;AACtE,eAAO,MAAM,cAAc;IACzB,yCAAyC;;IAEzC,sDAAsD;;CAE9C,CAAA;AAEV;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,QAAQ,GAAE,aAAsC,GAAG,MAAM,CA2BtF"}
|