feat(tokens): exclude selected paths from token accounting - #83
Open
choplin wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does
Some skill packages commit generated output for portability or because the
generated reference site is part of the package contract. Those files are not
agent instructions or references, but they currently contribute to
non-standard token warnings and the holistic structure ratio.
This PR adds
--exclude-token-pathstovalidate structureandcheck.Explicitly selected, skill-relative subtrees are excluded from non-standard
per-file token output, the Other files aggregate, and the holistic
standard-to-non-standard ratio. Non-excluded content remains counted, and the
option does not suppress structure, orphan, frontmatter, Markdown, or link
validation.
Paths are normalized across operating systems, matched on path boundaries, and
rejected when absolute or when they escape the skill root. A visible info result
is emitted whenever an exclusion is applied.
The main implementation lives in:
structure/paths.go— portable relative-path validation and subtree matchingstructure/tokens.go— filtered non-standard file traversal and accountingcmd/{validate_structure,check}.go— matching CLI flags and option propagationstructure/*_test.go,cmd/exitcode_integration_test.go, andtestdata/token-exclusion-skill/— aggregation, ratio, boundary, CLI, andoutput-format coverage
How to test
go test -race ./... -count=1 golangci-lint runThe integration tests cover both commands, Windows separators, invalid
absolute/traversal paths, similar-prefix siblings, retained non-excluded
content, and text, JSON, and Markdown output.
Checklist
go test -race ./... -count=1)golangci-lint run)