dsh-permission-rules 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/CHANGELOG.md +50 -0
- package/LICENSE +201 -0
- package/README.es.md +182 -0
- package/README.hi.md +182 -0
- package/README.md +182 -0
- package/README.pt.md +182 -0
- package/README.zh.md +182 -0
- package/cordis.patch.yml +16 -0
- package/docs/rules-format.en.md +105 -0
- package/docs/rules-format.md +103 -0
- package/docs/rules-format.schema.json +117 -0
- package/lib/index.js +1606 -0
- package/lib/types/config.d.ts +83 -0
- package/lib/types/config.d.ts.map +1 -0
- package/lib/types/config.js +72 -0
- package/lib/types/config.js.map +1 -0
- package/lib/types/events.d.ts +68 -0
- package/lib/types/events.d.ts.map +1 -0
- package/lib/types/events.js +21 -0
- package/lib/types/events.js.map +1 -0
- package/lib/types/glob.d.ts +55 -0
- package/lib/types/glob.d.ts.map +1 -0
- package/lib/types/glob.js +307 -0
- package/lib/types/glob.js.map +1 -0
- package/lib/types/index.d.ts +25 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/index.js +25 -0
- package/lib/types/index.js.map +1 -0
- package/lib/types/prose.d.ts +66 -0
- package/lib/types/prose.d.ts.map +1 -0
- package/lib/types/prose.js +143 -0
- package/lib/types/prose.js.map +1 -0
- package/lib/types/rules.d.ts +226 -0
- package/lib/types/rules.d.ts.map +1 -0
- package/lib/types/rules.js +581 -0
- package/lib/types/rules.js.map +1 -0
- package/lib/types/runtime.d.ts +175 -0
- package/lib/types/runtime.d.ts.map +1 -0
- package/lib/types/runtime.js +497 -0
- package/lib/types/runtime.js.map +1 -0
- package/package.json +103 -0
- package/scripts/repair-session-logs.mjs +327 -0
- package/src/config.ts +141 -0
- package/src/events.ts +75 -0
- package/src/glob.ts +303 -0
- package/src/index.ts +27 -0
- package/src/prose.ts +206 -0
- package/src/rules.ts +695 -0
- package/src/runtime.ts +504 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version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AI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;IAChC,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CAAC,GAAY,EAAE,MAAc;IAChD,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,CAAC,CAAA;IACtC,MAAM,OAAO,GAAG,IAAI,sBAAsB,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;IACzD,OAAO,CAAC,uBAAuB,EAAE,CAAA;IACjC,GAAG,CAAC,OAAO,CAAC,wBAAwB,EAAE,OAAO,CAAC,CAAA;IAC9C,GAAG,CAAC,EAAE,CAAC,mBAAmB,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;IAC3E,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC;QACpB,IAAI,EAAE,OAAO;QACb,WAAW,EAAE,iFAAiF;QAC9F,KAAK,EAAE,EAAE,IAAI,EAAE,oDAAoD,EAAE;QACrE,OAAO,EAAE,UAAU,CAAC,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC;KACnD,CAAC,CAAA;AACJ,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "dsh-permission-rules",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Declarative Claude Code-style permission rules for DeepSeek Harness: ordered allow/deny/ask rules with tool-name, argument (glob/regex), and workspace-path matching on the tools/pre-execute waterfall, full session-log audit, and HMR rule reload.",
|
|
5
|
+
"private": false,
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./lib/index.js",
|
|
8
|
+
"types": "./lib/types/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./lib/types/index.d.ts",
|
|
12
|
+
"default": "./lib/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./package.json": "./package.json"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"lib",
|
|
18
|
+
"src",
|
|
19
|
+
"cordis.patch.yml",
|
|
20
|
+
"docs",
|
|
21
|
+
"scripts/repair-session-logs.mjs",
|
|
22
|
+
"README.md",
|
|
23
|
+
"README.zh.md",
|
|
24
|
+
"README.es.md",
|
|
25
|
+
"README.pt.md",
|
|
26
|
+
"README.hi.md",
|
|
27
|
+
"CHANGELOG.md",
|
|
28
|
+
"LICENSE"
|
|
29
|
+
],
|
|
30
|
+
"sideEffects": false,
|
|
31
|
+
"dsh": {
|
|
32
|
+
"bundle": {
|
|
33
|
+
"patch": "./cordis.patch.yml"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"keywords": [
|
|
37
|
+
"dsh",
|
|
38
|
+
"dsh-plugin",
|
|
39
|
+
"deepseek-harness",
|
|
40
|
+
"permission",
|
|
41
|
+
"policy",
|
|
42
|
+
"allow-deny-ask",
|
|
43
|
+
"approval",
|
|
44
|
+
"safety"
|
|
45
|
+
],
|
|
46
|
+
"author": "dsh-permission-rules contributors",
|
|
47
|
+
"repository": {
|
|
48
|
+
"type": "git",
|
|
49
|
+
"url": "git+https://github.com/PerryLink/dsh-permission-rules.git"
|
|
50
|
+
},
|
|
51
|
+
"homepage": "https://github.com/PerryLink/dsh-permission-rules#readme",
|
|
52
|
+
"bugs": {
|
|
53
|
+
"url": "https://github.com/PerryLink/dsh-permission-rules/issues"
|
|
54
|
+
},
|
|
55
|
+
"engines": {
|
|
56
|
+
"node": "^22.19.0 || >=24.0.0"
|
|
57
|
+
},
|
|
58
|
+
"peerDependencies": {
|
|
59
|
+
"@deepseek-ai/cordis": "^4.0.1",
|
|
60
|
+
"@deepseek-ai/dsh-agent": "0.1.0-rc.6",
|
|
61
|
+
"@deepseek-ai/dsh-commands": "0.1.0-rc.6",
|
|
62
|
+
"@deepseek-ai/dsh-llm": "0.1.0-rc.6",
|
|
63
|
+
"@deepseek-ai/dsh-session": "0.1.0-rc.6",
|
|
64
|
+
"@deepseek-ai/dsh-tools": "0.1.0-rc.6",
|
|
65
|
+
"@deepseek-ai/schemastery": "^3.18.0"
|
|
66
|
+
},
|
|
67
|
+
"dependencies": {
|
|
68
|
+
"chokidar": "^5.0.0",
|
|
69
|
+
"tsdown": "^0.22.14",
|
|
70
|
+
"typescript": "^5.9.0",
|
|
71
|
+
"yaml": "^2.8.0"
|
|
72
|
+
},
|
|
73
|
+
"devDependencies": {
|
|
74
|
+
"@deepseek-ai/cordis": "^4.0.1",
|
|
75
|
+
"@deepseek-ai/dsh-agent": "0.1.0-rc.6",
|
|
76
|
+
"@deepseek-ai/dsh-commands": "0.1.0-rc.6",
|
|
77
|
+
"@deepseek-ai/dsh-llm": "0.1.0-rc.6",
|
|
78
|
+
"@deepseek-ai/dsh-session": "0.1.0-rc.6",
|
|
79
|
+
"@deepseek-ai/dsh-subagent": "0.1.0-rc.6",
|
|
80
|
+
"@deepseek-ai/dsh-tools": "0.1.0-rc.6",
|
|
81
|
+
"@deepseek-ai/dsh-user-approval": "0.1.0-rc.6",
|
|
82
|
+
"@deepseek-ai/schemastery": "^3.18.0",
|
|
83
|
+
"@eslint/js": "^10.0.1",
|
|
84
|
+
"@types/node": "^22.19.0",
|
|
85
|
+
"@vitest/coverage-v8": "^3.2.0",
|
|
86
|
+
"dsh-auto-review": "file:vendor/dsh-auto-review-0.3.0.tgz",
|
|
87
|
+
"eslint": "^10.8.1",
|
|
88
|
+
"globals": "^17.11.0",
|
|
89
|
+
"typescript-eslint": "^8.67.0",
|
|
90
|
+
"vitest": "^3.2.0"
|
|
91
|
+
},
|
|
92
|
+
"scripts": {
|
|
93
|
+
"build": "node scripts/prepare.mjs",
|
|
94
|
+
"typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.test.json --noEmit",
|
|
95
|
+
"lint": "eslint src test scripts",
|
|
96
|
+
"test": "vitest run",
|
|
97
|
+
"test:coverage": "vitest run --coverage",
|
|
98
|
+
"pack:check": "node scripts/prepare.mjs && pnpm pack",
|
|
99
|
+
"prepare": "node scripts/prepare.mjs"
|
|
100
|
+
},
|
|
101
|
+
"packageManager": "pnpm@11.7.0",
|
|
102
|
+
"license": "Apache-2.0"
|
|
103
|
+
}
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Repair DSH JSONL session logs that were written before `Session.append`
|
|
3
|
+
* exposed the `ignorable` envelope marker. Out-of-repo plugin events
|
|
4
|
+
* (`permissionRules/decision`, `autoReview/verdict`, `autoReview/state`) were
|
|
5
|
+
* appended unmarked, so the persistence read path refuses those logs with
|
|
6
|
+
* `SessionFormatUnsupportedError` ("unknown to this harness and not marked
|
|
7
|
+
* ignorable").
|
|
8
|
+
*
|
|
9
|
+
* This script rewrites ONLY the targeted log-only audit rows, adding
|
|
10
|
+
* `ignorable: true` to their envelopes; every other byte is preserved. Each
|
|
11
|
+
* modified artifact is backed up to `<file>.bak-<epoch>` before replacement.
|
|
12
|
+
*
|
|
13
|
+
* It understands both physical encodings of the JSONL backend:
|
|
14
|
+
* - `session.jsonl.zstd` — a concatenation of checksummed Zstandard frames
|
|
15
|
+
* (frame 1 = header line, later frames = durable append batches); each
|
|
16
|
+
* frame is decompressed, filtered, and recompressed independently so
|
|
17
|
+
* frame boundaries survive.
|
|
18
|
+
* - `session.jsonl` — plaintext JSONL lines.
|
|
19
|
+
*
|
|
20
|
+
* Usage:
|
|
21
|
+
* node scripts/repair-session-logs.mjs scan [--home DIR] # report foreign rows, change nothing
|
|
22
|
+
* node scripts/repair-session-logs.mjs repair [--home DIR] [--dry-run]
|
|
23
|
+
* node scripts/repair-session-logs.mjs repair --types a/b,c/d
|
|
24
|
+
*
|
|
25
|
+
* `--home` defaults to `$env:DSH_HOME/sessions` or `~/.dsh/sessions`.
|
|
26
|
+
* The default target set is the log-only audit vocabulary owned by the
|
|
27
|
+
* dsh-permission-rules / dsh-auto-review plugins; only types you understand
|
|
28
|
+
* to be reconstruction-safe may be added via `--types`.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
import { constants, zstdCompressSync, zstdDecompressSync } from 'node:zlib'
|
|
32
|
+
import { existsSync, readdirSync, readFileSync, renameSync, statSync, writeFileSync } from 'node:fs'
|
|
33
|
+
import { homedir } from 'node:os'
|
|
34
|
+
import { join, resolve } from 'node:path'
|
|
35
|
+
|
|
36
|
+
const ZSTD_MAGIC = 0xfd2fb528
|
|
37
|
+
const CHECKSUM_OPTIONS = { params: { [constants.ZSTD_c_checksumFlag]: 1 } }
|
|
38
|
+
|
|
39
|
+
const DEFAULT_TARGET_TYPES = [
|
|
40
|
+
'permissionRules/decision',
|
|
41
|
+
'autoReview/verdict',
|
|
42
|
+
'autoReview/state',
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
/** Row types that are storage records, never session events (leave untouched). */
|
|
46
|
+
const STORAGE_ROW_TYPES = new Set([
|
|
47
|
+
'text-chunks',
|
|
48
|
+
'reasoning-chunks',
|
|
49
|
+
'tool-call-chunks',
|
|
50
|
+
])
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The harness build's generated event vocabulary
|
|
54
|
+
* (`KNOWN_SESSION_EVENT_TYPES`, `packages/core/session/src/known-event-types.ts`).
|
|
55
|
+
* Rows whose type is outside this set are what the read path refuses when the
|
|
56
|
+
* envelope lacks `ignorable: true`; the scan reports them so nothing is missed.
|
|
57
|
+
* Regenerate this list from the harness checkout when it changes.
|
|
58
|
+
*/
|
|
59
|
+
const KNOWN_SESSION_EVENT_TYPES = new Set([
|
|
60
|
+
'agent-preset/selected',
|
|
61
|
+
'agent/inbox/spliced',
|
|
62
|
+
'approval/asked',
|
|
63
|
+
'approval/decided',
|
|
64
|
+
'approval/policy',
|
|
65
|
+
'assistant/chunk',
|
|
66
|
+
'assistant/message',
|
|
67
|
+
'command/done',
|
|
68
|
+
'command/run',
|
|
69
|
+
'compaction/end',
|
|
70
|
+
'compaction/prune',
|
|
71
|
+
'compaction/start',
|
|
72
|
+
'compaction/summary',
|
|
73
|
+
'feedback/record',
|
|
74
|
+
'goal/change',
|
|
75
|
+
'hook/invoked',
|
|
76
|
+
'hook/result',
|
|
77
|
+
'llm/retry',
|
|
78
|
+
'llm/retry-started',
|
|
79
|
+
'permission/preset',
|
|
80
|
+
'plan/mode',
|
|
81
|
+
'request/context',
|
|
82
|
+
'request/header',
|
|
83
|
+
'sandbox/mode',
|
|
84
|
+
'schedule/change',
|
|
85
|
+
'session/end-seed',
|
|
86
|
+
'session/title',
|
|
87
|
+
'session/title-llm-request',
|
|
88
|
+
'step/end',
|
|
89
|
+
'step/start',
|
|
90
|
+
'subagent/descriptor',
|
|
91
|
+
'todo/write',
|
|
92
|
+
'tool-workflow/agent-end',
|
|
93
|
+
'tool-workflow/agent-start',
|
|
94
|
+
'tool-workflow/run-end',
|
|
95
|
+
'tool-workflow/run-start',
|
|
96
|
+
'tool/call',
|
|
97
|
+
'tool/code-dispatch',
|
|
98
|
+
'tool/code-dispatch-start',
|
|
99
|
+
'tool/result',
|
|
100
|
+
'turn/end',
|
|
101
|
+
'turn/start',
|
|
102
|
+
'user/message',
|
|
103
|
+
'web/deepseek-search-llm-request',
|
|
104
|
+
])
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Locate complete Zstandard frame ranges in a concatenated stream, mirroring
|
|
108
|
+
* the JSONL backend's structural scan. Throws on corrupt structure; a trailing
|
|
109
|
+
* incomplete frame is reported as `tornStart` and skipped.
|
|
110
|
+
* @param {Buffer} buffer - the raw artifact bytes.
|
|
111
|
+
* @returns {{ frames: {start:number,end:number}[], tornStart?: number }}
|
|
112
|
+
*/
|
|
113
|
+
function scanZstdFrames(buffer) {
|
|
114
|
+
const frames = []
|
|
115
|
+
let offset = 0
|
|
116
|
+
while (offset < buffer.length) {
|
|
117
|
+
const start = offset
|
|
118
|
+
if (buffer.length - offset < 4) return { frames, tornStart: start }
|
|
119
|
+
if (buffer.readUInt32LE(offset) !== ZSTD_MAGIC) {
|
|
120
|
+
throw new Error(`corrupt Zstandard stream: invalid frame magic at byte ${offset}`)
|
|
121
|
+
}
|
|
122
|
+
offset += 4
|
|
123
|
+
if (offset === buffer.length) return { frames, tornStart: start }
|
|
124
|
+
const descriptor = buffer.readUInt8(offset)
|
|
125
|
+
offset += 1
|
|
126
|
+
if ((descriptor & 0x18) !== 0) {
|
|
127
|
+
throw new Error(`corrupt Zstandard stream: reserved frame-header bit at byte ${offset - 1}`)
|
|
128
|
+
}
|
|
129
|
+
const contentSizeFlag = descriptor >>> 6
|
|
130
|
+
const singleSegment = (descriptor & 0x20) !== 0
|
|
131
|
+
const dictionaryFlag = descriptor & 0x03
|
|
132
|
+
const dictionaryBytes = dictionaryFlag === 3 ? 4 : dictionaryFlag
|
|
133
|
+
const contentSizeBytes = contentSizeFlag === 0 ? (singleSegment ? 1 : 0) : 1 << contentSizeFlag
|
|
134
|
+
const remainingHeaderBytes = (singleSegment ? 0 : 1) + dictionaryBytes + contentSizeBytes
|
|
135
|
+
if (buffer.length - offset < remainingHeaderBytes) return { frames, tornStart: start }
|
|
136
|
+
offset += remainingHeaderBytes
|
|
137
|
+
for (;;) {
|
|
138
|
+
if (buffer.length - offset < 3) return { frames, tornStart: start }
|
|
139
|
+
const blockHeader = buffer.readUIntLE(offset, 3)
|
|
140
|
+
offset += 3
|
|
141
|
+
const lastBlock = (blockHeader & 1) !== 0
|
|
142
|
+
const blockType = (blockHeader >>> 1) & 0x03
|
|
143
|
+
const blockSize = blockHeader >>> 3
|
|
144
|
+
if (blockType === 0x03) {
|
|
145
|
+
throw new Error(`corrupt Zstandard stream: reserved block type at byte ${offset - 3}`)
|
|
146
|
+
}
|
|
147
|
+
const payloadBytes = blockType === 0x01 ? 1 : blockSize
|
|
148
|
+
if (buffer.length - offset < payloadBytes) return { frames, tornStart: start }
|
|
149
|
+
offset += payloadBytes
|
|
150
|
+
if (lastBlock) break
|
|
151
|
+
}
|
|
152
|
+
if ((descriptor & 0x04) !== 0) {
|
|
153
|
+
if (buffer.length - offset < 4) return { frames, tornStart: start }
|
|
154
|
+
offset += 4
|
|
155
|
+
}
|
|
156
|
+
frames.push({ start, end: offset })
|
|
157
|
+
}
|
|
158
|
+
return { frames }
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** Split decompressed text into final-newline-terminated lines. */
|
|
162
|
+
function splitLines(text) {
|
|
163
|
+
const lines = text.split('\n')
|
|
164
|
+
if (lines.at(-1) === '') lines.pop()
|
|
165
|
+
return lines
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Apply the ignorable marker to targeted audit rows in one JSONL frame.
|
|
170
|
+
* @param {string} text - the frame plaintext.
|
|
171
|
+
* @param {Set<string>} targetTypes - event types to mark.
|
|
172
|
+
* @param {Map<string, number>} foreignSeen - scan accumulator: type -> row count.
|
|
173
|
+
* @returns {{ text: string, changed: number }}
|
|
174
|
+
*/
|
|
175
|
+
function filterFrame(text, targetTypes, foreignSeen) {
|
|
176
|
+
const lines = splitLines(text)
|
|
177
|
+
let changed = 0
|
|
178
|
+
const out = lines.map(line => {
|
|
179
|
+
if (line.length === 0) return line
|
|
180
|
+
let row
|
|
181
|
+
try {
|
|
182
|
+
row = JSON.parse(line)
|
|
183
|
+
} catch {
|
|
184
|
+
return line // preserve unparsable bytes exactly; the reader owns the refusal
|
|
185
|
+
}
|
|
186
|
+
if (typeof row !== 'object' || row === null) return line
|
|
187
|
+
const type = row.type
|
|
188
|
+
if (typeof type !== 'string' || STORAGE_ROW_TYPES.has(type)) return line
|
|
189
|
+
if (type === 'session') return line // header row: never an event
|
|
190
|
+
if (!KNOWN_SESSION_EVENT_TYPES.has(type)) {
|
|
191
|
+
foreignSeen.set(type, (foreignSeen.get(type) ?? 0) + 1)
|
|
192
|
+
}
|
|
193
|
+
if (targetTypes.has(type)) {
|
|
194
|
+
if (row.ignorable === true) return line
|
|
195
|
+
row.ignorable = true
|
|
196
|
+
changed += 1
|
|
197
|
+
return JSON.stringify(row)
|
|
198
|
+
}
|
|
199
|
+
return line
|
|
200
|
+
})
|
|
201
|
+
return { text: out.join('\n') + '\n', changed }
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/** Find every session artifact under a sessions root. */
|
|
205
|
+
function findLogs(root) {
|
|
206
|
+
const found = []
|
|
207
|
+
const walk = dir => {
|
|
208
|
+
for (const entry of readdirSync(dir)) {
|
|
209
|
+
const full = join(dir, entry)
|
|
210
|
+
const stat = statSync(full)
|
|
211
|
+
if (stat.isDirectory()) walk(full)
|
|
212
|
+
else if (entry === 'session.jsonl' || entry === 'session.jsonl.zstd') found.push(full)
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
walk(root)
|
|
216
|
+
return found
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/** Read a log into { headerFrame, frames: [{text, start, end}] }. */
|
|
220
|
+
function readLog(path) {
|
|
221
|
+
const buffer = readFileSync(path)
|
|
222
|
+
if (path.endsWith('.zstd')) {
|
|
223
|
+
const { frames, tornStart } = scanZstdFrames(buffer)
|
|
224
|
+
if (frames.length === 0) throw new Error(`${path}: no complete Zstandard frame`)
|
|
225
|
+
return {
|
|
226
|
+
compressed: true,
|
|
227
|
+
frames: frames.map(range => ({
|
|
228
|
+
...range,
|
|
229
|
+
text: zstdDecompressSync(buffer.subarray(range.start, range.end)).toString('utf8'),
|
|
230
|
+
})),
|
|
231
|
+
tornStart,
|
|
232
|
+
buffer,
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return {
|
|
236
|
+
compressed: false,
|
|
237
|
+
frames: [{ start: 0, end: buffer.length, text: buffer.toString('utf8') }],
|
|
238
|
+
tornStart: undefined,
|
|
239
|
+
buffer,
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function parseArgs(argv) {
|
|
244
|
+
const args = { mode: undefined, home: undefined, dryRun: false, types: DEFAULT_TARGET_TYPES }
|
|
245
|
+
for (let i = 0; i < argv.length; i++) {
|
|
246
|
+
const arg = argv[i]
|
|
247
|
+
if (arg === 'scan' || arg === 'repair') args.mode = arg
|
|
248
|
+
else if (arg === '--home') args.home = argv[++i]
|
|
249
|
+
else if (arg === '--dry-run') args.dryRun = true
|
|
250
|
+
else if (arg === '--types') args.types = argv[++i].split(',')
|
|
251
|
+
}
|
|
252
|
+
return args
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function usage() {
|
|
256
|
+
console.error('usage: node repair-session-logs.mjs scan|repair [--home DIR] [--dry-run] [--types a/b,c/d]')
|
|
257
|
+
process.exit(2)
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
const args = parseArgs(process.argv.slice(2))
|
|
261
|
+
if (args.mode === undefined) usage()
|
|
262
|
+
const home = args.home ?? process.env.DSH_HOME
|
|
263
|
+
const root = home !== undefined ? resolve(home, 'sessions') : join(homedir(), '.dsh', 'sessions')
|
|
264
|
+
if (!existsSync(root)) {
|
|
265
|
+
console.error(`sessions root not found: ${root}`)
|
|
266
|
+
process.exit(1)
|
|
267
|
+
}
|
|
268
|
+
const targetTypes = new Set(args.types)
|
|
269
|
+
|
|
270
|
+
const logs = findLogs(root)
|
|
271
|
+
if (logs.length === 0) {
|
|
272
|
+
console.log(`no session logs found under ${root}`)
|
|
273
|
+
process.exit(0)
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
let scanned = 0
|
|
277
|
+
let affectedFiles = 0
|
|
278
|
+
let marked = 0
|
|
279
|
+
const foreignSeen = new Map()
|
|
280
|
+
const failures = []
|
|
281
|
+
|
|
282
|
+
for (const path of logs) {
|
|
283
|
+
let log
|
|
284
|
+
try {
|
|
285
|
+
log = readLog(path)
|
|
286
|
+
} catch (error) {
|
|
287
|
+
failures.push(`${path}: ${error.message}`)
|
|
288
|
+
continue
|
|
289
|
+
}
|
|
290
|
+
if (log.tornStart !== undefined) {
|
|
291
|
+
console.warn(`warn: ${path} ends in a torn Zstandard frame at byte ${log.tornStart}; trailing bytes are left untouched`)
|
|
292
|
+
}
|
|
293
|
+
let fileChanged = 0
|
|
294
|
+
const newFrames = []
|
|
295
|
+
for (const frame of log.frames) {
|
|
296
|
+
const { text, changed } = filterFrame(frame.text, targetTypes, foreignSeen)
|
|
297
|
+
newFrames.push({ ...frame, text })
|
|
298
|
+
fileChanged += changed
|
|
299
|
+
}
|
|
300
|
+
scanned += 1
|
|
301
|
+
if (fileChanged > 0) {
|
|
302
|
+
affectedFiles += 1
|
|
303
|
+
marked += fileChanged
|
|
304
|
+
if (args.mode === 'repair' && !args.dryRun) {
|
|
305
|
+
const backup = `${path}.bak-${Date.now()}`
|
|
306
|
+
renameSync(path, backup)
|
|
307
|
+
const content = log.compressed
|
|
308
|
+
? Buffer.concat(newFrames.map(frame => zstdCompressSync(frame.text, CHECKSUM_OPTIONS)))
|
|
309
|
+
: Buffer.from(newFrames[0].text, 'utf8')
|
|
310
|
+
writeFileSync(path, content)
|
|
311
|
+
console.log(`repaired ${path} (${fileChanged} row(s) marked ignorable; backup: ${backup})`)
|
|
312
|
+
} else {
|
|
313
|
+
console.log(`${args.dryRun ? '[dry-run] would repair' : 'would repair'} ${path}: ${fileChanged} row(s)`)
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
if (foreignSeen.size > 0) {
|
|
319
|
+
console.log('\nforeign (non-harness) event rows found by type:')
|
|
320
|
+
for (const [type, count] of [...foreignSeen.entries()].sort()) {
|
|
321
|
+
const action = targetTypes.has(type) ? 'targeted for ignorable repair' : 'NOT targeted — investigate before touching'
|
|
322
|
+
console.log(` ${type}: ${count} rows (${action})`)
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
for (const failure of failures) console.error(`error: ${failure}`)
|
|
326
|
+
console.log(`\n${scanned} log(s) scanned, ${affectedFiles} affected, ${marked} row(s) would be marked${args.mode === 'repair' && !args.dryRun ? ' (repaired)' : ''}`)
|
|
327
|
+
process.exit(failures.length > 0 ? 1 : 0)
|
package/src/config.ts
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Config schema and resolution for `dsh-permission-rules`. Every tunable is
|
|
3
|
+
* a validated {@link Config} field changeable from cordis.yml; the
|
|
4
|
+
* resolution step validates the numeric bounds and compiles nothing — rule
|
|
5
|
+
* files are external documents resolved per session cwd at load time.
|
|
6
|
+
* @module dsh-permission-rules/config
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { isAbsolute } from 'node:path'
|
|
10
|
+
import z from '@deepseek-ai/schemastery'
|
|
11
|
+
import type { PatternMode } from './rules.ts'
|
|
12
|
+
import type { UiLanguage } from './prose.ts'
|
|
13
|
+
|
|
14
|
+
/** What happens when a discovered rule file exists but cannot be parsed or compiled. */
|
|
15
|
+
export type BadFilePolicy = 'fail' | 'ignore-with-warning'
|
|
16
|
+
|
|
17
|
+
/** Which decisions are audit-logged: every call, or only rule hits. */
|
|
18
|
+
export type AuditGranularity = 'all' | 'hits'
|
|
19
|
+
|
|
20
|
+
/** Raw plugin config — every field optional; {@link Config} supplies the defaults. */
|
|
21
|
+
export interface Config {
|
|
22
|
+
/**
|
|
23
|
+
* Rule file location. A relative value is resolved against the calling
|
|
24
|
+
* session's workspace cwd (so `<cwd>/.dsh/rules.yaml` by default); an
|
|
25
|
+
* absolute value is used as-is for every session.
|
|
26
|
+
*/
|
|
27
|
+
rulesFile?: string
|
|
28
|
+
/**
|
|
29
|
+
* Fallback rule file used when per-cwd discovery finds no rule file.
|
|
30
|
+
* Absolute, or relative to `process.cwd()`. Unset = an empty rule set.
|
|
31
|
+
*/
|
|
32
|
+
fallbackPath?: string
|
|
33
|
+
/**
|
|
34
|
+
* How an unreadable/invalid rule file is handled at load: `'fail'` throws
|
|
35
|
+
* (the pending tool call errors loudly; HMR reloads keep the previous
|
|
36
|
+
* rules and report the error), `'ignore-with-warning'` logs a warning and
|
|
37
|
+
* continues with an empty (initial) or previous (reload) rule set.
|
|
38
|
+
*/
|
|
39
|
+
badFilePolicy?: BadFilePolicy
|
|
40
|
+
/** Hard cap on the number of rules across the effective source chain; a larger chain fails the load. */
|
|
41
|
+
maxRules?: number
|
|
42
|
+
/** Hard cap on cached per-workspace rule loads; the least-recently-used workspace is evicted beyond it. */
|
|
43
|
+
maxCachedWorkspaces?: number
|
|
44
|
+
/** How `params`, `paths`, and `when.env` patterns are interpreted: `'glob'` (default) or `'regex'`. */
|
|
45
|
+
patternMode?: PatternMode
|
|
46
|
+
/** Whether the loaded rule file is watched and reloaded on change. */
|
|
47
|
+
watch?: boolean
|
|
48
|
+
/** Debounce window for watch-driven reloads, in milliseconds. */
|
|
49
|
+
watchStabilityThresholdMs?: number
|
|
50
|
+
/** Language of the `/rules` command output: `'en'` (default), `'zh'`, `'es'`, `'pt'`, or `'hi'`. */
|
|
51
|
+
language?: UiLanguage
|
|
52
|
+
/** Whether `paths` patterns (and workspace-root comparison) ignore ASCII case; defaults to `true` on Windows. */
|
|
53
|
+
caseInsensitivePaths?: boolean
|
|
54
|
+
/** Audit granularity: `'all'` logs every hit AND passthrough; `'hits'` skips passthrough events. */
|
|
55
|
+
audit?: AuditGranularity
|
|
56
|
+
/** Walk parent directories of the session cwd and merge every found rule file (nearest first). */
|
|
57
|
+
searchUp?: boolean
|
|
58
|
+
/** Hard cap on unbounded `*`/`**` quantifiers per glob pattern (backtracking-degree bound). */
|
|
59
|
+
maxGlobStars?: number
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Config after {@link resolveConfig}: every optional field has its explicit default. */
|
|
63
|
+
export interface ResolvedConfig {
|
|
64
|
+
readonly rulesFile: string
|
|
65
|
+
readonly fallbackPath: string | undefined
|
|
66
|
+
readonly badFilePolicy: BadFilePolicy
|
|
67
|
+
readonly maxRules: number
|
|
68
|
+
readonly maxCachedWorkspaces: number
|
|
69
|
+
readonly patternMode: PatternMode
|
|
70
|
+
readonly watch: boolean
|
|
71
|
+
readonly watchStabilityThresholdMs: number
|
|
72
|
+
readonly language: UiLanguage
|
|
73
|
+
readonly caseInsensitivePaths: boolean
|
|
74
|
+
readonly audit: AuditGranularity
|
|
75
|
+
readonly searchUp: boolean
|
|
76
|
+
readonly maxGlobStars: number
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Schemastery schema: the loader validates and fills defaults before `apply`. */
|
|
80
|
+
export const Config: z<Config> = z.object({
|
|
81
|
+
rulesFile: z.string().default('.dsh/rules.yaml'),
|
|
82
|
+
fallbackPath: z.string(),
|
|
83
|
+
badFilePolicy: z.union(['fail', 'ignore-with-warning'] as const).default('fail'),
|
|
84
|
+
maxRules: z.number().default(256),
|
|
85
|
+
maxCachedWorkspaces: z.number().default(512),
|
|
86
|
+
patternMode: z.union(['glob', 'regex'] as const).default('glob'),
|
|
87
|
+
watch: z.boolean().default(true),
|
|
88
|
+
watchStabilityThresholdMs: z.number().default(200),
|
|
89
|
+
language: z.union(['en', 'zh', 'es', 'pt', 'hi'] as const).default('en'),
|
|
90
|
+
caseInsensitivePaths: z.boolean().default(process.platform === 'win32'),
|
|
91
|
+
audit: z.union(['all', 'hits'] as const).default('all'),
|
|
92
|
+
searchUp: z.boolean().default(false),
|
|
93
|
+
maxGlobStars: z.number().default(2),
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Validate raw values and fill explicit defaults. A `maxRules`,
|
|
98
|
+
* `maxCachedWorkspaces`, or `maxGlobStars` that is not a positive safe
|
|
99
|
+
* integer, a non-positive stability window, or `searchUp` combined with an
|
|
100
|
+
* absolute `rulesFile` throws here — misconfiguration fails loud at mount.
|
|
101
|
+
* @param config - raw (possibly partial) plugin config.
|
|
102
|
+
* @returns the fully resolved config.
|
|
103
|
+
*/
|
|
104
|
+
export function resolveConfig(config: Config = {}): ResolvedConfig {
|
|
105
|
+
const rulesFile = config.rulesFile ?? '.dsh/rules.yaml'
|
|
106
|
+
const searchUp = config.searchUp ?? false
|
|
107
|
+
if (searchUp && isAbsolute(rulesFile)) {
|
|
108
|
+
throw new TypeError(`searchUp cannot be combined with an absolute rulesFile (${JSON.stringify(rulesFile)}): parent-directory walking needs a relative file name`)
|
|
109
|
+
}
|
|
110
|
+
const maxRules = config.maxRules ?? 256
|
|
111
|
+
if (!Number.isSafeInteger(maxRules) || maxRules <= 0) {
|
|
112
|
+
throw new TypeError(`maxRules must be a positive safe integer, got ${String(config.maxRules)}`)
|
|
113
|
+
}
|
|
114
|
+
const watchStabilityThresholdMs = config.watchStabilityThresholdMs ?? 200
|
|
115
|
+
if (!Number.isSafeInteger(watchStabilityThresholdMs) || watchStabilityThresholdMs < 0) {
|
|
116
|
+
throw new TypeError(`watchStabilityThresholdMs must be a non-negative safe integer, got ${String(config.watchStabilityThresholdMs)}`)
|
|
117
|
+
}
|
|
118
|
+
const maxCachedWorkspaces = config.maxCachedWorkspaces ?? 512
|
|
119
|
+
if (!Number.isSafeInteger(maxCachedWorkspaces) || maxCachedWorkspaces <= 0) {
|
|
120
|
+
throw new TypeError(`maxCachedWorkspaces must be a positive safe integer, got ${String(config.maxCachedWorkspaces)}`)
|
|
121
|
+
}
|
|
122
|
+
const maxGlobStars = config.maxGlobStars ?? 2
|
|
123
|
+
if (!Number.isSafeInteger(maxGlobStars) || maxGlobStars <= 0) {
|
|
124
|
+
throw new TypeError(`maxGlobStars must be a positive safe integer, got ${String(config.maxGlobStars)}`)
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
rulesFile,
|
|
128
|
+
fallbackPath: config.fallbackPath,
|
|
129
|
+
badFilePolicy: config.badFilePolicy ?? 'fail',
|
|
130
|
+
maxRules,
|
|
131
|
+
maxCachedWorkspaces,
|
|
132
|
+
patternMode: config.patternMode ?? 'glob',
|
|
133
|
+
watch: config.watch ?? true,
|
|
134
|
+
watchStabilityThresholdMs,
|
|
135
|
+
language: config.language ?? 'en',
|
|
136
|
+
caseInsensitivePaths: config.caseInsensitivePaths ?? process.platform === 'win32',
|
|
137
|
+
audit: config.audit ?? 'all',
|
|
138
|
+
searchUp,
|
|
139
|
+
maxGlobStars,
|
|
140
|
+
}
|
|
141
|
+
}
|