@staff0rd/assist 0.1186.0 → 0.1187.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.
Files changed (26) hide show
  1. package/agent/commands/github.md +2 -1
  2. package/dist/.build-files +19 -20
  3. package/dist/built-version +1 -1
  4. package/dist/{chunk-ZDCNWRGU.js → chunk-7GGVRB3G.js} +1 -1
  5. package/dist/{chunk-WG3TXZMV.js → chunk-DPCFT55U.js} +16 -6
  6. package/dist/{chunk-7XBRJ63U.js → chunk-GIFMD6SW.js} +5 -7
  7. package/dist/{chunk-ZYOSEPXM.js → chunk-GYM3LVZT.js} +1 -1
  8. package/dist/{chunk-HJA2C6EP.js → chunk-ODH4PKV4.js} +1 -1
  9. package/dist/{chunk-2TFVO6FJ.js → chunk-PEOCY7Q3.js} +1 -1
  10. package/dist/{chunk-MJ4RLQ5N.js → chunk-Q4TGGE5L.js} +0 -63
  11. package/dist/{chunk-WH3YSTWQ.js → chunk-XNN2K4S3.js} +1 -1
  12. package/dist/{chunk-ONODYZ2H.js → chunk-YDSX6BYY.js} +65 -4
  13. package/dist/commands/sessions/web/bundle.js +1 -1
  14. package/dist/{createIssue-5KNMMJVA.js → createIssue-ZFRBIC7A.js} +42 -35
  15. package/dist/{doctorNodes-ZDTNLDHK.js → doctorNodes-Y5L32TWX.js} +3 -3
  16. package/dist/{edit-5QLQ3TLJ.js → edit-2ZO7TOPW.js} +6 -7
  17. package/dist/index.js +33 -28
  18. package/dist/{raise-O7DVXVP6.js → raise-WQ2WINT4.js} +6 -7
  19. package/dist/{restartNode-ZM73BIZ4.js → restartNode-CAPDQK23.js} +5 -5
  20. package/dist/{runDaemon-QU6S6FVH.js → runDaemon-GHG5TRPX.js} +2 -2
  21. package/dist/{signExtension-VSB6MSLB.js → signExtension-GQXLL6CC.js} +1 -1
  22. package/dist/{updateNode-SRU5E3O3.js → updateNode-RMHEOL4X.js} +5 -5
  23. package/dist/{web-RXI5PSBM.js → web-3NKRW2FS.js} +6 -7
  24. package/dist/{web-GRLY54Q4.js → web-IE3MFOE5.js} +6 -7
  25. package/package.json +1 -1
  26. package/dist/chunk-S6FVZYHH.js +0 -16
@@ -83,13 +83,14 @@ Create a new issue from a free-form request (e.g. `create bug against owner/repo
83
83
 
84
84
  - **Milestone** — the milestone's title, passed as named; the command matches it against the repo's open milestones.
85
85
  - **Type** and **parent** — only if the request names them.
86
+ - **Screenshots** — when you already have an image or video to include (e.g. a file the user pointed at on disk), pass it with `--screenshot '[Group/]Caption=path'`, once per file, rather than asking the user to drop it into the preview. It is attached under `## Screenshots` for you.
86
87
 
87
88
  If a named project, label or milestone doesn't match, list the available ones and ask the user which they meant (or whether to drop it). Never guess a near match or silently omit it. For a milestone, check `gh api repos/<owner>/<repo>/milestones --jq '.[].title'` before running, or relay the list the command prints when it rejects the name.
88
89
 
89
90
  Then run the command bare, as a background task, and do no other work until it returns — in a web session it blocks on the preview pane until the user approves or rejects:
90
91
 
91
92
  ```
92
- assist github issue create -R <owner>/<repo> --title "<title>" --body "<body>" [--label <name>]... [--project <number>] [--status <name>] [--milestone <name>] [--type <name>] [--parent <issue>] 2>&1
93
+ assist github issue create -R <owner>/<repo> --title "<title>" --body "<body>" [--label <name>]... [--project <number>] [--status <name>] [--milestone <name>] [--type <name>] [--parent <issue>] [--screenshot '[Group/]Caption=path']... 2>&1
93
94
  ```
94
95
 
95
96
  Every option is resolved before the preview, so an unknown name creates nothing. Relay the outcome:
package/dist/.build-files CHANGED
@@ -39,7 +39,6 @@ chunk-2KG6ZPX4.js
39
39
  chunk-2MG2THMQ.js
40
40
  chunk-2RUGZQUD.js
41
41
  chunk-2RYBRXTJ.js
42
- chunk-2TFVO6FJ.js
43
42
  chunk-3HNTLFII.js
44
43
  chunk-3JXMQFUS.js
45
44
  chunk-3KLTYFPV.js
@@ -82,6 +81,7 @@ chunk-6VCFPUNV.js
82
81
  chunk-6Z7XJJNZ.js
83
82
  chunk-7DSWCPDZ.js
84
83
  chunk-7F22C6MC.js
84
+ chunk-7GGVRB3G.js
85
85
  chunk-7HNRCA3N.js
86
86
  chunk-7KDF6H4R.js
87
87
  chunk-7KVL2L7Z.js
@@ -89,7 +89,6 @@ chunk-7NPZZRMK.js
89
89
  chunk-7NZOH4LN.js
90
90
  chunk-7SMQSAXT.js
91
91
  chunk-7TAUUXVY.js
92
- chunk-7XBRJ63U.js
93
92
  chunk-A2XSU5K6.js
94
93
  chunk-A7ONLVZD.js
95
94
  chunk-ABLDOQ4B.js
@@ -132,6 +131,7 @@ chunk-D7UZLH36.js
132
131
  chunk-DGQ7KOW4.js
133
132
  chunk-DIAC4XYA.js
134
133
  chunk-DISNKALJ.js
134
+ chunk-DPCFT55U.js
135
135
  chunk-DS2YJZZY.js
136
136
  chunk-DUNO7WBT.js
137
137
  chunk-DZBGDSCK.js
@@ -163,6 +163,7 @@ chunk-FYYZG4GY.js
163
163
  chunk-FZDQG67V.js
164
164
  chunk-G3CJH2XK.js
165
165
  chunk-G3ROBZ4I.js
166
+ chunk-GIFMD6SW.js
166
167
  chunk-GIHVMELY.js
167
168
  chunk-GL5GKF5A.js
168
169
  chunk-GNNMJOUE.js
@@ -170,6 +171,7 @@ chunk-GQF23TWI.js
170
171
  chunk-GRXFWFGP.js
171
172
  chunk-GVI4JSG7.js
172
173
  chunk-GVVK5XFZ.js
174
+ chunk-GYM3LVZT.js
173
175
  chunk-H2KHIEQF.js
174
176
  chunk-H63MI5HI.js
175
177
  chunk-H7EUPSJB.js
@@ -177,7 +179,6 @@ chunk-HCANRBFK.js
177
179
  chunk-HCYTW3DN.js
178
180
  chunk-HI6T3DND.js
179
181
  chunk-HIOA4WIF.js
180
- chunk-HJA2C6EP.js
181
182
  chunk-HKGCLAZ7.js
182
183
  chunk-HN7MFXZ7.js
183
184
  chunk-HPV2ZVOX.js
@@ -234,7 +235,6 @@ chunk-M3O2BTJG.js
234
235
  chunk-M6MAQU3Z.js
235
236
  chunk-MFTQLD5M.js
236
237
  chunk-MJ44T7R4.js
237
- chunk-MJ4RLQ5N.js
238
238
  chunk-MJLABLH5.js
239
239
  chunk-MRUIXQXS.js
240
240
  chunk-MT2LAO3P.js
@@ -256,9 +256,9 @@ chunk-NZYSENRR.js
256
256
  chunk-O3SCSMQJ.js
257
257
  chunk-O6HFT23O.js
258
258
  chunk-O6RBWPG2.js
259
+ chunk-ODH4PKV4.js
259
260
  chunk-ODLSWRTS.js
260
261
  chunk-OLE7XSNB.js
261
- chunk-ONODYZ2H.js
262
262
  chunk-OQ6AYXHB.js
263
263
  chunk-ORSRBZ2X.js
264
264
  chunk-OU6Q5ZS3.js
@@ -271,10 +271,12 @@ chunk-P56S7RYB.js
271
271
  chunk-P7FVAGFQ.js
272
272
  chunk-PB3F4XB3.js
273
273
  chunk-PDXOHW2M.js
274
+ chunk-PEOCY7Q3.js
274
275
  chunk-PIDKNOD6.js
275
276
  chunk-PNDUTAZR.js
276
277
  chunk-PURNABFX.js
277
278
  chunk-PZAEU7LL.js
279
+ chunk-Q4TGGE5L.js
278
280
  chunk-Q6PZLPK4.js
279
281
  chunk-Q7YVMIA3.js
280
282
  chunk-QAJUCN3A.js
@@ -300,7 +302,6 @@ chunk-RWVRH774.js
300
302
  chunk-RXFNQQZC.js
301
303
  chunk-RXKI4XAU.js
302
304
  chunk-RZBCBCNG.js
303
- chunk-S6FVZYHH.js
304
305
  chunk-S6XYTJU2.js
305
306
  chunk-SDMBTSYP.js
306
307
  chunk-SHWMHL7S.js
@@ -349,9 +350,7 @@ chunk-W5FPQALS.js
349
350
  chunk-W6UBSIJA.js
350
351
  chunk-W7TRZLEM.js
351
352
  chunk-WDODIKZ4.js
352
- chunk-WG3TXZMV.js
353
353
  chunk-WGDN4CNI.js
354
- chunk-WH3YSTWQ.js
355
354
  chunk-WOGUXGZS.js
356
355
  chunk-WTONCI74.js
357
356
  chunk-WUMARDUD.js
@@ -366,6 +365,7 @@ chunk-XDIVXGPQ.js
366
365
  chunk-XEJODD6D.js
367
366
  chunk-XJTXAL22.js
368
367
  chunk-XNCJ3OIJ.js
368
+ chunk-XNN2K4S3.js
369
369
  chunk-XSJGIJEE.js
370
370
  chunk-XT3AOF2P.js
371
371
  chunk-XTPBXBZA.js
@@ -379,6 +379,7 @@ chunk-XZT5S5IY.js
379
379
  chunk-Y3R4C2P7.js
380
380
  chunk-YCFOCDUA.js
381
381
  chunk-YDA62L6J.js
382
+ chunk-YDSX6BYY.js
382
383
  chunk-YHJHYOBF.js
383
384
  chunk-YIBSK5OC.js
384
385
  chunk-YJ72SXVD.js
@@ -400,7 +401,6 @@ chunk-Z2R2O27D.js
400
401
  chunk-Z2YQQYCQ.js
401
402
  chunk-Z64YKE5O.js
402
403
  chunk-ZABRGL2F.js
403
- chunk-ZDCNWRGU.js
404
404
  chunk-ZDSSSQZZ.js
405
405
  chunk-ZDWZ2VI3.js
406
406
  chunk-ZFX4EZMW.js
@@ -411,7 +411,6 @@ chunk-ZMW2VHAF.js
411
411
  chunk-ZN5LRXXN.js
412
412
  chunk-ZSHH4XS6.js
413
413
  chunk-ZYK7V4PG.js
414
- chunk-ZYOSEPXM.js
415
414
  chunk-ZZVYRC77.js
416
415
  clean-N5ZBCTOB.js
417
416
  cliHook-2K2PQZOJ.js
@@ -464,7 +463,7 @@ configSet-NMSZ27OX.js
464
463
  configUnset-IINMDUOO.js
465
464
  configure-M2ECXTUT.js
466
465
  coverage-G7J25BUX.js
467
- createIssue-5KNMMJVA.js
466
+ createIssue-ZFRBIC7A.js
468
467
  cyclomatic-CYUIP7H3.js
469
468
  daemonStatus-EAZHBC6O.js
470
469
  del-6CB5KFFD.js
@@ -476,11 +475,11 @@ deps-RSUOIZPE.js
476
475
  docsConfirm-AQGXUXUM.js
477
476
  docsScreenshots-VV5F5SK5.js
478
477
  docsUnlock-27IXZHHP.js
479
- doctorNodes-ZDTNLDHK.js
478
+ doctorNodes-Y5L32TWX.js
480
479
  done-3VAD7V2R.js
481
480
  drainDaemon-ZHP2VY7D.js
482
481
  dropRetiredTables-JBLALSG5.js
483
- edit-5QLQ3TLJ.js
482
+ edit-2ZO7TOPW.js
484
483
  editHook-S6MCRMW4.js
485
484
  editIssue-MPKFMOLQ.js
486
485
  editIssueComment-3E3SBBJE.js
@@ -556,7 +555,7 @@ prs-2SRUKVTI.js
556
555
  prsSlackChannel-QGXDVDOM.js
557
556
  prsStatus-6G3ZTK36.js
558
557
  pullIfConfigured-ATTGJC3C.js
559
- raise-O7DVXVP6.js
558
+ raise-WQ2WINT4.js
560
559
  raiseHelpText-IDZI3UAC.js
561
560
  ravendbAuth-QCLMPEJ3.js
562
561
  ravendbCollections-L4H5PMFE.js
@@ -583,7 +582,7 @@ repos-HRCIMY6J.js
583
582
  resolveHarness-ADZRYQZA.js
584
583
  resolveModel-2OGVGUM3.js
585
584
  restartDaemon-Y7V2QF3N.js
586
- restartNode-ZM73BIZ4.js
585
+ restartNode-CAPDQK23.js
587
586
  restructure-OGGDZTXX.js
588
587
  review-5635HCXL.js
589
588
  reviewPrComments-E5Y5AQ7D.js
@@ -591,7 +590,7 @@ rewindPhase-S6NGWRFK.js
591
590
  rulesAdd-75UVUUDX.js
592
591
  run-TSPTUSMX.js
593
592
  run-ZRNTAO7O.js
594
- runDaemon-QU6S6FVH.js
593
+ runDaemon-GHG5TRPX.js
595
594
  runExtract-ALNQ3I3T.js
596
595
  runParallelPhase-V2LPUTA3.js
597
596
  runRefine-DSGHXEKJ.js
@@ -613,7 +612,7 @@ show-INQEZ755.js
613
612
  show-WD57SDPL.js
614
613
  showClaudeCodeIcon-E4SAM3GN.js
615
614
  showCodexIcon-YUAKV4NI.js
616
- signExtension-VSB6MSLB.js
615
+ signExtension-GQXLL6CC.js
617
616
  simulateDivergence-VB4UL4UR.js
618
617
  skip-7Q3IVOBV.js
619
618
  slack-DX2FRJ7S.js
@@ -641,7 +640,7 @@ unlinkNode-RKC44U2T.js
641
640
  unstar-YQDZUJV7.js
642
641
  update-FHGTCK6N.js
643
642
  update-W7ANHGDR.js
644
- updateNode-SRU5E3O3.js
643
+ updateNode-RMHEOL4X.js
645
644
  updatePhase-JEVJRAOR.js
646
645
  updatePlan-PYKAHGKE.js
647
646
  version-W7VP7LDJ.js
@@ -649,8 +648,8 @@ viewIssue-CYHIPCFO.js
649
648
  watchLoop-MV7DVGC6.js
650
649
  watchReport-A4W7UOAJ.js
651
650
  watchWait-5Y2J5VQY.js
652
- web-GRLY54Q4.js
653
- web-RXI5PSBM.js
651
+ web-3NKRW2FS.js
652
+ web-IE3MFOE5.js
654
653
  withPool-LEJ76IOJ.js
655
654
  wontdo-XAQGHSR5.js
656
655
  wontfix-W2DXPEE4.js
@@ -1 +1 @@
1
- 0.1186.0
1
+ 0.1187.0
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  buildDoctorProbes,
3
3
  diagnoseLink
4
- } from "./chunk-HJA2C6EP.js";
4
+ } from "./chunk-ODH4PKV4.js";
5
5
  import {
6
6
  findLinkSpec
7
7
  } from "./chunk-J2PPCMCR.js";
@@ -1,6 +1,14 @@
1
- import {
2
- stagedAttachmentsDir
3
- } from "./chunk-S6FVZYHH.js";
1
+ // src/shared/stagedAttachmentsDir.ts
2
+ import { homedir } from "os";
3
+ import { join } from "path";
4
+ var stagedAttachmentsDir = join(homedir(), ".assist", "attachments");
5
+
6
+ // src/shared/isStagedAttachmentPath.ts
7
+ import { isAbsolute, relative, resolve, sep } from "path";
8
+ function isStagedAttachmentPath(path) {
9
+ const rel = relative(stagedAttachmentsDir, resolve(path));
10
+ return rel !== "" && rel !== ".." && !rel.startsWith(`..${sep}`) && !isAbsolute(rel);
11
+ }
4
12
 
5
13
  // src/commands/sessions/web/attachmentContentType.ts
6
14
  import { extname } from "path";
@@ -32,7 +40,7 @@ var ghAttachableExtensions = /* @__PURE__ */ new Set([
32
40
 
33
41
  // src/commands/sessions/web/stageAttachment.ts
34
42
  import { mkdir, mkdtemp, writeFile } from "fs/promises";
35
- import { extname as extname2, join } from "path";
43
+ import { extname as extname2, join as join2 } from "path";
36
44
  function extensionFromMime(contentType) {
37
45
  const mime = contentType.split(";")[0].trim().toLowerCase();
38
46
  const known = attachmentMimeTypes[mime];
@@ -56,14 +64,16 @@ function safeBaseName(name) {
56
64
  async function stageAttachment(name, contentType, body) {
57
65
  const ext = pickExtension(name, contentType);
58
66
  await mkdir(stagedAttachmentsDir, { recursive: true });
59
- const dir = await mkdtemp(join(stagedAttachmentsDir, "upload-"));
67
+ const dir = await mkdtemp(join2(stagedAttachmentsDir, "upload-"));
60
68
  const alt = safeBaseName(name);
61
- const filePath = join(dir, `${alt}.${ext}`);
69
+ const filePath = join2(dir, `${alt}.${ext}`);
62
70
  await writeFile(filePath, body);
63
71
  return { dir, filePath, alt };
64
72
  }
65
73
 
66
74
  export {
75
+ stagedAttachmentsDir,
76
+ isStagedAttachmentPath,
67
77
  attachmentContentType,
68
78
  ghAttachableExtensions,
69
79
  stageAttachment
@@ -10,7 +10,7 @@ import {
10
10
  } from "./chunk-JM57BCD6.js";
11
11
  import {
12
12
  firstBrokenHop
13
- } from "./chunk-ZDCNWRGU.js";
13
+ } from "./chunk-7GGVRB3G.js";
14
14
  import {
15
15
  describePeerError,
16
16
  fetchPeerJson
@@ -47,7 +47,7 @@ import {
47
47
  import {
48
48
  ASSIST_VERSION,
49
49
  PROTOCOL_VERSION
50
- } from "./chunk-ZYOSEPXM.js";
50
+ } from "./chunk-GYM3LVZT.js";
51
51
  import {
52
52
  findLinkSpec
53
53
  } from "./chunk-J2PPCMCR.js";
@@ -115,10 +115,6 @@ import {
115
115
  import {
116
116
  requestPromptSession
117
117
  } from "./chunk-XTQSKMFH.js";
118
- import {
119
- attachmentContentType,
120
- stageAttachment
121
- } from "./chunk-WG3TXZMV.js";
122
118
  import {
123
119
  isDoNotMerge
124
120
  } from "./chunk-NGTSPXSJ.js";
@@ -146,9 +142,11 @@ import {
146
142
  fetchProjectV2
147
143
  } from "./chunk-YQ3CNWB3.js";
148
144
  import {
145
+ attachmentContentType,
149
146
  isStagedAttachmentPath,
147
+ stageAttachment,
150
148
  stagedAttachmentsDir
151
- } from "./chunk-S6FVZYHH.js";
149
+ } from "./chunk-DPCFT55U.js";
152
150
  import {
153
151
  assignIssueToSelf
154
152
  } from "./chunk-SDMBTSYP.js";
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-5CNDLMYO.js";
4
4
  import {
5
5
  package_default
6
- } from "./chunk-WH3YSTWQ.js";
6
+ } from "./chunk-XNN2K4S3.js";
7
7
  import {
8
8
  loadConfig
9
9
  } from "./chunk-UFSOFNXQ.js";
@@ -14,7 +14,7 @@ import {
14
14
  isHello,
15
15
  linkVersionCheck,
16
16
  negotiateProtocol
17
- } from "./chunk-ZYOSEPXM.js";
17
+ } from "./chunk-GYM3LVZT.js";
18
18
 
19
19
  // src/commands/sessions/nodes/probePeerHello.ts
20
20
  var HELLO_TIMEOUT_MS = 5e3;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  firstBrokenHop
3
- } from "./chunk-ZDCNWRGU.js";
3
+ } from "./chunk-7GGVRB3G.js";
4
4
  import {
5
5
  describePeerError
6
6
  } from "./chunk-VABNWHSE.js";
@@ -4,55 +4,10 @@ import {
4
4
  import {
5
5
  normalizeGithubIssue
6
6
  } from "./chunk-FVZP4ULO.js";
7
- import {
8
- attachmentContentType,
9
- ghAttachableExtensions,
10
- stageAttachment
11
- } from "./chunk-WG3TXZMV.js";
12
7
  import {
13
8
  loadJson
14
9
  } from "./chunk-CGYVYHMM.js";
15
10
 
16
- // src/commands/prs/parseScreenshotSpec.ts
17
- import { statSync } from "fs";
18
- import { basename, extname, resolve } from "path";
19
- function splitOnce(value, separator) {
20
- const index = value.indexOf(separator);
21
- if (index === -1) return null;
22
- return [value.slice(0, index), value.slice(index + separator.length)];
23
- }
24
- function isFile(path) {
25
- try {
26
- return statSync(path).isFile();
27
- } catch {
28
- return false;
29
- }
30
- }
31
- function parseScreenshotSpec(spec) {
32
- const [label, rawPath] = splitOnce(spec, "=") ?? ["", spec];
33
- const [group, caption] = splitOnce(label, "/") ?? ["", label];
34
- const path = resolve(rawPath.trim());
35
- const ext = extname(path).replace(/^\./, "").toLowerCase();
36
- if (!isFile(path))
37
- throw new Error(`--screenshot '${spec}': file not found: ${path}`);
38
- if (!ghAttachableExtensions.has(ext))
39
- throw new Error(
40
- `--screenshot '${spec}': gh cannot attach .${ext || "(none)"} files (supported: ${[...ghAttachableExtensions].join(", ")}).`
41
- );
42
- const alt = caption.trim() || basename(path, extname(path));
43
- return group.trim() ? { path, alt, group: group.trim() } : { path, alt };
44
- }
45
-
46
- // src/commands/prs/parseScreenshotSpecs.ts
47
- function parseScreenshotSpecs(specs) {
48
- try {
49
- return (specs ?? []).map(parseScreenshotSpec);
50
- } catch (error) {
51
- console.error(`Error: ${error.message}`);
52
- process.exit(1);
53
- }
54
- }
55
-
56
11
  // src/commands/prs/findWallOfText.ts
57
12
  var MAX_PARAGRAPH_CHARS = 600;
58
13
  var MAX_PARAGRAPH_SENTENCES = 4;
@@ -152,26 +107,8 @@ ${sections.how}`);
152
107
  return parts.join("\n\n");
153
108
  }
154
109
 
155
- // src/commands/prs/stageScreenshots.ts
156
- import { readFile } from "fs/promises";
157
- import { basename as basename2 } from "path";
158
- function stageScreenshots(screenshots = []) {
159
- return Promise.all(
160
- screenshots.map(async (screenshot) => {
161
- const { filePath } = await stageAttachment(
162
- basename2(screenshot.path),
163
- attachmentContentType(screenshot.path),
164
- await readFile(screenshot.path)
165
- );
166
- return { ...screenshot, path: filePath };
167
- })
168
- );
169
- }
170
-
171
110
  export {
172
111
  renderWhy,
173
112
  buildPrBody,
174
- parseScreenshotSpecs,
175
- stageScreenshots,
176
113
  validatePrContent
177
114
  };
@@ -1,7 +1,7 @@
1
1
  // package.json
2
2
  var package_default = {
3
3
  name: "@staff0rd/assist",
4
- version: "0.1186.0",
4
+ version: "0.1187.0",
5
5
  type: "module",
6
6
  main: "dist/index.js",
7
7
  bin: {
@@ -2,8 +2,11 @@ import {
2
2
  minGhAttachVersion
3
3
  } from "./chunk-B7B26YPF.js";
4
4
  import {
5
- isStagedAttachmentPath
6
- } from "./chunk-S6FVZYHH.js";
5
+ attachmentContentType,
6
+ ghAttachableExtensions,
7
+ isStagedAttachmentPath,
8
+ stageAttachment
9
+ } from "./chunk-DPCFT55U.js";
7
10
 
8
11
  // src/commands/prs/renderScreenshotBlock.ts
9
12
  import { extname } from "path";
@@ -82,6 +85,62 @@ function appendScreenshots(body, attachments) {
82
85
  ${section}` : section;
83
86
  }
84
87
 
88
+ // src/commands/prs/parseScreenshotSpec.ts
89
+ import { statSync } from "fs";
90
+ import { basename, extname as extname2, resolve } from "path";
91
+ function splitOnce(value, separator) {
92
+ const index = value.indexOf(separator);
93
+ if (index === -1) return null;
94
+ return [value.slice(0, index), value.slice(index + separator.length)];
95
+ }
96
+ function isFile(path) {
97
+ try {
98
+ return statSync(path).isFile();
99
+ } catch {
100
+ return false;
101
+ }
102
+ }
103
+ function parseScreenshotSpec(spec) {
104
+ const [label, rawPath] = splitOnce(spec, "=") ?? ["", spec];
105
+ const [group, caption] = splitOnce(label, "/") ?? ["", label];
106
+ const path = resolve(rawPath.trim());
107
+ const ext = extname2(path).replace(/^\./, "").toLowerCase();
108
+ if (!isFile(path))
109
+ throw new Error(`--screenshot '${spec}': file not found: ${path}`);
110
+ if (!ghAttachableExtensions.has(ext))
111
+ throw new Error(
112
+ `--screenshot '${spec}': gh cannot attach .${ext || "(none)"} files (supported: ${[...ghAttachableExtensions].join(", ")}).`
113
+ );
114
+ const alt = caption.trim() || basename(path, extname2(path));
115
+ return group.trim() ? { path, alt, group: group.trim() } : { path, alt };
116
+ }
117
+
118
+ // src/commands/prs/parseScreenshotSpecs.ts
119
+ function parseScreenshotSpecs(specs) {
120
+ try {
121
+ return (specs ?? []).map(parseScreenshotSpec);
122
+ } catch (error) {
123
+ console.error(`Error: ${error.message}`);
124
+ process.exit(1);
125
+ }
126
+ }
127
+
128
+ // src/commands/prs/stageScreenshots.ts
129
+ import { readFile } from "fs/promises";
130
+ import { basename as basename2 } from "path";
131
+ function stageScreenshots(screenshots = []) {
132
+ return Promise.all(
133
+ screenshots.map(async (screenshot) => {
134
+ const { filePath } = await stageAttachment(
135
+ basename2(screenshot.path),
136
+ attachmentContentType(screenshot.path),
137
+ await readFile(screenshot.path)
138
+ );
139
+ return { ...screenshot, path: filePath };
140
+ })
141
+ );
142
+ }
143
+
85
144
  // src/commands/prs/attachArgs.ts
86
145
  function attachArgs(attachments) {
87
146
  return attachments.flatMap(({ path }) => ["--attach", path]);
@@ -89,7 +148,7 @@ function attachArgs(attachments) {
89
148
 
90
149
  // src/commands/prs/runGhWithAttachments.ts
91
150
  import { execFileSync } from "child_process";
92
- import { basename } from "path";
151
+ import { basename as basename3 } from "path";
93
152
 
94
153
  // src/shared/removeStagedAttachments.ts
95
154
  import { rmSync } from "fs";
@@ -106,7 +165,7 @@ function removeStagedAttachments(attachments) {
106
165
  var PLACED_URL = /https:\/\/\S+\/(pull|issues)\/\d+/;
107
166
  function reportPartialFailure(attachments, stderr) {
108
167
  const failed = attachments.filter(
109
- ({ path }) => stderr.includes(path) || stderr.includes(basename(path))
168
+ ({ path }) => stderr.includes(path) || stderr.includes(basename3(path))
110
169
  );
111
170
  const named = failed.length > 0 ? failed : attachments;
112
171
  console.error(
@@ -141,6 +200,8 @@ function runGhWithAttachments(args, attachments) {
141
200
 
142
201
  export {
143
202
  appendScreenshots,
203
+ parseScreenshotSpecs,
204
+ stageScreenshots,
144
205
  attachArgs,
145
206
  runGhWithAttachments
146
207
  };