dsh-project-flow-explainer 0.0.0-stage → 0.6.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/README.md CHANGED
@@ -1,3 +1,202 @@
1
- # Temporary Holding Version
1
+ # dsh-project-flow-explainer (DSH adapter)
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Adapter mỏng đăng ký 7 tool trong DeepSeek Harness và gọi lại core Python qua subprocess.
4
+ Core không phụ thuộc DSH: xoá thư mục này thì CLI Python vẫn chạy nguyên vẹn.
5
+
6
+ ## Yêu cầu
7
+
8
+ | Thành phần | Giá trị |
9
+ |---|---|
10
+ | Node | `>= 20` (đã test 24.22.3) |
11
+ | DSH | `0.2.2-rc.2` (`engines.dsh`) |
12
+ | Python | 3.12 (chỉ standard library) |
13
+ | Mạng | không cần lúc chạy; chỉ cần khi cài bundle lần đầu vào profile mới |
14
+
15
+ ## Lệnh người dùng: `/project-flow-explainer`
16
+
17
+ Người dùng gõ trực tiếp trong Web UI, không cần nhờ model chọn tool:
18
+
19
+ ```text
20
+ /project-flow-explainer từ lúc bấm xuất báo cáo đến khi nhận được file
21
+ /project-flow-explainer xuất Excel --repo /duong/dan/khac
22
+ ```
23
+
24
+ Plugin đăng ký qua `ctx.commands.register()` (`lib/command.js`), nên:
25
+
26
+ - Kết quả hiện thẳng trong UI, **không vào lịch sử model** và không tốn token —
27
+ đúng đặc tính của command, khác với tool.
28
+ - Repository lấy từ working directory của session; `--repo` để chỉ định nơi khác.
29
+ - Cùng chính sách với tool: `allowedRoots`, cùng core, cùng chỗ ghi artifact.
30
+ - Lệnh không có thì plugin vẫn mount: `commands` là service tùy chọn, composition
31
+ headless không có adapter lệnh.
32
+
33
+ Lệnh trả `{kind:'success', text}` hoặc `{kind:'error', text}` với mã lỗi ổn định
34
+ (`allowed_roots_unconfigured`, `repository_outside_allowed_roots`, `core_timeout`, …).
35
+ Khi giao diện hỏi mã lỗi, đọc nguyên văn trong `text`, không đoán.
36
+
37
+ ## Tool
38
+
39
+ | Tool | Quyền ghi | Ghi chú |
40
+ |---|---|---|
41
+ | `project_flow_explain` | có (artifact flow) | trả đường dẫn tương đối tính từ repository |
42
+ | `project_code_index` | có (`.pfe/index`) | full hoặc incremental |
43
+ | `project_code_search` | không | chỉ trả đường dẫn tương đối |
44
+ | `project_context_pack` | không | mặc định không snippet |
45
+ | `project_impact_analysis` | không | cần index |
46
+ | `project_verify_flow` | không | verdict pass/partial/fail |
47
+ | `project_knowledge_refresh` | có (`.pfe/index`) | chỉ parse lại file đã đổi |
48
+
49
+ ## Cài đặt
50
+
51
+ ### Từ checkout (dev)
52
+
53
+ ```bash
54
+ dsh plugin --profile pfe-test add /duong/dan/project-flow-explainer/dsh-plugin
55
+ ```
56
+
57
+ ### Từ tarball (độc lập, không cần checkout)
58
+
59
+ ```bash
60
+ node dsh-plugin/scripts/pack.mjs # -> dist/dsh-project-flow-explainer-0.3.0.tgz
61
+ dsh plugin --profile pfe-test add "$PWD/dist/dsh-project-flow-explainer-0.3.0.tgz"
62
+ ```
63
+
64
+ Tarball chứa `vendor/core/{scripts,assets,tools,pfe}` do script pack sinh ra từ checkout.
65
+ Bản cài độc lập tìm được `scripts/build_flow.py` và `tools/pfe_cli.py` mà không cần thư mục cha.
66
+
67
+ ## Cấu hình: override row, không insert lại
68
+
69
+ `cordis.patch.yml` của bundle **đã** insert row `project-flow-explainer`.
70
+ Profile chỉ cần override theo id; insert lại cùng id sẽ tạo duplicate loader entry:
71
+
72
+ ```yaml
73
+ - id: project-flow-explainer
74
+ config:
75
+ allowedRoots:
76
+ - /home/ban/workspace
77
+ pythonPath: python3
78
+ timeoutMs: 180000
79
+ maxOutputBytes: 1048576
80
+ ```
81
+
82
+ | Key | Mặc định | Ý nghĩa |
83
+ |---|---|---|
84
+ | `allowedRoots` | không có → từ chối mọi path | danh sách thư mục gốc được đọc, so sánh sau `realpath` |
85
+ | `pythonPath` | `python3` | interpreter gọi core |
86
+ | `coreRoot` | tự dò (`vendor/core` → thư mục cha) | chỉ đặt khi core ở nơi khác; sai là `core_not_found` |
87
+ | `timeoutMs` | `180000` | ngân sách mỗi lần gọi |
88
+ | `maxOutputBytes` | `1048576` | giới hạn stdout/stderr của child |
89
+
90
+ Không có cấu hình nào cho phép artifact ra ngoài `<repo>/artifacts/flows`.
91
+
92
+ ### Profile template `headless`
93
+
94
+ Template này không có API key và cần preset permission tường minh. Thêm vào patch layer:
95
+
96
+ ```yaml
97
+ - id: permission
98
+ config:
99
+ defaultPreset: workspace-write
100
+ - id: project-flow-explainer
101
+ config:
102
+ allowedRoots: ['/duong/dan/workspace']
103
+ ```
104
+
105
+ Thiếu `defaultPreset` thì DSH dừng với lỗi composed sandbox/approval defaults.
106
+
107
+ ## Mã lỗi ổn định
108
+
109
+ | Mã | Khi nào |
110
+ |---|---|
111
+ | `allowed_roots_unconfigured` | thiếu hoặc rỗng `allowedRoots` |
112
+ | `allowed_roots_invalid` | phần tử không phải chuỗi hoặc không tuyệt đối |
113
+ | `repository_outside_allowed_roots` | repo ngoài root sau realpath |
114
+ | `repository_path_missing` / `_invalid_type` / `_relative` | tham số sai |
115
+ | `invalid_artifact_root` / `artifact_symlink_escape` | output không phải `artifacts/flows` |
116
+ | `core_timeout` | vượt `timeoutMs` |
117
+ | `core_failed` / `core_spawn_failed` | core lỗi hoặc không chạy được |
118
+ | `core_cli_not_found` | bản core cũ không có `tools/pfe_cli.py` |
119
+ | `index_missing` | chưa chạy `project_code_index` |
120
+ | `no_changed_files` | impact thiếu `changed_files` và `diff` |
121
+ | `invalid_arguments` | tham số không phải object |
122
+ | `ABORTED` | runtime map từ `Error{name:'AbortError'}` |
123
+
124
+ ## Gỡ cài đặt
125
+
126
+ ```bash
127
+ dsh plugin --profile pfe-test remove dsh-project-flow-explainer
128
+ ```
129
+
130
+ Profile `web` không bị chạm trong mọi bước.
131
+
132
+ ## Kiểm thử
133
+
134
+ ```bash
135
+ node --test dsh-plugin/tests/plugin.test.mjs # policy, artifact, abort, config
136
+ node --test dsh-plugin/tests/knowledge.test.mjs # 6 tool tri thức + validation
137
+ node --test dsh-plugin/tests/lifecycle.test.mjs # mount/dispose/remount, huỷ khi đang chạy
138
+ node --test dsh-plugin/tests/settings.test.mjs # binding settings theo entry id và package name
139
+ node --test dsh-plugin/tests/arguments.test.mjs # từ chối tham số không khai báo, cả 7 tool
140
+ node --test dsh-plugin/tests/command.test.mjs # lệnh /project-flow-explainer (8 test)
141
+ node --test dsh-plugin/tests/pack.test.mjs # pack + cài độc lập
142
+ ```
143
+
144
+ ## Đối chiếu với chuẩn plugin DSH
145
+
146
+ Rà theo gói tài liệu `dsh-plugin-dev` (bản dịch của docs.deepseekdocs.com) và đối chiếu
147
+ với chính bản cài đang chạy.
148
+
149
+ | Chuẩn | Trạng thái trong plugin này |
150
+ |---|---|
151
+ | `export const name` + `export function apply(ctx, config)` | **ĐẠT** (`index.js`) |
152
+ | `inject` khai báo trước khi dùng `ctx.<service>` | **ĐẠT**: `inject = ['tools']`; `settings` lấy qua `ctx.inject` tùy chọn |
153
+ | Tool có `output { schema, render }`, `timeoutMs`, `isConcurrencySafe` | **ĐẠT**: 7/7 tool có đủ ba trường |
154
+ | Tên tool không đụng `run_code` | **ĐẠT** |
155
+ | Config schema + người dùng chỉnh trong Settings | **ĐẠT**, nhưng nạp `@deepseek-ai/schemastery` qua resolver neo vào bản cài (xem dưới) |
156
+ | Bundle layer qua `dsh.bundle.patch` | **ĐẠT**: `cordis.patch.yml`, dòng `insert` id `project-flow-explainer` |
157
+ | Nửa client (nếu có UI) | **ĐẠT**: `dsh.client` + `client.js` đăng ký slot `plugins.bundle.config` / `plugins.row.config` |
158
+ | Hủy và dọn tài nguyên | **ĐẠT**: `exec.signal` → `AbortError`; `ctx.effect` dọn run đang bay |
159
+ | Env của người dùng đọc qua snapshot khởi chạy | **ĐẠT** (working tree, chưa phát hành): `PFE_CORE_ROOT` đọc qua `ctx.get('launchEnvironment')`, lùi về `process.env` khi host không có |
160
+ | Tham số được kiểm trước khi chạy | **ĐẠT** bằng `lib/validate.js` + `rejectUnknownKeys()` (tương đương phần mà `defineTool` lo) |
161
+ | `defineTool` từ `@deepseek-ai/dsh-tools` | **KHÔNG dùng, có chủ ý** — xem dưới |
162
+ | `ctx.invariants`, Typert, `deferLoading`, `presentationMeta` | **KHÔNG dùng**: không cần cho một plugin 7 tool cục bộ |
163
+
164
+ ### Vì sao không dùng `defineTool`
165
+
166
+ `defineTool` là API chuẩn: nó chuyển `parameters` sang JSON Schema và **tự kiểm tham số trước
167
+ khi gọi `execute`**, ném `ToolArgsError`. Plugin này dựng thẳng object rồi `ctx.tools.register()`
168
+ vì `@deepseek-ai/dsh-tools` không resolve được từ thư mục plugin trong profile (kiểm bằng
169
+ `createRequire` từ `~/.dsh/profiles/web/node_modules/dsh-project-flow-explainer/`), và plugin
170
+ giữ cam kết "không import `@deepseek-ai/*`" để bản `link:`/tgz cài được ở mọi profile.
171
+
172
+ Cái mất khi bỏ `defineTool`: runtime **không** kiểm tham số theo schema, và lỗi sai tham số ra
173
+ dạng `InputError` của plugin thay vì `ToolArgsError`. Plugin tự bù đúng phần thiếu đó:
174
+
175
+ | `defineTool` cho gì | Plugin làm gì thay thế |
176
+ |---|---|
177
+ | chuyển `parameters` sang JSON Schema | khai báo thẳng JSON Schema trong định nghĩa tool |
178
+ | kiểm kiểu/giá trị theo schema trước `execute` | `lib/validate.js` kiểm từng trường với mã lỗi riêng (`repository_path_missing`, `top_k_out_of_range`, …) |
179
+ | `additionalProperties: false` được thực thi | `rejectUnknownKeys()` — từ chối khóa lạ bằng mã `unknown_arguments` (`tests/arguments.test.mjs`) |
180
+ | lỗi là `ToolArgsError` | lỗi là `InputError` với `code` ổn định, cộng `hint` |
181
+
182
+ Nếu muốn đúng chuẩn tuyệt đối, thêm `@deepseek-ai/dsh-tools` vào `peerDependencies` rồi bọc
183
+ `defineTool`, và chấp nhận rằng profile phải resolve được gói đó.
184
+
185
+ ### Chi phí prompt của 7 tool
186
+
187
+ Mô tả tool được tính vào system prompt **mỗi bước** của model, nên mỗi dòng phải trả lại giá trị
188
+ định tuyến của nó. Bảy tool hiện tốn **3 517 ký tự `description` + 2 633 ký tự `parameters` =
189
+ 6 150 ký tự (~1 757 token)** mỗi bước.
190
+
191
+ Đã thử cắt xuống 4 dòng/tool (bỏ `ĐIỀU KIỆN` và `TIẾP THEO`) để giảm còn 5 219 ký tự, nhưng
192
+ `dsh-plugin/tests/description.test.mjs` chứng minh đó là đánh đổi sai: model mất thông tin tiên
193
+ quyết và bước kế tiếp nên chọn sai tool, và chi phí của một lần chọn sai lớn hơn 900 ký tự tiết
194
+ kiệm được. Sáu dòng là mức giữ lại đủ. Thêm tool mới thì phải trả chi phí này mỗi bước — ưu tiên
195
+ gộp tool hơn là thêm tool.
196
+
197
+ ### Hợp đồng id của settings
198
+
199
+ `ctx.settings.describe()` trả row theo **id của dòng trong profile**, không phải tên package.
200
+ Plugin nhận cả hai: `project-flow-explainer` (id trong `cordis.patch.yml`) và
201
+ `dsh-project-flow-explainer` (tên package, dùng khi mount tay). Không so khớp theo chuỗi con.
202
+ Nếu dòng settings chưa xuất hiện lúc mount, lần `settings/document-updated` kế tiếp sẽ đọc lại.
package/client.js ADDED
@@ -0,0 +1,273 @@
1
+ window.__ModuleLoader__.load({
2
+ id: "dsh-project-flow-explainer",
3
+ factory: (require) => {
4
+ var module = { exports: {} };
5
+ var exports = module.exports;
6
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
7
+ const React = require("react");
8
+ const h = React.createElement;
9
+
10
+ const PACKAGE = "dsh-project-flow-explainer";
11
+ const ROW_ID = "project-flow-explainer";
12
+ const TOOLS = [
13
+ "project_flow_explain", "project_code_index", "project_code_search",
14
+ "project_context_pack", "project_impact_analysis", "project_verify_flow",
15
+ "project_knowledge_refresh",
16
+ ];
17
+
18
+ const FIELDS = [
19
+ {
20
+ key: "allowedRoots", kind: "lines", label: "Thư mục được đọc",
21
+ hint: "Mỗi dòng một đường dẫn tuyệt đối. Để trống nghĩa là từ chối mọi repository.",
22
+ },
23
+ {
24
+ key: "pythonPath", kind: "text", label: "Interpreter Python",
25
+ hint: "Lệnh hoặc đường dẫn tuyệt đối, ví dụ python3.", placeholder: "python3",
26
+ },
27
+ {
28
+ key: "coreRoot", kind: "text", label: "Thư mục core",
29
+ hint: "Bỏ trống để tự dò vendor/core trong gói đã cài.", placeholder: "(tự dò)",
30
+ },
31
+ {
32
+ key: "timeoutMs", kind: "number", label: "Timeout mỗi lần gọi (ms)",
33
+ hint: "Ngân sách thời gian cho một lần chạy core.", placeholder: "180000",
34
+ },
35
+ {
36
+ key: "maxOutputBytes", kind: "number", label: "Giới hạn output (byte)",
37
+ hint: "Cắt stdout và stderr vượt ngưỡng này.", placeholder: "1048576",
38
+ },
39
+ ];
40
+
41
+ const css = {
42
+ page: { display: "flex", flexDirection: "column", gap: 18, width: "100%", maxWidth: 720 },
43
+ section: { display: "flex", flexDirection: "column", gap: 10 },
44
+ sectionHead: { display: "flex", alignItems: "baseline", justifyContent: "space-between", gap: 8 },
45
+ h2: { margin: 0, fontSize: 14, fontWeight: 600, color: "var(--dsw-alias-label-primary)" },
46
+ meta: { fontSize: 12, color: "var(--dsw-alias-label-secondary)" },
47
+ row: { display: "flex", flexDirection: "column", gap: 4 },
48
+ label: { fontSize: 13, fontWeight: 600, color: "var(--dsw-alias-label-primary)" },
49
+ hint: { fontSize: 12, color: "var(--dsw-alias-label-secondary)", lineHeight: 1.5 },
50
+ input: {
51
+ boxSizing: "border-box", width: "100%", padding: "6px 8px",
52
+ borderRadius: "var(--dsw-radius-md, 8px)",
53
+ border: "0.5px solid var(--dsw-alias-border-l1, #d0d0d0)",
54
+ background: "var(--dsw-alias-card-fill, transparent)",
55
+ color: "var(--dsw-alias-label-primary)", font: "inherit", fontSize: 13,
56
+ },
57
+ textarea: { minHeight: 96, resize: "vertical", fontFamily: "inherit" },
58
+ grid: { display: "grid", gridTemplateColumns: "repeat(auto-fit, minmax(200px, 1fr))", gap: 12 },
59
+ error: { fontSize: 12, color: "var(--dsw-alias-label-error, #c0392b)" },
60
+ actions: { display: "flex", alignItems: "center", gap: 10, flexWrap: "wrap" },
61
+ button: {
62
+ padding: "6px 14px", borderRadius: "var(--dsw-radius-md, 8px)",
63
+ border: "0.5px solid var(--dsw-alias-border-l1, #d0d0d0)",
64
+ background: "var(--dsw-alias-card-fill-hover, #f2f2f2)",
65
+ color: "var(--dsw-alias-label-primary)", font: "inherit", fontSize: 13, cursor: "pointer",
66
+ },
67
+ callout: {
68
+ padding: "8px 10px", borderRadius: "var(--dsw-radius-md, 8px)",
69
+ border: "0.5px solid var(--dsw-alias-border-l1, #d0d0d0)",
70
+ background: "var(--dsw-alias-card-fill, transparent)",
71
+ fontSize: 12, lineHeight: 1.6, color: "var(--dsw-alias-label-secondary)",
72
+ },
73
+ list: { display: "flex", flexWrap: "wrap", gap: 6 },
74
+ chip: {
75
+ padding: "2px 8px", borderRadius: 999,
76
+ border: "0.5px solid var(--dsw-alias-border-l1, #d0d0d0)",
77
+ fontSize: 12, color: "var(--dsw-alias-label-secondary)",
78
+ },
79
+ };
80
+
81
+ function text(value) {
82
+ if (Array.isArray(value)) return value.join("\n");
83
+ if (value === undefined || value === null) return "";
84
+ return String(value);
85
+ }
86
+
87
+ function readForm(form) {
88
+ const state = (form && form.state) || {};
89
+ const value = state.value || {};
90
+ const next = {};
91
+ for (const field of FIELDS) next[field.key] = text(value[field.key]);
92
+ return {
93
+ next,
94
+ writable: state.writable !== false,
95
+ status: state.status || "loading",
96
+ revision: state.revision,
97
+ };
98
+ }
99
+
100
+ /** @returns {{ops: object[], errors: Record<string, string>}} */
101
+ function validate(draft) {
102
+ const errors = {};
103
+ const ops = [];
104
+ for (const field of FIELDS) {
105
+ const raw = draft[field.key];
106
+ if (field.kind === "lines") {
107
+ const lines = text(raw).split("\n").map((line) => line.trim()).filter(Boolean);
108
+ const bad = lines.filter((line) => line.charAt(0) !== "/");
109
+ if (bad.length > 0) errors[field.key] = "Phải là đường dẫn tuyệt đối: " + bad.join(", ");
110
+ else if (lines.includes("/")) errors[field.key] = "Root \"/\" quá rộng, hãy chọn thư mục cụ thể.";
111
+ if (!errors[field.key]) ops.push({ op: "set", path: [field.key], value: lines });
112
+ continue;
113
+ }
114
+ if (field.kind === "number") {
115
+ const trimmed = text(raw).trim();
116
+ if (trimmed === "") continue;
117
+ const parsed = Number(trimmed);
118
+ if (!Number.isInteger(parsed) || parsed <= 0) {
119
+ errors[field.key] = "Phải là số nguyên dương.";
120
+ continue;
121
+ }
122
+ ops.push({ op: "set", path: [field.key], value: parsed });
123
+ continue;
124
+ }
125
+ const trimmed = text(raw).trim();
126
+ if (field.key === "pythonPath" && trimmed === "") {
127
+ errors[field.key] = "Không được để trống.";
128
+ continue;
129
+ }
130
+ if (trimmed === "") ops.push({ op: "unset", path: [field.key] });
131
+ else ops.push({ op: "set", path: [field.key], value: trimmed });
132
+ }
133
+ return { ops, errors };
134
+ }
135
+
136
+ function SettingsPage(props) {
137
+ const form = props.form;
138
+ const initial = readForm(form);
139
+ const [draft, setDraft] = React.useState(initial.next);
140
+ const [errors, setErrors] = React.useState({});
141
+ const [note, setNote] = React.useState("");
142
+ const [busy, setBusy] = React.useState(false);
143
+ const [savedAt, setSavedAt] = React.useState("");
144
+
145
+ React.useEffect(() => {
146
+ setDraft(readForm(form).next);
147
+ }, [form, form && form.state && form.state.revision]);
148
+
149
+ if (props.view === "summary") {
150
+ const roots = text(initial.next.allowedRoots).split("\n").filter(Boolean);
151
+ return h("span", { style: css.meta }, roots.length === 0
152
+ ? "Chưa cấu hình thư mục nào, mọi lời gọi sẽ bị từ chối."
153
+ : roots.length + " thư mục: " + roots.join(", "));
154
+ }
155
+
156
+ if (!form) {
157
+ return h("div", { style: css.page },
158
+ h("div", { style: css.callout },
159
+ "Trang này không nhận được form cấu hình. Mở ",
160
+ h("strong", null, "Configure"), " ở dòng ", h("code", null, ROW_ID),
161
+ " bên dưới để sửa cấu hình, hoặc dùng patch layer ",
162
+ h("code", null, "- id: " + ROW_ID), " (xem dsh-plugin/README.md)."));
163
+ }
164
+
165
+ const update = (key, value) => {
166
+ setDraft((current) => Object.assign({}, current, { [key]: value }));
167
+ setErrors((current) => Object.assign({}, current, { [key]: "" }));
168
+ setNote("");
169
+ };
170
+
171
+ const save = async () => {
172
+ const checked = validate(draft);
173
+ if (Object.keys(checked.errors).length > 0) {
174
+ setErrors(checked.errors);
175
+ setNote("Chưa lưu: còn trường sai.");
176
+ return;
177
+ }
178
+ setBusy(true);
179
+ setNote("");
180
+ try {
181
+ const ok = await form.mutate(checked.ops);
182
+ setNote(ok ? "Đã lưu." : "Host từ chối thay đổi.");
183
+ if (ok) setSavedAt(new Date().toLocaleTimeString());
184
+ } catch (error) {
185
+ setNote("Lỗi khi lưu: " + String((error && error.message) || error));
186
+ } finally {
187
+ setBusy(false);
188
+ }
189
+ };
190
+
191
+ const restore = async () => {
192
+ setBusy(true);
193
+ setNote("");
194
+ try {
195
+ const ok = await form.mutate(FIELDS.map((field) => ({ op: "unset", path: [field.key] })));
196
+ setNote(ok ? "Đã khôi phục mặc định của schema." : "Host từ chối thay đổi.");
197
+ if (ok) setDraft(readForm(form).next);
198
+ } catch (error) {
199
+ setNote("Lỗi khi khôi phục: " + String((error && error.message) || error));
200
+ } finally {
201
+ setBusy(false);
202
+ }
203
+ };
204
+
205
+ const rootsCount = text(draft.allowedRoots).split("\n").map((line) => line.trim())
206
+ .filter(Boolean).length;
207
+ const disabled = busy || !initial.writable;
208
+
209
+ const field = (item) => h("div", { key: item.key, style: css.row },
210
+ h("label", { style: css.label, htmlFor: "pfe-" + item.key }, item.label),
211
+ h(item.kind === "lines" ? "textarea" : "input", {
212
+ id: "pfe-" + item.key,
213
+ style: item.kind === "lines" ? Object.assign({}, css.input, css.textarea) : css.input,
214
+ type: item.kind === "number" ? "number" : "text",
215
+ min: item.kind === "number" ? 1 : undefined,
216
+ placeholder: item.placeholder,
217
+ value: draft[item.key],
218
+ disabled,
219
+ spellCheck: false,
220
+ onChange: (event) => update(item.key, event.target.value),
221
+ }),
222
+ errors[item.key]
223
+ ? h("span", { style: css.error }, errors[item.key])
224
+ : h("span", { style: css.hint }, item.hint));
225
+
226
+ return h("div", { style: css.page },
227
+ h("div", { style: css.section },
228
+ h("div", { style: css.sectionHead },
229
+ h("span", { style: css.meta }, rootsCount + " root đang được đọc")),
230
+ field(FIELDS[0])),
231
+ h("div", { style: css.section },
232
+ h("div", { style: css.sectionHead }, h("h2", { style: css.h2 }, "Runtime")),
233
+ h("div", { style: css.grid }, FIELDS.slice(1).map(field))),
234
+ h("div", { style: css.actions },
235
+ h("button", {
236
+ type: "button", disabled,
237
+ style: Object.assign({}, css.button, disabled ? { opacity: 0.6, cursor: "default" } : {}),
238
+ onClick: save,
239
+ }, busy ? "Đang lưu..." : "Lưu cấu hình"),
240
+ h("button", {
241
+ type: "button", disabled,
242
+ style: Object.assign({}, css.button, disabled ? { opacity: 0.6, cursor: "default" } : {}),
243
+ onClick: restore,
244
+ }, "Khôi phục mặc định"),
245
+ h("span", { style: note.startsWith("Lỗi") || note.startsWith("Chưa lưu") ? css.error : css.meta },
246
+ note || (savedAt ? "Lưu lúc " + savedAt : ""))),
247
+ h("div", { style: css.callout },
248
+ "Deny-by-default: ", h("code", null, "allowedRoots"), " rỗng thì mọi lời gọi trả ",
249
+ h("code", null, "allowed_roots_unconfigured"), ". Đường dẫn được so sánh sau ",
250
+ h("code", null, "realpath"), "; symlink trỏ ra ngoài bị loại. File chứa secret ",
251
+ "không vào index, và tool không trả source thô."),
252
+ h("div", { style: css.section },
253
+ h("div", { style: css.sectionHead },
254
+ h("h2", { style: css.h2 }, "Tool đã đăng ký"),
255
+ h("span", { style: css.meta }, TOOLS.length + " tool")),
256
+ h("div", { style: css.list }, TOOLS.map((tool) => h("code", { key: tool, style: css.chip }, tool)))),
257
+ h("div", { style: css.meta },
258
+ "Gói ", h("code", null, PACKAGE), " · row ", h("code", null, ROW_ID),
259
+ initial.writable ? "" : " · Host đang chặn ghi cấu hình"));
260
+ }
261
+
262
+ function apply(ctx) {
263
+ const options = { name: "plugins.bundle.config", key: PACKAGE };
264
+ ctx.slots.inject("plugins.bundle.config", () => ctx.slots.register(options, SettingsPage));
265
+ ctx.slots.inject("plugins.row.config", () => ctx.slots.register(
266
+ { name: "plugins.row.config", key: PACKAGE + "#" + ROW_ID }, SettingsPage));
267
+ }
268
+
269
+ exports.apply = apply;
270
+ exports.inject = ["slots"];
271
+ return module.exports;
272
+ },
273
+ });
@@ -0,0 +1,26 @@
1
+ # DSH bundle layer: mount the Project Flow Explainer adapter.
2
+ #
3
+ # The plugin is dependency-free: it never imports @deepseek-ai/* (a profile
4
+ # cannot resolve those), it only uses the Context object DSH hands to
5
+ # `apply(ctx, config)`.
6
+ #
7
+ # POLICY - deny-by-default: this row ships WITHOUT `allowedRoots`, so every
8
+ # tool call fails with `allowed_roots_unconfigured` until a profile supplies
9
+ # real roots. This file already inserts the row with id
10
+ # `project-flow-explainer`; a profile must OVERRIDE that id, never insert a
11
+ # second row with the same id:
12
+ #
13
+ # - id: project-flow-explainer
14
+ # config:
15
+ # allowedRoots:
16
+ # - /home/ban/workspace
17
+ # pythonPath: python3
18
+ # timeoutMs: 180000
19
+ # maxOutputBytes: 1048576
20
+ #
21
+ # Config keys: allowedRoots (required to use any tool), pythonPath, coreRoot,
22
+ # timeoutMs, maxOutputBytes. Artifacts are always written to
23
+ # <repo>/artifacts/flows/<slug>/ - not configurable.
24
+ - insert:
25
+ - id: project-flow-explainer
26
+ name: dsh-project-flow-explainer