@surfishs/dsh-prompt-enhance 0.0.5 → 0.0.7

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/lib/client.js CHANGED
@@ -1103,7 +1103,10 @@ var zh = {
1103
1103
  "settings.description": "\u628A\u8F93\u5165\u6846\u8349\u7A3F\u6539\u5199\u4E3A\u7ED3\u6784\u5316\u63D0\u793A\u8BCD\uFF1A\u89D2\u8272\u4E0E\u76EE\u6807\u3001\u53EF\u6267\u884C\u6B65\u9AA4\u3001\u8F93\u51FA\u683C\u5F0F\u3001\u9A8C\u6536\u6807\u51C6\u3001\u8FB9\u754C\u6761\u4EF6\u3002\u539F\u6587\u4FDD\u7559\uFF0C\u5931\u8D25\u4E0D\u6539\u8349\u7A3F\uFF1B\u4FDD\u5B58\u540E\u4E0B\u4E00\u6B21\u8C03\u7528\u5373\u751F\u6548\u3002",
1104
1104
  "settings.save": "\u4FDD\u5B58",
1105
1105
  "settings.saving": "\u4FDD\u5B58\u4E2D\u2026",
1106
+ "settings.saved": "\u5DF2\u4FDD\u5B58",
1106
1107
  "settings.saveFailed": "\u672C\u90E8\u7F72\u6CA1\u6709\u63A5\u53D7\u8FD9\u4E9B\u503C\uFF0C\u5DF2\u4FDD\u7559\u4F9B\u4F60\u4FEE\u6539\u3002",
1108
+ "settings.saveFailedShort": "\u4FDD\u5B58\u5931\u8D25",
1109
+ "settings.advanced": "\u9AD8\u7EA7\u8BBE\u7F6E",
1107
1110
  "settings.readOnly": "\u672C\u90E8\u7F72\u7684\u8BBE\u7F6E\u4E3A\u53EA\u8BFB\u3002",
1108
1111
  "settings.unavailable": "\u8BE5\u63D2\u4EF6\u5F53\u524D\u672A\u52A0\u8F7D\uFF0C\u6682\u65F6\u65E0\u6CD5\u914D\u7F6E\u3002",
1109
1112
  "settings.reset": "\u6062\u590D\u9ED8\u8BA4",
@@ -1141,7 +1144,7 @@ var zh = {
1141
1144
  "settings.row.temperature.label": "\u6E29\u5EA6",
1142
1145
  "settings.row.temperature.hint": "\u91C7\u6837\u6E29\u5EA6\uFF080~1\uFF0C\u6B65\u8FDB 0.05\uFF09\uFF0C\u8D8A\u4F4E\u8D8A\u5FE0\u5B9E\u539F\u6587\uFF1B\u9ED8\u8BA4 0.3\u3002",
1143
1146
  "settings.row.reasoningEffort.label": "\u63A8\u7406\u9884\u7B97",
1144
- "settings.row.reasoningEffort.hint": "\u6863\u4F4D\u9009\u9879\u6765\u81EA\u5F53\u524D provider/model \u7684\u58F0\u660E\uFF1B\u81EA\u5B9A\u4E49\u6A21\u578B\u65F6\u6309\u9700\u8BFB\u53D6\u3002\u8DDF\u968F\u63D0\u4F9B\u65B9\u9ED8\u8BA4\u8868\u793A\u4E0D\u4F20\u8BE5\u5B57\u6BB5\u3002",
1147
+ "settings.row.reasoningEffort.hint": "\u6863\u4F4D\u9009\u9879\u6765\u81EA\u5F53\u524D provider/model \u7684\u58F0\u660E\uFF1B\u81EA\u5B9A\u4E49\u6A21\u578B\u65F6\u6309\u9700\u8BFB\u53D6\u3002\u63D0\u4F9B\u65B9\u9ED8\u8BA4\u8868\u793A\u4E0D\u4F20\u8BE5\u5B57\u6BB5\u3002",
1145
1148
  "settings.row.maxOutputTokens.label": "\u8F93\u51FA token \u4E0A\u9650",
1146
1149
  "settings.row.maxOutputTokens.hint": "\u5355\u6B21\u589E\u5F3A\u7684\u8F93\u51FA\u9884\u7B97\uFF1B\u9ED8\u8BA4 8192\u3002",
1147
1150
  "settings.row.maxInputChars.label": "\u8F93\u5165\u5B57\u7B26\u4E0A\u9650",
@@ -1152,7 +1155,7 @@ var zh = {
1152
1155
  "settings.row.strategyMode.hint": "\u81EA\u5B9A\u4E49\u7CFB\u7EDF\u63D0\u793A\u8BCD\u975E\u7A7A\u65F6\uFF1A\u6574\u4F53\u66FF\u6362\u5185\u7F6E\u7B56\u7565\uFF08\u4ECD\u4FDD\u7559\u6700\u5C0F\u8F93\u51FA\u5951\u7EA6\uFF09\uFF0C\u6216\u8FFD\u52A0\u5728\u5185\u7F6E\u7B56\u7565\u4E4B\u540E\uFF08\u5185\u7F6E\u89C4\u5219\u7EE7\u7EED\u751F\u6548\uFF09\u3002",
1153
1156
  "settings.row.systemPrompt.label": "\u81EA\u5B9A\u4E49\u7CFB\u7EDF\u63D0\u793A\u8BCD",
1154
1157
  "settings.row.systemPrompt.hint": "\u7559\u7A7A\u4F7F\u7528\u5185\u7F6E\u589E\u5F3A\u7B56\u7565\u3002",
1155
- "settings.row.systemPrompt.placeholder": "\u4F8B\uFF1A\u628A\u7528\u6237\u7684\u4E2D\u6587\u6587\u5B57\u7FFB\u8BD1\u6210\u82F1\u6587\u3002",
1158
+ "settings.row.systemPrompt.placeholder": "\u4F8B\uFF1A\u628A\u7528\u6237\u7684\u4E2D\u6587\u8F93\u5165\u7FFB\u8BD1\u6210\u82F1\u6587\u3002",
1156
1159
  "settings.row.contextMaxMessages.label": "\u4E0A\u4E0B\u6587\u6D88\u606F\u6761\u6570",
1157
1160
  "settings.row.contextMaxMessages.hint": "\u6700\u591A\u53C2\u8003\u6700\u8FD1\u591A\u5C11\u8F6E\u5BF9\u8BDD\uFF1B0 \u8868\u793A\u4E0D\u53C2\u8003\uFF1B\u9ED8\u8BA4 8\u3002",
1158
1161
  "settings.row.contextMaxChars.label": "\u4E0A\u4E0B\u6587\u5B57\u7B26\u4E0A\u9650",
@@ -1166,7 +1169,7 @@ var zh = {
1166
1169
  "settings.row.shortcut.placeholder": "\u4F8B\uFF1Actrl+alt+shift+e",
1167
1170
  "settings.strategy.replace": "\u66FF\u6362\u5185\u7F6E\u7B56\u7565",
1168
1171
  "settings.strategy.extend": "\u8FFD\u52A0\u5728\u5185\u7F6E\u7B56\u7565\u540E",
1169
- "settings.reasoning.inherit": "\u8DDF\u968F\u63D0\u4F9B\u65B9\u9ED8\u8BA4",
1172
+ "settings.reasoning.inherit": "\u63D0\u4F9B\u65B9\u9ED8\u8BA4",
1170
1173
  "settings.reasoning.loading": "\u6B63\u5728\u8BFB\u53D6\u8BE5\u6A21\u578B\u7684\u6863\u4F4D\u2026",
1171
1174
  "settings.reasoning.unavailable": "\u65E0\u6CD5\u8BFB\u53D6\u8BE5\u6A21\u578B\u7684\u6863\u4F4D\uFF0C\u4EC5\u53EF\u8DDF\u968F\u63D0\u4F9B\u65B9\u9ED8\u8BA4\u3002",
1172
1175
  "settings.reasoning.noTiers": "\u8BE5\u6A21\u578B\u672A\u58F0\u660E\u63A8\u7406\u6863\u4F4D\uFF0C\u8C03\u7528\u65F6\u5C06\u8DDF\u968F\u63D0\u4F9B\u65B9\u9ED8\u8BA4\u3002",
@@ -1241,7 +1244,10 @@ var en = {
1241
1244
  "settings.description": "Turns a composer draft into a structured prompt: role and goal, executable steps, output format, acceptance criteria, edge cases. The draft is preserved, failures never touch it, and saved values apply to the next call.",
1242
1245
  "settings.save": "Save",
1243
1246
  "settings.saving": "Saving\u2026",
1247
+ "settings.saved": "Saved",
1244
1248
  "settings.saveFailed": "The deployment did not accept these values; they were left for you to correct.",
1249
+ "settings.saveFailedShort": "Save failed",
1250
+ "settings.advanced": "Advanced",
1245
1251
  "settings.readOnly": "This deployment stores settings read-only.",
1246
1252
  "settings.unavailable": "This plugin is not loaded, so it cannot be configured right now.",
1247
1253
  "settings.reset": "Reset to default",
@@ -1279,7 +1285,7 @@ var en = {
1279
1285
  "settings.row.temperature.label": "Temperature",
1280
1286
  "settings.row.temperature.hint": "Sampling temperature (0\u20131, step 0.05); lower stays closer to the original. Default 0.3.",
1281
1287
  "settings.row.reasoningEffort.label": "Reasoning effort",
1282
- "settings.row.reasoningEffort.hint": "Tier choices come from what the configured provider/model declares; custom models are read on demand. Follow provider default omits the field.",
1288
+ "settings.row.reasoningEffort.hint": "Tier choices come from what the configured provider/model declares; custom models are read on demand. Provider default omits the field.",
1283
1289
  "settings.row.maxOutputTokens.label": "Output token budget",
1284
1290
  "settings.row.maxOutputTokens.hint": "Output budget for one enhancement call. Default 8192.",
1285
1291
  "settings.row.maxInputChars.label": "Input character cap",
@@ -1575,6 +1581,105 @@ var CSS = `
1575
1581
  font-size: 12px;
1576
1582
  }
1577
1583
  .dsh-pe-undo-x:hover { opacity: 1; background: var(--dsw-alias-bg-layer-2, rgba(128, 128, 128, 0.12)); }
1584
+ .dsh-pe-segmented-labels [role="tab"] {
1585
+ min-width: 0;
1586
+ overflow: hidden;
1587
+ text-overflow: ellipsis;
1588
+ text-align: center;
1589
+ white-space: nowrap;
1590
+ }
1591
+ .dsh-pe-advanced {
1592
+ margin-top: 12px;
1593
+ border-top: 1px solid var(--dsw-alias-border-l3, rgba(128, 128, 128, 0.22));
1594
+ }
1595
+ .dsh-pe-advanced > summary {
1596
+ display: flex;
1597
+ align-items: center;
1598
+ gap: 8px;
1599
+ min-height: 40px;
1600
+ padding: 0 4px;
1601
+ list-style: none;
1602
+ font-size: 13px;
1603
+ font-weight: 500;
1604
+ color: var(--dsw-alias-label-secondary, inherit);
1605
+ cursor: pointer;
1606
+ user-select: none;
1607
+ }
1608
+ .dsh-pe-advanced > summary::-webkit-details-marker { display: none; }
1609
+ .dsh-pe-advanced > summary::marker { content: ''; }
1610
+ .dsh-pe-advanced > summary::before {
1611
+ content: '';
1612
+ flex: none;
1613
+ width: 0;
1614
+ height: 0;
1615
+ border-top: 4px solid transparent;
1616
+ border-bottom: 4px solid transparent;
1617
+ border-left: 5px solid currentColor;
1618
+ transition: transform 120ms ease;
1619
+ }
1620
+ .dsh-pe-advanced[open] > summary::before { transform: rotate(90deg); }
1621
+ .dsh-pe-advanced > summary:hover {
1622
+ color: var(--dsw-alias-label-primary, inherit);
1623
+ background: rgba(127, 127, 127, 0.08);
1624
+ border-radius: 6px;
1625
+ }
1626
+ .dsh-pe-advanced > summary:focus-visible {
1627
+ outline: 2px solid var(--dsw-alias-state-business-primary, #4f8cff);
1628
+ outline-offset: -2px;
1629
+ border-radius: 6px;
1630
+ }
1631
+ .dsh-pe-advanced[open] > summary { margin-bottom: 4px; }
1632
+ .dsh-pe-advanced + .dsh-pe-form-footer { margin-top: 0; }
1633
+ .dsh-pe-chip-reset:hover:not(:disabled),
1634
+ .dsh-pe-chip-refresh:hover:not(:disabled) {
1635
+ --pe-chip-bg: var(--dsw-alias-interactive-bg-hover, rgba(127, 127, 127, 0.18));
1636
+ --pe-chip-color: var(--dsw-alias-label-primary, inherit);
1637
+ }
1638
+ .dsh-pe-chip-reset:focus-visible,
1639
+ .dsh-pe-chip-refresh:focus-visible {
1640
+ outline: 2px solid var(--dsw-alias-state-business-primary, #4f8cff);
1641
+ outline-offset: 2px;
1642
+ }
1643
+ .dsh-pe-form-footer {
1644
+ display: flex;
1645
+ justify-content: flex-end;
1646
+ margin-top: 12px;
1647
+ padding-top: 10px;
1648
+ border-top: 1px solid var(--dsw-alias-border-l3, rgba(128, 128, 128, 0.22));
1649
+ }
1650
+ .dsh-pe-save-group {
1651
+ display: flex;
1652
+ align-items: center;
1653
+ justify-content: flex-end;
1654
+ flex-wrap: wrap;
1655
+ gap: 8px;
1656
+ min-width: 0;
1657
+ max-width: 100%;
1658
+ margin-left: auto;
1659
+ }
1660
+ .dsh-pe-save-status {
1661
+ min-width: 0;
1662
+ max-width: 100%;
1663
+ font-size: 12px;
1664
+ color: var(--dsw-alias-label-secondary, inherit);
1665
+ text-align: right;
1666
+ overflow-wrap: anywhere;
1667
+ }
1668
+ .dsh-pe-save-button {
1669
+ flex: none;
1670
+ margin-left: 0;
1671
+ height: 28px;
1672
+ padding: 0 14px;
1673
+ border: 1px solid var(--dsw-alias-border-l2, rgba(128, 128, 128, 0.32));
1674
+ border-radius: 8px;
1675
+ background: var(--dsw-alias-bg-layer-1, transparent);
1676
+ color: inherit;
1677
+ font: inherit;
1678
+ font-size: 12px;
1679
+ cursor: pointer;
1680
+ }
1681
+ .dsh-pe-save-button:hover:not(:disabled) { background: rgba(127, 127, 127, 0.12); }
1682
+ .dsh-pe-save-button:disabled { opacity: 0.5; cursor: default; }
1578
1683
  `;
1579
1684
  function ensureStyles() {
1580
1685
  if (document.getElementById(STYLE_ID) !== null) return false;
@@ -2020,25 +2125,28 @@ var STRATEGY_OPTIONS = [
2020
2125
  { value: "replace-default", label: "settings.strategy.replace" },
2021
2126
  { value: "extend-default", label: "settings.strategy.extend" }
2022
2127
  ];
2023
- var ROWS = [
2128
+ var BASIC_ROWS = [
2024
2129
  { key: "enabled", kind: "boolean", label: "settings.row.enabled.label", hint: "settings.row.enabled.hint" },
2025
- { key: "contextAware", kind: "boolean", label: "settings.row.contextAware.label", hint: "settings.row.contextAware.hint" },
2026
- { key: "streaming", kind: "boolean", label: "settings.row.streaming.label", hint: "settings.row.streaming.hint" },
2027
2130
  { key: "provider", kind: "provider", label: "settings.row.provider.label", hint: "settings.row.provider.hint" },
2028
2131
  { key: "model", kind: "model", label: "settings.row.model.label", hint: "settings.row.model.hint" },
2029
- { key: "temperature", kind: "number", label: "settings.row.temperature.label", hint: "settings.row.temperature.hint" },
2030
2132
  { key: "reasoningEffort", kind: "reasoning", label: "settings.row.reasoningEffort.label", hint: "settings.row.reasoningEffort.hint" },
2031
- { key: "maxOutputTokens", kind: "number", label: "settings.row.maxOutputTokens.label", hint: "settings.row.maxOutputTokens.hint" },
2133
+ { key: "temperature", kind: "number", label: "settings.row.temperature.label", hint: "settings.row.temperature.hint" },
2134
+ { key: "contextAware", kind: "boolean", label: "settings.row.contextAware.label", hint: "settings.row.contextAware.hint" },
2135
+ { key: "streaming", kind: "boolean", label: "settings.row.streaming.label", hint: "settings.row.streaming.hint" },
2136
+ { key: "systemPrompt", kind: "text", label: "settings.row.systemPrompt.label", hint: "settings.row.systemPrompt.hint", placeholder: "settings.row.systemPrompt.placeholder" },
2137
+ { key: "shortcut", kind: "text", label: "settings.row.shortcut.label", hint: "settings.row.shortcut.hint", placeholder: "settings.row.shortcut.placeholder" }
2138
+ ];
2139
+ var ADVANCED_ROWS = [
2140
+ { key: "strategyMode", kind: "strategy", label: "settings.row.strategyMode.label", hint: "settings.row.strategyMode.hint" },
2032
2141
  { key: "maxInputChars", kind: "number", label: "settings.row.maxInputChars.label", hint: "settings.row.maxInputChars.hint" },
2142
+ { key: "maxOutputTokens", kind: "number", label: "settings.row.maxOutputTokens.label", hint: "settings.row.maxOutputTokens.hint" },
2033
2143
  { key: "timeoutMs", kind: "number", label: "settings.row.timeoutMs.label", hint: "settings.row.timeoutMs.hint" },
2034
- { key: "strategyMode", kind: "strategy", label: "settings.row.strategyMode.label", hint: "settings.row.strategyMode.hint" },
2035
- { key: "systemPrompt", kind: "text", label: "settings.row.systemPrompt.label", hint: "settings.row.systemPrompt.hint", placeholder: "settings.row.systemPrompt.placeholder" },
2036
2144
  { key: "contextMaxMessages", kind: "number", label: "settings.row.contextMaxMessages.label", hint: "settings.row.contextMaxMessages.hint" },
2037
2145
  { key: "contextMaxChars", kind: "number", label: "settings.row.contextMaxChars.label", hint: "settings.row.contextMaxChars.hint" },
2038
2146
  { key: "maxConcurrent", kind: "number", label: "settings.row.maxConcurrent.label", hint: "settings.row.maxConcurrent.hint" },
2039
- { key: "rateLimitPerMinute", kind: "number", label: "settings.row.rateLimitPerMinute.label", hint: "settings.row.rateLimitPerMinute.hint" },
2040
- { key: "shortcut", kind: "text", label: "settings.row.shortcut.label", hint: "settings.row.shortcut.hint", placeholder: "settings.row.shortcut.placeholder" }
2147
+ { key: "rateLimitPerMinute", kind: "number", label: "settings.row.rateLimitPerMinute.label", hint: "settings.row.rateLimitPerMinute.hint" }
2041
2148
  ];
2149
+ var ROWS = [...BASIC_ROWS, ...ADVANCED_ROWS];
2042
2150
  function descriptorOf(row) {
2043
2151
  switch (row.kind) {
2044
2152
  case "number":
@@ -2074,8 +2182,11 @@ function sectionCopy(t, chinese) {
2074
2182
  unavailable: t("settings.unavailable"),
2075
2183
  readOnly: t("settings.readOnly"),
2076
2184
  saveFailed: t("settings.saveFailed"),
2185
+ saveFailedShort: t("settings.saveFailedShort"),
2077
2186
  save: t("settings.save"),
2078
2187
  saving: t("settings.saving"),
2188
+ saved: t("settings.saved"),
2189
+ advanced: t("settings.advanced"),
2079
2190
  reset: t("settings.reset"),
2080
2191
  invalidNumber: t("settings.invalidNumber")
2081
2192
  },
@@ -2092,8 +2203,11 @@ function pageCopy(t) {
2092
2203
  unavailable: t("settings.unavailable"),
2093
2204
  readOnly: t("settings.readOnly"),
2094
2205
  saveFailed: t("settings.saveFailed"),
2206
+ saveFailedShort: t("settings.saveFailedShort"),
2095
2207
  save: t("settings.save"),
2096
2208
  saving: t("settings.saving"),
2209
+ saved: t("settings.saved"),
2210
+ advanced: t("settings.advanced"),
2097
2211
  reset: t("settings.reset"),
2098
2212
  invalidNumber: t("settings.invalidNumber")
2099
2213
  },
@@ -2132,12 +2246,12 @@ var CHIP_STYLE = {
2132
2246
  padding: "1px 8px",
2133
2247
  border: "none",
2134
2248
  borderRadius: 999,
2135
- background: "var(--dsw-alias-bg-module-platform, rgba(128, 128, 128, 0.12))",
2249
+ background: "var(--pe-chip-bg, var(--dsw-alias-bg-module-platform, rgba(128, 128, 128, 0.12)))",
2136
2250
  fontFamily: "inherit",
2137
2251
  fontSize: 11,
2138
2252
  fontWeight: 500,
2139
2253
  lineHeight: "17px",
2140
- color: "var(--dsw-alias-label-secondary, inherit)",
2254
+ color: "var(--pe-chip-color, var(--dsw-alias-label-secondary, inherit))",
2141
2255
  textDecoration: "underline",
2142
2256
  textUnderlineOffset: 2,
2143
2257
  cursor: "pointer"
@@ -2182,7 +2296,7 @@ var REPOSITORY_URL = "https://github.com/surfishs/dsh-prompt-enhance";
2182
2296
  var NPM_URL = "https://www.npmjs.com/package/@surfishs/dsh-prompt-enhance";
2183
2297
  var GITHUB_MARK = "M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82a7.6 7.6 0 0 1 2-.27c.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8z";
2184
2298
  var NPM_MARK = "M1.763 0C.786 0 0 .786 0 1.763v20.474C0 23.214.786 24 1.763 24h20.474c.977 0 1.763-.786 1.763-1.763V1.763C24 .786 23.214 0 22.237 0zM5.13 5.323l13.837.019-.009 13.836h-3.464l.01-10.382h-3.456L12.04 19.17H5.113z";
2185
- var PLUGIN_VERSION = true ? "0.0.5" : "0.0.0";
2299
+ var PLUGIN_VERSION = true ? "0.0.7" : "0.0.0";
2186
2300
  var HEADER_STYLE = { display: "flex", flexDirection: "column", gap: 12, padding: "2px 0" };
2187
2301
  var HEADER_ROW_STYLE = { display: "flex", alignItems: "center", gap: 10, flexWrap: "wrap" };
2188
2302
  var HEADER_TITLE_STYLE = {
@@ -2257,6 +2371,16 @@ function viewOf(snapshot, key) {
2257
2371
  invalid: field.invalid === true
2258
2372
  };
2259
2373
  }
2374
+ function defaultTextOf(key) {
2375
+ const descriptor = FIELD_SPECS.find((item) => item.field === key);
2376
+ const fallback = DEFAULT_VALUES[key];
2377
+ if (descriptor === void 0 || fallback === void 0) return "";
2378
+ try {
2379
+ return descriptor.format(fallback);
2380
+ } catch {
2381
+ return "";
2382
+ }
2383
+ }
2260
2384
  function atDefaultValue(key, text) {
2261
2385
  const fallback = DEFAULT_VALUES[key];
2262
2386
  if (fallback === void 0) return text.trim() === "";
@@ -2272,6 +2396,7 @@ function OverrideActions(props) {
2272
2396
  "button",
2273
2397
  {
2274
2398
  type: "button",
2399
+ className: "dsh-pe-chip-reset",
2275
2400
  style: { ...RESET_STYLE, ...props.disabled ? { opacity: 0.5, cursor: "default" } : {} },
2276
2401
  disabled: props.disabled,
2277
2402
  onClick: props.onReset,
@@ -2307,8 +2432,9 @@ function ChoiceRow(props) {
2307
2432
  import_dsh_client_ui_primitives.SegmentedControl,
2308
2433
  {
2309
2434
  id: props.id,
2435
+ className: "dsh-pe-segmented-labels",
2310
2436
  value: props.view.text,
2311
- options: props.options,
2437
+ options: props.options.map((option) => ({ ...option, title: option.title ?? option.label })),
2312
2438
  disabled: props.disabled,
2313
2439
  label: props.label,
2314
2440
  onChange: (next) => props.onEdit(next)
@@ -2383,11 +2509,15 @@ function ReasoningRow(props) {
2383
2509
  options.push({
2384
2510
  value: effort.id,
2385
2511
  label: effort.name,
2386
- ...effort.description === void 0 ? {} : { title: effort.description }
2512
+ title: effort.description === void 0 ? effort.name : `${effort.name} \u2014 ${effort.description}`
2387
2513
  });
2388
2514
  }
2389
2515
  }
2390
- options.push({ value: "inherit", label: props.copy.choice("settings.reasoning.inherit") });
2516
+ options.push({
2517
+ value: "inherit",
2518
+ label: props.copy.choice("settings.reasoning.inherit"),
2519
+ title: props.copy.choice("settings.reasoning.inherit")
2520
+ });
2391
2521
  const unsupported = !noTiers && phase === "ready" && capabilities?.source !== "unavailable" && current2 !== "" && current2 !== "inherit" && !realTierKnown;
2392
2522
  const refreshing = feedback === "refreshing";
2393
2523
  const refresh = () => {
@@ -2401,6 +2531,7 @@ function ReasoningRow(props) {
2401
2531
  "button",
2402
2532
  {
2403
2533
  type: "button",
2534
+ className: "dsh-pe-chip-refresh",
2404
2535
  style: { ...REFRESH_STYLE, opacity: props.disabled || refreshing ? 0.5 : 1 },
2405
2536
  disabled: props.disabled || refreshing,
2406
2537
  onClick: refresh,
@@ -2413,6 +2544,7 @@ function ReasoningRow(props) {
2413
2544
  import_dsh_client_ui_primitives.SegmentedControl,
2414
2545
  {
2415
2546
  id: props.id,
2547
+ className: "dsh-pe-segmented-labels",
2416
2548
  value: noTiers ? "inherit" : props.view.text,
2417
2549
  options,
2418
2550
  disabled: props.disabled,
@@ -2524,14 +2656,19 @@ function ModelRow(props) {
2524
2656
  }
2525
2657
  function TextControl(props) {
2526
2658
  const [focused, setFocused] = (0, import_react8.useState)(false);
2527
- const borderColor = props.invalid === true ? "var(--dsw-alias-state-error-primary, #f85149)" : focused ? "var(--dsw-alias-state-business-primary, #4f8cff)" : void 0;
2659
+ const [revealedInvalid, setRevealedInvalid] = (0, import_react8.useState)(false);
2660
+ (0, import_react8.useEffect)(() => {
2661
+ if (props.invalid !== true) setRevealedInvalid(false);
2662
+ }, [props.invalid]);
2663
+ const showInvalid = props.invalid === true && revealedInvalid;
2664
+ const borderColor = showInvalid ? "var(--dsw-alias-state-error-primary, #f85149)" : focused ? "var(--dsw-alias-state-business-primary, #4f8cff)" : void 0;
2528
2665
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2529
2666
  "input",
2530
2667
  {
2531
2668
  id: props.id,
2532
2669
  type: "text",
2533
2670
  inputMode: props.numeric === true ? "numeric" : void 0,
2534
- "aria-invalid": props.invalid === true || void 0,
2671
+ "aria-invalid": showInvalid || void 0,
2535
2672
  disabled: props.disabled,
2536
2673
  placeholder: props.placeholder,
2537
2674
  value: props.value,
@@ -2541,7 +2678,17 @@ function TextControl(props) {
2541
2678
  ...borderColor === void 0 ? {} : { borderColor }
2542
2679
  },
2543
2680
  onFocus: () => setFocused(true),
2544
- onBlur: () => setFocused(false),
2681
+ onBlur: () => {
2682
+ setFocused(false);
2683
+ if (props.invalid === true) setRevealedInvalid(true);
2684
+ props.onCommit?.();
2685
+ },
2686
+ onKeyDown: (event) => {
2687
+ if (event.key !== "Enter") return;
2688
+ event.preventDefault();
2689
+ if (props.invalid === true) setRevealedInvalid(true);
2690
+ props.onCommit?.();
2691
+ },
2545
2692
  onChange: (event) => props.onChange(event.target.value)
2546
2693
  }
2547
2694
  );
@@ -2562,7 +2709,8 @@ function ValueRow(props) {
2562
2709
  numeric: props.numeric,
2563
2710
  invalid,
2564
2711
  disabled: props.disabled,
2565
- onChange: props.onEdit
2712
+ onChange: props.onEdit,
2713
+ onCommit: props.onCommit
2566
2714
  }
2567
2715
  ),
2568
2716
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { style: HINT_STYLE, children: props.hint }),
@@ -2578,7 +2726,8 @@ function SettingsRow(props) {
2578
2726
  view: props.view,
2579
2727
  disabled: props.disabled,
2580
2728
  onEdit: props.onEdit,
2581
- onReset: props.onReset
2729
+ onReset: props.onReset,
2730
+ onCommit: props.onCommit
2582
2731
  };
2583
2732
  switch (props.row.kind) {
2584
2733
  case "boolean":
@@ -2599,7 +2748,128 @@ function SettingsRows(props) {
2599
2748
  const provider = viewOf(props.state, "provider").text.trim();
2600
2749
  const model = viewOf(props.state, "model").text.trim();
2601
2750
  const routing = useLlmRouting(provider, model);
2602
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_dsh_client_ui_primitives.SettingsForm, { labels: props.copy.labels, state: props.state, onSave: props.save, onDiscard: props.discard, children: ROWS.map((row, index) => {
2751
+ const [saveState, setSaveState] = (0, import_react8.useState)("idle");
2752
+ const timers = (0, import_react8.useRef)(/* @__PURE__ */ new Map());
2753
+ const savedTimer = (0, import_react8.useRef)(void 0);
2754
+ const savedValues = (0, import_react8.useRef)(/* @__PURE__ */ new Map());
2755
+ const sequence = (0, import_react8.useRef)(0);
2756
+ (0, import_react8.useEffect)(() => {
2757
+ for (const row of ROWS) {
2758
+ if (!savedValues.current.has(row.key)) {
2759
+ savedValues.current.set(row.key, viewOf(props.state, row.key).text);
2760
+ }
2761
+ }
2762
+ }, [props.state]);
2763
+ const runSave = async (key, text) => {
2764
+ if (props.writeField === void 0) return;
2765
+ if (savedValues.current.get(key) === text) return;
2766
+ const ticket = ++sequence.current;
2767
+ setSaveState("saving");
2768
+ const result = await props.writeField(key, text);
2769
+ if (ticket !== sequence.current) return;
2770
+ if (result === "invalid") {
2771
+ setSaveState("idle");
2772
+ return;
2773
+ }
2774
+ if (result === "failed") {
2775
+ setSaveState("failed");
2776
+ return;
2777
+ }
2778
+ savedValues.current.set(key, text);
2779
+ markSaved();
2780
+ };
2781
+ const markSaved = () => {
2782
+ setSaveState("saved");
2783
+ if (savedTimer.current !== void 0) clearTimeout(savedTimer.current);
2784
+ savedTimer.current = setTimeout(() => {
2785
+ setSaveState("idle");
2786
+ savedTimer.current = void 0;
2787
+ }, 2e3);
2788
+ };
2789
+ const runReset = async (key, fallback) => {
2790
+ if (props.writeField === void 0) return;
2791
+ const ticket = ++sequence.current;
2792
+ setSaveState("saving");
2793
+ const result = await props.writeField(key, "");
2794
+ if (ticket !== sequence.current) return;
2795
+ if (result === "failed") {
2796
+ setSaveState("failed");
2797
+ return;
2798
+ }
2799
+ if (result === "invalid") {
2800
+ setSaveState("idle");
2801
+ return;
2802
+ }
2803
+ savedValues.current.set(key, fallback);
2804
+ markSaved();
2805
+ };
2806
+ const resetAndSave = (key) => {
2807
+ props.resetField(key);
2808
+ const fallback = defaultTextOf(key);
2809
+ savedValues.current.set(key, fallback);
2810
+ void runReset(key, fallback);
2811
+ };
2812
+ const manualSave = async () => {
2813
+ if (props.writeField === void 0) {
2814
+ props.save?.();
2815
+ markSaved();
2816
+ return;
2817
+ }
2818
+ const changed = ROWS.map((row) => ({ key: row.key, text: viewOf(props.state, row.key).text })).filter((item) => savedValues.current.get(item.key) !== item.text);
2819
+ if (changed.length === 0) {
2820
+ markSaved();
2821
+ return;
2822
+ }
2823
+ const ticket = ++sequence.current;
2824
+ setSaveState("saving");
2825
+ let failed = false;
2826
+ let invalid = false;
2827
+ for (const item of changed) {
2828
+ const result = await props.writeField(item.key, item.text);
2829
+ if (result === "saved") savedValues.current.set(item.key, item.text);
2830
+ else if (result === "failed") failed = true;
2831
+ else invalid = true;
2832
+ }
2833
+ if (ticket !== sequence.current) return;
2834
+ if (failed) setSaveState("failed");
2835
+ else if (invalid && changed.every((item) => savedValues.current.get(item.key) !== item.text)) setSaveState("idle");
2836
+ else markSaved();
2837
+ };
2838
+ const scheduleSave = (key, text, immediate) => {
2839
+ const pending = timers.current.get(key);
2840
+ if (pending !== void 0) clearTimeout(pending);
2841
+ if (immediate) {
2842
+ timers.current.delete(key);
2843
+ void runSave(key, text);
2844
+ return;
2845
+ }
2846
+ const timer = setTimeout(() => {
2847
+ timers.current.delete(key);
2848
+ void runSave(key, text);
2849
+ }, 800);
2850
+ timers.current.set(key, timer);
2851
+ };
2852
+ const onEdit = (key, text) => {
2853
+ props.edit(key, text);
2854
+ const row = ROWS.find((item) => item.key === key);
2855
+ const debounced = row !== void 0 && (row.kind === "text" || row.kind === "number");
2856
+ scheduleSave(key, text, !debounced);
2857
+ };
2858
+ const flushField = (key, text) => {
2859
+ const pending = timers.current.get(key);
2860
+ if (pending !== void 0) {
2861
+ clearTimeout(pending);
2862
+ timers.current.delete(key);
2863
+ }
2864
+ void runSave(key, text ?? viewOf(props.state, key).text);
2865
+ };
2866
+ (0, import_react8.useEffect)(() => () => {
2867
+ for (const timer of timers.current.values()) clearTimeout(timer);
2868
+ timers.current.clear();
2869
+ if (savedTimer.current !== void 0) clearTimeout(savedTimer.current);
2870
+ }, []);
2871
+ const statusText = props.state.writable === false ? props.copy.labels.readOnly : saveState === "saving" ? props.copy.labels.saving : saveState === "saved" ? props.copy.labels.saved : saveState === "failed" ? props.copy.labels.saveFailedShort : "";
2872
+ const renderRow = (row, index) => {
2603
2873
  const raw = viewOf(props.state, row.key);
2604
2874
  const view = raw.overridden && atDefaultValue(row.key, raw.text) ? { ...raw, overridden: false } : raw;
2605
2875
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: index === 0 ? void 0 : SEPARATOR_STYLE, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
@@ -2612,11 +2882,34 @@ function SettingsRows(props) {
2612
2882
  reasoningPair: { provider, model },
2613
2883
  routing,
2614
2884
  providerValue: provider,
2615
- onEdit: (text) => props.edit(row.key, text),
2616
- onReset: () => props.resetField(row.key)
2885
+ onEdit: (text) => onEdit(row.key, text),
2886
+ onReset: () => resetAndSave(row.key),
2887
+ onCommit: () => flushField(row.key, viewOf(props.state, row.key).text)
2617
2888
  }
2618
2889
  ) }, row.key);
2619
- }) });
2890
+ };
2891
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "dsh-pe-form", children: [
2892
+ BASIC_ROWS.map(renderRow),
2893
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("details", { className: "dsh-pe-advanced", children: [
2894
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("summary", { children: props.copy.labels.advanced }),
2895
+ ADVANCED_ROWS.map(renderRow)
2896
+ ] }),
2897
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "dsh-pe-form-footer", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "dsh-pe-save-group", children: [
2898
+ statusText === "" ? null : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "dsh-pe-save-status", role: "status", "aria-live": "polite", children: statusText }),
2899
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2900
+ "button",
2901
+ {
2902
+ type: "button",
2903
+ className: "dsh-pe-save-button",
2904
+ disabled: props.save === void 0 || props.state.writable === false,
2905
+ onClick: () => {
2906
+ void manualSave();
2907
+ },
2908
+ children: props.copy.labels.save
2909
+ }
2910
+ )
2911
+ ] }) })
2912
+ ] });
2620
2913
  }
2621
2914
  function SettingsSection(props) {
2622
2915
  const read = props.usePromptEnhance;
@@ -2642,7 +2935,8 @@ function SettingsSection(props) {
2642
2935
  edit,
2643
2936
  resetField,
2644
2937
  save: props.save,
2645
- discard: props.discard
2938
+ discard: props.discard,
2939
+ writeField: props.writeField
2646
2940
  }
2647
2941
  )
2648
2942
  ] });
@@ -2667,7 +2961,8 @@ function SettingsPage(props) {
2667
2961
  edit,
2668
2962
  resetField,
2669
2963
  save: props.save,
2670
- discard: props.discard
2964
+ discard: props.discard,
2965
+ writeField: props.writeField
2671
2966
  }
2672
2967
  );
2673
2968
  }
@@ -2678,9 +2973,11 @@ var SettingsPageController = class {
2678
2973
  */
2679
2974
  constructor(scope, getLocale) {
2680
2975
  __publicField(this, "form");
2976
+ __publicField(this, "scope");
2681
2977
  __publicField(this, "store");
2682
2978
  __publicField(this, "getLocale");
2683
2979
  this.getLocale = getLocale;
2980
+ this.scope = scope;
2684
2981
  this.form = createSettingsForm(scope);
2685
2982
  this.store = this.form.bind(() => {
2686
2983
  const out = this.form.shell();
@@ -2696,7 +2993,11 @@ var SettingsPageController = class {
2696
2993
  /** The props the slots hand their pages. */
2697
2994
  inject() {
2698
2995
  const face = this.getLocale?.();
2699
- const props = { hooks: { promptEnhance: this.store }, ...this.form.actions() };
2996
+ const props = {
2997
+ hooks: { promptEnhance: this.store },
2998
+ ...this.form.actions(),
2999
+ writeField: (key, text) => this.writeField(key, text)
3000
+ };
2700
3001
  if (face !== void 0) {
2701
3002
  ;
2702
3003
  props.hooks.promptEnhanceLocale = {
@@ -2707,6 +3008,25 @@ var SettingsPageController = class {
2707
3008
  }
2708
3009
  return props;
2709
3010
  }
3011
+ /** Write one field through the host's per-field mutation API. */
3012
+ async writeField(key, text) {
3013
+ const descriptor = FIELD_SPECS.find((item) => item.field === key);
3014
+ if (descriptor === void 0) return "failed";
3015
+ const parsed = descriptor.parse(text);
3016
+ if (parsed === void 0) return "invalid";
3017
+ if (this.scope.set === void 0) return "failed";
3018
+ try {
3019
+ if (parsed.kind === "clear") {
3020
+ if (this.scope.unset === void 0) return "failed";
3021
+ if (!await this.scope.unset(key)) return "failed";
3022
+ } else {
3023
+ if (!await this.scope.set(key, parsed.value)) return "failed";
3024
+ }
3025
+ return "saved";
3026
+ } catch {
3027
+ return "failed";
3028
+ }
3029
+ }
2710
3030
  /** Release the form's subscriptions. */
2711
3031
  dispose() {
2712
3032
  try {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@surfishs/dsh-prompt-enhance",
3
3
  "description": "Prompt enhancement for the dsh web GUI: rewrite the composer draft into a well-structured prompt through the harness LLM service, preview the before/after, then fill back, copy, or undo. Original draft is always preserved.",
4
- "version": "0.0.5",
4
+ "version": "0.0.7",
5
5
  "author": "surfishs",
6
6
  "type": "module",
7
7
  "engines": {