sera-code 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (456) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE-SERA.md +25 -0
  3. package/README.md +27 -2
  4. package/THIRD_PARTY_NOTICES.md +68 -0
  5. package/bin/sera.mjs +137 -0
  6. package/dist/bundle/chunks/anthropic-messages-RD7GXOQL.js +6 -0
  7. package/dist/bundle/chunks/anthropic.js +75 -0
  8. package/dist/bundle/chunks/azure-openai-responses-CJT3KTVK.js +2 -0
  9. package/dist/bundle/chunks/bedrock-converse-stream.js +89 -0
  10. package/dist/bundle/chunks/chunk-46WGNYIE.js +82 -0
  11. package/dist/bundle/chunks/chunk-4UNN5OGR.js +4 -0
  12. package/dist/bundle/chunks/chunk-53H5DPHA.js +16 -0
  13. package/dist/bundle/chunks/chunk-5AGIVGSV.js +6 -0
  14. package/dist/bundle/chunks/chunk-6JXVX6Q2.js +2 -0
  15. package/dist/bundle/chunks/chunk-6QGV3IWD.js +6 -0
  16. package/dist/bundle/chunks/chunk-7CBJINYJ.js +20 -0
  17. package/dist/bundle/chunks/chunk-7DDKXS2Q.js +2 -0
  18. package/dist/bundle/chunks/chunk-7RZ5BS7U.js +2 -0
  19. package/dist/bundle/chunks/chunk-7ZC4UXSL.js +2 -0
  20. package/dist/bundle/chunks/chunk-BPHHHEET.js +9 -0
  21. package/dist/bundle/chunks/chunk-BSS6T6KQ.js +2 -0
  22. package/dist/bundle/chunks/chunk-CF5GWZHW.js +31 -0
  23. package/dist/bundle/chunks/chunk-EDSQGWII.js +44 -0
  24. package/dist/bundle/chunks/chunk-FFMDRXC4.js +10 -0
  25. package/dist/bundle/chunks/chunk-GUGC72EB.js +1222 -0
  26. package/dist/bundle/chunks/chunk-HODJBMOY.js +9 -0
  27. package/dist/bundle/chunks/chunk-HQBQWHLD.js +7 -0
  28. package/dist/bundle/chunks/chunk-HQJBN2MC.js +2 -0
  29. package/dist/bundle/chunks/chunk-JXWJOIH4.js +2 -0
  30. package/dist/bundle/chunks/chunk-KXU77PUU.js +4 -0
  31. package/dist/bundle/chunks/chunk-L2ZPNLYD.js +2 -0
  32. package/dist/bundle/chunks/chunk-LPXNMA2W.js +2 -0
  33. package/dist/bundle/chunks/chunk-LVVZS2NO.js +12 -0
  34. package/dist/bundle/chunks/chunk-M3LEVT3X.js +2 -0
  35. package/dist/bundle/chunks/chunk-P7FPUEYA.js +2 -0
  36. package/dist/bundle/chunks/chunk-PGXDEOVV.js +2 -0
  37. package/dist/bundle/chunks/chunk-PJACZCIR.js +2 -0
  38. package/dist/bundle/chunks/chunk-PMRZO46Y.js +2 -0
  39. package/dist/bundle/chunks/chunk-PRRNXB7S.js +2 -0
  40. package/dist/bundle/chunks/chunk-QTM7S6TH.js +2 -0
  41. package/dist/bundle/chunks/chunk-RDZVAGPR.js +2 -0
  42. package/dist/bundle/chunks/chunk-TLNP2BSO.js +2 -0
  43. package/dist/bundle/chunks/chunk-TMKHGABX.js +2 -0
  44. package/dist/bundle/chunks/chunk-TMTOQ7H7.js +2 -0
  45. package/dist/bundle/chunks/chunk-UKVNB6C4.js +2 -0
  46. package/dist/bundle/chunks/chunk-USJZMAIR.js +2 -0
  47. package/dist/bundle/chunks/chunk-UTB4DTYQ.js +2 -0
  48. package/dist/bundle/chunks/chunk-ZLAHUYDW.js +131 -0
  49. package/dist/bundle/chunks/chunk-ZNCN2NGY.js +60 -0
  50. package/dist/bundle/chunks/cli-MML2DU4A.js +51 -0
  51. package/dist/bundle/chunks/cloudflare-workers-ai-system-one-QPZQRBK5.js +2 -0
  52. package/dist/bundle/chunks/codemode-worker.js +478 -0
  53. package/dist/bundle/chunks/dist-ZNZCJI7B.js +7 -0
  54. package/dist/bundle/chunks/easter-egg-3d-VOETWRJO.js +2 -0
  55. package/dist/bundle/chunks/execute-HXDNZ26B.js +505 -0
  56. package/dist/bundle/chunks/github-copilot.js +2 -0
  57. package/dist/bundle/chunks/google-generative-ai-SJXMIEPZ.js +2 -0
  58. package/dist/bundle/chunks/google-vertex-VSXQ3BDH.js +2 -0
  59. package/dist/bundle/chunks/https-proxy-agent-LVOO5TPL.js +13 -0
  60. package/dist/bundle/chunks/image-resize-worker.js +2 -0
  61. package/dist/bundle/chunks/jiti-loader-GL4HJFAD.js +21 -0
  62. package/dist/bundle/chunks/jiti-static-loader-2RCDI6B4.js +2 -0
  63. package/dist/bundle/chunks/kimi-coding.js +2 -0
  64. package/dist/bundle/chunks/lib-4AVRLBHM.js +9 -0
  65. package/dist/bundle/chunks/llama-cpp-classify-4KFSGAMH.js +22 -0
  66. package/dist/bundle/chunks/meta.js +2 -0
  67. package/dist/bundle/chunks/mistral-conversations-JYWDZV2K.js +5 -0
  68. package/dist/bundle/chunks/multipart-parser-FMGQ7342.js +3 -0
  69. package/dist/bundle/chunks/node-AUOGOBCN.js +2 -0
  70. package/dist/bundle/chunks/node-KCMANYC2.js +16 -0
  71. package/dist/bundle/chunks/openai-chatgpt.js +75 -0
  72. package/dist/bundle/chunks/openai-codex-responses-OQV5DCFA.js +10 -0
  73. package/dist/bundle/chunks/openai-codex.js +75 -0
  74. package/dist/bundle/chunks/openai-completions-RFDJM2W5.js +7 -0
  75. package/dist/bundle/chunks/openai-decisions-O6PHBSCB.js +5 -0
  76. package/dist/bundle/chunks/openai-responses-LVNAPALQ.js +4 -0
  77. package/dist/bundle/chunks/openrouter-images-4WG6OOLH.js +2 -0
  78. package/dist/bundle/chunks/openrouter.js +75 -0
  79. package/dist/bundle/chunks/pdfjs-BETXZQ7A.js +108 -0
  80. package/dist/bundle/chunks/pdfjs-decoders-37HBPYHX.js +2 -0
  81. package/dist/bundle/chunks/pdfjs-jbig2-MH7WRXUP.js +2 -0
  82. package/dist/bundle/chunks/pdfjs-jbig2_nowasm_fallback-UVK7AQLA.js +2 -0
  83. package/dist/bundle/chunks/pdfjs-openjpeg-TC2QHC4G.js +2 -0
  84. package/dist/bundle/chunks/pdfjs-openjpeg_nowasm_fallback-ZC2FTHCZ.js +3 -0
  85. package/dist/bundle/chunks/pi-messages-EZXKVRR6.js +8 -0
  86. package/dist/bundle/chunks/radius.js +75 -0
  87. package/dist/bundle/chunks/runtime-JAH75CB5.js +2 -0
  88. package/dist/bundle/chunks/src-QKGKDFSU.js +4 -0
  89. package/dist/bundle/chunks/typesafe-system-one-X3JT6ECA.js +2 -0
  90. package/dist/bundle/chunks/virtual-modules-I5QRIHN6.js +2 -0
  91. package/dist/bundle/chunks/xai.js +2 -0
  92. package/dist/bundle/cli-runtime.js +3 -0
  93. package/dist/bundle/cli.js +5 -0
  94. package/dist/bundle/index.js +2 -0
  95. package/dist/bundle/rpc-entry.js +3 -0
  96. package/dist/core/export-html/ansi-to-html.d.ts +22 -0
  97. package/dist/core/export-html/ansi-to-html.d.ts.map +1 -0
  98. package/dist/core/export-html/ansi-to-html.js +249 -0
  99. package/dist/core/export-html/ansi-to-html.js.map +1 -0
  100. package/dist/core/export-html/index.d.ts +37 -0
  101. package/dist/core/export-html/index.d.ts.map +1 -0
  102. package/dist/core/export-html/index.js +228 -0
  103. package/dist/core/export-html/index.js.map +1 -0
  104. package/dist/core/export-html/template.css +1085 -0
  105. package/dist/core/export-html/template.html +56 -0
  106. package/dist/core/export-html/template.js +2044 -0
  107. package/dist/core/export-html/tool-renderer.d.ts +34 -0
  108. package/dist/core/export-html/tool-renderer.d.ts.map +1 -0
  109. package/dist/core/export-html/tool-renderer.js +110 -0
  110. package/dist/core/export-html/tool-renderer.js.map +1 -0
  111. package/dist/core/export-html/vendor/highlight.min.js +1213 -0
  112. package/dist/core/export-html/vendor/marked-cjk-friendly.min.js +6 -0
  113. package/dist/core/export-html/vendor/marked.min.js +79 -0
  114. package/dist/modes/interactive/assets/clankolas.png +0 -0
  115. package/dist/modes/interactive/theme/dark.json +81 -0
  116. package/dist/modes/interactive/theme/light.json +81 -0
  117. package/dist/modes/interactive/theme/system-theme.d.ts +55 -0
  118. package/dist/modes/interactive/theme/system-theme.d.ts.map +1 -0
  119. package/dist/modes/interactive/theme/system-theme.js +546 -0
  120. package/dist/modes/interactive/theme/system-theme.js.map +1 -0
  121. package/dist/modes/interactive/theme/theme-controller.d.ts +81 -0
  122. package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -0
  123. package/dist/modes/interactive/theme/theme-controller.js +210 -0
  124. package/dist/modes/interactive/theme/theme-controller.js.map +1 -0
  125. package/dist/modes/interactive/theme/theme-schema.d.ts +28 -0
  126. package/dist/modes/interactive/theme/theme-schema.d.ts.map +1 -0
  127. package/dist/modes/interactive/theme/theme-schema.js +105 -0
  128. package/dist/modes/interactive/theme/theme-schema.js.map +1 -0
  129. package/dist/modes/interactive/theme/theme-tokens.d.ts +257 -0
  130. package/dist/modes/interactive/theme/theme-tokens.d.ts.map +1 -0
  131. package/dist/modes/interactive/theme/theme-tokens.js +94 -0
  132. package/dist/modes/interactive/theme/theme-tokens.js.map +1 -0
  133. package/dist/modes/interactive/theme/theme.d.ts +155 -0
  134. package/dist/modes/interactive/theme/theme.d.ts.map +1 -0
  135. package/dist/modes/interactive/theme/theme.js +905 -0
  136. package/dist/modes/interactive/theme/theme.js.map +1 -0
  137. package/docs/cli-integration.md +106 -0
  138. package/docs/cli.md +333 -0
  139. package/docs/codemode.md +230 -0
  140. package/docs/compaction.md +463 -0
  141. package/docs/configuration.md +47 -0
  142. package/docs/containerization.md +183 -0
  143. package/docs/custom-provider.md +227 -0
  144. package/docs/docs.json +220 -0
  145. package/docs/environment-variables.md +102 -0
  146. package/docs/extensions.md +400 -0
  147. package/docs/how-pi-works.md +49 -0
  148. package/docs/index.md +39 -0
  149. package/docs/json.md +226 -0
  150. package/docs/keybindings.md +195 -0
  151. package/docs/llama-cpp.md +121 -0
  152. package/docs/mcp.md +272 -0
  153. package/docs/message-types.md +279 -0
  154. package/docs/models-configuration.md +196 -0
  155. package/docs/models.md +225 -0
  156. package/docs/nvidia-rtx-llama-cpp.md +96 -0
  157. package/docs/packages.md +131 -0
  158. package/docs/prompt-templates.md +59 -0
  159. package/docs/providers.md +247 -0
  160. package/docs/quickstart.md +136 -0
  161. package/docs/rpc-commands.md +860 -0
  162. package/docs/rpc-extension-ui.md +200 -0
  163. package/docs/rpc.md +193 -0
  164. package/docs/sdk.md +147 -0
  165. package/docs/security.md +99 -0
  166. package/docs/session-format.md +293 -0
  167. package/docs/sessions.md +66 -0
  168. package/docs/settings.md +172 -0
  169. package/docs/shell-aliases.md +93 -0
  170. package/docs/skills.md +93 -0
  171. package/docs/slash-commands.md +61 -0
  172. package/docs/terminal-setup.md +233 -0
  173. package/docs/termux.md +117 -0
  174. package/docs/themes.md +138 -0
  175. package/docs/tmux.md +55 -0
  176. package/docs/tui.md +195 -0
  177. package/docs/usage.md +94 -0
  178. package/docs/virtual-models.md +114 -0
  179. package/docs/windows.md +81 -0
  180. package/lib/auth.js +190 -0
  181. package/lib/provider.js +52 -0
  182. package/package.json +43 -5
  183. package/sera-core/skills/apple-tasarim/SKILL.md +48 -0
  184. package/sera-core/skills/apple-tasarim/referanslar/apple-hig.md +55 -0
  185. package/sera-core/skills/belge-yarat/SKILL.md +64 -0
  186. package/sera-core/skills/belge-yarat/referanslar/belge-yazim.md +60 -0
  187. package/sera-core/skills/derin-arastirma/SKILL.md +52 -0
  188. package/sera-core/skills/derin-arastirma/referanslar/arastirma-yontem.md +50 -0
  189. package/sera-core/skills/dusunme-dogrulama/SKILL.md +59 -0
  190. package/sera-core/skills/dusunme-dogrulama/referanslar/dusunme-kontrol.md +54 -0
  191. package/sera-core/skills/film-stilleri/SKILL.md +51 -0
  192. package/sera-core/skills/hyperframes/LICENSE-UPSTREAM +190 -0
  193. package/sera-core/skills/hyperframes/SKILL.md +79 -0
  194. package/sera-core/skills/hyperframes/assets/frame-presets/biennale-yellow/FRAME.md +289 -0
  195. package/sera-core/skills/hyperframes/assets/frame-presets/blockframe/FRAME.md +275 -0
  196. package/sera-core/skills/hyperframes/assets/frame-presets/blue-professional/FRAME.md +307 -0
  197. package/sera-core/skills/hyperframes/assets/frame-presets/bold-poster/FRAME.md +275 -0
  198. package/sera-core/skills/hyperframes/assets/frame-presets/broadside/FRAME.md +284 -0
  199. package/sera-core/skills/hyperframes/assets/frame-presets/capsule/FRAME.md +284 -0
  200. package/sera-core/skills/hyperframes/assets/frame-presets/cartesian/FRAME.md +278 -0
  201. package/sera-core/skills/hyperframes/assets/frame-presets/cobalt-grid/FRAME.md +265 -0
  202. package/sera-core/skills/hyperframes/assets/frame-presets/code-editorial/FRAME.md +277 -0
  203. package/sera-core/skills/hyperframes/assets/frame-presets/coral/FRAME.md +314 -0
  204. package/sera-core/skills/hyperframes/assets/frame-presets/creative-mode/FRAME.md +333 -0
  205. package/sera-core/skills/hyperframes/assets/frame-presets/daisy-days/FRAME.md +274 -0
  206. package/sera-core/skills/hyperframes/assets/frame-presets/editorial-forest/FRAME.md +265 -0
  207. package/sera-core/skills/hyperframes/references/captions.md +46 -0
  208. package/sera-core/skills/hyperframes/references/film.md +48 -0
  209. package/sera-core/skills/hyperframes/references/format.md +159 -0
  210. package/sera-core/skills/hyperframes/references/look.md +69 -0
  211. package/sera-core/skills/hyperframes/references/motion.md +95 -0
  212. package/sera-core/skills/hyperframes/references/overlays.md +39 -0
  213. package/sera-core/skills/hyperframes/references/path-tracing.md +36 -0
  214. package/sera-core/skills/hyperframes/references/plugin-installation.md +42 -0
  215. package/sera-core/skills/hyperframes/references/review.md +51 -0
  216. package/sera-core/skills/hyperframes/references/runtimes.md +69 -0
  217. package/sera-core/skills/hyperframes/references/skill-lifecycle.md +54 -0
  218. package/sera-core/skills/hyperframes/references/sound.md +43 -0
  219. package/sera-core/skills/hyperframes/references/spec.md +76 -0
  220. package/sera-core/skills/hyperframes/references/story.md +103 -0
  221. package/sera-core/skills/hyperframes/references/storyboard-format.md +107 -0
  222. package/sera-core/skills/hyperframes/references/storyboard.md +36 -0
  223. package/sera-core/skills/hyperframes/references/types/3d.md +25 -0
  224. package/sera-core/skills/hyperframes/references/types/character.md +20 -0
  225. package/sera-core/skills/hyperframes/references/types/data.md +19 -0
  226. package/sera-core/skills/hyperframes/references/types/explainer.md +34 -0
  227. package/sera-core/skills/hyperframes/references/types/launch.md +41 -0
  228. package/sera-core/skills/hyperframes/references/types/music.md +24 -0
  229. package/sera-core/skills/hyperframes/references/types/vertical.md +23 -0
  230. package/sera-core/skills/hyperframes-cli/LICENSE-UPSTREAM +190 -0
  231. package/sera-core/skills/hyperframes-cli/SKILL.md +99 -0
  232. package/sera-core/skills/hyperframes-cli/references/beats.md +17 -0
  233. package/sera-core/skills/hyperframes-cli/references/compare-and-batch.md +105 -0
  234. package/sera-core/skills/hyperframes-cli/references/conventions.md +16 -0
  235. package/sera-core/skills/hyperframes-cli/references/doctor-browser.md +80 -0
  236. package/sera-core/skills/hyperframes-cli/references/feedback.md +14 -0
  237. package/sera-core/skills/hyperframes-cli/references/init-and-scaffold.md +75 -0
  238. package/sera-core/skills/hyperframes-cli/references/lint-validate-inspect.md +164 -0
  239. package/sera-core/skills/hyperframes-cli/references/preview-render.md +204 -0
  240. package/sera-core/skills/hyperframes-cli/references/upgrade-info-misc.md +134 -0
  241. package/sera-core/skills/impeccable/LICENSE-UPSTREAM +191 -0
  242. package/sera-core/skills/impeccable/NOTICE-UPSTREAM.md +11 -0
  243. package/sera-core/skills/impeccable/SKILL.md +89 -0
  244. package/sera-core/skills/impeccable/reference/adapt.md +318 -0
  245. package/sera-core/skills/impeccable/reference/adapt.native.md +58 -0
  246. package/sera-core/skills/impeccable/reference/android.md +46 -0
  247. package/sera-core/skills/impeccable/reference/animate.md +89 -0
  248. package/sera-core/skills/impeccable/reference/audit.md +139 -0
  249. package/sera-core/skills/impeccable/reference/audit.native.md +139 -0
  250. package/sera-core/skills/impeccable/reference/bolder.md +33 -0
  251. package/sera-core/skills/impeccable/reference/clarify.md +94 -0
  252. package/sera-core/skills/impeccable/reference/colorize.md +86 -0
  253. package/sera-core/skills/impeccable/reference/component-review.md +63 -0
  254. package/sera-core/skills/impeccable/reference/craft-floor.md +44 -0
  255. package/sera-core/skills/impeccable/reference/craft.md +5 -0
  256. package/sera-core/skills/impeccable/reference/critique.md +819 -0
  257. package/sera-core/skills/impeccable/reference/degraded/asset-producer.md +42 -0
  258. package/sera-core/skills/impeccable/reference/degraded/documenter.md +24 -0
  259. package/sera-core/skills/impeccable/reference/degraded/finish-reviewer.md +38 -0
  260. package/sera-core/skills/impeccable/reference/degraded/manual-edit-applier.md +93 -0
  261. package/sera-core/skills/impeccable/reference/delight.md +70 -0
  262. package/sera-core/skills/impeccable/reference/distill.md +111 -0
  263. package/sera-core/skills/impeccable/reference/doctor.md +54 -0
  264. package/sera-core/skills/impeccable/reference/document.md +416 -0
  265. package/sera-core/skills/impeccable/reference/extract.md +69 -0
  266. package/sera-core/skills/impeccable/reference/generate.md +101 -0
  267. package/sera-core/skills/impeccable/reference/harden.md +362 -0
  268. package/sera-core/skills/impeccable/reference/hooks.md +120 -0
  269. package/sera-core/skills/impeccable/reference/init.md +133 -0
  270. package/sera-core/skills/impeccable/reference/ios.md +51 -0
  271. package/sera-core/skills/impeccable/reference/layout.md +84 -0
  272. package/sera-core/skills/impeccable/reference/live-setup.md +104 -0
  273. package/sera-core/skills/impeccable/reference/live.md +327 -0
  274. package/sera-core/skills/impeccable/reference/mode-operate.md +21 -0
  275. package/sera-core/skills/impeccable/reference/mode-persuade.md +19 -0
  276. package/sera-core/skills/impeccable/reference/mode-read.md +21 -0
  277. package/sera-core/skills/impeccable/reference/new-work.md +152 -0
  278. package/sera-core/skills/impeccable/reference/onboard.md +234 -0
  279. package/sera-core/skills/impeccable/reference/operate.md +61 -0
  280. package/sera-core/skills/impeccable/reference/optimize.md +257 -0
  281. package/sera-core/skills/impeccable/reference/overdrive.md +127 -0
  282. package/sera-core/skills/impeccable/reference/polish.md +105 -0
  283. package/sera-core/skills/impeccable/reference/quieter.md +99 -0
  284. package/sera-core/skills/impeccable/reference/region-map.md +26 -0
  285. package/sera-core/skills/impeccable/reference/routing.md +24 -0
  286. package/sera-core/skills/impeccable/reference/shape.md +59 -0
  287. package/sera-core/skills/impeccable/reference/typeset.md +90 -0
  288. package/sera-core/skills/impeccable/reference/visualize.md +47 -0
  289. package/sera-core/skills/oyun-yarat/SKILL.md +106 -0
  290. package/sera-core/skills/oyun-yarat/referanslar/3b-yaris.md +74 -0
  291. package/sera-core/skills/oyun-yarat/referanslar/kaplay.md +99 -0
  292. package/sera-core/skills/oyun-yarat/referanslar/oyun-desenleri.md +73 -0
  293. package/sera-core/skills/oyun-yarat/sablonlar/kaplay-2d.html +164 -0
  294. package/sera-core/skills/oyun-yarat/sablonlar/three-yaris.html +149 -0
  295. package/sera-core/skills/oyun-yarat/sablonlar/tuval-minimal.html +77 -0
  296. package/sera-core/skills/receiving-code-review/LICENSE-UPSTREAM +21 -0
  297. package/sera-core/skills/receiving-code-review/SKILL.md +205 -0
  298. package/sera-core/skills/refero-design/LICENSE-UPSTREAM +21 -0
  299. package/sera-core/skills/refero-design/SKILL.md +534 -0
  300. package/sera-core/skills/refero-design/references/anti-ai-slop.md +292 -0
  301. package/sera-core/skills/refero-design/references/color.md +563 -0
  302. package/sera-core/skills/refero-design/references/copywriting.md +222 -0
  303. package/sera-core/skills/refero-design/references/craft-details.md +525 -0
  304. package/sera-core/skills/refero-design/references/example-workflow.md +264 -0
  305. package/sera-core/skills/refero-design/references/icons.md +166 -0
  306. package/sera-core/skills/refero-design/references/mcp-tools.md +258 -0
  307. package/sera-core/skills/refero-design/references/motion.md +504 -0
  308. package/sera-core/skills/refero-design/references/typography.md +737 -0
  309. package/sera-core/skills/refero-design/references/visual-workflow.md +105 -0
  310. package/sera-core/skills/requesting-code-review/LICENSE-UPSTREAM +21 -0
  311. package/sera-core/skills/requesting-code-review/SKILL.md +95 -0
  312. package/sera-core/skills/requesting-code-review/code-reviewer.md +198 -0
  313. package/sera-core/skills/reverse-engineer-anything/DISCLAIMER.md +136 -0
  314. package/sera-core/skills/reverse-engineer-anything/LICENSE-REA-MIT +21 -0
  315. package/sera-core/skills/reverse-engineer-anything/SKILL.md +363 -0
  316. package/sera-core/skills/reverse-engineer-anything/THIRD_PARTY_NOTICES.md +135 -0
  317. package/sera-core/skills/reverse-engineer-anything/references/android-applications.md +36 -0
  318. package/sera-core/skills/reverse-engineer-anything/references/connection-and-recovery.md +127 -0
  319. package/sera-core/skills/reverse-engineer-anything/references/evidence-workflows.md +71 -0
  320. package/sera-core/skills/reverse-engineer-anything/references/javascript-applications.md +218 -0
  321. package/sera-core/skills/reverse-engineer-anything/references/native-and-artifacts.md +297 -0
  322. package/sera-core/skills/reverse-engineer-anything/references/runtime-observation.md +78 -0
  323. package/sera-core/skills/seo-audit/LICENSE-UPSTREAM +21 -0
  324. package/sera-core/skills/seo-audit/SKILL.md +210 -0
  325. package/sera-core/skills/sera-guvenlik-denetim/SKILL.md +44 -0
  326. package/sera-core/skills/sera-guvenlik-denetim/referanslar/guvenlik-listesi.md +33 -0
  327. package/sera-core/skills/sera-hata-ayikla/SKILL.md +27 -0
  328. package/sera-core/skills/sera-hata-ayikla/referanslar/hata-ayiklama.md +37 -0
  329. package/sera-core/skills/sera-kod-inceleme/SKILL.md +44 -0
  330. package/sera-core/skills/sera-kod-inceleme/referanslar/inceleme-listesi.md +62 -0
  331. package/sera-core/skills/sera-ofis-dosya/SKILL.md +27 -0
  332. package/sera-core/skills/sera-ofis-dosya/referanslar/ofis-dosya.md +93 -0
  333. package/sera-core/skills/sera-research/SKILL.md +90 -0
  334. package/sera-core/skills/sera-tasarim/SKILL.md +149 -0
  335. package/sera-core/skills/sera-teslim-sozlesmesi/SKILL.md +592 -0
  336. package/sera-core/skills/sera-test-yaz/SKILL.md +26 -0
  337. package/sera-core/skills/sera-test-yaz/referanslar/test-yazimi.md +35 -0
  338. package/sera-core/skills/sera-veri-gorsel/SKILL.md +65 -0
  339. package/sera-core/skills/sera-web-test/SKILL.md +26 -0
  340. package/sera-core/skills/sera-web-test/referanslar/web-test.md +44 -0
  341. package/sera-core/skills/sera-zamanli-gorev/SKILL.md +22 -0
  342. package/sera-core/skills/sera-zamanli-gorev/referanslar/zamanli-gorev.md +58 -0
  343. package/sera-core/skills/systematic-debugging/LICENSE-UPSTREAM +21 -0
  344. package/sera-core/skills/systematic-debugging/SKILL.md +283 -0
  345. package/sera-core/skills/systematic-debugging/condition-based-waiting.md +115 -0
  346. package/sera-core/skills/systematic-debugging/defense-in-depth.md +122 -0
  347. package/sera-core/skills/systematic-debugging/root-cause-tracing.md +169 -0
  348. package/sera-core/skills/test-driven-development/LICENSE-UPSTREAM +21 -0
  349. package/sera-core/skills/test-driven-development/SKILL.md +330 -0
  350. package/sera-core/skills/test-driven-development/writing-good-tests.md +198 -0
  351. package/sera-core/skills/ticaret-icerik/SKILL.md +49 -0
  352. package/sera-core/skills/ticaret-icerik/referanslar/ticaret-icerik.md +54 -0
  353. package/sera-core/skills/uygulama-yarat/SKILL.md +95 -0
  354. package/sera-core/skills/uygulama-yarat/referanslar/uygulama-desenleri.md +63 -0
  355. package/sera-core/skills/uygulama-yarat/sablonlar/uygulama-tek-dosya.html +121 -0
  356. package/sera-core/skills/uyumluluk-denetim/SKILL.md +56 -0
  357. package/sera-core/skills/uyumluluk-denetim/referanslar/mevzuat-tablosu.md +65 -0
  358. package/sera-core/skills/veri-analizi/SKILL.md +54 -0
  359. package/sera-core/skills/veri-analizi/referanslar/veri-analizi-yontem.md +49 -0
  360. package/sera-core/skills/veri-analizi/sablonlar/profil.mjs +79 -0
  361. package/sera-core/skills/video-duzen/SKILL.md +50 -0
  362. package/sera-core/skills/video-duzen/referanslar/video-duzen.md +100 -0
  363. package/sera-core/skills/web-yayin-listesi/SKILL.md +115 -0
  364. package/sera-core/skills/writing-plans/LICENSE-UPSTREAM +21 -0
  365. package/sera-core/skills/writing-plans/SKILL.md +204 -0
  366. package/sera-core/src/action-nudge.ts +200 -0
  367. package/sera-core/src/agent-mode.ts +143 -0
  368. package/sera-core/src/agents.ts +185 -0
  369. package/sera-core/src/app-master.ts +275 -0
  370. package/sera-core/src/app-verify.ts +551 -0
  371. package/sera-core/src/approval.ts +131 -0
  372. package/sera-core/src/budget.ts +136 -0
  373. package/sera-core/src/command-policy.ts +808 -0
  374. package/sera-core/src/config.ts +135 -0
  375. package/sera-core/src/context-diet.ts +272 -0
  376. package/sera-core/src/device-id.ts +48 -0
  377. package/sera-core/src/dogal-arac.ts +203 -0
  378. package/sera-core/src/dogal-niyet.ts +173 -0
  379. package/sera-core/src/egress-allow.ts +52 -0
  380. package/sera-core/src/export.ts +124 -0
  381. package/sera-core/src/exposure.ts +8 -0
  382. package/sera-core/src/extension.ts +2416 -0
  383. package/sera-core/src/fs-tools.ts +444 -0
  384. package/sera-core/src/generated/build-rules.ts +26 -0
  385. package/sera-core/src/generated/zero-knowledge.ts +170 -0
  386. package/sera-core/src/github-agent-command.ts +133 -0
  387. package/sera-core/src/github-agent-engine.ts +198 -0
  388. package/sera-core/src/github-agent-schedule.ts +180 -0
  389. package/sera-core/src/github-agent.ts +669 -0
  390. package/sera-core/src/github-ajan-akis.ts +193 -0
  391. package/sera-core/src/github-ajan-gercek.ts +102 -0
  392. package/sera-core/src/github-tick.ts +78 -0
  393. package/sera-core/src/github-yedek.ts +269 -0
  394. package/sera-core/src/goal.ts +119 -0
  395. package/sera-core/src/handoff.ts +132 -0
  396. package/sera-core/src/hooks.ts +284 -0
  397. package/sera-core/src/image-tool.ts +118 -0
  398. package/sera-core/src/intake-brief.ts +82 -0
  399. package/sera-core/src/intake-core.ts +1152 -0
  400. package/sera-core/src/intake-hook.ts +88 -0
  401. package/sera-core/src/ios-build-tool.ts +134 -0
  402. package/sera-core/src/lazy-capability.ts +125 -0
  403. package/sera-core/src/lazy-mcp.ts +300 -0
  404. package/sera-core/src/limit-command.ts +51 -0
  405. package/sera-core/src/loop-brake.ts +129 -0
  406. package/sera-core/src/lsp.ts +618 -0
  407. package/sera-core/src/mcp-bridge.ts +159 -0
  408. package/sera-core/src/mcp-pin.ts +105 -0
  409. package/sera-core/src/mcp-ssrf.ts +124 -0
  410. package/sera-core/src/message-cap.ts +45 -0
  411. package/sera-core/src/no-progress.ts +177 -0
  412. package/sera-core/src/notebook-tool.ts +179 -0
  413. package/sera-core/src/ofis.ts +473 -0
  414. package/sera-core/src/path-guard.ts +139 -0
  415. package/sera-core/src/permission-bridge.ts +228 -0
  416. package/sera-core/src/policy-chain.ts +122 -0
  417. package/sera-core/src/pricing.ts +71 -0
  418. package/sera-core/src/proc.ts +149 -0
  419. package/sera-core/src/rea.ts +188 -0
  420. package/sera-core/src/repo-map.ts +230 -0
  421. package/sera-core/src/research.ts +347 -0
  422. package/sera-core/src/rules-memory.ts +227 -0
  423. package/sera-core/src/sandbox.ts +445 -0
  424. package/sera-core/src/server-error.ts +78 -0
  425. package/sera-core/src/skills.ts +268 -0
  426. package/sera-core/src/snapshot.ts +143 -0
  427. package/sera-core/src/spec-gate.ts +112 -0
  428. package/sera-core/src/subagent.ts +261 -0
  429. package/sera-core/src/teslim.ts +120 -0
  430. package/sera-core/src/test-fix.ts +184 -0
  431. package/sera-core/src/todo-question.ts +163 -0
  432. package/sera-core/src/turn-snapshots.ts +126 -0
  433. package/sera-core/src/tuval/arac.ts +338 -0
  434. package/sera-core/src/tuval/arsiv.ts +106 -0
  435. package/sera-core/src/tuval/belge.ts +216 -0
  436. package/sera-core/src/tuval/birlestir.ts +282 -0
  437. package/sera-core/src/tuval/disa.ts +235 -0
  438. package/sera-core/src/tuval/editor.ts +583 -0
  439. package/sera-core/src/tuval/film-cekirdek.ts +170 -0
  440. package/sera-core/src/tuval/film-disa.ts +188 -0
  441. package/sera-core/src/tuval/film-oynatici.ts +307 -0
  442. package/sera-core/src/tuval/kimlik.ts +156 -0
  443. package/sera-core/src/tuval/pano.ts +763 -0
  444. package/sera-core/src/tuval/proje.ts +728 -0
  445. package/sera-core/src/tuval/sistem-cekirdek.ts +167 -0
  446. package/sera-core/src/tuval/sistem.ts +328 -0
  447. package/sera-core/src/tuval/sunucu.ts +413 -0
  448. package/sera-core/src/tuval/uretim.ts +24 -0
  449. package/sera-core/src/tuval/veri-cekirdek.ts +477 -0
  450. package/sera-core/src/tuval/xlsx.ts +215 -0
  451. package/sera-core/src/tuval/zip.ts +163 -0
  452. package/sera-core/src/untrusted.ts +201 -0
  453. package/sera-core/src/video-edit-tool.ts +411 -0
  454. package/sera-core/src/video-tool.ts +217 -0
  455. package/sera-core/src/web-tools.ts +257 -0
  456. package/sera-core/src/zk.ts +104 -0
@@ -0,0 +1,347 @@
1
+ /**
2
+ * Derin Arastirma Modu (sera-research) altyapisi. Sartname: SERA-ARASTIRMA-MODU.md (§3-§7, A19-A21).
3
+ * - Ayri butce hatti: `research/` aylik tavan (vars. $4), diskte aylik sayac (~/.sera/research-budget.json).
4
+ * Arastirma etkinken model cagrilari (ust + alt ajan) ve arama bedeli bu sayaca eklenir; tavanda sert durulur.
5
+ * - Arama cagrisi <= 12 / gorev (web_search; ayri arama servisi/anahtar YOK: mevcut web_search kullanilir).
6
+ * - A19: korumali `bash` yoksa mod acilmaz (research.compute = bash araci; python3/node).
7
+ * - Scratchpad: <proje>/.sera/research/ (plan.md + alt ajan basina dosya); research_note yazar, research_recall okur.
8
+ */
9
+
10
+ import { appendFileSync, existsSync, mkdirSync, readdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
11
+ import { basename, dirname, join } from "node:path";
12
+ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
13
+ import { Type } from "typebox";
14
+ import { rareExposure } from "./exposure.ts";
15
+
16
+ export const RESEARCH_SKILL = "sera-research";
17
+ export const RESEARCH_MONTHLY_CAP_USD = 4;
18
+ export const RESEARCH_MAX_SEARCHES = 12;
19
+
20
+ /** A19: arastirma gorevi korumali bash/python ortami olmadan baslatilamaz. undefined = acilabilir. */
21
+ export function a19Check(activeTools: readonly string[]): string | undefined {
22
+ return activeTools.includes("bash")
23
+ ? undefined
24
+ : "[Sera A19] Arastirma modu 'bash' araci olmadan acilamaz: bu isin degeri okumaktan degil hesaplamaktan (python3/node ile) gelir. 'bash' araci etkinlestirilmeden sera-research yuklenmez.";
25
+ }
26
+
27
+ const monthKey = (d: Date) => `${d.getUTCFullYear()}-${String(d.getUTCMonth() + 1).padStart(2, "0")}`;
28
+
29
+ /** Aylik arastirma harcama defteri (text/ ve media/ hattindan ayri). */
30
+ export class ResearchLedger {
31
+ readonly file: string;
32
+ readonly capUsd: number;
33
+ private readonly now: () => Date;
34
+ constructor(file: string, capUsd: number = RESEARCH_MONTHLY_CAP_USD, now: () => Date = () => new Date()) {
35
+ this.file = file;
36
+ this.capUsd = capUsd;
37
+ this.now = now;
38
+ }
39
+
40
+ spent(): number {
41
+ try {
42
+ const j = JSON.parse(readFileSync(this.file, "utf8")) as { month?: string; usd?: number };
43
+ return j.month === monthKey(this.now()) && Number.isFinite(j.usd) ? Number(j.usd) : 0;
44
+ } catch {
45
+ return 0;
46
+ }
47
+ }
48
+ remaining(): number {
49
+ return Math.max(0, this.capUsd - this.spent());
50
+ }
51
+ capReached(): boolean {
52
+ return this.capUsd > 0 && this.spent() >= this.capUsd;
53
+ }
54
+ add(usd: number): void {
55
+ if (!(usd > 0)) return;
56
+ const total = this.spent() + usd;
57
+ mkdirSync(dirname(this.file), { recursive: true });
58
+ const tmp = `${this.file}.tmp`;
59
+ writeFileSync(tmp, JSON.stringify({ month: monthKey(this.now()), usd: total }));
60
+ renameSync(tmp, this.file);
61
+ }
62
+ }
63
+
64
+ export interface ResearchModeOpts {
65
+ ledger: ResearchLedger;
66
+ activeTools: () => readonly string[];
67
+ maxSearches?: number;
68
+ /** arama basina bedel (USD). Mevcut web_search ucretsiz (DuckDuckGo) -> vars. 0; ucretli servis baglanirsa env ile verilir. */
69
+ searchUsd?: number;
70
+ }
71
+
72
+ const capMsg = (l: ResearchLedger) =>
73
+ `[Sera BUTCE] research/ aylik tavani doldu ($${l.spent().toFixed(4)} / $${l.capUsd.toFixed(2)}). Yeni arama/alt ajan YOK; elindeki kismi bulgulari (.sera/research/ not dosyalari) tek dosyada raporla ve "kismi bulgu, tavan doldu" diye belirt.`;
74
+
75
+ /** Bir kullanici istemi (gorev) boyunca arastirma durumu: etkinlik, arama sayaci, tavan. */
76
+ export class ResearchMode {
77
+ active = false;
78
+ searches = 0;
79
+ private readonly max: number;
80
+ private readonly o: ResearchModeOpts;
81
+ constructor(o: ResearchModeOpts) {
82
+ this.o = o;
83
+ this.max = o.maxSearches ?? RESEARCH_MAX_SEARCHES;
84
+ }
85
+ reset(): void {
86
+ this.active = false;
87
+ this.searches = 0;
88
+ }
89
+ /** SKILL.md okunuyor ya da /skill:sera-research istemi. Donus: engel gerekcesi. */
90
+ activate(): string | undefined {
91
+ const a19 = a19Check(this.o.activeTools());
92
+ if (a19) return a19;
93
+ if (this.o.ledger.capReached()) return capMsg(this.o.ledger);
94
+ this.active = true;
95
+ return undefined;
96
+ }
97
+ static isSkillPath(p: string): boolean {
98
+ const n = p.split("\\").join("/");
99
+ return basename(n) === "SKILL.md" && basename(dirname(n)) === RESEARCH_SKILL;
100
+ }
101
+ /** Arac cagrisi oncesi: engel gerekcesi (yoksa undefined). */
102
+ onToolCall(tool: string, input?: unknown): string | undefined {
103
+ if (tool === "read" && ResearchMode.isSkillPath(String((input as { path?: unknown } | undefined)?.path ?? "")))
104
+ return this.activate();
105
+ if (!this.active) return undefined;
106
+ if ((tool === "web_search" || tool === "web_fetch" || tool === "task") && this.o.ledger.capReached())
107
+ return capMsg(this.o.ledger);
108
+ if (tool === "web_search") {
109
+ if (this.searches >= this.max)
110
+ return `[Sera BUTCE] Gorev basina arama siniri (${this.max}) doldu. Yeni arama yapma; web_fetch ile bilinen kaynaklari oku ya da bulgulari yaz.`;
111
+ this.searches++;
112
+ this.o.ledger.add(this.o.searchUsd ?? 0);
113
+ }
114
+ return undefined;
115
+ }
116
+ /** Model/alt ajan harcamasi (USD) arastirma hattina. */
117
+ recordUsd(usd: number): void {
118
+ if (this.active) this.o.ledger.add(usd);
119
+ }
120
+ capReached(): boolean {
121
+ return this.active && this.o.ledger.capReached();
122
+ }
123
+ capMessage(): string {
124
+ return capMsg(this.o.ledger);
125
+ }
126
+ }
127
+
128
+ // --- Scratchpad: .sera/research/ ----------------------------------------------------------------------------------
129
+ const NAME_RE = /^[A-Za-z0-9][A-Za-z0-9_-]{0,39}$/;
130
+ export const researchDir = (cwd: string) => join(cwd, ".sera", "research");
131
+
132
+ function padFile(cwd: string, pad: string): string {
133
+ if (!NAME_RE.test(pad))
134
+ throw new Error(
135
+ `Gecersiz scratchpad adi '${pad}' (harf/rakam/-/_, en cok 40 karakter; 'plan' ya da alt ajan kimligi).`,
136
+ );
137
+ return join(researchDir(cwd), `${pad}.md`);
138
+ }
139
+
140
+ /** research.note(): bolume ekler (diske; baglama degil). */
141
+ export function researchNote(cwd: string, pad: string, section: string, text: string): string {
142
+ const f = padFile(cwd, pad);
143
+ const sec = section.replace(/[\r\n]+/g, " ").trim();
144
+ if (!sec) throw new Error("Bolum adi bos.");
145
+ mkdirSync(researchDir(cwd), { recursive: true });
146
+ appendFileSync(f, `${existsSync(f) ? "\n" : ""}## ${sec}\n${text.trim()}\n`);
147
+ return f;
148
+ }
149
+
150
+ /** research.recall(): bolumu (ya da tum dosyayi) geri okur. */
151
+ export function researchRecall(cwd: string, pad: string | undefined, section?: string): string {
152
+ const dir = researchDir(cwd);
153
+ if (!pad) {
154
+ if (!existsSync(dir)) return "(scratchpad bos)";
155
+ const names = readdirSync(dir).filter((n) => n.endsWith(".md"));
156
+ return names.length ? `Scratchpad dosyalari: ${names.join(", ")}` : "(scratchpad bos)";
157
+ }
158
+ const f = padFile(cwd, pad);
159
+ if (!existsSync(f)) return `(${pad}.md yok)`;
160
+ const raw = readFileSync(f, "utf8");
161
+ if (!section) return raw;
162
+ const sec = section.trim().toLowerCase();
163
+ const parts = raw.split(/^## /m).slice(1);
164
+ const hit = parts.filter((p) => p.split("\n", 1)[0]!.trim().toLowerCase() === sec);
165
+ return hit.length ? hit.map((p) => `## ${p}`.trimEnd()).join("\n") : `(bolum '${section}' yok)`;
166
+ }
167
+
168
+ const out = (text: string, isError = false) => ({
169
+ content: [{ type: "text" as const, text }],
170
+ details: undefined,
171
+ ...(isError ? { isError: true } : {}),
172
+ });
173
+
174
+ export function registerResearchTools(pi: ExtensionAPI): void {
175
+ pi.registerTool({
176
+ name: "research_note",
177
+ exposure: rareExposure(),
178
+ label: "Research note",
179
+ description:
180
+ "Arastirma scratchpad'ine (.sera/research/<scratchpad>.md) bir bolum ekler: bulgular baglamda degil diskte yasar. scratchpad='plan' ya da alt ajan kimligi.",
181
+ promptSnippet: "Arastirma notunu diske yaz (scratchpad, section, text)",
182
+ parameters: Type.Object({
183
+ scratchpad: Type.String({ description: "'plan' ya da alt ajan adi (dosya adi)" }),
184
+ section: Type.String({ description: "Bolum basligi (or. Gorev, Anahtar Sonuclar)" }),
185
+ text: Type.String({ description: "Eklenecek metin" }),
186
+ }),
187
+ async execute(_id, params, _s, _u, ctx) {
188
+ const p = params as { scratchpad: string; section: string; text: string };
189
+ try {
190
+ return out(`Yazildi: ${researchNote(ctx?.cwd ?? process.cwd(), p.scratchpad, p.section, p.text)}`);
191
+ } catch (e) {
192
+ return out(`[research_note] ${(e as Error).message}`, true);
193
+ }
194
+ },
195
+ });
196
+ pi.registerTool({
197
+ name: "research_recall",
198
+ exposure: rareExposure(),
199
+ label: "Research recall",
200
+ description:
201
+ "Arastirma scratchpad'inden geri okur (yaz + geri oku zorunlu). scratchpad verilmezse dosyalari listeler; section verilmezse tum dosya doner.",
202
+ promptSnippet: "Arastirma notunu diskten oku (scratchpad, ops. section)",
203
+ parameters: Type.Object({
204
+ scratchpad: Type.Optional(Type.String({ description: "'plan' ya da alt ajan adi" })),
205
+ section: Type.Optional(Type.String({ description: "Bolum basligi" })),
206
+ }),
207
+ async execute(_id, params, _s, _u, ctx) {
208
+ const p = params as { scratchpad?: string; section?: string };
209
+ try {
210
+ return out(researchRecall(ctx?.cwd ?? process.cwd(), p.scratchpad, p.section));
211
+ } catch (e) {
212
+ return out(`[research_recall] ${(e as Error).message}`, true);
213
+ }
214
+ },
215
+ });
216
+ }
217
+
218
+ // --- §7-6..9: dagitim sablonlari, ozet siniri, dogrulama, CitationAgent girdisi, DivInit -----------------------------
219
+ /** Alt ajan ozeti siniri: ~2K token (karakter/4). */
220
+ export const RESEARCH_SUMMARY_MAX_TOKENS = 2000;
221
+
222
+ export function clipSummary(text: string, maxTokens = RESEARCH_SUMMARY_MAX_TOKENS): string {
223
+ const max = maxTokens * 4;
224
+ if (text.length <= max) return text;
225
+ return `${text.slice(0, max).trimEnd()}\n\n[Sera UYARI: alt ajan ozeti ~${maxTokens} token sinirini asti (${text.length} karakter), kirpildi. Ayrintilar alt ajanin scratchpad dosyasinda (research_recall).]`;
226
+ }
227
+
228
+ const words = (q: string): Set<string> =>
229
+ new Set(
230
+ q
231
+ .toLowerCase()
232
+ .normalize("NFKD")
233
+ .replace(/[^\p{L}\p{N}\s]/gu, " ")
234
+ .split(/\s+/)
235
+ .filter((w) => w.length > 1),
236
+ );
237
+ export function jaccard(a: string, b: string): number {
238
+ const x = words(a);
239
+ const y = words(b);
240
+ if (x.size === 0 && y.size === 0) return 1;
241
+ let inter = 0;
242
+ for (const w of x) if (y.has(w)) inter++;
243
+ return inter / (x.size + y.size - inter);
244
+ }
245
+
246
+ /** DivInit: ayni niyeti tasiyan (kelime kumesi Jaccard >= esik) sorgulardan ilki kalir, digerleri atilir. */
247
+ export function diversityFilter(
248
+ queries: string[],
249
+ threshold = 0.6,
250
+ ): { kept: string[]; dropped: { query: string; similarTo: string }[] } {
251
+ const kept: string[] = [];
252
+ const dropped: { query: string; similarTo: string }[] = [];
253
+ for (const q of queries) {
254
+ const twin = kept.find((k) => jaccard(k, q) >= threshold);
255
+ if (twin) dropped.push({ query: q, similarTo: twin });
256
+ else kept.push(q);
257
+ }
258
+ return { kept, dropped };
259
+ }
260
+
261
+ /** Scratchpad dosyalarindaki URL'ler (CitationAgent girdisi: hafizadan degil, diskten). */
262
+ export function collectSources(cwd: string): { url: string; file: string }[] {
263
+ const dir = researchDir(cwd);
264
+ if (!existsSync(dir)) return [];
265
+ const seen = new Set<string>();
266
+ const out: { url: string; file: string }[] = [];
267
+ for (const n of readdirSync(dir)
268
+ .filter((f) => f.endsWith(".md"))
269
+ .sort()) {
270
+ for (const m of readFileSync(join(dir, n), "utf8").matchAll(/https?:\/\/[^\s)\]>"'`]+/g)) {
271
+ const url = m[0].replace(/[.,;:]+$/, "");
272
+ if (seen.has(url)) continue;
273
+ seen.add(url);
274
+ out.push({ url, file: n });
275
+ }
276
+ }
277
+ return out;
278
+ }
279
+
280
+ export type ResearchTaskKind = "gather" | "verify" | "cite";
281
+
282
+ /** `task` aracina verilecek hazir sablon (subagent_type vermeden; ayri baglam). */
283
+ export function researchTaskPrompt(cwd: string, kind: ResearchTaskKind, subject: string, scratchpad?: string): string {
284
+ if (kind === "gather") {
285
+ const pad = scratchpad || "alt1";
286
+ return [
287
+ `You are a research subagent. Objective: ${subject}`,
288
+ `Use web_search (start broad, depth 1) and web_fetch; call 3+ tools in parallel. Write findings with research_note(scratchpad="${pad}", section, text) and read them back with research_recall before relying on them.`,
289
+ "Every claim carries a source as [id](url); mark vendor-reported numbers. Do not answer current facts from memory.",
290
+ `Done-boundary: stop when the objective is answered or you have used ~8 turns. Return ONLY a distilled summary of at most ${RESEARCH_SUMMARY_MAX_TOKENS} tokens.`,
291
+ ].join("\n");
292
+ }
293
+ if (kind === "verify")
294
+ return [
295
+ "You are a VERIFIER, not a searcher. Same tools as the search agents; different job.",
296
+ `Claim to verify: ${subject}`,
297
+ "Verify whether this claim holds; give confidence (0-100) and the independent sources you checked. Prefer primary sources; flag vendor-reported numbers as hypotheses. Verification needs far fewer calls than searching (~18 vs ~75): stop as soon as the claim is confirmed or refuted.",
298
+ `Return: VERDICT (holds / partly / fails / unverifiable), CONFIDENCE, [id](url) sources, one-line reason. At most ${RESEARCH_SUMMARY_MAX_TOKENS} tokens.`,
299
+ ].join("\n");
300
+ const src = collectSources(cwd);
301
+ return [
302
+ "You are the CitationAgent, a SEPARATE pass with its own context. Do NOT reconstruct URLs from memory.",
303
+ "Use ONLY the sources listed below, taken from the scratchpad files on disk. Attach a numbered citation to each claim in the draft; if a claim has no listed source, mark it [no source] instead of inventing one.",
304
+ `Draft/claims: ${subject}`,
305
+ "Sources (from .sera/research/):",
306
+ src.length
307
+ ? src.map((s, i) => `[${i + 1}] ${s.url} (${s.file})`).join("\n")
308
+ : "(none found - mark every claim [no source])",
309
+ "Return the draft with numbered citations and a final Sources list.",
310
+ ].join("\n");
311
+ }
312
+
313
+ export function registerResearchWorkflowTools(pi: ExtensionAPI): void {
314
+ pi.registerTool({
315
+ name: "research_divinit",
316
+ exposure: rareExposure(),
317
+ label: "Research DivInit",
318
+ description:
319
+ "DivInit: ilk tur sorgularini cesitlilik filtresinden gecirir; ayni niyeti tasiyan (kelime kumesi Jaccard >= 0.6) sorgulardan biri atilir. Subagent'lara dagitmadan ONCE cagir.",
320
+ promptSnippet: "Ilk tur sorgularini cesitlendir (queries[])",
321
+ parameters: Type.Object({ queries: Type.Array(Type.String(), { description: "Aday sorgular" }) }),
322
+ async execute(_id, params) {
323
+ const { kept, dropped } = diversityFilter((params as { queries: string[] }).queries);
324
+ return out(
325
+ `Tutulan (${kept.length}):\n${kept.map((q) => `- ${q}`).join("\n")}\nAtilan (${dropped.length}):\n${dropped.map((d) => `- ${d.query} (benzer: ${d.similarTo})`).join("\n") || "-"}`,
326
+ );
327
+ },
328
+ });
329
+ pi.registerTool({
330
+ name: "research_task",
331
+ exposure: rareExposure(),
332
+ label: "Research task template",
333
+ description:
334
+ "`task` araci icin hazir arastirma sablonu uretir. kind: gather (3-5 paralel toplayici, ~2K ozet), verify (ayri dogrulama gecisi: 'verify whether this claim holds; give confidence'), cite (CitationAgent: URL'ler yalniz scratchpad dosyalarindan). Donen metni AYNEN task'in prompt'u olarak ver.",
335
+ promptSnippet: "task icin arastirma sablonu al (kind, subject, ops. scratchpad)",
336
+ parameters: Type.Object({
337
+ kind: Type.Union([Type.Literal("gather"), Type.Literal("verify"), Type.Literal("cite")]),
338
+ subject: Type.String({ description: "gather: hedef; verify: dogrulanacak iddia; cite: taslak/iddialar" }),
339
+ scratchpad: Type.Optional(Type.String({ description: "gather: alt ajanin scratchpad adi" })),
340
+ }),
341
+ async execute(_id, params, _s, _u, ctx) {
342
+ const p = params as { kind: ResearchTaskKind; subject: string; scratchpad?: string };
343
+ if (p.scratchpad && !NAME_RE.test(p.scratchpad)) return out("[research_task] gecersiz scratchpad adi", true);
344
+ return out(researchTaskPrompt(ctx?.cwd ?? process.cwd(), p.kind, p.subject, p.scratchpad));
345
+ },
346
+ });
347
+ }
@@ -0,0 +1,227 @@
1
+ /**
2
+ * Kural zinciri + kalici bellek (D1-6).
3
+ *
4
+ * Motor AGENTS.md/CLAUDE.md zincirini zaten yukler (genel ~/.sera/engine + kokten calisma klasorune ust klasorler;
5
+ * siralama: genel, sonra kok -> yakin; yakin olan sonda = cakismada o gecerli). Sera burada:
6
+ * 1) ~/.sera/AGENTS.md (Sera kullanici kurallari) zincirin basina eklenir (motorun genel dosyasindan once degil, onunla ayni kapsam).
7
+ * 2) Bellek: kullanici ~/.sera/memory.md + proje <proje>/.sera/memory.md; zincirin SONUNA (en yuksek oncelik: proje bellegi).
8
+ * 3) Token ust siniri: kurallar ve bellek ayri butcelerle budanir. Kurallarda en UZAK dosya once kisalir/duser;
9
+ * bellekte en ESKI kayit once duser. Sinir asilmaz.
10
+ * 4) Yazma kapisi (web lib/memory-write-gate.ts ile ayni anlam): SERA_MEMORY_WRITE=0 -> yeni kayit reddedilir, okuma etkilenmez.
11
+ */
12
+
13
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
14
+ import { dirname, join } from "node:path";
15
+
16
+ export interface ContextFile {
17
+ path: string;
18
+ content: string;
19
+ }
20
+
21
+ export const MEMORY_COMMAND = "hatirla";
22
+ /** ~4 karakter = 1 token (kaba ama sabit; ust sinir icin yeterli). */
23
+ export const CHARS_PER_TOKEN = 4;
24
+
25
+ export function truncatedNote(skipped: number): string {
26
+ return `\n…(Sera: bağlam sınırı nedeniyle kısaltıldı, ${skipped} karakter atlandı)`;
27
+ }
28
+
29
+ /**
30
+ * Dosyalari toplam `maxChars` sinirina indirir. En yakin (dizinin SONU) once yer alir; sigmayan dosya kisaltilir,
31
+ * hic yer kalmayanlar duser. Sira korunur.
32
+ */
33
+ export function capFiles(
34
+ files: ContextFile[],
35
+ maxChars: number,
36
+ ): { files: ContextFile[]; truncated: string[]; dropped: string[] } {
37
+ let left = Math.max(0, maxChars);
38
+ const keep: (ContextFile | undefined)[] = new Array(files.length);
39
+ const truncated: string[] = [];
40
+ const dropped: string[] = [];
41
+ for (let i = files.length - 1; i >= 0; i--) {
42
+ const f = files[i]!;
43
+ if (f.content.length <= left) {
44
+ keep[i] = f;
45
+ left -= f.content.length;
46
+ continue;
47
+ }
48
+ const note = truncatedNote(f.content.length);
49
+ if (left <= note.length + 200) {
50
+ dropped.push(f.path);
51
+ left = 0;
52
+ continue;
53
+ }
54
+ const room = left - note.length - 20;
55
+ const head = f.content.slice(0, room);
56
+ keep[i] = { path: f.path, content: head + truncatedNote(f.content.length - head.length) };
57
+ truncated.push(f.path);
58
+ left = 0;
59
+ }
60
+ return { files: keep.filter((f): f is ContextFile => !!f), truncated, dropped };
61
+ }
62
+
63
+ /** Bellek metninden en YENI kayitlari (satir) siniri asmadan tutar. */
64
+ export function capMemory(text: string, maxChars: number): string {
65
+ const lines = text.split("\n").filter((l) => l.trim());
66
+ const out: string[] = [];
67
+ let used = 0;
68
+ for (let i = lines.length - 1; i >= 0; i--) {
69
+ const l = lines[i]!;
70
+ if (used + l.length + 1 > maxChars) break;
71
+ out.unshift(l);
72
+ used += l.length + 1;
73
+ }
74
+ return out.join("\n");
75
+ }
76
+
77
+ const SECRET =
78
+ /(sk-[A-Za-z0-9_-]{16,}|gh[pousr]_[A-Za-z0-9]{20,}|AKIA[0-9A-Z]{16}|eyJ[A-Za-z0-9_-]{20,}\.[A-Za-z0-9_-]{10,}|-----BEGIN [A-Z ]*PRIVATE KEY|(?:api[_-]?key|token|password|parola|sifre|şifre)\s*[:=]\s*\S{6,})/i;
79
+
80
+ export class MemoryStore {
81
+ readonly file: string;
82
+ readonly writable: boolean;
83
+ constructor(file: string, writable = true) {
84
+ this.file = file;
85
+ this.writable = writable;
86
+ }
87
+ read(): string {
88
+ try {
89
+ return readFileSync(this.file, "utf8");
90
+ } catch {
91
+ return "";
92
+ }
93
+ }
94
+ /** Yeni kayit. Kapali kapi, bos metin, sir benzeri icerik Turkce hata ile reddedilir. */
95
+ add(text: string, now = new Date()): string {
96
+ if (!this.writable)
97
+ throw new Error("Bellek yazma kapalı (SERA_MEMORY_WRITE=0). Okuma serbest; yalnız yeni kayıt eklenemez.");
98
+ const t = text.replace(/\s+/g, " ").trim();
99
+ if (!t) throw new Error("Hatırlanacak metin boş. Kullanım: /hatirla <metin> | /hatirla genel <metin>");
100
+ if (t.length > 500) throw new Error("Bellek kaydı en fazla 500 karakter olabilir.");
101
+ if (SECRET.test(t)) throw new Error("Bu metin parola/anahtar gibi görünüyor; belleğe yazılmadı.");
102
+ const line = `- [${now.toISOString().slice(0, 10)}] ${t}`;
103
+ const old = this.read();
104
+ mkdirSync(dirname(this.file), { recursive: true });
105
+ writeFileSync(this.file, `${old}${old && !old.endsWith("\n") ? "\n" : ""}${line}\n`);
106
+ return line;
107
+ }
108
+ lines(): string[] {
109
+ return memoryLines(this.read());
110
+ }
111
+ /** /bellek duzenle <n> <metin>: n. kaydin metnini degistirir, tarih etiketi korunur; kurallar add ile ayni. */
112
+ update(n: number | string, text: string): string {
113
+ if (!this.writable)
114
+ throw new Error("Bellek yazma kapalı (SERA_MEMORY_WRITE=0). Okuma serbest; yalnız yeni kayıt eklenemez.");
115
+ const lines = this.lines();
116
+ if (!/^\d+$/.test(String(n)) || Number(n) < 1 || Number(n) > lines.length)
117
+ throw new Error(`Bu numarada not yok: ${n} (toplam ${lines.length}).`);
118
+ const t = text.replace(/\s+/g, " ").trim();
119
+ if (!t) throw new Error("Hatırlanacak metin boş. Kullanım: /hatirla <metin> | /hatirla genel <metin>");
120
+ if (t.length > 500) throw new Error("Bellek kaydı en fazla 500 karakter olabilir.");
121
+ if (SECRET.test(t)) throw new Error("Bu metin parola/anahtar gibi görünüyor; belleğe yazılmadı.");
122
+ const i = Number(n) - 1;
123
+ const date = /^- (\[\d{4}-\d{2}-\d{2}\] )/.exec(lines[i]!);
124
+ const out = lines.slice();
125
+ out[i] = `- ${date ? date[1] : ""}${t}`;
126
+ writeFileSync(
127
+ this.file,
128
+ out
129
+ .map(
130
+ (l) => `${l}
131
+ `,
132
+ )
133
+ .join(""),
134
+ );
135
+ return out[i]!;
136
+ }
137
+ /** /unut: numarali kaydi ya da hepsini siler; donus silinen satirlar. */
138
+ forget(arg: string): string[] {
139
+ if (!this.writable)
140
+ throw new Error("Bellek yazma kapalı (SERA_MEMORY_WRITE=0). Okuma serbest; yalnız yeni kayıt eklenemez.");
141
+ const r = forgetLines(this.lines(), arg);
142
+ if ("error" in r) throw new Error(r.error);
143
+ writeFileSync(this.file, r.lines.map((l) => `${l}\n`).join(""));
144
+ return r.removed;
145
+ }
146
+ }
147
+
148
+ export function memoryLines(text: string): string[] {
149
+ return text.split("\n").filter((l) => l.trim());
150
+ }
151
+
152
+ const FORGET_USAGE = "Kullanım: /unut <no> | /unut hepsi | /unut genel <no> (tüm projeler)";
153
+
154
+ /** Web ile ayni kural (sera-web/lib/memory-rules.vectors.json "forget"). */
155
+ export function forgetLines(lines: string[], arg: string): { lines: string[]; removed: string[] } | { error: string } {
156
+ const a = arg.trim().toLowerCase();
157
+ if (!lines.length) return { error: "Silinecek not yok." };
158
+ if (a === "hepsi") return { lines: [], removed: lines };
159
+ if (!/^\d+$/.test(a)) return { error: FORGET_USAGE };
160
+ const n = Number(a);
161
+ if (n < 1 || n > lines.length) return { error: `Bu numarada not yok: ${n} (toplam ${lines.length}).` };
162
+ return { lines: lines.filter((_, i) => i !== n - 1), removed: [lines[n - 1]!] };
163
+ }
164
+
165
+ /** /bellek ciktisi (web ile ayni bicim). */
166
+ export function memoryListText(project: string[], user: string[]): string {
167
+ const sec = (title: string, ls: string[]) =>
168
+ `${title}:\n${ls.length ? ls.map((l, i) => `${i + 1}. ${l.replace(/^- /, "")}`).join("\n") : "(boş)"}`;
169
+ return `${sec("Bu proje", project)}\n${sec("Tüm projeler", user)}`;
170
+ }
171
+
172
+ export interface RulesMemoryOptions {
173
+ home: string;
174
+ cwd: string;
175
+ maxRuleTokens: number;
176
+ maxMemoryTokens: number;
177
+ }
178
+
179
+ export function memoryPaths(home: string, cwd: string): { user: string; project: string } {
180
+ return { user: join(home, "memory.md"), project: join(cwd, ".sera", "memory.md") };
181
+ }
182
+
183
+ /** Motorun bagalam dosyalarina Sera kurallarini ve bellegi ekler, sinirlar uygular. */
184
+ export function applyRulesMemory(
185
+ files: ContextFile[],
186
+ o: RulesMemoryOptions,
187
+ ): { files: ContextFile[]; truncated: string[]; dropped: string[] } {
188
+ const rules = [...files];
189
+ const userRules = join(o.home, "AGENTS.md");
190
+ if (existsSync(userRules) && !rules.some((f) => f.path === userRules)) {
191
+ try {
192
+ rules.unshift({ path: userRules, content: readFileSync(userRules, "utf8") });
193
+ } catch {
194
+ // okunamadi: atla
195
+ }
196
+ }
197
+ const capped = capFiles(rules, o.maxRuleTokens * CHARS_PER_TOKEN);
198
+ const mp = memoryPaths(o.home, o.cwd);
199
+ const mem: ContextFile[] = [];
200
+ let budget = o.maxMemoryTokens * CHARS_PER_TOKEN;
201
+ // proje bellegi once butce alir (daha ozel), sonra kullanici; siralamada kullanici once, proje sonda (oncelik).
202
+ const proj = capMemory(new MemoryStore(mp.project).read(), budget);
203
+ budget -= proj.length;
204
+ const user = capMemory(new MemoryStore(mp.user).read(), Math.max(0, budget));
205
+ const header = "Sera belleği (kullanıcının /hatirla ile kaydettiği notlar; çakışmada proje notu geçerli):\n";
206
+ if (user) mem.push({ path: `${mp.user} (Sera belleği: kullanıcı)`, content: header + user });
207
+ if (proj) mem.push({ path: `${mp.project} (Sera belleği: proje)`, content: header + proj });
208
+ return { files: [...capped.files, ...mem], truncated: capped.truncated, dropped: capped.dropped };
209
+ }
210
+
211
+ /** Web ile BIREBIR (sera-web/public/assets/sera-memory.js SHOW_RE + isShowIntent): "neleri hatirliyorsun" gibi KISA dogal istek. */
212
+ export const SHOW_INTENT_SOURCES = [
213
+ "(neleri|neyi|nelerimi|ne)\\s+(hatırlıyorsun|hatirliyorsun|biliyorsun)(\\s+benim\\s+hakkımda|\\s+benim\\s+hakkimda|\\s+hakkımda|\\s+hakkimda)?",
214
+ "(hafızanı|hafizani|belleğini|bellegini|notlarını|notlarini)\\s+(göster|goster|aç|ac|listele)",
215
+ "(hafızan|hafizan|belleğin|bellegin)\\s+(neler|ne)",
216
+ "hatırladıkların|hatirladiklarin|hatırladıklarım|hatirladiklarim",
217
+ "what\\s+do\\s+you\\s+(remember|know)(\\s+about\\s+me)?",
218
+ "(show|open)\\s+(your\\s+|my\\s+)?(memory|memories|notes)",
219
+ ];
220
+ const SHOW_RE = new RegExp(SHOW_INTENT_SOURCES.join("|"), "i");
221
+ export function isShowIntent(text: string): boolean {
222
+ const t = String(text ?? "").trim();
223
+ if (!t || t.length > 60 || t.charAt(0) === "/") return false;
224
+ const lo = t.toLocaleLowerCase("tr").replace(/[?!.\s]+$/g, "");
225
+ const m = SHOW_RE.exec(lo);
226
+ return !!m && m[0].length >= lo.length * 0.6;
227
+ }