@dungsil/dsh-plugin-ui-setting-vcs 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/cordis.patch.yml +3 -0
- package/dist/client.js +359 -0
- package/dist/index.js +132 -0
- package/locale/en.json +6 -0
- package/locale/ko.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +94 -3
- package/README.md +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 dungsil
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/cordis.patch.yml
ADDED
package/dist/client.js
ADDED
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({ id: "@dungsil/dsh-plugin-ui-setting-vcs", factory(require) { const module = { exports: {} }; const exports = module.exports;
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
let react = require("react");
|
|
4
|
+
let _deepseek_ai_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
5
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
6
|
+
// ../../tools/ui/src/client.ts
|
|
7
|
+
function useLocaleSnapshot(locale) {
|
|
8
|
+
const subscribe = (0, react.useCallback)((listener) => locale.subscribe(listener), [locale]);
|
|
9
|
+
const getSnapshot = (0, react.useCallback)(() => locale.getSnapshot(), [locale]);
|
|
10
|
+
return (0, react.useSyncExternalStore)(subscribe, getSnapshot);
|
|
11
|
+
}
|
|
12
|
+
/** Each effect owns its sheet, even when another plugin installs the same defaults. */
|
|
13
|
+
function installStyles(css) {
|
|
14
|
+
const style = document.createElement("style");
|
|
15
|
+
style.textContent = css;
|
|
16
|
+
document.head.append(style);
|
|
17
|
+
return () => style.remove();
|
|
18
|
+
}
|
|
19
|
+
// ../../tools/ui/src/settings.tsx
|
|
20
|
+
const settingsStyles = `
|
|
21
|
+
.dsh-plugin-settings-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 0; border-bottom: .5px solid var(--dsw-alias-border-l2); }
|
|
22
|
+
.dsh-plugin-settings-text { flex: 1; min-width: 0; }
|
|
23
|
+
.dsh-plugin-settings-picker { min-width: 0; }
|
|
24
|
+
.dsh-plugin-settings-selector { box-sizing: border-box; display: inline-flex; align-items: center; gap: 12px; max-width: 100%; height: 36px; padding: 0 14px; border: none; border-radius: var(--dsw-radius-md); background: var(--dsw-alias-bg-module-platform); color: inherit; font: inherit; cursor: pointer; }
|
|
25
|
+
.dsh-plugin-settings-value { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
26
|
+
.dsh-plugin-settings-selector svg { flex: none; }
|
|
27
|
+
.dsh-plugin-settings-selector:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover); }
|
|
28
|
+
.dsh-plugin-settings-selector:disabled { opacity: .5; cursor: default; }
|
|
29
|
+
.dsh-plugin-settings-selector:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary-new-colorprimary-new-color); outline-offset: 2px; }
|
|
30
|
+
`;
|
|
31
|
+
function SettingsRow({ label, children }) {
|
|
32
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
33
|
+
className: "dsh-plugin-settings-row",
|
|
34
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
35
|
+
className: "dsh-plugin-settings-text",
|
|
36
|
+
children: label
|
|
37
|
+
}), children]
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
// src/protocol.ts
|
|
41
|
+
const channel = "/api";
|
|
42
|
+
const readMethod = "dungsil-setting-vcs/read";
|
|
43
|
+
const saveMethod = "dungsil-setting-vcs/save";
|
|
44
|
+
function validSettings(value, kind) {
|
|
45
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
46
|
+
const settings = value;
|
|
47
|
+
const target = kind ?? (Object.hasOwn(settings, "directory") ? "worktree" : "panel");
|
|
48
|
+
const keys = target === "worktree" ? ["directory", "prefix"] : ["prefix"];
|
|
49
|
+
if (Object.keys(settings).length !== keys.length || !keys.every((key) => Object.hasOwn(settings, key))) return false;
|
|
50
|
+
if (typeof settings.prefix !== "string" || settings.prefix.length > 100 || settings.prefix !== "" && (!/^[A-Za-z0-9_]/.test(settings.prefix) || /[^A-Za-z0-9_-]/.test(settings.prefix))) return false;
|
|
51
|
+
if (target === "panel") return true;
|
|
52
|
+
const directory = settings.directory;
|
|
53
|
+
return typeof directory === "string" && directory.trim().length > 0 && directory.length <= 4096 && !/[\\\\:\x00-\x1f\x7f]/.test(directory) && directory.split("/").every((part) => part.length > 0 && part !== "." && part !== "..");
|
|
54
|
+
}
|
|
55
|
+
// src/copy.ts
|
|
56
|
+
const copy = {
|
|
57
|
+
en: {
|
|
58
|
+
nav: "Version control",
|
|
59
|
+
scope: "Changes are saved automatically and apply to future worktrees from both tools and the Forge UI. Existing checkouts and Git configuration are not changed.",
|
|
60
|
+
worktree: "Worktrees",
|
|
61
|
+
panel: "Forge panel",
|
|
62
|
+
directory: "Worktree directory",
|
|
63
|
+
prefix: "Worktree name prefix",
|
|
64
|
+
directoryHint: "Use a repository-relative subdirectory with / separators; absolute paths and . or .. segments are not supported.",
|
|
65
|
+
prefixHint: "Used for automatically generated names, not semantic branch naming.",
|
|
66
|
+
unsupported: "The official Forge bundle does not support the previous commit author, commit signing, default checkout selection, tracked remote, delete-on-archive, or semantic branch naming settings. These settings are not migrated or saved here.",
|
|
67
|
+
empty: "No editable Forge settings were found. Enable the official Forge bundle first.",
|
|
68
|
+
loading: "Loading…",
|
|
69
|
+
saving: "Saving…",
|
|
70
|
+
saved: "Saved automatically",
|
|
71
|
+
mixed: "Different values",
|
|
72
|
+
mixedHint: "Existing values differ. Editing a field applies that value to both tool and UI worktrees; other fields are kept unchanged.",
|
|
73
|
+
refresh: "Reload saved values",
|
|
74
|
+
error: "Could not confirm the result. Reload saved values before retrying.",
|
|
75
|
+
conflict: "Settings changed elsewhere. Reload saved values before retrying.",
|
|
76
|
+
invalid: "Enter a valid relative directory (up to 4096 characters). A prefix may be empty or start with an ASCII letter, digit, or underscore, followed by those characters or hyphens (up to 100 characters)."
|
|
77
|
+
},
|
|
78
|
+
ko: {
|
|
79
|
+
nav: "버전 관리",
|
|
80
|
+
scope: "변경 사항은 자동 저장되며, 이후 도구와 Forge UI에서 생성할 워크트리에 공통 적용됩니다. 기존 체크아웃과 Git 설정은 변경하지 않습니다.",
|
|
81
|
+
worktree: "워크트리",
|
|
82
|
+
panel: "Forge 패널",
|
|
83
|
+
directory: "워크트리 디렉터리",
|
|
84
|
+
prefix: "워크트리 이름 접두사",
|
|
85
|
+
directoryHint: "저장소 아래의 상대 경로를 /로 구분해 입력하세요. 절대 경로와 . 또는 .. 경로 조각은 지원하지 않습니다.",
|
|
86
|
+
prefixHint: "자동 생성 이름에 사용하며, 시멘틱 브랜치 이름 형식은 지원하지 않습니다.",
|
|
87
|
+
unsupported: "공식 Forge 번들은 기존의 커밋 작성자, 커밋 서명, 기본 체크아웃 선택, 추적 중인 원격 브랜치, 보관 시 삭제, 시멘틱 브랜치 이름 설정을 지원하지 않습니다. 이 항목들은 여기서 이전하거나 저장하지 않습니다.",
|
|
88
|
+
empty: "편집할 수 있는 Forge 설정이 없습니다. 먼저 공식 Forge 번들을 활성화하세요.",
|
|
89
|
+
loading: "불러오는 중…",
|
|
90
|
+
saving: "저장 중…",
|
|
91
|
+
saved: "자동 저장됨",
|
|
92
|
+
mixed: "서로 다른 값",
|
|
93
|
+
mixedHint: "기존 값이 서로 다릅니다. 항목을 변경하면 도구와 UI 워크트리에 공통 적용하며, 변경하지 않은 항목은 그대로 유지합니다.",
|
|
94
|
+
refresh: "저장된 값 다시 불러오기",
|
|
95
|
+
error: "결과를 확인하지 못했습니다. 저장된 값을 다시 불러온 뒤 재시도하세요.",
|
|
96
|
+
conflict: "다른 곳에서 설정을 변경했습니다. 저장된 값을 다시 불러온 뒤 재시도하세요.",
|
|
97
|
+
invalid: "올바른 상대 디렉터리(4096자 이내)를 입력하세요. 접두사는 비우거나 영문자·숫자·밑줄로 시작해 영문자·숫자·밑줄·하이픈으로 100자 이내로 입력하세요."
|
|
98
|
+
},
|
|
99
|
+
zh: {
|
|
100
|
+
nav: "版本控制",
|
|
101
|
+
scope: "更改会自动保存,并同时应用于之后通过工具和 Forge UI 创建的工作树。不会修改现有检出或 Git 配置。",
|
|
102
|
+
worktree: "工作树",
|
|
103
|
+
panel: "Forge 面板",
|
|
104
|
+
directory: "工作树目录",
|
|
105
|
+
prefix: "工作树名称前缀",
|
|
106
|
+
directoryHint: "请输入以 / 分隔的仓库内相对目录。不支持绝对路径以及 . 或 .. 路径段。",
|
|
107
|
+
prefixHint: "用于自动生成的名称,不支持语义化分支命名。",
|
|
108
|
+
unsupported: "官方 Forge 插件包不支持旧版的提交作者、提交签名、默认检出选择、跟踪远程分支、归档时删除或语义化分支命名设置。此处不会迁移或保存这些设置。",
|
|
109
|
+
empty: "未找到可编辑的 Forge 设置。请先启用官方 Forge 插件包。",
|
|
110
|
+
loading: "正在加载…",
|
|
111
|
+
saving: "正在保存…",
|
|
112
|
+
saved: "已自动保存",
|
|
113
|
+
mixed: "值不一致",
|
|
114
|
+
mixedHint: "现有值不一致。编辑字段会将该值同时应用于工具和 UI 工作树,未编辑的字段保持不变。",
|
|
115
|
+
refresh: "重新加载已保存的值",
|
|
116
|
+
error: "无法确认结果。请重新加载已保存的值后重试。",
|
|
117
|
+
conflict: "设置已在其他位置更改。请重新加载已保存的值后重试。",
|
|
118
|
+
invalid: "请输入有效的相对目录(最多 4096 个字符)。前缀可留空,或以 ASCII 字母、数字、下划线开头,后接这些字符或连字符(最多 100 个字符)。"
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
const localized = (language) => copy[language.startsWith("ko") ? "ko" : language.startsWith("zh") ? "zh" : "en"];
|
|
122
|
+
// src/client.tsx
|
|
123
|
+
const inject = [
|
|
124
|
+
"connection",
|
|
125
|
+
"locale",
|
|
126
|
+
"slots"
|
|
127
|
+
];
|
|
128
|
+
const validPatch = (patch) => (patch.directory === void 0 || validSettings({
|
|
129
|
+
directory: patch.directory,
|
|
130
|
+
prefix: ""
|
|
131
|
+
}, "worktree")) && (patch.prefix === void 0 || validSettings({ prefix: patch.prefix }, "panel"));
|
|
132
|
+
const common = (values) => values.every((value) => value === values[0]) ? values[0] : void 0;
|
|
133
|
+
function VcsSettings({ ctx }) {
|
|
134
|
+
const text = localized(useLocaleSnapshot(ctx.locale).active);
|
|
135
|
+
const id = (0, react.useId)();
|
|
136
|
+
const [view, setView] = (0, react.useState)();
|
|
137
|
+
const [draft, setDraft] = (0, react.useState)({});
|
|
138
|
+
const [loading, setLoading] = (0, react.useState)(true);
|
|
139
|
+
const [saving, setSaving] = (0, react.useState)(false);
|
|
140
|
+
const [savedNotice, setSavedNotice] = (0, react.useState)(false);
|
|
141
|
+
const [notice, setNotice] = (0, react.useState)();
|
|
142
|
+
const saved = (0, react.useRef)();
|
|
143
|
+
const latest = (0, react.useRef)({});
|
|
144
|
+
const pending = (0, react.useRef)(false);
|
|
145
|
+
const blocked = (0, react.useRef)(true);
|
|
146
|
+
const lifetime = (0, react.useRef)(null);
|
|
147
|
+
const connection = ctx.get("connection");
|
|
148
|
+
const load = async () => {
|
|
149
|
+
const signal = lifetime.current?.signal;
|
|
150
|
+
if (!signal || signal.aborted || pending.current) return;
|
|
151
|
+
pending.current = true;
|
|
152
|
+
blocked.current = true;
|
|
153
|
+
setLoading(true);
|
|
154
|
+
try {
|
|
155
|
+
const result = await connection.rpc.call(channel, readMethod, {}, signal);
|
|
156
|
+
if (signal.aborted) return;
|
|
157
|
+
if (!result.ok) throw new Error("unavailable");
|
|
158
|
+
const next = result.value;
|
|
159
|
+
saved.current = next;
|
|
160
|
+
latest.current = {};
|
|
161
|
+
setView(next);
|
|
162
|
+
setDraft({
|
|
163
|
+
directory: common(next.entries.filter((entry) => entry.kind === "worktree").map((entry) => entry.settings.directory)),
|
|
164
|
+
prefix: common(next.entries.map((entry) => entry.settings.prefix))
|
|
165
|
+
});
|
|
166
|
+
setNotice(void 0);
|
|
167
|
+
setSavedNotice(false);
|
|
168
|
+
blocked.current = false;
|
|
169
|
+
} catch {
|
|
170
|
+
if (!signal.aborted) setNotice("error");
|
|
171
|
+
} finally {
|
|
172
|
+
pending.current = false;
|
|
173
|
+
if (!signal.aborted) setLoading(false);
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
const save = async () => {
|
|
177
|
+
const signal = lifetime.current?.signal;
|
|
178
|
+
if (!signal || signal.aborted || pending.current || blocked.current || !saved.current) return;
|
|
179
|
+
pending.current = true;
|
|
180
|
+
setSaving(true);
|
|
181
|
+
try {
|
|
182
|
+
while (Object.keys(latest.current).length && validPatch(latest.current)) {
|
|
183
|
+
const patch = { ...latest.current };
|
|
184
|
+
const baseline = saved.current;
|
|
185
|
+
for (const entry of baseline.entries) {
|
|
186
|
+
const settings = {
|
|
187
|
+
...entry.settings,
|
|
188
|
+
...patch.prefix !== void 0 ? { prefix: patch.prefix } : {},
|
|
189
|
+
...entry.kind === "worktree" && patch.directory !== void 0 ? { directory: patch.directory } : {}
|
|
190
|
+
};
|
|
191
|
+
if (JSON.stringify(settings) === JSON.stringify(entry.settings)) continue;
|
|
192
|
+
const result = await connection.rpc.call(channel, saveMethod, {
|
|
193
|
+
id: entry.id,
|
|
194
|
+
revision: entry.revision,
|
|
195
|
+
settings
|
|
196
|
+
}, signal);
|
|
197
|
+
if (signal.aborted) return;
|
|
198
|
+
if (!result.ok) {
|
|
199
|
+
blocked.current = true;
|
|
200
|
+
setNotice(result.error.code === "conflict" ? "conflict" : "error");
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
const next = result.value.entries.find((item) => item.id === entry.id);
|
|
204
|
+
if (!next) throw new Error("unavailable");
|
|
205
|
+
saved.current = { entries: saved.current.entries.map((item) => item.id === entry.id ? next : item) };
|
|
206
|
+
}
|
|
207
|
+
for (const key of ["directory", "prefix"]) if (latest.current[key] === patch[key]) delete latest.current[key];
|
|
208
|
+
}
|
|
209
|
+
setSavedNotice(Object.keys(latest.current).length === 0);
|
|
210
|
+
} catch {
|
|
211
|
+
if (!signal.aborted) {
|
|
212
|
+
blocked.current = true;
|
|
213
|
+
setNotice("error");
|
|
214
|
+
}
|
|
215
|
+
} finally {
|
|
216
|
+
pending.current = false;
|
|
217
|
+
if (!signal.aborted) setSaving(false);
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
const change = (key, value) => {
|
|
221
|
+
if (blocked.current) return;
|
|
222
|
+
latest.current = {
|
|
223
|
+
...latest.current,
|
|
224
|
+
[key]: value
|
|
225
|
+
};
|
|
226
|
+
setDraft((current) => ({
|
|
227
|
+
...current,
|
|
228
|
+
[key]: value
|
|
229
|
+
}));
|
|
230
|
+
setSavedNotice(false);
|
|
231
|
+
};
|
|
232
|
+
(0, react.useEffect)(() => {
|
|
233
|
+
const controller = new AbortController();
|
|
234
|
+
lifetime.current = controller;
|
|
235
|
+
load();
|
|
236
|
+
return () => controller.abort();
|
|
237
|
+
}, []);
|
|
238
|
+
(0, react.useEffect)(() => {
|
|
239
|
+
if (loading || saving || blocked.current || !validPatch(latest.current) || !Object.keys(latest.current).length) return;
|
|
240
|
+
const timer = setTimeout(() => void save(), 600);
|
|
241
|
+
return () => clearTimeout(timer);
|
|
242
|
+
}, [
|
|
243
|
+
draft,
|
|
244
|
+
loading,
|
|
245
|
+
saving
|
|
246
|
+
]);
|
|
247
|
+
const hasDirectory = view?.entries.some((entry) => entry.kind === "worktree");
|
|
248
|
+
const mixedDirectory = draft.directory === void 0 && hasDirectory;
|
|
249
|
+
const mixedPrefix = draft.prefix === void 0 && !!view?.entries.length;
|
|
250
|
+
const invalidDirectory = draft.directory !== void 0 && !validPatch({ directory: draft.directory });
|
|
251
|
+
const invalidPrefix = draft.prefix !== void 0 && !validPatch({ prefix: draft.prefix });
|
|
252
|
+
const invalid = invalidDirectory || invalidPrefix;
|
|
253
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
254
|
+
className: "dsh-setting-vcs",
|
|
255
|
+
"aria-label": text.nav,
|
|
256
|
+
"aria-busy": loading || saving,
|
|
257
|
+
children: [
|
|
258
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: text.scope }),
|
|
259
|
+
loading && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
260
|
+
role: "status",
|
|
261
|
+
children: text.loading
|
|
262
|
+
}),
|
|
263
|
+
!loading && view?.entries.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: text.empty }),
|
|
264
|
+
!loading && !!view?.entries.length && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("form", {
|
|
265
|
+
onSubmit: (event) => event.preventDefault(),
|
|
266
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("fieldset", {
|
|
267
|
+
disabled: blocked.current,
|
|
268
|
+
children: [
|
|
269
|
+
hasDirectory && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SettingsRow, {
|
|
270
|
+
label: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
|
|
271
|
+
htmlFor: `${id}-directory`,
|
|
272
|
+
children: text.directory
|
|
273
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: text.directoryHint })] }),
|
|
274
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Input, {
|
|
275
|
+
id: `${id}-directory`,
|
|
276
|
+
value: draft.directory ?? "",
|
|
277
|
+
placeholder: mixedDirectory ? text.mixed : void 0,
|
|
278
|
+
maxLength: 4096,
|
|
279
|
+
autoComplete: "off",
|
|
280
|
+
spellCheck: false,
|
|
281
|
+
"aria-invalid": invalidDirectory || void 0,
|
|
282
|
+
"aria-describedby": invalid ? `${id}-invalid` : void 0,
|
|
283
|
+
onChange: (event) => change("directory", event.target.value)
|
|
284
|
+
})
|
|
285
|
+
}),
|
|
286
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SettingsRow, {
|
|
287
|
+
label: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
|
|
288
|
+
htmlFor: `${id}-prefix`,
|
|
289
|
+
children: text.prefix
|
|
290
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: text.prefixHint })] }),
|
|
291
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Input, {
|
|
292
|
+
id: `${id}-prefix`,
|
|
293
|
+
value: draft.prefix ?? "",
|
|
294
|
+
placeholder: mixedPrefix ? text.mixed : void 0,
|
|
295
|
+
maxLength: 100,
|
|
296
|
+
autoComplete: "off",
|
|
297
|
+
spellCheck: false,
|
|
298
|
+
"aria-invalid": invalidPrefix || void 0,
|
|
299
|
+
"aria-describedby": invalid ? `${id}-invalid` : void 0,
|
|
300
|
+
onChange: (event) => change("prefix", event.target.value)
|
|
301
|
+
})
|
|
302
|
+
}),
|
|
303
|
+
invalid && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
304
|
+
id: `${id}-invalid`,
|
|
305
|
+
role: "alert",
|
|
306
|
+
children: text.invalid
|
|
307
|
+
})
|
|
308
|
+
]
|
|
309
|
+
})
|
|
310
|
+
}),
|
|
311
|
+
(mixedDirectory || mixedPrefix) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: text.mixedHint }),
|
|
312
|
+
saving && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
313
|
+
role: "status",
|
|
314
|
+
children: text.saving
|
|
315
|
+
}),
|
|
316
|
+
!saving && savedNotice && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
317
|
+
role: "status",
|
|
318
|
+
children: text.saved
|
|
319
|
+
}),
|
|
320
|
+
notice && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
321
|
+
role: "alert",
|
|
322
|
+
children: text[notice]
|
|
323
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
324
|
+
type: "button",
|
|
325
|
+
disabled: loading || saving,
|
|
326
|
+
onClick: () => void load(),
|
|
327
|
+
children: text.refresh
|
|
328
|
+
})] }),
|
|
329
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
330
|
+
className: "dsh-setting-vcs-note",
|
|
331
|
+
children: text.unsupported
|
|
332
|
+
})
|
|
333
|
+
]
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
function apply(ctx) {
|
|
337
|
+
ctx.slots.inject("settings.section", () => ctx.slots.register({
|
|
338
|
+
name: "settings.section",
|
|
339
|
+
id: "dungsil-ui-setting-vcs",
|
|
340
|
+
order: 18,
|
|
341
|
+
label: () => localized(ctx.locale.getSnapshot().active).nav,
|
|
342
|
+
inject: () => ({ ctx })
|
|
343
|
+
}, VcsSettings));
|
|
344
|
+
ctx.effect(() => installStyles(`${settingsStyles}
|
|
345
|
+
.dsh-setting-vcs { color: var(--dsw-alias-label-primary); font: 14px/22px var(--dsw-font-family, system-ui); }
|
|
346
|
+
.dsh-setting-vcs fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
|
|
347
|
+
.dsh-setting-vcs p { color: var(--dsw-alias-label-secondary); overflow-wrap: anywhere; }
|
|
348
|
+
.dsh-setting-vcs .dsh-plugin-settings-text p { font-size: 12px; line-height: 20px; margin: 4px 0 0; }
|
|
349
|
+
.dsh-setting-vcs input { box-sizing: border-box; width: 240px; max-width: 50%; flex: 0 1 240px; min-width: 0; }
|
|
350
|
+
.dsh-setting-vcs [role=alert] { color: var(--dsw-alias-state-error-primary); }
|
|
351
|
+
.dsh-setting-vcs-note { margin-top: 24px; }
|
|
352
|
+
@media (max-width: 520px) { .dsh-setting-vcs .dsh-plugin-settings-row { align-items: stretch; flex-direction: column; gap: 8px; } .dsh-setting-vcs input { width: 100%; max-width: 100%; flex: auto; } }
|
|
353
|
+
`), "ui-setting-vcs: settings styles");
|
|
354
|
+
}
|
|
355
|
+
exports.VcsSettings = VcsSettings;
|
|
356
|
+
exports.apply = apply;
|
|
357
|
+
exports.inject = inject;
|
|
358
|
+
|
|
359
|
+
return module.exports; } });
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { clientRequestSchema } from "@deepseek-ai/dsh-client-connection";
|
|
3
|
+
// src/protocol.ts
|
|
4
|
+
const channel = "/api";
|
|
5
|
+
const readMethod = "dungsil-setting-vcs/read";
|
|
6
|
+
const saveMethod = "dungsil-setting-vcs/save";
|
|
7
|
+
function validSettings(value, kind) {
|
|
8
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
9
|
+
const settings = value;
|
|
10
|
+
const target = kind ?? (Object.hasOwn(settings, "directory") ? "worktree" : "panel");
|
|
11
|
+
const keys = target === "worktree" ? ["directory", "prefix"] : ["prefix"];
|
|
12
|
+
if (Object.keys(settings).length !== keys.length || !keys.every((key) => Object.hasOwn(settings, key))) return false;
|
|
13
|
+
if (typeof settings.prefix !== "string" || settings.prefix.length > 100 || settings.prefix !== "" && (!/^[A-Za-z0-9_]/.test(settings.prefix) || /[^A-Za-z0-9_-]/.test(settings.prefix))) return false;
|
|
14
|
+
if (target === "panel") return true;
|
|
15
|
+
const directory = settings.directory;
|
|
16
|
+
return typeof directory === "string" && directory.trim().length > 0 && directory.length <= 4096 && !/[\\\\:\x00-\x1f\x7f]/.test(directory) && directory.split("/").every((part) => part.length > 0 && part !== "." && part !== "..");
|
|
17
|
+
}
|
|
18
|
+
// src/index.ts
|
|
19
|
+
const name = "dungsil-ui-setting-vcs";
|
|
20
|
+
const inject = ["connection", "configEditor"];
|
|
21
|
+
const packages = /* @__PURE__ */ new Map([["@deepseek-ai/dsh-experimental-worktree", "worktree"], ["@deepseek-ai/dsh-experimental-client-ui-forge", "panel"]]);
|
|
22
|
+
var SettingsError = class extends Error {
|
|
23
|
+
code;
|
|
24
|
+
constructor(code) {
|
|
25
|
+
super(code);
|
|
26
|
+
this.code = code;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
function record(value) {
|
|
30
|
+
return !!value && typeof value === "object" && !Array.isArray(value) && !("__jsExpr" in value);
|
|
31
|
+
}
|
|
32
|
+
function layers(inherited, current) {
|
|
33
|
+
if (!record(inherited) || !record(current)) throw new SettingsError("unavailable");
|
|
34
|
+
return {
|
|
35
|
+
...inherited,
|
|
36
|
+
...current
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function revision(inherited, current) {
|
|
40
|
+
return createHash("sha256").update(JSON.stringify([inherited, layers(inherited, current)])).digest("hex");
|
|
41
|
+
}
|
|
42
|
+
function settings(kind, inherited, current) {
|
|
43
|
+
const effective = layers(inherited, current);
|
|
44
|
+
const keys = kind === "worktree" ? ["directory", "namePrefix"] : ["worktreePrefix"];
|
|
45
|
+
for (const layer of [inherited, current]) for (const key of keys) if (Object.hasOwn(layer, key) && typeof layer[key] !== "string") throw new SettingsError("unavailable");
|
|
46
|
+
return kind === "worktree" ? {
|
|
47
|
+
directory: effective.directory ?? ".agents/worktrees",
|
|
48
|
+
prefix: effective.namePrefix ?? "dsh-"
|
|
49
|
+
} : { prefix: effective.worktreePrefix ?? "dsh-" };
|
|
50
|
+
}
|
|
51
|
+
function apply(ctx) {
|
|
52
|
+
const editor = ctx.configEditor;
|
|
53
|
+
const rows = () => {
|
|
54
|
+
const candidates = editor.configuration().filter(({ entry }) => packages.has(entry.options.name));
|
|
55
|
+
const ids = /* @__PURE__ */ new Set();
|
|
56
|
+
for (const { entry } of candidates) {
|
|
57
|
+
if (!entry.options.id || ids.has(entry.options.id)) throw new SettingsError("unavailable");
|
|
58
|
+
ids.add(entry.options.id);
|
|
59
|
+
}
|
|
60
|
+
return candidates;
|
|
61
|
+
};
|
|
62
|
+
const view = () => ({ entries: rows().map(({ entry, inherited, override }) => {
|
|
63
|
+
const kind = packages.get(entry.options.name);
|
|
64
|
+
return {
|
|
65
|
+
id: entry.options.id,
|
|
66
|
+
kind,
|
|
67
|
+
revision: revision(inherited, override),
|
|
68
|
+
settings: settings(kind, inherited, override)
|
|
69
|
+
};
|
|
70
|
+
}) });
|
|
71
|
+
for (const endpoint of [readMethod, saveMethod]) ctx.effect(() => ctx.connection.fetch.register({
|
|
72
|
+
path: `${channel}/${endpoint}`,
|
|
73
|
+
methods: ["POST"],
|
|
74
|
+
requestBody: "buffered",
|
|
75
|
+
async fetch(request) {
|
|
76
|
+
let body;
|
|
77
|
+
try {
|
|
78
|
+
body = clientRequestSchema.safeParse(await request.json());
|
|
79
|
+
} catch {
|
|
80
|
+
return new Response("Invalid request", { status: 400 });
|
|
81
|
+
}
|
|
82
|
+
if (!body.success || body.data.method !== endpoint) return new Response("Invalid request", { status: 400 });
|
|
83
|
+
let result;
|
|
84
|
+
try {
|
|
85
|
+
if (endpoint === "dungsil-setting-vcs/save") {
|
|
86
|
+
const payload = body.data.payload;
|
|
87
|
+
if (!record(payload) || Object.keys(payload).length !== 3 || ![
|
|
88
|
+
"id",
|
|
89
|
+
"revision",
|
|
90
|
+
"settings"
|
|
91
|
+
].every((key) => Object.hasOwn(payload, key)) || typeof payload.id !== "string" || typeof payload.revision !== "string" || payload.revision.length !== 64 || !/^[a-f0-9]{64}$/.test(payload.revision)) throw new SettingsError("invalid_request");
|
|
92
|
+
const target = rows().find(({ entry }) => entry.options.id === payload.id);
|
|
93
|
+
if (!target) throw new SettingsError("unavailable");
|
|
94
|
+
const kind = packages.get(target.entry.options.name);
|
|
95
|
+
const next = payload.settings;
|
|
96
|
+
if (!validSettings(next, kind)) throw new SettingsError("invalid_request");
|
|
97
|
+
await editor.edit(target.entry, (current, inherited) => {
|
|
98
|
+
if (revision(inherited, current) !== payload.revision) throw new SettingsError("conflict");
|
|
99
|
+
settings(kind, inherited, current);
|
|
100
|
+
return kind === "worktree" ? {
|
|
101
|
+
...layers(inherited, current),
|
|
102
|
+
directory: next.directory,
|
|
103
|
+
namePrefix: next.prefix
|
|
104
|
+
} : {
|
|
105
|
+
...layers(inherited, current),
|
|
106
|
+
worktreePrefix: next.prefix
|
|
107
|
+
};
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
result = {
|
|
111
|
+
ok: true,
|
|
112
|
+
value: view()
|
|
113
|
+
};
|
|
114
|
+
} catch (error) {
|
|
115
|
+
result = {
|
|
116
|
+
ok: false,
|
|
117
|
+
error: {
|
|
118
|
+
code: error instanceof SettingsError ? error.code : endpoint === "dungsil-setting-vcs/save" ? "save_failed" : "load_failed",
|
|
119
|
+
message: "VCS settings operation failed.",
|
|
120
|
+
details: {}
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
return Response.json({
|
|
125
|
+
type: "server-response",
|
|
126
|
+
rpcId: body.data.rpcId,
|
|
127
|
+
result
|
|
128
|
+
}, { headers: { "Cache-Control": "no-store" } });
|
|
129
|
+
}
|
|
130
|
+
}), "ui-setting-vcs: owner-only settings");
|
|
131
|
+
}
|
|
132
|
+
export { apply, inject, name };
|
package/locale/en.json
ADDED
package/locale/ko.json
ADDED
package/locale/zh.json
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,97 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dungsil/dsh-plugin-ui-setting-vcs",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Configure Git worktree and forge panel defaults in DeepSeek Harness settings.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/dungsil/dsh-plugins.git",
|
|
9
|
+
"directory": "packages/ui-setting-vcs"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"locale",
|
|
14
|
+
"cordis.patch.yml"
|
|
15
|
+
],
|
|
16
|
+
"type": "module",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": "./dist/index.js",
|
|
19
|
+
"./client": "./dist/client.js",
|
|
20
|
+
"./package.json": "./package.json",
|
|
21
|
+
"./locale/*.json": "./locale/*.json"
|
|
22
|
+
},
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@deepseek-ai/cordis": "4.1.0",
|
|
28
|
+
"@deepseek-ai/dsh-app-boot": "0.2.2-rc.3",
|
|
29
|
+
"@deepseek-ai/dsh-client-connection": "0.2.2-rc.3",
|
|
30
|
+
"@deepseek-ai/dsh-client-locale": "0.2.2-rc.3",
|
|
31
|
+
"@deepseek-ai/dsh-client-ui-renderer": "0.2.2-rc.3",
|
|
32
|
+
"@deepseek-ai/dsh-client-ui-settings": "0.2.2-rc.3",
|
|
33
|
+
"@deepseek-ai/dsh-config-editor": "0.2.2-rc.3",
|
|
34
|
+
"@deepseek-ai/dsh-credentials-local": "0.2.2-rc.3",
|
|
35
|
+
"@dungsil/dsh-tsconfig": "0.0.0",
|
|
36
|
+
"@dungsil/dsh-tsdown": "0.0.0",
|
|
37
|
+
"@dungsil/dsh-ui": "0.0.0",
|
|
38
|
+
"@types/react": "18.3.31",
|
|
39
|
+
"@types/react-dom": "18.3.7",
|
|
40
|
+
"happy-dom": "21.0.4",
|
|
41
|
+
"react": "18.3.1",
|
|
42
|
+
"react-dom": "18.3.1",
|
|
43
|
+
"tsdown": "0.23.4"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"@deepseek-ai/cordis": "^4.0.5",
|
|
47
|
+
"@deepseek-ai/dsh-client-connection": "^0.2.2-rc.1",
|
|
48
|
+
"@deepseek-ai/dsh-client-ui-primitives": "^0.2.2-rc.1",
|
|
49
|
+
"@deepseek-ai/dsh-config-editor": "^0.2.2-rc.1"
|
|
50
|
+
},
|
|
51
|
+
"engines": {
|
|
52
|
+
"dsh": "^0.2.2-rc.1",
|
|
53
|
+
"node": ">=24.9.0"
|
|
54
|
+
},
|
|
55
|
+
"dsh": {
|
|
56
|
+
"bundle": {
|
|
57
|
+
"patch": "./cordis.patch.yml"
|
|
58
|
+
},
|
|
59
|
+
"client": {
|
|
60
|
+
"platform": "web",
|
|
61
|
+
"immediately": true,
|
|
62
|
+
"inject": [
|
|
63
|
+
"@deepseek-ai/dsh-client-connection",
|
|
64
|
+
"@deepseek-ai/dsh-client-locale",
|
|
65
|
+
"@deepseek-ai/dsh-client-ui-renderer",
|
|
66
|
+
"@deepseek-ai/dsh-client-ui-settings"
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"market": {
|
|
71
|
+
"order": 7.3,
|
|
72
|
+
"title": {
|
|
73
|
+
"en": "VCS settings",
|
|
74
|
+
"ko": "버전 관리 설정",
|
|
75
|
+
"zh": "版本控制设置"
|
|
76
|
+
},
|
|
77
|
+
"description": {
|
|
78
|
+
"en": "Configure worktree directories and naming prefixes in settings.",
|
|
79
|
+
"ko": "설정에서 worktree 경로와 이름 접두사를 변경합니다.",
|
|
80
|
+
"zh": "在设置中配置 worktree 目录和名称前缀。"
|
|
81
|
+
},
|
|
82
|
+
"category": "ui",
|
|
83
|
+
"labels": [],
|
|
84
|
+
"keywords": [
|
|
85
|
+
"git",
|
|
86
|
+
"worktree",
|
|
87
|
+
"vcs",
|
|
88
|
+
"settings",
|
|
89
|
+
"ui"
|
|
90
|
+
]
|
|
91
|
+
},
|
|
92
|
+
"scripts": {
|
|
93
|
+
"build": "tsdown",
|
|
94
|
+
"typecheck": "tsc --noEmit",
|
|
95
|
+
"test": "node --test test/*.test.mjs"
|
|
96
|
+
}
|
|
6
97
|
}
|
package/README.md
DELETED