@agentcred-ai/cli 0.1.1 → 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
@@ -157,10 +173,14 @@ async function verifyCommand(args) {
157
173
  throw new Error("Invalid key: --key flag must be provided with a file path");
158
174
  }
159
175
  const keyData = await fs2.readFile(values.key, "utf-8");
160
- const publicJWK = JSON.parse(keyData);
176
+ const jwkData = JSON.parse(keyData);
177
+ const { d: _privateKey, ...publicJWK } = jwkData;
161
178
  const publicKey = await importJWK(publicJWK, "EdDSA");
162
179
  const result = await verifyOffline(envelope, publicKey);
163
- 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) {
164
184
  console.log(`\u2713 Verified: @${result.github?.username} (${result.agent}) at ${result.signedAt}`);
165
185
  } else {
166
186
  console.error(`\u2717 Verification failed: ${result.error}`);
@@ -168,7 +188,10 @@ async function verifyCommand(args) {
168
188
  }
169
189
  } else {
170
190
  const result = await verify(envelope);
171
- 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) {
172
195
  console.log(`\u2713 Verified: @${result.github?.username} (${result.agent}) at ${result.signedAt}`);
173
196
  } else {
174
197
  console.error(`\u2717 Verification failed: ${result.error}`);
@@ -178,6 +201,7 @@ async function verifyCommand(args) {
178
201
  }
179
202
 
180
203
  // src/commands/whoami.ts
204
+ import { parseArgs as parseArgs4 } from "util";
181
205
  import { FileSystemKeyStorage as FileSystemKeyStorage3 } from "@agentcred-ai/sdk";
182
206
  import { createHash } from "crypto";
183
207
  import * as fs3 from "fs/promises";
@@ -188,12 +212,20 @@ var HELP4 = `agentcred whoami \u2014 Show current identity
188
212
  Usage: agentcred whoami
189
213
 
190
214
  Options:
191
- --help, -h Show this help message`;
215
+ --json Output result as JSON (for programmatic use)
216
+ --help, -h Show this help message`;
192
217
  async function whoamiCommand(args) {
193
218
  if (args.includes("--help") || args.includes("-h")) {
194
219
  console.log(HELP4);
195
220
  return;
196
221
  }
222
+ const { values } = parseArgs4({
223
+ args,
224
+ options: {
225
+ json: { type: "boolean", default: false }
226
+ },
227
+ strict: false
228
+ });
197
229
  const storage = new FileSystemKeyStorage3();
198
230
  const usernames = await storage.list();
199
231
  if (usernames.length === 0) {
@@ -207,14 +239,18 @@ async function whoamiCommand(args) {
207
239
  const privateJWK = JSON.parse(keyData);
208
240
  const { d: _d, ...publicPortion } = privateJWK;
209
241
  const fingerprint = createHash("sha256").update(JSON.stringify(publicPortion)).digest("hex").slice(0, 16);
210
- 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
+ }
211
247
  } catch {
212
248
  throw new Error("No identity configured. Run 'agentcred init' first.");
213
249
  }
214
250
  }
215
251
 
216
252
  // src/index.ts
217
- var version = "0.0.1";
253
+ var version = "0.2.0";
218
254
  var HELP5 = `agentcred v${version} \u2014 Human accountability badge for AI agents
219
255
 
220
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.1",
3
+ "version": "0.2.0",
4
4
  "description": "CLI tool for AgentCred developer workflows",
5
5
  "type": "module",
6
6
  "bin": {
@@ -19,7 +19,7 @@
19
19
  ],
20
20
  "dependencies": {
21
21
  "jose": "^6.1.3",
22
- "@agentcred-ai/sdk": "0.1.1"
22
+ "@agentcred-ai/sdk": "0.1.2"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@types/node": "^25.1.0",