@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,239 @@
1
+ import { SectionBuilder } from './SectionBuilder.js';
2
+ import { TemplateProcessor } from './TemplateProcessor.js';
3
+ /**
4
+ * Main orchestrator for context template generation
5
+ * Coordinates between statement manager, prompt parser, and section builder
6
+ */
7
+ export class ContextTemplateEngine {
8
+ promptParser;
9
+ statementManager;
10
+ sectionBuilder;
11
+ templateProcessor;
12
+ enableNewEngine = true;
13
+ constructor(promptParser, statementManager, sectionBuilder) {
14
+ this.promptParser = promptParser;
15
+ this.statementManager = statementManager;
16
+ this.sectionBuilder = sectionBuilder || new SectionBuilder(this.statementManager, this.promptParser);
17
+ this.templateProcessor = new TemplateProcessor();
18
+ }
19
+ /**
20
+ * Ensure statement manager is initialized
21
+ */
22
+ async ensureStatementManagerInitialized() {
23
+ try {
24
+ // Try to load statements, this will set isLoaded to true
25
+ await this.statementManager.loadStatements();
26
+ }
27
+ catch (error) {
28
+ // If loading fails, initialize with defaults
29
+ console.warn('Failed to load custom statements, using defaults:', error);
30
+ // The StatementManager should handle this gracefully with its fallback system
31
+ }
32
+ }
33
+ /**
34
+ * Generate context from enhanced project data
35
+ */
36
+ async generateContext(data) {
37
+ try {
38
+ // Ensure statement manager is initialized
39
+ await this.ensureStatementManagerInitialized();
40
+ // Validate input data
41
+ this.validateInputData(data);
42
+ // Build template configuration
43
+ const template = await this.buildTemplate(data);
44
+ // Assemble sections into final context
45
+ const sections = await this.assembleSections(template, data);
46
+ // Format and return final output
47
+ return this.formatOutput(sections);
48
+ }
49
+ catch (error) {
50
+ console.error('Error generating context with template engine:', error);
51
+ // Fallback to basic template
52
+ return this.getErrorContext(data);
53
+ }
54
+ }
55
+ /**
56
+ * Build template configuration based on project data
57
+ */
58
+ async buildTemplate(data) {
59
+ const sections = [];
60
+ // 1. Project intro section (always included)
61
+ // Select appropriate opening statement based on work type
62
+ const statementKey = data.workType === 'start' ? 'start-project-statement' : 'continue-project-statement';
63
+ sections.push({
64
+ key: 'project-intro',
65
+ title: '',
66
+ content: await this.statementManager.getStatement(statementKey),
67
+ conditional: false,
68
+ order: 1
69
+ });
70
+ // 1.5. Project information object (always included)
71
+ sections.push({
72
+ key: 'project-info',
73
+ title: '',
74
+ content: await this.sectionBuilder.buildProjectInfoSection(data),
75
+ conditional: false,
76
+ order: 1.5
77
+ });
78
+ // 2. Context initialization prompt (select appropriate version based on monorepo mode)
79
+ const contextInitPrompt = await this.promptParser.getContextInitializationPrompt(data.isMonorepo);
80
+ sections.push({
81
+ key: 'context-init',
82
+ title: '',
83
+ content: contextInitPrompt?.content || 'Project context and environment details follow.',
84
+ conditional: false,
85
+ order: 2
86
+ });
87
+ // 3. Tools and MCP section (always included)
88
+ sections.push({
89
+ key: 'tools-section',
90
+ title: '### 3rd-Party Tools & MCP',
91
+ content: await this.sectionBuilder.buildToolsSection(data),
92
+ conditional: false,
93
+ order: 3
94
+ });
95
+ // 4. Monorepo section (conditional on project setting only)
96
+ if (data.isMonorepo) {
97
+ sections.push({
98
+ key: 'monorepo-section',
99
+ title: '### Monorepo Note',
100
+ content: await this.sectionBuilder.buildMonorepoSection(data),
101
+ conditional: true,
102
+ condition: () => data.isMonorepo,
103
+ order: 4
104
+ });
105
+ }
106
+ // 5. Current project state section (always included if present)
107
+ if (data.recentEvents && data.recentEvents.trim()) {
108
+ sections.push({
109
+ key: 'current-events',
110
+ title: '### Current Project State',
111
+ content: data.recentEvents,
112
+ conditional: false,
113
+ order: 5
114
+ });
115
+ }
116
+ // 6. Instruction section (always included)
117
+ sections.push({
118
+ key: 'instruction',
119
+ title: '### Instruction Prompt',
120
+ content: await this.sectionBuilder.buildInstructionSection(data),
121
+ conditional: false,
122
+ order: 6
123
+ });
124
+ // 7. Additional instructions section (conditional)
125
+ if (data.additionalNotes && data.additionalNotes.trim()) {
126
+ sections.push({
127
+ key: 'additional-notes',
128
+ title: '## Additional Instructions',
129
+ content: data.additionalNotes,
130
+ conditional: false,
131
+ order: 7
132
+ });
133
+ }
134
+ return {
135
+ sections,
136
+ statements: {},
137
+ prompts: {}
138
+ };
139
+ }
140
+ /**
141
+ * Assemble sections into final context string
142
+ */
143
+ async assembleSections(template, data) {
144
+ const processedSections = [];
145
+ // Sort sections by order
146
+ const sortedSections = template.sections.sort((a, b) => a.order - b.order);
147
+ for (const section of sortedSections) {
148
+ // Check conditional sections
149
+ if (section.conditional && section.condition && !section.condition(data)) {
150
+ continue;
151
+ }
152
+ // Process section content
153
+ const processedContent = await this.processSection(section, data);
154
+ if (processedContent.trim()) {
155
+ processedSections.push(processedContent);
156
+ }
157
+ }
158
+ // Combine sections with proper spacing
159
+ return processedSections.join('\n\n');
160
+ }
161
+ /**
162
+ * Process individual section with template variables
163
+ */
164
+ async processSection(section, data) {
165
+ let content = section.content;
166
+ // Replace template variables
167
+ content = this.replaceTemplateVariables(content, data);
168
+ // Add section title if present
169
+ if (section.title) {
170
+ content = `${section.title}\n${content}`;
171
+ }
172
+ return content;
173
+ }
174
+ /**
175
+ * Replace template variables in content using enhanced TemplateProcessor
176
+ */
177
+ replaceTemplateVariables(content, data) {
178
+ // Use the enhanced TemplateProcessor which handles slice parsing and all template variables
179
+ return this.templateProcessor.processTemplate(content, data);
180
+ }
181
+ /**
182
+ * Format final output with cleanup
183
+ */
184
+ formatOutput(content) {
185
+ // Remove excessive whitespace
186
+ let formatted = content.replace(/\n{3,}/g, '\n\n');
187
+ // Normalize line endings
188
+ formatted = formatted.replace(/\r\n/g, '\n');
189
+ // Trim leading/trailing whitespace
190
+ formatted = formatted.trim();
191
+ return formatted;
192
+ }
193
+ /**
194
+ * Validate input data has required fields
195
+ */
196
+ validateInputData(data) {
197
+ const required = ['projectName', 'template', 'slice', 'instruction'];
198
+ // Assertion safe: required array contains only known EnhancedContextData keys
199
+ const missing = required.filter(field => !data[field]);
200
+ if (missing.length > 0) {
201
+ throw new Error(`Missing required fields: ${missing.join(', ')}`);
202
+ }
203
+ }
204
+ /**
205
+ * Generate explicit error context (no silent fallbacks)
206
+ */
207
+ getErrorContext(data) {
208
+ return `ERROR: Context generation failed
209
+
210
+ Project: ${data.projectName || 'MISSING_PROJECT_NAME'}
211
+ Template: ${data.template || 'MISSING_TEMPLATE'}
212
+ Slice: ${data.slice || 'MISSING_SLICE'}
213
+ Instruction: ${data.instruction || 'MISSING_INSTRUCTION'}
214
+ Monorepo: ${data.isMonorepo ? 'Yes' : 'No'}
215
+
216
+ This is an explicit error - context template engine failed to generate proper output.
217
+ Check the console for detailed error information.`;
218
+ }
219
+ /**
220
+ * Check if new template engine is enabled
221
+ */
222
+ isEnabled() {
223
+ return this.enableNewEngine;
224
+ }
225
+ /**
226
+ * Toggle template engine on/off for testing
227
+ */
228
+ setEnabled(enabled) {
229
+ this.enableNewEngine = enabled;
230
+ }
231
+ /**
232
+ * Update file paths on internal services (resolves absolute paths from projectPath)
233
+ */
234
+ updateServicePaths(promptFilePath, statementFilePath) {
235
+ this.promptParser.setFilePath(promptFilePath);
236
+ this.statementManager.setFilePath(statementFilePath);
237
+ }
238
+ }
239
+ //# sourceMappingURL=ContextTemplateEngine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContextTemplateEngine.js","sourceRoot":"","sources":["../../src/services/ContextTemplateEngine.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D;;;GAGG;AACH,MAAM,OAAO,qBAAqB;IACxB,YAAY,CAAiB;IAC7B,gBAAgB,CAAoB;IACpC,cAAc,CAAiB;IAC/B,iBAAiB,CAAoB;IACrC,eAAe,GAAY,IAAI,CAAC;IAExC,YACE,YAA4B,EAC5B,gBAAmC,EACnC,cAA+B;QAE/B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,cAAc,GAAG,cAAc,IAAI,IAAI,cAAc,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QACrG,IAAI,CAAC,iBAAiB,GAAG,IAAI,iBAAiB,EAAE,CAAC;IACnD,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,iCAAiC;QAC7C,IAAI,CAAC;YACH,yDAAyD;YACzD,MAAM,IAAI,CAAC,gBAAgB,CAAC,cAAc,EAAE,CAAC;QAC/C,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,6CAA6C;YAC7C,OAAO,CAAC,IAAI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,CAAC,IAAyB;QACjD,MAAM,QAAQ,GAAG,CAAC,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC;QACrE,8EAA8E;QAC9E,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,KAAkC,CAAC,CAAC,CAAC;QAEpF,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CAAC,4BAA4B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACpE,CAAC;IACH,CAAC;IAED;;OAEG;IACK,eAAe,CAAC,IAAyB;QAC/C,OAAO;;WAEA,IAAI,CAAC,WAAW,IAAI,sBAAsB;YACzC,IAAI,CAAC,QAAQ,IAAI,kBAAkB;SACtC,IAAI,CAAC,KAAK,IAAI,eAAe;eACvB,IAAI,CAAC,WAAW,IAAI,qBAAqB;YAC5C,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;;;kDAGQ,CAAC;IACjD,CAAC;IAED;;OAEG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,OAAgB;QACzB,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC;IACjC,CAAC;IAED;;OAEG;IACH,kBAAkB,CAAC,cAAsB,EAAE,iBAAyB;QAClE,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;QAC9C,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC;IACvD,CAAC;CACF"}
@@ -0,0 +1,14 @@
1
+ import { ContextTemplateEngine } from './ContextTemplateEngine.js';
2
+ import { ContextIntegrator } from './ContextIntegrator.js';
3
+ /**
4
+ * Creates a fully wired context assembly pipeline for a given project path.
5
+ * Intended for use in non-renderer contexts (MCP server, CLI, tests).
6
+ *
7
+ * @param projectPath Absolute path to the project root
8
+ * @returns { engine, integrator } ready for context generation
9
+ */
10
+ export declare function createContextPipeline(projectPath: string): {
11
+ engine: ContextTemplateEngine;
12
+ integrator: ContextIntegrator;
13
+ };
14
+ //# sourceMappingURL=CoreServiceFactory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CoreServiceFactory.d.ts","sourceRoot":"","sources":["../../src/services/CoreServiceFactory.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAG3D;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,MAAM,GAAG;IAC1D,MAAM,EAAE,qBAAqB,CAAC;IAC9B,UAAU,EAAE,iBAAiB,CAAC;CAC/B,CAWA"}
@@ -0,0 +1,23 @@
1
+ import * as path from 'path';
2
+ import { SystemPromptParser } from './SystemPromptParser.js';
3
+ import { StatementManager } from './StatementManager.js';
4
+ import { ContextTemplateEngine } from './ContextTemplateEngine.js';
5
+ import { ContextIntegrator } from './ContextIntegrator.js';
6
+ import { PROMPT_FILE_RELATIVE_PATH, STATEMENTS_FILE_RELATIVE_PATH } from './constants.js';
7
+ /**
8
+ * Creates a fully wired context assembly pipeline for a given project path.
9
+ * Intended for use in non-renderer contexts (MCP server, CLI, tests).
10
+ *
11
+ * @param projectPath Absolute path to the project root
12
+ * @returns { engine, integrator } ready for context generation
13
+ */
14
+ export function createContextPipeline(projectPath) {
15
+ const promptFilePath = path.join(projectPath, PROMPT_FILE_RELATIVE_PATH);
16
+ const statementFilePath = path.join(projectPath, STATEMENTS_FILE_RELATIVE_PATH);
17
+ const promptParser = new SystemPromptParser(promptFilePath);
18
+ const statementManager = new StatementManager(statementFilePath);
19
+ const engine = new ContextTemplateEngine(promptParser, statementManager);
20
+ const integrator = new ContextIntegrator(engine);
21
+ return { engine, integrator };
22
+ }
23
+ //# sourceMappingURL=CoreServiceFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CoreServiceFactory.js","sourceRoot":"","sources":["../../src/services/CoreServiceFactory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,yBAAyB,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAC;AAE1F;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,WAAmB;IAIvD,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,yBAAyB,CAAC,CAAC;IACzE,MAAM,iBAAiB,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,6BAA6B,CAAC,CAAC;IAEhF,MAAM,YAAY,GAAG,IAAI,kBAAkB,CAAC,cAAc,CAAC,CAAC;IAC5D,MAAM,gBAAgB,GAAG,IAAI,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;IAEjE,MAAM,MAAM,GAAG,IAAI,qBAAqB,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;IACzE,MAAM,UAAU,GAAG,IAAI,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAEjD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;AAChC,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { PathValidationResult, DirectoryListResult } from '../types/paths.js';
2
+ /**
3
+ * Stateless service for validating project paths and listing directory contents.
4
+ * Runs in the main process; all data passed per-call (no constructor state).
5
+ */
6
+ export declare class ProjectPathService {
7
+ /** Validate a project path against the expected directory structure. */
8
+ validate(projectPath: string): Promise<PathValidationResult>;
9
+ /** On-demand revalidation — same logic as validate, separate for semantic clarity. */
10
+ healthCheck(projectPath: string): Promise<PathValidationResult>;
11
+ /** List files in a project subdirectory (filenames only). */
12
+ listDirectory(projectPath: string, subdirectory: string, isMonorepo?: boolean): Promise<DirectoryListResult>;
13
+ }
14
+ //# sourceMappingURL=ProjectPathService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProjectPathService.d.ts","sourceRoot":"","sources":["../../src/services/ProjectPathService.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AASnF;;;GAGG;AACH,qBAAa,kBAAkB;IAC7B,wEAAwE;IAClE,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAwFlE,sFAAsF;IAChF,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAIrE,6DAA6D;IACvD,aAAa,CACjB,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,UAAU,CAAC,EAAE,OAAO,GACnB,OAAO,CAAC,mBAAmB,CAAC;CAsChC"}
@@ -0,0 +1,142 @@
1
+ import * as fs from 'fs';
2
+ import * as path from 'path';
3
+ const EXPECTED_SUBDIRS = ['slices', 'tasks', 'features', 'architecture'];
4
+ /** Type guard for Node.js filesystem errors */
5
+ function isNodeError(err) {
6
+ return err instanceof Error && 'code' in err;
7
+ }
8
+ /**
9
+ * Stateless service for validating project paths and listing directory contents.
10
+ * Runs in the main process; all data passed per-call (no constructor state).
11
+ */
12
+ export class ProjectPathService {
13
+ /** Validate a project path against the expected directory structure. */
14
+ async validate(projectPath) {
15
+ const result = {
16
+ valid: false,
17
+ projectPath,
18
+ errors: [],
19
+ structure: {
20
+ hasProjectDocuments: false,
21
+ hasUserDir: false,
22
+ subdirectories: [],
23
+ },
24
+ };
25
+ if (!projectPath || typeof projectPath !== 'string') {
26
+ result.errors.push('Path must be a non-empty string');
27
+ return result;
28
+ }
29
+ if (projectPath.includes('\0') || projectPath.includes('..')) {
30
+ result.errors.push('Path contains invalid characters');
31
+ return result;
32
+ }
33
+ try {
34
+ const stat = await fs.promises.stat(projectPath);
35
+ if (!stat.isDirectory()) {
36
+ result.errors.push('Path is not a directory');
37
+ return result;
38
+ }
39
+ }
40
+ catch (err) {
41
+ if (isNodeError(err)) {
42
+ if (err.code === 'ENOENT') {
43
+ result.errors.push('Path does not exist');
44
+ }
45
+ else if (err.code === 'EACCES') {
46
+ result.errors.push('Permission denied');
47
+ }
48
+ else {
49
+ result.errors.push(`Cannot access path: ${err.code ?? 'unknown error'}`);
50
+ }
51
+ }
52
+ else {
53
+ result.errors.push(`Cannot access path: ${err instanceof Error ? err.message : 'unknown error'}`);
54
+ }
55
+ return result;
56
+ }
57
+ // Check for project-documents/
58
+ const projectDocsPath = path.join(projectPath, 'project-documents');
59
+ try {
60
+ const stat = await fs.promises.stat(projectDocsPath);
61
+ if (stat.isDirectory()) {
62
+ result.structure.hasProjectDocuments = true;
63
+ }
64
+ else {
65
+ result.errors.push('project-documents exists but is not a directory');
66
+ return result;
67
+ }
68
+ }
69
+ catch {
70
+ result.errors.push('project-documents/ directory not found');
71
+ return result;
72
+ }
73
+ // Check for project-documents/user/
74
+ const userDirPath = path.join(projectDocsPath, 'user');
75
+ try {
76
+ const stat = await fs.promises.stat(userDirPath);
77
+ if (stat.isDirectory()) {
78
+ result.structure.hasUserDir = true;
79
+ }
80
+ }
81
+ catch {
82
+ // user/ not found is not fatal — path is still valid if project-documents exists
83
+ }
84
+ // Check which expected subdirectories exist under user/
85
+ if (result.structure.hasUserDir) {
86
+ for (const subdir of EXPECTED_SUBDIRS) {
87
+ const subdirPath = path.join(userDirPath, subdir);
88
+ try {
89
+ const stat = await fs.promises.stat(subdirPath);
90
+ if (stat.isDirectory()) {
91
+ result.structure.subdirectories.push(subdir);
92
+ }
93
+ }
94
+ catch {
95
+ // Subdirectory doesn't exist — that's fine
96
+ }
97
+ }
98
+ }
99
+ result.valid = true;
100
+ return result;
101
+ }
102
+ /** On-demand revalidation — same logic as validate, separate for semantic clarity. */
103
+ async healthCheck(projectPath) {
104
+ return this.validate(projectPath);
105
+ }
106
+ /** List files in a project subdirectory (filenames only). */
107
+ async listDirectory(projectPath, subdirectory, isMonorepo) {
108
+ if (!projectPath || typeof projectPath !== 'string') {
109
+ return { files: [], error: 'Path must be a non-empty string' };
110
+ }
111
+ if (projectPath.includes('\0') || projectPath.includes('..')) {
112
+ return { files: [], error: 'Path contains invalid characters' };
113
+ }
114
+ if (!subdirectory || subdirectory.includes('..') || subdirectory.includes('\0')) {
115
+ return { files: [], error: 'Subdirectory contains invalid characters' };
116
+ }
117
+ const basePath = isMonorepo
118
+ ? path.join(projectPath, 'project-artifacts')
119
+ : path.join(projectPath, 'project-documents', 'user');
120
+ const fullPath = path.join(basePath, subdirectory);
121
+ try {
122
+ const entries = await fs.promises.readdir(fullPath, { withFileTypes: true });
123
+ const files = entries
124
+ .filter((entry) => entry.isFile())
125
+ .map((entry) => entry.name);
126
+ return { files };
127
+ }
128
+ catch (err) {
129
+ if (isNodeError(err)) {
130
+ if (err.code === 'ENOENT') {
131
+ return { files: [], error: `Directory not found: ${subdirectory}` };
132
+ }
133
+ else if (err.code === 'EACCES') {
134
+ return { files: [], error: 'Permission denied' };
135
+ }
136
+ return { files: [], error: `Cannot read directory: ${err.code ?? 'unknown error'}` };
137
+ }
138
+ return { files: [], error: `Cannot read directory: ${err instanceof Error ? err.message : 'unknown error'}` };
139
+ }
140
+ }
141
+ }
142
+ //# sourceMappingURL=ProjectPathService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProjectPathService.js","sourceRoot":"","sources":["../../src/services/ProjectPathService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAG7B,MAAM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AAwB,YAAY,EAAE,EAAE,CAAC;gBACtE,CAAC;qBAAM,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;oBACjC,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,mBAAmB,EAAE,CAAC;gBACnD,CAAC;gBACD,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,0BAA0B,GAAG,CAAC,IAAI,IAAI,eAAe,EAAE,EAAE,CAAC;YACvF,CAAC;YACD,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,0BAA0B,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,EAAE,EAAE,CAAC;QAChH,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,70 @@
1
+ import type { ContextSection, SectionBuilderConfig } from '../types/sections.js';
2
+ import type { EnhancedContextData } from '../types/context.js';
3
+ import type { IStatementReader, IPromptReader } from './interfaces.js';
4
+ /**
5
+ * Service for building individual context sections
6
+ * Handles conditional logic, template processing, and section assembly
7
+ */
8
+ export declare class SectionBuilder {
9
+ private statementManager;
10
+ private promptParser;
11
+ private templateProcessor;
12
+ private config;
13
+ constructor(statementManager: IStatementReader, promptParser: IPromptReader, config?: SectionBuilderConfig);
14
+ /**
15
+ * Build the tools and MCP section
16
+ */
17
+ buildToolsSection(data: EnhancedContextData): Promise<string>;
18
+ /**
19
+ * Build the monorepo-specific section
20
+ */
21
+ buildMonorepoSection(data: EnhancedContextData): string;
22
+ /**
23
+ * Build the instruction section with appropriate system prompt
24
+ */
25
+ buildInstructionSection(data: EnhancedContextData): Promise<string>;
26
+ /**
27
+ * Build the project information object section
28
+ */
29
+ buildProjectInfoSection(data: EnhancedContextData): Promise<string>;
30
+ /**
31
+ * Build a generic section with content
32
+ */
33
+ buildSection(section: ContextSection, data: EnhancedContextData): string;
34
+ /**
35
+ * Build current events section
36
+ */
37
+ buildCurrentEventsSection(data: EnhancedContextData): string;
38
+ /**
39
+ * Build additional notes section
40
+ */
41
+ buildAdditionalNotesSection(data: EnhancedContextData): string;
42
+ /**
43
+ * Detect available MCP servers and return info
44
+ */
45
+ private detectMCPAvailability;
46
+ /**
47
+ * Detect available tools and return info
48
+ */
49
+ detectAvailableTools(data: EnhancedContextData): string[];
50
+ /**
51
+ * Check if tools or MCP are available
52
+ */
53
+ hasToolsOrMCP(data: EnhancedContextData): boolean;
54
+ /**
55
+ * Validate section structure
56
+ */
57
+ validateSection(section: ContextSection): {
58
+ isValid: boolean;
59
+ errors: string[];
60
+ };
61
+ /**
62
+ * Create a section object
63
+ */
64
+ createSection(key: string, content: string, order: number, options?: {
65
+ title?: string;
66
+ conditional?: boolean;
67
+ condition?: (data: EnhancedContextData) => boolean;
68
+ }): ContextSection;
69
+ }
70
+ //# sourceMappingURL=SectionBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SectionBuilder.d.ts","sourceRoot":"","sources":["../../src/services/SectionBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGvE;;;GAGG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,gBAAgB,CAAmB;IAC3C,OAAO,CAAC,YAAY,CAAgB;IACpC,OAAO,CAAC,iBAAiB,CAAoB;IAC7C,OAAO,CAAC,MAAM,CAAuB;gBAGnC,gBAAgB,EAAE,gBAAgB,EAClC,YAAY,EAAE,aAAa,EAC3B,MAAM,CAAC,EAAE,oBAAoB;IAa/B;;OAEG;IACG,iBAAiB,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC;IAoDnE;;OAEG;IACH,oBAAoB,CAAC,IAAI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