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,618 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LSP tanilari + bicimlendirici (Sera Code'un opencode'daki /lsp ve /formatter ozelliginin Pi karsiligi).
|
|
3
|
+
*
|
|
4
|
+
* Tasarim: edit/write sonrasi dosya (varsa) projenin bicimlendiricisinden gecirilir, sonra dil sunucusundan tani istenir ve
|
|
5
|
+
* hatalar arac sonucuna eklenir (model kendi hatasini ayni turda gorur). `lsp` araci: diagnostics|hover|definition|references.
|
|
6
|
+
* Sunucular TEMBEL baslar (ilk kullanimda), bosta kalinca kapanir (lazy-capability.ts).
|
|
7
|
+
*
|
|
8
|
+
* Sunucu tablosunun cekirdegi (komut/argumanlar/dosya turleri/kok isaretleri) oh-my-pi
|
|
9
|
+
* (https://github.com/can1357/oh-my-pi, MIT) packages/coding-agent/src/lsp/defaults.json'dan uyarlandi; istemci/yonetici
|
|
10
|
+
* kodu bu depoya ozgu, kucuk ve bagimliliksizdir.
|
|
11
|
+
*/
|
|
12
|
+
import { type ChildProcessWithoutNullStreams, spawn } from "node:child_process";
|
|
13
|
+
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
14
|
+
import { dirname, extname, isAbsolute, join, resolve } from "node:path";
|
|
15
|
+
import { pathToFileURL } from "node:url";
|
|
16
|
+
import { LazyRuntime } from "./lazy-capability.ts";
|
|
17
|
+
|
|
18
|
+
export interface LspServerDef {
|
|
19
|
+
command: string;
|
|
20
|
+
args: string[];
|
|
21
|
+
fileTypes: string[];
|
|
22
|
+
rootMarkers: string[];
|
|
23
|
+
/** Yalnizca biçimlendirme/lint yapan sunucu: hover/definition icin tercih edilmez. */
|
|
24
|
+
isLinter?: boolean;
|
|
25
|
+
languageId?: Record<string, string>;
|
|
26
|
+
initOptions?: unknown;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const DEFAULT_SERVERS: Record<string, LspServerDef> = {
|
|
30
|
+
"typescript-language-server": {
|
|
31
|
+
command: "typescript-language-server",
|
|
32
|
+
args: ["--stdio"],
|
|
33
|
+
fileTypes: [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"],
|
|
34
|
+
rootMarkers: ["tsconfig.json", "jsconfig.json", "package.json"],
|
|
35
|
+
},
|
|
36
|
+
biome: {
|
|
37
|
+
command: "biome",
|
|
38
|
+
args: ["lsp-proxy"],
|
|
39
|
+
fileTypes: [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".json", ".jsonc", ".css"],
|
|
40
|
+
rootMarkers: ["biome.json", "biome.jsonc"],
|
|
41
|
+
isLinter: true,
|
|
42
|
+
},
|
|
43
|
+
"rust-analyzer": {
|
|
44
|
+
command: "rust-analyzer",
|
|
45
|
+
args: [],
|
|
46
|
+
fileTypes: [".rs"],
|
|
47
|
+
rootMarkers: ["Cargo.toml", "rust-analyzer.toml"],
|
|
48
|
+
},
|
|
49
|
+
gopls: { command: "gopls", args: ["serve"], fileTypes: [".go"], rootMarkers: ["go.mod", "go.work"] },
|
|
50
|
+
pyright: {
|
|
51
|
+
command: "pyright-langserver",
|
|
52
|
+
args: ["--stdio"],
|
|
53
|
+
fileTypes: [".py", ".pyi"],
|
|
54
|
+
rootMarkers: ["pyproject.toml", "pyrightconfig.json", "setup.py", "requirements.txt"],
|
|
55
|
+
},
|
|
56
|
+
clangd: {
|
|
57
|
+
command: "clangd",
|
|
58
|
+
args: ["--background-index"],
|
|
59
|
+
fileTypes: [".c", ".cpp", ".cc", ".h", ".hpp"],
|
|
60
|
+
rootMarkers: ["compile_commands.json", "CMakeLists.txt", ".clangd"],
|
|
61
|
+
},
|
|
62
|
+
zls: { command: "zls", args: [], fileTypes: [".zig"], rootMarkers: ["build.zig", "build.zig.zon"] },
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export interface FormatterDef {
|
|
66
|
+
/** {file} yer tutucusu mutlak dosya yoluyla degisir. */
|
|
67
|
+
command: string;
|
|
68
|
+
args: string[];
|
|
69
|
+
fileTypes: string[];
|
|
70
|
+
/** Bicimlendirici yalniz bu isaretlerden biri proje kokunde (ust dizinlerde) varsa calisir; bos = her zaman. */
|
|
71
|
+
configMarkers: string[];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export const DEFAULT_FORMATTERS: Record<string, FormatterDef> = {
|
|
75
|
+
biome: {
|
|
76
|
+
command: "biome",
|
|
77
|
+
args: ["format", "--write", "{file}"],
|
|
78
|
+
fileTypes: [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".json", ".jsonc", ".css"],
|
|
79
|
+
configMarkers: ["biome.json", "biome.jsonc"],
|
|
80
|
+
},
|
|
81
|
+
prettier: {
|
|
82
|
+
command: "prettier",
|
|
83
|
+
args: ["--write", "{file}"],
|
|
84
|
+
fileTypes: [
|
|
85
|
+
".ts",
|
|
86
|
+
".tsx",
|
|
87
|
+
".js",
|
|
88
|
+
".jsx",
|
|
89
|
+
".mjs",
|
|
90
|
+
".cjs",
|
|
91
|
+
".json",
|
|
92
|
+
".css",
|
|
93
|
+
".scss",
|
|
94
|
+
".html",
|
|
95
|
+
".md",
|
|
96
|
+
".yaml",
|
|
97
|
+
".yml",
|
|
98
|
+
],
|
|
99
|
+
configMarkers: [
|
|
100
|
+
".prettierrc",
|
|
101
|
+
".prettierrc.json",
|
|
102
|
+
".prettierrc.js",
|
|
103
|
+
".prettierrc.yml",
|
|
104
|
+
"prettier.config.js",
|
|
105
|
+
"prettier.config.mjs",
|
|
106
|
+
],
|
|
107
|
+
},
|
|
108
|
+
rustfmt: { command: "rustfmt", args: ["{file}"], fileTypes: [".rs"], configMarkers: ["Cargo.toml"] },
|
|
109
|
+
gofmt: { command: "gofmt", args: ["-w", "{file}"], fileTypes: [".go"], configMarkers: ["go.mod"] },
|
|
110
|
+
ruff: {
|
|
111
|
+
command: "ruff",
|
|
112
|
+
args: ["format", "{file}"],
|
|
113
|
+
fileTypes: [".py"],
|
|
114
|
+
configMarkers: ["ruff.toml", ".ruff.toml"],
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
/** SERA_LSP_CONFIG / SERA_FORMATTERS (JSON) varsayilanlarin USTUNE yazar; `null` degeri girdiyi kapatir. */
|
|
119
|
+
function overlay<T>(base: Record<string, T>, raw: string | undefined): Record<string, T> {
|
|
120
|
+
const out = { ...base };
|
|
121
|
+
if (!raw) return out;
|
|
122
|
+
try {
|
|
123
|
+
const o = JSON.parse(raw) as Record<string, T | null>;
|
|
124
|
+
for (const [k, v] of Object.entries(o)) {
|
|
125
|
+
if (v === null) delete out[k];
|
|
126
|
+
else out[k] = v;
|
|
127
|
+
}
|
|
128
|
+
} catch {
|
|
129
|
+
// bozuk ayar: varsayilanlar kalir
|
|
130
|
+
}
|
|
131
|
+
return out;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export function serverTable(env: Record<string, string | undefined> = process.env) {
|
|
135
|
+
return overlay(DEFAULT_SERVERS, env.SERA_LSP_CONFIG);
|
|
136
|
+
}
|
|
137
|
+
export function formatterTable(env: Record<string, string | undefined> = process.env) {
|
|
138
|
+
return overlay(DEFAULT_FORMATTERS, env.SERA_FORMATTERS);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function isDir(p: string): boolean {
|
|
142
|
+
try {
|
|
143
|
+
return statSync(p).isDirectory();
|
|
144
|
+
} catch {
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** Dosyadan yukari dogru isaret dosyasi arar; bulunan dizin ya da undefined. */
|
|
150
|
+
export function findRoot(file: string, markers: string[], stop: string): string | undefined {
|
|
151
|
+
let dir = dirname(file);
|
|
152
|
+
const top = resolve(stop);
|
|
153
|
+
for (let i = 0; i < 40; i++) {
|
|
154
|
+
if (markers.some((m) => existsSync(join(dir, m)))) return dir;
|
|
155
|
+
if (resolve(dir) === top) break;
|
|
156
|
+
const up = dirname(dir);
|
|
157
|
+
if (up === dir) break;
|
|
158
|
+
dir = up;
|
|
159
|
+
}
|
|
160
|
+
return undefined;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** Komutu PATH'te ya da proje node_modules/.bin altinda (yukari dogru) arar. */
|
|
164
|
+
export function resolveCommand(command: string, from: string, env: Record<string, string | undefined> = process.env) {
|
|
165
|
+
if (isAbsolute(command) || command.includes("/") || command.includes("\\"))
|
|
166
|
+
return existsSync(command) ? command : undefined;
|
|
167
|
+
const exts = process.platform === "win32" ? [".cmd", ".exe", ".bat", ""] : [""];
|
|
168
|
+
let dir = resolve(from);
|
|
169
|
+
for (let i = 0; i < 40; i++) {
|
|
170
|
+
for (const e of exts) {
|
|
171
|
+
const p = join(dir, "node_modules", ".bin", command + e);
|
|
172
|
+
if (existsSync(p)) return p;
|
|
173
|
+
}
|
|
174
|
+
const up = dirname(dir);
|
|
175
|
+
if (up === dir) break;
|
|
176
|
+
dir = up;
|
|
177
|
+
}
|
|
178
|
+
for (const d of (env.PATH ?? env.Path ?? "").split(process.platform === "win32" ? ";" : ":")) {
|
|
179
|
+
if (!d) continue;
|
|
180
|
+
for (const e of exts) {
|
|
181
|
+
const p = join(d, command + e);
|
|
182
|
+
if (existsSync(p) && !isDir(p)) return p;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return undefined;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/** Windows .cmd/.bat shim'leri shell ile calisir; o durumda bosluklu yol/arguman tirnaklanir. */
|
|
189
|
+
function spawnSpec(cmd: string, args: string[]) {
|
|
190
|
+
const shell = process.platform === "win32" && /\.(cmd|bat)$/i.test(cmd);
|
|
191
|
+
const q = (x: string) => (shell && /\s/.test(x) ? `"${x}"` : x);
|
|
192
|
+
return { cmd: q(cmd), args: args.map(q), shell };
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// --- JSON-RPC istemcisi --------------------------------------------------------------------------
|
|
196
|
+
|
|
197
|
+
export interface Diagnostic {
|
|
198
|
+
severity?: number;
|
|
199
|
+
message: string;
|
|
200
|
+
source?: string;
|
|
201
|
+
code?: string | number;
|
|
202
|
+
range: { start: { line: number; character: number }; end: { line: number; character: number } };
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const LANG_BY_EXT: Record<string, string> = {
|
|
206
|
+
".ts": "typescript",
|
|
207
|
+
".tsx": "typescriptreact",
|
|
208
|
+
".js": "javascript",
|
|
209
|
+
".jsx": "javascriptreact",
|
|
210
|
+
".mjs": "javascript",
|
|
211
|
+
".cjs": "javascript",
|
|
212
|
+
".json": "json",
|
|
213
|
+
".jsonc": "jsonc",
|
|
214
|
+
".css": "css",
|
|
215
|
+
".rs": "rust",
|
|
216
|
+
".go": "go",
|
|
217
|
+
".py": "python",
|
|
218
|
+
".pyi": "python",
|
|
219
|
+
".c": "c",
|
|
220
|
+
".h": "c",
|
|
221
|
+
".cpp": "cpp",
|
|
222
|
+
".cc": "cpp",
|
|
223
|
+
".hpp": "cpp",
|
|
224
|
+
".zig": "zig",
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
export class LspClient {
|
|
228
|
+
private proc: ChildProcessWithoutNullStreams;
|
|
229
|
+
private buf = Buffer.alloc(0);
|
|
230
|
+
private nextId = 1;
|
|
231
|
+
private pending = new Map<number, { resolve: (v: unknown) => void; reject: (e: Error) => void }>();
|
|
232
|
+
private diags = new Map<string, Diagnostic[]>();
|
|
233
|
+
private versions = new Map<string, number>();
|
|
234
|
+
private waiters = new Map<string, Array<() => void>>();
|
|
235
|
+
closed = false;
|
|
236
|
+
stderr = "";
|
|
237
|
+
readonly name: string;
|
|
238
|
+
readonly root: string;
|
|
239
|
+
private readonly def: LspServerDef;
|
|
240
|
+
|
|
241
|
+
constructor(
|
|
242
|
+
name: string,
|
|
243
|
+
root: string,
|
|
244
|
+
cmdPath: string,
|
|
245
|
+
args: string[],
|
|
246
|
+
def: LspServerDef,
|
|
247
|
+
env: Record<string, string | undefined> = process.env,
|
|
248
|
+
) {
|
|
249
|
+
this.name = name;
|
|
250
|
+
this.root = root;
|
|
251
|
+
this.def = def;
|
|
252
|
+
const sp = spawnSpec(cmdPath, args);
|
|
253
|
+
this.proc = spawn(sp.cmd, sp.args, {
|
|
254
|
+
cwd: root,
|
|
255
|
+
env: env as NodeJS.ProcessEnv,
|
|
256
|
+
shell: sp.shell,
|
|
257
|
+
windowsHide: true,
|
|
258
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
259
|
+
});
|
|
260
|
+
this.proc.stdout.on("data", (c: Buffer) => this.onData(c));
|
|
261
|
+
this.proc.stderr.on("data", (c: Buffer) => {
|
|
262
|
+
this.stderr = (this.stderr + c.toString()).slice(-2000);
|
|
263
|
+
});
|
|
264
|
+
this.proc.on("error", (e) => this.fail(e));
|
|
265
|
+
this.proc.on("close", () => this.fail(new Error(`${name} kapandi`)));
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
private fail(e: Error): void {
|
|
269
|
+
this.closed = true;
|
|
270
|
+
for (const p of this.pending.values()) p.reject(e);
|
|
271
|
+
this.pending.clear();
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
private onData(c: Buffer): void {
|
|
275
|
+
this.buf = Buffer.concat([this.buf, c]);
|
|
276
|
+
for (;;) {
|
|
277
|
+
const head = this.buf.indexOf("\r\n\r\n");
|
|
278
|
+
if (head < 0) return;
|
|
279
|
+
const m = /Content-Length:\s*(\d+)/i.exec(this.buf.subarray(0, head).toString("ascii"));
|
|
280
|
+
if (!m) {
|
|
281
|
+
this.buf = this.buf.subarray(head + 4);
|
|
282
|
+
continue;
|
|
283
|
+
}
|
|
284
|
+
const len = Number(m[1]);
|
|
285
|
+
if (this.buf.length < head + 4 + len) return;
|
|
286
|
+
const body = this.buf.subarray(head + 4, head + 4 + len).toString("utf8");
|
|
287
|
+
this.buf = this.buf.subarray(head + 4 + len);
|
|
288
|
+
try {
|
|
289
|
+
this.onMessage(JSON.parse(body));
|
|
290
|
+
} catch {
|
|
291
|
+
// bozuk mesaj: yok say
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
private onMessage(msg: {
|
|
297
|
+
id?: number;
|
|
298
|
+
method?: string;
|
|
299
|
+
params?: any;
|
|
300
|
+
result?: unknown;
|
|
301
|
+
error?: { message: string };
|
|
302
|
+
}): void {
|
|
303
|
+
if (msg.method === "textDocument/publishDiagnostics" && msg.params) {
|
|
304
|
+
const uri: string = msg.params.uri;
|
|
305
|
+
this.diags.set(uri, msg.params.diagnostics ?? []);
|
|
306
|
+
for (const w of this.waiters.get(uri)?.splice(0) ?? []) w();
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
if (msg.id !== undefined && msg.method) {
|
|
310
|
+
// sunucudan istemciye istek (workspace/configuration vb.): bos yanit ver
|
|
311
|
+
this.write({ jsonrpc: "2.0", id: msg.id, result: msg.method === "workspace/configuration" ? [] : null });
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
if (msg.id !== undefined) {
|
|
315
|
+
const p = this.pending.get(msg.id);
|
|
316
|
+
if (!p) return;
|
|
317
|
+
this.pending.delete(msg.id);
|
|
318
|
+
if (msg.error) p.reject(new Error(msg.error.message));
|
|
319
|
+
else p.resolve(msg.result);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
private write(obj: unknown): void {
|
|
324
|
+
if (this.closed) return;
|
|
325
|
+
const s = JSON.stringify(obj);
|
|
326
|
+
this.proc.stdin.write(`Content-Length: ${Buffer.byteLength(s)}\r\n\r\n${s}`);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
request<T = unknown>(method: string, params: unknown, timeoutMs = 15000): Promise<T> {
|
|
330
|
+
return new Promise<T>((res, rej) => {
|
|
331
|
+
if (this.closed) return rej(new Error(`${this.name} calismiyor`));
|
|
332
|
+
const id = this.nextId++;
|
|
333
|
+
const t = setTimeout(() => {
|
|
334
|
+
this.pending.delete(id);
|
|
335
|
+
rej(new Error(`${method} zaman asimi`));
|
|
336
|
+
}, timeoutMs);
|
|
337
|
+
this.pending.set(id, {
|
|
338
|
+
resolve: (v) => {
|
|
339
|
+
clearTimeout(t);
|
|
340
|
+
res(v as T);
|
|
341
|
+
},
|
|
342
|
+
reject: (e) => {
|
|
343
|
+
clearTimeout(t);
|
|
344
|
+
rej(e);
|
|
345
|
+
},
|
|
346
|
+
});
|
|
347
|
+
this.write({ jsonrpc: "2.0", id, method, params });
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
notify(method: string, params: unknown): void {
|
|
352
|
+
this.write({ jsonrpc: "2.0", method, params });
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
async init(): Promise<void> {
|
|
356
|
+
await this.request(
|
|
357
|
+
"initialize",
|
|
358
|
+
{
|
|
359
|
+
processId: process.pid,
|
|
360
|
+
rootUri: pathToFileURL(this.root).href,
|
|
361
|
+
workspaceFolders: [{ uri: pathToFileURL(this.root).href, name: "root" }],
|
|
362
|
+
capabilities: {
|
|
363
|
+
textDocument: {
|
|
364
|
+
synchronization: { didSave: true },
|
|
365
|
+
publishDiagnostics: { relatedInformation: false },
|
|
366
|
+
hover: { contentFormat: ["plaintext", "markdown"] },
|
|
367
|
+
definition: {},
|
|
368
|
+
references: {},
|
|
369
|
+
},
|
|
370
|
+
workspace: { configuration: true, workspaceFolders: true },
|
|
371
|
+
},
|
|
372
|
+
initializationOptions: this.def.initOptions,
|
|
373
|
+
},
|
|
374
|
+
30000,
|
|
375
|
+
);
|
|
376
|
+
this.notify("initialized", {});
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
/** Dosyayi (yeniden) esitler ve sunucudan yeni tani bekler; zaman asiminda eldeki son tani doner. */
|
|
380
|
+
async diagnose(file: string, waitMs: number): Promise<Diagnostic[]> {
|
|
381
|
+
const uri = pathToFileURL(file).href;
|
|
382
|
+
const text = readFileSync(file, "utf8");
|
|
383
|
+
const wait = new Promise<void>((done) => {
|
|
384
|
+
const t = setTimeout(done, waitMs);
|
|
385
|
+
const list = this.waiters.get(uri) ?? [];
|
|
386
|
+
list.push(() => {
|
|
387
|
+
clearTimeout(t);
|
|
388
|
+
done();
|
|
389
|
+
});
|
|
390
|
+
this.waiters.set(uri, list);
|
|
391
|
+
});
|
|
392
|
+
this.diags.delete(uri);
|
|
393
|
+
const v = (this.versions.get(uri) ?? 0) + 1;
|
|
394
|
+
this.versions.set(uri, v);
|
|
395
|
+
if (v === 1) {
|
|
396
|
+
const ext = extname(file).toLowerCase();
|
|
397
|
+
this.notify("textDocument/didOpen", {
|
|
398
|
+
textDocument: {
|
|
399
|
+
uri,
|
|
400
|
+
languageId: this.def.languageId?.[ext] ?? LANG_BY_EXT[ext] ?? "plaintext",
|
|
401
|
+
version: v,
|
|
402
|
+
text,
|
|
403
|
+
},
|
|
404
|
+
});
|
|
405
|
+
} else {
|
|
406
|
+
this.notify("textDocument/didChange", { textDocument: { uri, version: v }, contentChanges: [{ text }] });
|
|
407
|
+
}
|
|
408
|
+
this.notify("textDocument/didSave", { textDocument: { uri }, text });
|
|
409
|
+
await wait;
|
|
410
|
+
return this.diags.get(uri) ?? [];
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
position(file: string, line: number, character: number) {
|
|
414
|
+
return { textDocument: { uri: pathToFileURL(file).href }, position: { line, character } };
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
async close(): Promise<void> {
|
|
418
|
+
if (this.closed) return;
|
|
419
|
+
try {
|
|
420
|
+
await this.request("shutdown", null, 3000);
|
|
421
|
+
this.notify("exit", null);
|
|
422
|
+
} catch {
|
|
423
|
+
// kapanis yaniti yok
|
|
424
|
+
}
|
|
425
|
+
this.closed = true;
|
|
426
|
+
try {
|
|
427
|
+
this.proc.kill();
|
|
428
|
+
} catch {
|
|
429
|
+
// zaten kapali
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
// --- Yonetici --------------------------------------------------------------------------------------
|
|
435
|
+
|
|
436
|
+
export interface LspStatus {
|
|
437
|
+
id: string;
|
|
438
|
+
name: string;
|
|
439
|
+
root: string;
|
|
440
|
+
status: "connected" | "error" | "starting";
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
export class LspManager {
|
|
444
|
+
private runtimes = new Map<string, { rt: LazyRuntime<LspClient>; name: string; root: string }>();
|
|
445
|
+
/** Sunucu adi -> kac kez baslatildi (olcum/test). */
|
|
446
|
+
readonly starts = new Map<string, number>();
|
|
447
|
+
|
|
448
|
+
private readonly cwd: string;
|
|
449
|
+
private readonly env: Record<string, string | undefined>;
|
|
450
|
+
private readonly idleMs: number;
|
|
451
|
+
/** Sunucu durumu degisince (baslama/kapanma/hata) cagrilir; arayuz durum satiri icin. */
|
|
452
|
+
onChange?: () => void;
|
|
453
|
+
|
|
454
|
+
constructor(cwd: string, env: Record<string, string | undefined> = process.env, idleMs = 5 * 60 * 1000) {
|
|
455
|
+
this.cwd = cwd;
|
|
456
|
+
this.env = env;
|
|
457
|
+
this.idleMs = idleMs;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
enabled(): boolean {
|
|
461
|
+
return this.env.SERA_LSP !== "0";
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
/** Bu dosya icin uygun sunucular (tabloda sirayla); yalnizca komutu bulunabilen ve koku olan. */
|
|
465
|
+
candidates(file: string): Array<{ name: string; def: LspServerDef; cmd: string; root: string }> {
|
|
466
|
+
const ext = extname(file).toLowerCase();
|
|
467
|
+
const out: Array<{ name: string; def: LspServerDef; cmd: string; root: string }> = [];
|
|
468
|
+
for (const [name, def] of Object.entries(serverTable(this.env))) {
|
|
469
|
+
if (!def.fileTypes.includes(ext)) continue;
|
|
470
|
+
const root = findRoot(file, def.rootMarkers, this.cwd);
|
|
471
|
+
if (!root) continue;
|
|
472
|
+
const cmd = resolveCommand(def.command, root, this.env);
|
|
473
|
+
if (!cmd) continue;
|
|
474
|
+
out.push({ name, def, cmd, root });
|
|
475
|
+
}
|
|
476
|
+
// dil sunucusu (isLinter degil) once: hover/definition icin dogru olan o
|
|
477
|
+
return out.sort((a, b) => Number(!!a.def.isLinter) - Number(!!b.def.isLinter));
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
private runtime(c: { name: string; def: LspServerDef; cmd: string; root: string }) {
|
|
481
|
+
const key = `${c.name}@${c.root}`;
|
|
482
|
+
let e = this.runtimes.get(key);
|
|
483
|
+
if (!e) {
|
|
484
|
+
const rt = new LazyRuntime<LspClient>(
|
|
485
|
+
{
|
|
486
|
+
id: `lsp:${c.name}`,
|
|
487
|
+
summary: `LSP ${c.name}`,
|
|
488
|
+
activate: async () => {
|
|
489
|
+
this.starts.set(c.name, (this.starts.get(c.name) ?? 0) + 1);
|
|
490
|
+
const cl = new LspClient(c.name, c.root, c.cmd, c.def.args, c.def, this.env);
|
|
491
|
+
await cl.init();
|
|
492
|
+
return cl;
|
|
493
|
+
},
|
|
494
|
+
deactivate: (h) => h.close(),
|
|
495
|
+
},
|
|
496
|
+
{ idleMs: this.idleMs, onState: () => this.onChange?.() },
|
|
497
|
+
);
|
|
498
|
+
e = { rt, name: c.name, root: c.root };
|
|
499
|
+
this.runtimes.set(key, e);
|
|
500
|
+
}
|
|
501
|
+
return e.rt;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
/** Tum uygun sunucularin tanilarini birlestirir. */
|
|
505
|
+
async diagnostics(file: string, waitMs = 4000): Promise<Array<Diagnostic & { server: string }>> {
|
|
506
|
+
const all: Array<Diagnostic & { server: string }> = [];
|
|
507
|
+
await Promise.all(
|
|
508
|
+
this.candidates(file).map(async (c) => {
|
|
509
|
+
try {
|
|
510
|
+
const ds = await this.runtime(c).use((cl) => cl.diagnose(file, waitMs));
|
|
511
|
+
for (const d of ds) all.push({ ...d, server: c.name });
|
|
512
|
+
} catch {
|
|
513
|
+
// sunucu acilamadi: bu sunucudan tani yok (ayri durum satirinda gorunur)
|
|
514
|
+
}
|
|
515
|
+
}),
|
|
516
|
+
);
|
|
517
|
+
return all;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
/** hover/definition/references: ilk dil sunucusuna (yoksa ilk uygun sunucuya) sorar. */
|
|
521
|
+
async query(file: string, method: "hover" | "definition" | "references", line: number, character: number) {
|
|
522
|
+
const c = this.candidates(file)[0];
|
|
523
|
+
if (!c) throw new Error("Bu dosya turu icin kurulu dil sunucusu bulunamadi.");
|
|
524
|
+
return this.runtime(c).use(async (cl) => {
|
|
525
|
+
await cl.diagnose(file, 300);
|
|
526
|
+
const p = cl.position(file, line, character);
|
|
527
|
+
if (method === "references")
|
|
528
|
+
return cl.request("textDocument/references", { ...p, context: { includeDeclaration: true } });
|
|
529
|
+
return cl.request(`textDocument/${method}`, p);
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
status(): LspStatus[] {
|
|
534
|
+
return [...this.runtimes.entries()]
|
|
535
|
+
.filter(([, e]) => e.rt.state !== "off")
|
|
536
|
+
.map(([id, e]) => ({
|
|
537
|
+
id,
|
|
538
|
+
name: e.name,
|
|
539
|
+
root: e.root,
|
|
540
|
+
status: e.rt.state === "on" ? "connected" : e.rt.state === "failed" ? "error" : "starting",
|
|
541
|
+
}));
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
async stopAll(): Promise<void> {
|
|
545
|
+
await Promise.all([...this.runtimes.values()].map((e) => e.rt.stop()));
|
|
546
|
+
this.runtimes.clear();
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
// --- Bicimlendirici --------------------------------------------------------------------------------
|
|
551
|
+
|
|
552
|
+
export interface FormatResult {
|
|
553
|
+
formatter: string;
|
|
554
|
+
changed: boolean;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
export function runFormatter(
|
|
558
|
+
file: string,
|
|
559
|
+
cwd: string,
|
|
560
|
+
env: Record<string, string | undefined> = process.env,
|
|
561
|
+
): Promise<FormatResult | undefined> {
|
|
562
|
+
if (env.SERA_FORMAT === "0") return Promise.resolve(undefined);
|
|
563
|
+
const ext = extname(file).toLowerCase();
|
|
564
|
+
for (const [name, f] of Object.entries(formatterTable(env))) {
|
|
565
|
+
if (!f.fileTypes.includes(ext)) continue;
|
|
566
|
+
const root = f.configMarkers.length ? findRoot(file, f.configMarkers, cwd) : cwd;
|
|
567
|
+
if (!root) continue;
|
|
568
|
+
const cmd = resolveCommand(f.command, root, env);
|
|
569
|
+
if (!cmd) continue;
|
|
570
|
+
const before = readFileSync(file, "utf8");
|
|
571
|
+
const args = f.args.map((a) => a.replace("{file}", file));
|
|
572
|
+
return new Promise((done) => {
|
|
573
|
+
const sp = spawnSpec(cmd, args);
|
|
574
|
+
const p = spawn(sp.cmd, sp.args, {
|
|
575
|
+
cwd: root,
|
|
576
|
+
windowsHide: true,
|
|
577
|
+
shell: sp.shell,
|
|
578
|
+
stdio: "ignore",
|
|
579
|
+
});
|
|
580
|
+
const t = setTimeout(() => p.kill(), 20000);
|
|
581
|
+
p.on("error", () => {
|
|
582
|
+
clearTimeout(t);
|
|
583
|
+
done(undefined);
|
|
584
|
+
});
|
|
585
|
+
p.on("close", (code) => {
|
|
586
|
+
clearTimeout(t);
|
|
587
|
+
if (code !== 0) return done(undefined);
|
|
588
|
+
try {
|
|
589
|
+
done({ formatter: name, changed: readFileSync(file, "utf8") !== before });
|
|
590
|
+
} catch {
|
|
591
|
+
done(undefined);
|
|
592
|
+
}
|
|
593
|
+
});
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
return Promise.resolve(undefined);
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
// --- Metin ---------------------------------------------------------------------------------------------
|
|
600
|
+
|
|
601
|
+
const SEV = ["", "hata", "uyari", "bilgi", "ipucu"];
|
|
602
|
+
|
|
603
|
+
export function formatDiagnostics(
|
|
604
|
+
file: string,
|
|
605
|
+
ds: Array<Diagnostic & { server?: string }>,
|
|
606
|
+
maxErrors = 20,
|
|
607
|
+
): string | undefined {
|
|
608
|
+
const errors = ds.filter((d) => (d.severity ?? 1) === 1);
|
|
609
|
+
if (!errors.length) return undefined;
|
|
610
|
+
const lines = errors.slice(0, maxErrors).map((d) => {
|
|
611
|
+
const where = `${d.range.start.line + 1}:${d.range.start.character + 1}`;
|
|
612
|
+
const code = d.code !== undefined ? ` [${d.code}]` : "";
|
|
613
|
+
return ` ${where} ${SEV[d.severity ?? 1]}${code} ${d.message.split("\n")[0]}${d.server ? ` (${d.server})` : ""}`;
|
|
614
|
+
});
|
|
615
|
+
const more = errors.length > maxErrors ? `\n ... ve ${errors.length - maxErrors} hata daha` : "";
|
|
616
|
+
const warn = ds.length - errors.length;
|
|
617
|
+
return `[LSP] ${file}: ${errors.length} hata${warn ? `, ${warn} uyari` : ""}\n${lines.join("\n")}${more}`;
|
|
618
|
+
}
|