import fs from "node:fs"; import type { AgentAdapter } from "../agents/types.js"; import type { HintContext } from "./types.js"; export interface BuildHintContextOptions { config?: any; results?: any; /** Defaults to `process.cwd()`. Injectable for tests. */ cwd?: string; /** Defaults to `!!process.stdout.isTTY`. Injectable for tests. */ isTTY?: boolean; /** Defaults to `os.platform()`. Injectable for tests. */ platform?: NodeJS.Platform; /** Defaults to `listAdapters()`. Injectable for tests. */ adapters?: AgentAdapter[]; /** * Override the agent-probe timeout. Tests with stub adapters that * resolve synchronously can pass `0` to disable. */ agentProbeTimeoutMs?: number; } export declare function buildHintContext(options?: BuildHintContextOptions): Promise; /** * Walk from `start` upward looking for a `.git/config` file. When found, * parse out the URL of `[remote "origin"]`. Returns `null` if no repo or * no origin remote was found, or on any I/O / parse error. * * Stops at the filesystem root. Bounded to 30 iterations to be doubly * sure we never loop forever on pathological filesystems. */ export declare function readGitOriginUrl(start: string): string | null; export declare function parseOriginUrl(text: string): string | null; export declare function detectDocDetectiveWorkflow(cwd: string): boolean; /** * True when at least one command in a workflow `run:` block is * `doc-detective` (or a thin runner like `npx`/`yarn`/`pnpm`/`bunx` * invoking it). Splits on common shell chaining/grouping operators * (`&&`, `||`, `;`, `|`, newline) and inspects each command piece * at its START — so arbitrary mentions like `echo doc-detective`, * `grep doc-detective package.json`, or `# doc-detective todo` * don't false-positive. Doesn't try to parse shell quoting; the * common workflow invocations are simple enough that this catches * the realistic cases without a full grammar. */ export declare function runInvokesDocDetective(run: string): boolean; interface WalkData { usedStepTypes: Set; usedBrowserContexts: Set; producedScreenshots: boolean; usedAnnotations: boolean; producedAutoScreenshots: boolean; producedRecordings: boolean; usedSelectorOnlyFinds: boolean; hasRelativeUrls: boolean; hasCurlInRunShell: boolean; hasNodeOrPythonInRunShell: boolean; usedCustomAssertions: boolean; usedRetry: boolean; failedTransientRequest: boolean; failedRunShellWithoutShell: boolean; failedAnnotationTargetWithoutTimeout: boolean; ranIosContexts: boolean; hasStaleRecordings: boolean; viewportFloored: boolean; ranMobileContexts: boolean; repeatedAppSurfaceRefs: boolean; appSurfaceRefCounts: Map; } /** * Px delta above which a realized viewport counts as FLOORED by the browser. * Mirrors `VIEWPORT_TOLERANCE_PX` in `src/core/utils.ts` — the threshold the * runner itself uses to warn — so the hint fires exactly when the run warned. * Duplicated rather than imported: `hints/` stays free of the core module graph * (core/utils pulls axios and the runtime stack). `test/hints.test.js` asserts * the two constants stay equal. */ export declare const VIEWPORT_FLOOR_TOLERANCE_PX = 16; /** * Matches the runner's "target didn't resolve" annotation failures — both the * single-element form ("the element to annotate") and the `all` form ("any * element to annotate"). Mirrors the messages in * `src/core/annotations/geometry.ts`; matched on text rather than imported so * `hints/` stays free of the core module graph, the same trade the viewport * tolerance and surface-key list above make. Exported so `test/hints.test.js` * can drive a real resolution failure through geometry and assert the message * still matches — a reword there would otherwise silence the hint quietly. */ export declare const ANNOTATION_TARGET_MISSING: RegExp; export declare const SURFACE_SENSITIVE_HINT_KEYS: string[]; export declare function walkResults(results: any): WalkData; /** * Find the nearest `package.json` walking up from `cwd`. Returns the * full path or `null`. Walking up matches `readGitOriginUrl` / * `readGitignore` so probes stay consistent when doc-detective is run * from a subdirectory. */ export declare function findPackageJsonUpward(cwd: string): string | null; /** * True when ANY `scripts[*]` value in the given `package.json` * contains the literal substring `doc-detective`. Pure file read + * JSON parse; `null`/absent paths return false. */ export declare function hasDocDetectiveScriptInPackageJson(packageJsonPath: string | null): boolean; /** * Backwards-compatible wrapper kept for tests that exercise the * scripts probe in isolation. Walks up from `cwd` and forwards to * `hasDocDetectiveScriptInPackageJson`. */ export declare function readNpmScripts(cwd: string): boolean; /** * True when the managed WebDriverAgent cache holds at least one completed, * VALID prebuild — i.e. the user already runs `install ios`, so the * `prebuildWebDriverAgent` hint has nothing to teach. Validity uses the same * `readProductsMarker` the session locator uses (marker shape + Runner app * present), so a corrupt or gutted key dir doesn't suppress the hint. One * bounded readdir of `/ios/wda` plus a marker read per entry, * capped at 100 entries (the walk-budget rule; a real wda root holds a * handful of keys); false on any error (missing dir, unreadable cache, * unsafe cache path). */ export declare function detectManagedWdaProducts(config: any, deps?: { fs?: Pick; }): boolean; export declare function detectOutputDirGitignored(cwd: string, outputDir: any): boolean; /** * Loose match: split into trimmed non-comment lines, normalize away * leading slash and trailing slash, and check if any pattern matches the * normalized output dir. * * Doesn't try to be a full gitignore implementation — patterns like `**` * and negation are rare for build-output entries, and a coarse match is * good enough to gate the hint. */ export declare function gitignoreCovers(text: string, outputDir: string): boolean; export declare function parseNodeMajor(versionString: string): number; /** Single source of truth for the RST extension(s) we scan and refer to. */ export declare const RST_EXTENSIONS: string[]; /** * Returns true if any file under the repo root (or `cwd` if no * `.git` directory is found in any parent) ends with a `.rst` * suffix. Walks up from `cwd` to locate `.git`, then scans * downward from that directory. This keeps the probe consistent * with `detectDocDetectiveWorkflow` and `findPackageJsonUpward` — * doc-detective run from a monorepo subdirectory still sees `.rst` * files in sibling packages. Caps at 100 file inspections to bound * the worst case on huge monorepos. Skips dotted entries and * `node_modules`. Failures are caught and treated as "not found" * so a permission error never breaks the post-run summary. */ export declare function detectRstFiles(cwd: string): boolean; export {}; //# sourceMappingURL=context.d.ts.map