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
use std::path::PathBuf;
use clap::{ArgAction, Args, Subcommand};
#[derive(Debug, Args)]
pub(crate) struct InstallArgs {
/// Fail if harn.lock would need to change.
#[arg(long, default_value_t = false, action = ArgAction::SetTrue)]
pub frozen: bool,
/// Alias for --frozen, intended for CI and production installs.
#[arg(long, default_value_t = false, action = ArgAction::SetTrue)]
pub locked: bool,
/// Do not fetch from package sources; use only harn.lock and the local cache.
#[arg(long, default_value_t = false, action = ArgAction::SetTrue, conflicts_with = "refetch")]
pub offline: bool,
/// Force refetching one dependency (or every dependency with `--refetch all`).
#[arg(long, value_name = "ALIAS|all")]
pub refetch: Option<String>,
/// Emit a JSON install summary instead of a human-readable line.
#[arg(long, default_value_t = false, action = ArgAction::SetTrue)]
pub json: bool,
}
#[derive(Debug, Args)]
pub(crate) struct AddArgs {
/// Git URL/ref spec, local package path, or dependency name in the legacy `--git/--path` form.
pub name_or_spec: String,
/// Override the dependency alias written under `[dependencies]`.
#[arg(long)]
pub alias: Option<String>,
/// Git URL for a remote dependency.
#[arg(long, conflicts_with = "path")]
pub git: Option<String>,
/// Deprecated alias for `--rev` on the legacy `--git` form.
#[arg(long, conflicts_with_all = ["rev", "branch"])]
pub tag: Option<String>,
/// Git rev to pin for a remote dependency.
#[arg(long, conflicts_with = "branch")]
pub rev: Option<String>,
/// Git branch to track in the manifest; the lockfile still pins a commit.
#[arg(long, conflicts_with_all = ["rev", "tag"])]
pub branch: Option<String>,
/// Local path for a path dependency.
#[arg(long, conflicts_with = "git")]
pub path: Option<String>,
/// Package registry index URL or path for registry-name dependencies.
#[arg(long, value_name = "URL|PATH")]
pub registry: Option<String>,
}
#[derive(Debug, Args)]
pub(crate) struct UpdateArgs {
/// Refresh every dependency instead of one alias.
#[arg(long, default_value_t = false, action = ArgAction::SetTrue)]
pub all: bool,
/// Refresh only this dependency alias.
pub alias: Option<String>,
/// Emit a JSON update summary instead of a human-readable line.
#[arg(long, default_value_t = false, action = ArgAction::SetTrue)]
pub json: bool,
}
#[derive(Debug, Args)]
pub(crate) struct RemoveArgs {
/// Dependency alias to remove from harn.toml and harn.lock.
pub alias: String,
}
#[derive(Debug, Args)]
pub(crate) struct PackageArgs {
#[command(subcommand)]
pub command: PackageCommand,
}
#[derive(Debug, Subcommand)]
pub(crate) enum PackageCommand {
/// Search the package registry index.
Search(PackageSearchArgs),
/// Show package registry metadata for one package.
Info(PackageInfoArgs),
/// Validate a package manifest and publish readiness.
Check(PackageCheckArgs),
/// Build an inspectable package artifact directory.
Pack(PackagePackArgs),
/// Generate package API docs from exported Harn symbols.
Docs(PackageDocsArgs),
/// Inspect, clean, and verify the shared package cache.
Cache(PackageCacheArgs),
/// Report dependencies whose lockfile entries have newer registry or branch HEAD versions.
Outdated(PackageOutdatedArgs),
/// Audit harn.lock provenance, package compatibility, and supply-chain integrity.
Audit(PackageAuditArgs),
/// Inspect or verify the published Harn protocol-artifact contract.
Artifacts(PackageArtifactsArgs),
}
#[derive(Debug, Args)]
pub(crate) struct PackageCheckArgs {
/// Package directory, harn.toml, or file under the package. Defaults to cwd.
pub package: Option<PathBuf>,
/// Emit JSON instead of a human-readable report.
#[arg(long)]
pub json: bool,
}
#[derive(Debug, Args)]
pub(crate) struct PackagePackArgs {
/// Package directory, harn.toml, or file under the package. Defaults to cwd.
pub package: Option<PathBuf>,
/// Output artifact directory. Defaults to .harn/dist/<name>-<version>.
#[arg(long, value_name = "DIR")]
pub output: Option<PathBuf>,
/// Validate and print the file list without writing the artifact.
#[arg(long)]
pub dry_run: bool,
/// Emit JSON instead of a human-readable report.
#[arg(long)]
pub json: bool,
}
#[derive(Debug, Args)]
pub(crate) struct PackageDocsArgs {
/// Package directory, harn.toml, or file under the package. Defaults to cwd.
pub package: Option<PathBuf>,
/// Output Markdown file. Defaults to docs/api.md.
#[arg(long, value_name = "PATH")]
pub output: Option<PathBuf>,
/// Verify the output file already matches generated docs.
#[arg(long)]
pub check: bool,
}
#[derive(Debug, Args)]
pub(crate) struct PackageSearchArgs {
/// Search query. Omit to list all registry packages.
pub query: Option<String>,
/// Package registry index URL or path.
#[arg(long, value_name = "URL|PATH")]
pub registry: Option<String>,
/// Emit JSON instead of a tab-separated table.
#[arg(long)]
pub json: bool,
}
#[derive(Debug, Args)]
pub(crate) struct PackageInfoArgs {
/// Registry package name, optionally with @version.
pub name: String,
/// Package registry index URL or path.
#[arg(long, value_name = "URL|PATH")]
pub registry: Option<String>,
/// Emit JSON instead of human-readable metadata.
#[arg(long)]
pub json: bool,
}
#[derive(Debug, Args)]
pub(crate) struct PublishArgs {
/// Package directory, harn.toml, or file under the package. Defaults to cwd.
pub package: Option<PathBuf>,
/// Required until registry submission support lands.
#[arg(long)]
pub dry_run: bool,
/// Package registry index URL or path to report as the submission target.
#[arg(long, value_name = "URL|PATH")]
pub registry: Option<String>,
/// Emit JSON instead of a human-readable report.
#[arg(long)]
pub json: bool,
}
#[derive(Debug, Args)]
pub(crate) struct PackageCacheArgs {
#[command(subcommand)]
pub command: PackageCacheCommand,
}
#[derive(Debug, Subcommand)]
pub(crate) enum PackageCacheCommand {
/// List cached git package entries.
List,
/// Remove cached git package entries not referenced by harn.lock, or every entry with --all.
Clean(PackageCacheCleanArgs),
/// Verify cached package contents against harn.lock.
Verify(PackageCacheVerifyArgs),
}
#[derive(Debug, Args)]
pub(crate) struct PackageCacheCleanArgs {
/// Remove every package cache entry instead of only entries unused by the current harn.lock.
#[arg(long, default_value_t = false, action = ArgAction::SetTrue)]
pub all: bool,
}
#[derive(Debug, Args)]
pub(crate) struct PackageCacheVerifyArgs {
/// Also verify materialized packages under .harn/packages/.
#[arg(long, default_value_t = false, action = ArgAction::SetTrue)]
pub materialized: bool,
}
#[derive(Debug, Args)]
pub(crate) struct PackageOutdatedArgs {
/// Resolve registry latest versions over the network instead of relying on the local index cache.
#[arg(long, default_value_t = false, action = ArgAction::SetTrue)]
pub refresh: bool,
/// Probe git remotes for branch-tracking dependencies. Requires git in PATH.
#[arg(long, default_value_t = false, action = ArgAction::SetTrue)]
pub remote: bool,
/// Override the registry index URL or path.
#[arg(long, value_name = "URL|PATH")]
pub registry: Option<String>,
/// Emit JSON instead of a human-readable report.
#[arg(long, default_value_t = false, action = ArgAction::SetTrue)]
pub json: bool,
}
#[derive(Debug, Args)]
pub(crate) struct PackageAuditArgs {
/// Override the registry index URL or path used for yanked-version checks.
#[arg(long, value_name = "URL|PATH")]
pub registry: Option<String>,
/// Skip integrity hashing of materialized packages under .harn/packages/.
#[arg(long, default_value_t = false, action = ArgAction::SetTrue)]
pub skip_materialized: bool,
/// Emit JSON instead of a human-readable report.
#[arg(long, default_value_t = false, action = ArgAction::SetTrue)]
pub json: bool,
}
#[derive(Debug, Args)]
pub(crate) struct PackageArtifactsArgs {
#[command(subcommand)]
pub command: PackageArtifactsCommand,
}
#[derive(Debug, Subcommand)]
pub(crate) enum PackageArtifactsCommand {
/// Print the protocol-artifact manifest the running Harn would generate.
Manifest(PackageArtifactsManifestArgs),
/// Compare a downstream-vendored manifest against the running Harn manifest and report drift.
Check(PackageArtifactsCheckArgs),
}
#[derive(Debug, Args)]
pub(crate) struct PackageArtifactsManifestArgs {
/// Write the manifest to this path instead of stdout.
#[arg(long, value_name = "PATH")]
pub output: Option<PathBuf>,
}
#[derive(Debug, Args)]
pub(crate) struct PackageArtifactsCheckArgs {
/// Path to the vendored protocol-artifact manifest the downstream consumer is shipping.
pub manifest: PathBuf,
/// Emit JSON instead of a human-readable report.
#[arg(long, default_value_t = false, action = ArgAction::SetTrue)]
pub json: bool,
}