captain-tool 0.0.120 → 0.0.122

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,10 +74,18 @@ One command installs captain-tool and connects it to your AI client(s):
74
74
  npx captain-tool@latest setup
75
75
  ```
76
76
 
77
- It installs captain-tool globally (so your clients keep a path to it that npm does not clean
78
- up), then asks which clients to configure, whether to auto-approve Captain's tools in Claude
79
- Code, and turns on skill proof. If the global install needs permissions you don't have, it
80
- stops, registers nothing, and prints the `npm install -g` command to run yourself.
77
+ It sets up Claude Code: it asks "Set up Claude Code? [Y/n]", whether to auto-approve Captain's
78
+ tools, and whether to sign in now, then installs captain-tool globally (so Claude Code keeps a
79
+ path to it that npm does not clean up), registers it, turns on skill proof and adds the
80
+ `/captain-status` command. It ends with "Setup complete. Open Claude Code and say hi to start."
81
+ If the global install needs permissions you don't have, it stops, registers nothing, and prints
82
+ the `npm install -g` command to run yourself. Other clients (Claude Desktop, VS Code, Cursor,
83
+ Windsurf, Codex) are set up by hand: see Manual setup below. `--uninstall` still removes
84
+ Captain from every client an earlier setup configured.
85
+
86
+ In your first chat, Captain checks your status (any message, "Check Captain status and get me
87
+ set up", or `/captain-status`), signs you in, picks your workspace, and offers once to turn how
88
+ you work in Claude Code into Captain flows.
81
89
 
82
90
  ### Already ran `npm install -g captain-tool`?
83
91
 
@@ -154,7 +162,7 @@ claude mcp add -s user captain -- cmd /c captain-tool
154
162
  }
155
163
  ```
156
164
 
157
- `mcp__captain` (no tool suffix) approves every tool from this server. Your own `deny` and `ask` rules always take precedence over this allow rule. Note the rule prefix is the *registration key*: if you registered under a different name, the rule must match it. Old `mcp__captain-tool__*` rules from before the rename match nothing — the wizard sweeps them out of `~/.claude/settings.json`; per-project `.claude/settings.local.json` files can hold more, so clean those by hand if Claude Code still prompts. For scripted installs, `npx captain-tool setup --yes` configures all clients and enables auto-approval without prompting.
165
+ `mcp__captain` (no tool suffix) approves every tool from this server. Your own `deny` and `ask` rules always take precedence over this allow rule. Note the rule prefix is the *registration key*: if you registered under a different name, the rule must match it. Old `mcp__captain-tool__*` rules from before the rename match nothing — the wizard sweeps them out of `~/.claude/settings.json`; per-project `.claude/settings.local.json` files can hold more, so clean those by hand if Claude Code still prompts. For scripted installs, `npx captain-tool setup --yes` sets up Claude Code and enables auto-approval without prompting.
158
166
 
159
167
  ### VS Code + Copilot
160
168
 
@@ -222,11 +230,19 @@ On Windows, use `command = "cmd"` and `args = ["/c", "captain-tool"]`.
222
230
 
223
231
  ## First use
224
232
 
225
- Once connected, ask your AI agent:
233
+ Setup offers to sign you in as its last step: your browser opens, you approve, and you are done.
234
+ To sign in later, or from a script that ran setup with `--yes`, run:
235
+
236
+ ```
237
+ captain-tool login
238
+ ```
239
+
240
+ (`--no-browser` prints the sign-in URL instead of opening it.) Or skip it: your agent asks you to
241
+ sign in the first time you use Captain. Once connected, ask your AI agent:
226
242
 
227
243
  > "Check captain status and get me set up."
228
244
 
229
- It will walk you through logging in and selecting your workspace. After that, you can ask things like:
245
+ It will walk you through anything left, such as signing in and selecting your workspace. After that, you can ask things like:
230
246
 
231
247
  ```
232
248
  Show me all my pipelines.
@@ -669,6 +669,67 @@ function runHooks(binary, args) {
669
669
  return { ok: res.status === 0, output };
670
670
  }
671
671
 
672
+ /**
673
+ * Sign in to Captain with `captain-tool login`, which opens the browser and waits for the
674
+ * approval (it drives the same sign-in as the Captain panel, through Captain's local service).
675
+ * Interactive: the person sees the URL and code and answers in the browser, so the child gets
676
+ * this terminal. Returns true when the person is signed in. Never throws: setup's registration
677
+ * stands whatever happens here. `spawn` is injectable for tests.
678
+ */
679
+ function runLogin(binary, spawn = require('child_process').spawnSync) {
680
+ if (!binary) return false;
681
+ const res = spawn(binary, ['login'], { stdio: 'inherit' });
682
+ return !res.error && res.status === 0;
683
+ }
684
+
685
+ /** Setup's last line (user decision, 2026-11-24). */
686
+ const SETUP_DONE = 'Setup complete. Open Claude Code and say hi to start.';
687
+
688
+ /** An answer to a [Y/n] question: Enter or y/yes is yes. */
689
+ function isYes(answer) {
690
+ return answer === '' || /^y(es)?$/i.test(answer);
691
+ }
692
+
693
+ // ── The /captain-status command ─────────────────────────────────────────────────
694
+ // A Claude Code user command (~/.claude/commands/captain-status.md) that runs captain_status,
695
+ // one of the ways a first chat can begin. The marker line tells ours from a file the person
696
+ // wrote: setup never overwrites theirs, and --uninstall removes only ours.
697
+ const STATUS_COMMAND_MARKER = '<!-- written by captain-tool setup -->';
698
+ const STATUS_COMMAND = `---
699
+ description: Check Captain's status and get set up
700
+ ---
701
+ ${STATUS_COMMAND_MARKER}
702
+ Call the captain_status tool and follow its guidance.
703
+ `;
704
+
705
+ function statusCommandPath() {
706
+ return expandPath('~/.claude/commands/captain-status.md');
707
+ }
708
+
709
+ /** Writes the command when it is absent or ours. Returns the path written, or null. */
710
+ function installStatusCommand(filePath = statusCommandPath()) {
711
+ if (fs.existsSync(filePath)) {
712
+ const current = fs.readFileSync(filePath, 'utf8');
713
+ if (!current.includes(STATUS_COMMAND_MARKER)) return null;
714
+ if (current === STATUS_COMMAND) return null;
715
+ }
716
+ fs.mkdirSync(path.dirname(filePath), { recursive: true });
717
+ fs.writeFileSync(filePath, STATUS_COMMAND);
718
+ return filePath;
719
+ }
720
+
721
+ /** Removes the command when it is ours. Returns true when a file was removed. */
722
+ function removeStatusCommand(filePath = statusCommandPath()) {
723
+ if (!fs.existsSync(filePath)) return false;
724
+ if (!fs.readFileSync(filePath, 'utf8').includes(STATUS_COMMAND_MARKER)) return false;
725
+ fs.unlinkSync(filePath);
726
+ return true;
727
+ }
728
+
729
+ /** What setup says when it does not sign the person in itself. */
730
+ const SIGN_IN_LATER =
731
+ 'Sign in any time with `captain-tool login`, or your agent will ask the first time you use Captain.';
732
+
672
733
  /** The flags this wizard reads. */
673
734
  function parseFlags(argv) {
674
735
  return {
@@ -753,6 +814,12 @@ function uninstall(binaryPath, { hooksOnly }) {
753
814
  failed = true;
754
815
  }
755
816
  if (client.permissionsPath) {
817
+ try {
818
+ if (removeStatusCommand()) console.log(`Removed the /captain-status command: ${statusCommandPath()}`);
819
+ } catch (err) {
820
+ console.error(`Could not remove ${statusCommandPath()}: ${err.message}`);
821
+ failed = true;
822
+ }
756
823
  try {
757
824
  // Same promise as the install sweep: an unrelated `captain-tool` server keeps its rules.
758
825
  const sweepLegacy = !hasUnrelatedLegacyServer(readJsonConfig(client.configPath(binaryPath)));
@@ -908,55 +975,32 @@ async function main() {
908
975
  return;
909
976
  }
910
977
 
911
- let selected;
978
+ // Setup configures Claude Code only (user decision, 2026-11-24). The other clients stay in
979
+ // CLIENTS so `--uninstall` still removes Captain from every client an earlier setup wrote.
980
+ const claudeCode = CLIENTS.indexOf(claudeCodeClient());
981
+ let selected = [claudeCode];
912
982
  let wantPermissions = false;
983
+ // `--yes` (scripts, CI) never signs in: a browser sign-in needs a person at the keyboard.
984
+ let wantSignIn = false;
913
985
  if (assumeYes) {
914
- selected = CLIENTS.map((_, i) => i);
915
986
  wantPermissions = true;
916
- console.log('--yes: configuring all clients and enabling auto-approval.');
987
+ console.log('--yes: setting up Claude Code and enabling auto-approval.');
917
988
  console.log('');
918
989
  } else if (!process.stdin.isTTY) {
919
- console.error('stdin is not interactive. Re-run with --yes to configure all clients without prompts.');
990
+ console.error('stdin is not interactive. Re-run with --yes to set up Claude Code without prompts.');
920
991
  process.exit(1);
921
992
  } else {
922
- // Present the client menu.
923
- console.log('Select which agent(s) to configure:');
924
- console.log(' 0. All of the above');
925
- CLIENTS.forEach((client, i) => {
926
- console.log(` ${i + 1}. ${client.name}`);
927
- });
928
- console.log('');
929
-
930
993
  const rl = readline.createInterface({
931
994
  input: process.stdin,
932
995
  output: process.stdout,
933
996
  });
934
997
 
935
- while (true) {
936
- const answer = await prompt(
937
- rl,
938
- `Enter number(s) separated by commas (e.g. "1,3") or 0 for all: `
939
- );
940
- if (answer === null) abortNoInput();
941
-
942
- // Parse the answer into a list of client indices (0-based into CLIENTS).
943
- if (answer === '0') {
944
- selected = CLIENTS.map((_, i) => i);
945
- break;
946
- }
947
-
948
- const indices = answer
949
- .split(',')
950
- .map((s) => parseInt(s.trim(), 10) - 1) // convert 1-based menu to 0-based
951
- .filter((n) => Number.isInteger(n) && n >= 0 && n < CLIENTS.length);
952
-
953
- if (indices.length === 0) {
954
- console.log(`Please enter a number between 0 and ${CLIENTS.length}.`);
955
- continue;
956
- }
957
-
958
- selected = indices;
959
- break;
998
+ const setUp = await prompt(rl, 'Set up Claude Code? [Y/n]: ');
999
+ if (setUp === null) abortNoInput();
1000
+ if (!isYes(setUp)) {
1001
+ rl.close();
1002
+ console.log('Nothing was set up.');
1003
+ return;
960
1004
  }
961
1005
 
962
1006
  // If Claude Code is among the selections, offer to auto-approve captain's
@@ -973,9 +1017,15 @@ async function main() {
973
1017
  `permissions.allow in ${permClient.permissionsPath()} so tool calls never prompt. [Y/n]: `
974
1018
  );
975
1019
  if (answer === null) abortNoInput();
976
- wantPermissions = answer === '' || /^y(es)?$/i.test(answer);
1020
+ wantPermissions = isYes(answer);
977
1021
  }
978
1022
 
1023
+ // Sign in now? Asked here with the other questions, before anything is installed; the
1024
+ // sign-in itself runs last, once the server is registered.
1025
+ const signIn = await prompt(rl, 'Sign in to Captain now? Your browser will open. [Y/n]: ');
1026
+ if (signIn === null) abortNoInput();
1027
+ wantSignIn = isYes(signIn);
1028
+
979
1029
  rl.close();
980
1030
  console.log('');
981
1031
  }
@@ -1077,6 +1127,13 @@ async function main() {
1077
1127
  // whenever Claude Code was configured, whether or not the Captain extension is in use. A
1078
1128
  // failure here is a warning: the MCP registration above stands.
1079
1129
  if (permIdx !== undefined) {
1130
+ // The /captain-status command: a first chat can start with it (it runs captain_status).
1131
+ try {
1132
+ const written = installStatusCommand();
1133
+ if (written) console.log(`Added the /captain-status command: ${written}`);
1134
+ } catch (err) {
1135
+ console.warn(`Warning: /captain-status command not added: ${err.message}`);
1136
+ }
1080
1137
  const bin = hooksBinary(binaryPath);
1081
1138
  if (!bin) {
1082
1139
  console.warn('Skill-proof hook skipped: no captain-tool binary found. Run `captain-tool hooks install` once captain-tool is installed.');
@@ -1096,6 +1153,7 @@ async function main() {
1096
1153
  }
1097
1154
 
1098
1155
  console.log('Setup complete. The captain server is registered and ready to use.');
1156
+
1099
1157
  // CAP-ADR-0030: the registered `captain-tool` is a relay to Captain's local service (the
1100
1158
  // daemon the Captain extension also runs). The two must be the same release.
1101
1159
  console.log('');
@@ -1103,6 +1161,23 @@ async function main() {
1103
1161
  console.log('not running. If you also use the Captain extension,');
1104
1162
  console.log('update captain-tool and the Captain extension together:');
1105
1163
  console.log('each refuses the other across a version that changed how agents connect.');
1164
+
1165
+ // Last, because it is interactive and its result is the last thing the person should see.
1166
+ console.log('');
1167
+ if (wantSignIn) {
1168
+ const bin = hooksBinary(binaryPath);
1169
+ if (!bin) {
1170
+ console.warn('Sign-in skipped: no captain-tool binary found.');
1171
+ console.log(SIGN_IN_LATER);
1172
+ } else if (!runLogin(bin)) {
1173
+ console.warn('Not signed in yet.');
1174
+ console.log(SIGN_IN_LATER);
1175
+ }
1176
+ } else {
1177
+ console.log(SIGN_IN_LATER);
1178
+ }
1179
+ console.log('');
1180
+ console.log(SETUP_DONE);
1106
1181
  }
1107
1182
 
1108
1183
  // Only run the interactive wizard when invoked directly. Guarding on
@@ -1131,6 +1206,13 @@ module.exports = {
1131
1206
  hasUnrelatedLegacyServer,
1132
1207
  hooksBinary,
1133
1208
  runHooks,
1209
+ runLogin,
1210
+ SIGN_IN_LATER,
1211
+ SETUP_DONE,
1212
+ isYes,
1213
+ STATUS_COMMAND,
1214
+ installStatusCommand,
1215
+ removeStatusCommand,
1134
1216
  parseFlags,
1135
1217
  uninstallClient,
1136
1218
  removePermissionRule,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "captain-tool",
3
- "version": "0.0.120",
3
+ "version": "0.0.122",
4
4
  "description": "MCP server connecting Claude Desktop and VS Code Copilot to Captain Cloud",
5
5
  "bin": {
6
6
  "captain-tool": "bin/captain-tool",
@@ -11,10 +11,10 @@
11
11
  "test": "node test/setup.test.js"
12
12
  },
13
13
  "optionalDependencies": {
14
- "@captain-tool/captain-tool-win32-x64": "0.0.120",
15
- "@captain-tool/captain-tool-darwin-x64": "0.0.120",
16
- "@captain-tool/captain-tool-darwin-arm64": "0.0.120",
17
- "@captain-tool/captain-tool-linux-x64": "0.0.120"
14
+ "@captain-tool/captain-tool-win32-x64": "0.0.122",
15
+ "@captain-tool/captain-tool-darwin-x64": "0.0.122",
16
+ "@captain-tool/captain-tool-darwin-arm64": "0.0.122",
17
+ "@captain-tool/captain-tool-linux-x64": "0.0.122"
18
18
  },
19
19
  "files": [
20
20
  "bin/",