Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

22.6 KB
Raw Blame

Compression Rules Format (မြန်မာ)

🌐 Languages: 🇺🇸 English · 🇪🇹 am · 🇸🇦 ar · 🇦🇿 az · 🇧🇬 bg · 🇧🇩 bn · 🇧🇦 bs · 🇨🇿 cs · 🇩🇰 da · 🇩🇪 de · 🇬🇷 el · 🇪🇸 es · 🇪🇪 et · 🇮🇷 fa · 🇫🇮 fi · 🇫🇷 fr · 🇮🇪 ga · 🇮🇳 gu · 🇳🇬 ha · 🇮🇱 he · 🇮🇳 hi · 🇭🇷 hr · 🇭🇺 hu · 🇦🇲 hy · 🇮🇩 id · 🇳🇬 ig · 🇮🇹 it · 🇯🇵 ja · 🇬🇪 ka · 🇰🇭 km · 🇮🇳 kn · 🇰🇷 ko · 🇱🇹 lt · 🇱🇻 lv · 🇮🇳 ml · 🇮🇳 mr · 🇲🇾 ms · 🇲🇹 mt · 🇳🇵 ne · 🇳🇱 nl · 🇳🇴 no · 🇮🇳 or · 🇮🇳 pa · 🇵🇭 phi · 🇵🇱 pl · 🇵🇹 pt · 🇧🇷 pt-BR · 🇷🇴 ro · 🇷🇺 ru · 🇱🇰 si · 🇸🇰 sk · 🇸🇮 sl · 🇷🇸 sr · 🇸🇪 sv · 🇰🇪 sw · 🇮🇳 ta · 🇮🇳 te · 🇹🇭 th · 🇹🇷 tr · 🇺🇦 uk-UA · 🇵🇰 ur · 🇺🇿 uz · 🇻🇳 vi · 🇳🇬 yo · 🇨🇳 zh-CN · 🇹🇼 zh-TW


ချုံ့ခြင်းစည်းမျဉ်းများသည် runtime တွင် load လုပ်သည့် JSON ဖိုင်များဖြစ်သည်။ language pack အသစ်များနှင့် RTK command filter များကို engine code ပြောင်းလဲစရာမလိုဘဲ ပြန်လည်သုံးသပ်နိုင်စေရန် ၎င်းတို့ကို data-only အဖြစ် ရည်ရွယ်ထားသည်။

စံ schema (အမှန်တရား၏ မူရင်းရင်းမြစ်): open-sse/services/compression/rules/_schema.json (JSON Schema draft 2020-12)။ အောက်ပါဥပမာများသည် သရုပ်ပြရန်သာဖြစ်သည် — မသေချာပါက သင့် pack ကို _schema.json နှင့် တိုက်ဆိုင်စစ်ဆေးပါ။

Caveman Rule Pack များ

Caveman rule pack များကို အောက်ပါနေရာတွင် ထားရှိသည်-

open-sse/services/compression/rules/<language>/<pack>.json

pack တစ်ခုစီတွင် protected region များကို သီးခြားခွဲထုတ်ပြီးနောက် ပုံမှန်စကားပြေစာသားအပေါ် အသုံးချမည့် အစားထိုးမှုများ ပါဝင်သည်။

{
  "language": "en",
  "category": "filler",
  "rules": [
    {
      "name": "question_to_directive",
      "pattern": "\\b(?:Can you explain why|Could you show me how)\\b\\s*",
      "replacement": "Explain why ",
      "replacementMap": {
        "can you explain why": "Explain why ",
        "could you show me how": "Show how "
      },
      "flags": "gi",
      "context": "all",
      "category": "context",
      "minIntensity": "lite",
      "description": "Convert verbose questions into direct requests."
    }
  ]
}

Caveman Field များ

Field လိုအပ်မှု ဖော်ပြချက်
language လိုအပ်သည် en, pt-BR, es ကဲ့သို့သော BCP-47 ပုံစံ language key
category လိုအပ်သည် Pack category ဖိုင်အမည်/category၊ ဥပမာ filler သို့မဟုတ် dedup
rules လိုအပ်သည် regex အစားထိုးစည်းမျဉ်းများ၏ array
rules[].name လိုအပ်သည် တည်ငြိမ်သော စည်းမျဉ်းအမည်
rules[].pattern လိုအပ်သည် JavaScript regex source
rules[].flags မလိုအပ်ပါ JavaScript regex flag များ၊ မူလတန်ဖိုး gi
rules[].replacement မလိုအပ်ပါ အစားထိုး string သို့မဟုတ် replacementMap တွင် ကိုက်ညီမှုမရှိသည့်အခါ အသုံးပြုမည့် fallback
rules[].replacementMap မလိုအပ်ပါ ပုံမှန်ပြုထားသော ကိုက်ညီသည့်စာသားကို key အဖြစ်သုံးထားသည့် ကိုက်ညီမှုအလိုက် အစားထိုးတန်ဖိုးများ
rules[].context မလိုအပ်ပါ all, user, assistant, သို့မဟုတ် system၊ မူလတန်ဖိုး all
rules[].category မလိုအပ်ပါ filler, context, structural, dedup, terse, သို့မဟုတ် ultra
rules[].minIntensity မလိုအပ်ပါ lite, full, သို့မဟုတ် ultra၊ မူလတန်ဖိုး lite
rules[].description မလိုအပ်ပါ လူဖတ်ရှုနားလည်နိုင်သော စည်းမျဉ်းအကျဉ်းချုပ်

စာလုံးအကြီးအသေးခွဲခြားသော ကိုက်ညီမှုသည် အရေးကြီးသည့်အခါ flags ကို အသုံးပြုပါ။ ဥပမာ၊ the OpenAI API ကို မဖယ်ရှားဘဲ စာလုံးအသေးဖြင့်စသော စကားပြေရှေ့ရှိ article ကို ဖယ်ရှားခြင်းဖြစ်သည်။ regex တစ်ခုတွင် မတူညီသော output များ လိုအပ်သည့် alternative အများအပြားရှိသောအခါ replacementMap ကို အသုံးပြုပါ။ ထိုသို့ပြုလုပ်ခြင်းဖြင့် ပိုမိုစုံလင်သော built-in TypeScript replacement function များ၏ အပြုအမူကို ထိန်းသိမ်းထားနိုင်သည့်အပြင် JSON rule pack များကို data-only အဖြစ် ဆက်လက်ထားရှိနိုင်သည်။

RTK Filter Packs

RTK filter များကို အောက်ပါနေရာတွင် ထားရှိသည်-

open-sse/services/compression/engines/rtk/filters/<filter>.json

Filter တစ်ခုစီသည် command-output family တစ်ခုကို မည်သို့ခွဲခြားသိရှိပြီး ချုံ့မည်ကို ဖော်ပြသည်။

{
  "id": "test-vitest",
  "label": "Vitest output",
  "category": "test",
  "priority": 92,
  "match": {
    "outputTypes": ["test-vitest"],
    "commands": ["vitest", "npm test", "npm run test"],
    "patterns": ["\\bFAIL\\b", "\\bPASS\\b", "\\bTest Files\\b"]
  },
  "rules": {
    "stripAnsi": true,
    "replace": [{ "pattern": "\\s+\\[[0-9]+ms\\]", "replacement": "" }],
    "matchOutput": [
      {
        "pattern": "All tests passed",
        "message": "vitest: ok",
        "unless": "FAIL|Error:"
      }
    ],
    "includePatterns": ["FAIL", "Error:", "Test Files", "Tests"],
    "dropPatterns": ["^\\s*$", "Duration\\s+\\d+"],
    "collapsePatterns": ["^\\s+at "],
    "deduplicate": true,
    "truncateLineAt": 240,
    "maxLines": 160,
    "headLines": 24,
    "tailLines": 40,
    "onEmpty": "vitest: ok",
    "filterStderr": false
  },
  "preserve": {
    "errorPatterns": ["FAIL", "Error:", "AssertionError"],
    "summaryPatterns": ["Test Files", "Tests", "Snapshots"]
  },
  "tests": [
    {
      "name": "keeps failing tests",
      "command": "vitest",
      "input": "FAIL test/a.test.ts\\nError: boom\\nTest Files 1 failed",
      "expected": "FAIL test/a.test.ts\\nError: boom\\nTest Files 1 failed"
    }
  ]
}

RTK Field များ

Field လိုအပ်မှု ဖော်ပြချက်
id လိုအပ်သည် မပြောင်းလဲသော filter id
label လိုအပ်သည် Dashboard တွင် ဖတ်ရှုနိုင်သော အမည်
category လိုအပ်သည် Filter family- git, test, build, shell, docker, package, infra, cloud, generic
priority မလိုအပ်ပါ Filter အများအပြား ကိုက်ညီသည့်အခါ priority ပိုမြင့်သော filter ကို အသုံးပြုသည်
match.outputTypes မလိုအပ်ပါ ဤ filter ကို ရွေးချယ်သည့် detector output id များ
match.commands မလိုအပ်ပါ ဤ filter ကို ရွေးချယ်သည့် command token များ
match.patterns မလိုအပ်ပါ Output စာသားမှ ဤ filter ကို ရွေးချယ်သည့် regex pattern များ
rules.stripAnsi မလိုအပ်ပါ Regex အဆင့်များ မလုပ်ဆောင်မီ ANSI escape sequence များကို ဖယ်ရှားသည်
rules.replace မလိုအပ်ပါ စာကြောင်းတစ်ကြောင်းချင်းစီအလိုက် အစီအစဉ်တကျ အသုံးပြုသည့် regex အစားထိုးမှုများ
rules.matchOutput မလိုအပ်ပါ ရွေးချယ်နိုင်သော unless guard ပါသည့် short-circuit output rule များ
rules.includePatterns မလိုအပ်ပါ ထိန်းသိမ်းထားရန် ဦးစားပေးသင့်သည့် စာကြောင်းများ
rules.dropPatterns မလိုအပ်ပါ မလိုအပ်သော အချက်အလက်အဖြစ် ဖယ်ရှားမည့် စာကြောင်းများ
rules.collapsePatterns မလိုအပ်ပါ ခေါက်သိမ်းနိုင်သော ထပ်ခါတလဲလဲ ကိုက်ညီသည့် စာကြောင်းများ
rules.deduplicate မလိုအပ်ပါ ပုံမှန်ပြုလုပ်ပြီး တူညီနေသော စာကြောင်းများကို ခေါက်သိမ်းသည်
rules.truncateLineAt မလိုအပ်ပါ Unicode ကို ဘေးကင်းစွာ ကိုင်တွယ်နိုင်သည့် စာကြောင်းတစ်ကြောင်းချင်းစီ၏ အက္ခရာကန့်သတ်ချက်
rules.maxLines မလိုအပ်ပါ နောက်ဆုံးပိုင်းကို ထိန်းသိမ်းခြင်းမပြုမီ အများဆုံး ထိန်းသိမ်းထားမည့် စာကြောင်းအရေအတွက်
rules.headLines မလိုအပ်ပါ ဖြတ်တောက်ချိန်တွင် ထိန်းသိမ်းထားမည့် အစပိုင်းစာကြောင်းများ
rules.tailLines မလိုအပ်ပါ လတ်တလော အကြောင်းအရာအခြေအနေအတွက် ထိန်းသိမ်းထားမည့် နောက်ဆုံးပိုင်းစာကြောင်းများ
rules.onEmpty မလိုအပ်ပါ Filtering ပြုလုပ်ခြင်းကြောင့် အကြောင်းအရာအားလုံး ဖယ်ရှားသွားသည့်အခါ အသုံးပြုမည့် အရန် message
rules.filterStderr မလိုအပ်ပါ နောက်ပိုင်း filtering အဆင့်များမတိုင်မီ အသုံးများသော stderr prefix များကို ပုံမှန်ပြုလုပ်သည်
preserve.errorPatterns မလိုအပ်ပါ ဖြတ်တောက်ပြီးနောက် ဆက်လက်ကျန်ရှိသင့်သည့် error စာကြောင်းများ
preserve.summaryPatterns မလိုအပ်ပါ ဖြတ်တောက်ပြီးနောက် ဆက်လက်ကျန်ရှိသင့်သည့် အနှစ်ချုပ်စာကြောင်းများ
tests[] မလိုအပ်ပါ RTK verify gate က အသုံးပြုသည့် inline အတည်ပြုနမူနာများ

RTK သည် declarative အဆင့်များကို ဤအစီအစဉ်အတိုင်း အသုံးပြုသည်- stripAnsi, filterStderr, replace, matchOutput, dropPatterns/includePatterns, truncateLineAt, headLines/tailLines, maxLines နှင့် onEmpty။

စိတ်ကြိုက် filter များကို အောက်ပါနေရာများမှ ဖွင့်နိုင်သည်-

  1. ကိုက်ညီသော .rtk/trust.json hash ရှိပြီးနောက် သို့မဟုတ် trustProjectFilters ကို ဖွင့်ထားမှသာ project .rtk/filters.json file များ။
  2. Global DATA_DIR/rtk/filters.json။
  3. Built-in filter များ။

Project/global စိတ်ကြိုက် file များတွင် filter object တစ်ခု သို့မဟုတ် filter object array တစ်ခု ပါဝင်နိုင်သည်။ မမှန်ကန်သော စိတ်ကြိုက် filter များကို diagnostic များနှင့်အတူ ကျော်သွားမည်ဖြစ်ပြီး မမှန်ကန်သော built-in filter များသည် validation မအောင်မြင်စေပါ။

Project trust file-

{
  "filtersSha256": "0123456789abcdef..."
}

Environment override OMNIROUTE_RTK_TRUST_PROJECT_FILTERS=1 သည် hash မလိုဘဲ project filter များကို ယုံကြည်စေပြီး ထိန်းချုပ်ထားသော local development တွင်သာ အသုံးပြုသင့်သည်။

ဘေးကင်းရေး စည်းမျဉ်းများ

  • စည်းမျဉ်းများကို idempotent ဖြစ်အောင် ထိန်းသိမ်းပါ။ တူညီသော filter ကို နှစ်ကြိမ် အသုံးပြုခြင်းကြောင့် output ပျက်စီးမှု မဖြစ်သင့်ပါ။
  • ဖြစ်နိုင်သမျှ error စာသားအတိအကျ၊ file path များ၊ line number များနှင့် command အကျဉ်းချုပ်များကို မပြောင်းလဲဘဲ ထိန်းသိမ်းပါ။
  • code block များ၊ JSON payload များ၊ URL များ သို့မဟုတ် secret များကို ပြောင်းလဲသည့် စည်းမျဉ်းများကို ရှောင်ကြဉ်ပါ။
  • detector/filter test များတွင် command family အသစ်များအတွက် unit test coverage ထည့်ပါ။
  • built-in filter တိုင်းနှင့် အများသုံး custom filter များတွင် tests[] နမူနာများ ထည့်ပါ။

စစ်ဆေးအတည်ပြုခြင်း

Rule pack များကို အသုံးမပြုမီ စစ်ဆေးအတည်ပြုပါသည်။ Built-in Caveman pack များနှင့် built-in RTK filter များသည် ပျက်စီးနေသော release asset များကို ဖြန့်ချိခြင်းမပြုမီ ဖော်ထုတ်နိုင်ရန် validation ပြုလုပ်နေစဉ် ချက်ချင်း ရပ်တန့်ပြီး မအောင်မြင်ကြောင်း ပြပါသည်။ Custom RTK filter များကို parsing သို့မဟုတ် trust validation မအောင်မြင်သည့်အခါ diagnostic အချက်အလက်များနှင့်အတူ ကျော်သွားပါသည်။

သီးခြားအာရုံစိုက် စစ်ဆေးအတည်ပြုခြင်း-

node --import tsx/esm --test tests/unit/compression/rule-loader.test.ts tests/unit/compression/language-packs.test.ts
node --import tsx/esm --test tests/unit/compression/rtk-verify.test.ts tests/unit/compression/rtk-dsl-pipeline.test.ts