Skip to content

t.1fn: safe and extensible ace-lint fix system#267

Open
cs3b wants to merge 16 commits intomainfrom
1fn-safe-and-extensible-ace-lint-fix-system
Open

t.1fn: safe and extensible ace-lint fix system#267
cs3b wants to merge 16 commits intomainfrom
1fn-safe-and-extensible-ace-lint-fix-system

Conversation

@cs3b
Copy link
Owner

@cs3b cs3b commented Mar 26, 2026

📋 Summary

ace-lint --fix now applies surgical, line-level edits instead of reformatting entire files through kramdown — preserving frontmatter, code blocks, and document structure. A new --auto-fix-with-agent flag provides LLM-assisted repair for issues that deterministic rules cannot fix, and --dry-run lets you preview fixes without writing.

Previously, --fix used kramdown round-trip formatting which could silently rewrite frontmatter, collapse tables, and alter HTML attributes.

✏️ Changes

  • Add MarkdownSurgicalFixer: line-level fix molecule for em-dash, smart quotes, trailing whitespace, blank-line rules, and trailing newline — skips fenced code blocks and frontmatter (c5f800131)
  • Add guarded kramdown formatting: structural-risk checks (frontmatter, fence count, table rows, HTML attributes) before write in KramdownFormatter (c5f800131)
  • Add --auto-fix (aliases --fix, -f): deterministic surgical fix → re-lint pipeline (5dd5af7ec)
  • Add --auto-fix-with-agent: LLM-assisted repair using Ace::LLM::QueryInterface with prompt construction (5dd5af7ec)
  • Add --dry-run (-n): preview fixes without writing (5dd5af7ec)
  • Add --model: override LLM model for agent-assisted fixes (5dd5af7ec)
  • Fix auto-fix exit code: return exit 1 when violations remain after fix (9bba87e28)
  • Add lint.doctor_agent_model config key in .ace-defaults/lint/config.yml (5dd5af7ec)
  • Update LintOrchestrator: --fix runs surgical fixer, --format runs guarded kramdown, --fix --format runs both in correct order (c5f800131)

📁 File Changes

+1272,  -109   24 files   total

+1105,   -53   18 files      ace-lint/
 +679,   -38    7 files   🧱 lib/
   +1,    -0                 ace/lint.rb
 +230,    -7                 ace/lint/cli/commands/lint.rb
  +68,    -9                 ace/lint/molecules/kramdown_formatter.rb
  +67,   -18                 .../markdown_linter.rb
 +277,    -0                 .../markdown_surgical_fixer.rb
  +35,    -3                 ace/lint/organisms/lint_orchestrator.rb
   +1,    -1                 ace/lint/version.rb
 +352,    -3    6 files   🧪 test/
 +111,    -0                 commands/lint_command_test.rb
   +3,    -3                 e2e/TS-LINT-001-lint-pipeline/TC-003-fix-mode.runner.md
  +79,    -0                 molecules/kramdown_formatter_test.rb
  +22,    -0                 .../markdown_linter_test.rb
  +93,    -0                 .../markdown_surgical_fixer_test.rb
  +44,    -0                 organisms/lint_orchestrator_test.rb
  +74,   -12    5 files      
   +3,    -2                 .ace-defaults/lint/config.yml
  +36,    -0                 CHANGELOG.md
   +3,    -1                 README.md
  +15,    -4                 docs/getting-started.md
  +17,    -5                 .../usage.md

  +32,    -1    2 files      ./
  +29,    -0                 CHANGELOG.md
   +3,    -1                 docs/tools.md

🧪 Test Evidence

  • MarkdownSurgicalFixerTest (10 tests) — validates line-level surgical edits: em-dash, smart quotes, trailing whitespace, blank-line rules, frontmatter/code-block preservation, missing file error handling
  • KramdownFormatterTest (8 tests) — validates guarded formatting with structural-risk detection
  • MarkdownLinterTest (expanded) — validates fenced-code-state tracking and trailing whitespace warning detection
  • LintOrchestratorTest (expanded) — validates fix/format pipeline ordering and mode combinations
  • LintCommandTest (11 tests) — validates CLI flag parsing, auto-fix flow, agent-assisted path, dry-run, format warning
  • Suite totals: 294 tests, 874 assertions, 0 failures, 0 errors
  • Full monorepo: 7493/7494 tests pass (1 pre-existing ace-docs failure)
  • E2E: TS-LINT-001 passes 7/7 after fixture refresh

📦 Releases

  • ace-lint v0.26.0 — Add surgical markdown fixes and guarded kramdown formatting
  • ace-lint v0.27.0 — Add deterministic auto-fix (--auto-fix) and agent-assisted repair (--auto-fix-with-agent) flags

🎮 Demo

Surgical fix (deterministic)

ace-lint --auto-fix README.md

Dry-run preview

ace-lint --auto-fix --dry-run README.md

Agent-assisted fix

ace-lint --auto-fix-with-agent --model anthropic:sonnet README.md

cs3b added 16 commits March 26, 2026 01:44
Split markdown auto-fix into a line-level surgical fixer and a guarded
kramdown formatter. `--fix` now preserves frontmatter, code blocks, and
other structure, while `--format` skips rewrites that risk structural
changes.
Add a regression test for fix_file when the target markdown path does not exist, asserting the operation fails and reports a file-not-found error.
Update the task spec to reflect completed validation, with all acceptance and verification items checked off and the task status set to done.
Update the gem version constant and add the 0.26.0 changelog entry for the release.
Refresh the top-level changelog and Gemfile.lock to point at the new ace-lint release.
Document the 8qp-t-1fn-0 markdown surgical fix release retro, including
what went well, what needs improvement, and follow-up action items.
Introduce `--auto-fix`, `--auto-fix-with-agent`, `--dry-run`, and `--model`, with config-backed agent defaults and coverage for the new fix flow.
Mark implemented success criteria and validation checks for the auto-fix and agent-assisted lint task.
Update the tools reference to show deterministic auto-fix, dry-run preview, and agent escalation usage.
Treat unresolved issues after `--auto-fix` as an error and add coverage for both failing and clean auto-fix paths.
Update the task spec to reflect the implemented auto-fix-with-agent behavior, model passthrough, and verification results.
Update the package changelog and version constant for the 0.27.0 release.
Refresh the root changelog entry and Gemfile.lock to track the new ace-lint release.
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.

1 participant