Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 20, 2025

Parameter substitution via -p flag (e.g., ${jira_issue_key}) only worked in task files. Rule files printed parameters verbatim.

Changes

  • main.go: Apply os.Expand to rule content in ruleFileWalker, matching existing task behavior in emitTaskFileContent
  • main_test.go: Add test coverage for parameter expansion in rules (both successful substitution and missing parameter preservation)

Example

# rule.md
Issue: ${jira_issue_key}
Project: ${project_name}
$ coding-context-cli -p jira_issue_key=PROJ-123 -p project_name=MyApp my-task
# Output now includes:
# Issue: PROJ-123
# Project: MyApp

Missing parameters preserve placeholder syntax: ${undefined_param}.

Original prompt

This section details on the original issue you should resolve

<issue_title>Extend templating to rules</issue_title>
<issue_description>Currently, we only template variables with in the tasks. I'd like to template them in the rules files too.

E.g. ${jira_issue_key} could be used in any rule file.</issue_description>

Comments on the Issue (you are @copilot in this section)

@alexec @swedishborgie thoughts?

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Copilot AI changed the title [WIP] Extend templating to support rules files Extend parameter templating to rule files Nov 20, 2025
Copilot AI requested a review from alexec November 20, 2025 04:49
@alexec alexec requested a review from Copilot November 20, 2025 04:50
@alexec alexec marked this pull request as ready for review November 20, 2025 04:50
Copy link
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

This PR extends parameter substitution (via the -p flag) from task files to rule files. Previously, parameters like ${jira_issue_key} only worked in task files, with rule files printing them verbatim. Now, both rule and task files support parameter expansion with identical behavior.

Key Changes:

  • Parameter expansion now applies to rule file content using os.Expand
  • Missing parameters preserve the placeholder syntax ${param_name}
  • Table-driven tests added for both successful substitution and missing parameter handling

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
main.go Added parameter expansion to ruleFileWalker function using os.Expand, matching the existing implementation in emitTaskFileContent
main_test.go Added comprehensive test coverage with two new test cases for parameter substitution in rules (successful substitution and missing parameter preservation)

@alexec alexec merged commit 932d53a into main Nov 20, 2025
8 checks passed
@alexec alexec deleted the copilot/extend-templating-to-rules branch November 20, 2025 04:55
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.

Extend templating to rules

2 participants