@purveyors/cli 0.9.6 → 0.15.1

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 (63) hide show
  1. package/README.md +476 -159
  2. package/dist/commands/auth.d.ts.map +1 -1
  3. package/dist/commands/auth.js +4 -3
  4. package/dist/commands/auth.js.map +1 -1
  5. package/dist/commands/catalog.d.ts.map +1 -1
  6. package/dist/commands/catalog.js +55 -31
  7. package/dist/commands/catalog.js.map +1 -1
  8. package/dist/commands/config.d.ts.map +1 -1
  9. package/dist/commands/config.js +61 -12
  10. package/dist/commands/config.js.map +1 -1
  11. package/dist/commands/context.d.ts.map +1 -1
  12. package/dist/commands/context.js +34 -234
  13. package/dist/commands/context.js.map +1 -1
  14. package/dist/commands/manifest.d.ts +3 -0
  15. package/dist/commands/manifest.d.ts.map +1 -0
  16. package/dist/commands/manifest.js +32 -0
  17. package/dist/commands/manifest.js.map +1 -0
  18. package/dist/commands/roast.d.ts.map +1 -1
  19. package/dist/commands/roast.js +105 -2
  20. package/dist/commands/roast.js.map +1 -1
  21. package/dist/commands/sales.d.ts.map +1 -1
  22. package/dist/commands/sales.js +87 -40
  23. package/dist/commands/sales.js.map +1 -1
  24. package/dist/index.js +6 -105
  25. package/dist/index.js.map +1 -1
  26. package/dist/lib/config.d.ts.map +1 -1
  27. package/dist/lib/config.js +8 -2
  28. package/dist/lib/config.js.map +1 -1
  29. package/dist/lib/errors.d.ts +13 -1
  30. package/dist/lib/errors.d.ts.map +1 -1
  31. package/dist/lib/errors.js +153 -10
  32. package/dist/lib/errors.js.map +1 -1
  33. package/dist/lib/index.d.ts +1 -0
  34. package/dist/lib/index.d.ts.map +1 -1
  35. package/dist/lib/index.js +1 -0
  36. package/dist/lib/index.js.map +1 -1
  37. package/dist/lib/interactive/watch.d.ts +37 -3
  38. package/dist/lib/interactive/watch.d.ts.map +1 -1
  39. package/dist/lib/interactive/watch.js +237 -81
  40. package/dist/lib/interactive/watch.js.map +1 -1
  41. package/dist/lib/manifest.d.ts +107 -0
  42. package/dist/lib/manifest.d.ts.map +1 -0
  43. package/dist/lib/manifest.js +977 -0
  44. package/dist/lib/manifest.js.map +1 -0
  45. package/dist/lib/output.d.ts +10 -0
  46. package/dist/lib/output.d.ts.map +1 -1
  47. package/dist/lib/output.js +33 -18
  48. package/dist/lib/output.js.map +1 -1
  49. package/dist/lib/roast.d.ts +2 -0
  50. package/dist/lib/roast.d.ts.map +1 -1
  51. package/dist/lib/roast.js +5 -2
  52. package/dist/lib/roast.js.map +1 -1
  53. package/dist/lib/sales.d.ts +15 -2
  54. package/dist/lib/sales.d.ts.map +1 -1
  55. package/dist/lib/sales.js +77 -15
  56. package/dist/lib/sales.js.map +1 -1
  57. package/dist/program.d.ts +4 -0
  58. package/dist/program.d.ts.map +1 -0
  59. package/dist/program.js +135 -0
  60. package/dist/program.js.map +1 -0
  61. package/dist/types/index.d.ts +4 -0
  62. package/dist/types/index.d.ts.map +1 -1
  63. package/package.json +7 -1
@@ -0,0 +1,135 @@
1
+ import { Command } from 'commander';
2
+ import { readFileSync } from 'fs';
3
+ import { dirname, join } from 'path';
4
+ import { fileURLToPath } from 'url';
5
+ import { buildAuthCommand } from './commands/auth.js';
6
+ import { buildCatalogCommand } from './commands/catalog.js';
7
+ import { buildConfigCommand } from './commands/config.js';
8
+ import { buildContextCommand } from './commands/context.js';
9
+ import { buildInventoryCommand } from './commands/inventory.js';
10
+ import { buildManifestCommand } from './commands/manifest.js';
11
+ import { buildRoastCommand } from './commands/roast.js';
12
+ import { buildSalesCommand } from './commands/sales.js';
13
+ import { buildTastingCommand } from './commands/tasting.js';
14
+ const __filename = fileURLToPath(import.meta.url);
15
+ const __dirname = dirname(__filename);
16
+ function applyProcessBoundarySettings(command) {
17
+ command.configureOutput({
18
+ outputError: () => {
19
+ // Route Commander parse failures through the top-level fatal() contract
20
+ // instead of printing raw stderr before exitOverride throws.
21
+ },
22
+ });
23
+ command.exitOverride((error) => {
24
+ if (error.exitCode === 0) {
25
+ process.exit(0);
26
+ }
27
+ throw error;
28
+ });
29
+ for (const subcommand of command.commands) {
30
+ applyProcessBoundarySettings(subcommand);
31
+ }
32
+ }
33
+ export function getCliVersion() {
34
+ let version = '0.0.1';
35
+ try {
36
+ const pkg = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'), 'utf-8'));
37
+ version = pkg.version ?? version;
38
+ }
39
+ catch {
40
+ // Fallback to hardcoded version
41
+ }
42
+ return version;
43
+ }
44
+ export function createProgram(version = getCliVersion()) {
45
+ const program = new Command();
46
+ program
47
+ .name('purvey')
48
+ .description('The official CLI for purveyors.io. Coffee intelligence from your terminal')
49
+ .version(version, '-v, --version', 'Print version')
50
+ .option('--json', 'Output compact JSON explicitly (same as the default)')
51
+ .option('--pretty', 'Pretty-print JSON output with colors')
52
+ .option('--csv', 'Output results as CSV where supported')
53
+ .addHelpText('after', `
54
+ Authentication:
55
+ auth login Log in to purveyors.io (--headless for agents)
56
+ auth status Show current login status and role
57
+ auth logout Clear stored credentials
58
+
59
+ Catalog (viewer role required, authentication needed):
60
+ catalog search Search the coffee catalog with filters
61
+ catalog get Get details for a specific coffee by ID
62
+ catalog stats Aggregate statistics for the catalog
63
+ catalog similar Find similar coffees by catalog ID
64
+
65
+ Personal Data (member role required):
66
+ inventory list List your green coffee inventory
67
+ inventory get Get a single inventory item
68
+ inventory add Add a bean to your inventory
69
+ inventory update Update an inventory item
70
+ inventory delete Delete an inventory item
71
+ roast list List your roast profiles
72
+ roast get Get a single roast profile
73
+ roast create Create a new roast profile
74
+ roast update Update a roast profile
75
+ roast delete Delete a roast profile
76
+ roast import Import an Artisan .alog roast file
77
+ roast watch Watch a directory for new .alog files
78
+ sales list List your sales records
79
+ sales record Record a new sale
80
+ sales update Update a sale record
81
+ sales delete Delete a sale record
82
+ tasting get Get tasting notes for a coffee
83
+ tasting rate Rate a coffee bean with cupping scores
84
+
85
+ Local and reference commands (no pre-existing session required):
86
+ config list Show all config values
87
+ config get Get a config value
88
+ config set Set a config value
89
+ config reset Reset config to defaults
90
+ context Output the dense human-readable operator reference; use --json/--pretty only for manifest parity
91
+ manifest Output the preferred stable machine-readable CLI contract for agents/scripts
92
+
93
+ Global Options:
94
+ --json Output compact JSON explicitly
95
+ --pretty Pretty-print JSON output
96
+ --csv Output array results as CSV where supported
97
+ --help Show help for any command
98
+ --version Show version number
99
+
100
+ Examples:
101
+ $ purvey auth login --headless
102
+ $ purvey catalog search --origin "Ethiopia" --process "natural" --pretty
103
+ $ purvey catalog similar 1182 --threshold 0.85 --stocked-only --json | jq '.[0]'
104
+ $ purvey inventory list --stocked --pretty
105
+ $ purvey roast import my-roast.alog --coffee-id 7
106
+ $ purvey roast watch ~/artisan/ --auto-match
107
+ $ purvey tasting rate 42 --aroma 4 --body 3 --acidity 5 --sweetness 4 --aftertaste 4
108
+ $ purvey --help
109
+ $ purvey context
110
+ $ purvey manifest
111
+ $ purvey manifest --pretty
112
+ $ purvey context --json > cli-manifest.json
113
+
114
+ CLI docs: https://purveyors.io/docs/cli/overview
115
+ API docs: https://purveyors.io/docs/api/overview
116
+ Repository: https://github.com/reedwhetstone/purveyors-cli
117
+ npm package: https://www.npmjs.com/package/@purveyors/cli
118
+ Quick discovery: purvey --help
119
+ Human reference: purvey context
120
+ JSON manifest: purvey manifest
121
+ Module import: @purveyors/cli/manifest
122
+ `);
123
+ program.addCommand(buildAuthCommand());
124
+ program.addCommand(buildCatalogCommand());
125
+ program.addCommand(buildConfigCommand());
126
+ program.addCommand(buildContextCommand());
127
+ program.addCommand(buildInventoryCommand());
128
+ program.addCommand(buildManifestCommand());
129
+ program.addCommand(buildRoastCommand());
130
+ program.addCommand(buildSalesCommand());
131
+ program.addCommand(buildTastingCommand());
132
+ applyProcessBoundarySettings(program);
133
+ return program;
134
+ }
135
+ //# sourceMappingURL=program.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"program.js","sourceRoot":"","sources":["../src/program.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,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,CAAC,oBAAoB,EAAE,CAAC,CAAC;IAC3C,OAAO,CAAC,UAAU,CAAC,iBAAiB,EAAE,CAAC,CAAC;IACxC,OAAO,CAAC,UAAU,CAAC,iBAAiB,EAAE,CAAC,CAAC;IACxC,OAAO,CAAC,UAAU,CAAC,mBAAmB,EAAE,CAAC,CAAC;IAE1C,4BAA4B,CAAC,OAAO,CAAC,CAAC;IAEtC,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -26,4 +26,8 @@ export interface CliError {
26
26
  message: string;
27
27
  details?: unknown;
28
28
  }
29
+ export interface CliErrorEnvelope extends CliError {
30
+ error: true;
31
+ exitCode: number;
32
+ }
29
33
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE;QACJ,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;CACH;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE;QACJ,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;CACH;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,gBAAiB,SAAQ,QAAQ;IAChD,KAAK,EAAE,IAAI,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;CAClB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purveyors/cli",
3
- "version": "0.9.6",
3
+ "version": "0.15.1",
4
4
  "description": "The official CLI for purveyors.io — coffee intelligence from your terminal",
5
5
  "type": "module",
6
6
  "bin": {
@@ -14,6 +14,7 @@
14
14
  "./sales": "./dist/lib/sales.js",
15
15
  "./tasting": "./dist/lib/tasting.js",
16
16
  "./lib": "./dist/lib/index.js",
17
+ "./manifest": "./dist/lib/manifest.js",
17
18
  "./artisan": "./dist/lib/artisan/index.js",
18
19
  "./ai": "./dist/lib/ai.js"
19
20
  },
@@ -38,11 +39,16 @@
38
39
  "author": "Reed Whetstone",
39
40
  "license": "SEE LICENSE IN LICENSE.md",
40
41
  "scripts": {
42
+ "clean:dist": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
41
43
  "build": "tsc",
42
44
  "dev": "tsx src/index.ts",
43
45
  "lint": "prettier --check . && eslint .",
44
46
  "format": "prettier --write .",
45
47
  "check": "tsc --noEmit",
48
+ "verify:contract": "vitest run tests/manifest.test.ts tests/cli-output-modes.test.ts",
49
+ "verify:dist": "vitest run tests/dist-contract.test.ts",
50
+ "verify:prepublish": "pnpm clean:dist && pnpm build && pnpm verify:contract && pnpm verify:dist && node scripts/verify-prepublish-parity.mjs",
51
+ "prepack": "pnpm verify:prepublish",
46
52
  "test": "vitest run",
47
53
  "test:watch": "vitest"
48
54
  },