tenjin-cli 0.1.0-alpha.10 → 0.1.0-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +54 -30
- package/dist/{buy-FMDBZ4NY.js → buy-THMVOPUH.js} +17 -17
- package/dist/{chunk-AWQ6A4CI.js → chunk-2SDUV6MQ.js} +83 -72
- package/dist/chunk-2SDUV6MQ.js.map +1 -0
- package/dist/{chunk-DKQMJTG7.js → chunk-3GSZUADW.js} +14 -3
- package/dist/{chunk-DKQMJTG7.js.map → chunk-3GSZUADW.js.map} +1 -1
- package/dist/{chunk-5SE6BJRP.js → chunk-4NTZETIL.js} +25 -2
- package/dist/chunk-4NTZETIL.js.map +1 -0
- package/dist/{chunk-TWRYSGAW.js → chunk-4TCU3YRD.js} +8 -12
- package/dist/chunk-4TCU3YRD.js.map +1 -0
- package/dist/{chunk-7WDY4AXV.js → chunk-6BGYHARE.js} +18 -18
- package/dist/{chunk-UOJRKQTZ.js → chunk-6UY2UQMY.js} +3 -3
- package/dist/{chunk-36X2CA3N.js → chunk-ALUNME53.js} +1 -6
- package/dist/{chunk-36X2CA3N.js.map → chunk-ALUNME53.js.map} +1 -1
- package/dist/{chunk-GECSWJ7O.js → chunk-CNUXRXI2.js} +2 -2
- package/dist/chunk-E6YOODH7.js +913 -0
- package/dist/chunk-E6YOODH7.js.map +1 -0
- package/dist/{chunk-O6CAUZGY.js → chunk-EDVI7RRD.js} +3 -3
- package/dist/{chunk-MD7WGYYI.js → chunk-GKV6VZSZ.js} +9 -9
- package/dist/{chunk-JSSIMGQT.js → chunk-GUUAYR3K.js} +27 -26
- package/dist/chunk-GUUAYR3K.js.map +1 -0
- package/dist/{chunk-ZUAQRIVP.js → chunk-IAFYUFIC.js} +64 -25
- package/dist/chunk-IAFYUFIC.js.map +1 -0
- package/dist/{chunk-R2VLGNFD.js → chunk-IB63U6BM.js} +5 -1
- package/dist/chunk-IB63U6BM.js.map +1 -0
- package/dist/chunk-IXTENA2H.js +235 -0
- package/dist/chunk-IXTENA2H.js.map +1 -0
- package/dist/{chunk-BJJ5BQO6.js → chunk-JTYIX6OD.js} +3 -4
- package/dist/{chunk-5JXAZP7H.js → chunk-NUF2PKJO.js} +2 -1
- package/dist/{chunk-KYH4KPE5.js → chunk-O25VWJCG.js} +26 -26
- package/dist/{chunk-BUDHTDKL.js → chunk-OCN27NJV.js} +6 -6
- package/dist/{chunk-GSDZRCGF.js → chunk-OZHJ3FLR.js} +4 -4
- package/dist/{chunk-X3OOVSPX.js → chunk-RSBN67PA.js} +2 -4
- package/dist/{chunk-5JMKIDMM.js → chunk-SFGXAZ3M.js} +3 -3
- package/dist/{chunk-POF7HPRV.js → chunk-TDDN5GXR.js} +3 -3
- package/dist/{chunk-STND72DS.js → chunk-UFPJBS4C.js} +4 -4
- package/dist/chunk-UFPJBS4C.js.map +1 -0
- package/dist/{chunk-A6KCZPNQ.js → chunk-UY6CGULW.js} +2 -2
- package/dist/{chunk-A6KCZPNQ.js.map → chunk-UY6CGULW.js.map} +1 -1
- package/dist/{chunk-VRRLTZ2Q.js → chunk-VWY3U732.js} +40 -17
- package/dist/chunk-VWY3U732.js.map +1 -0
- package/dist/{chunk-6BZLSRNU.js → chunk-XWHXX2BI.js} +6 -6
- package/dist/{chunk-V4WWTZHZ.js → chunk-ZE7KOO7A.js} +7 -7
- package/dist/{cli-HK2XAWNW.js → cli-Y2HBOSGK.js} +57 -60
- package/dist/{cli-HK2XAWNW.js.map → cli-Y2HBOSGK.js.map} +1 -1
- package/dist/{config-LYCHHNAJ.js → config-WDGMZKHU.js} +4 -4
- package/dist/{doctor-2KPUQURC.js → doctor-CSIWKWM2.js} +9 -9
- package/dist/{edit-TST3OCKQ.js → edit-E7N6F3OY.js} +15 -15
- package/dist/fund-OKK627GL.js +38 -0
- package/dist/index.js +1 -1
- package/dist/{inspect-TPTHVPBB.js → inspect-573WHEV4.js} +13 -13
- package/dist/{install-PT3XEDJ6.js → install-SQAYMNQC.js} +88 -823
- package/dist/install-SQAYMNQC.js.map +1 -0
- package/dist/{outcome-NPNSF2Q7.js → outcome-W3KYGF23.js} +9 -9
- package/dist/{publish-XP5SEWST.js → publish-N5U4XYVA.js} +16 -17
- package/dist/{read-D4VXRWOG.js → read-PJ7Z6UGF.js} +18 -18
- package/dist/{run-3IPGEXW7.js → run-FSO3MMXN.js} +71 -90
- package/dist/{run-3IPGEXW7.js.map → run-FSO3MMXN.js.map} +1 -1
- package/dist/{search-YOBD6VDI.js → search-ZWOP4EGK.js} +10 -11
- package/dist/{send-BWNP6WN4.js → send-F34ZDXDZ.js} +5 -5
- package/dist/{session-GZEZBOMI.js → session-4N4ZT3AH.js} +13 -13
- package/dist/{skill-heal-OK6YALW6.js → skill-heal-XBEK272G.js} +3 -3
- package/dist/uninstall-BTKPHPDL.js +68 -0
- package/dist/uninstall-BTKPHPDL.js.map +1 -0
- package/dist/{wallet-YEGQBWWL.js → wallet-UL4P2JRO.js} +3 -3
- package/dist/{wallet-5RHDFPN2.js → wallet-WJ6UP5OU.js} +5 -5
- package/docs/agent-permissions.md +42 -29
- package/package.json +1 -1
- package/skills/tenjin-publish/SKILL.md +49 -36
- package/skills/tenjin-search/SKILL.md +34 -28
- package/dist/candidate-7LAELUQD.js +0 -23
- package/dist/chunk-2GSRYTZS.js +0 -127
- package/dist/chunk-2GSRYTZS.js.map +0 -1
- package/dist/chunk-5SE6BJRP.js.map +0 -1
- package/dist/chunk-AWQ6A4CI.js.map +0 -1
- package/dist/chunk-JSSIMGQT.js.map +0 -1
- package/dist/chunk-R2VLGNFD.js.map +0 -1
- package/dist/chunk-STND72DS.js.map +0 -1
- package/dist/chunk-TEL27PR5.js +0 -124
- package/dist/chunk-TEL27PR5.js.map +0 -1
- package/dist/chunk-TWRYSGAW.js.map +0 -1
- package/dist/chunk-VRRLTZ2Q.js.map +0 -1
- package/dist/chunk-ZUAQRIVP.js.map +0 -1
- package/dist/install-PT3XEDJ6.js.map +0 -1
- /package/dist/{buy-FMDBZ4NY.js.map → buy-THMVOPUH.js.map} +0 -0
- /package/dist/{chunk-7WDY4AXV.js.map → chunk-6BGYHARE.js.map} +0 -0
- /package/dist/{chunk-UOJRKQTZ.js.map → chunk-6UY2UQMY.js.map} +0 -0
- /package/dist/{chunk-GECSWJ7O.js.map → chunk-CNUXRXI2.js.map} +0 -0
- /package/dist/{chunk-O6CAUZGY.js.map → chunk-EDVI7RRD.js.map} +0 -0
- /package/dist/{chunk-MD7WGYYI.js.map → chunk-GKV6VZSZ.js.map} +0 -0
- /package/dist/{chunk-BJJ5BQO6.js.map → chunk-JTYIX6OD.js.map} +0 -0
- /package/dist/{chunk-5JXAZP7H.js.map → chunk-NUF2PKJO.js.map} +0 -0
- /package/dist/{chunk-KYH4KPE5.js.map → chunk-O25VWJCG.js.map} +0 -0
- /package/dist/{chunk-BUDHTDKL.js.map → chunk-OCN27NJV.js.map} +0 -0
- /package/dist/{chunk-GSDZRCGF.js.map → chunk-OZHJ3FLR.js.map} +0 -0
- /package/dist/{chunk-X3OOVSPX.js.map → chunk-RSBN67PA.js.map} +0 -0
- /package/dist/{chunk-5JMKIDMM.js.map → chunk-SFGXAZ3M.js.map} +0 -0
- /package/dist/{chunk-POF7HPRV.js.map → chunk-TDDN5GXR.js.map} +0 -0
- /package/dist/{chunk-6BZLSRNU.js.map → chunk-XWHXX2BI.js.map} +0 -0
- /package/dist/{chunk-V4WWTZHZ.js.map → chunk-ZE7KOO7A.js.map} +0 -0
- /package/dist/{candidate-7LAELUQD.js.map → config-WDGMZKHU.js.map} +0 -0
- /package/dist/{config-LYCHHNAJ.js.map → doctor-CSIWKWM2.js.map} +0 -0
- /package/dist/{doctor-2KPUQURC.js.map → edit-E7N6F3OY.js.map} +0 -0
- /package/dist/{edit-TST3OCKQ.js.map → fund-OKK627GL.js.map} +0 -0
- /package/dist/{inspect-TPTHVPBB.js.map → inspect-573WHEV4.js.map} +0 -0
- /package/dist/{outcome-NPNSF2Q7.js.map → outcome-W3KYGF23.js.map} +0 -0
- /package/dist/{publish-XP5SEWST.js.map → publish-N5U4XYVA.js.map} +0 -0
- /package/dist/{read-D4VXRWOG.js.map → read-PJ7Z6UGF.js.map} +0 -0
- /package/dist/{search-YOBD6VDI.js.map → search-ZWOP4EGK.js.map} +0 -0
- /package/dist/{send-BWNP6WN4.js.map → send-F34ZDXDZ.js.map} +0 -0
- /package/dist/{session-GZEZBOMI.js.map → session-4N4ZT3AH.js.map} +0 -0
- /package/dist/{skill-heal-OK6YALW6.js.map → skill-heal-XBEK272G.js.map} +0 -0
- /package/dist/{wallet-5RHDFPN2.js.map → wallet-UL4P2JRO.js.map} +0 -0
- /package/dist/{wallet-YEGQBWWL.js.map → wallet-WJ6UP5OU.js.map} +0 -0
package/README.md
CHANGED
|
@@ -38,7 +38,7 @@ offer to publish the finding so the next agent pays us.
|
|
|
38
38
|
npm i -g tenjin-cli
|
|
39
39
|
tenjin install # wires the skills and hooks, settles the setup decisions, runs doctor
|
|
40
40
|
tenjin wallet show # your wallet address; `tenjin wallet balance` for USDC
|
|
41
|
-
|
|
41
|
+
tenjin fund 5 # card checkout via Coinbase Onramp; or send USDC on Base yourself
|
|
42
42
|
tenjin search "what actually changed in <library> v3's public API"
|
|
43
43
|
```
|
|
44
44
|
|
|
@@ -63,6 +63,7 @@ on Base for gas). Searching and free pieces cost nothing.
|
|
|
63
63
|
| Command | Purpose |
|
|
64
64
|
| --------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
|
|
65
65
|
| `tenjin install` | Wire the harness skills, hooks and permissions, settle the setup decisions, then run doctor over the result |
|
|
66
|
+
| `tenjin uninstall` | Remove everything install wrote; nothing under `~/.tenjin` is touched |
|
|
66
67
|
| `tenjin doctor` | Environment, API reachability, contract, skill-wiring, and wallet checks |
|
|
67
68
|
| `tenjin config [get\|set]` | Spend policy, publish consent, and the hook toggles |
|
|
68
69
|
| `tenjin wallet [create\|show\|balance]` | Local Base wallet; the key never leaves the machine |
|
|
@@ -74,7 +75,7 @@ on Base for gas). Searching and free pieces cost nothing.
|
|
|
74
75
|
| `tenjin outcome` | Report how a search ended; this is the signal the marketplace learns from |
|
|
75
76
|
| `tenjin publish [file]` | Publish Markdown with an optional answer card, gated by a local scan and your consent mode |
|
|
76
77
|
| `tenjin edit <postId>` | Show one of your posts and its card, or merge-update it |
|
|
77
|
-
| `tenjin
|
|
78
|
+
| `tenjin fund [amountUsd]` | Card-fund THIS wallet via Coinbase Onramp: prints and opens a checkout link, then waits for the USDC |
|
|
78
79
|
| `tenjin send <amount> usdc <to>` | **Escape hatch:** move USDC on Base out of the agent wallet |
|
|
79
80
|
| `tenjin mcp` | Local stdio MCP server over the same command cores |
|
|
80
81
|
|
|
@@ -130,13 +131,26 @@ value. That is why `--no-hooks` and `--search-hooks off` differ.
|
|
|
130
131
|
| `--search-hooks` | `auto\|remind\|off` | ask, else `auto` | Register the hooks in this mode; persists `hooks.searchMode` |
|
|
131
132
|
| `--no-hooks` | — | hooks on | Register no hooks this run; writes no config |
|
|
132
133
|
| `--no-wallet` | — | wallet on | Create no wallet |
|
|
133
|
-
| `--no-claude-md` | — | nudge on | Write no CLAUDE.md nudge |
|
|
134
134
|
|
|
135
|
-
A default run settles all
|
|
135
|
+
A default run settles all four: the allowlist, the hooks, the wallet,
|
|
136
136
|
and `publish.mode` (headless persists `auto`, the mode the interactive select
|
|
137
|
-
recommends). The flags are the opt-outs. (`--allow-free-verbs
|
|
138
|
-
parse as no-ops so older docs and scripts keep working; they
|
|
139
|
-
`--help`.)
|
|
137
|
+
recommends). The flags are the opt-outs. (`--allow-free-verbs`, `--claude-md` and
|
|
138
|
+
`--no-claude-md` still parse as no-ops so older docs and scripts keep working; they
|
|
139
|
+
are hidden from `--help`.)
|
|
140
|
+
|
|
141
|
+
### `tenjin uninstall`
|
|
142
|
+
|
|
143
|
+
Removes exactly what `install` wrote and nothing else: the skills, the hook
|
|
144
|
+
scripts, our hook entries and permission rules in `~/.claude/settings.json`, and
|
|
145
|
+
the pointer line older versions left in `CLAUDE.md`/`AGENTS.md`. Ownership is
|
|
146
|
+
checked before every removal — a skill whose frontmatter names something else, a
|
|
147
|
+
hook entry pointing at another tool's script, and a permission rule we did not
|
|
148
|
+
write are all left alone.
|
|
149
|
+
|
|
150
|
+
It never touches anything under `~/.tenjin` — your **wallet**, **config**,
|
|
151
|
+
**library** and **search history**, plus anything an older version left in
|
|
152
|
+
`~/.tenjin/candidates` — and it prints that list every run. Safe to run twice, or on
|
|
153
|
+
a machine that never installed: it reports what it found and exits 0.
|
|
140
154
|
|
|
141
155
|
### `tenjin search <question>`
|
|
142
156
|
|
|
@@ -167,6 +181,19 @@ endpoint, so `buy <url>` can.
|
|
|
167
181
|
| `--max-price` | decimal USD | none | Hard price cap; never bypassed by `--yes` | buy |
|
|
168
182
|
| `--yes` | — | off | Clear the interactive confirm only, not the cap | buy |
|
|
169
183
|
|
|
184
|
+
### `tenjin fund [amountUsd]`
|
|
185
|
+
|
|
186
|
+
| Flag | Values | Default | Effect |
|
|
187
|
+
| ----------- | ------ | ------------- | ------------------------------------------------- |
|
|
188
|
+
| `--no-open` | — | open at a TTY | Print the checkout link without opening a browser |
|
|
189
|
+
| `--no-wait` | — | wait at a TTY | Return once the link is issued instead of polling |
|
|
190
|
+
|
|
191
|
+
Both default to off when stdout is not a TTY, so a piped or `--json` run neither
|
|
192
|
+
opens a browser nor blocks. The checkout link goes to stderr as soon as it is
|
|
193
|
+
minted, on every surface, because it is single-use and expires in about five
|
|
194
|
+
minutes. `pollStatus` in the envelope reports the outcome: `skipped`,
|
|
195
|
+
`unavailable`, `timed-out`, or `arrived`.
|
|
196
|
+
|
|
170
197
|
### `tenjin session start`
|
|
171
198
|
|
|
172
199
|
| Flag | Values | Default | Effect |
|
|
@@ -187,9 +214,10 @@ endpoint, so `buy <url>` can.
|
|
|
187
214
|
|
|
188
215
|
| Flag | Values | Default | Effect |
|
|
189
216
|
| ----------------- | --------------------------------- | ---------------------- | ---------------------------------------------------------------------- |
|
|
190
|
-
| `--
|
|
217
|
+
| `--search-id` | uuid | none | The search this file answers; closes its loop, prefills its question |
|
|
191
218
|
| `--draft` | — | off | Save privately instead of publishing |
|
|
192
219
|
| `--price` | decimal USD | `publish.defaultPrice` | Post price |
|
|
220
|
+
| `--excerpt` | text (≤500 chars) | derived from the body | The public preview a non-buyer reads |
|
|
193
221
|
| `--mode` | `review\|auto\|full-auto` | `publish.mode` | Consent mode for this run |
|
|
194
222
|
| `--yes` | — | off | Clear warning findings and the review confirm |
|
|
195
223
|
| `--question` | text | none | A question this piece answers, repeatable |
|
|
@@ -227,17 +255,15 @@ so an omitted field is kept. It takes every card flag `publish` takes
|
|
|
227
255
|
guard (the API offers no `If-Match`), so a web-panel edit landing in between can be
|
|
228
256
|
overwritten.
|
|
229
257
|
|
|
230
|
-
### `tenjin
|
|
258
|
+
### `tenjin wallet create`, `tenjin send`
|
|
231
259
|
|
|
232
|
-
| Flag
|
|
233
|
-
|
|
|
234
|
-
| `--
|
|
235
|
-
| `--
|
|
236
|
-
| `--replace` | — | off | Archive the existing wallet first, then create a new one | `wallet create` |
|
|
237
|
-
| `--yes` | — | off | Skip the confirm; required to send when not at a TTY | `send` |
|
|
260
|
+
| Flag | Values | Default | Effect | Command |
|
|
261
|
+
| ----------- | ------ | ------- | -------------------------------------------------------- | --------------- |
|
|
262
|
+
| `--replace` | — | off | Archive the existing wallet first, then create a new one | `wallet create` |
|
|
263
|
+
| `--yes` | — | off | Skip the confirm; required to send when not at a TTY | `send` |
|
|
238
264
|
|
|
239
|
-
`doctor`, `inspect`, `config`, `wallet show`, `wallet balance
|
|
240
|
-
|
|
265
|
+
`doctor`, `inspect`, `config`, `wallet show`, `wallet balance` and `mcp` take
|
|
266
|
+
only the global flags.
|
|
241
267
|
|
|
242
268
|
## Configuration
|
|
243
269
|
|
|
@@ -280,7 +306,7 @@ budget and the 5s harness kill below.
|
|
|
280
306
|
bought and attributed and a miss stays visible to the reminder below. A miss, a
|
|
281
307
|
timeout, a dead network, or a response that fails validation exits silently.
|
|
282
308
|
- **Stop** checks locally, with no network call, for a MISS from the last eight
|
|
283
|
-
hours that no outcome report
|
|
309
|
+
hours that no outcome report or publish has closed. A
|
|
284
310
|
deliberate `tenjin search` that went unanswered is named on its own line with
|
|
285
311
|
its `searchId`. Searches the WebSearch hook ran are batched into one line, at
|
|
286
312
|
most three, because nobody vetted those questions for the marketplace and only
|
|
@@ -339,6 +365,7 @@ array of `~/.claude/settings.json`:
|
|
|
339
365
|
|
|
340
366
|
```
|
|
341
367
|
Bash(tenjin search:*)
|
|
368
|
+
Bash(tenjin fund:*)
|
|
342
369
|
Bash(tenjin inspect:*)
|
|
343
370
|
Bash(tenjin read:*)
|
|
344
371
|
Bash(tenjin outcome:*)
|
|
@@ -346,7 +373,6 @@ Bash(tenjin doctor:*)
|
|
|
346
373
|
Bash(tenjin wallet show:*)
|
|
347
374
|
Bash(tenjin wallet balance:*)
|
|
348
375
|
Bash(tenjin config get:*)
|
|
349
|
-
Bash(tenjin candidate list:*)
|
|
350
376
|
```
|
|
351
377
|
|
|
352
378
|
Three tiers:
|
|
@@ -399,9 +425,9 @@ decision:
|
|
|
399
425
|
A run with nobody to ask still produces a working install. Everything is on by
|
|
400
426
|
default on both paths, each with an opt-out flag: the permission allowlist
|
|
401
427
|
(`--no-allow-free-verbs`), the search hooks (`--no-hooks`, or `--search-hooks
|
|
402
|
-
off` to make it durable), the
|
|
403
|
-
|
|
404
|
-
|
|
428
|
+
off` to make it durable), and the wallet (`--no-wallet`). Everything written is
|
|
429
|
+
disclosed in the output with its undo, and `tenjin uninstall` reverses all of it
|
|
430
|
+
in one command.
|
|
405
431
|
|
|
406
432
|
The wallet is created headlessly too, because `buy` and publishing back after a
|
|
407
433
|
MISS both need one and a walletless install stops at the first useful thing an
|
|
@@ -438,12 +464,10 @@ Where the three skills land:
|
|
|
438
464
|
- **Nothing detected**: the installer falls back to `~/.agents/skills/`, so a
|
|
439
465
|
harness installed later still finds the skills.
|
|
440
466
|
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
marked with an HTML comment, so a re-run refreshes a drifted copy in place and
|
|
446
|
-
never duplicates it; deleting that line is the undo.
|
|
467
|
+
`install` writes nothing into your `CLAUDE.md` or `AGENTS.md`. A harness loads
|
|
468
|
+
every skill's frontmatter description at session start, so that is already the
|
|
469
|
+
trigger surface, and a pointer line only duplicated it. Earlier versions did write
|
|
470
|
+
one; an install that finds it removes it and says so.
|
|
447
471
|
|
|
448
472
|
The three skills:
|
|
449
473
|
|
|
@@ -558,9 +582,9 @@ server the CLI ships (see [Local stdio MCP server](#local-stdio-mcp-server)).
|
|
|
558
582
|
|
|
559
583
|
`tenjin mcp` runs a local MCP server over stdio backed by the same command cores
|
|
560
584
|
as the CLI (`search`, `inspect`, `buy`, `outcome`, `publish`, `edit`,
|
|
561
|
-
`
|
|
585
|
+
`wallet`, and `fund`), in-process, no shelling out. It exposes eight tools
|
|
562
586
|
(`tenjin_search`, `tenjin_inspect`, `tenjin_buy`, `tenjin_outcome`,
|
|
563
|
-
`tenjin_publish`, `tenjin_edit`, `
|
|
587
|
+
`tenjin_publish`, `tenjin_edit`, `tenjin_wallet`, `tenjin_fund`), each
|
|
564
588
|
returning the machine JSON envelope as `structuredContent` with a short text
|
|
565
589
|
summary. The consent gates carry over exactly: the spend policy gates
|
|
566
590
|
`tenjin_buy`, `publish.mode` gates `tenjin_publish` and `tenjin_edit` (the client
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
runBuy
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-O25VWJCG.js";
|
|
5
|
+
import "./chunk-QW2Q2KAH.js";
|
|
6
|
+
import "./chunk-OZHJ3FLR.js";
|
|
7
|
+
import "./chunk-ZE7KOO7A.js";
|
|
7
8
|
import "./chunk-SGK2B724.js";
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-6UY2UQMY.js";
|
|
10
|
+
import "./chunk-4NTZETIL.js";
|
|
11
|
+
import "./chunk-EDVI7RRD.js";
|
|
12
|
+
import "./chunk-6BGYHARE.js";
|
|
10
13
|
import "./chunk-S5RYMCV6.js";
|
|
11
14
|
import "./chunk-POJRB2AE.js";
|
|
12
15
|
import "./chunk-YLYINX2H.js";
|
|
13
|
-
import "./chunk-QW2Q2KAH.js";
|
|
14
16
|
import "./chunk-MJZZTKCC.js";
|
|
15
|
-
import "./chunk-
|
|
16
|
-
import "./chunk-
|
|
17
|
-
import "./chunk-
|
|
18
|
-
import "./chunk-O6CAUZGY.js";
|
|
19
|
-
import "./chunk-5SE6BJRP.js";
|
|
20
|
-
import "./chunk-DKQMJTG7.js";
|
|
21
|
-
import "./chunk-A6KCZPNQ.js";
|
|
17
|
+
import "./chunk-CNUXRXI2.js";
|
|
18
|
+
import "./chunk-3GSZUADW.js";
|
|
19
|
+
import "./chunk-UY6CGULW.js";
|
|
22
20
|
import "./chunk-PZSUWDF2.js";
|
|
23
|
-
import "./chunk-
|
|
24
|
-
import "./chunk-
|
|
21
|
+
import "./chunk-Y7ERTA7D.js";
|
|
22
|
+
import "./chunk-KZAAWQNP.js";
|
|
23
|
+
import "./chunk-IB63U6BM.js";
|
|
24
|
+
import "./chunk-JTYIX6OD.js";
|
|
25
25
|
import "./chunk-FKSAUOJU.js";
|
|
26
|
-
import "./chunk-
|
|
26
|
+
import "./chunk-ALUNME53.js";
|
|
27
27
|
import "./chunk-ZQIQ55KK.js";
|
|
28
28
|
import "./chunk-P74I3WH4.js";
|
|
29
29
|
import "./chunk-2I4QTOLB.js";
|
|
@@ -41,4 +41,4 @@ import "./chunk-ZXTAQYNA.js";
|
|
|
41
41
|
export {
|
|
42
42
|
runBuy
|
|
43
43
|
};
|
|
44
|
-
//# sourceMappingURL=buy-
|
|
44
|
+
//# sourceMappingURL=buy-THMVOPUH.js.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
|
+
EXCERPT_MAX_LENGTH,
|
|
3
4
|
PUBLISH_STATUSES,
|
|
4
5
|
dedupeFindings,
|
|
5
6
|
deriveCard,
|
|
@@ -15,37 +16,35 @@ import {
|
|
|
15
16
|
resolveWriteAuth,
|
|
16
17
|
scan,
|
|
17
18
|
writeModeNotices
|
|
18
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-IAFYUFIC.js";
|
|
19
20
|
import {
|
|
20
21
|
headingOutline
|
|
21
22
|
} from "./chunk-SGK2B724.js";
|
|
23
|
+
import {
|
|
24
|
+
loadSearches,
|
|
25
|
+
markSearchResolved
|
|
26
|
+
} from "./chunk-4NTZETIL.js";
|
|
22
27
|
import {
|
|
23
28
|
describeWallet,
|
|
24
29
|
resolveWalletProvider
|
|
25
|
-
} from "./chunk-
|
|
26
|
-
import {
|
|
27
|
-
dropCandidate,
|
|
28
|
-
readCandidate
|
|
29
|
-
} from "./chunk-TEL27PR5.js";
|
|
30
|
-
import {
|
|
31
|
-
markSearchResolved
|
|
32
|
-
} from "./chunk-5SE6BJRP.js";
|
|
30
|
+
} from "./chunk-CNUXRXI2.js";
|
|
33
31
|
import {
|
|
34
32
|
trimSlash
|
|
35
33
|
} from "./chunk-PZSUWDF2.js";
|
|
36
34
|
import {
|
|
37
|
-
sanitizeForTerminal
|
|
38
|
-
|
|
35
|
+
sanitizeForTerminal,
|
|
36
|
+
sanitizeWireText
|
|
37
|
+
} from "./chunk-IB63U6BM.js";
|
|
39
38
|
import {
|
|
40
39
|
resolveContextSettings,
|
|
41
40
|
resolvePublishSettings
|
|
42
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-JTYIX6OD.js";
|
|
43
42
|
import {
|
|
44
43
|
UUID_RE,
|
|
45
44
|
parsePublishModeFlag,
|
|
46
45
|
parseUsdToAtomic,
|
|
47
46
|
toMoney
|
|
48
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-ALUNME53.js";
|
|
49
48
|
import {
|
|
50
49
|
CliError
|
|
51
50
|
} from "./chunk-PZRAAAY2.js";
|
|
@@ -57,16 +56,26 @@ async function runPublish(args, ctx, deps = {}) {
|
|
|
57
56
|
const env = deps.env ?? process.env;
|
|
58
57
|
const cwd = deps.cwd ?? process.cwd();
|
|
59
58
|
if (args.mode !== void 0) parsePublishModeFlag(args.mode, "--mode");
|
|
60
|
-
|
|
59
|
+
validateSearchId(args);
|
|
60
|
+
const raw = await readSource(args);
|
|
61
|
+
const storedSearch = args.searchId !== void 0 ? (await loadSearches(ctx.dataDir)).find((s) => s.searchId === args.searchId) ?? null : null;
|
|
61
62
|
const { frontmatter, body } = parseFrontmatter(raw);
|
|
62
63
|
const status = resolveStatus(args, frontmatter);
|
|
63
64
|
const title = resolveTitle(frontmatter, body);
|
|
64
65
|
const tags = resolveTags(frontmatter);
|
|
65
|
-
const excerpt =
|
|
66
|
+
const excerpt = resolveExcerpt(args, frontmatter);
|
|
66
67
|
const handle = expectString(frontmatter, "handle");
|
|
67
68
|
const cardFlags = cardFlagsFrom(args);
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
const wanted = storedSearch?.question;
|
|
70
|
+
const prefillQuestion = wanted === void 0 ? void 0 : cardQuestion(wanted);
|
|
71
|
+
const roomForPrefill = cardFlags.question === void 0 && frontmatter.questionsAnswered === void 0;
|
|
72
|
+
if (prefillQuestion !== void 0 && roomForPrefill) cardFlags.question = [prefillQuestion];
|
|
73
|
+
const prefill = wanted === void 0 || !roomForPrefill ? "none" : prefillQuestion !== void 0 ? "applied" : "dropped-too-long";
|
|
74
|
+
if (prefill === "dropped-too-long") {
|
|
75
|
+
ctx.io.stderr.write(
|
|
76
|
+
`The searched question is longer than ${CARD_QUESTION_MAX} characters, so it was not added to the answer card; pass --question to set a shorter one.
|
|
77
|
+
`
|
|
78
|
+
);
|
|
70
79
|
}
|
|
71
80
|
const card = deriveCard(frontmatter, cardFlags);
|
|
72
81
|
const settings = await resolvePublishSettings({
|
|
@@ -82,7 +91,7 @@ async function runPublish(args, ctx, deps = {}) {
|
|
|
82
91
|
"each publish asks you once. Set auto to publish clean scans automatically"
|
|
83
92
|
);
|
|
84
93
|
const priceAtomic = resolvePrice(args, frontmatter, settings.defaultPriceAtomic);
|
|
85
|
-
const markerRoot =
|
|
94
|
+
const markerRoot = args.file !== void 0 ? dirname(resolve(cwd, args.file)) : cwd;
|
|
86
95
|
const scanContext = { projectMarkers: await deriveProjectMarkers(markerRoot) };
|
|
87
96
|
const findings = dedupeFindings([
|
|
88
97
|
...scan(raw, scanContext),
|
|
@@ -145,67 +154,51 @@ async function runPublish(args, ctx, deps = {}) {
|
|
|
145
154
|
timeoutMs: ctx.flags.timeout,
|
|
146
155
|
...deps.fetchImpl !== void 0 ? { fetchImpl: deps.fetchImpl } : {}
|
|
147
156
|
});
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
|
|
157
|
+
const parksPrivately = status === "draft";
|
|
158
|
+
let searchInfo;
|
|
159
|
+
if (args.searchId !== void 0) {
|
|
160
|
+
searchInfo = await closeNamedSearch(ctx, args.searchId, storedSearch, parksPrivately, prefill);
|
|
151
161
|
}
|
|
152
|
-
return receipt(result, runtime.baseUrl,
|
|
162
|
+
return receipt(result, runtime.baseUrl, searchInfo);
|
|
153
163
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
return { id, cleared: false, warning };
|
|
161
|
-
} catch (err) {
|
|
162
|
-
const warning = `Published successfully, but could not clear candidate ${id}: ${errorMessage(err)}. Remove it with \`tenjin candidate drop ${id}\`.`;
|
|
163
|
-
ctx.io.stderr.write(`${warning}
|
|
164
|
-
`);
|
|
165
|
-
return { id, cleared: false, warning };
|
|
164
|
+
function validateSearchId(args) {
|
|
165
|
+
if (args.searchId === void 0) return;
|
|
166
|
+
if (!UUID_RE.test(args.searchId)) {
|
|
167
|
+
throw new CliError("USAGE", `Invalid --search-id: ${JSON.stringify(args.searchId)}.`, {
|
|
168
|
+
fix: "Pass the searchId from a prior `tenjin search` (a uuid)."
|
|
169
|
+
});
|
|
166
170
|
}
|
|
167
171
|
}
|
|
168
|
-
function
|
|
169
|
-
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
}
|
|
178
|
-
if (!UUID_RE.test(args.candidate)) {
|
|
179
|
-
throw new CliError("USAGE", `Invalid candidate id: ${JSON.stringify(args.candidate)}`, {
|
|
180
|
-
fix: "Pass a candidate id from `tenjin candidate list`."
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
const record = await readCandidate(dataDir, args.candidate);
|
|
184
|
-
if (record === null) {
|
|
185
|
-
throw new CliError("USAGE", `Unknown candidate: ${JSON.stringify(args.candidate)}`, {
|
|
186
|
-
fix: "List parked candidates with `tenjin candidate list`."
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
return { raw: await readDraft(record), candidate: record };
|
|
172
|
+
async function closeNamedSearch(ctx, searchId, stored, parksPrivately, prefill) {
|
|
173
|
+
const open = (reason) => {
|
|
174
|
+
ctx.io.stderr.write(`${reason}
|
|
175
|
+
`);
|
|
176
|
+
return { id: searchId, closed: false, prefill };
|
|
177
|
+
};
|
|
178
|
+
if (parksPrivately) return open(`Saved as a draft, so search ${searchId} stays open.`);
|
|
179
|
+
if (stored === null) {
|
|
180
|
+
return open(`Published, but search ${searchId} is not in the local store.`);
|
|
190
181
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
182
|
+
const outcome = await markSearchResolved(ctx.dataDir, searchId, "publish");
|
|
183
|
+
if (outcome === "failed") {
|
|
184
|
+
return open(
|
|
185
|
+
`Published, but the local record for search ${searchId} could not be updated, so the open-loop reminder may repeat. Close it with \`tenjin outcome --search-id ${searchId} --status used\`.`
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
if (outcome === "not-found") {
|
|
189
|
+
return open(`Published, but search ${searchId} is no longer in the local store.`);
|
|
195
190
|
}
|
|
196
|
-
return {
|
|
191
|
+
return { id: searchId, closed: true, prefill };
|
|
197
192
|
}
|
|
198
|
-
async function
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
throw new CliError("INTERNAL", `Candidate ${record.id} is missing its draft.`, {
|
|
203
|
-
fix: `Drop it with \`tenjin candidate drop ${record.id}\` and re-add the draft.`,
|
|
204
|
-
cause: err
|
|
193
|
+
async function readSource(args) {
|
|
194
|
+
if (args.file === void 0) {
|
|
195
|
+
throw new CliError("USAGE", "Nothing to publish.", {
|
|
196
|
+
fix: "Pass a Markdown file, e.g. `tenjin publish post.md`."
|
|
205
197
|
});
|
|
206
198
|
}
|
|
199
|
+
return readMarkdown(args.file);
|
|
207
200
|
}
|
|
208
|
-
function receipt(result, baseUrl,
|
|
201
|
+
function receipt(result, baseUrl, searchInfo) {
|
|
209
202
|
const price = toMoney(result.priceAtomic);
|
|
210
203
|
const missing = missingSentences(result.cacheEligibleMissing).map(sanitizeForTerminal);
|
|
211
204
|
const cacheEligible = result.cacheEligible ?? false;
|
|
@@ -214,7 +207,7 @@ function receipt(result, baseUrl, candidateInfo) {
|
|
|
214
207
|
const human = [
|
|
215
208
|
`Published ${title} (${sanitizeForTerminal(result.status)}) for ${price.usd} USD \u2192 ${sanitizeForTerminal(result.url)}`,
|
|
216
209
|
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).",
|
|
217
|
-
...
|
|
210
|
+
...searchInfo?.closed === true ? [`Closed the loop on search ${searchInfo.id}.`] : [],
|
|
218
211
|
...result.warnings.map((w) => `warning: ${sanitizeForTerminal(w)}`)
|
|
219
212
|
];
|
|
220
213
|
return {
|
|
@@ -226,7 +219,7 @@ function receipt(result, baseUrl, candidateInfo) {
|
|
|
226
219
|
cacheEligible,
|
|
227
220
|
missing,
|
|
228
221
|
deskUrl,
|
|
229
|
-
...
|
|
222
|
+
...searchInfo !== void 0 ? { search: searchInfo } : {},
|
|
230
223
|
...result.warnings.length > 0 ? { warnings: result.warnings } : {}
|
|
231
224
|
},
|
|
232
225
|
humanLines: human
|
|
@@ -265,6 +258,24 @@ function resolveTitle(frontmatter, body) {
|
|
|
265
258
|
const h1 = headings.find((h) => h.level === 1) ?? headings[0];
|
|
266
259
|
return h1?.text;
|
|
267
260
|
}
|
|
261
|
+
var CARD_QUESTION_MAX = 200;
|
|
262
|
+
function cardQuestion(raw) {
|
|
263
|
+
const question = sanitizeWireText(raw);
|
|
264
|
+
return question.length > 0 && question.length <= CARD_QUESTION_MAX ? question : void 0;
|
|
265
|
+
}
|
|
266
|
+
function resolveExcerpt(args, frontmatter) {
|
|
267
|
+
const raw = args.excerpt ?? expectString(frontmatter, "excerpt");
|
|
268
|
+
if (raw === void 0) return void 0;
|
|
269
|
+
const excerpt = sanitizeWireText(raw);
|
|
270
|
+
if (excerpt.length > EXCERPT_MAX_LENGTH) {
|
|
271
|
+
throw new CliError(
|
|
272
|
+
"USAGE",
|
|
273
|
+
`excerpt must be at most ${EXCERPT_MAX_LENGTH} characters (got ${excerpt.length}).`,
|
|
274
|
+
{ fix: `Shorten it to ${EXCERPT_MAX_LENGTH} characters or fewer.` }
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
return excerpt;
|
|
278
|
+
}
|
|
268
279
|
function resolveTags(frontmatter) {
|
|
269
280
|
const fm = frontmatter.tags;
|
|
270
281
|
if (fm === void 0) return void 0;
|
|
@@ -338,4 +349,4 @@ function confirmMessage(warnCount, priceUsd) {
|
|
|
338
349
|
export {
|
|
339
350
|
runPublish
|
|
340
351
|
};
|
|
341
|
-
//# sourceMappingURL=chunk-
|
|
352
|
+
//# sourceMappingURL=chunk-2SDUV6MQ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/publish.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { dirname, resolve } from 'node:path';\nimport { CliError } from '../lib/errors';\nimport { parseUsdToAtomic, toMoney } from '../lib/money';\nimport { resolveContextSettings, resolvePublishSettings } from '../lib/settings';\nimport { parsePublishModeFlag } from '../lib/config';\nimport { loadSearches, markSearchResolved, type StoredSearch } from '../lib/search-store';\nimport { UUID_RE } from '../lib/ids';\nimport { scan, type ScanContext, type ScanFinding } from '../lib/scan';\nimport { deriveProjectMarkers } from '../lib/scan-context';\nimport { headingOutline } from '../lib/markdown';\nimport { sanitizeForTerminal, sanitizeWireText } from '../lib/output';\nimport { trimSlash } from '../lib/url';\nimport {\n deriveCard,\n localCardEligibility,\n missingSentences,\n parseAppliesToFlags,\n parseFrontmatter,\n type CardFlags,\n type Frontmatter,\n type ResourceCardInput,\n} from '../lib/card';\nimport {\n publishPost,\n EXCERPT_MAX_LENGTH,\n PUBLISH_STATUSES,\n type PublishInput,\n type PublishStatus,\n} from '../lib/posts-api';\nimport {\n dedupeFindings,\n describeFindings,\n needsConfirmation,\n publicFinding,\n resolveWriteAuth,\n writeModeNotices,\n} from '../lib/consent';\nimport { describeWallet, resolveWalletProvider, type WalletProvider } from '../lib/wallet';\nimport type { CommandContext, CommandResult } from '../context';\n\n/**\n * `tenjin publish <file.md>`: read the Markdown, parse\n * frontmatter for post + answer-card fields, run the deterministic scan (every\n * mode), gate on the D38\n * consent cascade, then write via the session key (minted on first use) or the\n * plain-SIWX fallback and return a compact receipt. The ordering is the point and\n * is enforced here: scan and consent BEFORE any wallet touch or network write.\n *\n * Exit codes: 0 success (incl. an ineligible-but-published card), 2 usage, 3\n * needs_confirmation / non-bypassable publish_blocked, 4 a write failure after\n * approval.\n */\n\nexport interface PublishArgs {\n /** The Markdown file to publish. */\n file?: string;\n /** The search this publish answers; closes its open loop. */\n searchId?: string;\n draft?: boolean;\n yes?: boolean;\n /** Raw `--mode` (review|auto|full-auto); validated at the edge (USAGE on a bad value). */\n mode?: string;\n /** Top-level post price, decimal USD at the edge (O1). */\n price?: string;\n /** The public preview text; overrides frontmatter `excerpt`. Absent, the server\n * derives one from the body's leading prose. */\n excerpt?: string;\n question?: string[];\n task?: string[];\n scope?: string;\n exclusions?: string;\n appliesTo?: string[];\n asOf?: string;\n validUntil?: string;\n artifactType?: string;\n temporalMode?: string;\n provenance?: string;\n methodology?: string;\n}\n\nexport interface PublishDeps {\n fetchImpl?: typeof fetch;\n provider?: WalletProvider;\n /** Force the plain-SIWX write path (default: session key unless TENJIN_NO_SESSION=1). */\n useSession?: boolean;\n /** Environment seam (mode, base-url, TENJIN_NO_SESSION); defaults to process.env. */\n env?: NodeJS.ProcessEnv;\n /** Working directory for the `.tenjin.json` walk; defaults to process.cwd(). */\n cwd?: string;\n}\n\nexport async function runPublish(\n args: PublishArgs,\n ctx: CommandContext,\n deps: PublishDeps = {},\n): Promise<CommandResult> {\n const env = deps.env ?? process.env;\n const cwd = deps.cwd ?? process.cwd();\n // Validate --mode at the edge (USAGE, exit 2) BEFORE any consent resolution: a\n // typo like `--mode Review` must never be silently dropped onto a looser mode\n // and publish unconfirmed. Mirrors install's --publish-mode edge check.\n if (args.mode !== undefined) parsePublishModeFlag(args.mode, '--mode');\n validateSearchId(args);\n\n const raw = await readSource(args);\n // Read the named search ONCE, here: it prefills the card's question below, and\n // whether it was found decides what the post-publish close reports. Local read,\n // and a missing store reads as no entry rather than failing the publish.\n const storedSearch =\n args.searchId !== undefined\n ? ((await loadSearches(ctx.dataDir)).find((s) => s.searchId === args.searchId) ?? null)\n : null;\n const { frontmatter, body } = parseFrontmatter(raw);\n\n const status = resolveStatus(args, frontmatter);\n const title = resolveTitle(frontmatter, body);\n const tags = resolveTags(frontmatter);\n const excerpt = resolveExcerpt(args, frontmatter);\n const handle = expectString(frontmatter, 'handle');\n // The named search's question prefills questionsAnswered, but only as a\n // fallback: an explicit --question OR a frontmatter questionsAnswered still\n // wins. That phrasing is what the next searcher will send.\n const cardFlags = cardFlagsFrom(args);\n const wanted = storedSearch?.question;\n const prefillQuestion = wanted === undefined ? undefined : cardQuestion(wanted);\n const roomForPrefill =\n cardFlags.question === undefined && frontmatter.questionsAnswered === undefined;\n if (prefillQuestion !== undefined && roomForPrefill) cardFlags.question = [prefillQuestion];\n // A prefill that was WANTED, had room, and was dropped anyway is the one case a\n // caller cannot infer: the card simply comes back without the question it asked\n // for. Reported on both surfaces, because --json never sees the stderr line.\n const prefill: PrefillOutcome =\n wanted === undefined || !roomForPrefill\n ? 'none'\n : prefillQuestion !== undefined\n ? 'applied'\n : 'dropped-too-long';\n if (prefill === 'dropped-too-long') {\n ctx.io.stderr.write(\n `The searched question is longer than ${CARD_QUESTION_MAX} characters, so it was not added to the answer card; pass --question to set a shorter one.\\n`,\n );\n }\n const card = deriveCard(frontmatter, cardFlags);\n\n // The consent cascade + resolved price (global < project < env < flag), with the\n // full-auto loosening gate. Its downgrade warnings go to stderr, not the receipt.\n const settings = await resolvePublishSettings({\n dataDir: ctx.dataDir,\n cwd,\n ...(args.mode !== undefined ? { flag: args.mode } : {}),\n env,\n });\n // The resolver's downgrade warnings, a mistyped env mode, and the one-line\n // explainer for an unconfigured mode: all stderr, all invisible to --json.\n writeModeNotices(\n ctx.io.stderr,\n settings,\n env,\n 'each publish asks you once. Set auto to publish clean scans automatically',\n );\n const priceAtomic = resolvePrice(args, frontmatter, settings.defaultPriceAtomic);\n\n // The scan runs in EVERY mode (D38): it gates the gate, it does not replace it.\n // Scan the whole file AND the derived card's text, so a secret reaches the same\n // gates whether it arrives in the body, in frontmatter, or via a card-authoring\n // flag (--provenance, --scope, …) — the card ships to the PUBLIC card, so a flag\n // secret must block exactly like an in-file one. Dedupe by check+excerpt so a\n // frontmatter value (present in both raw and the card) is not double-counted.\n // The scan context carries the source project's git remote slugs (offline FS\n // read, best-effort): a draft quoting its own project's repo/org warns as a\n // private-by-default reference (open-questions publishing-safety check-set).\n // Markers derive from the DRAFT's project, not the shell's cwd (review r5): a\n // file publish walks up from the file's own directory, so the process cwd is\n // unrelated to where the draft actually lives.\n const markerRoot = args.file !== undefined ? dirname(resolve(cwd, args.file)) : cwd;\n const scanContext: ScanContext = { projectMarkers: await deriveProjectMarkers(markerRoot) };\n const findings = dedupeFindings([\n ...scan(raw, scanContext),\n ...scan(cardScanText(card), scanContext),\n ]);\n const blocking = findings.filter((f) => f.severity === 'block');\n const warns = findings.filter((f) => f.severity === 'warn');\n\n const eligibility = localCardEligibility(card);\n const price = toMoney(priceAtomic);\n\n // A hard-block finding refuses in EVERY mode and is never clearable by --yes or\n // full-auto — the same non-bypassable posture as buy's price cap.\n if (blocking.length > 0) {\n throw new CliError('PUBLISH_BLOCKED', blockMessage(blocking), {\n fix: 'Remove the secret from the file (it is never masked away by --yes), then re-run.',\n details: {\n mode: settings.mode,\n findings: blocking.map(publicFinding),\n price: { atomic: price.atomic, usd: price.usd },\n },\n });\n }\n\n // --yes clears the soft findings and the review confirm alike.\n if (needsConfirmation(settings.mode, warns.length) && args.yes !== true) {\n throw new CliError('NEEDS_CONFIRMATION', confirmMessage(warns.length, price.usd), {\n fix: 'Review the findings, then re-run with --yes (or resolve the source and re-run).',\n details: {\n mode: settings.mode,\n price: { atomic: price.atomic, usd: price.usd },\n findings: warns.map(publicFinding),\n card: eligibility,\n target: { status, titlePreview: sanitizeForTerminal(title ?? '(untitled draft)') },\n },\n });\n }\n\n // Approved (or nothing to confirm): from here a wallet is required. The write\n // base URL is resolved through the shared settings seam and used for BOTH the\n // SIWX/session header domain and the POST host, so the two never diverge.\n const runtime = await resolveContextSettings(ctx);\n const provider = resolveWalletProvider(\n ctx,\n deps.provider !== undefined ? { provider: deps.provider } : {},\n );\n await describeWallet(provider); // surfaces WALLET_MISSING with its own fix\n const signer = await provider.getSigner();\n const auth = resolveWriteAuth({\n signer,\n baseUrl: runtime.baseUrl,\n dataDir: ctx.dataDir,\n // A publish always writes.\n scope: 'read+write',\n ...(deps.useSession !== undefined ? { useSession: deps.useSession } : {}),\n env,\n });\n\n const input: PublishInput = {\n ...(title !== undefined ? { title } : {}),\n bodyMd: body,\n ...(excerpt !== undefined ? { excerpt } : {}),\n ...(tags !== undefined ? { tags } : {}),\n priceAtomic,\n ...(handle !== undefined ? { handle } : {}),\n status,\n ...(card !== undefined ? { resource: card } : {}),\n };\n\n const result = await publishPost(input, auth, {\n baseUrl: runtime.baseUrl,\n timeoutMs: ctx.flags.timeout,\n ...(deps.fetchImpl !== undefined ? { fetchImpl: deps.fetchImpl } : {}),\n });\n\n // A DRAFT answered nobody. It parks the piece privately, so it clears no parked\n // loop: the draft is still the pending answer, and the later real publish is\n // what resolves it.\n const parksPrivately = status === 'draft';\n\n let searchInfo: SearchReceipt | undefined;\n if (args.searchId !== undefined) {\n searchInfo = await closeNamedSearch(ctx, args.searchId, storedSearch, parksPrivately, prefill);\n }\n return receipt(result, runtime.baseUrl, searchInfo);\n}\n\n/**\n * What `--search-id` did, as a machine field. `--json` suppresses every stderr\n * note below, so without this an agent that named a search had no way to learn\n * whether its loop actually closed — the same silent-flag failure the draft note\n * fixes for a human.\n */\ninterface SearchReceipt {\n id: string;\n closed: boolean;\n prefill: PrefillOutcome;\n}\n\n/**\n * What became of the searched question as a card entry. `none` covers both \"no\n * stored question\" and \"the draft named its own\", which are the cases where\n * nothing was expected; `dropped-too-long` is the one a caller has to be told.\n */\ntype PrefillOutcome = 'applied' | 'dropped-too-long' | 'none';\n\n/**\n * `--search-id` at the edge: a uuid, refused before any wallet touch so a typo\n * costs a message rather than a signing prompt.\n */\nfunction validateSearchId(args: PublishArgs): void {\n if (args.searchId === undefined) return;\n if (!UUID_RE.test(args.searchId)) {\n throw new CliError('USAGE', `Invalid --search-id: ${JSON.stringify(args.searchId)}.`, {\n fix: 'Pass the searchId from a prior `tenjin search` (a uuid).',\n });\n }\n}\n\n/**\n * Close the loop a `--search-id` file publish named, and say what happened in\n * both registers: a stderr line for a human, the returned receipt for `--json`.\n *\n * Two outcomes close nothing, and neither is an error — the piece is already\n * published, and bookkeeping never fails the write that ran. A `--draft` parks\n * privately and answers nobody, and an unknown id (aged out of the local store,\n * or from another machine) has no loop here to close.\n *\n * `closed: true` describes the LOOP, not this call: `markSearchResolved` keeps\n * the first resolution, so a search an `outcome` already closed reports closed\n * here too, which is what the caller is actually asking about. It reports the\n * OUTCOME of the write rather than the intent to write, so a swallowed lock\n * timeout comes back as `closed: false` and a stderr line instead of a receipt\n * claiming a close that never landed.\n */\nasync function closeNamedSearch(\n ctx: CommandContext,\n searchId: string,\n stored: StoredSearch | null,\n parksPrivately: boolean,\n prefill: PrefillOutcome,\n): Promise<SearchReceipt> {\n const open = (reason: string): SearchReceipt => {\n ctx.io.stderr.write(`${reason}\\n`);\n return { id: searchId, closed: false, prefill };\n };\n if (parksPrivately) return open(`Saved as a draft, so search ${searchId} stays open.`);\n if (stored === null) {\n return open(`Published, but search ${searchId} is not in the local store.`);\n }\n const outcome = await markSearchResolved(ctx.dataDir, searchId, 'publish');\n if (outcome === 'failed') {\n return open(\n `Published, but the local record for search ${searchId} could not be updated, so the open-loop reminder may repeat. Close it with \\`tenjin outcome --search-id ${searchId} --status used\\`.`,\n );\n }\n // `not-found` here means the entry was evicted between the read above and this\n // write: nothing was closed, so nothing claims to have been.\n if (outcome === 'not-found') {\n return open(`Published, but search ${searchId} is no longer in the local store.`);\n }\n return { id: searchId, closed: true, prefill };\n}\n\n/** The Markdown to publish. A missing path is USAGE before any wallet touch. */\nasync function readSource(args: PublishArgs): Promise<string> {\n if (args.file === undefined) {\n throw new CliError('USAGE', 'Nothing to publish.', {\n fix: 'Pass a Markdown file, e.g. `tenjin publish post.md`.',\n });\n }\n return readMarkdown(args.file);\n}\n\nfunction receipt(\n result: Awaited<ReturnType<typeof publishPost>>,\n baseUrl: string,\n searchInfo?: SearchReceipt,\n): CommandResult {\n const price = toMoney(result.priceAtomic);\n const missing = missingSentences(result.cacheEligibleMissing).map(sanitizeForTerminal);\n const cacheEligible = result.cacheEligible ?? false;\n const deskUrl = `${trimSlash(baseUrl)}/desk`;\n const title = sanitizeForTerminal(result.title);\n // status and url are server-sent open strings (posts-api declares both as bare\n // z.string()), so they get the same treatment as the title beside them: this\n // line is what an author reads to learn where their piece went.\n const human = [\n `Published ${title} (${sanitizeForTerminal(result.status)}) for ${price.usd} USD → ${sanitizeForTerminal(result.url)}`,\n cacheEligible\n ? 'Answer card is search-eligible.'\n : missing.length > 0\n ? `Answer card not search-eligible yet: ${missing.join(' ')}`\n : 'Published as a browse-only document (no answer card).',\n ...(searchInfo?.closed === true ? [`Closed the loop on search ${searchInfo.id}.`] : []),\n ...result.warnings.map((w) => `warning: ${sanitizeForTerminal(w)}`),\n ];\n return {\n data: {\n resourceId: result.resourceId,\n url: result.url,\n status: result.status,\n price,\n cacheEligible,\n missing,\n deskUrl,\n ...(searchInfo !== undefined ? { search: searchInfo } : {}),\n ...(result.warnings.length > 0 ? { warnings: result.warnings } : {}),\n },\n humanLines: human,\n };\n}\n\n// ---------------------------------------------------------------------------\n// Field resolution.\n// ---------------------------------------------------------------------------\n\nasync function readMarkdown(file: string): Promise<string> {\n try {\n return await readFile(file, 'utf8');\n } catch (err) {\n throw new CliError('USAGE', `Could not read ${JSON.stringify(file)}`, {\n fix: 'Pass a path to a readable Markdown file, e.g. `tenjin publish post.md`.',\n cause: err,\n });\n }\n}\n\nfunction resolveStatus(args: PublishArgs, frontmatter: Frontmatter): PublishStatus {\n if (args.draft === true) return 'draft';\n const fm = frontmatter.status;\n if (fm === undefined) return 'published';\n if (typeof fm !== 'string' || !(PUBLISH_STATUSES as readonly string[]).includes(fm)) {\n throw new CliError('USAGE', `Invalid status ${JSON.stringify(fm)} in frontmatter.`, {\n fix: 'Use status: draft | published | unlisted, or pass --draft.',\n });\n }\n return fm as PublishStatus;\n}\n\nfunction resolveTitle(frontmatter: Frontmatter, body: string): string | undefined {\n const fm = frontmatter.title;\n if (fm !== undefined) {\n if (typeof fm !== 'string') {\n throw new CliError('USAGE', 'frontmatter title must be a single string.');\n }\n return fm.trim();\n }\n // Fall back to the first heading (level 1 preferred) so a plain `# Title` post\n // needs no frontmatter.\n const headings = headingOutline(body);\n const h1 = headings.find((h) => h.level === 1) ?? headings[0];\n return h1?.text;\n}\n\n/** The server's per-item bound on `questionsAnswered` (mirrored by deriveCard). */\nconst CARD_QUESTION_MAX = 200;\n\n/**\n * A stored question as a card entry, or undefined when it cannot be one.\n *\n * Dropped rather than cut over the item bound: a search question may run to the\n * server's 512, and a prefill that fails card validation would turn a publish\n * that was fine into a usage error the caller never asked for. Truncating is\n * worse still — half a question is a different question, and this text is what\n * the next searcher matches against.\n */\nfunction cardQuestion(raw: string): string | undefined {\n const question = sanitizeWireText(raw);\n return question.length > 0 && question.length <= CARD_QUESTION_MAX ? question : undefined;\n}\n\n/**\n * The public preview text: `--excerpt` over frontmatter `excerpt`, or undefined\n * to let the server derive one from the body's leading prose.\n *\n * The bound is checked HERE as well as in the request builder, because the\n * builder runs after a wallet signature has been collected and this is the edge:\n * a too-long excerpt should cost a message, not a signing prompt. Refused rather\n * than truncated — a silently cut preview is a different preview, and the whole\n * point of setting one is controlling exactly what a non-buyer reads. Sanitized\n * before the bound for the same reason the builder is: the stripped text is what\n * ships, so it is what the length has to describe.\n */\nfunction resolveExcerpt(args: PublishArgs, frontmatter: Frontmatter): string | undefined {\n const raw = args.excerpt ?? expectString(frontmatter, 'excerpt');\n if (raw === undefined) return undefined;\n const excerpt = sanitizeWireText(raw);\n if (excerpt.length > EXCERPT_MAX_LENGTH) {\n throw new CliError(\n 'USAGE',\n `excerpt must be at most ${EXCERPT_MAX_LENGTH} characters (got ${excerpt.length}).`,\n { fix: `Shorten it to ${EXCERPT_MAX_LENGTH} characters or fewer.` },\n );\n }\n return excerpt;\n}\n\nfunction resolveTags(frontmatter: Frontmatter): string[] | undefined {\n const fm = frontmatter.tags;\n if (fm === undefined) return undefined;\n if (typeof fm === 'string') return [fm];\n if (Array.isArray(fm)) return fm;\n throw new CliError('USAGE', 'frontmatter tags must be a list of strings.');\n}\n\nfunction expectString(frontmatter: Frontmatter, key: string): string | undefined {\n const fm = frontmatter[key];\n if (fm === undefined) return undefined;\n if (typeof fm !== 'string') {\n throw new CliError('USAGE', `frontmatter ${key} must be a single string.`);\n }\n return fm;\n}\n\nfunction resolvePrice(args: PublishArgs, frontmatter: Frontmatter, defaultAtomic: string): string {\n if (args.price !== undefined) return parseUsdToAtomic(args.price);\n const fm = frontmatter.price;\n if (fm !== undefined) {\n if (typeof fm !== 'string') {\n throw new CliError('USAGE', 'frontmatter price must be a decimal-USD string, e.g. \"0.10\".');\n }\n return parseUsdToAtomic(fm);\n }\n return defaultAtomic;\n}\n\nfunction cardFlagsFrom(args: PublishArgs): CardFlags {\n return {\n ...(args.question !== undefined && args.question.length > 0 ? { question: args.question } : {}),\n ...(args.task !== undefined && args.task.length > 0 ? { task: args.task } : {}),\n ...(args.scope !== undefined ? { scope: args.scope } : {}),\n ...(args.exclusions !== undefined ? { exclusions: args.exclusions } : {}),\n ...(args.asOf !== undefined ? { asOf: args.asOf } : {}),\n ...(args.validUntil !== undefined ? { validUntil: args.validUntil } : {}),\n ...(args.artifactType !== undefined ? { artifactType: args.artifactType } : {}),\n ...(args.temporalMode !== undefined ? { temporalMode: args.temporalMode } : {}),\n ...(args.provenance !== undefined ? { provenance: args.provenance } : {}),\n ...(args.methodology !== undefined ? { methodology: args.methodology } : {}),\n ...(args.appliesTo !== undefined && args.appliesTo.length > 0\n ? { appliesTo: parseAppliesToFlags(args.appliesTo) }\n : {}),\n };\n}\n\n/**\n * The derived card's free-text values as one newline-joined document, so the scan\n * covers card-flag input (which never touches the file) at the same severity as\n * the body. Empty when there is no card.\n */\nfunction cardScanText(card: ResourceCardInput | undefined): string {\n if (card === undefined) return '';\n const parts: string[] = [];\n const add = (v: string | undefined): void => {\n if (v !== undefined) parts.push(v);\n };\n add(card.scope);\n add(card.exclusions);\n add(card.provenanceSummary);\n add(card.methodologySummary);\n add(card.mediaType);\n add(card.maintenanceCadence);\n add(card.asOf);\n add(card.validUntil);\n add(card.estimatedPaidInputCost);\n if (card.questionsAnswered !== undefined) parts.push(...card.questionsAnswered);\n if (card.tasksSupported !== undefined) parts.push(...card.tasksSupported);\n if (card.appliesTo !== undefined) {\n for (const values of Object.values(card.appliesTo)) parts.push(...values);\n }\n return parts.join('\\n');\n}\n\n// ---------------------------------------------------------------------------\n// Finding + message shaping.\n// ---------------------------------------------------------------------------\n\nfunction blockMessage(blocking: ScanFinding[]): string {\n return `Publish blocked: the file contains ${describeFindings(blocking)}.`;\n}\n\nfunction confirmMessage(warnCount: number, priceUsd: string): string {\n return warnCount > 0\n ? `Publish needs confirmation: ${warnCount} finding(s), price $${priceUsd}.`\n : `Publish needs confirmation: price $${priceUsd}.`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,gBAAgB;AACzB,SAAS,SAAS,eAAe;AA2FjC,eAAsB,WACpB,MACA,KACA,OAAoB,CAAC,GACG;AACxB,QAAM,MAAM,KAAK,OAAO,QAAQ;AAChC,QAAM,MAAM,KAAK,OAAO,QAAQ,IAAI;AAIpC,MAAI,KAAK,SAAS,OAAW,sBAAqB,KAAK,MAAM,QAAQ;AACrE,mBAAiB,IAAI;AAErB,QAAM,MAAM,MAAM,WAAW,IAAI;AAIjC,QAAM,eACJ,KAAK,aAAa,UACZ,MAAM,aAAa,IAAI,OAAO,GAAG,KAAK,CAAC,MAAM,EAAE,aAAa,KAAK,QAAQ,KAAK,OAChF;AACN,QAAM,EAAE,aAAa,KAAK,IAAI,iBAAiB,GAAG;AAElD,QAAM,SAAS,cAAc,MAAM,WAAW;AAC9C,QAAM,QAAQ,aAAa,aAAa,IAAI;AAC5C,QAAM,OAAO,YAAY,WAAW;AACpC,QAAM,UAAU,eAAe,MAAM,WAAW;AAChD,Q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cAAc,QAAW;AAChC,eAAW,UAAU,OAAO,OAAO,KAAK,SAAS,EAAG,OAAM,KAAK,GAAG,MAAM;AAAA,EAC1E;AACA,SAAO,MAAM,KAAK,IAAI;AACxB;AAMA,SAAS,aAAa,UAAiC;AACrD,SAAO,sCAAsC,iBAAiB,QAAQ,CAAC;AACzE;AAEA,SAAS,eAAe,WAAmB,UAA0B;AACnE,SAAO,YAAY,IACf,+BAA+B,SAAS,uBAAuB,QAAQ,MACvE,sCAAsC,QAAQ;AACpD;","names":[]}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
package_default
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-UY6CGULW.js";
|
|
5
|
+
import {
|
|
6
|
+
CliError
|
|
7
|
+
} from "./chunk-PZRAAAY2.js";
|
|
5
8
|
|
|
6
9
|
// src/lib/client-meta.ts
|
|
7
10
|
var TENJIN_USER_AGENT = `tenjin-cli/${package_default.version} (+https://tenjin.blog)`;
|
|
@@ -177,12 +180,20 @@ async function httpRequest(url, opts) {
|
|
|
177
180
|
clearTimeout(timer);
|
|
178
181
|
}
|
|
179
182
|
}
|
|
183
|
+
function fetchFailureToCliError(failure, opts = {}) {
|
|
184
|
+
const code = failure.kind === "network" || failure.kind === "timeout" ? "NETWORK_ERROR" : failure.kind === "invalid-json" ? "CONTRACT_MISMATCH" : "API_UNREACHABLE";
|
|
185
|
+
return new CliError(code, failure.message, {
|
|
186
|
+
...opts.fix !== void 0 ? { fix: opts.fix } : {},
|
|
187
|
+
...opts.details !== void 0 ? { details: opts.details } : {}
|
|
188
|
+
});
|
|
189
|
+
}
|
|
180
190
|
function errorMessage(err) {
|
|
181
191
|
return err instanceof Error ? err.message : String(err);
|
|
182
192
|
}
|
|
183
193
|
|
|
184
194
|
export {
|
|
185
195
|
fetchJson,
|
|
186
|
-
httpRequest
|
|
196
|
+
httpRequest,
|
|
197
|
+
fetchFailureToCliError
|
|
187
198
|
};
|
|
188
|
-
//# sourceMappingURL=chunk-
|
|
199
|
+
//# sourceMappingURL=chunk-3GSZUADW.js.map
|