@vzn/vx 0.0.334 → 0.0.336
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/README.md +2 -0
- package/package.json +5 -5
- package/src/orchestrator/persistent.ts +11 -7
- package/src/orchestrator/projects.ts +2 -2
- package/src/workspace/index.ts +1 -1
- package/src/workspace/lockfile.ts +63 -21
package/README.md
CHANGED
|
@@ -205,6 +205,8 @@ machine.
|
|
|
205
205
|
| [`@vzn/vx-mcp`](packages/vx-mcp) | `vx mcp`: a read-only MCP server for AI coding agents |
|
|
206
206
|
| [`@vzn/vx-schedule-history`](packages/vx-schedule-history) | Schedule by the critical path learned from past runs |
|
|
207
207
|
|
|
208
|
+
Only `@vzn/vx` is on npm today; the plugins' first publish is pending.
|
|
209
|
+
|
|
208
210
|
Write your own: [plugin guide](https://vznjs.github.io/vx/guides/plugins/) ·
|
|
209
211
|
[architecture](packages/vx/docs/architecture.md).
|
|
210
212
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vzn/vx",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.336",
|
|
4
4
|
"description": "A fast, correct task runner and build cache for JavaScript monorepos.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
"node": ">=18"
|
|
22
22
|
},
|
|
23
23
|
"optionalDependencies": {
|
|
24
|
-
"@vzn/vx-linux-x64": "0.0.
|
|
25
|
-
"@vzn/vx-linux-arm64": "0.0.
|
|
26
|
-
"@vzn/vx-darwin-x64": "0.0.
|
|
27
|
-
"@vzn/vx-darwin-arm64": "0.0.
|
|
24
|
+
"@vzn/vx-linux-x64": "0.0.336",
|
|
25
|
+
"@vzn/vx-linux-arm64": "0.0.336",
|
|
26
|
+
"@vzn/vx-darwin-x64": "0.0.336",
|
|
27
|
+
"@vzn/vx-darwin-arm64": "0.0.336"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@anthropic-ai/sandbox-runtime": "^0.0.76"
|
|
@@ -25,8 +25,8 @@ export interface KeepAlive {
|
|
|
25
25
|
/**
|
|
26
26
|
* A persistent task the user REQUESTED (or one surfaced for display) is the
|
|
27
27
|
* run's whole purpose — it is left running and blocked on at the very end,
|
|
28
|
-
* after the summary. So is every persistent task a
|
|
29
|
-
* directly or through groups: `vx run dev --filter app` stopped the api#dev
|
|
28
|
+
* after the summary. So is every persistent task a requested group stands
|
|
29
|
+
* for, and every one a kept one depends on, directly or through groups: `vx run dev --filter app` stopped the api#dev
|
|
30
30
|
* its app#dev was started against (C-46). A one-shot's persistent deps are
|
|
31
31
|
* not kept on its account; it has finished with them. Only in the real CLI
|
|
32
32
|
* foreground: a custom logger or `handleSignals: false` (watch mode,
|
|
@@ -38,11 +38,15 @@ export function selectKeepAlive(
|
|
|
38
38
|
foreground: boolean,
|
|
39
39
|
): KeepAlive {
|
|
40
40
|
const out: KeepAlive = { nodes: [], children: [] }
|
|
41
|
-
if (!foreground) return out
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
if (!foreground || registry.size === 0) return out
|
|
42
|
+
// A requested GROUP is a requested server's stand-in: `vx run app#dev`
|
|
43
|
+
// over `dev: { dependsOn: ['^dev'] }` started every server and exited 0
|
|
44
|
+
// at the end of the graph, stopping them all (C-52).
|
|
45
|
+
const stack: string[] = []
|
|
46
|
+
for (const [id, n] of nodes) {
|
|
47
|
+
if (!n.requested && n.surfaced !== true) continue
|
|
48
|
+
if (registry.has(id) || isGroupTask(n)) stack.push(id)
|
|
49
|
+
}
|
|
46
50
|
const reached = new Set<string>()
|
|
47
51
|
while (stack.length > 0) {
|
|
48
52
|
const id = stack.pop()!
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import path from 'node:path'
|
|
8
8
|
import type { ProjectConfig } from '../config.js'
|
|
9
9
|
import {
|
|
10
|
-
|
|
10
|
+
frozenProjectConfigs,
|
|
11
11
|
loadProjectConfigs,
|
|
12
12
|
validateProjectConfig,
|
|
13
13
|
type LoadProjectConfigOptions,
|
|
@@ -216,7 +216,7 @@ export async function loadProjects(args: LoadProjectsArgs): Promise<LoadedProjec
|
|
|
216
216
|
typeof m.configPath === 'string' && args.staged?.get(m.name) === undefined,
|
|
217
217
|
)
|
|
218
218
|
const loaded = lock
|
|
219
|
-
? await
|
|
219
|
+
? await frozenProjectConfigs(lock, withFile, workspaceRoot, args.evalCache?.store)
|
|
220
220
|
: await loadProjectConfigs(
|
|
221
221
|
withFile.map((m) => m.configPath),
|
|
222
222
|
args.evalCache !== undefined ? { evalCache: args.evalCache } : {},
|
package/src/workspace/index.ts
CHANGED
|
@@ -18,7 +18,7 @@ export {
|
|
|
18
18
|
export { computeNestedProjectDirs } from './nested-dirs.js'
|
|
19
19
|
export { buildPackageGraph, type PackageGraph } from './package-graph.js'
|
|
20
20
|
export {
|
|
21
|
-
|
|
21
|
+
frozenProjectConfigs,
|
|
22
22
|
LOCKFILE_NAME,
|
|
23
23
|
LOCKFILE_VERSION,
|
|
24
24
|
lockfilePath,
|
|
@@ -16,7 +16,9 @@
|
|
|
16
16
|
import { rename, rm } from 'node:fs/promises'
|
|
17
17
|
import path from 'node:path'
|
|
18
18
|
import type { ProjectConfig } from '../config.js'
|
|
19
|
-
import { relPosix, UserError } from '../util/index.js'
|
|
19
|
+
import { relPosix, UserError, xxh3 } from '../util/index.js'
|
|
20
|
+
import { VERSION } from '../version.js'
|
|
21
|
+
import { CONFIG_EVAL_VERSION, type ConfigEvalStore } from './config-cache.js'
|
|
20
22
|
import { validateProjectConfig } from './config-schema.js'
|
|
21
23
|
|
|
22
24
|
export const LOCKFILE_NAME = 'vx-lock.json'
|
|
@@ -54,8 +56,10 @@ export async function readLockfile(root: string): Promise<Lockfile | null> {
|
|
|
54
56
|
const file = Bun.file(lockfilePath(root))
|
|
55
57
|
if (!(await file.exists())) return null
|
|
56
58
|
let parsed: unknown
|
|
59
|
+
let text: string
|
|
57
60
|
try {
|
|
58
|
-
|
|
61
|
+
text = await file.text()
|
|
62
|
+
parsed = JSON.parse(text)
|
|
59
63
|
} catch {
|
|
60
64
|
throw new UserError(`${LOCKFILE_NAME} is not valid JSON — re-run \`vx lock\` or delete it`)
|
|
61
65
|
}
|
|
@@ -95,9 +99,13 @@ export async function readLockfile(root: string): Promise<Lockfile | null> {
|
|
|
95
99
|
throw new UserError(`${LOCKFILE_NAME}: entry for "${name}" is malformed — re-run \`vx lock\``)
|
|
96
100
|
}
|
|
97
101
|
}
|
|
102
|
+
lockDigests.set(parsed, xxh3(text).toString(16))
|
|
98
103
|
return parsed as Lockfile
|
|
99
104
|
}
|
|
100
105
|
|
|
106
|
+
/** The digest of the bytes each lock `readLockfile` returned was parsed from. */
|
|
107
|
+
const lockDigests = new WeakMap<object, string>()
|
|
108
|
+
|
|
101
109
|
export async function writeLockfile(root: string, lock: Lockfile): Promise<void> {
|
|
102
110
|
// Written beside its name and renamed over it: `Bun.write` truncates in
|
|
103
111
|
// place, so a `--frozen` run, or `vx watch --frozen` woken by the write
|
|
@@ -123,26 +131,36 @@ export async function writeLockfile(root: string, lock: Lockfile): Promise<void>
|
|
|
123
131
|
|
|
124
132
|
/**
|
|
125
133
|
* Run-time config load from the lock: return the FROZEN resolved config
|
|
126
|
-
* for
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
134
|
+
* for each project, in order. No evaluation happens — this is the fast,
|
|
135
|
+
* eval-free trust path — and no staleness check either (see below): the
|
|
136
|
+
* lock's contract is "what runs is what was locked", so a config file
|
|
137
|
+
* edited since `vx lock` still runs as locked until `vx lock --check`
|
|
138
|
+
* says otherwise. An unlocked project is a hard error; silently falling
|
|
139
|
+
* back to evaluation would break frozen-env semantics.
|
|
140
|
+
*
|
|
141
|
+
* `store` remembers which entries of which lock bytes this validator
|
|
142
|
+
* accepted, beside the config evaluations and keyed like them (vx's and
|
|
143
|
+
* Bun's versions): validating 1,000 entries was ~30 ms of every warm
|
|
144
|
+
* `--frozen` run, for a verdict that cannot change until the bytes or vx
|
|
145
|
+
* do.
|
|
132
146
|
*/
|
|
133
|
-
export async function
|
|
147
|
+
export async function frozenProjectConfigs(
|
|
134
148
|
lock: Lockfile,
|
|
135
|
-
|
|
149
|
+
metas: ReadonlyArray<{ name: string; configPath: string }>,
|
|
136
150
|
root: string,
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
151
|
+
store?: ConfigEvalStore,
|
|
152
|
+
): Promise<ProjectConfig[]> {
|
|
153
|
+
const entries = metas.map((meta) => {
|
|
154
|
+
const rel = relPosix(root, meta.configPath)
|
|
155
|
+
const entry = lock.projects[meta.name]
|
|
156
|
+
if (!entry || entry.configPath !== rel) {
|
|
157
|
+
throw new UserError(
|
|
158
|
+
`${LOCKFILE_NAME} has no entry for "${meta.name}" (${rel}) — ` +
|
|
159
|
+
`run \`vx lock\` to refresh, or delete ${LOCKFILE_NAME}`,
|
|
160
|
+
)
|
|
161
|
+
}
|
|
162
|
+
return entry
|
|
163
|
+
})
|
|
146
164
|
// No staleness checks here, deliberately: --frozen runs after
|
|
147
165
|
// `vx lock --check` in any sane pipeline, and that audit re-
|
|
148
166
|
// evaluates everything — a per-file byte-hash re-check would be
|
|
@@ -151,6 +169,30 @@ export async function frozenProjectConfig(
|
|
|
151
169
|
// in the file solely for --check's fast file-changed reporting.
|
|
152
170
|
// The lock is hand-editable; the stored config crosses the same
|
|
153
171
|
// boundary a freshly evaluated one does.
|
|
154
|
-
|
|
155
|
-
|
|
172
|
+
const digest = store === undefined ? undefined : lockDigests.get(lock)
|
|
173
|
+
const keys =
|
|
174
|
+
digest === undefined
|
|
175
|
+
? undefined
|
|
176
|
+
: metas.map(
|
|
177
|
+
(m) =>
|
|
178
|
+
`vx-lock-valid-v${CONFIG_EVAL_VERSION}\0${VERSION}\0${Bun.version}\0${digest}\0${m.name}`,
|
|
179
|
+
)
|
|
180
|
+
const known =
|
|
181
|
+
keys === undefined || store === undefined
|
|
182
|
+
? new Map<string, string>()
|
|
183
|
+
: store.getConfigEvals !== undefined
|
|
184
|
+
? store.getConfigEvals(keys)
|
|
185
|
+
: new Map(keys.flatMap((k) => (store.getConfigEval(k) === null ? [] : [[k, '1'] as const])))
|
|
186
|
+
const accepted: Array<readonly [string, string]> = []
|
|
187
|
+
for (let i = 0; i < entries.length; i++) {
|
|
188
|
+
const key = keys?.[i]
|
|
189
|
+
if (key !== undefined && known.has(key)) continue
|
|
190
|
+
validateProjectConfig(entries[i]!.config, `${LOCKFILE_NAME} (${metas[i]!.name})`)
|
|
191
|
+
if (key !== undefined) accepted.push([key, '1'])
|
|
192
|
+
}
|
|
193
|
+
if (store !== undefined && accepted.length > 0) {
|
|
194
|
+
if (store.putConfigEvals !== undefined) store.putConfigEvals(accepted)
|
|
195
|
+
else for (const [k, v] of accepted) store.putConfigEval(k, v)
|
|
196
|
+
}
|
|
197
|
+
return entries.map((e) => e.config)
|
|
156
198
|
}
|