sera-code 0.0.0-stage → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/NOTICE-SERA.md +33 -0
- package/README.md +27 -2
- package/THIRD_PARTY_NOTICES.md +68 -0
- package/bin/sera.mjs +145 -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-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-AZC5WTED.js +1222 -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-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-LOMPDCMP.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-Z2V3PTLI.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 +377 -0
- package/lib/provider.js +71 -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 +2410 -0
- package/sera-core/src/fs-tools.ts +448 -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/model-list.ts +108 -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 +476 -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 +121 -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,808 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Komut / yol politikasi (saf, I/O yok; web ile ayni kurallar): bir arac cagrisini "guvenli" (sormadan
|
|
3
|
+
* calistir), "sor" (kullaniciya sor) ya da "engelle" (hic calistirma) olarak siniflandirir.
|
|
4
|
+
*
|
|
5
|
+
* Ilke: sifir bilgili kullanici zararsiz okuma komutlari icin soru gormez; geri donusu olmayan komutlar
|
|
6
|
+
* hic calismaz; arada kalan her sey sade Turkce bir soruyla sorulur. Emin olunamayan her durum "sor"dur.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export type Verdict = "safe" | "ask" | "deny";
|
|
10
|
+
|
|
11
|
+
export interface Decision {
|
|
12
|
+
verdict: Verdict;
|
|
13
|
+
/** Kullaniciya/modele gosterilen sade Turkce aciklama (ask/deny icin). */
|
|
14
|
+
reason?: string;
|
|
15
|
+
/** "Hep izin ver" icin desen (ask icin): ayni desene uyan sonraki komutlar sorulmaz. */
|
|
16
|
+
pattern?: string;
|
|
17
|
+
/** true: "hep izin ver" bu cagriyi KAPSAMAZ (korumali yol, tehlikeli komut). */
|
|
18
|
+
sticky?: boolean;
|
|
19
|
+
/** true: komut verileri bilgisayardan DISARI gonderir (DISARI GONDERIM kategorisi; her zaman sticky). */
|
|
20
|
+
egress?: boolean;
|
|
21
|
+
/** egress icin hedef (uzak depo/alan adi), sade metin; kimlik bilgisi icermez. */
|
|
22
|
+
target?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface PolicyOptions {
|
|
26
|
+
/** git uzak adini (origin) gercek adrese cevirir (G/C yapan katman verir; bu dosya saf kalir). */
|
|
27
|
+
resolveRemote?: (name: string) => string | undefined;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Yalniz okuyan, yan etkisiz komutlar (ilk kelime). */
|
|
31
|
+
const READ_ONLY = new Set([
|
|
32
|
+
"ls",
|
|
33
|
+
"dir",
|
|
34
|
+
"cat",
|
|
35
|
+
"type",
|
|
36
|
+
"head",
|
|
37
|
+
"tail",
|
|
38
|
+
"less",
|
|
39
|
+
"more",
|
|
40
|
+
"pwd",
|
|
41
|
+
"echo",
|
|
42
|
+
"printf",
|
|
43
|
+
"wc",
|
|
44
|
+
"which",
|
|
45
|
+
"where",
|
|
46
|
+
"whoami",
|
|
47
|
+
"date",
|
|
48
|
+
"rg",
|
|
49
|
+
"grep",
|
|
50
|
+
"egrep",
|
|
51
|
+
"fgrep",
|
|
52
|
+
"tree",
|
|
53
|
+
"stat",
|
|
54
|
+
"file",
|
|
55
|
+
"du",
|
|
56
|
+
"df",
|
|
57
|
+
"env",
|
|
58
|
+
"printenv",
|
|
59
|
+
"basename",
|
|
60
|
+
"dirname",
|
|
61
|
+
"realpath",
|
|
62
|
+
"sort",
|
|
63
|
+
"uniq",
|
|
64
|
+
"cut",
|
|
65
|
+
"diff",
|
|
66
|
+
"cmp",
|
|
67
|
+
"md5sum",
|
|
68
|
+
"sha256sum",
|
|
69
|
+
"true",
|
|
70
|
+
"Get-ChildItem",
|
|
71
|
+
"Get-Content",
|
|
72
|
+
"Get-Location",
|
|
73
|
+
"Select-String",
|
|
74
|
+
"Get-Item",
|
|
75
|
+
"Test-Path",
|
|
76
|
+
]);
|
|
77
|
+
|
|
78
|
+
/** git'in salt-okunur alt komutlari. */
|
|
79
|
+
const GIT_READ = new Set([
|
|
80
|
+
"status",
|
|
81
|
+
"diff",
|
|
82
|
+
"log",
|
|
83
|
+
"show",
|
|
84
|
+
"branch",
|
|
85
|
+
"remote",
|
|
86
|
+
"rev-parse",
|
|
87
|
+
"ls-files",
|
|
88
|
+
"blame",
|
|
89
|
+
"describe",
|
|
90
|
+
"tag",
|
|
91
|
+
]);
|
|
92
|
+
|
|
93
|
+
/** Geri donusu olmayan / sistemi bozan komutlar: hic calistirilmaz. */
|
|
94
|
+
const DENY: Array<[RegExp, string]> = [
|
|
95
|
+
[
|
|
96
|
+
/\brm\s+(-[a-zA-Z]*\s+)*-[a-zA-Z]*[rR][a-zA-Z]*\s+(-[a-zA-Z]*\s+)*(\/|~|\$HOME|\*|\.\/?\*?|\.\.)(\s|$)/,
|
|
97
|
+
"Bu komut tüm klasörü ya da sistemi silebilir; Sera bunu çalıştırmaz.",
|
|
98
|
+
],
|
|
99
|
+
[/\b(mkfs(\.\w+)?|format\s+[a-zA-Z]:|diskpart)\b/, "Bu komut diski biçimlendirir; Sera bunu çalıştırmaz."],
|
|
100
|
+
[/\bdd\b[^|;&]*\bof=\/dev\//, "Bu komut diske doğrudan yazar; Sera bunu çalıştırmaz."],
|
|
101
|
+
[/:\(\)\s*\{\s*:\|:&\s*\};:/, "Bu komut bilgisayarı kilitler; Sera bunu çalıştırmaz."],
|
|
102
|
+
[
|
|
103
|
+
/\b(curl|wget|iwr|Invoke-WebRequest)\b[^|]*\|\s*(sudo\s+)?(sh|bash|zsh|iex|Invoke-Expression|python\d?|node)\b/,
|
|
104
|
+
"İnternetten indirilen kodu doğrudan çalıştırır; Sera bunu çalıştırmaz.",
|
|
105
|
+
],
|
|
106
|
+
[
|
|
107
|
+
/\b(shutdown|reboot|halt|poweroff)\b/,
|
|
108
|
+
"Bu komut bilgisayarı kapatır ya da yeniden başlatır; Sera bunu çalıştırmaz.",
|
|
109
|
+
],
|
|
110
|
+
[
|
|
111
|
+
/\bRemove-Item\b[^|;&]*-Recurse[^|;&]*\s(\/|[a-zA-Z]:\\?|~|\$HOME|\$env:USERPROFILE)(\s|$)/i,
|
|
112
|
+
"Bu komut tüm sürücüyü ya da kullanıcı klasörünü silebilir; Sera bunu çalıştırmaz.",
|
|
113
|
+
],
|
|
114
|
+
[/\bchmod\s+(-R\s+)?[0-7]*777\s+\/(\s|$)/, "Bu komut tüm sistemin izinlerini açar; Sera bunu çalıştırmaz."],
|
|
115
|
+
];
|
|
116
|
+
|
|
117
|
+
/** Her seferinde sorulmasi gereken riskli komutlar ("hep izin ver" kapsamaz). */
|
|
118
|
+
const STICKY_ASK: Array<[RegExp, string]> = [
|
|
119
|
+
[
|
|
120
|
+
/\bgit\s+push\b[^|;&]*(\s--force\b|\s-f\b|\s--force-with-lease\b|\s\+\S)/,
|
|
121
|
+
"Uzak depodaki geçmişi zorla değiştirir; başkalarının işi kaybolabilir.",
|
|
122
|
+
],
|
|
123
|
+
[
|
|
124
|
+
/\bgit\s+(reset\s+--hard|clean\s+-[a-zA-Z]*f|checkout\s+--\s|restore\s+\.)/,
|
|
125
|
+
"Kaydedilmemiş değişiklikleri geri dönüşsüz siler.",
|
|
126
|
+
],
|
|
127
|
+
[/\brm\s+(-[a-zA-Z]*\s+)*-[a-zA-Z]*[rR]/, "Klasörleri ve içindekileri kalıcı olarak siler."],
|
|
128
|
+
[/\bRemove-Item\b[^|;&]*-Recurse/i, "Klasörleri ve içindekileri kalıcı olarak siler."],
|
|
129
|
+
[/\b(sudo|runas)\b/, "Yönetici yetkisiyle çalışır."],
|
|
130
|
+
[/\b(DROP\s+(TABLE|DATABASE)|TRUNCATE\s+TABLE)\b/i, "Veritabanındaki verileri kalıcı olarak siler."],
|
|
131
|
+
];
|
|
132
|
+
|
|
133
|
+
/** Yazilmasi korumali yollar: her yazma sorulur, "hep izin ver" kapsamaz; bazilari hic yazilmaz. */
|
|
134
|
+
const PATH_DENY: Array<[RegExp, string]> = [
|
|
135
|
+
[/(^|[\\/])\.git[\\/]/, "Git'in iç dosyalarına doğrudan yazmak depoyu bozar; Sera bunu yapmaz."],
|
|
136
|
+
[
|
|
137
|
+
/(^|[\\/])\.ssh[\\/]|(^|[\\/])id_(rsa|ed25519|ecdsa)(\.pub)?$/,
|
|
138
|
+
"SSH anahtarlarına yazmak güvenlik riskidir; Sera bunu yapmaz.",
|
|
139
|
+
],
|
|
140
|
+
];
|
|
141
|
+
const PATH_STICKY: Array<[RegExp, string]> = [
|
|
142
|
+
[/(^|[\\/])\.env(\.[\w.-]+)?$/, "Gizli anahtarların bulunduğu .env dosyasını değiştirir."],
|
|
143
|
+
[
|
|
144
|
+
/(^|[\\/])(\.sera[\\/]settings\.json|sera-code[\\/][^\\/]*\.jsonc?)$/i,
|
|
145
|
+
"Sera'nın izin ve güvenlik ayarlarını değiştirir.",
|
|
146
|
+
],
|
|
147
|
+
[/\.(pem|key|p12|pfx|keystore|jks)$/i, "Sertifika ya da anahtar dosyasını değiştirir."],
|
|
148
|
+
[/(^|[\\/])(credentials|secrets?)(\.[\w]+)?$/i, "Gizli bilgi dosyasını değiştirir."],
|
|
149
|
+
];
|
|
150
|
+
|
|
151
|
+
/** Kabuk komutunu ust duzey parcalara ayirir; ayrilamayan/gizli calistirma iceriyorsa undefined. */
|
|
152
|
+
export function segments(cmd: string): string[] | undefined {
|
|
153
|
+
if (/\$\(|`|<\(|>\(/.test(cmd)) return undefined; // komut ikamesi: icerigi gorulemez
|
|
154
|
+
// Tek `&` (arka plan) de ayiricidir: "ls & curl -X POST ..." eskiden tek parca sayilip zararsiz cikiyordu
|
|
155
|
+
// (Fable incelemesi 2026-11-12, YUKSEK). Yonlendirmeler (2>&1, >&2, &>) korunur.
|
|
156
|
+
const FD = "\u0000";
|
|
157
|
+
const AMP = "\u0001";
|
|
158
|
+
return cmd
|
|
159
|
+
.replace(/(\d*)>&(\d+|-)/g, `$1>${FD}$2`)
|
|
160
|
+
.replace(/&>/g, `${AMP}>`)
|
|
161
|
+
.split(/&&|\|\||[;|&\n]/)
|
|
162
|
+
.map((s) => s.replaceAll(FD, "&").replaceAll(AMP, "&").trim())
|
|
163
|
+
.filter(Boolean);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export function words(seg: string): string[] {
|
|
167
|
+
return seg.match(/"[^"]*"|'[^']*'|\S+/g) ?? [];
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// path-guard.ts ile ayni desenler (bu dosya bagimliliksiz kalmali: web'e birebir kopyalanir).
|
|
171
|
+
const SENSITIVE_DIR_ARG = /(^|\/)\.(ssh|aws|gnupg|kube|azure|config\/gcloud|docker)(\/|$)/i;
|
|
172
|
+
const SENSITIVE_FILE_ARG =
|
|
173
|
+
/(^|\/)(\.env(\.(?!example$|sample$|template$)[^/]*)?|id_(rsa|dsa|ecdsa|ed25519)(\.pub)?|\.netrc|\.npmrc|\.pypirc|\.git-credentials|credentials(\.json)?|secrets?\.(json|ya?ml)|[^/]*\.(pem|key|pfx|p12|kdbx)|login data|cookies)$/i;
|
|
174
|
+
function sensitiveArg(word: string): boolean {
|
|
175
|
+
const p = word
|
|
176
|
+
.replace(/^["']|["']$/g, "")
|
|
177
|
+
.replace(/^@/, "")
|
|
178
|
+
.replaceAll("\\", "/");
|
|
179
|
+
return SENSITIVE_DIR_ARG.test(p) || SENSITIVE_FILE_ARG.test(p);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** Bir parca yalniz okuyor mu (yonlendirme yok, salt-okunur komut). */
|
|
183
|
+
function readOnlySegment(seg: string): boolean {
|
|
184
|
+
if (/(^|[^0-9&])>{1,2}(?!&)/.test(seg.replace(/\d?>\s*\/dev\/null|2>&1|\d?>\s*\$null/g, ""))) return false;
|
|
185
|
+
const w = words(seg);
|
|
186
|
+
const first = (w[0] ?? "").replace(/^\.\//, "");
|
|
187
|
+
// Duyarli dosya/dizin okuyan kabuk komutu (cat ~/.ssh/id_rsa, type .env) zararsiz degil: sorulur
|
|
188
|
+
// (Fable 2026-11-12 ORTA 8; tek & acigiyla birlesince sorusuz sizdirma yoluydu).
|
|
189
|
+
if (w.slice(1).some((x) => sensitiveArg(x))) return false;
|
|
190
|
+
// Dosyaya yazan secenek her komutta (git diff --output= dahil) zararsiz degil (Fable 2026-11-12).
|
|
191
|
+
if (w.some((x) => /^--output(=|$)/.test(x))) return false;
|
|
192
|
+
if (first === "git") {
|
|
193
|
+
const sub = w.find((x, i) => i > 0 && !x.startsWith("-"));
|
|
194
|
+
if (!sub || !GIT_READ.has(sub)) return false;
|
|
195
|
+
if (sub === "branch" && w.some((x) => /^-(d|D|m|M|c|C)$|^--(delete|move|copy)$/.test(x))) return false;
|
|
196
|
+
if (sub === "tag" && w.length > 2 && !w.includes("-l") && !w.includes("--list")) return false;
|
|
197
|
+
if (sub === "remote" && w.some((x) => /^(add|remove|rm|rename|set-url)$/.test(x))) return false;
|
|
198
|
+
return true;
|
|
199
|
+
}
|
|
200
|
+
if (first === "find") return !w.some((x) => /^-(exec|execdir|delete|ok|okdir|fprint\w*)$/.test(x));
|
|
201
|
+
if (first === "sort" && w.some((x) => /^-[a-zA-Z]*o/.test(x))) return false;
|
|
202
|
+
// env yalniz argumansiz okur; "env FOO=1 node x.js" bir program calistirir. printenv yalniz degisken adi alir.
|
|
203
|
+
if (first === "env") return w.length === 1;
|
|
204
|
+
if (first === "printenv") return w.slice(1).every((x) => /^\w+$/.test(x));
|
|
205
|
+
if (first === "sed")
|
|
206
|
+
return (
|
|
207
|
+
!w.some((x) => /^-i|^--in-place/.test(x)) &&
|
|
208
|
+
// sed betigindeki w/W (dosyaya yaz) ve e (komut calistir) komutlari
|
|
209
|
+
!w.slice(1).some((x) => /(^|[;{}\s'"/])[wWe](\s|$)|\/[a-zA-Z0-9]*[wWe]\s/.test(x))
|
|
210
|
+
);
|
|
211
|
+
if (/^(node|python\d?|bun|npm|pnpm|yarn|cargo|go|deno)$/.test(first))
|
|
212
|
+
return w.length === 2 && /^(-v|--version|-V|version)$/.test(w[1] ?? "");
|
|
213
|
+
return READ_ONLY.has(first);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** Alt komutu olan araclar: desen "arac altkomut" olur (npm test izni npm install'a gecmez). */
|
|
217
|
+
const SUBCOMMAND_TOOLS = new Set([
|
|
218
|
+
"npm",
|
|
219
|
+
"pnpm",
|
|
220
|
+
"yarn",
|
|
221
|
+
"bun",
|
|
222
|
+
"npx",
|
|
223
|
+
"bunx",
|
|
224
|
+
"git",
|
|
225
|
+
"gh",
|
|
226
|
+
"cargo",
|
|
227
|
+
"go",
|
|
228
|
+
"deno",
|
|
229
|
+
"docker",
|
|
230
|
+
"kubectl",
|
|
231
|
+
"pip",
|
|
232
|
+
"pip3",
|
|
233
|
+
"uv",
|
|
234
|
+
"poetry",
|
|
235
|
+
"dotnet",
|
|
236
|
+
"make",
|
|
237
|
+
"mvn",
|
|
238
|
+
"gradle",
|
|
239
|
+
]);
|
|
240
|
+
|
|
241
|
+
/** "Hep izin ver" deseni: alt komutlu araclarda "arac altkomut" (npm test, git commit), digerlerinde ilk kelime (echo, python). */
|
|
242
|
+
export function commandPattern(cmd: string): string {
|
|
243
|
+
const first = segments(cmd)?.[0] ?? cmd.trim();
|
|
244
|
+
const w = words(first);
|
|
245
|
+
const tool = w[0] ?? "";
|
|
246
|
+
const sub = SUBCOMMAND_TOOLS.has(tool) && w[1] && !w[1].startsWith("-") && /^[\w:.-]+$/.test(w[1]) ? ` ${w[1]}` : "";
|
|
247
|
+
return `${tool}${sub}`;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/** Desen tum parcalari kapsiyor mu (zincirleme komutta her parca ayni desene uymali). */
|
|
251
|
+
export function patternCovers(pattern: string, cmd: string): boolean {
|
|
252
|
+
const segs = segments(cmd);
|
|
253
|
+
if (!segs) return false;
|
|
254
|
+
// Fable #12: hassas yola yonlendirme ("echo x >> ~/.ssh/authorized_keys") "hep izin ver" kapsamina girmez;
|
|
255
|
+
// hedef, edit/write ile ayni yol kapisindan (classifyWrite) gecer: deny/sticky ise her seferinde sorulur.
|
|
256
|
+
// Tirnakli / degiskenli / mutlak ya da ust dizine cikan hedef cozulemez → kapsanmaz (fail-closed).
|
|
257
|
+
const risky = (t: string): boolean => {
|
|
258
|
+
if (/['"$`%]|(^|[\\/])\.\.([\\/]|$)|^([a-z]:)?[\\/]/i.test(t)) return true;
|
|
259
|
+
const d = classifyWrite(t);
|
|
260
|
+
return d.verdict === "deny" || !!d.sticky;
|
|
261
|
+
};
|
|
262
|
+
if (segs.some((s) => redirectTargets(s).some(risky))) return false;
|
|
263
|
+
return segs.every((s) => s === pattern || s.startsWith(`${pattern} `));
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/** Parcadaki dosyaya cikis yonlendirme hedefleri (tirnak ici sayilmaz; 2>&1 ve /dev/null, NUL, $null atlanir). */
|
|
267
|
+
export function redirectTargets(seg: string): string[] {
|
|
268
|
+
const bare = seg.replace(/'[^']*'|"(?:\\.|[^"\\])*"/g, "''");
|
|
269
|
+
const re = /(?:^|[^<>&|])(?:\d|&)?>>?\|?\s*([^\s;&|]*)/g;
|
|
270
|
+
const out: string[] = [];
|
|
271
|
+
for (let m = re.exec(bare); m; m = re.exec(bare)) {
|
|
272
|
+
const t = m[1] ?? "";
|
|
273
|
+
if (!t || t.startsWith("&")) continue;
|
|
274
|
+
if (/^(\/dev\/null|nul|\$null)$/i.test(t)) continue;
|
|
275
|
+
out.push(t.replace(/^~(?=[\\/])/, process.env.HOME || process.env.USERPROFILE || "~"));
|
|
276
|
+
}
|
|
277
|
+
return out;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// ---------------------------------------------------------------------------------------------
|
|
281
|
+
// DISARI GONDERIM (egress): verilerin bilgisayardan cikabilecegi her komut "sor" + sticky olur.
|
|
282
|
+
// "Hep izin ver" bunu KAPSAMAZ; her seferinde hedefiyle birlikte sorulur. Emin olunamayan ama aga cikabilen
|
|
283
|
+
// komutlar zaten genel "sor"dur (fail-closed); burasi bilinen gonderim komutlarini ayrica isaretler.
|
|
284
|
+
// ---------------------------------------------------------------------------------------------
|
|
285
|
+
|
|
286
|
+
interface EgressHit {
|
|
287
|
+
what: string;
|
|
288
|
+
target: string;
|
|
289
|
+
extra?: string;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
const unq = (s: string): string => s.replace(/^["']|["']$/g, "");
|
|
293
|
+
|
|
294
|
+
/** Komut adi: yol ve .exe/.cmd/.ps1 uzantisi atilir, kucuk harf. */
|
|
295
|
+
function cmdName(tok: string | undefined): string {
|
|
296
|
+
return unq(tok ?? "")
|
|
297
|
+
.replace(/^.*[\\/]/, "")
|
|
298
|
+
.replace(/\.(exe|cmd|bat|ps1)$/i, "")
|
|
299
|
+
.toLowerCase();
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/** Adresi sade "alan-adi/yol" haline getirir; kimlik bilgisi (kullanici:parola@) ve sorgu dizesi atilir. */
|
|
303
|
+
export function hostPath(u: string): string {
|
|
304
|
+
let s = unq(u.trim());
|
|
305
|
+
s = s.replace(/^[a-z][a-z0-9+.-]*:\/\//i, "");
|
|
306
|
+
s = s.replace(/^[^@/]*@/, "");
|
|
307
|
+
s = s.replace(/^([^/:]+):(?!\d+(\/|$))(?=[^/])/, "$1/"); // git@host:owner/repo -> host/owner/repo
|
|
308
|
+
s = s.split(/[?#]/)[0] ?? s;
|
|
309
|
+
return s.replace(/\/+$/, "");
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
const LOOPBACK = /^(localhost|127\.\d+\.\d+\.\d+|\[?::1\]?|0\.0\.0\.0)(:\d+)?(\/|$)/i;
|
|
313
|
+
|
|
314
|
+
const SHELL_WRAPPERS = new Set([
|
|
315
|
+
"sudo",
|
|
316
|
+
"env",
|
|
317
|
+
"time",
|
|
318
|
+
"nohup",
|
|
319
|
+
"nice",
|
|
320
|
+
"command",
|
|
321
|
+
"exec",
|
|
322
|
+
"xargs",
|
|
323
|
+
"timeout",
|
|
324
|
+
"doas",
|
|
325
|
+
"call",
|
|
326
|
+
]);
|
|
327
|
+
const SHELLS = new Set(["bash", "sh", "zsh", "dash", "fish", "pwsh", "powershell", "cmd"]);
|
|
328
|
+
const INTERPRETERS = /^(python\d*(\.\d+)?|py|node|nodejs|bun|deno|ruby|perl|php)$/;
|
|
329
|
+
|
|
330
|
+
/** Python/Node/... tek satir kodunda aga veri gonderen kaliplar. */
|
|
331
|
+
const NET_CODE =
|
|
332
|
+
/\b(requests|httpx|session|client)\.(post|put|patch|delete|request)\s*\(|\burllib2?\.request\b|\burlopen\s*\(|\bhttp\.client\b|\bhttplib\b|\bsmtplib\b|\bftplib\b|\bparamiko\b|\bboto3\b|\bsocket\.(socket|create_connection)|\baiohttp\b|\bfetch\s*\([\s\S]{0,300}?(method\s*:\s*['"`]?(POST|PUT|PATCH|DELETE)|body\s*:)|\baxios\.(post|put|patch|delete|request)|\bXMLHttpRequest\b|\bnew\s+WebSocket\b|\b(https?|net|tls)\.(request|connect|createConnection)\s*\(|\bnet\.Socket\b|\bUpload(String|File|Data|Values)\b|\bnet\/http\b|\bhttp\.Post\b|\bNet::HTTP\b|\bcurl_exec\b/i;
|
|
333
|
+
|
|
334
|
+
const PS_WEB = new Set(["iwr", "irm", "invoke-webrequest", "invoke-restmethod"]);
|
|
335
|
+
const WRITE_METHODS = /^(post|put|patch|delete)$/i;
|
|
336
|
+
|
|
337
|
+
function positionals(w: string[], from: number, valueFlags: ReadonlySet<string> = new Set()): string[] {
|
|
338
|
+
const out: string[] = [];
|
|
339
|
+
for (let i = from; i < w.length; i++) {
|
|
340
|
+
const t = unq(w[i] ?? "");
|
|
341
|
+
if (valueFlags.has(t)) {
|
|
342
|
+
i++;
|
|
343
|
+
continue;
|
|
344
|
+
}
|
|
345
|
+
if (t.startsWith("-")) continue;
|
|
346
|
+
out.push(t);
|
|
347
|
+
}
|
|
348
|
+
return out;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
function firstUrl(w: string[]): string | undefined {
|
|
352
|
+
for (let i = 1; i < w.length; i++) {
|
|
353
|
+
const t = unq(w[i] ?? "");
|
|
354
|
+
if (/^(https?|ftps?|sftp|s3|gs):\/\//i.test(t)) return t;
|
|
355
|
+
if (/^-uri$/i.test(t) && w[i + 1]) return unq(w[i + 1] ?? "");
|
|
356
|
+
}
|
|
357
|
+
for (let i = 1; i < w.length; i++) {
|
|
358
|
+
const t = unq(w[i] ?? "");
|
|
359
|
+
if (!t.startsWith("-") && /^[\w.-]+\.[a-z]{2,}(:\d+)?(\/|$)/i.test(t)) return t;
|
|
360
|
+
}
|
|
361
|
+
return undefined;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
const SCP_REMOTE = /^(?:[\w.-]+@)?(?:\[[\w:]+\]|[\w.-]{2,}):(?![\\/]{2})|^(rsync|ssh|sftp|scp):\/\//i;
|
|
365
|
+
|
|
366
|
+
function gitEgress(w: string[], opts: PolicyOptions): EgressHit | undefined {
|
|
367
|
+
let i = 1;
|
|
368
|
+
while (i < w.length) {
|
|
369
|
+
const t = unq(w[i] ?? "");
|
|
370
|
+
if (/^(-C|-c|--git-dir|--work-tree|--namespace|--exec-path)$/.test(t)) i += 2;
|
|
371
|
+
else if (t.startsWith("-")) i++;
|
|
372
|
+
else break;
|
|
373
|
+
}
|
|
374
|
+
const sub = unq(w[i] ?? "");
|
|
375
|
+
const rest = w.slice(i + 1).map(unq);
|
|
376
|
+
if (sub === "send-email") return { what: "git send-email", target: "e-posta sunucusu (SMTP)" };
|
|
377
|
+
const isPush =
|
|
378
|
+
sub === "push" ||
|
|
379
|
+
(sub === "lfs" && rest[0] === "push") ||
|
|
380
|
+
(sub === "svn" && rest[0] === "dcommit") ||
|
|
381
|
+
(sub === "subtree" && rest[0] === "push");
|
|
382
|
+
if (!isPush) return undefined;
|
|
383
|
+
const repoFlag = rest.find((x) => x.startsWith("--repo="))?.slice(7);
|
|
384
|
+
const pos = rest.filter((x) => !x.startsWith("-")).slice(sub === "push" ? 0 : 1);
|
|
385
|
+
const remote = repoFlag ?? pos[0];
|
|
386
|
+
let target: string;
|
|
387
|
+
if (remote && /:\/\/|@|\./.test(remote)) target = hostPath(remote);
|
|
388
|
+
else {
|
|
389
|
+
const url = opts.resolveRemote?.(remote ?? "");
|
|
390
|
+
const name = remote ?? "varsayılan uzak depo";
|
|
391
|
+
target = url ? hostPath(url) : name;
|
|
392
|
+
}
|
|
393
|
+
const force = rest.some((x) => /^(--force|-f|--force-with-lease(=.*)?)$/.test(x) || /^\+\S/.test(x));
|
|
394
|
+
return {
|
|
395
|
+
what: `git ${sub}`,
|
|
396
|
+
target,
|
|
397
|
+
extra: force ? "Ayrıca uzak depodaki geçmişi zorla değiştirir; başkalarının işi kaybolabilir." : undefined,
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
const GH_WRITE_VERBS =
|
|
402
|
+
/^(create|upload|comment|merge|edit|close|reopen|delete|fork|sync|run|set|review|ready|transfer|rename|archive|rerun|cancel|enable|disable|import|add|remove|publish)$/;
|
|
403
|
+
const GH_GROUPS = /^(pr|issue|repo|gist|release|workflow|secret|variable|label|project|ruleset|run|cache|codespace)$/;
|
|
404
|
+
|
|
405
|
+
function ghEgress(w: string[]): EgressHit | undefined {
|
|
406
|
+
const t = w.map(unq);
|
|
407
|
+
const ri = t.findIndex((x) => x === "-R" || x === "--repo");
|
|
408
|
+
const repo = ri >= 0 ? t[ri + 1] : t.find((x) => x.startsWith("--repo="))?.slice(7);
|
|
409
|
+
const target = `github.com${repo ? `/${repo}` : ""}`;
|
|
410
|
+
const pos = positionals(t, 1, new Set(["-R", "--repo"]));
|
|
411
|
+
if (pos[0] === "api") {
|
|
412
|
+
const mi = t.findIndex((x) => x === "-X" || x === "--method");
|
|
413
|
+
const method =
|
|
414
|
+
(mi >= 0 ? t[mi + 1] : t.find((x) => /^(-X|--method=)/.test(x))?.replace(/^(-X|--method=)/, "")) ?? "";
|
|
415
|
+
const sends = t.some((x) => /^(-f|-F|--field|--raw-field|--input)(=|$)/.test(x) || /^-[fF]\S/.test(x));
|
|
416
|
+
if ((method && method.toUpperCase() !== "GET") || sends) {
|
|
417
|
+
return {
|
|
418
|
+
what: `gh api ${method ? method.toUpperCase() : "POST"}`,
|
|
419
|
+
target: `github.com/${pos[1] ?? ""}`.replace(/\/$/, ""),
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
return undefined;
|
|
423
|
+
}
|
|
424
|
+
if (pos[0] && pos[1] && GH_GROUPS.test(pos[0]) && GH_WRITE_VERBS.test(pos[1])) {
|
|
425
|
+
return { what: `gh ${pos[0]} ${pos[1]}`, target };
|
|
426
|
+
}
|
|
427
|
+
return undefined;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
function curlEgress(name: string, w: string[]): EgressHit | undefined {
|
|
431
|
+
const t = w.map(unq);
|
|
432
|
+
let sends = false;
|
|
433
|
+
for (let i = 1; i < t.length && !sends; i++) {
|
|
434
|
+
const a = t[i] ?? "";
|
|
435
|
+
const next = t[i + 1] ?? "";
|
|
436
|
+
if (/^-(Method|Body|InFile|Form)(:.*)?$/i.test(a)) {
|
|
437
|
+
if (/^-Method/i.test(a)) {
|
|
438
|
+
const v = a.includes(":") ? a.slice(a.indexOf(":") + 1) : next;
|
|
439
|
+
if (WRITE_METHODS.test(v)) sends = true;
|
|
440
|
+
} else sends = true;
|
|
441
|
+
} else if (
|
|
442
|
+
/^--(data|data-[\w-]+|form|form-string|upload-file|json|post-data|post-file|body-data|body-file)(=|$)/.test(a)
|
|
443
|
+
)
|
|
444
|
+
sends = true;
|
|
445
|
+
else if (/^--(request|method)(=|$)/.test(a)) {
|
|
446
|
+
const v = a.includes("=") ? a.slice(a.indexOf("=") + 1) : next;
|
|
447
|
+
if (WRITE_METHODS.test(v)) sends = true;
|
|
448
|
+
} else if (/^-X./.test(a) && WRITE_METHODS.test(a.slice(2))) sends = true;
|
|
449
|
+
else if (a === "-X" && WRITE_METHODS.test(next)) sends = true;
|
|
450
|
+
else if (!PS_WEB.has(name) && /^-[a-zA-Z]{1,6}$/.test(a)) {
|
|
451
|
+
for (const ch of a.slice(1)) {
|
|
452
|
+
if ("dFT".includes(ch)) {
|
|
453
|
+
sends = true;
|
|
454
|
+
break;
|
|
455
|
+
}
|
|
456
|
+
if ("oHAuebcmxwKEyYzQrCDUtX".includes(ch)) break; // sonraki karakterler bu secenegin degeri
|
|
457
|
+
}
|
|
458
|
+
} else if (/^-[dFT]./.test(a) && !PS_WEB.has(name)) sends = true;
|
|
459
|
+
}
|
|
460
|
+
if (!sends) return undefined;
|
|
461
|
+
const url = firstUrl(t);
|
|
462
|
+
const target = url ? hostPath(url) : "(adres komutta görünmüyor)";
|
|
463
|
+
if (url && LOOPBACK.test(target)) return undefined; // kendi bilgisayarina gonderim: disari cikmaz
|
|
464
|
+
return { what: name, target };
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
function sshEgress(w: string[], seg: string, piped: boolean): EgressHit | undefined {
|
|
468
|
+
const t = w.map(unq);
|
|
469
|
+
const valueFlags = new Set([
|
|
470
|
+
"-p",
|
|
471
|
+
"-i",
|
|
472
|
+
"-l",
|
|
473
|
+
"-o",
|
|
474
|
+
"-F",
|
|
475
|
+
"-J",
|
|
476
|
+
"-b",
|
|
477
|
+
"-c",
|
|
478
|
+
"-e",
|
|
479
|
+
"-E",
|
|
480
|
+
"-I",
|
|
481
|
+
"-m",
|
|
482
|
+
"-O",
|
|
483
|
+
"-Q",
|
|
484
|
+
"-S",
|
|
485
|
+
"-B",
|
|
486
|
+
"-L",
|
|
487
|
+
"-R",
|
|
488
|
+
"-D",
|
|
489
|
+
"-W",
|
|
490
|
+
"-w",
|
|
491
|
+
]);
|
|
492
|
+
const pos = positionals(t, 1, valueFlags);
|
|
493
|
+
const host = pos[0] ?? "(sunucu)";
|
|
494
|
+
const remoteCmd = pos.slice(1).join(" ");
|
|
495
|
+
const tunnel = t.some((x) => /^-[LRDW]/.test(x));
|
|
496
|
+
const stdin = piped || /(^|[^<])<(?![(<])/.test(seg) || /<</.test(seg);
|
|
497
|
+
const writes =
|
|
498
|
+
remoteCmd.length > 0 && /[>]|\b(tee|dd\s+of=|cat\s*>|tar\s+\w*x|base64\s+-d|sh|bash)\b/.test(remoteCmd);
|
|
499
|
+
if (!(tunnel || stdin || writes)) return undefined;
|
|
500
|
+
return { what: tunnel ? "ssh (tünel)" : "ssh (veri aktarımı)", target: hostPath(host) };
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
function lastRemote(w: string[], re: RegExp): string | undefined {
|
|
504
|
+
const last = positionals(w.map(unq), 1).pop();
|
|
505
|
+
return last && re.test(last) ? last : undefined;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
function cloudEgress(name: string, w: string[]): EgressHit | undefined {
|
|
509
|
+
const pos = positionals(w.map(unq), 1);
|
|
510
|
+
const last = pos[pos.length - 1] ?? "";
|
|
511
|
+
if (name === "rclone") {
|
|
512
|
+
const sub = pos[0] ?? "";
|
|
513
|
+
const remote = /^[\w.-]{2,}:/.test(last);
|
|
514
|
+
if (/^(rcat|bisync)$/.test(sub) || (/^(copy|sync|move|copyto|moveto)$/.test(sub) && remote))
|
|
515
|
+
return { what: `rclone ${sub}`, target: last || "(uzak depo)" };
|
|
516
|
+
}
|
|
517
|
+
if (name === "aws") {
|
|
518
|
+
if (pos[0] === "s3" && /^(cp|mv|sync)$/.test(pos[1] ?? "") && /^s3:\/\//.test(last))
|
|
519
|
+
return { what: `aws s3 ${pos[1]}`, target: hostPath(last) };
|
|
520
|
+
if (pos[0] === "s3api" && /^(put-|upload|create-multipart)/.test(pos[1] ?? ""))
|
|
521
|
+
return { what: `aws s3api ${pos[1]}`, target: "Amazon S3" };
|
|
522
|
+
}
|
|
523
|
+
if (name === "gsutil" || (name === "gcloud" && pos[0] === "storage")) {
|
|
524
|
+
const p = name === "gcloud" ? pos.slice(1) : pos;
|
|
525
|
+
if (/^(cp|mv|rsync)$/.test(p[0] ?? "") && /^(gs|s3):\/\//.test(last))
|
|
526
|
+
return { what: `${name} ${p[0]}`, target: hostPath(last) };
|
|
527
|
+
}
|
|
528
|
+
if (name === "az" && pos[0] === "storage" && pos.some((x) => /upload|copy|sync|append|set-content/.test(x)))
|
|
529
|
+
return { what: "az storage", target: "Azure Storage" };
|
|
530
|
+
if (name === "azcopy" && /^(copy|sync|cp)$/.test(pos[0] ?? "") && /^https?:\/\//.test(last))
|
|
531
|
+
return { what: `azcopy ${pos[0]}`, target: hostPath(last) };
|
|
532
|
+
if (name === "s3cmd" && /^(put|sync|cp|mv)$/.test(pos[0] ?? ""))
|
|
533
|
+
return { what: `s3cmd ${pos[0]}`, target: "Amazon S3" };
|
|
534
|
+
return undefined;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
function publishEgress(name: string, w: string[]): EgressHit | undefined {
|
|
538
|
+
const t = w.map(unq);
|
|
539
|
+
const pos = positionals(
|
|
540
|
+
t,
|
|
541
|
+
1,
|
|
542
|
+
new Set([
|
|
543
|
+
"--registry",
|
|
544
|
+
"--cwd",
|
|
545
|
+
"-C",
|
|
546
|
+
"--prefix",
|
|
547
|
+
"-w",
|
|
548
|
+
"--workspace",
|
|
549
|
+
"--repository-url",
|
|
550
|
+
"-r",
|
|
551
|
+
"--repository",
|
|
552
|
+
"--source",
|
|
553
|
+
"-s",
|
|
554
|
+
]),
|
|
555
|
+
);
|
|
556
|
+
const sub = pos[0] ?? "";
|
|
557
|
+
const flag = (n: string): string | undefined => {
|
|
558
|
+
const i = t.indexOf(n);
|
|
559
|
+
return i >= 0 ? t[i + 1] : t.find((x) => x.startsWith(`${n}=`))?.slice(n.length + 1);
|
|
560
|
+
};
|
|
561
|
+
if (/^(npm|pnpm|yarn|bun|npx)$/.test(name)) {
|
|
562
|
+
const s = name === "yarn" && sub === "npm" ? (pos[1] ?? "") : sub;
|
|
563
|
+
const sub2 = name === "yarn" && sub === "npm" ? pos[2] : pos[1];
|
|
564
|
+
if (
|
|
565
|
+
/^(publish|unpublish|deprecate)$/.test(s) ||
|
|
566
|
+
(s === "dist-tag" && /^(add|rm)$/.test(sub2 ?? "")) ||
|
|
567
|
+
(s === "owner" && /^(add|rm)$/.test(sub2 ?? ""))
|
|
568
|
+
) {
|
|
569
|
+
const reg = flag("--registry");
|
|
570
|
+
return { what: `${name} ${s}`, target: reg ? hostPath(reg) : "registry.npmjs.org (npm)" };
|
|
571
|
+
}
|
|
572
|
+
return undefined;
|
|
573
|
+
}
|
|
574
|
+
if (name === "cargo" && sub === "publish")
|
|
575
|
+
return { what: "cargo publish", target: flag("--registry") ?? "crates.io" };
|
|
576
|
+
if (name === "twine" && sub === "upload") {
|
|
577
|
+
const url = flag("--repository-url");
|
|
578
|
+
return {
|
|
579
|
+
what: "twine upload",
|
|
580
|
+
target: url ? hostPath(url) : (flag("-r") ?? flag("--repository") ?? "PyPI (pypi.org)"),
|
|
581
|
+
};
|
|
582
|
+
}
|
|
583
|
+
if ((name === "uv" || name === "poetry" || name === "flit") && sub === "publish")
|
|
584
|
+
return { what: `${name} publish`, target: "PyPI (pypi.org)" };
|
|
585
|
+
if (name === "gem" && sub === "push") return { what: "gem push", target: "rubygems.org" };
|
|
586
|
+
if (name === "dotnet" && sub === "nuget" && pos[1] === "push")
|
|
587
|
+
return { what: "dotnet nuget push", target: flag("--source") ?? flag("-s") ?? "nuget.org" };
|
|
588
|
+
if (/^(docker|podman|nerdctl)$/.test(name)) {
|
|
589
|
+
if (sub === "push") return { what: `${name} push`, target: pos[1] ? hostPath(pos[1]) : "kayıt defteri" };
|
|
590
|
+
if (t.includes("--push") || (sub === "compose" && pos[1] === "push"))
|
|
591
|
+
return { what: `${name} ${sub}`, target: "kayıt defteri (--push)" };
|
|
592
|
+
return undefined;
|
|
593
|
+
}
|
|
594
|
+
if (name === "helm" && sub === "push")
|
|
595
|
+
return { what: "helm push", target: pos[2] ? hostPath(pos[2]) : "grafik deposu" };
|
|
596
|
+
return undefined;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
function deployEgress(name: string, w: string[]): EgressHit | undefined {
|
|
600
|
+
const pos = positionals(w.map(unq), 1);
|
|
601
|
+
const sub = pos[0] ?? "";
|
|
602
|
+
const all = pos.join(" ");
|
|
603
|
+
const hit = (target: string): EgressHit => ({ what: `${name} ${all}`.trim(), target });
|
|
604
|
+
switch (name) {
|
|
605
|
+
case "wrangler":
|
|
606
|
+
return /\b(deploy|publish|put|bulk|upload|apply)\b/.test(all) ? hit("Cloudflare") : undefined;
|
|
607
|
+
case "vercel":
|
|
608
|
+
return pos.length === 0 || /^(deploy|promote)$/.test(sub) || (sub === "env" && /^(add|rm)$/.test(pos[1] ?? ""))
|
|
609
|
+
? hit("Vercel")
|
|
610
|
+
: undefined;
|
|
611
|
+
case "netlify":
|
|
612
|
+
return /^(deploy|env:set|env:import|functions:deploy)$/.test(sub) ? hit("Netlify") : undefined;
|
|
613
|
+
case "firebase":
|
|
614
|
+
return sub === "deploy" ? hit("Firebase") : undefined;
|
|
615
|
+
case "fly":
|
|
616
|
+
case "flyctl":
|
|
617
|
+
return /^(deploy|launch)$/.test(sub) || (sub === "secrets" && pos[1] === "set") ? hit("Fly.io") : undefined;
|
|
618
|
+
case "railway":
|
|
619
|
+
return /^(up|deploy|variables)$/.test(sub) ? hit("Railway") : undefined;
|
|
620
|
+
case "supabase":
|
|
621
|
+
return /\b(push|deploy)\b/.test(all) || (sub === "secrets" && pos[1] === "set") ? hit("Supabase") : undefined;
|
|
622
|
+
case "surge":
|
|
623
|
+
case "gh-pages":
|
|
624
|
+
return hit(name);
|
|
625
|
+
case "sls":
|
|
626
|
+
case "serverless":
|
|
627
|
+
case "sam":
|
|
628
|
+
case "cdk":
|
|
629
|
+
return sub === "deploy" ? hit("bulut sağlayıcı") : undefined;
|
|
630
|
+
default:
|
|
631
|
+
return undefined;
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
/** Tek bir kabuk parcasi icin gonderim tespiti. piped: onceki komuttan boru ile veri geliyor. */
|
|
636
|
+
function egressOfSegment(seg: string, piped: boolean, opts: PolicyOptions, depth: number): EgressHit | undefined {
|
|
637
|
+
// komut ikamesi icindeki komutlar da taranir
|
|
638
|
+
for (const m of seg.matchAll(/\$\(([^)]*)\)|`([^`]*)`/g)) {
|
|
639
|
+
const r = depth < 4 ? egressOfText(m[1] ?? m[2] ?? "", opts, depth + 1) : undefined;
|
|
640
|
+
if (r) return r;
|
|
641
|
+
}
|
|
642
|
+
if (/\/dev\/(tcp|udp)\//.test(seg)) return { what: "bash /dev/tcp", target: "ağ bağlantısı (ham soket)" };
|
|
643
|
+
let w = words(seg);
|
|
644
|
+
while (w.length && (/^[A-Za-z_]\w*=/.test(w[0] ?? "") || SHELL_WRAPPERS.has(cmdName(w[0])))) {
|
|
645
|
+
const wasWrapper = SHELL_WRAPPERS.has(cmdName(w[0]));
|
|
646
|
+
w = w.slice(1);
|
|
647
|
+
if (wasWrapper) while (w.length > 1 && /^(-[\w-]+|\d+[smhd]?)$/.test(w[0] ?? "")) w = w.slice(1);
|
|
648
|
+
}
|
|
649
|
+
if (!w.length) return undefined;
|
|
650
|
+
const name = cmdName(w[0]);
|
|
651
|
+
if (SHELLS.has(name)) {
|
|
652
|
+
const i = w.findIndex((x, k) => k > 0 && /^(-c|-lc|-command|\/c)$/i.test(unq(x)));
|
|
653
|
+
if (i > 0 && depth < 4)
|
|
654
|
+
return egressOfText(
|
|
655
|
+
w
|
|
656
|
+
.slice(i + 1)
|
|
657
|
+
.map(unq)
|
|
658
|
+
.join(" "),
|
|
659
|
+
opts,
|
|
660
|
+
depth + 1,
|
|
661
|
+
);
|
|
662
|
+
return undefined;
|
|
663
|
+
}
|
|
664
|
+
if (INTERPRETERS.test(name)) {
|
|
665
|
+
if (name.startsWith("python") || name === "py") {
|
|
666
|
+
const m = w.findIndex((x) => unq(x) === "-m");
|
|
667
|
+
if (m > 0 && cmdName(w[m + 1]) === "twine") return publishEgress("twine", w.slice(m + 1));
|
|
668
|
+
}
|
|
669
|
+
const hasCode = w.some((x) => /^-(c|e|p|r|-eval)$/.test(unq(x)) || unq(x) === "eval");
|
|
670
|
+
const code = hasCode || /<</.test(seg) || w.length === 1 || unq(w[1] ?? "") === "-";
|
|
671
|
+
if (code && NET_CODE.test(seg)) {
|
|
672
|
+
const u = firstUrl(w.map(unq));
|
|
673
|
+
return { what: `${name} (kod ağa veri gönderiyor)`, target: u ? hostPath(u) : "(adres kodda)" };
|
|
674
|
+
}
|
|
675
|
+
if (!/^(bun|deno)$/.test(name)) return undefined;
|
|
676
|
+
}
|
|
677
|
+
if (name === "git") return gitEgress(w, opts);
|
|
678
|
+
if (name === "gh") return ghEgress(w);
|
|
679
|
+
if (name === "curl" || name === "wget" || PS_WEB.has(name)) return curlEgress(name, w);
|
|
680
|
+
if (name === "scp" || name === "rsync") {
|
|
681
|
+
const last = lastRemote(w, SCP_REMOTE);
|
|
682
|
+
return last ? { what: name, target: hostPath(last) } : undefined;
|
|
683
|
+
}
|
|
684
|
+
if (/^(sftp|ftp|lftp|tftp|ncftp|ncftpput)$/.test(name))
|
|
685
|
+
return { what: name, target: hostPath(positionals(w.map(unq), 1).pop() ?? "(sunucu)") };
|
|
686
|
+
if (name === "ssh") return sshEgress(w, seg, piped);
|
|
687
|
+
if (/^(nc|ncat|netcat|socat|telnet)$/.test(name))
|
|
688
|
+
return { what: name, target: positionals(w.map(unq), 1).slice(0, 2).join(":") || "(ağ bağlantısı)" };
|
|
689
|
+
if (name === "openssl" && w.some((x) => unq(x) === "s_client"))
|
|
690
|
+
return { what: "openssl s_client", target: "ağ bağlantısı" };
|
|
691
|
+
if (/^(sendmail|mail|mailx|mutt|msmtp|swaks|send-mailmessage)$/.test(name)) return { what: name, target: "e-posta" };
|
|
692
|
+
if (name === "start-bitstransfer") {
|
|
693
|
+
const u = firstUrl(w.map(unq));
|
|
694
|
+
return { what: name, target: u ? hostPath(u) : "(adres komutta görünmüyor)" };
|
|
695
|
+
}
|
|
696
|
+
return publishEgress(name, w) ?? cloudEgress(name, w) ?? deployEgress(name, w);
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
/** Tirnak disindaki && || ; satir-sonu | isaretlerinde boler (ayiraclar da dizide kalir). */
|
|
700
|
+
function splitOps(cmd: string): { parts: string[]; open: boolean } {
|
|
701
|
+
const out: string[] = [];
|
|
702
|
+
let cur = "";
|
|
703
|
+
let q = "";
|
|
704
|
+
for (let i = 0; i < cmd.length; i++) {
|
|
705
|
+
const ch = cmd[i] as string;
|
|
706
|
+
if (q) {
|
|
707
|
+
cur += ch;
|
|
708
|
+
if (ch === q) q = "";
|
|
709
|
+
continue;
|
|
710
|
+
}
|
|
711
|
+
if (ch === '"' || ch === "'") {
|
|
712
|
+
q = ch;
|
|
713
|
+
cur += ch;
|
|
714
|
+
continue;
|
|
715
|
+
}
|
|
716
|
+
const two = cmd.slice(i, i + 2);
|
|
717
|
+
if (two === "&&" || two === "||") {
|
|
718
|
+
out.push(cur, two);
|
|
719
|
+
cur = "";
|
|
720
|
+
i++;
|
|
721
|
+
} else if (ch === ";" || ch === "\n" || ch === "|") {
|
|
722
|
+
out.push(cur, ch);
|
|
723
|
+
cur = "";
|
|
724
|
+
} else cur += ch;
|
|
725
|
+
}
|
|
726
|
+
out.push(cur);
|
|
727
|
+
return { parts: out, open: q !== "" };
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
/** Komut metnini parcalar (&& || ; satir sonu | ) ve her parcayi tarar. Ilk bulunan doner. */
|
|
731
|
+
function egressOfText(cmd: string, opts: PolicyOptions, depth = 0): EgressHit | undefined {
|
|
732
|
+
const scan = (parts: string[]): EgressHit | undefined => {
|
|
733
|
+
let piped = false;
|
|
734
|
+
for (const p of parts) {
|
|
735
|
+
if (p === "|") {
|
|
736
|
+
piped = true;
|
|
737
|
+
continue;
|
|
738
|
+
}
|
|
739
|
+
if (p === "&&" || p === "||" || p === ";" || p === "\n") {
|
|
740
|
+
piped = false;
|
|
741
|
+
continue;
|
|
742
|
+
}
|
|
743
|
+
const seg = p.trim();
|
|
744
|
+
if (!seg) continue;
|
|
745
|
+
const hit = egressOfSegment(seg, piped, opts, depth);
|
|
746
|
+
if (hit) return hit;
|
|
747
|
+
piped = false;
|
|
748
|
+
}
|
|
749
|
+
return undefined;
|
|
750
|
+
};
|
|
751
|
+
const { parts, open } = splitOps(cmd);
|
|
752
|
+
const hit = scan(parts);
|
|
753
|
+
if (hit || !open) return hit;
|
|
754
|
+
// Kapanmamis tirnak: kalan metin gizlenmis olabilir -> tirnaksiz (naif) bolmeyle de tara (fail-closed).
|
|
755
|
+
return scan(cmd.split(/(&&|\|\||[;\n]|\|)/));
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
/** DISARI GONDERIM tespiti (disa acik: testler ve "dar istisna" eslemesi icin). */
|
|
759
|
+
export function detectEgress(
|
|
760
|
+
cmd: string,
|
|
761
|
+
opts: PolicyOptions = {},
|
|
762
|
+
): { what: string; target: string; reason: string } | undefined {
|
|
763
|
+
const hit = egressOfText(cmd, opts);
|
|
764
|
+
if (!hit) return undefined;
|
|
765
|
+
const reason = `Bu komut verilerini internete gönderecek: ${hit.what} → ${hit.target}. Onaylıyor musun?${hit.extra ? ` ${hit.extra}` : ""}`;
|
|
766
|
+
return { what: hit.what, target: hit.target, reason };
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
export function classifyCommand(cmd: string, opts: PolicyOptions = {}): Decision {
|
|
770
|
+
const c = cmd.trim();
|
|
771
|
+
if (!c) return { verdict: "ask", reason: "Ne çalıştıracağı belli olmayan boş bir komut." };
|
|
772
|
+
for (const [re, reason] of DENY) if (re.test(c)) return { verdict: "deny", reason };
|
|
773
|
+
// DISARI GONDERIM: her zaman sor + sticky ("hep izin ver" kapsamaz); hedef gorunur.
|
|
774
|
+
const eg = detectEgress(c, opts);
|
|
775
|
+
if (eg) return { verdict: "ask", reason: eg.reason, sticky: true, egress: true, target: eg.target };
|
|
776
|
+
for (const [re, reason] of STICKY_ASK) if (re.test(c)) return { verdict: "ask", reason, sticky: true };
|
|
777
|
+
const segs = segments(c);
|
|
778
|
+
if (segs?.every(readOnlySegment)) return { verdict: "safe" };
|
|
779
|
+
return {
|
|
780
|
+
verdict: "ask",
|
|
781
|
+
reason: segs ? "Bilgisayarında bir komut çalıştıracak." : "İçinde gizlice çalışan bir alt komut var.",
|
|
782
|
+
pattern: segs ? commandPattern(c) : undefined,
|
|
783
|
+
};
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
export function classifyWrite(path: string): Decision {
|
|
787
|
+
const p = path.trim();
|
|
788
|
+
for (const [re, reason] of PATH_DENY) if (re.test(p)) return { verdict: "deny", reason };
|
|
789
|
+
for (const [re, reason] of PATH_STICKY) if (re.test(p)) return { verdict: "ask", reason, sticky: true };
|
|
790
|
+
return { verdict: "ask", reason: "Projendeki bir dosyayı değiştirecek." };
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
/** Arac cagrisini siniflandirir. Bilinmeyen araclar bu katmanin konusu degil (undefined). */
|
|
794
|
+
export function classifyToolCall(toolName: string, input: unknown, opts: PolicyOptions = {}): Decision | undefined {
|
|
795
|
+
const i = (input ?? {}) as Record<string, unknown>;
|
|
796
|
+
// proc (arka plan surec araci): komut verilmeyen eylemler (list/read/kill) kendi sureclerini yonetir -> zararsiz.
|
|
797
|
+
if (toolName === "proc" && !String(i.command ?? "").trim()) return { verdict: "safe" };
|
|
798
|
+
// app_verify: komutsuz (html/klasor dogrulama) zararsiz; command/serve_command kabukla ayni politikadan gecer.
|
|
799
|
+
if (toolName === "app_verify") {
|
|
800
|
+
const c = String(i.command ?? i.serve_command ?? "").trim();
|
|
801
|
+
return c ? classifyCommand(c, opts) : { verdict: "safe" };
|
|
802
|
+
}
|
|
803
|
+
if (toolName === "bash" || toolName === "powershell" || toolName === "proc")
|
|
804
|
+
return classifyCommand(String(i.command ?? ""), opts);
|
|
805
|
+
if (toolName === "edit" || toolName === "write" || toolName === "notebook_edit")
|
|
806
|
+
return classifyWrite(String(i.path ?? i.file_path ?? ""));
|
|
807
|
+
return undefined;
|
|
808
|
+
}
|