pub struct Task {
pub name: String,
pub description: String,
pub lang: String,
pub script: String,
pub dir: Option<String>,
pub env: Vec<(String, String)>,
pub args: Vec<Arg>,
pub requires: Vec<String>,
pub agent_allow: bool,
}Expand description
One task: a named script with its interpreter and metadata.
Fields§
§name: StringThe heading text (the command name).
description: StringProse in the task body that is not a recognized Key: value line.
lang: StringThe fenced block’s info-string language (sh, zsh, python, …); empty
means an unlabeled fence (treated as sh).
script: StringThe script (the fenced block’s contents), verbatim.
dir: Option<String>Dir: overrides the working directory. When absent, a task runs in
the invocation directory, not where the task file lives, so an inherited
or global task acts on your current project. A relative value resolves
against the task file’s own directory (Dir: . pins the task there); an
absolute value is used verbatim. It may contain {{ arg }}, and resolution
is purely lexical, with no filesystem access. See TaskFile::invocation.
env: Vec<(String, String)>Env: adds extra environment for this task.
args: Vec<Arg>Args: declares positional arguments in just’s syntax. A bare name is
required, name='default' is optional, and a trailing *name is variadic
(it collects the rest, space-joined). Each one is substituted as
{{ name }} in the script and also exported as $name. Note that
{{ name }} is raw text substitution, applied before the shell parses
the script, so "{{ name }}" is NOT injection-safe for untrusted values.
Prefer "$name", which the shell quotes, and reserve {{ }} for Dir:
and developer-authored templates.
requires: Vec<String>Requires: names the tasks this one depends on. mdtask-core does not run
them (execution stays the caller’s), but dependency_order resolves the
transitive run order (deps first, cycle and typo detected) so a caller can
run each in turn. The mdtask CLI does exactly that.
agent_allow: boolAgent: allow opts a task in to being listed and run by an MCP or agent
surface. It is advisory data: nothing in mdtask-core’s execution path
checks it. A caller exposing tasks to an agent must filter with
TaskFile::agent_tasks (off by default), which is the enforcement point.
The flag alone enforces nothing.
Implementations§
Source§impl Task
impl Task
Sourcepub fn script_arg_templates(&self) -> Vec<&str>
pub fn script_arg_templates(&self) -> Vec<&str>
The declared argument names this task interpolates into its script via
{{ arg }} (raw text substitution, applied before the shell parses the
script). Because {{ }} is not shell-quoted, each of these is a shell
injection point for an untrusted argument value. A surface that runs a task
with caller-controlled argument values (an agent/MCP surface) should refuse
a task that has any, and the author should switch to "$arg", which the
shell quotes. Empty for a task that only uses $arg (the safe form) or uses
{{ }} solely in Dir: (which is not the script). See TaskFile::invocation.