tessera-design-toolkit 0.7.1

Tessera Design Toolkit (TDT) - CLI for managing engineering artifacts with requirements, risks, BOMs, tolerance analysis, and full traceability
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
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
//! CLI argument definitions using clap derive

use clap::{Parser, Subcommand, ValueEnum};
use std::path::PathBuf;

use crate::cli::commands::{
    asm::AsmCommands,
    baseline::BaselineCommands,
    blame::BlameArgs,
    bulk::BulkCommands,
    cache::CacheCommands,
    capa::CapaCommands,
    cmp::CmpCommands,
    completions::CompletionsArgs,
    config::ConfigCommands,
    ctrl::CtrlCommands,
    dev::DevCommands,
    diff::DiffArgs,
    dmm::DmmArgs,
    dsm::DsmArgs,
    export::ExportCommands,
    feat::FeatCommands,
    haz::HazCommands,
    history::HistoryArgs,
    import::ImportArgs,
    init::InitArgs,
    link::LinkCommands,
    log::LogArgs,
    lot::LotCommands,
    mate::MateCommands,
    ncr::NcrCommands,
    proc::ProcCommands,
    quote::QuoteCommands,
    recent::RecentArgs,
    report::ReportCommands,
    req::ReqCommands,
    risk::RiskCommands,
    rslt::RsltCommands,
    schema::SchemaCommands,
    search::SearchArgs,
    status::StatusArgs,
    sup::SupCommands,
    tags::TagsCommands,
    test::TestCommands,
    tol::TolCommands,
    trace::TraceCommands,
    validate::ValidateArgs,
    where_used::WhereUsedArgs,
    work::WorkCommands,
    workflow::{
        ApproveArgs, CheckArgs, RejectArgs, ReleaseArgs, ReviewCommands, SubmitArgs, TeamCommands,
    },
};

/// Custom help template with grouped commands
const HELP_TEMPLATE: &str = "\
{before-help}{name} {version}
{about-with-newline}
{usage-heading} {usage}

PROJECT:
  init        Initialize a new Tessera project
  status      Show project status dashboard
  validate    Validate project files against schemas

REQUIREMENTS & RISKS:
  req         Requirement management (new, list, show, edit)
  haz         Hazard management (new, list, show, edit)
  risk        Risk/FMEA management (new, list, show, edit, summary)

VERIFICATION & VALIDATION:
  test        Test protocol management (new, list, show, edit)
  rslt        Test result management (new, list, show, edit)

BILL OF MATERIALS:
  cmp         Component management (new, list, show, edit)
  asm         Assembly management (new, list, show, edit, cost, mass)

PROCUREMENT:
  quote       Quote management (new, list, show, edit)
  sup         Supplier management (new, list, show, edit)

MANUFACTURING:
  proc        Manufacturing process management (new, list, show, edit)
  ctrl        Control plan item management (new, list, show, edit)
  work        Work instruction management (new, list, show, edit)
  lot         Production lot/batch management (new, list, show, step, complete)
  dev         Process deviation management (new, list, show, approve, expire)

QUALITY:
  ncr         Non-conformance report management (new, list, show, edit)
  capa        Corrective/preventive action management (new, list, show, edit)

TOLERANCE ANALYSIS:
  feat        Feature management - dimensional features on components
  mate        Mate management - 1:1 feature contacts with fit calculation
  tol         Tolerance stackup analysis (worst-case, RSS, Monte Carlo)

TRACEABILITY & REPORTS:
  link        Manage links between entities (add, remove, show)
  trace       Traceability queries (from, to, coverage)
  dsm         Design Structure Matrix for component interactions
  dmm         Domain Mapping Matrix for cross-entity analysis
  where-used  Find where an entity is used/referenced
  report      Generate engineering reports (rvm, fmea, bom, etc.)

VERSION CONTROL:
  history     View git history for an entity
  blame       View git blame for an entity
  diff        View git diff for an entity
  baseline    Baseline management (create, compare, list, changed)

WORKFLOW (opt-in):
  submit      Submit entities for review (creates PR)
  approve     Approve entities under review
  reject      Reject entities back to draft
  release     Release approved entities
  review      View pending reviews (list, summary)
  team        Team roster management (list, whoami, init, add, remove)
  check       Check entities meet approval requirements

INTERCHANGE:
  export      Export project data (sysml)
  import      Import entities from CSV or SysML files

UTILITIES:
  bulk        Bulk operations on multiple entities
  cache       Entity cache management (rebuild, sync, status, query)
  config      View and modify Tessera configuration (show, set, unset)
  search      Search across all entity types
  recent      Show recently modified entities
  tags        View and manage entity tags (list, show)
  schema      View entity field definitions, valid values, and link types
  completions Generate shell completion scripts (bash, zsh, fish, powershell)
  help        Print this message or the help of the given subcommand(s)

OPTIONS:
{options}
{after-help}";

#[derive(Parser)]
#[command(name = "tdt")]
#[command(author, version, about = "Tessera - Engineering Artifact Management")]
#[command(
    long_about = "Tessera is a Unix-style toolkit for managing engineering artifacts as plain text files under git version control. Visit https://tessera-engineering.com for documentation."
)]
#[command(propagate_version = true)]
#[command(help_template = HELP_TEMPLATE)]
#[command(subcommand_required = true)]
#[command(disable_help_subcommand = false)]
#[command(infer_subcommands = true)]
pub struct Cli {
    #[command(subcommand)]
    pub command: Commands,

    #[command(flatten)]
    pub global: GlobalOpts,
}

#[derive(clap::Args, Clone, Debug)]
pub struct GlobalOpts {
    /// Output format (json, yaml, csv, tsv, md, id, short-id, path, dot, tree, table)
    #[arg(long, short = 'o', global = true, default_value = "auto")]
    pub output: OutputFormat,

    /// Suppress non-essential output
    #[arg(long, short = 'q', global = true)]
    pub quiet: bool,

    /// Enable verbose output
    #[arg(long, short = 'v', global = true)]
    pub verbose: bool,

    /// Project root (default: auto-detect by finding .tdt/)
    #[arg(long, global = true)]
    pub project: Option<PathBuf>,
}

/// Subcommands grouped logically by function area
#[derive(Subcommand)]
pub enum Commands {
    // ─────────────────────────────────────────────────────────────────────
    // PROJECT MANAGEMENT
    // ─────────────────────────────────────────────────────────────────────
    /// Initialize a new Tessera project
    Init(InitArgs),

    /// Show project status dashboard
    Status(StatusArgs),

    /// Validate project files against schemas
    Validate(ValidateArgs),

    // ─────────────────────────────────────────────────────────────────────
    // REQUIREMENTS & RISKS
    // ─────────────────────────────────────────────────────────────────────
    /// Requirement management (new, list, show, edit)
    #[command(subcommand)]
    Req(ReqCommands),

    /// Hazard management (new, list, show, edit)
    #[command(subcommand)]
    Haz(HazCommands),

    /// Risk/FMEA management (new, list, show, edit, summary)
    #[command(subcommand)]
    Risk(RiskCommands),

    // ─────────────────────────────────────────────────────────────────────
    // VERIFICATION & VALIDATION
    // ─────────────────────────────────────────────────────────────────────
    /// Test protocol management (new, list, show, edit)
    #[command(subcommand)]
    Test(TestCommands),

    /// Test result management (new, list, show, edit)
    #[command(subcommand)]
    Rslt(RsltCommands),

    // ─────────────────────────────────────────────────────────────────────
    // BILL OF MATERIALS
    // ─────────────────────────────────────────────────────────────────────
    /// Component management (new, list, show, edit)
    #[command(subcommand)]
    Cmp(CmpCommands),

    /// Assembly management (new, list, show, edit, cost, mass)
    #[command(subcommand)]
    Asm(AsmCommands),

    // ─────────────────────────────────────────────────────────────────────
    // PROCUREMENT
    // ─────────────────────────────────────────────────────────────────────
    /// Quote management (new, list, show, edit)
    #[command(subcommand)]
    Quote(QuoteCommands),

    /// Supplier management (new, list, show, edit)
    #[command(subcommand)]
    Sup(SupCommands),

    // ─────────────────────────────────────────────────────────────────────
    // MANUFACTURING
    // ─────────────────────────────────────────────────────────────────────
    /// Manufacturing process management (new, list, show, edit)
    #[command(subcommand)]
    Proc(ProcCommands),

    /// Control plan item management (new, list, show, edit)
    #[command(subcommand)]
    Ctrl(CtrlCommands),

    /// Work instruction management (new, list, show, edit)
    #[command(subcommand)]
    Work(WorkCommands),

    /// Production lot/batch management (new, list, show, step, complete)
    #[command(subcommand)]
    Lot(LotCommands),

    /// Process deviation management (new, list, show, approve, expire)
    #[command(subcommand)]
    Dev(DevCommands),

    // ─────────────────────────────────────────────────────────────────────
    // QUALITY
    // ─────────────────────────────────────────────────────────────────────
    /// Non-conformance report management (new, list, show, edit)
    #[command(subcommand)]
    Ncr(NcrCommands),

    /// Corrective/preventive action management (new, list, show, edit)
    #[command(subcommand)]
    Capa(CapaCommands),

    // ─────────────────────────────────────────────────────────────────────
    // TOLERANCE ANALYSIS
    // ─────────────────────────────────────────────────────────────────────
    /// Feature management - dimensional features on components
    #[command(subcommand)]
    Feat(FeatCommands),

    /// Mate management - 1:1 feature contacts with fit calculation
    #[command(subcommand)]
    Mate(MateCommands),

    /// Tolerance stackup analysis (worst-case, RSS, Monte Carlo)
    #[command(subcommand)]
    Tol(TolCommands),

    // ─────────────────────────────────────────────────────────────────────
    // TRACEABILITY & REPORTS
    // ─────────────────────────────────────────────────────────────────────
    /// Manage links between entities (add, remove, show)
    #[command(subcommand)]
    Link(LinkCommands),

    /// View workflow activity log (approvals, releases) across all entities
    Log(LogArgs),

    /// Traceability queries (from, to, coverage)
    #[command(subcommand)]
    Trace(TraceCommands),

    /// Design Structure Matrix for component interactions
    Dsm(DsmArgs),

    /// Domain Mapping Matrix for cross-entity analysis
    Dmm(DmmArgs),

    /// Find where an entity is used/referenced
    WhereUsed(WhereUsedArgs),

    /// Generate engineering reports (rvm, fmea, bom, etc.)
    #[command(subcommand)]
    Report(ReportCommands),

    // ─────────────────────────────────────────────────────────────────────
    // VERSION CONTROL
    // ─────────────────────────────────────────────────────────────────────
    /// View git history for an entity
    History(HistoryArgs),

    /// View git blame for an entity
    Blame(BlameArgs),

    /// View git diff for an entity
    Diff(DiffArgs),

    /// Baseline management (create, compare, list, changed)
    #[command(subcommand)]
    Baseline(BaselineCommands),

    // ─────────────────────────────────────────────────────────────────────
    // WORKFLOW (opt-in)
    // ─────────────────────────────────────────────────────────────────────
    /// Submit entities for review (creates PR)
    Submit(SubmitArgs),

    /// Approve entities under review
    Approve(ApproveArgs),

    /// Reject entities back to draft
    Reject(RejectArgs),

    /// Release approved entities
    Release(ReleaseArgs),

    /// View pending reviews (list, summary)
    #[command(subcommand)]
    Review(ReviewCommands),

    /// Team roster management (list, whoami, init, add, remove)
    #[command(subcommand)]
    Team(TeamCommands),

    /// Check entities meet approval requirements
    Check(CheckArgs),

    // ─────────────────────────────────────────────────────────────────────
    // INTERCHANGE
    // ─────────────────────────────────────────────────────────────────────
    /// Export project data (sysml)
    #[command(subcommand)]
    Export(ExportCommands),

    /// Import entities from CSV or SysML files
    Import(ImportArgs),

    // ─────────────────────────────────────────────────────────────────────
    // UTILITIES
    // ─────────────────────────────────────────────────────────────────────
    /// Bulk operations on multiple entities
    #[command(subcommand)]
    Bulk(BulkCommands),

    /// Entity cache management (rebuild, sync, status, query)
    #[command(subcommand)]
    Cache(CacheCommands),

    /// View and modify Tessera configuration (show, set, unset)
    #[command(subcommand)]
    Config(ConfigCommands),

    /// Search across all entity types
    Search(SearchArgs),

    /// Show recently modified entities
    Recent(RecentArgs),

    /// View and manage entity tags (list, show)
    #[command(subcommand)]
    Tags(TagsCommands),

    /// View entity schemas (list, show) - for AI agent ergonomics
    #[command(subcommand)]
    Schema(SchemaCommands),

    /// Generate shell completion scripts
    Completions(CompletionsArgs),
}

#[derive(ValueEnum, Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum OutputFormat {
    /// Automatically detect based on context (yaml for show, tsv for list)
    #[default]
    Auto,
    /// YAML format (full fidelity)
    Yaml,
    /// Tab-separated values (for piping)
    Tsv,
    /// JSON format (for programming)
    Json,
    /// CSV format (for spreadsheets)
    Csv,
    /// Markdown tables
    Md,
    /// Just IDs, one per line (full ULIDs for git collaboration)
    Id,
    /// Short IDs only (e.g., REQ@1) for piping between tdt commands
    #[value(name = "short-id")]
    ShortId,
    /// File path only (for new commands - enables easy editing after creation)
    Path,
    /// Graphviz DOT format (for dependency graphs)
    Dot,
    /// ASCII tree format (for hierarchical output)
    Tree,
    /// Human-readable table format (default for list commands)
    Table,
}