mirror of
https://github.com/codeflash-ai/codeflash-internal.git
synced 2026-05-04 18:25:18 +00:00
Three private tiles published to the codeflash workspace: - codeflash-internal-rules: 6 eager rules (code-style, architecture, optimization-patterns, git-conventions, testing-rules, multi-language-handlers) - codeflash-internal-docs: 8 lazy doc pages (domain-types, optimization-pipeline, test-generation-pipeline, context-extraction, aiservice/cf-api endpoints, configuration-thresholds, llm-provider-abstraction) - codeflash-internal-skills: 4 on-demand skills (debug-optimization-failure, add-language-support, add-api-endpoint, debug-test-generation)
2.1 KiB
2.1 KiB
Code Style
Python (aiservice)
- Python 3.12+ — use modern syntax (type unions
X | Y,matchstatements) - Line length: 120 characters
- Tooling: Ruff for linting/formatting (
ruff check .,ruff format .), mypy strict mode, ty for type checking, prek for pre-commit (uv run prek run --all-files) - Package management: Always use
uv— run commands viauv run - Comments: Minimal — only explain "why", not "what"
- Docstrings: Do not add unless explicitly requested
- Source transforms: Use
libcstfor code modification/transformation (preserves formatting);astis acceptable for read-only analysis - Async: All endpoints are
async def— runs under ASGI via uvicorn. Useasyncio.TaskGroupfor concurrent operations - Schemas: Use Pydantic
BaseModelorninja.Schemafor all request/response types - LLM calls: Use
aiservice/llm.py— never call provider APIs directly - Prompts: Stored as
.mdfiles alongside their modules, rendered with Jinja2 - Lazy imports: Use inside function bodies in routers to avoid circular dependencies (
# noqa: PLC0415)
JavaScript/TypeScript (cf-api, cf-webapp, VSC-Extension)
- All JS/TS packages use ESLint + Prettier. Run commands from each package directory
- cf-api: Express app. Webhook routes MUST be registered before body parser (raw body needed for signature verification).
instrument.tsmust be imported first in entry point (Sentry). Tests use dependency injection:setXxxDependencies()/resetXxxDependencies() - cf-webapp: Next.js. Default to server components;
"use client"only for interactivity. Server actions in"use server"files. Prisma queries in server components only. Path alias@/*→./src/* - VSC-Extension: Different prettier config (80 width + semicolons vs 100/no-semi elsewhere). npm workspaces for local
@codeflash/*packages. Sidebar is a separate Vite/React app embedded via webview postMessage - Prisma: Schema in
common/prisma/schema.prisma, shared by cf-api and cf-webapp.commonis CommonJS — userequire-style imports