pacework 1.7.12 → 1.7.14
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/bin/pacework-runner.mjs +15 -4
- package/lib/capabilities.mjs +1 -0
- package/lib/run-limits.mjs +40 -5
- package/package.json +3 -2
package/bin/pacework-runner.mjs
CHANGED
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
describeRunLimits,
|
|
20
20
|
hasCommitsSince,
|
|
21
21
|
holdsUnpushedStoppedWork,
|
|
22
|
+
currentFileComparison,
|
|
22
23
|
listRunChangedFiles,
|
|
23
24
|
changedFileComparison,
|
|
24
25
|
resolveRunLimits,
|
|
@@ -3318,6 +3319,12 @@ async function runExecutor(run, state) {
|
|
|
3318
3319
|
review: isReviewRun(run), startSha: runStartSha,
|
|
3319
3320
|
baseBranch: run.__baseBranch ?? run.repo_context?.base_branch ?? null,
|
|
3320
3321
|
}) : { sha: null, label: "no git checkout" }
|
|
3322
|
+
// The files this run changed, against the base as the checkout holds it now:
|
|
3323
|
+
// a base the run merged in or rebased onto must not count as its own work.
|
|
3324
|
+
async function runChangedFilesNow() {
|
|
3325
|
+
Object.assign(fileComparison, await currentFileComparison(worktreePath, fileComparison))
|
|
3326
|
+
return listRunChangedFiles(worktreePath, fileComparison.sha)
|
|
3327
|
+
}
|
|
3321
3328
|
// Only Claude Code can stop itself at a cost, and another provider's cost is
|
|
3322
3329
|
// priced at Anthropic's rates, so it cannot be held to a dollar limit.
|
|
3323
3330
|
const costLimitApplies = runLimits.maxCostUsd !== null
|
|
@@ -3445,7 +3452,7 @@ async function runExecutor(run, state) {
|
|
|
3445
3452
|
limitCheckInFlight = true
|
|
3446
3453
|
try {
|
|
3447
3454
|
const changed = fileLimitApplies && runLimits.maxChangedFiles !== null
|
|
3448
|
-
? await
|
|
3455
|
+
? await runChangedFilesNow()
|
|
3449
3456
|
: []
|
|
3450
3457
|
const stop = checkRunLimits(
|
|
3451
3458
|
{ ...runLimits, maxChangedFiles: fileLimitApplies ? runLimits.maxChangedFiles : null, maxCostUsd: null },
|
|
@@ -3840,7 +3847,7 @@ async function runExecutor(run, state) {
|
|
|
3840
3847
|
// TRIPWIRE PROTOCOL: the last look, for files changed after the live
|
|
3841
3848
|
// check's last one. The work is saved below, never reset away.
|
|
3842
3849
|
if (fileLimitApplies && runLimits.maxChangedFiles !== null) {
|
|
3843
|
-
const runChangedFiles = await
|
|
3850
|
+
const runChangedFiles = await runChangedFilesNow()
|
|
3844
3851
|
const stop = checkRunLimits(
|
|
3845
3852
|
{ maxChangedFiles: runLimits.maxChangedFiles, maxCostUsd: null, maxMinutes: null },
|
|
3846
3853
|
{ changedFileCount: runChangedFiles.length },
|
|
@@ -4368,7 +4375,11 @@ async function saveStoppedWork({ run, stop, worktreePath, branch, gitAvailable,
|
|
|
4368
4375
|
*/
|
|
4369
4376
|
async function reportStoppedRun(input) {
|
|
4370
4377
|
const { run, stop, gitAvailable, worktreePath, runStartSha, runRoot, mcpKey, runLogger } = input
|
|
4371
|
-
|
|
4378
|
+
// Read the base once more, so the report names the commit its file list was counted from.
|
|
4379
|
+
const fileComparison = gitAvailable && input.fileComparison
|
|
4380
|
+
? await currentFileComparison(worktreePath, input.fileComparison)
|
|
4381
|
+
: input.fileComparison
|
|
4382
|
+
const changedFiles = gitAvailable ? await listRunChangedFiles(worktreePath, fileComparison?.sha ?? runStartSha) : []
|
|
4372
4383
|
const saved = await saveStoppedWork(input)
|
|
4373
4384
|
const report = buildImpactReport({
|
|
4374
4385
|
stop,
|
|
@@ -4380,7 +4391,7 @@ async function reportStoppedRun(input) {
|
|
|
4380
4391
|
saved,
|
|
4381
4392
|
executor: executorDisplayName(),
|
|
4382
4393
|
agentName: run.agent?.name || null,
|
|
4383
|
-
comparison:
|
|
4394
|
+
comparison: fileComparison?.label,
|
|
4384
4395
|
})
|
|
4385
4396
|
try {
|
|
4386
4397
|
fs.mkdirSync(runRoot, { recursive: true })
|
package/lib/capabilities.mjs
CHANGED
|
@@ -51,6 +51,7 @@ export function detectCapabilities({ repoRoot, executors = [], exec = run, platf
|
|
|
51
51
|
// Only when a GitHub repo was found: an empty list would mean "can't do any repo".
|
|
52
52
|
if (remotes.length) capabilities.repos = [...new Set(remotes)]
|
|
53
53
|
const tools = []
|
|
54
|
+
if (exec("git", ["--version"])) tools.push("git")
|
|
54
55
|
if (exec("docker", ["version", "--format", "{{.Server.Version}}"])) tools.push("docker")
|
|
55
56
|
if (canSandbox({ platform, executors, exec })) tools.push("sandbox")
|
|
56
57
|
capabilities.tools = tools
|
package/lib/run-limits.mjs
CHANGED
|
@@ -302,16 +302,51 @@ export async function changedFileComparison(worktreePath, { review, startSha, ba
|
|
|
302
302
|
if (review) return { sha: startSha, label: `review start ${startSha ?? "(working tree)"}` }
|
|
303
303
|
for (const ref of [baseBranch ? `origin/${baseBranch}` : null, "origin/HEAD"].filter(Boolean)) {
|
|
304
304
|
const sha = (await git(worktreePath, ["merge-base", ref, "HEAD"]))?.trim()
|
|
305
|
-
if (sha) return { sha, label: `merge base with ${ref} (${sha})` }
|
|
305
|
+
if (sha) return { sha, ref, label: `merge base with ${ref} (${sha})` }
|
|
306
306
|
}
|
|
307
307
|
return { sha: startSha, label: `run start ${startSha ?? "(working tree)"}; remote base unavailable` }
|
|
308
308
|
}
|
|
309
309
|
|
|
310
|
-
/**
|
|
310
|
+
/**
|
|
311
|
+
* A build's comparison as it stands now. The base moves during a run: the agent
|
|
312
|
+
* is told to bring its branch up to date, and merging or rebasing onto the base
|
|
313
|
+
* puts every file that changed there into the checkout. Measured from the base
|
|
314
|
+
* the run started on, those files counted as the run's own and stopped it.
|
|
315
|
+
*
|
|
316
|
+
* So the base is read again at every check: the newest commit of the base branch
|
|
317
|
+
* the checkout holds. A merge of the base that is not committed yet counts too,
|
|
318
|
+
* since what it brings in is already in the working tree. A comparison without a
|
|
319
|
+
* base ref (a review, or no readable remote base) is returned as it is, and so
|
|
320
|
+
* is one whose base can no longer be read.
|
|
321
|
+
*/
|
|
322
|
+
export async function currentFileComparison(worktreePath, comparison) {
|
|
323
|
+
if (!comparison?.ref) return comparison
|
|
324
|
+
let sha = (await git(worktreePath, ["merge-base", comparison.ref, "HEAD"]))?.trim() || null
|
|
325
|
+
const merging = (await git(worktreePath, ["rev-parse", "--verify", "--quiet", "MERGE_HEAD"]))?.trim() || null
|
|
326
|
+
if (merging) {
|
|
327
|
+
const incoming = (await git(worktreePath, ["merge-base", comparison.ref, merging]))?.trim() || null
|
|
328
|
+
// Only a newer point on the same base line replaces the committed one.
|
|
329
|
+
if (incoming && (!sha || await git(worktreePath, ["merge-base", "--is-ancestor", sha, incoming]) !== null)) sha = incoming
|
|
330
|
+
}
|
|
331
|
+
if (!sha || sha === comparison.sha) return comparison
|
|
332
|
+
return { ...comparison, sha, label: `merge base with ${comparison.ref} (${sha})` }
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* The files a run changed since `startSha`, committed or not, untracked included.
|
|
337
|
+
*
|
|
338
|
+
* With a start commit, tracked files come from the working tree's difference to
|
|
339
|
+
* it and nothing else. `git status` is not asked: during a merge it lists every
|
|
340
|
+
* file the other side brings in as staged, whether or not this run touched it.
|
|
341
|
+
*/
|
|
311
342
|
export async function listRunChangedFiles(worktreePath, startSha) {
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
343
|
+
if (!startSha) {
|
|
344
|
+
const status = await git(worktreePath, ["status", "--porcelain", "--untracked-files=all", "--", ...DEPENDENCY_PATHSPEC_EXCLUDES])
|
|
345
|
+
return parseChangedFiles(status, null)
|
|
346
|
+
}
|
|
347
|
+
const diff = await git(worktreePath, ["diff", "--name-only", startSha, "--", ...DEPENDENCY_PATHSPEC_EXCLUDES])
|
|
348
|
+
const untracked = await git(worktreePath, ["ls-files", "--others", "--exclude-standard", "--", ...DEPENDENCY_PATHSPEC_EXCLUDES])
|
|
349
|
+
return parseChangedFiles(null, [diff, untracked].filter(Boolean).join("\n"))
|
|
315
350
|
}
|
|
316
351
|
|
|
317
352
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pacework",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.14",
|
|
4
4
|
"description": "pacework CLI: connect this machine as a runner for pacework AI agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
"lib/"
|
|
12
12
|
],
|
|
13
13
|
"scripts": {
|
|
14
|
-
"test": "node --test test/*.test.mjs"
|
|
14
|
+
"test": "node --test test/*.test.mjs",
|
|
15
|
+
"benchmark:verify": "node benchmark/bin/verify-items.mjs"
|
|
15
16
|
},
|
|
16
17
|
"engines": {
|
|
17
18
|
"node": ">=18.0.0"
|