Skip to main content

Scanner

Struct Scanner 

Source
pub struct Scanner<F: FileSystemProvider = StdFileSystemProvider, P: MarkdownParser = PulldownMarkdownParser> { /* private fields */ }
Expand description

Scanner for analyzing skills and related agent-extension packages.

Implementations§

Source§

impl Scanner<StdFileSystemProvider, PulldownMarkdownParser>

Source

pub fn new() -> Result<Self, ScanError>

Source

pub fn with_std_adapters(options: ScanOptions) -> Result<Self, ScanError>

Source§

impl<F: FileSystemProvider, P: MarkdownParser> Scanner<F, P>

Source

pub fn with_custom_adapters( options: ScanOptions, fs_provider: F, parser: P, ) -> Result<Self, ScanError>

Source

pub fn scan_file(&self, path: impl AsRef<Path>) -> Result<ScanResult, ScanError>

Scan a single document file and return its ScanResult.

Accepts any path that resolves to a readable file through the scanner’s FileSystemProvider. The file does not need to be a canonical skill entrypoint — use scan_skill_file when callers want that stricter precondition. Use scan_package or scan to scan a whole package and aggregate results.

§Errors
  • ScanError::PathNotFound if path does not exist through fs.
  • Errors propagated from the analyzer / rule engine pipeline (parse failures, rule evaluation errors, …) surface as ScanError variants.
Source

pub fn scan_skill_file( &self, path: impl AsRef<Path>, ) -> Result<ScanResult, ScanError>

Scan a path that MUST be a canonical skill entrypoint (SKILL.md, agent.md, manifest, etc.). Use this when the caller already enforces “this is the skill” semantics — scan / scan_package discover entrypoints automatically and should be preferred for general use.

§Errors
Source

pub fn scan_package( &self, path: impl AsRef<Path>, ) -> Result<PackageScanResult, ScanError>

Scan an entire package directory (or a single file treated as a degenerate one-target package). Discovers every target via discover_package_targets and aggregates per-target results into a PackageScanResult. Per-target failures are recorded in pkg_result.errors instead of aborting the whole scan, so a partially malformed package still produces verdicts for the readable subset.

§Errors
  • ScanError::PathNotFound if path does not exist.
  • Errors from package discovery (only the initial discovery step bubbles up; per-file errors are captured into PackageScanResult::errors).
Source

pub fn scan( &self, path: impl AsRef<Path>, ) -> Result<PackageScanResult, ScanError>

Top-level entry point. Honours the configured ScanTargetMode:

  • Auto (default) — file paths route to scan_file, directory paths to scan_package.
  • File — always treated as a single document; directories produce PathNotFound-equivalent errors via the analyzer.
  • Package — always treated as a package, even when the path is a single file. Useful when callers want package-level aggregation over a synthetic one-file package.
§Errors
  • ScanError::PathNotFound if path is missing in Auto mode.
  • Errors from the underlying scan_file / scan_package paths.
Source

pub fn rule_count(&self) -> usize

Number of compiled rules currently loaded into the underlying RuleEngine. Combines built-in rules with any external packs loaded via --rules-dir. Useful for diagnostics and CLI rules count summaries.

Source

pub fn rules(&self) -> Vec<&Rule>

Borrow every loaded rule as a slice of references. Order matches the RuleEngine’s internal Vec<CompiledRule>: built-ins first, then external packs in load order. Intended for read-only inspection (CLI rules list, snapshot tests); the engine retains ownership.

Auto Trait Implementations§

§

impl<F, P> Freeze for Scanner<F, P>
where P: Freeze, F: Freeze,

§

impl<F = StdFileSystemProvider, P = PulldownMarkdownParser> !RefUnwindSafe for Scanner<F, P>

§

impl<F, P> Send for Scanner<F, P>

§

impl<F, P> Sync for Scanner<F, P>

§

impl<F, P> Unpin for Scanner<F, P>
where P: Unpin, F: Unpin,

§

impl<F, P> UnsafeUnpin for Scanner<F, P>
where P: UnsafeUnpin, F: UnsafeUnpin,

§

impl<F = StdFileSystemProvider, P = PulldownMarkdownParser> !UnwindSafe for Scanner<F, P>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more