@unbrained/pm-cli 2026.9.19 → 2026.9.21

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.
Files changed (149) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +954 -924
  3. package/dist/cli/main.d.ts +10 -76
  4. package/dist/cli/main.js +1 -2
  5. package/dist/cli/register-operations.js +1 -1
  6. package/dist/cli/runtime/activation.d.ts +51 -0
  7. package/dist/cli/runtime/activation.js +2 -0
  8. package/dist/cli/runtime/invocation-options.d.ts +41 -0
  9. package/dist/cli/runtime/invocation-options.js +2 -0
  10. package/dist/cli/runtime/selection.d.ts +29 -0
  11. package/dist/cli/runtime/selection.js +2 -0
  12. package/dist/cli/runtime/telemetry-outcome.d.ts +20 -0
  13. package/dist/cli/runtime/telemetry-outcome.js +2 -0
  14. package/dist/cli-bundle/bundle-manifest.json +150 -150
  15. package/dist/cli-bundle/chunks/{chunk-QA4GUEKJ.js → chunk-2QLXN6HZ.js} +46 -46
  16. package/dist/cli-bundle/chunks/chunk-2UNYUB4A.js +2 -0
  17. package/dist/cli-bundle/chunks/chunk-4SI67A2F.js +8 -0
  18. package/dist/cli-bundle/chunks/chunk-7YUYLYJQ.js +6 -0
  19. package/dist/cli-bundle/chunks/{chunk-7CN53F4S.js → chunk-FBWAECBI.js} +3 -3
  20. package/dist/cli-bundle/chunks/chunk-GRHSNUQO.js +20 -0
  21. package/dist/cli-bundle/chunks/chunk-HAFSMFJK.js +3 -0
  22. package/dist/cli-bundle/chunks/chunk-JBJUOOJI.js +238 -0
  23. package/dist/cli-bundle/chunks/chunk-K7RWRJLT.js +29 -0
  24. package/dist/cli-bundle/chunks/chunk-NHRB3L5T.js +2 -0
  25. package/dist/cli-bundle/chunks/{chunk-CCLWCESZ.js → chunk-QZTS23BV.js} +2 -2
  26. package/dist/cli-bundle/chunks/{chunk-K4VAU4HU.js → chunk-SDLBF4PY.js} +1252 -1252
  27. package/dist/cli-bundle/chunks/{register-list-query-RMZNHSII.js → register-list-query-5V43MYPN.js} +6 -6
  28. package/dist/cli-bundle/chunks/{register-mutation-HJGSGX3H.js → register-mutation-DXES37MA.js} +4 -4
  29. package/dist/cli-bundle/chunks/register-operations-LJU5H2CU.js +2 -0
  30. package/dist/cli-bundle/chunks/register-setup-HJUNGYBB.js +2 -0
  31. package/dist/cli-bundle/focused-chunks/chunk-3XPBKIV6.js +12 -0
  32. package/dist/cli-bundle/focused-chunks/{chunk-7Y7PAC56.js → chunk-5BLRMUMK.js} +2 -2
  33. package/dist/cli-bundle/focused-chunks/{chunk-5SZ4JSPZ.js → chunk-6MNKQKT6.js} +2 -2
  34. package/dist/cli-bundle/focused-chunks/{chunk-IKPR4VVN.js → chunk-DPBTIFW7.js} +2 -2
  35. package/dist/cli-bundle/focused-chunks/{chunk-J3GN4SQT.js → chunk-DRNXMOSV.js} +2 -2
  36. package/dist/cli-bundle/focused-chunks/{chunk-P4BA7OX7.js → chunk-FXAZPSU6.js} +7 -7
  37. package/dist/cli-bundle/focused-chunks/{chunk-ARK4FIO4.js → chunk-HYPK5OPA.js} +2 -2
  38. package/dist/cli-bundle/focused-chunks/{chunk-I4WDON3K.js → chunk-IA5CCSBB.js} +2 -2
  39. package/dist/cli-bundle/focused-chunks/{chunk-CJ4QA4RW.js → chunk-ISEOBALS.js} +2 -2
  40. package/dist/cli-bundle/focused-chunks/{chunk-ZI2YBJFH.js → chunk-K5ZCBC6Y.js} +3 -3
  41. package/dist/cli-bundle/focused-chunks/{chunk-V3YMNAO7.js → chunk-L6L4XCLY.js} +2 -2
  42. package/dist/cli-bundle/focused-chunks/{chunk-TDHVROGL.js → chunk-N6KI3LWF.js} +2 -2
  43. package/dist/cli-bundle/focused-chunks/chunk-PC6ZZVNP.js +20 -0
  44. package/dist/cli-bundle/focused-chunks/chunk-RQL5WLNZ.js +30 -0
  45. package/dist/cli-bundle/focused-chunks/{chunk-ZDBKYZFE.js → chunk-U2SB2BMM.js} +2 -2
  46. package/dist/cli-bundle/focused-chunks/{chunk-YDFEWXXZ.js → chunk-UIS5FVHH.js} +53 -53
  47. package/dist/cli-bundle/main.js +26 -27
  48. package/dist/cli-bundle/sdk-authoring.js +1 -1
  49. package/dist/cli-bundle/sdk-contracts.js +1 -1
  50. package/dist/cli-bundle/sdk-core.js +39 -39
  51. package/dist/cli-bundle/sdk-governance.js +1 -1
  52. package/dist/cli-bundle/sdk-graph.js +1 -1
  53. package/dist/cli-bundle/sdk-merge.js +42 -42
  54. package/dist/cli-bundle/sdk-query.js +1 -1
  55. package/dist/cli-bundle/sdk-runtime.js +1 -1
  56. package/dist/cli-bundle/sdk-testing.js +1 -1
  57. package/dist/cli-bundle/sdk.js +8 -8
  58. package/dist/core/diagnostics/remediation.js +1 -1
  59. package/dist/core/extensions/extension-types.d.ts +2 -2
  60. package/dist/core/extensions/loader.d.ts +9 -15
  61. package/dist/core/extensions/loader.js +1 -1
  62. package/dist/core/extensions/manifest-parser.d.ts +5 -0
  63. package/dist/core/extensions/manifest-parser.js +2 -0
  64. package/dist/core/extensions/registration-contracts.d.ts +34 -0
  65. package/dist/core/extensions/registration-contracts.js +2 -0
  66. package/dist/core/governance/issue-codes.d.ts +10 -1
  67. package/dist/core/governance/issue-codes.js +1 -1
  68. package/dist/core/validate/fix-planning.d.ts +3 -3
  69. package/dist/core/validate/fix-planning.js +1 -1
  70. package/dist/sdk/agent/refusal-reachability.d.ts +1 -1
  71. package/dist/sdk/completion/bash.d.ts +3 -0
  72. package/dist/sdk/completion/bash.js +2 -0
  73. package/dist/sdk/completion/fish.d.ts +3 -0
  74. package/dist/sdk/completion/fish.js +1054 -0
  75. package/dist/sdk/completion/shared.d.ts +103 -0
  76. package/dist/sdk/completion/shared.js +2 -0
  77. package/dist/sdk/completion/zsh.d.ts +3 -0
  78. package/dist/sdk/completion/zsh.js +1109 -0
  79. package/dist/sdk/completion.d.ts +5 -30
  80. package/dist/sdk/completion.js +1 -2160
  81. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
  82. package/dist/sdk/governance/closure-timestamps.d.ts +32 -0
  83. package/dist/sdk/governance/closure-timestamps.js +2 -0
  84. package/dist/sdk/governance/validate-normalization.d.ts +2 -0
  85. package/dist/sdk/governance/validate-normalization.js +1 -1
  86. package/dist/sdk/governance/validate.js +1 -1
  87. package/dist/sdk/governance.d.ts +1 -0
  88. package/dist/sdk/governance.js +1 -1
  89. package/dist/sdk/public-surface.json +1 -1
  90. package/dist/sdk/query/search/corpus.d.ts +27 -0
  91. package/dist/sdk/query/search/corpus.js +2 -0
  92. package/dist/sdk/query/search/filters.d.ts +27 -0
  93. package/dist/sdk/query/search/filters.js +2 -0
  94. package/dist/sdk/query/search/input.d.ts +28 -0
  95. package/dist/sdk/query/search/input.js +2 -0
  96. package/dist/sdk/query/search/lexical.d.ts +34 -0
  97. package/dist/sdk/query/search/lexical.js +2 -0
  98. package/dist/sdk/query/search/response.d.ts +34 -0
  99. package/dist/sdk/query/search/response.js +2 -0
  100. package/dist/sdk/query/search/semantic.d.ts +229 -0
  101. package/dist/sdk/query/search/semantic.js +3 -0
  102. package/dist/sdk/query/search/types.d.ts +123 -0
  103. package/dist/sdk/query/search/types.js +2 -0
  104. package/dist/sdk/query/search.d.ts +13 -364
  105. package/dist/sdk/query/search.js +1 -2
  106. package/dist/sdk/runtime/actions.d.ts +4 -0
  107. package/dist/sdk/runtime/actions.js +2 -0
  108. package/dist/sdk/runtime/context.d.ts +38 -0
  109. package/dist/sdk/runtime/context.js +2 -0
  110. package/dist/sdk/runtime/schema.d.ts +4 -0
  111. package/dist/sdk/runtime/schema.js +2 -0
  112. package/dist/sdk/runtime.d.ts +90 -95
  113. package/dist/sdk/runtime.js +1 -1
  114. package/docs/ARCHITECTURE.md +68 -0
  115. package/docs/HISTORY_GOVERNANCE_REPAIR.md +66 -0
  116. package/docs/README.md +2 -0
  117. package/docs/VALIDATION_PORTABILITY.md +82 -0
  118. package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +4 -3
  119. package/marketplace.json +2 -2
  120. package/package.json +6 -6
  121. package/packages/pm-beads/package.json +1 -1
  122. package/packages/pm-calendar/package.json +1 -1
  123. package/packages/pm-command-kit/package.json +1 -1
  124. package/packages/pm-digital-twin/package.json +1 -1
  125. package/packages/pm-governance-audit/package.json +1 -1
  126. package/packages/pm-guide-shell/extensions/guide-shell/runtime.ts +23 -17
  127. package/packages/pm-guide-shell/package.json +1 -1
  128. package/packages/pm-kanban/package.json +1 -1
  129. package/packages/pm-lifecycle-hooks/package.json +1 -1
  130. package/packages/pm-linked-test-adapters/package.json +1 -1
  131. package/packages/pm-search-advanced/package.json +1 -1
  132. package/packages/pm-templates/package.json +1 -1
  133. package/packages/pm-todos/package.json +1 -1
  134. package/packages/pm-vcs/package.json +1 -1
  135. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  136. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  137. package/dist/cli-bundle/chunks/chunk-AACGU5IA.js +0 -3
  138. package/dist/cli-bundle/chunks/chunk-J7NP7QLW.js +0 -6
  139. package/dist/cli-bundle/chunks/chunk-KHN4NMKT.js +0 -238
  140. package/dist/cli-bundle/chunks/chunk-KYG2QKNY.js +0 -29
  141. package/dist/cli-bundle/chunks/chunk-OQS2Y6VN.js +0 -2
  142. package/dist/cli-bundle/chunks/chunk-QTHR3LXF.js +0 -20
  143. package/dist/cli-bundle/chunks/chunk-RVMDPIGD.js +0 -2
  144. package/dist/cli-bundle/chunks/chunk-WASMH647.js +0 -8
  145. package/dist/cli-bundle/chunks/register-operations-LBEMFUMM.js +0 -2
  146. package/dist/cli-bundle/chunks/register-setup-MU557JAA.js +0 -2
  147. package/dist/cli-bundle/focused-chunks/chunk-I32L3FWW.js +0 -12
  148. package/dist/cli-bundle/focused-chunks/chunk-OOZHQFBF.js +0 -20
  149. package/dist/cli-bundle/focused-chunks/chunk-QL4MO5M2.js +0 -30
@@ -0,0 +1,123 @@
1
+ /**
2
+ * @module sdk/query/search/types
3
+ * Shared search result and pipeline state contracts; no runtime dependencies.
4
+ */
5
+ import { type QueryExpansionConfig, type RerankConfig } from "../../../core/search/relevance.js";
6
+ import type { ItemMetadata } from "../../../types/index.js";
7
+ import { type WorkspaceMemoryRollup } from "../../workspace-memory.js";
8
+ import { type SearchMatchMode, type SearchModeSource, type SearchOptions, type SearchProjectionConfig, type SearchProjectionMode } from "../search-contracts.js";
9
+ import { type SearchMode } from "../search-rendering.js";
10
+ /** Documents the search hit payload exchanged by command, SDK, and package integrations. */
11
+ export interface SearchHit {
12
+ /** Value that configures or reports item for this contract. */
13
+ item: ItemMetadata;
14
+ /** Value that configures or reports score for this contract. */
15
+ score: number;
16
+ /** Value that configures or reports matched fields for this contract. */
17
+ matched_fields: string[];
18
+ /** Value that configures or reports matched all terms for this contract. */
19
+ matched_all_terms?: boolean;
20
+ /** Value that configures or reports exact id match for this contract. */
21
+ exact_id_match?: boolean;
22
+ /** Value that configures or reports highlights for this contract. */
23
+ highlights?: SearchHitHighlight[];
24
+ }
25
+ /**
26
+ * Pairs a matched field name with a snippet of its text where every matching
27
+ * token run is wrapped in the {@link HIGHLIGHT_OPEN}/{@link HIGHLIGHT_CLOSE}
28
+ * markers. Emitted on {@link SearchHit.highlights} when `--highlight` is set.
29
+ */
30
+ export interface SearchHitHighlight {
31
+ /** Value that configures or reports field for this contract. */
32
+ field: string;
33
+ /** Value that configures or reports snippet for this contract. */
34
+ snippet: string;
35
+ }
36
+ /** Restricts search result item values accepted by command, SDK, and storage contracts. */
37
+ export type SearchResultItem = SearchHit | Record<string, unknown>;
38
+ interface SearchResultBase {
39
+ query: string;
40
+ mode: SearchMode;
41
+ /** Which layer chose `mode` before any runtime fallback: the caller, `search.default_mode`, or the workspace-state default. */
42
+ mode_source?: SearchModeSource;
43
+ items: SearchResultItem[];
44
+ count: number;
45
+ total?: number;
46
+ /** Whether additional ranked hits remain after this page. */
47
+ has_more?: boolean;
48
+ /** Opaque continuation cursor when additional hits remain. */
49
+ next_cursor?: string;
50
+ /** Effective page size for this response. */
51
+ applied_limit?: number;
52
+ /** Explicit marker that the response is a bounded page. */
53
+ truncated?: true;
54
+ count_only?: boolean;
55
+ warnings?: string[];
56
+ /** Historical epoch and epic rollups matching the query in large workspaces. */
57
+ workspace_memory?: {
58
+ /** Persistence freshness for the derived projection. */
59
+ cache_status: "fresh" | "rebuilt";
60
+ /** Matching bounded rollups, ordered by term coverage and recency. */
61
+ matches: WorkspaceMemoryRollup[];
62
+ };
63
+ }
64
+ /** Documents the search compact result payload exchanged by command, SDK, and package integrations. */
65
+ export interface SearchCompactResult extends SearchResultBase {
66
+ /** Value that configures or reports filters for this contract. */
67
+ filters: Record<string, unknown>;
68
+ /** Value that configures or reports projection for this contract. */
69
+ projection?: undefined;
70
+ /** Value that configures or reports now for this contract. */
71
+ now?: undefined;
72
+ }
73
+ /** Documents the search verbose result payload exchanged by command, SDK, and package integrations. */
74
+ export interface SearchVerboseResult extends SearchResultBase {
75
+ /** Value that configures or reports filters for this contract. */
76
+ filters: Record<string, unknown>;
77
+ /** Value that configures or reports projection for this contract. */
78
+ projection: {
79
+ mode: SearchProjectionMode;
80
+ fields: string[] | null;
81
+ };
82
+ /** Value that configures or reports now for this contract. */
83
+ now: string;
84
+ }
85
+ /** Restricts search result values accepted by command, SDK, and storage contracts. */
86
+ export type SearchResult = SearchCompactResult | SearchVerboseResult;
87
+ /** Validated search input shared by corpus selection, retrieval and result construction. */
88
+ interface PreparedSearchInput {
89
+ query: string;
90
+ options: SearchOptions;
91
+ inlineWarnings: string[];
92
+ highlight: boolean;
93
+ includeLinked: boolean;
94
+ titleExact: boolean;
95
+ phraseExact: boolean;
96
+ matchMode: SearchMatchMode;
97
+ minScoreOverride: number | undefined;
98
+ countOnly: boolean;
99
+ tokens: string[];
100
+ normalizedQuery: string;
101
+ limit: number | undefined;
102
+ projection: SearchProjectionConfig;
103
+ modeWasExplicit: boolean;
104
+ }
105
+ /** Resolved query settings and evidence retained while shaping the final response. */
106
+ interface SearchResponseContext {
107
+ query: string;
108
+ effectiveMode: SearchMode;
109
+ modeSource: SearchModeSource;
110
+ matchMode: SearchMatchMode;
111
+ options: SearchOptions;
112
+ includeLinked: boolean;
113
+ titleExact: boolean;
114
+ phraseExact: boolean;
115
+ scoreThreshold: number;
116
+ hybridSemanticWeight: number;
117
+ queryExpansion: QueryExpansionConfig;
118
+ rerank: RerankConfig;
119
+ projection: SearchProjectionConfig;
120
+ warnings: string[];
121
+ runtimeFieldFilters: Record<string, unknown>;
122
+ }
123
+ export { PreparedSearchInput, SearchResponseContext };
@@ -0,0 +1,2 @@
1
+ !(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]="e5f69492-4892-582c-af77-a8e142d02d37")}catch(e2){}})();
2
+ //# sourceMappingURL=types.js.map
@@ -1,207 +1,17 @@
1
- import { type ItemTypeRegistry } from "../../core/item/type-registry.js";
2
- import { type EmbeddingProviderConfig, type EmbeddingProviderResolution } from "../../core/search/providers.js";
3
- import { type QueryExpansionConfig, type RerankConfig } from "../../core/search/relevance.js";
4
- import { type VectorQueryHit, type VectorStoreConfig, type VectorStoreResolution } from "../../core/search/vector-stores.js";
5
- import { type Bm25Params } from "../../core/search/bm25.js";
6
- import { type LifecycleClassifier } from "../../core/governance/metadata-coverage.js";
7
- import { buildCompactSearchFilterSummary, buildVerboseSearchFilters, type SearchMode } from "./search-rendering.js";
8
- import { type RuntimeStatusRegistry } from "../../core/schema/runtime-schema.js";
9
1
  import type { GlobalOptions } from "../../core/shared/command-types.js";
10
- import type { ItemDocument, ItemFormat, ItemMetadata, ItemStatus, PmSettings } from "../../types/index.js";
11
- import { parseSearchProjection, parseSearchTokens, parseTimestampWindow, validateSearchProjectionFields, type SearchMatchMode, type SearchModeSource, type SearchOptions, type SearchProjectionConfig, type SearchProjectionMode, type SearchTuning } from "./search-contracts.js";
12
- import { type WorkspaceMemoryRollup } from "../workspace-memory.js";
13
- export type { SearchDefaultMode, SearchMatchMode, SearchModeResolution, SearchModeSource, SearchOptions, SearchTuning, } from "./search-contracts.js";
14
- export { resolveEffectiveSearchMode, resolveHybridSemanticWeight, resolveSearchMaxResults, resolveSearchScoreThreshold, resolveSearchTuning, } from "./search-contracts.js";
15
- declare const INLINE_QUERY_FILTER_FIELDS: readonly ["tag", "status", "type", "priority"];
16
- type InlineQueryFilterField = (typeof INLINE_QUERY_FILTER_FIELDS)[number];
17
- /** Documents the search hit payload exchanged by command, SDK, and package integrations. */
18
- export interface SearchHit {
19
- /** Value that configures or reports item for this contract. */
20
- item: ItemMetadata;
21
- /** Value that configures or reports score for this contract. */
22
- score: number;
23
- /** Value that configures or reports matched fields for this contract. */
24
- matched_fields: string[];
25
- /** Value that configures or reports matched all terms for this contract. */
26
- matched_all_terms?: boolean;
27
- /** Value that configures or reports exact id match for this contract. */
28
- exact_id_match?: boolean;
29
- /** Value that configures or reports highlights for this contract. */
30
- highlights?: SearchHitHighlight[];
31
- }
32
- /**
33
- * Pairs a matched field name with a snippet of its text where every matching
34
- * token run is wrapped in the {@link HIGHLIGHT_OPEN}/{@link HIGHLIGHT_CLOSE}
35
- * markers. Emitted on {@link SearchHit.highlights} when `--highlight` is set.
36
- */
37
- export interface SearchHitHighlight {
38
- /** Value that configures or reports field for this contract. */
39
- field: string;
40
- /** Value that configures or reports snippet for this contract. */
41
- snippet: string;
42
- }
43
- /** Restricts search result item values accepted by command, SDK, and storage contracts. */
44
- export type SearchResultItem = SearchHit | Record<string, unknown>;
45
- interface SearchResultBase {
46
- query: string;
47
- mode: SearchMode;
48
- /** Which layer chose `mode` before any runtime fallback: the caller, `search.default_mode`, or the workspace-state default. */
49
- mode_source?: SearchModeSource;
50
- items: SearchResultItem[];
51
- count: number;
52
- total?: number;
53
- /** Whether additional ranked hits remain after this page. */
54
- has_more?: boolean;
55
- /** Opaque continuation cursor when additional hits remain. */
56
- next_cursor?: string;
57
- /** Effective page size for this response. */
58
- applied_limit?: number;
59
- /** Explicit marker that the response is a bounded page. */
60
- truncated?: true;
61
- count_only?: boolean;
62
- warnings?: string[];
63
- /** Historical epoch and epic rollups matching the query in large workspaces. */
64
- workspace_memory?: {
65
- /** Persistence freshness for the derived projection. */
66
- cache_status: "fresh" | "rebuilt";
67
- /** Matching bounded rollups, ordered by term coverage and recency. */
68
- matches: WorkspaceMemoryRollup[];
69
- };
70
- }
71
- /** Documents the search compact result payload exchanged by command, SDK, and package integrations. */
72
- export interface SearchCompactResult extends SearchResultBase {
73
- /** Value that configures or reports filters for this contract. */
74
- filters: Record<string, unknown>;
75
- /** Value that configures or reports projection for this contract. */
76
- projection?: undefined;
77
- /** Value that configures or reports now for this contract. */
78
- now?: undefined;
79
- }
80
- /** Documents the search verbose result payload exchanged by command, SDK, and package integrations. */
81
- export interface SearchVerboseResult extends SearchResultBase {
82
- /** Value that configures or reports filters for this contract. */
83
- filters: Record<string, unknown>;
84
- /** Value that configures or reports projection for this contract. */
85
- projection: {
86
- mode: SearchProjectionMode;
87
- fields: string[] | null;
88
- };
89
- /** Value that configures or reports now for this contract. */
90
- now: string;
91
- }
92
- /** Restricts search result values accepted by command, SDK, and storage contracts. */
93
- export type SearchResult = SearchCompactResult | SearchVerboseResult;
94
- interface ExtensionSearchProviderContext {
95
- query: string;
96
- mode: SearchMode;
97
- tokens: string[];
98
- options: SearchOptions;
99
- settings: PmSettings;
100
- documents: ItemDocument[];
101
- }
102
- interface ExtensionSearchProviderHit {
103
- id: string;
104
- score: number;
105
- matched_fields?: string[];
106
- }
107
- type ExtensionSearchProviderQuery = (context: ExtensionSearchProviderContext) => Promise<ExtensionSearchProviderHit[] | {
108
- hits?: ExtensionSearchProviderHit[];
109
- }> | ExtensionSearchProviderHit[] | {
110
- hits?: ExtensionSearchProviderHit[];
111
- };
112
- interface ExtensionSearchProviderQueryExpansionContext {
113
- query: string;
114
- mode: Exclude<SearchMode, "keyword">;
115
- settings: PmSettings;
116
- }
117
- type ExtensionSearchProviderQueryExpansion = (context: ExtensionSearchProviderQueryExpansionContext) => Promise<string[] | {
118
- queries?: string[];
119
- }> | string[] | {
120
- queries?: string[];
121
- };
122
- interface ExtensionSearchProviderRerankCandidate {
123
- id: string;
124
- text: string;
125
- score: number;
126
- }
127
- interface ExtensionSearchProviderRerankContext {
128
- query: string;
129
- mode: "hybrid";
130
- model: string;
131
- top_k: number;
132
- settings: PmSettings;
133
- candidates: ExtensionSearchProviderRerankCandidate[];
134
- }
135
- type ExtensionSearchProviderRerank = (context: ExtensionSearchProviderRerankContext) => Promise<Array<{
136
- id?: unknown;
137
- score?: unknown;
138
- }> | {
139
- hits?: Array<{
140
- id?: unknown;
141
- score?: unknown;
142
- }>;
143
- }> | Array<{
144
- id?: unknown;
145
- score?: unknown;
146
- }> | {
147
- hits?: Array<{
148
- id?: unknown;
149
- score?: unknown;
150
- }>;
151
- };
152
- type ExtensionVectorQuery = (context: {
153
- vector: number[];
154
- limit: number;
155
- settings: PmSettings;
156
- }) => Promise<VectorQueryHit[]> | VectorQueryHit[];
157
- type ExtensionVectorUpsert = (context: {
158
- points: Array<{
159
- id: string;
160
- vector: number[];
161
- payload: Record<string, unknown>;
162
- }>;
163
- settings: PmSettings;
164
- }) => Promise<void> | void;
165
- type ExtensionVectorAdapter = {
166
- adapterName: string;
167
- query?: ExtensionVectorQuery;
168
- upsert?: ExtensionVectorUpsert;
169
- };
170
- type ImplicitSemanticFallbackReason = "timeout" | "connection" | "error";
171
- /**
172
- * Aggregate the `code` strings found along an error's `cause` chain.
173
- *
174
- * undici (Node's fetch) collapses connection errors to the generic message
175
- * "fetch failed" and stashes the real syscall code (e.g. `ECONNREFUSED`) on
176
- * `error.cause.code`. Walking the chain (bounded depth) lets the fallback
177
- * classifier label a downed/unreachable Ollama backend as "connection" rather
178
- * than the catch-all "error".
179
- */
180
- export declare function collectErrorCauseCodes(error: unknown): string;
181
- /**
182
- * Classify why an implicit/explicit semantic search degraded to keyword mode,
183
- * inspecting both the error message and the {@link collectErrorCauseCodes} chain
184
- * so undici's generic "fetch failed" is recognised as a connection failure.
185
- */
186
- export declare function classifyImplicitSemanticFallbackReason(error: unknown): ImplicitSemanticFallbackReason;
187
- declare function buildExplicitSemanticFallbackWarning(requestedMode: SearchMode, error: unknown): string;
188
- interface VectorIndexRecoveryRegistrations {
189
- commands?: readonly {
190
- command: string;
191
- }[];
192
- }
193
- interface VectorIndexRecovery {
194
- command: string;
195
- args: string[];
196
- follow_up_command?: string;
197
- follow_up_args?: string[];
198
- }
199
- /** Resolve an executable reindex path from the active extension capability surface. */
200
- export declare function resolveVectorIndexRecovery(registrations: VectorIndexRecoveryRegistrations | null): VectorIndexRecovery;
201
- /** Compare the vectorization-status ledger against the filtered corpus and, when the vector index is behind, emit a one-line stderr warning plus a structured `vector_index_stale:N` entry in the JSON warnings array. Best-effort: ledger read failures fall through silently — the existing semantic/hybrid fallback paths cover backend errors. */
202
- declare function maybeEmitVectorIndexStaleWarning(pmRoot: string, filteredDocuments: ItemDocument[], warnings: string[]): Promise<void>;
203
- /** Format token-efficient vector-index staleness and executable recovery warnings. */
204
- export declare function formatVectorIndexRecoveryWarnings(staleCount: number, recovery: VectorIndexRecovery): string[];
2
+ import { parseSearchProjection, parseSearchTokens, parseTimestampWindow, validateSearchProjectionFields, type SearchOptions } from "./search-contracts.js";
3
+ import { buildCompactSearchFilterSummary, buildVerboseSearchFilters } from "./search-rendering.js";
4
+ import { collectLinkedPaths, loadDocuments, loadLinkedCorpus, resolveLinkedCorpusRoots } from "./search/corpus.js";
5
+ import { applyExactQueryFilters, applyFilters, collectExactPhraseFields, dependencyEntries, documentContainsExactPhrase, stringArray, textEntries } from "./search/filters.js";
6
+ import { applyInlineQueryFilters, parseInlineQueryFilters } from "./search/input.js";
7
+ import { buildHitHighlights, buildHybridLexicalScore, countOccurrences, highlightFieldSnippet, markTokenRuns, normalizeScoreMap, scoreDocument, sortHits } from "./search/lexical.js";
8
+ import { emptySearchResult, projectSearchHits, readSearchFieldValue } from "./search/response.js";
9
+ import { buildExplicitSemanticFallbackWarning, buildRerankCorpus, buildSemanticHits, classifyImplicitSemanticFallbackReason, collectErrorCauseCodes, combineHybridHits, computeBuiltInBm25Hits, computeSemanticOrHybridHits, maybeEmitVectorIndexStaleWarning, mergeVectorHitsById, normalizeExtensionProviderHits, requireSemanticDependencies, resolveBuiltInBm25Mode, resolveExtensionSearchProvider, resolveExtensionSearchProviderByName, resolveExtensionVectorAdapter } from "./search/semantic.js";
10
+ import type { SearchResult } from "./search/types.js";
11
+ export type { SearchDefaultMode, SearchMatchMode, SearchModeResolution, SearchModeSource, SearchOptions, SearchTuning } from "./search-contracts.js";
12
+ export { resolveEffectiveSearchMode, resolveHybridSemanticWeight, resolveSearchMaxResults, resolveSearchScoreThreshold, resolveSearchTuning } from "./search-contracts.js";
13
+ export { classifyImplicitSemanticFallbackReason, collectErrorCauseCodes, formatVectorIndexRecoveryWarnings, resolveVectorIndexRecovery } from "./search/semantic.js";
14
+ export type { SearchCompactResult, SearchHit, SearchHitHighlight, SearchResult, SearchResultItem, SearchVerboseResult } from "./search/types.js";
205
15
  /** Public contract for test only search command, shared by SDK and presentation-layer consumers. */
206
16
  export declare const _testOnlySearchCommand: {
207
17
  applyFilters: typeof applyFilters;
@@ -251,166 +61,5 @@ export declare const _testOnlySearchCommand: {
251
61
  textEntries: typeof textEntries;
252
62
  validateSearchProjectionFields: typeof validateSearchProjectionFields;
253
63
  };
254
- /** Result of extracting inline `field:value` tokens from a raw search query. */
255
- interface InlineQueryParse {
256
- /** The query with all recognized inline filter tokens removed. */
257
- residualQuery: string;
258
- /** Recognized inline filters keyed by field name; first occurrence per field wins. */
259
- inlineFilters: Partial<Record<InlineQueryFilterField, string>>;
260
- }
261
- /**
262
- * Split a raw search query into its residual keyword text and any inline
263
- * `field:value` filter tokens (GH-157). Recognized fields are
264
- * {@link INLINE_QUERY_FILTER_FIELDS}; the value runs to the end of the token so
265
- * colon-bearing values like `tag:area:search` parse as `{ tag: "area:search" }`.
266
- * Only the first occurrence of each field is captured — later duplicates are left
267
- * in the residual query so they are never silently dropped. Tokens whose prefix
268
- * is not a recognized field (`foo:bar`) stay in the residual query verbatim.
269
- */
270
- declare function parseInlineQueryFilters(query: string): InlineQueryParse;
271
- /** Merge inline `field:value` filters into a search options object (GH-157). Explicit `--field` flags always win: an inline token is applied only when the corresponding option is not already set, and a conflicting inline token is recorded as a `search_inline_filter_ignored:<field>:flag_takes_precedence` warning so the override is observable rather than silent. Returns a fresh options object — the caller's input is never mutated. */
272
- declare function applyInlineQueryFilters(options: SearchOptions, inlineFilters: Partial<Record<InlineQueryFilterField, string>>, warnings: string[]): SearchOptions;
273
- declare function stringArray(value: unknown): string[];
274
- declare function textEntries(value: unknown): Array<{
275
- text: string;
276
- }>;
277
- declare function dependencyEntries(value: unknown): Array<{
278
- id: string;
279
- kind: string;
280
- }>;
281
- declare function collectExactPhraseFields(document: ItemDocument): string[];
282
- declare function documentContainsExactPhrase(document: ItemDocument, normalizedQuery: string): boolean;
283
- declare function applyExactQueryFilters(items: ItemDocument[], normalizedQuery: string, options: {
284
- titleExact: boolean;
285
- phraseExact: boolean;
286
- }): ItemDocument[];
287
- declare function applyFilters(items: ItemDocument[], options: SearchOptions, typeRegistry: ItemTypeRegistry, runtimeFieldFilters: Record<string, unknown>, statusFilter: ItemStatus[] | undefined, lifecycleClassifier: LifecycleClassifier): ItemDocument[];
288
- declare function countOccurrences(haystack: string, needle: string): number;
289
- declare function collectLinkedPaths(item: ItemMetadata): Array<{
290
- scope: "project" | "global";
291
- path: string;
292
- }>;
293
- interface ContainmentRoot {
294
- resolved: string;
295
- realpath: string;
296
- }
297
- interface LinkedCorpusRoots {
298
- projectContainmentRoot: ContainmentRoot | null;
299
- globalContainmentRoot: ContainmentRoot | null;
300
- }
301
- declare function resolveLinkedCorpusRoots(projectRoot: string, globalRoot: string): Promise<LinkedCorpusRoots>;
302
- declare function loadLinkedCorpus(document: ItemDocument, roots: LinkedCorpusRoots): Promise<string>;
303
- /**
304
- * Wrap every case-insensitive occurrence of any query token in `text` with the
305
- * {@link HIGHLIGHT_OPEN}/{@link HIGHLIGHT_CLOSE} markers. Token boundaries follow
306
- * the same substring semantics as the lexical scorer (a token highlights inside
307
- * longer words, matching how it scored), and overlapping matches are coalesced
308
- * by the single combined alternation so markers never nest.
309
- */
310
- declare function markTokenRuns(text: string, tokens: string[]): string;
311
- /**
312
- * Build a single highlighted snippet for one field value (GH-157), or null when
313
- * no token matches. The snippet is a window of {@link HIGHLIGHT_SNIPPET_RADIUS}
314
- * characters on each side of the first match with the matching token runs
315
- * wrapped in markers, prefixed/suffixed with an ellipsis when the field text was
316
- * trimmed. Returning null lets the caller skip fields with no concrete textual
317
- * match (e.g. a field flagged purely by the phrase-coverage bonus).
318
- */
319
- declare function highlightFieldSnippet(text: string, tokens: string[]): string | null;
320
- /** Produce per-field matched-text snippets for a hit (GH-157, `--highlight`). Iterates the hit's already-sorted `matched_fields`, retains only the document-derived searchable fields (skipping synthetic markers like `id`, `semantic`, `rerank`, and `linked_content`), and emits a snippet for each field that still contains a concrete token match. */
321
- declare function buildHitHighlights(document: ItemDocument, matchedFields: string[], tokens: string[]): SearchHitHighlight[];
322
- declare function scoreDocument(document: ItemDocument, tokens: string[], normalizedQuery: string, linkedCorpus: string, tuning: SearchTuning, idPrefix: string, applyCoverageBonus?: boolean): SearchHit | null;
323
- declare function sortHits(items: SearchHit[], statusRegistry: RuntimeStatusRegistry): SearchHit[];
324
- declare function buildHybridLexicalScore(document: ItemDocument, tokens: string[], normalizedQuery: string, includeLinked: boolean, linkedCorpusById: Map<string, string>, tuning: SearchTuning, idPrefix: string, applyCoverageBonus?: boolean): SearchHit | null;
325
- declare function normalizeScoreMap(scoreById: Map<string, number>): Map<string, number>;
326
- declare function emptySearchResult(query: string, mode: SearchMode, matchMode: SearchMatchMode, options: SearchOptions, includeLinked: boolean, scoreThreshold: number, hybridSemanticWeight: number, queryExpansion: QueryExpansionConfig, rerank: RerankConfig, projection: SearchProjectionConfig, warnings: string[], runtimeFieldFilters: Record<string, unknown> | undefined, countOnly: boolean, modeSource: SearchModeSource): SearchResult;
327
- declare function requireSemanticDependencies(requestedMode: Exclude<SearchMode, "keyword">, providerResolution: EmbeddingProviderResolution, vectorResolution: VectorStoreResolution, hasExtensionVectorQuery: boolean): {
328
- provider: EmbeddingProviderConfig;
329
- vectorStore: VectorStoreConfig | null;
330
- };
331
- interface ExtensionSearchProviderHooks {
332
- providerName: string;
333
- query?: ExtensionSearchProviderQuery;
334
- queryExpansion?: ExtensionSearchProviderQueryExpansion;
335
- rerank?: ExtensionSearchProviderRerank;
336
- }
337
- declare function resolveExtensionSearchProviderByName(providerName: string | undefined): ExtensionSearchProviderHooks | null;
338
- declare function resolveExtensionSearchProvider(settings: PmSettings): {
339
- providerName: string;
340
- query: ExtensionSearchProviderQuery;
341
- } | null;
342
- declare function resolveExtensionVectorAdapter(settings: PmSettings): ExtensionVectorAdapter | null;
343
- declare function normalizeExtensionProviderHits(providerName: string, raw: unknown, filteredById: Map<string, ItemDocument>): SearchHit[];
344
- declare function buildSemanticHits(vectorHits: VectorQueryHit[], filteredById: Map<string, ItemDocument>): {
345
- semanticHits: SearchHit[];
346
- semanticScores: Map<string, number>;
347
- };
348
- declare function combineHybridHits(filteredById: Map<string, ItemDocument>, semanticScores: Map<string, number>, keywordHits: SearchHit[], hybridSemanticWeight: number, semanticFieldLabel?: string): SearchHit[];
349
- /** Built-in BM25 activation outcome for semantic/hybrid search (pm-75k9): - `"explicit"`: `search.provider` is `bm25` — the user opted into offline lexical ranking, so it is used even if an embedding provider is configured. - `"auto-fallback"`: `search.provider` is `auto` and neither an embedding provider nor an extension search provider is available — BM25 is used in place of degrading to the naive field-weighted keyword scorer. - `null`: BM25 does not apply; the existing embedding/extension path runs. */
350
- type BuiltInBm25Mode = "explicit" | "auto-fallback";
351
- declare function resolveBuiltInBm25Mode(params: {
352
- configuredProvider: string | undefined;
353
- hasEmbeddingProvider: boolean;
354
- hasExtensionSearchProvider: boolean;
355
- }): BuiltInBm25Mode | null;
356
- /**
357
- * Rank the filtered corpus with the offline BM25 provider (pm-75k9). Builds a
358
- * BM25 index over each document's resolved search corpus (honoring
359
- * `search.corpus_fields`), scores the query, and shapes hits for the requested
360
- * mode: semantic mode returns pure BM25-ranked hits tagged
361
- * `matched_fields: ["bm25"]`, while hybrid mode blends the BM25 scores with the
362
- * locally computed keyword scores via {@link combineHybridHits}. The exact
363
- * full-ID / short-ID guarantee is preserved in both modes via
364
- * {@link forceExactIdHitsToTop}. No network, embedding service, or vector store
365
- * is involved, so this path cannot fail on a backend error.
366
- */
367
- declare function computeBuiltInBm25Hits(params: {
368
- requestedMode: Exclude<SearchMode, "keyword">;
369
- query: string;
370
- filteredDocuments: ItemDocument[];
371
- keywordHits: SearchHit[];
372
- corpusFields: string[];
373
- bm25Params: Bm25Params;
374
- hybridSemanticWeight: number;
375
- }): SearchHit[];
376
- interface SemanticQueryContext {
377
- requestedMode: Exclude<SearchMode, "keyword">;
378
- query: string;
379
- filteredDocuments: ItemDocument[];
380
- keywordHits: SearchHit[];
381
- hybridSemanticWeight: number;
382
- limit: number | undefined;
383
- maxResults: number;
384
- provider: EmbeddingProviderConfig;
385
- vectorStore: VectorStoreConfig | null;
386
- extensionVectorAdapter: ExtensionVectorAdapter | null;
387
- queryExpansion: QueryExpansionConfig;
388
- queryExpansionExtension: {
389
- providerName: string;
390
- expand: ExtensionSearchProviderQueryExpansion;
391
- } | null;
392
- rerank: RerankConfig;
393
- rerankExtension: {
394
- providerName: string;
395
- rerank: ExtensionSearchProviderRerank;
396
- } | null;
397
- warnings: string[];
398
- settings: PmSettings;
399
- embeddingTimeoutMs?: number;
400
- vectorQueryTimeoutMs?: number;
401
- }
402
- interface SemanticQueryResult {
403
- hits: SearchHit[];
404
- vectorMatchCount: number;
405
- }
406
- declare function mergeVectorHitsById(vectorHitGroups: VectorQueryHit[][]): VectorQueryHit[];
407
- declare function buildRerankCorpus(document: ItemDocument): string;
408
- declare function computeSemanticOrHybridHits(context: SemanticQueryContext): Promise<SemanticQueryResult>;
409
- declare function loadDocuments(pmRoot: string, itemFormat: ItemFormat, typeToFolder: Record<string, string>, schema: PmSettings["schema"]): Promise<{
410
- documents: ItemDocument[];
411
- warnings: string[];
412
- }>;
413
- declare function readSearchFieldValue(hit: SearchHit, field: string): unknown;
414
- declare function projectSearchHits(hits: SearchHit[], projection: SearchProjectionConfig): SearchResultItem[];
415
64
  /** Implements run search for the public runtime surface of this module. */
416
65
  export declare function runSearch(rawQuery: string, rawOptions: SearchOptions, global: GlobalOptions): Promise<SearchResult>;