@agentcred-ai/cli 0.1.2 → 0.2.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.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- declare const version = "0.0.1";
1
+ declare const version: string;
2
2
  declare function main(): Promise<void>;
3
3
 
4
4
  export { main, version };
package/dist/index.js CHANGED
@@ -6,10 +6,15 @@ import { createIdentity, FileSystemKeyStorage } from "@agentcred-ai/sdk";
6
6
  var HELP = `agentcred init \u2014 Initialize identity with GitHub token
7
7
 
8
8
  Usage: agentcred init --token <github_token>
9
+ agentcred init (uses AGENTCRED_GITHUB_TOKEN env var)
9
10
 
10
11
  Options:
11
- --token <token> GitHub personal access token (required)
12
- --help, -h Show this help message`;
12
+ --token <token> GitHub personal access token
13
+ (or set AGENTCRED_GITHUB_TOKEN environment variable)
14
+ --json Output result as JSON (for programmatic use)
15
+ --help, -h Show this help message
16
+
17
+ Tip: Prefer AGENTCRED_GITHUB_TOKEN over --token to avoid leaking tokens in shell history.`;
13
18
  async function initCommand(args) {
14
19
  if (args.includes("--help") || args.includes("-h")) {
15
20
  console.log(HELP);
@@ -18,7 +23,8 @@ async function initCommand(args) {
18
23
  const { values } = parseArgs({
19
24
  args,
20
25
  options: {
21
- token: { type: "string" }
26
+ token: { type: "string" },
27
+ json: { type: "boolean", default: false }
22
28
  },
23
29
  strict: false
24
30
  });
@@ -31,7 +37,15 @@ async function initCommand(args) {
31
37
  }
32
38
  const storage = new FileSystemKeyStorage();
33
39
  const identity = await createIdentity(token, { storage });
34
- console.log(`\u2713 Identity created for @${identity.github.username}`);
40
+ if (values.json) {
41
+ console.log(JSON.stringify({
42
+ username: identity.github.username,
43
+ fingerprint: identity.fingerprint,
44
+ registeredAt: identity.registeredAt
45
+ }, null, 2));
46
+ } else {
47
+ console.log(`\u2713 Identity created for @${identity.github.username}`);
48
+ }
35
49
  }
36
50
 
37
51
  // src/commands/sign.ts
@@ -107,6 +121,7 @@ Usage: agentcred verify [file] [options]
107
121
  Options:
108
122
  --offline Verify offline using a local public key
109
123
  --key <path> Path to public key JWK file (used with --offline)
124
+ --json Output result as JSON (for programmatic use)
110
125
  --help, -h Show this help message
111
126
 
112
127
  If no file is given, reads from stdin.`;
@@ -126,7 +141,8 @@ async function verifyCommand(args) {
126
141
  args,
127
142
  options: {
128
143
  offline: { type: "boolean", default: false },
129
- key: { type: "string" }
144
+ key: { type: "string" },
145
+ json: { type: "boolean", default: false }
130
146
  },
131
147
  allowPositionals: true,
132
148
  strict: false
@@ -161,7 +177,10 @@ async function verifyCommand(args) {
161
177
  const { d: _privateKey, ...publicJWK } = jwkData;
162
178
  const publicKey = await importJWK(publicJWK, "EdDSA");
163
179
  const result = await verifyOffline(envelope, publicKey);
164
- if (result.verified) {
180
+ if (values.json) {
181
+ console.log(JSON.stringify(result, null, 2));
182
+ if (!result.verified) process.exit(1);
183
+ } else if (result.verified) {
165
184
  console.log(`\u2713 Verified: @${result.github?.username} (${result.agent}) at ${result.signedAt}`);
166
185
  } else {
167
186
  console.error(`\u2717 Verification failed: ${result.error}`);
@@ -169,7 +188,10 @@ async function verifyCommand(args) {
169
188
  }
170
189
  } else {
171
190
  const result = await verify(envelope);
172
- if (result.verified) {
191
+ if (values.json) {
192
+ console.log(JSON.stringify(result, null, 2));
193
+ if (!result.verified) process.exit(1);
194
+ } else if (result.verified) {
173
195
  console.log(`\u2713 Verified: @${result.github?.username} (${result.agent}) at ${result.signedAt}`);
174
196
  } else {
175
197
  console.error(`\u2717 Verification failed: ${result.error}`);
@@ -179,6 +201,7 @@ async function verifyCommand(args) {
179
201
  }
180
202
 
181
203
  // src/commands/whoami.ts
204
+ import { parseArgs as parseArgs4 } from "util";
182
205
  import { FileSystemKeyStorage as FileSystemKeyStorage3 } from "@agentcred-ai/sdk";
183
206
  import { createHash } from "crypto";
184
207
  import * as fs3 from "fs/promises";
@@ -189,12 +212,20 @@ var HELP4 = `agentcred whoami \u2014 Show current identity
189
212
  Usage: agentcred whoami
190
213
 
191
214
  Options:
192
- --help, -h Show this help message`;
215
+ --json Output result as JSON (for programmatic use)
216
+ --help, -h Show this help message`;
193
217
  async function whoamiCommand(args) {
194
218
  if (args.includes("--help") || args.includes("-h")) {
195
219
  console.log(HELP4);
196
220
  return;
197
221
  }
222
+ const { values } = parseArgs4({
223
+ args,
224
+ options: {
225
+ json: { type: "boolean", default: false }
226
+ },
227
+ strict: false
228
+ });
198
229
  const storage = new FileSystemKeyStorage3();
199
230
  const usernames = await storage.list();
200
231
  if (usernames.length === 0) {
@@ -208,14 +239,18 @@ async function whoamiCommand(args) {
208
239
  const privateJWK = JSON.parse(keyData);
209
240
  const { d: _d, ...publicPortion } = privateJWK;
210
241
  const fingerprint = createHash("sha256").update(JSON.stringify(publicPortion)).digest("hex").slice(0, 16);
211
- console.log(`You are @${username} (fingerprint: ${fingerprint})`);
242
+ if (values.json) {
243
+ console.log(JSON.stringify({ username, fingerprint, keyPath }, null, 2));
244
+ } else {
245
+ console.log(`You are @${username} (fingerprint: ${fingerprint})`);
246
+ }
212
247
  } catch {
213
248
  throw new Error("No identity configured. Run 'agentcred init' first.");
214
249
  }
215
250
  }
216
251
 
217
252
  // src/index.ts
218
- var version = "0.0.1";
253
+ var version = "0.2.0";
219
254
  var HELP5 = `agentcred v${version} \u2014 Human accountability badge for AI agents
220
255
 
221
256
  Usage: agentcred <command> [options]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentcred-ai/cli",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
4
4
  "description": "CLI tool for AgentCred developer workflows",
5
5
  "type": "module",
6
6
  "bin": {