tenjin-cli 0.1.0-alpha.16 → 0.1.0-alpha.18

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.
Files changed (116) hide show
  1. package/README.md +5 -0
  2. package/dist/chunk-2G2WLVHB.js +102 -0
  3. package/dist/chunk-2G2WLVHB.js.map +1 -0
  4. package/dist/chunk-2I4QTOLB.js +11 -0
  5. package/dist/chunk-2I4QTOLB.js.map +1 -0
  6. package/dist/chunk-35M3VITA.js +102 -0
  7. package/dist/chunk-35M3VITA.js.map +1 -0
  8. package/dist/chunk-3KKKB2AQ.js +40 -0
  9. package/dist/chunk-3KKKB2AQ.js.map +1 -0
  10. package/dist/{chunk-OIM4HLN6.js → chunk-7QKHZQKW.js} +295 -20
  11. package/dist/chunk-7QKHZQKW.js.map +1 -0
  12. package/dist/{chunk-BBVUVBUO.js → chunk-AR7U7BRG.js} +44 -7
  13. package/dist/{chunk-BBVUVBUO.js.map → chunk-AR7U7BRG.js.map} +1 -1
  14. package/dist/{chunk-DMZZLPZN.js → chunk-AUKDYPPX.js} +14 -89
  15. package/dist/chunk-AUKDYPPX.js.map +1 -0
  16. package/dist/{chunk-56MOAIP5.js → chunk-BTX2QE2Y.js} +9 -6
  17. package/dist/chunk-BTX2QE2Y.js.map +1 -0
  18. package/dist/{chunk-HVRC33OL.js → chunk-EPCOMXLF.js} +4 -6
  19. package/dist/{chunk-HVRC33OL.js.map → chunk-EPCOMXLF.js.map} +1 -1
  20. package/dist/{chunk-25TJPVBF.js → chunk-F3FUGWPZ.js} +28 -15
  21. package/dist/chunk-F3FUGWPZ.js.map +1 -0
  22. package/dist/{chunk-2U5ZVEV3.js → chunk-FGR734LZ.js} +6 -6
  23. package/dist/{chunk-PZEN5PHN.js → chunk-J5INH7WB.js} +17 -3
  24. package/dist/chunk-J5INH7WB.js.map +1 -0
  25. package/dist/{chunk-7WEQQJLG.js → chunk-JLEF5WHM.js} +66 -2
  26. package/dist/chunk-JLEF5WHM.js.map +1 -0
  27. package/dist/{chunk-YEETV6IW.js → chunk-KUBEYXSO.js} +10 -12
  28. package/dist/{chunk-YEETV6IW.js.map → chunk-KUBEYXSO.js.map} +1 -1
  29. package/dist/{chunk-L3PVMIYQ.js → chunk-N44H5TFB.js} +82 -150
  30. package/dist/chunk-N44H5TFB.js.map +1 -0
  31. package/dist/{chunk-BFFM2WFK.js → chunk-NRQMOVKM.js} +2 -2
  32. package/dist/{chunk-BFFM2WFK.js.map → chunk-NRQMOVKM.js.map} +1 -1
  33. package/dist/{chunk-GULLJQXA.js → chunk-ON6C6WOX.js} +127 -17
  34. package/dist/chunk-ON6C6WOX.js.map +1 -0
  35. package/dist/{chunk-OJLYNM4Z.js → chunk-PDA2BVFY.js} +77 -19
  36. package/dist/chunk-PDA2BVFY.js.map +1 -0
  37. package/dist/chunk-S2NRVRPF.js +171 -0
  38. package/dist/chunk-S2NRVRPF.js.map +1 -0
  39. package/dist/chunk-TGLKKLQG.js +11 -0
  40. package/dist/chunk-TGLKKLQG.js.map +1 -0
  41. package/dist/{chunk-SKAHDQH7.js → chunk-TJMCBIZU.js} +6 -7
  42. package/dist/{chunk-SKAHDQH7.js.map → chunk-TJMCBIZU.js.map} +1 -1
  43. package/dist/chunk-TP4D47BY.js +127 -0
  44. package/dist/chunk-TP4D47BY.js.map +1 -0
  45. package/dist/{chunk-WH7OWT6G.js → chunk-U2DZISAH.js} +2 -8
  46. package/dist/chunk-U2DZISAH.js.map +1 -0
  47. package/dist/{chunk-YJHHCWM3.js → chunk-WLMJE3GJ.js} +3 -3
  48. package/dist/{chunk-U5DXNFJC.js → chunk-WS4JA6TC.js} +3 -3
  49. package/dist/{chunk-5X4SZ5BF.js → chunk-WUHY2AXD.js} +4 -4
  50. package/dist/{chunk-USS336NF.js → chunk-YPQSMIDH.js} +5 -5
  51. package/dist/chunk-YPQSMIDH.js.map +1 -0
  52. package/dist/{chunk-3AJS6LLN.js → chunk-ZG7SFI34.js} +7 -7
  53. package/dist/{cli-M3XCSOU6.js → cli-MP3RAYHL.js} +43 -29
  54. package/dist/{cli-M3XCSOU6.js.map → cli-MP3RAYHL.js.map} +1 -1
  55. package/dist/{config-MXOX7XDR.js → config-BJK6U5VY.js} +11 -10
  56. package/dist/{doctor-LU4YIZWM.js → doctor-KJROWE5V.js} +108 -21
  57. package/dist/doctor-KJROWE5V.js.map +1 -0
  58. package/dist/{fund-A54P2QFK.js → fund-I5COXPEJ.js} +13 -11
  59. package/dist/{fund-A54P2QFK.js.map → fund-I5COXPEJ.js.map} +1 -1
  60. package/dist/hook-command-EJO2564A.js +821 -0
  61. package/dist/hook-command-EJO2564A.js.map +1 -0
  62. package/dist/index.js +2 -2
  63. package/dist/{install-XUM2XSHW.js → install-NUQLLHS2.js} +21 -14
  64. package/dist/{install-wallet-QIOFORTX.js → install-wallet-JPFTEC6H.js} +12 -10
  65. package/dist/{install-wallet-QIOFORTX.js.map → install-wallet-JPFTEC6H.js.map} +1 -1
  66. package/dist/{mcp-HJC2PLRV.js → mcp-I5XMVE64.js} +77 -34
  67. package/dist/{mcp-HJC2PLRV.js.map → mcp-I5XMVE64.js.map} +1 -1
  68. package/dist/{pay-SBXZEPEP.js → pay-WA3JSCNB.js} +21 -14
  69. package/dist/{redact-46ZHF2NH.js → redact-6W23GGJC.js} +4 -6
  70. package/dist/{send-ASD2ZXJD.js → send-KVUH5WDO.js} +12 -10
  71. package/dist/{send-ASD2ZXJD.js.map → send-KVUH5WDO.js.map} +1 -1
  72. package/dist/{skill-placement-NFVHY6A3.js → skill-placement-JMDPSKE6.js} +12 -13
  73. package/dist/{skill-placement-NFVHY6A3.js.map → skill-placement-JMDPSKE6.js.map} +1 -1
  74. package/dist/{status-T2SDB57A.js → status-FFC6FO72.js} +8 -7
  75. package/dist/{status-T2SDB57A.js.map → status-FFC6FO72.js.map} +1 -1
  76. package/dist/{status-line-CGPUSDMC.js → status-line-SAXSU6CR.js} +19 -3
  77. package/dist/status-line-SAXSU6CR.js.map +1 -0
  78. package/dist/{status-line-wiring-BYPHTYZE.js → status-line-wiring-DQZCWIUO.js} +5 -6
  79. package/dist/tenjin-daemon.mjs +384 -23
  80. package/dist/{uninstall-FKYZHAM3.js → uninstall-SWICHBTF.js} +41 -18
  81. package/dist/uninstall-SWICHBTF.js.map +1 -0
  82. package/dist/{update-ANJ2AOTN.js → update-W572AMXG.js} +6 -7
  83. package/dist/{update-ANJ2AOTN.js.map → update-W572AMXG.js.map} +1 -1
  84. package/dist/{wallet-PWAHVKWW.js → wallet-L2YLAJFN.js} +12 -10
  85. package/docs/agent-permissions.md +17 -9
  86. package/docs/safety-model.md +1 -1
  87. package/package.json +1 -1
  88. package/dist/chunk-25TJPVBF.js.map +0 -1
  89. package/dist/chunk-56MOAIP5.js.map +0 -1
  90. package/dist/chunk-7WEQQJLG.js.map +0 -1
  91. package/dist/chunk-DMZZLPZN.js.map +0 -1
  92. package/dist/chunk-GULLJQXA.js.map +0 -1
  93. package/dist/chunk-L3PVMIYQ.js.map +0 -1
  94. package/dist/chunk-OCBHUHWB.js +0 -69
  95. package/dist/chunk-OCBHUHWB.js.map +0 -1
  96. package/dist/chunk-OIM4HLN6.js.map +0 -1
  97. package/dist/chunk-OJLYNM4Z.js.map +0 -1
  98. package/dist/chunk-PZEN5PHN.js.map +0 -1
  99. package/dist/chunk-USS336NF.js.map +0 -1
  100. package/dist/chunk-WH7OWT6G.js.map +0 -1
  101. package/dist/doctor-LU4YIZWM.js.map +0 -1
  102. package/dist/hook-command-U6KWPEDQ.js +0 -377
  103. package/dist/hook-command-U6KWPEDQ.js.map +0 -1
  104. package/dist/status-line-CGPUSDMC.js.map +0 -1
  105. package/dist/uninstall-FKYZHAM3.js.map +0 -1
  106. /package/dist/{chunk-2U5ZVEV3.js.map → chunk-FGR734LZ.js.map} +0 -0
  107. /package/dist/{chunk-YJHHCWM3.js.map → chunk-WLMJE3GJ.js.map} +0 -0
  108. /package/dist/{chunk-U5DXNFJC.js.map → chunk-WS4JA6TC.js.map} +0 -0
  109. /package/dist/{chunk-5X4SZ5BF.js.map → chunk-WUHY2AXD.js.map} +0 -0
  110. /package/dist/{chunk-3AJS6LLN.js.map → chunk-ZG7SFI34.js.map} +0 -0
  111. /package/dist/{config-MXOX7XDR.js.map → config-BJK6U5VY.js.map} +0 -0
  112. /package/dist/{install-XUM2XSHW.js.map → install-NUQLLHS2.js.map} +0 -0
  113. /package/dist/{pay-SBXZEPEP.js.map → pay-WA3JSCNB.js.map} +0 -0
  114. /package/dist/{redact-46ZHF2NH.js.map → redact-6W23GGJC.js.map} +0 -0
  115. /package/dist/{status-line-wiring-BYPHTYZE.js.map → status-line-wiring-DQZCWIUO.js.map} +0 -0
  116. /package/dist/{wallet-PWAHVKWW.js.map → wallet-L2YLAJFN.js.map} +0 -0
@@ -1,17 +1,22 @@
1
1
  import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
2
  import {
3
+ MAX_PAID_LEG_TIMEOUT_MS,
4
+ paidLegTimeoutMs,
3
5
  runPay
4
- } from "./chunk-L3PVMIYQ.js";
6
+ } from "./chunk-N44H5TFB.js";
7
+ import "./chunk-2G2WLVHB.js";
5
8
  import "./chunk-3AUDA53C.js";
6
- import "./chunk-5X4SZ5BF.js";
9
+ import "./chunk-WUHY2AXD.js";
7
10
  import "./chunk-TTNESUPQ.js";
8
11
  import "./chunk-HPWO4O6S.js";
9
12
  import "./chunk-POUWHWID.js";
10
13
  import "./chunk-XZKD7DIF.js";
11
14
  import "./chunk-LHHMV4GU.js";
12
- import "./chunk-56MOAIP5.js";
13
- import "./chunk-YEETV6IW.js";
14
- import "./chunk-DMZZLPZN.js";
15
+ import "./chunk-BTX2QE2Y.js";
16
+ import "./chunk-3KKKB2AQ.js";
17
+ import "./chunk-KUBEYXSO.js";
18
+ import "./chunk-AUKDYPPX.js";
19
+ import "./chunk-35M3VITA.js";
15
20
  import "./chunk-AWQPGIR6.js";
16
21
  import "./chunk-N35E6CM2.js";
17
22
  import "./chunk-JRGFKVAZ.js";
@@ -20,18 +25,20 @@ import "./chunk-EGELTSPU.js";
20
25
  import "./chunk-KG3D7FIF.js";
21
26
  import "./chunk-RBJPAZFI.js";
22
27
  import "./chunk-BPMWXTFX.js";
23
- import "./chunk-OIM4HLN6.js";
24
- import "./chunk-YJHHCWM3.js";
28
+ import "./chunk-7QKHZQKW.js";
29
+ import "./chunk-WLMJE3GJ.js";
25
30
  import "./chunk-MEFB5KHA.js";
26
- import "./chunk-OJLYNM4Z.js";
27
- import "./chunk-WH7OWT6G.js";
28
- import "./chunk-BBVUVBUO.js";
29
- import "./chunk-BFFM2WFK.js";
30
- import "./chunk-OCBHUHWB.js";
31
+ import "./chunk-2I4QTOLB.js";
32
+ import "./chunk-PDA2BVFY.js";
33
+ import "./chunk-U2DZISAH.js";
34
+ import "./chunk-AR7U7BRG.js";
35
+ import "./chunk-NRQMOVKM.js";
36
+ import "./chunk-JLEF5WHM.js";
31
37
  import "./chunk-2BKS2FVE.js";
32
- import "./chunk-7WEQQJLG.js";
33
38
  import "./chunk-ZXTAQYNA.js";
34
39
  export {
40
+ MAX_PAID_LEG_TIMEOUT_MS,
41
+ paidLegTimeoutMs,
35
42
  runPay
36
43
  };
37
- //# sourceMappingURL=pay-SBXZEPEP.js.map
44
+ //# sourceMappingURL=pay-WA3JSCNB.js.map
@@ -3,15 +3,13 @@ import {
3
3
  EMITTED_CHECKS,
4
4
  checksFor,
5
5
  findings,
6
- mask,
7
- maskRules
8
- } from "./chunk-OIM4HLN6.js";
6
+ mask
7
+ } from "./chunk-7QKHZQKW.js";
9
8
  import "./chunk-ZXTAQYNA.js";
10
9
  export {
11
10
  EMITTED_CHECKS,
12
11
  checksFor,
13
12
  findings,
14
- mask,
15
- maskRules
13
+ mask
16
14
  };
17
- //# sourceMappingURL=redact-46ZHF2NH.js.map
15
+ //# sourceMappingURL=redact-6W23GGJC.js.map
@@ -10,12 +10,14 @@ import {
10
10
  broadcastUsdcSend,
11
11
  getUsdcBalance,
12
12
  prepareUsdcSend
13
- } from "./chunk-56MOAIP5.js";
13
+ } from "./chunk-BTX2QE2Y.js";
14
+ import "./chunk-3KKKB2AQ.js";
14
15
  import {
15
16
  describeWallet,
16
17
  resolveWalletProvider
17
- } from "./chunk-YEETV6IW.js";
18
- import "./chunk-DMZZLPZN.js";
18
+ } from "./chunk-KUBEYXSO.js";
19
+ import "./chunk-AUKDYPPX.js";
20
+ import "./chunk-35M3VITA.js";
19
21
  import "./chunk-AWQPGIR6.js";
20
22
  import "./chunk-N35E6CM2.js";
21
23
  import "./chunk-JRGFKVAZ.js";
@@ -28,23 +30,23 @@ import {
28
30
  import "./chunk-KG3D7FIF.js";
29
31
  import "./chunk-RBJPAZFI.js";
30
32
  import "./chunk-BPMWXTFX.js";
31
- import "./chunk-YJHHCWM3.js";
33
+ import "./chunk-WLMJE3GJ.js";
32
34
  import "./chunk-MEFB5KHA.js";
35
+ import "./chunk-2I4QTOLB.js";
33
36
  import {
34
37
  resolveContextSettings
35
- } from "./chunk-OJLYNM4Z.js";
38
+ } from "./chunk-PDA2BVFY.js";
36
39
  import {
37
40
  parseUsdToAtomic,
38
41
  toMoney
39
- } from "./chunk-WH7OWT6G.js";
42
+ } from "./chunk-U2DZISAH.js";
40
43
  import {
41
44
  SEND_MAX_UNSET
42
- } from "./chunk-BBVUVBUO.js";
45
+ } from "./chunk-AR7U7BRG.js";
43
46
  import {
44
47
  CliError
45
- } from "./chunk-OCBHUHWB.js";
48
+ } from "./chunk-JLEF5WHM.js";
46
49
  import "./chunk-2BKS2FVE.js";
47
- import "./chunk-7WEQQJLG.js";
48
50
  import "./chunk-ZXTAQYNA.js";
49
51
 
50
52
  // src/commands/send.ts
@@ -220,4 +222,4 @@ This moves funds out of the agent wallet and cannot be undone. [y/N] `;
220
222
  export {
221
223
  runSend
222
224
  };
223
- //# sourceMappingURL=send-ASD2ZXJD.js.map
225
+ //# sourceMappingURL=send-KVUH5WDO.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/commands/send.ts"],"sourcesContent":["import { formatEther, getAddress, isAddress, type Address } from 'viem';\nimport { SEND_MAX_UNSET } from '../lib/config';\nimport { CliError } from '../lib/errors';\nimport { parseUsdToAtomic, toMoney } from '../lib/money';\nimport { promptYesNo } from '../lib/prompt';\nimport { resolveContextSettings } from '../lib/settings';\nimport {\n broadcastUsdcSend,\n FeeCapExceededError,\n getUsdcBalance,\n prepareUsdcSend,\n SendPendingError,\n SendRevertedError,\n USDC_ADDRESS,\n} from '../lib/usdc';\nimport { describeWallet, resolveWalletProvider, type WalletProvider } from '../lib/wallet';\nimport type { CommandContext, CommandResult } from '../context';\n\n/**\n * `tenjin wallet send <amount> <token> <to>`: the escape hatch that moves funds OUT of\n * the agent wallet, complementary to delegation (which redirects future revenue\n * off the hot key; this is for a balance already on it). Invariants a reader\n * cannot derive from the code order alone:\n * - the confirm (buy's posture: interactive y/N, `--yes` bypasses the prompt\n * only, headless without it refuses) runs BEFORE the signer is resolved, so\n * no refusal branch ever touches key material;\n * - `sendMaxAmount` is a spend-policy gate, NOT satisfiable by --yes, and it\n * has NO default: unset refuses until `config set sendMaxAmount` is run\n * (require-set-before-first-send; \"none\" is an explicit uncapped opt-in);\n * - the verb is deliberately absent from the MCP toolset (spec 10's narrow\n * toolset) and the skill adapters — human-invoked only, both pinned by tests.\n */\n\nexport interface SendArgs {\n /** Decimal USD at the edge (O1 convention); converted to atomic exactly once. */\n amount: string;\n token: string;\n /** Recipient address, 0x-prefixed; checksummed or all-lowercase. */\n to: string;\n /** Skip the interactive confirm. REQUIRED to send when not at a TTY. */\n yes?: boolean;\n}\n\nexport interface SendDeps {\n /** Test seam: bypass the local wallet provider. */\n provider?: WalletProvider;\n /** Interactive-confirm seam; defaults to a TTY y/n prompt (same shape as buy). */\n confirm?: (prompt: string) => Promise<boolean>;\n}\n\nconst ZERO_ADDRESS: Address = '0x0000000000000000000000000000000000000000';\nconst DEAD_ADDRESS: Address = '0x000000000000000000000000000000000000dEaD';\n\nexport async function runSend(\n args: SendArgs,\n ctx: CommandContext,\n deps: SendDeps = {},\n): Promise<CommandResult> {\n requireUsdc(args.token);\n const amountAtomic = BigInt(parseUsdToAtomic(args.amount));\n if (amountAtomic === 0n) {\n throw new CliError('USAGE', 'The send amount must be greater than zero.', {\n fix: 'Pass a positive decimal USDC amount, e.g. `tenjin wallet send 5 usdc <to>`.',\n });\n }\n const to = parseRecipient(args.to);\n\n const provider = resolveWalletProvider(\n ctx,\n deps.provider !== undefined ? { provider: deps.provider } : {},\n );\n // Address + posture only; surfaces WALLET_MISSING. No key material yet.\n const desc = await describeWallet(provider);\n if (to.toLowerCase() === desc.address.toLowerCase()) {\n throw new CliError('USAGE', 'The recipient is this wallet itself.', {\n fix: 'Pass the destination wallet address, not the sending one.',\n });\n }\n\n const { rpcUrl, sendMaxAmountAtomic } = await resolveContextSettings(ctx);\n enforceSendCap(amountAtomic, sendMaxAmountAtomic);\n\n let balance: bigint;\n try {\n balance = await getUsdcBalance(desc.address, rpcUrl);\n } catch (err) {\n throw new CliError('RPC_ERROR', `Could not read the USDC balance from ${rpcUrl}.`, {\n fix: 'Check your network, or set a working RPC with `tenjin config set rpcUrl <url>`.',\n cause: err,\n });\n }\n if (amountAtomic > balance) {\n throw new CliError('REFUSED', 'The amount exceeds the wallet USDC balance.', {\n fix: 'Check `tenjin wallet balance` and send at most that amount.',\n details: {\n requested: toMoney(amountAtomic.toString()),\n balance: toMoney(balance.toString()),\n },\n });\n }\n\n // Read-only chain prep before the confirm, so the prompt can show the fee and\n // a wallet without gas refuses before asking anyone to approve anything.\n let prepared;\n try {\n prepared = await prepareUsdcSend({ from: desc.address, to, amountAtomic, rpcUrl });\n } catch (err) {\n if (err instanceof FeeCapExceededError) {\n throw new CliError('REFUSED', 'The RPC gas/fee estimate is abnormal for Base; refusing.', {\n fix: 'Check `tenjin config get rpcUrl` points at a trusted Base RPC; if the RPC is fine, Base fees are spiking — wait and retry.',\n cause: err,\n });\n }\n throw new CliError('RPC_ERROR', 'Could not prepare the transfer on Base.', {\n fix: 'Check your network, or set a working RPC with `tenjin config set rpcUrl <url>`.',\n cause: err,\n });\n }\n if (prepared.ethBalanceWei < prepared.feeWei) {\n throw new CliError('REFUSED', 'The wallet has no ETH on Base to pay the network fee.', {\n fix: `Send a little ETH on Base to ${desc.address} (about ${formatEther(prepared.feeWei)} ETH needed), then retry.`,\n details: {\n ethBalanceWei: prepared.ethBalanceWei.toString(),\n feeWei: prepared.feeWei.toString(),\n },\n });\n }\n\n const approved = await confirmSend(ctx, deps, args.yes === true, {\n amountAtomic,\n to,\n from: desc.address,\n feeWei: prepared.feeWei,\n });\n if (!approved) {\n throw new CliError('REFUSED', 'Send not confirmed.', {\n fix: 'Verify the recipient and amount, then re-run with --yes to approve this transfer.',\n details: { to, amount: toMoney(amountAtomic.toString()) },\n });\n }\n\n // The only door to the key; a missing passphrase entry refuses here with the\n // provider's coded error. The signer must be the wallet the human just saw:\n // the local provider guarantees it, a hosted one is only trusted after this.\n const signer = await provider.getSigner();\n if (signer.address.toLowerCase() !== desc.address.toLowerCase()) {\n throw new CliError(\n 'PROVIDER_ERROR',\n `The signer address ${signer.address} does not match the confirmed wallet ${desc.address}.`,\n { fix: 'The wallet changed between preview and signing; re-run `tenjin wallet send`.' },\n );\n }\n\n let txHash: string;\n try {\n txHash = await broadcastUsdcSend({ signer, prepared, rpcUrl });\n } catch (err) {\n if (err instanceof SendRevertedError) {\n throw new CliError('SEND_FAILED', 'The transfer was mined but reverted; no USDC moved.', {\n fix: 'Check the transaction on a Base explorer, then retry if the cause is transient.',\n details: { txHash: err.txHash },\n cause: err,\n });\n }\n if (err instanceof SendPendingError) {\n throw new CliError('SEND_FAILED', 'The transfer was broadcast but not confirmed in time.', {\n fix: 'Check the transaction on a Base explorer before retrying: it may still mine, and an immediate retry could double-send.',\n details: { txHash: err.txHash, pending: true },\n cause: err,\n });\n }\n throw new CliError('RPC_ERROR', 'The transfer could not be sent on Base.', {\n fix: 'Check the network and RPC, then retry.',\n cause: err,\n });\n }\n\n const amount = toMoney(amountAtomic.toString());\n return {\n data: { txHash, from: signer.address, to, token: 'USDC', network: 'base', amount },\n humanLines: [`Sent ${amount.usd} USDC on Base to ${to}`, `Tx: ${txHash}`],\n };\n}\n\n/**\n * The hard per-send cap (`config set sendMaxAmount`): a policy gate, not a\n * confirm — no branch here is satisfiable by --yes. There is no default cap:\n * an unset key refuses (require-set-before-first-send), exactly as strict as\n * the set-cap refusals below.\n */\nfunction enforceSendCap(\n amountAtomic: bigint,\n capAtomic: bigint | null | typeof SEND_MAX_UNSET,\n): void {\n if (capAtomic === SEND_MAX_UNSET) {\n throw new CliError(\n 'POLICY_REFUSED',\n 'No sendMaxAmount is configured; a per-send cap must be set before the first send.',\n {\n fix: 'Run `tenjin config set sendMaxAmount <usd>` (or `0` to disable send, or `none` to opt in to uncapped), then retry. --yes does not bypass this.',\n },\n );\n }\n if (capAtomic === null) return;\n if (capAtomic === 0n) {\n throw new CliError('POLICY_REFUSED', 'Sending is disabled by sendMaxAmount = 0.', {\n fix: 'Run `tenjin config set sendMaxAmount <usd|none>` to allow sends.',\n });\n }\n if (amountAtomic > capAtomic) {\n throw new CliError('POLICY_REFUSED', 'The amount exceeds the sendMaxAmount cap.', {\n fix: 'Send a smaller amount, or raise the cap with `tenjin config set sendMaxAmount <usd>`.',\n details: { requested: toMoney(amountAtomic.toString()), cap: toMoney(capAtomic.toString()) },\n });\n }\n}\n\n/** USDC on Base only; anything else is a usage error, not a guess. */\nfunction requireUsdc(token: string): void {\n if (token.trim().toLowerCase() === 'usdc') return;\n throw new CliError('USAGE', `Unsupported token: ${JSON.stringify(token)}`, {\n fix: 'Only USDC on Base is supported: `tenjin wallet send <amount> usdc <to>`.',\n });\n}\n\n/**\n * Validate and resolve the recipient. Strict `isAddress` refuses malformed input\n * and a bad EIP-55 checksum on MIXED-CASE input (all-lowercase input carries no\n * checksum to verify — that limit is inherent to the format); `getAddress` then\n * yields the checksummed form the preview shows and the transfer targets. Known\n * fund-destroying destinations (the USDC contract, the zero address, the burn\n * address) refuse outright.\n */\nfunction parseRecipient(raw: string): Address {\n const trimmed = raw.trim();\n if (!isAddress(trimmed)) {\n throw new CliError('USAGE', `Invalid recipient address: ${JSON.stringify(raw)}`, {\n fix: 'Pass a 0x-prefixed 20-byte address, checksummed or all-lowercase (lowercase skips the checksum typo check).',\n });\n }\n const to = getAddress(trimmed);\n if (to === USDC_ADDRESS || to === ZERO_ADDRESS || to === DEAD_ADDRESS) {\n throw new CliError('USAGE', 'The recipient is a known fund-destroying address.', {\n fix: 'Tokens sent to the token contract, the zero address, or the burn address are unrecoverable. Pass the destination wallet address.',\n });\n }\n return to;\n}\n\ninterface ConfirmDetails {\n amountAtomic: bigint;\n to: Address;\n from: Address;\n feeWei: bigint;\n}\n\n/** Buy's confirm posture; the preview names the resolved recipient, amount, and fee. */\nasync function confirmSend(\n ctx: CommandContext,\n deps: SendDeps,\n yes: boolean,\n d: ConfirmDetails,\n): Promise<boolean> {\n if (yes) return true;\n const prompt =\n `Send ${toMoney(d.amountAtomic.toString()).usd} USDC on Base\\n` +\n ` from ${d.from}\\n` +\n ` to ${d.to}\\n` +\n ` network fee up to ~${formatEther(d.feeWei)} ETH\\n` +\n `This moves funds out of the agent wallet and cannot be undone. [y/N] `;\n if (deps.confirm !== undefined) return deps.confirm(prompt);\n // Both streams must be real TTYs; piped stdin/stdout without --yes refuses.\n if (!ctx.io.isTTY || !process.stdin.isTTY) return false;\n return promptYesNo(prompt);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,IAAM,eAAwB;AAC9B,IAAM,eAAwB;AAE9B,eAAsB,QACpB,MACA,KACA,OAAiB,CAAC,GACM;AACxB,cAAY,KAAK,KAAK;AACtB,QAAM,eAAe,OAAO,iBAAiB,KAAK,MAAM,CAAC;AACzD,MAAI,iBAAiB,IAAI;AACvB,UAAM,IAAI,SAAS,SAAS,8CAA8C;AAAA,MACxE,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AG,CAAC,IAAI;AAAA,MAC/E,KAAK;AAAA,IACP,CAAC;AAAA,EACH;AACA,QAAM,KAAK,WAAW,OAAO;AAC7B,MAAI,OAAO,gBAAgB,OAAO,gBAAgB,OAAO,cAAc;AACrE,UAAM,IAAI,SAAS,SAAS,qDAAqD;AAAA,MAC/E,KAAK;AAAA,IACP,CAAC;AAAA,EACH;AACA,SAAO;AACT;AAUA,eAAe,YACb,KACA,MACA,KACA,GACkB;AAClB,MAAI,IAAK,QAAO;AAChB,QAAM,SACJ,QAAQ,QAAQ,EAAE,aAAa,SAAS,CAAC,EAAE,GAAG;AAAA,SACpC,EAAE,IAAI;AAAA,SACN,EAAE,EAAE;AAAA,uBACU,YAAY,EAAE,MAAM,CAAC;AAAA;AAE/C,MAAI,KAAK,YAAY,OAAW,QAAO,KAAK,QAAQ,MAAM;AAE1D,MAAI,CAAC,IAAI,GAAG,SAAS,CAAC,QAAQ,MAAM,MAAO,QAAO;AAClD,SAAO,YAAY,MAAM;AAC3B;","names":[]}
1
+ {"version":3,"sources":["../src/commands/send.ts"],"sourcesContent":["import { formatEther, getAddress, isAddress, type Address } from 'viem';\nimport { SEND_MAX_UNSET } from '../lib/config';\nimport { CliError } from '../lib/errors';\nimport { parseUsdToAtomic, toMoney } from '../lib/money';\nimport { promptYesNo } from '../lib/prompt';\nimport { resolveContextSettings } from '../lib/settings';\nimport {\n broadcastUsdcSend,\n FeeCapExceededError,\n getUsdcBalance,\n prepareUsdcSend,\n SendPendingError,\n SendRevertedError,\n USDC_ADDRESS,\n} from '../lib/usdc';\nimport { describeWallet, resolveWalletProvider, type WalletProvider } from '../lib/wallet';\nimport type { CommandContext, CommandResult } from '../context';\n\n/**\n * `tenjin wallet send <amount> <token> <to>`: the escape hatch that moves funds OUT of\n * the agent wallet, complementary to delegation (which redirects future revenue\n * off the hot key; this is for a balance already on it). Invariants a reader\n * cannot derive from the code order alone:\n * - the confirm (buy's posture: interactive y/N, `--yes` bypasses the prompt\n * only, headless without it refuses) runs BEFORE the signer is resolved, so\n * no refusal branch ever touches key material;\n * - `sendMaxAmount` is a spend-policy gate, NOT satisfiable by --yes, and it\n * has NO default: unset refuses until `config set sendMaxAmount` is run\n * (require-set-before-first-send; \"none\" is an explicit uncapped opt-in);\n * - the verb is deliberately absent from the MCP toolset (spec 10's narrow\n * toolset) and the skill adapters — human-invoked only, both pinned by tests.\n */\n\nexport interface SendArgs {\n /** Decimal USD at the edge (O1 convention); converted to atomic exactly once. */\n amount: string;\n token: string;\n /** Recipient address, 0x-prefixed; checksummed or all-lowercase. */\n to: string;\n /** Skip the interactive confirm. REQUIRED to send when not at a TTY. */\n yes?: boolean;\n}\n\nexport interface SendDeps {\n /** Test seam: bypass the local wallet provider. */\n provider?: WalletProvider;\n /** Interactive-confirm seam; defaults to a TTY y/n prompt (same shape as buy). */\n confirm?: (prompt: string) => Promise<boolean>;\n}\n\nconst ZERO_ADDRESS: Address = '0x0000000000000000000000000000000000000000';\nconst DEAD_ADDRESS: Address = '0x000000000000000000000000000000000000dEaD';\n\nexport async function runSend(\n args: SendArgs,\n ctx: CommandContext,\n deps: SendDeps = {},\n): Promise<CommandResult> {\n requireUsdc(args.token);\n const amountAtomic = BigInt(parseUsdToAtomic(args.amount));\n if (amountAtomic === 0n) {\n throw new CliError('USAGE', 'The send amount must be greater than zero.', {\n fix: 'Pass a positive decimal USDC amount, e.g. `tenjin wallet send 5 usdc <to>`.',\n });\n }\n const to = parseRecipient(args.to);\n\n const provider = resolveWalletProvider(\n ctx,\n deps.provider !== undefined ? { provider: deps.provider } : {},\n );\n // Address + posture only; surfaces WALLET_MISSING. No key material yet.\n const desc = await describeWallet(provider);\n if (to.toLowerCase() === desc.address.toLowerCase()) {\n throw new CliError('USAGE', 'The recipient is this wallet itself.', {\n fix: 'Pass the destination wallet address, not the sending one.',\n });\n }\n\n const { rpcUrl, sendMaxAmountAtomic } = await resolveContextSettings(ctx);\n enforceSendCap(amountAtomic, sendMaxAmountAtomic);\n\n let balance: bigint;\n try {\n balance = await getUsdcBalance(desc.address, rpcUrl);\n } catch (err) {\n throw new CliError('RPC_ERROR', `Could not read the USDC balance from ${rpcUrl}.`, {\n fix: 'Check your network, or set a working RPC with `tenjin config set rpcUrl <url>`.',\n cause: err,\n });\n }\n if (amountAtomic > balance) {\n throw new CliError('REFUSED', 'The amount exceeds the wallet USDC balance.', {\n fix: 'Check `tenjin wallet balance` and send at most that amount.',\n details: {\n requested: toMoney(amountAtomic.toString()),\n balance: toMoney(balance.toString()),\n },\n });\n }\n\n // Read-only chain prep before the confirm, so the prompt can show the fee and\n // a wallet without gas refuses before asking anyone to approve anything.\n let prepared;\n try {\n prepared = await prepareUsdcSend({ from: desc.address, to, amountAtomic, rpcUrl });\n } catch (err) {\n if (err instanceof FeeCapExceededError) {\n throw new CliError('REFUSED', 'The RPC gas/fee estimate is abnormal for Base; refusing.', {\n fix: 'Check `tenjin config get rpcUrl` points at a trusted Base RPC; if the RPC is fine, Base fees are spiking — wait and retry.',\n cause: err,\n });\n }\n throw new CliError('RPC_ERROR', 'Could not prepare the transfer on Base.', {\n fix: 'Check your network, or set a working RPC with `tenjin config set rpcUrl <url>`.',\n cause: err,\n });\n }\n if (prepared.ethBalanceWei < prepared.feeWei) {\n throw new CliError('REFUSED', 'The wallet has no ETH on Base to pay the network fee.', {\n fix: `Send a little ETH on Base to ${desc.address} (about ${formatEther(prepared.feeWei)} ETH needed), then retry.`,\n details: {\n ethBalanceWei: prepared.ethBalanceWei.toString(),\n feeWei: prepared.feeWei.toString(),\n },\n });\n }\n\n const approved = await confirmSend(ctx, deps, args.yes === true, {\n amountAtomic,\n to,\n from: desc.address,\n feeWei: prepared.feeWei,\n });\n if (!approved) {\n throw new CliError('REFUSED', 'Send not confirmed.', {\n fix: 'Verify the recipient and amount, then re-run with --yes to approve this transfer.',\n details: { to, amount: toMoney(amountAtomic.toString()) },\n });\n }\n\n // The only door to the key; a missing passphrase entry refuses here with the\n // provider's coded error. The signer must be the wallet the human just saw:\n // the local provider guarantees it, a hosted one is only trusted after this.\n const signer = await provider.getSigner();\n if (signer.address.toLowerCase() !== desc.address.toLowerCase()) {\n throw new CliError(\n 'PROVIDER_ERROR',\n `The signer address ${signer.address} does not match the confirmed wallet ${desc.address}.`,\n { fix: 'The wallet changed between preview and signing; re-run `tenjin wallet send`.' },\n );\n }\n\n let txHash: string;\n try {\n txHash = await broadcastUsdcSend({ signer, prepared, rpcUrl });\n } catch (err) {\n if (err instanceof SendRevertedError) {\n throw new CliError('SEND_FAILED', 'The transfer was mined but reverted; no USDC moved.', {\n fix: 'Check the transaction on a Base explorer, then retry if the cause is transient.',\n details: { txHash: err.txHash },\n cause: err,\n });\n }\n if (err instanceof SendPendingError) {\n throw new CliError('SEND_FAILED', 'The transfer was broadcast but not confirmed in time.', {\n fix: 'Check the transaction on a Base explorer before retrying: it may still mine, and an immediate retry could double-send.',\n details: { txHash: err.txHash, pending: true },\n cause: err,\n });\n }\n throw new CliError('RPC_ERROR', 'The transfer could not be sent on Base.', {\n fix: 'Check the network and RPC, then retry.',\n cause: err,\n });\n }\n\n const amount = toMoney(amountAtomic.toString());\n return {\n data: { txHash, from: signer.address, to, token: 'USDC', network: 'base', amount },\n humanLines: [`Sent ${amount.usd} USDC on Base to ${to}`, `Tx: ${txHash}`],\n };\n}\n\n/**\n * The hard per-send cap (`config set sendMaxAmount`): a policy gate, not a\n * confirm — no branch here is satisfiable by --yes. There is no default cap:\n * an unset key refuses (require-set-before-first-send), exactly as strict as\n * the set-cap refusals below.\n */\nfunction enforceSendCap(\n amountAtomic: bigint,\n capAtomic: bigint | null | typeof SEND_MAX_UNSET,\n): void {\n if (capAtomic === SEND_MAX_UNSET) {\n throw new CliError(\n 'POLICY_REFUSED',\n 'No sendMaxAmount is configured; a per-send cap must be set before the first send.',\n {\n fix: 'Run `tenjin config set sendMaxAmount <usd>` (or `0` to disable send, or `none` to opt in to uncapped), then retry. --yes does not bypass this.',\n },\n );\n }\n if (capAtomic === null) return;\n if (capAtomic === 0n) {\n throw new CliError('POLICY_REFUSED', 'Sending is disabled by sendMaxAmount = 0.', {\n fix: 'Run `tenjin config set sendMaxAmount <usd|none>` to allow sends.',\n });\n }\n if (amountAtomic > capAtomic) {\n throw new CliError('POLICY_REFUSED', 'The amount exceeds the sendMaxAmount cap.', {\n fix: 'Send a smaller amount, or raise the cap with `tenjin config set sendMaxAmount <usd>`.',\n details: { requested: toMoney(amountAtomic.toString()), cap: toMoney(capAtomic.toString()) },\n });\n }\n}\n\n/** USDC on Base only; anything else is a usage error, not a guess. */\nfunction requireUsdc(token: string): void {\n if (token.trim().toLowerCase() === 'usdc') return;\n throw new CliError('USAGE', `Unsupported token: ${JSON.stringify(token)}`, {\n fix: 'Only USDC on Base is supported: `tenjin wallet send <amount> usdc <to>`.',\n });\n}\n\n/**\n * Validate and resolve the recipient. Strict `isAddress` refuses malformed input\n * and a bad EIP-55 checksum on MIXED-CASE input (all-lowercase input carries no\n * checksum to verify — that limit is inherent to the format); `getAddress` then\n * yields the checksummed form the preview shows and the transfer targets. Known\n * fund-destroying destinations (the USDC contract, the zero address, the burn\n * address) refuse outright.\n */\nfunction parseRecipient(raw: string): Address {\n const trimmed = raw.trim();\n if (!isAddress(trimmed)) {\n throw new CliError('USAGE', `Invalid recipient address: ${JSON.stringify(raw)}`, {\n fix: 'Pass a 0x-prefixed 20-byte address, checksummed or all-lowercase (lowercase skips the checksum typo check).',\n });\n }\n const to = getAddress(trimmed);\n if (to === USDC_ADDRESS || to === ZERO_ADDRESS || to === DEAD_ADDRESS) {\n throw new CliError('USAGE', 'The recipient is a known fund-destroying address.', {\n fix: 'Tokens sent to the token contract, the zero address, or the burn address are unrecoverable. Pass the destination wallet address.',\n });\n }\n return to;\n}\n\ninterface ConfirmDetails {\n amountAtomic: bigint;\n to: Address;\n from: Address;\n feeWei: bigint;\n}\n\n/** Buy's confirm posture; the preview names the resolved recipient, amount, and fee. */\nasync function confirmSend(\n ctx: CommandContext,\n deps: SendDeps,\n yes: boolean,\n d: ConfirmDetails,\n): Promise<boolean> {\n if (yes) return true;\n const prompt =\n `Send ${toMoney(d.amountAtomic.toString()).usd} USDC on Base\\n` +\n ` from ${d.from}\\n` +\n ` to ${d.to}\\n` +\n ` network fee up to ~${formatEther(d.feeWei)} ETH\\n` +\n `This moves funds out of the agent wallet and cannot be undone. [y/N] `;\n if (deps.confirm !== undefined) return deps.confirm(prompt);\n // Both streams must be real TTYs; piped stdin/stdout without --yes refuses.\n if (!ctx.io.isTTY || !process.stdin.isTTY) return false;\n return promptYesNo(prompt);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,IAAM,eAAwB;AAC9B,IAAM,eAAwB;AAE9B,eAAsB,QACpB,MACA,KACA,OAAiB,CAAC,GACM;AACxB,cAAY,KAAK,KAAK;AACtB,QAAM,eAAe,OAAO,iBAAiB,KAAK,MAAM,CAAC;AACzD,MAAI,iBAAiB,IAAI;AACvB,UAAM,IAAI,SAAS,SAAS,8CAA8C;AAAA,MACxE,KAAK;AAAA,IACP,CAAC;AAAA,EACH;AACA,QAAM,KAAK,eAAe,KAAK,EAAE;AAEjC,QAAM,WAAW;AAAA,IACf;AAAA,IACA,KAAK,aAAa,SAAY,EAAE,UAAU,KAAK,SAAS,IAAI,CAAC;AAAA,EAC/D;AAEA,QAAM,OAAO,MAAM,eAAe,QAAQ;AAC1C,MAAI,GAAG,YAAY,MAAM,KAAK,QAAQ,YAAY,GAAG;AACnD,UAAM,IAAI,SAAS,SAAS,wCAAwC;AAAA,MAClE,KAAK;AAAA,IACP,CAAC;AAAA,EACH;AAEA,QAAM,EAAE,QAAQ,oBAAoB,IAAI,MAAM,uBAAuB,GAAG;AACxE,iBAAe,cAAc,mBAAmB;AAEhD,MAAI;AACJ,MAAI;AACF,cAAU,MAAM,eAAe,KAAK,SAAS,MAAM;AAAA,EACrD,SAAS,KAAK;AACZ,UAAM,IAAI,SAAS,aAAa,wCAAwC,MAAM,KAAK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O,QAAO;AAClD,SAAO,YAAY,MAAM;AAC3B;","names":[]}
@@ -1,7 +1,7 @@
1
1
  import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
2
  import {
3
3
  emitWriteNotice
4
- } from "./chunk-YJHHCWM3.js";
4
+ } from "./chunk-WLMJE3GJ.js";
5
5
  import {
6
6
  HOSTED_SKILL_NAME,
7
7
  OPTIONAL_PAY_SKILL,
@@ -10,24 +10,23 @@ import {
10
10
  resolveSkillsSource,
11
11
  skillFrontmatterName,
12
12
  skillsDirsFor
13
- } from "./chunk-U5DXNFJC.js";
14
- import {
15
- isTeamModeConfig
16
- } from "./chunk-OJLYNM4Z.js";
13
+ } from "./chunk-WS4JA6TC.js";
17
14
  import {
18
15
  hasCode
19
- } from "./chunk-WH7OWT6G.js";
16
+ } from "./chunk-2I4QTOLB.js";
17
+ import {
18
+ isTeamModeConfig
19
+ } from "./chunk-PDA2BVFY.js";
20
+ import "./chunk-U2DZISAH.js";
20
21
  import {
21
22
  PRODUCTION_HOST,
22
23
  loadRawConfig
23
- } from "./chunk-BBVUVBUO.js";
24
- import {
25
- CliError
26
- } from "./chunk-OCBHUHWB.js";
27
- import "./chunk-2BKS2FVE.js";
24
+ } from "./chunk-AR7U7BRG.js";
28
25
  import {
26
+ CliError,
29
27
  writeFileAtomic
30
- } from "./chunk-7WEQQJLG.js";
28
+ } from "./chunk-JLEF5WHM.js";
29
+ import "./chunk-2BKS2FVE.js";
31
30
  import "./chunk-ZXTAQYNA.js";
32
31
 
33
32
  // src/lib/skill-placement.ts
@@ -297,4 +296,4 @@ export {
297
296
  placeOptionalSkill,
298
297
  syncBazaarSkill
299
298
  };
300
- //# sourceMappingURL=skill-placement-NFVHY6A3.js.map
299
+ //# sourceMappingURL=skill-placement-JMDPSKE6.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/lib/skill-placement.ts","../src/lib/skill-materialize.ts","../src/lib/skill-writer.ts"],"sourcesContent":["import { lstatSync } from 'node:fs';\nimport { readdir, rm, rmdir } from 'node:fs/promises';\nimport { homedir } from 'node:os';\nimport { isAbsolute, join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { emitWriteNotice } from './output';\nimport type { Io } from './output';\nimport { loadRawConfig } from './config';\nimport { isTeamModeConfig } from './settings';\nimport { skillMaterialize } from './skill-materialize';\nimport { readSkillFile, skillFrontmatterName, skillsDirsFor } from './skill-wiring';\nimport { installSkill } from './skill-writer';\nimport { OPTIONAL_PAY_SKILL, SKILL_NAMES, resolveSkillsSource } from './skills-source';\n\n/**\n * Optional skills, where PRESENCE is the whole mechanism: the tenjin-pay skill\n * is on disk exactly while the `bazaarPay` toggle is on, so an agent is never\n * taught a lane the operator turned off, and turning the lane on is what makes\n * the teaching appear. No conditional content, no markers: the unit of\n * consent stays the one the whole pipeline already has, a skill directory.\n *\n * Its CONTENT still goes through the same shaping every other skill's does\n * (lib/skill-materialize): presence and content are different questions, and the\n * placer is one of the writers that has to materialize for the comparers to keep\n * agreeing. tenjin-pay ships no marker today, so it is a no-op there — but a\n * placer that skipped shaping would be the one writer whose `up-to-date` meant\n * something different from everyone else's.\n *\n * Removal follows `uninstall`'s rules exactly (lib/uninstall removeSkills):\n * only a SKILL.md whose frontmatter still claims our name is ours to delete,\n * and the directory goes only when our file was the only thing in it, so an\n * operator's own files beside it survive a toggle-off.\n */\n\n/** Ensure `name` is present or absent under one skills directory. */\nexport async function placeOptionalSkill(\n name: string,\n skillsDir: string,\n skillsSource: string,\n present: boolean,\n teamMode: boolean,\n): Promise<{ changed: boolean }> {\n const skillDir = join(skillsDir, name);\n if (present) {\n const { status } = await installSkill(join(skillsSource, name), skillDir, false, name, {\n materialize: skillMaterialize({ teamMode }),\n });\n return { changed: status !== 'up-to-date' };\n }\n if (lstatSync(skillDir, { throwIfNoEntry: false })?.isDirectory() !== true) {\n return { changed: false };\n }\n const path = join(skillDir, 'SKILL.md');\n const read = await readSkillFile(path);\n if (read.kind === 'absent') return { changed: false };\n if (read.kind !== 'ok' || skillFrontmatterName(read.bytes.toString('utf8')) !== name) {\n return { changed: false }; // not ours to delete for sitting at our path\n }\n await rm(path, { force: true });\n const rest = await readdir(skillDir).catch(() => null);\n if (rest !== null && rest.length === 0) await rmdir(skillDir).catch(() => undefined);\n return { changed: true };\n}\n\n/**\n * The `config set bazaarPay` twin of the heal: converge the tenjin-pay skill's\n * presence with the toggle across every skills directory a tenjin skill is\n * already wired into (presence of any shipped skill is the operator's consent\n * to a directory; an unwired directory is never created). Operator act, so\n * failures degrade per directory and doctor reports what remains.\n */\nexport async function syncBazaarSkill(\n enabled: boolean,\n deps: {\n io: Io;\n homeDir?: string;\n skillsSourceDir?: string;\n /** Where `config.json` lives, for the team-mode fact the content is shaped by.\n * Absent means public, for a caller with no data dir to read. */\n dataDir?: string;\n },\n): Promise<void> {\n const home = deps.homeDir ?? homedir();\n if (!isAbsolute(home)) return;\n // Same fail-safe as the heal's: an unreadable config throws out of here rather\n // than being guessed as public, which on a team machine would write the other\n // mode's text. The caller is already best-effort after a successful persist.\n const teamMode =\n deps.dataDir === undefined ? false : isTeamModeConfig(await loadRawConfig(deps.dataDir));\n let source: string;\n try {\n source =\n deps.skillsSourceDir ?? resolveSkillsSource(fileURLToPath(new URL('.', import.meta.url)));\n } catch {\n return; // no readable source: nothing safe to write, nothing to remove FROM\n }\n const touched: string[] = [];\n for (const dir of skillsDirsFor(home)) {\n try {\n if (lstatSync(dir, { throwIfNoEntry: false })?.isDirectory() !== true) continue;\n const consented = SKILL_NAMES.some(\n (name) =>\n lstatSync(join(dir, name, 'SKILL.md'), { throwIfNoEntry: false })?.isFile() === true,\n );\n if (!consented) continue;\n const { changed } = await placeOptionalSkill(\n OPTIONAL_PAY_SKILL,\n dir,\n source,\n enabled,\n teamMode,\n );\n if (changed) touched.push(join(dir, OPTIONAL_PAY_SKILL));\n } catch {\n // This directory keeps what it has; `tenjin doctor` reports the drift.\n }\n }\n if (touched.length > 0) {\n emitWriteNotice(\n deps.io,\n `${enabled ? 'Installed' : 'Removed'} ${touched.join(' and ')} to match bazaarPay.`,\n );\n }\n}\n","import { CliError } from './errors';\n\n/**\n * Config-conditional blocks in packaged skill markdown. A skill source may wrap a\n * region in full-line HTML-comment markers:\n *\n * <!-- tenjin:when teamMode -->\n * ...lines an agent should only see when the flag is on...\n * <!-- tenjin:else -->\n * ...lines an agent should only see when it is off...\n * <!-- /tenjin:when -->\n *\n * Materializing resolves those regions against a flag set and the marker lines\n * themselves never survive, so an installed SKILL.md carries no machinery for an\n * agent to read. The `else` arm is what makes this a REPLACEMENT seam rather than\n * an additive one, and it is the whole reason it exists: the two arms are\n * structurally exclusive, so exactly one of them can ever reach a reader. Guidance\n * that DIFFERS by machine fact is written as one when/else pair replacing one\n * region, never as a base paragraph plus a \"however, on a team shelf...\" rider —\n * a reader in either mode would then see both, and two rules for the same decision\n * in one file is worse than either rule alone. A bare `when` with no `else` stays\n * legal for content that is genuinely additive.\n *\n * Unknown flags are OFF because every flag this CLI defines defaults off; a marker\n * for a flag this build does not know is a newer source's block, and advertising a\n * lane this build cannot gate is the unsafe direction. That default is safe for a\n * bare `when` and merely wrong-way-round for a when/else, so a typo in a flag NAME\n * cannot be caught here: `skill-writer.test.ts` pins every marker in every shipped\n * skill against {@link SKILL_CONTENT_FLAG_NAMES} instead, which is where a\n * misspelling has to fail.\n *\n * Every writer and every comparer resolves flags through {@link skillContentFlags}\n * so there is one mapping from machine facts to marker flags. `install`, the\n * post-command self-heal, the optional-skill placer and `doctor`'s staleness\n * compare all materialize; `scripts/pack-smoke.sh` cannot run this code against\n * the packed tarball, so it asserts the rendered PROPERTIES (marker-free, and no\n * sentence from the other mode) rather than raw bytes. Those five agree only while\n * that stays true: teaching four of five is how a shaped skill and a raw\n * comparison end up disagreeing forever.\n *\n * The grammar is deliberately line-based and flat (no nesting): the parse below\n * fails closed on anything else, because a half-stripped skill silently teaching\n * the wrong verb set is worse than a refused install.\n */\nconst OPEN_MARKER = /^\\s*<!--\\s*tenjin:when\\s+([a-zA-Z][a-zA-Z0-9.]*)\\s*-->\\s*$/;\nconst CLOSE_MARKER = /^\\s*<!--\\s*\\/tenjin:when\\s*-->\\s*$/;\n/** The arm switch. Carries no flag name: there is exactly one flag in play, the\n * open marker's, and repeating it is a second place for it to be misspelled. */\nconst ELSE_MARKER = /^\\s*<!--\\s*tenjin:else\\s*-->\\s*$/;\n/**\n * A line reaching for the grammar and missing it: trailing content after an open\n * marker, a flag name on a close or an else, a mistyped delimiter. Without this\n * such a line survives as ordinary content and the parse fails much later at\n * whichever marker is left unbalanced, naming a line the author did not write\n * wrong.\n */\nconst NEAR_MARKER = /^\\s*<!--\\s*\\/?\\s*tenjin:(?:when|else)\\b/;\n\n/** Flag values keyed by flag name; absent keys read as false. */\nexport type SkillContentFlags = Readonly<Record<string, boolean>>;\n\n/**\n * Every flag name a shipped skill's markers may use. A closed set, and the reason\n * it can be one is that the runtime deliberately cannot police it: an unknown flag\n * resolves OFF, which for a when/else pair means silently rendering the OTHER\n * mode's guidance. So the check for a misspelled flag is a build-time one over the\n * packaged skills (`skill-writer.test.ts`), and this is the list it checks against.\n */\nexport const SKILL_CONTENT_FLAG_NAMES = ['teamMode'] as const;\n\n/**\n * THE mapping from machine facts to marker flags. Every writer and comparer goes\n * through this rather than building a record inline, so there is one answer to\n * \"what does this machine's skill text say\" and no call site can drift by omitting\n * a flag (an omitted flag is a silent OFF, which is a rendered mode, not an error).\n *\n * `teamMode` is the machine's CONFIGURED mode — a team shelf of the team's own\n * plus its door key, per `settings.isTeamModeConfig` — not this invocation's. A\n * `--base-url` cannot reach it, and it should not: the file being written outlives\n * the command that wrote it and is read by every later session on this machine.\n */\nexport function skillContentFlags(facts: { teamMode: boolean }): SkillContentFlags {\n return { teamMode: facts.teamMode };\n}\n\n/** The transform `installSkill` takes, for a machine in the given mode. */\nexport function skillMaterialize(facts: {\n teamMode: boolean;\n}): (rel: string, content: Buffer) => Buffer {\n return materializeTransform(skillContentFlags(facts));\n}\n\n/** One packaged skill file's text as this machine would read it. */\nexport function renderSkillMarkdown(text: string, facts: { teamMode: boolean }): string {\n return materializeSkillMarkdown(text, skillContentFlags(facts));\n}\n\nexport function materializeSkillMarkdown(text: string, flags: SkillContentFlags): string {\n const lines = text.split('\\n');\n const out: string[] = [];\n let inBlock: string | null = null;\n /** Does the arm currently being read survive? */\n let keep = false;\n /** Has this block's `else` been seen? A second one is malformed, not a no-op. */\n let elsed = false;\n for (const [i, line] of lines.entries()) {\n const open = OPEN_MARKER.exec(line);\n if (open !== null) {\n if (inBlock !== null) {\n throw markerError(`nested tenjin:when at line ${i + 1} (already inside \"${inBlock}\")`);\n }\n inBlock = open[1]!;\n keep = flags[inBlock] === true;\n elsed = false;\n continue;\n }\n if (ELSE_MARKER.test(line)) {\n if (inBlock === null) throw markerError(`unopened tenjin:else at line ${i + 1}`);\n // Two elses would make the third arm's fate depend on parity, and the author\n // who typed it meant one of them to be a close.\n if (elsed) throw markerError(`second tenjin:else at line ${i + 1} in \"${inBlock}\"`);\n elsed = true;\n keep = !keep;\n continue;\n }\n if (CLOSE_MARKER.test(line)) {\n if (inBlock === null) throw markerError(`unopened /tenjin:when at line ${i + 1}`);\n inBlock = null;\n continue;\n }\n if (NEAR_MARKER.test(line)) {\n throw markerError(`malformed tenjin:when marker at line ${i + 1}: ${line.trim()}`);\n }\n if (inBlock === null || keep) out.push(line);\n }\n if (inBlock !== null) throw markerError(`unclosed tenjin:when \"${inBlock}\"`);\n return out.join('\\n');\n}\n\n/**\n * Every flag name the markers in `text` reference, in source order. Used by the\n * build-time pin over the packaged skills; see {@link SKILL_CONTENT_FLAG_NAMES}\n * for why that check cannot live in the parse.\n */\nexport function markerFlagsIn(text: string): string[] {\n return text\n .split('\\n')\n .map((line) => OPEN_MARKER.exec(line)?.[1])\n .filter((flag): flag is string => flag !== undefined);\n}\n\n/**\n * The transform `installSkill` takes for packaged source files. Only markdown is\n * text this grammar owns; any other file type a skill may ever ship passes through\n * byte-for-byte, so this can never corrupt a non-text asset.\n */\nexport function materializeTransform(\n flags: SkillContentFlags,\n): (rel: string, content: Buffer) => Buffer {\n return (rel, content) => {\n if (!rel.toLowerCase().endsWith('.md')) return content;\n return Buffer.from(materializeSkillMarkdown(content.toString('utf8'), flags), 'utf8');\n };\n}\n\nfunction markerError(detail: string): CliError {\n return new CliError('INTERNAL', `Malformed skill markers: ${detail}.`, {\n fix: 'Reinstall tenjin-cli; the packaged skills must carry balanced tenjin:when markers.',\n });\n}\n","import { existsSync } from 'node:fs';\nimport { lstat, readFile, readdir, realpath, stat } from 'node:fs/promises';\nimport { dirname, join, relative } from 'node:path';\nimport { writeFileAtomic } from './atomic-json';\nimport { hasCode } from './errno';\nimport { CliError } from './errors';\nimport { PRODUCTION_HOST } from './production-origin';\nimport { HOSTED_SKILL_NAME, readSkillFile } from './skill-wiring';\n\n/**\n * Writing one packaged skill into one harness directory, and the path guards that\n * write needs. Its own module, free of the command layer's dependencies, because\n * `install` and the post-command self-heal both write skills and the heal runs on\n * every command: reaching into commands/install would parse the wallet's viem\n * chunk on a `tenjin config`.\n */\n\nexport type SkillInstallStatus =\n 'installed' | 'updated' | 'up-to-date' | 'would-install' | 'would-update';\n\nexport interface SkillInstallResult {\n status: SkillInstallStatus;\n warning?: string;\n /** Was a real copy (a SKILL.md, not just the directory) already on disk before this run? */\n preexisting: boolean;\n}\n\nexport interface SkillWriteOptions {\n /**\n * Write THROUGH a symlinked destination (default), or replace it. `install`\n * follows the link, because the operator pointed it somewhere on purpose. The\n * unattended self-heal does not, and passes false: it has already refused every\n * link it could see, and this closes the gap between that look and this write,\n * where a link appearing in between would otherwise be followed. `rename` never\n * follows its final component, so the worst a race can now do is leave our\n * regular file where the new link was.\n */\n followSymlinks?: boolean;\n /**\n * Shape a packaged file before it is compared and written (config-conditional\n * skill content; see lib/skill-materialize). Applied to the SOURCE side only,\n * before the on-disk compare, so \"up-to-date\" means \"matches what this config\n * state would write\" and a config change makes the same source differ again. A\n * transform that throws aborts the whole install of this skill: a half-shaped\n * skill must never be written.\n */\n materialize?: (rel: string, content: Buffer) => Buffer;\n}\n\nexport async function installSkill(\n srcDir: string,\n destDir: string,\n dryRun: boolean,\n name: string,\n opts: SkillWriteOptions = {},\n): Promise<SkillInstallResult> {\n const src = await readTree(srcDir);\n if (src === null) {\n // assertSkillsSource already guards SKILL.md; this is defensive for an empty dir.\n throw new CliError('INTERNAL', `Packaged skill source ${srcDir} is empty`);\n }\n if (opts.materialize !== undefined) {\n for (const [rel, content] of src) src.set(rel, opts.materialize(rel, content));\n }\n\n // Only the files this package SHIPS are read and written. Everything else in the\n // directory belongs to the operator: never inspected, listed, or removed. That is\n // what package managers do (npm, dpkg, Homebrew all own their files, not the\n // directory), and wholesale replacement was the single cause behind a run of\n // data-loss, symlink and enumeration bugs.\n //\n // Resolved on BOTH paths, dry run included, so a dry run cannot promise a write\n // the real run refuses.\n const writeTo = new Map<string, string>();\n await assertReachable(destDir, name);\n await assertNoCaseCollision(destDir, name);\n for (const rel of src.keys()) {\n const declared = join(destDir, rel);\n writeTo.set(\n rel,\n opts.followSymlinks === false ? declared : await resolveThroughLink(declared, name),\n );\n }\n\n let differs = false;\n let preexisting = false;\n for (const [rel, content] of src) {\n const current = await readShippedFile(writeTo.get(rel)!, name, destDir);\n if (rel === 'SKILL.md') preexisting = current !== null;\n if (current === null || !current.equals(content)) differs = true;\n }\n const change = !preexisting ? 'create' : differs ? 'update' : 'none';\n\n if (!dryRun && change !== 'none') {\n for (const [rel, content] of src) {\n const target = writeTo.get(rel)!;\n try {\n // An existing file keeps the mode it has. A skill an operator (or their\n // dotfiles) made group-readable or read-only is theirs to have set that\n // way, and an update is no reason to hand it back at the default 0644.\n const current = await stat(target).catch(() => null);\n await writeFileAtomic(\n target,\n content,\n current === null ? {} : { mode: current.mode & 0o777 },\n );\n } catch (err) {\n // Culprit is derived from the file that FAILED, not assumed to be the\n // skills root: an existing skill directory that refuses the temp file is\n // itself the thing to chmod, and a symlinked SKILL.md fails in the link's\n // TARGET directory, which no path under destDir names.\n throw wrapWriteError(\n err,\n destDir,\n `the ${name} skill`,\n await deepestExisting(dirname(target)),\n { expected: ': a skill is a directory holding SKILL.md' },\n );\n }\n }\n }\n\n if (change === 'create') return { status: dryRun ? 'would-install' : 'installed', preexisting };\n if (change === 'none') return { status: 'up-to-date', preexisting };\n return {\n status: dryRun ? 'would-update' : 'updated',\n preexisting,\n // The hosted skill is a MIRROR of tenjin.blog/skills.md (roadmap G4), so a\n // differing local copy is a replacement, not the drift warning the CLI skills\n // get. Neither side carries a version or date, so the wording claims no\n // direction: the local file may well be a newer fetch than this package's copy.\n warning:\n name === HOSTED_SKILL_NAME\n ? `${destDir}: the hosted Tenjin skill differed and ${dryRun ? 'would be' : 'was'} replaced by this package's mirror of ${PRODUCTION_HOST}/skills.md, which may be older; it stays as the zero-install fallback. Re-fetch it from ${PRODUCTION_HOST}/skills.md if you need the current one.`\n : `${destDir}: local edits to ${name}'s SKILL.md ${dryRun ? 'would be' : 'were'} overwritten (the packaged copy is canonical).`,\n };\n}\n\n/**\n * Read a shipped file, or null when it is not there.\n *\n * The node-type guard lives in `readSkillFile`, shared with the wiring check and\n * the staleness check, because all three read the same operator-controlled paths\n * and a pipe at one of them used to hang whichever command got there first.\n */\nasync function readShippedFile(\n path: string,\n name: string,\n destDir: string,\n): Promise<Buffer | null> {\n const read = await readSkillFile(path);\n if (read.kind === 'absent') return null;\n if (read.kind === 'ok') return read.bytes;\n if (read.kind === 'not-regular') {\n throw new CliError('INTERNAL', `${path} is not a regular file, so ${name} was not written.`, {\n fix: `A skill file must be a regular file. Check what is there (\\`ls -l ${path}\\`) and remove or replace it, then re-run \\`tenjin install\\`.`,\n });\n }\n // Names the FILE, not its directory: this is a read failure, and pointing at a\n // perfectly writable parent is what sent operators to chmod the wrong thing.\n throw wrapWriteError(read.err, destDir, `the ${name} skill`, path, { verb: 'read' });\n}\n\n/**\n * A destination the operator manages through a symlink is written THROUGH it, so\n * their link survives and their target is what actually changes. Same call the\n * settings.json writer makes, and the same reason: committing with `rename` over a\n * link would replace it with a regular file and strand the target.\n */\nexport async function resolveThroughLink(path: string, name: string): Promise<string> {\n const entry = await lstat(path).catch(() => null);\n if (entry === null || !entry.isSymbolicLink()) return path;\n const target = await realpath(path).catch(() => null);\n if (target !== null) return target;\n throw new CliError('INTERNAL', `${path} is a broken symlink, so ${name} was not written.`, {\n fix: `Point it at a path that exists, or remove it (\\`ls -ld ${path}\\`), then re-run \\`tenjin install\\`.`,\n });\n}\n\n/**\n * On a case-insensitive filesystem (the macOS default), a user directory named a\n * case variant of a shipped skill ALIASES the skill's path, so the write would\n * replace the user's own SKILL.md under a warning naming a path that is not on\n * disk. Detected by the alias itself: the destination resolves but the parent\n * lists only a differently-cased entry, which also means a case-SENSITIVE\n * filesystem (where both names can coexist) never trips this. Dry runs too.\n */\nasync function assertNoCaseCollision(destDir: string, name: string): Promise<void> {\n if (!existsSync(destDir)) return;\n const entries = await readdir(dirname(destDir)).catch(() => null);\n if (entries === null || entries.includes(name)) return;\n const variant = entries.find((e) => e.toLowerCase() === name.toLowerCase());\n if (variant === undefined) return;\n const actual = join(dirname(destDir), variant);\n throw new CliError(\n 'INTERNAL',\n `${actual} is a case variant of the ${name} skill and this filesystem treats them as the same directory, so ${name} was not written.`,\n {\n fix: `Rename or remove ${actual}, then re-run \\`tenjin install\\`.`,\n },\n );\n}\n\n/**\n * Fail a destination directory that is a BROKEN SYMLINK, on dry runs too, so a dry\n * run cannot report `would-install` where the real run cannot write. It checks only\n * that: an unwritable but real directory passes here and fails at the write, with\n * the permission-denied error.\n */\nasync function assertReachable(destDir: string, name: string): Promise<void> {\n const entry = await lstat(destDir).catch(() => null);\n if (entry?.isSymbolicLink() !== true) return;\n if ((await realpath(destDir).catch(() => null)) !== null) return;\n throw new CliError('INTERNAL', `${destDir} is a broken symlink, so ${name} was not written.`, {\n fix: `Point it at a directory that exists, or remove it (\\`ls -ld ${destDir}\\`), then re-run \\`tenjin install\\`.`,\n });\n}\n\n/**\n * The directory a denied WRITE should point the operator at: the deepest existing\n * ancestor of the failed target's directory, RESOLVED. An existing skill directory\n * that refuses the temp file names itself; a directory that could not be created\n * names the ancestor that refused to create it, because `ls -ld` on a path that is\n * not there says nothing. Resolved because a destination managed through a symlink\n * denies the write in the link's TARGET, and telling the operator to chmod the\n * link's path leaves them staring at a healthy link.\n */\nexport async function deepestExisting(dir: string): Promise<string> {\n for (let cur = dir; ; cur = dirname(cur)) {\n if (existsSync(cur)) return realpath(cur).catch(() => cur);\n if (dirname(cur) === cur) return cur;\n }\n}\n\n/** A raw errno under INTERNAL reads as a CLI bug and carries no fix. */\nexport function wrapWriteError(\n err: unknown,\n /** The destination as the operator knows it (the declared path, pre-resolution). */\n dest: string,\n /** What could not be written, e.g. `the tenjin-search skill` or `the Tenjin pointer`. */\n subject: string,\n /**\n * The path to point the operator at. A READ failure names the file itself, which\n * is the thing whose mode is wrong. A WRITE failure names the deepest existing\n * directory on the failed target's resolved path.\n */\n culprit: string,\n opts: {\n /** Which side failed; a read error reported as \"could not write\" misleads. */\n verb?: 'read' | 'write';\n /** Sentence tail for the wrong-kind fix, telling the operator the expected shape. */\n expected?: string;\n } = {},\n): unknown {\n const verb = opts.verb ?? 'write';\n const denied = hasCode(err, 'EACCES') || hasCode(err, 'EPERM');\n const missing = hasCode(err, 'ENOENT');\n // A skills directory that resolves to a regular file, or a SKILL.md that resolves\n // to a directory. Pathological, but a raw ENOTDIR/EISDIR says nothing about which\n // path is the wrong kind of thing.\n const wrongKind = hasCode(err, 'ENOTDIR') || hasCode(err, 'EISDIR');\n if (!denied && !missing && !wrongKind) return err;\n const fix = denied\n ? `Permission denied on ${culprit}. Check it (\\`ls -ld ${culprit}\\`), then re-run \\`tenjin install\\`.`\n : wrongKind\n ? `${dest} (or a path inside it) is not the kind of thing it needs to be${opts.expected ?? ''}. Check it (\\`ls -ld ${dest}\\`), then re-run \\`tenjin install\\`.`\n : `${dest} could not be created; if it is a symlink, check that its target exists (\\`ls -ld ${dest}\\`), then re-run \\`tenjin install\\`.`;\n return new CliError(\n 'INTERNAL',\n `Could not ${verb} ${subject} ${verb === 'read' ? 'at' : 'to'} ${dest}.`,\n { fix, cause: err },\n );\n}\n\n/**\n * Read a directory tree into a rel-path -> content map, or null when it does not\n * exist. Reads as raw `Buffer`, not `utf8`: today's skills are markdown-only, but\n * this is a general recursive dir-copy, and decoding to a string here would\n * silently corrupt a future non-text asset (an image, a font) on write, or worse,\n * make two different corrupted binaries both decode to U+FFFD and compare equal.\n */\nasync function readTree(dir: string): Promise<Map<string, Buffer> | null> {\n if (!existsSync(dir)) return null;\n const entries = await readdir(dir, { recursive: true, withFileTypes: true });\n const files = new Map<string, Buffer>();\n for (const entry of entries) {\n if (!entry.isFile()) continue;\n const full = join(entry.parentPath, entry.name);\n files.set(relative(dir, full), await readFile(full));\n }\n return files;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,iBAAiB;AAC1B,SAAS,WAAAA,UAAS,IAAI,aAAa;AACnC,SAAS,eAAe;AACxB,SAAS,YAAY,QAAAC,aAAY;AACjC,SAAS,qBAAqB;;;ACwC9B,IAAM,cAAc;AACpB,IAAM,eAAe;AAGrB,IAAM,cAAc;AAQpB,IAAM,cAAc;AAyBb,SAAS,kBAAkB,OAAiD;AACjF,SAAO,EAAE,UAAU,MAAM,SAAS;AACpC;AAGO,SAAS,iBAAiB,OAEY;AAC3C,SAAO,qBAAqB,kBAAkB,KAAK,CAAC;AACtD;AAOO,SAAS,yBAAyB,MAAc,OAAkC;AACvF,QAAM,QAAQ,KAAK,MAAM,IAAI;AAC7B,QAAM,MAAgB,CAAC;AACvB,MAAI,UAAyB;AAE7B,MAAI,OAAO;AAEX,MAAI,QAAQ;AACZ,aAAW,CAAC,GAAG,IAAI,KAAK,MAAM,QAAQ,GAAG;AACvC,UAAM,OAAO,YAAY,KAAK,IAAI;AAClC,QAAI,SAAS,MAAM;AACjB,UAAI,YAAY,MAAM;A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AA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AACA,UAAI,QAAS,SAAQ,KAAKA,MAAK,KAAK,kBAAkB,CAAC;AAAA,IACzD,QAAQ;AAAA,IAER;AAAA,EACF;AACA,MAAI,QAAQ,SAAS,GAAG;AACtB;AAAA,MACE,KAAK;AAAA,MACL,GAAG,UAAU,cAAc,SAAS,IAAI,QAAQ,KAAK,OAAO,CAAC;AAAA,IAC/D;AAAA,EACF;AACF;","names":["readdir","join","join","readdir"]}
1
+ {"version":3,"sources":["../src/lib/skill-placement.ts","../src/lib/skill-materialize.ts","../src/lib/skill-writer.ts"],"sourcesContent":["import { lstatSync } from 'node:fs';\nimport { readdir, rm, rmdir } from 'node:fs/promises';\nimport { homedir } from 'node:os';\nimport { isAbsolute, join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { emitWriteNotice } from './output';\nimport type { Io } from './output';\nimport { loadRawConfig } from './config';\nimport { isTeamModeConfig } from './settings';\nimport { skillMaterialize } from './skill-materialize';\nimport { readSkillFile, skillFrontmatterName, skillsDirsFor } from './skill-wiring';\nimport { installSkill } from './skill-writer';\nimport { OPTIONAL_PAY_SKILL, SKILL_NAMES, resolveSkillsSource } from './skills-source';\n\n/**\n * Optional skills, where PRESENCE is the whole mechanism: the tenjin-pay skill\n * is on disk exactly while the `bazaarPay` toggle is on, so an agent is never\n * taught a lane the operator turned off, and turning the lane on is what makes\n * the teaching appear. No conditional content, no markers: the unit of\n * consent stays the one the whole pipeline already has, a skill directory.\n *\n * Its CONTENT still goes through the same shaping every other skill's does\n * (lib/skill-materialize): presence and content are different questions, and the\n * placer is one of the writers that has to materialize for the comparers to keep\n * agreeing. tenjin-pay ships no marker today, so it is a no-op there — but a\n * placer that skipped shaping would be the one writer whose `up-to-date` meant\n * something different from everyone else's.\n *\n * Removal follows `uninstall`'s rules exactly (lib/uninstall removeSkills):\n * only a SKILL.md whose frontmatter still claims our name is ours to delete,\n * and the directory goes only when our file was the only thing in it, so an\n * operator's own files beside it survive a toggle-off.\n */\n\n/** Ensure `name` is present or absent under one skills directory. */\nexport async function placeOptionalSkill(\n name: string,\n skillsDir: string,\n skillsSource: string,\n present: boolean,\n teamMode: boolean,\n): Promise<{ changed: boolean }> {\n const skillDir = join(skillsDir, name);\n if (present) {\n const { status } = await installSkill(join(skillsSource, name), skillDir, false, name, {\n materialize: skillMaterialize({ teamMode }),\n });\n return { changed: status !== 'up-to-date' };\n }\n if (lstatSync(skillDir, { throwIfNoEntry: false })?.isDirectory() !== true) {\n return { changed: false };\n }\n const path = join(skillDir, 'SKILL.md');\n const read = await readSkillFile(path);\n if (read.kind === 'absent') return { changed: false };\n if (read.kind !== 'ok' || skillFrontmatterName(read.bytes.toString('utf8')) !== name) {\n return { changed: false }; // not ours to delete for sitting at our path\n }\n await rm(path, { force: true });\n const rest = await readdir(skillDir).catch(() => null);\n if (rest !== null && rest.length === 0) await rmdir(skillDir).catch(() => undefined);\n return { changed: true };\n}\n\n/**\n * The `config set bazaarPay` twin of the heal: converge the tenjin-pay skill's\n * presence with the toggle across every skills directory a tenjin skill is\n * already wired into (presence of any shipped skill is the operator's consent\n * to a directory; an unwired directory is never created). Operator act, so\n * failures degrade per directory and doctor reports what remains.\n */\nexport async function syncBazaarSkill(\n enabled: boolean,\n deps: {\n io: Io;\n homeDir?: string;\n skillsSourceDir?: string;\n /** Where `config.json` lives, for the team-mode fact the content is shaped by.\n * Absent means public, for a caller with no data dir to read. */\n dataDir?: string;\n },\n): Promise<void> {\n const home = deps.homeDir ?? homedir();\n if (!isAbsolute(home)) return;\n // Same fail-safe as the heal's: an unreadable config throws out of here rather\n // than being guessed as public, which on a team machine would write the other\n // mode's text. The caller is already best-effort after a successful persist.\n const teamMode =\n deps.dataDir === undefined ? false : isTeamModeConfig(await loadRawConfig(deps.dataDir));\n let source: string;\n try {\n source =\n deps.skillsSourceDir ?? resolveSkillsSource(fileURLToPath(new URL('.', import.meta.url)));\n } catch {\n return; // no readable source: nothing safe to write, nothing to remove FROM\n }\n const touched: string[] = [];\n for (const dir of skillsDirsFor(home)) {\n try {\n if (lstatSync(dir, { throwIfNoEntry: false })?.isDirectory() !== true) continue;\n const consented = SKILL_NAMES.some(\n (name) =>\n lstatSync(join(dir, name, 'SKILL.md'), { throwIfNoEntry: false })?.isFile() === true,\n );\n if (!consented) continue;\n const { changed } = await placeOptionalSkill(\n OPTIONAL_PAY_SKILL,\n dir,\n source,\n enabled,\n teamMode,\n );\n if (changed) touched.push(join(dir, OPTIONAL_PAY_SKILL));\n } catch {\n // This directory keeps what it has; `tenjin doctor` reports the drift.\n }\n }\n if (touched.length > 0) {\n emitWriteNotice(\n deps.io,\n `${enabled ? 'Installed' : 'Removed'} ${touched.join(' and ')} to match bazaarPay.`,\n );\n }\n}\n","import { CliError } from './errors';\n\n/**\n * Config-conditional blocks in packaged skill markdown. A skill source may wrap a\n * region in full-line HTML-comment markers:\n *\n * <!-- tenjin:when teamMode -->\n * ...lines an agent should only see when the flag is on...\n * <!-- tenjin:else -->\n * ...lines an agent should only see when it is off...\n * <!-- /tenjin:when -->\n *\n * Materializing resolves those regions against a flag set and the marker lines\n * themselves never survive, so an installed SKILL.md carries no machinery for an\n * agent to read. The `else` arm is what makes this a REPLACEMENT seam rather than\n * an additive one, and it is the whole reason it exists: the two arms are\n * structurally exclusive, so exactly one of them can ever reach a reader. Guidance\n * that DIFFERS by machine fact is written as one when/else pair replacing one\n * region, never as a base paragraph plus a \"however, on a team shelf...\" rider —\n * a reader in either mode would then see both, and two rules for the same decision\n * in one file is worse than either rule alone. A bare `when` with no `else` stays\n * legal for content that is genuinely additive.\n *\n * Unknown flags are OFF because every flag this CLI defines defaults off; a marker\n * for a flag this build does not know is a newer source's block, and advertising a\n * lane this build cannot gate is the unsafe direction. That default is safe for a\n * bare `when` and merely wrong-way-round for a when/else, so a typo in a flag NAME\n * cannot be caught here: `skill-writer.test.ts` pins every marker in every shipped\n * skill against {@link SKILL_CONTENT_FLAG_NAMES} instead, which is where a\n * misspelling has to fail.\n *\n * Every writer and every comparer resolves flags through {@link skillContentFlags}\n * so there is one mapping from machine facts to marker flags. `install`, the\n * post-command self-heal, the optional-skill placer and `doctor`'s staleness\n * compare all materialize; `scripts/pack-smoke.sh` cannot run this code against\n * the packed tarball, so it asserts the rendered PROPERTIES (marker-free, and no\n * sentence from the other mode) rather than raw bytes. Those five agree only while\n * that stays true: teaching four of five is how a shaped skill and a raw\n * comparison end up disagreeing forever.\n *\n * The grammar is deliberately line-based and flat (no nesting): the parse below\n * fails closed on anything else, because a half-stripped skill silently teaching\n * the wrong verb set is worse than a refused install.\n */\nconst OPEN_MARKER = /^\\s*<!--\\s*tenjin:when\\s+([a-zA-Z][a-zA-Z0-9.]*)\\s*-->\\s*$/;\nconst CLOSE_MARKER = /^\\s*<!--\\s*\\/tenjin:when\\s*-->\\s*$/;\n/** The arm switch. Carries no flag name: there is exactly one flag in play, the\n * open marker's, and repeating it is a second place for it to be misspelled. */\nconst ELSE_MARKER = /^\\s*<!--\\s*tenjin:else\\s*-->\\s*$/;\n/**\n * A line reaching for the grammar and missing it: trailing content after an open\n * marker, a flag name on a close or an else, a mistyped delimiter. Without this\n * such a line survives as ordinary content and the parse fails much later at\n * whichever marker is left unbalanced, naming a line the author did not write\n * wrong.\n */\nconst NEAR_MARKER = /^\\s*<!--\\s*\\/?\\s*tenjin:(?:when|else)\\b/;\n\n/** Flag values keyed by flag name; absent keys read as false. */\nexport type SkillContentFlags = Readonly<Record<string, boolean>>;\n\n/**\n * Every flag name a shipped skill's markers may use. A closed set, and the reason\n * it can be one is that the runtime deliberately cannot police it: an unknown flag\n * resolves OFF, which for a when/else pair means silently rendering the OTHER\n * mode's guidance. So the check for a misspelled flag is a build-time one over the\n * packaged skills (`skill-writer.test.ts`), and this is the list it checks against.\n */\nexport const SKILL_CONTENT_FLAG_NAMES = ['teamMode'] as const;\n\n/**\n * THE mapping from machine facts to marker flags. Every writer and comparer goes\n * through this rather than building a record inline, so there is one answer to\n * \"what does this machine's skill text say\" and no call site can drift by omitting\n * a flag (an omitted flag is a silent OFF, which is a rendered mode, not an error).\n *\n * `teamMode` is the machine's CONFIGURED mode — a team shelf of the team's own\n * plus its door key, per `settings.isTeamModeConfig` — not this invocation's. A\n * `--base-url` cannot reach it, and it should not: the file being written outlives\n * the command that wrote it and is read by every later session on this machine.\n */\nexport function skillContentFlags(facts: { teamMode: boolean }): SkillContentFlags {\n return { teamMode: facts.teamMode };\n}\n\n/** The transform `installSkill` takes, for a machine in the given mode. */\nexport function skillMaterialize(facts: {\n teamMode: boolean;\n}): (rel: string, content: Buffer) => Buffer {\n return materializeTransform(skillContentFlags(facts));\n}\n\n/** One packaged skill file's text as this machine would read it. */\nexport function renderSkillMarkdown(text: string, facts: { teamMode: boolean }): string {\n return materializeSkillMarkdown(text, skillContentFlags(facts));\n}\n\nexport function materializeSkillMarkdown(text: string, flags: SkillContentFlags): string {\n const lines = text.split('\\n');\n const out: string[] = [];\n let inBlock: string | null = null;\n /** Does the arm currently being read survive? */\n let keep = false;\n /** Has this block's `else` been seen? A second one is malformed, not a no-op. */\n let elsed = false;\n for (const [i, line] of lines.entries()) {\n const open = OPEN_MARKER.exec(line);\n if (open !== null) {\n if (inBlock !== null) {\n throw markerError(`nested tenjin:when at line ${i + 1} (already inside \"${inBlock}\")`);\n }\n inBlock = open[1]!;\n keep = flags[inBlock] === true;\n elsed = false;\n continue;\n }\n if (ELSE_MARKER.test(line)) {\n if (inBlock === null) throw markerError(`unopened tenjin:else at line ${i + 1}`);\n // Two elses would make the third arm's fate depend on parity, and the author\n // who typed it meant one of them to be a close.\n if (elsed) throw markerError(`second tenjin:else at line ${i + 1} in \"${inBlock}\"`);\n elsed = true;\n keep = !keep;\n continue;\n }\n if (CLOSE_MARKER.test(line)) {\n if (inBlock === null) throw markerError(`unopened /tenjin:when at line ${i + 1}`);\n inBlock = null;\n continue;\n }\n if (NEAR_MARKER.test(line)) {\n throw markerError(`malformed tenjin:when marker at line ${i + 1}: ${line.trim()}`);\n }\n if (inBlock === null || keep) out.push(line);\n }\n if (inBlock !== null) throw markerError(`unclosed tenjin:when \"${inBlock}\"`);\n return out.join('\\n');\n}\n\n/**\n * Every flag name the markers in `text` reference, in source order. Used by the\n * build-time pin over the packaged skills; see {@link SKILL_CONTENT_FLAG_NAMES}\n * for why that check cannot live in the parse.\n */\nexport function markerFlagsIn(text: string): string[] {\n return text\n .split('\\n')\n .map((line) => OPEN_MARKER.exec(line)?.[1])\n .filter((flag): flag is string => flag !== undefined);\n}\n\n/**\n * The transform `installSkill` takes for packaged source files. Only markdown is\n * text this grammar owns; any other file type a skill may ever ship passes through\n * byte-for-byte, so this can never corrupt a non-text asset.\n */\nexport function materializeTransform(\n flags: SkillContentFlags,\n): (rel: string, content: Buffer) => Buffer {\n return (rel, content) => {\n if (!rel.toLowerCase().endsWith('.md')) return content;\n return Buffer.from(materializeSkillMarkdown(content.toString('utf8'), flags), 'utf8');\n };\n}\n\nfunction markerError(detail: string): CliError {\n return new CliError('INTERNAL', `Malformed skill markers: ${detail}.`, {\n fix: 'Reinstall tenjin-cli; the packaged skills must carry balanced tenjin:when markers.',\n });\n}\n","import { existsSync } from 'node:fs';\nimport { lstat, readFile, readdir, realpath, stat } from 'node:fs/promises';\nimport { dirname, join, relative } from 'node:path';\nimport { writeFileAtomic } from './atomic-json';\nimport { hasCode } from './errno';\nimport { CliError } from './errors';\nimport { PRODUCTION_HOST } from './production-origin';\nimport { HOSTED_SKILL_NAME, readSkillFile } from './skill-wiring';\n\n/**\n * Writing one packaged skill into one harness directory, and the path guards that\n * write needs. Its own module, free of the command layer's dependencies, because\n * `install` and the post-command self-heal both write skills and the heal runs on\n * every command: reaching into commands/install would parse the wallet's viem\n * chunk on a `tenjin config`.\n */\n\nexport type SkillInstallStatus =\n 'installed' | 'updated' | 'up-to-date' | 'would-install' | 'would-update';\n\nexport interface SkillInstallResult {\n status: SkillInstallStatus;\n warning?: string;\n /** Was a real copy (a SKILL.md, not just the directory) already on disk before this run? */\n preexisting: boolean;\n}\n\nexport interface SkillWriteOptions {\n /**\n * Write THROUGH a symlinked destination (default), or replace it. `install`\n * follows the link, because the operator pointed it somewhere on purpose. The\n * unattended self-heal does not, and passes false: it has already refused every\n * link it could see, and this closes the gap between that look and this write,\n * where a link appearing in between would otherwise be followed. `rename` never\n * follows its final component, so the worst a race can now do is leave our\n * regular file where the new link was.\n */\n followSymlinks?: boolean;\n /**\n * Shape a packaged file before it is compared and written (config-conditional\n * skill content; see lib/skill-materialize). Applied to the SOURCE side only,\n * before the on-disk compare, so \"up-to-date\" means \"matches what this config\n * state would write\" and a config change makes the same source differ again. A\n * transform that throws aborts the whole install of this skill: a half-shaped\n * skill must never be written.\n */\n materialize?: (rel: string, content: Buffer) => Buffer;\n}\n\nexport async function installSkill(\n srcDir: string,\n destDir: string,\n dryRun: boolean,\n name: string,\n opts: SkillWriteOptions = {},\n): Promise<SkillInstallResult> {\n const src = await readTree(srcDir);\n if (src === null) {\n // assertSkillsSource already guards SKILL.md; this is defensive for an empty dir.\n throw new CliError('INTERNAL', `Packaged skill source ${srcDir} is empty`);\n }\n if (opts.materialize !== undefined) {\n for (const [rel, content] of src) src.set(rel, opts.materialize(rel, content));\n }\n\n // Only the files this package SHIPS are read and written. Everything else in the\n // directory belongs to the operator: never inspected, listed, or removed. That is\n // what package managers do (npm, dpkg, Homebrew all own their files, not the\n // directory), and wholesale replacement was the single cause behind a run of\n // data-loss, symlink and enumeration bugs.\n //\n // Resolved on BOTH paths, dry run included, so a dry run cannot promise a write\n // the real run refuses.\n const writeTo = new Map<string, string>();\n await assertReachable(destDir, name);\n await assertNoCaseCollision(destDir, name);\n for (const rel of src.keys()) {\n const declared = join(destDir, rel);\n writeTo.set(\n rel,\n opts.followSymlinks === false ? declared : await resolveThroughLink(declared, name),\n );\n }\n\n let differs = false;\n let preexisting = false;\n for (const [rel, content] of src) {\n const current = await readShippedFile(writeTo.get(rel)!, name, destDir);\n if (rel === 'SKILL.md') preexisting = current !== null;\n if (current === null || !current.equals(content)) differs = true;\n }\n const change = !preexisting ? 'create' : differs ? 'update' : 'none';\n\n if (!dryRun && change !== 'none') {\n for (const [rel, content] of src) {\n const target = writeTo.get(rel)!;\n try {\n // An existing file keeps the mode it has. A skill an operator (or their\n // dotfiles) made group-readable or read-only is theirs to have set that\n // way, and an update is no reason to hand it back at the default 0644.\n const current = await stat(target).catch(() => null);\n await writeFileAtomic(\n target,\n content,\n current === null ? {} : { mode: current.mode & 0o777 },\n );\n } catch (err) {\n // Culprit is derived from the file that FAILED, not assumed to be the\n // skills root: an existing skill directory that refuses the temp file is\n // itself the thing to chmod, and a symlinked SKILL.md fails in the link's\n // TARGET directory, which no path under destDir names.\n throw wrapWriteError(\n err,\n destDir,\n `the ${name} skill`,\n await deepestExisting(dirname(target)),\n { expected: ': a skill is a directory holding SKILL.md' },\n );\n }\n }\n }\n\n if (change === 'create') return { status: dryRun ? 'would-install' : 'installed', preexisting };\n if (change === 'none') return { status: 'up-to-date', preexisting };\n return {\n status: dryRun ? 'would-update' : 'updated',\n preexisting,\n // The hosted skill is a MIRROR of tenjin.blog/skills.md (roadmap G4), so a\n // differing local copy is a replacement, not the drift warning the CLI skills\n // get. Neither side carries a version or date, so the wording claims no\n // direction: the local file may well be a newer fetch than this package's copy.\n warning:\n name === HOSTED_SKILL_NAME\n ? `${destDir}: the hosted Tenjin skill differed and ${dryRun ? 'would be' : 'was'} replaced by this package's mirror of ${PRODUCTION_HOST}/skills.md, which may be older; it stays as the zero-install fallback. Re-fetch it from ${PRODUCTION_HOST}/skills.md if you need the current one.`\n : `${destDir}: local edits to ${name}'s SKILL.md ${dryRun ? 'would be' : 'were'} overwritten (the packaged copy is canonical).`,\n };\n}\n\n/**\n * Read a shipped file, or null when it is not there.\n *\n * The node-type guard lives in `readSkillFile`, shared with the wiring check and\n * the staleness check, because all three read the same operator-controlled paths\n * and a pipe at one of them used to hang whichever command got there first.\n */\nasync function readShippedFile(\n path: string,\n name: string,\n destDir: string,\n): Promise<Buffer | null> {\n const read = await readSkillFile(path);\n if (read.kind === 'absent') return null;\n if (read.kind === 'ok') return read.bytes;\n if (read.kind === 'not-regular') {\n throw new CliError('INTERNAL', `${path} is not a regular file, so ${name} was not written.`, {\n fix: `A skill file must be a regular file. Check what is there (\\`ls -l ${path}\\`) and remove or replace it, then re-run \\`tenjin install\\`.`,\n });\n }\n // Names the FILE, not its directory: this is a read failure, and pointing at a\n // perfectly writable parent is what sent operators to chmod the wrong thing.\n throw wrapWriteError(read.err, destDir, `the ${name} skill`, path, { verb: 'read' });\n}\n\n/**\n * A destination the operator manages through a symlink is written THROUGH it, so\n * their link survives and their target is what actually changes. Same call the\n * settings.json writer makes, and the same reason: committing with `rename` over a\n * link would replace it with a regular file and strand the target.\n */\nexport async function resolveThroughLink(path: string, name: string): Promise<string> {\n const entry = await lstat(path).catch(() => null);\n if (entry === null || !entry.isSymbolicLink()) return path;\n const target = await realpath(path).catch(() => null);\n if (target !== null) return target;\n throw new CliError('INTERNAL', `${path} is a broken symlink, so ${name} was not written.`, {\n fix: `Point it at a path that exists, or remove it (\\`ls -ld ${path}\\`), then re-run \\`tenjin install\\`.`,\n });\n}\n\n/**\n * On a case-insensitive filesystem (the macOS default), a user directory named a\n * case variant of a shipped skill ALIASES the skill's path, so the write would\n * replace the user's own SKILL.md under a warning naming a path that is not on\n * disk. Detected by the alias itself: the destination resolves but the parent\n * lists only a differently-cased entry, which also means a case-SENSITIVE\n * filesystem (where both names can coexist) never trips this. Dry runs too.\n */\nasync function assertNoCaseCollision(destDir: string, name: string): Promise<void> {\n if (!existsSync(destDir)) return;\n const entries = await readdir(dirname(destDir)).catch(() => null);\n if (entries === null || entries.includes(name)) return;\n const variant = entries.find((e) => e.toLowerCase() === name.toLowerCase());\n if (variant === undefined) return;\n const actual = join(dirname(destDir), variant);\n throw new CliError(\n 'INTERNAL',\n `${actual} is a case variant of the ${name} skill and this filesystem treats them as the same directory, so ${name} was not written.`,\n {\n fix: `Rename or remove ${actual}, then re-run \\`tenjin install\\`.`,\n },\n );\n}\n\n/**\n * Fail a destination directory that is a BROKEN SYMLINK, on dry runs too, so a dry\n * run cannot report `would-install` where the real run cannot write. It checks only\n * that: an unwritable but real directory passes here and fails at the write, with\n * the permission-denied error.\n */\nasync function assertReachable(destDir: string, name: string): Promise<void> {\n const entry = await lstat(destDir).catch(() => null);\n if (entry?.isSymbolicLink() !== true) return;\n if ((await realpath(destDir).catch(() => null)) !== null) return;\n throw new CliError('INTERNAL', `${destDir} is a broken symlink, so ${name} was not written.`, {\n fix: `Point it at a directory that exists, or remove it (\\`ls -ld ${destDir}\\`), then re-run \\`tenjin install\\`.`,\n });\n}\n\n/**\n * The directory a denied WRITE should point the operator at: the deepest existing\n * ancestor of the failed target's directory, RESOLVED. An existing skill directory\n * that refuses the temp file names itself; a directory that could not be created\n * names the ancestor that refused to create it, because `ls -ld` on a path that is\n * not there says nothing. Resolved because a destination managed through a symlink\n * denies the write in the link's TARGET, and telling the operator to chmod the\n * link's path leaves them staring at a healthy link.\n */\nexport async function deepestExisting(dir: string): Promise<string> {\n for (let cur = dir; ; cur = dirname(cur)) {\n if (existsSync(cur)) return realpath(cur).catch(() => cur);\n if (dirname(cur) === cur) return cur;\n }\n}\n\n/** A raw errno under INTERNAL reads as a CLI bug and carries no fix. */\nexport function wrapWriteError(\n err: unknown,\n /** The destination as the operator knows it (the declared path, pre-resolution). */\n dest: string,\n /** What could not be written, e.g. `the tenjin-search skill` or `the Tenjin pointer`. */\n subject: string,\n /**\n * The path to point the operator at. A READ failure names the file itself, which\n * is the thing whose mode is wrong. A WRITE failure names the deepest existing\n * directory on the failed target's resolved path.\n */\n culprit: string,\n opts: {\n /** Which side failed; a read error reported as \"could not write\" misleads. */\n verb?: 'read' | 'write';\n /** Sentence tail for the wrong-kind fix, telling the operator the expected shape. */\n expected?: string;\n } = {},\n): unknown {\n const verb = opts.verb ?? 'write';\n const denied = hasCode(err, 'EACCES') || hasCode(err, 'EPERM');\n const missing = hasCode(err, 'ENOENT');\n // A skills directory that resolves to a regular file, or a SKILL.md that resolves\n // to a directory. Pathological, but a raw ENOTDIR/EISDIR says nothing about which\n // path is the wrong kind of thing.\n const wrongKind = hasCode(err, 'ENOTDIR') || hasCode(err, 'EISDIR');\n if (!denied && !missing && !wrongKind) return err;\n const fix = denied\n ? `Permission denied on ${culprit}. Check it (\\`ls -ld ${culprit}\\`), then re-run \\`tenjin install\\`.`\n : wrongKind\n ? `${dest} (or a path inside it) is not the kind of thing it needs to be${opts.expected ?? ''}. Check it (\\`ls -ld ${dest}\\`), then re-run \\`tenjin install\\`.`\n : `${dest} could not be created; if it is a symlink, check that its target exists (\\`ls -ld ${dest}\\`), then re-run \\`tenjin install\\`.`;\n return new CliError(\n 'INTERNAL',\n `Could not ${verb} ${subject} ${verb === 'read' ? 'at' : 'to'} ${dest}.`,\n { fix, cause: err },\n );\n}\n\n/**\n * Read a directory tree into a rel-path -> content map, or null when it does not\n * exist. Reads as raw `Buffer`, not `utf8`: today's skills are markdown-only, but\n * this is a general recursive dir-copy, and decoding to a string here would\n * silently corrupt a future non-text asset (an image, a font) on write, or worse,\n * make two different corrupted binaries both decode to U+FFFD and compare equal.\n */\nasync function readTree(dir: string): Promise<Map<string, Buffer> | null> {\n if (!existsSync(dir)) return null;\n const entries = await readdir(dir, { recursive: true, withFileTypes: true });\n const files = new Map<string, Buffer>();\n for (const entry of entries) {\n if (!entry.isFile()) continue;\n const full = join(entry.parentPath, entry.name);\n files.set(relative(dir, full), await readFile(full));\n }\n return files;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,iBAAiB;AAC1B,SAAS,WAAAA,UAAS,IAAI,aAAa;AACnC,SAAS,eAAe;AACxB,SAAS,YAAY,QAAAC,aAAY;AACjC,SAAS,qBAAqB;;;ACwC9B,IAAM,cAAc;AACpB,IAAM,eAAe;AAGrB,IAAM,cAAc;AAQpB,IAAM,cAAc;AAyBb,SAAS,kBAAkB,OAAiD;AACjF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C,CAAC;AAAA,EAC5F,QAAQ;AACN;AAAA,EACF;AACA,QAAM,UAAoB,CAAC;AAC3B,aAAW,OAAO,cAAc,IAAI,GAAG;AACrC,QAAI;AACF,UAAI,UAAU,KAAK,EAAE,gBAAgB,MAAM,CAAC,GAAG,YAAY,MAAM,KAAM;AACvE,YAAM,YAAY,YAAY;AAAA,QAC5B,CAAC,SACC,UAAUD,MAAK,KAAK,MAAM,UAAU,GAAG,EAAE,gBAAgB,MAAM,CAAC,GAAG,OAAO,MAAM;AAAA,MACpF;AACA,UAAI,CAAC,UAAW;AAChB,YAAM,EAAE,QAAQ,IAAI,MAAM;AAAA,QACxB;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AACA,UAAI,QAAS,SAAQ,KAAKA,MAAK,KAAK,kBAAkB,CAAC;AAAA,IACzD,QAAQ;AAAA,IAER;AAAA,EACF;AACA,MAAI,QAAQ,SAAS,GAAG;AACtB;AAAA,MACE,KAAK;AAAA,MACL,GAAG,UAAU,cAAc,SAAS,IAAI,QAAQ,KAAK,OAAO,CAAC;AAAA,IAC/D;AAAA,EACF;AACF;","names":["readdir","join","join","readdir"]}
@@ -1,18 +1,19 @@
1
1
  import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
+ import "./chunk-AUKDYPPX.js";
2
3
  import {
3
4
  readSpendSummary
4
- } from "./chunk-DMZZLPZN.js";
5
+ } from "./chunk-35M3VITA.js";
5
6
  import "./chunk-MEFB5KHA.js";
7
+ import "./chunk-2I4QTOLB.js";
6
8
  import {
7
9
  resolveContextSettings
8
- } from "./chunk-OJLYNM4Z.js";
10
+ } from "./chunk-PDA2BVFY.js";
9
11
  import {
10
12
  toMoney
11
- } from "./chunk-WH7OWT6G.js";
12
- import "./chunk-BBVUVBUO.js";
13
- import "./chunk-OCBHUHWB.js";
13
+ } from "./chunk-U2DZISAH.js";
14
+ import "./chunk-AR7U7BRG.js";
15
+ import "./chunk-JLEF5WHM.js";
14
16
  import "./chunk-2BKS2FVE.js";
15
- import "./chunk-7WEQQJLG.js";
16
17
  import "./chunk-ZXTAQYNA.js";
17
18
 
18
19
  // src/router/status.ts
@@ -60,4 +61,4 @@ function confirmLabel(confirm) {
60
61
  export {
61
62
  runRouterStatus
62
63
  };
63
- //# sourceMappingURL=status-T2SDB57A.js.map
64
+ //# sourceMappingURL=status-FFC6FO72.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/router/status.ts"],"sourcesContent":["import { toMoney } from '../lib/money';\nimport type { ConfirmPolicy } from '../lib/policy';\nimport { resolveContextSettings } from '../lib/settings';\nimport { readSpendSummary } from '../lib/wallet/spend';\nimport type { CommandContext, CommandResult } from '../context';\n\n/**\n * `tenjin status`: what this machine has spent and what it is still holding.\n *\n * IT READS `spend.json`, NOT THE BACKEND. The rolling window, the committed\n * total and the reservations still open are the local truth about money, and\n * the reservations are also the record of a request whose outcome is unknown:\n * an authorization that was transmitted is committed, so anything still open\n * here is either in flight or a crash that has not yet aged out.\n */\n\nexport interface StatusDeps {\n now?: () => number;\n}\n\nexport async function runRouterStatus(\n ctx: CommandContext,\n deps: StatusDeps = {},\n): Promise<CommandResult> {\n const now = deps.now ?? Date.now;\n const settings = await resolveContextSettings(ctx);\n // The same projection an authorization would make, so what this prints is\n // what the next lookup would actually be measured against.\n const ledger = await readSpendSummary(ctx.dataDir, { now });\n const committedAtomic = BigInt(ledger?.committedAtomic ?? '0');\n const reservedAtomic = (ledger?.reservations ?? []).reduce(\n (sum, r) => sum + BigInt(r.amountAtomic),\n 0n,\n );\n const budgetAtomic = BigInt(settings.policy.sessionBudgetAtomic);\n const data = {\n baseUrl: settings.baseUrl,\n window: {\n startedAtMs: ledger?.windowStartMs ?? null,\n committed: toMoney(committedAtomic.toString()),\n reserved: toMoney(reservedAtomic.toString()),\n budget: budgetAtomic === 0n ? null : toMoney(budgetAtomic.toString()),\n },\n caps: {\n maxAutoSpend: toMoney(settings.policy.maxAutoSpendAtomic.toString()),\n confirm: confirmLabel(settings.policy.confirm),\n },\n inFlight: (ledger?.reservations ?? []).map((r) => ({\n amount: toMoney(r.amountAtomic),\n ageSeconds: Math.max(0, Math.round((now() - r.atMs) / 1000)),\n ...(r.requestKey !== undefined ? { request: r.requestKey } : {}),\n })),\n };\n const budgetLine =\n budgetAtomic === 0n\n ? 'no session budget set'\n : `of ${toMoney(budgetAtomic.toString()).usd} USD in the rolling 24h window`;\n return {\n data,\n humanLines: [\n `spent ${toMoney(committedAtomic.toString()).usd} USD ${budgetLine}`,\n `reserved ${toMoney(reservedAtomic.toString()).usd} USD in ${data.inFlight.length} open request(s)`,\n `per call at most ${toMoney(settings.policy.maxAutoSpendAtomic.toString()).usd} USD, confirm ${confirmLabel(settings.policy.confirm)}`,\n ],\n };\n}\n\nfunction confirmLabel(confirm: ConfirmPolicy): string {\n return confirm.mode === 'always'\n ? 'always'\n : `above ${toMoney(confirm.thresholdAtomic.toString()).usd} USD`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAoBA,eAAsB,gBACpB,KACA,OAAmB,CAAC,GACI;AACxB,QAAM,MAAM,KAAK,OAAO,KAAK;AAC7B,QAAM,WAAW,MAAM,uBAAuB,GAAG;AAGjD,QAAM,SAAS,MAAM,iBAAiB,IAAI,SAAS,EAAE,IAAI,CAAC;AAC1D,QAAM,kBAAkB,OAAO,QAAQ,mBAAmB,GAAG;AAC7D,QAAM,kBAAkB,QAAQ,gBAAgB,CAAC,GAAG;AAAA,IAClD,CAAC,KAAK,MAAM,MAAM,OAAO,EAAE,YAAY;AAAA,IACvC;AAAA,EACF;AACA,QAAM,eAAe,OAAO,SAAS,OAAO,mBAAmB;AAC/D,QAAM,OAAO;AAAA,IACX,SAAS,SAAS;AAAA,IAClB,QAAQ;AAAA,MACN,aAAa,QAAQ,iBAAiB;AAAA,MACtC,WAAW,QAAQ,gBAAgB,SAAS,CAAC;AAAA,MAC7C,UAAU,QAAQ,eAAe,SAAS,CAAC;AAAA,MAC3C,QAAQ,iBAAiB,KAAK,OAAO,QAAQ,aAAa,SAAS,CAAC;AAAA,IACtE;AAAA,IACA,MAAM;AAAA,MACJ,cAAc,QAAQ,SAAS,OAAO,mBAAmB,SAAS,CAAC;AAAA,MACnE,SAAS,aAAa,SAAS,OAAO,OAAO;AAAA,IAC/C;AAAA,IACA,WAAW,QAAQ,gBAAgB,CAAC,GAAG,IAAI,CAAC,OAAO;AAAA,MACjD,QAAQ,QAAQ,EAAE,YAAY;AAAA,MAC9B,YAAY,KAAK,IAAI,GAAG,KAAK,OAAO,IAAI,IAAI,EAAE,QAAQ,GAAI,CAAC;AAAA,MAC3D,GAAI,EAAE,eAAe,SAAY,EAAE,SAAS,EAAE,WAAW,IAAI,CAAC;AAAA,IAChE,EAAE;AAAA,EACJ;AACA,QAAM,aACJ,iBAAiB,KACb,0BACA,MAAM,QAAQ,aAAa,SAAS,CAAC,EAAE,GAAG;AAChD,SAAO;AAAA,IACL;AAAA,IACA,YAAY;AAAA,MACV,SAAS,QAAQ,gBAAgB,SAAS,CAAC,EAAE,GAAG,QAAQ,UAAU;AAAA,MAClE,YAAY,QAAQ,eAAe,SAAS,CAAC,EAAE,GAAG,WAAW,KAAK,SAAS,MAAM;AAAA,MACjF,oBAAoB,QAAQ,SAAS,OAAO,mBAAmB,SAAS,CAAC,EAAE,GAAG,iBAAiB,aAAa,SAAS,OAAO,OAAO,CAAC;AAAA,IACtI;AAAA,EACF;AACF;AAEA,SAAS,aAAa,SAAgC;AACpD,SAAO,QAAQ,SAAS,WACpB,WACA,SAAS,QAAQ,QAAQ,gBAAgB,SAAS,CAAC,EAAE,GAAG;AAC9D;","names":[]}
1
+ {"version":3,"sources":["../src/router/status.ts"],"sourcesContent":["import { toMoney } from '../lib/money';\nimport type { ConfirmPolicy } from '../lib/policy';\nimport { resolveContextSettings } from '../lib/settings';\nimport { readSpendSummary } from '../lib/wallet/spend';\nimport type { CommandContext, CommandResult } from '../context';\n\n/**\n * `tenjin status`: what this machine has spent and what it is still holding.\n *\n * IT READS `spend.json`, NOT THE BACKEND. The rolling window, the committed\n * total and the reservations still open are the local truth about money, and\n * the reservations are also the record of a request whose outcome is unknown:\n * an authorization that was transmitted is committed, so anything still open\n * here is either in flight or a crash that has not yet aged out.\n */\n\nexport interface StatusDeps {\n now?: () => number;\n}\n\nexport async function runRouterStatus(\n ctx: CommandContext,\n deps: StatusDeps = {},\n): Promise<CommandResult> {\n const now = deps.now ?? Date.now;\n const settings = await resolveContextSettings(ctx);\n // The same projection an authorization would make, so what this prints is\n // what the next lookup would actually be measured against.\n const ledger = await readSpendSummary(ctx.dataDir, { now });\n const committedAtomic = BigInt(ledger?.committedAtomic ?? '0');\n const reservedAtomic = (ledger?.reservations ?? []).reduce(\n (sum, r) => sum + BigInt(r.amountAtomic),\n 0n,\n );\n const budgetAtomic = BigInt(settings.policy.sessionBudgetAtomic);\n const data = {\n baseUrl: settings.baseUrl,\n window: {\n startedAtMs: ledger?.windowStartMs ?? null,\n committed: toMoney(committedAtomic.toString()),\n reserved: toMoney(reservedAtomic.toString()),\n budget: budgetAtomic === 0n ? null : toMoney(budgetAtomic.toString()),\n },\n caps: {\n maxAutoSpend: toMoney(settings.policy.maxAutoSpendAtomic.toString()),\n confirm: confirmLabel(settings.policy.confirm),\n },\n inFlight: (ledger?.reservations ?? []).map((r) => ({\n amount: toMoney(r.amountAtomic),\n ageSeconds: Math.max(0, Math.round((now() - r.atMs) / 1000)),\n ...(r.requestKey !== undefined ? { request: r.requestKey } : {}),\n })),\n };\n const budgetLine =\n budgetAtomic === 0n\n ? 'no session budget set'\n : `of ${toMoney(budgetAtomic.toString()).usd} USD in the rolling 24h window`;\n return {\n data,\n humanLines: [\n `spent ${toMoney(committedAtomic.toString()).usd} USD ${budgetLine}`,\n `reserved ${toMoney(reservedAtomic.toString()).usd} USD in ${data.inFlight.length} open request(s)`,\n `per call at most ${toMoney(settings.policy.maxAutoSpendAtomic.toString()).usd} USD, confirm ${confirmLabel(settings.policy.confirm)}`,\n ],\n };\n}\n\nfunction confirmLabel(confirm: ConfirmPolicy): string {\n return confirm.mode === 'always'\n ? 'always'\n : `above ${toMoney(confirm.thresholdAtomic.toString()).usd} USD`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAoBA,eAAsB,gBACpB,KACA,OAAmB,CAAC,GACI;AACxB,QAAM,MAAM,KAAK,OAAO,KAAK;AAC7B,QAAM,WAAW,MAAM,uBAAuB,GAAG;AAGjD,QAAM,SAAS,MAAM,iBAAiB,IAAI,SAAS,EAAE,IAAI,CAAC;AAC1D,QAAM,kBAAkB,OAAO,QAAQ,mBAAmB,GAAG;AAC7D,QAAM,kBAAkB,QAAQ,gBAAgB,CAAC,GAAG;AAAA,IAClD,CAAC,KAAK,MAAM,MAAM,OAAO,EAAE,YAAY;AAAA,IACvC;AAAA,EACF;AACA,QAAM,eAAe,OAAO,SAAS,OAAO,mBAAmB;AAC/D,QAAM,OAAO;AAAA,IACX,SAAS,SAAS;AAAA,IAClB,QAAQ;AAAA,MACN,aAAa,QAAQ,iBAAiB;AAAA,MACtC,WAAW,QAAQ,gBAAgB,SAAS,CAAC;AAAA,MAC7C,UAAU,QAAQ,eAAe,SAAS,CAAC;AAAA,MAC3C,QAAQ,iBAAiB,KAAK,OAAO,QAAQ,aAAa,SAAS,CAAC;AAAA,IACtE;AAAA,IACA,MAAM;AAAA,MACJ,cAAc,QAAQ,SAAS,OAAO,mBAAmB,SAAS,CAAC;AAAA,MACnE,SAAS,aAAa,SAAS,OAAO,OAAO;AAAA,IAC/C;AAAA,IACA,WAAW,QAAQ,gBAAgB,CAAC,GAAG,IAAI,CAAC,OAAO;AAAA,MACjD,QAAQ,QAAQ,EAAE,YAAY;AAAA,MAC9B,YAAY,KAAK,IAAI,GAAG,KAAK,OAAO,IAAI,IAAI,EAAE,QAAQ,GAAI,CAAC;AAAA,MAC3D,GAAI,EAAE,eAAe,SAAY,EAAE,SAAS,EAAE,WAAW,IAAI,CAAC;AAAA,IAChE,EAAE;AAAA,EACJ;AACA,QAAM,aACJ,iBAAiB,KACb,0BACA,MAAM,QAAQ,aAAa,SAAS,CAAC,EAAE,GAAG;AAChD,SAAO;AAAA,IACL;AAAA,IACA,YAAY;AAAA,MACV,SAAS,QAAQ,gBAAgB,SAAS,CAAC,EAAE,GAAG,QAAQ,UAAU;AAAA,MAClE,YAAY,QAAQ,eAAe,SAAS,CAAC,EAAE,GAAG,WAAW,KAAK,SAAS,MAAM;AAAA,MACjF,oBAAoB,QAAQ,SAAS,OAAO,mBAAmB,SAAS,CAAC,EAAE,GAAG,iBAAiB,aAAa,SAAS,OAAO,OAAO,CAAC;AAAA,IACtI;AAAA,EACF;AACF;AAEA,SAAS,aAAa,SAAgC;AACpD,SAAO,QAAQ,SAAS,WACpB,WACA,SAAS,QAAQ,QAAQ,gBAAgB,SAAS,CAAC,EAAE,GAAG;AAC9D;","names":[]}
@@ -1,8 +1,15 @@
1
1
  import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
2
  import {
3
3
  renderProgress
4
- } from "./chunk-PZEN5PHN.js";
5
- import "./chunk-7WEQQJLG.js";
4
+ } from "./chunk-J5INH7WB.js";
5
+ import {
6
+ routerSettings
7
+ } from "./chunk-TP4D47BY.js";
8
+ import "./chunk-PDA2BVFY.js";
9
+ import "./chunk-U2DZISAH.js";
10
+ import "./chunk-AR7U7BRG.js";
11
+ import "./chunk-JLEF5WHM.js";
12
+ import "./chunk-2BKS2FVE.js";
6
13
  import "./chunk-ZXTAQYNA.js";
7
14
 
8
15
  // src/router/status-line.ts
@@ -22,6 +29,11 @@ async function runStatusLine(io, deps) {
22
29
  const event = JSON.parse(raw);
23
30
  const sessionId = sessionIdOf(event);
24
31
  if (sessionId === null) return;
32
+ const router = await routerSettings(
33
+ { cwd: cwdOf(event) ?? process.cwd(), dataDir: deps.dataDir },
34
+ { warn: () => void 0 }
35
+ );
36
+ if (!router.enabled.value) return;
25
37
  const columns = Number((deps.env ?? process.env).COLUMNS);
26
38
  rendered = await renderProgress(deps.dataDir, sessionId, {
27
39
  ...Number.isFinite(columns) && columns > 0 ? { columns } : {},
@@ -39,6 +51,10 @@ function sessionIdOf(event) {
39
51
  if (typeof value !== "string" || value.length === 0 || value.length > 200) return null;
40
52
  return value;
41
53
  }
54
+ function cwdOf(event) {
55
+ const value = event.cwd;
56
+ return typeof value === "string" && value.length > 0 ? value : null;
57
+ }
42
58
  async function readStdin() {
43
59
  return new Promise((resolve, reject) => {
44
60
  const chunks = [];
@@ -68,4 +84,4 @@ export {
68
84
  runStatusLine,
69
85
  statusLineMain
70
86
  };
71
- //# sourceMappingURL=status-line-CGPUSDMC.js.map
87
+ //# sourceMappingURL=status-line-SAXSU6CR.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/router/status-line.ts"],"sourcesContent":["import { renderProgress } from './progress';\nimport { routerSettings } from './settings';\nimport type { Io } from '../lib/output';\n\n/**\n * `tenjin status-line`: the live footer Claude Code runs on its own refresh.\n *\n * CHEAP AND READ-ONLY. One JSON event on stdin for the session identity, the\n * router's own switch for its directory, one read of that session's progress\n * directory, one line out. No network call, no wallet, no write: it runs once a\n * second for as long as a session is open, so anything it touched would be\n * touched 3,600 times an hour.\n *\n * IT CANNOT FAIL LOUDLY either. Every error path writes nothing and returns, so\n * the command exits 0 with empty output and the harness shows no footer.\n */\n\n/** Claude Code's status event is small; anything larger is not one. */\nconst MAX_EVENT_BYTES = 64_000;\n/** The harness writes the event immediately, so this is a liveness check. */\nexport const STDIN_TIMEOUT_MS = 1_000;\n\nexport interface StatusLineDeps {\n dataDir: string;\n /** Test seam for the harness event; production reads stdin. */\n readEvent?: () => Promise<string>;\n env?: NodeJS.ProcessEnv;\n now?: () => number;\n}\n\n/**\n * The bin entry's fast path for a bare `tenjin status-line`, which runs on a\n * one-second timer: commander and the command tree cost about 120 ms of parse\n * per tick over this path. It does load zod, for the router's own switch\n * through the one config parser, about 17 ms a tick. `dist-chunks.test.ts`\n * pins what it may load.\n */\nexport async function statusLineMain(): Promise<void> {\n const { dataDir } = await import('../lib/paths');\n await runStatusLine(\n { stdout: process.stdout, stderr: process.stderr, isTTY: false },\n { dataDir: dataDir(process.env) },\n );\n}\n\nexport async function runStatusLine(io: Io, deps: StatusLineDeps): Promise<void> {\n let rendered: string;\n try {\n const raw = await (deps.readEvent ?? readStdin)();\n const event: unknown = JSON.parse(raw);\n const sessionId = sessionIdOf(event);\n if (sessionId === null) return;\n // Off here means no footer: the router is not running in this directory.\n const router = await routerSettings(\n { cwd: cwdOf(event) ?? process.cwd(), dataDir: deps.dataDir },\n { warn: () => undefined },\n );\n if (!router.enabled.value) return;\n const columns = Number((deps.env ?? process.env).COLUMNS);\n rendered = await renderProgress(deps.dataDir, sessionId, {\n ...(Number.isFinite(columns) && columns > 0 ? { columns } : {}),\n ...(deps.now !== undefined ? { now: deps.now() } : {}),\n });\n } catch {\n return;\n }\n if (rendered.length > 0) io.stdout.write(`${rendered}\\n`);\n}\n\n/**\n * The session identity, and nothing else off the event. A footer that showed\n * the wrong session's lookups would be a leak between two terminals, so an\n * event without a plain, bounded `session_id` renders nothing at all.\n */\nfunction sessionIdOf(event: unknown): string | null {\n if (event === null || typeof event !== 'object' || Array.isArray(event)) return null;\n const value = (event as { session_id?: unknown }).session_id;\n if (typeof value !== 'string' || value.length === 0 || value.length > 200) return null;\n return value;\n}\n\n/** The session's working directory, which `router.*` resolves from. */\nfunction cwdOf(event: unknown): string | null {\n const value = (event as { cwd?: unknown }).cwd;\n return typeof value === 'string' && value.length > 0 ? value : null;\n}\n\nasync function readStdin(): Promise<string> {\n return new Promise((resolve, reject) => {\n const chunks: Buffer[] = [];\n let size = 0;\n const timer = setTimeout(() => reject(new Error('no harness event')), STDIN_TIMEOUT_MS);\n process.stdin.on('data', (chunk: Buffer) => {\n size += chunk.length;\n if (size > MAX_EVENT_BYTES) {\n clearTimeout(timer);\n reject(new Error('harness event too large'));\n return;\n }\n chunks.push(chunk);\n });\n process.stdin.once('end', () => {\n clearTimeout(timer);\n resolve(Buffer.concat(chunks).toString('utf8'));\n });\n process.stdin.once('error', () => {\n clearTimeout(timer);\n reject(new Error('harness event unreadable'));\n });\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;AAkBA,IAAM,kBAAkB;AAEjB,IAAM,mBAAmB;AAiBhC,eAAsB,iBAAgC;AACpD,QAAM,EAAE,QAAQ,IAAI,MAAM,OAAO,qBAAc;AAC/C,QAAM;AAAA,IACJ,EAAE,QAAQ,QAAQ,QAAQ,QAAQ,QAAQ,QAAQ,OAAO,MAAM;AAAA,IAC/D,EAAE,SAAS,QAAQ,QAAQ,GAAG,EAAE;AAAA,EAClC;AACF;AAEA,eAAsB,cAAc,IAAQ,MAAqC;AAC/E,MAAI;AACJ,MAAI;AACF,UAAM,MAAM,OAAO,KAAK,aAAa,WAAW;AAChD,UAAM,QAAiB,KAAK,MAAM,GAAG;AACrC,UAAM,YAAY,YAAY,KAAK;AACnC,QAAI,cAAc,KAAM;AAExB,UAAM,SAAS,MAAM;AAAA,MACnB,EAAE,KAAK,MAAM,KAAK,KAAK,QAAQ,IAAI,GAAG,SAAS,KAAK,QAAQ;AAAA,MAC5D,EAAE,MAAM,MAAM,OAAU;AAAA,IAC1B;AACA,QAAI,CAAC,OAAO,QAAQ,MAAO;AAC3B,UAAM,UAAU,QAAQ,KAAK,OAAO,QAAQ,KAAK,OAAO;AACxD,eAAW,MAAM,eAAe,KAAK,SAAS,WAAW;AAAA,MACvD,GAAI,OAAO,SAAS,OAAO,KAAK,UAAU,IAAI,EAAE,QAAQ,IAAI,CAAC;AAAA,MAC7D,GAAI,KAAK,QAAQ,SAAY,EAAE,KAAK,KAAK,IAAI,EAAE,IAAI,CAAC;AAAA,IACtD,CAAC;AAAA,EACH,QAAQ;AACN;AAAA,EACF;AACA,MAAI,SAAS,SAAS,EAAG,IAAG,OAAO,MAAM,GAAG,QAAQ;AAAA,CAAI;AAC1D;AAOA,SAAS,YAAY,OAA+B;AAClD,MAAI,UAAU,QAAQ,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK,EAAG,QAAO;AAChF,QAAM,QAAS,MAAmC;AAClD,MAAI,OAAO,UAAU,YAAY,MAAM,WAAW,KAAK,MAAM,SAAS,IAAK,QAAO;AAClF,SAAO;AACT;AAGA,SAAS,MAAM,OAA+B;AAC5C,QAAM,QAAS,MAA4B;AAC3C,SAAO,OAAO,UAAU,YAAY,MAAM,SAAS,IAAI,QAAQ;AACjE;AAEA,eAAe,YAA6B;AAC1C,SAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,UAAM,SAAmB,CAAC;AAC1B,QAAI,OAAO;AACX,UAAM,QAAQ,WAAW,MAAM,OAAO,IAAI,MAAM,kBAAkB,CAAC,GAAG,gBAAgB;AACtF,YAAQ,MAAM,GAAG,QAAQ,CAAC,UAAkB;AAC1C,cAAQ,MAAM;AACd,UAAI,OAAO,iBAAiB;AAC1B,qBAAa,KAAK;AAClB,eAAO,IAAI,MAAM,yBAAyB,CAAC;AAC3C;AAAA,MACF;AACA,aAAO,KAAK,KAAK;AAAA,IACnB,CAAC;AACD,YAAQ,MAAM,KAAK,OAAO,MAAM;AAC9B,mBAAa,KAAK;AAClB,cAAQ,OAAO,OAAO,MAAM,EAAE,SAAS,MAAM,CAAC;AAAA,IAChD,CAAC;AACD,YAAQ,MAAM,KAAK,SAAS,MAAM;AAChC,mBAAa,KAAK;AAClB,aAAO,IAAI,MAAM,0BAA0B,CAAC;AAAA,IAC9C,CAAC;AAAA,EACH,CAAC;AACH;","names":[]}
@@ -9,12 +9,11 @@ import {
9
9
  inspectStatusLine,
10
10
  removeStatusLine,
11
11
  statusLineMode
12
- } from "./chunk-HVRC33OL.js";
13
- import "./chunk-SKAHDQH7.js";
14
- import "./chunk-BFFM2WFK.js";
15
- import "./chunk-OCBHUHWB.js";
12
+ } from "./chunk-EPCOMXLF.js";
13
+ import "./chunk-TJMCBIZU.js";
14
+ import "./chunk-NRQMOVKM.js";
15
+ import "./chunk-JLEF5WHM.js";
16
16
  import "./chunk-2BKS2FVE.js";
17
- import "./chunk-7WEQQJLG.js";
18
17
  import "./chunk-ZXTAQYNA.js";
19
18
  export {
20
19
  STATUS_LINE_COMMAND,
@@ -27,4 +26,4 @@ export {
27
26
  removeStatusLine,
28
27
  statusLineMode
29
28
  };
30
- //# sourceMappingURL=status-line-wiring-BYPHTYZE.js.map
29
+ //# sourceMappingURL=status-line-wiring-DQZCWIUO.js.map