feat(project-files): let Chat read and write Project files
Summary
Lets Chat read, search, write, upload and copy Project files, on top of the Project files backend that #9015 through #9019 merged.
Everything stays behind the projects flag, which turns on only after the project-first redesign ships its Project files UI.
Scope: backend and Chat transport only.
The Project file browser and other Project UI were removed from this PR, because the redesign will build that surface project-first rather than inside the workspace Files page.
The removed UI is preserved at the project-files-ui-seed tag for that work.
The only client change left is the shared ChatContext wire type (Project contexts and file owners) and its kind registry entry.
What Chat can do with Project files
- Discover the user's Projects (
projects list) and target one explicitly per command with--project <id>. - Read, view and grep Project files, write and upload them from the workbench sandbox, and copy files between workspaces and Projects.
- Accept Project and Project file tags in a user's message.
Secret handling matches workspace files
- Project text reads and grep now redact secrets the way workspace text reads do, instead of refusing any file that contains one.
- One text extraction core is shared by workspace text reads and private file observation: parse, redact before a line window can cut a secret, then slice.
readProjectFileTextadmits the source and every rendered input ascompletetext and returns text only, so bytes never leave under acompletelabel.readProjectFileArtifactstill admitsopaquebytes, so visual and byte reads of a file with a secret are still refused.
Flag gating
- Project sandbox callbacks now run under the same workbench content gate as workspace callbacks, since staging treats resource-delegated Chat principals as Chat.
- The chat resources API refuses new Project tabs while Projects are off; removing or reordering stored tabs still works.
- Every other Chat path to Project data already checks the flag: worker hints,
list_user_projects, Project file use cases, and sandbox callbacks. - A flag check in
list_user_projectsthat could never run was removed.
Pairing with simstudioai/mothership#594
This PR and the worker companion merge back to back, Sim first.
Sim sends file-owner hints only when the worker's health check advertises the file-owner protocol, so merging Sim first changes nothing at runtime.
The worker byte-checks Sim's copies of the generated contracts, so the pair must land together; the companion pin will point at this PR's head on staging.
Type of Change
- New feature
- Other: removes the Project files UI from scope
Testing
- Typecheck, repository audits and the test-types ratchet pass.
- Unit suites for the touched areas pass (427 files).
- Project and content integration suites pass against disposable PostgreSQL, including Project reads, grep, write transport, account deletion and private purge.
- New integration coverage checks that a Project file with a secret is masked at the model egress for full reads, never leaks through a line-range read, still matches grep on its other lines, and is refused for byte reads.
- Locally, nine generated-document archive tests time out because the isolated document worker is unavailable; they time out identically on the commit before this change.
- Staging verification with Projects off: pre-deploy fixtures are seeded and the old release passes all three Chat checks (grep masks a workspace secret, a ranged read shows the secret's name instead of its value, a sandbox read succeeds); the post-deploy run follows once this pair is serving.
- E2B and Daytona acceptance of the Project workbench flow is still outstanding and gates the flag flip, not this merge.
Reviewers: focus on readProjectFileText and the artifact view factory in artifacts.ts, the shared extractFileTextFromBytes, and the Project sandbox callback gate.
Checklist
- Code follows project style guidelines
- Self-reviewed my changes
- Tests added/updated and passing
- No new warnings introduced
- I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)
š¤ Generated with Claude Code