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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
pub mod add;
pub mod init;
pub mod own;
pub mod status;
pub mod sync;
pub mod wander;
use clap::{Parser, Subcommand};
#[derive(Parser)]
#[command(
name = "rtango",
version,
about = "Package manager for agent skills and configuration files"
)]
pub struct Cli {
#[command(subcommand)]
pub command: Command,
}
#[derive(Subcommand)]
pub enum Command {
/// Scan project and create .rtango/spec.yaml + .rtango/lock.yaml
Init {
/// Overwrite existing spec
#[arg(short, long)]
force: bool,
/// Skip auto-detection, create an empty spec skeleton
#[arg(short, long)]
no_detect: bool,
},
/// Bring target files in sync with the spec
Sync {
/// Dry-run: exit 1 if out of sync (for CI)
#[arg(short, long)]
check: bool,
/// Ignore on_target_modified: fail
#[arg(short, long)]
force: bool,
/// Only process a single rule
#[arg(short, long, value_name = "ID")]
rule: Option<String>,
/// Adopt existing target files on first sync
#[arg(short, long)]
adopt: bool,
},
/// Show sync plan without writing anything
Status {
/// Only show a single rule
#[arg(short, long, value_name = "ID")]
rule: Option<String>,
/// Show up-to-date items too
#[arg(short, long)]
verbose: bool,
},
/// Run init + sync in-memory: render target files without creating `.rtango/`
Wander {
/// Additional target agent to render for (repeatable)
#[arg(short = 't', long = "target", value_name = "AGENT")]
targets: Vec<String>,
},
/// Record or clear a manual ownership decision for a contested path
Own {
/// Target path (absolute, or relative to the project root)
path: std::path::PathBuf,
/// Rule id that should own the path (omit with --clear)
rule_id: Option<String>,
/// Remove any recorded ownership for this path
#[arg(short, long)]
clear: bool,
},
/// Append a rule to the spec (mechanical — no validation beyond id/source/kind)
Add {
/// Rule id (must be unique within the spec)
id: String,
/// Local source path (directory or file, relative to root).
/// Combine with --collection-kind/--col to treat a local directory as a collection.
#[arg(
short = 'l',
long = "local",
value_name = "PATH",
conflicts_with = "repo"
)]
local: Option<std::path::PathBuf>,
/// GitHub source: owner/repo[@ref][:path].
/// Combine with --collection-kind/--col to treat a GitHub repo as a collection.
#[arg(
short = 'r',
long = "repo",
value_name = "SPEC",
conflicts_with = "local"
)]
repo: Option<String>,
/// Kind is a single skill
#[arg(
long = "skill",
conflicts_with_all = ["agent", "skill_set", "agent_set", "system", "collection_kind"]
)]
skill: bool,
/// Kind is a single agent
#[arg(
long = "agent",
conflicts_with_all = ["skill", "skill_set", "agent_set", "system", "collection_kind"]
)]
agent: bool,
/// Kind is skill-set
#[arg(
long = "skill-set",
visible_alias = "ss",
conflicts_with_all = ["skill", "agent", "agent_set", "system", "collection_kind"]
)]
skill_set: bool,
/// Kind is agent-set
#[arg(
long = "agent-set",
visible_alias = "as",
conflicts_with_all = ["skill", "agent", "skill_set", "system", "collection_kind"]
)]
agent_set: bool,
/// Kind is a system instruction file (CLAUDE.md / AGENTS.md / etc.)
#[arg(
long = "system",
conflicts_with_all = [
"skill", "agent", "skill_set", "agent_set", "collection_kind",
"name", "description", "allowed_tools", "include", "exclude",
]
)]
system: bool,
/// Kind is a remote rtango collection (imports rules from a remote spec.yaml)
#[arg(
long = "collection-kind",
visible_alias = "col",
conflicts_with_all = [
"skill", "agent", "skill_set", "agent_set", "system",
"name", "description", "allowed_tools",
]
)]
collection_kind: bool,
/// Schema agent for the rule (required when spec has >1 agent)
/// For collections, overrides the schema_agent for all imported rules.
#[arg(short = 'g', long = "schema", value_name = "AGENT")]
schema: Option<String>,
/// Override frontmatter name (single kinds only)
#[arg(
long = "name",
value_name = "NAME",
conflicts_with_all = ["skill_set", "agent_set", "collection_kind"]
)]
name: Option<String>,
/// Override frontmatter description (single kinds only)
#[arg(
long = "description",
value_name = "TEXT",
conflicts_with_all = ["skill_set", "agent_set", "collection_kind"]
)]
description: Option<String>,
/// Override frontmatter allowed-tools (single kinds only, space-separated)
#[arg(
long = "allowed-tools",
value_name = "TOOLS",
conflicts_with_all = ["skill_set", "agent_set", "collection_kind"]
)]
allowed_tools: Option<String>,
/// Only include entries matching NAME (set and collection kinds, repeatable)
#[arg(
long = "include",
value_name = "NAME",
conflicts_with_all = ["skill", "agent", "exclude"]
)]
include: Vec<String>,
/// Exclude entries matching NAME (set and collection kinds, repeatable)
#[arg(
long = "exclude",
value_name = "NAME",
conflicts_with_all = ["skill", "agent", "include"]
)]
exclude: Vec<String>,
},
}
pub fn run(cli: Cli) -> anyhow::Result<()> {
let root = std::env::current_dir()?;
match cli.command {
Command::Init { force, no_detect } => init::exec(&root, force, no_detect),
Command::Sync {
check,
force,
rule,
adopt,
} => sync::exec(&root, check, force, rule, adopt),
Command::Status { rule, verbose } => status::exec(&root, rule, verbose),
Command::Wander { targets } => wander::exec(&root, targets),
Command::Own {
path,
rule_id,
clear,
} => own::exec(&root, path, rule_id, clear),
Command::Add {
id,
local,
repo,
skill,
agent,
skill_set,
agent_set,
system,
collection_kind,
schema,
name,
description,
allowed_tools,
include,
exclude,
} => add::exec(
&root,
add::AddOptions {
id,
local,
repo,
skill,
agent,
skill_set,
agent_set,
system,
collection_kind,
schema,
name,
description,
allowed_tools,
include,
exclude,
},
),
}
}