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,473 @@
1
+ /**
2
+ * Sera Ofis — rol tabanlı ajan takımı (sahip onayı 2026-11-10).
3
+ *
4
+ * Roller: MÜDÜR = ana ajan (planı yapar, `ofis` aracını çağırır) · ÇALIŞAN = görevi yapan alt ajan ·
5
+ * ŞEF = çalışanın işini GERÇEK komutla (test) doğrulayan alt ajan · DANIŞMAN = iki başarısız denemeden sonra
6
+ * yol gösteren güçlü model (yalnız gerektiğinde).
7
+ *
8
+ * Neden serbest sohbet değil pano: çok-ajanlı sistemlerde token'ın ve hataların çoğu ajanların birbirine uzun,
9
+ * belirsiz mesaj yazmasından gelir (MetaGPT/ChatDev başarısızlık çalışmaları). Burada mesajlar yapılandırılmıştır:
10
+ * her görevin kimliği, bağımlılığı, dokunduğu dosyalar ve kısa sonuç özeti vardır; bağımlı görev yalnız bu
11
+ * özetleri görür (tam sohbet geçmişini değil).
12
+ *
13
+ * Bu dosya SAF mantıktır (süreç başlatmaz); alt ajanı çalıştıran fonksiyon dışarıdan verilir → birim testli.
14
+ */
15
+ import { classifyCommand, redirectTargets, segments, words } from "./command-policy.ts";
16
+
17
+ export type OfisRol = "calisan" | "sef" | "danisman";
18
+
19
+ export interface OfisGorevGirdi {
20
+ id: string;
21
+ baslik: string;
22
+ /** Çalışana verilecek eksiksiz talimat */
23
+ is: string;
24
+ /** Görevin değiştireceği dosyalar (aynı dosyaya aynı anda iki çalışan dokunamaz) */
25
+ dosyalar?: string[];
26
+ /** Önce bitmesi gereken görev kimlikleri */
27
+ bagimli?: string[];
28
+ /** Görevi doğrulayan komut (ör. "pytest -q tests/test_x.py"); yoksa planın genel doğrulaması */
29
+ dogrulama?: string;
30
+ }
31
+
32
+ export type OfisDurum = "bekliyor" | "calisiyor" | "bitti" | "basarisiz" | "atlandi";
33
+
34
+ export interface OfisGorev extends OfisGorevGirdi {
35
+ durum: OfisDurum;
36
+ deneme: number;
37
+ /** Çalışanın kısa sonuç özeti (bağımlı görevlere aktarılır) */
38
+ ozet?: string;
39
+ /** Şefin son ret gerekçesi */
40
+ ret?: string;
41
+ /** Danışmanın yönlendirmesi */
42
+ tavsiye?: string;
43
+ }
44
+
45
+ export interface OfisPlan {
46
+ hedef: string;
47
+ gorevler: OfisGorevGirdi[];
48
+ /** Tüm iş bitince çalıştırılacak genel doğrulama komutu */
49
+ dogrulama?: string;
50
+ }
51
+
52
+ export const OFIS_SINIR = {
53
+ /** Bir planda en çok görev (büyük plan = token yangını) */
54
+ gorev: 8,
55
+ /** Aynı anda en çok çalışan */
56
+ paralel: 2,
57
+ /** Danışmana gitmeden önce çalışanın deneme sayısı */
58
+ denemeDanismanOncesi: 2,
59
+ /** Danışman tavsiyesinden sonra son deneme dahil toplam deneme */
60
+ denemeToplam: 3,
61
+ /** Bağımlı göreve aktarılan özet uzunluğu */
62
+ ozet: 600,
63
+ /** Şef ret gerekçesi uzunluğu */
64
+ ret: 800,
65
+ };
66
+
67
+ const ID_RE = /^[a-z0-9][a-z0-9_-]{0,31}$/i;
68
+
69
+ /** Planı doğrular; sorun varsa Türkçe hata metni döner, yoksa undefined. */
70
+ export function planHatasi(plan: OfisPlan): string | undefined {
71
+ if (!plan || typeof plan.hedef !== "string" || !plan.hedef.trim()) return "Plan hedefi boş.";
72
+ const g = plan.gorevler;
73
+ if (!Array.isArray(g) || g.length === 0) return "Planda görev yok.";
74
+ if (g.length < 2)
75
+ return "Tek görevlik iş için ofis gerekmez; işi kendin yap (ofis yalnız bölünebilen büyük işler için).";
76
+ if (g.length > OFIS_SINIR.gorev)
77
+ return `Plan çok büyük (${g.length} görev, en çok ${OFIS_SINIR.gorev}). Görevleri birleştir ya da işi aşamalara böl.`;
78
+ const ids = new Set<string>();
79
+ for (const t of g) {
80
+ if (!t || typeof t.id !== "string" || !ID_RE.test(t.id))
81
+ return `Geçersiz görev kimliği: ${JSON.stringify(t?.id)}`;
82
+ if (ids.has(t.id)) return `Aynı görev kimliği iki kez: ${t.id}`;
83
+ ids.add(t.id);
84
+ if (typeof t.is !== "string" || !t.is.trim()) return `${t.id}: talimat (is) boş.`;
85
+ // O11 (Fable 2026-11-12): dosya listesi yoksa kilit hiç devreye girmiyordu → her görevde ZORUNLU.
86
+ if (!Array.isArray(t.dosyalar) || !t.dosyalar.some((f) => typeof f === "string" && f.trim()))
87
+ return `${t.id}: görevin değiştireceği dosyalar (dosyalar) boş. Her görev hangi dosyalara yazacağını söylemeli (aynı dosyaya iki çalışan dokunamaz).`;
88
+ }
89
+ for (const t of g)
90
+ for (const d of t.bagimli ?? []) {
91
+ if (!ids.has(d)) return `${t.id}: bilinmeyen bağımlılık ${d}`;
92
+ if (d === t.id) return `${t.id}: kendine bağımlı olamaz.`;
93
+ }
94
+ // döngü denetimi (DFS)
95
+ const renk = new Map<string, 0 | 1 | 2>();
96
+ const byId = new Map(g.map((t) => [t.id, t]));
97
+ const dfs = (id: string): boolean => {
98
+ const r = renk.get(id) ?? 0;
99
+ if (r === 1) return true;
100
+ if (r === 2) return false;
101
+ renk.set(id, 1);
102
+ for (const d of byId.get(id)!.bagimli ?? []) if (dfs(d)) return true;
103
+ renk.set(id, 2);
104
+ return false;
105
+ };
106
+ for (const t of g) if (dfs(t.id)) return `Bağımlılık döngüsü var (${t.id} civarı).`;
107
+ return undefined;
108
+ }
109
+
110
+ export function panoKur(plan: OfisPlan): OfisGorev[] {
111
+ return plan.gorevler.map((t) => ({ ...t, durum: "bekliyor", deneme: 0 }));
112
+ }
113
+
114
+ const normYol = (p: string) => p.replace(/\\/g, "/").replace(/^\.\//, "").toLowerCase();
115
+
116
+ /**
117
+ * Başlatılabilir görevler: bekliyor + tüm bağımlılıklar bitti + dosyaları çalışan bir görevle (ya da bu turda
118
+ * seçilen başka görevle) çakışmıyor. En çok `bos` kadar döner.
119
+ */
120
+ export function hazirGorevler(pano: OfisGorev[], bos: number): OfisGorev[] {
121
+ const kilit = new Set<string>();
122
+ for (const t of pano) if (t.durum === "calisiyor") for (const f of t.dosyalar ?? []) kilit.add(normYol(f));
123
+ const byId = new Map(pano.map((t) => [t.id, t]));
124
+ const out: OfisGorev[] = [];
125
+ for (const t of pano) {
126
+ if (out.length >= bos) break;
127
+ if (t.durum !== "bekliyor") continue;
128
+ if (!(t.bagimli ?? []).every((d) => byId.get(d)?.durum === "bitti")) continue;
129
+ const fs = (t.dosyalar ?? []).map(normYol);
130
+ if (fs.some((f) => kilit.has(f))) continue;
131
+ for (const f of fs) kilit.add(f);
132
+ out.push(t);
133
+ }
134
+ return out;
135
+ }
136
+
137
+ /** Bağımlılığı başarısız/atlanan görevleri "atlandi" yapar (sonsuz bekleme olmasın). */
138
+ export function zinciriKapat(pano: OfisGorev[]): void {
139
+ let degisti = true;
140
+ const byId = new Map(pano.map((t) => [t.id, t]));
141
+ while (degisti) {
142
+ degisti = false;
143
+ for (const t of pano) {
144
+ if (t.durum !== "bekliyor") continue;
145
+ const kotu = (t.bagimli ?? []).find((d) => {
146
+ const s = byId.get(d)?.durum;
147
+ return s === "basarisiz" || s === "atlandi";
148
+ });
149
+ if (kotu) {
150
+ t.durum = "atlandi";
151
+ t.ret = `Bağımlı olduğu ${kotu} tamamlanamadı.`;
152
+ degisti = true;
153
+ }
154
+ }
155
+ }
156
+ }
157
+
158
+ const kisalt = (s: string, n: number) => {
159
+ const t = (s ?? "").trim();
160
+ return t.length > n ? `${t.slice(0, n)}…` : t;
161
+ };
162
+
163
+ /** Çalışan istemi: görev + yalnız bağımlı görevlerin KISA özetleri (tam geçmiş değil) + varsa şef reddi/danışman. */
164
+ export function calisanIstemi(plan: OfisPlan, pano: OfisGorev[], t: OfisGorev): string {
165
+ const byId = new Map(pano.map((x) => [x.id, x]));
166
+ const once = (t.bagimli ?? [])
167
+ .map((d) => byId.get(d))
168
+ .filter((x): x is OfisGorev => !!x)
169
+ .map((x) => `- [${x.id}] ${x.baslik}: ${x.ozet ?? "(özet yok)"}`);
170
+ const parcalar = [
171
+ "Sen Sera Ofis'te bir ÇALIŞANSIN. Ekibin ortak hedefi aşağıda; sana düşen YALNIZ bu görev.",
172
+ `Ortak hedef: ${plan.hedef}`,
173
+ `Görevin [${t.id}] ${t.baslik}:\n${t.is}`,
174
+ ];
175
+ if (t.dosyalar?.length)
176
+ parcalar.push(
177
+ `Yalnız şu dosyalara yaz: ${t.dosyalar.join(", ")}. Başka dosyayı DEĞİŞTİRME (diğer çalışanlar onlarla çalışıyor); okuyabilirsin.`,
178
+ );
179
+ if (once.length) parcalar.push(`Senden önce biten görevler (kısa özet):\n${once.join("\n")}`);
180
+ const dog = t.dogrulama ?? plan.dogrulama;
181
+ if (dog) parcalar.push(`İşin şu komutla doğrulanacak: \`${dog}\`. Bitirmeden önce kendin de çalıştır.`);
182
+ if (t.ret) parcalar.push(`ŞEF önceki denemeni REDDETTİ. Gerekçe:\n${t.ret}`);
183
+ if (t.tavsiye) parcalar.push(`DANIŞMANIN yönlendirmesi (buna uy):\n${t.tavsiye}`);
184
+ parcalar.push(
185
+ "Bitince SON mesajında en çok 5 satırla ne yaptığını yaz (hangi dosya, ne değişti). Uzun açıklama yazma.",
186
+ );
187
+ return parcalar.join("\n\n");
188
+ }
189
+
190
+ /** Şef istemi: komutu GERÇEKTEN çalıştır, modelin "tamam" demesine güvenme. */
191
+ export function sefIstemi(plan: OfisPlan, t: OfisGorev, komut: string | undefined): string {
192
+ const p = [
193
+ "Sen Sera Ofis'te ŞEFSİN: bir çalışanın işini doğruluyorsun. Kod YAZMA, dosya DEĞİŞTİRME.",
194
+ `Ortak hedef: ${plan.hedef}`,
195
+ `Doğrulanan görev [${t.id}] ${t.baslik}:\n${t.is}`,
196
+ `Çalışanın özeti: ${t.ozet ?? "(yok)"}`,
197
+ ];
198
+ if (komut)
199
+ p.push(
200
+ `Şu komutu bash ile ÇALIŞTIR ve çıktısına göre karar ver: \`${komut}\`. Komut başarısızsa görev REDDEDİLİR.`,
201
+ );
202
+ else p.push("Doğrulama komutu yok: ilgili dosyaları oku ve görevin gerçekten yapılıp yapılmadığını denetle.");
203
+ p.push(
204
+ "Cevabının İLK satırı tam olarak `ONAY` ya da `RET: <kısa gerekçe>` olsun. RET ise sonraki satırlara başarısız test adı/hata satırı gibi somut kanıtı yaz (en çok 10 satır).",
205
+ );
206
+ return p.join("\n\n");
207
+ }
208
+
209
+ export function danismanIstemi(plan: OfisPlan, t: OfisGorev): string {
210
+ return [
211
+ "Sen Sera Ofis'in TEKNİK DANIŞMANISIN. Bir çalışan aynı görevde iki kez başarısız oldu.",
212
+ `Ortak hedef: ${plan.hedef}`,
213
+ `Görev [${t.id}] ${t.baslik}:\n${t.is}`,
214
+ `Son ret gerekçesi:\n${t.ret ?? "(yok)"}`,
215
+ "Gerekirse dosyaları oku ama DEĞİŞTİRME. Kök nedeni bul ve çalışanın uygulayacağı somut, adım adım bir düzeltme yolu yaz (en çok 15 satır).",
216
+ ].join("\n\n");
217
+ }
218
+
219
+ /** Şef cevabını ayrıştırır. Belirsiz cevap güvenli tarafta RET sayılır. */
220
+ export function sefKarari(text: string): { onay: boolean; gerekce: string } {
221
+ const satirlar = (text ?? "").trim().split(/\r?\n/);
222
+ const ilk = (satirlar[0] ?? "").trim().replace(/^[*`#>\s]+/, "");
223
+ if (/^ONAY\b/i.test(ilk)) return { onay: true, gerekce: "" };
224
+ const m = /^RET\s*:?\s*(.*)$/i.exec(ilk);
225
+ const gerekce = m ? [m[1], ...satirlar.slice(1)].join("\n") : `Şef net karar vermedi:\n${text}`;
226
+ return { onay: false, gerekce: kisalt(gerekce, OFIS_SINIR.ret) };
227
+ }
228
+
229
+ export interface CalistirSonuc {
230
+ ok: boolean;
231
+ text: string;
232
+ /** bütçe tavanı doldu → ofis tamamen durur */
233
+ butceBitti?: boolean;
234
+ }
235
+
236
+ export interface OfisBagimlilik {
237
+ calistir: (rol: OfisRol, istem: string, gorev: OfisGorev) => Promise<CalistirSonuc>;
238
+ /** Danışman kullanılabilir mi (ör. plan Max içeriyor mu) */
239
+ danismanVar: boolean;
240
+ /** Pano her değiştiğinde (ilerleme gösterimi) */
241
+ guncelle?: (pano: OfisGorev[]) => void;
242
+ signal?: AbortSignal;
243
+ paralel?: number;
244
+ }
245
+
246
+ export interface OfisRapor {
247
+ pano: OfisGorev[];
248
+ durdu?: string;
249
+ }
250
+
251
+ /** Bir görevi sonuçlanana kadar yürütür: çalışan → şef → (2 ret) danışman → son deneme. */
252
+ async function gorevYurut(
253
+ plan: OfisPlan,
254
+ pano: OfisGorev[],
255
+ t: OfisGorev,
256
+ d: OfisBagimlilik,
257
+ ): Promise<string | undefined> {
258
+ const komut = t.dogrulama ?? plan.dogrulama;
259
+ const maxDeneme = d.danismanVar ? OFIS_SINIR.denemeToplam : OFIS_SINIR.denemeDanismanOncesi;
260
+ while (t.deneme < maxDeneme) {
261
+ if (d.signal?.aborted) return "durduruldu";
262
+ if (t.deneme === OFIS_SINIR.denemeDanismanOncesi && d.danismanVar && !t.tavsiye) {
263
+ const r = await d.calistir("danisman", danismanIstemi(plan, t), t);
264
+ if (r.butceBitti) return "bütçe tavanı doldu";
265
+ if (r.ok && r.text.trim()) t.tavsiye = kisalt(r.text, 1500);
266
+ d.guncelle?.(pano);
267
+ }
268
+ t.deneme += 1;
269
+ const w = await d.calistir("calisan", calisanIstemi(plan, pano, t), t);
270
+ if (w.butceBitti) return "bütçe tavanı doldu";
271
+ if (!w.ok) {
272
+ t.ret = kisalt(`Çalışan görevi tamamlayamadı: ${w.text}`, OFIS_SINIR.ret);
273
+ d.guncelle?.(pano);
274
+ continue;
275
+ }
276
+ t.ozet = kisalt(w.text, OFIS_SINIR.ozet);
277
+ d.guncelle?.(pano);
278
+ const s = await d.calistir("sef", sefIstemi(plan, t, komut), t);
279
+ if (s.butceBitti) return "bütçe tavanı doldu";
280
+ const k = s.ok
281
+ ? sefKarari(s.text)
282
+ : { onay: false, gerekce: kisalt(`Şef doğrulayamadı: ${s.text}`, OFIS_SINIR.ret) };
283
+ if (k.onay) {
284
+ t.durum = "bitti";
285
+ t.ret = undefined;
286
+ d.guncelle?.(pano);
287
+ return undefined;
288
+ }
289
+ t.ret = k.gerekce;
290
+ d.guncelle?.(pano);
291
+ }
292
+ t.durum = "basarisiz";
293
+ d.guncelle?.(pano);
294
+ return undefined;
295
+ }
296
+
297
+ /** Panoyu bitene kadar yürütür (en çok `paralel` çalışan aynı anda). */
298
+ export async function ofisYurut(plan: OfisPlan, d: OfisBagimlilik): Promise<OfisRapor> {
299
+ const hata = planHatasi(plan);
300
+ if (hata) throw new Error(hata);
301
+ const pano = panoKur(plan);
302
+ const paralel = Math.max(1, Math.min(d.paralel ?? OFIS_SINIR.paralel, OFIS_SINIR.paralel));
303
+ const calisan = new Map<string, Promise<{ id: string; dur?: string }>>();
304
+ let durdu: string | undefined;
305
+ d.guncelle?.(pano);
306
+ for (;;) {
307
+ zinciriKapat(pano);
308
+ if (!durdu && !d.signal?.aborted)
309
+ for (const t of hazirGorevler(pano, paralel - calisan.size)) {
310
+ t.durum = "calisiyor";
311
+ d.guncelle?.(pano);
312
+ calisan.set(
313
+ t.id,
314
+ gorevYurut(plan, pano, t, d).then(
315
+ (dur) => ({ id: t.id, dur }),
316
+ (e) => {
317
+ t.durum = "basarisiz";
318
+ t.ret = kisalt(`Beklenmeyen hata: ${(e as Error)?.message ?? e}`, OFIS_SINIR.ret);
319
+ return { id: t.id };
320
+ },
321
+ ),
322
+ );
323
+ }
324
+ if (calisan.size === 0) break;
325
+ const bitti = await Promise.race(calisan.values());
326
+ calisan.delete(bitti.id);
327
+ if (bitti.dur && !durdu) durdu = bitti.dur;
328
+ if (d.signal?.aborted && !durdu) durdu = "durduruldu";
329
+ }
330
+ if (durdu)
331
+ for (const t of pano)
332
+ if (t.durum === "bekliyor" || t.durum === "calisiyor") {
333
+ t.durum = "atlandi";
334
+ t.ret ??= `Ofis durdu: ${durdu}`;
335
+ }
336
+ d.guncelle?.(pano);
337
+ return { pano, durdu };
338
+ }
339
+
340
+ const ISARET: Record<OfisDurum, string> = {
341
+ bekliyor: "○",
342
+ calisiyor: "◐",
343
+ bitti: "✓",
344
+ basarisiz: "✗",
345
+ atlandi: "–",
346
+ };
347
+
348
+ /** Kısa pano metni (ilerleme ve müdüre dönen sonuç). */
349
+ export function panoMetni(pano: OfisGorev[], ayrinti = false): string {
350
+ return pano
351
+ .map((t) => {
352
+ let s = `${ISARET[t.durum]} [${t.id}] ${t.baslik} — ${t.durum}${t.deneme > 1 ? ` (${t.deneme} deneme)` : ""}`;
353
+ if (ayrinti && t.durum === "bitti" && t.ozet) s += `\n ${t.ozet.replace(/\n/g, "\n ")}`;
354
+ if (ayrinti && (t.durum === "basarisiz" || t.durum === "atlandi") && t.ret)
355
+ s += `\n neden: ${t.ret.replace(/\n/g, "\n ")}`;
356
+ return s;
357
+ })
358
+ .join("\n");
359
+ }
360
+
361
+ /** Rol → model. Varsayılanlar: çalışan/şef = Mini (2026-11-14: eski ara paket kaldırıldı), danışman = Max. Env ile değişir. */
362
+ export function rolModeli(
363
+ rol: OfisRol,
364
+ env: Record<string, string | undefined>,
365
+ mevcut: string | undefined,
366
+ ): string | undefined {
367
+ const anahtar = {
368
+ calisan: "SERA_OFIS_CALISAN_MODEL",
369
+ sef: "SERA_OFIS_SEF_MODEL",
370
+ danisman: "SERA_OFIS_DANISMAN_MODEL",
371
+ }[rol];
372
+ const v = env[anahtar]?.trim();
373
+ if (v) return v;
374
+ if (rol === "danisman") return "sera-max";
375
+ return mevcut === "sera-max" ? "sera-mini" : mevcut;
376
+ }
377
+
378
+ /** Rol → araç allowlist'i (şef ve danışman yazamaz). undefined = kısıt yok. */
379
+ export function rolAraclari(rol: OfisRol): string[] | undefined {
380
+ if (rol === "calisan") return undefined;
381
+ return ["read", "grep", "find", "ls", "bash"];
382
+ }
383
+
384
+ /** Alt ajana yazılabilir dosya listesini taşıyan env (JSON dizi). Yalnız Ofis çalışanında ayarlanır. */
385
+ export const OFIS_YAZ_ENV = "SERA_OFIS_YAZ";
386
+
387
+ /**
388
+ * Ofis çalışanının dosya sınırını ZORLAR (yalnız istemde yazmak yetmedi: 2026-11-10 denemesinde çalışan başka
389
+ * görevin dosyasına yazdı). edit/write/notebook_edit için hedef yol izinli listede değilse engel gerekçesi döner.
390
+ * Not: kabuk (bash) ile yazma bu katmanda ayrıştırılamaz; şefin gerçek doğrulaması ikinci savunmadır.
391
+ */
392
+ export function ofisYazmaEngeli(toolName: string, input: unknown, izinli: string[], cwd: string): string | undefined {
393
+ if (toolName !== "edit" && toolName !== "write" && toolName !== "notebook_edit") return undefined;
394
+ const i = (input ?? {}) as Record<string, unknown>;
395
+ const hedef = String(i.path ?? i.file_path ?? i.filePath ?? "");
396
+ if (!hedef) return undefined;
397
+ const tam = (p: string) => {
398
+ let s = p.replace(/\\/g, "/");
399
+ if (!/^([a-z]:)?\//i.test(s)) s = `${cwd.replace(/\\/g, "/").replace(/\/+$/, "")}/${s}`;
400
+ const out: string[] = [];
401
+ for (const parca of s.split("/")) {
402
+ if (parca === "." || parca === "") continue;
403
+ if (parca === "..") out.pop();
404
+ else out.push(parca);
405
+ }
406
+ return out.join("/").toLowerCase();
407
+ };
408
+ const h = tam(hedef);
409
+ if (izinli.some((f) => tam(f) === h)) return undefined;
410
+ return `Sera Ofis: bu görevde yalnız şu dosyalara yazabilirsin: ${izinli.join(", ")}. "${hedef}" başka bir çalışanın alanı; gerekiyorsa son mesajında müdüre bildir.`;
411
+ }
412
+
413
+ /** Alt ajanın Ofis rolü (şef/danışman kabuğu salt-okunur) ve şefin çalıştırabileceği doğrulama komutu. */
414
+ export const OFIS_ROL_ENV = "SERA_OFIS_ROL";
415
+ export const OFIS_KOMUT_ENV = "SERA_OFIS_KOMUT";
416
+
417
+ const unq = (s: string) => s.replace(/^["']|["']$/g, "");
418
+
419
+ /** Kabuk parçasının yazdığı dosyalar: yönlendirme, sed -i, tee, cp/mv hedefi, rm/touch/truncate argümanları. */
420
+ export function kabukYazmaHedefleri(cmd: string): string[] | undefined {
421
+ const segs = segments(cmd);
422
+ if (!segs) return undefined; // komut ikamesi: içerik görülemez
423
+ const out: string[] = [];
424
+ for (const seg of segs) {
425
+ out.push(...redirectTargets(seg));
426
+ const w = words(seg).map(unq);
427
+ const ad = (w[0] ?? "").replace(/^.*[\\/]/, "").toLowerCase();
428
+ const arg = w.slice(1).filter((x) => !x.startsWith("-"));
429
+ if (ad === "sed" && w.some((x) => /^-i|^--in-place/.test(x))) out.push(...arg.slice(1));
430
+ else if (ad === "tee" || ad === "rm" || ad === "touch" || ad === "truncate" || ad === "rmdir") out.push(...arg);
431
+ else if ((ad === "cp" || ad === "mv" || ad === "install") && arg.length >= 2) out.push(arg[arg.length - 1]!);
432
+ else if (/^(set-content|add-content|out-file|remove-item|new-item|move-item|copy-item)$/i.test(ad)) {
433
+ const p = w.findIndex((x) => /^-(path|literalpath|filepath|destination)$/i.test(x));
434
+ out.push(p >= 0 && w[p + 1] ? w[p + 1]! : (arg[0] ?? ""));
435
+ }
436
+ }
437
+ return out.filter(Boolean);
438
+ }
439
+
440
+ /**
441
+ * O11 (Fable 2026-11-12): Ofis kilidi kabukla aşılıyordu. Kabuk komutu (bash/powershell) için engel gerekçesi döner.
442
+ * - şef/danışman: yalnız salt-okunur komut + (şef) görevin kendi doğrulama komutu birebir.
443
+ * - çalışan: kabukla yazdığı her dosya izinli listede olmalı; içeriği görülemeyen komut (ikame) engellenir.
444
+ * Sınır: kabuk içinden çalışan bir betiğin (node x.js) yazdıkları ayrıştırılamaz — şefin gerçek doğrulaması ikinci savunma.
445
+ */
446
+ export function ofisKabukEngeli(
447
+ cmd: string,
448
+ rol: string | undefined,
449
+ izinli: string[],
450
+ cwd: string,
451
+ izinliKomut: string[] = [],
452
+ ): string | undefined {
453
+ const c = (cmd ?? "").trim();
454
+ if (!c) return undefined;
455
+ if (rol === "sef" || rol === "danisman") {
456
+ if (classifyCommand(c).verdict === "safe") return undefined;
457
+ if (rol === "sef" && izinliKomut.some((k) => k.trim() === c)) return undefined;
458
+ return rol === "sef"
459
+ ? `Sera Ofis: şef yalnız okuyan komutlar ve görevin doğrulama komutunu (${izinliKomut.join(" · ") || "yok"}) çalıştırabilir; dosya değiştiremez.`
460
+ : "Sera Ofis: danışman yalnız okuyan komutlar çalıştırabilir; dosya değiştiremez.";
461
+ }
462
+ if (rol !== "calisan") return undefined;
463
+ // izinli boşsa (bozuk liste) güvenli taraf: kabukla HİÇBİR dosyaya yazılamaz (ofisYazmaEngeli ile aynı davranış).
464
+ const hedefler = kabukYazmaHedefleri(c);
465
+ if (hedefler === undefined)
466
+ return "Sera Ofis: içinde alt komut ($(...) ya da `...`) olan kabuk komutu çalışanda kullanılamaz; dosyayı edit/write ile değiştir.";
467
+ for (const h of hedefler) {
468
+ if (/^(\/dev\/null|nul|\$null)$/i.test(h)) continue;
469
+ const r = ofisYazmaEngeli("write", { path: h }, izinli, cwd);
470
+ if (r) return r;
471
+ }
472
+ return undefined;
473
+ }
@@ -0,0 +1,139 @@
1
+ /**
2
+ * E4: proje disi dosya onayi. edit/write hedefi proje kokunun disindaysa, ve read hedefi proje disinda duyarli bir
3
+ * yolsa (~/.ssh, ~/.aws, .env ...) arac cagrisi kullanici onayina baglanir. Karar vermeden once yol GERCEK konuma
4
+ * cozulur: `..`, sembolik baglantilar (henuz olmayan dosya icin en yakin var olan ust klasor), Windows buyuk/kucuk
5
+ * harf ve `\?\` on eki. Saf mantik; onay sorusu PermissionGate.confirm uzerinden gider.
6
+ */
7
+ import { existsSync, lstatSync, readlinkSync, realpathSync } from "node:fs";
8
+ import { homedir, tmpdir } from "node:os";
9
+ import { delimiter, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
10
+ import { fileURLToPath } from "node:url";
11
+
12
+ const UNICODE_SPACES = new RegExp(
13
+ `[${[0xa0, 0x202f, 0x205f, 0x3000, ...Array.from({ length: 11 }, (_, k) => 0x2000 + k)].map((n) => String.fromCharCode(n)).join("")}]`,
14
+ "g",
15
+ );
16
+
17
+ const SENSITIVE_DIR = /(^|\/)\.(ssh|aws|gnupg|kube|azure|config\/gcloud|docker)(\/|$)/i;
18
+ const SENSITIVE_FILE =
19
+ /(^|\/)(\.env(\.(?!example$|sample$|template$)[^/]*)?|id_(rsa|dsa|ecdsa|ed25519)(\.pub)?|\.netrc|\.npmrc|\.pypirc|\.git-credentials|credentials(\.json)?|secrets?\.(json|ya?ml)|[^/]*\.(pem|key|pfx|p12|kdbx)|login data|cookies)$/i;
20
+
21
+ const READ_LIKE = new Set(["read", "grep", "glob", "ls", "find"]);
22
+
23
+ /** Kimlik bilgisi/gizli anahtar tasiyan yol mu (konumdan bagimsiz). */
24
+ export function isSensitivePath(p: string): boolean {
25
+ const n = p.replaceAll("\\", "/");
26
+ return SENSITIVE_DIR.test(n) || SENSITIVE_FILE.test(n);
27
+ }
28
+
29
+ /**
30
+ * Pi'nin arac yol cozumuyle AYNI normallestirme (utils/paths.ts normalizePath): bas `@`, unicode bosluklar, Windows'ta
31
+ * Git-Bash `/c/...`, `~`, `file://`. Farkli cozmek kontrol atlatmaya yol acar.
32
+ */
33
+ export function expandPath(p: string, home = homedir(), win = process.platform === "win32"): string {
34
+ let s = p.replace(UNICODE_SPACES, " ");
35
+ if (s.startsWith("@")) s = s.slice(1);
36
+ if (win && s.startsWith("/") && !s.startsWith("//") && !s.includes("\\")) {
37
+ const m = s.match(/^\/(?:mnt\/|cygdrive\/)?([a-z])(?:\/(.*))?$/i);
38
+ if (m) s = `${m[1].toUpperCase()}:\\${(m[2] ?? "").replaceAll("/", "\\")}`;
39
+ }
40
+ if (s === "~") return home;
41
+ if (s.startsWith("~/") || (win && s.startsWith("~\\"))) return join(home, s.slice(2));
42
+ if (/^file:\/\//.test(s)) {
43
+ try {
44
+ return fileURLToPath(s);
45
+ } catch {
46
+ return s;
47
+ }
48
+ }
49
+ return s;
50
+ }
51
+
52
+ /** Yolu gercek konuma cozer: var olan en yakin ust klasoru realpath, kalani oldugu gibi ekler. */
53
+ export function resolveReal(p: string, depth = 0): string {
54
+ let cur = resolve(p);
55
+ const rest: string[] = [];
56
+ while (!existsSync(cur)) {
57
+ // kirik sembolik baglanti: yazma baglantinin HEDEFINDE olusur -> hedefe takip et
58
+ try {
59
+ if (depth < 8 && lstatSync(cur).isSymbolicLink()) {
60
+ const t = resolve(dirname(cur), readlinkSync(cur));
61
+ return resolveReal(resolve(t, ...rest), depth + 1);
62
+ }
63
+ } catch {
64
+ // baglanti degil / yok
65
+ }
66
+ const up = dirname(cur);
67
+ if (up === cur) break;
68
+ rest.unshift(cur.slice(up.length).replace(/^[\\/]+/, ""));
69
+ cur = up;
70
+ }
71
+ let real = cur;
72
+ try {
73
+ real = realpathSync.native(cur);
74
+ } catch {
75
+ // kullanilamayan yol: oldugu gibi
76
+ }
77
+ return resolve(real, ...rest).replace(/^\\\\\?\\/, "");
78
+ }
79
+
80
+ const fold = (p: string, ci: boolean) => (ci ? p.toLowerCase() : p);
81
+
82
+ export function isInside(root: string, target: string, caseInsensitive = process.platform === "win32"): boolean {
83
+ const r = fold(root, caseInsensitive);
84
+ const t = fold(target, caseInsensitive);
85
+ const rel = relative(r, t);
86
+ return rel === "" || (!rel.startsWith(`..${sep}`) && rel !== ".." && !isAbsolute(rel));
87
+ }
88
+
89
+ export interface PathGuardOptions {
90
+ /** Ek izinli kokler (SERA_ALLOW_PATHS, `;`/`:` ile ayrilmis). */
91
+ extraRoots?: string[];
92
+ caseInsensitive?: boolean;
93
+ home?: string;
94
+ }
95
+
96
+ export interface OutsideFinding {
97
+ path: string;
98
+ sensitive: boolean;
99
+ write: boolean;
100
+ reason: string;
101
+ }
102
+
103
+ export function extraRootsFromEnv(env: NodeJS.ProcessEnv = process.env): string[] {
104
+ return (env.SERA_ALLOW_PATHS ?? "")
105
+ .split(delimiter)
106
+ .map((s) => s.trim())
107
+ .filter(Boolean);
108
+ }
109
+
110
+ /** undefined = proje icinde / zararsiz; aksi halde onay gerektiren bulgu. */
111
+ export function checkOutside(
112
+ cwd: string,
113
+ toolName: string,
114
+ input: unknown,
115
+ opts: PathGuardOptions = {},
116
+ ): OutsideFinding | undefined {
117
+ const write = toolName === "edit" || toolName === "write" || toolName === "notebook_edit";
118
+ // grep/glob/ls/find da proje dışı DUYARLI dizini tarayabilir (Fable 2026-11-12 ORTA 8): okuma gibi denetlenir.
119
+ if (!write && !READ_LIKE.has(toolName)) return undefined;
120
+ const i = (input ?? {}) as Record<string, unknown>;
121
+ const raw = String(i.path ?? i.file_path ?? "").trim();
122
+ if (!raw) return undefined;
123
+ const ci = opts.caseInsensitive ?? process.platform === "win32";
124
+ const target = resolveReal(
125
+ isAbsolute(expandPath(raw, opts.home)) ? expandPath(raw, opts.home) : resolve(cwd, expandPath(raw, opts.home)),
126
+ );
127
+ const root = resolveReal(cwd);
128
+ if (isInside(root, target, ci)) return undefined;
129
+ const sensitive = isSensitivePath(target);
130
+ if (!write && !sensitive) return undefined;
131
+ const allowed = [...(opts.extraRoots ?? []).map((r) => resolveReal(resolve(cwd, expandPath(r, opts.home))))];
132
+ // gecici klasor: yazma serbest (derleme/ara dosyalar); duyarli yol her zaman sorulur.
133
+ if (write && !sensitive) allowed.push(resolveReal(tmpdir()));
134
+ if (!sensitive && allowed.some((a) => isInside(a, target, ci))) return undefined;
135
+ const reason = sensitive
136
+ ? `Proje dışındaki duyarlı bir dosya ${write ? "değiştirilmek" : "okunmak"} isteniyor: ${target}. Anahtar/parola içerebilir. Onaylıyor musun?`
137
+ : `Proje klasörünün DIŞINDA bir dosya ${toolName === "edit" ? "düzenlenmek" : "yazılmak"} isteniyor: ${target} (proje: ${root}). Onaylıyor musun?`;
138
+ return { path: target, sensitive, write, reason };
139
+ }