@ipul-labs/forge 1.16.7 → 1.17.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/README.md +58 -21
- package/lib/bin/cli/analyze.d.ts +9 -0
- package/lib/bin/cli/analyze.d.ts.map +1 -0
- package/lib/bin/cli/analyze.js +491 -0
- package/lib/bin/cli/analyze.js.map +1 -0
- package/lib/bin/cli/apply.d.ts +2 -0
- package/lib/bin/cli/apply.d.ts.map +1 -0
- package/lib/bin/cli/apply.js +262 -0
- package/lib/bin/cli/apply.js.map +1 -0
- package/lib/bin/cli/cifix.d.ts +2 -0
- package/lib/bin/cli/cifix.d.ts.map +1 -0
- package/lib/bin/cli/cifix.js +310 -0
- package/lib/bin/cli/cifix.js.map +1 -0
- package/lib/bin/cli/close.d.ts +2 -0
- package/lib/bin/cli/close.d.ts.map +1 -0
- package/lib/bin/cli/close.js +113 -0
- package/lib/bin/cli/close.js.map +1 -0
- package/lib/bin/cli/createIssue.d.ts +2 -0
- package/lib/bin/cli/createIssue.d.ts.map +1 -0
- package/lib/bin/cli/createIssue.js +108 -0
- package/lib/bin/cli/createIssue.js.map +1 -0
- package/lib/bin/cli/doctor.d.ts +2 -0
- package/lib/bin/cli/doctor.d.ts.map +1 -0
- package/lib/bin/cli/doctor.js +145 -0
- package/lib/bin/cli/doctor.js.map +1 -0
- package/lib/bin/cli/init.d.ts +4 -0
- package/lib/bin/cli/init.d.ts.map +1 -0
- package/lib/bin/cli/init.js +288 -0
- package/lib/bin/cli/init.js.map +1 -0
- package/lib/bin/cli/ink.d.ts +23 -0
- package/lib/bin/cli/ink.d.ts.map +1 -0
- package/{bin → lib/bin}/cli/ink.js +18 -19
- package/lib/bin/cli/ink.js.map +1 -0
- package/lib/bin/cli/issue.d.ts +2 -0
- package/lib/bin/cli/issue.d.ts.map +1 -0
- package/lib/bin/cli/issue.js +114 -0
- package/lib/bin/cli/issue.js.map +1 -0
- package/lib/bin/cli/issues.d.ts +2 -0
- package/lib/bin/cli/issues.d.ts.map +1 -0
- package/lib/bin/cli/issues.js +149 -0
- package/lib/bin/cli/issues.js.map +1 -0
- package/lib/bin/cli/merge.d.ts +2 -0
- package/lib/bin/cli/merge.d.ts.map +1 -0
- package/lib/bin/cli/merge.js +162 -0
- package/lib/bin/cli/merge.js.map +1 -0
- package/lib/bin/cli/refine.d.ts +2 -0
- package/lib/bin/cli/refine.d.ts.map +1 -0
- package/lib/bin/cli/refine.js +249 -0
- package/lib/bin/cli/refine.js.map +1 -0
- package/lib/bin/cli/repl.d.ts +2 -0
- package/lib/bin/cli/repl.d.ts.map +1 -0
- package/lib/bin/cli/repl.js +309 -0
- package/lib/bin/cli/repl.js.map +1 -0
- package/lib/bin/cli/repos.d.ts +2 -0
- package/lib/bin/cli/repos.d.ts.map +1 -0
- package/lib/bin/cli/repos.js +86 -0
- package/lib/bin/cli/repos.js.map +1 -0
- package/lib/bin/cli/resolution.d.ts +2 -0
- package/lib/bin/cli/resolution.d.ts.map +1 -0
- package/lib/bin/cli/resolution.js +139 -0
- package/lib/bin/cli/resolution.js.map +1 -0
- package/lib/bin/cli/serverClient.d.ts +26 -0
- package/lib/bin/cli/serverClient.d.ts.map +1 -0
- package/lib/bin/cli/serverClient.js +111 -0
- package/lib/bin/cli/serverClient.js.map +1 -0
- package/lib/bin/cli/session.d.ts +8 -0
- package/lib/bin/cli/session.d.ts.map +1 -0
- package/lib/bin/cli/session.js +212 -0
- package/lib/bin/cli/session.js.map +1 -0
- package/lib/bin/cli/sessionStore.d.ts +69 -0
- package/lib/bin/cli/sessionStore.d.ts.map +1 -0
- package/lib/bin/cli/sessionStore.js +196 -0
- package/lib/bin/cli/sessionStore.js.map +1 -0
- package/lib/bin/cli/ship.d.ts +33 -0
- package/lib/bin/cli/ship.d.ts.map +1 -0
- package/lib/bin/cli/ship.js +737 -0
- package/lib/bin/cli/ship.js.map +1 -0
- package/lib/bin/cli/types.d.ts +59 -0
- package/lib/bin/cli/types.d.ts.map +1 -0
- package/lib/bin/cli/types.js +2 -0
- package/lib/bin/cli/types.js.map +1 -0
- package/lib/bin/cli/update.d.ts +2 -0
- package/lib/bin/cli/update.d.ts.map +1 -0
- package/lib/bin/cli/update.js +87 -0
- package/lib/bin/cli/update.js.map +1 -0
- package/lib/bin/cli/utils.d.ts +43 -0
- package/lib/bin/cli/utils.d.ts.map +1 -0
- package/lib/bin/cli/utils.js +171 -0
- package/lib/bin/cli/utils.js.map +1 -0
- package/lib/bin/cli/validate.d.ts +2 -0
- package/lib/bin/cli/validate.d.ts.map +1 -0
- package/lib/bin/cli/validate.js +283 -0
- package/lib/bin/cli/validate.js.map +1 -0
- package/lib/bin/cli/watch.d.ts +5 -0
- package/lib/bin/cli/watch.d.ts.map +1 -0
- package/lib/bin/cli/watch.js +263 -0
- package/lib/bin/cli/watch.js.map +1 -0
- package/lib/bin/forge-agent.d.ts +3 -0
- package/lib/bin/forge-agent.d.ts.map +1 -0
- package/{bin → lib/bin}/forge-agent.js +104 -105
- package/lib/bin/forge-agent.js.map +1 -0
- package/lib/server/forge/core/ForgeAgent.d.ts +260 -0
- package/lib/server/forge/core/ForgeAgent.d.ts.map +1 -0
- package/lib/server/forge/core/ForgeAgent.js +995 -0
- package/lib/server/forge/core/ForgeAgent.js.map +1 -0
- package/lib/server/forge/core/agentClient.d.ts +39 -0
- package/lib/server/forge/core/agentClient.d.ts.map +1 -0
- package/{server → lib/server}/forge/core/agentClient.js +7 -12
- package/lib/server/forge/core/agentClient.js.map +1 -0
- package/lib/server/forge/core/branchName.d.ts +20 -0
- package/lib/server/forge/core/branchName.d.ts.map +1 -0
- package/lib/server/forge/core/branchName.js +39 -0
- package/lib/server/forge/core/branchName.js.map +1 -0
- package/lib/server/forge/core/claudeClient.d.ts +60 -0
- package/lib/server/forge/core/claudeClient.d.ts.map +1 -0
- package/lib/server/forge/core/claudeClient.js +347 -0
- package/lib/server/forge/core/claudeClient.js.map +1 -0
- package/lib/server/forge/core/configStore.d.ts +76 -0
- package/lib/server/forge/core/configStore.d.ts.map +1 -0
- package/lib/server/forge/core/configStore.js +213 -0
- package/lib/server/forge/core/configStore.js.map +1 -0
- package/lib/server/forge/core/gitlabClient.d.ts +144 -0
- package/lib/server/forge/core/gitlabClient.d.ts.map +1 -0
- package/{server → lib/server}/forge/core/gitlabClient.js +98 -180
- package/lib/server/forge/core/gitlabClient.js.map +1 -0
- package/lib/server/forge/core/jobs.d.ts +67 -0
- package/lib/server/forge/core/jobs.d.ts.map +1 -0
- package/lib/server/forge/core/jobs.js +185 -0
- package/lib/server/forge/core/jobs.js.map +1 -0
- package/lib/server/forge/core/k8s.d.ts +18 -0
- package/lib/server/forge/core/k8s.d.ts.map +1 -0
- package/lib/server/forge/core/k8s.js +49 -0
- package/lib/server/forge/core/k8s.js.map +1 -0
- package/lib/server/forge/core/localRepo.d.ts +36 -0
- package/lib/server/forge/core/localRepo.d.ts.map +1 -0
- package/lib/server/forge/core/localRepo.js +165 -0
- package/lib/server/forge/core/localRepo.js.map +1 -0
- package/lib/server/forge/core/openclawClient.d.ts +61 -0
- package/lib/server/forge/core/openclawClient.d.ts.map +1 -0
- package/lib/server/forge/core/openclawClient.js +111 -0
- package/lib/server/forge/core/openclawClient.js.map +1 -0
- package/lib/server/forge/core/prompts.d.ts +96 -0
- package/lib/server/forge/core/prompts.d.ts.map +1 -0
- package/lib/server/forge/core/prompts.js +450 -0
- package/lib/server/forge/core/prompts.js.map +1 -0
- package/lib/server/forge/core/providers/azuredevops.d.ts +134 -0
- package/lib/server/forge/core/providers/azuredevops.d.ts.map +1 -0
- package/lib/server/forge/core/providers/azuredevops.js +360 -0
- package/lib/server/forge/core/providers/azuredevops.js.map +1 -0
- package/lib/server/forge/core/providers/base.d.ts +114 -0
- package/lib/server/forge/core/providers/base.d.ts.map +1 -0
- package/lib/server/forge/core/providers/base.js +98 -0
- package/lib/server/forge/core/providers/base.js.map +1 -0
- package/lib/server/forge/core/providers/github.d.ts +133 -0
- package/lib/server/forge/core/providers/github.d.ts.map +1 -0
- package/lib/server/forge/core/providers/github.js +307 -0
- package/lib/server/forge/core/providers/github.js.map +1 -0
- package/lib/server/forge/core/providers/gitlab.d.ts +144 -0
- package/lib/server/forge/core/providers/gitlab.d.ts.map +1 -0
- package/lib/server/forge/core/providers/gitlab.js +407 -0
- package/lib/server/forge/core/providers/gitlab.js.map +1 -0
- package/lib/server/forge/core/providers/index.d.ts +21 -0
- package/lib/server/forge/core/providers/index.d.ts.map +1 -0
- package/lib/server/forge/core/providers/index.js +43 -0
- package/lib/server/forge/core/providers/index.js.map +1 -0
- package/lib/server/forge/core/providers/types.d.ts +80 -0
- package/lib/server/forge/core/providers/types.d.ts.map +1 -0
- package/lib/server/forge/core/providers/types.js +2 -0
- package/lib/server/forge/core/providers/types.js.map +1 -0
- package/lib/server/forge/core/quotaClient.d.ts +48 -0
- package/lib/server/forge/core/quotaClient.d.ts.map +1 -0
- package/lib/server/forge/core/quotaClient.js +88 -0
- package/lib/server/forge/core/quotaClient.js.map +1 -0
- package/lib/server/forge/core/types.d.ts +160 -0
- package/lib/server/forge/core/types.d.ts.map +1 -0
- package/lib/server/forge/core/types.js +2 -0
- package/lib/server/forge/core/types.js.map +1 -0
- package/lib/server/forge/core/validator/attribute.d.ts +31 -0
- package/lib/server/forge/core/validator/attribute.d.ts.map +1 -0
- package/lib/server/forge/core/validator/attribute.js +82 -0
- package/lib/server/forge/core/validator/attribute.js.map +1 -0
- package/lib/server/forge/core/validator/clone.d.ts +14 -0
- package/lib/server/forge/core/validator/clone.d.ts.map +1 -0
- package/lib/server/forge/core/validator/clone.js +99 -0
- package/lib/server/forge/core/validator/clone.js.map +1 -0
- package/lib/server/forge/core/validator/cmd.d.ts +23 -0
- package/lib/server/forge/core/validator/cmd.d.ts.map +1 -0
- package/lib/server/forge/core/validator/cmd.js +87 -0
- package/lib/server/forge/core/validator/cmd.js.map +1 -0
- package/lib/server/forge/core/validator/fs.d.ts +5 -0
- package/lib/server/forge/core/validator/fs.d.ts.map +1 -0
- package/{server → lib/server}/forge/core/validator/fs.js +8 -3
- package/lib/server/forge/core/validator/fs.js.map +1 -0
- package/lib/server/forge/core/validator/overlay.d.ts +13 -0
- package/lib/server/forge/core/validator/overlay.d.ts.map +1 -0
- package/lib/server/forge/core/validator/overlay.js +53 -0
- package/lib/server/forge/core/validator/overlay.js.map +1 -0
- package/lib/server/forge/core/validator/projectType.d.ts +20 -0
- package/lib/server/forge/core/validator/projectType.d.ts.map +1 -0
- package/lib/server/forge/core/validator/projectType.js +94 -0
- package/lib/server/forge/core/validator/projectType.js.map +1 -0
- package/lib/server/forge/core/validator/runners/go.d.ts +21 -0
- package/lib/server/forge/core/validator/runners/go.d.ts.map +1 -0
- package/lib/server/forge/core/validator/runners/go.js +99 -0
- package/lib/server/forge/core/validator/runners/go.js.map +1 -0
- package/lib/server/forge/core/validator/runners/node.d.ts +12 -0
- package/lib/server/forge/core/validator/runners/node.d.ts.map +1 -0
- package/lib/server/forge/core/validator/runners/node.js +75 -0
- package/lib/server/forge/core/validator/runners/node.js.map +1 -0
- package/lib/server/forge/core/validator/tdd.d.ts +30 -0
- package/lib/server/forge/core/validator/tdd.d.ts.map +1 -0
- package/lib/server/forge/core/validator/tdd.js +96 -0
- package/lib/server/forge/core/validator/tdd.js.map +1 -0
- package/lib/server/forge/core/validator.d.ts +58 -0
- package/lib/server/forge/core/validator.d.ts.map +1 -0
- package/lib/server/forge/core/validator.js +150 -0
- package/lib/server/forge/core/validator.js.map +1 -0
- package/lib/server/forge/routes.d.ts +22 -0
- package/lib/server/forge/routes.d.ts.map +1 -0
- package/lib/server/forge/routes.js +984 -0
- package/lib/server/forge/routes.js.map +1 -0
- package/lib/server.d.ts +2 -0
- package/lib/server.d.ts.map +1 -0
- package/lib/server.js +52 -0
- package/lib/server.js.map +1 -0
- package/lib/shared/events.d.ts +12 -0
- package/lib/shared/events.d.ts.map +1 -0
- package/lib/shared/events.js +12 -0
- package/lib/shared/events.js.map +1 -0
- package/package.json +17 -13
- package/scripts/fix-shebang.cjs +10 -0
- package/bin/cli/analyze.js +0 -516
- package/bin/cli/apply.js +0 -264
- package/bin/cli/cifix.js +0 -300
- package/bin/cli/close.js +0 -125
- package/bin/cli/createIssue.js +0 -112
- package/bin/cli/doctor.js +0 -161
- package/bin/cli/init.js +0 -306
- package/bin/cli/issue.js +0 -116
- package/bin/cli/issues.js +0 -155
- package/bin/cli/merge.js +0 -175
- package/bin/cli/refine.js +0 -253
- package/bin/cli/repl.js +0 -301
- package/bin/cli/repos.js +0 -91
- package/bin/cli/resolution.js +0 -126
- package/bin/cli/session.js +0 -230
- package/bin/cli/sessionStore.js +0 -211
- package/bin/cli/ship.js +0 -762
- package/bin/cli/update.js +0 -95
- package/bin/cli/utils.js +0 -145
- package/bin/cli/validate.js +0 -280
- package/bin/cli/watch.js +0 -274
- package/server/forge/core/ForgeAgent.js +0 -1179
- package/server/forge/core/ForgeAgent.test.js +0 -179
- package/server/forge/core/branchName.js +0 -41
- package/server/forge/core/claudeClient.js +0 -378
- package/server/forge/core/configStore.js +0 -229
- package/server/forge/core/configStore.test.js +0 -89
- package/server/forge/core/jobs.js +0 -180
- package/server/forge/core/k8s.js +0 -54
- package/server/forge/core/localRepo.js +0 -153
- package/server/forge/core/openclawClient.js +0 -125
- package/server/forge/core/prompts.js +0 -483
- package/server/forge/core/prompts.test.js +0 -219
- package/server/forge/core/providers/azuredevops.js +0 -409
- package/server/forge/core/providers/base.js +0 -208
- package/server/forge/core/providers/github.js +0 -348
- package/server/forge/core/providers/gitlab.js +0 -529
- package/server/forge/core/providers/index.js +0 -47
- package/server/forge/core/quotaClient.js +0 -101
- package/server/forge/core/validator/attribute.js +0 -84
- package/server/forge/core/validator/clone.js +0 -105
- package/server/forge/core/validator/cmd.js +0 -98
- package/server/forge/core/validator/overlay.js +0 -52
- package/server/forge/core/validator/projectType.js +0 -87
- package/server/forge/core/validator/runners/go.js +0 -107
- package/server/forge/core/validator/runners/node.js +0 -84
- package/server/forge/core/validator/tdd.js +0 -105
- package/server/forge/core/validator.js +0 -167
- package/server/forge/routes.js +0 -1026
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* server/forge/core/openclawClient.js
|
|
3
|
+
*
|
|
4
|
+
* Communicates with a locally-running OpenClaw Gateway over HTTP.
|
|
5
|
+
* Configure with:
|
|
6
|
+
* OPENCLAW_GATEWAY_URL — e.g. http://192.168.x.x:18789 (Tailscale) or SSH tunnel
|
|
7
|
+
* OPENCLAW_TOKEN — Bearer token if your Gateway requires auth
|
|
8
|
+
*
|
|
9
|
+
* The Gateway runs on 127.0.0.1:18789 by default. Expose it remotely via:
|
|
10
|
+
* Tailscale: bind to tailnet interface
|
|
11
|
+
* SSH tunnel: ssh -N -L 18789:127.0.0.1:18789 user@host
|
|
12
|
+
*/
|
|
13
|
+
import { buildIdentifyFilesPrompt, buildProposeFixPrompt, buildRefineOrAskPrompt, buildCheckResolutionPrompt, } from "./prompts.js";
|
|
14
|
+
const GATEWAY_URL = process.env.OPENCLAW_GATEWAY_URL?.replace(/\/$/, "");
|
|
15
|
+
const GATEWAY_TOKEN = process.env.OPENCLAW_TOKEN;
|
|
16
|
+
const TIMEOUT_MS = 120_000;
|
|
17
|
+
// ─── JSON output helpers ──────────────────────────────────────────────────────
|
|
18
|
+
function extractJSON(text) {
|
|
19
|
+
const fenced = text.match(/```(?:json)?\s*([\s\S]*?)```/);
|
|
20
|
+
if (fenced)
|
|
21
|
+
return JSON.parse(fenced[1].trim());
|
|
22
|
+
const start = text.indexOf("{");
|
|
23
|
+
const end = text.lastIndexOf("}");
|
|
24
|
+
if (start !== -1 && end !== -1)
|
|
25
|
+
return JSON.parse(text.slice(start, end + 1));
|
|
26
|
+
throw new Error("No JSON found in OpenClaw response");
|
|
27
|
+
}
|
|
28
|
+
// ─── Gateway transport ────────────────────────────────────────────────────────
|
|
29
|
+
/**
|
|
30
|
+
* Send a prompt to the OpenClaw Gateway and return the text response.
|
|
31
|
+
*
|
|
32
|
+
* @param {string} prompt
|
|
33
|
+
* @param {string} [model]
|
|
34
|
+
* @param {{ signal?: AbortSignal }} [opts]
|
|
35
|
+
* @returns {Promise<string>}
|
|
36
|
+
*/
|
|
37
|
+
async function callGateway(prompt, model, opts = {}) {
|
|
38
|
+
if (!GATEWAY_URL) {
|
|
39
|
+
throw new Error("OPENCLAW_GATEWAY_URL is not set. Add it to your .env and point it at your OpenClaw Gateway.");
|
|
40
|
+
}
|
|
41
|
+
const controller = new AbortController();
|
|
42
|
+
const timer = setTimeout(() => controller.abort(), TIMEOUT_MS);
|
|
43
|
+
// Chain the external cancel signal so a job cancel aborts the fetch in
|
|
44
|
+
// addition to the timeout.
|
|
45
|
+
const external = opts.signal;
|
|
46
|
+
const onExternalAbort = () => controller.abort();
|
|
47
|
+
if (external) {
|
|
48
|
+
if (external.aborted)
|
|
49
|
+
controller.abort();
|
|
50
|
+
else
|
|
51
|
+
external.addEventListener("abort", onExternalAbort, { once: true });
|
|
52
|
+
}
|
|
53
|
+
try {
|
|
54
|
+
const body = { message: prompt };
|
|
55
|
+
if (model)
|
|
56
|
+
body.model = model;
|
|
57
|
+
const res = await fetch(`${GATEWAY_URL}/api/v1/agent`, {
|
|
58
|
+
method: "POST",
|
|
59
|
+
headers: {
|
|
60
|
+
"Content-Type": "application/json",
|
|
61
|
+
...(GATEWAY_TOKEN ? { Authorization: `Bearer ${GATEWAY_TOKEN}` } : {}),
|
|
62
|
+
},
|
|
63
|
+
body: JSON.stringify(body),
|
|
64
|
+
signal: controller.signal,
|
|
65
|
+
});
|
|
66
|
+
if (!res.ok) {
|
|
67
|
+
const text = await res.text().catch(() => "");
|
|
68
|
+
throw new Error(`OpenClaw gateway ${res.status}: ${text.slice(0, 300)}`);
|
|
69
|
+
}
|
|
70
|
+
const data = await res.json();
|
|
71
|
+
return String(data.result ?? data.message ?? data.content ?? data.text ?? JSON.stringify(data));
|
|
72
|
+
}
|
|
73
|
+
catch (err) {
|
|
74
|
+
if (err instanceof Error && err.name === "AbortError") {
|
|
75
|
+
// External cancellation wins over "timeout" framing so the terminal
|
|
76
|
+
// event the job emits reflects the user action, not a stale timer.
|
|
77
|
+
if (external?.aborted)
|
|
78
|
+
throw err;
|
|
79
|
+
throw new Error("OpenClaw gateway timed out after 2 minutes");
|
|
80
|
+
}
|
|
81
|
+
throw err;
|
|
82
|
+
}
|
|
83
|
+
finally {
|
|
84
|
+
clearTimeout(timer);
|
|
85
|
+
external?.removeEventListener("abort", onExternalAbort);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
// ─── Public API (mirrors claudeClient.js) ────────────────────────────────────
|
|
89
|
+
export async function checkResolution(issue, diffs, model, opts = {}) {
|
|
90
|
+
const text = await callGateway(buildCheckResolutionPrompt(issue, diffs), model, opts);
|
|
91
|
+
const data = extractJSON(text);
|
|
92
|
+
return { ...data, cost: 0, serviceTier: "openclaw", inputTokens: 0, outputTokens: 0, cacheCreationTokens: 0, cacheReadTokens: 0 };
|
|
93
|
+
}
|
|
94
|
+
export async function identifyRelevantFiles(issue, fileTree, model, opts = {}) {
|
|
95
|
+
const text = await callGateway(buildIdentifyFilesPrompt(issue, fileTree), model, opts);
|
|
96
|
+
const data = extractJSON(text);
|
|
97
|
+
return { ...data, cost: 0, serviceTier: "openclaw", inputTokens: 0, outputTokens: 0, cacheCreationTokens: 0, cacheReadTokens: 0 };
|
|
98
|
+
}
|
|
99
|
+
export async function proposeFix(issue, fileContents, options = {}, model, opts = {}) {
|
|
100
|
+
const text = await callGateway(buildProposeFixPrompt(issue, fileContents, options), model, opts);
|
|
101
|
+
const data = extractJSON(text);
|
|
102
|
+
return { ...data, cost: 0, serviceTier: "openclaw", inputTokens: 0, outputTokens: 0, cacheCreationTokens: 0, cacheReadTokens: 0 };
|
|
103
|
+
}
|
|
104
|
+
export async function refineOrAsk(issue, fileContents, options = {}, model, _onEvent, opts = {}) {
|
|
105
|
+
// OpenClaw is a single HTTP round-trip — no streaming surface. The onEvent
|
|
106
|
+
// callback is accepted for signature parity with claudeClient and ignored.
|
|
107
|
+
const text = await callGateway(buildRefineOrAskPrompt(issue, fileContents, options), model, opts);
|
|
108
|
+
const data = extractJSON(text);
|
|
109
|
+
return { ...data, cost: 0, serviceTier: "openclaw", inputTokens: 0, outputTokens: 0, cacheCreationTokens: 0, cacheReadTokens: 0 };
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=openclawClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openclawClient.js","sourceRoot":"","sources":["../../../../server/forge/core/openclawClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACN,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,0BAA0B,GAC1B,MAAM,cAAc,CAAC;AAsDtB,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AACzE,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;AACjD,MAAM,UAAU,GAAG,OAAO,CAAC;AAE3B,iFAAiF;AAEjF,SAAS,WAAW,CAAC,IAAY;IAChC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAC1D,IAAI,MAAM;QAAE,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAChD,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAChC,MAAM,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAClC,IAAI,KAAK,KAAK,CAAC,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;IAC9E,MAAM,IAAI,K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AK,UAAU,WAAW,CAAC,KAAiB,EAAE,YAA2B,EAAE,UAAyB,EAAE,EAAE,KAAyB,EAAE,QAAiD,EAAE,OAAwB,EAAE;IACtN,2EAA2E;IAC3E,2EAA2E;IAC3E,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC,sBAAsB,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IAClG,MAAM,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IAC/B,OAAO,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,mBAAmB,EAAE,CAAC,EAAE,eAAe,EAAE,CAAC,EAAE,CAAC;AACnI,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* server/forge/core/prompts.js
|
|
3
|
+
*
|
|
4
|
+
* Shared prompt builders used by both claudeClient and openclawClient.
|
|
5
|
+
*
|
|
6
|
+
* Multi-repo awareness: when more than one repo is in play (full-stack fixes),
|
|
7
|
+
* every file reference carries a `repo` field so the model can target changes
|
|
8
|
+
* to the correct repository. Single-repo callers can still pass file trees /
|
|
9
|
+
* contents without a repo field — they are normalised before rendering.
|
|
10
|
+
*/
|
|
11
|
+
import type { NormalDiff } from "./providers/types.ts";
|
|
12
|
+
import type { ForgeChange } from "./types.ts";
|
|
13
|
+
interface RepoTree {
|
|
14
|
+
repo: string;
|
|
15
|
+
files: string[];
|
|
16
|
+
}
|
|
17
|
+
interface FileContent {
|
|
18
|
+
repo?: string;
|
|
19
|
+
path: string;
|
|
20
|
+
content: string;
|
|
21
|
+
}
|
|
22
|
+
interface IssueInput {
|
|
23
|
+
iid?: number;
|
|
24
|
+
title?: string | null;
|
|
25
|
+
description?: string | null;
|
|
26
|
+
labels?: Array<string | {
|
|
27
|
+
name?: string;
|
|
28
|
+
}> | null;
|
|
29
|
+
}
|
|
30
|
+
interface ValidationStep {
|
|
31
|
+
skipped?: boolean;
|
|
32
|
+
status?: string;
|
|
33
|
+
passed?: boolean;
|
|
34
|
+
exitCode?: number;
|
|
35
|
+
tail?: string;
|
|
36
|
+
}
|
|
37
|
+
interface ValidationState {
|
|
38
|
+
checkedAt?: string;
|
|
39
|
+
allPassed?: boolean;
|
|
40
|
+
steps?: Record<string, ValidationStep>;
|
|
41
|
+
}
|
|
42
|
+
interface ProposeFixOptions {
|
|
43
|
+
feedback?: string;
|
|
44
|
+
previousChanges?: ForgeChange[];
|
|
45
|
+
ciContext?: string;
|
|
46
|
+
userPrompt?: string;
|
|
47
|
+
repos?: string[];
|
|
48
|
+
promptRules?: string;
|
|
49
|
+
}
|
|
50
|
+
interface RefineOptions {
|
|
51
|
+
feedback?: string;
|
|
52
|
+
previousChanges?: ForgeChange[];
|
|
53
|
+
validationState?: ValidationState;
|
|
54
|
+
repos?: string[];
|
|
55
|
+
repoTrees?: RepoTree[];
|
|
56
|
+
repoAccessMode?: string;
|
|
57
|
+
promptRules?: string;
|
|
58
|
+
repoCwd?: string;
|
|
59
|
+
sessionId?: string;
|
|
60
|
+
resumeSession?: boolean;
|
|
61
|
+
}
|
|
62
|
+
interface ResumeOptions {
|
|
63
|
+
feedback?: string;
|
|
64
|
+
validationState?: ValidationState;
|
|
65
|
+
}
|
|
66
|
+
export declare const SELECT_FILES_SCHEMA: string;
|
|
67
|
+
export declare const PROPOSE_FIX_SCHEMA: string;
|
|
68
|
+
export declare const CI_FIX_SCHEMA: string;
|
|
69
|
+
export declare const REFINE_OR_ASK_SCHEMA: string;
|
|
70
|
+
export declare const RESOLUTION_CHECK_SCHEMA: string;
|
|
71
|
+
/**
|
|
72
|
+
* Classifies an issue as "feature", "fix", or "chore" from its title, labels,
|
|
73
|
+
* and description. Used to select the right prompt guidance and file caps.
|
|
74
|
+
*
|
|
75
|
+
* Priority: conventional-commit title prefix > labels > description heuristics > default "fix".
|
|
76
|
+
*/
|
|
77
|
+
export declare function classifyIssue(issue: IssueInput): "feature" | "fix" | "chore" | "refactor";
|
|
78
|
+
export declare function buildIdentifyFilesPrompt(issue: IssueInput, repoTrees: RepoTree[] | string[]): string;
|
|
79
|
+
export declare function buildProposeFixPrompt(issue: IssueInput, fileContents: FileContent[], options?: ProposeFixOptions): string;
|
|
80
|
+
/**
|
|
81
|
+
* Single-prompt conversational refine: the model auto-classifies the user's
|
|
82
|
+
* message as a question about state or a directive to change code, then
|
|
83
|
+
* responds with EITHER a grounded answer OR a fresh changes[] payload.
|
|
84
|
+
*/
|
|
85
|
+
export declare function buildRefineOrAskPrompt(issue: IssueInput, fileContents: FileContent[], options?: RefineOptions): string;
|
|
86
|
+
/**
|
|
87
|
+
* Slim continuation prompt for refine turns 2+ when the Claude session is
|
|
88
|
+
* being resumed via `--resume <id>`. The model already has the issue, repo
|
|
89
|
+
* access, prior proposed changes, and full file contents from the first
|
|
90
|
+
* turn — repeating them would waste tokens and dilute the cache hit. We only
|
|
91
|
+
* inject what's new: the user's message and the latest validation state.
|
|
92
|
+
*/
|
|
93
|
+
export declare function buildRefineResumePrompt(options?: ResumeOptions): string;
|
|
94
|
+
export declare function buildCheckResolutionPrompt(issue: IssueInput, diffs: NormalDiff[]): string;
|
|
95
|
+
export {};
|
|
96
|
+
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../../server/forge/core/prompts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAe,MAAM,sBAAsB,CAAC;AACpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,UAAU,QAAQ;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,EAAE,CAAC;CAChB;AAED,UAAU,WAAW;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC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