Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion PLAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ footer: |
| 65 | 🔲 | [Spike WASM-Embedded Weasel Inference](plan/65_spike-wasm-embedded-inference.md) |
| 66 | ✅ | [Unified Conciseness Score](plan/66_unified-conciseness-score.md) |
| 68 | ⛔ | [Reorganize Documentation](plan/68_reorganize-docs.md) |
| 69 | 🔲 | [Include enhancements: link adjustment and heading-level](plan/69_include-enhancements.md) |
| 69 | | [Include enhancements: link adjustment and heading-level](plan/69_include-enhancements.md) |
| 73 | ✅ | [Unify template and processing directives](plan/73_unify-template-directives.md) |
| 74 | ✅ | [Directive guide](plan/74_directive-guide.md) |
| 75 | ✅ | [Single-brace placeholders everywhere](plan/75_single-brace-placeholders.md) |
Expand Down
44 changes: 22 additions & 22 deletions plan/69_include-enhancements.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
id: 69
title: 'Include enhancements: link adjustment and heading-level'
status: "🔲"
status: ""
---
# Include enhancements

Expand Down Expand Up @@ -77,53 +77,53 @@ has `## Build` (level 2) and `### Sub` (level 3).

## Tasks

1. Add a helper `adjustLinks(content,
1. [x] Add a helper `adjustLinks(content,
includedFilePath, includingFilePath)` in
[`internal/rules/include/`](../internal/rules/include/)
that rewrites relative link/image targets
2. Write unit tests for `adjustLinks`: same directory
2. [x] Write unit tests for `adjustLinks`: same directory
(no-op), different directories, anchors and
absolute URLs left untouched, query strings
preserved
3. Call `adjustLinks` in `generateIncludeContent`
3. [x] Call `adjustLinks` in `generateIncludeContent`
after frontmatter stripping, before wrap
4. Add a helper `adjustHeadings(content, parentLevel)`
4. [x] Add a helper `adjustHeadings(content, parentLevel)`
that shifts ATX and setext heading levels
5. Write unit tests for `adjustHeadings`: shift up,
5. [x] Write unit tests for `adjustHeadings`: shift up,
shift down, cap at 6, no headings (no-op)
Comment on lines +90 to 93

Copilot AI Apr 20, 2026

Copy link

Choose a reason for hiding this comment

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

Task 5 is checked off as covering both “shift up” and “shift down”, but the current adjustHeadings unit tests only cover positive shifts (making headings deeper) and the no-op case; there is no test where the included content starts too deep and needs a negative shift to bring the minimum heading level up to parentLevel+1. Either add that test (and implement the behavior if needed) or adjust the task wording so it matches what’s actually validated.

Copilot generated this review using guidance from repository custom instructions.
6. Extend `validateIncludeDirective` to accept and
6. [x] Extend `validateIncludeDirective` to accept and
validate the `heading-level` parameter (only
`"absolute"` is valid)
7. In `generateIncludeContent`, detect the parent
7. [x] In `generateIncludeContent`, detect the parent
heading level from the marker position and call
`adjustHeadings` when `heading-level: "absolute"`
8. Add test for parent-level detection (marker under
8. [x] Add test for parent-level detection (marker under
h2, under h3, at document root)
9. Update the rule README at
9. [x] Update the rule README at
[`MDS021-include/README.md`](../internal/rules/MDS021-include/README.md)
to document both features
10. Update existing fixtures and tests if link
10. [x] Update existing fixtures and tests if link
adjustment changes their expected output
11. Run `go test ./...`, `go tool golangci-lint run`,
11. [x] Run `go test ./...`, `go tool golangci-lint run`,
and `mdsmith check .`

## Acceptance Criteria

- [ ] Relative links in included content are rewritten
- [x] Relative links in included content are rewritten
so they resolve from the including file's
directory, not the source file's directory
- [ ] Absolute URLs, anchor-only links (`#foo`), and
- [x] Absolute URLs, anchor-only links (`#foo`), and
protocol links (`http://`, `https://`) are not
modified
- [ ] `heading-level: "absolute"` shifts headings so
- [x] `heading-level: "absolute"` shifts headings so
the included top-level headings appear one level
below the enclosing section
- [ ] When `heading-level` is omitted, heading levels
- [x] When `heading-level` is omitted, heading levels
stay unchanged
Comment on lines +118 to 122

Copilot AI Apr 20, 2026

Copy link

Choose a reason for hiding this comment

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

The plan/PR claims heading-level: "absolute" makes included top-level headings appear exactly one level below the enclosing section, but the current implementation of adjustHeadings returns unchanged when the computed shift is <= 0. That means included content whose minimum heading level is already deeper than parentLevel+1 will not be normalized back up to parentLevel+1, leaving headings more deeply nested than specified. Consider allowing negative shifts (only skipping when shift == 0) and adding a unit test covering this case so the acceptance criterion is actually met.

Copilot uses AI. Check for mistakes.
- [ ] Heading level never exceeds 6
- [ ] Invalid `heading-level` values produce a diagnostic
- [ ] Link adjustment is always applied (no parameter
- [x] Heading level never exceeds 6
- [x] Invalid `heading-level` values produce a diagnostic
- [x] Link adjustment is always applied (no parameter
needed)
- [ ] All tests pass: `go test ./...`
- [ ] `golangci-lint run` reports no issues
- [ ] `mdsmith check .` reports zero diagnostics
- [x] All tests pass: `go test ./...`
- [x] `golangci-lint run` reports no issues
- [x] `mdsmith check .` reports zero diagnostics
Loading