Add support for new import syntax {{#import}} and deprecate @include/@import#1275
Add support for new import syntax {{#import}} and deprecate @include/@import#1275
Conversation
…import Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
pelikhan
left a comment
There was a problem hiding this comment.
update to syntax to
{{#import ...}}
The : is optinal and ignores
{{#import: ...}} # ok too, ignore :
|
@copilot update to syntax to {{#import ...}} The : is optinal and ignores {{#import: ...}} # ok too, ignore : |
|
@copilot format, lint, recompile |
…path}} Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Done! The colon is now optional in the import syntax. Both
Done! The colon is now optional in the import syntax. Both |
Done! ✓
All unit tests pass. No commits needed as the code was already properly formatted and compiled. |
| {{#import relative/path/to/file.md}} | ||
| ``` | ||
|
|
||
| Or with an optional colon: |
There was a problem hiding this comment.
Removed optional colon documentation from Basic Import Syntax section.
|
|
||
| Imports files relative to the current markdown file's location. | ||
|
|
||
| :::note |
There was a problem hiding this comment.
Removed the note about optional colon syntax.
| {{#import? relative/path/to/file.md}} | ||
| ``` | ||
|
|
||
| Or with a colon: |
There was a problem hiding this comment.
Removed colon syntax documentation from Optional Imports and Section-Specific Imports sections.
| + {{#import shared/config.md#Section}} | ||
| ``` | ||
|
|
||
| You can also use the colon if preferred: |
There was a problem hiding this comment.
Removed the "You can also use the colon if preferred" section from Legacy Syntax.
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Overview
This PR implements the new
{{#import ... }}syntax for imports in agentic workflows while maintaining full backward compatibility with the existing@includeand@importsyntax. The old syntax is now deprecated and will display helpful warnings during compilation.Motivation
The new syntax provides better consistency with the existing
{{#if ...}}template syntax and creates a clearer distinction between workflow directives and regular markdown content.Changes
New Import Syntax
The following syntax is now available and recommended:
{{#import shared/tools.md}} # Basic import {{#import? shared/optional.md}} # Optional import {{#import shared/tools.md#Section}} # Section-specific importNote: While the colon after
#importis supported internally for backward compatibility (e.g.,{{#import: path}}), the recommended and documented syntax omits the colon for simplicity and consistency.Deprecation Warnings
When using the old syntax, users now see clear migration guidance:
Implementation Details
ParseImportDirective()to classify and parse import directivesBackward Compatibility
@include,@import) remains fully functional{{#import: path}}) supported internally but not documentedTesting
Files Changed
pkg/parser/frontmatter.go- Core parser with dual syntax support and optional colonpkg/parser/import_syntax_test.go- New comprehensive test suitepkg/workflow/template.go- Validation updatespkg/cli/imports.go&pkg/cli/remove_command.go- CLI processing updatesdocs/src/content/docs/guides/packaging-imports.md- Documentation updates (simplified to show only syntax without colon).github/instructions/github-agentic-workflows.instructions.md- Agent instructions.github/workflows/dev.md- Example workflow migrated to new syntaxMigration Path
Users can adopt the new syntax gradually:
Fixes #1274
Original prompt
💡 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.