sera-code 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (456) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE-SERA.md +25 -0
  3. package/README.md +27 -2
  4. package/THIRD_PARTY_NOTICES.md +68 -0
  5. package/bin/sera.mjs +137 -0
  6. package/dist/bundle/chunks/anthropic-messages-RD7GXOQL.js +6 -0
  7. package/dist/bundle/chunks/anthropic.js +75 -0
  8. package/dist/bundle/chunks/azure-openai-responses-CJT3KTVK.js +2 -0
  9. package/dist/bundle/chunks/bedrock-converse-stream.js +89 -0
  10. package/dist/bundle/chunks/chunk-46WGNYIE.js +82 -0
  11. package/dist/bundle/chunks/chunk-4UNN5OGR.js +4 -0
  12. package/dist/bundle/chunks/chunk-53H5DPHA.js +16 -0
  13. package/dist/bundle/chunks/chunk-5AGIVGSV.js +6 -0
  14. package/dist/bundle/chunks/chunk-6JXVX6Q2.js +2 -0
  15. package/dist/bundle/chunks/chunk-6QGV3IWD.js +6 -0
  16. package/dist/bundle/chunks/chunk-7CBJINYJ.js +20 -0
  17. package/dist/bundle/chunks/chunk-7DDKXS2Q.js +2 -0
  18. package/dist/bundle/chunks/chunk-7RZ5BS7U.js +2 -0
  19. package/dist/bundle/chunks/chunk-7ZC4UXSL.js +2 -0
  20. package/dist/bundle/chunks/chunk-BPHHHEET.js +9 -0
  21. package/dist/bundle/chunks/chunk-BSS6T6KQ.js +2 -0
  22. package/dist/bundle/chunks/chunk-CF5GWZHW.js +31 -0
  23. package/dist/bundle/chunks/chunk-EDSQGWII.js +44 -0
  24. package/dist/bundle/chunks/chunk-FFMDRXC4.js +10 -0
  25. package/dist/bundle/chunks/chunk-GUGC72EB.js +1222 -0
  26. package/dist/bundle/chunks/chunk-HODJBMOY.js +9 -0
  27. package/dist/bundle/chunks/chunk-HQBQWHLD.js +7 -0
  28. package/dist/bundle/chunks/chunk-HQJBN2MC.js +2 -0
  29. package/dist/bundle/chunks/chunk-JXWJOIH4.js +2 -0
  30. package/dist/bundle/chunks/chunk-KXU77PUU.js +4 -0
  31. package/dist/bundle/chunks/chunk-L2ZPNLYD.js +2 -0
  32. package/dist/bundle/chunks/chunk-LPXNMA2W.js +2 -0
  33. package/dist/bundle/chunks/chunk-LVVZS2NO.js +12 -0
  34. package/dist/bundle/chunks/chunk-M3LEVT3X.js +2 -0
  35. package/dist/bundle/chunks/chunk-P7FPUEYA.js +2 -0
  36. package/dist/bundle/chunks/chunk-PGXDEOVV.js +2 -0
  37. package/dist/bundle/chunks/chunk-PJACZCIR.js +2 -0
  38. package/dist/bundle/chunks/chunk-PMRZO46Y.js +2 -0
  39. package/dist/bundle/chunks/chunk-PRRNXB7S.js +2 -0
  40. package/dist/bundle/chunks/chunk-QTM7S6TH.js +2 -0
  41. package/dist/bundle/chunks/chunk-RDZVAGPR.js +2 -0
  42. package/dist/bundle/chunks/chunk-TLNP2BSO.js +2 -0
  43. package/dist/bundle/chunks/chunk-TMKHGABX.js +2 -0
  44. package/dist/bundle/chunks/chunk-TMTOQ7H7.js +2 -0
  45. package/dist/bundle/chunks/chunk-UKVNB6C4.js +2 -0
  46. package/dist/bundle/chunks/chunk-USJZMAIR.js +2 -0
  47. package/dist/bundle/chunks/chunk-UTB4DTYQ.js +2 -0
  48. package/dist/bundle/chunks/chunk-ZLAHUYDW.js +131 -0
  49. package/dist/bundle/chunks/chunk-ZNCN2NGY.js +60 -0
  50. package/dist/bundle/chunks/cli-MML2DU4A.js +51 -0
  51. package/dist/bundle/chunks/cloudflare-workers-ai-system-one-QPZQRBK5.js +2 -0
  52. package/dist/bundle/chunks/codemode-worker.js +478 -0
  53. package/dist/bundle/chunks/dist-ZNZCJI7B.js +7 -0
  54. package/dist/bundle/chunks/easter-egg-3d-VOETWRJO.js +2 -0
  55. package/dist/bundle/chunks/execute-HXDNZ26B.js +505 -0
  56. package/dist/bundle/chunks/github-copilot.js +2 -0
  57. package/dist/bundle/chunks/google-generative-ai-SJXMIEPZ.js +2 -0
  58. package/dist/bundle/chunks/google-vertex-VSXQ3BDH.js +2 -0
  59. package/dist/bundle/chunks/https-proxy-agent-LVOO5TPL.js +13 -0
  60. package/dist/bundle/chunks/image-resize-worker.js +2 -0
  61. package/dist/bundle/chunks/jiti-loader-GL4HJFAD.js +21 -0
  62. package/dist/bundle/chunks/jiti-static-loader-2RCDI6B4.js +2 -0
  63. package/dist/bundle/chunks/kimi-coding.js +2 -0
  64. package/dist/bundle/chunks/lib-4AVRLBHM.js +9 -0
  65. package/dist/bundle/chunks/llama-cpp-classify-4KFSGAMH.js +22 -0
  66. package/dist/bundle/chunks/meta.js +2 -0
  67. package/dist/bundle/chunks/mistral-conversations-JYWDZV2K.js +5 -0
  68. package/dist/bundle/chunks/multipart-parser-FMGQ7342.js +3 -0
  69. package/dist/bundle/chunks/node-AUOGOBCN.js +2 -0
  70. package/dist/bundle/chunks/node-KCMANYC2.js +16 -0
  71. package/dist/bundle/chunks/openai-chatgpt.js +75 -0
  72. package/dist/bundle/chunks/openai-codex-responses-OQV5DCFA.js +10 -0
  73. package/dist/bundle/chunks/openai-codex.js +75 -0
  74. package/dist/bundle/chunks/openai-completions-RFDJM2W5.js +7 -0
  75. package/dist/bundle/chunks/openai-decisions-O6PHBSCB.js +5 -0
  76. package/dist/bundle/chunks/openai-responses-LVNAPALQ.js +4 -0
  77. package/dist/bundle/chunks/openrouter-images-4WG6OOLH.js +2 -0
  78. package/dist/bundle/chunks/openrouter.js +75 -0
  79. package/dist/bundle/chunks/pdfjs-BETXZQ7A.js +108 -0
  80. package/dist/bundle/chunks/pdfjs-decoders-37HBPYHX.js +2 -0
  81. package/dist/bundle/chunks/pdfjs-jbig2-MH7WRXUP.js +2 -0
  82. package/dist/bundle/chunks/pdfjs-jbig2_nowasm_fallback-UVK7AQLA.js +2 -0
  83. package/dist/bundle/chunks/pdfjs-openjpeg-TC2QHC4G.js +2 -0
  84. package/dist/bundle/chunks/pdfjs-openjpeg_nowasm_fallback-ZC2FTHCZ.js +3 -0
  85. package/dist/bundle/chunks/pi-messages-EZXKVRR6.js +8 -0
  86. package/dist/bundle/chunks/radius.js +75 -0
  87. package/dist/bundle/chunks/runtime-JAH75CB5.js +2 -0
  88. package/dist/bundle/chunks/src-QKGKDFSU.js +4 -0
  89. package/dist/bundle/chunks/typesafe-system-one-X3JT6ECA.js +2 -0
  90. package/dist/bundle/chunks/virtual-modules-I5QRIHN6.js +2 -0
  91. package/dist/bundle/chunks/xai.js +2 -0
  92. package/dist/bundle/cli-runtime.js +3 -0
  93. package/dist/bundle/cli.js +5 -0
  94. package/dist/bundle/index.js +2 -0
  95. package/dist/bundle/rpc-entry.js +3 -0
  96. package/dist/core/export-html/ansi-to-html.d.ts +22 -0
  97. package/dist/core/export-html/ansi-to-html.d.ts.map +1 -0
  98. package/dist/core/export-html/ansi-to-html.js +249 -0
  99. package/dist/core/export-html/ansi-to-html.js.map +1 -0
  100. package/dist/core/export-html/index.d.ts +37 -0
  101. package/dist/core/export-html/index.d.ts.map +1 -0
  102. package/dist/core/export-html/index.js +228 -0
  103. package/dist/core/export-html/index.js.map +1 -0
  104. package/dist/core/export-html/template.css +1085 -0
  105. package/dist/core/export-html/template.html +56 -0
  106. package/dist/core/export-html/template.js +2044 -0
  107. package/dist/core/export-html/tool-renderer.d.ts +34 -0
  108. package/dist/core/export-html/tool-renderer.d.ts.map +1 -0
  109. package/dist/core/export-html/tool-renderer.js +110 -0
  110. package/dist/core/export-html/tool-renderer.js.map +1 -0
  111. package/dist/core/export-html/vendor/highlight.min.js +1213 -0
  112. package/dist/core/export-html/vendor/marked-cjk-friendly.min.js +6 -0
  113. package/dist/core/export-html/vendor/marked.min.js +79 -0
  114. package/dist/modes/interactive/assets/clankolas.png +0 -0
  115. package/dist/modes/interactive/theme/dark.json +81 -0
  116. package/dist/modes/interactive/theme/light.json +81 -0
  117. package/dist/modes/interactive/theme/system-theme.d.ts +55 -0
  118. package/dist/modes/interactive/theme/system-theme.d.ts.map +1 -0
  119. package/dist/modes/interactive/theme/system-theme.js +546 -0
  120. package/dist/modes/interactive/theme/system-theme.js.map +1 -0
  121. package/dist/modes/interactive/theme/theme-controller.d.ts +81 -0
  122. package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -0
  123. package/dist/modes/interactive/theme/theme-controller.js +210 -0
  124. package/dist/modes/interactive/theme/theme-controller.js.map +1 -0
  125. package/dist/modes/interactive/theme/theme-schema.d.ts +28 -0
  126. package/dist/modes/interactive/theme/theme-schema.d.ts.map +1 -0
  127. package/dist/modes/interactive/theme/theme-schema.js +105 -0
  128. package/dist/modes/interactive/theme/theme-schema.js.map +1 -0
  129. package/dist/modes/interactive/theme/theme-tokens.d.ts +257 -0
  130. package/dist/modes/interactive/theme/theme-tokens.d.ts.map +1 -0
  131. package/dist/modes/interactive/theme/theme-tokens.js +94 -0
  132. package/dist/modes/interactive/theme/theme-tokens.js.map +1 -0
  133. package/dist/modes/interactive/theme/theme.d.ts +155 -0
  134. package/dist/modes/interactive/theme/theme.d.ts.map +1 -0
  135. package/dist/modes/interactive/theme/theme.js +905 -0
  136. package/dist/modes/interactive/theme/theme.js.map +1 -0
  137. package/docs/cli-integration.md +106 -0
  138. package/docs/cli.md +333 -0
  139. package/docs/codemode.md +230 -0
  140. package/docs/compaction.md +463 -0
  141. package/docs/configuration.md +47 -0
  142. package/docs/containerization.md +183 -0
  143. package/docs/custom-provider.md +227 -0
  144. package/docs/docs.json +220 -0
  145. package/docs/environment-variables.md +102 -0
  146. package/docs/extensions.md +400 -0
  147. package/docs/how-pi-works.md +49 -0
  148. package/docs/index.md +39 -0
  149. package/docs/json.md +226 -0
  150. package/docs/keybindings.md +195 -0
  151. package/docs/llama-cpp.md +121 -0
  152. package/docs/mcp.md +272 -0
  153. package/docs/message-types.md +279 -0
  154. package/docs/models-configuration.md +196 -0
  155. package/docs/models.md +225 -0
  156. package/docs/nvidia-rtx-llama-cpp.md +96 -0
  157. package/docs/packages.md +131 -0
  158. package/docs/prompt-templates.md +59 -0
  159. package/docs/providers.md +247 -0
  160. package/docs/quickstart.md +136 -0
  161. package/docs/rpc-commands.md +860 -0
  162. package/docs/rpc-extension-ui.md +200 -0
  163. package/docs/rpc.md +193 -0
  164. package/docs/sdk.md +147 -0
  165. package/docs/security.md +99 -0
  166. package/docs/session-format.md +293 -0
  167. package/docs/sessions.md +66 -0
  168. package/docs/settings.md +172 -0
  169. package/docs/shell-aliases.md +93 -0
  170. package/docs/skills.md +93 -0
  171. package/docs/slash-commands.md +61 -0
  172. package/docs/terminal-setup.md +233 -0
  173. package/docs/termux.md +117 -0
  174. package/docs/themes.md +138 -0
  175. package/docs/tmux.md +55 -0
  176. package/docs/tui.md +195 -0
  177. package/docs/usage.md +94 -0
  178. package/docs/virtual-models.md +114 -0
  179. package/docs/windows.md +81 -0
  180. package/lib/auth.js +190 -0
  181. package/lib/provider.js +52 -0
  182. package/package.json +43 -5
  183. package/sera-core/skills/apple-tasarim/SKILL.md +48 -0
  184. package/sera-core/skills/apple-tasarim/referanslar/apple-hig.md +55 -0
  185. package/sera-core/skills/belge-yarat/SKILL.md +64 -0
  186. package/sera-core/skills/belge-yarat/referanslar/belge-yazim.md +60 -0
  187. package/sera-core/skills/derin-arastirma/SKILL.md +52 -0
  188. package/sera-core/skills/derin-arastirma/referanslar/arastirma-yontem.md +50 -0
  189. package/sera-core/skills/dusunme-dogrulama/SKILL.md +59 -0
  190. package/sera-core/skills/dusunme-dogrulama/referanslar/dusunme-kontrol.md +54 -0
  191. package/sera-core/skills/film-stilleri/SKILL.md +51 -0
  192. package/sera-core/skills/hyperframes/LICENSE-UPSTREAM +190 -0
  193. package/sera-core/skills/hyperframes/SKILL.md +79 -0
  194. package/sera-core/skills/hyperframes/assets/frame-presets/biennale-yellow/FRAME.md +289 -0
  195. package/sera-core/skills/hyperframes/assets/frame-presets/blockframe/FRAME.md +275 -0
  196. package/sera-core/skills/hyperframes/assets/frame-presets/blue-professional/FRAME.md +307 -0
  197. package/sera-core/skills/hyperframes/assets/frame-presets/bold-poster/FRAME.md +275 -0
  198. package/sera-core/skills/hyperframes/assets/frame-presets/broadside/FRAME.md +284 -0
  199. package/sera-core/skills/hyperframes/assets/frame-presets/capsule/FRAME.md +284 -0
  200. package/sera-core/skills/hyperframes/assets/frame-presets/cartesian/FRAME.md +278 -0
  201. package/sera-core/skills/hyperframes/assets/frame-presets/cobalt-grid/FRAME.md +265 -0
  202. package/sera-core/skills/hyperframes/assets/frame-presets/code-editorial/FRAME.md +277 -0
  203. package/sera-core/skills/hyperframes/assets/frame-presets/coral/FRAME.md +314 -0
  204. package/sera-core/skills/hyperframes/assets/frame-presets/creative-mode/FRAME.md +333 -0
  205. package/sera-core/skills/hyperframes/assets/frame-presets/daisy-days/FRAME.md +274 -0
  206. package/sera-core/skills/hyperframes/assets/frame-presets/editorial-forest/FRAME.md +265 -0
  207. package/sera-core/skills/hyperframes/references/captions.md +46 -0
  208. package/sera-core/skills/hyperframes/references/film.md +48 -0
  209. package/sera-core/skills/hyperframes/references/format.md +159 -0
  210. package/sera-core/skills/hyperframes/references/look.md +69 -0
  211. package/sera-core/skills/hyperframes/references/motion.md +95 -0
  212. package/sera-core/skills/hyperframes/references/overlays.md +39 -0
  213. package/sera-core/skills/hyperframes/references/path-tracing.md +36 -0
  214. package/sera-core/skills/hyperframes/references/plugin-installation.md +42 -0
  215. package/sera-core/skills/hyperframes/references/review.md +51 -0
  216. package/sera-core/skills/hyperframes/references/runtimes.md +69 -0
  217. package/sera-core/skills/hyperframes/references/skill-lifecycle.md +54 -0
  218. package/sera-core/skills/hyperframes/references/sound.md +43 -0
  219. package/sera-core/skills/hyperframes/references/spec.md +76 -0
  220. package/sera-core/skills/hyperframes/references/story.md +103 -0
  221. package/sera-core/skills/hyperframes/references/storyboard-format.md +107 -0
  222. package/sera-core/skills/hyperframes/references/storyboard.md +36 -0
  223. package/sera-core/skills/hyperframes/references/types/3d.md +25 -0
  224. package/sera-core/skills/hyperframes/references/types/character.md +20 -0
  225. package/sera-core/skills/hyperframes/references/types/data.md +19 -0
  226. package/sera-core/skills/hyperframes/references/types/explainer.md +34 -0
  227. package/sera-core/skills/hyperframes/references/types/launch.md +41 -0
  228. package/sera-core/skills/hyperframes/references/types/music.md +24 -0
  229. package/sera-core/skills/hyperframes/references/types/vertical.md +23 -0
  230. package/sera-core/skills/hyperframes-cli/LICENSE-UPSTREAM +190 -0
  231. package/sera-core/skills/hyperframes-cli/SKILL.md +99 -0
  232. package/sera-core/skills/hyperframes-cli/references/beats.md +17 -0
  233. package/sera-core/skills/hyperframes-cli/references/compare-and-batch.md +105 -0
  234. package/sera-core/skills/hyperframes-cli/references/conventions.md +16 -0
  235. package/sera-core/skills/hyperframes-cli/references/doctor-browser.md +80 -0
  236. package/sera-core/skills/hyperframes-cli/references/feedback.md +14 -0
  237. package/sera-core/skills/hyperframes-cli/references/init-and-scaffold.md +75 -0
  238. package/sera-core/skills/hyperframes-cli/references/lint-validate-inspect.md +164 -0
  239. package/sera-core/skills/hyperframes-cli/references/preview-render.md +204 -0
  240. package/sera-core/skills/hyperframes-cli/references/upgrade-info-misc.md +134 -0
  241. package/sera-core/skills/impeccable/LICENSE-UPSTREAM +191 -0
  242. package/sera-core/skills/impeccable/NOTICE-UPSTREAM.md +11 -0
  243. package/sera-core/skills/impeccable/SKILL.md +89 -0
  244. package/sera-core/skills/impeccable/reference/adapt.md +318 -0
  245. package/sera-core/skills/impeccable/reference/adapt.native.md +58 -0
  246. package/sera-core/skills/impeccable/reference/android.md +46 -0
  247. package/sera-core/skills/impeccable/reference/animate.md +89 -0
  248. package/sera-core/skills/impeccable/reference/audit.md +139 -0
  249. package/sera-core/skills/impeccable/reference/audit.native.md +139 -0
  250. package/sera-core/skills/impeccable/reference/bolder.md +33 -0
  251. package/sera-core/skills/impeccable/reference/clarify.md +94 -0
  252. package/sera-core/skills/impeccable/reference/colorize.md +86 -0
  253. package/sera-core/skills/impeccable/reference/component-review.md +63 -0
  254. package/sera-core/skills/impeccable/reference/craft-floor.md +44 -0
  255. package/sera-core/skills/impeccable/reference/craft.md +5 -0
  256. package/sera-core/skills/impeccable/reference/critique.md +819 -0
  257. package/sera-core/skills/impeccable/reference/degraded/asset-producer.md +42 -0
  258. package/sera-core/skills/impeccable/reference/degraded/documenter.md +24 -0
  259. package/sera-core/skills/impeccable/reference/degraded/finish-reviewer.md +38 -0
  260. package/sera-core/skills/impeccable/reference/degraded/manual-edit-applier.md +93 -0
  261. package/sera-core/skills/impeccable/reference/delight.md +70 -0
  262. package/sera-core/skills/impeccable/reference/distill.md +111 -0
  263. package/sera-core/skills/impeccable/reference/doctor.md +54 -0
  264. package/sera-core/skills/impeccable/reference/document.md +416 -0
  265. package/sera-core/skills/impeccable/reference/extract.md +69 -0
  266. package/sera-core/skills/impeccable/reference/generate.md +101 -0
  267. package/sera-core/skills/impeccable/reference/harden.md +362 -0
  268. package/sera-core/skills/impeccable/reference/hooks.md +120 -0
  269. package/sera-core/skills/impeccable/reference/init.md +133 -0
  270. package/sera-core/skills/impeccable/reference/ios.md +51 -0
  271. package/sera-core/skills/impeccable/reference/layout.md +84 -0
  272. package/sera-core/skills/impeccable/reference/live-setup.md +104 -0
  273. package/sera-core/skills/impeccable/reference/live.md +327 -0
  274. package/sera-core/skills/impeccable/reference/mode-operate.md +21 -0
  275. package/sera-core/skills/impeccable/reference/mode-persuade.md +19 -0
  276. package/sera-core/skills/impeccable/reference/mode-read.md +21 -0
  277. package/sera-core/skills/impeccable/reference/new-work.md +152 -0
  278. package/sera-core/skills/impeccable/reference/onboard.md +234 -0
  279. package/sera-core/skills/impeccable/reference/operate.md +61 -0
  280. package/sera-core/skills/impeccable/reference/optimize.md +257 -0
  281. package/sera-core/skills/impeccable/reference/overdrive.md +127 -0
  282. package/sera-core/skills/impeccable/reference/polish.md +105 -0
  283. package/sera-core/skills/impeccable/reference/quieter.md +99 -0
  284. package/sera-core/skills/impeccable/reference/region-map.md +26 -0
  285. package/sera-core/skills/impeccable/reference/routing.md +24 -0
  286. package/sera-core/skills/impeccable/reference/shape.md +59 -0
  287. package/sera-core/skills/impeccable/reference/typeset.md +90 -0
  288. package/sera-core/skills/impeccable/reference/visualize.md +47 -0
  289. package/sera-core/skills/oyun-yarat/SKILL.md +106 -0
  290. package/sera-core/skills/oyun-yarat/referanslar/3b-yaris.md +74 -0
  291. package/sera-core/skills/oyun-yarat/referanslar/kaplay.md +99 -0
  292. package/sera-core/skills/oyun-yarat/referanslar/oyun-desenleri.md +73 -0
  293. package/sera-core/skills/oyun-yarat/sablonlar/kaplay-2d.html +164 -0
  294. package/sera-core/skills/oyun-yarat/sablonlar/three-yaris.html +149 -0
  295. package/sera-core/skills/oyun-yarat/sablonlar/tuval-minimal.html +77 -0
  296. package/sera-core/skills/receiving-code-review/LICENSE-UPSTREAM +21 -0
  297. package/sera-core/skills/receiving-code-review/SKILL.md +205 -0
  298. package/sera-core/skills/refero-design/LICENSE-UPSTREAM +21 -0
  299. package/sera-core/skills/refero-design/SKILL.md +534 -0
  300. package/sera-core/skills/refero-design/references/anti-ai-slop.md +292 -0
  301. package/sera-core/skills/refero-design/references/color.md +563 -0
  302. package/sera-core/skills/refero-design/references/copywriting.md +222 -0
  303. package/sera-core/skills/refero-design/references/craft-details.md +525 -0
  304. package/sera-core/skills/refero-design/references/example-workflow.md +264 -0
  305. package/sera-core/skills/refero-design/references/icons.md +166 -0
  306. package/sera-core/skills/refero-design/references/mcp-tools.md +258 -0
  307. package/sera-core/skills/refero-design/references/motion.md +504 -0
  308. package/sera-core/skills/refero-design/references/typography.md +737 -0
  309. package/sera-core/skills/refero-design/references/visual-workflow.md +105 -0
  310. package/sera-core/skills/requesting-code-review/LICENSE-UPSTREAM +21 -0
  311. package/sera-core/skills/requesting-code-review/SKILL.md +95 -0
  312. package/sera-core/skills/requesting-code-review/code-reviewer.md +198 -0
  313. package/sera-core/skills/reverse-engineer-anything/DISCLAIMER.md +136 -0
  314. package/sera-core/skills/reverse-engineer-anything/LICENSE-REA-MIT +21 -0
  315. package/sera-core/skills/reverse-engineer-anything/SKILL.md +363 -0
  316. package/sera-core/skills/reverse-engineer-anything/THIRD_PARTY_NOTICES.md +135 -0
  317. package/sera-core/skills/reverse-engineer-anything/references/android-applications.md +36 -0
  318. package/sera-core/skills/reverse-engineer-anything/references/connection-and-recovery.md +127 -0
  319. package/sera-core/skills/reverse-engineer-anything/references/evidence-workflows.md +71 -0
  320. package/sera-core/skills/reverse-engineer-anything/references/javascript-applications.md +218 -0
  321. package/sera-core/skills/reverse-engineer-anything/references/native-and-artifacts.md +297 -0
  322. package/sera-core/skills/reverse-engineer-anything/references/runtime-observation.md +78 -0
  323. package/sera-core/skills/seo-audit/LICENSE-UPSTREAM +21 -0
  324. package/sera-core/skills/seo-audit/SKILL.md +210 -0
  325. package/sera-core/skills/sera-guvenlik-denetim/SKILL.md +44 -0
  326. package/sera-core/skills/sera-guvenlik-denetim/referanslar/guvenlik-listesi.md +33 -0
  327. package/sera-core/skills/sera-hata-ayikla/SKILL.md +27 -0
  328. package/sera-core/skills/sera-hata-ayikla/referanslar/hata-ayiklama.md +37 -0
  329. package/sera-core/skills/sera-kod-inceleme/SKILL.md +44 -0
  330. package/sera-core/skills/sera-kod-inceleme/referanslar/inceleme-listesi.md +62 -0
  331. package/sera-core/skills/sera-ofis-dosya/SKILL.md +27 -0
  332. package/sera-core/skills/sera-ofis-dosya/referanslar/ofis-dosya.md +93 -0
  333. package/sera-core/skills/sera-research/SKILL.md +90 -0
  334. package/sera-core/skills/sera-tasarim/SKILL.md +149 -0
  335. package/sera-core/skills/sera-teslim-sozlesmesi/SKILL.md +592 -0
  336. package/sera-core/skills/sera-test-yaz/SKILL.md +26 -0
  337. package/sera-core/skills/sera-test-yaz/referanslar/test-yazimi.md +35 -0
  338. package/sera-core/skills/sera-veri-gorsel/SKILL.md +65 -0
  339. package/sera-core/skills/sera-web-test/SKILL.md +26 -0
  340. package/sera-core/skills/sera-web-test/referanslar/web-test.md +44 -0
  341. package/sera-core/skills/sera-zamanli-gorev/SKILL.md +22 -0
  342. package/sera-core/skills/sera-zamanli-gorev/referanslar/zamanli-gorev.md +58 -0
  343. package/sera-core/skills/systematic-debugging/LICENSE-UPSTREAM +21 -0
  344. package/sera-core/skills/systematic-debugging/SKILL.md +283 -0
  345. package/sera-core/skills/systematic-debugging/condition-based-waiting.md +115 -0
  346. package/sera-core/skills/systematic-debugging/defense-in-depth.md +122 -0
  347. package/sera-core/skills/systematic-debugging/root-cause-tracing.md +169 -0
  348. package/sera-core/skills/test-driven-development/LICENSE-UPSTREAM +21 -0
  349. package/sera-core/skills/test-driven-development/SKILL.md +330 -0
  350. package/sera-core/skills/test-driven-development/writing-good-tests.md +198 -0
  351. package/sera-core/skills/ticaret-icerik/SKILL.md +49 -0
  352. package/sera-core/skills/ticaret-icerik/referanslar/ticaret-icerik.md +54 -0
  353. package/sera-core/skills/uygulama-yarat/SKILL.md +95 -0
  354. package/sera-core/skills/uygulama-yarat/referanslar/uygulama-desenleri.md +63 -0
  355. package/sera-core/skills/uygulama-yarat/sablonlar/uygulama-tek-dosya.html +121 -0
  356. package/sera-core/skills/uyumluluk-denetim/SKILL.md +56 -0
  357. package/sera-core/skills/uyumluluk-denetim/referanslar/mevzuat-tablosu.md +65 -0
  358. package/sera-core/skills/veri-analizi/SKILL.md +54 -0
  359. package/sera-core/skills/veri-analizi/referanslar/veri-analizi-yontem.md +49 -0
  360. package/sera-core/skills/veri-analizi/sablonlar/profil.mjs +79 -0
  361. package/sera-core/skills/video-duzen/SKILL.md +50 -0
  362. package/sera-core/skills/video-duzen/referanslar/video-duzen.md +100 -0
  363. package/sera-core/skills/web-yayin-listesi/SKILL.md +115 -0
  364. package/sera-core/skills/writing-plans/LICENSE-UPSTREAM +21 -0
  365. package/sera-core/skills/writing-plans/SKILL.md +204 -0
  366. package/sera-core/src/action-nudge.ts +200 -0
  367. package/sera-core/src/agent-mode.ts +143 -0
  368. package/sera-core/src/agents.ts +185 -0
  369. package/sera-core/src/app-master.ts +275 -0
  370. package/sera-core/src/app-verify.ts +551 -0
  371. package/sera-core/src/approval.ts +131 -0
  372. package/sera-core/src/budget.ts +136 -0
  373. package/sera-core/src/command-policy.ts +808 -0
  374. package/sera-core/src/config.ts +135 -0
  375. package/sera-core/src/context-diet.ts +272 -0
  376. package/sera-core/src/device-id.ts +48 -0
  377. package/sera-core/src/dogal-arac.ts +203 -0
  378. package/sera-core/src/dogal-niyet.ts +173 -0
  379. package/sera-core/src/egress-allow.ts +52 -0
  380. package/sera-core/src/export.ts +124 -0
  381. package/sera-core/src/exposure.ts +8 -0
  382. package/sera-core/src/extension.ts +2416 -0
  383. package/sera-core/src/fs-tools.ts +444 -0
  384. package/sera-core/src/generated/build-rules.ts +26 -0
  385. package/sera-core/src/generated/zero-knowledge.ts +170 -0
  386. package/sera-core/src/github-agent-command.ts +133 -0
  387. package/sera-core/src/github-agent-engine.ts +198 -0
  388. package/sera-core/src/github-agent-schedule.ts +180 -0
  389. package/sera-core/src/github-agent.ts +669 -0
  390. package/sera-core/src/github-ajan-akis.ts +193 -0
  391. package/sera-core/src/github-ajan-gercek.ts +102 -0
  392. package/sera-core/src/github-tick.ts +78 -0
  393. package/sera-core/src/github-yedek.ts +269 -0
  394. package/sera-core/src/goal.ts +119 -0
  395. package/sera-core/src/handoff.ts +132 -0
  396. package/sera-core/src/hooks.ts +284 -0
  397. package/sera-core/src/image-tool.ts +118 -0
  398. package/sera-core/src/intake-brief.ts +82 -0
  399. package/sera-core/src/intake-core.ts +1152 -0
  400. package/sera-core/src/intake-hook.ts +88 -0
  401. package/sera-core/src/ios-build-tool.ts +134 -0
  402. package/sera-core/src/lazy-capability.ts +125 -0
  403. package/sera-core/src/lazy-mcp.ts +300 -0
  404. package/sera-core/src/limit-command.ts +51 -0
  405. package/sera-core/src/loop-brake.ts +129 -0
  406. package/sera-core/src/lsp.ts +618 -0
  407. package/sera-core/src/mcp-bridge.ts +159 -0
  408. package/sera-core/src/mcp-pin.ts +105 -0
  409. package/sera-core/src/mcp-ssrf.ts +124 -0
  410. package/sera-core/src/message-cap.ts +45 -0
  411. package/sera-core/src/no-progress.ts +177 -0
  412. package/sera-core/src/notebook-tool.ts +179 -0
  413. package/sera-core/src/ofis.ts +473 -0
  414. package/sera-core/src/path-guard.ts +139 -0
  415. package/sera-core/src/permission-bridge.ts +228 -0
  416. package/sera-core/src/policy-chain.ts +122 -0
  417. package/sera-core/src/pricing.ts +71 -0
  418. package/sera-core/src/proc.ts +149 -0
  419. package/sera-core/src/rea.ts +188 -0
  420. package/sera-core/src/repo-map.ts +230 -0
  421. package/sera-core/src/research.ts +347 -0
  422. package/sera-core/src/rules-memory.ts +227 -0
  423. package/sera-core/src/sandbox.ts +445 -0
  424. package/sera-core/src/server-error.ts +78 -0
  425. package/sera-core/src/skills.ts +268 -0
  426. package/sera-core/src/snapshot.ts +143 -0
  427. package/sera-core/src/spec-gate.ts +112 -0
  428. package/sera-core/src/subagent.ts +261 -0
  429. package/sera-core/src/teslim.ts +120 -0
  430. package/sera-core/src/test-fix.ts +184 -0
  431. package/sera-core/src/todo-question.ts +163 -0
  432. package/sera-core/src/turn-snapshots.ts +126 -0
  433. package/sera-core/src/tuval/arac.ts +338 -0
  434. package/sera-core/src/tuval/arsiv.ts +106 -0
  435. package/sera-core/src/tuval/belge.ts +216 -0
  436. package/sera-core/src/tuval/birlestir.ts +282 -0
  437. package/sera-core/src/tuval/disa.ts +235 -0
  438. package/sera-core/src/tuval/editor.ts +583 -0
  439. package/sera-core/src/tuval/film-cekirdek.ts +170 -0
  440. package/sera-core/src/tuval/film-disa.ts +188 -0
  441. package/sera-core/src/tuval/film-oynatici.ts +307 -0
  442. package/sera-core/src/tuval/kimlik.ts +156 -0
  443. package/sera-core/src/tuval/pano.ts +763 -0
  444. package/sera-core/src/tuval/proje.ts +728 -0
  445. package/sera-core/src/tuval/sistem-cekirdek.ts +167 -0
  446. package/sera-core/src/tuval/sistem.ts +328 -0
  447. package/sera-core/src/tuval/sunucu.ts +413 -0
  448. package/sera-core/src/tuval/uretim.ts +24 -0
  449. package/sera-core/src/tuval/veri-cekirdek.ts +477 -0
  450. package/sera-core/src/tuval/xlsx.ts +215 -0
  451. package/sera-core/src/tuval/zip.ts +163 -0
  452. package/sera-core/src/untrusted.ts +201 -0
  453. package/sera-core/src/video-edit-tool.ts +411 -0
  454. package/sera-core/src/video-tool.ts +217 -0
  455. package/sera-core/src/web-tools.ts +257 -0
  456. package/sera-core/src/zk.ts +104 -0
@@ -0,0 +1,728 @@
1
+ /**
2
+ * Sera Tuval: proje klasoru bicimi, yorum kaydi ve surum gecmisi (saf dosya mantigi, sunucudan bagimsiz).
3
+ *
4
+ * <kok>/sera-tuval.json bildirim: ad, tur ("tasarim" | "deste"), artboard listesi
5
+ * <kok>/<dosya>.html her artboard (ya da slayt) bagimsiz tek HTML
6
+ * <kok>/yorumlar.json yorumlar (secici + metin parmak izi + kutu konumu) ve ajan yanitlari
7
+ * <kok>/gecmis/ surumler: index.json + <n>-<artboard>.html
8
+ *
9
+ * Ozgun tasarim; ucuncu taraf editor kodu/metni kullanilmamistir.
10
+ */
11
+ import { createHash, randomBytes } from "node:crypto";
12
+ import { existsSync, mkdirSync, readdirSync, readFileSync, renameSync, statSync, writeFileSync } from "node:fs";
13
+ import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
14
+ import { sahneIskeleti } from "./film-cekirdek.ts";
15
+
16
+ export const BILDIRIM = "sera-tuval.json";
17
+ export const YORUMLAR = "yorumlar.json";
18
+ export const GECMIS = "gecmis";
19
+ export const BELGE_G = 794;
20
+ export const BELGE_Y = 1123;
21
+ export const SLAYT_G = 1920;
22
+ export const SLAYT_Y = 1080;
23
+
24
+ export type Tur = "tasarim" | "deste" | "pano" | "sistem" | "film" | "belge";
25
+ export const TURLER: Tur[] = ["tasarim", "deste", "pano", "sistem", "film", "belge"];
26
+ /** Uretilen turler: artboard dosyasi belirtec/veriden uretilir, elle metin duzenleme ve sayfa ekleme kapali. */
27
+ export const URETILEN: Tur[] = ["pano", "sistem"];
28
+
29
+ export interface Artboard {
30
+ id: string;
31
+ ad: string;
32
+ dosya: string;
33
+ genislik: number;
34
+ yukseklik: number;
35
+ }
36
+ export interface Bildirim {
37
+ surum: 1;
38
+ ad: string;
39
+ tur: Tur;
40
+ artboardlar: Artboard[];
41
+ /** Kullanilan tasarim sistemi klasoru (proje kokune gore yol); belirtecleri artboard'lara :root olarak eklenir. */
42
+ sistem?: string;
43
+ /** Yalniz "film" turu: sahne sureleri, kare hizi, anlatim metni ve ses izi. */
44
+ film?: FilmAyar;
45
+ }
46
+ export interface FilmAyar {
47
+ fps: number;
48
+ /** artboard(sahne) id -> sure (saniye) */
49
+ sureler: Record<string, number>;
50
+ /** sahne id -> anlatim metni (altyazi kaynagi) */
51
+ anlatim?: Record<string, string>;
52
+ /** ses izi: proje icindeki dosya + film zamaninda baslangic (sn) */
53
+ ses?: { dosya: string; baslangic: number };
54
+ }
55
+ export const FILM_SURE_MIN = 0.5;
56
+ export const FILM_SURE_MAX = 120;
57
+ export const FILM_SURE_VARSAYILAN = 3;
58
+ export const FILM_SES_UZANTI = /\.(mp3|wav|m4a|aac|ogg)$/i;
59
+
60
+ export type YorumDurum = "acik" | "gonderildi" | "alindi" | "cozuldu";
61
+ export interface Secici {
62
+ css: string;
63
+ metin: string;
64
+ parmakIzi: string;
65
+ kutu: { x: number; y: number; g: number; y2: number };
66
+ /** Surukleyerek secilen alan (artboard belge koordinati); yoksa tek ogeye tiklanmis demektir. */
67
+ alan?: { x: number; y: number; g: number; y2: number };
68
+ }
69
+ export interface Yanit {
70
+ yazar: "sera" | "insan";
71
+ metin: string;
72
+ zaman: string;
73
+ ad?: string;
74
+ }
75
+ export interface Yorum {
76
+ id: string;
77
+ artboard: string;
78
+ secici: Secici;
79
+ metin: string;
80
+ durum: YorumDurum;
81
+ yazar: "insan";
82
+ zaman: string;
83
+ yanitlar: Yanit[];
84
+ /** Film projesinde: yorumun birakildigi AN (film basindan saniye). */
85
+ an?: number;
86
+ /** Yorumu yazanin gorunen adi (paylasimda). */
87
+ ad?: string;
88
+ }
89
+ export interface Surum {
90
+ n: number;
91
+ artboard: string;
92
+ kim: "insan" | "sera";
93
+ zaman: string;
94
+ hash: string;
95
+ boyut: number;
96
+ not?: string;
97
+ /** Dosyaya uygulanmayan yan surum (cakisma ya da birlesmede korunan gelen metin). */
98
+ yan?: boolean;
99
+ /** Degisikligi yapan kisinin gorunen adi (paylasimda). */
100
+ ad?: string;
101
+ }
102
+
103
+ const now = () => new Date().toISOString();
104
+ export const hashOf = (s: string | Buffer) => createHash("sha256").update(s).digest("hex").slice(0, 16);
105
+ export const yeniId = (p: string) => `${p}${randomBytes(4).toString("hex")}`;
106
+
107
+ /** Metin parmak izi: bosluklar normallestirilir, kucuk harfe indirilir, kisa ozet. */
108
+ export function metinParmakIzi(metin: string): string {
109
+ const n = metin.replace(/\s+/g, " ").trim().toLowerCase().slice(0, 200);
110
+ return n ? hashOf(n) : "";
111
+ }
112
+
113
+ export function atomikYaz(dosya: string, icerik: string): void {
114
+ mkdirSync(dirname(dosya), { recursive: true });
115
+ const gecici = `${dosya}.${process.pid}.${randomBytes(3).toString("hex")}.tmp`;
116
+ writeFileSync(gecici, icerik, "utf8");
117
+ renameSync(gecici, dosya);
118
+ }
119
+
120
+ function jsonOku<T>(dosya: string, varsayilan: T): T {
121
+ try {
122
+ return JSON.parse(readFileSync(dosya, "utf8")) as T;
123
+ } catch {
124
+ return varsayilan;
125
+ }
126
+ }
127
+
128
+ /** Bir yolun kok icinde kaldigini dogrular (yol kacisi savunmasi). */
129
+ export function kokIci(kok: string, hedef: string): string {
130
+ const k = resolve(kok);
131
+ const h = resolve(k, hedef);
132
+ const r = relative(k, h);
133
+ if (r === "" || r.startsWith("..") || isAbsolute(r) || r.split(sep).includes("..")) {
134
+ throw new Error(`Kok disina cikan yol reddedildi: ${hedef}`);
135
+ }
136
+ return h;
137
+ }
138
+
139
+ export function bildirimOku(kok: string): Bildirim {
140
+ const ham = readFileSync(join(kok, BILDIRIM), "utf8");
141
+ return dogrula(JSON.parse(ham));
142
+ }
143
+
144
+ /** Gecersizse acik Turkce hata firlatir. */
145
+ export function dogrula(b: unknown): Bildirim {
146
+ if (!b || typeof b !== "object") throw new Error(`${BILDIRIM} bir nesne olmali.`);
147
+ const o = b as Record<string, unknown>;
148
+ if (o.surum !== 1) throw new Error(`${BILDIRIM}: surum 1 olmali.`);
149
+ if (typeof o.ad !== "string" || !o.ad.trim()) throw new Error(`${BILDIRIM}: ad gerekli.`);
150
+ if (!TURLER.includes(o.tur as Tur))
151
+ throw new Error(`${BILDIRIM}: tur ${TURLER.map((t) => `"${t}"`).join(", ")} olmali.`);
152
+ if (!Array.isArray(o.artboardlar) || o.artboardlar.length === 0)
153
+ throw new Error(`${BILDIRIM}: en az bir artboard gerekli.`);
154
+ const ids = new Set<string>();
155
+ const arts: Artboard[] = [];
156
+ for (const a of o.artboardlar as Record<string, unknown>[]) {
157
+ if (!a || typeof a.id !== "string" || !/^[a-z0-9][a-z0-9_-]{0,40}$/i.test(a.id))
158
+ throw new Error(`${BILDIRIM}: artboard id gecersiz.`);
159
+ if (ids.has(a.id)) throw new Error(`${BILDIRIM}: artboard id tekrar ediyor: ${a.id}`);
160
+ ids.add(a.id);
161
+ if (typeof a.dosya !== "string" || !/\.html?$/i.test(a.dosya))
162
+ throw new Error(`${BILDIRIM}: ${a.id} icin .html dosyasi gerekli.`);
163
+ if (a.dosya.includes("..") || isAbsolute(a.dosya) || a.dosya.startsWith(GECMIS))
164
+ throw new Error(`${BILDIRIM}: ${a.id} dosya yolu gecersiz.`);
165
+ const deste = o.tur === "deste" || o.tur === "film";
166
+ const g = Number(a.genislik ?? (deste ? SLAYT_G : o.tur === "belge" ? BELGE_G : 1440));
167
+ const y = Number(
168
+ a.yukseklik ??
169
+ (deste ? SLAYT_Y : o.tur === "pano" ? 1100 : o.tur === "sistem" ? 1500 : o.tur === "belge" ? BELGE_Y : 900),
170
+ );
171
+ if (!(g >= 200 && g <= 8000 && y >= 200 && y <= 20000)) throw new Error(`${BILDIRIM}: ${a.id} boyutu gecersiz.`);
172
+ arts.push({ id: a.id, ad: typeof a.ad === "string" ? a.ad : a.id, dosya: a.dosya, genislik: g, yukseklik: y });
173
+ }
174
+ const sistem = typeof o.sistem === "string" && o.sistem.trim() ? o.sistem.trim() : undefined;
175
+ const film = o.tur === "film" ? filmDogrula(o.film, arts) : undefined;
176
+ return {
177
+ surum: 1,
178
+ ad: o.ad.trim(),
179
+ tur: o.tur as Tur,
180
+ artboardlar: arts,
181
+ ...(sistem ? { sistem } : {}),
182
+ ...(film ? { film } : {}),
183
+ };
184
+ }
185
+
186
+ /** Film ayari: eksik sureler varsayilanla tamamlanir, sinirlar zorlanir; ses yolu proje icinde ve ses uzantili olmali. */
187
+ export function filmDogrula(f: unknown, arts: Artboard[]): FilmAyar {
188
+ const o = (f && typeof f === "object" ? f : {}) as Record<string, unknown>;
189
+ const fps = Number(o.fps ?? 30);
190
+ if (!Number.isFinite(fps) || fps < 1 || fps > 60) throw new Error(`${BILDIRIM}: film.fps 1-60 arasi olmali.`);
191
+ const ham = (o.sureler && typeof o.sureler === "object" ? o.sureler : {}) as Record<string, unknown>;
192
+ const sureler: Record<string, number> = {};
193
+ for (const a of arts) {
194
+ const v = Number(ham[a.id] ?? FILM_SURE_VARSAYILAN);
195
+ if (!Number.isFinite(v)) throw new Error(`${BILDIRIM}: film.sureler.${a.id} sayi olmali.`);
196
+ sureler[a.id] = Math.round(Math.min(FILM_SURE_MAX, Math.max(FILM_SURE_MIN, v)) * 100) / 100;
197
+ }
198
+ const anlatim: Record<string, string> = {};
199
+ if (o.anlatim && typeof o.anlatim === "object") {
200
+ for (const [k, v] of Object.entries(o.anlatim as Record<string, unknown>)) {
201
+ if (typeof v === "string" && v.trim() && arts.some((a) => a.id === k)) anlatim[k] = v.slice(0, 2000);
202
+ }
203
+ }
204
+ let ses: FilmAyar["ses"];
205
+ if (o.ses && typeof o.ses === "object") {
206
+ const s = o.ses as Record<string, unknown>;
207
+ const dosya = String(s.dosya ?? "");
208
+ if (!FILM_SES_UZANTI.test(dosya) || dosya.includes("..") || isAbsolute(dosya) || dosya.startsWith(GECMIS))
209
+ throw new Error(`${BILDIRIM}: film.ses.dosya proje icinde bir ses dosyasi (mp3, wav, m4a, aac, ogg) olmali.`);
210
+ const bas = Number(s.baslangic ?? 0);
211
+ ses = { dosya, baslangic: Number.isFinite(bas) ? Math.max(0, Math.min(3600, bas)) : 0 };
212
+ }
213
+ return {
214
+ fps: Math.round(fps),
215
+ sureler,
216
+ ...(Object.keys(anlatim).length ? { anlatim } : {}),
217
+ ...(ses ? { ses } : {}),
218
+ };
219
+ }
220
+
221
+ export interface KontrolSonucu {
222
+ gecerli: boolean;
223
+ sorunlar: string[];
224
+ bildirim?: Bildirim;
225
+ }
226
+
227
+ /** Proje gecerli mi: bildirim + her artboard dosyasi var ve bos degil + HTML iskeleti. */
228
+ export function kontrol(kok: string): KontrolSonucu {
229
+ const sorunlar: string[] = [];
230
+ let b: Bildirim;
231
+ try {
232
+ b = bildirimOku(kok);
233
+ } catch (e) {
234
+ return { gecerli: false, sorunlar: [(e as Error).message] };
235
+ }
236
+ for (const a of b.artboardlar) {
237
+ const yol = join(kok, a.dosya);
238
+ try {
239
+ kokIci(kok, a.dosya);
240
+ if (!existsSync(yol)) {
241
+ sorunlar.push(`${a.id}: dosya yok (${a.dosya})`);
242
+ continue;
243
+ }
244
+ const t = readFileSync(yol, "utf8");
245
+ if (t.trim().length < 20) sorunlar.push(`${a.id}: dosya bos ya da cok kisa`);
246
+ else if (!/<html[\s>]|<body[\s>]|<!doctype/i.test(t))
247
+ sorunlar.push(`${a.id}: tam HTML belgesi degil (<!doctype html> ile baslayin)`);
248
+ if (/<meta[^>]+name=["']viewport["']/i.test(t) === false) sorunlar.push(`${a.id}: viewport meta etiketi yok`);
249
+ } catch (e) {
250
+ sorunlar.push(`${a.id}: ${(e as Error).message}`);
251
+ }
252
+ }
253
+ return { gecerli: sorunlar.length === 0, sorunlar, bildirim: b };
254
+ }
255
+
256
+ /** Yeni proje iskeleti (varsa bildirimi ezmez). */
257
+ export function olustur(kok: string, ad: string, tur: Tur, artboardlar: Artboard[]): Bildirim {
258
+ const b = dogrula({ surum: 1, ad, tur, artboardlar });
259
+ mkdirSync(kok, { recursive: true });
260
+ if (!existsSync(join(kok, BILDIRIM))) atomikYaz(join(kok, BILDIRIM), `${JSON.stringify(b, null, 2)}\n`);
261
+ return b;
262
+ }
263
+
264
+ /** Film projesi kurar: `sahne` adet sahne iskeleti (1920x1080, varsayilan 3 sn). Var olan projenin uzerine yazmaz. */
265
+ export function filmOlustur(kok: string, ad: string, sahne = 2): Bildirim {
266
+ const n = Math.min(30, Math.max(1, Math.round(sahne)));
267
+ if (existsSync(join(kok, BILDIRIM))) throw new Error("Bu klasorde zaten bir Tuval projesi var.");
268
+ const arts: Artboard[] = Array.from({ length: n }, (_v, i) => ({
269
+ id: `sahne${i + 1}`,
270
+ ad: `Sahne ${i + 1}`,
271
+ dosya: `sahne${i + 1}.html`,
272
+ genislik: SLAYT_G,
273
+ yukseklik: SLAYT_Y,
274
+ }));
275
+ const b = olustur(kok, ad, "film", arts);
276
+ for (const a of arts) atomikYaz(kokIci(kok, a.dosya), sahneIskeleti(a.ad, FILM_SURE_VARSAYILAN));
277
+ return b;
278
+ }
279
+
280
+ /** Belge sayfasi iskeleti (A4, okunur yazi). `govde` verilirse baslik altina HTML olarak eklenir. */
281
+ export function belgeSayfasi(baslik: string, govde: string[]): string {
282
+ const k = (t: string) => t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
283
+ return `<!doctype html>
284
+ <html lang="tr"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
285
+ <title>${k(baslik)}</title>
286
+ <style>
287
+ :root{--zemin:#fff;--metin:#1b1f24;--soluk:#5b6470;--vurgu:#1d5fd0;--cizgi:#d8dde3}
288
+ *{box-sizing:border-box}body{margin:0;padding:72px 64px;background:var(--zemin);color:var(--metin);font:16px/1.65 system-ui,"Segoe UI",sans-serif}
289
+ h1{font-size:32px;line-height:1.2;margin:0 0 20px}h2{font-size:22px;margin:28px 0 10px}h3{font-size:18px;margin:22px 0 8px}
290
+ p{margin:0 0 12px}ul,ol{margin:0 0 12px;padding-left:24px}code{background:#f1f3f5;padding:1px 5px;border-radius:4px;font-size:.92em}
291
+ pre{background:#f1f3f5;padding:12px 14px;border-radius:8px;overflow:auto}blockquote{margin:0 0 12px;padding-left:14px;border-left:3px solid var(--vurgu);color:var(--soluk)}
292
+ table{border-collapse:collapse;margin:0 0 14px;width:100%}th,td{border:1px solid var(--cizgi);padding:6px 10px;text-align:left}a{color:var(--vurgu)}
293
+ </style></head><body>
294
+ <h1>${k(baslik)}</h1>
295
+ ${govde.join("\n")}
296
+ </body></html>
297
+ `;
298
+ }
299
+
300
+ /** Belge projesi kurar: her bolum ayri bir sayfa. Var olan projenin uzerine yazmaz. */
301
+ export function belgeOlustur(kok: string, ad: string, bolumler: string[] = ["Giris", "Ayrintilar"]): Bildirim {
302
+ if (existsSync(join(kok, BILDIRIM))) throw new Error("Bu klasorde zaten bir Tuval projesi var.");
303
+ const adlar = bolumler
304
+ .map((x) => x.trim())
305
+ .filter(Boolean)
306
+ .slice(0, 40);
307
+ if (!adlar.length) adlar.push("Giris");
308
+ const arts: Artboard[] = adlar.map((x, i) => ({
309
+ id: `sayfa${i + 1}`,
310
+ ad: x,
311
+ dosya: `sayfa${i + 1}.html`,
312
+ genislik: BELGE_G,
313
+ yukseklik: BELGE_Y,
314
+ }));
315
+ const b = olustur(kok, ad, "belge", arts);
316
+ for (const a of arts) atomikYaz(kokIci(kok, a.dosya), belgeSayfasi(a.ad, ["<p>Buraya yazin.</p>"]));
317
+ return b;
318
+ }
319
+
320
+ export function artboardBul(b: Bildirim, id: string): Artboard {
321
+ const a = b.artboardlar.find((x) => x.id === id);
322
+ if (!a) throw new Error(`Artboard yok: ${id}`);
323
+ return a;
324
+ }
325
+
326
+ export function artboardOku(kok: string, a: Artboard): string {
327
+ return readFileSync(kokIci(kok, a.dosya), "utf8");
328
+ }
329
+
330
+ // ---------------------------------------------------------------- yorumlar
331
+
332
+ export function yorumlariOku(kok: string): Yorum[] {
333
+ const d = jsonOku<{ yorumlar?: Yorum[] }>(join(kok, YORUMLAR), {});
334
+ return Array.isArray(d.yorumlar) ? d.yorumlar : [];
335
+ }
336
+ function yorumlariYaz(kok: string, y: Yorum[]): void {
337
+ atomikYaz(join(kok, YORUMLAR), `${JSON.stringify({ surum: 1, yorumlar: y }, null, 2)}\n`);
338
+ }
339
+
340
+ const kisalt = (s: unknown, n: number) => (typeof s === "string" ? s.slice(0, n) : "");
341
+
342
+ /** Istemciden gelen yorum girdisini dogrular ve kaydeder (durum: acik). */
343
+ export function yorumEkle(kok: string, girdi: unknown): Yorum {
344
+ const g = (girdi ?? {}) as Record<string, unknown>;
345
+ const b = bildirimOku(kok);
346
+ const art = artboardBul(b, String(g.artboard ?? ""));
347
+ const metin = kisalt(g.metin, 4000).trim();
348
+ if (!metin) throw new Error("Yorum metni bos.");
349
+ const s = (g.secici ?? {}) as Record<string, unknown>;
350
+ const css = kisalt(s.css, 1000);
351
+ if (!css) throw new Error("Yorum icin secici gerekli.");
352
+ const kb = (s.kutu ?? {}) as Record<string, unknown>;
353
+ const sayi = (v: unknown) => (Number.isFinite(Number(v)) ? Math.round(Number(v)) : 0);
354
+ const ozet = kisalt(s.metin, 200);
355
+ const an = Number(g.zaman ?? g.an);
356
+ const ad = kisalt(g.ad, 40).trim();
357
+ const al = s.alan && typeof s.alan === "object" ? (s.alan as Record<string, unknown>) : undefined;
358
+ let alan: Secici["alan"];
359
+ if (al) {
360
+ const a = { x: sayi(al.x), y: sayi(al.y), g: sayi(al.g), y2: sayi(al.y2) };
361
+ if (a.g < 4 || a.y2 < 4) throw new Error("Secilen alan cok kucuk.");
362
+ alan = { x: Math.max(0, a.x), y: Math.max(0, a.y), g: Math.min(a.g, 20000), y2: Math.min(a.y2, 40000) };
363
+ }
364
+ const y: Yorum = {
365
+ id: yeniId("y"),
366
+ artboard: art.id,
367
+ secici: {
368
+ css,
369
+ metin: ozet,
370
+ parmakIzi: metinParmakIzi(ozet),
371
+ kutu: { x: sayi(kb.x), y: sayi(kb.y), g: sayi(kb.g), y2: sayi(kb.y2) },
372
+ ...(alan ? { alan } : {}),
373
+ },
374
+ metin,
375
+ durum: "acik",
376
+ yazar: "insan",
377
+ zaman: now(),
378
+ yanitlar: [],
379
+ ...(b.tur === "film" && Number.isFinite(an) && an >= 0 ? { an: Math.round(an * 100) / 100 } : {}),
380
+ ...(ad ? { ad } : {}),
381
+ };
382
+ const tum = yorumlariOku(kok);
383
+ tum.push(y);
384
+ yorumlariYaz(kok, tum);
385
+ return y;
386
+ }
387
+
388
+ /** "Sera'ya gonder": acik yorumlari gonderildi yapar. Idler verilmezse hepsi. */
389
+ export function gonder(kok: string, idler?: string[]): Yorum[] {
390
+ const tum = yorumlariOku(kok);
391
+ const gidenler: Yorum[] = [];
392
+ for (const y of tum) {
393
+ if (y.durum === "acik" && (!idler || idler.includes(y.id))) {
394
+ y.durum = "gonderildi";
395
+ gidenler.push(y);
396
+ }
397
+ }
398
+ if (gidenler.length) yorumlariYaz(kok, tum);
399
+ return gidenler;
400
+ }
401
+
402
+ /** Ajan icin: "gonderildi" yorumlari "alindi" yapip dondurur (bir kez teslim). */
403
+ export function alinacaklar(kok: string): Yorum[] {
404
+ const tum = yorumlariOku(kok);
405
+ const alinan = tum.filter((y) => y.durum === "gonderildi");
406
+ if (alinan.length) {
407
+ for (const y of alinan) y.durum = "alindi";
408
+ yorumlariYaz(kok, tum);
409
+ }
410
+ return alinan;
411
+ }
412
+
413
+ export function yanitla(
414
+ kok: string,
415
+ id: string,
416
+ metin: string,
417
+ cozuldu: boolean,
418
+ yazar: "sera" | "insan" = "sera",
419
+ ad?: string,
420
+ ): Yorum {
421
+ const tum = yorumlariOku(kok);
422
+ const y = tum.find((x) => x.id === id);
423
+ if (!y) throw new Error(`Yorum yok: ${id}`);
424
+ const m = kisalt(metin, 4000).trim();
425
+ if (!m && !cozuldu) throw new Error("Yanit metni bos.");
426
+ if (m) y.yanitlar.push({ yazar, metin: m, zaman: now(), ...(ad ? { ad: kisalt(ad, 40) } : {}) });
427
+ if (cozuldu) y.durum = "cozuldu";
428
+ else if (yazar === "insan" && (y.durum === "cozuldu" || y.durum === "alindi")) y.durum = "acik"; // kullanici yeniden yazdi: tekrar gonderilebilir
429
+ yorumlariYaz(kok, tum);
430
+ return y;
431
+ }
432
+
433
+ export function yorumSil(kok: string, id: string): void {
434
+ yorumlariYaz(
435
+ kok,
436
+ yorumlariOku(kok).filter((y) => y.id !== id),
437
+ );
438
+ }
439
+
440
+ // ---------------------------------------------------------------- surum gecmisi
441
+
442
+ const GIDX = (kok: string) => join(kok, GECMIS, "index.json");
443
+ export function surumleriOku(kok: string): Surum[] {
444
+ const d = jsonOku<{ surumler?: Surum[] }>(GIDX(kok), {});
445
+ return Array.isArray(d.surumler) ? d.surumler : [];
446
+ }
447
+
448
+ const kimliksiz = (s: string) => s.replace(/ data-tuval-id=(?:"[^"]*"|'[^']*')/g, "");
449
+
450
+ function surumDosya(kok: string, n: number, art: string): string {
451
+ return join(kok, GECMIS, `${String(n).padStart(4, "0")}-${art}.html`);
452
+ }
453
+
454
+ /**
455
+ * Artboard'in guncel icerigi son kayitli surumden farkliysa yeni surum yazar (kim: degisikligi yapan).
456
+ * Ajanin dogrudan dosyaya yazdigi degisiklikleri de yakalamak icin sunucu/arac her acilista cagirir.
457
+ */
458
+ export function surumKaydet(
459
+ kok: string,
460
+ a: Artboard,
461
+ kim: "insan" | "sera",
462
+ not?: string,
463
+ ad?: string,
464
+ ): Surum | undefined {
465
+ const metin = artboardOku(kok, a);
466
+ const h = hashOf(metin);
467
+ const liste = surumleriOku(kok);
468
+ const son = [...liste].reverse().find((s) => s.artboard === a.id && !s.yan);
469
+ if (son && son.hash === h) return undefined;
470
+ if (son) {
471
+ // Yalniz kalici oge kimligi (data-tuval-id) atandiysa yeni surum acma: son surumun icerigini kimlikli haliyle tazele.
472
+ let onceki: string | undefined;
473
+ try {
474
+ onceki = readFileSync(surumDosya(kok, son.n, a.id), "utf8");
475
+ } catch {
476
+ onceki = undefined;
477
+ }
478
+ if (onceki !== undefined && kimliksiz(onceki) === kimliksiz(metin)) {
479
+ atomikYaz(surumDosya(kok, son.n, a.id), metin);
480
+ son.hash = h;
481
+ son.boyut = Buffer.byteLength(metin);
482
+ atomikYaz(
483
+ GIDX(kok),
484
+ `${JSON.stringify({ surum: 1, surumler: liste }, null, 2)}
485
+ `,
486
+ );
487
+ return undefined;
488
+ }
489
+ }
490
+ const n = (liste.length ? liste[liste.length - 1]!.n : 0) + 1;
491
+ atomikYaz(surumDosya(kok, n, a.id), metin);
492
+ const s: Surum = {
493
+ n,
494
+ artboard: a.id,
495
+ kim,
496
+ zaman: now(),
497
+ hash: h,
498
+ boyut: Buffer.byteLength(metin),
499
+ ...(not ? { not } : {}),
500
+ ...(ad ? { ad } : {}),
501
+ };
502
+ liste.push(s);
503
+ atomikYaz(GIDX(kok), `${JSON.stringify({ surum: 1, surumler: liste }, null, 2)}\n`);
504
+ return s;
505
+ }
506
+
507
+ /**
508
+ * Dosyaya UYGULANMAYAN bir metni gecmise yazar (cakismada ya da birlesmede gelen metin sessizce kaybolmasin).
509
+ * Yan surum, "son surum" karsilastirmasina girmez; geri yuklenebilir.
510
+ */
511
+ export function yanSurumYaz(kok: string, a: Artboard, metin: string, not: string, ad?: string): Surum {
512
+ const liste = surumleriOku(kok);
513
+ const n = (liste.length ? liste[liste.length - 1]!.n : 0) + 1;
514
+ atomikYaz(surumDosya(kok, n, a.id), metin);
515
+ const s: Surum = {
516
+ n,
517
+ artboard: a.id,
518
+ kim: "insan",
519
+ zaman: now(),
520
+ hash: hashOf(metin),
521
+ boyut: Buffer.byteLength(metin),
522
+ not,
523
+ yan: true,
524
+ ...(ad ? { ad } : {}),
525
+ };
526
+ liste.push(s);
527
+ atomikYaz(GIDX(kok), `${JSON.stringify({ surum: 1, surumler: liste }, null, 2)}\n`);
528
+ return s;
529
+ }
530
+
531
+ /** Artboard'in su anki dosya icerigi ozeti (istemci "taban" karsilastirmasi icin). */
532
+ export function artboardHash(kok: string, a: Artboard): string {
533
+ return hashOf(artboardOku(kok, a));
534
+ }
535
+
536
+ /** Tum artboardlari esitler; dosyada kayitsiz degisiklik varsa `kim` adina surum acar. */
537
+ export function senkronla(kok: string, kim: "insan" | "sera"): Surum[] {
538
+ const b = bildirimOku(kok);
539
+ const yeni: Surum[] = [];
540
+ for (const a of b.artboardlar) {
541
+ if (!existsSync(join(kok, a.dosya))) continue;
542
+ const ilk = !surumleriOku(kok).some((x) => x.artboard === a.id);
543
+ const s = surumKaydet(kok, a, kim, ilk ? "ilk surum" : undefined);
544
+ if (s) yeni.push(s);
545
+ }
546
+ return yeni;
547
+ }
548
+
549
+ export function surumIcerik(kok: string, n: number): { surum: Surum; metin: string } {
550
+ const s = surumleriOku(kok).find((x) => x.n === n);
551
+ if (!s) throw new Error(`Surum yok: ${n}`);
552
+ return { surum: s, metin: readFileSync(surumDosya(kok, n, s.artboard), "utf8") };
553
+ }
554
+
555
+ /** Eski surumu geri yukler: dosya yeniden yazilir ve YENI surum olarak kaydedilir (gecmis silinmez). */
556
+ export function geriYukle(kok: string, n: number, kim: "insan" | "sera"): Surum {
557
+ const { surum, metin } = surumIcerik(kok, n);
558
+ const b = bildirimOku(kok);
559
+ const a = artboardBul(b, surum.artboard);
560
+ // Mevcut hali kayitsizsa once onu koru.
561
+ surumKaydet(kok, a, "sera", "geri yuklemeden onceki hal");
562
+ atomikYaz(kokIci(kok, a.dosya), metin);
563
+ const yeni = surumKaydet(kok, a, kim, `v${n} geri yuklendi`);
564
+ if (yeni) return yeni;
565
+ // Icerik son surumle ayniysa (zaten o hal): son surumu dondur.
566
+ return [...surumleriOku(kok)].reverse().find((s) => s.artboard === a.id)!;
567
+ }
568
+
569
+ /** Insan duzenlemesi: artboard dosyasini yazar, surum acar. */
570
+ export function artboardKaydet(
571
+ kok: string,
572
+ id: string,
573
+ html: string,
574
+ kim: "insan" | "sera" = "insan",
575
+ ad?: string,
576
+ ): Surum | undefined {
577
+ const b = bildirimOku(kok);
578
+ if (URETILEN.includes(b.tur))
579
+ throw new Error("Bu proje turunde sayfa elle duzenlenemez (icerik veriden/belirtecten uretilir).");
580
+ const a = artboardBul(b, id);
581
+ if (html.length > 8_000_000) throw new Error("Dosya cok buyuk.");
582
+ surumKaydet(kok, a, "sera", "insan duzenlemesinden onceki hal");
583
+ atomikYaz(kokIci(kok, a.dosya), html);
584
+ return surumKaydet(kok, a, kim, "elle duzenleme", ad);
585
+ }
586
+
587
+ /** Canli yenileme icin degisim imzasi (bildirim + artboardlar + yorumlar mtime). */
588
+ export function dosyaDegisimi(kok: string): string {
589
+ const parca: string[] = [];
590
+ try {
591
+ const b = bildirimOku(kok);
592
+ parca.push(String(statSync(join(kok, BILDIRIM)).mtimeMs));
593
+ for (const a of b.artboardlar) {
594
+ try {
595
+ parca.push(`${a.id}:${statSync(join(kok, a.dosya)).mtimeMs}`);
596
+ } catch {
597
+ parca.push(`${a.id}:-`);
598
+ }
599
+ }
600
+ try {
601
+ parca.push(`y:${statSync(join(kok, YORUMLAR)).mtimeMs}`);
602
+ } catch {
603
+ // yorum dosyasi henuz yok
604
+ }
605
+ for (const ek of ["pano.json", "tasarim-sistemi.json"]) {
606
+ try {
607
+ parca.push(`${ek}:${statSync(join(kok, ek)).mtimeMs}`);
608
+ } catch {
609
+ // yok
610
+ }
611
+ }
612
+ try {
613
+ for (const f of readdirSync(join(kok, "veri"))) parca.push(`v:${f}:${statSync(join(kok, "veri", f)).mtimeMs}`);
614
+ } catch {
615
+ // veri klasoru yok
616
+ }
617
+ if (b.sistem) {
618
+ try {
619
+ parca.push(`s:${statSync(join(resolve(kok, b.sistem), "tasarim-sistemi.json")).mtimeMs}`);
620
+ } catch {
621
+ // sistem dosyasi okunamadi
622
+ }
623
+ }
624
+ } catch {
625
+ // bildirim okunamadi
626
+ }
627
+ return parca.join("|");
628
+ }
629
+
630
+ // ---------------------------------------------------------------- artboard ekle / sil / sirala
631
+
632
+ const BOS_SAYFA = (ad: string, deste: boolean) =>
633
+ `<!doctype html>
634
+ <html lang="tr"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
635
+ <title>${ad.replace(/[<&]/g, "")}</title>
636
+ <style>:root{--zemin:#faf8f4;--metin:#1c1b19;--vurgu:#1f5f4a}body{margin:0;background:var(--zemin);color:var(--metin);font-family:system-ui,sans-serif${deste ? ";width:1920px;height:1080px" : ""}}main{padding:${deste ? "96px" : "40px 24px"}}h1{font-size:${deste ? "88px" : "2.25rem"};margin:0 0 16px}p{font-size:${deste ? "40px" : "1.125rem"};margin:0}</style></head>
637
+ <body><main id="icerik"><h1>${ad.replace(/[<&]/g, "")}</h1><p>Buraya yazin.</p></main></body></html>
638
+ `;
639
+
640
+ function bosId(b: Bildirim, temel: string): string {
641
+ const ids = new Set(b.artboardlar.map((a) => a.id));
642
+ for (let i = 1; i < 1000; i++) {
643
+ const id = `${temel}${i}`;
644
+ if (!ids.has(id)) return id;
645
+ }
646
+ return yeniId(temel);
647
+ }
648
+
649
+ function bildirimYaz(kok: string, b: Bildirim): void {
650
+ atomikYaz(join(kok, BILDIRIM), `${JSON.stringify(dogrula(b), null, 2)}\n`);
651
+ }
652
+
653
+ /** Film: bir sahnenin suresini (sn) ayarlar; sinirlara kirpilir, bildirim guncellenir. */
654
+ export function filmSureAyarla(kok: string, id: string, sure: number): Bildirim {
655
+ const b = bildirimOku(kok);
656
+ if (b.tur !== "film") throw new Error("Bu proje bir film degil.");
657
+ artboardBul(b, id);
658
+ if (!Number.isFinite(sure)) throw new Error("Sure bir sayi olmali.");
659
+ const f = b.film ?? filmDogrula({}, b.artboardlar);
660
+ bildirimYaz(kok, { ...b, film: { ...f, sureler: { ...f.sureler, [id]: sure } } });
661
+ return bildirimOku(kok);
662
+ }
663
+
664
+ /** Yeni sayfa/slayt ekler. `kopya` verilirse o artboard'in icerigi kopyalanir; aksi halde bos iskelet. */
665
+ export function artboardEkle(
666
+ kok: string,
667
+ girdi: { ad?: string; kopya?: string; genislik?: number; yukseklik?: number; sonra?: string },
668
+ ): Artboard {
669
+ const b = bildirimOku(kok);
670
+ if (URETILEN.includes(b.tur))
671
+ throw new Error("Bu proje turunde sayfa eklenemez (icerik veriden/belirtecten uretilir).");
672
+ const deste = b.tur === "deste" || b.tur === "film";
673
+ const film = b.tur === "film";
674
+ const id = bosId(b, film ? "sahne" : deste ? "s" : "sayfa");
675
+ const kaynak = girdi.kopya ? artboardBul(b, girdi.kopya) : undefined;
676
+ const ad =
677
+ kisalt(girdi.ad, 60).trim() ||
678
+ (deste ? `Slayt ${b.artboardlar.length + 1}` : `Sayfa ${b.artboardlar.length + 1}`);
679
+ const belge = b.tur === "belge";
680
+ const g = Number(girdi.genislik ?? kaynak?.genislik ?? (deste ? SLAYT_G : belge ? BELGE_G : 1440));
681
+ const y = Number(girdi.yukseklik ?? kaynak?.yukseklik ?? (deste ? SLAYT_Y : belge ? BELGE_Y : 900));
682
+ const a: Artboard = { id, ad, dosya: `${id}.html`, genislik: g, yukseklik: y };
683
+ dogrula({ ...b, artboardlar: [...b.artboardlar, a] }); // boyut vb. denetimi
684
+ atomikYaz(
685
+ kokIci(kok, a.dosya),
686
+ kaynak
687
+ ? artboardOku(kok, kaynak)
688
+ : film
689
+ ? sahneIskeleti(ad, FILM_SURE_VARSAYILAN)
690
+ : belge
691
+ ? belgeSayfasi(ad, [])
692
+ : BOS_SAYFA(ad, deste),
693
+ );
694
+ const liste = [...b.artboardlar];
695
+ const konum = girdi.sonra ? liste.findIndex((x) => x.id === girdi.sonra) : -1;
696
+ liste.splice(konum >= 0 ? konum + 1 : liste.length, 0, a);
697
+ bildirimYaz(kok, { ...b, artboardlar: liste });
698
+ surumKaydet(kok, a, "insan", kaynak ? `${kaynak.id} kopyalandi` : "yeni sayfa");
699
+ return a;
700
+ }
701
+
702
+ /** Artboard'i projeden cikarir; dosya `silinen/` klasorune tasinir (gecmis surumler korunur). En az bir artboard kalmali. */
703
+ export function artboardSil(kok: string, id: string): void {
704
+ const b = bildirimOku(kok);
705
+ if (URETILEN.includes(b.tur)) throw new Error("Bu proje turunde sayfa silinemez.");
706
+ const a = artboardBul(b, id);
707
+ if (b.artboardlar.length <= 1) throw new Error("Son sayfa silinemez.");
708
+ surumKaydet(kok, a, "sera", "silinmeden onceki hal");
709
+ const hedef = kokIci(kok, join("silinen", `${Date.now()}-${a.dosya.replace(/[\\/]/g, "_")}`));
710
+ mkdirSync(dirname(hedef), { recursive: true });
711
+ renameSync(kokIci(kok, a.dosya), hedef);
712
+ bildirimYaz(kok, { ...b, artboardlar: b.artboardlar.filter((x) => x.id !== id) });
713
+ yorumlariYaz(
714
+ kok,
715
+ yorumlariOku(kok).filter((y) => y.artboard !== id),
716
+ );
717
+ }
718
+
719
+ /** Yeni sira: mevcut id'lerin birebir permutasyonu olmali. */
720
+ export function artboardSirala(kok: string, idler: string[]): Bildirim {
721
+ const b = bildirimOku(kok);
722
+ const mevcut = b.artboardlar.map((a) => a.id).sort();
723
+ if (idler.length !== mevcut.length || [...idler].sort().join("|") !== mevcut.join("|"))
724
+ throw new Error("Sira, projedeki tum sayfalari tam olarak bir kez icermeli.");
725
+ const yeni = { ...b, artboardlar: idler.map((i) => artboardBul(b, i)) };
726
+ bildirimYaz(kok, yeni);
727
+ return yeni;
728
+ }