Skip to content

Feature/ai nl parser - #15

Merged
huantrinh1802 merged 9 commits into
mainfrom
feature/ai-nl-parser
Sep 19, 2026
Merged

huantrinh1802 merged 9 commits into
mainfrom
feature/ai-nl-parser

Conversation

@huantrinh1802

Copy link
Copy Markdown
Owner

No description provided.

huantrinh1802 and others added 9 commits September 19, 2026 21:50
Why:
- Reduce friction of remembering taskwarrior attribute syntax by letting
  users describe tasks in plain language

What:
- Add tools/ai.py with provider-agnostic parse_nl_to_command() function
- Support Anthropic (claude-sonnet-4-6) and OpenAI (gpt-4o-mini) backends
- Late-import both SDKs so they remain optional dependencies
- Add anthropic and openai as optional deps under [extras] ai in pyproject.toml

Impact:
- No breaking change; providers only activate when explicitly used

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Why:
- Wire the AI parser into the CLI so users can run
  `twf ai "buy groceries tomorrow high priority"` directly

What:
- Add ai() command to main.py accepting free-form prompt as positional args
- --group / -g selects taskwarrior group (defaults to first in config)
- --provider / -p overrides AI provider (falls back to TW_AI_PROVIDER env,
  then "anthropic")
- Reuses existing confirmation + subprocess execution pattern from task_wrapper
- Import group_mappings_completion for --group autocompletion

Impact:
- No breaking change to existing commands

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Why:
- Users shouldn't have to set env vars just to use AI; TW_CONFIG is the
  existing single source of truth for all TWF settings

What:
- Add 'ai' section to default TW_CONFIG (provider, anthropic_api_key, openai_api_key)
- Update _parse_with_* to accept config_api_key; env var still wins over config
- Resolution order: CLI flag > env var > TW_CONFIG > default ("anthropic")
- Pass config_api_key through parse_nl_to_command to ai command in main.py
- Update error messages to reference both env var and TW_CONFIG options

Impact:
- No breaking change; existing env var usage continues to work unchanged

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Why:
- UV is significantly faster for installs and lock resolution, and
  hatchling is the standard PEP 517 backend for uv-managed projects

What:
- Replace [tool.poetry] with [project] (PEP 621); hatchling build backend
- Move scripts/extras/dev-deps to [project.scripts], [project.optional-dependencies],
  [dependency-groups] respectively
- Add [tool.hatch.build.targets.wheel] packages = ["tools"] for package discovery
- Remove poetry.lock (run `uv sync` to generate uv.lock)
- Update ci.yml: replace snok/install-poetry with astral-sh/setup-uv,
  use uv run for ruff/pytest, bump test matrix to 3.10/3.11/3.12
- Update python-publish.yml: use uv build + uv publish with UV_PUBLISH_TOKEN

Impact:
- Run `uv sync` to generate uv.lock; `uv sync --extra ai` for AI providers
- pipx install still works unchanged via PEP 517

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Why:
- Old README had minimal installation info and no mention of AI features
  or the UV migration

What:
- Add install instructions for standard and [ai] extra via pipx and uv
- Add configuration section documenting TW_CONFIG structure and AI key
  resolution order (CLI flag > env var > TW_CONFIG > default)
- Add AI natural language section with example inputs/outputs and option table
- Add development section with uv sync commands
- Fix related tools section

Impact:
- Documentation only; no code change

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Why:
- Complete the UV migration: uv.lock is the new source of truth for
  reproducible installs

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Why:
- Version reflects the new AI feature and UV migration
- Config default path had a typo (confg.json → config.json)
- README needed the updated default path and mtwd integration instructions

What:
- pyproject.toml: 0.5.2 → 0.6.0
- tools/__init__.py: fix typo confg.json → config.json
- README: update default config path to ~/.local/share/tw_flow/config.json,
  simplify default config example, add TW_CONFIG export instructions for
  m_taskwarrior_d.nvim users (bash/zsh/fish)

Impact:
- Existing users with TW_CONFIG set are unaffected
- New users get config at ~/.local/share/tw_flow/config.json

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Why:
- No external issue tracker is used for this project, so requiring
  issue links on TODOs adds noise with no benefit

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Why:
- Simplifying the default config broke tests that assumed the old 'task'
  group and 'Bills' template existed; also exposed a typo (confg.json)
  and a chicken-and-egg import ordering bug in the test setup

What:
- Add root conftest.py: pytest_configure hook writes a fixed TEST_CONFIG
  (personal + test groups, Bills template, Test project query) to TW_CONFIG
  before any tools module is imported
- tests/conftest.py: move tools imports into fixtures so they happen after
  pytest_configure has written the config file
- pyproject.toml: ignore ruff TD003 (missing issue link) — no issue tracker
- tools/__init__.py: fix typo confg.json → config.json in default path

Impact:
- Tests now pass on a fresh environment with no pre-existing config file

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@huantrinh1802
huantrinh1802 merged commit 944fee4 into main Sep 19, 2026
4 checks passed
@huantrinh1802
huantrinh1802 deleted the feature/ai-nl-parser branch September 19, 2026 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant