@linxin666/dsh-liangshen 0.4.1 → 0.4.3

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.i18n.yaml CHANGED
@@ -2,5 +2,5 @@
2
2
  # side as of the last confirmed-consistent state. Both languages carry equal authority;
3
3
  # after editing either side, bring the other along and re-record with:
4
4
  # node scripts/verify-docs.mjs --write <dir>
5
- README.md: 7812a1d2e0d7afe91640c8287bedeae85810dc56
6
- README.zh.md: 0849beef44b789bf7f34c87a3f3fc3c0dab2374a
5
+ README.md: 9a50dbac66119d4f823e718045c3d3bc83582f8b
6
+ README.zh.md: e57260eea0eacc1639a2800ff7901eea14c9f8d7
package/README.md CHANGED
@@ -94,7 +94,7 @@ When validating mode behavior and evaluating performance, verification tiers mus
94
94
  - **Real inference probe**: Verifies only transport connectivity and minimal model response capability to specific formats (e.g. using a headless probe to verify output parsing); a single successful probe demonstrates absence of blockers, but never that mode integration has succeeded.
95
95
  - **Mode integration pass**: Requires full session verification of complete headers, the configured presentation behavior, paged activation and eviction, SDK parameter semantics under `run_code`, and sandbox policy enforcement.
96
96
  - **Statistical improvement**: Must be evaluated across multiple comparative benchmark rounds in an isolated environment with recorded fixed routes and source hashes, evaluating task completion rate, tool failure rate, rule violation rate, human intervention frequency, and time/token costs. Single or few smoke runs do not constitute evidence of performance improvement.
97
- 2. **Benchmark tooling**: the isolated runner is `packages/dsh-liangshen/tools/benchmark-live-run.mjs`. It materializes the evaluated preset into a temporary directory and declares it from the run's own agent-preset registry through a variant patch, redirects session persistence into the run directory, and records a baseline (repository commit, shipped preset hash, DSH version, fixed route, task revision) with every run. The candidate matrix isolates the persona and the presentation strategy: `B` (shipped defaults), `P` (candidate persona), the presentation arms `T` (candidate persona, PTC from the first turn) and `N` (candidate persona, full native roster throughout), and `M` (the bundle's official Minimal preset, an external reference rather than a single-factor arm). Run one smoke case with `node tools/benchmark-live-run.mjs --variant B`, or the bounded matrix over the seed corpus with `node tools/benchmark-live-run.mjs --tasks tools/tasks/liangshen-v41-flash.json --groups B,P,T,N,M --repeat 3 --max-sessions 60 --budget-usd 5`; aggregate the run records in a results directory with `node tools/benchmark-report.mjs .benchmark-results`, which reports per-group success rates with Wilson intervals, paired per-task deltas with confidence intervals, token and cost totals, infrastructure failures separately, and the recorded baseline. Smoke runs validate the protocol and the cost estimate; they are not evidence of a general coding gain.
97
+ 2. **Benchmark tooling**: the isolated runner is `packages/dsh-liangshen/tools/benchmark-live-run.mjs`. It materializes the evaluated preset into a temporary directory and declares it from the run's own agent-preset registry through a variant patch, redirects session persistence into the run directory, and records a baseline (repository commit, shipped preset hash, DSH version, fixed route, task revision) with every run. The candidate matrix isolates the persona and the presentation strategy: `B` (shipped defaults), `P` (candidate persona), the presentation arms `T` (candidate persona, PTC from the first turn) and `N` (candidate persona, full native roster throughout), and `M` (the bundle's official Minimal preset, an external reference rather than a single-factor arm). Run one smoke case with `node tools/benchmark-live-run.mjs --variant B`, or the bounded matrix over the seed corpus with `node tools/benchmark-live-run.mjs --tasks tools/tasks/liangshen-v41-flash.json --groups B,P,T,N,M --repeat 3 --max-sessions 60 --budget-cny 10 --prices tools/prices/deepseek-flash.json`; aggregate the run records in a results directory with `node tools/benchmark-report.mjs .benchmark-results`, which reports per-group success rates with Wilson intervals, paired per-task deltas with confidence intervals, token totals, cost in the price book's currency, model tool errors and transport failures separately, research calls and the inspections preceding the first write, infrastructure failures separately, and the recorded baseline. Cost is CNY because the route bills in CNY, and `tools/prices/deepseek-flash.json` carries the published off-peak row: a peak-hour run costs double what the book records. A budget the run cannot price is refused rather than silently disarmed. A tool result whose error carries a `WEB_*` code counts as a transport failure, so a workspace that could not reach a host never reads as a model that guessed. Smoke runs validate the protocol and the cost estimate; they are not evidence of a general coding gain.
98
98
 
99
99
  ## Configuration
100
100
 
@@ -130,7 +130,7 @@ All fields are editable in the web settings surface (plugin config) or through t
130
130
  - The preset carries the same trust level as shell access — review `presets/liangshen/` before installing;
131
131
  - The plugin makes no network requests and adds no telemetry;
132
132
  - Do not switch presets mid-conversation;
133
- - Requires DSH 0.1.7-rc.1+ (preset mechanism, the `system-prompt/assemble` waterfall, the persona `prefix` schema, and the PTC presentation API).
133
+ - Requires DSH 0.1.7-rc.2+ (preset mechanism, the `system-prompt/assemble` waterfall, the persona `prefix` schema, and the PTC presentation API).
134
134
 
135
135
  ## License
136
136
 
package/README.zh.md CHANGED
@@ -94,7 +94,7 @@ dsh plugin --profile web remove @linxin666/dsh-liangshen
94
94
  - **真实推理探针**:仅验证链路连通性与模型对特定格式的最小响应能力(例如使用 headless 探针验证模型是否能正常解析输出);单次探针成功仅代表功能未阻断,绝不证明模式集成已达标。
95
95
  - **模式集成通过**:要求在真实完整会话中,验证完整 header、所配置呈现行为、分页激活与驱逐、`run_code` 下的 SDK 参数语义解析与沙箱策略执行无误。
96
96
  - **统计显著性提升**:必须在固定 route 与源码 hash 记录的隔离环境中进行多轮对比评测,综合评估任务完成率、工具失败率、规则违反率、人工介入次数与耗时/token 开销。单次或少数 smoke 运行不构成效果提升的证据。
97
- 2. **评测工具**:隔离 runner 位于 `packages/dsh-liangshen/tools/benchmark-live-run.mjs`:它把被评测 preset 物化到临时目录,并通过 variant patch 在本轮自己的 agent-preset registry 中声明它,把会话持久化改写到本次运行目录,并为每次运行记录基线(仓库提交、出厂 preset hash、DSH 版本、固定 route、任务版本)。候选矩阵隔离 persona 与呈现策略两个因素:`B`(出厂默认)、`P`(候选 persona)、呈现臂 `T`(候选 persona,首轮即 PTC)与 `N`(候选 persona,全程原生清单)、以及 `M`(内置包官方 Minimal preset,仅作外部参照而非单因素对照)。单次 smoke 用 `node tools/benchmark-live-run.mjs --variant B`,按种子任务集跑有界矩阵用 `node tools/benchmark-live-run.mjs --tasks tools/tasks/liangshen-v41-flash.json --groups B,P,T,N,M --repeat 3 --max-sessions 60 --budget-usd 5`,再用 `node tools/benchmark-report.mjs .benchmark-results` 汇总结果目录:按组给出成功率与 Wilson 区间、按任务配对差值与置信区间、token 与费用合计、单独列出的基础设施失败以及记录的基线。smoke 只验证协议与费用估算,不构成通用编码能力提升的证据。
97
+ 2. **评测工具**:隔离 runner 位于 `packages/dsh-liangshen/tools/benchmark-live-run.mjs`:它把被评测 preset 物化到临时目录,并通过 variant patch 在本轮自己的 agent-preset registry 中声明它,把会话持久化改写到本次运行目录,并为每次运行记录基线(仓库提交、出厂 preset hash、DSH 版本、固定 route、任务版本)。候选矩阵隔离 persona 与呈现策略两个因素:`B`(出厂默认)、`P`(候选 persona)、呈现臂 `T`(候选 persona,首轮即 PTC)与 `N`(候选 persona,全程原生清单)、以及 `M`(内置包官方 Minimal preset,仅作外部参照而非单因素对照)。单次 smoke 用 `node tools/benchmark-live-run.mjs --variant B`,按种子任务集跑有界矩阵用 `node tools/benchmark-live-run.mjs --tasks tools/tasks/liangshen-v41-flash.json --groups B,P,T,N,M --repeat 3 --max-sessions 60 --budget-cny 10 --prices tools/prices/deepseek-flash.json`,再用 `node tools/benchmark-report.mjs .benchmark-results` 汇总结果目录:按组给出成功率与 Wilson 区间、按任务配对差值与置信区间、token 合计、按价格书币种计的费用、分列的模型工具错误与传输失败、研究调用次数与首次写入前的检查次数、单独列出的基础设施失败以及记录的基线。费用以 CNY 计,因为该路由以 CNY 计费,`tools/prices/deepseek-flash.json` 承载已发布的非高峰价:高峰时段运行的实际成本是该记录的两倍。无法计价的预算会被拒绝而不是被静默解除。错误码以 `WEB_*` 开头的工具结果计为传输失败,因此无法访问主机的环境绝不会被读成模型靠猜。smoke 只验证协议与费用估算,不构成通用编码能力提升的证据。
98
98
 
99
99
  ## 配置
100
100
 
@@ -130,7 +130,7 @@ dsh plugin --profile web remove @linxin666/dsh-liangshen
130
130
  - preset 与 shell 访问具有相同信任等级,安装前可自行审阅 `presets/liangshen/`;
131
131
  - 插件不发起网络请求,也不增加遥测;
132
132
  - 不要在已经产生内容的会话中途切换 preset;
133
- - 需要 DSH 0.1.7-rc.1+(preset 机制、`system-prompt/assemble` 瀑布、persona 的 `prefix` schema,以及 PTC 呈现 API)。
133
+ - 需要 DSH 0.1.7-rc.2+(preset 机制、`system-prompt/assemble` 瀑布、persona 的 `prefix` schema,以及 PTC 呈现 API)。
134
134
 
135
135
  ## 许可
136
136
 
package/lib/client.js CHANGED
@@ -1881,22 +1881,135 @@ window.__ModuleLoader__.load({
1881
1881
  reconcile();
1882
1882
  }
1883
1883
  //#endregion
1884
+ //#region src/client/settings-entry-form.ts
1885
+ /** The snapshot a form reports before the Host has answered with this entry. */
1886
+ function pendingSnapshot() {
1887
+ return {
1888
+ status: "loading",
1889
+ value: void 0,
1890
+ base: void 0,
1891
+ user: void 0,
1892
+ revision: void 0,
1893
+ writable: false,
1894
+ mode: "host"
1895
+ };
1896
+ }
1897
+ /**
1898
+ * Create a settings form bound to the profile entry id this Host serves, and
1899
+ * rebound whenever the shared describe mirror names a different one of this
1900
+ * package's rows.
1901
+ * @param options - the shared forms service and this package's candidate row ids.
1902
+ * @returns a form delegating to the currently resolved entry's own form.
1903
+ */
1904
+ function createServedEntryForm(options) {
1905
+ const { forms, entryIds } = options;
1906
+ const fallbackId = entryIds[0];
1907
+ const namespaceId = entryIds[entryIds.length - 1];
1908
+ const listeners = /* @__PURE__ */ new Set();
1909
+ let boundId;
1910
+ let bound;
1911
+ let offBound;
1912
+ let snapshot = pendingSnapshot();
1913
+ /** Republish: the delegated snapshot when one is bound, the pending one otherwise. */
1914
+ const publish = () => {
1915
+ if (bound !== void 0) snapshot = bound.getSnapshot();
1916
+ for (const listener of [...listeners]) listener();
1917
+ };
1918
+ /**
1919
+ * The entry id the mirror currently justifies. An unanswered or empty mirror
1920
+ * is not evidence of absence, so it keeps the first candidate; a mirror that
1921
+ * answers without any of this package's rows leaves the namespace itself.
1922
+ * @returns the entry id to bind.
1923
+ */
1924
+ const resolve = () => {
1925
+ let served;
1926
+ try {
1927
+ served = forms.describe().getSnapshot().view?.namespaces.map((row) => row.ns);
1928
+ } catch {
1929
+ served = void 0;
1930
+ }
1931
+ if (served === void 0 || served.length === 0) return fallbackId;
1932
+ return entryIds.find((id) => served.includes(id)) ?? namespaceId;
1933
+ };
1934
+ /** Bind (or rebind) the resolved entry's form; a no-op while it is unchanged. */
1935
+ const bind = () => {
1936
+ const target = resolve();
1937
+ if (target === boundId) return;
1938
+ offBound?.();
1939
+ offBound = void 0;
1940
+ let form;
1941
+ try {
1942
+ form = forms.get(target);
1943
+ } catch {
1944
+ boundId = void 0;
1945
+ return;
1946
+ }
1947
+ boundId = target;
1948
+ bound = form;
1949
+ offBound = form.subscribe(() => {
1950
+ publish();
1951
+ });
1952
+ publish();
1953
+ };
1954
+ try {
1955
+ forms.describe().subscribe(() => {
1956
+ bind();
1957
+ });
1958
+ } catch {}
1959
+ bind();
1960
+ return {
1961
+ getSnapshot: () => snapshot,
1962
+ subscribe: (listener) => {
1963
+ listeners.add(listener);
1964
+ return () => {
1965
+ listeners.delete(listener);
1966
+ };
1967
+ },
1968
+ set: (field, value) => bound?.set(field, value) ?? Promise.resolve(false),
1969
+ unset: (field) => bound?.unset(field) ?? Promise.resolve(false),
1970
+ mutate: (ops, expectedRevision) => bound?.mutate(ops, expectedRevision) ?? Promise.resolve(false)
1971
+ };
1972
+ }
1973
+ //#endregion
1884
1974
  //#region src/client/index.ts
1885
1975
  /** Locale namespace this half owns. */
1886
1976
  const NS = "liangshen";
1887
1977
  /**
1888
- * Settings namespace the settings card edits. Under the 0.1.7 settings
1889
- * contract the namespace IS the Host profile entry id, so this names the
1890
- * standalone row; the aggregate install mounts the generated
1891
- * `web-ui-liangshen` row instead and the family binder resolves between the
1892
- * two. Without that binder the card binds the entry id directly.
1978
+ * Settings namespace the settings card edits: the family identity of this
1979
+ * plugin's own settings form, and the row id a standalone bundle install
1980
+ * carries. The aggregate install mounts the generated `web-ui-liangshen` row
1981
+ * instead, and the family binder resolves between the two.
1893
1982
  */
1894
1983
  const SETTINGS_NAMESPACE = "liangshen";
1984
+ /**
1985
+ * Profile entry id the family aggregate's generated row carries — the shape
1986
+ * nearly every user runs, and the id the shared-forms fallback binds when the
1987
+ * family binder cannot resolve the namespace.
1988
+ */
1989
+ const AGGREGATE_ENTRY_ID = "web-ui-liangshen";
1990
+ /** Profile entry ids this package's patch rows carry, most specific first. */
1895
1991
  const LIANGSHEN_ENTRY_IDS = [
1896
- "web-ui-liangshen",
1992
+ AGGREGATE_ENTRY_ID,
1897
1993
  "ui-liangshen",
1898
1994
  SETTINGS_NAMESPACE
1899
1995
  ];
1996
+ /**
1997
+ * The profile entry id this package's own row carries, for a page that serves
1998
+ * no family binder.
1999
+ *
2000
+ * The shared describe mirror is the only local evidence of which row id this
2001
+ * profile actually serves, but it answers asynchronously: at plugin activation
2002
+ * it usually holds nothing yet. An unanswered or empty mirror is therefore NOT
2003
+ * evidence of absence, and binding the bare namespace there is what made every
2004
+ * save fail with `No configurable plugin entry "liangshen"` — the form is
2005
+ * bound once per session, so a wrong guess never recovers. The aggregate row id
2006
+ * is the answer that matches nearly every deployment; only a mirror that
2007
+ * answers with OTHER plugins' rows keeps the namespace as the last resort (the
2008
+ * pre-0.1.7 keying shape), because that answer is the one that actually proves
2009
+ * this package's own row is not served.
2010
+ * @param forms - the shared configuration forms service.
2011
+ * @returns the entry id to bind.
2012
+ */
1900
2013
  function servedEntryId(forms) {
1901
2014
  let served;
1902
2015
  try {
@@ -1904,10 +2017,31 @@ window.__ModuleLoader__.load({
1904
2017
  } catch {
1905
2018
  served = void 0;
1906
2019
  }
1907
- if (!served || served.length === 0) return SETTINGS_NAMESPACE;
2020
+ if (served === void 0 || served.length === 0) return AGGREGATE_ENTRY_ID;
1908
2021
  return LIANGSHEN_ENTRY_IDS.find((id) => served.includes(id)) ?? "liangshen";
1909
2022
  }
1910
2023
  /**
2024
+ * Bind the settings form the card stages over.
2025
+ *
2026
+ * The family binder comes first: it is what resolves this package's family
2027
+ * namespace onto the profile entry id the Host serves the form under, and it
2028
+ * keeps the loopback bridge as its own fallback. A page without that group (or
2029
+ * one where its client half has not applied yet) binds through the shared forms
2030
+ * service, on the entry id the describe mirror justifies and rebound as soon as
2031
+ * the mirror answers — see {@link createServedEntryForm} for why a one-shot
2032
+ * guess cannot be right for both an aggregate and a standalone install.
2033
+ * @param ctx - the browser plugin context.
2034
+ * @returns the form the settings card reads and writes.
2035
+ */
2036
+ function bindSettingsForm(ctx) {
2037
+ const binder = ctx.get("webUiSettings");
2038
+ if (binder !== void 0 && typeof binder.bind === "function") return binder.bind({ namespace: SETTINGS_NAMESPACE });
2039
+ return createServedEntryForm({
2040
+ forms: ctx.configForms,
2041
+ entryIds: LIANGSHEN_ENTRY_IDS
2042
+ });
2043
+ }
2044
+ /**
1911
2045
  * Required client services: the slot registry, locale, sessions, the shared
1912
2046
  * configuration forms, and the roster Remote. Both `remote` and
1913
2047
  * `remote.agentPresets` are declared: the context proxy refuses an uninjected
@@ -1944,8 +2078,7 @@ window.__ModuleLoader__.load({
1944
2078
  controller.start();
1945
2079
  } catch {}
1946
2080
  try {
1947
- const binder = ctx.get("webUiSettings");
1948
- const settingsCard = new LiangShenSettingsCardController(binder !== void 0 && typeof binder.bind === "function" ? binder.bind({ namespace: SETTINGS_NAMESPACE }) : ctx.configForms.get(servedEntryId(ctx.configForms)));
2081
+ const settingsCard = new LiangShenSettingsCardController(bindSettingsForm(ctx));
1949
2082
  installPluginCard(ctx, {
1950
2083
  bundle: "@linxin666/dsh-liangshen",
1951
2084
  id: "liangshen",
@@ -1981,9 +2114,11 @@ window.__ModuleLoader__.load({
1981
2114
  exports.NS = NS;
1982
2115
  exports.SETTINGS_NAMESPACE = SETTINGS_NAMESPACE;
1983
2116
  exports.apply = apply;
2117
+ exports.bindSettingsForm = bindSettingsForm;
1984
2118
  exports.inject = inject;
1985
2119
  exports.leverState = leverState;
1986
2120
  exports.restoreTarget = restoreTarget;
2121
+ exports.servedEntryId = servedEntryId;
1987
2122
  return module.exports;
1988
2123
  }
1989
2124
  });