@oh-my-pi/pi-coding-agent 17.2.11 → 17.2.12
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/CHANGELOG.md +13 -0
- package/dist/{CHANGELOG-d9xenpn9.md → CHANGELOG-k9ghy5sn.md} +13 -0
- package/dist/cli.js +10795 -10791
- package/dist/types/advisor/runtime.d.ts +1 -1
- package/dist/types/config/custom-models.d.ts +31 -0
- package/dist/types/config/model-config-values.d.ts +19 -0
- package/dist/types/config/model-patch.d.ts +93 -0
- package/dist/types/config/model-provider-discovery.d.ts +51 -0
- package/dist/types/config/model-registry.d.ts +5 -52
- package/dist/types/config/settings.d.ts +5 -3
- package/dist/types/debug/raw-sse-buffer.d.ts +9 -0
- package/dist/types/discovery/agent-plugin-format.d.ts +6 -13
- package/dist/types/discovery/contained-path.d.ts +2 -3
- package/dist/types/eval/executor-base.d.ts +8 -2
- package/dist/types/eval/kernel-session-registry.d.ts +60 -0
- package/dist/types/export/share.d.ts +1 -1
- package/dist/types/lsp/diagnostics.d.ts +96 -0
- package/dist/types/lsp/index.d.ts +7 -128
- package/dist/types/lsp/servers.d.ts +72 -0
- package/dist/types/lsp/tool.d.ts +42 -0
- package/dist/types/lsp/workspace-diagnostics.d.ts +12 -0
- package/dist/types/lsp/writethrough.d.ts +33 -0
- package/dist/types/mcp/transports/header-policy.d.ts +2 -1
- package/dist/types/modes/components/agent-hub-projection.d.ts +2 -7
- package/dist/types/modes/components/agent-hub-renderer.d.ts +0 -7
- package/dist/types/modes/theme/color.d.ts +19 -0
- package/dist/types/modes/theme/loader.d.ts +19 -0
- package/dist/types/modes/theme/schema.d.ts +175 -0
- package/dist/types/modes/theme/symbols.d.ts +28 -0
- package/dist/types/modes/theme/theme-class.d.ts +244 -0
- package/dist/types/modes/theme/theme.d.ts +9 -280
- package/dist/types/modes/theme/tui-adapters.d.ts +13 -0
- package/dist/types/registry/agent-registry.d.ts +1 -3
- package/dist/types/secrets/index.d.ts +3 -1
- package/dist/types/secrets/message-transform.d.ts +40 -0
- package/dist/types/secrets/obfuscator.d.ts +0 -108
- package/dist/types/secrets/placeholder-scan.d.ts +95 -0
- package/dist/types/secrets/placeholder.d.ts +94 -0
- package/dist/types/secrets/replacement.d.ts +82 -0
- package/dist/types/session/agent-session-types.d.ts +6 -0
- package/dist/types/session/agent-session.d.ts +1 -1
- package/dist/types/session/session-handoff.d.ts +3 -3
- package/dist/types/session/session-manager.d.ts +32 -0
- package/dist/types/session/session-provider-boundary.d.ts +1 -1
- package/dist/types/session/turn-recovery.d.ts +2 -2
- package/dist/types/slash-commands/builtin-collaboration.d.ts +2 -0
- package/dist/types/slash-commands/builtin-completions.d.ts +36 -0
- package/dist/types/slash-commands/builtin-control.d.ts +2 -0
- package/dist/types/slash-commands/builtin-lifecycle.d.ts +3 -0
- package/dist/types/slash-commands/builtin-marketplace.d.ts +11 -0
- package/dist/types/slash-commands/builtin-modes.d.ts +5 -0
- package/dist/types/slash-commands/builtin-registry.d.ts +1 -1
- package/dist/types/slash-commands/builtin-session.d.ts +2 -0
- package/dist/types/tools/gh-common.d.ts +69 -0
- package/dist/types/tools/gh-pr-checkout.d.ts +84 -0
- package/dist/types/tools/gh-pr-diff.d.ts +102 -0
- package/dist/types/tools/gh-run-watch.d.ts +78 -0
- package/dist/types/tools/gh-search.d.ts +61 -0
- package/dist/types/tools/gh-types.d.ts +340 -0
- package/dist/types/tools/gh-view.d.ts +88 -0
- package/dist/types/tools/gh.d.ts +4 -201
- package/dist/types/tools/read-archive.d.ts +16 -0
- package/dist/types/tools/read-format.d.ts +104 -0
- package/dist/types/tools/read-path-resolution.d.ts +19 -0
- package/dist/types/tools/read-pdf-images.d.ts +12 -0
- package/dist/types/tools/read-renderer.d.ts +24 -0
- package/dist/types/tools/read-selector.d.ts +27 -0
- package/dist/types/tools/read-sqlite.d.ts +16 -0
- package/dist/types/tools/read-summary.d.ts +19 -0
- package/dist/types/tools/read.d.ts +1 -23
- package/dist/types/tools/shell-tokenize.d.ts +2 -1
- package/dist/types/utils/changelog.d.ts +0 -5
- package/package.json +13 -13
- package/src/advisor/runtime.ts +12 -7
- package/src/config/custom-models.ts +188 -0
- package/src/config/model-config-values.ts +128 -0
- package/src/config/model-patch.ts +252 -0
- package/src/config/model-provider-discovery.ts +132 -0
- package/src/config/model-registry.ts +64 -704
- package/src/config/settings.ts +7 -3
- package/src/debug/raw-sse-buffer.ts +20 -0
- package/src/discovery/agent-plugin-format.ts +7 -7
- package/src/discovery/contained-path.ts +2 -5
- package/src/edit/hashline/diff.ts +5 -1
- package/src/eval/executor-base.ts +39 -6
- package/src/eval/jl/executor.ts +82 -371
- package/src/eval/kernel-session-registry.ts +398 -0
- package/src/eval/py/executor.ts +53 -261
- package/src/eval/rb/executor.ts +36 -279
- package/src/export/share.ts +2 -1
- package/src/lsp/diagnostics.ts +516 -0
- package/src/lsp/index.ts +20 -2819
- package/src/lsp/servers.ts +296 -0
- package/src/lsp/tool.ts +1352 -0
- package/src/lsp/workspace-diagnostics.ts +170 -0
- package/src/lsp/writethrough.ts +561 -0
- package/src/mcp/transports/header-policy.ts +1 -1
- package/src/modes/components/agent-hub-projection.ts +2 -2
- package/src/modes/components/agent-hub-renderer.ts +3 -7
- package/src/modes/controllers/command-controller.ts +4 -1
- package/src/modes/theme/color.ts +133 -0
- package/src/modes/theme/loader.ts +178 -0
- package/src/modes/theme/schema.ts +263 -0
- package/src/modes/theme/symbols.ts +1000 -0
- package/src/modes/theme/theme-class.ts +611 -0
- package/src/modes/theme/theme.ts +27 -2453
- package/src/modes/theme/tui-adapters.ts +279 -0
- package/src/registry/agent-registry.ts +2 -2
- package/src/secrets/index.ts +6 -12
- package/src/secrets/message-transform.ts +287 -0
- package/src/secrets/obfuscator.ts +39 -1303
- package/src/secrets/placeholder-scan.ts +506 -0
- package/src/secrets/placeholder.ts +309 -0
- package/src/secrets/replacement.ts +216 -0
- package/src/session/agent-session-types.ts +6 -0
- package/src/session/agent-session.ts +113 -7
- package/src/session/indexed-session-storage.ts +7 -2
- package/src/session/session-advisors.ts +32 -34
- package/src/session/session-handoff.ts +39 -20
- package/src/session/session-manager.ts +67 -3
- package/src/session/session-provider-boundary.ts +3 -6
- package/src/session/turn-recovery.ts +21 -12
- package/src/slash-commands/builtin-collaboration.ts +504 -0
- package/src/slash-commands/builtin-completions.ts +291 -0
- package/src/slash-commands/builtin-control.ts +78 -0
- package/src/slash-commands/builtin-lifecycle.ts +506 -0
- package/src/slash-commands/builtin-marketplace.ts +567 -0
- package/src/slash-commands/builtin-modes.ts +518 -0
- package/src/slash-commands/builtin-registry.ts +21 -3000
- package/src/slash-commands/builtin-session.ts +592 -0
- package/src/task/executor.ts +17 -14
- package/src/tools/gh-common.ts +288 -0
- package/src/tools/gh-pr-checkout.ts +679 -0
- package/src/tools/gh-pr-diff.ts +473 -0
- package/src/tools/gh-run-watch.ts +1015 -0
- package/src/tools/gh-search.ts +500 -0
- package/src/tools/gh-types.ts +379 -0
- package/src/tools/gh-view.ts +612 -0
- package/src/tools/gh.ts +109 -3821
- package/src/tools/read-archive.ts +209 -0
- package/src/tools/read-format.ts +593 -0
- package/src/tools/read-path-resolution.ts +36 -0
- package/src/tools/read-pdf-images.ts +250 -0
- package/src/tools/read-renderer.ts +289 -0
- package/src/tools/read-selector.ts +84 -0
- package/src/tools/read-sqlite.ts +215 -0
- package/src/tools/read-summary.ts +199 -0
- package/src/tools/read.ts +77 -1820
- package/src/tools/shell-tokenize.ts +1 -1
- package/src/utils/changelog.ts +1 -1
- package/src/utils/title-generator.ts +3 -1
- package/src/web/search/providers/zai.ts +12 -3
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { AgentToolResult } from "@oh-my-pi/pi-agent-core";
|
|
2
|
+
import type { ToolSession } from "./index.js";
|
|
3
|
+
import type { GhToolDetails } from "./gh.js";
|
|
4
|
+
import type { GhLabel, GhUser } from "./gh-types.js";
|
|
5
|
+
export declare function normalizeText(value: string | null | undefined): string;
|
|
6
|
+
export declare function normalizeBlock(value: string | null | undefined): string;
|
|
7
|
+
export declare function looksLikeGitHubUrl(value: string | undefined): boolean;
|
|
8
|
+
export declare function normalizeOptionalString(value: string | null | undefined): string | undefined;
|
|
9
|
+
export declare function normalizePrIdentifierList(value: string | string[] | undefined): string[];
|
|
10
|
+
export declare function requireNonEmpty(value: string | null | undefined, label: string): string;
|
|
11
|
+
export declare function appendRepoFlag(args: string[], repo: string | undefined, identifier?: string): void;
|
|
12
|
+
export declare const REPO_API_URL_PREFIX = "https://api.github.com/repos/";
|
|
13
|
+
export declare const PR_URL_PATTERN: RegExp;
|
|
14
|
+
export declare const ISSUE_URL_PATTERN: RegExp;
|
|
15
|
+
export declare function requireCurrentGitBranch(cwd: string, signal?: AbortSignal): Promise<string>;
|
|
16
|
+
export declare function requireCurrentGitHead(cwd: string, signal?: AbortSignal): Promise<string>;
|
|
17
|
+
export declare function formatAuthor(author: GhUser | null | undefined): string | undefined;
|
|
18
|
+
export declare function formatLabels(labels: GhLabel[] | undefined): string | undefined;
|
|
19
|
+
export declare function pushLine(lines: string[], label: string, value: string | number | boolean | undefined): void;
|
|
20
|
+
export declare function parsePullRequestUrl(value: string | undefined): {
|
|
21
|
+
repo?: string;
|
|
22
|
+
prNumber?: number;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Parse a digit-only decimal positive integer or return undefined. Rejects
|
|
26
|
+
* `1e2`, `0x10`, `12.0`, leading +/-, or any other shape `Number()` would
|
|
27
|
+
* accept — those would otherwise key the cache against the wrong row.
|
|
28
|
+
*/
|
|
29
|
+
export declare function parsePositiveDecimalInt(value: string | undefined): number | undefined;
|
|
30
|
+
export declare function parseIssueUrl(value: string | undefined): {
|
|
31
|
+
repo?: string;
|
|
32
|
+
issueNumber?: number;
|
|
33
|
+
};
|
|
34
|
+
export declare function githubRepoSlugEquals(left: string | undefined, right: string): boolean;
|
|
35
|
+
export declare function resolveGitHubRepo(cwd: string, repo: string | undefined, runRepo: string | undefined, signal?: AbortSignal): Promise<string>;
|
|
36
|
+
/**
|
|
37
|
+
* Process-lifetime cache of `gh repo view --json nameWithOwner` lookups keyed
|
|
38
|
+
* by absolute cwd. Avoids repeated `gh` chatter when the same protocol handler
|
|
39
|
+
* or tool call resolves the default repo many times in a row.
|
|
40
|
+
*
|
|
41
|
+
* The shared lookup is intentionally **not** bound to any caller's
|
|
42
|
+
* AbortSignal. Cancelling one caller would otherwise kill the underlying
|
|
43
|
+
* `gh repo view` for every concurrent waiter on the same cwd. Each caller's
|
|
44
|
+
* signal is honored at the wait point via `untilAborted` instead, so an abort
|
|
45
|
+
* unwinds only that caller.
|
|
46
|
+
*/
|
|
47
|
+
export declare const DEFAULT_REPO_RESOLVED: Map<string, string>;
|
|
48
|
+
export declare const DEFAULT_REPO_INFLIGHT: Map<string, Promise<string>>;
|
|
49
|
+
export declare function resolveDefaultRepoMemoized(cwd: string, signal?: AbortSignal): Promise<string>;
|
|
50
|
+
/**
|
|
51
|
+
* Best-effort cached cwd → `owner/repo` resolution that swallows any failure
|
|
52
|
+
* (not a git checkout, no GitHub remote, `gh` unauthenticated, …) into
|
|
53
|
+
* `undefined`. Use where the cwd repo is a convenience fallback, not a safety
|
|
54
|
+
* check.
|
|
55
|
+
*/
|
|
56
|
+
export declare function tryResolveCurrentRepo(cwd: string, signal: AbortSignal | undefined): Promise<string | undefined>;
|
|
57
|
+
/**
|
|
58
|
+
* Best-effort fresh cwd → `owner/repo` resolution for safety checks that must
|
|
59
|
+
* reflect the repository currently mounted at `cwd`, not the process-lifetime
|
|
60
|
+
* default-repo cache.
|
|
61
|
+
*/
|
|
62
|
+
export declare function tryResolveCurrentRepoFresh(cwd: string, signal: AbortSignal | undefined): Promise<string | undefined>;
|
|
63
|
+
export declare function saveArtifactText(session: ToolSession, toolType: string, text: string): Promise<string | undefined>;
|
|
64
|
+
export declare function appendArtifactReference(text: string, artifactId: string | undefined, label: string): string;
|
|
65
|
+
export declare function buildTextResult(text: string, sourceUrl?: string, details?: GhToolDetails, options?: {
|
|
66
|
+
artifactId?: string;
|
|
67
|
+
artifactLabel?: string;
|
|
68
|
+
useless?: boolean;
|
|
69
|
+
}): AgentToolResult<GhToolDetails>;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { AgentToolResult } from "@oh-my-pi/pi-agent-core";
|
|
2
|
+
import * as git from "../utils/git.js";
|
|
3
|
+
import type { ToolSession } from "./index.js";
|
|
4
|
+
import type { GhPrCheckoutSummary, GhToolDetails } from "./gh.js";
|
|
5
|
+
import type { GhPrViewData, GhRepoViewData, GithubInput } from "./gh-types.js";
|
|
6
|
+
export declare const GH_REPO_CLONE_FIELDS: string[];
|
|
7
|
+
export declare const GH_PR_CHECKOUT_FIELDS: string[];
|
|
8
|
+
export declare function sanitizeRemoteName(value: string): string;
|
|
9
|
+
/** Maximum disambiguation suffixes we try before giving up on a worktree path. */
|
|
10
|
+
export declare const WORKTREE_PATH_MAX_SUFFIX = 100;
|
|
11
|
+
export declare function toLocalBranchRef(value: string): string;
|
|
12
|
+
export declare function requireGitRepoRoot(cwd: string, signal?: AbortSignal): Promise<string>;
|
|
13
|
+
export declare function requirePrimaryGitRepoRoot(cwd: string, signal?: AbortSignal): Promise<string>;
|
|
14
|
+
/**
|
|
15
|
+
* Resolve a worktree path that is free of conflicts.
|
|
16
|
+
*
|
|
17
|
+
* Given a `basePath`, return either `basePath` itself or `${basePath}-2`,
|
|
18
|
+
* `${basePath}-3`, … up to {@link WORKTREE_PATH_MAX_SUFFIX} — whichever is the
|
|
19
|
+
* first variant that is **not** registered with git as another worktree and
|
|
20
|
+
* **not** present on disk. The numeric tail salvages two rare cases that
|
|
21
|
+
* would otherwise abort a checkout: stale leftover dirs from an interrupted
|
|
22
|
+
* `git worktree add`, and the (vanishingly unlikely) `hashPath` collision
|
|
23
|
+
* between two repos that happen to produce the same 7-hex digest.
|
|
24
|
+
*/
|
|
25
|
+
export declare function resolveAvailableWorktreePath(basePath: string, existingWorktrees: git.GitWorktreeEntry[]): Promise<string>;
|
|
26
|
+
export declare function selectPrCloneUrl(originUrl: string | undefined, repo: Pick<GhRepoViewData, "url" | "sshUrl">): string;
|
|
27
|
+
export declare function getRemoteUrls(repoRoot: string, signal?: AbortSignal): Promise<Map<string, string>>;
|
|
28
|
+
export declare function ensurePrRemote(repoRoot: string, data: GhPrViewData, signal?: AbortSignal): Promise<{
|
|
29
|
+
name: string;
|
|
30
|
+
url: string;
|
|
31
|
+
}>;
|
|
32
|
+
export declare function resolvePrBranchPushTarget(repoRoot: string, localBranch: string, signal?: AbortSignal): Promise<{
|
|
33
|
+
remoteName: string;
|
|
34
|
+
remoteBranch: string;
|
|
35
|
+
remoteUrl?: string;
|
|
36
|
+
prUrl?: string;
|
|
37
|
+
maintainerCanModify?: boolean;
|
|
38
|
+
isCrossRepository: boolean;
|
|
39
|
+
}>;
|
|
40
|
+
export declare function formatPrCheckoutResult(options: {
|
|
41
|
+
data: GhPrViewData;
|
|
42
|
+
localBranch: string;
|
|
43
|
+
worktreePath: string;
|
|
44
|
+
remoteName: string;
|
|
45
|
+
remoteUrl: string;
|
|
46
|
+
reused: boolean;
|
|
47
|
+
}): string;
|
|
48
|
+
export declare function formatPrPushResult(options: {
|
|
49
|
+
localBranch: string;
|
|
50
|
+
remoteName: string;
|
|
51
|
+
remoteBranch: string;
|
|
52
|
+
remoteUrl?: string;
|
|
53
|
+
prUrl?: string;
|
|
54
|
+
forceWithLease: boolean;
|
|
55
|
+
}): string;
|
|
56
|
+
export declare function joinSections(sections: string[]): string[];
|
|
57
|
+
export declare function executePrCheckout(session: ToolSession, params: GithubInput, signal: AbortSignal | undefined): Promise<AgentToolResult<GhToolDetails>>;
|
|
58
|
+
export interface PrCheckoutOptions {
|
|
59
|
+
prRef: string | undefined;
|
|
60
|
+
repo: string | undefined;
|
|
61
|
+
force: boolean;
|
|
62
|
+
}
|
|
63
|
+
export interface PrCheckoutOutcome {
|
|
64
|
+
data: GhPrViewData;
|
|
65
|
+
localBranch: string;
|
|
66
|
+
worktreePath: string;
|
|
67
|
+
remoteName: string;
|
|
68
|
+
remoteUrl: string;
|
|
69
|
+
headRefName: string;
|
|
70
|
+
reused: boolean;
|
|
71
|
+
}
|
|
72
|
+
export declare function checkoutPullRequest(session: ToolSession, signal: AbortSignal | undefined, options: PrCheckoutOptions): Promise<PrCheckoutOutcome>;
|
|
73
|
+
export declare function outcomeToSummary(outcome: PrCheckoutOutcome): GhPrCheckoutSummary;
|
|
74
|
+
export declare function executePrPush(session: ToolSession, params: GithubInput, signal: AbortSignal | undefined): Promise<AgentToolResult<GhToolDetails>>;
|
|
75
|
+
export declare function executePrCreate(session: ToolSession, params: GithubInput, signal: AbortSignal | undefined): Promise<AgentToolResult<GhToolDetails>>;
|
|
76
|
+
export declare function formatPrCreateResult(options: {
|
|
77
|
+
url: string;
|
|
78
|
+
prNumber?: number;
|
|
79
|
+
data?: GhPrViewData;
|
|
80
|
+
title?: string;
|
|
81
|
+
base?: string;
|
|
82
|
+
head?: string;
|
|
83
|
+
draft?: boolean;
|
|
84
|
+
}): string;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { Settings } from "../config/settings.js";
|
|
2
|
+
import type { ViewLookupResult } from "./gh-view.js";
|
|
3
|
+
export declare const PR_DIFF_FILES_PAGE_SIZE = 100;
|
|
4
|
+
export declare const PR_DIFF_FILES_MAX = 3000;
|
|
5
|
+
export interface PrDiffFile {
|
|
6
|
+
/** Display path. Prefers the post-image (`b/<path>`) when present. */
|
|
7
|
+
path: string;
|
|
8
|
+
additions: number;
|
|
9
|
+
deletions: number;
|
|
10
|
+
changeType: "modified" | "added" | "deleted" | "renamed" | "binary";
|
|
11
|
+
/** Pre-image path for renames/deletes; same as `path` otherwise. */
|
|
12
|
+
oldPath?: string;
|
|
13
|
+
/** Byte offset of the section's `diff --git` line in the unified diff. */
|
|
14
|
+
startOffset: number;
|
|
15
|
+
/** Byte offset of the next section (or end-of-text). */
|
|
16
|
+
endOffset: number;
|
|
17
|
+
}
|
|
18
|
+
export interface PrDiffPayload {
|
|
19
|
+
/** Full unified diff text as returned by `gh pr diff --color never`. */
|
|
20
|
+
unified: string;
|
|
21
|
+
files: PrDiffFile[];
|
|
22
|
+
}
|
|
23
|
+
export interface PrDiffLookupOptions {
|
|
24
|
+
cwd: string;
|
|
25
|
+
repo: string;
|
|
26
|
+
number: number;
|
|
27
|
+
signal?: AbortSignal;
|
|
28
|
+
settings?: Settings;
|
|
29
|
+
cacheAuthKey?: string | null;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Split `gh pr diff` output on `^diff --git ` boundaries and parse per-file
|
|
33
|
+
* metadata. The unified diff is preserved verbatim so callers can slice it by
|
|
34
|
+
* byte offsets without re-running gh.
|
|
35
|
+
*/
|
|
36
|
+
export declare function parsePrUnifiedDiff(text: string): PrDiffPayload;
|
|
37
|
+
export interface ParsedDiffHeaderToken {
|
|
38
|
+
value: string;
|
|
39
|
+
nextIndex: number;
|
|
40
|
+
}
|
|
41
|
+
export declare function skipDiffHeaderSpaces(text: string, index: number): number;
|
|
42
|
+
export declare function parseDiffQuotedEscape(text: string, slashIndex: number): ParsedDiffHeaderToken;
|
|
43
|
+
export declare function parseDiffQuotedToken(text: string, startIndex: number): ParsedDiffHeaderToken | undefined;
|
|
44
|
+
export declare function parseDiffHeaderToken(text: string, startIndex: number): ParsedDiffHeaderToken | undefined;
|
|
45
|
+
export declare function stripPrDiffPathPrefix(value: string, prefix: "a/" | "b/"): string | undefined;
|
|
46
|
+
export declare function parsePrDiffHeaderPaths(header: string): {
|
|
47
|
+
oldPath?: string;
|
|
48
|
+
newPath?: string;
|
|
49
|
+
};
|
|
50
|
+
export declare function isPrDiffFileHeaderLine(line: string): boolean;
|
|
51
|
+
export declare function parsePrDiffSection(section: string, startOffset: number, endOffset: number): PrDiffFile;
|
|
52
|
+
/**
|
|
53
|
+
* A single entry from `GET /repos/{owner}/{repo}/pulls/{n}/files`. `patch` is
|
|
54
|
+
* absent for binary files and for individual file diffs GitHub deems too large
|
|
55
|
+
* to render.
|
|
56
|
+
*/
|
|
57
|
+
export interface GhPrFileApi {
|
|
58
|
+
filename?: string;
|
|
59
|
+
previous_filename?: string;
|
|
60
|
+
status?: string;
|
|
61
|
+
additions?: number;
|
|
62
|
+
deletions?: number;
|
|
63
|
+
patch?: string;
|
|
64
|
+
}
|
|
65
|
+
export interface GhPrApi {
|
|
66
|
+
changed_files?: number;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* GitHub rejects the aggregate PR diff endpoint with HTTP 406 once the diff
|
|
70
|
+
* exceeds 20,000 lines. Detect that specific failure so the caller can fall
|
|
71
|
+
* back to the per-file endpoint instead of aborting the whole review.
|
|
72
|
+
*/
|
|
73
|
+
export declare function isPrDiffTooLargeError(err: unknown): boolean;
|
|
74
|
+
export declare function formatSyntheticDiffPath(prefix: "a/" | "b/", path: string): string;
|
|
75
|
+
/**
|
|
76
|
+
* Reconstruct a `diff --git` section from a single files-API entry. The API's
|
|
77
|
+
* `patch` field carries only the hunk body, so the `diff --git`/`---`/`+++`
|
|
78
|
+
* headers are synthesized to match `gh pr diff` output — this keeps
|
|
79
|
+
* {@link parsePrUnifiedDiff} and the review parser producing identical section
|
|
80
|
+
* boundaries and byte offsets. Files whose `patch` is omitted (binary or
|
|
81
|
+
* too-large) stay visible with an explicit marker rather than being dropped.
|
|
82
|
+
*/
|
|
83
|
+
export declare function buildSyntheticDiffSection(file: GhPrFileApi): string | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* Fallback PR diff retrieval via the paginated per-file endpoint, used when the
|
|
86
|
+
* aggregate `gh pr diff` is rejected for exceeding GitHub's 20,000-line limit.
|
|
87
|
+
* The per-file patches are not subject to that aggregate cap, so even very
|
|
88
|
+
* large PRs can be reassembled into a synthetic unified diff.
|
|
89
|
+
*/
|
|
90
|
+
export declare function fetchPrDiffViaFilesApi(cwd: string, repo: string, number: number, signal: AbortSignal | undefined): Promise<string>;
|
|
91
|
+
export declare function fetchPrDiffFresh(cwd: string, repo: string, number: number, signal: AbortSignal | undefined): Promise<{
|
|
92
|
+
rendered: string;
|
|
93
|
+
sourceUrl: string | undefined;
|
|
94
|
+
payload: PrDiffPayload;
|
|
95
|
+
}>;
|
|
96
|
+
/**
|
|
97
|
+
* Cache-aware PR diff fetcher. Stores the full unified diff plus a parsed
|
|
98
|
+
* file index in a single `pr-diff` cache row so the listing, full-diff, and
|
|
99
|
+
* per-file slice variants of `pr://<n>/diff` share one `gh pr diff`
|
|
100
|
+
* invocation.
|
|
101
|
+
*/
|
|
102
|
+
export declare function getOrFetchPrDiff(options: PrDiffLookupOptions): Promise<ViewLookupResult<PrDiffPayload>>;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { AgentToolResult, AgentToolUpdateCallback } from "@oh-my-pi/pi-agent-core";
|
|
2
|
+
import type { ToolSession } from "./index.js";
|
|
3
|
+
import type { GhRunWatchFailedLogDetails, GhRunWatchJobDetails, GhRunWatchRunDetails, GhRunWatchViewDetails, GhToolDetails } from "./gh.js";
|
|
4
|
+
import type { GhActionsJobApi, GhActionsRunApi, GhFailedJobLog, GhRunJobSnapshot, GhRunReference, GhRunSnapshot, GithubInput } from "./gh-types.js";
|
|
5
|
+
export declare const RUN_WATCH_INTERVAL_DEFAULT = 3;
|
|
6
|
+
export declare const RUN_WATCH_INTERVAL_SLOW = 15;
|
|
7
|
+
export declare const RUN_WATCH_FAST_WINDOW_MS = 60000;
|
|
8
|
+
export declare const RUN_WATCH_NO_RUNS_GIVE_UP_MS = 90000;
|
|
9
|
+
export declare const RUN_WATCH_MAX_POLL_FAILURES = 5;
|
|
10
|
+
export declare const RUN_WATCH_GRACE_DEFAULT = 5;
|
|
11
|
+
export declare const RUN_WATCH_TAIL_DEFAULT = 15;
|
|
12
|
+
export declare const RUN_WATCH_TAIL_MAX = 200;
|
|
13
|
+
export declare const RUN_JOBS_PAGE_SIZE = 100;
|
|
14
|
+
export declare function resolveTailLimit(value: number | undefined): number;
|
|
15
|
+
export declare const RUN_URL_PATTERN: RegExp;
|
|
16
|
+
export declare const RUN_SUCCESS_CONCLUSIONS: Set<string>;
|
|
17
|
+
export declare const RUN_FAILURE_CONCLUSIONS: Set<string>;
|
|
18
|
+
export declare const JOB_FAILURE_CONCLUSIONS: Set<string>;
|
|
19
|
+
export declare function parseRunReference(value: string | undefined): GhRunReference;
|
|
20
|
+
export declare function normalizeRunJob(job: GhActionsJobApi): GhRunJobSnapshot | null;
|
|
21
|
+
export declare function normalizeRunSnapshot(run: GhActionsRunApi, jobs: GhRunJobSnapshot[]): GhRunSnapshot;
|
|
22
|
+
export declare function getRunOutcome(value: string | undefined): "success" | "failure" | "pending";
|
|
23
|
+
export declare function getRunSnapshotOutcome(run: GhRunSnapshot): "success" | "failure" | "pending";
|
|
24
|
+
export declare function getRunCollectionOutcome(runs: GhRunSnapshot[]): "success" | "failure" | "pending";
|
|
25
|
+
export declare function getRunCollectionSignature(runs: GhRunSnapshot[]): string;
|
|
26
|
+
export declare function isFailedJob(job: GhRunJobSnapshot): boolean;
|
|
27
|
+
export declare const GH_RATE_LIMIT_ERROR_PATTERN: RegExp;
|
|
28
|
+
/**
|
|
29
|
+
* Rate-limit / secondary-limit gh failures are transient; the run_watch poll
|
|
30
|
+
* loops back off and retry them instead of discarding the whole watch.
|
|
31
|
+
*/
|
|
32
|
+
export declare function isRateLimitedGhError(err: unknown): boolean;
|
|
33
|
+
export declare function formatJobState(job: GhRunJobSnapshot): string;
|
|
34
|
+
export declare function parseTimestampMs(value: string | undefined): number | undefined;
|
|
35
|
+
export declare function getJobDurationSeconds(job: GhRunJobSnapshot, observedAtMs: number): number | undefined;
|
|
36
|
+
export declare function buildRunWatchJobDetails(job: GhRunJobSnapshot, observedAtMs: number): GhRunWatchJobDetails;
|
|
37
|
+
export declare function buildRunWatchRunDetails(run: GhRunSnapshot, observedAtMs: number): GhRunWatchRunDetails;
|
|
38
|
+
export declare function buildFailedLogDetails(failedJobLogs: GhFailedJobLog[]): GhRunWatchFailedLogDetails[];
|
|
39
|
+
export declare function renderJobsSection(jobs: GhRunJobSnapshot[]): string[];
|
|
40
|
+
export declare function renderFailedJobLogs(failedJobLogs: GhFailedJobLog[], options: {
|
|
41
|
+
mode: "tail";
|
|
42
|
+
tail: number;
|
|
43
|
+
} | {
|
|
44
|
+
mode: "full";
|
|
45
|
+
}): string[];
|
|
46
|
+
export declare function renderRunSection(run: GhRunSnapshot): string[];
|
|
47
|
+
export declare function formatRunWatchSnapshot(repo: string, run: GhRunSnapshot, pollCount: number, note?: string, includeOutcome?: boolean): string;
|
|
48
|
+
export declare function formatRunWatchResult(repo: string, run: GhRunSnapshot, failedJobLogs: GhFailedJobLog[], tail: number, options?: {
|
|
49
|
+
mode?: "tail" | "full";
|
|
50
|
+
}): string;
|
|
51
|
+
export declare function formatCommitRunWatchSnapshot(repo: string, headSha: string, branch: string | undefined, runs: GhRunSnapshot[], pollCount: number, note?: string): string;
|
|
52
|
+
export declare function formatCommitRunWatchResult(repo: string, headSha: string, branch: string | undefined, runs: GhRunSnapshot[], failedJobLogs: GhFailedJobLog[], tail: number, options?: {
|
|
53
|
+
mode?: "tail" | "full";
|
|
54
|
+
}): string;
|
|
55
|
+
export declare function buildGhDetails(repo: string, run: GhRunSnapshot): GhToolDetails;
|
|
56
|
+
export declare function buildRunWatchDetails(repo: string, run: GhRunSnapshot, options?: {
|
|
57
|
+
state?: GhRunWatchViewDetails["state"];
|
|
58
|
+
pollCount?: number;
|
|
59
|
+
note?: string;
|
|
60
|
+
failedJobLogs?: GhFailedJobLog[];
|
|
61
|
+
}): GhToolDetails;
|
|
62
|
+
export declare function buildGhRunCollectionDetails(repo: string, headSha: string, branch: string | undefined, runs: GhRunSnapshot[]): GhToolDetails;
|
|
63
|
+
export declare function buildCommitRunWatchDetails(repo: string, headSha: string, branch: string | undefined, runs: GhRunSnapshot[], options?: {
|
|
64
|
+
state?: GhRunWatchViewDetails["state"];
|
|
65
|
+
pollCount?: number;
|
|
66
|
+
note?: string;
|
|
67
|
+
failedJobLogs?: GhFailedJobLog[];
|
|
68
|
+
}): GhToolDetails;
|
|
69
|
+
export declare function resolveGitHubBranchHead(cwd: string, repo: string, branch: string, signal?: AbortSignal): Promise<string>;
|
|
70
|
+
export declare function fetchRunsForCommit(cwd: string, repo: string, headSha: string, signal?: AbortSignal, completedRunJobsCache?: Map<number, GhRunJobSnapshot[]>): Promise<GhRunSnapshot[]>;
|
|
71
|
+
export declare function fetchRunJobs(cwd: string, repo: string, runId: number, signal?: AbortSignal): Promise<GhRunJobSnapshot[]>;
|
|
72
|
+
export declare function fetchRunSnapshot(cwd: string, repo: string, runId: number, signal?: AbortSignal): Promise<GhRunSnapshot>;
|
|
73
|
+
export declare function tailLogLines(log: string, tail: number): string | undefined;
|
|
74
|
+
export declare function fetchFailedJobLogs(cwd: string, repo: string, failedJobs: Array<{
|
|
75
|
+
run: GhRunSnapshot;
|
|
76
|
+
job: GhRunJobSnapshot;
|
|
77
|
+
}>, tail: number, signal?: AbortSignal): Promise<GhFailedJobLog[]>;
|
|
78
|
+
export declare function executeRunWatch(session: ToolSession, toolName: string, params: GithubInput, signal: AbortSignal | undefined, onUpdate: AgentToolUpdateCallback<GhToolDetails> | undefined): Promise<AgentToolResult<GhToolDetails>>;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { AgentToolResult } from "@oh-my-pi/pi-agent-core";
|
|
2
|
+
import type { ToolSession } from "./index.js";
|
|
3
|
+
import type { GhToolDetails } from "./gh.js";
|
|
4
|
+
import type { GhApiLabel, GhApiSearchCodeItem, GhApiSearchCommitItem, GhApiSearchIssueItem, GhApiSearchRepoItem, GhApiUser, GhLabel, GhSearchCodeResult, GhSearchCommitResult, GhSearchRepoResult, GhSearchResult, GhUser, GithubInput } from "./gh-types.js";
|
|
5
|
+
export declare const SEARCH_LIMIT_DEFAULT = 10;
|
|
6
|
+
export declare const SEARCH_LIMIT_MAX = 50;
|
|
7
|
+
export declare const FILE_PREVIEW_LIMIT = 50;
|
|
8
|
+
export declare function resolveSearchLimit(value: number | undefined): number;
|
|
9
|
+
export declare const RELATIVE_DURATION_PATTERN: RegExp;
|
|
10
|
+
export declare const ISO_DATE_PATTERN: RegExp;
|
|
11
|
+
export declare const FIXED_UNIT_MS: Record<string, number>;
|
|
12
|
+
/**
|
|
13
|
+
* Resolve a search date bound to a GitHub-search-compatible literal. Returns
|
|
14
|
+
* either a `YYYY-MM-DD` date (relative durations and date-only inputs) or a
|
|
15
|
+
* full ISO 8601 datetime string (datetime inputs), so the caller can drop it
|
|
16
|
+
* straight into a qualifier like `created:>=<value>`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function parseSearchDateBound(raw: string, now?: Date): string;
|
|
19
|
+
/**
|
|
20
|
+
* Build the GitHub-search qualifier (e.g. `created:>=2026-05-09`) for the
|
|
21
|
+
* provided bounds, or `undefined` if neither bound is set.
|
|
22
|
+
*/
|
|
23
|
+
export declare function buildSearchDateQualifier(field: string, since: string | undefined, until: string | undefined, now?: Date): string | undefined;
|
|
24
|
+
export declare function resolveSearchDateField(command: "issues" | "prs" | "commits" | "repos", requested: "created" | "updated" | undefined): string;
|
|
25
|
+
export declare function composeSearchQuery(parts: ReadonlyArray<string | undefined>): string;
|
|
26
|
+
export declare function buildGhApiSearchArgs(endpoint: "issues" | "code" | "commits" | "repositories", query: string, limit: number, extraHeaders?: ReadonlyArray<string>): string[];
|
|
27
|
+
export declare function repoFromRepositoryUrl(value: string | undefined): string | undefined;
|
|
28
|
+
export declare function apiUserToGhUser(user: GhApiUser | null | undefined): GhUser | undefined;
|
|
29
|
+
export declare function apiLabelsToGhLabels(labels: GhApiLabel[] | undefined): GhLabel[];
|
|
30
|
+
export declare function apiIssueToSearchResult(item: GhApiSearchIssueItem): GhSearchResult;
|
|
31
|
+
export declare function apiCodeToSearchResult(item: GhApiSearchCodeItem): GhSearchCodeResult;
|
|
32
|
+
export declare function apiCommitToSearchResult(item: GhApiSearchCommitItem): GhSearchCommitResult;
|
|
33
|
+
export declare function apiRepoToSearchResult(item: GhApiSearchRepoItem): GhSearchRepoResult;
|
|
34
|
+
/**
|
|
35
|
+
* Matches search-query qualifiers that already scope to a repository, org, or
|
|
36
|
+
* user. When present, callers should avoid layering a default `repo:<current>`
|
|
37
|
+
* on top — the user has already expressed an explicit scope.
|
|
38
|
+
*
|
|
39
|
+
* Only the leading `repo:`/`org:`/`user:`/`owner:` token is treated as a
|
|
40
|
+
* scope marker; arbitrary substrings (e.g. inside quoted text) are ignored.
|
|
41
|
+
*/
|
|
42
|
+
export declare const REPO_SCOPE_QUALIFIER_PATTERN: RegExp;
|
|
43
|
+
/**
|
|
44
|
+
* Resolve the effective `repo:` scope for a search op. Returns the explicit
|
|
45
|
+
* `repo` when set, `undefined` when the query already carries a scoping
|
|
46
|
+
* qualifier, and otherwise the current checkout's `owner/repo` via
|
|
47
|
+
* `resolveDefaultRepoMemoized`. Resolution failures (no git/gh context, no
|
|
48
|
+
* configured remote) silently fall back to `undefined` so the search proceeds
|
|
49
|
+
* across all of GitHub instead of throwing.
|
|
50
|
+
*/
|
|
51
|
+
export declare function resolveSearchRepoScope(cwd: string, repo: string | undefined, query: string | undefined, signal: AbortSignal | undefined): Promise<string | undefined>;
|
|
52
|
+
export declare function formatSearchResults(kind: "issues" | "pull requests", query: string, repo: string | undefined, items: GhSearchResult[]): string;
|
|
53
|
+
export declare function formatSearchCodeResults(query: string, repo: string | undefined, items: GhSearchCodeResult[]): string;
|
|
54
|
+
export declare function formatSearchCommitMessage(message: string | undefined): string | undefined;
|
|
55
|
+
export declare function formatSearchCommitsResults(query: string, repo: string | undefined, items: GhSearchCommitResult[]): string;
|
|
56
|
+
export declare function formatSearchReposResults(query: string, items: GhSearchRepoResult[]): string;
|
|
57
|
+
export declare function executeSearchIssues(session: ToolSession, params: GithubInput, signal: AbortSignal | undefined): Promise<AgentToolResult<GhToolDetails>>;
|
|
58
|
+
export declare function executeSearchPrs(session: ToolSession, params: GithubInput, signal: AbortSignal | undefined): Promise<AgentToolResult<GhToolDetails>>;
|
|
59
|
+
export declare function executeSearchCode(session: ToolSession, params: GithubInput, signal: AbortSignal | undefined): Promise<AgentToolResult<GhToolDetails>>;
|
|
60
|
+
export declare function executeSearchCommits(session: ToolSession, params: GithubInput, signal: AbortSignal | undefined): Promise<AgentToolResult<GhToolDetails>>;
|
|
61
|
+
export declare function executeSearchRepos(session: ToolSession, params: GithubInput, signal: AbortSignal | undefined): Promise<AgentToolResult<GhToolDetails>>;
|