filterlist

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package filterlist implements the --files-from JSON include/exclude allowlist for ckv build. Supplied at the CLI as a path to a JSON file:

{
  "include": ["consensus/wbft/**", "core/txpool/*.go"],
  "exclude": ["**/testdata/**", "**/*_test.go"]
}

Patterns use doublestar semantics: `**` matches any number of path segments (including zero). Both fields are optional — an empty include list means "every discovered file is eligible" and the exclude list still trims unwanted matches.

The JSON schema is intentionally identical to the one in the sibling code-knowledge-graph repo (internal/filterlist/filterlist.go) so a single file-list JSON works for both ckg and ckv.

Rationale: ckv already has a denylist (--exclude / .ckvignore). This package provides the orthogonal allowlist: "I want ONLY these files." Unlike GoBuildFiles (which is Go-only and driven by go/packages), this filter applies to ALL languages (Go, TypeScript, Solidity, JavaScript, Markdown) before any per-language handling.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FilterList

type FilterList struct {
	Include []string `json:"include"`
	Exclude []string `json:"exclude"`
}

FilterList holds the parsed include/exclude rules.

func Load

func Load(path string) (*FilterList, error)

Load reads and parses the JSON file at path. Returns a nil filter (and nil error) when path is empty — callers can treat nil as "no allowlist".

func (*FilterList) Allow

func (f *FilterList) Allow(relPath string) bool

Allow reports whether relPath (slash-separated, relative to srcRoot) passes the filter. Decision rule:

  1. exclude match → reject (exclude trumps include)
  2. include empty → accept (nil filter is also accepted)
  3. include match → accept
  4. otherwise → reject

func (*FilterList) FilterPaths

func (f *FilterList) FilterPaths(paths []string) []string

FilterPaths returns the subset of paths that f.Allow accepts. A nil filter returns paths unchanged (zero allocation).

Jump to

Keyboard shortcuts

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