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,135 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import type { BudgetLimits } from "./budget.ts";
|
|
5
|
+
import type { LoopBrakeConfig } from "./loop-brake.ts";
|
|
6
|
+
import { type SandboxConfig, sandboxFromConfig } from "./sandbox.ts";
|
|
7
|
+
|
|
8
|
+
export interface DietConfig {
|
|
9
|
+
enabled: boolean;
|
|
10
|
+
/** Keep tool results of the last N assistant turns untouched. */
|
|
11
|
+
keepRecentTurns: number;
|
|
12
|
+
/** Tool results larger than this many chars are prune candidates. */
|
|
13
|
+
minChars: number;
|
|
14
|
+
/** Prune only when estimated context tokens exceed this (batch prune, keeps provider cache stable otherwise). */
|
|
15
|
+
pruneAtTokens: number;
|
|
16
|
+
/** Hysteresis: next prune event only after the estimate grew by this many tokens past the previous post-prune size (cache-friendly batching). */
|
|
17
|
+
pruneStepTokens: number;
|
|
18
|
+
/** Compact when context >= min(window * ratio, absMaxTokens). */
|
|
19
|
+
compactRatio: number;
|
|
20
|
+
compactAbsMaxTokens: number;
|
|
21
|
+
/** Directory where pruned full outputs are spilled. */
|
|
22
|
+
spillDir: string;
|
|
23
|
+
/** Any single tool result text longer than this many chars is cut (head + tail); full text is spilled. 0 = off. */
|
|
24
|
+
outputCapChars: number;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface SeraConfig {
|
|
28
|
+
budget: BudgetLimits;
|
|
29
|
+
priceModel?: string;
|
|
30
|
+
diet: DietConfig;
|
|
31
|
+
loop: Partial<LoopBrakeConfig>;
|
|
32
|
+
/** D2-7 depo haritası: üst düzey sembol indeksi bağlama enjekte edilir. Varsayılan KAPALI (opt-in, token maliyeti). */
|
|
33
|
+
repoMap: { enabled: boolean; maxTokens: number };
|
|
34
|
+
/** D2-6: OS sandbox (opt-in; varsayılan kapalı). */
|
|
35
|
+
sandbox: SandboxConfig;
|
|
36
|
+
/** true: no budget ceiling was configured, so the safety defaults (DEFAULT_BUDGET) are in force. */
|
|
37
|
+
budgetDefaulted: boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Safety net, ON by default (a runaway guard, not a normal limiter): applies only to dimensions the user did not set.
|
|
42
|
+
* Disable one dimension with SERA_BUDGET_USD=0 / SERA_BUDGET_TURNS=0 (a limit <= 0 means "unlimited").
|
|
43
|
+
*/
|
|
44
|
+
export const DEFAULT_BUDGET = { usd: 25, turns: 1500 } as const;
|
|
45
|
+
|
|
46
|
+
export const DEFAULT_DIET: DietConfig = {
|
|
47
|
+
enabled: true,
|
|
48
|
+
// 2026-11-12 (sahip: oturum geneli token tasarrufu): budama daha erken ve daha kucuk ciktilarda devreye girer.
|
|
49
|
+
// Kaynak: gozlem maskeleme maliyeti yariya indirir, cozum orani ayni kalir (arXiv 2508.21433).
|
|
50
|
+
keepRecentTurns: 4,
|
|
51
|
+
minChars: 800,
|
|
52
|
+
pruneAtTokens: 10_000,
|
|
53
|
+
pruneStepTokens: 6_000,
|
|
54
|
+
// Compaction trigger = min(window * 0.5, 40K): a 1M window used to grow to ~983K before summarising.
|
|
55
|
+
compactRatio: 0.5,
|
|
56
|
+
compactAbsMaxTokens: 40_000, // olcum: scripts/compact-replay.ts (64K hic tetiklenmiyordu; 40K = ozet sonrasi ~28K + 12K pay)
|
|
57
|
+
spillDir: join(homedir(), ".sera", "spill"),
|
|
58
|
+
outputCapChars: 12_000,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
function num(v: string | undefined): number | undefined {
|
|
62
|
+
if (v === undefined || v === "") return undefined;
|
|
63
|
+
const n = Number(v);
|
|
64
|
+
return Number.isFinite(n) ? n : undefined;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Config precedence: env (SERA_*) > settings file > defaults.
|
|
69
|
+
* Settings file: $SERA_SETTINGS, else ./.sera/settings.json, else ~/.sera/settings.json. Shape = SeraConfig (partial).
|
|
70
|
+
*/
|
|
71
|
+
export function loadConfig(env: NodeJS.ProcessEnv = process.env, cwd: string = process.cwd()): SeraConfig {
|
|
72
|
+
let file: Partial<SeraConfig> = {};
|
|
73
|
+
const candidates = [
|
|
74
|
+
env.SERA_SETTINGS,
|
|
75
|
+
join(cwd, ".sera", "settings.json"),
|
|
76
|
+
join(homedir(), ".sera", "settings.json"),
|
|
77
|
+
];
|
|
78
|
+
for (const p of candidates) {
|
|
79
|
+
if (p && existsSync(p)) {
|
|
80
|
+
try {
|
|
81
|
+
file = JSON.parse(readFileSync(p, "utf8"));
|
|
82
|
+
} catch {
|
|
83
|
+
// ignore malformed settings
|
|
84
|
+
}
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const budget: BudgetLimits = {
|
|
89
|
+
usd: num(env.SERA_BUDGET_USD) ?? file.budget?.usd,
|
|
90
|
+
turns: num(env.SERA_BUDGET_TURNS) ?? file.budget?.turns,
|
|
91
|
+
uncachedInputTokens: num(env.SERA_BUDGET_INPUT_TOKENS) ?? file.budget?.uncachedInputTokens,
|
|
92
|
+
warnAt: num(env.SERA_BUDGET_WARN_AT) ?? file.budget?.warnAt,
|
|
93
|
+
};
|
|
94
|
+
// Nothing configured at all -> safety defaults on. Any explicit value (even 0 = unlimited) opts out of the defaults.
|
|
95
|
+
const budgetDefaulted =
|
|
96
|
+
budget.usd === undefined && budget.turns === undefined && budget.uncachedInputTokens === undefined;
|
|
97
|
+
if (budgetDefaulted) {
|
|
98
|
+
budget.usd = DEFAULT_BUDGET.usd;
|
|
99
|
+
budget.turns = DEFAULT_BUDGET.turns;
|
|
100
|
+
}
|
|
101
|
+
const diet: DietConfig = {
|
|
102
|
+
...DEFAULT_DIET,
|
|
103
|
+
...(file.diet ?? {}),
|
|
104
|
+
enabled: env.SERA_DIET === "0" ? false : (file.diet?.enabled ?? true),
|
|
105
|
+
minChars: num(env.SERA_DIET_MIN_CHARS) ?? file.diet?.minChars ?? DEFAULT_DIET.minChars,
|
|
106
|
+
keepRecentTurns: num(env.SERA_DIET_KEEP_TURNS) ?? file.diet?.keepRecentTurns ?? DEFAULT_DIET.keepRecentTurns,
|
|
107
|
+
pruneAtTokens: num(env.SERA_DIET_PRUNE_AT) ?? file.diet?.pruneAtTokens ?? DEFAULT_DIET.pruneAtTokens,
|
|
108
|
+
pruneStepTokens: num(env.SERA_DIET_PRUNE_STEP) ?? file.diet?.pruneStepTokens ?? DEFAULT_DIET.pruneStepTokens,
|
|
109
|
+
compactAbsMaxTokens:
|
|
110
|
+
num(env.SERA_COMPACT_MAX_TOKENS) ?? file.diet?.compactAbsMaxTokens ?? DEFAULT_DIET.compactAbsMaxTokens,
|
|
111
|
+
compactRatio: num(env.SERA_COMPACT_RATIO) ?? file.diet?.compactRatio ?? DEFAULT_DIET.compactRatio,
|
|
112
|
+
spillDir: env.SERA_SPILL_DIR ?? file.diet?.spillDir ?? DEFAULT_DIET.spillDir,
|
|
113
|
+
outputCapChars: num(env.SERA_OUTPUT_CAP_CHARS) ?? file.diet?.outputCapChars ?? DEFAULT_DIET.outputCapChars,
|
|
114
|
+
};
|
|
115
|
+
const loop: Partial<LoopBrakeConfig> = { ...(file.loop ?? {}) };
|
|
116
|
+
const w = num(env.SERA_LOOP_WARN),
|
|
117
|
+
s = num(env.SERA_LOOP_STRATEGY),
|
|
118
|
+
t = num(env.SERA_LOOP_STOP);
|
|
119
|
+
if (w !== undefined) loop.warnAt = w;
|
|
120
|
+
if (s !== undefined) loop.strategyAt = s;
|
|
121
|
+
if (t !== undefined) loop.stopAt = t;
|
|
122
|
+
const repoMap = {
|
|
123
|
+
enabled: env.SERA_REPO_MAP === "1" ? true : env.SERA_REPO_MAP === "0" ? false : (file.repoMap?.enabled ?? false),
|
|
124
|
+
maxTokens: num(env.SERA_REPO_MAP_MAX_TOKENS) ?? file.repoMap?.maxTokens ?? 1500,
|
|
125
|
+
};
|
|
126
|
+
return {
|
|
127
|
+
budget,
|
|
128
|
+
priceModel: env.SERA_PRICE_MODEL ?? file.priceModel,
|
|
129
|
+
diet,
|
|
130
|
+
loop,
|
|
131
|
+
repoMap,
|
|
132
|
+
sandbox: sandboxFromConfig(file, env),
|
|
133
|
+
budgetDefaulted,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { mkdirSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
|
|
5
|
+
// Context diet (D2): prune old, large tool results into short stubs that reference a spill file,
|
|
6
|
+
// and decide when to compact early. Pure policy + injected spill writer.
|
|
7
|
+
|
|
8
|
+
export interface MsgLike {
|
|
9
|
+
role: string;
|
|
10
|
+
content?: unknown;
|
|
11
|
+
toolCallId?: string;
|
|
12
|
+
toolName?: string;
|
|
13
|
+
isError?: boolean;
|
|
14
|
+
[k: string]: unknown;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface PruneOptions {
|
|
18
|
+
keepRecentTurns: number;
|
|
19
|
+
minChars: number;
|
|
20
|
+
pruneAtTokens: number;
|
|
21
|
+
/**
|
|
22
|
+
* Hysteresis (provider-cache friendly): after a prune event the next one waits until the estimate grew by at least this many
|
|
23
|
+
* tokens over the post-prune size. Every event rewrites an old message and so misses the provider cache from that point on;
|
|
24
|
+
* batching events turns "a miss every turn" into "a miss every few turns". 0/undefined = no hysteresis (old behaviour).
|
|
25
|
+
*/
|
|
26
|
+
pruneStepTokens?: number;
|
|
27
|
+
/** Writes the full output somewhere and returns a reference (path). */
|
|
28
|
+
spill: (id: string, text: string) => string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const STUB_MARK = "[Sera: eski arac ciktisi budandi";
|
|
32
|
+
const ARG_MARK = "[Sera: eski arguman budandi";
|
|
33
|
+
const TEXT_MARK = "[Sera: eski cevabin devami budandi";
|
|
34
|
+
/** Eski asistan metni bu uzunlugu asarsa basi (TEXT_KEEP) kalir; kullanici zaten okudu, model ozunu bilir. */
|
|
35
|
+
const TEXT_PRUNE_OVER = 2000;
|
|
36
|
+
const TEXT_KEEP = 600;
|
|
37
|
+
/** Argumanlari budanabilen araclar: buyuk metin alanlari diske zaten yazilmistir (path alani korunur). */
|
|
38
|
+
const ARG_TOOLS = new Set(["write", "edit"]);
|
|
39
|
+
const BIG_KEYS = new Set(["content", "newText", "oldText", "new_string", "old_string", "edits"]);
|
|
40
|
+
|
|
41
|
+
export function contentText(content: unknown): string {
|
|
42
|
+
if (typeof content === "string") return content;
|
|
43
|
+
if (!Array.isArray(content)) return "";
|
|
44
|
+
return content
|
|
45
|
+
.map((c) =>
|
|
46
|
+
c && typeof c === "object" && (c as { type?: string }).type === "text"
|
|
47
|
+
? String((c as { text?: string }).text ?? "")
|
|
48
|
+
: "",
|
|
49
|
+
)
|
|
50
|
+
.join("\n");
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Cheap token estimate: chars / 4 over text-like content. */
|
|
54
|
+
export function estimateTokens(messages: MsgLike[]): number {
|
|
55
|
+
let chars = 0;
|
|
56
|
+
for (const m of messages) {
|
|
57
|
+
if (typeof m.content === "string") chars += m.content.length;
|
|
58
|
+
else if (Array.isArray(m.content)) {
|
|
59
|
+
for (const c of m.content as Array<Record<string, unknown>>) {
|
|
60
|
+
if (c.type === "text") chars += String(c.text ?? "").length;
|
|
61
|
+
else if (c.type === "toolCall") chars += JSON.stringify(c.arguments ?? {}).length + 20;
|
|
62
|
+
else if (c.type === "thinking") chars += String(c.thinking ?? "").length;
|
|
63
|
+
else chars += 200;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return Math.ceil(chars / 4);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function makeFileSpill(dir: string): (id: string, text: string) => string {
|
|
71
|
+
return (id, text) => {
|
|
72
|
+
mkdirSync(dir, { recursive: true });
|
|
73
|
+
const name = `${createHash("sha1")
|
|
74
|
+
.update(id + text.length)
|
|
75
|
+
.digest("hex")
|
|
76
|
+
.slice(0, 16)}.txt`;
|
|
77
|
+
const p = join(dir, name);
|
|
78
|
+
writeFileSync(p, text, "utf8");
|
|
79
|
+
return p;
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export class ContextDiet {
|
|
84
|
+
/** toolCallIds already pruned; once pruned, always pruned (stable provider-cache prefix between prune events). */
|
|
85
|
+
private pruned = new Map<string, string>();
|
|
86
|
+
/** toolCall id -> budanmis arguman nesnesi (bir kez budanan hep ayni bayt: saglayici onbellegi icin). */
|
|
87
|
+
private prunedArgs = new Map<string, Record<string, unknown>>();
|
|
88
|
+
/** Budanmis asistan metinleri: anahtar = mesaj sirasi + uzunluk (ayni mesaj hep ayni bayt). */
|
|
89
|
+
private prunedTexts = new Map<string, string>();
|
|
90
|
+
prunedCount = 0;
|
|
91
|
+
prunedChars = 0;
|
|
92
|
+
/** Estimated tokens right after the last prune event (hysteresis base). */
|
|
93
|
+
private lastKept = 0;
|
|
94
|
+
readonly opts: PruneOptions;
|
|
95
|
+
|
|
96
|
+
constructor(opts: PruneOptions) {
|
|
97
|
+
this.opts = opts;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
private stub(m: MsgLike, text: string): string {
|
|
101
|
+
const id = m.toolCallId ?? "?";
|
|
102
|
+
let s = this.pruned.get(id);
|
|
103
|
+
if (s) return s;
|
|
104
|
+
const ref = this.opts.spill(id, text);
|
|
105
|
+
const head = text.slice(0, 160).replace(/\s+/g, " ").trim();
|
|
106
|
+
s = `${STUB_MARK}: ${m.toolName ?? "arac"}, ${text.length} karakter. Tam cikti dosyada: ${ref}. Ilk satirlar: ${head}]`;
|
|
107
|
+
this.pruned.set(id, s);
|
|
108
|
+
this.prunedCount += 1;
|
|
109
|
+
this.prunedChars += text.length - s.length;
|
|
110
|
+
return s;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** write/edit cagrisinin buyuk metin alanlarini kisa isaretle degistirir; diger alanlar (path) aynen kalir. */
|
|
114
|
+
private stubArgs(id: string, args: Record<string, unknown>): Record<string, unknown> {
|
|
115
|
+
const done = this.prunedArgs.get(id);
|
|
116
|
+
if (done) return done;
|
|
117
|
+
const out: Record<string, unknown> = {};
|
|
118
|
+
let saved = 0;
|
|
119
|
+
for (const [k, v] of Object.entries(args)) {
|
|
120
|
+
if (!BIG_KEYS.has(k)) {
|
|
121
|
+
out[k] = v;
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
const len = typeof v === "string" ? v.length : JSON.stringify(v ?? "").length;
|
|
125
|
+
const s = `${ARG_MARK}: ${len} karakter; guncel hali dosyada (gerekirse read)]`;
|
|
126
|
+
out[k] = s;
|
|
127
|
+
saved += len - s.length;
|
|
128
|
+
}
|
|
129
|
+
this.prunedArgs.set(id, out);
|
|
130
|
+
this.prunedChars += Math.max(0, saved);
|
|
131
|
+
return out;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** Asistan mesajindaki eski write/edit cagrilarinin argumanlarini buda (only=true: yalniz daha once budananlar). */
|
|
135
|
+
private pruneCalls(m: MsgLike, only: boolean): MsgLike {
|
|
136
|
+
if (m.role !== "assistant" || !Array.isArray(m.content)) return m;
|
|
137
|
+
let hit = false;
|
|
138
|
+
const content = (m.content as Array<Record<string, unknown>>).map((c, j) => {
|
|
139
|
+
if (c?.type === "text") {
|
|
140
|
+
const t = String(c.text ?? "");
|
|
141
|
+
const key = `${String((m as { timestamp?: unknown }).timestamp ?? "")}:${j}:${t.length}`;
|
|
142
|
+
const done = this.prunedTexts.get(key);
|
|
143
|
+
if (done !== undefined) {
|
|
144
|
+
hit = true;
|
|
145
|
+
return { ...c, text: done };
|
|
146
|
+
}
|
|
147
|
+
if (only || t.length <= TEXT_PRUNE_OVER || t.startsWith(TEXT_MARK)) return c;
|
|
148
|
+
const next = `${t.slice(0, TEXT_KEEP)}\n${TEXT_MARK}: ${t.length - TEXT_KEEP} karakter]`;
|
|
149
|
+
this.prunedTexts.set(key, next);
|
|
150
|
+
this.prunedChars += t.length - next.length;
|
|
151
|
+
hit = true;
|
|
152
|
+
return { ...c, text: next };
|
|
153
|
+
}
|
|
154
|
+
if (c?.type !== "toolCall" || !ARG_TOOLS.has(String(c.name ?? ""))) return c;
|
|
155
|
+
const id = String(c.id ?? "");
|
|
156
|
+
const args = (c.arguments ?? {}) as Record<string, unknown>;
|
|
157
|
+
if (!id) return c;
|
|
158
|
+
if (only ? !this.prunedArgs.has(id) : JSON.stringify(args).length < this.opts.minChars) return c;
|
|
159
|
+
const next = this.stubArgs(id, args);
|
|
160
|
+
if (next === args) return c;
|
|
161
|
+
hit = true;
|
|
162
|
+
return { ...c, arguments: next };
|
|
163
|
+
});
|
|
164
|
+
return hit ? { ...m, content } : m;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** Returns a new message array (input not mutated). */
|
|
168
|
+
prune(messages: MsgLike[]): MsgLike[] {
|
|
169
|
+
const o = this.opts;
|
|
170
|
+
// turn age of each message = number of assistant messages after it
|
|
171
|
+
const age = new Array<number>(messages.length).fill(0);
|
|
172
|
+
let a = 0;
|
|
173
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
174
|
+
age[i] = a;
|
|
175
|
+
if (messages[i].role === "assistant") a += 1;
|
|
176
|
+
}
|
|
177
|
+
const before = this.pruned.size;
|
|
178
|
+
const argsBefore = this.prunedArgs.size;
|
|
179
|
+
const textsBefore = this.prunedTexts.size;
|
|
180
|
+
let changed = false;
|
|
181
|
+
const isStubbed = (m: MsgLike) => contentText(m.content).startsWith(STUB_MARK);
|
|
182
|
+
// Ayni dosyanin eski okumalari: bir dosya sonradan yeniden okunduysa (ya da yazildi/duzenlendiyse) eski read sonucu
|
|
183
|
+
// gecersizdir; yasina bakilmadan budanir (sahip 2026-11-12: her mesajda tum oturumu yeniden gonderme).
|
|
184
|
+
const superseded = supersededReads(messages);
|
|
185
|
+
// 1) earlier stubs are re-applied unchanged (the prefix the provider cached stays byte-identical)
|
|
186
|
+
const base = messages.map((m0) => {
|
|
187
|
+
const m = this.prunedArgs.size || this.prunedTexts.size ? this.pruneCalls(m0, true) : m0;
|
|
188
|
+
if (m !== m0) changed = true;
|
|
189
|
+
if (m.role !== "toolResult" || !this.pruned.has(m.toolCallId ?? "") || isStubbed(m)) return m;
|
|
190
|
+
changed = true;
|
|
191
|
+
return { ...m, content: [{ type: "text", text: this.stub(m, contentText(m.content)) }] };
|
|
192
|
+
});
|
|
193
|
+
// 2) a NEW prune event only when the EFFECTIVE context (stubs applied) is over the threshold and, after a previous
|
|
194
|
+
// event, has grown by pruneStepTokens (hysteresis: each event rewrites old messages = provider cache miss from there).
|
|
195
|
+
const est = estimateTokens(base);
|
|
196
|
+
const over = est > Math.max(o.pruneAtTokens, this.lastKept > 0 ? this.lastKept + (o.pruneStepTokens ?? 0) : 0);
|
|
197
|
+
const out = over
|
|
198
|
+
? base.map((m, i) => {
|
|
199
|
+
if (m.role === "assistant" && age[i] >= o.keepRecentTurns) {
|
|
200
|
+
const n = this.pruneCalls(m, false);
|
|
201
|
+
if (n !== m) changed = true;
|
|
202
|
+
return n;
|
|
203
|
+
}
|
|
204
|
+
if (m.role !== "toolResult" || isStubbed(m)) return m;
|
|
205
|
+
const text = contentText(m.content);
|
|
206
|
+
const old = age[i] >= o.keepRecentTurns || superseded.has(m.toolCallId ?? "");
|
|
207
|
+
if (!(old && text.length >= o.minChars)) return m;
|
|
208
|
+
changed = true;
|
|
209
|
+
return { ...m, content: [{ type: "text", text: this.stub(m, text) }] };
|
|
210
|
+
})
|
|
211
|
+
: base;
|
|
212
|
+
if (this.pruned.size > before || this.prunedArgs.size > argsBefore || this.prunedTexts.size > textsBefore)
|
|
213
|
+
this.lastKept = estimateTokens(out);
|
|
214
|
+
return changed ? out : messages;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/** Sonradan ayni yol yeniden okunan/yazilan/duzenlenen read cagrilarinin toolCallId'leri (en son okuma korunur). */
|
|
219
|
+
export function supersededReads(messages: MsgLike[]): Set<string> {
|
|
220
|
+
const out = new Set<string>();
|
|
221
|
+
const lastTouch = new Map<string, number>();
|
|
222
|
+
const reads: { id: string; path: string; at: number }[] = [];
|
|
223
|
+
messages.forEach((m, i) => {
|
|
224
|
+
if (m.role !== "assistant" || !Array.isArray(m.content)) return;
|
|
225
|
+
for (const c of m.content as Array<Record<string, unknown>>) {
|
|
226
|
+
if (c?.type !== "toolCall") continue;
|
|
227
|
+
const name = String(c.name ?? "");
|
|
228
|
+
const path = String((c.arguments as { path?: unknown } | undefined)?.path ?? "")
|
|
229
|
+
.replace(/\\/g, "/")
|
|
230
|
+
.toLowerCase();
|
|
231
|
+
if (!path) continue;
|
|
232
|
+
if (name === "read") reads.push({ id: String(c.id ?? ""), path, at: i });
|
|
233
|
+
if (name === "read" || name === "write" || name === "edit") lastTouch.set(path, i);
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
for (const r of reads) if (r.id && (lastTouch.get(r.path) ?? -1) > r.at) out.add(r.id);
|
|
237
|
+
return out;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/** Compaction threshold in tokens: min(window * ratio, absolute cap). */
|
|
241
|
+
export function compactThreshold(contextWindow: number, ratio: number, absMax: number): number {
|
|
242
|
+
return Math.floor(Math.min(contextWindow * ratio, absMax));
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export function shouldCompact(tokens: number | null, contextWindow: number, ratio: number, absMax: number): boolean {
|
|
246
|
+
if (tokens === null || !Number.isFinite(tokens)) return false;
|
|
247
|
+
return tokens >= compactThreshold(contextWindow, ratio, absMax);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
const CAP_MARK = "[Sera: arac ciktisi kisaltildi";
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Per-result cap (token saving at the source, before the output ever enters the context): a text longer than
|
|
254
|
+
* maxChars keeps head + tail, the full text is spilled to a file and referenced. Returns undefined when nothing
|
|
255
|
+
* to cut (also when already capped, so the step is idempotent). maxChars <= 0 disables.
|
|
256
|
+
*/
|
|
257
|
+
export function capOutput(
|
|
258
|
+
toolName: string,
|
|
259
|
+
toolCallId: string,
|
|
260
|
+
text: string,
|
|
261
|
+
maxChars: number,
|
|
262
|
+
spill: (id: string, text: string) => string,
|
|
263
|
+
): string | undefined {
|
|
264
|
+
if (!(maxChars > 0) || text.length <= maxChars || text.includes(CAP_MARK)) return undefined;
|
|
265
|
+
const headLen = Math.floor(maxChars * 0.6);
|
|
266
|
+
const tailLen = maxChars - headLen;
|
|
267
|
+
const ref = spill(toolCallId || toolName, text);
|
|
268
|
+
const cut = text.length - headLen - tailLen;
|
|
269
|
+
return `${text.slice(0, headLen)}
|
|
270
|
+
${CAP_MARK}: ${toolName}, ${cut} karakter atlandi (toplam ${text.length}). Tam cikti dosyada: ${ref}. Gerekirse o dosyadan ilgili bolumu oku.]
|
|
271
|
+
${text.slice(text.length - tailLen)}`;
|
|
272
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kalici cihaz kimligi (web plan korumasi: sera-web/lib/plan-guard.ts). ssera.online'a giden her
|
|
3
|
+
* kullanici-belirtecli istege `x-sera-device` olarak eklenir. 32 hex karakter, ilk kullanimda uretilir,
|
|
4
|
+
* ~/.sera/device-id dosyasinda saklanir ($SERA_DEVICE_ID_FILE ile degistirilebilir). Dosya yazilamazsa
|
|
5
|
+
* surec boyunca sabit bir bellek-ici kimlik kullanilir (istek yine gider).
|
|
6
|
+
*/
|
|
7
|
+
import { randomBytes } from "node:crypto";
|
|
8
|
+
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
9
|
+
import { homedir } from "node:os";
|
|
10
|
+
import { dirname, join } from "node:path";
|
|
11
|
+
|
|
12
|
+
const VALID = /^[A-Za-z0-9_-]{16,128}$/;
|
|
13
|
+
let cached: string | undefined;
|
|
14
|
+
let cachedFile: string | undefined;
|
|
15
|
+
|
|
16
|
+
export function deviceIdFile(): string {
|
|
17
|
+
return process.env.SERA_DEVICE_ID_FILE || join(homedir(), ".sera", "device-id");
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function deviceId(): string {
|
|
21
|
+
const file = deviceIdFile();
|
|
22
|
+
if (cached && cachedFile === file) return cached;
|
|
23
|
+
let id: string | undefined;
|
|
24
|
+
try {
|
|
25
|
+
const v = readFileSync(file, "utf8").trim();
|
|
26
|
+
if (VALID.test(v)) id = v;
|
|
27
|
+
} catch {
|
|
28
|
+
// dosya yok: asagida uretilir
|
|
29
|
+
}
|
|
30
|
+
if (!id) {
|
|
31
|
+
id = randomBytes(16).toString("hex");
|
|
32
|
+
try {
|
|
33
|
+
mkdirSync(dirname(file), { recursive: true });
|
|
34
|
+
writeFileSync(file, `${id}\n`, { mode: 0o600 });
|
|
35
|
+
} catch {
|
|
36
|
+
// yazilamadi: bellek-ici kimlik
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
cached = id;
|
|
40
|
+
cachedFile = file;
|
|
41
|
+
return id;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Test icin onbellegi sifirlar. */
|
|
45
|
+
export function _resetDeviceIdForTest(): void {
|
|
46
|
+
cached = undefined;
|
|
47
|
+
cachedFile = undefined;
|
|
48
|
+
}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dogal-dil arac katmani: slash komutlarinin ayni mantigi MODEL ARACLARI olarak (deferred; tool_search ile bulunur).
|
|
3
|
+
* - `sera_islem`: hedef|aktar|devret|mod|plan|uygula|guven|hatirla|unut|geri -> kayitli komut isleyicisini cagirir.
|
|
4
|
+
* - `github_ajan`: kur|durum|mod|durdur (mantik github-ajan-akis.ts).
|
|
5
|
+
* KAPI: arac yalniz KULLANICININ kendi son mesajinda ilgili niyet varsa calisir (arac sonucu/web metni niyet sayilmaz;
|
|
6
|
+
* "modu tam yap" diyen bir sayfa araci tetikleyemez). Kapi saf `gateIntent` ile testlenir.
|
|
7
|
+
*/
|
|
8
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
9
|
+
import { Type } from "typebox";
|
|
10
|
+
import { detectIntents, type IntentName, intentHintText } from "./dogal-niyet.ts";
|
|
11
|
+
import { rareExposure } from "./exposure.ts";
|
|
12
|
+
import { type AkisDeps, type AkisParams, githubAjan } from "./github-ajan-akis.ts";
|
|
13
|
+
import { realAkisDeps } from "./github-ajan-gercek.ts";
|
|
14
|
+
import { githubYedek, type YedekAction } from "./github-yedek.ts";
|
|
15
|
+
|
|
16
|
+
export type Handler = (args: string, ctx: any) => unknown | Promise<unknown>;
|
|
17
|
+
|
|
18
|
+
/** islem -> [komut adi, gereken niyet, arguman onceleme]. */
|
|
19
|
+
export const ISLEMLER: Record<string, { cmd: string; intent: IntentName; fix?: (a: string) => string }> = {
|
|
20
|
+
hedef: { cmd: "goal", intent: "hedef" },
|
|
21
|
+
aktar: { cmd: "sera-export", intent: "aktar" },
|
|
22
|
+
devret: { cmd: "sera-handoff", intent: "devret" },
|
|
23
|
+
mod: { cmd: "sera-mode", intent: "mod" },
|
|
24
|
+
plan: { cmd: "sera-agent", intent: "plan", fix: () => "plan" },
|
|
25
|
+
uygula: { cmd: "sera-agent", intent: "build", fix: () => "build" },
|
|
26
|
+
guven: { cmd: "guven", intent: "guven" },
|
|
27
|
+
hatirla: { cmd: "hatirla", intent: "hatirla" },
|
|
28
|
+
unut: { cmd: "unut", intent: "unut" },
|
|
29
|
+
geri: { cmd: "geri", intent: "geri" },
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export interface GateResult {
|
|
33
|
+
ok: boolean;
|
|
34
|
+
reason?: string;
|
|
35
|
+
}
|
|
36
|
+
/** Kullanicinin SON mesajindan yakalanan niyetler `seen` icinde mi? */
|
|
37
|
+
export function gateIntent(seen: ReadonlySet<IntentName>, need: IntentName): GateResult {
|
|
38
|
+
return seen.has(need)
|
|
39
|
+
? { ok: true }
|
|
40
|
+
: {
|
|
41
|
+
ok: false,
|
|
42
|
+
reason: "Bu işlem için kullanıcının açıkça istemesi gerekir; kullanıcı bunu bu mesajında istemedi.",
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Komut isleyicisini calistirir; ui.notify ciktisini toplayip metin olarak dondurur. */
|
|
47
|
+
export async function runHandler(h: Handler, args: string, ctx: any): Promise<string> {
|
|
48
|
+
const out: string[] = [];
|
|
49
|
+
const shim = Object.create(ctx, {
|
|
50
|
+
hasUI: { value: true },
|
|
51
|
+
ui: { value: { ...(ctx?.ui ?? {}), notify: (m: string) => void out.push(String(m)) } },
|
|
52
|
+
// Arac turunun ortasinda konusma agaci gezilemez: dosya geri alma calisir, konusma geri sarilmaz.
|
|
53
|
+
navigateTree: { value: async () => ({ cancelled: false }) },
|
|
54
|
+
});
|
|
55
|
+
await h(args, shim);
|
|
56
|
+
return out.join("\n") || "Tamam.";
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const textOut = (t: string, isError = false) => ({
|
|
60
|
+
content: [{ type: "text" as const, text: t }],
|
|
61
|
+
details: {},
|
|
62
|
+
...(isError ? { isError: true } : {}),
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
/** github_ajan icin eylem -> gereken niyet (durum serbest; kur: bu oturumda GitHub niyeti gorulmus olmali). */
|
|
66
|
+
export function githubGate(
|
|
67
|
+
p: Pick<AkisParams, "action" | "mod">,
|
|
68
|
+
seen: ReadonlySet<IntentName>,
|
|
69
|
+
githubSeen: boolean,
|
|
70
|
+
): GateResult {
|
|
71
|
+
if (p.action === "durum") return { ok: true };
|
|
72
|
+
const no = {
|
|
73
|
+
ok: false,
|
|
74
|
+
reason: "Bu işlem için kullanıcının açıkça istemesi gerekir; kullanıcı bunu bu mesajında istemedi.",
|
|
75
|
+
};
|
|
76
|
+
if (p.action === "kur") return githubSeen || seen.has("github") ? { ok: true } : no;
|
|
77
|
+
if (p.action === "durdur") return seen.has("github-stop") ? { ok: true } : no;
|
|
78
|
+
if (p.action === "mod") return seen.has(p.mod === "act" ? "github-act" : "github-observe") ? { ok: true } : no;
|
|
79
|
+
return no;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface DogalOpts {
|
|
83
|
+
handlers: Map<string, Handler>;
|
|
84
|
+
/** Test icin: gercek yerine sahte bagimlilik. */
|
|
85
|
+
akisDeps?: (cwd: string, ctx: any) => AkisDeps;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Niyet takibi + ipucu + iki arac. Yalniz ust ajan. */
|
|
89
|
+
export function registerDogalTools(pi: ExtensionAPI, o: DogalOpts): void {
|
|
90
|
+
let seen: ReadonlySet<IntentName> = new Set();
|
|
91
|
+
let githubSeen = false;
|
|
92
|
+
let lastUser = "";
|
|
93
|
+
pi.on("before_agent_start", (event) => {
|
|
94
|
+
if (event.messageType === "user" && !event.prompt.startsWith("[SİSTEM")) {
|
|
95
|
+
lastUser = event.prompt;
|
|
96
|
+
seen = detectIntents(event.prompt);
|
|
97
|
+
if (seen.has("github")) githubSeen = true;
|
|
98
|
+
}
|
|
99
|
+
const hint = intentHintText(lastUser);
|
|
100
|
+
if (hint && event.messageType === "user") {
|
|
101
|
+
const opts = event.systemPromptOptions as { appendSystemPrompt?: string };
|
|
102
|
+
opts.appendSystemPrompt = (opts.appendSystemPrompt ?? "") + hint;
|
|
103
|
+
}
|
|
104
|
+
return undefined;
|
|
105
|
+
});
|
|
106
|
+
pi.registerTool({
|
|
107
|
+
name: "sera_islem",
|
|
108
|
+
exposure: rareExposure(),
|
|
109
|
+
label: "sera_islem",
|
|
110
|
+
description:
|
|
111
|
+
"Kullanıcının DOĞAL isteğini Sera ayarına çevirir (kullanıcı komut yazmaz). islem=hedef (bitene kadar uğraş; arguman=hedef) | aktar (konuşmayı dosyaya kaydet) | devret (yeni oturuma devir notu) | mod (arguman=oku|düzenle|tam, ağ kapat|aç) | plan (önce plan, dosyalara dokunma) | uygula (plana geç) | guven (bu projeye güven) | hatirla (arguman=not) | unut (arguman=hepsi|no) | geri (son değişikliği geri al). Yalnız kullanıcı bunu kendi mesajında istediyse çalışır.",
|
|
112
|
+
promptSnippet: "Natural-language Sera settings: goal/export/handoff/mode/plan/trust/remember/forget/undo",
|
|
113
|
+
parameters: Type.Object({
|
|
114
|
+
islem: Type.String({ description: Object.keys(ISLEMLER).join("|") }),
|
|
115
|
+
arguman: Type.Optional(Type.String()),
|
|
116
|
+
}),
|
|
117
|
+
async execute(_id, params, _signal, _update, ctx) {
|
|
118
|
+
const spec = ISLEMLER[params.islem];
|
|
119
|
+
if (!spec) return textOut(`Bilinmeyen islem. Seçenekler: ${Object.keys(ISLEMLER).join(", ")}`, true);
|
|
120
|
+
const g = gateIntent(seen, spec.intent);
|
|
121
|
+
if (!g.ok) return textOut(g.reason ?? "Reddedildi.", true);
|
|
122
|
+
const h = o.handlers.get(spec.cmd);
|
|
123
|
+
if (!h) return textOut(`Bu özellik şu an kapalı (${params.islem}).`, true);
|
|
124
|
+
try {
|
|
125
|
+
return textOut(
|
|
126
|
+
await runHandler(h, spec.fix ? spec.fix(params.arguman ?? "") : (params.arguman ?? ""), ctx),
|
|
127
|
+
);
|
|
128
|
+
} catch (e) {
|
|
129
|
+
return textOut(`Yapılamadı: ${e instanceof Error ? e.message : String(e)}`, true);
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
const mkDeps = (ctx: any) =>
|
|
134
|
+
o.akisDeps?.(ctx.cwd, ctx) ??
|
|
135
|
+
realAkisDeps(ctx.cwd, {
|
|
136
|
+
entry: process.env.SERA_PI_ENTRY ?? process.argv[1] ?? "",
|
|
137
|
+
args: ctx.model ? ["--provider", ctx.model.provider, "--model", ctx.model.id] : [],
|
|
138
|
+
});
|
|
139
|
+
// Degisiklikleri otomatik yedekle (yalniz baglanmis projelerde; sir bulunursa ENGELLENIR). Sessiz; engelde kullaniciya soyler.
|
|
140
|
+
pi.on("agent_end", async (_e, ctx) => {
|
|
141
|
+
try {
|
|
142
|
+
const r = await githubYedek("gonder", ctx.cwd, mkDeps(ctx));
|
|
143
|
+
if (r.status === "blocked") ctx.ui?.notify?.(r.text, "warning");
|
|
144
|
+
} catch {
|
|
145
|
+
// yedekleme asla ana isi bozmaz
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
pi.registerTool({
|
|
149
|
+
name: "github_yedek",
|
|
150
|
+
exposure: rareExposure(),
|
|
151
|
+
label: "github_yedek",
|
|
152
|
+
description:
|
|
153
|
+
"Proje yedeği/GitHub bağlama teklifi. Sera bir PROJE ÜRETİP TESLİM ETTİKTEN SONRA action=durum çağır; status=ask ise dönen metni olduğu gibi göster (iki seçenek: Bağla / Şimdi değil) ve kullanıcının cevabını bekle. Kullanıcı Bağla derse action=baglan, Şimdi değil derse action=simdi-degil. Üretimi ASLA bekletme/engelleme.",
|
|
154
|
+
promptSnippet: "After delivering a built project, offer once to back it up to the user's GitHub (private)",
|
|
155
|
+
parameters: Type.Object({ action: Type.String({ description: "durum|baglan|simdi-degil" }) }),
|
|
156
|
+
async execute(_id, params, _signal, _update, ctx) {
|
|
157
|
+
const a = params.action as YedekAction;
|
|
158
|
+
if (!["durum", "baglan", "simdi-degil"].includes(a)) return textOut("action: durum|baglan|simdi-degil", true);
|
|
159
|
+
if (a === "baglan" && !seen.has("yedek-bagla") && !seen.has("github"))
|
|
160
|
+
return textOut("Bunun için kullanıcının 'Bağla' demesi gerekir.", true);
|
|
161
|
+
if (a === "simdi-degil" && !seen.has("yedek-ret"))
|
|
162
|
+
return textOut("Bunun için kullanıcının 'Şimdi değil' demesi gerekir.", true);
|
|
163
|
+
try {
|
|
164
|
+
const r = await githubYedek(a, ctx.cwd, mkDeps(ctx));
|
|
165
|
+
return textOut(`[${r.status}] ${r.text}`, r.status === "error");
|
|
166
|
+
} catch (e) {
|
|
167
|
+
return textOut(`Yapılamadı: ${e instanceof Error ? e.message : String(e)}`, true);
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
});
|
|
171
|
+
pi.registerTool({
|
|
172
|
+
name: "github_ajan",
|
|
173
|
+
exposure: rareExposure(),
|
|
174
|
+
label: "github_ajan",
|
|
175
|
+
description:
|
|
176
|
+
"GitHub projesini izleyen ajan (kullanıcı komut yazmaz). action=kur (sıfır soru: giriş, depo seçimi, arka plan izleyici; depo=owner/name ya da listeden numara) | durum | mod (mod=act|observe) | durdur. Dönen metni kullanıcıya olduğu gibi, teknik terim eklemeden ilet. status=login-needed ya da choose ise kullanıcının cevabını bekle, sonra kur'u yeniden çağır.",
|
|
177
|
+
promptSnippet: "Watch the user's GitHub repo: setup/status/mode/stop (no commands needed)",
|
|
178
|
+
parameters: Type.Object({
|
|
179
|
+
action: Type.String({ description: "kur|durum|mod|durdur" }),
|
|
180
|
+
depo: Type.Optional(Type.String()),
|
|
181
|
+
mod: Type.Optional(Type.String({ description: "act|observe" })),
|
|
182
|
+
}),
|
|
183
|
+
async execute(_id, params, _signal, _update, ctx) {
|
|
184
|
+
const a = params.action as AkisParams["action"];
|
|
185
|
+
if (!["kur", "durum", "mod", "durdur"].includes(a)) return textOut("action: kur|durum|mod|durdur", true);
|
|
186
|
+
const mod = params.mod === "act" || params.mod === "observe" ? params.mod : undefined;
|
|
187
|
+
const g = githubGate({ action: a, mod }, seen, githubSeen);
|
|
188
|
+
if (!g.ok) return textOut(g.reason ?? "Reddedildi.", true);
|
|
189
|
+
try {
|
|
190
|
+
const deps =
|
|
191
|
+
o.akisDeps?.(ctx.cwd, ctx) ??
|
|
192
|
+
realAkisDeps(ctx.cwd, {
|
|
193
|
+
entry: process.env.SERA_PI_ENTRY ?? process.argv[1] ?? "",
|
|
194
|
+
args: ctx.model ? ["--provider", ctx.model.provider, "--model", ctx.model.id] : [],
|
|
195
|
+
});
|
|
196
|
+
const r = await githubAjan({ action: a, depo: params.depo, mod }, deps);
|
|
197
|
+
return textOut(`[${r.status}] ${r.text}`, r.status === "error");
|
|
198
|
+
} catch (e) {
|
|
199
|
+
return textOut(`Yapılamadı: ${e instanceof Error ? e.message : String(e)}`, true);
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
});
|
|
203
|
+
}
|