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,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `/sera-github` komutunun Pi'ye baglanmasi (kur | durum | mod | tek-tur | izle). Mantik github-agent.ts'te.
|
|
3
|
+
* extension.ts'ten yalniz uste ajanda (SERA_SUBAGENT_DEPTH != 1) cagrilir.
|
|
4
|
+
*/
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
7
|
+
import {
|
|
8
|
+
acquireLock,
|
|
9
|
+
defaultHome,
|
|
10
|
+
GH_USAGE,
|
|
11
|
+
loadConfig,
|
|
12
|
+
parseGithubCommand,
|
|
13
|
+
releaseLock,
|
|
14
|
+
runOnce,
|
|
15
|
+
saveConfig,
|
|
16
|
+
statusText,
|
|
17
|
+
type TicketOutcome,
|
|
18
|
+
} from "./github-agent.ts";
|
|
19
|
+
import { makeEngine, makeRunner, setupGithub } from "./github-agent-engine.ts";
|
|
20
|
+
|
|
21
|
+
type Say = (ctx: ExtensionContext, msg: string, level?: "info" | "warning" | "error") => void;
|
|
22
|
+
|
|
23
|
+
const NL = "\n";
|
|
24
|
+
const NOT_SETUP = "Kurulu değil. Önce: /sera-github kur sahip/depo";
|
|
25
|
+
|
|
26
|
+
export function registerGithubCommand(pi: ExtensionAPI, say: Say): void {
|
|
27
|
+
let timer: ReturnType<typeof setInterval> | undefined;
|
|
28
|
+
let busy = false;
|
|
29
|
+
const home = defaultHome();
|
|
30
|
+
|
|
31
|
+
const tick = async (ctx: ExtensionContext): Promise<TicketOutcome[]> => {
|
|
32
|
+
const cfg = loadConfig(home);
|
|
33
|
+
if (!cfg) throw new Error(NOT_SETUP);
|
|
34
|
+
if (busy) return [];
|
|
35
|
+
busy = true;
|
|
36
|
+
try {
|
|
37
|
+
const engine = makeEngine({
|
|
38
|
+
node: process.execPath,
|
|
39
|
+
entry: process.env.SERA_PI_ENTRY ?? process.argv[1] ?? "",
|
|
40
|
+
extensions: [fileURLToPath(new URL("./extension.ts", import.meta.url))],
|
|
41
|
+
args: ctx.model ? ["--provider", ctx.model.provider, "--model", ctx.model.id] : [],
|
|
42
|
+
});
|
|
43
|
+
const r = await runOnce(cfg, { run: makeRunner(), engine, home, now: () => Date.now() });
|
|
44
|
+
if (r.error) throw new Error(r.error);
|
|
45
|
+
return r.outcomes;
|
|
46
|
+
} finally {
|
|
47
|
+
busy = false;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const report = (o: TicketOutcome[]): string =>
|
|
51
|
+
o.length
|
|
52
|
+
? o.map((x) => `${x.id}: ${x.status}${x.pr ? ` ${x.pr}` : x.detail ? ` (${x.detail})` : ""}`).join(NL)
|
|
53
|
+
: "yeni olay yok";
|
|
54
|
+
|
|
55
|
+
pi.registerCommand("sera-github", {
|
|
56
|
+
description: "Sera: GitHub deposunda yaşayan ajan — kur | durum | mod | tek-tur | izle",
|
|
57
|
+
handler: async (args, ctx) => {
|
|
58
|
+
const c = parseGithubCommand(args);
|
|
59
|
+
try {
|
|
60
|
+
if (c.action === "yardim")
|
|
61
|
+
return say(ctx, `[Sera GitHub] ${c.error ? c.error + NL : ""}${GH_USAGE}`, "warning");
|
|
62
|
+
if (c.action === "kur") {
|
|
63
|
+
const { cfg, notes } = await setupGithub(c, { run: makeRunner(), home, now: () => Date.now() });
|
|
64
|
+
const head = `[Sera GitHub] Kuruldu: ${cfg.repo} | mod: ${cfg.mode} | izinli: ${cfg.allowed.join(", ")}`;
|
|
65
|
+
return say(
|
|
66
|
+
ctx,
|
|
67
|
+
[head, ...notes, "Başlangıç modu observe (yazmaz). Etkinleştirmek: /sera-github mod act"].join(NL),
|
|
68
|
+
"info",
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
if (c.action === "durum")
|
|
72
|
+
return say(
|
|
73
|
+
ctx,
|
|
74
|
+
`[Sera GitHub]${NL}${statusText(home, Date.now())}${NL}izleme: ${timer ? "AÇIK" : "kapalı"}`,
|
|
75
|
+
"info",
|
|
76
|
+
);
|
|
77
|
+
if (c.action === "mod") {
|
|
78
|
+
const cfg = loadConfig(home);
|
|
79
|
+
if (!cfg) return say(ctx, `[Sera GitHub] ${NOT_SETUP}`, "warning");
|
|
80
|
+
saveConfig(home, { ...cfg, mode: c.mode ?? cfg.mode });
|
|
81
|
+
return say(ctx, `[Sera GitHub] Mod: ${c.mode}`, "info");
|
|
82
|
+
}
|
|
83
|
+
if (c.action === "izle-dur") {
|
|
84
|
+
if (timer) clearInterval(timer);
|
|
85
|
+
timer = undefined;
|
|
86
|
+
releaseLock(home);
|
|
87
|
+
return say(ctx, "[Sera GitHub] İzleme durdu.", "info");
|
|
88
|
+
}
|
|
89
|
+
if (c.action === "tek-tur") {
|
|
90
|
+
if (!acquireLock(home, Date.now()))
|
|
91
|
+
return say(ctx, "[Sera GitHub] Başka bir yoklayıcı çalışıyor.", "warning");
|
|
92
|
+
try {
|
|
93
|
+
return say(ctx, `[Sera GitHub] Tur bitti:${NL}${report(await tick(ctx))}`, "info");
|
|
94
|
+
} finally {
|
|
95
|
+
if (!timer) releaseLock(home);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (c.action === "izle") {
|
|
99
|
+
const cfg = loadConfig(home);
|
|
100
|
+
if (!cfg) return say(ctx, `[Sera GitHub] ${NOT_SETUP}`, "warning");
|
|
101
|
+
if (timer) return say(ctx, "[Sera GitHub] İzleme zaten açık. Durdurmak: /sera-github izle dur", "info");
|
|
102
|
+
if (!acquireLock(home, Date.now()))
|
|
103
|
+
return say(ctx, "[Sera GitHub] Başka bir yoklayıcı çalışıyor.", "warning");
|
|
104
|
+
const sec = c.pollSec ?? cfg.pollSec ?? 60;
|
|
105
|
+
const loop = () =>
|
|
106
|
+
tick(ctx)
|
|
107
|
+
.then((o) => {
|
|
108
|
+
if (o.length) say(ctx, `[Sera GitHub]${NL}${report(o)}`, "info");
|
|
109
|
+
})
|
|
110
|
+
.catch((e) =>
|
|
111
|
+
say(ctx, `[Sera GitHub] Tur hatası: ${e instanceof Error ? e.message : String(e)}`, "warning"),
|
|
112
|
+
);
|
|
113
|
+
void loop();
|
|
114
|
+
timer = setInterval(loop, sec * 1000);
|
|
115
|
+
timer.unref?.();
|
|
116
|
+
return say(
|
|
117
|
+
ctx,
|
|
118
|
+
`[Sera GitHub] İzleme açık (her ${sec} sn, mod: ${cfg.mode}). Durdurmak: /sera-github izle dur`,
|
|
119
|
+
"info",
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
} catch (e) {
|
|
123
|
+
say(ctx, `[Sera GitHub] Hata: ${e instanceof Error ? e.message : String(e)}`, "error");
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
pi.on("session_shutdown", () => {
|
|
128
|
+
if (!timer) return;
|
|
129
|
+
clearInterval(timer);
|
|
130
|
+
timer = undefined;
|
|
131
|
+
releaseLock(home);
|
|
132
|
+
});
|
|
133
|
+
}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitHub ajani icin gercek bagimliliklar: gh/git calistirici, Sera motoru (basiz alt surec = runChild), kurulum.
|
|
3
|
+
* Mantik github-agent.ts'te; burasi I/O ve motor baglamasi (testte sahte Pi girisiyle de calisir).
|
|
4
|
+
*/
|
|
5
|
+
import { spawn } from "node:child_process";
|
|
6
|
+
import { existsSync, mkdirSync } from "node:fs";
|
|
7
|
+
import { join } from "node:path";
|
|
8
|
+
import { BudgetGovernor } from "./budget.ts";
|
|
9
|
+
import {
|
|
10
|
+
type Deps,
|
|
11
|
+
type Engine,
|
|
12
|
+
type GhAgentConfig,
|
|
13
|
+
type GhCommand,
|
|
14
|
+
loadConfig,
|
|
15
|
+
type Runner,
|
|
16
|
+
type RunResult,
|
|
17
|
+
saveConfig,
|
|
18
|
+
} from "./github-agent.ts";
|
|
19
|
+
import { resolveCommand } from "./lsp.ts";
|
|
20
|
+
import { PERMISSION_TITLE_PREFIX } from "./permission-bridge.ts";
|
|
21
|
+
import { killTree } from "./proc.ts";
|
|
22
|
+
import { runChild, SUBAGENT_DEPTH_ENV } from "./subagent.ts";
|
|
23
|
+
|
|
24
|
+
function shellFor(args: string[], cwd?: string): [string, string[]] {
|
|
25
|
+
if (process.platform !== "win32") return ["sh", args];
|
|
26
|
+
const bash = resolveCommand("bash", cwd ?? process.cwd());
|
|
27
|
+
return bash ? [bash, args] : ["cmd.exe", ["/d", "/s", "/c", args[1] ?? ""]];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function makeRunner(): Runner {
|
|
31
|
+
return (cmd, args, opts = {}) =>
|
|
32
|
+
new Promise<RunResult>((resolve) => {
|
|
33
|
+
const [bin, a] = cmd === "sh" ? shellFor(args, opts.cwd) : [cmd, args];
|
|
34
|
+
const child = spawn(bin, a, {
|
|
35
|
+
cwd: opts.cwd,
|
|
36
|
+
windowsHide: true,
|
|
37
|
+
detached: process.platform !== "win32",
|
|
38
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
39
|
+
});
|
|
40
|
+
let out = "";
|
|
41
|
+
let err = "";
|
|
42
|
+
let done = false;
|
|
43
|
+
const cap = (s: string, add: string) => (s.length > 2_000_000 ? s : s + add);
|
|
44
|
+
child.stdout.setEncoding("utf8").on("data", (d: string) => {
|
|
45
|
+
out = cap(out, d);
|
|
46
|
+
});
|
|
47
|
+
child.stderr.setEncoding("utf8").on("data", (d: string) => {
|
|
48
|
+
err = cap(err, d);
|
|
49
|
+
});
|
|
50
|
+
const end = (code: number) => {
|
|
51
|
+
if (done) return;
|
|
52
|
+
done = true;
|
|
53
|
+
clearTimeout(timer);
|
|
54
|
+
resolve({ code, stdout: out, stderr: err });
|
|
55
|
+
};
|
|
56
|
+
const timer = setTimeout(() => {
|
|
57
|
+
err += "\n[zaman asimi]";
|
|
58
|
+
try {
|
|
59
|
+
killTree(child);
|
|
60
|
+
} catch {
|
|
61
|
+
// kapanmis
|
|
62
|
+
}
|
|
63
|
+
end(124);
|
|
64
|
+
}, opts.timeoutMs ?? 120_000);
|
|
65
|
+
child.on("error", (e) => {
|
|
66
|
+
err += String(e);
|
|
67
|
+
end(127);
|
|
68
|
+
});
|
|
69
|
+
child.on("close", (code) => end(code ?? 1));
|
|
70
|
+
child.stdin.on("error", () => {});
|
|
71
|
+
child.stdin.end(opts.input ?? "");
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Alt surecin izin sorusuna karar (insansiz): yalniz sıradan, worktree-ici islere "once"; geri kalan RED. */
|
|
76
|
+
export function decideChildPermission(title: string): "once" | "reject" {
|
|
77
|
+
if (!title.startsWith(PERMISSION_TITLE_PREFIX)) return "reject";
|
|
78
|
+
let p: { kind?: string; reason?: string; sticky?: boolean; egress?: boolean };
|
|
79
|
+
try {
|
|
80
|
+
p = JSON.parse(title.slice(PERMISSION_TITLE_PREFIX.length));
|
|
81
|
+
} catch {
|
|
82
|
+
return "reject";
|
|
83
|
+
}
|
|
84
|
+
if (p.egress || p.sticky || p.kind === "mcp") return "reject";
|
|
85
|
+
if (/DIŞINDA|duyarlı|Dışarı|harici/i.test(p.reason ?? "")) return "reject";
|
|
86
|
+
return p.kind === "bash" || p.kind === "edit" ? "once" : "reject";
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface EngineSetup {
|
|
90
|
+
node: string;
|
|
91
|
+
entry: string;
|
|
92
|
+
extensions: string[];
|
|
93
|
+
args?: string[]; // ornegin --provider X --model Y
|
|
94
|
+
baseEnv?: Record<string, string | undefined>;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Motor ortami: izole calisma. Sera sandbox'i ZORUNLU acik (kullanici ortamindaki SERA_SANDBOX=0 gecersiz) ve yazma yalniz
|
|
99
|
+
* calisma dizini (izole worktree) + sandbox gecici klasoru; ek yazma/yol izni yok; gizli dosyalar sandbox denyWrite'ta.
|
|
100
|
+
*/
|
|
101
|
+
export function engineEnv(
|
|
102
|
+
s: Pick<EngineSetup, "baseEnv">,
|
|
103
|
+
req: { cwd: string; maxUsd: number; maxTurns: number },
|
|
104
|
+
): Record<string, string | undefined> {
|
|
105
|
+
return {
|
|
106
|
+
...s.baseEnv,
|
|
107
|
+
SERA_PERMISSIONS: "1",
|
|
108
|
+
SERA_MODE: "full",
|
|
109
|
+
SERA_NET: "ask",
|
|
110
|
+
SERA_SANDBOX: "1",
|
|
111
|
+
SERA_SANDBOX_ALLOW_WRITE: "",
|
|
112
|
+
SERA_WORKSPACE_GUARD: "1",
|
|
113
|
+
SERA_UNTRUSTED: "1",
|
|
114
|
+
SERA_ALLOW_PATHS: "",
|
|
115
|
+
SERA_SUBAGENTS: "0",
|
|
116
|
+
[SUBAGENT_DEPTH_ENV]: "1",
|
|
117
|
+
SERA_BUDGET_USD: String(req.maxUsd),
|
|
118
|
+
SERA_BUDGET_TURNS: String(req.maxTurns),
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** Sera motoru: ayri Pi sureci, tam onay modu, TUM kapilar acik, tavanli butce + sure. */
|
|
123
|
+
export function makeEngine(s: EngineSetup): Engine {
|
|
124
|
+
return async (req) => {
|
|
125
|
+
const env = engineEnv(s, req);
|
|
126
|
+
const res = await runChild({
|
|
127
|
+
node: s.node,
|
|
128
|
+
entry: s.entry,
|
|
129
|
+
extensions: s.extensions,
|
|
130
|
+
cwd: req.cwd,
|
|
131
|
+
args: s.args ?? [],
|
|
132
|
+
env,
|
|
133
|
+
prompt: req.prompt,
|
|
134
|
+
timeoutMs: req.timeoutMs,
|
|
135
|
+
onPermission: async (title) => decideChildPermission(title),
|
|
136
|
+
});
|
|
137
|
+
const g = new BudgetGovernor({ usd: req.maxUsd, turns: req.maxTurns });
|
|
138
|
+
for (const u of res.usages) g.record(u);
|
|
139
|
+
const out: ReturnType<Engine> extends Promise<infer R> ? R : never = {
|
|
140
|
+
text: res.text,
|
|
141
|
+
usd: g.usd,
|
|
142
|
+
turns: g.turns,
|
|
143
|
+
};
|
|
144
|
+
if (res.halted) out.halted = res.halted;
|
|
145
|
+
else if (res.stopReason === "timeout" || res.stopReason === "aborted")
|
|
146
|
+
out.error = res.errorMessage ?? res.stopReason;
|
|
147
|
+
else if (res.stopReason === "error" || (res.errorMessage && !res.text))
|
|
148
|
+
out.error = res.errorMessage ?? "motor hatasi";
|
|
149
|
+
else if (g.check().halted) out.halted = g.check().message;
|
|
150
|
+
return out;
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** `kur`: yapilandirmayi yazar. gh ile kullanici girisini ve (gerekirse) klonu hazirlar. */
|
|
155
|
+
export async function setupGithub(
|
|
156
|
+
cmd: GhCommand,
|
|
157
|
+
d: Pick<Deps, "run" | "home" | "now">,
|
|
158
|
+
): Promise<{ cfg: GhAgentConfig; notes: string[] }> {
|
|
159
|
+
const repo = cmd.repo as string;
|
|
160
|
+
const notes: string[] = [];
|
|
161
|
+
const who = await d.run("gh", ["api", "user", "--jq", ".login"], { timeoutMs: 30_000 });
|
|
162
|
+
const login = who.code === 0 ? who.stdout.trim() : "";
|
|
163
|
+
if (!login && !cmd.allowed?.length) throw new Error("gh oturumu yok (gh auth login) ve --izinli verilmedi.");
|
|
164
|
+
const allowed = (cmd.allowed?.length ? cmd.allowed : [login]).map((x) => x.toLowerCase());
|
|
165
|
+
const slug = repo.replace("/", "__");
|
|
166
|
+
const clonePath = cmd.clonePath ?? join(d.home, "clones", slug);
|
|
167
|
+
if (!existsSync(join(clonePath, ".git"))) {
|
|
168
|
+
mkdirSync(join(clonePath, ".."), { recursive: true });
|
|
169
|
+
const c = await d.run("gh", ["repo", "clone", repo, clonePath], { timeoutMs: 300_000 });
|
|
170
|
+
if (c.code !== 0) throw new Error(`klonlanamadi: ${(c.stderr || c.stdout).trim().slice(0, 200)}`);
|
|
171
|
+
notes.push(`Klonlandı: ${clonePath}`);
|
|
172
|
+
} else {
|
|
173
|
+
const o = await d.run("git", ["remote", "get-url", "origin"], { cwd: clonePath, timeoutMs: 15_000 });
|
|
174
|
+
if (o.code !== 0 || !o.stdout.toLowerCase().includes(repo.toLowerCase()))
|
|
175
|
+
throw new Error(`Klon klasörünün origin'i ${repo} değil: ${o.stdout.trim()}`);
|
|
176
|
+
}
|
|
177
|
+
const gn = await d.run("git", ["config", "user.name"], { cwd: clonePath, timeoutMs: 15_000 });
|
|
178
|
+
const ge = await d.run("git", ["config", "user.email"], { cwd: clonePath, timeoutMs: 15_000 });
|
|
179
|
+
const prev = loadConfig(d.home);
|
|
180
|
+
const cfg: GhAgentConfig = {
|
|
181
|
+
repo,
|
|
182
|
+
allowed,
|
|
183
|
+
clonePath,
|
|
184
|
+
mode: cmd.mode ?? prev?.mode ?? "observe",
|
|
185
|
+
botLogin: login || undefined,
|
|
186
|
+
maxUsd: prev?.maxUsd ?? 1,
|
|
187
|
+
maxTurns: prev?.maxTurns ?? 40,
|
|
188
|
+
timeoutMs: prev?.timeoutMs ?? 20 * 60_000,
|
|
189
|
+
dailyMaxUsd: prev?.dailyMaxUsd ?? 3,
|
|
190
|
+
testCommand: cmd.testCommand ?? prev?.testCommand,
|
|
191
|
+
authorName: prev?.authorName ?? (gn.stdout.trim() ? `${gn.stdout.trim()} (Sera ajanı)` : "Sera ajanı"),
|
|
192
|
+
authorEmail: prev?.authorEmail ?? (ge.stdout.trim() || undefined),
|
|
193
|
+
pollSec: prev?.pollSec ?? 60,
|
|
194
|
+
workRoot: prev?.workRoot ?? join(d.home, "work", slug),
|
|
195
|
+
};
|
|
196
|
+
saveConfig(d.home, cfg);
|
|
197
|
+
return { cfg, notes };
|
|
198
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitHub ajani icin kalici arka plan izleyici: Sera kapaliyken de calisir.
|
|
3
|
+
* - Windows: Gorev Zamanlayici (schtasks, kullanici duzeyi, YONETICI GEREKTIRMEZ), oturum aciksa her 5 dk.
|
|
4
|
+
* Pencere cakmasin diye wscript //B ile gizli calisan kucuk .vbs sarmalayici.
|
|
5
|
+
* - macOS: launchd kullanici ajani (~/Library/LaunchAgents). Linux: kullanici crontab'i (isaretli satir).
|
|
6
|
+
* Tek ornek kilidi + gunluk butce tavani github-agent.ts'te (acquireLock / dailyMaxUsd); durdur = gorevi siler.
|
|
7
|
+
* Tum dis cagrilar enjekte edilen `Exec` ile yapilir: testte sahte exec, gercek makinede gercek.
|
|
8
|
+
*/
|
|
9
|
+
import { mkdirSync, rmSync, writeFileSync } from "node:fs";
|
|
10
|
+
import { homedir } from "node:os";
|
|
11
|
+
import { join } from "node:path";
|
|
12
|
+
|
|
13
|
+
export type Exec = (
|
|
14
|
+
cmd: string,
|
|
15
|
+
args: string[],
|
|
16
|
+
opts?: { input?: string; timeoutMs?: number },
|
|
17
|
+
) => Promise<{ code: number; stdout: string; stderr: string }>;
|
|
18
|
+
|
|
19
|
+
export const TASK_NAME = "SeraGithubAjan";
|
|
20
|
+
export const LAUNCHD_LABEL = "com.sera.github-ajan";
|
|
21
|
+
export const CRON_MARK = "# sera-github-ajan";
|
|
22
|
+
|
|
23
|
+
export interface ScheduleSpec {
|
|
24
|
+
platform: NodeJS.Platform;
|
|
25
|
+
/** Ajan evi (config.json, tick.vbs/tick.log burada). */
|
|
26
|
+
home: string;
|
|
27
|
+
node: string;
|
|
28
|
+
/** tick betigi (github-tick.ts) mutlak yolu. */
|
|
29
|
+
tickScript: string;
|
|
30
|
+
everyMin?: number;
|
|
31
|
+
/** Test icin: LaunchAgents/ dizinini degistirir. */
|
|
32
|
+
launchAgentsDir?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const q = (s: string) => `"${s.replace(/"/g, '""')}"`;
|
|
36
|
+
|
|
37
|
+
export function tickCommandLine(s: ScheduleSpec): string {
|
|
38
|
+
return `${q(s.node)} ${q(s.tickScript)}`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Windows: gizli calistirici .vbs icerigi. */
|
|
42
|
+
export function vbsContent(s: ScheduleSpec): string {
|
|
43
|
+
const cmd = `${q(s.node)} ${q(s.tickScript)}`.replace(/"/g, '""');
|
|
44
|
+
return `CreateObject("WScript.Shell").Run "${cmd}", 0, True\r\n`;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function windowsCreateArgs(s: ScheduleSpec): string[] {
|
|
48
|
+
const vbs = join(s.home, "tick.vbs");
|
|
49
|
+
const tr = `wscript.exe //B //Nologo ${q(vbs)}`;
|
|
50
|
+
return ["/Create", "/TN", TASK_NAME, "/SC", "MINUTE", "/MO", String(s.everyMin ?? 5), "/TR", tr, "/F"];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function plistContent(s: ScheduleSpec): string {
|
|
54
|
+
const secs = (s.everyMin ?? 5) * 60;
|
|
55
|
+
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
56
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
57
|
+
<plist version="1.0"><dict>
|
|
58
|
+
<key>Label</key><string>${LAUNCHD_LABEL}</string>
|
|
59
|
+
<key>ProgramArguments</key><array><string>${s.node}</string><string>${s.tickScript}</string></array>
|
|
60
|
+
<key>StartInterval</key><integer>${secs}</integer>
|
|
61
|
+
<key>RunAtLoad</key><true/>
|
|
62
|
+
<key>StandardErrorPath</key><string>${join(s.home, "tick.log")}</string>
|
|
63
|
+
</dict></plist>
|
|
64
|
+
`;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function cronLine(s: ScheduleSpec): string {
|
|
68
|
+
return `*/${s.everyMin ?? 5} * * * * ${q(s.node)} ${q(s.tickScript)} >> ${q(join(s.home, "tick.log"))} 2>&1 ${CRON_MARK}`;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const plistPath = (s: ScheduleSpec) =>
|
|
72
|
+
join(s.launchAgentsDir ?? join(homedir(), "Library", "LaunchAgents"), `${LAUNCHD_LABEL}.plist`);
|
|
73
|
+
|
|
74
|
+
export interface ScheduleResult {
|
|
75
|
+
ok: boolean;
|
|
76
|
+
detail: string;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export async function installSchedule(exec: Exec, s: ScheduleSpec): Promise<ScheduleResult> {
|
|
80
|
+
mkdirSync(s.home, { recursive: true });
|
|
81
|
+
if (s.platform === "win32") {
|
|
82
|
+
writeFileSync(join(s.home, "tick.vbs"), vbsContent(s));
|
|
83
|
+
const r = await exec("schtasks", windowsCreateArgs(s), { timeoutMs: 30_000 });
|
|
84
|
+
return { ok: r.code === 0, detail: (r.stdout + r.stderr).trim().slice(0, 300) };
|
|
85
|
+
}
|
|
86
|
+
if (s.platform === "darwin") {
|
|
87
|
+
const p = plistPath(s);
|
|
88
|
+
mkdirSync(join(p, ".."), { recursive: true });
|
|
89
|
+
writeFileSync(p, plistContent(s));
|
|
90
|
+
await exec("launchctl", ["unload", p], { timeoutMs: 15_000 });
|
|
91
|
+
const r = await exec("launchctl", ["load", "-w", p], { timeoutMs: 15_000 });
|
|
92
|
+
return { ok: r.code === 0, detail: (r.stdout + r.stderr).trim().slice(0, 300) };
|
|
93
|
+
}
|
|
94
|
+
const cur = await exec("crontab", ["-l"], { timeoutMs: 15_000 });
|
|
95
|
+
const keep = (cur.code === 0 ? cur.stdout : "").split("\n").filter((l) => l.trim() && !l.includes(CRON_MARK));
|
|
96
|
+
const r = await exec("crontab", ["-"], { input: `${[...keep, cronLine(s)].join("\n")}\n`, timeoutMs: 15_000 });
|
|
97
|
+
return { ok: r.code === 0, detail: (r.stdout + r.stderr).trim().slice(0, 300) };
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export async function removeSchedule(
|
|
101
|
+
exec: Exec,
|
|
102
|
+
s: Pick<ScheduleSpec, "platform" | "home" | "launchAgentsDir">,
|
|
103
|
+
): Promise<ScheduleResult> {
|
|
104
|
+
if (s.platform === "win32") {
|
|
105
|
+
const r = await exec("schtasks", ["/Delete", "/TN", TASK_NAME, "/F"], { timeoutMs: 30_000 });
|
|
106
|
+
rmSync(join(s.home, "tick.vbs"), { force: true });
|
|
107
|
+
// gorev zaten yoksa da "silindi" sayilir
|
|
108
|
+
return {
|
|
109
|
+
ok: r.code === 0 || /cannot find|bulunam|does not exist|not exist/i.test(r.stdout + r.stderr),
|
|
110
|
+
detail: (r.stdout + r.stderr).trim().slice(0, 300),
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
if (s.platform === "darwin") {
|
|
114
|
+
const p = plistPath(s as ScheduleSpec);
|
|
115
|
+
await exec("launchctl", ["unload", "-w", p], { timeoutMs: 15_000 });
|
|
116
|
+
rmSync(p, { force: true });
|
|
117
|
+
return { ok: true, detail: "launchd ajanı kaldırıldı" };
|
|
118
|
+
}
|
|
119
|
+
const cur = await exec("crontab", ["-l"], { timeoutMs: 15_000 });
|
|
120
|
+
if (cur.code !== 0) return { ok: true, detail: "crontab yok" };
|
|
121
|
+
const keep = cur.stdout.split("\n").filter((l) => l.trim() && !l.includes(CRON_MARK));
|
|
122
|
+
const r = await exec("crontab", ["-"], { input: keep.length ? `${keep.join("\n")}\n` : "", timeoutMs: 15_000 });
|
|
123
|
+
return { ok: r.code === 0, detail: (r.stdout + r.stderr).trim().slice(0, 300) };
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export async function scheduleInstalled(
|
|
127
|
+
exec: Exec,
|
|
128
|
+
s: Pick<ScheduleSpec, "platform" | "home" | "launchAgentsDir">,
|
|
129
|
+
): Promise<boolean> {
|
|
130
|
+
if (s.platform === "win32")
|
|
131
|
+
return (await exec("schtasks", ["/Query", "/TN", TASK_NAME], { timeoutMs: 30_000 })).code === 0;
|
|
132
|
+
if (s.platform === "darwin")
|
|
133
|
+
return (await exec("launchctl", ["list", LAUNCHD_LABEL], { timeoutMs: 15_000 })).code === 0;
|
|
134
|
+
const cur = await exec("crontab", ["-l"], { timeoutMs: 15_000 });
|
|
135
|
+
return cur.code === 0 && cur.stdout.includes(CRON_MARK);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// ---------------------------------------------------------------- bildirim (PR acilinca)
|
|
139
|
+
|
|
140
|
+
/** Yonetici gerektirmez; modul yok: Windows PowerShell 5.1 yerlesik WinRT ToastNotification. */
|
|
141
|
+
export function notifyCommand(
|
|
142
|
+
platform: NodeJS.Platform,
|
|
143
|
+
title: string,
|
|
144
|
+
body: string,
|
|
145
|
+
): { cmd: string; args: string[] } | undefined {
|
|
146
|
+
const esc = (s: string) =>
|
|
147
|
+
s
|
|
148
|
+
.replace(/[\r\n]+/g, " ")
|
|
149
|
+
.replace(/[<>&"'`$]/g, " ")
|
|
150
|
+
.slice(0, 200);
|
|
151
|
+
const t = esc(title);
|
|
152
|
+
const b = esc(body);
|
|
153
|
+
if (platform === "win32") {
|
|
154
|
+
const ps =
|
|
155
|
+
`$ErrorActionPreference='Stop';` +
|
|
156
|
+
`[void][Windows.UI.Notifications.ToastNotificationManager,Windows.UI.Notifications,ContentType=WindowsRuntime];` +
|
|
157
|
+
`[void][Windows.Data.Xml.Dom.XmlDocument,Windows.Data.Xml.Dom.XmlDocument,ContentType=WindowsRuntime];` +
|
|
158
|
+
`$x=New-Object Windows.Data.Xml.Dom.XmlDocument;` +
|
|
159
|
+
`$x.LoadXml('<toast><visual><binding template="ToastGeneric"><text>${t}</text><text>${b}</text></binding></visual></toast>');` +
|
|
160
|
+
`$n=[Windows.UI.Notifications.ToastNotification]::new($x);` +
|
|
161
|
+
`[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier('{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\\WindowsPowerShell\\v1.0\\powershell.exe').Show($n)`;
|
|
162
|
+
return {
|
|
163
|
+
cmd: "powershell.exe",
|
|
164
|
+
args: ["-NoProfile", "-NonInteractive", "-WindowStyle", "Hidden", "-Command", ps],
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
if (platform === "darwin")
|
|
168
|
+
return { cmd: "osascript", args: ["-e", `display notification "${b}" with title "${t}"`] };
|
|
169
|
+
return { cmd: "notify-send", args: [t, b] };
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export async function notifyPr(exec: Exec, platform: NodeJS.Platform, repo: string, pr: string): Promise<boolean> {
|
|
173
|
+
const c = notifyCommand(platform, "Sera bir değişiklik hazırladı", `${repo}: ${pr}`);
|
|
174
|
+
if (!c) return false;
|
|
175
|
+
try {
|
|
176
|
+
return (await exec(c.cmd, c.args, { timeoutMs: 20_000 })).code === 0;
|
|
177
|
+
} catch {
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
}
|