1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
use clap::{Args, Subcommand, ValueEnum};
#[derive(Debug, Args)]
pub(crate) struct ToolArgs {
#[command(subcommand)]
pub command: ToolCommand,
}
#[derive(Debug, Subcommand)]
pub(crate) enum ToolCommand {
/// Scaffold a Harn package that exports one custom tool.
New(ToolNewArgs),
/// Run a script-published tool registry as a generated command tree.
#[command(disable_help_flag = true)]
Run(ToolRunArgs),
/// Generate shell completion for a script-published command tree.
Completions(ToolCompletionsArgs),
/// Print the canonical harn-tools catalog for a script-published registry.
Schema(ToolSchemaArgs),
}
#[derive(Debug, Args)]
pub(crate) struct ToolCompletionsArgs {
/// Harn script whose main pipeline publishes a tool registry.
pub file: String,
/// Shell whose static completion program should be emitted.
#[arg(long, value_enum)]
pub shell: ToolCompletionShell,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, ValueEnum)]
pub(crate) enum ToolCompletionShell {
Bash,
Zsh,
Fish,
PowerShell,
}
#[derive(Debug, Args)]
pub(crate) struct ToolNewArgs {
/// Tool/package name. May use dashes; generated Harn identifiers use underscores.
pub name: String,
/// One-line tool description.
#[arg(long)]
pub description: Option<String>,
/// Destination directory. Defaults to `<name>/`.
#[arg(long = "dir", value_name = "PATH")]
pub dir: Option<String>,
/// Overwrite an existing generated directory.
#[arg(long)]
pub force: bool,
}
#[derive(Debug, Args)]
pub(crate) struct ToolRunArgs {
/// Harn script whose main pipeline publishes a registry with mcp_tools(...).
pub file: String,
/// Generated command path and flags. `--help` renders registry-derived help.
#[arg(trailing_var_arg = true, allow_hyphen_values = true)]
pub arguments: Vec<String>,
}
#[derive(Debug, Args)]
pub(crate) struct ToolSchemaArgs {
/// Harn script to inspect.
pub file: String,
/// Tool owner to inspect: execute a published registry or statically read exports.
#[arg(long, value_enum, default_value_t = ToolSchemaSurface::Script)]
pub surface: ToolSchemaSurface,
/// Pretty-print the JSON catalog.
#[arg(long)]
pub pretty: bool,
}
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, ValueEnum)]
pub(crate) enum ToolSchemaSurface {
/// Execute main and inspect its script-published tool registry.
#[default]
Script,
/// Compile public exports and their types without executing the script.
Exports,
}