Skip to content

fix(tasks): switch cwd detection from removed for-cwd to view . --json - #42

Merged
muqsitnawaz merged 1 commit into
mainfrom
fix/consumer-view-switch
Sep 1, 2026
Merged

fix(tasks): switch cwd detection from removed for-cwd to view . --json#42
muqsitnawaz merged 1 commit into
mainfrom
fix/consumer-view-switch

Conversation

@muqsitnawaz

Copy link
Copy Markdown
Contributor

Why

agi-cli deleted agents projects for-cwd and folded cwd→project detection into agents projects view <path> --json (PHNX-3704 / agi-cli #3380, merged + released). linear-cli main's resolve_cwd_project still calls the now-removed for-cwd, so on an updated agents binary it falls open to unscoped — the regression the unreleased 0.20.0 auto-scope was about to ship.

What

  • resolve_cwd_project → a single agents projects view . --json call. It longest-matches the cwd over every bound root + monorepo subpath and returns {name, linear:{name, projectId}, root} in one shot (unmatched cwd → null fields, exit 0). Replaces the two-call for-cwd + list dance.
  • Same fail-open contract: missing binary / timeout / nonzero / bad JSON / no match → (None, None), never raises.
  • Amends the unreleased 0.20.0 CHANGELOG (latest tag is v0.19.1; no version bump).

Verified

  • python3 -m unittest test_linear132 pass (ResolveCwdProjectTest rewritten to the single view call).
  • Live against the installed agents (which already has view, lacks for-cwd):
    • from agents/prixproject: {name: Prix, auto: true}, scope all, 64 tasks
    • from /tmpproject: null, unscoped

Closes the consumer half of PHNX-3704. After merge → cut linear-cli 0.20.0.

…json`

agi-cli (agents-cli) deleted `agents projects for-cwd` and folded cwd→project
detection into `agents projects view <path> --json` (PHNX-3704, agi-cli #3380,
merged + released). linear-cli's resolve_cwd_project still called the now-gone
`for-cwd`, so on an updated `agents` binary it fell open to unscoped — a
regression the 0.20.0 auto-scope was about to ship.

Rewrite resolve_cwd_project to a SINGLE `agents projects view . --json` call:
it longest-matches the cwd over every bound root + monorepo subpath and returns
`{name, linear:{name, projectId}, root}` in one shot (an unmatched cwd returns
null fields, exit 0). Replaces the previous two-call `for-cwd` + `list` dance.
Same fail-open contract (missing binary / timeout / nonzero / bad JSON / no
match → (None, None), never raises). Amends the unreleased 0.20.0 CHANGELOG.

Tests: ResolveCwdProjectTest rewritten to the single view call; 132 pass.
Live: from prix/ scopes to Prix via view . --json; from /tmp unscoped —
verified against the installed agents that already has view and lacks for-cwd.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@prix-cloud

prix-cloud Bot commented Sep 1, 2026

Copy link
Copy Markdown

Code Reviewer

Verdict: Ready to merge

Build: ✅ Compiles cleanly (Python syntax check, py_compile)
Tests: ✅ 132 pass, 0 failures, 0 errors (all test_linear)

Summary

Replaces the two-call agents projects for-cwd --json + agents projects list --json dance with a single agents projects view . --json call, matching the upstream agi-cli API change (PHNX-3704 / agi-cli #3380). The new call returns the matched project's Linear binding ({name, linear: {name, projectId}, root}) in one shot.

Changes that work well

  • Strictly simpler code. The _agents_json helper is removed entirely — the single subprocess call is inlined with the same fail-open error handling, saving ~9 lines of indirection.
  • Same fail-open contract. Every edge case the original handled (OSError/ValueError/SubprocessError, nonzero exit, empty stdout, bad JSON, non-dict response, missing linear key) is preserved. (None, None) is returned for all of them.
  • Tests updated precisely. Each of the 6 ResolveCwdProjectTest cases was rewritten to match the new single-call pattern, including the renamed test_view_without_linear_binding_is_none (was test_def_without_linear_binding_is_none).
  • lin = data.get("linear") or {} is correct — handles both "linear": None (unbound cwd) and a missing key uniformly, yielding {} and then (None, None) from the subsequent .get() calls.
  • CHANGELOG is amended cleanly within the unreleased 0.20.0 section (no version bump needed since latest tag is v0.19.1).

Issues

None found. The diff is a straightforward API consumer switch with complete test coverage and no observable behavior changes.


Reviewed by Code Reviewer — actually ran the build and tests on this branch (132/132 pass).

@muqsitnawaz
muqsitnawaz merged commit 6c8af83 into main Sep 1, 2026
5 checks passed
@muqsitnawaz
muqsitnawaz deleted the fix/consumer-view-switch branch September 1, 2026 11:48
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