@kangyishuai/dsh-casefile 0.8.1 → 0.9.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 +95 -36
- package/README.zh-CN.md +96 -36
- package/lib/actions.js +270 -36
- package/lib/client.js +815 -102
- package/lib/core/brief.js +58 -12
- package/lib/core/model.js +17 -1
- package/lib/core/report.js +8 -1
- package/lib/core/store.js +371 -15
- package/lib/service.js +54 -2
- package/lib/tools.js +112 -16
- package/locale/en.json +11 -1
- package/locale/zh.json +11 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
Unofficial plugin for [DeepSeek Harness (DSH)](https://github.com/deepseek-ai/deepseek-harness). Not affiliated with DeepSeek. It is an adapter on top of [REA](https://github.com/morluto/rea) (MIT); it ships none of REA's code and no analysis engine.
|
|
8
8
|
|
|
9
|
-
> **Status: M3 complete (five checkers + one-call cycle + near-miss + coverage gate + report).** Persists projects, evidence, claims, features, unknowns, obligations and check records; exports a redacted spec pack; ships a workbench page (evidence / obligations / runs), a sidebar entry and a settings section. A **builder session** can be started from a project: casefile creates a child session, feeds it only the spec pack (never the original target), and returns the session id; `awaitBuilder` reports why it stopped. The build/check loop runs real commands: `case_build start` records a `BuildRun` with an implementation digest, `case_check run` records a result bound to that digest, and a later build whose digest differs automatically **reopens** the obligations it had closed. Verified by
|
|
9
|
+
> **Status: M3 complete (five checkers + one-call cycle + near-miss + coverage gate + report).** Persists projects, evidence, claims, features, unknowns, obligations and check records; exports a redacted spec pack; ships a workbench page (evidence / obligations / runs), a sidebar entry and a settings section. A **builder session** can be started from a project: casefile creates a child session, feeds it only the spec pack (never the original target), and returns the session id; `awaitBuilder` reports why it stopped. The build/check loop runs real commands: `case_build start` records a `BuildRun` with an implementation digest, `case_check run` records a result bound to that digest, and a later build whose digest differs automatically **reopens** the obligations it had closed. Verified by the package unit suite (counts and commands are listed in [docs/testing/casefile.md](../../docs/testing/casefile.md)) plus a web end-to-end smoke on a throwaway DSH home (including the stale-reopen path) and a desktop read-only regression. Treat it as young software.
|
|
10
10
|
|
|
11
11
|
## What it does
|
|
12
12
|
|
|
@@ -19,7 +19,17 @@ Casefile is the missing layer:
|
|
|
19
19
|
- **Claims you can cite and select.** A `Claim` is the unit you quote in a handoff: it references evidence ids, carries its own limitations, and can be selected (`case_claim select`) for export.
|
|
20
20
|
- **Feature grouping for scoped work.** Group selected claims into a `Feature` with boundaries and non-goals — the unit later used by "rebuild only these features".
|
|
21
21
|
- **Unknowns are shipped, not hidden.** Open unknowns are part of the spec pack; a pack that silently drops them is a lie.
|
|
22
|
-
- **Spec pack export.** `case_brief export` writes `spec/<timestamp>/spec.json` + `brief.md`: selected claims, their evidence, features, open unknowns, a coverage summary, and a content hash. Redaction is on by default
|
|
22
|
+
- **Spec pack export.** `case_brief export` writes `spec/<timestamp>/spec.json` + `brief.md`: selected claims, their evidence, features, open unknowns, a coverage summary, and a content hash. Redaction is on by default and shared by spec packs, machine-readable bundles **and** the HTML/Markdown acceptance report (see [Privacy](#side-effects--risks)).
|
|
23
|
+
|
|
24
|
+
## Redaction
|
|
25
|
+
|
|
26
|
+
All three exports (spec pack, bundle, report) go through the same `redactPack` pass, and `case_project report` redacts by default too:
|
|
27
|
+
|
|
28
|
+
- **Paths:** any path under a common system root (`/Users`, `/home`, `/var`, `/tmp`, `/private`, `/Applications`, `/Volumes`, `/opt`, `/etc`, `/Library`, `/usr`, `/System`, `/bin`, `/sbin`, `/dev`, `/proc`, `/boot`, `/root`, `/mnt`, `/media`, `/snap`, `/nix`, `/data`, `/srv`, `/workspace`), any unexpanded `~/…`, and any **absolute** path ending in a **1–8 character** file extension — replaced with `<path>`.
|
|
29
|
+
- **Tokens:** `sk-…`, `ghp_…`, `github_pat_…`, AWS `AKIA…`/`ASIA…`, Google `AIza…`, `npm_…`, `xox[abp]-…`, `Bearer …`, JWT (`eyJ…`), PEM private-key blocks, and `password=` / `api_key=` / `secret=` / `token=` values — replaced with `[redacted]`.
|
|
30
|
+
- **Deliberately kept:** URLs and API routes **without a file extension** (`https://example.test/api/todos`, `POST /api/todos`, `/auth/token`) stay readable, because a spec pack that turns every route into `<path>` is useless to the builder. An absolute path ending in a file extension is redacted even when it looks like a route (`/static/app.js`, `/api/v1/openapi.json`).
|
|
31
|
+
|
|
32
|
+
Known limit: a path that contains spaces is redacted only up to the first space (the remainder stays). Redaction is a safety net, not a guarantee: review a pack before sharing it.
|
|
23
33
|
- **Capability detection.** `case_project` and `diagnose()` report whether `mcp__rea__*` tools are visible and which casefile-required tools are missing, instead of silently degrading.
|
|
24
34
|
|
|
25
35
|
## Install
|
|
@@ -48,25 +58,46 @@ Re-run `pnpm pack` + `add` after changing the code. Restart the DSH desktop app
|
|
|
48
58
|
The plugin adds a **Casefile** entry to the sidebar. The page lists projects on the left and shows the selected project on the right with three tabs:
|
|
49
59
|
|
|
50
60
|
- **Evidence** — claims (with confidence, limits and evidence count) and the evidence records they cite;
|
|
51
|
-
- **Obligations** — obligations, their status, and open unknowns. Closing an obligation needs a _fresh PASS
|
|
52
|
-
The list view opens with an **overview strip**: project count, breakdown by target kind and state, obligation pass/total, and unresolved unknowns across every project. `case_project overview` returns the same data as JSON.
|
|
61
|
+
- **Obligations** — obligations, their status, and open unknowns. Closing an obligation needs a _fresh PASS check bound to the current implementation digest_; otherwise the button names the exact blocker (`no-fresh-check`, `coverage-below`, `open-unknowns`, …) instead of pretending.
|
|
53
62
|
- **Runs** — build rounds (status, implementation digest, command) and check verdicts bound to each digest.
|
|
54
63
|
|
|
55
|
-
|
|
64
|
+
The list view opens with an **overview strip** (project count, breakdown by target kind and state, obligation pass/total, unresolved unknowns across projects); `case_project overview` returns the same data as JSON. An **empty** workbench explains in plain words what a case file is, who it is for and what the first step is; tool names (`case_evidence`, `case_claim`, …) are folded under “For developers / the AI agent” instead of being the first thing a new user reads. The **New project** form labels every field (title, target, target kind, authorization) and validates the required title on blur and on submit, with a readable error instead of a dead button.
|
|
65
|
+
|
|
66
|
+
The panel header shows the selected project's **autonomy level** (L0–L3); the badge's tooltip explains in plain words what the level means, with L0–L3 kept as a subtitle.
|
|
67
|
+
|
|
68
|
+
The header also exposes a **Trash** entry. It lists projects dropped with `case_project drop` (id, size, file count), restores one with a click, and empties the trash only after a dry-run shows the impact (`N entries / size; unknown entries are kept`). Dropped projects are moved, never deleted, until you confirm the hard delete.
|
|
69
|
+
|
|
70
|
+
A project's detail page carries a collapsed **Danger zone → Move to trash** entry for the user: it first previews the impact (file count / size, restorable) and only moves the project after an explicit confirmation, then shows it in the trash. The agent-side `case_project drop` tool requires `confirm: true` **and** is documented as "only after the user explicitly agreed, never on your own initiative" — under a full-access permission preset the model could technically call it, so the tool description and this README both put the consent requirement in writing.
|
|
71
|
+
|
|
72
|
+
Per [ADR 0002](https://github.com/kangyishuai/dsh-plugins/blob/main/docs/adr/0002-destructive-operations.md) there is also `case_project purge` (`dryRun` + `confirm`) for scripted use, and every drop/restore/purge is written to the data root's `audit.jsonl` (a dropped project can no longer write into its own audit file).
|
|
73
|
+
|
|
74
|
+
A settings section shows the data root, project count and REA connection state. REA being absent is shown as an **optional, unavailable notice** (it does not block creating projects or recording evidence), not as an error; the raw `mcp__rea__*` detection detail is available under the same advanced fold.
|
|
56
75
|
|
|
57
76
|
## Tools
|
|
58
77
|
|
|
59
|
-
| Tool
|
|
60
|
-
|
|
|
61
|
-
| `case_project`
|
|
62
|
-
| `case_evidence`
|
|
63
|
-
| `case_claim`
|
|
64
|
-
| `case_feature`
|
|
65
|
-
| `case_unknown`
|
|
66
|
-
| `
|
|
78
|
+
| Tool | Actions | Purpose |
|
|
79
|
+
| ----------------- | ------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
|
|
80
|
+
| `case_project` | `open`, `list`, `get`, `update` | Open a new **or existing** project, list, inspect, change authorization tier / scope / state |
|
|
81
|
+
| `case_evidence` | `add`, `list`, `show` | Store an REA observation as evidence; filter; read one |
|
|
82
|
+
| `case_claim` | `add`, `list`, `search`, `select` | Store a citable conclusion; search; select it for export |
|
|
83
|
+
| `case_feature` | `add`, `list` | Group claims into a feature with boundaries and non-goals |
|
|
84
|
+
| `case_unknown` | `add`, `list`, `resolve` | Record unknowns; mark one resolved with a note |
|
|
85
|
+
| `case_obligation` | `add`, `list`, `close`, `reopen` | Acceptance obligations; `close` needs a fresh passing check |
|
|
86
|
+
| `case_build` | `start`, `agent`, `status`, `loop`, `cycle` | Build runs, builder sessions, and the build→check→close loop |
|
|
87
|
+
| `case_check` | `run`, `list`, `loop` | Run one checker and bind the result to the current implementation digest |
|
|
88
|
+
| `case_access` | `await-login` | Poll a CDP page until a sign-in predicate holds (ready / timeout / error) |
|
|
89
|
+
| `case_app` | `inspect` | One-screen macOS `.app` summary (bundle id, versions, sandbox, ATS, UTI domains) |
|
|
90
|
+
| `case_brief` | `export` | Write the redacted spec pack (`spec.json` + `brief.md`) |
|
|
91
|
+
| `case_ingest` | `ingest`, `schema` | Ingest an external agent's report under a stable contract (recorded, not endorsed); `schema` prints the contract |
|
|
92
|
+
|
|
93
|
+
`case_project` also carries `close`, `report` (`format: md | html | both`, redacted by default), `bundle` (machine-readable, deterministic), `overview`, `archive`, `drop` (`dryRun` / `confirm`), `trash`, `restore`, `purge` (`dryRun` / `confirm`), and `autonomy` (L0–L3 gating).
|
|
94
|
+
|
|
95
|
+
**Session memory:** every call that receives an explicit `projectId` also makes it the session's current project, and that pointer is persisted under the data root — `case_project open` with an existing project id opens it instead of failing, and after a restart the same session can keep calling tools without repeating `projectId`. If a call still omits it, the error names the last opened project as a hint instead of just failing.
|
|
67
96
|
|
|
68
97
|
Every tool returns `{ ok, data?, error?{code,message,hint}, summary }`; errors carry a stable code, so the model can correct itself instead of guessing.
|
|
69
98
|
|
|
99
|
+
**Tool-surface cost:** these 12 definitions total ~13.6 KB of `description`+`parameters` JSON (≈3.4K tokens at ~4 bytes/token) and are resident in every session, while only a small fraction of sessions use casefile. That is a deliberate trade-off (each tool keeps a self-explanatory schema); the low-frequency ones (`case_access`, `case_app`, `case_ingest`) are the first candidates to merge into a `case_misc` tool if the surface needs shrinking.
|
|
100
|
+
|
|
70
101
|
Obligations may carry `featureIds`, so a **scoped replica** can report coverage per feature: an obligation tagged with a feature only counts toward that feature's ratio; untagged ones count only globally.
|
|
71
102
|
|
|
72
103
|
## Checkers
|
|
@@ -111,50 +142,78 @@ Everything lives under the plugin's data root (default `<DSH_HOME>/casefile`, ov
|
|
|
111
142
|
|
|
112
143
|
```
|
|
113
144
|
casefile/
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
145
|
+
├── projects/<project-id>/
|
|
146
|
+
│ ├── project.json # version + target + authTier + scope + REA version
|
|
147
|
+
│ ├── evidence.jsonl # append-only; same id later wins
|
|
148
|
+
│ ├── claims.jsonl
|
|
149
|
+
│ ├── features.jsonl
|
|
150
|
+
│ ├── unknowns.jsonl
|
|
151
|
+
│ ├── audit.jsonl # who did what, append-only
|
|
152
|
+
│ ├── artifacts/ # archived artifacts (size-capped)
|
|
153
|
+
│ ├── checks/ # verification runs
|
|
154
|
+
│ ├── spec/<timestamp>/ # exported spec.json + brief.md
|
|
155
|
+
│ ├── reports/ # exported reports
|
|
156
|
+
│ └── bundles/ # exported agent-environment bundles
|
|
157
|
+
├── trash/ # dropped projects, restorable
|
|
158
|
+
├── audit.jsonl # data-root audit (drop / restore / purge)
|
|
159
|
+
├── last-opened.json # last opened project (UI convenience)
|
|
160
|
+
├── session-pointers.json # session → project pointers
|
|
161
|
+
└── builder-sessions.jsonl # builder sessions (read-only guard)
|
|
122
162
|
```
|
|
123
163
|
|
|
124
164
|
Rules: JSON files carry a `version`; a file written by a newer casefile is reported as read-only instead of silently rewritten. Corrupt JSON is renamed `.broken` and kept. Records are append-only, so a project directory can be reviewed and diffed.
|
|
125
165
|
|
|
126
166
|
## Config
|
|
127
167
|
|
|
128
|
-
| Key | Default | Meaning
|
|
129
|
-
| ------------------ | --------------------- |
|
|
130
|
-
| `dataRoot` | `<DSH_HOME>/casefile` | Where project data lives; injectable for tests
|
|
131
|
-
| `defaultAuthTier` | `research` | Default authorization tier for new projects
|
|
132
|
-
| `cleanRoomDefault` | `true` | Reserved for the builder milestone: builder cannot see the original
|
|
133
|
-
| `checkers` | `["cli","web"]` | Reserved for the verification milestone
|
|
134
|
-
| `maxRounds` | `5` | Reserved for the verification loop
|
|
135
|
-
| `
|
|
168
|
+
| Key | Default | Meaning |
|
|
169
|
+
| ------------------ | --------------------- | --------------------------------------------------------------------- |
|
|
170
|
+
| `dataRoot` | `<DSH_HOME>/casefile` | Where project data lives; injectable for tests |
|
|
171
|
+
| `defaultAuthTier` | `research` | Default authorization tier for new projects |
|
|
172
|
+
| `cleanRoomDefault` | `true` | Reserved for the builder milestone: builder cannot see the original |
|
|
173
|
+
| `checkers` | `["cli","web"]` | Reserved for the verification milestone |
|
|
174
|
+
| `maxRounds` | `5` | Reserved for the verification loop |
|
|
175
|
+
| `maxArtifactBytes` | `67108864` (64 MiB) | Reject archiving artifacts larger than this (stat pre-check, no read) |
|
|
136
176
|
|
|
137
177
|
Config is read from the `casefile` row in `cordis.patch.yml`. Do not edit the profile by hand — change the row's `config:`.
|
|
138
178
|
|
|
139
179
|
## Compatibility
|
|
140
180
|
|
|
141
|
-
| Plugin
|
|
142
|
-
|
|
|
143
|
-
| 0.1.x–0.2.x
|
|
144
|
-
| 0.3.x–0.5.x
|
|
181
|
+
| Plugin | Verified on DSH | What was run |
|
|
182
|
+
| --------------- | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
183
|
+
| 0.1.x–0.2.x | 0.2.2-rc.3 (macOS, desktop + web) | 138 → 177 unit tests; 52-assertion web end-to-end smoke on a throwaway DSH home; **14-assertion desktop read-only regression on a real Electron renderer (CDP)**; `pnpm gate casefile` 4/4 steps green. |
|
|
184
|
+
| 0.3.x–0.5.x | same | 172 → 177 unit tests; adds `case_access` (sign-in wait), `case_app` (app-bundle first hop), artifact archiving, and project `archive`/`drop`; **exercised on 8 real projects** (local macOS app, sign-in-gated page, external-collector ingestion). |
|
|
185
|
+
| **0.6.x–0.8.x** | same | 216 unit tests; **56-assertion web end-to-end** (adds external-report ingest dryRun/real assertions); **15-assertion desktop regression** (adds autonomy badge); `pnpm gate casefile` 4/4 green. Adds: HTML report, machine-readable bundle, L3 unattended runs, external-report ingest contract (incl. automatic Craft-shaped mapping), blank-screenshot guard. |
|
|
186
|
+
| 0.8.1 | 0.2.2-rc.5 (macOS, desktop + web) | No code change needed for this DSH build. 216 unit tests; **56-assertion web end-to-end smoke**; **15-assertion desktop read-only regression (run twice, idempotent)**; `pnpm gate casefile` 4/4 steps green, plus **`pnpm gate:all --repeat 2`** green across all six plugins (631s). The 43-package host diff for this release ([runtime rc.5](../../docs/runtime/0.2.2-rc.5.md)) found no change in any host API this plugin uses. |
|
|
145
187
|
|
|
146
188
|
Host APIs used here were verified by runtime inspection; the findings are recorded in `docs/runtime/0.2.2-rc.3.md` §10 (including two pitfalls: a missed `declareRemote` silently 404s only that endpoint, and `agentPresets` cannot be composed from bundle names).
|
|
147
189
|
|
|
148
|
-
|
|
190
|
+
**Five** target kinds were exercised in real tasks (incl. a local Electron app): **a local macOS app bundle** (Info.plist, signature surface, binary inventory — the binary layer needs REA + Ghidra, see `docs/runtime/0.2.2-rc.3.md` §13–§14), **a sign-in-gated web page** (`case_access await-login`, structure-only capture), **external-collector artifacts** (`producer` + `artifactPath` archiving), and **an app's own release package** (survey → spec → acceptance, closed end to end).
|
|
149
191
|
|
|
150
192
|
## Side effects & risks
|
|
151
193
|
|
|
152
194
|
- **Files it writes:** only under the data root above. It never writes into the investigated project, never modifies the REA binary, and never edits the profile.
|
|
153
|
-
- **Destructive actions:**
|
|
154
|
-
- **Privacy:** project data stays on this machine. Spec packs are redacted by default (
|
|
195
|
+
- **Destructive actions:** following [ADR 0002](https://github.com/kangyishuai/dsh-plugins/blob/main/docs/adr/0002-destructive-operations.md). `case_project drop` moves the whole project directory into `<dataRoot>/trash/<timestamp>-<id>` (recoverable), needs `confirm: true`, supports `dryRun` with a count / size / target path, and writes a data-root audit entry. The tool contract says the agent must only call it **after the user explicitly agreed**; the workbench offers the same action to the user behind a preview + confirmation (Danger zone). Note that under a `danger-full-access` / `approval: never` preset the host does not add an approval prompt for this tool — full-access sessions are trusted to follow their instructions, so this consent requirement is documented rather than enforced by the host. The trash can be listed, restored and emptied (`case_project purge`, `dryRun` + `confirm`; unknown entries in the trash are kept and reported, never `rm -rf`ed). Nothing is hard-deleted without an explicit confirmation.
|
|
196
|
+
- **Privacy:** project data stays on this machine. Spec packs, bundles and reports are redacted by default (system-root paths, `~/…`, extended paths, and the token shapes listed above) but **you should still review a file before sharing it** — redaction is a safety net, not a guarantee.
|
|
155
197
|
- **Evidence quality:** casefile stores what you tell it. It does not verify an observation, and it never upgrades a claim's confidence or authority.
|
|
156
198
|
- **Legal:** intended for research and for software you own or are authorized to analyze. It deliberately ships **no** DRM/anti-debugging bypass and no way to reuse third-party assets. Read [DISCLAIMER.md](./DISCLAIMER.md) before use.
|
|
157
199
|
|
|
200
|
+
## Uninstall
|
|
201
|
+
|
|
202
|
+
Uninstalling the plugin does **not** delete anything: the host only removes the package. Your case files stay on disk under the data root (`<DSH_HOME>/casefile` by default — see [Data layout](#data-layout)):
|
|
203
|
+
|
|
204
|
+
- `projects/<id>/` — project records plus `artifacts/`, `spec/`, `reports/`, `bundles/` and `checks/`;
|
|
205
|
+
- `trash/` — projects moved there by `case_project drop` (still restorable if you reinstall);
|
|
206
|
+
- `audit.jsonl`, `last-opened.json`, `session-pointers.json`, `builder-sessions.jsonl` — the data-root audit trail, the last-opened pointer, the session → project pointers and the builder-session records used by the read-only guard.
|
|
207
|
+
|
|
208
|
+
Nothing is uploaded, and nothing is cleaned up on uninstall — deliberately, so a reinstall keeps your evidence. To delete the data manually (only after you have exported what you need):
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
du -sh "$DSH_HOME/casefile" # see the size first
|
|
212
|
+
rm -rf "$DSH_HOME/casefile" # use your configured dataRoot if you overrode it
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
Exported spec packs, reports and bundles live **inside** the project directories (`spec/`, `reports/`, `bundles/`), so they are removed with the tree; copy them out first if they matter.
|
|
216
|
+
|
|
158
217
|
## Development
|
|
159
218
|
|
|
160
219
|
```bash
|
package/README.zh-CN.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
[DeepSeek Harness (DSH)](https://github.com/deepseek-ai/deepseek-harness) 的非官方插件,与 DeepSeek 无关。它是 [REA](https://github.com/morluto/rea)(MIT)之上的适配层:不包含 REA 的代码,也不带分析引擎。
|
|
8
8
|
|
|
9
|
-
> **状态:M3 完成(五类 checker + 一次调用闭环 + near-miss + 覆盖率硬门 + 报告)。** 落盘「项目 / 证据 / 结论 / 功能 / 未知项 / 义务 / 检查记录」,能导出去原始化的规格包,并提供工作台页(证据 / 义务 / 运行)、侧栏入口与设置分节。现在可以从项目里起一个 **builder 会话**:casefile 建子会话、只投喂规格包(不投原件),返回 sessionId;`awaitBuilder` 报它为什么停下。`case_build loop` 一次跑完一轮:构建 → 按义务自带的检查配方逐个检查 → 通过的关闭 → 命中停止条件就停。构建/检查循环真的跑命令:`case_build start` 落 `BuildRun` 并算实现 digest,`case_check run` 记录绑定该 digest 的检查结果;之后再构建若 digest
|
|
9
|
+
> **状态:M3 完成(五类 checker + 一次调用闭环 + near-miss + 覆盖率硬门 + 报告)。** 落盘「项目 / 证据 / 结论 / 功能 / 未知项 / 义务 / 检查记录」,能导出去原始化的规格包,并提供工作台页(证据 / 义务 / 运行)、侧栏入口与设置分节。现在可以从项目里起一个 **builder 会话**:casefile 建子会话、只投喂规格包(不投原件),返回 sessionId;`awaitBuilder` 报它为什么停下。`case_build loop` 一次跑完一轮:构建 → 按义务自带的检查配方逐个检查 → 通过的关闭 → 命中停止条件就停。构建/检查循环真的跑命令:`case_build start` 落 `BuildRun` 并算实现 digest,`case_check run` 记录绑定该 digest 的检查结果;之后再构建若 digest 变了,**自动重开**已被它关闭的义务。验证以包内单测 + 临时 DSH_HOME 上的 web 端到端冒烟(含 stale 重开路径)+ 桌面只读回归为准,具体条数与命令见 [docs/testing/casefile.md](../../docs/testing/casefile.md)。请按早期软件对待。
|
|
10
10
|
|
|
11
11
|
## 它解决什么
|
|
12
12
|
|
|
@@ -19,7 +19,18 @@ casefile 补的就是这一层:
|
|
|
19
19
|
- **可引用、可选中的结论。** `Claim` 是交接时被引用的单位:引用证据 id、带自己的局限、可被勾选(`case_claim select`)进入规格包。
|
|
20
20
|
- **功能分组。** 把选中的结论归到 `Feature`,写清边界与非目标——后续「只复刻这些功能」的范围单位。
|
|
21
21
|
- **未知项必须随包交付。** 未解决的未知项会进规格包;悄悄丢掉的包等于说谎。
|
|
22
|
-
- **规格包导出。** `case_brief export` 写出 `spec/<时间戳>/spec.json` + `brief.md
|
|
22
|
+
- **规格包导出。** `case_brief export` 写出 `spec/<时间戳>/spec.json` + `brief.md`:选中的结论、证据、功能、未知项、覆盖度摘要与内容哈希。默认脱敏,且规格包、机器可读 bundle 与验收报告**共用同一套脱敏**(见[副作用与风险](#副作用与风险)的「隐私」段)。
|
|
23
|
+
|
|
24
|
+
## 脱敏
|
|
25
|
+
|
|
26
|
+
三条导出(规格包、bundle、报告)都走同一个 `redactPack`,`case_project report` 默认也脱敏:
|
|
27
|
+
|
|
28
|
+
- **路径:** 常见系统根目录下的任意路径(`/Users`、`/home`、`/var`、`/tmp`、`/private`、`/Applications`、`/Volumes`、`/opt`、`/etc`、`/Library`、`/usr`、`/System`、`/bin`、`/sbin`、`/dev`、`/proc`、`/boot`、`/root`、`/mnt`、`/media`、`/snap`、`/nix`、`/data`、`/srv`、`/workspace`)、未展开的 `~/…`、以及任何**以 1–8 字符扩展名结尾的绝对路径** → `<path>`。
|
|
29
|
+
- **Token:** `sk-…`、`ghp_…`、`github_pat_…`、AWS `AKIA…`/`ASIA…`、Google `AIza…`、`npm_…`、`xox[abp]-…`、`Bearer …`、JWT(`eyJ…`)、PEM 私钥块,以及 `password=` / `api_key=` / `secret=` / `token=` 的值 → `[redacted]`。
|
|
30
|
+
- **刻意保留:** **不带扩展名**的 URL 与 API 路由(`https://example.test/api/todos`、`POST /api/todos`、`/auth/token`)保持可读——把每个路由都变成 `<path>` 的规格包对 builder 没有价值。带文件扩展名的绝对路径即使像路由也会被遮(`/static/app.js`、`/api/v1/openapi.json`)。
|
|
31
|
+
|
|
32
|
+
已知限制:含空格的路径只遮到第一个空格为止,后面的片段会保留。脱敏是安全网,不是保证:分享前请自己过一遍。
|
|
33
|
+
|
|
23
34
|
- **能力探测。** `case_project` 与 `diagnose()` 报告 `mcp__rea__*` 是否可见、casefile 依赖的工具缺哪些,而不是静默降级。
|
|
24
35
|
|
|
25
36
|
## 安装
|
|
@@ -48,25 +59,46 @@ dsh plugin --profile desktop add /tmp/kangyishuai-dsh-casefile-*.tgz
|
|
|
48
59
|
插件在侧栏加一个「案卷」入口。页面左侧是项目列表,右侧是选中项目的三个页签:
|
|
49
60
|
|
|
50
61
|
- **证据** —— 结论(带可信度、局限、证据数)与它们引用的证据记录;
|
|
51
|
-
- **义务** —— 义务、状态与未解决未知项。关闭义务需要**新鲜的 PASS
|
|
52
|
-
列表页顶部有一条**总览**:项目数、按目标类型与状态的分布、义务通过数/总数、跨项目的未解决未知项。`case_project overview` 以 JSON 返回同一份数据。
|
|
62
|
+
- **义务** —— 义务、状态与未解决未知项。关闭义务需要**新鲜的 PASS 检查,且与当前实现 digest 绑定**;否则按钮会点名具体阻塞项(`no-fresh-check`、`coverage-below`、`open-unknowns` 等),而不是假装能关。
|
|
53
63
|
- **运行** —— 构建轮次(状态、实现 digest、命令)与绑定到该 digest 的检查结论。
|
|
54
64
|
|
|
55
|
-
|
|
65
|
+
列表页顶部有一条**总览**:项目数、按目标类型与状态的分布、义务通过数/总数、跨项目的未解决未知项;`case_project overview` 以 JSON 返回同一份数据。**空工作台**用人话说清这是什么、适合谁、第一步做什么;工具名(`case_evidence`、`case_claim` 等)收在「给开发者 / AI 的说明」折叠里,不再作为新用户首先读到的东西。**新建项目**表单给每个字段加了标签(标题、目标、对象类型、授权范围),必填标题在失焦与提交时校验并给出可读错误,而不是一个按了没反应的按钮。
|
|
66
|
+
|
|
67
|
+
面板头部显示当前项目的**自主性级别**(L0–L3);徽章提示用一句话解释这个等级是什么,L0–L3 作为副标题保留。
|
|
68
|
+
|
|
69
|
+
头部还有**回收站**入口:列出被 `case_project drop` 丢弃的项目(id、体积、文件数),可一键恢复;清空回收站前先用 dry-run 展示影响面(`N 个条目 / 体积;来历不明的条目会保留`)。丢弃只是移走,确认硬删之前都能恢复。
|
|
70
|
+
|
|
71
|
+
项目详情页给用户留了一个默认收起的**「危险操作 → 移入回收站」**入口:先 dry-run 展示影响面(文件数 / 体积、可恢复),再显式确认才移动,移完直接进回收站视图。agent 侧的 `case_project drop` 除了 `confirm: true`,工具描述还明确要求「必须用户明确同意后才可执行,不得自行 drop」——完全权限档下宿主不会额外弹审批,所以这条同意要求同时写进工具契约与本文档,属于文档约束而非宿主强制。
|
|
72
|
+
|
|
73
|
+
按 [ADR 0002](https://github.com/kangyishuai/dsh-plugins/blob/main/docs/adr/0002-destructive-operations.md),脚本化场景用 `case_project purge`(`dryRun` + `confirm`);每次 drop/restore/purge 都会写数据根级 `audit.jsonl`(被丢弃的项目已经写不进自己的 audit 文件)。
|
|
74
|
+
|
|
75
|
+
设置分节显示数据根、项目数与 REA 接入状态。REA 未接入按**可选 / 不可用说明**呈现(不影响建项目和手工记录证据),不是红色错误;`mcp__rea__*` 的原始检测结果放在同一个高级折叠里。
|
|
56
76
|
|
|
57
77
|
## 工具
|
|
58
78
|
|
|
59
|
-
| 工具
|
|
60
|
-
|
|
|
61
|
-
| `case_project`
|
|
62
|
-
| `case_evidence`
|
|
63
|
-
| `case_claim`
|
|
64
|
-
| `case_feature`
|
|
65
|
-
| `case_unknown`
|
|
66
|
-
| `
|
|
79
|
+
| 工具 | 动作 | 用途 |
|
|
80
|
+
| ----------------- | ----------------------------------------------- | -------------------------------------------------------------------- |
|
|
81
|
+
| `case_project` | `open` / `list` / `get` / `update` | 新建**或打开已有**项目、列表、详情、改授权档/范围/状态 |
|
|
82
|
+
| `case_evidence` | `add` / `list` / `show` | 把 REA 观察写成证据;过滤;看单条 |
|
|
83
|
+
| `case_claim` | `add` / `list` / `search` / `select` | 写可引用结论;搜索;勾选进入规格包 |
|
|
84
|
+
| `case_feature` | `add` / `list` | 把结论归到功能,写边界与非目标 |
|
|
85
|
+
| `case_unknown` | `add` / `list` / `resolve` | 记录未知项;带备注标记已解决 |
|
|
86
|
+
| `case_obligation` | `add` / `list` / `close` / `reopen` | 可验收义务;`close` 必须有新鲜的通过检查 |
|
|
87
|
+
| `case_build` | `start` / `agent` / `status` / `loop` / `cycle` | 构建运行、builder 会话、构建→检查→关闭的循环 |
|
|
88
|
+
| `case_check` | `run` / `list` / `loop` | 跑一个 checker,并把结果绑定到当前实现 digest |
|
|
89
|
+
| `case_access` | `await-login` | 轮询 CDP 页面直到登录判据成立(就绪/超时/错误) |
|
|
90
|
+
| `case_app` | `inspect` | macOS `.app` 一屏摘要(bundle id、版本、沙盒、ATS、UTI 归属域) |
|
|
91
|
+
| `case_brief` | `export` | 写出脱敏的规格包(`spec.json` + `brief.md`) |
|
|
92
|
+
| `case_ingest` | `ingest` / `schema` | 按稳定契约摄入外部 agent 的报告(只记录、不背书);`schema` 打印契约 |
|
|
93
|
+
|
|
94
|
+
`case_project` 另有 `close`、`report`(`format: md / html / both`,默认脱敏)、`bundle`(机器可读、确定性)、`overview`、`archive`、`drop`(`dryRun` / `confirm`)、`trash`、`restore`、`purge`(`dryRun` / `confirm`)、`autonomy`(L0–L3 分级)。
|
|
95
|
+
|
|
96
|
+
**会话记忆:** 任何显式传入 `projectId` 的调用都会把它设为本会话的当前项目,且该指针会落盘——`case_project open` 传已有项目 id 时直接打开而不是报 `project-exists`;重启后同一会话继续调用工具不必重复传 `projectId`。若仍漏传,错误提示会带上「上次打开的项目」而不是只说失败。
|
|
67
97
|
|
|
68
98
|
所有工具统一返回 `{ ok, data?, error?{code,message,hint}, summary }`;错误带稳定 code,模型能自行纠正而不是猜。
|
|
69
99
|
|
|
100
|
+
**工具面代价:** 这 12 个工具的定义(`description` + `parameters` JSON)合计约 13.6 KB ≈ 3.4K tokens(按 ~4 B/token 估算),常驻每个会话,而真正用到 casefile 的会话是少数。这是有意的取舍(每个工具的 schema 都能自解释);如果之后要压缩,优先把低频的 `case_access` / `case_app` / `case_ingest` 并进一个 `case_misc`。
|
|
101
|
+
|
|
70
102
|
义务可以带 `featureIds`,这样**只复刻选定功能**时能报出每个功能的覆盖率:挂在某功能上的义务只计入该功能,未挂的只计入全局。
|
|
71
103
|
|
|
72
104
|
## Checker
|
|
@@ -111,50 +143,78 @@ casefile 自己不去抓任何内容。每条证据带一份 **`producer`** 记
|
|
|
111
143
|
|
|
112
144
|
```
|
|
113
145
|
casefile/
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
146
|
+
├── projects/<project-id>/
|
|
147
|
+
│ ├── project.json # version + 目标 + 授权档 + 范围 + REA 版本
|
|
148
|
+
│ ├── evidence.jsonl # append-only;同 id 后者胜
|
|
149
|
+
│ ├── claims.jsonl
|
|
150
|
+
│ ├── features.jsonl
|
|
151
|
+
│ ├── unknowns.jsonl
|
|
152
|
+
│ ├── audit.jsonl # 谁做了什么,append-only
|
|
153
|
+
│ ├── artifacts/ # 归档产物(有体积上限)
|
|
154
|
+
│ ├── checks/ # 验收运行记录
|
|
155
|
+
│ ├── spec/<时间戳>/ # 导出的 spec.json + brief.md
|
|
156
|
+
│ ├── reports/ # 导出的报告
|
|
157
|
+
│ └── bundles/ # 导出的 agent 环境包
|
|
158
|
+
├── trash/ # 被 drop 的项目,可恢复
|
|
159
|
+
├── audit.jsonl # 数据根审计(drop / restore / purge)
|
|
160
|
+
├── last-opened.json # 最近打开的项目(UI 便利)
|
|
161
|
+
├── session-pointers.json # 会话 → 项目指针
|
|
162
|
+
└── builder-sessions.jsonl # builder 会话(只读 guard 用)
|
|
122
163
|
```
|
|
123
164
|
|
|
124
165
|
规则:JSON 文件带 `version`;被更新版 casefile 写过的文件会报「只读」而不是被静默改写。坏 JSON 改名 `.broken` 保留。记录 append-only,项目目录可以 review、可以 diff。
|
|
125
166
|
|
|
126
167
|
## 配置
|
|
127
168
|
|
|
128
|
-
| 键 | 默认 | 含义
|
|
129
|
-
| ------------------ | --------------------- |
|
|
130
|
-
| `dataRoot` | `<DSH_HOME>/casefile` | 项目数据位置;测试可注入
|
|
131
|
-
| `defaultAuthTier` | `research` | 新项目默认授权档
|
|
132
|
-
| `cleanRoomDefault` | `true` | 预留给 builder 里程碑:builder 看不到原件
|
|
133
|
-
| `checkers` | `["cli","web"]` | 预留给验收里程碑
|
|
134
|
-
| `maxRounds` | `5` | 预留给循环
|
|
135
|
-
| `
|
|
169
|
+
| 键 | 默认 | 含义 |
|
|
170
|
+
| ------------------ | --------------------- | -------------------------------------------------------- |
|
|
171
|
+
| `dataRoot` | `<DSH_HOME>/casefile` | 项目数据位置;测试可注入 |
|
|
172
|
+
| `defaultAuthTier` | `research` | 新项目默认授权档 |
|
|
173
|
+
| `cleanRoomDefault` | `true` | 预留给 builder 里程碑:builder 看不到原件 |
|
|
174
|
+
| `checkers` | `["cli","web"]` | 预留给验收里程碑 |
|
|
175
|
+
| `maxRounds` | `5` | 预留给循环 |
|
|
176
|
+
| `maxArtifactBytes` | `67108864`(64 MiB) | 归档产物体积上限;超限直接拒绝(先 stat 预检,不读正文) |
|
|
136
177
|
|
|
137
178
|
配置写在 `cordis.patch.yml` 里 `casefile` 那一行的 `config:`,不要手改 profile。
|
|
138
179
|
|
|
139
180
|
## 兼容性
|
|
140
181
|
|
|
141
|
-
| 插件
|
|
142
|
-
|
|
|
143
|
-
| 0.1.x–0.2.x
|
|
144
|
-
| 0.3.x–0.5.x
|
|
182
|
+
| 插件 | 已在哪个 DSH 上验证 | 跑了什么 |
|
|
183
|
+
| --------------- | --------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
184
|
+
| 0.1.x–0.2.x | 0.2.2-rc.3(macOS,桌面版 + web) | 138 → 177 项单元测试;临时 DSH_HOME 上 52 项 web 端到端冒烟;**真实 Electron 渲染进程上 14 项桌面只读回归(CDP)**;`pnpm gate casefile` 4/4 步全绿。 |
|
|
185
|
+
| 0.3.x–0.5.x | 同上 | 172 → 177 项单元测试;新增 `case_access`(等登录)、`case_app`(应用包第一跳)、产物归档、项目 `archive`/`drop`;**在 8 个真实项目上跑通**(含本机 macOS 应用、登录态网页、外部采集器摄入)。 |
|
|
186
|
+
| **0.6.x–0.8.x** | 同上 | 216 项单元测试;**56 项 web 端到端**(新增外部报告摄入 dryRun/真摄入断言);**15 项桌面只读回归**(新增自主性徽章断言);`pnpm gate casefile` 4/4 全绿。新增:HTML 报告、机器可读 bundle、L3 无人值守、外部报告摄入契约(含 Craft 形状自动映射)、空白截图防护。 |
|
|
187
|
+
| 0.8.1 | 0.2.2-rc.5(macOS,桌面版 + web) | 这一版 DSH 不需要改代码。216 项单元测试;**56 项 web 端到端冒烟**;**15 项桌面只读回归(连跑 2 次,幂等)**;`pnpm gate casefile` 4/4 全绿,并已跑过 **`pnpm gate:all --repeat 2`**(六插件 631s 全绿)。本版的 43 包宿主 diff([runtime rc.5](../../docs/runtime/0.2.2-rc.5.md))里,本插件用到的宿主 API 一个都没动。 |
|
|
145
188
|
|
|
146
189
|
本插件用到的宿主 API 都经过运行时勘察,结论记在 `docs/runtime/0.2.2-rc.3.md` §10(含两个坑:漏一条 `declareRemote` 只会让那一个端点静默 404;`agentPresets` 不能用 bundle 名组合)。
|
|
147
190
|
|
|
148
|
-
|
|
191
|
+
真实任务里验证过的**五类**目标(含本机 Electron 应用):**本机 macOS 应用包**(Info.plist/签名面/二进制库存,二进制层需 REA + Ghidra,见 `docs/runtime/0.2.2-rc.3.md` §13–§14)、**登录态网页**(`case_access await-login` + 只取结构)、**外部采集器产物**(`producer` + `artifactPath` 归档)、**应用自身发布包**(mas 包勘察 → 规格 → 验收闭环)。
|
|
149
192
|
|
|
150
193
|
## 副作用与风险
|
|
151
194
|
|
|
152
195
|
- **写哪些文件:** 只写上面的数据根。不写被调查的项目、不改 REA 二进制、不编辑 profile。
|
|
153
|
-
- **破坏性操作:**
|
|
154
|
-
- **隐私:**
|
|
196
|
+
- **破坏性操作:** 遵循仓库 [ADR 0002](https://github.com/kangyishuai/dsh-plugins/blob/main/docs/adr/0002-destructive-operations.md)。`case_project drop` 把整个项目目录移进 `<dataRoot>/trash/<时间戳>-<id>`(可恢复),必须传 `confirm: true`,支持 `dryRun` 并给出条目数/体积/目标路径,同时写数据根审计。工具契约明确要求 agent **只能在用户明确同意后**调用;工作台给用户自己的同一动作放在「危险操作」里,先预览影响面再确认。注意:在 `danger-full-access` / `approval: never` 权限档下宿主不会为这个工具加审批弹窗——完全权限会话被视为可信执行者,因此这条同意要求是文档约束,而不是宿主强制。回收站可查看、可恢复、可清空(`case_project purge`,`dryRun` + `confirm`;回收站里来历不明的条目保留并计数,绝不 `rm -rf`)。没有显式确认就不会硬删任何东西。
|
|
197
|
+
- **隐私:** 项目数据只在本机。规格包、bundle 与报告默认脱敏(系统根目录路径、`~/…`、扩展路径,以及上面列出的 token 形态),但**分享前仍应自己过一遍**——脱敏是安全网,不是保证。
|
|
155
198
|
- **证据质量:** casefile 只存你告诉它的东西。它不验证观察,也从不提升结论的可信度或权威性。
|
|
156
199
|
- **法务:** 面向研究与「你拥有或已获授权分析」的软件。刻意**不提供** DRM/反调试绕过,也不提供复用第三方资产的途径。使用前读 [DISCLAIMER.md](./DISCLAIMER.md)。
|
|
157
200
|
|
|
201
|
+
## 卸载后残留
|
|
202
|
+
|
|
203
|
+
卸载插件**不会删任何数据**:宿主只移除包本身。案卷仍留在数据根下(默认 `<DSH_HOME>/casefile`,见[数据布局](#数据布局)):
|
|
204
|
+
|
|
205
|
+
- `projects/<id>/` —— 项目记录,以及 `artifacts/`、`spec/`、`reports/`、`bundles/`、`checks/`;
|
|
206
|
+
- `trash/` —— 被 `case_project drop` 移进回收站的项目(重装后仍可恢复);
|
|
207
|
+
- `audit.jsonl`、`last-opened.json`、`session-pointers.json`、`builder-sessions.jsonl` —— 数据根审计、最近打开指针、会话 → 项目指针,以及只读 guard 用的 builder 会话记录。
|
|
208
|
+
|
|
209
|
+
数据不上传,卸载时也不清理——这是有意的,重装后证据还在。要手工删除(先确认已经导出需要的东西):
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
du -sh "$DSH_HOME/casefile" # 先看体积
|
|
213
|
+
rm -rf "$DSH_HOME/casefile" # 改过 dataRoot 的话换成你自己的路径
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
导出的规格包、报告和 bundle 都在项目目录**里面**(`spec/`、`reports/`、`bundles/`),会随目录一起删掉;需要的话先拷出来。
|
|
217
|
+
|
|
158
218
|
## 开发
|
|
159
219
|
|
|
160
220
|
```bash
|