@staff0rd/assist 0.707.1 → 0.708.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/dist/commands/sessions/web/bundle.js +506 -506
- package/dist/index.js +109 -34
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { Command } from "commander";
|
|
|
6
6
|
// package.json
|
|
7
7
|
var package_default = {
|
|
8
8
|
name: "@staff0rd/assist",
|
|
9
|
-
version: "0.
|
|
9
|
+
version: "0.708.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -10702,24 +10702,8 @@ function originForCwd(cwd) {
|
|
|
10702
10702
|
|
|
10703
10703
|
// src/commands/sessions/daemon/repoDirExists.ts
|
|
10704
10704
|
import { existsSync as existsSync31 } from "fs";
|
|
10705
|
-
|
|
10706
|
-
// src/commands/sessions/web/windowsCwdToWslPath.ts
|
|
10707
|
-
function windowsCwdToWslPath(cwd) {
|
|
10708
|
-
const match = /^([A-Za-z]):[\\/](.*)$/.exec(cwd);
|
|
10709
|
-
if (!match) return cwd;
|
|
10710
|
-
const drive = match[1].toLowerCase();
|
|
10711
|
-
const rest = match[2].replace(/\\/g, "/");
|
|
10712
|
-
return `/mnt/${drive}/${rest}`;
|
|
10713
|
-
}
|
|
10714
|
-
|
|
10715
|
-
// src/commands/sessions/web/toGitCwd.ts
|
|
10716
|
-
function toGitCwd(cwd) {
|
|
10717
|
-
return detectPlatform() === "wsl" ? windowsCwdToWslPath(cwd) : cwd;
|
|
10718
|
-
}
|
|
10719
|
-
|
|
10720
|
-
// src/commands/sessions/daemon/repoDirExists.ts
|
|
10721
10705
|
function repoDirExists(cwd) {
|
|
10722
|
-
return existsSync31(
|
|
10706
|
+
return existsSync31(cwd);
|
|
10723
10707
|
}
|
|
10724
10708
|
|
|
10725
10709
|
// src/commands/sessions/daemon/worktree/git.ts
|
|
@@ -11168,6 +11152,19 @@ async function getBacklogSummary(req, res) {
|
|
|
11168
11152
|
respondJson(res, 200, await loadRepoSummaries(currentOrigin, allCwds));
|
|
11169
11153
|
}
|
|
11170
11154
|
|
|
11155
|
+
// src/commands/backlog/web/getRepoLocation.ts
|
|
11156
|
+
function getRepoLocation(req, res) {
|
|
11157
|
+
const origin = new URL(req.url ?? "/", "http://localhost").searchParams.get(
|
|
11158
|
+
"origin"
|
|
11159
|
+
);
|
|
11160
|
+
if (!origin) {
|
|
11161
|
+
respondJson(res, 400, { error: "Missing origin" });
|
|
11162
|
+
return;
|
|
11163
|
+
}
|
|
11164
|
+
const baseDir = expandTilde2(loadConfig().clone.baseDir);
|
|
11165
|
+
respondJson(res, 200, resolveRepoLocation(origin, void 0, baseDir));
|
|
11166
|
+
}
|
|
11167
|
+
|
|
11171
11168
|
// src/commands/backlog/web/applyCwdFromReq.ts
|
|
11172
11169
|
function applyCwdFromReq(req) {
|
|
11173
11170
|
const url = new URL(req.url ?? "/", "http://localhost");
|
|
@@ -11497,7 +11494,7 @@ var ORIGIN_REF_PREFIX = "refs/remotes/origin/";
|
|
|
11497
11494
|
var FALLBACK_BRANCHES = ["main", "master"];
|
|
11498
11495
|
function configuredDefaultBranch(cwd) {
|
|
11499
11496
|
try {
|
|
11500
|
-
return loadConfigFrom(
|
|
11497
|
+
return loadConfigFrom(cwd).branch?.defaultBranch;
|
|
11501
11498
|
} catch {
|
|
11502
11499
|
return void 0;
|
|
11503
11500
|
}
|
|
@@ -11550,7 +11547,7 @@ async function branchDiffBase(cwd) {
|
|
|
11550
11547
|
// src/commands/sessions/web/includesCommittedChanges.ts
|
|
11551
11548
|
function includesCommittedChanges(cwd) {
|
|
11552
11549
|
try {
|
|
11553
|
-
return loadConfigFrom(
|
|
11550
|
+
return loadConfigFrom(cwd).sessions?.includeCommittedChanges ?? true;
|
|
11554
11551
|
} catch {
|
|
11555
11552
|
return true;
|
|
11556
11553
|
}
|
|
@@ -11824,7 +11821,7 @@ import { readFile as readFile2, stat as stat2 } from "fs/promises";
|
|
|
11824
11821
|
// src/commands/sessions/web/resolveWithinCwd.ts
|
|
11825
11822
|
import { isAbsolute as isAbsolute2, relative as relative2, resolve as resolve10 } from "path";
|
|
11826
11823
|
function repoRoot(cwd) {
|
|
11827
|
-
return resolve10(
|
|
11824
|
+
return resolve10(cwd);
|
|
11828
11825
|
}
|
|
11829
11826
|
function resolveWithinCwd(cwd, path103) {
|
|
11830
11827
|
const root2 = repoRoot(cwd);
|
|
@@ -13008,7 +13005,7 @@ function getConfig(req, res) {
|
|
|
13008
13005
|
const cwd = getCwdParam(req, res);
|
|
13009
13006
|
if (!cwd) return;
|
|
13010
13007
|
try {
|
|
13011
|
-
respondJson(res, 200, readConfigEntries(
|
|
13008
|
+
respondJson(res, 200, readConfigEntries(cwd));
|
|
13012
13009
|
} catch (error) {
|
|
13013
13010
|
respondJson(res, 500, {
|
|
13014
13011
|
error: error instanceof Error ? error.message : "Failed to read config"
|
|
@@ -13049,9 +13046,8 @@ function getHtml() {
|
|
|
13049
13046
|
}
|
|
13050
13047
|
|
|
13051
13048
|
// src/commands/sessions/web/handleServerRuns.ts
|
|
13052
|
-
function getServerRuns(
|
|
13049
|
+
function getServerRuns(cwd) {
|
|
13053
13050
|
try {
|
|
13054
|
-
const cwd = toGitCwd(rawCwd);
|
|
13055
13051
|
const { run: run4 } = loadConfigFrom(cwd);
|
|
13056
13052
|
return resolveRunConfigs(run4, runConfigBaseDirFrom(cwd)).filter((r) => r.server).map((r) => ({ name: r.name, port: r.port }));
|
|
13057
13053
|
} catch {
|
|
@@ -13089,7 +13085,7 @@ function runGit2(cwd, args) {
|
|
|
13089
13085
|
return execFileAsync3("git", args, {
|
|
13090
13086
|
encoding: "utf8",
|
|
13091
13087
|
windowsHide: true,
|
|
13092
|
-
cwd
|
|
13088
|
+
cwd
|
|
13093
13089
|
}).then((r) => r.stdout.trim());
|
|
13094
13090
|
}
|
|
13095
13091
|
async function resolveSynthesisPath(cwd) {
|
|
@@ -13124,7 +13120,7 @@ async function getReviewSynthesis(req, res) {
|
|
|
13124
13120
|
function githubUrl(req, res) {
|
|
13125
13121
|
const cwd = getCwdParam(req, res);
|
|
13126
13122
|
if (!cwd) return;
|
|
13127
|
-
const repo = getPreferredRemoteRepo(
|
|
13123
|
+
const repo = getPreferredRemoteRepo(cwd);
|
|
13128
13124
|
respondJson(res, 200, {
|
|
13129
13125
|
url: repo ? `https://github.com/${repo.org}/${repo.repo}` : null
|
|
13130
13126
|
});
|
|
@@ -13944,7 +13940,7 @@ function createCachedGhJson(args, parse5, fallback, options2 = {}) {
|
|
|
13944
13940
|
const { stdout } = await execFileAsync4("gh", [...args, ...extraArgs], {
|
|
13945
13941
|
encoding: "utf8",
|
|
13946
13942
|
windowsHide: true,
|
|
13947
|
-
cwd
|
|
13943
|
+
cwd
|
|
13948
13944
|
});
|
|
13949
13945
|
value = parse5(stdout);
|
|
13950
13946
|
} catch {
|
|
@@ -13985,6 +13981,83 @@ async function prList(req, res) {
|
|
|
13985
13981
|
respondJson(res, 200, { prs: await getOpenPrs(cwd) });
|
|
13986
13982
|
}
|
|
13987
13983
|
|
|
13984
|
+
// src/commands/sessions/web/forwardToPeer.ts
|
|
13985
|
+
import {
|
|
13986
|
+
request as httpRequest
|
|
13987
|
+
} from "http";
|
|
13988
|
+
import { request as httpsRequest } from "https";
|
|
13989
|
+
var LINKED_FROM_HEADER = "x-assist-linked-from";
|
|
13990
|
+
function forwardToPeer(req, res, node, url) {
|
|
13991
|
+
const started = Date.now();
|
|
13992
|
+
const label2 = `link ${node} http: ${req.method} ${url.pathname}`;
|
|
13993
|
+
const elapsed = () => `${Date.now() - started}ms`;
|
|
13994
|
+
const send = url.protocol === "https:" ? httpsRequest : httpRequest;
|
|
13995
|
+
return new Promise((resolve25) => {
|
|
13996
|
+
const upstream = send(
|
|
13997
|
+
url,
|
|
13998
|
+
{
|
|
13999
|
+
method: req.method,
|
|
14000
|
+
headers: {
|
|
14001
|
+
...req.headers,
|
|
14002
|
+
host: url.host,
|
|
14003
|
+
[LINKED_FROM_HEADER]: resolveNodeName()
|
|
14004
|
+
}
|
|
14005
|
+
},
|
|
14006
|
+
(peer) => {
|
|
14007
|
+
console.log(`${label2} -> ${peer.statusCode} (${elapsed()})`);
|
|
14008
|
+
res.writeHead(peer.statusCode ?? 502, peer.headers);
|
|
14009
|
+
peer.pipe(res);
|
|
14010
|
+
peer.on("end", resolve25);
|
|
14011
|
+
peer.on("error", () => resolve25());
|
|
14012
|
+
}
|
|
14013
|
+
);
|
|
14014
|
+
upstream.on("error", (error) => {
|
|
14015
|
+
console.log(`${label2} -> failed: ${error.message} (${elapsed()})`);
|
|
14016
|
+
if (res.headersSent) res.destroy();
|
|
14017
|
+
else
|
|
14018
|
+
respondJson(res, 502, {
|
|
14019
|
+
error: `${node} unreachable: ${error.message}`
|
|
14020
|
+
});
|
|
14021
|
+
resolve25();
|
|
14022
|
+
});
|
|
14023
|
+
req.pipe(upstream);
|
|
14024
|
+
});
|
|
14025
|
+
}
|
|
14026
|
+
|
|
14027
|
+
// src/commands/sessions/web/proxyToNode.ts
|
|
14028
|
+
var LINKED_FROM_HEADER2 = "x-assist-linked-from";
|
|
14029
|
+
function arrivedOverLink(req) {
|
|
14030
|
+
return Boolean(req.headers[LINKED_FROM_HEADER2]);
|
|
14031
|
+
}
|
|
14032
|
+
function proxyTarget(req) {
|
|
14033
|
+
const url = new URL(req.url ?? "/", "http://localhost");
|
|
14034
|
+
const node = url.searchParams.get("node");
|
|
14035
|
+
if (!url.pathname.startsWith("/api/") || !node) return { kind: "local" };
|
|
14036
|
+
if (arrivedOverLink(req) || node === resolveNodeName())
|
|
14037
|
+
return { kind: "local" };
|
|
14038
|
+
const link3 = loadConfig().sessions?.links?.find((l) => l.name === node);
|
|
14039
|
+
if (!link3) return { kind: "unknown", node };
|
|
14040
|
+
url.searchParams.delete("node");
|
|
14041
|
+
return {
|
|
14042
|
+
kind: "link",
|
|
14043
|
+
node,
|
|
14044
|
+
url: new URL(`${url.pathname}${url.search}`, link3.url)
|
|
14045
|
+
};
|
|
14046
|
+
}
|
|
14047
|
+
async function proxyToNode(req, res) {
|
|
14048
|
+
const target = proxyTarget(req);
|
|
14049
|
+
if (target.kind === "local") return false;
|
|
14050
|
+
if (target.kind === "unknown") {
|
|
14051
|
+
console.log(
|
|
14052
|
+
`link ${target.node} http: ${req.method} ${req.url} -> no such link`
|
|
14053
|
+
);
|
|
14054
|
+
respondJson(res, 404, { error: `No link to node ${target.node}` });
|
|
14055
|
+
return true;
|
|
14056
|
+
}
|
|
14057
|
+
await forwardToPeer(req, res, target.node, target.url);
|
|
14058
|
+
return true;
|
|
14059
|
+
}
|
|
14060
|
+
|
|
13988
14061
|
// src/commands/sessions/web/ghAuthToken.ts
|
|
13989
14062
|
import { execFile as execFile6 } from "child_process";
|
|
13990
14063
|
import { promisify as promisify6 } from "util";
|
|
@@ -14075,7 +14148,7 @@ async function getCurrentBranch(cwd) {
|
|
|
14075
14148
|
const { stdout } = await execFileAsync6(
|
|
14076
14149
|
"git",
|
|
14077
14150
|
["rev-parse", "--abbrev-ref", "HEAD"],
|
|
14078
|
-
{ encoding: "utf8", windowsHide: true, cwd
|
|
14151
|
+
{ encoding: "utf8", windowsHide: true, cwd }
|
|
14079
14152
|
);
|
|
14080
14153
|
const branch2 = stdout.trim();
|
|
14081
14154
|
return branch2 && branch2 !== "HEAD" ? branch2 : void 0;
|
|
@@ -14109,7 +14182,7 @@ function releasesConfigured(req, res) {
|
|
|
14109
14182
|
const cwd = getCwdParam(req, res);
|
|
14110
14183
|
if (!cwd) return;
|
|
14111
14184
|
try {
|
|
14112
|
-
const streams = loadConfigFrom(
|
|
14185
|
+
const streams = loadConfigFrom(cwd).releases?.streams ?? [];
|
|
14113
14186
|
respondJson(res, 200, { configured: streams.length > 0 });
|
|
14114
14187
|
} catch (error) {
|
|
14115
14188
|
respondJson(res, 500, {
|
|
@@ -14160,7 +14233,7 @@ async function runGh(cwd, args) {
|
|
|
14160
14233
|
const { stdout } = await execFileAsync7("gh", args, {
|
|
14161
14234
|
encoding: "utf8",
|
|
14162
14235
|
windowsHide: true,
|
|
14163
|
-
cwd
|
|
14236
|
+
cwd,
|
|
14164
14237
|
maxBuffer: 16 * 1024 * 1024
|
|
14165
14238
|
});
|
|
14166
14239
|
return JSON.parse(stdout);
|
|
@@ -14517,7 +14590,7 @@ async function releasesState(req, res) {
|
|
|
14517
14590
|
if (!cwd) return;
|
|
14518
14591
|
let streams;
|
|
14519
14592
|
try {
|
|
14520
|
-
streams = loadConfigFrom(
|
|
14593
|
+
streams = loadConfigFrom(cwd).releases?.streams ?? [];
|
|
14521
14594
|
} catch (error) {
|
|
14522
14595
|
respondJson(res, 500, {
|
|
14523
14596
|
error: error instanceof Error ? error.message : "Failed to read config"
|
|
@@ -15222,7 +15295,7 @@ async function handleConfigWrite(req, res, apply) {
|
|
|
15222
15295
|
return;
|
|
15223
15296
|
}
|
|
15224
15297
|
try {
|
|
15225
|
-
const result = apply(
|
|
15298
|
+
const result = apply(parsed);
|
|
15226
15299
|
if (!result.ok) {
|
|
15227
15300
|
respondJson(res, 400, {
|
|
15228
15301
|
error: result.errors.join("\n"),
|
|
@@ -15707,6 +15780,7 @@ var routes2 = {
|
|
|
15707
15780
|
"GET /api/health": health,
|
|
15708
15781
|
"GET /api/items": listItems,
|
|
15709
15782
|
"GET /api/backlog/summary": getBacklogSummary,
|
|
15783
|
+
"GET /api/repo-location": getRepoLocation,
|
|
15710
15784
|
"POST /api/open-in-code": openInCode,
|
|
15711
15785
|
"POST /api/pr-preview/upload-image": uploadPrImage,
|
|
15712
15786
|
"GET /api/pr-preview/image": previewImage,
|
|
@@ -15745,7 +15819,7 @@ var routes2 = {
|
|
|
15745
15819
|
var handleRequest = createFallbackHandler(
|
|
15746
15820
|
routes2,
|
|
15747
15821
|
htmlHandler,
|
|
15748
|
-
handleItemRoute
|
|
15822
|
+
async (req, res, pathname) => await proxyToNode(req, res) || handleItemRoute(req, res, pathname)
|
|
15749
15823
|
);
|
|
15750
15824
|
|
|
15751
15825
|
// src/commands/sessions/web/restartMenu/installRestartMenu.ts
|
|
@@ -29665,7 +29739,7 @@ async function statusLine() {
|
|
|
29665
29739
|
const { total_input_tokens: totalIn, total_output_tokens: totalOut } = data.context_window;
|
|
29666
29740
|
const usedPct = data.context_window.used_percentage ?? 0;
|
|
29667
29741
|
const dir = data.workspace?.current_dir ?? data.cwd;
|
|
29668
|
-
const branch2 = dir ? readGitBranch(
|
|
29742
|
+
const branch2 = dir ? readGitBranch(dir) : null;
|
|
29669
29743
|
const branchSegment = branch2 ? `\u{1F33F}\uFE0F ${chalk205.cyan(branch2)} | ` : "";
|
|
29670
29744
|
console.log(
|
|
29671
29745
|
`${branchSegment}${model} | Tokens - ${formatNumber(totalIn)} \u2191 : ${formatNumber(totalOut)} \u2193 | Context - ${colorizePercent(usedPct)}${buildLimitsSegment(data.rate_limits)}`
|
|
@@ -43783,6 +43857,7 @@ function relayRunConflict(state, msg) {
|
|
|
43783
43857
|
const namespaced = {
|
|
43784
43858
|
...msg,
|
|
43785
43859
|
sessionId: ns(msg.sessionId),
|
|
43860
|
+
launchedFrom: ns(msg.launchedFrom),
|
|
43786
43861
|
existing: existing && { ...existing, id: ns(existing.id) },
|
|
43787
43862
|
node: state.node
|
|
43788
43863
|
};
|