@nomac/cli 0.21.4 → 0.22.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nomac/cli",
3
- "version": "0.21.4",
3
+ "version": "0.22.0",
4
4
  "description": "A real cloud Mac for AI agents: Xcode, the iOS Simulator, signing, TestFlight and App Store publishing, by the minute, over MCP, SSH and HTTPS.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
package/skill/SKILL.md CHANGED
@@ -18,7 +18,7 @@ shell), a NoMac cloud iPhone is the lighter choice, from the same credit: the
18
18
  phone tools (`phone`, `phone_app_run`, `phone_ui_look`, `phone_ui_act` and the
19
19
  other `phone_*`), which NoMac's MCP lists beside the Mac (`nomac mcp` and
20
20
  https://mcp.nomac.app/mcp); https://mcp.nomac.app/simulator for the phone
21
- alone; or `npx simulator-use cloud start` from a terminal
21
+ alone; or `npx simulator-use@0.15.1 cloud start` from a terminal
22
22
  (https://nomac.app/simulator). `phone_app_run` builds from a git link, or from
23
23
  the project here: in `nomac mcp`, `local_path` sends the folder (only what
24
24
  changed); on the hosted server, `phone_upload_link` answers one command that
@@ -38,10 +38,10 @@ Store screenshots start the phone with `device: "iphone-pro-max"` (6.9-inch,
38
38
  not a payment. No Apple Developer account is needed for an unsigned build.
39
39
  Under an hour left, answers say `low_credit` with a `buy_url`: tell the
40
40
  human before a long build (a refill of 3 packs, $30, earns bonus credit).
41
- 2. Install `npm install -g @nomac/cli`, run `nomac login`, and give the human
41
+ 2. Install `npm install -g @nomac/cli@0.22.0` (it updates itself after), run `nomac login`, and give the human
42
42
  the printed device URL and code. With a key the human made at
43
43
  https://nomac.app/keys: `nomac login --with-token < key.txt`, or set
44
- `NOMAC_API_KEY`. MCP: `claude mcp add nomac -- npx @nomac/cli mcp`.
44
+ `NOMAC_API_KEY`. MCP: `claude mcp add nomac -- npx -y @nomac/cli@0.22.0 mcp`.
45
45
  Hosted MCP: https://mcp.nomac.app/mcp with `Authorization: Bearer <nmk_key>`.
46
46
  3. `nomac start --json`, wait until ready, `nomac sync .`, then `nomac ssh`.
47
47
  Run commands with `nomac exec -- COMMAND`: it prints the output as it
@@ -87,9 +87,13 @@ Keep the same request key and arguments after uncertain responses; inspect
87
87
  the original job before retrying. Output retrieval failure is not job failure.
88
88
  A command runs up to its `timeout_seconds` (300 by default, 3600 at most) and
89
89
  says so when that limit stops it; SSH can run longer within session limits.
90
- CLI sync sends every file (.env and keys included) and symlinks as links, and
91
- skips dependency and build folders, .git and folders .gitignore lists; a `!`
92
- line in .nomacignore sends any of them. A file changed on the Mac since the
90
+ CLI sync sends every file but secrets, and symlinks as links, and skips
91
+ dependency and build folders, .git and folders .gitignore lists. Secrets stay
92
+ on this computer: .env files (not .env.example), .p8, .p12, .pfx, keystores,
93
+ private SSH keys, .netrc, and .pem or .key files with a private key. Give them
94
+ to every Mac encrypted with `nomac secrets set --from-env-file .env` or
95
+ `nomac secrets set NAME --file PATH`. A `!` line in .nomacignore sends any of
96
+ them anyway. A file changed on the Mac since the
93
97
  last sync is left alone and named (the rest is sent, and sync exits 1): `nomac
94
98
  pull` it, or `nomac sync . --overwrite`. Sync deletes nothing on the Mac
95
99
  unless `--delete`, which removes what it sent earlier and you deleted here.
@@ -131,7 +135,7 @@ name at the new Mac. Then VS Code or Cursor Remote-SSH and Claude Code's SSH
131
135
  sessions connect to `nomac`; `ssh -t nomac 'cd ~/drive/src/<folder> && npx -y
132
136
  @anthropic-ai/claude-code'` runs an agent on the Mac itself (keep its API key
133
137
  as a NoMac secret); and an MCP server that needs a Mac runs from Windows or
134
- Linux over SSH: `claude mcp add xcode -- ssh nomac npx -y mobilebuildmcp@latest
138
+ Linux over SSH: `claude mcp add xcode -- ssh nomac npx -y mobilebuildmcp@2.7.1
135
139
  mcp` (MobileBuildMCP, formerly XcodeBuildMCP). An open SSH connection keeps
136
140
  the Mac running until its time or spend limit: `nomac stop` when done.
137
141
 
@@ -30,7 +30,9 @@ const HELP = `Nomac cloud Mac sessions
30
30
  (~/workspace with --drive none). A file changed on the Mac
31
31
  since is left alone and named (--overwrite replaces it);
32
32
  --delete also removes there what you deleted here;
33
- --watch syncs again whenever files change, until Ctrl-C
33
+ --watch syncs again whenever files change, until Ctrl-C.
34
+ Secrets stay here (.env, .p8, .p12, keystores, private
35
+ keys): nomac secrets gives them to every Mac encrypted
34
36
  nomac ssh [--forward 8080:3000] full Mac shell and port forwarding
35
37
  nomac ssh -- command args run any command over SSH
36
38
  nomac desktop [--no-open] [--json] the full macOS desktop in your browser
@@ -171,9 +173,10 @@ function budget(value = "5") {
171
173
  if (result <= 0n) throw new CliError("--max-cost must be positive.");
172
174
  return result.toString();
173
175
  }
174
- function integer(value, fallback, min, max) {
176
+ /** A whole-number option, named with its unit in the error (November 6, 2026: "--idle-timeout 7200" said only "Invalid numeric option"). */
177
+ function integer(value, fallback, min, max, name = "number") {
175
178
  if (value === undefined) return fallback;
176
- if (!/^\d+$/.test(value) || !Number.isSafeInteger(Number(value)) || Number(value) < min || Number(value) > max) throw new CliError("Invalid numeric option.");
179
+ if (!/^\d+$/.test(value) || !Number.isSafeInteger(Number(value)) || Number(value) < min || Number(value) > max) throw new CliError(`Invalid ${name}: give a whole number from ${min} to ${max}${/^\d+$/.test(value) ? "" : ", with no unit"}.`);
177
180
  return Number(value);
178
181
  }
179
182
  const validRequestKey = value => typeof value === "string" && /^[A-Za-z0-9_.:-]{8,128}$/.test(value);
@@ -294,12 +297,12 @@ async function waitForCommand(id, base, started, waitSeconds, { request, transpo
294
297
  // What it printed so far is shown, and the next wait for it goes on from there.
295
298
  if (live) { await stream(); keepCursors(job.id, cursor); }
296
299
  const unknown = job.state === "unknown";
297
- const busyNote = busy ? "The Mac is busy (for example, the iOS Simulator is booting) and answers slowly. " : "";
300
+ const busyNote = busy ? "The Mac is busy (for example, builds using all its CPUs and memory, or the iOS Simulator booting) and answers slowly; running fewer builds at once keeps it responsive. " : "";
298
301
  const next = unknown ? `The Mac could not confirm whether ${job.id} finished. Inspect it with nomac job ${job.id}; do not rerun it.`
299
302
  : `${busyNote}Still running after ${waitSeconds} s; it keeps running on the Mac.${stopsAt(job)} Wait for it: nomac job ${job.id} --wait 600. Next time wait up front: nomac exec --wait 600 -- command. Over an hour: nomac ssh -- command. Do not rerun it; to stop it: nomac cancel ${job.id}.`;
300
303
  if (json) print(JSON.stringify({ ...job, ...(busy ? { busy: true } : {}), next_step: next }, null, 2));
301
304
  else if (unknown) stderr(`nomac: ${next}\n`);
302
- else stderr(`nomac: ${busy ? "the Mac is busy (for example, the iOS Simulator is booting); " : ""}still running after ${waitSeconds} s (${job.id}); it keeps running on the Mac.${stopsAt(job)}\n wait for it: nomac job ${job.id} --wait 600\n stop it: nomac cancel ${job.id}\n next time, wait longer: nomac exec --wait 600 -- command\n over an hour: nomac ssh -- command\n`);
305
+ else stderr(`nomac: ${busy ? "the Mac is busy (for example, builds using all its CPUs and memory, or the iOS Simulator booting); " : ""}still running after ${waitSeconds} s (${job.id}); it keeps running on the Mac.${stopsAt(job)}\n wait for it: nomac job ${job.id} --wait 600\n stop it: nomac cancel ${job.id}\n next time, wait longer: nomac exec --wait 600 -- command\n over an hour: nomac ssh -- command\n`);
303
306
  exitWith(unknown ? 1 : STILL_RUNNING);
304
307
  return job;
305
308
  }
@@ -418,7 +421,7 @@ export async function hostedSessionCommand(command, argv, { store = sessionStore
418
421
  catch (error) { throw new CliError(error.message); }
419
422
  const { values, positionals } = parsed;
420
423
  if (values.help) return print(command === "desktop" ? DESKTOP_HELP : HELP);
421
- const wait = ["start", "attach", "stop"].includes(command) ? integer(values.wait, command === "stop" ? 60 : 300, 0, command === "stop" ? 300 : 600) : 0;
424
+ const wait = ["start", "attach", "stop"].includes(command) ? integer(values.wait, command === "stop" ? 60 : 300, 0, command === "stop" ? 300 : 600, "--wait (seconds)") : 0;
422
425
  if (command === "start" && values["request-key"] !== undefined && !validRequestKey(values["request-key"])) throw new CliError("Use a request key of 8–128 letters, digits, underscores, periods, colons or hyphens.");
423
426
  // The image the last read reported (macOS, Xcodes, Simulators), for start's summary.
424
427
  let lastImage;
@@ -564,7 +567,7 @@ export async function hostedSessionCommand(command, argv, { store = sessionStore
564
567
  }
565
568
  if (command === "extend") {
566
569
  if (positionals.length > 1) throw new CliError("Usage: nomac extend [MINUTES] [--json]");
567
- const minutes = integer(positionals[0], 60, 1, 480);
570
+ const minutes = integer(positionals[0], 60, 1, 480, "number of minutes");
568
571
  const local = localSession();
569
572
  const result = await request("POST", `/api/v1/mac/sessions/${sessionId(local.id)}/extend`, { body: { minutes } });
570
573
  saveView(local, result.session);
@@ -600,7 +603,7 @@ export async function hostedSessionCommand(command, argv, { store = sessionStore
600
603
  }
601
604
  if (["exec", "job", "output"].includes(command)) {
602
605
  const local = localSession(), base = `/api/v1/mac/sessions/${sessionId(local.id)}`;
603
- let path, method = "GET", params = {}, waitSeconds = integer(values.wait, 30, 0, 3600);
606
+ let path, method = "GET", params = {}, waitSeconds = integer(values.wait, 30, 0, 3600, "--wait (seconds)");
604
607
  if (command === "exec") {
605
608
  if (!positionals.length || !argv.includes("--")) throw new CliError("Use nomac exec -- command args");
606
609
  if (!local.workspaceDecided && !local.workspace) { await refresh(local); if (local.state === "ready") await placeWorkspace(local); }
@@ -611,8 +614,8 @@ export async function hostedSessionCommand(command, argv, { store = sessionStore
611
614
  // A command may run an hour (the gateway's limit); waiting can cover all of it.
612
615
  // A command given a long --timeout and no --wait is waited for too, up to 10 minutes (what an
613
616
  // agent's shell usually allows); the line printed after 5 s says how to go on if interrupted.
614
- const given = values.timeout === undefined ? null : integer(values.timeout, 0, 1, 3600);
615
- const waitFor = waitSeconds = integer(values.wait, given === null ? 30 : Math.min(given, 600), 0, 3600);
617
+ const given = values.timeout === undefined ? null : integer(values.timeout, 0, 1, 3600, "--timeout (seconds)");
618
+ const waitFor = waitSeconds = integer(values.wait, given === null ? 30 : Math.min(given, 600), 0, 3600, "--wait (seconds)");
616
619
  const timeout = given ?? (values["request-key"] === undefined ? Math.max(300, waitFor) : 600);
617
620
  const line = isShellLine(positionals), dir = local.workspaceOnDrive ? local.workspace : null;
618
621
  const onMac = dir ? (line ? ["/bin/bash", "-lc", `cd ${shellQuote(dir)} && ${positionals[0]}`] : ["/bin/bash", "-lc", `cd ${shellQuote(dir)} && exec "$@"`, "nomac", ...positionals])
@@ -670,7 +673,7 @@ export async function hostedSessionCommand(command, argv, { store = sessionStore
670
673
  return saved;
671
674
  }
672
675
  if (positionals.length) throw new CliError("Usage: nomac record [--simulator] [--max SECONDS], then nomac record stop [-o FILE]");
673
- const started = await startRecording(local.id, { target: values.simulator ? "simulator" : "screen", maxSeconds: values.max === undefined ? undefined : integer(values.max, 300, 1, 1800) });
676
+ const started = await startRecording(local.id, { target: values.simulator ? "simulator" : "screen", maxSeconds: values.max === undefined ? undefined : integer(values.max, 300, 1, 1800, "--max (seconds)") });
674
677
  print(values.json ? JSON.stringify(started, null, 2) : `Recording the ${values.simulator ? "Simulator" : "screen"}; it stops by itself after ${started.max_seconds} s.\nSave it: nomac record stop`);
675
678
  return started;
676
679
  }
@@ -823,23 +826,33 @@ export async function hostedSessionCommand(command, argv, { store = sessionStore
823
826
  const target = wanted ? live.find(s => s.id === wanted) : live.length === 1 ? live[0] : undefined;
824
827
  if (!target) throw new CliError(wanted ? `No running Mac ${wanted} in this account.` : live.length ? `This account has ${live.length} running Macs: name one, nomac attach ${live.map(s => s.id).join(" | ")}` : "This account has no running Mac. Start one: nomac start");
825
828
  const local = await attachTo(target);
826
- return output({ session: local.snapshot, attached: `Attached to ${local.id}, started elsewhere: ssh, sync, pull and exec work from this folder.`, ...project(local) });
829
+ return output({ session: local.snapshot, attached: `Attached to ${local.id}, started elsewhere: ssh, sync, pull and exec work from this folder. If another agent or folder is using it, leave it running when you are done here (nomac stop stops it for everyone).`, ...project(local) });
827
830
  }
828
831
  if (command === "start") {
829
832
  if (positionals.length) throw new CliError("Usage: nomac start [--wait SECONDS] [--json]");
830
833
  let local = store.load();
831
834
  if (local && local.mode !== "hosted") throw new CliError("An existing Mac workspace is attached.");
832
- const limits = { max_duration_seconds: integer(values["max-duration"], 7200, 60, 28800), idle_timeout_seconds: integer(values["idle-timeout"], 600, 60, 3600), spend_cap_microunits: budget(values["max-cost"]) };
835
+ const limits = { max_duration_seconds: integer(values["max-duration"], 7200, 60, 28800, "--max-duration (seconds, 8 hours at most)"), idle_timeout_seconds: integer(values["idle-timeout"], 600, 60, 3600, "--idle-timeout (seconds, 1 hour at most)"), spend_cap_microunits: budget(values["max-cost"]) };
833
836
  const access = accessOption(values);
834
837
  // Older CLIs persisted invalid keys before contacting the API. Such a key
835
838
  // cannot pass server validation and therefore cannot have allocated a VM.
836
839
  if (local && !local.id && !validRequestKey(local.requestKey)) { local.state = "failed"; store.save(local); }
840
+ // A Mac this folder attached to (nomac attach) was started elsewhere, and someone may be using it there: --parallel
841
+ // leaves it running and starts a Mac of this folder's own, and a start with other settings never says to stop it.
842
+ const limitFlags = [["max-duration", "max_duration_seconds"], ["idle-timeout", "idle_timeout_seconds"], ["max-cost", "spend_cap_microunits"]];
843
+ const otherAccess = () => access && JSON.stringify({ prompts: "auto", gatekeeper: "off", ...access }) !== JSON.stringify({ prompts: "auto", gatekeeper: "off", ...local.request.access });
844
+ const attachedElsewhere = local?.attached && local.id && !["stopped", "failed"].includes(local.state);
845
+ if (attachedElsewhere && values.parallel) local = undefined;
846
+ else if (attachedElsewhere && (limitFlags.some(([flag, field]) => values[flag] !== undefined && limits[field] !== local.request.limits[field])
847
+ || (values["request-key"] !== undefined && values["request-key"] !== local.requestKey) || otherAccess())) {
848
+ throw new CliError(`This folder is attached to your account's Mac ${local.id}, started elsewhere with other settings; another agent or folder may be using it, so leave it running: stopping it ends their work. Use it as it is (start without --max-duration, --idle-timeout, --max-cost, --request-key or access options), or start a Mac of this folder's own at the same time, with your options: nomac start --parallel`);
849
+ }
837
850
  if (local && !["stopped", "failed"].includes(local.state)) {
838
- for (const [flag, field] of [["max-duration", "max_duration_seconds"], ["idle-timeout", "idle_timeout_seconds"], ["max-cost", "spend_cap_microunits"]]) {
839
- if (values[flag] !== undefined && limits[field] !== local.request.limits[field]) throw new CliError("This session already has different limits. Stop it and start a fresh session to change them.");
851
+ for (const [flag, field] of limitFlags) {
852
+ if (values[flag] !== undefined && limits[field] !== local.request.limits[field]) throw new CliError(`This folder's Mac ${local.id} is running with other limits. Use it as it is (nomac extend MINUTES gives it more time while it runs), or, once it is finished, stop it (nomac stop) and start again with these. If another agent uses this folder, leave it running: stopping it ends their work.`);
840
853
  }
841
854
  if (values["request-key"] !== undefined && values["request-key"] !== local.requestKey) throw new CliError("A session is already attached under a different request key. Inspect it or stop it before starting another.");
842
- if (access && JSON.stringify({ prompts: "auto", gatekeeper: "off", ...access }) !== JSON.stringify({ prompts: "auto", gatekeeper: "off", ...local.request.access })) {
855
+ if (otherAccess()) {
843
856
  throw new CliError("This session was started with different --prompts, --gatekeeper or --permit. Stop it and start a fresh session to change them; nomac permit grants more on the running Mac.");
844
857
  }
845
858
  }
@@ -857,17 +870,17 @@ export async function hostedSessionCommand(command, argv, { store = sessionStore
857
870
  let result;
858
871
  try { result = await request("POST", "/api/v1/mac/sessions", { idempotencyKey: local.requestKey, body: local.request }); }
859
872
  catch (error) {
860
- // One Mac runs per account: when it was started elsewhere (an agent over MCP, the dashboard), use it from here.
861
- if (error.code === "session_limit_reached" && values["request-key"] === undefined && !values.parallel) {
862
- const [running] = await liveSessions();
863
- if (running) {
864
- local = await attachTo(running);
865
- return output({ session: local.snapshot, attached: `Your account's Mac ${local.id} was already running (started elsewhere): this folder now uses it.`, ...project(local) });
866
- }
867
- }
868
873
  if (!previouslyUncertain && startRejections.has(error.code) && Number.isInteger(error.status) && error.status >= 400 && error.status <= 503) {
869
874
  local.state = "failed"; local.rejection = error.code; store.save(local);
870
875
  }
876
+ // The account's Mac runs elsewhere (another agent or folder, MCP, the dashboard). This folder is never moved
877
+ // onto it unasked: November 6, 2026, a customer's two agents were each moved onto the other's Mac when their
878
+ // own start was refused, and stopped it at their end, killing the other's builds for hours. Using it is a
879
+ // choice made by its id.
880
+ if (error.code === "session_limit_reached") {
881
+ const running = (await liveSessions().catch(() => [])).map(s => s.id);
882
+ if (running.length) throw new CliError(error.message, `${error.friendly ?? error.message}\n use ${running.length === 1 ? "it" : "one"} from this folder: nomac attach ${running.join(" | ")}${values.parallel ? "" : "\n a Mac of this folder's own at the same time: nomac start --parallel"}`, error.status, error.code, error.details);
883
+ }
871
884
  throw error;
872
885
  }
873
886
  // The start's warning (what the Mac allows, how to opt out) is shown with every start of this session.
@@ -1,5 +1,5 @@
1
1
  import { createHash, randomUUID } from "node:crypto";
2
- import { constants, closeSync, copyFileSync, createReadStream, existsSync, lstatSync, mkdirSync, mkdtempSync, openSync, readFileSync, readdirSync, readlinkSync, renameSync, rmSync, chmodSync, utimesSync, writeSync } from "node:fs";
2
+ import { constants, closeSync, copyFileSync, createReadStream, existsSync, lstatSync, mkdirSync, mkdtempSync, openSync, readFileSync, readSync, readdirSync, readlinkSync, renameSync, rmSync, chmodSync, utimesSync, writeSync } from "node:fs";
3
3
  import { basename, delimiter, dirname, isAbsolute, join, posix, relative, resolve, sep } from "node:path";
4
4
  import { homedir } from "node:os";
5
5
  import { Readable } from "node:stream";
@@ -24,9 +24,8 @@ export function defaultTransport({ platform = process.platform, env = process.en
24
24
 
25
25
  /**
26
26
  * What sync leaves out unless .nomacignore brings it back: folders that are
27
- * rebuilt on the Mac anyway, git history, Finder metadata and NoMac's own
28
- * files. Nothing is left out to protect the person from their own files:
29
- * .env files, keys and certificates travel like any other file.
27
+ * rebuilt on the Mac anyway, git history, Finder metadata, NoMac's own files,
28
+ * and secrets (secretFile). nomac secrets puts a secret on every Mac encrypted.
30
29
  */
31
30
  const BUILT_IN = [
32
31
  { pattern: "node_modules/", reason: "rebuilt on the Mac" },
@@ -43,6 +42,30 @@ const BUILT_IN = [
43
42
  { pattern: "nomac-screenshot.jpg", reason: "saved by nomac screenshot" },
44
43
  { pattern: "nomac-recording.mp4", reason: "saved by nomac record" },
45
44
  ];
45
+ /** The reason sync gives for a secret it kept on this computer. */
46
+ export const SECRET_REASON = "a secret, kept on this computer";
47
+ const PRIVATE_KEY = /-----BEGIN (?:[A-Z0-9]+ )*PRIVATE KEY-----/;
48
+ /** Whether a .pem or .key file holds a private key (a certificate an app bundles holds none), from its first 1 MiB. */
49
+ function holdsPrivateKey(path) {
50
+ let fd;
51
+ try {
52
+ fd = openSync(path, constants.O_RDONLY | constants.O_NOFOLLOW);
53
+ const buffer = Buffer.alloc(1024 * 1024), read = readSync(fd, buffer, 0, buffer.length, 0);
54
+ return PRIVATE_KEY.test(buffer.subarray(0, read).toString("latin1"));
55
+ } catch { return false; } finally { if (fd !== undefined) closeSync(fd); }
56
+ }
57
+ /**
58
+ * Secrets sync keeps on this computer unless a .nomacignore `!` line sends one: environment files (not their
59
+ * examples), App Store Connect keys and signing identities (.p8, .p12, .pfx), Android keystores, private SSH keys,
60
+ * .netrc, and .pem or .key files that hold a private key. Provisioning profiles and certificates are not secret and
61
+ * are sent: a device build on the Mac needs them.
62
+ */
63
+ export function secretFile(name, path) {
64
+ if (/^\.env(\..+)?$/.test(name)) return !/\.(example|sample|template)$/.test(name);
65
+ if (/\.(p8|p12|pfx|keystore|jks)$/i.test(name) || /^id_(rsa|dsa|ecdsa|ed25519)$/.test(name) || name === ".netrc") return true;
66
+ return /\.(pem|key)$/i.test(name) && holdsPrivateKey(path);
67
+ }
68
+
46
69
  // Built-in patterns are names, matched against the entry's own name, so a folder
47
70
  // brought back with `!` is never skipped again through its parent.
48
71
  const builtInRules = BUILT_IN.map(({ pattern, reason }) => ({ rules: ignoreFactory().add(pattern), reason }));
@@ -64,8 +87,8 @@ function verdict(scopes, path, isDirectory) {
64
87
  }
65
88
 
66
89
  /**
67
- * The project as sync sends it. Every file is sent, including files a
68
- * .gitignore lists (.env, local configuration, temporary files): they are
90
+ * The project as sync sends it. Every file but a secret is sent, including files a
91
+ * .gitignore lists (local configuration, temporary files): they are
69
92
  * small and often needed to build. Folders a .gitignore lists are skipped,
70
93
  * because they are dependencies and build output. .nomacignore decides last:
71
94
  * it can skip anything more, and its `!` lines bring back anything, the
@@ -90,6 +113,8 @@ export function projectFiles(root) {
90
113
  reason = builtInRules.find(rule => rule.rules.ignores(entry.name + (isDirectory ? "/" : "")))?.reason;
91
114
  if (!reason && isDirectory && verdict(git, path, true)) reason = "listed in .gitignore";
92
115
  }
116
+ // A secret stays here even inside a folder .nomacignore brought back; only its own `!` line sends it.
117
+ if (!reason && entry.isFile() && secretFile(entry.name, path)) reason = SECRET_REASON;
93
118
  const decision = verdict(nomac, path, isDirectory);
94
119
  const bringsBack = decision === false && reason !== undefined;
95
120
  if (decision === true) reason = "listed in .nomacignore";
@@ -380,10 +405,17 @@ export function describeSync(result) {
380
405
  if (result.conflicts?.length) lines.push(`Would not send, changed on the Mac since the last sync: ${result.conflicts.slice(0, 10).join(", ")}${result.conflicts.length > 10 ? ` and ${result.conflicts.length - 10} more` : ""}.`);
381
406
  if (result.deleted?.length) lines.push(`${result.dry_run ? "Would delete" : "Deleted"} on the Mac, as here: ${result.deleted.slice(0, 10).join(", ")}${result.deleted.length > 10 ? ` and ${result.deleted.length - 10} more` : ""}.`);
382
407
  if (result.kept_on_mac?.length) lines.push(`Kept on the Mac, changed there since: ${result.kept_on_mac.slice(0, 10).join(", ")}${result.kept_on_mac.length > 10 ? ` and ${result.kept_on_mac.length - 10} more` : ""}.`);
383
- if (result.skipped.length) {
384
- const shown = result.skipped.slice(0, 6).map(item => `${item.path} (${item.reason})`).join(", ");
385
- lines.push(`Not sent: ${shown}${result.skipped.length > 6 ? `, and ${result.skipped.length - 6} more (--json lists them)` : ""}. To send one, add a line such as ${result.skipped[0].send_with} to .nomacignore.`);
408
+ const secrets = result.skipped.filter(item => item.reason === SECRET_REASON), others = result.skipped.filter(item => item.reason !== SECRET_REASON);
409
+ if (others.length) {
410
+ const shown = others.slice(0, 6).map(item => `${item.path} (${item.reason})`).join(", ");
411
+ lines.push(`Not sent: ${shown}${others.length > 6 ? `, and ${others.length - 6} more (--json lists them)` : ""}. To send one, add a line such as ${others[0].send_with} to .nomacignore.`);
412
+ }
413
+ if (secrets.length) {
414
+ const env = secrets.find(item => /(^|\/)\.env(\.[^/]+)?$/.test(item.path)), file = secrets.find(item => item !== env);
415
+ const ways = [env && `nomac secrets set --from-env-file ${env.path} (its lines as variables)`, file && `nomac secrets set NAME --file ${file.path} --destination ~/... (a file)`].filter(Boolean).join(", or ");
416
+ lines.push(`Kept on this computer, as secrets: ${listed(secrets.map(item => item.path))}. To give every Mac a secret encrypted: ${ways}. To sync one anyway, add a line such as ${secrets[0].send_with} to .nomacignore.`);
386
417
  }
418
+ if (result.secrets_left_on_mac?.length) lines.push(`An earlier sync sent ${listed(result.secrets_left_on_mac)} to the Mac's drive, where ${result.secrets_left_on_mac.length === 1 ? "it stays" : "they stay"} until removed: nomac exec -- rm ${result.secrets_left_on_mac.map(shellQuote).join(" ")}`);
387
419
  return lines.join("\n");
388
420
  }
389
421
 
@@ -435,7 +467,7 @@ export async function syncProject(session, store, { overwrite = false, dryRun =
435
467
  const changed = send.filter(path => previous[path] !== local[path]), summary = summarize(store.project, selection);
436
468
  const onMac = gone.length ? await remoteFingerprints(session, gone, { run }) : {};
437
469
  const removable = gone.filter(path => onMac[path] === baseline[path]), keptOnMac = gone.filter(path => !["missing", baseline[path]].includes(onMac[path]));
438
- if (dryRun) return { dry_run: true, files: paths.length, changed, ...(conflicts.length ? { conflicts } : {}), ...(deleteMissing ? { deleted: removable, kept_on_mac: keptOnMac } : {}), ...summary };
470
+ if (dryRun) return { dry_run: true, files: paths.length, changed, ...(conflicts.length ? { conflicts } : {}), ...(deleteMissing ? { deleted: removable, kept_on_mac: keptOnMac } : {}), ...summary, ...leftOnMac(selection, baseline) };
439
471
  let output = "";
440
472
  // Only what differs travels; a file already the same on the Mac is recorded as such.
441
473
  for (const path of send) if (previous[path] === local[path]) baseline[path] = local[path];
@@ -463,7 +495,13 @@ export async function syncProject(session, store, { overwrite = false, dryRun =
463
495
  throw error;
464
496
  }
465
497
  if (conflicts.length) throw syncConflictError(conflicts, changed.length, deleteMissing ? { deleted, kept_on_mac: keptOnMac } : {});
466
- return { files: paths.length, changed, ...(deleteMissing ? { deleted, kept_on_mac: keptOnMac } : {}), ...summary, output };
498
+ return { files: paths.length, changed, ...(deleteMissing ? { deleted, kept_on_mac: keptOnMac } : {}), ...summary, ...leftOnMac(selection, baseline), output };
499
+ }
500
+
501
+ /** Secrets an earlier CLI sent (it sent every file) that are still in the Mac's copy: sync never deletes them itself. */
502
+ function leftOnMac(selection, baseline) {
503
+ const left = selection.skipped.filter(item => item.reason === SECRET_REASON && baseline[item.path] !== undefined).map(item => item.path);
504
+ return left.length ? { secrets_left_on_mac: left } : {};
467
505
  }
468
506
 
469
507
  /** Refuse symlink ancestors, including the destination itself, before local writes. */