sera-code 0.0.0-stage → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (457) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE-SERA.md +33 -0
  3. package/README.md +27 -2
  4. package/THIRD_PARTY_NOTICES.md +68 -0
  5. package/bin/sera.mjs +145 -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-6QGV3IWD.js +6 -0
  15. package/dist/bundle/chunks/chunk-7CBJINYJ.js +20 -0
  16. package/dist/bundle/chunks/chunk-7DDKXS2Q.js +2 -0
  17. package/dist/bundle/chunks/chunk-7RZ5BS7U.js +2 -0
  18. package/dist/bundle/chunks/chunk-7ZC4UXSL.js +2 -0
  19. package/dist/bundle/chunks/chunk-AZC5WTED.js +1222 -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-HODJBMOY.js +9 -0
  26. package/dist/bundle/chunks/chunk-HQBQWHLD.js +7 -0
  27. package/dist/bundle/chunks/chunk-HQJBN2MC.js +2 -0
  28. package/dist/bundle/chunks/chunk-JXWJOIH4.js +2 -0
  29. package/dist/bundle/chunks/chunk-KXU77PUU.js +4 -0
  30. package/dist/bundle/chunks/chunk-L2ZPNLYD.js +2 -0
  31. package/dist/bundle/chunks/chunk-LOMPDCMP.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-Z2V3PTLI.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 +377 -0
  181. package/lib/provider.js +71 -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 +2410 -0
  383. package/sera-core/src/fs-tools.ts +448 -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/model-list.ts +108 -0
  412. package/sera-core/src/no-progress.ts +177 -0
  413. package/sera-core/src/notebook-tool.ts +179 -0
  414. package/sera-core/src/ofis.ts +473 -0
  415. package/sera-core/src/path-guard.ts +139 -0
  416. package/sera-core/src/permission-bridge.ts +228 -0
  417. package/sera-core/src/policy-chain.ts +122 -0
  418. package/sera-core/src/pricing.ts +71 -0
  419. package/sera-core/src/proc.ts +149 -0
  420. package/sera-core/src/rea.ts +188 -0
  421. package/sera-core/src/repo-map.ts +230 -0
  422. package/sera-core/src/research.ts +347 -0
  423. package/sera-core/src/rules-memory.ts +227 -0
  424. package/sera-core/src/sandbox.ts +476 -0
  425. package/sera-core/src/server-error.ts +78 -0
  426. package/sera-core/src/skills.ts +268 -0
  427. package/sera-core/src/snapshot.ts +143 -0
  428. package/sera-core/src/spec-gate.ts +112 -0
  429. package/sera-core/src/subagent.ts +261 -0
  430. package/sera-core/src/teslim.ts +121 -0
  431. package/sera-core/src/test-fix.ts +184 -0
  432. package/sera-core/src/todo-question.ts +163 -0
  433. package/sera-core/src/turn-snapshots.ts +126 -0
  434. package/sera-core/src/tuval/arac.ts +338 -0
  435. package/sera-core/src/tuval/arsiv.ts +106 -0
  436. package/sera-core/src/tuval/belge.ts +216 -0
  437. package/sera-core/src/tuval/birlestir.ts +282 -0
  438. package/sera-core/src/tuval/disa.ts +235 -0
  439. package/sera-core/src/tuval/editor.ts +583 -0
  440. package/sera-core/src/tuval/film-cekirdek.ts +170 -0
  441. package/sera-core/src/tuval/film-disa.ts +188 -0
  442. package/sera-core/src/tuval/film-oynatici.ts +307 -0
  443. package/sera-core/src/tuval/kimlik.ts +156 -0
  444. package/sera-core/src/tuval/pano.ts +763 -0
  445. package/sera-core/src/tuval/proje.ts +728 -0
  446. package/sera-core/src/tuval/sistem-cekirdek.ts +167 -0
  447. package/sera-core/src/tuval/sistem.ts +328 -0
  448. package/sera-core/src/tuval/sunucu.ts +413 -0
  449. package/sera-core/src/tuval/uretim.ts +24 -0
  450. package/sera-core/src/tuval/veri-cekirdek.ts +477 -0
  451. package/sera-core/src/tuval/xlsx.ts +215 -0
  452. package/sera-core/src/tuval/zip.ts +163 -0
  453. package/sera-core/src/untrusted.ts +201 -0
  454. package/sera-core/src/video-edit-tool.ts +411 -0
  455. package/sera-core/src/video-tool.ts +217 -0
  456. package/sera-core/src/web-tools.ts +257 -0
  457. package/sera-core/src/zk.ts +104 -0
@@ -0,0 +1,448 @@
1
+ /**
2
+ * Saf Node dosya tarama araclari: `glob`, `grep`, `ls` (Claude Code Glob/Grep/LS karsiligi). Disaridan ikili (rg/fd/bash)
3
+ * GEREKTIRMEZ: Windows'ta da ayni calisir, internet/indirme yok. Motorun yerlesik `grep`/`find`/`ls` araclari rg/fd'yi
4
+ * indirmeye calisir ve varsayilan olarak etkin degildir; bunlar dogrudan (direct) kayitli oldugu icin her oturumda hazirdir.
5
+ * `grep` ve `ls` adlari yerlesiklerin ustune yazar (uzanti ayni ada kayit edince yerlesigin yerine gecer).
6
+ */
7
+
8
+ import { type Dirent, readFileSync, statSync } from "node:fs";
9
+ import { opendir, readFile, stat } from "node:fs/promises";
10
+ import { isAbsolute, join, resolve } from "node:path";
11
+ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
12
+ import { Type } from "typebox";
13
+ import { rareExposure } from "./exposure.ts";
14
+
15
+ /** Her zaman atlanan dizinler (depo/bagimlilik/uretim cikti gurultusu). */
16
+ // 2026-11-12 (sahip: "iki satir ilerliyor sonra donup kaliyor"): derleme ciktisi/onbellek klasorleri de atlanir; dev agacta
17
+ // arama dakikalarca suruyordu.
18
+ export const ALWAYS_SKIP_DIRS = new Set([
19
+ ".git",
20
+ "node_modules",
21
+ ".hg",
22
+ ".svn",
23
+ ".turbo",
24
+ ".next",
25
+ ".cache",
26
+ "dist",
27
+ "coverage",
28
+ ]);
29
+ /** Bir arama (glob/grep) en fazla bu kadar surer; dolunca o ana kadar bulunanlar "daha dar yol ver" notuyla doner. */
30
+ export const SCAN_TIME_LIMIT_MS = Number(process.env.SERA_SCAN_TIME_MS ?? 20_000);
31
+ const MAX_FILE_BYTES = 5 * 1024 * 1024;
32
+ const MAX_OUT_BYTES = 30 * 1024;
33
+ const MAX_LINE_CHARS = 500;
34
+ const DEFAULT_GLOB_LIMIT = 200;
35
+ const DEFAULT_GREP_LIMIT = 100;
36
+ const DEFAULT_LS_LIMIT = 500;
37
+ const SCAN_FILE_CAP = 50_000;
38
+
39
+ /** Glob deseni -> RegExp. `**`, `*`, `?`, `{a,b}`, `[abc]` desteklenir. Bosluk/`\` yol ayiracı `/` kabul edilir. */
40
+ export function globToRegExp(glob: string): RegExp {
41
+ const g = glob.replace(/\\/g, "/");
42
+ let re = "";
43
+ let i = 0;
44
+ let braces = 0;
45
+ while (i < g.length) {
46
+ const c = g[i]!;
47
+ if (c === "*") {
48
+ if (g[i + 1] === "*") {
49
+ // "**/" = sifir ya da daha cok dizin; sonda "**" = her sey
50
+ if (g[i + 2] === "/") {
51
+ re += "(?:.*/)?";
52
+ i += 3;
53
+ } else {
54
+ re += ".*";
55
+ i += 2;
56
+ }
57
+ } else {
58
+ re += "[^/]*";
59
+ i++;
60
+ }
61
+ } else if (c === "?") {
62
+ re += "[^/]";
63
+ i++;
64
+ } else if (c === "{") {
65
+ braces++;
66
+ re += "(?:";
67
+ i++;
68
+ } else if (c === "}" && braces > 0) {
69
+ braces--;
70
+ re += ")";
71
+ i++;
72
+ } else if (c === "," && braces > 0) {
73
+ re += "|";
74
+ i++;
75
+ } else if (c === "[") {
76
+ const close = g.indexOf("]", i + 2);
77
+ if (close < 0) {
78
+ re += "\\[";
79
+ i++;
80
+ } else {
81
+ let body = g.slice(i + 1, close);
82
+ if (body.startsWith("!")) body = `^${body.slice(1)}`;
83
+ re += `[${body.replace(/\\/g, "\\\\")}]`;
84
+ i = close + 1;
85
+ }
86
+ } else {
87
+ re += c.replace(/[.+^$()|\\]/g, "\\$&");
88
+ i++;
89
+ }
90
+ }
91
+ return new RegExp(`^${re}$`, process.platform === "win32" ? "i" : "");
92
+ }
93
+
94
+ /** Desen `/` icermiyorsa taban ada (her derinlikte), icerirse tam goreli yola uygulanir. */
95
+ export function globMatcher(glob: string): (relPath: string) => boolean {
96
+ const g = glob.replace(/\\/g, "/").replace(/^\.\//, "");
97
+ const re = globToRegExp(g);
98
+ if (g.includes("/")) return (p) => re.test(p);
99
+ return (p) => re.test(p.slice(p.lastIndexOf("/") + 1));
100
+ }
101
+
102
+ /** Kok .gitignore'unun basit alt kumesi (olumsuzlama/ic ice dosya yok): her satir bir glob; "x/" yalniz dizin. */
103
+ export function loadGitignore(root: string): ((relPath: string, isDir: boolean) => boolean) | undefined {
104
+ let text: string;
105
+ try {
106
+ text = readFileSync(join(root, ".gitignore"), "utf8");
107
+ } catch {
108
+ return undefined;
109
+ }
110
+ const rules: { m: (p: string) => boolean; dirOnly: boolean }[] = [];
111
+ for (const raw of text.split(/\r?\n/)) {
112
+ const line = raw.trim();
113
+ if (!line || line.startsWith("#") || line.startsWith("!")) continue;
114
+ const dirOnly = line.endsWith("/");
115
+ const pat = (dirOnly ? line.slice(0, -1) : line).replace(/^\//, "");
116
+ if (!pat) continue;
117
+ // "/" iceren desen tam goreli yola, icermeyen taban ada uygulanir (globMatcher bunu kendisi ayirir).
118
+ rules.push({ m: globMatcher(pat), dirOnly });
119
+ }
120
+ if (!rules.length) return undefined;
121
+ return (rel, isDir) => rules.some((r) => (!r.dirOnly || isDir) && r.m(rel));
122
+ }
123
+
124
+ export interface WalkOpts {
125
+ /** .gitignore kurallarina uy (varsayilan true). */
126
+ gitignore?: boolean;
127
+ signal?: AbortSignal;
128
+ /** Bu zamandan (Date.now) sonra gezinti durur ve onStop cagrilir. */
129
+ deadline?: number;
130
+ /** Zaman ya da dosya siniri dolunca bir kez cagrilir. */
131
+ onStop?: () => void;
132
+ }
133
+
134
+ /** Dizini yinelemeli gezer; her dosya icin kokten goreli (`/`) yol uretir. Sirasi: ada gore (dizin once degil, kararli). */
135
+ export async function* walkFiles(root: string, opts: WalkOpts = {}): AsyncGenerator<string> {
136
+ const ignored = opts.gitignore === false ? undefined : loadGitignore(root);
137
+ let count = 0;
138
+ let halted = false;
139
+ const halt = () => {
140
+ if (!halted) {
141
+ halted = true;
142
+ opts.onStop?.();
143
+ }
144
+ };
145
+ async function* rec(abs: string, rel: string): AsyncGenerator<string> {
146
+ if (opts.signal?.aborted) throw new Error("Operation aborted");
147
+ if (halted) return;
148
+ if (opts.deadline !== undefined && Date.now() > opts.deadline) return halt();
149
+ let entries: Dirent[];
150
+ try {
151
+ const dir = await opendir(abs);
152
+ entries = [];
153
+ for await (const e of dir) entries.push(e);
154
+ } catch {
155
+ return;
156
+ }
157
+ entries.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));
158
+ for (const e of entries) {
159
+ const r = rel ? `${rel}/${e.name}` : e.name;
160
+ if (e.isDirectory()) {
161
+ if (ALWAYS_SKIP_DIRS.has(e.name) || ignored?.(r, true)) continue;
162
+ yield* rec(join(abs, e.name), r);
163
+ } else if (e.isFile() || e.isSymbolicLink()) {
164
+ if (ignored?.(r, false)) continue;
165
+ if (++count > SCAN_FILE_CAP) return halt();
166
+ yield r;
167
+ }
168
+ }
169
+ }
170
+ yield* rec(root, "");
171
+ }
172
+
173
+ function capText(text: string): string {
174
+ if (Buffer.byteLength(text) <= MAX_OUT_BYTES) return text;
175
+ return `${Buffer.from(text).subarray(0, MAX_OUT_BYTES).toString("utf8")}\n[cikti ${MAX_OUT_BYTES / 1024}KB'ta kesildi; deseni/yolu daralt]`;
176
+ }
177
+
178
+ function resolveIn(cwd: string, p: string | undefined): string {
179
+ const raw = (p ?? "").trim();
180
+ if (!raw || raw === ".") return resolve(cwd);
181
+ return isAbsolute(raw) ? resolve(raw) : resolve(cwd, raw);
182
+ }
183
+
184
+ const out = (text: string, details?: unknown) => ({
185
+ content: [{ type: "text" as const, text }],
186
+ details: details as undefined,
187
+ });
188
+
189
+ async function requireDir(abs: string, shown: string): Promise<void> {
190
+ let st: Awaited<ReturnType<typeof stat>>;
191
+ try {
192
+ st = await stat(abs);
193
+ } catch {
194
+ throw new Error(`Yol yok: ${shown}. Once ls ile ust dizini kontrol et.`);
195
+ }
196
+ if (!st.isDirectory()) throw new Error(`Bu bir dizin degil: ${shown}`);
197
+ }
198
+
199
+ export interface GlobResult {
200
+ files: string[];
201
+ truncated: boolean;
202
+ /** Zaman/dosya siniri doldu: sonuclar eksik olabilir. */
203
+ timedOut?: boolean;
204
+ }
205
+
206
+ /** Desene uyan dosyalar, en yeni degisen once. */
207
+ export async function globFiles(
208
+ root: string,
209
+ pattern: string,
210
+ limit = DEFAULT_GLOB_LIMIT,
211
+ signal?: AbortSignal,
212
+ ): Promise<GlobResult> {
213
+ const match = globMatcher(pattern);
214
+ const hits: { p: string; t: number }[] = [];
215
+ let timedOut = false;
216
+ for await (const rel of walkFiles(root, {
217
+ signal,
218
+ deadline: Date.now() + SCAN_TIME_LIMIT_MS,
219
+ onStop: () => {
220
+ timedOut = true;
221
+ },
222
+ })) {
223
+ if (!match(rel)) continue;
224
+ let t = 0;
225
+ try {
226
+ t = statSync(join(root, rel)).mtimeMs;
227
+ } catch {
228
+ /* silinmis olabilir */
229
+ }
230
+ hits.push({ p: rel, t });
231
+ }
232
+ hits.sort((a, b) => b.t - a.t || (a.p < b.p ? -1 : 1));
233
+ return { files: hits.slice(0, limit).map((h) => h.p), truncated: hits.length > limit, timedOut };
234
+ }
235
+
236
+ export interface GrepOpts {
237
+ pattern: string;
238
+ glob?: string;
239
+ ignoreCase?: boolean;
240
+ literal?: boolean;
241
+ context?: number;
242
+ limit?: number;
243
+ mode?: "content" | "files" | "count";
244
+ signal?: AbortSignal;
245
+ }
246
+
247
+ export async function grepPath(
248
+ target: string,
249
+ shown: string,
250
+ o: GrepOpts,
251
+ ): Promise<{ text: string; matches: number; files: number }> {
252
+ const limit = Math.max(1, o.limit ?? DEFAULT_GREP_LIMIT);
253
+ const ctxN = Math.max(0, Math.min(10, o.context ?? 0));
254
+ const mode = o.mode ?? "content";
255
+ let re: RegExp;
256
+ try {
257
+ re = new RegExp(
258
+ o.literal ? o.pattern.replace(/[.*+?^${}()|[\]\\]/g, "\\$&") : o.pattern,
259
+ o.ignoreCase ? "i" : "",
260
+ );
261
+ } catch (e) {
262
+ throw new Error(
263
+ `Gecersiz duzenli ifade: ${e instanceof Error ? e.message : String(e)} (duz metin icin literal=true)`,
264
+ );
265
+ }
266
+ const st = await stat(target).catch(() => undefined);
267
+ if (!st) throw new Error(`Yol yok: ${shown}. Once ls ile ust dizini kontrol et.`);
268
+ const isDir = st.isDirectory();
269
+ const root = isDir ? target : resolve(target, "..");
270
+ const globOk = o.glob ? globMatcher(o.glob) : undefined;
271
+ const lines: string[] = [];
272
+ let matches = 0;
273
+ let filesHit = 0;
274
+ let stopped = false;
275
+ let timedOut = false;
276
+
277
+ const files: AsyncIterable<string> | string[] = isDir
278
+ ? walkFiles(target, {
279
+ signal: o.signal,
280
+ deadline: Date.now() + SCAN_TIME_LIMIT_MS,
281
+ onStop: () => {
282
+ timedOut = true;
283
+ },
284
+ })
285
+ : [target.slice(root.length + 1)];
286
+ for await (const rel of files) {
287
+ if (globOk && !globOk(rel)) continue;
288
+ const abs = isDir ? join(target, rel) : target;
289
+ let buf: Buffer;
290
+ try {
291
+ const s = await stat(abs);
292
+ if (s.size > MAX_FILE_BYTES) continue;
293
+ buf = await readFile(abs);
294
+ } catch {
295
+ continue;
296
+ }
297
+ if (buf.subarray(0, 8000).includes(0)) continue; // ikili dosya
298
+ const text = buf.toString("utf8").replace(/\r\n/g, "\n");
299
+ const all = text.split("\n");
300
+ const hitIdx: number[] = [];
301
+ for (let i = 0; i < all.length; i++) if (re.test(all[i]!)) hitIdx.push(i);
302
+ if (!hitIdx.length) continue;
303
+ filesHit++;
304
+ const shownRel = isDir ? rel : shown;
305
+ if (mode === "files") {
306
+ lines.push(shownRel);
307
+ if (filesHit >= limit) {
308
+ stopped = true;
309
+ break;
310
+ }
311
+ continue;
312
+ }
313
+ if (mode === "count") {
314
+ lines.push(`${shownRel}:${hitIdx.length}`);
315
+ matches += hitIdx.length;
316
+ if (filesHit >= limit) {
317
+ stopped = true;
318
+ break;
319
+ }
320
+ continue;
321
+ }
322
+ const shownLines = new Set<number>();
323
+ for (const i of hitIdx) {
324
+ if (matches >= limit) {
325
+ stopped = true;
326
+ break;
327
+ }
328
+ matches++;
329
+ for (let k = Math.max(0, i - ctxN); k <= Math.min(all.length - 1, i + ctxN); k++) shownLines.add(k);
330
+ }
331
+ let prev = -2;
332
+ for (const k of [...shownLines].sort((a, b) => a - b)) {
333
+ if (ctxN > 0 && prev >= 0 && k !== prev + 1) lines.push("--");
334
+ const raw = all[k]!;
335
+ const body = raw.length > MAX_LINE_CHARS ? `${raw.slice(0, MAX_LINE_CHARS)}...` : raw;
336
+ lines.push(`${shownRel}${hitIdx.includes(k) ? ":" : "-"}${k + 1}${hitIdx.includes(k) ? ":" : "-"} ${body}`);
337
+ prev = k;
338
+ }
339
+ if (stopped) break;
340
+ }
341
+ const slow = timedOut
342
+ ? `\n[arama ${SCAN_TIME_LIMIT_MS / 1000} sn sinirinda durdu, sonuclar eksik olabilir: path ile daha dar bir klasor ver]`
343
+ : "";
344
+ if (!lines.length) return { text: `Eslesme yok.${slow}`, matches: 0, files: 0 };
345
+ const tail = (stopped ? `\n[ilk ${limit} sonuc; limit arttir ya da deseni/yolu daralt]` : "") + slow;
346
+ return { text: capText(lines.join("\n")) + tail, matches, files: filesHit };
347
+ }
348
+
349
+ export function registerFsTools(pi: ExtensionAPI): void {
350
+ pi.registerTool({
351
+ name: "glob",
352
+ label: "Glob",
353
+ description:
354
+ "Dosyalari glob desenine gore bulur (ornek '**/*.ts'); en yeni once. .gitignore/node_modules atlanir; find yerine bunu kullan.",
355
+ promptSnippet: "Dosyalari glob desenine gore bul (ornek '**/*.ts'); bash find yerine bunu kullan",
356
+ parameters: Type.Object({
357
+ pattern: Type.String({
358
+ description: "Desen; '/' yoksa her derinlikte dosya adina uyar",
359
+ }),
360
+ path: Type.Optional(Type.String({ description: "Dizin (varsayilan cwd)" })),
361
+ limit: Type.Optional(Type.Number({ description: `En fazla sonuc (varsayilan ${DEFAULT_GLOB_LIMIT})` })),
362
+ }),
363
+ async execute(_id, params, signal, _u, ctx) {
364
+ const p = params as { pattern: string; path?: string; limit?: number };
365
+ if (!p.pattern?.trim()) throw new Error("pattern bos.");
366
+ const root = resolveIn(ctx?.cwd ?? process.cwd(), p.path);
367
+ await requireDir(root, p.path ?? ".");
368
+ const r = await globFiles(root, p.pattern.trim(), Math.max(1, p.limit ?? DEFAULT_GLOB_LIMIT), signal);
369
+ const slow = r.timedOut
370
+ ? `\n[arama ${SCAN_TIME_LIMIT_MS / 1000} sn sinirinda durdu, sonuclar eksik olabilir: path ile daha dar bir klasor ver]`
371
+ : "";
372
+ if (!r.files.length) return out(`'${p.pattern}' icin dosya bulunamadi.${slow}`);
373
+ const tail = (r.truncated ? `\n[ilk ${r.files.length} sonuc; deseni daralt]` : "") + slow;
374
+ return out(capText(r.files.join("\n")) + tail, { count: r.files.length });
375
+ },
376
+ });
377
+
378
+ pi.registerTool({
379
+ name: "grep",
380
+ label: "Grep",
381
+ description:
382
+ "Dosya iceriginde regex arar (cikti 'yol:satir: metin'); grep/rg yerine bunu kullan. .gitignore/node_modules/ikili atlanir.",
383
+ promptSnippet:
384
+ "Dosya iceriginde regex ara (path, glob, ignoreCase, context, outputMode); bash grep/rg yerine bunu kullan",
385
+ parameters: Type.Object({
386
+ pattern: Type.String({ description: "Regex" }),
387
+ path: Type.Optional(Type.String({ description: "Dosya/dizin (varsayilan cwd)" })),
388
+ glob: Type.Optional(Type.String({ description: "Dosya filtresi, ornek '*.ts'" })),
389
+ ignoreCase: Type.Optional(Type.Boolean()),
390
+ literal: Type.Optional(Type.Boolean({ description: "Duz metin" })),
391
+ context: Type.Optional(Type.Number({ description: "Cevre satir (0-10)" })),
392
+ limit: Type.Optional(Type.Number({ description: `En fazla eslesme (varsayilan ${DEFAULT_GREP_LIMIT})` })),
393
+ outputMode: Type.Optional(Type.String({ description: "content|files|count" })),
394
+ }),
395
+ async execute(_id, params, signal, _u, ctx) {
396
+ const p = params as {
397
+ pattern: string;
398
+ path?: string;
399
+ glob?: string;
400
+ ignoreCase?: boolean;
401
+ literal?: boolean;
402
+ context?: number;
403
+ limit?: number;
404
+ outputMode?: string;
405
+ };
406
+ if (!p.pattern) throw new Error("pattern bos.");
407
+ const mode = p.outputMode === "files" || p.outputMode === "count" ? p.outputMode : "content";
408
+ const target = resolveIn(ctx?.cwd ?? process.cwd(), p.path);
409
+ const r = await grepPath(target, p.path ?? ".", {
410
+ pattern: p.pattern,
411
+ glob: p.glob,
412
+ ignoreCase: p.ignoreCase,
413
+ literal: p.literal,
414
+ context: p.context,
415
+ limit: p.limit,
416
+ mode,
417
+ signal,
418
+ });
419
+ return out(r.text, { matches: r.matches, files: r.files });
420
+ },
421
+ });
422
+
423
+ pi.registerTool({
424
+ name: "ls",
425
+ exposure: rareExposure(),
426
+ label: "Ls",
427
+ description:
428
+ "Bir dizinin icerigini listeler (dizinler sonda '/' ile, ada gore sirali). Yeni dosya olusturmadan once VAR OLUP OLMADIGINI kontrol etmek icin kullanma: write dogrudan olusturur.",
429
+ promptSnippet: "Dizin icerigini listele (path, limit)",
430
+ parameters: Type.Object({
431
+ path: Type.Optional(Type.String({ description: "Dizin (varsayilan: calisma dizini)" })),
432
+ limit: Type.Optional(Type.Number({ description: `En fazla girdi (varsayilan ${DEFAULT_LS_LIMIT})` })),
433
+ }),
434
+ async execute(_id, params, _s, _u, ctx) {
435
+ const p = params as { path?: string; limit?: number };
436
+ const abs = resolveIn(ctx?.cwd ?? process.cwd(), p.path);
437
+ await requireDir(abs, p.path ?? ".");
438
+ const dir = await opendir(abs);
439
+ const names: string[] = [];
440
+ for await (const e of dir) names.push(e.isDirectory() ? `${e.name}/` : e.name);
441
+ names.sort((a, b) => (a.toLowerCase() < b.toLowerCase() ? -1 : a.toLowerCase() > b.toLowerCase() ? 1 : 0));
442
+ const limit = Math.max(1, p.limit ?? DEFAULT_LS_LIMIT);
443
+ if (!names.length) return out("(bos dizin)");
444
+ const tail = names.length > limit ? `\n[ilk ${limit} girdi, toplam ${names.length}]` : "";
445
+ return out(capText(names.slice(0, limit).join("\n")) + tail, { count: names.length });
446
+ },
447
+ });
448
+ }
@@ -0,0 +1,26 @@
1
+ // ÜRETİLDİ — ELLE DÜZENLEME. Kaynak: sera-web/lib/build-rules.ts (npx tsx scripts/sync-zero-knowledge.ts)
2
+ // SERA — "UYGULAMA YAPARKEN CLAUDE GİBİ ÇALIŞ" kalite kuralları: TEK KAYNAK (web + CLI + kod ajanı).
3
+ // Kaynak: "Kendi Modellerini Claude Seviyesine Yaklaştırma Rehberi" bölüm 6 + Anthropic frontend-design özü.
4
+ // YALNIZ uygulama niyetinde istemde gider (web: isAppBuildRequest(son mesaj) || sohbette artifact var; CLI: aynı dedektör;
5
+ // kod ajanı: SYSTEM_PROMPT). Sohbette GİTMEZ → token artmaz. Türetilen kopyalar scripts/sync-zero-knowledge.ts ile üretilir
6
+ // (CLI build-rules.generated.ts, seracode-agent/build_rules_text.py); elle düzenleme YOK, lib/zero-knowledge.test.ts senkronu denetler.
7
+ // Dosya yalnız bu sabiti dışa aktarır (CLI'ya birebir kopyalanır).
8
+
9
+ export const BUILD_RULES = [
10
+ "UYGULAMA KALİTE KURALLARI (uygulama/site/oyun/araç yaparken):",
11
+ "1. Asla en basit şablonu yazma; gerçekten kullanılabilir, uçtan uca çalışan bir uygulama yap. İstek belirsizse makul varsayımı seç, devam et.",
12
+ "2. Önce kafanda planla (yazma): ekranlar, veri akışı, tasarım yönü. Sonra eksiksiz yaz; TODO/yarım parça bırakma.",
13
+ "3. TASARIM:",
14
+ "- Tek net estetik yön seç (editoryal, brutalist, yumuşak/organik, retro-fütüristik, lüks-sade...) ve sonuna kadar tutarlı kal; jenerik yapay zeka görünümünden kaçın.",
15
+ "- Yazı: Inter/Roboto/Arial görünümünden kaçın, karakterli başlık+gövde ikilisi seç. Harici font/CDN yasaksa sistem font yığınlarıyla karakter ver: Georgia/'Iowan Old Style' serif başlık, ui-rounded/'Segoe UI' gövde, ui-monospace rakamlar; boyut ve ağırlık kontrastı yüksek olsun.",
16
+ "- Renk: bir baskın renk + keskin bir vurgu; mor-beyaz gradyan klişesi yok. Renk, boşluk, yarıçap CSS değişkenleriyle (--bg --fg --accent --space --radius); açık+koyu tema (prefers-color-scheme).",
17
+ "- Kompozisyon: net hiyerarşi, ölçek farkı, cömert boşluk; kutu kutu sıkıcı kartlar yerine asimetri ve katman. Arka plan düz olmasın: ince gradyan/doku/desen/gölge.",
18
+ "- Hareket: hover, odak ve geçiş animasyonları, yumuşak giriş (CSS transition/animation); prefers-reduced-motion'a saygı.",
19
+ "4. Tüm durumlar: boş durum (yönlendiren metin), yükleniyor, hata (sade Türkçe mesaj), silmede onay/geri alma. Ekran boş görünmesin diye anlamlı örnek veriyle başla.",
20
+ "5. Mobil öncelikli: esnek yerleşim (flex/grid, clamp), yatay taşma yok, dokunma hedefi en az 44px, viewport meta.",
21
+ "6. Erişilebilirlik: yeterli kontrast, görünür odak halkası, etiketli form alanları, klavyeyle kullanım.",
22
+ "7. Veri tarayıcıda kalıcı olsun (localStorage, try/catch); kullanıcı verisini sessizce kaybetme.",
23
+ "8. Kod: küçük ve anlaşılır; gereksiz soyutlama yok. Bilmediğin API/kütüphaneyi uydurma, basit yoldan git. Hata alırsan nedenini bul, düzelt; aynı başarısız denemeyi 3 kereden fazla tekrarlama.",
24
+ "9. Doğrula: çalıştırma aracın varsa uygulamayı gerçekten çalıştır, konsol hatalarına bak; doğrulamadan 'bitti' deme. Aracın yoksa mantığı baştan sona gözden geçir. Test için açtığın sunucu/tarayıcı/arka plan sürecini (ör. http.server, npm run dev, Playwright) iş bitince MUTLAKA kapat; açık port bırakma.",
25
+ "10. Teslim: kısa özet (ne yaptın, hangi varsayımlar); uzun açıklama yazma.",
26
+ ].join("\n");
@@ -0,0 +1,170 @@
1
+ // ÜRETİLDİ — ELLE DÜZENLEME. Kaynak: sera-web/lib/zero-knowledge.ts (npx tsx scripts/sync-zero-knowledge.ts)
2
+ // SERA — "SIFIR BİLGİ KULLANICI" davranış kuralı: TEK KAYNAK (web + mobil + CLI).
3
+ // 2026-10-26 sahip direktifi: kullanıcı kitlesi sıfır teknik bilgili. "Bana bir uygulama yap" denince Sera
4
+ // (1) ekrana kod bloğu dökmez, kurulum/komut talimatı vermez, (2) framework/port/veritabanı gibi teknik soru
5
+ // sormaz, (3) kararları kendi verir, uygulamayı kendi izole kutusunda çalıştırıp ÖNİZLEMEYİ gösterir.
6
+ //
7
+ // Bu dosya üç şeyi taşır:
8
+ // 1) ZK_RULES / ZK_CLI_RULES : prompt blokları (api/chat.ts → lib/safety.ts, api/v1 → CLI/mobil, CLI txt'i
9
+ // scripts/sync-zero-knowledge.mjs ile BURADAN üretilir; elle kopya YOK).
10
+ // 2) Saf dedektörler : isAppBuildRequest / asksForCode / checkAppReply (testlenebilir, ağ yok).
11
+ // 3) guardAppReply : son-işlem koruması — kod-döküm / kurulum talimatı / teknik soru yakalanırsa modelden
12
+ // TEK yeniden deneme ister; yine olmazsa kodsuz sade mesaja düşer (sonsuz döngü YOK).
13
+
14
+ /** Ortak çekirdek kural (tüm modlar, web + mobil + CLI). */
15
+ export const ZK_RULES =
16
+ " SIFIR BİLGİ KULLANICI KURALI (DEĞİŞMEZ): Kullanıcı sıfır teknik bilgili. Uygulama/site/oyun/araç isterse: " +
17
+ "(1) ASLA kod bloğu gösterme ('kodu göster' demedikçe), kurulum/komut talimatı verme. " +
18
+ "(2) ASLA teknik soru sorma/teknik terim (framework, port, veritabanı, API) söyleme; teknik kararları KENDİN ver (sade, mobilde çalışan, Türkçe). " +
19
+ "(3) KOD DEĞİL, ÇALIŞAN ÖNİZLEMEYİ göster, sonra 'Rengini değiştireyim mi?' gibi sade devam et. " +
20
+ "(4) Soru şartsa yalnız ürün düzeyinde tek basit soru ('Renkler koyu mu olsun, açık mı?'); tercihen sormadan yap. " +
21
+ "(5) 'Kodu göster' derse göster.";
22
+
23
+ /** CLI'ye (tarayıcıda otomatik açılan önizleme) özgü ek. Web'de ARTIFACT_BLOCK karşılığıdır. */
24
+ export const ZK_CLI_RULES =
25
+ " CLI ÖNİZLEME KURALI: Uygulama isteğinde dosyaları kendin oluştur (yeni, boş bir klasörde; mümkünse TEK dosyalı index.html — HTML+CSS+JS, " +
26
+ "harici paket/CDN yok, Türkçe arayüz, veriler localStorage'da). Sonra önizlemeyi kullanıcının tarayıcısında kendin aç: " +
27
+ "Windows'ta `start \"\" index.html`, macOS'ta `open index.html`, Linux'ta `xdg-open index.html` (bash aracıyla). " +
28
+ "Paket gerektiren büyük uygulamada sunucuyu arka planda başlat, adresi kullanıcıya göstermeden TARAYICIDA aç. " +
29
+ "Kullanıcıya dosya yolu, komut ya da kod gösterme; 'Tarayıcında açtım, hemen dene. Rengini değiştireyim mi?' gibi sade konuş.";
30
+
31
+ // ───────── Dedektörler (saf) ─────────
32
+
33
+ const BUILD_VERB = "(yap|yapar\\s?m[ıi]s[ıi]n|yapsana|yapabilir\\s?misin|yaz|yazar\\s?m[ıi]s[ıi]n|haz[ıi]rla|olu[şs]tur|kodla|geli[şs]tir|tasarla|istiyorum|laz[ıi]m|gerek|build|make|create|develop|write|code)";
34
+ const APP_NOUN = "(uygulama|program|yaz[ıi]l[ıi]m|site|web\\s?site|sayfa|oyun|ara[çc]|hesap\\s?makine|sayac|sayaç|yap[ıi]lacaklar|todo|to-do|liste|takip|panel|bot|app|application|website|web\\s?app|game|tool|calculator|tracker|dashboard)";
35
+ const BUILD_RE = new RegExp(`${APP_NOUN}[^.!?\\n]{0,60}${BUILD_VERB}|${BUILD_VERB}[^.!?\\n]{0,40}${APP_NOUN}`, "i");
36
+ // "giderlerimi takip edemiyorum" gibi dert anlatımı (uygulama kelimesi olmadan) — lib/classifyComplexity APP_RE ile aynı ruh.
37
+ const NEED_RE = /(takip\s?edemiyorum|tutmam\s?laz[ıi]m|kar[ıi][şs][ıi]yor|unutuyorum|hat[ıi]rlas[ıi]n|kaçırıyorum)/i;
38
+ const NOT_APP_RE = /(nas[ıi]l\s+(çal[ıi][şs][ıi]r|yap[ıi]l[ıi]r)|nedir|ne\s+demek|a[çc][ıi]kla|anlat|hata\s+ver|bug|d[üu]zelt\s+bunu)/i;
39
+
40
+ /** Kullanıcı kodu AÇIKÇA istiyorsa koruma devre dışı. */
41
+ export function asksForCode(text: string): boolean {
42
+ return /(kod(u|unu|larını|lar[ıi])?\s*(g[öo]ster|ver|payla[şs]|yaz\s*bana)|kaynak\s*kod|show\s+(me\s+)?(the\s+)?(source\s+)?code|give\s+me\s+the\s+code|source\s*code|kodunu\s*da)/i.test(text || "");
43
+ }
44
+
45
+ /** Son kullanıcı mesajı "bana bir uygulama/program/site/oyun/araç yap" türü mü? */
46
+ export function isAppBuildRequest(text: string): boolean {
47
+ const t = (text || "").trim();
48
+ if (t.length < 6 || t.length > 1500) return false;
49
+ if (BUILD_RE.test(t) && !NOT_APP_RE.test(t)) return true;
50
+ return NEED_RE.test(t);
51
+ }
52
+
53
+ const ARTIFACT_RE = /```\s*(html:artifact|sera:proje)/i;
54
+ const FENCE_RE = /```([^\n`]*)\n([\s\S]*?)(```|$)/g;
55
+ const INSTALL_RE = /(npm\s+(install|i|run|start)\b|npx\s+\S+|yarn\s+(add|install)|pnpm\s+(add|install)|pip3?\s+install|pip\s+install|python3?\s+\S+\.py|node\s+\S+\.js|flask\s+run|uvicorn|terminal(i|de|e)?\s+a[çc]|komut\s+sat[ıi]r[ıi]|şu\s+dosyaya\s+kaydet|dosyaya\s+kaydet|kaydet(ip|in)?\s+(şu|bu)|save\s+(it\s+|this\s+)?(as|to)\s+\S+\.(html|js|py)|run\s+`?npm)/i;
56
+ const JARGON = "(framework|react|vue|angular|svelte|next\\.?js|node\\.?js|express|django|flask|tailwind|typescript|port\\b|veritaban[ıi]|database|sql|mongodb|postgres|\\bapi\\b|backend|frontend|npm|deploy|repo\\b|terminal|sunucu|server|hosting|docker|kütüphane|library|programlama\\s+dili|hangi\\s+dil)";
57
+ const JARGON_Q_RE = new RegExp(`[^.!?\\n]*${JARGON}[^.!?\\n]*\\?`, "i");
58
+
59
+ export interface AppReplyCheck {
60
+ ok: boolean;
61
+ /** Boş değilse neden ihlal: "kod_dokumu" | "kurulum_talimati" | "teknik_soru" */
62
+ reasons: Array<"kod_dokumu" | "kurulum_talimati" | "teknik_soru">;
63
+ hasArtifact: boolean;
64
+ }
65
+
66
+ /** Bir uygulama-isteği yanıtını denetler (saf). Çalışan önizleme bloğu varsa kod bloğu ihlal sayılmaz. */
67
+ export function checkAppReply(reply: string): AppReplyCheck {
68
+ const text = reply || "";
69
+ const hasArtifact = ARTIFACT_RE.test(text);
70
+ const reasons: AppReplyCheck["reasons"] = [];
71
+ if (!hasArtifact) {
72
+ let big = false;
73
+ for (const m of text.matchAll(FENCE_RE)) {
74
+ const lang = (m[1] || "").trim().toLowerCase();
75
+ if (/^(html:artifact|sera:proje)$/.test(lang)) continue;
76
+ if ((m[2] || "").split("\n").filter((l) => l.trim()).length >= 4) { big = true; break; }
77
+ }
78
+ if (big) reasons.push("kod_dokumu");
79
+ }
80
+ if (INSTALL_RE.test(text)) reasons.push("kurulum_talimati");
81
+ if (JARGON_Q_RE.test(text.replace(FENCE_RE, " "))) reasons.push("teknik_soru");
82
+ return { ok: reasons.length === 0, reasons, hasArtifact };
83
+ }
84
+
85
+ /** Modele giden düzeltme talimatı (yeniden deneme). */
86
+ export function correctionFor(reasons: AppReplyCheck["reasons"], canBuild: boolean): string {
87
+ const why = reasons.map((r) => r === "kod_dokumu" ? "kod bloğu döktün" : r === "kurulum_talimati" ? "kurulum/komut talimatı verdin" : "teknik soru sordun").join(", ");
88
+ return (
89
+ `[SİSTEM DÜZELTMESİ] Önceki yanıt kuralı çiğnedi (${why}). Kullanıcı sıfır teknik bilgili. ` +
90
+ (canBuild
91
+ ? "Şimdi YENİDEN yaz: kod/komut/kurulum anlatma, teknik soru sorma; tüm kararları kendin ver ve uygulamayı TEK ```html:artifact``` bloğunda (HTML+CSS+JS, harici dosya yok, Türkçe arayüz, localStorage) ver. Bloktan sonra tek sade cümle: 'İşte uygulaman, hemen dene. Rengini değiştireyim mi?' "
92
+ : "Şimdi YENİDEN yaz: kod/komut/kurulum anlatma, teknik soru sorma; bu pakette uygulama hazırlama yoksa bunu tek sade cümleyle söyle ve Max ile yapılabileceğini belirt. ") +
93
+ "Bu düzeltmeden bahsetme."
94
+ );
95
+ }
96
+
97
+ /** Retry de başarısızsa kullanıcıya gösterilecek kodsuz, sade mesaj. */
98
+ export const ZK_FALLBACK_TEXT =
99
+ "Bunu hazırlarken bir aksaklık oldu. İsteğini bir kez daha yazar mısın? İstersen ne istediğini bir iki cümleyle anlat, ben hallederim.";
100
+
101
+ export interface GuardOutcome {
102
+ text: string;
103
+ retried: boolean;
104
+ /** İlk yanıttaki ihlaller (boş = temiz geçti). */
105
+ violations: AppReplyCheck["reasons"];
106
+ /** Son durum: "clean" | "fixed" | "fallback" | "bypass" */
107
+ status: "clean" | "fixed" | "fallback" | "bypass";
108
+ }
109
+
110
+ /**
111
+ * Son-işlem koruması. `reply` ilk yanıt; `regenerate(correction)` modelden düzeltmeli YENİ yanıtı alır (null = başarısız).
112
+ * Yalnız uygulama-isteğinde ve kullanıcı "kodu göster" dememişse devreye girer. TEK yeniden deneme; sonsuz döngü yok.
113
+ */
114
+ export async function guardAppReply(
115
+ userText: string,
116
+ reply: string,
117
+ regenerate: (correction: string) => Promise<string | null>,
118
+ opts: { canBuild?: boolean; enabled?: boolean } = {},
119
+ ): Promise<GuardOutcome> {
120
+ if (opts.enabled === false || !isAppBuildRequest(userText) || asksForCode(userText)) {
121
+ return { text: reply, retried: false, violations: [], status: "bypass" };
122
+ }
123
+ const first = checkAppReply(reply);
124
+ if (first.ok) return { text: reply, retried: false, violations: [], status: "clean" };
125
+ let second: string | null = null;
126
+ try { second = await regenerate(correctionFor(first.reasons, opts.canBuild !== false)); } catch { second = null; }
127
+ if (second && checkAppReply(second).ok) {
128
+ return { text: second, retried: true, violations: first.reasons, status: "fixed" };
129
+ }
130
+ return { text: ZK_FALLBACK_TEXT, retried: true, violations: first.reasons, status: "fallback" };
131
+ }
132
+
133
+ /** Düz-metin akışını sonuna kadar okur (sınır: 400 KB; aşarsa kalanı atılır). */
134
+ export async function streamToText(stream: ReadableStream<Uint8Array>, maxChars = 400_000): Promise<string> {
135
+ const reader = stream.getReader();
136
+ const dec = new TextDecoder();
137
+ let out = "";
138
+ for (;;) {
139
+ const { done, value } = await reader.read();
140
+ if (done) break;
141
+ out += dec.decode(value, { stream: true });
142
+ if (out.length > maxChars) { try { await reader.cancel(); } catch { /* yoksay */ } break; }
143
+ }
144
+ return out + dec.decode();
145
+ }
146
+
147
+ // ───────── CLI tur-sonu denetimi (sera-code-cli session/prompt.ts bunu çağırır; kopya DEĞİL, sync ile üretilir) ─────────
148
+
149
+ /** Önizlemenin tarayıcıda açıldığını gösteren komut (bash aracı girdisi). */
150
+ const PREVIEW_CMD_RE = /(start\s+""?\s*\S*\.html?|\bopen\s+\S*\.html?|xdg-open|Start-Process|explorer(\.exe)?\s+\S*\.html?|sensible-browser|https?:\/\/(localhost|127\.0\.0\.1))/i;
151
+ export function cliPreviewOpened(bashCommands: string[]): boolean {
152
+ return bashCommands.some((c) => PREVIEW_CMD_RE.test(c || ""));
153
+ }
154
+
155
+ /**
156
+ * CLI tur sonu: asistanın SON metni uygulama isteğinde kod dökümü/kurulum talimatı/teknik soru içeriyorsa ve önizleme
157
+ * açılmadıysa modele verilecek düzeltme metnini döndürür; gerek yoksa null. Çağıran tur başına EN FAZLA 1 kez uygular.
158
+ */
159
+ export function cliTurnCorrection(userText: string, finalText: string, bashCommands: string[]): string | null {
160
+ if (!isAppBuildRequest(userText) || asksForCode(userText)) return null;
161
+ if (cliPreviewOpened(bashCommands)) return null;
162
+ const chk = checkAppReply(finalText);
163
+ if (chk.ok) return null;
164
+ return (
165
+ `[SİSTEM DÜZELTMESİ] Önceki yanıt kuralı çiğnedi (${chk.reasons.join(", ")}). Kullanıcı sıfır teknik bilgili. ` +
166
+ "Şimdi: kodu/komutu/kurulumu anlatma, teknik soru sorma. Uygulamayı kendin dosya olarak oluştur (tek index.html), " +
167
+ "önizlemeyi kullanıcının tarayıcısında kendin aç (bash: Windows `start \"\" index.html`, macOS `open index.html`, Linux `xdg-open index.html`), " +
168
+ "sonra tek sade cümle yaz: 'Tarayıcında açtım, hemen dene. Rengini değiştireyim mi?' Bu düzeltmeden bahsetme."
169
+ );
170
+ }