@staff0rd/assist 0.707.1 → 0.708.1

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