caique 0.5.0 → 0.5.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.
package/README.md CHANGED
@@ -268,7 +268,7 @@ Graded by the incumbent's own test suite:
268
268
  | `clack` | 14 / 17 |
269
269
  | `inquirer-core` | 41 / 41 |
270
270
 
271
- Weight, installed and tree-inclusive: **122,447 bytes** against **182,472** for the incumbents it replaces — a ratio of **0.6710** (@inquirer/core measured but left out of the ceiling, so it is understated).
271
+ Weight, installed and tree-inclusive: **123,321 bytes** against **182,472** for the incumbents it replaces — a ratio of **0.6758** (@inquirer/core measured but left out of the ceiling, so it is understated).
272
272
  ## Where it sits
273
273
 
274
274
  Plugins register under the `widgets` key, against the one schema the whole family shares.
package/dist/check.js CHANGED
@@ -1,9 +1,37 @@
1
+ import { readFileSync } from 'node:fs';
1
2
  import { resolve } from 'node:path';
2
3
  import { pathToFileURL } from 'node:url';
3
4
  import { PluginError, register, reset, validate } from './plugin.js';
4
5
  export const EXIT_OK = 0;
5
6
  export const EXIT_RUNTIME = 1;
6
7
  export const EXIT_USAGE = 2;
8
+ const USAGE = 'usage: caique check <plugin-file>\n';
9
+ const HELP = `${USAGE}
10
+ Load a plugin file, validate it against the family schema, register it, and report what
11
+ caique does with it. Exit 0 when it contributes, 1 on a refusal (with a code and a fix), 2 on
12
+ a usage error.
13
+
14
+ -h, --help show this help
15
+ -V, --version print the version
16
+ `;
17
+ function version() {
18
+ return JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')).version;
19
+ }
20
+ function target(arg, write) {
21
+ if (arg === '--help' || arg === '-h') {
22
+ write(HELP);
23
+ return EXIT_OK;
24
+ }
25
+ if (arg === '--version' || arg === '-V') {
26
+ write(`${version()}\n`);
27
+ return EXIT_OK;
28
+ }
29
+ if (arg === undefined || arg.startsWith('-')) {
30
+ write(arg === undefined ? USAGE : `unknown option ${arg}\n${USAGE}`);
31
+ return EXIT_USAGE;
32
+ }
33
+ return arg;
34
+ }
7
35
  function refuse(code, message, fix, write) {
8
36
  write(`${code}: ${message}\n fix: ${fix}\n`);
9
37
  return EXIT_RUNTIME;
@@ -20,11 +48,9 @@ export async function check(argv, write) {
20
48
  }
21
49
  }
22
50
  async function inspect(argv, write) {
23
- const file = argv[0];
24
- if (file === undefined) {
25
- write('usage: caique check <plugin-file>\n');
26
- return EXIT_USAGE;
27
- }
51
+ const file = target(argv[0], write);
52
+ if (typeof file === 'number')
53
+ return file;
28
54
  const loaded = (await import(pathToFileURL(resolve(file)).href));
29
55
  const plugin = loaded.default ?? loaded;
30
56
  reset();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "caique",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "The parrot that always answers back, and the boat that goes between ship and shore. Prompts that are flags first, so agents answer before they are asked and non-TTY callers get an error naming the flag, never a hang. Drop-in path for inquirer and clack.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -98,8 +98,8 @@
98
98
  "ai-agent"
99
99
  ],
100
100
  "dependencies": {
101
- "closeout": "^0.5.0",
102
- "linegauge": "^0.5.0"
101
+ "closeout": "^0.5.1",
102
+ "linegauge": "^0.5.1"
103
103
  },
104
104
  "devDependencies": {
105
105
  "vitest": "^5.0.1"