@atbash/cli 0.3.10 → 0.3.11

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.
@@ -0,0 +1,7 @@
1
+ import { Command } from "commander";
2
+ /**
3
+ * Auto-install completion into ~/.zshrc on first run.
4
+ * Safe to call multiple times — skips if already installed.
5
+ */
6
+ export declare function installCompletionIfNeeded(): void;
7
+ export declare function registerCompletionCommand(program: Command): void;
@@ -0,0 +1,207 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.installCompletionIfNeeded = installCompletionIfNeeded;
40
+ exports.registerCompletionCommand = registerCompletionCommand;
41
+ const fs = __importStar(require("fs"));
42
+ const path = __importStar(require("path"));
43
+ const os = __importStar(require("os"));
44
+ const chalk_1 = __importDefault(require("chalk"));
45
+ const ZSH_COMPLETION = `#compdef atbash
46
+
47
+ _atbash() {
48
+ local -a commands
49
+ commands=(
50
+ 'judge:Submit a pending action for judgment'
51
+ 'whoami:Show your agent on-chain info'
52
+ 'policy:View your agent safety policy'
53
+ 'tier:Show tier info for your org'
54
+ 'tools:Query tool call logs'
55
+ 'held:View held actions'
56
+ 'history:Show recent tool call activity'
57
+ 'stats:Show chain-wide verdict statistics'
58
+ 'status:Check the status of a judgment by ID'
59
+ 'keygen:Generate a new agent keypair'
60
+ 'set:Save a configuration value'
61
+ 'unset:Remove a single configuration value'
62
+ 'wipe:Clear all saved configuration'
63
+ 'config:Show current configuration'
64
+ 'completion:Output shell completion script'
65
+ )
66
+
67
+ local -a judge_opts
68
+ judge_opts=(
69
+ '(-c --context)'{-c,--context}'[Operational context]:context:'
70
+ '(-k --agent-key)'{-k,--agent-key}'[Agent private key]:key:'
71
+ '--provider[Inference provider]:provider:(openai google microsoft custom)'
72
+ '--model[Model override]:model:'
73
+ '--org[Org name]:org:'
74
+ '--endpoint[Judge API base URL]:url:'
75
+ '--timeout[Max wait for verdict (ms)]:ms:'
76
+ '--json[Output result as JSON]'
77
+ )
78
+
79
+ local -a set_args
80
+ set_args=(
81
+ 'agent-key'
82
+ 'org-name'
83
+ 'endpoint'
84
+ 'rid'
85
+ 'provider'
86
+ 'model'
87
+ )
88
+
89
+ local -a unset_args
90
+ unset_args=(
91
+ 'agent-key'
92
+ 'org-name'
93
+ 'endpoint'
94
+ 'rid'
95
+ 'provider'
96
+ 'model'
97
+ )
98
+
99
+ _arguments -C \\
100
+ '(-v --version)'{-v,--version}'[Show version]' \\
101
+ '(-h --help)'{-h,--help}'[Show help]' \\
102
+ '1:command:->cmd' \\
103
+ '*::arg:->args'
104
+
105
+ case $state in
106
+ cmd)
107
+ _describe 'command' commands
108
+ ;;
109
+ args)
110
+ case $words[1] in
111
+ judge)
112
+ _arguments $judge_opts '1:action:'
113
+ ;;
114
+ set)
115
+ _arguments '1:key:(agent-key org-name endpoint rid provider model)' '2:value:'
116
+ ;;
117
+ unset)
118
+ _arguments '1:key:(agent-key org-name endpoint rid provider model)'
119
+ ;;
120
+ tier|held|tools|history)
121
+ _arguments '--org[Org name]:org:'
122
+ ;;
123
+ status)
124
+ _arguments '1:judgment-id:' '(-k --agent-key)'{-k,--agent-key}'[Agent key]:key:'
125
+ ;;
126
+ esac
127
+ ;;
128
+ esac
129
+ }
130
+
131
+ _atbash
132
+ `;
133
+ const BASH_COMPLETION = `_atbash() {
134
+ local cur prev commands
135
+ COMPREPLY=()
136
+ cur="\${COMP_WORDS[COMP_CWORD]}"
137
+ prev="\${COMP_WORDS[COMP_CWORD-1]}"
138
+ commands="judge whoami policy tier tools held history stats status keygen set unset wipe config completion"
139
+
140
+ case "\${prev}" in
141
+ atbash)
142
+ COMPREPLY=( $(compgen -W "\${commands}" -- "\${cur}") )
143
+ return 0
144
+ ;;
145
+ set|unset)
146
+ COMPREPLY=( $(compgen -W "agent-key org-name endpoint rid provider model" -- "\${cur}") )
147
+ return 0
148
+ ;;
149
+ --provider)
150
+ COMPREPLY=( $(compgen -W "openai google microsoft custom" -- "\${cur}") )
151
+ return 0
152
+ ;;
153
+ esac
154
+ }
155
+
156
+ complete -F _atbash atbash
157
+ `;
158
+ const COMPLETION_DIR = path.join(os.homedir(), ".config", "atbash");
159
+ const COMPLETION_FILE = path.join(COMPLETION_DIR, "completion.zsh");
160
+ const MARKER = '# atbash shell completion';
161
+ /**
162
+ * Auto-install completion into ~/.zshrc on first run.
163
+ * Safe to call multiple times — skips if already installed.
164
+ */
165
+ function installCompletionIfNeeded() {
166
+ try {
167
+ const shell = process.env.SHELL || "";
168
+ if (!shell.includes("zsh"))
169
+ return; // only zsh for now
170
+ const zshrc = path.join(os.homedir(), ".zshrc");
171
+ // Check if already installed
172
+ if (fs.existsSync(zshrc)) {
173
+ const content = fs.readFileSync(zshrc, "utf-8");
174
+ if (content.includes(MARKER))
175
+ return; // already there
176
+ }
177
+ // Write completion script to ~/.config/atbash/completion.zsh
178
+ fs.mkdirSync(COMPLETION_DIR, { recursive: true });
179
+ fs.writeFileSync(COMPLETION_FILE, ZSH_COMPLETION);
180
+ // Append source line to .zshrc
181
+ const line = `\n${MARKER}\nsource "${COMPLETION_FILE}"\n`;
182
+ fs.appendFileSync(zshrc, line);
183
+ console.log(chalk_1.default.dim(" Tab completion installed. Restart your terminal or run: source ~/.zshrc"));
184
+ }
185
+ catch {
186
+ // Never crash on completion install failure
187
+ }
188
+ }
189
+ function registerCompletionCommand(program) {
190
+ program
191
+ .command("completion")
192
+ .description("Output shell completion script")
193
+ .option("--shell <shell>", "Shell type: zsh or bash", "zsh")
194
+ .action((opts) => {
195
+ const shell = opts.shell.toLowerCase();
196
+ if (shell === "bash") {
197
+ console.log(BASH_COMPLETION);
198
+ }
199
+ else {
200
+ console.log(ZSH_COMPLETION);
201
+ }
202
+ console.error(shell === "zsh"
203
+ ? '# Add to ~/.zshrc:\n# eval "$(atbash completion)"'
204
+ : '# Add to ~/.bashrc:\n# eval "$(atbash completion --shell bash)"');
205
+ });
206
+ }
207
+ //# sourceMappingURL=completion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"completion.js","sourceRoot":"","sources":["../../src/commands/completion.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiIA,8DA2BC;AAED,8DAkBC;AA/KD,uCAAyB;AACzB,2CAA6B;AAC7B,uCAAyB;AACzB,kDAA0B;AAE1B,MAAM,cAAc,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,4CAA4C;IAC9C,CAAC;AACH,CAAC;AAED,SAAgB,yBAAyB,CAAC,OAAgB;IACxD,OAAO;SACJ,OAAO,CAAC,YAAY,CAAC;SACrB,WAAW,CAAC,gCAAgC,CAAC;SAC7C,MAAM,CAAC,iBAAiB,EAAE,yBAAyB,EAAE,KAAK,CAAC;SAC3D,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;QACf,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;QACvC,IAAI,KAAK,KAAK,MAAM,EAAE,CAAC;YACrB,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;QAC/B,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;QAC9B,CAAC;QACD,OAAO,CAAC,KAAK,CACX,KAAK,KAAK,KAAK;YACb,CAAC,CAAC,qDAAqD;YACvD,CAAC,CAAC,mEAAmE,CACxE,CAAC;IACJ,CAAC,CAAC,CAAC;AACP,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atbash/cli",
3
- "version": "0.3.10",
3
+ "version": "0.3.11",
4
4
  "description": "Atbash CLI — control boundary before the last irreversible step in an agent workflow",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "homepage": "https://atbash.ai",
@@ -19,7 +19,7 @@
19
19
  "release": "npm version patch --no-git-tag-version && npm run build && npx npm@10 publish --access public"
20
20
  },
21
21
  "dependencies": {
22
- "@atbash/sdk": "^0.3.16",
22
+ "@atbash/sdk": "^0.3.17",
23
23
  "chalk": "^4.1.2",
24
24
  "commander": "^12.0.0",
25
25
  "ora": "^5.4.1"