@rhei-team/rhei 1.0.0-beta.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 (30) hide show
  1. package/README.md +1048 -0
  2. package/bin/rhei-mcp.js +3 -0
  3. package/dist/index.d.ts +12 -0
  4. package/dist/index.js +86366 -0
  5. package/dist/premium/contracts.d.ts +445 -0
  6. package/dist/premium/contracts.js +97 -0
  7. package/dist/vendor/rhei-core/briefs.js +1276 -0
  8. package/dist/vendor/rhei-core/codeAgent.js +615 -0
  9. package/dist/vendor/rhei-core/codeEditSession.js +293 -0
  10. package/dist/vendor/rhei-core/codeIntelligence.js +4287 -0
  11. package/dist/vendor/rhei-core/codeMarket.js +8946 -0
  12. package/dist/vendor/rhei-core/codeReviewIntelligence.js +5918 -0
  13. package/dist/vendor/rhei-core/codeSemantics.js +172427 -0
  14. package/dist/vendor/rhei-core/codeStory.js +667 -0
  15. package/dist/vendor/rhei-core/codeStrategyPlan.js +663 -0
  16. package/dist/vendor/rhei-core/codeTrail.js +2781 -0
  17. package/dist/vendor/rhei-core/codeWorkHandoff.js +281 -0
  18. package/dist/vendor/rhei-core/contextQuery.js +1119 -0
  19. package/dist/vendor/rhei-core/contextRouting.js +2052 -0
  20. package/dist/vendor/rhei-core/evidenceLedger.js +5336 -0
  21. package/dist/vendor/rhei-core/executionSafety.js +0 -0
  22. package/dist/vendor/rhei-core/goalIntelligence.js +2218 -0
  23. package/dist/vendor/rhei-core/model-lanes.js +75 -0
  24. package/dist/vendor/rhei-core/now.js +127 -0
  25. package/dist/vendor/rhei-core/package.json +29 -0
  26. package/dist/vendor/rhei-core/programPlan.js +3153 -0
  27. package/dist/vendor/rhei-core/search.js +196 -0
  28. package/dist/vendor/rhei-core/serviceIntelligence.js +1734 -0
  29. package/dist/vendor/rhei-core/workflowPlan.js +1660 -0
  30. package/package.json +41 -0
@@ -0,0 +1,196 @@
1
+ // ../core/src/search/unifiedSearchContract.ts
2
+ var UNIFIED_SEARCH_RESULT_CONTRACT_VERSION = "unified_search_result.v1";
3
+ // ../core/src/search/paletteSectionLabels.ts
4
+ var PALETTE_SECTION_TITLES = {
5
+ suggested: "Suggested",
6
+ top_results: "Top results",
7
+ open_now: "Open now",
8
+ actions: "Actions",
9
+ pages: "Pages",
10
+ chats: "Chats",
11
+ knowledge: "Knowledge",
12
+ activity: "Activity",
13
+ media: "Media",
14
+ code: "Code",
15
+ other: "Other"
16
+ };
17
+ var PALETTE_SOURCE_SECTION_IDS = {
18
+ suggested_actions: "suggested",
19
+ current_context: "suggested",
20
+ more_context: "suggested",
21
+ best_matches: "top_results",
22
+ search: "top_results",
23
+ open_work: "open_now",
24
+ actions: "actions",
25
+ documents: "pages",
26
+ pages: "pages",
27
+ chat_threads: "chats",
28
+ ai_chats: "chats",
29
+ chat_messages: "chats",
30
+ entities: "knowledge",
31
+ topics: "knowledge",
32
+ memories: "knowledge",
33
+ memory: "knowledge",
34
+ relationships: "knowledge",
35
+ project_graph: "knowledge",
36
+ activity_runs: "activity",
37
+ media: "media",
38
+ code: "code",
39
+ other: "other"
40
+ };
41
+ function getPaletteSectionId(key) {
42
+ return PALETTE_SOURCE_SECTION_IDS[key];
43
+ }
44
+ function getPaletteSectionTitle(key) {
45
+ if (key in PALETTE_SECTION_TITLES) {
46
+ return PALETTE_SECTION_TITLES[key];
47
+ }
48
+ return PALETTE_SECTION_TITLES[getPaletteSectionId(key)];
49
+ }
50
+ // ../core/src/search/codeSearchQuery.ts
51
+ var CODE_SEARCH_QUERY_V1_KINDS = [
52
+ "file",
53
+ "symbol",
54
+ "test",
55
+ "doc",
56
+ "package",
57
+ "service",
58
+ "graph_advisory"
59
+ ];
60
+ var KNOWN_FIELDS = new Set(["kind", "lang", "language", "path", "name", "symbol"]);
61
+ var CODE_SEARCH_QUERY_KIND_SET = new Set(CODE_SEARCH_QUERY_V1_KINDS);
62
+ function parseCodeSearchQueryV1(raw) {
63
+ const tokens = queryTokens(raw);
64
+ const textTokens = [];
65
+ const quotedTextTokens = [];
66
+ const unknownFieldTokens = [];
67
+ const filters = {
68
+ kind: [],
69
+ language: [],
70
+ path: [],
71
+ name: [],
72
+ symbol: []
73
+ };
74
+ const reasonCodes = [];
75
+ for (const token of tokens) {
76
+ const fielded = parseFieldedToken(token.text);
77
+ if (!fielded || !KNOWN_FIELDS.has(fielded.field)) {
78
+ textTokens.push(token.text);
79
+ if (token.quoted)
80
+ quotedTextTokens.push(token.text);
81
+ if (fielded)
82
+ unknownFieldTokens.push(token.text);
83
+ continue;
84
+ }
85
+ const value = normalizeFilterValue(fielded.value);
86
+ if (!value) {
87
+ textTokens.push(token.text);
88
+ if (token.quoted)
89
+ quotedTextTokens.push(token.text);
90
+ reasonCodes.push(`query_filter:${fielded.field}:empty_fallback`);
91
+ continue;
92
+ }
93
+ if (fielded.field === "kind") {
94
+ if (!CODE_SEARCH_QUERY_KIND_SET.has(value)) {
95
+ textTokens.push(token.text);
96
+ if (token.quoted)
97
+ quotedTextTokens.push(token.text);
98
+ reasonCodes.push("query_filter:kind:invalid_fallback");
99
+ continue;
100
+ }
101
+ filters.kind.push(value);
102
+ reasonCodes.push("query_filter:kind");
103
+ continue;
104
+ }
105
+ if (fielded.field === "lang" || fielded.field === "language") {
106
+ const language = normalizeLanguageFilter(value);
107
+ if (!language) {
108
+ textTokens.push(token.text);
109
+ if (token.quoted)
110
+ quotedTextTokens.push(token.text);
111
+ reasonCodes.push("query_filter:language:invalid_fallback");
112
+ continue;
113
+ }
114
+ filters.language.push(language);
115
+ reasonCodes.push("query_filter:language");
116
+ continue;
117
+ }
118
+ if (fielded.field === "path") {
119
+ filters.path.push(value);
120
+ reasonCodes.push("query_filter:path");
121
+ continue;
122
+ }
123
+ if (fielded.field === "name") {
124
+ filters.name.push(value);
125
+ reasonCodes.push("query_filter:name");
126
+ continue;
127
+ }
128
+ if (fielded.field === "symbol") {
129
+ filters.symbol.push(value);
130
+ reasonCodes.push("query_filter:symbol");
131
+ continue;
132
+ }
133
+ }
134
+ return {
135
+ schemaVersion: 1,
136
+ raw,
137
+ text: textTokens.join(" ").trim(),
138
+ quotedTextTokens: unique(quotedTextTokens),
139
+ filters: {
140
+ kind: unique(filters.kind),
141
+ language: unique(filters.language),
142
+ path: unique(filters.path),
143
+ name: unique(filters.name),
144
+ symbol: unique(filters.symbol)
145
+ },
146
+ unknownFieldTokens: unique(unknownFieldTokens),
147
+ reasonCodes: unique(reasonCodes)
148
+ };
149
+ }
150
+ function queryTokens(raw) {
151
+ const tokens = [];
152
+ const pattern = /"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'|`([^`\\]*(?:\\.[^`\\]*)*)`|(\S+)/g;
153
+ for (const match of raw.matchAll(pattern)) {
154
+ const quoted = match[1] !== undefined || match[2] !== undefined || match[3] !== undefined;
155
+ const text = match[1] ?? match[2] ?? match[3] ?? match[4] ?? "";
156
+ if (text.length > 0)
157
+ tokens.push({ text, quoted });
158
+ }
159
+ return tokens;
160
+ }
161
+ function parseFieldedToken(token) {
162
+ const match = /^([A-Za-z][A-Za-z0-9_-]*):(.*)$/.exec(token);
163
+ if (!match)
164
+ return;
165
+ return { field: match[1].toLowerCase(), value: match[2] ?? "" };
166
+ }
167
+ function normalizeFilterValue(value) {
168
+ return value.trim().replace(/^(["'`])(.+)\1$/, "$2").toLowerCase();
169
+ }
170
+ function normalizeLanguageFilter(value) {
171
+ const normalized = value.toLowerCase();
172
+ const aliases = {
173
+ ts: "typescript",
174
+ tsx: "typescript",
175
+ js: "javascript",
176
+ jsx: "javascript",
177
+ md: "markdown",
178
+ mdx: "markdown"
179
+ };
180
+ const language = aliases[normalized] ?? normalized;
181
+ if (!/^[a-z][a-z0-9_+-]*$/.test(language))
182
+ return;
183
+ return language;
184
+ }
185
+ function unique(values) {
186
+ return [...new Set(values.filter((value) => value.length > 0))];
187
+ }
188
+ export {
189
+ parseCodeSearchQueryV1,
190
+ getPaletteSectionTitle,
191
+ getPaletteSectionId,
192
+ UNIFIED_SEARCH_RESULT_CONTRACT_VERSION,
193
+ PALETTE_SOURCE_SECTION_IDS,
194
+ PALETTE_SECTION_TITLES,
195
+ CODE_SEARCH_QUERY_V1_KINDS
196
+ };