tenjin-cli 0.1.0-alpha.2 → 0.1.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +156 -185
- package/dist/{_esm-FEASBWRP.js → _esm-N4KAVXQR.js} +9 -9
- package/dist/buy-OOOLUDND.js +41 -0
- package/dist/candidate-TWCWTFGA.js +22 -0
- package/dist/{ccip-XR5NE5QK.js → ccip-RPPPKTJR.js} +5 -5
- package/dist/{ccip-NQXCEK2U.js → ccip-ZGGWQN4X.js} +4 -4
- package/dist/{chunk-XJIW7USF.js → chunk-333FOTUJ.js} +5 -5
- package/dist/{chunk-YALGASEU.js → chunk-47PP7TAG.js} +1610 -1610
- package/dist/chunk-47PP7TAG.js.map +1 -0
- package/dist/{buy-U35DQ6XM.js → chunk-4GR7DGD6.js} +23 -41
- package/dist/{buy-U35DQ6XM.js.map → chunk-4GR7DGD6.js.map} +1 -1
- package/dist/{chunk-27ONARHV.js → chunk-5JH7ZB6Z.js} +7 -7
- package/dist/{chunk-27ONARHV.js.map → chunk-5JH7ZB6Z.js.map} +1 -1
- package/dist/{chunk-OYMYCW7J.js → chunk-6WWVYYSB.js} +32 -2
- package/dist/{chunk-OYMYCW7J.js.map → chunk-6WWVYYSB.js.map} +1 -1
- package/dist/{chunk-UGX7YPX2.js → chunk-7FK2UN2T.js} +65 -65
- package/dist/{chunk-UGX7YPX2.js.map → chunk-7FK2UN2T.js.map} +1 -1
- package/dist/{chunk-IYLHQMT5.js → chunk-BXUS5UCT.js} +5 -4
- package/dist/chunk-BXUS5UCT.js.map +1 -0
- package/dist/{chunk-QNP7H47L.js → chunk-C4TIWOAM.js} +2 -2
- package/dist/{chunk-QNP7H47L.js.map → chunk-C4TIWOAM.js.map} +1 -1
- package/dist/{chunk-7PHSZKQS.js → chunk-CJU555P5.js} +24 -24
- package/dist/{chunk-7PHSZKQS.js.map → chunk-CJU555P5.js.map} +1 -1
- package/dist/{chunk-YN5SHIXQ.js → chunk-DPET3TW5.js} +2 -2
- package/dist/{chunk-TLCMMYLY.js → chunk-DPUMEMGM.js} +5 -5
- package/dist/chunk-DPUMEMGM.js.map +1 -0
- package/dist/{chunk-TFGSOPWR.js → chunk-EUQN3L5X.js} +9 -9
- package/dist/{chunk-TFGSOPWR.js.map → chunk-EUQN3L5X.js.map} +1 -1
- package/dist/{chunk-UPIEAMGH.js → chunk-FHB3VKZW.js} +6 -6
- package/dist/{chunk-UPIEAMGH.js.map → chunk-FHB3VKZW.js.map} +1 -1
- package/dist/{chunk-S3IGX57D.js → chunk-FU6MCSLG.js} +9 -9
- package/dist/{lookup-WYVTOMVY.js → chunk-H5ETJRQD.js} +54 -29
- package/dist/chunk-H5ETJRQD.js.map +1 -0
- package/dist/chunk-KXIX7YDV.js +59 -0
- package/dist/chunk-KXIX7YDV.js.map +1 -0
- package/dist/{chunk-5CLSD5YN.js → chunk-KYQVEKP5.js} +7 -7
- package/dist/{chunk-RRN3YTK7.js → chunk-KZAAWQNP.js} +3 -3
- package/dist/{chunk-NCE5NSN6.js → chunk-M2O56UK7.js} +158 -158
- package/dist/chunk-M2O56UK7.js.map +1 -0
- package/dist/{chunk-7KUW4MJD.js → chunk-MM4TGTST.js} +6 -6
- package/dist/{chunk-7KUW4MJD.js.map → chunk-MM4TGTST.js.map} +1 -1
- package/dist/{chunk-YIYQ2ZNT.js → chunk-NXCJN2FJ.js} +55 -28
- package/dist/chunk-NXCJN2FJ.js.map +1 -0
- package/dist/{candidate-RLYCQMF5.js → chunk-OJD54DIU.js} +15 -19
- package/dist/{candidate-RLYCQMF5.js.map → chunk-OJD54DIU.js.map} +1 -1
- package/dist/{chunk-ZABPQJ3M.js → chunk-POJRB2AE.js} +2 -2
- package/dist/{chunk-N62ROTMC.js → chunk-QH6677FJ.js} +5 -4
- package/dist/chunk-QH6677FJ.js.map +1 -0
- package/dist/{wallet-6QKS6UHW.js → chunk-R7BMDJZM.js} +15 -27
- package/dist/{wallet-6QKS6UHW.js.map → chunk-R7BMDJZM.js.map} +1 -1
- package/dist/{chunk-Z6MFJV5Z.js → chunk-S3KZ3PPK.js} +15 -11
- package/dist/{chunk-Z6MFJV5Z.js.map → chunk-S3KZ3PPK.js.map} +1 -1
- package/dist/{chunk-CYOF7ROH.js → chunk-S5RYMCV6.js} +3 -3
- package/dist/{chunk-ZMHYXMO6.js → chunk-U5S527PP.js} +3 -3
- package/dist/{chunk-RY4XKNV3.js → chunk-UHTVXQ2O.js} +3 -3
- package/dist/{publish-D76B3MBK.js → chunk-ULLWHHIT.js} +25 -42
- package/dist/chunk-ULLWHHIT.js.map +1 -0
- package/dist/{chunk-Z52RA3NC.js → chunk-VV4P5RVK.js} +47 -20
- package/dist/chunk-VV4P5RVK.js.map +1 -0
- package/dist/{chunk-QVX5MWJZ.js → chunk-W6R3HAAG.js} +2 -2
- package/dist/{chunk-3OV7E5G5.js → chunk-WWX32ML4.js} +1 -1
- package/dist/{chunk-3OV7E5G5.js.map → chunk-WWX32ML4.js.map} +1 -1
- package/dist/{chunk-HIVZG55D.js → chunk-XJN5WUKL.js} +2 -2
- package/dist/{chunk-JPHG2JW3.js → chunk-XNNOR7F7.js} +25 -25
- package/dist/chunk-XNNOR7F7.js.map +1 -0
- package/dist/{inspect-JGYJWFDP.js → chunk-YFREUEUI.js} +8 -26
- package/dist/{inspect-JGYJWFDP.js.map → chunk-YFREUEUI.js.map} +1 -1
- package/dist/{chunk-HSDCI7OV.js → chunk-YLYINX2H.js} +3 -3
- package/dist/{cli-4NNBEQYH.js → cli-AFSLAKR6.js} +47 -36
- package/dist/{cli-4NNBEQYH.js.map → cli-AFSLAKR6.js.map} +1 -1
- package/dist/{config-2VSXWWHK.js → config-DBEEM3UA.js} +5 -5
- package/dist/{doctor-JJPNIBYH.js → doctor-XDA3YU6H.js} +7 -7
- package/dist/{ethersCompat-Df4a6QIZ-3YZIAXDK.js → ethersCompat-Df4a6QIZ-WHYKB6HA.js} +5 -5
- package/dist/index.js +1 -1
- package/dist/inspect-YBGDAG47.js +33 -0
- package/dist/install-7J6KKEEP.js +542 -0
- package/dist/install-7J6KKEEP.js.map +1 -0
- package/dist/outcome-ZFGHX2XW.js +20 -0
- package/dist/publish-IH7RJXGB.js +36 -0
- package/dist/publish-IH7RJXGB.js.map +1 -0
- package/dist/run-DCZFEW2C.js +16806 -0
- package/dist/run-DCZFEW2C.js.map +1 -0
- package/dist/search-R6NIQFXI.js +24 -0
- package/dist/search-R6NIQFXI.js.map +1 -0
- package/dist/{secp256k1-N3ZHU7LB.js → secp256k1-XRPVBC6V.js} +3 -3
- package/dist/secp256k1-XRPVBC6V.js.map +1 -0
- package/dist/usdc-AU6ZIKA6.js +22 -0
- package/dist/usdc-AU6ZIKA6.js.map +1 -0
- package/dist/{viemAdapter-By13KInL-ZZE6UV4Y.js → viemAdapter-By13KInL-TUQJBMHM.js} +5 -5
- package/dist/viemAdapter-By13KInL-TUQJBMHM.js.map +1 -0
- package/dist/{wallet-PA54CRBL.js → wallet-HKG3GSTX.js} +10 -10
- package/dist/wallet-HKG3GSTX.js.map +1 -0
- package/dist/wallet-UWHSHWC6.js +31 -0
- package/dist/wallet-UWHSHWC6.js.map +1 -0
- package/package.json +4 -3
- package/skills/tenjin/SKILL.md +56 -13
- package/skills/tenjin-publish/SKILL.md +57 -27
- package/skills/tenjin-search/SKILL.md +57 -31
- package/dist/chunk-IYLHQMT5.js.map +0 -1
- package/dist/chunk-JPHG2JW3.js.map +0 -1
- package/dist/chunk-N62ROTMC.js.map +0 -1
- package/dist/chunk-NCE5NSN6.js.map +0 -1
- package/dist/chunk-TLCMMYLY.js.map +0 -1
- package/dist/chunk-YALGASEU.js.map +0 -1
- package/dist/chunk-YIYQ2ZNT.js.map +0 -1
- package/dist/chunk-Z52RA3NC.js.map +0 -1
- package/dist/install-ZQRMSRGW.js +0 -378
- package/dist/install-ZQRMSRGW.js.map +0 -1
- package/dist/lookup-WYVTOMVY.js.map +0 -1
- package/dist/outcome-HKKT6QIA.js +0 -66
- package/dist/outcome-HKKT6QIA.js.map +0 -1
- package/dist/publish-D76B3MBK.js.map +0 -1
- package/dist/usdc-JIAJW4SV.js +0 -22
- /package/dist/{_esm-FEASBWRP.js.map → _esm-N4KAVXQR.js.map} +0 -0
- /package/dist/{ccip-NQXCEK2U.js.map → buy-OOOLUDND.js.map} +0 -0
- /package/dist/{ccip-XR5NE5QK.js.map → candidate-TWCWTFGA.js.map} +0 -0
- /package/dist/{config-2VSXWWHK.js.map → ccip-RPPPKTJR.js.map} +0 -0
- /package/dist/{doctor-JJPNIBYH.js.map → ccip-ZGGWQN4X.js.map} +0 -0
- /package/dist/{chunk-XJIW7USF.js.map → chunk-333FOTUJ.js.map} +0 -0
- /package/dist/{chunk-YN5SHIXQ.js.map → chunk-DPET3TW5.js.map} +0 -0
- /package/dist/{chunk-S3IGX57D.js.map → chunk-FU6MCSLG.js.map} +0 -0
- /package/dist/{chunk-5CLSD5YN.js.map → chunk-KYQVEKP5.js.map} +0 -0
- /package/dist/{chunk-RRN3YTK7.js.map → chunk-KZAAWQNP.js.map} +0 -0
- /package/dist/{chunk-ZABPQJ3M.js.map → chunk-POJRB2AE.js.map} +0 -0
- /package/dist/{chunk-CYOF7ROH.js.map → chunk-S5RYMCV6.js.map} +0 -0
- /package/dist/{chunk-ZMHYXMO6.js.map → chunk-U5S527PP.js.map} +0 -0
- /package/dist/{chunk-RY4XKNV3.js.map → chunk-UHTVXQ2O.js.map} +0 -0
- /package/dist/{chunk-QVX5MWJZ.js.map → chunk-W6R3HAAG.js.map} +0 -0
- /package/dist/{chunk-HIVZG55D.js.map → chunk-XJN5WUKL.js.map} +0 -0
- /package/dist/{chunk-HSDCI7OV.js.map → chunk-YLYINX2H.js.map} +0 -0
- /package/dist/{ethersCompat-Df4a6QIZ-3YZIAXDK.js.map → config-DBEEM3UA.js.map} +0 -0
- /package/dist/{secp256k1-N3ZHU7LB.js.map → doctor-XDA3YU6H.js.map} +0 -0
- /package/dist/{usdc-JIAJW4SV.js.map → ethersCompat-Df4a6QIZ-WHYKB6HA.js.map} +0 -0
- /package/dist/{viemAdapter-By13KInL-ZZE6UV4Y.js.map → inspect-YBGDAG47.js.map} +0 -0
- /package/dist/{wallet-PA54CRBL.js.map → outcome-ZFGHX2XW.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/output.ts","../src/schemas.ts"],"sourcesContent":["import { styleText } from 'node:util';\nimport { Stream } from 'node:stream';\nimport { CliError } from './errors';\nimport { SCHEMA_VERSION } from '../schemas';\nimport type { FailureEnvelope, OutputError, SuccessEnvelope } from '../schemas';\n\n/**\n * Injected streams + TTY fact. Every command receives one via CommandContext,\n * so tests drive the CLI in-process with memory buffers and no child process.\n * `isTTY` is the real terminal fact; the separate `--json` flag (passed to the\n * emit functions) is what suppresses human rendering — the two are ANDed, never\n * conflated, so `--json` on a TTY still yields pure machine output.\n */\nexport interface Io {\n stdout: NodeJS.WritableStream;\n stderr: NodeJS.WritableStream;\n isTTY: boolean;\n}\n\nexport function defaultIo(): Io {\n return {\n stdout: process.stdout,\n stderr: process.stderr,\n isTTY: Boolean(process.stdout.isTTY),\n };\n}\n\nexport interface EmitOptions {\n /** The global --json flag. When true, the JSON envelope is emitted even at a TTY. */\n json?: boolean;\n}\n\n/**\n * The two pure envelope builders, shared by the CLI's emit functions and the MCP\n * adapter so both surfaces produce the identical wire object by construction. They\n * hold no I/O and no --json branching: they turn a (command, data) or a normalized\n * CliError into the exact object that goes to stdout / structuredContent.\n */\nexport function buildSuccessEnvelope(command: string, data: unknown): SuccessEnvelope {\n return { schemaVersion: SCHEMA_VERSION, command, ok: true, data };\n}\n\nexport function buildFailureEnvelope(command: string, err: CliError): FailureEnvelope {\n const error: OutputError = {\n code: err.code,\n message: err.message,\n ...(err.fix !== undefined ? { fix: err.fix } : {}),\n ...(err.details !== undefined ? { details: err.details } : {}),\n };\n return { schemaVersion: SCHEMA_VERSION, command, ok: false, error };\n}\n\n/**\n * Output contract (human-first): at a TTY without `--json`, print ONLY the human\n * rendering to stdout, no JSON envelope. With `--json`, or when stdout is not a\n * TTY (a pipe, an agent), print exactly one JSON envelope to stdout and nothing\n * else. Exit codes are identical on both paths; only the stdout shape differs.\n */\nexport function emitSuccess(\n io: Io,\n command: string,\n data: unknown,\n humanLines: string[] = [],\n opts: EmitOptions = {},\n): void {\n if (humanMode(io, opts)) {\n writeLines(io.stdout, humanLines);\n return;\n }\n writeJson(io.stdout, buildSuccessEnvelope(command, data));\n}\n\n/**\n * The failure half of the same contract: at a TTY without `--json`, a red error\n * line plus a `fix` line to stdout and no envelope; otherwise exactly one failure\n * envelope to stdout. Accepts a CliError or any thrown value (non-CliError\n * normalizes to INTERNAL). Returns the normalized CliError so the caller reads its\n * `exitCode`.\n */\nexport function emitFailure(\n io: Io,\n command: string,\n err: unknown,\n opts: EmitOptions = {},\n): CliError {\n const cliErr = normalizeError(err);\n if (humanMode(io, opts)) {\n // Error messages can embed server-sourced text (api error passthrough) and\n // never carry intentional ANSI, so sanitize before painting.\n const lines = [paint(io, 'red', `error: ${sanitizeForTerminal(cliErr.message)}`)];\n if (cliErr.fix !== undefined) {\n lines.push(paint(io, 'dim', `fix: ${sanitizeForTerminal(cliErr.fix)}`));\n }\n // Scan findings are the one detail shape a human needs inline: without them an\n // interactive publish hitting NEEDS_CONFIRMATION / PUBLISH_BLOCKED sees the\n // count but not WHICH lines tripped. Every other details shape stays machine-only.\n lines.push(...findingLines(io, cliErr.details));\n writeLines(io.stdout, lines);\n return cliErr;\n }\n writeJson(io.stdout, buildFailureEnvelope(command, cliErr));\n return cliErr;\n}\n\n/**\n * Strip C0/C1 control characters and ANSI escape sequences from a string headed\n * for a terminal. Commands apply this to every SERVER-sourced string (titles,\n * handles) they put into human lines or the buy confirm prompt; without it a\n * malicious deployment could use cursor-movement escapes to overwrite the very\n * price a human is being asked to confirm. It is not applied to whole human\n * lines here because trusted callers (doctor) paint their own ANSI colors. JSON\n * stdout is untouched (JSON.stringify escapes control characters itself).\n */\nexport function sanitizeForTerminal(text: string): string {\n return (\n text\n // CSI/OSC/charset escape sequences first, then any stray ESC and the rest\n // of C0 (except \\t) plus DEL and the C1 range.\n // eslint-disable-next-line no-control-regex\n .replace(/\\x1b(?:\\[[0-9;?]*[ -/]*[@-~]|\\][^\\x07\\x1b]*(?:\\x07|\\x1b\\\\)|[@-Z\\\\-_])/g, '')\n // eslint-disable-next-line no-control-regex\n .replace(/[\\x00-\\x08\\x0a-\\x1f\\x7f-\\x9f]/g, '')\n );\n}\n\n/** CliError passes through; every other thrown value becomes an INTERNAL CliError. */\nexport function normalizeError(err: unknown): CliError {\n if (err instanceof CliError) return err;\n if (err instanceof Error) return new CliError('INTERNAL', err.message, { cause: err });\n return new CliError('INTERNAL', 'Unexpected error', { details: err });\n}\n\n/** True in human-first mode: a TTY without --json. Otherwise the JSON envelope wins. */\nfunction humanMode(io: Io, opts: EmitOptions): boolean {\n return io.isTTY && opts.json !== true;\n}\n\n/**\n * Render `details.findings` (the scan-finding projection publish attaches to\n * NEEDS_CONFIRMATION / PUBLISH_BLOCKED) as one dim line per finding:\n * ` <check> (line N): <excerpt>`. The excerpt is already masked for secret\n * findings at the source; sanitize it anyway since it can echo file content.\n * Returns [] for any other details shape, so no other error leaks a detail dump.\n */\nfunction findingLines(io: Io, details: unknown): string[] {\n if (typeof details !== 'object' || details === null || !('findings' in details)) return [];\n const { findings } = details as { findings: unknown };\n if (!Array.isArray(findings) || findings.length === 0) return [];\n const rendered: string[] = [];\n for (const f of findings) {\n if (typeof f !== 'object' || f === null) continue;\n const { check, line, excerpt } = f as { check?: unknown; line?: unknown; excerpt?: unknown };\n if (typeof check !== 'string' || typeof line !== 'number' || typeof excerpt !== 'string') {\n continue;\n }\n rendered.push(paint(io, 'dim', ` ${check} (line ${line}): ${sanitizeForTerminal(excerpt)}`));\n }\n return rendered;\n}\n\nfunction writeJson(stream: NodeJS.WritableStream, value: unknown): void {\n stream.write(`${JSON.stringify(value, null, 2)}\\n`);\n}\n\nfunction writeLines(stream: NodeJS.WritableStream, lines: string[]): void {\n if (lines.length > 0) stream.write(`${lines.join('\\n')}\\n`);\n}\n\n/**\n * Color a human line for stdout (the human surface now). styleText emits ANSI only\n * when the target stream is color-capable (a real TTY with color depth) and honors\n * NO_COLOR/FORCE_COLOR natively. The `stream` option is passed only when stdout is\n * a genuine Stream; a test/redirected sink is not one, so it falls back to the\n * default capability check and comes out plain.\n */\nfunction paint(io: Io, format: Parameters<typeof styleText>[0], text: string): string {\n if (io.stdout instanceof Stream) return styleText(format, text, { stream: io.stdout });\n return styleText(format, text);\n}\n","import { z } from 'zod';\n\n/**\n * Bumped only on a breaking change to any stdout envelope shape. Agents pin on\n * this: a consumer that sees an unexpected value should refuse to parse rather\n * than guess. Every envelope carries it, success or failure.\n */\nexport const SCHEMA_VERSION = 1;\n\n/**\n * The closed set of machine error codes. `error.code` in a failure envelope is\n * always one of these; agents branch on it, humans read `message`/`fix`. The\n * exit-code mapping lives in lib/errors.ts (this enum is the single source of\n * the code names both sides agree on).\n */\nexport const ErrorCodeSchema = z.enum([\n 'NODE_UNSUPPORTED',\n 'USAGE',\n 'CONFIG_INVALID',\n 'WALLET_EXISTS',\n 'WALLET_MISSING',\n 'WALLET_INVALID_KEY',\n 'PROVIDER_ERROR',\n 'RPC_ERROR',\n 'API_UNREACHABLE',\n 'CONTRACT_MISMATCH',\n 'REFUSED',\n 'NETWORK_ERROR',\n 'INTERNAL',\n 'NOT_IMPLEMENTED',\n // B2 (search/inspect/buy/outcome): a policy refusal (exit 3) has its own code\n // so an agent can distinguish a spend-cap block from a generic REFUSED; a\n // payment that failed after approval (exit 4) is PAYMENT_FAILED; the read\n // route's own coded failures (402 preview parse, 409 gate) surface as these.\n 'POLICY_REFUSED',\n 'PAYMENT_FAILED',\n 'RESOURCE_NOT_FOUND',\n 'SEARCH_NOT_FOUND',\n // A 429 from the anonymous search/outcome/read limits; error.details carries\n // retryAfterSeconds so a looping agent can back off instead of hammering.\n 'RATE_LIMITED',\n // B3 (publish): a publish that needs the human's yes (exit 3) — soft scan\n // findings, or `review` mode always. NEEDS_CONFIRMATION clears with --yes;\n // PUBLISH_BLOCKED is a hard-block finding (a live secret) that no mode or --yes\n // ever clears. PUBLISH_FAILED (exit 4) is a write that failed AFTER approval,\n // mirroring PAYMENT_FAILED's post-decision failure class.\n 'NEEDS_CONFIRMATION',\n 'PUBLISH_BLOCKED',\n 'PUBLISH_FAILED',\n]);\nexport type ErrorCode = z.infer<typeof ErrorCodeSchema>;\n\n/**\n * All money in machine output is dual-form: `atomic` is the 6-decimal USDC base\n * unit as a decimal string (never a JS number — precision), `usd` is the same\n * value formatted as decimal dollars. Emit both so agents compute on `atomic`\n * and humans read `usd` without either side re-deriving the other.\n */\nexport const MoneySchema = z.object({\n atomic: z.string(),\n usd: z.string(),\n});\nexport type Money = z.infer<typeof MoneySchema>;\n\nexport const OutputErrorSchema = z.object({\n code: ErrorCodeSchema,\n message: z.string(),\n fix: z.string().optional(),\n details: z.unknown().optional(),\n});\nexport type OutputError = z.infer<typeof OutputErrorSchema>;\n\nexport const SuccessEnvelopeSchema = z.object({\n schemaVersion: z.literal(SCHEMA_VERSION),\n command: z.string(),\n ok: z.literal(true),\n data: z.unknown(),\n});\nexport type SuccessEnvelope = z.infer<typeof SuccessEnvelopeSchema>;\n\nexport const FailureEnvelopeSchema = z.object({\n schemaVersion: z.literal(SCHEMA_VERSION),\n command: z.string(),\n ok: z.literal(false),\n error: OutputErrorSchema,\n});\nexport type FailureEnvelope = z.infer<typeof FailureEnvelopeSchema>;\n\n/** The one thing every invocation prints to stdout, discriminated on `ok`. */\nexport const OutputEnvelopeSchema = z.discriminatedUnion('ok', [\n SuccessEnvelopeSchema,\n FailureEnvelopeSchema,\n]);\nexport type OutputEnvelope = z.infer<typeof OutputEnvelopeSchema>;\n"],"mappings":";;;;;;;AAAA,SAAS,iBAAiB;AAC1B,SAAS,cAAc;;;ACMhB,IAAM,iBAAiB;AAQvB,IAAM,kBAAkB,iBA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@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
randomBytes,
|
|
36
36
|
rotr,
|
|
37
37
|
toBytes
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-KYQVEKP5.js";
|
|
39
39
|
|
|
40
40
|
// node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/_md.js
|
|
41
41
|
function setBigUint64(view, byteOffset, value, isLE) {
|
|
@@ -2250,4 +2250,4 @@ export {
|
|
|
2250
2250
|
@noble/curves/esm/secp256k1.js:
|
|
2251
2251
|
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
2252
2252
|
*/
|
|
2253
|
-
//# sourceMappingURL=chunk-
|
|
2253
|
+
//# sourceMappingURL=chunk-W6R3HAAG.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/ids.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto';\n\n/**\n * The shared identity patterns for server-controlled values that become file\n * paths, URL segments, or terminal output. One definition so a future change\n * (e.g. accepting uppercase ids) cannot be applied in one command and missed in\n * another. SLUG_RE must match the server's slugify charset (lib/posts.ts:\n * lowercase a-z0-9 groups joined by single hyphens, no leading/trailing hyphen).\n */\nexport const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\nexport const SLUG_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;\n/** A non-negative atomic USDC integer string (6-decimal base units). */\nexport const ATOMIC_RE = /^\\d{1,39}$/;\n\n/**\n * Mint a fresh opaque id for a locally-created entity (a parked candidate). A v4\n * uuid: the same shape a
|
|
1
|
+
{"version":3,"sources":["../src/lib/ids.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto';\n\n/**\n * The shared identity patterns for server-controlled values that become file\n * paths, URL segments, or terminal output. One definition so a future change\n * (e.g. accepting uppercase ids) cannot be applied in one command and missed in\n * another. SLUG_RE must match the server's slugify charset (lib/posts.ts:\n * lowercase a-z0-9 groups joined by single hyphens, no leading/trailing hyphen).\n */\nexport const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\nexport const SLUG_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;\n/** A non-negative atomic USDC integer string (6-decimal base units). */\nexport const ATOMIC_RE = /^\\d{1,39}$/;\n\n/**\n * Mint a fresh opaque id for a locally-created entity (a parked candidate). A v4\n * uuid: the same shape a searchId takes, so UUID_RE validates it and a `drop\n * <id>` argument that reaches a filesystem path can't traverse out of the store.\n */\nexport function newId(): string {\n return randomUUID();\n}\n"],"mappings":";;;AAAA,SAAS,kBAAkB;AASpB,IAAM,UAAU;AAChB,IAAM,UAAU;AAEhB,IAAM,YAAY;AAOlB,SAAS,QAAgB;AAC9B,SAAO,WAAW;AACpB;","names":[]}
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
swap32IfBE,
|
|
16
16
|
toBytes,
|
|
17
17
|
u32
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-KYQVEKP5.js";
|
|
19
19
|
|
|
20
20
|
// node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/sha3.js
|
|
21
21
|
var _0n = BigInt(0);
|
|
@@ -201,4 +201,4 @@ var keccak_256 = /* @__PURE__ */ (() => gen(1, 136, 256 / 8))();
|
|
|
201
201
|
export {
|
|
202
202
|
keccak_256
|
|
203
203
|
};
|
|
204
|
-
//# sourceMappingURL=chunk-
|
|
204
|
+
//# sourceMappingURL=chunk-XJN5WUKL.js.map
|
|
@@ -7,9 +7,9 @@ import {
|
|
|
7
7
|
} from "./chunk-MUBUQVC3.js";
|
|
8
8
|
import {
|
|
9
9
|
external_exports
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-6WWVYYSB.js";
|
|
11
11
|
|
|
12
|
-
// src/lib/
|
|
12
|
+
// src/lib/search-store.ts
|
|
13
13
|
import { mkdir, readFile } from "fs/promises";
|
|
14
14
|
import { join } from "path";
|
|
15
15
|
var MAX_ENTRIES = 50;
|
|
@@ -19,8 +19,8 @@ var StoredCandidateSchema = external_exports.object({
|
|
|
19
19
|
title: external_exports.string(),
|
|
20
20
|
price: external_exports.string()
|
|
21
21
|
});
|
|
22
|
-
var
|
|
23
|
-
|
|
22
|
+
var StoredSearchSchema = external_exports.object({
|
|
23
|
+
searchId: external_exports.string(),
|
|
24
24
|
at: external_exports.string(),
|
|
25
25
|
question: external_exports.string(),
|
|
26
26
|
decision: external_exports.string(),
|
|
@@ -28,12 +28,12 @@ var StoredLookupSchema = external_exports.object({
|
|
|
28
28
|
});
|
|
29
29
|
var StoreSchema = external_exports.object({
|
|
30
30
|
schemaVersion: external_exports.literal(1),
|
|
31
|
-
|
|
31
|
+
searches: external_exports.array(StoredSearchSchema)
|
|
32
32
|
});
|
|
33
33
|
function storePath(dataDir) {
|
|
34
|
-
return join(dataDir, "
|
|
34
|
+
return join(dataDir, "searches.json");
|
|
35
35
|
}
|
|
36
|
-
async function
|
|
36
|
+
async function loadSearches(dataDir) {
|
|
37
37
|
let raw;
|
|
38
38
|
try {
|
|
39
39
|
raw = await readFile(storePath(dataDir), "utf8");
|
|
@@ -47,50 +47,50 @@ async function loadLookups(dataDir) {
|
|
|
47
47
|
return [];
|
|
48
48
|
}
|
|
49
49
|
const parsed = StoreSchema.safeParse(json);
|
|
50
|
-
return parsed.success ? parsed.data.
|
|
50
|
+
return parsed.success ? parsed.data.searches : [];
|
|
51
51
|
}
|
|
52
|
-
async function
|
|
52
|
+
async function recordSearch(dataDir, entry) {
|
|
53
53
|
await mkdir(dataDir, { recursive: true, mode: 448 });
|
|
54
54
|
const lockPath = `${storePath(dataDir)}.lock`;
|
|
55
55
|
await withFileLock(lockPath, async () => {
|
|
56
|
-
const existing = await
|
|
57
|
-
const
|
|
56
|
+
const existing = await loadSearches(dataDir);
|
|
57
|
+
const searches = [entry, ...existing.filter((l) => l.searchId !== entry.searchId)].slice(
|
|
58
58
|
0,
|
|
59
59
|
MAX_ENTRIES
|
|
60
60
|
);
|
|
61
61
|
await writeFileAtomic(
|
|
62
62
|
storePath(dataDir),
|
|
63
|
-
`${JSON.stringify({ schemaVersion: 1,
|
|
63
|
+
`${JSON.stringify({ schemaVersion: 1, searches }, null, 2)}
|
|
64
64
|
`,
|
|
65
65
|
{ mode: 420, dirMode: 448 }
|
|
66
66
|
);
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
|
-
async function
|
|
70
|
-
const
|
|
71
|
-
return
|
|
69
|
+
async function latestSearch(dataDir) {
|
|
70
|
+
const searches = await loadSearches(dataDir);
|
|
71
|
+
return searches[0] ?? null;
|
|
72
72
|
}
|
|
73
73
|
async function findStoredCandidate(dataDir, resourceId) {
|
|
74
|
-
for (const
|
|
75
|
-
const hit =
|
|
74
|
+
for (const search of await loadSearches(dataDir)) {
|
|
75
|
+
const hit = search.candidates.find((c) => c.resourceId === resourceId);
|
|
76
76
|
if (hit) return hit;
|
|
77
77
|
}
|
|
78
78
|
return null;
|
|
79
79
|
}
|
|
80
|
-
async function
|
|
81
|
-
for (const
|
|
82
|
-
const hit =
|
|
80
|
+
async function findSearchForResource(dataDir, match) {
|
|
81
|
+
for (const search of await loadSearches(dataDir)) {
|
|
82
|
+
const hit = search.candidates.some(
|
|
83
83
|
(c) => match.resourceId !== void 0 && c.resourceId === match.resourceId || match.url !== void 0 && c.url === match.url
|
|
84
84
|
);
|
|
85
|
-
if (hit) return
|
|
85
|
+
if (hit) return search.searchId;
|
|
86
86
|
}
|
|
87
87
|
return null;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
export {
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
recordSearch,
|
|
92
|
+
latestSearch,
|
|
93
93
|
findStoredCandidate,
|
|
94
|
-
|
|
94
|
+
findSearchForResource
|
|
95
95
|
};
|
|
96
|
-
//# sourceMappingURL=chunk-
|
|
96
|
+
//# sourceMappingURL=chunk-XNNOR7F7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/search-store.ts"],"sourcesContent":["import { mkdir, readFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { z } from 'zod';\nimport { writeFileAtomic } from './atomic-json';\nimport { withFileLock } from './lock';\n\n/**\n * A small local ledger of recent searches so `outcome --last` can target the most\n * recent one and `buy <resourceId>` can resolve the payable read URL a candidate\n * carried (the read route is keyed by handle/slug, not id, so an id alone can't\n * build the URL). Bounded and best-effort: a corrupt file reads as empty rather\n * than blocking a command. NOT an entitlement record, that is the library receipt.\n */\n\nconst MAX_ENTRIES = 50;\n\nconst StoredCandidateSchema = z.object({\n resourceId: z.string(),\n url: z.string(),\n title: z.string(),\n price: z.string(),\n});\nexport type StoredCandidate = z.infer<typeof StoredCandidateSchema>;\n\nconst StoredSearchSchema = z.object({\n searchId: z.string(),\n at: z.string(),\n question: z.string(),\n decision: z.string(),\n candidates: z.array(StoredCandidateSchema),\n});\nexport type StoredSearch = z.infer<typeof StoredSearchSchema>;\n\nconst StoreSchema = z.object({\n schemaVersion: z.literal(1),\n searches: z.array(StoredSearchSchema),\n});\n\nfunction storePath(dataDir: string): string {\n return join(dataDir, 'searches.json');\n}\n\nexport async function loadSearches(dataDir: string): Promise<StoredSearch[]> {\n let raw: string;\n try {\n raw = await readFile(storePath(dataDir), 'utf8');\n } catch {\n return [];\n }\n let json: unknown;\n try {\n json = JSON.parse(raw);\n } catch {\n return [];\n }\n const parsed = StoreSchema.safeParse(json);\n return parsed.success ? parsed.data.searches : [];\n}\n\n/** Prepend a search (newest first), cap to MAX_ENTRIES, persist under a lock so\n * concurrent searches don't drop each other's entry. */\nexport async function recordSearch(dataDir: string, entry: StoredSearch): Promise<void> {\n await mkdir(dataDir, { recursive: true, mode: 0o700 });\n const lockPath = `${storePath(dataDir)}.lock`;\n await withFileLock(lockPath, async () => {\n const existing = await loadSearches(dataDir);\n const searches = [entry, ...existing.filter((l) => l.searchId !== entry.searchId)].slice(\n 0,\n MAX_ENTRIES,\n );\n await writeFileAtomic(\n storePath(dataDir),\n `${JSON.stringify({ schemaVersion: 1, searches }, null, 2)}\\n`,\n { mode: 0o644, dirMode: 0o700 },\n );\n });\n}\n\nexport async function latestSearch(dataDir: string): Promise<StoredSearch | null> {\n const searches = await loadSearches(dataDir);\n return searches[0] ?? null;\n}\n\n/** The stored candidate for a resourceId across recent searches (newest first). */\nexport async function findStoredCandidate(\n dataDir: string,\n resourceId: string,\n): Promise<StoredCandidate | null> {\n for (const search of await loadSearches(dataDir)) {\n const hit = search.candidates.find((c) => c.resourceId === resourceId);\n if (hit) return hit;\n }\n return null;\n}\n\n/** The most recent searchId that surfaced this resource (by id or url), for\n * purchase attribution (`X-Tenjin-Search-Id`). Null when no local search did. */\nexport async function findSearchForResource(\n dataDir: string,\n match: { resourceId?: string; url?: string },\n): Promise<string | null> {\n for (const search of await loadSearches(dataDir)) {\n const hit = search.candidates.some(\n (c) =>\n (match.resourceId !== undefined && c.resourceId === match.resourceId) ||\n (match.url !== undefined && c.url === match.url),\n );\n if (hit) return search.searchId;\n }\n return null;\n}\n"],"mappings":";;;;;;;;;;;;AAAA,SAAS,OAAO,gBAAgB;AAChC,SAAS,YAAY;AAarB,IAAM,cAAc;AAEpB,IAAM,wBAAwB,iBAAE,OAAO;AAAA,EACrC,YAAY,iBAAE,OAAO;AAAA,EACrB,KAAK,iBAAE,OAAO;AAAA,EACd,OAAO,iBAAE,OAAO;AAAA,EAChB,OAAO,iBAAE,OAAO;AAClB,CAAC;AAGD,IAAM,qBAAqB,iBAAE,OAAO;AAAA,EAClC,UAAU,iBAAE,OAAO;AAAA,EACnB,IAAI,iBAAE,OAAO;AAAA,EACb,UAAU,iBAAE,OAAO;AAAA,EACnB,UAAU,iBAAE,OAAO;AAAA,EACnB,YAAY,iBAAE,MAAM,qBAAqB;AAC3C,CAAC;AAGD,IAAM,cAAc,iBAAE,OAAO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C,MAAM,EAAE,eAAe,UAAU;AACrE,QAAI,IAAK,QAAO;AAAA,EAClB;AACA,SAAO;AACT;AAIA,eAAsB,sBACpB,SACA,OACwB;AACxB,aAAW,UAAU,MAAM,aAAa,OAAO,GAAG;AAChD,UAAM,MAAM,OAAO,WAAW;AAAA,MAC5B,CAAC,MACE,MAAM,eAAe,UAAa,EAAE,eAAe,MAAM,cACzD,MAAM,QAAQ,UAAa,EAAE,QAAQ,MAAM;AAAA,IAChD;AACA,QAAI,IAAK,QAAO,OAAO;AAAA,EACzB;AACA,SAAO;AACT;","names":[]}
|
|
@@ -1,41 +1,22 @@
|
|
|
1
1
|
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
fetchRead
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-5JH7ZB6Z.js";
|
|
5
5
|
import {
|
|
6
6
|
headingOutline
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-FU6MCSLG.js";
|
|
8
8
|
import {
|
|
9
9
|
resolveResourceRef
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-JPHG2JW3.js";
|
|
12
|
-
import "./chunk-YIYQ2ZNT.js";
|
|
13
|
-
import "./chunk-3OV7E5G5.js";
|
|
10
|
+
} from "./chunk-MM4TGTST.js";
|
|
14
11
|
import {
|
|
15
12
|
sanitizeForTerminal
|
|
16
|
-
} from "./chunk-
|
|
17
|
-
import "./chunk-QNP7H47L.js";
|
|
18
|
-
import "./chunk-N62ROTMC.js";
|
|
19
|
-
import "./chunk-RRN3YTK7.js";
|
|
20
|
-
import "./chunk-CYOF7ROH.js";
|
|
21
|
-
import "./chunk-ZABPQJ3M.js";
|
|
22
|
-
import "./chunk-HSDCI7OV.js";
|
|
13
|
+
} from "./chunk-VV4P5RVK.js";
|
|
23
14
|
import {
|
|
24
15
|
resolveContextSettings
|
|
25
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-FHB3VKZW.js";
|
|
26
17
|
import {
|
|
27
18
|
toMoney
|
|
28
|
-
} from "./chunk-
|
|
29
|
-
import "./chunk-YBMMV4Y4.js";
|
|
30
|
-
import "./chunk-UO22YNY4.js";
|
|
31
|
-
import "./chunk-MUBUQVC3.js";
|
|
32
|
-
import "./chunk-OYMYCW7J.js";
|
|
33
|
-
import "./chunk-RY4XKNV3.js";
|
|
34
|
-
import "./chunk-QVX5MWJZ.js";
|
|
35
|
-
import "./chunk-HIVZG55D.js";
|
|
36
|
-
import "./chunk-RBJPAZFI.js";
|
|
37
|
-
import "./chunk-5CLSD5YN.js";
|
|
38
|
-
import "./chunk-ZXTAQYNA.js";
|
|
19
|
+
} from "./chunk-BXUS5UCT.js";
|
|
39
20
|
|
|
40
21
|
// src/commands/inspect.ts
|
|
41
22
|
async function runInspect(args, ctx, deps = {}) {
|
|
@@ -90,7 +71,8 @@ async function runInspect(args, ctx, deps = {}) {
|
|
|
90
71
|
humanLines: [sanitizeForTerminal(result.message)]
|
|
91
72
|
};
|
|
92
73
|
}
|
|
74
|
+
|
|
93
75
|
export {
|
|
94
76
|
runInspect
|
|
95
77
|
};
|
|
96
|
-
//# sourceMappingURL=
|
|
78
|
+
//# sourceMappingURL=chunk-YFREUEUI.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/inspect.ts"],"sourcesContent":["import { resolveResourceRef } from '../lib/resource-ref';\nimport { resolveContextSettings } from '../lib/settings';\nimport { fetchRead } from '../lib/read-client';\nimport { toMoney } from '../lib/money';\nimport { headingOutline } from '../lib/markdown';\nimport { sanitizeForTerminal } from '../lib/output';\nimport type { CommandContext, CommandResult } from '../context';\n\n/**\n * `tenjin inspect <resource-url-or-id>`, fetch the pre-purchase answer card /\n * preview from the read route's 402 body WITHOUT paying (spec 10). A free\n * resource returns 200 with the whole body; a paid one returns the leak-safe\n * preview plus the advertised price/network. Never signs, never pays, never saves.\n */\n\nexport interface InspectArgs {\n ref: string;\n}\n\nexport interface InspectDeps {\n fetchImpl?: typeof fetch;\n}\n\nexport async function runInspect(\n args: InspectArgs,\n ctx: CommandContext,\n deps: InspectDeps = {},\n): Promise<CommandResult> {\n const settings = await resolveContextSettings(ctx);\n const ref = await resolveResourceRef(args.ref, ctx.dataDir, settings.baseUrl);\n\n const result = await fetchRead(ref.url, {\n timeoutMs: ctx.flags.timeout,\n ...(deps.fetchImpl !== undefined ? { fetchImpl: deps.fetchImpl } : {}),\n });\n\n if (result.kind === 'entitled') {\n // Free (or already-entitled) resource: the body is readable now, no payment.\n const body = result.body;\n return {\n data: {\n url: ref.url,\n resourceId: body.id,\n access: 'free',\n title: body.title,\n price: toMoney(body.price),\n headings: headingOutline(body.bodyMd),\n },\n humanLines: [\n `${sanitizeForTerminal(body.title)}, free (${body.price} atomic). Read it with \\`tenjin buy\\`.`,\n ],\n };\n }\n\n if (result.kind === 'payment_required') {\n const requirement = result.paymentRequired.accepts[0];\n const price = requirement !== undefined ? toMoney(requirement.amount) : undefined;\n return {\n data: {\n url: ref.url,\n ...(ref.resourceId !== undefined ? { resourceId: ref.resourceId } : {}),\n access: 'paid',\n ...(price !== undefined ? { price } : {}),\n payment:\n requirement !== undefined\n ? {\n scheme: requirement.scheme,\n network: requirement.network,\n asset: requirement.asset,\n payTo: requirement.payTo,\n amount: requirement.amount,\n }\n : undefined,\n preview: result.preview,\n },\n humanLines: [\n `Paid resource${price !== undefined ? `, ${price.usd} USD (${price.atomic} atomic)` : ''}.`,\n 'This is the pre-purchase card; run `tenjin buy` to pay and read.',\n ],\n };\n }\n\n // already_purchased without a payment header is unexpected; report it plainly.\n return {\n data: { url: ref.url, access: 'entitled', message: result.message },\n humanLines: [sanitizeForTerminal(result.message)],\n };\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/commands/inspect.ts"],"sourcesContent":["import { resolveResourceRef } from '../lib/resource-ref';\nimport { resolveContextSettings } from '../lib/settings';\nimport { fetchRead } from '../lib/read-client';\nimport { toMoney } from '../lib/money';\nimport { headingOutline } from '../lib/markdown';\nimport { sanitizeForTerminal } from '../lib/output';\nimport type { CommandContext, CommandResult } from '../context';\n\n/**\n * `tenjin inspect <resource-url-or-id>`, fetch the pre-purchase answer card /\n * preview from the read route's 402 body WITHOUT paying (spec 10). A free\n * resource returns 200 with the whole body; a paid one returns the leak-safe\n * preview plus the advertised price/network. Never signs, never pays, never saves.\n */\n\nexport interface InspectArgs {\n ref: string;\n}\n\nexport interface InspectDeps {\n fetchImpl?: typeof fetch;\n}\n\nexport async function runInspect(\n args: InspectArgs,\n ctx: CommandContext,\n deps: InspectDeps = {},\n): Promise<CommandResult> {\n const settings = await resolveContextSettings(ctx);\n const ref = await resolveResourceRef(args.ref, ctx.dataDir, settings.baseUrl);\n\n const result = await fetchRead(ref.url, {\n timeoutMs: ctx.flags.timeout,\n ...(deps.fetchImpl !== undefined ? { fetchImpl: deps.fetchImpl } : {}),\n });\n\n if (result.kind === 'entitled') {\n // Free (or already-entitled) resource: the body is readable now, no payment.\n const body = result.body;\n return {\n data: {\n url: ref.url,\n resourceId: body.id,\n access: 'free',\n title: body.title,\n price: toMoney(body.price),\n headings: headingOutline(body.bodyMd),\n },\n humanLines: [\n `${sanitizeForTerminal(body.title)}, free (${body.price} atomic). Read it with \\`tenjin buy\\`.`,\n ],\n };\n }\n\n if (result.kind === 'payment_required') {\n const requirement = result.paymentRequired.accepts[0];\n const price = requirement !== undefined ? toMoney(requirement.amount) : undefined;\n return {\n data: {\n url: ref.url,\n ...(ref.resourceId !== undefined ? { resourceId: ref.resourceId } : {}),\n access: 'paid',\n ...(price !== undefined ? { price } : {}),\n payment:\n requirement !== undefined\n ? {\n scheme: requirement.scheme,\n network: requirement.network,\n asset: requirement.asset,\n payTo: requirement.payTo,\n amount: requirement.amount,\n }\n : undefined,\n preview: result.preview,\n },\n humanLines: [\n `Paid resource${price !== undefined ? `, ${price.usd} USD (${price.atomic} atomic)` : ''}.`,\n 'This is the pre-purchase card; run `tenjin buy` to pay and read.',\n ],\n };\n }\n\n // already_purchased without a payment header is unexpected; report it plainly.\n return {\n data: { url: ref.url, access: 'entitled', message: result.message },\n humanLines: [sanitizeForTerminal(result.message)],\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAuBA,eAAsB,WACpB,MACA,KACA,OAAoB,CAAC,GACG;AACxB,QAAM,WAAW,MAAM,uBAAuB,GAAG;AACjD,QAAM,MAAM,MAAM,mBAAmB,KAAK,KAAK,IAAI,SAAS,SAAS,OAAO;AAE5E,QAAM,SAAS,MAAM,UAAU,IAAI,KAAK;AAAA,IACtC,WAAW,IAAI,MAAM;AAAA,IACrB,GAAI,KAAK,cAAc,SAAY,EAAE,WAAW,KAAK,UAAU,IAAI,CAAC;AAAA,EACtE,CAAC;AAED,MAAI,OAAO,SAAS,YAAY;AAE9B,UAAM,OAAO,OAAO;AACpB,WAAO;AAAA,MACL,MAAM;AAAA,QACJ,KAAK,IAAI;AAAA,QACT,YAAY,KAAK;AAAA,QACjB,QAAQ;AAAA,QACR,OAAO,KAAK;AAAA,QACZ,OAAO,QAAQ,KAAK,KAAK;AAAA,QACzB,UAAU,eAAe,KAAK,MAAM;AAAA,MACtC;AAAA,MACA,YAAY;AAAA,QACV,GAAG,oBAAoB,KAAK,KAAK,CAAC,WAAW,KAAK,KAAK;AAAA,MACzD;AAAA,IACF;AAAA,EACF;AAEA,MAAI,OAAO,SAAS,oBAAoB;AACtC,UAAM,cAAc,OAAO,gBAAgB,QAAQ,CAAC;AACpD,UAAM,QAAQ,gBAAgB,SAAY,QAAQ,YAAY,MAAM,IAAI;AACxE,WAAO;AAAA,MACL,MAAM;AAAA,QACJ,KAAK,IAAI;AAAA,QACT,GAAI,IAAI,eAAe,SAAY,EAAE,YAAY,IAAI,WAAW,IAAI,CAAC;AAAA,QACrE,QAAQ;AAAA,QACR,GAAI,UAAU,SAAY,EAAE,MAAM,IAAI,CAAC;AAAA,QACvC,SACE,gBAAgB,SACZ;AAAA,UACE,QAAQ,YAAY;AAAA,UACpB,SAAS,YAAY;AAAA,UACrB,OAAO,YAAY;AAAA,UACnB,OAAO,YAAY;AAAA,UACnB,QAAQ,YAAY;AAAA,QACtB,IACA;AAAA,QACN,SAAS,OAAO;AAAA,MAClB;AAAA,MACA,YAAY;AAAA,QACV,gBAAgB,UAAU,SAAY,KAAK,MAAM,GAAG,SAAS,MAAM,MAAM,aAAa,EAAE;AAAA,QACxF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAGA,SAAO;AAAA,IACL,MAAM,EAAE,KAAK,IAAI,KAAK,QAAQ,YAAY,SAAS,OAAO,QAAQ;AAAA,IAClE,YAAY,CAAC,oBAAoB,OAAO,OAAO,CAAC;AAAA,EAClD;AACF;","names":[]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
keccak_256
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-XJN5WUKL.js";
|
|
5
5
|
import {
|
|
6
6
|
bytesToHex
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-KYQVEKP5.js";
|
|
8
8
|
import {
|
|
9
9
|
__commonJS,
|
|
10
10
|
__require,
|
|
@@ -7803,4 +7803,4 @@ export {
|
|
|
7803
7803
|
p2 as p,
|
|
7804
7804
|
m2 as m
|
|
7805
7805
|
};
|
|
7806
|
-
//# sourceMappingURL=chunk-
|
|
7806
|
+
//# sourceMappingURL=chunk-YLYINX2H.js.map
|
|
@@ -3,15 +3,15 @@ import {
|
|
|
3
3
|
defaultIo,
|
|
4
4
|
emitFailure,
|
|
5
5
|
emitSuccess
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-VV4P5RVK.js";
|
|
7
7
|
import {
|
|
8
8
|
package_default
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-QH6677FJ.js";
|
|
10
10
|
import {
|
|
11
11
|
CliError,
|
|
12
12
|
dataDir,
|
|
13
13
|
external_exports
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-6WWVYYSB.js";
|
|
15
15
|
import {
|
|
16
16
|
__commonJS,
|
|
17
17
|
__require,
|
|
@@ -3526,15 +3526,18 @@ function buildProgram(io, setExit) {
|
|
|
3526
3526
|
).option("--dry-run", "print what would change without writing anything").option(
|
|
3527
3527
|
"--publish-mode <mode>",
|
|
3528
3528
|
"set the publish consent mode non-interactively: review | auto | full-auto"
|
|
3529
|
-
).action(async function() {
|
|
3529
|
+
).option("--no-wallet", "skip the wallet-setup step of the interactive walkthrough").option("--claude-md", "append the Tenjin search nudge to ~/.claude/CLAUDE.md").option("--no-claude-md", "skip the CLAUDE.md nudge (and its interactive question)").action(async function() {
|
|
3530
3530
|
await runCommand("install", this, async (ctx) => {
|
|
3531
3531
|
const o = this.opts();
|
|
3532
|
-
const
|
|
3532
|
+
const claudeMdGiven = this.getOptionValueSource("claudeMd") !== "default";
|
|
3533
|
+
const { runInstall } = await import("./install-7J6KKEEP.js");
|
|
3533
3534
|
return runInstall(
|
|
3534
3535
|
{
|
|
3535
3536
|
...Array.isArray(o.harness) && o.harness.length > 0 ? { harness: o.harness } : {},
|
|
3536
3537
|
...o.dryRun === true ? { dryRun: true } : {},
|
|
3537
|
-
...typeof o.publishMode === "string" ? { publishMode: o.publishMode } : {}
|
|
3538
|
+
...typeof o.publishMode === "string" ? { publishMode: o.publishMode } : {},
|
|
3539
|
+
...o.wallet === false ? { noWallet: true } : {},
|
|
3540
|
+
...claudeMdGiven && typeof o.claudeMd === "boolean" ? { claudeMd: o.claudeMd } : {}
|
|
3538
3541
|
},
|
|
3539
3542
|
ctx
|
|
3540
3543
|
);
|
|
@@ -3542,7 +3545,7 @@ function buildProgram(io, setExit) {
|
|
|
3542
3545
|
});
|
|
3543
3546
|
addGlobalFlags(program2.command("doctor")).description("Check the local environment and Tenjin API reachability").action(async function() {
|
|
3544
3547
|
await runCommand("doctor", this, async (ctx) => {
|
|
3545
|
-
const { runDoctor } = await import("./doctor-
|
|
3548
|
+
const { runDoctor } = await import("./doctor-XDA3YU6H.js");
|
|
3546
3549
|
return runDoctor(ctx);
|
|
3547
3550
|
});
|
|
3548
3551
|
});
|
|
@@ -3551,19 +3554,19 @@ function buildProgram(io, setExit) {
|
|
|
3551
3554
|
);
|
|
3552
3555
|
config.action(async function() {
|
|
3553
3556
|
await runCommand("config", this, async (ctx) => {
|
|
3554
|
-
const { runConfigList } = await import("./config-
|
|
3557
|
+
const { runConfigList } = await import("./config-DBEEM3UA.js");
|
|
3555
3558
|
return runConfigList(ctx);
|
|
3556
3559
|
});
|
|
3557
3560
|
});
|
|
3558
3561
|
addGlobalFlags(config.command("get <key>")).description("Print one effective config value").action(async function(key) {
|
|
3559
3562
|
await runCommand("config.get", this, async (ctx) => {
|
|
3560
|
-
const { runConfigGet } = await import("./config-
|
|
3563
|
+
const { runConfigGet } = await import("./config-DBEEM3UA.js");
|
|
3561
3564
|
return runConfigGet({ key }, ctx);
|
|
3562
3565
|
});
|
|
3563
3566
|
});
|
|
3564
3567
|
addGlobalFlags(config.command("set <key> <value>")).description("Set a config value (decimal USD accepted for spend keys)").action(async function(key, value) {
|
|
3565
3568
|
await runCommand("config.set", this, async (ctx) => {
|
|
3566
|
-
const { runConfigSet } = await import("./config-
|
|
3569
|
+
const { runConfigSet } = await import("./config-DBEEM3UA.js");
|
|
3567
3570
|
return runConfigSet({ key, value }, ctx);
|
|
3568
3571
|
});
|
|
3569
3572
|
});
|
|
@@ -3572,29 +3575,29 @@ function buildProgram(io, setExit) {
|
|
|
3572
3575
|
);
|
|
3573
3576
|
addGlobalFlags(wallet.command("create")).description("Create a new local wallet").action(async function() {
|
|
3574
3577
|
await runCommand("wallet.create", this, async (ctx) => {
|
|
3575
|
-
const { runWalletCreate } = await import("./wallet-
|
|
3578
|
+
const { runWalletCreate } = await import("./wallet-UWHSHWC6.js");
|
|
3576
3579
|
return runWalletCreate(ctx);
|
|
3577
3580
|
});
|
|
3578
3581
|
});
|
|
3579
3582
|
addGlobalFlags(wallet.command("show")).description("Show the wallet address and key source (never the key)").action(async function() {
|
|
3580
3583
|
await runCommand("wallet.show", this, async (ctx) => {
|
|
3581
|
-
const { runWalletShow } = await import("./wallet-
|
|
3584
|
+
const { runWalletShow } = await import("./wallet-UWHSHWC6.js");
|
|
3582
3585
|
return runWalletShow(ctx);
|
|
3583
3586
|
});
|
|
3584
3587
|
});
|
|
3585
3588
|
addGlobalFlags(wallet.command("balance")).description("Show the wallet USDC balance on Base").action(async function() {
|
|
3586
3589
|
await runCommand("wallet.balance", this, async (ctx) => {
|
|
3587
|
-
const { runWalletBalance } = await import("./wallet-
|
|
3590
|
+
const { runWalletBalance } = await import("./wallet-UWHSHWC6.js");
|
|
3588
3591
|
return runWalletBalance(ctx);
|
|
3589
3592
|
});
|
|
3590
3593
|
});
|
|
3591
|
-
addGlobalFlags(program2.command("
|
|
3594
|
+
addGlobalFlags(program2.command("search <question>")).description(
|
|
3592
3595
|
"Ask for payable candidates or an honest MISS. Use when a task needs public knowledge someone may already have published; send only a generalized public question, never secrets or private context"
|
|
3593
3596
|
).option("--max-price <usd>", "only candidates at or below this decimal-USD price").option("--fresh-within <window>", "freshness window, e.g. P30D, P2W, P1Y").option("--limit <n>", "maximum candidates (1-10, default 5)").option("--applies-to <pair>", "applicability filter key=value (repeatable)", collect, []).action(async function(question) {
|
|
3594
|
-
await runCommand("
|
|
3597
|
+
await runCommand("search", this, async (ctx) => {
|
|
3595
3598
|
const o = this.opts();
|
|
3596
|
-
const {
|
|
3597
|
-
return
|
|
3599
|
+
const { runSearch } = await import("./search-R6NIQFXI.js");
|
|
3600
|
+
return runSearch(
|
|
3598
3601
|
{
|
|
3599
3602
|
question,
|
|
3600
3603
|
...typeof o.maxPrice === "string" ? { maxPrice: o.maxPrice } : {},
|
|
@@ -3607,10 +3610,10 @@ function buildProgram(io, setExit) {
|
|
|
3607
3610
|
});
|
|
3608
3611
|
});
|
|
3609
3612
|
addGlobalFlags(program2.command("inspect <resource>")).description(
|
|
3610
|
-
"Show a candidate's pre-purchase card / preview. Use after
|
|
3613
|
+
"Show a candidate's pre-purchase card / preview. Use after search, before buy, to check price, scope, and freshness; it never pays"
|
|
3611
3614
|
).action(async function(resource) {
|
|
3612
3615
|
await runCommand("inspect", this, async (ctx) => {
|
|
3613
|
-
const { runInspect } = await import("./inspect-
|
|
3616
|
+
const { runInspect } = await import("./inspect-YBGDAG47.js");
|
|
3614
3617
|
return runInspect({ ref: resource }, ctx);
|
|
3615
3618
|
});
|
|
3616
3619
|
});
|
|
@@ -3622,7 +3625,7 @@ function buildProgram(io, setExit) {
|
|
|
3622
3625
|
).action(async function(resource) {
|
|
3623
3626
|
await runCommand("buy", this, async (ctx) => {
|
|
3624
3627
|
const o = this.opts();
|
|
3625
|
-
const { runBuy } = await import("./buy-
|
|
3628
|
+
const { runBuy } = await import("./buy-OOOLUDND.js");
|
|
3626
3629
|
return runBuy(
|
|
3627
3630
|
{
|
|
3628
3631
|
ref: resource,
|
|
@@ -3643,7 +3646,7 @@ function buildProgram(io, setExit) {
|
|
|
3643
3646
|
).option("--draft", "save as a private draft instead of publishing").option("--yes", "clear soft findings and the review confirm (never a hard block)").option("--mode <mode>", "consent mode for this run: review | auto | full-auto").option("--price <usd>", "post price in decimal USD (defaults to publish.defaultPrice)").option("--question <text>", "a question this piece answers (repeatable)", collect, []).option("--task <text>", "a task this piece supports (repeatable)", collect, []).option("--scope <text>", "what the piece covers (card scope)").option("--exclusions <text>", "what the piece does not cover (card exclusions)").option("--applies-to <pair>", "applicability key=value (repeatable)", collect, []).option("--as-of <iso>", "as-of timestamp, ISO-8601 with offset").option("--valid-until <iso>", "valid-until timestamp, ISO-8601 with offset").option("--artifact-type <type>", "document | skill | dataset").option("--temporal-mode <mode>", "snapshot | maintained | evergreen").option("--provenance <text>", "provenance summary (card)").option("--methodology <text>", "methodology summary (card)").action(async function(file) {
|
|
3644
3647
|
await runCommand("publish", this, async (ctx) => {
|
|
3645
3648
|
const o = this.opts();
|
|
3646
|
-
const { runPublish } = await import("./publish-
|
|
3649
|
+
const { runPublish } = await import("./publish-IH7RJXGB.js");
|
|
3647
3650
|
return runPublish(
|
|
3648
3651
|
{
|
|
3649
3652
|
...typeof file === "string" ? { file } : {},
|
|
@@ -3669,18 +3672,18 @@ function buildProgram(io, setExit) {
|
|
|
3669
3672
|
});
|
|
3670
3673
|
});
|
|
3671
3674
|
addGlobalFlags(program2.command("outcome")).description(
|
|
3672
|
-
"Report how a
|
|
3673
|
-
).option("--
|
|
3675
|
+
"Report how a search ended, honestly (used, partially_used, rejected, regenerated, purchase_declined). Use after acting on a search; this closes the loop the marketplace learns from"
|
|
3676
|
+
).option("--search-id <id>", "the search to report against").option("--last", "target the most recent local search").requiredOption(
|
|
3674
3677
|
"--status <status>",
|
|
3675
3678
|
"used | partially_used | rejected | regenerated | purchase_declined"
|
|
3676
3679
|
).option("--resource <id>", "the resourceId the outcome concerns").option("--content-hash <hash>", "sha256:<64hex> of the exact body read").action(async function() {
|
|
3677
3680
|
await runCommand("outcome", this, async (ctx) => {
|
|
3678
3681
|
const o = this.opts();
|
|
3679
|
-
const { runOutcome } = await import("./outcome-
|
|
3682
|
+
const { runOutcome } = await import("./outcome-ZFGHX2XW.js");
|
|
3680
3683
|
return runOutcome(
|
|
3681
3684
|
{
|
|
3682
3685
|
status: String(o.status),
|
|
3683
|
-
...typeof o.
|
|
3686
|
+
...typeof o.searchId === "string" ? { searchId: o.searchId } : {},
|
|
3684
3687
|
...o.last === true ? { last: true } : {},
|
|
3685
3688
|
...typeof o.resource === "string" ? { resource: o.resource } : {},
|
|
3686
3689
|
...typeof o.contentHash === "string" ? { contentHash: o.contentHash } : {}
|
|
@@ -3694,14 +3697,14 @@ function buildProgram(io, setExit) {
|
|
|
3694
3697
|
"Manage local publish candidates (parked drafts; nothing uploads until publish)"
|
|
3695
3698
|
)
|
|
3696
3699
|
);
|
|
3697
|
-
addGlobalFlags(candidate.command("add <file>")).description("Park a Markdown draft as a publish candidate, tied to a
|
|
3700
|
+
addGlobalFlags(candidate.command("add <file>")).description("Park a Markdown draft as a publish candidate, tied to a search").requiredOption("--search-id <id>", "the search whose unmet demand this draft answers").option("--question <q>", "the question this draft answers").action(async function(file) {
|
|
3698
3701
|
await runCommand("candidate.add", this, async (ctx) => {
|
|
3699
3702
|
const o = this.opts();
|
|
3700
|
-
const { runCandidateAdd } = await import("./candidate-
|
|
3703
|
+
const { runCandidateAdd } = await import("./candidate-TWCWTFGA.js");
|
|
3701
3704
|
return runCandidateAdd(
|
|
3702
3705
|
{
|
|
3703
3706
|
file,
|
|
3704
|
-
|
|
3707
|
+
searchId: String(o.searchId),
|
|
3705
3708
|
...typeof o.question === "string" ? { question: o.question } : {}
|
|
3706
3709
|
},
|
|
3707
3710
|
ctx
|
|
@@ -3710,16 +3713,21 @@ function buildProgram(io, setExit) {
|
|
|
3710
3713
|
});
|
|
3711
3714
|
addGlobalFlags(candidate.command("list")).description("List pending candidates, newest first").action(async function() {
|
|
3712
3715
|
await runCommand("candidate.list", this, async (ctx) => {
|
|
3713
|
-
const { runCandidateList } = await import("./candidate-
|
|
3716
|
+
const { runCandidateList } = await import("./candidate-TWCWTFGA.js");
|
|
3714
3717
|
return runCandidateList(ctx);
|
|
3715
3718
|
});
|
|
3716
3719
|
});
|
|
3717
3720
|
addGlobalFlags(candidate.command("drop <id>")).description("Discard a pending candidate (never auto-deleted)").action(async function(id) {
|
|
3718
3721
|
await runCommand("candidate.drop", this, async (ctx) => {
|
|
3719
|
-
const { runCandidateDrop } = await import("./candidate-
|
|
3722
|
+
const { runCandidateDrop } = await import("./candidate-TWCWTFGA.js");
|
|
3720
3723
|
return runCandidateDrop({ id }, ctx);
|
|
3721
3724
|
});
|
|
3722
3725
|
});
|
|
3726
|
+
addGlobalFlags(program2.command("mcp")).description("Run a local stdio MCP server exposing the Tenjin command cores to an MCP client").action(async function() {
|
|
3727
|
+
const ctx = buildContext(this, io);
|
|
3728
|
+
const { runMcpServer } = await import("./run-DCZFEW2C.js");
|
|
3729
|
+
await runMcpServer({ dataDir: ctx.dataDir, flags: ctx.flags });
|
|
3730
|
+
});
|
|
3723
3731
|
return program2;
|
|
3724
3732
|
}
|
|
3725
3733
|
function collect(value, previous) {
|
|
@@ -3739,15 +3747,18 @@ async function main(argv, io = defaultIo()) {
|
|
|
3739
3747
|
}
|
|
3740
3748
|
function handleParseError(err, io, program2) {
|
|
3741
3749
|
const json = program2.opts().json === true;
|
|
3750
|
+
const humanFirst = io.isTTY && !json;
|
|
3742
3751
|
if (err instanceof CommanderError) {
|
|
3743
3752
|
if (err.code === "commander.version" || err.code === "commander.helpDisplayed") {
|
|
3744
3753
|
return 0;
|
|
3745
3754
|
}
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3755
|
+
if (!humanFirst) {
|
|
3756
|
+
const message = err.code === "commander.help" ? "No command specified" : err.message.replace(/^error:\s*/i, "");
|
|
3757
|
+
const usageErr = new CliError("USAGE", message, {
|
|
3758
|
+
fix: "Run `tenjin --help` for available commands."
|
|
3759
|
+
});
|
|
3760
|
+
emitFailure(io, "tenjin", usageErr, { json: true });
|
|
3761
|
+
}
|
|
3751
3762
|
return 2;
|
|
3752
3763
|
}
|
|
3753
3764
|
return emitFailure(io, "tenjin", err, { json }).exitCode;
|
|
@@ -3756,4 +3767,4 @@ export {
|
|
|
3756
3767
|
buildProgram,
|
|
3757
3768
|
main
|
|
3758
3769
|
};
|
|
3759
|
-
//# sourceMappingURL=cli-
|
|
3770
|
+
//# sourceMappingURL=cli-AFSLAKR6.js.map
|