feat(import): --link-deps maps GitHub issue-body dependencies to pm edges
What
Adds an opt-in --link-deps flag to pm github import that 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-deps recovers it: after the items are imported, a second pass resolves those references (through the existing gh:owner/repo#N provenance tags) and writes the corresponding blocked_by / blocks edges. pm next and pm deps then 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 only
Reference grammar
Case-insensitive; -/: glue tolerated; multi-ref runs like #1, #2 and #3; bare #N (resolved against the imported repo) and explicit owner/repo#N.
| Phrase | pm edge on the source item |
|---|---|
Blocked by #N / Depends on #N | blocked_by → referenced item |
Blocks #N | blocks → referenced item |
Guarantees
- Idempotent —
pm update --depdedupes by id+kind; re-import never duplicates edges. - Path-agnostic — runs identically after the normal and
--atomicimport. - Safe — refs inside fenced/inline code spans are ignored; self-references and refs to issues absent from the workspace are skipped (the latter counted as
unresolvedDependencyRefs); an individual failed edge never fails the import (reported independencyLinkFailures; the pass is re-runnable). - ReDoS-free parser — phrase + reference scanning is linear via sticky (
y) regexes anchored at the exact position; no nested quantifier over unbounded input. - Cycle-aware, not cycle-blocking — ordering cycles the mapped edges introduce are reported in
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 (+ dependencyLinkFailures when non-empty); --dry-run --link-deps reports wouldLinkDependencyCandidates. The peerDependency floor is unchanged (>=2026.7.20 already exports both SDK primitives).
Tests
25 new tests (full suite 164 green), typecheck clean, npm audit --omit=dev clean, changelog:check up to date:
- Pure units:
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. - Hermetic DI orchestration for
linkImportedDependencies(apply, failures, no-op short-circuit, warning dedupe). - 3 real end-to-end
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 #999 inside a code block correctly ignored (0 unresolved), and pm next correctly gated #2/#3 behind #1. Repo deleted after.
pm items
- Feature:
pm-github-hdai - Companion tracker:
pm-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-deps flag to pm github import that parses dependency phrases in GitHub issue bodies and writes pm blocked_by/blocks edges so pm next and pm deps reflect 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
- Maps “Blocked by/Depends on/Blocks” refs (bare
#Norowner/repo#N) to edges; case-insensitive, allows-/:, supports multi-refs; ignores refs in code. - Idempotent and best-effort: skips self and missing targets; works with or without
--atomic;--dry-runreports candidate count. - Emits ordering-cycle warnings via
collectNewOrderingCycleWarningsfrom@unbrained/pm-cli; result fields:linkedDependencies,unresolvedDependencyRefs,orderingCycleWarnings(anddependencyLinkFailureswhen present). - README updated; 27 tests added (incl. end-to-end); full suite 166 green.
- Maps “Blocked by/Depends on/Blocks” refs (bare
-
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.