@codeyam/codeyam-cli 0.1.9 → 0.1.10

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 (74) hide show
  1. package/analyzer-template/.build-info.json +7 -7
  2. package/analyzer-template/log.txt +3 -3
  3. package/analyzer-template/packages/database/src/lib/kysely/tables/editorScenariosTable.ts +45 -0
  4. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.d.ts +2 -0
  5. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.d.ts.map +1 -1
  6. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.js +45 -0
  7. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.js.map +1 -1
  8. package/codeyam-cli/src/commands/editor.js +236 -76
  9. package/codeyam-cli/src/commands/editor.js.map +1 -1
  10. package/codeyam-cli/src/utils/__tests__/analyzerFinalization.test.js +29 -0
  11. package/codeyam-cli/src/utils/__tests__/analyzerFinalization.test.js.map +1 -1
  12. package/codeyam-cli/src/utils/__tests__/editorApi.test.js +18 -8
  13. package/codeyam-cli/src/utils/__tests__/editorApi.test.js.map +1 -1
  14. package/codeyam-cli/src/utils/__tests__/editorAudit.test.js +133 -1
  15. package/codeyam-cli/src/utils/__tests__/editorAudit.test.js.map +1 -1
  16. package/codeyam-cli/src/utils/__tests__/editorPreview.test.js +14 -0
  17. package/codeyam-cli/src/utils/__tests__/editorPreview.test.js.map +1 -1
  18. package/codeyam-cli/src/utils/__tests__/editorScenarios.test.js +205 -1
  19. package/codeyam-cli/src/utils/__tests__/editorScenarios.test.js.map +1 -1
  20. package/codeyam-cli/src/utils/__tests__/parseRegisterArg.test.js +30 -2
  21. package/codeyam-cli/src/utils/__tests__/parseRegisterArg.test.js.map +1 -1
  22. package/codeyam-cli/src/utils/__tests__/scenariosManifest.test.js +155 -1
  23. package/codeyam-cli/src/utils/__tests__/scenariosManifest.test.js.map +1 -1
  24. package/codeyam-cli/src/utils/analyzerFinalization.js +5 -1
  25. package/codeyam-cli/src/utils/analyzerFinalization.js.map +1 -1
  26. package/codeyam-cli/src/utils/editorApi.js +11 -5
  27. package/codeyam-cli/src/utils/editorApi.js.map +1 -1
  28. package/codeyam-cli/src/utils/editorAudit.js +34 -0
  29. package/codeyam-cli/src/utils/editorAudit.js.map +1 -1
  30. package/codeyam-cli/src/utils/editorPreview.js +9 -4
  31. package/codeyam-cli/src/utils/editorPreview.js.map +1 -1
  32. package/codeyam-cli/src/utils/editorScenarios.js +64 -9
  33. package/codeyam-cli/src/utils/editorScenarios.js.map +1 -1
  34. package/codeyam-cli/src/utils/parseRegisterArg.js.map +1 -1
  35. package/codeyam-cli/src/utils/progress.js +2 -2
  36. package/codeyam-cli/src/utils/progress.js.map +1 -1
  37. package/codeyam-cli/src/utils/scenariosManifest.js +82 -0
  38. package/codeyam-cli/src/utils/scenariosManifest.js.map +1 -1
  39. package/codeyam-cli/src/webserver/__tests__/idleDetector.test.js +146 -0
  40. package/codeyam-cli/src/webserver/__tests__/idleDetector.test.js.map +1 -0
  41. package/codeyam-cli/src/webserver/build/client/assets/{ScenarioViewer-Bd-hxofb.js → ScenarioViewer-TSD3C211.js} +1 -1
  42. package/codeyam-cli/src/webserver/build/client/assets/{dev.empty-BsDh6TSF.js → dev.empty-Ii3inc0_.js} +1 -1
  43. package/codeyam-cli/src/webserver/build/client/assets/editor-COWCNVyV.js +10 -0
  44. package/codeyam-cli/src/webserver/build/client/assets/editorPreview-CNB06EIa.js +41 -0
  45. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-BsDXNp45.js → entity._sha._-DwCV5__E.js} +1 -1
  46. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha.scenarios._scenarioId.dev-BgAqUtTZ.js → entity._sha.scenarios._scenarioId.dev-CXSi2aeZ.js} +1 -1
  47. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha.scenarios._scenarioId.fullscreen-Bmshgrij.js → entity._sha.scenarios._scenarioId.fullscreen-CHMiAog3.js} +1 -1
  48. package/codeyam-cli/src/webserver/build/client/assets/globals-phvmGvat.css +1 -0
  49. package/codeyam-cli/src/webserver/build/client/assets/{manifest-65850841.js → manifest-6134dc40.js} +1 -1
  50. package/codeyam-cli/src/webserver/build/client/assets/{root-BwX8YgFb.js → root-BWAyuj0r.js} +3 -3
  51. package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-C-_hOl_g.js +1 -0
  52. package/codeyam-cli/src/webserver/build/client/sound-test.html +98 -0
  53. package/codeyam-cli/src/webserver/build/server/assets/{index-DEEQf4pi.js → index-ChX0hPcu.js} +1 -1
  54. package/codeyam-cli/src/webserver/build/server/assets/{init-CkWmyFY2.js → init-kSNsMjj8.js} +2 -2
  55. package/codeyam-cli/src/webserver/build/server/assets/{server-build-BHi-9O8W.js → server-build-Bm2xIhmh.js} +108 -108
  56. package/codeyam-cli/src/webserver/build/server/index.js +1 -1
  57. package/codeyam-cli/src/webserver/build-info.json +5 -5
  58. package/codeyam-cli/src/webserver/idleDetector.js +73 -0
  59. package/codeyam-cli/src/webserver/idleDetector.js.map +1 -0
  60. package/codeyam-cli/src/webserver/public/sound-test.html +98 -0
  61. package/codeyam-cli/src/webserver/server.js +46 -4
  62. package/codeyam-cli/src/webserver/server.js.map +1 -1
  63. package/codeyam-cli/src/webserver/terminalServer.js +34 -25
  64. package/codeyam-cli/src/webserver/terminalServer.js.map +1 -1
  65. package/codeyam-cli/templates/codeyam-editor-claude.md +1 -1
  66. package/codeyam-cli/templates/editor-step-hook.py +3 -2
  67. package/codeyam-cli/templates/skills/codeyam-editor/SKILL.md +10 -9
  68. package/package.json +1 -1
  69. package/packages/database/src/lib/kysely/tables/editorScenariosTable.js +45 -0
  70. package/packages/database/src/lib/kysely/tables/editorScenariosTable.js.map +1 -1
  71. package/codeyam-cli/src/webserver/build/client/assets/editor-PBc_6L9R.js +0 -10
  72. package/codeyam-cli/src/webserver/build/client/assets/editorPreview-4FzHlcNn.js +0 -41
  73. package/codeyam-cli/src/webserver/build/client/assets/globals-B8vTTNy2.css +0 -1
  74. package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-BE43Hjti.js +0 -1
@@ -0,0 +1 @@
1
+ import{r,j as e}from"./chunk-JZWAC4HX-C4pqxYJB.js";function z({currentWidth:d,currentHeight:u,devicePresets:l,customSizes:i,onApply:a,onSave:b,onRemove:x,onClose:s}){const[n,o]=r.useState(String(d)),[c,y]=r.useState(String(u)),[m,h]=r.useState(""),[v,L]=r.useState(!1),w=r.useRef(null),S=r.useRef(null);r.useEffect(()=>{const t=N=>{w.current&&!w.current.contains(N.target)&&s()};return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[s]),r.useEffect(()=>{const t=N=>{N.key==="Escape"&&s()};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[s]),r.useEffect(()=>{var t;(t=S.current)==null||t.select()},[]);const g=parseInt(n,10),f=parseInt(c,10),p=g>0&&f>0,k=p&&(g!==d||f!==u),C=()=>{p&&(a({name:"Custom",width:g,height:f}),s())},E=()=>{const t=m.trim();!t||!p||(b(t,g,f),a({name:t,width:g,height:f}),s())},j=t=>{t.key==="Enter"&&(v&&m.trim()?E():k&&C())};return e.jsxs("div",{ref:w,className:"absolute top-full mt-1 right-0 bg-[#2a2a2a] border border-[#444] rounded-lg shadow-xl z-50 w-64",children:[l&&l.length>0&&e.jsxs("div",{className:"border-b border-[#444]",children:[e.jsx("div",{className:"px-3 py-1.5 text-[10px] uppercase tracking-wider text-gray-500",children:"Presets"}),l.map(t=>e.jsxs("button",{onClick:()=>{a(t),s()},className:`w-full px-3 py-1.5 text-left text-xs transition-colors cursor-pointer ${t.width===d&&t.height===u?"text-white bg-[#444]":"text-gray-300 hover:text-white hover:bg-[#333]"}`,children:[e.jsx("span",{className:"font-medium",children:t.name}),e.jsxs("span",{className:"text-gray-500 ml-1.5",children:[t.width,"×",t.height]})]},t.name))]}),i.length>0&&e.jsxs("div",{className:"border-b border-[#444]",children:[e.jsx("div",{className:"px-3 py-1.5 text-[10px] uppercase tracking-wider text-gray-500",children:"Saved Sizes"}),i.map(t=>e.jsxs("div",{className:"flex items-center group hover:bg-[#333] transition-colors",children:[e.jsxs("button",{onClick:()=>{a(t),s()},className:"flex-1 px-3 py-1.5 text-left text-xs text-gray-300 hover:text-white transition-colors cursor-pointer",children:[e.jsx("span",{className:"font-medium",children:t.name}),e.jsxs("span",{className:"text-gray-500 ml-1.5",children:[t.width,"×",t.height]})]}),e.jsx("button",{onClick:()=>x(t.name),className:"px-2 py-1.5 text-gray-600 hover:text-red-400 opacity-0 group-hover:opacity-100 transition-all cursor-pointer",title:"Remove",children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})})]},t.name))]}),e.jsxs("div",{className:"p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("input",{ref:S,type:"number",value:n,onChange:t=>o(t.target.value),onKeyDown:j,min:"100",max:"7680",className:"w-full px-2 py-1.5 bg-[#1a1a1a] border border-[#555] rounded text-xs text-white text-center focus:outline-none focus:border-[#007a99] [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none",placeholder:"Width"}),e.jsx("span",{className:"text-gray-500 text-xs flex-shrink-0",children:"×"}),e.jsx("input",{type:"number",value:c,onChange:t=>y(t.target.value),onKeyDown:j,min:"100",max:"7680",className:"w-full px-2 py-1.5 bg-[#1a1a1a] border border-[#555] rounded text-xs text-white text-center focus:outline-none focus:border-[#007a99] [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none",placeholder:"Height"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:C,disabled:!p||!k,className:"flex-1 px-2 py-1.5 bg-[#007a99] text-white text-xs font-medium rounded hover:bg-[#006080] transition-colors cursor-pointer disabled:bg-[#333] disabled:text-gray-600 disabled:cursor-not-allowed",children:"Apply"}),v?e.jsxs("div",{className:"flex gap-1",children:[e.jsx("input",{type:"text",value:m,onChange:t=>h(t.target.value),onKeyDown:j,placeholder:"Name",className:"w-20 px-2 py-1.5 bg-[#1a1a1a] border border-[#555] rounded text-xs text-white focus:outline-none focus:border-[#007a99]",autoFocus:!0}),e.jsx("button",{onClick:E,disabled:!m.trim()||!p,className:"px-2 py-1.5 bg-[#007a99] text-white text-xs rounded hover:bg-[#006080] transition-colors cursor-pointer disabled:bg-[#333] disabled:text-gray-600 disabled:cursor-not-allowed",children:"OK"})]}):e.jsx("button",{onClick:()=>L(!0),disabled:!p,className:"px-2 py-1.5 bg-[#333] text-gray-300 text-xs rounded hover:bg-[#444] transition-colors cursor-pointer disabled:text-gray-600 disabled:cursor-not-allowed",title:"Save as preset",children:"Save"})]})]})]})}function D({width:d,height:u,onSave:l,onCancel:i}){const[a,b]=r.useState(""),[x,s]=r.useState(""),n=()=>{const o=a.trim();if(!o){s("Please enter a name");return}l(o)};return e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center p-4 z-50",children:e.jsxs("div",{className:"bg-white rounded-lg max-w-md w-full p-6 shadow-xl",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:"Save Custom Size"}),e.jsx("button",{onClick:i,className:"text-gray-400 hover:text-gray-600 transition-colors cursor-pointer","aria-label":"Close",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsxs("div",{className:"mb-6 p-4 bg-gray-50 rounded-lg border border-gray-200",children:[e.jsx("div",{className:"text-sm text-gray-500 mb-1",children:"Dimensions"}),e.jsxs("div",{className:"text-lg font-medium text-gray-900",children:[d,"px × ",u,"px"]})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("label",{htmlFor:"custom-size-name",className:"block text-sm font-medium text-gray-700 mb-2",children:"Name"}),e.jsx("input",{id:"custom-size-name",type:"text",value:a,onChange:o=>{b(o.target.value),s("")},onKeyDown:o=>{o.key==="Enter"&&a.trim()&&n(),o.key==="Escape"&&i()},placeholder:"e.g., iPhone 15 Pro",className:`w-full px-3 py-2 border rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-[#005c75] focus:border-[#005c75] ${x?"border-red-300":"border-gray-300"}`,autoFocus:!0}),x&&e.jsx("p",{className:"mt-1 text-sm text-red-600",children:x})]}),e.jsxs("div",{className:"flex gap-3 justify-end",children:[e.jsx("button",{onClick:i,className:"px-4 py-2 bg-gray-100 text-gray-700 text-sm font-medium rounded-md hover:bg-gray-200 transition-colors cursor-pointer",children:"Cancel"}),e.jsx("button",{onClick:n,disabled:!a.trim(),className:"px-4 py-2 bg-[#005c75] text-white text-sm font-medium rounded-md hover:bg-[#004a5c] transition-colors cursor-pointer disabled:bg-gray-300 disabled:cursor-not-allowed",children:"Save"})]})]})})}function I(d){const[u,l]=r.useState([]),i=d?`codeyam-custom-sizes-${d}`:null;r.useEffect(()=>{if(!i||typeof window>"u"){l([]);return}try{const s=localStorage.getItem(i);if(s){const n=JSON.parse(s);Array.isArray(n)&&l(n)}}catch(s){console.error("[useCustomSizes] Failed to load custom sizes:",s),l([])}},[i]);const a=r.useCallback(s=>{if(!(!i||typeof window>"u"))try{localStorage.setItem(i,JSON.stringify(s))}catch(n){console.error("[useCustomSizes] Failed to save custom sizes:",n)}},[i]),b=r.useCallback((s,n,o)=>{l(c=>{const y=c.findIndex(v=>v.name===s),m={name:s,width:n,height:o};let h;return y>=0?(h=[...c],h[y]=m):h=[...c,m],a(h),h})},[a]),x=r.useCallback(s=>{l(n=>{const o=n.filter(c=>c.name!==s);return a(o),o})},[a]);return{customSizes:u,addCustomSize:b,removeCustomSize:x}}export{z as C,D as S,I as u};
@@ -0,0 +1,98 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head><title>Notification Sound Picker</title></head>
4
+ <body style="font-family: system-ui; max-width: 600px; margin: 40px auto; background: #1e1e1e; color: #e0e0e0;">
5
+ <h2>Pick a notification sound</h2>
6
+ <p style="color: #999;">Click each button to preview. Note which one you like.</p>
7
+ <div id="buttons" style="display: flex; flex-direction: column; gap: 12px;"></div>
8
+ <script>
9
+ const sounds = {
10
+ 'Gentle chime (C5 → E5)': (ac) => {
11
+ const osc = ac.createOscillator(); const g = ac.createGain();
12
+ osc.connect(g); g.connect(ac.destination); osc.type = 'sine';
13
+ osc.frequency.setValueAtTime(523, ac.currentTime);
14
+ osc.frequency.setValueAtTime(659, ac.currentTime + 0.15);
15
+ g.gain.setValueAtTime(0.3, ac.currentTime);
16
+ g.gain.exponentialRampToValueAtTime(0.01, ac.currentTime + 0.4);
17
+ osc.start(); osc.stop(ac.currentTime + 0.4);
18
+ },
19
+ 'Soft double tap (G4 → G4)': (ac) => {
20
+ [0, 0.12].forEach(offset => {
21
+ const osc = ac.createOscillator(); const g = ac.createGain();
22
+ osc.connect(g); g.connect(ac.destination); osc.type = 'sine';
23
+ osc.frequency.value = 392;
24
+ g.gain.setValueAtTime(0.25, ac.currentTime + offset);
25
+ g.gain.exponentialRampToValueAtTime(0.01, ac.currentTime + offset + 0.1);
26
+ osc.start(ac.currentTime + offset); osc.stop(ac.currentTime + offset + 0.1);
27
+ });
28
+ },
29
+ 'Warm ding (E4)': (ac) => {
30
+ const osc = ac.createOscillator(); const g = ac.createGain();
31
+ osc.connect(g); g.connect(ac.destination); osc.type = 'sine';
32
+ osc.frequency.value = 330;
33
+ g.gain.setValueAtTime(0.35, ac.currentTime);
34
+ g.gain.exponentialRampToValueAtTime(0.01, ac.currentTime + 0.6);
35
+ osc.start(); osc.stop(ac.currentTime + 0.6);
36
+ },
37
+ 'Soft rising (A3 → E4 → A4)': (ac) => {
38
+ const osc = ac.createOscillator(); const g = ac.createGain();
39
+ osc.connect(g); g.connect(ac.destination); osc.type = 'sine';
40
+ osc.frequency.setValueAtTime(220, ac.currentTime);
41
+ osc.frequency.setValueAtTime(330, ac.currentTime + 0.12);
42
+ osc.frequency.setValueAtTime(440, ac.currentTime + 0.24);
43
+ g.gain.setValueAtTime(0.25, ac.currentTime);
44
+ g.gain.exponentialRampToValueAtTime(0.01, ac.currentTime + 0.5);
45
+ osc.start(); osc.stop(ac.currentTime + 0.5);
46
+ },
47
+ 'Mellow two-tone (D4 → A4)': (ac) => {
48
+ const osc = ac.createOscillator(); const g = ac.createGain();
49
+ osc.connect(g); g.connect(ac.destination); osc.type = 'sine';
50
+ osc.frequency.setValueAtTime(294, ac.currentTime);
51
+ osc.frequency.setValueAtTime(440, ac.currentTime + 0.18);
52
+ g.gain.setValueAtTime(0.3, ac.currentTime);
53
+ g.gain.exponentialRampToValueAtTime(0.01, ac.currentTime + 0.5);
54
+ osc.start(); osc.stop(ac.currentTime + 0.5);
55
+ },
56
+ 'Triangle bell (C5)': (ac) => {
57
+ const osc = ac.createOscillator(); const g = ac.createGain();
58
+ osc.connect(g); g.connect(ac.destination); osc.type = 'triangle';
59
+ osc.frequency.value = 523;
60
+ g.gain.setValueAtTime(0.4, ac.currentTime);
61
+ g.gain.exponentialRampToValueAtTime(0.01, ac.currentTime + 0.8);
62
+ osc.start(); osc.stop(ac.currentTime + 0.8);
63
+ },
64
+ 'Slack-style knock (wood block)': (ac) => {
65
+ [0, 0.08].forEach(offset => {
66
+ const osc = ac.createOscillator(); const g = ac.createGain();
67
+ osc.connect(g); g.connect(ac.destination); osc.type = 'square';
68
+ osc.frequency.setValueAtTime(800, ac.currentTime + offset);
69
+ osc.frequency.exponentialRampToValueAtTime(200, ac.currentTime + offset + 0.05);
70
+ g.gain.setValueAtTime(0.15, ac.currentTime + offset);
71
+ g.gain.exponentialRampToValueAtTime(0.01, ac.currentTime + offset + 0.06);
72
+ osc.start(ac.currentTime + offset); osc.stop(ac.currentTime + offset + 0.06);
73
+ });
74
+ },
75
+ 'Marimba hit (E4 + overtone)': (ac) => {
76
+ [330, 660].forEach((freq, i) => {
77
+ const osc = ac.createOscillator(); const g = ac.createGain();
78
+ osc.connect(g); g.connect(ac.destination); osc.type = 'sine';
79
+ osc.frequency.value = freq;
80
+ g.gain.setValueAtTime(i === 0 ? 0.3 : 0.1, ac.currentTime);
81
+ g.gain.exponentialRampToValueAtTime(0.01, ac.currentTime + 0.5);
82
+ osc.start(); osc.stop(ac.currentTime + 0.5);
83
+ });
84
+ },
85
+ };
86
+ const div = document.getElementById('buttons');
87
+ Object.entries(sounds).forEach(([name, fn]) => {
88
+ const btn = document.createElement('button');
89
+ btn.textContent = name;
90
+ btn.style.cssText = 'padding: 12px 20px; font-size: 15px; cursor: pointer; background: #333; color: #e0e0e0; border: 1px solid #555; border-radius: 6px; text-align: left;';
91
+ btn.onmouseenter = () => btn.style.background = '#444';
92
+ btn.onmouseleave = () => btn.style.background = '#333';
93
+ btn.onclick = () => fn(new AudioContext());
94
+ div.appendChild(btn);
95
+ });
96
+ </script>
97
+ </body>
98
+ </html>
@@ -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-BHi-9O8W.js";import"typescript";import"kysely";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/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-Bm2xIhmh.js";import"typescript";import"kysely";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/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,5 +1,5 @@
1
- import*as l from"fs/promises";import*as h from"fs";import*as t from"path";import f from"chalk";import{execSync as M}from"child_process";import D from"cli-spinners";import{ab as T,ac as B,ad as E,ae as _,af as R,ag as W,ah as q,ai as Y,F as O,I as U,aj as G,ak as z,al as A,x as P}from"./server-build-BHi-9O8W.js";import"fetch-retry";import"typescript";import"kysely";import{fileURLToPath as N}from"url";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/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 J(i){try{const s=M("git config --get remote.origin.url",{cwd:i,encoding:"utf8"}).trim().match(/github\.com[:/]([^/]+)\/([^/]+?)(?:\.git)?$/);if(s)return`${s[1]}-${s[2]}`}catch{}return t.basename(i)}class k{constructor(e=!1){this.spinnerIndex=0,this.currentMessage="",this.isSpinning=!1,this.spinnerFrames=D.dots.frames,this.spinnerInterval=D.dots.interval,this.isTTY=process.stdout.isTTY,this.quiet=e}start(e){if(this.currentMessage=e,this.isSpinning=!0,this.spinnerIndex=0,k.activeInstance=this,!this.quiet){if(!this.isTTY){console.log(f.cyan("⠿")+" "+this.currentMessage);return}process.stdout.write("\r"+f.cyan(this.spinnerFrames[this.spinnerIndex])+" "+this.currentMessage),this.spinnerIndex=(this.spinnerIndex+1)%this.spinnerFrames.length,this.spinner=setInterval(()=>{process.stdout.write("\r"+f.cyan(this.spinnerFrames[this.spinnerIndex])+" "+this.currentMessage),this.spinnerIndex=(this.spinnerIndex+1)%this.spinnerFrames.length},this.spinnerInterval),this.spinner.unref()}}static pause(){var e;(e=k.activeInstance)==null||e.stop()}static resume(){const e=k.activeInstance;e&&e.currentMessage&&e.start(e.currentMessage)}update(e){this.currentMessage=e,!this.quiet&&(this.isTTY||console.log(f.cyan("⠿")+" "+this.currentMessage))}succeed(e){this.stop();const s=e||this.currentMessage;this.quiet||(this.isTTY||s!==this.currentMessage)&&console.log(f.green("✓")+" "+s)}fail(e){this.stop();const s=e||this.currentMessage;this.quiet||console.log(f.red("✗")+" "+s)}warn(e){this.stop(),!this.quiet&&console.log(f.yellow("⚠")+" "+e)}info(e){this.stop(),!this.quiet&&console.log(f.blue("ℹ")+" "+e)}stop(){this.spinner&&(clearInterval(this.spinner),this.spinner=void 0),this.isSpinning&&this.isTTY&&(process.stdout.write("\r\x1B[K"),this.isSpinning=!1),this===k.activeInstance&&(k.activeInstance=void 0)}}async function L(i){k.pause();try{return await i()}finally{k.resume()}}const x=i=>console.log(f.green("✓")+" "+i),$=i=>console.log(f.red("✗")+" "+i),H=i=>console.log(f.blue("ℹ")+" "+i),K=i=>{console.log(),console.log(f.cyan.bold("🚀 "+i)),console.log()},V=N(import.meta.url),Q=t.dirname(V);async function w(i,e){await l.mkdir(e,{recursive:!0});const s=await l.readdir(i,{withFileTypes:!0});for(const n of s){const a=t.join(i,n.name),o=t.join(e,n.name);n.isDirectory()?await w(a,o):(await l.copyFile(a,o),(n.name.endsWith(".sh")||n.name.endsWith(".mjs"))&&await l.chmod(o,493))}}async function X(i,e){const s=(e==null?void 0:e.mode)??"memory";try{const n=t.join(i,".claude","skills"),a=t.join(Q,"../../templates"),o=t.join(a,"skills"),r=t.join(a,"commands"),u=t.join(n,"codeyam-memory"),p=t.join(n,"codeyam-new-rule");await w(t.join(o,"codeyam-memory"),u),await w(t.join(o,"codeyam-new-rule"),p);const S=s==="editor"||(e==null?void 0:e.editorMode)===!0;if(S){const c=t.join(n,"codeyam-editor");await w(t.join(o,"codeyam-editor"),c);const y=t.join(i,"CLAUDE.md");try{await l.access(y)}catch{await l.copyFile(t.join(a,"codeyam-editor-claude.md"),y)}}if(s==="full"){const c=t.join(n,"codeyam-setup"),y=t.join(n,"codeyam-sim"),m=t.join(n,"codeyam-test"),g=t.join(n,"codeyam-verify"),b=t.join(n,"codeyam-dev-mode");await w(t.join(o,"codeyam-setup"),c),await w(t.join(o,"codeyam-sim"),y),await w(t.join(o,"codeyam-test"),m),await w(t.join(o,"codeyam-verify"),g),await w(t.join(o,"codeyam-dev-mode"),b);const v=t.join(i,".claude","commands");await l.mkdir(v,{recursive:!0}),await l.copyFile(t.join(r,"codeyam-diagnose.md"),t.join(v,"codeyam-diagnose.md"))}const d=t.join(i,".codeyam","bin");await l.mkdir(d,{recursive:!0});const j=t.join(i,".codeyam","rules");if(await l.mkdir(j,{recursive:!0}),S)try{const c=t.join(d,"editor-step-hook.py");await l.copyFile(t.join(a,"editor-step-hook.py"),c),await l.chmod(c,493)}catch{}try{const c=t.join(d,"memory-hook.sh");await l.copyFile(t.join(a,"codeyam-memory-hook.sh"),c),await l.chmod(c,493)}catch{}try{const c=t.join(d,"rule-reflection-hook.py");await l.copyFile(t.join(a,"rule-reflection-hook.py"),c),await l.chmod(c,493)}catch{}try{const c=t.join(d,"rule-notification-hook.py");await l.copyFile(t.join(a,"rule-notification-hook.py"),c),await l.chmod(c,493)}catch{}try{const c=t.join(d,"prompts");await l.mkdir(c,{recursive:!0});const y=await l.readdir(t.join(a,"prompts"));for(const m of y)await l.copyFile(t.join(a,"prompts",m),t.join(c,m))}catch{}try{await l.copyFile(t.join(a,"rules-instructions.md"),t.join(j,"instructions.md"))}catch{}return{success:!0,skillsPath:t.relative(i,n)}}catch(n){return{success:!1,error:n instanceof Error?n.message:String(n)}}}function Z(i,e){const s=(e==null?void 0:e.mode)??"memory";try{const n=t.join(i,".claude"),a=t.join(n,"settings.local.json");h.existsSync(n)||h.mkdirSync(n,{recursive:!0});let o={};if(h.existsSync(a))try{const c=h.readFileSync(a,"utf8");o=JSON.parse(c)}catch{console.warn(`Warning: Could not parse ${a}, will create new file`)}o.permissions||(o.permissions={}),o.permissions.allow||(o.permissions.allow=[]);const r=["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:*)"],p=["Skill(codeyam-editor)","Bash(git:*)","Edit(**)","Write(**)"],S=s==="editor"||(e==null?void 0:e.editorMode)===!0;let d;if(s==="full"?d=[...r,...u]:s==="editor"?d=[...r,...p,...u]:d=r,S&&s!=="editor")for(const c of[...p,...u])d.includes(c)||d.push(c);let j=!1;for(const c of d)o.permissions.allow.includes(c)||(o.permissions.allow.push(c),j=!0);if(S){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 y of["PostToolUse","Stop","UserPromptSubmit"]){const m=o.hooks[y]||[];m.some(b=>{var v;return(v=b.hooks)==null?void 0:v.some(F=>{var C;return(C=F.command)==null?void 0:C.includes("editor-step-hook")})})||(m.push({hooks:[{type:"command",command:c,timeout:5}]}),o.hooks[y]=m,j=!0)}}return j&&h.writeFileSync(a,JSON.stringify(o,null,2),"utf8"),!0}catch(n){return console.warn(`Warning: Could not configure Claude Code settings: ${n.message}`),!1}}function ee(i){return h.existsSync(i)?h.readFileSync(i,"utf8").split(`
2
- `).map(s=>s.trim()).filter(s=>s&&!s.startsWith("#")).map(s=>s.startsWith("/")?s.slice(1):s):[]}function te(i){const e=[];function s(n){const a=t.join(n,".gitignore");if(h.existsSync(a)){const o=ee(a),r=t.relative(i,n),u=o.map(p=>r?t.join(r,p):p);e.push(...u)}try{const o=h.readdirSync(n,{withFileTypes:!0});for(const r of o)r.isDirectory()&&r.name!=="node_modules"&&r.name!==".git"&&r.name!=="dist"&&r.name!=="build"&&s(t.join(n,r.name))}catch{}}return s(i),e}function ie(i){let e=i.replace(/\/$/,"");const s=e.startsWith("**/");s&&(e=e.slice(3));const n=e.startsWith("/");return n&&(e=e.slice(1)),e=e.replace(/[.+^${}()|[\]\\*?]/g,"\\$&"),e=e.replace(/\\\*\\\*/g,".*").replace(/\\\*/g,"[^/]*").replace(/\\\?/g,"."),n&&!s?`^${e}(/.*)?$`:`^(.*/)?${e}(/.*)?$`}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 se(i){const e=oe();try{const n=te(i).filter(o=>o.trim().length>0).map(o=>ie(o)),a=[...e,...n];return Array.from(new Set(a))}catch(s){return console.warn("Failed to load gitignore patterns:",s),e}}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 i=>{K("Initializing CodeYam CLI project");let e=T();if(e&&!i.force){x("Project already initialized. Use --force to reinitialize.");return}if(e||(e=process.cwd()),B(e)){$("Cannot initialize CodeYam in your home directory or filesystem root."),$("Please run codeyam init from inside a project directory.");return}E(e);const{running:s}=_();s&&!i["keep-server"]&&(R()?x("CodeYam server stopped"):$("Failed to stop CodeYam server - it may have already stopped"));const n=t.join(e,".codeyam"),a=t.join(n,"config.json"),o=new k;try{o.start("Setting up project scaffolding..."),await l.mkdir(n,{recursive:!0}),await re(e),o.succeed("Project scaffolding ready");let r=J(e);try{const m=JSON.parse(h.readFileSync(a,"utf8"));m.projectSlug&&!m.projectSlug.startsWith("local-")&&(r=m.projectSlug)}catch{}const u=ne(e);let p=[];try{p=W(e)}catch{}if(p.length>0){const m=p.map(g=>`${g.path==="."?"Root":g.path} (${g.framework})`).join(", ");H(`Found ${p.length} web application${p.length>1?"s":""}: ${m}`)}o.start("Configuring project...");const S=q(a),d={projectSlug:r,packageManager:u,webapps:p,environmentVariables:[],createdAt:new Date().toISOString(),...S};await l.writeFile(a,JSON.stringify(d,null,2));const j=Y();if(!h.existsSync(j)){const m=O(j);await U(m)}if(!await L(()=>G())){o.fail("Environment validation failed");return}try{const{project:m}=await z({slug:r,packageManager:u,unapprovedPaths:se(e),webapps:p});o.succeed("Project configured"),o.start("Installing Claude Code skills...");const g=!!i["keep-server"],b=await X(e,{mode:g?"editor":"memory",editorMode:g}),{branch:v}=await A(m);d.branchId=v.id,await l.writeFile(a,JSON.stringify(d,null,2)),Z(e,{mode:g?"editor":"memory",editorMode:g}),b.success?o.succeed("Claude Code skills installed"):o.warn("Could not install skills");try{i["keep-server"]?await P({projectSlug:r,metadataUpdate:{editorMode:!0,labs:{simulations:!0}}}):await P({projectSlug:r,metadataUpdate:{labs:{simulations:!1}}})}catch{}d.aiMode="interactive"}catch(m){o.fail("Failed to create project"),$(m.message);return}const y=p.length>0?`, ${p.map(m=>m.framework).join(", ")}`:"";console.log(),x(`✨ Initialized ${r} (${u}${y})`),i.autoInit||(console.log(),console.log(f.bold(' Run "codeyam" to start the dashboard')),console.log(' Run "codeyam --help" for all commands'))}catch(r){o.fail("Failed to initialize project"),$(r.message),process.exit(1)}}};function ne(i){return h.existsSync(t.join(i,"pnpm-lock.yaml"))?"pnpm":h.existsSync(t.join(i,"yarn.lock"))?"yarn":(h.existsSync(t.join(i,"package-lock.json")),"npm")}const I=[".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/editor-mode-context.md",".codeyam/dev-mode-context.md",".codeyam/logs/",".codeyam/llm-calls/",".codeyam/captures/",".codeyam/results/",".codeyam/tmp/",".codeyam/rules/",".codeyam/bin/"];async function re(i){const e=t.join(i,".gitignore");let s="";try{s=await l.readFile(e,"utf8")}catch{}const n=s.split(`
1
+ import*as l from"fs/promises";import*as h from"fs";import*as t from"path";import f from"chalk";import{execSync as M}from"child_process";import D from"cli-spinners";import{ab as B,ac as T,ad as E,ae as _,af as R,ag as W,ah as q,ai as Y,F as O,I as U,aj as G,ak as z,al as A,x as P}from"./server-build-Bm2xIhmh.js";import"fetch-retry";import"typescript";import"kysely";import{fileURLToPath as N}from"url";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/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 J(i){try{const s=M("git config --get remote.origin.url",{cwd:i,encoding:"utf8"}).trim().match(/github\.com[:/]([^/]+)\/([^/]+?)(?:\.git)?$/);if(s)return`${s[1]}-${s[2]}`}catch{}return t.basename(i)}class k{constructor(e=!1){this.spinnerIndex=0,this.currentMessage="",this.isSpinning=!1,this.spinnerFrames=D.dots.frames,this.spinnerInterval=D.dots.interval,this.isTTY=process.stdout.isTTY,this.quiet=e}start(e){if(this.currentMessage=e,this.isSpinning=!0,this.spinnerIndex=0,k.activeInstance=this,!this.quiet){if(!this.isTTY){console.log(f.cyan("⠿")+" "+this.currentMessage);return}process.stdout.write("\r\x1B[K"+f.cyan(this.spinnerFrames[this.spinnerIndex])+" "+this.currentMessage),this.spinnerIndex=(this.spinnerIndex+1)%this.spinnerFrames.length,this.spinner=setInterval(()=>{process.stdout.write("\r\x1B[K"+f.cyan(this.spinnerFrames[this.spinnerIndex])+" "+this.currentMessage),this.spinnerIndex=(this.spinnerIndex+1)%this.spinnerFrames.length},this.spinnerInterval),this.spinner.unref()}}static pause(){var e;(e=k.activeInstance)==null||e.stop()}static resume(){const e=k.activeInstance;e&&e.currentMessage&&e.start(e.currentMessage)}update(e){this.currentMessage=e,!this.quiet&&(this.isTTY||console.log(f.cyan("⠿")+" "+this.currentMessage))}succeed(e){this.stop();const s=e||this.currentMessage;this.quiet||(this.isTTY||s!==this.currentMessage)&&console.log(f.green("✓")+" "+s)}fail(e){this.stop();const s=e||this.currentMessage;this.quiet||console.log(f.red("✗")+" "+s)}warn(e){this.stop(),!this.quiet&&console.log(f.yellow("⚠")+" "+e)}info(e){this.stop(),!this.quiet&&console.log(f.blue("ℹ")+" "+e)}stop(){this.spinner&&(clearInterval(this.spinner),this.spinner=void 0),this.isSpinning&&this.isTTY&&(process.stdout.write("\r\x1B[K"),this.isSpinning=!1),this===k.activeInstance&&(k.activeInstance=void 0)}}async function L(i){k.pause();try{return await i()}finally{k.resume()}}const x=i=>console.log(f.green("✓")+" "+i),$=i=>console.log(f.red("✗")+" "+i),H=i=>console.log(f.blue("ℹ")+" "+i),K=i=>{console.log(),console.log(f.cyan.bold("🚀 "+i)),console.log()},V=N(import.meta.url),Q=t.dirname(V);async function w(i,e){await l.mkdir(e,{recursive:!0});const s=await l.readdir(i,{withFileTypes:!0});for(const n of s){const a=t.join(i,n.name),o=t.join(e,n.name);n.isDirectory()?await w(a,o):(await l.copyFile(a,o),(n.name.endsWith(".sh")||n.name.endsWith(".mjs"))&&await l.chmod(o,493))}}async function X(i,e){const s=(e==null?void 0:e.mode)??"memory";try{const n=t.join(i,".claude","skills"),a=t.join(Q,"../../templates"),o=t.join(a,"skills"),r=t.join(a,"commands"),u=t.join(n,"codeyam-memory"),p=t.join(n,"codeyam-new-rule");await w(t.join(o,"codeyam-memory"),u),await w(t.join(o,"codeyam-new-rule"),p);const S=s==="editor"||(e==null?void 0:e.editorMode)===!0;if(S){const c=t.join(n,"codeyam-editor");await w(t.join(o,"codeyam-editor"),c);const y=t.join(i,"CLAUDE.md");try{await l.access(y)}catch{await l.copyFile(t.join(a,"codeyam-editor-claude.md"),y)}}if(s==="full"){const c=t.join(n,"codeyam-setup"),y=t.join(n,"codeyam-sim"),m=t.join(n,"codeyam-test"),g=t.join(n,"codeyam-verify"),b=t.join(n,"codeyam-dev-mode");await w(t.join(o,"codeyam-setup"),c),await w(t.join(o,"codeyam-sim"),y),await w(t.join(o,"codeyam-test"),m),await w(t.join(o,"codeyam-verify"),g),await w(t.join(o,"codeyam-dev-mode"),b);const v=t.join(i,".claude","commands");await l.mkdir(v,{recursive:!0}),await l.copyFile(t.join(r,"codeyam-diagnose.md"),t.join(v,"codeyam-diagnose.md"))}const d=t.join(i,".codeyam","bin");await l.mkdir(d,{recursive:!0});const j=t.join(i,".codeyam","rules");if(await l.mkdir(j,{recursive:!0}),S)try{const c=t.join(d,"editor-step-hook.py");await l.copyFile(t.join(a,"editor-step-hook.py"),c),await l.chmod(c,493)}catch{}try{const c=t.join(d,"memory-hook.sh");await l.copyFile(t.join(a,"codeyam-memory-hook.sh"),c),await l.chmod(c,493)}catch{}try{const c=t.join(d,"rule-reflection-hook.py");await l.copyFile(t.join(a,"rule-reflection-hook.py"),c),await l.chmod(c,493)}catch{}try{const c=t.join(d,"rule-notification-hook.py");await l.copyFile(t.join(a,"rule-notification-hook.py"),c),await l.chmod(c,493)}catch{}try{const c=t.join(d,"prompts");await l.mkdir(c,{recursive:!0});const y=await l.readdir(t.join(a,"prompts"));for(const m of y)await l.copyFile(t.join(a,"prompts",m),t.join(c,m))}catch{}try{await l.copyFile(t.join(a,"rules-instructions.md"),t.join(j,"instructions.md"))}catch{}return{success:!0,skillsPath:t.relative(i,n)}}catch(n){return{success:!1,error:n instanceof Error?n.message:String(n)}}}function Z(i,e){const s=(e==null?void 0:e.mode)??"memory";try{const n=t.join(i,".claude"),a=t.join(n,"settings.local.json");h.existsSync(n)||h.mkdirSync(n,{recursive:!0});let o={};if(h.existsSync(a))try{const c=h.readFileSync(a,"utf8");o=JSON.parse(c)}catch{console.warn(`Warning: Could not parse ${a}, will create new file`)}o.permissions||(o.permissions={}),o.permissions.allow||(o.permissions.allow=[]);const r=["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:*)"],p=["Skill(codeyam-editor)","Bash(git:*)","Edit(**)","Write(**)"],S=s==="editor"||(e==null?void 0:e.editorMode)===!0;let d;if(s==="full"?d=[...r,...u]:s==="editor"?d=[...r,...p,...u]:d=r,S&&s!=="editor")for(const c of[...p,...u])d.includes(c)||d.push(c);let j=!1;for(const c of d)o.permissions.allow.includes(c)||(o.permissions.allow.push(c),j=!0);if(S){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 y of["PostToolUse","Stop","UserPromptSubmit"]){const m=o.hooks[y]||[];m.some(b=>{var v;return(v=b.hooks)==null?void 0:v.some(F=>{var C;return(C=F.command)==null?void 0:C.includes("editor-step-hook")})})||(m.push({hooks:[{type:"command",command:c,timeout:5}]}),o.hooks[y]=m,j=!0)}}return j&&h.writeFileSync(a,JSON.stringify(o,null,2),"utf8"),!0}catch(n){return console.warn(`Warning: Could not configure Claude Code settings: ${n.message}`),!1}}function ee(i){return h.existsSync(i)?h.readFileSync(i,"utf8").split(`
2
+ `).map(s=>s.trim()).filter(s=>s&&!s.startsWith("#")).map(s=>s.startsWith("/")?s.slice(1):s):[]}function te(i){const e=[];function s(n){const a=t.join(n,".gitignore");if(h.existsSync(a)){const o=ee(a),r=t.relative(i,n),u=o.map(p=>r?t.join(r,p):p);e.push(...u)}try{const o=h.readdirSync(n,{withFileTypes:!0});for(const r of o)r.isDirectory()&&r.name!=="node_modules"&&r.name!==".git"&&r.name!=="dist"&&r.name!=="build"&&s(t.join(n,r.name))}catch{}}return s(i),e}function ie(i){let e=i.replace(/\/$/,"");const s=e.startsWith("**/");s&&(e=e.slice(3));const n=e.startsWith("/");return n&&(e=e.slice(1)),e=e.replace(/[.+^${}()|[\]\\*?]/g,"\\$&"),e=e.replace(/\\\*\\\*/g,".*").replace(/\\\*/g,"[^/]*").replace(/\\\?/g,"."),n&&!s?`^${e}(/.*)?$`:`^(.*/)?${e}(/.*)?$`}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 se(i){const e=oe();try{const n=te(i).filter(o=>o.trim().length>0).map(o=>ie(o)),a=[...e,...n];return Array.from(new Set(a))}catch(s){return console.warn("Failed to load gitignore patterns:",s),e}}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 i=>{K("Initializing CodeYam CLI project");let e=B();if(e&&!i.force){x("Project already initialized. Use --force to reinitialize.");return}if(e||(e=process.cwd()),T(e)){$("Cannot initialize CodeYam in your home directory or filesystem root."),$("Please run codeyam init from inside a project directory.");return}E(e);const{running:s}=_();s&&!i["keep-server"]&&(R()?x("CodeYam server stopped"):$("Failed to stop CodeYam server - it may have already stopped"));const n=t.join(e,".codeyam"),a=t.join(n,"config.json"),o=new k;try{o.start("Setting up project scaffolding..."),await l.mkdir(n,{recursive:!0}),await re(e),o.succeed("Project scaffolding ready");let r=J(e);try{const m=JSON.parse(h.readFileSync(a,"utf8"));m.projectSlug&&!m.projectSlug.startsWith("local-")&&(r=m.projectSlug)}catch{}const u=ne(e);let p=[];try{p=W(e)}catch{}if(p.length>0){const m=p.map(g=>`${g.path==="."?"Root":g.path} (${g.framework})`).join(", ");H(`Found ${p.length} web application${p.length>1?"s":""}: ${m}`)}o.start("Configuring project...");const S=q(a),d={projectSlug:r,packageManager:u,webapps:p,environmentVariables:[],createdAt:new Date().toISOString(),...S};await l.writeFile(a,JSON.stringify(d,null,2));const j=Y();if(!h.existsSync(j)){const m=O(j);await U(m)}if(!await L(()=>G())){o.fail("Environment validation failed");return}try{const{project:m}=await z({slug:r,packageManager:u,unapprovedPaths:se(e),webapps:p});o.succeed("Project configured"),o.start("Installing Claude Code skills...");const g=!!i["keep-server"],b=await X(e,{mode:g?"editor":"memory",editorMode:g}),{branch:v}=await A(m);d.branchId=v.id,await l.writeFile(a,JSON.stringify(d,null,2)),Z(e,{mode:g?"editor":"memory",editorMode:g}),b.success?o.succeed("Claude Code skills installed"):o.warn("Could not install skills");try{i["keep-server"]?await P({projectSlug:r,metadataUpdate:{editorMode:!0,labs:{simulations:!0}}}):await P({projectSlug:r,metadataUpdate:{labs:{simulations:!1}}})}catch{}d.aiMode="interactive"}catch(m){o.fail("Failed to create project"),$(m.message);return}const y=p.length>0?`, ${p.map(m=>m.framework).join(", ")}`:"";console.log(),x(`✨ Initialized ${r} (${u}${y})`),i.autoInit||(console.log(),console.log(f.bold(' Run "codeyam" to start the dashboard')),console.log(' Run "codeyam --help" for all commands'))}catch(r){o.fail("Failed to initialize project"),$(r.message),process.exit(1)}}};function ne(i){return h.existsSync(t.join(i,"pnpm-lock.yaml"))?"pnpm":h.existsSync(t.join(i,"yarn.lock"))?"yarn":(h.existsSync(t.join(i,"package-lock.json")),"npm")}const I=[".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/editor-mode-context.md",".codeyam/dev-mode-context.md",".codeyam/logs/",".codeyam/llm-calls/",".codeyam/captures/",".codeyam/results/",".codeyam/tmp/",".codeyam/rules/",".codeyam/bin/"];async function re(i){const e=t.join(i,".gitignore");let s="";try{s=await l.readFile(e,"utf8")}catch{}const n=s.split(`
3
3
  `),a=n.findIndex(r=>r.trim()===".codeyam"||r.trim()==="/.codeyam");if(a!==-1){const r=a>0&&n[a-1].trim().startsWith("# CodeYam local files")?a-1:a;n.splice(r,a-r+1),s=n.join(`
4
4
  `)}if(!I.some(r=>n.some(u=>u.trim()===r))){const r=`
5
5
  # CodeYam - local only (not shared)