Skip to content

Add support for new import syntax {{#import}} and deprecate @include/@import#1275

Merged
pelikhan merged 5 commits intomainfrom
copilot/update-import-syntax-handling
Oct 6, 2025
Merged

Add support for new import syntax {{#import}} and deprecate @include/@import#1275
pelikhan merged 5 commits intomainfrom
copilot/update-import-syntax-handling

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Oct 6, 2025

Overview

This PR implements the new {{#import ... }} syntax for imports in agentic workflows while maintaining full backward compatibility with the existing @include and @import syntax. 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 import

Note: While the colon after #import is 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:

⚠ Deprecated syntax: '@include shared/tools.md'. Use '{{#import shared/tools.md}}' instead.
⚠ Deprecated syntax: '@include? shared/optional.md'. Use '{{#import? shared/optional.md}}' instead.
⚠ Deprecated syntax: '@import shared/config.md#Section'. Use '{{#import shared/config.md#Section}}' instead.

Implementation Details

  • Parser Updates: Enhanced regex pattern to support both old and new syntax simultaneously, with optional colon support (undocumented)
  • New Helper Function: Added ParseImportDirective() to classify and parse import directives
  • Deprecation Detection: Automatically identifies legacy syntax and emits warnings
  • Comprehensive Updates: Updated all import processing functions across the codebase
  • Documentation: Updated guides and examples to showcase the new recommended syntax (without colon)

Backward Compatibility

  • ✅ All existing workflows continue to work without modification
  • ✅ Old syntax (@include, @import) remains fully functional
  • ✅ Colon syntax ({{#import: path}}) supported internally but not documented
  • ✅ Deprecation warnings are informational and non-blocking
  • ✅ No breaking changes
  • ✅ Users can migrate at their own pace

Testing

  • Added comprehensive unit tests for new syntax parsing (with and without colon)
  • Added tests for deprecation warning behavior
  • Updated existing tests to match new error messages
  • All tests pass (unit and integration)
  • Manual testing confirms both syntaxes work correctly

Files Changed

  • pkg/parser/frontmatter.go - Core parser with dual syntax support and optional colon
  • pkg/parser/import_syntax_test.go - New comprehensive test suite
  • pkg/workflow/template.go - Validation updates
  • pkg/cli/imports.go & pkg/cli/remove_command.go - CLI processing updates
  • docs/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 syntax
  • Test files updated for new error messages

Migration Path

Users can adopt the new syntax gradually:

# Before (deprecated)
- @include shared/tools.md
- @include? shared/optional.md  
- @import shared/config.md#Section

# After (recommended)
+ {{#import shared/tools.md}}
+ {{#import? shared/optional.md}}
+ {{#import shared/config.md#Section}}

Fixes #1274

Original prompt

This section details on the original issue you should resolve

<issue_title>Syntax update</issue_title>
<issue_description>Use this syntax for imports in markdown:

{{#import: ... }}

Deprecated support for @include, @import: generate warning if found and suggest new syntax.</issue_description>

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

Fixes #1274

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

Copilot AI and others added 2 commits October 6, 2025 19:58
…import

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Collaborator

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

update to syntax to

{{#import ...}}

The : is optinal and ignores

{{#import: ...}} # ok too, ignore :

Copilot AI changed the title [WIP] Update import syntax handling for Markdown documentation Add support for new import syntax {{#import:}} and deprecate @include/@import Oct 6, 2025
Copilot AI requested a review from pelikhan October 6, 2025 20:08
@pelikhan
Copy link
Copy Markdown
Collaborator

pelikhan commented Oct 6, 2025

@copilot update to syntax to

{{#import ...}}

The : is optinal and ignores

{{#import: ...}} # ok too, ignore :

@pelikhan
Copy link
Copy Markdown
Collaborator

pelikhan commented Oct 6, 2025

@copilot format, lint, recompile

…path}}

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Oct 6, 2025

@copilot update to syntax to

{{#import ...}}...

Done! The colon is now optional in the import syntax. Both {{#import path}} and {{#import: path}} work correctly. The documentation and examples have been updated to primarily show the syntax without the colon. (commit: short hash will be added after push)

@copilot update to syntax to

{{#import ...}}...

Done! The colon is now optional in the import syntax. Both {{#import path}} and {{#import: path}} work correctly. The documentation and examples have been updated to primarily show the syntax without the colon. (d895f46)

Copilot AI changed the title Add support for new import syntax {{#import:}} and deprecate @include/@import Add support for new import syntax {{#import}} and deprecate @include/@import Oct 6, 2025
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Oct 6, 2025

@copilot format, lint, recompile

Done! ✓

  • Formatted: make fmt completed successfully
  • Linted: JavaScript formatting validated with prettier
  • Recompiled: All 59 workflow files compiled successfully with no changes

All unit tests pass. No commits needed as the code was already properly formatted and compiled.

@pelikhan pelikhan marked this pull request as ready for review October 6, 2025 20:30
{{#import relative/path/to/file.md}}
```

Or with an optional colon:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

do not document optional column @copilot

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed optional colon documentation from Basic Import Syntax section.


Imports files relative to the current markdown file's location.

:::note
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@copilot remove note

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed the note about optional colon syntax.

{{#import? relative/path/to/file.md}}
```

Or with a colon:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@copilot do not document colon syntax

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@copilot do not document colon

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed the "You can also use the colon if preferred" section from Legacy Syntax.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI requested a review from pelikhan October 6, 2025 20:36
@pelikhan pelikhan merged commit e7fe454 into main Oct 6, 2025
27 checks passed
@pelikhan pelikhan deleted the copilot/update-import-syntax-handling branch October 6, 2025 20:45
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.

Syntax update

2 participants