Skip to content

Commit a913c51

Browse files
authored
Merge pull request #1404 from appwrite/feat/cli-agent-skills
[codex] Mask CLI secrets by default
2 parents d85efde + 4670d35 commit a913c51

4 files changed

Lines changed: 296 additions & 125 deletions

File tree

templates/cli/cli.ts.twig

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,19 +83,31 @@ if (process.argv.includes('-v') || process.argv.includes('--version')) {
8383
.helpOption('-h, --help', 'Display help for command')
8484
.version(version, '-v, --version', 'Output the version number')
8585
.option('-V, --verbose', 'Show complete error log')
86-
.option('-j, --json', 'Output in JSON format')
87-
.option('-R, --raw', 'Output full raw JSON (no filtering)')
86+
.option('-j, --json', 'Output filtered JSON without empty values')
87+
.option('-R, --raw', 'Output full JSON response (secrets still redacted unless --show-secrets is set)')
88+
.option('--show-secrets', 'Display sensitive values like secrets and tokens in output')
8889
.hook('preAction', migrate)
8990
.option('-f,--force', 'Flag to confirm all warnings')
9091
.option('-a,--all', 'Flag to push all resources')
9192
.option('--id [id...]', 'Flag to pass a list of ids for a given action')
9293
.option('--report', 'Enable reporting in case of CLI errors')
94+
.hook('preAction', (_thisCommand, actionCommand) => {
95+
const commandConfig = actionCommand as typeof actionCommand & {
96+
outputFields?: string[];
97+
};
98+
cliConfig.displayFields = Array.isArray(commandConfig.outputFields)
99+
? commandConfig.outputFields
100+
: [];
101+
})
93102
.on('option:json', () => {
94103
cliConfig.json = true;
95104
})
96105
.on('option:raw', () => {
97106
cliConfig.raw = true;
98107
})
108+
.on('option:show-secrets', () => {
109+
cliConfig.showSecrets = true;
110+
})
99111
.on('option:verbose', () => {
100112
cliConfig.verbose = true;
101113
})

templates/cli/lib/commands/services/services.ts.twig

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ export const {{ service.name | caseCamel }} = new Command("{{ service.name | cas
7676
{% set commandName = method.name | caseKebab %}
7777
{% if commandName not in seenCommands %}
7878
{% set seenCommands = seenCommands|merge([commandName]) %}
79-
{{ service.name | caseCamel }}
79+
{% set commandVar = service.name | caseCamel ~ method.name | caseUcfirst ~ 'Command' %}
80+
const {{ commandVar }} = {{ service.name | caseCamel }}
8081
.command(`{{ commandName }}`)
8182
.description(`{{ method.description | replace({'`': '\\`'}) | raw }}`)
8283
{% for parameter in method.parameters.all %}
@@ -130,5 +131,9 @@ export const {{ service.name | caseCamel }} = new Command("{{ service.name | cas
130131
),
131132
);
132133

134+
{% if service.name == 'projects' and method.name == 'list' %}
135+
({{ commandVar }} as Command & { outputFields?: string[] }).outputFields = ["name", "$id", "region", "status"];
136+
{% endif %}
137+
133138
{% endif %}
134139
{% endfor %}

0 commit comments

Comments
 (0)