@unbrained/pm-cli 2026.7.17 → 2026.7.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +2 -2
- package/CHANGELOG.md +13 -0
- package/dist/cli/commands/close.d.ts +1 -1
- package/dist/cli/commands/close.js +3 -3
- package/dist/cli/commands/close.js.map +1 -1
- package/dist/cli/commands/completion.js +47 -5
- package/dist/cli/commands/completion.js.map +1 -1
- package/dist/cli/commands/context.d.ts +2 -2
- package/dist/cli/commands/context.js +42 -28
- package/dist/cli/commands/context.js.map +1 -1
- package/dist/cli/commands/contracts.js +5 -3
- package/dist/cli/commands/contracts.js.map +1 -1
- package/dist/cli/commands/graph.d.ts +7 -0
- package/dist/cli/commands/graph.js +11 -0
- package/dist/cli/commands/graph.js.map +1 -0
- package/dist/cli/commands/index.d.ts +1 -0
- package/dist/cli/commands/index.js +3 -2
- package/dist/cli/commands/index.js.map +1 -1
- package/dist/cli/commands/next.d.ts +1 -1
- package/dist/cli/commands/next.js +3 -3
- package/dist/cli/commands/next.js.map +1 -1
- package/dist/cli/main.js +3 -2
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/register-list-query.js +49 -7
- package/dist/cli/register-list-query.js.map +1 -1
- package/dist/cli/register-mutation.js +7 -3
- package/dist/cli/register-mutation.js.map +1 -1
- package/dist/cli-bundle/bundle-manifest.json +157 -149
- package/dist/cli-bundle/chunks/{chunk-N7I2DGLP.js → chunk-35FHWD4C.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-37V5MXAU.js.map → chunk-35FHWD4C.js.map} +1 -7
- package/dist/cli-bundle/chunks/{chunk-MSGETE6I.js → chunk-3CUQZNQ6.js} +67 -509
- package/dist/cli-bundle/chunks/chunk-3CUQZNQ6.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-3QDR6ZLU.js +800 -0
- package/dist/cli-bundle/chunks/chunk-3QDR6ZLU.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-QNUAZYGW.js → chunk-43UMFKCK.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-HF63SBLC.js → chunk-6VHUGVNP.js} +39 -16
- package/dist/cli-bundle/chunks/chunk-6VHUGVNP.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-B6SH2YNN.js → chunk-7R6UIHYY.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-NCAFUBJX.js → chunk-7UCY6DR5.js} +183 -12
- package/dist/cli-bundle/chunks/chunk-7UCY6DR5.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-23TCGBRK.js → chunk-ADXDCAKP.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-7LTCLTRG.js → chunk-AXRT7K5V.js} +16 -3
- package/dist/cli-bundle/chunks/chunk-AXRT7K5V.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-P56LKFQX.js → chunk-BDA35QG5.js} +34 -4
- package/dist/cli-bundle/chunks/chunk-BDA35QG5.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-2MPMKJF2.js → chunk-DHNG452T.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-AFSV5HBB.js → chunk-E4FXM2XB.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-QKVVV6QO.js → chunk-EWIT5WIC.js} +3 -3
- package/dist/cli-bundle/chunks/chunk-EX7OQT3Y.js +783 -0
- package/dist/cli-bundle/chunks/chunk-EX7OQT3Y.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-LLODAQMP.js → chunk-F3VC3GOV.js} +41 -18
- package/dist/cli-bundle/chunks/chunk-F3VC3GOV.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-S46R2M3W.js → chunk-GKPCTQYG.js} +1709 -5
- package/dist/cli-bundle/chunks/chunk-GKPCTQYG.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-HXVHBERL.js → chunk-HPAYDSR2.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-XNPMDSQQ.js → chunk-HYTOJW2Q.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-V3VBXQQV.js → chunk-I3INI567.js} +516 -429
- package/dist/cli-bundle/chunks/chunk-I3INI567.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-V7MP6YTN.js → chunk-IL5SPRMH.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-YQCWK2MB.js → chunk-L5BTTDU5.js} +68 -503
- package/dist/cli-bundle/chunks/chunk-L5BTTDU5.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-SIJV365F.js → chunk-NCVT6XEL.js} +17 -4
- package/dist/cli-bundle/chunks/chunk-NCVT6XEL.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-DCC2AQBD.js → chunk-OGVTB5VO.js} +32 -31
- package/dist/cli-bundle/chunks/chunk-OGVTB5VO.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-6XAZB6SE.js → chunk-QPGQNLPI.js} +1660 -7
- package/dist/cli-bundle/chunks/chunk-QPGQNLPI.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-KOEZCHRF.js → chunk-QRZNCRNA.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-G6KM4YKY.js → chunk-RXPQ5Q23.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-7CTQ7WW5.js → chunk-SIPOACV5.js} +514 -427
- package/dist/cli-bundle/chunks/chunk-SIPOACV5.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-XYJK6GIQ.js → chunk-TGBTLGPX.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-37V5MXAU.js → chunk-TLWJP5BF.js} +3 -3
- package/dist/cli-bundle/chunks/chunk-TLWJP5BF.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-3D4YVTNG.js → chunk-TZAE66GQ.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-S6FF7VW6.js → chunk-WQXRZMFN.js} +187 -16
- package/dist/cli-bundle/chunks/chunk-WQXRZMFN.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-SPFZV2GR.js → chunk-XPUTSGJU.js} +32 -31
- package/dist/cli-bundle/chunks/chunk-XPUTSGJU.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-CFSUNEL7.js → chunk-XWBD6DSR.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-MNV226E4.js → chunk-XWYQ2LT4.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-I7GY4X6Y.js → chunk-YFE7JHX3.js} +26 -5
- package/dist/cli-bundle/chunks/chunk-YFE7JHX3.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-FZGM3PNA.js → chunk-YIIIAKCE.js} +2 -2
- package/dist/cli-bundle/chunks/{close-BEP7MHF3.js → close-GPD7DTJV.js} +3 -3
- package/dist/cli-bundle/chunks/{close-Y6QFUJQN.js → close-X3CF6FQP.js} +3 -3
- package/dist/cli-bundle/chunks/{close-many-JJFW7KTT.js → close-many-J7A5EHOQ.js} +5 -5
- package/dist/cli-bundle/chunks/{close-many-QJ6FKJUE.js → close-many-NQLYGPYW.js} +5 -5
- package/dist/cli-bundle/chunks/{deps-EVTOQMKW.js → deps-MQ4ZIGZB.js} +13 -4
- package/dist/cli-bundle/chunks/{deps-5NC4IZH7.js → deps-NIIKXLPB.js} +13 -4
- package/dist/cli-bundle/chunks/{profile-U2B6Y7GE.js → profile-AVCIIZID.js} +3 -3
- package/dist/cli-bundle/chunks/{profile-AGUKS52S.js → profile-LFYO3HHX.js} +3 -3
- package/dist/cli-bundle/chunks/{register-list-query-A5KRJ5J2.js → register-list-query-MZUF2EEC.js} +41 -13
- package/dist/cli-bundle/chunks/register-list-query-MZUF2EEC.js.map +1 -0
- package/dist/cli-bundle/chunks/{register-list-query-NEYP3TXO.js → register-list-query-UKMF55FT.js} +40 -12
- package/dist/cli-bundle/chunks/register-list-query-UKMF55FT.js.map +7 -0
- package/dist/cli-bundle/chunks/{register-mutation-6LOPBAHC.js → register-mutation-2PBW2GEX.js} +15 -13
- package/dist/cli-bundle/chunks/register-mutation-2PBW2GEX.js.map +1 -0
- package/dist/cli-bundle/chunks/{register-mutation-GCZOALNJ.js → register-mutation-T6RVNJC4.js} +14 -12
- package/dist/cli-bundle/chunks/{register-mutation-GCZOALNJ.js.map → register-mutation-T6RVNJC4.js.map} +2 -2
- package/dist/cli-bundle/chunks/{register-operations-6ZZIF27A.js → register-operations-KHZYR6MG.js} +11 -11
- package/dist/cli-bundle/chunks/{register-operations-REDIAEGI.js → register-operations-WPQ2LWZJ.js} +11 -11
- package/dist/cli-bundle/chunks/{register-setup-J3JS2ZVT.js → register-setup-PGDNOXDQ.js} +5 -5
- package/dist/cli-bundle/chunks/{register-setup-BHPMN5SK.js → register-setup-TDN7WAO6.js} +5 -5
- package/dist/cli-bundle/chunks/{update-SA6AG23P.js → update-SQYZA3ZW.js} +4 -4
- package/dist/cli-bundle/chunks/{update-PQQHLYCC.js → update-XZJYS5X7.js} +4 -4
- package/dist/cli-bundle/chunks/{update-many-RQVTFJPD.js → update-many-R24B3GBK.js} +6 -6
- package/dist/cli-bundle/chunks/{update-many-TV3L3KBX.js → update-many-WQ3R3J6N.js} +6 -6
- package/dist/cli-bundle/main.js +25 -9
- package/dist/cli-bundle/main.js.map +2 -2
- package/dist/cli-bundle/sdk-runtime.js +19 -16
- package/dist/cli-bundle/sdk.js +95 -305
- package/dist/cli-bundle/sdk.js.map +4 -4
- package/dist/core/item/actionability.d.ts +12 -0
- package/dist/core/item/actionability.js +39 -4
- package/dist/core/item/actionability.js.map +1 -1
- package/dist/core/sentry/instrument.d.ts +11 -0
- package/dist/core/sentry/instrument.js +21 -2
- package/dist/core/sentry/instrument.js.map +1 -1
- package/dist/mcp/server.d.ts +16 -18
- package/dist/mcp/server.js +84 -31
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/tool-definitions.js +17 -4
- package/dist/mcp/tool-definitions.js.map +1 -1
- package/dist/sdk/actionability.d.ts +10 -0
- package/dist/sdk/actionability.js +14 -0
- package/dist/sdk/actionability.js.map +1 -0
- package/dist/sdk/cli-contracts/enum-contracts.d.ts +6 -2
- package/dist/sdk/cli-contracts/enum-contracts.js +19 -2
- package/dist/sdk/cli-contracts/enum-contracts.js.map +1 -1
- package/dist/sdk/cli-contracts/flag-contracts.d.ts +2 -0
- package/dist/sdk/cli-contracts/flag-contracts.js +21 -2
- package/dist/sdk/cli-contracts/flag-contracts.js.map +1 -1
- package/dist/sdk/cli-contracts/tool-option-contracts.d.ts +2 -0
- package/dist/sdk/cli-contracts/tool-option-contracts.js +16 -2
- package/dist/sdk/cli-contracts/tool-option-contracts.js.map +1 -1
- package/dist/sdk/cli-contracts/tool-parameter-tables.js +80 -3
- package/dist/sdk/cli-contracts/tool-parameter-tables.js.map +1 -1
- package/dist/sdk/cli-contracts/tool-schema.d.ts +20 -0
- package/dist/sdk/cli-contracts/tool-schema.js +97 -9
- package/dist/sdk/cli-contracts/tool-schema.js.map +1 -1
- package/dist/sdk/cli-contracts.d.ts +2 -2
- package/dist/sdk/cli-contracts.js +4 -4
- package/dist/sdk/cli-contracts.js.map +1 -1
- package/dist/sdk/dependencies.d.ts +42 -53
- package/dist/sdk/dependencies.js +177 -125
- package/dist/sdk/dependencies.js.map +1 -1
- package/dist/sdk/governance/validate.js +3 -3
- package/dist/sdk/governance/validate.js.map +1 -1
- package/dist/sdk/graph/analytics.d.ts +124 -0
- package/dist/sdk/graph/analytics.js +464 -0
- package/dist/sdk/graph/analytics.js.map +1 -0
- package/dist/sdk/graph/assembly.d.ts +97 -0
- package/dist/sdk/graph/assembly.js +146 -0
- package/dist/sdk/graph/assembly.js.map +1 -0
- package/dist/sdk/graph/cache.d.ts +66 -0
- package/dist/sdk/graph/cache.js +148 -0
- package/dist/sdk/graph/cache.js.map +1 -0
- package/dist/sdk/graph/governance.d.ts +108 -0
- package/dist/sdk/graph/governance.js +360 -0
- package/dist/sdk/graph/governance.js.map +1 -0
- package/dist/sdk/graph/index.d.ts +16 -0
- package/dist/sdk/graph/index.js +20 -0
- package/dist/sdk/graph/index.js.map +1 -0
- package/dist/sdk/graph/remediation.d.ts +52 -0
- package/dist/sdk/graph/remediation.js +148 -0
- package/dist/sdk/graph/remediation.js.map +1 -0
- package/dist/sdk/graph/run.d.ts +295 -0
- package/dist/sdk/graph/run.js +468 -0
- package/dist/sdk/graph/run.js.map +1 -0
- package/dist/sdk/graph/traversal.d.ts +77 -0
- package/dist/sdk/graph/traversal.js +262 -0
- package/dist/sdk/graph/traversal.js.map +1 -0
- package/dist/sdk/index.d.ts +4 -2
- package/dist/sdk/index.js +6 -4
- package/dist/sdk/index.js.map +1 -1
- package/dist/sdk/query/list.d.ts +8 -0
- package/dist/sdk/query/list.js +19 -3
- package/dist/sdk/query/list.js.map +1 -1
- package/dist/sdk/relationship-context.d.ts +42 -0
- package/dist/sdk/relationship-context.js +99 -20
- package/dist/sdk/relationship-context.js.map +1 -1
- package/dist/sdk/relationships.d.ts +13 -0
- package/dist/sdk/relationships.js +30 -2
- package/dist/sdk/relationships.js.map +1 -1
- package/dist/sdk/runtime-input.d.ts +41 -0
- package/dist/sdk/runtime-input.js +422 -2
- package/dist/sdk/runtime-input.js.map +1 -1
- package/dist/sdk/runtime.d.ts +12 -23
- package/dist/sdk/runtime.js +19 -371
- package/dist/sdk/runtime.js.map +1 -1
- package/dist/sdk/test/linked-command-detection.js +12 -3
- package/dist/sdk/test/linked-command-detection.js.map +1 -1
- package/docs/AGENT_GUIDE.md +1 -0
- package/docs/COMMANDS.md +19 -1
- package/docs/RELATIONSHIP_GRAPH.md +99 -3
- package/docs/SDK.md +17 -3
- package/marketplace.json +2 -2
- package/package.json +1 -1
- package/packages/pm-beads/package.json +1 -1
- package/packages/pm-calendar/package.json +1 -1
- package/packages/pm-command-kit/package.json +1 -1
- package/packages/pm-governance-audit/package.json +1 -1
- package/packages/pm-guide-shell/package.json +1 -1
- package/packages/pm-kanban/package.json +1 -1
- package/packages/pm-lifecycle-hooks/package.json +1 -1
- package/packages/pm-linked-test-adapters/package.json +1 -1
- package/packages/pm-search-advanced/package.json +1 -1
- package/packages/pm-templates/package.json +1 -1
- package/packages/pm-todos/package.json +1 -1
- package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/dist/cli-bundle/chunks/chunk-6XAZB6SE.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-7CTQ7WW5.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-7LTCLTRG.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-DCC2AQBD.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-HF63SBLC.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-I7GY4X6Y.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-LLODAQMP.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-MSGETE6I.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-N7I2DGLP.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-NCAFUBJX.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-P56LKFQX.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-S46R2M3W.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-S6FF7VW6.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-SIJV365F.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-SPFZV2GR.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-V3VBXQQV.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-YQCWK2MB.js.map +0 -1
- package/dist/cli-bundle/chunks/register-list-query-A5KRJ5J2.js.map +0 -1
- package/dist/cli-bundle/chunks/register-list-query-NEYP3TXO.js.map +0 -7
- package/dist/cli-bundle/chunks/register-mutation-6LOPBAHC.js.map +0 -1
- /package/dist/cli-bundle/chunks/{chunk-QNUAZYGW.js.map → chunk-43UMFKCK.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-B6SH2YNN.js.map → chunk-7R6UIHYY.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-23TCGBRK.js.map → chunk-ADXDCAKP.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-2MPMKJF2.js.map → chunk-DHNG452T.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-AFSV5HBB.js.map → chunk-E4FXM2XB.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-QKVVV6QO.js.map → chunk-EWIT5WIC.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-HXVHBERL.js.map → chunk-HPAYDSR2.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-XNPMDSQQ.js.map → chunk-HYTOJW2Q.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-V7MP6YTN.js.map → chunk-IL5SPRMH.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-KOEZCHRF.js.map → chunk-QRZNCRNA.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-G6KM4YKY.js.map → chunk-RXPQ5Q23.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-XYJK6GIQ.js.map → chunk-TGBTLGPX.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-3D4YVTNG.js.map → chunk-TZAE66GQ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-CFSUNEL7.js.map → chunk-XWBD6DSR.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-MNV226E4.js.map → chunk-XWYQ2LT4.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-FZGM3PNA.js.map → chunk-YIIIAKCE.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{close-BEP7MHF3.js.map → close-GPD7DTJV.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{close-Y6QFUJQN.js.map → close-X3CF6FQP.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{close-many-JJFW7KTT.js.map → close-many-J7A5EHOQ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{close-many-QJ6FKJUE.js.map → close-many-NQLYGPYW.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{deps-EVTOQMKW.js.map → deps-MQ4ZIGZB.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{deps-5NC4IZH7.js.map → deps-NIIKXLPB.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{profile-U2B6Y7GE.js.map → profile-AVCIIZID.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{profile-AGUKS52S.js.map → profile-LFYO3HHX.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{register-operations-6ZZIF27A.js.map → register-operations-KHZYR6MG.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{register-operations-REDIAEGI.js.map → register-operations-WPQ2LWZJ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{register-setup-J3JS2ZVT.js.map → register-setup-PGDNOXDQ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{register-setup-BHPMN5SK.js.map → register-setup-TDN7WAO6.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{update-SA6AG23P.js.map → update-SQYZA3ZW.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{update-PQQHLYCC.js.map → update-XZJYS5X7.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{update-many-RQVTFJPD.js.map → update-many-R24B3GBK.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{update-many-TV3L3KBX.js.map → update-many-WQ3R3J6N.js.map} +0 -0
|
@@ -0,0 +1,468 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module sdk/graph/run
|
|
3
|
+
*
|
|
4
|
+
* Workspace-facing `pm graph` runner: one thin orchestrator that loads the
|
|
5
|
+
* tracker once, resolves the fingerprint-keyed workspace assembly through the
|
|
6
|
+
* shared graph cache, and dispatches bounded traversal, path, impact,
|
|
7
|
+
* analytics, governance-audit, and remediation-planning queries through the
|
|
8
|
+
* public graph toolkit. Every projection is counts-first, deterministic, and
|
|
9
|
+
* carries explicit cost, truncation, and cache metadata so agents can budget
|
|
10
|
+
* follow-up reads without re-scanning the workspace; identical repeated
|
|
11
|
+
* queries in long-lived hosts are answered from the memoized snapshot.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="3d4c5f7b-bcd4-569b-8bea-b06cc9f115e5")}catch(e){}}();
|
|
15
|
+
import { getActiveExtensionRegistrations } from "../../core/extensions/index.js";
|
|
16
|
+
import { pathExists } from "../../core/fs/fs-utils.js";
|
|
17
|
+
import { isTerminalStatus } from "../../core/item/status.js";
|
|
18
|
+
import { resolveItemTypeRegistry } from "../../core/item/type-registry.js";
|
|
19
|
+
import { resolveRuntimeStatusRegistry } from "../../core/schema/runtime-schema.js";
|
|
20
|
+
import { EXIT_CODE } from "../../core/shared/constants.js";
|
|
21
|
+
import { PmCliError } from "../../core/shared/errors.js";
|
|
22
|
+
import { listAllItemMetadataLight } from "../../core/store/item-store.js";
|
|
23
|
+
import { getSettingsPath, resolvePmRoot } from "../../core/store/paths.js";
|
|
24
|
+
import { readSettings } from "../../core/store/settings.js";
|
|
25
|
+
import { parseDirection, parseKinds, parseMaxDepth, parsePositiveInteger, } from "../dependencies.js";
|
|
26
|
+
import { analyzeGraphImpact, analyzeKnowledgeGraph, analyzeRelationshipExecution, } from "../relationship-analytics.js";
|
|
27
|
+
import { computeRelationshipDominators, detectRelationshipCommunities, findRedundantRelationshipEdges, } from "./analytics.js";
|
|
28
|
+
import { assembleWorkspaceRelationshipGraph, } from "./assembly.js";
|
|
29
|
+
import { computeWorkspaceGraphFingerprint, workspaceGraphCache, } from "./cache.js";
|
|
30
|
+
import { auditWorkspaceRelationshipGraph, } from "./governance.js";
|
|
31
|
+
import { planRelationshipRemediation, } from "./remediation.js";
|
|
32
|
+
import { enumerateRelationshipPaths, hierarchyAncestors, hierarchyDescendants, orderingPredecessors, orderingSuccessors, } from "./traversal.js";
|
|
33
|
+
import { GRAPH_SUBCOMMAND_VALUES, } from "../cli-contracts/enum-contracts.js";
|
|
34
|
+
export { GRAPH_SUBCOMMAND_VALUES };
|
|
35
|
+
/** Graph subcommands that require a root item id. */
|
|
36
|
+
const ROOTED_SUBCOMMANDS = new Set([
|
|
37
|
+
"ancestors",
|
|
38
|
+
"descendants",
|
|
39
|
+
"predecessors",
|
|
40
|
+
"successors",
|
|
41
|
+
"paths",
|
|
42
|
+
"impact",
|
|
43
|
+
"dominators",
|
|
44
|
+
]);
|
|
45
|
+
/** Default bounded sample rows returned by analyze/audit projections. */
|
|
46
|
+
const DEFAULT_SAMPLE_LIMIT = 10;
|
|
47
|
+
/** Normalize repeatable or comma-separated id options into a flat list. */
|
|
48
|
+
function normalizeIdList(raw) {
|
|
49
|
+
if (raw === undefined)
|
|
50
|
+
return [];
|
|
51
|
+
return (Array.isArray(raw) ? raw : [raw])
|
|
52
|
+
.flatMap((value) => value.split(","))
|
|
53
|
+
.map((value) => value.trim())
|
|
54
|
+
.filter((value) => value.length > 0);
|
|
55
|
+
}
|
|
56
|
+
/** Validate the graph subcommand and its positional-id requirements. */
|
|
57
|
+
export function parseGraphSubcommand(raw, id, target) {
|
|
58
|
+
const candidate = raw.trim().toLowerCase();
|
|
59
|
+
if (!GRAPH_SUBCOMMAND_VALUES.includes(candidate)) {
|
|
60
|
+
throw new PmCliError(`Invalid graph subcommand "${raw}". Use one of: ${GRAPH_SUBCOMMAND_VALUES.join(", ")}.`, EXIT_CODE.USAGE);
|
|
61
|
+
}
|
|
62
|
+
const subcommand = candidate;
|
|
63
|
+
if (ROOTED_SUBCOMMANDS.has(subcommand) && !id?.trim()) {
|
|
64
|
+
throw new PmCliError(`graph ${subcommand} requires an item id.`, EXIT_CODE.USAGE);
|
|
65
|
+
}
|
|
66
|
+
if (subcommand === "paths" && !target?.trim()) {
|
|
67
|
+
throw new PmCliError("graph paths requires a source and a target item id.", EXIT_CODE.USAGE);
|
|
68
|
+
}
|
|
69
|
+
return subcommand;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Re-throw graph-kernel semantic option misuse (non-family kind, unknown
|
|
73
|
+
* cursor, non-transitive redundancy kind) as a usage error carrying the
|
|
74
|
+
* original explanation instead of an opaque crash.
|
|
75
|
+
*/
|
|
76
|
+
function rethrowGraphUsage(error) {
|
|
77
|
+
if (error instanceof TypeError)
|
|
78
|
+
throw new PmCliError(error.message, EXIT_CODE.USAGE);
|
|
79
|
+
throw error;
|
|
80
|
+
}
|
|
81
|
+
/** Convert traversal metadata into the shared cost/truncation projection. */
|
|
82
|
+
function projectQueryMeta(meta) {
|
|
83
|
+
return {
|
|
84
|
+
truncated: meta.truncated,
|
|
85
|
+
cost: {
|
|
86
|
+
visited_nodes: meta.visitedNodes,
|
|
87
|
+
inspected_edges: meta.inspectedEdges,
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
/** Resolve one item id case-insensitively against the assembled graph. */
|
|
92
|
+
function canonicalizeGraphId(assembly, raw) {
|
|
93
|
+
const wanted = raw.trim().toLowerCase();
|
|
94
|
+
for (const detail of assembly.details) {
|
|
95
|
+
if (detail.id.trim().toLowerCase() === wanted &&
|
|
96
|
+
!assembly.missingIdSet.has(detail.id.toLowerCase())) {
|
|
97
|
+
return detail.id;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
throw new PmCliError(`Item ${raw} not found`, EXIT_CODE.NOT_FOUND);
|
|
101
|
+
}
|
|
102
|
+
/** Execute one transitive traversal subcommand over the assembled graph. */
|
|
103
|
+
function runGraphTraversal(subcommand, root, invocation) {
|
|
104
|
+
const walk = {
|
|
105
|
+
ancestors: hierarchyAncestors,
|
|
106
|
+
descendants: hierarchyDescendants,
|
|
107
|
+
predecessors: orderingPredecessors,
|
|
108
|
+
successors: orderingSuccessors,
|
|
109
|
+
}[subcommand];
|
|
110
|
+
let result;
|
|
111
|
+
try {
|
|
112
|
+
result = walk(invocation.assembly.graph, root, {
|
|
113
|
+
...(invocation.kinds === undefined ? {} : { kinds: invocation.kinds }),
|
|
114
|
+
...(invocation.maxDepth === undefined
|
|
115
|
+
? {}
|
|
116
|
+
: { maxDepth: invocation.maxDepth }),
|
|
117
|
+
...(invocation.limit === undefined ? {} : { limit: invocation.limit }),
|
|
118
|
+
...(invocation.after === undefined ? {} : { after: invocation.after }),
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
rethrowGraphUsage(error);
|
|
123
|
+
}
|
|
124
|
+
const meta = projectQueryMeta(result.meta);
|
|
125
|
+
return {
|
|
126
|
+
subcommand,
|
|
127
|
+
root,
|
|
128
|
+
count: result.value.length,
|
|
129
|
+
...meta,
|
|
130
|
+
...(result.meta.nextCursor === undefined
|
|
131
|
+
? {}
|
|
132
|
+
: { next_cursor: result.meta.nextCursor }),
|
|
133
|
+
...(invocation.summary ? {} : { ids: result.value }),
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
/** Execute the bounded simple-path enumeration subcommand. */
|
|
137
|
+
function runGraphPaths(root, target, invocation) {
|
|
138
|
+
const result = enumerateRelationshipPaths(invocation.assembly.graph, root, target, {
|
|
139
|
+
direction: invocation.direction,
|
|
140
|
+
...(invocation.kinds === undefined ? {} : { kinds: invocation.kinds }),
|
|
141
|
+
...(invocation.maxDepth === undefined
|
|
142
|
+
? {}
|
|
143
|
+
: { maxDepth: invocation.maxDepth }),
|
|
144
|
+
...(invocation.maxPaths === undefined
|
|
145
|
+
? {}
|
|
146
|
+
: { maxPaths: invocation.maxPaths }),
|
|
147
|
+
});
|
|
148
|
+
return {
|
|
149
|
+
subcommand: "paths",
|
|
150
|
+
root,
|
|
151
|
+
target,
|
|
152
|
+
direction: invocation.direction,
|
|
153
|
+
count: result.value.length,
|
|
154
|
+
...projectQueryMeta(result.meta),
|
|
155
|
+
...(invocation.summary
|
|
156
|
+
? {}
|
|
157
|
+
: {
|
|
158
|
+
paths: result.value.map((path) => ({
|
|
159
|
+
nodes: path.nodes,
|
|
160
|
+
kinds: path.edges.map((edge) => edge.kind),
|
|
161
|
+
length: path.length,
|
|
162
|
+
})),
|
|
163
|
+
}),
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
/** Execute the bounded blast-radius impact subcommand. */
|
|
167
|
+
function runGraphImpact(root, invocation) {
|
|
168
|
+
const analysis = analyzeGraphImpact(invocation.assembly.graph, root, {
|
|
169
|
+
direction: invocation.direction,
|
|
170
|
+
...(invocation.kinds === undefined ? {} : { kinds: invocation.kinds }),
|
|
171
|
+
...(invocation.maxDepth === undefined
|
|
172
|
+
? {}
|
|
173
|
+
: { maxDepth: invocation.maxDepth }),
|
|
174
|
+
...(invocation.limit === undefined ? {} : { limit: invocation.limit }),
|
|
175
|
+
});
|
|
176
|
+
return {
|
|
177
|
+
subcommand: "impact",
|
|
178
|
+
root,
|
|
179
|
+
direction: invocation.direction,
|
|
180
|
+
count: analysis.affected.length,
|
|
181
|
+
truncated: analysis.truncated,
|
|
182
|
+
cost: {
|
|
183
|
+
visited_nodes: analysis.cost.visitedNodes,
|
|
184
|
+
inspected_edges: analysis.cost.inspectedEdges,
|
|
185
|
+
},
|
|
186
|
+
...(invocation.summary ? {} : { affected: analysis.affected }),
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
/** Execute the workspace-wide execution and knowledge analytics subcommand. */
|
|
190
|
+
function runGraphAnalyze(invocation) {
|
|
191
|
+
const graph = invocation.assembly.graph;
|
|
192
|
+
const sampleLimit = invocation.limit ?? DEFAULT_SAMPLE_LIMIT;
|
|
193
|
+
const execution = analyzeRelationshipExecution(graph, {
|
|
194
|
+
registry: graph.registry(),
|
|
195
|
+
});
|
|
196
|
+
const knowledge = analyzeKnowledgeGraph(graph);
|
|
197
|
+
return {
|
|
198
|
+
subcommand: "analyze",
|
|
199
|
+
node_count: graph.nodes().length,
|
|
200
|
+
edge_count: graph.edges().length,
|
|
201
|
+
sample_limit: sampleLimit,
|
|
202
|
+
execution: {
|
|
203
|
+
acyclic: execution.acyclic,
|
|
204
|
+
ordered_node_count: execution.order.length,
|
|
205
|
+
layer_count: execution.layers.length,
|
|
206
|
+
frontier_count: execution.frontier.length,
|
|
207
|
+
critical_path_length: execution.criticalPathLength,
|
|
208
|
+
cycle_count: execution.cycles.length,
|
|
209
|
+
...(invocation.summary
|
|
210
|
+
? {}
|
|
211
|
+
: {
|
|
212
|
+
frontier: execution.frontier.slice(0, sampleLimit),
|
|
213
|
+
critical_path: execution.criticalPath.slice(0, sampleLimit),
|
|
214
|
+
cycles: execution.cycles.slice(0, sampleLimit),
|
|
215
|
+
}),
|
|
216
|
+
},
|
|
217
|
+
knowledge: {
|
|
218
|
+
component_count: knowledge.components.length,
|
|
219
|
+
largest_component_size: knowledge.components[0]?.length ?? 0,
|
|
220
|
+
orphan_count: knowledge.orphans.length,
|
|
221
|
+
...(invocation.summary
|
|
222
|
+
? {}
|
|
223
|
+
: {
|
|
224
|
+
orphans: knowledge.orphans.slice(0, sampleLimit),
|
|
225
|
+
hubs: knowledge.hubs.slice(0, sampleLimit),
|
|
226
|
+
}),
|
|
227
|
+
},
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
/** Execute the governance-audit subcommand over the assembled graph. */
|
|
231
|
+
function runGraphAudit(invocation, isTerminal) {
|
|
232
|
+
const report = auditWorkspaceRelationshipGraph(invocation.assembly, {
|
|
233
|
+
isTerminal,
|
|
234
|
+
...(invocation.sample === undefined
|
|
235
|
+
? {}
|
|
236
|
+
: { maxSampleSize: invocation.sample }),
|
|
237
|
+
...(invocation.exemptIsolates.length === 0
|
|
238
|
+
? {}
|
|
239
|
+
: { exemptIsolates: invocation.exemptIsolates }),
|
|
240
|
+
});
|
|
241
|
+
const bySeverity = {};
|
|
242
|
+
const byCode = {};
|
|
243
|
+
for (const finding of report.findings) {
|
|
244
|
+
bySeverity[finding.severity] = (bySeverity[finding.severity] ?? 0) + 1;
|
|
245
|
+
byCode[finding.code] = (byCode[finding.code] ?? 0) + finding.count;
|
|
246
|
+
}
|
|
247
|
+
return {
|
|
248
|
+
subcommand: "audit",
|
|
249
|
+
finding_count: report.findings.length,
|
|
250
|
+
findings_by_severity: bySeverity,
|
|
251
|
+
findings_by_code: byCode,
|
|
252
|
+
profile: report.profile,
|
|
253
|
+
...(invocation.summary ? {} : { findings: report.findings }),
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
/** Execute the deterministic community-detection subcommand. */
|
|
257
|
+
function runGraphCommunities(invocation) {
|
|
258
|
+
const sampleLimit = invocation.limit ?? DEFAULT_SAMPLE_LIMIT;
|
|
259
|
+
const result = detectRelationshipCommunities(invocation.assembly.graph, {
|
|
260
|
+
...(invocation.kinds === undefined ? {} : { kinds: invocation.kinds }),
|
|
261
|
+
});
|
|
262
|
+
const analysis = result.value;
|
|
263
|
+
return {
|
|
264
|
+
subcommand: "communities",
|
|
265
|
+
community_count: analysis.communities.length,
|
|
266
|
+
largest_community_size: analysis.communities[0]?.size ?? 0,
|
|
267
|
+
iterations: analysis.iterations,
|
|
268
|
+
converged: analysis.converged,
|
|
269
|
+
truncated: !analysis.converged || analysis.communities.length > sampleLimit,
|
|
270
|
+
cost: {
|
|
271
|
+
visited_nodes: result.meta.visitedNodes,
|
|
272
|
+
inspected_edges: result.meta.inspectedEdges,
|
|
273
|
+
},
|
|
274
|
+
...(invocation.summary
|
|
275
|
+
? {}
|
|
276
|
+
: {
|
|
277
|
+
communities: analysis.communities
|
|
278
|
+
.slice(0, sampleLimit)
|
|
279
|
+
.map((community) => ({
|
|
280
|
+
representative: community.representative,
|
|
281
|
+
size: community.size,
|
|
282
|
+
members: community.members.slice(0, sampleLimit),
|
|
283
|
+
})),
|
|
284
|
+
}),
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
/** Execute the transitive-redundancy scan subcommand. */
|
|
288
|
+
function runGraphRedundancy(invocation) {
|
|
289
|
+
let result;
|
|
290
|
+
try {
|
|
291
|
+
result = findRedundantRelationshipEdges(invocation.assembly.graph, {
|
|
292
|
+
...(invocation.kinds === undefined ? {} : { kinds: invocation.kinds }),
|
|
293
|
+
...(invocation.maxDepth === undefined
|
|
294
|
+
? {}
|
|
295
|
+
: { maxDepth: invocation.maxDepth }),
|
|
296
|
+
...(invocation.limit === undefined ? {} : { limit: invocation.limit }),
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
catch (error) {
|
|
300
|
+
rethrowGraphUsage(error);
|
|
301
|
+
}
|
|
302
|
+
return {
|
|
303
|
+
subcommand: "redundancy",
|
|
304
|
+
redundant_count: result.value.length,
|
|
305
|
+
...projectQueryMeta(result.meta),
|
|
306
|
+
...(invocation.summary
|
|
307
|
+
? {}
|
|
308
|
+
: {
|
|
309
|
+
redundant: result.value.map((row) => ({
|
|
310
|
+
source: row.edge.source,
|
|
311
|
+
target: row.edge.target,
|
|
312
|
+
kind: row.edge.kind,
|
|
313
|
+
witness: row.witness,
|
|
314
|
+
})),
|
|
315
|
+
}),
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
/** Execute the dominator/bottleneck analysis subcommand. */
|
|
319
|
+
function runGraphDominators(root, invocation) {
|
|
320
|
+
const limit = invocation.limit ?? DEFAULT_SAMPLE_LIMIT;
|
|
321
|
+
const result = computeRelationshipDominators(invocation.assembly.graph, root, {
|
|
322
|
+
direction: invocation.direction,
|
|
323
|
+
...(invocation.kinds === undefined ? {} : { kinds: invocation.kinds }),
|
|
324
|
+
...(invocation.maxDepth === undefined
|
|
325
|
+
? {}
|
|
326
|
+
: { maxDepth: invocation.maxDepth }),
|
|
327
|
+
});
|
|
328
|
+
const bottlenecks = result.value.rows.filter((row) => row.dominatedCount > 0);
|
|
329
|
+
return {
|
|
330
|
+
subcommand: "dominators",
|
|
331
|
+
root,
|
|
332
|
+
direction: invocation.direction,
|
|
333
|
+
reachable_count: result.value.reachableCount,
|
|
334
|
+
bottleneck_count: bottlenecks.length,
|
|
335
|
+
truncated: result.meta.truncated || bottlenecks.length > limit,
|
|
336
|
+
cost: {
|
|
337
|
+
visited_nodes: result.meta.visitedNodes,
|
|
338
|
+
inspected_edges: result.meta.inspectedEdges,
|
|
339
|
+
},
|
|
340
|
+
...(invocation.summary
|
|
341
|
+
? {}
|
|
342
|
+
: {
|
|
343
|
+
bottlenecks: bottlenecks.slice(0, limit).map((row) => ({
|
|
344
|
+
id: row.id,
|
|
345
|
+
idom: row.idom,
|
|
346
|
+
dominated_count: row.dominatedCount,
|
|
347
|
+
})),
|
|
348
|
+
}),
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
/** Execute the dry-run remediation planning subcommand. */
|
|
352
|
+
function runGraphPlan(invocation, isTerminal) {
|
|
353
|
+
const limit = invocation.limit ?? DEFAULT_SAMPLE_LIMIT;
|
|
354
|
+
const plan = planRelationshipRemediation(invocation.assembly, {
|
|
355
|
+
isTerminal,
|
|
356
|
+
redundancyLimit: limit,
|
|
357
|
+
...(invocation.sample === undefined
|
|
358
|
+
? {}
|
|
359
|
+
: { maxSampleSize: invocation.sample }),
|
|
360
|
+
...(invocation.exemptIsolates.length === 0
|
|
361
|
+
? {}
|
|
362
|
+
: { exemptIsolates: invocation.exemptIsolates }),
|
|
363
|
+
});
|
|
364
|
+
const byOp = {};
|
|
365
|
+
const byCode = {};
|
|
366
|
+
for (const step of plan.steps) {
|
|
367
|
+
byOp[step.op] = (byOp[step.op] ?? 0) + 1;
|
|
368
|
+
byCode[step.code] = (byCode[step.code] ?? 0) + 1;
|
|
369
|
+
}
|
|
370
|
+
return {
|
|
371
|
+
subcommand: "plan",
|
|
372
|
+
step_count: plan.steps.length,
|
|
373
|
+
steps_by_op: byOp,
|
|
374
|
+
steps_by_code: byCode,
|
|
375
|
+
finding_count: plan.report.findings.length,
|
|
376
|
+
truncated: plan.truncated || plan.steps.length > limit,
|
|
377
|
+
cost: {
|
|
378
|
+
visited_nodes: plan.cost.visitedNodes,
|
|
379
|
+
inspected_edges: plan.cost.inspectedEdges,
|
|
380
|
+
},
|
|
381
|
+
...(invocation.summary ? {} : { steps: plan.steps.slice(0, limit) }),
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
/** Build the deterministic memoization key covering every query-shaping input. */
|
|
385
|
+
function buildGraphQueryKey(subcommand, root, pathsTarget, invocation) {
|
|
386
|
+
return JSON.stringify({
|
|
387
|
+
subcommand,
|
|
388
|
+
root: root ?? null,
|
|
389
|
+
target: pathsTarget ?? null,
|
|
390
|
+
kinds: invocation.kinds ?? null,
|
|
391
|
+
maxDepth: invocation.maxDepth ?? null,
|
|
392
|
+
limit: invocation.limit ?? null,
|
|
393
|
+
after: invocation.after ?? null,
|
|
394
|
+
direction: invocation.direction,
|
|
395
|
+
maxPaths: invocation.maxPaths ?? null,
|
|
396
|
+
sample: invocation.sample ?? null,
|
|
397
|
+
// The audit consumes exemptions as a case-insensitive set, so the key
|
|
398
|
+
// must not distinguish logically identical spellings or orderings.
|
|
399
|
+
exemptIsolates: [
|
|
400
|
+
...new Set(invocation.exemptIsolates.map((id) => id.toLowerCase())),
|
|
401
|
+
].sort(),
|
|
402
|
+
summary: invocation.summary,
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
/** Dispatch one parsed graph subcommand to its executor. */
|
|
406
|
+
function executeGraphSubcommand(subcommand, root, pathsTarget, invocation, isTerminal) {
|
|
407
|
+
if (subcommand === "analyze")
|
|
408
|
+
return runGraphAnalyze(invocation);
|
|
409
|
+
if (subcommand === "audit")
|
|
410
|
+
return runGraphAudit(invocation, isTerminal);
|
|
411
|
+
if (subcommand === "plan")
|
|
412
|
+
return runGraphPlan(invocation, isTerminal);
|
|
413
|
+
if (subcommand === "communities")
|
|
414
|
+
return runGraphCommunities(invocation);
|
|
415
|
+
if (subcommand === "redundancy")
|
|
416
|
+
return runGraphRedundancy(invocation);
|
|
417
|
+
if (subcommand === "dominators")
|
|
418
|
+
return runGraphDominators(root, invocation);
|
|
419
|
+
if (subcommand === "paths")
|
|
420
|
+
return runGraphPaths(root, pathsTarget, invocation);
|
|
421
|
+
if (subcommand === "impact")
|
|
422
|
+
return runGraphImpact(root, invocation);
|
|
423
|
+
return runGraphTraversal(subcommand, root, invocation);
|
|
424
|
+
}
|
|
425
|
+
/** Implements run graph for the public runtime surface of this module. */
|
|
426
|
+
export async function runGraph(subcommandRaw, id, target, options, global) {
|
|
427
|
+
const subcommand = parseGraphSubcommand(subcommandRaw, id, target);
|
|
428
|
+
const pmRoot = resolvePmRoot(process.cwd(), global.path);
|
|
429
|
+
if (!(await pathExists(getSettingsPath(pmRoot)))) {
|
|
430
|
+
throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
|
|
431
|
+
}
|
|
432
|
+
const settings = await readSettings(pmRoot);
|
|
433
|
+
const typeRegistry = resolveItemTypeRegistry(settings, getActiveExtensionRegistrations());
|
|
434
|
+
const items = await listAllItemMetadataLight(pmRoot, settings.item_format, typeRegistry.type_to_folder, undefined, settings.schema);
|
|
435
|
+
const statusRegistry = resolveRuntimeStatusRegistry(settings.schema);
|
|
436
|
+
const isTerminal = (status) => isTerminalStatus(status, statusRegistry);
|
|
437
|
+
const kinds = parseKinds(options.kind);
|
|
438
|
+
const lookup = workspaceGraphCache().lookup(pmRoot, computeWorkspaceGraphFingerprint(items, isTerminal), () => assembleWorkspaceRelationshipGraph(items, isTerminal));
|
|
439
|
+
const invocation = {
|
|
440
|
+
assembly: lookup.assembly,
|
|
441
|
+
...(kinds === undefined ? {} : { kinds }),
|
|
442
|
+
maxDepth: parseMaxDepth(options.maxDepth),
|
|
443
|
+
limit: parsePositiveInteger(options.limit, "limit"),
|
|
444
|
+
after: options.after?.trim() || undefined,
|
|
445
|
+
direction: parseDirection(options.direction),
|
|
446
|
+
maxPaths: parsePositiveInteger(options.maxPaths, "max-paths"),
|
|
447
|
+
sample: parsePositiveInteger(options.sample, "sample"),
|
|
448
|
+
exemptIsolates: normalizeIdList(options.exemptIsolate),
|
|
449
|
+
summary: options.summary === true,
|
|
450
|
+
};
|
|
451
|
+
const root = ROOTED_SUBCOMMANDS.has(subcommand)
|
|
452
|
+
? canonicalizeGraphId(invocation.assembly, id)
|
|
453
|
+
: undefined;
|
|
454
|
+
const pathsTarget = subcommand === "paths"
|
|
455
|
+
? canonicalizeGraphId(invocation.assembly, target)
|
|
456
|
+
: undefined;
|
|
457
|
+
const memo = lookup.memoize(buildGraphQueryKey(subcommand, root, pathsTarget, invocation), () => executeGraphSubcommand(subcommand, root, pathsTarget, invocation, isTerminal));
|
|
458
|
+
return {
|
|
459
|
+
...memo.value,
|
|
460
|
+
cache: {
|
|
461
|
+
fingerprint: lookup.fingerprint.slice(0, 12),
|
|
462
|
+
assembly: lookup.assemblyReused ? "hit" : "miss",
|
|
463
|
+
result: memo.reused ? "hit" : "miss",
|
|
464
|
+
},
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
//# sourceMappingURL=run.js.map
|
|
468
|
+
//# debugId=3d4c5f7b-bcd4-569b-8bea-b06cc9f115e5
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.js","sources":["sdk/graph/run.ts"],"sourceRoot":"/","sourcesContent":["/**\n * @module sdk/graph/run\n *\n * Workspace-facing `pm graph` runner: one thin orchestrator that loads the\n * tracker once, resolves the fingerprint-keyed workspace assembly through the\n * shared graph cache, and dispatches bounded traversal, path, impact,\n * analytics, governance-audit, and remediation-planning queries through the\n * public graph toolkit. Every projection is counts-first, deterministic, and\n * carries explicit cost, truncation, and cache metadata so agents can budget\n * follow-up reads without re-scanning the workspace; identical repeated\n * queries in long-lived hosts are answered from the memoized snapshot.\n */\nimport { getActiveExtensionRegistrations } from \"../../core/extensions/index.js\";\nimport { pathExists } from \"../../core/fs/fs-utils.js\";\nimport { isTerminalStatus } from \"../../core/item/status.js\";\nimport { resolveItemTypeRegistry } from \"../../core/item/type-registry.js\";\nimport { resolveRuntimeStatusRegistry } from \"../../core/schema/runtime-schema.js\";\nimport type { GlobalOptions } from \"../../core/shared/command-types.js\";\nimport { EXIT_CODE } from \"../../core/shared/constants.js\";\nimport { PmCliError } from \"../../core/shared/errors.js\";\nimport { listAllItemMetadataLight } from \"../../core/store/item-store.js\";\nimport { getSettingsPath, resolvePmRoot } from \"../../core/store/paths.js\";\nimport { readSettings } from \"../../core/store/settings.js\";\nimport {\n parseDirection,\n parseKinds,\n parseMaxDepth,\n parsePositiveInteger,\n} from \"../dependencies.js\";\nimport {\n analyzeGraphImpact,\n analyzeKnowledgeGraph,\n analyzeRelationshipExecution,\n} from \"../relationship-analytics.js\";\nimport type { RelationshipQueryMeta } from \"../relationships.js\";\nimport {\n computeRelationshipDominators,\n detectRelationshipCommunities,\n findRedundantRelationshipEdges,\n} from \"./analytics.js\";\nimport {\n assembleWorkspaceRelationshipGraph,\n type WorkspaceRelationshipAssembly,\n} from \"./assembly.js\";\nimport {\n computeWorkspaceGraphFingerprint,\n workspaceGraphCache,\n type GraphCacheMetadata,\n} from \"./cache.js\";\nimport {\n auditWorkspaceRelationshipGraph,\n type RelationshipAuditReport,\n} from \"./governance.js\";\nimport {\n planRelationshipRemediation,\n type RelationshipRemediationStep,\n} from \"./remediation.js\";\nimport {\n enumerateRelationshipPaths,\n hierarchyAncestors,\n hierarchyDescendants,\n orderingPredecessors,\n orderingSuccessors,\n} from \"./traversal.js\";\n\nimport {\n GRAPH_SUBCOMMAND_VALUES,\n type GraphSubcommand,\n} from \"../cli-contracts/enum-contracts.js\";\n\nexport { GRAPH_SUBCOMMAND_VALUES, type GraphSubcommand };\n\n/** Graph subcommands that require a root item id. */\nconst ROOTED_SUBCOMMANDS = new Set<GraphSubcommand>([\n \"ancestors\",\n \"descendants\",\n \"predecessors\",\n \"successors\",\n \"paths\",\n \"impact\",\n \"dominators\",\n]);\n\n/** Default bounded sample rows returned by analyze/audit projections. */\nconst DEFAULT_SAMPLE_LIMIT = 10;\n\n/** Documents the graph command options payload exchanged by command, SDK, and package integrations. */\nexport interface GraphCommandOptions {\n /** Restricts traversal to registered relationship kinds (repeatable or comma-separated). */\n kind?: string | string[];\n /** Maximum traversal depth as a non-negative integer. */\n maxDepth?: string | number;\n /** Maximum returned rows per bounded collection. */\n limit?: string | number;\n /** Resume a traversal after this previously returned node id. */\n after?: string;\n /** Edge orientation for paths and impact queries (outgoing, incoming, or both). */\n direction?: string;\n /** Maximum enumerated paths for the paths subcommand. */\n maxPaths?: string | number;\n /** Maximum evidence sample entries per audit finding. */\n sample?: string | number;\n /** Item ids treated as explicitly valid isolates by the audit. */\n exemptIsolate?: string | string[];\n /** Return counts-first envelopes without row collections. */\n summary?: boolean;\n}\n\n/** Cost metadata attached to every graph query projection. */\nexport interface GraphQueryCost {\n /** Nodes expanded while answering the query. */\n visited_nodes: number;\n /** Edges inspected while answering the query. */\n inspected_edges: number;\n}\n\n/** Result envelope for the transitive traversal subcommands. */\nexport interface GraphTraversalResult {\n /** Executed graph subcommand. */\n subcommand: \"ancestors\" | \"descendants\" | \"predecessors\" | \"successors\";\n /** Canonical root item id. */\n root: string;\n /** Total emitted node ids before summary suppression. */\n count: number;\n /** Whether configured bounds omitted reachable work. */\n truncated: boolean;\n /** Cursor resuming emission after the last returned node. */\n next_cursor?: string;\n /** Query cost metadata. */\n cost: GraphQueryCost;\n /** Emitted node ids in deterministic breadth-first order; absent with summary. */\n ids?: string[];\n /** Cache observability for this invocation. */\n cache?: GraphCacheMetadata;\n}\n\n/** One enumerated path projected with relationship kinds instead of raw edges. */\nexport interface GraphPathRow {\n /** Ordered node ids from source to target inclusive. */\n nodes: string[];\n /** Relationship kind of each traversed edge, in path order. */\n kinds: string[];\n /** Number of edges in the path. */\n length: number;\n}\n\n/** Result envelope for the paths subcommand. */\nexport interface GraphPathsResult {\n /** Executed graph subcommand. */\n subcommand: \"paths\";\n /** Canonical source item id. */\n root: string;\n /** Canonical target item id. */\n target: string;\n /** Traversal orientation used for the enumeration. */\n direction: string;\n /** Total enumerated paths before summary suppression. */\n count: number;\n /** Whether depth, path-count, or safety bounds stopped the search early. */\n truncated: boolean;\n /** Query cost metadata. */\n cost: GraphQueryCost;\n /** Enumerated paths, shortest first; absent with summary. */\n paths?: GraphPathRow[];\n /** Cache observability for this invocation. */\n cache?: GraphCacheMetadata;\n}\n\n/** One affected item row in an impact projection. */\nexport interface GraphImpactRow {\n /** Affected item id. */\n id: string;\n /** Shortest relationship distance from the root. */\n distance: number;\n /** Exact node path explaining why the item is affected. */\n path: string[];\n}\n\n/** Result envelope for the impact subcommand. */\nexport interface GraphImpactResult {\n /** Executed graph subcommand. */\n subcommand: \"impact\";\n /** Canonical impact-origin item id. */\n root: string;\n /** Traversal orientation used for the blast-radius walk. */\n direction: string;\n /** Total affected items before summary suppression. */\n count: number;\n /** Whether configured bounds omitted reachable work. */\n truncated: boolean;\n /** Query cost metadata. */\n cost: GraphQueryCost;\n /** Affected item rows ordered by discovery; absent with summary. */\n affected?: GraphImpactRow[];\n /** Cache observability for this invocation. */\n cache?: GraphCacheMetadata;\n}\n\n/** Bounded execution-graph projection inside an analyze result. */\nexport interface GraphExecutionSummary {\n /** Whether the order-bearing graph is acyclic. */\n acyclic: boolean;\n /** Nodes participating in the topological order. */\n ordered_node_count: number;\n /** Number of parallelizable topological layers. */\n layer_count: number;\n /** Total items with no open prerequisites. */\n frontier_count: number;\n /** Bounded prerequisite-free sample; absent with summary. */\n frontier?: string[];\n /** Edge count of the longest execution path. */\n critical_path_length: number;\n /** Longest deterministic execution path; absent with summary. */\n critical_path?: string[];\n /** Total genuine ordering cycles. */\n cycle_count: number;\n /** Bounded ordering-cycle sample; absent with summary. */\n cycles?: string[][];\n}\n\n/** Bounded knowledge-graph projection inside an analyze result. */\nexport interface GraphKnowledgeSummary {\n /** Total weakly connected components. */\n component_count: number;\n /** Node count of the largest component. */\n largest_component_size: number;\n /** Total nodes without any relationship edges. */\n orphan_count: number;\n /** Bounded orphan sample; absent with summary. */\n orphans?: string[];\n /** Bounded maximum-degree hubs; absent with summary. */\n hubs?: { id: string; degree: number }[];\n}\n\n/** Result envelope for the analyze subcommand. */\nexport interface GraphAnalyzeResult {\n /** Executed graph subcommand. */\n subcommand: \"analyze\";\n /** Total indexed graph nodes. */\n node_count: number;\n /** Total deduplicated graph edges. */\n edge_count: number;\n /** Bound applied to every sample collection. */\n sample_limit: number;\n /** Execution-order analytics over registered ordering kinds. */\n execution: GraphExecutionSummary;\n /** Structural analytics over every stored edge. */\n knowledge: GraphKnowledgeSummary;\n /** Cache observability for this invocation. */\n cache?: GraphCacheMetadata;\n}\n\n/** Result envelope for the audit subcommand. */\nexport interface GraphAuditResult {\n /** Executed graph subcommand. */\n subcommand: \"audit\";\n /** Total audit findings. */\n finding_count: number;\n /** Finding counts keyed by severity. */\n findings_by_severity: Record<string, number>;\n /** Affected-subject counts keyed by finding code. */\n findings_by_code: Record<string, number>;\n /** Structural coverage metrics computed during the audit. */\n profile: RelationshipAuditReport[\"profile\"];\n /** Ordered findings with bounded evidence samples; absent with summary. */\n findings?: RelationshipAuditReport[\"findings\"];\n /** Cache observability for this invocation. */\n cache?: GraphCacheMetadata;\n}\n\n/** One bounded community row projected by the communities subcommand. */\nexport interface GraphCommunityRow {\n /** Lexicographically smallest member id, naming the community. */\n representative: string;\n /** Total member count before sampling. */\n size: number;\n /** Bounded sorted member sample. */\n members: string[];\n}\n\n/** Result envelope for the communities subcommand. */\nexport interface GraphCommunitiesResult {\n /** Executed graph subcommand. */\n subcommand: \"communities\";\n /** Total detected communities meeting the size floor. */\n community_count: number;\n /** Member count of the largest community. */\n largest_community_size: number;\n /** Label-propagation sweeps executed. */\n iterations: number;\n /** Whether labels stabilized before the iteration bound. */\n converged: boolean;\n /** Whether the iteration bound stopped propagation early or the sample bound omitted rows. */\n truncated: boolean;\n /** Query cost metadata. */\n cost: GraphQueryCost;\n /** Bounded community rows, largest first; absent with summary. */\n communities?: GraphCommunityRow[];\n /** Cache observability for this invocation. */\n cache?: GraphCacheMetadata;\n}\n\n/** One redundant stored edge projected with its witness path. */\nexport interface GraphRedundancyRow {\n /** Stored edge source id. */\n source: string;\n /** Stored edge target id. */\n target: string;\n /** Stored relationship kind. */\n kind: string;\n /** Semantic-orientation node path proving the edge is implied. */\n witness: string[];\n}\n\n/** Result envelope for the redundancy subcommand. */\nexport interface GraphRedundancyResult {\n /** Executed graph subcommand. */\n subcommand: \"redundancy\";\n /** Total redundant edges found within configured bounds. */\n redundant_count: number;\n /** Whether the row limit omitted further redundant edges. */\n truncated: boolean;\n /** Query cost metadata. */\n cost: GraphQueryCost;\n /** Redundant edge rows in deterministic scan order; absent with summary. */\n redundant?: GraphRedundancyRow[];\n /** Cache observability for this invocation. */\n cache?: GraphCacheMetadata;\n}\n\n/** One structural bottleneck row projected by the dominators subcommand. */\nexport interface GraphDominatorRow {\n /** Bottleneck node id. */\n id: string;\n /** Immediate dominator appearing on every root-to-node path. */\n idom: string;\n /** Reachable nodes strictly gated by this node. */\n dominated_count: number;\n}\n\n/** Result envelope for the dominators subcommand. */\nexport interface GraphDominatorsResult {\n /** Executed graph subcommand. */\n subcommand: \"dominators\";\n /** Canonical analyzed root id. */\n root: string;\n /** Traversal orientation used for reachability. */\n direction: string;\n /** Reachable node count including the root. */\n reachable_count: number;\n /** Total nodes gating at least one other reachable node. */\n bottleneck_count: number;\n /** Whether the depth bound cut reachability or the row limit omitted bottleneck rows. */\n truncated: boolean;\n /** Query cost metadata. */\n cost: GraphQueryCost;\n /** Bounded bottleneck rows, most-gating first; absent with summary. */\n bottlenecks?: GraphDominatorRow[];\n /** Cache observability for this invocation. */\n cache?: GraphCacheMetadata;\n}\n\n/** Result envelope for the dry-run remediation planning subcommand. */\nexport interface GraphPlanResult {\n /** Executed graph subcommand. */\n subcommand: \"plan\";\n /** Total derived remediation proposals before row bounding. */\n step_count: number;\n /** Proposal counts keyed by operation family. */\n steps_by_op: Record<string, number>;\n /** Proposal counts keyed by policy code. */\n steps_by_code: Record<string, number>;\n /** Total governance-audit findings the plan was derived from. */\n finding_count: number;\n /** Whether sample, scan, or row bounds omitted derivable proposals. */\n truncated: boolean;\n /** Query cost metadata. */\n cost: GraphQueryCost;\n /** Bounded proposal rows in audit severity order; absent with summary. */\n steps?: RelationshipRemediationStep[];\n /** Cache observability for this invocation. */\n cache?: GraphCacheMetadata;\n}\n\n/** Union of every graph subcommand result envelope. */\nexport type GraphResult =\n | GraphTraversalResult\n | GraphPathsResult\n | GraphImpactResult\n | GraphAnalyzeResult\n | GraphAuditResult\n | GraphCommunitiesResult\n | GraphRedundancyResult\n | GraphDominatorsResult\n | GraphPlanResult;\n\n/** Fully parsed graph invocation shared by the subcommand executors. */\ninterface GraphInvocation {\n /** Assembled workspace relationship graph and node details. */\n assembly: WorkspaceRelationshipAssembly;\n /** Canonical registered kind filters, when provided. */\n kinds?: string[];\n /** Parsed non-negative depth bound. */\n maxDepth?: number;\n /** Parsed positive row bound. */\n limit?: number;\n /** Traversal resume cursor. */\n after?: string;\n /** Validated traversal orientation. */\n direction: \"outgoing\" | \"incoming\" | \"both\";\n /** Parsed positive path-count bound. */\n maxPaths?: number;\n /** Parsed positive audit sample bound. */\n sample?: number;\n /** Normalized audit isolate exemptions. */\n exemptIsolates: string[];\n /** Whether row collections are suppressed. */\n summary: boolean;\n}\n\n/** Normalize repeatable or comma-separated id options into a flat list. */\nfunction normalizeIdList(raw: string | string[] | undefined): string[] {\n if (raw === undefined) return [];\n return (Array.isArray(raw) ? raw : [raw])\n .flatMap((value) => value.split(\",\"))\n .map((value) => value.trim())\n .filter((value) => value.length > 0);\n}\n\n/** Validate the graph subcommand and its positional-id requirements. */\nexport function parseGraphSubcommand(\n raw: string,\n id: string | undefined,\n target: string | undefined,\n): GraphSubcommand {\n const candidate = raw.trim().toLowerCase();\n if (!(GRAPH_SUBCOMMAND_VALUES as readonly string[]).includes(candidate)) {\n throw new PmCliError(\n `Invalid graph subcommand \"${raw}\". Use one of: ${GRAPH_SUBCOMMAND_VALUES.join(\", \")}.`,\n EXIT_CODE.USAGE,\n );\n }\n const subcommand = candidate as GraphSubcommand;\n if (ROOTED_SUBCOMMANDS.has(subcommand) && !id?.trim()) {\n throw new PmCliError(\n `graph ${subcommand} requires an item id.`,\n EXIT_CODE.USAGE,\n );\n }\n if (subcommand === \"paths\" && !target?.trim()) {\n throw new PmCliError(\n \"graph paths requires a source and a target item id.\",\n EXIT_CODE.USAGE,\n );\n }\n return subcommand;\n}\n\n/**\n * Re-throw graph-kernel semantic option misuse (non-family kind, unknown\n * cursor, non-transitive redundancy kind) as a usage error carrying the\n * original explanation instead of an opaque crash.\n */\nfunction rethrowGraphUsage(error: unknown): never {\n if (error instanceof TypeError)\n throw new PmCliError(error.message, EXIT_CODE.USAGE);\n throw error;\n}\n\n/** Convert traversal metadata into the shared cost/truncation projection. */\nfunction projectQueryMeta(meta: RelationshipQueryMeta): {\n truncated: boolean;\n cost: GraphQueryCost;\n} {\n return {\n truncated: meta.truncated,\n cost: {\n visited_nodes: meta.visitedNodes,\n inspected_edges: meta.inspectedEdges,\n },\n };\n}\n\n/** Resolve one item id case-insensitively against the assembled graph. */\nfunction canonicalizeGraphId(\n assembly: WorkspaceRelationshipAssembly,\n raw: string,\n): string {\n const wanted = raw.trim().toLowerCase();\n for (const detail of assembly.details) {\n if (\n detail.id.trim().toLowerCase() === wanted &&\n !assembly.missingIdSet.has(detail.id.toLowerCase())\n ) {\n return detail.id;\n }\n }\n throw new PmCliError(`Item ${raw} not found`, EXIT_CODE.NOT_FOUND);\n}\n\n/** Execute one transitive traversal subcommand over the assembled graph. */\nfunction runGraphTraversal(\n subcommand: \"ancestors\" | \"descendants\" | \"predecessors\" | \"successors\",\n root: string,\n invocation: GraphInvocation,\n): GraphTraversalResult {\n const walk = {\n ancestors: hierarchyAncestors,\n descendants: hierarchyDescendants,\n predecessors: orderingPredecessors,\n successors: orderingSuccessors,\n }[subcommand];\n let result;\n try {\n result = walk(invocation.assembly.graph, root, {\n ...(invocation.kinds === undefined ? {} : { kinds: invocation.kinds }),\n ...(invocation.maxDepth === undefined\n ? {}\n : { maxDepth: invocation.maxDepth }),\n ...(invocation.limit === undefined ? {} : { limit: invocation.limit }),\n ...(invocation.after === undefined ? {} : { after: invocation.after }),\n });\n } catch (error) {\n rethrowGraphUsage(error);\n }\n const meta = projectQueryMeta(result.meta);\n return {\n subcommand,\n root,\n count: result.value.length,\n ...meta,\n ...(result.meta.nextCursor === undefined\n ? {}\n : { next_cursor: result.meta.nextCursor }),\n ...(invocation.summary ? {} : { ids: result.value }),\n };\n}\n\n/** Execute the bounded simple-path enumeration subcommand. */\nfunction runGraphPaths(\n root: string,\n target: string,\n invocation: GraphInvocation,\n): GraphPathsResult {\n const result = enumerateRelationshipPaths(\n invocation.assembly.graph,\n root,\n target,\n {\n direction: invocation.direction,\n ...(invocation.kinds === undefined ? {} : { kinds: invocation.kinds }),\n ...(invocation.maxDepth === undefined\n ? {}\n : { maxDepth: invocation.maxDepth }),\n ...(invocation.maxPaths === undefined\n ? {}\n : { maxPaths: invocation.maxPaths }),\n },\n );\n return {\n subcommand: \"paths\",\n root,\n target,\n direction: invocation.direction,\n count: result.value.length,\n ...projectQueryMeta(result.meta),\n ...(invocation.summary\n ? {}\n : {\n paths: result.value.map((path) => ({\n nodes: path.nodes,\n kinds: path.edges.map((edge) => edge.kind),\n length: path.length,\n })),\n }),\n };\n}\n\n/** Execute the bounded blast-radius impact subcommand. */\nfunction runGraphImpact(\n root: string,\n invocation: GraphInvocation,\n): GraphImpactResult {\n const analysis = analyzeGraphImpact(invocation.assembly.graph, root, {\n direction: invocation.direction,\n ...(invocation.kinds === undefined ? {} : { kinds: invocation.kinds }),\n ...(invocation.maxDepth === undefined\n ? {}\n : { maxDepth: invocation.maxDepth }),\n ...(invocation.limit === undefined ? {} : { limit: invocation.limit }),\n });\n return {\n subcommand: \"impact\",\n root,\n direction: invocation.direction,\n count: analysis.affected.length,\n truncated: analysis.truncated,\n cost: {\n visited_nodes: analysis.cost.visitedNodes,\n inspected_edges: analysis.cost.inspectedEdges,\n },\n ...(invocation.summary ? {} : { affected: analysis.affected }),\n };\n}\n\n/** Execute the workspace-wide execution and knowledge analytics subcommand. */\nfunction runGraphAnalyze(invocation: GraphInvocation): GraphAnalyzeResult {\n const graph = invocation.assembly.graph;\n const sampleLimit = invocation.limit ?? DEFAULT_SAMPLE_LIMIT;\n const execution = analyzeRelationshipExecution(graph, {\n registry: graph.registry(),\n });\n const knowledge = analyzeKnowledgeGraph(graph);\n return {\n subcommand: \"analyze\",\n node_count: graph.nodes().length,\n edge_count: graph.edges().length,\n sample_limit: sampleLimit,\n execution: {\n acyclic: execution.acyclic,\n ordered_node_count: execution.order.length,\n layer_count: execution.layers.length,\n frontier_count: execution.frontier.length,\n critical_path_length: execution.criticalPathLength,\n cycle_count: execution.cycles.length,\n ...(invocation.summary\n ? {}\n : {\n frontier: execution.frontier.slice(0, sampleLimit),\n critical_path: execution.criticalPath.slice(0, sampleLimit),\n cycles: execution.cycles.slice(0, sampleLimit),\n }),\n },\n knowledge: {\n component_count: knowledge.components.length,\n largest_component_size: knowledge.components[0]?.length ?? 0,\n orphan_count: knowledge.orphans.length,\n ...(invocation.summary\n ? {}\n : {\n orphans: knowledge.orphans.slice(0, sampleLimit),\n hubs: knowledge.hubs.slice(0, sampleLimit),\n }),\n },\n };\n}\n\n/** Execute the governance-audit subcommand over the assembled graph. */\nfunction runGraphAudit(\n invocation: GraphInvocation,\n isTerminal: (status: string) => boolean,\n): GraphAuditResult {\n const report = auditWorkspaceRelationshipGraph(invocation.assembly, {\n isTerminal,\n ...(invocation.sample === undefined\n ? {}\n : { maxSampleSize: invocation.sample }),\n ...(invocation.exemptIsolates.length === 0\n ? {}\n : { exemptIsolates: invocation.exemptIsolates }),\n });\n const bySeverity: Record<string, number> = {};\n const byCode: Record<string, number> = {};\n for (const finding of report.findings) {\n bySeverity[finding.severity] = (bySeverity[finding.severity] ?? 0) + 1;\n byCode[finding.code] = (byCode[finding.code] ?? 0) + finding.count;\n }\n return {\n subcommand: \"audit\",\n finding_count: report.findings.length,\n findings_by_severity: bySeverity,\n findings_by_code: byCode,\n profile: report.profile,\n ...(invocation.summary ? {} : { findings: report.findings }),\n };\n}\n\n/** Execute the deterministic community-detection subcommand. */\nfunction runGraphCommunities(\n invocation: GraphInvocation,\n): GraphCommunitiesResult {\n const sampleLimit = invocation.limit ?? DEFAULT_SAMPLE_LIMIT;\n const result = detectRelationshipCommunities(invocation.assembly.graph, {\n ...(invocation.kinds === undefined ? {} : { kinds: invocation.kinds }),\n });\n const analysis = result.value;\n return {\n subcommand: \"communities\",\n community_count: analysis.communities.length,\n largest_community_size: analysis.communities[0]?.size ?? 0,\n iterations: analysis.iterations,\n converged: analysis.converged,\n truncated: !analysis.converged || analysis.communities.length > sampleLimit,\n cost: {\n visited_nodes: result.meta.visitedNodes,\n inspected_edges: result.meta.inspectedEdges,\n },\n ...(invocation.summary\n ? {}\n : {\n communities: analysis.communities\n .slice(0, sampleLimit)\n .map((community) => ({\n representative: community.representative,\n size: community.size,\n members: community.members.slice(0, sampleLimit),\n })),\n }),\n };\n}\n\n/** Execute the transitive-redundancy scan subcommand. */\nfunction runGraphRedundancy(\n invocation: GraphInvocation,\n): GraphRedundancyResult {\n let result;\n try {\n result = findRedundantRelationshipEdges(invocation.assembly.graph, {\n ...(invocation.kinds === undefined ? {} : { kinds: invocation.kinds }),\n ...(invocation.maxDepth === undefined\n ? {}\n : { maxDepth: invocation.maxDepth }),\n ...(invocation.limit === undefined ? {} : { limit: invocation.limit }),\n });\n } catch (error) {\n rethrowGraphUsage(error);\n }\n return {\n subcommand: \"redundancy\",\n redundant_count: result.value.length,\n ...projectQueryMeta(result.meta),\n ...(invocation.summary\n ? {}\n : {\n redundant: result.value.map((row) => ({\n source: row.edge.source,\n target: row.edge.target,\n kind: row.edge.kind,\n witness: row.witness,\n })),\n }),\n };\n}\n\n/** Execute the dominator/bottleneck analysis subcommand. */\nfunction runGraphDominators(\n root: string,\n invocation: GraphInvocation,\n): GraphDominatorsResult {\n const limit = invocation.limit ?? DEFAULT_SAMPLE_LIMIT;\n const result = computeRelationshipDominators(\n invocation.assembly.graph,\n root,\n {\n direction: invocation.direction,\n ...(invocation.kinds === undefined ? {} : { kinds: invocation.kinds }),\n ...(invocation.maxDepth === undefined\n ? {}\n : { maxDepth: invocation.maxDepth }),\n },\n );\n const bottlenecks = result.value.rows.filter((row) => row.dominatedCount > 0);\n return {\n subcommand: \"dominators\",\n root,\n direction: invocation.direction,\n reachable_count: result.value.reachableCount,\n bottleneck_count: bottlenecks.length,\n truncated: result.meta.truncated || bottlenecks.length > limit,\n cost: {\n visited_nodes: result.meta.visitedNodes,\n inspected_edges: result.meta.inspectedEdges,\n },\n ...(invocation.summary\n ? {}\n : {\n bottlenecks: bottlenecks.slice(0, limit).map((row) => ({\n id: row.id,\n idom: row.idom,\n dominated_count: row.dominatedCount,\n })),\n }),\n };\n}\n\n/** Execute the dry-run remediation planning subcommand. */\nfunction runGraphPlan(\n invocation: GraphInvocation,\n isTerminal: (status: string) => boolean,\n): GraphPlanResult {\n const limit = invocation.limit ?? DEFAULT_SAMPLE_LIMIT;\n const plan = planRelationshipRemediation(invocation.assembly, {\n isTerminal,\n redundancyLimit: limit,\n ...(invocation.sample === undefined\n ? {}\n : { maxSampleSize: invocation.sample }),\n ...(invocation.exemptIsolates.length === 0\n ? {}\n : { exemptIsolates: invocation.exemptIsolates }),\n });\n const byOp: Record<string, number> = {};\n const byCode: Record<string, number> = {};\n for (const step of plan.steps) {\n byOp[step.op] = (byOp[step.op] ?? 0) + 1;\n byCode[step.code] = (byCode[step.code] ?? 0) + 1;\n }\n return {\n subcommand: \"plan\",\n step_count: plan.steps.length,\n steps_by_op: byOp,\n steps_by_code: byCode,\n finding_count: plan.report.findings.length,\n truncated: plan.truncated || plan.steps.length > limit,\n cost: {\n visited_nodes: plan.cost.visitedNodes,\n inspected_edges: plan.cost.inspectedEdges,\n },\n ...(invocation.summary ? {} : { steps: plan.steps.slice(0, limit) }),\n };\n}\n\n/** Build the deterministic memoization key covering every query-shaping input. */\nfunction buildGraphQueryKey(\n subcommand: GraphSubcommand,\n root: string | undefined,\n pathsTarget: string | undefined,\n invocation: GraphInvocation,\n): string {\n return JSON.stringify({\n subcommand,\n root: root ?? null,\n target: pathsTarget ?? null,\n kinds: invocation.kinds ?? null,\n maxDepth: invocation.maxDepth ?? null,\n limit: invocation.limit ?? null,\n after: invocation.after ?? null,\n direction: invocation.direction,\n maxPaths: invocation.maxPaths ?? null,\n sample: invocation.sample ?? null,\n // The audit consumes exemptions as a case-insensitive set, so the key\n // must not distinguish logically identical spellings or orderings.\n exemptIsolates: [\n ...new Set(invocation.exemptIsolates.map((id) => id.toLowerCase())),\n ].sort(),\n summary: invocation.summary,\n });\n}\n\n/** Dispatch one parsed graph subcommand to its executor. */\nfunction executeGraphSubcommand(\n subcommand: GraphSubcommand,\n root: string | undefined,\n pathsTarget: string | undefined,\n invocation: GraphInvocation,\n isTerminal: (status: string) => boolean,\n): GraphResult {\n if (subcommand === \"analyze\") return runGraphAnalyze(invocation);\n if (subcommand === \"audit\") return runGraphAudit(invocation, isTerminal);\n if (subcommand === \"plan\") return runGraphPlan(invocation, isTerminal);\n if (subcommand === \"communities\") return runGraphCommunities(invocation);\n if (subcommand === \"redundancy\") return runGraphRedundancy(invocation);\n if (subcommand === \"dominators\") return runGraphDominators(root!, invocation);\n if (subcommand === \"paths\")\n return runGraphPaths(root!, pathsTarget!, invocation);\n if (subcommand === \"impact\") return runGraphImpact(root!, invocation);\n return runGraphTraversal(subcommand, root!, invocation);\n}\n\n/** Implements run graph for the public runtime surface of this module. */\nexport async function runGraph(\n subcommandRaw: string,\n id: string | undefined,\n target: string | undefined,\n options: GraphCommandOptions,\n global: GlobalOptions,\n): Promise<GraphResult> {\n const subcommand = parseGraphSubcommand(subcommandRaw, id, target);\n const pmRoot = resolvePmRoot(process.cwd(), global.path);\n if (!(await pathExists(getSettingsPath(pmRoot)))) {\n throw new PmCliError(\n `Tracker is not initialized at ${pmRoot}. Run pm init first.`,\n EXIT_CODE.NOT_FOUND,\n );\n }\n const settings = await readSettings(pmRoot);\n const typeRegistry = resolveItemTypeRegistry(\n settings,\n getActiveExtensionRegistrations(),\n );\n const items = await listAllItemMetadataLight(\n pmRoot,\n settings.item_format,\n typeRegistry.type_to_folder,\n undefined,\n settings.schema,\n );\n const statusRegistry = resolveRuntimeStatusRegistry(settings.schema);\n const isTerminal = (status: string): boolean =>\n isTerminalStatus(status, statusRegistry);\n const kinds = parseKinds(options.kind);\n const lookup = workspaceGraphCache().lookup(\n pmRoot,\n computeWorkspaceGraphFingerprint(items, isTerminal),\n () => assembleWorkspaceRelationshipGraph(items, isTerminal),\n );\n const invocation: GraphInvocation = {\n assembly: lookup.assembly,\n ...(kinds === undefined ? {} : { kinds }),\n maxDepth: parseMaxDepth(options.maxDepth),\n limit: parsePositiveInteger(options.limit, \"limit\"),\n after: options.after?.trim() || undefined,\n direction: parseDirection(options.direction),\n maxPaths: parsePositiveInteger(options.maxPaths, \"max-paths\"),\n sample: parsePositiveInteger(options.sample, \"sample\"),\n exemptIsolates: normalizeIdList(options.exemptIsolate),\n summary: options.summary === true,\n };\n const root = ROOTED_SUBCOMMANDS.has(subcommand)\n ? canonicalizeGraphId(invocation.assembly, id!)\n : undefined;\n const pathsTarget =\n subcommand === \"paths\"\n ? canonicalizeGraphId(invocation.assembly, target!)\n : undefined;\n const memo = lookup.memoize(\n buildGraphQueryKey(subcommand, root, pathsTarget, invocation),\n () =>\n executeGraphSubcommand(\n subcommand,\n root,\n pathsTarget,\n invocation,\n isTerminal,\n ),\n );\n return {\n ...memo.value,\n cache: {\n fingerprint: lookup.fingerprint.slice(0, 12),\n assembly: lookup.assemblyReused ? \"hit\" : \"miss\",\n result: memo.reused ? \"hit\" : \"miss\",\n },\n };\n}\n"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;;;AACH,OAAO,EAAE,+BAA+B,EAAE,MAAM,gCAAgC,CAAC;AACjF,OAAO,EAAE,UA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CAAC;IACF,OAAO;QACL,GAAG,IAAI,CAAC,KAAK;QACb,KAAK,EAAE;YACL,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;YAC5C,QAAQ,EAAE,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM;YAChD,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM;SACrC;KACF,CAAC;AACJ,CAAC","debugId":"3d4c5f7b-bcd4-569b-8bea-b06cc9f115e5"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module sdk/graph/traversal
|
|
3
|
+
*
|
|
4
|
+
* Registry-semantics graph traversal primitives layered over the bounded
|
|
5
|
+
* relationship kernel: hierarchy walks (ancestors/descendants), execution-order
|
|
6
|
+
* walks (predecessors/successors), and bounded simple-path enumeration. Every
|
|
7
|
+
* query is deterministic, cancellable, resumable via an explicit cursor, and
|
|
8
|
+
* reports exact cost and truncation metadata so agents can budget follow-up
|
|
9
|
+
* calls without re-reading the workspace.
|
|
10
|
+
*/
|
|
11
|
+
import { RelationshipGraph, type RelationshipEdge, type RelationshipKindDefinition, type RelationshipQueryOptions, type RelationshipQueryResult } from "../relationships.js";
|
|
12
|
+
/**
|
|
13
|
+
* Shared bounded-traversal controls extended with deterministic resumption.
|
|
14
|
+
* Semantic hierarchy and ordering orientation comes from the relationship-kind
|
|
15
|
+
* registry, so callers cannot supply the generic graph `direction` option.
|
|
16
|
+
*/
|
|
17
|
+
export interface GraphTraversalOptions extends Omit<RelationshipQueryOptions, "direction"> {
|
|
18
|
+
/**
|
|
19
|
+
* Resume emission after this previously returned node identifier. The
|
|
20
|
+
* traversal re-walks the same deterministic sequence and starts emitting
|
|
21
|
+
* after the cursor node; an identifier the sequence never reaches fails fast
|
|
22
|
+
* instead of silently returning an empty page.
|
|
23
|
+
*/
|
|
24
|
+
after?: string;
|
|
25
|
+
}
|
|
26
|
+
/** One enumerated simple path between two nodes. */
|
|
27
|
+
export interface RelationshipPath {
|
|
28
|
+
/** Ordered node identifiers from source to target inclusive. */
|
|
29
|
+
nodes: string[];
|
|
30
|
+
/** Edges connecting consecutive path nodes, in traversal order. */
|
|
31
|
+
edges: RelationshipEdge[];
|
|
32
|
+
/** Number of edges in the path. */
|
|
33
|
+
length: number;
|
|
34
|
+
}
|
|
35
|
+
/** Bounded-path enumeration controls. */
|
|
36
|
+
export interface GraphPathOptions extends RelationshipQueryOptions {
|
|
37
|
+
/** Maximum number of returned paths; defaults to 5. */
|
|
38
|
+
maxPaths?: number;
|
|
39
|
+
/** Safety bound on expanded partial paths before truncation; defaults to 10000. */
|
|
40
|
+
maxVisitedPaths?: number;
|
|
41
|
+
}
|
|
42
|
+
/** Endpoint of a hierarchy edge that represents the structural parent. */
|
|
43
|
+
export declare function hierarchyParentEndpoint(edge: RelationshipEdge, definition: RelationshipKindDefinition): string;
|
|
44
|
+
/** Endpoint of an ordering edge that must finish first. */
|
|
45
|
+
export declare function orderingPredecessorEndpoint(edge: RelationshipEdge, definition: RelationshipKindDefinition): string;
|
|
46
|
+
/**
|
|
47
|
+
* Return the bounded transitive hierarchy ancestors of one node in
|
|
48
|
+
* breadth-first discovery order, honoring each hierarchy kind's declared
|
|
49
|
+
* parent endpoint (so `parent` and inverse `child` spellings agree).
|
|
50
|
+
*/
|
|
51
|
+
export declare function hierarchyAncestors(graph: RelationshipGraph, id: string, options?: GraphTraversalOptions): RelationshipQueryResult<string[]>;
|
|
52
|
+
/**
|
|
53
|
+
* Return the bounded transitive hierarchy descendants of one node in
|
|
54
|
+
* breadth-first discovery order, honoring each hierarchy kind's declared
|
|
55
|
+
* parent endpoint.
|
|
56
|
+
*/
|
|
57
|
+
export declare function hierarchyDescendants(graph: RelationshipGraph, id: string, options?: GraphTraversalOptions): RelationshipQueryResult<string[]>;
|
|
58
|
+
/**
|
|
59
|
+
* Return the bounded transitive execution predecessors of one node — the work
|
|
60
|
+
* that must finish before it — in breadth-first discovery order, honoring each
|
|
61
|
+
* ordering kind's declared precedence (so `blocked_by` and inverse `blocks`
|
|
62
|
+
* spellings agree).
|
|
63
|
+
*/
|
|
64
|
+
export declare function orderingPredecessors(graph: RelationshipGraph, id: string, options?: GraphTraversalOptions): RelationshipQueryResult<string[]>;
|
|
65
|
+
/**
|
|
66
|
+
* Return the bounded transitive execution successors of one node — the work
|
|
67
|
+
* this node gates — in breadth-first discovery order, honoring each ordering
|
|
68
|
+
* kind's declared precedence.
|
|
69
|
+
*/
|
|
70
|
+
export declare function orderingSuccessors(graph: RelationshipGraph, id: string, options?: GraphTraversalOptions): RelationshipQueryResult<string[]>;
|
|
71
|
+
/**
|
|
72
|
+
* Enumerate bounded simple paths between two nodes, shortest first and
|
|
73
|
+
* lexicographic within equal length. Traversal honors direction and kind
|
|
74
|
+
* filters, caps returned paths, and reports truncation when depth, path-count,
|
|
75
|
+
* or the expansion-safety bound stops the search early.
|
|
76
|
+
*/
|
|
77
|
+
export declare function enumerateRelationshipPaths(graph: RelationshipGraph, source: string, target: string, options?: GraphPathOptions): RelationshipQueryResult<RelationshipPath[]>;
|