dsh-github-copilot 0.1.0-alpha.1.dsh.0.2.1.alpha.5
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 +439 -0
- package/CHANGELOG.md +875 -0
- package/CONTRIBUTING.md +55 -0
- package/LICENSE +21 -0
- package/README.md +366 -0
- package/README.zh.md +341 -0
- package/SECURITY.md +29 -0
- package/cordis.patch.yml +16 -0
- package/deployment-baseline.json +1580 -0
- package/docs/account-management-experience.md +143 -0
- package/docs/agent-readiness.md +110 -0
- package/docs/auto-high-cost.md +255 -0
- package/docs/auto-iteration-review.json +22 -0
- package/docs/auto-review-sampling.md +60 -0
- package/docs/auto-task-routing.md +341 -0
- package/docs/automatic-model-routing.md +236 -0
- package/docs/copilot-accounts.md +424 -0
- package/docs/copilot-compaction.md +148 -0
- package/docs/copilot-usage.md +133 -0
- package/docs/dual-model.md +66 -0
- package/docs/evidence-driven-iteration.md +86 -0
- package/docs/image-input-compatibility.md +64 -0
- package/docs/images/copilot-accounts-credits.png +0 -0
- package/docs/images/copilot-accounts.png +0 -0
- package/docs/images/copilot-current-provenance.json +39 -0
- package/docs/images/copilot-model-preferences.png +0 -0
- package/docs/images/copilot-search-routing.png +0 -0
- package/docs/images/copilot-session-continuation.png +0 -0
- package/docs/images/dual-model-desktop.png +0 -0
- package/docs/images/dual-model-mobile.png +0 -0
- package/docs/images/dual-model-provenance.json +35 -0
- package/docs/images/parent-model-follow.png +0 -0
- package/docs/manual-compaction-recovery.md +109 -0
- package/docs/mockups/copilot-account-dropdown.html +71 -0
- package/docs/mockups/copilot-account-management.html +393 -0
- package/docs/model-compatibility-acceptance.md +182 -0
- package/docs/npm-distribution.md +202 -0
- package/docs/official-first-016-alpha2.md +66 -0
- package/docs/official-first-020-rc1.md +32 -0
- package/docs/official-first-020-rc2.md +17 -0
- package/docs/official-first-021-alpha4.md +157 -0
- package/docs/official-first-021-alpha5.md +83 -0
- package/docs/plugin-diagnostics.md +605 -0
- package/docs/session-continuation.md +141 -0
- package/docs/session-search-routing.md +133 -0
- package/docs/single-route-migration.md +131 -0
- package/docs/web-lifecycle-rc2.md +55 -0
- package/lib/client.js +13236 -0
- package/lib/client.js.map +1 -0
- package/lib/copilot-identity-DRZY_d2X.js +15 -0
- package/lib/diagnostics-analysis-io.js +78 -0
- package/lib/diagnostics-analysis.js +427 -0
- package/lib/diagnostics-types-CF-qg8Do.js +708 -0
- package/lib/index.js +15661 -0
- package/lib/manual-compaction-recovery.js +485 -0
- package/lib/remote.js +1507 -0
- package/lib/request-budget-DLY_aRq0.js +87 -0
- package/lib/routed-web.js +120 -0
- package/lib/search-routing-CV2hs8as.js +792 -0
- package/lib/types/account-dropdown.d.ts +22 -0
- package/lib/types/account-model-auth.d.ts +15 -0
- package/lib/types/account-model-catalog.d.ts +70 -0
- package/lib/types/account-model-source.d.ts +85 -0
- package/lib/types/agent-compaction.d.ts +4 -0
- package/lib/types/authorization-code-clipboard.d.ts +4 -0
- package/lib/types/authorization-controller.d.ts +121 -0
- package/lib/types/auto-allocation-card.d.ts +9 -0
- package/lib/types/auto-allocation-diagnostics.d.ts +126 -0
- package/lib/types/auto-allocation-evidence.d.ts +44 -0
- package/lib/types/auto-allocation.d.ts +47 -0
- package/lib/types/auto-assessment-evidence.d.ts +111 -0
- package/lib/types/auto-model-host.d.ts +30 -0
- package/lib/types/auto-model-intent.d.ts +36 -0
- package/lib/types/auto-model-presentation.d.ts +57 -0
- package/lib/types/auto-model-routing.d.ts +64 -0
- package/lib/types/auto-review-sampling.d.ts +6 -0
- package/lib/types/auto-selection-explanation.d.ts +9 -0
- package/lib/types/auto-task-assessment.d.ts +49 -0
- package/lib/types/auto-task-classifier.d.ts +10 -0
- package/lib/types/background-compaction.d.ts +30 -0
- package/lib/types/client.d.ts +129 -0
- package/lib/types/compact-account.d.ts +42 -0
- package/lib/types/compaction-continuation-ui.d.ts +29 -0
- package/lib/types/compaction-continuation.d.ts +48 -0
- package/lib/types/compaction-input-estimate.d.ts +28 -0
- package/lib/types/compaction-pressure.d.ts +23 -0
- package/lib/types/compaction-replay.d.ts +18 -0
- package/lib/types/compatibility.d.ts +17 -0
- package/lib/types/composer-notice-style.d.ts +7 -0
- package/lib/types/config.d.ts +141 -0
- package/lib/types/content-file.d.ts +10 -0
- package/lib/types/context-evidence-ui.d.ts +28 -0
- package/lib/types/context-evidence.d.ts +256 -0
- package/lib/types/context-usage.d.ts +4 -0
- package/lib/types/copilot-account-presentation.d.ts +7 -0
- package/lib/types/copilot-accounts-card.d.ts +43 -0
- package/lib/types/copilot-accounts-host.d.ts +93 -0
- package/lib/types/copilot-accounts-remote.d.ts +85 -0
- package/lib/types/copilot-accounts-types.d.ts +43 -0
- package/lib/types/copilot-auth.d.ts +31 -0
- package/lib/types/copilot-grant.d.ts +11 -0
- package/lib/types/copilot-identity.d.ts +11 -0
- package/lib/types/copilot-request.d.ts +11 -0
- package/lib/types/copilot-stream-liveness.d.ts +23 -0
- package/lib/types/copilot-usage-card.d.ts +51 -0
- package/lib/types/copilot-usage-host.d.ts +61 -0
- package/lib/types/copilot-usage-normalize.d.ts +9 -0
- package/lib/types/copilot-usage-remote.d.ts +63 -0
- package/lib/types/copilot-usage-types.d.ts +20 -0
- package/lib/types/copilot-usage-ui.d.ts +4 -0
- package/lib/types/current-provider.d.ts +59 -0
- package/lib/types/deepseek-search-fallback.d.ts +11 -0
- package/lib/types/diagnostics-analysis-io.d.ts +23 -0
- package/lib/types/diagnostics-analysis.d.ts +298 -0
- package/lib/types/diagnostics-card.d.ts +12 -0
- package/lib/types/diagnostics-client.d.ts +13 -0
- package/lib/types/diagnostics-collector.d.ts +50 -0
- package/lib/types/diagnostics-host.d.ts +183 -0
- package/lib/types/diagnostics-remote.d.ts +113 -0
- package/lib/types/diagnostics-types.d.ts +893 -0
- package/lib/types/dual-model-host.d.ts +119 -0
- package/lib/types/dual-model-remote.d.ts +63 -0
- package/lib/types/dual-model-types.d.ts +34 -0
- package/lib/types/external-link.d.ts +3 -0
- package/lib/types/failure.d.ts +38 -0
- package/lib/types/http.d.ts +48 -0
- package/lib/types/image-input-admission.d.ts +5 -0
- package/lib/types/index.d.ts +39 -0
- package/lib/types/manual-compaction-recovery.d.ts +67 -0
- package/lib/types/migration-status.d.ts +50 -0
- package/lib/types/model-exclusions.d.ts +15 -0
- package/lib/types/model-preferences-card.d.ts +9 -0
- package/lib/types/model-protocol.d.ts +31 -0
- package/lib/types/native-select-style.d.ts +4 -0
- package/lib/types/native-settings-style.d.ts +10 -0
- package/lib/types/parent-model-follow-card.d.ts +32 -0
- package/lib/types/parent-model-follow.d.ts +44 -0
- package/lib/types/pi-provider-bridge.d.ts +22 -0
- package/lib/types/plan.d.ts +148 -0
- package/lib/types/pre-step-pressure.d.ts +8 -0
- package/lib/types/preview-provider.d.ts +77 -0
- package/lib/types/preview-route.d.ts +76 -0
- package/lib/types/probe.d.ts +39 -0
- package/lib/types/remote-codec.d.ts +10 -0
- package/lib/types/remote.d.ts +202 -0
- package/lib/types/replay-recovery-host.d.ts +28 -0
- package/lib/types/replay-recovery-remote.d.ts +14 -0
- package/lib/types/replay-recovery-types.d.ts +24 -0
- package/lib/types/replay-recovery-ui.d.ts +28 -0
- package/lib/types/replay-recovery.d.ts +17 -0
- package/lib/types/request-body-composition.d.ts +17 -0
- package/lib/types/request-body-evidence.d.ts +37 -0
- package/lib/types/request-body-timeout-marker.d.ts +2 -0
- package/lib/types/request-body-timeout.d.ts +4 -0
- package/lib/types/request-budget.d.ts +58 -0
- package/lib/types/request-diagnostics.d.ts +278 -0
- package/lib/types/request-upload-evidence.d.ts +23 -0
- package/lib/types/response-error-body.d.ts +3 -0
- package/lib/types/responses-reasoning-text.d.ts +24 -0
- package/lib/types/responses-reasoning.d.ts +7 -0
- package/lib/types/responses-replay-compat.d.ts +31 -0
- package/lib/types/responses-request-compression.d.ts +33 -0
- package/lib/types/route-ownership.d.ts +70 -0
- package/lib/types/routed-web.d.ts +50 -0
- package/lib/types/search-backend.d.ts +16 -0
- package/lib/types/search-routing-host.d.ts +19 -0
- package/lib/types/search-routing-policy.d.ts +18 -0
- package/lib/types/search-routing-remote.d.ts +20 -0
- package/lib/types/search-routing.d.ts +43 -0
- package/lib/types/search-tool-routing.d.ts +22 -0
- package/lib/types/serialize.d.ts +106 -0
- package/lib/types/session-accounts-controller.d.ts +20 -0
- package/lib/types/session-accounts-host.d.ts +33 -0
- package/lib/types/session-accounts-remote.d.ts +114 -0
- package/lib/types/session-accounts.d.ts +38 -0
- package/lib/types/session-continuation-host.d.ts +45 -0
- package/lib/types/session-continuation-remote.d.ts +22 -0
- package/lib/types/session-continuation-types.d.ts +62 -0
- package/lib/types/session-continuation-ui.d.ts +49 -0
- package/lib/types/session-continuation.d.ts +14 -0
- package/lib/types/settings-reader.d.ts +16 -0
- package/lib/types/sse.d.ts +28 -0
- package/lib/types/temporary-models.d.ts +25 -0
- package/lib/types/tool-schema-compat.d.ts +17 -0
- package/lib/types/traditional-search.d.ts +17 -0
- package/lib/types/turn-model-provenance.d.ts +45 -0
- package/lib/types/turn-request-models.d.ts +55 -0
- package/lib/types/turn-selection-card.d.ts +24 -0
- package/lib/types/turn-selection-host.d.ts +35 -0
- package/lib/types/turn-selection-remote.d.ts +17 -0
- package/lib/types/turn-selection.d.ts +186 -0
- package/lib/types/turn-usage-evidence.d.ts +66 -0
- package/lib/types/turn-usage-notice.d.ts +7 -0
- package/lib/types/types.d.ts +69 -0
- package/lib/types/usage.d.ts +26 -0
- package/lib/types/watchdog.d.ts +22 -0
- package/lib/types/web-delegate.d.ts +12 -0
- package/lib/types/web-search-routing-card.d.ts +16 -0
- package/lib/types/web-search-routing-config.d.ts +12 -0
- package/lib/types/wire-anthropic.d.ts +37 -0
- package/lib/types/wire.d.ts +56 -0
- package/lib/web-delegate.js +9 -0
- package/output/auto-model-mockup/index.html +207 -0
- package/package.json +261 -0
- package/scripts/analyze-diagnostics.mjs +91 -0
- package/scripts/check-search-composition.mjs +191 -0
- package/scripts/iteration-review.mjs +53 -0
- package/scripts/release-policy.mjs +353 -0
- package/scripts/select-core-release.mjs +11 -0
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process'
|
|
2
|
+
import { appendFileSync } from 'node:fs'
|
|
3
|
+
import { resolve } from 'node:path'
|
|
4
|
+
import { fileURLToPath } from 'node:url'
|
|
5
|
+
|
|
6
|
+
const REPOSITORY = 'cloga/dsh-github-copilot'
|
|
7
|
+
const PACKAGE_NAME = 'dsh-github-copilot'
|
|
8
|
+
const importantPaths = new Set([
|
|
9
|
+
'cordis.patch.yml', 'deployment-baseline.json',
|
|
10
|
+
'package.json', 'pnpm-lock.yaml', 'pnpm-workspace.yaml',
|
|
11
|
+
'scripts/check-search-composition.mjs', 'scripts/release-policy.mjs', 'scripts/select-core-release.mjs',
|
|
12
|
+
'tsconfig.json', 'tsconfig.tests.json', 'tsdown.config.ts', 'vitest.config.ts',
|
|
13
|
+
])
|
|
14
|
+
const importantPrefixes = ['src/', 'lib/']
|
|
15
|
+
const semverPattern = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*))*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$/
|
|
16
|
+
|
|
17
|
+
function normalizePath(file) {
|
|
18
|
+
if (typeof file !== 'string') throw new Error('Changed file paths must be strings')
|
|
19
|
+
return file.replaceAll('\\', '/').replace(/^(\.\/)+/, '')
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function isImportantFile(file) {
|
|
23
|
+
const path = normalizePath(file)
|
|
24
|
+
return importantPaths.has(path) || importantPrefixes.some(prefix => path.startsWith(prefix))
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function parseVersion(version) {
|
|
28
|
+
if (typeof version !== 'string') throw new Error(`Invalid version ${JSON.stringify(version)}: expected canonical SemVer`)
|
|
29
|
+
const match = semverPattern.exec(version)
|
|
30
|
+
if (!match) throw new Error(`Invalid version ${JSON.stringify(version)}: expected canonical SemVer`)
|
|
31
|
+
return {
|
|
32
|
+
major: BigInt(match[1]), minor: BigInt(match[2]), patch: BigInt(match[3]),
|
|
33
|
+
prerelease: match[4] === undefined ? [] : match[4].split('.'),
|
|
34
|
+
build: match[5] === undefined ? [] : match[5].split('.'),
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function compareVersions(left, right) {
|
|
39
|
+
const a = parseVersion(left)
|
|
40
|
+
const b = parseVersion(right)
|
|
41
|
+
for (const key of ['major', 'minor', 'patch']) {
|
|
42
|
+
if (a[key] !== b[key]) return a[key] > b[key] ? 1 : -1
|
|
43
|
+
}
|
|
44
|
+
if (a.prerelease.length === 0 || b.prerelease.length === 0) {
|
|
45
|
+
if (a.prerelease.length === b.prerelease.length) return 0
|
|
46
|
+
return a.prerelease.length === 0 ? 1 : -1
|
|
47
|
+
}
|
|
48
|
+
const length = Math.max(a.prerelease.length, b.prerelease.length)
|
|
49
|
+
for (let index = 0; index < length; index++) {
|
|
50
|
+
const leftId = a.prerelease[index]
|
|
51
|
+
const rightId = b.prerelease[index]
|
|
52
|
+
if (leftId === undefined || rightId === undefined) return leftId === undefined ? -1 : 1
|
|
53
|
+
if (leftId === rightId) continue
|
|
54
|
+
const leftNumeric = /^\d+$/.test(leftId)
|
|
55
|
+
const rightNumeric = /^\d+$/.test(rightId)
|
|
56
|
+
if (leftNumeric && rightNumeric) return BigInt(leftId) > BigInt(rightId) ? 1 : -1
|
|
57
|
+
if (leftNumeric !== rightNumeric) return leftNumeric ? -1 : 1
|
|
58
|
+
return leftId > rightId ? 1 : -1
|
|
59
|
+
}
|
|
60
|
+
return 0
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function isPrereleaseVersion(version) {
|
|
64
|
+
return parseVersion(version).prerelease.length > 0
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function assertDshVersionIdentity(version, engineVersion, baselineVersion) {
|
|
68
|
+
if (typeof engineVersion !== 'string' || typeof baselineVersion !== 'string') {
|
|
69
|
+
throw new Error('DSH version identity requires engines.dsh and the deployment baseline release')
|
|
70
|
+
}
|
|
71
|
+
if (engineVersion !== baselineVersion) {
|
|
72
|
+
throw new Error(`engines.dsh ${engineVersion} does not match deployment baseline ${baselineVersion}`)
|
|
73
|
+
}
|
|
74
|
+
const plugin = parseVersion(version)
|
|
75
|
+
const core = parseVersion(engineVersion)
|
|
76
|
+
if (plugin.build.length > 0 || core.build.length > 0) {
|
|
77
|
+
throw new Error('DSH version identity must not use build metadata')
|
|
78
|
+
}
|
|
79
|
+
if (plugin.major !== 0n || plugin.minor !== 1n || plugin.patch !== 0n
|
|
80
|
+
|| plugin.prerelease[0] !== 'alpha'
|
|
81
|
+
|| !/^[1-9]\d*$/.test(plugin.prerelease[1] ?? '')) {
|
|
82
|
+
throw new Error('exact-Core plugin versions must use 0.1.0-alpha.<positive iteration> before the DSH suffix')
|
|
83
|
+
}
|
|
84
|
+
const marker = plugin.prerelease.lastIndexOf('dsh')
|
|
85
|
+
if (marker !== 2) {
|
|
86
|
+
throw new Error('plugin prerelease must include its exact DSH Core version as a .dsh.<version> suffix')
|
|
87
|
+
}
|
|
88
|
+
const expected = ['dsh', core.major.toString(), core.minor.toString(), core.patch.toString(), ...core.prerelease].join('.')
|
|
89
|
+
const actual = plugin.prerelease.slice(marker).join('.')
|
|
90
|
+
if (actual !== expected) {
|
|
91
|
+
throw new Error(`plugin prerelease DSH suffix ${actual} does not match ${engineVersion}; expected ${expected}`)
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function assertReleaseLines(baseline) {
|
|
96
|
+
const lines = baseline?.releaseLines
|
|
97
|
+
if (!Array.isArray(lines) || lines.length === 0) throw new Error('Exact-Core release mapping is missing')
|
|
98
|
+
const cores = new Set()
|
|
99
|
+
const versions = new Set()
|
|
100
|
+
for (const line of lines) {
|
|
101
|
+
if (!line || !['published', 'pending'].includes(line.status)) throw new Error('Invalid release mapping status')
|
|
102
|
+
parseVersion(line.core)
|
|
103
|
+
parseVersion(line.version)
|
|
104
|
+
if (cores.has(line.core) || versions.has(line.version)) throw new Error('Duplicate release mapping')
|
|
105
|
+
cores.add(line.core)
|
|
106
|
+
versions.add(line.version)
|
|
107
|
+
if (parseVersion(line.version).prerelease.includes('dsh')) {
|
|
108
|
+
assertDshVersionIdentity(line.version, line.core, line.core)
|
|
109
|
+
} else if (line.status !== 'published') {
|
|
110
|
+
throw new Error('Only historical published anchors may omit the DSH suffix')
|
|
111
|
+
}
|
|
112
|
+
if (!baseline.supportedBaselines?.dsh?.baselines?.some(entry => entry.release === line.core)) {
|
|
113
|
+
throw new Error(`Release mapping has no exact Core baseline: ${line.core}`)
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
const current = lines.find(line => line.core === baseline.supportedBaselines?.dsh?.release)
|
|
117
|
+
if (current?.version !== baseline.package?.version) throw new Error('Current release mapping differs from package version')
|
|
118
|
+
return lines
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export function selectCoreRelease(baseline, core) {
|
|
122
|
+
parseVersion(core)
|
|
123
|
+
const line = assertReleaseLines(baseline).find(entry => entry.core === core)
|
|
124
|
+
if (!line) throw new Error(`No release mapping for exact DSH Core ${core}`)
|
|
125
|
+
return {
|
|
126
|
+
...line,
|
|
127
|
+
...(line.status === 'published' ? {
|
|
128
|
+
npmSpec: `${PACKAGE_NAME}@${line.version}`,
|
|
129
|
+
releaseUrl: `https://github.com/${REPOSITORY}/releases/tag/v${line.version}`,
|
|
130
|
+
archiveUrl: exactInstallUrl(line.version),
|
|
131
|
+
} : {}),
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export async function verifyCoreReleaseAvailability(baseline, core, { fetchImpl = fetch } = {}) {
|
|
136
|
+
const line = selectCoreRelease(baseline, core)
|
|
137
|
+
const version = line.version
|
|
138
|
+
const releaseResponse = await fetchImpl(
|
|
139
|
+
`https://api.github.com/repos/${REPOSITORY}/releases/tags/v${version}`,
|
|
140
|
+
{ headers: { accept: 'application/vnd.github+json' }, signal: AbortSignal.timeout(15_000) },
|
|
141
|
+
)
|
|
142
|
+
if (releaseResponse.status === 404) {
|
|
143
|
+
if (line.status === 'published') throw new Error(`Mapped GitHub Release v${version} is not observable`)
|
|
144
|
+
return { ...line, status: 'pending' }
|
|
145
|
+
}
|
|
146
|
+
if (!releaseResponse.ok) throw new Error(`GitHub Release lookup failed (${releaseResponse.status})`)
|
|
147
|
+
let release
|
|
148
|
+
try { release = await releaseResponse.json() } catch { throw new Error('GitHub Release metadata is invalid') }
|
|
149
|
+
if (release?.tag_name !== `v${version}` || release.draft !== false
|
|
150
|
+
|| release.prerelease !== isPrereleaseVersion(version)
|
|
151
|
+
|| !Array.isArray(release.assets)
|
|
152
|
+
|| !release.assets.some(asset => asset.name === `${PACKAGE_NAME}-${version}.tgz`)
|
|
153
|
+
|| !release.assets.some(asset => asset.name === 'SHA256SUMS')) {
|
|
154
|
+
throw new Error(`GitHub Release v${version} does not match the mapped published prerelease assets`)
|
|
155
|
+
}
|
|
156
|
+
const npmResponse = await fetchImpl(
|
|
157
|
+
`https://registry.npmjs.org/${PACKAGE_NAME}/${encodeURIComponent(version)}`,
|
|
158
|
+
{ signal: AbortSignal.timeout(15_000) },
|
|
159
|
+
)
|
|
160
|
+
if (npmResponse.status === 404) {
|
|
161
|
+
if (line.status === 'published') throw new Error(`Mapped npm version ${version} is not observable`)
|
|
162
|
+
return { ...line, status: 'incomplete' }
|
|
163
|
+
}
|
|
164
|
+
if (!npmResponse.ok) throw new Error(`npm version lookup failed (${npmResponse.status})`)
|
|
165
|
+
let npm
|
|
166
|
+
try { npm = await npmResponse.json() } catch { throw new Error('npm version metadata is invalid') }
|
|
167
|
+
if (npm?.name !== PACKAGE_NAME || npm.version !== version
|
|
168
|
+
|| npm.engines?.dsh !== core) {
|
|
169
|
+
throw new Error(`npm ${PACKAGE_NAME}@${version} does not verify exact DSH Core ${core}`)
|
|
170
|
+
}
|
|
171
|
+
return {
|
|
172
|
+
...line, status: 'published',
|
|
173
|
+
npmSpec: `${PACKAGE_NAME}@${version}`,
|
|
174
|
+
releaseUrl: `https://github.com/${REPOSITORY}/releases/tag/v${version}`,
|
|
175
|
+
archiveUrl: exactInstallUrl(version),
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function exactInstallUrl(version) {
|
|
180
|
+
return `https://github.com/${REPOSITORY}/releases/download/v${version}/${PACKAGE_NAME}-${version}.tgz`
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function assertReadmeMetadata(readme, label, version) {
|
|
184
|
+
const url = exactInstallUrl(version)
|
|
185
|
+
if (typeof readme !== 'string' || !readme.includes(url)) {
|
|
186
|
+
throw new Error(`${label} must include the exact release install URL ${url}`)
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export function assertReleaseMetadata({ version, readme, readmeZh, baseline, dshVersion, peers }) {
|
|
191
|
+
parseVersion(version)
|
|
192
|
+
assertReadmeMetadata(readme, 'README.md', version)
|
|
193
|
+
assertReadmeMetadata(readmeZh, 'README.zh.md', version)
|
|
194
|
+
if (!baseline || baseline.package?.name !== PACKAGE_NAME || baseline.package?.version !== version) {
|
|
195
|
+
throw new Error(`deployment-baseline.json package must identify ${PACKAGE_NAME} at version ${version}`)
|
|
196
|
+
}
|
|
197
|
+
if (baseline.baseline?.source !== `https://github.com/${REPOSITORY}`) {
|
|
198
|
+
throw new Error(`deployment-baseline.json baseline.source must be https://github.com/${REPOSITORY}`)
|
|
199
|
+
}
|
|
200
|
+
if (dshVersion !== undefined || baseline.supportedBaselines?.dsh?.release !== undefined) {
|
|
201
|
+
assertDshVersionIdentity(version, dshVersion, baseline.supportedBaselines?.dsh?.release)
|
|
202
|
+
assertReleaseLines(baseline)
|
|
203
|
+
for (const [name, range] of Object.entries(peers ?? {})) {
|
|
204
|
+
if (name.startsWith('@deepseek-ai/dsh-') && range !== dshVersion) {
|
|
205
|
+
throw new Error(`Core peer ${name} differs from exact engines.dsh ${dshVersion}`)
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export function assessChange({ baseManifest, manifest, files, readme, readmeZh, baseline }) {
|
|
212
|
+
if (manifest?.name !== PACKAGE_NAME || baseManifest?.name !== PACKAGE_NAME) {
|
|
213
|
+
throw new Error(`Both package manifests must identify ${PACKAGE_NAME}`)
|
|
214
|
+
}
|
|
215
|
+
const version = manifest.version
|
|
216
|
+
const comparison = compareVersions(version, baseManifest.version)
|
|
217
|
+
if (!Array.isArray(files)) throw new Error('Changed files must be an array')
|
|
218
|
+
const important = files.some(isImportantFile)
|
|
219
|
+
const newCoreLine = typeof manifest.engines?.dsh === 'string'
|
|
220
|
+
&& typeof baseManifest.engines?.dsh === 'string'
|
|
221
|
+
&& manifest.engines.dsh !== baseManifest.engines.dsh
|
|
222
|
+
if (newCoreLine) {
|
|
223
|
+
assertDshVersionIdentity(version, manifest.engines.dsh, baseline?.supportedBaselines?.dsh?.release)
|
|
224
|
+
const parsed = parseVersion(version)
|
|
225
|
+
if (parsed.major !== 0n || parsed.minor !== 1n || parsed.patch !== 0n
|
|
226
|
+
|| parsed.prerelease[0] !== 'alpha' || parsed.prerelease[1] !== '1') {
|
|
227
|
+
throw new Error('A new exact-Core line must start at 0.1.0-alpha.1.dsh.<exact Core>')
|
|
228
|
+
}
|
|
229
|
+
const lines = assertReleaseLines(baseline)
|
|
230
|
+
if (!lines.some(line => line.core === baseManifest.engines.dsh
|
|
231
|
+
&& line.version === baseManifest.version && line.status === 'published')) {
|
|
232
|
+
throw new Error('New Core line must preserve the previous published exact-Core anchor')
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
if (!newCoreLine && comparison < 0) throw new Error(`Version downgrade is forbidden: ${baseManifest.version} -> ${version}`)
|
|
236
|
+
if (important && !newCoreLine && comparison <= 0) {
|
|
237
|
+
throw new Error(`Important changes require a strictly newer SemVer than ${baseManifest.version}; update package.json, both READMEs, and deployment-baseline.json`)
|
|
238
|
+
}
|
|
239
|
+
const bumped = newCoreLine || comparison > 0
|
|
240
|
+
if (bumped || parseVersion(version).prerelease.includes('dsh')) assertReleaseMetadata({
|
|
241
|
+
version, readme, readmeZh, baseline, dshVersion: manifest.engines?.dsh, peers: manifest.peerDependencies,
|
|
242
|
+
})
|
|
243
|
+
return { important, bumped, version }
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function assertSha(sha, label) {
|
|
247
|
+
if (typeof sha !== 'string' || !/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(sha)) {
|
|
248
|
+
throw new Error(`${label} must resolve to a full Git commit SHA`)
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export function assessPlan({ manifest, head, tagInfo = null, files = [], githubRef = '' }) {
|
|
253
|
+
if (manifest?.name !== PACKAGE_NAME) throw new Error(`package.json must identify ${PACKAGE_NAME}`)
|
|
254
|
+
const version = manifest.version
|
|
255
|
+
parseVersion(version)
|
|
256
|
+
assertSha(head, 'HEAD')
|
|
257
|
+
const tag = `v${version}`
|
|
258
|
+
const recovery = githubRef.startsWith('refs/tags/')
|
|
259
|
+
if (recovery && githubRef !== `refs/tags/${tag}`) {
|
|
260
|
+
throw new Error(`Tag recovery requires GITHUB_REF refs/tags/${tag}; received ${githubRef}`)
|
|
261
|
+
}
|
|
262
|
+
if (tagInfo === null) {
|
|
263
|
+
if (recovery) throw new Error(`Tag recovery requires existing annotated tag ${tag} pointing to HEAD; fetch tags first`)
|
|
264
|
+
return { release: true, tag, sha: head, prerelease: isPrereleaseVersion(version) }
|
|
265
|
+
}
|
|
266
|
+
if (tagInfo.type !== 'tag') throw new Error(`${tag} must be an annotated tag; lightweight tags are not accepted`)
|
|
267
|
+
assertSha(tagInfo.sha, tag)
|
|
268
|
+
if (tagInfo.manifest?.name !== PACKAGE_NAME) throw new Error(`${tag} package.json must identify ${PACKAGE_NAME}`)
|
|
269
|
+
parseVersion(tagInfo.manifest.version)
|
|
270
|
+
if (tagInfo.manifest.version !== version) throw new Error(`${tag} package.json version ${tagInfo.manifest.version} does not match ${version}`)
|
|
271
|
+
if (tagInfo.sha === head) return { release: true, tag, sha: head, prerelease: isPrereleaseVersion(version) }
|
|
272
|
+
if (recovery) throw new Error(`Tag recovery requires ${tag} to point to HEAD (${head})`)
|
|
273
|
+
if (!Array.isArray(files)) throw new Error('Changed files must be an array')
|
|
274
|
+
if (files.some(isImportantFile)) {
|
|
275
|
+
throw new Error(`merged important changes lack a new version: ${tag} does not point to HEAD; bump package.json, both READMEs, and deployment-baseline.json`)
|
|
276
|
+
}
|
|
277
|
+
if (tagInfo.isAncestor !== true) throw new Error(`${tag} is not an ancestor of HEAD; fetch complete history and investigate the release tag`)
|
|
278
|
+
// Re-run publication against the exact tagged commit even when only docs/tests
|
|
279
|
+
// followed it. This reconciles a missing release, stranded draft, incomplete
|
|
280
|
+
// assets, or an uncertain prior write instead of silently treating a tag as
|
|
281
|
+
// proof that publication completed. An already immutable release is read-only.
|
|
282
|
+
return { release: true, tag, sha: tagInfo.sha, prerelease: isPrereleaseVersion(version) }
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
export function parseChangedFiles(output) {
|
|
286
|
+
if (output === '') return []
|
|
287
|
+
if (typeof output !== 'string' || !output.endsWith('\0')) throw new Error('Expected NUL-terminated git diff --name-only -z output')
|
|
288
|
+
return output.slice(0, -1).split('\0')
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
function parseJson(text, label) {
|
|
292
|
+
try { return JSON.parse(text) } catch (error) { throw new Error(`Cannot parse ${label}: ${error.message}`) }
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
export function runCli(args, {
|
|
296
|
+
cwd = process.cwd(), env = process.env,
|
|
297
|
+
git = argv => spawnSync('git', argv, { cwd, encoding: 'utf8', shell: false }),
|
|
298
|
+
appendOutput = (path, text) => appendFileSync(path, text, 'utf8'),
|
|
299
|
+
log = text => console.log(text),
|
|
300
|
+
} = {}) {
|
|
301
|
+
const planning = args.length === 1 && args[0] === '--plan'
|
|
302
|
+
const checking = args.length === 2 && args[0] === '--base'
|
|
303
|
+
if (!planning && !checking) throw new Error('Usage: node scripts/release-policy.mjs --base REF | --plan')
|
|
304
|
+
const base = checking ? args[1] : null
|
|
305
|
+
if (checking && (typeof base !== 'string' || !base || /^-/.test(base) || /[\0\r\n]/.test(base))) {
|
|
306
|
+
throw new Error('--base requires a non-option Git ref without NUL or line breaks')
|
|
307
|
+
}
|
|
308
|
+
const invokeGit = (argv, allowMissing = false) => {
|
|
309
|
+
const result = git(argv)
|
|
310
|
+
if (result.status === 0) return result.stdout ?? ''
|
|
311
|
+
if (allowMissing && result.status === 1) return null
|
|
312
|
+
const detail = result.error?.message || result.stderr?.trim() || `exit ${result.status}`
|
|
313
|
+
throw new Error(`git ${argv[0]} failed: ${detail}. Ensure the base ref, tags and complete history are fetched`)
|
|
314
|
+
}
|
|
315
|
+
const readHead = name => invokeGit(['show', `HEAD:${name}`])
|
|
316
|
+
const changedSince = ref => parseChangedFiles(invokeGit(['diff', '--name-only', '-z', '--no-renames', ref, 'HEAD', '--']))
|
|
317
|
+
const manifest = parseJson(readHead('package.json'), 'package.json')
|
|
318
|
+
let decision
|
|
319
|
+
if (checking) {
|
|
320
|
+
decision = assessChange({
|
|
321
|
+
baseManifest: parseJson(invokeGit(['show', `${base}:package.json`]), `${base}:package.json`),
|
|
322
|
+
manifest, files: changedSince(base), readme: readHead('README.md'), readmeZh: readHead('README.zh.md'),
|
|
323
|
+
baseline: parseJson(readHead('deployment-baseline.json'), 'deployment-baseline.json'),
|
|
324
|
+
})
|
|
325
|
+
} else {
|
|
326
|
+
const head = invokeGit(['rev-parse', '--verify', 'HEAD^{commit}']).trim()
|
|
327
|
+
const ref = `refs/tags/v${manifest.version}`
|
|
328
|
+
const exists = invokeGit(['show-ref', '--verify', '--quiet', ref], true) !== null
|
|
329
|
+
let tagInfo = null
|
|
330
|
+
let files = []
|
|
331
|
+
if (exists) {
|
|
332
|
+
const type = invokeGit(['cat-file', '-t', ref]).trim()
|
|
333
|
+
if (type !== 'tag') throw new Error(`${ref} must be an annotated tag; lightweight tags are not accepted`)
|
|
334
|
+
const sha = invokeGit(['rev-parse', '--verify', `${ref}^{commit}`]).trim()
|
|
335
|
+
tagInfo = {
|
|
336
|
+
type, sha, manifest: parseJson(invokeGit(['show', `${ref}:package.json`]), `${ref}:package.json`),
|
|
337
|
+
isAncestor: sha === head || invokeGit(['merge-base', '--is-ancestor', sha, head], true) !== null,
|
|
338
|
+
}
|
|
339
|
+
if (sha !== head) files = changedSince(sha)
|
|
340
|
+
}
|
|
341
|
+
decision = assessPlan({ manifest, head, tagInfo, files, githubRef: env.GITHUB_REF ?? '' })
|
|
342
|
+
if (env.GITHUB_OUTPUT) appendOutput(env.GITHUB_OUTPUT, `release=${decision.release}\ntag=${decision.tag}\nsha=${decision.sha}\nprerelease=${decision.prerelease}\n`)
|
|
343
|
+
}
|
|
344
|
+
log(JSON.stringify(decision))
|
|
345
|
+
return decision
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
349
|
+
try { runCli(process.argv.slice(2)) } catch (error) {
|
|
350
|
+
console.error(`Release policy: ${error.message}`)
|
|
351
|
+
process.exitCode = 1
|
|
352
|
+
}
|
|
353
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises'
|
|
2
|
+
import { verifyCoreReleaseAvailability } from './release-policy.mjs'
|
|
3
|
+
|
|
4
|
+
try {
|
|
5
|
+
if (process.argv.length !== 3) throw new Error('Usage: node scripts/select-core-release.mjs <exact DSH Core version>')
|
|
6
|
+
const baseline = JSON.parse(await readFile(new URL('../deployment-baseline.json', import.meta.url), 'utf8'))
|
|
7
|
+
console.log(JSON.stringify(await verifyCoreReleaseAvailability(baseline, process.argv[2])))
|
|
8
|
+
} catch (error) {
|
|
9
|
+
console.error(`Release selection: ${error.message}`)
|
|
10
|
+
process.exitCode = 1
|
|
11
|
+
}
|