@agledger/cli 2.1.0 → 2.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.
Files changed (48) hide show
  1. package/README.md +64 -22
  2. package/SKILL.md +15 -14
  3. package/bin/run.js +2 -2
  4. package/dist/api-client.d.ts +7 -0
  5. package/dist/api-client.js +44 -8
  6. package/dist/base.d.ts +91 -22
  7. package/dist/base.js +76 -47
  8. package/dist/cli/command.d.ts +58 -0
  9. package/dist/cli/command.js +44 -0
  10. package/dist/cli/flags.d.ts +76 -0
  11. package/dist/cli/flags.js +12 -0
  12. package/dist/cli/help.d.ts +6 -0
  13. package/dist/cli/help.js +107 -0
  14. package/dist/cli/index.d.ts +3 -0
  15. package/dist/cli/index.js +3 -0
  16. package/dist/cli/main.d.ts +22 -0
  17. package/dist/cli/main.js +223 -0
  18. package/dist/cli/parse.d.ts +20 -0
  19. package/dist/cli/parse.js +138 -0
  20. package/dist/commands/api.d.ts +106 -18
  21. package/dist/commands/api.js +103 -12
  22. package/dist/commands/auth.d.ts +35 -6
  23. package/dist/commands/auth.js +1 -1
  24. package/dist/commands/config.d.ts +43 -8
  25. package/dist/commands/config.js +9 -8
  26. package/dist/commands/discover.d.ts +35 -6
  27. package/dist/commands/docs.d.ts +41 -7
  28. package/dist/commands/docs.js +4 -4
  29. package/dist/commands/help-json.d.ts +39 -7
  30. package/dist/commands/help-json.js +27 -45
  31. package/dist/commands/list-commands.d.ts +36 -7
  32. package/dist/commands/list-commands.js +2 -2
  33. package/dist/commands/login.d.ts +66 -10
  34. package/dist/commands/login.js +30 -9
  35. package/dist/commands/logout.d.ts +41 -7
  36. package/dist/commands/logout.js +8 -8
  37. package/dist/commands/verify.d.ts +97 -13
  38. package/dist/commands/verify.js +84 -27
  39. package/dist/oidc.d.ts +47 -0
  40. package/dist/oidc.js +162 -3
  41. package/dist/util/config.d.ts +16 -1
  42. package/dist/util/config.js +50 -14
  43. package/dist/util/field-parser.d.ts +3 -1
  44. package/dist/util/field-parser.js +11 -5
  45. package/package.json +9 -21
  46. package/dist/hooks/command-not-found.d.ts +0 -3
  47. package/dist/hooks/command-not-found.js +0 -63
  48. package/oclif.manifest.json +0 -872
@@ -4,7 +4,9 @@
4
4
  * Conventions (modeled on `gh api`, which has the same two flags):
5
5
  * - `key=value` → { key: "value" }
6
6
  * - `key=true|false|null` → typed literal (`-F` only)
7
- * - `key=42` / `key=3.14` → number (`-F` only)
7
+ * - `key=42` / `key=3.14` → number (`-F` only; only when the number
8
+ * prints back as typed, so `0123`, `-0` and 20-digit
9
+ * ids stay strings)
8
10
  * - `key=[...]` / `key={...}` → JSON-parsed array/object (`-F` only)
9
11
  * - `a.b.c=value` → nested: { a: { b: { c: "value" } } }
10
12
  * - `arr[]=a arr[]=b` → { arr: ["a", "b"] }
@@ -4,7 +4,9 @@
4
4
  * Conventions (modeled on `gh api`, which has the same two flags):
5
5
  * - `key=value` → { key: "value" }
6
6
  * - `key=true|false|null` → typed literal (`-F` only)
7
- * - `key=42` / `key=3.14` → number (`-F` only)
7
+ * - `key=42` / `key=3.14` → number (`-F` only; only when the number
8
+ * prints back as typed, so `0123`, `-0` and 20-digit
9
+ * ids stay strings)
8
10
  * - `key=[...]` / `key={...}` → JSON-parsed array/object (`-F` only)
9
11
  * - `a.b.c=value` → nested: { a: { b: { c: "value" } } }
10
12
  * - `arr[]=a arr[]=b` → { arr: ["a", "b"] }
@@ -46,10 +48,14 @@ function coerceValue(raw) {
46
48
  return null;
47
49
  if (raw === '')
48
50
  return '';
49
- if (/^-?\d+$/.test(raw))
50
- return Number(raw);
51
- if (/^-?\d*\.\d+$/.test(raw))
52
- return Number(raw);
51
+ // A number only when it reads back as the same text: 0123, -0 and an integer
52
+ // past 2^53 would otherwise reach the Server as a different value than typed.
53
+ if (/^-?\d*\.?\d+$/.test(raw)) {
54
+ const number = Number(raw);
55
+ if (Number.isFinite(number) && String(number) === raw)
56
+ return number;
57
+ return raw;
58
+ }
53
59
  // JSON literals only if clearly bracketed, which avoids misinterpreting strings.
54
60
  if ((raw.startsWith('{') && raw.endsWith('}')) || (raw.startsWith('[') && raw.endsWith(']'))) {
55
61
  try {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@agledger/cli",
3
- "version": "2.1.0",
4
- "description": "AGLedger CLI: the AGLedger API from the command line, for developers and agents. Self-hosted, signed, hash-chained.",
3
+ "version": "2.2.0",
4
+ "description": "AGLedger CLI: the AGLedger API from the command line, for developers and agents. Self-hosted, signed, hash-chained. Patent pending.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",
7
7
  "bin": {
@@ -12,47 +12,35 @@
12
12
  "!dist/**/*.map",
13
13
  "bin",
14
14
  "LICENSE",
15
- "SKILL.md",
16
- "oclif.manifest.json"
15
+ "SKILL.md"
17
16
  ],
18
17
  "scripts": {
19
18
  "prebuild": "rm -rf dist",
20
19
  "build": "tsc",
21
- "postbuild": "oclif manifest",
22
20
  "typecheck": "tsc --noEmit",
23
21
  "clean": "rm -rf dist *.tsbuildinfo",
24
- "lint": "tsc --noEmit",
22
+ "lint": "oxlint --type-aware .",
25
23
  "pretest": "npm run build",
26
24
  "test": "vitest run",
27
25
  "deps:lag": "node scripts/dep-lag.mjs",
28
26
  "deps:refresh": "npm update && node scripts/dep-lag.mjs",
29
- "prepack": "npm run build",
27
+ "prepack": "node -e \"fs.existsSync('tsconfig.json')&&child_process.execSync('npm run build',{stdio:'inherit'})\"",
30
28
  "lint:pkg": "publint --strict && attw --pack . --ignore-rules cjs-resolves-to-esm no-resolution",
31
29
  "prepublishOnly": "npm run build && npm run lint:pkg"
32
30
  },
33
31
  "dependencies": {
34
- "@agledger/verify-core": "^2.1.0",
35
- "@oclif/core": "^5.0.0"
32
+ "@agledger/verify-core": "^2.2.0"
36
33
  },
37
34
  "devDependencies": {
38
35
  "@arethetypeswrong/cli": "^0.18.3",
36
+ "@cyclonedx/cyclonedx-npm": "7.0.1",
39
37
  "@types/node": "^24.0.0",
40
- "oclif": "^6.0.8",
38
+ "oxlint": "1.94.0",
39
+ "oxlint-tsgolint": "7.0.2008",
41
40
  "publint": "^0.3.21",
42
41
  "typescript": "^7.0.2",
43
42
  "vitest": "^5.0.0"
44
43
  },
45
- "oclif": {
46
- "bin": "agledger",
47
- "commands": {
48
- "strategy": "pattern",
49
- "target": "./dist/commands"
50
- },
51
- "hooks": {
52
- "command_not_found": "./dist/hooks/command-not-found.js"
53
- },
54
- "topicSeparator": " "
55
- },
56
44
  "repository": {
57
45
  "type": "git",
58
46
  "url": "git+https://github.com/agledger-ai/cli.git"
@@ -1,3 +0,0 @@
1
- import type { Hook } from '@oclif/core';
2
- declare const hook: Hook<'command_not_found'>;
3
- export default hook;
@@ -1,63 +0,0 @@
1
- /**
2
- * Unknown commands printed only "command X not found", with no nearest match
3
- * and no pointer to how to find the real one. An agent that
4
- * guessed a verb had nothing to recover from, which matters here because the
5
- * CLI deliberately has few commands: almost everything goes through
6
- * `agledger api`, and a wrong guess is the expected first move.
7
- */
8
- /** Levenshtein distance, iterative two-row form. */
9
- function distance(a, b) {
10
- if (a === b)
11
- return 0;
12
- if (a.length === 0)
13
- return b.length;
14
- if (b.length === 0)
15
- return a.length;
16
- let previous = Array.from({ length: b.length + 1 }, (_, i) => i);
17
- for (let i = 0; i < a.length; i++) {
18
- const current = [i + 1];
19
- for (let j = 0; j < b.length; j++) {
20
- const substitute = previous[j] + (a[i] === b[j] ? 0 : 1);
21
- current.push(Math.min(current[j] + 1, previous[j + 1] + 1, substitute));
22
- }
23
- previous = current;
24
- }
25
- return previous[b.length];
26
- }
27
- /** Closest command id, when it is close enough to be worth suggesting. */
28
- function nearest(id, candidates) {
29
- let best;
30
- let bestScore = Infinity;
31
- for (const candidate of candidates) {
32
- const score = distance(id.toLowerCase(), candidate.toLowerCase());
33
- if (score < bestScore) {
34
- bestScore = score;
35
- best = candidate;
36
- }
37
- }
38
- // Scale with the length of what was typed so short ids don't match everything.
39
- return best !== undefined && bestScore <= Math.max(2, Math.floor(id.length / 2))
40
- ? best
41
- : undefined;
42
- }
43
- const hook = async function (opts) {
44
- const id = opts.id;
45
- const ids = opts.config.commandIDs;
46
- const suggestion = nearest(id, ids);
47
- const parts = [
48
- suggestion ? `Did you mean \`agledger ${suggestion}\`?` : undefined,
49
- 'Run `agledger list-commands` to see every command.',
50
- // The real surface area is the API passthrough, not the command list.
51
- 'Most operations go through `agledger api <METHOD> <PATH>`, which reaches every route.',
52
- ].filter(Boolean);
53
- process.stderr.write(JSON.stringify({
54
- error: true,
55
- code: 'COMMAND_NOT_FOUND',
56
- message: `Command "${id}" not found.`,
57
- ...(suggestion ? { didYouMean: suggestion } : {}),
58
- suggestion: parts.join(' '),
59
- }) + '\n');
60
- // 2 = usage error, matching the exit code oclif already used for this case.
61
- process.exit(2);
62
- };
63
- export default hook;