@quantiya/codevibe-codex-plugin 2.0.111 → 2.0.112

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,30 @@
1
+ import { type ProcessRunner } from './git-runner';
2
+ export type HandOffGit = {
3
+ kind: 'available';
4
+ bin: string;
5
+ } | {
6
+ kind: 'unavailable';
7
+ why: string;
8
+ };
9
+ /** A transient failure (spawn pressure, signal, deadline): fail this probe, ask again next time. */
10
+ export declare class GitAvailabilityTransient extends Error {
11
+ }
12
+ export declare const MACOS_GIT_SHIM = "/usr/bin/git";
13
+ export interface AvailabilityDeps {
14
+ platform: NodeJS.Platform;
15
+ env: NodeJS.ProcessEnv;
16
+ /**
17
+ * a regular file that is executable (`stat` + `access(X_OK)`); a directory is never executable here. A definitive
18
+ * absence (ENOENT, ENOTDIR, EACCES, ELOOP, ENAMETOOLONG) is `false`; any other filesystem error throws, and the
19
+ * resolver treats it as transient (never cached).
20
+ */
21
+ isExecutable(p: string): Promise<boolean>;
22
+ realpath(p: string): Promise<string>;
23
+ readlink(p: string): Promise<string>;
24
+ }
25
+ export declare const defaultAvailabilityDeps: AvailabilityDeps;
26
+ /** Decide the hand-off git. Definitive answers resolve; transient ones throw `GitAvailabilityTransient`. */
27
+ export declare function resolveHandOffGit(runner: ProcessRunner, deps: AvailabilityDeps): Promise<HandOffGit>;
28
+ export declare function handOffGit(runner: ProcessRunner, deps?: AvailabilityDeps): Promise<HandOffGit>;
29
+ /** Tests only. */
30
+ export declare function resetHandOffGitCacheForTests(): void;
@@ -0,0 +1,34 @@
1
+ export declare const errnoCode: (err: unknown) => string;
2
+ /**
3
+ * git's own "not a repository" failure: exit status 128 with that diagnostic as git's `fatal:` line (`LC_ALL=C`) —
4
+ * the ONLY stderr line that starts with `fatal: `. `GIT_TRACE`/`GIT_TRACE2` output and `warning:` lines can come before
5
+ * it, and a path git prints can carry a newline followed by text of our choosing (a folder named
6
+ * "d\nfatal: not a git repository: x"), so a `fatal: `-prefixed line is not necessarily git's diagnostic. git's `die()`
7
+ * always prints its own `fatal: ` line, so when exactly one line has the prefix it is git's; when several do, which one
8
+ * is git's cannot be told and the failure is not classified (fail closed). git has two forms:
9
+ * `fatal: not a git repository (or any of the parent directories): .git` (discovery found nothing) and
10
+ * `fatal: not a git repository: <gitdir>` (a `.git` file, or `GIT_DIR`, naming something that is not a repository — a
11
+ * linked worktree whose repository is gone, a submodule folder copied out of its project). Matching the phrase
12
+ * anywhere in stderr would also match a path quoted inside another diagnostic or a trace line — "invalid gitfile
13
+ * format: <path>" under a folder named "not a git repository" — and a timeout or a signal is never "not a repository".
14
+ */
15
+ export declare function isNotAGitRepositoryFailure(err: unknown): boolean;
16
+ /**
17
+ * git's "detected dubious ownership in repository at '<path>'" refusal (`safe.directory`), classified by the same
18
+ * single-`fatal:`-line rule: git prints the path, so the phrase alone could be planted by a folder name.
19
+ */
20
+ export declare function isDubiousOwnershipFailure(err: unknown): boolean;
21
+ /**
22
+ * For a folder with a `.git` marker: is it really inside a repository? A `.git` that git itself does not
23
+ * accept (an empty or stale `.git` folder, a gitfile of a removed worktree) or a missing `git` binary is
24
+ * `not-a-repository`, so the folder is walked like any other; any other git failure is `error`.
25
+ */
26
+ export declare function classifyGitWorkspace(workspaceRoot: string, timeoutMs: number): Promise<'repository' | 'not-a-repository' | 'error'>;
27
+ /** Variables that make git use a repository other than the one in its working folder. */
28
+ export declare const REPOSITORY_LOCATING_GIT_ENV: readonly ["GIT_DIR", "GIT_WORK_TREE", "GIT_COMMON_DIR", "GIT_OBJECT_DIRECTORY", "GIT_INDEX_FILE", "GIT_ALTERNATE_OBJECT_DIRECTORIES", "GIT_NAMESPACE", "GIT_CEILING_DIRECTORIES", "GIT_DISCOVERY_ACROSS_FILESYSTEM"];
29
+ /** The launch folder's environment (today's, as `probeWorkspaceTreeFingerprint` uses). */
30
+ export declare function launchGitEnv(): NodeJS.ProcessEnv;
31
+ /** The environment for a repository found by the walk, or nested in one: no repository-locating variable. */
32
+ export declare function repositoryScrubbedEnv(): NodeJS.ProcessEnv;
33
+ /** Leading arguments of every advisory git call: no fsmonitor daemon, no optional index writes. */
34
+ export declare const ADVISORY_GIT_PREFIX: readonly ["-c", "core.fsmonitor=false", "--no-optional-locks"];
@@ -0,0 +1,24 @@
1
+ /** No process is started once fewer than this many milliseconds remain before the deadline. */
2
+ export declare const MIN_SPAWN_BUDGET_MS = 50;
3
+ /** A failed run: same fields `execFile` failures carry, so the git-classify readers work on both. */
4
+ export declare class ProcessRunError extends Error {
5
+ readonly code: number | string | null;
6
+ readonly signal: NodeJS.Signals | null;
7
+ readonly killed: boolean;
8
+ readonly stderr: string;
9
+ /** the deadline ended the run (or no time was left to start it) */
10
+ readonly timedOut: boolean;
11
+ constructor(message: string, code: number | string | null, signal: NodeJS.Signals | null, killed: boolean, stderr: string,
12
+ /** the deadline ended the run (or no time was left to start it) */
13
+ timedOut: boolean);
14
+ }
15
+ export interface ProcessRunner {
16
+ /** Resolves with stdout on exit 0; rejects with `ProcessRunError` otherwise. */
17
+ run(bin: string, args: readonly string[], opts: {
18
+ cwd: string;
19
+ env: NodeJS.ProcessEnv;
20
+ }): Promise<string>;
21
+ /** Process-group ids this runner spawned (diagnostics and tests). */
22
+ readonly spawnedGroups: readonly number[];
23
+ }
24
+ export declare function createProcessRunner(deadline: number, concurrency?: number): ProcessRunner;
@@ -0,0 +1,47 @@
1
+ import type { ProcessRunner } from './git-runner';
2
+ export declare const ADVISORY_FINGERPRINT_MAX_REPOSITORIES = 128;
3
+ /**
4
+ * A failure that ends the whole probe with this reason (fail closed). `dir` (absolute) and a bounded `category`
5
+ * (`timeout`, `exit-<code>`, `signal-<sig>`, `spawn-<errno>`, or a fixed step name) are for the desktop log only — never
6
+ * git's stderr.
7
+ */
8
+ export declare class ProbeFailure extends Error {
9
+ readonly reason: string;
10
+ readonly dir?: string | undefined;
11
+ readonly category?: string | undefined;
12
+ constructor(reason: string, dir?: string | undefined, category?: string | undefined);
13
+ }
14
+ export interface RecordContext {
15
+ runner: ProcessRunner;
16
+ git: string;
17
+ env: NodeJS.ProcessEnv;
18
+ /** absolute repository path → its control set, from the before-turn probe (after-turn probe only) */
19
+ before: Readonly<Record<string, string>> | null;
20
+ /** filled with every 3B repository's control set (absolute path → set) */
21
+ controlSets: Record<string, string>;
22
+ repositories: number;
23
+ }
24
+ /** A bounded failure category from a process-runner failure (never its message, which names the binary path). */
25
+ export declare function failureCategory(err: unknown): string;
26
+ /** `mode : size : mtime rounded to the nearest second : inode` — the walk's stamp, plus mode. */
27
+ export declare function stamp(p: string): Promise<string>;
28
+ export type RootTest = {
29
+ kind: 'root';
30
+ gitDir: string;
31
+ commonDir: string;
32
+ } | {
33
+ kind: 'walk';
34
+ };
35
+ /** Is `dir` (which has a `.git` entry) a repository ROOT? Not a repository / dubious ownership / not a root → walk it. */
36
+ export declare function repositoryRoot(dir: string, ctx: RecordContext): Promise<RootTest>;
37
+ /** 3B: a repository found by the walk (or nested in one). */
38
+ export declare function walkFoundRecord(dir: string, info: {
39
+ gitDir: string;
40
+ commonDir: string;
41
+ }, ctx: RecordContext, depth?: number): Promise<string>;
42
+ /**
43
+ * 3A: the launch repository (today's coverage plus HEAD). Nested records use the scrubbed environment. A nested entry
44
+ * that git does not accept as a repository root (not a repository, dubious ownership, a different top level) keeps its
45
+ * status line only — today's coverage; an unclassified git failure fails the probe (step 2).
46
+ */
47
+ export declare function launchRecord(top: string, ctx: RecordContext, nestedEnv: NodeJS.ProcessEnv, depth?: number): Promise<string>;
@@ -0,0 +1,34 @@
1
+ import { type AvailabilityDeps } from './git-availability';
2
+ /** Budget of the whole probe (walk and every git call); past it the probe fails (fail closed). */
3
+ export declare const ADVISORY_WALK_FINGERPRINT_TIMEOUT_MS = 10000;
4
+ /** Entry cap of the walk (a repository handed to git counts as one entry); past it the probe fails (fail closed). */
5
+ export declare const ADVISORY_WALK_FINGERPRINT_MAX_ENTRIES = 200000;
6
+ /** git processes the probe runs at once. */
7
+ export declare const ADVISORY_GIT_CONCURRENCY = 4;
8
+ export type AdvisoryWorkspaceFingerprintProbe = {
9
+ kind: 'fingerprint';
10
+ /** `git`: launch inside a repository; `walk`: no repository handed to git; `walk+git`: some were */
11
+ method: 'git' | 'walk' | 'walk+git';
12
+ value: string;
13
+ entries: number;
14
+ durationMs: number;
15
+ /** control sets of repositories found by the walk (absolute path → set), for the after-turn pre-check */
16
+ controlSets?: Readonly<Record<string, string>>;
17
+ } | {
18
+ kind: 'probe-failed';
19
+ method: 'git' | 'walk' | 'marker';
20
+ reason: string;
21
+ durationMs: number;
22
+ };
23
+ export interface AdvisoryProbeOptions {
24
+ timeoutMs?: number;
25
+ maxEntries?: number;
26
+ /** the before-turn result; its control sets gate any git run in a repository the walk finds */
27
+ before?: AdvisoryWorkspaceFingerprintProbe;
28
+ /** timeout of the launch-folder classification call (`git rev-parse --show-toplevel`) */
29
+ classifyTimeoutMs?: number;
30
+ /** git processes run at once (default ADVISORY_GIT_CONCURRENCY) */
31
+ gitConcurrency?: number;
32
+ availability?: AvailabilityDeps;
33
+ }
34
+ export declare function probeAdvisoryWorkspaceFingerprintImpl(workspaceRoot: string, options?: AdvisoryProbeOptions): Promise<AdvisoryWorkspaceFingerprintProbe>;
@@ -97,12 +97,22 @@ export declare function brainstormAllQuotaWalledMessage(walled: readonly Brainst
97
97
  * `logger.warn` (the WIRE is what the ZK invariant governs, NOT the local log
98
98
  * file, which never leaves the machine). The invariant is stricter than
99
99
  * ZK-on-wire (the mirror is E2E-encrypted regardless): only a BOUNDED enum label
100
- * is surfaced on the wire, never the agent's diagnostic. Three labels only —
101
- * quota-wall vs timeout vs generic failure — so no free-form detail can leak
102
- * through. [#635] the `'quota_walled'`/`'failed'` strings are preserved VERBATIM
100
+ * is surfaced on the wire, never the agent's diagnostic. Five closed labels —
101
+ * quota-wall, timeout, the two workspace-check outcomes (repo-aware fingerprint
102
+ * design r6), and generic failure — so no free-form detail can leak through. [#635] the `'quota_walled'`/`'failed'` strings are preserved VERBATIM
103
103
  * from the prior 2-label version; only `'timed_out'` is new.
104
104
  */
105
- export type BrainstormPanelFailureReason = 'quota_walled' | 'timed_out' | 'failed';
105
+ export type BrainstormPanelFailureReason = 'quota_walled' | 'timed_out' | 'workspace_unverifiable' | 'workspace_changed' | 'failed';
106
+ /** The user-facing text for a read-only turn refused by the workspace check, or null for any other reason. */
107
+ export declare function workspaceVerificationMessage(unavailableReason: string | null | undefined): string | null;
108
+ /** Map a failed advisory result to its closed panel label: quota wall > timeout > workspace check > generic. */
109
+ export declare function brainstormPanelFailureReasonFor(result: {
110
+ quotaWalled: boolean;
111
+ timedOut: boolean;
112
+ usage: {
113
+ unavailableReason?: string | null;
114
+ };
115
+ }): BrainstormPanelFailureReason;
106
116
  export declare function brainstormPanelFailureNotice(reason: BrainstormPanelFailureReason): string;
107
117
  export declare const BRAINSTORM_PRIOR_CONTEXT_LABEL = "Prior brainstorm context (idea so far + open questions):";
108
118
  export declare const BRAINSTORM_REQUEST_LABEL = "Current brainstorm request:";