Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

Never pick a hidden file as the newest artifact

deed463cd15c14a
diff --git a/cli/src/dsh/artifacts.spec.ts b/cli/src/dsh/artifacts.spec.ts
index 32deedbed..b462c69c3 100644
--- a/cli/src/dsh/artifacts.spec.ts
+++ b/cli/src/dsh/artifacts.spec.ts
@@ -25,7 +25,8 @@ describe('newestArtifact', () => {
touch('node_modules/lib/newest.step', 9_000)
touch('__cadgen__/cache.step', 9_000)
touch('.hidden/x.step', 9_000)
- expect(newestArtifact(workspace, ['.step', '.stl'])?.path).toBe('models/new.STEP')
+ touch('models/.new.STEP.glb', 9_000)
+ expect(newestArtifact(workspace, ['.step', '.stl', '.glb'])?.path).toBe('models/new.STEP')
expect(newestArtifact(workspace, ['.glb'])).toBeNull()
expect(newestArtifact(workspace, [])).toBeNull()
})
@@ -36,6 +37,7 @@ describe('isCandidateArtifact', () => {
expect(isCandidateArtifact('/ws/models/a.step', ['.step'])).toBe(true)
expect(isCandidateArtifact('/ws/a.txt', ['.step'])).toBe(false)
expect(isCandidateArtifact('/ws/node_modules/a.step', ['.step'])).toBe(false)
+ expect(isCandidateArtifact('/ws/models/.a.step.glb', ['.glb'])).toBe(false)
})
})
diff --git a/cli/src/dsh/artifacts.ts b/cli/src/dsh/artifacts.ts
index 663b1a9fd..55b957c31 100644
--- a/cli/src/dsh/artifacts.ts
+++ b/cli/src/dsh/artifacts.ts
@@ -52,7 +52,9 @@ export function newestArtifact(workspace: string, extensions: readonly string[])
if (!isArtifactDirIgnored(name) && !name.startsWith('.')) walk(path, depth + 1)
continue
}
- if (!st.isFile()) continue
+ // A hidden file is never the artifact: the 3D viewer keeps its inline GLB as `.model.step.glb`
+ // beside the STEP it was made from, and that is exactly the kind of file this must not pick.
+ if (!st.isFile() || name.startsWith('.')) continue
const dot = name.lastIndexOf('.')
if (dot < 0 || !wanted.has(name.slice(dot).toLowerCase())) continue
if (!best || st.mtimeMs > best.mtimeMs) {
@@ -68,5 +70,7 @@ export function newestArtifact(workspace: string, extensions: readonly string[])
export function isCandidateArtifact(path: string, extensions: readonly string[]): boolean {
const lower = path.toLowerCase()
if (!extensions.some((ext) => lower.endsWith(ext.toLowerCase()))) return false
- return !path.split(/[\\/]/).slice(0, -1).some((segment) => isArtifactDirIgnored(segment))
+ const segments = path.split(/[\\/]/)
+ if (segments[segments.length - 1].startsWith('.')) return false
+ return !segments.slice(0, -1).some((segment) => isArtifactDirIgnored(segment))
}