@mengyuly/dsh-ponytail 0.3.4 → 0.4.0
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/CHANGELOG.md +45 -0
- package/README.md +51 -8
- package/README_EN.md +70 -15
- package/dist-provenance.json +26 -11
- package/lib/client.js +305 -0
- package/lib/index.js +1926 -1882
- package/package.json +15 -2
package/lib/client.js
ADDED
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({ id: "@mengyuly/dsh-ponytail", factory: (require) => { const module = { exports: {} };
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/client.ts
|
|
21
|
+
var client_exports = {};
|
|
22
|
+
__export(client_exports, {
|
|
23
|
+
SettingsCard: () => SettingsCard,
|
|
24
|
+
apply: () => apply
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(client_exports);
|
|
27
|
+
var import_react = require("react");
|
|
28
|
+
var SKILLS = ["ponytail-review", "ponytail-audit", "ponytail-debt", "ponytail-gain", "ponytail-help"];
|
|
29
|
+
var MODES = ["inherit", "lite", "full", "ultra", "off"];
|
|
30
|
+
var zh = {
|
|
31
|
+
title: "Ponytail",
|
|
32
|
+
description: "\u9ED8\u8BA4\u6A21\u5F0F\u4E0E\u9644\u52A0\u6280\u80FD\uFF1B\u4E0D\u6539\u52A8\u6838\u5FC3\u89C4\u5219\u3002",
|
|
33
|
+
mode: "\u9ED8\u8BA4\u6A21\u5F0F",
|
|
34
|
+
inherit: "\u8DDF\u968F\u73B0\u6709\u914D\u7F6E",
|
|
35
|
+
lite: "Lite \xB7 \u6309\u9700\u6C42\u76F4\u63A5\u5B8C\u6210",
|
|
36
|
+
modeInfo: "\u67E5\u770B\u6A21\u5F0F\u4ECB\u7ECD",
|
|
37
|
+
"inherit-detail": "\u4E0D\u6307\u5B9A\u9762\u677F\u9ED8\u8BA4\u6A21\u5F0F\uFF0C\u6CBF\u7528\u5DF2\u6709\u914D\u7F6E\uFF1B\u6CA1\u6709\u914D\u7F6E\u65F6\u4F7F\u7528 Full\u3002",
|
|
38
|
+
"lite-detail": "\u76F4\u63A5\u5B8C\u6210\u660E\u786E\u9700\u6C42\uFF0C\u4F18\u5148\u590D\u7528\uFF0C\u4E0D\u4E3A\u51CF\u5C11\u4EE3\u7801\u800C\u6539\u52A8\u73B0\u6709\u67B6\u6784\u3002",
|
|
39
|
+
"full-detail": "\u6309\u4E03\u9636\u68AF\u5224\u65AD\uFF1A\u662F\u5426\u5FC5\u8981 \u2192 \u73B0\u6709\u4EE3\u7801 \u2192 \u6807\u51C6\u5E93 \u2192 \u5E73\u53F0\u80FD\u529B \u2192 \u5DF2\u88C5\u4F9D\u8D56 \u2192 \u5C0F\u8868\u8FBE\u5F0F \u2192 \u6700\u5C0F\u65B0\u5B9E\u73B0\u3002",
|
|
40
|
+
"ultra-detail": "\u66F4\u4E25\u683C\u8981\u6C42\u65B0\u589E\u529F\u80FD\u6216\u62BD\u8C61\u6709\u4F9D\u636E\uFF0C\u4F18\u5148\u5220\u9664\u548C\u590D\u7528\uFF0C\u4F46\u4E0D\u80FD\u7701\u7565\u660E\u786E\u9700\u6C42\u3002",
|
|
41
|
+
"off-detail": "\u505C\u6B62\u6CE8\u5165 Ponytail \u6838\u5FC3\u89C4\u5219\uFF0C\u4E0D\u5378\u8F7D\u63D2\u4EF6\uFF0C\u4E5F\u4E0D\u81EA\u52A8\u5173\u95ED\u9644\u52A0\u6280\u80FD\u3002",
|
|
42
|
+
modeSafety: "\u5B89\u5168\u3001\u8F93\u5165\u6821\u9A8C\u3001\u5FC5\u8981\u9519\u8BEF\u5904\u7406\u4E0E\u6700\u5C0F\u68C0\u67E5\u59CB\u7EC8\u4FDD\u7559\u3002\u6A21\u5F0F\u53EA\u6539\u53D8\u7CBE\u7B80\u7B56\u7565\uFF0C\u4E0D\u964D\u4F4E\u8D28\u91CF\u8981\u6C42\u3002",
|
|
43
|
+
full: "Full \xB7 \u4E03\u9636\u68AF\u9ED8\u8BA4\u7EA6\u675F",
|
|
44
|
+
ultra: "Ultra \xB7 \u66F4\u4E25\u683C\u5730\u907F\u514D\u8FC7\u5EA6\u5B9E\u73B0",
|
|
45
|
+
off: "Off \xB7 \u5173\u95ED\u89C4\u5219\u6CE8\u5165",
|
|
46
|
+
boundary: "\u73AF\u5883\u53D8\u91CF\u548C Profile \u914D\u7F6E\u4F18\u5148\u4E8E\u6B64\u8BBE\u7F6E\uFF1B\u5DF2\u6709\u4F1A\u8BDD\u8986\u76D6\u4FDD\u6301\u4E0D\u53D8\u3002\u5F53\u524D\u4F1A\u8BDD\u8BF7\u7528 /ponytail status \u67E5\u8BE2\u3002",
|
|
47
|
+
skills: "\u9644\u52A0\u6280\u80FD",
|
|
48
|
+
save: "\u4FDD\u5B58\u8BBE\u7F6E",
|
|
49
|
+
saving: "\u6B63\u5728\u4FDD\u5B58\u2026",
|
|
50
|
+
saved: "\u8BBE\u7F6E\u5DF2\u4FDD\u5B58",
|
|
51
|
+
modeHint: "\u4FDD\u5B58\u540E\u7528\u4E8E\u672A\u5355\u72EC\u5207\u6362\u6A21\u5F0F\u7684\u4F1A\u8BDD\uFF0C\u4E0D\u8986\u76D6\u5DF2\u6709\u4F1A\u8BDD\u8BBE\u7F6E\uFF1BOff \u4F1A\u5173\u95ED\u6838\u5FC3\u89C4\u5219\u6CE8\u5165\u3002",
|
|
52
|
+
skillsHint: "\u4EC5\u63A7\u5236\u9644\u52A0\u6280\u80FD\u662F\u5426\u53EF\u7528\uFF0C\u4E0D\u5F71\u54CD Ponytail \u6838\u5FC3\u7EA6\u675F\uFF1B\u52FE\u9009\u4E0D\u4F1A\u81EA\u52A8\u6267\u884C\u6280\u80FD\u3002",
|
|
53
|
+
resetHint: "\u4EC5\u6E05\u9664\u672C\u9762\u677F\u7684\u6A21\u5F0F\u4E0E\u6280\u80FD\u8BBE\u7F6E\uFF0C\u4E0D\u5220\u9664\u65E7\u914D\u7F6E\uFF0C\u4E5F\u4E0D\u91CD\u7F6E\u5F53\u524D\u4F1A\u8BDD\u3002",
|
|
54
|
+
"ponytail-review-hint": "\u68C0\u67E5\u6700\u8FD1\u6539\u52A8\u662F\u5426\u5B58\u5728\u8FC7\u5EA6\u8BBE\u8BA1\u3002",
|
|
55
|
+
"ponytail-audit-hint": "\u5BA1\u67E5\u6574\u4E2A\u4ED3\u5E93\u7684\u590D\u6742\u5EA6\uFF0C\u63D0\u51FA\u7B80\u5316\u5EFA\u8BAE\u3002",
|
|
56
|
+
"ponytail-debt-hint": "\u67E5\u627E Ponytail \u503A\u52A1\u6CE8\u91CA\uFF0C\u6574\u7406\u5DF2\u77E5\u9650\u5236\u4E0E\u5347\u7EA7\u8DEF\u5F84\u3002",
|
|
57
|
+
"ponytail-gain-hint": "\u67E5\u770B\u4E0A\u6E38\u6536\u76CA\u53C2\u8003\uFF0C\u4E0D\u4EE3\u8868\u5F53\u524D\u9879\u76EE\u7684\u5B9E\u6D4B\u6548\u679C\u3002",
|
|
58
|
+
"ponytail-help-hint": "\u8BA9\u6A21\u578B\u4ECB\u7ECD\u6280\u80FD\u7528\u6CD5\uFF1B\u4EC5\u770B\u547D\u4EE4\u5E2E\u52A9\u53EF\u7528 /ponytail help\uFF0C\u4E0D\u8C03\u7528\u6A21\u578B\u3002",
|
|
59
|
+
reset: "\u6062\u590D\u9762\u677F\u9ED8\u8BA4",
|
|
60
|
+
restored: "\u5DF2\u6062\u590D\u9762\u677F\u9ED8\u8BA4\uFF1B\u4E0D\u6E05\u9664\u4F1A\u8BDD\u8986\u76D6\u6216\u5176\u4ED6\u914D\u7F6E",
|
|
61
|
+
readOnly: "\u5F53\u524D\u8FDE\u63A5\u4E0D\u53EF\u5199\uFF0C\u8BBE\u7F6E\u672A\u4FDD\u5B58\u3002",
|
|
62
|
+
unavailable: "\u5BBF\u4E3B\u672A\u63D0\u4F9B Ponytail \u8BBE\u7F6E\uFF1B\u8BF7\u4F7F\u7528 /ponytail \u547D\u4EE4\u3002",
|
|
63
|
+
help: "\u4F7F\u7528\u5E2E\u52A9",
|
|
64
|
+
helpBody: "/ponytail \u5207\u6362\u5F53\u524D\u4F1A\u8BDD\uFF1B/ponytail status \u67E5\u770B\u5B9E\u9645\u72B6\u6001\u548C\u6765\u6E90\uFF1B/ponytail reset \u6E05\u9664\u4F1A\u8BDD\u8986\u76D6\uFF1B/ponytail help \u663E\u793A\u5E2E\u52A9\u3002\u9644\u52A0\u6280\u80FD\u53EA\u5728\u660E\u786E\u6267\u884C\u65F6\u8BF7\u6C42\u6A21\u578B\u5DE5\u4F5C\u3002",
|
|
65
|
+
modeRecommendation: "\u65E5\u5E38\u4F7F\u7528\u63A8\u8350 Full\uFF1A\u5B8C\u6574\u4E03\u9636\u68AF\u7EA6\u675F\uFF0C\u4FDD\u7559\u660E\u786E\u9700\u6C42\u4E0E\u5FC5\u8981\u68C0\u67E5\u3002Lite \u9002\u5408\u76F4\u63A5\u6309\u8981\u6C42\u5B8C\u6210\u3001\u5C11\u8BA8\u8BBA\u66FF\u4EE3\u65B9\u6848\uFF1BUltra \u9002\u5408\u66F4\u4E25\u683C\u63A7\u5236\u65B0\u589E\u590D\u6742\u5EA6\uFF0C\u4E0D\u4EE3\u8868\u6548\u679C\u4E00\u5B9A\u66F4\u597D\u3002\u4E09\u4E2A\u542F\u7528\u6A21\u5F0F\u90FD\u4FDD\u7559\u5B89\u5168\u5E95\u7EBF\u3002",
|
|
66
|
+
failed: "\u4FDD\u5B58\u5931\u8D25\uFF0C\u4FEE\u6539\u5C1A\u672A\u751F\u6548\uFF1A",
|
|
67
|
+
status: "\u67E5\u770B\u5F53\u524D\u6A21\u5F0F\u4E0E\u6765\u6E90",
|
|
68
|
+
sessionReset: "\u5F53\u524D\u4F1A\u8BDD\u8DDF\u968F\u9ED8\u8BA4",
|
|
69
|
+
"ponytail-review": "\u6539\u52A8\u8BC4\u5BA1",
|
|
70
|
+
"ponytail-audit": "\u5168\u4ED3\u5BA1\u8BA1",
|
|
71
|
+
"ponytail-debt": "\u503A\u52A1\u8D26\u672C",
|
|
72
|
+
"ponytail-gain": "\u6536\u76CA\u53C2\u8003",
|
|
73
|
+
"ponytail-help": "\u6280\u80FD\u5E2E\u52A9",
|
|
74
|
+
menuHelp: "\u67E5\u770B\u5E2E\u52A9\uFF08\u4E0D\u8C03\u7528\u6A21\u578B\uFF09",
|
|
75
|
+
switched: "\u53EA\u5207\u6362\u5F53\u524D\u4F1A\u8BDD\uFF0C\u4E0D\u4FEE\u6539\u9ED8\u8BA4\u8BBE\u7F6E"
|
|
76
|
+
};
|
|
77
|
+
var en = {
|
|
78
|
+
title: "Ponytail",
|
|
79
|
+
description: "Default mode and optional skills; core rules stay intact.",
|
|
80
|
+
mode: "Default mode",
|
|
81
|
+
inherit: "Follow existing configuration",
|
|
82
|
+
lite: "Lite \xB7 Complete the direct ask",
|
|
83
|
+
modeInfo: "Show mode description",
|
|
84
|
+
"inherit-detail": "Use existing configuration instead of a panel default; fall back to Full when none is configured.",
|
|
85
|
+
"lite-detail": "Complete explicit requirements, favor reuse, and do not change the architecture just to reduce line count.",
|
|
86
|
+
"full-detail": "Follow seven rungs: necessary? \u2192 existing code \u2192 standard library \u2192 platform feature \u2192 installed dependency \u2192 small expression \u2192 minimal new implementation.",
|
|
87
|
+
"ultra-detail": "Require stronger evidence for additions and abstractions. Favor deletion and reuse without dropping explicit requirements.",
|
|
88
|
+
"off-detail": "Stop Ponytail core rule injection without uninstalling the plugin or automatically disabling optional skills.",
|
|
89
|
+
modeSafety: "Security, input validation, essential error handling, and minimal checks stay intact. Modes change simplification strategy, not quality requirements.",
|
|
90
|
+
full: "Full \xB7 Seven-rung default",
|
|
91
|
+
ultra: "Ultra \xB7 Stronger anti-overengineering",
|
|
92
|
+
off: "Off \xB7 Disable rule injection",
|
|
93
|
+
boundary: "Environment and profile settings take priority. Existing session overrides stay intact. Use /ponytail status for the actual session mode.",
|
|
94
|
+
skills: "Optional skills",
|
|
95
|
+
save: "Save settings",
|
|
96
|
+
saving: "Saving\u2026",
|
|
97
|
+
saved: "Settings saved",
|
|
98
|
+
modeHint: "After saving, applies to sessions without a mode override. Existing overrides stay intact; Off disables core rule injection.",
|
|
99
|
+
skillsHint: "Controls optional skill availability only, not Ponytail core constraints. Checking a skill does not run it.",
|
|
100
|
+
resetHint: "Clears only this panel\u2019s mode and skill settings, not legacy configuration or the current session override.",
|
|
101
|
+
"ponytail-review-hint": "Check recent changes for overengineering.",
|
|
102
|
+
"ponytail-audit-hint": "Review repository-wide complexity and suggest simplifications.",
|
|
103
|
+
"ponytail-debt-hint": "Find Ponytail debt comments and collect known ceilings and upgrade paths.",
|
|
104
|
+
"ponytail-gain-hint": "View upstream impact references, not measured results for this project.",
|
|
105
|
+
"ponytail-help-hint": "Ask the model about skill usage. For command help without a model call, use /ponytail help.",
|
|
106
|
+
reset: "Reset panel defaults",
|
|
107
|
+
restored: "Panel defaults restored; session overrides and other configuration are untouched",
|
|
108
|
+
readOnly: "This connection is read-only; settings were not saved.",
|
|
109
|
+
unavailable: "Ponytail settings are unavailable on this host. Use /ponytail commands.",
|
|
110
|
+
help: "Help",
|
|
111
|
+
helpBody: "/ponytail changes this session; /ponytail status shows the actual mode and source; /ponytail reset clears its override; /ponytail help displays help. Optional skills request model work only when explicitly invoked.",
|
|
112
|
+
modeRecommendation: "Full is recommended for everyday use: the complete seven-rung approach, with explicit requirements and essential checks intact. Lite favors completing the direct ask with less discussion of alternatives. Ultra is for stricter control of added complexity, not necessarily better results. All three enabled modes preserve safety boundaries.",
|
|
113
|
+
failed: "Save failed; changes are not active: ",
|
|
114
|
+
status: "Show current mode and source",
|
|
115
|
+
sessionReset: "Follow defaults in this session",
|
|
116
|
+
"ponytail-review": "Change review",
|
|
117
|
+
"ponytail-audit": "Repository audit",
|
|
118
|
+
"ponytail-debt": "Debt ledger",
|
|
119
|
+
"ponytail-gain": "Impact reference",
|
|
120
|
+
"ponytail-help": "Skill help",
|
|
121
|
+
menuHelp: "Show help (no model call)",
|
|
122
|
+
switched: "Changes only this session, not defaults"
|
|
123
|
+
};
|
|
124
|
+
function SettingsCard({ scope, t }) {
|
|
125
|
+
const id = (0, import_react.useId)();
|
|
126
|
+
const [modeInfoOpen, setModeInfoOpen] = (0, import_react.useState)(false);
|
|
127
|
+
const hoverTimer = (0, import_react.useRef)(void 0);
|
|
128
|
+
const showModeInfo = (open, delay = 0) => {
|
|
129
|
+
clearTimeout(hoverTimer.current);
|
|
130
|
+
if (delay) hoverTimer.current = setTimeout(() => setModeInfoOpen(open), delay);
|
|
131
|
+
else setModeInfoOpen(open);
|
|
132
|
+
};
|
|
133
|
+
(0, import_react.useEffect)(() => () => clearTimeout(hoverTimer.current), []);
|
|
134
|
+
const snapshot = (0, import_react.useSyncExternalStore)(scope.subscribe.bind(scope), scope.getSnapshot.bind(scope));
|
|
135
|
+
const [draft, setDraft] = (0, import_react.useState)(null);
|
|
136
|
+
const [message, setMessage] = (0, import_react.useState)("");
|
|
137
|
+
const [failed, setFailed] = (0, import_react.useState)(false);
|
|
138
|
+
const [busy, setBusy] = (0, import_react.useState)(false);
|
|
139
|
+
const writing = (0, import_react.useRef)(false);
|
|
140
|
+
const current = draft ?? snapshot.value ?? { defaultMode: "inherit", disabledSkills: [] };
|
|
141
|
+
const disabled = busy || !snapshot.writable || snapshot.status !== "ready";
|
|
142
|
+
const edit = (patch) => {
|
|
143
|
+
setMessage("");
|
|
144
|
+
setDraft({ ...current, revision: draft?.revision ?? snapshot.revision, ...patch });
|
|
145
|
+
};
|
|
146
|
+
const save = async (reset = false) => {
|
|
147
|
+
if (writing.current || disabled || !reset && !draft) return;
|
|
148
|
+
writing.current = true;
|
|
149
|
+
setBusy(true);
|
|
150
|
+
setMessage("");
|
|
151
|
+
try {
|
|
152
|
+
const ops = reset ? ["defaultMode", "disabledSkills"].map((field) => ({ op: "unset", path: [field] })) : ["defaultMode", "disabledSkills"].map((field) => ({ op: "set", path: [field], value: current[field] }));
|
|
153
|
+
await scope.mutate(ops, reset ? snapshot.revision : draft?.revision);
|
|
154
|
+
setDraft(null);
|
|
155
|
+
setFailed(false);
|
|
156
|
+
setMessage(t(reset ? "restored" : "saved"));
|
|
157
|
+
} catch (error) {
|
|
158
|
+
setFailed(true);
|
|
159
|
+
setMessage(t("failed") + (error instanceof Error ? error.message : String(error)));
|
|
160
|
+
} finally {
|
|
161
|
+
writing.current = false;
|
|
162
|
+
setBusy(false);
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
return (0, import_react.createElement)(
|
|
166
|
+
"li",
|
|
167
|
+
{ className: "ponytail-settings" },
|
|
168
|
+
(0, import_react.createElement)("h3", null, t("title")),
|
|
169
|
+
(0, import_react.createElement)("p", null, t("description")),
|
|
170
|
+
(0, import_react.createElement)("p", null, t("boundary")),
|
|
171
|
+
snapshot.status !== "ready" ? (0, import_react.createElement)("p", { role: "status" }, t("unavailable")) : null,
|
|
172
|
+
snapshot.status === "ready" && !snapshot.writable ? (0, import_react.createElement)("p", { role: "status" }, t("readOnly")) : null,
|
|
173
|
+
(0, import_react.createElement)(
|
|
174
|
+
"div",
|
|
175
|
+
{
|
|
176
|
+
className: "ponytail-mode",
|
|
177
|
+
onMouseEnter: () => showModeInfo(true, 180),
|
|
178
|
+
onMouseLeave: () => showModeInfo(false, 120),
|
|
179
|
+
onFocus: () => showModeInfo(true),
|
|
180
|
+
onBlur: (event) => {
|
|
181
|
+
if (!event.currentTarget.contains(event.relatedTarget)) showModeInfo(false);
|
|
182
|
+
},
|
|
183
|
+
onKeyDown: (event) => {
|
|
184
|
+
if (event.key === "Escape") showModeInfo(false);
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
(0, import_react.createElement)("label", null, t("mode"), (0, import_react.createElement)(
|
|
188
|
+
"select",
|
|
189
|
+
{
|
|
190
|
+
value: current.defaultMode,
|
|
191
|
+
disabled,
|
|
192
|
+
"aria-describedby": `${id}-mode-detail`,
|
|
193
|
+
onPointerDown: () => showModeInfo(false),
|
|
194
|
+
onChange: (event) => {
|
|
195
|
+
edit({ defaultMode: event.target.value });
|
|
196
|
+
showModeInfo(true);
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
MODES.map((mode) => (0, import_react.createElement)("option", { key: mode, value: mode }, t(mode)))
|
|
200
|
+
)),
|
|
201
|
+
(0, import_react.createElement)("button", {
|
|
202
|
+
type: "button",
|
|
203
|
+
className: "ponytail-mode-info",
|
|
204
|
+
"aria-label": t("modeInfo"),
|
|
205
|
+
"aria-describedby": `${id}-mode-detail`,
|
|
206
|
+
onClick: () => showModeInfo(true)
|
|
207
|
+
}, "i"),
|
|
208
|
+
(0, import_react.createElement)(
|
|
209
|
+
"div",
|
|
210
|
+
{ id: `${id}-mode-detail`, role: "tooltip", hidden: !modeInfoOpen, className: "ponytail-mode-tooltip" },
|
|
211
|
+
(0, import_react.createElement)("strong", { className: "ponytail-tooltip-title" }, t(current.defaultMode)),
|
|
212
|
+
(0, import_react.createElement)("p", { className: "ponytail-tooltip-body" }, t(`${current.defaultMode}-detail`)),
|
|
213
|
+
["lite", "full", "ultra"].includes(current.defaultMode) ? (0, import_react.createElement)("p", { className: "ponytail-tooltip-note" }, t("modeSafety")) : null
|
|
214
|
+
)
|
|
215
|
+
),
|
|
216
|
+
(0, import_react.createElement)("p", { id: `${id}-mode` }, t("modeHint")),
|
|
217
|
+
(0, import_react.createElement)(
|
|
218
|
+
"fieldset",
|
|
219
|
+
{ disabled, "aria-describedby": `${id}-skills` },
|
|
220
|
+
(0, import_react.createElement)("legend", null, t("skills")),
|
|
221
|
+
(0, import_react.createElement)("p", { id: `${id}-skills` }, t("skillsHint")),
|
|
222
|
+
SKILLS.map((skill) => (0, import_react.createElement)("label", { key: skill }, (0, import_react.createElement)("input", {
|
|
223
|
+
type: "checkbox",
|
|
224
|
+
"aria-describedby": `${id}-${skill}`,
|
|
225
|
+
checked: !current.disabledSkills.includes(skill),
|
|
226
|
+
onChange: (event) => edit({ disabledSkills: event.target.checked ? current.disabledSkills.filter((name) => name !== skill) : [...current.disabledSkills, skill] })
|
|
227
|
+
}), (0, import_react.createElement)(
|
|
228
|
+
"span",
|
|
229
|
+
null,
|
|
230
|
+
t(skill),
|
|
231
|
+
(0, import_react.createElement)("small", { style: { display: "block", opacity: 0.7 } }, `/${skill}`),
|
|
232
|
+
(0, import_react.createElement)("small", { id: `${id}-${skill}`, style: { display: "block", lineHeight: 1.5 } }, t(`${skill}-hint`))
|
|
233
|
+
)))
|
|
234
|
+
),
|
|
235
|
+
(0, import_react.createElement)(
|
|
236
|
+
"div",
|
|
237
|
+
{ className: "ponytail-actions" },
|
|
238
|
+
(0, import_react.createElement)("button", { type: "button", disabled: disabled || !draft, onClick: () => {
|
|
239
|
+
void save();
|
|
240
|
+
} }, t(busy ? "saving" : "save")),
|
|
241
|
+
(0, import_react.createElement)("button", { type: "button", disabled, "aria-describedby": `${id}-reset`, onClick: () => {
|
|
242
|
+
void save(true);
|
|
243
|
+
} }, t("reset"))
|
|
244
|
+
),
|
|
245
|
+
(0, import_react.createElement)("p", { id: `${id}-reset` }, t("resetHint")),
|
|
246
|
+
message ? (0, import_react.createElement)("p", { role: failed ? "alert" : "status" }, message) : null,
|
|
247
|
+
(0, import_react.createElement)(
|
|
248
|
+
"details",
|
|
249
|
+
null,
|
|
250
|
+
(0, import_react.createElement)("summary", null, t("help")),
|
|
251
|
+
(0, import_react.createElement)("p", null, t("modeRecommendation")),
|
|
252
|
+
(0, import_react.createElement)("p", null, t("helpBody"))
|
|
253
|
+
)
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
var STYLE = '.ponytail-settings{list-style:none;border:1px solid var(--dsw-alias-border-l4);border-radius:16px;padding:16px;background:var(--dsw-alias-bg-layer-3);color:var(--dsw-alias-label-primary)}.ponytail-settings p{font-size:13px;line-height:1.5;max-width:70ch}.ponytail-settings label{display:flex;align-items:center;gap:10px;margin:10px 0;flex-wrap:wrap}.ponytail-settings fieldset{border:0;padding:12px 0}.ponytail-settings select,.ponytail-settings button{font:inherit;color:inherit;background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l4);border-radius:8px;padding:8px 12px}.ponytail-settings button:disabled{opacity:.5}.ponytail-settings :focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:2px}.ponytail-actions{display:flex;gap:8px;flex-wrap:wrap}.ponytail-settings details{margin-top:14px}.ponytail-mode{position:relative;display:flex;align-items:center;gap:10px;flex-wrap:wrap;width:fit-content;max-width:100%}.ponytail-settings .ponytail-mode-info{display:grid;place-items:center;width:26px;height:26px;padding:0;border-radius:50%;font-size:13px;font-weight:600;background:transparent;cursor:help}.ponytail-mode-tooltip{position:absolute;z-index:10;top:calc(100% + 8px);left:0;box-sizing:border-box;width:min(360px,calc(100vw - 84px));padding:16px;border:1px solid var(--dsw-alias-border-l4);border-radius:12px;background:var(--dsw-alias-bg-layer-3);box-shadow:0 8px 24px #0000001a,0 2px 6px #0000000a;overflow-wrap:anywhere}.ponytail-mode-tooltip::before{content:"";position:absolute;left:0;right:0;top:-12px;height:12px}.ponytail-tooltip-title{display:block;font-size:14px;line-height:1.5}.ponytail-mode-tooltip .ponytail-tooltip-body{margin:8px 0 0;font-size:14px;line-height:1.7}.ponytail-mode-tooltip .ponytail-tooltip-note{margin:12px 0 0;padding-top:10px;border-top:1px solid var(--dsw-alias-border-l4);font-size:12px;line-height:1.6;color:var(--dsw-alias-label-secondary,var(--dsw-alias-label-primary))}.ponytail-mode select{max-width:100%}';
|
|
257
|
+
function apply(ctx) {
|
|
258
|
+
ctx.inject(["locale", "settingsScope", "slots", "connection"], (client) => {
|
|
259
|
+
const t = client.locale.bind("ponytail");
|
|
260
|
+
client.effect(() => client.locale.register("ponytail", { zh, en }), "ponytail: dictionaries");
|
|
261
|
+
client.effect(() => {
|
|
262
|
+
const style = document.createElement("style");
|
|
263
|
+
style.textContent = STYLE;
|
|
264
|
+
document.head.append(style);
|
|
265
|
+
return () => style.remove();
|
|
266
|
+
}, "ponytail: settings style");
|
|
267
|
+
const bound = client.settingsScope.bind({ namespace: "ponytail" });
|
|
268
|
+
const scope = {
|
|
269
|
+
getSnapshot: bound.getSnapshot.bind(bound),
|
|
270
|
+
subscribe: bound.subscribe.bind(bound),
|
|
271
|
+
mutate: typeof bound.mutate === "function" ? bound.mutate.bind(bound) : async (ops, revision) => {
|
|
272
|
+
const response = await client.connection.api.settings.mutate({
|
|
273
|
+
ns: "ponytail",
|
|
274
|
+
ops,
|
|
275
|
+
...revision === void 0 ? {} : { expectedRevision: revision }
|
|
276
|
+
});
|
|
277
|
+
if (!response.result.ok) throw new Error(response.result.error?.message ?? "Ponytail settings write failed");
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
client.slots.inject("settings.plugin.item", () => client.slots.register({
|
|
281
|
+
name: "settings.plugin.item",
|
|
282
|
+
key: "ponytail",
|
|
283
|
+
locale: "ponytail",
|
|
284
|
+
inject: () => ({ scope })
|
|
285
|
+
}, SettingsCard));
|
|
286
|
+
client.inject(["commandUi", "remote"], (menu) => {
|
|
287
|
+
if (typeof menu.commandUi.decorate !== "function" || !menu.remote.commands?.execute) return;
|
|
288
|
+
menu.commandUi.decorate({ name: "ponytail", available: () => true, ui: {
|
|
289
|
+
kind: "popupSelect",
|
|
290
|
+
options: async () => [
|
|
291
|
+
...MODES.filter((mode) => mode !== "inherit").map((mode) => ({ id: mode, label: t(mode), detail: t("switched") })),
|
|
292
|
+
{ id: "status", label: t("status") },
|
|
293
|
+
{ id: "reset", label: t("sessionReset") },
|
|
294
|
+
{ id: "help", label: t("menuHelp") }
|
|
295
|
+
],
|
|
296
|
+
onSelect: async (option, session) => {
|
|
297
|
+
if (!["lite", "full", "ultra", "off", "status", "reset", "help"].includes(option.id)) throw new Error("Unknown Ponytail action");
|
|
298
|
+
const result = await menu.remote.commands.execute(session.sessionId, `/ponytail ${option.id}`, []);
|
|
299
|
+
if (!result.ok) throw new Error(result.error?.message ?? "Ponytail command failed");
|
|
300
|
+
}
|
|
301
|
+
} });
|
|
302
|
+
});
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
return module.exports; } });
|