brainx-skill 1.0.0 → 1.0.2

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
@@ -74,8 +74,8 @@ npm test
74
74
  npm pack --dry-run
75
75
  npm pack
76
76
  test_home="$(mktemp -d '/tmp/brainx skills.XXXXXX')"
77
- HOME="$test_home" npx --yes --package ./brainx-skill-1.0.0.tgz brainx install
78
- HOME="$test_home" npx --yes --package ./brainx-skill-1.0.0.tgz brainx update
77
+ HOME="$test_home" npx --yes --package ./brainx-skill-1.0.2.tgz brainx install
78
+ HOME="$test_home" npx --yes --package ./brainx-skill-1.0.2.tgz brainx update
79
79
  ```
80
80
 
81
81
  To preview the interaction directly from this checkout:
package/adapters/codex.js CHANGED
@@ -3,6 +3,5 @@
3
3
  module.exports = Object.freeze({
4
4
  id: 'codex',
5
5
  label: 'Codex',
6
- promptLabel: 'Codex CLI',
7
6
  homePath: ['.agents', 'skills'],
8
7
  });
package/lib/cli.js CHANGED
@@ -4,7 +4,11 @@ const fs = require('node:fs/promises');
4
4
  const os = require('node:os');
5
5
  const path = require('node:path');
6
6
  const { DEFAULT_ADAPTERS, runInstaller } = require('./installer');
7
- const { NonInteractiveInstallError, promptForInstall } = require('./prompts');
7
+ const {
8
+ InstallCancelledError,
9
+ NonInteractiveInstallError,
10
+ promptForInstall,
11
+ } = require('./prompts');
8
12
 
9
13
  const USAGE = `Usage:
10
14
  npx brainx-skill install
@@ -44,6 +48,10 @@ async function runCli(args, options = {}) {
44
48
  stdout: options.stdout || process.stdout,
45
49
  });
46
50
  } catch (error) {
51
+ if (error instanceof InstallCancelledError) {
52
+ stderr.write('Installation cancelled.\n');
53
+ return 130;
54
+ }
47
55
  if (error instanceof NonInteractiveInstallError) {
48
56
  stderr.write('Interactive installation requires a terminal.\n');
49
57
  stderr.write('Run this command in an interactive shell.\n');
package/lib/prompts.js CHANGED
@@ -10,6 +10,13 @@ class NonInteractiveInstallError extends Error {
10
10
  }
11
11
  }
12
12
 
13
+ class InstallCancelledError extends Error {
14
+ constructor() {
15
+ super('Installation cancelled.');
16
+ this.name = 'InstallCancelledError';
17
+ }
18
+ }
19
+
13
20
  function harnessLabel(adapter) {
14
21
  return adapter.promptLabel || adapter.label;
15
22
  }
@@ -62,17 +69,45 @@ async function detectHarnesses(options) {
62
69
 
63
70
  function createPromptApi(input, output) {
64
71
  const { AutoComplete, Select } = require('enquirer');
72
+
73
+ async function run(PromptType, options) {
74
+ const prompt = new PromptType({ ...options, stdin: input, stdout: output });
75
+ const cancel = prompt.cancel.bind(prompt);
76
+ prompt.cancel = async function cancelSafely(error) {
77
+ if (typeof this.stop === 'function') {
78
+ const stop = this.stop;
79
+ this.removeListener('close', stop);
80
+ try {
81
+ stop();
82
+ } catch (cleanupError) {
83
+ if (cleanupError.code !== 'ERR_USE_AFTER_CLOSE') {
84
+ throw cleanupError;
85
+ }
86
+ }
87
+ this.stop = undefined;
88
+ }
89
+ return cancel(error);
90
+ };
91
+
92
+ try {
93
+ return await prompt.run();
94
+ } catch (error) {
95
+ if (prompt.state.cancelled) {
96
+ throw new InstallCancelledError();
97
+ }
98
+ throw error;
99
+ }
100
+ }
101
+
65
102
  return {
66
103
  select(options) {
67
- return new Select({ ...options, stdin: input, stdout: output }).run();
104
+ return run(Select, options);
68
105
  },
69
106
  multiSelect(options) {
70
- return new AutoComplete({
107
+ return run(AutoComplete, {
71
108
  ...options,
72
109
  multiple: true,
73
- stdin: input,
74
- stdout: output,
75
- }).run();
110
+ });
76
111
  },
77
112
  };
78
113
  }
@@ -122,14 +157,18 @@ async function promptForInstall(options) {
122
157
  }
123
158
 
124
159
  if (!selectedHarnessIds) {
125
- const initiallySelected = new Set(
126
- detectedIds.length > 0 ? detectedIds : options.adapters.map((adapter) => adapter.id),
127
- );
160
+ const initiallySelected = detectedIds.length > 0
161
+ ? []
162
+ : options.adapters.map((adapter) => adapter.id);
128
163
  selectedHarnessIds = await prompt.multiSelect({
129
164
  name: 'harnesses',
130
165
  message: 'Select harnesses',
131
166
  hint: 'Type to filter, space to select, enter to confirm',
132
- initial: [...initiallySelected],
167
+ emptyError: ' ',
168
+ initial: initiallySelected,
169
+ symbols: {
170
+ indicator: { on: '\u25cf', off: '\u25cb' },
171
+ },
133
172
  choices: options.adapters.map((adapter) => ({
134
173
  name: adapter.id,
135
174
  message: harnessLabel(adapter),
@@ -159,6 +198,7 @@ async function promptForInstall(options) {
159
198
  }
160
199
 
161
200
  module.exports = {
201
+ InstallCancelledError,
162
202
  NonInteractiveInstallError,
163
203
  detectHarnesses,
164
204
  promptForInstall,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brainx-skill",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Portable BrainX Agent Skills for Claude Code, Codex, and Cursor",
5
5
  "license": "Apache-2.0",
6
6
  "type": "commonjs",