@context-forge/core 0.1.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 (111) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +70 -0
  3. package/dist/index.d.ts +4 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +4 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/node.d.ts +6 -0
  8. package/dist/node.d.ts.map +1 -0
  9. package/dist/node.js +10 -0
  10. package/dist/node.js.map +1 -0
  11. package/dist/services/ContextGenerator.d.ts +19 -0
  12. package/dist/services/ContextGenerator.d.ts.map +1 -0
  13. package/dist/services/ContextGenerator.js +66 -0
  14. package/dist/services/ContextGenerator.js.map +1 -0
  15. package/dist/services/ContextIntegrator.d.ts +84 -0
  16. package/dist/services/ContextIntegrator.d.ts.map +1 -0
  17. package/dist/services/ContextIntegrator.js +211 -0
  18. package/dist/services/ContextIntegrator.js.map +1 -0
  19. package/dist/services/ContextTemplateEngine.d.ts +65 -0
  20. package/dist/services/ContextTemplateEngine.d.ts.map +1 -0
  21. package/dist/services/ContextTemplateEngine.js +239 -0
  22. package/dist/services/ContextTemplateEngine.js.map +1 -0
  23. package/dist/services/CoreServiceFactory.d.ts +14 -0
  24. package/dist/services/CoreServiceFactory.d.ts.map +1 -0
  25. package/dist/services/CoreServiceFactory.js +23 -0
  26. package/dist/services/CoreServiceFactory.js.map +1 -0
  27. package/dist/services/ProjectPathService.d.ts +14 -0
  28. package/dist/services/ProjectPathService.d.ts.map +1 -0
  29. package/dist/services/ProjectPathService.js +142 -0
  30. package/dist/services/ProjectPathService.js.map +1 -0
  31. package/dist/services/SectionBuilder.d.ts +70 -0
  32. package/dist/services/SectionBuilder.d.ts.map +1 -0
  33. package/dist/services/SectionBuilder.js +303 -0
  34. package/dist/services/SectionBuilder.js.map +1 -0
  35. package/dist/services/StatementManager.d.ts +44 -0
  36. package/dist/services/StatementManager.d.ts.map +1 -0
  37. package/dist/services/StatementManager.js +216 -0
  38. package/dist/services/StatementManager.js.map +1 -0
  39. package/dist/services/SystemPromptParser.d.ts +72 -0
  40. package/dist/services/SystemPromptParser.d.ts.map +1 -0
  41. package/dist/services/SystemPromptParser.js +271 -0
  42. package/dist/services/SystemPromptParser.js.map +1 -0
  43. package/dist/services/TemplateProcessor.d.ts +35 -0
  44. package/dist/services/TemplateProcessor.d.ts.map +1 -0
  45. package/dist/services/TemplateProcessor.js +150 -0
  46. package/dist/services/TemplateProcessor.js.map +1 -0
  47. package/dist/services/constants.d.ts +8 -0
  48. package/dist/services/constants.d.ts.map +1 -0
  49. package/dist/services/constants.js +62 -0
  50. package/dist/services/constants.js.map +1 -0
  51. package/dist/services/index.d.ts +8 -0
  52. package/dist/services/index.d.ts.map +1 -0
  53. package/dist/services/index.js +12 -0
  54. package/dist/services/index.js.map +1 -0
  55. package/dist/services/interfaces.d.ts +21 -0
  56. package/dist/services/interfaces.d.ts.map +1 -0
  57. package/dist/services/interfaces.js +2 -0
  58. package/dist/services/interfaces.js.map +1 -0
  59. package/dist/storage/FileProjectStore.d.ts +24 -0
  60. package/dist/storage/FileProjectStore.d.ts.map +1 -0
  61. package/dist/storage/FileProjectStore.js +141 -0
  62. package/dist/storage/FileProjectStore.js.map +1 -0
  63. package/dist/storage/FileStorageService.d.ts +14 -0
  64. package/dist/storage/FileStorageService.d.ts.map +1 -0
  65. package/dist/storage/FileStorageService.js +114 -0
  66. package/dist/storage/FileStorageService.js.map +1 -0
  67. package/dist/storage/backupService.d.ts +28 -0
  68. package/dist/storage/backupService.d.ts.map +1 -0
  69. package/dist/storage/backupService.js +84 -0
  70. package/dist/storage/backupService.js.map +1 -0
  71. package/dist/storage/index.d.ts +6 -0
  72. package/dist/storage/index.d.ts.map +1 -0
  73. package/dist/storage/index.js +7 -0
  74. package/dist/storage/index.js.map +1 -0
  75. package/dist/storage/interfaces.d.ts +23 -0
  76. package/dist/storage/interfaces.d.ts.map +1 -0
  77. package/dist/storage/interfaces.js +2 -0
  78. package/dist/storage/interfaces.js.map +1 -0
  79. package/dist/storage/storagePaths.d.ts +9 -0
  80. package/dist/storage/storagePaths.d.ts.map +1 -0
  81. package/dist/storage/storagePaths.js +20 -0
  82. package/dist/storage/storagePaths.js.map +1 -0
  83. package/dist/types/context.d.ts +36 -0
  84. package/dist/types/context.d.ts.map +1 -0
  85. package/dist/types/context.js +2 -0
  86. package/dist/types/context.js.map +1 -0
  87. package/dist/types/index.d.ts +9 -0
  88. package/dist/types/index.d.ts.map +1 -0
  89. package/dist/types/index.js +3 -0
  90. package/dist/types/index.js.map +1 -0
  91. package/dist/types/paths.d.ts +18 -0
  92. package/dist/types/paths.d.ts.map +1 -0
  93. package/dist/types/paths.js +2 -0
  94. package/dist/types/paths.js.map +1 -0
  95. package/dist/types/project.d.ts +48 -0
  96. package/dist/types/project.d.ts.map +1 -0
  97. package/dist/types/project.js +2 -0
  98. package/dist/types/project.js.map +1 -0
  99. package/dist/types/prompts.d.ts +49 -0
  100. package/dist/types/prompts.d.ts.map +1 -0
  101. package/dist/types/prompts.js +10 -0
  102. package/dist/types/prompts.js.map +1 -0
  103. package/dist/types/sections.d.ts +64 -0
  104. package/dist/types/sections.d.ts.map +1 -0
  105. package/dist/types/sections.js +13 -0
  106. package/dist/types/sections.js.map +1 -0
  107. package/dist/types/statements.d.ts +40 -0
  108. package/dist/types/statements.d.ts.map +1 -0
  109. package/dist/types/statements.js +2 -0
  110. package/dist/types/statements.js.map +1 -0
  111. package/package.json +54 -0
@@ -0,0 +1,271 @@
1
+ import * as fs from 'fs';
2
+ import { SpecialPromptKeys } from '../types/prompts.js';
3
+ /**
4
+ * Service for parsing system prompts from the prompt.ai-project.system.md file
5
+ * Handles markdown section parsing, instruction mapping, and caching
6
+ */
7
+ export class SystemPromptParser {
8
+ promptsCache = new Map();
9
+ filePath;
10
+ static CACHE_TTL_MS = 5 * 60 * 1000; // 5 minutes
11
+ constructor(filePath) {
12
+ if (!filePath) {
13
+ throw new Error('SystemPromptParser requires an explicit file path. ' +
14
+ 'Configure a project path in the UI to resolve prompt files.');
15
+ }
16
+ this.filePath = filePath;
17
+ }
18
+ /**
19
+ * Parse the entire prompt file and extract all sections
20
+ */
21
+ async parsePromptFile() {
22
+ // Check if file exists
23
+ if (!fs.existsSync(this.filePath)) {
24
+ throw new Error(`System prompt file not found at ${this.filePath}`);
25
+ }
26
+ // Check cache first
27
+ const cached = this.getCachedPrompts();
28
+ if (cached) {
29
+ return {
30
+ prompts: cached,
31
+ errors: []
32
+ };
33
+ }
34
+ // Read and parse file
35
+ const fileContent = fs.readFileSync(this.filePath, 'utf-8');
36
+ const prompts = this.parseMarkdownSections(fileContent);
37
+ // Cache results
38
+ this.cachePrompts(prompts);
39
+ return {
40
+ prompts,
41
+ errors: []
42
+ };
43
+ }
44
+ /**
45
+ * Parse markdown sections using ##### headers
46
+ */
47
+ parseMarkdownSections(content) {
48
+ const prompts = [];
49
+ // Extract sections by ##### headers
50
+ const sectionPattern = /^##### (.+)$/gm;
51
+ const sections = content.split(sectionPattern);
52
+ // Process sections (odd indices are headers, even are content)
53
+ for (let i = 1; i < sections.length; i += 2) {
54
+ const header = sections[i]?.trim();
55
+ const sectionContent = sections[i + 1]?.trim();
56
+ if (!header || !sectionContent)
57
+ continue;
58
+ // Extract markdown code blocks from content
59
+ const promptContent = this.extractPromptContent(sectionContent);
60
+ if (promptContent) {
61
+ const key = this.generateKeyFromHeader(header);
62
+ const parameters = this.extractParameters(promptContent);
63
+ prompts.push({
64
+ name: header,
65
+ key,
66
+ content: promptContent,
67
+ parameters
68
+ });
69
+ }
70
+ }
71
+ return prompts;
72
+ }
73
+ /**
74
+ * Extract prompt content from section, handling markdown code blocks
75
+ */
76
+ extractPromptContent(sectionContent) {
77
+ // Look for markdown code blocks first
78
+ const codeBlockPattern = /```(?:markdown)?\s*\n([\s\S]*?)\n```/g;
79
+ const codeBlocks = [];
80
+ let match;
81
+ while ((match = codeBlockPattern.exec(sectionContent)) !== null) {
82
+ codeBlocks.push(match[1].trim());
83
+ }
84
+ // If we found code blocks, join them
85
+ if (codeBlocks.length > 0) {
86
+ return codeBlocks.join('\n\n');
87
+ }
88
+ // Otherwise, return the raw content after the first paragraph
89
+ const lines = sectionContent.split('\n');
90
+ const contentStart = lines.findIndex(line => line.trim().startsWith('```') ||
91
+ line.trim().length > 0 && !line.trim().startsWith('*'));
92
+ if (contentStart >= 0) {
93
+ return lines.slice(contentStart).join('\n').trim();
94
+ }
95
+ return sectionContent;
96
+ }
97
+ /**
98
+ * Generate a key from section header
99
+ */
100
+ generateKeyFromHeader(header) {
101
+ return header
102
+ .toLowerCase()
103
+ .replace(/[^\w\s-]/g, '')
104
+ .replace(/\s+/g, '-')
105
+ .replace(/--+/g, '-')
106
+ .trim();
107
+ }
108
+ /**
109
+ * Extract parameters from prompt content
110
+ */
111
+ extractParameters(content) {
112
+ const paramPattern = /\{(\w+)\}/g;
113
+ const parameters = new Set();
114
+ let match;
115
+ while ((match = paramPattern.exec(content)) !== null) {
116
+ parameters.add(match[1]);
117
+ }
118
+ return Array.from(parameters);
119
+ }
120
+ /**
121
+ * Get context initialization prompt (Model Change or Context Refresh)
122
+ * @param isMonorepo - If true, returns monorepo-specific version; otherwise returns regular version
123
+ */
124
+ async getContextInitializationPrompt(isMonorepo = false) {
125
+ const parsed = await this.parsePromptFile();
126
+ if (isMonorepo) {
127
+ // Look for monorepo-specific context initialization prompt
128
+ const monorepoPrompt = parsed.prompts.find(prompt => prompt.name.toLowerCase().includes('context initialization') &&
129
+ prompt.name.toLowerCase().includes('monorepo'));
130
+ if (monorepoPrompt) {
131
+ return monorepoPrompt;
132
+ }
133
+ }
134
+ // Return regular (non-monorepo) context initialization prompt
135
+ return parsed.prompts.find(prompt => (prompt.key === SpecialPromptKeys.CONTEXT_INITIALIZATION ||
136
+ prompt.name.toLowerCase().includes('context initialization') ||
137
+ prompt.name.toLowerCase().includes('model change') ||
138
+ prompt.name.toLowerCase().includes('context refresh')) &&
139
+ !prompt.name.toLowerCase().includes('monorepo')) || null;
140
+ }
141
+ /**
142
+ * Get tool use prompt (Use 3rd Party Tool)
143
+ */
144
+ async getToolUsePrompt() {
145
+ const parsed = await this.parsePromptFile();
146
+ return parsed.prompts.find(prompt => prompt.key === SpecialPromptKeys.TOOL_USE ||
147
+ prompt.name.toLowerCase().includes('tool usage')) || null;
148
+ }
149
+ /**
150
+ * Get prompt for specific instruction type
151
+ */
152
+ async getPromptForInstruction(instruction) {
153
+ const parsed = await this.parsePromptFile();
154
+ // Find prompt by fuzzy matching instruction key against section headers
155
+ const match = parsed.prompts.find(prompt => {
156
+ const nameLower = prompt.name.toLowerCase();
157
+ const instructionLower = instruction.toLowerCase();
158
+ return nameLower.includes(instructionLower) ||
159
+ prompt.key.includes(instructionLower);
160
+ });
161
+ return match || null;
162
+ }
163
+ /**
164
+ * Get all available prompts
165
+ */
166
+ async getAllPrompts() {
167
+ const parsed = await this.parsePromptFile();
168
+ return parsed.prompts;
169
+ }
170
+ /**
171
+ * Check cached prompts and return if valid
172
+ */
173
+ getCachedPrompts() {
174
+ const cached = this.promptsCache.get(this.filePath);
175
+ if (!cached)
176
+ return null;
177
+ try {
178
+ // Check if cache is expired
179
+ if (Date.now() - cached.cachedAt > SystemPromptParser.CACHE_TTL_MS) {
180
+ this.promptsCache.delete(this.filePath);
181
+ return null;
182
+ }
183
+ // Check if file has been modified
184
+ const stats = fs.statSync(this.filePath);
185
+ if (stats.mtime.getTime() !== cached.mtime) {
186
+ this.promptsCache.delete(this.filePath);
187
+ return null;
188
+ }
189
+ return cached.prompts;
190
+ }
191
+ catch (error) {
192
+ // File might not exist, cache is invalid
193
+ this.promptsCache.delete(this.filePath);
194
+ return null;
195
+ }
196
+ }
197
+ /**
198
+ * Cache parsed prompts with file modification time
199
+ */
200
+ cachePrompts(prompts) {
201
+ try {
202
+ const stats = fs.statSync(this.filePath);
203
+ this.promptsCache.set(this.filePath, {
204
+ prompts: [...prompts], // Deep copy
205
+ mtime: stats.mtime.getTime(),
206
+ cachedAt: Date.now()
207
+ });
208
+ // Prevent cache from growing too large
209
+ if (this.promptsCache.size > 10) {
210
+ const oldestKey = this.promptsCache.keys().next().value;
211
+ if (oldestKey) {
212
+ this.promptsCache.delete(oldestKey);
213
+ }
214
+ }
215
+ }
216
+ catch (error) {
217
+ // Don't fail on cache errors
218
+ console.warn('Failed to cache prompts:', error);
219
+ }
220
+ }
221
+ /**
222
+ * Set a new file path and invalidate the cache
223
+ */
224
+ setFilePath(path) {
225
+ this.filePath = path;
226
+ this.promptsCache.clear();
227
+ }
228
+ /**
229
+ * Clear cache (useful for testing or forced refresh)
230
+ */
231
+ clearCache() {
232
+ this.promptsCache.clear();
233
+ }
234
+ /**
235
+ * Validate prompt file structure
236
+ */
237
+ async validatePromptFile() {
238
+ const errors = [];
239
+ try {
240
+ if (!fs.existsSync(this.filePath)) {
241
+ errors.push('Prompt file does not exist');
242
+ return { isValid: false, errors };
243
+ }
244
+ const content = fs.readFileSync(this.filePath, 'utf-8');
245
+ // Check for YAML frontmatter
246
+ if (!content.startsWith('---')) {
247
+ errors.push('Missing YAML frontmatter');
248
+ }
249
+ // Check for at least some ##### sections
250
+ const sectionCount = (content.match(/^##### /gm) || []).length;
251
+ if (sectionCount === 0) {
252
+ errors.push('No prompt sections found (##### headers)');
253
+ }
254
+ // Try to parse and check for critical prompts
255
+ const parsed = await this.parsePromptFile();
256
+ if (parsed.errors.length > 0) {
257
+ errors.push(...parsed.errors);
258
+ }
259
+ return {
260
+ isValid: errors.length === 0,
261
+ errors
262
+ };
263
+ }
264
+ catch (error) {
265
+ const message = error instanceof Error ? error.message : String(error);
266
+ errors.push(`Validation error: ${message}`);
267
+ return { isValid: false, errors };
268
+ }
269
+ }
270
+ }
271
+ //# sourceMappingURL=SystemPromptParser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SystemPromptParser.js","sourceRoot":"","sources":["../../src/services/SystemPromptParser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAA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AAM,CAAC,CAAC;YAChC,CAAC;YAED,OAAO;gBACL,OAAO,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC;gBAC5B,MAAM;aACP,CAAC;QACJ,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACvE,MAAM,CAAC,IAAI,CAAC,qBAAqB,OAAO,EAAE,CAAC,CAAC;YAC5C,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;QACpC,CAAC;IACH,CAAC"}
@@ -0,0 +1,35 @@
1
+ import type { ContextData } from '../types/context.js';
2
+ /**
3
+ * Utility for processing template strings with variable substitution
4
+ * Handles simple {{variable}} replacement and boolean conditionals
5
+ */
6
+ export declare class TemplateProcessor {
7
+ /**
8
+ * Processes a template string by replacing variables with data values
9
+ * @param template Template string with {{variable}} placeholders
10
+ * @param data Context data to substitute into template
11
+ * @returns Processed template string
12
+ */
13
+ processTemplate(template: string, data: ContextData): string;
14
+ /**
15
+ * Creates enhanced data with computed variables from the original data
16
+ * @param data Original context data
17
+ * @returns Enhanced data with slice parsing and template computations
18
+ */
19
+ private createEnhancedData;
20
+ /**
21
+ * Processes boolean conditional statements in template
22
+ * Supports: {{#if variableName}}true content{{else}}false content{{/if}}
23
+ * @param template Template string with conditional statements
24
+ * @param data Context data for boolean evaluation
25
+ * @returns Template with conditionals resolved
26
+ */
27
+ private processBooleanConditionals;
28
+ /**
29
+ * Validates that a template string is properly formatted
30
+ * @param template Template string to validate
31
+ * @returns True if template has valid syntax
32
+ */
33
+ validateTemplate(template: string): boolean;
34
+ }
35
+ //# sourceMappingURL=TemplateProcessor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TemplateProcessor.d.ts","sourceRoot":"","sources":["../../src/services/TemplateProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAKvD;;;GAGG;AACH,qBAAa,iBAAiB;IAE5B;;;;;OAKG;IACH,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,MAAM;IAiE5D;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;IAgC1B;;;;;;OAMG;IACH,OAAO,CAAC,0BAA0B;IAuBlC;;;;OAIG;IACH,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;CAqB5C"}
@@ -0,0 +1,150 @@
1
+ /**
2
+ * Utility for processing template strings with variable substitution
3
+ * Handles simple {{variable}} replacement and boolean conditionals
4
+ */
5
+ export class TemplateProcessor {
6
+ /**
7
+ * Processes a template string by replacing variables with data values
8
+ * @param template Template string with {{variable}} placeholders
9
+ * @param data Context data to substitute into template
10
+ * @returns Processed template string
11
+ */
12
+ processTemplate(template, data) {
13
+ try {
14
+ // Start with the template
15
+ let processed = template;
16
+ // First handle boolean conditionals: {{#if isMonorepo}}Yes{{else}}No{{/if}}
17
+ processed = this.processBooleanConditionals(processed, data);
18
+ // Create enhanced data with computed variables
19
+ const enhancedData = this.createEnhancedData(data);
20
+ // Then replace simple variables: {{variableName}} and {variableName}
21
+ // First handle double brace format: {{variableName}}
22
+ processed = processed.replace(/\{\{(\w+)\}\}/g, (_match, variableName) => {
23
+ const value = enhancedData[variableName];
24
+ if (value !== undefined && value !== null) {
25
+ return String(value);
26
+ }
27
+ // Log warning for missing variables but don't fail
28
+ console.warn(`Template variable '${variableName}' not found in data, replacing with empty string`);
29
+ return '';
30
+ });
31
+ // Then handle single brace format with more flexible patterns: {variableName}, {slice | feature}, etc.
32
+ processed = processed.replace(/\{([^}]+)\}/g, (_match, expression) => {
33
+ // Handle pipe expressions like {slice | feature}
34
+ if (expression.includes(' | ')) {
35
+ const parts = expression.split(' | ').map((part) => part.trim());
36
+ // Use the first part as the primary variable name
37
+ const primaryVar = parts[0];
38
+ const value = enhancedData[primaryVar];
39
+ if (value !== undefined && value !== null) {
40
+ return String(value);
41
+ }
42
+ // If primary variable not found, return the expression as-is for now
43
+ return expression;
44
+ }
45
+ // Handle simple variable names with common aliases
46
+ let variableName = expression;
47
+ // Map common template variables to data field names
48
+ if (expression === 'project') {
49
+ variableName = 'projectName';
50
+ }
51
+ const value = enhancedData[variableName];
52
+ if (value !== undefined && value !== null) {
53
+ return String(value);
54
+ }
55
+ // For parameters that might not be in our data, don't log warnings
56
+ // These might be template placeholders that should remain as-is
57
+ return expression;
58
+ });
59
+ return processed;
60
+ }
61
+ catch (error) {
62
+ console.error('Error processing template:', error);
63
+ const message = error instanceof Error ? error.message : String(error);
64
+ return `${template}\n\n[Error processing template: ${message}]`;
65
+ }
66
+ }
67
+ /**
68
+ * Creates enhanced data with computed variables from the original data
69
+ * @param data Original context data
70
+ * @returns Enhanced data with slice parsing and template computations
71
+ */
72
+ createEnhancedData(data) {
73
+ const enhanced = { ...data };
74
+ // Parse slice into sliceindex and slicename
75
+ if (data.slice) {
76
+ const sliceMatch = data.slice.match(/^(\d+)-slice\.(.+)$/);
77
+ if (sliceMatch) {
78
+ enhanced.sliceindex = sliceMatch[1];
79
+ enhanced.slicename = sliceMatch[2];
80
+ }
81
+ }
82
+ // Add kebab-case alias for developmentPhase
83
+ if (data.developmentPhase) {
84
+ enhanced['development-phase'] = data.developmentPhase;
85
+ }
86
+ // Add kebab-case alias for taskFile
87
+ if (data.taskFile) {
88
+ enhanced['task-file'] = data.taskFile;
89
+ }
90
+ // Add date aliases for template variable substitution
91
+ if (data.projectDate) {
92
+ enhanced['project-date'] = data.projectDate;
93
+ enhanced['projectDate'] = data.projectDate;
94
+ enhanced['projectdate'] = data.projectDate;
95
+ }
96
+ return enhanced;
97
+ }
98
+ /**
99
+ * Processes boolean conditional statements in template
100
+ * Supports: {{#if variableName}}true content{{else}}false content{{/if}}
101
+ * @param template Template string with conditional statements
102
+ * @param data Context data for boolean evaluation
103
+ * @returns Template with conditionals resolved
104
+ */
105
+ processBooleanConditionals(template, data) {
106
+ // Pattern: {{#if variableName}}true content{{else}}false content{{/if}}
107
+ const conditionalPattern = /\{\{#if\s+(\w+)\}\}(.*?)\{\{else\}\}(.*?)\{\{\/if\}\}/gs;
108
+ return template.replace(conditionalPattern, (_match, variableName, trueContent, falseContent) => {
109
+ try {
110
+ // Dynamic key lookup — variable names come from templates at runtime
111
+ const value = variableName in data
112
+ ? data[variableName]
113
+ : undefined;
114
+ // Evaluate as boolean
115
+ const isTrue = Boolean(value);
116
+ return isTrue ? trueContent : falseContent;
117
+ }
118
+ catch (error) {
119
+ console.warn(`Error evaluating conditional for '${variableName}':`, error);
120
+ // Default to false content on error
121
+ return falseContent;
122
+ }
123
+ });
124
+ }
125
+ /**
126
+ * Validates that a template string is properly formatted
127
+ * @param template Template string to validate
128
+ * @returns True if template has valid syntax
129
+ */
130
+ validateTemplate(template) {
131
+ try {
132
+ // Check for unmatched brackets
133
+ const openBrackets = (template.match(/\{\{/g) || []).length;
134
+ const closeBrackets = (template.match(/\}\}/g) || []).length;
135
+ if (openBrackets !== closeBrackets) {
136
+ return false;
137
+ }
138
+ // Check for proper conditional syntax
139
+ // If there are #if statements, they should all be properly closed
140
+ const ifStatements = (template.match(/\{\{#if\s+\w+\}\}/g) || []).length;
141
+ const endIfStatements = (template.match(/\{\{\/if\}\}/g) || []).length;
142
+ return ifStatements === endIfStatements;
143
+ }
144
+ catch (error) {
145
+ console.error('Template validation error:', error);
146
+ return false;
147
+ }
148
+ }
149
+ }
150
+ //# sourceMappingURL=TemplateProcessor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TemplateProcessor.js","sourceRoot":"","sources":["../../src/services/TemplateProcessor.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,MAAM,OAAO,iBAAiB;IAE5B;;;;;OAKG;IACH,eAAe,CAAC,QAAgB,EAAE,IAAiB;QACjD,IAAI,CAAC;YACH,0BAA0B;YAC1B,IAAI,SAA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AC,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,gBAAgB,CAAC,QAAgB;QAC/B,IAAI,CAAC;YACH,+BAA+B;YAC/B,MAAM,YAAY,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;YAC5D,MAAM,aAAa,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;YAE7D,IAAI,YAAY,KAAK,aAAa,EAAE,CAAC;gBACnC,OAAO,KAAK,CAAC;YACf,CAAC;YAED,sCAAsC;YACtC,kEAAkE;YAClE,MAAM,YAAY,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,oBAAoB,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;YACzE,MAAM,eAAe,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;YAEvE,OAAO,YAAY,KAAK,eAAe,CAAC;QAC1C,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,KAAK,CAAC,CAAC;YACnD,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,8 @@
1
+ import type { TemplateStatement } from '../types/statements.js';
2
+ /** Relative path (from project root) to the default statements file */
3
+ export declare const STATEMENTS_FILE_RELATIVE_PATH = "default-statements.md";
4
+ /** Relative path (from project root) to the system prompt file */
5
+ export declare const PROMPT_FILE_RELATIVE_PATH = "project-documents/ai-project-guide/project-guides/prompt.ai-project.system.md";
6
+ /** Default statements used as fallback when the statements file is missing */
7
+ export declare const DEFAULT_STATEMENTS: Record<string, TemplateStatement>;
8
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/services/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,uEAAuE;AACvE,eAAO,MAAM,6BAA6B,0BAA0B,CAAC;AAErE,kEAAkE;AAClE,eAAO,MAAM,yBAAyB,kFAC2C,CAAC;AAElF,8EAA8E;AAC9E,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CA0DhE,CAAC"}
@@ -0,0 +1,62 @@
1
+ /** Relative path (from project root) to the default statements file */
2
+ export const STATEMENTS_FILE_RELATIVE_PATH = 'default-statements.md';
3
+ /** Relative path (from project root) to the system prompt file */
4
+ export const PROMPT_FILE_RELATIVE_PATH = 'project-documents/ai-project-guide/project-guides/prompt.ai-project.system.md';
5
+ /** Default statements used as fallback when the statements file is missing */
6
+ export const DEFAULT_STATEMENTS = {
7
+ 'start-project-statement': {
8
+ key: 'start-project-statement',
9
+ content: 'Starting work on {{projectName}}. Project information, environment context, instructions, and notes follow:',
10
+ description: 'Opening statement for starting a new project',
11
+ editable: true
12
+ },
13
+ 'continue-project-statement': {
14
+ key: 'continue-project-statement',
15
+ content: 'Continuing work on {{projectName}}. Project information, environment context, instructions, and notes follow:',
16
+ description: 'Opening statement for continuing project work',
17
+ editable: true
18
+ },
19
+ 'tool-intro-statement': {
20
+ key: 'tool-intro-statement',
21
+ content: 'The following tools and MCP servers are available for this project:',
22
+ description: 'Introduction to tools and MCP section',
23
+ editable: true
24
+ },
25
+ 'instruction-intro-statement': {
26
+ key: 'instruction-intro-statement',
27
+ content: 'Current development phase and instructions:',
28
+ description: 'Introduction to instruction prompt section',
29
+ editable: true
30
+ },
31
+ 'monorepo-statement': {
32
+ key: 'monorepo-statement',
33
+ content: 'Project is configured as a monorepo. Working in package: {{template}}, Slice: {{slice}}',
34
+ description: 'Monorepo configuration statement',
35
+ editable: true
36
+ },
37
+ 'current-events-header': {
38
+ key: 'current-events-header',
39
+ content: '### Current Project State',
40
+ description: 'Header for current project state section',
41
+ editable: true
42
+ },
43
+ 'additional-notes-header': {
44
+ key: 'additional-notes-header',
45
+ content: '### Additional Notes',
46
+ description: 'Header for additional notes section',
47
+ editable: true
48
+ },
49
+ 'no-tools-statement': {
50
+ key: 'no-tools-statement',
51
+ content: 'No additional tools or MCP servers detected for this session.',
52
+ description: 'Statement when no tools are available',
53
+ editable: true
54
+ },
55
+ 'custom-instruction-statement': {
56
+ key: 'custom-instruction-statement',
57
+ content: 'Custom instruction provided: {{instruction}}',
58
+ description: 'Statement for custom instruction types',
59
+ editable: true
60
+ }
61
+ };
62
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/services/constants.ts"],"names":[],"mappings":"AAEA,uEAAuE;AACvE,MAAM,CAAC,MAAM,6BAA6B,GAAG,uBAAuB,CAAC;AAErE,kEAAkE;AAClE,MAAM,CAAC,MAAM,yBAAyB,GACpC,+EAA+E,CAAC;AAElF,8EAA8E;AAC9E,MAAM,CAAC,MAAM,kBAAkB,GAAsC;IACnE,yBAAyB,EAAE;QACzB,GAAG,EAAE,yBAAyB;QAC9B,OAAO,EACL,6GAA6G;QAC/G,WAAW,EAAE,8CAA8C;QAC3D,QAAQ,EAAE,IAAI;KACf;IACD,4BAA4B,EAAE;QAC5B,GAAG,EAAE,4BAA4B;QACjC,OAAO,EACL,+GAA+G;QACjH,WAAW,EAAE,+CAA+C;QAC5D,QAAQ,EAAE,IAAI;KACf;IACD,sBAAsB,EAAE;QACtB,GAAG,EAAE,sBAAsB;QAC3B,OAAO,EAAE,qEAAqE;QAC9E,WAAW,EAAE,uCAAuC;QACpD,QAAQ,EAAE,IAAI;KACf;IACD,6BAA6B,EAAE;QAC7B,GAAG,EAAE,6BAA6B;QAClC,OAAO,EAAE,6CAA6C;QACtD,WAAW,EAAE,4CAA4C;QACzD,QAAQ,EAAE,IAAI;KACf;IACD,oBAAoB,EAAE;QACpB,GAAG,EAAE,oBAAoB;QACzB,OAAO,EACL,yFAAyF;QAC3F,WAAW,EAAE,kCAAkC;QAC/C,QAAQ,EAAE,IAAI;KACf;IACD,uBAAuB,EAAE;QACvB,GAAG,EAAE,uBAAuB;QAC5B,OAAO,EAAE,2BAA2B;QACpC,WAAW,EAAE,0CAA0C;QACvD,QAAQ,EAAE,IAAI;KACf;IACD,yBAAyB,EAAE;QACzB,GAAG,EAAE,yBAAyB;QAC9B,OAAO,EAAE,sBAAsB;QAC/B,WAAW,EAAE,qCAAqC;QAClD,QAAQ,EAAE,IAAI;KACf;IACD,oBAAoB,EAAE;QACpB,GAAG,EAAE,oBAAoB;QACzB,OAAO,EAAE,+DAA+D;QACxE,WAAW,EAAE,uCAAuC;QACpD,QAAQ,EAAE,IAAI;KACf;IACD,8BAA8B,EAAE;QAC9B,GAAG,EAAE,8BAA8B;QACnC,OAAO,EAAE,8CAA8C;QACvD,WAAW,EAAE,wCAAwC;QACrD,QAAQ,EAAE,IAAI;KACf;CACF,CAAC"}
@@ -0,0 +1,8 @@
1
+ export type { IStatementReader, IPromptReader, IStatementService, IPromptService } from './interfaces.js';
2
+ export { DEFAULT_STATEMENTS, STATEMENTS_FILE_RELATIVE_PATH, PROMPT_FILE_RELATIVE_PATH } from './constants.js';
3
+ export { TemplateProcessor } from './TemplateProcessor.js';
4
+ export { SectionBuilder } from './SectionBuilder.js';
5
+ export { ContextGenerator } from './ContextGenerator.js';
6
+ export { ContextTemplateEngine } from './ContextTemplateEngine.js';
7
+ export { ContextIntegrator } from './ContextIntegrator.js';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,gBAAgB,EAAE,aAAa,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAG1G,OAAO,EAAE,kBAAkB,EAAE,6BAA6B,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAG9G,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1,12 @@
1
+ // Constants
2
+ export { DEFAULT_STATEMENTS, STATEMENTS_FILE_RELATIVE_PATH, PROMPT_FILE_RELATIVE_PATH } from './constants.js';
3
+ // Browser-safe services (no fs/path dependency)
4
+ export { TemplateProcessor } from './TemplateProcessor.js';
5
+ export { SectionBuilder } from './SectionBuilder.js';
6
+ // Orchestrators (browser-safe — use interfaces, not concrete Node.js services)
7
+ export { ContextGenerator } from './ContextGenerator.js';
8
+ export { ContextTemplateEngine } from './ContextTemplateEngine.js';
9
+ export { ContextIntegrator } from './ContextIntegrator.js';
10
+ // Node.js-dependent services moved to @context-forge/core/node:
11
+ // StatementManager, SystemPromptParser, ProjectPathService, createContextPipeline
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAGA,YAAY;AACZ,OAAO,EAAE,kBAAkB,EAAE,6BAA6B,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAE9G,gDAAgD;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,+EAA+E;AAC/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,gEAAgE;AAChE,kFAAkF"}
@@ -0,0 +1,21 @@
1
+ import type { SystemPrompt } from '../types/prompts.js';
2
+ /** Minimal interface for reading template statements (satisfied by StatementManager and StatementManagerIPC) */
3
+ export interface IStatementReader {
4
+ getStatement(key: string): string;
5
+ }
6
+ /** Minimal interface for reading system prompts (satisfied by SystemPromptParser and SystemPromptParserIPC) */
7
+ export interface IPromptReader {
8
+ getToolUsePrompt(): Promise<SystemPrompt | null>;
9
+ getPromptForInstruction(instruction: string): Promise<SystemPrompt | null>;
10
+ getContextInitializationPrompt(isMonorepo?: boolean): Promise<SystemPrompt | null>;
11
+ }
12
+ /** Extended interface for statement management with file path support */
13
+ export interface IStatementService extends IStatementReader {
14
+ loadStatements(): Promise<void>;
15
+ setFilePath(path: string): void;
16
+ }
17
+ /** Extended interface for prompt parsing with file path support */
18
+ export interface IPromptService extends IPromptReader {
19
+ setFilePath(path: string): void;
20
+ }
21
+ //# sourceMappingURL=interfaces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../src/services/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,gHAAgH;AAChH,MAAM,WAAW,gBAAgB;IAC/B,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACnC;AAED,+GAA+G;AAC/G,MAAM,WAAW,aAAa;IAC5B,gBAAgB,IAAI,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;IACjD,uBAAuB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;IAC3E,8BAA8B,CAAC,UAAU,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;CACpF;AAED,yEAAyE;AACzE,MAAM,WAAW,iBAAkB,SAAQ,gBAAgB;IACzD,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACjC;AAED,mEAAmE;AACnE,MAAM,WAAW,cAAe,SAAQ,aAAa;IACnD,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACjC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/services/interfaces.ts"],"names":[],"mappings":""}