# GRAccess CLI Usage Command-line interface for Aveva System Platform Galaxy management via the GRAccess library. ## Global Options All commands that interact with a galaxy require: | Option | Short | Description | Required | |---|---|---|---| | `--galaxy` | `-g` | Galaxy name | Yes | | `--node` | `-n` | GR node name. Blank defaults to local node; `.` is normalized to the local machine name. | One-shot mode only | In session mode, `--node` is not needed because the daemon already holds the connection. Machine-facing commands also support: | Option | Description | |---|---| | `--json` | Legacy command-specific JSON. Existing shapes are preserved. | | `--llm-json` | Stable success/error envelope for LLM and tool callers. | | `--dry-run` | For mutating routed commands, validate arguments and confirmation without invoking mutating GRAccess calls. | `--llm-json` envelope shape: ```json { "success": true, "command": "object get", "galaxy": "ZB", "target": "TestMachine", "data": {}, "commandResult": null, "warnings": [], "unavailable": [], "error": null, "exitCode": 0 } ``` ## LLM And Tooling Commands ### `capabilities` Return the code-backed command registry. ```powershell graccess capabilities --json graccess capabilities --llm-json ``` The registry includes command names, arguments, mutation status, session routing support, confirmation target rules, and output schema names. ### `validate` Validate a single-command or batch plan file without connecting to GRAccess. ```powershell graccess validate --request plan.json --llm-json ``` ### `batch` Validate or execute a command plan. Execution stops on first failure. Every mutating step must include its own `confirm=true` and exact `confirm-target`. ```powershell graccess batch --file plan.json --mode validate --llm-json graccess batch --file plan.json --mode execute --llm-json ``` Plan example: ```json { "Galaxy": "ZB", "Node": ".", "Commands": [ { "Command": "object attribute value set", "Args": { "name": "TestMachine", "type": "template", "attribute": "Description", "value": "Updated", "data-type": "string", "confirm": true, "confirm-target": "TestMachine" } } ] } ``` ## Galaxy Commands ### `galaxy list` List available galaxies on a GR node. ``` graccess galaxy list [--node ] [--json] [--llm-json] ``` | Option | Short | Required | Description | |---|---|---|---| | `--node` | `-n` | No | GR node name to query. Blank defaults to local node; `.` is normalized to the local machine name. | | `--json` | | No | Output as JSON array | | `--llm-json` | | No | Output stable LLM envelope | This command always runs in one-shot mode (no galaxy login needed). It does not use or require an active session. Example output: ``` MyGalaxy1 MyGalaxy2 TestGalaxy ``` With `--json`: ```json [ "MyGalaxy1", "MyGalaxy2", "TestGalaxy" ] ``` --- ## Object Query Commands These commands route through an active session when one exists for the target galaxy. Without an active session, they connect to a galaxy, run a read-only GRAccess query, and disconnect. Name patterns use the GRAccess `namedLike` condition; use `%` as the wildcard. ### `object list` List templates, instances, or both. ``` graccess object list --galaxy --node [--type all|template|instance] [--pattern ] [--json] ``` | Option | Short | Default | Description | |---|---|---|---| | `--galaxy` | `-g` | (required) | Galaxy name | | `--node` | `-n` | local node | GR node name. `.` is normalized to the local machine name. | | `--type` | `-t` | `all` | Object type: `all`, `template`, or `instance` | | `--pattern` | `-p` | `%` | GRAccess name pattern. Use `%` as wildcard. | | `--json` | | `false` | Output as JSON | Example: ```powershell graccess object list --galaxy ZB --node . --type instance --pattern 'TestMachine_%' ``` ### `template list` List templates. ``` graccess template list --galaxy --node [--pattern ] [--json] ``` ### `instance list` List instances. ``` graccess instance list --galaxy --node [--pattern ] [--json] ``` Example: ```powershell graccess instance list --galaxy ZB --node . --pattern '%' ``` ### `object attributes` List attributes for a template or instance. ``` graccess object attributes --galaxy --node --name [--type all|template|instance] [--configurable] [--json] ``` | Option | Short | Default | Description | |---|---|---|---| | `--galaxy` | `-g` | (required) | Galaxy name | | `--node` | `-n` | local node | GR node name. `.` is normalized to the local machine name. | | `--name` | | (required) | Template or instance tagname | | `--type` | `-t` | `all` | Object type: `all`, `template`, or `instance` | | `--configurable` | | `false` | Query `ConfigurableAttributes` instead of `Attributes` | | `--json` | | `false` | Output as JSON | Some optional COM-backed attribute properties are not available for every object. In JSON output those values are emitted as `null`; text output includes the stable name, data type, and category columns. Example: ```powershell graccess object attributes --galaxy ZB --node . --name DEV --type instance --configurable ``` --- ## LLM Snapshot And IDE Commands ### `object snapshot` Return a bundled object snapshot for planning and verification. ```powershell graccess object snapshot --galaxy ZB --name TestMachine --type template --llm-json ``` Snapshot data includes object identity/status, all attributes, configurable attributes, extended attributes, relationships, lineage, children, contained objects, package-backed attribute values and script bodies where available, and unavailable field details. Use snapshots, direct lineage commands, and relationship queries together to parse inheritance and containment: ```powershell graccess object snapshot --galaxy ZB --name '$TestMachine' --type template --llm-json graccess object lineage --galaxy ZB --name '$TestMachine' --type template --llm-json graccess object children --galaxy ZB --name '$TestMachine' --type template --llm-json graccess object query-condition --galaxy ZB --type all --condition derivedOrInstantiatedFrom --value '$gMachine' --llm-json graccess object query-condition --galaxy ZB --type all --condition basedOn --value '$gMachine' --llm-json graccess object query-condition --galaxy ZB --type all --condition containedBy --value '$TestMachine' --llm-json graccess object query-condition --galaxy ZB --type all --condition hierarchicalNameLike --value '%TestMachine%' --llm-json ``` `object lineage` walks typed `ITemplate` / `IInstance` relationship properties first and falls back to the read-only package snapshot when GRAccess export is available. `object children` combines package-backed containment with direct GRAccess scans for objects whose `DerivedFrom`, `BasedOn`, `Container`, or `HierarchicalName` point at the target. When direct GRAccess does not expose a field, the CLI records a structured unavailable entry instead of guessing. Normal CLI usage does not query the Galaxy SQL database; SQL is allowed only for development verification/debugging outside the supported command path. ### Attribute values ```powershell graccess object attribute value get --galaxy ZB --name TestMachine --type template --attribute Description --llm-json graccess object attribute value set --galaxy ZB --name TestMachine --type template --attribute Description --value Updated --data-type string --confirm --confirm-target TestMachine --llm-json ``` Scalar `string`, `bool`, `int`, `float`, and `double` writes are supported first. Value reads try direct `IAttribute.Value` first, then use the read-only exported package fallback for scalar package values. Array and complex readback returns structured unavailable details unless parsed safely. ### Object scripts ```powershell graccess object scripts list --galaxy ZB --name TestMachine --type template --llm-json graccess object scripts get --galaxy ZB --name TestMachine --type template --script UpdateTestChangingInt --llm-json graccess object scripts get --galaxy ZB --name TestMachine --type template --script UpdateTestChangingInt.ExecuteText --llm-json graccess object scripts set --galaxy ZB --name TestMachine --type template --script UpdateTestChangingInt --file UpdateTestChangingInt.txt --confirm --confirm-target TestMachine --llm-json graccess object scripts settings set --galaxy ZB --name '$TestMachine' --type template --script UpdateTestChangingInt --trigger-period-ms 500 --lock-trigger-period --confirm --confirm-target '$TestMachine' --llm-json graccess object scripts create --galaxy ZB --name '$MyTemplate' --type template --script OnScan --file OnScan.txt --trigger-type Periodic --trigger-period-ms 1000 --confirm --confirm-target '$MyTemplate' --llm-json ``` Direct object script body access depends on the local GRAccess object model. Reads inspect the exported package fallback for script extension bodies and script text fields such as `ExecuteText`, `DeclarationsText`, `StartupText`, `ShutdownText`, `OnScanText`, `OffScanText`, and `Expression`. For writes, the CLI follows the GRAccess pattern used by `ScriptExtension` objects: script body and setting mutations prefer `IgObject.ConfigurableAttributes[...]`, then fall back to `Attributes[...]` only if the configurable collection does not expose the requested field. `object scripts set` writes the matching script body attribute; a bare script name maps to `.ExecuteText`. `object scripts settings set` writes common script settings such as `TriggerPeriod`, `TriggerType`, and `Expression`; `--lock-trigger-period` applies `MxLockedInMe` so derived instances receive the interval on deploy. `object scripts create` calls `AddExtensionPrimitive("ScriptExtension",