staklink 0.3.75 → 0.3.77
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/dist/proxy-server.cjs +180 -58
- package/dist/staklink-cli.cjs +1 -1
- package/package.json +1 -1
package/dist/proxy-server.cjs
CHANGED
|
@@ -53094,9 +53094,7 @@ async function startup() {
|
|
|
53094
53094
|
try {
|
|
53095
53095
|
await runner.runRebuildCommands(config4);
|
|
53096
53096
|
await runner.runInstallCommands(config4);
|
|
53097
|
-
log(
|
|
53098
|
-
`\u2705 Install commands executed successfully in ${workspaceRoot2}`
|
|
53099
|
-
);
|
|
53097
|
+
log(`\u2705 Install commands executed successfully in ${workspaceRoot2}`);
|
|
53100
53098
|
} catch (error87) {
|
|
53101
53099
|
log(`\u274C Failed to run install/rebuild commands: ${error87}`);
|
|
53102
53100
|
}
|
|
@@ -61116,9 +61114,7 @@ var Repo = class {
|
|
|
61116
61114
|
const isRejectedDueToRemoteChanges = errorMessage.includes("[rejected]") || errorMessage.includes("non-fast-forward") || errorMessage.includes("Updates were rejected");
|
|
61117
61115
|
if (isRejectedDueToRemoteChanges) {
|
|
61118
61116
|
try {
|
|
61119
|
-
await this.execCommand(
|
|
61120
|
-
`git pull --rebase origin ${currentBranch}`
|
|
61121
|
-
);
|
|
61117
|
+
await this.execCommand(`git pull --rebase origin ${currentBranch}`);
|
|
61122
61118
|
} catch (pullError) {
|
|
61123
61119
|
const status = await this.execCommand("git status");
|
|
61124
61120
|
if (status.includes("rebase in progress") || status.includes("Unmerged") || status.includes("both modified")) {
|
|
@@ -61217,7 +61213,7 @@ var SSEManager = class {
|
|
|
61217
61213
|
var sseManager = new SSEManager();
|
|
61218
61214
|
|
|
61219
61215
|
// src/proxy/version.ts
|
|
61220
|
-
var VERSION = "0.3.
|
|
61216
|
+
var VERSION = "0.3.77";
|
|
61221
61217
|
|
|
61222
61218
|
// node_modules/uuid/dist/esm/stringify.js
|
|
61223
61219
|
var byteToHex = [];
|
|
@@ -121551,22 +121547,34 @@ function sanitizeShellArg2(arg) {
|
|
|
121551
121547
|
}
|
|
121552
121548
|
|
|
121553
121549
|
// src/agent/goose.ts
|
|
121554
|
-
function goose_env(apiKey) {
|
|
121550
|
+
function goose_env(apiKey, model = "sonnet") {
|
|
121551
|
+
const models = {
|
|
121552
|
+
sonnet: "claude-sonnet-4-5",
|
|
121553
|
+
opus: "claude-opus-4-5"
|
|
121554
|
+
};
|
|
121555
121555
|
return {
|
|
121556
121556
|
GOOSE_CONTEXT_STRATEGY: "summarize",
|
|
121557
121557
|
GOOSE_MAX_TURNS: "2000",
|
|
121558
121558
|
GOOSE_MODE: "auto",
|
|
121559
121559
|
GOOSE_PROVIDER: "anthropic",
|
|
121560
|
-
GOOSE_MODEL:
|
|
121560
|
+
GOOSE_MODEL: models[model] || models.sonnet,
|
|
121561
121561
|
GOOSE_CLI_MIN_PRIORITY: "1.0",
|
|
121562
121562
|
CONFIGURE: "false",
|
|
121563
121563
|
ANTHROPIC_API_KEY: apiKey,
|
|
121564
121564
|
PATH: `${path7.join(os.homedir(), ".local", "bin")}:${process.env.PATH}`
|
|
121565
121565
|
};
|
|
121566
121566
|
}
|
|
121567
|
-
async function runAgent({
|
|
121567
|
+
async function runAgent({
|
|
121568
|
+
prompt,
|
|
121569
|
+
apiKey,
|
|
121570
|
+
cwd,
|
|
121571
|
+
system_prompt,
|
|
121572
|
+
session,
|
|
121573
|
+
summarize,
|
|
121574
|
+
model
|
|
121575
|
+
}) {
|
|
121568
121576
|
createGooseConfig();
|
|
121569
|
-
const env = goose_env(apiKey);
|
|
121577
|
+
const env = goose_env(apiKey, model);
|
|
121570
121578
|
console.log("RUN goose with env", env);
|
|
121571
121579
|
const cleanPrompt = sanitizeShellArg(prompt);
|
|
121572
121580
|
let system = system_prompt ? sanitizeShellArg(system_prompt) + "\n\n" : "";
|
|
@@ -121641,7 +121649,11 @@ async function runGooseWeb(apiKey, cwd, port) {
|
|
|
121641
121649
|
|
|
121642
121650
|
// src/agent/claude_code.ts
|
|
121643
121651
|
var import_child_process3 = require("child_process");
|
|
121644
|
-
async function runAgent2({
|
|
121652
|
+
async function runAgent2({
|
|
121653
|
+
prompt,
|
|
121654
|
+
apiKey,
|
|
121655
|
+
cwd
|
|
121656
|
+
}) {
|
|
121645
121657
|
if (!apiKey) {
|
|
121646
121658
|
throw new Error("Missing ANTHROPIC_API_KEY");
|
|
121647
121659
|
}
|
|
@@ -132876,6 +132888,7 @@ async function streamGooseToSSE(sessionId, prompt, apiKey, res, options) {
|
|
|
132876
132888
|
log("Streaming Goose to SSE", { sessionId, prompt, apiKey, resume });
|
|
132877
132889
|
createGooseConfig();
|
|
132878
132890
|
const textAccumulators = /* @__PURE__ */ new Map();
|
|
132891
|
+
let finishData = null;
|
|
132879
132892
|
try {
|
|
132880
132893
|
const result = streamText2({
|
|
132881
132894
|
model: goose("anthropic/claude-sonnet-4-5", {
|
|
@@ -132909,7 +132922,9 @@ async function streamGooseToSSE(sessionId, prompt, apiKey, res, options) {
|
|
|
132909
132922
|
id: completed.id,
|
|
132910
132923
|
text: completed.text,
|
|
132911
132924
|
timestamp: Date.now()
|
|
132912
|
-
}).catch(
|
|
132925
|
+
}).catch(
|
|
132926
|
+
(error87) => error("Error posting to webhook", error87)
|
|
132927
|
+
);
|
|
132913
132928
|
textAccumulators.delete(p.id);
|
|
132914
132929
|
}
|
|
132915
132930
|
break;
|
|
@@ -132921,7 +132936,9 @@ async function streamGooseToSSE(sessionId, prompt, apiKey, res, options) {
|
|
|
132921
132936
|
toolName: p.toolName,
|
|
132922
132937
|
input: p.input,
|
|
132923
132938
|
timestamp: Date.now()
|
|
132924
|
-
}).catch(
|
|
132939
|
+
}).catch(
|
|
132940
|
+
(error87) => error("Error posting to webhook", error87)
|
|
132941
|
+
);
|
|
132925
132942
|
break;
|
|
132926
132943
|
case "tool-result":
|
|
132927
132944
|
postToWebhook(options.webhookUrl, {
|
|
@@ -132931,7 +132948,15 @@ async function streamGooseToSSE(sessionId, prompt, apiKey, res, options) {
|
|
|
132931
132948
|
toolName: p.toolName,
|
|
132932
132949
|
output: truncateOutput(p.output),
|
|
132933
132950
|
timestamp: Date.now()
|
|
132934
|
-
}).catch(
|
|
132951
|
+
}).catch(
|
|
132952
|
+
(error87) => error("Error posting to webhook", error87)
|
|
132953
|
+
);
|
|
132954
|
+
break;
|
|
132955
|
+
case "finish":
|
|
132956
|
+
finishData = {
|
|
132957
|
+
finishReason: p.finishReason,
|
|
132958
|
+
totalUsage: p.totalUsage
|
|
132959
|
+
};
|
|
132935
132960
|
break;
|
|
132936
132961
|
}
|
|
132937
132962
|
}
|
|
@@ -132940,6 +132965,18 @@ async function streamGooseToSSE(sessionId, prompt, apiKey, res, options) {
|
|
|
132940
132965
|
error("Streaming error:", error87);
|
|
132941
132966
|
sendSSE(res, "error", { type: "error", error: error87.message });
|
|
132942
132967
|
} finally {
|
|
132968
|
+
if (options?.webhookUrl) {
|
|
132969
|
+
postToWebhook(options.webhookUrl, {
|
|
132970
|
+
sessionId,
|
|
132971
|
+
type: "finish",
|
|
132972
|
+
timestamp: Date.now(),
|
|
132973
|
+
...finishData || {}
|
|
132974
|
+
}).catch((error87) => error("Error posting to webhook", error87));
|
|
132975
|
+
}
|
|
132976
|
+
sendSSE(res, "done", {
|
|
132977
|
+
type: "done",
|
|
132978
|
+
...finishData || {}
|
|
132979
|
+
});
|
|
132943
132980
|
res.end();
|
|
132944
132981
|
}
|
|
132945
132982
|
}
|
|
@@ -133045,7 +133082,7 @@ var createAsyncAgentHandler = (getParams, transformResult) => {
|
|
|
133045
133082
|
return async (req, res) => {
|
|
133046
133083
|
const request_id = startReq();
|
|
133047
133084
|
try {
|
|
133048
|
-
const { repoName, apiKey, agent_name, session, summarize } = req.body;
|
|
133085
|
+
const { repoName, apiKey, agent_name, session, summarize, model } = req.body;
|
|
133049
133086
|
const params = getParams(req);
|
|
133050
133087
|
const workspaceRoot2 = await workspaceRoot();
|
|
133051
133088
|
let repoPath = workspaceRoot2;
|
|
@@ -133066,7 +133103,8 @@ var createAsyncAgentHandler = (getParams, transformResult) => {
|
|
|
133066
133103
|
cwd: repoPath,
|
|
133067
133104
|
system_prompt: params.system,
|
|
133068
133105
|
session,
|
|
133069
|
-
summarize: summarize ? true : false
|
|
133106
|
+
summarize: summarize ? true : false,
|
|
133107
|
+
model
|
|
133070
133108
|
}).then((result) => {
|
|
133071
133109
|
const finalResult = transformResult ? transformResult(result) : result;
|
|
133072
133110
|
finishReq(request_id, {
|
|
@@ -133560,9 +133598,7 @@ async function cleanupConfig(configState) {
|
|
|
133560
133598
|
try {
|
|
133561
133599
|
if (configState.wasCreated) {
|
|
133562
133600
|
await fs11.unlink(configState.configPath);
|
|
133563
|
-
log(
|
|
133564
|
-
`Cleaned up created config file: ${configState.configPath}`
|
|
133565
|
-
);
|
|
133601
|
+
log(`Cleaned up created config file: ${configState.configPath}`);
|
|
133566
133602
|
} else if (configState.wasModified && configState.originalContent) {
|
|
133567
133603
|
await fs11.writeFile(configState.configPath, configState.originalContent);
|
|
133568
133604
|
log(`Restored original config: ${configState.configPath}`);
|
|
@@ -134077,16 +134113,81 @@ Stderr: ${error87.stderr}`
|
|
|
134077
134113
|
};
|
|
134078
134114
|
|
|
134079
134115
|
// src/proxy/git_actions.ts
|
|
134080
|
-
async function
|
|
134116
|
+
async function handleBranchDiff(req, res) {
|
|
134081
134117
|
try {
|
|
134082
134118
|
const results = [];
|
|
134083
134119
|
const repos = await getReposMaybe();
|
|
134120
|
+
const baseBranch = req.query.base || "main";
|
|
134084
134121
|
for (const r of repos) {
|
|
134085
134122
|
const repo = await NewRepo(r);
|
|
134086
134123
|
const repoName = getRepoNameFromUrl(r);
|
|
134124
|
+
const currentBranch = (await repo.printCurrentBranch()).trim();
|
|
134125
|
+
if (currentBranch === baseBranch) {
|
|
134126
|
+
continue;
|
|
134127
|
+
}
|
|
134128
|
+
let mergeBase;
|
|
134129
|
+
try {
|
|
134130
|
+
mergeBase = (await repo.execCommand(`git merge-base ${baseBranch} HEAD`)).trim();
|
|
134131
|
+
} catch {
|
|
134132
|
+
try {
|
|
134133
|
+
mergeBase = (await repo.execCommand(`git merge-base origin/${baseBranch} HEAD`)).trim();
|
|
134134
|
+
} catch {
|
|
134135
|
+
warn(
|
|
134136
|
+
`Could not find merge base for ${repoName}, skipping...`
|
|
134137
|
+
);
|
|
134138
|
+
continue;
|
|
134139
|
+
}
|
|
134140
|
+
}
|
|
134087
134141
|
const diffOutput = await repo.execCommand(
|
|
134088
|
-
|
|
134142
|
+
`git diff --name-status ${mergeBase}`
|
|
134089
134143
|
);
|
|
134144
|
+
const lines = diffOutput.trim().split("\n").filter((line) => line);
|
|
134145
|
+
for (const line of lines) {
|
|
134146
|
+
const parts = line.split(" ");
|
|
134147
|
+
if (parts.length < 2) {
|
|
134148
|
+
continue;
|
|
134149
|
+
}
|
|
134150
|
+
const status = parts[0];
|
|
134151
|
+
const filePath = parts[1];
|
|
134152
|
+
let action;
|
|
134153
|
+
if (status.startsWith("A")) {
|
|
134154
|
+
action = "create";
|
|
134155
|
+
} else if (status.startsWith("D")) {
|
|
134156
|
+
action = "delete";
|
|
134157
|
+
} else {
|
|
134158
|
+
action = "modify";
|
|
134159
|
+
}
|
|
134160
|
+
let content = "";
|
|
134161
|
+
try {
|
|
134162
|
+
content = await repo.execCommand(
|
|
134163
|
+
`git diff ${mergeBase} -- "${filePath}"`
|
|
134164
|
+
);
|
|
134165
|
+
} catch (error87) {
|
|
134166
|
+
warn(`Error getting branch diff for ${filePath}:`, error87);
|
|
134167
|
+
}
|
|
134168
|
+
results.push({
|
|
134169
|
+
file: `${repoName}/${filePath}`,
|
|
134170
|
+
action,
|
|
134171
|
+
content,
|
|
134172
|
+
repoName,
|
|
134173
|
+
errors: []
|
|
134174
|
+
});
|
|
134175
|
+
}
|
|
134176
|
+
}
|
|
134177
|
+
res.status(200).json(results);
|
|
134178
|
+
} catch (error87) {
|
|
134179
|
+
error("Error fetching branch diff:", error87);
|
|
134180
|
+
fail(res, error87);
|
|
134181
|
+
}
|
|
134182
|
+
}
|
|
134183
|
+
async function handleDiff(_req, res) {
|
|
134184
|
+
try {
|
|
134185
|
+
const results = [];
|
|
134186
|
+
const repos = await getReposMaybe();
|
|
134187
|
+
for (const r of repos) {
|
|
134188
|
+
const repo = await NewRepo(r);
|
|
134189
|
+
const repoName = getRepoNameFromUrl(r);
|
|
134190
|
+
const diffOutput = await repo.execCommand("git diff --name-status HEAD");
|
|
134090
134191
|
const untrackedOutput = await repo.execCommand(
|
|
134091
134192
|
"git ls-files --others --exclude-standard"
|
|
134092
134193
|
);
|
|
@@ -134109,14 +134210,10 @@ async function handleDiff(_req, res) {
|
|
|
134109
134210
|
let content = "";
|
|
134110
134211
|
try {
|
|
134111
134212
|
if (action === "delete") {
|
|
134112
|
-
content = await repo.execCommand(
|
|
134113
|
-
`git diff HEAD -- "${filePath}"`
|
|
134114
|
-
);
|
|
134213
|
+
content = await repo.execCommand(`git diff HEAD -- "${filePath}"`);
|
|
134115
134214
|
} else {
|
|
134116
134215
|
log("Getting diff for", filePath);
|
|
134117
|
-
content = await repo.execCommand(
|
|
134118
|
-
`git diff HEAD -- "${filePath}"`
|
|
134119
|
-
);
|
|
134216
|
+
content = await repo.execCommand(`git diff HEAD -- "${filePath}"`);
|
|
134120
134217
|
}
|
|
134121
134218
|
} catch (error87) {
|
|
134122
134219
|
warn(`Error getting diff for ${filePath}:`, error87);
|
|
@@ -134340,10 +134437,7 @@ ${diff.trim()}`);
|
|
|
134340
134437
|
log(
|
|
134341
134438
|
`=> Waiting for CI checks to appear for PR #${prNumber}...`
|
|
134342
134439
|
);
|
|
134343
|
-
const hasChecks = await gh.waitForChecksToExist(
|
|
134344
|
-
prNumber,
|
|
134345
|
-
3e4
|
|
134346
|
-
);
|
|
134440
|
+
const hasChecks = await gh.waitForChecksToExist(prNumber, 3e4);
|
|
134347
134441
|
if (hasChecks) {
|
|
134348
134442
|
log(`=> Enabling auto-merge for PR #${prNumber}...`);
|
|
134349
134443
|
await gh.mergePR(prNumber, {
|
|
@@ -134664,41 +134758,65 @@ async function startProxyServer() {
|
|
|
134664
134758
|
app.use(updateLastHit);
|
|
134665
134759
|
app.post("/code", async (req, res) => {
|
|
134666
134760
|
log("===> POST code");
|
|
134667
|
-
await handleRequest(
|
|
134668
|
-
|
|
134669
|
-
|
|
134670
|
-
|
|
134671
|
-
|
|
134672
|
-
|
|
134673
|
-
|
|
134674
|
-
|
|
134675
|
-
|
|
134761
|
+
await handleRequest(
|
|
134762
|
+
req,
|
|
134763
|
+
res,
|
|
134764
|
+
"code",
|
|
134765
|
+
async (req2, res2) => {
|
|
134766
|
+
let restartAfter = req2.query.restart === "false" ? false : true;
|
|
134767
|
+
const code = req2.body;
|
|
134768
|
+
const result = await processCode(code);
|
|
134769
|
+
if (restartAfter) {
|
|
134770
|
+
await restartConfiguredProcesses();
|
|
134771
|
+
}
|
|
134772
|
+
res2.json({ success: true, result });
|
|
134773
|
+
},
|
|
134774
|
+
VSCODE_EXTENSION_URL
|
|
134775
|
+
);
|
|
134676
134776
|
});
|
|
134677
134777
|
app.post("/actions", async (req, res) => {
|
|
134678
134778
|
log("===> POST actions");
|
|
134679
|
-
await handleRequest(
|
|
134680
|
-
|
|
134681
|
-
|
|
134682
|
-
|
|
134683
|
-
|
|
134684
|
-
|
|
134685
|
-
|
|
134686
|
-
|
|
134687
|
-
|
|
134779
|
+
await handleRequest(
|
|
134780
|
+
req,
|
|
134781
|
+
res,
|
|
134782
|
+
"actions",
|
|
134783
|
+
async (req2, res2) => {
|
|
134784
|
+
let restartAfter = req2.query.restart === "false" ? false : true;
|
|
134785
|
+
const code = req2.body;
|
|
134786
|
+
const result = await processCode(code);
|
|
134787
|
+
if (restartAfter) {
|
|
134788
|
+
await restartConfiguredProcesses();
|
|
134789
|
+
}
|
|
134790
|
+
res2.json({ success: true, result });
|
|
134791
|
+
},
|
|
134792
|
+
VSCODE_EXTENSION_URL
|
|
134793
|
+
);
|
|
134688
134794
|
});
|
|
134689
134795
|
app.get("/rules", async (req, res) => {
|
|
134690
134796
|
log("===> GET rules");
|
|
134691
|
-
await handleRequest(
|
|
134692
|
-
|
|
134693
|
-
|
|
134694
|
-
|
|
134695
|
-
|
|
134797
|
+
await handleRequest(
|
|
134798
|
+
req,
|
|
134799
|
+
res,
|
|
134800
|
+
"rules",
|
|
134801
|
+
async (req2, res2) => {
|
|
134802
|
+
const root = await workspaceRoot();
|
|
134803
|
+
const rules = await gatherRulesFiles(root);
|
|
134804
|
+
res2.json(rules);
|
|
134805
|
+
},
|
|
134806
|
+
VSCODE_EXTENSION_URL
|
|
134807
|
+
);
|
|
134696
134808
|
});
|
|
134697
134809
|
app.get("/errors", async (req, res) => {
|
|
134698
134810
|
log("===> GET errors");
|
|
134699
|
-
await handleRequest(
|
|
134700
|
-
|
|
134701
|
-
|
|
134811
|
+
await handleRequest(
|
|
134812
|
+
req,
|
|
134813
|
+
res,
|
|
134814
|
+
"errors",
|
|
134815
|
+
async (req2, res2) => {
|
|
134816
|
+
res2.json({});
|
|
134817
|
+
},
|
|
134818
|
+
VSCODE_EXTENSION_URL
|
|
134819
|
+
);
|
|
134702
134820
|
});
|
|
134703
134821
|
app.get("/logs", async (req, res) => {
|
|
134704
134822
|
log("===> GET logs");
|
|
@@ -134749,6 +134867,10 @@ async function startProxyServer() {
|
|
|
134749
134867
|
log("===> GET diff");
|
|
134750
134868
|
await handleDiff(req, res);
|
|
134751
134869
|
});
|
|
134870
|
+
app.get("/branch-diff", async (req, res) => {
|
|
134871
|
+
log("===> GET branch-diff");
|
|
134872
|
+
await handleBranchDiff(req, res);
|
|
134873
|
+
});
|
|
134752
134874
|
app.post("/commit", async (req, res) => {
|
|
134753
134875
|
log(`===> POST /commit`);
|
|
134754
134876
|
await handleCommit(req, res);
|
package/dist/staklink-cli.cjs
CHANGED
|
@@ -10967,7 +10967,7 @@ var glob = Object.assign(glob_, {
|
|
|
10967
10967
|
glob.glob = glob;
|
|
10968
10968
|
|
|
10969
10969
|
// src/proxy/version.ts
|
|
10970
|
-
var VERSION = "0.3.
|
|
10970
|
+
var VERSION = "0.3.77";
|
|
10971
10971
|
|
|
10972
10972
|
// src/cli.ts
|
|
10973
10973
|
var STAKLINK_PROXY = "staklink-proxy";
|