Commit Graph

5 Commits

Author SHA1 Message Date
111be2c744 v0.8.26: harden control-byte sanitize across the tool suite + ssh-helper traps
Shared _sanitize_ctl (unconditional, nc-document) and _sanitize_ctl_tty
(strips only when stdout is a terminal) now live in cygwin-safe.sh. nc-msgs,
nc-parse, and the hl7-* tools route stdout through the tty-gated variant, so a
terminal is protected from raw HL7/NetConfig control bytes while pipes and
redirects stay byte-exact (the 0x1c framing route_test needs is preserved).
Exit codes propagate via PIPESTATUS. ssh-helper _read_hidden installs its
restore trap before stty -echo on every path and saves/restores the prior trap.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-28 16:35:06 -07:00
9dd5821436 v0.7.5: OAuth CR-taint fix + mouse opt-in + CR-safety sweep
- Fix bash arithmetic crash on MobaXterm/Cygwin: $(date +%s) was
  returning CR-tainted values landing in $(( )) operands
- Mouse mode off by default; opt in via LARRY_MOUSE=1 or /mouse on
- Comprehensive CR-safety sweep across lib/*.sh and larry.sh — every
  command-substitution result, file read, and user input that feeds
  an arithmetic context, case dispatcher, or path/header is now
  CR-stripped at the source

New shared helper lib/cygwin-safe.sh defines three primitives:
  coerce_int VAL [DEFAULT]   — for arithmetic / integer-test operands
  strip_cr VAL               — for case patterns, regex tests, paths, headers
  read_clean VAR [PROMPT]    — read -r wrapper that strips CR pre-assign

Hardened call sites (14 files, 60+ patch points):
  - larry.sh:  status-line date/tput, 3 y/N approvals, auth menu, API key
  - lib/oauth.sh:  cmd_login + cmd_refresh date+%s captures
  - lib/nc-engine.sh:  5 y/N action prompts + find|wc arithmetic
  - lib/nc-msgs.sh:  parse_time_ms (4 date sites) + meta-TSV time + MSG_COUNT
  - lib/nc-regression.sh:  tr|wc count + hl7-diff ?-fallback arithmetic
  - lib/nc-smat-diff.sh:  A_COUNT/B_COUNT/DIFFS_TOTAL
  - lib/nc-insert-protocol.sh:  every awk-emitted line number → head/tail math
  - lib/journal.sh:  _next_seq wc -l arithmetic
  - lib/lessons.sh:  _next_id/_count + 2 y/N prompts
  - lib/hl7-sanitize.sh:  cmd_count + clear-table y/N
  - lib/ssh-helper.sh:  4 local+remote wc -c integer compares
  - lib/nc-find.sh, lib/nc-table.sh, lib/nc-document.sh, larry-rollback.sh

Reproduces the exact error Bryan hit:
  bash: ...: arithmetic syntax error: invalid arithmetic operator (error token is "")

lib/cygwin-safe.sh added to MANIFEST so it auto-syncs on next launch.

Co-Authored-By: Clover (Claude Opus 4.7) <noreply@anthropic.com>
2026-05-27 19:17:48 -07:00
47e44c2289 v0.4.0: chain walk, OR/NOT filter groups, numeric/range ops, smat history
nc-parse.sh
  + chain <name> [--depth N] [--direction both|up|down]
    BFS over sources+destinations from a starting thread; returns the
    reachable cluster as TSV (depth, direction, thread).

nc-msgs.sh
  + Filter operator additions:
      >  >=  <  <=    numeric or lexical (works for HL7 YYYYMMDDHHMMSS timestamps)
      ><              range "LO..HI" inclusive
  + Filter group additions:
      --field         AND group (must match; existing behavior)
      --or-field      OR group  (at least one must match)
      --not-field     NOT group (none may match)
    All three groups combine; bug fixed where empty AND group bypassed
    OR/NOT checks in the count format.
  + SmatHistory walk:
      --include-history    also walks $HCISITEDIR/exec/processes/*/SmatHistory/
      --all                cheat-sheet alias for --include-history

Confirmed working against the real ancout test data:
  - chain IB_ADT_muxS finds all 7 downstream destinations
  - event=A08 OR event=A03 → 20 (19+1 of 22)
  - visit>400000000 → 22 (all numeric in range)
  - visit><400000000..400450000 → 22 (range inclusive)
  - --include-history → 22 active + 34 history rows = 56 total

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-26 10:58:16 -07:00
8ffdeb4f5d v0.3.4: field-name aliases, dot/dash syntax, ops (=, !=, ~, !~), new formats
Field path improvements (hl7-field.sh + every tool that uses it):
  - Accept both `.` and `-` as separators:
      PID.3 == PID-3
      PV1.3.4 == PV1-3.4 == PV1-3-4 == PV1.3-4
  - Field-name aliases (case-insensitive):
      mrn → PID.3
      account / account_number → PID.18
      name / patient_name → PID.5
      dob / birthdate → PID.7
      ssn → PID.19
      visit / encounter / csn → PV1.19
      attending → PV1.7
      event → MSH.9.2
      control_id / msgid → MSH.10
      ...and ~40 more covering MSH/PID/PV1/EVN/NK1/GT1/IN1/OBR/OBX/DG1/ORC
  - Aliases also accept component/subcomponent suffixes:
      name.2 → PID.5.2
      mrn.1 → PID.3.1

Filter operators (nc-msgs.sh --field):
  PATH=VALUE      exact equality
  PATH!=VALUE     not equal
  PATH~VALUE      contains (case-insensitive)
  PATH!~VALUE     does not contain (case-insensitive)
  PATH=NULL  /=   null / empty / absent
  PATH!=NULL      present (any non-empty rep)
  PATH=*          wildcard — any non-empty value
  Multiple --field flags AND; for OR, run two queries.

New output formats for nc-msgs.sh:
  text     (default) segments per line + metadata header per message
  oneline  one message per line, segments joined with a ⏎ marker
  fields   each non-empty field on its own line: "SEG.N: value"
  mp       alias for fields (matches v1 `mp` semantic)
  labeled  fields with friendly aliases: "MSH.9 (msg_type): ADT^A08"
  raw, json, count — unchanged

MANUAL.md updated with the full operator + format reference.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-26 10:35:46 -07:00
e08f030df5 v0.3.0: initial release of Larry-Anywhere
Portable AI agent for Cloverleaf integration work. Pure bash + curl + jq.
Zero dependency on v1 wrapper scripts or v2 cloverleaf-tools.pyz.

27 native Anthropic tools:

NetConfig parsing (read)
  nc_list_protocols, nc_list_processes, nc_protocol_block,
  nc_protocol_field, nc_protocol_nested, nc_protocol_summary,
  nc_destinations, nc_sources, nc_xlate_refs, nc_tclproc_refs

NetConfig modification (journal-backed writes with rollback)
  nc_insert_protocol, nc_add_route, larry_rollback_list

Workflows
  nc_find_inbound, nc_make_jump (3-thread jump pattern), nc_find
  (tbn/tbp/tbh/tbpr/where replacements), nc_document, nc_diff_interface,
  nc_regression

Messages
  hl7_field, nc_msgs (smat is SQLite!), hl7_diff (with --ignore MSH.7)

File system
  read_file, list_dir, grep_files, glob_files, write_file, bash_exec

Validated against a 22-site real Cloverleaf test install. Five worked
examples end-to-end: jump-thread generation, smat MRN search, system
documentation, interface+connected diff, HL7-aware regression diff.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-26 09:46:20 -07:00