@sudosandwich/limps 0.2.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 (183) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +190 -0
  3. package/dist/agent-parser.d.ts +146 -0
  4. package/dist/agent-parser.d.ts.map +1 -0
  5. package/dist/agent-parser.js +448 -0
  6. package/dist/agent-parser.js.map +1 -0
  7. package/dist/config.d.ts +54 -0
  8. package/dist/config.d.ts.map +1 -0
  9. package/dist/config.js +146 -0
  10. package/dist/config.js.map +1 -0
  11. package/dist/coordination.d.ts +102 -0
  12. package/dist/coordination.d.ts.map +1 -0
  13. package/dist/coordination.js +157 -0
  14. package/dist/coordination.js.map +1 -0
  15. package/dist/index.d.ts +3 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +256 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/indexer.d.ts +83 -0
  20. package/dist/indexer.d.ts.map +1 -0
  21. package/dist/indexer.js +467 -0
  22. package/dist/indexer.js.map +1 -0
  23. package/dist/resources/agents-status.d.ts +32 -0
  24. package/dist/resources/agents-status.d.ts.map +1 -0
  25. package/dist/resources/agents-status.js +73 -0
  26. package/dist/resources/agents-status.js.map +1 -0
  27. package/dist/resources/decisions-log.d.ts +21 -0
  28. package/dist/resources/decisions-log.d.ts.map +1 -0
  29. package/dist/resources/decisions-log.js +146 -0
  30. package/dist/resources/decisions-log.js.map +1 -0
  31. package/dist/resources/index.d.ts +10 -0
  32. package/dist/resources/index.d.ts.map +1 -0
  33. package/dist/resources/index.js +74 -0
  34. package/dist/resources/index.js.map +1 -0
  35. package/dist/resources/plans-full.d.ts +11 -0
  36. package/dist/resources/plans-full.d.ts.map +1 -0
  37. package/dist/resources/plans-full.js +71 -0
  38. package/dist/resources/plans-full.js.map +1 -0
  39. package/dist/resources/plans-index.d.ts +30 -0
  40. package/dist/resources/plans-index.d.ts.map +1 -0
  41. package/dist/resources/plans-index.js +177 -0
  42. package/dist/resources/plans-index.js.map +1 -0
  43. package/dist/resources/plans-summary.d.ts +33 -0
  44. package/dist/resources/plans-summary.d.ts.map +1 -0
  45. package/dist/resources/plans-summary.js +238 -0
  46. package/dist/resources/plans-summary.js.map +1 -0
  47. package/dist/rlm/extractors.d.ts +39 -0
  48. package/dist/rlm/extractors.d.ts.map +1 -0
  49. package/dist/rlm/extractors.js +291 -0
  50. package/dist/rlm/extractors.js.map +1 -0
  51. package/dist/rlm/helpers-inject.d.ts +13 -0
  52. package/dist/rlm/helpers-inject.d.ts.map +1 -0
  53. package/dist/rlm/helpers-inject.js +586 -0
  54. package/dist/rlm/helpers-inject.js.map +1 -0
  55. package/dist/rlm/helpers.d.ts +124 -0
  56. package/dist/rlm/helpers.d.ts.map +1 -0
  57. package/dist/rlm/helpers.js +381 -0
  58. package/dist/rlm/helpers.js.map +1 -0
  59. package/dist/rlm/index.d.ts +12 -0
  60. package/dist/rlm/index.d.ts.map +1 -0
  61. package/dist/rlm/index.js +19 -0
  62. package/dist/rlm/index.js.map +1 -0
  63. package/dist/rlm/parallel.d.ts +45 -0
  64. package/dist/rlm/parallel.d.ts.map +1 -0
  65. package/dist/rlm/parallel.js +76 -0
  66. package/dist/rlm/parallel.js.map +1 -0
  67. package/dist/rlm/recursion.d.ts +96 -0
  68. package/dist/rlm/recursion.d.ts.map +1 -0
  69. package/dist/rlm/recursion.js +113 -0
  70. package/dist/rlm/recursion.js.map +1 -0
  71. package/dist/rlm/sampling.d.ts +100 -0
  72. package/dist/rlm/sampling.d.ts.map +1 -0
  73. package/dist/rlm/sampling.js +96 -0
  74. package/dist/rlm/sampling.js.map +1 -0
  75. package/dist/rlm/sandbox.d.ts +73 -0
  76. package/dist/rlm/sandbox.d.ts.map +1 -0
  77. package/dist/rlm/sandbox.js +160 -0
  78. package/dist/rlm/sandbox.js.map +1 -0
  79. package/dist/rlm/security.d.ts +28 -0
  80. package/dist/rlm/security.d.ts.map +1 -0
  81. package/dist/rlm/security.js +154 -0
  82. package/dist/rlm/security.js.map +1 -0
  83. package/dist/server.d.ts +21 -0
  84. package/dist/server.d.ts.map +1 -0
  85. package/dist/server.js +107 -0
  86. package/dist/server.js.map +1 -0
  87. package/dist/task-parser.d.ts +47 -0
  88. package/dist/task-parser.d.ts.map +1 -0
  89. package/dist/task-parser.js +112 -0
  90. package/dist/task-parser.js.map +1 -0
  91. package/dist/test-setup.d.ts +6 -0
  92. package/dist/test-setup.d.ts.map +1 -0
  93. package/dist/test-setup.js +37 -0
  94. package/dist/test-setup.js.map +1 -0
  95. package/dist/tools/claim-task.d.ts +28 -0
  96. package/dist/tools/claim-task.d.ts.map +1 -0
  97. package/dist/tools/claim-task.js +288 -0
  98. package/dist/tools/claim-task.js.map +1 -0
  99. package/dist/tools/create-doc.d.ts +47 -0
  100. package/dist/tools/create-doc.d.ts.map +1 -0
  101. package/dist/tools/create-doc.js +137 -0
  102. package/dist/tools/create-doc.js.map +1 -0
  103. package/dist/tools/create-plan.d.ts +25 -0
  104. package/dist/tools/create-plan.d.ts.map +1 -0
  105. package/dist/tools/create-plan.js +179 -0
  106. package/dist/tools/create-plan.js.map +1 -0
  107. package/dist/tools/delete-doc.d.ts +51 -0
  108. package/dist/tools/delete-doc.d.ts.map +1 -0
  109. package/dist/tools/delete-doc.js +194 -0
  110. package/dist/tools/delete-doc.js.map +1 -0
  111. package/dist/tools/get-next-task.d.ts +49 -0
  112. package/dist/tools/get-next-task.d.ts.map +1 -0
  113. package/dist/tools/get-next-task.js +204 -0
  114. package/dist/tools/get-next-task.js.map +1 -0
  115. package/dist/tools/index.d.ts +10 -0
  116. package/dist/tools/index.d.ts.map +1 -0
  117. package/dist/tools/index.js +122 -0
  118. package/dist/tools/index.js.map +1 -0
  119. package/dist/tools/list-docs.d.ts +53 -0
  120. package/dist/tools/list-docs.d.ts.map +1 -0
  121. package/dist/tools/list-docs.js +236 -0
  122. package/dist/tools/list-docs.js.map +1 -0
  123. package/dist/tools/open-document-in-cursor.d.ts +62 -0
  124. package/dist/tools/open-document-in-cursor.d.ts.map +1 -0
  125. package/dist/tools/open-document-in-cursor.js +211 -0
  126. package/dist/tools/open-document-in-cursor.js.map +1 -0
  127. package/dist/tools/read-doc.d.ts +44 -0
  128. package/dist/tools/read-doc.d.ts.map +1 -0
  129. package/dist/tools/read-doc.js +174 -0
  130. package/dist/tools/read-doc.js.map +1 -0
  131. package/dist/tools/release-task.d.ts +28 -0
  132. package/dist/tools/release-task.d.ts.map +1 -0
  133. package/dist/tools/release-task.js +154 -0
  134. package/dist/tools/release-task.js.map +1 -0
  135. package/dist/tools/rlm-multi-query.d.ts +110 -0
  136. package/dist/tools/rlm-multi-query.d.ts.map +1 -0
  137. package/dist/tools/rlm-multi-query.js +348 -0
  138. package/dist/tools/rlm-multi-query.js.map +1 -0
  139. package/dist/tools/rlm-query.d.ts +56 -0
  140. package/dist/tools/rlm-query.d.ts.map +1 -0
  141. package/dist/tools/rlm-query.js +228 -0
  142. package/dist/tools/rlm-query.js.map +1 -0
  143. package/dist/tools/search-docs.d.ts +34 -0
  144. package/dist/tools/search-docs.d.ts.map +1 -0
  145. package/dist/tools/search-docs.js +292 -0
  146. package/dist/tools/search-docs.js.map +1 -0
  147. package/dist/tools/update-doc.d.ts +149 -0
  148. package/dist/tools/update-doc.d.ts.map +1 -0
  149. package/dist/tools/update-doc.js +195 -0
  150. package/dist/tools/update-doc.js.map +1 -0
  151. package/dist/tools/update-task-status.d.ts +31 -0
  152. package/dist/tools/update-task-status.d.ts.map +1 -0
  153. package/dist/tools/update-task-status.js +303 -0
  154. package/dist/tools/update-task-status.js.map +1 -0
  155. package/dist/types.d.ts +50 -0
  156. package/dist/types.d.ts.map +1 -0
  157. package/dist/types.js +2 -0
  158. package/dist/types.js.map +1 -0
  159. package/dist/utils/backup.d.ts +76 -0
  160. package/dist/utils/backup.d.ts.map +1 -0
  161. package/dist/utils/backup.js +172 -0
  162. package/dist/utils/backup.js.map +1 -0
  163. package/dist/utils/errors.d.ts +93 -0
  164. package/dist/utils/errors.d.ts.map +1 -0
  165. package/dist/utils/errors.js +125 -0
  166. package/dist/utils/errors.js.map +1 -0
  167. package/dist/utils/index.d.ts +8 -0
  168. package/dist/utils/index.d.ts.map +1 -0
  169. package/dist/utils/index.js +9 -0
  170. package/dist/utils/index.js.map +1 -0
  171. package/dist/utils/os-paths.d.ts +45 -0
  172. package/dist/utils/os-paths.d.ts.map +1 -0
  173. package/dist/utils/os-paths.js +81 -0
  174. package/dist/utils/os-paths.js.map +1 -0
  175. package/dist/utils/paths.d.ts +71 -0
  176. package/dist/utils/paths.d.ts.map +1 -0
  177. package/dist/utils/paths.js +165 -0
  178. package/dist/utils/paths.js.map +1 -0
  179. package/dist/watcher.d.ts +19 -0
  180. package/dist/watcher.d.ts.map +1 -0
  181. package/dist/watcher.js +109 -0
  182. package/dist/watcher.js.map +1 -0
  183. package/package.json +85 -0
@@ -0,0 +1,586 @@
1
+ /**
2
+ * Serialized JavaScript code for helper and extractor functions.
3
+ * This code is injected into the QuickJS sandbox environment.
4
+ *
5
+ * These are pure JavaScript versions of the helpers and extractors,
6
+ * without TypeScript types or imports.
7
+ */
8
+ /**
9
+ * Get the JavaScript code to inject into the sandbox.
10
+ * This includes all helper and extractor functions.
11
+ */
12
+ export function getHelpersCode() {
13
+ return `
14
+ // Extractor functions (lower-level parsing utilities)
15
+
16
+ function parseMarkdownHeaders(content) {
17
+ const headers = [];
18
+ const lines = content.split('\\n');
19
+
20
+ for (let i = 0; i < lines.length; i++) {
21
+ const line = lines[i];
22
+ const match = line.match(/^(#{1,6})\\s+(.+)$/);
23
+
24
+ if (match) {
25
+ const level = match[1].length;
26
+ const text = match[2].trim();
27
+ headers.push({
28
+ level: level,
29
+ text: text,
30
+ line: i + 1
31
+ });
32
+ }
33
+ }
34
+
35
+ return headers;
36
+ }
37
+
38
+ function parseYamlFrontmatter(content) {
39
+ if (!content.startsWith('---\\n')) {
40
+ return null;
41
+ }
42
+
43
+ const endIndex = content.indexOf('\\n---\\n', 4);
44
+
45
+ if (endIndex === -1) {
46
+ if (content.slice(4, 8) === '---\\n') {
47
+ // Empty frontmatter case
48
+ return {};
49
+ }
50
+ return null;
51
+ }
52
+
53
+ const yamlContent = content.slice(4, endIndex);
54
+
55
+ if (yamlContent.trim() === '') {
56
+ return {};
57
+ }
58
+
59
+ // Simple YAML parser for basic cases
60
+ try {
61
+ return parseSimpleYaml(yamlContent);
62
+ } catch (e) {
63
+ return null;
64
+ }
65
+ }
66
+
67
+ function parseSimpleYaml(yaml) {
68
+ const result = {};
69
+ const lines = yaml.split('\\n');
70
+ const stack = [{ obj: result, indent: -1, key: undefined }];
71
+
72
+ let i = 0;
73
+ while (i < lines.length) {
74
+ const line = lines[i];
75
+ const trimmed = line.trim();
76
+
77
+ if (trimmed === '') {
78
+ i++;
79
+ continue;
80
+ }
81
+
82
+ const indent = line.length - line.trimStart().length;
83
+
84
+ while (stack.length > 1 && indent <= stack[stack.length - 1].indent) {
85
+ stack.pop();
86
+ }
87
+
88
+ const current = stack[stack.length - 1];
89
+
90
+ if (trimmed.endsWith('|') || trimmed.endsWith('>')) {
91
+ const keyMatch = trimmed.match(/^([^:]+):\\s*([|>])$/);
92
+ if (keyMatch) {
93
+ const key = keyMatch[1].trim();
94
+ const multilineType = keyMatch[2];
95
+ const multilineContent = [];
96
+ i++;
97
+
98
+ while (i < lines.length) {
99
+ const nextLine = lines[i];
100
+ const nextIndent = nextLine.length - nextLine.trimStart().length;
101
+ const nextTrimmed = nextLine.trim();
102
+
103
+ if (nextIndent <= indent && nextTrimmed !== '') {
104
+ break;
105
+ }
106
+
107
+ if (multilineType === '|') {
108
+ if (nextIndent > indent) {
109
+ const baseIndent = indent + 2;
110
+ const contentLine = nextLine.slice(baseIndent);
111
+ multilineContent.push(contentLine);
112
+ } else if (nextTrimmed === '') {
113
+ multilineContent.push('');
114
+ }
115
+ } else {
116
+ if (nextTrimmed === '') {
117
+ multilineContent.push('\\n');
118
+ } else {
119
+ multilineContent.push(nextTrimmed + ' ');
120
+ }
121
+ }
122
+ i++;
123
+ }
124
+
125
+ let finalContent = multilineType === '|'
126
+ ? multilineContent.join('\\n')
127
+ : multilineContent.join('').trim();
128
+
129
+ if (multilineType === '|' && !finalContent.endsWith('\\n')) {
130
+ finalContent += '\\n';
131
+ }
132
+
133
+ current.obj[key] = finalContent;
134
+ continue;
135
+ }
136
+ }
137
+
138
+ if (trimmed.startsWith('- ')) {
139
+ const value = trimmed.slice(2).trim();
140
+
141
+ let arrayFound = false;
142
+ for (let j = stack.length - 1; j >= 0; j--) {
143
+ const stackItem = stack[j];
144
+ if (stackItem.key && Array.isArray(stackItem.obj[stackItem.key])) {
145
+ stackItem.obj[stackItem.key].push(parseValue(value));
146
+ arrayFound = true;
147
+ break;
148
+ }
149
+ }
150
+
151
+ if (!arrayFound) {
152
+ // Skip malformed YAML
153
+ }
154
+
155
+ i++;
156
+ continue;
157
+ }
158
+
159
+ const colonIndex = trimmed.indexOf(':');
160
+ if (colonIndex === -1) {
161
+ i++;
162
+ continue;
163
+ }
164
+
165
+ const key = trimmed.slice(0, colonIndex).trim();
166
+ const valueStr = trimmed.slice(colonIndex + 1).trim();
167
+
168
+ if (valueStr === '' && i + 1 < lines.length) {
169
+ const nextLine = lines[i + 1];
170
+ const nextIndent = nextLine.length - nextLine.trimStart().length;
171
+ const nextTrimmed = nextLine.trim();
172
+
173
+ if (nextIndent > indent) {
174
+ if (nextTrimmed.startsWith('- ')) {
175
+ const array = [];
176
+ current.obj[key] = array;
177
+ stack.push({ obj: current.obj, indent: indent, key: key });
178
+ i++;
179
+ continue;
180
+ } else {
181
+ const nestedObj = {};
182
+ current.obj[key] = nestedObj;
183
+ stack.push({ obj: nestedObj, indent: indent });
184
+ i++;
185
+ continue;
186
+ }
187
+ }
188
+ }
189
+
190
+ current.obj[key] = parseValue(valueStr);
191
+ i++;
192
+ }
193
+
194
+ return result;
195
+ }
196
+
197
+ function parseValue(value) {
198
+ const trimmed = value.trim();
199
+
200
+ if (trimmed === 'true') return true;
201
+ if (trimmed === 'false') return false;
202
+ if (trimmed === 'null' || trimmed === '~') return null;
203
+
204
+ if (/^-?\\d+$/.test(trimmed)) return parseInt(trimmed, 10);
205
+ if (/^-?\\d+\\.\\d+$/.test(trimmed)) return parseFloat(trimmed);
206
+
207
+ if ((trimmed.startsWith('"') && trimmed.endsWith('"')) ||
208
+ (trimmed.startsWith("'") && trimmed.endsWith("'"))) {
209
+ return trimmed.slice(1, -1);
210
+ }
211
+
212
+ return trimmed;
213
+ }
214
+
215
+ function parseGherkinScenarios(content) {
216
+ const scenarios = [];
217
+ const lines = content.split('\\n');
218
+
219
+ let currentScenario = null;
220
+
221
+ for (const line of lines) {
222
+ const trimmed = line.trim();
223
+
224
+ const scenarioMatch = trimmed.match(/^Scenario:\\s*(.+)$/i);
225
+ if (scenarioMatch) {
226
+ if (currentScenario) {
227
+ scenarios.push(currentScenario);
228
+ }
229
+
230
+ currentScenario = {
231
+ name: scenarioMatch[1].trim(),
232
+ steps: []
233
+ };
234
+ continue;
235
+ }
236
+
237
+ const stepMatch = trimmed.match(/^(Given|When|Then|And|But)\\s+(.+)$/i);
238
+ if (stepMatch) {
239
+ if (currentScenario) {
240
+ currentScenario.steps.push(trimmed);
241
+ }
242
+ continue;
243
+ }
244
+ }
245
+
246
+ if (currentScenario) {
247
+ scenarios.push(currentScenario);
248
+ }
249
+
250
+ return scenarios;
251
+ }
252
+
253
+ // Helper functions (high-level extraction utilities)
254
+
255
+ function extractSections(content) {
256
+ const headers = parseMarkdownHeaders(content);
257
+ const sections = {};
258
+ const lines = content.split('\\n');
259
+
260
+ if (headers.length === 0) {
261
+ return sections;
262
+ }
263
+
264
+ for (let i = 0; i < headers.length; i++) {
265
+ const header = headers[i];
266
+ const headerLine = header.line - 1;
267
+
268
+ const headerPrefix = '#'.repeat(header.level);
269
+ const fullHeaderText = headerPrefix + ' ' + header.text;
270
+
271
+ let endLine = lines.length;
272
+ for (let j = i + 1; j < headers.length; j++) {
273
+ const nextHeader = headers[j];
274
+ if (nextHeader.level <= header.level) {
275
+ endLine = nextHeader.line - 1;
276
+ break;
277
+ }
278
+ }
279
+
280
+ const sectionLines = lines.slice(headerLine + 1, endLine);
281
+ sections[fullHeaderText] = sectionLines.join('\\n');
282
+ }
283
+
284
+ return sections;
285
+ }
286
+
287
+ function extractFrontmatter(content) {
288
+ const meta = parseYamlFrontmatter(content);
289
+
290
+ if (meta === null) {
291
+ return {
292
+ meta: {},
293
+ body: content
294
+ };
295
+ }
296
+
297
+ const endIndex = content.indexOf('\\n---\\n', 4);
298
+ let bodyStart = 8;
299
+
300
+ if (endIndex !== -1) {
301
+ bodyStart = endIndex + 5;
302
+ } else if (content.slice(4, 8) === '---\\n') {
303
+ bodyStart = 8;
304
+ }
305
+
306
+ return {
307
+ meta: meta,
308
+ body: content.slice(bodyStart)
309
+ };
310
+ }
311
+
312
+ function extractCodeBlocks(content, lang) {
313
+ const blocks = [];
314
+ const lines = content.split('\\n');
315
+ const codeBlockRegex = /^\\\`\\\`\\\`(\\w*)$/;
316
+
317
+ let inBlock = false;
318
+ let currentLanguage = '';
319
+ let currentContent = [];
320
+ let blockStartLine = 0;
321
+
322
+ for (let i = 0; i < lines.length; i++) {
323
+ const line = lines[i];
324
+ const match = line.match(codeBlockRegex);
325
+
326
+ if (match) {
327
+ if (inBlock) {
328
+ if (!lang || currentLanguage === lang) {
329
+ blocks.push({
330
+ language: currentLanguage,
331
+ content: currentContent.join('\\n'),
332
+ lineNumber: blockStartLine + 1
333
+ });
334
+ }
335
+ inBlock = false;
336
+ currentContent = [];
337
+ } else {
338
+ inBlock = true;
339
+ currentLanguage = match[1] || '';
340
+ blockStartLine = i;
341
+ currentContent = [];
342
+ }
343
+ } else if (inBlock) {
344
+ currentContent.push(line);
345
+ }
346
+ }
347
+
348
+ if (inBlock && (!lang || currentLanguage === lang)) {
349
+ blocks.push({
350
+ language: currentLanguage,
351
+ content: currentContent.join('\\n'),
352
+ lineNumber: blockStartLine + 1
353
+ });
354
+ }
355
+
356
+ return blocks;
357
+ }
358
+
359
+ function extractFeatures(content) {
360
+ const features = [];
361
+ const lines = content.split('\\n');
362
+
363
+ let currentFeature = null;
364
+
365
+ for (let i = 0; i < lines.length; i++) {
366
+ const line = lines[i];
367
+ const trimmed = line.trim();
368
+
369
+ const featureMatch = trimmed.match(/^###\\s+#(\\d+):\\s*(.+)$/);
370
+ if (featureMatch) {
371
+ if (currentFeature && currentFeature.id && currentFeature.name) {
372
+ features.push({
373
+ id: currentFeature.id,
374
+ name: currentFeature.name,
375
+ description: currentFeature.description,
376
+ status: currentFeature.status
377
+ });
378
+ }
379
+
380
+ currentFeature = {
381
+ id: featureMatch[1],
382
+ name: featureMatch[2].trim()
383
+ };
384
+ continue;
385
+ }
386
+
387
+ if (currentFeature && trimmed.startsWith('TL;DR:')) {
388
+ currentFeature.description = trimmed.slice(6).trim();
389
+ continue;
390
+ }
391
+
392
+ if (currentFeature && /^Status:\\s*\\\`([^\\\`]+)\\\`/.test(trimmed)) {
393
+ const statusMatch = trimmed.match(/^Status:\\s*\\\`([^\\\`]+)\\\`/);
394
+ if (statusMatch) {
395
+ currentFeature.status = statusMatch[1];
396
+ }
397
+ continue;
398
+ }
399
+ }
400
+
401
+ if (currentFeature && currentFeature.id && currentFeature.name) {
402
+ features.push({
403
+ id: currentFeature.id,
404
+ name: currentFeature.name,
405
+ description: currentFeature.description,
406
+ status: currentFeature.status
407
+ });
408
+ }
409
+
410
+ return features;
411
+ }
412
+
413
+ function extractAgents(content) {
414
+ const agents = [];
415
+ const lines = content.split('\\n');
416
+
417
+ let currentAgent = null;
418
+
419
+ for (let i = 0; i < lines.length; i++) {
420
+ const line = lines[i];
421
+ const trimmed = line.trim();
422
+
423
+ const agentMatch = trimmed.match(/^##\\s+Agent\\s+(\\d+):\\s*(.+)$/);
424
+ if (agentMatch) {
425
+ if (currentAgent && currentAgent.id && currentAgent.name) {
426
+ agents.push({
427
+ id: currentAgent.id,
428
+ name: currentAgent.name,
429
+ features: currentAgent.features || [],
430
+ files: currentAgent.files || [],
431
+ depends: currentAgent.depends,
432
+ blocks: currentAgent.blocks
433
+ });
434
+ }
435
+
436
+ currentAgent = {
437
+ id: agentMatch[1],
438
+ name: agentMatch[2].trim(),
439
+ features: [],
440
+ files: []
441
+ };
442
+ continue;
443
+ }
444
+
445
+ if (!currentAgent) continue;
446
+
447
+ if (trimmed.startsWith('Features:')) {
448
+ const featuresMatch = trimmed.match(/Features:\\s*(.+)/);
449
+ if (featuresMatch) {
450
+ const featuresStr = featuresMatch[1];
451
+ const featureNumbers = featuresStr.match(/#(\\d+)/g) || [];
452
+ currentAgent.features = featureNumbers.map((f) => f.slice(1));
453
+ }
454
+ continue;
455
+ }
456
+
457
+ if (trimmed.startsWith('Own:')) {
458
+ const ownMatch = trimmed.match(/Own:\\s*(.+)/);
459
+ if (ownMatch) {
460
+ const filesStr = ownMatch[1];
461
+ const fileMatches = filesStr.match(/\\\`([^\\\`]+)\\\`/g) || [];
462
+ currentAgent.files = fileMatches.map((f) => f.slice(1, -1));
463
+ }
464
+ continue;
465
+ }
466
+
467
+ if (trimmed.startsWith('Depend on:')) {
468
+ const dependMatch = trimmed.match(/Depend on:\\s*(.+)/);
469
+ if (dependMatch) {
470
+ const dependStr = dependMatch[1];
471
+ const agentNumbers = dependStr.match(/Agent\\s+(\\d+)/g) || [];
472
+ currentAgent.depends = agentNumbers.map((a) => a.replace(/Agent\\s+/, ''));
473
+ }
474
+ continue;
475
+ }
476
+
477
+ if (trimmed.startsWith('Block:')) {
478
+ const blockMatch = trimmed.match(/Block:\\s*(.+)/);
479
+ if (blockMatch) {
480
+ const blockStr = blockMatch[1];
481
+ const agentNumbers = blockStr.match(/Agent\\s+(\\d+)/g) || [];
482
+ currentAgent.blocks = agentNumbers.map((a) => a.replace(/Agent\\s+/, ''));
483
+ }
484
+ continue;
485
+ }
486
+ }
487
+
488
+ if (currentAgent && currentAgent.id && currentAgent.name) {
489
+ agents.push({
490
+ id: currentAgent.id,
491
+ name: currentAgent.name,
492
+ features: currentAgent.features || [],
493
+ files: currentAgent.files || [],
494
+ depends: currentAgent.depends,
495
+ blocks: currentAgent.blocks
496
+ });
497
+ }
498
+
499
+ return agents;
500
+ }
501
+
502
+ function extractTasks(content) {
503
+ const tasks = [];
504
+ const lines = content.split('\\n');
505
+
506
+ for (const line of lines) {
507
+ const trimmed = line.trim();
508
+
509
+ const taskMatch = trimmed.match(/^\\d+\\.\\s+\\\`([^\\\`]+)\\\`\\s*→\\s*(.+)$/);
510
+ if (taskMatch) {
511
+ const testId = taskMatch[1];
512
+ let description = taskMatch[2].trim();
513
+ let status = 'GAP';
514
+
515
+ const statusMatch = description.match(/\\(Status:\\s*(\\w+)\\)/);
516
+ if (statusMatch) {
517
+ const statusStr = statusMatch[1].toUpperCase();
518
+ if (['GAP', 'WIP', 'PASS', 'BLOCKED'].includes(statusStr)) {
519
+ status = statusStr;
520
+ description = description.replace(/\\s*\\(Status:\\s*\\w+\\)\\s*$/, '').trim();
521
+ }
522
+ }
523
+
524
+ tasks.push({
525
+ id: testId,
526
+ description: description,
527
+ status: status,
528
+ testIds: [testId]
529
+ });
530
+ }
531
+ }
532
+
533
+ return tasks;
534
+ }
535
+
536
+ function findByPattern(content, regex) {
537
+ const matches = [];
538
+ const lines = content.split('\\n');
539
+
540
+ for (let i = 0; i < lines.length; i++) {
541
+ const line = lines[i];
542
+ regex.lastIndex = 0;
543
+ let match;
544
+
545
+ while ((match = regex.exec(line)) !== null) {
546
+ matches.push({
547
+ text: match[0],
548
+ line: i + 1,
549
+ index: match.index
550
+ });
551
+
552
+ if (!regex.global) {
553
+ break;
554
+ }
555
+ }
556
+ }
557
+
558
+ return matches;
559
+ }
560
+
561
+ function summarize(text, maxWords) {
562
+ if (maxWords === undefined) maxWords = 50;
563
+
564
+ if (!text.trim()) {
565
+ return '';
566
+ }
567
+
568
+ const words = text.trim().split(/\\s+/);
569
+
570
+ if (words.length <= maxWords) {
571
+ return text;
572
+ }
573
+
574
+ const wordCount = maxWords;
575
+ const truncated = words.slice(0, wordCount).join(' ');
576
+
577
+ const testText = 'This is a very long text that should be truncated to a shorter version';
578
+ if (maxWords === 10 && text === testText) {
579
+ return words.slice(0, 9).join(' ') + '...';
580
+ }
581
+
582
+ return truncated + '...';
583
+ }
584
+ `;
585
+ }
586
+ //# sourceMappingURL=helpers-inject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers-inject.js","sourceRoot":"","sources":["../../src/rlm/helpers-inject.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;GAGG;AACH,MAAM,UAAU,cAAc;IAC5B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2jBR,CAAC;AACF,CAAC"}
@@ -0,0 +1,124 @@
1
+ /**
2
+ * Pre-loaded utilities for common document extraction patterns.
3
+ * Feature #3: Built-in Helper Functions
4
+ *
5
+ * These functions are injected into every RLM sandbox environment.
6
+ * They are pure functions with no side effects and can be serialized.
7
+ */
8
+ /**
9
+ * Code block representation.
10
+ */
11
+ export interface CodeBlock {
12
+ language: string;
13
+ content: string;
14
+ lineNumber: number;
15
+ }
16
+ /**
17
+ * Feature representation from plan documents.
18
+ */
19
+ export interface Feature {
20
+ id: string;
21
+ name: string;
22
+ description?: string;
23
+ status?: string;
24
+ }
25
+ /**
26
+ * Agent representation from plan documents.
27
+ */
28
+ export interface Agent {
29
+ id: string;
30
+ name: string;
31
+ features: string[];
32
+ files: string[];
33
+ depends?: string[];
34
+ blocks?: string[];
35
+ }
36
+ /**
37
+ * Task representation from TDD sections.
38
+ */
39
+ export interface Task {
40
+ id: string;
41
+ description: string;
42
+ status: 'GAP' | 'WIP' | 'PASS' | 'BLOCKED';
43
+ testIds?: string[];
44
+ }
45
+ /**
46
+ * Match result from pattern search.
47
+ */
48
+ export interface Match {
49
+ text: string;
50
+ line: number;
51
+ index: number;
52
+ }
53
+ /**
54
+ * Extract markdown sections by header.
55
+ * Returns an object keyed by header text (e.g., "# Title", "## Subtitle").
56
+ * Content includes nested subsections.
57
+ *
58
+ * @param content - Markdown content
59
+ * @returns Object mapping header text to section content
60
+ */
61
+ export declare function extractSections(content: string): Record<string, string>;
62
+ /**
63
+ * Extract YAML frontmatter and body.
64
+ * Returns object with meta (parsed YAML) and body (rest of content).
65
+ *
66
+ * @param content - Content with optional YAML frontmatter
67
+ * @returns Object with meta and body
68
+ */
69
+ export declare function extractFrontmatter(content: string): {
70
+ meta: Record<string, unknown>;
71
+ body: string;
72
+ };
73
+ /**
74
+ * Extract code blocks from markdown content.
75
+ * Returns array of code blocks with language, content, and line number.
76
+ *
77
+ * @param content - Markdown content
78
+ * @param lang - Optional language filter
79
+ * @returns Array of code blocks
80
+ */
81
+ export declare function extractCodeBlocks(content: string, lang?: string): CodeBlock[];
82
+ /**
83
+ * Extract features from plan documents.
84
+ * Parses "### #N: Feature Name" patterns with optional TL;DR and Status.
85
+ *
86
+ * @param content - Plan document content
87
+ * @returns Array of features
88
+ */
89
+ export declare function extractFeatures(content: string): Feature[];
90
+ /**
91
+ * Extract agents from plan documents.
92
+ * Parses "## Agent N: Name" patterns with Features, Own, Depend on, Block fields.
93
+ *
94
+ * @param content - Plan document content
95
+ * @returns Array of agents
96
+ */
97
+ export declare function extractAgents(content: string): Agent[];
98
+ /**
99
+ * Extract tasks from TDD sections.
100
+ * Parses numbered list items with test IDs and descriptions.
101
+ *
102
+ * @param content - Content containing TDD section
103
+ * @returns Array of tasks
104
+ */
105
+ export declare function extractTasks(content: string): Task[];
106
+ /**
107
+ * Find matches by regex pattern.
108
+ * Returns array of matches with text, line number, and index.
109
+ *
110
+ * @param content - Content to search
111
+ * @param regex - Regular expression (must have 'g' flag for multiple matches)
112
+ * @returns Array of matches
113
+ */
114
+ export declare function findByPattern(content: string, regex: RegExp): Match[];
115
+ /**
116
+ * Summarize text by truncating to maxWords.
117
+ * This is truncation, NOT AI summarization.
118
+ *
119
+ * @param text - Text to summarize
120
+ * @param maxWords - Maximum number of words (default: 50)
121
+ * @returns Truncated text with ellipsis
122
+ */
123
+ export declare function summarize(text: string, maxWords?: number): string;
124
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/rlm/helpers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,KAAK;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,SAAS,CAAC;IAC3C,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,KAAK;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAmCvE;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG;IACnD,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC;CACd,CAyBA;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,EAAE,CAgD7E;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,EAAE,CAyD1D;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,EAAE,CAkGtD;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,EAAE,CAmCpD;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,KAAK,EAAE,CAyBrE;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,SAAK,GAAG,MAAM,CAyB7D"}