@morning-start/dsh-code-toolkit 0.27.4 → 0.28.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 +63 -0
- package/README.md +71 -10
- package/agents/audit/AGENT.md +171 -0
- package/agents/audit/examples/fake-capability.md +54 -0
- package/agents/audit/examples/wired-clean.md +66 -0
- package/agents/audit/references/audit-passes.md +118 -0
- package/agents/audit/references/capability-states.md +96 -0
- package/agents/audit/references/evidence.md +86 -0
- package/agents/audit/references/finding-the-chain.md +80 -0
- package/agents/audit/references/output.md +66 -0
- package/agents/caption/AGENT.md +12 -0
- package/agents/caption/references/evidence.md +46 -0
- package/agents/design/AGENT.md +214 -0
- package/agents/design/examples/one-page.md +55 -0
- package/agents/design/examples/overkill.md +56 -0
- package/agents/design/references/base-maps.md +110 -0
- package/agents/design/references/deliverables.md +71 -0
- package/agents/design/references/model-and-ports.md +73 -0
- package/agents/design/references/plan-and-batches.md +92 -0
- package/agents/design/references/scenario-cards.md +133 -0
- package/agents/design/references/self-check.md +73 -0
- package/agents/pua/AGENT.md +3 -0
- package/agents/review/AGENT.md +16 -0
- package/agents/scrub/AGENT.md +5 -1
- package/index.js +57 -1
- package/locale/en.json +2 -2
- package/locale/zh.json +2 -2
- package/package.json +5 -2
- package/src/command.js +14 -4
- package/src/design.js +70 -0
- package/src/i18n.js +46 -0
- package/src/report.js +112 -3
package/src/report.js
CHANGED
|
@@ -13,6 +13,41 @@ function findingList(value) {
|
|
|
13
13
|
return value && typeof value === 'object' ? [value] : []
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* The audit's closed set. A capability is in exactly one of these five states,
|
|
18
|
+
* and the token is the machine-readable half of the contract: the prose around
|
|
19
|
+
* it may be in any language, the token may not. Aliases are accepted on input
|
|
20
|
+
* because a model that writes Chinese will eventually write 通 instead of
|
|
21
|
+
* `wired`; accepting it costs nothing, guessing at a sixth state would.
|
|
22
|
+
*/
|
|
23
|
+
const CAPABILITY_STATES = ['wired', 'half', 'fake', 'broken', 'missing']
|
|
24
|
+
|
|
25
|
+
const STATE_ALIASES = {
|
|
26
|
+
wired: 'wired',
|
|
27
|
+
通: 'wired',
|
|
28
|
+
half: 'half',
|
|
29
|
+
半: 'half',
|
|
30
|
+
fake: 'fake',
|
|
31
|
+
假: 'fake',
|
|
32
|
+
broken: 'broken',
|
|
33
|
+
断: 'broken',
|
|
34
|
+
missing: 'missing',
|
|
35
|
+
无: 'missing',
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const STATE_LABELS = {
|
|
39
|
+
wired: 'state.wired',
|
|
40
|
+
half: 'state.half',
|
|
41
|
+
fake: 'state.fake',
|
|
42
|
+
broken: 'state.broken',
|
|
43
|
+
missing: 'state.missing',
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function stateOf(value) {
|
|
47
|
+
const token = textOf(value).toLowerCase()
|
|
48
|
+
return STATE_ALIASES[token] ?? STATE_ALIASES[textOf(value)] ?? null
|
|
49
|
+
}
|
|
50
|
+
|
|
16
51
|
function priorityOf(value) {
|
|
17
52
|
if (typeof value === 'number' && Number.isInteger(value) && value >= 0 && value <= 3) return value
|
|
18
53
|
if (typeof value !== 'string') return null
|
|
@@ -69,7 +104,37 @@ function decode(raw) {
|
|
|
69
104
|
})
|
|
70
105
|
|
|
71
106
|
const summary = textOf(value.overall_explanation)
|
|
72
|
-
|
|
107
|
+
|
|
108
|
+
// The audit's table. A row needs a state from the closed set; a row without
|
|
109
|
+
// one is dropped rather than guessed, because an unstated state is exactly
|
|
110
|
+
// the claim an audit exists to refuse.
|
|
111
|
+
const capabilities = Array.isArray(value.capabilities)
|
|
112
|
+
? value.capabilities.flatMap((item) => {
|
|
113
|
+
if (!item || typeof item !== 'object') return []
|
|
114
|
+
const capability = textOf(item.capability) || textOf(item.name)
|
|
115
|
+
const state = stateOf(item.state)
|
|
116
|
+
if (!capability || !state) return []
|
|
117
|
+
const evidence = item.evidence && typeof item.evidence === 'object' ? item.evidence : {}
|
|
118
|
+
const lines = linesOf(evidence.line_range) ?? linesOf(evidence.line) ?? linesOf(item.line)
|
|
119
|
+
const batch = Number.isInteger(item.batch) ? item.batch : Number.isInteger(item.suggested_batch) ? item.suggested_batch : undefined
|
|
120
|
+
return [{
|
|
121
|
+
id: textOf(item.id),
|
|
122
|
+
capability,
|
|
123
|
+
state,
|
|
124
|
+
path: textOf(evidence.file) || textOf(evidence.path) || textOf(item.file),
|
|
125
|
+
start: lines?.start ?? 0,
|
|
126
|
+
end: lines?.end ?? 0,
|
|
127
|
+
walk: textOf(item.path) || textOf(item.walk),
|
|
128
|
+
expected: textOf(item.expected),
|
|
129
|
+
actual: textOf(item.actual),
|
|
130
|
+
impact: textOf(item.impact),
|
|
131
|
+
...(batch === undefined ? {} : { batch }),
|
|
132
|
+
note: textOf(item.note) || textOf(item.body),
|
|
133
|
+
}]
|
|
134
|
+
})
|
|
135
|
+
: []
|
|
136
|
+
|
|
137
|
+
if (!summary && !findings.length && !capabilities.length) return undefined
|
|
73
138
|
|
|
74
139
|
const limitations = Array.isArray(value.limitations)
|
|
75
140
|
? value.limitations.filter((item) => typeof item === 'string' && item.trim()).map((item) => item.trim())
|
|
@@ -91,6 +156,7 @@ function decode(raw) {
|
|
|
91
156
|
|
|
92
157
|
return {
|
|
93
158
|
findings,
|
|
159
|
+
capabilities,
|
|
94
160
|
fixed,
|
|
95
161
|
summary,
|
|
96
162
|
limitations,
|
|
@@ -110,7 +176,11 @@ function objectsIn(raw) {
|
|
|
110
176
|
if (raw[i] !== '{') continue
|
|
111
177
|
const slice = objectAt(raw, i)
|
|
112
178
|
if (!slice) continue
|
|
113
|
-
|
|
179
|
+
// A review report carries findings; an audit report carries the capability
|
|
180
|
+
// table and may have no findings at all. Both are reports; prose is not.
|
|
181
|
+
if (slice.includes('"overall_') && (slice.includes('"findings"') || slice.includes('"capabilities"'))) {
|
|
182
|
+
found.push(slice)
|
|
183
|
+
}
|
|
114
184
|
i += slice.length - 1
|
|
115
185
|
}
|
|
116
186
|
return found
|
|
@@ -178,6 +248,43 @@ function renderFix(fix, t) {
|
|
|
178
248
|
return [`### ${fix.title}`, location, fix.change, verified].filter(Boolean).join('\n\n')
|
|
179
249
|
}
|
|
180
250
|
|
|
251
|
+
/**
|
|
252
|
+
* The audit's table plus one detail block per actionable row: the walk, what was
|
|
253
|
+
* expected, what happened, and what the person cannot do. The state token becomes
|
|
254
|
+
* a translated label; everything else is the agent's own words.
|
|
255
|
+
*/
|
|
256
|
+
function renderCapabilities(capabilities, t) {
|
|
257
|
+
const label = (state) => t(STATE_LABELS[state] ?? state)
|
|
258
|
+
const header = `| ${t('report.capability')} | ${t('report.state')} | ${t('report.evidence')} |`
|
|
259
|
+
const rows = capabilities.map((item) => {
|
|
260
|
+
const where = item.path ? fileLink(item.path, item.start, item.end) : ''
|
|
261
|
+
const name = item.id ? `${item.id} ${item.capability}` : item.capability
|
|
262
|
+
return `| ${name} | ${label(item.state)} | ${where} |`
|
|
263
|
+
})
|
|
264
|
+
const details = capabilities
|
|
265
|
+
.filter((item) => item.walk || item.expected || item.actual || item.impact || item.batch !== undefined || item.note)
|
|
266
|
+
.map((item) => {
|
|
267
|
+
const head = `### ${item.id ? `${item.id} · ` : ''}${item.capability} (${label(item.state)})`
|
|
268
|
+
const lines = [
|
|
269
|
+
item.walk ? `${t('report.walk')}${item.walk}` : '',
|
|
270
|
+
item.expected ? `${t('report.expected')}${item.expected}` : '',
|
|
271
|
+
item.actual ? `${t('report.actual')}${item.actual}` : '',
|
|
272
|
+
item.impact ? `${t('report.impact')}${item.impact}` : '',
|
|
273
|
+
item.batch !== undefined ? `${t('report.batch')}${item.batch}` : '',
|
|
274
|
+
item.note,
|
|
275
|
+
].filter(Boolean)
|
|
276
|
+
return [head, ...lines].join('\n')
|
|
277
|
+
})
|
|
278
|
+
return [
|
|
279
|
+
`## ${t('report.capabilities')}`,
|
|
280
|
+
'',
|
|
281
|
+
header,
|
|
282
|
+
'| --- | --- | --- |',
|
|
283
|
+
...rows,
|
|
284
|
+
...(details.length ? ['', ...details] : []),
|
|
285
|
+
].join('\n')
|
|
286
|
+
}
|
|
287
|
+
|
|
181
288
|
/**
|
|
182
289
|
* Render a parsed report as Markdown. `t` translates the few chrome labels;
|
|
183
290
|
* finding text is never translated — it is the agent's own words.
|
|
@@ -186,13 +293,15 @@ export function renderReport(report, t) {
|
|
|
186
293
|
if (report.format === 'text') return report.summary
|
|
187
294
|
|
|
188
295
|
const limits = report.limitations.map((item) => `- ${t('report.limitation')}${item}`)
|
|
189
|
-
const
|
|
296
|
+
const capabilities = report.capabilities ?? []
|
|
297
|
+
const empty = !report.findings.length && !capabilities.length ? t('report.noFindings') : ''
|
|
190
298
|
const fixed = report.fixed ?? []
|
|
191
299
|
|
|
192
300
|
return [
|
|
193
301
|
report.summary,
|
|
194
302
|
report.correctness ? `${t('report.verdict')}${report.correctness}` : '',
|
|
195
303
|
empty,
|
|
304
|
+
capabilities.length ? renderCapabilities(capabilities, t) : '',
|
|
196
305
|
...report.findings.map(renderFinding),
|
|
197
306
|
fixed.length ? `## ${t('report.fixed')}\n\n${fixed.map((fix) => renderFix(fix, t)).join('\n\n')}` : '',
|
|
198
307
|
limits.length ? limits.join('\n') : '',
|