Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .reviewmark.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -955,6 +955,22 @@ reviews:
- "test/DemaConsulting.SysML2Tools.Tool.Tests/Query/QueryOmgFixtureTests.cs"
- "test/DemaConsulting.SysML2Tools.Tool.Tests/Query/QueryErrorPathTests.cs"

- id: SysML2Tools-Tool-Export
title: Review of SysML2 Tools Export subsystem implementation
context:
- docs/design/sysml2-tools-tool.md
- docs/reqstream/sysml2-tools-tool.yaml
paths:
- "docs/reqstream/sysml2-tools-tool/export.yaml"
- "docs/design/sysml2-tools-tool/export.md"
- "docs/verification/sysml2-tools-tool/export.md"
- "src/DemaConsulting.SysML2Tools.Tool/Export/*.cs"
- "src/DemaConsulting.SysML2Tools.Tool/Export/ExportStrings.resx"
- "test/DemaConsulting.SysML2Tools.Tool.Tests/Resources/ResxResourceTests.cs"
- "test/DemaConsulting.SysML2Tools.Tool.Tests/Export/ExportTestFixtures.cs"
- "test/DemaConsulting.SysML2Tools.Tool.Tests/Export/ExportSubsystemTests.cs"
- "test/DemaConsulting.SysML2Tools.Tool.Tests/Export/ExportRenderingTests.cs"

- id: SysML2Tools-Tool-Help
title: Review of SysML2 Tools Help subsystem implementation
context:
Expand Down
48 changes: 41 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@ documentation, CI/CD pipelines, and AI-assisted modeling workflows.
`hierarchy`, `requirements`, `interface`, `connections`, `states`, `list`, `find`) for AI
and human callers, with Markdown or JSON output — designed so an AI agent can query
architecture and traceability facts directly instead of reading raw `.sysml` files
- **`export` Command**: Dumps the resolved semantic model (declarations, edges,
diagnostics) as a single JSON document or as JSON Lines (JSONL), for bulk/offline
AI-assisted analysis of an entire workspace at once
- **`help` Command**: Print help for the tool itself, a specific command
(`lint`/`render`/`query`), or a specific `query` verb — identical output to the
(`lint`/`render`/`query`/`export`), or a specific `query` verb — identical output to the
corresponding `<command> --help`
- **GeneralView Layout**: Package-grouped definition block diagrams placed by a layered (ELK-style)
engine with orthogonal specialization and membership edges, depth-coded fill colors, compartments,
Expand Down Expand Up @@ -132,15 +135,37 @@ sysml2tools query uses --element Pkg::MyPart model.sysml --format json
See [Querying](docs/user_guide/introduction.md#querying) in the user guide for the full
verb reference and more examples.

### Exporting

Dump the resolved semantic model as JSON or JSONL, for bulk/offline AI-assisted analysis:

```bash
# Export the whole workspace as a single indented JSON document (default format)
sysml2tools export model.sysml

# Export as JSON Lines (one compact JSON object per declaration/edge/diagnostic)
sysml2tools export model.sysml --format jsonl

# Write to a file instead of stdout (--output names a FILE, not a directory)
sysml2tools export "src/**/*.sysml" --format jsonl --output model.jsonl

# Include OMG standard library declarations/edges in the export
sysml2tools export model.sysml --include-stdlib
```

See [Exporting](docs/user_guide/introduction.md#exporting) in the user guide for the full
JSON/JSONL output shape.

### Getting Help

```bash
# Top-level help (same as bare --help)
sysml2tools help

# Command-specific help (identical to `lint --help`/`render --help`)
# Command-specific help (identical to `lint --help`/`render --help`/`export --help`)
sysml2tools help lint
sysml2tools help render
sysml2tools help export

# Query verb overview (identical to `query --help`)
sysml2tools help query
Expand Down Expand Up @@ -175,11 +200,11 @@ sysml2tools --silent --log output.log
sysml2tools [-v|--version] [-?|-h|--help] [--silent]
[--validate] [--result|--results <file>] [--depth <#>] [--log <file>]
[<verb> [verb-options] [<globs>]]
sysml2tools help [lint|render|query [<query-verb>]]
sysml2tools help [lint|render|query [<query-verb>]|export]
```

`<verb>` is `lint`, `render`, or `query <query-verb>` (11 query verbs — see the *Querying*
section above).
`<verb>` is `lint`, `render`, `export`, or `query <query-verb>` (11 query verbs — see the
*Querying* section above).

### Global Options

Expand Down Expand Up @@ -230,11 +255,20 @@ section above).
| `--name <substring>` | Name substring filter (`list`/`find` verbs only) |
| `--include-stdlib` | Include OMG standard library elements in results |

### `export` Options

| Option | Description |
| --- | --- |
| `<globs>` | One or more glob patterns for `.sysml` input files |
| `--format json\|jsonl` | Output format (default: `json`) |
| `--output <file>` | Write export document to this **file** (default: stdout); differs from `render`'s `--output` dir |
| `--include-stdlib` | Include OMG standard library declarations/edges (diagnostics are never stdlib-filtered) |

### `help` Options

| Option | Description |
| --- | --- |
| `[command]` | Optional: `lint`, `render`, or `query`; omit for top-level help |
| `[command]` | Optional: `lint`, `render`, `query`, or `export`; omit for top-level help |
| `[verb]` | Optional; only meaningful when `command` is `query` — one of the 11 supported query verbs |

## View Selection
Expand Down Expand Up @@ -265,7 +299,7 @@ see the *Introduction* user guide for details.
| `DemaConsulting.SysML2Tools.Language` | Library: SysML v2/KerML parser, AST, semantic model |
| `DemaConsulting.SysML2Tools.Stdlib` | Library: pre-compiled SysML v2 standard library |
| `DemaConsulting.SysML2Tools.Core` | Library: parser, semantic model, layout, `IRenderer` interface |
| `DemaConsulting.SysML2Tools.Tool` | CLI tool: `lint`, `render`, and `query` commands |
| `DemaConsulting.SysML2Tools.Tool` | CLI tool: `lint`, `render`, `query`, and `export` commands |

Library consumers can take a dependency on `DemaConsulting.SysML2Tools.Core` alone to access
parsing, semantic model, and layout without pulling in the CLI tool; `Core` automatically pulls
Expand Down
14 changes: 10 additions & 4 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The work falls into three themes:
and finish the remaining view dynamics.
- **Release & packaging** — self-validation coverage, package validation, and licensing/attribution.
- **Model query & analysis** — further AI-analysis options beyond the completed dynamic
(ad-hoc) views feature.
(ad-hoc) views and `export` verb features.

---

Expand Down Expand Up @@ -223,23 +223,29 @@ verification documentation for the full per-kind compatibility rules; the sequen
compatibility-check gap is carried forward as a known limitation in the "View dynamics
refinements" item above.

**Done:** `export` verb — `export [--format json|jsonl] [--output <file>] [--include-stdlib]
<patterns...>` dumps the resolved semantic model (declarations, edges, diagnostics) as a
single indented JSON document or as JSON Lines, for an agent harness to index locally and run
its own queries offline. Implemented by the new `Export` subsystem (`ExportCommand`,
`ExportResult`, `ExportResultSerializerContext`/`ExportLineSerializerContext`), reusing
`SysmlNode`/`SysmlEdge`/`SysmlDiagnostic` directly rather than a fourth parallel result shape.
See its design/requirements/verification documentation for the full JSON/JSONL output shape.

### Additional AI-analysis options (candidates)

Lower-priority options that further support AI analysis of a model; each is independently
scoped and gated, and any may be pulled forward or dropped:

- **`--format sarif` for `lint`** — `SysmlDiagnostic` is already structurally SARIF-compatible;
emitting SARIF lets AI/CI toolchains consume lint findings through standard tooling.
- **`export` verb** — dump the resolved semantic model (symbol table + edges + diagnostics) as
JSON/JSONL for an agent harness to index locally and run its own queries offline.
- **Metrics / summary query** — workspace-level counts and hotspots (most-depended-on elements,
unverified requirements, orphan elements, cyclic specialization) to orient an AI before it
starts, and to flag model-health issues in review.
- **`diff` of two workspaces** — structural/semantic delta between two model revisions (added /
removed / changed elements, edges, and requirement traces) so an AI reviewing a change sees the
*model-level* impact of a PR, not just the text diff.
- **Machine-readable `--format json` everywhere** — extend the shared formatter so every command
(not just `query`) can emit JSON, keeping the CLI uniformly scriptable.
(not just `query`/`export`) can emit JSON, keeping the CLI uniformly scriptable.

---

Expand Down
25 changes: 17 additions & 8 deletions docs/design/sysml2-tools-tool.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
## Architecture

The `DemaConsulting.SysML2Tools.Tool` is a command-line application built on .NET. It is structured as one
system containing one top-level unit (`Program`) and seven subsystems (`Cli`, `Lint`, `Render`,
`Help`, `Query`, `SelfTest`, `Utilities`):
system containing one top-level unit (`Program`) and eight subsystems (`Cli`, `Lint`, `Render`,
`Help`, `Query`, `Export`, `SelfTest`, `Utilities`):

```mermaid
flowchart TD
Expand All @@ -24,6 +24,9 @@ flowchart TD
subgraph Query
QueryCommand
end
subgraph Export
ExportCommand
end
subgraph SelfTest
Validation
end
Expand All @@ -35,6 +38,7 @@ flowchart TD
Program --> RenderCommand
Program --> HelpCommand
Program --> QueryCommand
Program --> ExportCommand
Program --> Validation
Validation --> Program
Validation --> PathHelpers
Expand All @@ -44,7 +48,8 @@ flowchart TD
`LintCommand` when the `lint` subcommand is passed, dispatches to `RenderCommand` when the
`render` subcommand is passed, dispatches to `HelpCommand` when the `help` subcommand (or
`--help`) is passed, dispatches to `QueryCommand` when the `query` subcommand is passed,
dispatches to `Validation` when `--validate` is passed, and returns the exit code from
dispatches to `ExportCommand` when the `export` subcommand is passed, dispatches to
`Validation` when `--validate` is passed, and returns the exit code from
`Context`. `Validation` calls `Program.Run` recursively to exercise the tool during
self-testing, and uses `PathHelpers` to construct safe temporary file paths.

Expand All @@ -58,8 +63,10 @@ self-testing, and uses `PathHelpers` to construct safe temporary file paths.
`--results <file>`, `--result <file>` (legacy alias for `--results`), `--depth <n>`, and
`--log <file>`. Accepts `lint <patterns...>` as a subcommand that invokes lint mode. Accepts
`query <verb> [options] <patterns...>` (11 verbs; `--element`/`-e`, `--format`,
`--direction`, `--kind`, `--name`, `--include-stdlib` options) as a preview subcommand whose
verbs currently report a "not yet implemented" diagnostic. Returns
`--direction`, `--kind`, `--name`, `--include-stdlib` options). Accepts
`export [options] <patterns...>` (`--format json|jsonl`, `--output <file>`,
`--include-stdlib` options) which dumps the resolved semantic model (declarations, edges,
diagnostics) as JSON or JSON Lines. Returns
exit code 0 for success and 1 for failures.
- *Constraints*: Unknown arguments cause exit code 1 and an error message on stderr.

Expand Down Expand Up @@ -137,10 +144,12 @@ N/A - not a safety-classified software item.
close any open log file handle.
- Path safety: all caller-supplied path components are validated by `PathHelpers.SafePathCombine`
before file-system use.
- Localization: `Program`, `Lint`, `Render`, and `Query`'s banner/help text (everything printed
by `PrintBanner`/`PrintTopLevelHelp`/`PrintHelp`/`PrintGeneralHelp`/`PrintVerbHelp`) is
- Localization: `Program`, `Lint`, `Render`, `Query`, and `Export`'s banner/help text
(everything printed by
`PrintBanner`/`PrintTopLevelHelp`/`PrintHelp`/`PrintGeneralHelp`/`PrintVerbHelp`) is
sourced from per-subsystem `.resx` files via hand-written `ResourceManager` accessor classes
(`ProgramStrings`, `LintStrings`, `RenderStrings`, `QueryStrings`), so a future non-English
(`ProgramStrings`, `LintStrings`, `RenderStrings`, `QueryStrings`, `ExportStrings`), so a
future non-English
locale can be added with zero code changes (see
`docs/design/sysml2-tools-tool/program.md`). Operational/diagnostic messages (progress
lines, error messages) remain plain string literals and are explicitly out of scope for
Expand Down
Loading
Loading