Skip to content

feat: allow task prompt to be loaded from file (#157)#200

Merged
spboyer merged 4 commits into
mainfrom
squad/157-prompt-from-file
Apr 21, 2026
Merged

feat: allow task prompt to be loaded from file (#157)#200
spboyer merged 4 commits into
mainfrom
squad/157-prompt-from-file

Conversation

@spboyer
Copy link
Copy Markdown
Member

@spboyer spboyer commented Apr 21, 2026

Summary

Closes #157

Adds prompt_file as an alternative to inline prompt in task YAML. Users can now specify:

inputs:
  prompt_file: path/to/prompt.md

The file path is resolved relative to the task YAML file's directory.

Changes

  • internal/models/testcase.go — Added MessageFile field to TestStimulus (yaml:"prompt_file"). Added resolvePromptFile() method called from LoadTestCase() that reads file content into Message.
  • internal/models/testcase_test.go — 7 new test cases: file load, subdirectory paths, mutual exclusivity error, missing file error, inline fallback, empty inputs, multiline content.
  • schemas/task.schema.json — Added prompt_file property and oneOf constraint replacing the hard required: ["prompt"].

Validation Rules

  • Error if both prompt and prompt_file are set
  • Error if prompt_file path doesn't exist
  • Path resolved relative to task YAML directory

Working as Linus (Backend Developer)

Copilot AI review requested due to automatic review settings April 21, 2026 16:59
@github-actions github-actions Bot enabled auto-merge (squash) April 21, 2026 16:59
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds support for specifying a task prompt via an external file (inputs.prompt_file) in task YAML, resolving the file path relative to the task YAML directory.

Changes:

  • Extend task stimulus model to support prompt_file and load file contents into the prompt during LoadTestCase().
  • Add tests covering prompt file loading behavior and validation scenarios.
  • Update schemas/task.schema.json to allow either prompt or prompt_file via oneOf.
Show a summary per file
File Description
schemas/task.schema.json Allows inputs.prompt_file as an alternative to inline inputs.prompt via oneOf.
internal/models/testcase.go Adds prompt_file field and resolves it into Stimulus.Message at load time.
internal/models/testcase_test.go Adds unit tests for prompt file loading and related parsing/validation behavior.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 5

Comment thread internal/models/testcase.go
Comment thread internal/models/testcase.go
Comment thread schemas/task.schema.json
Comment thread internal/models/testcase_test.go
Comment thread internal/models/testcase.go
Copilot AI review requested due to automatic review settings April 21, 2026 17:20
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot's findings

  • Files reviewed: 6/6 changed files
  • Comments generated: 7

Comment thread schemas/task.schema.json
Comment thread internal/suggest/suggest.go
Comment thread internal/models/testcase_test.go
Comment thread internal/models/testcase_test.go
Comment thread internal/models/testcase.go
Comment thread internal/models/testcase.go
Comment thread internal/models/testcase.go
Copilot AI and others added 4 commits April 21, 2026 14:21
Add prompt_file field to TestStimulus as an alternative to inline prompt.
When prompt_file is set, the file content is read and used as the prompt
message. The path is resolved relative to the task YAML file's directory.

Validation:
- Error if both prompt and prompt_file are set
- Error if prompt_file doesn't exist

Includes 7 test cases covering file load, subdirectory paths, mutual
exclusivity, missing file, inline fallback, empty inputs, and multiline.
Updates task.schema.json with prompt_file property and oneOf constraint.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…dPath

filepath.IsAbs does not recognize /etc/evil.yaml as absolute on Windows
since it lacks a drive letter. Add explicit check for leading / to catch
cross-platform absolute path injection.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Reject absolute paths and path traversal (security, per runner pattern)
- Clear MessageFile after resolve to avoid leaking paths in serialized output
- Add minLength: 1 to prompt_file in JSON schema
- Add 3 new tests: absolute path, path traversal, MessageFile clearing

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@spboyer spboyer force-pushed the squad/157-prompt-from-file branch from 65ede22 to 296628d Compare April 21, 2026 18:21
@spboyer spboyer merged commit 0540774 into main Apr 21, 2026
5 of 6 checks passed
@spboyer spboyer deleted the squad/157-prompt-from-file branch April 21, 2026 18:26
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.

Add the ability to specify the task prompt from a file.

3 participants