#!/usr/bin/env python3 """Keyword coding of collected threads (no paid APIs, no LLM). Input : raw/threads.jsonl (from collect.py) Output: raw/coded_kw.jsonl (all metadata + kw_* coded columns + private excerpt) Usage : python3 -I scripts/code.py [threads.jsonl] [out.jsonl] [--drop-removed] --drop-removed skips the repos removed after the full-build review (SkyPilot, replicate/cog) Rules are ordered: first match wins for single-valued columns; list columns join up to 3 matches with ';'. See codebook.md for definitions. """ import json, os, re, sys HERE = os.path.dirname(os.path.abspath(__file__)) sys.path.insert(0, HERE) import filters # noqa: E402 ROOT = os.path.dirname(HERE) I = re.I | re.A # ASCII \b so that "netlify现在" still matches def rx(s): return re.compile(s, I) HOSTS = [ # (label, regex) — order = priority when counts tie ("hf_inference_endpoints", rx(r"inference endpoints?\b|ui\.endpoints\.huggingface|dedicated endpoint")), ("hf_spaces", rx(r"hugging ?face spaces?|\bhf spaces?|\b(on|to|in) (a |the |my )?(hf |hugging ?face )?spaces?\b|spaces? (sdk|hardware|build|container)|huggingface\.co/spaces|hf\.space")), ("streamlit_cloud", rx(r"streamlit (community )?cloud|share\.streamlit|streamlit\.app\b")), ("vercel", rx(r"\bvercel\b(?!/ai)(?! ai sdk)")), ("netlify", rx(r"\bnetlify\b")), ("cloudflare", rx(r"\bcloudflare|\bworkers?\.dev|wrangler|\bpages\.dev")), ("fly", rx(r"\bfly\.io\b|\bflyctl\b|\bfly deploy\b|fly\.toml")), ("railway", rx(r"\brailway\b")), ("render", rx(r"\brender\.com\b|\bon render\b|\bto render\b|onrender\.com|render\.yaml")), ("heroku", rx(r"\bheroku\b")), ("supabase", rx(r"\bsupabase\b")), ("langgraph_platform", rx(r"langgraph (platform|cloud)|langsmith deploy|langgraph deploy|langgraph-api|langgraph up")), ("azure", rx(r"\bazure\b|\bazd\b|app service|container apps|\baks\b")), ("gcp", rx(r"cloud ?run\b|\bgcp\b|google cloud|app engine|\bgke\b|vertex|cloud functions|firebase")), ("aws", rx(r"\baws\b|aws lambda|\b(on|to|in|via) lambda\b|lambda (deploy\w*|layers?|cold start|timeouts?|function url|@edge)|sagemaker|\becs\b|\beks\b|\bec2\b|amplify|bedrock|fargate|elastic beanstalk|apprunner|app runner")), ("digitalocean", rx(r"digital ?ocean|\bdroplet")), ("runpod", rx(r"\brunpod\b")), ("modal", rx(r"\bmodal\.com\b|\bmodal (deploy|serve|labs)\b|on modal\b")), ("replicate", rx(r"\breplicate\.com\b|\bcog push\b|on replicate\b|to replicate\b")), ("kubernetes", rx(r"kubernetes|\bk8s\b|\bhelm\b|openshift")), ("posit_connect", rx(r"posit connect|rstudio connect")), ("vps_docker", rx(r"\bvps\b|docker[- ]compose|\bdocker\b|self[- ]host\w*|nginx|own server|ubuntu server|coolify|easypanel|dokploy|caprover")), ] REPO_HOST = {"vercel/vercel": "vercel", "netlify/cli": "netlify", "superfly/flyctl": "fly", "railwayapp/cli": "railway", "Azure-Samples/azure-search-openai-demo": "azure", "Azure-Samples/chat-with-your-data-solution-accelerator": "azure", "microsoft/sample-app-aoai-chatGPT": "azure", "GoogleCloudPlatform/generative-ai": "gcp", "GoogleCloudPlatform/agent-starter-pack": "gcp", "Azure-Samples/contoso-chat": "azure", "Azure-Samples/rag-postgres-openai-python": "azure", "replicate/cog": "replicate"} FRAMEWORKS = [ ("streamlit", rx(r"\bstreamlit\b")), ("gradio", rx(r"\bgradio\b")), ("chainlit", rx(r"\bchainlit\b")), ("nextjs", rx(r"next\.?js|\bnext (13|14|15|16)\b|app router|\bnext build\b")), ("remix", rx(r"\bremix\b")), ("sveltekit", rx(r"svelte")), ("nuxt", rx(r"\bnuxt")), ("vite_react", rx(r"\bvite\b")), ("astro", rx(r"\bastro\b")), ("fastapi", rx(r"fastapi|uvicorn")), ("flask", rx(r"\bflask\b")), ("django", rx(r"\bdjango\b")), ("express_node", rx(r"\bexpress\b|node\.?js")), ("hono", rx(r"\bhono\b")), ("langgraph", rx(r"langgraph")), ("langchain", rx(r"langchain")), ("llamaindex", rx(r"llama_?index|llama-index")), ("vercel_ai_sdk", rx(r"ai[- ]sdk|vercel/ai|@ai-sdk|useChat|streamText")), ("flowise", rx(r"flowise")), ("langflow", rx(r"langflow")), ("open_webui", rx(r"open[- ]?webui")), ("nextchat", rx(r"nextchat|chatgpt-next-web")), ("chatbot_ui", rx(r"chatbot[- ]ui")), ("cog", rx(r"\bcog (push|predict|build)\b|cog\.yaml")), ("tgi", rx(r"text-generation-inference|\btgi\b")), ("ollama", rx(r"\bollama\b")), ("vllm", rx(r"\bvllm\b")), ("dify", rx(r"\bdify\b")), ("ragflow", rx(r"ragflow")), ("anythingllm", rx(r"anything-?llm")), ("litellm", rx(r"litellm")), ("mastra", rx(r"\bmastra\b")), ("google_adk", rx(r"\badk\b|agent development kit")), ("crewai", rx(r"crew ?ai")), ("agno", rx(r"\bagno\b")), ("skypilot", rx(r"skypilot|\bsky (serve|launch)")), ] REPO_FRAMEWORK = {"streamlit/streamlit": "streamlit", "gradio-app/gradio": "gradio", "Chainlit/chainlit": "chainlit", "langchain-ai/langchain": "langchain", "langchain-ai/langchainjs": "langchain", "langchain-ai/langgraph": "langgraph", "vercel/ai": "vercel_ai_sdk", "ollama/ollama": "ollama", "ChatGPTNextWeb/NextChat": "nextchat", "mckaywrigley/chatbot-ui": "chatbot_ui", "FlowiseAI/Flowise": "flowise", "langflow-ai/langflow": "langflow", "run-llama/llama_index": "llamaindex", "open-webui/open-webui": "open_webui", "huggingface/text-generation-inference": "tgi", "replicate/cog": "cog", "stackblitz-labs/bolt.diy": "vite_react", "microsoft/sample-app-aoai-chatGPT": "flask", "langgenius/dify": "dify", "infiniflow/ragflow": "ragflow", "Mintplex-Labs/anything-llm": "anythingllm", "huggingface/chat-ui": "hf_chat_ui", "vercel/chatbot": "nextjs", "BerriAI/litellm": "litellm", "vllm-project/vllm": "vllm", "mastra-ai/mastra": "mastra", "google/adk-python": "google_adk", "crewAIInc/crewAI": "crewai", "agno-agi/agno": "agno", "skypilot-org/skypilot": "skypilot", "Azure-Samples/rag-postgres-openai-python": "fastapi", "Azure-Samples/contoso-chat": "prompty"} PROVIDERS = [ ("azure_openai", rx(r"azure[ _-]?open ?ai|\baoai\b")), ("openai", rx(r"\bopen ?ai\b|\bgpt-?[345o]|chatgpt")), ("anthropic", rx(r"anthropic|\bclaude\b(?![- ]code)(?! made| told| deployed| concludes)")), ("google", rx(r"gemini|vertex ?ai|palm\b")), ("aws_bedrock", rx(r"bedrock")), ("local_ollama", rx(r"\bollama\b|llama\.cpp|lm studio|\bgguf\b")), ("huggingface", rx(r"hugging ?face|transformers|\bhf_|inference endpoint|\btgi\b")), ("mistral", rx(r"mistral")), ("deepseek", rx(r"deepseek")), ("groq", rx(r"\bgroq\b")), ("openrouter", rx(r"openrouter")), ("replicate", rx(r"replicate")), ("cohere", rx(r"cohere")), ] REPO_PROVIDER = {"Azure-Samples/azure-search-openai-demo": "azure_openai", "Azure-Samples/chat-with-your-data-solution-accelerator": "azure_openai", "microsoft/sample-app-aoai-chatGPT": "azure_openai", "GoogleCloudPlatform/generative-ai": "google", "GoogleCloudPlatform/agent-starter-pack": "google", "Azure-Samples/contoso-chat": "azure_openai", "Azure-Samples/rag-postgres-openai-python": "azure_openai", "ollama/ollama": "local_ollama", "huggingface/text-generation-inference": "huggingface"} # credential words for secret_exposed; "token" alone is not one here (LLM tokens), it needs a qualifier _CRED = (r"(secrets?\b|credentials?|api[_ -]?keys?|(access|auth|bearer|github|gh|hf|hugging ?face|personal access|oauth|refresh|session|jwt|api|secret)[_ -]?tokens?\b|" r"passwords?|\.env\b|\.dev\.vars|private[_ -]?keys?|sensitive (files?|data|values?|info\w*))") _SEC_ACT = r"(?", " ", t or "", flags=re.S) t = re.sub(r"```.*?```", " ", t, flags=re.S) t = re.sub(r"`[^`]*`", " ", t) t = re.sub(r"https?://\S+", "", t) t = re.sub(r"[\w.+-]+@[\w-]+\.[\w.]+", "", t) t = re.sub(r"@[\w-]+", "@", t) t = re.sub(r"^\s*(#+.*|[-*] \[[ x]\].*|\*\*[^*]+\*\*:?\s*)$", " ", t, flags=re.M) t = re.sub(r"!\[[^\]]*\]\([^)]*\)", " ", t) return re.sub(r"\s+", " ", t).strip() def excerpt(body, n=30): w = clean(body).split() return " ".join(w[:n]) def first(rules, text): for lab, r in rules: if r.search(text): return lab return None def multi(rules, text, k=3): return ";".join([lab for lab, r in rules if r.search(text)][:k]) or None # relevance rules learned from the pilot's manual judgement (see report.md) NOT_DEPLOY = rx(r"deployment[_ ]?name|\bptu\b|serverless (api )?endpoint|bedrock marketplace|" r"(model|llm|embedding)s? (deployed|hosted) (via|with|by|in|on) (vllm|xinference|azure|tgi|ollama)|" r"(locally|local(ly)?[- ]deployed|my own) (model|llm|embedding)|deployed (embedding|chat|llm) model|" r"use (a |my )?(remote|locally) deployed") LOCAL = rx(r"\blocal(ly)? deploy\w*|\blocal(ly)? (docker|private|offline|intranet )?(docker |compose )?(deploy\w*|setup|install\w*)|docker local|docker desktop|\bwsl2?\b|truenas|langgraph dev\b|\bon my (mac|laptop|pc|machine)|desktop app|\.exe\b|" r"windows 1[01]\b.{0,40}(server|local)|test(ing)? (it |your agent )?locally|errors when testing locally") PITCH = rx(r"we('re| are) building|our (open-source )?platform|open-source platform for|happy to (help|contribute)|" r"\bwithdrawn\b|marketplace where agents|we have implemented") FEATURE = rx(r"^\s*(\[?feat(ure)?( request)?\]?[:\s]|add (support|a |an )|support (for )?|idea:|enhance|request:|" r"allow |make .* (easier|friendly)|proposal)") CLASSIFIER = rx(r"classifier|\baup\b|usage[- ]policy|safeguard|flag(s|ged)? .{0,30}(malicious|policy)|prompt[- ]injection") REMOTE_T = rx(r"vercel|netlify|cloudflare|fly\.io|flyctl|railway|render\b|heroku|azure|azd|cloud ?run|gcp|google cloud|aws|" r"lambda|sagemaker|ecs|eks|aks|gke|kubernetes|k8s|helm|spaces|streamlit cloud|production|prod\b|server|hosted|" r"vps|digitalocean|runpod|modal|replicate|supabase|langgraph (platform|cloud)|reasoning engine|agent engine|" r"inference endpoint|app service|container app|coolify|amplify|fargate|deploy\w*|serverless|edge") BUILDER_SELF = rx(r"(deploy\w*|host\w*|run\w*|install\w*) (the |custom |costum |own )?(bolt|blot)(\.diy)?\b|" r"\bbolt(\.diy)? (on|to|in) |bolt\.diy (is|on)|coolify|easypanel|docker|cloudflare runtime") # v3 (after the full-build sample): a generic cloud/vendor name in the title is not enough HOSTING_T = rx(r"vercel|netlify|railway|render\.com|onrender|\b(on|to) render\b(?!ing)(?! (the|a|an|it|html|markdown|text|images?)\b)|render (deploy\w*|blueprint|service)\b|" r"heroku|fly\.io|flyctl|cloud ?run|app service|container apps?|" r"aws lambda|\b(on|to|in|via) lambda\b|lambda (deploy\w*|layers?|cold start|timeouts?|function url|@edge|runtime)|" r"ecs\b|fargate|\beks\b|\bgke\b|\baks\b|kubernetes|\bk8s?\b|\bk3s\b|helm|openshift|hugging ?face spaces?|hf spaces?|" r"\b(on|to|in) (hf |hugging ?face |a |the |my )?spaces?\b(?! (between|in|and|before|after|at|around|instead|characters?|key))|\bspaces? (sdk|hardware|build|container|secrets|app|demo)|zerogpu|" r"sagemaker (deploy\w*|endpoint deploy\w*)|deploy\w* .{0,40}sagemaker|\b(on|in|to) (an? |the )?(aws|azure|gcp|google cloud|ec2|sagemaker)\b|" r"runpod|modal\.com|\bon modal\b|modal (deploy|serve|labs)|cloudformation|reverse proxy|nginx|traefik|ingress|cloudflared?[ -]tunnels?|\[serve\]|agent ?engine|reasoning engine|langgraph (platform|cloud)|" r"langsmith deploy|mastra cloud|supabase (edge )?functions?|cloudflare (workers?|pages)|workers?\.dev|amplify|" r"elastic beanstalk|app engine|digital ?ocean|coolify|docker[- ]compose|\bdocker\b|podman|\bvps\b|ec2|azd\b|streamlit (community )?cloud|" r"inference endpoints?|posit connect|sky serve|skyserve|firebase hosting|firebase (app|functions)|" r"(remote|cloud|linux|ubuntu|production|prod|company|shared|dedicated) (server|vm|instance|host|gpu)s?|\bon (a |the |my )?(remote )?(server|vm)\b") DEPLOY_VERB_T = rx(r"\bdeploy\w*|\bhosting\b|\bhosted\b|self[- ]host\w*|\bredeploy\w*|\bprovision\w*|\bpublish\w*|go(ing)? live|" r"\b(in|on|for|to) (the )?(production|prod)\b(?![- ](grade|ready|use|code|systems?|quality|patterns?))|production (only|server|environment|build|deployment|mode|setup)|(prod|production) (env|build)\b|" r"\bon (the )?server\b|\bazd up\b") NOT_DEPLOY_SENSE = rx(r"router|load ?balanc\w* (between|across) (models|deployments)|model deployment(?! (to|on|in) )|deployment[_ ]?(name|id)s?\b|" r"custom[- ]priced|cost map|\[usage\]|" r"deploy\w* (the )?(new |latest )?version|after (deploying|upgrading) (to )?(v|version)|gpu deployment|deployment (thinking|defaults|settings)|" r"(ios|macos|android) deployment|deployment target (too|for ios|version)|publish(ing)? (to )?(npm|pypi|the package|package)|published (package|version)|npm publish") # Rule 7: a cloud's managed AI API used as a client, not an app deployed on a host MANAGED_API_T = rx(r"vertex ?ai(?! agent ?engine)|bedrock|azure ?open ?ai|\baoai\b|ai foundry|azure ai (services|inference)|batch (prediction|api|inference|job)|" r"gemini api|openai api|workers ai|ai gateway|sagemaker(?! deploy)|\bvercel_ai_gateway|\bsagemaker_|" r"(serverless|provisioned|ptu|global|standard) (api |model )?(endpoint|deployment|throughput)") APP_HOST_T = rx(r"vercel(?! ai gateway)(?!_ai)|netlify|railway|render\.com|heroku|fly\.io|cloud ?run|app service|container apps?|lambda\b|ecs\b|fargate|eks|gke|aks|" r"kubernetes|k8s|helm|openshift|spaces?\b|(on|to|in) sagemaker|deploy\w* .{0,40}sagemaker|agent ?engine|reasoning engine|docker|vps|\bazd\b|app engine|cloudflare (workers?|pages)(?! ai)|" r"deploy\w* (my |the |our |a |an )?(app|agent|server|proxy|litellm|chatbot|bot|application|site|frontend|backend|ui)|" r"deploy\w* (a |the )?(model|llm|endpoint) (to|on|in) (azure ml|azure machine learning|sagemaker|vertex ai endpoint)|managed online endpoint") # Rule 9: CI / tests of a framework's cloud integration CI_T = rx(r"\bci\b|\[ci\]|^ci[:(]|github actions?|gh actions?|workflows? (fail\w*|run|broken)|\be2e\b|end[- ]to[- ]end tests?|integration tests?|unit tests?|" r"smoke ?tests?|regression tests?|flaky|\btests? (fail\w*|for|of|against|on|broken)|^\[?tests?\]?[:(]|ci[- ]failure|release (pipeline|workflow|job)") # Rule 6: app behaviour bugs; they need a link to the host (deploy, config, runtime) to stay in APP_BUG_T = rx(r"\b(ui|button|display\w*|markdown|chat history|hallucinat\w*|infinite loop|loops? forever|repeat(s|ing|ed)? (itself|the|output|answer)|" r"output (is )?(wrong|garbled|empty|incorrect)|answers?|citations?|i18n|translation|dark mode|theme|layout|css|font|style|" r"tool[- ]call\w*|function[- ]call\w*|structured output|tokeni[sz]\w*|accuracy|quality|reasoning (text|content)|thinking (text|content)|" r"cost tracking|spend|usage (data|tracking)|logs? (clutter|spam)|telemetry|metrics?|cach(e|ed|ing) tokens?|prompt_tokens)\b") HOST_LINK = rx(r"\b(deploy\w* (fail\w*|error\w*|broken|stuck|crash\w*|times? out)|fail\w* (to|when|while|after|on|in) (deploy\w*|start\w*|boot|run(ning)? (on|in))|" r"(cannot|can'?t|unable to|won'?t|doesn'?t|does not|not) (deploy|start|boot|connect|reach|access|load|run)|works? (fine )?locally|local(ly)? (works|fine)|" r"but not (on|in|when|after)|only (on|in|when) (deploy\w*|production|prod|spaces|vercel|k8s|kubernetes|docker|server)|" r"env\w*|config\w*|port|proxy|https?\b|ssl|tls|cors|domain|subpath|root[_ ]path|base[_ ]?path|timeout|timed out|memory|oom|ram|disk|volume|storage|" r"startup|start(s|ing)?|crash\w*|restart\w*|container|image|helm|chart|ingress|install\w*|permission|forbidden|40[134]|50[0234]|auth\w*|login|oauth|" r"secret|keys?|database|postgres|redis|network\w*|dns|websocket|stream\w*|cold start|scal\w*|replica\w*|pod|node|gpu|cuda|nccl|driver|build\w*|" r"read[- ]only|non[- ]?root|filesystem|mount\w*|bucket|s3|gcs|blob|iframe|static files?|assets?|routing|redirect\w*|404|session)\b") CC_NOISE = rx(r"browser pane|built-in browser|in-app browser|desktop|warp\b|oauth|connector|plugin|email|turnstile|challenge page|sub-?agents?|cowork|msix|" r"auto-?updat\w*|managed[- ](settings|mcp|config)|deployment (mode|surface|store|mount)|third-party deployment|custom-3p|org(anization)?[- ]skill|" r"skills? (deploy|publish)|marketplace|remote control|voice mode|install\.sh|binarydeployment|ssh remote|deployment target|ios|" r"model deployed instead|driver deployment|deployed instead of|56-agent|deploy(ed|s)? .{0,20}(sub-?)?agents\b") # Rule 4: an agent that deploys and hits its own limits (classifier, permission denied, false "it's deployed") CC_DEPLOY = rx(r"deploy\w*|production|\bprod\b|publish\w*|go live|vercel|netlify|cloudflare (workers?|pages)|firebase|railway|supabase|heroku|" r"fly\.io|cloud ?run|kubernetes|k8s|nginx|\bvps\b|\bserver\b|\bdomain\b|website|\bsite\b|\bhosting\b") CC_LIMIT = rx(r"classifier|auto[- ]?mode|blocked|blocks|denied|deny|refus\w*|flag\w*|false (positive|completion)|claim\w*|reported .{0,40}(success|working|deployed)|" r"without (asking|confirmation|permission|authori[sz]ation|warning)|unauthori[sz]ed|unrequested|unprompted|autonomous\w*|" r"(deployed|published|uploaded) .{0,40}(secret|credential|\.env|\.dev\.vars|sensitive)|secret|credential|wrong (project|account|repo)|destroy\w*|took down|broke") GENERIC_RE = filters.GENERIC_REPOS SERVING_REPOS = {"vllm-project/vllm", "ollama/ollama", "huggingface/text-generation-inference", "skypilot-org/skypilot", "replicate/cog"} AGENT_DEPLOY_REPOS = {"google/adk-python", "GoogleCloudPlatform/agent-starter-pack", "langchain-ai/langgraph", "mastra-ai/mastra", "crewAIInc/crewAI", "agno-agi/agno"} def relevance(t, title, text, alltext): """Rules v4 (owner decisions 2026-10-28). Returns (yes|no, unsure_reason or ''). unsure_reason marks rows the keywords cannot settle; they are judged by the reviewer.""" g, repo = t["group"], t["repo"] generic = g in ("host", "framework_generic") or repo in GENERIC_RE tclean = re.sub(r"vercel ai sdk|ai sdk|sandbox-vercel|@vercel/\S+|vercel/ai\b|vercel[_ ]ai[_ ]gateway|ai gateway", " ", title, flags=I) hosting, verb = bool(HOSTING_T.search(tclean)), bool(DEPLOY_VERB_T.search(tclean)) # rule 8: general frameworks and host CLIs need AI evidence in the thread itself (title, body, comments) if generic and not filters.AI_EVIDENCE.search(re.sub(r"gradio|streamlit|vercel|next\.?js|netlify", " ", alltext, flags=I)): return "no", "" if PITCH.search(text[:1500]): return "no", "" if repo == "anthropics/claude-code": if CC_NOISE.search(title) or NOT_DEPLOY_SENSE.search(title): return "no", "" if not CC_DEPLOY.search(title): return "no", "" # rule 4: the agent deploying (or claiming to) and hitting limits; rule 2: local docker build is not a host if re.search(r"local `?docker build|locally", title, I): return "no", "" if CC_LIMIT.search(title) or re.search(r"deploy\w*", title, I): return "yes", "" if CC_LIMIT.search(title) and re.search(r"deploy\w*|production|prod\b|publish", title, I) else "cc:deploy_context_unclear" return "no", "cc:host_word_only" if CLASSIFIER.search(title): return "no", "" if NOT_DEPLOY.search(text) and not re.search(r"deploy\w* (to|on|in) (vercel|netlify|azure|aws|gcp|cloud|render|railway|k8s|kubernetes|hugging)", title, I): return "no", "" remote = bool(HOSTING_T.search(re.sub(r"docker[- ]?(compose)?|podman", " ", tclean, flags=I))) if LOCAL.search(title) and not remote or LOCAL.search(text[:2500]) and not hosting: return "no", "" # rule 2: laptop, WSL, local GPU, "local docker deployment" if not remote and re.search(r"\b(macos|mac (intel|m[1-4])|windows(?!\.net)|apple silicon|rtx \d{4}|jetson|raspberry|offline (device|machine)|local (gpu|machine|computer))\b", title, I) \ and not re.search(r"works? (fine )?(on|in) (the |my )?local|locally|\bbut\b|\b(adk|mastra|azd|az|gcloud|vercel|wrangler|langgraph|flowise) (deploy|build|up|webapp)\b|deploy\w* (to|on) (?!(the |my |a )?(mac|windows|jetson|raspberry))|agent_engine|gh actions", title, I): return "no", "" # rule 2: a local machine named in the title if not (g in ("framework", "sample", "builder") or filters.AI.search(text)): return "no", "" if not (hosting or verb): return "no", "" # e.g. "Azure provider does not support ...", "AWS Bedrock ... structured output" # rule 7: managed AI API as a client own_host = g == "sample" or repo in SERVING_REPOS or repo in AGENT_DEPLOY_REPOS if MANAGED_API_T.search(title) and not APP_HOST_T.search(tclean): if own_host and (verb or re.search(r"\b(on|to|in) (gcp |google )?(vertex ai|sagemaker)\b", title, I)): pass # rule 3 / sample apps: the repo's own app or model server deployed on that cloud elif verb and re.search(r"deploy\w*", tclean, I): return "yes", "managed_api:deploy_word" else: return "no", "" if NOT_DEPLOY_SENSE.search(title) and not hosting: return "no", "" ci = bool(CI_T.search(title)) or any(re.search(r"ci[- ]failure|^ci$|area:ci|testing", l, I) for l in t["labels"]) if ci: # rule 9: CI/tests of a cloud integration are in; other CI is out return ("yes", "") if hosting else ("no", "ci:no_cloud_named" if verb else "") if repo == "BerriAI/litellm" and not (hosting or re.search(r"deploy\w* (litellm|the proxy|proxy)|docker|helm", title, I)): return "no", "" # LiteLLM "deployment" = a model entry in the router if repo in SERVING_REPOS and not hosting: # rules 2+3: model serving counts on a remote host only; "deploy a model" often means a local run if re.search(r"\b(server|production|prod|cluster|multi[- ]node|remote|cloud|container|docker|instance|api access|concurren\w*)\b", text[:2500], I): return "yes", "serving:host_not_named" return "no", "" if g == "host" and re.search(r"agent", title, I) and not re.search(r"app|deploy\w* (my|a|the)", title, I): return "no", "host:agent_tooling" if not hosting and not re.search(r"deploy\w*|hosting|hosted|self[- ]host|provision|publish|go(ing)? live|on (the )?server|azd up", tclean, I): return "yes", "production_only" # only "in production": a host is implied, the link may be weak # rule 6: an app bug seen on a server, with no link to the deploy, config or host runtime if APP_BUG_T.search(re.sub(r"chat-ui|open[- ]?webui|chatbot[- ]ui", " ", title, flags=I)) and not HOST_LINK.search(title): return "yes", "app_bug:host_link_unclear" return "yes", "" # thread_type (rule 5): what the thread is TT_PREFIX = [("pr_ci", rx(r"^\s*(\[(ci|test|tests|chore|build)\]|(ci|test|tests|chore)(\(\w+\))?:)")), ("docs", rx(r"^\s*(\[(docs?|documentation)\]|docs?(\(\w+\))?:|documentation:)")), ("feature", rx(r"^\s*(\[(feat(ure)?( request)?|enhancement|rfc|proposal|idea|request)\]|(feat|feature|feature request|enhancement|rfc|proposal|idea|request)(\(\w+\))?:)")), ("question", rx(r"^\s*(\[(question|usage|help|support|discussion)\]|(question|usage|help)(\(\w+\))?:)")), ("problem", rx(r"^\s*(\[(bug|bug report|installation|regression|model|refund)\]|bug(\(\w+\))?:)"))] ERRORISH = rx(r"\b(errors?|fail\w*|broken|break(s|ing)?|crash\w*|not work\w*|doesn'?t work|does not work|isn'?t working|cannot|can'?t|unable|won'?t|stuck|" r"timeouts?|timed out|exception|bug|wrong|incorrect|invalid|denied|refused|rejected|blocked|undefined|not found|hang(s|ing)?|freez\w*|" r"[45]\d\d|missing|issue with|problem with|no longer|regression|leak\w*|ignor\w*|without (asking|confirmation|permission))\b") FEATURE_T = rx(r"^\s*(add(ing)?|support(ing)?|allow|enable|provide|implement|introduce|make|expose|offer|create|let)\b|feature request|\bplease add\b|would be (nice|great|good|helpful)|" r"\bsupport for\b|\bproposal\b|\bshould (support|allow|be able)|\bwish\b|\bability to\b|\boption (to|for)\b|\bconfigurable\b") DOCS_T = rx(r"\bdocs?\b|documentation|readme|\bguide\b|tutorial|instructions?|\bexamples? (for|of|on)\b|recipe|cookbook|how-?to guide") QUESTION_T = rx(r"^\s*(how|what|which|why|where|when|is|are|can|could|does|do|should|any)\b|\?\s*$|\bhow (to|do|can|should)\b|is it possible|is there a way|" r"best (way|practice)|recommend\w*|guidance|help needed|need help|question") FEATURE_L = rx(r"enhancement|feature|rfc|proposal|integration request|idea") DOCS_L = rx(r"documentation|\bdocs?\b") QUESTION_L = rx(r"question|support|usage|answered|help wanted(?!.)|discussion") BUG_L = rx(r"\bbug\b|regression|crash|has repro|possible bug|🐞") CI_L = rx(r"ci[- ]failure|^ci$|area:ci|\btests?\b|flaky") def thread_type(t, title): labels = [l.lower() for l in t["labels"]] for lab, r in TT_PREFIX: if r.search(title): if lab == "docs" and re.search(r"(fail|error|broken|not working|outdated|wrong|incorrect)", title, I) and not DOCS_T.search(title): return "problem" return lab if CI_T.search(title) or any(CI_L.search(l) for l in labels): return "pr_ci" err = bool(ERRORISH.search(title)) if DOCS_T.search(title) and not err: return "docs" if any(DOCS_L.search(l) for l in labels) and not any(BUG_L.search(l) for l in labels): return "docs" if any(FEATURE_L.search(l) for l in labels) and not err: return "feature" if FEATURE_T.search(title) and not err: return "feature" if err or any(BUG_L.search(l) for l in labels): return "problem" if QUESTION_T.search(title) or any(QUESTION_L.search(l) for l in labels): return "question" if ERRORISH.search(t.get("body", "")[:1500]): return "problem" return "other" def code(t): title, body = t["title"], t["body"] others_c = [c for c in t["comments"] if not c["by_author"] and not c["is_bot"]] coms = " ".join(c["body"] for c in t["comments"]) text = title + "\n" + body repo, g = t["repo"], t["group"] out = {} alltext = text + "\n" + coms out["kw_relevant"], out["kw_unsure"] = relevance(t, title, text, alltext) out["kw_thread_type"] = thread_type(t, title) builder_self = g == "builder" and repo == "stackblitz-labs/bolt.diy" and bool(BUILDER_SELF.search(text[:2000])) # host: title first, then body, then repo default out["kw_target_host"] = first(HOSTS, title) or first(HOSTS, body) or REPO_HOST.get(repo) or "unspecified" # app type data_cue = re.search(r"\brag\b|retriev|vector|embedding|knowledge base|ai search|cognitive ?search|own data|your data|index(es)? ", text, I) if g == "builder" and not builder_self: at = "ai_generated_web_app" elif re.search(r"\bagents?\b|langgraph|crew|reasoning engine|agent engine|adk\b", text, I) or repo in ("langchain-ai/langgraph", "mastra-ai/mastra", "google/adk-python", "crewAIInc/crewAI", "agno-agi/agno", "GoogleCloudPlatform/agent-starter-pack"): at = "agent" elif repo in ("Azure-Samples/azure-search-openai-demo", "Azure-Samples/chat-with-your-data-solution-accelerator", "infiniflow/ragflow", "Mintplex-Labs/anything-llm", "Azure-Samples/rag-postgres-openai-python", "Azure-Samples/contoso-chat") or data_cue: at = "rag" elif repo in ("huggingface/text-generation-inference", "replicate/cog", "ollama/ollama", "vllm-project/vllm", "BerriAI/litellm", "skypilot-org/skypilot") or re.search(r"serv(e|ing) (the |a )?model|inference (server|endpoint)|model serving|sagemaker endpoint", text, I): at = "model_serving" elif repo in ("ChatGPTNextWeb/NextChat", "mckaywrigley/chatbot-ui", "huggingface/chat-ui", "vercel/chatbot", "Chainlit/chainlit", "open-webui/open-webui", "microsoft/sample-app-aoai-chatGPT") or re.search(r"chat ?bot|\bchat\b", text, I): at = "chatbot" else: at = "other" out["kw_app_type"] = at fw_default = "remix" if builder_self else (None if g == "builder" else REPO_FRAMEWORK.get(repo)) out["kw_framework"] = fw_default or first(FRAMEWORKS, text) or "unspecified" stack = [fw_default] + [lab for lab, r in FRAMEWORKS if r.search(text)] out["kw_stack"] = ";".join(dict.fromkeys(s for s in stack if s)) or None prov_text = text if repo != "anthropics/claude-code" else re.sub(r"claude|anthropic", " ", text, flags=I) out["kw_model_provider"] = multi(PROVIDERS, prov_text) or REPO_PROVIDER.get(repo) or "unspecified" # error type and category: title evidence first, then body err_t, err_b = first(ERRORS, title), first(ERRORS, body[:3000]) extra_t = first(CATEGORY_EXTRA, title) if err_t == "iac_template_error": # provisioning failures: prefer the inner cause when stated inner = first([e for e in ERRORS if e[0] in ("quota_billing", "permission_rbac")], body[:3000]) err_t = inner or err_t if err_t: cat, conf = CATEGORY_OF_ERROR[err_t], "title" elif extra_t: cat, conf = extra_t, "title" elif err_t: cat, conf = CATEGORY_OF_ERROR[err_t], "title" elif err_b: cat, conf = CATEGORY_OF_ERROR[err_b], "body" else: cat, conf = "other", "none" err = err_t or err_b or "other_unknown" if cat == "other": # topics added 2026-10-30; never replace an existing topic nt, agent_err = new_topic(repo, title, body[:3000]) if nt: cat = nt # the agent subtype replaces other_unknown, or a server_error_5xx found only in the body; # a 5xx seen in the title is kept. coding_confidence is left as is: it describes the evidence # for error_type and the 14 original topics, not for the three topics added 2026-10-30 if agent_err and (err == "other_unknown" or (err == "server_error_5xx" and conf == "body")): err = agent_err out["kw_error_type"] = err out["kw_topic"] = cat out["coding_confidence"] = conf # AI-generated app tool = first(AI_TOOLS, text) if re.search(r"(built|made|generated|created|wrote|written|vibe)[^.]{0,40}(with|by|using)|vibe.?cod", text, I) else None tool = REPO_AI_TOOL.get(repo) or tool if builder_self: out["kw_ai_generated_app"], out["kw_ai_tool"] = "no", None else: out["kw_ai_generated_app"] = "yes" if tool else "unknown" out["kw_ai_tool"] = tool # thread outcome maint = [c for c in others_c if c.get("assoc") in ("OWNER", "MEMBER", "COLLABORATOR")] out["maintainer_replied"] = "yes" if maint else "no" stale = any(re.search(r"stale|inactiv|auto-?clos", l, I) for l in t["labels"]) or any( re.search(r"stale|inactiv|automatically closed|no activity|closing (this|due)", c["body"], I) for c in t["comments"] if c["is_bot"] or not c["by_author"]) fix_words = r"(it )?works now|that (worked|fixed)|solved|resolved|fixed it|found (the|a) (fix|solution|problem|issue)|the (problem|issue) was|turns out|was related to|i fixed it|managed to" author_ok = any(c["by_author"] and re.search(fix_words + r"|thank(s| you).{0,40}(work|fix|help)", c["body"], I) for c in t["comments"]) \ or bool(re.search(r"i fixed it|update: .{0,40}(fixed|solved)", body, I)) dup = any(re.search(r"duplicate", l, I) for l in t["labels"]) or t.get("state_reason") == "duplicate" if t["state"] == "open": resolved = "yes" if author_ok else "no" else: resolved = "yes" if (t.get("state_reason") == "completed" and not stale) or author_ok else "no" out["resolved"] = resolved ocoms = " ".join(c["body"] for c in others_c) if dup: rt = "duplicate" elif not others_c: rt = "self_resolved" if author_ok else ("stale_closed" if stale and t["state"] == "closed" else "unanswered") elif re.search(r"not (intended|designed|supported|possible|planned)|limitation|by design|won'?t fix|out of scope|isn'?t supported|is not an? (actual )?(bug|flowise error)", ocoms, I) and t["state"] == "closed": rt = "platform_limit_no_fix" if not re.search(r"your (deployment )?environment|not a \w+ error", ocoms, I) else "user_error_config" elif re.search(r"fixed in|released in|(upgrade|update) to (the latest|v?\d)|new (version|release)|latest (version|release)|beta release|now fixed|merged a fix|merging a fix", ocoms, I): rt = "version_upgrade" elif re.search(r"downgrad|pin(ned)? to|roll(ed)? back to", coms, I): rt = "version_downgrade" elif re.search(r"workaround|work around|in the meantime|temporar|stopgap", coms, I): rt = "workaround" elif re.search(r"my (bad|mistake|fault)|typo|you forgot|user error|misconfig|your (deployment )?environment", coms, I): rt = "user_error_config" elif author_ok and re.search(r"\bset\b|config|setting|env(ironment)? var|--host|0\.0\.0\.0|add(ing)? .{0,20}to (your|the)|change", coms, I): rt = "config_fix" elif author_ok: rt = "self_resolved" elif stale and t["state"] == "closed": rt = "stale_closed" elif t["state"] == "open": rt = "open_unresolved" else: rt = "closed_unclear" out["kw_resolution_type"] = rt return out # repos removed after the full-build review (see repos_full.json _doc); kept in the pilot file DROPPED_REPOS = set() def main(): src = sys.argv[1] if len(sys.argv) > 1 else os.path.join(ROOT, "raw", "threads.jsonl") dst = sys.argv[2] if len(sys.argv) > 2 else os.path.join(ROOT, "raw", "coded_kw.jsonl") if "--drop-removed" in sys.argv: DROPPED_REPOS.update({"skypilot-org/skypilot", "replicate/cog"}) with open(dst, "w") as f: for line in open(src): t = json.loads(line) if t["repo"] in DROPPED_REPOS: continue if t["repo"] in filters.GENERIC_REPOS and t["group"] == "framework": t["group"] = "framework_generic" # rule 8: Gradio counts as a general framework rec = {k: v for k, v in t.items() if k not in ("body", "comments")} rec.update(code(t)) rec["excerpt_private"] = excerpt(t["body"]) f.write(json.dumps(rec) + "\n") if __name__ == "__main__": main()