Agent-First Slug v0.10: The Rule as a Value

by Agent-First Kit Contributors

Fallback and delimiter errors now carry the broken rule as a typed value, naming the first offending character. Published slugs are pinned by a stability table, each validation policy states what it checks and what it leaves to the platform, and afslug installs its skill into the standard skill folders or one directory you name.

v0.9 made every afslug error name its rule with its own error.code. In the Rust API, though, the rule a fallback or delimiter broke was still a sentence: a &'static str field you could print but not match on. v0.10 makes it a value.

A broken fallback says which rule and which character

SlugError::FallbackViolatesConfig now carries a GeneratedSlugRule, one variant per rule a generated slug follows:

  • LengthLimit
  • DelimiterAtEdge
  • RepeatedDelimiter
  • FilteredCharacter { character }
  • NotLowercase { character }

The two character rules name the first character that broke them, so the error points at the problem instead of describing it:

$ afslug slugify "x" --fallback "Bad"
{"error":{"code":"fallback_violates_config","hint":"pass a --fallback this configuration could itself have produced, or --fallback-verbatim to insert the value as written","message":"fallback slug does not satisfy this configuration: lowercasing is enabled and `B` (U+0042) is not lowercase","retryable":false},"kind":"error","trace":{}}

A character that would be invisible or would break the line is named by code point alone, as whitespace and combining marks already were:

$ afslug slugify "x" --fallback "a b"
{"error":{"code":"fallback_violates_config","hint":"pass a --fallback this configuration could itself have produced, or --fallback-verbatim to insert the value as written","message":"fallback slug does not satisfy this configuration: it contains U+0020, which this configuration would have filtered out","retryable":false},"kind":"error","trace":{}}

SlugError::AmbiguousReplacementDelimiter likewise carries a DelimiterConflict (KeptByCharacterSet, PreservedByDotPolicy, ChangedByLowercasing) in place of its reason string.

The messages are shared by every surface, so they no longer name Rust fields. “it is longer than max_slug_chars” is now “it is longer than the maximum slug length”, which reads the same whether the limit came from a SlugConfig or from --max-chars.

Published slugs are pinned

A slug is a stored identifier. Once it is written to disk or into a URL, the next release has to produce the same one. A new stability table records the output of the released crate for inputs where the rules make a difference: case expansion, combining marks, dots between digits, truncation boundaries, empty output and fallbacks. Each row is written as afslug slugify flags, so one table checks both the library and the CLI.

If a row stops matching, the output changed. That has to be recorded and announced in a release, not fixed by quietly updating the test.

What validation checks, and what it leaves out

SlugValidationPolicy now documents exactly what it covers. LocalPathSegment rejects an empty value, . and .., /, \, Unicode whitespace and control characters. UrlPathSegment adds ?, # and a raw %.

These are surface checks. They do not check anything platform-specific: a value that passes can still be refused or changed by a particular filesystem, for example : or a trailing . on Windows, a reserved device name such as con, or a byte length over the filesystem’s limit. A URL segment is still raw UTF-8, so percent-encode it with a URL library before building the URL. validate_slug checks only the surface, not whether a given configuration could have produced the value.

Installing the skill

afslug skill install no longer takes --agent. With no options it installs into the standard skill folders for the chosen --scope (personal by default):

$ afslug skill install
$ afslug skill install --scope workspace

To install somewhere else, name one directory. --skills-dir now stands alone instead of requiring a named agent, and it cannot be combined with --scope:

$ afslug skill install --skills-dir ./my-skills

skill status and skill uninstall take the same two forms.

Breaking changes

  • SlugError::FallbackViolatesConfig { reason } is now { rule } of type GeneratedSlugRule, and AmbiguousReplacementDelimiter { reason } is now { conflict } of type DelimiterConflict. Code that read or matched the string needs to match the enum instead.
  • Two message texts changed: the length rule no longer says max_slug_chars, and the filtered-character and lowercase rules now name the character. Match on error.code or the enum, not on message text.
  • afslug skill install|status|uninstall --agent is gone. Use no option for the standard folders, or --skills-dir PATH for one directory.

Slug output is unchanged from v0.9, and the stability table now enforces that.

Also in this release: Agent-First Data moves to 0.41.0, and afslug --help shows each option’s default.

Getting it

$ brew install agentfirstkit/tap/afslug
$ cargo install agent-first-slug