@reqlan/analytical 0.4.0

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 (97) hide show
  1. package/out/analysis/analyser-registry.d.ts +21 -0
  2. package/out/analysis/analyser-registry.js +33 -0
  3. package/out/analysis/analyser-registry.js.map +1 -0
  4. package/out/analysis/completion-tracking-analyser.d.ts +3 -0
  5. package/out/analysis/completion-tracking-analyser.js +37 -0
  6. package/out/analysis/completion-tracking-analyser.js.map +1 -0
  7. package/out/analysis/deprecation-impact-analyser.d.ts +3 -0
  8. package/out/analysis/deprecation-impact-analyser.js +21 -0
  9. package/out/analysis/deprecation-impact-analyser.js.map +1 -0
  10. package/out/analysis/file-related-analyser.d.ts +5 -0
  11. package/out/analysis/file-related-analyser.js +41 -0
  12. package/out/analysis/file-related-analyser.js.map +1 -0
  13. package/out/analysis/git-dates-analyser.d.ts +9 -0
  14. package/out/analysis/git-dates-analyser.js +39 -0
  15. package/out/analysis/git-dates-analyser.js.map +1 -0
  16. package/out/analysis/list-ideas-analyser.d.ts +3 -0
  17. package/out/analysis/list-ideas-analyser.js +7 -0
  18. package/out/analysis/list-ideas-analyser.js.map +1 -0
  19. package/out/analysis/local-graph-analyser.d.ts +6 -0
  20. package/out/analysis/local-graph-analyser.js +42 -0
  21. package/out/analysis/local-graph-analyser.js.map +1 -0
  22. package/out/analysis/semantic-search-analyser.d.ts +8 -0
  23. package/out/analysis/semantic-search-analyser.js +51 -0
  24. package/out/analysis/semantic-search-analyser.js.map +1 -0
  25. package/out/analysis-api.d.ts +31 -0
  26. package/out/analysis-api.js +136 -0
  27. package/out/analysis-api.js.map +1 -0
  28. package/out/core/analytical-store.d.ts +78 -0
  29. package/out/core/analytical-store.js +141 -0
  30. package/out/core/analytical-store.js.map +1 -0
  31. package/out/core/context-model.d.ts +187 -0
  32. package/out/core/context-model.js +36 -0
  33. package/out/core/context-model.js.map +1 -0
  34. package/out/core/context-signals.d.ts +149 -0
  35. package/out/core/context-signals.js +397 -0
  36. package/out/core/context-signals.js.map +1 -0
  37. package/out/core/file-path-match.d.ts +7 -0
  38. package/out/core/file-path-match.js +39 -0
  39. package/out/core/file-path-match.js.map +1 -0
  40. package/out/core/file-reference-resolve.d.ts +8 -0
  41. package/out/core/file-reference-resolve.js +28 -0
  42. package/out/core/file-reference-resolve.js.map +1 -0
  43. package/out/core/idea-references.d.ts +13 -0
  44. package/out/core/idea-references.js +25 -0
  45. package/out/core/idea-references.js.map +1 -0
  46. package/out/core/index-error.d.ts +23 -0
  47. package/out/core/index-error.js +33 -0
  48. package/out/core/index-error.js.map +1 -0
  49. package/out/core/types.d.ts +172 -0
  50. package/out/core/types.js +48 -0
  51. package/out/core/types.js.map +1 -0
  52. package/out/core/workspace-paths.d.ts +4 -0
  53. package/out/core/workspace-paths.js +92 -0
  54. package/out/core/workspace-paths.js.map +1 -0
  55. package/out/create-runtime.d.ts +21 -0
  56. package/out/create-runtime.js +39 -0
  57. package/out/create-runtime.js.map +1 -0
  58. package/out/export/build-export-snapshot.d.ts +3 -0
  59. package/out/export/build-export-snapshot.js +573 -0
  60. package/out/export/build-export-snapshot.js.map +1 -0
  61. package/out/export/html-export-assets.d.ts +3 -0
  62. package/out/export/html-export-assets.js +1066 -0
  63. package/out/export/html-export-assets.js.map +1 -0
  64. package/out/export/html-export-template.d.ts +17 -0
  65. package/out/export/html-export-template.js +930 -0
  66. package/out/export/html-export-template.js.map +1 -0
  67. package/out/export/html-export-utils.d.ts +45 -0
  68. package/out/export/html-export-utils.js +262 -0
  69. package/out/export/html-export-utils.js.map +1 -0
  70. package/out/export/types.d.ts +187 -0
  71. package/out/export/types.js +2 -0
  72. package/out/export/types.js.map +1 -0
  73. package/out/export/write-html-export.d.ts +2 -0
  74. package/out/export/write-html-export.js +143 -0
  75. package/out/export/write-html-export.js.map +1 -0
  76. package/out/headless-index-service.d.ts +23 -0
  77. package/out/headless-index-service.js +171 -0
  78. package/out/headless-index-service.js.map +1 -0
  79. package/out/index-store/idea-extractor.d.ts +6 -0
  80. package/out/index-store/idea-extractor.js +271 -0
  81. package/out/index-store/idea-extractor.js.map +1 -0
  82. package/out/index-store/schema.d.ts +10 -0
  83. package/out/index-store/schema.js +54 -0
  84. package/out/index-store/schema.js.map +1 -0
  85. package/out/index-store/sqlite-store.d.ts +66 -0
  86. package/out/index-store/sqlite-store.js +964 -0
  87. package/out/index-store/sqlite-store.js.map +1 -0
  88. package/out/index-store/webview-graph-queries.d.ts +62 -0
  89. package/out/index-store/webview-graph-queries.js +256 -0
  90. package/out/index-store/webview-graph-queries.js.map +1 -0
  91. package/out/index-store/webview-table-queries.d.ts +57 -0
  92. package/out/index-store/webview-table-queries.js +199 -0
  93. package/out/index-store/webview-table-queries.js.map +1 -0
  94. package/out/index.d.ts +40 -0
  95. package/out/index.js +27 -0
  96. package/out/index.js.map +1 -0
  97. package/package.json +52 -0
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Zustand store for analytical submodule state and lifecycle actions.
3
+ */
4
+ import { type StoreApi } from 'zustand/vanilla';
5
+ export type IndexState = 'uninitialized' | 'opening' | 'idle' | 'syncing' | 'ready' | 'error' | 'closing';
6
+ type IndexEvent = 'activate' | 'opened' | 'sync' | 'synced' | 'fail' | 'deactivate';
7
+ export type WorkspaceChange = 'created' | 'changed' | 'deleted';
8
+ export type IndexErrorPhase = 'open' | 'parse' | 'extract' | 'persist' | 'sync' | 'transition';
9
+ export interface IndexError {
10
+ message: string;
11
+ fileUri?: string;
12
+ ideaNames?: string[];
13
+ phase?: IndexErrorPhase;
14
+ cause?: unknown;
15
+ }
16
+ export interface FileIndexIssue {
17
+ fileUri: string;
18
+ line: number;
19
+ column: number;
20
+ message: string;
21
+ phase: IndexErrorPhase;
22
+ ideaNames?: string[];
23
+ cause?: string;
24
+ at: number;
25
+ }
26
+ export interface DocumentUpdate {
27
+ fileUri: string;
28
+ ideaCount: number;
29
+ at: number;
30
+ }
31
+ export interface WorkspaceFileChange {
32
+ fileUri: string;
33
+ change: WorkspaceChange;
34
+ at: number;
35
+ }
36
+ export interface AnalysisRun {
37
+ analyser: string;
38
+ params: unknown;
39
+ status: 'running' | 'completed' | 'failed';
40
+ result?: unknown;
41
+ error?: string;
42
+ at: number;
43
+ }
44
+ export interface AnalyticalState {
45
+ indexState: IndexState;
46
+ previousIndexState?: IndexState;
47
+ ideaCount: number;
48
+ edgeCount: number;
49
+ lastError?: IndexError;
50
+ fileIndexIssues: FileIndexIssue[];
51
+ documentUpdates: DocumentUpdate[];
52
+ workspaceChanges: WorkspaceFileChange[];
53
+ analysisRuns: AnalysisRun[];
54
+ currentAnalysis?: AnalysisRun;
55
+ }
56
+ export interface AnalyticalActions {
57
+ canDispatchIndex: (event: IndexEvent) => boolean;
58
+ dispatchIndex: (event: IndexEvent) => boolean;
59
+ setIndexReady: (counts: {
60
+ ideaCount: number;
61
+ edgeCount: number;
62
+ }) => void;
63
+ recordIndexError: (message: string, cause?: unknown, context?: Pick<IndexError, 'fileUri' | 'ideaNames' | 'phase'>) => void;
64
+ recordFileIndexIssues: (fileUri: string, issues: Array<Omit<FileIndexIssue, 'fileUri' | 'at'>>) => void;
65
+ clearFileIndexIssues: () => void;
66
+ clearFileIndexIssuesForFile: (fileUri: string) => void;
67
+ clearLastError: () => void;
68
+ recordDocumentUpdate: (fileUri: string, ideaCount: number) => void;
69
+ recordWorkspaceChange: (fileUri: string, change: WorkspaceChange) => void;
70
+ startAnalysis: (analyser: string, params: unknown) => void;
71
+ completeAnalysis: (analyser: string, result: unknown) => void;
72
+ failAnalysis: (analyser: string, error: string) => void;
73
+ reset: () => void;
74
+ }
75
+ export type AnalyticalStoreState = AnalyticalState & AnalyticalActions;
76
+ export type AnalyticalStore = StoreApi<AnalyticalStoreState>;
77
+ export declare function createAnalyticalStore(): AnalyticalStore;
78
+ export {};
@@ -0,0 +1,141 @@
1
+ /**
2
+ * Zustand store for analytical submodule state and lifecycle actions.
3
+ */
4
+ import { createStore } from 'zustand/vanilla';
5
+ const INDEX_TRANSITIONS = {
6
+ uninitialized: { activate: 'opening' },
7
+ opening: { opened: 'idle', fail: 'error' },
8
+ idle: { sync: 'syncing', deactivate: 'closing' },
9
+ ready: { sync: 'syncing', deactivate: 'closing' },
10
+ syncing: { synced: 'ready', fail: 'error' },
11
+ error: { sync: 'syncing', deactivate: 'closing' },
12
+ closing: {}
13
+ };
14
+ const INITIAL_STATE = {
15
+ indexState: 'uninitialized',
16
+ ideaCount: 0,
17
+ edgeCount: 0,
18
+ fileIndexIssues: [],
19
+ documentUpdates: [],
20
+ workspaceChanges: [],
21
+ analysisRuns: []
22
+ };
23
+ const MAX_ACTIVITY = 50;
24
+ const MAX_FILE_ISSUES = 500;
25
+ function resolveTransition(state, event) {
26
+ return INDEX_TRANSITIONS[state]?.[event];
27
+ }
28
+ function appendActivity(items, item) {
29
+ return [...items, item].slice(-MAX_ACTIVITY);
30
+ }
31
+ export function createAnalyticalStore() {
32
+ return createStore((set, get) => ({
33
+ ...INITIAL_STATE,
34
+ canDispatchIndex(event) {
35
+ return resolveTransition(get().indexState, event) !== undefined;
36
+ },
37
+ dispatchIndex(event) {
38
+ const current = get().indexState;
39
+ const next = resolveTransition(current, event);
40
+ if (!next) {
41
+ return false;
42
+ }
43
+ set({
44
+ previousIndexState: current,
45
+ indexState: next
46
+ });
47
+ return true;
48
+ },
49
+ setIndexReady({ ideaCount, edgeCount }) {
50
+ set({ ideaCount, edgeCount });
51
+ },
52
+ recordIndexError(message, cause, context) {
53
+ set({
54
+ lastError: {
55
+ message,
56
+ cause,
57
+ fileUri: context?.fileUri,
58
+ ideaNames: context?.ideaNames,
59
+ phase: context?.phase
60
+ }
61
+ });
62
+ },
63
+ recordFileIndexIssues(fileUri, issues) {
64
+ const at = Date.now();
65
+ set(state => ({
66
+ fileIndexIssues: [
67
+ ...state.fileIndexIssues.filter(issue => issue.fileUri !== fileUri),
68
+ ...issues.map(issue => ({ ...issue, fileUri, at }))
69
+ ].slice(-MAX_FILE_ISSUES)
70
+ }));
71
+ },
72
+ clearFileIndexIssues() {
73
+ set({ fileIndexIssues: [] });
74
+ },
75
+ clearFileIndexIssuesForFile(fileUri) {
76
+ set(state => ({
77
+ fileIndexIssues: state.fileIndexIssues.filter(issue => issue.fileUri !== fileUri)
78
+ }));
79
+ },
80
+ clearLastError() {
81
+ set({ lastError: undefined });
82
+ },
83
+ recordDocumentUpdate(fileUri, ideaCount) {
84
+ set(state => ({
85
+ documentUpdates: appendActivity(state.documentUpdates, {
86
+ fileUri,
87
+ ideaCount,
88
+ at: Date.now()
89
+ })
90
+ }));
91
+ },
92
+ recordWorkspaceChange(fileUri, change) {
93
+ set(state => ({
94
+ workspaceChanges: appendActivity(state.workspaceChanges, {
95
+ fileUri,
96
+ change,
97
+ at: Date.now()
98
+ })
99
+ }));
100
+ },
101
+ startAnalysis(analyser, params) {
102
+ const run = {
103
+ analyser,
104
+ params,
105
+ status: 'running',
106
+ at: Date.now()
107
+ };
108
+ set({ currentAnalysis: run });
109
+ },
110
+ completeAnalysis(analyser, result) {
111
+ const completed = {
112
+ analyser,
113
+ params: get().currentAnalysis?.params,
114
+ status: 'completed',
115
+ result,
116
+ at: Date.now()
117
+ };
118
+ set(state => ({
119
+ currentAnalysis: undefined,
120
+ analysisRuns: appendActivity(state.analysisRuns, completed)
121
+ }));
122
+ },
123
+ failAnalysis(analyser, error) {
124
+ const failed = {
125
+ analyser,
126
+ params: get().currentAnalysis?.params,
127
+ status: 'failed',
128
+ error,
129
+ at: Date.now()
130
+ };
131
+ set(state => ({
132
+ currentAnalysis: undefined,
133
+ analysisRuns: appendActivity(state.analysisRuns, failed)
134
+ }));
135
+ },
136
+ reset() {
137
+ set({ ...INITIAL_STATE });
138
+ }
139
+ }));
140
+ }
141
+ //# sourceMappingURL=analytical-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analytical-store.js","sourceRoot":"","sources":["../../src/core/analytical-store.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,WAAW,EAA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gB;gBAC3B,QAAQ;gBACR,MAAM,EAAE,GAAG,EAAE,CAAC,eAAe,EAAE,MAAM;gBACrC,MAAM,EAAE,WAAW;gBACnB,MAAM;gBACN,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE;aACjB,CAAC;YACF,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;gBACV,eAAe,EAAE,SAAS;gBAC1B,YAAY,EAAE,cAAc,CAAC,KAAK,CAAC,YAAY,EAAE,SAAS,CAAC;aAC9D,CAAC,CAAC,CAAC;QACR,CAAC;QAED,YAAY,CAAC,QAAQ,EAAE,KAAK;YACxB,MAAM,MAAM,GAAgB;gBACxB,QAAQ;gBACR,MAAM,EAAE,GAAG,EAAE,CAAC,eAAe,EAAE,MAAM;gBACrC,MAAM,EAAE,QAAQ;gBAChB,KAAK;gBACL,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE;aACjB,CAAC;YACF,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;gBACV,eAAe,EAAE,SAAS;gBAC1B,YAAY,EAAE,cAAc,CAAC,KAAK,CAAC,YAAY,EAAE,MAAM,CAAC;aAC3D,CAAC,CAAC,CAAC;QACR,CAAC;QAED,KAAK;YACD,GAAG,CAAC,EAAE,GAAG,aAAa,EAAE,CAAC,CAAC;QAC9B,CAAC;KACJ,CAAC,CAAC,CAAC;AACR,CAAC"}
@@ -0,0 +1,187 @@
1
+ /**
2
+ * Composed reqlan context model — dimensions, focus, and merged footprint.
3
+ * per ["../../../../reqlan rq/extension/module/context-scope.rq"]
4
+ */
5
+ import type { IdeaSummary, IdeaWithRange, OutlineNode, ReferenceListRow } from './types.js';
6
+ import type { AiReadiness, ContextFingerprintAxes, ContextSignals, ContextSynthesis } from './context-signals.js';
7
+ export type { AiReadiness, ContextFingerprintAxes, ContextSignals, ContextSynthesis, ContextRiskLevel, ContextCoverageLevel, ContextHotspotBand, DevelopmentHistorySignals, LifecycleSignals, QualitySignals, RelationshipSignals, RiskSignals } from './context-signals.js';
8
+ export interface ContextReferencesSlice {
9
+ ideaId: string;
10
+ rows: ReferenceListRow[];
11
+ }
12
+ export type ContextDimensionId = 'workspace' | 'current_file' | 'open_files' | 'file_history' | 'edit_history' | 'manual' | 'git';
13
+ export type ContextFocusKind = 'idea' | 'file' | 'selection' | 'none';
14
+ export interface ContextFocus {
15
+ kind: ContextFocusKind;
16
+ ideaId?: string;
17
+ fileUri?: string;
18
+ line?: number;
19
+ selectionIdeaIds?: string[];
20
+ }
21
+ export interface ContextFileEntry {
22
+ fileUri: string;
23
+ fileLabel: string;
24
+ line?: number;
25
+ touchedAt?: number;
26
+ gitChange?: 'staged' | 'unstaged' | 'both';
27
+ sources: ContextDimensionId[];
28
+ }
29
+ export interface ContextIdeaEntry {
30
+ idea: IdeaSummary;
31
+ sources: ContextDimensionId[];
32
+ weight: number;
33
+ }
34
+ export interface ContextProvenance {
35
+ ideaSources: Record<string, ContextDimensionId[]>;
36
+ fileSources: Record<string, ContextDimensionId[]>;
37
+ }
38
+ export interface ContextDimensionContribution {
39
+ id: ContextDimensionId;
40
+ label: string;
41
+ enabled: boolean;
42
+ pinned: boolean;
43
+ weight: number;
44
+ ideaCount: number;
45
+ fileCount: number;
46
+ summary: string;
47
+ /** Effective graph hop depth for this dimension (inherits global when unset). */
48
+ hopDepth: number;
49
+ /** True when this dimension supports per-lens hop overrides. */
50
+ supportsHopControl: boolean;
51
+ }
52
+ export interface CurrentFileSlice {
53
+ fileUri: string;
54
+ fileLabel: string;
55
+ isRqFile: boolean;
56
+ focusIdea?: IdeaSummary;
57
+ ideasInFile: IdeaWithRange[];
58
+ outline: OutlineNode[];
59
+ unresolvedCount: number;
60
+ /** Ideas with edges to this file (or its ideas) — file-scoped inbound. */
61
+ referencingIdeas: IdeaSummary[];
62
+ /** Ideas that reference the focused idea — idea-scoped inbound. */
63
+ inboundReferencingIdeas: IdeaSummary[];
64
+ /** Ideas the focused idea references — idea-scoped outbound. */
65
+ referencedIdeas: IdeaSummary[];
66
+ commentLinkedIdeas: IdeaSummary[];
67
+ folderReferencingIdeas: IdeaSummary[];
68
+ gitChange?: 'staged' | 'unstaged' | 'both';
69
+ }
70
+ export interface ContextSelection {
71
+ fileUri: string;
72
+ startLine: number;
73
+ endLine: number;
74
+ ideaIds: string[];
75
+ ideas: IdeaSummary[];
76
+ }
77
+ export interface ContextFileLensDetail {
78
+ fileUri: string;
79
+ fileLabel: string;
80
+ ideasInFile: IdeaWithRange[];
81
+ relatedIdeas: IdeaSummary[];
82
+ }
83
+ /** @deprecated Use CurrentFileSlice — kept for wire compat during migration */
84
+ export type ActivityBarScope = CurrentFileSlice;
85
+ /** One commit from focus-scoped `git log` for the git history lens. */
86
+ export interface GitFocusCommit {
87
+ hash: string;
88
+ shortHash: string;
89
+ subject: string;
90
+ author: string;
91
+ authoredAt: string;
92
+ }
93
+ export interface GitAuthorRollup {
94
+ name: string;
95
+ commitCount: number;
96
+ }
97
+ export interface GitPeerChangeRate {
98
+ ideaId: string;
99
+ name: string;
100
+ commitCount: number;
101
+ ageDays?: number;
102
+ changeRate?: number;
103
+ }
104
+ export interface GitFocusStats {
105
+ symbolName?: string;
106
+ createdAt?: string;
107
+ createdBy?: string;
108
+ modifiedAt?: string;
109
+ modifiedBy?: string;
110
+ commitCount?: number;
111
+ ageDays?: number;
112
+ changeRate?: number;
113
+ relativeChangeRate?: number;
114
+ relativeChangeLabel?: 'cold' | 'typical' | 'hot' | 'very_hot';
115
+ peers?: GitPeerChangeRate[];
116
+ }
117
+ export interface GitContextSlice {
118
+ branch?: string;
119
+ headShort?: string;
120
+ unstagedCount: number;
121
+ stagedCount: number;
122
+ changedFiles: ContextFileEntry[];
123
+ /** Recent commits touching the focus file / idea line range. */
124
+ focusCommits: GitFocusCommit[];
125
+ topAuthors: GitAuthorRollup[];
126
+ /** Lifecycle and churn metrics for the focused symbol when available. */
127
+ focusStats?: GitFocusStats;
128
+ /** Collapsed lens summary, e.g. "main · 3 commits · 2 authors". */
129
+ summary: string;
130
+ /** Focus-hero cue, e.g. "2d ago · main". */
131
+ historyCue?: string;
132
+ }
133
+ export interface WorkspaceContextSlice {
134
+ ready: boolean;
135
+ ideaCount: number;
136
+ edgeCount: number;
137
+ }
138
+ export interface ContextFootprint {
139
+ ideaIds: string[];
140
+ fileUris: string[];
141
+ effectiveCenterId?: string;
142
+ summaryLine: string;
143
+ provenance: ContextProvenance;
144
+ }
145
+ export interface ContextAnomaly {
146
+ kind: 'unresolved_refs' | 'index_issue' | 'git_conflict';
147
+ message: string;
148
+ action?: 'filter_broken_refs' | 'open_workspace' | 'open_file';
149
+ fileUri?: string;
150
+ }
151
+ export interface ReqlanContextModel {
152
+ revision: number;
153
+ focus: ContextFocus;
154
+ dimensions: ContextDimensionContribution[];
155
+ footprint: ContextFootprint;
156
+ expandedLens?: ContextDimensionId;
157
+ /** Global graph hop depth for panes and context search. */
158
+ globalHopDepth: number;
159
+ minHopDepth: number;
160
+ maxHopDepth: number;
161
+ /** Per-dimension hop overrides; omitted dimensions inherit globalHopDepth. */
162
+ dimensionHopDepth: Partial<Record<ContextDimensionId, number>>;
163
+ currentFile?: CurrentFileSlice;
164
+ openFiles: ContextFileEntry[];
165
+ fileHistory: ContextFileEntry[];
166
+ editHistory: ContextFileEntry[];
167
+ manualIdeas: IdeaSummary[];
168
+ git?: GitContextSlice;
169
+ workspace: WorkspaceContextSlice;
170
+ anomalies: ContextAnomaly[];
171
+ selection?: ContextSelection;
172
+ /** Bidirectional reference rows for [footprint.effectiveCenterId]. */
173
+ references?: ContextReferencesSlice;
174
+ /** v2 focus signals (relationship, history, risk, …). */
175
+ signals?: ContextSignals;
176
+ /** v2 synthesized knowledge for the focus entity. */
177
+ synthesis?: ContextSynthesis;
178
+ /** Compact axes describing what is in composed context. */
179
+ fingerprint?: ContextFingerprintAxes;
180
+ /** Whether AI has enough / safe enough context to assist. */
181
+ aiReadiness?: AiReadiness;
182
+ }
183
+ export declare const CONTEXT_DIMENSION_LABELS: Record<ContextDimensionId, string>;
184
+ export declare const CONTEXT_DIMENSION_WEIGHTS: Record<ContextDimensionId, number>;
185
+ export declare const DEFAULT_ENABLED_DIMENSIONS: Record<ContextDimensionId, boolean>;
186
+ /** Dimensions that traverse the requirement graph and expose hop controls. */
187
+ export declare const CONTEXT_GRAPH_SEARCH_DIMENSIONS: ContextDimensionId[];
@@ -0,0 +1,36 @@
1
+ export const CONTEXT_DIMENSION_LABELS = {
2
+ workspace: 'Workspace',
3
+ current_file: 'This file',
4
+ open_files: 'Open',
5
+ file_history: 'Visited',
6
+ edit_history: 'Edited',
7
+ manual: 'Pinned',
8
+ git: 'Git'
9
+ };
10
+ export const CONTEXT_DIMENSION_WEIGHTS = {
11
+ workspace: 0.1,
12
+ current_file: 1.0,
13
+ open_files: 0.6,
14
+ file_history: 0.4,
15
+ edit_history: 0.5,
16
+ manual: 0.9,
17
+ git: 0.7
18
+ };
19
+ export const DEFAULT_ENABLED_DIMENSIONS = {
20
+ workspace: true,
21
+ current_file: true,
22
+ open_files: true,
23
+ file_history: true,
24
+ edit_history: true,
25
+ manual: true,
26
+ git: true
27
+ };
28
+ /** Dimensions that traverse the requirement graph and expose hop controls. */
29
+ export const CONTEXT_GRAPH_SEARCH_DIMENSIONS = [
30
+ 'current_file',
31
+ 'open_files',
32
+ 'file_history',
33
+ 'edit_history',
34
+ 'manual'
35
+ ];
36
+ //# sourceMappingURL=context-model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-model.js","sourceRoot":"","sources":["../../src/core/context-model.ts"],"names":[],"mappings":"AAsOA,MAAM,CAAC,MAAM,wBAAwB,GAAuC;IACxE,SAAS,EAAE,WAAW;IACtB,YAAY,EAAE,WAAW;IACzB,UAAU,EAAE,MAAM;IAClB,YAAY,EAAE,SAAS;IACvB,YAAY,EAAE,QAAQ;IACtB,MAAM,EAAE,QAAQ;IAChB,GAAG,EAAE,KAAK;CACb,CAAC;AAEF,MAAM,CAAC,MAAM,yBAAyB,GAAuC;IACzE,SAAS,EAAE,GAAG;IACd,YAAY,EAAE,GAAG;IACjB,UAAU,EAAE,GAAG;IACf,YAAY,EAAE,GAAG;IACjB,YAAY,EAAE,GAAG;IACjB,MAAM,EAAE,GAAG;IACX,GAAG,EAAE,GAAG;CACX,CAAC;AAEF,MAAM,CAAC,MAAM,0BAA0B,GAAwC;IAC3E,SAAS,EAAE,IAAI;IACf,YAAY,EAAE,IAAI;IAClB,UAAU,EAAE,IAAI;IAChB,YAAY,EAAE,IAAI;IAClB,YAAY,EAAE,IAAI;IAClB,MAAM,EAAE,IAAI;IACZ,GAAG,EAAE,IAAI;CACZ,CAAC;AAEF,8EAA8E;AAC9E,MAAM,CAAC,MAAM,+BAA+B,GAAyB;IACjE,cAAc;IACd,YAAY;IACZ,cAAc;IACd,cAAc;IACd,QAAQ;CACX,CAAC"}
@@ -0,0 +1,149 @@
1
+ /**
2
+ * Context signals and focus synthesis for context-scope v2.
3
+ * per ["../../../../reqlan rq/extension/module/context-scope-v2.rq"]
4
+ */
5
+ export type ContextRiskLevel = 'low' | 'medium' | 'high';
6
+ export type ContextCoverageLevel = 'unknown' | 'partial' | 'complete';
7
+ export type ContextHotspotBand = 'low' | 'medium' | 'high';
8
+ export interface RelationshipSignals {
9
+ parentCount: number;
10
+ childCount: number;
11
+ inboundCount: number;
12
+ outboundCount: number;
13
+ /** Inbound idea references that are not in the ancestor (parent) set. */
14
+ dependentCount: number;
15
+ }
16
+ export interface DevelopmentHistorySignals {
17
+ createdAt?: string;
18
+ createdBy?: string;
19
+ modifiedAt?: string;
20
+ modifiedBy?: string;
21
+ /** Whole days since createdAt; undefined when unknown. */
22
+ ageDays?: number;
23
+ /** Whole days since modifiedAt; undefined when unknown. */
24
+ timeSinceTouchedDays?: number;
25
+ /** Focus-scoped commit count from git history (when collected). */
26
+ commitCount?: number;
27
+ /** Commits per day since introduction; undefined when age is unknown. */
28
+ changeRate?: number;
29
+ /** Ratio of focus changeRate to peer median changeRate. */
30
+ relativeChangeRate?: number;
31
+ relativeChangeLabel?: 'cold' | 'typical' | 'hot' | 'very_hot';
32
+ /** Top author names for the focus path / line range. */
33
+ authors?: string[];
34
+ }
35
+ export interface LifecycleSignals {
36
+ createdAt?: string;
37
+ lastEditedAt?: string;
38
+ status?: string;
39
+ }
40
+ export interface RiskSignals {
41
+ highFanout: boolean;
42
+ unresolvedRefs: boolean;
43
+ recentlyTouched: boolean;
44
+ flags: string[];
45
+ }
46
+ export interface QualitySignals {
47
+ unresolvedCount: number;
48
+ hasStatus: boolean;
49
+ }
50
+ export interface ContextSignals {
51
+ focusIdeaId?: string;
52
+ relationship?: RelationshipSignals;
53
+ developmentHistory?: DevelopmentHistorySignals;
54
+ lifecycle?: LifecycleSignals;
55
+ risk?: RiskSignals;
56
+ quality?: QualitySignals;
57
+ }
58
+ export interface ContextSynthesis {
59
+ stability: number;
60
+ confidence: number;
61
+ aiRisk: ContextRiskLevel;
62
+ coverage: ContextCoverageLevel;
63
+ story: string;
64
+ stories: string[];
65
+ }
66
+ export interface ContextFingerprintAxes {
67
+ files: number;
68
+ requirements: number;
69
+ history: number;
70
+ architecture: number;
71
+ git: number;
72
+ diagnostics: number;
73
+ coverage: number;
74
+ }
75
+ export interface AiReadiness {
76
+ score: number;
77
+ ready: boolean;
78
+ checks: {
79
+ label: string;
80
+ ok: boolean;
81
+ }[];
82
+ risk: ContextRiskLevel;
83
+ }
84
+ export interface FocusSignalInput {
85
+ focusIdeaId?: string;
86
+ status?: string;
87
+ parentCount: number;
88
+ inboundCount: number;
89
+ outboundCount: number;
90
+ unresolvedCount: number;
91
+ createdAt?: string;
92
+ createdBy?: string;
93
+ modifiedAt?: string;
94
+ modifiedBy?: string;
95
+ commitCount?: number;
96
+ changeRate?: number;
97
+ relativeChangeRate?: number;
98
+ relativeChangeLabel?: 'cold' | 'typical' | 'hot' | 'very_hot';
99
+ authors?: string[];
100
+ now?: Date;
101
+ }
102
+ export declare function emptyContextSignals(): ContextSignals;
103
+ export declare function emptyContextSynthesis(): ContextSynthesis;
104
+ export declare function buildFocusSignals(input: FocusSignalInput): ContextSignals;
105
+ export declare function synthesizeFocusContext(signals: ContextSignals): ContextSynthesis;
106
+ export declare function formatSynthesisMarkdown(synthesis: ContextSynthesis): string;
107
+ export declare function buildContextFingerprint(input: {
108
+ fileCount: number;
109
+ ideaCount: number;
110
+ historyCount: number;
111
+ hasArchitectureHint: boolean;
112
+ /** @deprecated Prefer gitCommitCount / gitAuthorCount; dirty-tree count is secondary. */
113
+ gitChangeCount?: number;
114
+ gitCommitCount?: number;
115
+ gitAuthorCount?: number;
116
+ anomalyCount: number;
117
+ coverage: ContextCoverageLevel;
118
+ }): ContextFingerprintAxes;
119
+ /** Overview of why context fingerprint / health bars matter for developers. */
120
+ export declare const CONTEXT_FINGERPRINT_HELP: string;
121
+ /** Per-axis semantic help for scope-pane tooltips and the fingerprint info panel. */
122
+ export declare const CONTEXT_FINGERPRINT_AXIS_HELP: Record<keyof ContextFingerprintAxes, string>;
123
+ export declare function fingerprintAxisTooltip(key: keyof ContextFingerprintAxes, value: number): string;
124
+ export declare function buildAiReadiness(signals: ContextSignals, synthesis: ContextSynthesis): AiReadiness;
125
+ export declare function formatFingerprintMarkdown(axes: ContextFingerprintAxes): string;
126
+ export declare function formatAiReadinessMarkdown(readiness: AiReadiness): string;
127
+ export declare function hotspotBandFromRisk(risk: ContextRiskLevel): ContextHotspotBand;
128
+ export declare function hotspotBorderWidth(band?: ContextHotspotBand): number;
129
+ export declare function hotspotBorderColor(band?: ContextHotspotBand): string;
130
+ /** Opacity for impact-radius fade: selected = 1, 1 hop = 0.75, 2 hops = 0.45, farther = 0.2. */
131
+ export declare function impactOpacityForHopDistance(distance: number | undefined): number;
132
+ /** BFS hop distances from a center over undirected edges. */
133
+ export declare function hopDistancesFromCenter(centerId: string, edges: {
134
+ sourceId: string;
135
+ targetId: string;
136
+ }[]): Map<string, number>;
137
+ /** Thin requirement-card cue from ref counts (Ideas Summary rows). */
138
+ export declare function requirementCardCue(inboundCount: number, outboundCount: number): {
139
+ stability: number;
140
+ label: string;
141
+ };
142
+ /** Timeline milestones for the ribbon widget. */
143
+ export declare function timelineMilestones(signals: ContextSignals, now?: Date): {
144
+ id: string;
145
+ label: string;
146
+ at: Date;
147
+ }[];
148
+ /** Two-point churn intensity 0–1 for the thin heat bar. */
149
+ export declare function thinChurnIntensity(signals: ContextSignals): number;