class

Hwaro::CLI::Commands::Tool::AgentsMdCommand

Inherits Reference < Object

Constants

DESCRIPTION = "Generate or update AGENTS.md file"
FENCE_CLOSE_RE = /\A {0,3}(`{3,}|~{3,})[ \t]*\z/

A CLOSING fence carries no info string (CommonMark) — accepting one (```text) would flip the in/out-of-fence parity.

FENCE_RE = /\A {0,3}(`{3,}|~{3,})/
FLAGS = [FlagInfo.new(short: nil, long: "--remote", description: "Generate lightweight version with links to online docs"), FlagInfo.new(short: nil, long: "--local", description: "Generate full embedded reference (default)"), FlagInfo.new(short: nil, long: "--write", description: "Write to AGENTS.md file instead of stdout"), FlagInfo.new(short: "-f", long: "--force", description: "Regenerate an existing file without confirmation (the Site-Specific Instructions section is still preserved)"), HELP_FLAG]
MARKER_LINE_RE = /\A {0,3}#{Regex.escape(Services::Defaults::AgentsMd::SITE_SECTION_MARKER)}(?:[ \t].*)?\z/

The heading only counts when the line STARTS with the marker (≤3 leading spaces still renders as the same ATX heading) — a first-substring index let a mid-prose mention shift the merge point. Trailing text after a separating blank is allowed so a user-annotated heading ("## Site-Specific Instructions (do not delete)") keeps being found; losing it meant --write --force discarded the user's whole section.

NAME = "agents-md"

Single source of truth for command metadata

POSITIONAL_ARGS = [] of String
POSITIONAL_CHOICES = [] of String
SITE_SECTION_MARKER = Services::Defaults::AgentsMd::SITE_SECTION_MARKER

The generated document ends with a "Site-Specific Instructions" section that explicitly invites the user to add their own rules. Regenerating used to overwrite the whole file — destroying exactly the content the template told them to write there. Carry the existing file's section (heading included) into the fresh template; a file without the marker falls back to a full rewrite (announced above), as does a template variant without one. The marker itself lives on the template service so the two can't drift apart.

Class methods

metadata
Source

Instance methods

run(args : Array(String))
Source