mdcheck

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 29, 2026 License: Apache-2.0 Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package mdcheck holds the Markdown checks that tools/readmegen (the README) and tools/launchrender (the launch files under docs/launch/) share: line and fence splitting, the hook-claims check against docs/hooks/policy.md wording, and the AD-3 leak check. Messages name a file, a line and a detector, never key text.

Index

Constants

View Source
const GitHooksFile = "docs/hooks/git.md"

GitHooksFile documents what the git hooks fail on: fail_on, by default a live key.

View Source
const PolicyFile = "docs/hooks/policy.md"

PolicyFile is the hook policy every prevention claim must stay within.

View Source
const PolicyKeys = "live and high-confidence keys"

PolicyKeys is the policy's wording of what the hook blocks. A sentence that says something blocks or prevents keys must say it, unless it is negated.

Variables

View Source
var HeadingRE = regexp.MustCompile(`^(#{1,6})\s+(.*?)\s*#*\s*$`)

HeadingRE matches an ATX heading line.

View Source
var LaunchClaimVerbRE = regexp.MustCompile(`(?i)\b(block|blocks|blocked|blocking|prevent|prevents|prevented|preventing|stop|stops|deny|denies|protect|protects)\b`)

LaunchClaimVerbRE is the wider verb set of launch copy (tools/launchrender): the README's block and prevent plus stop, deny and protect. The README keeps the narrower set, since its pitch says the tool helps "stop them going public".

Functions

func HookClaims

func HookClaims(file, page string, skip func(line int) bool) []string

HookClaims checks every clause of page (paragraphs, list items, table cells and fenced lines, split into sentences, then at semicolons and at ", and" before another mechanism) that says something blocks or prevents keys, unless it is negated. Code spans are left out before matching. Such a clause must say PolicyKeys and name the Claude Code hook: the subject itself, or for a pronoun or "the hook" the last mechanism named before it in the same paragraph or table row (a table cell without one takes the row's). Generic "hooks", git hooks, commits, pushes, pull requests, husky, lefthook, the GitHub Action and CI fail it: they fail on fail_on, live keys by default. skip reports 1-based lines to leave out (for example a section that restates the policy and is checked against it); nil skips nothing. Messages are "file:line: ...".

func HookClaimsWith

func HookClaimsWith(verbs *regexp.Regexp, file, page string, skip func(line int) bool) []string

HookClaimsWith is HookClaims with another set of claim verbs.

func Leaks

func Leaks(files map[string][]byte) []string

Leaks is the AD-3 leak check: it scans each file with the embedded registry, verification off, test keys and inline allow markers included, and reports every key-shaped match by file, line and detector, never by its text. Only redacted forms such as "sk-pro...a1b2 (51)" may appear, and the registry patterns never match those. Messages are sorted.

func Lines

func Lines(page string) ([]string, []bool)

Lines returns the lines of a Markdown page with a flag per line: true when the line is inside a fenced code block (the fence lines themselves are false).

func Sentences

func Sentences(text string) []string

Sentences splits text at a period followed by a space or the end, outside code spans.

Types

type Unit

type Unit struct {
	Line int
	Text string
}

Unit is a paragraph, list item, table row or fenced line with its first line (1-based).

func Units

func Units(page string) []Unit

Units splits a page into paragraphs, list items (bulleted or numbered), table rows and fenced lines. Headings and blank lines end a unit.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL