@action-intelligence/cli 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +222 -0
  2. package/action.mjs +228 -0
  3. package/package.json +23 -0
package/README.md ADDED
@@ -0,0 +1,222 @@
1
+ # Action CLI
2
+
3
+ The Action CLI is the Git-friendly, headless authoring surface for workflows. It talks only to
4
+ the public `/v1` API: project files never reach into Action's database, Pierre, Nango, or runtime
5
+ providers directly.
6
+
7
+ The server can gate the public workflow API per environment. When it is disabled, CLI remote
8
+ commands fail without changing the local project.
9
+
10
+ ## Install
11
+
12
+ Node.js 20 or newer is required for the public package:
13
+
14
+ ```sh
15
+ npm install --global @action-intelligence/cli
16
+ action --version
17
+ action auth login
18
+ ```
19
+
20
+ For a one-off invocation, use `npx @action-intelligence/cli`. The same package supports macOS, Linux, and
21
+ Windows. Human sessions use macOS Keychain, Linux Secret Service, or Windows Credential Manager.
22
+
23
+ ## Run from this repository
24
+
25
+ The repository pins Bun in the root `package.json`.
26
+
27
+ ```sh
28
+ bun install --frozen-lockfile
29
+ bun run --cwd apps/action-cli typecheck
30
+ bun run --cwd apps/action-cli test
31
+ bun run --cwd apps/action-cli build
32
+ node apps/action-cli/dist/index.js --help
33
+ ```
34
+
35
+ The installed package exposes the executable as `action`.
36
+
37
+ ## Authentication and context
38
+
39
+ For an interactive session, use:
40
+
41
+ ```sh
42
+ action auth login
43
+ ```
44
+
45
+ The CLI discovers Action's public AuthKit configuration, opens the WorkOS device flow, and resolves
46
+ the signed-in user to an eligible Action organization. Existing Action members and active Directory
47
+ Sync users can both sign in; a directory-only user is provisioned on first login. If the identity is
48
+ eligible for multiple organizations, login prompts for one. `--organization <id-or-key>` makes that
49
+ choice explicit.
50
+
51
+ Refreshable credentials are stored in the operating system credential store, never in profile or
52
+ project files. macOS Keychain, Linux Secret Service, and Windows Credential Manager are supported.
53
+ The non-secret profile retains the discovered AuthKit client ID and issuer plus the selected Action organization. The
54
+ `ACTION_AUTHKIT_CLIENT_ID` and `ACTION_AUTHKIT_ISSUER` overrides remain available for local or
55
+ self-hosted development, but normal users do not need them.
56
+
57
+ Automation can provide one of these environment variables:
58
+
59
+ - `ACTION_TOKEN`: a short-lived WorkOS M2M or other accepted bearer token.
60
+ - `ACTION_API_KEY`: an Action organization API key.
61
+
62
+ `ACTION_TOKEN` takes precedence when both are present. Put either value in a CI secret manager;
63
+ do not write it to `action.json`, `.action/lock.json`, or the non-secret profile file.
64
+
65
+ Profiles retain the API origin, WorkOS issuer/client ID, selected organization, and selected space.
66
+ Use `action context list`, `action context show`, and `action context use` to inspect or change the
67
+ remote context. `--profile`, `--api-url`, and `--space` provide per-command overrides. Stored human
68
+ sessions are origin-bound: an `--api-url` override to a different origin requires an explicit
69
+ `ACTION_TOKEN` or `ACTION_API_KEY`. Login, refresh-token rotation, and logout are serialized per
70
+ profile so concurrent CLI processes cannot overwrite a newer session.
71
+
72
+ ## Workflow project
73
+
74
+ `action workflows init` creates the repository representation:
75
+
76
+ ```text
77
+ action.json
78
+ workflows/
79
+ my-workflow/
80
+ workflow.json
81
+ index.mjs
82
+ .action/
83
+ lock.json
84
+ ```
85
+
86
+ - `action.json` identifies the schema version.
87
+ - `workflow.json` contains stable workflow metadata and input/output schemas.
88
+ - `index.mjs` contains ECMAScript source. Extra or symbolic-link source files are rejected.
89
+ - `.action/lock.json` records the origin, space, workflow IDs, revision bases, content digests, the
90
+ last successfully validated revision, and non-secret retry state for an interrupted publication.
91
+ It contains no credentials and is intended to travel with the project so collaborators share the
92
+ same optimistic-concurrency base.
93
+
94
+ Tracked JSON is canonicalized, source uses LF line endings with a final newline, and unchanged pulls
95
+ are byte-stable.
96
+
97
+ ## Authoring loop
98
+
99
+ ```sh
100
+ action workflows pull
101
+ action workflows status
102
+ action workflows diff
103
+ action workflows validate
104
+ action workflows push
105
+ ```
106
+
107
+ The default pull retrieves the latest authoring revision, including drafts. A published-only pull is
108
+ for inspection and does not move the normal authoring base. Pull refuses to overwrite local changes
109
+ unless the caller explicitly selects an overwrite strategy.
110
+
111
+ Historical published exports contain the exact versioned source and input/output schemas. Because
112
+ display names and descriptions are workflow-level mutable labels rather than revision data, those
113
+ exports use the stable workflow key as the name and omit the current description instead of mixing
114
+ current labels into historical code.
115
+
116
+ Push creates or updates draft revisions only. It never publishes, and removing a local workflow
117
+ directory never archives its remote workflow. Multi-workflow pushes report each result; successful
118
+ drafts remain recorded in the lockfile if another workflow conflicts.
119
+
120
+ Production effects are explicit and revision-specific:
121
+
122
+ ```sh
123
+ action workflows publish <workflow-key> --revision <revision-id>
124
+ action workflows archive <workflow-key>
125
+ ```
126
+
127
+ Use `action workflows list` and `action workflows revisions <workflow-key>` to inspect remote state.
128
+ Application actions, required scopes, and connected accounts can be discovered without a project
129
+ checkout. Supplying an application filter requests its full action schemas:
130
+
131
+ ```sh
132
+ action workflows capabilities
133
+ action workflows capabilities linear --json
134
+ ```
135
+
136
+ Draft tests and production runs require exactly one of `--input` or `--input-file`. A draft test
137
+ starts a real run rather than a simulated dry run, so connector actions may change external
138
+ systems. Prefer a file or stdin for inputs containing secrets so they do not appear in process
139
+ arguments:
140
+
141
+ ```sh
142
+ action workflows test my-workflow --input-file input.json --wait
143
+ printf '%s' '{"customerId":"customer_123"}' | action workflows test my-workflow --input-file -
144
+ action workflows run my-workflow --input-file input.json
145
+ printf '%s' '{"ticketId":"T-123"}' | action workflows run my-workflow --input-file - --wait
146
+ ```
147
+
148
+ `--input '<json>'` remains available for non-sensitive inputs.
149
+
150
+ ## Published workflow runs
151
+
152
+ Run the currently published revision with JSON input and optionally wait for a terminal state:
153
+
154
+ ```sh
155
+ action workflows run <workflow-key> --input '{"ticketId":"T-123"}'
156
+ action workflows run <workflow-key> --input-file run-input.json --wait
157
+ ```
158
+
159
+ Inspect or control a production run through its stable run ID:
160
+
161
+ ```sh
162
+ action workflows runs list --workflow <workflow-key> --status running
163
+ action workflows runs get <run-id>
164
+ action workflows runs watch <run-id>
165
+ action workflows runs watch <run-id> --cursor <opaque-cursor> --jsonl
166
+ action workflows runs cancel <run-id>
167
+ ```
168
+
169
+ Watch cursors are opaque and resumable. Ctrl-C stops only the local watch; it does not cancel the
170
+ remote run. Use the explicit cancel command for that.
171
+
172
+ `--jsonl` emits each event as `{"type":"event","event":{...}}`, followed by one terminal
173
+ `{"type":"summary","eventCount":...,"nextCursor":...,"run":...,"stopped":...}` record. Consumers
174
+ must branch on `type`. The streaming `--jsonl` mode cannot be combined with the global `--json`
175
+ option.
176
+
177
+ ## Automation output
178
+
179
+ Every remote command supports `--json`. JSON mode writes a single machine-readable result to stdout
180
+ and keeps progress noise out of the stream. `--non-interactive` disables prompts; a destructive
181
+ operation must also receive its explicit confirmation option.
182
+
183
+ Stable process exit codes are:
184
+
185
+ | Code | Meaning |
186
+ | ---: | ----------------------------------- |
187
+ | 0 | Success |
188
+ | 1 | Internal CLI failure |
189
+ | 2 | Invalid command or arguments |
190
+ | 3 | Authentication required or rejected |
191
+ | 4 | Resource not found |
192
+ | 5 | Revision or local/remote conflict |
193
+ | 6 | Local or server validation failure |
194
+ | 7 | Other remote API failure |
195
+ | 8 | Partial multi-workflow result |
196
+
197
+ API errors are normalized and redact credential-bearing headers and query parameters before output.
198
+
199
+ ## Build distributable artifacts
200
+
201
+ `bun run --cwd apps/action-cli release:package` assembles the dependency-free npm payload in
202
+ `dist/npm`. `bun run --cwd apps/action-cli release:binaries` cross-compiles standalone executables
203
+ for macOS, Linux, and Windows on x64 and ARM64. Once binary artifacts have been assembled beside one
204
+ another, produce their deterministic integrity manifest with:
205
+
206
+ ```sh
207
+ bun run --cwd apps/action-cli release:checksums -- dist/release/action-*
208
+ ```
209
+
210
+ The command writes a conventional, sorted `SHA256SUMS` file beside the artifacts. A `cli-vX.Y.Z`
211
+ tag whose commit is on `main` validates the package on macOS, Linux, and Windows, publishes the
212
+ public npm package through short-lived OIDC credentials, and retains checksummed standalone build
213
+ artifacts for release validation. npm is the supported public installation channel.
214
+
215
+ ## Extension model
216
+
217
+ - Add API shapes to OpenAPI and regenerate `@action/workflows-client`; do not hand-maintain a second
218
+ transport client.
219
+ - Keep command routing, remote API adaptation, local project state, authentication, and rendering in
220
+ separate modules.
221
+ - Add new product areas as sibling command namespaces instead of importing workflow internals.
222
+ - Preserve canonical project serialization and stable JSON output as compatibility contracts.