@codemcp/workflows-core 3.1.16

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 (114) hide show
  1. package/.turbo/turbo-build.log +4 -0
  2. package/LICENSE +674 -0
  3. package/dist/config-manager.d.ts +24 -0
  4. package/dist/config-manager.js +68 -0
  5. package/dist/config-manager.js.map +1 -0
  6. package/dist/conversation-manager.d.ts +97 -0
  7. package/dist/conversation-manager.js +367 -0
  8. package/dist/conversation-manager.js.map +1 -0
  9. package/dist/database.d.ts +73 -0
  10. package/dist/database.js +500 -0
  11. package/dist/database.js.map +1 -0
  12. package/dist/file-detection-manager.d.ts +53 -0
  13. package/dist/file-detection-manager.js +221 -0
  14. package/dist/file-detection-manager.js.map +1 -0
  15. package/dist/git-manager.d.ts +14 -0
  16. package/dist/git-manager.js +59 -0
  17. package/dist/git-manager.js.map +1 -0
  18. package/dist/index.d.ts +19 -0
  19. package/dist/index.js +25 -0
  20. package/dist/index.js.map +1 -0
  21. package/dist/instruction-generator.d.ts +69 -0
  22. package/dist/instruction-generator.js +133 -0
  23. package/dist/instruction-generator.js.map +1 -0
  24. package/dist/interaction-logger.d.ts +37 -0
  25. package/dist/interaction-logger.js +87 -0
  26. package/dist/interaction-logger.js.map +1 -0
  27. package/dist/logger.d.ts +64 -0
  28. package/dist/logger.js +283 -0
  29. package/dist/logger.js.map +1 -0
  30. package/dist/path-validation-utils.d.ts +51 -0
  31. package/dist/path-validation-utils.js +202 -0
  32. package/dist/path-validation-utils.js.map +1 -0
  33. package/dist/plan-manager.d.ts +65 -0
  34. package/dist/plan-manager.js +256 -0
  35. package/dist/plan-manager.js.map +1 -0
  36. package/dist/project-docs-manager.d.ts +119 -0
  37. package/dist/project-docs-manager.js +357 -0
  38. package/dist/project-docs-manager.js.map +1 -0
  39. package/dist/state-machine-loader.d.ts +60 -0
  40. package/dist/state-machine-loader.js +235 -0
  41. package/dist/state-machine-loader.js.map +1 -0
  42. package/dist/state-machine-types.d.ts +58 -0
  43. package/dist/state-machine-types.js +7 -0
  44. package/dist/state-machine-types.js.map +1 -0
  45. package/dist/state-machine.d.ts +52 -0
  46. package/dist/state-machine.js +256 -0
  47. package/dist/state-machine.js.map +1 -0
  48. package/dist/system-prompt-generator.d.ts +17 -0
  49. package/dist/system-prompt-generator.js +113 -0
  50. package/dist/system-prompt-generator.js.map +1 -0
  51. package/dist/template-manager.d.ts +61 -0
  52. package/dist/template-manager.js +229 -0
  53. package/dist/template-manager.js.map +1 -0
  54. package/dist/transition-engine.d.ts +70 -0
  55. package/dist/transition-engine.js +240 -0
  56. package/dist/transition-engine.js.map +1 -0
  57. package/dist/types.d.ts +56 -0
  58. package/dist/types.js +5 -0
  59. package/dist/types.js.map +1 -0
  60. package/dist/workflow-manager.d.ts +89 -0
  61. package/dist/workflow-manager.js +466 -0
  62. package/dist/workflow-manager.js.map +1 -0
  63. package/package.json +27 -0
  64. package/src/config-manager.ts +96 -0
  65. package/src/conversation-manager.ts +492 -0
  66. package/src/database.ts +685 -0
  67. package/src/file-detection-manager.ts +302 -0
  68. package/src/git-manager.ts +64 -0
  69. package/src/index.ts +28 -0
  70. package/src/instruction-generator.ts +210 -0
  71. package/src/interaction-logger.ts +109 -0
  72. package/src/logger.ts +353 -0
  73. package/src/path-validation-utils.ts +261 -0
  74. package/src/plan-manager.ts +323 -0
  75. package/src/project-docs-manager.ts +522 -0
  76. package/src/state-machine-loader.ts +308 -0
  77. package/src/state-machine-types.ts +72 -0
  78. package/src/state-machine.ts +370 -0
  79. package/src/system-prompt-generator.ts +122 -0
  80. package/src/template-manager.ts +321 -0
  81. package/src/transition-engine.ts +386 -0
  82. package/src/types.ts +60 -0
  83. package/src/workflow-manager.ts +601 -0
  84. package/test/unit/conversation-manager.test.ts +179 -0
  85. package/test/unit/custom-workflow-loading.test.ts +174 -0
  86. package/test/unit/directory-linking-and-extensions.test.ts +338 -0
  87. package/test/unit/file-linking-integration.test.ts +256 -0
  88. package/test/unit/git-commit-integration.test.ts +91 -0
  89. package/test/unit/git-manager.test.ts +86 -0
  90. package/test/unit/install-workflow.test.ts +138 -0
  91. package/test/unit/instruction-generator.test.ts +247 -0
  92. package/test/unit/list-workflows-filtering.test.ts +68 -0
  93. package/test/unit/none-template-functionality.test.ts +224 -0
  94. package/test/unit/project-docs-manager.test.ts +337 -0
  95. package/test/unit/state-machine-loader.test.ts +234 -0
  96. package/test/unit/template-manager.test.ts +217 -0
  97. package/test/unit/validate-workflow-name.test.ts +150 -0
  98. package/test/unit/workflow-domain-filtering.test.ts +75 -0
  99. package/test/unit/workflow-enum-generation.test.ts +92 -0
  100. package/test/unit/workflow-manager-enhanced-path-resolution.test.ts +369 -0
  101. package/test/unit/workflow-manager-path-resolution.test.ts +150 -0
  102. package/test/unit/workflow-migration.test.ts +155 -0
  103. package/test/unit/workflow-override-by-name.test.ts +116 -0
  104. package/test/unit/workflow-prioritization.test.ts +38 -0
  105. package/test/unit/workflow-validation.test.ts +303 -0
  106. package/test/utils/e2e-test-setup.ts +453 -0
  107. package/test/utils/run-server-in-dir.sh +27 -0
  108. package/test/utils/temp-files.ts +308 -0
  109. package/test/utils/test-access.ts +79 -0
  110. package/test/utils/test-helpers.ts +286 -0
  111. package/test/utils/test-setup.ts +78 -0
  112. package/tsconfig.build.json +21 -0
  113. package/tsconfig.json +8 -0
  114. package/vitest.config.ts +18 -0
@@ -0,0 +1,221 @@
1
+ /**
2
+ * File Detection Manager
3
+ *
4
+ * Handles pattern-based file discovery and suggestions for existing documentation files.
5
+ * Supports auto-detection of common documentation patterns in projects.
6
+ */
7
+ import { readdir, access } from 'node:fs/promises';
8
+ import { join, basename } from 'node:path';
9
+ import { createLogger } from './logger.js';
10
+ import { PathValidationUtils } from './path-validation-utils.js';
11
+ const logger = createLogger('FileDetectionManager');
12
+ export class FileDetectionManager {
13
+ projectPath;
14
+ constructor(projectPath) {
15
+ this.projectPath = projectPath;
16
+ }
17
+ /**
18
+ * Detect existing documentation files in the project
19
+ */
20
+ async detectDocumentationFiles() {
21
+ logger.debug('Starting documentation file detection', {
22
+ projectPath: this.projectPath,
23
+ });
24
+ const searchLocations = this.getSearchLocations();
25
+ const patterns = PathValidationUtils.getCommonDocumentationPatterns();
26
+ const result = {
27
+ architecture: [],
28
+ requirements: [],
29
+ design: [],
30
+ };
31
+ // Search in each location
32
+ for (const location of searchLocations) {
33
+ try {
34
+ await access(location);
35
+ const files = await this.scanLocation(location);
36
+ // Match files against patterns
37
+ for (const file of files) {
38
+ const matches = this.matchFileToPatterns(file, patterns);
39
+ for (const match of matches) {
40
+ result[match.type].push({
41
+ path: file.path,
42
+ relativePath: file.relativePath,
43
+ type: match.type,
44
+ confidence: match.confidence,
45
+ });
46
+ }
47
+ }
48
+ }
49
+ catch (error) {
50
+ logger.debug('Search location not accessible', {
51
+ location,
52
+ error: error instanceof Error ? error.message : 'Unknown error',
53
+ });
54
+ }
55
+ }
56
+ // Sort by confidence and remove duplicates
57
+ result.architecture = this.sortAndDeduplicate(result.architecture);
58
+ result.requirements = this.sortAndDeduplicate(result.requirements);
59
+ result.design = this.sortAndDeduplicate(result.design);
60
+ logger.info('Documentation file detection completed', {
61
+ found: {
62
+ architecture: result.architecture.length,
63
+ requirements: result.requirements.length,
64
+ design: result.design.length,
65
+ },
66
+ });
67
+ return result;
68
+ }
69
+ /**
70
+ * Get search locations for documentation files
71
+ */
72
+ getSearchLocations() {
73
+ return [
74
+ this.projectPath, // Project root
75
+ join(this.projectPath, 'docs'), // docs/ folder
76
+ join(this.projectPath, 'doc'), // doc/ folder
77
+ join(this.projectPath, '.vibe', 'docs'), // .vibe/docs/ folder
78
+ join(this.projectPath, 'documentation'), // documentation/ folder
79
+ ];
80
+ }
81
+ /**
82
+ * Scan a location for files
83
+ */
84
+ async scanLocation(location) {
85
+ try {
86
+ const entries = await readdir(location, { withFileTypes: true });
87
+ const files = [];
88
+ for (const entry of entries) {
89
+ if (entry.isFile()) {
90
+ const fullPath = join(location, entry.name);
91
+ const relativePath = fullPath.replace(this.projectPath + '/', '');
92
+ files.push({
93
+ path: fullPath,
94
+ relativePath,
95
+ });
96
+ }
97
+ }
98
+ return files;
99
+ }
100
+ catch (error) {
101
+ logger.debug('Failed to scan location', {
102
+ location,
103
+ error: error instanceof Error ? error.message : 'Unknown error',
104
+ });
105
+ return [];
106
+ }
107
+ }
108
+ /**
109
+ * Match a file against documentation patterns
110
+ */
111
+ matchFileToPatterns(file, patterns) {
112
+ const fileName = basename(file.path).toLowerCase();
113
+ const relativePath = file.relativePath.toLowerCase();
114
+ const matches = [];
115
+ // Check architecture patterns
116
+ if (this.matchesPatterns(fileName, relativePath, patterns.architecture)) {
117
+ const confidence = this.getConfidence(fileName, 'architecture');
118
+ matches.push({ type: 'architecture', confidence });
119
+ }
120
+ // Check requirements patterns
121
+ if (this.matchesPatterns(fileName, relativePath, patterns.requirements)) {
122
+ const confidence = this.getConfidence(fileName, 'requirements');
123
+ matches.push({ type: 'requirements', confidence });
124
+ }
125
+ // Check design patterns
126
+ if (this.matchesPatterns(fileName, relativePath, patterns.design)) {
127
+ const confidence = this.getConfidence(fileName, 'design');
128
+ matches.push({ type: 'design', confidence });
129
+ }
130
+ return matches;
131
+ }
132
+ /**
133
+ * Check if file matches any of the patterns
134
+ */
135
+ matchesPatterns(fileName, relativePath, patterns) {
136
+ return patterns.some(pattern => {
137
+ const normalizedPattern = pattern.toLowerCase();
138
+ // Exact filename match
139
+ if (fileName === normalizedPattern) {
140
+ return true;
141
+ }
142
+ // Relative path match
143
+ if (relativePath === normalizedPattern) {
144
+ return true;
145
+ }
146
+ // Pattern matching with wildcards
147
+ if (normalizedPattern.includes('*')) {
148
+ const regex = new RegExp(normalizedPattern.replace(/\*/g, '.*'));
149
+ return regex.test(fileName) || regex.test(relativePath);
150
+ }
151
+ return false;
152
+ });
153
+ }
154
+ /**
155
+ * Determine confidence level for a match
156
+ */
157
+ getConfidence(fileName, type) {
158
+ // High confidence for exact type matches
159
+ if (fileName.includes(type.toLowerCase())) {
160
+ return 'high';
161
+ }
162
+ // Medium confidence for README files (could contain any type)
163
+ if (fileName.includes('readme')) {
164
+ return 'medium';
165
+ }
166
+ // Low confidence for other matches
167
+ return 'low';
168
+ }
169
+ /**
170
+ * Sort by confidence and remove duplicates
171
+ */
172
+ sortAndDeduplicate(files) {
173
+ // Remove duplicates by path
174
+ const unique = files.filter((file, index, array) => array.findIndex(f => f.path === file.path) === index);
175
+ // Sort by confidence (high first) and then by path length (shorter first)
176
+ return unique.sort((a, b) => {
177
+ const confidenceOrder = { high: 0, medium: 1, low: 2 };
178
+ const confidenceDiff = confidenceOrder[a.confidence] - confidenceOrder[b.confidence];
179
+ if (confidenceDiff !== 0) {
180
+ return confidenceDiff;
181
+ }
182
+ return a.relativePath.length - b.relativePath.length;
183
+ });
184
+ }
185
+ /**
186
+ * Format file suggestions for LLM responses
187
+ */
188
+ formatSuggestions(detectionResult) {
189
+ const suggestions = [];
190
+ if (detectionResult.architecture.length > 0) {
191
+ suggestions.push(`**Architecture files found:**`);
192
+ for (const file of detectionResult.architecture.slice(0, 3)) {
193
+ suggestions.push(` - ${file.relativePath} (${file.confidence} confidence)`);
194
+ }
195
+ }
196
+ if (detectionResult.requirements.length > 0) {
197
+ suggestions.push(`**Requirements files found:**`);
198
+ for (const file of detectionResult.requirements.slice(0, 3)) {
199
+ suggestions.push(` - ${file.relativePath} (${file.confidence} confidence)`);
200
+ }
201
+ }
202
+ if (detectionResult.design.length > 0) {
203
+ suggestions.push(`**Design files found:**`);
204
+ for (const file of detectionResult.design.slice(0, 3)) {
205
+ suggestions.push(` - ${file.relativePath} (${file.confidence} confidence)`);
206
+ }
207
+ }
208
+ if (suggestions.length === 0) {
209
+ return 'No existing documentation files detected.';
210
+ }
211
+ return [
212
+ 'Existing documentation files detected:',
213
+ '',
214
+ ...suggestions,
215
+ '',
216
+ 'You can use these files with `setup_project_docs` by providing the file paths instead of template names.',
217
+ 'Example: `setup_project_docs({ architecture: "README.md", requirements: "docs/requirements.md", design: "freestyle" })`',
218
+ ].join('\n');
219
+ }
220
+ }
221
+ //# sourceMappingURL=file-detection-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-detection-manager.js","sourceRoot":"","sources":["../src/file-detection-manager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEjE,MAAM,MAAM,GAAG,YAAY,CAAC,sBAAsB,CAAC,CAAC;AAepD,MAAM,OAAO,oBAAoB;IACvB,WAAW,CAAS;IAE5B,YAAY,WAAmB;QAC7B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,wBAAwB;QAC5B,MAAM,CAAC,KAAK,CAAC,uCAAuC,EAAE;YACpD,WAAW,EAAE,IAAI,CAAC,WAAW;SAC9B,CAAC,CAAC;QAEH,MAAM,eAAe,GAAG,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAClD,MAAM,QAAQ,GAAG,mBAAmB,CAAC,8BAA8B,EAAE,CAAC;QAEtE,MAAM,MAAM,GAAwB;YAClC,YAAY,EAAE,EAAE;YAChB,YAAY,EAAE,EAAE;YAChB,MAAM,EAAE,EAAE;SACX,CAAC;QAEF,0BAA0B;QAC1B,KAAK,MAAM,QAAQ,IAAI,eAAe,EAAE,CAAC;YACvC,IAAI,CAAC;gBACH,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAC;gBACvB,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;gBAEhD,+BAA+B;gBAC/B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;oBACzB,MAAM,OAA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CAAC;QAED,IAAI,eAAe,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtC,WAAW,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;YAC5C,KAAK,MAAM,IAAI,IAAI,eAAe,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;gBACtD,WAAW,CAAC,IAAI,CACd,OAAO,IAAI,CAAC,YAAY,KAAK,IAAI,CAAC,UAAU,cAAc,CAC3D,CAAC;YACJ,CAAC;QACH,CAAC;QAED,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC7B,OAAO,2CAA2C,CAAC;QACrD,CAAC;QAED,OAAO;YACL,wCAAwC;YACxC,EAAE;YACF,GAAG,WAAW;YACd,EAAE;YACF,0GAA0G;YAC1G,yHAAyH;SAC1H,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACf,CAAC;CACF"}
@@ -0,0 +1,14 @@
1
+ export declare class GitManager {
2
+ /**
3
+ * Check if a directory is a git repository
4
+ */
5
+ static isGitRepository(projectPath: string): boolean;
6
+ /**
7
+ * Get the current git branch for a project
8
+ */
9
+ static getCurrentBranch(projectPath: string): string;
10
+ /**
11
+ * Get the current HEAD commit hash (for tracking start of development)
12
+ */
13
+ static getCurrentCommitHash(projectPath: string): string | null;
14
+ }
@@ -0,0 +1,59 @@
1
+ import { execSync } from 'node:child_process';
2
+ import { existsSync } from 'node:fs';
3
+ import { createLogger } from './logger.js';
4
+ const logger = createLogger('GitManager');
5
+ export class GitManager {
6
+ /**
7
+ * Check if a directory is a git repository
8
+ */
9
+ static isGitRepository(projectPath) {
10
+ return existsSync(`${projectPath}/.git`);
11
+ }
12
+ /**
13
+ * Get the current git branch for a project
14
+ */
15
+ static getCurrentBranch(projectPath) {
16
+ try {
17
+ if (!this.isGitRepository(projectPath)) {
18
+ logger.debug('Not a git repository, using "default" as branch name', {
19
+ projectPath,
20
+ });
21
+ return 'default';
22
+ }
23
+ const branch = execSync('git rev-parse --abbrev-ref HEAD', {
24
+ cwd: projectPath,
25
+ encoding: 'utf-8',
26
+ stdio: ['ignore', 'pipe', 'ignore'],
27
+ }).trim();
28
+ logger.debug('Detected git branch', { projectPath, branch });
29
+ return branch;
30
+ }
31
+ catch (_error) {
32
+ logger.debug('Failed to get git branch, using "default" as branch name', {
33
+ projectPath,
34
+ });
35
+ return 'default';
36
+ }
37
+ }
38
+ /**
39
+ * Get the current HEAD commit hash (for tracking start of development)
40
+ */
41
+ static getCurrentCommitHash(projectPath) {
42
+ try {
43
+ if (!this.isGitRepository(projectPath)) {
44
+ return null;
45
+ }
46
+ const hash = execSync('git rev-parse HEAD', {
47
+ cwd: projectPath,
48
+ encoding: 'utf-8',
49
+ stdio: ['ignore', 'pipe', 'ignore'],
50
+ }).trim();
51
+ return hash;
52
+ }
53
+ catch (error) {
54
+ logger.debug('Failed to get current commit hash', { projectPath, error });
55
+ return null;
56
+ }
57
+ }
58
+ }
59
+ //# sourceMappingURL=git-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git-manager.js","sourceRoot":"","sources":["../src/git-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,MAAM,MAAM,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC;AAE1C,MAAM,OAAO,UAAU;IACrB;;OAEG;IACH,MAAM,CAAC,eAAe,CAAC,WAAmB;QACxC,OAAO,UAAU,CAAC,GAAG,WAAW,OAAO,CAAC,CAAC;IAC3C,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,gBAAgB,CAAC,WAAmB;QACzC,IAAI,CAAC;YACH,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,EAAE,CAAC;gBACvC,MAAM,CAAC,KAAK,CAAC,sDAAsD,EAAE;oBACnE,WAAW;iBACZ,CAAC,CAAC;gBACH,OAAO,SAAS,CAAC;YACnB,CAAC;YAED,MAAM,MAAM,GAAG,QAAQ,CAAC,iCAAiC,EAAE;gBACzD,GAAG,EAAE,WAAW;gBAChB,QAAQ,EAAE,OAAO;gBACjB,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC;aACpC,CAAC,CAAC,IAAI,EAAE,CAAC;YAEV,MAAM,CAAC,KAAK,CAAC,qBAAqB,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,CAAC;YAC7D,OAAO,MAAM,CAAC;QAChB,CAAC;QAAC,OAAO,MAAM,EAAE,CAAC;YAChB,MAAM,CAAC,KAAK,CAAC,0DAA0D,EAAE;gBACvE,WAAW;aACZ,CAAC,CAAC;YACH,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,oBAAoB,CAAC,WAAmB;QAC7C,IAAI,CAAC;YACH,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,EAAE,CAAC;gBACvC,OAAO,IAAI,CAAC;YACd,CAAC;YAED,MAAM,IAAI,GAAG,QAAQ,CAAC,oBAAoB,EAAE;gBAC1C,GAAG,EAAE,WAAW;gBAChB,QAAQ,EAAE,OAAO;gBACjB,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC;aACpC,CAAC,CAAC,IAAI,EAAE,CAAC;YAEV,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CAAC,mCAAmC,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,CAAC;YAC1E,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,19 @@
1
+ export * from './types.js';
2
+ export * from './state-machine-types.js';
3
+ export * from './state-machine.js';
4
+ export * from './state-machine-loader.js';
5
+ export * from './workflow-manager.js';
6
+ export * from './transition-engine.js';
7
+ export * from './database.js';
8
+ export * from './conversation-manager.js';
9
+ export * from './plan-manager.js';
10
+ export * from './template-manager.js';
11
+ export * from './project-docs-manager.js';
12
+ export * from './file-detection-manager.js';
13
+ export * from './config-manager.js';
14
+ export * from './git-manager.js';
15
+ export * from './logger.js';
16
+ export * from './interaction-logger.js';
17
+ export * from './instruction-generator.js';
18
+ export * from './system-prompt-generator.js';
19
+ export * from './path-validation-utils.js';
package/dist/index.js ADDED
@@ -0,0 +1,25 @@
1
+ // Core types and interfaces
2
+ export * from './types.js';
3
+ export * from './state-machine-types.js';
4
+ // State machine and workflow management
5
+ export * from './state-machine.js';
6
+ export * from './state-machine-loader.js';
7
+ export * from './workflow-manager.js';
8
+ export * from './transition-engine.js';
9
+ // Data management
10
+ export * from './database.js';
11
+ export * from './conversation-manager.js';
12
+ // Project and plan management
13
+ export * from './plan-manager.js';
14
+ export * from './template-manager.js';
15
+ export * from './project-docs-manager.js';
16
+ export * from './file-detection-manager.js';
17
+ export * from './config-manager.js';
18
+ export * from './git-manager.js';
19
+ // Utilities and generators
20
+ export * from './logger.js';
21
+ export * from './interaction-logger.js';
22
+ export * from './instruction-generator.js';
23
+ export * from './system-prompt-generator.js';
24
+ export * from './path-validation-utils.js';
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,0BAA0B,CAAC;AAEzC,wCAAwC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AAEvC,kBAAkB;AAClB,cAAc,eAAe,CAAC;AAC9B,cAAc,2BAA2B,CAAC;AAE1C,8BAA8B;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AAEjC,2BAA2B;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Instruction Generator
3
+ *
4
+ * Creates phase-specific guidance for the LLM based on current conversation state.
5
+ * Customizes instructions based on project context and development phase.
6
+ * Supports custom state machine definitions for dynamic instruction generation.
7
+ * Handles variable substitution for project artifact references.
8
+ */
9
+ import type { ConversationContext } from './types.js';
10
+ import { PlanManager } from './plan-manager.js';
11
+ import type { YamlStateMachine } from './state-machine-types.js';
12
+ export interface InstructionContext {
13
+ phase: string;
14
+ conversationContext: ConversationContext;
15
+ transitionReason: string;
16
+ isModeled: boolean;
17
+ planFileExists: boolean;
18
+ }
19
+ export interface GeneratedInstructions {
20
+ instructions: string;
21
+ planFileGuidance: string;
22
+ metadata: {
23
+ phase: string;
24
+ planFilePath: string;
25
+ transitionReason: string;
26
+ isModeled: boolean;
27
+ };
28
+ }
29
+ export declare class InstructionGenerator {
30
+ private planManager;
31
+ private projectDocsManager;
32
+ private stateMachine;
33
+ constructor(planManager: PlanManager);
34
+ /**
35
+ * Set the state machine definition for dynamic instruction generation
36
+ */
37
+ setStateMachine(stateMachine: YamlStateMachine): void;
38
+ /**
39
+ * Generate comprehensive instructions for the LLM
40
+ */
41
+ generateInstructions(baseInstructions: string, context: InstructionContext): Promise<GeneratedInstructions>;
42
+ /**
43
+ * Apply variable substitution to instructions
44
+ * Replaces project artifact variables with actual file paths
45
+ */
46
+ private applyVariableSubstitution;
47
+ /**
48
+ * Escape special regex characters in variable names
49
+ */
50
+ private escapeRegExp;
51
+ /**
52
+ * Enhance base instructions with context-specific information
53
+ */
54
+ private enhanceInstructions;
55
+ /**
56
+ * Get phase-specific contextual information based on state machine
57
+ */
58
+ private getPhaseSpecificContext;
59
+ /**
60
+ * Get default phase context for standard phases
61
+ /**
62
+ * Get phase-specific reminders and best practices based on state machine
63
+ */
64
+ private getPhaseReminders;
65
+ /**
66
+ * Capitalize phase name for display
67
+ */
68
+ private capitalizePhase;
69
+ }
@@ -0,0 +1,133 @@
1
+ /**
2
+ * Instruction Generator
3
+ *
4
+ * Creates phase-specific guidance for the LLM based on current conversation state.
5
+ * Customizes instructions based on project context and development phase.
6
+ * Supports custom state machine definitions for dynamic instruction generation.
7
+ * Handles variable substitution for project artifact references.
8
+ */
9
+ import { ProjectDocsManager } from './project-docs-manager.js';
10
+ export class InstructionGenerator {
11
+ planManager;
12
+ projectDocsManager;
13
+ stateMachine = null;
14
+ constructor(planManager) {
15
+ this.planManager = planManager;
16
+ this.projectDocsManager = new ProjectDocsManager();
17
+ }
18
+ /**
19
+ * Set the state machine definition for dynamic instruction generation
20
+ */
21
+ setStateMachine(stateMachine) {
22
+ this.stateMachine = stateMachine;
23
+ }
24
+ /**
25
+ * Generate comprehensive instructions for the LLM
26
+ */
27
+ async generateInstructions(baseInstructions, context) {
28
+ // Apply variable substitution to base instructions
29
+ const substitutedInstructions = this.applyVariableSubstitution(baseInstructions, context.conversationContext.projectPath);
30
+ // Get plan file guidance
31
+ const planFileGuidance = this.planManager.generatePlanFileGuidance(context.phase);
32
+ // Enhance base instructions with context-specific guidance
33
+ const enhancedInstructions = await this.enhanceInstructions(substitutedInstructions, context, planFileGuidance);
34
+ return {
35
+ instructions: enhancedInstructions,
36
+ planFileGuidance,
37
+ metadata: {
38
+ phase: context.phase,
39
+ planFilePath: context.conversationContext.planFilePath,
40
+ transitionReason: context.transitionReason,
41
+ isModeled: context.isModeled,
42
+ },
43
+ };
44
+ }
45
+ /**
46
+ * Apply variable substitution to instructions
47
+ * Replaces project artifact variables with actual file paths
48
+ */
49
+ applyVariableSubstitution(instructions, projectPath) {
50
+ const substitutions = this.projectDocsManager.getVariableSubstitutions(projectPath);
51
+ let result = instructions;
52
+ for (const [variable, value] of Object.entries(substitutions)) {
53
+ // Use global replace to handle multiple occurrences
54
+ result = result.replace(new RegExp(this.escapeRegExp(variable), 'g'), value);
55
+ }
56
+ return result;
57
+ }
58
+ /**
59
+ * Escape special regex characters in variable names
60
+ */
61
+ escapeRegExp(string) {
62
+ return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
63
+ }
64
+ /**
65
+ * Enhance base instructions with context-specific information
66
+ */
67
+ async enhanceInstructions(baseInstructions, context, _planFileGuidance) {
68
+ const { phase, conversationContext, transitionReason, isModeled, planFileExists, } = context;
69
+ // Build plan-file-referential instructions
70
+ let enhanced = `Check your plan file at \`${conversationContext.planFilePath}\` and focus on the "${this.capitalizePhase(phase)}" section.
71
+
72
+ ${baseInstructions}
73
+
74
+ **Plan File Guidance:**
75
+ - Work on the tasks listed in the ${this.capitalizePhase(phase)} section
76
+ - Mark completed tasks with [x] as you finish them
77
+ - Add new tasks as they are identified during your work with the user
78
+ - Update the "Key Decisions" section with important choices made
79
+ - Add relevant notes to help maintain context`;
80
+ // Add project context
81
+ enhanced += `\n\n**Project Context:**
82
+ - Project: ${conversationContext.projectPath}
83
+ - Branch: ${conversationContext.gitBranch}
84
+ - Current Phase: ${phase}`;
85
+ // Add transition context if this is a modeled transition
86
+ if (isModeled && transitionReason) {
87
+ enhanced += `\n\n**Phase Context:**
88
+ - ${transitionReason}`;
89
+ }
90
+ // Add plan file creation note if needed
91
+ if (!planFileExists) {
92
+ enhanced +=
93
+ '\n\n**Note**: Plan file will be created when you first update it.';
94
+ }
95
+ return enhanced;
96
+ }
97
+ /**
98
+ * Get phase-specific contextual information based on state machine
99
+ */
100
+ getPhaseSpecificContext(phase) {
101
+ if (this.stateMachine) {
102
+ const phaseDefinition = this.stateMachine.states[phase];
103
+ if (phaseDefinition) {
104
+ return `**Context**: ${phaseDefinition.description}`;
105
+ }
106
+ }
107
+ throw new Error(`State machine not set or unknown phase: ${phase}. This should not happen as state machine is always loaded.`);
108
+ }
109
+ /**
110
+ * Get default phase context for standard phases
111
+ /**
112
+ * Get phase-specific reminders and best practices based on state machine
113
+ */
114
+ getPhaseReminders(phase) {
115
+ if (this.stateMachine) {
116
+ const phaseDefinition = this.stateMachine.states[phase];
117
+ if (phaseDefinition) {
118
+ return `**Remember**: \n- Focus on: ${phaseDefinition.description}\n- Update plan file with ${phase} progress\n- Mark completed tasks with [x]\n- Stay focused on current phase objectives`;
119
+ }
120
+ }
121
+ throw new Error(`State machine not set or unknown phase: ${phase}. This should not happen as state machine is always loaded.`);
122
+ }
123
+ /**
124
+ * Capitalize phase name for display
125
+ */
126
+ capitalizePhase(phase) {
127
+ return phase
128
+ .split('_')
129
+ .map(word => word.charAt(0).toUpperCase() + word.slice(1))
130
+ .join(' ');
131
+ }
132
+ }
133
+ //# sourceMappingURL=instruction-generator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instruction-generator.js","sourceRoot":"","sources":["../src/instruction-generator.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAsB/D,MAAM,OAAO,oBAAoB;IACvB,WAAW,CAAc;IACzB,kBAAkB,CAAqB;IACvC,YAAY,GAA4B,IAAI,CAAC;IAErD,YAAY,WAAwB;QAClC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,kBAAkB,GAAG,IAAI,kBAAkB,EAAE,CAAC;IACrD,CAAC;IAED;;OAEG;IACH,eAAe,CAAC,YAA8B;QAC5C,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,oBAAoB,CACxB,gBAAwB,EACxB,OAA2B;QAE3B,mDAAmD;QACnD,MAAM,uBAAuB,GAAG,IAAI,CAAC,yBAAyB,CAC5D,gBAAgB,EAChB,OAAO,C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AAC;YAC9L,CAAC;QACH,CAAC;QAED,MAAM,IAAI,KAAK,CACb,2CAA2C,KAAK,6DAA6D,CAC9G,CAAC;IACJ,CAAC;IAED;;OAEG;IACK,eAAe,CAAC,KAAa;QACnC,OAAO,KAAK;aACT,KAAK,CAAC,GAAG,CAAC;aACV,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;aACzD,IAAI,CAAC,GAAG,CAAC,CAAC;IACf,CAAC;CACF"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Interaction Logger module
3
+ *
4
+ * Handles logging of tool interactions to the database for auditing and debugging.
5
+ */
6
+ import { Database } from './database.js';
7
+ import type { InteractionLog } from './types.js';
8
+ /**
9
+ * Handles logging of tool interactions to the database
10
+ */
11
+ export declare class InteractionLogger {
12
+ private database;
13
+ /**
14
+ * Create a new InteractionLogger
15
+ *
16
+ * @param database - Database instance to use for logging
17
+ */
18
+ constructor(database: Database);
19
+ /**
20
+ * Log an interaction with a tool
21
+ *
22
+ * @param conversationId - ID of the conversation
23
+ * @param toolName - Name of the tool that was called
24
+ * @param inputParams - Input parameters to the tool (will be stringified)
25
+ * @param responseData - Response data from the tool (will be stringified)
26
+ * @param currentPhase - Current development phase
27
+ * @returns Promise that resolves when the log is saved
28
+ */
29
+ logInteraction(conversationId: string, toolName: string, inputParams: unknown, responseData: unknown, currentPhase: string): Promise<void>;
30
+ /**
31
+ * Get all interactions for a specific conversation
32
+ *
33
+ * @param conversationId - ID of the conversation to get logs for
34
+ * @returns Promise that resolves to an array of interaction logs
35
+ */
36
+ getInteractionsByConversationId(conversationId: string): Promise<InteractionLog[]>;
37
+ }