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.
- package/LICENSE +21 -0
- package/NOTICE-SERA.md +25 -0
- package/README.md +27 -2
- package/THIRD_PARTY_NOTICES.md +68 -0
- package/bin/sera.mjs +137 -0
- package/dist/bundle/chunks/anthropic-messages-RD7GXOQL.js +6 -0
- package/dist/bundle/chunks/anthropic.js +75 -0
- package/dist/bundle/chunks/azure-openai-responses-CJT3KTVK.js +2 -0
- package/dist/bundle/chunks/bedrock-converse-stream.js +89 -0
- package/dist/bundle/chunks/chunk-46WGNYIE.js +82 -0
- package/dist/bundle/chunks/chunk-4UNN5OGR.js +4 -0
- package/dist/bundle/chunks/chunk-53H5DPHA.js +16 -0
- package/dist/bundle/chunks/chunk-5AGIVGSV.js +6 -0
- package/dist/bundle/chunks/chunk-6JXVX6Q2.js +2 -0
- package/dist/bundle/chunks/chunk-6QGV3IWD.js +6 -0
- package/dist/bundle/chunks/chunk-7CBJINYJ.js +20 -0
- package/dist/bundle/chunks/chunk-7DDKXS2Q.js +2 -0
- package/dist/bundle/chunks/chunk-7RZ5BS7U.js +2 -0
- package/dist/bundle/chunks/chunk-7ZC4UXSL.js +2 -0
- package/dist/bundle/chunks/chunk-BPHHHEET.js +9 -0
- package/dist/bundle/chunks/chunk-BSS6T6KQ.js +2 -0
- package/dist/bundle/chunks/chunk-CF5GWZHW.js +31 -0
- package/dist/bundle/chunks/chunk-EDSQGWII.js +44 -0
- package/dist/bundle/chunks/chunk-FFMDRXC4.js +10 -0
- package/dist/bundle/chunks/chunk-GUGC72EB.js +1222 -0
- package/dist/bundle/chunks/chunk-HODJBMOY.js +9 -0
- package/dist/bundle/chunks/chunk-HQBQWHLD.js +7 -0
- package/dist/bundle/chunks/chunk-HQJBN2MC.js +2 -0
- package/dist/bundle/chunks/chunk-JXWJOIH4.js +2 -0
- package/dist/bundle/chunks/chunk-KXU77PUU.js +4 -0
- package/dist/bundle/chunks/chunk-L2ZPNLYD.js +2 -0
- package/dist/bundle/chunks/chunk-LPXNMA2W.js +2 -0
- package/dist/bundle/chunks/chunk-LVVZS2NO.js +12 -0
- package/dist/bundle/chunks/chunk-M3LEVT3X.js +2 -0
- package/dist/bundle/chunks/chunk-P7FPUEYA.js +2 -0
- package/dist/bundle/chunks/chunk-PGXDEOVV.js +2 -0
- package/dist/bundle/chunks/chunk-PJACZCIR.js +2 -0
- package/dist/bundle/chunks/chunk-PMRZO46Y.js +2 -0
- package/dist/bundle/chunks/chunk-PRRNXB7S.js +2 -0
- package/dist/bundle/chunks/chunk-QTM7S6TH.js +2 -0
- package/dist/bundle/chunks/chunk-RDZVAGPR.js +2 -0
- package/dist/bundle/chunks/chunk-TLNP2BSO.js +2 -0
- package/dist/bundle/chunks/chunk-TMKHGABX.js +2 -0
- package/dist/bundle/chunks/chunk-TMTOQ7H7.js +2 -0
- package/dist/bundle/chunks/chunk-UKVNB6C4.js +2 -0
- package/dist/bundle/chunks/chunk-USJZMAIR.js +2 -0
- package/dist/bundle/chunks/chunk-UTB4DTYQ.js +2 -0
- package/dist/bundle/chunks/chunk-ZLAHUYDW.js +131 -0
- package/dist/bundle/chunks/chunk-ZNCN2NGY.js +60 -0
- package/dist/bundle/chunks/cli-MML2DU4A.js +51 -0
- package/dist/bundle/chunks/cloudflare-workers-ai-system-one-QPZQRBK5.js +2 -0
- package/dist/bundle/chunks/codemode-worker.js +478 -0
- package/dist/bundle/chunks/dist-ZNZCJI7B.js +7 -0
- package/dist/bundle/chunks/easter-egg-3d-VOETWRJO.js +2 -0
- package/dist/bundle/chunks/execute-HXDNZ26B.js +505 -0
- package/dist/bundle/chunks/github-copilot.js +2 -0
- package/dist/bundle/chunks/google-generative-ai-SJXMIEPZ.js +2 -0
- package/dist/bundle/chunks/google-vertex-VSXQ3BDH.js +2 -0
- package/dist/bundle/chunks/https-proxy-agent-LVOO5TPL.js +13 -0
- package/dist/bundle/chunks/image-resize-worker.js +2 -0
- package/dist/bundle/chunks/jiti-loader-GL4HJFAD.js +21 -0
- package/dist/bundle/chunks/jiti-static-loader-2RCDI6B4.js +2 -0
- package/dist/bundle/chunks/kimi-coding.js +2 -0
- package/dist/bundle/chunks/lib-4AVRLBHM.js +9 -0
- package/dist/bundle/chunks/llama-cpp-classify-4KFSGAMH.js +22 -0
- package/dist/bundle/chunks/meta.js +2 -0
- package/dist/bundle/chunks/mistral-conversations-JYWDZV2K.js +5 -0
- package/dist/bundle/chunks/multipart-parser-FMGQ7342.js +3 -0
- package/dist/bundle/chunks/node-AUOGOBCN.js +2 -0
- package/dist/bundle/chunks/node-KCMANYC2.js +16 -0
- package/dist/bundle/chunks/openai-chatgpt.js +75 -0
- package/dist/bundle/chunks/openai-codex-responses-OQV5DCFA.js +10 -0
- package/dist/bundle/chunks/openai-codex.js +75 -0
- package/dist/bundle/chunks/openai-completions-RFDJM2W5.js +7 -0
- package/dist/bundle/chunks/openai-decisions-O6PHBSCB.js +5 -0
- package/dist/bundle/chunks/openai-responses-LVNAPALQ.js +4 -0
- package/dist/bundle/chunks/openrouter-images-4WG6OOLH.js +2 -0
- package/dist/bundle/chunks/openrouter.js +75 -0
- package/dist/bundle/chunks/pdfjs-BETXZQ7A.js +108 -0
- package/dist/bundle/chunks/pdfjs-decoders-37HBPYHX.js +2 -0
- package/dist/bundle/chunks/pdfjs-jbig2-MH7WRXUP.js +2 -0
- package/dist/bundle/chunks/pdfjs-jbig2_nowasm_fallback-UVK7AQLA.js +2 -0
- package/dist/bundle/chunks/pdfjs-openjpeg-TC2QHC4G.js +2 -0
- package/dist/bundle/chunks/pdfjs-openjpeg_nowasm_fallback-ZC2FTHCZ.js +3 -0
- package/dist/bundle/chunks/pi-messages-EZXKVRR6.js +8 -0
- package/dist/bundle/chunks/radius.js +75 -0
- package/dist/bundle/chunks/runtime-JAH75CB5.js +2 -0
- package/dist/bundle/chunks/src-QKGKDFSU.js +4 -0
- package/dist/bundle/chunks/typesafe-system-one-X3JT6ECA.js +2 -0
- package/dist/bundle/chunks/virtual-modules-I5QRIHN6.js +2 -0
- package/dist/bundle/chunks/xai.js +2 -0
- package/dist/bundle/cli-runtime.js +3 -0
- package/dist/bundle/cli.js +5 -0
- package/dist/bundle/index.js +2 -0
- package/dist/bundle/rpc-entry.js +3 -0
- package/dist/core/export-html/ansi-to-html.d.ts +22 -0
- package/dist/core/export-html/ansi-to-html.d.ts.map +1 -0
- package/dist/core/export-html/ansi-to-html.js +249 -0
- package/dist/core/export-html/ansi-to-html.js.map +1 -0
- package/dist/core/export-html/index.d.ts +37 -0
- package/dist/core/export-html/index.d.ts.map +1 -0
- package/dist/core/export-html/index.js +228 -0
- package/dist/core/export-html/index.js.map +1 -0
- package/dist/core/export-html/template.css +1085 -0
- package/dist/core/export-html/template.html +56 -0
- package/dist/core/export-html/template.js +2044 -0
- package/dist/core/export-html/tool-renderer.d.ts +34 -0
- package/dist/core/export-html/tool-renderer.d.ts.map +1 -0
- package/dist/core/export-html/tool-renderer.js +110 -0
- package/dist/core/export-html/tool-renderer.js.map +1 -0
- package/dist/core/export-html/vendor/highlight.min.js +1213 -0
- package/dist/core/export-html/vendor/marked-cjk-friendly.min.js +6 -0
- package/dist/core/export-html/vendor/marked.min.js +79 -0
- package/dist/modes/interactive/assets/clankolas.png +0 -0
- package/dist/modes/interactive/theme/dark.json +81 -0
- package/dist/modes/interactive/theme/light.json +81 -0
- package/dist/modes/interactive/theme/system-theme.d.ts +55 -0
- package/dist/modes/interactive/theme/system-theme.d.ts.map +1 -0
- package/dist/modes/interactive/theme/system-theme.js +546 -0
- package/dist/modes/interactive/theme/system-theme.js.map +1 -0
- package/dist/modes/interactive/theme/theme-controller.d.ts +81 -0
- package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme-controller.js +210 -0
- package/dist/modes/interactive/theme/theme-controller.js.map +1 -0
- package/dist/modes/interactive/theme/theme-schema.d.ts +28 -0
- package/dist/modes/interactive/theme/theme-schema.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme-schema.js +105 -0
- package/dist/modes/interactive/theme/theme-schema.js.map +1 -0
- package/dist/modes/interactive/theme/theme-tokens.d.ts +257 -0
- package/dist/modes/interactive/theme/theme-tokens.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme-tokens.js +94 -0
- package/dist/modes/interactive/theme/theme-tokens.js.map +1 -0
- package/dist/modes/interactive/theme/theme.d.ts +155 -0
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme.js +905 -0
- package/dist/modes/interactive/theme/theme.js.map +1 -0
- package/docs/cli-integration.md +106 -0
- package/docs/cli.md +333 -0
- package/docs/codemode.md +230 -0
- package/docs/compaction.md +463 -0
- package/docs/configuration.md +47 -0
- package/docs/containerization.md +183 -0
- package/docs/custom-provider.md +227 -0
- package/docs/docs.json +220 -0
- package/docs/environment-variables.md +102 -0
- package/docs/extensions.md +400 -0
- package/docs/how-pi-works.md +49 -0
- package/docs/index.md +39 -0
- package/docs/json.md +226 -0
- package/docs/keybindings.md +195 -0
- package/docs/llama-cpp.md +121 -0
- package/docs/mcp.md +272 -0
- package/docs/message-types.md +279 -0
- package/docs/models-configuration.md +196 -0
- package/docs/models.md +225 -0
- package/docs/nvidia-rtx-llama-cpp.md +96 -0
- package/docs/packages.md +131 -0
- package/docs/prompt-templates.md +59 -0
- package/docs/providers.md +247 -0
- package/docs/quickstart.md +136 -0
- package/docs/rpc-commands.md +860 -0
- package/docs/rpc-extension-ui.md +200 -0
- package/docs/rpc.md +193 -0
- package/docs/sdk.md +147 -0
- package/docs/security.md +99 -0
- package/docs/session-format.md +293 -0
- package/docs/sessions.md +66 -0
- package/docs/settings.md +172 -0
- package/docs/shell-aliases.md +93 -0
- package/docs/skills.md +93 -0
- package/docs/slash-commands.md +61 -0
- package/docs/terminal-setup.md +233 -0
- package/docs/termux.md +117 -0
- package/docs/themes.md +138 -0
- package/docs/tmux.md +55 -0
- package/docs/tui.md +195 -0
- package/docs/usage.md +94 -0
- package/docs/virtual-models.md +114 -0
- package/docs/windows.md +81 -0
- package/lib/auth.js +190 -0
- package/lib/provider.js +52 -0
- package/package.json +43 -5
- package/sera-core/skills/apple-tasarim/SKILL.md +48 -0
- package/sera-core/skills/apple-tasarim/referanslar/apple-hig.md +55 -0
- package/sera-core/skills/belge-yarat/SKILL.md +64 -0
- package/sera-core/skills/belge-yarat/referanslar/belge-yazim.md +60 -0
- package/sera-core/skills/derin-arastirma/SKILL.md +52 -0
- package/sera-core/skills/derin-arastirma/referanslar/arastirma-yontem.md +50 -0
- package/sera-core/skills/dusunme-dogrulama/SKILL.md +59 -0
- package/sera-core/skills/dusunme-dogrulama/referanslar/dusunme-kontrol.md +54 -0
- package/sera-core/skills/film-stilleri/SKILL.md +51 -0
- package/sera-core/skills/hyperframes/LICENSE-UPSTREAM +190 -0
- package/sera-core/skills/hyperframes/SKILL.md +79 -0
- package/sera-core/skills/hyperframes/assets/frame-presets/biennale-yellow/FRAME.md +289 -0
- package/sera-core/skills/hyperframes/assets/frame-presets/blockframe/FRAME.md +275 -0
- package/sera-core/skills/hyperframes/assets/frame-presets/blue-professional/FRAME.md +307 -0
- package/sera-core/skills/hyperframes/assets/frame-presets/bold-poster/FRAME.md +275 -0
- package/sera-core/skills/hyperframes/assets/frame-presets/broadside/FRAME.md +284 -0
- package/sera-core/skills/hyperframes/assets/frame-presets/capsule/FRAME.md +284 -0
- package/sera-core/skills/hyperframes/assets/frame-presets/cartesian/FRAME.md +278 -0
- package/sera-core/skills/hyperframes/assets/frame-presets/cobalt-grid/FRAME.md +265 -0
- package/sera-core/skills/hyperframes/assets/frame-presets/code-editorial/FRAME.md +277 -0
- package/sera-core/skills/hyperframes/assets/frame-presets/coral/FRAME.md +314 -0
- package/sera-core/skills/hyperframes/assets/frame-presets/creative-mode/FRAME.md +333 -0
- package/sera-core/skills/hyperframes/assets/frame-presets/daisy-days/FRAME.md +274 -0
- package/sera-core/skills/hyperframes/assets/frame-presets/editorial-forest/FRAME.md +265 -0
- package/sera-core/skills/hyperframes/references/captions.md +46 -0
- package/sera-core/skills/hyperframes/references/film.md +48 -0
- package/sera-core/skills/hyperframes/references/format.md +159 -0
- package/sera-core/skills/hyperframes/references/look.md +69 -0
- package/sera-core/skills/hyperframes/references/motion.md +95 -0
- package/sera-core/skills/hyperframes/references/overlays.md +39 -0
- package/sera-core/skills/hyperframes/references/path-tracing.md +36 -0
- package/sera-core/skills/hyperframes/references/plugin-installation.md +42 -0
- package/sera-core/skills/hyperframes/references/review.md +51 -0
- package/sera-core/skills/hyperframes/references/runtimes.md +69 -0
- package/sera-core/skills/hyperframes/references/skill-lifecycle.md +54 -0
- package/sera-core/skills/hyperframes/references/sound.md +43 -0
- package/sera-core/skills/hyperframes/references/spec.md +76 -0
- package/sera-core/skills/hyperframes/references/story.md +103 -0
- package/sera-core/skills/hyperframes/references/storyboard-format.md +107 -0
- package/sera-core/skills/hyperframes/references/storyboard.md +36 -0
- package/sera-core/skills/hyperframes/references/types/3d.md +25 -0
- package/sera-core/skills/hyperframes/references/types/character.md +20 -0
- package/sera-core/skills/hyperframes/references/types/data.md +19 -0
- package/sera-core/skills/hyperframes/references/types/explainer.md +34 -0
- package/sera-core/skills/hyperframes/references/types/launch.md +41 -0
- package/sera-core/skills/hyperframes/references/types/music.md +24 -0
- package/sera-core/skills/hyperframes/references/types/vertical.md +23 -0
- package/sera-core/skills/hyperframes-cli/LICENSE-UPSTREAM +190 -0
- package/sera-core/skills/hyperframes-cli/SKILL.md +99 -0
- package/sera-core/skills/hyperframes-cli/references/beats.md +17 -0
- package/sera-core/skills/hyperframes-cli/references/compare-and-batch.md +105 -0
- package/sera-core/skills/hyperframes-cli/references/conventions.md +16 -0
- package/sera-core/skills/hyperframes-cli/references/doctor-browser.md +80 -0
- package/sera-core/skills/hyperframes-cli/references/feedback.md +14 -0
- package/sera-core/skills/hyperframes-cli/references/init-and-scaffold.md +75 -0
- package/sera-core/skills/hyperframes-cli/references/lint-validate-inspect.md +164 -0
- package/sera-core/skills/hyperframes-cli/references/preview-render.md +204 -0
- package/sera-core/skills/hyperframes-cli/references/upgrade-info-misc.md +134 -0
- package/sera-core/skills/impeccable/LICENSE-UPSTREAM +191 -0
- package/sera-core/skills/impeccable/NOTICE-UPSTREAM.md +11 -0
- package/sera-core/skills/impeccable/SKILL.md +89 -0
- package/sera-core/skills/impeccable/reference/adapt.md +318 -0
- package/sera-core/skills/impeccable/reference/adapt.native.md +58 -0
- package/sera-core/skills/impeccable/reference/android.md +46 -0
- package/sera-core/skills/impeccable/reference/animate.md +89 -0
- package/sera-core/skills/impeccable/reference/audit.md +139 -0
- package/sera-core/skills/impeccable/reference/audit.native.md +139 -0
- package/sera-core/skills/impeccable/reference/bolder.md +33 -0
- package/sera-core/skills/impeccable/reference/clarify.md +94 -0
- package/sera-core/skills/impeccable/reference/colorize.md +86 -0
- package/sera-core/skills/impeccable/reference/component-review.md +63 -0
- package/sera-core/skills/impeccable/reference/craft-floor.md +44 -0
- package/sera-core/skills/impeccable/reference/craft.md +5 -0
- package/sera-core/skills/impeccable/reference/critique.md +819 -0
- package/sera-core/skills/impeccable/reference/degraded/asset-producer.md +42 -0
- package/sera-core/skills/impeccable/reference/degraded/documenter.md +24 -0
- package/sera-core/skills/impeccable/reference/degraded/finish-reviewer.md +38 -0
- package/sera-core/skills/impeccable/reference/degraded/manual-edit-applier.md +93 -0
- package/sera-core/skills/impeccable/reference/delight.md +70 -0
- package/sera-core/skills/impeccable/reference/distill.md +111 -0
- package/sera-core/skills/impeccable/reference/doctor.md +54 -0
- package/sera-core/skills/impeccable/reference/document.md +416 -0
- package/sera-core/skills/impeccable/reference/extract.md +69 -0
- package/sera-core/skills/impeccable/reference/generate.md +101 -0
- package/sera-core/skills/impeccable/reference/harden.md +362 -0
- package/sera-core/skills/impeccable/reference/hooks.md +120 -0
- package/sera-core/skills/impeccable/reference/init.md +133 -0
- package/sera-core/skills/impeccable/reference/ios.md +51 -0
- package/sera-core/skills/impeccable/reference/layout.md +84 -0
- package/sera-core/skills/impeccable/reference/live-setup.md +104 -0
- package/sera-core/skills/impeccable/reference/live.md +327 -0
- package/sera-core/skills/impeccable/reference/mode-operate.md +21 -0
- package/sera-core/skills/impeccable/reference/mode-persuade.md +19 -0
- package/sera-core/skills/impeccable/reference/mode-read.md +21 -0
- package/sera-core/skills/impeccable/reference/new-work.md +152 -0
- package/sera-core/skills/impeccable/reference/onboard.md +234 -0
- package/sera-core/skills/impeccable/reference/operate.md +61 -0
- package/sera-core/skills/impeccable/reference/optimize.md +257 -0
- package/sera-core/skills/impeccable/reference/overdrive.md +127 -0
- package/sera-core/skills/impeccable/reference/polish.md +105 -0
- package/sera-core/skills/impeccable/reference/quieter.md +99 -0
- package/sera-core/skills/impeccable/reference/region-map.md +26 -0
- package/sera-core/skills/impeccable/reference/routing.md +24 -0
- package/sera-core/skills/impeccable/reference/shape.md +59 -0
- package/sera-core/skills/impeccable/reference/typeset.md +90 -0
- package/sera-core/skills/impeccable/reference/visualize.md +47 -0
- package/sera-core/skills/oyun-yarat/SKILL.md +106 -0
- package/sera-core/skills/oyun-yarat/referanslar/3b-yaris.md +74 -0
- package/sera-core/skills/oyun-yarat/referanslar/kaplay.md +99 -0
- package/sera-core/skills/oyun-yarat/referanslar/oyun-desenleri.md +73 -0
- package/sera-core/skills/oyun-yarat/sablonlar/kaplay-2d.html +164 -0
- package/sera-core/skills/oyun-yarat/sablonlar/three-yaris.html +149 -0
- package/sera-core/skills/oyun-yarat/sablonlar/tuval-minimal.html +77 -0
- package/sera-core/skills/receiving-code-review/LICENSE-UPSTREAM +21 -0
- package/sera-core/skills/receiving-code-review/SKILL.md +205 -0
- package/sera-core/skills/refero-design/LICENSE-UPSTREAM +21 -0
- package/sera-core/skills/refero-design/SKILL.md +534 -0
- package/sera-core/skills/refero-design/references/anti-ai-slop.md +292 -0
- package/sera-core/skills/refero-design/references/color.md +563 -0
- package/sera-core/skills/refero-design/references/copywriting.md +222 -0
- package/sera-core/skills/refero-design/references/craft-details.md +525 -0
- package/sera-core/skills/refero-design/references/example-workflow.md +264 -0
- package/sera-core/skills/refero-design/references/icons.md +166 -0
- package/sera-core/skills/refero-design/references/mcp-tools.md +258 -0
- package/sera-core/skills/refero-design/references/motion.md +504 -0
- package/sera-core/skills/refero-design/references/typography.md +737 -0
- package/sera-core/skills/refero-design/references/visual-workflow.md +105 -0
- package/sera-core/skills/requesting-code-review/LICENSE-UPSTREAM +21 -0
- package/sera-core/skills/requesting-code-review/SKILL.md +95 -0
- package/sera-core/skills/requesting-code-review/code-reviewer.md +198 -0
- package/sera-core/skills/reverse-engineer-anything/DISCLAIMER.md +136 -0
- package/sera-core/skills/reverse-engineer-anything/LICENSE-REA-MIT +21 -0
- package/sera-core/skills/reverse-engineer-anything/SKILL.md +363 -0
- package/sera-core/skills/reverse-engineer-anything/THIRD_PARTY_NOTICES.md +135 -0
- package/sera-core/skills/reverse-engineer-anything/references/android-applications.md +36 -0
- package/sera-core/skills/reverse-engineer-anything/references/connection-and-recovery.md +127 -0
- package/sera-core/skills/reverse-engineer-anything/references/evidence-workflows.md +71 -0
- package/sera-core/skills/reverse-engineer-anything/references/javascript-applications.md +218 -0
- package/sera-core/skills/reverse-engineer-anything/references/native-and-artifacts.md +297 -0
- package/sera-core/skills/reverse-engineer-anything/references/runtime-observation.md +78 -0
- package/sera-core/skills/seo-audit/LICENSE-UPSTREAM +21 -0
- package/sera-core/skills/seo-audit/SKILL.md +210 -0
- package/sera-core/skills/sera-guvenlik-denetim/SKILL.md +44 -0
- package/sera-core/skills/sera-guvenlik-denetim/referanslar/guvenlik-listesi.md +33 -0
- package/sera-core/skills/sera-hata-ayikla/SKILL.md +27 -0
- package/sera-core/skills/sera-hata-ayikla/referanslar/hata-ayiklama.md +37 -0
- package/sera-core/skills/sera-kod-inceleme/SKILL.md +44 -0
- package/sera-core/skills/sera-kod-inceleme/referanslar/inceleme-listesi.md +62 -0
- package/sera-core/skills/sera-ofis-dosya/SKILL.md +27 -0
- package/sera-core/skills/sera-ofis-dosya/referanslar/ofis-dosya.md +93 -0
- package/sera-core/skills/sera-research/SKILL.md +90 -0
- package/sera-core/skills/sera-tasarim/SKILL.md +149 -0
- package/sera-core/skills/sera-teslim-sozlesmesi/SKILL.md +592 -0
- package/sera-core/skills/sera-test-yaz/SKILL.md +26 -0
- package/sera-core/skills/sera-test-yaz/referanslar/test-yazimi.md +35 -0
- package/sera-core/skills/sera-veri-gorsel/SKILL.md +65 -0
- package/sera-core/skills/sera-web-test/SKILL.md +26 -0
- package/sera-core/skills/sera-web-test/referanslar/web-test.md +44 -0
- package/sera-core/skills/sera-zamanli-gorev/SKILL.md +22 -0
- package/sera-core/skills/sera-zamanli-gorev/referanslar/zamanli-gorev.md +58 -0
- package/sera-core/skills/systematic-debugging/LICENSE-UPSTREAM +21 -0
- package/sera-core/skills/systematic-debugging/SKILL.md +283 -0
- package/sera-core/skills/systematic-debugging/condition-based-waiting.md +115 -0
- package/sera-core/skills/systematic-debugging/defense-in-depth.md +122 -0
- package/sera-core/skills/systematic-debugging/root-cause-tracing.md +169 -0
- package/sera-core/skills/test-driven-development/LICENSE-UPSTREAM +21 -0
- package/sera-core/skills/test-driven-development/SKILL.md +330 -0
- package/sera-core/skills/test-driven-development/writing-good-tests.md +198 -0
- package/sera-core/skills/ticaret-icerik/SKILL.md +49 -0
- package/sera-core/skills/ticaret-icerik/referanslar/ticaret-icerik.md +54 -0
- package/sera-core/skills/uygulama-yarat/SKILL.md +95 -0
- package/sera-core/skills/uygulama-yarat/referanslar/uygulama-desenleri.md +63 -0
- package/sera-core/skills/uygulama-yarat/sablonlar/uygulama-tek-dosya.html +121 -0
- package/sera-core/skills/uyumluluk-denetim/SKILL.md +56 -0
- package/sera-core/skills/uyumluluk-denetim/referanslar/mevzuat-tablosu.md +65 -0
- package/sera-core/skills/veri-analizi/SKILL.md +54 -0
- package/sera-core/skills/veri-analizi/referanslar/veri-analizi-yontem.md +49 -0
- package/sera-core/skills/veri-analizi/sablonlar/profil.mjs +79 -0
- package/sera-core/skills/video-duzen/SKILL.md +50 -0
- package/sera-core/skills/video-duzen/referanslar/video-duzen.md +100 -0
- package/sera-core/skills/web-yayin-listesi/SKILL.md +115 -0
- package/sera-core/skills/writing-plans/LICENSE-UPSTREAM +21 -0
- package/sera-core/skills/writing-plans/SKILL.md +204 -0
- package/sera-core/src/action-nudge.ts +200 -0
- package/sera-core/src/agent-mode.ts +143 -0
- package/sera-core/src/agents.ts +185 -0
- package/sera-core/src/app-master.ts +275 -0
- package/sera-core/src/app-verify.ts +551 -0
- package/sera-core/src/approval.ts +131 -0
- package/sera-core/src/budget.ts +136 -0
- package/sera-core/src/command-policy.ts +808 -0
- package/sera-core/src/config.ts +135 -0
- package/sera-core/src/context-diet.ts +272 -0
- package/sera-core/src/device-id.ts +48 -0
- package/sera-core/src/dogal-arac.ts +203 -0
- package/sera-core/src/dogal-niyet.ts +173 -0
- package/sera-core/src/egress-allow.ts +52 -0
- package/sera-core/src/export.ts +124 -0
- package/sera-core/src/exposure.ts +8 -0
- package/sera-core/src/extension.ts +2416 -0
- package/sera-core/src/fs-tools.ts +444 -0
- package/sera-core/src/generated/build-rules.ts +26 -0
- package/sera-core/src/generated/zero-knowledge.ts +170 -0
- package/sera-core/src/github-agent-command.ts +133 -0
- package/sera-core/src/github-agent-engine.ts +198 -0
- package/sera-core/src/github-agent-schedule.ts +180 -0
- package/sera-core/src/github-agent.ts +669 -0
- package/sera-core/src/github-ajan-akis.ts +193 -0
- package/sera-core/src/github-ajan-gercek.ts +102 -0
- package/sera-core/src/github-tick.ts +78 -0
- package/sera-core/src/github-yedek.ts +269 -0
- package/sera-core/src/goal.ts +119 -0
- package/sera-core/src/handoff.ts +132 -0
- package/sera-core/src/hooks.ts +284 -0
- package/sera-core/src/image-tool.ts +118 -0
- package/sera-core/src/intake-brief.ts +82 -0
- package/sera-core/src/intake-core.ts +1152 -0
- package/sera-core/src/intake-hook.ts +88 -0
- package/sera-core/src/ios-build-tool.ts +134 -0
- package/sera-core/src/lazy-capability.ts +125 -0
- package/sera-core/src/lazy-mcp.ts +300 -0
- package/sera-core/src/limit-command.ts +51 -0
- package/sera-core/src/loop-brake.ts +129 -0
- package/sera-core/src/lsp.ts +618 -0
- package/sera-core/src/mcp-bridge.ts +159 -0
- package/sera-core/src/mcp-pin.ts +105 -0
- package/sera-core/src/mcp-ssrf.ts +124 -0
- package/sera-core/src/message-cap.ts +45 -0
- package/sera-core/src/no-progress.ts +177 -0
- package/sera-core/src/notebook-tool.ts +179 -0
- package/sera-core/src/ofis.ts +473 -0
- package/sera-core/src/path-guard.ts +139 -0
- package/sera-core/src/permission-bridge.ts +228 -0
- package/sera-core/src/policy-chain.ts +122 -0
- package/sera-core/src/pricing.ts +71 -0
- package/sera-core/src/proc.ts +149 -0
- package/sera-core/src/rea.ts +188 -0
- package/sera-core/src/repo-map.ts +230 -0
- package/sera-core/src/research.ts +347 -0
- package/sera-core/src/rules-memory.ts +227 -0
- package/sera-core/src/sandbox.ts +445 -0
- package/sera-core/src/server-error.ts +78 -0
- package/sera-core/src/skills.ts +268 -0
- package/sera-core/src/snapshot.ts +143 -0
- package/sera-core/src/spec-gate.ts +112 -0
- package/sera-core/src/subagent.ts +261 -0
- package/sera-core/src/teslim.ts +120 -0
- package/sera-core/src/test-fix.ts +184 -0
- package/sera-core/src/todo-question.ts +163 -0
- package/sera-core/src/turn-snapshots.ts +126 -0
- package/sera-core/src/tuval/arac.ts +338 -0
- package/sera-core/src/tuval/arsiv.ts +106 -0
- package/sera-core/src/tuval/belge.ts +216 -0
- package/sera-core/src/tuval/birlestir.ts +282 -0
- package/sera-core/src/tuval/disa.ts +235 -0
- package/sera-core/src/tuval/editor.ts +583 -0
- package/sera-core/src/tuval/film-cekirdek.ts +170 -0
- package/sera-core/src/tuval/film-disa.ts +188 -0
- package/sera-core/src/tuval/film-oynatici.ts +307 -0
- package/sera-core/src/tuval/kimlik.ts +156 -0
- package/sera-core/src/tuval/pano.ts +763 -0
- package/sera-core/src/tuval/proje.ts +728 -0
- package/sera-core/src/tuval/sistem-cekirdek.ts +167 -0
- package/sera-core/src/tuval/sistem.ts +328 -0
- package/sera-core/src/tuval/sunucu.ts +413 -0
- package/sera-core/src/tuval/uretim.ts +24 -0
- package/sera-core/src/tuval/veri-cekirdek.ts +477 -0
- package/sera-core/src/tuval/xlsx.ts +215 -0
- package/sera-core/src/tuval/zip.ts +163 -0
- package/sera-core/src/untrusted.ts +201 -0
- package/sera-core/src/video-edit-tool.ts +411 -0
- package/sera-core/src/video-tool.ts +217 -0
- package/sera-core/src/web-tools.ts +257 -0
- package/sera-core/src/zk.ts +104 -0
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Alt ajan (Sera "task" araci) - Pi cekirdegine dokunmadan.
|
|
3
|
+
* Ayni Pi'yi ayri bir RPC sureci olarak (yeni, kalicilastirilmayan oturum) calistirir; son metni ana ajana doner.
|
|
4
|
+
* - Butce: alt ajan ust tavanin KALANI ile baslar (SERA_BUDGET_* env) ve harcamasi ust governor'a sayilir.
|
|
5
|
+
* - Izin: alt ajanin izin sorulari ust surec uzerinden host'a (Sera Code) iletilir; arayuz yoksa reddedilir.
|
|
6
|
+
* - Gosterim: alt ajanin olaylari (`details.sera_child`) host'a aktarilir (Sera alt oturumu).
|
|
7
|
+
* Etkinlestirme: SERA_SUBAGENTS=1. Alt ajan icinde (SERA_SUBAGENT_DEPTH=1) arac kayitli degildir (ic ice yok).
|
|
8
|
+
*/
|
|
9
|
+
import { spawn } from "node:child_process";
|
|
10
|
+
import { randomUUID } from "node:crypto";
|
|
11
|
+
import type { BudgetLimits } from "./budget.ts";
|
|
12
|
+
import { PERMISSION_TITLE_PREFIX } from "./permission-bridge.ts";
|
|
13
|
+
import type { UsageLike } from "./pricing.ts";
|
|
14
|
+
import { killTree } from "./proc.ts";
|
|
15
|
+
|
|
16
|
+
export const SUBAGENT_DEPTH_ENV = "SERA_SUBAGENT_DEPTH";
|
|
17
|
+
|
|
18
|
+
export interface Spent {
|
|
19
|
+
usd: number;
|
|
20
|
+
turns: number;
|
|
21
|
+
uncachedInputTokens: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Alt ajanin butcesi = ust tavanin KALANI. Bir boyut bittiyse `exhausted` (alt ajan hic baslatilmaz). */
|
|
25
|
+
/**
|
|
26
|
+
* Paralel cocuklar icin REZERVE: `reserved` = calisan cocuklarin henuz harcamadigi pay (cap - harcanan);
|
|
27
|
+
* `slots` = bu cocukla birlikte bolusulecek bos cocuk yuvasi sayisi. Cocuk payi = (kalan - rezerve) / slots.
|
|
28
|
+
* Boylece N paralel cocugun tavan toplami kalani asamaz (once her cocuk tum kalani goruyor, ~Nx asiyordu).
|
|
29
|
+
*/
|
|
30
|
+
export function childBudget(
|
|
31
|
+
limits: BudgetLimits,
|
|
32
|
+
spent: Spent,
|
|
33
|
+
share: { reserved?: Partial<Spent>; slots?: number } = {},
|
|
34
|
+
): { env: Record<string, string>; exhausted?: string } {
|
|
35
|
+
const slots = Math.max(1, share.slots ?? 1);
|
|
36
|
+
const env: Record<string, string> = {};
|
|
37
|
+
const dims: Array<[keyof Spent, string, string]> = [
|
|
38
|
+
["usd", "SERA_BUDGET_USD", "USD"],
|
|
39
|
+
["turns", "SERA_BUDGET_TURNS", "tur"],
|
|
40
|
+
["uncachedInputTokens", "SERA_BUDGET_INPUT_TOKENS", "girdi token"],
|
|
41
|
+
];
|
|
42
|
+
for (const [dim, name, label] of dims) {
|
|
43
|
+
const limit = limits[dim];
|
|
44
|
+
if (limit === undefined || limit <= 0) continue;
|
|
45
|
+
const left = limit - spent[dim] - (share.reserved?.[dim] ?? 0);
|
|
46
|
+
if (left <= 0) return { env, exhausted: label };
|
|
47
|
+
// Fable #21: tur ve token tam sayi; pay asagi yuvarlanir (3,33 tur -> 3; eskiden cocuk 4 tur yapiyordu).
|
|
48
|
+
const part = dim === "usd" ? left / slots : Math.floor(left / slots);
|
|
49
|
+
if (part <= 0) return { env, exhausted: label };
|
|
50
|
+
env[name] = String(part);
|
|
51
|
+
}
|
|
52
|
+
return { env };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface ChildResult {
|
|
56
|
+
text: string;
|
|
57
|
+
usages: UsageLike[];
|
|
58
|
+
stopReason?: string;
|
|
59
|
+
errorMessage?: string;
|
|
60
|
+
/** alt ajan butce tavaninda durdu */
|
|
61
|
+
halted?: string;
|
|
62
|
+
exitCode?: number | null;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface ChildOptions {
|
|
66
|
+
node: string;
|
|
67
|
+
entry: string;
|
|
68
|
+
extensions: string[];
|
|
69
|
+
cwd: string;
|
|
70
|
+
args: string[];
|
|
71
|
+
env: Record<string, string | undefined>;
|
|
72
|
+
prompt: string;
|
|
73
|
+
/** ilk komutlar (ornegin plan modu: "/sera-agent plan") */
|
|
74
|
+
preamble?: string[];
|
|
75
|
+
signal?: AbortSignal;
|
|
76
|
+
/** Toplam duvar-saati zaman aşımı (ms). Süre dolarsa alt ajan SONLANDIRILIR (donma önleme). 0/undefined = kapalı. */
|
|
77
|
+
timeoutMs?: number;
|
|
78
|
+
/** alt ajan olayi (host'a aktarim) */
|
|
79
|
+
onEvent?: (ev: any) => void;
|
|
80
|
+
/** alt ajan izin sorusu -> yanit (once|always|reject); undefined = reddet */
|
|
81
|
+
onPermission: (title: string, options: string[]) => Promise<string | undefined>;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const textOf = (content: unknown): string =>
|
|
85
|
+
Array.isArray(content)
|
|
86
|
+
? content
|
|
87
|
+
.filter((c) => c?.type === "text" && typeof c.text === "string")
|
|
88
|
+
.map((c) => c.text)
|
|
89
|
+
.join("")
|
|
90
|
+
: "";
|
|
91
|
+
|
|
92
|
+
export function runChild(o: ChildOptions): Promise<ChildResult> {
|
|
93
|
+
return new Promise((resolve) => {
|
|
94
|
+
const args = [o.entry, ...o.extensions.flatMap((e) => ["-e", e]), "--no-session", ...o.args];
|
|
95
|
+
const child = spawn(o.node, args, {
|
|
96
|
+
cwd: o.cwd,
|
|
97
|
+
env: { ...process.env, ...o.env } as NodeJS.ProcessEnv,
|
|
98
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
99
|
+
detached: process.platform !== "win32", // POSIX: kendi süreç grubu → ağaç öldürme (yetim süreç kalmaz)
|
|
100
|
+
windowsHide: true,
|
|
101
|
+
});
|
|
102
|
+
const res: ChildResult = { text: "", usages: [] };
|
|
103
|
+
let buf = "";
|
|
104
|
+
let stderr = "";
|
|
105
|
+
let settled = false;
|
|
106
|
+
let aborted = false;
|
|
107
|
+
let started = false;
|
|
108
|
+
let n = 0;
|
|
109
|
+
let killTimer: ReturnType<typeof setTimeout> | undefined;
|
|
110
|
+
const pending = new Map<string, () => void>();
|
|
111
|
+
const send = (m: object) => {
|
|
112
|
+
try {
|
|
113
|
+
child.stdin!.write(`${JSON.stringify(m)}\n`);
|
|
114
|
+
} catch {
|
|
115
|
+
// surec kapanmis olabilir
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
const finish = () => {
|
|
119
|
+
if (settled) return;
|
|
120
|
+
settled = true;
|
|
121
|
+
if (killTimer) clearTimeout(killTimer);
|
|
122
|
+
const gone = child.exitCode !== null || child.signalCode !== null;
|
|
123
|
+
try {
|
|
124
|
+
killTree(child); // yalnız child.kill() değil: tüm süreç ağacı (yetim/asılı alt süreç kalmaz)
|
|
125
|
+
} catch {
|
|
126
|
+
// zaten kapali
|
|
127
|
+
}
|
|
128
|
+
// Öldürme eşzamansız tamamlanır (Windows'ta taskkill /F sonrası süreç cwd tutamacını kısa süre daha tutar):
|
|
129
|
+
// çağıran çocuğun çalışma dizinini silerse EPERM/EBUSY alırdı. Gerçekten kapanana kadar (en çok 3 sn) bekle.
|
|
130
|
+
if (gone) return resolve(res);
|
|
131
|
+
const t = setTimeout(() => resolve(res), 3000);
|
|
132
|
+
t.unref();
|
|
133
|
+
child.once("close", () => {
|
|
134
|
+
clearTimeout(t);
|
|
135
|
+
resolve(res);
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
const request = (cmd: object) =>
|
|
139
|
+
new Promise<void>((r) => {
|
|
140
|
+
const id = `c${++n}`;
|
|
141
|
+
pending.set(id, r);
|
|
142
|
+
send({ ...cmd, id });
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
const onEvent = async (ev: any) => {
|
|
146
|
+
if (ev?.type === "extension_ui_request") {
|
|
147
|
+
const isPermission =
|
|
148
|
+
ev.method === "select" && typeof ev.title === "string" && ev.title.startsWith(PERMISSION_TITLE_PREFIX);
|
|
149
|
+
if (isPermission) {
|
|
150
|
+
let reply: string | undefined;
|
|
151
|
+
try {
|
|
152
|
+
reply = await o.onPermission(
|
|
153
|
+
ev.title,
|
|
154
|
+
Array.isArray(ev.options) ? ev.options : ["once", "always", "reject"],
|
|
155
|
+
);
|
|
156
|
+
} catch {
|
|
157
|
+
reply = undefined;
|
|
158
|
+
}
|
|
159
|
+
send({ type: "extension_ui_response", id: ev.id, value: reply ?? "reject" });
|
|
160
|
+
} else if (["select", "confirm", "input", "editor"].includes(ev.method)) {
|
|
161
|
+
send({ type: "extension_ui_response", id: ev.id, cancelled: true });
|
|
162
|
+
}
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
if (ev?.type === "message_end" && ev.message?.role === "assistant") {
|
|
166
|
+
if (ev.message.usage) res.usages.push(ev.message.usage);
|
|
167
|
+
res.stopReason = ev.message.stopReason;
|
|
168
|
+
res.errorMessage = ev.message.errorMessage;
|
|
169
|
+
const t = textOf(ev.message.content);
|
|
170
|
+
if (t) res.text = t;
|
|
171
|
+
}
|
|
172
|
+
if (ev?.type === "entry_appended" && ev.entry?.customType === "sera-budget-halt") {
|
|
173
|
+
res.halted = typeof ev.entry.data?.message === "string" ? ev.entry.data.message : "butce tavani";
|
|
174
|
+
}
|
|
175
|
+
o.onEvent?.(ev);
|
|
176
|
+
if (ev?.type === "agent_settled" && started) finish();
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
child.stdout!.setEncoding("utf8");
|
|
180
|
+
child.stdout!.on("data", (d: string) => {
|
|
181
|
+
buf += d;
|
|
182
|
+
const lines = buf.split("\n");
|
|
183
|
+
buf = lines.pop() ?? "";
|
|
184
|
+
for (const raw of lines) {
|
|
185
|
+
const line = raw.endsWith("\r") ? raw.slice(0, -1) : raw;
|
|
186
|
+
if (!line.trim()) continue;
|
|
187
|
+
let msg: any;
|
|
188
|
+
try {
|
|
189
|
+
msg = JSON.parse(line);
|
|
190
|
+
} catch {
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
if (msg.type === "response" && typeof msg.id === "string" && pending.has(msg.id)) {
|
|
194
|
+
const r = pending.get(msg.id)!;
|
|
195
|
+
pending.delete(msg.id);
|
|
196
|
+
r();
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
void onEvent(msg);
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
child.stderr!.setEncoding("utf8");
|
|
203
|
+
child.stderr!.on("data", (d: string) => {
|
|
204
|
+
stderr = (stderr + d).slice(-2000);
|
|
205
|
+
});
|
|
206
|
+
child.on("error", () => {
|
|
207
|
+
res.errorMessage ??= "surec baslatilamadi";
|
|
208
|
+
finish();
|
|
209
|
+
});
|
|
210
|
+
child.on("close", (code) => {
|
|
211
|
+
res.exitCode = code;
|
|
212
|
+
if (!settled && !res.errorMessage) {
|
|
213
|
+
res.errorMessage = aborted
|
|
214
|
+
? "durduruldu"
|
|
215
|
+
: `surec kapandi: ${stderr.trim().split("\n").slice(-1)[0] ?? ""}`;
|
|
216
|
+
}
|
|
217
|
+
finish();
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
const onAbort = () => {
|
|
221
|
+
aborted = true;
|
|
222
|
+
res.stopReason = "aborted";
|
|
223
|
+
send({ type: "abort" });
|
|
224
|
+
setTimeout(finish, 1500).unref();
|
|
225
|
+
};
|
|
226
|
+
if (o.signal?.aborted) onAbort();
|
|
227
|
+
else o.signal?.addEventListener("abort", onAbort, { once: true });
|
|
228
|
+
|
|
229
|
+
// Donma önleme: toplam süre dolarsa alt ajanı sonlandır (model API/izin sorusu vb. asılı kalırsa üst ajan sonsuza beklemesin).
|
|
230
|
+
if (o.timeoutMs && o.timeoutMs > 0) {
|
|
231
|
+
killTimer = setTimeout(() => {
|
|
232
|
+
if (settled) return;
|
|
233
|
+
aborted = true;
|
|
234
|
+
res.stopReason = "timeout";
|
|
235
|
+
res.errorMessage ??= `alt ajan zaman asimina ugradi (${Math.round(o.timeoutMs! / 1000)} sn)`;
|
|
236
|
+
finish();
|
|
237
|
+
}, o.timeoutMs);
|
|
238
|
+
killTimer.unref();
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
void (async () => {
|
|
242
|
+
for (const p of o.preamble ?? []) await request({ type: "prompt", message: p });
|
|
243
|
+
started = true;
|
|
244
|
+
send({ type: "prompt", message: o.prompt, id: `c${++n}` });
|
|
245
|
+
})();
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/** Host'a iletilecek olay: agir alanlar (partial anlik goruntusu) atilir; gereksiz olaylar elenir. */
|
|
250
|
+
export function slimEvent(ev: any): any {
|
|
251
|
+
if (ev?.type === "message_update" && ev.assistantMessageEvent) {
|
|
252
|
+
const { partial: _p, ...rest } = ev.assistantMessageEvent;
|
|
253
|
+
return { type: "message_update", assistantMessageEvent: rest };
|
|
254
|
+
}
|
|
255
|
+
if (ev?.type === "tool_execution_update") return undefined;
|
|
256
|
+
return ev;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export function newChildId(): string {
|
|
260
|
+
return `cld_${randomUUID().replace(/-/g, "").slice(0, 16)}`;
|
|
261
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sera Teslim Sozlesmesi (dahili test): kullanici program/proje/uygulama istediginde `skills/sera-teslim-sozlesmesi/SKILL.md`
|
|
3
|
+
* govdesi (01-KUR sozlesmesi, BIREBIR) o isteme TEMBEL eklenir. Baglamda baslangicta yalniz metadata durur (skill dizini);
|
|
4
|
+
* govde yalniz proje isteginde yuklenir, sohbet/selam/kucuk duzeltmede yuklenmez.
|
|
5
|
+
* Web esi: sera-web/lib/teslim-sozlesmesi.ts (ayni niyet kurali, ayni sozlesme metni).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
9
|
+
import { dirname, join } from "node:path";
|
|
10
|
+
import { fileURLToPath } from "node:url";
|
|
11
|
+
|
|
12
|
+
export const TESLIM_SKILL_NAME = "sera-teslim-sozlesmesi";
|
|
13
|
+
export const TESLIM_CUSTOM_TYPE = "sera-teslim-sozlesmesi";
|
|
14
|
+
/** Ayni oturumda sozlesme bu kadar kullanici turu sonra (gecmisten budanmis olabilir) yeniden eklenebilir. */
|
|
15
|
+
export const TESLIM_REINJECT_AFTER_TURNS = 12;
|
|
16
|
+
|
|
17
|
+
const L = "(?<![\\p{L}])"; // sol sinir (JS \b Turkce harflerde calismaz)
|
|
18
|
+
// 2026-11-15 A/B ölçümü: "bir uygulama lazım / istiyorum / ihtiyacım var" kaçıyordu → ihtiyaç ifadeleri de fiil sayılır.
|
|
19
|
+
const VERB = new RegExp(
|
|
20
|
+
`${L}(yap(?!ı)|yaz(?!ıl|il)|olu[sş]tur|kodla|geli[sş]tir|haz[ıi]rla|tasarla|[üu]ret|in[sş]a\\s+et|laz[ıi]m|isti?yor|ihtiyac[ıi]m|build|create|make|write|develop|generate|implement|design|need|want)\\p{L}{0,12}`,
|
|
21
|
+
"iu",
|
|
22
|
+
);
|
|
23
|
+
const NOUN = new RegExp(
|
|
24
|
+
`${L}(program|uygulama|proje|web\\s*site|site|sayfa|panel|dashboard|oyun|bot|otomasyon|eklenti|extension|plugin|api|backend|frontend|ma[gğ]aza|platform|yaz[ıi]l[ıi]m|sistem|crm|blog|landing|app|application|website|webapp|tool|ara[cç]|cli|script|saas|portal|mod[uü]l|todo|hesap\\s*makinesi)\\p{L}{0,4}(?![\\p{L}])`,
|
|
25
|
+
"iu",
|
|
26
|
+
);
|
|
27
|
+
/** Saf aciklama sorusu: sozlesmeyi YUKLEME. Proje fiili+ismi yoksa zaten yuklenmez. */
|
|
28
|
+
const QUESTION_ONLY = /^\s*(nedir|ne demek|nas[ıi]l [cç]al[ıi][sş][ıi]r|what is|how does|explain|a[cç][ıi]kla)(?![\p{L}])/iu;
|
|
29
|
+
|
|
30
|
+
/** Niyet: ilk 1500 karakterde bir "yap/yaz/olustur/build..." fiili VE bir proje ismi (program/uygulama/panel/site...). */
|
|
31
|
+
export function isProjectRequest(text: string): boolean {
|
|
32
|
+
const t = (text ?? "").trim();
|
|
33
|
+
if (t.length < 12) return false;
|
|
34
|
+
if (QUESTION_ONLY.test(t)) return false;
|
|
35
|
+
const head = t.slice(0, 1500);
|
|
36
|
+
return VERB.test(head) && NOUN.test(head);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Yerlesik beceri dosyasi (packages/sera-core/skills/...). */
|
|
40
|
+
export function teslimSkillPath(srcDir = dirname(fileURLToPath(import.meta.url))): string {
|
|
41
|
+
return join(srcDir, "..", "skills", TESLIM_SKILL_NAME, "SKILL.md");
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** SKILL.md gövdesi (on bilgi kirpilir; sozlesme metni BIREBIR). Dosya yoksa undefined. */
|
|
45
|
+
export function loadTeslimBody(file = teslimSkillPath()): string | undefined {
|
|
46
|
+
try {
|
|
47
|
+
if (!existsSync(file)) return undefined;
|
|
48
|
+
const raw = readFileSync(file, "utf8");
|
|
49
|
+
const m = /^---\r?\n[\s\S]*?\r?\n---\r?\n\r?\n/.exec(raw);
|
|
50
|
+
return m ? raw.slice(m[0].length) : raw;
|
|
51
|
+
} catch {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// §7 TOKEN BUTCESI (01'in kendi kurali): yetenek kaynakli ek yuk turda <= 1.200 token; govde tamami ASLA. SKILL.md DEGISMEZ
|
|
57
|
+
// (hash testi); calisma aninda yalniz ilgili BOLUMLER secilir. §6 (skill runtime) ve §7 (token protokolu) harness kuralidir,
|
|
58
|
+
// modele gonderilmez. Turkce ~3,84 kr/token. Web esi: sera-web/lib/teslim-sozlesmesi.ts (ayni secici).
|
|
59
|
+
export const TESLIM_TOKEN_CAP = 1200;
|
|
60
|
+
export const CHARS_PER_TOKEN = 3.84;
|
|
61
|
+
export const TESLIM_CAP_CHARS = Math.floor(TESLIM_TOKEN_CAP * CHARS_PER_TOKEN);
|
|
62
|
+
export const TESLIM_NOTE_HEAD =
|
|
63
|
+
"[SERA TESLIM SOZLESMESI — kullanici yazmadi; bu bir program istegi, asagidaki bolumler baglayici. Kullaniciya teknik secim/skill/npx/dizin sorma.]";
|
|
64
|
+
|
|
65
|
+
export function parseSections(body: string): Record<number, string> {
|
|
66
|
+
const out: Record<number, string> = {};
|
|
67
|
+
for (const part of body.split(/\n(?=## \d+ · )/)) {
|
|
68
|
+
const m = /^## (\d+) · /.exec(part);
|
|
69
|
+
if (m) out[Number(m[1])] = part.trim();
|
|
70
|
+
}
|
|
71
|
+
return out;
|
|
72
|
+
}
|
|
73
|
+
const UI = /(?<![\p{L}])(site|sayfa|panel|dashboard|oyun|aray[üu]z|landing|ma[gğ]aza|blog|app|uygulama|ekran|tasar)/iu;
|
|
74
|
+
const BACKEND = /(?<![\p{L}])(api|backend|sunucu|server|veritaban|database|bot|otomasyon|script|betik|cli)/iu;
|
|
75
|
+
|
|
76
|
+
/** Goreve gore bolum onceligi: §2 her zaman; sonra alan bolumu; butceye sigmayan atlanir. */
|
|
77
|
+
export function teslimSectionIds(text: string, sections: Record<number, string>): number[] {
|
|
78
|
+
const want = [2, ...(UI.test(text) ? [4, 9] : []), ...(BACKEND.test(text) ? [5, 14] : []), 19, 16];
|
|
79
|
+
const ids: number[] = [];
|
|
80
|
+
let used = TESLIM_NOTE_HEAD.length;
|
|
81
|
+
for (const id of [...new Set(want)]) {
|
|
82
|
+
const sec = sections[id];
|
|
83
|
+
if (!sec) continue;
|
|
84
|
+
if (used + sec.length + 2 > TESLIM_CAP_CHARS) continue;
|
|
85
|
+
ids.push(id);
|
|
86
|
+
used += sec.length + 2;
|
|
87
|
+
}
|
|
88
|
+
return ids;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** Gizli mesaj metni: yalniz secilen bolumler (<= 1.200 token). */
|
|
92
|
+
export function teslimMessageText(body: string, prompt = ""): string {
|
|
93
|
+
const sections = parseSections(body);
|
|
94
|
+
const text = teslimSectionIds(prompt, sections)
|
|
95
|
+
.map((id) => sections[id])
|
|
96
|
+
.join("\n\n");
|
|
97
|
+
return `${TESLIM_NOTE_HEAD}\n\n${text}`;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** Oturum basina durum: ayni sozlesmeyi her turda eklemez. */
|
|
101
|
+
export class TeslimGate {
|
|
102
|
+
private turnsSince = Number.POSITIVE_INFINITY;
|
|
103
|
+
/** Her gercek kullanici turunda cagir; eklenecek metni (yoksa undefined) dondurur. */
|
|
104
|
+
onUserTurn(prompt: string, body: () => string | undefined): string | undefined {
|
|
105
|
+
this.turnsSince += 1;
|
|
106
|
+
if (prompt.includes(`<skill name="${TESLIM_SKILL_NAME}"`)) {
|
|
107
|
+
this.turnsSince = 0; // /skill:ad ile zaten acildi
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
if (this.turnsSince < TESLIM_REINJECT_AFTER_TURNS) return undefined;
|
|
111
|
+
if (!isProjectRequest(prompt)) return undefined;
|
|
112
|
+
const b = body();
|
|
113
|
+
if (!b) return undefined;
|
|
114
|
+
this.turnsSince = 0;
|
|
115
|
+
return teslimMessageText(b, prompt);
|
|
116
|
+
}
|
|
117
|
+
reset(): void {
|
|
118
|
+
this.turnsSince = Number.POSITIVE_INFINITY;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test-duzelt dongusu (D1-10). `/test [komut]` proje testlerini calistirir; kirilirsa hata ozetini modele verir ve
|
|
3
|
+
* duzeltme turu bittikten sonra testleri yeniden calistirir. En fazla `SERA_TEST_MAX_ATTEMPTS` (varsayilan 3)
|
|
4
|
+
* duzeltme turu; dongu freni (loop-brake) durdurursa ya da kullanici turu keserse dongu de durur.
|
|
5
|
+
* Her calistirma `sera-test` kaydi olarak yazilir; kayit o anki son anlik kopyayi (`sera-snapshot.after`) tasir,
|
|
6
|
+
* yani her test sonucu geri alinabilir bir dosya durumuna baglidir.
|
|
7
|
+
* Istege bagli otomatik commit (`SERA_TEST_AUTOCOMMIT=1`): testler duzeltmeden sonra gecerse YALNIZ dongu
|
|
8
|
+
* sirasinda edit/write ile degisen dosyalar commitlenir (kullanicinin baska degisiklikleri karismaz).
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { spawn } from "node:child_process";
|
|
12
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
13
|
+
import { isAbsolute, join, relative, resolve } from "node:path";
|
|
14
|
+
import { killTree } from "./hooks.ts";
|
|
15
|
+
|
|
16
|
+
export const TEST_COMMAND = "test";
|
|
17
|
+
export const TEST_ENTRY = "sera-test";
|
|
18
|
+
export const DEFAULT_TEST_ATTEMPTS = 3;
|
|
19
|
+
export const DEFAULT_TEST_TIMEOUT_MS = 300_000;
|
|
20
|
+
const DIGEST_MAX_CHARS = 4000;
|
|
21
|
+
|
|
22
|
+
export interface TestRun {
|
|
23
|
+
ok: boolean;
|
|
24
|
+
code: number | null;
|
|
25
|
+
output: string;
|
|
26
|
+
ms: number;
|
|
27
|
+
timedOut: boolean;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface TestEntry {
|
|
31
|
+
cmd: string;
|
|
32
|
+
attempt: number;
|
|
33
|
+
ok: boolean;
|
|
34
|
+
code: number | null;
|
|
35
|
+
ms: number;
|
|
36
|
+
/** Calistirma anindaki son tur kopyasi (yoksa undefined). */
|
|
37
|
+
snapshot?: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function testAttempts(env: NodeJS.ProcessEnv = process.env): number {
|
|
41
|
+
const n = Number.parseInt(env.SERA_TEST_MAX_ATTEMPTS ?? "", 10);
|
|
42
|
+
return Number.isInteger(n) ? Math.min(10, Math.max(0, n)) : DEFAULT_TEST_ATTEMPTS;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function testTimeoutMs(env: NodeJS.ProcessEnv = process.env): number {
|
|
46
|
+
const n = Number.parseInt(env.SERA_TEST_TIMEOUT_MS ?? "", 10);
|
|
47
|
+
return Number.isInteger(n) && n > 0 ? n : DEFAULT_TEST_TIMEOUT_MS;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Proje test komutu: SERA_TEST_CMD > package.json "test" betigi > python/rust/go isaretleri. */
|
|
51
|
+
export function detectTestCommand(cwd: string, env: NodeJS.ProcessEnv = process.env): string | undefined {
|
|
52
|
+
if (env.SERA_TEST_CMD?.trim()) return env.SERA_TEST_CMD.trim();
|
|
53
|
+
const pkg = join(cwd, "package.json");
|
|
54
|
+
if (existsSync(pkg)) {
|
|
55
|
+
try {
|
|
56
|
+
const test = (JSON.parse(readFileSync(pkg, "utf8")) as { scripts?: Record<string, string> }).scripts?.test;
|
|
57
|
+
if (test && !/no test specified/i.test(test)) return "npm test";
|
|
58
|
+
} catch {
|
|
59
|
+
// bozuk package.json: diger isaretlere bak
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (["pytest.ini", "pyproject.toml", "setup.cfg", "tox.ini"].some((f) => existsSync(join(cwd, f))))
|
|
63
|
+
return "python -m pytest -q";
|
|
64
|
+
if (existsSync(join(cwd, "Cargo.toml"))) return "cargo test";
|
|
65
|
+
if (existsSync(join(cwd, "go.mod"))) return "go test ./...";
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function runTests(cmd: string, cwd: string, timeoutMs: number): Promise<TestRun> {
|
|
70
|
+
const t0 = Date.now();
|
|
71
|
+
return new Promise((done) => {
|
|
72
|
+
let output = "";
|
|
73
|
+
let finished = false;
|
|
74
|
+
const finish = (r: Omit<TestRun, "ms" | "output">) => {
|
|
75
|
+
if (finished) return;
|
|
76
|
+
finished = true;
|
|
77
|
+
clearTimeout(timer);
|
|
78
|
+
done({ ...r, output, ms: Date.now() - t0 });
|
|
79
|
+
};
|
|
80
|
+
const p = spawn(cmd, {
|
|
81
|
+
cwd,
|
|
82
|
+
shell: true,
|
|
83
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
84
|
+
windowsHide: true,
|
|
85
|
+
detached: process.platform !== "win32",
|
|
86
|
+
env: { ...process.env, CI: process.env.CI ?? "1", FORCE_COLOR: "0" },
|
|
87
|
+
});
|
|
88
|
+
const add = (c: Buffer) => {
|
|
89
|
+
output += c.toString();
|
|
90
|
+
if (output.length > 2_000_000) output = output.slice(-1_000_000); // yalniz son kisim gerekli
|
|
91
|
+
};
|
|
92
|
+
p.stdout?.on("data", add);
|
|
93
|
+
p.stderr?.on("data", add);
|
|
94
|
+
let timedOut = false;
|
|
95
|
+
const timer = setTimeout(() => {
|
|
96
|
+
timedOut = true;
|
|
97
|
+
void killTree(p).then(() => finish({ ok: false, code: null, timedOut: true }));
|
|
98
|
+
}, timeoutMs);
|
|
99
|
+
p.on("error", (e) => {
|
|
100
|
+
output += `\n${e.message}`;
|
|
101
|
+
finish({ ok: false, code: null, timedOut: false });
|
|
102
|
+
});
|
|
103
|
+
p.on("close", (code) => {
|
|
104
|
+
if (timedOut) return; // sonucu zaman asimi yolu (agac olduruldukten sonra) verir
|
|
105
|
+
finish({ ok: code === 0, code, timedOut: false });
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const ANSI = /\x1b\[[0-9;?]*[ -/]*[@-~]/g;
|
|
111
|
+
const SIGNAL = /(error|fail|assert|expected|received|exception|traceback|panic|✗|×|not ok)/i;
|
|
112
|
+
|
|
113
|
+
/** Test ciktisinin modele giden ozeti: renk kodlari atilir, hata satirlari (+cevresi) ve son kisim tutulur. */
|
|
114
|
+
export function failureDigest(output: string, maxChars = DIGEST_MAX_CHARS): string {
|
|
115
|
+
const text = output.replace(ANSI, "").replace(/\r\n?/g, "\n");
|
|
116
|
+
if (text.length <= maxChars) return text.trim();
|
|
117
|
+
const lines = text.split("\n");
|
|
118
|
+
const keep = new Set<number>();
|
|
119
|
+
lines.forEach((l, i) => {
|
|
120
|
+
if (SIGNAL.test(l)) for (let k = Math.max(0, i - 2); k <= Math.min(lines.length - 1, i + 3); k++) keep.add(k);
|
|
121
|
+
});
|
|
122
|
+
const tailBudget = Math.floor(maxChars / 3);
|
|
123
|
+
let head = "";
|
|
124
|
+
let prev = -2;
|
|
125
|
+
for (const i of [...keep].sort((a, b) => a - b)) {
|
|
126
|
+
const piece = `${i !== prev + 1 ? "…\n" : ""}${lines[i]}\n`;
|
|
127
|
+
if (head.length + piece.length > maxChars - tailBudget) break;
|
|
128
|
+
head += piece;
|
|
129
|
+
prev = i;
|
|
130
|
+
}
|
|
131
|
+
const tail = text.slice(-(maxChars - head.length - 30));
|
|
132
|
+
return `${head}\n… (son kisim) …\n${tail}`.trim();
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export function fixPrompt(cmd: string, run: TestRun, attempt: number, max: number): string {
|
|
136
|
+
const why = run.timedOut ? "zaman asimina ugradi" : `cikis kodu ${run.code ?? "?"}`;
|
|
137
|
+
return [
|
|
138
|
+
`[Sera /test] \`${cmd}\` basarisiz (${why}). Duzeltme denemesi ${attempt}/${max}.`,
|
|
139
|
+
"Asagidaki hata ozetine bakarak KODU duzelt (testi gecsin diye testi silme/zayiflatma). Duzeltmeden sonra testleri kendin calistirma; Sera tekrar calistiracak.",
|
|
140
|
+
"",
|
|
141
|
+
"```",
|
|
142
|
+
failureDigest(run.output),
|
|
143
|
+
"```",
|
|
144
|
+
].join("\n");
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** Dongu sirasinda edit/write ile degisen yollar (cwd'ye gore goreli, cwd disindakiler atilir). */
|
|
148
|
+
export function editedPath(cwd: string, toolName: string, input: unknown): string | undefined {
|
|
149
|
+
if (toolName !== "edit" && toolName !== "write" && toolName !== "notebook_edit") return undefined;
|
|
150
|
+
const p =
|
|
151
|
+
(input as { path?: unknown; file_path?: unknown } | undefined)?.path ??
|
|
152
|
+
(input as { file_path?: unknown } | undefined)?.file_path;
|
|
153
|
+
if (typeof p !== "string" || !p) return undefined;
|
|
154
|
+
const rel = relative(cwd, isAbsolute(p) ? p : resolve(cwd, p));
|
|
155
|
+
return rel && !rel.startsWith("..") && !isAbsolute(rel) ? rel.replace(/\\/g, "/") : undefined;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function git(args: string[], cwd: string): Promise<{ code: number | null; out: string }> {
|
|
159
|
+
return new Promise((done) => {
|
|
160
|
+
let out = "";
|
|
161
|
+
const p = spawn("git", args, { cwd, windowsHide: true, stdio: ["ignore", "pipe", "pipe"] });
|
|
162
|
+
p.stdout.on("data", (c: Buffer) => {
|
|
163
|
+
out += c.toString();
|
|
164
|
+
});
|
|
165
|
+
p.stderr.on("data", (c: Buffer) => {
|
|
166
|
+
out += c.toString();
|
|
167
|
+
});
|
|
168
|
+
p.on("error", (e) => done({ code: null, out: e.message }));
|
|
169
|
+
p.on("close", (code) => done({ code, out }));
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** Yalniz verilen yollari commitler; degisiklik yoksa ya da git deposu degilse undefined. */
|
|
174
|
+
export async function commitPaths(cwd: string, paths: string[], message: string): Promise<string | undefined> {
|
|
175
|
+
if (!paths.length) return undefined;
|
|
176
|
+
if ((await git(["rev-parse", "--is-inside-work-tree"], cwd)).code !== 0) return undefined;
|
|
177
|
+
const existing = paths.filter((p) => existsSync(join(cwd, p)));
|
|
178
|
+
if (existing.length && (await git(["add", "--", ...existing], cwd)).code !== 0) return undefined;
|
|
179
|
+
const st = await git(["status", "--porcelain", "--", ...paths], cwd);
|
|
180
|
+
if (!st.out.trim()) return undefined;
|
|
181
|
+
const c = await git(["commit", "-q", "-m", message, "--", ...paths], cwd);
|
|
182
|
+
if (c.code !== 0) throw new Error(`otomatik commit basarisiz: ${c.out.trim().slice(0, 300)}`);
|
|
183
|
+
return (await git(["rev-parse", "--short", "HEAD"], cwd)).out.trim();
|
|
184
|
+
}
|