From fde842439d06ad4b287d47e943331fc82879897a Mon Sep 17 00:00:00 2001 From: ScriptedAlchemy Date: Sun, 6 Sep 2026 03:27:12 +0000 Subject: [PATCH 1/2] fix(dev): ignore the package build's ..compile- scratch dir in the source watcher --- .changeset/watcher-compile-scratch.md | 5 +++++ packages/agent-bundle/src/dev/watcher.ts | 9 +++++---- packages/agent-bundle/tests/dev-watcher.test.ts | 4 ++++ 3 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 .changeset/watcher-compile-scratch.md diff --git a/.changeset/watcher-compile-scratch.md b/.changeset/watcher-compile-scratch.md new file mode 100644 index 000000000..020082bca --- /dev/null +++ b/.changeset/watcher-compile-scratch.md @@ -0,0 +1,5 @@ +--- +"agent-bundle": patch +--- + +Ignore the package build's `..compile-XXXXXX` scratch directory in the `agent-bundle dev` source watcher, so a `dist/` package build no longer republishes the epoch it just produced and Workbench invocations run under the epoch that was active when they were queued. (#PR) diff --git a/packages/agent-bundle/src/dev/watcher.ts b/packages/agent-bundle/src/dev/watcher.ts index cb1b0fa18..d27e91f51 100644 --- a/packages/agent-bundle/src/dev/watcher.ts +++ b/packages/agent-bundle/src/dev/watcher.ts @@ -37,14 +37,15 @@ const relativePath = (root: string, path: string): string | undefined => { * Whether `source` is inside the staging directory an output root is * assembled in: the package build (`package-build.ts`) and the artifact * build (`build.ts`) `mkdtemp` a `..stage-XXXXXX` sibling of the - * output root and rename it into place, so those paths are build output - * too, not source. Without this, every `dist/` package build inside + * output root and rename it into place, and the package build compiles in a + * `..compile-XXXXXX` sibling first (#656), so those paths are build + * output too, not source. Without this, every `dist/` package build inside * `agent-bundle dev` would invalidate the epoch it just produced. */ const isOutputStagingPath = (output: string, source: string): boolean => { const parent = dirname(output); - const prefix = `${parent === '.' ? '' : `${parent}/`}.${basename(output)}.stage-`; - return source.startsWith(prefix); + const prefix = `${parent === '.' ? '' : `${parent}/`}.${basename(output)}.`; + return source.startsWith(`${prefix}stage-`) || source.startsWith(`${prefix}compile-`); }; const defaultPathSignature = async (path: string): Promise => { diff --git a/packages/agent-bundle/tests/dev-watcher.test.ts b/packages/agent-bundle/tests/dev-watcher.test.ts index 4afd18541..cf597fdd6 100644 --- a/packages/agent-bundle/tests/dev-watcher.test.ts +++ b/packages/agent-bundle/tests/dev-watcher.test.ts @@ -71,6 +71,10 @@ it('debounces only relevant source paths into one ordered invalidation and close // renaming it into place; that staging tree is output, not source. fake.emit('addDir', '/project with spaces/.dist.stage-W3rHAr'); fake.emit('add', '/project with spaces/.dist.stage-W3rHAr/bin/plugin.js'); + // ... and compiles into a `.dist.compile-XXXXXX` sibling first (#656). + fake.emit('addDir', '/project with spaces/.dist.compile-Qm2xLp'); + fake.emit('add', '/project with spaces/.dist.compile-Qm2xLp/bin/plugin.js'); + fake.emit('unlinkDir', '/project with spaces/.dist.compile-Qm2xLp'); fake.emit('add', '/project with spaces/.distinct-source.ts'); await watcher.flush(); From f8d40d91fdf527385dd6022897310d0eee884ffe Mon Sep 17 00:00:00 2001 From: ScriptedAlchemy Date: Sun, 6 Sep 2026 03:29:05 +0000 Subject: [PATCH 2/2] changeset: name the PR --- .changeset/watcher-compile-scratch.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/watcher-compile-scratch.md b/.changeset/watcher-compile-scratch.md index 020082bca..df79a4c77 100644 --- a/.changeset/watcher-compile-scratch.md +++ b/.changeset/watcher-compile-scratch.md @@ -2,4 +2,4 @@ "agent-bundle": patch --- -Ignore the package build's `..compile-XXXXXX` scratch directory in the `agent-bundle dev` source watcher, so a `dist/` package build no longer republishes the epoch it just produced and Workbench invocations run under the epoch that was active when they were queued. (#PR) +Ignore the package build's `..compile-XXXXXX` scratch directory in the `agent-bundle dev` source watcher, so a `dist/` package build no longer republishes the epoch it just produced and Workbench invocations run under the epoch that was active when they were queued. (#669)