@dsh-cc/command-doctor 0.5.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.
Files changed (89) hide show
  1. package/LICENSE +201 -0
  2. package/README.i18n.yaml +6 -0
  3. package/README.md +47 -0
  4. package/README.zh.md +47 -0
  5. package/lib/checks/env.d.ts +12 -0
  6. package/lib/checks/env.d.ts.map +1 -0
  7. package/lib/checks/env.js +71 -0
  8. package/lib/checks/env.js.map +1 -0
  9. package/lib/checks/git.d.ts +26 -0
  10. package/lib/checks/git.d.ts.map +1 -0
  11. package/lib/checks/git.js +94 -0
  12. package/lib/checks/git.js.map +1 -0
  13. package/lib/checks/hooks.d.ts +33 -0
  14. package/lib/checks/hooks.d.ts.map +1 -0
  15. package/lib/checks/hooks.js +138 -0
  16. package/lib/checks/hooks.js.map +1 -0
  17. package/lib/checks/mcp.d.ts +24 -0
  18. package/lib/checks/mcp.d.ts.map +1 -0
  19. package/lib/checks/mcp.js +107 -0
  20. package/lib/checks/mcp.js.map +1 -0
  21. package/lib/checks/models.d.ts +57 -0
  22. package/lib/checks/models.d.ts.map +1 -0
  23. package/lib/checks/models.js +190 -0
  24. package/lib/checks/models.js.map +1 -0
  25. package/lib/checks/plugins.d.ts +24 -0
  26. package/lib/checks/plugins.d.ts.map +1 -0
  27. package/lib/checks/plugins.js +55 -0
  28. package/lib/checks/plugins.js.map +1 -0
  29. package/lib/checks/seams.d.ts +12 -0
  30. package/lib/checks/seams.d.ts.map +1 -0
  31. package/lib/checks/seams.js +44 -0
  32. package/lib/checks/seams.js.map +1 -0
  33. package/lib/checks/session.d.ts +10 -0
  34. package/lib/checks/session.d.ts.map +1 -0
  35. package/lib/checks/session.js +88 -0
  36. package/lib/checks/session.js.map +1 -0
  37. package/lib/checks/storage.d.ts +13 -0
  38. package/lib/checks/storage.d.ts.map +1 -0
  39. package/lib/checks/storage.js +53 -0
  40. package/lib/checks/storage.js.map +1 -0
  41. package/lib/checks/web.d.ts +12 -0
  42. package/lib/checks/web.d.ts.map +1 -0
  43. package/lib/checks/web.js +128 -0
  44. package/lib/checks/web.js.map +1 -0
  45. package/lib/collect.d.ts +28 -0
  46. package/lib/collect.d.ts.map +1 -0
  47. package/lib/collect.js +76 -0
  48. package/lib/collect.js.map +1 -0
  49. package/lib/doctor.d.ts +8 -0
  50. package/lib/doctor.d.ts.map +1 -0
  51. package/lib/doctor.js +7 -0
  52. package/lib/doctor.js.map +1 -0
  53. package/lib/flags.d.ts +23 -0
  54. package/lib/flags.d.ts.map +1 -0
  55. package/lib/flags.js +36 -0
  56. package/lib/flags.js.map +1 -0
  57. package/lib/index.d.ts +20 -0
  58. package/lib/index.d.ts.map +1 -0
  59. package/lib/index.js +71 -0
  60. package/lib/index.js.map +1 -0
  61. package/lib/invariant.d.ts +16 -0
  62. package/lib/invariant.d.ts.map +1 -0
  63. package/lib/invariant.js +23 -0
  64. package/lib/invariant.js.map +1 -0
  65. package/lib/json.d.ts +19 -0
  66. package/lib/json.d.ts.map +1 -0
  67. package/lib/json.js +27 -0
  68. package/lib/json.js.map +1 -0
  69. package/lib/last-model.d.ts +23 -0
  70. package/lib/last-model.d.ts.map +1 -0
  71. package/lib/last-model.js +30 -0
  72. package/lib/last-model.js.map +1 -0
  73. package/lib/redact.d.ts +14 -0
  74. package/lib/redact.d.ts.map +1 -0
  75. package/lib/redact.js +53 -0
  76. package/lib/redact.js.map +1 -0
  77. package/lib/render.d.ts +17 -0
  78. package/lib/render.d.ts.map +1 -0
  79. package/lib/render.js +60 -0
  80. package/lib/render.js.map +1 -0
  81. package/lib/report.d.ts +60 -0
  82. package/lib/report.d.ts.map +1 -0
  83. package/lib/report.js +18 -0
  84. package/lib/report.js.map +1 -0
  85. package/lib/version.d.ts +29 -0
  86. package/lib/version.d.ts.map +1 -0
  87. package/lib/version.js +62 -0
  88. package/lib/version.js.map +1 -0
  89. package/package.json +51 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,6 @@
1
+ # Bilingual-pair consistency record (docs/i18n/README.md): the git blob hash of each
2
+ # side as of the last confirmed-consistent state. Both languages carry equal authority;
3
+ # after editing either side, bring the other along and re-record with:
4
+ # pnpm run verify-translation-pairing --write packages/interaction/command-doctor/README.md
5
+ README.md: 54b6b31337a623291adc5388569e6f54a75534bc
6
+ README.zh.md: d4e1f94e8685e625cc6021100778789a74651260
package/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # @dsh-cc/command-doctor
2
+
3
+ English | [中文](README.zh.md)
4
+
5
+ Human-facing `/doctor` command: a product-grade **session health report**. One data object, three renderings — default text, verbose text, and a JSON file under `$DSH_HOME`. The plugin registers one global command through [`ctx.commands`](../../interaction/commands/README.md), so every composed command adapter discovers and executes it without a model turn.
6
+
7
+ ## Command contract
8
+
9
+ | Input | Result |
10
+ |---|---|
11
+ | `/doctor` | Cheap in-process checks. `ok` rows collapse to one line; `warn`/`fail`/`skip`/`info` rows expand with summary and suggested fix. |
12
+ | `/doctor --verbose` | Cheap checks plus the slow probes: LLM catalog validation, the `serena-hooks` PATH scan, git worktree facts, and a session-store write probe. Evidence is printed on every row. |
13
+ | `/doctor --json` | Collects exactly like `--verbose` and writes the full report to `$DSH_HOME/tui/doctor-report.json` (created with parents, overwritten). The command text is only the path, the summary counts, and the fail/warn check ids — never a JSON blob in the transcript. |
14
+
15
+ `--verbose --json` together collect verbose and emit JSON. Unknown tokens return the usage text as a success result; checks never run on a parse miss.
16
+
17
+ ## Report shape
18
+
19
+ `DoctorReport` carries `schemaVersion: 1`, `generatedAt`, `durationMs`, an `env` header (dsh-cc/harness/node/os/arch/cwd), and a `checks` array grouped under `env`, `session`, `models`, `mcp`, `hooks`, `web`, `storage`, `git`, `plugins`, and `seams`.
20
+
21
+ **Consumer rule (schemaVersion):** adding a check id is **not** breaking — consumers must tolerate unknown check ids and groups. Only a `schemaVersion` bump is breaking.
22
+
23
+ Every string is scrubbed for secret-like substrings (`sk-`, `ghp_`, `xoxb-`, `Bearer `) before rendering or writing, and evidence values are restricted to primitives.
24
+
25
+ ## Composition
26
+
27
+ The producer injects `commands`. In the `cc` preset it lives inside the `cc-services` group so it can read `ccModelRoutes`, `mcpConnections`, and `hookBridgeStatus`:
28
+
29
+ ```yaml
30
+ - id: commands
31
+ name: '@deepseek-ai/dsh-commands'
32
+ - id: command-doctor
33
+ name: '@dsh-cc/command-doctor'
34
+ ```
35
+
36
+ Every optional seam is duck-typed via `ctx.get`; an absent seam is a `skip` row, not a failure. Each check group is try/catch-isolated, so a throwing seam degrades to one failing row while the command itself still succeeds.
37
+
38
+ ## Known limits
39
+
40
+ - **No headless CLI** — `dsh doctor` is Phase 2; the command only runs inside a session.
41
+ - **No CC-style mutations** — this is read-only + findings + suggested fix; it never edits CLAUDE.md or skills, and MCP operations stay on `/mcp`.
42
+ - **Missing fetch provider is info** — a mounted web seam without a fetch provider reports the known `WEB_PROVIDER_UNAVAILABLE` limit, not a failure.
43
+ - **Hook discovery is single-file** — CC layered project/user discovery and live reload are not implemented (reported as an `info` row).
44
+
45
+ ## Model Experience
46
+
47
+ The slash input and the diagnostic output never enter model requests and consume no model tokens. Presentation text is never logged.
package/README.zh.md ADDED
@@ -0,0 +1,47 @@
1
+ # @dsh-cc/command-doctor
2
+
3
+ [English](README.md) | 中文
4
+
5
+ 面向用户的 `/doctor` 命令:产品级的**会话健康报告**。同一份数据对象、三种呈现——默认文本、详细文本,以及写到 `$DSH_HOME` 下的 JSON 文件。该插件通过 [`ctx.commands`](../../interaction/commands/README.md) 注册一个全局命令,因此每个已组合的命令适配器都能发现并执行它,无需模型轮次。
6
+
7
+ ## 命令约定
8
+
9
+ | 输入 | 结果 |
10
+ |---|---|
11
+ | `/doctor` | 廉价的进程内检查。`ok` 行折叠为一行;`warn`/`fail`/`skip`/`info` 行展开显示摘要与建议修复。 |
12
+ | `/doctor --verbose` | 廉价检查加上慢探针:LLM 目录校验、`serena-hooks` 的 PATH 扫描、git worktree 事实,以及会话存储写入探针。每一行都会打印 evidence。 |
13
+ | `/doctor --json` | 以与 `--verbose` 相同的方式收集,并把完整报告写入 `$DSH_HOME/tui/doctor-report.json`(逐级建目录、覆盖旧文件)。命令文本只包含路径、summary 计数与 fail/warn 检查 id——绝不会把 JSON 大块塞进会话记录。 |
14
+
15
+ `--verbose --json` 同时使用时按详细模式收集并输出 JSON。未知 token 会以成功结果返回用法文本;解析失败时不会运行任何检查。
16
+
17
+ ## 报告结构
18
+
19
+ `DoctorReport` 携带 `schemaVersion: 1`、`generatedAt`、`durationMs`、`env` 头部(dsh-cc/harness/node/os/arch/cwd),以及按 `env`、`session`、`models`、`mcp`、`hooks`、`web`、`storage`、`git`、`plugins`、`seams` 分组的 `checks` 数组。
20
+
21
+ **消费方规则(schemaVersion):** 新增检查 id **不是**破坏性变更——消费方必须容忍未知的检查 id 与分组。只有 `schemaVersion` 升位才是破坏性的。
22
+
23
+ 每段字符串在渲染或写盘前都会清洗类密钥子串(`sk-`、`ghp_`、`xoxb-`、`Bearer `),且 evidence 取值仅限原始类型。
24
+
25
+ ## 组合
26
+
27
+ 生产方注入 `commands`。在 `cc` 预设中它位于 `cc-services` 组内,以便读取 `ccModelRoutes`、`mcpConnections` 与 `hookBridgeStatus`:
28
+
29
+ ```yaml
30
+ - id: commands
31
+ name: '@deepseek-ai/dsh-commands'
32
+ - id: command-doctor
33
+ name: '@dsh-cc/command-doctor'
34
+ ```
35
+
36
+ 所有可选接缝都通过 `ctx.get` 鸭子类型读取;缺失的接缝报告为 `skip` 行,而不是失败。每个检查组都有独立的 try/catch,因此抛错的接缝只会退化为一行 fail,命令本身仍然成功。
37
+
38
+ ## 已知限制
39
+
40
+ - **没有无头 CLI** — `dsh doctor` 属于第二阶段;本命令只能在会话内运行。
41
+ - **不做 CC 式的修改** — 只读 + 发现问题 + 建议修复;绝不改写 CLAUDE.md 或 skills,MCP 操作仍走 `/mcp`。
42
+ - **fetch provider 缺失只是 info** — 已挂载 web 接缝但缺少 fetch provider 时,报告已知的 `WEB_PROVIDER_UNAVAILABLE` 限制,而非失败。
43
+ - **Hook 发现仅限单文件** — CC 的分层 project/user 发现与热重载尚未实现(以 `info` 行报告)。
44
+
45
+ ## 模型体验
46
+
47
+ 斜杠输入与诊断输出都不会进入模型请求,也不消耗模型 token。呈现文本绝不会记录到日志中。
@@ -0,0 +1,12 @@
1
+ /**
2
+ * `env` checks for `/doctor`: dsh-cc version, harness version, Node engines,
3
+ * and platform facts.
4
+ * @module @dsh-cc/command-doctor/checks/env
5
+ */
6
+ import type { Context } from '@deepseek-ai/cordis';
7
+ import type { Check } from '../report.ts';
8
+ /** Duck-typed host-surfaced harness version (string or `{ version }`). */
9
+ export declare function harnessVersion(ctx: Context): string | undefined;
10
+ /** Collect the env group checks. */
11
+ export declare function envChecks(ctx: Context): Check[];
12
+ //# sourceMappingURL=env.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/checks/env.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AAGzC,0EAA0E;AAC1E,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAS/D;AAED,oCAAoC;AACpC,wBAAgB,SAAS,CAAC,GAAG,EAAE,OAAO,GAAG,KAAK,EAAE,CA+C/C"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * `env` checks for `/doctor`: dsh-cc version, harness version, Node engines,
3
+ * and platform facts.
4
+ * @module @dsh-cc/command-doctor/checks/env
5
+ */
6
+ import { nodeSatisfiesEngines, readEngines, readVersion } from "../version.js";
7
+ /** Duck-typed host-surfaced harness version (string or `{ version }`). */
8
+ export function harnessVersion(ctx) {
9
+ const value = ctx.get('harnessVersion');
10
+ if (value === undefined)
11
+ return undefined;
12
+ if (typeof value === 'string')
13
+ return value;
14
+ if (typeof value === 'object' && value !== null) {
15
+ const record = value;
16
+ if (typeof record.version === 'string')
17
+ return record.version;
18
+ }
19
+ return undefined;
20
+ }
21
+ /** Collect the env group checks. */
22
+ export function envChecks(ctx) {
23
+ const checks = [];
24
+ const dshCc = readVersion();
25
+ checks.push({
26
+ id: 'env.dsh-cc',
27
+ group: 'env',
28
+ status: 'ok',
29
+ summary: `dsh-cc ${dshCc}`,
30
+ evidence: { version: dshCc },
31
+ });
32
+ const harness = harnessVersion(ctx);
33
+ if (harness === undefined) {
34
+ checks.push({
35
+ id: 'env.harness',
36
+ group: 'env',
37
+ status: 'skip',
38
+ summary: 'harnessVersion seam not mounted',
39
+ });
40
+ }
41
+ else {
42
+ checks.push({
43
+ id: 'env.harness',
44
+ group: 'env',
45
+ status: 'ok',
46
+ summary: `harness ${harness}`,
47
+ evidence: { version: harness },
48
+ });
49
+ }
50
+ const node = process.version;
51
+ const engines = readEngines();
52
+ const satisfies = nodeSatisfiesEngines(node);
53
+ checks.push({
54
+ id: 'env.node',
55
+ group: 'env',
56
+ status: satisfies ? 'ok' : 'fail',
57
+ summary: satisfies ? `node ${node} satisfies ${engines}` : `node ${node} does not satisfy ${engines}`,
58
+ detail: satisfies ? undefined : `required range: ${engines}`,
59
+ fix: satisfies ? undefined : 'upgrade Node to a version within the required range',
60
+ evidence: { node, engines },
61
+ });
62
+ checks.push({
63
+ id: 'env.os',
64
+ group: 'env',
65
+ status: 'info',
66
+ summary: `${process.platform} ${process.arch}`,
67
+ evidence: { os: process.platform, arch: process.arch },
68
+ });
69
+ return checks;
70
+ }
71
+ //# sourceMappingURL=env.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.js","sourceRoot":"","sources":["../../src/checks/env.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE9E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AAE,EAAE,OAAO,EAAE,OAAO,EAAE;SAC/B,CAAC,CAAA;IACJ,CAAC;IACD,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAA;IAC5B,MAAM,OAAO,GAAG,WAAW,EAAE,CAAA;IAC7B,MAAM,SAAS,GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAA;IAC5C,MAAM,CAAC,IAAI,CAAC;QACV,EAAE,EAAE,UAAU;QACd,KAAK,EAAE,KAAK;QACZ,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM;QACjC,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,QAAQ,IAAI,cAAc,OAAO,EAAE,CAAC,CAAC,CAAC,QAAQ,IAAI,qBAAqB,OAAO,EAAE;QACrG,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,mBAAmB,OAAO,EAAE;QAC5D,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,qDAAqD;QAClF,QAAQ,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;KAC5B,CAAC,CAAA;IACF,MAAM,CAAC,IAAI,CAAC;QACV,EAAE,EAAE,QAAQ;QACZ,KAAK,EAAE,KAAK;QACZ,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,GAAG,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,IAAI,EAAE;QAC9C,QAAQ,EAAE,EAAE,EAAE,EAAE,OAAO,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE;KACvD,CAAC,CAAA;IACF,OAAO,MAAM,CAAA;AACf,CAAC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * `git` checks for `/doctor`: a verbose-only filesystem probe of the working
3
+ * tree (worktree vs main checkout), plus an optional shell-based branch probe.
4
+ * @module @dsh-cc/command-doctor/checks/git
5
+ */
6
+ import type { Context } from '@deepseek-ai/cordis';
7
+ import type { Check } from '../report.ts';
8
+ /** Filesystem git facts shared with the mcp group's Serena cross-note. */
9
+ export interface GitInfo {
10
+ /** Whether the cwd is a git worktree (`.git` is a file). */
11
+ readonly worktree: boolean;
12
+ /** Whether cwd contains a `.git` entry at all. */
13
+ readonly isRepo: boolean;
14
+ /** Whether cwd contains `node_modules`. */
15
+ readonly hasNodeModules: boolean;
16
+ /** Whether cwd contains a `.serena` directory. */
17
+ readonly hasSerena: boolean;
18
+ }
19
+ /** Read the filesystem git facts for cwd (safe in tests; no subprocess). */
20
+ export declare function gitInfo(cwd?: string): GitInfo;
21
+ /** Collect the git group checks. */
22
+ export declare function gitChecks(ctx: Context, options: {
23
+ verbose: boolean;
24
+ cwd?: string;
25
+ }): Promise<Check[]>;
26
+ //# sourceMappingURL=git.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../src/checks/git.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AAEzC,0EAA0E;AAC1E,MAAM,WAAW,OAAO;IACtB,4DAA4D;IAC5D,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;IAC1B,kDAAkD;IAClD,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;IACxB,2CAA2C;IAC3C,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAA;IAChC,kDAAkD;IAClD,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;CAC5B;AAED,4EAA4E;AAC5E,wBAAgB,OAAO,CAAC,GAAG,GAAE,MAAsB,GAAG,OAAO,CAuB5D;AAED,oCAAoC;AACpC,wBAAsB,SAAS,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,CAuC3G"}
@@ -0,0 +1,94 @@
1
+ /**
2
+ * `git` checks for `/doctor`: a verbose-only filesystem probe of the working
3
+ * tree (worktree vs main checkout), plus an optional shell-based branch probe.
4
+ * @module @dsh-cc/command-doctor/checks/git
5
+ */
6
+ import { lstatSync } from 'node:fs';
7
+ /** Read the filesystem git facts for cwd (safe in tests; no subprocess). */
8
+ export function gitInfo(cwd = process.cwd()) {
9
+ let worktree = false;
10
+ let isRepo = false;
11
+ try {
12
+ const stat = lstatSync(`${cwd}/.git`);
13
+ isRepo = true;
14
+ worktree = stat.isFile();
15
+ }
16
+ catch {
17
+ isRepo = false;
18
+ }
19
+ let hasNodeModules = false;
20
+ try {
21
+ hasNodeModules = lstatSync(`${cwd}/node_modules`) !== undefined;
22
+ }
23
+ catch {
24
+ hasNodeModules = false;
25
+ }
26
+ let hasSerena = false;
27
+ try {
28
+ hasSerena = lstatSync(`${cwd}/.serena`).isDirectory();
29
+ }
30
+ catch {
31
+ hasSerena = false;
32
+ }
33
+ return { worktree, isRepo, hasNodeModules, hasSerena };
34
+ }
35
+ /** Collect the git group checks. */
36
+ export async function gitChecks(ctx, options) {
37
+ if (!options.verbose) {
38
+ return [{
39
+ id: 'git.worktree',
40
+ group: 'git',
41
+ status: 'skip',
42
+ summary: 'not probed (use --verbose)',
43
+ }];
44
+ }
45
+ const cwd = options.cwd ?? process.cwd();
46
+ const info = gitInfo(cwd);
47
+ if (!info.isRepo) {
48
+ return [{
49
+ id: 'git.worktree',
50
+ group: 'git',
51
+ status: 'skip',
52
+ summary: 'not a git repo',
53
+ evidence: { cwd },
54
+ }];
55
+ }
56
+ const checks = [{
57
+ id: 'git.worktree',
58
+ group: 'git',
59
+ status: info.worktree ? 'info' : 'ok',
60
+ summary: info.worktree ? 'worktree (linked checkout)' : 'main checkout',
61
+ detail: await branchDetail(ctx),
62
+ evidence: { cwd, worktree: info.worktree },
63
+ }];
64
+ if (info.worktree && !info.hasNodeModules) {
65
+ checks.push({
66
+ id: 'git.worktree-deps',
67
+ group: 'git',
68
+ status: 'warn',
69
+ summary: 'worktree has no node_modules',
70
+ fix: 'run the package manager install in this worktree',
71
+ evidence: { cwd },
72
+ });
73
+ }
74
+ return checks;
75
+ }
76
+ /** Optional one-second branch probe through a mounted shell seam. */
77
+ async function branchDetail(ctx) {
78
+ const shell = ctx.get('shell');
79
+ const run = shell?.run?.bind(shell) ?? shell?.exec?.bind(shell);
80
+ if (run === undefined)
81
+ return undefined;
82
+ try {
83
+ const result = await Promise.race([
84
+ run('git rev-parse --abbrev-ref HEAD', { timeout: 1000 }),
85
+ new Promise(resolve => setTimeout(() => resolve(undefined), 1000)),
86
+ ]);
87
+ const branch = result?.stdout?.trim();
88
+ return branch === undefined || branch.length === 0 ? undefined : `branch ${branch}`;
89
+ }
90
+ catch {
91
+ return undefined;
92
+ }
93
+ }
94
+ //# sourceMappingURL=git.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git.js","sourceRoot":"","sources":["../../src/checks/git.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAgBnC,4EAA4E;AAC5E,MAAM,UAAU,OAAO,CAAC,MAAc,OAAO,CAAC,GAAG,EAAE;IACjD,IAAI,QAAQ,GAAG,KAAK,CAAA;IACpB,IAAI,MAAM,GAAG,KAAK,CAAA;IAClB,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,SAAS,CAAC,GAAG,GAAG,OAAO,CAAC,CAAA;QACrC,MAAM,GAAG,IAAI,CAAA;QACb,QAAQ,GAAG,IAAI,CAAC,MAAM,EAAE,CAAA;IAC1B,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,GAAG,KAAK,CAAA;IAChB,CAAC;IACD,IAAI,cAAc,GAAG,KAAK,CAAA;IAC1B,IAAI,CAAC;QACH,cAAc,GAAG,SAAS,CAAC,GAAG,GAAG,eAAe,CAAC,KAAK,SAAS,CAAA;IACj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,CAAC,CAAC,UAAU,MAAM,EAAE,CAAA;IACrF,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAA;IAClB,CAAC;AACH,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * `hooks` checks for `/doctor`: the hook bridge load report, flag defaults,
3
+ * and the verbose-only `serena-hooks` PATH probe.
4
+ * @module @dsh-cc/command-doctor/checks/hooks
5
+ */
6
+ import type { Context } from '@deepseek-ai/cordis';
7
+ import type { Check } from '../report.ts';
8
+ /** Duck-typed `hookBridgeStatus` face used here. */
9
+ export interface HookBridgeStatus {
10
+ readonly sourcePath: string;
11
+ readonly events: readonly {
12
+ name: string;
13
+ groups: number;
14
+ hooks: number;
15
+ }[];
16
+ readonly skipped: readonly {
17
+ event?: string;
18
+ type?: string;
19
+ reason?: string;
20
+ }[];
21
+ /** Loaded command-hook strings (after substitution); doctor scans these for binaries. */
22
+ readonly commands?: readonly string[];
23
+ readonly error?: string;
24
+ readonly enablePromptHooks: boolean;
25
+ readonly enableAgentHooks: boolean;
26
+ }
27
+ /** Collect the hooks group checks. */
28
+ export declare function hookChecks(ctx: Context, options: {
29
+ verbose: boolean;
30
+ }): Check[];
31
+ /** Pure-fs PATH scan; appends platform executable suffixes. */
32
+ export declare function scanPath(binary: string): string | undefined;
33
+ //# sourceMappingURL=hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/checks/hooks.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AAEzC,oDAAoD;AACpD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,MAAM,EAAE,SAAS;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;IAC3E,QAAQ,CAAC,OAAO,EAAE,SAAS;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;IAC/E,yFAAyF;IACzF,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IACrC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAA;IACnC,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAA;CACnC;AAED,sCAAsC;AACtC,wBAAgB,UAAU,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,GAAG,KAAK,EAAE,CAmE/E;AA2CD,+DAA+D;AAC/D,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAiB3D"}