m-cli

command module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 15, 2026 License: Apache-2.0 Imports: 27 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

m-cli

The cross-engine M toolchain — the m busybox. A single static Go binary that delivers fmt/lint/lsp/test/coverage/watch for M (MUMPS) source, working across YottaDB and IRIS (spec §1). It's the Go rewrite of the Python m-cli, built on the m-parse substrate (tree-sitter-m via wazero — no CGO).

Status. The native commands fmt/lint/lsp/test/coverage/watch are built, and m is now the busybox dispatcher: it fronts the sibling binaries irissync (IRIS source axis) and kids-vc (KIDS round-trip) under one m, with one aggregated m schema. See the implementation plan.

m fmt --rules=canonical --check .    # CI gate: exit 3 if any file differs
m lint --profile xindex routine.m    # query-driven rules over the parse tree
m test --engine ydb …                # run *TST.m suites through the engine
m pull --full                        # → irissync pull (materialize IRIS source)
m kids decompose patch.KID           # → kids-vc decompose
m schema | jq .                      # the full aggregated tree as JSON

m fmt

An AST-preserving formatter over the m-parse syntax tree (spec §3.1). It works as edits-over-source: rules emit byte-span edits guided by the parse tree, applied to the original bytes. Two key properties:

  • Identity by default. With the default --rules=identity, nothing changes — unformatted input round-trips byte-for-byte. Formatting is opt-in (mirrors the Python m-cli's identity default + canonical layer).
  • AST-preserving. Rules only change what they must (e.g. keyword letter-case), verified by an internal tree-shape check: parse(format(src)) has the same shape as parse(src).
Preset (--rules) What it does
identity (default) No-op; the round-trip baseline.
canonical uppercase-command-keywords — set→SET, w→W, leaving arguments untouched. (More rules + the pythonic/pythonic-lower/compact/sac presets follow.)

Flags: --check (report files needing formatting; exit 3 if any — the CI gate), --write/-w (rewrite in place), --stdin (format stdin → stdout as a raw filter). With no flags it reports what would change (exit 0).

File discovery walks paths (default .) for .m / .mac / .int — .int is included because VistA loaded via ^%RI stores its routine source as .int (there .int is the source, not compiler output). Explicit file arguments are formatted as given.

The busybox — dispatched subcommands

m keeps its native commands and dispatches the rest to sibling binaries, so each sibling keeps its own SBOM and release cadence — a small attestable family, not one mixed-dep blob (spec §2.2, ADR §5):

m command Forwards to Notes
m list · m pull · m status · m verify · m push irissync the IRIS source axis (push is the sole DB writer)
m kids <decompose|assemble|roundtrip|canonicalize|lint|parse> kids-vc KIDS round-trip + PIKS data-class gate
  • Discovery. Each sibling is resolved in order: the M_<NAME>_BIN override (e.g. M_IRISSYNC_BIN, M_KIDS_VC_BIN), then alongside the m binary, then $PATH. A miss is a deterministic SIBLING_NOT_FOUND error object (exit 1) — never a panic or a raw exec error.
  • Faithful passthrough. Args, stdin/stdout/stderr, and the child's exit code pass through unchanged; the toolchain-wide globals (--output, --verbose, --no-color) are re-forwarded so the sibling renders identically.
  • One tree. m schema aggregates each available sibling's sub-schema under its dispatched namespace, so an agent sees a single command tree. Siblings that aren't installed degrade to a discoverable stub (the schema stays valid).

Extension point. Adding a dispatched namespace (e.g. m meta … → vista-meta, deferred) is a one-line Spec in internal/dispatch; nothing else changes. Discovery, forwarding, and schema aggregation all key off that registry.

Architecture

   m fmt … ──► discover .m/.mac/.int ──► for each file:
                                           parse (m-parse: tree-sitter-m via
                                                  wazero, embedded WASM, no CGO)
                                           rules emit byte-span edits ──► apply
                                           ──► --check (exit 3) / --write / report

The whole binary stays static (CGO_ENABLED=0) because the parser is the embedded grammar WASM run in wazero (m-parse), not a CGO tree-sitter binding.

Repository layout

m-cli/
├── main.go                 # the `m` CLI grammar (Kong struct) + `m fmt`, version, schema
├── internal/mfmt/          # the formatter
│   ├── format.go           #   Format() + the edits-over-source engine (applyEdits)
│   ├── rules.go            #   Rule interface; identity/canonical presets; uppercase-command-keywords
│   └── shape.go            #   SameShape — the AST-preserving check
├── clikit/                 # shared CLI conventions (from go-cli-template)
├── Makefile · .golangci.yml · .github/workflows/ci.yml
└── LICENSE · NOTICE        # Apache-2.0 (Go); see Licensing

Build, test, CI

Target What it does
make build dist/m, static (CGO_ENABLED=0), -trimpath, version-stamped
make test go test -race -cover ./... (race needs CGO; the rest is CGO-free)
make lint golangci-lint run ./...
make schema build + emit the JSON schema (CI conformance artifact)
make dist cross-compile linux/{amd64,arm64}, darwin/arm64, windows/amd64

CI (the org's reusable go-ci workflow) runs golangci-lint, race tests, the schema contract, and a static CGO_ENABLED=0 cross-compile matrix.

Licensing

The Go code here is Apache-2.0 (LICENSE/NOTICE). The binary links m-parse, whose embedded grammar WASM is currently AGPL-3.0, so a built m transitively includes an AGPL-derived artifact. Per project policy, all licensing reconciliation is deferred to project completion — end-state Apache-2.0 for every artifact except the VS Code extensions (MIT). The interim AGPL status is not a blocker. See the m-parse NOTICE and the toolchain spec.

Documentation

Overview

Command m is the cross-engine M toolchain (the busybox; spec §1). This stage ships `m fmt` — the AST-preserving formatter over the m-parse substrate (spec §3.1) — alongside the shared clikit conventions (--output text|json, schema, deterministic errors). lint/lsp/test/coverage/watch land next.

Try:

m fmt routine.m                      # report whether it needs formatting
m fmt --rules=canonical --write .    # uppercase command keywords in place
m fmt --rules=canonical --check .    # CI gate: exit 3 if any file differs
cat routine.m | m fmt --rules=canonical --stdin
m schema | jq .

Directories

Path Synopsis
Package clikit is the shared CLI convention layer for the m-cli Go toolchain.
Package clikit is the shared CLI convention layer for the m-cli Go toolchain.
internal
arch
Package arch implements the m/v waterline gates — the machine-checkable boundary between the engine-neutral `m` layer and the VistA-specific `v` layer (see docs/background/m-v-waterline-adr.md in the org `docs` repo).
Package arch implements the m/v waterline gates — the machine-checkable boundary between the engine-neutral `m` layer and the VistA-specific `v` layer (see docs/background/m-v-waterline-adr.md in the org `docs` repo).
config
Package config loads m-cli's project-level configuration — the [lint.*] and fmt sections of a `.m-cli.toml` (preferred) or a `[tool.m-cli]` table in pyproject.toml.
Package config loads m-cli's project-level configuration — the [lint.*] and fmt sections of a `.m-cli.toml` (preferred) or a `[tool.m-cli]` table in pyproject.toml.
dispatch
Package dispatch is the `m` busybox's sibling-binary dispatcher (spec §2.2, tracker [N12]).
Package dispatch is the `m` busybox's sibling-binary dispatcher (spec §2.2, tracker [N12]).
engine
Package engine is the runtime adapter — the only engine-bound code in m-cli (spec §8).
Package engine is the runtime adapter — the only engine-bound code in m-cli (spec §8).
flow
Package flow is m-cli's control-flow / dataflow infrastructure for the path-sensitive lint rules (spec §3.1; the Python tool's "Phase 7").
Package flow is m-cli's control-flow / dataflow infrastructure for the path-sensitive lint rules (spec §3.1; the Python tool's "Phase 7").
harness
Package harness is the host-side trigger/render client for the resident pure-M harness (design §3.1, spec §9).
Package harness is the host-side trigger/render client for the resident pure-M harness (design §3.1, spec §9).
lint
Package lint is m-cli's M source linter.
Package lint is m-cli's M source linter.
lsp
Package lsp is m-cli's Language Server (spec §3.1): LSP 3.x over stdio, reusing the lint and fmt engines so the editor shows exactly the diagnostics CI produces.
Package lsp is m-cli's Language Server (spec §3.1): LSP 3.x over stdio, reusing the lint and fmt engines so the editor shows exactly the diagnostics CI produces.
mcov
Package mcov is m-cli's coverage runner (spec §3.1/§8).
Package mcov is m-cli's coverage runner (spec §3.1/§8).
mfmt
Package mfmt is m-cli's AST-preserving M source formatter (spec §3.1).
Package mfmt is m-cli's AST-preserving M source formatter (spec §3.1).
mtest
Package mtest is m-cli's test runner (spec §3.2): it discovers *TST.m suites, runs them through the Engine adapter, and parses the pure-M ^STDASSERT / TESTRUN output.
Package mtest is m-cli's test runner (spec §3.2): it discovers *TST.m suites, runs them through the Engine adapter, and parses the pure-M ^STDASSERT / TESTRUN output.
watch
Package watch is the host-side half of `m watch` (spec §3.1, §9): a save triggered inner loop that re-runs the engine-neutral checks (lint, fmt) on changed files.
Package watch is the host-side half of `m watch` (spec §3.1, §9): a save triggered inner loop that re-runs the engine-neutral checks (lint, fmt) on changed files.
workspace
Package workspace is an in-memory cross-routine index of M source: every routine's labels (declarations) and outbound call sites (references).
Package workspace is an in-memory cross-routine index of M source: every routine's labels (declarations) and outbound call sites (references).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址