pub struct BashShape {
pub primary_program: Option<String>,
pub all_programs: Vec<String>,
pub list_ops: Vec<String>,
pub pipeline_stages: usize,
pub redirects: Vec<String>,
pub has_heredoc: bool,
pub cwd_hint: Option<String>,
pub side_effect: Option<SideEffect>,
pub kind: Option<ProgramKind>,
pub top_level_statements: Vec<StatementSlice>,
}Expand description
Compact summary of a bash command string, attached to args._shape on
each normalised Bash tool-call frame. All fields are optional/additive:
readers must ignore unknown keys, and missing keys mean “not computed”
(older sessions, parse failure).
Fields§
§primary_program: Option<String>First command’s program name after stripping a leading cd X && prefix
and any leading var=val assignments — what the operator was actually
trying to run.
all_programs: Vec<String>All program names found in the script, in invocation order, deduped.
list_ops: Vec<String>Top-level list operators present ("&&", "||"), deduped.
pipeline_stages: usizeMaximum pipeline stage count seen (1 = no pipe, >1 = piped).
redirects: Vec<String>File-redirect operators (>, >>, &>, …) used anywhere in the script.
has_heredoc: booltrue when a <<EOF heredoc opens — UI can collapse the body.
cwd_hint: Option<String>Working-directory hint: argument of a leading cd that was stripped
when determining primary_program. Rendered as “(in foo/bar)”.
side_effect: Option<SideEffect>Side-effect classification derived from primary_program + first argument.
None = read-only or unknown.
kind: Option<ProgramKind>Coarse program category derived from primary_program alone. Lets the
UI pick an icon / activity bucket without re-mapping a hardcoded program
list in TS. Orthogonal to side_effect — kind is what the program is,
side_effect is what this invocation does.
top_level_statements: Vec<StatementSlice>Source byte ranges of each top-level statement in program.statements,
in order. Use this — never raw.split('\n') — when a consumer needs to
segment a multi-statement bash string back into its individual commands
(e.g. the conveyor modal’s batch-approve UI). \<LF> line-continuations
are collapsed at the lexer level by tree-sitter, so a backslash-continued
multi-flag invocation yields ONE slice, not one per \<LF>.