@iamu-dev/iamu 0.2.0-beta.1 → 0.2.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/dist/bin.js +29 -8
  2. package/dist/index.js +29 -8
  3. package/dist/templates/skills/iamu-setup.md +8 -16
  4. package/package.json +3 -3
  5. package/dist/adapters/claude-plugin.d.ts +0 -13
  6. package/dist/adapters/registry.d.ts +0 -6
  7. package/dist/adapters/types.d.ts +0 -19
  8. package/dist/bin.d.ts +0 -2
  9. package/dist/build-info.d.ts +0 -53
  10. package/dist/cloud-url.d.ts +0 -19
  11. package/dist/commands/auth-http.d.ts +0 -37
  12. package/dist/commands/auth-project-choice.d.ts +0 -74
  13. package/dist/commands/auth-token-input.d.ts +0 -21
  14. package/dist/commands/auth.d.ts +0 -84
  15. package/dist/commands/browse-actions.d.ts +0 -56
  16. package/dist/commands/browse-driver.d.ts +0 -117
  17. package/dist/commands/browse.d.ts +0 -156
  18. package/dist/commands/cloud-push.d.ts +0 -27
  19. package/dist/commands/complete.d.ts +0 -131
  20. package/dist/commands/completion.d.ts +0 -2
  21. package/dist/commands/context.d.ts +0 -58
  22. package/dist/commands/credentials.d.ts +0 -144
  23. package/dist/commands/diff-filter.d.ts +0 -11
  24. package/dist/commands/doctor.d.ts +0 -24
  25. package/dist/commands/evaluate.d.ts +0 -30
  26. package/dist/commands/findings.d.ts +0 -7
  27. package/dist/commands/init.d.ts +0 -9
  28. package/dist/commands/instructions-walk.d.ts +0 -59
  29. package/dist/commands/list.d.ts +0 -5
  30. package/dist/commands/match.d.ts +0 -12
  31. package/dist/commands/mcp-config.d.ts +0 -10
  32. package/dist/commands/new-entity.d.ts +0 -15
  33. package/dist/commands/new-finding.d.ts +0 -19
  34. package/dist/commands/open.d.ts +0 -8
  35. package/dist/commands/port.d.ts +0 -17
  36. package/dist/commands/prune.d.ts +0 -11
  37. package/dist/commands/pull.d.ts +0 -5
  38. package/dist/commands/register-cloud.d.ts +0 -5
  39. package/dist/commands/register-findings.d.ts +0 -5
  40. package/dist/commands/register-project.d.ts +0 -5
  41. package/dist/commands/register-walkthrough.d.ts +0 -5
  42. package/dist/commands/register.d.ts +0 -10
  43. package/dist/commands/report.d.ts +0 -3
  44. package/dist/commands/serve.d.ts +0 -11
  45. package/dist/commands/skills.d.ts +0 -34
  46. package/dist/commands/start-run.d.ts +0 -49
  47. package/dist/commands/status.d.ts +0 -3
  48. package/dist/commands/step-numbering.d.ts +0 -87
  49. package/dist/commands/step.d.ts +0 -95
  50. package/dist/commands/sync.d.ts +0 -6
  51. package/dist/commands/triage.d.ts +0 -21
  52. package/dist/commands/update.d.ts +0 -4
  53. package/dist/commands/validate.d.ts +0 -8
  54. package/dist/commands/view-results.d.ts +0 -9
  55. package/dist/index.d.ts +0 -9
  56. package/dist/sync-mcp/fatal.d.ts +0 -42
  57. package/dist/sync-mcp/server.d.ts +0 -1
  58. package/dist/sync-mcp/tools.d.ts +0 -12
  59. package/dist/templates.d.ts +0 -10
  60. package/dist/ui/journey-diff.d.ts +0 -3
  61. package/dist/ui/json.d.ts +0 -6
  62. package/dist/ui/logger.d.ts +0 -5
  63. package/dist/ui/panic.d.ts +0 -11
  64. package/dist/ui/symbols.d.ts +0 -11
  65. package/dist/ui/table.d.ts +0 -20
  66. package/dist/ui/update-check.d.ts +0 -6
  67. package/dist/worktree-state.d.ts +0 -49
@@ -1,117 +0,0 @@
1
- import type { Page } from "playwright-core";
2
- /** A page size in CSS pixels. */
3
- export interface Size {
4
- width: number;
5
- height: number;
6
- }
7
- /**
8
- * The page a command acts on, plus how to let go of it. Detaching
9
- * disconnects from the browser; it never closes the page.
10
- *
11
- * @public
12
- */
13
- export interface AttachedPage {
14
- page: Page;
15
- detach(): Promise<void>;
16
- }
17
- /**
18
- * What `iamu browse` needs from the machine and the browser — the real
19
- * one spawns Chrome and speaks CDP; tests pass a fake.
20
- *
21
- * @public
22
- */
23
- export interface BrowserDriver {
24
- /** Is a browser answering CDP on this port? Must not hang. */
25
- isRunning(port: number): Promise<boolean>;
26
- /** Launch Chrome detached with these arguments; returns its PID. */
27
- launch(chrome: string, args: string[]): number | undefined;
28
- /**
29
- * Fit the running window's content area to the viewport
30
- * (`Browser.setWindowBounds`), so a person watching sees the
31
- * persona's screen. Best effort: a window cannot be phone-narrow, and
32
- * every command emulates the stored viewport on its page anyway.
33
- */
34
- resize(port: number, viewport: Size | null): Promise<void>;
35
- /** Attach over CDP to the page the persona is on. Throws when nothing answers. */
36
- attach(port: number): Promise<AttachedPage>;
37
- /** Ask the browser on this port to close (`Browser.close`). Best effort. */
38
- closeBrowser(port: number): Promise<void>;
39
- /** The full command line of `pid`, or null when it is gone or cannot be read. */
40
- commandLine(pid: number): Promise<string | null>;
41
- /** Send SIGTERM to `pid`. Never throws. */
42
- kill(pid: number): void;
43
- }
44
- /** How long a CDP liveness probe may take before the port counts as dead. */
45
- export declare const CDP_PROBE_TIMEOUT_MS = 1000;
46
- /**
47
- * Is a browser answering CDP on `port`? A process that accepts the
48
- * connection but never answers (a hung Chrome, something else on the
49
- * port) counts as not running once `timeoutMs` passes.
50
- *
51
- * @param port - CDP port on 127.0.0.1.
52
- * @param timeoutMs - Give up after this long.
53
- * @returns True when `/json/version` answers 2xx in time.
54
- *
55
- * @example
56
- * ```ts
57
- * if (!(await probeCdp(9333))) console.log("no browser");
58
- * ```
59
- *
60
- * @public
61
- */
62
- export declare function probeCdp(port: number, timeoutMs?: number): Promise<boolean>;
63
- /**
64
- * The command line of a running process, read without a shell:
65
- * `/proc/<pid>/cmdline` on Linux, else `ps -ww -o args= -p <pid>`.
66
- * Windows has no equivalent we trust, so it answers null there — and
67
- * callers then leave the process alone.
68
- *
69
- * @param pid - Process ID to inspect.
70
- * @param platform - Defaults to `process.platform`.
71
- * @returns The arguments joined by spaces, or null.
72
- *
73
- * @example
74
- * ```ts
75
- * const cmd = await readProcessCommandLine(12345);
76
- * ```
77
- *
78
- * @public
79
- */
80
- export declare function readProcessCommandLine(pid: number, platform?: NodeJS.Platform): Promise<string | null>;
81
- /**
82
- * Was this command line launched with exactly this `--user-data-dir`?
83
- * The profile directory is ours alone, so a match means the PID is the
84
- * Chrome `iamu browse start` launched, not a process that reused its PID.
85
- *
86
- * @param commandLine - From {@link readProcessCommandLine}.
87
- * @param profileDir - The `--user-data-dir` we launched with.
88
- * @returns True only on an exact flag match.
89
- *
90
- * @example
91
- * ```ts
92
- * isOurBrowser("chrome --user-data-dir=/h/.iamu/browse/profile", "/h/.iamu/browse/profile"); // true
93
- * ```
94
- *
95
- * @public
96
- */
97
- export declare function isOurBrowser(commandLine: string | null, profileDir: string): boolean;
98
- /**
99
- * SIGTERM `pid` only if it is verifiably our Chrome (see
100
- * {@link isOurBrowser}). PIDs get reused; anything else is left alone
101
- * and Chrome's own profile lock guards a second launch.
102
- *
103
- * @param pid - PID recorded in the browse state.
104
- * @param profileDir - The `--user-data-dir` it was launched with.
105
- * @param driver - Supplies `commandLine` and `kill`.
106
- * @returns True when the process was signalled.
107
- *
108
- * @example
109
- * ```ts
110
- * await reapBrowser(state.pid, profileDir, cdpDriver);
111
- * ```
112
- *
113
- * @public
114
- */
115
- export declare function reapBrowser(pid: number, profileDir: string, driver: Pick<BrowserDriver, "commandLine" | "kill">): Promise<boolean>;
116
- /** The real driver: spawns Chrome and speaks CDP through playwright-core. */
117
- export declare const cdpDriver: BrowserDriver;
@@ -1,156 +0,0 @@
1
- import type { Page } from "playwright-core";
2
- import { type BrowserDriver, type Size } from "./browse-driver.js";
3
- export type { BrowserDriver } from "./browse-driver.js";
4
- /** Parsed options for `iamu browse <command>`. */
5
- export interface BrowseOptions {
6
- shot?: string;
7
- nth?: string;
8
- submit?: boolean;
9
- full?: boolean;
10
- viewport?: string;
11
- width?: string;
12
- height?: string;
13
- headless?: boolean;
14
- port?: string | number;
15
- /** `start`: size the browser for this run's persona. */
16
- run?: string;
17
- action?: string;
18
- note?: string;
19
- surface?: string;
20
- maxSteps?: string | number;
21
- json?: boolean;
22
- }
23
- interface BrowseState {
24
- port: number;
25
- viewport: Size | null;
26
- pid?: number;
27
- headless?: boolean;
28
- }
29
- /**
30
- * The state `iamu browse start` left in `~/.iamu/browse/state.json`, or
31
- * null when no browser was started (or the file is unreadable).
32
- *
33
- * @example
34
- * ```ts
35
- * const state = readBrowseState();
36
- * if (state) console.log(`CDP on :${state.port}`);
37
- * ```
38
- *
39
- * @public
40
- */
41
- export declare function readBrowseState(): BrowseState | null;
42
- /**
43
- * Parse `"390x844"` into a size.
44
- *
45
- * @param value - `WxH`, 2–5 digits each.
46
- * @returns The size, or null when absent or malformed.
47
- *
48
- * @example
49
- * ```ts
50
- * parseViewport("390x844"); // { width: 390, height: 844 }
51
- * ```
52
- *
53
- * @public
54
- */
55
- export declare function parseViewport(value: string | undefined): Size | null;
56
- /**
57
- * The installed Chrome/Chromium to drive: `IAMU_BROWSER`, else the
58
- * usual install location for this platform.
59
- *
60
- * @example
61
- * ```ts
62
- * const chrome = findChrome();
63
- * if (!chrome) console.error("Install Chrome or set IAMU_BROWSER");
64
- * ```
65
- *
66
- * @public
67
- */
68
- export declare function findChrome(env?: NodeJS.ProcessEnv, platform?: NodeJS.Platform, exists?: (p: string) => boolean): string | null;
69
- /**
70
- * Should `start` launch without a window? `--headless` wins, then
71
- * `IAMU_HEADLESS`, then CI or a Linux box with no `DISPLAY`.
72
- *
73
- * @example
74
- * ```ts
75
- * isHeadlessEnvironment({ headless: true }); // true
76
- * ```
77
- *
78
- * @public
79
- */
80
- export declare function isHeadlessEnvironment(opts?: BrowseOptions): boolean;
81
- /**
82
- * Should Chrome run with `--no-sandbox`? Only when it cannot start
83
- * otherwise — as root (Chrome refuses to sandbox as root, typical in
84
- * containers) — or when explicitly asked via `IAMU_BROWSE_NO_SANDBOX=1`.
85
- * Being headless or in CI is not a reason: the sandbox is what keeps a
86
- * page the persona visits away from the machine.
87
- *
88
- * @param env - Defaults to `process.env`.
89
- * @param uid - Effective user ID; defaults to `process.getuid()` (undefined on Windows).
90
- * @returns True when `--no-sandbox` should be passed.
91
- *
92
- * @example
93
- * ```ts
94
- * shouldDisableSandbox({ IAMU_BROWSE_NO_SANDBOX: "1" }, 1000); // true
95
- * shouldDisableSandbox({ CI: "true" }, 1000); // false
96
- * ```
97
- *
98
- * @public
99
- */
100
- export declare function shouldDisableSandbox(env?: NodeJS.ProcessEnv, uid?: number | undefined): boolean;
101
- /**
102
- * Start the browser, or converge the one already running: a running
103
- * browser is reused, and resized when the requested viewport differs
104
- * from the one it was started with — never silently left at another
105
- * persona's size.
106
- *
107
- * A PID left by an earlier `start` whose CDP no longer answers is
108
- * terminated only when its command line shows our `--user-data-dir`;
109
- * a PID the OS has since handed to another process is left alone.
110
- *
111
- * @param opts - `viewport`, `run`, `port`, `width`, `height`, `headless`, `json`.
112
- * @param driver - Machine/browser seam; tests pass a fake.
113
- *
114
- * @example
115
- * ```ts
116
- * await start({ viewport: "390x844" });
117
- * ```
118
- *
119
- * @public
120
- */
121
- export declare function start(opts: BrowseOptions, driver?: BrowserDriver): Promise<void>;
122
- /** Where the page ended up after an action. */
123
- export interface PageResult {
124
- url: string;
125
- title: string;
126
- /** Absolute path of the screenshot written, or null when none was asked for. */
127
- screenshot: string | null;
128
- }
129
- /**
130
- * Attach to the running browser, run `fn` on the page the persona is
131
- * on, optionally screenshot it, and return where the page is. Prints
132
- * nothing on success — the caller decides the output shape. Detaching
133
- * never closes the page.
134
- *
135
- * @public
136
- */
137
- export declare function withPage(opts: BrowseOptions, driver: BrowserDriver, fn: (page: Page) => Promise<void>,
138
- /** What the action looks for, named for the error message. */
139
- target?: string): Promise<PageResult | null>;
140
- /**
141
- * `iamu browse <command> [args…]` — dispatch one browse subcommand.
142
- * Failures print to stderr and set exit code 1.
143
- *
144
- * @param command - `start`, `stop`, `step`, `snapshot`, `shot`, or a page action.
145
- * @param args - Positional arguments after the command.
146
- * @param opts - Parsed CLI options.
147
- * @param driver - Machine/browser seam; tests pass a fake.
148
- *
149
- * @example
150
- * ```ts
151
- * await browse("click", ["button", "Sign in"], { json: true });
152
- * ```
153
- *
154
- * @public
155
- */
156
- export declare function browse(command: string, args: string[], opts: BrowseOptions, driver?: BrowserDriver): Promise<void>;
@@ -1,27 +0,0 @@
1
- /** What happened to a run's cloud copy, as `--json` and the terminal show it. */
2
- export interface CloudRunInfo {
3
- mirrored: boolean;
4
- status: string;
5
- skipped_reason?: string;
6
- /** Dashboard URL — set only when the cloud holds this run. */
7
- url?: string;
8
- }
9
- /**
10
- * Push one run to the cloud when the project is cloud-linked. Returns
11
- * `undefined` for a local-only project, so callers print nothing.
12
- *
13
- * Called by every command that changes what the run's cloud copy shows
14
- * (`complete`, `evaluate-record`): offering "Open in Iamu Cloud" after a
15
- * local-only write would open a stale report.
16
- */
17
- export declare function pushRunToCloud(projectRoot: string, runId: string): Promise<CloudRunInfo | undefined>;
18
- /** Project dashboard URL, or `null` for a local-only project. */
19
- export declare function projectDashboardUrl(projectRoot: string): Promise<string | null>;
20
- /**
21
- * Dashboard URL of a run this machine already pushed, or `null` when the
22
- * project is local-only or the run never reached the cloud. Reads local
23
- * sync tracking only — no network.
24
- */
25
- export declare function pushedRunUrl(projectRoot: string, runId: string): Promise<string | null>;
26
- /** Terminal lines for a run's cloud state; prints nothing when local-only. */
27
- export declare function printCloudRunInfo(info: CloudRunInfo | undefined): void;
@@ -1,131 +0,0 @@
1
- import { type JourneyDiff, type RevisitPlaceCoverage, type VerificationSummary, type WalkthroughManifest } from "@iamu-dev/local-store";
2
- import { type CanonicalWalkthrough, type RunViewport } from "@iamu-dev/protocol";
3
- import { type CloudRunInfo } from "./cloud-push.js";
4
- export interface CompleteOptions {
5
- cwd?: string;
6
- json?: boolean;
7
- force?: boolean;
8
- yes?: boolean;
9
- prompt?: boolean;
10
- view?: boolean;
11
- strictProvenance?: boolean;
12
- }
13
- /** Non-fatal observations made while completing, reported after assembly. */
14
- export interface CompletionExtras {
15
- revisit: RevisitReport | null;
16
- viewportWarning: string | null;
17
- codeWarning: string | null;
18
- cloudInfo: CloudRunInfo | undefined;
19
- }
20
- /**
21
- * `iamu complete <run-id>`: assemble canonical.json + report.md, mark the
22
- * run completed, push it when cloud-linked and report the outcome.
23
- */
24
- export declare function complete(runId: string, opts?: CompleteOptions): Promise<void>;
25
- /**
26
- * The run's completion time. `--force` reassembles the report of a finished
27
- * run; the run still finished when it first completed. Re-stamping would
28
- * move every re-assembled run to "now", which breaks run ordering and
29
- * durations downstream.
30
- */
31
- export declare function pickCompletedAt(manifest: Pick<WalkthroughManifest, "completed_at">, now?: () => Date): string;
32
- /** The manifest with its status flipped to completed. */
33
- export declare function completedManifest(manifest: WalkthroughManifest, completedAt: string): WalkthroughManifest;
34
- /** Persist the completed manifest to disk atomically. */
35
- export declare function persistManifest(manifestPath: string, manifest: WalkthroughManifest, completedAt: string): Promise<WalkthroughManifest>;
36
- /** `complete --json` output: the canonical plus whichever extras exist. */
37
- export declare function completeJsonPayload(canonical: CanonicalWalkthrough, extras: CompletionExtras): Record<string, unknown>;
38
- /** Non-fatal provenance warnings; prints nothing for a clean audit. */
39
- export declare function printProvenanceWarnings(audit: ProvenanceAudit): void;
40
- /** Width and height from a PNG's IHDR chunk; null if it is not a PNG. */
41
- export declare function pngSize(head: Buffer): {
42
- width: number;
43
- height: number;
44
- } | null;
45
- /**
46
- * Is a screenshot `width` px wide consistent with a viewport `expected`
47
- * CSS px wide? At 1× within 20%; at a 2× or 3× device pixel ratio the
48
- * width is an exact multiple, so within 5% — wide enough for a scrollbar,
49
- * narrow enough that a 1280 px desktop shot never passes as a 3× phone.
50
- */
51
- export declare function screenshotFitsViewport(width: number, expected: number): boolean;
52
- /**
53
- * A warning when the run's first screenshot is not the width of the
54
- * device its persona uses — the browser was left at another persona's
55
- * size. Null when the run recorded no viewport, has no screenshots, or
56
- * the sizes agree. Never fatal.
57
- */
58
- export declare function screenshotSizeWarning(runDirPath: string, viewport: RunViewport | null): Promise<string | null>;
59
- export interface ProvenanceAudit {
60
- verified: boolean;
61
- warnings: string[];
62
- step_count: number;
63
- duration_seconds: number | null;
64
- avg_step_interval_seconds: number | null;
65
- uniform_intervals: boolean;
66
- }
67
- /**
68
- * Audit steps for suspicious timing anomalies that indicate programmatic batch
69
- * generation (scripts, mocks) rather than interactive human/LLM persona execution.
70
- */
71
- export declare function auditStepProvenance(steps: Array<{
72
- timestamp?: string;
73
- action?: string;
74
- step_number?: number;
75
- }>): ProvenanceAudit;
76
- /** Strictly validate runtime canonical structure against the protocol schema. */
77
- export declare function validateCanonicalWalkthrough(canonical: unknown): CanonicalWalkthrough;
78
- /**
79
- * Read recorded judge verdicts (if present) and overlay them onto the canonical
80
- * walkthrough for report markdown rendering.
81
- */
82
- export declare function applyRecordedVerdicts(canonical: CanonicalWalkthrough, runDirPath: string): Promise<CanonicalWalkthrough>;
83
- /** Persist canonical.json to disk atomically. */
84
- export declare function persistCanonical(runDirPath: string, canonical: CanonicalWalkthrough): Promise<string>;
85
- /** Persist report.md to disk atomically. */
86
- export declare function persistReport(runDirPath: string, canonical: CanonicalWalkthrough): Promise<string>;
87
- /**
88
- * Build canonical.json (with the verification delta) and report.md for a
89
- * run. The report keeps any verdicts already recorded by
90
- * `evaluate-record`, so re-assembling after the judge (`--force`,
91
- * `match-record`) does not drop them.
92
- */
93
- export declare function assembleRun(projectRoot: string, runId: string, manifest: WalkthroughManifest, completedAt: string): Promise<{
94
- canonical: CanonicalWalkthrough;
95
- verification: VerificationSummary | null;
96
- journeyDiff: JourneyDiff | null;
97
- canonicalWithVerification: CanonicalWalkthrough & {
98
- provenance_audit?: ProvenanceAudit;
99
- };
100
- canonicalPath: string;
101
- reportPath: string;
102
- }>;
103
- /** One requested place, whether the run reached it, and what awaits there. */
104
- export type RevisitReportPlace = RevisitPlaceCoverage & {
105
- findings: Array<{
106
- id: string;
107
- title: string;
108
- }>;
109
- };
110
- /** Coverage of the run's places to pass through, with finding titles. */
111
- export interface RevisitReport {
112
- requested: number;
113
- reached: number;
114
- places: RevisitReportPlace[];
115
- }
116
- /**
117
- * Did the run reach the places `start-run` asked it to pass through
118
- * (manifest `revisit`)? Null when it asked for none. Local only: the
119
- * cloud manifest has no field for it. Titles are for the person reading
120
- * this output — the walker never saw them.
121
- */
122
- export declare function revisitReport(projectRoot: string, runId: string, manifest: WalkthroughManifest): Promise<RevisitReport | null>;
123
- /** Print "Re-check places: reached N of M — not reached: …". */
124
- export declare function printRevisit(r: RevisitReport): void;
125
- /**
126
- * Print the delta against this scenario's previous completed run. Its
127
- * counts are relative to that one run — "new" here means "not in that
128
- * run", which is not the matcher's "first seen" (never recorded before)
129
- * — so the heading says what it compares with.
130
- */
131
- export declare function printVerification(verification: VerificationSummary): void;
@@ -1,2 +0,0 @@
1
- import type { Command } from "commander";
2
- export declare function completion(program: Command, shell?: string): void;
@@ -1,58 +0,0 @@
1
- import { readEntity } from "@iamu-dev/local-store";
2
- import type { EntityType, ProjectConfig } from "@iamu-dev/protocol";
3
- export interface ProjectContext {
4
- projectRoot: string;
5
- config: ProjectConfig;
6
- }
7
- export interface CloudContext extends ProjectContext {
8
- apiKey: string;
9
- apiUrl: string;
10
- }
11
- export declare function commandError(message: string, opts?: {
12
- json?: boolean | string;
13
- }): void;
14
- /**
15
- * Resolve a run directory, reporting an unusable run id as a command
16
- * error (message + exit code 1) instead of letting it reach the
17
- * filesystem. Returns `null` once the error has been reported.
18
- */
19
- export declare function resolveRunDir(projectRoot: string, runId: string, opts?: {
20
- json?: boolean;
21
- }): string | null;
22
- /**
23
- * Last-resort handler for a rejection that escaped a command action.
24
- * Prints one line — JSON-shaped when the invocation carried `--json` —
25
- * and leaves a non-zero exit code behind. Without it, Commander's
26
- * `parseAsync()` rejection reaches Node as an unhandled rejection: a
27
- * stack trace at the user, and historically exit code 0.
28
- *
29
- * @param err - The value the command rejected with.
30
- * @param argv - Invocation argv; only `--json` is read from it.
31
- *
32
- * @example
33
- * ```ts
34
- * await program.parseAsync().catch(reportFatalError);
35
- * ```
36
- */
37
- export declare function reportFatalError(err: unknown, argv?: readonly string[]): void;
38
- export declare function resolveProject(opts?: {
39
- json?: boolean | string;
40
- }): Promise<ProjectContext | null>;
41
- /**
42
- * Resolves both project context and run directory path.
43
- * Returns null if either fails (error already reported).
44
- */
45
- export declare function resolveProjectAndRunDir(runId: string, opts?: {
46
- cwd?: string;
47
- json?: boolean;
48
- }): Promise<{
49
- projectRoot: string;
50
- config: ProjectConfig;
51
- runDirPath: string;
52
- } | null>;
53
- export declare function resolveCloudProject(opts?: {
54
- json?: boolean | string;
55
- }): Promise<CloudContext | null>;
56
- export declare function safeReadEntity<T extends object = Record<string, unknown>>(projectRoot: string, type: EntityType, slug: string, opts?: {
57
- json?: boolean | string;
58
- }): Promise<Awaited<ReturnType<typeof readEntity<T>>> | null>;
@@ -1,144 +0,0 @@
1
- import { IamuConfigError } from "@iamu-dev/protocol";
2
- /**
3
- * Production API URL, used when neither a flag, `IAMU_API_URL`, nor the
4
- * project config names one.
5
- *
6
- * @example
7
- * ```ts
8
- * const url = config.cloud_api_url ?? DEFAULT_API_URL;
9
- * ```
10
- */
11
- export declare const DEFAULT_API_URL = "https://api.iamu.dev";
12
- /**
13
- * Stored credentials, keyed by API URL. Values are left `unknown` on
14
- * purpose: the file is user-editable, so every reader narrows.
15
- */
16
- export type CredentialsStore = Record<string, unknown>;
17
- /**
18
- * Absolute path of the credentials file (`~/.iamu/credentials.json`).
19
- *
20
- * @returns The path; the file may not exist yet.
21
- *
22
- * @example
23
- * ```ts
24
- * console.log(`Tokens live in ${getCredentialsPath()}`);
25
- * ```
26
- */
27
- export declare function getCredentialsPath(): string;
28
- /**
29
- * The API URL a command talks to: the configured one (project config
30
- * or flag), else `IAMU_API_URL`, else {@link DEFAULT_API_URL}. Empty
31
- * strings count as unset.
32
- *
33
- * @param configured - URL from project config or a flag, if any.
34
- * @returns The effective API URL.
35
- *
36
- * @example
37
- * ```ts
38
- * const apiUrl = resolveApiUrl(config.cloud_api_url);
39
- * ```
40
- */
41
- export declare function resolveApiUrl(configured?: string | null): string;
42
- /**
43
- * The credentials file exists but is not a JSON object. Reported instead
44
- * of being treated as empty: the next login would otherwise overwrite
45
- * every stored token without a word.
46
- *
47
- * @example
48
- * ```ts
49
- * try {
50
- * await readCredentialsStore();
51
- * } catch (err) {
52
- * if (err instanceof CredentialsFileError) console.error(err.message);
53
- * }
54
- * ```
55
- */
56
- export declare class CredentialsFileError extends IamuConfigError {
57
- /**
58
- * @param path - The unreadable credentials file.
59
- * @param reason - What is wrong with it.
60
- * @param cause - Underlying parse error, if any.
61
- */
62
- constructor(path: string, reason: string, cause?: unknown);
63
- }
64
- /**
65
- * Read the whole credentials store. A missing file is an empty store; a
66
- * corrupt one throws {@link CredentialsFileError} so no caller writes
67
- * over tokens it could not read.
68
- *
69
- * @returns The parsed store.
70
- * @throws {@link CredentialsFileError} when the file is not a JSON object.
71
- *
72
- * @example
73
- * ```ts
74
- * const store = await readCredentialsStore();
75
- * delete store["https://api.iamu.dev"];
76
- * await writeCredentialsStore(store);
77
- * ```
78
- */
79
- export declare function readCredentialsStore(): Promise<CredentialsStore>;
80
- /**
81
- * Replace the credentials store. Written to a temp file with mode 0600
82
- * and renamed into place, so a crash mid-write leaves the previous file
83
- * intact and the tokens are never world-readable, even briefly. The
84
- * parent directory is created with mode 0700.
85
- *
86
- * @param store - The full store to persist.
87
- *
88
- * @example
89
- * ```ts
90
- * const store = await readCredentialsStore();
91
- * store[apiUrl] = { token, createdAt: new Date().toISOString() };
92
- * await writeCredentialsStore(store);
93
- * ```
94
- */
95
- export declare function writeCredentialsStore(store: CredentialsStore): Promise<void>;
96
- /** @internal Reset warned flag for unit testing. */
97
- export declare function _resetWarnedUnreadableStoreForTesting(): void;
98
- /**
99
- * Token for `apiUrl`: `IAMU_TOKEN`, then `IAMU_API_KEY`, then the entry
100
- * for that URL in the credentials file. A corrupt credentials file is
101
- * reported once on stderr (with the recovery step) and treated as no
102
- * token.
103
- *
104
- * Synchronous because it sits on hot paths (MCP tool handlers, status).
105
- *
106
- * @param apiUrl - API URL the token must belong to; defaults via
107
- * {@link resolveApiUrl}.
108
- * @returns The token, or `null` when none is available.
109
- *
110
- * @example
111
- * ```ts
112
- * const token = resolveApiKey(config.cloud_api_url);
113
- * if (!token) console.error("Run iamu auth login");
114
- * ```
115
- */
116
- export declare function resolveApiKey(apiUrl?: string | null): string | null;
117
- /**
118
- * True for hostnames that never leave the machine.
119
- *
120
- * @param hostname - `URL.hostname` (IPv6 arrives bracketed).
121
- * @returns Whether the host is loopback.
122
- *
123
- * @example
124
- * ```ts
125
- * isLoopbackHost(new URL("http://[::1]:3000").hostname); // true
126
- * ```
127
- */
128
- export declare function isLoopbackHost(hostname: string): boolean;
129
- /**
130
- * Refuse an API URL that would send the bearer token in cleartext:
131
- * anything but `https://`, except plain `http://` to a loopback host
132
- * (the local cloud stack).
133
- *
134
- * @param url - Candidate API URL.
135
- * @param source - Where it came from, for the error (`--url`,
136
- * `IAMU_API_URL`, ...).
137
- * @throws {@link IamuValidationError} when the URL is malformed or insecure.
138
- *
139
- * @example
140
- * ```ts
141
- * assertSecureApiUrl(process.env.IAMU_API_URL ?? DEFAULT_API_URL, "IAMU_API_URL");
142
- * ```
143
- */
144
- export declare function assertSecureApiUrl(url: string, source: string): void;
@@ -1,11 +0,0 @@
1
- import type { OutlineFrontmatter, ScenarioFrontmatter } from "@iamu-dev/protocol";
2
- export interface ChangedFilesResult {
3
- baseRef: string;
4
- files: string[];
5
- }
6
- /** Resolve changed files against a git base ref (e.g. origin/main, HEAD~1). */
7
- export declare function getChangedFiles(projectRoot: string, explicitRef?: string | boolean): ChangedFilesResult | null;
8
- /** Extract matching tokens from a scenario and its outline. */
9
- export declare function extractScenarioKeywords(scenario: ScenarioFrontmatter, outline?: OutlineFrontmatter): string[];
10
- /** Checks whether any changed file matches the scenario's keywords or path. */
11
- export declare function matchesChangedFiles(changedFiles: string[], scenario: ScenarioFrontmatter, outline?: OutlineFrontmatter): boolean;
@@ -1,24 +0,0 @@
1
- export interface DoctorCheck {
2
- category: "runtime" | "browser" | "project" | "agent" | "cloud";
3
- name: string;
4
- status: "ok" | "warn" | "error";
5
- message: string;
6
- remedy?: string;
7
- }
8
- export interface DoctorResult {
9
- ok: boolean;
10
- checks: DoctorCheck[];
11
- summary: {
12
- ok: number;
13
- warn: number;
14
- error: number;
15
- };
16
- }
17
- /** Check if a TCP port is available or bound */
18
- export declare function checkPortAvailable(port: number): Promise<boolean>;
19
- /** Check CDP responsiveness on a port */
20
- export declare function checkCdpResponsive(port: number): Promise<boolean>;
21
- export declare function runDoctorChecks(projectRoot?: string): Promise<DoctorResult>;
22
- export declare function doctor(opts?: {
23
- json?: boolean;
24
- }): Promise<void>;