@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.
- package/LICENSE +21 -0
- package/README.md +70 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/node.d.ts +6 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +10 -0
- package/dist/node.js.map +1 -0
- package/dist/services/ContextGenerator.d.ts +19 -0
- package/dist/services/ContextGenerator.d.ts.map +1 -0
- package/dist/services/ContextGenerator.js +66 -0
- package/dist/services/ContextGenerator.js.map +1 -0
- package/dist/services/ContextIntegrator.d.ts +84 -0
- package/dist/services/ContextIntegrator.d.ts.map +1 -0
- package/dist/services/ContextIntegrator.js +211 -0
- package/dist/services/ContextIntegrator.js.map +1 -0
- package/dist/services/ContextTemplateEngine.d.ts +65 -0
- package/dist/services/ContextTemplateEngine.d.ts.map +1 -0
- package/dist/services/ContextTemplateEngine.js +239 -0
- package/dist/services/ContextTemplateEngine.js.map +1 -0
- package/dist/services/CoreServiceFactory.d.ts +14 -0
- package/dist/services/CoreServiceFactory.d.ts.map +1 -0
- package/dist/services/CoreServiceFactory.js +23 -0
- package/dist/services/CoreServiceFactory.js.map +1 -0
- package/dist/services/ProjectPathService.d.ts +14 -0
- package/dist/services/ProjectPathService.d.ts.map +1 -0
- package/dist/services/ProjectPathService.js +142 -0
- package/dist/services/ProjectPathService.js.map +1 -0
- package/dist/services/SectionBuilder.d.ts +70 -0
- package/dist/services/SectionBuilder.d.ts.map +1 -0
- package/dist/services/SectionBuilder.js +303 -0
- package/dist/services/SectionBuilder.js.map +1 -0
- package/dist/services/StatementManager.d.ts +44 -0
- package/dist/services/StatementManager.d.ts.map +1 -0
- package/dist/services/StatementManager.js +216 -0
- package/dist/services/StatementManager.js.map +1 -0
- package/dist/services/SystemPromptParser.d.ts +72 -0
- package/dist/services/SystemPromptParser.d.ts.map +1 -0
- package/dist/services/SystemPromptParser.js +271 -0
- package/dist/services/SystemPromptParser.js.map +1 -0
- package/dist/services/TemplateProcessor.d.ts +35 -0
- package/dist/services/TemplateProcessor.d.ts.map +1 -0
- package/dist/services/TemplateProcessor.js +150 -0
- package/dist/services/TemplateProcessor.js.map +1 -0
- package/dist/services/constants.d.ts +8 -0
- package/dist/services/constants.d.ts.map +1 -0
- package/dist/services/constants.js +62 -0
- package/dist/services/constants.js.map +1 -0
- package/dist/services/index.d.ts +8 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +12 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/interfaces.d.ts +21 -0
- package/dist/services/interfaces.d.ts.map +1 -0
- package/dist/services/interfaces.js +2 -0
- package/dist/services/interfaces.js.map +1 -0
- package/dist/storage/FileProjectStore.d.ts +24 -0
- package/dist/storage/FileProjectStore.d.ts.map +1 -0
- package/dist/storage/FileProjectStore.js +141 -0
- package/dist/storage/FileProjectStore.js.map +1 -0
- package/dist/storage/FileStorageService.d.ts +14 -0
- package/dist/storage/FileStorageService.d.ts.map +1 -0
- package/dist/storage/FileStorageService.js +114 -0
- package/dist/storage/FileStorageService.js.map +1 -0
- package/dist/storage/backupService.d.ts +28 -0
- package/dist/storage/backupService.d.ts.map +1 -0
- package/dist/storage/backupService.js +84 -0
- package/dist/storage/backupService.js.map +1 -0
- package/dist/storage/index.d.ts +6 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +7 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/interfaces.d.ts +23 -0
- package/dist/storage/interfaces.d.ts.map +1 -0
- package/dist/storage/interfaces.js +2 -0
- package/dist/storage/interfaces.js.map +1 -0
- package/dist/storage/storagePaths.d.ts +9 -0
- package/dist/storage/storagePaths.d.ts.map +1 -0
- package/dist/storage/storagePaths.js +20 -0
- package/dist/storage/storagePaths.js.map +1 -0
- package/dist/types/context.d.ts +36 -0
- package/dist/types/context.d.ts.map +1 -0
- package/dist/types/context.js +2 -0
- package/dist/types/context.js.map +1 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/paths.d.ts +18 -0
- package/dist/types/paths.d.ts.map +1 -0
- package/dist/types/paths.js +2 -0
- package/dist/types/paths.js.map +1 -0
- package/dist/types/project.d.ts +48 -0
- package/dist/types/project.d.ts.map +1 -0
- package/dist/types/project.js +2 -0
- package/dist/types/project.js.map +1 -0
- package/dist/types/prompts.d.ts +49 -0
- package/dist/types/prompts.d.ts.map +1 -0
- package/dist/types/prompts.js +10 -0
- package/dist/types/prompts.js.map +1 -0
- package/dist/types/sections.d.ts +64 -0
- package/dist/types/sections.d.ts.map +1 -0
- package/dist/types/sections.js +13 -0
- package/dist/types/sections.js.map +1 -0
- package/dist/types/statements.d.ts +40 -0
- package/dist/types/statements.d.ts.map +1 -0
- package/dist/types/statements.js +2 -0
- package/dist/types/statements.js.map +1 -0
- package/package.json +54 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-2026 Manta Templates
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# @context-forge/core
|
|
2
|
+
|
|
3
|
+
The context generation engine that powers Context Forge. Handles template processing, project state management, prompt parsing, section building, and the full context assembly pipeline.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This package contains the core logic shared by both the [MCP server](../mcp-server/README.md) and the [Electron desktop app](../electron/). It has no Electron dependency and can be used by any Node.js consumer.
|
|
8
|
+
|
|
9
|
+
Key capabilities:
|
|
10
|
+
- **Context pipeline** — assembles structured context prompts from project configuration, templates, and statements
|
|
11
|
+
- **Template processing** — variable substitution (`{{projectName}}`, `{{slice}}`, etc.) with conditional sections
|
|
12
|
+
- **Statement management** — loads and resolves default statements (start/continue, tool intro, instruction blocks)
|
|
13
|
+
- **Prompt parsing** — reads `prompt.ai-project.system.md` files and extracts named template sections
|
|
14
|
+
- **Project storage** — filesystem-backed CRUD for project configuration with backup and migration support
|
|
15
|
+
|
|
16
|
+
## Export Paths
|
|
17
|
+
|
|
18
|
+
The package provides two entry points to separate browser-safe code from Node.js-dependent code.
|
|
19
|
+
|
|
20
|
+
### `@context-forge/core` — Types, interfaces, and browser-safe services
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import type { ProjectData, UpdateProjectData } from '@context-forge/core';
|
|
24
|
+
import type { IProjectStore, IStorageService } from '@context-forge/core';
|
|
25
|
+
import { TemplateProcessor, SectionBuilder } from '@context-forge/core';
|
|
26
|
+
import { ContextGenerator, ContextIntegrator } from '@context-forge/core';
|
|
27
|
+
import { PROMPT_FILE_RELATIVE_PATH, DEFAULT_STATEMENTS } from '@context-forge/core';
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
This entry point contains no `fs` or `path` dependencies and is safe for browser/renderer contexts.
|
|
31
|
+
|
|
32
|
+
### `@context-forge/core/node` — Node.js implementations
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
import { FileProjectStore, FileStorageService } from '@context-forge/core/node';
|
|
36
|
+
import { createContextPipeline } from '@context-forge/core/node';
|
|
37
|
+
import { StatementManager, SystemPromptParser } from '@context-forge/core/node';
|
|
38
|
+
import { ProjectPathService } from '@context-forge/core/node';
|
|
39
|
+
import { getStoragePath } from '@context-forge/core/node';
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
This entry point includes filesystem-dependent services. Use it in main processes, CLI tools, MCP servers, and tests. Do not import from browser/renderer code.
|
|
43
|
+
|
|
44
|
+
## Key Services
|
|
45
|
+
|
|
46
|
+
| Service | Entry Point | Description |
|
|
47
|
+
|---------|-------------|-------------|
|
|
48
|
+
| `FileProjectStore` | `./node` | Filesystem-backed project CRUD (read, create, update, delete) |
|
|
49
|
+
| `createContextPipeline` | `./node` | Factory that wires up all services for a project path and returns a ready-to-use `ContextIntegrator` |
|
|
50
|
+
| `StatementManager` | `./node` | Loads and parses `default-statements.md` from a project directory |
|
|
51
|
+
| `SystemPromptParser` | `./node` | Parses `prompt.ai-project.system.md` into named template sections |
|
|
52
|
+
| `ProjectPathService` | `./node` | Resolves file paths relative to a project root (task files, slice designs, guides) |
|
|
53
|
+
| `ContextIntegrator` | `.` | Orchestrates full context generation from a `ProjectData` object |
|
|
54
|
+
| `TemplateProcessor` | `.` | Handles `{{variable}}` substitution in template strings |
|
|
55
|
+
| `SectionBuilder` | `.` | Assembles individual context sections (statements, instructions, tools) |
|
|
56
|
+
|
|
57
|
+
## Usage in the Monorepo
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
packages/
|
|
61
|
+
core/ ← this package
|
|
62
|
+
mcp-server/ depends on @context-forge/core (workspace:*)
|
|
63
|
+
electron/ depends on @context-forge/core (workspace:*)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Both the MCP server and Electron app import types from `@context-forge/core` and Node.js services from `@context-forge/core/node`. The Electron renderer uses only the browser-safe entry point, with IPC bridges to access Node.js services from the main process.
|
|
67
|
+
|
|
68
|
+
## License
|
|
69
|
+
|
|
70
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AAGpC,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC"}
|
package/dist/node.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { StatementManager } from './services/StatementManager.js';
|
|
2
|
+
export { SystemPromptParser } from './services/SystemPromptParser.js';
|
|
3
|
+
export { ProjectPathService } from './services/ProjectPathService.js';
|
|
4
|
+
export { createContextPipeline } from './services/CoreServiceFactory.js';
|
|
5
|
+
export * from './storage/index.js';
|
|
6
|
+
//# sourceMappingURL=node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAGzE,cAAc,oBAAoB,CAAC"}
|
package/dist/node.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// @context-forge/core/node — Node.js-only services (fs/path dependent)
|
|
2
|
+
// Use this entry point in main process, CLI, MCP server, and tests.
|
|
3
|
+
// Do NOT import from renderer/browser code — use IPC wrappers instead.
|
|
4
|
+
export { StatementManager } from './services/StatementManager.js';
|
|
5
|
+
export { SystemPromptParser } from './services/SystemPromptParser.js';
|
|
6
|
+
export { ProjectPathService } from './services/ProjectPathService.js';
|
|
7
|
+
export { createContextPipeline } from './services/CoreServiceFactory.js';
|
|
8
|
+
// Storage — filesystem-backed project CRUD, backup, and storage utilities
|
|
9
|
+
export * from './storage/index.js';
|
|
10
|
+
//# sourceMappingURL=node.js.map
|
package/dist/node.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,oEAAoE;AACpE,uEAAuE;AAEvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAEzE,0EAA0E;AAC1E,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ProjectData } from '../types/project.js';
|
|
2
|
+
/**
|
|
3
|
+
* Basic context generation service for Claude Code prompts
|
|
4
|
+
*/
|
|
5
|
+
export declare class ContextGenerator {
|
|
6
|
+
/**
|
|
7
|
+
* Generates a basic context prompt for Claude Code based on project data
|
|
8
|
+
*/
|
|
9
|
+
generateContext(project: ProjectData, additionalNotes?: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Gets the base template for context generation
|
|
12
|
+
*/
|
|
13
|
+
private getBaseTemplate;
|
|
14
|
+
/**
|
|
15
|
+
* Validates project data for context generation
|
|
16
|
+
*/
|
|
17
|
+
validateProject(project: ProjectData): string[];
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=ContextGenerator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContextGenerator.d.ts","sourceRoot":"","sources":["../../src/services/ContextGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD;;GAEG;AACH,qBAAa,gBAAgB;IAE3B;;OAEG;IACH,eAAe,CAAC,OAAO,EAAE,WAAW,EAAE,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM;IAoBvE;;OAEG;IACH,OAAO,CAAC,eAAe;IAuBvB;;OAEG;IACH,eAAe,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,EAAE;CAiBhD"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Basic context generation service for Claude Code prompts
|
|
3
|
+
*/
|
|
4
|
+
export class ContextGenerator {
|
|
5
|
+
/**
|
|
6
|
+
* Generates a basic context prompt for Claude Code based on project data
|
|
7
|
+
*/
|
|
8
|
+
generateContext(project, additionalNotes) {
|
|
9
|
+
const template = this.getBaseTemplate();
|
|
10
|
+
// Simple variable substitution
|
|
11
|
+
let context = template
|
|
12
|
+
.replace('{{PROJECT_NAME}}', project.name)
|
|
13
|
+
.replace('{{TEMPLATE}}', project.template)
|
|
14
|
+
.replace('{{SLICE}}', project.slice)
|
|
15
|
+
.replace('{{TASK_FILE}}', project.taskFile || '')
|
|
16
|
+
.replace('{{MONOREPO_STATUS}}', project.isMonorepo ? 'Monorepo project' : 'Single project')
|
|
17
|
+
.replace('{{TIMESTAMP}}', new Date().toLocaleString());
|
|
18
|
+
// Add additional notes if provided
|
|
19
|
+
if (additionalNotes && additionalNotes.trim()) {
|
|
20
|
+
context += '\n\n## Additional Context\n\n' + additionalNotes.trim();
|
|
21
|
+
}
|
|
22
|
+
return context;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Gets the base template for context generation
|
|
26
|
+
*/
|
|
27
|
+
getBaseTemplate() {
|
|
28
|
+
return `# Context for Claude Code
|
|
29
|
+
|
|
30
|
+
## Project Information
|
|
31
|
+
- **Project Name:** {{PROJECT_NAME}}
|
|
32
|
+
- **Template:** {{TEMPLATE}}
|
|
33
|
+
- **Current Slice:** {{SLICE}}
|
|
34
|
+
- **Tasks File:** {{TASK_FILE}}
|
|
35
|
+
- **Type:** {{MONOREPO_STATUS}}
|
|
36
|
+
- **Generated:** {{TIMESTAMP}}
|
|
37
|
+
|
|
38
|
+
## Working Context
|
|
39
|
+
I'm working on the **{{SLICE}}** slice for project **{{PROJECT_NAME}}**. This project uses the **{{TEMPLATE}}** template structure.
|
|
40
|
+
|
|
41
|
+
## Current Objectives
|
|
42
|
+
- Implement the {{SLICE}} functionality according to the slice design
|
|
43
|
+
- Follow existing code patterns and conventions
|
|
44
|
+
- Ensure all tests pass and the build succeeds
|
|
45
|
+
|
|
46
|
+
## Next Steps
|
|
47
|
+
Please help me continue development on this slice, following the project guidelines and maintaining code quality standards.`;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Validates project data for context generation
|
|
51
|
+
*/
|
|
52
|
+
validateProject(project) {
|
|
53
|
+
const errors = [];
|
|
54
|
+
if (!project.name || project.name.trim().length === 0) {
|
|
55
|
+
errors.push('Project name is required');
|
|
56
|
+
}
|
|
57
|
+
if (!project.template || project.template.trim().length === 0) {
|
|
58
|
+
errors.push('Template is required');
|
|
59
|
+
}
|
|
60
|
+
if (!project.slice || project.slice.trim().length === 0) {
|
|
61
|
+
errors.push('Slice is required');
|
|
62
|
+
}
|
|
63
|
+
return errors;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=ContextGenerator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContextGenerator.js","sourceRoot":"","sources":["../../src/services/ContextGenerator.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,OAAO,gBAAgB;IAE3B;;OAEG;IACH,eAAe,CAAC,OAAoB,EAAE,eAAwB;QAC5D,MAAM,QAAQ,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;QAExC,+BAA+B;QAC/B,IAAI,OAAO,GAAG,QAAQ;aACnB,OAAO,CAAC,kBAAkB,EAAE,OAAO,CAAC,IAAI,CAAC;aACzC,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC,QAAQ,CAAC;aACzC,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC,KAAK,CAAC;aACnC,OAAO,CAAC,eAAe,EAAE,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC;aAChD,OAAO,CAAC,qBAAqB,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,gBAAgB,CAAC;aAC1F,OAAO,CAAC,eAAe,EAAE,IAAI,IAAI,EAAE,CAAC,cAAc,EAAE,CAAC,CAAC;QAEzD,mCAAmC;QACnC,IAAI,eAAe,IAAI,eAAe,CAAC,IAAI,EAAE,EAAE,CAAC;YAC9C,OAAO,IAAI,+BAA+B,GAAG,eAAe,CAAC,IAAI,EAAE,CAAC;QACtE,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;OAEG;IACK,eAAe;QACrB,OAAO;;;;;;;;;;;;;;;;;;;4HAmBiH,CAAC;IAC3H,CAAC;IAED;;OAEG;IACH,eAAe,CAAC,OAAoB;QAClC,MAAM,MAAM,GAAa,EAAE,CAAC;QAE5B,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACtD,MAAM,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;QAC1C,CAAC;QAED,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC9D,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;QACtC,CAAC;QAED,IAAI,CAAC,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxD,MAAM,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;QACnC,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { ProjectData } from '../types/project.js';
|
|
2
|
+
import { ContextTemplateEngine } from './ContextTemplateEngine.js';
|
|
3
|
+
/**
|
|
4
|
+
* Service for integrating project data with context generation
|
|
5
|
+
* Transforms ProjectData into formatted context strings
|
|
6
|
+
*/
|
|
7
|
+
export declare class ContextIntegrator {
|
|
8
|
+
private templateProcessor;
|
|
9
|
+
private templateEngine;
|
|
10
|
+
private enableNewEngine;
|
|
11
|
+
constructor(engine: ContextTemplateEngine, enableNewEngine?: boolean);
|
|
12
|
+
/**
|
|
13
|
+
* Generates a complete context string from project data
|
|
14
|
+
* Main integration point - takes project data and returns formatted context
|
|
15
|
+
* @param project Project data from storage
|
|
16
|
+
* @returns Formatted context string ready for display/copying
|
|
17
|
+
*/
|
|
18
|
+
generateContextFromProject(project: ProjectData): Promise<string>;
|
|
19
|
+
/**
|
|
20
|
+
* Generate context using the new template engine
|
|
21
|
+
*/
|
|
22
|
+
private generateWithTemplateEngine;
|
|
23
|
+
/**
|
|
24
|
+
* Generate context using the legacy system
|
|
25
|
+
*/
|
|
26
|
+
private generateWithLegacySystem;
|
|
27
|
+
/**
|
|
28
|
+
* Maps ProjectData structure to EnhancedContextData structure
|
|
29
|
+
* Includes tool detection and additional template features
|
|
30
|
+
* @param project Project data from storage
|
|
31
|
+
* @returns Enhanced context data ready for template engine
|
|
32
|
+
*/
|
|
33
|
+
private mapProjectToEnhancedContext;
|
|
34
|
+
/**
|
|
35
|
+
* Maps ProjectData structure to ContextData structure (legacy)
|
|
36
|
+
* Handles null/undefined values with appropriate defaults
|
|
37
|
+
* @param project Project data from storage
|
|
38
|
+
* @returns Context data ready for template processing
|
|
39
|
+
*/
|
|
40
|
+
private mapProjectToContext;
|
|
41
|
+
/**
|
|
42
|
+
* Applies final formatting to processed context
|
|
43
|
+
* @param content Processed template content
|
|
44
|
+
* @returns Formatted context string
|
|
45
|
+
*/
|
|
46
|
+
private formatOutput;
|
|
47
|
+
/**
|
|
48
|
+
* Generates error context when main generation fails
|
|
49
|
+
* @param project Original project data
|
|
50
|
+
* @param error Error that occurred
|
|
51
|
+
* @returns Fallback context string
|
|
52
|
+
*/
|
|
53
|
+
private getErrorContext;
|
|
54
|
+
/**
|
|
55
|
+
* Validates project data before processing
|
|
56
|
+
* @param project Project data to validate
|
|
57
|
+
* @returns True if project has minimum required fields
|
|
58
|
+
*/
|
|
59
|
+
validateProject(project: ProjectData | null | undefined): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Detect available tools for the project
|
|
62
|
+
* Currently returns placeholder data - can be enhanced for actual detection
|
|
63
|
+
*/
|
|
64
|
+
private detectAvailableTools;
|
|
65
|
+
/**
|
|
66
|
+
* Detect available MCP servers for the project
|
|
67
|
+
* Currently returns placeholder data - can be enhanced for actual detection
|
|
68
|
+
*/
|
|
69
|
+
private detectMCPServers;
|
|
70
|
+
/**
|
|
71
|
+
* Check if new template engine is enabled
|
|
72
|
+
*/
|
|
73
|
+
isNewEngineEnabled(): boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Toggle between new and legacy template systems
|
|
76
|
+
*/
|
|
77
|
+
setNewEngineEnabled(enabled: boolean): void;
|
|
78
|
+
/**
|
|
79
|
+
* Gets the default template string (legacy)
|
|
80
|
+
* @returns Default template string
|
|
81
|
+
*/
|
|
82
|
+
getDefaultTemplate(): string;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=ContextIntegrator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContextIntegrator.d.ts","sourceRoot":"","sources":["../../src/services/ContextIntegrator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAsBnE;;;GAGG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,iBAAiB,CAAoB;IAC7C,OAAO,CAAC,cAAc,CAAwB;IAC9C,OAAO,CAAC,eAAe,CAAU;gBAErB,MAAM,EAAE,qBAAqB,EAAE,eAAe,GAAE,OAAc;IAM1E;;;;;OAKG;IACG,0BAA0B,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC;IAavE;;OAEG;YACW,0BAA0B;IAiBxC;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAWhC;;;;;OAKG;YACW,2BAA2B;IAwBzC;;;;;OAKG;IACH,OAAO,CAAC,mBAAmB;IAgB3B;;;;OAIG;IACH,OAAO,CAAC,YAAY;IAapB;;;;;OAKG;IACH,OAAO,CAAC,eAAe;IAevB;;;;OAIG;IACH,eAAe,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO;IAYjE;;;OAGG;YACW,oBAAoB;IAKlC;;;OAGG;YACW,gBAAgB;IAK9B;;OAEG;IACH,kBAAkB,IAAI,OAAO;IAI7B;;OAEG;IACH,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAI3C;;;OAGG;IACH,kBAAkB,IAAI,MAAM;CAG7B"}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { TemplateProcessor } from './TemplateProcessor.js';
|
|
2
|
+
import { PROMPT_FILE_RELATIVE_PATH, STATEMENTS_FILE_RELATIVE_PATH } from './constants.js';
|
|
3
|
+
/**
|
|
4
|
+
* Default template for context generation
|
|
5
|
+
* Uses markdown format with template variable substitution
|
|
6
|
+
*/
|
|
7
|
+
const DEFAULT_TEMPLATE = `# Project: {{projectName}}
|
|
8
|
+
Template: {{template}}
|
|
9
|
+
Slice: {{slice}}
|
|
10
|
+
Instruction: {{instruction}}
|
|
11
|
+
{{#if isMonorepo}}Monorepo: Yes{{else}}Monorepo: No{{/if}}
|
|
12
|
+
|
|
13
|
+
## Recent Events
|
|
14
|
+
{{recentEvents}}
|
|
15
|
+
|
|
16
|
+
## Additional Context
|
|
17
|
+
{{additionalNotes}}
|
|
18
|
+
|
|
19
|
+
## Current Status
|
|
20
|
+
Ready for {{instruction}} work on {{slice}} slice.`;
|
|
21
|
+
/**
|
|
22
|
+
* Service for integrating project data with context generation
|
|
23
|
+
* Transforms ProjectData into formatted context strings
|
|
24
|
+
*/
|
|
25
|
+
export class ContextIntegrator {
|
|
26
|
+
templateProcessor;
|
|
27
|
+
templateEngine;
|
|
28
|
+
enableNewEngine;
|
|
29
|
+
constructor(engine, enableNewEngine = true) {
|
|
30
|
+
this.templateProcessor = new TemplateProcessor();
|
|
31
|
+
this.templateEngine = engine;
|
|
32
|
+
this.enableNewEngine = enableNewEngine;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Generates a complete context string from project data
|
|
36
|
+
* Main integration point - takes project data and returns formatted context
|
|
37
|
+
* @param project Project data from storage
|
|
38
|
+
* @returns Formatted context string ready for display/copying
|
|
39
|
+
*/
|
|
40
|
+
async generateContextFromProject(project) {
|
|
41
|
+
try {
|
|
42
|
+
if (this.enableNewEngine) {
|
|
43
|
+
return await this.generateWithTemplateEngine(project);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
return this.generateWithLegacySystem(project);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
console.error('Error generating context from project:', error);
|
|
51
|
+
return this.getErrorContext(project, error);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Generate context using the new template engine
|
|
56
|
+
*/
|
|
57
|
+
async generateWithTemplateEngine(project) {
|
|
58
|
+
// Resolve absolute file paths from project root before service calls
|
|
59
|
+
if (project.projectPath) {
|
|
60
|
+
const base = project.projectPath.replace(/\/+$/, '');
|
|
61
|
+
this.templateEngine.updateServicePaths(`${base}/${PROMPT_FILE_RELATIVE_PATH}`, `${base}/${STATEMENTS_FILE_RELATIVE_PATH}`);
|
|
62
|
+
}
|
|
63
|
+
// Map project data to enhanced context data
|
|
64
|
+
const enhancedData = await this.mapProjectToEnhancedContext(project);
|
|
65
|
+
// Generate using template engine
|
|
66
|
+
return await this.templateEngine.generateContext(enhancedData);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Generate context using the legacy system
|
|
70
|
+
*/
|
|
71
|
+
generateWithLegacySystem(project) {
|
|
72
|
+
// Map project data to context data structure
|
|
73
|
+
const contextData = this.mapProjectToContext(project);
|
|
74
|
+
// Process template with context data
|
|
75
|
+
const processedContext = this.templateProcessor.processTemplate(DEFAULT_TEMPLATE, contextData);
|
|
76
|
+
// Apply final formatting
|
|
77
|
+
return this.formatOutput(processedContext);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Maps ProjectData structure to EnhancedContextData structure
|
|
81
|
+
* Includes tool detection and additional template features
|
|
82
|
+
* @param project Project data from storage
|
|
83
|
+
* @returns Enhanced context data ready for template engine
|
|
84
|
+
*/
|
|
85
|
+
async mapProjectToEnhancedContext(project) {
|
|
86
|
+
// Detect available tools and MCP servers
|
|
87
|
+
const availableTools = await this.detectAvailableTools();
|
|
88
|
+
const mcpServers = await this.detectMCPServers();
|
|
89
|
+
return {
|
|
90
|
+
projectName: project.name || 'Unknown Project',
|
|
91
|
+
template: project.template || '',
|
|
92
|
+
slice: project.slice || 'Unknown Slice',
|
|
93
|
+
taskFile: project.taskFile || '',
|
|
94
|
+
instruction: project.instruction || 'implementation',
|
|
95
|
+
developmentPhase: project.developmentPhase || 'WARNING: MISSING DEVELOPMENT PHASE',
|
|
96
|
+
workType: project.workType || 'continue',
|
|
97
|
+
projectDate: project.projectDate || new Date().toISOString().split('T')[0],
|
|
98
|
+
isMonorepo: project.isMonorepo || false,
|
|
99
|
+
recentEvents: project.customData?.recentEvents || '',
|
|
100
|
+
additionalNotes: project.customData?.additionalNotes || '',
|
|
101
|
+
availableTools,
|
|
102
|
+
mcpServers,
|
|
103
|
+
templateVersion: '1.0.0',
|
|
104
|
+
customData: project.customData
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Maps ProjectData structure to ContextData structure (legacy)
|
|
109
|
+
* Handles null/undefined values with appropriate defaults
|
|
110
|
+
* @param project Project data from storage
|
|
111
|
+
* @returns Context data ready for template processing
|
|
112
|
+
*/
|
|
113
|
+
mapProjectToContext(project) {
|
|
114
|
+
return {
|
|
115
|
+
projectName: project.name || 'Unknown Project',
|
|
116
|
+
template: project.template || 'Unknown Template',
|
|
117
|
+
slice: project.slice || 'Unknown Slice',
|
|
118
|
+
taskFile: project.taskFile || '',
|
|
119
|
+
instruction: project.instruction || 'implementation',
|
|
120
|
+
developmentPhase: project.developmentPhase || 'WARNING: MISSING DEVELOPMENT PHASE',
|
|
121
|
+
workType: project.workType || 'continue',
|
|
122
|
+
projectDate: project.projectDate || new Date().toISOString().split('T')[0],
|
|
123
|
+
isMonorepo: project.isMonorepo || false,
|
|
124
|
+
recentEvents: project.customData?.recentEvents || '',
|
|
125
|
+
additionalNotes: project.customData?.additionalNotes || ''
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Applies final formatting to processed context
|
|
130
|
+
* @param content Processed template content
|
|
131
|
+
* @returns Formatted context string
|
|
132
|
+
*/
|
|
133
|
+
formatOutput(content) {
|
|
134
|
+
// Clean up multiple blank lines
|
|
135
|
+
let formatted = content.replace(/\n\s*\n\s*\n/g, '\n\n');
|
|
136
|
+
// Trim leading/trailing whitespace
|
|
137
|
+
formatted = formatted.trim();
|
|
138
|
+
// Ensure consistent line endings
|
|
139
|
+
formatted = formatted.replace(/\r\n/g, '\n');
|
|
140
|
+
return formatted;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Generates error context when main generation fails
|
|
144
|
+
* @param project Original project data
|
|
145
|
+
* @param error Error that occurred
|
|
146
|
+
* @returns Fallback context string
|
|
147
|
+
*/
|
|
148
|
+
getErrorContext(project, error) {
|
|
149
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
150
|
+
return `# Project: ${project.name || 'Unknown'}
|
|
151
|
+
|
|
152
|
+
⚠️ Error generating context: ${message}
|
|
153
|
+
|
|
154
|
+
## Project Details
|
|
155
|
+
- Template: ${project.template || 'Unknown'}
|
|
156
|
+
- Slice: ${project.slice || 'Unknown'}
|
|
157
|
+
- Instruction: ${project.instruction || 'Unknown'}
|
|
158
|
+
- Monorepo: ${project.isMonorepo ? 'Yes' : 'No'}
|
|
159
|
+
|
|
160
|
+
Please check the console for detailed error information.`;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Validates project data before processing
|
|
164
|
+
* @param project Project data to validate
|
|
165
|
+
* @returns True if project has minimum required fields
|
|
166
|
+
*/
|
|
167
|
+
validateProject(project) {
|
|
168
|
+
if (!project) {
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
return Boolean(project.name &&
|
|
172
|
+
project.template &&
|
|
173
|
+
project.slice);
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Detect available tools for the project
|
|
177
|
+
* Currently returns placeholder data - can be enhanced for actual detection
|
|
178
|
+
*/
|
|
179
|
+
async detectAvailableTools() {
|
|
180
|
+
// Placeholder implementation - can be enhanced to actually detect tools
|
|
181
|
+
return ['npm', 'git', 'vscode'];
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Detect available MCP servers for the project
|
|
185
|
+
* Currently returns placeholder data - can be enhanced for actual detection
|
|
186
|
+
*/
|
|
187
|
+
async detectMCPServers() {
|
|
188
|
+
// Placeholder implementation - can be enhanced to detect actual MCP servers
|
|
189
|
+
return ['context7'];
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Check if new template engine is enabled
|
|
193
|
+
*/
|
|
194
|
+
isNewEngineEnabled() {
|
|
195
|
+
return this.enableNewEngine;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Toggle between new and legacy template systems
|
|
199
|
+
*/
|
|
200
|
+
setNewEngineEnabled(enabled) {
|
|
201
|
+
this.enableNewEngine = enabled;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Gets the default template string (legacy)
|
|
205
|
+
* @returns Default template string
|
|
206
|
+
*/
|
|
207
|
+
getDefaultTemplate() {
|
|
208
|
+
return DEFAULT_TEMPLATE;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
//# sourceMappingURL=ContextIntegrator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContextIntegrator.js","sourceRoot":"","sources":["../../src/services/ContextIntegrator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,yBAAyB,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAC;AAE1F;;;GAGG;AACH,MAAM,gBAAgB,GAAG;;;;;;;;;;;;;mDAa0B,CAAC;AAEpD;;;GAGG;AACH,MAAM,OAAO,iBAAiB;IACpB,iBAAiB,CAAoB;IACrC,cAAc,CAAwB;IACtC,eAAe,CAAU;IAEjC,YAAY,MAA6B,EAAE,kBAA2B,IAAI;QACxE,IAAI,CAAC,iBAAiB,GAAG,IAAI,iBAAiB,EAAE,CAAC;QACjD,IAAI,CAA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SAAS;WAChC,OAAO,CAAC,KAAK,IAAI,SAAS;iBACpB,OAAO,CAAC,WAAW,IAAI,SAAS;cACnC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;;yDAEU,CAAC;IACxD,CAAC;IAED;;;;OAIG;IACH,eAAe,CAAC,OAAuC;QACrD,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,OAAO,CACZ,OAAO,CAAC,IAAI;YACZ,OAAO,CAAC,QAAQ;YAChB,OAAO,CAAC,KAAK,CACd,CAAC;IACJ,CAAC;IAED;;;OAGG;IACK,KAAK,CAAC,oBAAoB;QAChC,wEAAwE;QACxE,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;IAClC,CAAC;IAED;;;OAGG;IACK,KAAK,CAAC,gBAAgB;QAC5B,4EAA4E;QAC5E,OAAO,CAAC,UAAU,CAAC,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,kBAAkB;QAChB,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,mBAAmB,CAAC,OAAgB;QAClC,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC;IACjC,CAAC;IAED;;;OAGG;IACH,kBAAkB;QAChB,OAAO,gBAAgB,CAAC;IAC1B,CAAC;CACF"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { EnhancedContextData } from '../types/context.js';
|
|
2
|
+
import type { ContextTemplate } from '../types/sections.js';
|
|
3
|
+
import type { IPromptService, IStatementService } from './interfaces.js';
|
|
4
|
+
import { SectionBuilder } from './SectionBuilder.js';
|
|
5
|
+
/**
|
|
6
|
+
* Main orchestrator for context template generation
|
|
7
|
+
* Coordinates between statement manager, prompt parser, and section builder
|
|
8
|
+
*/
|
|
9
|
+
export declare class ContextTemplateEngine {
|
|
10
|
+
private promptParser;
|
|
11
|
+
private statementManager;
|
|
12
|
+
private sectionBuilder;
|
|
13
|
+
private templateProcessor;
|
|
14
|
+
private enableNewEngine;
|
|
15
|
+
constructor(promptParser: IPromptService, statementManager: IStatementService, sectionBuilder?: SectionBuilder);
|
|
16
|
+
/**
|
|
17
|
+
* Ensure statement manager is initialized
|
|
18
|
+
*/
|
|
19
|
+
private ensureStatementManagerInitialized;
|
|
20
|
+
/**
|
|
21
|
+
* Generate context from enhanced project data
|
|
22
|
+
*/
|
|
23
|
+
generateContext(data: EnhancedContextData): Promise<string>;
|
|
24
|
+
/**
|
|
25
|
+
* Build template configuration based on project data
|
|
26
|
+
*/
|
|
27
|
+
buildTemplate(data: EnhancedContextData): Promise<ContextTemplate>;
|
|
28
|
+
/**
|
|
29
|
+
* Assemble sections into final context string
|
|
30
|
+
*/
|
|
31
|
+
assembleSections(template: ContextTemplate, data: EnhancedContextData): Promise<string>;
|
|
32
|
+
/**
|
|
33
|
+
* Process individual section with template variables
|
|
34
|
+
*/
|
|
35
|
+
private processSection;
|
|
36
|
+
/**
|
|
37
|
+
* Replace template variables in content using enhanced TemplateProcessor
|
|
38
|
+
*/
|
|
39
|
+
private replaceTemplateVariables;
|
|
40
|
+
/**
|
|
41
|
+
* Format final output with cleanup
|
|
42
|
+
*/
|
|
43
|
+
private formatOutput;
|
|
44
|
+
/**
|
|
45
|
+
* Validate input data has required fields
|
|
46
|
+
*/
|
|
47
|
+
private validateInputData;
|
|
48
|
+
/**
|
|
49
|
+
* Generate explicit error context (no silent fallbacks)
|
|
50
|
+
*/
|
|
51
|
+
private getErrorContext;
|
|
52
|
+
/**
|
|
53
|
+
* Check if new template engine is enabled
|
|
54
|
+
*/
|
|
55
|
+
isEnabled(): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Toggle template engine on/off for testing
|
|
58
|
+
*/
|
|
59
|
+
setEnabled(enabled: boolean): void;
|
|
60
|
+
/**
|
|
61
|
+
* Update file paths on internal services (resolves absolute paths from projectPath)
|
|
62
|
+
*/
|
|
63
|
+
updateServicePaths(promptFilePath: string, statementFilePath: string): void;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=ContextTemplateEngine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContextTemplateEngine.d.ts","sourceRoot":"","sources":["../../src/services/ContextTemplateEngine.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,KAAK,EAAkB,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD;;;GAGG;AACH,qBAAa,qBAAqB;IAChC,OAAO,CAAC,YAAY,CAAiB;IACrC,OAAO,CAAC,gBAAgB,CAAoB;IAC5C,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,iBAAiB,CAAoB;IAC7C,OAAO,CAAC,eAAe,CAAiB;gBAGtC,YAAY,EAAE,cAAc,EAC5B,gBAAgB,EAAE,iBAAiB,EACnC,cAAc,CAAC,EAAE,cAAc;IAQjC;;OAEG;YACW,iCAAiC;IAW/C;;OAEG;IACG,eAAe,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC;IAuBjE;;OAEG;IACG,aAAa,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,eAAe,CAAC;IA4FxE;;OAEG;IACG,gBAAgB,CAAC,QAAQ,EAAE,eAAe,EAAE,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC;IAwB7F;;OAEG;YACW,cAAc;IAc5B;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAKhC;;OAEG;IACH,OAAO,CAAC,YAAY;IAapB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAUzB;;OAEG;IACH,OAAO,CAAC,eAAe;IAavB;;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