@skrr-ai/cli 0.1.210 → 0.1.212

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.
@@ -60,6 +60,8 @@ export type CanonicalIntentEnvelope = {
60
60
  retryAfter?: string;
61
61
  retryable?: boolean;
62
62
  initiativeId?: string;
63
+ /** The server's own words about this outcome, such as where a rerouted message goes. */
64
+ message?: string;
63
65
  /** The owner replied after this update began — withhold the tail. */
64
66
  ownerInterjected?: boolean;
65
67
  /** Whether One Voice counted this message against the owner's attention budget (OSK-22367). */
@@ -135,6 +135,7 @@ class AgentMessageSend extends base_command_1.BaseCommand {
135
135
  // send still goes through the ProactiveMessageGateway; that is the mechanism, not the purpose.
136
136
  static description = 'Send the owner a message from this Agent: it lands in their chat with the Agent (or another destination you name), and their policy decides how it reaches them. ' +
137
137
  'Send when something changes what they know or should decide: what you are starting and when they will hear back, a finding, a choice they must make, a blocker, the result. ' +
138
+ 'From a Task that an Agent dispatched in its chat, anything but an interrupt blocker may answer `held (routed_to_coordinator)`: that Agent passes it on. ' +
138
139
  'Run `agent message context` first to see what they have already read from you. ' +
139
140
  'Judgment and a worked example: `skrr guide communication pacing`.';
140
141
  // The story here (a search reindex) deliberately differs from the one in
@@ -592,6 +593,7 @@ class AgentMessageSend extends base_command_1.BaseCommand {
592
593
  retryAfter: result.retryAfter,
593
594
  retryable: result.retryable,
594
595
  initiativeId: result.initiativeId,
596
+ ...(typeof result.message === 'string' ? { message: result.message } : {}),
595
597
  ownerInterjected: result.ownerInterjected,
596
598
  oneVoice: result.oneVoice,
597
599
  },
@@ -1510,6 +1512,7 @@ function describePersonSender(envelope) {
1510
1512
  * Wording is the guide's; a reason with no entry keeps its status sentence.
1511
1513
  */
1512
1514
  const REASON_CONSEQUENCE = {
1515
+ [data_provider_1.AGENT_MESSAGE_ROUTED_REASON]: data_provider_1.AGENT_MESSAGE_ROUTED_NOTE,
1513
1516
  delivery_mode_off: "Not delivered, and the owner's delivery mode means it never will be. Say it in the conversation instead. Do not resend.",
1514
1517
  delivery_mode_suggestions_only: 'Kept as a suggestion the owner sees in the product, not sent as a message. Do not resend.',
1515
1518
  destination_not_allowed: 'Not delivered: workspace policy excludes this destination. Send to an allowed one, or ask the person to change the policy.',
@@ -36,13 +36,23 @@ class DutiesPause extends base_command_1.BaseCommand {
36
36
  // that left triggers live looked exactly like one that did not. Say which
37
37
  // happened; a reconciler will converge the degraded case, but a person
38
38
  // deciding whether they are really stopped should not have to assume it.
39
- const teardown = duty
40
- .teardown;
39
+ const teardown = duty.teardown;
41
40
  if (teardown?.status === 'degraded') {
42
41
  this.warn('The control loop is stopped, but some scheduled wakes may not have been retired yet. ' +
43
42
  'They cannot start new work — every wake is refused while this Duty is paused — ' +
44
43
  `and the reconciler retries automatically. Check with: skrr duties trigger-status ${args.id}`);
45
44
  }
45
+ // A held proposal is pinned to the Duty version it was made at, and a pause moves the version, so none
46
+ // can be approved after the resume (OSK-33390). Say so here rather than at the refusal. `null` means the
47
+ // server could not count them, which is not the same as none: say nothing rather than guess.
48
+ const voided = duty.voidedProposals;
49
+ if (typeof voided === 'number' && voided > 0) {
50
+ const one = voided === 1;
51
+ this.log(`${voided} held proposal${one ? '' : 's'} from this Duty can no longer be approved or run, ` +
52
+ `because a pause changes the Duty ${one ? 'it was' : 'they were'} made for. After you resume, ` +
53
+ `its next check can propose ${one ? 'it' : 'them'} again. ` +
54
+ `See ${one ? 'it' : 'them'} with: ${this.config.bin} duties action-proposals ${args.id}`);
55
+ }
46
56
  (0, duties_1.renderDutySummary)(duty, (line) => this.log(line));
47
57
  }
48
58
  }
@@ -91,7 +91,7 @@ function assessorSuffix(expectation) {
91
91
  if (!['met', 'waived', 'unmet'].includes(expectation.state))
92
92
  return '';
93
93
  // A person's judgement names its channel, then any tool their CLI declared, marked as declared.
94
- return ` (${(0, task_closure_1.describeAssessor)(expectation.assessedByKind, expectation.assessedByVia, expectation.assessedByDeclaredTool)})`;
94
+ return ` (${(0, task_closure_1.describeAssessor)(expectation.assessedByKind, expectation.assessedByVia, expectation.assessedByDeclaredTool, { coordinator: expectation.assessedByCoordinator })})`;
95
95
  }
96
96
  /**
97
97
  * A judgement made about a Result that is no longer the current one (OSK-15431).
@@ -226,7 +226,7 @@ class TasksExpectations extends base_command_1.BaseCommand {
226
226
  `${rejectedRows.length === 1 ? 'it' : 'them'}:`);
227
227
  for (const row of rejectedRows) {
228
228
  const who = row.assessedByKind
229
- ? ` by ${(0, task_closure_1.describeAssessor)(row.assessedByKind, row.assessedByVia, row.assessedByDeclaredTool)}`
229
+ ? ` by ${(0, task_closure_1.describeAssessor)(row.assessedByKind, row.assessedByVia, row.assessedByDeclaredTool, { coordinator: row.assessedByCoordinator })}`
230
230
  : '';
231
231
  const when = row.assessedAt ? ` on ${String(row.assessedAt).slice(0, 10)}` : '';
232
232
  this.log(` ${row.id}${who}${when}${row.reason ? `: ${row.reason}` : ''}`);
@@ -256,7 +256,7 @@ class TasksReviewQueue extends base_command_1.BaseCommand {
256
256
  ? ` on ${String(expectation.assessedAt).slice(0, 10)}`
257
257
  : '';
258
258
  const why = expectation.reason ? `: ${expectation.reason}` : '';
259
- const who = (0, task_closure_1.describeAssessor)(expectation.assessedByKind, expectation.assessedByVia, expectation.assessedByDeclaredTool);
259
+ const who = (0, task_closure_1.describeAssessor)(expectation.assessedByKind, expectation.assessedByVia, expectation.assessedByDeclaredTool, { coordinator: expectation.assessedByCoordinator });
260
260
  this.log(` ${decision} by ${who}${when}${why}`);
261
261
  }
262
262
  if (expectation.evidenceLevel) {
@@ -49,6 +49,7 @@ class Update extends core_1.Command {
49
49
  currentVersion: (0, cli_runtime_1.getCliVersion)(this.config.root),
50
50
  baseURL: (0, config_1.loadConfig)().baseURL,
51
51
  restart: flags.restart,
52
+ cliRoot: this.config.root,
52
53
  }, platform_update_local_1.localPlatformUpdateDependencies);
53
54
  if (flags.json)
54
55
  this.log(JSON.stringify(result, null, 2));
@@ -768,7 +768,7 @@
768
768
  "id": "delivery-statuses",
769
769
  "title": "Delivery statuses",
770
770
  "readWhen": "you need what a send’s status means",
771
- "tokens": 841,
771
+ "tokens": 907,
772
772
  "aliases": [],
773
773
  "explains": [
774
774
  "agent_not_authorized_for_session",
@@ -786,7 +786,7 @@
786
786
  ]
787
787
  }
788
788
  ],
789
- "hash": "23f1216a96cf6a986f480ca393a3dfd2a98700fdf3a0a9f5450b65665c888aa8",
789
+ "hash": "27dc779ef617201872f61130d88641a5743d18a6f25fdb271a8f1f40f73449c4",
790
790
  "tokens": 574
791
791
  },
792
792
  "routedIndex": {
@@ -2140,7 +2140,7 @@
2140
2140
  "routed": false,
2141
2141
  "aliases": [],
2142
2142
  "body": "## Concept model\n\nAn **Agent Update** is a deliberate owner-facing message, not a record: durable changes go in\nthe work's own records, which it points at.\n\n## Agent Updates\n\nProactively message the owner whenever it would improve their ability to steer the work, understand\na meaningful change, or stay confidently involved. Adapt to the task, uncertainty and stakes, the\nuser's engagement, what you have already communicated, and any per-agent style direction. Do not\nfollow a fixed schedule or manufacture status chatter.\n\n- Choose the semantic kind: `milestone` for a meaningful completed stage, `status` for a\n useful non-blocking checkpoint, `decision` for a concrete choice, `blocker` when user action is needed to\n continue, and one `result` for the terminal outcome (including failure).\n- Declare the attention intent with `--attention ambient|notify|interrupt`: `ambient` stays in\n the durable timeline by default, `notify` is worth seeing soon, and `interrupt` is reserved for\n work that is blocked or genuinely time-sensitive. The system and the user choose delivery channels and native\n presentation; attention never directly selects an Android channel, iOS interruption level, sound, or critical\n alert, and never bypasses notification preferences, quiet hours, Focus, or rate limits.\n- Say what is newly true and what it changes for the work. Include the next step, decision, or\n uncertainty when it would help the user; do not force every message into a fixed template.\n- Before work of more than a few minutes that they are not watching (a Task run, a Duty, or\n they are away), send a short `status`: what you are doing and roughly when they will hear back.\n- A time you gave is a promise. If you will miss it, say so before it passes, with the new estimate\n and why. When work runs long with nothing new to report, one short status around the time they\n would start to wonder keeps them confident; keep those under one status key so each replaces the\n last instead of piling up.\n- Write like a capable teammate giving a busy owner a real, in-the-moment briefing — not like a\n system log, a customer-service script, or a task template. Open on the thing itself, never on a\n subject line (\"Status on the refactor:\", \"Quick update:\"). In the user's language, lead with the\n fresh fact, decision, or risk; then make clear why it matters and what happens next. Where the\n evidence is available, ground the update in one or two useful specifics: the affected thing, the\n evidence, the timing, or the trade-off.\n Use plain, varied sentences and only the confidence the evidence earns. Keep them short: where a\n dash would staple two clauses into one, use two sentences instead. Be warm and direct, but\n never manufacture familiarity, emotion, certainty, or colour that is not true. Avoid AI-shaped\n filler such as \"I am pleased to report\", \"completed / in progress / next step\" recaps,\n \"I will continue to monitor\", \"feel free to let me know\", ceremonial thanks, and vague claims\n such as \"the optimization is complete\". Say the thing instead: \"The migration is in; the\n slowest query fell from 2.8s to 420ms. I am running the full regression now and will flag any\n breakage before merge.\" Treat that as a standard of specificity, not a rigid script. Do not make\n a message longer merely to sound human.\n- Task context and card presentation are separate: a message shows no Task Card unless you choose\n `--attach-task-card` (or `presentation.taskCard: true`). Use one only when it helps them follow\n the live task.\n- In a hand-started session, use `skrr agent message context --agent <id>` when recent\n updates, read state, or a user's reply would help your judgment. It supplies observations, not a\n schedule or a command to send.\n- In a skrr-managed session, do not pass task, run, or session identity: skrr derives it.\n In a hand-started session, add `--task <task-id>` only when you know the correct task; it is\n declared context.\n- Prefer one message for one thought. Send separate things the person would read, answer or act on\n apart as a sequence with `--part \"<next thought>\"` and one explicit semantic `--idempotency-key`, the\n most important first. One thought stays one message however long it runs: give it paragraphs. Never\n split text mechanically. If one part does not reach the user, the remaining parts are deliberately not\n sent — the user would otherwise read your thoughts out of order.\n- An idempotency key names ONE update for this agent permanently, so make it specific to this run\n (for example `<task-id>:verify-complete`). Reuse it only to retry that same update: reused with\n the same text it is dropped as a duplicate, and with different text it is rejected.\n- A non-`delivered` status (`held`, `approval_required`, `duplicate`, `dropped`) is a policy\n outcome, not an error. It is never a reason to bypass this command with a direct DM or Slack\n call — this is the only sanctioned agent-to-user path.\n\n## Authority\n\n| Actor | May do | Only a person may do |\n| --- | --- | --- |\n| Agent | Decide to message, and its kind, attention, task and card | Choose the channel and presentation; release a held or approval-gated intent |\n| Person | Everything an Agent may do | — |\n\n## Live state\n\n- `skrr agent message context --agent <id>` (above); inside a session it also reports what this\n turn has sent (`currentTurn`).\n\n## Related guides\n\n- `tasks` — the records an update points at.\n- `agents` — which Agent a session speaks as (`identity`).",
2143
- "hash": "f9921f75061708884a5212401a774a55c75f388b51a854fdd3627d328633637a",
2143
+ "hash": "bf02c86c2cc54ef96db9f63767c62333675dbfa8f9214a9c1da170aa84b7a26b",
2144
2144
  "tokens": 1454,
2145
2145
  "sections": [
2146
2146
  {
@@ -2245,7 +2245,7 @@
2245
2245
  "id": "delivery-statuses",
2246
2246
  "title": "Delivery statuses",
2247
2247
  "readWhen": "you need what a send’s status means",
2248
- "tokens": 841,
2248
+ "tokens": 907,
2249
2249
  "aliases": [],
2250
2250
  "explains": [
2251
2251
  "agent_not_authorized_for_session",
@@ -8573,7 +8573,7 @@
8573
8573
  "id": "delivery-statuses",
8574
8574
  "title": "Delivery statuses",
8575
8575
  "readWhen": "you need what a send’s status means",
8576
- "tokens": 841,
8576
+ "tokens": 907,
8577
8577
  "aliases": [],
8578
8578
  "explains": [
8579
8579
  "agent_not_authorized_for_session",
@@ -8716,7 +8716,7 @@
8716
8716
  "id": "delivery-statuses",
8717
8717
  "title": "Delivery statuses",
8718
8718
  "readWhen": "you need what a send’s status means",
8719
- "tokens": 841,
8719
+ "tokens": 907,
8720
8720
  "aliases": [],
8721
8721
  "explains": [
8722
8722
  "agent_not_authorized_for_session",
@@ -8852,7 +8852,7 @@
8852
8852
  "id": "delivery-statuses",
8853
8853
  "title": "Delivery statuses",
8854
8854
  "readWhen": "you need what a send’s status means",
8855
- "tokens": 841,
8855
+ "tokens": 907,
8856
8856
  "aliases": [],
8857
8857
  "explains": [
8858
8858
  "agent_not_authorized_for_session",
@@ -8987,7 +8987,7 @@
8987
8987
  "id": "delivery-statuses",
8988
8988
  "title": "Delivery statuses",
8989
8989
  "readWhen": "you need what a send’s status means",
8990
- "tokens": 841,
8990
+ "tokens": 907,
8991
8991
  "aliases": [],
8992
8992
  "explains": [
8993
8993
  "agent_not_authorized_for_session",
@@ -9133,7 +9133,7 @@
9133
9133
  "id": "delivery-statuses",
9134
9134
  "title": "Delivery statuses",
9135
9135
  "readWhen": "you need what a send’s status means",
9136
- "tokens": 841,
9136
+ "tokens": 907,
9137
9137
  "aliases": [],
9138
9138
  "explains": [
9139
9139
  "agent_not_authorized_for_session",
@@ -9274,7 +9274,7 @@
9274
9274
  "id": "delivery-statuses",
9275
9275
  "title": "Delivery statuses",
9276
9276
  "readWhen": "you need what a send’s status means",
9277
- "tokens": 841,
9277
+ "tokens": 907,
9278
9278
  "aliases": [],
9279
9279
  "explains": [
9280
9280
  "agent_not_authorized_for_session",
@@ -9413,7 +9413,7 @@
9413
9413
  "id": "delivery-statuses",
9414
9414
  "title": "Delivery statuses",
9415
9415
  "readWhen": "you need what a send’s status means",
9416
- "tokens": 841,
9416
+ "tokens": 907,
9417
9417
  "aliases": [],
9418
9418
  "explains": [
9419
9419
  "agent_not_authorized_for_session",
@@ -9451,9 +9451,9 @@
9451
9451
  "delivery_mode_ask_first",
9452
9452
  "delivery_policy_unavailable"
9453
9453
  ],
9454
- "body": "Read this when a send answered and you need to know what its status means.\n\n| Status | Meaning |\n| --- | --- |\n| `submitted` | recorded, not yet dispatched — still owned by the platform |\n| `held` | policy withheld it for now; it may still be delivered — `reason` says why |\n| `re_evaluation` | being re-checked against policy — still owned by the platform |\n| `approval_required` | waiting on the person’s approval; they decide it by `intent.id` (`initiativeId` only for agent email) |\n| `authorized` | cleared for dispatch — still owned by the platform |\n| `dispatching` | being delivered right now |\n| `delivered` | reached the user |\n| `transport_failed` | delivery errored; `retryable` and `retryAfter` say whether to try again |\n| `dropped` | will not be delivered — read `reason` and change the request before resending |\n| `expired` | outlived its window before delivery |\n| `cancelled` | withdrawn before delivery |\n| `duplicate` | the idempotency key already carried this identical update — the earlier send stands |\n| `accepted` | an earlier send already delivered this update |\n| `failed` | the transport could not deliver; `retryable` says whether a retry can help |\n| `queued_offline` | held by the local daemon until it can reach the platform — still in flight |\n| `refused` | a guard declined the send; `reason` names it |\n| `unknown` | the transport could not certify the outcome |\n\nA `held`, `approval_required` or `dropped` result carries `reason`; a transport\nfailure carries `retryable` and `retryAfter`. The exit code is `0` while the\nplatform still owns the outcome — `3` is retryable non-delivery, `4` terminal.\n\nAn approval to the person is decided by the message's own id (`intent.id`, which\nreads `pmi_…`): they list it with `skrr agent message pending` and decide it with\n`approve` or `decline`. Only an `agent_email` approval carries `initiativeId`, so\ndo not wait for one on a message to the person. `ok` is `true` for a single send\nthat was held; a sequence that stopped early reports `ok: false` with `halt` (see\nthe parts guide) while the exit code stays `0`.\n\n## Refusals\n\n| Code | Cause | Fix |\n| --- | --- | --- |\n| `agent_not_authorized_for_session` | The send names an agent the session is not bound to | Drop `--agent`, or send as the agent the session runs |\n| `session_claim_required` | No session or claim authorizes the send | Run inside the managed session, or sign in and send as the person |\n| `context_task_not_authorized_for_session` | The declared `--task` is not this session's | Omit `--task`; a managed session derives it |\n| `task_context_forbidden` | The declared task was not found or is not accessible in this workspace | Check the task and workspace, or omit `--task` |\n| `main_chat_disabled` | The owner's main chat is off | Tell the person; do not route around it |\n| `destination_not_allowed` | Workspace policy excludes this destination | Send to an allowed destination, or ask the person to change policy |\n| `delivery_mode_off` | The owner's delivery mode delivers nothing | Do not resend; say it in the conversation instead |\n| `delivery_mode_suggestions_only` | Policy keeps the update as a suggestion | Leave it — the person sees it in-product |\n| `delivery_mode_ask_first` | Policy wants the person's approval first | Wait for the approval; do not resend |\n| `delivery_policy_unavailable` | Policy could not be read, so the send failed closed | Retry once; if it repeats, tell the person |",
9455
- "hash": "fa45eaa4cb64467e2695fb3fee8ef4320e7e574db66d5c22d4afd8865f6cea86",
9456
- "tokens": 841,
9454
+ "body": "Read this when a send answered and you need to know what its status means.\n\n| Status | Meaning |\n| --- | --- |\n| `submitted` | recorded, not yet dispatched — still owned by the platform |\n| `held` | policy withheld it for now; it may still be delivered — `reason` says why |\n| `re_evaluation` | being re-checked against policy — still owned by the platform |\n| `approval_required` | waiting on the person’s approval; they decide it by `intent.id` (`initiativeId` only for agent email) |\n| `authorized` | cleared for dispatch — still owned by the platform |\n| `dispatching` | being delivered right now |\n| `delivered` | reached the user |\n| `transport_failed` | delivery errored; `retryable` and `retryAfter` say whether to try again |\n| `dropped` | will not be delivered — read `reason` and change the request before resending |\n| `expired` | outlived its window before delivery |\n| `cancelled` | withdrawn before delivery |\n| `duplicate` | the idempotency key already carried this identical update — the earlier send stands |\n| `accepted` | an earlier send already delivered this update |\n| `failed` | the transport could not deliver; `retryable` says whether a retry can help |\n| `queued_offline` | held by the local daemon until it can reach the platform — still in flight |\n| `refused` | a guard declined the send; `reason` names it |\n| `unknown` | the transport could not certify the outcome |\n\nA `held`, `approval_required` or `dropped` result carries `reason`; a transport\nfailure carries `retryable` and `retryAfter`. The exit code is `0` while the\nplatform still owns the outcome — `3` is retryable non-delivery, `4` terminal.\n\nAn approval to the person is decided by the message's own id (`intent.id`, which\nreads `pmi_…`): they list it with `skrr agent message pending` and decide it with\n`approve` or `decline`. Only an `agent_email` approval carries `initiativeId`, so\ndo not wait for one on a message to the person. `ok` is `true` for a single send\nthat was held; a sequence that stopped early reports `ok: false` with `halt` (see\nthe parts guide) while the exit code stays `0`.\n\n`held` with `routed_to_coordinator` answers a Task another Agent dispatched in its\nchat: the update is recorded on the Task as progress, and that Agent passes on what the\nperson still needs to hear. Do not resend. A `blocker` with attention `interrupt` goes\nto them directly.\n\n## Refusals\n\n| Code | Cause | Fix |\n| --- | --- | --- |\n| `agent_not_authorized_for_session` | The send names an agent the session is not bound to | Drop `--agent`, or send as the agent the session runs |\n| `session_claim_required` | No session or claim authorizes the send | Run inside the managed session, or sign in and send as the person |\n| `context_task_not_authorized_for_session` | The declared `--task` is not this session's | Omit `--task`; a managed session derives it |\n| `task_context_forbidden` | The declared task was not found or is not accessible in this workspace | Check the task and workspace, or omit `--task` |\n| `main_chat_disabled` | The owner's main chat is off | Tell the person; do not route around it |\n| `destination_not_allowed` | Workspace policy excludes this destination | Send to an allowed destination, or ask the person to change policy |\n| `delivery_mode_off` | The owner's delivery mode delivers nothing | Do not resend; say it in the conversation instead |\n| `delivery_mode_suggestions_only` | Policy keeps the update as a suggestion | Leave it — the person sees it in-product |\n| `delivery_mode_ask_first` | Policy wants the person's approval first | Wait for the approval; do not resend |\n| `delivery_policy_unavailable` | Policy could not be read, so the send failed closed | Retry once; if it repeats, tell the person |",
9455
+ "hash": "5ab72f28bd5a64bdf84d81625a05229a8d2367ff7a7db6f0d726b2b1a5842fd3",
9456
+ "tokens": 907,
9457
9457
  "sections": [
9458
9458
  {
9459
9459
  "id": "pacing",
@@ -9557,7 +9557,7 @@
9557
9557
  "id": "delivery-statuses",
9558
9558
  "title": "Delivery statuses",
9559
9559
  "readWhen": "you need what a send’s status means",
9560
- "tokens": 841,
9560
+ "tokens": 907,
9561
9561
  "aliases": [],
9562
9562
  "explains": [
9563
9563
  "agent_not_authorized_for_session",
@@ -49,4 +49,58 @@ export type CliInstallationDiagnosticsOptions = {
49
49
  * unrecognised rather than trusted.
50
50
  */
51
51
  export declare function inspectCliInstallations(options?: CliInstallationDiagnosticsOptions): CliInstallationDiagnostics;
52
+ /** A directory in a login shell's search order, and the file that listed it. */
53
+ export type LoginShellDirectory = {
54
+ dir: string;
55
+ /** `/etc/paths`, a file in `/etc/paths.d`, or `PATH` when it was inherited. */
56
+ listedBy: string;
57
+ };
58
+ /**
59
+ * The order a macOS login shell searches, given the PATH it inherited (OSK-23562).
60
+ *
61
+ * `/etc/profile` and `/etc/zprofile` run `path_helper -s`, which rebuilds PATH as
62
+ * the lines of `/etc/paths`, then each file in `/etc/paths.d` in name order, then
63
+ * the inherited entries it has not already listed. So `/opt/homebrew/bin` (from
64
+ * `/etc/paths.d/homebrew`) outranks `~/.local/bin` in every login shell, whatever
65
+ * order the PATH had. The daemon reads the same rule for `skrrd status`
66
+ * (`daemon/src/session-sky.ts`); a user's own profile is not modelled, because
67
+ * reading it means running it.
68
+ */
69
+ export declare function macosLoginShellSearchPath(inheritedPath: string | undefined, etcDir?: string): LoginShellDirectory[];
70
+ export type CliShadow = {
71
+ /** `path`: the caller's own PATH. `login_shell`: a macOS login shell started from it. */
72
+ kind: 'path' | 'login_shell';
73
+ path: string;
74
+ version: string;
75
+ packageRoot: string;
76
+ /** For `login_shell`, the file that put this copy's directory first. */
77
+ listedBy: string | null;
78
+ message: string;
79
+ };
80
+ export type CliShadowOptions = {
81
+ /** The package root of the CLI this command runs from, which `skrr update` updates. */
82
+ activeRoot: string;
83
+ activeEntry?: string;
84
+ env?: NodeJS.ProcessEnv;
85
+ platform?: NodeJS.Platform;
86
+ /** Where `paths` and `paths.d` live; `/etc` outside tests. */
87
+ etcDir?: string;
88
+ /**
89
+ * The version this update leaves in place, when the package on disk is not it
90
+ * yet: `performCliUpdate` hands the install to a worker, so `activeRoot` still
91
+ * holds the old version when it returns. Defaults to the version on disk.
92
+ */
93
+ targetVersion?: string | null;
94
+ };
95
+ /**
96
+ * Other `skrr` installations that run instead of this one (OSK-23562).
97
+ *
98
+ * `skrr update --component cli` replaces the CLI it runs from. A second copy
99
+ * earlier on PATH keeps answering `skrr`, and on macOS a login shell can choose
100
+ * yet another: an agent harness that ran each command in `zsh -lc` got an
101
+ * npm-global 0.1.127 under Homebrew's node while this updater had just installed
102
+ * 0.1.209 in `~/.local`. Read-only, like `inspectCliInstallations`: no candidate is
103
+ * executed and no PATH is changed.
104
+ */
105
+ export declare function inspectCliShadows(options: CliShadowOptions): CliShadow[];
52
106
  export {};
@@ -34,8 +34,11 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.inspectCliInstallations = inspectCliInstallations;
37
+ exports.macosLoginShellSearchPath = macosLoginShellSearchPath;
38
+ exports.inspectCliShadows = inspectCliShadows;
37
39
  const fs = __importStar(require("node:fs"));
38
40
  const path = __importStar(require("node:path"));
41
+ const auth_core_1 = require("@skrr-ai/auth-core");
39
42
  const update_check_1 = require("./update-check");
40
43
  const CLI_PACKAGE_NAME = '@skrr-ai/cli';
41
44
  /**
@@ -103,10 +106,13 @@ function inspectCliInstallations(options = {}) {
103
106
  }))
104
107
  .sort(compareCandidates);
105
108
  const active = rows.find((candidate) => candidate.active) ?? null;
106
- const pathVersions = [...new Set(rows
109
+ const pathVersions = [
110
+ ...new Set(rows
107
111
  .filter((candidate) => candidate.pathPrecedence !== null)
108
- .sort((a, b) => (a.pathPrecedence ?? Number.MAX_SAFE_INTEGER) - (b.pathPrecedence ?? Number.MAX_SAFE_INTEGER))
109
- .map((candidate) => candidate.version))];
112
+ .sort((a, b) => (a.pathPrecedence ?? Number.MAX_SAFE_INTEGER) -
113
+ (b.pathPrecedence ?? Number.MAX_SAFE_INTEGER))
114
+ .map((candidate) => candidate.version)),
115
+ ];
110
116
  const hasVersionDrift = pathVersions.length > 1;
111
117
  return {
112
118
  active,
@@ -123,19 +129,20 @@ function addCandidate(candidates, packageInfo, location, env) {
123
129
  const install = existing
124
130
  ? null
125
131
  : (0, update_check_1.classifyCliInstall)(env, [process.execPath, location.path], null, false);
126
- const candidate = existing ?? {
127
- paths: new Set(),
128
- realPath: location.realPath,
129
- packageRoot: packageInfo.packageRoot,
130
- version: packageInfo.version,
131
- // Read-only classification: doctor never creates a write-probe just to
132
- // identify an installation.
133
- owner: install.kind,
134
- updateCommand: (0, update_check_1.cliUpdateCommand)(install.kind, install.npmPrefix),
135
- sources: new Set(),
136
- pathPrecedence: location.pathPrecedence,
137
- active: false,
138
- };
132
+ const candidate = existing ??
133
+ {
134
+ paths: new Set(),
135
+ realPath: location.realPath,
136
+ packageRoot: packageInfo.packageRoot,
137
+ version: packageInfo.version,
138
+ // Read-only classification: doctor never creates a write-probe just to
139
+ // identify an installation.
140
+ owner: install.kind,
141
+ updateCommand: (0, update_check_1.cliUpdateCommand)(install.kind, install.npmPrefix),
142
+ sources: new Set(),
143
+ pathPrecedence: location.pathPrecedence,
144
+ active: false,
145
+ };
139
146
  if (!existing)
140
147
  candidates.set(key, candidate);
141
148
  candidate.paths.add(location.path);
@@ -152,7 +159,12 @@ function executableLocations(options) {
152
159
  const names = options.platform === 'win32' ? ['skrr.exe', 'skrr.cmd'] : ['skrr'];
153
160
  const locations = [];
154
161
  if (options.activeEntry) {
155
- locations.push({ path: options.activeEntry, realPath: realPath(options.activeEntry), source: 'active', pathPrecedence: null });
162
+ locations.push({
163
+ path: options.activeEntry,
164
+ realPath: realPath(options.activeEntry),
165
+ source: 'active',
166
+ pathPrecedence: null,
167
+ });
156
168
  }
157
169
  const seenPath = new Set();
158
170
  for (const [index, directory] of options.pathValue.split(path.delimiter).entries()) {
@@ -163,7 +175,12 @@ function executableLocations(options) {
163
175
  if (!isExecutable(candidate, options.platform) || seenPath.has(candidate))
164
176
  continue;
165
177
  seenPath.add(candidate);
166
- locations.push({ path: candidate, realPath: realPath(candidate), source: 'path', pathPrecedence: index });
178
+ locations.push({
179
+ path: candidate,
180
+ realPath: realPath(candidate),
181
+ source: 'path',
182
+ pathPrecedence: index,
183
+ });
167
184
  }
168
185
  }
169
186
  for (const candidate of options.wellKnownPaths) {
@@ -171,7 +188,12 @@ function executableLocations(options) {
171
188
  if (!isExecutable(resolved, options.platform) || seenPath.has(resolved))
172
189
  continue;
173
190
  seenPath.add(resolved);
174
- locations.push({ path: resolved, realPath: realPath(resolved), source: 'well_known', pathPrecedence: null });
191
+ locations.push({
192
+ path: resolved,
193
+ realPath: realPath(resolved),
194
+ source: 'well_known',
195
+ pathPrecedence: null,
196
+ });
175
197
  }
176
198
  return locations;
177
199
  }
@@ -244,7 +266,8 @@ function compareCandidates(a, b) {
244
266
  function versionDriftRemedy(candidates, active) {
245
267
  const pathCandidates = candidates
246
268
  .filter((candidate) => candidate.pathPrecedence !== null)
247
- .sort((a, b) => (a.pathPrecedence ?? Number.MAX_SAFE_INTEGER) - (b.pathPrecedence ?? Number.MAX_SAFE_INTEGER));
269
+ .sort((a, b) => (a.pathPrecedence ?? Number.MAX_SAFE_INTEGER) -
270
+ (b.pathPrecedence ?? Number.MAX_SAFE_INTEGER));
248
271
  const selected = pathCandidates[0] ?? active;
249
272
  if (!selected)
250
273
  return 'Inspect the skrr entries on PATH, update the intended installation, then re-run `skrr doctor`.';
@@ -252,3 +275,145 @@ function versionDriftRemedy(candidates, active) {
252
275
  `\`${selected.updateCommand}\`, then remove or reorder the other skrr entries using their owning package manager. ` +
253
276
  'No PATH changes were made. Verify with `skrr update --component cli --check` and `skrr doctor`.');
254
277
  }
278
+ function listedDirectories(file) {
279
+ try {
280
+ return fs
281
+ .readFileSync(file, 'utf8')
282
+ .split('\n')
283
+ .map((line) => line.trim())
284
+ .filter(Boolean);
285
+ }
286
+ catch {
287
+ return [];
288
+ }
289
+ }
290
+ /**
291
+ * The order a macOS login shell searches, given the PATH it inherited (OSK-23562).
292
+ *
293
+ * `/etc/profile` and `/etc/zprofile` run `path_helper -s`, which rebuilds PATH as
294
+ * the lines of `/etc/paths`, then each file in `/etc/paths.d` in name order, then
295
+ * the inherited entries it has not already listed. So `/opt/homebrew/bin` (from
296
+ * `/etc/paths.d/homebrew`) outranks `~/.local/bin` in every login shell, whatever
297
+ * order the PATH had. The daemon reads the same rule for `skrrd status`
298
+ * (`daemon/src/session-sky.ts`); a user's own profile is not modelled, because
299
+ * reading it means running it.
300
+ */
301
+ function macosLoginShellSearchPath(inheritedPath, etcDir = '/etc') {
302
+ const sources = [path.join(etcDir, 'paths')];
303
+ try {
304
+ const dropIns = path.join(etcDir, 'paths.d');
305
+ for (const name of fs.readdirSync(dropIns).sort())
306
+ sources.push(path.join(dropIns, name));
307
+ }
308
+ catch {
309
+ /* no drop-ins */
310
+ }
311
+ const out = [];
312
+ const seen = new Set();
313
+ const add = (dir, listedBy) => {
314
+ if (!dir || seen.has(dir))
315
+ return;
316
+ seen.add(dir);
317
+ out.push({ dir, listedBy });
318
+ };
319
+ for (const listedBy of sources) {
320
+ for (const dir of listedDirectories(listedBy))
321
+ add(dir, listedBy);
322
+ }
323
+ for (const dir of String(inheritedPath ?? '').split(':'))
324
+ add(dir, 'PATH');
325
+ return out;
326
+ }
327
+ function firstOnPath(diagnostics) {
328
+ return (diagnostics.candidates
329
+ .filter((candidate) => candidate.pathPrecedence !== null)
330
+ .sort((a, b) => (a.pathPrecedence ?? 0) - (b.pathPrecedence ?? 0))[0] ?? null);
331
+ }
332
+ const NPM_PREFIX_TAIL = path.join('lib', 'node_modules', '@skrr-ai', 'cli');
333
+ /**
334
+ * How to retire a shadowing copy. Retire, not pin: a second npm prefix updated to
335
+ * today's version is stale again at the next release, and removing it from its own
336
+ * prefix is what fixed the machine this was found on. Other owners keep their own
337
+ * update command, which never names an old version.
338
+ */
339
+ function retireCommand(shadow) {
340
+ if (shadow.packageRoot.endsWith(`${path.sep}${NPM_PREFIX_TAIL}`)) {
341
+ const prefix = shadow.packageRoot.slice(0, -NPM_PREFIX_TAIL.length - 1);
342
+ const quoted = `'${prefix.replace(/'/g, "'\\''")}'`;
343
+ return `Remove it with \`npm uninstall --global --prefix ${quoted} ${CLI_PACKAGE_NAME}\`.`;
344
+ }
345
+ return `Remove it, or update it with \`${shadow.updateCommand}\`.`;
346
+ }
347
+ /** Only a copy known to be OLDER than the target is a problem; a newer one is not. */
348
+ function isOlder(version, target) {
349
+ return (0, auth_core_1.compareReleaseVersions)(version, target) === -1;
350
+ }
351
+ /**
352
+ * Other `skrr` installations that run instead of this one (OSK-23562).
353
+ *
354
+ * `skrr update --component cli` replaces the CLI it runs from. A second copy
355
+ * earlier on PATH keeps answering `skrr`, and on macOS a login shell can choose
356
+ * yet another: an agent harness that ran each command in `zsh -lc` got an
357
+ * npm-global 0.1.127 under Homebrew's node while this updater had just installed
358
+ * 0.1.209 in `~/.local`. Read-only, like `inspectCliInstallations`: no candidate is
359
+ * executed and no PATH is changed.
360
+ */
361
+ function inspectCliShadows(options) {
362
+ const env = options.env ?? process.env;
363
+ const platform = options.platform ?? process.platform;
364
+ const base = {
365
+ activeRoot: options.activeRoot,
366
+ activeEntry: options.activeEntry,
367
+ platform,
368
+ wellKnownPaths: [],
369
+ };
370
+ const onPath = inspectCliInstallations({ ...base, env });
371
+ const active = onPath.active;
372
+ if (!active)
373
+ return [];
374
+ const target = options.targetVersion || active.version;
375
+ const activeLabel = `${active.paths[0] ?? active.packageRoot}, v${target}`;
376
+ const shadows = [];
377
+ const first = firstOnPath(onPath);
378
+ if (first && !first.active && isOlder(first.version, target)) {
379
+ shadows.push({
380
+ kind: 'path',
381
+ path: first.paths[0],
382
+ version: first.version,
383
+ packageRoot: first.packageRoot,
384
+ listedBy: null,
385
+ message: `${first.paths[0]} (v${first.version}) comes first on your PATH, so \`skrr\` runs it, not the ` +
386
+ `CLI this command updates (${activeLabel}). ${retireCommand(first)}`,
387
+ });
388
+ }
389
+ if (platform === 'darwin') {
390
+ const order = macosLoginShellSearchPath(env.PATH, options.etcDir);
391
+ const login = inspectCliInstallations({
392
+ ...base,
393
+ env: { ...env, PATH: order.map((entry) => entry.dir).join(path.delimiter) },
394
+ });
395
+ const winner = firstOnPath(login);
396
+ if (winner &&
397
+ !winner.active &&
398
+ winner.packageRoot !== first?.packageRoot &&
399
+ isOlder(winner.version, target)) {
400
+ const listing = order[winner.pathPrecedence ?? -1];
401
+ const listedBy = listing && listing.listedBy !== 'PATH' ? listing.listedBy : null;
402
+ shadows.push({
403
+ kind: 'login_shell',
404
+ path: winner.paths[0],
405
+ version: winner.version,
406
+ packageRoot: winner.packageRoot,
407
+ listedBy,
408
+ message: `Login shells run ${winner.paths[0]} (v${winner.version}), not the CLI this command updates ` +
409
+ `(${activeLabel})` +
410
+ (listedBy
411
+ ? `: macOS path_helper puts ${listing.dir} (listed in ${listedBy}) ahead of your PATH`
412
+ : '') +
413
+ '. Agent harnesses that run commands in a login shell (Codex runs `zsh -lc`) get that copy. ' +
414
+ retireCommand(winner),
415
+ });
416
+ }
417
+ }
418
+ return shadows;
419
+ }
@@ -1,2 +1,11 @@
1
- import type { PlatformUpdateDependencies } from './platform-update';
1
+ import type { PlatformUpdateDependencies, PlatformUpdateOptions } from './platform-update';
2
+ /**
3
+ * The `skrr` copies that run instead of the one a CLI update replaces (OSK-23562).
4
+ * A diagnostic, so it never fails the update it rides on.
5
+ */
6
+ export declare function cliShadowWarnings(options: PlatformUpdateOptions, status: {
7
+ state?: string;
8
+ installedVersion?: string | null;
9
+ offeredVersion?: string | null;
10
+ }): string[];
2
11
  export declare const localPlatformUpdateDependencies: PlatformUpdateDependencies;
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.localPlatformUpdateDependencies = void 0;
4
+ exports.cliShadowWarnings = cliShadowWarnings;
4
5
  const update_check_1 = require("./update-check");
5
6
  const first_party_harness_update_1 = require("./first-party-harness-update");
6
7
  const exec_runtime_binary_1 = require("./exec-runtime-binary");
8
+ const cli_installation_diagnostics_1 = require("./cli-installation-diagnostics");
7
9
  const DAEMON_STATUS_RE = /^v?(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?)$/;
8
10
  function parseDaemonStatus(stdout) {
9
11
  let parsed;
@@ -85,6 +87,28 @@ async function updateDaemon(mode, options) {
85
87
  },
86
88
  };
87
89
  }
90
+ /**
91
+ * The `skrr` copies that run instead of the one a CLI update replaces (OSK-23562).
92
+ * A diagnostic, so it never fails the update it rides on.
93
+ */
94
+ function cliShadowWarnings(options, status) {
95
+ if (!options.cliRoot)
96
+ return [];
97
+ // An apply that handed the install to a worker returns before the package on
98
+ // disk changes, so the version to compare a shadow with is the one on its way.
99
+ const installing = options.mode === 'apply' && (status.state === 'pending' || status.state === 'restart-pending');
100
+ const targetVersion = (installing ? status.offeredVersion : null) ?? status.installedVersion;
101
+ try {
102
+ return (0, cli_installation_diagnostics_1.inspectCliShadows)({
103
+ activeRoot: options.cliRoot,
104
+ env: options.env,
105
+ targetVersion,
106
+ }).map((shadow) => shadow.message);
107
+ }
108
+ catch {
109
+ return [];
110
+ }
111
+ }
88
112
  exports.localPlatformUpdateDependencies = {
89
113
  async cli(mode, options) {
90
114
  const args = {
@@ -92,11 +116,15 @@ exports.localPlatformUpdateDependencies = {
92
116
  baseURL: options.baseURL,
93
117
  env: options.env,
94
118
  };
119
+ let status;
95
120
  if (mode === 'status')
96
- return (0, update_check_1.readCliUpdateStatus)(args);
97
- if (mode === 'check')
98
- return (0, update_check_1.checkCliUpdate)({ ...args, force: true });
99
- return (0, update_check_1.performCliUpdate)(args);
121
+ status = (0, update_check_1.readCliUpdateStatus)(args);
122
+ else if (mode === 'check')
123
+ status = await (0, update_check_1.checkCliUpdate)({ ...args, force: true });
124
+ else
125
+ status = await (0, update_check_1.performCliUpdate)(args);
126
+ const warnings = cliShadowWarnings({ ...options, mode }, status);
127
+ return warnings.length > 0 ? { ...status, warnings } : status;
100
128
  },
101
129
  async code(mode, options) {
102
130
  if (mode === 'status')