@staff0rd/assist 0.552.0 → 0.554.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/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.552.0",
9
+ version: "0.554.0",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -11933,6 +11933,60 @@ async function revertDiffFile(req, res) {
11933
11933
  }
11934
11934
  }
11935
11935
 
11936
+ // src/commands/sessions/web/revertDiffPaths.ts
11937
+ import { relative as relative4 } from "path";
11938
+
11939
+ // src/commands/sessions/web/readJsonBody.ts
11940
+ async function readJsonBody(req) {
11941
+ const chunks = [];
11942
+ for await (const chunk of req) chunks.push(chunk);
11943
+ return JSON.parse(Buffer.concat(chunks).toString("utf8"));
11944
+ }
11945
+
11946
+ // src/commands/sessions/web/revertDiffPaths.ts
11947
+ function requestedPaths(body) {
11948
+ const paths = body.paths;
11949
+ if (!Array.isArray(paths)) return null;
11950
+ if (paths.some((path73) => typeof path73 !== "string")) return null;
11951
+ return paths;
11952
+ }
11953
+ async function revertDiffPaths(req, res) {
11954
+ const cwd = getCwdParam(req, res);
11955
+ if (!cwd) return;
11956
+ let paths;
11957
+ try {
11958
+ paths = requestedPaths(await readJsonBody(req));
11959
+ } catch {
11960
+ respondJson(res, 400, { error: "Invalid JSON body" });
11961
+ return;
11962
+ }
11963
+ if (!paths) {
11964
+ respondJson(res, 400, { error: "Missing paths" });
11965
+ return;
11966
+ }
11967
+ const root = repoRoot(cwd);
11968
+ const reverted = [];
11969
+ const failed2 = [];
11970
+ for (const path73 of paths) {
11971
+ const target = resolveWithinCwd(cwd, path73);
11972
+ if (!target) {
11973
+ failed2.push({ path: path73, error: "Path outside cwd" });
11974
+ continue;
11975
+ }
11976
+ const relativePath = relative4(root, target);
11977
+ try {
11978
+ await revertPathChanges(cwd, relativePath);
11979
+ reverted.push(relativePath);
11980
+ } catch (error) {
11981
+ failed2.push({
11982
+ path: relativePath,
11983
+ error: error instanceof Error ? error.message : "Failed to revert file"
11984
+ });
11985
+ }
11986
+ }
11987
+ respondJson(res, 200, { reverted, failed: failed2 });
11988
+ }
11989
+
11936
11990
  // src/commands/sessions/web/sessionLayout.ts
11937
11991
  function sessionLayout(_req, res) {
11938
11992
  const topBar = loadConfig().sessions?.topBar ?? true;
@@ -12292,13 +12346,6 @@ function isConfigWriteScope(value) {
12292
12346
  return value === "project" || value === "global" || value === "repo";
12293
12347
  }
12294
12348
 
12295
- // src/commands/sessions/web/readJsonBody.ts
12296
- async function readJsonBody(req) {
12297
- const chunks = [];
12298
- for await (const chunk of req) chunks.push(chunk);
12299
- return JSON.parse(Buffer.concat(chunks).toString("utf8"));
12300
- }
12301
-
12302
12349
  // src/commands/sessions/web/parseConfigWriteRequest.ts
12303
12350
  async function parseConfigWriteRequest(req) {
12304
12351
  let body;
@@ -12778,6 +12825,7 @@ var routes2 = {
12778
12825
  "GET /api/diff": diff2,
12779
12826
  "GET /api/diff-scopes": diffScopes,
12780
12827
  "POST /api/diff/revert": revertDiffFile,
12828
+ "POST /api/diff/revert-all": revertDiffPaths,
12781
12829
  "GET /api/file": fileContent,
12782
12830
  "POST /api/file": writeFileContent,
12783
12831
  "GET /api/files": listFiles,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.552.0",
3
+ "version": "0.554.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {