@staff0rd/assist 0.531.0 → 0.533.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.531.0",
9
+ version: "0.533.0",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -11433,6 +11433,49 @@ async function restartWeb(req, res, deps2 = {}) {
11433
11433
  }
11434
11434
  }
11435
11435
 
11436
+ // src/commands/sessions/web/revertDiffFile.ts
11437
+ import { relative as relative3 } from "path";
11438
+
11439
+ // src/commands/sessions/web/revertPathChanges.ts
11440
+ async function isTracked(cwd, path71) {
11441
+ try {
11442
+ await execGit(cwd, ["ls-files", "--error-unmatch", "--", path71]);
11443
+ return true;
11444
+ } catch {
11445
+ return false;
11446
+ }
11447
+ }
11448
+ async function isInHead(cwd, path71) {
11449
+ const listing = await execGit(cwd, ["ls-tree", "HEAD", "--", path71]);
11450
+ return listing.trim().length > 0;
11451
+ }
11452
+ async function revertPathChanges(cwd, path71) {
11453
+ if (!await isTracked(cwd, path71)) {
11454
+ await execGit(cwd, ["clean", "-f", "--", path71]);
11455
+ return;
11456
+ }
11457
+ if (await isInHead(cwd, path71)) {
11458
+ await execGit(cwd, ["checkout", "HEAD", "--", path71]);
11459
+ return;
11460
+ }
11461
+ await execGit(cwd, ["rm", "-f", "--", path71]);
11462
+ }
11463
+
11464
+ // src/commands/sessions/web/revertDiffFile.ts
11465
+ async function revertDiffFile(req, res) {
11466
+ const resolved = getFileTarget(req, res);
11467
+ if (!resolved) return;
11468
+ const path71 = relative3(repoRoot(resolved.cwd), resolved.target);
11469
+ try {
11470
+ await revertPathChanges(resolved.cwd, path71);
11471
+ respondJson(res, 200, { reverted: path71 });
11472
+ } catch (error) {
11473
+ respondJson(res, 500, {
11474
+ error: error instanceof Error ? error.message : "Failed to revert file"
11475
+ });
11476
+ }
11477
+ }
11478
+
11436
11479
  // src/commands/sessions/web/sessionLayout.ts
11437
11480
  function sessionLayout(_req, res) {
11438
11481
  const topBar = loadConfig().sessions?.topBar ?? true;
@@ -12277,6 +12320,7 @@ var routes2 = {
12277
12320
  "GET /api/git-status": gitStatus,
12278
12321
  "GET /api/diff": diff2,
12279
12322
  "GET /api/diff-scopes": diffScopes,
12323
+ "POST /api/diff/revert": revertDiffFile,
12280
12324
  "GET /api/file": fileContent,
12281
12325
  "POST /api/file": writeFileContent,
12282
12326
  "GET /api/files": listFiles,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.531.0",
3
+ "version": "0.533.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {