dsh-clear-debug 0.0.0-stage → 0.1.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.
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Per-file history of attributions.
3
+ *
4
+ * Keyed by file rather than file:line: line numbers drift with every edit,
5
+ * files do not. The record is what a later session needs most — this file has
6
+ * been blamed before, and here is what was already ruled out.
7
+ */
8
+
9
+ import { promises as fsp } from 'node:fs';
10
+ import { join } from 'node:path';
11
+
12
+ const STORE = '.dsh/site-history.json';
13
+ const KEEP = 20;
14
+
15
+ export function fileOf(site) {
16
+ return String(site ?? '').replace(/:\d+$/, '').trim().toLowerCase();
17
+ }
18
+
19
+ async function readAll(root) {
20
+ try {
21
+ const parsed = JSON.parse(await fsp.readFile(join(root, STORE), 'utf8'));
22
+ return parsed && typeof parsed === 'object' && !Array.isArray(parsed) ? parsed : {};
23
+ } catch {
24
+ return {};
25
+ }
26
+ }
27
+
28
+ async function writeAll(root, all) {
29
+ await fsp.mkdir(join(root, '.dsh'), { recursive: true });
30
+ await fsp.writeFile(join(root, STORE), `${JSON.stringify(all, null, 2)}\n`, 'utf8');
31
+ }
32
+
33
+ function bucket(all, file) {
34
+ if (!all[file]) all[file] = { file, attributed: 0, refuted: [], fixed: [] };
35
+ return all[file];
36
+ }
37
+
38
+ export async function recordFixed(root, site, record) {
39
+ if (!root || !site) return null;
40
+ const all = await readAll(root);
41
+ const entry = bucket(all, fileOf(site));
42
+ entry.attributed += 1;
43
+ entry.fixed.push({ at: Date.now(), ...record });
44
+ entry.fixed = entry.fixed.slice(-KEEP);
45
+ await writeAll(root, all);
46
+ return entry;
47
+ }
48
+
49
+ export async function recordRefuted(root, site, record) {
50
+ if (!root || !site) return null;
51
+ const all = await readAll(root);
52
+ const entry = bucket(all, fileOf(site));
53
+ entry.refuted.push({ at: Date.now(), ...record });
54
+ entry.refuted = entry.refuted.slice(-KEEP);
55
+ await writeAll(root, all);
56
+ return entry;
57
+ }
58
+
59
+ export async function siteHistory(root, site) {
60
+ if (!root || !site) return null;
61
+ const all = await readAll(root);
62
+ return all[fileOf(site)] ?? null;
63
+ }
package/locale/en.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "meta": {
3
+ "title": "Change scope",
4
+ "description": "Records the authorized scope of a bug fix or rewrite before editing, blocks edits outside that scope, and sediments one invariant per completed fix.",
5
+ "detail": "docs/DETAIL.md"
6
+ }
7
+ }
package/locale/zh.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "meta": {
3
+ "title": "变更范围",
4
+ "description": "在改代码之前登记本次修复或重写的授权范围,拦截范围外的编辑,并在每次修复完成时沉淀一条不变量。",
5
+ "detail": "docs/DETAIL.md"
6
+ }
7
+ }
package/package.json CHANGED
@@ -1,6 +1,59 @@
1
1
  {
2
2
  "name": "dsh-clear-debug",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "Declare the scope of a change before editing, enforce it, verify the result against the log, and record one executable invariant per fix.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/high-landway/dsh-clear-debug.git"
10
+ },
11
+ "homepage": "https://github.com/high-landway/dsh-clear-debug#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/high-landway/dsh-clear-debug/issues"
14
+ },
15
+ "keywords": [
16
+ "deepseek",
17
+ "dsh",
18
+ "dsh-plugin",
19
+ "debugging",
20
+ "root-cause",
21
+ "code-review"
22
+ ],
23
+ "exports": {
24
+ ".": "./index.js",
25
+ "./locale/*.json": "./locale/*.json",
26
+ "./icon": "./icon.svg"
27
+ },
28
+ "files": [
29
+ "index.js",
30
+ "lib",
31
+ "cordis.patch.yml",
32
+ "locale/*.json",
33
+ "docs/DETAIL.md",
34
+ "icon.svg",
35
+ "README.md",
36
+ "LICENSE"
37
+ ],
38
+ "dsh": {
39
+ "bundle": {
40
+ "patch": "./cordis.patch.yml"
41
+ }
42
+ },
43
+ "peerDependencies": {
44
+ "@deepseek-ai/cosmokit": "~1.9.0",
45
+ "@deepseek-ai/schemastery": "~3.19.0"
46
+ },
47
+ "peerDependenciesMeta": {
48
+ "@deepseek-ai/cosmokit": {
49
+ "optional": true
50
+ },
51
+ "@deepseek-ai/schemastery": {
52
+ "optional": true
53
+ }
54
+ },
55
+ "devDependencies": {
56
+ "@deepseek-ai/cosmokit": "~1.9.0",
57
+ "@deepseek-ai/schemastery": "~3.19.0"
58
+ }
6
59
  }