@opencraw/cli 0.1.50 → 0.1.52

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.
@@ -0,0 +1,2 @@
1
+ export { resolveAccess } from './resolve-access.use-case';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,12 @@
1
+ import type { AccessConfig } from '@opencraw/core';
2
+ import type { CommonOptions } from '../arguments';
3
+ /**
4
+ * The access config a command runs with: the file `--access` (or
5
+ * `OPENCRAW_ACCESS`) names, with `--access-profile` as its default.
6
+ *
7
+ * @param options - The command's shared options.
8
+ * @returns The config, or `undefined` for direct access.
9
+ * @throws Error when a profile is asked for without a config, or is not in it.
10
+ */
11
+ export declare function resolveAccess(options: CommonOptions): Promise<AccessConfig | undefined>;
12
+ //# sourceMappingURL=resolve-access.use-case.d.ts.map
@@ -0,0 +1,86 @@
1
+ /** Options every command shares. */
2
+ export interface CommonOptions {
3
+ /** A browser binary other than the one Playwright installed. */
4
+ browserPath?: string;
5
+ /** Accept an intercepting proxy's certificate. */
6
+ insecureTls: boolean;
7
+ /** A user agent for requests and the browser. */
8
+ userAgent?: string;
9
+ /** An access config file (proxy profiles); `OPENCRAW_ACCESS` when not given. */
10
+ access?: string;
11
+ /** The access profile to use by default, overriding the config's `default`. */
12
+ accessProfile?: string;
13
+ /** A plugins module: hooks, access plugins; `--hooks` / `OPENCRAW_PLUGINS` / `OPENCRAW_HOOKS` too. */
14
+ plugins?: string;
15
+ }
16
+ export type Command = {
17
+ name: 'help';
18
+ } | {
19
+ name: 'version';
20
+ } | {
21
+ name: 'validate';
22
+ paths: string[];
23
+ } | {
24
+ name: 'export';
25
+ /** A finished run's JSON Lines file. */
26
+ records: string;
27
+ /** The output recipe the records were mapped to: it names the columns. */
28
+ output: string;
29
+ /** The file to write; its extension is the format. */
30
+ out: string;
31
+ options: CommonOptions;
32
+ } | {
33
+ name: 'diff';
34
+ previous: string;
35
+ current: string;
36
+ /** The fields that identify a record; empty uses each line's `_key`. */
37
+ key: string[];
38
+ /** Fields left out of the comparison. */
39
+ ignore: string[];
40
+ /** Where to write the changes as JSON Lines. */
41
+ changes?: string;
42
+ } | {
43
+ name: 'run';
44
+ paths: string[];
45
+ /** A JSON Lines file; records go to stdout without it. */
46
+ out?: string;
47
+ append: boolean;
48
+ resume: boolean;
49
+ trace: boolean;
50
+ /** One record per input, with the scope it was mapped from. */
51
+ dryRun: boolean;
52
+ /** Run only the input recipes with these ids. */
53
+ only: string[];
54
+ headed: boolean;
55
+ /** A previous run's JSON Lines file to compare this run's records with. */
56
+ diff?: string;
57
+ /** Where to write the changes `diff` finds, as JSON Lines. */
58
+ changes?: string;
59
+ /** How many input recipes run at once. */
60
+ parallel?: number;
61
+ /** Tries per request for recipes whose `limits.retry` says nothing (1 turns retrying off). */
62
+ retries?: number;
63
+ /** Where `session.browserProfile` profiles live; `OPENCRAW_PROFILES` when not given. */
64
+ profiles?: string;
65
+ /** Per-site politeness across every recipe: overrides the access config's `throttle` defaults. */
66
+ throttle: {
67
+ delayMs?: number;
68
+ concurrency?: number;
69
+ };
70
+ options: CommonOptions;
71
+ } | {
72
+ name: 'probe';
73
+ url: string;
74
+ /** Also render the page in a browser and watch the JSON it fetches. */
75
+ browser: boolean;
76
+ options: CommonOptions;
77
+ } | {
78
+ name: 'studio';
79
+ /** The recipe folder to open; the current directory when not given. */
80
+ folder?: string;
81
+ /** A hooks or plugins module to run recipes with (`--hooks`, `--plugins`, `OPENCRAW_HOOKS`, `OPENCRAW_PLUGINS`; issue #150). */
82
+ plugins?: string;
83
+ /** A folder, recipe file or document the printed link opens straight away (`--open`, issue #235). */
84
+ open?: string;
85
+ };
86
+ //# sourceMappingURL=command.contract.d.ts.map
@@ -0,0 +1,3 @@
1
+ export type { Command, CommonOptions } from './command.contract';
2
+ export { parseArguments, USAGE } from './parse-arguments.algorithm';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,12 @@
1
+ import type { Command } from './command.contract';
2
+ export declare const USAGE = "opencraw <command> [options]\n\nCommands\n validate <recipe files or directories...> Parse and bind the recipes; list every problem with its path.\n run <recipe files or directories...> Crawl. Records go to --out (its extension picks the format), or to stdout as JSON Lines.\n probe <url> Fetch a page and report where its data lives.\n diff <previous.jsonl> <current.jsonl> Compare two runs' records by key: added, removed, changed.\n export <records.jsonl> <output recipe> --out <file>\n Write a finished run's records again in another format (the extension\n of --out chooses it, as for run).\n studio [folder] [--open <path>] Open a recipe folder in the browser: run samples, read\n the trace next to the page (needs @opencraw/studio).\n --open prints a link that opens a folder, recipe or\n document straight away.\n\nOptions for run\n --out <file> Write records to this file; the extension is the format: .jsonl, .json, .csv, .xlsx, .yml/.yaml,\n .html (a page that looks like Studio) or .pdf (that page, printed; needs Chromium). Any other\n extension is an error. Default: stdout as JSON Lines.\n --append Keep what --out holds and add to it (each line carries _key); .jsonl only.\n --resume Skip records --out already has (needs --append).\n --only <id> Run only this input recipe (repeatable).\n --dry-run One record per input, printed with the scope it was mapped from.\n --trace Print the crawl trace to stderr.\n --headed Show the browser.\n --parallel <n> Run this many input recipes at once (default 1). Iterations inside a recipe\n follow its limits.concurrency.\n --retries <n> Tries per request that fails in passing (connection, timeout, 429, 5xx), for\n recipes whose limits.retry says nothing. Default 3; 1 turns retrying off.\n --profiles <dir> Where recipes' session.browserProfile profiles live (or OPENCRAW_PROFILES;\n default .opencraw/profiles).\n --diff <file> Compare this run's records with a previous run's JSON Lines file (it may be\n --out itself: it is read before the crawl). Keys come from the output recipe.\n --host-delay <ms> At least this long between two requests to one site, across every recipe.\n --host-concurrency <n>\n At most this many requests to one site in flight, across every recipe.\n Both override the access config's \"throttle\" defaults.\n\nOptions for diff\n --key <a,b> The fields that identify a record (default: each line's _key).\n --ignore <a,b> Fields left out of the comparison (a date the crawl stamps, say).\n --changes <file> Also write every change as a JSON line (run --diff takes it too).\n\nOptions for probe\n --browser Also render the page in a browser and list the JSON it fetches.\n\nOptions for both\n --browser-path <p> A browser binary other than the one Playwright installed (or OPENCRAW_CHROMIUM).\n --insecure-tls Accept an intercepting proxy's certificate (or OPENCRAW_INSECURE_TLS=1).\n --user-agent <ua> The user agent to send.\n --access <file> An access config: proxy profiles, credentials as {{env.NAME}} (or OPENCRAW_ACCESS).\n --access-profile <name>\n The access profile to use when a recipe names none.\n --plugins <file> A JavaScript module exporting hooks (the recipes' hook steps and transforms),\n accessPlugins (for { kind: \"plugin\" } access profiles) and captchaSolvers\n (for session.captcha and captcha steps); --hooks, or OPENCRAW_PLUGINS /\n OPENCRAW_HOOKS. It runs as your code: trust it.\n --help, --version";
3
+ /**
4
+ * Turns argv into a command.
5
+ *
6
+ * @param argv - The arguments after the program name.
7
+ * @param env - The environment, for the defaults some options have.
8
+ * @returns The command.
9
+ * @throws Error with a usage message on bad input.
10
+ */
11
+ export declare function parseArguments(argv: readonly string[], env?: Record<string, string | undefined>): Command;
12
+ //# sourceMappingURL=parse-arguments.algorithm.d.ts.map
@@ -0,0 +1,22 @@
1
+ import type { RecordDiff } from '@opencraw/core';
2
+ import type { Command } from '../arguments';
3
+ import type { Terminal } from '../terminal';
4
+ /**
5
+ * Compares two runs' JSON Lines files and prints what changed; with
6
+ * `--changes`, writes every change as a JSON line too.
7
+ *
8
+ * @param command - The parsed `diff` command.
9
+ * @param terminal - Where the report goes.
10
+ * @returns The exit code: 0, or 1 when a file cannot be read or has no key.
11
+ */
12
+ export declare function diffFiles(command: Extract<Command, {
13
+ name: 'diff';
14
+ }>, terminal: Terminal): Promise<number>;
15
+ /**
16
+ * Writes a diff's changes as JSON Lines: `{ change, key, before?, after?, fields? }`.
17
+ *
18
+ * @param path - The file.
19
+ * @param diff - The diff.
20
+ */
21
+ export declare function writeChanges(path: string, diff: RecordDiff): Promise<void>;
22
+ //# sourceMappingURL=diff-files.use-case.d.ts.map
@@ -0,0 +1,12 @@
1
+ import type { RecordDiff } from '@opencraw/core';
2
+ /**
3
+ * A diff as people read it: the counts, a warning when the run lost most of
4
+ * its records, then one line per change, `-` removed, `~` changed (with each
5
+ * field's before → after), `+` added.
6
+ *
7
+ * @param diff - The diff.
8
+ * @param limit - Changes listed at most.
9
+ * @returns The lines.
10
+ */
11
+ export declare function diffReport(diff: RecordDiff, limit?: number): string[];
12
+ //# sourceMappingURL=diff-report.mapper.d.ts.map
@@ -0,0 +1,3 @@
1
+ export { diffFiles, writeChanges } from './diff-files.use-case';
2
+ export { diffReport } from './diff-report.mapper';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,14 @@
1
+ import type { Command } from '../arguments';
2
+ import type { Terminal } from '../terminal';
3
+ /**
4
+ * Writes a finished run's JSON Lines file again in another format: the extension of `--out` chooses it, as it does for `run`. The output recipe
5
+ * supplies the columns (its fields, in order, with their types and descriptions).
6
+ *
7
+ * @param command - The parsed `export` command.
8
+ * @param terminal - Where the result and errors go.
9
+ * @returns The exit code: 0, or 1 when a file cannot be read, the recipe is not an output recipe, or the extension names no format.
10
+ */
11
+ export declare function exportRecords(command: Extract<Command, {
12
+ name: 'export';
13
+ }>, terminal: Terminal): Promise<number>;
14
+ //# sourceMappingURL=export-records.use-case.d.ts.map
@@ -0,0 +1,2 @@
1
+ export { exportRecords } from './export-records.use-case';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,3 @@
1
+ export { loadHooks, loadPlugins } from './load-hooks.repository';
2
+ export type { ModuleImporter, PluginModule } from './load-hooks.repository';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,47 @@
1
+ import type { AccessPlugin, CaptchaSolver, HookMap } from '@opencraw/core';
2
+ /** What a plugins module provides: hooks for `hook` steps and transforms, and plugins the engine calls. */
3
+ export interface PluginModule {
4
+ hooks: HookMap;
5
+ /** Access plugins: `{ kind: "plugin", name }` profiles in the access config use them. */
6
+ accessPlugins: AccessPlugin[];
7
+ /** Captcha solvers: recipes name them in `session.captcha.solver` and `captcha` steps. */
8
+ captchaSolvers: CaptchaSolver[];
9
+ }
10
+ /**
11
+ * Loads a plugins module: a JavaScript module whose named exports `hooks`
12
+ * (`{ name: function }`), `accessPlugins` (`[{ name, lease }]`) and
13
+ * `captchaSolvers` (`[{ name, solve }]`) give what recipes and access profiles
14
+ * refer to by name:
15
+ *
16
+ * ```js
17
+ * export const hooks = { positive: v => v > 0 }
18
+ * export const accessPlugins = [{ name: 'browserbase', lease: async () => ({ cdp: { endpoint } }) }]
19
+ * export const captchaSolvers = [{ name: 'capsolver', solve: async (challenge, { page }) => ({ status: 'solved' }) }]
20
+ * ```
21
+ *
22
+ * A module with none of those names is a bare hooks module, as before: its
23
+ * default export when that is an object of functions, else its named function
24
+ * exports.
25
+ *
26
+ * The module runs with the caller's privileges, like any code the caller
27
+ * imports: point this only at a file you trust.
28
+ *
29
+ * @param path - A `.mjs` / `.js` / `.cjs` file, or a `.ts` / `.mts` file on a Node that strips types (22.18+).
30
+ * @param importModule - How to import it; `import()` unless a test says otherwise.
31
+ * @returns The hooks and plugins.
32
+ * @throws Error naming the file when it cannot be imported, provides nothing,
33
+ * or provides something that is not what its name promises.
34
+ */
35
+ export declare function loadPlugins(path: string, importModule?: ModuleImporter): Promise<PluginModule>;
36
+ /**
37
+ * Loads the hooks of a hooks or plugins module (see {@link loadPlugins}).
38
+ *
39
+ * @param path - A `.mjs` / `.js` / `.cjs` file.
40
+ * @param importModule - How to import it.
41
+ * @returns The hooks by name.
42
+ * @throws Error naming the file when it cannot be imported or exports no hooks.
43
+ */
44
+ export declare function loadHooks(path: string, importModule?: ModuleImporter): Promise<HookMap>;
45
+ /** Imports a module by URL, returning its namespace. */
46
+ export type ModuleImporter = (url: string) => Promise<Record<string, unknown>>;
47
+ //# sourceMappingURL=load-hooks.repository.d.ts.map
package/dist/index.d.ts CHANGED
@@ -1 +1,18 @@
1
- export * from "./src/index.js";
1
+ export { main } from './main';
2
+ export { parseArguments, USAGE } from './arguments';
3
+ export type { Command } from './arguments';
4
+ export { processTerminal } from './terminal';
5
+ export type { Terminal } from './terminal';
6
+ export { findData, probeReport, probeUrl } from './probe';
7
+ export type { ProbeFindings, ProbeResult, ProbeOptions } from './probe';
8
+ export { readRecipeFiles } from './recipe-files';
9
+ export type { RecipeFiles } from './recipe-files';
10
+ export { loadForRun } from './run';
11
+ export { diffReport, writeChanges } from './diff';
12
+ export type { CommonOptions } from './arguments';
13
+ export { resolveAccess } from './access';
14
+ export { loadHooks, loadPlugins } from './hooks-module';
15
+ export type { PluginModule } from './hooks-module';
16
+ export { runStudio } from './studio';
17
+ export type { StudioModule } from './studio';
18
+ //# sourceMappingURL=index.d.ts.map
package/dist/main.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ import type { Terminal } from './terminal';
2
+ /**
3
+ * Runs one cli invocation: parses argv, dispatches to a use case, writes
4
+ * through `terminal`. Never throws; a bad command or a use case failure both
5
+ * become a non-zero return.
6
+ *
7
+ * @param argv - Arguments after the program name.
8
+ * @param terminal - Where output goes.
9
+ * @returns The process exit code.
10
+ */
11
+ export declare function main(argv: readonly string[], terminal: Terminal): Promise<number>;
12
+ //# sourceMappingURL=main.d.ts.map
@@ -0,0 +1,6 @@
1
+ export { probePage, probeUrl } from './probe-page.use-case';
2
+ export type { ProbeResult, ProbeOptions } from './probe-page.use-case';
3
+ export { probeReport, pdfReport, workbookReport, deckReport, jsonReport, xmlReport } from './probe-report.mapper';
4
+ export { findData } from '@opencraw/probe';
5
+ export type { ProbeFindings, JsonLdFinding, InlineJsonFinding } from '@opencraw/probe';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,65 @@
1
+ import type { AccessConfig, AccessPlugin } from '@opencraw/core';
2
+ import { findData } from '@opencraw/probe';
3
+ import type { DeckFindings, HtmlFindings, JsonFindings, PdfFindings, WorkbookFindings, XmlFindings } from '@opencraw/probe';
4
+ import type { CommonOptions } from '../arguments';
5
+ import type { Terminal } from '../terminal';
6
+ /** What fetching and, optionally, rendering a page found. */
7
+ export interface ProbeResult {
8
+ url: string;
9
+ status: number;
10
+ findings: ReturnType<typeof findData>;
11
+ /** JSON responses observed while the page rendered; empty unless `options.browser` was set. */
12
+ observed: string[];
13
+ /** Present when the URL is a PDF: its rows and likely table headers. */
14
+ pdf?: PdfFindings;
15
+ /** Present when the URL is a CSV or a spreadsheet: its sheets, rows and likely table headers. */
16
+ workbook?: WorkbookFindings;
17
+ /** Present when the URL is a presentation: its slides, table headers, charts and text-box grids. */
18
+ deck?: DeckFindings;
19
+ /** Present when the URL is JSON, JSON Lines or YAML: its structure and record lists. */
20
+ json?: JsonFindings;
21
+ /** Present for HTML: its tables' headers; for rendered Markdown also its outline and front matter. */
22
+ html?: HtmlFindings;
23
+ /** Present for XML: its namespaces, repeated elements and structure. */
24
+ xml?: XmlFindings;
25
+ }
26
+ /** How to probe: the cli's options, plus what a service probing for others sets. */
27
+ export interface ProbeOptions extends CommonOptions {
28
+ /** Also render the page and list the JSON it fetches. */
29
+ browser: boolean;
30
+ /** The only hosts the probe may reach, as `CrawlOptions.allowedHosts`; local paths and `file:` are refused. */
31
+ allowedHosts?: string[];
32
+ /** An access config already loaded, instead of `access` (a file). `accessProfile` still picks the default. */
33
+ accessConfig?: AccessConfig;
34
+ /** Access plugins already loaded, instead of those in `plugins` (a module). */
35
+ accessPlugins?: AccessPlugin[];
36
+ }
37
+ /**
38
+ * Fetches a page and finds where its data lives, through the access profile the
39
+ * options name (direct without one). With `browser: true` it also
40
+ * renders the page and lists the JSON responses seen while it settles, which
41
+ * finds endpoints a plain fetch of the initial HTML cannot. No `Terminal`
42
+ * involved: the cli's `probePage` and `@opencraw/mcp`'s probe tool both
43
+ * build on this, one printing the result, the other returning it as data.
44
+ *
45
+ * A PDF, a spreadsheet, a CSV or a presentation (by content type, or a local
46
+ * path) is read instead: its rows, and the rows that look like table headers.
47
+ *
48
+ * @param url - The page to probe, or a local file path.
49
+ * @param options - Browser path, TLS and user agent, plus whether to render.
50
+ * @returns What was found.
51
+ * @throws Error when the fetch itself fails.
52
+ */
53
+ export declare function probeUrl(url: string, options: ProbeOptions): Promise<ProbeResult>;
54
+ /**
55
+ * Fetches a page and reports where its data lives, to a `Terminal`.
56
+ *
57
+ * @param url - The page to probe.
58
+ * @param options - Browser path, TLS and user agent, plus whether to render.
59
+ * @param terminal - Where the report goes.
60
+ * @returns The exit code: 0, or 1 on a fetch failure.
61
+ */
62
+ export declare function probePage(url: string, options: {
63
+ browser: boolean;
64
+ } & CommonOptions, terminal: Terminal): Promise<number>;
65
+ //# sourceMappingURL=probe-page.use-case.d.ts.map
@@ -0,0 +1,59 @@
1
+ import type { DeckFindings, HtmlFindings, JsonFindings, PdfFindings, ProbeFindings, WorkbookFindings, XmlFindings } from '@opencraw/probe';
2
+ /**
3
+ * Renders a probe's findings as text.
4
+ *
5
+ * @param url - The URL probed.
6
+ * @param status - The HTTP status.
7
+ * @param findings - What `findData` found.
8
+ * @param observed - JSON responses a browser saw, when `--browser` was used.
9
+ * @param html - The tables (and, for Markdown, the outline and front matter) found.
10
+ * @returns The report.
11
+ */
12
+ export declare function probeReport(url: string, status: number, findings: ProbeFindings, observed?: string[], html?: HtmlFindings): string;
13
+ /**
14
+ * Renders what a probe found in a PDF as text.
15
+ *
16
+ * @param url - The URL or file probed.
17
+ * @param pdf - What `describePdf` found.
18
+ * @returns The report.
19
+ */
20
+ export declare function pdfReport(url: string, pdf: PdfFindings): string;
21
+ /**
22
+ * Formats what a probe found in a workbook (a CSV or a spreadsheet): its sheets,
23
+ * the rows that look like table headers with a selector for each, and the first
24
+ * rows.
25
+ *
26
+ * @param url - The workbook's URL.
27
+ * @param workbook - The findings.
28
+ * @returns The report.
29
+ */
30
+ export declare function workbookReport(url: string, workbook: WorkbookFindings): string;
31
+ /**
32
+ * Formats what a probe found in a deck (a presentation): its slides, the native
33
+ * tables' headers with a selector for each, its charts, and the slides whose
34
+ * text boxes look like a table.
35
+ *
36
+ * @param url - The deck's URL.
37
+ * @param deck - The findings.
38
+ * @returns The report.
39
+ */
40
+ export declare function deckReport(url: string, deck: DeckFindings): string;
41
+ /**
42
+ * Formats what a probe found in JSON data: its record lists with the path a
43
+ * `jsonpath` extract needs, then its structure.
44
+ *
45
+ * @param url - The document's URL.
46
+ * @param json - The findings.
47
+ * @returns The report.
48
+ */
49
+ export declare function jsonReport(url: string, json: JsonFindings): string;
50
+ /**
51
+ * Formats what a probe found in an XML document: its namespaces and the
52
+ * `namespaces` an `xpath` extract needs, the elements that repeat, and its structure.
53
+ *
54
+ * @param url - The document's URL.
55
+ * @param xml - The findings.
56
+ * @returns The report.
57
+ */
58
+ export declare function xmlReport(url: string, xml: XmlFindings): string;
59
+ //# sourceMappingURL=probe-report.mapper.d.ts.map
@@ -0,0 +1,3 @@
1
+ export { readRecipeFiles } from './read-recipe-files.repository';
2
+ export type { RecipeFiles } from './read-recipe-files.repository';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,26 @@
1
+ import type { RecipeSource } from '@opencraw/core';
2
+ /** Decoded recipes, split by their `kind`. */
3
+ export interface RecipeFiles {
4
+ /** `path` is the file, `path:line` in a JSON Lines file, or a label (`recipes[0]`) for one from memory. */
5
+ outputs: {
6
+ path: string;
7
+ recipe: unknown;
8
+ }[];
9
+ inputs: {
10
+ path: string;
11
+ recipe: unknown;
12
+ }[];
13
+ /** Documents that are neither; listed so a typo in `kind` does not pass silently. */
14
+ others: string[];
15
+ }
16
+ /**
17
+ * Reads recipes, expanding directories to their `.json` and `.jsonl` files
18
+ * (sorted, not recursive), and sorts them by `kind`. The command line passes
19
+ * paths; the MCP server also passes recipes it was handed inline.
20
+ *
21
+ * @param sources - Files or directories, or any other recipe source core reads.
22
+ * @returns The decoded recipes.
23
+ * @throws Error naming a file that is not JSON or JSON Lines.
24
+ */
25
+ export declare function readRecipeFiles(sources: RecipeSource): Promise<RecipeFiles>;
26
+ //# sourceMappingURL=read-recipe-files.repository.d.ts.map
@@ -0,0 +1,3 @@
1
+ export { runRecipes } from './run-recipes.use-case';
2
+ export { loadForRun } from './load-for-run.use-case';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,13 @@
1
+ import type { RecipeSet, RecipeSource } from '@opencraw/core';
2
+ /**
3
+ * Loads and binds the recipes `run` needs, filtered to the input ids in `only`
4
+ * when given.
5
+ *
6
+ * @param sources - Recipe files or directories (or recipes the MCP server was handed inline).
7
+ * @param only - Input recipe ids to keep; empty keeps all.
8
+ * @returns The bound set.
9
+ * @throws Error when there is not exactly one output recipe.
10
+ * @throws RecipeValidationError, RecipeBindingError on a bad recipe.
11
+ */
12
+ export declare function loadForRun(sources: RecipeSource, only: readonly string[]): Promise<RecipeSet>;
13
+ //# sourceMappingURL=load-for-run.use-case.d.ts.map
@@ -0,0 +1,17 @@
1
+ import type { Command } from '../arguments';
2
+ import type { Terminal } from '../terminal';
3
+ /**
4
+ * Crawls the recipes at `paths` and reports what happened.
5
+ *
6
+ * `--dry-run` caps every input at one record, attaches the scope each record
7
+ * was mapped from, and prints them side by side instead of writing them, so a
8
+ * recipe under construction can be checked without a full run.
9
+ *
10
+ * @param command - The parsed `run` command.
11
+ * @param terminal - Where records, the trace and errors go.
12
+ * @returns The exit code: 0, or 1 on a load failure or a recipe error.
13
+ */
14
+ export declare function runRecipes(command: Extract<Command, {
15
+ name: 'run';
16
+ }>, terminal: Terminal): Promise<number>;
17
+ //# sourceMappingURL=run-recipes.use-case.d.ts.map
@@ -0,0 +1,3 @@
1
+ export { runStudio } from './run-studio.use-case';
2
+ export type { StudioModule } from './run-studio.use-case';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,32 @@
1
+ import { loadPlugins } from '../hooks-module';
2
+ import type { PluginModule } from '../hooks-module';
3
+ import type { Terminal } from '../terminal';
4
+ /** The one export the cli needs from `@opencraw/studio`. */
5
+ export interface StudioModule {
6
+ main: (argv: readonly string[], options?: {
7
+ plugins?: PluginModule & {
8
+ source: string;
9
+ };
10
+ open?: string;
11
+ }) => Promise<void>;
12
+ }
13
+ /**
14
+ * Runs `opencraw studio [folder]`: imports `@opencraw/studio` lazily and
15
+ * delegates to its own `main`, which starts the server, prints the URL with
16
+ * the token, and keeps running until interrupted (Ctrl+C) — the cli's own
17
+ * call does not return before that. `@opencraw/studio` is an optional peer
18
+ * dependency (`peerDependenciesMeta`), never a hard one: the cli stays light
19
+ * for callers who only need to crawl. When it is not installed, this prints
20
+ * how to add it instead of letting a raw `ERR_MODULE_NOT_FOUND` stack trace
21
+ * through.
22
+ *
23
+ * @param folder - The recipe folder to open; `@opencraw/studio`'s own default (the current directory) when omitted.
24
+ * @param terminal - Where output goes.
25
+ * @param importStudio - How the module is loaded; the real dynamic `import()` by default, replaced in tests.
26
+ * @param pluginsFile - A hooks or plugins module (`--hooks`, issue #150), loaded here, on the command line's own authority, and handed to Studio: the server never loads code itself.
27
+ * @param load - How the module is read; `loadPlugins` unless a test says otherwise.
28
+ * @param open - A folder, recipe file or document (`--open`, issue #235): the printed link opens it straight away.
29
+ * @returns The exit code: 0 once the server has stopped, 1 when `@opencraw/studio` is missing.
30
+ */
31
+ export declare function runStudio(folder: string | undefined, terminal: Terminal, importStudio?: () => Promise<StudioModule>, pluginsFile?: string, load?: typeof loadPlugins, open?: string): Promise<number>;
32
+ //# sourceMappingURL=run-studio.use-case.d.ts.map
@@ -0,0 +1,3 @@
1
+ export type { Terminal } from './terminal.contract';
2
+ export { processTerminal } from './terminal.client';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,4 @@
1
+ import type { Terminal } from './terminal.contract';
2
+ /** The process's stdout and stderr. */
3
+ export declare function processTerminal(): Terminal;
4
+ //# sourceMappingURL=terminal.client.d.ts.map
@@ -0,0 +1,6 @@
1
+ /** Where a command writes: results to `out`, diagnostics and progress to `err`. Tests capture both. */
2
+ export interface Terminal {
3
+ out: (line: string) => void;
4
+ err: (line: string) => void;
5
+ }
6
+ //# sourceMappingURL=terminal.contract.d.ts.map
@@ -0,0 +1,2 @@
1
+ export { validateRecipes } from './validate-recipes.use-case';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,10 @@
1
+ import type { Terminal } from '../terminal';
2
+ /**
3
+ * Loads and binds recipe files, printing every problem with its JSON path.
4
+ *
5
+ * @param paths - Recipe files or directories.
6
+ * @param terminal - Where results go.
7
+ * @returns The exit code: 0 when the recipes bind cleanly, 1 otherwise.
8
+ */
9
+ export declare function validateRecipes(paths: readonly string[], terminal: Terminal): Promise<number>;
10
+ //# sourceMappingURL=validate-recipes.use-case.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencraw/cli",
3
- "version": "0.1.50",
3
+ "version": "0.1.52",
4
4
  "type": "module",
5
5
  "main": "./dist/index.esm.js",
6
6
  "module": "./dist/index.esm.js",
@@ -24,12 +24,12 @@
24
24
  "!**/*.js.map"
25
25
  ],
26
26
  "dependencies": {
27
- "@opencraw/core": "^0.1.44",
28
- "@opencraw/probe": "^0.0.27",
27
+ "@opencraw/core": "^0.1.46",
28
+ "@opencraw/probe": "^0.0.29",
29
29
  "playwright": "^1.63.0"
30
30
  },
31
31
  "peerDependencies": {
32
- "@opencraw/studio": "^0.0.39"
32
+ "@opencraw/studio": "^0.0.41"
33
33
  },
34
34
  "peerDependenciesMeta": {
35
35
  "@opencraw/studio": {