4.4 KiB
4.4 KiB
| adapter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Generic Adapter (Auto-Discovery Fallback)
This adapter activates when no language-specific adapter matches. Instead of assuming a specific language (previous behavior: defaulting to Go), it discovers commands from project conventions.
Discovery Strategy
1. Makefile Discovery
If a Makefile exists, parse targets:
# Extract make targets
grep -E '^[a-zA-Z_-]+:' Makefile | sed 's/:.*//'
Common target mappings:
| Target Pattern | Mapped Command |
|---|---|
build, compile |
commands.build |
test, check |
commands.test |
lint, lint-arch |
commands.lint, commands.lint_arch |
fmt, format |
commands.format |
run, start, serve |
commands.start |
dev, watch |
commands.dev |
2. README Discovery
If no Makefile, scan README.md for code blocks with common commands:
# Look for fenced code blocks with build/test commands
grep -A 2 '```' README.md
3. package.json Scripts Discovery (non-Node projects)
Some non-Node projects use package.json for script aliases:
# Check if package.json scripts exist
cat package.json | python3 -c "import sys,json; [print(k,v) for k,v in json.load(sys.stdin).get('scripts',{}).items()]"
4. docker-compose.yml Discovery
If docker-compose.yml exists, extract service definitions for environment setup.
When Generic Adapter Activates
The generic adapter is the last resort. It activates only when:
- No
go.mod,package.json,pyproject.toml,pom.xml,Cargo.tomlexists - Or when the user explicitly requests generic mode
Behavior Differences from Language-Specific Adapters
| Aspect | Language Adapter | Generic Adapter |
|---|---|---|
| Build command | Hardcoded default | Discovered from Makefile/README |
| Route detection | Framework-specific regex | Generic HTTP patterns only |
| Layer conventions | Language-idiomatic paths | Common directory names |
| Linter | Language-specific template | None (rely on existing tools) |
| CI template | Language-specific image | Ubuntu with custom steps |
Extending to New Languages
If you find yourself repeatedly using the generic adapter for a specific language,
that's a signal to create a proper language adapter. See adapter-schema.md for
the schema to follow.