@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.
Files changed (147) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +2925 -2
  3. package/dist/chatTimelineOrdering.d.ts +50 -0
  4. package/dist/chatTimelineOrdering.d.ts.map +1 -0
  5. package/dist/chatTimelineOrdering.js +46 -0
  6. package/dist/chatTimelineOrdering.js.map +1 -0
  7. package/dist/command-metadata.d.ts +117 -0
  8. package/dist/command-metadata.d.ts.map +1 -0
  9. package/dist/command-metadata.js +271 -0
  10. package/dist/command-metadata.js.map +1 -0
  11. package/dist/components/activity-utilities.d.ts +107 -0
  12. package/dist/components/activity-utilities.d.ts.map +1 -0
  13. package/dist/components/activity-utilities.js +154 -0
  14. package/dist/components/activity-utilities.js.map +1 -0
  15. package/dist/components/chat-autocommit-utilities.d.ts +172 -0
  16. package/dist/components/chat-autocommit-utilities.d.ts.map +1 -0
  17. package/dist/components/chat-autocommit-utilities.js +185 -0
  18. package/dist/components/chat-autocommit-utilities.js.map +1 -0
  19. package/dist/components/chat-card-style.d.ts +81 -0
  20. package/dist/components/chat-card-style.d.ts.map +1 -0
  21. package/dist/components/chat-card-style.js +78 -0
  22. package/dist/components/chat-card-style.js.map +1 -0
  23. package/dist/components/chat-commands.d.ts +17 -0
  24. package/dist/components/chat-commands.d.ts.map +1 -0
  25. package/dist/components/chat-commands.js +17 -0
  26. package/dist/components/chat-commands.js.map +1 -0
  27. package/dist/components/chat-commit-utilities.d.ts +29 -0
  28. package/dist/components/chat-commit-utilities.d.ts.map +1 -0
  29. package/dist/components/chat-commit-utilities.js +31 -0
  30. package/dist/components/chat-commit-utilities.js.map +1 -0
  31. package/dist/components/chat-cost-utilities.d.ts +62 -0
  32. package/dist/components/chat-cost-utilities.d.ts.map +1 -0
  33. package/dist/components/chat-cost-utilities.js +66 -0
  34. package/dist/components/chat-cost-utilities.js.map +1 -0
  35. package/dist/components/chat-effort-utilities.d.ts +104 -0
  36. package/dist/components/chat-effort-utilities.d.ts.map +1 -0
  37. package/dist/components/chat-effort-utilities.js +99 -0
  38. package/dist/components/chat-effort-utilities.js.map +1 -0
  39. package/dist/components/chat-help-utilities.d.ts +89 -0
  40. package/dist/components/chat-help-utilities.d.ts.map +1 -0
  41. package/dist/components/chat-help-utilities.js +131 -0
  42. package/dist/components/chat-help-utilities.js.map +1 -0
  43. package/dist/components/chat-model-mode-utilities.d.ts +169 -0
  44. package/dist/components/chat-model-mode-utilities.d.ts.map +1 -0
  45. package/dist/components/chat-model-mode-utilities.js +221 -0
  46. package/dist/components/chat-model-mode-utilities.js.map +1 -0
  47. package/dist/components/chat-models-utilities.d.ts +162 -0
  48. package/dist/components/chat-models-utilities.d.ts.map +1 -0
  49. package/dist/components/chat-models-utilities.js +302 -0
  50. package/dist/components/chat-models-utilities.js.map +1 -0
  51. package/dist/components/chat-report-utilities.d.ts +149 -0
  52. package/dist/components/chat-report-utilities.d.ts.map +1 -0
  53. package/dist/components/chat-report-utilities.js +151 -0
  54. package/dist/components/chat-report-utilities.js.map +1 -0
  55. package/dist/components/chat-scripts-utilities.d.ts +185 -0
  56. package/dist/components/chat-scripts-utilities.d.ts.map +1 -0
  57. package/dist/components/chat-scripts-utilities.js +199 -0
  58. package/dist/components/chat-scripts-utilities.js.map +1 -0
  59. package/dist/components/chat-settings-utilities.d.ts +72 -0
  60. package/dist/components/chat-settings-utilities.d.ts.map +1 -0
  61. package/dist/components/chat-settings-utilities.js +56 -0
  62. package/dist/components/chat-settings-utilities.js.map +1 -0
  63. package/dist/components/chat-share-utilities.d.ts +110 -0
  64. package/dist/components/chat-share-utilities.d.ts.map +1 -0
  65. package/dist/components/chat-share-utilities.js +90 -0
  66. package/dist/components/chat-share-utilities.js.map +1 -0
  67. package/dist/components/chat-skills-utilities.d.ts +242 -0
  68. package/dist/components/chat-skills-utilities.d.ts.map +1 -0
  69. package/dist/components/chat-skills-utilities.js +433 -0
  70. package/dist/components/chat-skills-utilities.js.map +1 -0
  71. package/dist/components/chat-stream-utilities.d.ts +74 -0
  72. package/dist/components/chat-stream-utilities.d.ts.map +1 -0
  73. package/dist/components/chat-stream-utilities.js +103 -0
  74. package/dist/components/chat-stream-utilities.js.map +1 -0
  75. package/dist/components/chat-timestamps-utilities.d.ts +123 -0
  76. package/dist/components/chat-timestamps-utilities.d.ts.map +1 -0
  77. package/dist/components/chat-timestamps-utilities.js +177 -0
  78. package/dist/components/chat-timestamps-utilities.js.map +1 -0
  79. package/dist/components/chat-tips-utilities.d.ts +108 -0
  80. package/dist/components/chat-tips-utilities.d.ts.map +1 -0
  81. package/dist/components/chat-tips-utilities.js +137 -0
  82. package/dist/components/chat-tips-utilities.js.map +1 -0
  83. package/dist/components/device-cycle.d.ts +84 -0
  84. package/dist/components/device-cycle.d.ts.map +1 -0
  85. package/dist/components/device-cycle.js +77 -0
  86. package/dist/components/device-cycle.js.map +1 -0
  87. package/dist/components/fileExplorerPersistence.d.ts +50 -0
  88. package/dist/components/fileExplorerPersistence.d.ts.map +1 -0
  89. package/dist/components/fileExplorerPersistence.js +63 -0
  90. package/dist/components/fileExplorerPersistence.js.map +1 -0
  91. package/dist/components/search-utilities.d.ts +15 -0
  92. package/dist/components/search-utilities.d.ts.map +1 -0
  93. package/dist/components/search-utilities.js +26 -0
  94. package/dist/components/search-utilities.js.map +1 -0
  95. package/dist/components/tests-bar-utilities.d.ts +106 -0
  96. package/dist/components/tests-bar-utilities.d.ts.map +1 -0
  97. package/dist/components/tests-bar-utilities.js +167 -0
  98. package/dist/components/tests-bar-utilities.js.map +1 -0
  99. package/dist/components/tests-card-utilities.d.ts +280 -0
  100. package/dist/components/tests-card-utilities.d.ts.map +1 -0
  101. package/dist/components/tests-card-utilities.js +591 -0
  102. package/dist/components/tests-card-utilities.js.map +1 -0
  103. package/dist/components/tool-call-utilities.d.ts +256 -0
  104. package/dist/components/tool-call-utilities.d.ts.map +1 -0
  105. package/dist/components/tool-call-utilities.js +1004 -0
  106. package/dist/components/tool-call-utilities.js.map +1 -0
  107. package/dist/components/user-avatar-utilities.d.ts +41 -0
  108. package/dist/components/user-avatar-utilities.d.ts.map +1 -0
  109. package/dist/components/user-avatar-utilities.js +56 -0
  110. package/dist/components/user-avatar-utilities.js.map +1 -0
  111. package/dist/components/workspace-layout-utilities.d.ts +37 -0
  112. package/dist/components/workspace-layout-utilities.d.ts.map +1 -0
  113. package/dist/components/workspace-layout-utilities.js +58 -0
  114. package/dist/components/workspace-layout-utilities.js.map +1 -0
  115. package/dist/customEventCards.d.ts +147 -0
  116. package/dist/customEventCards.d.ts.map +1 -0
  117. package/dist/customEventCards.js +36 -0
  118. package/dist/customEventCards.js.map +1 -0
  119. package/dist/icon-names.d.ts +26 -0
  120. package/dist/icon-names.d.ts.map +1 -0
  121. package/dist/icon-names.js +14 -0
  122. package/dist/icon-names.js.map +1 -0
  123. package/dist/index.d.ts +51 -0
  124. package/dist/index.d.ts.map +1 -0
  125. package/dist/index.js +51 -0
  126. package/dist/index.js.map +1 -0
  127. package/dist/keyboard-shortcut-utilities.d.ts +63 -0
  128. package/dist/keyboard-shortcut-utilities.d.ts.map +1 -0
  129. package/dist/keyboard-shortcut-utilities.js +100 -0
  130. package/dist/keyboard-shortcut-utilities.js.map +1 -0
  131. package/dist/panels.d.ts +26 -0
  132. package/dist/panels.d.ts.map +1 -0
  133. package/dist/panels.js +26 -0
  134. package/dist/panels.js.map +1 -0
  135. package/dist/settings-metadata.d.ts +78 -0
  136. package/dist/settings-metadata.d.ts.map +1 -0
  137. package/dist/settings-metadata.js +137 -0
  138. package/dist/settings-metadata.js.map +1 -0
  139. package/dist/types.d.ts +588 -0
  140. package/dist/types.d.ts.map +1 -0
  141. package/dist/types.js +9 -0
  142. package/dist/types.js.map +1 -0
  143. package/dist/viewport-queries.d.ts +19 -0
  144. package/dist/viewport-queries.d.ts.map +1 -0
  145. package/dist/viewport-queries.js +19 -0
  146. package/dist/viewport-queries.js.map +1 -0
  147. package/package.json +74 -4
@@ -0,0 +1,151 @@
1
+ /**
2
+ * Pure helpers backing the `/report` (and `/bug` alias) command and the header
3
+ * bug-report button.
4
+ *
5
+ * The report modal collects a title, description, optional reproduction steps,
6
+ * and an "include recent chat" toggle, then POSTs to
7
+ * `POST /projects/:id/report { title, description, steps?, includeChat, clientInfo? }`.
8
+ * The backend files a GitHub issue when a report repo + token are configured
9
+ * (else records a DB row) and always persists a DB row tagged with
10
+ * projectId+userId, returning `{ ok, url?, id }`.
11
+ *
12
+ * The payload also carries an optional `clientInfo` block of client-side
13
+ * diagnostics — app version, browser/OS (user agent + platform), language,
14
+ * viewport + screen size, theme, and the current URL — collected by
15
+ * {@link collectClientInfo}. Every field is read defensively (each guarded for
16
+ * SSR / missing globals) so the report attaches whatever it can without ever
17
+ * throwing, giving triage real context without the user having to type it.
18
+ *
19
+ * These helpers parse the command, build the exact POST payload (omitting empty
20
+ * optional fields), validate the form, and produce a confirmation message. They
21
+ * are deterministic and side-effect free so they can be unit tested without
22
+ * rendering or a real backend. The confirmation/link rendering uses these values
23
+ * with `t()` in the component — the only translatable strings here are the
24
+ * confirmation defaults, kept i18n-ready by the caller.
25
+ *
26
+ * @module
27
+ */
28
+ /** An empty report form (the modal's initial state). */
29
+ export const EMPTY_REPORT_FORM = {
30
+ title: '',
31
+ description: '',
32
+ steps: '',
33
+ includeChat: true,
34
+ };
35
+ /**
36
+ * Parses a `/report [title]` or `/bug [title]` command. Returns the (possibly
37
+ * empty) trimmed title used to seed the modal when the input is one of those
38
+ * commands, else `null`.
39
+ *
40
+ * @param input - The raw chat input.
41
+ * @returns `{ title }` when it's a `/report` or `/bug` command, else `null`.
42
+ */
43
+ export function parseReportCommand(input) {
44
+ const match = input.trim().match(/^\/(?:report|bug)(?:\s+(.*))?$/i);
45
+ if (!match)
46
+ return null;
47
+ return { title: (match[1] ?? '').trim() };
48
+ }
49
+ /**
50
+ * Collects client-side diagnostics for a report. Reads `navigator`
51
+ * (userAgent/platform/language), `window` (inner viewport size, screen size,
52
+ * location href), plus the caller-supplied app version and theme. Every access
53
+ * is guarded (`typeof window/navigator !== 'undefined'` and per-property
54
+ * presence) so it is SSR-safe and never throws — it returns only the fields it
55
+ * could actually read, so the result may be partial or (in a headless
56
+ * environment) empty.
57
+ *
58
+ * @param opts - Caller-supplied context.
59
+ * @param opts.appVersion - The running build version, if known.
60
+ * @param opts.theme - The active theme (`'light'` | `'dark'`), if known.
61
+ * @returns The populated subset of {@link ClientInfo}.
62
+ */
63
+ export function collectClientInfo(opts = {}) {
64
+ const info = {};
65
+ if (opts.appVersion)
66
+ info.appVersion = opts.appVersion;
67
+ if (opts.theme)
68
+ info.theme = opts.theme;
69
+ if (typeof navigator !== 'undefined') {
70
+ if (navigator.userAgent)
71
+ info.userAgent = navigator.userAgent;
72
+ if (navigator.platform)
73
+ info.platform = navigator.platform;
74
+ if (navigator.language)
75
+ info.language = navigator.language;
76
+ }
77
+ if (typeof window !== 'undefined') {
78
+ if (typeof window.innerWidth === 'number' && typeof window.innerHeight === 'number') {
79
+ info.viewport = `${window.innerWidth}×${window.innerHeight}`;
80
+ }
81
+ if (window.screen) {
82
+ info.screen = `${window.screen.width}×${window.screen.height}`;
83
+ }
84
+ if (window.location?.href) {
85
+ info.url = window.location.href;
86
+ }
87
+ }
88
+ return info;
89
+ }
90
+ /**
91
+ * Builds the `POST /projects/:id/report` body from the form state, trimming all
92
+ * text fields and omitting `steps` entirely when it is blank. When `clientInfo`
93
+ * is supplied and non-empty, it is attached; an `undefined` or empty diagnostics
94
+ * object is omitted from the payload.
95
+ *
96
+ * @param form - The report form state.
97
+ * @param clientInfo - Optional client diagnostics from {@link collectClientInfo}.
98
+ * @returns The normalized report payload.
99
+ */
100
+ export function buildReportPayload(form, clientInfo) {
101
+ const steps = form.steps.trim();
102
+ const payload = {
103
+ title: form.title.trim(),
104
+ description: form.description.trim(),
105
+ includeChat: form.includeChat,
106
+ };
107
+ if (steps)
108
+ payload.steps = steps;
109
+ if (clientInfo && Object.keys(clientInfo).length > 0)
110
+ payload.clientInfo = clientInfo;
111
+ return payload;
112
+ }
113
+ /**
114
+ * Whether the report form has the minimum required fields: a non-empty title
115
+ * and a non-empty description.
116
+ *
117
+ * @param form - The report form state.
118
+ * @returns `true` when the form can be submitted.
119
+ */
120
+ export function isReportFormValid(form) {
121
+ return form.title.trim().length > 0 && form.description.trim().length > 0;
122
+ }
123
+ /**
124
+ * Builds the confirmation message shown after a report is submitted. Returns the
125
+ * English defaults; the component passes these through `t()` at render. The
126
+ * success `defaultValue` may contain the `{{productName}}` interpolation token,
127
+ * which the caller fills in from the host's product identity (neutral default:
128
+ * "the IDE"). When the result is not `ok`, returns the failure message.
129
+ *
130
+ * @param result - The `POST /projects/:id/report` response.
131
+ * @returns `{ key, defaultValue }` for the confirmation/failure message.
132
+ */
133
+ export function formatReportConfirmation(result) {
134
+ if (!result.ok) {
135
+ return {
136
+ key: 'ide.chat.report.failed',
137
+ defaultValue: 'Could not submit your report. Please try again.',
138
+ };
139
+ }
140
+ if (result.url) {
141
+ return {
142
+ key: 'ide.chat.report.submittedWithLink',
143
+ defaultValue: 'Thanks! Your report was submitted — track it on the linked issue.',
144
+ };
145
+ }
146
+ return {
147
+ key: 'ide.chat.report.submitted',
148
+ defaultValue: "Thanks! Your report was submitted to {{productName}}'s team.",
149
+ };
150
+ }
151
+ //# sourceMappingURL=chat-report-utilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat-report-utilities.js","sourceRoot":"","sources":["../../src/components/chat-report-utilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AA+DH,wDAAwD;AACxD,MAAM,CAAC,MAAM,iBAAiB,GAAoB;IAChD,KAAK,EAAE,EAAE;IACT,WAAW,EAAE,EAAE;IACf,KAAK,EAAE,EAAE;IACT,WAAW,EAAE,IAAI;CAClB,CAAA;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAAC,K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AAO;YACL,GAAG,EAAE,mCAAmC;YACxC,YAAY,EAAE,mEAAmE;SAClF,CAAA;IACH,CAAC;IACD,OAAO;QACL,GAAG,EAAE,2BAA2B;QAChC,YAAY,EAAE,8DAA8D;KAC7E,CAAA;AACH,CAAC"}
@@ -0,0 +1,185 @@
1
+ /**
2
+ * Pure helpers backing the `/scripts` browser and the `/run <name>` command.
3
+ *
4
+ * Scripts are saved shell files under the project's `.agents/scripts/` tree
5
+ * (`.agents/scripts/<name>.sh`) carrying a YAML frontmatter header (`name`,
6
+ * `description`, `createdAt`). The UI lists them via `GET /projects/:id/scripts`,
7
+ * runs one via `POST /projects/:id/scripts/:name/run`, and saves a new one (e.g.
8
+ * one the agent just generated) via `POST /projects/:id/scripts`.
9
+ *
10
+ * These helpers parse the slash commands, normalize a script name into the safe
11
+ * filename base the backend expects, resolve a typed `/run` argument against the
12
+ * known scripts, filter the list for the browser, and assemble a run's raw
13
+ * output for display. They are deterministic and side-effect free so they can be
14
+ * unit tested without rendering or a real backend. Any user-facing prose
15
+ * (status labels, empty states) lives in the components via `t()`, never here —
16
+ * `formatRunOutput` returns only the command's own (untranslatable) stdout/stderr.
17
+ *
18
+ * @module
19
+ */
20
+ /**
21
+ * A typed option a script accepts. The user supplies a value before running; it
22
+ * reaches the script (or built-in) as an input the body reads by `name`. `enum`
23
+ * constrains the value to `options`. Mirrors the backend `ScriptParam`.
24
+ */
25
+ export interface ScriptParam {
26
+ /** Option name (also the environment variable the script body reads). */
27
+ name: string;
28
+ /** `string` = free text; `enum` = one of `options`. */
29
+ type: 'string' | 'enum';
30
+ /** One-line label shown next to the field. */
31
+ description: string;
32
+ /** Whether a value must be supplied to run. */
33
+ required: boolean;
34
+ /** Allowed values when `type === 'enum'`. */
35
+ options?: string[];
36
+ /** Default value pre-filled into the field. */
37
+ default?: string;
38
+ }
39
+ /** A saved project script's metadata (the body lives in the sandbox file). */
40
+ export interface ScriptInfo {
41
+ /** Script name — the `<name>` in `.agents/scripts/<name>.sh` (no extension). */
42
+ name: string;
43
+ /** One-line description (from the script's YAML frontmatter `description`). */
44
+ description: string;
45
+ /** ISO 8601 creation timestamp (frontmatter `createdAt`). */
46
+ createdAt: string;
47
+ /** Typed options the script accepts (absent/empty = takes none). */
48
+ params?: ScriptParam[];
49
+ /** True for a server-backed built-in action (e.g. `setup-ci`), not a saved `.sh`. */
50
+ builtin?: boolean;
51
+ }
52
+ /** The result of running a script via the sandbox `exec`. */
53
+ export interface ScriptRunResult {
54
+ /** Captured standard output. */
55
+ stdout: string;
56
+ /** Captured standard error. */
57
+ stderr: string;
58
+ /** Process exit code (`0` = success). */
59
+ exitCode: number;
60
+ }
61
+ /** The `POST /projects/:id/scripts` request body for saving a script. */
62
+ export interface SaveScriptPayload {
63
+ /** Normalized script name (the filename base, no `.sh`). */
64
+ name: string;
65
+ /** One-line description stored in the frontmatter header. */
66
+ description: string;
67
+ /** The shell script body. */
68
+ body: string;
69
+ }
70
+ /**
71
+ * Normalizes a raw, possibly user- or AI-supplied script name into the safe
72
+ * filename base the backend writes as `.agents/scripts/<name>.sh`: lowercased,
73
+ * a trailing `.sh` dropped, every run of disallowed characters collapsed to a
74
+ * single `-`, and leading/trailing `-` trimmed. Returns `''` when nothing usable
75
+ * remains (the caller should treat that as invalid).
76
+ *
77
+ * @param raw - The raw script name (e.g. `'Run Tests.sh'`).
78
+ * @returns The normalized base name (e.g. `'run-tests'`), or `''`.
79
+ */
80
+ export declare function normalizeScriptName(raw: string): string;
81
+ /**
82
+ * Parses a `/scripts [query]` command. Returns the (possibly empty) trimmed
83
+ * filter query when the input is the `/scripts` command, else `null`.
84
+ *
85
+ * @param input - The raw chat input.
86
+ * @returns `{ query }` when it's a `/scripts` command, else `null`.
87
+ */
88
+ export declare function parseScriptsCommand(input: string): {
89
+ query: string;
90
+ } | null;
91
+ /**
92
+ * Parses a `/run [name] [--opt value ...]` command. The first token is the
93
+ * script name; any trailing `--key value` / `--key=value` flags become option
94
+ * values passed to the run. Returns `null` when the input is not a `/run`
95
+ * command; an empty `name` signals `/run` was typed without an argument.
96
+ *
97
+ * @param input - The raw chat input.
98
+ * @returns `{ name, params }` when it's a `/run` command, else `null`.
99
+ */
100
+ export declare function parseRunCommand(input: string): {
101
+ name: string;
102
+ params: Record<string, string>;
103
+ } | null;
104
+ /**
105
+ * Parses `--key value` and `--key=value` flag pairs from a command remainder
106
+ * into an option map. A bare flag with no value (end of string or another flag
107
+ * following) is treated as an empty string. Quoted values (`--k "a b"`) keep
108
+ * their inner spaces.
109
+ *
110
+ * @param rest - The text after the script name.
111
+ * @returns The parsed `{ key: value }` map.
112
+ */
113
+ export declare function parseFlagArgs(rest: string): Record<string, string>;
114
+ /**
115
+ * Returns the required params of a script that are not satisfied by the supplied
116
+ * values (missing, `undefined`, or empty). Used to decide whether a `/run` can
117
+ * proceed directly or must open the panel's option form.
118
+ *
119
+ * @param script - The script whose params to check (may declare none).
120
+ * @param values - The supplied option values.
121
+ * @returns The unsatisfied required params (empty when all are satisfied).
122
+ */
123
+ export declare function missingRequiredParams(script: Pick<ScriptInfo, 'params'>, values: Record<string, string>): ScriptParam[];
124
+ /**
125
+ * Resolves a `/run` name argument against the known scripts. Tries, in order:
126
+ * exact (case-insensitive, `.sh`-insensitive) match, then a unique prefix match,
127
+ * then a unique substring match. Returns `undefined` when there is no match or
128
+ * the match is ambiguous (more than one prefix/substring candidate).
129
+ *
130
+ * @param scripts - The known scripts.
131
+ * @param name - The raw name argument (may include a `.sh` suffix).
132
+ * @returns The single matching script, or `undefined`.
133
+ */
134
+ export declare function findScriptByName(scripts: readonly ScriptInfo[], name: string): ScriptInfo | undefined;
135
+ /**
136
+ * Filters scripts by a free-text query, matching (case-insensitively) against
137
+ * the name and description. An empty/blank query returns all scripts in input
138
+ * order.
139
+ *
140
+ * @param scripts - The scripts to filter.
141
+ * @param query - The search query.
142
+ * @returns The matching scripts, in input order.
143
+ */
144
+ export declare function filterScripts(scripts: readonly ScriptInfo[], query: string): ScriptInfo[];
145
+ /**
146
+ * Assembles a run's raw output for display: stdout followed by stderr (each
147
+ * trimmed of trailing whitespace), joined by a blank line when both are present.
148
+ * Returns `''` when the run produced no output — the component decides how to
149
+ * render an empty result. Contains no translatable prose; the exit-status label
150
+ * is rendered separately by the component via `t()`.
151
+ *
152
+ * @param result - The script run result.
153
+ * @returns The combined stdout/stderr text (possibly empty).
154
+ */
155
+ export declare function formatRunOutput(result: ScriptRunResult): string;
156
+ /**
157
+ * Whether a run succeeded (exit code `0`).
158
+ *
159
+ * @param result - The script run result.
160
+ * @returns `true` when `exitCode === 0`.
161
+ */
162
+ export declare function runSucceeded(result: ScriptRunResult): boolean;
163
+ /**
164
+ * Builds the `POST /projects/:id/scripts` body from raw form/AI input,
165
+ * normalizing the name and trimming the description and body. The backend adds
166
+ * the YAML frontmatter header (`name`, `description`, `createdAt`); the body
167
+ * here is the script content only.
168
+ *
169
+ * @param input - The raw `{ name, description, body }` to save.
170
+ * @returns The normalized save payload.
171
+ */
172
+ export declare function buildSaveScriptPayload(input: {
173
+ name: string;
174
+ description: string;
175
+ body: string;
176
+ }): SaveScriptPayload;
177
+ /**
178
+ * Whether a save payload has the minimum required fields: a non-empty
179
+ * normalized name and a non-empty body.
180
+ *
181
+ * @param payload - The save payload to validate.
182
+ * @returns `true` when the payload can be saved.
183
+ */
184
+ export declare function isSaveScriptValid(payload: SaveScriptPayload): boolean;
185
+ //# sourceMappingURL=chat-scripts-utilities.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat-scripts-utilities.d.ts","sourceRoot":"","sources":["../../src/components/chat-scripts-utilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,yEAAyE;IACzE,IAAI,EAAE,MAAM,CAAA;IACZ,uDAAuD;IACvD,IAAI,EAAE,QAAQ,GAAG,MAAM,CAAA;IACvB,8CAA8C;IAC9C,WAAW,EAAE,MAAM,CAAA;IACnB,+CAA+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AAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CASlE;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,EAClC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC7B,WAAW,EAAE,CAIf;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,SAAS,UAAU,EAAE,EAC9B,IAAI,EAAE,MAAM,GACX,UAAU,GAAG,SAAS,CAUxB;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,SAAS,UAAU,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU,EAAE,CAMzF;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAK/D;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAE7D;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE;IAC5C,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;CACb,GAAG,iBAAiB,CAMpB;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAErE"}
@@ -0,0 +1,199 @@
1
+ /**
2
+ * Pure helpers backing the `/scripts` browser and the `/run <name>` command.
3
+ *
4
+ * Scripts are saved shell files under the project's `.agents/scripts/` tree
5
+ * (`.agents/scripts/<name>.sh`) carrying a YAML frontmatter header (`name`,
6
+ * `description`, `createdAt`). The UI lists them via `GET /projects/:id/scripts`,
7
+ * runs one via `POST /projects/:id/scripts/:name/run`, and saves a new one (e.g.
8
+ * one the agent just generated) via `POST /projects/:id/scripts`.
9
+ *
10
+ * These helpers parse the slash commands, normalize a script name into the safe
11
+ * filename base the backend expects, resolve a typed `/run` argument against the
12
+ * known scripts, filter the list for the browser, and assemble a run's raw
13
+ * output for display. They are deterministic and side-effect free so they can be
14
+ * unit tested without rendering or a real backend. Any user-facing prose
15
+ * (status labels, empty states) lives in the components via `t()`, never here —
16
+ * `formatRunOutput` returns only the command's own (untranslatable) stdout/stderr.
17
+ *
18
+ * @module
19
+ */
20
+ /**
21
+ * Normalizes a raw, possibly user- or AI-supplied script name into the safe
22
+ * filename base the backend writes as `.agents/scripts/<name>.sh`: lowercased,
23
+ * a trailing `.sh` dropped, every run of disallowed characters collapsed to a
24
+ * single `-`, and leading/trailing `-` trimmed. Returns `''` when nothing usable
25
+ * remains (the caller should treat that as invalid).
26
+ *
27
+ * @param raw - The raw script name (e.g. `'Run Tests.sh'`).
28
+ * @returns The normalized base name (e.g. `'run-tests'`), or `''`.
29
+ */
30
+ export function normalizeScriptName(raw) {
31
+ return raw
32
+ .trim()
33
+ .replace(/\.sh$/i, '')
34
+ .toLowerCase()
35
+ .replace(/[^a-z0-9_-]+/g, '-')
36
+ .replace(/-+/g, '-')
37
+ .replace(/^-+|-+$/g, '');
38
+ }
39
+ /**
40
+ * Parses a `/scripts [query]` command. Returns the (possibly empty) trimmed
41
+ * filter query when the input is the `/scripts` command, else `null`.
42
+ *
43
+ * @param input - The raw chat input.
44
+ * @returns `{ query }` when it's a `/scripts` command, else `null`.
45
+ */
46
+ export function parseScriptsCommand(input) {
47
+ const match = input.trim().match(/^\/scripts(?:\s+(.*))?$/i);
48
+ if (!match)
49
+ return null;
50
+ return { query: (match[1] ?? '').trim() };
51
+ }
52
+ /**
53
+ * Parses a `/run [name] [--opt value ...]` command. The first token is the
54
+ * script name; any trailing `--key value` / `--key=value` flags become option
55
+ * values passed to the run. Returns `null` when the input is not a `/run`
56
+ * command; an empty `name` signals `/run` was typed without an argument.
57
+ *
58
+ * @param input - The raw chat input.
59
+ * @returns `{ name, params }` when it's a `/run` command, else `null`.
60
+ */
61
+ export function parseRunCommand(input) {
62
+ const match = input.trim().match(/^\/run(?:\s+(.*))?$/i);
63
+ if (!match)
64
+ return null;
65
+ const rest = (match[1] ?? '').trim();
66
+ if (!rest)
67
+ return { name: '', params: {} };
68
+ const firstSpace = rest.search(/\s/);
69
+ if (firstSpace === -1)
70
+ return { name: rest, params: {} };
71
+ return {
72
+ name: rest.slice(0, firstSpace),
73
+ params: parseFlagArgs(rest.slice(firstSpace + 1)),
74
+ };
75
+ }
76
+ /**
77
+ * Parses `--key value` and `--key=value` flag pairs from a command remainder
78
+ * into an option map. A bare flag with no value (end of string or another flag
79
+ * following) is treated as an empty string. Quoted values (`--k "a b"`) keep
80
+ * their inner spaces.
81
+ *
82
+ * @param rest - The text after the script name.
83
+ * @returns The parsed `{ key: value }` map.
84
+ */
85
+ export function parseFlagArgs(rest) {
86
+ const params = {};
87
+ // Match `--key=value`, `--key "quoted value"`, or `--key value`.
88
+ const re = /--([a-zA-Z_][a-zA-Z0-9_]*)(?:=(\S+)|\s+"([^"]*)"|\s+(?!--)(\S+))?/g;
89
+ let m;
90
+ while ((m = re.exec(rest)) !== null) {
91
+ params[m[1]] = m[2] ?? m[3] ?? m[4] ?? '';
92
+ }
93
+ return params;
94
+ }
95
+ /**
96
+ * Returns the required params of a script that are not satisfied by the supplied
97
+ * values (missing, `undefined`, or empty). Used to decide whether a `/run` can
98
+ * proceed directly or must open the panel's option form.
99
+ *
100
+ * @param script - The script whose params to check (may declare none).
101
+ * @param values - The supplied option values.
102
+ * @returns The unsatisfied required params (empty when all are satisfied).
103
+ */
104
+ export function missingRequiredParams(script, values) {
105
+ return (script.params ?? []).filter((p) => p.required && !(values[p.name] ?? p.default ?? '').trim());
106
+ }
107
+ /**
108
+ * Resolves a `/run` name argument against the known scripts. Tries, in order:
109
+ * exact (case-insensitive, `.sh`-insensitive) match, then a unique prefix match,
110
+ * then a unique substring match. Returns `undefined` when there is no match or
111
+ * the match is ambiguous (more than one prefix/substring candidate).
112
+ *
113
+ * @param scripts - The known scripts.
114
+ * @param name - The raw name argument (may include a `.sh` suffix).
115
+ * @returns The single matching script, or `undefined`.
116
+ */
117
+ export function findScriptByName(scripts, name) {
118
+ const q = normalizeScriptName(name);
119
+ if (!q)
120
+ return undefined;
121
+ const exact = scripts.find((s) => normalizeScriptName(s.name) === q);
122
+ if (exact)
123
+ return exact;
124
+ const prefix = scripts.filter((s) => normalizeScriptName(s.name).startsWith(q));
125
+ if (prefix.length === 1)
126
+ return prefix[0];
127
+ if (prefix.length > 1)
128
+ return undefined;
129
+ const substring = scripts.filter((s) => normalizeScriptName(s.name).includes(q));
130
+ return substring.length === 1 ? substring[0] : undefined;
131
+ }
132
+ /**
133
+ * Filters scripts by a free-text query, matching (case-insensitively) against
134
+ * the name and description. An empty/blank query returns all scripts in input
135
+ * order.
136
+ *
137
+ * @param scripts - The scripts to filter.
138
+ * @param query - The search query.
139
+ * @returns The matching scripts, in input order.
140
+ */
141
+ export function filterScripts(scripts, query) {
142
+ const q = query.trim().toLowerCase();
143
+ if (!q)
144
+ return [...scripts];
145
+ return scripts.filter((s) => s.name.toLowerCase().includes(q) || s.description.toLowerCase().includes(q));
146
+ }
147
+ /**
148
+ * Assembles a run's raw output for display: stdout followed by stderr (each
149
+ * trimmed of trailing whitespace), joined by a blank line when both are present.
150
+ * Returns `''` when the run produced no output — the component decides how to
151
+ * render an empty result. Contains no translatable prose; the exit-status label
152
+ * is rendered separately by the component via `t()`.
153
+ *
154
+ * @param result - The script run result.
155
+ * @returns The combined stdout/stderr text (possibly empty).
156
+ */
157
+ export function formatRunOutput(result) {
158
+ const out = (result.stdout ?? '').replace(/\s+$/, '');
159
+ const err = (result.stderr ?? '').replace(/\s+$/, '');
160
+ if (out && err)
161
+ return `${out}\n\n${err}`;
162
+ return out || err;
163
+ }
164
+ /**
165
+ * Whether a run succeeded (exit code `0`).
166
+ *
167
+ * @param result - The script run result.
168
+ * @returns `true` when `exitCode === 0`.
169
+ */
170
+ export function runSucceeded(result) {
171
+ return result.exitCode === 0;
172
+ }
173
+ /**
174
+ * Builds the `POST /projects/:id/scripts` body from raw form/AI input,
175
+ * normalizing the name and trimming the description and body. The backend adds
176
+ * the YAML frontmatter header (`name`, `description`, `createdAt`); the body
177
+ * here is the script content only.
178
+ *
179
+ * @param input - The raw `{ name, description, body }` to save.
180
+ * @returns The normalized save payload.
181
+ */
182
+ export function buildSaveScriptPayload(input) {
183
+ return {
184
+ name: normalizeScriptName(input.name),
185
+ description: input.description.trim(),
186
+ body: input.body.replace(/\s+$/, ''),
187
+ };
188
+ }
189
+ /**
190
+ * Whether a save payload has the minimum required fields: a non-empty
191
+ * normalized name and a non-empty body.
192
+ *
193
+ * @param payload - The save payload to validate.
194
+ * @returns `true` when the payload can be saved.
195
+ */
196
+ export function isSaveScriptValid(payload) {
197
+ return payload.name.length > 0 && payload.body.trim().length > 0;
198
+ }
199
+ //# sourceMappingURL=chat-scripts-utilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat-scripts-utilities.js","sourceRoot":"","sources":["../../src/components/chat-scripts-utilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAwDH;;;;;;;;;GASG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAAW;IAC7C,OAAO,GAAG;SACP,IAAI,EAAE;SACN,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC;SACrB,WAAW,EAAE;SACb,OAAO,CAAC,eAAe,EAAE,GAAG,CAAC;SAC7B,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;SACnB,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAA;AAC5B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAa;IAC/C,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAA;IAC5D,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAA;IACvB,O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,CAAC;QACrC,WAAW,EAAE,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE;QACrC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;KACrC,CAAA;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAA0B;IAC1D,OAAO,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAA;AAClE,CAAC"}
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Pure helpers backing the `/settings` view.
3
+ *
4
+ * The list of user-controllable settings itself now lives in the React-free
5
+ * {@link module:../settings-metadata | settings-metadata} module at the package
6
+ * root — the **single source of truth** that can be imported on either side of
7
+ * the api/app boundary (the IDE `/settings` card here, and the molecule.dev API
8
+ * system prompt's "User-Controllable Settings" section via the package's
9
+ * `./settings-metadata` subpath export). This module adds no settings of its
10
+ * own; it zips that canonical metadata together with the already-formatted,
11
+ * display-ready current values into a flat list of {@link SettingDescriptor}s
12
+ * the React {@link SettingsCard} renders. Splitting the value-binding out of the
13
+ * component lets it be unit tested without rendering, and deriving from the
14
+ * shared metadata is what keeps the settings card and the canonical list (and
15
+ * the command menu) from ever drifting apart — the SYN11 fix.
16
+ *
17
+ * All prose in the metadata is the English default; the {@link SettingsCard}
18
+ * wraps each `label`/`description` in `t('ide.chat.settings.<id>.…', …,
19
+ * { defaultValue })` at render time. The `value` is the already-formatted,
20
+ * display-ready current value supplied by the caller (so dynamic,
21
+ * possibly-localized fragments stay out of this pure layer).
22
+ *
23
+ * @module
24
+ */
25
+ import type { SettingKey, SettingMeta } from '../settings-metadata.js';
26
+ /** Notification-sound mode for a single event (mirrors ChatPanel's `SoundMode`). */
27
+ export type SoundEventMode = 'off' | 'whenNotFocused' | 'always';
28
+ /**
29
+ * A canonical {@link SettingMeta} paired with its display-ready current value —
30
+ * what the `/settings` card renders for one row.
31
+ */
32
+ export type SettingDescriptor = SettingMeta & {
33
+ /** The formatted, display-ready current value (already localized by caller). */
34
+ value: string;
35
+ };
36
+ /**
37
+ * Display-ready current values for the user-controllable settings, keyed by the
38
+ * canonical {@link SettingKey}. The caller resolves these (model labels from the
39
+ * catalog, on/off and mode words via `t()`, the effort label, the sounds summary
40
+ * via {@link summarizeSounds}) so this layer stays pure.
41
+ */
42
+ export type SettingsDisplayValues = Record<SettingKey, string>;
43
+ /**
44
+ * Builds the ordered list of user-controllable agent settings by zipping the
45
+ * canonical {@link SETTINGS} metadata together with the supplied display-ready
46
+ * values, so the `/settings` card always shows the live state AND can never
47
+ * drift from the shared single source of truth.
48
+ *
49
+ * Each `description` may contain the `{{agentName}}` interpolation token; the
50
+ * caller ({@link SettingsCard}) fills it in from the host's agent identity
51
+ * (neutral default: "the assistant") at render time.
52
+ *
53
+ * @param values - Display-ready current values for each setting, keyed by {@link SettingKey}.
54
+ * @returns One {@link SettingDescriptor} per setting in {@link SETTINGS}, in display order.
55
+ */
56
+ export declare function buildSettingsList(values: SettingsDisplayValues): SettingDescriptor[];
57
+ /** Aggregate enabled/total counts for a notification-sounds config. */
58
+ export interface SoundsSummary {
59
+ /** Number of events set to anything other than `'off'`. */
60
+ enabled: number;
61
+ /** Total number of sound events. */
62
+ total: number;
63
+ }
64
+ /**
65
+ * Summarizes a notification-sounds config into enabled/total counts. Pure and
66
+ * deterministic; the component turns the counts into a localized string.
67
+ *
68
+ * @param sounds - Per-event sound modes (event name → mode).
69
+ * @returns The number of enabled events and the total event count.
70
+ */
71
+ export declare function summarizeSounds(sounds: Record<string, SoundEventMode>): SoundsSummary;
72
+ //# sourceMappingURL=chat-settings-utilities.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat-settings-utilities.d.ts","sourceRoot":"","sources":["../../src/components/chat-settings-utilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAGtE,oFAAoF;AACpF,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,gBAAgB,GAAG,QAAQ,CAAA;AAEhE;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,WAAW,GAAG;IAC5C,gFAAgF;IAChF,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED;;;;;GAKG;AACH,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,CAAA;AAE9D;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,qBAAqB,GAAG,iBAAiB,EAAE,CAEpF;AAED,uEAAuE;AACvE,MAAM,WAAW,aAAa;IAC5B,2DAA2D;IAC3D,OAAO,EAAE,MAAM,CAAA;IACf,oCAAoC;IACpC,KAAK,EAAE,MAAM,CAAA;CACd;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,GAAG,aAAa,CAMrF"}