feat(import): --link-deps maps GitHub issue-body dependencies to pm edges#9
Conversation
…dges Opt-in second pass over `pm github import` that parses dependency references from issue BODIES (`Blocked by #N`, `Depends on owner/repo#N`, `Blocks #N`) and materializes them as pm dependency edges between the imported items, resolved through the existing `gh:owner/repo#N` provenance tags. Agents get the real ready/blocked ordering (`pm next`, `pm deps`) instead of a flat list — project management = context management. Implementation (index.ts): - parseDependencyReferences (pure): case/hyphen/colon-tolerant phrase grammar; bare `#N` + explicit `owner/repo#N`; multi-ref runs (`#1, #2 and #3`); fenced/inline code-span stripping; in-body dedupe. "Blocked by"/"Depends on" → blocked_by; "Blocks" → blocks. - buildProvenanceIndexFromMetadata + planDependencyLinks (pure): resolve refs to concrete edges; skip self-references, unresolved targets (counted), and issues whose source item is absent; dedupe edges. - linkImportedDependencies: best-effort, idempotent (`pm update --dep` dedupes by id+kind), path-agnostic (runs after the normal AND --atomic import). Ordering cycles the mapped edges introduce are reported, not rejected, via the SDK `collectNewOrderingCycleWarnings` advisory over the workspace before/after the pass — restoring the advisory that the `commitItemMutations` atomic path drops (its outcome carries only {id,op}). Result surface gains linkedDependencies / unresolvedDependencyRefs / orderingCycleWarnings (+ dependencyLinkFailures when non-empty); a `--dry-run --link-deps` result reports wouldLinkDependencyCandidates. peerDependency floor unchanged (>=2026.7.20 already exports both SDK fns). Tests: 25 new (parser/planner/provenance units, hermetic DI orchestration, 3 real end-to-end runImport cases) — full suite 164 green, typecheck clean, audit --omit=dev clean, changelog:check up to date. Verified against a real private repo over live REST: 3 dependency-phrased issues → 3 edges, code-block `#999` correctly ignored, `pm next` gating confirmed. Tracks pm item pm-github-hdai. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
WalkthroughAdds an opt-in ChangesGitHub dependency linking
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai full review |
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
|
✅ Action performedFull review finished. Your included review limit is currently reached under our Fair Usage Limits Policy. This review may still proceed through usage-based billing if eligible. Your next included review will be available in 37 minutes. |
|
@greptileai review |
|
@coderabbitai full review |
✅ Action performedFull review finished. |
Adversarial review found the second-pass call sites awaited linkImportedDependencies without guarding SDK-load / snapshot / advisory errors. On a host whose CLI predates the required SDK exports (or on a transient workspace-read error), the items commit, then the pass throws and runImport rejects — the caller sees a FAILED command despite a fully successful import, contradicting the feature's best-effort contract. Fix: linkImportedDependencies now wraps (1) SDK resolution + pre-edge snapshot — a failure returns linked:0 with a 'dependency linking skipped' note instead of throwing; and (2) the after-snapshot + ordering-cycle detector — a failure preserves the edges already written and records an 'ordering-cycle advisory skipped' note. Per-edge failures were already captured. +2 tests (27 link-deps / 166 total, all green). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Pushed d96512c addressing a robustness gap surfaced in review: the @coderabbitai full review |
|
✅ Action performedFull review finished. Your included review limit is currently reached under our Fair Usage Limits Policy. This review may still proceed through usage-based billing if eligible. Your next included review will be available in 38 minutes. |
Review trail (merging)All checks green on both commits ( To compensate for the throttled/unavailable bots, an independent adversarial review was run over the diff; it surfaced one MEDIUM robustness gap — the second pass could throw after a committed import on an older-CLI host — which is fixed in Merging on the green gate; happy to follow up on any findings CodeRabbit emits once its window reopens. |
…review loop complete Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
What
Adds an opt-in
--link-depsflag topm github importthat maps dependency references declared in GitHub issue bodies into pm dependency edges between the imported items.GitHub authors express dependencies in prose —
Blocked by #12,Depends on owner/repo#5,Blocks #9. A flat import discards that structure, so agents see an undifferentiated list of items with no blocker graph.--link-depsrecovers it: after the items are imported, a second pass resolves those references (through the existinggh:owner/repo#Nprovenance tags) and writes the correspondingblocked_by/blocksedges.pm nextandpm depsthen reflect the real ready/blocked ordering — project management = context management.pm github import owner/repo --link-deps pm github import owner/repo --atomic --link-deps pm github import owner/repo --link-deps --dry-run # reports candidate reference count onlyReference grammar
Case-insensitive;
-/:glue tolerated; multi-ref runs like#1, #2 and #3; bare#N(resolved against the imported repo) and explicitowner/repo#N.Blocked by #N/Depends on #Nblocked_by→ referenced itemBlocks #Nblocks→ referenced itemGuarantees
pm update --depdedupes by id+kind; re-import never duplicates edges.--atomicimport.unresolvedDependencyRefs); an individual failed edge never fails the import (reported independencyLinkFailures; the pass is re-runnable).y) regexes anchored at the exact position; no nested quantifier over unbounded input.orderingCycleWarnings, computed via the pm SDKcollectNewOrderingCycleWarningsadvisory over the workspace before/after the pass. This restores the advisory that thecommitItemMutationsatomic path drops (its outcome carries only{id,op}), matching the SDK's warn-don't-reject contract for legacy graph debt.Import result gains
linkedDependencies,unresolvedDependencyRefs,orderingCycleWarnings(+dependencyLinkFailureswhen non-empty);--dry-run --link-depsreportswouldLinkDependencyCandidates. The peerDependency floor is unchanged (>=2026.7.20already exports both SDK primitives).Tests
25 new tests (full suite 164 green), typecheck clean,
npm audit --omit=devclean,changelog:checkup to date:parseDependencyReferences(grammar, cross-repo, multi-ref, code-span stripping, dedupe,roadblocksnon-match),planDependencyLinks(self-ref / dangling / absent-source skips, dedupe),buildProvenanceIndexFromMetadata(first-writer-wins),countDependencyRefCandidates.linkImportedDependencies(apply, failures, no-op short-circuit, warning dedupe).runImport --link-depscases against a live pm tracker + SDK.Real-data verification: imported a private throwaway repo over live GitHub REST with 3 dependency-phrased issues → 3 edges written (
#2 blocked_by #1;#3 blocked_by #2 + #1), the#999inside a code block correctly ignored (0 unresolved), andpm nextcorrectly gated#2/#3behind#1. Repo deleted after.pm items
pm-github-hdaipm-cli-website-096t(relates to absorption epicpm-cli-website-7pnx— this PR substantively resolves its part-2, "adoptcollectNewOrderingCycleWarningsfleet-wide", by giving the SDK export a real use site).🤖 Generated with Claude Code
Summary by cubic
Adds an opt-in
--link-depsflag topm github importthat parses dependency phrases in GitHub issue bodies and writes pmblocked_by/blocksedges sopm nextandpm depsreflect real ready/blocked order. The pass is now hardened so SDK load/snapshot/advisory failures never reject a successful import; they’re reported and linking is skipped.New Features
#Norowner/repo#N) to edges; case-insensitive, allows-/:, supports multi-refs; ignores refs in code.--atomic;--dry-runreports candidate count.collectNewOrderingCycleWarningsfrom@unbrained/pm-cli; result fields:linkedDependencies,unresolvedDependencyRefs,orderingCycleWarnings(anddependencyLinkFailureswhen present).Bug Fixes
--link-depsinfra errors (SDK import, pre/after snapshots, cycle advisory) no longer fail the command post-import; edges already written are preserved and a clear note is returned.Written for commit d96512c. Summary will update on new commits.