[PyneTS CLI]

pynets check / format / run / dump / info — Rich TTY, JSON on pipes. run calls Runtime.run, unlike Python pyne run.

PyneTS CLI

Abstract

pynets is a Bun CLI for parse, format, AST dump, and evaluate. TTY output is a Rich-inspired panel (PYNE volt). Pipes and --json stay machine-readable. Exit codes: 0 ok, 1 syntax/runtime, 2 usage.

Unlike Python pyne run (compile-only smoke), pynets run calls Runtime.run. Default --mode interpret. --mode compile / auto select JS emit (@hoox-sh/pynets 0.2.0, including this repo’s pynets/ pin).

Conceptual model

Interface surface

usage: pynets <check|format|run|dump|info> [file] [--bars N]
              [--mode interpret|compile|auto]
              [--commission N] [--slippage N] [--pyramiding N]
              [--json] [--plain] [--rich] [--full] [--indent N]
CommandActionFile required
checkParse-only validationyes
formatParse → unparse (pretty on TTY)yes
runRuntime.run on synthetic OHLCVyes
dumpASDL-shaped ASTyes
infoVersion and runtime extrasno
help / -hUsageno
FlagMeaning
--bars NSynthetic bar count for run (default 20, max 100000)
--mode MODEinterpret (default) | compile | auto
--commission NBroker commission fraction (e.g. 0.001)
--slippage NBroker slippage in price units
--pyramiding NMax same-direction adds
--jsonMachine-readable run / info
--indent NAST dump indent (default 2)
--fullPrint the full dump (no 80-line cap)
--plainDisable Rich (wins over FORCE_COLOR)
--richForce Rich (put after the command)
-h, --helpHelp

Path resolution

resolveUserFile takes only the path you typed (cwd-relative or absolute). No search path. Missing file → exit 2 (error: file not found).

Synthetic bars

run builds a ramp: close = 100 + i, high/low = close ± 0.5, volume = 1, time = 1700000000000 + i * 60000. Symbol is hardcoded AAPL. This is a desk smoke, not a data provider.

Internals

PathRole
src/cli.tsArg parse, commands, exit codes
src/cli/rich.tsTTY paint, help, tables, sparkline
src/index.tsparse / unparse / dump / Runtime

run constructs new Runtime("AAPL", { broker, mode }).run(source, syntheticBars(bars)).

Invariants & edge cases

  1. Pipe-safe. Non-TTY check prints ok. Non-TTY run prints JSON.
  2. --rich must come after the command (pynets run x.pine --rich), because flags before the command are stripped for Rich detection.
  3. Unknown flags and extra positional args are usage errors (exit 2).
  4. run default mode is interpret, matching new Runtime() — not Pro API auto.
  5. --bars is clamped; negative / non-integer → usage error.

Worked examples

pynets check script.pine
pynets format script.pine
pynets dump script.pine --full
pynets run script.pine --bars 50
pynets run script.pine --mode compile --json
pynets run strat.pine --commission 0.001 --pyramiding 1
pynets info --json

CI:

pynets check script.pine
# stdout: ok
# exit 0 / 1 / 2

Failure modes

SymptomCauseFix
Exit 2 missing fileNo path / ENOENTPass a real file
Exit 1 on checkSyntax errorRead the ANTLR message
run JSON has error / error_kind: parseScript does not parsepynets check first
Expected compile-only like pyne runDifferent CLISee modes
Rich garbage in logsTTY detected--plain or pipe

See also