feat(cli): detect Python projects during init - #270
Open
elMonsi wants to merge 1 commit into
Open
Conversation
`facility init` promised to detect a repository's package manager and checks, but detection only knew the Node ecosystem: a Python repo got packageManager "none", an empty check list, and a workflow stub reading "no Node toolchain detected". As the method doc argues, an agent with nothing to run cannot verify its work, so every non-Node repo began on exactly the empty job site Facility exists to prevent. Detect Python as a first-class ecosystem when no Node manifest is present: - pyproject.toml / requirements.txt / setup.py / setup.cfg / Pipfile select poetry, pipenv, or pip, and the matching dependency install command. - Checks are proposed only with configuration evidence (ruff/black/mypy tables or config files; pytest config, a tests/ dir, or conftest.py) and invoked through the tool's environment (poetry run / pipenv run). - The generated workflow renders a SHA-pinned actions/setup-python step, python-version quoted so YAML never reads 3.10 as a float, taken from .python-version when present. - Alembic migration layouts feed the database module hint. Node detection is unchanged and takes precedence. No runtime dependency is added; init still asks the operator to confirm every proposed default. Addresses theam#199 for the Python ecosystem; other stacks can follow the same shape. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
facility initpromises to "detect the repository's package manager and checks," but detection inpackages/cli/src/detect.mjsonly knows the Node ecosystem: it walkspnpm-lock.yaml → yarn.lock → package-lock.json → package.json, derives checks frompackage.jsonscripts, and otherwise returnspackageManager: "none"with an empty check list and a workflow stub reading "no Node toolchain detected."That collides with the core argument in
concepts/method.md— "the environment can't run anything, so verification is impossible, so the agent hedges … the fix is not a better prompt. It is a better job site." Today every Python (and other non-Node) repository begins on exactly that empty job site, so the delivery contract has nothing to bind against.This change makes Python a first-class detected ecosystem — a first step toward #199, in the shape other stacks can follow.
Changes
detect.mjs— when no Node manifest is present, probe for Python (pyproject.toml,requirements.txt,setup.py,setup.cfg,Pipfile):poetry install,pipenv install --dev,pip install -r requirements.txt, orpip install -e .).ruff/black/mypytables or config files, andpytestconfig / atests/dir /conftest.py— invoked through the tool's environment (poetry run …,pipenv run …). A dependency merely being present is not treated as proof the team runs it.python-versionfrom.python-versionwhen present (default3.x).alembic/versions,migrations/versions) for the database-module hint.init.mjs—toolchainStepsrenders a Python toolchain: a SHA-pinnedactions/setup-python@a26af69…(v5) step withpython-versionquoted so YAML never reads3.10as the float3.1, followed by the tool bootstrap and dependency install.Node detection is unchanged and takes precedence (a repo with
package.jsonstays a Node repo). No runtime dependency is added — no TOML parser, just presence checks and narrow text probes — andinitstill asks the operator to confirm every proposed default.Tests
New
packages/cli/test/detect.test.mjs:poetry install+poetry run …checks;requirements.txt→pip install -r requirements.txt, and a merely-listed tool does not become a check;pip install -e .;requirements.txtdoes not flip a Node repo);initrenders the pinned, quotedsetup-pythonstep and the detected install/check.Verification
Full
pnpm verifywas not run to completion locally: I'm on Windows, where two pre-existing, unrelated tests fail regardless of this change — the.agents/skillssymlink step (#230) and a CRLF line-ending mismatch in the watchtower canary assertion. I confirmed those two failures are identical on a clean checkout (stashing this change), so this PR introduces no regression; CI runs the full suite on Linux.