feat: add RepositoryFiles context for component file access#5272
Conversation
Adds a new RepositoryFilesContext interface to core.ExecutionContext that lets components list and read files from the canvas git repository (Files tab). - Interface: List() and Read(path) backed by supergit git.Provider - Lazy repo resolution via FindRepositoryUnscoped on first access - Wired into NodeQueueWorker (component execution) and webhook handler - gitProvider passed to NodeQueueWorker from server.go Part of repository-files-context mission.
Allows the Claude Text Prompt component to read files from the canvas repository (Files tab) and include them as document content blocks in the API request. - New 'files' config field: list of file paths to include - Files read via ctx.RepositoryFiles.Read() at execution time - Sent as inline document content blocks (type: document, source: text) - 100KB per file size limit - Media type detection based on file extension - Updated Message.Content to support both string and []ContentBlock Part of repository-files-context mission.
- Add RepositoryFiles to SetupContext so components can validate files exist during publish (before any run) - Claude textPrompt Setup() now checks configured files exist in the repository and returns available files in the error message - Fix NodeExecutor: was missing RepositoryFiles on ExecutionContext (this was the actual execution path, not process_queue_context) - Wire gitProvider through CanvasPublisher and publish functions - Error on nil RepositoryFiles when files are configured (no silent skip) - Fix media type: Claude inline documents only accept text/plain Part of repository-files-context mission.
|
👋 Commands for maintainers:
|
|
❌ OSS Guard found dependency licenses that are not permitted for this project. Project license (from repository): Apache-2.0 Permitted dependency licenses: MIT,Apache-2.0,BSD-2-Clause,BSD-3-Clause,ISC,0BSD,Unlicense,CC0-1.0,CC-BY-4.0,Zlib,MPL-2.0,OpenSSL,BlueOak-1.0.0 Reason: One or more dependencies use licenses that are not compatible with the project license. osv-scanner report: Add approved exceptions in your repository's |
NewRepositoryFilesContext returns nil when gitProvider is nil, preventing panics in code paths where gitProvider isn't available (e.g., change request publishing).
|
❌ OSS Guard found dependency licenses that are not permitted for this project. Project license (from repository): Apache-2.0 Permitted dependency licenses: MIT,Apache-2.0,BSD-2-Clause,BSD-3-Clause,ISC,0BSD,Unlicense,CC0-1.0,CC-BY-4.0,Zlib,MPL-2.0,OpenSSL,BlueOak-1.0.0 Reason: One or more dependencies use licenses that are not compatible with the project license. osv-scanner report: Add approved exceptions in your repository's |
All CanvasPublisherOptions now receive gitProvider so Setup() can validate files exist at publish time. Previously only CreateCanvas had it; PublishCanvasVersion and PublishCanvasChangeRequest were missing it, causing file validation to silently skip.
|
❌ OSS Guard found dependency licenses that are not permitted for this project. Project license (from repository): Apache-2.0 Permitted dependency licenses: MIT,Apache-2.0,BSD-2-Clause,BSD-3-Clause,ISC,0BSD,Unlicense,CC0-1.0,CC-BY-4.0,Zlib,MPL-2.0,OpenSSL,BlueOak-1.0.0 Reason: One or more dependencies use licenses that are not compatible with the project license. osv-scanner report: Add approved exceptions in your repository's |
1. Remove debug log from node_queue_worker (left from debugging) 2. Use transaction-aware repo lookup in Setup (new NewRepositoryFilesContextInTransaction for publish path) 3. Error instead of silent skip when files configured but RepositoryFiles is nil 4. Normalize file paths before comparison (handle ./ and leading / in configured paths) 5. GitProvider already wired through all publish paths (from previous commit) Part of repository-files-context mission.
|
❌ OSS Guard found dependency licenses that are not permitted for this project. Project license (from repository): Apache-2.0 Permitted dependency licenses: MIT,Apache-2.0,BSD-2-Clause,BSD-3-Clause,ISC,0BSD,Unlicense,CC0-1.0,CC-BY-4.0,Zlib,MPL-2.0,OpenSSL,BlueOak-1.0.0 Reason: One or more dependencies use licenses that are not compatible with the project license. osv-scanner report: Add approved exceptions in your repository's |
|
❌ OSS Guard found dependency licenses that are not permitted for this project. Project license (from repository): Apache-2.0 Permitted dependency licenses: MIT,Apache-2.0,BSD-2-Clause,BSD-3-Clause,ISC,0BSD,Unlicense,CC0-1.0,CC-BY-4.0,Zlib,MPL-2.0,OpenSSL,BlueOak-1.0.0 Reason: One or more dependencies use licenses that are not compatible with the project license. osv-scanner report: Add approved exceptions in your repository's |
Human reviewer (lucaspin):
1. Rename RepositoryFiles -> Files on ExecutionContext/SetupContext
2. Remove duplicate decodeStringList hack - mapstructure handles
[]string from []any natively
3. Remove nil check on ctx.Files - contexts should always be
available (wired in all execution paths)
Bugbot:
4. Normalize file paths in Execute's buildUserContent (was only
normalized in Setup validation)
5. Remove dead mediaTypeForPath function - inline 'text/plain'
6. Fix normalizeFilePath('.') edge case - path.Clean('.') returns
'.' which wasn't handled
1. Add FieldTypeRepositoryFile config type - enables future UI file picker. Currently renders as text input (fallback). 2. Add total file size limit (500KB) - prevents context window blowup when multiple files are attached. Per-file limit remains 100KB. 3. Document Message.Content type flexibility - Content can be string or []ContentBlock, documented with comment. 4. Add defensive nil check in buildUserContent - returns clear error if Files context unavailable in execution paths that don't have gitProvider (e.g., integration subscriptions). 5. Context propagation in resolveRepo deferred - changing the RepositoryFilesContext interface to accept context.Context would be a breaking change across all callers. Tracked for follow-up.
1. Setup nil guard: ctx.Files can be nil when GitProvider is unavailable. Returns clear error instead of panic. 2. Use gitprovider.NormalizePath instead of custom normalizeFilePath. Aligns path normalization with the git layer (handles backslashes, null bytes, .git segments, .. traversal).
New field renderer for 'repository-file' type that renders a select dropdown populated with files from the canvas repository. - Fetches files via canvasesListCanvasRepositoryFiles API - Gets canvasId from URL params (useParams) - Shows file paths as dropdown options - Loading state and empty state handled - Registered in ConfigurationFieldRenderer switch statement This completes the frontend for the FieldTypeRepositoryFile config type added in the backend.
The files config is a list field with repository-file item type. ListFieldRenderer renders simple items as plain text inputs, not through ConfigurationFieldRenderer. Added explicit case for repository-file items to render the file picker dropdown.
…iles
SDK generates {canvasId} not {canvas_id} as the path parameter.
Was sending literal '{canvasId}' in the URL.
Cookie-authenticated requests need x-organization-id header. Without it, the org auth middleware returns 404.
- Fix test compilation: add nil gitProvider arg to all callers of PublishCanvasVersion, ActOnCanvasChangeRequest, NewNodeExecutor, NewNodeQueueWorker, and BuildProcessQueueContext in test files - Run gofmt -s on all files flagged by check.format.go - Use ValidateUserPath instead of NormalizePath for configured file paths in claude.textPrompt Setup and buildUserContent, blocking .superplane/ reserved paths from being sent to Claude - Add isError state to RepositoryFileFieldRenderer, showing 'Failed to load files' on API errors instead of 'No files found'
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 1023ce2. Configure here.
Per lucaspin's review — ResourceRegistry in test/support has a GitProvider available, use it instead of nil.

Summary
Gives every canvas component access to Files tab (repository files) at runtime via
ExecutionContext.RepositoryFiles. Uses it in the Claude textPrompt component to attach files as context in the API call.Changes
Phase 1: Core
RepositoryFilesContextinterface onExecutionContextandSetupContext(List + Read)git.Providerwith lazy repo resolutionNodeExecutor,NodeQueueWorker, webhook handler, andCanvasPublisherPhase 2: Claude textPrompt
filesconfig field (list of file paths from Files tab)ctx.RepositoryFiles.Read()at execution timeTesting
claude.textPromptcomponentagent.md) in the Files tab with specific contentfiles: [agent.md]and a prompt like "What is your purpose?"Verified
agent.mdcontent ("Your purpose is to find cat images") and references it in the response