@h-rig/server 0.0.6-alpha.1 → 0.0.6-alpha.11
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/README.md +23 -0
- package/dist/src/index.js +920 -287
- package/dist/src/server-helpers/github-api-session-index.js +107 -0
- package/dist/src/server-helpers/github-auth-store.js +117 -21
- package/dist/src/server-helpers/github-user-namespace.js +102 -0
- package/dist/src/server-helpers/http-router.js +998 -151
- package/dist/src/server-helpers/issue-analysis.js +30 -11
- package/dist/src/server-helpers/project-registry.js +5 -0
- package/dist/src/server-helpers/run-mutations.js +248 -103
- package/dist/src/server-helpers/snapshot-orchestrator.js +1 -1
- package/dist/src/server-helpers/snapshot-service.js +1 -1
- package/dist/src/server-helpers/ws-router.js +4 -4
- package/dist/src/server.js +921 -287
- package/package.json +4 -4
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// packages/server/src/server-helpers/issue-analysis.ts
|
|
3
|
-
import { execFile } from "child_process";
|
|
4
3
|
import { createHash } from "crypto";
|
|
5
4
|
function stableIssueHash(issue) {
|
|
6
5
|
const labels = Array.isArray(issue.labels) ? [...issue.labels].map(String).sort() : [];
|
|
@@ -134,16 +133,33 @@ function parseIssueAnalysisResult(raw) {
|
|
|
134
133
|
return result;
|
|
135
134
|
}
|
|
136
135
|
function createDefaultPiIssueAnalysisCommandRunner() {
|
|
137
|
-
return (command, args, options) =>
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
const exitCode = typeof error?.code === "number" ? error.code : error ? 1 : 0;
|
|
144
|
-
resolve({ exitCode, stdout: String(stdout ?? ""), stderr: String(stderr ?? "") });
|
|
136
|
+
return async (command, args, options) => {
|
|
137
|
+
const env = options.env ? { ...process.env, ...options.env } : process.env;
|
|
138
|
+
const proc = Bun.spawn([command, ...args], {
|
|
139
|
+
stdout: "pipe",
|
|
140
|
+
stderr: "pipe",
|
|
141
|
+
env
|
|
145
142
|
});
|
|
146
|
-
|
|
143
|
+
let timedOut = false;
|
|
144
|
+
const timer = setTimeout(() => {
|
|
145
|
+
timedOut = true;
|
|
146
|
+
proc.kill();
|
|
147
|
+
}, options.timeoutMs);
|
|
148
|
+
try {
|
|
149
|
+
const [stdout, stderr, exitCode] = await Promise.all([
|
|
150
|
+
new Response(proc.stdout).text(),
|
|
151
|
+
new Response(proc.stderr).text(),
|
|
152
|
+
proc.exited
|
|
153
|
+
]);
|
|
154
|
+
return {
|
|
155
|
+
exitCode: timedOut && exitCode === 0 ? 1 : exitCode,
|
|
156
|
+
stdout,
|
|
157
|
+
stderr: timedOut && stderr.trim().length === 0 ? `Pi issue analysis timed out after ${options.timeoutMs}ms` : stderr
|
|
158
|
+
};
|
|
159
|
+
} finally {
|
|
160
|
+
clearTimeout(timer);
|
|
161
|
+
}
|
|
162
|
+
};
|
|
147
163
|
}
|
|
148
164
|
function createPiIssueAnalyzer(input = {}) {
|
|
149
165
|
const piBinary = input.piBinary ?? process.env.RIG_ISSUE_ANALYSIS_PI_BINARY ?? "pi";
|
|
@@ -151,7 +167,10 @@ function createPiIssueAnalyzer(input = {}) {
|
|
|
151
167
|
const runCommand = input.runCommand ?? createDefaultPiIssueAnalysisCommandRunner();
|
|
152
168
|
return async ({ prompt }) => {
|
|
153
169
|
const args = ["--print", "--mode", "json", "--no-session"];
|
|
154
|
-
const
|
|
170
|
+
const provider = input.provider?.trim() || process.env.RIG_ISSUE_ANALYSIS_PROVIDER?.trim() || process.env.RIG_PI_PROVIDER?.trim();
|
|
171
|
+
const model = input.model?.trim() || process.env.RIG_ISSUE_ANALYSIS_MODEL?.trim() || process.env.RIG_PI_MODEL?.trim() || "openai-codex/gpt-5.5";
|
|
172
|
+
if (provider)
|
|
173
|
+
args.push("--provider", provider);
|
|
155
174
|
if (model)
|
|
156
175
|
args.push("--model", model);
|
|
157
176
|
args.push(prompt);
|
|
@@ -115,8 +115,13 @@ function upsertProjectRecord(projectRoot, input) {
|
|
|
115
115
|
function linkProjectCheckout(projectRoot, repoSlug, checkout) {
|
|
116
116
|
return upsertProjectRecord(projectRoot, { repoSlug, checkout });
|
|
117
117
|
}
|
|
118
|
+
function projectRegistryContainsCheckout(projectRoot, checkoutPath) {
|
|
119
|
+
const target = resolve(checkoutPath);
|
|
120
|
+
return Object.values(readRegistry(projectRoot)).some((project) => project.checkouts.some((checkout) => checkout.path ? resolve(checkout.path) === target : false));
|
|
121
|
+
}
|
|
118
122
|
export {
|
|
119
123
|
upsertProjectRecord,
|
|
124
|
+
projectRegistryContainsCheckout,
|
|
120
125
|
normalizeRepoSlug,
|
|
121
126
|
linkProjectCheckout,
|
|
122
127
|
getProjectRecord,
|