app-anything GitHub

Add a detector

Detectors run only inside init: they look at project files and propose manifest fragments. The working examples are src/app_anything/project/detect/backend.py (the Flask, FastAPI, Express and plain-HTTP detectors) and frontend.py (static, Vite, Next, CRA), with contract tests in tests/contract/test_builtins.py.

1. One trigger, one proposal

@detector("deno", Facet.BACKEND)
class DenoDetector:
    def detect(self, root: Path) -> Proposal | None:
        if not _imports_deno(root):
            return None
        return Proposal(
            DetectorMeta("deno", Facet.BACKEND),
            {
                "backend": {
                    "runtime": "deno>=2",
                    "entry": "deno task start",
                    "sources": ["main.ts"],
                    "lock": "deno.lock",
                    "health": "/healthz",
                }
            },
        )

Rules of thumb from the builtin detectors:

2. Register and test

init collects every detector automatically once the module is listed in builtin_contributions(). Subclass DetectorContract (app_anything.sdk.testing) with a positive_root that triggers yours and let the suite assert the proposal shape — including that an empty root yields None.

3. Keep the example honest

Point your detector at a real-world shape and add it to examples/ if it is a new stack: the suite runs init over every example, so a detector that only works on synthetic files will be caught.

Rendered from docs/how-to/add-a-detector.md on main.