import type { CLI } from '../../../commands/cli/types.ts';
import { type CommandSpec } from '../../../commands/spec/types.ts';
import { CommandWord } from '../../../policy/types.ts';
import { type ByteSource } from '../../../io/types.ts';
import { PathSpec } from '../../../types.ts';
import { type MountRegistry } from '../../mount/registry.ts';
import type { SessionAccess } from '../../../view/types.ts';
export declare const CWD_DEFAULT_RAW: Record<string, string>;
export declare const DISPATCH_FLAG_KEYS: Readonly<Record<string, readonly string[]>>;
export declare function defaultCwdOperand(parts: readonly (string | PathSpec)[], cmdName: string, registry: MountRegistry, cwd: string, stdin: ByteSource | null): PathSpec | null;
/**
 * The path-valued options a command tree's walk resolves. `pathFlagScopes`
 * reads the built-in specs, which hold no tree, and a tree's words are
 * classified as its walk reads them, its group options as text. So a tree's
 * group options and its leaf's are read here, walked as the run walks them:
 * `notes --file /data/secret show` hands the leaf `/data/secret`, and a rule
 * protecting it has to see it. Mirrors Python's `tree_path_scopes`.
 */
export declare function treePathScopes(registry: MountRegistry, name: string, argv: readonly string[], cwd: string, env?: Record<string, string>, access?: SessionAccess): PathSpec[];
export declare function pathFlagScopes(cmdName: string, argv: string[], cwd: string): PathSpec[];
/**
 * The path operands a line names positionally, flag values left out.
 *
 * Classification turns every path-shaped word into a PathSpec, including the
 * value of a path-valued flag, so the classified word list cannot tell
 * `tar -xf a.tar -C /mnt` (extract INTO a mount) from `tar -cf a.tar /mnt`
 * (archive a whole mount). Only the spec knows which slot a word filled, so
 * this asks it and keeps the classified spec for each surviving operand,
 * whose `rawPath` is what a message should name.
 */
export declare function positionalScopes(cmdName: string, argv: string[], cwd: string, words: readonly (string | PathSpec)[]): PathSpec[];
/** The handler will answer help, version or a refusal before reading any input files. */
export declare function optionLoopExits(cmdName: string, spec: CommandSpec | null, argv: string[], cwd: string): boolean;
/**
 * The classified path words that route a line. Classification makes a dispatched
 * option's file a path word like any other, so a command in DISPATCH_FLAG_KEYS
 * routes by its positional operands alone; every other command by all its
 * path words.
 */
export declare function routedOperands(cmdName: string, argv: string[], cwd: string, words: readonly (string | PathSpec)[], pathScopes: PathSpec[]): PathSpec[];
/**
 * Drop the operands that name no path from a line's routing words. An awk
 * `var=value` operand is an assignment awk makes when its input reaches
 * it, so it routes nowhere: `awk p /data/a x=1 /data/b` runs on /data like
 * the same line without it. A lone `-` is standard input to the commands in
 * STDIN_DASH_COMMANDS, so it routes nowhere either, past STDIN_DASH_LEADING's
 * leading operands only where it names an output (split's PREFIX).
 */
export declare function routableScopes(cmdName: string, scopes: PathSpec[]): PathSpec[];
/** Combine positional and path-flag scopes, keeping operand order. */
export declare function mergeScopes(positional: PathSpec[], flagScopes: PathSpec[]): PathSpec[];
/**
 * The command tree a head word walks: an installed CLI's, else one the
 * mount serving the name registered (`MountEntry.cliFor`). A tree on a mount
 * runs on the mount that serves its name, the working directory's when it
 * has one, else the first that does, never by operand path: its walk, not a
 * spec, says which words are paths. Mirrors Python's `command_tree`.
 */
export declare function commandTree(registry: MountRegistry, name: string, cwd: string, argv?: readonly string[], access?: SessionAccess): CLI | null;
/**
 * The line as an admission pattern reads it, and the program it runs.
 *
 * For a command tree's head (an installed CLI, or a tree a mount serves)
 * the spec walk names the verb path (global options before the verb
 * dropped, an alias canonicalized) and hands back the leaf's own words, so
 * `git -C /r push origin` reads as `git push origin` and a rule on
 * `git push` catches it; a walk the tree refuses (unknown verb, bare group,
 * usage error) reads the raw words, since the line fails on its own.
 * Anything else is the name and the raw argv, and the program is the bare
 * name. `env` is the session environment, which fills a group option
 * declaring `Argument.env` as the run's walk does.
 */
export declare function programTokens(registry: MountRegistry, name: string, argv: readonly string[], cwd: string, env?: Record<string, string>, access?: SessionAccess): [readonly string[], readonly string[]];
/**
 * The classified path words a builtin's grammar reads as path operands. Read
 * by position, so neither an option's value nor a text operand (grep's
 * pattern) counts even where its spelling repeats a path operand's, and a
 * word the classifier left as text never counts.
 */
export declare function operandPaths(cmdName: string, words: readonly (string | PathSpec)[], cwd: string): PathSpec[];
/**
 * The command line word by word, each with its kind and the path it names.
 * The name comes first and the redirect targets last. A command tree's verbs
 * (an installed CLI's, or a mount's) are read off the tree and its leaf's
 * words off the leaf's grammar; any other command's words off its own spec.
 * `env` is the session environment, which fills a group option declaring
 * `Argument.env` as the run's walk does. Mirrors Python's `command_words`.
 */
export declare function commandWords(registry: MountRegistry, name: string, argv: readonly string[], classified: readonly (string | PathSpec)[], redirects: readonly PathSpec[], cwd: string, env?: Record<string, string>, access?: SessionAccess): CommandWord[];
//# sourceMappingURL=routing.d.ts.map