aws-cli-agent 0.6.0 → 0.6.2
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.
- package/CHANGELOG.md +19 -3
- package/README.md +38 -36
- package/dist/cli.js +1 -1
- package/dist/tools/aws-cli.d.ts +15 -0
- package/dist/tools/aws-cli.js +15 -2
- package/dist/tools/bash.js +109 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,25 @@ All notable changes to this project are documented here.
|
|
|
4
4
|
Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/);
|
|
5
5
|
versioning follows [SemVer](https://semver.org/).
|
|
6
6
|
|
|
7
|
+
## [0.6.2] - 2026-06-05
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
- **README.md** Minor changes in the README.md.
|
|
12
|
+
|
|
13
|
+
## [0.6.1] - 2026-05-31
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
- **AWS commands are highlighted in the bash script approval preview.** When the agent generates a script for execution, AWS CLI invocations now stand out from the rest of the script body with inverse-color "highlighter strips" so the mutating calls are easy to spot in a long script:
|
|
18
|
+
- Read-only AWS calls (`describe-*`, `list-*`, `get-*`, `s3 ls`, `sts get-caller-identity`, etc.) render as a **blue strip**.
|
|
19
|
+
- Mutating AWS calls (`delete-*`, `terminate-*`, `create-*`, `put-*`, `s3 rm`, `s3 cp`, etc.) render as a **yellow strip**.
|
|
20
|
+
- Everything else — shell control flow, comments, args, flags, pipelines — stays in the existing green script body color.
|
|
21
|
+
|
|
22
|
+
Detection is pattern-based, not a full shell parser: `aws <service> <verb>` is matched wherever it appears in a line (start of line, after a pipe, after `time` or `env VAR=val`, inside a `$(...)` substitution). Read-only vs. mutating classification uses the same `READ_ONLY_VERBS` / `READ_ONLY_FULL` lists that drive the per-command auto-approve decision — single source of truth, no drift between the two features. Adding a verb to either list affects both behaviors.
|
|
23
|
+
|
|
24
|
+
False positives (e.g. an `aws ec2 describe-instances` substring inside an `echo "..."` literal) get highlighted too. Accepted limitation: a real shell tokenizer would catch these, but the surrounding `echo` and quotes make them visually distinguishable in context.
|
|
25
|
+
|
|
7
26
|
## [0.6.0] - 2026-05-31
|
|
8
27
|
|
|
9
28
|
### Breaking
|
|
@@ -55,7 +74,6 @@ versioning follows [SemVer](https://semver.org/).
|
|
|
55
74
|
|
|
56
75
|
- **Ctrl-C inside an SSM session no longer prints "Cannot perform start session: read /dev/stdin: input/output error".** Previously, Ctrl-C delivered SIGINT to both the AWS CLI subprocess AND aca; aca's process tore down the shared stdin before the AWS CLI's own cleanup completed, producing the I/O-error message. The fix: `aca` installs a no-op SIGINT handler for the lifetime of any interactive AWS CLI subprocess, leaving the signal exclusively to the child. The AWS CLI now performs its normal clean shutdown and exits with code 0 or 130, which aca recognizes as a clean termination.
|
|
57
76
|
|
|
58
|
-
## [0.5.0] - 2026-05-19
|
|
59
77
|
### Added
|
|
60
78
|
|
|
61
79
|
- **Graceful error handling for AWS CLI failures.** AWS CLI exit codes
|
|
@@ -85,8 +103,6 @@ versioning follows [SemVer](https://semver.org/).
|
|
|
85
103
|
With verbose off, nothing aca generates reaches the terminal — only
|
|
86
104
|
the AWS CLI's verbatim output does, matching the README's promise.
|
|
87
105
|
|
|
88
|
-
## [0.4.0] - 2026-05-18
|
|
89
|
-
|
|
90
106
|
### Changed
|
|
91
107
|
|
|
92
108
|
- **Dependency upgrades.** Vercel AI SDK v4 → v6, zod v3 → v4, TypeScript
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# aws-cli-agent (
|
|
1
|
+
# aws-cli-agent (aca)
|
|
2
2
|
|
|
3
3
|
> Agentic AI assistant that turns natural-language requests into AWS CLI commands and runs them locally.
|
|
4
4
|
|
|
@@ -8,18 +8,20 @@ You describe what you want in plain English. The agent searches your local histo
|
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
10
|
# Interactive session to an instance the agent has to look up
|
|
11
|
-
aca
|
|
11
|
+
aca start ssm session to instance my-instance in my-account
|
|
12
12
|
|
|
13
|
-
#
|
|
14
|
-
aca
|
|
13
|
+
# List resources
|
|
14
|
+
aca list instance ids, names in my-account as text
|
|
15
15
|
|
|
16
|
-
# Cross-resource composition: instances, their
|
|
17
|
-
aca
|
|
16
|
+
# Cross-resource composition: instances, their profiles, and the attached policies
|
|
17
|
+
aca list ec2 instance ids, names and the iam policies in the instance profiles as json in my-account
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
-
The first example is interactive — the agent runs a read-only `describe-instances` to resolve the name, then prompts before opening the SSM session. The second produces a
|
|
20
|
+
The first example is interactive — the agent runs a read-only `describe-instances` to resolve the name, then prompts before opening the SSM session. The second produces a text list on stdout, pipeable to `less` or `grep`. The third is the kind of request where the agent will most likely build a bash script with `jq` plumbing rather than chain individual AWS CLI calls.
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+

|
|
23
|
+
|
|
24
|
+
## Warning - read before using
|
|
23
25
|
|
|
24
26
|
`aca` runs real AWS CLI commands against your real AWS accounts. Treat it accordingly.
|
|
25
27
|
|
|
@@ -31,15 +33,9 @@ The first example is interactive — the agent runs a read-only `describe-instan
|
|
|
31
33
|
- **Your prompts go to the model provider.** AWS CLI output is fed back to the model as part of subsequent steps. That means resource names, instance IDs, tag values, and any other data that appears in command output is transmitted to Anthropic / OpenAI / Google / Bedrock (depending on your provider choice). The provider does not retain this data beyond the request itself (and the cache TTL, ~5 minutes for cached prefixes), but **confirm this is compatible with the policies you have to respect** before pointing `aca` at sensitive accounts.
|
|
32
34
|
- **Provider terms apply.** When you use a provider, you agree to that provider's terms of service. For Bedrock, that's AWS's own terms (data stays in your AWS account boundary). For Anthropic / OpenAI / Google, that's their respective enterprise / API terms. Read them.
|
|
33
35
|
- **Audit log is your friend.** Every executed command — including its stdout, stderr, and exit code — lands in `audit.log` (JSONL). If you ever need to reconstruct what happened, it's all there. Don't disable `logging.auditLog` unless you have a specific reason.
|
|
34
|
-
- **API keys in the config file persist to disk.** As of 0.6.0, you can put your LLM provider API key in `<provider>.apiKey` for convenience. The env var still takes precedence when both are set. Putting a key on disk is a meaningful step down from keeping it in your shell environment: backup tools, accidental `git add .` from the wrong directory, screen-sharing, and shoulder-surfing all become realistic leak vectors.
|
|
36
|
+
- **API keys in the config file persist to disk.** As of 0.6.0, you can put your LLM provider API key in `<provider>.apiKey` for convenience. The env var still takes precedence when both are set. Putting a key on disk is a meaningful step down from keeping it in your shell environment: backup tools, accidental `git add .` from the wrong directory, screen-sharing, and shoulder-surfing all become realistic leak vectors. Use the env var path when possible; reserve the config-file path for casual local use.
|
|
35
37
|
- **No warranty.** **You use this agent at your own risk.** The authors are not responsible for unintended AWS API calls, deleted resources, exceeded budgets, or any other damage caused by using this tool. If you wouldn't run `aws` commands blindly from a script you found in someone's gist, don't run `aca` blindly either.
|
|
36
38
|
|
|
37
|
-
## Trademark & affiliation
|
|
38
|
-
|
|
39
|
-
`aws-cli-agent` (`aca`) is an independent project, not affiliated with or
|
|
40
|
-
endorsed by Amazon Web Services. "AWS" and "Amazon Web Services" are
|
|
41
|
-
trademarks of Amazon.com, Inc.
|
|
42
|
-
|
|
43
39
|
## Installation
|
|
44
40
|
|
|
45
41
|
```bash
|
|
@@ -67,7 +63,7 @@ export ANTHROPIC_API_KEY=sk-ant-...
|
|
|
67
63
|
# (Bedrock needs no API key — uses your AWS credential chain)
|
|
68
64
|
|
|
69
65
|
# 3. Try it
|
|
70
|
-
aca
|
|
66
|
+
aca list all s3 buckets in account my-staging
|
|
71
67
|
```
|
|
72
68
|
|
|
73
69
|
## Configuration
|
|
@@ -170,6 +166,26 @@ When the key is resolved from the config file instead of an env var, `aca` write
|
|
|
170
166
|
|
|
171
167
|
The config file is created with file mode `0600` (owner read/write only) when `aca config` runs. If you edit it manually with another tool, `aca` won't re-permission it on read — that's on you.
|
|
172
168
|
|
|
169
|
+
### Bedrock
|
|
170
|
+
|
|
171
|
+
When `provider = "bedrock"`, configure model, region, and (optionally) profile in the `bedrock` block:
|
|
172
|
+
|
|
173
|
+
```json
|
|
174
|
+
{
|
|
175
|
+
"provider": "bedrock",
|
|
176
|
+
"bedrock": {
|
|
177
|
+
"model": "us.anthropic.claude-sonnet-4-6",
|
|
178
|
+
"region": "us-east-1",
|
|
179
|
+
"profile": "shared-services"
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
- **Model IDs**: Bedrock uses fully-qualified inference-profile IDs. The `us.` / `eu.` / `apac.` prefix is required for most newer Anthropic models. Use `aws bedrock list-inference-profiles --region <region>` to discover what your account can invoke.
|
|
185
|
+
- **`bedrock.profile`** is independent from operational profiles. The agent calls Bedrock under `bedrock.profile`, but each AWS CLI command it issues uses its own `--profile` (resolved from the user's prompt / history). This is the right pattern when one account holds Bedrock entitlements and other accounts hold workloads.
|
|
186
|
+
- If `bedrock.region` is unset, falls back to `AWS_REGION` / `AWS_DEFAULT_REGION` env vars.
|
|
187
|
+
- Bedrock uses the AWS credential chain — there's no `apiKey` field.
|
|
188
|
+
|
|
173
189
|
### Logging
|
|
174
190
|
|
|
175
191
|
```json
|
|
@@ -198,26 +214,6 @@ If `defaultRegion` is set, `aca` appends `--region <value>` to every AWS CLI com
|
|
|
198
214
|
aca --region eu-west-1 "list ec2 instances in my-staging"
|
|
199
215
|
```
|
|
200
216
|
|
|
201
|
-
### Bedrock
|
|
202
|
-
|
|
203
|
-
When `provider = "bedrock"`, configure model, region, and (optionally) profile in the `bedrock` block:
|
|
204
|
-
|
|
205
|
-
```json
|
|
206
|
-
{
|
|
207
|
-
"provider": "bedrock",
|
|
208
|
-
"bedrock": {
|
|
209
|
-
"model": "us.anthropic.claude-sonnet-4-6",
|
|
210
|
-
"region": "us-east-1",
|
|
211
|
-
"profile": "shared-services"
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
- **Model IDs**: Bedrock uses fully-qualified inference-profile IDs. The `us.` / `eu.` / `apac.` prefix is required for most newer Anthropic models. Use `aws bedrock list-inference-profiles --region <region>` to discover what your account can invoke.
|
|
217
|
-
- **`bedrock.profile`** is independent from operational profiles. The agent calls Bedrock under `bedrock.profile`, but each AWS CLI command it issues uses its own `--profile` (resolved from the user's prompt / history). This is the right pattern when one account holds Bedrock entitlements and other accounts hold workloads.
|
|
218
|
-
- If `bedrock.region` is unset, falls back to `AWS_REGION` / `AWS_DEFAULT_REGION` env vars.
|
|
219
|
-
- Bedrock uses the AWS credential chain — there's no `apiKey` field.
|
|
220
|
-
|
|
221
217
|
### Prompt caching
|
|
222
218
|
|
|
223
219
|
`aca` sends the same system prompt on every step of every invocation — roughly 3,300 tokens of stable content. When `caching: true` (the default), this prefix is marked cacheable on providers that support it:
|
|
@@ -415,6 +411,12 @@ aca ... 2>/dev/null # silence the agent's chrom
|
|
|
415
411
|
|
|
416
412
|
Without this rule, the approval prompts and reasoning lines would land in the next process's stdin and corrupt downstream tools. With it, the agent is invisible to pipelines — exactly as if you'd run the `aws` command directly.
|
|
417
413
|
|
|
414
|
+
## Trademark & affiliation
|
|
415
|
+
|
|
416
|
+
`aws-cli-agent` (`aca`) is an independent project, not affiliated with or
|
|
417
|
+
endorsed by Amazon Web Services. "AWS" and "Amazon Web Services" are
|
|
418
|
+
trademarks of Amazon.com, Inc.
|
|
419
|
+
|
|
418
420
|
## License
|
|
419
421
|
|
|
420
422
|
MIT
|
package/dist/cli.js
CHANGED
|
@@ -9,7 +9,7 @@ import { History } from './history.js';
|
|
|
9
9
|
import { runAgent } from './agent.js';
|
|
10
10
|
import { FILES, PATHS, DEFAULT_SCRIPT_FOLDER } from './paths.js';
|
|
11
11
|
import { UserCancelledError } from './errors.js';
|
|
12
|
-
const VERSION = '0.6.
|
|
12
|
+
const VERSION = '0.6.2';
|
|
13
13
|
/**
|
|
14
14
|
* Apply CLI flags on top of the loaded config. Flags only override; they
|
|
15
15
|
* never widen or compose with each other implicitly.
|
package/dist/tools/aws-cli.d.ts
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
import type { Logger } from '../logger.js';
|
|
2
2
|
import type { Config } from '../config.js';
|
|
3
|
+
/**
|
|
4
|
+
* Read-only verb patterns. Used both to decide whether an AWS CLI call may
|
|
5
|
+
* auto-approve, and (since 0.7.0) to syntax-highlight bash scripts in the
|
|
6
|
+
* approval display — read-only verbs render in light blue, mutating in yellow.
|
|
7
|
+
*
|
|
8
|
+
* Exported so bash.ts can apply the same classification consistently. If
|
|
9
|
+
* you add a verb here, the highlighter picks it up automatically.
|
|
10
|
+
*/
|
|
11
|
+
export declare const READ_ONLY_VERBS: RegExp[];
|
|
12
|
+
/**
|
|
13
|
+
* Full-command patterns that are read-only but don't match a verb prefix
|
|
14
|
+
* (e.g. `s3 ls`, `sts get-caller-identity` where the resource type isn't a
|
|
15
|
+
* standard verb). Same usage as READ_ONLY_VERBS.
|
|
16
|
+
*/
|
|
17
|
+
export declare const READ_ONLY_FULL: RegExp[];
|
|
3
18
|
export declare function awsCliTool(opts: {
|
|
4
19
|
logger: Logger;
|
|
5
20
|
config: Config;
|
package/dist/tools/aws-cli.js
CHANGED
|
@@ -4,7 +4,15 @@ import { z } from 'zod';
|
|
|
4
4
|
import { confirm } from '@inquirer/prompts';
|
|
5
5
|
import chalk from 'chalk';
|
|
6
6
|
import { FATAL_AWS_EXIT_CODES, FatalAwsCliError, UserCancelledError, wrapPrompt } from '../errors.js';
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Read-only verb patterns. Used both to decide whether an AWS CLI call may
|
|
9
|
+
* auto-approve, and (since 0.7.0) to syntax-highlight bash scripts in the
|
|
10
|
+
* approval display — read-only verbs render in light blue, mutating in yellow.
|
|
11
|
+
*
|
|
12
|
+
* Exported so bash.ts can apply the same classification consistently. If
|
|
13
|
+
* you add a verb here, the highlighter picks it up automatically.
|
|
14
|
+
*/
|
|
15
|
+
export const READ_ONLY_VERBS = [
|
|
8
16
|
/^describe-/,
|
|
9
17
|
/^list-/,
|
|
10
18
|
/^get-/,
|
|
@@ -15,7 +23,12 @@ const READ_ONLY_VERBS = [
|
|
|
15
23
|
/^scan$/,
|
|
16
24
|
/^query$/,
|
|
17
25
|
];
|
|
18
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Full-command patterns that are read-only but don't match a verb prefix
|
|
28
|
+
* (e.g. `s3 ls`, `sts get-caller-identity` where the resource type isn't a
|
|
29
|
+
* standard verb). Same usage as READ_ONLY_VERBS.
|
|
30
|
+
*/
|
|
31
|
+
export const READ_ONLY_FULL = [
|
|
19
32
|
/^s3\s+ls(\s|$)/,
|
|
20
33
|
];
|
|
21
34
|
/**
|
package/dist/tools/bash.js
CHANGED
|
@@ -8,6 +8,7 @@ import { select } from '@inquirer/prompts';
|
|
|
8
8
|
import chalk from 'chalk';
|
|
9
9
|
import { DEFAULT_SCRIPT_FOLDER } from '../paths.js';
|
|
10
10
|
import { wrapPrompt } from '../errors.js';
|
|
11
|
+
import { READ_ONLY_FULL, READ_ONLY_VERBS } from './aws-cli.js';
|
|
11
12
|
function runProcess(cmd, args) {
|
|
12
13
|
return new Promise((resolve, reject) => {
|
|
13
14
|
const proc = spawn(cmd, args, { env: process.env });
|
|
@@ -32,6 +33,109 @@ function indent(s, prefix) {
|
|
|
32
33
|
.map((l) => prefix + l)
|
|
33
34
|
.join('\n');
|
|
34
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Match an `aws <service> <verb> ...` invocation anywhere within a line.
|
|
38
|
+
* The lookbehind is intentionally permissive — it matches `aws` at the
|
|
39
|
+
* start of the line, after a pipe (`| aws ...`), after `time aws ...`,
|
|
40
|
+
* after `env VAR=val aws ...`, etc. We don't try to be a full shell
|
|
41
|
+
* parser: that's overkill for a syntax-highlight feature. False positives
|
|
42
|
+
* (e.g. the literal string `"use aws ec2 ..."` inside an echo) get
|
|
43
|
+
* highlighted too, but that's preferable to false negatives — and the
|
|
44
|
+
* surrounding context usually makes them visually distinguishable.
|
|
45
|
+
*
|
|
46
|
+
* Captures three groups: service (group 1), verb (group 2), and the rest
|
|
47
|
+
* of the args up to end of line or a shell metacharacter that ends a
|
|
48
|
+
* command (group 3). We stop the arg span at `|`, `;`, `&`, `)`, and `>` /
|
|
49
|
+
* `<` redirections so we don't highlight half of the next pipeline stage.
|
|
50
|
+
*/
|
|
51
|
+
const AWS_CALL_RE = /\baws\s+([a-z][a-z0-9-]*)\s+([a-z][a-z0-9-]*)((?:\s+[^|;&)<>\n]*)?)/g;
|
|
52
|
+
/**
|
|
53
|
+
* Decide whether an `aws <service> <verb>` invocation is read-only. Uses
|
|
54
|
+
* the same classification as the per-command auto-approve path so the
|
|
55
|
+
* highlighting matches the runtime behavior: if the highlight is light
|
|
56
|
+
* blue, the command would auto-approve with `autoApprove.readOnly: true`
|
|
57
|
+
* if it were a standalone tool call.
|
|
58
|
+
*/
|
|
59
|
+
function isAwsCallReadOnly(service, verb, restOfArgs) {
|
|
60
|
+
// READ_ONLY_FULL patterns match against `service verb [args...]`.
|
|
61
|
+
// We pass the same shape to mirror runtime behavior.
|
|
62
|
+
const full = `${service} ${verb}${restOfArgs}`;
|
|
63
|
+
if (READ_ONLY_FULL.some((re) => re.test(full)))
|
|
64
|
+
return true;
|
|
65
|
+
if (READ_ONLY_VERBS.some((re) => re.test(verb)))
|
|
66
|
+
return true;
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Color the AWS CLI invocations inside a script. Read-only calls
|
|
71
|
+
* (describe-, list-, get-, etc.) render in light blue; mutating calls
|
|
72
|
+
* (delete-, terminate-, create-, etc.) render in yellow. Non-AWS portions
|
|
73
|
+
* of each line stay in the script body's default green wrap.
|
|
74
|
+
*
|
|
75
|
+
* Implementation note: chalk colors don't nest the way you'd hope. If we
|
|
76
|
+
* wrapped the whole script in `chalk.green()` and then embedded blue/yellow
|
|
77
|
+
* spans inside it, the inner spans' closing reset (\u001b[39m) would
|
|
78
|
+
* disable the green for the remainder of the string. To avoid that, we
|
|
79
|
+
* render each line piece by piece, explicitly re-applying green to the
|
|
80
|
+
* non-highlighted spans.
|
|
81
|
+
*/
|
|
82
|
+
function highlightAwsCalls(script) {
|
|
83
|
+
return script
|
|
84
|
+
.split('\n')
|
|
85
|
+
.map((line) => {
|
|
86
|
+
// Walk the line in pieces, emitting green for plain text and a
|
|
87
|
+
// distinct color for each AWS invocation. We use the regex's
|
|
88
|
+
// exec-loop position tracking to splice the line.
|
|
89
|
+
AWS_CALL_RE.lastIndex = 0;
|
|
90
|
+
let out = '';
|
|
91
|
+
let cursor = 0;
|
|
92
|
+
let m;
|
|
93
|
+
while ((m = AWS_CALL_RE.exec(line)) !== null) {
|
|
94
|
+
// The `aws` keyword itself isn't in the capture groups — find it
|
|
95
|
+
// by scanning backward from the service position.
|
|
96
|
+
const matchStart = m.index;
|
|
97
|
+
const service = m[1];
|
|
98
|
+
const verb = m[2];
|
|
99
|
+
const restOfArgs = m[3] ?? '';
|
|
100
|
+
const readOnly = isAwsCallReadOnly(service, verb, restOfArgs);
|
|
101
|
+
// Pre-`aws` text (e.g. `| `, `time `, or empty for start-of-line)
|
|
102
|
+
// stays green.
|
|
103
|
+
if (matchStart > cursor) {
|
|
104
|
+
out += chalk.green(line.slice(cursor, matchStart));
|
|
105
|
+
}
|
|
106
|
+
// The `aws <service> <verb>` triple gets the distinct color.
|
|
107
|
+
// restOfArgs (the flags and values) stays green — flags are the
|
|
108
|
+
// boring part, the verb is what the user needs to verify.
|
|
109
|
+
// Inverse (swaps fg/bg) produces a "highlighter strip" look: the
|
|
110
|
+
// background takes the color and the text shows through in the
|
|
111
|
+
// terminal's default foreground. Much more visible against the
|
|
112
|
+
// green script body than colored text alone would be — the eye
|
|
113
|
+
// snaps to a block of color faster than to a colored word.
|
|
114
|
+
// Green strip for read-only (matches the safe/discovery feel of
|
|
115
|
+
// the surrounding green script body); red strip for mutating
|
|
116
|
+
// (the classic "stop and look" signal).
|
|
117
|
+
const highlight = readOnly
|
|
118
|
+
? chalk.inverse.blueBright
|
|
119
|
+
: chalk.inverse.yellowBright;
|
|
120
|
+
out += highlight(`aws ${service} ${verb}`);
|
|
121
|
+
if (restOfArgs.length > 0) {
|
|
122
|
+
out += chalk.green(restOfArgs);
|
|
123
|
+
}
|
|
124
|
+
cursor = matchStart + m[0].length;
|
|
125
|
+
}
|
|
126
|
+
// Trailing text after the last match stays green.
|
|
127
|
+
if (cursor < line.length) {
|
|
128
|
+
out += chalk.green(line.slice(cursor));
|
|
129
|
+
}
|
|
130
|
+
// If no AWS call was found in the line, fall through with the whole
|
|
131
|
+
// line in green — same as the old uniform-green behavior.
|
|
132
|
+
if (out === '') {
|
|
133
|
+
out = chalk.green(line);
|
|
134
|
+
}
|
|
135
|
+
return out;
|
|
136
|
+
})
|
|
137
|
+
.join('\n');
|
|
138
|
+
}
|
|
35
139
|
/**
|
|
36
140
|
* Compute a filesystem-friendly filename for a saved script.
|
|
37
141
|
* Combines a timestamp (so files sort chronologically) with a short slug
|
|
@@ -64,7 +168,11 @@ export function bashScriptTool(opts) {
|
|
|
64
168
|
process.stderr.write('\n');
|
|
65
169
|
process.stderr.write(`${chalk.bold(' Reason: ')}${purpose}\n`);
|
|
66
170
|
process.stderr.write(`${chalk.bold(' Script:')}\n`);
|
|
67
|
-
|
|
171
|
+
// Render the script with AWS calls highlighted. Read-only calls
|
|
172
|
+
// (describe-, list-, get-, etc.) render in light blue; mutating calls
|
|
173
|
+
// (delete-, terminate-, create-, etc.) render in yellow. Everything
|
|
174
|
+
// else stays green. See highlightAwsCalls for the parser caveats.
|
|
175
|
+
process.stderr.write(highlightAwsCalls(indent(script, ' ')) + '\n');
|
|
68
176
|
// The save-to-disk option respects the configured folder, or falls back
|
|
69
177
|
// to the XDG default. Compute the would-be path *before* prompting so
|
|
70
178
|
// the user can see exactly where it'll land.
|