@vaporsoft/orc 0.1.0
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/LICENSE +6 -0
- package/README.md +178 -0
- package/dist/bin/orc.d.ts +3 -0
- package/dist/bin/orc.d.ts.map +1 -0
- package/dist/bin/orc.js +4 -0
- package/dist/bin/orc.js.map +1 -0
- package/dist/src/cli.d.ts +6 -0
- package/dist/src/cli.d.ts.map +1 -0
- package/dist/src/cli.js +28 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/commands/init.d.ts +6 -0
- package/dist/src/commands/init.d.ts.map +1 -0
- package/dist/src/commands/init.js +58 -0
- package/dist/src/commands/init.js.map +1 -0
- package/dist/src/commands/start.d.ts +17 -0
- package/dist/src/commands/start.d.ts.map +1 -0
- package/dist/src/commands/start.js +146 -0
- package/dist/src/commands/start.js.map +1 -0
- package/dist/src/constants.d.ts +18 -0
- package/dist/src/constants.d.ts.map +1 -0
- package/dist/src/constants.js +42 -0
- package/dist/src/constants.js.map +1 -0
- package/dist/src/core/comment-categorizer.d.ts +20 -0
- package/dist/src/core/comment-categorizer.d.ts.map +1 -0
- package/dist/src/core/comment-categorizer.js +208 -0
- package/dist/src/core/comment-categorizer.js.map +1 -0
- package/dist/src/core/comment-fetcher.d.ts +37 -0
- package/dist/src/core/comment-fetcher.d.ts.map +1 -0
- package/dist/src/core/comment-fetcher.js +138 -0
- package/dist/src/core/comment-fetcher.js.map +1 -0
- package/dist/src/core/daemon.d.ts +92 -0
- package/dist/src/core/daemon.d.ts.map +1 -0
- package/dist/src/core/daemon.js +896 -0
- package/dist/src/core/daemon.js.map +1 -0
- package/dist/src/core/fix-executor.d.ts +50 -0
- package/dist/src/core/fix-executor.d.ts.map +1 -0
- package/dist/src/core/fix-executor.js +374 -0
- package/dist/src/core/fix-executor.js.map +1 -0
- package/dist/src/core/git-manager.d.ts +44 -0
- package/dist/src/core/git-manager.d.ts.map +1 -0
- package/dist/src/core/git-manager.js +230 -0
- package/dist/src/core/git-manager.js.map +1 -0
- package/dist/src/core/pilot-config.d.ts +18 -0
- package/dist/src/core/pilot-config.d.ts.map +1 -0
- package/dist/src/core/pilot-config.js +76 -0
- package/dist/src/core/pilot-config.js.map +1 -0
- package/dist/src/core/progress-store.d.ts +32 -0
- package/dist/src/core/progress-store.d.ts.map +1 -0
- package/dist/src/core/progress-store.js +106 -0
- package/dist/src/core/progress-store.js.map +1 -0
- package/dist/src/core/repo-config.d.ts +11 -0
- package/dist/src/core/repo-config.d.ts.map +1 -0
- package/dist/src/core/repo-config.js +168 -0
- package/dist/src/core/repo-config.js.map +1 -0
- package/dist/src/core/session-controller.d.ts +61 -0
- package/dist/src/core/session-controller.d.ts.map +1 -0
- package/dist/src/core/session-controller.js +926 -0
- package/dist/src/core/session-controller.js.map +1 -0
- package/dist/src/core/thread-responder.d.ts +28 -0
- package/dist/src/core/thread-responder.d.ts.map +1 -0
- package/dist/src/core/thread-responder.js +193 -0
- package/dist/src/core/thread-responder.js.map +1 -0
- package/dist/src/core/worktree-manager.d.ts +26 -0
- package/dist/src/core/worktree-manager.d.ts.map +1 -0
- package/dist/src/core/worktree-manager.js +189 -0
- package/dist/src/core/worktree-manager.js.map +1 -0
- package/dist/src/github/gh-client.d.ts +57 -0
- package/dist/src/github/gh-client.d.ts.map +1 -0
- package/dist/src/github/gh-client.js +236 -0
- package/dist/src/github/gh-client.js.map +1 -0
- package/dist/src/github/queries.d.ts +9 -0
- package/dist/src/github/queries.d.ts.map +1 -0
- package/dist/src/github/queries.js +152 -0
- package/dist/src/github/queries.js.map +1 -0
- package/dist/src/github/types.d.ts +114 -0
- package/dist/src/github/types.d.ts.map +1 -0
- package/dist/src/github/types.js +3 -0
- package/dist/src/github/types.js.map +1 -0
- package/dist/src/tui/App.d.ts +8 -0
- package/dist/src/tui/App.d.ts.map +1 -0
- package/dist/src/tui/App.js +407 -0
- package/dist/src/tui/App.js.map +1 -0
- package/dist/src/tui/components/ActivityPane.d.ts +7 -0
- package/dist/src/tui/components/ActivityPane.d.ts.map +1 -0
- package/dist/src/tui/components/ActivityPane.js +10 -0
- package/dist/src/tui/components/ActivityPane.js.map +1 -0
- package/dist/src/tui/components/DetailPanel.d.ts +15 -0
- package/dist/src/tui/components/DetailPanel.d.ts.map +1 -0
- package/dist/src/tui/components/DetailPanel.js +137 -0
- package/dist/src/tui/components/DetailPanel.js.map +1 -0
- package/dist/src/tui/components/DrillInOverlay.d.ts +13 -0
- package/dist/src/tui/components/DrillInOverlay.d.ts.map +1 -0
- package/dist/src/tui/components/DrillInOverlay.js +85 -0
- package/dist/src/tui/components/DrillInOverlay.js.map +1 -0
- package/dist/src/tui/components/ExpandedContent.d.ts +10 -0
- package/dist/src/tui/components/ExpandedContent.d.ts.map +1 -0
- package/dist/src/tui/components/ExpandedContent.js +99 -0
- package/dist/src/tui/components/ExpandedContent.js.map +1 -0
- package/dist/src/tui/components/Header.d.ts +12 -0
- package/dist/src/tui/components/Header.d.ts.map +1 -0
- package/dist/src/tui/components/Header.js +35 -0
- package/dist/src/tui/components/Header.js.map +1 -0
- package/dist/src/tui/components/HelpBar.d.ts +2 -0
- package/dist/src/tui/components/HelpBar.d.ts.map +1 -0
- package/dist/src/tui/components/HelpBar.js +11 -0
- package/dist/src/tui/components/HelpBar.js.map +1 -0
- package/dist/src/tui/components/KeybindLegend.d.ts +7 -0
- package/dist/src/tui/components/KeybindLegend.d.ts.map +1 -0
- package/dist/src/tui/components/KeybindLegend.js +53 -0
- package/dist/src/tui/components/KeybindLegend.js.map +1 -0
- package/dist/src/tui/components/LogPane.d.ts +11 -0
- package/dist/src/tui/components/LogPane.d.ts.map +1 -0
- package/dist/src/tui/components/LogPane.js +31 -0
- package/dist/src/tui/components/LogPane.js.map +1 -0
- package/dist/src/tui/components/SessionList.d.ts +14 -0
- package/dist/src/tui/components/SessionList.d.ts.map +1 -0
- package/dist/src/tui/components/SessionList.js +31 -0
- package/dist/src/tui/components/SessionList.js.map +1 -0
- package/dist/src/tui/components/SessionRow.d.ts +10 -0
- package/dist/src/tui/components/SessionRow.d.ts.map +1 -0
- package/dist/src/tui/components/SessionRow.js +52 -0
- package/dist/src/tui/components/SessionRow.js.map +1 -0
- package/dist/src/tui/components/SettingsPanel.d.ts +8 -0
- package/dist/src/tui/components/SettingsPanel.d.ts.map +1 -0
- package/dist/src/tui/components/SettingsPanel.js +191 -0
- package/dist/src/tui/components/SettingsPanel.js.map +1 -0
- package/dist/src/tui/components/StatusBadge.d.ts +9 -0
- package/dist/src/tui/components/StatusBadge.d.ts.map +1 -0
- package/dist/src/tui/components/StatusBadge.js +52 -0
- package/dist/src/tui/components/StatusBadge.js.map +1 -0
- package/dist/src/tui/components/Toolbar.d.ts +5 -0
- package/dist/src/tui/components/Toolbar.d.ts.map +1 -0
- package/dist/src/tui/components/Toolbar.js +2 -0
- package/dist/src/tui/components/Toolbar.js.map +1 -0
- package/dist/src/tui/components/comment-constants.d.ts +4 -0
- package/dist/src/tui/components/comment-constants.d.ts.map +1 -0
- package/dist/src/tui/components/comment-constants.js +15 -0
- package/dist/src/tui/components/comment-constants.js.map +1 -0
- package/dist/src/tui/hooks/logFlushUtils.d.ts +15 -0
- package/dist/src/tui/hooks/logFlushUtils.d.ts.map +1 -0
- package/dist/src/tui/hooks/logFlushUtils.js +33 -0
- package/dist/src/tui/hooks/logFlushUtils.js.map +1 -0
- package/dist/src/tui/hooks/useBranchLogs.d.ts +7 -0
- package/dist/src/tui/hooks/useBranchLogs.d.ts.map +1 -0
- package/dist/src/tui/hooks/useBranchLogs.js +58 -0
- package/dist/src/tui/hooks/useBranchLogs.js.map +1 -0
- package/dist/src/tui/hooks/useDaemonState.d.ts +19 -0
- package/dist/src/tui/hooks/useDaemonState.d.ts.map +1 -0
- package/dist/src/tui/hooks/useDaemonState.js +152 -0
- package/dist/src/tui/hooks/useDaemonState.js.map +1 -0
- package/dist/src/tui/hooks/useInitialDiscovery.d.ts +8 -0
- package/dist/src/tui/hooks/useInitialDiscovery.d.ts.map +1 -0
- package/dist/src/tui/hooks/useInitialDiscovery.js +31 -0
- package/dist/src/tui/hooks/useInitialDiscovery.js.map +1 -0
- package/dist/src/tui/hooks/useLogBuffer.d.ts +7 -0
- package/dist/src/tui/hooks/useLogBuffer.d.ts.map +1 -0
- package/dist/src/tui/hooks/useLogBuffer.js +52 -0
- package/dist/src/tui/hooks/useLogBuffer.js.map +1 -0
- package/dist/src/tui/hooks/useNextCheckCountdown.d.ts +7 -0
- package/dist/src/tui/hooks/useNextCheckCountdown.d.ts.map +1 -0
- package/dist/src/tui/hooks/useNextCheckCountdown.js +42 -0
- package/dist/src/tui/hooks/useNextCheckCountdown.js.map +1 -0
- package/dist/src/tui/hooks/useTerminalFocus.d.ts +9 -0
- package/dist/src/tui/hooks/useTerminalFocus.d.ts.map +1 -0
- package/dist/src/tui/hooks/useTerminalFocus.js +43 -0
- package/dist/src/tui/hooks/useTerminalFocus.js.map +1 -0
- package/dist/src/tui/theme.d.ts +32 -0
- package/dist/src/tui/theme.d.ts.map +1 -0
- package/dist/src/tui/theme.js +61 -0
- package/dist/src/tui/theme.js.map +1 -0
- package/dist/src/types/config.d.ts +35 -0
- package/dist/src/types/config.d.ts.map +1 -0
- package/dist/src/types/config.js +14 -0
- package/dist/src/types/config.js.map +1 -0
- package/dist/src/types/index.d.ts +107 -0
- package/dist/src/types/index.d.ts.map +1 -0
- package/dist/src/types/index.js +3 -0
- package/dist/src/types/index.js.map +1 -0
- package/dist/src/utils/concurrency.d.ts +7 -0
- package/dist/src/utils/concurrency.d.ts.map +1 -0
- package/dist/src/utils/concurrency.js +26 -0
- package/dist/src/utils/concurrency.js.map +1 -0
- package/dist/src/utils/format.d.ts +2 -0
- package/dist/src/utils/format.d.ts.map +1 -0
- package/dist/src/utils/format.js +8 -0
- package/dist/src/utils/format.js.map +1 -0
- package/dist/src/utils/logger.d.ts +39 -0
- package/dist/src/utils/logger.d.ts.map +1 -0
- package/dist/src/utils/logger.js +120 -0
- package/dist/src/utils/logger.js.map +1 -0
- package/dist/src/utils/notify.d.ts +6 -0
- package/dist/src/utils/notify.d.ts.map +1 -0
- package/dist/src/utils/notify.js +15 -0
- package/dist/src/utils/notify.js.map +1 -0
- package/dist/src/utils/open-terminal.d.ts +12 -0
- package/dist/src/utils/open-terminal.d.ts.map +1 -0
- package/dist/src/utils/open-terminal.js +93 -0
- package/dist/src/utils/open-terminal.js.map +1 -0
- package/dist/src/utils/process.d.ts +14 -0
- package/dist/src/utils/process.d.ts.map +1 -0
- package/dist/src/utils/process.js +36 -0
- package/dist/src/utils/process.js.map +1 -0
- package/dist/src/utils/project-detector.d.ts +12 -0
- package/dist/src/utils/project-detector.d.ts.map +1 -0
- package/dist/src/utils/project-detector.js +123 -0
- package/dist/src/utils/project-detector.js.map +1 -0
- package/dist/src/utils/quoting.d.ts +15 -0
- package/dist/src/utils/quoting.d.ts.map +1 -0
- package/dist/src/utils/quoting.js +39 -0
- package/dist/src/utils/quoting.js.map +1 -0
- package/dist/src/utils/retry.d.ts +14 -0
- package/dist/src/utils/retry.d.ts.map +1 -0
- package/dist/src/utils/retry.js +41 -0
- package/dist/src/utils/retry.js.map +1 -0
- package/dist/src/utils/settings.d.ts +14 -0
- package/dist/src/utils/settings.d.ts.map +1 -0
- package/dist/src/utils/settings.js +21 -0
- package/dist/src/utils/settings.js.map +1 -0
- package/dist/src/utils/time.d.ts +2 -0
- package/dist/src/utils/time.d.ts.map +1 -0
- package/dist/src/utils/time.js +5 -0
- package/dist/src/utils/time.js.map +1 -0
- package/package.json +73 -0
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wrapper around the `gh` CLI for GitHub API access.
|
|
3
|
+
* Uses `gh api` for GraphQL and REST calls — inherits the user's auth.
|
|
4
|
+
*/
|
|
5
|
+
import { exec } from "../utils/process.js";
|
|
6
|
+
import { withRetry, RateLimitError } from "../utils/retry.js";
|
|
7
|
+
import { logger } from "../utils/logger.js";
|
|
8
|
+
import { REVIEW_THREADS_QUERY, RESOLVE_THREAD_MUTATION, PR_COMMENTS_QUERY, PR_FOR_BRANCH_QUERY, MY_OPEN_PRS_QUERY, } from "./queries.js";
|
|
9
|
+
const RATE_LIMIT_PATTERN = /rate limit|abuse detection/i;
|
|
10
|
+
export class GHClient {
|
|
11
|
+
repoInfo = null;
|
|
12
|
+
cachedLogin = null;
|
|
13
|
+
cwd;
|
|
14
|
+
constructor(cwd) {
|
|
15
|
+
this.cwd = cwd;
|
|
16
|
+
}
|
|
17
|
+
/** Run a `gh` CLI command, converting rate-limit failures to RateLimitError. */
|
|
18
|
+
async execGH(args, options) {
|
|
19
|
+
try {
|
|
20
|
+
return await exec("gh", args, { cwd: this.cwd, ...options });
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
24
|
+
if (RATE_LIMIT_PATTERN.test(message)) {
|
|
25
|
+
throw new RateLimitError(message);
|
|
26
|
+
}
|
|
27
|
+
throw err;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/** Discover owner/repo from the current git remote. */
|
|
31
|
+
async getRepoInfo() {
|
|
32
|
+
if (this.repoInfo)
|
|
33
|
+
return this.repoInfo;
|
|
34
|
+
const { stdout } = await this.execGH(["repo", "view", "--json", "owner,name"]);
|
|
35
|
+
const parsed = JSON.parse(stdout);
|
|
36
|
+
this.repoInfo = { owner: parsed.owner.login, repo: parsed.name };
|
|
37
|
+
return this.repoInfo;
|
|
38
|
+
}
|
|
39
|
+
/** Get the authenticated user's login. */
|
|
40
|
+
async getCurrentUser() {
|
|
41
|
+
if (this.cachedLogin)
|
|
42
|
+
return this.cachedLogin;
|
|
43
|
+
const { stdout } = await this.execGH(["api", "user", "--jq", ".login"]);
|
|
44
|
+
this.cachedLogin = stdout.trim();
|
|
45
|
+
return this.cachedLogin;
|
|
46
|
+
}
|
|
47
|
+
/** Find all open PRs authored by the current user. */
|
|
48
|
+
async getMyOpenPRs() {
|
|
49
|
+
const { owner, repo } = await this.getRepoInfo();
|
|
50
|
+
const login = await this.getCurrentUser();
|
|
51
|
+
const searchQuery = `repo:${owner}/${repo} is:pr is:open author:${login}`;
|
|
52
|
+
const result = await this.graphql(MY_OPEN_PRS_QUERY, { searchQuery });
|
|
53
|
+
return result.data.search.nodes.filter((node) => node.number !== undefined);
|
|
54
|
+
}
|
|
55
|
+
/** Execute a GraphQL query via `gh api graphql`. */
|
|
56
|
+
async graphql(query, variables) {
|
|
57
|
+
const args = ["api", "graphql", "-f", `query=${query}`];
|
|
58
|
+
for (const [key, value] of Object.entries(variables)) {
|
|
59
|
+
if (typeof value === "number") {
|
|
60
|
+
args.push("-F", `${key}=${value}`);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
args.push("-f", `${key}=${String(value)}`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const { stdout } = await withRetry(() => this.execGH(args), "graphql");
|
|
67
|
+
return JSON.parse(stdout);
|
|
68
|
+
}
|
|
69
|
+
/** Find the open PR for a branch. */
|
|
70
|
+
async findPRForBranch(branch) {
|
|
71
|
+
const { owner, repo } = await this.getRepoInfo();
|
|
72
|
+
const result = await this.graphql(PR_FOR_BRANCH_QUERY, { owner, repo, branch });
|
|
73
|
+
const nodes = result.data.repository.pullRequests.nodes;
|
|
74
|
+
return nodes.length > 0 ? nodes[0] : null;
|
|
75
|
+
}
|
|
76
|
+
/** Fetch all unresolved review threads for a PR (paginated). */
|
|
77
|
+
async getReviewThreads(prNumber) {
|
|
78
|
+
const { owner, repo } = await this.getRepoInfo();
|
|
79
|
+
const allThreads = [];
|
|
80
|
+
let cursor = null;
|
|
81
|
+
do {
|
|
82
|
+
const variables = { owner, repo, prNumber };
|
|
83
|
+
if (cursor)
|
|
84
|
+
variables.cursor = cursor;
|
|
85
|
+
const result = await this.graphql(REVIEW_THREADS_QUERY, variables);
|
|
86
|
+
const connection = result.data.repository.pullRequest.reviewThreads;
|
|
87
|
+
allThreads.push(...connection.nodes);
|
|
88
|
+
cursor = connection.pageInfo.hasNextPage
|
|
89
|
+
? connection.pageInfo.endCursor
|
|
90
|
+
: null;
|
|
91
|
+
} while (cursor);
|
|
92
|
+
return allThreads;
|
|
93
|
+
}
|
|
94
|
+
/** Fetch all top-level PR conversation comments (paginated). */
|
|
95
|
+
async getPRComments(prNumber) {
|
|
96
|
+
const { owner, repo } = await this.getRepoInfo();
|
|
97
|
+
const allComments = [];
|
|
98
|
+
let cursor = null;
|
|
99
|
+
do {
|
|
100
|
+
const variables = { owner, repo, prNumber };
|
|
101
|
+
if (cursor)
|
|
102
|
+
variables.cursor = cursor;
|
|
103
|
+
const result = await this.graphql(PR_COMMENTS_QUERY, variables);
|
|
104
|
+
const connection = result.data.repository.pullRequest.comments;
|
|
105
|
+
allComments.push(...connection.nodes);
|
|
106
|
+
cursor = connection.pageInfo.hasNextPage
|
|
107
|
+
? connection.pageInfo.endCursor
|
|
108
|
+
: null;
|
|
109
|
+
} while (cursor);
|
|
110
|
+
return allComments;
|
|
111
|
+
}
|
|
112
|
+
/** Add a top-level comment to a PR conversation. */
|
|
113
|
+
async addPRComment(prNumber, body) {
|
|
114
|
+
const { owner, repo } = await this.getRepoInfo();
|
|
115
|
+
await withRetry(() => this.execGH([
|
|
116
|
+
"api",
|
|
117
|
+
"--method", "POST",
|
|
118
|
+
`repos/${owner}/${repo}/issues/${prNumber}/comments`,
|
|
119
|
+
"-f", `body=${body}`,
|
|
120
|
+
]), "add-pr-comment");
|
|
121
|
+
}
|
|
122
|
+
/** Fetch CI check runs for the latest commit on a PR. */
|
|
123
|
+
async getCheckRuns(prNumber) {
|
|
124
|
+
const { owner, repo } = await this.getRepoInfo();
|
|
125
|
+
const { stdout } = await withRetry(() => this.execGH([
|
|
126
|
+
"api",
|
|
127
|
+
`repos/${owner}/${repo}/pulls/${prNumber}`,
|
|
128
|
+
"--jq",
|
|
129
|
+
".head.sha",
|
|
130
|
+
]), "fetch-pr-sha");
|
|
131
|
+
const sha = stdout.trim();
|
|
132
|
+
const { stdout: checksJson } = await withRetry(() => this.execGH([
|
|
133
|
+
"api",
|
|
134
|
+
`repos/${owner}/${repo}/commits/${sha}/check-runs`,
|
|
135
|
+
]), "fetch-checks");
|
|
136
|
+
const response = JSON.parse(checksJson);
|
|
137
|
+
return response.check_runs;
|
|
138
|
+
}
|
|
139
|
+
/** Fetch failed CI run logs with smart truncation. */
|
|
140
|
+
async getFailedRunLog(runId) {
|
|
141
|
+
try {
|
|
142
|
+
const { stdout } = await this.execGH(["run", "view", String(runId), "--log-failed"]);
|
|
143
|
+
return this.truncateLog(stdout);
|
|
144
|
+
}
|
|
145
|
+
catch (err) {
|
|
146
|
+
if (err instanceof RateLimitError) {
|
|
147
|
+
throw err;
|
|
148
|
+
}
|
|
149
|
+
logger.warn(`Failed to fetch logs for run ${runId}`);
|
|
150
|
+
return "(logs unavailable)";
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
/** List workflow runs for the HEAD commit of a PR. */
|
|
154
|
+
async getWorkflowRuns(prNumber) {
|
|
155
|
+
const { owner, repo } = await this.getRepoInfo();
|
|
156
|
+
const { stdout: shaOut } = await withRetry(() => this.execGH([
|
|
157
|
+
"api",
|
|
158
|
+
`repos/${owner}/${repo}/pulls/${prNumber}`,
|
|
159
|
+
"--jq",
|
|
160
|
+
".head.sha",
|
|
161
|
+
]), "fetch-pr-sha-for-runs");
|
|
162
|
+
const sha = shaOut.trim();
|
|
163
|
+
const { stdout } = await this.execGH(["run", "list", "--commit", sha, "--json", "databaseId,name,conclusion,status"]);
|
|
164
|
+
return JSON.parse(stdout);
|
|
165
|
+
}
|
|
166
|
+
/** Truncate a log to the last portion, keeping errors visible. */
|
|
167
|
+
truncateLog(log, maxLength = 30000) {
|
|
168
|
+
if (log.length <= maxLength)
|
|
169
|
+
return log;
|
|
170
|
+
const lines = log.split("\n");
|
|
171
|
+
const result = [];
|
|
172
|
+
let size = 0;
|
|
173
|
+
for (let i = lines.length - 1; i >= 0; i--) {
|
|
174
|
+
size += lines[i].length + 1;
|
|
175
|
+
if (size > maxLength)
|
|
176
|
+
break;
|
|
177
|
+
result.unshift(lines[i]);
|
|
178
|
+
}
|
|
179
|
+
return `... (truncated ${lines.length - result.length} lines) ...\n` + result.join("\n");
|
|
180
|
+
}
|
|
181
|
+
/** Resolve a review thread via GraphQL mutation. */
|
|
182
|
+
async resolveThread(threadId) {
|
|
183
|
+
await this.graphql(RESOLVE_THREAD_MUTATION, { threadId });
|
|
184
|
+
}
|
|
185
|
+
/** Add a reply comment to a PR review thread. */
|
|
186
|
+
async addThreadReply(threadNodeId, body) {
|
|
187
|
+
await withRetry(() => this.execGH([
|
|
188
|
+
"api",
|
|
189
|
+
"graphql",
|
|
190
|
+
"-f",
|
|
191
|
+
`query=mutation { addPullRequestReviewThreadReply(input: { pullRequestReviewThreadId: "${threadNodeId}", body: "${body.replace(/"/g, '\\"').replace(/\n/g, "\\n")}" }) { comment { id } } }`,
|
|
192
|
+
]), "reply-to-thread");
|
|
193
|
+
}
|
|
194
|
+
/** Re-request review from the given reviewers. */
|
|
195
|
+
async requestReviewers(prNumber, reviewers) {
|
|
196
|
+
if (reviewers.length === 0)
|
|
197
|
+
return;
|
|
198
|
+
const { owner, repo } = await this.getRepoInfo();
|
|
199
|
+
try {
|
|
200
|
+
// gh api -F passes typed JSON fields; repeating the key builds an array
|
|
201
|
+
const args = [
|
|
202
|
+
"api",
|
|
203
|
+
"--method", "POST",
|
|
204
|
+
`repos/${owner}/${repo}/pulls/${prNumber}/requested_reviewers`,
|
|
205
|
+
];
|
|
206
|
+
for (const reviewer of reviewers) {
|
|
207
|
+
args.push("-f", `reviewers[]=${reviewer}`);
|
|
208
|
+
}
|
|
209
|
+
await this.execGH(args);
|
|
210
|
+
logger.info(`Re-requested review from: ${reviewers.join(", ")}`);
|
|
211
|
+
}
|
|
212
|
+
catch (err) {
|
|
213
|
+
logger.warn(`Failed to re-request reviewers: ${err}`);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
/** Check whether a PR was merged. */
|
|
217
|
+
async isPRMerged(prNumber) {
|
|
218
|
+
const { owner, repo } = await this.getRepoInfo();
|
|
219
|
+
try {
|
|
220
|
+
const { stdout } = await this.execGH([
|
|
221
|
+
"api",
|
|
222
|
+
`repos/${owner}/${repo}/pulls/${prNumber}`,
|
|
223
|
+
"--jq", ".merged",
|
|
224
|
+
]);
|
|
225
|
+
return stdout.trim() === "true";
|
|
226
|
+
}
|
|
227
|
+
catch {
|
|
228
|
+
return false;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
/** Validate that `gh` is authenticated and can reach the repo. */
|
|
232
|
+
async validateAuth() {
|
|
233
|
+
await this.execGH(["auth", "status"]);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
//# sourceMappingURL=gh-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gh-client.js","sourceRoot":"","sources":["../../../src/github/gh-client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAmB,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AAgBtB,MAAM,kBAAkB,GAAG,6BAA6B,CAAC;AAEzD,MAAM,OAAO,QAAQ;IACX,QAAQ,GAAoB,IAAI,CAAC;IACjC,WAAW,GAAkB,IAAI,CAAC;IAClC,GAAG,CAAS;IAEpB,YAAY,GAAW;QACrB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAED,gFAAgF;IACxE,KAAK,CAAC,MAAM,CAClB,IAAc,EACd,OAAoC;QAEpC,IAAI,CAAC;YACH,OAAO,MAAM,IAAI,CAAC,IAA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AC,6BAA6B,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACnE,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,CAAC,IAAI,CAAC,mCAAmC,GAAG,EAAE,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;IAED,qCAAqC;IACrC,KAAK,CAAC,UAAU,CAAC,QAAgB;QAC/B,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC;QACjD,IAAI,CAAC;YACH,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC;gBACnC,KAAK;gBACL,SAAS,KAAK,IAAI,IAAI,UAAU,QAAQ,EAAE;gBAC1C,MAAM,EAAE,SAAS;aAClB,CAAC,CAAC;YACH,OAAO,MAAM,CAAC,IAAI,EAAE,KAAK,MAAM,CAAC;QAClC,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED,kEAAkE;IAClE,KAAK,CAAC,YAAY;QAChB,MAAM,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;IACxC,CAAC;CACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** GraphQL queries and mutations for GitHub. */
|
|
2
|
+
export declare const REVIEW_THREADS_QUERY = "\nquery ReviewThreads($owner: String!, $repo: String!, $prNumber: Int!, $cursor: String) {\n repository(owner: $owner, name: $repo) {\n pullRequest(number: $prNumber) {\n reviewThreads(first: 100, after: $cursor) {\n pageInfo {\n hasNextPage\n endCursor\n }\n nodes {\n id\n isResolved\n isOutdated\n comments(first: 100) {\n nodes {\n id\n databaseId\n body\n author {\n login\n }\n path\n line\n diffHunk\n createdAt\n }\n }\n }\n }\n }\n }\n}\n";
|
|
3
|
+
export declare const RESOLVE_THREAD_MUTATION = "\nmutation ResolveThread($threadId: ID!) {\n resolveReviewThread(input: { threadId: $threadId }) {\n thread {\n id\n isResolved\n }\n }\n}\n";
|
|
4
|
+
export declare const ADD_PR_COMMENT_MUTATION = "\nmutation AddComment($subjectId: ID!, $body: String!) {\n addComment(input: { subjectId: $subjectId, body: $body }) {\n commentEdge {\n node {\n id\n }\n }\n }\n}\n";
|
|
5
|
+
export declare const PR_QUERY = "\nquery PullRequest($owner: String!, $repo: String!, $prNumber: Int!) {\n repository(owner: $owner, name: $repo) {\n pullRequest(number: $prNumber) {\n id\n number\n url\n title\n state\n headRefName\n baseRefName\n headRefOid\n author { login }\n }\n }\n}\n";
|
|
6
|
+
export declare const MY_OPEN_PRS_QUERY = "\nquery MyOpenPRs($searchQuery: String!) {\n search(query: $searchQuery, type: ISSUE, first: 50) {\n nodes {\n ... on PullRequest {\n number\n url\n title\n state\n headRefName\n baseRefName\n headRefOid\n author { login }\n commits(last: 1) {\n nodes {\n commit {\n statusCheckRollup {\n contexts(first: 50) {\n nodes {\n ... on CheckRun {\n databaseId\n name\n status\n conclusion\n detailsUrl\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n}\n";
|
|
7
|
+
export declare const PR_COMMENTS_QUERY = "\nquery PRComments($owner: String!, $repo: String!, $prNumber: Int!, $cursor: String) {\n repository(owner: $owner, name: $repo) {\n pullRequest(number: $prNumber) {\n comments(first: 100, after: $cursor) {\n pageInfo {\n hasNextPage\n endCursor\n }\n nodes {\n id\n databaseId\n body\n author {\n login\n }\n createdAt\n }\n }\n }\n }\n}\n";
|
|
8
|
+
export declare const PR_FOR_BRANCH_QUERY = "\nquery PRForBranch($owner: String!, $repo: String!, $branch: String!) {\n repository(owner: $owner, name: $repo) {\n pullRequests(headRefName: $branch, states: [OPEN], first: 1) {\n nodes {\n id\n number\n url\n title\n state\n headRefName\n baseRefName\n headRefOid\n author { login }\n }\n }\n }\n}\n";
|
|
9
|
+
//# sourceMappingURL=queries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../../src/github/queries.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAEhD,eAAO,MAAM,oBAAoB,2sBAgChC,CAAC;AAEF,eAAO,MAAM,uBAAuB,mKASnC,CAAC;AAEF,eAAO,MAAM,uBAAuB,mMAUnC,CAAC;AAEF,eAAO,MAAM,QAAQ,4TAgBpB,CAAC;AAEF,eAAO,MAAM,iBAAiB,syBAoC7B,CAAC;AAEF,eAAO,MAAM,iBAAiB,0dAsB7B,CAAC;AAEF,eAAO,MAAM,mBAAmB,qYAkB/B,CAAC"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/** GraphQL queries and mutations for GitHub. */
|
|
2
|
+
export const REVIEW_THREADS_QUERY = `
|
|
3
|
+
query ReviewThreads($owner: String!, $repo: String!, $prNumber: Int!, $cursor: String) {
|
|
4
|
+
repository(owner: $owner, name: $repo) {
|
|
5
|
+
pullRequest(number: $prNumber) {
|
|
6
|
+
reviewThreads(first: 100, after: $cursor) {
|
|
7
|
+
pageInfo {
|
|
8
|
+
hasNextPage
|
|
9
|
+
endCursor
|
|
10
|
+
}
|
|
11
|
+
nodes {
|
|
12
|
+
id
|
|
13
|
+
isResolved
|
|
14
|
+
isOutdated
|
|
15
|
+
comments(first: 100) {
|
|
16
|
+
nodes {
|
|
17
|
+
id
|
|
18
|
+
databaseId
|
|
19
|
+
body
|
|
20
|
+
author {
|
|
21
|
+
login
|
|
22
|
+
}
|
|
23
|
+
path
|
|
24
|
+
line
|
|
25
|
+
diffHunk
|
|
26
|
+
createdAt
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
`;
|
|
35
|
+
export const RESOLVE_THREAD_MUTATION = `
|
|
36
|
+
mutation ResolveThread($threadId: ID!) {
|
|
37
|
+
resolveReviewThread(input: { threadId: $threadId }) {
|
|
38
|
+
thread {
|
|
39
|
+
id
|
|
40
|
+
isResolved
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
`;
|
|
45
|
+
export const ADD_PR_COMMENT_MUTATION = `
|
|
46
|
+
mutation AddComment($subjectId: ID!, $body: String!) {
|
|
47
|
+
addComment(input: { subjectId: $subjectId, body: $body }) {
|
|
48
|
+
commentEdge {
|
|
49
|
+
node {
|
|
50
|
+
id
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
`;
|
|
56
|
+
export const PR_QUERY = `
|
|
57
|
+
query PullRequest($owner: String!, $repo: String!, $prNumber: Int!) {
|
|
58
|
+
repository(owner: $owner, name: $repo) {
|
|
59
|
+
pullRequest(number: $prNumber) {
|
|
60
|
+
id
|
|
61
|
+
number
|
|
62
|
+
url
|
|
63
|
+
title
|
|
64
|
+
state
|
|
65
|
+
headRefName
|
|
66
|
+
baseRefName
|
|
67
|
+
headRefOid
|
|
68
|
+
author { login }
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
`;
|
|
73
|
+
export const MY_OPEN_PRS_QUERY = `
|
|
74
|
+
query MyOpenPRs($searchQuery: String!) {
|
|
75
|
+
search(query: $searchQuery, type: ISSUE, first: 50) {
|
|
76
|
+
nodes {
|
|
77
|
+
... on PullRequest {
|
|
78
|
+
number
|
|
79
|
+
url
|
|
80
|
+
title
|
|
81
|
+
state
|
|
82
|
+
headRefName
|
|
83
|
+
baseRefName
|
|
84
|
+
headRefOid
|
|
85
|
+
author { login }
|
|
86
|
+
commits(last: 1) {
|
|
87
|
+
nodes {
|
|
88
|
+
commit {
|
|
89
|
+
statusCheckRollup {
|
|
90
|
+
contexts(first: 50) {
|
|
91
|
+
nodes {
|
|
92
|
+
... on CheckRun {
|
|
93
|
+
databaseId
|
|
94
|
+
name
|
|
95
|
+
status
|
|
96
|
+
conclusion
|
|
97
|
+
detailsUrl
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
`;
|
|
110
|
+
export const PR_COMMENTS_QUERY = `
|
|
111
|
+
query PRComments($owner: String!, $repo: String!, $prNumber: Int!, $cursor: String) {
|
|
112
|
+
repository(owner: $owner, name: $repo) {
|
|
113
|
+
pullRequest(number: $prNumber) {
|
|
114
|
+
comments(first: 100, after: $cursor) {
|
|
115
|
+
pageInfo {
|
|
116
|
+
hasNextPage
|
|
117
|
+
endCursor
|
|
118
|
+
}
|
|
119
|
+
nodes {
|
|
120
|
+
id
|
|
121
|
+
databaseId
|
|
122
|
+
body
|
|
123
|
+
author {
|
|
124
|
+
login
|
|
125
|
+
}
|
|
126
|
+
createdAt
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
`;
|
|
133
|
+
export const PR_FOR_BRANCH_QUERY = `
|
|
134
|
+
query PRForBranch($owner: String!, $repo: String!, $branch: String!) {
|
|
135
|
+
repository(owner: $owner, name: $repo) {
|
|
136
|
+
pullRequests(headRefName: $branch, states: [OPEN], first: 1) {
|
|
137
|
+
nodes {
|
|
138
|
+
id
|
|
139
|
+
number
|
|
140
|
+
url
|
|
141
|
+
title
|
|
142
|
+
state
|
|
143
|
+
headRefName
|
|
144
|
+
baseRefName
|
|
145
|
+
headRefOid
|
|
146
|
+
author { login }
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
`;
|
|
152
|
+
//# sourceMappingURL=queries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queries.js","sourceRoot":"","sources":["../../../src/github/queries.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAEhD,MAAM,CAAC,MAAM,oBAAoB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgCnC,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG;;;;;;;;;CAStC,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG;;;;;;;;;;CAUtC,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAG;;;;;;;;;;;;;;;;CAgBvB,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoChC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;;;;;;;;;;CAsBhC,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;CAkBlC,CAAC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/** Types representing GitHub GraphQL/REST API responses. */
|
|
2
|
+
export interface GHPullRequest {
|
|
3
|
+
number: number;
|
|
4
|
+
url: string;
|
|
5
|
+
title: string;
|
|
6
|
+
state: "OPEN" | "CLOSED" | "MERGED";
|
|
7
|
+
headRefName: string;
|
|
8
|
+
baseRefName: string;
|
|
9
|
+
headRefOid: string;
|
|
10
|
+
author: {
|
|
11
|
+
login: string;
|
|
12
|
+
};
|
|
13
|
+
commits?: {
|
|
14
|
+
nodes: {
|
|
15
|
+
commit: {
|
|
16
|
+
statusCheckRollup: {
|
|
17
|
+
contexts: {
|
|
18
|
+
nodes: {
|
|
19
|
+
databaseId?: number;
|
|
20
|
+
name?: string;
|
|
21
|
+
status?: string;
|
|
22
|
+
conclusion?: string | null;
|
|
23
|
+
detailsUrl?: string;
|
|
24
|
+
}[];
|
|
25
|
+
};
|
|
26
|
+
} | null;
|
|
27
|
+
};
|
|
28
|
+
}[];
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export interface GHReviewComment {
|
|
32
|
+
id: string;
|
|
33
|
+
databaseId: number;
|
|
34
|
+
body: string;
|
|
35
|
+
author: {
|
|
36
|
+
login: string;
|
|
37
|
+
};
|
|
38
|
+
path: string;
|
|
39
|
+
line: number | null;
|
|
40
|
+
diffHunk: string;
|
|
41
|
+
createdAt: string;
|
|
42
|
+
}
|
|
43
|
+
export interface GHReviewThread {
|
|
44
|
+
id: string;
|
|
45
|
+
isResolved: boolean;
|
|
46
|
+
isOutdated: boolean;
|
|
47
|
+
comments: {
|
|
48
|
+
nodes: GHReviewComment[];
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export interface GHReviewThreadsResponse {
|
|
52
|
+
data: {
|
|
53
|
+
repository: {
|
|
54
|
+
pullRequest: {
|
|
55
|
+
reviewThreads: {
|
|
56
|
+
pageInfo: {
|
|
57
|
+
hasNextPage: boolean;
|
|
58
|
+
endCursor: string | null;
|
|
59
|
+
};
|
|
60
|
+
nodes: GHReviewThread[];
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
export interface GHCheckRun {
|
|
67
|
+
id: number;
|
|
68
|
+
name: string;
|
|
69
|
+
status: string;
|
|
70
|
+
conclusion: string | null;
|
|
71
|
+
html_url: string;
|
|
72
|
+
app?: {
|
|
73
|
+
slug: string;
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
export interface GHCheckRunsResponse {
|
|
77
|
+
total_count: number;
|
|
78
|
+
check_runs: GHCheckRun[];
|
|
79
|
+
}
|
|
80
|
+
/** A top-level PR conversation comment (not inline on code). */
|
|
81
|
+
export interface GHPRComment {
|
|
82
|
+
id: string;
|
|
83
|
+
databaseId: number;
|
|
84
|
+
body: string;
|
|
85
|
+
author: {
|
|
86
|
+
login: string;
|
|
87
|
+
};
|
|
88
|
+
createdAt: string;
|
|
89
|
+
}
|
|
90
|
+
export interface GHPRCommentsResponse {
|
|
91
|
+
data: {
|
|
92
|
+
repository: {
|
|
93
|
+
pullRequest: {
|
|
94
|
+
comments: {
|
|
95
|
+
pageInfo: {
|
|
96
|
+
hasNextPage: boolean;
|
|
97
|
+
endCursor: string | null;
|
|
98
|
+
};
|
|
99
|
+
nodes: GHPRComment[];
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
export type GHReviewState = "APPROVED" | "CHANGES_REQUESTED" | "COMMENTED" | "DISMISSED" | "PENDING";
|
|
106
|
+
export interface GHReview {
|
|
107
|
+
id: string;
|
|
108
|
+
state: GHReviewState;
|
|
109
|
+
author: {
|
|
110
|
+
login: string;
|
|
111
|
+
};
|
|
112
|
+
submittedAt: string;
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/github/types.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAE5D,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1B,OAAO,CAAC,EAAE;QACR,KAAK,EAAE;YACL,MAAM,EAAE;gBACN,iBAAiB,EAAE;oBACjB,QAAQ,EAAE;wBACR,KAAK,EAAE;4BACL,UAAU,CAAC,EAAE,MAAM,CAAC;4BACpB,IAAI,CAAC,EAAE,MAAM,CAAC;4BACd,MAAM,CAAC,EAAE,MAAM,CAAC;4BAChB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;4BAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;yBACrB,EAAE,CAAC;qBACL,CAAC;iBACH,GAAG,IAAI,CAAC;aACV,CAA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AE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE;QACJ,UAAU,EAAE;YACV,WAAW,EAAE;gBACX,QAAQ,EAAE;oBACR,QAAQ,EAAE;wBAAE,WAAW,EAAE,OAAO,CAAC;wBAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;qBAAE,CAAC;oBAC7D,KAAK,EAAE,WAAW,EAAE,CAAC;iBACtB,CAAC;aACH,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,MAAM,MAAM,aAAa,GACrB,UAAU,GACV,mBAAmB,GACnB,WAAW,GACX,WAAW,GACX,SAAS,CAAC;AAEd,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,aAAa,CAAC;IACrB,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;CACrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/github/types.ts"],"names":[],"mappings":"AAAA,4DAA4D"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Daemon } from "../core/daemon.js";
|
|
2
|
+
interface AppProps {
|
|
3
|
+
daemon: Daemon;
|
|
4
|
+
startTime: number;
|
|
5
|
+
}
|
|
6
|
+
export declare function App({ daemon, startTime }: AppProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=App.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../../src/tui/App.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAuBhD,UAAU,QAAQ;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,GAAG,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,QAAQ,2CA6dlD"}
|