dsh-advisor 0.1.4 → 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/README.i18n.yaml +2 -2
- package/README.md +60 -227
- package/README.zh.md +59 -106
- package/lib/advisor-runtime.d.ts +16 -14
- package/lib/advisor-runtime.js +19 -17
- package/lib/advisor-runtime.js.map +1 -1
- package/lib/commands.d.ts +48 -0
- package/lib/commands.js +51 -2
- package/lib/commands.js.map +1 -1
- package/lib/index.d.ts +3 -0
- package/lib/index.js +58 -8
- package/lib/index.js.map +1 -1
- package/lib/tui.d.ts +60 -0
- package/lib/tui.js +113 -0
- package/lib/tui.js.map +1 -0
- package/package.json +1 -1
package/lib/tui.js
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dsh-tui client surface (plan dsh-advisor-tui-client-n8, T1) — the
|
|
3
|
+
* `tuiCommandTrees` /advisor provider.
|
|
4
|
+
*
|
|
5
|
+
* In a `dsh --profile dsh-tui` terminal session the plugin's `/advisor`
|
|
6
|
+
* command (registered through the conditional `ctx.inject(['commands'], ...)`
|
|
7
|
+
* child) already lands in the TUI `/` menu via the command-registry merge.
|
|
8
|
+
* What the TUI cannot infer is the LOCALIZED row description and the typed
|
|
9
|
+
* subcommand COMPLETION — those come from the optional `tuiCommandTrees`
|
|
10
|
+
* host service (`src/dsh-adapter/command-trees.ts` in dsh-TUI): a provider
|
|
11
|
+
* declares `root`, zh/en `descriptions`, and a `children(canonicalPath)`
|
|
12
|
+
* completion tree (root at index 0; the TUI asks at depth 2 when completing
|
|
13
|
+
* `/advisor <sub> ⋯`).
|
|
14
|
+
*
|
|
15
|
+
* This module is the advisor's TUI seam: `installTuiClient` conditionally
|
|
16
|
+
* injects `tuiCommandTrees` and registers the `/advisor` tree when the
|
|
17
|
+
* service exists; a profile without the `dsh-tui-command-trees` row (or any
|
|
18
|
+
* non-TUI host) gets a clean no-op. The provider shapes are minimal LOCAL
|
|
19
|
+
* structural copies of the dsh-TUI types — the advisor MUST NOT import
|
|
20
|
+
* `@deepseek-harness-tui/dsh-tui` (zero new peers, plan Global Constraint),
|
|
21
|
+
* so drift against the upstream shape is bounded to the structural cast at
|
|
22
|
+
* the inject boundary and pinned by `tests/tui-client.test.ts`.
|
|
23
|
+
*
|
|
24
|
+
* @module dsh-advisor/tui
|
|
25
|
+
*/
|
|
26
|
+
/** The `/advisor` tree root (matches the command registry name). */
|
|
27
|
+
export const ADVISOR_TUI_ROOT = 'advisor';
|
|
28
|
+
/** The four typed `/advisor` subcommands surfaced as completion children.
|
|
29
|
+
* Bare `/advisor` (toggle) is the empty-argument default, not a completion
|
|
30
|
+
* child (compass S1); `USAGE` is the unknown-subcommand fallback, not a
|
|
31
|
+
* named command. */
|
|
32
|
+
const ADVISOR_SUBCOMMANDS = ['on', 'off', 'status', 'config'];
|
|
33
|
+
/** zh/en copy for the `/` menu row (shown via the host's `descriptions(root)`). */
|
|
34
|
+
const ADVISOR_TUI_DESCRIPTIONS = {
|
|
35
|
+
zh: '按会话运行的评审顾问:开启 / 关闭 / 状态 / 配置',
|
|
36
|
+
en: 'Per-session advisor: enable, disable, status, or config',
|
|
37
|
+
};
|
|
38
|
+
/** zh/en copy per completion node. `description` is the plain fallback the
|
|
39
|
+
* node carries; `descriptions` is the localized map the TUI prefers. */
|
|
40
|
+
const SUBCOMMAND_DESCRIPTIONS = {
|
|
41
|
+
on: {
|
|
42
|
+
description: 'Enable the advisor for this session',
|
|
43
|
+
descriptions: {
|
|
44
|
+
zh: '为本会话启用顾问',
|
|
45
|
+
en: 'Enable the advisor for this session',
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
off: {
|
|
49
|
+
description: 'Disable the advisor for this session',
|
|
50
|
+
descriptions: {
|
|
51
|
+
zh: '为本会话禁用顾问',
|
|
52
|
+
en: 'Disable the advisor for this session',
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
status: {
|
|
56
|
+
description: 'Show per-session advisor status (state, model, runtime, pending, last activity)',
|
|
57
|
+
descriptions: {
|
|
58
|
+
zh: '查看本会话顾问状态(开关、模型、运行态、待处理、最近活动)',
|
|
59
|
+
en: 'Show per-session advisor status (state, model, runtime, pending, last activity)',
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
config: {
|
|
63
|
+
description: 'Show the composed advisor config (settings readback)',
|
|
64
|
+
descriptions: {
|
|
65
|
+
zh: '查看组合后的顾问配置(设置回读)',
|
|
66
|
+
en: 'Show the composed advisor config (settings readback)',
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
/** The `/advisor` completion tree. `children` NEVER throws: unknown paths and
|
|
71
|
+
* a bare `[]` return an empty list (leaves have no deeper completion — the
|
|
72
|
+
* TUI asks at depth 2). */
|
|
73
|
+
const advisorTree = {
|
|
74
|
+
root: ADVISOR_TUI_ROOT,
|
|
75
|
+
descriptions: ADVISOR_TUI_DESCRIPTIONS,
|
|
76
|
+
children(canonicalPath) {
|
|
77
|
+
// Root at index 0: only `['advisor']` asks for the subcommand list.
|
|
78
|
+
if (canonicalPath.length !== 1 || canonicalPath[0] !== ADVISOR_TUI_ROOT)
|
|
79
|
+
return [];
|
|
80
|
+
return ADVISOR_SUBCOMMANDS.map((name) => ({
|
|
81
|
+
name,
|
|
82
|
+
description: SUBCOMMAND_DESCRIPTIONS[name].description,
|
|
83
|
+
descriptions: SUBCOMMAND_DESCRIPTIONS[name].descriptions,
|
|
84
|
+
}));
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Install the advisor's TUI client surface: register the `/advisor`
|
|
89
|
+
* `tuiCommandTrees` provider when the host service exists (conditional
|
|
90
|
+
* inject; absent service → clean no-op). Called from `apply()` AFTER the
|
|
91
|
+
* single-reviewer claim, so the tree registers at most once per process
|
|
92
|
+
* (a duplicate-root registration would throw in the host registry). The
|
|
93
|
+
* structural accessor keeps the inject key in the standard position: the
|
|
94
|
+
* cordis Context has no `tuiCommandTrees` augmentation in this repo, so the
|
|
95
|
+
* service is read through a local structural cast.
|
|
96
|
+
*/
|
|
97
|
+
export function installTuiClient(ctx) {
|
|
98
|
+
ctx.inject(['tuiCommandTrees'], (tctx) => {
|
|
99
|
+
const trees = tctx.tuiCommandTrees;
|
|
100
|
+
if (trees === undefined)
|
|
101
|
+
return;
|
|
102
|
+
try {
|
|
103
|
+
return trees.register(advisorTree);
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
if (!(error instanceof Error) || !error.message.includes('already registered'))
|
|
107
|
+
throw error;
|
|
108
|
+
tctx.logger('advisor').debug('advisor tui tree already registered — no tree on this fiber (multi-fiber dedupe)');
|
|
109
|
+
return () => { };
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=tui.js.map
|
package/lib/tui.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tui.js","sourceRoot":"","sources":["../src/tui.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AA4BH,oEAAoE;AACpE,MAAM,CAAC,MAAM,gBAAgB,GAAG,SAAS,CAAA;AAEzC;;;oBAGoB;AACpB,MAAM,mBAAmB,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAU,CAAA;AAItE,mFAAmF;AACnF,MAAM,wBAAwB,GAA6B;IACzD,EAAE,EAAE,8BAA8B;IAClC,EAAE,EAAE,yDAAyD;CAC9D,CAAA;AAED;wEACwE;AACxE,MAAM,uBAAuB,GAAyG;IACpI,EAAE,EAAE;QACF,WAAW,EAAE,qCAAqC;QAClD,YAAY,EAAE;YACZ,EAAE,EAAE,UAAU;YACd,EAAE,EAAE,qCAAqC;SAC1C;KACF;IACD,GAAG,EAAE;QACH,WAAW,EAAE,sCAAsC;QACnD,YAAY,EAAE;YACZ,EAAE,EAAE,UAAU;YACd,EAAE,E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AC;gBAAE,MAAM,KAAK,CAAA;YAC3F,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,kFAAkF,CAAC,CAAA;YAChH,OAAO,GAAG,EAAE,GAAE,CAAC,CAAA;QACjB,CAAC;IACH,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-advisor",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "dsh plugin bundle porting the omp advisor subsystem: a per-session reviewer model that observes the primary transcript and injects severity-ranked advice (nit/concern/blocker).",
|
|
6
6
|
"repository": {
|