dsh-github-copilot 0.4.0-alpha.114 → 0.4.0-alpha.116
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/AGENTS.md +13 -4
- package/CHANGELOG.md +15 -0
- package/CONTRIBUTING.md +9 -0
- package/README.md +24 -7
- package/README.zh.md +19 -7
- package/deployment-baseline.json +29 -3
- package/docs/auto-high-cost.md +132 -0
- package/docs/auto-iteration-review.json +22 -0
- package/docs/auto-task-routing.md +8 -6
- package/docs/automatic-model-routing.md +4 -1
- package/docs/copilot-compaction.md +2 -2
- package/docs/evidence-driven-iteration.md +86 -0
- package/docs/manual-compaction-recovery.md +20 -6
- package/lib/client.js +239 -75
- package/lib/client.js.map +1 -1
- package/lib/index.js +261 -18
- package/lib/manual-compaction-recovery.js +39 -10
- package/lib/remote.js +125 -40
- package/lib/types/authorization-controller.d.ts +2 -0
- package/lib/types/auto-allocation-card.d.ts +9 -0
- package/lib/types/auto-allocation-evidence.d.ts +38 -0
- package/lib/types/auto-allocation.d.ts +24 -0
- package/lib/types/auto-model-host.d.ts +2 -0
- package/lib/types/auto-model-routing.d.ts +6 -2
- package/lib/types/auto-task-classifier.d.ts +1 -1
- package/lib/types/config.d.ts +8 -2
- package/lib/types/manual-compaction-recovery.d.ts +16 -3
- package/lib/types/model-preferences-card.d.ts +1 -1
- package/lib/types/preview-route.d.ts +4 -3
- package/lib/types/remote.d.ts +3 -0
- package/lib/types/turn-selection-card.d.ts +2 -1
- package/lib/types/turn-selection-host.d.ts +21 -0
- package/lib/types/turn-selection-remote.d.ts +2 -0
- package/lib/types/turn-selection.d.ts +15 -0
- package/package.json +5 -1
- package/scripts/iteration-review.mjs +53 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { open } from 'node:fs/promises'
|
|
2
|
+
import { resolve } from 'node:path'
|
|
3
|
+
import { fileURLToPath } from 'node:url'
|
|
4
|
+
|
|
5
|
+
export function validateIterationReview(value) {
|
|
6
|
+
const require = (condition, message) => { if (!condition) throw new Error(`Iteration review: ${message}`) }
|
|
7
|
+
const object = value => value !== null && typeof value === 'object' && !Array.isArray(value)
|
|
8
|
+
const keys = (value, allowed) => require(object(value) && Object.keys(value).every(key => allowed.includes(key)), 'unknown or invalid fields')
|
|
9
|
+
const text = value => typeof value === 'string' && value.trim().length > 0 && value.length <= 2000
|
|
10
|
+
keys(value, ['schemaVersion', 'feature', 'status', 'policyVersion', 'observation', 'previousReview', 'findings', 'decision', 'validation', 'followUp'])
|
|
11
|
+
require(value.schemaVersion === 1 && value.feature === 'autorouting', 'unsupported version or feature')
|
|
12
|
+
require(['observed', 'not-collected', 'insufficient-sample', 'unavailable'].includes(value.status), 'explicit evidence status required')
|
|
13
|
+
require(text(value.policyVersion), 'policy version required')
|
|
14
|
+
keys(value.observation, ['start', 'end', 'sampleCount', 'limitations'])
|
|
15
|
+
const { start, end, sampleCount, limitations } = value.observation
|
|
16
|
+
require(Number.isSafeInteger(sampleCount) && sampleCount >= 0, 'invalid sample count')
|
|
17
|
+
require(text(limitations), 'observation limitations required')
|
|
18
|
+
if (value.status === 'observed' || value.status === 'insufficient-sample') {
|
|
19
|
+
require(typeof start === 'string' && typeof end === 'string'
|
|
20
|
+
&& Number.isFinite(Date.parse(start)) && Number.isFinite(Date.parse(end))
|
|
21
|
+
&& Date.parse(start) <= Date.parse(end), 'valid observation window required')
|
|
22
|
+
require(sampleCount > 0, 'observed evidence needs samples')
|
|
23
|
+
} else require(start === null && end === null && sampleCount === 0, 'missing evidence cannot claim a window')
|
|
24
|
+
require(value.previousReview === null || text(value.previousReview), 'invalid prior review reference')
|
|
25
|
+
for (const field of ['findings', 'decision', 'validation']) require(text(value[field]), `${field} required`)
|
|
26
|
+
keys(value.followUp, ['owner', 'trigger', 'metric', 'action'])
|
|
27
|
+
for (const field of ['owner', 'trigger', 'metric', 'action']) require(text(value.followUp[field]), `follow-up ${field} required`)
|
|
28
|
+
return { schemaVersion: 1, ok: true, feature: value.feature, evidenceStatus: value.status,
|
|
29
|
+
sampleCount, reviewDocumentOnly: true, evidenceTruthVerified: false }
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export async function main(args = process.argv.slice(2)) {
|
|
33
|
+
try {
|
|
34
|
+
if (args.length !== 2 || args[0] !== '--report') throw new Error('Invalid arguments')
|
|
35
|
+
const handle = await open(resolve(args[1]), 'r')
|
|
36
|
+
let value
|
|
37
|
+
try {
|
|
38
|
+
const info = await handle.stat()
|
|
39
|
+
if (!info.isFile() || info.size > 32768) throw new Error('Invalid report file')
|
|
40
|
+
const bytes = Buffer.alloc(32769)
|
|
41
|
+
const { bytesRead } = await handle.read(bytes, 0, bytes.length, 0)
|
|
42
|
+
if (bytesRead > 32768) throw new Error('Report exceeds 32 KiB')
|
|
43
|
+
value = JSON.parse(bytes.subarray(0, bytesRead).toString('utf8'))
|
|
44
|
+
} finally { await handle.close() }
|
|
45
|
+
const review = validateIterationReview(value)
|
|
46
|
+
console.log(JSON.stringify({ ...review, report: value }))
|
|
47
|
+
return 0
|
|
48
|
+
} catch {
|
|
49
|
+
console.error('ITERATION_REVIEW_INVALID: provide a bounded report matching docs/evidence-driven-iteration.md')
|
|
50
|
+
return 1
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) process.exitCode = await main()
|