feat: auto-detect language in init#40
Draft
joshbouncesecurity wants to merge 3 commits intoknostic:masterfrom
Draft
feat: auto-detect language in init#40joshbouncesecurity wants to merge 3 commits intoknostic:masterfrom
joshbouncesecurity wants to merge 3 commits intoknostic:masterfrom
Conversation
- Make --language optional in `openant init` (default: auto-detect) - Make git repository optional for local paths (use "nogit" placeholder) - Add shared config/languages.json for file extension mappings - Both Go (init.go) and Python (parser_adapter.py) load from the same config file, eliminating duplicated extension lists - Add .worktrees/ to .gitignore for worktree-based workflow Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add unit tests for ``detect_language`` covering Python, JS/TS, Go, skip-dir handling, and the empty-directory error path. These tests build synthetic fixtures with ``tmp_path`` and run without the Go toolchain, so they execute in every CI matrix configuration. Add a ``TestInit`` class to ``test_go_cli.py`` that drives the real binary and verifies: - auto-detect on the Python and JS fixtures - auto-detect on synthetic TypeScript and Go trees - explicit ``-l`` flag overrides auto-detection - non-git directory is initialized with a ``nogit`` placeholder SHA - ``--commit`` on a non-git path warns and falls back to ``nogit`` - empty directory fails with a clear "no supported source files" message Item 13 of #16.
Add two tmp_path tests (TS dominant over Python, Python dominant over JS) that exercise the dominance heuristic without relying on skip_dirs to mask competing extensions. Mention Zig in the init -l flag help and in the Go detectLanguage "no supported source files" error so the Go side matches the Python detector (which already lists Zig). The .zig extension is already present in config/languages.json.
Contributor
Author
Manual verification
|
Contributor
Author
Local test resultsBuilt the Go CLI from this branch on Windows and exercised auto-detect on the in-repo fixtures ( Commands run: Outcome:
Help text reads: |
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.
Summary
Makes
--languageoptional inopenant initby auto-detecting the project language from file extensions in the target path. Also drops the assumption that the path is a git repository for local-only mode. New users can runopenant init <path>and have it just work.Addresses item 13 from #16 (does not close the issue).
Test plan
openant init <python-repo>— language detected as Python.openant init <ts-repo>— language detected as TypeScript.openant init <repo> --language go— explicit flag wins.