tenjin-cli 0.1.0-alpha.5 → 0.1.0-alpha.7

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 +107 -33
  2. package/dist/{buy-YMXXVNFH.js → buy-XVOMNWKN.js} +18 -16
  3. package/dist/{candidate-H7FR4AU5.js → candidate-DJB2NNTG.js} +7 -8
  4. package/dist/{chunk-TXPPMK4L.js → chunk-2KIDDWQO.js} +5 -5
  5. package/dist/{chunk-3IRDP7TN.js → chunk-2L73UI6T.js} +6 -4
  6. package/dist/{chunk-3IRDP7TN.js.map → chunk-2L73UI6T.js.map} +1 -1
  7. package/dist/{chunk-ZW3B5LWX.js → chunk-2YX6LTCD.js} +5 -5
  8. package/dist/{chunk-HTDALK7M.js → chunk-5X4EBGGU.js} +15 -12
  9. package/dist/{chunk-HTDALK7M.js.map → chunk-5X4EBGGU.js.map} +1 -1
  10. package/dist/{chunk-RTJLLPFA.js → chunk-6S44OLND.js} +123 -23
  11. package/dist/chunk-6S44OLND.js.map +1 -0
  12. package/dist/{chunk-FU6MCSLG.js → chunk-7WDY4AXV.js} +2 -64
  13. package/dist/chunk-7WDY4AXV.js.map +1 -0
  14. package/dist/{chunk-NFSOVL3C.js → chunk-BBUYCDSG.js} +12 -3
  15. package/dist/chunk-BBUYCDSG.js.map +1 -0
  16. package/dist/chunk-CYRYVZPN.js +213 -0
  17. package/dist/chunk-CYRYVZPN.js.map +1 -0
  18. package/dist/{chunk-MDDGEGSW.js → chunk-DAJ56EUU.js} +3 -3
  19. package/dist/{chunk-IOPWPMT2.js → chunk-DH6D6QIO.js} +5 -5
  20. package/dist/chunk-E6BNARCS.js +614 -0
  21. package/dist/chunk-E6BNARCS.js.map +1 -0
  22. package/dist/chunk-GABYDXWL.js +190 -0
  23. package/dist/chunk-GABYDXWL.js.map +1 -0
  24. package/dist/{chunk-LAM66WFJ.js → chunk-GM4RZUVU.js} +6 -8
  25. package/dist/{chunk-LAM66WFJ.js.map → chunk-GM4RZUVU.js.map} +1 -1
  26. package/dist/{chunk-ZDY2KY5X.js → chunk-GXYNLMUQ.js} +28 -11
  27. package/dist/chunk-GXYNLMUQ.js.map +1 -0
  28. package/dist/{chunk-PAUXMRSF.js → chunk-J6CVKC4M.js} +73 -2
  29. package/dist/chunk-J6CVKC4M.js.map +1 -0
  30. package/dist/{chunk-BIKAUVC2.js → chunk-KT2DGKFT.js} +40 -6
  31. package/dist/chunk-KT2DGKFT.js.map +1 -0
  32. package/dist/chunk-L6AV2Q73.js +105 -0
  33. package/dist/chunk-L6AV2Q73.js.map +1 -0
  34. package/dist/{chunk-CVX6JNGD.js → chunk-OTDI5FXG.js} +3 -5
  35. package/dist/{chunk-CVX6JNGD.js.map → chunk-OTDI5FXG.js.map} +1 -1
  36. package/dist/chunk-PIIWLEEG.js +337 -0
  37. package/dist/chunk-PIIWLEEG.js.map +1 -0
  38. package/dist/{chunk-PYNSGYBE.js → chunk-PLU3E63S.js} +249 -552
  39. package/dist/chunk-PLU3E63S.js.map +1 -0
  40. package/dist/{chunk-C444K6MI.js → chunk-RGFBBNGP.js} +42 -17
  41. package/dist/{chunk-C444K6MI.js.map → chunk-RGFBBNGP.js.map} +1 -1
  42. package/dist/chunk-SGK2B724.js +67 -0
  43. package/dist/chunk-SGK2B724.js.map +1 -0
  44. package/dist/{chunk-5SCU253N.js → chunk-UYP7G3GZ.js} +2 -2
  45. package/dist/{chunk-ZIYVN4CD.js → chunk-VZ3AJCO5.js} +3 -5
  46. package/dist/{chunk-ZIYVN4CD.js.map → chunk-VZ3AJCO5.js.map} +1 -1
  47. package/dist/{chunk-NJF2WENW.js → chunk-WDJTGVKN.js} +2 -2
  48. package/dist/{chunk-NJF2WENW.js.map → chunk-WDJTGVKN.js.map} +1 -1
  49. package/dist/{chunk-4WVKXKDK.js → chunk-WI5EOAQQ.js} +29 -238
  50. package/dist/chunk-WI5EOAQQ.js.map +1 -0
  51. package/dist/{chunk-QONTBYQW.js → chunk-WRWCDLVK.js} +4 -6
  52. package/dist/{chunk-QONTBYQW.js.map → chunk-WRWCDLVK.js.map} +1 -1
  53. package/dist/chunk-XBJ3VLWX.js +35 -0
  54. package/dist/chunk-XBJ3VLWX.js.map +1 -0
  55. package/dist/{chunk-ADJYSM45.js → chunk-ZEWY3RJ3.js} +27 -13
  56. package/dist/chunk-ZEWY3RJ3.js.map +1 -0
  57. package/dist/chunk-ZFE7STX7.js +143 -0
  58. package/dist/chunk-ZFE7STX7.js.map +1 -0
  59. package/dist/{cli-IW76QTN3.js → cli-7B2QNJG3.js} +231 -23
  60. package/dist/cli-7B2QNJG3.js.map +1 -0
  61. package/dist/{config-VCOS7P5K.js → config-SAQEQRFB.js} +5 -6
  62. package/dist/{doctor-WS65JG3V.js → doctor-ENJ22XWN.js} +10 -9
  63. package/dist/{publish-DSFWQRUN.js → edit-2QO5GQDU.js} +18 -16
  64. package/dist/index.js +1 -1
  65. package/dist/{inspect-SFJWUQHO.js → inspect-IPKKQB2S.js} +15 -14
  66. package/dist/{install-RVPQPCKH.js → install-7ZIYISQ7.js} +17 -17
  67. package/dist/outcome-NSDE2KAJ.js +20 -0
  68. package/dist/publish-7WIFFNFG.js +40 -0
  69. package/dist/read-5TQR7LCF.js +158 -0
  70. package/dist/read-5TQR7LCF.js.map +1 -0
  71. package/dist/{run-OMPKA43G.js → run-NPKIP26Y.js} +102 -28
  72. package/dist/{run-OMPKA43G.js.map → run-NPKIP26Y.js.map} +1 -1
  73. package/dist/search-63ELMRZH.js +24 -0
  74. package/dist/{send-3G4C64HJ.js → send-ENE47KQE.js} +7 -7
  75. package/dist/session-FZU4VFFE.js +87 -0
  76. package/dist/session-FZU4VFFE.js.map +1 -0
  77. package/dist/{wallet-PP22LAX7.js → wallet-OCCGEH6H.js} +7 -7
  78. package/dist/{wallet-B7KJS2R5.js → wallet-RBDVNZVR.js} +5 -5
  79. package/dist/wallet-RBDVNZVR.js.map +1 -0
  80. package/package.json +1 -1
  81. package/skills/tenjin/SKILL.md +2 -2
  82. package/skills/tenjin-publish/SKILL.md +12 -4
  83. package/skills/tenjin-search/SKILL.md +68 -12
  84. package/dist/chunk-2JQ5JSG6.js +0 -68
  85. package/dist/chunk-2JQ5JSG6.js.map +0 -1
  86. package/dist/chunk-4WVKXKDK.js.map +0 -1
  87. package/dist/chunk-ADJYSM45.js.map +0 -1
  88. package/dist/chunk-BIKAUVC2.js.map +0 -1
  89. package/dist/chunk-FU6MCSLG.js.map +0 -1
  90. package/dist/chunk-L4IHCN6B.js +0 -63
  91. package/dist/chunk-L4IHCN6B.js.map +0 -1
  92. package/dist/chunk-NFSOVL3C.js.map +0 -1
  93. package/dist/chunk-PAUXMRSF.js.map +0 -1
  94. package/dist/chunk-PYNSGYBE.js.map +0 -1
  95. package/dist/chunk-RTJLLPFA.js.map +0 -1
  96. package/dist/chunk-ZDY2KY5X.js.map +0 -1
  97. package/dist/cli-IW76QTN3.js.map +0 -1
  98. package/dist/outcome-GNYCSZ7J.js +0 -20
  99. package/dist/search-KOI6Y7P6.js +0 -24
  100. /package/dist/{buy-YMXXVNFH.js.map → buy-XVOMNWKN.js.map} +0 -0
  101. /package/dist/{candidate-H7FR4AU5.js.map → candidate-DJB2NNTG.js.map} +0 -0
  102. /package/dist/{chunk-TXPPMK4L.js.map → chunk-2KIDDWQO.js.map} +0 -0
  103. /package/dist/{chunk-ZW3B5LWX.js.map → chunk-2YX6LTCD.js.map} +0 -0
  104. /package/dist/{chunk-MDDGEGSW.js.map → chunk-DAJ56EUU.js.map} +0 -0
  105. /package/dist/{chunk-IOPWPMT2.js.map → chunk-DH6D6QIO.js.map} +0 -0
  106. /package/dist/{chunk-5SCU253N.js.map → chunk-UYP7G3GZ.js.map} +0 -0
  107. /package/dist/{config-VCOS7P5K.js.map → config-SAQEQRFB.js.map} +0 -0
  108. /package/dist/{doctor-WS65JG3V.js.map → doctor-ENJ22XWN.js.map} +0 -0
  109. /package/dist/{inspect-SFJWUQHO.js.map → edit-2QO5GQDU.js.map} +0 -0
  110. /package/dist/{outcome-GNYCSZ7J.js.map → inspect-IPKKQB2S.js.map} +0 -0
  111. /package/dist/{install-RVPQPCKH.js.map → install-7ZIYISQ7.js.map} +0 -0
  112. /package/dist/{publish-DSFWQRUN.js.map → outcome-NSDE2KAJ.js.map} +0 -0
  113. /package/dist/{search-KOI6Y7P6.js.map → publish-7WIFFNFG.js.map} +0 -0
  114. /package/dist/{wallet-B7KJS2R5.js.map → search-63ELMRZH.js.map} +0 -0
  115. /package/dist/{send-3G4C64HJ.js.map → send-ENE47KQE.js.map} +0 -0
  116. /package/dist/{wallet-PP22LAX7.js.map → wallet-OCCGEH6H.js.map} +0 -0
@@ -1,56 +1,30 @@
1
1
  import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
2
  import {
3
- buildSiwxHeader,
4
- headingOutline
5
- } from "./chunk-FU6MCSLG.js";
6
- import {
7
- describeWallet,
8
- resolveWalletProvider
9
- } from "./chunk-C444K6MI.js";
3
+ SESSION_CHAIN_ID,
4
+ createSessionKeyAuth,
5
+ createSiwxAuth
6
+ } from "./chunk-ZFE7STX7.js";
10
7
  import {
11
8
  rateLimitError
12
- } from "./chunk-3IRDP7TN.js";
13
- import {
14
- dropCandidate,
15
- readCandidate
16
- } from "./chunk-ZIYVN4CD.js";
9
+ } from "./chunk-2L73UI6T.js";
17
10
  import {
18
11
  ATOMIC_RE,
19
12
  UUID_RE
20
13
  } from "./chunk-WWX32ML4.js";
21
14
  import {
22
15
  CLIENT_HEADER,
23
- httpRequest,
24
- trimSlash
25
- } from "./chunk-ZDY2KY5X.js";
26
- import {
27
- sanitizeForTerminal
28
- } from "./chunk-NFSOVL3C.js";
16
+ httpRequest
17
+ } from "./chunk-GXYNLMUQ.js";
29
18
  import {
30
- hasCode
31
- } from "./chunk-2I4QTOLB.js";
32
- import {
33
- resolveContextSettings,
34
- resolvePublishSettings
35
- } from "./chunk-MDDGEGSW.js";
36
- import {
37
- PublishModeSchema,
38
- parsePublishModeFlag,
39
- parseUsdToAtomic,
40
- toMoney
41
- } from "./chunk-5SCU253N.js";
19
+ trimSlash
20
+ } from "./chunk-XBJ3VLWX.js";
42
21
  import {
43
- writeFileAtomic
44
- } from "./chunk-2JQ5JSG6.js";
22
+ PublishModeSchema
23
+ } from "./chunk-UYP7G3GZ.js";
45
24
  import {
46
25
  CliError,
47
- external_exports,
48
- sessionPath
49
- } from "./chunk-PAUXMRSF.js";
50
-
51
- // src/commands/publish.ts
52
- import { readFile as readFile3 } from "fs/promises";
53
- import { dirname as dirname2, resolve as resolve2 } from "path";
26
+ external_exports
27
+ } from "./chunk-J6CVKC4M.js";
54
28
 
55
29
  // src/lib/scan.ts
56
30
  var LONG_QUOTE_WORDS = 80;
@@ -973,7 +947,8 @@ function buildPostCreateBody(input) {
973
947
  if (bodyMd !== void 0 && bodyMd.length > 2e5) {
974
948
  throw new CliError("USAGE", "bodyMd must be at most 200000 characters.");
975
949
  }
976
- if (input.excerpt !== void 0 && input.excerpt.length > 500) {
950
+ const excerpt = input.excerpt?.trim();
951
+ if (excerpt !== void 0 && excerpt.length > 500) {
977
952
  throw new CliError("USAGE", "excerpt must be at most 500 characters.");
978
953
  }
979
954
  if (input.tags !== void 0) {
@@ -1004,7 +979,7 @@ function buildPostCreateBody(input) {
1004
979
  return {
1005
980
  ...title !== void 0 && title.length > 0 ? { title } : {},
1006
981
  ...bodyMd !== void 0 ? { bodyMd } : {},
1007
- ...input.excerpt !== void 0 ? { excerpt: input.excerpt } : {},
982
+ ...excerpt !== void 0 ? { excerpt } : {},
1008
983
  ...input.tags !== void 0 && input.tags.length > 0 ? { tags: input.tags } : {},
1009
984
  ...input.priceAtomic !== void 0 ? { price: input.priceAtomic } : {},
1010
985
  ...input.handle !== void 0 ? { handle: input.handle } : {},
@@ -1013,6 +988,22 @@ function buildPostCreateBody(input) {
1013
988
  };
1014
989
  }
1015
990
  var resourceEchoSchema = external_exports.object({
991
+ artifactType: external_exports.string().nullish(),
992
+ mediaType: external_exports.string().nullish(),
993
+ temporalMode: external_exports.string().nullish(),
994
+ asOf: external_exports.string().nullish(),
995
+ validUntil: external_exports.string().nullish(),
996
+ supersedesPostId: external_exports.string().nullish(),
997
+ questionsAnswered: external_exports.array(external_exports.string()).nullish(),
998
+ tasksSupported: external_exports.array(external_exports.string()).nullish(),
999
+ scope: external_exports.string().nullish(),
1000
+ exclusions: external_exports.string().nullish(),
1001
+ appliesTo: external_exports.record(external_exports.string(), external_exports.array(external_exports.string())).nullish(),
1002
+ provenanceSummary: external_exports.string().nullish(),
1003
+ methodologySummary: external_exports.string().nullish(),
1004
+ maintenanceCadence: external_exports.string().nullish(),
1005
+ reproductionMinutes: external_exports.number().nullish(),
1006
+ estimatedPaidInputCost: external_exports.string().nullish(),
1016
1007
  cacheEligible: external_exports.boolean(),
1017
1008
  cacheEligibleMissing: external_exports.array(external_exports.string())
1018
1009
  }).passthrough();
@@ -1023,6 +1014,9 @@ var ownPostSchema = external_exports.object({
1023
1014
  status: external_exports.string(),
1024
1015
  price: external_exports.string(),
1025
1016
  url: external_exports.string(),
1017
+ excerpt: external_exports.string().nullish(),
1018
+ bodyMd: external_exports.string().nullish(),
1019
+ tags: external_exports.array(external_exports.string()).nullish(),
1026
1020
  warnings: external_exports.array(external_exports.string()).optional(),
1027
1021
  resource: resourceEchoSchema.optional()
1028
1022
  }).passthrough();
@@ -1074,6 +1068,179 @@ async function publishPost(input, auth, opts) {
1074
1068
  };
1075
1069
  }
1076
1070
  }
1071
+ function buildPostUpdateBody(input) {
1072
+ const title = input.title?.trim();
1073
+ if (input.title !== void 0 && (title === void 0 || title.length === 0)) {
1074
+ throw new CliError("USAGE", "title cannot be empty.", {
1075
+ fix: "Pass a title, or omit --title to keep the stored one."
1076
+ });
1077
+ }
1078
+ if (title !== void 0 && title.length > 200) {
1079
+ throw new CliError("USAGE", "title must be at most 200 characters.");
1080
+ }
1081
+ if (input.bodyMd !== void 0) {
1082
+ if (input.bodyMd.trim().length === 0) {
1083
+ throw new CliError("USAGE", "bodyMd cannot be empty.", {
1084
+ fix: "Pass a file with Markdown in it, or omit --body to keep the stored body."
1085
+ });
1086
+ }
1087
+ if (input.bodyMd.length > 2e5) {
1088
+ throw new CliError("USAGE", "bodyMd must be at most 200000 characters.");
1089
+ }
1090
+ }
1091
+ const excerpt = input.excerpt?.trim();
1092
+ if (excerpt !== void 0 && excerpt.length > 500) {
1093
+ throw new CliError("USAGE", "excerpt must be at most 500 characters.");
1094
+ }
1095
+ if (input.tags !== void 0) {
1096
+ if (input.tags.length > 5) throw new CliError("USAGE", "at most 5 tags.");
1097
+ for (const tag of input.tags) {
1098
+ if (tag.length === 0 || tag.length > 50) {
1099
+ throw new CliError("USAGE", "each tag is 1 to 50 characters.");
1100
+ }
1101
+ }
1102
+ }
1103
+ if (input.priceAtomic !== void 0 && !PRICE_RE.test(input.priceAtomic)) {
1104
+ throw new CliError("USAGE", `Invalid price: ${JSON.stringify(input.priceAtomic)}`, {
1105
+ fix: "A price is an atomic USDC integer up to 13 digits, e.g. 100000 for $0.10."
1106
+ });
1107
+ }
1108
+ const body = {
1109
+ ...title !== void 0 ? { title } : {},
1110
+ ...input.bodyMd !== void 0 ? { bodyMd: input.bodyMd } : {},
1111
+ ...excerpt !== void 0 ? { excerpt } : {},
1112
+ ...input.tags !== void 0 ? { tags: input.tags } : {},
1113
+ ...input.priceAtomic !== void 0 ? { price: input.priceAtomic } : {},
1114
+ ...input.status !== void 0 ? { status: input.status } : {},
1115
+ ...input.resource !== void 0 ? { resource: input.resource } : {}
1116
+ };
1117
+ if (Object.keys(body).length === 0) {
1118
+ throw new CliError("USAGE", "Nothing to update.", {
1119
+ fix: "Pass at least one field flag, or run `tenjin edit <postId>` with no flags to view the post."
1120
+ });
1121
+ }
1122
+ return body;
1123
+ }
1124
+ async function getOwnPost(id, auth, opts) {
1125
+ const url = `${trimSlash(opts.baseUrl)}/api/posts/${encodeURIComponent(id)}`;
1126
+ let recoveries = 0;
1127
+ for (; ; ) {
1128
+ const authHeaders = await auth.headersFor({ method: "GET", url });
1129
+ const res = await httpRequest(url, {
1130
+ method: "GET",
1131
+ timeoutMs: opts.timeoutMs,
1132
+ headers: { accept: "application/json", "x-tenjin-client": CLIENT_HEADER, ...authHeaders },
1133
+ ...opts.fetchImpl !== void 0 ? { fetchImpl: opts.fetchImpl } : {}
1134
+ });
1135
+ if (!res.ok) throw writeTransportError(url, res);
1136
+ if (res.status === 401 && recoveries < MAX_RECOVERIES) {
1137
+ const code = auth401Code(res);
1138
+ if (await auth.recover(code)) {
1139
+ recoveries++;
1140
+ continue;
1141
+ }
1142
+ throw readAuthError(code, res);
1143
+ }
1144
+ if (res.status === 401) throw readAuthError(auth401Code(res), res);
1145
+ if (res.status === 404) throw postNotFound(id);
1146
+ if (res.status === 429) throw rateLimitError(url, (n) => res.header(n));
1147
+ if (res.status !== 200) {
1148
+ throw new CliError(
1149
+ "API_UNREACHABLE",
1150
+ serverMessage(res.json) ?? `Could not read post ${id} (${res.status}).`,
1151
+ {
1152
+ fix: "Review the server error, then retry.",
1153
+ details: { status: res.status, ...res.json !== void 0 ? { server: res.json } : {} }
1154
+ }
1155
+ );
1156
+ }
1157
+ return parseOwnPost(res.json, "read");
1158
+ }
1159
+ }
1160
+ async function updatePost(id, input, auth, opts) {
1161
+ const body = buildPostUpdateBody(input);
1162
+ const url = `${trimSlash(opts.baseUrl)}/api/posts/${encodeURIComponent(id)}`;
1163
+ const bodyStr = JSON.stringify(body);
1164
+ let recoveries = 0;
1165
+ for (; ; ) {
1166
+ const authHeaders = await auth.headersFor({ method: "PUT", url, body: bodyStr });
1167
+ const res = await httpRequest(url, {
1168
+ method: "PUT",
1169
+ timeoutMs: opts.timeoutMs,
1170
+ headers: { "x-tenjin-client": CLIENT_HEADER, ...authHeaders },
1171
+ jsonBody: body,
1172
+ ...opts.fetchImpl !== void 0 ? { fetchImpl: opts.fetchImpl } : {}
1173
+ });
1174
+ if (!res.ok) throw writeTransportError(url, res);
1175
+ if (res.status === 401 && recoveries < MAX_RECOVERIES) {
1176
+ const code = auth401Code(res);
1177
+ if (await auth.recover(code)) {
1178
+ recoveries++;
1179
+ continue;
1180
+ }
1181
+ throw authError(code, res);
1182
+ }
1183
+ if (res.status === 401) throw authError(auth401Code(res), res);
1184
+ if (res.status === 404) throw postNotFound(id);
1185
+ if (res.status === 429) throw rateLimitError(url, (n) => res.header(n));
1186
+ if (res.status !== 200) throw updateFailed(res);
1187
+ return parseOwnPost(res.json, "update");
1188
+ }
1189
+ }
1190
+ function parseOwnPost(json, what) {
1191
+ const parsed = ownPostSchema.safeParse(json);
1192
+ if (!parsed.success) {
1193
+ throw new CliError(
1194
+ "CONTRACT_MISMATCH",
1195
+ `The post ${what} response did not match the contract.`,
1196
+ {
1197
+ fix: "Update tenjin-cli; the server contract may have changed.",
1198
+ details: parsed.error.issues
1199
+ }
1200
+ );
1201
+ }
1202
+ return parsed.data;
1203
+ }
1204
+ function postNotFound(id) {
1205
+ return new CliError("RESOURCE_NOT_FOUND", `Post ${id} was not found, or is not yours.`, {
1206
+ fix: "Check the post id on your desk; owner-scoped routes do not distinguish the two."
1207
+ });
1208
+ }
1209
+ function readAuthError(code, res) {
1210
+ return new CliError(
1211
+ "API_UNREACHABLE",
1212
+ serverMessage(res.json) ?? `Reading the post was not authorized (${code ?? "401"}).`,
1213
+ {
1214
+ fix: code === "session_key_unbound" ? "Delete ~/.tenjin/session.json to re-establish the session key." : "Check the wallet and retry.",
1215
+ details: {
1216
+ code: code ?? "unauthorized",
1217
+ ...res.json !== void 0 ? { server: res.json } : {}
1218
+ }
1219
+ }
1220
+ );
1221
+ }
1222
+ function updateFailed(res) {
1223
+ const fields = fieldErrorKeys(res.json);
1224
+ const base = serverMessage(res.json) ?? `Update failed (${res.status}).`;
1225
+ return new CliError(
1226
+ "PUBLISH_FAILED",
1227
+ fields.length > 0 ? `${base} (${fields.join(", ")})` : base,
1228
+ {
1229
+ fix: fields.length > 0 ? "Correct the reported fields, then re-run `tenjin edit`." : "Review the server error, then re-run `tenjin edit`.",
1230
+ details: { status: res.status, ...res.json !== void 0 ? { server: res.json } : {} }
1231
+ }
1232
+ );
1233
+ }
1234
+ function fieldErrorKeys(json) {
1235
+ if (typeof json !== "object" || json === null) return [];
1236
+ const err = json.error;
1237
+ if (typeof err !== "object" || err === null) return [];
1238
+ const details = err.details;
1239
+ if (typeof details !== "object" || details === null) return [];
1240
+ const fieldErrors = details.fieldErrors;
1241
+ if (typeof fieldErrors !== "object" || fieldErrors === null) return [];
1242
+ return Object.keys(fieldErrors);
1243
+ }
1077
1244
  function auth401Code(res) {
1078
1245
  const header = res.header("www-authenticate");
1079
1246
  const m = header !== void 0 ? /error="([^"]+)"/.exec(header) : null;
@@ -1130,524 +1297,43 @@ function writeTransportError(url, result) {
1130
1297
  });
1131
1298
  }
1132
1299
 
1133
- // src/lib/session-key.ts
1134
- import { createHash, randomBytes, webcrypto } from "crypto";
1135
- import { readFile as readFile2, stat as stat2 } from "fs/promises";
1136
- var SESSION_SCOPE = "read+write";
1137
- var SESSION_TTL_MS = 24 * 60 * 60 * 1e3;
1138
- var EXP_SKEW_MS = 6e4;
1139
- var SessionFileSchema = external_exports.object({
1140
- /** Lowercased wallet address this delegation is bound to. */
1141
- address: external_exports.string(),
1142
- /** The constant base64 SIWX `Tenjin-Session-Delegation` header value. */
1143
- delegation: external_exports.string(),
1144
- /** Delegation expiry (ISO 8601); a request is never signed at/after this. */
1145
- exp: external_exports.string(),
1146
- scope: external_exports.string(),
1147
- /** base64url raw 65-byte uncompressed P-256 point (0x04||X||Y). */
1148
- publicKeyRaw: external_exports.string(),
1149
- /** The P-256 private key as a JWK, re-imported to sign each request. */
1150
- privateKeyJwk: external_exports.record(external_exports.string(), external_exports.unknown())
1151
- });
1152
- var subtle = webcrypto.subtle;
1153
- function toBase64(bytes) {
1154
- return Buffer.from(bytes).toString("base64");
1155
- }
1156
- function toBase64Url(bytes) {
1157
- return Buffer.from(bytes).toString("base64url");
1158
- }
1159
- function contentDigest(body) {
1160
- const hash = createHash("sha256").update(body, "utf8").digest();
1161
- return `sha-256=:${hash.toString("base64")}:`;
1162
- }
1163
- function targetUri(url) {
1164
- const u = new URL(url);
1165
- return `${u.protocol}//${u.host}${u.pathname}${u.search}`;
1166
- }
1167
- function signatureParams(input) {
1168
- const covered = input.contentDigest !== void 0 ? '"@method" "@target-uri" "content-digest"' : '"@method" "@target-uri"';
1169
- return `(${covered});created=${input.created};nonce="${input.nonce}";keyid="${input.keyid}";alg="ecdsa-p256-sha256"`;
1170
- }
1171
- function signatureBase(input) {
1172
- const params = signatureParams(input);
1173
- const lines = [
1174
- `"@method": ${input.method.toUpperCase()}`,
1175
- `"@target-uri": ${targetUri(input.url)}`,
1176
- ...input.contentDigest !== void 0 ? [`"content-digest": ${input.contentDigest}`] : [],
1177
- `"@signature-params": ${params}`
1178
- ];
1179
- return lines.join("\n");
1180
- }
1181
- function generateP256KeyPair() {
1182
- return subtle.generateKey({ name: "ECDSA", namedCurve: "P-256" }, true, [
1183
- "sign",
1184
- "verify"
1185
- ]);
1186
- }
1187
- async function importSigningKey(jwk) {
1188
- return subtle.importKey(
1189
- "jwk",
1190
- jwk,
1191
- { name: "ECDSA", namedCurve: "P-256" },
1192
- false,
1193
- ["sign"]
1194
- );
1195
- }
1196
- async function signBase(jwk, base) {
1197
- const key = await importSigningKey(jwk);
1198
- const sig = await subtle.sign({ name: "ECDSA", hash: "SHA-256" }, key, Buffer.from(base, "utf8"));
1199
- return toBase64(new Uint8Array(sig));
1200
- }
1201
- function keyidFor(publicKeyRaw) {
1202
- return `p256:${publicKeyRaw}`;
1203
- }
1204
- function delegationResources(publicKeyRaw, expIso) {
1205
- return [
1206
- `urn:tenjin:session:pubkey:p256:${publicKeyRaw}`,
1207
- `urn:tenjin:session:exp:${expIso}`,
1208
- `urn:tenjin:session:scope:${SESSION_SCOPE}`
1209
- ];
1210
- }
1211
- async function establishSession(config, deps = {}) {
1212
- const now = deps.now ?? Date.now;
1213
- const pair = await generateP256KeyPair();
1214
- const rawPub = new Uint8Array(await subtle.exportKey("raw", pair.publicKey));
1215
- const publicKeyRaw = toBase64Url(rawPub);
1216
- const jwk = await subtle.exportKey("jwk", pair.privateKey);
1217
- const expIso = new Date(now() + SESSION_TTL_MS).toISOString();
1218
- const delegation = await buildSiwxHeader(config.signer, {
1219
- baseUrl: config.baseUrl,
1220
- chainId: config.chainId,
1221
- ttlMs: SESSION_TTL_MS,
1222
- statement: "Delegate a Tenjin session key.",
1223
- resources: delegationResources(publicKeyRaw, expIso)
1224
- });
1225
- const file = {
1226
- address: config.signer.address.toLowerCase(),
1227
- delegation,
1228
- exp: expIso,
1229
- scope: SESSION_SCOPE,
1230
- publicKeyRaw,
1231
- privateKeyJwk: jwk
1232
- };
1233
- await saveSessionFile(config.dataDir, file);
1234
- return file;
1235
- }
1236
- async function signWithSession(file, req, deps = {}) {
1237
- const now = deps.now ?? Date.now;
1238
- const nonce = deps.nonce ?? (() => randomBytes(16).toString("hex"));
1239
- const digest = contentDigest(req.body);
1240
- const created = Math.floor(now() / 1e3);
1241
- const params = {
1242
- method: req.method,
1243
- url: req.url,
1244
- contentDigest: digest,
1245
- created,
1246
- nonce: nonce(),
1247
- keyid: keyidFor(file.publicKeyRaw)
1248
- };
1249
- const base = signatureBase(params);
1250
- const signature = await signBase(file.privateKeyJwk, base);
1251
- return {
1252
- "Tenjin-Session-Delegation": file.delegation,
1253
- "Signature-Input": `tenjin=${signatureParams(params)}`,
1254
- Signature: `tenjin=:${signature}:`,
1255
- "Content-Digest": digest
1256
- };
1257
- }
1258
- async function loadSessionFile(dir) {
1259
- const path = sessionPath(dir);
1260
- if (process.platform !== "win32") {
1261
- try {
1262
- const mode = (await stat2(path)).mode & 63;
1263
- if (mode !== 0) return null;
1264
- } catch (err) {
1265
- if (hasCode(err, "ENOENT")) return null;
1266
- throw sessionReadError(path, err);
1267
- }
1268
- }
1269
- let raw;
1270
- try {
1271
- raw = await readFile2(path, "utf8");
1272
- } catch (err) {
1273
- if (hasCode(err, "ENOENT")) return null;
1274
- throw sessionReadError(path, err);
1275
- }
1276
- let json;
1277
- try {
1278
- json = JSON.parse(raw);
1279
- } catch {
1280
- return null;
1281
- }
1282
- const parsed = SessionFileSchema.safeParse(json);
1283
- return parsed.success ? parsed.data : null;
1284
- }
1285
- function sessionReadError(path, cause) {
1286
- return new CliError("INTERNAL", `Could not read the session cache at ${path}`, {
1287
- fix: `Check file permissions on ${path}, or delete it to re-establish.`,
1288
- cause
1289
- });
1290
- }
1291
- async function saveSessionFile(dir, file) {
1292
- await writeFileAtomic(sessionPath(dir), `${JSON.stringify(file, null, 2)}
1293
- `, {
1294
- mode: 384,
1295
- dirMode: 448
1296
- });
1297
- }
1298
- function isSessionUsable(file, address, now) {
1299
- if (file.address !== address.toLowerCase()) return false;
1300
- if (file.scope !== SESSION_SCOPE) return false;
1301
- const expMs = Date.parse(file.exp);
1302
- if (!Number.isFinite(expMs)) return false;
1303
- return now < expMs - EXP_SKEW_MS;
1304
- }
1305
- function recoveryFor(code) {
1306
- switch (code) {
1307
- case "proof_expired":
1308
- return "resign";
1309
- case "session_expired":
1310
- case "proof_revoked":
1311
- case "insufficient_scope":
1312
- return "reestablish";
1313
- case "session_key_unbound":
1314
- return "fatal";
1315
- default:
1316
- return "fatal";
1317
- }
1318
- }
1319
- function createSessionKeyAuth(config, deps = {}) {
1320
- const now = deps.now ?? Date.now;
1321
- let cached = null;
1322
- let forceReestablish = false;
1323
- const ensure = async () => {
1324
- if (!forceReestablish && cached !== null && isSessionUsable(cached, config.signer.address, now())) {
1325
- return cached;
1326
- }
1327
- if (!forceReestablish) {
1328
- const onDisk = await loadSessionFile(config.dataDir);
1329
- if (onDisk !== null && isSessionUsable(onDisk, config.signer.address, now())) {
1330
- cached = onDisk;
1331
- return cached;
1332
- }
1333
- }
1334
- cached = await establishSession(config, deps);
1335
- forceReestablish = false;
1336
- return cached;
1337
- };
1338
- return {
1339
- async headersFor(req) {
1340
- const file = await ensure();
1341
- return signWithSession(file, req, deps);
1342
- },
1343
- async recover(code) {
1344
- const recovery = recoveryFor(code);
1345
- if (recovery === "fatal") return false;
1346
- if (recovery === "reestablish") {
1347
- cached = null;
1348
- forceReestablish = true;
1349
- }
1350
- return true;
1351
- }
1300
+ // src/lib/consent.ts
1301
+ var WRITE_CHAIN_ID = SESSION_CHAIN_ID;
1302
+ function resolveWriteAuth(opts) {
1303
+ const config = {
1304
+ signer: opts.signer,
1305
+ baseUrl: opts.baseUrl,
1306
+ chainId: WRITE_CHAIN_ID,
1307
+ dataDir: opts.dataDir,
1308
+ scope: opts.scope
1352
1309
  };
1310
+ const useSession = opts.useSession ?? opts.env.TENJIN_NO_SESSION !== "1";
1311
+ return useSession ? createSessionKeyAuth(config) : createSiwxAuth(config);
1353
1312
  }
1354
- function createSiwxAuth(config) {
1355
- return {
1356
- async headersFor() {
1357
- const header = await buildSiwxHeader(config.signer, {
1358
- baseUrl: config.baseUrl,
1359
- chainId: config.chainId
1360
- });
1361
- return { "SIGN-IN-WITH-X": header };
1362
- },
1363
- async recover(code) {
1364
- return code === "nonce_already_used" || code === "invalid_proof" || code === "proof_expired";
1365
- }
1366
- };
1313
+ function needsConfirmation(mode, warnCount) {
1314
+ return mode === "review" || mode === "auto" && warnCount > 0;
1367
1315
  }
1368
-
1369
- // src/commands/publish.ts
1370
- var WRITE_CHAIN_ID = "eip155:8453";
1371
- async function runPublish(args, ctx, deps = {}) {
1372
- const env = deps.env ?? process.env;
1373
- const cwd = deps.cwd ?? process.cwd();
1374
- if (args.mode !== void 0) parsePublishModeFlag(args.mode, "--mode");
1375
- const { raw, candidate } = await resolveSource(args, ctx.dataDir);
1376
- const { frontmatter, body } = parseFrontmatter(raw);
1377
- const status = resolveStatus(args, frontmatter);
1378
- const title = resolveTitle(frontmatter, body);
1379
- const tags = resolveTags(frontmatter);
1380
- const excerpt = expectString(frontmatter, "excerpt");
1381
- const handle = expectString(frontmatter, "handle");
1382
- const cardFlags = cardFlagsFrom(args);
1383
- if (candidate?.meta.question !== void 0 && cardFlags.question === void 0 && frontmatter.questionsAnswered === void 0) {
1384
- cardFlags.question = [candidate.meta.question];
1385
- }
1386
- const card = deriveCard(frontmatter, cardFlags);
1387
- const settings = await resolvePublishSettings({
1388
- dataDir: ctx.dataDir,
1389
- cwd,
1390
- ...args.mode !== void 0 ? { flag: args.mode } : {},
1391
- env
1392
- });
1316
+ function writeModeNotices(stderr, settings, env, defaultExplainer) {
1393
1317
  for (const warning of settings.warnings) {
1394
- ctx.io.stderr.write(`${warning}
1318
+ stderr.write(`${warning}
1395
1319
  `);
1396
1320
  }
1397
1321
  const envMode = env.TENJIN_PUBLISH_MODE;
1398
1322
  if (envMode !== void 0 && envMode.length > 0 && !PublishModeSchema.safeParse(envMode).success) {
1399
- ctx.io.stderr.write(
1323
+ stderr.write(
1400
1324
  `Ignoring invalid TENJIN_PUBLISH_MODE=${JSON.stringify(envMode)}; using ${settings.mode} (${settings.modeSource}).
1401
1325
  `
1402
1326
  );
1403
1327
  }
1404
1328
  if (settings.modeSource === "default") {
1405
- ctx.io.stderr.write(
1406
- `publish.mode: ${settings.mode} (default) - each publish asks you once. Set auto to publish clean scans automatically: tenjin config set publish.mode auto.
1329
+ stderr.write(
1330
+ `publish.mode: ${settings.mode} (default) - ${defaultExplainer}: tenjin config set publish.mode auto.
1407
1331
  `
1408
1332
  );
1409
1333
  }
1410
- const priceAtomic = resolvePrice(args, frontmatter, settings.defaultPriceAtomic);
1411
- const markerRoot = candidate !== void 0 ? candidate.meta.sourceProject : args.file !== void 0 ? dirname2(resolve2(cwd, args.file)) : cwd;
1412
- const scanContext = { projectMarkers: await deriveProjectMarkers(markerRoot) };
1413
- const findings = dedupeFindings([
1414
- ...scan(raw, scanContext),
1415
- ...scan(cardScanText(card), scanContext)
1416
- ]);
1417
- const blocking = findings.filter((f) => f.severity === "block");
1418
- const warns = findings.filter((f) => f.severity === "warn");
1419
- const eligibility = localCardEligibility(card);
1420
- const price = toMoney(priceAtomic);
1421
- if (blocking.length > 0) {
1422
- throw new CliError("PUBLISH_BLOCKED", blockMessage(blocking), {
1423
- fix: "Remove the secret from the file (it is never masked away by --yes), then re-run.",
1424
- details: {
1425
- mode: settings.mode,
1426
- findings: blocking.map(publicFinding),
1427
- price: { atomic: price.atomic, usd: price.usd }
1428
- }
1429
- });
1430
- }
1431
- const needsConfirm = settings.mode === "review" || settings.mode === "auto" && warns.length > 0;
1432
- if (needsConfirm && args.yes !== true) {
1433
- throw new CliError("NEEDS_CONFIRMATION", confirmMessage(warns.length, price.usd), {
1434
- fix: "Review the findings, then re-run with --yes (or resolve the source and re-run).",
1435
- details: {
1436
- mode: settings.mode,
1437
- price: { atomic: price.atomic, usd: price.usd },
1438
- findings: warns.map(publicFinding),
1439
- card: eligibility,
1440
- target: { status, titlePreview: sanitizeForTerminal(title ?? "(untitled draft)") }
1441
- }
1442
- });
1443
- }
1444
- const runtime = await resolveContextSettings(ctx);
1445
- const provider = resolveWalletProvider(
1446
- ctx,
1447
- deps.provider !== void 0 ? { provider: deps.provider } : {}
1448
- );
1449
- await describeWallet(provider);
1450
- const signer = await provider.getSigner();
1451
- const auth = resolveWriteAuth(signer, runtime.baseUrl, ctx.dataDir, deps, env);
1452
- const input = {
1453
- ...title !== void 0 ? { title } : {},
1454
- bodyMd: body,
1455
- ...excerpt !== void 0 ? { excerpt } : {},
1456
- ...tags !== void 0 ? { tags } : {},
1457
- priceAtomic,
1458
- ...handle !== void 0 ? { handle } : {},
1459
- status,
1460
- ...card !== void 0 ? { resource: card } : {}
1461
- };
1462
- const result = await publishPost(input, auth, {
1463
- baseUrl: runtime.baseUrl,
1464
- timeoutMs: ctx.flags.timeout,
1465
- ...deps.fetchImpl !== void 0 ? { fetchImpl: deps.fetchImpl } : {}
1466
- });
1467
- const candidateInfo = candidate !== void 0 ? await clearPublishedCandidate(ctx, candidate.id) : void 0;
1468
- return receipt(result, runtime.baseUrl, candidateInfo);
1469
1334
  }
1470
- async function clearPublishedCandidate(ctx, id) {
1471
- try {
1472
- if (await dropCandidate(ctx.dataDir, id)) return { id, cleared: true };
1473
- const warning = `Published, but candidate ${id} was already gone; nothing to clear.`;
1474
- ctx.io.stderr.write(`${warning}
1475
- `);
1476
- return { id, cleared: false, warning };
1477
- } catch (err) {
1478
- const warning = `Published successfully, but could not clear candidate ${id}: ${errorMessage(err)}. Remove it with \`tenjin candidate drop ${id}\`.`;
1479
- ctx.io.stderr.write(`${warning}
1480
- `);
1481
- return { id, cleared: false, warning };
1482
- }
1483
- }
1484
- function errorMessage(err) {
1485
- return err instanceof Error ? err.message : String(err);
1486
- }
1487
- async function resolveSource(args, dataDir) {
1488
- if (args.candidate !== void 0) {
1489
- if (args.file !== void 0) {
1490
- throw new CliError("USAGE", "Pass EITHER a file or --candidate, not both.", {
1491
- fix: "Publish a file with `tenjin publish post.md`, or a candidate with `--candidate <id>`."
1492
- });
1493
- }
1494
- if (!UUID_RE.test(args.candidate)) {
1495
- throw new CliError("USAGE", `Invalid candidate id: ${JSON.stringify(args.candidate)}`, {
1496
- fix: "Pass a candidate id from `tenjin candidate list`."
1497
- });
1498
- }
1499
- const record = await readCandidate(dataDir, args.candidate);
1500
- if (record === null) {
1501
- throw new CliError("USAGE", `Unknown candidate: ${JSON.stringify(args.candidate)}`, {
1502
- fix: "List parked candidates with `tenjin candidate list`."
1503
- });
1504
- }
1505
- return { raw: await readDraft(record), candidate: record };
1506
- }
1507
- if (args.file === void 0) {
1508
- throw new CliError("USAGE", "Nothing to publish.", {
1509
- fix: "Pass a Markdown file (`tenjin publish post.md`) or `--candidate <id>`."
1510
- });
1511
- }
1512
- return { raw: await readMarkdown(args.file) };
1513
- }
1514
- async function readDraft(record) {
1515
- try {
1516
- return await readFile3(record.draftPath, "utf8");
1517
- } catch (err) {
1518
- throw new CliError("INTERNAL", `Candidate ${record.id} is missing its draft.`, {
1519
- fix: `Drop it with \`tenjin candidate drop ${record.id}\` and re-add the draft.`,
1520
- cause: err
1521
- });
1522
- }
1523
- }
1524
- function receipt(result, baseUrl, candidateInfo) {
1525
- const price = toMoney(result.priceAtomic);
1526
- const missing = missingSentences(result.cacheEligibleMissing);
1527
- const cacheEligible = result.cacheEligible ?? false;
1528
- const deskUrl = `${trimSlash(baseUrl)}/desk`;
1529
- const title = sanitizeForTerminal(result.title);
1530
- const human = [
1531
- `Published ${title} (${result.status}) for ${price.usd} USD \u2192 ${result.url}`,
1532
- cacheEligible ? "Answer card is search-eligible." : missing.length > 0 ? `Answer card not search-eligible yet: ${missing.join(" ")}` : "Published as a browse-only document (no answer card).",
1533
- ...candidateInfo?.cleared === true ? [`Cleared candidate ${candidateInfo.id}.`] : [],
1534
- ...result.warnings.map((w) => `warning: ${sanitizeForTerminal(w)}`)
1535
- ];
1536
- return {
1537
- data: {
1538
- resourceId: result.resourceId,
1539
- url: result.url,
1540
- status: result.status,
1541
- price,
1542
- cacheEligible,
1543
- missing,
1544
- deskUrl,
1545
- ...candidateInfo !== void 0 ? { candidate: candidateInfo } : {},
1546
- ...result.warnings.length > 0 ? { warnings: result.warnings } : {}
1547
- },
1548
- humanLines: human
1549
- };
1550
- }
1551
- async function readMarkdown(file) {
1552
- try {
1553
- return await readFile3(file, "utf8");
1554
- } catch (err) {
1555
- throw new CliError("USAGE", `Could not read ${JSON.stringify(file)}`, {
1556
- fix: "Pass a path to a readable Markdown file, e.g. `tenjin publish post.md`.",
1557
- cause: err
1558
- });
1559
- }
1560
- }
1561
- function resolveStatus(args, frontmatter) {
1562
- if (args.draft === true) return "draft";
1563
- const fm = frontmatter.status;
1564
- if (fm === void 0) return "published";
1565
- if (typeof fm !== "string" || !PUBLISH_STATUSES.includes(fm)) {
1566
- throw new CliError("USAGE", `Invalid status ${JSON.stringify(fm)} in frontmatter.`, {
1567
- fix: "Use status: draft | published | unlisted, or pass --draft."
1568
- });
1569
- }
1570
- return fm;
1571
- }
1572
- function resolveTitle(frontmatter, body) {
1573
- const fm = frontmatter.title;
1574
- if (fm !== void 0) {
1575
- if (typeof fm !== "string") {
1576
- throw new CliError("USAGE", "frontmatter title must be a single string.");
1577
- }
1578
- return fm.trim();
1579
- }
1580
- const headings = headingOutline(body);
1581
- const h1 = headings.find((h) => h.level === 1) ?? headings[0];
1582
- return h1?.text;
1583
- }
1584
- function resolveTags(frontmatter) {
1585
- const fm = frontmatter.tags;
1586
- if (fm === void 0) return void 0;
1587
- if (typeof fm === "string") return [fm];
1588
- if (Array.isArray(fm)) return fm;
1589
- throw new CliError("USAGE", "frontmatter tags must be a list of strings.");
1590
- }
1591
- function expectString(frontmatter, key) {
1592
- const fm = frontmatter[key];
1593
- if (fm === void 0) return void 0;
1594
- if (typeof fm !== "string") {
1595
- throw new CliError("USAGE", `frontmatter ${key} must be a single string.`);
1596
- }
1597
- return fm;
1598
- }
1599
- function resolvePrice(args, frontmatter, defaultAtomic) {
1600
- if (args.price !== void 0) return parseUsdToAtomic(args.price);
1601
- const fm = frontmatter.price;
1602
- if (fm !== void 0) {
1603
- if (typeof fm !== "string") {
1604
- throw new CliError("USAGE", 'frontmatter price must be a decimal-USD string, e.g. "0.10".');
1605
- }
1606
- return parseUsdToAtomic(fm);
1607
- }
1608
- return defaultAtomic;
1609
- }
1610
- function cardFlagsFrom(args) {
1611
- return {
1612
- ...args.question !== void 0 && args.question.length > 0 ? { question: args.question } : {},
1613
- ...args.task !== void 0 && args.task.length > 0 ? { task: args.task } : {},
1614
- ...args.scope !== void 0 ? { scope: args.scope } : {},
1615
- ...args.exclusions !== void 0 ? { exclusions: args.exclusions } : {},
1616
- ...args.asOf !== void 0 ? { asOf: args.asOf } : {},
1617
- ...args.validUntil !== void 0 ? { validUntil: args.validUntil } : {},
1618
- ...args.artifactType !== void 0 ? { artifactType: args.artifactType } : {},
1619
- ...args.temporalMode !== void 0 ? { temporalMode: args.temporalMode } : {},
1620
- ...args.provenance !== void 0 ? { provenance: args.provenance } : {},
1621
- ...args.methodology !== void 0 ? { methodology: args.methodology } : {},
1622
- ...args.appliesTo !== void 0 && args.appliesTo.length > 0 ? { appliesTo: parseAppliesToFlags(args.appliesTo) } : {}
1623
- };
1624
- }
1625
- function resolveWriteAuth(signer, baseUrl, dataDir, deps, env) {
1626
- const config = { signer, baseUrl, chainId: WRITE_CHAIN_ID, dataDir };
1627
- const useSession = deps.useSession ?? env.TENJIN_NO_SESSION !== "1";
1628
- return useSession ? createSessionKeyAuth(config) : createSiwxAuth(config);
1629
- }
1630
- function cardScanText(card) {
1631
- if (card === void 0) return "";
1632
- const parts = [];
1633
- const add = (v) => {
1634
- if (v !== void 0) parts.push(v);
1635
- };
1636
- add(card.scope);
1637
- add(card.exclusions);
1638
- add(card.provenanceSummary);
1639
- add(card.methodologySummary);
1640
- add(card.mediaType);
1641
- add(card.maintenanceCadence);
1642
- add(card.asOf);
1643
- add(card.validUntil);
1644
- add(card.estimatedPaidInputCost);
1645
- if (card.questionsAnswered !== void 0) parts.push(...card.questionsAnswered);
1646
- if (card.tasksSupported !== void 0) parts.push(...card.tasksSupported);
1647
- if (card.appliesTo !== void 0) {
1648
- for (const values of Object.values(card.appliesTo)) parts.push(...values);
1649
- }
1650
- return parts.join("\n");
1335
+ function publicFinding(f) {
1336
+ return { check: f.check, severity: f.severity, line: f.line, excerpt: f.excerpt };
1651
1337
  }
1652
1338
  function dedupeFindings(findings) {
1653
1339
  const seen = /* @__PURE__ */ new Set();
@@ -1658,18 +1344,29 @@ function dedupeFindings(findings) {
1658
1344
  return true;
1659
1345
  });
1660
1346
  }
1661
- function publicFinding(f) {
1662
- return { check: f.check, severity: f.severity, line: f.line, excerpt: f.excerpt };
1663
- }
1664
- function blockMessage(blocking) {
1347
+ function describeFindings(blocking) {
1665
1348
  const checks = [...new Set(blocking.map((f) => f.check))].join(", ");
1666
- return `Publish blocked: the file contains ${blocking.length} secret finding(s) (${checks}).`;
1667
- }
1668
- function confirmMessage(warnCount, priceUsd) {
1669
- return warnCount > 0 ? `Publish needs confirmation: ${warnCount} finding(s), price $${priceUsd}.` : `Publish needs confirmation: price $${priceUsd}.`;
1349
+ return `${blocking.length} secret finding(s) (${checks})`;
1670
1350
  }
1671
1351
 
1672
1352
  export {
1673
- runPublish
1353
+ scan,
1354
+ deriveProjectMarkers,
1355
+ parseFrontmatter,
1356
+ deriveCard,
1357
+ parseAppliesToFlags,
1358
+ missingSentences,
1359
+ localCardEligibility,
1360
+ PUBLISH_STATUSES,
1361
+ publishPost,
1362
+ buildPostUpdateBody,
1363
+ getOwnPost,
1364
+ updatePost,
1365
+ resolveWriteAuth,
1366
+ needsConfirmation,
1367
+ writeModeNotices,
1368
+ publicFinding,
1369
+ dedupeFindings,
1370
+ describeFindings
1674
1371
  };
1675
- //# sourceMappingURL=chunk-PYNSGYBE.js.map
1372
+ //# sourceMappingURL=chunk-PLU3E63S.js.map