Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ npx --yes @eshen_fox_mie/agent-ready ci --write

Current detectors cover common JavaScript/TypeScript, Python, Ruby, PHP, C#, Java, Kotlin, Rust, Go, and monorepo repositories:

- package manager: npm, pnpm, yarn, bun, pip, bundler, composer, dotnet, maven, gradle, cargo, go
- package manager: npm, pnpm, yarn, bun, Python/pip, Poetry, PDM, uv, bundler, composer, dotnet, maven, gradle, cargo, go
- commands: install, dev, start, build, test, lint, format, backend install, local services
- docs: README, architecture docs, ADR directories, existing agent docs
- CI: GitHub Actions workflows
Expand Down
2 changes: 1 addition & 1 deletion docs/detectors.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This page summarizes the current detector coverage. Claims here should stay alig
| Ecosystem | Detected signals | Frameworks/tools | Inferred commands |
| --- | --- | --- | --- |
| JavaScript / TypeScript | `package.json`, lockfiles, package scripts, framework configs, route/component conventions | React, Vite, Next.js, Next.js App Router, Vue, Nuxt, Astro, Svelte, SvelteKit, Express, NestJS, Vitest, Jest, Playwright, Storybook | package manager install, `dev`, `start`, `build`, `test`, `lint`, `format` from scripts |
| Python | `pyproject.toml`, `requirements.txt`, `setup.py`, `tests/` | FastAPI, Django, Flask, Pytest, Ruff | `python3 -m pip install ...`, `python3 -m pytest`, Ruff lint/format |
| Python | `pyproject.toml`, `requirements.txt`, `setup.py`, `poetry.lock`, `pdm.lock`, `uv.lock`, `tests/` | FastAPI, Django, Flask, Pytest, Ruff | pip, Poetry, PDM, or uv install/test commands plus Ruff lint/format |
| Ruby | `Gemfile`, `config/application.rb`, `bin/rails` | Rails | `bundle install`, `bin/rails server`, `bin/rails test` |
| PHP | `composer.json`, `artisan`, `app/Http/Kernel.php` | Laravel | `composer install`, `php artisan serve`, `php artisan test` |
| C# / .NET | `*.csproj`, `*.sln`, `global.json`, `Program.cs` | .NET | `dotnet restore`, `dotnet build`, `dotnet test` |
Expand Down
36 changes: 31 additions & 5 deletions src/scanner.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,19 @@ async function detectPackageManager(root, files = []) {
["bun", "bun.lockb"],
["bun", "bun.lock"],
["npm", "package-lock.json"],
["poetry", "poetry.lock"],
["pdm", "pdm.lock"],
["uv", "uv.lock"],
];
for (const [name, file] of checks) {
if (await pathExists(path.join(root, file))) return name;
}
if (await pathExists(path.join(root, "package.json"))) return "npm";
if (await pathExists(path.join(root, "pyproject.toml"))) return "python";
const pyproject = await readTextIfExists(path.join(root, "pyproject.toml"));
if (hasPythonToolConfig(pyproject, "poetry")) return "poetry";
if (hasPythonToolConfig(pyproject, "pdm")) return "pdm";
if (hasPythonToolConfig(pyproject, "uv")) return "uv";
if (pyproject) return "python";
if (await pathExists(path.join(root, "Cargo.toml"))) return "cargo";
if (await pathExists(path.join(root, "go.mod"))) return "go";
if (await pathExists(path.join(root, "mvnw")) || await pathExists(path.join(root, "pom.xml"))) return "maven";
Expand All @@ -164,13 +171,13 @@ async function detectCommands({ root, packageJson, packageManager, pyproject, ca
}

if (pyproject || files.includes("requirements.txt") || files.includes("setup.py")) {
commands.install ||= pyproject ? "python3 -m pip install -e ." : "python3 -m pip install -r requirements.txt";
commands.install ||= pythonInstallCommand(packageManager, Boolean(pyproject));
if (hasPythonTool(pyproject, "pytest") || files.some((file) => /^tests?\//.test(file))) {
commands.test ||= "python3 -m pytest";
commands.test ||= pythonRunCommand(packageManager, "pytest");
}
if (hasPythonTool(pyproject, "ruff")) {
commands.lint ||= "python3 -m ruff check .";
commands.format ||= "python3 -m ruff format .";
commands.lint ||= pythonRunCommand(packageManager, "ruff check .");
commands.format ||= pythonRunCommand(packageManager, "ruff format .");
}
}

Expand Down Expand Up @@ -252,11 +259,30 @@ function runScriptCommand(packageManager, script) {
return `npm run ${script}`;
}

function pythonInstallCommand(packageManager, hasPyproject) {
if (packageManager === "poetry") return "poetry install";
if (packageManager === "pdm") return "pdm install";
if (packageManager === "uv") return "uv sync";
return hasPyproject ? "python3 -m pip install -e ." : "python3 -m pip install -r requirements.txt";
}

function pythonRunCommand(packageManager, command) {
if (packageManager === "poetry") return `poetry run ${command}`;
if (packageManager === "pdm") return `pdm run ${command}`;
if (packageManager === "uv") return `uv run ${command}`;
return `python3 -m ${command}`;
}

function hasPythonTool(pyproject, tool) {
if (!pyproject) return false;
return new RegExp(`(^|[^a-zA-Z0-9_-])${escapeRegExp(tool)}([^a-zA-Z0-9_-]|$)`, "i").test(pyproject);
}

function hasPythonToolConfig(pyproject, tool) {
if (!pyproject) return false;
return new RegExp(`^\\s*\\[tool\\.${escapeRegExp(tool)}(?:\\.|\\])`, "im").test(pyproject);
}

function detectName({ packageJson, pyproject, cargoToml, goMod, pomXml, composerJson, files, root }) {
if (packageJson?.name) return packageJson.name;
const pyName = parseTomlValue(pyproject, "name");
Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/pdm-python-app/app/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def hello():
return "pdm"

2 changes: 2 additions & 0 deletions test/fixtures/pdm-python-app/pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions test/fixtures/pdm-python-app/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[project]
name = "fixture-pdm-python-app"
version = "0.1.0"
dependencies = ["flask"]

[dependency-groups]
dev = ["pytest", "ruff"]

[tool.pdm]
distribution = false

6 changes: 6 additions & 0 deletions test/fixtures/pdm-python-app/tests/test_main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from app.main import hello


def test_hello():
assert hello() == "pdm"

3 changes: 3 additions & 0 deletions test/fixtures/poetry-python-app/app/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def hello():
return "poetry"

2 changes: 2 additions & 0 deletions test/fixtures/poetry-python-app/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions test/fixtures/poetry-python-app/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[tool.poetry]
name = "fixture-poetry-python-app"
version = "0.1.0"
description = "Fixture for Poetry package manager detection."
authors = ["Fixture <fixture@example.com>"]

[tool.poetry.dependencies]
python = "^3.11"
fastapi = "^0.115.0"

[tool.poetry.group.dev.dependencies]
pytest = "^8.0.0"
ruff = "^0.8.0"

6 changes: 6 additions & 0 deletions test/fixtures/poetry-python-app/tests/test_main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from app.main import hello


def test_hello():
assert hello() == "poetry"

3 changes: 3 additions & 0 deletions test/fixtures/uv-python-app/app/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def hello():
return "uv"

11 changes: 11 additions & 0 deletions test/fixtures/uv-python-app/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[project]
name = "fixture-uv-python-app"
version = "0.1.0"
dependencies = ["django"]

[dependency-groups]
dev = ["pytest", "ruff"]

[tool.uv]
package = true

6 changes: 6 additions & 0 deletions test/fixtures/uv-python-app/tests/test_main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from app.main import hello


def test_hello():
assert hello() == "uv"

2 changes: 2 additions & 0 deletions test/fixtures/uv-python-app/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions test/scanner.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,28 @@ test("scan detects Python, Rust, and Go repositories", async () => {
assert.equal(go.commands.test, "go test ./...");
});

test("scan detects Python package managers", async () => {
const poetry = await scanRepo(fixture("poetry-python-app"));
const pdm = await scanRepo(fixture("pdm-python-app"));
const uv = await scanRepo(fixture("uv-python-app"));

assert.equal(poetry.packageManager, "poetry");
assert.equal(poetry.commands.install, "poetry install");
assert.equal(poetry.commands.test, "poetry run pytest");
assert.equal(poetry.commands.lint, "poetry run ruff check .");
assert.equal(poetry.commands.format, "poetry run ruff format .");

assert.equal(pdm.packageManager, "pdm");
assert.equal(pdm.commands.install, "pdm install");
assert.equal(pdm.commands.test, "pdm run pytest");
assert.equal(pdm.commands.lint, "pdm run ruff check .");

assert.equal(uv.packageManager, "uv");
assert.equal(uv.commands.install, "uv sync");
assert.equal(uv.commands.test, "uv run pytest");
assert.equal(uv.commands.lint, "uv run ruff check .");
});

test("scan handles Go and Rust web framework edge cases", async () => {
const goGin = await scanRepo(fixture("go-gin-cmd-app"));
const rustWorkspace = await scanRepo(fixture("rust-workspace-web"));
Expand Down