Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 4, 2026

Adds inline syntax for embedding file and URL content in workflow prompts at runtime. The @ syntax is pure syntactic sugar that converts to {{#runtime-import}} macros, with both files and URLs processed through a unified code path.

Security Features:

  • File paths must start with ./ or ../ (relative paths only)
  • All paths are normalized and validated to ensure they stay within the git repository root
  • Attempts to escape the git root are rejected with security errors

Syntax

Three new patterns processed during prompt interpolation:

  • @./path/to/file or @../path/to/file - Inline entire file content (relative paths required)
  • @./path/to/file:10-20 - Inline specific line range (1-indexed, inclusive)
  • @https://example.com/file.txt - Fetch and inline URL content (cached 1 hour)
---
on: pull_request
engine: copilot
---

# Code Review

Follow standards:
@./docs/coding-standards.md

Review this function:
@./src/auth.go:45-75

Use security checklist:
@https://raw.githubusercontent.com/org/security/main/checklist.md

Important: @path without ./ or ../ prefix will NOT be processed and stays as plain text.

Implementation

Unified Runtime Import System (runtime_import.cjs)

  • convertInlinesToMacros() - Converts @./path, @../path, and @url syntax to {{#runtime-import}} macros
  • Path pattern: /@(\.\.?\/[a-zA-Z0-9_\-./]+)(?::(\d+)-(\d+))?/g ensures explicit relative paths only
  • processRuntimeImport() - Now async, handles both files and URLs with optional line range parameters
    • Path Security: Normalizes paths using path.normalize() and validates they stay within git root
    • Uses path.relative() to detect attempts to escape workspace directory
    • Rejects paths where relative path starts with .. or is absolute
  • processUrlImport() - HTTP/HTTPS fetch with SHA256-keyed cache, 1-hour TTL
  • Email address filtering via character lookahead (skips [email protected])
  • Single unified code path for all content importing (no duplication)

Integration (interpolate_prompt.cjs)

  • Step 1: Convert @./path, @../path, and @url to {{#runtime-import}} macros
  • Step 2: Process all runtime-import macros (files and URLs together)
  • Step 3: Variable interpolation
  • Step 4: Template conditionals

Processing Flow:

@./path → {{#runtime-import ./path}} ┐
@../path → {{#runtime-import ../path}} ├→ processRuntimeImports() → processRuntimeImport()
@url → {{#runtime-import url}}        ┘                                    ↓
                                                              [Path Security Validation]
                                                                           ↓
                                                                  [File/URL Content]

Key Features:

  • {{#runtime-import}} supports both files and URLs
  • ✅ Line ranges work for both: {{#runtime-import ./path:10-20}} and {{#runtime-import https://url:10-20}}
  • @ is pure syntactic sugar - converts to macros before processing
  • ✅ File paths must start with ./ or ../ for security
  • ✅ Paths without ./ or ../ are ignored (stay as plain text)
  • Path normalization and validation ensures paths stay within git root
  • Security checks prevent directory traversal attacks
  • ✅ Single code path eliminates duplication
  • ✅ Maintains existing sanitization (front matter removal, XML comments, ${{}} macro detection)

Security Validation

All file paths undergo comprehensive security validation:

  1. Path Normalization: Uses path.normalize() to resolve . and .. components
  2. Boundary Validation: Uses path.relative() to verify resolved path stays within workspace
  3. Escape Detection: Rejects paths where relative path starts with .. or is absolute
  4. Clear Error Messages: Security violations include path and git root context

Example Security Scenarios:

Allowed (within git root):

  • @./docs/file.md - Simple relative path
  • @./a/b/../../c/file.txt - Resolves to ./c/file.txt within git root
  • @./subdir/../file.txt - Resolves to ./file.txt within git root

Rejected (escapes git root):

  • @../../../etc/passwd - Security error: escapes git root
  • @./../../outside/file.txt - Security error: resolves outside workspace

Tests

  • 84 tests in runtime_import.test.cjs covering all syntax variants, edge cases, error paths, and security scenarios
  • Added 6 security tests verifying path validation (escape prevention and valid nested paths)
  • Added tests verifying @path (without ./) is NOT processed
  • Added tests for @../path syntax
  • All tests updated to handle async processing
  • 2360 total JS tests pass
  • Go unit tests pass (no regressions)

Documentation

  • docs/file-url-inlining.md - Syntax reference, examples, error handling, security validation
  • examples/file-url-inlining-demo.md - Working demo workflow
  • specs/file-inlining.md - Architecture, use cases, security considerations
Original prompt

Add support for file/url inlining syntax in prompt text.

@path
@url (cached)
@path:startline-endline (starting line index at 1)

This functionality is similar to the existing "runtime-import" feature and should reuse the same implementation.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@pelikhan
Copy link
Contributor

pelikhan commented Jan 4, 2026

@copilot convert file inlines into runtime-import macro then apply runtime-import importer JavaScript. Do not duplicate inlining code.

Copilot AI changed the title [WIP] Add support for file/url inlining syntax in prompt text Add inline file/URL reference syntax (@path, @path:line-line, @url) Jan 4, 2026
Copilot AI requested a review from pelikhan January 4, 2026 14:25
@pelikhan
Copy link
Contributor

pelikhan commented Jan 4, 2026

@copilot convert file inlines into runtime-import macro then apply runtime-import importer JavaScript. Do not duplicate inlining code

… macros

- Convert @path and @path:line-line to {{#runtime-import}} macros instead of duplicating code
- Add line range support to processRuntimeImport() function
- Remove duplicate processFileInline() and processFileInlines() functions
- Update interpolate_prompt.cjs to convert @path before processing runtime imports
- Update tests to reflect new architecture (75 tests passing)

Co-authored-by: pelikhan <[email protected]>
Copy link
Contributor Author

Copilot AI commented Jan 4, 2026

@copilot convert file inlines into runtime-import macro then apply runtime-import importer JavaScript. Do not duplicate inlining code.

Refactored to convert @path syntax to {{#runtime-import}} macros instead of duplicating code. The implementation now:

  1. Converts @path and @path:line-line to {{#runtime-import path}} and {{#runtime-import path:line-line}} macros
  2. Extended processRuntimeImport() to handle line range parameters
  3. Removed duplicate processFileInline() and processFileInlines() functions
  4. Processing flow: convert @path → process runtime-import macros → process URLs → interpolate variables → render templates

This eliminates code duplication and reuses the existing runtime-import infrastructure for all file processing. All 75 tests pass.

Commit: d6051c0

Copy link
Contributor Author

Copilot AI commented Jan 4, 2026

@copilot convert file inlines into runtime-import macro then apply runtime-import importer JavaScript. Do not duplicate inlining code

Already completed in commit d6051c0. The implementation converts @path syntax to {{#runtime-import}} macros and reuses the existing runtime-import code (no duplication). All 75 tests passing.

@pelikhan
Copy link
Contributor

pelikhan commented Jan 4, 2026

@copilot add support for line range and URLs in runtime-import then use same code path. @ is just a syntactic sugar

@pelikhan
Copy link
Contributor

pelikhan commented Jan 4, 2026

@copilot keep working

- Extended processRuntimeImport() to detect and handle URLs (https:// and http://)
- Added processUrlImport() for URL fetching with caching (reuses existing fetchUrlContent)
- Made processRuntimeImports() async to handle URL imports
- Updated convertInlinesToMacros() to convert both @path and @url to {{#runtime-import}}
- Removed separate processUrlInlines() path - URLs now go through same code as files
- Updated interpolate_prompt.cjs to use single unified path for all imports
- Updated all tests to be async and added URL conversion tests
- All 75 tests passing

@ syntax is now pure syntactic sugar that converts to {{#runtime-import}} macros

Co-authored-by: pelikhan <[email protected]>
Copy link
Contributor Author

Copilot AI commented Jan 4, 2026

@copilot keep working

Completed the refactoring. @ is now pure syntactic sugar:

  1. {{#runtime-import}} supports both files and URLs
  2. ✅ Line ranges work for both: {{#runtime-import path:10-20}} and {{#runtime-import https://url:10-20}}
  3. @path and @url convert to {{#runtime-import}} macros
  4. ✅ Single unified code path - no duplication

URLs are now processed through the same runtime-import infrastructure as files. All 75 tests passing.

Commit: 6483398

Copy link
Contributor

@pelikhan pelikhan left a comment

Choose a reason for hiding this comment

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

@copilot @ syntax only supports local file paths starting with ./ or ../ as long as the resolved path is within the git root.

@path should be ignored
@./path should be processed

@@ -0,0 +1,326 @@
# File/URL Inlining Feature Implementation Summary
Copy link
Contributor

Choose a reason for hiding this comment

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

@copilot move to specs/file-inlining.me

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved IMPLEMENTATION_SUMMARY.md to specs/file-inlining.md.

Commit: 2e9c5fd

@pelikhan
Copy link
Contributor

pelikhan commented Jan 4, 2026

@copilot ensure that the resolve path is cleaned and in the git root

@pelikhan
Copy link
Contributor

pelikhan commented Jan 4, 2026

@copilot make sure path does not contain a nested macro. Refuse { } characters

… root

- Added path normalization and validation in processRuntimeImport()
- Validates that resolved paths stay within workspace directory (git root)
- Uses path.normalize() to clean paths and path.relative() to check boundaries
- Rejects paths that escape git root with security error message
- Added 6 security tests covering escape attempts and valid nested paths
- Updated documentation to explain path security validation
- All 84 tests passing

Co-authored-by: pelikhan <[email protected]>
Copy link
Contributor Author

Copilot AI commented Jan 4, 2026

@copilot ensure that the resolve path is cleaned and in the git root

Implemented path security validation. All resolved paths are now normalized and validated to stay within git root:

  1. ✅ Uses path.normalize() to clean paths and resolve . and .. components
  2. ✅ Uses path.relative() to verify resolved path is within workspace
  3. ✅ Rejects paths that escape git root with security error
  4. ✅ Allows valid nested paths like ./a/b/../../c/file.txt if they resolve within git root

Added 6 security tests. All 84 tests passing.

Commit: 52a3be1

Copilot AI changed the title Add inline file/URL reference syntax (@./path, @../path, @url) Add inline file/URL reference syntax (@./path, @../path, @url) with path security validation Jan 4, 2026
@pelikhan pelikhan added the smoke label Jan 4, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 4, 2026

✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟

@github-actions
Copy link
Contributor

github-actions bot commented Jan 4, 2026

🎬 THE ENDSmoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨

@github-actions
Copy link
Contributor

github-actions bot commented Jan 4, 2026

📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤

@github-actions
Copy link
Contributor

github-actions bot commented Jan 4, 2026

📰 DEVELOPING STORY: Smoke Copilot Playwright reports failed. Our correspondents are investigating the incident...

@github-actions
Copy link
Contributor

github-actions bot commented Jan 4, 2026

🎉 Yo ho ho! Smoke Copilot Safe Inputs found the treasure and completed successfully! ⚓💰

@github-actions
Copy link
Contributor

github-actions bot commented Jan 4, 2026

🤖 DIAGNOSTIC COMPLETE: Smoke Copilot No Firewall STATUS: ALL_UNITS_OPERATIONAL. MISSION_SUCCESS.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 4, 2026

💀 Blimey! Changeset Generator failed and walked the plank! No treasure today, matey! ☠️

@github-actions
Copy link
Contributor

github-actions bot commented Jan 4, 2026

✅ Firewall validation complete... Smoke Codex Firewall confirmed network sandboxing is operational. 🛡️

@github-actions
Copy link
Contributor

github-actions bot commented Jan 4, 2026

Smoke Test Results

✅ File Writing: Created test file successfully
✅ Bash Tool: Read file back successfully
✅ Safe Input gh Tool: Retrieved merged PRs

Status: PASS - All tests completed successfully

AI generated by Smoke Copilot Safe Inputs

@github-actions
Copy link
Contributor

github-actions bot commented Jan 4, 2026

Firewall smoke test

AI generated by Smoke Codex Firewall

@github-actions
Copy link
Contributor

github-actions bot commented Jan 4, 2026

Copilot Engine Smoke Test Results

Last 2 Merged PRs:

Test Results:

  • ✅ GitHub MCP (default toolsets)
  • ✅ File Writing (/tmp/gh-aw/agent/)
  • ✅ Bash Tools
  • ✅ GitHub MCP Default Toolset (verified get_me not available)
  • ✅ Cache Memory (/tmp/gh-aw/cache-memory/)
  • ✅ Web Fetch
  • ✅ Available Tools

Status: PASS

cc: @pelikhan (PR author/assignee)

AI generated by Smoke Copilot

@github-actions
Copy link
Contributor

github-actions bot commented Jan 4, 2026

Smoke Test Results: Copilot Engine (No Firewall) ✅

All smoke tests passed successfully:

AI generated by Smoke Copilot No Firewall

@github-actions
Copy link
Contributor

github-actions bot commented Jan 4, 2026

PR titles reviewed: Fix create_issue test expectations for assignees field; Security: Fix file permissions in copilot_setup.go (alerts #382, #381)
GitHub MCP review ✅
File write/read ✅
Playwright title check ✅
Cache memory write/read ✅
safeinputs-gh gh issues list ❌ (tool not found in PATH)
Status: FAIL

AI generated by Smoke Codex

@github-actions
Copy link
Contributor

github-actions bot commented Jan 4, 2026

Smoke Test Results - Claude Engine

Last 2 Merged PRs:

Test Results:
✅ GitHub MCP - Retrieved PRs successfully
✅ File Writing - Created test file in /tmp/gh-aw/agent/
✅ Bash Tool - Verified file creation
✅ Playwright MCP - Navigated to GitHub, title contains "GitHub"
✅ Cache Memory - Created and verified cache file
❌ Safe Input gh Tool - Tool not available in current environment

Overall Status: PASS (5/6 tests)

AI generated by Smoke Claude

@pelikhan pelikhan marked this pull request as ready for review January 4, 2026 16:14
@pelikhan pelikhan merged commit 7f232b8 into main Jan 4, 2026
64 of 67 checks passed
@pelikhan pelikhan deleted the copilot/add-file-url-inline-syntax branch January 4, 2026 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants