plaincrew 0.2.0 → 0.2.2
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/app-build/BUILD_ID +1 -1
- package/app-build/app-path-routes-manifest.json +1 -0
- package/app-build/build-manifest.json +3 -3
- package/app-build/diagnostics/route-bundle-stats.json +20 -20
- package/app-build/fallback-build-manifest.json +3 -3
- package/app-build/routes-manifest.json +8 -0
- package/app-build/server/app/_global-error.html +1 -1
- package/app-build/server/app/_global-error.rsc +1 -1
- package/app-build/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/app-build/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/app-build/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/app-build/server/app/_not-found.html +1 -1
- package/app-build/server/app/_not-found.rsc +1 -1
- package/app-build/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/app-build/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/app-build/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/app-build/server/app/api/account/ai/route.js +2 -2
- package/app-build/server/app/api/account/leaving/route.js +2 -2
- package/app-build/server/app/api/ais/models/route.js +2 -2
- package/app-build/server/app/api/attachments/route.js +2 -2
- package/app-build/server/app/api/auth/[...all]/route.js +2 -2
- package/app-build/server/app/api/cloud/enter/route.js +2 -2
- package/app-build/server/app/api/connect/[code]/approve/route.js +2 -2
- package/app-build/server/app/api/inngest/route.js +2 -2
- package/app-build/server/app/api/organization/route.js +2 -2
- package/app-build/server/app/api/projects/[id]/base/route.js +2 -2
- package/app-build/server/app/api/projects/[id]/github/route.js +11 -12
- package/app-build/server/app/api/projects/[id]/notes/[noteId]/route.js +2 -2
- package/app-build/server/app/api/projects/[id]/notes/route.js +2 -2
- package/app-build/server/app/api/projects/[id]/route.js +13 -12
- package/app-build/server/app/api/projects/[id]/site/route.js +11 -10
- package/app-build/server/app/api/projects/analyze/route.js +2 -2
- package/app-build/server/app/api/projects/route.js +2 -2
- package/app-build/server/app/api/projects/scratch/route.js +3 -3
- package/app-build/server/app/api/runs/[runId]/blocks/[blockId]/route.js +2 -2
- package/app-build/server/app/api/runs/[runId]/branch-name/route.js +2 -2
- package/app-build/server/app/api/runs/[runId]/cancel/route.js +2 -2
- package/app-build/server/app/api/runs/[runId]/connect-github/route.js +11 -12
- package/app-build/server/app/api/runs/[runId]/decision/route.js +2 -2
- package/app-build/server/app/api/runs/[runId]/delivery/route.js +2 -2
- package/app-build/server/app/api/runs/[runId]/events/route.js +2 -2
- package/app-build/server/app/api/runs/[runId]/failure/explain/route.js +2 -2
- package/app-build/server/app/api/runs/[runId]/failure/route.js +2 -2
- package/app-build/server/app/api/runs/[runId]/findings/route.js +2 -2
- package/app-build/server/app/api/runs/[runId]/follow-up/route.js +2 -2
- package/app-build/server/app/api/runs/[runId]/plan/route.js +2 -2
- package/app-build/server/app/api/runs/[runId]/preview/route.js +2 -2
- package/app-build/server/app/api/runs/[runId]/prompts/route.js +2 -2
- package/app-build/server/app/api/runs/[runId]/questions/[questionId]/route.js +2 -2
- package/app-build/server/app/api/runs/[runId]/review/route.js +2 -2
- package/app-build/server/app/api/runs/[runId]/route.js +2 -2
- package/app-build/server/app/api/runs/[runId]/ship/route.js +2 -2
- package/app-build/server/app/api/runs/[runId]/snapshots/[shot]/route.js +2 -2
- package/app-build/server/app/api/runs/[runId]/snapshots/route.js +2 -2
- package/app-build/server/app/api/runs/[runId]/throw-away/route/app-paths-manifest.json +3 -0
- package/app-build/server/app/api/runs/[runId]/throw-away/route/build-manifest.json +12 -0
- package/app-build/server/app/api/runs/[runId]/throw-away/route/server-reference-manifest.json +4 -0
- package/app-build/server/app/api/runs/[runId]/throw-away/route.js +27 -0
- package/app-build/server/app/api/runs/[runId]/throw-away/route_client-reference-manifest.js +3 -0
- package/app-build/server/app/api/runs/[runId]/versions/[n]/route.js +2 -2
- package/app-build/server/app/api/runs/[runId]/versions/[n]/site/route.js +2 -2
- package/app-build/server/app/api/runs/[runId]/versions/live/route.js +2 -2
- package/app-build/server/app/api/runs/[runId]/versions/route.js +2 -2
- package/app-build/server/app/api/system/choose-folder/route.js +2 -2
- package/app-build/server/app/api/workflows/[id]/draft/route.js +2 -2
- package/app-build/server/app/api/workflows/[id]/publish/route.js +2 -2
- package/app-build/server/app/api/workflows/[id]/runs/route.js +2 -2
- package/app-build/server/app/canvas/[workflowId]/page.js +2 -2
- package/app-build/server/app/canvas/[workflowId]/page_client-reference-manifest.js +1 -1
- package/app-build/server/app/connect/page.js +2 -2
- package/app-build/server/app/connect/page_client-reference-manifest.js +1 -1
- package/app-build/server/app/invite/[id]/page.js +2 -2
- package/app-build/server/app/invite/[id]/page_client-reference-manifest.js +1 -1
- package/app-build/server/app/organization/new/page.js +2 -2
- package/app-build/server/app/organization/new/page_client-reference-manifest.js +1 -1
- package/app-build/server/app/page.js +2 -2
- package/app-build/server/app/page_client-reference-manifest.js +1 -1
- package/app-build/server/app/sign-in/page.js +2 -2
- package/app-build/server/app/sign-in/page_client-reference-manifest.js +1 -1
- package/app-build/server/app/sign-up/page.js +2 -2
- package/app-build/server/app/sign-up/page_client-reference-manifest.js +1 -1
- package/app-build/server/app-paths-manifest.json +1 -0
- package/app-build/server/chunks/1oeh_server_app_api_runs_[runId]_throw-away_route_actions_1a19gfw3nf1x2.js +3 -0
- package/app-build/server/chunks/{[root-of-the-server]__09mx4_ihytiv9._.js → [root-of-the-server]__0-rma_dhn0mrx._.js} +1 -1
- package/app-build/server/chunks/{[root-of-the-server]__0qzwj14rh2ym2._.js → [root-of-the-server]__00222l-7v_pw1._.js} +1 -1
- package/app-build/server/chunks/{[root-of-the-server]__0-hf81cjc9miq._.js → [root-of-the-server]__01yfk7-22rke8._.js} +1 -1
- package/app-build/server/chunks/{[root-of-the-server]__111rn2m71ahq1._.js → [root-of-the-server]__077j6jvkmfen-._.js} +1 -1
- package/app-build/server/chunks/{[root-of-the-server]__0j9vey56ni96j._.js → [root-of-the-server]__07u87ai27nhgy._.js} +1 -1
- package/app-build/server/chunks/[root-of-the-server]__0_use5ykfraw7._.js +14 -14
- package/app-build/server/chunks/{[root-of-the-server]__0fer144qqb0_6._.js → [root-of-the-server]__0a-kovunokq7y._.js} +1 -1
- package/app-build/server/chunks/{[root-of-the-server]__11vhj0obteagu._.js → [root-of-the-server]__0bwl79z8x10tg._.js} +1 -1
- package/app-build/server/chunks/{[root-of-the-server]__1fg-66qrs9vmd._.js → [root-of-the-server]__0frjchnam0z0j._.js} +1 -1
- package/app-build/server/chunks/{[root-of-the-server]__20oqzfu0t4513._.js → [root-of-the-server]__0h5zi4_dsk0d-._.js} +1 -1
- package/app-build/server/chunks/{[root-of-the-server]__04bfm6aam99jr._.js → [root-of-the-server]__0k9ljvlsra_ty._.js} +1 -1
- package/app-build/server/chunks/{[root-of-the-server]__0drcpac0a5hru._.js → [root-of-the-server]__0o_g6qunr-flu._.js} +1 -1
- package/app-build/server/chunks/{[root-of-the-server]__16_r5tdw4ji2s._.js → [root-of-the-server]__0pom1ni7il-px._.js} +1 -1
- package/app-build/server/chunks/{[root-of-the-server]__0hryxb3l1_c-b._.js → [root-of-the-server]__0pws17pv2c29c._.js} +1 -1
- package/app-build/server/chunks/{[root-of-the-server]__0d4dt0ywt1ow0._.js → [root-of-the-server]__0qjq8c0jw-mdw._.js} +1 -1
- package/app-build/server/chunks/{[root-of-the-server]__1jwagne56rhyq._.js → [root-of-the-server]__0rw7-w7ggzp9w._.js} +2 -2
- package/app-build/server/chunks/[root-of-the-server]__0v0z73--8rq51._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__0w_5-09zlziz9._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__0ww92n3isnzm2._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__0xtbjsk_8ab4j._.js +3 -0
- package/app-build/server/chunks/{[root-of-the-server]__0j-5-xlcodeao._.js → [root-of-the-server]__0zxb48z34gqs1._.js} +1 -1
- package/app-build/server/chunks/{[root-of-the-server]__1m9ci-2fhznpr._.js → [root-of-the-server]__13aehgyzs9lbd._.js} +1 -1
- package/app-build/server/chunks/[root-of-the-server]__15witsrnyg3dd._.js +3 -0
- package/app-build/server/chunks/{[root-of-the-server]__1a17c0kjajkbe._.js → [root-of-the-server]__17m5okwlzsyl1._.js} +1 -1
- package/app-build/server/chunks/{[root-of-the-server]__0_wicg5sueifn._.js → [root-of-the-server]__17x6k6pitzk_5._.js} +1 -1
- package/app-build/server/chunks/[root-of-the-server]__18der_neib1_t._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__18hx5fasl2mue._.js +3 -0
- package/app-build/server/chunks/{[root-of-the-server]__1no1kg2v5558v._.js → [root-of-the-server]__18sbr3uygawkb._.js} +1 -1
- package/app-build/server/chunks/[root-of-the-server]__19vu74udpbi3u._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__1a1-7v9-7r7z3._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__1a87dgnjgqot2._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__1ae3yidgvaczf._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__1aje8j3jhgce_._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__1aw9yt_bvxa4y._.js +3 -0
- package/app-build/server/chunks/{[root-of-the-server]__1j82aseh7oyg8._.js → [root-of-the-server]__1dg18go136mg2._.js} +1 -1
- package/app-build/server/chunks/{[root-of-the-server]__083kealcx1eos._.js → [root-of-the-server]__1h4ao1cxtu9ct._.js} +1 -1
- package/app-build/server/chunks/[root-of-the-server]__1hynzq99iy2jv._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__1hz3h385ra2_h._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__1j1gi9vgjem2s._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__1lb4spfx1cufp._.js +3 -0
- package/app-build/server/chunks/{[root-of-the-server]__01_h69z_7y8hj._.js → [root-of-the-server]__1m7zmx0c3d29a._.js} +1 -1
- package/app-build/server/chunks/{[root-of-the-server]__1dx64weifqusv._.js → [root-of-the-server]__1mgzlhbtfm2s2._.js} +1 -1
- package/app-build/server/chunks/{[root-of-the-server]__04fo6q9-bmsqf._.js → [root-of-the-server]__1qrhu-f3_okvy._.js} +1 -1
- package/app-build/server/chunks/[root-of-the-server]__1sxtsguf6-rqn._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__1uaaw183mgxvp._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__1vz7pyxbcxdam._.js +3 -0
- package/app-build/server/chunks/[root-of-the-server]__203b0tgsx02nt._.js +3 -0
- package/app-build/server/chunks/{[root-of-the-server]__1_67_outgzgho._.js → [root-of-the-server]__20u3cxne2g634._.js} +1 -1
- package/app-build/server/chunks/_0-spos-0d2krg._.js +19 -0
- package/app-build/server/chunks/_00_jnbz1zvwgx._.js +19 -0
- package/app-build/server/chunks/_00nvlapuy-n5u._.js +19 -0
- package/app-build/server/chunks/_02ydx-6i02-15._.js +19 -0
- package/app-build/server/chunks/_09ejh1dyvkto7._.js +1 -1
- package/app-build/server/chunks/_0acmw0tv499h0._.js +19 -0
- package/app-build/server/chunks/_0aw98t7vmjb88._.js +19 -0
- package/app-build/server/chunks/_0b2ridyy82jxe._.js +1 -1
- package/app-build/server/chunks/_0bhd3724mk5_8._.js +19 -0
- package/app-build/server/chunks/_0bhh96fypchdz._.js +3 -0
- package/app-build/server/chunks/_0bsptjrzcu8a7._.js +19 -0
- package/app-build/server/chunks/_0d-t3ot63p6q4._.js +19 -0
- package/app-build/server/chunks/_0e2pq-eirvzjq._.js +1 -1
- package/app-build/server/chunks/_0et5mjk8ma941._.js +1 -1
- package/app-build/server/chunks/_0ety_xj8s9se5._.js +19 -0
- package/app-build/server/chunks/_0fbwelpje0vpp._.js +19 -0
- package/app-build/server/chunks/_0ipkjlo50tvzh._.js +19 -0
- package/app-build/server/chunks/_0j8and6kle-vr._.js +19 -0
- package/app-build/server/chunks/_0l56fyw-2mdap._.js +19 -0
- package/app-build/server/chunks/_0o-zfrg3y0fq7._.js +19 -0
- package/app-build/server/chunks/_0oh4tv1yn6ko-._.js +19 -0
- package/app-build/server/chunks/_0omlu-feiobkm._.js +19 -0
- package/app-build/server/chunks/_0prtq3d1e3y27._.js +1 -1
- package/app-build/server/chunks/_0qgouuuv9x557._.js +19 -0
- package/app-build/server/chunks/_0r2znajb4c33_._.js +19 -0
- package/app-build/server/chunks/_0r7go8jj5dc5t._.js +4 -0
- package/app-build/server/chunks/_0uer66e27_rqy._.js +1 -1
- package/app-build/server/chunks/_0w3v4t4p9vsb-._.js +1 -1
- package/app-build/server/chunks/_0wi30r5c4hlyh._.js +19 -0
- package/app-build/server/chunks/_0yi75njq4zxzw._.js +2 -2
- package/app-build/server/chunks/_0yxx6fkquhd5h._.js +19 -0
- package/app-build/server/chunks/_1-l-baxl7r6o-._.js +19 -0
- package/app-build/server/chunks/_1-piaouq4au1v._.js +1 -1
- package/app-build/server/chunks/_12v43tznpol4u._.js +1 -1
- package/app-build/server/chunks/_153o0hrf0g3mk._.js +19 -0
- package/app-build/server/chunks/_155fw3g6f3-4h._.js +19 -0
- package/app-build/server/chunks/_19_0wmfnwvz9o._.js +1 -1
- package/app-build/server/chunks/_19q1zxel7pllh._.js +1 -1
- package/app-build/server/chunks/_1_mlvky6w1ov8._.js +19 -0
- package/app-build/server/chunks/_1bf1pcq2wtg91._.js +1 -1
- package/app-build/server/chunks/_1cq7469bqdm3u._.js +1 -1
- package/app-build/server/chunks/_1f610h-qim306._.js +19 -0
- package/app-build/server/chunks/_1h24vpftu-w_x._.js +19 -0
- package/app-build/server/chunks/_1hhnlf5x-a4y4._.js +19 -0
- package/app-build/server/chunks/_1l2bdu1tjz32v._.js +3 -0
- package/app-build/server/chunks/_1nx8fwgx5ca29._.js +19 -0
- package/app-build/server/chunks/_1ob-6ym8mt48u._.js +1 -1
- package/app-build/server/chunks/_1uwtj6yrwszfe._.js +1 -1
- package/app-build/server/chunks/_1vb0vvvhh6nh7._.js +1 -1
- package/app-build/server/chunks/_1vfxvrhfw43y_._.js +3 -0
- package/app-build/server/chunks/_1w-v2i1f-t_3x._.js +19 -0
- package/app-build/server/chunks/_1wau1ee-6k-7o._.js +1 -1
- package/app-build/server/chunks/_1yho6hc7s0457._.js +1 -1
- package/app-build/server/chunks/_1zn_x1pv0cr9q._.js +19 -0
- package/app-build/server/chunks/src_engine_ship_ts_1-sbwwj6ig7jv._.js +1 -1
- package/app-build/server/chunks/src_engine_site-preview_ts_0-dbxa3-3tr7l._.js +3 -0
- package/app-build/server/chunks/ssr/{[root-of-the-server]__02fcbpwktzl0e._.js → [root-of-the-server]__0oas93cn5j9ig._.js} +1 -1
- package/app-build/server/chunks/ssr/{[root-of-the-server]__1cu7ckiad_t58._.js → [root-of-the-server]__0xan19-2pz7sa._.js} +1 -1
- package/app-build/server/chunks/ssr/{[root-of-the-server]__1ik_gvdjzwan6._.js → [root-of-the-server]__12-_-lnji2wdx._.js} +1 -1
- package/app-build/server/chunks/ssr/{[root-of-the-server]__06kehcks298uq._.js → [root-of-the-server]__1flxwowggjg0y._.js} +1 -1
- package/app-build/server/chunks/ssr/{[root-of-the-server]__0mpgsl517i3-0._.js → [root-of-the-server]__1g-692s4zsw6v._.js} +1 -1
- package/app-build/server/chunks/ssr/{[root-of-the-server]__0ayx2k8e4n7yj._.js → [root-of-the-server]__1wvi-5c59hvhk._.js} +1 -1
- package/app-build/server/chunks/ssr/{[root-of-the-server]__07qbaxjilfrhb._.js → [root-of-the-server]__1xfbap5otqs7y._.js} +1 -1
- package/app-build/server/chunks/ssr/{_0plc10a4e_g26._.js → _0au36lf3n46hl._.js} +2 -2
- package/app-build/server/chunks/ssr/_14z-y2hqpv20w._.js +2 -2
- package/app-build/server/chunks/ssr/{_0vqiqfwum1eeq._.js → _1heqye3wc0a3t._.js} +2 -2
- package/app-build/server/chunks/ssr/{_15rry-mn1ylod._.js → _1mesxn8ux7m-b._.js} +2 -2
- package/app-build/server/chunks/ssr/{_1stfnmis3lpoq._.js → _1tl5r54a78aca._.js} +2 -2
- package/app-build/server/chunks/ssr/_212xzvdrw1r-3._.js +498 -0
- package/app-build/server/chunks/ssr/src_ui_0a7papum2y8_i._.js +1 -1
- package/app-build/server/chunks/ssr/src_ui_0dybjq718frlj._.js +1 -1
- package/app-build/server/chunks/ssr/src_ui_1lk_5nzn_qoqs._.js +1 -1
- package/app-build/server/chunks/ssr/src_ui_1pd2_lbqeputa._.js +1 -1
- package/app-build/server/chunks/ssr/src_ui_canvas_AddProjectDialog_tsx_10a7chj-0e01u._.js +1 -1
- package/app-build/server/chunks/ssr/src_ui_strings_ts_1es3352ykktl1._.js +1 -1
- package/app-build/server/middleware-build-manifest.js +3 -3
- package/app-build/server/pages/404.html +1 -1
- package/app-build/server/pages/500.html +1 -1
- package/app-build/static/chunks/0ii9_22v9su8d.js +1 -0
- package/app-build/static/chunks/{0u800lsoqi8_z.js → 1itn52l0g-rzl.js} +8 -8
- package/app-build/static/chunks/2-i8llxdbif11.js +1 -0
- package/app-build/static/chunks/2ld15xpoa2y6e.js +5 -0
- package/app-build/trace-build +1 -1
- package/package.json +1 -1
- package/app-build/server/chunks/[root-of-the-server]__0o-3c4wjexyir._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__0qwqrlb3b7i0y._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__0qzb976d_qj48._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__0rwo4zg_leice._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__0tt48asd4bq_v._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__0x8sjs-qr0fi-._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__0z7e3um13c2p0._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__11-p_3onzgf2e._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__15p8ahu4ip30q._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__16023he7o7zot._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__17z8-upkyjz-v._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__1_2bvyen56qja._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__1bbm3yv2mh0ob._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__1ehsotx9v9v0-._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__1ghp4gx3vslm5._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__1irx63ehwr_32._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__1n1otzmcc-pl-._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__1rq-k_585r2e9._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__1su62l6u2edkj._.js +0 -3
- package/app-build/server/chunks/[root-of-the-server]__1xodvnju6iwx3._.js +0 -3
- package/app-build/server/chunks/_01f7ho67e16bo._.js +0 -3
- package/app-build/server/chunks/_04ipxobgytrai._.js +0 -19
- package/app-build/server/chunks/_06_bsixuw5t32._.js +0 -19
- package/app-build/server/chunks/_0_6-kjk5l5ckf._.js +0 -19
- package/app-build/server/chunks/_0_q5vorhn2m7p._.js +0 -19
- package/app-build/server/chunks/_0b15uwzi-_wuu._.js +0 -19
- package/app-build/server/chunks/_0fx9tvayvawom._.js +0 -19
- package/app-build/server/chunks/_0hfgolst82fo-._.js +0 -19
- package/app-build/server/chunks/_0mvcmkm58awy6._.js +0 -19
- package/app-build/server/chunks/_0p2av7ih_dhj4._.js +0 -19
- package/app-build/server/chunks/_0rnf-n0hrw3r0._.js +0 -19
- package/app-build/server/chunks/_0sqpau27sb7i_._.js +0 -19
- package/app-build/server/chunks/_0wuc81q3tth-g._.js +0 -19
- package/app-build/server/chunks/_0x2g7uj3hbyqa._.js +0 -19
- package/app-build/server/chunks/_0zm1mzakhcn80._.js +0 -3
- package/app-build/server/chunks/_1-bgcffz4bjus._.js +0 -19
- package/app-build/server/chunks/_1-yeinb4sdagg._.js +0 -19
- package/app-build/server/chunks/_108rver1pgqw-._.js +0 -19
- package/app-build/server/chunks/_13lb7kts14z5a._.js +0 -3
- package/app-build/server/chunks/_143_tdoh-o8r2._.js +0 -19
- package/app-build/server/chunks/_146_--s-6f_o-._.js +0 -19
- package/app-build/server/chunks/_190n79a8itd96._.js +0 -19
- package/app-build/server/chunks/_1fq2ezphtpgk3._.js +0 -19
- package/app-build/server/chunks/_1fv67kzffpbb_._.js +0 -19
- package/app-build/server/chunks/_1k79cnpkap3g1._.js +0 -19
- package/app-build/server/chunks/_1kwxo3qf7dky_._.js +0 -19
- package/app-build/server/chunks/_1oyjikbasms78._.js +0 -3
- package/app-build/server/chunks/_1p4epxp2kfwl3._.js +0 -19
- package/app-build/server/chunks/_1tqh-hw_2xsox._.js +0 -19
- package/app-build/server/chunks/_1u_phco4tax56._.js +0 -19
- package/app-build/server/chunks/_1unrzazajazmw._.js +0 -19
- package/app-build/server/chunks/_1vmf9gx675--i._.js +0 -19
- package/app-build/server/chunks/_20y-6xht4mb44._.js +0 -19
- package/app-build/server/chunks/ssr/_1uj-3d4t3_f-w._.js +0 -498
- package/app-build/static/chunks/04hu91jpixs3u.js +0 -1
- package/app-build/static/chunks/1wg6_v6094_ev.js +0 -1
- package/app-build/static/chunks/2ku8241h3kja_.js +0 -5
- /package/app-build/static/{r8bYBXboElhyfwYccuAh5 → dLfuxcueP2VUobb7KqDeT}/_buildManifest.js +0 -0
- /package/app-build/static/{r8bYBXboElhyfwYccuAh5 → dLfuxcueP2VUobb7KqDeT}/_clientMiddlewareManifest.js +0 -0
- /package/app-build/static/{r8bYBXboElhyfwYccuAh5 → dLfuxcueP2VUobb7KqDeT}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module.exports=[60338,e=>{"use strict";var t=e.i(56325),r=e.i(44988),n=e.i(18899);e.s(["H",0,function(e){return n.B`count(${e||n.B.raw("*")})`.mapWith(Number)},"y",0,function(e){return n.B`max(${e})`.mapWith((0,r.f)(e,t.f)?e:String)}])},44586,e=>{"use strict";e.s(["f",0,function(e){return/^[A-Za-z0-9._-]{1,100}$/.test(e)&&"."!==e&&".."!==e}])},96662,e=>e.a(async(t,r)=>{try{var n=e.i(75225),i=e.i(49129),a=e.i(24924),s=e.i(92335),o=e.i(82283),l=t([a]);async function c(e){let t=await f(e);return e=>{let r=[];for(let n of t)n.runId===e&&("undo"===n.answerOption?r.pop():"other"===n.answerOption&&n.answerText?.trim()&&r.push(n.answerText.trim()));return r}}[a]=l.then?(await l)():l;let f=async e=>e.length>0?a.r.select().from(s.m).where((0,n.b)((0,n.y)(s.m.runId,e),(0,n.u)(s.m.kind,"direct"))).orderBy((0,i.M)(s.m.createdAt)):[];async function u(e,t){let r=[];for(let t of(await f([e])))"undo"===t.answerOption?r.push({at:t.createdAt,text:null}):"other"===t.answerOption&&t.answerText?.trim()&&r.push({at:t.createdAt,text:t.answerText.trim()});for(let t of(await a.r.select().from(s.a).where((0,n.b)((0,n.u)(s.a.runId,e),(0,n.u)(s.a.decision,"changes")))))t.reason?.trim()&&r.push({at:t.createdAt,text:t.reason.trim()});r.sort((e,t)=>e.at.localeCompare(t.at));let i=[];for(let e of r)null===e.text?i.pop():i.push(e.text);return i.length>0?o.f.review.withLaterAsks(t,i):t}e.s(["P",0,c,"u",0,u]),r()}catch(e){r(e)}},!1),82461,e=>e.a(async(t,r)=>{try{var n=e.i(2157),i=e.i(50227),a=e.i(75225),s=e.i(6561),o=e.i(24924),l=e.i(92335),c=e.i(65272),u=e.i(82283),f=e.i(91138),d=t([o]);[o]=d.then?(await d)():d;let m=(0,i.join)(f.f,"attachments");class y extends Error{}let g=[{mime:"image/png",ext:"png",test:e=>e.subarray(0,8).equals(Buffer.from([137,80,78,71,13,10,26,10]))},{mime:"image/jpeg",ext:"jpg",test:e=>255===e[0]&&216===e[1]&&255===e[2]},{mime:"image/gif",ext:"gif",test:e=>"GIF87a"===e.subarray(0,6).toString("ascii")||"GIF89a"===e.subarray(0,6).toString("ascii")},{mime:"image/webp",ext:"webp",test:e=>"RIFF"===e.subarray(0,4).toString("ascii")&&"WEBP"===e.subarray(8,12).toString("ascii")}];async function h(e,t,r=m){let a;if(0===t.length)throw new y(u.f.attachments.notImage);if(t.length>0xa00000)throw new y(u.f.attachments.tooBig(10));let f=(a=g.find(e=>t.length>=12&&e.test(t)))?{mime:a.mime,ext:a.ext}:null;if(!f)throw new y(u.f.attachments.notImage);let d=(0,s.v)();(0,n.mkdirSync)(r,{recursive:!0});let p=(0,i.join)(r,`${d}.${f.ext}`);(0,n.writeFileSync)(p,t),await (0,c.h)()?.put((0,c._)(d,f.ext),t,f.mime);let w=e.replace(/[^\w.\- ]+/g,"_").slice(0,120)||`image.${f.ext}`;return await o.r.insert(l.K).values({id:d,path:p,name:w,mime:f.mime,size:t.length,createdAt:new Date().toISOString()}),{id:d,name:w,mime:f.mime,size:t.length}}async function p(e,t,r=null,n=null){let i=[...new Set(e)].slice(0,6);if(0===i.length)return 0;let s=await o.r.select().from(l.K).where((0,a.b)((0,a.y)(l.K.id,i),(0,a.M)(l.K.runId)));for(let e of s)await o.r.update(l.K).set({runId:t,approvalId:r,questionId:n}).where((0,a.u)(l.K.id,e.id));return s.length}async function w(e,t=null,r=m){let s="string"==typeof t?t:null,u=null!==t&&"object"==typeof t?(0,a.u)(l.K.questionId,t.question):(0,a.b)(s?(0,a.u)(l.K.approvalId,s):(0,a.M)(l.K.approvalId),(0,a.M)(l.K.questionId)),f=await o.r.select().from(l.K).where((0,a.b)((0,a.u)(l.K.runId,e),u)),d=[];for(let e of f){let t=(0,i.extname)(e.path).slice(1)||"png",a=(0,n.existsSync)(e.path)?e.path:(0,i.join)(r,`${e.id}.${t}`);if(!(0,n.existsSync)(a)){let i=await (0,c.h)()?.get((0,c._)(e.id,t));if(!i)continue;(0,n.mkdirSync)(r,{recursive:!0}),(0,n.writeFileSync)(a,i.body)}d.push(a)}return d}e.s(["o",0,m,"F",0,y,"H",0,6,"R",0,0xa00000,"V",0,p,"W",0,w,"r",0,h]),r()}catch(e){r(e)}},!1),120,e=>e.a(async(t,r)=>{try{var n=e.i(74533),i=e.i(66680),a=e.i(2157),s=e.i(50227),o=e.i(29420),l=e.i(62534),c=e.i(40855),u=e.i(64950),f=e.i(91138),d=t([u]);[u]=d.then?(await d)():d;let v=(0,s.join)(f.f,"bases"),S=["pnpm-lock.yaml","yarn.lock","bun.lock","bun.lockb","package-lock.json"],k=(e,t)=>(0,n.execFileSync)("git",t,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","pipe"]}).trim();function h(e){for(let t of[...S,"package.json"]){let r=(0,s.join)(e,t);if((0,a.existsSync)(r))return`${t}:${(0,i.createHash)("sha256").update((0,a.readFileSync)(r)).digest("hex")}`}return null}let x=(e,t=v)=>(0,s.join)(t,e);function p(e,t,r=v){let n=x(e,r);if((0,a.existsSync)(n))try{if(!t)throw Error("no repository to ask");k(t,["worktree","remove","--force",n])}catch{(0,a.rmSync)(n,{recursive:!0,force:!0})}}async function w(e,t){await (0,u.J)(e,{...t,baseUpdatedAt:new Date().toISOString()})}let I=new Set;async function m(e,t={}){if(I.has(e))return;let r=await (0,u.I)(e);if(!r?.repoPath)return;I.add(e);let n=r.repoPath,i=x(e,t.root);try{await w(e,{baseStatus:"installing",baseMessage:null});let r=(0,o.I)(n),u=r?await (0,o.Y)(n,r):null,f=u?.commit??k(n,["rev-parse","HEAD"]);p(e,n,t.root),(0,a.mkdirSync)((0,s.dirname)(i),{recursive:!0}),k(n,["worktree","prune"]),k(n,["worktree","add","--detach","-q",i,f]);let d=await (t.install??l.F)(i);if(d&&!d.ok)return void await w(e,{baseStatus:"failed",baseCommit:f,baseLockHash:null,baseMessage:(0,c.l)((0,c.h)(d.outputTail).trim().split("\n").slice(-2).join(" "),300)});await w(e,{baseStatus:"ready",baseCommit:f,baseLockHash:h(i),baseMessage:null})}catch(t){await w(e,{baseStatus:"failed",baseMessage:(0,c.l)((0,c.h)(t instanceof Error?t.message:String(t)),300)})}finally{I.delete(e)}}function y(e,t){try{(0,n.execFileSync)("python3",["-I","-c","import ctypes,sys; sys.exit(ctypes.CDLL(None).clonefile(sys.argv[1].encode(), sys.argv[2].encode(), 0))",e,t],{stdio:"ignore",timeout:12e4});return}catch{(0,a.rmSync)(t,{recursive:!0,force:!0})}try{(0,n.execFileSync)("cp",["-cR",e,t],{stdio:"ignore"});return}catch{(0,a.rmSync)(t,{recursive:!0,force:!0})}(0,n.execFileSync)("cp",["-R",e,t],{stdio:"ignore"})}async function g(e,t,r=v){let n=await (0,u.I)(e),i=x(e,r);if(n?.baseStatus!=="ready"||!n.baseLockHash||!(0,a.existsSync)(i))return{copied:!1,reason:"no-base"};if(h(t)!==n.baseLockHash)return{copied:!1,reason:"different-lockfile"};let o=Date.now();try{let e,r;for(let n of(e=[],(r=t=>{for(let n of(0,a.readdirSync)(t,{withFileTypes:!0})){if(!n.isDirectory()||".git"===n.name)continue;let a=(0,s.join)(t,n.name);"node_modules"===n.name?e.push((0,s.relative)(i,a)):r(a)}})(i),e.sort())){let e=(0,s.join)(t,n);(0,a.existsSync)(e)||((0,a.mkdirSync)((0,s.dirname)(e),{recursive:!0}),y((0,s.join)(i,n),e))}return{copied:!0,ms:Date.now()-o}}catch{return{copied:!1,reason:"copy-failed"}}}async function b(e,t){let r=await (0,u.I)(e);if(!r?.repoPath||"ready"!==r.baseStatus)return!1;let a=function(e,t){for(let r of[...S,"package.json"])try{let a=(0,n.execFileSync)("git",["show",`${t}:${r}`],{cwd:e,stdio:["ignore","pipe","ignore"],maxBuffer:0x10000000});return`${r}:${(0,i.createHash)("sha256").update(a).digest("hex")}`}catch{}return null}(r.repoPath,t);return null!==a&&a!==r.baseLockHash}e.s(["y",0,b,"q",0,y,"S",0,g,"F",0,p,"m",0,m]),r()}catch(e){r(e)}},!1),28033,e=>{"use strict";var t=e.i(74533),r=e.i(60526),n=e.i(40855);let i=/^[a-z0-9]+(?:-[a-z0-9]+){1,5}$/,a=new Set("a al an and are as at be by con de del el en es esta este first for from haz in is it la las lo los make me mi my no now of on or para please por primero que se sin so solo the then to un una uno y ya you your ejecuta ejecutar run install pnpm npm yarn bun cambia cambiar change quiero want can could would nada mas more".split(" "));function s(e){let t=(0,n.h)(e).normalize("NFD").replace(/[̀-ͯ]/g,"").toLowerCase().split(/\s+/).filter(e=>!/[/\\]|\.[a-z]{1,4}\b/.test(e)).map(e=>e.replace(/[^a-z0-9]+/g,"")).filter(e=>e.length>1&&!a.has(e)&&!/^\d+(px|rem|em|%)?$/.test(e)),r=[];for(let e of t)if(!r.includes(e)&&([...r,e].join("-").length>48||(r.push(e),5===r.length)))break;return r.length>0?r.join("-"):null}let o=e=>new Promise((n,i)=>{(0,t.execFile)("claude",["-p","--model","haiku","--setting-sources","","--strict-mcp-config",e],{cwd:(0,r.tmpdir)(),timeout:2e4,maxBuffer:65536},(e,t)=>e?i(e):n(t))});async function l(e,t,r=o){let n=`Name a git branch for this change. Reply with ONLY 2 to 5 lowercase English words joined by hyphens that say what changed, nothing else.
|
|
2
|
+
Request: ${e.slice(0,2e3)}
|
|
3
|
+
Files changed: ${t.slice(0,20).join(", ")||"unknown"}`;try{var a;let e,t=(a=await r(n),e=a.trim().split("\n")[0]?.trim().toLowerCase().replace(/^[`'"]+|[`'".]+$/g,"").replace(/^ai\//,"")??"",i.test(e)&&e.length<=48?e:null);if(t)return t}catch{}return s(e)??"change"}async function c(e,t,r=o){let n;if(""===t.trim())return null;let i=`Write a git commit message for this diff. Line 1: an imperative summary of what the code change does, at most 72 characters. Then a blank line, then 1 to 4 short lines starting with "- " saying what changed. English. Reply with the message only.
|
|
4
|
+
What the person asked for (context only): ${e.slice(0,1e3)}
|
|
5
|
+
Diff:
|
|
6
|
+
${t.slice(0,12e3)}`;try{n=await r(i)}catch{return null}let a=n.replace(/```[a-z]*\n?/g,"").trim().split("\n"),s=(a[0]??"").trim().replace(/^["'`]+|["'`]+$/g,"");return s.length<3||s.length>72||/[:!]$/.test(s)||/^(sure|here|okay|ok)\b/i.test(s)?null:{subject:s,body:a.slice(1).filter(e=>!/^\s*(co-authored-by|signed-off-by|generated with)\b/i.test(e)&&!e.includes("🤖")).join("\n").trim().slice(0,800)}}e.s(["q",0,o,"k",0,function(e,t){return`ai/${t}-${e.slice(-6).toLowerCase()}`},"R",0,s,"A",0,l,"s",0,c])},29420,e=>{"use strict";var t=e.i(74533);let r=(e,r)=>(0,t.execFileSync)("git",r,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","pipe"]}).trim(),n=(e,t)=>{try{return r(e,t)||null}catch{return null}},i=/^[A-Za-z0-9][A-Za-z0-9._/-]{0,199}$/;function a(e,t){return!i.test(t)||t.includes("..")?null:n(e,["rev-parse","--verify","--quiet",`refs/heads/${t}^{commit}`])}async function s(e,i){let s=a(e,i);if(!s)return null;if(!n(e,["remote","get-url","origin"]))return{commit:s,fromOrigin:!1};await new Promise(r=>(0,t.execFile)("git",["fetch","--quiet","origin",`refs/heads/${i}:refs/remotes/origin/${i}`],{cwd:e,timeout:2e4,env:{...process.env,GIT_TERMINAL_PROMPT:"0"}},()=>r()));let o=n(e,["rev-parse","--verify","--quiet",`refs/remotes/origin/${i}^{commit}`]);if(!o||o===s)return{commit:s,fromOrigin:!1};try{return r(e,["merge-base","--is-ancestor",s,o]),{commit:o,fromOrigin:!0}}catch{return{commit:s,fromOrigin:!1}}}e.s(["m",0,a,"I",0,function(e){for(let t of[n(e,["symbolic-ref","--quiet","--short","refs/remotes/origin/HEAD"])?.replace(/^origin\//,""),"main","master"])if(t&&a(e,t))return t;return n(e,["symbolic-ref","--quiet","--short","HEAD"])},"Y",0,s])},37857,e=>{"use strict";async function t(){let t,{chromium:r}=await e.A(64351);for(let e of[void 0,"chrome","msedge"])try{return await r.launch(e?{channel:e}:{})}catch(e){t??=e}throw t}e.s(["f",0,t])},16806,e=>{"use strict";let t=/^(__NEXT|NEXT_|INNGEST|TURBOPACK|NODE_ENV$|PORT$|HOSTNAME$|FACTORY_|DATABASE_URL|LOCAL_DATABASE_URL$|NEON_|R2_)/;e.s(["f",0,function(e={},r=process.env){let n={};for(let[e,i]of Object.entries(r))t.test(e)||(n[e]=i);return{...n,...e}}])},65080,e=>e.a(async(t,r)=>{try{var n=e.i(74533),i=e.i(2157),a=e.i(60526),s=e.i(50227),o=e.i(75225),l=e.i(49129),c=e.i(24924),u=e.i(92335),f=e.i(55372),d=e.i(40855),h=e.i(28033),p=e.i(29420),w=e.i(58096),m=e.i(18536),y=e.i(82283),g=e.i(64950),b=e.i(30188),v=e.i(77954),S=t([c,f,w,g,v]);[c,f,w,g,v]=S.then?(await S)():S;class z extends Error{status;kind;constructor(e,t,r){super(e),this.status=t,this.kind=r,this.name="DeliveryError"}}let H=(e,t,r)=>(0,n.execFileSync)("git",t,{cwd:e,encoding:"utf8",input:r,stdio:["pipe","pipe","pipe"],maxBuffer:0x4000000}).trim();async function k(e){let t=(await c.r.select().from(u.B).where((0,o.u)(u.B.id,e)))[0];if(!t)return null;let r=await (0,v.v)(e);return{run:t,passedBy:r,eligible:"completed"===t.status&&null!==r&&!!t.worktreePath&&!!t.baseCommit}}async function x(e,t){let r=(await c.r.select().from(u.f).where((0,o.b)((0,o.u)(u.f.runId,e),(0,o.u)(u.f.type,t))).orderBy((0,l.A)(u.f.sequence)))[0];return r?JSON.parse(r.payloadJson):null}async function I(e){return(await (0,g.I)(e))?.repoPath??null}function $(e){if(!e)return null;try{return H(e,["symbolic-ref","--quiet","--short","HEAD"])||null}catch{return null}}function j(e){try{return H(e,["remote","get-url","origin"]).trim()||null}catch{return null}}async function P(e){var t;let r=await k(e);if(!r)throw new z(y.f.errors.runNotFound,404);let n=await x(e,"run.kept"),i=await x(e,"run.delivered"),a=await x(e,"run.pushed"),s=await (0,g.D)(e),o=await I(r.run.projectId);return{hasRemote:s.here&&(t=o)?null!==j(t):null,githubSkipped:!!s.here&&function(e){if(!e)return!1;try{return"off"===H(e,["config","--local","--get",w.A]).trim()}catch{return!1}}(o),here:s.here,machine:s.machine,eligible:r.eligible,passedBy:r.passedBy,kept:!!n,delivered:!!i,branch:n?.branch??r.run.branch,commit:i?.commit??n?.commit??null,files:i?.files??n?.files??[],appliedTo:i?.appliedTo??null,current:$(o),returnTo:(await x(e,"run.switched"))?.from??null,pushed:null!==a&&a.branch===(n?.branch??r.run.branch),pullRequestUrl:a?.pullRequestUrl??null,autoShip:await E(e)}}async function E(e){let t=(await c.r.select().from(u.f).where((0,o.b)((0,o.u)(u.f.runId,e),(0,o.u)(u.f.type,"run.auto_ship"))).orderBy((0,l.A)(u.f.sequence)))[0];if(!t)return null;let r=JSON.parse(t.payloadJson);return{state:r.state??"started",step:r.step??null,reason:r.reason??null,message:r.message??null,at:t.createdAt}}function _(e,t,r="person"){let n=e.worktreePath;if(H(n,["add","-A"]),""!==H(n,["diff","--cached","--name-only"])){let i=e.request.replace(/\s+/g," ").trim(),a="app"===r?`Made by an agent in Plaincrew, run ${e.id}. ${y.f.delivery.passedOnItsOwn}`:`Made by an agent in Plaincrew, run ${e.id}, and approved by a person.`,s=(0,d.h)(i);H(n,["-c","user.name=Plaincrew","-c","user.email=plaincrew@localhost","commit","-q","--no-verify","-m",t?`${(0,d.h)(t.subject)}
|
|
7
|
+
|
|
8
|
+
${t.body?`${(0,d.h)(t.body)}
|
|
9
|
+
|
|
10
|
+
`:""}Asked for: ${(0,d.l)(s,500)}
|
|
11
|
+
|
|
12
|
+
${a}`:`${(0,d.l)(s,72)}
|
|
13
|
+
|
|
14
|
+
${a}`])}return H(n,["rev-parse","HEAD"])}async function A(e){return await x(e,"run.delivered")!==null}let J=/^[A-Za-z0-9][A-Za-z0-9._/-]{0,99}$/;async function B(e){let t=(await c.r.select().from(u.B).where((0,o.u)(u.B.id,e)))[0],r=t?.worktreePath;if(!t||!r)return[];try{let e=t.deliveryBase??t.baseCommit,n=H(r,["diff","--name-only",e]).split("\n"),i=H(r,["ls-files","--others","--exclude-standard"]).split("\n");return[...new Set([...n,...i].filter(Boolean))].sort()}catch{return[]}}async function T(e){let t=(await c.r.select().from(u.B).where((0,o.u)(u.B.id,e)))[0],r=t?.worktreePath;if(!t||!r)return"";try{let e=t.deliveryBase??t.baseCommit,n=H(r,["diff",e]),i=H(r,["ls-files","--others","--exclude-standard"]).split("\n").filter(Boolean).map(e=>`new file: ${e}`);return(0,d.h)([n,...i].join("\n"))}catch{return""}}async function F(e){return(await c.r.select().from(u.B).where((0,o.u)(u.B.id,e)))[0]?.request??null}async function R(e,t={}){return(0,b.f)(e,async()=>{let r=await (0,g.b)(e);if(r)throw new z(r,409);let i=await k(e);if(!i)throw new z(y.f.errors.runNotFound,404);if(!i.eligible)throw new z(y.f.delivery.notEligible,409);if(await x(e,"run.kept"))return P(e);let{run:a}=i,s=a.worktreePath,l=t.name?.trim()||null;if(null!==l&&!function(e){if(!J.test(e)||e.includes("..")||e.includes("//")||e.endsWith("/")||e.endsWith(".lock")||e.endsWith("."))return!1;try{return(0,n.execFileSync)("git",["check-ref-format","--branch",e],{stdio:"ignore"}),!0}catch{return!1}}(l))throw new z(y.f.delivery.badBranchName,400);let d=a.branch??H(s,["rev-parse","--abbrev-ref","HEAD"]),p=e=>""!==H(s,["branch","--list",e]);if(null!==l&&l!==d&&p(l))throw new z(y.f.delivery.branchExists(l),409);let w=_(a,t.message,i.passedBy??"person"),b=H(s,["diff","--name-only",a.deliveryBase??a.baseCommit,w]).split("\n").filter(Boolean);if(0===b.length)throw new z(y.f.delivery.nothing,409);let v=null===l?await O(a,s,w):null;v&&(await c.r.update(u.B).set({branch:v}).where((0,o.u)(u.B.id,a.id)),d=v);let S=null===v&&(d.startsWith("factory/")||d===(0,m.E)(a.id,a.request)),I=l??(S?t.fallbackName??(0,h.k)(a.id,(0,h.R)(a.request)??"change"):d);return I===d||null===l&&p(I)||(H(s,["branch","-m",I]),await c.r.update(u.B).set({branch:I}).where((0,o.u)(u.B.id,a.id)),d=I),await c.r.transaction(async t=>{await (0,f.f)({runId:e,type:"run.kept",payload:{branch:d,commit:w,files:b}},t)}),P(e)})}async function N(e,t){let r=(await c.r.select().from(u.f).where((0,o.b)((0,o.u)(u.f.runId,e),(0,o.u)(u.f.type,"run.pr_opened"))).orderBy((0,l.A)(u.f.sequence)).limit(1))[0],i=r?JSON.parse(r.payloadJson).number:void 0;if("number"!=typeof i)return!1;try{let e=(0,n.execFileSync)("gh",["pr","view",String(i),"--json","state"],{cwd:t,encoding:"utf8",timeout:15e3,stdio:["ignore","pipe","ignore"]});if("MERGED"!==JSON.parse(e).state)return!1}catch{return!1}return await c.r.transaction(async t=>void await (0,f.f)({runId:e,type:"run.merged",payload:{number:i}},t)),!0}async function O(e,t,r){if(!e.parentRunId)return null;let n=await x(e.parentRunId,"run.kept");if(!n?.branch||await x(e.parentRunId,"run.merged")||await N(e.parentRunId,t))return null;let i=n.branch;try{let n=H(t,["rev-parse","--verify","--quiet",`refs/heads/${i}^{commit}`]);H(t,["merge-base","--is-ancestor",n,r]);let a=(await c.r.select().from(u.B).where((0,o.u)(u.B.id,e.parentRunId)))[0];if(a?.worktreePath)try{H(a.worktreePath,["symbolic-ref","--quiet","--short","HEAD"])===i&&H(a.worktreePath,["checkout","-q","--detach"])}catch{}return H(t,["checkout","-q","-B",i,r]),i}catch{return null}}async function M(e,t={}){return(0,b.f)(e,async()=>{let r=await (0,g.b)(e);if(r)throw new z(r,409);let n=await k(e);if(!n)throw new z(y.f.errors.runNotFound,404);if(!n.eligible)throw new z(y.f.delivery.notEligible,409);if(await x(e,"run.delivered"))return P(e);let l=await (0,g.I)(n.run.projectId),d=l?.repoPath;if(!d)throw new z(y.f.run.noRepository,409);if(""!==H(d,["status","--porcelain"]))throw new z(y.f.delivery.dirty,409);let h=await R(e,t),p=(await c.r.select().from(u.B).where((0,o.u)(u.B.id,e)))[0],w=p.worktreePath,m=p.deliveryBase??p.baseCommit,b=h.commit,v=h.files,S=H(w,["diff","--binary",m,b]),I=(0,i.mkdtempSync)((0,s.join)((0,a.tmpdir)(),"factory-delivery-")),$=(0,s.join)(I,"change.patch");try{(0,i.writeFileSync)($,S.endsWith("\n")?S:`${S}
|
|
15
|
+
`);try{H(d,["apply","--check","--whitespace=nowarn",$])}catch{throw new z(y.f.delivery.conflict(p.branch??""),409)}H(d,["apply","--whitespace=nowarn",$])}finally{(0,i.rmSync)(I,{recursive:!0,force:!0})}return await c.r.transaction(async t=>{await (0,f.f)({runId:e,type:"run.delivered",payload:{branch:h.branch,commit:b,files:v,appliedTo:d}},t)}),P(e)})}function C(e,t){if(""!==H(e,["status","--porcelain","--untracked-files=no"]))throw new z(y.f.delivery.dirty,409);try{H(e,["checkout","-q",t])}catch{throw new z(y.f.delivery.switchFailed(t),409)}}async function D(e){return(0,b.f)(e,async()=>{let t=await (0,g.b)(e);if(t)throw new z(t,409);let r=await k(e);if(!r)throw new z(y.f.errors.runNotFound,404);let n=await x(e,"run.kept");if(!n?.branch)throw new z(y.f.delivery.keepFirst,409);let i=await I(r.run.projectId);if(!i)throw new z(y.f.run.noRepository,409);let a=$(i);if(a===n.branch)return P(e);if(!a)throw new z(y.f.delivery.notOnBranch,409);if(""!==H(i,["status","--porcelain","--untracked-files=no"]))throw new z(y.f.delivery.dirty,409);let s=r.run.worktreePath;if(s)try{H(s,["checkout","-q","--detach"])}catch{}return C(i,n.branch),await c.r.transaction(async t=>void await (0,f.f)({runId:e,type:"run.switched",payload:{branch:n.branch,from:a}},t)),P(e)})}async function q(e){return(0,b.f)(e,async()=>{let t=await (0,g.b)(e);if(t)throw new z(t,409);let r=await k(e);if(!r)throw new z(y.f.errors.runNotFound,404);let n=await x(e,"run.switched");if(!n?.from)throw new z(y.f.delivery.neverSwitched,409);let i=await I(r.run.projectId);if(!i)throw new z(y.f.run.noRepository,409);return $(i)!==n.from&&(C(i,n.from),await c.r.transaction(async t=>void await (0,f.f)({runId:e,type:"run.switched_back",payload:{branch:n.from}},t))),P(e)})}let G=(e,t)=>new Promise((r,i)=>{(0,n.execFile)("git",t,{cwd:e,timeout:6e4,env:{...process.env,GIT_TERMINAL_PROMPT:"0"}},(e,t,n)=>e?i(Error(String(n||e.message))):r(String(t).trim()))});async function L(e){return(0,b.f)(e,async()=>{let t,r=await (0,g.b)(e);if(r)throw new z(r,409);let n=await k(e);if(!n)throw new z(y.f.errors.runNotFound,404);let i=await x(e,"run.kept");if(!i?.branch)throw new z(y.f.delivery.keepFirst,409);let a=i.branch,s=await I(n.run.projectId);if(!s)throw new z(y.f.run.noRepository,409);let o=j(s);if(null===o)throw new z(y.f.delivery.noRemote,409,"no_connection");try{let e=(0,p.I)(s);e&&e!==a&&await G(s,["ls-remote","--heads","origin",`refs/heads/${e}`])===""&&await G(s,["push","--porcelain","origin",`refs/heads/${e}:refs/heads/${e}`]),await G(s,["push","--porcelain","origin",`refs/heads/${a}:refs/heads/${a}`])}catch(t){let e=(0,d.h)(String(t.message)).replace(/[a-z]+:\/\/[^\s]*@/gi,"").trim().split("\n").filter(Boolean).slice(-2).join(" ");throw new z(y.f.delivery.pushFailed((0,d.l)(e,240)),409)}try{H(s,["branch","--set-upstream-to",`origin/${a}`,a])}catch{}let l=(t=/^(?:https?:\/\/(?:[^@/]+@)?github\.com\/|git@github\.com:|ssh:\/\/git@github\.com\/)([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+?)(?:\.git)?\/?$/.exec(o.trim()))?`https://github.com/${t[1]}/${t[2]}/pull/new/${a}`:null,u=await x(e,"run.pushed");return(u?.branch!==a||(u.pullRequestUrl??null)!==l)&&await c.r.transaction(async t=>void await (0,f.f)({runId:e,type:"run.pushed",payload:{branch:a,pullRequestUrl:l}},t)),P(e)})}e.s(["E",0,z,"D",0,E,"Q",0,B,"s",0,M,"Z",0,P,"w",0,_,"$",0,R,"J",0,function(e){try{return H(e,["remote","get-url","--push","origin"]).trim()||null}catch{return null}},"K",0,j,"c",0,T,"y",0,L,"t",0,F,"P",0,q,"V",0,D,"_",0,function(e){let t=e.worktreePath;if(H(t,["add","-A"]),""!==H(t,["diff","--cached","--name-only"])){let r=e.request.replace(/\s+/g," ").trim();H(t,["-c","user.name=Plaincrew","-c","user.email=plaincrew@localhost","commit","-q","--no-verify","-m",`Unfinished: ${(0,d.l)((0,d.h)(r),60)}
|
|
16
|
+
|
|
17
|
+
Left by an agent in Plaincrew, run ${e.id}, which stopped before a person approved it.`])}return H(t,["rev-parse","HEAD"])},"A",0,A]),r()}catch(e){r(e)}},!1),55372,e=>e.a(async(t,r)=>{try{var n=e.i(75225),i=e.i(49129),a=e.i(60338),s=e.i(18899),o=e.i(6561),l=e.i(24924),c=e.i(92335),u=t([l]);[l]=u.then?(await u)():u;class m extends Error{runId;constructor(e){super(`Cannot append event: run ${e} does not exist`),this.runId=e,this.name="RunNotFoundError"}}class y extends Error{constructor(e){super(`${e} event requires a payload with a non-empty string blockId`),this.name="InvalidEventPayloadError"}}function f(e){return{id:e.id,runId:e.runId,nodeRunId:e.nodeRunId,sequence:e.sequence,type:e.type,payload:JSON.parse(e.payloadJson),createdAt:e.createdAt}}async function d(e,t){if(t.type.startsWith("node.")){let e=t.payload?.blockId;if("string"!=typeof e||""===e)throw new y(t.type)}let r=(await e.select({projectId:c.B.projectId}).from(c.B).where((0,n.u)(c.B.id,t.runId)))[0];if(!r)throw new m(t.runId);await h(e,t.runId);let i=(await e.select({m:(0,a.y)(c.f.sequence)}).from(c.f).where((0,n.u)(c.f.runId,t.runId)))[0];return f((await e.insert(c.f).values({id:(0,o.v)(),projectId:r.projectId,runId:t.runId,nodeRunId:t.nodeRunId??null,sequence:(i?.m??0)+1,type:t.type,payloadJson:JSON.stringify(t.payload??{}),createdAt:new Date().toISOString()}).returning())[0])}async function h(e,t){await e.execute(s.B`select pg_advisory_xact_lock(hashtext(${t}))`)}async function p(e,t){return t?d(t,e):l.r.transaction(t=>d(t,e))}async function w(e,t){return(await l.r.select().from(c.f).where((0,n.b)((0,n.u)(c.f.runId,e),(0,n.H)(c.f.sequence,t))).orderBy((0,i.M)(c.f.sequence))).map(f)}e.s(["q",0,p,"f",0,function(e,t){return d(t,e)},"J",0,w,"g",0,h]),r()}catch(e){r(e)}},!1),58096,e=>e.a(async(t,r)=>{try{var n=e.i(74533),i=e.i(50227),a=e.i(75225),s=e.i(24924),o=e.i(92335),l=e.i(44586),c=e.i(29420),u=e.i(64950),f=e.i(40855),d=e.i(82283),h=t([s,u]);[s,u]=h.then?(await h)():h;class j extends Error{status;constructor(e,t=409){super(e),this.status=t,this.name="ConnectError"}}let P=(e,t,r)=>new Promise((i,a)=>(0,n.execFile)(e,t,{cwd:r,timeout:12e4,maxBuffer:8388608,env:{...process.env,GH_PROMPT_DISABLED:"1",GIT_TERMINAL_PROMPT:"0"}},(e,t,r)=>e?a(Object.assign(Error(String(r||e.message)),{code:e.code})):i(String(t)))),E=/^(https:\/\/github\.com\/[\w.-]+\/[\w.-]+?(\.git)?\/?|git@github\.com:[\w.-]+\/[\w.-]+?(\.git)?)$/,_=d.f.delivery.connect;function p(e){let t=e instanceof Error?e.message:String(e);return e?.code==="ENOENT"?_.noGh:/gh auth login|not logged in|authentication/i.test(t)?_.notLoggedIn:/name already exists/i.test(t)?_.nameTaken:/repository not found|could not read from remote|does not appear to be a git repository/i.test(t)?_.notFound:/rejected|fetch first|non-fast-forward/i.test(t)?_.notEmpty:_.failed((0,f.l)((0,f.h)(e instanceof Error?e.message:String(e)).trim(),300))}function w(e,t){let r=e.trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._-]/g,"").replace(/^[.-]+/,"").slice(0,100);if((0,l.f)(r))return r;let n=t?(0,i.basename)(t).replace(/[^A-Za-z0-9._-]/g,"-").slice(0,100):"";return(0,l.f)(n)?n:"my-project"}let A="plaincrew.github";async function m(e,t){return t("git",["config","--local","--get",A],e).then(e=>"off"===e.trim(),()=>!1)}async function y(e,t,r){t?await r("git",["config","--local",A,"off"],e):await r("git",["config","--local","--unset-all",A],e).catch(()=>void 0)}let B=(e,t)=>t("git",["remote","get-url","origin"],e).then(e=>e.trim()||null,()=>null);async function g(e,t,r){let n=await B(e,r);if(n)return{url:n};let i=await b(e,t,r);return await y(e,!1,r),i}async function b(e,t,r){let n=(0,c.I)(e)??"main";if("url"in t){let i,a=(i=t.url.trim(),E.test(i)?i.replace(/\/$/,""):null);if(!a)throw new j(_.badLink,400);await r("git",["remote","add","origin",a],e);try{await r("git",["push","-u","origin",n],e)}catch(t){throw await r("git",["remote","remove","origin"],e).catch(()=>void 0),new j(p(t))}return{url:a}}let i=t.name?.trim()||w("",e);if(!(0,l.f)(i))throw new j(_.badName,400);try{await r("gh",["repo","create",i,"public"===t.create?"--public":"--private","--source",".","--remote","origin"],e),await r("git",["push","-u","origin",n],e)}catch(e){throw new j(p(e))}return{url:await B(e,r)}}async function v(e,t,r=P){let n=await (0,u.I)(e),i=n?.repoPath;if(!i)throw new j(_.noFolder);let a="create"in t&&!t.name?.trim()?{...t,name:w(n.name,i)}:t;return g(i,a,r)}async function S(e,t,r=P){let n=(await s.r.select().from(o.B).where((0,a.u)(o.B.id,e)))[0];if(!n)throw new j(d.f.errors.runNotFound,404);return v(n.projectId,t,r)}async function k(e,t=P){let r=await (0,u.I)(e),n=r?.repoPath??null,i=w(r?.name??"",n);if(!n)return{url:null,here:!1,skipped:!1,suggestedName:i};let a=await B(n,t);return{url:a?a.replace(/^git@github\.com:/,"https://github.com/").replace(/\.git$/,""):null,here:!0,skipped:!a&&await m(n,t),suggestedName:i}}async function x(e,t=P){let r=(await s.r.select().from(o.B).where((0,a.u)(o.B.id,e)))[0];if(!r)throw new j(d.f.errors.runNotFound,404);return k(r.projectId,t)}async function I(e,t,r=P){let n=(await (0,u.I)(e))?.repoPath;if(!n)throw new j(_.noFolder);return await y(n,t,r),k(e,r)}async function $(e,t,r=P){let n=(await s.r.select().from(o.B).where((0,a.u)(o.B.id,e)))[0];if(!n)throw new j(d.f.errors.runNotFound,404);return I(n.projectId,t,r)}e.s(["Y",0,j,"A",0,A,"c",0,S,"J",0,v,"$",0,k,"v",0,x,"U",0,I,"B",0,$]),r()}catch(e){r(e)}},!1),62534,e=>{"use strict";var t=e.i(2157),r=e.i(50227),n=e.i(32374);function i(e){let n=n=>(0,t.existsSync)((0,r.join)(e,n));return n("package.json")?n("pnpm-lock.yaml")?"pnpm install --frozen-lockfile --prefer-offline":n("yarn.lock")?"yarn install --frozen-lockfile":n("bun.lockb")||n("bun.lock")?"bun install --frozen-lockfile":n("package-lock.json")?"npm ci --prefer-offline --no-audit --no-fund":"npm install --no-package-lock --no-audit --no-fund":null}async function a(e,t){let r=i(e);if(!r)return null;let a=new AbortController,s=setTimeout(()=>a.abort(),6e5),o=()=>a.abort();t?.addEventListener("abort",o,{once:!0});try{let t=await (0,n.P)(r,e,a.signal);return{command:r,ok:t.started&&0===t.exitCode,durationMs:t.durationMs,outputTail:t.outputTail}}finally{clearTimeout(s),t?.removeEventListener("abort",o)}}e.s(["d",0,i,"F",0,a])},64950,e=>e.a(async(t,r)=>{try{var n=e.i(2157),i=e.i(60526),a=e.i(50227),s=e.i(75225),o=e.i(6561),l=e.i(24924),c=e.i(92335),u=e.i(82283),f=e.i(91138),d=t([l]);[l]=d.then?(await d)():d;let b=globalThis;function h(){if(process.env.FACTORY_MACHINE_ID)return{id:process.env.FACTORY_MACHINE_ID,name:process.env.FACTORY_MACHINE_NAME??"this computer"};if(b.__factoryMachine)return b.__factoryMachine;let e=process.env.FACTORY_MACHINE_FILE??(0,a.join)(f.f,"machine.json"),t=null;if((0,n.existsSync)(e))try{let r=JSON.parse((0,n.readFileSync)(e,"utf8"));"string"==typeof r.id&&"string"==typeof r.name&&(t={id:r.id,name:r.name})}catch{t=null}return t||(t={id:(0,o.v)(),name:(0,i.hostname)().replace(/\.local$/,"")||"this computer"},(0,n.mkdirSync)((0,a.dirname)(e),{recursive:!0}),(0,n.writeFileSync)(e,JSON.stringify(t,null,2))),b.__factoryMachine=t}async function p(e){return e?(await l.r.select({name:c.u.name}).from(c.u).where((0,s.u)(c.u.id,e)))[0]?.name??null:null}async function w(e,t=l.r){let r=(await t.select().from(c.c).where((0,s.u)(c.c.id,e)))[0];if(!r)return;let n=(await t.select().from(c.l).where((0,s.b)((0,s.u)(c.l.projectId,e),(0,s.u)(c.l.machineId,h().id))))[0];return n?{...r,repoPath:n.repoPath,baseStatus:n.baseStatus,baseCommit:n.baseCommit,baseLockHash:n.baseLockHash,baseMessage:n.baseMessage,baseUpdatedAt:n.baseUpdatedAt}:r}async function m(e,t,r=l.r){let n=h().id;if((await r.select().from(c.l).where((0,s.b)((0,s.u)(c.l.projectId,e),(0,s.u)(c.l.machineId,n))))[0])return void await r.update(c.l).set(t).where((0,s.b)((0,s.u)(c.l.projectId,e),(0,s.u)(c.l.machineId,n)));let i=(await r.select().from(c.c).where((0,s.u)(c.c.id,e)))[0];await r.insert(c.l).values({projectId:e,machineId:n,repoPath:i?.repoPath??null,baseStatus:i?.baseStatus??"none",baseCommit:i?.baseCommit??null,baseLockHash:i?.baseLockHash??null,baseMessage:i?.baseMessage??null,baseUpdatedAt:i?.baseUpdatedAt??null,...t})}async function y(e){let t=(await l.r.select({machineId:c.B.machineId}).from(c.B).where((0,s.u)(c.B.id,e)))[0],r=t?.machineId??null;return{here:null!==r&&r===h().id,machineId:r,machine:await p(r)}}async function g(e){let t=await y(e);return t.here?null:u.f.machine.elsewhere(t.machine)}e.s(["b",0,g,"I",0,w,"D",0,y,"J",0,m,"j",0,h]),r()}catch(e){r(e)}},!1),77954,e=>e.a(async(t,r)=>{try{var n=e.i(75225),i=e.i(24924),a=e.i(92335),s=t([i]);async function o(e,t=i.r){if((await t.select().from(a.a).where((0,n.b)((0,n.u)(a.a.runId,e),(0,n.u)(a.a.decision,"approved"))))[0])return"person";let r=(await t.select().from(a.B).where((0,n.u)(a.B.id,e)))[0];if(!r)return null;let s=(await t.select().from(a.G).where((0,n.u)(a.G.id,r.versionId)))[0];if(!s)return null;let l=JSON.parse(s.graphJson).blocks.filter(e=>"human"===e.kind).map(e=>e.id);if(0===l.length)return null;let c=new Set((await t.select().from(a.r).where((0,n.b)((0,n.u)(a.r.runId,e),(0,n.u)(a.r.state,"passed")))).filter(e=>l.includes(e.blockId)).map(e=>e.id));return(await t.select().from(a.f).where((0,n.b)((0,n.u)(a.f.runId,e),(0,n.u)(a.f.type,"node.completed")))).some(e=>{if(!e.nodeRunId||!c.has(e.nodeRunId))return!1;try{return!0===JSON.parse(e.payloadJson).autoApproved}catch{return!1}})?"app":null}async function l(e,t=i.r){let r=new Set;if(0===e.length)return r;let s=await t.select({id:a.B.id,versionId:a.B.versionId}).from(a.B).where((0,n.b)((0,n.y)(a.B.id,e),(0,n.u)(a.B.status,"completed")));if(0===s.length)return r;let o=s.map(e=>e.id),c=new Set((await t.select({runId:a.a.runId}).from(a.a).where((0,n.b)((0,n.y)(a.a.runId,o),(0,n.u)(a.a.decision,"approved")))).map(e=>e.runId)),u=new Map;for(let e of(await t.select().from(a.G).where((0,n.y)(a.G.id,[...new Set(s.map(e=>e.versionId))]))))try{u.set(e.id,JSON.parse(e.graphJson).blocks.filter(e=>"human"===e.kind).map(e=>e.id))}catch{u.set(e.id,[])}let f=new Map(s.map(e=>[e.id,e.versionId])),d=new Map;for(let e of(await t.select().from(a.r).where((0,n.b)((0,n.y)(a.r.runId,o),(0,n.u)(a.r.state,"passed")))))u.get(f.get(e.runId)??"")?.includes(e.blockId)&&d.set(e.id,e.runId);if(0===d.size)return r;for(let e of(await t.select().from(a.f).where((0,n.b)((0,n.y)(a.f.nodeRunId,[...d.keys()]),(0,n.u)(a.f.type,"node.completed")))))if(!(!e.nodeRunId||!d.has(e.nodeRunId)||c.has(e.runId)))try{!0===JSON.parse(e.payloadJson).autoApproved&&r.add(e.runId)}catch{}return r}[i]=s.then?(await s)():s,e.s(["v",0,o,"o",0,l]),r()}catch(e){r(e)}},!1),20195,e=>e.a(async(t,r)=>{try{var n=e.i(16806),i=e.i(74533),a=e.i(2157),s=e.i(61095),o=e.i(50227),l=e.i(75225),c=e.i(24924),u=e.i(92335),f=e.i(62534),d=e.i(40855),h=e.i(32374),p=e.i(82283),w=e.i(64950),m=t([c,w]);[c,w]=m.then?(await m)():m;let _=globalThis.__factoryPreviews??=new Map;function y(e,t){let r;try{r=JSON.parse((0,a.readFileSync)((0,o.join)(e,"package.json"),"utf8"))}catch{return null}if(!r.scripts?.dev)return null;let n={...r.dependencies,...r.devDependencies},i=t=>(0,a.existsSync)((0,o.join)(e,t)),s=i("pnpm-lock.yaml")?"pnpm":i("yarn.lock")?"yarn":i("bun.lockb")||i("bun.lock")?"bun":"npm",l=String(t);return{argv:[..."npm"===s?["npm","run","dev","--"]:"yarn"===s?["yarn","dev"]:[s,"run","dev"],...n.next?["-p",l,"-H","127.0.0.1"]:n.vite?["--port",l,"--host","127.0.0.1","--strictPort"]:[]],installArgv:i("node_modules")?null:[s,"install"]}}let A=Promise.resolve();function g(e,t){e.log=(0,d.l)((0,d.h)((0,h.X)(e.log+t.toString())).slice(-4e3),4e3)}async function b(e,t){let r=Date.now()+18e4;for(;Date.now()<r&&"starting"===t.status&&(!t.child||null===t.child.exitCode);)try{return await fetch(e,{signal:AbortSignal.timeout(3e3)}),!0}catch{await new Promise(e=>setTimeout(e,1e3))}return!1}function v(e,t){if(e?.pid)try{process.kill(-e.pid,t)}catch{}}function S(e){let t=_.get(e);return t?{status:t.status,url:t.url,message:t.message,log:t.log}:{status:"stopped",url:null,message:null,log:""}}let B=globalThis.__factoryPreviewSeen??=new Map,T=globalThis;T.__factoryPreviewWatch||(T.__factoryPreviewWatch=setInterval(()=>void function(e=18e4,t=Date.now()){let r=[];for(let[n,i]of[...B]){let a=_.get(n)?.status;"installing"!==a&&"starting"!==a&&"ready"!==a?B.delete(n):t-i>e&&(E(n),r.push(n))}}(),6e4).unref());let F=globalThis.__factoryPreviewStops??=new Map;async function k(e,t){let r=F.get(e)??0,n=await t();return(F.get(e)??0)===r?n:(E(e),S(e))}async function x(e){let t=await (0,w.b)(e);if(t)throw new N(t);let r=_.get(e);if(r&&"failed"!==r.status&&"stopped"!==r.status)return S(e);if(!(await c.r.select().from(u.B).where((0,l.u)(u.B.id,e)))[0])throw new N(p.f.preview.noWorktree);if(await I(e)){let t={status:"installing",url:null,message:null,log:"",child:null,port:null};return _.set(e,t),(async()=>{let r=Date.now()+R;for(;Date.now()<r&&"installing"===t.status&&await I(e).catch(()=>!1);)await new Promise(e=>setTimeout(e,1e3));if(_.get(e)===t&&"installing"===t.status){_.delete(e);try{await $(e)}catch(r){_.set(e,{...t,status:"failed",message:r instanceof N?r.message:p.f.preview.failed})}}})(),S(e)}return $(e)}let R=24e4;async function I(e){let t=(await c.r.select().from(u.B).where((0,l.u)(u.B.id,e)))[0];return!!t&&("queued"===t.status||"running"===t.status)&&(!(t.worktreePath&&(0,a.existsSync)(t.worktreePath))||"running"===t.status&&!!(0,f.d)(t.worktreePath)&&void 0===(await c.r.select().from(u.f).where((0,l.b)((0,l.u)(u.f.runId,e),(0,l.u)(u.f.type,"run.installed"))))[0])}async function $(e){let t=(await c.r.select().from(u.B).where((0,l.u)(u.B.id,e)))[0];if(!t?.worktreePath||!(0,a.existsSync)(t.worktreePath))throw new N(p.f.preview.noWorktree);let r=await (0,w.I)(t.projectId);return E(`site:${t.projectId}`),j(e,t.worktreePath,r?.repoPath??null)}async function j(e,t,r){let l,c=_.get(e);if(c&&"failed"!==c.status&&"stopped"!==c.status)return S(e);let u=await (A=(l=A.then(()=>new Promise((e,t)=>{let r=n=>{if(n>4400)return t(Error("no free port"));let i=(0,s.createServer)();i.once("error",()=>r(n+1)),i.listen(n,"127.0.0.1",()=>i.close(()=>[..._.values()].some(e=>e.port===n&&"failed"!==e.status&&"stopped"!==e.status)?r(n+1):e(n)))};r(4200)}))).then(()=>new Promise(e=>setTimeout(e,0)),()=>void 0),l),f=y(t,u);if(!f)throw new N(p.f.preview.noDevScript);let d={status:f.installArgv?"installing":"starting",url:null,message:null,log:"",child:null,port:u};_.set(e,d),r&&function(e,t){let r=[];for(let n of(0,a.readdirSync)(e))!(!/^\.env(\..+)?$/.test(n)||/\.example$|\.sample$|\.template$/.test(n))&&((0,a.existsSync)((0,o.join)(t,n))||((0,a.copyFileSync)((0,o.join)(e,n),(0,o.join)(t,n)),r.push(n)))}(r,t);let h=(0,n.f)({NODE_ENV:"development",PORT:String(u),HOST:"127.0.0.1",HOSTNAME:"127.0.0.1",BROWSER:"none"});return(async()=>{if(f.installArgv){var e;let r=await (e=f.installArgv,new Promise(r=>{let n=(0,i.spawn)(e[0],e.slice(1),{cwd:t,env:h,detached:!0,stdio:["ignore","pipe","pipe"]});d.child=n,n.stdout?.on("data",e=>g(d,e)),n.stderr?.on("data",e=>g(d,e)),n.once("error",()=>r(null)),n.once("close",e=>r(e))}));if("stopped"===d.status)return;if(0!==r){d.status="failed",d.message=p.f.preview.installFailed;return}d.status="starting"}let r=(0,i.spawn)(f.argv[0],f.argv.slice(1),{cwd:t,env:h,detached:!0,stdio:["ignore","pipe","pipe"]});d.child=r,r.stdout?.on("data",e=>g(d,e)),r.stderr?.on("data",e=>g(d,e)),r.once("close",()=>{("starting"===d.status||"ready"===d.status)&&(d.status="failed",d.message=p.f.preview.exited)});let n=`http://127.0.0.1:${u}/`;await b(n,d)?(d.status="ready",d.url=n):"starting"===d.status&&(d.status="failed",d.message=p.f.preview.neverServed,v(r,"SIGTERM"))})(),S(e)}async function P(e,t=3e5){let r=Date.now()+t;for(;Date.now()<r;){let t=S(e);if("ready"===t.status)return t.url;if("failed"===t.status||"stopped"===t.status)break;await new Promise(e=>setTimeout(e,1e3))}return null}function E(e){F.set(e,(F.get(e)??0)+1),B.delete(e);let t=_.get(e);if(!t)return;t.status="stopped",t.url=null;let r=t.child;v(r,"SIGTERM"),setTimeout(()=>v(r,"SIGKILL"),3e3).unref()}class N extends Error{}let O=globalThis;O.__factoryPreviewExitHook||(O.__factoryPreviewExitHook=!0,process.once("exit",()=>{for(let e of _.values())v(e.child,"SIGKILL")})),e.s(["L",0,N,"n",0,y,"h",0,S,"s",0,e=>k(e,()=>x(e)),"O",0,j,"D",0,E,"m",0,k,"q",0,P,"i",0,function(e){B.set(e,Date.now())}]),r()}catch(e){r(e)}},!1),40855,e=>{"use strict";let t="[redacted]",r=[[/-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z ]*PRIVATE KEY-----/g,t],[/\bsk-(?:ant-)?[A-Za-z0-9_-]{16,}/g,t],[/\bgh[pousr]_[A-Za-z0-9]{20,}/g,t],[/\bgithub_pat_[A-Za-z0-9_]{20,}/g,t],[/\bAKIA[0-9A-Z]{16}\b/g,t],[/\bxox[abposr]-[A-Za-z0-9-]{10,}/g,t],[/\b(Bearer)\s+[A-Za-z0-9._~+/=-]{8,}/gi,`$1 ${t}`],[/(["']?[A-Za-z0-9_]*(?:key|token|secret|password|passwd|credential)[A-Za-z0-9_]*["']?\s*[:=]\s*)("[^"]*"|'[^']*'|[^\s"',}]+)/gi,`$1${t}`]],n=/KEY|TOKEN|SECRET|PASSWORD|CREDENTIAL/i,i=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");e.s(["l",0,function(e,t){return e.length<=t?e:`${e.slice(0,t-1)}…`},"h",0,function(e,a=process.env){let s=e;for(let[e,r]of Object.entries(a))r&&!(r.length<8)&&n.test(e)&&(s=s.replace(RegExp(i(r),"g"),t));for(let[e,t]of r)s=s.replace(e,t);return s}])},87345,e=>{"use strict";var t=e.i(74533),r=e.i(2157),n=e.i(50227),i=e.i(82283);let a=/(^|\/)\.env(\.|$)|secret|credential/i,s=[[a,i.f.risk.areas.secrets],[/auth|login|logout|sign-?in|sign-?up|session|password|oauth|jwt|token/i,i.f.risk.areas.auth],[/payment|billing|stripe|checkout|invoice|subscription|paypal|price|pricing/i,i.f.risk.areas.payments],[/migration|(^|\/)(prisma|supabase|drizzle|db|database)\/|schema\.(prisma|sql|ts)$|\.sql$/i,i.f.risk.areas.database],[/(^|\/)(api|server|actions)\/|(^|\/)(middleware|proxy)\.[jt]s$|route\.[jt]sx?$/i,i.f.risk.areas.server],[/(^|\/)(package\.json|pnpm-lock\.yaml|package-lock\.json|yarn\.lock|bun\.lockb?|tsconfig[^/]*\.json)$|\.config\.[cm]?[jt]s$|(^|\/)\.[a-z]+rc(\.[a-z]+)?$/i,i.f.risk.areas.config],[/(^|\/)(\.github|\.gitlab|\.circleci)\/|(^|\/)(dockerfile|docker-compose[^/]*|vercel\.json|vercel\.ts|fly\.toml|netlify\.toml|render\.yaml|procfile)$/i,i.f.risk.areas.deploy]];function o(e,t){let r=e.toLowerCase(),n=t.toLowerCase();return n.endsWith("/")?r.startsWith(n):r===n}function l(e,t,r=[],n=[]){let a,c,u=[],f=e.reduce((e,t)=>e+t.lines,0);for(let t of(0===e.length&&u.push(i.f.risk.nothingChanged),u.push(...(a=[...new Set(r)].flatMap(t=>{let r=e.filter(e=>o(e.path,t));return r.length>0?[i.f.risk.insideCore(r[0].path,t,r.length-1)]:[]})).length>5?[...a.slice(0,5),i.f.risk.moreCore(a.length-5)]:a),u.push(...(c=n.flatMap(t=>{let r=e.find(e=>t.paths.some(t=>o(e.path,t)));return r?[i.f.risk.onDecision(r.path,t.text)]:[]})).length>5?[...c.slice(0,5),i.f.risk.moreDecisions(c.length-5)]:c),e)){let e=s.find(([e])=>e.test(t.path));e&&u.push(i.f.risk.touches(t.path,e[1]))}e.length>8&&u.push(i.f.risk.tooManyFiles(e.length,8)),f>300&&u.push(i.f.risk.tooManyLines(f,300)),t.testsRan?t.testsPassed||u.push(i.f.risk.testsFailed):u.push(i.f.risk.noTests),t.testsChanged&&u.push(i.f.risk.testsChanged),t.reviewOpen&&u.push(i.f.risk.reviewStillOpen),t.reviewUnchecked&&u.push(i.f.risk.fixUnchecked),t.reviewUnreadable&&u.push(i.f.risk.reviewUnreadable);let d=0===u.length?"low":"high",h=t.testsChanged||!t.testsRan,p="high"===d&&h&&u.every(e=>e===i.f.risk.noTests||e===i.f.risk.testsChanged);return{level:d,reasons:"low"===d?[i.f.risk.lowBecause(e.length,f)]:u,files:e.map(e=>e.path),linesChanged:f,...p?{onlyTests:p}:{}}}e.s(["Q",0,a,"y",0,s,"r",0,function(e,a,s,o=[],c=[]){try{return l(function(e,i){let a=r=>(0,t.execFileSync)("git",r,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","pipe"]}),s=[];for(let e of a(["diff","--numstat","-z","--no-renames",i]).split("\0")){let[t,r,...n]=e.split(" "),i=n.join(" ");if(!i)continue;let a=e=>void 0===e||"-"===e?1:Number(e);s.push({path:i,lines:a(t)+a(r)})}let o=new Set(s.map(e=>e.path));return[...s,...a(["ls-files","--others","--exclude-standard","-z"]).split("\0").filter(e=>e&&!o.has(e)).map(t=>{let i=1;try{i=Math.max(1,(0,r.readFileSync)((0,n.join)(e,t),"utf8").split("\n").length)}catch{}return{path:t,lines:i}})]}(e,a),s,o,c)}catch{return{level:"high",reasons:[i.f.risk.unreadable],files:[],linesChanged:0}}},"F",0,l,"B",0,o])},30188,e=>{"use strict";var t=e.i(78500);let r=globalThis,n=r.__factorySerial??=new Map,i=new t.AsyncLocalStorage;async function a(e,t){let r,a=i.getStore();if(a?.has(e))return t();let s=n.get(e)??Promise.resolve(),o=new Promise(e=>r=e),l=s.then(()=>o);n.set(e,l),await s.catch(()=>void 0);try{return await i.run(new Set([...a??[],e]),t)}finally{r(),n.get(e)===l&&n.delete(e)}}e.s(["f",0,a])},69608,e=>e.a(async(t,r)=>{try{var n=e.i(74533),i=e.i(66680),a=e.i(2157),s=e.i(50227),o=e.i(75225),l=e.i(49129),c=e.i(24924),u=e.i(92335),f=e.i(120),d=e.i(65080),h=e.i(55372),p=e.i(20195),w=e.i(40855),m=e.i(82283),y=e.i(64950),g=e.i(65272),b=e.i(26955),v=e.i(91138),S=e.i(37857),k=t([c,f,d,h,p,y]);[c,f,d,h,p,y]=k.then?(await k)():k;let F=(0,s.join)(v.f,"snapshots"),R=["before-desktop","after-desktop","before-mobile","after-mobile"],N={desktop:{viewport:{width:1440,height:900},deviceScaleFactor:1},mobile:{viewport:{width:390,height:844},deviceScaleFactor:2,isMobile:!0,hasTouch:!0}},O=async(e,t)=>{let r=await (0,S.f)();try{for(let n of["desktop","mobile"]){let i=await r.newContext(N[n]),a=await i.newPage();await a.goto(e,{waitUntil:"load",timeout:12e4}),await a.waitForLoadState("networkidle",{timeout:15e3}).catch(()=>void 0),await a.waitForTimeout(1500),await a.screenshot({path:t[n]}),await i.close()}}finally{await r.close()}},M='[role="tab"]:not([aria-selected="true"]), summary, button[aria-expanded="false"]',C=async(e,t,r)=>{let n=await (0,S.f)();try{let i=await n.newContext(N.desktop),[a,s,o]=[await i.newPage(),await i.newPage(),await i.newPage()],l=async(e,t)=>{await e.goto(t,{waitUntil:"load",timeout:12e4}),await e.waitForLoadState("networkidle",{timeout:15e3}).catch(()=>void 0),await e.waitForTimeout(1200)},c=e=>e.screenshot({animations:"disabled"}),u=(e,t)=>o.evaluate(async([e,t])=>{let r=e=>new Promise((t,r)=>{let n=new Image;n.onload=()=>t(n),n.onerror=()=>r(Error("picture")),n.src=`data:image/png;base64,${e}`}),[n,i]=await Promise.all([r(e),r(t)]);if(n.width!==i.width||n.height!==i.height)return 1;let a=e=>{let t=document.createElement("canvas");t.width=e.width,t.height=e.height;let r=t.getContext("2d");return r.drawImage(e,0,0),r.getImageData(0,0,e.width,e.height).data},[s,o]=[a(n),a(i)],l=0;for(let e=0;e<s.length;e+=4)Math.abs(s[e]-o[e])+Math.abs(s[e+1]-o[e+1])+Math.abs(s[e+2]-o[e+2])>48&&l++;return l/(s.length/4)},[e.toString("base64"),t.toString("base64")]),f=async(e,t,r)=>{let n=e.locator(M),i=r?n.filter({hasText:r}).first():null,a=i&&await i.count()>0?i:n.nth(t);await a.count()!==0&&(await a.click({timeout:4e3}).catch(()=>void 0),await e.waitForLoadState("networkidle",{timeout:8e3}).catch(()=>void 0),await e.waitForTimeout(1200))};if(await Promise.all([l(a,e),l(s,t)]),await u(await c(a),await c(s))>3e-4)return null;let d=(e,t,r)=>o.evaluate(async([e,t,r])=>{let n=e=>new Promise((t,r)=>{let n=new Image;n.onload=()=>t(n),n.onerror=()=>r(Error("picture")),n.src=`data:image/png;base64,${e}`}),[i,a]=await Promise.all([n(e),n(t)]),s=Math.min(i.width,a.width),o=Math.min(i.height,a.height);if(0===s||0===o||Math.max(i.height,a.height)>16e3)return null;let l=e=>{let t=document.createElement("canvas");t.width=s,t.height=o;let r=t.getContext("2d");return r.drawImage(e,0,0),r.getImageData(0,0,s,o).data},[c,u]=[l(i),l(a)],f=Math.max(4,Math.floor(.004*s));for(let e=0;e<o;e++){let t=0;for(let n=e*s*4,i=n+4*s;n<i;n+=4)if(Math.abs(c[n]-u[n])+Math.abs(c[n+1]-u[n+1])+Math.abs(c[n+2]-u[n+2])>48&&++t>=f)return Math.floor(e/r)}return i.height!==a.height?Math.floor(o/r):null},[e.toString("base64"),t.toString("base64"),r]),h=!1;for(let o of["desktop","mobile"]){let c="desktop"===o?i:await n.newContext(N[o]),[u,f]="desktop"===o?[a,s]:[await c.newPage(),await c.newPage()];"desktop"!==o&&await Promise.all([l(u,e),l(f,t)]);let p=e=>e.screenshot({fullPage:!0,animations:"disabled"}),w=await d(await p(u),await p(f),N[o].deviceScaleFactor).catch(()=>null);if(null===w)continue;let m=Math.max(0,w-180);await Promise.all([u,f].map(e=>e.evaluate(e=>window.scrollTo(0,e),m))),await u.waitForTimeout(900),await u.screenshot({path:r.before[o],animations:"disabled"}),await f.screenshot({path:r.after[o],animations:"disabled"}),h=!0}if(h)return"@below";let p=(await s.locator(M).allInnerTexts()).slice(0,6).map(e=>(e.split("\n")[0]??"").trim()),w=null;for(let[r,n]of p.entries()){r>0&&await Promise.all([l(a,e),l(s,t)]),await Promise.all([f(a,r,n),f(s,r,n)]);let i=await u(await c(a),await c(s));i>3e-4&&(!w||i>w.by)&&(w={index:r,name:n,by:i})}if(!w)return null;let m=w;for(let o of["desktop","mobile"]){let c="desktop"===o?i:await n.newContext(N[o]),[u,d]="desktop"===o?[a,s]:[await c.newPage(),await c.newPage()];await Promise.all([l(u,e),l(d,t)]),await Promise.all([f(u,m.index,m.name),f(d,m.index,m.name)]),await u.screenshot({path:r.before[o]}),await d.screenshot({path:r.after[o]})}return m.name||null}finally{await n.close()}},D=/^(?:src\/)?app\/(?:(.*)\/)?page\.(?:tsx|jsx|ts|js|mdx)$/,q=/^(?:src\/)?pages\/(.*)\.(?:tsx|jsx|ts|js|mdx)$/;function x(e){let t=D.exec(e);if(t)return`/${(t[1]??"").split("/").filter(e=>e&&!/^\(.*\)$/.test(e)&&!e.startsWith("@")).join("/")}`;let r=q.exec(e);return r&&!/^(_|api\/)/.test(r[1])?`/${r[1].replace(/(^|\/)index$/,"")}`.replace(/\/$/,"")||"/":null}function I(e){for(let t of e){let e=x(t);if(null!==e&&!e.includes("["))return e}return"/"}let L=/(?:\bfrom\s*|\bimport\s*\(?\s*|\brequire\(\s*)['"]([^'"]+)['"]/g,z=["",".tsx",".ts",".jsx",".js",".mjs",".mdx","/index.tsx","/index.ts","/index.jsx","/index.js"];async function $(e,t,r,n,i=6){let a=e=>e.split(/[?#]/)[0].replace(/(.)\/$/,"$1"),s=new Set(["/"]),o=["/"],l=0;for(let c=0;c<3&&o.length>0;c++){let c=[];for(let u of o){if(l++>=i)return null;let o=await r(new URL(u,t).toString()).catch(()=>[]),f=function(e,t,r){let n=RegExp(`^${e.split("/").map(e=>/^\[\[?\.\.\./.test(e)?".+":e.startsWith("[")?"[^/]+":e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("/")}$`),i=new Set(r);for(let e of t){let t=e.split(/[?#]/)[0].replace(/(.)\/$/,"$1");if(n.test(t)&&!i.has(t))return t}return null}(e,o,n);if(f)return f;for(let e of o.map(a))s.has(e)||n.includes(e)||(s.add(e),c.push(e))}o=c}return null}let H=[/(^|\/)(__tests__|__mocks__|tests?|e2e|cypress|playwright|docs?|\.github|\.husky|\.vscode)\//,/\.(test|spec|stories)\.[cm]?[jt]sx?$/,/\.(md|mdx|txt|snap|lock)$/i,/(^|\/)(package\.json|package-lock\.json|pnpm-lock\.yaml|bun\.lockb?|tsconfig[^/]*\.json|\.[^/]+)$/,/(^|\/)(vitest|jest|playwright|cypress|eslint|prettier|commitlint|lint-staged)\.config\.[cm]?[jt]s$/,/(^|\/)(vitest|jest)\.setup\.[cm]?[jt]sx?$/],J=/(^|\/)__tests__\/|\.(test|spec)\.[cm]?[jt]sx?$/;function j(e){return 0===e.length||e.some(e=>/(^|\/)(app|pages)\//.test(e)&&!J.test(e)||!H.some(t=>t.test(e)))}let G={status:"unneeded",route:null,shots:[],message:null},W=(e,t,r=F)=>(0,s.join)(r,e,`${t}.png`),U=/^[0-9a-f]{16}$/,K=(e,t,r,n=F)=>(0,s.join)(n,e,"kept",t,`${r}.png`);async function P(e,t,r=F,n){if(!R.includes(t))return null;if(void 0!==n){if(!U.test(n))return null;let i=K(e,n,t,r);return(0,a.existsSync)(i)?new Uint8Array((0,a.readFileSync)(i)):(await (0,g.h)()?.get((0,g.q)(e,n,t)))?.body??null}let i=Z(e,t,r);return i?new Uint8Array((0,a.readFileSync)(i)):(await (0,g.h)()?.get((0,g.g)(e,t)))?.body??null}let Z=(e,t,r=F)=>R.includes(t)&&(0,a.existsSync)(W(e,t,r))?W(e,t,r):null,Y=async e=>{let t=(await c.r.select().from(u.B).where((0,o.u)(u.B.id,e)))[0];try{if(t?.worktreePath&&(0,a.existsSync)(t.worktreePath))return(0,i.createHash)("sha256").update(`${V(t)??""}:${(0,b.$)(t.worktreePath)}`).digest("hex").slice(0,16)}catch{}return(0,i.createHash)("sha256").update(await (0,d.c)(e)).digest("hex").slice(0,16)},V=e=>e.baseCommit??e.deliveryBase,X=globalThis.__factorySnapshots??=new Map;async function E(e){let t=X.get(e);if(void 0!==t)return{status:"working",route:null,shots:[],message:t};if(!j(await (0,d.Q)(e)))return G;let r=(await c.r.select().from(u.f).where((0,o.b)((0,o.u)(u.f.runId,e),(0,o.u)(u.f.type,"run.snapshots"))).orderBy((0,l.A)(u.f.sequence)))[0];if(!r)return{status:"none",route:null,shots:[],message:null};let n=JSON.parse(r.payloadJson);if(n.change!==await Y(e))return{status:"none",route:null,shots:[],message:null};let i=n.shots.filter(t=>null!==(0,g.h)()||null!==Z(e,t));return i.length>0?{status:"ready",route:n.route,opened:n.opened??null,shots:i,taken:String(r.sequence),message:null,newProject:!0===n.newProject}:{status:"failed",route:n.route,shots:[],message:n.message}}let Q=async e=>{let t=await (0,S.f)();try{let r=await t.newPage();await r.goto(e,{waitUntil:"load",timeout:12e4}),await r.waitForLoadState("networkidle",{timeout:15e3}).catch(()=>void 0);let n=await r.$$eval("a[href]",e=>e.map(e=>e.href)),i=new URL(e).origin;return n.filter(e=>e.startsWith(`${i}/`)).map(e=>e.slice(i.length))}finally{await t.close()}},ee=(e,t)=>(0,n.execFileSync)("git",t,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","pipe"]}).trim();async function _(e,t,r=F){let n={status:"none",route:null,shots:[],message:null};if(!U.test(t))return n;for(let i of(await c.r.select().from(u.f).where((0,o.b)((0,o.u)(u.f.runId,e),(0,o.u)(u.f.type,"run.snapshots"))).orderBy((0,l.A)(u.f.sequence)))){let s=JSON.parse(i.payloadJson);if(s.change!==t)continue;let o=s.shots.filter(n=>null!==(0,g.h)()||(0,a.existsSync)(K(e,t,n,r)));return o.length>0?{status:"ready",route:s.route,opened:s.opened??null,shots:o,taken:`${i.sequence}-${t}`,message:null,newProject:!0===s.newProject}:n}return n}async function A(e,t=F){let r=(await c.r.select().from(u.B).where((0,o.u)(u.B.id,e)))[0];if(!r)return[];let n=r.request,i=0,s=new Set,f=new Set,d=new Map;for(let r of(await c.r.select().from(u.f).where((0,o.u)(u.f.runId,e)).orderBy((0,l.M)(u.f.sequence)))){let o=JSON.parse(r.payloadJson);"node.plan_decided"===r.type&&r.nodeRunId&&f.add(r.nodeRunId);let l="string"==typeof o.note?o.note.trim():"",c=`${String(o.by)}-${String(o.round)}`;if("node.reopened"===r.type&&"fixes"!==o.by&&"reviewer"!==o.by&&l&&!s.has(c)&&!(r.nodeRunId&&f.has(r.nodeRunId))&&(s.add(c),n=l,i++),"run.snapshots"!==r.type||"string"!=typeof o.change||!U.test(o.change)||!Array.isArray(o.shots))continue;let u=o.change,h=o.shots.filter(r=>null!==(0,g.h)()||(0,a.existsSync)(K(e,u,r,t)));h.length>0&&d.set(i,{change:u,asked:n,shots:h,taken:`${r.sequence}-${u}`,newProject:!0===o.newProject})}return[...d.entries()].sort((e,t)=>e[0]-t[0]).map(([,e])=>e)}async function B(e,t=O,r=F,n=Q,i=C){let l,b=await (0,y.b)(e);if(b)throw new et(b);if(X.has(e))return E(e);let v=(await c.r.select().from(u.B).where((0,o.u)(u.B.id,e)))[0];if(!v?.worktreePath||!(0,a.existsSync)(v.worktreePath))throw new et(m.f.snapshots.noWorkingCopy);let S=await (0,y.I)(v.projectId),k=S?.repoPath,P=V(v);if(!k||!P)throw new et(m.f.snapshots.noWorkingCopy);let _=await (0,d.Q)(e);if(!j(_))return G;let A=await Y(e),R=v.worktreePath,N=_.some(e=>null!==x(e))?_:function(e,t){let r=e=>z.map(t=>e+t).find(e=>t.has(e))??null,n=new Map;for(let[e,i]of t){let t=e.split("/").slice(0,-1);for(let a of i.matchAll(L)){let i=a[1],s=(i.startsWith(".")?[i.split("/").reduce((e,t)=>"."===t||""===t?e:".."===t?e.slice(0,-1):[...e,t],t).join("/")]:/^[@~]\//.test(i)?[`src/${i.slice(2)}`,i.slice(2)]:[]).map(r).find(Boolean);s&&s!==e&&n.set(s,[...n.get(s)??[],e])}}let i=new Set(e),a=[...e];for(;a.length>0;){let e=a.filter(e=>null!==x(e));if(e.length>0)return e;for(let e of a=[...new Set(a.flatMap(e=>n.get(e)??[]))].filter(e=>!i.has(e)))i.add(e)}return[]}(_,function(e){let t=new Map;try{for(let r of ee(e,["ls-files","--cached","--others","--exclude-standard"]).split("\n").filter(e=>/\.(?:[cm]?[jt]sx?|mdx)$/.test(e)).slice(0,4e3))try{let n=(0,a.readFileSync)((0,s.join)(e,r),"utf8");n.length<4e5&&t.set(r,n)}catch{}}catch{}return t}(R)),M=I(N),D=(l=N.map(x).filter(e=>null!==e)).some(e=>!e.includes("["))?null:l[0]??null,q=(0,s.join)(r,e),H=(0,s.join)(q,"before-tree"),J=`${e}:before`,U=["starting","installing","ready"].includes((0,p.h)(e).status);return X.set(e,m.f.snapshots.starting),(async()=>{let o=[],l=null,u=null,d=!1;try{(0,a.mkdirSync)(q,{recursive:!0}),(0,a.existsSync)(H)&&T(k,H),ee(k,["worktree","add","-q","--detach",H,P]),await (0,f.S)(v.projectId,H);let c=null!==(0,p.n)(H,0);d=!c,M=c?I(N):"/",await Promise.all([(0,p.s)(e),c?(0,p.O)(J,H,k):null]),X.set(e,m.f.snapshots.waiting);let[h,w]=await Promise.all([(0,p.q)(e),c?(0,p.q)(J):null]);if(D&&h&&c)try{let e=ee(R,["ls-files"]).split("\n").map(x).filter(e=>null!==e&&!e.includes("["));M=await $(D,h,n,e)??M}catch{}X.set(e,m.f.snapshots.shooting);let y=e=>new URL(M,e).toString();if(w&&(await t(y(w),{desktop:W(e,"before-desktop",r),mobile:W(e,"before-mobile",r)}),o.push("before-desktop","before-mobile")),h&&(await t(y(h),{desktop:W(e,"after-desktop",r),mobile:W(e,"after-mobile",r)}),o.push("after-desktop","after-mobile")),w&&h){X.set(e,m.f.snapshots.looking);let t=t=>({desktop:W(e,`${t}-desktop`,r),mobile:W(e,`${t}-mobile`,r)});u=await i(y(w),y(h),{before:t("before"),after:t("after")}).catch(()=>null)}let b=(0,g.h)();for(let t of((0,a.mkdirSync)((0,s.join)(q,"kept",A),{recursive:!0}),o)){if((0,a.copyFileSync)(W(e,t,r),K(e,A,t,r)),!b)continue;let n=(0,a.readFileSync)(W(e,t,r));await b.put((0,g.g)(e,t),n,"image/png"),await b.put((0,g.q)(e,A,t),n,"image/png")}(!c||w)&&h||(l=m.f.snapshots.didNotStart(h?m.f.snapshots.beforeVersion:m.f.snapshots.afterVersion))}catch(e){l=m.f.snapshots.failed((0,w.l)((0,w.h)(String(e?.message??e)).split("\n")[0]??"",200))}finally{(0,p.D)(J),U||(0,p.D)(e),setTimeout(()=>T(k,H),4e3).unref();try{await c.r.transaction(async t=>void await (0,h.f)({runId:e,type:"run.snapshots",payload:{route:M,opened:u,shots:o,message:l,change:A,newProject:d}},t))}finally{X.delete(e)}}})(),E(e)}function T(e,t){try{ee(e,["worktree","remove","--force",t])}catch{(0,a.rmSync)(t,{recursive:!0,force:!0});try{ee(e,["worktree","prune"])}catch{}}}class et extends Error{}e.s(["P",0,F,"J",0,et,"e",0,B,"c",0,j,"_",0,_,"g",0,P,"S",0,T,"V",0,E,"j",0,A]),r()}catch(e){r(e)}},!1),32374,e=>{"use strict";var t=e.i(74533),r=e.i(2157),n=e.i(50227),i=e.i(16806),a=e.i(40855);let s=/Tests\s+((?:\d+\s+(?:passed|failed|skipped|todo)\s*\|?\s*)+)\((\d+)\)/g,o=/Tests:\s+([^\n]*?)(\d+)\s+total/g,l=(e,t)=>Number(e.match(RegExp(`(\\d+)\\s+${t}`))?.[1]??0),c=/\x1b\[[0-9;?]*[ -\/]*[@-~]/g;function u(e){return e.replace(c,"")}let f=[/(^|\/)package\.json$/,/(^|\/)(__tests__|tests?|spec|e2e)\//,/\.(test|spec)\.[cm]?[jt]sx?$/,/(^|\/)(vitest|jest|playwright|mocha|karma|cypress)\.config\.[cm]?[jt]s$/,/(^|\/)\.mocharc(\.[a-z]+)?$/,/(^|\/)(test_[^/]*|[^/]*_test)\.py$/,/(^|\/)(pytest\.ini|conftest\.py|tox\.ini)$/,/_test\.go$/,/(^|\/)Makefile$/];function d(e){return f.some(t=>t.test(e))}let h=/no test specified/;e.s(["L",0,function(e,r){if(!r)return null;try{let n=r=>(0,t.execFileSync)("git",r,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","pipe"]}),i=n(["diff","--name-only",r]).split("\n"),a=n(["ls-files","--others","--exclude-standard"]).split("\n");return[...new Set([...i,...a].map(e=>e.trim()).filter(Boolean))].filter(d).sort()}catch{return null}},"n",0,function(e){let t=(0,n.join)(e,"package.json");if(!(0,r.existsSync)(t))return null;try{let i=JSON.parse((0,r.readFileSync)(t,"utf8")),a=i.scripts?.test;if("string"!=typeof a||""===a.trim()||h.test(a))return null;let s=t=>(0,r.existsSync)((0,n.join)(e,t));if(s("pnpm-lock.yaml"))return"pnpm test";if(s("yarn.lock"))return"yarn test";if(s("bun.lockb")||s("bun.lock"))return"bun run test";return"npm test"}catch{return null}},"P",0,function(e,r,n,c={},f){let d=Date.now();return new Promise(h=>{let p="",w=(0,t.spawn)("sh",["-c",e],{cwd:r,detached:!0,env:(0,i.f)({CI:"1",FORCE_COLOR:"0",NO_COLOR:"1",...c})}),m=e=>{p=(p+e.toString()).slice(-16e3)};w.stdout.on("data",m),w.stderr.on("data",m);let y=!1,g=()=>{y=!0;try{w.pid&&process.kill(-w.pid,"SIGKILL")}catch{}};n.aborted?g():n.addEventListener("abort",g,{once:!0});let b=(t,r,i)=>{n.removeEventListener("abort",g);let c=y?null:function(e){let t=u(e),r={passed:0,failed:0,total:0},n=!1;for(let e of t.matchAll(s))r.passed+=l(e[1],"passed"),r.failed+=l(e[1],"failed"),r.total+=Number(e[2]),n=!0;for(let e of t.matchAll(o))r.passed+=l(e[1],"passed"),r.failed+=l(e[1],"failed"),r.total+=Number(e[2]),n=!0;let i=e=>[...t.matchAll(RegExp(`(?:^|\\s)(?:#|ℹ)\\s+${e}\\s+(\\d+)\\s*$`,"gm"))].map(e=>Number(e[1])),[a,c,f]=[i("tests"),i("pass"),i("fail")];if(a.length>0&&a.length===c.length&&a.length===f.length){let e=e=>e.reduce((e,t)=>e+t,0);r.passed+=e(c),r.failed+=e(f),r.total+=e(a),n=!0}return n?r:null}(p);f?.(u(p)),h({command:e,exitCode:y?null:t,signal:y?null:r,started:i,durationMs:Date.now()-d,counts:c,outputTail:(0,a.h)(u(p)).slice(-4e3),changedTestFiles:null})};w.on("error",()=>b(null,null,!1)),w.on("close",(e,t)=>b(e,t,!0))})},"X",0,u])},26955,e=>{"use strict";var t=e.i(74533),r=e.i(66680),n=e.i(2157),i=e.i(60526),a=e.i(50227),s=e.i(87345),o=e.i(91138);let l=/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/;function c(e,t){if("string"!=typeof e||!l.test(e))throw Error(`Not a git object id: ${t}`)}function u(e,t){if(t.store)return(0,a.resolve)(t.store);let i=(0,r.createHash)("sha256").update((0,n.realpathSync)(e)).digest("hex").slice(0,16);return(0,a.join)(o.f,"snapshots",i)}function f(e,r,i){let s={...process.env};for(let e of["GIT_DIR","GIT_WORK_TREE","GIT_INDEX_FILE","GIT_COMMON_DIR","GIT_OBJECT_DIRECTORY","GIT_ALTERNATE_OBJECT_DIRECTORIES","GIT_NAMESPACE","GIT_PREFIX"])delete s[e];let o=(0,t.execFileSync)("git",["rev-parse","--git-path","objects"],{cwd:e,env:s,encoding:"utf8",stdio:["ignore","pipe","pipe"]}).trim(),l=(0,a.join)(u(e,r),"objects");return(0,n.mkdirSync)(l,{recursive:!0}),{...s,GIT_OBJECT_DIRECTORY:l,GIT_ALTERNATE_OBJECT_DIRECTORIES:(0,a.isAbsolute)(o)?o:(0,a.resolve)(e,o),...i?{GIT_INDEX_FILE:i}:{}}}function d(e,r,n,i={}){return(0,t.execFileSync)("git",["--no-optional-locks","-c","core.hooksPath=/dev/null","-c","core.fsmonitor=false",...n],{cwd:e,env:f(e,r,i.index),encoding:"utf8",input:i.input,stdio:["pipe","pipe","pipe"],maxBuffer:0x10000000,timeout:12e4})}function h(e,r,n){return(0,t.execFileSync)("git",["--no-optional-locks","-c","core.hooksPath=/dev/null",...n],{cwd:e,env:f(e,r),stdio:["ignore","pipe","pipe"],maxBuffer:0x10000000,timeout:12e4})}function p(e,t={}){let r=d(e,t,["rev-parse","--show-toplevel"]).trim();if((0,n.realpathSync)(r)!==(0,n.realpathSync)(e))throw Error("The folder is not a working copy of its own");let s=(0,n.mkdtempSync)((0,a.join)((0,i.tmpdir)(),"factory-index-"));try{var o=(0,a.join)(s,"index");let r=!0;try{d(e,t,["rev-parse","--verify","-q","HEAD^{commit}"])}catch{r=!1}return r&&d(e,t,["read-tree","HEAD"],{index:o}),d(e,t,["add","-A","--","."],{index:o}),d(e,t,["write-tree"],{index:o}).trim()}finally{(0,n.rmSync)(s,{recursive:!0,force:!0})}}let w=e=>e?"100755":"100644",m=new Set(["node_modules",".next","dist","build","out","coverage",".turbo",".cache",".vercel",".git"]);function y(e,t={}){let r=p(e,t),{files:i,skipped:o}=function(e,t){let r=d(e,t,["ls-files","-o","-i","--exclude-standard","-z"]).split("\0").filter(Boolean).filter(e=>!e.split("/").some(e=>m.has(e))&&s.Q.test(e)),i=[],o=0;for(let s of r)try{let r=(0,n.lstatSync)((0,a.join)(e,s));if(i.length>=50||!r.isFile()||r.size>1048576){o++;continue}i.push({path:s,mode:w((73&r.mode)!=0),blob:d(e,t,["hash-object","-w","--",s]).trim()})}catch{o++}return{files:i.sort((e,t)=>e.path<t.path?-1:1),skipped:o}}(e,t);return{tree:r,ignored:i,skipped:o}}let g=e=>e?`${e.mode} ${e.sha}`:"-";function b(e,t,r,n){let i=d(e,t,["diff-tree","-r","-z","--name-status","--no-renames",r,n]).split("\0"),a=[];for(let e=0;e+1<i.length;e+=2)a.push({status:i[e],path:i[e+1]});return a}function v(e,t,r,n={}){return c(t,"from"),c(r,"tree"),b(e,n,t,r).map(e=>e.path).sort()}let S=e=>"string"==typeof e?{tree:e,ignored:[],skipped:0}:e;function k(e,t,r,n={}){let i=S(t),a=S(r);c(i.tree,"before"),c(a.tree,"after");let s=new Set(b(e,n,i.tree,a.tree).map(e=>e.path)),o=e=>new Map(e.ignored.map(e=>[e.path,g({mode:e.mode,sha:e.blob})])),l=o(i),u=o(a);for(let e of new Set([...l.keys(),...u.keys()]))l.get(e)!==u.get(e)&&s.add(e);return[...s].sort()}function x(e,t,r,n){let i=new Map;for(let a=0;a<n.length;a+=100){let s=n.slice(a,a+100);for(let n of d(e,t,["ls-tree","-r","-z",r,"--",...s]).split("\0").filter(Boolean)){let e=n.indexOf(" "),[t,r,a]=n.slice(0,e).split(" ");"blob"===r&&s.includes(n.slice(e+1))&&i.set(n.slice(e+1),{mode:t,sha:a})}}return i}function I(e,t,r){let i,s=(0,a.join)(e,r);try{i=(0,n.lstatSync)(s)}catch{return null}return i.isSymbolicLink()?{mode:"120000",sha:d(e,t,["hash-object","--stdin"],{input:(0,n.readlinkSync)(s)}).trim()}:i.isDirectory()?0===(0,n.readdirSync)(s).length?null:{mode:"040000",sha:"folder"}:{mode:w((73&i.mode)!=0),sha:d(e,t,["hash-object","--",r]).trim()}}let $=e=>""!==e&&!e.startsWith("/")&&e.split("/").every(e=>""!==e&&".."!==e&&".git"!==e),j=e=>/(^|\/)\.(gitignore|gitattributes)$/.test(e);function P(e,t,r,i={}){let s=S(t),o=S(r);c(s.tree,"before"),c(o.tree,"after");let l=k(e,s,o,i),u=new Set([...s.ignored,...o.ignored].map(e=>e.path)),f=x(e,i,s.tree,l),p=x(e,i,o.tree,l),w=(e,t,r)=>{let n=t.get(r);if(n)return n;let i=e.ignored.find(e=>e.path===r);return i?{mode:i.mode,sha:i.blob}:null},m=[],y=[],b=[],v=!1,E=t=>{try{if(!$(t)||function(e,t){let r=t.split("/"),i=e;for(let e of r.slice(0,-1)){i=(0,a.join)(i,e);try{if((0,n.lstatSync)(i).isSymbolicLink())return!0}catch{break}}return!1}(e,t))throw Error("Not a path to touch");let r=w(s,f,t),l=w(o,p,t);if(g(r)===g(l))return;let c=I(e,i,t);if(g(c)===g(r))return void m.push(t);if(g(c)!==g(l))return void y.push(t);if(null===r){if(!u.has(t)){if(v)return void y.push(t);if(function(e,t,r){try{return d(e,t,["check-ignore","-q","--",r]),!0}catch{return!1}}(e,i,t))return}(0,n.rmSync)((0,a.join)(e,t),{force:!0})}else{let s=(0,a.join)(e,t),o="120000"===r.mode?h(e,i,["cat-file","blob",r.sha]):h(e,i,["cat-file","--filters",`--path=${t}`,r.sha]),l=t.split("/"),c=e;for(let e of l.slice(0,-1))if(c=(0,a.join)(c,e),(0,n.existsSync)(c)){if(!(0,n.lstatSync)(c).isDirectory())throw Error("A file is in the way")}else(0,n.mkdirSync)(c);((0,n.existsSync)(s)||function(e){try{return(0,n.lstatSync)(e).isSymbolicLink()}catch{return!1}}(s))&&((0,n.lstatSync)(s).isDirectory()?(0,n.rmdirSync)(s):(0,n.rmSync)(s,{force:!0})),"120000"===r.mode?(0,n.symlinkSync)(o.toString(),s):((0,n.writeFileSync)(s,o),(0,n.chmodSync)(s,"100755"===r.mode?493:420))}m.push(t)}catch{b.push(t)}},_=e=>null===w(s,f,e),A=[...l.filter(j),...l.filter(e=>!j(e)&&_(e)),...l.filter(e=>!j(e)&&!_(e))];for(let e of A.filter(j))E(e);for(let e of(v=[...y,...b].some(j),A.filter(e=>!j(e))))E(e);return{reverted:m.sort(),kept:y.sort(),failed:b.sort()}}let E=(e,t)=>(0,a.join)(u(e,t),"attempts");e.s(["n",0,2,"H",0,v,"d",0,k,"e",0,function(e,t,r={}){let n=d(e,r,["status","--porcelain=v1","-z","-uall"]).split("\0").filter(Boolean),i=new Set(t.ignored.map(e=>e.path));for(let e=0;e<n.length;e++){let t=n[e].slice(0,2);i.add(n[e].slice(3).replace(/\/$/,"")),("R"===t[0]||"C"===t[0])&&e++}let a=[...i].filter($),s=x(e,r,t.tree,a);return a.filter(n=>g(s.get(n)??(t.ignored.find(e=>e.path===n)?{mode:t.ignored.find(e=>e.path===n).mode,sha:t.ignored.find(e=>e.path===n).blob}:null))!==g(I(e,r,n))).sort()},"G",0,function(e,t,r={}){c(t,"tree");let n=p(e,r),i=["--no-renames","--no-color","--no-ext-diff","--no-textconv"],a=v(e,t,n,r),s=d(e,r,["-c","core.quotepath=off","diff-tree","-r","-p",...i,t,n]),o=new Map;for(let a of d(e,r,["diff-tree","-r","-z","--numstat",...i,t,n]).split("\0").filter(Boolean)){let[e,t,...r]=a.split(" "),n=e=>void 0===e||"-"===e?1:Number(e);o.set(r.join(" "),n(e)+n(t))}return{paths:a,diff:s,files:a.map(e=>({path:e,lines:Math.max(1,o.get(e)??1)}))}},"W",0,function(e,t,r={}){let i=E(e,r);if((0,n.existsSync)(i))for(let e of(0,n.readdirSync)(i))e.startsWith(`${t}-`)&&(0,n.rmSync)((0,a.join)(i,e),{force:!0})},"z",0,function(e,t,r={}){c(t,"tree");let n=P(e,t,p(e,r),r);if(n.failed.length>0)throw Error(`Could not put back: ${n.failed.join(", ")}`)},"$",0,p,"u",0,function(e,t,r={}){if(!/^[A-Za-z0-9_-]+$/.test(t))throw Error("Not a name to claim");let i=E(e,r);(0,n.mkdirSync)(i,{recursive:!0});let s=(0,a.join)(i,t),o=()=>{try{let e=JSON.parse((0,n.readFileSync)(s,"utf8")),t="string"==typeof e.tree&&l.test(e.tree)&&Array.isArray(e.ignored)&&e.ignored.every(e=>e&&"string"==typeof e.path&&"string"==typeof e.mode&&"string"==typeof e.blob&&l.test(e.blob));return{again:!0,start:t?{tree:e.tree,ignored:e.ignored,skipped:"number"==typeof e.skipped?e.skipped:0}:null}}catch{return{again:!0,start:null}}};if((0,n.existsSync)(s))return o();let c=y(e,r);try{(0,n.writeFileSync)(s,JSON.stringify(c),{flag:"wx"})}catch{return o()}return{again:!1,start:c}},"o",0,y,"p",0,P])},92835,e=>e.a(async(t,r)=>{try{var n=e.i(74533),i=e.i(2157),a=e.i(60526),s=e.i(50227),o=e.i(75225),l=e.i(24924),c=e.i(92335),u=e.i(96662),f=e.i(120),d=e.i(20195),h=e.i(64950),p=e.i(30188),w=e.i(69608),m=e.i(82283),y=e.i(37857),g=t([l,u,f,d,h,w]);[l,u,f,d,h,w]=g.then?(await g)():g;let j=async(e,t)=>{let r=await (0,y.f)();try{let n=await (await r.newContext({viewport:{width:1440,height:900},deviceScaleFactor:1})).newPage();await n.goto(e,{waitUntil:"load",timeout:12e4}),await n.waitForLoadState("networkidle",{timeout:15e3}).catch(()=>void 0),await n.waitForTimeout(1500),await n.screenshot({path:t,fullPage:!0})}finally{await r.close()}},P=/^version-(\d{1,2})\.(png|patch)$/,E=(e,t,r)=>(0,s.join)(r,e,`version-${t}.png`),_=(e,t,r)=>(0,s.join)(r,e,`version-${t}.patch`),A=(e,t,r)=>(0,n.execFileSync)("git",["-c","core.hooksPath=/dev/null",...t],{cwd:e,env:r??process.env,stdio:["ignore","pipe","pipe"],maxBuffer:0x20000000});async function b(e,t,r=j,n=w.P){try{let a=(0,d.h)(e);if("ready"!==a.status||!a.url)return!1;return(0,i.mkdirSync)((0,s.join)(n,e),{recursive:!0}),await r(a.url,E(e,t,n)),!0}catch{return!1}}function v(e,t=w.P){let r=(0,s.join)(t,e);return(0,i.existsSync)(r)?[...new Set((0,i.readdirSync)(r).flatMap(e=>{let t=P.exec(e);return t?[Number(t[1])]:[]}))].sort((e,t)=>e-t):[]}async function S(e,t=w.P){let r=v(e,t);if(0===r.length)return[];let n=(await l.r.select().from(c.B).where((0,o.u)(c.B.id,e)))[0];if(!n)return[];let a=[n.request,...(await (0,u.P)([e]))(e)];return r.map(r=>({n:r,text:a[r-1]??null,site:(0,i.existsSync)(_(e,r,t)),picture:(0,i.existsSync)(E(e,r,t))}))}let B=globalThis.__factoryVersions??=new Map,T=e=>`${e}:version`,F=(e,t)=>(0,s.join)(t,e,"version-tree");class R extends Error{}function k(e){return(0,d.i)(T(e)),{...(0,d.h)(T(e)),n:B.get(e)??null}}async function x(e,t,r){let n=(0,d.h)(T(e)).status;if(B.get(e)===t&&("starting"===n||"installing"===n||"ready"===n))return k(e);let a=(await l.r.select().from(c.B).where((0,o.u)(c.B.id,e)))[0],s=a?(await (0,h.I)(a.projectId))?.repoPath??null:null,u=_(e,t,r),p=(0,i.existsSync)(`${u}.base`)?(0,i.readFileSync)(`${u}.base`,"utf8").trim():"";if(!a||!s||!(0,i.existsSync)(u)||!/^[0-9a-f]{7,64}$/.test(p))throw new R(m.f.direct.versionNotKept);await $(e,r,!0);let w=F(e,r);try{A(s,["worktree","add","-q","--detach",w,p]),(0,i.statSync)(u).size>0&&A(w,["apply","--binary","--whitespace=nowarn",u]),await (0,f.S)(a.projectId,w),B.set(e,t),await (0,d.O)(T(e),w,s)}catch{throw(0,d.D)(T(e)),B.delete(e),I(s,w),new R(m.f.direct.versionNotBuilt)}return k(e)}function I(e,t){try{e?(0,w.S)(e,t):(0,i.rmSync)(t,{recursive:!0,force:!0})}catch{}}async function $(e,t,r){let n="stopped"!==(0,d.h)(T(e)).status;(0,d.D)(T(e)),B.delete(e);let a=F(e,t);if(!(0,i.existsSync)(a))return;let s=(await l.r.select().from(c.B).where((0,o.u)(c.B.id,e)))[0],u=s?(await (0,h.I)(s.projectId))?.repoPath??null:null;n&&await new Promise(e=>setTimeout(e,r?1500:4e3)),I(u,a)}e.s(["R",0,R,"q",0,b,"x",0,function(e,t,r=w.P){for(let n of v(e,r))n<=t||((0,i.rmSync)(E(e,n,r),{force:!0}),(0,i.rmSync)(_(e,n,r),{force:!0}),(0,i.rmSync)(`${_(e,n,r)}.base`,{force:!0}))},"H",0,S,"A",0,function(e,t,r=w.P){let n=E(e,t,r);return Number.isInteger(t)&&t>=1&&t<=99&&(0,i.existsSync)(n)?new Uint8Array((0,i.readFileSync)(n)):null},"Y",0,function(e,t,r,n,o=w.P){let l=(0,i.mkdtempSync)((0,s.join)((0,a.tmpdir)(),"factory-version-"));try{let a={...process.env,GIT_INDEX_FILE:(0,s.join)(l,"index")};A(e,["read-tree",t],a),A(e,["add","-A","--","."],a);let c=A(e,["diff","--cached","--binary","--full-index",t],a);return(0,i.mkdirSync)((0,s.join)(o,r),{recursive:!0}),(0,i.writeFileSync)(_(r,n,o),c),(0,i.writeFileSync)(`${_(r,n,o)}.base`,t),!0}catch{return!1}finally{(0,i.rmSync)(l,{recursive:!0,force:!0})}},"C",0,(e,t,r=w.P)=>(0,p.f)(T(e),()=>x(e,t,r)),"i",0,(e,t=w.P)=>(0,p.f)(T(e),()=>$(e,t,!1)),"S",0,k]),r()}catch(e){r(e)}},!1),18536,e=>{"use strict";var t=e.i(74533),r=e.i(2157),n=e.i(50227),i=e.i(91138);let a=(0,n.join)(i.f,"worktrees"),s=(e,r)=>(0,t.execFileSync)("git",r,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","pipe"]}).trim();function o(e,t){let r=(t??"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40).replace(/-+$/g,"");return`ai/${r||"change"}-${e.slice(-6).toLowerCase()}`}e.s(["U",0,a,"E",0,o,"r",0,function(e,t,i=a,l,c){let u=o(t,c),f=(0,n.join)(i,t);if((0,r.existsSync)(f))return{path:f,branch:s(f,["rev-parse","--abbrev-ref","HEAD"]),baseCommit:s(f,["merge-base","HEAD",u])};let d=s(e,["rev-parse","--verify",l?`${l}^{commit}`:"HEAD"]);return(0,r.mkdirSync)(i,{recursive:!0}),s(e,["worktree","add","-q","-b",u,f,d]),{path:f,branch:u,baseCommit:d}}])}];
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=_153o0hrf0g3mk._.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module.exports=[60338,e=>{"use strict";var t=e.i(56325),r=e.i(44988),n=e.i(18899);e.s(["H",0,function(e){return n.B`count(${e||n.B.raw("*")})`.mapWith(Number)},"y",0,function(e){return n.B`max(${e})`.mapWith((0,r.f)(e,t.f)?e:String)}])},44586,e=>{"use strict";e.s(["f",0,function(e){return/^[A-Za-z0-9._-]{1,100}$/.test(e)&&"."!==e&&".."!==e}])},96662,e=>e.a(async(t,r)=>{try{var n=e.i(75225),i=e.i(49129),a=e.i(24924),s=e.i(92335),o=e.i(82283),l=t([a]);async function c(e){let t=await f(e);return e=>{let r=[];for(let n of t)n.runId===e&&("undo"===n.answerOption?r.pop():"other"===n.answerOption&&n.answerText?.trim()&&r.push(n.answerText.trim()));return r}}[a]=l.then?(await l)():l;let f=async e=>e.length>0?a.r.select().from(s.m).where((0,n.b)((0,n.y)(s.m.runId,e),(0,n.u)(s.m.kind,"direct"))).orderBy((0,i.M)(s.m.createdAt)):[];async function u(e,t){let r=[];for(let t of(await f([e])))"undo"===t.answerOption?r.push({at:t.createdAt,text:null}):"other"===t.answerOption&&t.answerText?.trim()&&r.push({at:t.createdAt,text:t.answerText.trim()});for(let t of(await a.r.select().from(s.a).where((0,n.b)((0,n.u)(s.a.runId,e),(0,n.u)(s.a.decision,"changes")))))t.reason?.trim()&&r.push({at:t.createdAt,text:t.reason.trim()});r.sort((e,t)=>e.at.localeCompare(t.at));let i=[];for(let e of r)null===e.text?i.pop():i.push(e.text);return i.length>0?o.f.review.withLaterAsks(t,i):t}e.s(["P",0,c,"u",0,u]),r()}catch(e){r(e)}},!1),82461,e=>e.a(async(t,r)=>{try{var n=e.i(2157),i=e.i(50227),a=e.i(75225),s=e.i(6561),o=e.i(24924),l=e.i(92335),c=e.i(65272),u=e.i(82283),f=e.i(91138),d=t([o]);[o]=d.then?(await d)():d;let m=(0,i.join)(f.f,"attachments");class y extends Error{}let g=[{mime:"image/png",ext:"png",test:e=>e.subarray(0,8).equals(Buffer.from([137,80,78,71,13,10,26,10]))},{mime:"image/jpeg",ext:"jpg",test:e=>255===e[0]&&216===e[1]&&255===e[2]},{mime:"image/gif",ext:"gif",test:e=>"GIF87a"===e.subarray(0,6).toString("ascii")||"GIF89a"===e.subarray(0,6).toString("ascii")},{mime:"image/webp",ext:"webp",test:e=>"RIFF"===e.subarray(0,4).toString("ascii")&&"WEBP"===e.subarray(8,12).toString("ascii")}];async function h(e,t,r=m){let a;if(0===t.length)throw new y(u.f.attachments.notImage);if(t.length>0xa00000)throw new y(u.f.attachments.tooBig(10));let f=(a=g.find(e=>t.length>=12&&e.test(t)))?{mime:a.mime,ext:a.ext}:null;if(!f)throw new y(u.f.attachments.notImage);let d=(0,s.v)();(0,n.mkdirSync)(r,{recursive:!0});let p=(0,i.join)(r,`${d}.${f.ext}`);(0,n.writeFileSync)(p,t),await (0,c.h)()?.put((0,c._)(d,f.ext),t,f.mime);let w=e.replace(/[^\w.\- ]+/g,"_").slice(0,120)||`image.${f.ext}`;return await o.r.insert(l.K).values({id:d,path:p,name:w,mime:f.mime,size:t.length,createdAt:new Date().toISOString()}),{id:d,name:w,mime:f.mime,size:t.length}}async function p(e,t,r=null,n=null){let i=[...new Set(e)].slice(0,6);if(0===i.length)return 0;let s=await o.r.select().from(l.K).where((0,a.b)((0,a.y)(l.K.id,i),(0,a.M)(l.K.runId)));for(let e of s)await o.r.update(l.K).set({runId:t,approvalId:r,questionId:n}).where((0,a.u)(l.K.id,e.id));return s.length}async function w(e,t=null,r=m){let s="string"==typeof t?t:null,u=null!==t&&"object"==typeof t?(0,a.u)(l.K.questionId,t.question):(0,a.b)(s?(0,a.u)(l.K.approvalId,s):(0,a.M)(l.K.approvalId),(0,a.M)(l.K.questionId)),f=await o.r.select().from(l.K).where((0,a.b)((0,a.u)(l.K.runId,e),u)),d=[];for(let e of f){let t=(0,i.extname)(e.path).slice(1)||"png",a=(0,n.existsSync)(e.path)?e.path:(0,i.join)(r,`${e.id}.${t}`);if(!(0,n.existsSync)(a)){let i=await (0,c.h)()?.get((0,c._)(e.id,t));if(!i)continue;(0,n.mkdirSync)(r,{recursive:!0}),(0,n.writeFileSync)(a,i.body)}d.push(a)}return d}e.s(["o",0,m,"F",0,y,"H",0,6,"R",0,0xa00000,"V",0,p,"W",0,w,"r",0,h]),r()}catch(e){r(e)}},!1),120,e=>e.a(async(t,r)=>{try{var n=e.i(74533),i=e.i(66680),a=e.i(2157),s=e.i(50227),o=e.i(29420),l=e.i(62534),c=e.i(40855),u=e.i(64950),f=e.i(91138),d=t([u]);[u]=d.then?(await d)():d;let v=(0,s.join)(f.f,"bases"),S=["pnpm-lock.yaml","yarn.lock","bun.lock","bun.lockb","package-lock.json"],k=(e,t)=>(0,n.execFileSync)("git",t,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","pipe"]}).trim();function h(e){for(let t of[...S,"package.json"]){let r=(0,s.join)(e,t);if((0,a.existsSync)(r))return`${t}:${(0,i.createHash)("sha256").update((0,a.readFileSync)(r)).digest("hex")}`}return null}let x=(e,t=v)=>(0,s.join)(t,e);function p(e,t,r=v){let n=x(e,r);if((0,a.existsSync)(n))try{if(!t)throw Error("no repository to ask");k(t,["worktree","remove","--force",n])}catch{(0,a.rmSync)(n,{recursive:!0,force:!0})}}async function w(e,t){await (0,u.J)(e,{...t,baseUpdatedAt:new Date().toISOString()})}let I=new Set;async function m(e,t={}){if(I.has(e))return;let r=await (0,u.I)(e);if(!r?.repoPath)return;I.add(e);let n=r.repoPath,i=x(e,t.root);try{await w(e,{baseStatus:"installing",baseMessage:null});let r=(0,o.I)(n),u=r?await (0,o.Y)(n,r):null,f=u?.commit??k(n,["rev-parse","HEAD"]);p(e,n,t.root),(0,a.mkdirSync)((0,s.dirname)(i),{recursive:!0}),k(n,["worktree","prune"]),k(n,["worktree","add","--detach","-q",i,f]);let d=await (t.install??l.F)(i);if(d&&!d.ok)return void await w(e,{baseStatus:"failed",baseCommit:f,baseLockHash:null,baseMessage:(0,c.l)((0,c.h)(d.outputTail).trim().split("\n").slice(-2).join(" "),300)});await w(e,{baseStatus:"ready",baseCommit:f,baseLockHash:h(i),baseMessage:null})}catch(t){await w(e,{baseStatus:"failed",baseMessage:(0,c.l)((0,c.h)(t instanceof Error?t.message:String(t)),300)})}finally{I.delete(e)}}function y(e,t){try{(0,n.execFileSync)("python3",["-I","-c","import ctypes,sys; sys.exit(ctypes.CDLL(None).clonefile(sys.argv[1].encode(), sys.argv[2].encode(), 0))",e,t],{stdio:"ignore",timeout:12e4});return}catch{(0,a.rmSync)(t,{recursive:!0,force:!0})}try{(0,n.execFileSync)("cp",["-cR",e,t],{stdio:"ignore"});return}catch{(0,a.rmSync)(t,{recursive:!0,force:!0})}(0,n.execFileSync)("cp",["-R",e,t],{stdio:"ignore"})}async function g(e,t,r=v){let n=await (0,u.I)(e),i=x(e,r);if(n?.baseStatus!=="ready"||!n.baseLockHash||!(0,a.existsSync)(i))return{copied:!1,reason:"no-base"};if(h(t)!==n.baseLockHash)return{copied:!1,reason:"different-lockfile"};let o=Date.now();try{let e,r;for(let n of(e=[],(r=t=>{for(let n of(0,a.readdirSync)(t,{withFileTypes:!0})){if(!n.isDirectory()||".git"===n.name)continue;let a=(0,s.join)(t,n.name);"node_modules"===n.name?e.push((0,s.relative)(i,a)):r(a)}})(i),e.sort())){let e=(0,s.join)(t,n);(0,a.existsSync)(e)||((0,a.mkdirSync)((0,s.dirname)(e),{recursive:!0}),y((0,s.join)(i,n),e))}return{copied:!0,ms:Date.now()-o}}catch{return{copied:!1,reason:"copy-failed"}}}async function b(e,t){let r=await (0,u.I)(e);if(!r?.repoPath||"ready"!==r.baseStatus)return!1;let a=function(e,t){for(let r of[...S,"package.json"])try{let a=(0,n.execFileSync)("git",["show",`${t}:${r}`],{cwd:e,stdio:["ignore","pipe","ignore"],maxBuffer:0x10000000});return`${r}:${(0,i.createHash)("sha256").update(a).digest("hex")}`}catch{}return null}(r.repoPath,t);return null!==a&&a!==r.baseLockHash}e.s(["y",0,b,"q",0,y,"S",0,g,"F",0,p,"m",0,m]),r()}catch(e){r(e)}},!1),28033,e=>{"use strict";var t=e.i(74533),r=e.i(60526),n=e.i(40855);let i=/^[a-z0-9]+(?:-[a-z0-9]+){1,5}$/,a=new Set("a al an and are as at be by con de del el en es esta este first for from haz in is it la las lo los make me mi my no now of on or para please por primero que se sin so solo the then to un una uno y ya you your ejecuta ejecutar run install pnpm npm yarn bun cambia cambiar change quiero want can could would nada mas more".split(" "));function s(e){let t=(0,n.h)(e).normalize("NFD").replace(/[̀-ͯ]/g,"").toLowerCase().split(/\s+/).filter(e=>!/[/\\]|\.[a-z]{1,4}\b/.test(e)).map(e=>e.replace(/[^a-z0-9]+/g,"")).filter(e=>e.length>1&&!a.has(e)&&!/^\d+(px|rem|em|%)?$/.test(e)),r=[];for(let e of t)if(!r.includes(e)&&([...r,e].join("-").length>48||(r.push(e),5===r.length)))break;return r.length>0?r.join("-"):null}let o=e=>new Promise((n,i)=>{(0,t.execFile)("claude",["-p","--model","haiku","--setting-sources","","--strict-mcp-config",e],{cwd:(0,r.tmpdir)(),timeout:2e4,maxBuffer:65536},(e,t)=>e?i(e):n(t))});async function l(e,t,r=o){let n=`Name a git branch for this change. Reply with ONLY 2 to 5 lowercase English words joined by hyphens that say what changed, nothing else.
|
|
2
|
+
Request: ${e.slice(0,2e3)}
|
|
3
|
+
Files changed: ${t.slice(0,20).join(", ")||"unknown"}`;try{var a;let e,t=(a=await r(n),e=a.trim().split("\n")[0]?.trim().toLowerCase().replace(/^[`'"]+|[`'".]+$/g,"").replace(/^ai\//,"")??"",i.test(e)&&e.length<=48?e:null);if(t)return t}catch{}return s(e)??"change"}async function c(e,t,r=o){let n;if(""===t.trim())return null;let i=`Write a git commit message for this diff. Line 1: an imperative summary of what the code change does, at most 72 characters. Then a blank line, then 1 to 4 short lines starting with "- " saying what changed. English. Reply with the message only.
|
|
4
|
+
What the person asked for (context only): ${e.slice(0,1e3)}
|
|
5
|
+
Diff:
|
|
6
|
+
${t.slice(0,12e3)}`;try{n=await r(i)}catch{return null}let a=n.replace(/```[a-z]*\n?/g,"").trim().split("\n"),s=(a[0]??"").trim().replace(/^["'`]+|["'`]+$/g,"");return s.length<3||s.length>72||/[:!]$/.test(s)||/^(sure|here|okay|ok)\b/i.test(s)?null:{subject:s,body:a.slice(1).filter(e=>!/^\s*(co-authored-by|signed-off-by|generated with)\b/i.test(e)&&!e.includes("🤖")).join("\n").trim().slice(0,800)}}e.s(["q",0,o,"k",0,function(e,t){return`ai/${t}-${e.slice(-6).toLowerCase()}`},"R",0,s,"A",0,l,"s",0,c])},29420,e=>{"use strict";var t=e.i(74533);let r=(e,r)=>(0,t.execFileSync)("git",r,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","pipe"]}).trim(),n=(e,t)=>{try{return r(e,t)||null}catch{return null}},i=/^[A-Za-z0-9][A-Za-z0-9._/-]{0,199}$/;function a(e,t){return!i.test(t)||t.includes("..")?null:n(e,["rev-parse","--verify","--quiet",`refs/heads/${t}^{commit}`])}async function s(e,i){let s=a(e,i);if(!s)return null;if(!n(e,["remote","get-url","origin"]))return{commit:s,fromOrigin:!1};await new Promise(r=>(0,t.execFile)("git",["fetch","--quiet","origin",`refs/heads/${i}:refs/remotes/origin/${i}`],{cwd:e,timeout:2e4,env:{...process.env,GIT_TERMINAL_PROMPT:"0"}},()=>r()));let o=n(e,["rev-parse","--verify","--quiet",`refs/remotes/origin/${i}^{commit}`]);if(!o||o===s)return{commit:s,fromOrigin:!1};try{return r(e,["merge-base","--is-ancestor",s,o]),{commit:o,fromOrigin:!0}}catch{return{commit:s,fromOrigin:!1}}}e.s(["m",0,a,"I",0,function(e){for(let t of[n(e,["symbolic-ref","--quiet","--short","refs/remotes/origin/HEAD"])?.replace(/^origin\//,""),"main","master"])if(t&&a(e,t))return t;return n(e,["symbolic-ref","--quiet","--short","HEAD"])},"Y",0,s])},37857,e=>{"use strict";async function t(){let t,{chromium:r}=await e.A(64351);for(let e of[void 0,"chrome","msedge"])try{return await r.launch(e?{channel:e}:{})}catch(e){t??=e}throw t}e.s(["f",0,t])},16806,e=>{"use strict";let t=/^(__NEXT|NEXT_|INNGEST|TURBOPACK|NODE_ENV$|PORT$|HOSTNAME$|FACTORY_|DATABASE_URL|LOCAL_DATABASE_URL$|NEON_|R2_)/;e.s(["f",0,function(e={},r=process.env){let n={};for(let[e,i]of Object.entries(r))t.test(e)||(n[e]=i);return{...n,...e}}])},65080,e=>e.a(async(t,r)=>{try{var n=e.i(74533),i=e.i(2157),a=e.i(60526),s=e.i(50227),o=e.i(75225),l=e.i(49129),c=e.i(24924),u=e.i(92335),f=e.i(55372),d=e.i(40855),h=e.i(28033),p=e.i(29420),w=e.i(58096),m=e.i(18536),y=e.i(82283),g=e.i(64950),b=e.i(30188),v=e.i(77954),S=t([c,f,w,g,v]);[c,f,w,g,v]=S.then?(await S)():S;class z extends Error{status;kind;constructor(e,t,r){super(e),this.status=t,this.kind=r,this.name="DeliveryError"}}let H=(e,t,r)=>(0,n.execFileSync)("git",t,{cwd:e,encoding:"utf8",input:r,stdio:["pipe","pipe","pipe"],maxBuffer:0x4000000}).trim();async function k(e){let t=(await c.r.select().from(u.B).where((0,o.u)(u.B.id,e)))[0];if(!t)return null;let r=await (0,v.v)(e);return{run:t,passedBy:r,eligible:"completed"===t.status&&null!==r&&!!t.worktreePath&&!!t.baseCommit}}async function x(e,t){let r=(await c.r.select().from(u.f).where((0,o.b)((0,o.u)(u.f.runId,e),(0,o.u)(u.f.type,t))).orderBy((0,l.A)(u.f.sequence)))[0];return r?JSON.parse(r.payloadJson):null}async function I(e){return(await (0,g.I)(e))?.repoPath??null}function $(e){if(!e)return null;try{return H(e,["symbolic-ref","--quiet","--short","HEAD"])||null}catch{return null}}function j(e){try{return H(e,["remote","get-url","origin"]).trim()||null}catch{return null}}async function P(e){var t;let r=await k(e);if(!r)throw new z(y.f.errors.runNotFound,404);let n=await x(e,"run.kept"),i=await x(e,"run.delivered"),a=await x(e,"run.pushed"),s=await (0,g.D)(e),o=await I(r.run.projectId);return{hasRemote:s.here&&(t=o)?null!==j(t):null,githubSkipped:!!s.here&&function(e){if(!e)return!1;try{return"off"===H(e,["config","--local","--get",w.A]).trim()}catch{return!1}}(o),here:s.here,machine:s.machine,eligible:r.eligible,passedBy:r.passedBy,kept:!!n,delivered:!!i,branch:n?.branch??r.run.branch,commit:i?.commit??n?.commit??null,files:i?.files??n?.files??[],appliedTo:i?.appliedTo??null,current:$(o),returnTo:(await x(e,"run.switched"))?.from??null,pushed:null!==a&&a.branch===(n?.branch??r.run.branch),pullRequestUrl:a?.pullRequestUrl??null,autoShip:await E(e)}}async function E(e){let t=(await c.r.select().from(u.f).where((0,o.b)((0,o.u)(u.f.runId,e),(0,o.u)(u.f.type,"run.auto_ship"))).orderBy((0,l.A)(u.f.sequence)))[0];if(!t)return null;let r=JSON.parse(t.payloadJson);return{state:r.state??"started",step:r.step??null,reason:r.reason??null,message:r.message??null,at:t.createdAt}}function _(e,t,r="person"){let n=e.worktreePath;if(H(n,["add","-A"]),""!==H(n,["diff","--cached","--name-only"])){let i=e.request.replace(/\s+/g," ").trim(),a="app"===r?`Made by an agent in Plaincrew, run ${e.id}. ${y.f.delivery.passedOnItsOwn}`:`Made by an agent in Plaincrew, run ${e.id}, and approved by a person.`,s=(0,d.h)(i);H(n,["-c","user.name=Plaincrew","-c","user.email=plaincrew@localhost","commit","-q","--no-verify","-m",t?`${(0,d.h)(t.subject)}
|
|
7
|
+
|
|
8
|
+
${t.body?`${(0,d.h)(t.body)}
|
|
9
|
+
|
|
10
|
+
`:""}Asked for: ${(0,d.l)(s,500)}
|
|
11
|
+
|
|
12
|
+
${a}`:`${(0,d.l)(s,72)}
|
|
13
|
+
|
|
14
|
+
${a}`])}return H(n,["rev-parse","HEAD"])}async function A(e){return await x(e,"run.delivered")!==null}let J=/^[A-Za-z0-9][A-Za-z0-9._/-]{0,99}$/;async function B(e){let t=(await c.r.select().from(u.B).where((0,o.u)(u.B.id,e)))[0],r=t?.worktreePath;if(!t||!r)return[];try{let e=t.deliveryBase??t.baseCommit,n=H(r,["diff","--name-only",e]).split("\n"),i=H(r,["ls-files","--others","--exclude-standard"]).split("\n");return[...new Set([...n,...i].filter(Boolean))].sort()}catch{return[]}}async function T(e){let t=(await c.r.select().from(u.B).where((0,o.u)(u.B.id,e)))[0],r=t?.worktreePath;if(!t||!r)return"";try{let e=t.deliveryBase??t.baseCommit,n=H(r,["diff",e]),i=H(r,["ls-files","--others","--exclude-standard"]).split("\n").filter(Boolean).map(e=>`new file: ${e}`);return(0,d.h)([n,...i].join("\n"))}catch{return""}}async function F(e){return(await c.r.select().from(u.B).where((0,o.u)(u.B.id,e)))[0]?.request??null}async function R(e,t={}){return(0,b.f)(e,async()=>{let r=await (0,g.b)(e);if(r)throw new z(r,409);let i=await k(e);if(!i)throw new z(y.f.errors.runNotFound,404);if(!i.eligible)throw new z(y.f.delivery.notEligible,409);if(await x(e,"run.kept"))return P(e);let{run:a}=i,s=a.worktreePath,l=t.name?.trim()||null;if(null!==l&&!function(e){if(!J.test(e)||e.includes("..")||e.includes("//")||e.endsWith("/")||e.endsWith(".lock")||e.endsWith("."))return!1;try{return(0,n.execFileSync)("git",["check-ref-format","--branch",e],{stdio:"ignore"}),!0}catch{return!1}}(l))throw new z(y.f.delivery.badBranchName,400);let d=a.branch??H(s,["rev-parse","--abbrev-ref","HEAD"]),p=e=>""!==H(s,["branch","--list",e]);if(null!==l&&l!==d&&p(l))throw new z(y.f.delivery.branchExists(l),409);let w=_(a,t.message,i.passedBy??"person"),b=H(s,["diff","--name-only",a.deliveryBase??a.baseCommit,w]).split("\n").filter(Boolean);if(0===b.length)throw new z(y.f.delivery.nothing,409);let v=null===l?await O(a,s,w):null;v&&(await c.r.update(u.B).set({branch:v}).where((0,o.u)(u.B.id,a.id)),d=v);let S=null===v&&(d.startsWith("factory/")||d===(0,m.E)(a.id,a.request)),I=l??(S?t.fallbackName??(0,h.k)(a.id,(0,h.R)(a.request)??"change"):d);return I===d||null===l&&p(I)||(H(s,["branch","-m",I]),await c.r.update(u.B).set({branch:I}).where((0,o.u)(u.B.id,a.id)),d=I),await c.r.transaction(async t=>{await (0,f.f)({runId:e,type:"run.kept",payload:{branch:d,commit:w,files:b}},t)}),P(e)})}async function N(e,t){let r=(await c.r.select().from(u.f).where((0,o.b)((0,o.u)(u.f.runId,e),(0,o.u)(u.f.type,"run.pr_opened"))).orderBy((0,l.A)(u.f.sequence)).limit(1))[0],i=r?JSON.parse(r.payloadJson).number:void 0;if("number"!=typeof i)return!1;try{let e=(0,n.execFileSync)("gh",["pr","view",String(i),"--json","state"],{cwd:t,encoding:"utf8",timeout:15e3,stdio:["ignore","pipe","ignore"]});if("MERGED"!==JSON.parse(e).state)return!1}catch{return!1}return await c.r.transaction(async t=>void await (0,f.f)({runId:e,type:"run.merged",payload:{number:i}},t)),!0}async function O(e,t,r){if(!e.parentRunId)return null;let n=await x(e.parentRunId,"run.kept");if(!n?.branch||await x(e.parentRunId,"run.merged")||await N(e.parentRunId,t))return null;let i=n.branch;try{let n=H(t,["rev-parse","--verify","--quiet",`refs/heads/${i}^{commit}`]);H(t,["merge-base","--is-ancestor",n,r]);let a=(await c.r.select().from(u.B).where((0,o.u)(u.B.id,e.parentRunId)))[0];if(a?.worktreePath)try{H(a.worktreePath,["symbolic-ref","--quiet","--short","HEAD"])===i&&H(a.worktreePath,["checkout","-q","--detach"])}catch{}return H(t,["checkout","-q","-B",i,r]),i}catch{return null}}async function M(e,t={}){return(0,b.f)(e,async()=>{let r=await (0,g.b)(e);if(r)throw new z(r,409);let n=await k(e);if(!n)throw new z(y.f.errors.runNotFound,404);if(!n.eligible)throw new z(y.f.delivery.notEligible,409);if(await x(e,"run.delivered"))return P(e);let l=await (0,g.I)(n.run.projectId),d=l?.repoPath;if(!d)throw new z(y.f.run.noRepository,409);if(""!==H(d,["status","--porcelain"]))throw new z(y.f.delivery.dirty,409);let h=await R(e,t),p=(await c.r.select().from(u.B).where((0,o.u)(u.B.id,e)))[0],w=p.worktreePath,m=p.deliveryBase??p.baseCommit,b=h.commit,v=h.files,S=H(w,["diff","--binary",m,b]),I=(0,i.mkdtempSync)((0,s.join)((0,a.tmpdir)(),"factory-delivery-")),$=(0,s.join)(I,"change.patch");try{(0,i.writeFileSync)($,S.endsWith("\n")?S:`${S}
|
|
15
|
+
`);try{H(d,["apply","--check","--whitespace=nowarn",$])}catch{throw new z(y.f.delivery.conflict(p.branch??""),409)}H(d,["apply","--whitespace=nowarn",$])}finally{(0,i.rmSync)(I,{recursive:!0,force:!0})}return await c.r.transaction(async t=>{await (0,f.f)({runId:e,type:"run.delivered",payload:{branch:h.branch,commit:b,files:v,appliedTo:d}},t)}),P(e)})}function C(e,t){if(""!==H(e,["status","--porcelain","--untracked-files=no"]))throw new z(y.f.delivery.dirty,409);try{H(e,["checkout","-q",t])}catch{throw new z(y.f.delivery.switchFailed(t),409)}}async function D(e){return(0,b.f)(e,async()=>{let t=await (0,g.b)(e);if(t)throw new z(t,409);let r=await k(e);if(!r)throw new z(y.f.errors.runNotFound,404);let n=await x(e,"run.kept");if(!n?.branch)throw new z(y.f.delivery.keepFirst,409);let i=await I(r.run.projectId);if(!i)throw new z(y.f.run.noRepository,409);let a=$(i);if(a===n.branch)return P(e);if(!a)throw new z(y.f.delivery.notOnBranch,409);if(""!==H(i,["status","--porcelain","--untracked-files=no"]))throw new z(y.f.delivery.dirty,409);let s=r.run.worktreePath;if(s)try{H(s,["checkout","-q","--detach"])}catch{}return C(i,n.branch),await c.r.transaction(async t=>void await (0,f.f)({runId:e,type:"run.switched",payload:{branch:n.branch,from:a}},t)),P(e)})}async function q(e){return(0,b.f)(e,async()=>{let t=await (0,g.b)(e);if(t)throw new z(t,409);let r=await k(e);if(!r)throw new z(y.f.errors.runNotFound,404);let n=await x(e,"run.switched");if(!n?.from)throw new z(y.f.delivery.neverSwitched,409);let i=await I(r.run.projectId);if(!i)throw new z(y.f.run.noRepository,409);return $(i)!==n.from&&(C(i,n.from),await c.r.transaction(async t=>void await (0,f.f)({runId:e,type:"run.switched_back",payload:{branch:n.from}},t))),P(e)})}let G=(e,t)=>new Promise((r,i)=>{(0,n.execFile)("git",t,{cwd:e,timeout:6e4,env:{...process.env,GIT_TERMINAL_PROMPT:"0"}},(e,t,n)=>e?i(Error(String(n||e.message))):r(String(t).trim()))});async function L(e){return(0,b.f)(e,async()=>{let t,r=await (0,g.b)(e);if(r)throw new z(r,409);let n=await k(e);if(!n)throw new z(y.f.errors.runNotFound,404);let i=await x(e,"run.kept");if(!i?.branch)throw new z(y.f.delivery.keepFirst,409);let a=i.branch,s=await I(n.run.projectId);if(!s)throw new z(y.f.run.noRepository,409);let o=j(s);if(null===o)throw new z(y.f.delivery.noRemote,409,"no_connection");try{let e=(0,p.I)(s);e&&e!==a&&await G(s,["ls-remote","--heads","origin",`refs/heads/${e}`])===""&&await G(s,["push","--porcelain","origin",`refs/heads/${e}:refs/heads/${e}`]),await G(s,["push","--porcelain","origin",`refs/heads/${a}:refs/heads/${a}`])}catch(t){let e=(0,d.h)(String(t.message)).replace(/[a-z]+:\/\/[^\s]*@/gi,"").trim().split("\n").filter(Boolean).slice(-2).join(" ");throw new z(y.f.delivery.pushFailed((0,d.l)(e,240)),409)}try{H(s,["branch","--set-upstream-to",`origin/${a}`,a])}catch{}let l=(t=/^(?:https?:\/\/(?:[^@/]+@)?github\.com\/|git@github\.com:|ssh:\/\/git@github\.com\/)([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+?)(?:\.git)?\/?$/.exec(o.trim()))?`https://github.com/${t[1]}/${t[2]}/pull/new/${a}`:null,u=await x(e,"run.pushed");return(u?.branch!==a||(u.pullRequestUrl??null)!==l)&&await c.r.transaction(async t=>void await (0,f.f)({runId:e,type:"run.pushed",payload:{branch:a,pullRequestUrl:l}},t)),P(e)})}e.s(["E",0,z,"D",0,E,"Q",0,B,"s",0,M,"Z",0,P,"w",0,_,"$",0,R,"J",0,function(e){try{return H(e,["remote","get-url","--push","origin"]).trim()||null}catch{return null}},"K",0,j,"c",0,T,"y",0,L,"t",0,F,"P",0,q,"V",0,D,"_",0,function(e){let t=e.worktreePath;if(H(t,["add","-A"]),""!==H(t,["diff","--cached","--name-only"])){let r=e.request.replace(/\s+/g," ").trim();H(t,["-c","user.name=Plaincrew","-c","user.email=plaincrew@localhost","commit","-q","--no-verify","-m",`Unfinished: ${(0,d.l)((0,d.h)(r),60)}
|
|
16
|
+
|
|
17
|
+
Left by an agent in Plaincrew, run ${e.id}, which stopped before a person approved it.`])}return H(t,["rev-parse","HEAD"])},"A",0,A]),r()}catch(e){r(e)}},!1),55372,e=>e.a(async(t,r)=>{try{var n=e.i(75225),i=e.i(49129),a=e.i(60338),s=e.i(18899),o=e.i(6561),l=e.i(24924),c=e.i(92335),u=t([l]);[l]=u.then?(await u)():u;class m extends Error{runId;constructor(e){super(`Cannot append event: run ${e} does not exist`),this.runId=e,this.name="RunNotFoundError"}}class y extends Error{constructor(e){super(`${e} event requires a payload with a non-empty string blockId`),this.name="InvalidEventPayloadError"}}function f(e){return{id:e.id,runId:e.runId,nodeRunId:e.nodeRunId,sequence:e.sequence,type:e.type,payload:JSON.parse(e.payloadJson),createdAt:e.createdAt}}async function d(e,t){if(t.type.startsWith("node.")){let e=t.payload?.blockId;if("string"!=typeof e||""===e)throw new y(t.type)}let r=(await e.select({projectId:c.B.projectId}).from(c.B).where((0,n.u)(c.B.id,t.runId)))[0];if(!r)throw new m(t.runId);await h(e,t.runId);let i=(await e.select({m:(0,a.y)(c.f.sequence)}).from(c.f).where((0,n.u)(c.f.runId,t.runId)))[0];return f((await e.insert(c.f).values({id:(0,o.v)(),projectId:r.projectId,runId:t.runId,nodeRunId:t.nodeRunId??null,sequence:(i?.m??0)+1,type:t.type,payloadJson:JSON.stringify(t.payload??{}),createdAt:new Date().toISOString()}).returning())[0])}async function h(e,t){await e.execute(s.B`select pg_advisory_xact_lock(hashtext(${t}))`)}async function p(e,t){return t?d(t,e):l.r.transaction(t=>d(t,e))}async function w(e,t){return(await l.r.select().from(c.f).where((0,n.b)((0,n.u)(c.f.runId,e),(0,n.H)(c.f.sequence,t))).orderBy((0,i.M)(c.f.sequence))).map(f)}e.s(["q",0,p,"f",0,function(e,t){return d(t,e)},"J",0,w,"g",0,h]),r()}catch(e){r(e)}},!1),58096,e=>e.a(async(t,r)=>{try{var n=e.i(74533),i=e.i(50227),a=e.i(75225),s=e.i(24924),o=e.i(92335),l=e.i(44586),c=e.i(29420),u=e.i(64950),f=e.i(40855),d=e.i(82283),h=t([s,u]);[s,u]=h.then?(await h)():h;class j extends Error{status;constructor(e,t=409){super(e),this.status=t,this.name="ConnectError"}}let P=(e,t,r)=>new Promise((i,a)=>(0,n.execFile)(e,t,{cwd:r,timeout:12e4,maxBuffer:8388608,env:{...process.env,GH_PROMPT_DISABLED:"1",GIT_TERMINAL_PROMPT:"0"}},(e,t,r)=>e?a(Object.assign(Error(String(r||e.message)),{code:e.code})):i(String(t)))),E=/^(https:\/\/github\.com\/[\w.-]+\/[\w.-]+?(\.git)?\/?|git@github\.com:[\w.-]+\/[\w.-]+?(\.git)?)$/,_=d.f.delivery.connect;function p(e){let t=e instanceof Error?e.message:String(e);return e?.code==="ENOENT"?_.noGh:/gh auth login|not logged in|authentication/i.test(t)?_.notLoggedIn:/name already exists/i.test(t)?_.nameTaken:/repository not found|could not read from remote|does not appear to be a git repository/i.test(t)?_.notFound:/rejected|fetch first|non-fast-forward/i.test(t)?_.notEmpty:_.failed((0,f.l)((0,f.h)(e instanceof Error?e.message:String(e)).trim(),300))}function w(e,t){let r=e.trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._-]/g,"").replace(/^[.-]+/,"").slice(0,100);if((0,l.f)(r))return r;let n=t?(0,i.basename)(t).replace(/[^A-Za-z0-9._-]/g,"-").slice(0,100):"";return(0,l.f)(n)?n:"my-project"}let A="plaincrew.github";async function m(e,t){return t("git",["config","--local","--get",A],e).then(e=>"off"===e.trim(),()=>!1)}async function y(e,t,r){t?await r("git",["config","--local",A,"off"],e):await r("git",["config","--local","--unset-all",A],e).catch(()=>void 0)}let B=(e,t)=>t("git",["remote","get-url","origin"],e).then(e=>e.trim()||null,()=>null);async function g(e,t,r){let n=await B(e,r);if(n)return{url:n};let i=await b(e,t,r);return await y(e,!1,r),i}async function b(e,t,r){let n=(0,c.I)(e)??"main";if("url"in t){let i,a=(i=t.url.trim(),E.test(i)?i.replace(/\/$/,""):null);if(!a)throw new j(_.badLink,400);await r("git",["remote","add","origin",a],e);try{await r("git",["push","-u","origin",n],e)}catch(t){throw await r("git",["remote","remove","origin"],e).catch(()=>void 0),new j(p(t))}return{url:a}}let i=t.name?.trim()||w("",e);if(!(0,l.f)(i))throw new j(_.badName,400);try{await r("gh",["repo","create",i,"public"===t.create?"--public":"--private","--source",".","--remote","origin"],e),await r("git",["push","-u","origin",n],e)}catch(e){throw new j(p(e))}return{url:await B(e,r)}}async function v(e,t,r=P){let n=await (0,u.I)(e),i=n?.repoPath;if(!i)throw new j(_.noFolder);let a="create"in t&&!t.name?.trim()?{...t,name:w(n.name,i)}:t;return g(i,a,r)}async function S(e,t,r=P){let n=(await s.r.select().from(o.B).where((0,a.u)(o.B.id,e)))[0];if(!n)throw new j(d.f.errors.runNotFound,404);return v(n.projectId,t,r)}async function k(e,t=P){let r=await (0,u.I)(e),n=r?.repoPath??null,i=w(r?.name??"",n);if(!n)return{url:null,here:!1,skipped:!1,suggestedName:i};let a=await B(n,t);return{url:a?a.replace(/^git@github\.com:/,"https://github.com/").replace(/\.git$/,""):null,here:!0,skipped:!a&&await m(n,t),suggestedName:i}}async function x(e,t=P){let r=(await s.r.select().from(o.B).where((0,a.u)(o.B.id,e)))[0];if(!r)throw new j(d.f.errors.runNotFound,404);return k(r.projectId,t)}async function I(e,t,r=P){let n=(await (0,u.I)(e))?.repoPath;if(!n)throw new j(_.noFolder);return await y(n,t,r),k(e,r)}async function $(e,t,r=P){let n=(await s.r.select().from(o.B).where((0,a.u)(o.B.id,e)))[0];if(!n)throw new j(d.f.errors.runNotFound,404);return I(n.projectId,t,r)}e.s(["Y",0,j,"A",0,A,"c",0,S,"J",0,v,"$",0,k,"v",0,x,"U",0,I,"B",0,$]),r()}catch(e){r(e)}},!1),62534,e=>{"use strict";var t=e.i(2157),r=e.i(50227),n=e.i(32374);function i(e){let n=n=>(0,t.existsSync)((0,r.join)(e,n));return n("package.json")?n("pnpm-lock.yaml")?"pnpm install --frozen-lockfile --prefer-offline":n("yarn.lock")?"yarn install --frozen-lockfile":n("bun.lockb")||n("bun.lock")?"bun install --frozen-lockfile":n("package-lock.json")?"npm ci --prefer-offline --no-audit --no-fund":"npm install --no-package-lock --no-audit --no-fund":null}async function a(e,t){let r=i(e);if(!r)return null;let a=new AbortController,s=setTimeout(()=>a.abort(),6e5),o=()=>a.abort();t?.addEventListener("abort",o,{once:!0});try{let t=await (0,n.P)(r,e,a.signal);return{command:r,ok:t.started&&0===t.exitCode,durationMs:t.durationMs,outputTail:t.outputTail}}finally{clearTimeout(s),t?.removeEventListener("abort",o)}}e.s(["d",0,i,"F",0,a])},64950,e=>e.a(async(t,r)=>{try{var n=e.i(2157),i=e.i(60526),a=e.i(50227),s=e.i(75225),o=e.i(6561),l=e.i(24924),c=e.i(92335),u=e.i(82283),f=e.i(91138),d=t([l]);[l]=d.then?(await d)():d;let b=globalThis;function h(){if(process.env.FACTORY_MACHINE_ID)return{id:process.env.FACTORY_MACHINE_ID,name:process.env.FACTORY_MACHINE_NAME??"this computer"};if(b.__factoryMachine)return b.__factoryMachine;let e=process.env.FACTORY_MACHINE_FILE??(0,a.join)(f.f,"machine.json"),t=null;if((0,n.existsSync)(e))try{let r=JSON.parse((0,n.readFileSync)(e,"utf8"));"string"==typeof r.id&&"string"==typeof r.name&&(t={id:r.id,name:r.name})}catch{t=null}return t||(t={id:(0,o.v)(),name:(0,i.hostname)().replace(/\.local$/,"")||"this computer"},(0,n.mkdirSync)((0,a.dirname)(e),{recursive:!0}),(0,n.writeFileSync)(e,JSON.stringify(t,null,2))),b.__factoryMachine=t}async function p(e){return e?(await l.r.select({name:c.u.name}).from(c.u).where((0,s.u)(c.u.id,e)))[0]?.name??null:null}async function w(e,t=l.r){let r=(await t.select().from(c.c).where((0,s.u)(c.c.id,e)))[0];if(!r)return;let n=(await t.select().from(c.l).where((0,s.b)((0,s.u)(c.l.projectId,e),(0,s.u)(c.l.machineId,h().id))))[0];return n?{...r,repoPath:n.repoPath,baseStatus:n.baseStatus,baseCommit:n.baseCommit,baseLockHash:n.baseLockHash,baseMessage:n.baseMessage,baseUpdatedAt:n.baseUpdatedAt}:r}async function m(e,t,r=l.r){let n=h().id;if((await r.select().from(c.l).where((0,s.b)((0,s.u)(c.l.projectId,e),(0,s.u)(c.l.machineId,n))))[0])return void await r.update(c.l).set(t).where((0,s.b)((0,s.u)(c.l.projectId,e),(0,s.u)(c.l.machineId,n)));let i=(await r.select().from(c.c).where((0,s.u)(c.c.id,e)))[0];await r.insert(c.l).values({projectId:e,machineId:n,repoPath:i?.repoPath??null,baseStatus:i?.baseStatus??"none",baseCommit:i?.baseCommit??null,baseLockHash:i?.baseLockHash??null,baseMessage:i?.baseMessage??null,baseUpdatedAt:i?.baseUpdatedAt??null,...t})}async function y(e){let t=(await l.r.select({machineId:c.B.machineId}).from(c.B).where((0,s.u)(c.B.id,e)))[0],r=t?.machineId??null;return{here:null!==r&&r===h().id,machineId:r,machine:await p(r)}}async function g(e){let t=await y(e);return t.here?null:u.f.machine.elsewhere(t.machine)}e.s(["b",0,g,"I",0,w,"D",0,y,"J",0,m,"j",0,h]),r()}catch(e){r(e)}},!1),77954,e=>e.a(async(t,r)=>{try{var n=e.i(75225),i=e.i(24924),a=e.i(92335),s=t([i]);async function o(e,t=i.r){if((await t.select().from(a.a).where((0,n.b)((0,n.u)(a.a.runId,e),(0,n.u)(a.a.decision,"approved"))))[0])return"person";let r=(await t.select().from(a.B).where((0,n.u)(a.B.id,e)))[0];if(!r)return null;let s=(await t.select().from(a.G).where((0,n.u)(a.G.id,r.versionId)))[0];if(!s)return null;let l=JSON.parse(s.graphJson).blocks.filter(e=>"human"===e.kind).map(e=>e.id);if(0===l.length)return null;let c=new Set((await t.select().from(a.r).where((0,n.b)((0,n.u)(a.r.runId,e),(0,n.u)(a.r.state,"passed")))).filter(e=>l.includes(e.blockId)).map(e=>e.id));return(await t.select().from(a.f).where((0,n.b)((0,n.u)(a.f.runId,e),(0,n.u)(a.f.type,"node.completed")))).some(e=>{if(!e.nodeRunId||!c.has(e.nodeRunId))return!1;try{return!0===JSON.parse(e.payloadJson).autoApproved}catch{return!1}})?"app":null}async function l(e,t=i.r){let r=new Set;if(0===e.length)return r;let s=await t.select({id:a.B.id,versionId:a.B.versionId}).from(a.B).where((0,n.b)((0,n.y)(a.B.id,e),(0,n.u)(a.B.status,"completed")));if(0===s.length)return r;let o=s.map(e=>e.id),c=new Set((await t.select({runId:a.a.runId}).from(a.a).where((0,n.b)((0,n.y)(a.a.runId,o),(0,n.u)(a.a.decision,"approved")))).map(e=>e.runId)),u=new Map;for(let e of(await t.select().from(a.G).where((0,n.y)(a.G.id,[...new Set(s.map(e=>e.versionId))]))))try{u.set(e.id,JSON.parse(e.graphJson).blocks.filter(e=>"human"===e.kind).map(e=>e.id))}catch{u.set(e.id,[])}let f=new Map(s.map(e=>[e.id,e.versionId])),d=new Map;for(let e of(await t.select().from(a.r).where((0,n.b)((0,n.y)(a.r.runId,o),(0,n.u)(a.r.state,"passed")))))u.get(f.get(e.runId)??"")?.includes(e.blockId)&&d.set(e.id,e.runId);if(0===d.size)return r;for(let e of(await t.select().from(a.f).where((0,n.b)((0,n.y)(a.f.nodeRunId,[...d.keys()]),(0,n.u)(a.f.type,"node.completed")))))if(!(!e.nodeRunId||!d.has(e.nodeRunId)||c.has(e.runId)))try{!0===JSON.parse(e.payloadJson).autoApproved&&r.add(e.runId)}catch{}return r}[i]=s.then?(await s)():s,e.s(["v",0,o,"o",0,l]),r()}catch(e){r(e)}},!1),20195,e=>e.a(async(t,r)=>{try{var n=e.i(16806),i=e.i(74533),a=e.i(2157),s=e.i(61095),o=e.i(50227),l=e.i(75225),c=e.i(24924),u=e.i(92335),f=e.i(62534),d=e.i(40855),h=e.i(32374),p=e.i(82283),w=e.i(64950),m=t([c,w]);[c,w]=m.then?(await m)():m;let _=globalThis.__factoryPreviews??=new Map;function y(e,t){let r;try{r=JSON.parse((0,a.readFileSync)((0,o.join)(e,"package.json"),"utf8"))}catch{return null}if(!r.scripts?.dev)return null;let n={...r.dependencies,...r.devDependencies},i=t=>(0,a.existsSync)((0,o.join)(e,t)),s=i("pnpm-lock.yaml")?"pnpm":i("yarn.lock")?"yarn":i("bun.lockb")||i("bun.lock")?"bun":"npm",l=String(t);return{argv:[..."npm"===s?["npm","run","dev","--"]:"yarn"===s?["yarn","dev"]:[s,"run","dev"],...n.next?["-p",l,"-H","127.0.0.1"]:n.vite?["--port",l,"--host","127.0.0.1","--strictPort"]:[]],installArgv:i("node_modules")?null:[s,"install"]}}let A=Promise.resolve();function g(e,t){e.log=(0,d.l)((0,d.h)((0,h.X)(e.log+t.toString())).slice(-4e3),4e3)}async function b(e,t){let r=Date.now()+18e4;for(;Date.now()<r&&"starting"===t.status&&(!t.child||null===t.child.exitCode);)try{return await fetch(e,{signal:AbortSignal.timeout(3e3)}),!0}catch{await new Promise(e=>setTimeout(e,1e3))}return!1}function v(e,t){if(e?.pid)try{process.kill(-e.pid,t)}catch{}}function S(e){let t=_.get(e);return t?{status:t.status,url:t.url,message:t.message,log:t.log}:{status:"stopped",url:null,message:null,log:""}}let B=globalThis.__factoryPreviewSeen??=new Map,T=globalThis;T.__factoryPreviewWatch||(T.__factoryPreviewWatch=setInterval(()=>void function(e=18e4,t=Date.now()){let r=[];for(let[n,i]of[...B]){let a=_.get(n)?.status;"installing"!==a&&"starting"!==a&&"ready"!==a?B.delete(n):t-i>e&&(E(n),r.push(n))}}(),6e4).unref());let F=globalThis.__factoryPreviewStops??=new Map;async function k(e,t){let r=F.get(e)??0,n=await t();return(F.get(e)??0)===r?n:(E(e),S(e))}async function x(e){let t=await (0,w.b)(e);if(t)throw new N(t);let r=_.get(e);if(r&&"failed"!==r.status&&"stopped"!==r.status)return S(e);if(!(await c.r.select().from(u.B).where((0,l.u)(u.B.id,e)))[0])throw new N(p.f.preview.noWorktree);if(await I(e)){let t={status:"installing",url:null,message:null,log:"",child:null,port:null};return _.set(e,t),(async()=>{let r=Date.now()+R;for(;Date.now()<r&&"installing"===t.status&&await I(e).catch(()=>!1);)await new Promise(e=>setTimeout(e,1e3));if(_.get(e)===t&&"installing"===t.status){_.delete(e);try{await $(e)}catch(r){_.set(e,{...t,status:"failed",message:r instanceof N?r.message:p.f.preview.failed})}}})(),S(e)}return $(e)}let R=24e4;async function I(e){let t=(await c.r.select().from(u.B).where((0,l.u)(u.B.id,e)))[0];return!!t&&("queued"===t.status||"running"===t.status)&&(!(t.worktreePath&&(0,a.existsSync)(t.worktreePath))||"running"===t.status&&!!(0,f.d)(t.worktreePath)&&void 0===(await c.r.select().from(u.f).where((0,l.b)((0,l.u)(u.f.runId,e),(0,l.u)(u.f.type,"run.installed"))))[0])}async function $(e){let t=(await c.r.select().from(u.B).where((0,l.u)(u.B.id,e)))[0];if(!t?.worktreePath||!(0,a.existsSync)(t.worktreePath))throw new N(p.f.preview.noWorktree);let r=await (0,w.I)(t.projectId);return E(`site:${t.projectId}`),j(e,t.worktreePath,r?.repoPath??null)}async function j(e,t,r){let l,c=_.get(e);if(c&&"failed"!==c.status&&"stopped"!==c.status)return S(e);let u=await (A=(l=A.then(()=>new Promise((e,t)=>{let r=n=>{if(n>4400)return t(Error("no free port"));let i=(0,s.createServer)();i.once("error",()=>r(n+1)),i.listen(n,"127.0.0.1",()=>i.close(()=>[..._.values()].some(e=>e.port===n&&"failed"!==e.status&&"stopped"!==e.status)?r(n+1):e(n)))};r(4200)}))).then(()=>new Promise(e=>setTimeout(e,0)),()=>void 0),l),f=y(t,u);if(!f)throw new N(p.f.preview.noDevScript);let d={status:f.installArgv?"installing":"starting",url:null,message:null,log:"",child:null,port:u};_.set(e,d),r&&function(e,t){let r=[];for(let n of(0,a.readdirSync)(e))!(!/^\.env(\..+)?$/.test(n)||/\.example$|\.sample$|\.template$/.test(n))&&((0,a.existsSync)((0,o.join)(t,n))||((0,a.copyFileSync)((0,o.join)(e,n),(0,o.join)(t,n)),r.push(n)))}(r,t);let h=(0,n.f)({NODE_ENV:"development",PORT:String(u),HOST:"127.0.0.1",HOSTNAME:"127.0.0.1",BROWSER:"none"});return(async()=>{if(f.installArgv){var e;let r=await (e=f.installArgv,new Promise(r=>{let n=(0,i.spawn)(e[0],e.slice(1),{cwd:t,env:h,detached:!0,stdio:["ignore","pipe","pipe"]});d.child=n,n.stdout?.on("data",e=>g(d,e)),n.stderr?.on("data",e=>g(d,e)),n.once("error",()=>r(null)),n.once("close",e=>r(e))}));if("stopped"===d.status)return;if(0!==r){d.status="failed",d.message=p.f.preview.installFailed;return}d.status="starting"}let r=(0,i.spawn)(f.argv[0],f.argv.slice(1),{cwd:t,env:h,detached:!0,stdio:["ignore","pipe","pipe"]});d.child=r,r.stdout?.on("data",e=>g(d,e)),r.stderr?.on("data",e=>g(d,e)),r.once("close",()=>{("starting"===d.status||"ready"===d.status)&&(d.status="failed",d.message=p.f.preview.exited)});let n=`http://127.0.0.1:${u}/`;await b(n,d)?(d.status="ready",d.url=n):"starting"===d.status&&(d.status="failed",d.message=p.f.preview.neverServed,v(r,"SIGTERM"))})(),S(e)}async function P(e,t=3e5){let r=Date.now()+t;for(;Date.now()<r;){let t=S(e);if("ready"===t.status)return t.url;if("failed"===t.status||"stopped"===t.status)break;await new Promise(e=>setTimeout(e,1e3))}return null}function E(e){F.set(e,(F.get(e)??0)+1),B.delete(e);let t=_.get(e);if(!t)return;t.status="stopped",t.url=null;let r=t.child;v(r,"SIGTERM"),setTimeout(()=>v(r,"SIGKILL"),3e3).unref()}class N extends Error{}let O=globalThis;O.__factoryPreviewExitHook||(O.__factoryPreviewExitHook=!0,process.once("exit",()=>{for(let e of _.values())v(e.child,"SIGKILL")})),e.s(["L",0,N,"n",0,y,"h",0,S,"s",0,e=>k(e,()=>x(e)),"O",0,j,"D",0,E,"m",0,k,"q",0,P,"i",0,function(e){B.set(e,Date.now())}]),r()}catch(e){r(e)}},!1),40855,e=>{"use strict";let t="[redacted]",r=[[/-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z ]*PRIVATE KEY-----/g,t],[/\bsk-(?:ant-)?[A-Za-z0-9_-]{16,}/g,t],[/\bgh[pousr]_[A-Za-z0-9]{20,}/g,t],[/\bgithub_pat_[A-Za-z0-9_]{20,}/g,t],[/\bAKIA[0-9A-Z]{16}\b/g,t],[/\bxox[abposr]-[A-Za-z0-9-]{10,}/g,t],[/\b(Bearer)\s+[A-Za-z0-9._~+/=-]{8,}/gi,`$1 ${t}`],[/(["']?[A-Za-z0-9_]*(?:key|token|secret|password|passwd|credential)[A-Za-z0-9_]*["']?\s*[:=]\s*)("[^"]*"|'[^']*'|[^\s"',}]+)/gi,`$1${t}`]],n=/KEY|TOKEN|SECRET|PASSWORD|CREDENTIAL/i,i=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");e.s(["l",0,function(e,t){return e.length<=t?e:`${e.slice(0,t-1)}…`},"h",0,function(e,a=process.env){let s=e;for(let[e,r]of Object.entries(a))r&&!(r.length<8)&&n.test(e)&&(s=s.replace(RegExp(i(r),"g"),t));for(let[e,t]of r)s=s.replace(e,t);return s}])},87345,e=>{"use strict";var t=e.i(74533),r=e.i(2157),n=e.i(50227),i=e.i(82283);let a=/(^|\/)\.env(\.|$)|secret|credential/i,s=[[a,i.f.risk.areas.secrets],[/auth|login|logout|sign-?in|sign-?up|session|password|oauth|jwt|token/i,i.f.risk.areas.auth],[/payment|billing|stripe|checkout|invoice|subscription|paypal|price|pricing/i,i.f.risk.areas.payments],[/migration|(^|\/)(prisma|supabase|drizzle|db|database)\/|schema\.(prisma|sql|ts)$|\.sql$/i,i.f.risk.areas.database],[/(^|\/)(api|server|actions)\/|(^|\/)(middleware|proxy)\.[jt]s$|route\.[jt]sx?$/i,i.f.risk.areas.server],[/(^|\/)(package\.json|pnpm-lock\.yaml|package-lock\.json|yarn\.lock|bun\.lockb?|tsconfig[^/]*\.json)$|\.config\.[cm]?[jt]s$|(^|\/)\.[a-z]+rc(\.[a-z]+)?$/i,i.f.risk.areas.config],[/(^|\/)(\.github|\.gitlab|\.circleci)\/|(^|\/)(dockerfile|docker-compose[^/]*|vercel\.json|vercel\.ts|fly\.toml|netlify\.toml|render\.yaml|procfile)$/i,i.f.risk.areas.deploy]];function o(e,t){let r=e.toLowerCase(),n=t.toLowerCase();return n.endsWith("/")?r.startsWith(n):r===n}function l(e,t,r=[],n=[]){let a,c,u=[],f=e.reduce((e,t)=>e+t.lines,0);for(let t of(0===e.length&&u.push(i.f.risk.nothingChanged),u.push(...(a=[...new Set(r)].flatMap(t=>{let r=e.filter(e=>o(e.path,t));return r.length>0?[i.f.risk.insideCore(r[0].path,t,r.length-1)]:[]})).length>5?[...a.slice(0,5),i.f.risk.moreCore(a.length-5)]:a),u.push(...(c=n.flatMap(t=>{let r=e.find(e=>t.paths.some(t=>o(e.path,t)));return r?[i.f.risk.onDecision(r.path,t.text)]:[]})).length>5?[...c.slice(0,5),i.f.risk.moreDecisions(c.length-5)]:c),e)){let e=s.find(([e])=>e.test(t.path));e&&u.push(i.f.risk.touches(t.path,e[1]))}e.length>8&&u.push(i.f.risk.tooManyFiles(e.length,8)),f>300&&u.push(i.f.risk.tooManyLines(f,300)),t.testsRan?t.testsPassed||u.push(i.f.risk.testsFailed):u.push(i.f.risk.noTests),t.testsChanged&&u.push(i.f.risk.testsChanged),t.reviewOpen&&u.push(i.f.risk.reviewStillOpen),t.reviewUnchecked&&u.push(i.f.risk.fixUnchecked),t.reviewUnreadable&&u.push(i.f.risk.reviewUnreadable);let d=0===u.length?"low":"high",h=t.testsChanged||!t.testsRan,p="high"===d&&h&&u.every(e=>e===i.f.risk.noTests||e===i.f.risk.testsChanged);return{level:d,reasons:"low"===d?[i.f.risk.lowBecause(e.length,f)]:u,files:e.map(e=>e.path),linesChanged:f,...p?{onlyTests:p}:{}}}e.s(["Q",0,a,"y",0,s,"r",0,function(e,a,s,o=[],c=[]){try{return l(function(e,i){let a=r=>(0,t.execFileSync)("git",r,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","pipe"]}),s=[];for(let e of a(["diff","--numstat","-z","--no-renames",i]).split("\0")){let[t,r,...n]=e.split(" "),i=n.join(" ");if(!i)continue;let a=e=>void 0===e||"-"===e?1:Number(e);s.push({path:i,lines:a(t)+a(r)})}let o=new Set(s.map(e=>e.path));return[...s,...a(["ls-files","--others","--exclude-standard","-z"]).split("\0").filter(e=>e&&!o.has(e)).map(t=>{let i=1;try{i=Math.max(1,(0,r.readFileSync)((0,n.join)(e,t),"utf8").split("\n").length)}catch{}return{path:t,lines:i}})]}(e,a),s,o,c)}catch{return{level:"high",reasons:[i.f.risk.unreadable],files:[],linesChanged:0}}},"F",0,l,"B",0,o])},30188,e=>{"use strict";var t=e.i(78500);let r=globalThis,n=r.__factorySerial??=new Map,i=new t.AsyncLocalStorage;async function a(e,t){let r,a=i.getStore();if(a?.has(e))return t();let s=n.get(e)??Promise.resolve(),o=new Promise(e=>r=e),l=s.then(()=>o);n.set(e,l),await s.catch(()=>void 0);try{return await i.run(new Set([...a??[],e]),t)}finally{r(),n.get(e)===l&&n.delete(e)}}e.s(["f",0,a])},69608,e=>e.a(async(t,r)=>{try{var n=e.i(74533),i=e.i(66680),a=e.i(2157),s=e.i(50227),o=e.i(75225),l=e.i(49129),c=e.i(24924),u=e.i(92335),f=e.i(120),d=e.i(65080),h=e.i(55372),p=e.i(20195),w=e.i(40855),m=e.i(82283),y=e.i(64950),g=e.i(65272),b=e.i(26955),v=e.i(91138),S=e.i(37857),k=t([c,f,d,h,p,y]);[c,f,d,h,p,y]=k.then?(await k)():k;let F=(0,s.join)(v.f,"snapshots"),R=["before-desktop","after-desktop","before-mobile","after-mobile"],N={desktop:{viewport:{width:1440,height:900},deviceScaleFactor:1},mobile:{viewport:{width:390,height:844},deviceScaleFactor:2,isMobile:!0,hasTouch:!0}},O=async(e,t)=>{let r=await (0,S.f)();try{for(let n of["desktop","mobile"]){let i=await r.newContext(N[n]),a=await i.newPage();await a.goto(e,{waitUntil:"load",timeout:12e4}),await a.waitForLoadState("networkidle",{timeout:15e3}).catch(()=>void 0),await a.waitForTimeout(1500),await a.screenshot({path:t[n]}),await i.close()}}finally{await r.close()}},M='[role="tab"]:not([aria-selected="true"]), summary, button[aria-expanded="false"]',C=async(e,t,r)=>{let n=await (0,S.f)();try{let i=await n.newContext(N.desktop),[a,s,o]=[await i.newPage(),await i.newPage(),await i.newPage()],l=async(e,t)=>{await e.goto(t,{waitUntil:"load",timeout:12e4}),await e.waitForLoadState("networkidle",{timeout:15e3}).catch(()=>void 0),await e.waitForTimeout(1200)},c=e=>e.screenshot({animations:"disabled"}),u=(e,t)=>o.evaluate(async([e,t])=>{let r=e=>new Promise((t,r)=>{let n=new Image;n.onload=()=>t(n),n.onerror=()=>r(Error("picture")),n.src=`data:image/png;base64,${e}`}),[n,i]=await Promise.all([r(e),r(t)]);if(n.width!==i.width||n.height!==i.height)return 1;let a=e=>{let t=document.createElement("canvas");t.width=e.width,t.height=e.height;let r=t.getContext("2d");return r.drawImage(e,0,0),r.getImageData(0,0,e.width,e.height).data},[s,o]=[a(n),a(i)],l=0;for(let e=0;e<s.length;e+=4)Math.abs(s[e]-o[e])+Math.abs(s[e+1]-o[e+1])+Math.abs(s[e+2]-o[e+2])>48&&l++;return l/(s.length/4)},[e.toString("base64"),t.toString("base64")]),f=async(e,t,r)=>{let n=e.locator(M),i=r?n.filter({hasText:r}).first():null,a=i&&await i.count()>0?i:n.nth(t);await a.count()!==0&&(await a.click({timeout:4e3}).catch(()=>void 0),await e.waitForLoadState("networkidle",{timeout:8e3}).catch(()=>void 0),await e.waitForTimeout(1200))};if(await Promise.all([l(a,e),l(s,t)]),await u(await c(a),await c(s))>3e-4)return null;let d=(e,t,r)=>o.evaluate(async([e,t,r])=>{let n=e=>new Promise((t,r)=>{let n=new Image;n.onload=()=>t(n),n.onerror=()=>r(Error("picture")),n.src=`data:image/png;base64,${e}`}),[i,a]=await Promise.all([n(e),n(t)]),s=Math.min(i.width,a.width),o=Math.min(i.height,a.height);if(0===s||0===o||Math.max(i.height,a.height)>16e3)return null;let l=e=>{let t=document.createElement("canvas");t.width=s,t.height=o;let r=t.getContext("2d");return r.drawImage(e,0,0),r.getImageData(0,0,s,o).data},[c,u]=[l(i),l(a)],f=Math.max(4,Math.floor(.004*s));for(let e=0;e<o;e++){let t=0;for(let n=e*s*4,i=n+4*s;n<i;n+=4)if(Math.abs(c[n]-u[n])+Math.abs(c[n+1]-u[n+1])+Math.abs(c[n+2]-u[n+2])>48&&++t>=f)return Math.floor(e/r)}return i.height!==a.height?Math.floor(o/r):null},[e.toString("base64"),t.toString("base64"),r]),h=!1;for(let o of["desktop","mobile"]){let c="desktop"===o?i:await n.newContext(N[o]),[u,f]="desktop"===o?[a,s]:[await c.newPage(),await c.newPage()];"desktop"!==o&&await Promise.all([l(u,e),l(f,t)]);let p=e=>e.screenshot({fullPage:!0,animations:"disabled"}),w=await d(await p(u),await p(f),N[o].deviceScaleFactor).catch(()=>null);if(null===w)continue;let m=Math.max(0,w-180);await Promise.all([u,f].map(e=>e.evaluate(e=>window.scrollTo(0,e),m))),await u.waitForTimeout(900),await u.screenshot({path:r.before[o],animations:"disabled"}),await f.screenshot({path:r.after[o],animations:"disabled"}),h=!0}if(h)return"@below";let p=(await s.locator(M).allInnerTexts()).slice(0,6).map(e=>(e.split("\n")[0]??"").trim()),w=null;for(let[r,n]of p.entries()){r>0&&await Promise.all([l(a,e),l(s,t)]),await Promise.all([f(a,r,n),f(s,r,n)]);let i=await u(await c(a),await c(s));i>3e-4&&(!w||i>w.by)&&(w={index:r,name:n,by:i})}if(!w)return null;let m=w;for(let o of["desktop","mobile"]){let c="desktop"===o?i:await n.newContext(N[o]),[u,d]="desktop"===o?[a,s]:[await c.newPage(),await c.newPage()];await Promise.all([l(u,e),l(d,t)]),await Promise.all([f(u,m.index,m.name),f(d,m.index,m.name)]),await u.screenshot({path:r.before[o]}),await d.screenshot({path:r.after[o]})}return m.name||null}finally{await n.close()}},D=/^(?:src\/)?app\/(?:(.*)\/)?page\.(?:tsx|jsx|ts|js|mdx)$/,q=/^(?:src\/)?pages\/(.*)\.(?:tsx|jsx|ts|js|mdx)$/;function x(e){let t=D.exec(e);if(t)return`/${(t[1]??"").split("/").filter(e=>e&&!/^\(.*\)$/.test(e)&&!e.startsWith("@")).join("/")}`;let r=q.exec(e);return r&&!/^(_|api\/)/.test(r[1])?`/${r[1].replace(/(^|\/)index$/,"")}`.replace(/\/$/,"")||"/":null}function I(e){for(let t of e){let e=x(t);if(null!==e&&!e.includes("["))return e}return"/"}let L=/(?:\bfrom\s*|\bimport\s*\(?\s*|\brequire\(\s*)['"]([^'"]+)['"]/g,z=["",".tsx",".ts",".jsx",".js",".mjs",".mdx","/index.tsx","/index.ts","/index.jsx","/index.js"];async function $(e,t,r,n,i=6){let a=e=>e.split(/[?#]/)[0].replace(/(.)\/$/,"$1"),s=new Set(["/"]),o=["/"],l=0;for(let c=0;c<3&&o.length>0;c++){let c=[];for(let u of o){if(l++>=i)return null;let o=await r(new URL(u,t).toString()).catch(()=>[]),f=function(e,t,r){let n=RegExp(`^${e.split("/").map(e=>/^\[\[?\.\.\./.test(e)?".+":e.startsWith("[")?"[^/]+":e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("/")}$`),i=new Set(r);for(let e of t){let t=e.split(/[?#]/)[0].replace(/(.)\/$/,"$1");if(n.test(t)&&!i.has(t))return t}return null}(e,o,n);if(f)return f;for(let e of o.map(a))s.has(e)||n.includes(e)||(s.add(e),c.push(e))}o=c}return null}let H=[/(^|\/)(__tests__|__mocks__|tests?|e2e|cypress|playwright|docs?|\.github|\.husky|\.vscode)\//,/\.(test|spec|stories)\.[cm]?[jt]sx?$/,/\.(md|mdx|txt|snap|lock)$/i,/(^|\/)(package\.json|package-lock\.json|pnpm-lock\.yaml|bun\.lockb?|tsconfig[^/]*\.json|\.[^/]+)$/,/(^|\/)(vitest|jest|playwright|cypress|eslint|prettier|commitlint|lint-staged)\.config\.[cm]?[jt]s$/,/(^|\/)(vitest|jest)\.setup\.[cm]?[jt]sx?$/],J=/(^|\/)__tests__\/|\.(test|spec)\.[cm]?[jt]sx?$/;function j(e){return 0===e.length||e.some(e=>/(^|\/)(app|pages)\//.test(e)&&!J.test(e)||!H.some(t=>t.test(e)))}let G={status:"unneeded",route:null,shots:[],message:null},W=(e,t,r=F)=>(0,s.join)(r,e,`${t}.png`),U=/^[0-9a-f]{16}$/,K=(e,t,r,n=F)=>(0,s.join)(n,e,"kept",t,`${r}.png`);async function P(e,t,r=F,n){if(!R.includes(t))return null;if(void 0!==n){if(!U.test(n))return null;let i=K(e,n,t,r);return(0,a.existsSync)(i)?new Uint8Array((0,a.readFileSync)(i)):(await (0,g.h)()?.get((0,g.q)(e,n,t)))?.body??null}let i=Z(e,t,r);return i?new Uint8Array((0,a.readFileSync)(i)):(await (0,g.h)()?.get((0,g.g)(e,t)))?.body??null}let Z=(e,t,r=F)=>R.includes(t)&&(0,a.existsSync)(W(e,t,r))?W(e,t,r):null,Y=async e=>{let t=(await c.r.select().from(u.B).where((0,o.u)(u.B.id,e)))[0];try{if(t?.worktreePath&&(0,a.existsSync)(t.worktreePath))return(0,i.createHash)("sha256").update(`${V(t)??""}:${(0,b.$)(t.worktreePath)}`).digest("hex").slice(0,16)}catch{}return(0,i.createHash)("sha256").update(await (0,d.c)(e)).digest("hex").slice(0,16)},V=e=>e.baseCommit??e.deliveryBase,X=globalThis.__factorySnapshots??=new Map;async function E(e){let t=X.get(e);if(void 0!==t)return{status:"working",route:null,shots:[],message:t};if(!j(await (0,d.Q)(e)))return G;let r=(await c.r.select().from(u.f).where((0,o.b)((0,o.u)(u.f.runId,e),(0,o.u)(u.f.type,"run.snapshots"))).orderBy((0,l.A)(u.f.sequence)))[0];if(!r)return{status:"none",route:null,shots:[],message:null};let n=JSON.parse(r.payloadJson);if(n.change!==await Y(e))return{status:"none",route:null,shots:[],message:null};let i=n.shots.filter(t=>null!==(0,g.h)()||null!==Z(e,t));return i.length>0?{status:"ready",route:n.route,opened:n.opened??null,shots:i,taken:String(r.sequence),message:null,newProject:!0===n.newProject}:{status:"failed",route:n.route,shots:[],message:n.message}}let Q=async e=>{let t=await (0,S.f)();try{let r=await t.newPage();await r.goto(e,{waitUntil:"load",timeout:12e4}),await r.waitForLoadState("networkidle",{timeout:15e3}).catch(()=>void 0);let n=await r.$$eval("a[href]",e=>e.map(e=>e.href)),i=new URL(e).origin;return n.filter(e=>e.startsWith(`${i}/`)).map(e=>e.slice(i.length))}finally{await t.close()}},ee=(e,t)=>(0,n.execFileSync)("git",t,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","pipe"]}).trim();async function _(e,t,r=F){let n={status:"none",route:null,shots:[],message:null};if(!U.test(t))return n;for(let i of(await c.r.select().from(u.f).where((0,o.b)((0,o.u)(u.f.runId,e),(0,o.u)(u.f.type,"run.snapshots"))).orderBy((0,l.A)(u.f.sequence)))){let s=JSON.parse(i.payloadJson);if(s.change!==t)continue;let o=s.shots.filter(n=>null!==(0,g.h)()||(0,a.existsSync)(K(e,t,n,r)));return o.length>0?{status:"ready",route:s.route,opened:s.opened??null,shots:o,taken:`${i.sequence}-${t}`,message:null,newProject:!0===s.newProject}:n}return n}async function A(e,t=F){let r=(await c.r.select().from(u.B).where((0,o.u)(u.B.id,e)))[0];if(!r)return[];let n=r.request,i=0,s=new Set,f=new Set,d=new Map;for(let r of(await c.r.select().from(u.f).where((0,o.u)(u.f.runId,e)).orderBy((0,l.M)(u.f.sequence)))){let o=JSON.parse(r.payloadJson);"node.plan_decided"===r.type&&r.nodeRunId&&f.add(r.nodeRunId);let l="string"==typeof o.note?o.note.trim():"",c=`${String(o.by)}-${String(o.round)}`;if("node.reopened"===r.type&&"fixes"!==o.by&&"reviewer"!==o.by&&l&&!s.has(c)&&!(r.nodeRunId&&f.has(r.nodeRunId))&&(s.add(c),n=l,i++),"run.snapshots"!==r.type||"string"!=typeof o.change||!U.test(o.change)||!Array.isArray(o.shots))continue;let u=o.change,h=o.shots.filter(r=>null!==(0,g.h)()||(0,a.existsSync)(K(e,u,r,t)));h.length>0&&d.set(i,{change:u,asked:n,shots:h,taken:`${r.sequence}-${u}`,newProject:!0===o.newProject})}return[...d.entries()].sort((e,t)=>e[0]-t[0]).map(([,e])=>e)}async function B(e,t=O,r=F,n=Q,i=C){let l,b=await (0,y.b)(e);if(b)throw new et(b);if(X.has(e))return E(e);let v=(await c.r.select().from(u.B).where((0,o.u)(u.B.id,e)))[0];if(!v?.worktreePath||!(0,a.existsSync)(v.worktreePath))throw new et(m.f.snapshots.noWorkingCopy);let S=await (0,y.I)(v.projectId),k=S?.repoPath,P=V(v);if(!k||!P)throw new et(m.f.snapshots.noWorkingCopy);let _=await (0,d.Q)(e);if(!j(_))return G;let A=await Y(e),R=v.worktreePath,N=_.some(e=>null!==x(e))?_:function(e,t){let r=e=>z.map(t=>e+t).find(e=>t.has(e))??null,n=new Map;for(let[e,i]of t){let t=e.split("/").slice(0,-1);for(let a of i.matchAll(L)){let i=a[1],s=(i.startsWith(".")?[i.split("/").reduce((e,t)=>"."===t||""===t?e:".."===t?e.slice(0,-1):[...e,t],t).join("/")]:/^[@~]\//.test(i)?[`src/${i.slice(2)}`,i.slice(2)]:[]).map(r).find(Boolean);s&&s!==e&&n.set(s,[...n.get(s)??[],e])}}let i=new Set(e),a=[...e];for(;a.length>0;){let e=a.filter(e=>null!==x(e));if(e.length>0)return e;for(let e of a=[...new Set(a.flatMap(e=>n.get(e)??[]))].filter(e=>!i.has(e)))i.add(e)}return[]}(_,function(e){let t=new Map;try{for(let r of ee(e,["ls-files","--cached","--others","--exclude-standard"]).split("\n").filter(e=>/\.(?:[cm]?[jt]sx?|mdx)$/.test(e)).slice(0,4e3))try{let n=(0,a.readFileSync)((0,s.join)(e,r),"utf8");n.length<4e5&&t.set(r,n)}catch{}}catch{}return t}(R)),M=I(N),D=(l=N.map(x).filter(e=>null!==e)).some(e=>!e.includes("["))?null:l[0]??null,q=(0,s.join)(r,e),H=(0,s.join)(q,"before-tree"),J=`${e}:before`,U=["starting","installing","ready"].includes((0,p.h)(e).status);return X.set(e,m.f.snapshots.starting),(async()=>{let o=[],l=null,u=null,d=!1;try{(0,a.mkdirSync)(q,{recursive:!0}),(0,a.existsSync)(H)&&T(k,H),ee(k,["worktree","add","-q","--detach",H,P]),await (0,f.S)(v.projectId,H);let c=null!==(0,p.n)(H,0);d=!c,M=c?I(N):"/",await Promise.all([(0,p.s)(e),c?(0,p.O)(J,H,k):null]),X.set(e,m.f.snapshots.waiting);let[h,w]=await Promise.all([(0,p.q)(e),c?(0,p.q)(J):null]);if(D&&h&&c)try{let e=ee(R,["ls-files"]).split("\n").map(x).filter(e=>null!==e&&!e.includes("["));M=await $(D,h,n,e)??M}catch{}X.set(e,m.f.snapshots.shooting);let y=e=>new URL(M,e).toString();if(w&&(await t(y(w),{desktop:W(e,"before-desktop",r),mobile:W(e,"before-mobile",r)}),o.push("before-desktop","before-mobile")),h&&(await t(y(h),{desktop:W(e,"after-desktop",r),mobile:W(e,"after-mobile",r)}),o.push("after-desktop","after-mobile")),w&&h){X.set(e,m.f.snapshots.looking);let t=t=>({desktop:W(e,`${t}-desktop`,r),mobile:W(e,`${t}-mobile`,r)});u=await i(y(w),y(h),{before:t("before"),after:t("after")}).catch(()=>null)}let b=(0,g.h)();for(let t of((0,a.mkdirSync)((0,s.join)(q,"kept",A),{recursive:!0}),o)){if((0,a.copyFileSync)(W(e,t,r),K(e,A,t,r)),!b)continue;let n=(0,a.readFileSync)(W(e,t,r));await b.put((0,g.g)(e,t),n,"image/png"),await b.put((0,g.q)(e,A,t),n,"image/png")}(!c||w)&&h||(l=m.f.snapshots.didNotStart(h?m.f.snapshots.beforeVersion:m.f.snapshots.afterVersion))}catch(e){l=m.f.snapshots.failed((0,w.l)((0,w.h)(String(e?.message??e)).split("\n")[0]??"",200))}finally{(0,p.D)(J),U||(0,p.D)(e),setTimeout(()=>T(k,H),4e3).unref();try{await c.r.transaction(async t=>void await (0,h.f)({runId:e,type:"run.snapshots",payload:{route:M,opened:u,shots:o,message:l,change:A,newProject:d}},t))}finally{X.delete(e)}}})(),E(e)}function T(e,t){try{ee(e,["worktree","remove","--force",t])}catch{(0,a.rmSync)(t,{recursive:!0,force:!0});try{ee(e,["worktree","prune"])}catch{}}}class et extends Error{}e.s(["P",0,F,"J",0,et,"e",0,B,"c",0,j,"_",0,_,"g",0,P,"S",0,T,"V",0,E,"j",0,A]),r()}catch(e){r(e)}},!1),32374,e=>{"use strict";var t=e.i(74533),r=e.i(2157),n=e.i(50227),i=e.i(16806),a=e.i(40855);let s=/Tests\s+((?:\d+\s+(?:passed|failed|skipped|todo)\s*\|?\s*)+)\((\d+)\)/g,o=/Tests:\s+([^\n]*?)(\d+)\s+total/g,l=(e,t)=>Number(e.match(RegExp(`(\\d+)\\s+${t}`))?.[1]??0),c=/\x1b\[[0-9;?]*[ -\/]*[@-~]/g;function u(e){return e.replace(c,"")}let f=[/(^|\/)package\.json$/,/(^|\/)(__tests__|tests?|spec|e2e)\//,/\.(test|spec)\.[cm]?[jt]sx?$/,/(^|\/)(vitest|jest|playwright|mocha|karma|cypress)\.config\.[cm]?[jt]s$/,/(^|\/)\.mocharc(\.[a-z]+)?$/,/(^|\/)(test_[^/]*|[^/]*_test)\.py$/,/(^|\/)(pytest\.ini|conftest\.py|tox\.ini)$/,/_test\.go$/,/(^|\/)Makefile$/];function d(e){return f.some(t=>t.test(e))}let h=/no test specified/;e.s(["L",0,function(e,r){if(!r)return null;try{let n=r=>(0,t.execFileSync)("git",r,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","pipe"]}),i=n(["diff","--name-only",r]).split("\n"),a=n(["ls-files","--others","--exclude-standard"]).split("\n");return[...new Set([...i,...a].map(e=>e.trim()).filter(Boolean))].filter(d).sort()}catch{return null}},"n",0,function(e){let t=(0,n.join)(e,"package.json");if(!(0,r.existsSync)(t))return null;try{let i=JSON.parse((0,r.readFileSync)(t,"utf8")),a=i.scripts?.test;if("string"!=typeof a||""===a.trim()||h.test(a))return null;let s=t=>(0,r.existsSync)((0,n.join)(e,t));if(s("pnpm-lock.yaml"))return"pnpm test";if(s("yarn.lock"))return"yarn test";if(s("bun.lockb")||s("bun.lock"))return"bun run test";return"npm test"}catch{return null}},"P",0,function(e,r,n,c={},f){let d=Date.now();return new Promise(h=>{let p="",w=(0,t.spawn)("sh",["-c",e],{cwd:r,detached:!0,env:(0,i.f)({CI:"1",FORCE_COLOR:"0",NO_COLOR:"1",...c})}),m=e=>{p=(p+e.toString()).slice(-16e3)};w.stdout.on("data",m),w.stderr.on("data",m);let y=!1,g=()=>{y=!0;try{w.pid&&process.kill(-w.pid,"SIGKILL")}catch{}};n.aborted?g():n.addEventListener("abort",g,{once:!0});let b=(t,r,i)=>{n.removeEventListener("abort",g);let c=y?null:function(e){let t=u(e),r={passed:0,failed:0,total:0},n=!1;for(let e of t.matchAll(s))r.passed+=l(e[1],"passed"),r.failed+=l(e[1],"failed"),r.total+=Number(e[2]),n=!0;for(let e of t.matchAll(o))r.passed+=l(e[1],"passed"),r.failed+=l(e[1],"failed"),r.total+=Number(e[2]),n=!0;let i=e=>[...t.matchAll(RegExp(`(?:^|\\s)(?:#|ℹ)\\s+${e}\\s+(\\d+)\\s*$`,"gm"))].map(e=>Number(e[1])),[a,c,f]=[i("tests"),i("pass"),i("fail")];if(a.length>0&&a.length===c.length&&a.length===f.length){let e=e=>e.reduce((e,t)=>e+t,0);r.passed+=e(c),r.failed+=e(f),r.total+=e(a),n=!0}return n?r:null}(p);f?.(u(p)),h({command:e,exitCode:y?null:t,signal:y?null:r,started:i,durationMs:Date.now()-d,counts:c,outputTail:(0,a.h)(u(p)).slice(-4e3),changedTestFiles:null})};w.on("error",()=>b(null,null,!1)),w.on("close",(e,t)=>b(e,t,!0))})},"X",0,u])},26955,e=>{"use strict";var t=e.i(74533),r=e.i(66680),n=e.i(2157),i=e.i(60526),a=e.i(50227),s=e.i(87345),o=e.i(91138);let l=/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/;function c(e,t){if("string"!=typeof e||!l.test(e))throw Error(`Not a git object id: ${t}`)}function u(e,t){if(t.store)return(0,a.resolve)(t.store);let i=(0,r.createHash)("sha256").update((0,n.realpathSync)(e)).digest("hex").slice(0,16);return(0,a.join)(o.f,"snapshots",i)}function f(e,r,i){let s={...process.env};for(let e of["GIT_DIR","GIT_WORK_TREE","GIT_INDEX_FILE","GIT_COMMON_DIR","GIT_OBJECT_DIRECTORY","GIT_ALTERNATE_OBJECT_DIRECTORIES","GIT_NAMESPACE","GIT_PREFIX"])delete s[e];let o=(0,t.execFileSync)("git",["rev-parse","--git-path","objects"],{cwd:e,env:s,encoding:"utf8",stdio:["ignore","pipe","pipe"]}).trim(),l=(0,a.join)(u(e,r),"objects");return(0,n.mkdirSync)(l,{recursive:!0}),{...s,GIT_OBJECT_DIRECTORY:l,GIT_ALTERNATE_OBJECT_DIRECTORIES:(0,a.isAbsolute)(o)?o:(0,a.resolve)(e,o),...i?{GIT_INDEX_FILE:i}:{}}}function d(e,r,n,i={}){return(0,t.execFileSync)("git",["--no-optional-locks","-c","core.hooksPath=/dev/null","-c","core.fsmonitor=false",...n],{cwd:e,env:f(e,r,i.index),encoding:"utf8",input:i.input,stdio:["pipe","pipe","pipe"],maxBuffer:0x10000000,timeout:12e4})}function h(e,r,n){return(0,t.execFileSync)("git",["--no-optional-locks","-c","core.hooksPath=/dev/null",...n],{cwd:e,env:f(e,r),stdio:["ignore","pipe","pipe"],maxBuffer:0x10000000,timeout:12e4})}function p(e,t={}){let r=d(e,t,["rev-parse","--show-toplevel"]).trim();if((0,n.realpathSync)(r)!==(0,n.realpathSync)(e))throw Error("The folder is not a working copy of its own");let s=(0,n.mkdtempSync)((0,a.join)((0,i.tmpdir)(),"factory-index-"));try{var o=(0,a.join)(s,"index");let r=!0;try{d(e,t,["rev-parse","--verify","-q","HEAD^{commit}"])}catch{r=!1}return r&&d(e,t,["read-tree","HEAD"],{index:o}),d(e,t,["add","-A","--","."],{index:o}),d(e,t,["write-tree"],{index:o}).trim()}finally{(0,n.rmSync)(s,{recursive:!0,force:!0})}}let w=e=>e?"100755":"100644",m=new Set(["node_modules",".next","dist","build","out","coverage",".turbo",".cache",".vercel",".git"]);function y(e,t={}){let r=p(e,t),{files:i,skipped:o}=function(e,t){let r=d(e,t,["ls-files","-o","-i","--exclude-standard","-z"]).split("\0").filter(Boolean).filter(e=>!e.split("/").some(e=>m.has(e))&&s.Q.test(e)),i=[],o=0;for(let s of r)try{let r=(0,n.lstatSync)((0,a.join)(e,s));if(i.length>=50||!r.isFile()||r.size>1048576){o++;continue}i.push({path:s,mode:w((73&r.mode)!=0),blob:d(e,t,["hash-object","-w","--",s]).trim()})}catch{o++}return{files:i.sort((e,t)=>e.path<t.path?-1:1),skipped:o}}(e,t);return{tree:r,ignored:i,skipped:o}}let g=e=>e?`${e.mode} ${e.sha}`:"-";function b(e,t,r,n){let i=d(e,t,["diff-tree","-r","-z","--name-status","--no-renames",r,n]).split("\0"),a=[];for(let e=0;e+1<i.length;e+=2)a.push({status:i[e],path:i[e+1]});return a}function v(e,t,r,n={}){return c(t,"from"),c(r,"tree"),b(e,n,t,r).map(e=>e.path).sort()}let S=e=>"string"==typeof e?{tree:e,ignored:[],skipped:0}:e;function k(e,t,r,n={}){let i=S(t),a=S(r);c(i.tree,"before"),c(a.tree,"after");let s=new Set(b(e,n,i.tree,a.tree).map(e=>e.path)),o=e=>new Map(e.ignored.map(e=>[e.path,g({mode:e.mode,sha:e.blob})])),l=o(i),u=o(a);for(let e of new Set([...l.keys(),...u.keys()]))l.get(e)!==u.get(e)&&s.add(e);return[...s].sort()}function x(e,t,r,n){let i=new Map;for(let a=0;a<n.length;a+=100){let s=n.slice(a,a+100);for(let n of d(e,t,["ls-tree","-r","-z",r,"--",...s]).split("\0").filter(Boolean)){let e=n.indexOf(" "),[t,r,a]=n.slice(0,e).split(" ");"blob"===r&&s.includes(n.slice(e+1))&&i.set(n.slice(e+1),{mode:t,sha:a})}}return i}function I(e,t,r){let i,s=(0,a.join)(e,r);try{i=(0,n.lstatSync)(s)}catch{return null}return i.isSymbolicLink()?{mode:"120000",sha:d(e,t,["hash-object","--stdin"],{input:(0,n.readlinkSync)(s)}).trim()}:i.isDirectory()?0===(0,n.readdirSync)(s).length?null:{mode:"040000",sha:"folder"}:{mode:w((73&i.mode)!=0),sha:d(e,t,["hash-object","--",r]).trim()}}let $=e=>""!==e&&!e.startsWith("/")&&e.split("/").every(e=>""!==e&&".."!==e&&".git"!==e),j=e=>/(^|\/)\.(gitignore|gitattributes)$/.test(e);function P(e,t,r,i={}){let s=S(t),o=S(r);c(s.tree,"before"),c(o.tree,"after");let l=k(e,s,o,i),u=new Set([...s.ignored,...o.ignored].map(e=>e.path)),f=x(e,i,s.tree,l),p=x(e,i,o.tree,l),w=(e,t,r)=>{let n=t.get(r);if(n)return n;let i=e.ignored.find(e=>e.path===r);return i?{mode:i.mode,sha:i.blob}:null},m=[],y=[],b=[],v=!1,E=t=>{try{if(!$(t)||function(e,t){let r=t.split("/"),i=e;for(let e of r.slice(0,-1)){i=(0,a.join)(i,e);try{if((0,n.lstatSync)(i).isSymbolicLink())return!0}catch{break}}return!1}(e,t))throw Error("Not a path to touch");let r=w(s,f,t),l=w(o,p,t);if(g(r)===g(l))return;let c=I(e,i,t);if(g(c)===g(r))return void m.push(t);if(g(c)!==g(l))return void y.push(t);if(null===r){if(!u.has(t)){if(v)return void y.push(t);if(function(e,t,r){try{return d(e,t,["check-ignore","-q","--",r]),!0}catch{return!1}}(e,i,t))return}(0,n.rmSync)((0,a.join)(e,t),{force:!0})}else{let s=(0,a.join)(e,t),o="120000"===r.mode?h(e,i,["cat-file","blob",r.sha]):h(e,i,["cat-file","--filters",`--path=${t}`,r.sha]),l=t.split("/"),c=e;for(let e of l.slice(0,-1))if(c=(0,a.join)(c,e),(0,n.existsSync)(c)){if(!(0,n.lstatSync)(c).isDirectory())throw Error("A file is in the way")}else(0,n.mkdirSync)(c);((0,n.existsSync)(s)||function(e){try{return(0,n.lstatSync)(e).isSymbolicLink()}catch{return!1}}(s))&&((0,n.lstatSync)(s).isDirectory()?(0,n.rmdirSync)(s):(0,n.rmSync)(s,{force:!0})),"120000"===r.mode?(0,n.symlinkSync)(o.toString(),s):((0,n.writeFileSync)(s,o),(0,n.chmodSync)(s,"100755"===r.mode?493:420))}m.push(t)}catch{b.push(t)}},_=e=>null===w(s,f,e),A=[...l.filter(j),...l.filter(e=>!j(e)&&_(e)),...l.filter(e=>!j(e)&&!_(e))];for(let e of A.filter(j))E(e);for(let e of(v=[...y,...b].some(j),A.filter(e=>!j(e))))E(e);return{reverted:m.sort(),kept:y.sort(),failed:b.sort()}}let E=(e,t)=>(0,a.join)(u(e,t),"attempts");e.s(["n",0,2,"H",0,v,"d",0,k,"e",0,function(e,t,r={}){let n=d(e,r,["status","--porcelain=v1","-z","-uall"]).split("\0").filter(Boolean),i=new Set(t.ignored.map(e=>e.path));for(let e=0;e<n.length;e++){let t=n[e].slice(0,2);i.add(n[e].slice(3).replace(/\/$/,"")),("R"===t[0]||"C"===t[0])&&e++}let a=[...i].filter($),s=x(e,r,t.tree,a);return a.filter(n=>g(s.get(n)??(t.ignored.find(e=>e.path===n)?{mode:t.ignored.find(e=>e.path===n).mode,sha:t.ignored.find(e=>e.path===n).blob}:null))!==g(I(e,r,n))).sort()},"G",0,function(e,t,r={}){c(t,"tree");let n=p(e,r),i=["--no-renames","--no-color","--no-ext-diff","--no-textconv"],a=v(e,t,n,r),s=d(e,r,["-c","core.quotepath=off","diff-tree","-r","-p",...i,t,n]),o=new Map;for(let a of d(e,r,["diff-tree","-r","-z","--numstat",...i,t,n]).split("\0").filter(Boolean)){let[e,t,...r]=a.split(" "),n=e=>void 0===e||"-"===e?1:Number(e);o.set(r.join(" "),n(e)+n(t))}return{paths:a,diff:s,files:a.map(e=>({path:e,lines:Math.max(1,o.get(e)??1)}))}},"W",0,function(e,t,r={}){let i=E(e,r);if((0,n.existsSync)(i))for(let e of(0,n.readdirSync)(i))e.startsWith(`${t}-`)&&(0,n.rmSync)((0,a.join)(i,e),{force:!0})},"z",0,function(e,t,r={}){c(t,"tree");let n=P(e,t,p(e,r),r);if(n.failed.length>0)throw Error(`Could not put back: ${n.failed.join(", ")}`)},"$",0,p,"u",0,function(e,t,r={}){if(!/^[A-Za-z0-9_-]+$/.test(t))throw Error("Not a name to claim");let i=E(e,r);(0,n.mkdirSync)(i,{recursive:!0});let s=(0,a.join)(i,t),o=()=>{try{let e=JSON.parse((0,n.readFileSync)(s,"utf8")),t="string"==typeof e.tree&&l.test(e.tree)&&Array.isArray(e.ignored)&&e.ignored.every(e=>e&&"string"==typeof e.path&&"string"==typeof e.mode&&"string"==typeof e.blob&&l.test(e.blob));return{again:!0,start:t?{tree:e.tree,ignored:e.ignored,skipped:"number"==typeof e.skipped?e.skipped:0}:null}}catch{return{again:!0,start:null}}};if((0,n.existsSync)(s))return o();let c=y(e,r);try{(0,n.writeFileSync)(s,JSON.stringify(c),{flag:"wx"})}catch{return o()}return{again:!1,start:c}},"o",0,y,"p",0,P])},92835,e=>e.a(async(t,r)=>{try{var n=e.i(74533),i=e.i(2157),a=e.i(60526),s=e.i(50227),o=e.i(75225),l=e.i(24924),c=e.i(92335),u=e.i(96662),f=e.i(120),d=e.i(20195),h=e.i(64950),p=e.i(30188),w=e.i(69608),m=e.i(82283),y=e.i(37857),g=t([l,u,f,d,h,w]);[l,u,f,d,h,w]=g.then?(await g)():g;let j=async(e,t)=>{let r=await (0,y.f)();try{let n=await (await r.newContext({viewport:{width:1440,height:900},deviceScaleFactor:1})).newPage();await n.goto(e,{waitUntil:"load",timeout:12e4}),await n.waitForLoadState("networkidle",{timeout:15e3}).catch(()=>void 0),await n.waitForTimeout(1500),await n.screenshot({path:t,fullPage:!0})}finally{await r.close()}},P=/^version-(\d{1,2})\.(png|patch)$/,E=(e,t,r)=>(0,s.join)(r,e,`version-${t}.png`),_=(e,t,r)=>(0,s.join)(r,e,`version-${t}.patch`),A=(e,t,r)=>(0,n.execFileSync)("git",["-c","core.hooksPath=/dev/null",...t],{cwd:e,env:r??process.env,stdio:["ignore","pipe","pipe"],maxBuffer:0x20000000});async function b(e,t,r=j,n=w.P){try{let a=(0,d.h)(e);if("ready"!==a.status||!a.url)return!1;return(0,i.mkdirSync)((0,s.join)(n,e),{recursive:!0}),await r(a.url,E(e,t,n)),!0}catch{return!1}}function v(e,t=w.P){let r=(0,s.join)(t,e);return(0,i.existsSync)(r)?[...new Set((0,i.readdirSync)(r).flatMap(e=>{let t=P.exec(e);return t?[Number(t[1])]:[]}))].sort((e,t)=>e-t):[]}async function S(e,t=w.P){let r=v(e,t);if(0===r.length)return[];let n=(await l.r.select().from(c.B).where((0,o.u)(c.B.id,e)))[0];if(!n)return[];let a=[n.request,...(await (0,u.P)([e]))(e)];return r.map(r=>({n:r,text:a[r-1]??null,site:(0,i.existsSync)(_(e,r,t)),picture:(0,i.existsSync)(E(e,r,t))}))}let B=globalThis.__factoryVersions??=new Map,T=e=>`${e}:version`,F=(e,t)=>(0,s.join)(t,e,"version-tree");class R extends Error{}function k(e){return(0,d.i)(T(e)),{...(0,d.h)(T(e)),n:B.get(e)??null}}async function x(e,t,r){let n=(0,d.h)(T(e)).status;if(B.get(e)===t&&("starting"===n||"installing"===n||"ready"===n))return k(e);let a=(await l.r.select().from(c.B).where((0,o.u)(c.B.id,e)))[0],s=a?(await (0,h.I)(a.projectId))?.repoPath??null:null,u=_(e,t,r),p=(0,i.existsSync)(`${u}.base`)?(0,i.readFileSync)(`${u}.base`,"utf8").trim():"";if(!a||!s||!(0,i.existsSync)(u)||!/^[0-9a-f]{7,64}$/.test(p))throw new R(m.f.direct.versionNotKept);await $(e,r,!0);let w=F(e,r);try{A(s,["worktree","add","-q","--detach",w,p]),(0,i.statSync)(u).size>0&&A(w,["apply","--binary","--whitespace=nowarn",u]),await (0,f.S)(a.projectId,w),B.set(e,t),await (0,d.O)(T(e),w,s)}catch{throw(0,d.D)(T(e)),B.delete(e),I(s,w),new R(m.f.direct.versionNotBuilt)}return k(e)}function I(e,t){try{e?(0,w.S)(e,t):(0,i.rmSync)(t,{recursive:!0,force:!0})}catch{}}async function $(e,t,r){let n="stopped"!==(0,d.h)(T(e)).status;(0,d.D)(T(e)),B.delete(e);let a=F(e,t);if(!(0,i.existsSync)(a))return;let s=(await l.r.select().from(c.B).where((0,o.u)(c.B.id,e)))[0],u=s?(await (0,h.I)(s.projectId))?.repoPath??null:null;n&&await new Promise(e=>setTimeout(e,r?1500:4e3)),I(u,a)}e.s(["R",0,R,"q",0,b,"x",0,function(e,t,r=w.P){for(let n of v(e,r))n<=t||((0,i.rmSync)(E(e,n,r),{force:!0}),(0,i.rmSync)(_(e,n,r),{force:!0}),(0,i.rmSync)(`${_(e,n,r)}.base`,{force:!0}))},"H",0,S,"A",0,function(e,t,r=w.P){let n=E(e,t,r);return Number.isInteger(t)&&t>=1&&t<=99&&(0,i.existsSync)(n)?new Uint8Array((0,i.readFileSync)(n)):null},"Y",0,function(e,t,r,n,o=w.P){let l=(0,i.mkdtempSync)((0,s.join)((0,a.tmpdir)(),"factory-version-"));try{let a={...process.env,GIT_INDEX_FILE:(0,s.join)(l,"index")};A(e,["read-tree",t],a),A(e,["add","-A","--","."],a);let c=A(e,["diff","--cached","--binary","--full-index",t],a);return(0,i.mkdirSync)((0,s.join)(o,r),{recursive:!0}),(0,i.writeFileSync)(_(r,n,o),c),(0,i.writeFileSync)(`${_(r,n,o)}.base`,t),!0}catch{return!1}finally{(0,i.rmSync)(l,{recursive:!0,force:!0})}},"C",0,(e,t,r=w.P)=>(0,p.f)(T(e),()=>x(e,t,r)),"i",0,(e,t=w.P)=>(0,p.f)(T(e),()=>$(e,t,!1)),"S",0,k]),r()}catch(e){r(e)}},!1),18536,e=>{"use strict";var t=e.i(74533),r=e.i(2157),n=e.i(50227),i=e.i(91138);let a=(0,n.join)(i.f,"worktrees"),s=(e,r)=>(0,t.execFileSync)("git",r,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","pipe"]}).trim();function o(e,t){let r=(t??"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40).replace(/-+$/g,"");return`ai/${r||"change"}-${e.slice(-6).toLowerCase()}`}e.s(["U",0,a,"E",0,o,"r",0,function(e,t,i=a,l,c){let u=o(t,c),f=(0,n.join)(i,t);if((0,r.existsSync)(f))return{path:f,branch:s(f,["rev-parse","--abbrev-ref","HEAD"]),baseCommit:s(f,["merge-base","HEAD",u])};let d=s(e,["rev-parse","--verify",l?`${l}^{commit}`:"HEAD"]);return(0,r.mkdirSync)(i,{recursive:!0}),s(e,["worktree","add","-q","-b",u,f,d]),{path:f,branch:u,baseCommit:d}}])}];
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=_155fw3g6f3-4h._.js.map
|