@orkestrel/scaffold 0.0.134 → 0.0.135
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/dist/agents/skills/orkestrel-parallel/scripts/lane.js +610 -79
- package/dist/agents/skills/orkestrel-publish/scripts/wave.js +307 -16
- package/dist/bin/main.js +253 -35
- package/dist/bin/main.js.map +1 -1
- package/dist/host/AGENTS.md +1 -1
- package/dist/host/agents/skills/orkestrel-parallel/SKILL.md +1 -1
- package/dist/host/agents/skills/orkestrel-parallel/scripts/lane.ts +782 -115
- package/dist/host/agents/skills/orkestrel-publish/references/release.md +1 -0
- package/dist/host/agents/skills/orkestrel-publish/references/wave.md +22 -5
- package/dist/host/agents/skills/orkestrel-publish/scripts/wave.ts +379 -27
- package/dist/host/claude/agents/orkestrel.md +14 -14
- package/dist/host/claude/rules/architecture.md +1 -1
- package/dist/host/claude/rules/patterns.md +2 -0
- package/dist/host/claude/rules/workspace.md +64 -63
- package/dist/host/configs/helpers.ts +88 -67
- package/dist/host/dotfiles/oxlintrc.json +1 -57
- package/dist/host/guides/agent.md +989 -395
- package/dist/host/guides/database.md +357 -342
- package/dist/host/guides/middleware.md +5 -5
- package/dist/host/guides/ollama.md +41 -42
- package/dist/host/guides/scaffold.md +177 -105
- package/dist/host/guides/study.md +12 -12
- package/dist/host/guides/test.md +158 -46
- package/dist/host/guides/toolbox.md +127 -81
- package/dist/host/guides/workspace.md +21 -14
- package/dist/host/manifest.json +23 -23
- package/dist/host/tests/config.test.ts +166 -112
- package/dist/src/core/index.cjs +491 -195
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +217 -24
- package/dist/src/core/index.d.ts +217 -24
- package/dist/src/core/index.js +482 -193
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/server/index.cjs +18 -8
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.d.cts +4 -3
- package/dist/src/server/index.d.ts +4 -3
- package/dist/src/server/index.js +19 -9
- package/dist/src/server/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -29,6 +29,7 @@ When a consumer needs a dependency's unpublished source, to meet a defect that l
|
|
|
29
29
|
- A runtime `dependencies` bump reaches every consumer: each package downstream re-pins, re-runs its gates, bumps, and republishes in layer order.
|
|
30
30
|
- A development `devDependencies` bump reaches nobody: re-pin, prove the gates green, commit to `main`; do not bump or publish.
|
|
31
31
|
- A development bump that moves the published artifact is a runtime bump. Prove the direction with the build: rebuild after the re-pin and run `node .agents/skills/orkestrel-publish/scripts/compare.ts`, which compares `dist/` against the published tarball on material content only. Exit 3 bumps and publishes that package, and its dependents follow the runtime rule.
|
|
32
|
+
- A change that moves only comments, TSDoc, or a guide owes no release of its own, even when `compare.ts` exits 3. It ships with the package's next release that another change owes. Scaffold's vendored files follow § The scaffold surface instead.
|
|
32
33
|
- A `0.0.x` caret pins one exact release, so the fleet publishes in topological layer order derived from runtime `dependencies` and `peerDependencies` edges, never from a development edge.
|
|
33
34
|
- Read each package's version and layer from the catalog table in `.claude/agents/orkestrel.md`, refreshed per [wave.md](wave.md) § Prepare a layer before sequencing a cascade. Never write a second order elsewhere.
|
|
34
35
|
|
|
@@ -16,22 +16,39 @@ overwrite receipts are written only where the work tree ignores `tmp/`.
|
|
|
16
16
|
1. Re-pin every `dependencies` and `devDependencies` range the audit's release readings name to
|
|
17
17
|
the caret of its returned release, and install before the overwrite. Keep a published
|
|
18
18
|
`peerDependencies` range at the floor the release needs: raise it only when its floor fails the
|
|
19
|
-
release.
|
|
20
|
-
|
|
19
|
+
release. The floor fails when the declared range excludes the version the registry serves. Raise
|
|
20
|
+
it to the caret of that version, and leave a range the served version satisfies as declared. Read an
|
|
21
|
+
exact version, a caret, a tilde, and `||` arms of those; leave any other form as declared. Name
|
|
22
|
+
each peer raised or kept in the rewrite row, with the reason it was kept. Read the audit
|
|
23
|
+
population as the declared `@orkestrel`
|
|
21
24
|
dependencies in `dependencies` and `devDependencies`, plus declared foreign tools that the
|
|
22
25
|
blueprint plans in those sections; exclude the fixed showcase tool pair from ordinary release lookups.
|
|
23
26
|
Look up fleet releases with `*`; look up foreign tools with
|
|
24
27
|
a caret over the declared major when one can be extracted, otherwise with the declared range.
|
|
25
28
|
Do not treat a declared minor or patch bound as the lookup bound. A lookup skips a deprecated
|
|
26
|
-
version, and skips a version above `latest` when the range is `*` or sits in `latest`'s major.
|
|
29
|
+
version, and skips a version above `latest` when the range is `*` or sits in `latest`'s major.
|
|
30
|
+
A peer declared also as a dependency takes that dependency's reading. Peer-only dependencies
|
|
31
|
+
produce no audit reading, so the visit looks each one up with `npm view` under the same bounds:
|
|
32
|
+
a fleet package with `*`, and a foreign tool with a caret over its declared major, or with its
|
|
33
|
+
declared range when its arms span several majors. A peer-only reading moves `peerDependencies`
|
|
34
|
+
ranges alone and never a dependency range the audit did not read. When a lookup exits non-zero,
|
|
35
|
+
stop the step before the rewrite and the install. When a lookup exits 0 and serves no eligible
|
|
36
|
+
release, keep the peer and name it `no eligible release`. Offline, look up nothing and keep each
|
|
37
|
+
peer-only dependency as `no release reading`. When more than one arm of a peer range sits in the
|
|
38
|
+
release's major, keep the peer and name it `several arms in the major of` the release. A peer
|
|
39
|
+
whose arms span several majors and that no dependency reading names never rises, because its
|
|
40
|
+
own range bounds its lookup and admits every release the lookup serves.
|
|
27
41
|
For example, with a peer `vite: ^8.3.7` and a development `vite: ^8.3.7` whose registry serves
|
|
28
|
-
`8.3.8`, apply `vite: ^8.3.7 -> ^8.3.8` to the development range and leave the peer at `^8.3.7
|
|
42
|
+
`8.3.8`, apply `vite: ^8.3.7 -> ^8.3.8` to the development range and leave the peer at `^8.3.7`,
|
|
43
|
+
which admits `8.3.8`; with a peer `@orkestrel/database: ^0.0.23` whose registry serves `0.0.24`,
|
|
44
|
+
apply `^0.0.23 -> ^0.0.24` to the peer, because a `0.0.x` caret admits one release;
|
|
29
45
|
with a planned tool whose registry serves `8.3.4`, apply `vite: ~8.2.0 -> ^8.3.4` even though
|
|
30
46
|
the tilde excludes `8.3.4`.
|
|
31
47
|
Keep this pin step within each declared major; step 5 states the overwrite's lift.
|
|
32
48
|
A range joined by `||` names one supported major per
|
|
33
49
|
arm, so move only the arm in the release's major and keep every other arm: with
|
|
34
|
-
`vitest: ^4.1.11 || ^5.0.5` and a registry serving `4.1.12`, apply `^4.1.12 || ^5.0.5
|
|
50
|
+
`vitest: ^4.1.11 || ^5.0.5` and a registry serving `4.1.12`, apply `^4.1.12 || ^5.0.5` to a
|
|
51
|
+
dependency range; a peer `~4.1.11 || ^5.0.5` against `4.2.0` rises to `^4.2.0 || ^5.0.5`.
|
|
35
52
|
For a workspace whose selected framework activates a
|
|
36
53
|
`TOOLCHAIN_HOLDS` row, keep the tool within that range's major; read the audit question for its reason. Prove
|
|
37
54
|
that framework on the later major before lifting its hold.
|
|
@@ -3,10 +3,14 @@
|
|
|
3
3
|
// node .agents/skills/orkestrel-publish/scripts/wave.ts --plan [--catalog PATH] [--json]
|
|
4
4
|
// --visit runs the visit `wave.md` § Visit a repository fixes, in order, stopping at the first step
|
|
5
5
|
// that fails: pin (read `scaffold audit --json`, whose drift exit is the reading the pin closes, then
|
|
6
|
-
// re-pin every `dependencies` and `devDependencies` range the audit release readings name to the registry caret
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
6
|
+
// re-pin every `dependencies` and `devDependencies` range the audit release readings name to the registry caret,
|
|
7
|
+
// look up each peer-only dependency with `npm view` as the audit bounds a dependency, stopping when a lookup
|
|
8
|
+
// exits non-zero, raise a `peerDependencies` range from its reading, never a dependency range from a peer-only
|
|
9
|
+
// reading, to the caret of its served version only when the declared exact, caret, tilde, or `||` range excludes
|
|
10
|
+
// that version, moving the one arm in the release's major, keep every other peer as declared, including one with
|
|
11
|
+
// several arms in that major, no eligible release, or no reading offline, and one spanning several majors whose
|
|
12
|
+
// lookup bound is its own range and never rises, name each peer raised or kept in the rewrite row, and install),
|
|
13
|
+
// commit (`git commit --only` of
|
|
10
14
|
// the manifest and lockfile as the preparation commit), overwrite (`scaffold overwrite --json`, then
|
|
11
15
|
// `scaffold audit` exiting 0; offline, an exit of 1 whose note names the skipped catalog step is
|
|
12
16
|
// accepted; on @orkestrel/scaffold itself both are skipped with a note, because the vendored host
|
|
@@ -226,12 +230,38 @@ export interface RangeMove {
|
|
|
226
230
|
readonly moved: readonly string[]
|
|
227
231
|
}
|
|
228
232
|
|
|
229
|
-
/** Describes a manifest re-pin: the ranges it moved and the
|
|
233
|
+
/** Describes a manifest re-pin: the ranges it moved, raised peers included, and the peers it kept. */
|
|
230
234
|
export interface Rewrite {
|
|
231
235
|
readonly moved: readonly string[]
|
|
232
236
|
readonly kept: readonly string[]
|
|
233
237
|
}
|
|
234
238
|
|
|
239
|
+
/** Describes one manifest field after a re-pin: its moves and the peer messages it kept. */
|
|
240
|
+
export interface FieldMove {
|
|
241
|
+
readonly field: string
|
|
242
|
+
readonly moves: RangeMove
|
|
243
|
+
readonly kept: readonly string[]
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/** Describes the versions one `||` arm of a range admits, from `floor` up to but excluding `ceiling`. */
|
|
247
|
+
export interface RangeArm {
|
|
248
|
+
readonly floor: readonly [number, number, number]
|
|
249
|
+
readonly ceiling: readonly [number, number, number]
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/** Describes the decision on one peer range: the range after it, its rewrite message, and whether it rose. */
|
|
253
|
+
export interface PeerMove {
|
|
254
|
+
readonly range: string
|
|
255
|
+
readonly message: string
|
|
256
|
+
readonly raised: boolean
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/** Describes the registry lookup a peer-only dependency needs: its name and the lookup bound. */
|
|
260
|
+
export interface PeerLookup {
|
|
261
|
+
readonly name: string
|
|
262
|
+
readonly bound: string
|
|
263
|
+
}
|
|
264
|
+
|
|
235
265
|
/** Describes the bump ruling a visit reaches. */
|
|
236
266
|
export interface Ruling {
|
|
237
267
|
readonly distMoved: boolean | undefined
|
|
@@ -1535,6 +1565,246 @@ export function runFormat(runner: Runner): FormatReceipt | undefined {
|
|
|
1535
1565
|
}
|
|
1536
1566
|
}
|
|
1537
1567
|
|
|
1568
|
+
/**
|
|
1569
|
+
* Parses a whole text as one JSON object or a list of JSON objects.
|
|
1570
|
+
*
|
|
1571
|
+
* @param text - A JSON document, such as `npm view NAME@RANGE FIELD --json` output, which prints one
|
|
1572
|
+
* record for one match and a list for several.
|
|
1573
|
+
* @returns Each object the document carries, or none when the text is not JSON.
|
|
1574
|
+
*/
|
|
1575
|
+
export function parseJsonRecords(text: string): ReadonlyArray<Record<string, unknown>> {
|
|
1576
|
+
try {
|
|
1577
|
+
const parsed: unknown = JSON.parse(text)
|
|
1578
|
+
return (Array.isArray(parsed) ? parsed : [parsed])
|
|
1579
|
+
.filter(isRecord)
|
|
1580
|
+
.map((entry) => Object.fromEntries(Object.entries(entry)))
|
|
1581
|
+
} catch {
|
|
1582
|
+
return []
|
|
1583
|
+
}
|
|
1584
|
+
}
|
|
1585
|
+
|
|
1586
|
+
/**
|
|
1587
|
+
* Parses the major, minor, and patch numbers of a plain `major.minor.patch` version.
|
|
1588
|
+
*
|
|
1589
|
+
* @param text - The version text.
|
|
1590
|
+
* @returns The three numbers, or undefined when the text carries a prefix, a prerelease, or any
|
|
1591
|
+
* other form.
|
|
1592
|
+
* @example
|
|
1593
|
+
* ```ts
|
|
1594
|
+
* parseVersion('8.3.8') // [8, 3, 8]
|
|
1595
|
+
* parseVersion('8.3.8-beta.1') // undefined
|
|
1596
|
+
* ```
|
|
1597
|
+
*/
|
|
1598
|
+
export function parseVersion(text: string): readonly [number, number, number] | undefined {
|
|
1599
|
+
const match = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/u.exec(text)
|
|
1600
|
+
if (match === null) return undefined
|
|
1601
|
+
return [Number(match[1]), Number(match[2]), Number(match[3])]
|
|
1602
|
+
}
|
|
1603
|
+
|
|
1604
|
+
/**
|
|
1605
|
+
* Compares two plain versions by their major, minor, and patch numbers.
|
|
1606
|
+
*
|
|
1607
|
+
* @param left - The version ordered first when it compares lower.
|
|
1608
|
+
* @param right - The version it is compared with.
|
|
1609
|
+
* @returns A negative number when `left` is lower, zero when equal, and a positive number when higher.
|
|
1610
|
+
* @example
|
|
1611
|
+
* ```ts
|
|
1612
|
+
* compareVersions([0, 0, 23], [0, 0, 24]) // -1
|
|
1613
|
+
* ```
|
|
1614
|
+
*/
|
|
1615
|
+
export function compareVersions(
|
|
1616
|
+
left: readonly [number, number, number],
|
|
1617
|
+
right: readonly [number, number, number],
|
|
1618
|
+
): number {
|
|
1619
|
+
return left[0] - right[0] || left[1] - right[1] || left[2] - right[2]
|
|
1620
|
+
}
|
|
1621
|
+
|
|
1622
|
+
/**
|
|
1623
|
+
* Parses a declared range as the half-open version intervals its `||` arms admit.
|
|
1624
|
+
*
|
|
1625
|
+
* @remarks
|
|
1626
|
+
* An arm is an exact `major.minor.patch` version, a caret, or a tilde over one. A caret admits up to
|
|
1627
|
+
* the next major, the next minor under major 0, and the next patch under `0.0`; a tilde admits up to
|
|
1628
|
+
* the next minor. Any other form, an empty arm included, makes the whole range unreadable.
|
|
1629
|
+
*
|
|
1630
|
+
* @param range - The declared range.
|
|
1631
|
+
* @returns One interval per arm, with an inclusive `floor` and an exclusive `ceiling`, or undefined
|
|
1632
|
+
* when an arm is outside those forms.
|
|
1633
|
+
* @example
|
|
1634
|
+
* ```ts
|
|
1635
|
+
* parseRange('^0.0.23') // [{ floor: [0, 0, 23], ceiling: [0, 0, 24] }]
|
|
1636
|
+
* parseRange('>=8') // undefined
|
|
1637
|
+
* ```
|
|
1638
|
+
*/
|
|
1639
|
+
export function parseRange(range: string): readonly RangeArm[] | undefined {
|
|
1640
|
+
const arms = range.trim().split(/\s*\|\|\s*/u)
|
|
1641
|
+
const parsed = arms.flatMap((arm): readonly RangeArm[] => {
|
|
1642
|
+
const match = /^([\^~]?)(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/u.exec(arm)
|
|
1643
|
+
if (match === null) return []
|
|
1644
|
+
const major = Number(match[2])
|
|
1645
|
+
const minor = Number(match[3])
|
|
1646
|
+
const patch = Number(match[4])
|
|
1647
|
+
const ceiling: readonly [number, number, number] =
|
|
1648
|
+
match[1] === '~'
|
|
1649
|
+
? [major, minor + 1, 0]
|
|
1650
|
+
: match[1] === ''
|
|
1651
|
+
? [major, minor, patch + 1]
|
|
1652
|
+
: major > 0
|
|
1653
|
+
? [major + 1, 0, 0]
|
|
1654
|
+
: minor > 0
|
|
1655
|
+
? [0, minor + 1, 0]
|
|
1656
|
+
: [0, 0, patch + 1]
|
|
1657
|
+
return [{ floor: [major, minor, patch], ceiling }]
|
|
1658
|
+
})
|
|
1659
|
+
return parsed.length === arms.length ? parsed : undefined
|
|
1660
|
+
}
|
|
1661
|
+
|
|
1662
|
+
/**
|
|
1663
|
+
* Computes whether a declared range admits a plain version.
|
|
1664
|
+
*
|
|
1665
|
+
* @param range - The declared range, in a form {@link parseRange} reads.
|
|
1666
|
+
* @param version - The plain version.
|
|
1667
|
+
* @returns True if an arm admits the version, false if none does, and undefined when the range or
|
|
1668
|
+
* the version is unreadable.
|
|
1669
|
+
* @example
|
|
1670
|
+
* ```ts
|
|
1671
|
+
* computeSatisfaction('^8.3.7', '8.3.8') // true
|
|
1672
|
+
* computeSatisfaction('^0.0.23', '0.0.24') // false
|
|
1673
|
+
* computeSatisfaction('*', '1.0.0') // undefined
|
|
1674
|
+
* ```
|
|
1675
|
+
*/
|
|
1676
|
+
export function computeSatisfaction(range: string, version: string): boolean | undefined {
|
|
1677
|
+
const arms = parseRange(range)
|
|
1678
|
+
const parsed = parseVersion(version)
|
|
1679
|
+
if (arms === undefined || parsed === undefined) return undefined
|
|
1680
|
+
return arms.some(
|
|
1681
|
+
(arm) => compareVersions(arm.floor, parsed) <= 0 && compareVersions(parsed, arm.ceiling) < 0,
|
|
1682
|
+
)
|
|
1683
|
+
}
|
|
1684
|
+
|
|
1685
|
+
/**
|
|
1686
|
+
* Raises one declared peer range whose floor fails the served release, and words the decision.
|
|
1687
|
+
*
|
|
1688
|
+
* @remarks
|
|
1689
|
+
* A range the served version satisfies stays as declared. A failing range moves per
|
|
1690
|
+
* {@link moveRange}: the one arm in the release's major becomes the caret of the release. A range
|
|
1691
|
+
* that is unreadable, carries no arm or several arms in that major, or whose arm in that major opens
|
|
1692
|
+
* above the release stays as declared, and the message names why. A reading that names the peer and
|
|
1693
|
+
* carries no release keeps it as `no eligible release`; no reading keeps it as `no release reading`.
|
|
1694
|
+
*
|
|
1695
|
+
* @param name - The peer's package name.
|
|
1696
|
+
* @param range - The declared peer range.
|
|
1697
|
+
* @param reading - The release reading that names the peer, or undefined when none does.
|
|
1698
|
+
* @returns The range after the decision and the rewrite row message: `peer NAME OLD -> NEW` when it
|
|
1699
|
+
* rose, `peer NAME OLD kept, REASON` otherwise.
|
|
1700
|
+
* @example
|
|
1701
|
+
* ```ts
|
|
1702
|
+
* raisePeer('@orkestrel/database', '^0.0.23', { name: '@orkestrel/database', range: '*', latest: '0.0.24' })
|
|
1703
|
+
* // { range: '^0.0.24', message: 'peer @orkestrel/database ^0.0.23 -> ^0.0.24', raised: true }
|
|
1704
|
+
* ```
|
|
1705
|
+
*/
|
|
1706
|
+
export function raisePeer(name: string, range: string, reading: Release | undefined): PeerMove {
|
|
1707
|
+
const arms = parseRange(range)
|
|
1708
|
+
const latest = reading?.latest
|
|
1709
|
+
const version = latest === undefined ? undefined : parseVersion(latest)
|
|
1710
|
+
const matched =
|
|
1711
|
+
version === undefined ? [] : (arms ?? []).filter((entry) => entry.floor[0] === version[0])
|
|
1712
|
+
const reason =
|
|
1713
|
+
arms === undefined
|
|
1714
|
+
? 'unreadable range'
|
|
1715
|
+
: reading === undefined
|
|
1716
|
+
? 'no release reading'
|
|
1717
|
+
: latest === undefined
|
|
1718
|
+
? 'no eligible release'
|
|
1719
|
+
: version === undefined
|
|
1720
|
+
? `unreadable release ${latest}`
|
|
1721
|
+
: computeSatisfaction(range, latest) === true
|
|
1722
|
+
? `admits ${latest}`
|
|
1723
|
+
: matched.length === 0
|
|
1724
|
+
? `no arm in the major of ${latest}`
|
|
1725
|
+
: matched.length > 1
|
|
1726
|
+
? `several arms in the major of ${latest}`
|
|
1727
|
+
: matched.some((arm) => compareVersions(arm.floor, version) > 0)
|
|
1728
|
+
? `its floor is above ${latest}`
|
|
1729
|
+
: undefined
|
|
1730
|
+
if (reason !== undefined || latest === undefined)
|
|
1731
|
+
return { range, message: `peer ${name} ${range} kept, ${String(reason)}`, raised: false }
|
|
1732
|
+
const next = String(moveRange(range, latest))
|
|
1733
|
+
return { range: next, message: `peer ${name} ${range} -> ${next}`, raised: true }
|
|
1734
|
+
}
|
|
1735
|
+
|
|
1736
|
+
/**
|
|
1737
|
+
* Collects the registry lookup each peer-only dependency needs for its release reading.
|
|
1738
|
+
*
|
|
1739
|
+
* @remarks
|
|
1740
|
+
* A peer a release reading already names, such as one also declared under `devDependencies`, takes
|
|
1741
|
+
* that reading. A peer whose range {@link parseRange} cannot read needs no reading. A fleet package
|
|
1742
|
+
* is looked up with `*`, and a foreign tool with a caret over its declared major, or with the
|
|
1743
|
+
* declared range when its arms span several majors, as the audit bounds a dependency. A range bound
|
|
1744
|
+
* by itself admits every release its lookup serves, so such a peer never rises.
|
|
1745
|
+
*
|
|
1746
|
+
* @param manifest - The manifest record.
|
|
1747
|
+
* @param releases - The audit's release readings.
|
|
1748
|
+
* @returns One lookup per peer-only dependency, in declaration order.
|
|
1749
|
+
* @example
|
|
1750
|
+
* ```ts
|
|
1751
|
+
* collectPeerLookups({ peerDependencies: { vite: '^8.3.7' } }, [])
|
|
1752
|
+
* // [{ name: 'vite', bound: '^8' }]
|
|
1753
|
+
* ```
|
|
1754
|
+
*/
|
|
1755
|
+
export function collectPeerLookups(
|
|
1756
|
+
manifest: Record<string, unknown>,
|
|
1757
|
+
releases: readonly Release[],
|
|
1758
|
+
): readonly PeerLookup[] {
|
|
1759
|
+
const named = new Set(releases.map((release) => release.name))
|
|
1760
|
+
const block = manifest.peerDependencies
|
|
1761
|
+
if (typeof block !== 'object' || block === null) return []
|
|
1762
|
+
return Object.entries(block).flatMap(([name, range]): readonly PeerLookup[] => {
|
|
1763
|
+
if (typeof range !== 'string' || named.has(name)) return []
|
|
1764
|
+
const majors = [...new Set(parseRange(range)?.map((arm) => arm.floor[0]))]
|
|
1765
|
+
if (majors.length === 0) return []
|
|
1766
|
+
const bound = name.startsWith('@orkestrel/')
|
|
1767
|
+
? '*'
|
|
1768
|
+
: majors.length === 1
|
|
1769
|
+
? `^${String(majors[0])}`
|
|
1770
|
+
: range
|
|
1771
|
+
return [{ name, bound }]
|
|
1772
|
+
})
|
|
1773
|
+
}
|
|
1774
|
+
|
|
1775
|
+
/**
|
|
1776
|
+
* Reads the release a registry lookup serves out of the output of
|
|
1777
|
+
* `npm view NAME@BOUND version deprecated dist-tags.latest --json`.
|
|
1778
|
+
*
|
|
1779
|
+
* @remarks
|
|
1780
|
+
* The reading skips a deprecated version, a version outside the plain `major.minor.patch` form, and
|
|
1781
|
+
* a version above `latest` when the bound is `*` or the caret of `latest`'s major, then takes the
|
|
1782
|
+
* highest, as the audit's lookup does.
|
|
1783
|
+
*
|
|
1784
|
+
* @param text - The command's standard output.
|
|
1785
|
+
* @param bound - The lookup bound.
|
|
1786
|
+
* @returns The served version, or undefined when no version is eligible or the output is unreadable.
|
|
1787
|
+
* @example
|
|
1788
|
+
* ```ts
|
|
1789
|
+
* readServedVersion('{"version":"0.0.24","dist-tags.latest":"0.0.24"}', '*') // '0.0.24'
|
|
1790
|
+
* ```
|
|
1791
|
+
*/
|
|
1792
|
+
export function readServedVersion(text: string, bound: string): string | undefined {
|
|
1793
|
+
const eligible = parseJsonRecords(text).flatMap((entry) => {
|
|
1794
|
+
const version = readString(entry, 'version') ?? ''
|
|
1795
|
+
const plain = parseVersion(version)
|
|
1796
|
+
const deprecated = readString(entry, 'deprecated') ?? ''
|
|
1797
|
+
const latest = parseVersion(readString(entry, 'dist-tags.latest') ?? '')
|
|
1798
|
+
if (plain === undefined || deprecated.length > 0) return []
|
|
1799
|
+
const capped =
|
|
1800
|
+
latest !== undefined && (bound === '*' || bound === `^${String(latest[0])}`)
|
|
1801
|
+
? compareVersions(plain, latest) <= 0
|
|
1802
|
+
: true
|
|
1803
|
+
return capped ? [{ version, plain }] : []
|
|
1804
|
+
})
|
|
1805
|
+
return eligible.toSorted((left, right) => compareVersions(right.plain, left.plain))[0]?.version
|
|
1806
|
+
}
|
|
1807
|
+
|
|
1538
1808
|
/**
|
|
1539
1809
|
* Moves one declared range to the registry caret of a release, keeping every other major a
|
|
1540
1810
|
* disjunctive range admits.
|
|
@@ -1597,56 +1867,107 @@ export function computeRanges(
|
|
|
1597
1867
|
}
|
|
1598
1868
|
|
|
1599
1869
|
/**
|
|
1600
|
-
* Writes the re-pinned ranges into the target's manifest,
|
|
1870
|
+
* Writes the re-pinned ranges into the target's manifest, raising each peer range whose floor fails
|
|
1871
|
+
* its release.
|
|
1601
1872
|
*
|
|
1602
1873
|
* @remarks
|
|
1603
|
-
* A `
|
|
1604
|
-
*
|
|
1605
|
-
*
|
|
1874
|
+
* A `dependencies` or `devDependencies` range moves per {@link computeRanges} over the audit's
|
|
1875
|
+
* readings alone. A `peerDependencies` range takes the last audit reading that names it with a
|
|
1876
|
+
* release, else its peer-only reading, and moves per {@link raisePeer}: it rises to the caret of the
|
|
1877
|
+
* served version only when the declared range excludes that version, and otherwise stays as
|
|
1878
|
+
* declared. Every raised peer joins the moved list and every other peer is reported as kept.
|
|
1606
1879
|
*
|
|
1607
1880
|
* @param target - The target directory.
|
|
1608
1881
|
* @param releases - The audit's release readings.
|
|
1882
|
+
* @param peers - The peer-only readings, which move `peerDependencies` ranges alone. Default: none.
|
|
1609
1883
|
* @returns One message per range moved and one per peer range kept; the manifest is rewritten only
|
|
1610
1884
|
* when a range moved.
|
|
1611
1885
|
* @example
|
|
1612
1886
|
* ```ts
|
|
1613
1887
|
* writeRanges('.', [{ name: 'vite', range: '^8', latest: '8.3.8' }])
|
|
1614
|
-
* // { moved: ['vite ^8.3.7 -> ^8.3.8'], kept: ['peer vite ^8.3.7
|
|
1888
|
+
* // { moved: ['vite ^8.3.7 -> ^8.3.8'], kept: ['peer vite ^8.3.7 kept, admits 8.3.8'] }
|
|
1615
1889
|
* ```
|
|
1616
1890
|
*/
|
|
1617
|
-
export function writeRanges(
|
|
1891
|
+
export function writeRanges(
|
|
1892
|
+
target: string,
|
|
1893
|
+
releases: readonly Release[],
|
|
1894
|
+
peers: readonly Release[] = [],
|
|
1895
|
+
): Rewrite {
|
|
1618
1896
|
const manifest = readManifest(target)
|
|
1619
1897
|
if (manifest === undefined) return { moved: [], kept: [] }
|
|
1620
|
-
const fields = RANGE_FIELDS.flatMap((field) => {
|
|
1898
|
+
const fields = RANGE_FIELDS.flatMap((field): readonly FieldMove[] => {
|
|
1621
1899
|
const block = manifest[field]
|
|
1622
1900
|
if (typeof block !== 'object' || block === null) return []
|
|
1623
1901
|
const ranges = Object.fromEntries(Object.entries(block))
|
|
1624
|
-
|
|
1902
|
+
if (field !== 'peerDependencies')
|
|
1903
|
+
return [{ field, moves: computeRanges(ranges, releases), kept: [] }]
|
|
1904
|
+
const decisions = Object.entries(ranges).flatMap(([name, range]) =>
|
|
1905
|
+
typeof range === 'string'
|
|
1906
|
+
? [
|
|
1907
|
+
[
|
|
1908
|
+
name,
|
|
1909
|
+
raisePeer(
|
|
1910
|
+
name,
|
|
1911
|
+
range,
|
|
1912
|
+
releases.findLast(
|
|
1913
|
+
(release) => release.name === name && release.latest !== undefined,
|
|
1914
|
+
) ?? peers.findLast((release) => release.name === name),
|
|
1915
|
+
),
|
|
1916
|
+
] as const,
|
|
1917
|
+
]
|
|
1918
|
+
: [],
|
|
1919
|
+
)
|
|
1920
|
+
return [
|
|
1921
|
+
{
|
|
1922
|
+
field,
|
|
1923
|
+
moves: {
|
|
1924
|
+
ranges: {
|
|
1925
|
+
...ranges,
|
|
1926
|
+
...Object.fromEntries(decisions.map(([name, peer]) => [name, peer.range])),
|
|
1927
|
+
},
|
|
1928
|
+
moved: decisions.flatMap(([, peer]) => (peer.raised ? [peer.message] : [])),
|
|
1929
|
+
},
|
|
1930
|
+
kept: decisions.flatMap(([, peer]) => (peer.raised ? [] : [peer.message])),
|
|
1931
|
+
},
|
|
1932
|
+
]
|
|
1625
1933
|
})
|
|
1626
|
-
const
|
|
1627
|
-
const kept = peers.flatMap((entry) =>
|
|
1628
|
-
Object.entries(entry.ranges)
|
|
1629
|
-
.filter(([name, range]) => entry.moves.ranges[name] !== range)
|
|
1630
|
-
.map(
|
|
1631
|
-
([name, range]) =>
|
|
1632
|
-
`peer ${name} ${String(range)} left alone, not ${String(entry.moves.ranges[name])}`,
|
|
1633
|
-
),
|
|
1634
|
-
)
|
|
1635
|
-
const pinned = fields.filter((entry) => entry.field !== 'peerDependencies')
|
|
1636
|
-
const moved = pinned.flatMap((entry) => entry.moves.moved)
|
|
1934
|
+
const moved = fields.flatMap((entry) => entry.moves.moved)
|
|
1637
1935
|
if (moved.length > 0) {
|
|
1638
1936
|
const written = {
|
|
1639
1937
|
...manifest,
|
|
1640
|
-
...Object.fromEntries(
|
|
1938
|
+
...Object.fromEntries(fields.map((entry) => [entry.field, entry.moves.ranges])),
|
|
1641
1939
|
}
|
|
1642
1940
|
writeFileSync(join(target, 'package.json'), `${JSON.stringify(written, null, '\t')}\n`)
|
|
1643
1941
|
}
|
|
1644
|
-
return { moved, kept }
|
|
1942
|
+
return { moved, kept: fields.flatMap((entry) => entry.kept) }
|
|
1943
|
+
}
|
|
1944
|
+
|
|
1945
|
+
/**
|
|
1946
|
+
* Judges one peer-only release lookup.
|
|
1947
|
+
*
|
|
1948
|
+
* @param result - The `npm view NAME@BOUND version deprecated dist-tags.latest --json` command.
|
|
1949
|
+
* @param bound - The lookup bound.
|
|
1950
|
+
* @returns Exit 0 naming the served version, or naming that no release within the bound is
|
|
1951
|
+
* eligible, when the lookup exited 0; else the lookup's failing exit and its reason.
|
|
1952
|
+
*/
|
|
1953
|
+
export function judgeLookup(result: SpawnSyncReturns<string>, bound: string): Verdict {
|
|
1954
|
+
if (result.status !== 0) return readVerdict(result)
|
|
1955
|
+
const served = readServedVersion(result.stdout, bound)
|
|
1956
|
+
return {
|
|
1957
|
+
exit: 0,
|
|
1958
|
+
note: served === undefined ? `no eligible release within ${bound}` : `serves ${served}`,
|
|
1959
|
+
}
|
|
1645
1960
|
}
|
|
1646
1961
|
|
|
1647
1962
|
/**
|
|
1648
1963
|
* Runs the pin step.
|
|
1649
1964
|
*
|
|
1965
|
+
* @remarks
|
|
1966
|
+
* A peer-only dependency produces no audit release reading, so the step looks each one up with
|
|
1967
|
+
* `npm view`, per {@link collectPeerLookups}, before the rewrite, and stops before the rewrite and
|
|
1968
|
+
* the install when a lookup exits non-zero. A lookup that exits 0 with no eligible release keeps
|
|
1969
|
+
* its peer. Offline, it looks up none and the rewrite keeps those peers as declared.
|
|
1970
|
+
*
|
|
1650
1971
|
* @param runner - The visit's state.
|
|
1651
1972
|
* @param scaffoldFile - The scaffold executable.
|
|
1652
1973
|
* @param scaffoldPrefix - The arguments that precede scaffold's own.
|
|
@@ -1670,7 +1991,38 @@ export function runPin(
|
|
|
1670
1991
|
if (audit !== undefined) {
|
|
1671
1992
|
const releases = readReleases(audit.stdout)
|
|
1672
1993
|
if (releases === undefined || (audit.status !== 0 && audit.status !== 1)) return
|
|
1673
|
-
const
|
|
1994
|
+
const lookups = collectPeerLookups(readManifest(runner.target) ?? {}, releases)
|
|
1995
|
+
if (runner.offline && lookups.length > 0)
|
|
1996
|
+
appendStep(
|
|
1997
|
+
runner,
|
|
1998
|
+
'pin',
|
|
1999
|
+
'npm view',
|
|
2000
|
+
`offline: no peer-only lookup for ${lookups.map((lookup) => lookup.name).join(', ')}`,
|
|
2001
|
+
)
|
|
2002
|
+
const readings = (runner.offline ? [] : lookups).map((lookup): Release | undefined => {
|
|
2003
|
+
const view = runNpmStep(
|
|
2004
|
+
runner,
|
|
2005
|
+
'pin',
|
|
2006
|
+
[
|
|
2007
|
+
'view',
|
|
2008
|
+
`${lookup.name}@${lookup.bound}`,
|
|
2009
|
+
'version',
|
|
2010
|
+
'deprecated',
|
|
2011
|
+
'dist-tags.latest',
|
|
2012
|
+
'--json',
|
|
2013
|
+
],
|
|
2014
|
+
(result) => judgeLookup(result, lookup.bound),
|
|
2015
|
+
)
|
|
2016
|
+
if (view?.status !== 0) return undefined
|
|
2017
|
+
const latest = readServedVersion(view.stdout, lookup.bound)
|
|
2018
|
+
return { name: lookup.name, range: lookup.bound, latest }
|
|
2019
|
+
})
|
|
2020
|
+
if (readings.includes(undefined)) return
|
|
2021
|
+
const { moved, kept } = writeRanges(
|
|
2022
|
+
runner.target,
|
|
2023
|
+
releases,
|
|
2024
|
+
readings.filter((reading) => reading !== undefined),
|
|
2025
|
+
)
|
|
1674
2026
|
appendStep(
|
|
1675
2027
|
runner,
|
|
1676
2028
|
'pin',
|