@codeyam/codeyam-cli 0.1.20 → 0.1.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/analyzer-template/.build-info.json +7 -7
  2. package/analyzer-template/log.txt +3 -3
  3. package/analyzer-template/package.json +1 -1
  4. package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +5 -1
  5. package/analyzer-template/packages/analyze/src/lib/files/analyze/findOrCreateEntity.ts +1 -0
  6. package/analyzer-template/packages/analyze/src/lib/files/analyzeChange.ts +4 -0
  7. package/analyzer-template/packages/analyze/src/lib/files/analyzeInitial.ts +4 -0
  8. package/analyzer-template/packages/aws/package.json +1 -1
  9. package/analyzer-template/packages/database/src/lib/loadEntity.ts +11 -4
  10. package/analyzer-template/packages/github/dist/database/src/lib/loadEntity.d.ts +4 -1
  11. package/analyzer-template/packages/github/dist/database/src/lib/loadEntity.d.ts.map +1 -1
  12. package/analyzer-template/packages/github/dist/database/src/lib/loadEntity.js +4 -4
  13. package/analyzer-template/packages/github/dist/database/src/lib/loadEntity.js.map +1 -1
  14. package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.d.ts +3 -1
  15. package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.d.ts.map +1 -1
  16. package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.js +22 -1
  17. package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.js.map +1 -1
  18. package/analyzer-template/packages/utils/src/lib/fs/rsyncCopy.ts +27 -0
  19. package/codeyam-cli/src/commands/editor.js +185 -59
  20. package/codeyam-cli/src/commands/editor.js.map +1 -1
  21. package/codeyam-cli/src/utils/__tests__/editorAudit.test.js +630 -23
  22. package/codeyam-cli/src/utils/__tests__/editorAudit.test.js.map +1 -1
  23. package/codeyam-cli/src/utils/__tests__/registerScenarioResult.test.js +127 -0
  24. package/codeyam-cli/src/utils/__tests__/registerScenarioResult.test.js.map +1 -0
  25. package/codeyam-cli/src/utils/analyzer.js +8 -0
  26. package/codeyam-cli/src/utils/analyzer.js.map +1 -1
  27. package/codeyam-cli/src/utils/editorAudit.js +113 -12
  28. package/codeyam-cli/src/utils/editorAudit.js.map +1 -1
  29. package/codeyam-cli/src/utils/registerScenarioResult.js +52 -0
  30. package/codeyam-cli/src/utils/registerScenarioResult.js.map +1 -0
  31. package/codeyam-cli/src/webserver/app/lib/clientErrors.js +3 -0
  32. package/codeyam-cli/src/webserver/app/lib/clientErrors.js.map +1 -1
  33. package/codeyam-cli/src/webserver/build/client/assets/api.editor-save-scenario-data-l0sNRNKZ.js +1 -0
  34. package/codeyam-cli/src/webserver/build/client/assets/api.editor-schema-l0sNRNKZ.js +1 -0
  35. package/codeyam-cli/src/webserver/build/client/assets/{cy-logo-cli-CCKUIm0S.svg → cy-logo-cli-CJzc4vOH.svg} +2 -2
  36. package/codeyam-cli/src/webserver/build/client/assets/cy-logo-cli-DODLxLcw.js +1 -0
  37. package/codeyam-cli/src/webserver/build/client/assets/editor.entity.(_sha)-Dx-h1rJK.js +130 -0
  38. package/codeyam-cli/src/webserver/build/client/assets/editorPreview-NTuLi4Xg.js +41 -0
  39. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha.scenarios._scenarioId.dev-KTQuL0aj.js → entity._sha.scenarios._scenarioId.dev-BA5L8bU-.js} +1 -1
  40. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha.scenarios._scenarioId.fullscreen-C6eeL24i.js → entity._sha.scenarios._scenarioId.fullscreen-D4dmRgvO.js} +1 -1
  41. package/codeyam-cli/src/webserver/build/client/assets/globals-BrPXT1iR.css +1 -0
  42. package/codeyam-cli/src/webserver/build/client/assets/manifest-5025e428.js +1 -0
  43. package/codeyam-cli/src/webserver/build/client/assets/{root-BxUQigda.js → root-BCx1S8Z3.js} +26 -13
  44. package/codeyam-cli/src/webserver/build/server/assets/{analysisRunner-B_PsTAb1.js → analysisRunner-C1kjC9UJ.js} +1 -1
  45. package/codeyam-cli/src/webserver/build/server/assets/{index-CjLhfz6Z.js → index-C91yWWCI.js} +1 -1
  46. package/codeyam-cli/src/webserver/build/server/assets/{init-BEqlbI84.js → init-Dkas-RUS.js} +1 -1
  47. package/codeyam-cli/src/webserver/build/server/assets/server-build-pulXLTrG.js +640 -0
  48. package/codeyam-cli/src/webserver/build/server/index.js +1 -1
  49. package/codeyam-cli/src/webserver/build-info.json +5 -5
  50. package/codeyam-cli/src/webserver/terminalServer.js +10 -3
  51. package/codeyam-cli/src/webserver/terminalServer.js.map +1 -1
  52. package/package.json +1 -1
  53. package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +4 -1
  54. package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js.map +1 -1
  55. package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js +1 -0
  56. package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js.map +1 -1
  57. package/packages/analyze/src/lib/files/analyzeChange.js +1 -0
  58. package/packages/analyze/src/lib/files/analyzeChange.js.map +1 -1
  59. package/packages/analyze/src/lib/files/analyzeInitial.js +1 -0
  60. package/packages/analyze/src/lib/files/analyzeInitial.js.map +1 -1
  61. package/packages/database/src/lib/loadEntity.js +4 -4
  62. package/packages/database/src/lib/loadEntity.js.map +1 -1
  63. package/packages/utils/src/lib/fs/rsyncCopy.js +22 -1
  64. package/packages/utils/src/lib/fs/rsyncCopy.js.map +1 -1
  65. package/codeyam-cli/src/webserver/build/client/assets/cy-logo-cli-DcX-ZS3p.js +0 -1
  66. package/codeyam-cli/src/webserver/build/client/assets/editor.entity.(_sha)-DII1pg_z.js +0 -58
  67. package/codeyam-cli/src/webserver/build/client/assets/editorPreview-oepecPae.js +0 -41
  68. package/codeyam-cli/src/webserver/build/client/assets/globals-Yn9W3zp3.css +0 -1
  69. package/codeyam-cli/src/webserver/build/client/assets/manifest-cdf2c0a7.js +0 -1
  70. package/codeyam-cli/src/webserver/build/server/assets/server-build-YI63xTu4.js +0 -553
@@ -1,4 +1,4 @@
1
- import{r as o,c as ie,a as oe,d as re,L as J,w as le,D as ce,M as de,G as me,S as he,H as pe,I as xe,k as G,u as fe,f as ue,O as ye}from"./chunk-JZWAC4HX-BAdwhyCx.js";import{j as e}from"./jsx-runtime-D_zvdyIk.js";import{_ as ge}from"./preload-helper-ckwbz45p.js";import{c as ve}from"./cy-logo-cli-DcX-ZS3p.js";import{B as je,R as ke,S as be}from"./ReportIssueModal-C2PLkej3.js";import{a as we,R as Ce}from"./useReportContext-Cy5Qg_UR.js";import{L as Z}from"./loader-circle-De-7qQ2u.js";import{c as L}from"./createLucideIcon-4ImjHTVC.js";import{B as Ne}from"./book-open-CL-lMgHh.js";import{T as Se,u as Ee}from"./useToast-5HR2j9ZE.js";import{u as Le}from"./useLastLogLine-BNd5hYuW.js";import{L as Ae}from"./LogViewer-CM5zg40N.js";import{E as ze}from"./EntityTypeIcon-CD7lGABo.js";import{T as Te}from"./TruncatedFilePath-CK7-NaPZ.js";import{C as Me}from"./chevron-down-GmAjGS9-.js";import{C as Fe}from"./circle-check-DFcQkN5j.js";import{C as _e}from"./CopyButton-CLe80MMu.js";import"./triangle-alert-DqJ0j69l.js";import"./copy-C6iF61Xs.js";const Be=2e3,De=5e3;function Ie(t){return t.startsWith("/editor")?De:Be}function We(t){const{now:s,lastRevalidation:a,throttleMs:l}=t;if(a===0)return"immediate";const r=s-a;return r>=l?"immediate":{action:"deferred",delayMs:l-r}}function Pe({id:t,selected:s,onClick:a,icon:l,name:r}){const[d,i]=o.useState(!1);o.useEffect(()=>{i(!0)},[]);const N=o.useCallback(()=>{a==null||a(t)},[a,t]);return e.jsxs("button",{className:`
1
+ import{r as a,c as ie,a as ae,d as re,L as Y,w as le,D as ce,M as de,G as me,S as he,H as pe,I as xe,k as X,u as fe,f as ue,O as ye}from"./chunk-JZWAC4HX-BAdwhyCx.js";import{j as e}from"./jsx-runtime-D_zvdyIk.js";import{_ as ge}from"./preload-helper-ckwbz45p.js";import{c as ve}from"./cy-logo-cli-DODLxLcw.js";import{B as je,R as be,S as ke}from"./ReportIssueModal-C2PLkej3.js";import{a as we,R as Ce}from"./useReportContext-Cy5Qg_UR.js";import{L as Z}from"./loader-circle-De-7qQ2u.js";import{c as E}from"./createLucideIcon-4ImjHTVC.js";import{B as Ne}from"./book-open-CL-lMgHh.js";import{T as Se,u as Le}from"./useToast-5HR2j9ZE.js";import{u as Ee}from"./useLastLogLine-BNd5hYuW.js";import{L as Ae}from"./LogViewer-CM5zg40N.js";import{E as Te}from"./EntityTypeIcon-CD7lGABo.js";import{T as ze}from"./TruncatedFilePath-CK7-NaPZ.js";import{C as Me}from"./chevron-down-GmAjGS9-.js";import{C as Be}from"./circle-check-DFcQkN5j.js";import{C as Ie}from"./CopyButton-CLe80MMu.js";import"./triangle-alert-DqJ0j69l.js";import"./copy-C6iF61Xs.js";const _e=2e3,Fe=5e3;function De(t){return t.startsWith("/editor")?Fe:_e}function We(t){const{now:s,lastRevalidation:o,throttleMs:l}=t;if(o===0)return"immediate";const r=s-o;return r>=l?"immediate":{action:"deferred",delayMs:l-r}}function Pe({id:t,selected:s,onClick:o,icon:l,name:r}){const[d,i]=a.useState(!1);a.useEffect(()=>{i(!0)},[]);const N=a.useCallback(()=>{o==null||o(t)},[o,t]);return e.jsxs("button",{className:`
2
2
  w-full px-1.5 py-2 cursor-pointer focus:outline-none
3
3
  flex flex-col items-center justify-center gap-1 transition-colors
4
4
  ${s?"text-[#CBF3FA]":"text-[#568B94] hover:text-[#CBF3FA]"}
@@ -7,53 +7,53 @@ import{r as o,c as ie,a as oe,d as re,L as J,w as le,D as ce,M as de,G as me,S a
7
7
  *
8
8
  * This source code is licensed under the ISC license.
9
9
  * See the LICENSE file in the root directory of this source tree.
10
- */const Re=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],Q=L("activity",Re);/**
10
+ */const Re=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],G=E("activity",Re);/**
11
11
  * @license lucide-react v0.577.0 - ISC
12
12
  *
13
13
  * This source code is licensed under the ISC license.
14
14
  * See the LICENSE file in the root directory of this source tree.
15
- */const $e=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M7 10h10",key:"1101jm"}],["path",{d:"M7 14h10",key:"1mhdw3"}]],He=L("circle-equal",$e);/**
15
+ */const $e=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M7 10h10",key:"1101jm"}],["path",{d:"M7 14h10",key:"1mhdw3"}]],He=E("circle-equal",$e);/**
16
16
  * @license lucide-react v0.577.0 - ISC
17
17
  *
18
18
  * This source code is licensed under the ISC license.
19
19
  * See the LICENSE file in the root directory of this source tree.
20
- */const Ve=[["path",{d:"M15.536 11.293a1 1 0 0 0 0 1.414l2.376 2.377a1 1 0 0 0 1.414 0l2.377-2.377a1 1 0 0 0 0-1.414l-2.377-2.377a1 1 0 0 0-1.414 0z",key:"1uwlt4"}],["path",{d:"M2.297 11.293a1 1 0 0 0 0 1.414l2.377 2.377a1 1 0 0 0 1.414 0l2.377-2.377a1 1 0 0 0 0-1.414L6.088 8.916a1 1 0 0 0-1.414 0z",key:"10291m"}],["path",{d:"M8.916 17.912a1 1 0 0 0 0 1.415l2.377 2.376a1 1 0 0 0 1.414 0l2.377-2.376a1 1 0 0 0 0-1.415l-2.377-2.376a1 1 0 0 0-1.414 0z",key:"1tqoq1"}],["path",{d:"M8.916 4.674a1 1 0 0 0 0 1.414l2.377 2.376a1 1 0 0 0 1.414 0l2.377-2.376a1 1 0 0 0 0-1.414l-2.377-2.377a1 1 0 0 0-1.414 0z",key:"1x6lto"}]],Oe=L("component",Ve);/**
20
+ */const Ve=[["path",{d:"M15.536 11.293a1 1 0 0 0 0 1.414l2.376 2.377a1 1 0 0 0 1.414 0l2.377-2.377a1 1 0 0 0 0-1.414l-2.377-2.377a1 1 0 0 0-1.414 0z",key:"1uwlt4"}],["path",{d:"M2.297 11.293a1 1 0 0 0 0 1.414l2.377 2.377a1 1 0 0 0 1.414 0l2.377-2.377a1 1 0 0 0 0-1.414L6.088 8.916a1 1 0 0 0-1.414 0z",key:"10291m"}],["path",{d:"M8.916 17.912a1 1 0 0 0 0 1.415l2.377 2.376a1 1 0 0 0 1.414 0l2.377-2.376a1 1 0 0 0 0-1.415l-2.377-2.376a1 1 0 0 0-1.414 0z",key:"1tqoq1"}],["path",{d:"M8.916 4.674a1 1 0 0 0 0 1.414l2.377 2.376a1 1 0 0 0 1.414 0l2.377-2.376a1 1 0 0 0 0-1.414l-2.377-2.377a1 1 0 0 0-1.414 0z",key:"1x6lto"}]],Oe=E("component",Ve);/**
21
21
  * @license lucide-react v0.577.0 - ISC
22
22
  *
23
23
  * This source code is licensed under the ISC license.
24
24
  * See the LICENSE file in the root directory of this source tree.
25
- */const qe=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]],Ue=L("file",qe);/**
25
+ */const qe=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]],Ue=E("file",qe);/**
26
26
  * @license lucide-react v0.577.0 - ISC
27
27
  *
28
28
  * This source code is licensed under the ISC license.
29
29
  * See the LICENSE file in the root directory of this source tree.
30
- */const Ye=[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]],Je=L("flask-conical",Ye);/**
30
+ */const Je=[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]],Ye=E("flask-conical",Je);/**
31
31
  * @license lucide-react v0.577.0 - ISC
32
32
  *
33
33
  * This source code is licensed under the ISC license.
34
34
  * See the LICENSE file in the root directory of this source tree.
35
- */const Ge=[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]],se=L("git-commit-horizontal",Ge);/**
35
+ */const Xe=[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]],se=E("git-commit-horizontal",Xe);/**
36
36
  * @license lucide-react v0.577.0 - ISC
37
37
  *
38
38
  * This source code is licensed under the ISC license.
39
39
  * See the LICENSE file in the root directory of this source tree.
40
- */const Qe=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]],Xe=L("house",Qe);/**
40
+ */const Ge=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]],Qe=E("house",Ge);/**
41
41
  * @license lucide-react v0.577.0 - ISC
42
42
  *
43
43
  * This source code is licensed under the ISC license.
44
44
  * See the LICENSE file in the root directory of this source tree.
45
- */const Ke=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M9 21V9",key:"1oto5p"}]],Ze=L("panels-top-left",Ke);/**
45
+ */const Ke=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M9 21V9",key:"1oto5p"}]],Ze=E("panels-top-left",Ke);/**
46
46
  * @license lucide-react v0.577.0 - ISC
47
47
  *
48
48
  * This source code is licensed under the ISC license.
49
49
  * See the LICENSE file in the root directory of this source tree.
50
- */const et=[["path",{d:"M13 7 8.7 2.7a2.41 2.41 0 0 0-3.4 0L2.7 5.3a2.41 2.41 0 0 0 0 3.4L7 13",key:"orapub"}],["path",{d:"m8 6 2-2",key:"115y1s"}],["path",{d:"m18 16 2-2",key:"ee94s4"}],["path",{d:"m17 11 4.3 4.3c.94.94.94 2.46 0 3.4l-2.6 2.6c-.94.94-2.46.94-3.4 0L11 17",key:"cfq27r"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],tt=L("pencil-ruler",et);/**
50
+ */const et=[["path",{d:"M13 7 8.7 2.7a2.41 2.41 0 0 0-3.4 0L2.7 5.3a2.41 2.41 0 0 0 0 3.4L7 13",key:"orapub"}],["path",{d:"m8 6 2-2",key:"115y1s"}],["path",{d:"m18 16 2-2",key:"ee94s4"}],["path",{d:"m17 11 4.3 4.3c.94.94.94 2.46 0 3.4l-2.6 2.6c-.94.94-2.46.94-3.4 0L11 17",key:"cfq27r"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],tt=E("pencil-ruler",et);/**
51
51
  * @license lucide-react v0.577.0 - ISC
52
52
  *
53
53
  * This source code is licensed under the ISC license.
54
54
  * See the LICENSE file in the root directory of this source tree.
55
- */const st=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],nt=L("refresh-cw",st);function it({labs:t,isAdmin:s,editorMode:a}){var v;const l=ie(),r=oe(),[d,i]=o.useState(),[N,A]=o.useState(!1),[k,p]=o.useState(!1),[F,S]=o.useState(null),b=re();o.useEffect(()=>{b.state==="idle"&&!b.data&&b.load("/api/generate-report")},[b]);const $=((v=b.data)==null?void 0:v.defaultEmail)||"",m={width:"20px",height:"20px",strokeWidth:1.5},z=(t==null?void 0:t.simulations)??!1,_=[{id:"editor",icon:e.jsx(tt,{style:m}),link:"/editor",name:"Editor",hidden:!a,newTab:!0},{id:"dashboard",icon:e.jsx(Xe,{style:m}),link:"/",name:"Dashboard",hidden:!z||a},{id:"simulations",icon:e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:m,children:[e.jsx("path",{d:"M9 12.75V15.75",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M6 15.75H12",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M6.75 12.7498L11.325 8.17483C11.6067 7.89873 11.9858 7.7447 12.3803 7.7461C12.7747 7.74751 13.1528 7.90423 13.4325 8.18233L16.5 11.2498",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M6 8.25C6.82843 8.25 7.5 7.57843 7.5 6.75C7.5 5.92157 6.82843 5.25 6 5.25C5.17157 5.25 4.5 5.92157 4.5 6.75C4.5 7.57843 5.17157 8.25 6 8.25Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M15 2.25H3C2.17157 2.25 1.5 2.92157 1.5 3.75V11.25C1.5 12.0784 2.17157 12.75 3 12.75H15C15.8284 12.75 16.5 12.0784 16.5 11.25V3.75C16.5 2.92157 15.8284 2.25 15 2.25Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),link:"/simulations",name:"Simulations",hidden:!z||a},{id:"git",icon:e.jsx(se,{style:m}),link:"/git",name:"Git",hidden:!z||a},{id:"files",icon:e.jsx(Ue,{style:m}),link:"/files",name:"Files",hidden:!z||a},{id:"activity",icon:e.jsx(nt,{style:m}),link:"/activity",name:"Activity",hidden:!z||a},{id:"memory",icon:e.jsx(Ne,{style:m}),link:"/memory",name:"Memory"},{id:"labs",icon:e.jsx(Je,{style:m}),link:"/labs",name:"Labs"},{id:"settings",icon:e.jsx(be,{style:m}),link:"/settings",name:"Settings"},{id:"commits",icon:e.jsx(se,{style:m}),link:"/commits",name:"Commits",hidden:!0},{id:"pages",icon:e.jsx(Ze,{style:m}),link:"/pages",name:"Pages",hidden:!0},{id:"components",icon:e.jsx(Oe,{style:m}),link:"/components",name:"Components",hidden:!0}],B=o.useCallback(c=>{const u=_.find(h=>h.id===c);u!=null&&u.link&&(u.newTab?window.open(u.link,"_blank"):r(u.link)),i(h=>h===c?void 0:c)},[_,r]);o.useEffect(()=>{const c={editor:["editor"],dashboard:["/","/home"],git:["git"],commits:["commits"],simulations:["simulations"],activity:["activity"],memory:["memory","agent-transcripts"],files:["files"],labs:["labs"],settings:["settings"],pages:["pages"],components:["components"]};for(const[u,h]of Object.entries(c))if(h.some(y=>y==="/"?l.pathname==="/":l.pathname.includes(y))){i(u);return}i(void 0)},[l]);const D=async()=>{p(!0);try{const{default:c}=await ge(async()=>{const{default:y}=await import("./html2canvas-pro.esm-fmIEn3Bc.js");return{default:y}},[]),h=(await c(document.body)).toDataURL("image/jpeg",.8);S(h),A(!0)}catch(c){console.error("Screenshot capture failed:",c),A(!0)}finally{p(!1)}},w=()=>{A(!1),S(null)},g=we();return e.jsxs(e.Fragment,{children:[e.jsxs("div",{id:"sidebar",className:"sticky top-0 w-full h-screen bg-[#051C22] flex flex-col justify-between py-3",children:[e.jsxs("div",{className:"w-full flex flex-col items-center",children:[e.jsx("div",{className:"py-3 mt-2 mb-4",children:e.jsx(J,{to:"/",className:"flex items-center justify-center cursor-pointer",children:e.jsx("img",{src:ve,alt:"CodeYam",className:"h-6"})})}),_.filter(c=>!c.hidden).map(c=>e.jsx(Pe,{id:c.id,selected:c.id===d,onClick:B,icon:c.icon,name:c.name},`sidebar-button-${c.id}`))]}),s&&e.jsx("div",{className:"w-full flex flex-col items-center pb-2",children:e.jsxs("button",{onClick:()=>void D(),disabled:k,className:"w-full px-1.5 py-2 flex flex-col items-center justify-center gap-1 text-[#568B94] hover:text-[#CBF3FA] transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-wait",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg flex items-center justify-center",children:k?e.jsx(Z,{style:{width:"20px",height:"20px",strokeWidth:1.5},className:"animate-spin"}):e.jsx(je,{style:{width:"20px",height:"20px",strokeWidth:1.5}})}),e.jsx("span",{className:"text-[9px] font-normal text-center leading-tight whitespace-pre-line",children:k?"Capturing...":`Report
56
- Bug`})]})})]}),N&&e.jsx(ke,{isOpen:!0,onClose:w,context:g,defaultEmail:$,screenshotDataUrl:F??void 0})]})}function at({toast:t,onClose:s}){o.useEffect(()=>{const r=t.duration||5e3;if(r>0){const d=setTimeout(()=>{s(t.id)},r);return()=>clearTimeout(d)}},[t.id,t.duration,s]);const a={success:"✅",error:"❌",info:"ℹ️",warning:"⚠️"},l={success:"bg-emerald-50 border-emerald-200 text-emerald-900",error:"bg-red-50 border-red-200 text-red-900",info:"bg-blue-50 border-blue-200 text-blue-900",warning:"bg-amber-50 border-amber-200 text-amber-900"};return e.jsxs("div",{className:`flex items-center gap-3 px-4 py-3 rounded-lg border-2 shadow-lg min-w-[320px] max-w-[500px] animate-[slideIn_0.3s_ease-out] ${l[t.type]}`,children:[e.jsx("span",{className:"text-2xl",children:a[t.type]}),e.jsx("p",{className:"flex-1 text-sm font-medium m-0",children:t.message}),e.jsx("button",{onClick:()=>s(t.id),className:"text-gray-500 hover:text-gray-700 text-xl leading-none bg-transparent border-none cursor-pointer p-0 w-6 h-6 flex items-center justify-center rounded transition-colors hover:bg-black/10",children:"×"})]})}function ot({toasts:t,onClose:s}){return t.length===0?null:e.jsxs("div",{className:"fixed top-4 right-4 z-10000 flex flex-col gap-2",children:[e.jsx("style",{children:`
55
+ */const st=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],nt=E("refresh-cw",st);function it({labs:t,isAdmin:s,editorMode:o}){var v;const l=ie(),r=ae(),[d,i]=a.useState(),[N,A]=a.useState(!1),[b,p]=a.useState(!1),[B,S]=a.useState(null),k=re();a.useEffect(()=>{k.state==="idle"&&!k.data&&k.load("/api/generate-report")},[k]);const $=((v=k.data)==null?void 0:v.defaultEmail)||"",m={width:"20px",height:"20px",strokeWidth:1.5},T=(t==null?void 0:t.simulations)??!1,I=[{id:"editor",icon:e.jsx(tt,{style:m}),link:"/editor",name:"Editor",hidden:!o,newTab:!0},{id:"dashboard",icon:e.jsx(Qe,{style:m}),link:"/",name:"Dashboard",hidden:!T||o},{id:"simulations",icon:e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:m,children:[e.jsx("path",{d:"M9 12.75V15.75",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M6 15.75H12",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M6.75 12.7498L11.325 8.17483C11.6067 7.89873 11.9858 7.7447 12.3803 7.7461C12.7747 7.74751 13.1528 7.90423 13.4325 8.18233L16.5 11.2498",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M6 8.25C6.82843 8.25 7.5 7.57843 7.5 6.75C7.5 5.92157 6.82843 5.25 6 5.25C5.17157 5.25 4.5 5.92157 4.5 6.75C4.5 7.57843 5.17157 8.25 6 8.25Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M15 2.25H3C2.17157 2.25 1.5 2.92157 1.5 3.75V11.25C1.5 12.0784 2.17157 12.75 3 12.75H15C15.8284 12.75 16.5 12.0784 16.5 11.25V3.75C16.5 2.92157 15.8284 2.25 15 2.25Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),link:"/simulations",name:"Simulations",hidden:!T||o},{id:"git",icon:e.jsx(se,{style:m}),link:"/git",name:"Git",hidden:!T||o},{id:"files",icon:e.jsx(Ue,{style:m}),link:"/files",name:"Files",hidden:!T||o},{id:"activity",icon:e.jsx(nt,{style:m}),link:"/activity",name:"Activity",hidden:!T||o},{id:"memory",icon:e.jsx(Ne,{style:m}),link:"/memory",name:"Memory"},{id:"labs",icon:e.jsx(Ye,{style:m}),link:"/labs",name:"Labs"},{id:"settings",icon:e.jsx(ke,{style:m}),link:"/settings",name:"Settings"},{id:"commits",icon:e.jsx(se,{style:m}),link:"/commits",name:"Commits",hidden:!0},{id:"pages",icon:e.jsx(Ze,{style:m}),link:"/pages",name:"Pages",hidden:!0},{id:"components",icon:e.jsx(Oe,{style:m}),link:"/components",name:"Components",hidden:!0}],_=a.useCallback(c=>{const u=I.find(h=>h.id===c);u!=null&&u.link&&(u.newTab?window.open(u.link,"_blank"):r(u.link)),i(h=>h===c?void 0:c)},[I,r]);a.useEffect(()=>{const c={editor:["editor"],dashboard:["/","/home"],git:["git"],commits:["commits"],simulations:["simulations"],activity:["activity"],memory:["memory","agent-transcripts"],files:["files"],labs:["labs"],settings:["settings"],pages:["pages"],components:["components"]};for(const[u,h]of Object.entries(c))if(h.some(y=>y==="/"?l.pathname==="/":l.pathname.includes(y))){i(u);return}i(void 0)},[l]);const F=async()=>{p(!0);try{const{default:c}=await ge(async()=>{const{default:y}=await import("./html2canvas-pro.esm-fmIEn3Bc.js");return{default:y}},[]),h=(await c(document.body)).toDataURL("image/jpeg",.8);S(h),A(!0)}catch(c){console.error("Screenshot capture failed:",c),A(!0)}finally{p(!1)}},w=()=>{A(!1),S(null)},g=we();return e.jsxs(e.Fragment,{children:[e.jsxs("div",{id:"sidebar",className:"sticky top-0 w-full h-screen bg-[#051C22] flex flex-col justify-between py-3",children:[e.jsxs("div",{className:"w-full flex flex-col items-center",children:[e.jsx("div",{className:"py-3 mt-2 mb-4",children:e.jsx(Y,{to:"/",className:"flex items-center justify-center cursor-pointer",children:e.jsx("img",{src:ve,alt:"CodeYam",className:"h-6"})})}),I.filter(c=>!c.hidden).map(c=>e.jsx(Pe,{id:c.id,selected:c.id===d,onClick:_,icon:c.icon,name:c.name},`sidebar-button-${c.id}`))]}),s&&e.jsx("div",{className:"w-full flex flex-col items-center pb-2",children:e.jsxs("button",{onClick:()=>void F(),disabled:b,className:"w-full px-1.5 py-2 flex flex-col items-center justify-center gap-1 text-[#568B94] hover:text-[#CBF3FA] transition-colors cursor-pointer disabled:opacity-50 disabled:cursor-wait",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg flex items-center justify-center",children:b?e.jsx(Z,{style:{width:"20px",height:"20px",strokeWidth:1.5},className:"animate-spin"}):e.jsx(je,{style:{width:"20px",height:"20px",strokeWidth:1.5}})}),e.jsx("span",{className:"text-[9px] font-normal text-center leading-tight whitespace-pre-line",children:b?"Capturing...":`Report
56
+ Bug`})]})})]}),N&&e.jsx(be,{isOpen:!0,onClose:w,context:g,defaultEmail:$,screenshotDataUrl:B??void 0})]})}function ot({toast:t,onClose:s}){a.useEffect(()=>{const r=t.duration||5e3;if(r>0){const d=setTimeout(()=>{s(t.id)},r);return()=>clearTimeout(d)}},[t.id,t.duration,s]);const o={success:"✅",error:"❌",info:"ℹ️",warning:"⚠️"},l={success:"bg-emerald-50 border-emerald-200 text-emerald-900",error:"bg-red-50 border-red-200 text-red-900",info:"bg-blue-50 border-blue-200 text-blue-900",warning:"bg-amber-50 border-amber-200 text-amber-900"};return e.jsxs("div",{className:`flex items-center gap-3 px-4 py-3 rounded-lg border-2 shadow-lg min-w-[320px] max-w-[500px] animate-[slideIn_0.3s_ease-out] ${l[t.type]}`,children:[e.jsx("span",{className:"text-2xl",children:o[t.type]}),e.jsx("p",{className:"flex-1 text-sm font-medium m-0",children:t.message}),e.jsx("button",{onClick:()=>s(t.id),className:"text-gray-500 hover:text-gray-700 text-xl leading-none bg-transparent border-none cursor-pointer p-0 w-6 h-6 flex items-center justify-center rounded transition-colors hover:bg-black/10",children:"×"})]})}function at({toasts:t,onClose:s}){return t.length===0?null:e.jsxs("div",{className:"fixed top-4 right-4 z-10000 flex flex-col gap-2",children:[e.jsx("style",{children:`
57
57
  @keyframes slideIn {
58
58
  from {
59
59
  transform: translateX(400px);
@@ -64,4 +64,17 @@ Bug`})]})})]}),N&&e.jsx(ke,{isOpen:!0,onClose:w,context:g,defaultEmail:$,screens
64
64
  opacity: 1;
65
65
  }
66
66
  }
67
- `}),t.map(a=>e.jsx(at,{toast:a,onClose:s},a.id))]})}function X({entity:t,nameSize:s="11px",pathSize:a="10px",pathMaxLength:l=50,showScenarioCount:r=!1,scenarioCount:d=0,additionalContent:i}){return e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ze,{type:t.entityType||"other"}),e.jsxs(J,{to:`/entity/${t.sha}`,className:"hover:underline shrink-0 cursor-pointer",style:{fontSize:s,fontWeight:500,color:"#000",whiteSpace:"nowrap"},children:[t.name,r&&d>0&&` (${d})`]}),e.jsx(Te,{filePath:t.filePath,maxLength:l,style:{fontSize:a,color:"#8E8E8E"}})]}),i]})}const K={fontSize:"9px",color:"#005C75",fontStyle:"italic"};function rt({currentRun:t,projectSlug:s,currentEntities:a=[],isAnalysisStarting:l=!1,queuedJobCount:r=0,queueJobs:d=[],currentlyExecuting:i=null,historicalRuns:N=[]}){var Y,O,ee;const[A,k]=o.useState(!1),[p,F]=o.useState(!1),[S,b]=o.useState(null),[$,m]=o.useState(new Set),[z,_]=o.useState(new Set),[B,D]=o.useState(!1),w=!!i||d.length>0,g=!!i,v=(i==null?void 0:i.entities)||a,c=!!(t!=null&&t.analysisCompletedAt),u=(t==null?void 0:t.readyToBeCaptured)??0,h=(t==null?void 0:t.capturesCompleted)??0;t!=null&&t.captureCompletedAt||c&&(u===0||h>=u);const y=(t==null?void 0:t.currentEntityShas)&&t.currentEntityShas.length>0,H=w,{lastLine:I}=Le(s,H),T=g||d.length>0,U=new Set(((Y=i==null?void 0:i.entities)==null?void 0:Y.map(n=>n.sha))||[]),P=N.filter(n=>!(n.currentEntityShas||[]).some(x=>U.has(x))),V=(()=>{const f=Date.now()-1440*60*1e3;if(t!=null&&t.createdAt&&y){const x=t.analysisCompletedAt||t.createdAt;if(new Date(x).getTime()>f)return!0}if(P.length>0){const x=P[0],M=x.analysisCompletedAt||x.archivedAt||x.createdAt;if(M&&new Date(M).getTime()>f)return!0}return!1})();return o.useEffect(()=>{const n=(i==null?void 0:i.id)||null;w&&!p&&n!==S&&F(!0),!w&&S!==null&&b(null)},[w,i==null?void 0:i.id,p,S]),e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`fixed bottom-4 right-4 z-9998 bg-white rounded shadow-lg border-2 border-primary-100 transition-all duration-200 ${p?"min-w-[350px] max-w-[500px]":"w-auto"}`,children:[!p&&e.jsxs("div",{onClick:()=>{F(!0),b(null)},className:"flex items-center gap-2 px-3 py-2 cursor-pointer hover:bg-gray-50 transition-colors",title:"Click to expand",children:[T?e.jsx(Z,{size:16,className:"animate-spin",style:{color:"#005C75"}}):e.jsx("div",{className:"flex items-center justify-center rounded",style:{backgroundColor:"#E0E9EC",width:"20px",height:"20px"},children:e.jsx(Q,{size:16,style:{color:"#005C75"}})}),e.jsx("span",{style:{fontSize:"12px",fontWeight:500,color:"#343434"},children:T?"Analyzing...":"Activity: No Activity Yet"}),T&&e.jsx("button",{onClick:n=>{n.stopPropagation(),k(!0)},className:"ml-auto px-2 py-1 rounded transition-colors cursor-pointer",style:{backgroundColor:"#E0E9EC",color:"#005C75",fontSize:"10px",fontWeight:600},children:"View Logs"})]}),p&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[T?e.jsx(Z,{size:16,className:"animate-spin",style:{color:"#005C75"}}):e.jsx("div",{className:"flex items-center justify-center rounded",style:{backgroundColor:"#E0E9EC",width:"20px",height:"20px"},children:e.jsx(Q,{size:16,style:{color:"#005C75"}})}),e.jsx("span",{style:{fontSize:"12px",fontWeight:500,color:"#343434"},children:T?"Analyzing...":"Activity"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>k(!0),className:"px-2 py-1 rounded transition-colors cursor-pointer",style:{backgroundColor:"#E0E9EC",color:"#005C75",fontSize:"10px",fontWeight:600},children:"View Logs"}),e.jsx("button",{onClick:()=>{F(!1),b((i==null?void 0:i.id)||null)},className:"p-1 rounded transition-colors cursor-pointer",style:{backgroundColor:"#E0E9EC"},title:"Collapse","aria-label":"Collapse",children:e.jsx(Me,{size:16,style:{color:"#646464"}})})]})]}),e.jsx("div",{style:{height:"1px",backgroundColor:"#E0E9EC",margin:"0 12px"}}),e.jsxs("div",{className:"px-3 pt-2 pb-3 space-y-3",children:[T&&i&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[e.jsx(Q,{size:12,style:{color:"#005C75"}}),e.jsx("h4",{style:{fontSize:"11px",fontWeight:600,color:"#343434"},children:"Current Activity"})]}),e.jsx("div",{className:"rounded p-2",style:{backgroundColor:"#f5f5f5"},children:v.length>0?e.jsxs("div",{className:"space-y-1.5",children:[(B?v:v.slice(0,3)).map(n=>e.jsx(X,{entity:n,nameSize:"11px",pathSize:"10px",pathMaxLength:150},n.sha)),v.length>3&&e.jsx("button",{onClick:()=>D(n=>!n),className:"cursor-pointer bg-transparent border-none p-0 hover:underline",style:K,"aria-label":B?"Show fewer entities":`Show ${v.length-3} more entities`,children:B?"Show less":`+${v.length-3} more`}),I&&e.jsx("div",{style:{fontSize:"10px",color:"#005C75",marginTop:"4px"},children:I})]}):e.jsxs("div",{children:[i.entityNames&&i.entityNames.length>0?e.jsxs("div",{className:"space-y-0.5",children:[i.entityNames.slice(0,5).map((n,f)=>e.jsx("div",{style:{fontSize:"11px",color:"#343434"},children:n},f)),i.entityNames.length>5&&e.jsxs("div",{className:"italic",style:{fontSize:"10px",color:"#666"},children:["+",i.entityNames.length-5," ","more"]})]}):e.jsxs("div",{style:{fontSize:"11px",color:"#343434"},children:["Analyzing"," ",((O=i.entityShas)==null?void 0:O.length)||0," ",((ee=i.entityShas)==null?void 0:ee.length)===1?"entity":"entities","..."]}),I&&e.jsx("div",{style:{fontSize:"10px",color:"#005C75",marginTop:"4px"},children:I})]})})]}),d.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[e.jsx(He,{size:12,style:{color:"#005C75"}}),e.jsx("h4",{style:{fontSize:"11px",fontWeight:600,color:"#343434"},children:"Queued Activity"})]}),e.jsx("div",{className:"space-y-2 max-h-[200px] overflow-y-auto",children:d.map(n=>{var M,R;const f=$.has(n.id),x=f?n.entities:n.entities.slice(0,3);return e.jsx("div",{className:"rounded p-2",style:{backgroundColor:"#f5f5f5"},children:n.entities.length>0?e.jsxs("div",{className:"space-y-1.5",children:[x.map(E=>e.jsx(X,{entity:E,nameSize:"10px",pathSize:"9px",pathMaxLength:120},E.sha)),n.entities.length>3&&e.jsx("button",{onClick:()=>{m(E=>{const W=new Set(E);return W.has(n.id)?W.delete(n.id):W.add(n.id),W})},className:"cursor-pointer bg-transparent border-none p-0 hover:underline",style:K,"aria-label":f?"Show fewer entities":`Show ${n.entities.length-3} more entities`,children:f?"Show less":`+${n.entities.length-3} more`})]}):e.jsxs("div",{style:{fontSize:"10px",color:"#343434"},children:[n.type==="analysis"&&e.jsx(e.Fragment,{children:n.entityNames&&n.entityNames.length>0?e.jsxs("div",{className:"space-y-0.5",children:[n.entityNames.slice(0,5).map((E,W)=>e.jsx("div",{children:E},W)),n.entityNames.length>5&&e.jsxs("div",{className:"italic",children:["+",n.entityNames.length-5," more"]})]}):`Analyzing ${((M=n.entityShas)==null?void 0:M.length)||0} ${((R=n.entityShas)==null?void 0:R.length)===1?"entity":"entities"}`}),n.type==="recapture"&&"Recapturing scenario",n.type==="debug-setup"&&"Setting up debug environment"]})},n.id)})})]}),V&&P.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[e.jsx(Fe,{size:12,style:{color:"#005C75"}}),e.jsx("h4",{style:{fontSize:"11px",fontWeight:600,color:"#343434"},children:"Recently Completed"})]}),e.jsx("div",{className:"space-y-2 max-h-[200px] overflow-y-auto",children:P.slice(0,3).map((n,f)=>{const x=n.entities||[],M=n.analysisCompletedAt||n.archivedAt||n.createdAt||"",R=(()=>{if(!M)return"";const C=Date.now()-new Date(M).getTime(),j=Math.floor(C/6e4),q=Math.floor(C/36e5);return q>0?`${q}h ago`:j>0?`${j}m ago`:"just now"})(),E=z.has(f),ae=(E?x:x.slice(0,3)).map(C=>{var j,q,te;return{...C,scenarioCount:((te=(q=(j=C.analyses)==null?void 0:j[0])==null?void 0:q.scenarios)==null?void 0:te.length)||0}});return e.jsx("div",{className:"rounded p-2",style:{backgroundColor:"#f5f5f5"},children:x.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[ae.map((C,j)=>e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx(X,{entity:C,nameSize:"10px",pathSize:"9px",pathMaxLength:100,showScenarioCount:!0,scenarioCount:C.scenarioCount})}),j===0&&R&&e.jsx("div",{style:{fontSize:"9px",color:"#8E8E8E",whiteSpace:"nowrap",paddingTop:"2px"},children:R})]},C.sha)),x.length>3&&e.jsx("button",{onClick:()=>{_(C=>{const j=new Set(C);return j.has(f)?j.delete(f):j.add(f),j})},className:"cursor-pointer bg-transparent border-none p-0 hover:underline",style:K,"aria-label":E?"Show fewer entities":`Show ${x.length-3} more entities`,children:E?"Show less":`+${x.length-3} more`})]})},f)})})]})]}),e.jsx("div",{style:{height:"1px",backgroundColor:"#E0E9EC",margin:"0 12px"}}),e.jsx("div",{className:"px-3 pb-2",children:e.jsx(J,{to:"/activity",className:"text-xs font-medium hover:underline cursor-pointer",style:{color:"#005C75"},children:"View All Activity →"})})]})]}),A&&s&&e.jsx(Ae,{projectSlug:s,onClose:()=>k(!1)})]})}const lt="/assets/globals-Yn9W3zp3.css";function ne({text:t,subtext:s,linkText:a,linkTo:l}){const[r,d]=o.useState(!1);return r?null:e.jsx("div",{className:"bg-blue-100 border rounded border-blue-800 shadow-sm mx-6 mt-6",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-4 py-3 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[e.jsx("div",{className:"shrink-0",children:e.jsx("svg",{className:"w-5 h-5 text-yellow-600",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-blue-900",children:t}),e.jsx("p",{className:"text-xs text-blue-700 mt-0.5",children:s})]}),e.jsx(J,{to:l,className:"shrink-0 px-4 py-2 bg-blue-600 text-white text-sm font-medium rounded hover:bg-blue-700 transition-colors",children:a})]}),e.jsx("button",{type:"button",onClick:()=>d(!0),className:"shrink-0 ml-4 p-1 rounded text-blue-600 hover:text-blue-800 hover:bg-blue-100 transition-colors cursor-pointer","aria-label":"Dismiss banner",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{d:"M6 18L18 6M6 6l12 12"})})})]})})}function ct({version:t}){return e.jsx("div",{className:"px-6 sm:px-12 pb-8 mt-auto pt-8",children:e.jsxs("div",{className:"border-t border-cygray-30 pt-6 flex flex-wrap justify-between items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"font-mono text-sm font-semibold tracking-widest text-cyblack-100",children:"CODEYAM"}),t&&e.jsx("span",{className:"font-mono text-xs text-gray-400",children:t})]}),e.jsxs("div",{className:"flex items-center gap-4 font-mono text-xs uppercase tracking-widest",children:[e.jsx("a",{href:"https://blog.codeyam.com/",target:"_blank",rel:"noopener noreferrer",className:"text-cyblack-100 underline underline-offset-4 hover:text-primary-100",children:"Read the Blog"}),e.jsx("span",{className:"text-cygray-30",children:"|"}),e.jsx("a",{href:"https://discord.gg/x4uAgaRdwF",target:"_blank",rel:"noopener noreferrer",className:"text-cyblack-100 underline underline-offset-4 hover:text-primary-100",children:"Join Discord"})]})]})})}function dt({serverVersion:t}){const[s,a]=o.useState("stale"),[l,r]=o.useState(null),d=async()=>{a("restarting"),r(null);try{if(!(await fetch("/api/restart-server",{method:"POST"})).ok)throw new Error("Failed to restart server");a("reconnecting");let N=0;const A=30,k=1e3,p=async()=>{try{if((await fetch("/api/health")).ok){window.location.reload();return}}catch{}N++,N<A?setTimeout(()=>void p(),k):(r("Server took too long to restart. Please refresh manually."),a("stale"))};setTimeout(()=>void p(),500)}catch(i){r(i instanceof Error?i.message:"Failed to restart server"),a("stale")}};return e.jsx("div",{className:"bg-amber-100 border rounded border-amber-700 shadow-sm mx-6 mt-6",children:e.jsx("div",{className:"max-w-7xl mx-auto px-4 py-3 flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[e.jsx("div",{className:"shrink-0",children:e.jsx("svg",{className:"w-5 h-5 text-amber-600",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}),e.jsxs("div",{className:"flex-1",children:[s==="stale"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm font-medium text-amber-900",children:"Dashboard server is out of date"}),e.jsxs("p",{className:"text-xs text-amber-700 mt-0.5",children:["Server version: ",t,". A newer version of CodeYam CLI is installed. Restart the server to get the latest features."]}),l&&e.jsx("p",{className:"text-xs text-red-600 mt-1",children:l})]}),s==="restarting"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm font-medium text-amber-900",children:"Restarting server..."}),e.jsx("p",{className:"text-xs text-amber-700 mt-0.5",children:"Please wait while the server restarts."})]}),s==="reconnecting"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm font-medium text-amber-900",children:"Reconnecting..."}),e.jsx("p",{className:"text-xs text-amber-700 mt-0.5",children:"Waiting for the server to come back online."})]})]}),s==="stale"&&e.jsx("button",{type:"button",onClick:()=>void d(),className:"shrink-0 px-4 py-2 bg-amber-600 text-white text-sm font-medium rounded hover:bg-amber-700 transition-colors cursor-pointer",children:"Restart Server"}),(s==="restarting"||s==="reconnecting")&&e.jsxs("div",{className:"shrink-0 flex items-center gap-2 px-4 py-2 text-amber-700 text-sm",children:[e.jsxs("svg",{className:"w-4 h-4 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),s==="restarting"?"Stopping...":"Reconnecting..."]})]})})})}function mt({currentVersion:t,latestVersion:s}){const[a,l]=o.useState(!1);if(a)return null;const r="npm install -g @codeyam/codeyam-cli@latest && codeyam stop && codeyam";return e.jsx("div",{className:"bg-emerald-100 border rounded border-emerald-700 shadow-sm mx-6 mt-6",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-4 py-3 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[e.jsx("div",{className:"shrink-0",children:e.jsx("svg",{className:"w-5 h-5 text-emerald-600",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{d:"M7 11l5-5m0 0l5 5m-5-5v12"})})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-emerald-900",children:"A new version of CodeYam CLI is available"}),e.jsxs("p",{className:"text-xs text-emerald-700 mt-0.5",children:["Current: ",t," → Latest: ",s]})]}),e.jsxs("div",{className:"shrink-0 flex items-center gap-2",children:[e.jsx("code",{className:"text-xs bg-emerald-200 text-emerald-900 px-2 py-1.5 rounded font-mono",children:r}),e.jsx(_e,{content:r,label:"Copy",copiedLabel:"Copied!",className:"px-3 py-1.5 bg-emerald-600 text-white text-xs font-medium rounded hover:bg-emerald-700 transition-colors"})]})]}),e.jsx("button",{type:"button",onClick:()=>l(!0),className:"shrink-0 ml-4 p-1 rounded text-emerald-600 hover:text-emerald-800 hover:bg-emerald-200 transition-colors cursor-pointer","aria-label":"Dismiss banner",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{d:"M6 18L18 6M6 6l12 12"})})})]})})}const Ft=()=>[{rel:"stylesheet",href:lt},{rel:"icon",type:"image/x-icon",href:"/favicon.ico"}];function ht(){const{currentRun:t,projectSlug:s,currentEntities:a,availableAPIKeys:l,queuedJobCount:r,queueJobs:d,currentlyExecuting:i,historicalRuns:N,isServerOutOfDate:A,serverVersion:k,npmUpdate:p,labs:F,simulationsEnabled:S,isSimulationsReady:b,isAdmin:$,editorMode:m,displayVersion:z}=fe(),{toasts:_,closeToast:B}=Ee(),D=ue(),w=o.useRef(D),g=ie(),v=o.useRef(g.pathname);o.useEffect(()=>{w.current=D},[D]),o.useEffect(()=>{v.current=g.pathname},[g.pathname]);const c=g.pathname.startsWith("/entity/")&&g.pathname.includes("/edit/")||g.pathname.startsWith("/dev/")||g.pathname.startsWith("/editor"),u=g.pathname.includes("/fullscreen")||g.pathname.startsWith("/editor");return o.useEffect(()=>{let h=null,y=null,H=0;function I(){h||(h=new EventSource("/api/events"),h.addEventListener("message",P=>{const V=JSON.parse(P.data);(V.type==="queue"||V.type==="db-change")&&V.type;const Y=Ie(v.current),O=We({now:Date.now(),lastRevalidation:H,throttleMs:Y});O==="immediate"?(w.current.revalidate(),H=Date.now()):(y&&clearTimeout(y),y=setTimeout(()=>{w.current.revalidate(),H=Date.now(),y=null},O.delayMs))}),h.addEventListener("error",()=>{}))}function T(){y&&(clearTimeout(y),y=null),h&&(h.close(),h=null)}function U(){document.hidden?T():(I(),w.current.revalidate())}return document.hidden||I(),document.addEventListener("visibilitychange",U),()=>{document.removeEventListener("visibilitychange",U),T()}},[]),e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`min-h-screen ${c?"":"grid"} bg-cygray-10`,style:c?void 0:{gridTemplateColumns:"65px minmax(0, 1fr)"},children:[!c&&e.jsx(it,{labs:F,isAdmin:$,editorMode:m}),e.jsxs("div",{className:"max-h-screen overflow-auto bg-cygray-10 flex flex-col min-h-screen",children:[A&&e.jsx(dt,{serverVersion:k}),p&&p.currentVersion&&e.jsx(mt,{currentVersion:p.currentVersion,latestVersion:p.latestVersion}),S&&!m&&l.length===0&&e.jsx(ne,{text:"No AI API keys configured. Please provide an AI API key at your earliest convenience.",subtext:"An API key is required for stable, frequent use of CodeYam",linkText:"Configure API Keys",linkTo:"/settings"}),S&&!m&&!b&&e.jsx(ne,{text:"Simulations enabled but not yet configured",subtext:"Run /codeyam-setup in Claude Code to install the analyzer and configure your dev server",linkText:"View Labs",linkTo:"/labs"}),e.jsx("div",{className:"flex-1",children:e.jsx(ye,{})}),e.jsx(ct,{version:z})]})]}),e.jsx(ot,{toasts:_,onClose:B}),!u&&S&&e.jsx(rt,{currentRun:t,projectSlug:s,currentEntities:a,isAnalysisStarting:!1,queuedJobCount:r,queueJobs:d,currentlyExecuting:i,historicalRuns:N})]})}const _t=le(function(){return e.jsxs("html",{lang:"en",children:[e.jsxs("head",{children:[e.jsx("meta",{charSet:"utf-8"}),e.jsx("meta",{name:"viewport",content:"width=device-width,initial-scale=1"}),e.jsx(de,{}),e.jsx(me,{})]}),e.jsxs("body",{children:[e.jsx(Se,{children:e.jsx(Ce,{children:e.jsx(ht,{})})}),e.jsx(he,{}),e.jsx(pe,{})]})]})});function pt(t){if(t instanceof TypeError&&/fetch/i.test(t.message)||t instanceof Error&&/fetch/i.test(t.message))return!0;const s=String(t);return/failed to fetch|fetch.*failed|load.*chunk/i.test(s)}const Bt=ce(function(){const s=xe(),a=!G(s)&&pt(s),l=G(s)?s.status:500,r=G(s)?s.statusText||"Server Error":"Something went wrong";return e.jsxs("html",{lang:"en",children:[e.jsxs("head",{children:[e.jsx("meta",{charSet:"utf-8"}),e.jsx("meta",{name:"viewport",content:"width=device-width,initial-scale=1"}),e.jsxs("title",{children:[l," - CodeYam"]})]}),e.jsx("body",{style:{margin:0,fontFamily:'"IBM Plex Sans", system-ui, -apple-system, sans-serif',backgroundColor:"#F8F7F6",color:"#232323",display:"flex",alignItems:"center",justifyContent:"center",minHeight:"100vh"},children:e.jsxs("div",{style:{maxWidth:520,width:"100%",padding:"48px 32px",textAlign:"center"},children:[e.jsx("div",{style:{fontSize:64,fontWeight:700,color:"#005C75",lineHeight:1,marginBottom:8},children:l}),e.jsx("h1",{style:{fontSize:22,fontWeight:600,margin:"0 0 16px",color:"#232323"},children:r}),a?e.jsxs("div",{children:[e.jsx("p",{style:{fontSize:15,color:"#3E3E3E",lineHeight:1.6,margin:"0 0 24px"},children:"It looks like the CodeYam server is no longer running. This usually happens when the terminal session that started it was closed."}),e.jsx("div",{style:{backgroundColor:"#232323",color:"#D7FF63",borderRadius:8,padding:"14px 20px",fontFamily:'"IBM Plex Mono", monospace',fontSize:14,marginBottom:24,display:"inline-block"},children:"codeyam editor"}),e.jsx("p",{style:{fontSize:14,color:"#8E8E8E",margin:0},children:"Run this command in your project directory to restart the server, then refresh this page."})]}):e.jsxs("div",{children:[e.jsx("p",{style:{fontSize:15,color:"#3E3E3E",lineHeight:1.6,margin:"0 0 24px"},children:"An unexpected error occurred. Try refreshing the page."}),s instanceof Error&&s.message&&e.jsx("pre",{style:{backgroundColor:"#EFEFEF",borderRadius:8,padding:"14px 20px",fontFamily:'"IBM Plex Mono", monospace',fontSize:13,color:"#3E3E3E",textAlign:"left",overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",margin:0},children:s.message})]})]})})]})});export{Bt as ErrorBoundary,_t as default,Ft as links};
67
+ `}),t.map(o=>e.jsx(ot,{toast:o,onClose:s},o.id))]})}function Q({entity:t,nameSize:s="11px",pathSize:o="10px",pathMaxLength:l=50,showScenarioCount:r=!1,scenarioCount:d=0,additionalContent:i}){return e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Te,{type:t.entityType||"other"}),e.jsxs(Y,{to:`/entity/${t.sha}`,className:"hover:underline shrink-0 cursor-pointer",style:{fontSize:s,fontWeight:500,color:"#000",whiteSpace:"nowrap"},children:[t.name,r&&d>0&&` (${d})`]}),e.jsx(ze,{filePath:t.filePath,maxLength:l,style:{fontSize:o,color:"#8E8E8E"}})]}),i]})}const K={fontSize:"9px",color:"#005C75",fontStyle:"italic"};function rt({currentRun:t,projectSlug:s,currentEntities:o=[],isAnalysisStarting:l=!1,queuedJobCount:r=0,queueJobs:d=[],currentlyExecuting:i=null,historicalRuns:N=[]}){var J,O,ee;const[A,b]=a.useState(!1),[p,B]=a.useState(!1),[S,k]=a.useState(null),[$,m]=a.useState(new Set),[T,I]=a.useState(new Set),[_,F]=a.useState(!1),w=!!i||d.length>0,g=!!i,v=(i==null?void 0:i.entities)||o,c=!!(t!=null&&t.analysisCompletedAt),u=(t==null?void 0:t.readyToBeCaptured)??0,h=(t==null?void 0:t.capturesCompleted)??0;t!=null&&t.captureCompletedAt||c&&(u===0||h>=u);const y=(t==null?void 0:t.currentEntityShas)&&t.currentEntityShas.length>0,H=w,{lastLine:D}=Ee(s,H),z=g||d.length>0,U=new Set(((J=i==null?void 0:i.entities)==null?void 0:J.map(n=>n.sha))||[]),P=N.filter(n=>!(n.currentEntityShas||[]).some(x=>U.has(x))),V=(()=>{const f=Date.now()-1440*60*1e3;if(t!=null&&t.createdAt&&y){const x=t.analysisCompletedAt||t.createdAt;if(new Date(x).getTime()>f)return!0}if(P.length>0){const x=P[0],M=x.analysisCompletedAt||x.archivedAt||x.createdAt;if(M&&new Date(M).getTime()>f)return!0}return!1})();return a.useEffect(()=>{const n=(i==null?void 0:i.id)||null;w&&!p&&n!==S&&B(!0),!w&&S!==null&&k(null)},[w,i==null?void 0:i.id,p,S]),e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`fixed bottom-4 right-4 z-9998 bg-white rounded shadow-lg border-2 border-primary-100 transition-all duration-200 ${p?"min-w-[350px] max-w-[500px]":"w-auto"}`,children:[!p&&e.jsxs("div",{onClick:()=>{B(!0),k(null)},className:"flex items-center gap-2 px-3 py-2 cursor-pointer hover:bg-gray-50 transition-colors",title:"Click to expand",children:[z?e.jsx(Z,{size:16,className:"animate-spin",style:{color:"#005C75"}}):e.jsx("div",{className:"flex items-center justify-center rounded",style:{backgroundColor:"#E0E9EC",width:"20px",height:"20px"},children:e.jsx(G,{size:16,style:{color:"#005C75"}})}),e.jsx("span",{style:{fontSize:"12px",fontWeight:500,color:"#343434"},children:z?"Analyzing...":"Activity: No Activity Yet"}),z&&e.jsx("button",{onClick:n=>{n.stopPropagation(),b(!0)},className:"ml-auto px-2 py-1 rounded transition-colors cursor-pointer",style:{backgroundColor:"#E0E9EC",color:"#005C75",fontSize:"10px",fontWeight:600},children:"View Logs"})]}),p&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[z?e.jsx(Z,{size:16,className:"animate-spin",style:{color:"#005C75"}}):e.jsx("div",{className:"flex items-center justify-center rounded",style:{backgroundColor:"#E0E9EC",width:"20px",height:"20px"},children:e.jsx(G,{size:16,style:{color:"#005C75"}})}),e.jsx("span",{style:{fontSize:"12px",fontWeight:500,color:"#343434"},children:z?"Analyzing...":"Activity"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>b(!0),className:"px-2 py-1 rounded transition-colors cursor-pointer",style:{backgroundColor:"#E0E9EC",color:"#005C75",fontSize:"10px",fontWeight:600},children:"View Logs"}),e.jsx("button",{onClick:()=>{B(!1),k((i==null?void 0:i.id)||null)},className:"p-1 rounded transition-colors cursor-pointer",style:{backgroundColor:"#E0E9EC"},title:"Collapse","aria-label":"Collapse",children:e.jsx(Me,{size:16,style:{color:"#646464"}})})]})]}),e.jsx("div",{style:{height:"1px",backgroundColor:"#E0E9EC",margin:"0 12px"}}),e.jsxs("div",{className:"px-3 pt-2 pb-3 space-y-3",children:[z&&i&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[e.jsx(G,{size:12,style:{color:"#005C75"}}),e.jsx("h4",{style:{fontSize:"11px",fontWeight:600,color:"#343434"},children:"Current Activity"})]}),e.jsx("div",{className:"rounded p-2",style:{backgroundColor:"#f5f5f5"},children:v.length>0?e.jsxs("div",{className:"space-y-1.5",children:[(_?v:v.slice(0,3)).map(n=>e.jsx(Q,{entity:n,nameSize:"11px",pathSize:"10px",pathMaxLength:150},n.sha)),v.length>3&&e.jsx("button",{onClick:()=>F(n=>!n),className:"cursor-pointer bg-transparent border-none p-0 hover:underline",style:K,"aria-label":_?"Show fewer entities":`Show ${v.length-3} more entities`,children:_?"Show less":`+${v.length-3} more`}),D&&e.jsx("div",{style:{fontSize:"10px",color:"#005C75",marginTop:"4px"},children:D})]}):e.jsxs("div",{children:[i.entityNames&&i.entityNames.length>0?e.jsxs("div",{className:"space-y-0.5",children:[i.entityNames.slice(0,5).map((n,f)=>e.jsx("div",{style:{fontSize:"11px",color:"#343434"},children:n},f)),i.entityNames.length>5&&e.jsxs("div",{className:"italic",style:{fontSize:"10px",color:"#666"},children:["+",i.entityNames.length-5," ","more"]})]}):e.jsxs("div",{style:{fontSize:"11px",color:"#343434"},children:["Analyzing"," ",((O=i.entityShas)==null?void 0:O.length)||0," ",((ee=i.entityShas)==null?void 0:ee.length)===1?"entity":"entities","..."]}),D&&e.jsx("div",{style:{fontSize:"10px",color:"#005C75",marginTop:"4px"},children:D})]})})]}),d.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[e.jsx(He,{size:12,style:{color:"#005C75"}}),e.jsx("h4",{style:{fontSize:"11px",fontWeight:600,color:"#343434"},children:"Queued Activity"})]}),e.jsx("div",{className:"space-y-2 max-h-[200px] overflow-y-auto",children:d.map(n=>{var M,R;const f=$.has(n.id),x=f?n.entities:n.entities.slice(0,3);return e.jsx("div",{className:"rounded p-2",style:{backgroundColor:"#f5f5f5"},children:n.entities.length>0?e.jsxs("div",{className:"space-y-1.5",children:[x.map(L=>e.jsx(Q,{entity:L,nameSize:"10px",pathSize:"9px",pathMaxLength:120},L.sha)),n.entities.length>3&&e.jsx("button",{onClick:()=>{m(L=>{const W=new Set(L);return W.has(n.id)?W.delete(n.id):W.add(n.id),W})},className:"cursor-pointer bg-transparent border-none p-0 hover:underline",style:K,"aria-label":f?"Show fewer entities":`Show ${n.entities.length-3} more entities`,children:f?"Show less":`+${n.entities.length-3} more`})]}):e.jsxs("div",{style:{fontSize:"10px",color:"#343434"},children:[n.type==="analysis"&&e.jsx(e.Fragment,{children:n.entityNames&&n.entityNames.length>0?e.jsxs("div",{className:"space-y-0.5",children:[n.entityNames.slice(0,5).map((L,W)=>e.jsx("div",{children:L},W)),n.entityNames.length>5&&e.jsxs("div",{className:"italic",children:["+",n.entityNames.length-5," more"]})]}):`Analyzing ${((M=n.entityShas)==null?void 0:M.length)||0} ${((R=n.entityShas)==null?void 0:R.length)===1?"entity":"entities"}`}),n.type==="recapture"&&"Recapturing scenario",n.type==="debug-setup"&&"Setting up debug environment"]})},n.id)})})]}),V&&P.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[e.jsx(Be,{size:12,style:{color:"#005C75"}}),e.jsx("h4",{style:{fontSize:"11px",fontWeight:600,color:"#343434"},children:"Recently Completed"})]}),e.jsx("div",{className:"space-y-2 max-h-[200px] overflow-y-auto",children:P.slice(0,3).map((n,f)=>{const x=n.entities||[],M=n.analysisCompletedAt||n.archivedAt||n.createdAt||"",R=(()=>{if(!M)return"";const C=Date.now()-new Date(M).getTime(),j=Math.floor(C/6e4),q=Math.floor(C/36e5);return q>0?`${q}h ago`:j>0?`${j}m ago`:"just now"})(),L=T.has(f),oe=(L?x:x.slice(0,3)).map(C=>{var j,q,te;return{...C,scenarioCount:((te=(q=(j=C.analyses)==null?void 0:j[0])==null?void 0:q.scenarios)==null?void 0:te.length)||0}});return e.jsx("div",{className:"rounded p-2",style:{backgroundColor:"#f5f5f5"},children:x.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[oe.map((C,j)=>e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx(Q,{entity:C,nameSize:"10px",pathSize:"9px",pathMaxLength:100,showScenarioCount:!0,scenarioCount:C.scenarioCount})}),j===0&&R&&e.jsx("div",{style:{fontSize:"9px",color:"#8E8E8E",whiteSpace:"nowrap",paddingTop:"2px"},children:R})]},C.sha)),x.length>3&&e.jsx("button",{onClick:()=>{I(C=>{const j=new Set(C);return j.has(f)?j.delete(f):j.add(f),j})},className:"cursor-pointer bg-transparent border-none p-0 hover:underline",style:K,"aria-label":L?"Show fewer entities":`Show ${x.length-3} more entities`,children:L?"Show less":`+${x.length-3} more`})]})},f)})})]})]}),e.jsx("div",{style:{height:"1px",backgroundColor:"#E0E9EC",margin:"0 12px"}}),e.jsx("div",{className:"px-3 pb-2",children:e.jsx(Y,{to:"/activity",className:"text-xs font-medium hover:underline cursor-pointer",style:{color:"#005C75"},children:"View All Activity →"})})]})]}),A&&s&&e.jsx(Ae,{projectSlug:s,onClose:()=>b(!1)})]})}const lt="/assets/globals-BrPXT1iR.css";function ne({text:t,subtext:s,linkText:o,linkTo:l}){const[r,d]=a.useState(!1);return r?null:e.jsx("div",{className:"bg-blue-100 border rounded border-blue-800 shadow-sm mx-6 mt-6",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-4 py-3 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[e.jsx("div",{className:"shrink-0",children:e.jsx("svg",{className:"w-5 h-5 text-yellow-600",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-blue-900",children:t}),e.jsx("p",{className:"text-xs text-blue-700 mt-0.5",children:s})]}),e.jsx(Y,{to:l,className:"shrink-0 px-4 py-2 bg-blue-600 text-white text-sm font-medium rounded hover:bg-blue-700 transition-colors",children:o})]}),e.jsx("button",{type:"button",onClick:()=>d(!0),className:"shrink-0 ml-4 p-1 rounded text-blue-600 hover:text-blue-800 hover:bg-blue-100 transition-colors cursor-pointer","aria-label":"Dismiss banner",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{d:"M6 18L18 6M6 6l12 12"})})})]})})}function ct({version:t}){return e.jsx("div",{className:"px-6 sm:px-12 pb-8 mt-auto pt-8",children:e.jsxs("div",{className:"border-t border-cygray-30 pt-6 flex flex-wrap justify-between items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"font-mono text-sm font-semibold tracking-widest text-cyblack-100",children:"CODEYAM"}),t&&e.jsx("span",{className:"font-mono text-xs text-gray-400",children:t})]}),e.jsxs("div",{className:"flex items-center gap-4 font-mono text-xs uppercase tracking-widest",children:[e.jsx("a",{href:"https://blog.codeyam.com/",target:"_blank",rel:"noopener noreferrer",className:"text-cyblack-100 underline underline-offset-4 hover:text-primary-100",children:"Read the Blog"}),e.jsx("span",{className:"text-cygray-30",children:"|"}),e.jsx("a",{href:"https://discord.gg/x4uAgaRdwF",target:"_blank",rel:"noopener noreferrer",className:"text-cyblack-100 underline underline-offset-4 hover:text-primary-100",children:"Join Discord"})]})]})})}function dt({serverVersion:t}){const[s,o]=a.useState("stale"),[l,r]=a.useState(null),d=async()=>{o("restarting"),r(null);try{if(!(await fetch("/api/restart-server",{method:"POST"})).ok)throw new Error("Failed to restart server");o("reconnecting");let N=0;const A=30,b=1e3,p=async()=>{try{if((await fetch("/api/health")).ok){window.location.reload();return}}catch{}N++,N<A?setTimeout(()=>void p(),b):(r("Server took too long to restart. Please refresh manually."),o("stale"))};setTimeout(()=>void p(),500)}catch(i){r(i instanceof Error?i.message:"Failed to restart server"),o("stale")}};return e.jsx("div",{className:"bg-amber-100 border rounded border-amber-700 shadow-sm mx-6 mt-6",children:e.jsx("div",{className:"max-w-7xl mx-auto px-4 py-3 flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[e.jsx("div",{className:"shrink-0",children:e.jsx("svg",{className:"w-5 h-5 text-amber-600",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}),e.jsxs("div",{className:"flex-1",children:[s==="stale"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm font-medium text-amber-900",children:"Dashboard server is out of date"}),e.jsxs("p",{className:"text-xs text-amber-700 mt-0.5",children:["Server version: ",t,". A newer version of CodeYam CLI is installed. Restart the server to get the latest features."]}),l&&e.jsx("p",{className:"text-xs text-red-600 mt-1",children:l})]}),s==="restarting"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm font-medium text-amber-900",children:"Restarting server..."}),e.jsx("p",{className:"text-xs text-amber-700 mt-0.5",children:"Please wait while the server restarts."})]}),s==="reconnecting"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm font-medium text-amber-900",children:"Reconnecting..."}),e.jsx("p",{className:"text-xs text-amber-700 mt-0.5",children:"Waiting for the server to come back online."})]})]}),s==="stale"&&e.jsx("button",{type:"button",onClick:()=>void d(),className:"shrink-0 px-4 py-2 bg-amber-600 text-white text-sm font-medium rounded hover:bg-amber-700 transition-colors cursor-pointer",children:"Restart Server"}),(s==="restarting"||s==="reconnecting")&&e.jsxs("div",{className:"shrink-0 flex items-center gap-2 px-4 py-2 text-amber-700 text-sm",children:[e.jsxs("svg",{className:"w-4 h-4 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),s==="restarting"?"Stopping...":"Reconnecting..."]})]})})})}function mt({currentVersion:t,latestVersion:s}){const[o,l]=a.useState(!1);if(o)return null;const r="npm install -g @codeyam/codeyam-cli@latest && codeyam stop && codeyam";return e.jsx("div",{className:"bg-emerald-100 border rounded border-emerald-700 shadow-sm mx-6 mt-6",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-4 py-3 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[e.jsx("div",{className:"shrink-0",children:e.jsx("svg",{className:"w-5 h-5 text-emerald-600",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{d:"M7 11l5-5m0 0l5 5m-5-5v12"})})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-emerald-900",children:"A new version of CodeYam CLI is available"}),e.jsxs("p",{className:"text-xs text-emerald-700 mt-0.5",children:["Current: ",t," → Latest: ",s]})]}),e.jsxs("div",{className:"shrink-0 flex items-center gap-2",children:[e.jsx("code",{className:"text-xs bg-emerald-200 text-emerald-900 px-2 py-1.5 rounded font-mono",children:r}),e.jsx(Ie,{content:r,label:"Copy",copiedLabel:"Copied!",className:"px-3 py-1.5 bg-emerald-600 text-white text-xs font-medium rounded hover:bg-emerald-700 transition-colors"})]})]}),e.jsx("button",{type:"button",onClick:()=>l(!0),className:"shrink-0 ml-4 p-1 rounded text-emerald-600 hover:text-emerald-800 hover:bg-emerald-200 transition-colors cursor-pointer","aria-label":"Dismiss banner",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{d:"M6 18L18 6M6 6l12 12"})})})]})})}const Bt=()=>[{rel:"stylesheet",href:lt},{rel:"icon",type:"image/x-icon",href:"/favicon.ico"}];function ht(){const{currentRun:t,projectSlug:s,currentEntities:o,availableAPIKeys:l,queuedJobCount:r,queueJobs:d,currentlyExecuting:i,historicalRuns:N,isServerOutOfDate:A,serverVersion:b,npmUpdate:p,labs:B,simulationsEnabled:S,isSimulationsReady:k,isAdmin:$,editorMode:m,displayVersion:T}=fe(),{toasts:I,closeToast:_}=Le(),F=ue(),w=a.useRef(F),g=ie(),v=a.useRef(g.pathname);a.useEffect(()=>{w.current=F},[F]),a.useEffect(()=>{v.current=g.pathname},[g.pathname]);const c=g.pathname.startsWith("/entity/")&&g.pathname.includes("/edit/")||g.pathname.startsWith("/dev/")||g.pathname.startsWith("/editor"),u=g.pathname.includes("/fullscreen")||g.pathname.startsWith("/editor");return a.useEffect(()=>{let h=null,y=null,H=0;function D(){h||(h=new EventSource("/api/events"),h.addEventListener("message",P=>{const V=JSON.parse(P.data);(V.type==="queue"||V.type==="db-change")&&V.type;const J=De(v.current),O=We({now:Date.now(),lastRevalidation:H,throttleMs:J});O==="immediate"?(w.current.revalidate(),H=Date.now()):(y&&clearTimeout(y),y=setTimeout(()=>{w.current.revalidate(),H=Date.now(),y=null},O.delayMs))}),h.addEventListener("error",()=>{}))}function z(){y&&(clearTimeout(y),y=null),h&&(h.close(),h=null)}function U(){document.hidden?z():(D(),w.current.revalidate())}return document.hidden||D(),document.addEventListener("visibilitychange",U),()=>{document.removeEventListener("visibilitychange",U),z()}},[]),e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`min-h-screen ${c?"":"grid"} bg-cygray-10`,style:c?void 0:{gridTemplateColumns:"65px minmax(0, 1fr)"},children:[!c&&e.jsx(it,{labs:B,isAdmin:$,editorMode:m}),e.jsxs("div",{className:"max-h-screen overflow-auto bg-cygray-10 flex flex-col min-h-screen",children:[A&&e.jsx(dt,{serverVersion:b}),p&&p.currentVersion&&e.jsx(mt,{currentVersion:p.currentVersion,latestVersion:p.latestVersion}),S&&!m&&l.length===0&&e.jsx(ne,{text:"No AI API keys configured. Please provide an AI API key at your earliest convenience.",subtext:"An API key is required for stable, frequent use of CodeYam",linkText:"Configure API Keys",linkTo:"/settings"}),S&&!m&&!k&&e.jsx(ne,{text:"Simulations enabled but not yet configured",subtext:"Run /codeyam-setup in Claude Code to install the analyzer and configure your dev server",linkText:"View Labs",linkTo:"/labs"}),e.jsx("div",{className:"flex-1",children:e.jsx(ye,{})}),e.jsx(ct,{version:T})]})]}),e.jsx(at,{toasts:I,onClose:_}),!u&&S&&e.jsx(rt,{currentRun:t,projectSlug:s,currentEntities:o,isAnalysisStarting:!1,queuedJobCount:r,queueJobs:d,currentlyExecuting:i,historicalRuns:N})]})}const It=le(function(){return e.jsxs("html",{lang:"en",children:[e.jsxs("head",{children:[e.jsx("meta",{charSet:"utf-8"}),e.jsx("meta",{name:"viewport",content:"width=device-width,initial-scale=1"}),e.jsx(de,{}),e.jsx(me,{})]}),e.jsxs("body",{children:[e.jsx(Se,{children:e.jsx(Ce,{children:e.jsx(ht,{})})}),e.jsx(he,{}),e.jsx(pe,{})]})]})});function pt(t){if(t instanceof TypeError&&/fetch/i.test(t.message)||t instanceof Error&&/fetch/i.test(t.message))return!0;const s=String(t);return/failed to fetch|fetch.*failed|load.*chunk/i.test(s)}const _t=ce(function(){const s=xe(),o=!X(s)&&pt(s),l=X(s)?s.status:500,r=X(s)?s.statusText||"Server Error":"Something went wrong";return e.jsxs("html",{lang:"en",children:[e.jsxs("head",{children:[e.jsx("meta",{charSet:"utf-8"}),e.jsx("meta",{name:"viewport",content:"width=device-width,initial-scale=1"}),e.jsxs("title",{children:[l," - CodeYam"]})]}),e.jsx("body",{style:{margin:0,fontFamily:'"IBM Plex Sans", system-ui, -apple-system, sans-serif',backgroundColor:"#1e1e1e",color:"#ffffff",minHeight:"100vh",display:"flex",alignItems:"center"},children:e.jsxs("div",{style:{maxWidth:700,width:"100%",padding:"64px 80px"},children:[e.jsxs("div",{style:{fontFamily:'"IBM Plex Mono", monospace',fontSize:32,fontWeight:400,color:"#8E8E8E",lineHeight:1,marginBottom:12},children:["<",l,">"]}),e.jsx("h1",{style:{fontSize:42,fontWeight:600,margin:"0 0 20px",color:"#ffffff",lineHeight:1.2},children:o?"Something went wrong :(":r}),o?e.jsxs("div",{children:[e.jsx("p",{style:{fontSize:16,color:"#8E8E8E",lineHeight:1.7,margin:"0 0 28px",maxWidth:480},children:"It looks like the CodeYam server is no longer running. This usually happens when the terminal session that started it was closed."}),e.jsxs("p",{style:{fontSize:16,color:"#ffffff",margin:0,lineHeight:1.7,display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:["Run"," ",e.jsxs("button",{id:"copy-cmd-btn",type:"button",style:{display:"inline-flex",alignItems:"center",gap:8,backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:6,padding:"6px 12px",fontFamily:'"IBM Plex Mono", monospace',fontSize:13,color:"#ffffff",letterSpacing:"0.05em",textTransform:"uppercase",cursor:"pointer",minWidth:172,justifyContent:"center"},children:[e.jsx("span",{id:"copy-cmd-label",children:"codeyam editor"}),e.jsxs("svg",{id:"copy-cmd-icon",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#D7FF63",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),e.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})]})," ","in your project directory to restart the server. Then refresh this page."]}),e.jsx("script",{dangerouslySetInnerHTML:{__html:`
68
+ document.getElementById('copy-cmd-btn').addEventListener('click', function() {
69
+ var label = document.getElementById('copy-cmd-label');
70
+ var icon = document.getElementById('copy-cmd-icon');
71
+ navigator.clipboard.writeText('codeyam editor').then(function() {
72
+ label.textContent = 'copied!';
73
+ icon.style.display = 'none';
74
+ setTimeout(function() {
75
+ label.textContent = 'codeyam editor';
76
+ icon.style.display = '';
77
+ }, 2000);
78
+ });
79
+ });
80
+ `}})]}):e.jsxs("div",{children:[e.jsx("p",{style:{fontSize:16,color:"#8E8E8E",lineHeight:1.7,margin:"0 0 28px",maxWidth:480},children:"An unexpected error occurred. Try refreshing the page."}),s instanceof Error&&s.message&&e.jsx("pre",{style:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:8,padding:"16px 20px",fontFamily:'"IBM Plex Mono", monospace',fontSize:13,color:"#8E8E8E",textAlign:"left",overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",margin:0},children:s.message})]})]})})]})});export{_t as ErrorBoundary,It as default,Bt as links};
@@ -1,4 +1,4 @@
1
- import*as Y from"fs/promises";import*as w from"path";import{P as J,w as H}from"./progress-CHTtrxFG.js";import{ab as V,ac as _,ad as G,ae as q,af as K,ag as Q,ah as X,ai as Z,aj as U,ak as ee,u as te,al as re,am as oe,an as ne}from"./server-build-YI63xTu4.js";import{spawn as W,execSync as se}from"child_process";import*as P from"fs";import{fileURLToPath as ie}from"url";import"fetch-retry";import"typescript";import"pluralize";import"piscina";import"json5";import"cli-spinners";import"chalk";import"react/jsx-runtime";import"node:stream";import"@react-router/node";import"react-router";import"isbot";import"react-dom/server";import"react";import"lucide-react";import"better-sqlite3";import"pg";import"kysely";import"kysely/helpers/sqlite";import"kysely/helpers/postgres";import"os";import"prompts";import"crypto";import"util";import"dotenv";import"events";import"uuid";import"http";import"net";import"ws";import"node-pty";import"openai";import"p-queue";import"p-retry";import"@aws-sdk/client-dynamodb";import"lru-cache";import"@aws-sdk/util-dynamodb";import"v8";import"react-syntax-highlighter";import"react-syntax-highlighter/dist/cjs/styles/prism/index.js";import"node:crypto";import"minimatch";import"react-markdown";import"remark-gfm";import"react-diff-viewer-continued";const ae=ie(import.meta.url),ce=w.dirname(ae);async function le(b){let i=b.port;const{rootPath:c,project:l,branch:E,processName:R="server"}=b;let u=!1;const{running:m,state:e,pids:v}=V();if(m&&e)if(e.cliVersion!==_)console.log(`CLI version mismatch (server: ${e.cliVersion??"unknown"} → CLI: ${_}), restarting server...`),G(),u=!0;else return{url:e.url,pid:e.pid,wasAlreadyRunning:!0};else m&&v&&v.length>0&&(q(i)||(i=K(i,q)));const j=`http://localhost:${i}`,S=w.join(ce,"..","webserver","bootstrap.js"),o=w.join(c,".codeyam","logs");P.existsSync(o)||P.mkdirSync(o,{recursive:!0});const A={CODEYAM_PORT:i.toString(),CODEYAM_ROOT_PATH:c,CODEYAM_PROJECT:l?JSON.stringify(l):"",CODEYAM_BRANCH:E?JSON.stringify(E):"",CODEYAM_PROCESS_NAME:`codeyam-${R}`,...u?{CODEYAM_WAIT_FOR_PORT:"true"}:{},...process.env.CODEYAM_TRACE_TRANSFORMS?{CODEYAM_TRACE_TRANSFORMS:process.env.CODEYAM_TRACE_TRANSFORMS}:{}};let p;if(process.platform==="win32")p=await pe(S,A,o);else{const s=P.openSync(w.join(o,"background-server.log"),"a"),r=P.openSync(w.join(o,"background-server-error.log"),"a"),f=W("node",["--max-old-space-size=8192",S],{detached:!0,stdio:["ignore",s,r],env:{...process.env,...A}});f.unref(),p=f.pid}try{const s=se(`lsof -ti:${i}`,{encoding:"utf8"}).trim();if(s){const r=s.split(`
1
+ import*as Y from"fs/promises";import*as w from"path";import{P as J,w as H}from"./progress-CHTtrxFG.js";import{ab as V,ac as _,ad as G,ae as q,af as K,ag as Q,ah as X,ai as Z,aj as U,ak as ee,u as te,al as re,am as oe,an as ne}from"./server-build-pulXLTrG.js";import{spawn as W,execSync as se}from"child_process";import*as P from"fs";import{fileURLToPath as ie}from"url";import"fetch-retry";import"typescript";import"pluralize";import"piscina";import"json5";import"cli-spinners";import"chalk";import"react/jsx-runtime";import"node:stream";import"@react-router/node";import"react-router";import"isbot";import"react-dom/server";import"react";import"lucide-react";import"better-sqlite3";import"pg";import"kysely";import"kysely/helpers/sqlite";import"kysely/helpers/postgres";import"os";import"prompts";import"crypto";import"util";import"dotenv";import"events";import"uuid";import"http";import"net";import"ws";import"node-pty";import"openai";import"p-queue";import"p-retry";import"@aws-sdk/client-dynamodb";import"lru-cache";import"@aws-sdk/util-dynamodb";import"v8";import"react-syntax-highlighter";import"react-syntax-highlighter/dist/cjs/styles/prism/index.js";import"node:crypto";import"minimatch";import"react-markdown";import"remark-gfm";import"react-diff-viewer-continued";const ae=ie(import.meta.url),ce=w.dirname(ae);async function le(b){let i=b.port;const{rootPath:c,project:l,branch:E,processName:R="server"}=b;let u=!1;const{running:m,state:e,pids:v}=V();if(m&&e)if(e.cliVersion!==_)console.log(`CLI version mismatch (server: ${e.cliVersion??"unknown"} → CLI: ${_}), restarting server...`),G(),u=!0;else return{url:e.url,pid:e.pid,wasAlreadyRunning:!0};else m&&v&&v.length>0&&(q(i)||(i=K(i,q)));const j=`http://localhost:${i}`,S=w.join(ce,"..","webserver","bootstrap.js"),o=w.join(c,".codeyam","logs");P.existsSync(o)||P.mkdirSync(o,{recursive:!0});const A={CODEYAM_PORT:i.toString(),CODEYAM_ROOT_PATH:c,CODEYAM_PROJECT:l?JSON.stringify(l):"",CODEYAM_BRANCH:E?JSON.stringify(E):"",CODEYAM_PROCESS_NAME:`codeyam-${R}`,...u?{CODEYAM_WAIT_FOR_PORT:"true"}:{},...process.env.CODEYAM_TRACE_TRANSFORMS?{CODEYAM_TRACE_TRANSFORMS:process.env.CODEYAM_TRACE_TRANSFORMS}:{}};let p;if(process.platform==="win32")p=await pe(S,A,o);else{const s=P.openSync(w.join(o,"background-server.log"),"a"),r=P.openSync(w.join(o,"background-server-error.log"),"a"),f=W("node",["--max-old-space-size=8192",S],{detached:!0,stdio:["ignore",s,r],env:{...process.env,...A}});f.unref(),p=f.pid}try{const s=se(`lsof -ti:${i}`,{encoding:"utf8"}).trim();if(s){const r=s.split(`
2
2
  `),f=r.find(C=>C===String(p)),d=r.filter(C=>C!==String(p));d.length>0&&console.warn(`[BackgroundServer] Port ${i} still held by other PID(s): ${d.join(", ")} (server PID: ${p})`)}}catch{}const L=`http://127.0.0.1:${i}/api/health`,y=6e4,D=500,a=Date.now();let g="",k=!1;for(;Date.now()-a<y;){try{process.kill(p,0)}catch{const r=((Date.now()-a)/1e3).toFixed(1);console.error(`[BackgroundServer] Server process (PID ${p}) died after ${r}s`);const f=w.join(o,"background-server.log");try{const $=P.readFileSync(f,"utf8").trim().split(`
3
3
  `).slice(-15).join(`
4
4
  `);console.error(`[BackgroundServer] Last log lines:
@@ -1 +1 @@
1
- import"fetch-retry";import{K as Z,N as _,Q as $,R as aa,U as ea,W as sa,Z as ta,a1 as ra,a4 as oa,J as ia,L as ma,M as la,O as pa,P as na,S as ca,T as ba,V as Ta,X as da,Y as ua,_ as ha,$ as Ca,a0 as Sa,a2 as ya,a3 as Ba,a5 as Aa,I as Ea,a6 as Pa,a7 as ga,a8 as ja,aa as Fa,a9 as Ua,d as Da,a as Ga,b as Ma,c as qa,e as Ja,f as fa,g as ka,h as xa,i as Ha,j as La,k as va,E as wa,H as za,G as Ia,F as Ka,l as Na,m as Oa,n as Qa,o as Ra,p as Va,q as Wa,r as Xa,s as Ya,t as Za,u as _a,v as $a,w as ae,x as ee,y as se,z as te,A as re,B as oe,C as ie,D as me}from"./server-build-YI63xTu4.js";import"typescript";import"react/jsx-runtime";import"node:stream";import"@react-router/node";import"react-router";import"isbot";import"react-dom/server";import"react";import"lucide-react";import"better-sqlite3";import"pg";import"fs";import"path";import"kysely";import"kysely/helpers/sqlite";import"kysely/helpers/postgres";import"fs/promises";import"os";import"prompts";import"chalk";import"crypto";import"child_process";import"url";import"util";import"dotenv";import"events";import"uuid";import"http";import"net";import"ws";import"node-pty";import"openai";import"p-queue";import"p-retry";import"@aws-sdk/client-dynamodb";import"lru-cache";import"pluralize";import"piscina";import"json5";import"@aws-sdk/util-dynamodb";import"v8";import"react-syntax-highlighter";import"react-syntax-highlighter/dist/cjs/styles/prism/index.js";import"node:crypto";import"minimatch";import"react-markdown";import"remark-gfm";import"react-diff-viewer-continued";export{Z as AnalysisBranchesTableColumns,_ as BranchesTableColumns,$ as CommitsTableColumns,aa as CommitsTableColumnsLite,ea as EntitiesTableColumns,sa as EntityBranchesTableColumns,ta as FilesTableColumns,ra as ProjectsTableColumns,oa as ScenariosTableColumns,ia as createAnalysesTable,ma as createAnalysisBranchesTable,la as createBackgroundJobsTable,pa as createBranchesTable,na as createCommitBranchesTable,ca as createCommitsTable,ba as createEditorScenariosTable,Ta as createEntitiesTable,da as createEntityBranchesTable,ua as createEntityStatementsTable,ha as createFilesTable,Ca as createGithubPayloadsTable,Sa as createGithubUsersTable,ya as createProjectsTable,Ba as createScenarioCommentsTable,Aa as createScenariosTable,Ea as createSqliteSchema,Pa as createStatementsTable,ga as createTeamsTable,ja as createUserScenariosTable,Fa as createUserTeamsTable,Ua as createUsersTable,Da as dbToAnalysis,Ga as dbToAnalysisBranch,Ma as dbToBranch,qa as dbToCommit,Ja as dbToEntity,fa as dbToFile,ka as dbToProject,xa as dbToScenario,Ha as dbToUserScenario,La as deleteScenarios,va as generateSha,wa as getDatabase,za as getJsonHelper,Ia as getPostgreDatabase,Ka as getSqliteDatabase,Na as loadAnalyses,Oa as loadAnalysis,Qa as loadBranches,Ra as loadCommitBranches,Va as loadCommits,Wa as loadEntities,Xa as loadEntity,Ya as loadFiles,Za as loadProject,_a as updateCommitMetadata,$a as updateFreshAnalysisMetadata,ae as updateFreshAnalysisStatus,ee as updateProjectMetadata,se as upsertBranches,te as upsertCommitBranches,re as upsertCommits,oe as upsertGithubUser,ie as upsertProjects,me as upsertScenarios};
1
+ import"fetch-retry";import{K as Z,N as _,Q as $,R as aa,U as ea,W as sa,Z as ta,a1 as ra,a4 as oa,J as ia,L as ma,M as la,O as pa,P as na,S as ca,T as ba,V as Ta,X as da,Y as ua,_ as ha,$ as Ca,a0 as Sa,a2 as ya,a3 as Ba,a5 as Aa,I as Ea,a6 as Pa,a7 as ga,a8 as ja,aa as Fa,a9 as Ua,d as Da,a as Ga,b as Ma,c as qa,e as Ja,f as fa,g as ka,h as xa,i as Ha,j as La,k as va,E as wa,H as za,G as Ia,F as Ka,l as Na,m as Oa,n as Qa,o as Ra,p as Va,q as Wa,r as Xa,s as Ya,t as Za,u as _a,v as $a,w as ae,x as ee,y as se,z as te,A as re,B as oe,C as ie,D as me}from"./server-build-pulXLTrG.js";import"typescript";import"react/jsx-runtime";import"node:stream";import"@react-router/node";import"react-router";import"isbot";import"react-dom/server";import"react";import"lucide-react";import"better-sqlite3";import"pg";import"fs";import"path";import"kysely";import"kysely/helpers/sqlite";import"kysely/helpers/postgres";import"fs/promises";import"os";import"prompts";import"chalk";import"crypto";import"child_process";import"url";import"util";import"dotenv";import"events";import"uuid";import"http";import"net";import"ws";import"node-pty";import"openai";import"p-queue";import"p-retry";import"@aws-sdk/client-dynamodb";import"lru-cache";import"pluralize";import"piscina";import"json5";import"@aws-sdk/util-dynamodb";import"v8";import"react-syntax-highlighter";import"react-syntax-highlighter/dist/cjs/styles/prism/index.js";import"node:crypto";import"minimatch";import"react-markdown";import"remark-gfm";import"react-diff-viewer-continued";export{Z as AnalysisBranchesTableColumns,_ as BranchesTableColumns,$ as CommitsTableColumns,aa as CommitsTableColumnsLite,ea as EntitiesTableColumns,sa as EntityBranchesTableColumns,ta as FilesTableColumns,ra as ProjectsTableColumns,oa as ScenariosTableColumns,ia as createAnalysesTable,ma as createAnalysisBranchesTable,la as createBackgroundJobsTable,pa as createBranchesTable,na as createCommitBranchesTable,ca as createCommitsTable,ba as createEditorScenariosTable,Ta as createEntitiesTable,da as createEntityBranchesTable,ua as createEntityStatementsTable,ha as createFilesTable,Ca as createGithubPayloadsTable,Sa as createGithubUsersTable,ya as createProjectsTable,Ba as createScenarioCommentsTable,Aa as createScenariosTable,Ea as createSqliteSchema,Pa as createStatementsTable,ga as createTeamsTable,ja as createUserScenariosTable,Fa as createUserTeamsTable,Ua as createUsersTable,Da as dbToAnalysis,Ga as dbToAnalysisBranch,Ma as dbToBranch,qa as dbToCommit,Ja as dbToEntity,fa as dbToFile,ka as dbToProject,xa as dbToScenario,Ha as dbToUserScenario,La as deleteScenarios,va as generateSha,wa as getDatabase,za as getJsonHelper,Ia as getPostgreDatabase,Ka as getSqliteDatabase,Na as loadAnalyses,Oa as loadAnalysis,Qa as loadBranches,Ra as loadCommitBranches,Va as loadCommits,Wa as loadEntities,Xa as loadEntity,Ya as loadFiles,Za as loadProject,_a as updateCommitMetadata,$a as updateFreshAnalysisMetadata,ae as updateFreshAnalysisStatus,ee as updateProjectMetadata,se as upsertBranches,te as upsertCommitBranches,re as upsertCommits,oe as upsertGithubUser,ie as upsertProjects,me as upsertScenarios};
@@ -1,4 +1,4 @@
1
- import*as m from"fs/promises";import*as y from"fs";import*as e from"path";import x from"chalk";import{execSync as F}from"child_process";import{h as _,s as b,e as v,P as B,i as E,w as R}from"./progress-CHTtrxFG.js";import{ao as I,ap as W,aq as M,ab as O,ad as T,ar as U,as as A,at as G,F as q,I as Y,an as z,au as N,av as J,x as P}from"./server-build-YI63xTu4.js";import"fetch-retry";import"typescript";import{fileURLToPath as L}from"url";import"cli-spinners";import"react/jsx-runtime";import"node:stream";import"@react-router/node";import"react-router";import"isbot";import"react-dom/server";import"react";import"lucide-react";import"better-sqlite3";import"pg";import"kysely";import"kysely/helpers/sqlite";import"kysely/helpers/postgres";import"os";import"prompts";import"crypto";import"util";import"dotenv";import"events";import"uuid";import"http";import"net";import"ws";import"node-pty";import"openai";import"p-queue";import"p-retry";import"@aws-sdk/client-dynamodb";import"lru-cache";import"pluralize";import"piscina";import"json5";import"@aws-sdk/util-dynamodb";import"v8";import"react-syntax-highlighter";import"react-syntax-highlighter/dist/cjs/styles/prism/index.js";import"node:crypto";import"minimatch";import"react-markdown";import"remark-gfm";import"react-diff-viewer-continued";function H(a){try{const r=F("git config --get remote.origin.url",{cwd:a,encoding:"utf8"}).trim().match(/github\.com[:/]([^/]+)\/([^/]+?)(?:\.git)?$/);if(r)return`${r[1]}-${r[2]}`}catch{}return e.basename(a)}const V=L(import.meta.url),K=e.dirname(V);async function g(a,t){await m.mkdir(t,{recursive:!0});const r=await m.readdir(a,{withFileTypes:!0});for(const i of r){const s=e.join(a,i.name),o=e.join(t,i.name);i.isDirectory()?await g(s,o):(await m.copyFile(s,o),(i.name.endsWith(".sh")||i.name.endsWith(".mjs"))&&await m.chmod(o,493))}}async function Q(a,t){const r=(t==null?void 0:t.mode)??"memory";try{const i=e.join(a,".claude","skills"),s=e.join(K,"../../templates"),o=e.join(s,"skills"),n=e.join(s,"commands"),u=e.join(i,"codeyam-memory"),p=e.join(i,"codeyam-new-rule");await g(e.join(o,"codeyam-memory"),u),await g(e.join(o,"codeyam-new-rule"),p);const w=r==="editor"||(t==null?void 0:t.editorMode)===!0;if(w){const c=e.join(i,"codeyam-editor");await g(e.join(o,"codeyam-editor"),c);const f=e.join(a,"CLAUDE.md");try{await m.access(f)}catch{await m.copyFile(e.join(s,"codeyam-editor-claude.md"),f)}const d=e.join(a,".codeyam","docs");await m.mkdir(d,{recursive:!0}),await m.copyFile(e.join(s,"codeyam-editor-reference.md"),e.join(d,"editor-reference.md"))}if(r==="full"){const c=e.join(i,"codeyam-setup"),f=e.join(i,"codeyam-sim"),d=e.join(i,"codeyam-test"),h=e.join(i,"codeyam-verify"),S=e.join(i,"codeyam-dev-mode");await g(e.join(o,"codeyam-setup"),c),await g(e.join(o,"codeyam-sim"),f),await g(e.join(o,"codeyam-test"),d),await g(e.join(o,"codeyam-verify"),h),await g(e.join(o,"codeyam-dev-mode"),S);const k=e.join(a,".claude","commands");await m.mkdir(k,{recursive:!0}),await m.copyFile(e.join(n,"codeyam-diagnose.md"),e.join(k,"codeyam-diagnose.md"))}const l=e.join(a,".codeyam","bin");await m.mkdir(l,{recursive:!0});const j=e.join(a,".codeyam","rules");if(await m.mkdir(j,{recursive:!0}),w){try{const c=e.join(l,"editor-step-hook.py");await m.copyFile(e.join(s,"editor-step-hook.py"),c),await m.chmod(c,493)}catch{}try{const c=e.join(s,"seed-adapters"),f=e.join(a,".codeyam","seed-adapters");await g(c,f)}catch{}}try{const c=e.join(l,"memory-hook.sh");await m.copyFile(e.join(s,"codeyam-memory-hook.sh"),c),await m.chmod(c,493)}catch{}try{const c=e.join(l,"rule-reflection-hook.py");await m.copyFile(e.join(s,"rule-reflection-hook.py"),c),await m.chmod(c,493)}catch{}try{const c=e.join(l,"rule-notification-hook.py");await m.copyFile(e.join(s,"rule-notification-hook.py"),c),await m.chmod(c,493)}catch{}try{const c=e.join(l,"prompts");await m.mkdir(c,{recursive:!0});const f=await m.readdir(e.join(s,"prompts"));for(const d of f)await m.copyFile(e.join(s,"prompts",d),e.join(c,d))}catch{}try{await m.copyFile(e.join(s,"rules-instructions.md"),e.join(j,"instructions.md"))}catch{}return{success:!0,skillsPath:e.relative(a,i)}}catch(i){return{success:!1,error:i instanceof Error?i.message:String(i)}}}function X(a,t){const r=(t==null?void 0:t.mode)??"memory";try{const i=e.join(a,".claude"),s=e.join(i,"settings.local.json");y.existsSync(i)||y.mkdirSync(i,{recursive:!0});let o={};if(y.existsSync(s))try{const c=y.readFileSync(s,"utf8");o=JSON.parse(c)}catch{console.warn(`Warning: Could not parse ${s}, will create new file`)}o.permissions||(o.permissions={}),o.permissions.allow||(o.permissions.allow=[]);const n=["Skill(codeyam-memory)","Skill(codeyam-new-rule)","Bash(codeyam)","Bash(codeyam:*)","Read(.codeyam/**)","Edit(.codeyam/**)","Write(.codeyam/**)","Glob(.codeyam/**)"],u=["Skill(codeyam-setup)","Skill(codeyam-sim)","Skill(codeyam-debug)","Skill(codeyam-test)","Skill(codeyam-verify)","Skill(codeyam-dev-mode)","Read(/tmp/**)","Edit(/tmp/**)","Write(/tmp/**)","Glob(/tmp/**)","Bash(npm install:*)","Bash(npm run:*)","Bash(npx:*)","Bash(node:*)","Bash(cp:*)","Bash(mkdir:*)","Bash(chmod:*)","Bash(rm:*)","Bash(curl:*)","Bash(sleep:*)","Bash(echo:*)","Bash(grep:*)","Bash(python3:*)","Bash(cat:*)","Bash(printf:*)","Bash(ls:*)"],p=["Skill(codeyam-editor)","Bash(git:*)","Edit(**)","Write(**)"],w=r==="editor"||(t==null?void 0:t.editorMode)===!0;let l;if(r==="full"?l=[...n,...u]:r==="editor"?l=[...n,...p,...u]:l=n,w&&r!=="editor")for(const c of[...p,...u])l.includes(c)||l.push(c);let j=!1;for(const c of l)o.permissions.allow.includes(c)||(o.permissions.allow.push(c),j=!0);if(w){o.hooks||(o.hooks={});const c='test -f "$CLAUDE_PROJECT_DIR"/.codeyam/bin/editor-step-hook.py && python3 "$CLAUDE_PROJECT_DIR"/.codeyam/bin/editor-step-hook.py || true';for(const f of["PostToolUse","Stop","UserPromptSubmit"]){const d=o.hooks[f]||[];d.some(S=>{var k;return(k=S.hooks)==null?void 0:k.some(C=>{var $;return($=C.command)==null?void 0:$.includes("editor-step-hook")})})||(d.push({hooks:[{type:"command",command:c,timeout:5}]}),o.hooks[f]=d,j=!0)}}return j&&y.writeFileSync(s,JSON.stringify(o,null,2),"utf8"),!0}catch(i){return console.warn(`Warning: Could not configure Claude Code settings: ${i.message}`),!1}}function Z(a){return y.existsSync(a)?y.readFileSync(a,"utf8").split(`
1
+ import*as m from"fs/promises";import*as y from"fs";import*as e from"path";import x from"chalk";import{execSync as F}from"child_process";import{h as _,s as b,e as v,P as B,i as E,w as R}from"./progress-CHTtrxFG.js";import{ao as I,ap as W,aq as M,ab as O,ad as T,ar as U,as as A,at as G,F as q,I as Y,an as z,au as N,av as J,x as P}from"./server-build-pulXLTrG.js";import"fetch-retry";import"typescript";import{fileURLToPath as L}from"url";import"cli-spinners";import"react/jsx-runtime";import"node:stream";import"@react-router/node";import"react-router";import"isbot";import"react-dom/server";import"react";import"lucide-react";import"better-sqlite3";import"pg";import"kysely";import"kysely/helpers/sqlite";import"kysely/helpers/postgres";import"os";import"prompts";import"crypto";import"util";import"dotenv";import"events";import"uuid";import"http";import"net";import"ws";import"node-pty";import"openai";import"p-queue";import"p-retry";import"@aws-sdk/client-dynamodb";import"lru-cache";import"pluralize";import"piscina";import"json5";import"@aws-sdk/util-dynamodb";import"v8";import"react-syntax-highlighter";import"react-syntax-highlighter/dist/cjs/styles/prism/index.js";import"node:crypto";import"minimatch";import"react-markdown";import"remark-gfm";import"react-diff-viewer-continued";function H(a){try{const r=F("git config --get remote.origin.url",{cwd:a,encoding:"utf8"}).trim().match(/github\.com[:/]([^/]+)\/([^/]+?)(?:\.git)?$/);if(r)return`${r[1]}-${r[2]}`}catch{}return e.basename(a)}const V=L(import.meta.url),K=e.dirname(V);async function g(a,t){await m.mkdir(t,{recursive:!0});const r=await m.readdir(a,{withFileTypes:!0});for(const i of r){const s=e.join(a,i.name),o=e.join(t,i.name);i.isDirectory()?await g(s,o):(await m.copyFile(s,o),(i.name.endsWith(".sh")||i.name.endsWith(".mjs"))&&await m.chmod(o,493))}}async function Q(a,t){const r=(t==null?void 0:t.mode)??"memory";try{const i=e.join(a,".claude","skills"),s=e.join(K,"../../templates"),o=e.join(s,"skills"),n=e.join(s,"commands"),u=e.join(i,"codeyam-memory"),p=e.join(i,"codeyam-new-rule");await g(e.join(o,"codeyam-memory"),u),await g(e.join(o,"codeyam-new-rule"),p);const w=r==="editor"||(t==null?void 0:t.editorMode)===!0;if(w){const c=e.join(i,"codeyam-editor");await g(e.join(o,"codeyam-editor"),c);const f=e.join(a,"CLAUDE.md");try{await m.access(f)}catch{await m.copyFile(e.join(s,"codeyam-editor-claude.md"),f)}const d=e.join(a,".codeyam","docs");await m.mkdir(d,{recursive:!0}),await m.copyFile(e.join(s,"codeyam-editor-reference.md"),e.join(d,"editor-reference.md"))}if(r==="full"){const c=e.join(i,"codeyam-setup"),f=e.join(i,"codeyam-sim"),d=e.join(i,"codeyam-test"),h=e.join(i,"codeyam-verify"),S=e.join(i,"codeyam-dev-mode");await g(e.join(o,"codeyam-setup"),c),await g(e.join(o,"codeyam-sim"),f),await g(e.join(o,"codeyam-test"),d),await g(e.join(o,"codeyam-verify"),h),await g(e.join(o,"codeyam-dev-mode"),S);const k=e.join(a,".claude","commands");await m.mkdir(k,{recursive:!0}),await m.copyFile(e.join(n,"codeyam-diagnose.md"),e.join(k,"codeyam-diagnose.md"))}const l=e.join(a,".codeyam","bin");await m.mkdir(l,{recursive:!0});const j=e.join(a,".codeyam","rules");if(await m.mkdir(j,{recursive:!0}),w){try{const c=e.join(l,"editor-step-hook.py");await m.copyFile(e.join(s,"editor-step-hook.py"),c),await m.chmod(c,493)}catch{}try{const c=e.join(s,"seed-adapters"),f=e.join(a,".codeyam","seed-adapters");await g(c,f)}catch{}}try{const c=e.join(l,"memory-hook.sh");await m.copyFile(e.join(s,"codeyam-memory-hook.sh"),c),await m.chmod(c,493)}catch{}try{const c=e.join(l,"rule-reflection-hook.py");await m.copyFile(e.join(s,"rule-reflection-hook.py"),c),await m.chmod(c,493)}catch{}try{const c=e.join(l,"rule-notification-hook.py");await m.copyFile(e.join(s,"rule-notification-hook.py"),c),await m.chmod(c,493)}catch{}try{const c=e.join(l,"prompts");await m.mkdir(c,{recursive:!0});const f=await m.readdir(e.join(s,"prompts"));for(const d of f)await m.copyFile(e.join(s,"prompts",d),e.join(c,d))}catch{}try{await m.copyFile(e.join(s,"rules-instructions.md"),e.join(j,"instructions.md"))}catch{}return{success:!0,skillsPath:e.relative(a,i)}}catch(i){return{success:!1,error:i instanceof Error?i.message:String(i)}}}function X(a,t){const r=(t==null?void 0:t.mode)??"memory";try{const i=e.join(a,".claude"),s=e.join(i,"settings.local.json");y.existsSync(i)||y.mkdirSync(i,{recursive:!0});let o={};if(y.existsSync(s))try{const c=y.readFileSync(s,"utf8");o=JSON.parse(c)}catch{console.warn(`Warning: Could not parse ${s}, will create new file`)}o.permissions||(o.permissions={}),o.permissions.allow||(o.permissions.allow=[]);const n=["Skill(codeyam-memory)","Skill(codeyam-new-rule)","Bash(codeyam)","Bash(codeyam:*)","Read(.codeyam/**)","Edit(.codeyam/**)","Write(.codeyam/**)","Glob(.codeyam/**)"],u=["Skill(codeyam-setup)","Skill(codeyam-sim)","Skill(codeyam-debug)","Skill(codeyam-test)","Skill(codeyam-verify)","Skill(codeyam-dev-mode)","Read(/tmp/**)","Edit(/tmp/**)","Write(/tmp/**)","Glob(/tmp/**)","Bash(npm install:*)","Bash(npm run:*)","Bash(npx:*)","Bash(node:*)","Bash(cp:*)","Bash(mkdir:*)","Bash(chmod:*)","Bash(rm:*)","Bash(curl:*)","Bash(sleep:*)","Bash(echo:*)","Bash(grep:*)","Bash(python3:*)","Bash(cat:*)","Bash(printf:*)","Bash(ls:*)"],p=["Skill(codeyam-editor)","Bash(git:*)","Edit(**)","Write(**)"],w=r==="editor"||(t==null?void 0:t.editorMode)===!0;let l;if(r==="full"?l=[...n,...u]:r==="editor"?l=[...n,...p,...u]:l=n,w&&r!=="editor")for(const c of[...p,...u])l.includes(c)||l.push(c);let j=!1;for(const c of l)o.permissions.allow.includes(c)||(o.permissions.allow.push(c),j=!0);if(w){o.hooks||(o.hooks={});const c='test -f "$CLAUDE_PROJECT_DIR"/.codeyam/bin/editor-step-hook.py && python3 "$CLAUDE_PROJECT_DIR"/.codeyam/bin/editor-step-hook.py || true';for(const f of["PostToolUse","Stop","UserPromptSubmit"]){const d=o.hooks[f]||[];d.some(S=>{var k;return(k=S.hooks)==null?void 0:k.some(C=>{var $;return($=C.command)==null?void 0:$.includes("editor-step-hook")})})||(d.push({hooks:[{type:"command",command:c,timeout:5}]}),o.hooks[f]=d,j=!0)}}return j&&y.writeFileSync(s,JSON.stringify(o,null,2),"utf8"),!0}catch(i){return console.warn(`Warning: Could not configure Claude Code settings: ${i.message}`),!1}}function Z(a){return y.existsSync(a)?y.readFileSync(a,"utf8").split(`
2
2
  `).map(r=>r.trim()).filter(r=>r&&!r.startsWith("#")).map(r=>r.startsWith("/")?r.slice(1):r):[]}function ee(a){const t=[];function r(i){const s=e.join(i,".gitignore");if(y.existsSync(s)){const o=Z(s),n=e.relative(a,i),u=o.map(p=>n?e.join(n,p):p);t.push(...u)}try{const o=y.readdirSync(i,{withFileTypes:!0});for(const n of o)n.isDirectory()&&n.name!=="node_modules"&&n.name!==".git"&&n.name!=="dist"&&n.name!=="build"&&r(e.join(i,n.name))}catch{}}return r(a),t}function te(a){let t=a.replace(/\/$/,"");const r=t.startsWith("**/");r&&(t=t.slice(3));const i=t.startsWith("/");return i&&(t=t.slice(1)),t=t.replace(/[.+^${}()|[\]\\*?]/g,"\\$&"),t=t.replace(/\\\*\\\*/g,".*").replace(/\\\*/g,"[^/]*").replace(/\\\?/g,"."),i&&!r?`^${t}(/.*)?$`:`^(.*/)?${t}(/.*)?$`}function oe(){return["^(.*/)?node_modules/.*$","^(.*/)?dist/.*$","^(.*/)?build/.*$","^(.*/)?\\.next/.*$","^(.*/)?out/.*$","^(.*/)?\\.cache/.*$","^(.*/)?__tests__/.*$","^(.*/)?__mocks__/.*$","^(.*/)?.+\\.test\\.(ts|tsx|js|jsx)$","^(.*/)?.+\\.spec\\.(ts|tsx|js|jsx)$","^(.*/)?test/.*$","^(.*/)?tests/.*$","^(.*/)?__test","^(.*/)?\\.git/.*$","^(.*/)?coverage/.*$","^(.*/)?\\.nyc_output/.*$","^(.*/)?\\.vscode/.*$","^(.*/)?\\.idea/.*$","^(.*/)?\\.DS_Store$"]}function ie(a){const t=oe();try{const i=ee(a).filter(o=>o.trim().length>0).map(o=>te(o)),s=[...t,...i];return Array.from(new Set(s))}catch(r){return console.warn("Failed to load gitignore patterns:",r),t}}const tt={command:"init",describe:"Initialize a project for CodeYam CLI analysis",builder:{force:{type:"boolean",alias:"f",describe:"Force initialization even if .codeyam already exists",default:!1},"keep-server":{type:"boolean",describe:"Skip stopping the running CodeYam server (use when running inside the editor)",default:!1}},handler:async a=>{_("Initializing CodeYam CLI project");let t=I();if(t&&!a.force){b("Project already initialized. Use --force to reinitialize.");return}if(t||(t=process.cwd()),W(t)){v("Cannot initialize CodeYam in your home directory or filesystem root."),v("Please run codeyam init from inside a project directory.");return}M(t);const{running:r}=O();r&&!a["keep-server"]&&(T()?b("CodeYam server stopped"):v("Failed to stop CodeYam server - it may have already stopped"));const i=e.join(t,".codeyam"),s=e.join(i,"config.json"),o=new B;try{o.start("Setting up project scaffolding..."),await m.mkdir(i,{recursive:!0}),await ae(t),o.succeed("Project scaffolding ready");let n=H(t);try{const d=JSON.parse(y.readFileSync(s,"utf8"));d.projectSlug&&!d.projectSlug.startsWith("local-")&&(n=d.projectSlug)}catch{}const u=re(t);let p=[];try{p=U(t)}catch{}if(p.length>0){const d=p.map(h=>`${h.path==="."?"Root":h.path} (${h.framework})`).join(", ");E(`Found ${p.length} web application${p.length>1?"s":""}: ${d}`)}o.start("Configuring project...");const w=A(s),l={projectSlug:n,packageManager:u,webapps:p,environmentVariables:[],createdAt:new Date().toISOString(),...w};await m.writeFile(s,JSON.stringify(l,null,2));const j=G();if(!y.existsSync(j)){const d=q(j);await Y(d)}if(!await R(()=>z())){o.fail("Environment validation failed");return}try{const{project:d}=await N({slug:n,packageManager:u,unapprovedPaths:ie(t),webapps:p});o.succeed("Project configured"),o.start("Installing Claude Code skills...");const h=!!a["keep-server"],S=await Q(t,{mode:h?"editor":"memory",editorMode:h}),{branch:k}=await J(d);l.branchId=k.id,await m.writeFile(s,JSON.stringify(l,null,2)),X(t,{mode:h?"editor":"memory",editorMode:h}),S.success?o.succeed("Claude Code skills installed"):o.warn("Could not install skills");try{a["keep-server"]?await P({projectSlug:n,metadataUpdate:{editorMode:!0,labs:{simulations:!0}}}):await P({projectSlug:n,metadataUpdate:{labs:{simulations:!1}}})}catch{}l.aiMode="interactive"}catch(d){o.fail("Failed to create project"),v(d.message);return}const f=p.length>0?`, ${p.map(d=>d.framework).join(", ")}`:"";console.log(),b(`✨ Initialized ${n} (${u}${f})`),a.autoInit||(console.log(),console.log(x.bold(' Run "codeyam" to start the dashboard')),console.log(' Run "codeyam --help" for all commands'))}catch(n){o.fail("Failed to initialize project"),v(n.message),process.exit(1)}}};function re(a){return y.existsSync(e.join(a,"pnpm-lock.yaml"))?"pnpm":y.existsSync(e.join(a,"yarn.lock"))?"yarn":(y.existsSync(e.join(a,"package-lock.json")),"npm")}const D=[".codeyam/db.sqlite3",".codeyam/db.sqlite3-wal",".codeyam/db.sqlite3-shm",".codeyam/secrets.json",".codeyam/server.json",".codeyam/server-state.json",".codeyam/queue.json",".codeyam/active-scenario.json",".codeyam/editor-step.json",".codeyam/editor-user-prompt.txt",".codeyam/claude-session-id.txt",".codeyam/editor-mode-context.md",".codeyam/dev-mode-context.md",".codeyam/logs/",".codeyam/llm-calls/",".codeyam/captures/",".codeyam/results/",".codeyam/tmp/",".codeyam/rules/",".codeyam/bin/",".codeyam/docs/"];async function ae(a){const t=e.join(a,".gitignore");let r="";try{r=await m.readFile(t,"utf8")}catch{}const i=r.split(`
3
3
  `),s=i.findIndex(n=>n.trim()===".codeyam"||n.trim()==="/.codeyam");if(s!==-1){const n=s>0&&i[s-1].trim().startsWith("# CodeYam local files")?s-1:s;i.splice(n,s-n+1),r=i.join(`
4
4
  `)}if(!D.some(n=>i.some(u=>u.trim()===n))){const n=`