@jiyr0119/dsh-service-console 0.1.0 → 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.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # DSH Service Console
2
2
 
3
+ **English** | [简体中文](./README.zh.md)
4
+
3
5
  > A local development service console for DSH: discover listening ports, identify services related to the current conversation or workspace, and safely inspect, stop, or restart them.
4
6
 
5
7
  **DSH 本地开发服务控制台:发现监听端口,识别与当前对话或工作区相关的服务,并安全地查看、停止和重启。**
@@ -12,7 +14,9 @@ Single-purpose plugin for the DeepSeek Harness web UI. When the model (or you) s
12
14
  - **Ownership & risk** — five-level attribution: `This chat` (matched against the session launch ledger), `Workspace`, `Other local`, `Unknown`, `Protected`.
13
15
  - **Control** — graceful stop to the process group, restart with a safe saved launch command. Every action is confirmed twice and re-validated against the current snapshot.
14
16
  - **Safeguards** — PID-reuse / fingerprint checks before any signal; unknown and protected services are read-only; force-kill is off by default; no implicit auto-cleanup; command output is redacted.
15
- - **Scopes, search, config, i18n** — conversation / workspace / machine scopes, keyword filtering, refresh interval / graceful timeout / force-kill settings, zh/en.
17
+ - **All local services** — every listening service on this machine is visible; ownership is shown as a safety signal rather than a hidden category filter.
18
+ - **Search, config, i18n** — keyword filtering, refresh interval / graceful timeout / force-kill settings, zh/en.
19
+ - **DSH-native inspector** — an expanded service record card presents process identity, ports, command, working directory and ownership evidence in the Web UI's token-based visual language.
16
20
 
17
21
  ## Install
18
22
 
@@ -28,6 +32,12 @@ Then refresh the DSH web UI — a `🖥 SC` entry appears in the conversation he
28
32
 
29
33
  Alternative — dynamic paste (zero-build, process-local): paste `dynamic/host.js` + `dynamic/client.js` via the dynamic Cordis plugin flow.
30
34
 
35
+ ## UI preview
36
+
37
+ ![Service Console 0.2.0 — all local services and DSH-style inspector](./assets/service-console-0.2.0.gif)
38
+
39
+ The preview shows the complete local listening-service list and the expanded inspector card. The ownership badge remains visible as a safety signal, while the list itself is no longer split into conversation/workspace/machine categories.
40
+
31
41
  ## Permissions & safety
32
42
 
33
43
  - The client never sends raw PIDs or shell commands; it targets a service ID and the Host re-validates PID / start time / fingerprint before acting.
@@ -44,6 +54,23 @@ npm run build
44
54
  npm test # unit + integration tests (node --test)
45
55
  ```
46
56
 
57
+ ## Testing
58
+
59
+ `npm test` builds once and runs the whole suite with Node's built-in test runner (`node --test`). No extra test framework is required.
60
+
61
+ | File | Type | What it covers |
62
+ | --- | --- | --- |
63
+ | `test/process-inspector.test.mjs` | Unit | Platform output parsing (`parseLstart`, `parseListenRows`, `parsePsRows`, `parseAddress`), command redaction, five-level ownership classification |
64
+ | `test/host-more.test.mjs` | Unit | Config validation, session ledger, lifecycle state machine (stop/restart) with fake dependencies, service aggregation & fingerprint stability |
65
+ | `test/integration.test.mjs` | Integration | Real system commands + a temporary HTTP server spawned by the test itself; signals are only ever sent to test-owned processes |
66
+
67
+ ```bash
68
+ npm test # full suite
69
+ npm run build && node --test test/process-inspector.test.mjs # run a single file
70
+ ```
71
+
72
+ Unit tests import the built output under `lib/`, so the sources must be compiled first — `npm test` handles this automatically.
73
+
47
74
  ## License
48
75
 
49
76
  MIT
package/README.zh.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # DSH Service Console
2
2
 
3
+ [English](./README.md) | **简体中文**
4
+
3
5
  > A local development service console for DSH: discover listening ports, identify services related to the current conversation or workspace, and safely inspect, stop, or restart them.
4
6
  >
5
7
  > **DSH 本地开发服务控制台:发现监听端口,识别与当前对话或工作区相关的服务,并安全地查看、停止和重启。**
@@ -12,7 +14,9 @@
12
14
  - **归属与风险** — 五级归属:`本次对话`(与会话启动台账匹配)、`工作区`、`本机其他`、`未知`、`受保护`。
13
15
  - **受控操作** — 对进程组优雅停止;对保存了安全启动命令的服务重启。每个动作均二次确认,并在操作前重新校验快照。
14
16
  - **安全防护** — 任何信号前校验 PID 复用 / fingerprint;未知与受保护服务只读;强制终止默认关闭;无隐式自动清理;命令输出脱敏。
15
- - **范围 / 搜索 / 配置 / 国际化** — 本次对话 / 工作区 / 本机三种范围、关键字过滤、刷新间隔 / 优雅超时 / 强制终止设置、中英文。
17
+ - **全量本机服务** — 展示本机全部监听服务;归属只作为安全提示,不再隐藏端口分类,用户可自行选择要查看或停止的服务。
18
+ - **搜索 / 配置 / 国际化** — 支持关键字过滤、刷新间隔 / 优雅超时 / 强制终止设置、中英文。
19
+ - **DSH 原生检查卡片** — 展开详情采用 DSH Web token 化视觉风格,展示进程身份、端口、命令、工作目录和归属证据。
16
20
 
17
21
  ## 安装
18
22
 
@@ -28,6 +32,12 @@ dsh plugin --profile web add -w @jiyr0119/dsh-service-console@latest
28
32
 
29
33
  备用方式——动态粘贴(零构建、进程级):通过动态 Cordis 插件流程粘贴 `dynamic/host.js` + `dynamic/client.js`。
30
34
 
35
+ ## 界面预览
36
+
37
+ ![Service Console 0.2.0:全量本机服务与 DSH 风格检查卡片](./assets/service-console-0.2.0.gif)
38
+
39
+ 预览展示本机完整监听服务列表与展开后的检查卡片。归属徽标仍作为安全提示保留,但列表不再按对话 / 工作区 / 本机拆分隐藏服务。
40
+
31
41
  ## 权限与安全
32
42
 
33
43
  - Client 不直接传任意 PID 或 Shell 命令,只以 service ID 为目标,Host 在操作前重新校验 PID / 启动时间 / fingerprint。
@@ -44,6 +54,23 @@ npm run build
44
54
  npm test # 单元 + 集成测试(node --test)
45
55
  ```
46
56
 
57
+ ## 测试
58
+
59
+ `npm test` 会先构建一次,再用 Node 内置测试运行器(`node --test`)执行整个测试套件,无需额外测试框架。
60
+
61
+ | 文件 | 类型 | 覆盖内容 |
62
+ | --- | --- | --- |
63
+ | `test/process-inspector.test.mjs` | 单元测试 | 平台输出解析(`parseLstart`、`parseListenRows`、`parsePsRows`、`parseAddress`)、命令脱敏、五级归属分类 |
64
+ | `test/host-more.test.mjs` | 单元测试 | 配置校验、会话台账、基于 fake 依赖的生命周期状态机(停止/重启)、服务聚合与 fingerprint 稳定性 |
65
+ | `test/integration.test.mjs` | 集成测试 | 真实系统命令 + 测试自建的临时 HTTP 服务;只对测试自有进程发信号 |
66
+
67
+ ```bash
68
+ npm test # 全部用例
69
+ npm run build && node --test test/process-inspector.test.mjs # 单独运行某个文件
70
+ ```
71
+
72
+ 单元测试直接 import 构建产物(`lib/`),因此需要先编译源码——`npm test` 会自动完成。
73
+
47
74
  ## 许可证
48
75
 
49
76
  MIT
Binary file
package/dsh.plugin.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "id": "dsh-external/dsh-service-console",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "main": "./lib/index.js",
5
5
  "description": "本地开发服务控制台:发现监听端口,识别服务归属,安全查看/停止/重启。Local development service console for DSH.",
6
6
  "engines": {
package/dynamic/client.js CHANGED
@@ -15,7 +15,7 @@ return {
15
15
 
16
16
  const TEXTS = {
17
17
  zh: {
18
- title: 'Service Console', scopeConv: '本次对话', scopeWs: '工作区', scopeMachine: '本机',
18
+ title: 'Service Console', scopeConv: '全部本机服务', scopeWs: '全部本机服务', scopeMachine: '全部本机服务',
19
19
  search: '搜索服务/端口/路径…', auto: '5s', config: '配置', close: '关闭',
20
20
  noSvc: '未发现服务', stop: '停止', restart: '重启', detail: '详情',
21
21
  confirmStop: '确认停止?', confirmRestart: '确认重启?', confirmTxt: '确认对 {name} (pid {pid}) 执行{action}?',
@@ -23,7 +23,7 @@ return {
23
23
  evidence: '归属证据', refreshInterval: '自动刷新间隔(ms)', gracefulTimeout: '优雅超时(ms)', forceKill: '允许强制终止',
24
24
  },
25
25
  en: {
26
- title: 'Service Console', scopeConv: 'This chat', scopeWs: 'Workspace', scopeMachine: 'This Mac',
26
+ title: 'Service Console', scopeConv: 'All local services', scopeWs: 'All local services', scopeMachine: 'All local services',
27
27
  search: 'Search services/ports/paths…', auto: '5s', config: 'Config', close: 'Close',
28
28
  noSvc: 'no services found', stop: 'Stop', restart: 'Restart', detail: 'Detail',
29
29
  confirmStop: 'Confirm stop?', confirmRestart: 'Confirm restart?', confirmTxt: 'Run {action} on {name} (pid {pid})?',
@@ -64,7 +64,6 @@ return {
64
64
  function Panel() {
65
65
  const [open, setLocal] = React.useState(store.open)
66
66
  const [lang, setLang] = React.useState('zh')
67
- const [scope, setScope] = React.useState('workspace')
68
67
  const [query, setQuery] = React.useState('')
69
68
  const [showConfig, setShowConfig] = React.useState(false)
70
69
  const [configData, setConfigData] = React.useState(null)
@@ -111,9 +110,8 @@ return {
111
110
  host.call('config', { action: 'update', patch }).then((res) => { if (res && res.data) setConfigData(res.data.config) })
112
111
  }
113
112
 
113
+ // Show every listening service; ownership is a safety badge, not a visibility filter.
114
114
  let rows = (view.data && view.data.services) || []
115
- if (scope === 'conversation') rows = rows.filter((s) => s.ownership === 'conversation-confirmed')
116
- else if (scope === 'workspace') rows = rows.filter((s) => s.ownership === 'conversation-confirmed' || s.ownership === 'workspace-inferred')
117
115
  if (query) {
118
116
  const q = String(query).toLowerCase()
119
117
  rows = rows.filter((s) => String(s.name).toLowerCase().indexOf(q) >= 0 || String(s.pid).indexOf(q) >= 0 || (s.commandSummary || '').toLowerCase().indexOf(q) >= 0 || (s.cwd || '').toLowerCase().indexOf(q) >= 0 || (s.listeners || []).some((l) => String(l.port).indexOf(q) >= 0))
@@ -127,11 +125,7 @@ return {
127
125
  return React.createElement('div', { style: STYLE.panel },
128
126
  React.createElement('div', { style: { display: 'flex', alignItems: 'center', gap: 6, marginBottom: 6, flexWrap: 'wrap' } },
129
127
  React.createElement('strong', null, T.title),
130
- React.createElement('select', { value: scope, onChange: (e) => setScope(e.target.value), style: STYLE.input },
131
- React.createElement('option', { value: 'conversation' }, T.scopeConv),
132
- React.createElement('option', { value: 'workspace' }, T.scopeWs),
133
- React.createElement('option', { value: 'machine' }, T.scopeMachine)
134
- ),
128
+ React.createElement('span', { style: Object.assign({}, STYLE.muted, { padding: '3px 6px', border: '1px solid var(--dsw-alias-border-l1, #444)', borderRadius: 4 }) }, T.scopeMachine),
135
129
  React.createElement('button', { onClick: () => setLang(lang === 'zh' ? 'en' : 'zh'), style: STYLE.btn }, lang === 'zh' ? 'EN' : '中'),
136
130
  React.createElement('button', { onClick: () => { setShowConfig(!showConfig); if (!showConfig) loadConfig() }, style: STYLE.btn }, T.config),
137
131
  React.createElement('span', { style: { flex: 1 } }),
package/lib/client.js CHANGED
@@ -28,8 +28,8 @@ window.__ModuleLoader__.load({
28
28
  let react = require("react");
29
29
  react = __toESM(react, 1);
30
30
  let react_jsx_runtime = require("react/jsx-runtime");
31
- //#region \0dsh-css:/Users/jonathan/workspaceforme/dsh-service-console/src/client/service-console.module.css.mjs
32
- const css = ".citwcW_panel{z-index:9999;background:var(--dsw-alias-bg-overlay,#262626);width:540px;max-height:min(640px,100dvh - 110px);color:var(--dsw-alias-label-primary,#eee);border:1px solid var(--dsw-alias-border-l1,#444);pointer-events:auto;border-radius:10px;padding:12px;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:12px;position:fixed;top:72px;right:20px;overflow:auto;box-shadow:0 8px 32px #00000059}.citwcW_header{flex-wrap:wrap;align-items:center;gap:6px;margin-bottom:6px;display:flex}.citwcW_row{border-bottom:1px solid var(--dsw-alias-border-l1,#333);padding:8px 0}.citwcW_rowMain{flex-wrap:wrap;align-items:center;gap:6px;display:flex}.citwcW_name{font-weight:600}.citwcW_muted{color:var(--dsw-alias-label-secondary,#999)}.citwcW_ok{color:var(--dsw-alias-state-success-primary,#4ade80)}.citwcW_err{color:var(--dsw-alias-state-error-primary,#f87171)}.citwcW_warn{color:var(--dsw-alias-state-warn-primary,#fbbf24)}.citwcW_btn{cursor:pointer;border:1px solid var(--dsw-alias-border-l1,#555);background:var(--dsw-alias-bg-layer-1,#333);color:var(--dsw-alias-label-primary,#eee);border-radius:4px;margin-left:6px;padding:1px 6px;font-family:inherit;font-size:11px;text-decoration:none}.citwcW_badge{border:1px solid;border-radius:4px;padding:0 5px;font-size:10px}.citwcW_input{background:var(--dsw-alias-bg-layer-1,#333);color:var(--dsw-alias-label-primary,#eee);border:1px solid var(--dsw-alias-border-l1,#555);border-radius:4px;padding:2px 6px;font-family:inherit;font-size:11px}.citwcW_search{box-sizing:border-box;width:100%;margin-bottom:6px}.citwcW_spacer{flex:1}.citwcW_configBox{background:var(--dsw-alias-bg-layer-1,#333);border-radius:6px;margin-bottom:8px;padding:8px}.citwcW_configRow{align-items:center;gap:6px;margin-top:4px;display:flex}.citwcW_confirmRow{margin-top:4px}.citwcW_detailBox{background:var(--dsw-alias-bg-layer-1,#333);border-radius:6px;margin-top:4px;padding:6px}.citwcW_entry{border:1px solid var(--dsw-alias-border-l2);min-width:111px;height:32px;color:var(--dsw-alias-label-primary);font-family:var(--dsw-font-family);cursor:pointer;background:0 0;border-radius:18px;justify-content:center;align-items:center;gap:4px;padding:6px 12px;font-size:13px;font-weight:400;line-height:20px;display:inline-flex}.citwcW_entry:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}.citwcW_entryLabel,.citwcW_entryIcon{white-space:nowrap;flex:none}";
31
+ //#region \0dsh-css:/home/runner/work/dsh-service-console/dsh-service-console/src/client/service-console.module.css.mjs
32
+ const css = ".PuSt5a_panel{z-index:9999;box-sizing:border-box;width:min(620px,100vw - 32px);max-height:min(760px,100dvh - 88px);color:var(--dsw-alias-label-primary,#f5f5f5);background:var(--dsw-alias-bg-overlay,#202124);border:1px solid var(--dsw-alias-border-l1,#3b3d42);font-family:var(--dsw-font-family,Inter, -apple-system, BlinkMacSystemFont, sans-serif);pointer-events:auto;border-radius:14px;padding:18px;font-size:13px;position:fixed;top:64px;right:20px;overflow:auto;box-shadow:0 18px 55px #0000006b,0 2px 8px #0003}.PuSt5a_header{border-bottom:1px solid var(--dsw-alias-border-l1,#35373c);justify-content:space-between;align-items:flex-start;gap:16px;padding-bottom:14px;display:flex}.PuSt5a_titleBlock{flex-direction:column;gap:3px;display:flex}.PuSt5a_titleBlock strong{letter-spacing:-.02em;font-size:19px}.PuSt5a_eyebrow,.PuSt5a_detailAccent,.PuSt5a_detailLabel{color:var(--dsw-alias-label-tertiary,#858991);letter-spacing:.1em;text-transform:uppercase;font-size:10px;font-weight:650}.PuSt5a_subtitle,.PuSt5a_scopeHint{color:var(--dsw-alias-label-secondary,#a8abb2);font-size:12px}.PuSt5a_headerActions{gap:5px;display:flex}.PuSt5a_iconBtn,.PuSt5a_closeBtn{cursor:pointer;border:1px solid var(--dsw-alias-border-l2,#50535a);background:var(--dsw-alias-bg-layer-1,#2a2c30);width:30px;height:30px;color:var(--dsw-alias-label-primary,#eee);border-radius:8px;padding:0;font-family:inherit}.PuSt5a_iconBtn:hover,.PuSt5a_closeBtn:hover,.PuSt5a_btn:hover{background:var(--dsw-alias-interactive-bg-hover,#383b41)}.PuSt5a_closeBtn{color:var(--dsw-alias-label-secondary,#aaa);font-size:21px;line-height:1}.PuSt5a_scopeLine{color:var(--dsw-alias-label-primary,#eee);align-items:center;gap:7px;padding:12px 0 10px;font-size:12px;display:flex}.PuSt5a_liveDot{background:var(--dsw-alias-state-success-primary,#55d187);width:7px;height:7px;box-shadow:0 0 0 3px color-mix(in srgb, var(--dsw-alias-state-success-primary,#55d187) 18%, transparent);border-radius:50%}.PuSt5a_autoRefresh{color:var(--dsw-alias-label-secondary,#aaa);font-size:11px}.PuSt5a_autoRefresh input{accent-color:var(--dsw-alias-state-success-primary,#55d187)}.PuSt5a_row{border-bottom:1px solid var(--dsw-alias-border-l1,#35373c);padding:13px 0}.PuSt5a_rowMain{flex-wrap:wrap;align-items:center;gap:7px;display:flex}.PuSt5a_name{font-size:14px;font-weight:650}.PuSt5a_muted{color:var(--dsw-alias-label-secondary,#999)}.PuSt5a_ok{color:var(--dsw-alias-state-success-primary,#55d187)}.PuSt5a_err{color:var(--dsw-alias-state-error-primary,#ff7c83)}.PuSt5a_warn{color:var(--dsw-alias-state-warn-primary,#e7b85d)}.PuSt5a_status{color:var(--dsw-alias-label-secondary,#a8abb2);margin:10px 0;font-size:11px}.PuSt5a_btn{cursor:pointer;border:1px solid var(--dsw-alias-border-l2,#50535a);background:var(--dsw-alias-bg-layer-1,#2a2c30);color:var(--dsw-alias-label-primary,#eee);font:inherit;border-radius:7px;margin-left:5px;padding:5px 9px;font-size:11px;text-decoration:none}.PuSt5a_badge{border:1px solid;border-radius:999px;padding:2px 7px;font-size:10px}.PuSt5a_input{box-sizing:border-box;border:1px solid var(--dsw-alias-border-l2,#50535a);background:var(--dsw-alias-bg-layer-1,#2a2c30);color:var(--dsw-alias-label-primary,#eee);font:inherit;border-radius:8px;padding:8px 10px;font-size:12px}.PuSt5a_search{width:100%;margin-bottom:7px}.PuSt5a_spacer{flex:1}.PuSt5a_configBox{border:1px solid var(--dsw-alias-border-l1,#35373c);background:var(--dsw-alias-bg-layer-1,#292b30);border-radius:9px;margin:10px 0;padding:11px}.PuSt5a_configRow{align-items:center;gap:8px;margin-top:7px;display:flex}.PuSt5a_confirmRow{background:color-mix(in srgb, var(--dsw-alias-state-warn-primary,#e7b85d) 9%, transparent);border-radius:8px;flex-wrap:wrap;align-items:center;gap:5px;margin-top:9px;padding:9px;display:flex}.PuSt5a_detailBox{border:1px solid var(--dsw-alias-border-l2,#50535a);background:var(--dsw-alias-bg-layer-1,#292b30);box-shadow:inset 3px 0 0 var(--dsw-alias-state-warn-primary,#e7b85d);border-radius:10px;margin-top:11px;padding:13px}.PuSt5a_detailHeader{justify-content:space-between;align-items:center;margin-bottom:12px;font-size:12px;font-weight:650;display:flex}.PuSt5a_detailAccent{color:var(--dsw-alias-state-warn-primary,#e7b85d);font-size:9px}.PuSt5a_detailGrid{grid-template-columns:repeat(2,minmax(0,1fr));gap:11px;display:grid}.PuSt5a_detailGrid>div{flex-direction:column;gap:4px;min-width:0;display:flex}.PuSt5a_detailGrid code{overflow-wrap:anywhere;color:var(--dsw-alias-label-primary,#e7e8ea);font:11px ui-monospace,SFMono-Regular,Menlo,monospace}.PuSt5a_evidenceBlock{border-top:1px solid var(--dsw-alias-border-l1,#3b3d42);margin-top:14px;padding-top:11px}.PuSt5a_evidenceItem{color:var(--dsw-alias-label-secondary,#b4b6bc);gap:7px;margin-top:6px;font-size:11px;display:flex}.PuSt5a_evidenceItem span{color:var(--dsw-alias-state-warn-primary,#e7b85d)}.PuSt5a_entry{border:1px solid var(--dsw-alias-border-l2);min-width:111px;height:32px;color:var(--dsw-alias-label-primary);font-family:var(--dsw-font-family);cursor:pointer;background:0 0;border-radius:18px;justify-content:center;align-items:center;gap:4px;padding:6px 12px;font-size:13px;font-weight:400;line-height:20px;display:inline-flex}.PuSt5a_entry:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}.PuSt5a_entryLabel,.PuSt5a_entryIcon{white-space:nowrap;flex:none}@media (width<=640px){.PuSt5a_panel{width:calc(100vw - 20px);max-height:calc(100dvh - 20px);top:10px;right:10px}.PuSt5a_detailGrid{grid-template-columns:1fr}}@media (prefers-reduced-motion:reduce){.PuSt5a_panel{scroll-behavior:auto}}";
33
33
  const tagId = "@jiyr0119/dsh-service-console/service-console.module.css";
34
34
  if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null) {
35
35
  const tag = document.createElement("style");
@@ -39,27 +39,44 @@ window.__ModuleLoader__.load({
39
39
  document.head.appendChild(tag);
40
40
  }
41
41
  var service_console_module_css_default = {
42
- "spacer": "citwcW_spacer",
43
- "err": "citwcW_err",
44
- "rowMain": "citwcW_rowMain",
45
- "entry": "citwcW_entry",
46
- "entryIcon": "citwcW_entryIcon",
47
- "row": "citwcW_row",
48
- "entryLabel": "citwcW_entryLabel",
49
- "detailBox": "citwcW_detailBox",
50
- "name": "citwcW_name",
51
- "warn": "citwcW_warn",
52
- "configBox": "citwcW_configBox",
53
- "input": "citwcW_input",
54
- "panel": "citwcW_panel",
55
- "ok": "citwcW_ok",
56
- "btn": "citwcW_btn",
57
- "header": "citwcW_header",
58
- "confirmRow": "citwcW_confirmRow",
59
- "muted": "citwcW_muted",
60
- "configRow": "citwcW_configRow",
61
- "badge": "citwcW_badge",
62
- "search": "citwcW_search"
42
+ "detailGrid": "PuSt5a_detailGrid",
43
+ "search": "PuSt5a_search",
44
+ "headerActions": "PuSt5a_headerActions",
45
+ "detailBox": "PuSt5a_detailBox",
46
+ "detailHeader": "PuSt5a_detailHeader",
47
+ "eyebrow": "PuSt5a_eyebrow",
48
+ "name": "PuSt5a_name",
49
+ "spacer": "PuSt5a_spacer",
50
+ "scopeLine": "PuSt5a_scopeLine",
51
+ "subtitle": "PuSt5a_subtitle",
52
+ "badge": "PuSt5a_badge",
53
+ "detailLabel": "PuSt5a_detailLabel",
54
+ "configRow": "PuSt5a_configRow",
55
+ "header": "PuSt5a_header",
56
+ "evidenceBlock": "PuSt5a_evidenceBlock",
57
+ "muted": "PuSt5a_muted",
58
+ "entryLabel": "PuSt5a_entryLabel",
59
+ "liveDot": "PuSt5a_liveDot",
60
+ "input": "PuSt5a_input",
61
+ "titleBlock": "PuSt5a_titleBlock",
62
+ "closeBtn": "PuSt5a_closeBtn",
63
+ "warn": "PuSt5a_warn",
64
+ "configBox": "PuSt5a_configBox",
65
+ "iconBtn": "PuSt5a_iconBtn",
66
+ "panel": "PuSt5a_panel",
67
+ "ok": "PuSt5a_ok",
68
+ "status": "PuSt5a_status",
69
+ "btn": "PuSt5a_btn",
70
+ "evidenceItem": "PuSt5a_evidenceItem",
71
+ "row": "PuSt5a_row",
72
+ "rowMain": "PuSt5a_rowMain",
73
+ "autoRefresh": "PuSt5a_autoRefresh",
74
+ "detailAccent": "PuSt5a_detailAccent",
75
+ "err": "PuSt5a_err",
76
+ "entry": "PuSt5a_entry",
77
+ "scopeHint": "PuSt5a_scopeHint",
78
+ "confirmRow": "PuSt5a_confirmRow",
79
+ "entryIcon": "PuSt5a_entryIcon"
63
80
  };
64
81
  //#endregion
65
82
  //#region src/client/ServiceConsole.tsx
@@ -133,10 +150,8 @@ window.__ModuleLoader__.load({
133
150
  const TEXTS = {
134
151
  zh: {
135
152
  title: "Service Console",
136
- search: "搜索服务/端口/路径…",
137
- scopeConv: "本次对话",
138
- scopeWs: "工作区",
139
- scopeMachine: "本机",
153
+ subtitle: "本机监听服务",
154
+ search: "搜索服务、端口或路径…",
140
155
  auto: "5s",
141
156
  config: "配置",
142
157
  close: "关闭",
@@ -154,14 +169,16 @@ window.__ModuleLoader__.load({
154
169
  evidence: "归属证据",
155
170
  refreshInterval: "自动刷新间隔(ms)",
156
171
  gracefulTimeout: "优雅超时(ms)",
157
- forceKill: "允许强制终止"
172
+ forceKill: "允许强制终止",
173
+ allLocal: "全部本机服务",
174
+ servicesFound: "项服务",
175
+ lastScan: "最近扫描",
176
+ closePanel: "关闭面板"
158
177
  },
159
178
  en: {
160
179
  title: "Service Console",
161
- search: "Search services/ports/paths…",
162
- scopeConv: "This chat",
163
- scopeWs: "Workspace",
164
- scopeMachine: "This Mac",
180
+ subtitle: "Listening services on this Mac",
181
+ search: "Search services, ports, or paths…",
165
182
  auto: "5s",
166
183
  config: "Config",
167
184
  close: "Close",
@@ -179,7 +196,11 @@ window.__ModuleLoader__.load({
179
196
  evidence: "Ownership evidence",
180
197
  refreshInterval: "Refresh interval (ms)",
181
198
  gracefulTimeout: "Graceful timeout (ms)",
182
- forceKill: "Allow force kill"
199
+ forceKill: "Allow force kill",
200
+ allLocal: "All local services",
201
+ servicesFound: "services",
202
+ lastScan: "Last scan",
203
+ closePanel: "Close panel"
183
204
  }
184
205
  };
185
206
  function ServiceConsoleEntry() {
@@ -206,7 +227,6 @@ window.__ModuleLoader__.load({
206
227
  function ServiceConsolePanel() {
207
228
  const [open, setLocal] = react.useState(store.open);
208
229
  const [lang, setLang] = react.useState("zh");
209
- const [scope, setScope] = react.useState("workspace");
210
230
  const [query, setQuery] = react.useState("");
211
231
  const [showConfig, setShowConfig] = react.useState(false);
212
232
  const [configData, setConfigData] = react.useState(null);
@@ -324,24 +344,29 @@ window.__ModuleLoader__.load({
324
344
  }).catch(() => void 0);
325
345
  };
326
346
  let rows = view.data?.services ?? [];
327
- if (scope === "conversation") rows = rows.filter((s) => s.ownership === "conversation-confirmed");
328
- else if (scope === "workspace") rows = rows.filter((s) => s.ownership === "conversation-confirmed" || s.ownership === "workspace-inferred");
329
347
  if (query) {
330
348
  const q = String(query).toLowerCase();
331
349
  rows = rows.filter((s) => s.name.toLowerCase().indexOf(q) >= 0 || String(s.pid).indexOf(q) >= 0 || (s.commandSummary ?? "").toLowerCase().indexOf(q) >= 0 || (s.cwd ?? "").toLowerCase().indexOf(q) >= 0 || s.listeners.some((l) => String(l.port).indexOf(q) >= 0));
332
350
  }
333
351
  const status = view.phase === "scanning" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
334
- className: service_console_module_css_default.warn,
335
- children: ["⏳ ", view.at]
352
+ className: service_console_module_css_default.status,
353
+ children: [
354
+ "⏳ ",
355
+ T.lastScan,
356
+ ": ",
357
+ view.at
358
+ ]
336
359
  }) : view.phase === "done" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
337
- className: service_console_module_css_default.ok,
360
+ className: service_console_module_css_default.status,
338
361
  children: [
339
- "✅ ",
340
- view.at,
362
+ "● ",
363
+ String(rows.length),
364
+ " ",
365
+ T.servicesFound,
341
366
  " · ",
342
- String(view.data?.count ?? 0),
343
- " · ledger=",
344
- String(view.data?.ledgerCount ?? 0)
367
+ T.lastScan,
368
+ ": ",
369
+ view.at
345
370
  ]
346
371
  }) : view.phase === "error" || view.phase === "timeout" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
347
372
  className: service_console_module_css_default.err,
@@ -352,43 +377,64 @@ window.__ModuleLoader__.load({
352
377
  children: [
353
378
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
354
379
  className: service_console_module_css_default.header,
380
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
381
+ className: service_console_module_css_default.titleBlock,
382
+ children: [
383
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
384
+ className: service_console_module_css_default.eyebrow,
385
+ children: "DSH / LOCAL RUNTIME"
386
+ }),
387
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: T.title }),
388
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
389
+ className: service_console_module_css_default.subtitle,
390
+ children: T.subtitle
391
+ })
392
+ ]
393
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
394
+ className: service_console_module_css_default.headerActions,
395
+ children: [
396
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
397
+ className: service_console_module_css_default.iconBtn,
398
+ onClick: () => setLang(lang === "zh" ? "en" : "zh"),
399
+ "aria-label": "Toggle language",
400
+ children: lang === "zh" ? "EN" : "中"
401
+ }),
402
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
403
+ className: service_console_module_css_default.iconBtn,
404
+ onClick: () => {
405
+ setShowConfig(!showConfig);
406
+ if (!showConfig) loadConfig();
407
+ },
408
+ "aria-label": T.config,
409
+ children: "⚙"
410
+ }),
411
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
412
+ className: service_console_module_css_default.iconBtn,
413
+ onClick: scan,
414
+ "aria-label": "Refresh",
415
+ children: "↻"
416
+ }),
417
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
418
+ className: service_console_module_css_default.closeBtn,
419
+ onClick: () => setOpen(false),
420
+ "aria-label": T.closePanel,
421
+ children: "×"
422
+ })
423
+ ]
424
+ })]
425
+ }),
426
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
427
+ className: service_console_module_css_default.scopeLine,
355
428
  children: [
356
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: T.title }),
357
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
358
- className: service_console_module_css_default.input,
359
- value: scope,
360
- onChange: (e) => setScope(e.target.value),
361
- children: [
362
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
363
- value: "conversation",
364
- children: T.scopeConv
365
- }),
366
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
367
- value: "workspace",
368
- children: T.scopeWs
369
- }),
370
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
371
- value: "machine",
372
- children: T.scopeMachine
373
- })
374
- ]
375
- }),
376
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
377
- className: service_console_module_css_default.btn,
378
- onClick: () => setLang(lang === "zh" ? "en" : "zh"),
379
- children: lang === "zh" ? "EN" : "中"
380
- }),
381
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
382
- className: service_console_module_css_default.btn,
383
- onClick: () => {
384
- setShowConfig(!showConfig);
385
- if (!showConfig) loadConfig();
386
- },
387
- children: T.config
429
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: service_console_module_css_default.liveDot }),
430
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: T.allLocal }),
431
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
432
+ className: service_console_module_css_default.scopeHint,
433
+ children: ["· ", T.subtitle]
388
434
  }),
389
435
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: service_console_module_css_default.spacer }),
390
436
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
391
- className: service_console_module_css_default.muted,
437
+ className: service_console_module_css_default.autoRefresh,
392
438
  children: [
393
439
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
394
440
  type: "checkbox",
@@ -398,16 +444,6 @@ window.__ModuleLoader__.load({
398
444
  " ",
399
445
  T.auto
400
446
  ]
401
- }),
402
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
403
- className: service_console_module_css_default.btn,
404
- onClick: scan,
405
- children: "↻"
406
- }),
407
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
408
- className: service_console_module_css_default.btn,
409
- onClick: () => setOpen(false),
410
- children: T.close
411
447
  })
412
448
  ]
413
449
  }),
@@ -565,30 +601,55 @@ window.__ModuleLoader__.load({
565
601
  }) : null,
566
602
  expanded === svc.id ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
567
603
  className: service_console_module_css_default.detailBox,
604
+ role: "region",
605
+ "aria-label": T.detail,
568
606
  children: [
569
607
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
570
- className: service_console_module_css_default.muted,
571
- children: ["id: ", svc.id]
608
+ className: service_console_module_css_default.detailHeader,
609
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: T.detail }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
610
+ className: service_console_module_css_default.detailAccent,
611
+ children: "SERVICE RECORD"
612
+ })]
572
613
  }),
573
614
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
574
- className: service_console_module_css_default.muted,
615
+ className: service_console_module_css_default.detailGrid,
575
616
  children: [
576
- "pgid: ",
577
- String(svc.processGroupId ?? "-"),
578
- " · ppid: ",
579
- String(svc.parentPid ?? "-"),
580
- " · startedAt: ",
581
- String(svc.startedAt ?? "-")
617
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
618
+ className: service_console_module_css_default.detailLabel,
619
+ children: "SERVICE ID"
620
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: svc.id })] }),
621
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
622
+ className: service_console_module_css_default.detailLabel,
623
+ children: "PROCESS"
624
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("code", { children: [
625
+ "PID ",
626
+ svc.pid,
627
+ " · PGID ",
628
+ String(svc.processGroupId ?? "-")
629
+ ] })] }),
630
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
631
+ className: service_console_module_css_default.detailLabel,
632
+ children: "PARENT"
633
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("code", { children: ["PPID ", String(svc.parentPid ?? "-")] })] }),
634
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
635
+ className: service_console_module_css_default.detailLabel,
636
+ children: "STARTED"
637
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: String(svc.startedAt ?? "-") })] })
582
638
  ]
583
639
  }),
584
640
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
585
- className: service_console_module_css_default.muted,
586
- children: [T.evidence, ":"]
587
- }),
588
- svc.ownershipEvidence.map((ev, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
589
- className: service_console_module_css_default.muted,
590
- children: [" · ", ev]
591
- }, i))
641
+ className: service_console_module_css_default.evidenceBlock,
642
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
643
+ className: service_console_module_css_default.detailLabel,
644
+ children: T.evidence
645
+ }), svc.ownershipEvidence.length ? svc.ownershipEvidence.map((ev, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
646
+ className: service_console_module_css_default.evidenceItem,
647
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "↳" }), ev]
648
+ }, i)) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
649
+ className: service_console_module_css_default.muted,
650
+ children: "—"
651
+ })]
652
+ })
592
653
  ]
593
654
  }) : null
594
655
  ]
package/manifest.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "dsh-service-console",
3
3
  "name": "服务控制台 (Service Console)",
4
- "version": "0.1.0",
4
+ "version": "0.2.0",
5
5
  "description": "本地开发服务控制台:发现监听端口,识别归属,安全停止/重启",
6
6
  "kind": "dynamic-cordis-plugin",
7
7
  "platforms": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jiyr0119/dsh-service-console",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "DeepSeek Harness 本地开发服务控制台(原生插件):发现监听端口,识别服务归属,安全查看/停止/重启。Local development service console for DSH.",
5
5
  "license": "MIT",
6
6
  "type": "module",