Skip to content

feat: add RepositoryFiles context for component file access#5272

Merged
AleksandarCole merged 21 commits into
mainfrom
feat/repository-files-context
Jun 10, 2026
Merged

feat: add RepositoryFiles context for component file access#5272
AleksandarCole merged 21 commits into
mainfrom
feat/repository-files-context

Conversation

@bender-rodriguez-unit1

Copy link
Copy Markdown
Contributor

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

  • New RepositoryFilesContext interface on ExecutionContext and SetupContext (List + Read)
  • Implementation backed by supergit git.Provider with lazy repo resolution
  • Wired into NodeExecutor, NodeQueueWorker, webhook handler, and CanvasPublisher

Phase 2: Claude textPrompt

  • New files config field (list of file paths from Files tab)
  • Files read via ctx.RepositoryFiles.Read() at execution time
  • Sent to Claude as inline document content blocks alongside the prompt
  • 100KB per file size limit
  • Publish-time validation: checks files exist in the repo, returns clear error with available files list

Testing

  1. Create an app with a claude.textPrompt component
  2. Add a file (e.g., agent.md) in the Files tab with specific content
  3. Configure the textPrompt with files: [agent.md] and a prompt like "What is your purpose?"
  4. Run — Claude responds referencing the file content
  5. Try a typo in the filename — publish fails with "file not found" error listing available files

Verified

  • Tested on dev instance: Claude correctly reads agent.md content ("Your purpose is to find cat images") and references it in the response
  • Error handling works: nil context, missing files, API errors all surface clearly

Bender Rodriguez added 3 commits June 10, 2026 08:06
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.
@superplanehq-integration

Copy link
Copy Markdown

👋 Commands for maintainers:

  • /sp start - Start an ephemeral machine (takes ~30s)
  • /sp stop - Stop a running machine (auto-executed on pr close)

@superplane-gh-integration-9000

Copy link
Copy Markdown

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:

@csstools/color-helpers 5.1.0 (npm) - MIT-0
argparse 2.0.1 (npm) - Python-2.0
csv 3.3.5 (RubyGems) - Ruby, BSD-2-Clause
elkjs 0.10.0 (npm) - EPL-2.0
khroma 2.1.0 (npm) - UNKNOWN
posthog-js 1.368.2 (npm) - non-standard
stdlib 1.26.2 (Go) - UNKNOWN

Add approved exceptions in your repository's osv-scanner.toml.

Comment thread pkg/grpc/actions/canvases/publish_canvas_version.go
Comment thread pkg/workers/node_queue_worker.go Outdated
NewRepositoryFilesContext returns nil when gitProvider is nil,
preventing panics in code paths where gitProvider isn't available
(e.g., change request publishing).
@superplane-gh-integration-9000

Copy link
Copy Markdown

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:

@csstools/color-helpers 5.1.0 (npm) - MIT-0
argparse 2.0.1 (npm) - Python-2.0
csv 3.3.5 (RubyGems) - Ruby, BSD-2-Clause
elkjs 0.10.0 (npm) - EPL-2.0
khroma 2.1.0 (npm) - UNKNOWN
posthog-js 1.368.2 (npm) - non-standard
stdlib 1.26.2 (Go) - UNKNOWN

Add approved exceptions in your repository's osv-scanner.toml.

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.
@superplane-gh-integration-9000

Copy link
Copy Markdown

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:

@csstools/color-helpers 5.1.0 (npm) - MIT-0
argparse 2.0.1 (npm) - Python-2.0
csv 3.3.5 (RubyGems) - Ruby, BSD-2-Clause
elkjs 0.10.0 (npm) - EPL-2.0
khroma 2.1.0 (npm) - UNKNOWN
posthog-js 1.368.2 (npm) - non-standard
stdlib 1.26.2 (Go) - UNKNOWN

Add approved exceptions in your repository's osv-scanner.toml.

Comment thread pkg/workers/contexts/repository_files_context.go
Comment thread pkg/integrations/claude/text_prompt.go
Comment thread pkg/integrations/claude/text_prompt.go
Bender Rodriguez added 2 commits June 10, 2026 09:49
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.
@superplane-gh-integration-9000

Copy link
Copy Markdown

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:

@csstools/color-helpers 5.1.0 (npm) - MIT-0
argparse 2.0.1 (npm) - Python-2.0
csv 3.3.5 (RubyGems) - Ruby, BSD-2-Clause
elkjs 0.10.0 (npm) - EPL-2.0
khroma 2.1.0 (npm) - UNKNOWN
posthog-js 1.368.2 (npm) - non-standard
stdlib 1.26.2 (Go) - UNKNOWN

Add approved exceptions in your repository's osv-scanner.toml.

@superplane-gh-integration-9000

Copy link
Copy Markdown

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:

@csstools/color-helpers 5.1.0 (npm) - MIT-0
argparse 2.0.1 (npm) - Python-2.0
csv 3.3.5 (RubyGems) - Ruby, BSD-2-Clause
elkjs 0.10.0 (npm) - EPL-2.0
khroma 2.1.0 (npm) - UNKNOWN
posthog-js 1.368.2 (npm) - non-standard
stdlib 1.26.2 (Go) - UNKNOWN

Add approved exceptions in your repository's osv-scanner.toml.

Comment thread pkg/integrations/claude/text_prompt.go Outdated
Comment thread pkg/core/component.go Outdated
Comment thread pkg/integrations/claude/text_prompt.go Outdated
Comment thread pkg/integrations/claude/text_prompt.go Outdated
Comment thread pkg/integrations/claude/text_prompt.go Outdated
Comment thread pkg/integrations/claude/text_prompt.go Outdated
@superplane-policy-bot superplane-policy-bot Bot requested a review from lucaspin June 10, 2026 16:35
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
Comment thread pkg/integrations/claude/text_prompt.go
Comment thread pkg/workers/contexts/repository_files_context.go
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.
Comment thread pkg/integrations/claude/text_prompt.go
Comment thread pkg/integrations/claude/text_prompt.go Outdated
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).
Comment thread pkg/integrations/claude/text_prompt.go
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.
Comment thread web_src/src/ui/configurationFieldRenderer/index.tsx
Comment thread pkg/integrations/claude/text_prompt.go
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.
Comment thread pkg/integrations/claude/text_prompt.go
Bender Rodriguez and others added 4 commits June 10, 2026 18:23
…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'
Comment thread pkg/integrations/claude/text_prompt.go

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread pkg/grpc/actions/canvases/publish_canvas_version_test.go Outdated
Per lucaspin's review — ResourceRegistry in test/support has a
GitProvider available, use it instead of nil.
@superplane-policy-bot superplane-policy-bot Bot requested a review from lucaspin June 10, 2026 22:15
@AleksandarCole AleksandarCole merged commit 5fc4feb into main Jun 10, 2026
6 of 7 checks passed
@AleksandarCole AleksandarCole deleted the feat/repository-files-context branch June 10, 2026 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants