Skip to content

feat: expand --focus to accept issue refs (closes #202)#213

Merged
akashgit merged 6 commits into
mainfrom
experiment/54-issue-flag
May 11, 2026
Merged

feat: expand --focus to accept issue refs (closes #202)#213
akashgit merged 6 commits into
mainfrom
experiment/54-issue-flag

Conversation

@akashgit
Copy link
Copy Markdown
Owner

Summary

Reworks the approach to issue targeting (originally PR #210). Instead of adding a separate --issue flag, expands --focus to auto-detect issue references:

factory ceo /path --focus 42                                    # bare number
factory ceo /path --focus "https://github.com/o/r/issues/42"   # URL
factory ceo /path --focus "owner/repo#42"                       # shorthand
factory ceo /path --focus "dashboard UI"                        # plain text (unchanged)
  • No new flag--focus does the right thing based on input shape
  • No duplication — shared _resolve_focus_issue() helper replaces copy-pasted blocks in cmd_ceo and cmd_run
  • Smaller mutual exclusion surface — all --issue-specific checks (5+ per command) collapse into existing --focus exclusions
  • Nested GitLab groups — fixes parse_issue_ref regex to handle group/subgroup/project/-/issues/N

Files changed

  • factory/issue.py — add is_issue_ref() detector, fix GitLab nested groups regex
  • factory/cli.py — add _resolve_focus_issue(), remove --issue from both subparsers, wire into cmd_ceo/cmd_run
  • CLAUDE.md — document --focus accepting issue refs
  • tests/test_issue.py — 34 tests: is_issue_ref, nested groups, _resolve_focus_issue integration, all parsing/fetching/formatting

Addresses all PR #210 review findings

Test plan

  • 34 unit tests pass (pytest tests/test_issue.py -v)
  • Lint clean (ruff check)
  • Type check clean (mypy factory/issue.py factory/cli.py)
  • Smoke test passes (pytest tests/test_models.py tests/test_guards.py tests/test_cli.py)
  • Real integration: fetched issue factory ceo --issue <url>: target a GitHub/GitLab issue directly #202 via bare number, URL, and shorthand — all resolved correctly

Closes #202, closes #211, closes #212

🤖 Generated with Claude Code

akashgit and others added 4 commits May 10, 2026 00:11
Adds the ability to point the factory at a GitHub or GitLab issue
directly, fetching the issue content and using it as the build spec.

- New module factory/issue.py with IssueSpec dataclass, parse_issue_ref,
  infer_remote, fetch_issue, and format_issue_as_spec
- --issue flag on both ceo and run subparsers
- Mutual exclusion with --prompt, --focus, --no-github, --mode interactive/research
- Issue spec persisted to .factory/strategy/current.md (same as --prompt)
- Issue number/URL passed through to _build_ceo_task for CEO directive
- 25 tests covering parsing, remote inference, formatting, fetching, and CLI validation

Closes #209

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fixes ordering bug in cmd_run where --issue validation happened after
the network call to fetch the issue. Also moves --no-github check in
cmd_ceo to early validation block. Adds missing cmd_run mutual exclusion
tests (4 new tests).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Instead of a separate --issue flag with its own mutual exclusion matrix,
--focus now auto-detects issue references (bare numbers, URLs, owner/repo#N)
and fetches them via gh/glab CLI. This eliminates duplicated validation code
between cmd_ceo and cmd_run and simplifies the CLI surface.

Changes:
- factory/issue.py: add is_issue_ref() detector, fix GitLab nested groups regex
- factory/cli.py: add _resolve_focus_issue() helper, remove --issue from both
  subparsers, wire focus resolution into cmd_ceo and cmd_run
- CLAUDE.md: document --focus accepting issue refs
- tests/test_issue.py: add is_issue_ref tests, nested GitLab groups test,
  _resolve_focus_issue integration tests, remove obsolete --issue CLI tests

Closes #211, closes #212

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 11, 2026

Codecov Report

❌ Patch coverage is 97.29730% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.20%. Comparing base (7521938) to head (9837a2a).

Files with missing lines Patch % Lines
factory/cli.py 92.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #213      +/-   ##
==========================================
+ Coverage   87.01%   87.20%   +0.19%     
==========================================
  Files          51       52       +1     
  Lines        7300     7440     +140     
==========================================
+ Hits         6352     6488     +136     
- Misses        948      952       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

akashgit and others added 2 commits May 10, 2026 22:31
- _resolve_focus_issue no longer calls sys.exit() — callers check
  no_github before calling, consistent with all other CLI error paths
- Returns 4-tuple (title, context, number, url) so callers can update
  the focus name to "Title (issue #N)" for better backlog/CEO context
- Fix indentation on split kwargs in cmd_run

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove redundant GitLab /-/issues/ pattern in is_issue_ref — already
  caught by the general /issues/ pattern above it
- Add test for unparseable git remote URL (file:// protocol)
- Add tests for _build_ceo_task issue embedding (with/without URL)
- Add test for cmd_run --focus + --no-github error path
- factory/issue.py now at 100% coverage

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant