Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
250 commits
Select commit Hold shift + click to select a range
9c903a5
feat(artifacts): add project-local artifact store
austinywang Jul 21, 2026
4837f70
feat(artifacts): capture and browse agent artifacts
austinywang Jul 21, 2026
fef3f38
fix(artifacts): harden capture lifecycle
austinywang Jul 22, 2026
4ba8b67
fix(artifacts): bound batch capture work
austinywang Jul 22, 2026
6294f28
test(artifacts): cover review safety regressions
austinywang Jul 22, 2026
ebb60f1
fix(artifacts): close review lifecycle gaps
austinywang Jul 22, 2026
d2cd193
test(artifacts): cover corrupt provenance rollback
austinywang Jul 22, 2026
9cb670c
fix(artifacts): fail closed on corrupt provenance
austinywang Jul 22, 2026
0e4d238
test(artifacts): cover out-of-order capture completion
austinywang Jul 22, 2026
3939d8d
fix(artifacts): keep capture generations monotonic
austinywang Jul 22, 2026
6247250
test(artifacts): cover dedupe beyond sidebar budget
austinywang Jul 22, 2026
b00cfa6
fix(artifacts): scan moved files beyond sidebar budget
austinywang Jul 22, 2026
990cf56
test(artifacts): cover review lifecycle regressions
austinywang Jul 22, 2026
3e4c494
fix(artifacts): harden capture ordering and lifecycle
austinywang Jul 22, 2026
d95a898
test(artifacts): cover bounded capture and search safety
austinywang Jul 22, 2026
f9caef0
fix(artifacts): bound filesystem recovery and search
austinywang Jul 22, 2026
f2d13ad
fix(artifacts): coalesce bounded transcript capture
austinywang Jul 22, 2026
a7d72ed
fix(artifacts): satisfy pre-merge architecture checks
austinywang Jul 22, 2026
6740d15
test: cover artifact review regressions
austinywang Jul 22, 2026
b22fe7c
fix: bound and beta-gate artifact capture
austinywang Jul 22, 2026
79ff63b
test: cover artifact lifecycle safety
austinywang Jul 22, 2026
0fe11cc
fix: harden artifact lifecycle safety
austinywang Jul 22, 2026
601d357
test: cover artifact capture authorization boundaries
austinywang Jul 22, 2026
c2829af
fix: enforce artifact capture authorization boundaries
austinywang Jul 22, 2026
e1b9f18
fix: make artifact deduplication traversal iterative
austinywang Jul 22, 2026
70cbdb4
test: cover artifact capture authorization gaps
austinywang Jul 22, 2026
11dbca7
fix: harden automatic artifact capture authorization
austinywang Jul 22, 2026
6b14d65
test: cover remaining artifact capture safety gaps
austinywang Jul 22, 2026
5b2e564
fix: close artifact automatic capture safety gaps
austinywang Jul 22, 2026
7d5b66e
fix: bound artifact Git tracked checks
austinywang Jul 22, 2026
f021277
test: cover artifact capture review regressions
austinywang Jul 22, 2026
3d52d86
fix: address artifact capture review findings
austinywang Jul 22, 2026
7c9a15b
test: cover reserved artifact marker filenames
austinywang Jul 22, 2026
b7efcbb
fix: reserve artifact marker destinations
austinywang Jul 22, 2026
6991411
test: cover case-insensitive artifact markers
austinywang Jul 22, 2026
effb891
fix: honor artifact marker volume semantics
austinywang Jul 22, 2026
4aa5f32
test: cover artifact import ownership races
austinywang Jul 22, 2026
8b5b16a
refactor: isolate resolved artifact save phase
austinywang Jul 22, 2026
bc4b356
test: cover artifact save authorization snapshots
austinywang Jul 22, 2026
dc1e4c8
fix: preserve artifact capture ownership invariants
austinywang Jul 22, 2026
efb0b48
test: cover canceled artifact staging copies
austinywang Jul 22, 2026
6456161
fix: cancel artifact staging copies promptly
austinywang Jul 22, 2026
fa36c0f
test: cover artifact batch and mutation boundaries
austinywang Jul 22, 2026
1325316
fix: enforce artifact mutation boundaries
austinywang Jul 22, 2026
75cb5ce
test: cover artifact Git safety boundaries
austinywang Jul 22, 2026
5316585
fix: harden artifact Git safety checks
austinywang Jul 22, 2026
a82332d
test: cover remaining artifact review boundaries
austinywang Jul 22, 2026
7964928
fix: close artifact scan and attribution boundaries
austinywang Jul 22, 2026
1e9fe37
test: cover artifact resource boundaries
austinywang Jul 22, 2026
8e4f8e6
fix: bound artifact discovery resources
austinywang Jul 22, 2026
4c43dab
test: define session-rooted cmux filesystem
austinywang Jul 22, 2026
9e75db8
feat: unify project files by agent session
austinywang Jul 23, 2026
0f84f15
docs: add cmux project files agent skill
austinywang Jul 23, 2026
7d7ead9
test: split artifact capture coordinator fixture
austinywang Jul 23, 2026
9033ec1
test: cover artifact authorization resets
austinywang Jul 23, 2026
d70c5ce
fix: preserve project file authorization boundaries
austinywang Jul 23, 2026
aaaa123
test: cover project file privacy edge cases
austinywang Jul 23, 2026
d14421b
fix: fail closed on project file privacy
austinywang Jul 23, 2026
54cf9eb
test: require unresolved Git markers to fail closed
austinywang Jul 23, 2026
4dde794
test: cover exact note mutations and turn completion
austinywang Jul 23, 2026
1299a45
fix: require exact project file mutations
austinywang Jul 23, 2026
b9d0e90
test: cover artifact identity and preview isolation
austinywang Jul 23, 2026
558d8d0
test: require artifact preview navigation confinement
austinywang Jul 23, 2026
caffc95
fix: isolate artifact sessions and HTML previews
austinywang Jul 23, 2026
e596205
Merge remote-tracking branch 'origin/main' into feat-cmux-artifacts
austinywang Jul 23, 2026
83d71e6
fix: propagate artifact open failures
austinywang Jul 23, 2026
aa3ec2e
test: cover short identities and preview restoration
austinywang Jul 23, 2026
20faa67
fix: harden artifact session identity and preview lifecycle
austinywang Jul 23, 2026
7f2565f
test: cover artifact preview and note safety
austinywang Jul 23, 2026
182762a
fix: keep artifact previews and notes private
austinywang Jul 23, 2026
6abe865
fix: inject the agent chat session registry
austinywang Jul 23, 2026
b5fc7d4
test: cover reorganized privacy and read-write redirection
austinywang Jul 23, 2026
de059fe
fix: close artifact privacy gaps
austinywang Jul 23, 2026
aff8d88
test: cover artifact import safety bounds
austinywang Jul 23, 2026
1d82761
fix: enforce artifact import safety bounds
austinywang Jul 23, 2026
26f024d
test: cover native sessions and FIFO capture
austinywang Jul 23, 2026
de3b52b
fix: preserve session identity without blocking
austinywang Jul 23, 2026
1ee3d93
fix: import artifact app dependencies
austinywang Jul 23, 2026
43fc5de
test: cover artifact session and ignore races
austinywang Jul 23, 2026
7a78df2
fix: isolate artifact identity and Git privacy
austinywang Jul 23, 2026
be5cddb
Merge remote-tracking branch 'origin/main' into feat-cmux-artifacts
austinywang Jul 23, 2026
3ab57ab
test: cover conflicting agent identity values
austinywang Jul 23, 2026
bf21423
fix: reject conflicting agent session values
austinywang Jul 23, 2026
19b20be
test: isolate artifact provider identities
austinywang Jul 23, 2026
45127e0
fix: key artifact sessions by provider identity
austinywang Jul 23, 2026
9d4f795
test: reject ambiguous cmux filesystem identities
austinywang Jul 23, 2026
49b17fd
fix: enforce cmux session filesystem identity
austinywang Jul 23, 2026
ee6640d
test: protect artifact append and workspace boundaries
austinywang Jul 23, 2026
d869c7d
fix: isolate artifact mutation scopes
austinywang Jul 23, 2026
c74fb5c
test: bound artifact lock and thumbnail revisions
austinywang Jul 23, 2026
88e63a6
fix: bound artifact locks and refresh thumbnails
austinywang Jul 23, 2026
58d6dc4
test: close artifact review gaps
austinywang Jul 23, 2026
7b92c33
fix: enforce artifact capture boundaries
austinywang Jul 23, 2026
1c18bec
test: cover artifact runtime ownership gaps
austinywang Jul 23, 2026
c3faa37
fix: reconcile artifact runtime ownership
austinywang Jul 23, 2026
dfc4f29
test: bound artifact capture enable resolution
austinywang Jul 23, 2026
0004f00
fix: bound artifact capture enable resolution
austinywang Jul 23, 2026
e9f06c5
test: cover artifact capture review findings
austinywang Jul 23, 2026
5841012
fix: bound capture batches and focus artifact search
austinywang Jul 23, 2026
e2d81b7
test: cover artifact continuation and note control paths
austinywang Jul 23, 2026
56280ab
fix: validate note paths and continue bounded captures
austinywang Jul 23, 2026
39d0951
test: bound artifact-only hook resolution
austinywang Jul 23, 2026
377147c
fix: bound artifact-only hook resolution
austinywang Jul 23, 2026
89566f2
test: cover artifact capture safety gaps
austinywang Jul 23, 2026
d6d1bd6
fix: harden artifact persistence and retries
austinywang Jul 23, 2026
b296f68
test: cover off-main artifact model release
austinywang Jul 23, 2026
1b9e2d4
fix: make artifact sidebar teardown executor-safe
austinywang Jul 23, 2026
7a639d2
test: cover artifact review regressions
austinywang Jul 23, 2026
790022e
fix: keep artifact reads side-effect-free
austinywang Jul 23, 2026
06d58cf
test: cover final artifact review findings
austinywang Jul 23, 2026
b6fd1e3
fix: harden artifact capture revisions
austinywang Jul 23, 2026
ae43111
fix: use safe stdout for note reads
austinywang Jul 23, 2026
9d8b2d6
test: preserve artifact authorization across capture batches
austinywang Jul 23, 2026
d753652
fix: preserve artifact authority across batches
austinywang Jul 23, 2026
918252d
test: cover artifact rewrite and sidechain capture
austinywang Jul 23, 2026
989304f
fix: revoke unverified artifact authority
austinywang Jul 23, 2026
a9d1f6c
test: cover final artifact capture review findings
austinywang Jul 23, 2026
87c59e9
fix: bound and authorize artifact capture inputs
austinywang Jul 23, 2026
61261da
test: cover transcript artifact ownership boundaries
austinywang Jul 23, 2026
4798e58
fix: centralize artifact transcript resolution
austinywang Jul 23, 2026
99251d3
Merge remote-tracking branch 'origin/main' into feat-cmux-artifacts
austinywang Aug 7, 2026
4df89e9
test: cover artifact capture completion bounds
austinywang Aug 7, 2026
e1280e9
fix: share coding agent definitions with CLI
austinywang Aug 7, 2026
610be93
fix: handle artifact batch size errors in CLI
austinywang Aug 7, 2026
eafde52
test: cover note CLI input source validation
austinywang Aug 7, 2026
7cdda29
fix: remove stale prose streamer project references
austinywang Aug 7, 2026
bdcdccb
fix: import agent launch types in artifact tests
austinywang Aug 7, 2026
711d669
fix: import agent chat models in artifact tests
austinywang Aug 7, 2026
917043e
fix: import artifact capture types in index tests
austinywang Aug 7, 2026
239818f
fix: validate note input source exclusivity
austinywang Aug 7, 2026
fa52ecf
fix: capture completed turns with bounded transcript reads
austinywang Aug 7, 2026
3be681d
refactor: keep artifact helpers on owning types
austinywang Aug 7, 2026
e251e14
Merge remote-tracking branch 'origin/main' into feat-cmux-artifacts
austinywang Aug 7, 2026
6d86a31
refactor: align artifact ownership and tests
austinywang Aug 7, 2026
90e7e10
fix: preserve sendability for injected filesystem helpers
austinywang Aug 7, 2026
08b27e0
test: cover referenced ephemeral prefix policy
austinywang Aug 7, 2026
c609195
fix: qualify artifact staging lease constants
austinywang Aug 7, 2026
80746d8
test: reject symlinked ephemeral prefixes
austinywang Aug 25, 2026
4c0934e
fix: enforce trusted ephemeral capture prefixes
austinywang Aug 25, 2026
93814ec
Merge origin/main into feat-cmux-artifacts
austinywang Aug 25, 2026
cc02bdb
fix: align merged submodule pointers
austinywang Aug 25, 2026
60ba465
fix: close review safety gaps
austinywang Aug 25, 2026
7a41b78
test: cover transcript mutation and tailer bounds
austinywang Aug 25, 2026
c16f59a
fix: bound artifact transcript tailers and authorization
austinywang Aug 25, 2026
3d87d57
Merge remote-tracking branch 'origin/main' into feat-cmux-artifacts
austinywang Aug 25, 2026
0a5b598
fix: close artifact review findings
austinywang Aug 25, 2026
2654a26
test: cover artifact capture coalescing and source races
austinywang Aug 25, 2026
396c3d1
fix: coalesce artifact capture and close source TOCTOU
austinywang Aug 25, 2026
3b0b55a
test: cover artifact mutation and preview policy races
austinywang Aug 25, 2026
8381ce4
fix: close artifact mutation and preview races
austinywang Aug 25, 2026
c836446
fix: preserve trusted preview and canonical note paths
austinywang Aug 25, 2026
887dcb4
test: cover shell, preview, and exclude safety
austinywang Aug 25, 2026
4975d8f
fix: close remaining artifact safety gaps
austinywang Aug 25, 2026
1f5f764
Merge remote-tracking branch 'origin/main' into feat-cmux-artifacts
austinywang Aug 25, 2026
2ffac5b
test: preserve resolved artifact project roots
austinywang Aug 25, 2026
6c1aa68
fix: bound historical captures and reuse project roots
austinywang Aug 25, 2026
80477e3
fix: close final artifact CLI review gaps
austinywang Aug 25, 2026
ef82057
test: cover mobile artifact gates and row revalidation
austinywang Aug 25, 2026
2a136cc
fix: gate and revalidate mobile artifact opens
austinywang Aug 25, 2026
c2760c0
test: cover artifact capture bounds and teardown
austinywang Aug 25, 2026
5369fbd
fix: bound pending artifact mutations and teardown capture
austinywang Aug 25, 2026
07d4509
test: fix tailer ownership fixture identities
austinywang Aug 25, 2026
7069c76
fix: close artifact preview and mutation races
austinywang Aug 25, 2026
067fd9f
fix: confine gallery and provenance artifact paths
austinywang Aug 25, 2026
006f37d
fix: bound transcript capture and tailer ownership
austinywang Aug 25, 2026
a0a4d70
fix: preserve mobile save authorization and git fallback
austinywang Aug 25, 2026
c309575
test: cover transcript rewrite and save safety
austinywang Aug 25, 2026
e1fa783
fix: close remaining artifact bounds and privacy gaps
austinywang Aug 25, 2026
d9627e6
test: cover staging and capture workload bounds
austinywang Aug 25, 2026
1c27545
fix: confine staging cleanup and cap capture workloads
austinywang Aug 25, 2026
684d676
test: cover capture retry and lease confinement
austinywang Aug 25, 2026
dacd130
fix: pin artifact leases and preserve capture retries
austinywang Aug 25, 2026
f66488d
fix: close final capture and descriptor safety gaps
austinywang Aug 25, 2026
7607444
test: cover staging symlink recovery
austinywang Aug 25, 2026
b1a2e52
fix: confine staging recovery and artifact previews
austinywang Aug 25, 2026
8864fdc
test: cover read-only capture and stale staging cleanup
austinywang Aug 25, 2026
49b8a6f
fix: confine note opens and avoid read-only capture scans
austinywang Aug 25, 2026
a1ca5cc
test: cover unknown Claude tool results
austinywang Aug 25, 2026
8061a38
fix: bound references and secure auxiliary artifact reads
austinywang Aug 25, 2026
3fd0a3c
test: cover fragment preview and missing-artifact progress
austinywang Aug 25, 2026
112352c
fix: stabilize artifact previews and capture progress
austinywang Aug 25, 2026
a970bab
fix: preserve confined artifact handoffs and markdown resources
austinywang Aug 25, 2026
d736876
fix: pin marker writes and bound external artifact handoffs
austinywang Aug 25, 2026
a182c9e
fix: harden artifact roots and temporary open files
austinywang Aug 25, 2026
b86e3d3
fix: bound mobile tailers and pin preview consumers
austinywang Aug 25, 2026
8405cbf
fix: preserve tool status and coalesce artifact refreshes
austinywang Aug 25, 2026
3b8274d
test: cover artifact cache, watcher, and CLI bounds
austinywang Aug 25, 2026
8e84316
fix: close artifact cache, watcher, and CLI review gaps
austinywang Aug 25, 2026
220f07e
test: cover artifact recency and destructive CLI guards
austinywang Aug 25, 2026
2ca7c41
fix: harden artifact recency and destructive CLI paths
austinywang Aug 25, 2026
2f36a8e
fix: fence artifact lifecycle and preview paths
austinywang Aug 25, 2026
aff1da5
fix: bound artifact resolution and preview concurrency
austinywang Aug 25, 2026
8ed03d4
fix: secure artifact handoffs and save affordances
austinywang Aug 25, 2026
51abb60
fix: move markdown artifact image staging off main actor
austinywang Aug 25, 2026
d336ab9
fix: protect active artifact handoffs
austinywang Aug 25, 2026
296697e
fix: fence project identity and save eligibility
austinywang Aug 25, 2026
a341928
fix: tighten transcript status and preview refresh fences
austinywang Aug 25, 2026
f3325d1
refactor: separate artifact recency heap entry
austinywang Aug 25, 2026
a8d7c75
fix: bound stale artifact scans and previews
austinywang Aug 25, 2026
c8f4cb8
fix: close transcript and artifact refresh races
austinywang Aug 25, 2026
6092f69
fix: close artifact sidebar safety gaps
austinywang Aug 25, 2026
ad440e4
fix: make artifact preview handoffs race-safe
austinywang Aug 25, 2026
db8f9ec
fix: pin artifact drag descriptors
austinywang Aug 25, 2026
1cc69c0
fix: retain artifact drag names and leases
austinywang Aug 25, 2026
dc3e5ca
fix: finish artifact drag progress
austinywang Aug 25, 2026
91edf4f
Merge origin/main into feat-cmux-artifacts
austinywang Aug 25, 2026
3b564dc
fix: bound artifact refresh and save work
austinywang Aug 26, 2026
cfc3ffc
fix: coalesce watcher events during scans
austinywang Aug 26, 2026
93b700b
fix: cancel artifact watcher children with rebinds
austinywang Aug 26, 2026
a29a147
fix: reset watcher state on artifact rebind
austinywang Aug 26, 2026
ba412dd
fix: close remaining artifact review gaps
austinywang Aug 26, 2026
2712552
fix: harden artifact save and transcript status
austinywang Aug 26, 2026
3cda164
fix: keep artifact retries and status evidence safe
austinywang Aug 26, 2026
30693ee
fix: parse transcript failure envelopes safely
austinywang Aug 26, 2026
c0d957c
fix: keep transcript status evidence provider-scoped
austinywang Aug 26, 2026
528080b
fix: retain exact transcript failure markers
austinywang Aug 26, 2026
0b6b71b
fix: retain multiline transcript failure prefixes
austinywang Aug 26, 2026
fb21398
Merge origin/main into feat-cmux-artifacts
austinywang Aug 26, 2026
288472d
fix: authorize mobile chat artifact tickets
austinywang Aug 26, 2026
2ca1a0d
fix: bound structured artifact path extraction
austinywang Aug 26, 2026
f24033f
fix: honor explicit transcript success status
austinywang Aug 26, 2026
bb6062e
fix: wire artifact sidebar file into app target
austinywang Aug 26, 2026
7a12ff4
fix: scope mobile artifact saves to Mac-wide tickets
austinywang Aug 26, 2026
f8cad67
fix: bound transcript artifact path retention
austinywang Aug 26, 2026
26f0db6
fix: prefer native agent identity for project files
austinywang Aug 26, 2026
27a9c8a
fix: reserve zero-byte project-file handoff slots
austinywang Aug 26, 2026
1401867
fix: move artifact markdown image validation off main
austinywang Aug 26, 2026
cd9d949
docs: require confirmation for note removal
austinywang Aug 26, 2026
54e3745
fix(artifacts): adapt POSIX path checks to Xcode 26
austinywang Aug 26, 2026
529858f
fix(artifacts): repair Swift 6 watcher and lease initialization
austinywang Aug 26, 2026
a42c0c8
fix(artifacts): own watcher tasks without task-group sends
austinywang Aug 26, 2026
b255996
fix(remote): release upload heartbeat lock after watchdog
austinywang Aug 26, 2026
4be37c6
fix(artifacts): select safe fcntl overload in app targets
austinywang Aug 26, 2026
f8e6a2b
fix: repair artifact integration call sites
austinywang Aug 26, 2026
8087525
fix(artifacts): repair preview and path helper calls
austinywang Aug 26, 2026
f4c0311
fix: expose remaining artifact integration seams
austinywang Aug 26, 2026
66edb9a
fix: update artifact integration test call sites
austinywang Aug 26, 2026
7e83bb8
Merge remote-tracking branch 'origin/main' into feat-cmux-artifacts
austinywang Aug 26, 2026
592b6d1
fix: repair artifact tests and warning budget
austinywang Aug 26, 2026
df89792
Merge remote-tracking branch 'origin/main' into feat-cmux-artifacts
austinywang Aug 26, 2026
5fcc99f
fix: close artifact CI integration gaps
austinywang Aug 26, 2026
080ea26
fix: address final artifact review findings
austinywang Aug 26, 2026
7a24277
fix: close artifact review regressions
austinywang Aug 26, 2026
aecf70e
fix: bound artifact staging and sidebar identity work
austinywang Aug 27, 2026
c3311c2
test: cover Iroh artifact ancestor swaps
austinywang Aug 27, 2026
dd6c4bc
test: cover artifact identity and empty-folder regressions
austinywang Sep 1, 2026
f29410b
fix: bind artifact reads to authorized filesystem identities
austinywang Sep 1, 2026
acd1f0d
merge: reconcile artifact branch with origin/main
austinywang Sep 1, 2026
0213b1b
merge: sync latest origin/main
austinywang Sep 1, 2026
6c4bbbc
fix: make artifact CI deterministic
austinywang Sep 9, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CLI/ArtifactCLIArguments.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
struct ArtifactCLIArguments {
let subcommand: String
let operands: [String]
let projectPath: String?
}
286 changes: 286 additions & 0 deletions CLI/CMUXCLI+Artifacts.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,286 @@
import CmuxArtifacts
import Foundation

extension CMUXCLI {
func runArtifactCommand(
commandArgs: [String],
jsonOutput: Bool,
processEnvironment: [String: String]
) async throws {
let parsed = try artifactArguments(commandArgs)
let projectRoot = artifactProjectRoot(explicitPath: parsed.projectPath)
let repository = LocalArtifactRepository()

do {
switch parsed.subcommand {
case "list":
guard parsed.operands.isEmpty else {
throw CLIError(message: artifactUsage(), exitCode: 2)
}
let snapshot = try await repository.snapshot(projectRoot: projectRoot)
let files = artifactFiles(in: snapshot.nodes)
if jsonOutput {
print(jsonString([
"project_root": projectRoot.path,
"artifacts_root": snapshot.artifactsRoot.path,
"artifacts": files.map(artifactPayload),
]))
} else if files.isEmpty {
print(String(
localized: "cli.artifact.output.empty",
defaultValue: "No artifacts found."
))
} else {
files.forEach { print($0.relativePath) }
}

case "path":
let name = try artifactRequiredOperand(parsed.operands, subcommand: "path")
let node = try await repository.resolve(projectRoot: projectRoot, name: name)
if jsonOutput {
print(jsonString(artifactPayload(node)))
} else {
print(node.absolutePath)
}

case "open":
let name = try artifactRequiredOperand(parsed.operands, subcommand: "open")
let node = try await repository.resolve(projectRoot: projectRoot, name: name)
try openArtifact(node)
if jsonOutput { print(jsonString(artifactPayload(node))) }

case "add":
let rawPath = try artifactRequiredOperand(parsed.operands, subcommand: "add")
let sourceURL = artifactFileURL(rawPath)
let context = artifactCaptureContext(
projectRoot: projectRoot,
environment: processEnvironment
)
let outcome = try await ArtifactCaptureService(store: repository).add(
sourceURL: sourceURL,
context: context
)
guard let record = outcome.record else {
throw CLIError(message: String(
localized: "cli.artifact.error.addRejected",
defaultValue: "The artifact was not added."
))
}
Comment thread
austinywang marked this conversation as resolved.
Resolved
let absolutePath = ArtifactStorePaths(projectRoot: projectRoot).artifactsRoot
.appendingPathComponent(record.relativePath, isDirectory: false).path
Comment thread
austinywang marked this conversation as resolved.
Resolved
if jsonOutput {
print(jsonString([
"path": absolutePath,
"relative_path": record.relativePath,
"digest": record.digest,
"result": artifactOutcomeName(outcome),
]))
} else {
print(absolutePath)
}

case "search":
let query = try artifactRequiredOperand(parsed.operands, subcommand: "search")
let results = try await repository.search(projectRoot: projectRoot, query: query)
if jsonOutput {
print(jsonString([
"query": query,
"results": results.map { result in
var payload = artifactPayload(result.node)
payload["matched_content"] = result.matchedContent
payload["snippet"] = result.snippet ?? NSNull()
return payload
},
]))
} else if results.isEmpty {
print(String(
localized: "cli.artifact.output.noMatches",
defaultValue: "No artifacts matched."
))
} else {
for result in results {
if let snippet = result.snippet {
print("\(result.node.relativePath): \(snippet)")
} else {
print(result.node.relativePath)
}
}
}

default:
throw CLIError(message: artifactUsage(), exitCode: 2)
}
} catch let error as ArtifactStoreError {
throw CLIError(message: artifactErrorMessage(error), exitCode: 2)
}
}

func artifactUsage() -> String {
String(localized: "cli.artifact.usage", defaultValue: """
Usage: cmux artifact list [--project <path>]
cmux artifact path <name-or-relative-path> [--project <path>]
cmux artifact open <name-or-relative-path> [--project <path>]
cmux artifact add <path> [--project <path>]
cmux artifact search <query> [--project <path>]

Browse and add ordinary files under <project>/.cmux/artifacts.
Commands work without a running cmux app or socket. The project defaults
to the nearest ancestor containing .cmux or .git.
""")
}

private func artifactArguments(_ arguments: [String]) throws -> ArtifactCLIArguments {
var projectPath: String?
var remaining: [String] = []
var index = 0
var pastTerminator = false
while index < arguments.count {
let argument = arguments[index]
if pastTerminator {
remaining.append(argument)
index += 1
continue
}
if argument == "--" {
pastTerminator = true
index += 1
continue
}
if argument == "--project" {
guard index + 1 < arguments.count else {
throw CLIError(message: String(
localized: "cli.artifact.error.projectValue",
defaultValue: "artifact: --project requires a path"
), exitCode: 2)
}
projectPath = arguments[index + 1]
index += 2
} else if argument.hasPrefix("--project=") {
projectPath = String(argument.dropFirst("--project=".count))
index += 1
} else if argument.hasPrefix("-") {
throw CLIError(message: artifactUsage(), exitCode: 2)
} else {
remaining.append(argument)
index += 1
}
}
if let projectPath,
projectPath.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
throw CLIError(message: String(
localized: "cli.artifact.error.projectValue",
defaultValue: "artifact: --project requires a path"
), exitCode: 2)
}
return ArtifactCLIArguments(
subcommand: remaining.first?.lowercased() ?? "list",
operands: Array(remaining.dropFirst()),
projectPath: projectPath
)
}

private func artifactProjectRoot(explicitPath: String?) -> URL {
let start = explicitPath.map(artifactFileURL)
?? URL(fileURLWithPath: FileManager.default.currentDirectoryPath, isDirectory: true)
return ArtifactProjectLocator().projectRoot(startingAt: start, fileManager: .default)
}

private func artifactFileURL(_ rawPath: String) -> URL {
let expanded = NSString(string: rawPath).expandingTildeInPath
if expanded.hasPrefix("/") {
return URL(fileURLWithPath: expanded).standardizedFileURL
}
return URL(
fileURLWithPath: expanded,
relativeTo: URL(fileURLWithPath: FileManager.default.currentDirectoryPath, isDirectory: true)
).standardizedFileURL
}

private func artifactRequiredOperand(_ operands: [String], subcommand: String) throws -> String {
let value = operands.joined(separator: " ").trimmingCharacters(in: .whitespacesAndNewlines)
guard !value.isEmpty else {
throw CLIError(message: String(
format: String(
localized: "cli.artifact.error.missingOperand",
defaultValue: "artifact %@ requires a value"
),
subcommand
), exitCode: 2)
}
return value
}

private func artifactCaptureContext(
projectRoot: URL,
environment: [String: String]
) -> ArtifactCaptureContext {
let codexSession = environment["CMUX_CODEX_SESSION_ID"]
let claudeSession = environment["CMUX_CLAUDE_SESSION_ID"]
return ArtifactCaptureContext(
projectRoot: projectRoot,
workspaceID: environment["CMUX_WORKSPACE_ID"],
workspaceTitle: environment["CMUX_WORKSPACE_TITLE"],
sessionID: codexSession ?? claudeSession ?? environment["CMUX_AGENT_SESSION_ID"],
agentName: codexSession == nil ? (claudeSession == nil ? environment["CMUX_AGENT_NAME"] : "claude") : "codex"
)
}

private func artifactFiles(in nodes: [ArtifactNode]) -> [ArtifactNode] {
nodes.flatMap { node in
node.isDirectory ? artifactFiles(in: node.children) : [node]
}
}

private func artifactPayload(_ node: ArtifactNode) -> [String: Any] {
[
"name": node.name,
"relative_path": node.relativePath,
"path": node.absolutePath,
"kind": node.fileKind?.rawValue ?? "other",
"size": node.size ?? 0,
]
}

private func artifactOutcomeName(_ outcome: ArtifactImportOutcome) -> String {
switch outcome {
case .copied: return "copied"
case .deduplicated: return "deduplicated"
case .alreadyStored: return "already_stored"
case .skipped: return "skipped"
}
}

private func openArtifact(_ node: ArtifactNode) throws {
let process = Process()
process.executableURL = URL(fileURLWithPath: "/usr/bin/open")
process.arguments = [node.absolutePath]
try process.run()
process.waitUntilExit()
guard process.terminationStatus == 0 else {
throw CLIError(message: String(
format: String(
localized: "cli.artifact.error.openFailed",
defaultValue: "Could not open artifact at %@"
),
node.absolutePath
))
}
}

private func artifactErrorMessage(_ error: ArtifactStoreError) -> String {
switch error {
case .sourceNotRegularFile(let path):
return String(format: String(localized: "cli.artifact.error.notFile", defaultValue: "Not a regular file: %@"), path)
case .unsupportedExtension(let pathExtension):
return String(format: String(localized: "cli.artifact.error.unsupported", defaultValue: "Unsupported artifact extension: %@"), pathExtension)
case .fileTooLarge(let actual, let limit):
return String(format: String(localized: "cli.artifact.error.tooLarge", defaultValue: "Artifact is too large (%lld bytes; limit %lld)."), actual, limit)
case .artifactNotFound(let name):
return String(format: String(localized: "cli.artifact.error.notFound", defaultValue: "Artifact not found: %@"), name)
case .ambiguousArtifactName(let name, let matches):
return String(format: String(localized: "cli.artifact.error.ambiguous", defaultValue: "Artifact name '%@' is ambiguous: %@"), name, matches.joined(separator: ", "))
case .pathOutsideStore(let path):
return String(format: String(localized: "cli.artifact.error.outsideStore", defaultValue: "Artifact path escaped the store: %@"), path)
}
}
}
1 change: 1 addition & 0 deletions CLI/CMUXCLI+CommandSuggestions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ extension CMUXCLI {
"__internal_flags",
"__tmux-compat",
"agent-hibernation",
"artifact",
"ai-accounts",
"auth",
"bind-key",
Expand Down
11 changes: 7 additions & 4 deletions CLI/cmux.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3012,7 +3012,7 @@ struct CMUXCLI {
"--dx", "--dy", "--email", "--event", "--expires", "--focus",
"--function", "--id", "--image", "--index", "--key", "--kind",
"--label", "--layout", "--lines", "--load-state", "--max-depth", "--name", "--os",
"--order", "--out", "--pane", "--panel", "--path", "--profile", "--property",
"--order", "--out", "--pane", "--panel", "--path", "--profile", "--project", "--property",
"--provider", "--relay-port", "--script", "--selector", "--session",
"--shell", "--source", "--subtitle", "--surface", "--tab", "--target-pane", "--team",
"--text", "--timeout", "--timeout-ms", "--title", "--transcript",
Expand Down Expand Up @@ -3143,7 +3143,7 @@ struct CMUXCLI {
return true
}

func run() throws {
func run() async throws {
let processEnv = ProcessInfo.processInfo.environment
let cliBundleIdentifier = CLISocketPathResolver.currentAppBundleIdentifier()
var explicitSocketPath: String? = nil
Expand Down Expand Up @@ -3241,6 +3241,7 @@ struct CMUXCLI {
if command == "docs" { try runDocsCommand(commandArgs: commandArgs, jsonOutput: jsonOutput); return }
if command == "welcome" { printWelcome(); return }
if command == "sessions" || command == "session-debug" { try runSessionsCommand(commandArgs: command == "session-debug" ? ["debug"] + commandArgs : commandArgs, jsonOutput: jsonOutput, processEnv: processEnv); return }
if command == "artifact" { try await runArtifactCommand(commandArgs: commandArgs, jsonOutput: jsonOutput, processEnvironment: processEnv); return }
if command == "__sigpipe-probe" { try runSIGPIPEProbe(commandArgs: commandArgs); return }
if command == "__sigpipe-stdin-pipe-probe" { try runSIGPIPEStdinPipeProbe(); return }
if command == "__sigpipe-inspect" { try runSIGPIPEInspect(commandArgs: commandArgs); return }
Expand Down Expand Up @@ -14916,6 +14917,7 @@ struct CMUXCLI {

Check connectivity to the cmux socket server.
"""
case "artifact": return artifactUsage()
case "capabilities":
return """
Usage: cmux capabilities
Expand Down Expand Up @@ -35090,6 +35092,7 @@ export default CMUXSessionRestore;

Commands:
welcome
\(String(localized: "cli.artifact.helpLine", defaultValue: "artifact <list|path|open|add|search> [--project <path>]"))
docs [settings|shortcuts|api|browser|agents|dock|sidebars]
settings [open [target]|path|docs|<target>]
config <doctor|check|validate|path|paths|docs|documentation|reload>
Expand Down Expand Up @@ -35288,7 +35291,7 @@ private enum CMUXCLIOutput {

@main
struct CMUXTermMain {
static func main() {
static func main() async {
let initialSIGPIPEInspectionPayload = CMUXCLI.currentSIGPIPEInspectionPayload()
_ = signal(SIGPIPE, SIG_DFL)
configureCLIStdioNoSIGPIPE()
Expand All @@ -35297,7 +35300,7 @@ struct CMUXTermMain {
initialSIGPIPEInspectionPayload: initialSIGPIPEInspectionPayload
)
do {
try cli.run()
try await cli.run()
} catch {
CMUXCLIOutput.writeStandardError("Error: \(error)\n")
let exitCode = (error as? CLIError)?.exitCode ?? 1
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import Foundation

/// Stable project-local location returned after saving a chat artifact.
public struct ChatArtifactSaveResult: Codable, Equatable, Sendable {
/// Absolute path to the persisted artifact on the Mac.
public let path: String
/// Path relative to the project's `.cmux/artifacts` directory.
public let relativePath: String
/// Prompt-ready project-relative reference.
public let reference: String

/// Creates the location returned for a persisted chat artifact.
///
/// - Parameters:
/// - path: Absolute path to the persisted file on the Mac.
/// - relativePath: Path relative to the project's artifact root.
/// - reference: Prompt-ready project-relative reference.
public init(path: String, relativePath: String, reference: String) {
self.path = path
self.relativePath = relativePath
self.reference = reference
}
}
Loading