dsh-triage 0.2.0 → 0.3.1

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/dist/serve.d.ts CHANGED
@@ -1,10 +1,14 @@
1
1
  /**
2
- * `dsh-triage serve` — the local control panel (M4 / `docs/specs/M4-surface.md` §2).
2
+ * `dsh-triage serve` — the local panel (M4 / `docs/specs/M4-surface.md` §2).
3
3
  *
4
- * WHAT IT IS: a read-only window onto the evidence this repo already produces. It lists
5
- * `data/results/*.json`, shows the conclusion and the reasons behind it, and links the
6
- * artifact + its `.sha256`. It deliberately does NOT re-judge anything: a panel that
7
- * invents conclusions would be a second engine with its own drift.
4
+ * WHAT IT IS (R49): the first screen is the answer — is this profile broken, which row, what
5
+ * do I type. `GET /api/summary` carries that projection; the ledger and the `data/results`
6
+ * artifacts live behind two tabs. Before R49 the first screen was a table of artifact names,
7
+ * which is the repo's evidence discipline, not the user's question.
8
+ *
9
+ * It deliberately does NOT re-judge anything: `summary` is built by the same module the CLI
10
+ * uses, from the same `loadAuditData()` object. A panel that invented conclusions would be a
11
+ * second engine with its own drift.
8
12
  *
9
13
  * WHY ZERO DEPENDENCIES: same discipline as the gates (`docs/adr/0003`). A panel that
10
14
  * needs a build step or a framework is a panel that breaks when someone reinstalls.
@@ -15,9 +19,11 @@
15
19
  * - `POST` is refused unless the caller started the process with `--allow-execute`, and
16
20
  * even then this version only answers 501 — running a probe from a browser is a later
17
21
  * step, not a happy accident;
18
- * - artifact names are validated and served from a listing (no path traversal).
22
+ * - artifact names are validated and served from a listing (no path traversal);
23
+ * - every value the page renders is escaped; the page ships no remote assets (CSP below).
19
24
  */
20
25
  import { type Server } from 'node:http';
26
+ import type { ProfileSummary } from './summary.js';
21
27
  export interface ServeOptions {
22
28
  /** Directory holding `*.json` + `.sha256` evidence files. */
23
29
  readonly resultsDir: string;
@@ -34,20 +40,23 @@ export interface ServeOptions {
34
40
  *
35
41
  * Injected rather than imported on purpose: the panel stays a *display* layer, and
36
42
  * "which home, which profile, which stamp" is the CLI's decision, not the server's.
37
- * `null`/absent means `/api/audit` answers **501** — never a 200 with an empty list,
38
- * because "not enabled" and "nothing to report" must not look alike.
43
+ * `null`/absent means `/api/summary` and `/api/audit` answer **501** — never a 200 with an
44
+ * empty list, because "not enabled" and "nothing to report" must not look alike.
39
45
  */
40
46
  readonly audit?: (() => Promise<AuditSnapshot>) | null;
41
47
  }
42
48
  /**
43
- * One `audit` run, in the two shapes the panel can display.
49
+ * One `audit` run, in the shapes the panel displays.
44
50
  *
45
- * The payload is the exact object `dsh-triage audit --json` prints, so the panel and the CLI
46
- * cannot disagree without someone editing the engine (T-406's acceptance rule).
51
+ * `payload` is the exact object `dsh-triage audit --json` prints. `summary` is the projection
52
+ * the CLI's first screen prints. Both come from the *same* `loadAuditData()` call — a caller
53
+ * that supplies only one of them would let the panel and the CLI disagree, so both are
54
+ * required (T-406's acceptance rule, R49).
47
55
  */
48
56
  export type AuditSnapshot = {
49
57
  readonly ok: true;
50
58
  readonly payload: Record<string, unknown>;
59
+ readonly summary: ProfileSummary;
51
60
  } | {
52
61
  readonly ok: false;
53
62
  readonly message: string;
@@ -79,13 +88,39 @@ export declare function artifactKind(name: string): string;
79
88
  export declare function summarizeArtifact(resultsDir: string, name: string): ArtifactSummary;
80
89
  /** Every `*.json` in the results directory, newest first. Read-only by construction. */
81
90
  export declare function listArtifacts(resultsDir: string): ArtifactSummary[];
91
+ /**
92
+ * Resolve an artifact name to a real path inside `resultsDir`, or `null`.
93
+ *
94
+ * The name regex already refuses separators and `..`; this is the second lock. A symlink or
95
+ * NTFS junction planted inside the results directory must not become a read anywhere else on
96
+ * disk, and a file over the 2MB ceiling is refused before it is opened.
97
+ */
98
+ export declare function resolveArtifact(resultsDir: string, name: string): string | null;
99
+ /** The four fields the first screen prints above the verdict. Never the profile directory. */
100
+ export interface EnvHeadline {
101
+ readonly dsh: string | null;
102
+ readonly profile: string | null;
103
+ readonly platform: string | null;
104
+ readonly arch: string | null;
105
+ }
82
106
  export declare function createPanelServer(options: ServeOptions): PanelServer;
83
107
  export declare function startPanel(options: ServeOptions): Promise<PanelServer>;
84
108
  /** Deterministic digest helper used by the smoke recorder. */
85
109
  export declare function sha256OfText(text: string): string;
86
110
  /**
87
- * The page is intentionally plain: one table, a detail pane, no framework, no remote
88
- * assets. Everything it shows comes from `/api/artifacts` and `/api/artifact`.
111
+ * The page (R50): three layers, nothing else.
112
+ *
113
+ * status — one sentence and one number, the width of the text, no boxes;
114
+ * issues — the rows that need a decision, one line each;
115
+ * commands — the exact strings to type, one click each.
116
+ *
117
+ * Everything the answer rests on (the artifact ledger and the raw `audit --json`
118
+ * payload) stays one Tab away instead of competing with it. The detail level is a real
119
+ * switch, not a matter of taste: `simple` hides the ledger entirely and says every issue
120
+ * in everyday words; `advanced` keeps the ledger, the six counters and audit's own wording.
121
+ *
122
+ * No framework, no remote assets, no inline event handlers: everything is built from the two
123
+ * JSON routes and escaped on the way in (see `esc` below). `data-copy` buttons carry the exact
124
+ * command text, so "what do I type" is one click instead of a transcription.
89
125
  */
90
126
  export declare function renderPanelHtml(locale: 'en' | 'zh'): string;
91
- //# sourceMappingURL=serve.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../src/serve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAsC,KAAK,MAAM,EAAuB,MAAM,WAAW,CAAA;AAMhG,MAAM,WAAW,YAAY;IAC3B,6DAA6D;IAC7D,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,0EAA0E;IAC1E,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,4CAA4C;IAC5C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,0DAA0D;IAC1D,QAAQ,CAAC,MAAM,CAAC,EAAE,IAAI,GAAG,IAAI,CAAA;IAC7B,0EAA0E;IAC1E,Q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