tenjin-cli 0.1.0-alpha.2 → 0.1.0-alpha.4

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 (135) hide show
  1. package/README.md +156 -185
  2. package/dist/{_esm-FEASBWRP.js → _esm-N4KAVXQR.js} +9 -9
  3. package/dist/buy-OOOLUDND.js +41 -0
  4. package/dist/candidate-TWCWTFGA.js +22 -0
  5. package/dist/{ccip-XR5NE5QK.js → ccip-RPPPKTJR.js} +5 -5
  6. package/dist/{ccip-NQXCEK2U.js → ccip-ZGGWQN4X.js} +4 -4
  7. package/dist/{chunk-XJIW7USF.js → chunk-333FOTUJ.js} +5 -5
  8. package/dist/{chunk-YALGASEU.js → chunk-47PP7TAG.js} +1610 -1610
  9. package/dist/chunk-47PP7TAG.js.map +1 -0
  10. package/dist/{buy-U35DQ6XM.js → chunk-4GR7DGD6.js} +23 -41
  11. package/dist/{buy-U35DQ6XM.js.map → chunk-4GR7DGD6.js.map} +1 -1
  12. package/dist/{chunk-27ONARHV.js → chunk-5JH7ZB6Z.js} +7 -7
  13. package/dist/{chunk-27ONARHV.js.map → chunk-5JH7ZB6Z.js.map} +1 -1
  14. package/dist/{chunk-OYMYCW7J.js → chunk-6WWVYYSB.js} +32 -2
  15. package/dist/{chunk-OYMYCW7J.js.map → chunk-6WWVYYSB.js.map} +1 -1
  16. package/dist/{chunk-UGX7YPX2.js → chunk-7FK2UN2T.js} +65 -65
  17. package/dist/{chunk-UGX7YPX2.js.map → chunk-7FK2UN2T.js.map} +1 -1
  18. package/dist/{chunk-IYLHQMT5.js → chunk-BXUS5UCT.js} +5 -4
  19. package/dist/chunk-BXUS5UCT.js.map +1 -0
  20. package/dist/{chunk-QNP7H47L.js → chunk-C4TIWOAM.js} +2 -2
  21. package/dist/{chunk-QNP7H47L.js.map → chunk-C4TIWOAM.js.map} +1 -1
  22. package/dist/{chunk-7PHSZKQS.js → chunk-CJU555P5.js} +24 -24
  23. package/dist/{chunk-7PHSZKQS.js.map → chunk-CJU555P5.js.map} +1 -1
  24. package/dist/{chunk-YN5SHIXQ.js → chunk-DPET3TW5.js} +2 -2
  25. package/dist/{chunk-TLCMMYLY.js → chunk-DPUMEMGM.js} +5 -5
  26. package/dist/chunk-DPUMEMGM.js.map +1 -0
  27. package/dist/{chunk-TFGSOPWR.js → chunk-EUQN3L5X.js} +9 -9
  28. package/dist/{chunk-TFGSOPWR.js.map → chunk-EUQN3L5X.js.map} +1 -1
  29. package/dist/{chunk-UPIEAMGH.js → chunk-FHB3VKZW.js} +6 -6
  30. package/dist/{chunk-UPIEAMGH.js.map → chunk-FHB3VKZW.js.map} +1 -1
  31. package/dist/{chunk-S3IGX57D.js → chunk-FU6MCSLG.js} +9 -9
  32. package/dist/{lookup-WYVTOMVY.js → chunk-H5ETJRQD.js} +54 -29
  33. package/dist/chunk-H5ETJRQD.js.map +1 -0
  34. package/dist/chunk-KXIX7YDV.js +59 -0
  35. package/dist/chunk-KXIX7YDV.js.map +1 -0
  36. package/dist/{chunk-5CLSD5YN.js → chunk-KYQVEKP5.js} +7 -7
  37. package/dist/{chunk-RRN3YTK7.js → chunk-KZAAWQNP.js} +3 -3
  38. package/dist/{chunk-NCE5NSN6.js → chunk-M2O56UK7.js} +158 -158
  39. package/dist/chunk-M2O56UK7.js.map +1 -0
  40. package/dist/{chunk-7KUW4MJD.js → chunk-MM4TGTST.js} +6 -6
  41. package/dist/{chunk-7KUW4MJD.js.map → chunk-MM4TGTST.js.map} +1 -1
  42. package/dist/{chunk-YIYQ2ZNT.js → chunk-NXCJN2FJ.js} +55 -28
  43. package/dist/chunk-NXCJN2FJ.js.map +1 -0
  44. package/dist/{candidate-RLYCQMF5.js → chunk-OJD54DIU.js} +15 -19
  45. package/dist/{candidate-RLYCQMF5.js.map → chunk-OJD54DIU.js.map} +1 -1
  46. package/dist/{chunk-ZABPQJ3M.js → chunk-POJRB2AE.js} +2 -2
  47. package/dist/{chunk-N62ROTMC.js → chunk-QH6677FJ.js} +5 -4
  48. package/dist/chunk-QH6677FJ.js.map +1 -0
  49. package/dist/{wallet-6QKS6UHW.js → chunk-R7BMDJZM.js} +15 -27
  50. package/dist/{wallet-6QKS6UHW.js.map → chunk-R7BMDJZM.js.map} +1 -1
  51. package/dist/{chunk-Z6MFJV5Z.js → chunk-S3KZ3PPK.js} +15 -11
  52. package/dist/{chunk-Z6MFJV5Z.js.map → chunk-S3KZ3PPK.js.map} +1 -1
  53. package/dist/{chunk-CYOF7ROH.js → chunk-S5RYMCV6.js} +3 -3
  54. package/dist/{chunk-ZMHYXMO6.js → chunk-U5S527PP.js} +3 -3
  55. package/dist/{chunk-RY4XKNV3.js → chunk-UHTVXQ2O.js} +3 -3
  56. package/dist/{publish-D76B3MBK.js → chunk-ULLWHHIT.js} +25 -42
  57. package/dist/chunk-ULLWHHIT.js.map +1 -0
  58. package/dist/{chunk-Z52RA3NC.js → chunk-VV4P5RVK.js} +47 -20
  59. package/dist/chunk-VV4P5RVK.js.map +1 -0
  60. package/dist/{chunk-QVX5MWJZ.js → chunk-W6R3HAAG.js} +2 -2
  61. package/dist/{chunk-3OV7E5G5.js → chunk-WWX32ML4.js} +1 -1
  62. package/dist/{chunk-3OV7E5G5.js.map → chunk-WWX32ML4.js.map} +1 -1
  63. package/dist/{chunk-HIVZG55D.js → chunk-XJN5WUKL.js} +2 -2
  64. package/dist/{chunk-JPHG2JW3.js → chunk-XNNOR7F7.js} +25 -25
  65. package/dist/chunk-XNNOR7F7.js.map +1 -0
  66. package/dist/{inspect-JGYJWFDP.js → chunk-YFREUEUI.js} +8 -26
  67. package/dist/{inspect-JGYJWFDP.js.map → chunk-YFREUEUI.js.map} +1 -1
  68. package/dist/{chunk-HSDCI7OV.js → chunk-YLYINX2H.js} +3 -3
  69. package/dist/{cli-4NNBEQYH.js → cli-AFSLAKR6.js} +47 -36
  70. package/dist/{cli-4NNBEQYH.js.map → cli-AFSLAKR6.js.map} +1 -1
  71. package/dist/{config-2VSXWWHK.js → config-DBEEM3UA.js} +5 -5
  72. package/dist/{doctor-JJPNIBYH.js → doctor-XDA3YU6H.js} +7 -7
  73. package/dist/{ethersCompat-Df4a6QIZ-3YZIAXDK.js → ethersCompat-Df4a6QIZ-WHYKB6HA.js} +5 -5
  74. package/dist/index.js +1 -1
  75. package/dist/inspect-YBGDAG47.js +33 -0
  76. package/dist/install-7J6KKEEP.js +542 -0
  77. package/dist/install-7J6KKEEP.js.map +1 -0
  78. package/dist/outcome-ZFGHX2XW.js +20 -0
  79. package/dist/publish-IH7RJXGB.js +36 -0
  80. package/dist/publish-IH7RJXGB.js.map +1 -0
  81. package/dist/run-DCZFEW2C.js +16806 -0
  82. package/dist/run-DCZFEW2C.js.map +1 -0
  83. package/dist/search-R6NIQFXI.js +24 -0
  84. package/dist/search-R6NIQFXI.js.map +1 -0
  85. package/dist/{secp256k1-N3ZHU7LB.js → secp256k1-XRPVBC6V.js} +3 -3
  86. package/dist/secp256k1-XRPVBC6V.js.map +1 -0
  87. package/dist/usdc-AU6ZIKA6.js +22 -0
  88. package/dist/usdc-AU6ZIKA6.js.map +1 -0
  89. package/dist/{viemAdapter-By13KInL-ZZE6UV4Y.js → viemAdapter-By13KInL-TUQJBMHM.js} +5 -5
  90. package/dist/viemAdapter-By13KInL-TUQJBMHM.js.map +1 -0
  91. package/dist/{wallet-PA54CRBL.js → wallet-HKG3GSTX.js} +10 -10
  92. package/dist/wallet-HKG3GSTX.js.map +1 -0
  93. package/dist/wallet-UWHSHWC6.js +31 -0
  94. package/dist/wallet-UWHSHWC6.js.map +1 -0
  95. package/package.json +4 -3
  96. package/skills/tenjin/SKILL.md +56 -13
  97. package/skills/tenjin-publish/SKILL.md +57 -27
  98. package/skills/tenjin-search/SKILL.md +57 -31
  99. package/dist/chunk-IYLHQMT5.js.map +0 -1
  100. package/dist/chunk-JPHG2JW3.js.map +0 -1
  101. package/dist/chunk-N62ROTMC.js.map +0 -1
  102. package/dist/chunk-NCE5NSN6.js.map +0 -1
  103. package/dist/chunk-TLCMMYLY.js.map +0 -1
  104. package/dist/chunk-YALGASEU.js.map +0 -1
  105. package/dist/chunk-YIYQ2ZNT.js.map +0 -1
  106. package/dist/chunk-Z52RA3NC.js.map +0 -1
  107. package/dist/install-ZQRMSRGW.js +0 -378
  108. package/dist/install-ZQRMSRGW.js.map +0 -1
  109. package/dist/lookup-WYVTOMVY.js.map +0 -1
  110. package/dist/outcome-HKKT6QIA.js +0 -66
  111. package/dist/outcome-HKKT6QIA.js.map +0 -1
  112. package/dist/publish-D76B3MBK.js.map +0 -1
  113. package/dist/usdc-JIAJW4SV.js +0 -22
  114. /package/dist/{_esm-FEASBWRP.js.map → _esm-N4KAVXQR.js.map} +0 -0
  115. /package/dist/{ccip-NQXCEK2U.js.map → buy-OOOLUDND.js.map} +0 -0
  116. /package/dist/{ccip-XR5NE5QK.js.map → candidate-TWCWTFGA.js.map} +0 -0
  117. /package/dist/{config-2VSXWWHK.js.map → ccip-RPPPKTJR.js.map} +0 -0
  118. /package/dist/{doctor-JJPNIBYH.js.map → ccip-ZGGWQN4X.js.map} +0 -0
  119. /package/dist/{chunk-XJIW7USF.js.map → chunk-333FOTUJ.js.map} +0 -0
  120. /package/dist/{chunk-YN5SHIXQ.js.map → chunk-DPET3TW5.js.map} +0 -0
  121. /package/dist/{chunk-S3IGX57D.js.map → chunk-FU6MCSLG.js.map} +0 -0
  122. /package/dist/{chunk-5CLSD5YN.js.map → chunk-KYQVEKP5.js.map} +0 -0
  123. /package/dist/{chunk-RRN3YTK7.js.map → chunk-KZAAWQNP.js.map} +0 -0
  124. /package/dist/{chunk-ZABPQJ3M.js.map → chunk-POJRB2AE.js.map} +0 -0
  125. /package/dist/{chunk-CYOF7ROH.js.map → chunk-S5RYMCV6.js.map} +0 -0
  126. /package/dist/{chunk-ZMHYXMO6.js.map → chunk-U5S527PP.js.map} +0 -0
  127. /package/dist/{chunk-RY4XKNV3.js.map → chunk-UHTVXQ2O.js.map} +0 -0
  128. /package/dist/{chunk-QVX5MWJZ.js.map → chunk-W6R3HAAG.js.map} +0 -0
  129. /package/dist/{chunk-HIVZG55D.js.map → chunk-XJN5WUKL.js.map} +0 -0
  130. /package/dist/{chunk-HSDCI7OV.js.map → chunk-YLYINX2H.js.map} +0 -0
  131. /package/dist/{ethersCompat-Df4a6QIZ-3YZIAXDK.js.map → config-DBEEM3UA.js.map} +0 -0
  132. /package/dist/{secp256k1-N3ZHU7LB.js.map → doctor-XDA3YU6H.js.map} +0 -0
  133. /package/dist/{usdc-JIAJW4SV.js.map → ethersCompat-Df4a6QIZ-WHYKB6HA.js.map} +0 -0
  134. /package/dist/{viemAdapter-By13KInL-ZZE6UV4Y.js.map → inspect-YBGDAG47.js.map} +0 -0
  135. /package/dist/{wallet-PA54CRBL.js.map → outcome-ZFGHX2XW.js.map} +0 -0
@@ -4,13 +4,13 @@ import {
4
4
  runConfigGet,
5
5
  runConfigList,
6
6
  runConfigSet
7
- } from "./chunk-TFGSOPWR.js";
8
- import "./chunk-UPIEAMGH.js";
9
- import "./chunk-IYLHQMT5.js";
7
+ } from "./chunk-EUQN3L5X.js";
8
+ import "./chunk-FHB3VKZW.js";
10
9
  import "./chunk-YBMMV4Y4.js";
11
10
  import "./chunk-UO22YNY4.js";
11
+ import "./chunk-BXUS5UCT.js";
12
12
  import "./chunk-MUBUQVC3.js";
13
- import "./chunk-OYMYCW7J.js";
13
+ import "./chunk-6WWVYYSB.js";
14
14
  import "./chunk-ZXTAQYNA.js";
15
15
  export {
16
16
  persistPublishMode,
@@ -18,4 +18,4 @@ export {
18
18
  runConfigList,
19
19
  runConfigSet
20
20
  };
21
- //# sourceMappingURL=config-2VSXWWHK.js.map
21
+ //# sourceMappingURL=config-DBEEM3UA.js.map
@@ -3,18 +3,18 @@ import {
3
3
  collectDoctorChecks,
4
4
  renderDoctorHuman,
5
5
  runDoctor
6
- } from "./chunk-7PHSZKQS.js";
7
- import "./chunk-QNP7H47L.js";
8
- import "./chunk-N62ROTMC.js";
9
- import "./chunk-IYLHQMT5.js";
10
- import "./chunk-YN5SHIXQ.js";
6
+ } from "./chunk-CJU555P5.js";
7
+ import "./chunk-DPET3TW5.js";
8
+ import "./chunk-C4TIWOAM.js";
9
+ import "./chunk-QH6677FJ.js";
11
10
  import "./chunk-2I4QTOLB.js";
11
+ import "./chunk-BXUS5UCT.js";
12
12
  import "./chunk-MUBUQVC3.js";
13
- import "./chunk-OYMYCW7J.js";
13
+ import "./chunk-6WWVYYSB.js";
14
14
  import "./chunk-ZXTAQYNA.js";
15
15
  export {
16
16
  collectDoctorChecks,
17
17
  renderDoctorHuman,
18
18
  runDoctor
19
19
  };
20
- //# sourceMappingURL=doctor-JJPNIBYH.js.map
20
+ //# sourceMappingURL=doctor-XDA3YU6H.js.map
@@ -4,10 +4,10 @@ import {
4
4
  c,
5
5
  f,
6
6
  s
7
- } from "./chunk-ZABPQJ3M.js";
8
- import "./chunk-HSDCI7OV.js";
9
- import "./chunk-HIVZG55D.js";
10
- import "./chunk-5CLSD5YN.js";
7
+ } from "./chunk-POJRB2AE.js";
8
+ import "./chunk-YLYINX2H.js";
9
+ import "./chunk-XJN5WUKL.js";
10
+ import "./chunk-KYQVEKP5.js";
11
11
  import "./chunk-ZXTAQYNA.js";
12
12
  export {
13
13
  s as i,
@@ -15,4 +15,4 @@ export {
15
15
  a as r,
16
16
  f as t
17
17
  };
18
- //# sourceMappingURL=ethersCompat-Df4a6QIZ-3YZIAXDK.js.map
18
+ //# sourceMappingURL=ethersCompat-Df4a6QIZ-WHYKB6HA.js.map
package/dist/index.js CHANGED
@@ -21,6 +21,6 @@ if (Number.isNaN(nodeMajor) || nodeMajor < MIN_NODE_MAJOR) {
21
21
  `);
22
22
  process.exit(1);
23
23
  }
24
- var { main } = await import("./cli-4NNBEQYH.js");
24
+ var { main } = await import("./cli-AFSLAKR6.js");
25
25
  process.exit(await main(process.argv.slice(2)));
26
26
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,33 @@
1
+ import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
+ import {
3
+ runInspect
4
+ } from "./chunk-YFREUEUI.js";
5
+ import "./chunk-5JH7ZB6Z.js";
6
+ import "./chunk-FU6MCSLG.js";
7
+ import "./chunk-MM4TGTST.js";
8
+ import "./chunk-XNNOR7F7.js";
9
+ import "./chunk-NXCJN2FJ.js";
10
+ import "./chunk-WWX32ML4.js";
11
+ import "./chunk-VV4P5RVK.js";
12
+ import "./chunk-C4TIWOAM.js";
13
+ import "./chunk-QH6677FJ.js";
14
+ import "./chunk-KZAAWQNP.js";
15
+ import "./chunk-S5RYMCV6.js";
16
+ import "./chunk-POJRB2AE.js";
17
+ import "./chunk-YLYINX2H.js";
18
+ import "./chunk-FHB3VKZW.js";
19
+ import "./chunk-YBMMV4Y4.js";
20
+ import "./chunk-UO22YNY4.js";
21
+ import "./chunk-BXUS5UCT.js";
22
+ import "./chunk-MUBUQVC3.js";
23
+ import "./chunk-6WWVYYSB.js";
24
+ import "./chunk-UHTVXQ2O.js";
25
+ import "./chunk-W6R3HAAG.js";
26
+ import "./chunk-XJN5WUKL.js";
27
+ import "./chunk-RBJPAZFI.js";
28
+ import "./chunk-KYQVEKP5.js";
29
+ import "./chunk-ZXTAQYNA.js";
30
+ export {
31
+ runInspect
32
+ };
33
+ //# sourceMappingURL=inspect-YBGDAG47.js.map
@@ -0,0 +1,542 @@
1
+ import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
+ import {
3
+ runWalletCreate
4
+ } from "./chunk-R7BMDJZM.js";
5
+ import {
6
+ describeWallet,
7
+ resolveWalletProvider
8
+ } from "./chunk-S3KZ3PPK.js";
9
+ import {
10
+ collectDoctorChecks
11
+ } from "./chunk-CJU555P5.js";
12
+ import {
13
+ walletFileExists
14
+ } from "./chunk-DPET3TW5.js";
15
+ import "./chunk-C4TIWOAM.js";
16
+ import "./chunk-QH6677FJ.js";
17
+ import "./chunk-2I4QTOLB.js";
18
+ import {
19
+ persistPublishMode
20
+ } from "./chunk-EUQN3L5X.js";
21
+ import "./chunk-FHB3VKZW.js";
22
+ import "./chunk-YBMMV4Y4.js";
23
+ import "./chunk-UO22YNY4.js";
24
+ import {
25
+ CONFIG_DEFAULTS,
26
+ PublishModeSchema,
27
+ loadRawConfig,
28
+ parsePublishModeFlag
29
+ } from "./chunk-BXUS5UCT.js";
30
+ import {
31
+ writeFileAtomic
32
+ } from "./chunk-MUBUQVC3.js";
33
+ import {
34
+ CliError,
35
+ external_exports
36
+ } from "./chunk-6WWVYYSB.js";
37
+ import "./chunk-333FOTUJ.js";
38
+ import "./chunk-7FK2UN2T.js";
39
+ import "./chunk-M2O56UK7.js";
40
+ import "./chunk-UHTVXQ2O.js";
41
+ import "./chunk-W6R3HAAG.js";
42
+ import "./chunk-U5S527PP.js";
43
+ import "./chunk-47PP7TAG.js";
44
+ import "./chunk-XJN5WUKL.js";
45
+ import "./chunk-RBJPAZFI.js";
46
+ import "./chunk-KYQVEKP5.js";
47
+ import "./chunk-ZXTAQYNA.js";
48
+
49
+ // src/commands/install.ts
50
+ import { existsSync as existsSync2, statSync } from "fs";
51
+ import { readFile, readdir, rm } from "fs/promises";
52
+ import { createInterface } from "readline";
53
+ import { fileURLToPath } from "url";
54
+ import { delimiter, join as join2, relative } from "path";
55
+ import { homedir } from "os";
56
+ import { styleText } from "util";
57
+ import { Stream } from "stream";
58
+
59
+ // src/lib/skills-source.ts
60
+ import { existsSync } from "fs";
61
+ import { dirname, join } from "path";
62
+ var SKILL_NAMES = ["tenjin-search", "tenjin-publish", "tenjin"];
63
+ var SENTINEL = join("tenjin", "SKILL.md");
64
+ function resolveSkillsSource(startDir) {
65
+ let dir = startDir;
66
+ for (let i = 0; i < 8; i += 1) {
67
+ const candidate = join(dir, "skills");
68
+ if (existsSync(join(candidate, SENTINEL))) return candidate;
69
+ const parent = dirname(dir);
70
+ if (parent === dir) break;
71
+ dir = parent;
72
+ }
73
+ throw new CliError("INTERNAL", "Could not locate the packaged Tenjin skills directory", {
74
+ fix: "Reinstall tenjin-cli; the published package must ship the skills/ directory (files array).",
75
+ details: { startDir }
76
+ });
77
+ }
78
+
79
+ // src/commands/install.ts
80
+ var HARNESSES = ["claude", "codex", "shared"];
81
+ var InstallInputSchema = external_exports.object({
82
+ harness: external_exports.array(external_exports.string()).optional(),
83
+ dryRun: external_exports.boolean().optional(),
84
+ publishMode: external_exports.string().optional(),
85
+ noWallet: external_exports.boolean().optional(),
86
+ /** Tri-state opt-in for the ~/.claude/CLAUDE.md nudge: true (--claude-md), false
87
+ * (--no-claude-md), or undefined (ask interactively, else skip). */
88
+ claudeMd: external_exports.boolean().optional()
89
+ });
90
+ var SKILLS_MARKER = "<!-- tenjin-cli:skills -->";
91
+ function nudgeLine(skillsDir) {
92
+ return `${SKILLS_MARKER} Tenjin: before regenerating public research (version-specific compatibility, integration gotchas, benchmarks, dated probes), run 'tenjin search "<question>" --json' first; it is free and anonymous but sends the generalized question text to tenjin.blog, so strip private identifiers. Skills (tenjin-search, tenjin-publish, tenjin) are installed at ${skillsDir}; read the relevant SKILL.md before using the CLI.`;
93
+ }
94
+ function upsertMarkerLine(existing, line) {
95
+ const text = existing ?? "";
96
+ if (!text.includes(SKILLS_MARKER)) {
97
+ const prefix = text.length === 0 || text.endsWith("\n") ? "" : "\n";
98
+ return { content: `${text}${prefix}${line}
99
+ `, change: "append" };
100
+ }
101
+ const lines = text.split("\n");
102
+ const idx = lines.findIndex((l) => l.includes(SKILLS_MARKER));
103
+ if (lines[idx] === line) return { content: null, change: "none" };
104
+ lines[idx] = line;
105
+ return { content: lines.join("\n"), change: "replace" };
106
+ }
107
+ var CODEX_NETWORK_RULE = "[sandbox_workspace_write]\nnetwork_access = true";
108
+ async function runInstall(input, ctx, deps = {}) {
109
+ const parsed = InstallInputSchema.safeParse(input);
110
+ if (!parsed.success) {
111
+ throw new CliError("USAGE", "Invalid install options", {
112
+ fix: "Run `tenjin install --help`.",
113
+ details: parsed.error.issues
114
+ });
115
+ }
116
+ const dryRun = parsed.data.dryRun === true;
117
+ const noWallet = parsed.data.noWallet === true;
118
+ const claudeMdFlag = parsed.data.claudeMd;
119
+ const publishModeFlag = parsed.data.publishMode !== void 0 ? parseModeFlag(parsed.data.publishMode) : void 0;
120
+ const env = deps.env ?? process.env;
121
+ const home = deps.homeDir ?? homedir();
122
+ const which = deps.which ?? ((bin) => onPath(bin, env));
123
+ const humanOutput = ctx.flags.json === true ? false : deps.isInteractive ?? ctx.io.isTTY;
124
+ const canPrompt = humanOutput && (deps.isInteractive ?? Boolean(process.stdin.isTTY));
125
+ const skillsSource = deps.skillsSourceDir ?? resolveSkillsSource(fileURLToPath(new URL(".", import.meta.url)));
126
+ await assertSkillsSource(skillsSource);
127
+ const plans = resolvePlans(parsed.data.harness, home, which);
128
+ const claudeMdWrite = plans.some((p) => p.harness === "claude") ? await decideClaudeMd(claudeMdFlag, canPrompt, dryRun, deps) : false;
129
+ const harnesses = [];
130
+ for (const plan of plans) {
131
+ harnesses.push(await applyPlan(plan, skillsSource, dryRun, claudeMdWrite));
132
+ }
133
+ const collect = deps.collectChecks ?? ((c) => collectDoctorChecks(c, deps.doctorDeps ?? {}));
134
+ const doctor = await collect(ctx);
135
+ const publishMode = await selectPublishMode(publishModeFlag, ctx, deps, dryRun, canPrompt);
136
+ const data = {
137
+ dryRun,
138
+ skillsSource,
139
+ harnesses,
140
+ doctor: { status: doctor.failure !== void 0 ? "fail" : "pass", checks: doctor.checks },
141
+ publishMode
142
+ };
143
+ if (!humanOutput) return { data };
144
+ const humanLines = await buildWalkthrough(ctx, deps, {
145
+ dryRun,
146
+ noWallet,
147
+ canPrompt,
148
+ harnesses,
149
+ publishMode,
150
+ doctor
151
+ });
152
+ return { data, humanLines };
153
+ }
154
+ var EXAMPLE_QUESTION = "what actually changed in <library> v3's public API";
155
+ async function buildWalkthrough(ctx, deps, s) {
156
+ const io = ctx.io;
157
+ const lines = [];
158
+ if (s.dryRun) lines.push(paint(io, "yellow", "Dry run: nothing was written."));
159
+ lines.push(...skillsWalkthrough(io, s.harnesses, s.dryRun), "");
160
+ lines.push(
161
+ `${paint(io, "bold", `publish mode: ${s.publishMode.value}`)} ${paint(io, "dim", modeBlurb(s.publishMode.value))}`,
162
+ ""
163
+ );
164
+ lines.push(...await walletWalkthrough(ctx, deps, s.dryRun || !s.canPrompt, s.noWallet, io), "");
165
+ lines.push(...doctorSummary(io, s.doctor), "");
166
+ lines.push(`Done. Try: tenjin search "${EXAMPLE_QUESTION}"`);
167
+ return lines;
168
+ }
169
+ function harnessLabel(h) {
170
+ return h === "claude" ? "Claude Code" : h === "codex" ? "Codex" : "Agent Skills";
171
+ }
172
+ function skillsWalkthrough(io, harnesses, dryRun) {
173
+ const lines = [];
174
+ for (const h of harnesses) {
175
+ const n = h.skills.length;
176
+ const changed = h.skills.some((s) => s.status !== "up-to-date");
177
+ const verb = dryRun ? "would install" : changed ? "installed" : "up to date";
178
+ const wired = [];
179
+ if (h.agentsMd !== void 0) wired.push("AGENTS.md nudge");
180
+ if (h.claudeMd !== void 0 && h.claudeMd.status !== "skipped") wired.push("CLAUDE.md nudge");
181
+ const suffix = wired.length > 0 ? ` + ${wired.join(" + ")}` : "";
182
+ lines.push(
183
+ `${paint(io, "green", "\u2713")} ${harnessLabel(h.harness)}: ${n} skills ${verb}${suffix}`
184
+ );
185
+ const nudgePaths = nudgeFilesTouched(h);
186
+ if (nudgePaths.length > 0) {
187
+ lines.push(
188
+ paint(
189
+ io,
190
+ "dim",
191
+ " The nudge tells agents to run a free anonymous `tenjin search` before regenerating research; the generalized question text is sent to tenjin.blog."
192
+ )
193
+ );
194
+ lines.push(
195
+ paint(
196
+ io,
197
+ "dim",
198
+ ` Undo anytime: delete the ${SKILLS_MARKER} line from ${nudgePaths.join(" and ")}.`
199
+ )
200
+ );
201
+ }
202
+ if (h.claudeMd?.status === "skipped") {
203
+ lines.push(
204
+ paint(
205
+ io,
206
+ "dim",
207
+ " Add a Tenjin search nudge to ~/.claude/CLAUDE.md later: tenjin install --harness claude --claude-md"
208
+ )
209
+ );
210
+ }
211
+ if (h.codexNetworkRule !== void 0) {
212
+ lines.push(
213
+ paint(io, "dim", " Codex blocks network by default; add to ~/.codex/config.toml:")
214
+ );
215
+ for (const rl of h.codexNetworkRule.split("\n")) lines.push(paint(io, "dim", ` ${rl}`));
216
+ }
217
+ for (const w of h.warnings) lines.push(paint(io, "yellow", ` ! ${w}`));
218
+ }
219
+ return lines;
220
+ }
221
+ function nudgeFilesTouched(h) {
222
+ const paths = [];
223
+ if (h.agentsMd !== void 0 && ["appended", "updated", "would-append", "would-update"].includes(h.agentsMd.status)) {
224
+ paths.push(h.agentsMd.path);
225
+ }
226
+ if (h.claudeMd !== void 0 && ["written", "updated", "would-write", "would-update"].includes(h.claudeMd.status)) {
227
+ paths.push(h.claudeMd.path);
228
+ }
229
+ return paths;
230
+ }
231
+ function modeBlurb(v) {
232
+ return v === "review" ? "asks before every publish" : v === "auto" ? "publishes clean scans automatically" : "only detected secrets stop a publish";
233
+ }
234
+ async function walletWalkthrough(ctx, deps, skipCreate, noWallet, io) {
235
+ const exists = await (deps.walletExists ?? walletFileExists)(ctx.dataDir);
236
+ if (exists) {
237
+ const address2 = await (deps.walletAddress ?? existingWalletAddress)(ctx);
238
+ return [`${paint(io, "bold", "Wallet:")} ${address2} (existing)`];
239
+ }
240
+ const later = `${paint(io, "bold", "Wallet:")} none. Create one later with: tenjin wallet create`;
241
+ if (skipCreate || noWallet) return [later];
242
+ const confirm = deps.confirmWallet ?? defaultConfirmYesNo;
243
+ if (!await confirm("Create a wallet now? [Y/n] ")) return [later];
244
+ const address = await (deps.createWallet ?? defaultCreateWallet)(ctx);
245
+ return [
246
+ paint(io, "bold", "Wallet created:"),
247
+ ` ${address}`,
248
+ " Fund it: send a few dollars of USDC on Base to that address (this is a pocket-money wallet; keep it small).",
249
+ " Check with: tenjin wallet balance"
250
+ ];
251
+ }
252
+ async function existingWalletAddress(ctx) {
253
+ return (await describeWallet(resolveWalletProvider(ctx))).address;
254
+ }
255
+ async function defaultCreateWallet(ctx) {
256
+ const result = await runWalletCreate(ctx);
257
+ return result.data.address;
258
+ }
259
+ function defaultConfirmYesNo(label) {
260
+ return new Promise((resolve) => {
261
+ const rl = createInterface({ input: process.stdin, output: process.stderr });
262
+ let settled = false;
263
+ const settle = (value) => {
264
+ if (settled) return;
265
+ settled = true;
266
+ rl.close();
267
+ resolve(value);
268
+ };
269
+ rl.once("close", () => settle(false));
270
+ rl.question(label, (answer) => {
271
+ const a = answer.trim().toLowerCase();
272
+ settle(a === "" || a === "y" || a === "yes");
273
+ });
274
+ });
275
+ }
276
+ function doctorSummary(io, doctor) {
277
+ const problems = doctor.checks.filter((c) => c.status !== "ok");
278
+ if (problems.length === 0) return [`${paint(io, "green", "\u2713")} Everything checks out`];
279
+ const lines = [paint(io, "yellow", "Some checks need attention:")];
280
+ for (const c of problems) {
281
+ const icon = c.status === "fail" ? paint(io, "red", "\u2717") : paint(io, "yellow", "!");
282
+ lines.push(` ${icon} ${c.name}: ${c.detail}`);
283
+ if (c.fix !== void 0) lines.push(paint(io, "dim", ` fix: ${c.fix}`));
284
+ }
285
+ return lines;
286
+ }
287
+ var DEFAULT_MODE = CONFIG_DEFAULTS.publish.mode;
288
+ var PUBLISH_MODE_PROMPT = [
289
+ "Publish consent mode?",
290
+ " review - asks a yes/no for every publish",
291
+ " auto - publishes automatically when the secret-scan is clean (including answers your agent derives)",
292
+ " full-auto - publishes even past warnings; only detected secrets stop it",
293
+ `[${DEFAULT_MODE}]: `
294
+ ].join("\n");
295
+ async function selectPublishMode(flag, ctx, deps, dryRun, interactive) {
296
+ if (flag !== void 0) {
297
+ if (!dryRun) await persistPublishMode(ctx.dataDir, flag);
298
+ return { value: flag, source: "flag" };
299
+ }
300
+ const config = await loadRawConfig(ctx.dataDir);
301
+ if (config.publish?.mode !== void 0) {
302
+ return { value: config.publish.mode, source: "existing" };
303
+ }
304
+ if (dryRun || !interactive) return { value: DEFAULT_MODE, source: "default-skipped" };
305
+ const prompt = deps.promptMode ?? defaultPromptMode;
306
+ for (let attempt = 0; attempt < 2; attempt++) {
307
+ const answer = (await prompt(PUBLISH_MODE_PROMPT)).trim();
308
+ if (answer.length === 0) return { value: DEFAULT_MODE, source: "default-skipped" };
309
+ const parsed = PublishModeSchema.safeParse(answer);
310
+ if (parsed.success) {
311
+ await persistPublishMode(ctx.dataDir, parsed.data);
312
+ return { value: parsed.data, source: "prompt" };
313
+ }
314
+ }
315
+ ctx.io.stderr.write(
316
+ `Unrecognized mode; keeping the default (${DEFAULT_MODE}). Change it with \`tenjin config set publish.mode\`.
317
+ `
318
+ );
319
+ return { value: DEFAULT_MODE, source: "default-skipped" };
320
+ }
321
+ function parseModeFlag(value) {
322
+ return parsePublishModeFlag(value, "--publish-mode");
323
+ }
324
+ function defaultPromptMode(label) {
325
+ return new Promise((resolve) => {
326
+ const rl = createInterface({ input: process.stdin, output: process.stderr });
327
+ let settled = false;
328
+ const settle = (value) => {
329
+ if (settled) return;
330
+ settled = true;
331
+ rl.close();
332
+ resolve(value);
333
+ };
334
+ rl.once("close", () => settle(""));
335
+ rl.question(label, (answer) => settle(answer));
336
+ });
337
+ }
338
+ function resolvePlans(override, home, which) {
339
+ const claudeDir = join2(home, ".claude", "skills");
340
+ const sharedDir = join2(home, ".agents", "skills");
341
+ if (override !== void 0 && override.length > 0) {
342
+ const plans2 = override.map(
343
+ (v) => planFor(validateHarness(v), ["override"], true, home, claudeDir, sharedDir)
344
+ );
345
+ return dedupeBySkillsDir(plans2);
346
+ }
347
+ const plans = [];
348
+ const claudeBy = detectReasons(existsSync2(join2(home, ".claude")), which("claude"));
349
+ const codexBy = detectReasons(existsSync2(join2(home, ".codex")), which("codex"));
350
+ if (claudeBy.length > 0)
351
+ plans.push(planFor("claude", claudeBy, true, home, claudeDir, sharedDir));
352
+ if (codexBy.length > 0) plans.push(planFor("codex", codexBy, true, home, claudeDir, sharedDir));
353
+ if (plans.length === 0) {
354
+ plans.push(planFor("shared", ["fallback"], false, home, claudeDir, sharedDir));
355
+ }
356
+ return dedupeBySkillsDir(plans);
357
+ }
358
+ function detectReasons(homeDirPresent, onPathPresent) {
359
+ const reasons = [];
360
+ if (homeDirPresent) reasons.push("home-dir");
361
+ if (onPathPresent) reasons.push("binary");
362
+ return reasons;
363
+ }
364
+ function planFor(harness, detectedBy, detected, home, claudeDir, sharedDir) {
365
+ const skillsDir = harness === "claude" ? claudeDir : sharedDir;
366
+ return { harness, detected, detectedBy, skillsDir, wiresAgentsMd: harness !== "claude", home };
367
+ }
368
+ function dedupeBySkillsDir(plans) {
369
+ const seen = /* @__PURE__ */ new Set();
370
+ const out = [];
371
+ for (const p of plans) {
372
+ if (seen.has(p.skillsDir)) continue;
373
+ seen.add(p.skillsDir);
374
+ out.push(p);
375
+ }
376
+ return out;
377
+ }
378
+ function validateHarness(value) {
379
+ if (HARNESSES.includes(value)) return value;
380
+ throw new CliError("USAGE", `Unknown harness "${value}"`, {
381
+ fix: `--harness must be one of: ${HARNESSES.join(", ")}.`
382
+ });
383
+ }
384
+ async function applyPlan(plan, skillsSource, dryRun, claudeMdWrite) {
385
+ const skills = [];
386
+ const warnings = [];
387
+ for (const name of SKILL_NAMES) {
388
+ const { status, warning } = await installSkill(
389
+ join2(skillsSource, name),
390
+ join2(plan.skillsDir, name),
391
+ dryRun
392
+ );
393
+ skills.push({ name, status });
394
+ if (warning !== void 0) warnings.push(warning);
395
+ }
396
+ const result = {
397
+ harness: plan.harness,
398
+ detected: plan.detected,
399
+ detectedBy: plan.detectedBy,
400
+ skillsDir: plan.skillsDir,
401
+ skills,
402
+ notes: notesFor(plan),
403
+ warnings
404
+ };
405
+ if (plan.wiresAgentsMd) {
406
+ result.agentsMd = await wireAgentsMd(plan, dryRun);
407
+ result.codexNetworkRule = CODEX_NETWORK_RULE;
408
+ } else if (plan.harness === "claude") {
409
+ result.claudeMd = await wireClaudeMd(plan, dryRun, claudeMdWrite);
410
+ }
411
+ return result;
412
+ }
413
+ async function decideClaudeMd(flag, canPrompt, dryRun, deps) {
414
+ if (flag !== void 0) return flag;
415
+ if (dryRun || !canPrompt) return false;
416
+ const confirm = deps.confirmClaudeMd ?? defaultConfirmYesNo;
417
+ return confirm(
418
+ "Add a one-line nudge to ~/.claude/CLAUDE.md telling agents to try a free Tenjin search before regenerating research? It sends only generalized question text to tenjin.blog. [Y/n] "
419
+ );
420
+ }
421
+ async function wireClaudeMd(plan, dryRun, write) {
422
+ const path = join2(plan.home, ".claude", "CLAUDE.md");
423
+ if (!write) return { path, status: "skipped" };
424
+ const existing = existsSync2(path) ? await readFile(path, "utf8") : null;
425
+ const { content, change } = upsertMarkerLine(existing, nudgeLine(plan.skillsDir));
426
+ if (change === "none") return { path, status: "up-to-date" };
427
+ if (!dryRun && content !== null) await writeFileAtomic(path, content);
428
+ if (change === "append") return { path, status: dryRun ? "would-write" : "written" };
429
+ return { path, status: dryRun ? "would-update" : "updated" };
430
+ }
431
+ function notesFor(plan) {
432
+ if (plan.harness === "claude") {
433
+ return [
434
+ "Installed at the user level (~/.claude/skills). A Claude Code plugin will later make this automatic."
435
+ ];
436
+ }
437
+ return [
438
+ "Copied into the shared Agent Skills location (~/.agents/skills). Codex and any Agent-Skills-compatible harness read it there."
439
+ ];
440
+ }
441
+ async function installSkill(srcDir, destDir, dryRun) {
442
+ const src = await readTree(srcDir);
443
+ const dest = await readTree(destDir);
444
+ if (src === null) {
445
+ throw new CliError("INTERNAL", `Packaged skill source ${srcDir} is empty`);
446
+ }
447
+ const change = dest === null ? "create" : treesEqual(src, dest) ? "none" : "update";
448
+ if (!dryRun && change !== "none") {
449
+ await rm(destDir, { recursive: true, force: true });
450
+ for (const [rel, content] of src) {
451
+ await writeFileAtomic(join2(destDir, rel), content);
452
+ }
453
+ }
454
+ if (change === "create") return { status: dryRun ? "would-install" : "installed" };
455
+ if (change === "none") return { status: "up-to-date" };
456
+ return {
457
+ status: dryRun ? "would-update" : "updated",
458
+ warning: `${destDir}: local skill copy differed and was ${dryRun ? "would be " : ""}overwritten (the packaged copy is canonical).`
459
+ };
460
+ }
461
+ async function readTree(dir) {
462
+ if (!existsSync2(dir)) return null;
463
+ const entries = await readdir(dir, { recursive: true, withFileTypes: true });
464
+ const files = /* @__PURE__ */ new Map();
465
+ for (const entry of entries) {
466
+ if (!entry.isFile()) continue;
467
+ const full = join2(entry.parentPath, entry.name);
468
+ files.set(relative(dir, full), await readFile(full));
469
+ }
470
+ return files;
471
+ }
472
+ function treesEqual(a, b) {
473
+ if (b === null) return false;
474
+ if (a.size !== b.size) return false;
475
+ for (const [k, v] of a) {
476
+ const other = b.get(k);
477
+ if (other === void 0 || !v.equals(other)) return false;
478
+ }
479
+ return true;
480
+ }
481
+ async function wireAgentsMd(plan, dryRun) {
482
+ const shared = join2(plan.home, ".agents", "AGENTS.md");
483
+ const codex = join2(plan.home, ".codex", "AGENTS.md");
484
+ const line = nudgeLine(plan.skillsDir);
485
+ for (const path of [shared, codex]) {
486
+ if (existsSync2(path) && (await readFile(path, "utf8")).includes(SKILLS_MARKER)) {
487
+ return upsertAgentsMd(path, line, dryRun);
488
+ }
489
+ }
490
+ return upsertAgentsMd(chooseAgentsMdPath(plan.home), line, dryRun);
491
+ }
492
+ async function upsertAgentsMd(path, line, dryRun) {
493
+ const existing = existsSync2(path) ? await readFile(path, "utf8") : null;
494
+ const { content, change } = upsertMarkerLine(existing, line);
495
+ if (change === "none") return { path, status: "already-present" };
496
+ if (!dryRun && content !== null) await writeFileAtomic(path, content);
497
+ if (change === "append") return { path, status: dryRun ? "would-append" : "appended" };
498
+ return { path, status: dryRun ? "would-update" : "updated" };
499
+ }
500
+ function chooseAgentsMdPath(home) {
501
+ const shared = join2(home, ".agents", "AGENTS.md");
502
+ const codex = join2(home, ".codex", "AGENTS.md");
503
+ if (existsSync2(shared)) return shared;
504
+ if (existsSync2(codex)) return codex;
505
+ if (existsSync2(join2(home, ".codex"))) return codex;
506
+ return shared;
507
+ }
508
+ function onPath(bin, env) {
509
+ const raw = env.PATH ?? "";
510
+ const exts = process.platform === "win32" ? ["", ...(env.PATHEXT ?? ".EXE;.CMD;.BAT;.COM").split(";").filter((e) => e.length > 0)] : [""];
511
+ for (const part of raw.split(delimiter)) {
512
+ if (part.length === 0) continue;
513
+ for (const ext of exts) {
514
+ if (isFile(join2(part, bin + ext))) return true;
515
+ }
516
+ }
517
+ return false;
518
+ }
519
+ function isFile(p) {
520
+ try {
521
+ return statSync(p).isFile();
522
+ } catch {
523
+ return false;
524
+ }
525
+ }
526
+ function paint(io, format, text) {
527
+ if (io.stdout instanceof Stream) return styleText(format, text, { stream: io.stdout });
528
+ return styleText(format, text);
529
+ }
530
+ async function assertSkillsSource(dir) {
531
+ for (const name of SKILL_NAMES) {
532
+ if (!existsSync2(join2(dir, name, "SKILL.md"))) {
533
+ throw new CliError("INTERNAL", `Packaged skill "${name}" is missing under ${dir}`, {
534
+ fix: "Reinstall tenjin-cli; the published package must ship every skill under skills/."
535
+ });
536
+ }
537
+ }
538
+ }
539
+ export {
540
+ runInstall
541
+ };
542
+ //# sourceMappingURL=install-7J6KKEEP.js.map