@codebakers/mcp 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/INSTALL.md +221 -0
  2. package/LICENSE +21 -0
  3. package/README.md +412 -0
  4. package/dist/cli.d.ts +9 -0
  5. package/dist/cli.d.ts.map +1 -0
  6. package/dist/cli.js +236 -0
  7. package/dist/cli.js.map +1 -0
  8. package/dist/index.d.ts +12 -0
  9. package/dist/index.d.ts.map +1 -0
  10. package/dist/index.js +526 -0
  11. package/dist/index.js.map +1 -0
  12. package/dist/tools/analyze-mockups.d.ts +18 -0
  13. package/dist/tools/analyze-mockups.d.ts.map +1 -0
  14. package/dist/tools/analyze-mockups.js +497 -0
  15. package/dist/tools/analyze-mockups.js.map +1 -0
  16. package/dist/tools/autonomous-build.d.ts +19 -0
  17. package/dist/tools/autonomous-build.d.ts.map +1 -0
  18. package/dist/tools/autonomous-build.js +287 -0
  19. package/dist/tools/autonomous-build.js.map +1 -0
  20. package/dist/tools/check-gate.d.ts +21 -0
  21. package/dist/tools/check-gate.d.ts.map +1 -0
  22. package/dist/tools/check-gate.js +446 -0
  23. package/dist/tools/check-gate.js.map +1 -0
  24. package/dist/tools/check-scope.d.ts +22 -0
  25. package/dist/tools/check-scope.d.ts.map +1 -0
  26. package/dist/tools/check-scope.js +251 -0
  27. package/dist/tools/check-scope.js.map +1 -0
  28. package/dist/tools/deploy-vercel.d.ts +18 -0
  29. package/dist/tools/deploy-vercel.d.ts.map +1 -0
  30. package/dist/tools/deploy-vercel.js +178 -0
  31. package/dist/tools/deploy-vercel.js.map +1 -0
  32. package/dist/tools/diagnose-error.d.ts +20 -0
  33. package/dist/tools/diagnose-error.d.ts.map +1 -0
  34. package/dist/tools/diagnose-error.js +351 -0
  35. package/dist/tools/diagnose-error.js.map +1 -0
  36. package/dist/tools/enforce-feature.d.ts +25 -0
  37. package/dist/tools/enforce-feature.d.ts.map +1 -0
  38. package/dist/tools/enforce-feature.js +387 -0
  39. package/dist/tools/enforce-feature.js.map +1 -0
  40. package/dist/tools/execute-atomic-unit.d.ts +23 -0
  41. package/dist/tools/execute-atomic-unit.d.ts.map +1 -0
  42. package/dist/tools/execute-atomic-unit.js +107 -0
  43. package/dist/tools/execute-atomic-unit.js.map +1 -0
  44. package/dist/tools/fix-commit.d.ts +23 -0
  45. package/dist/tools/fix-commit.d.ts.map +1 -0
  46. package/dist/tools/fix-commit.js +213 -0
  47. package/dist/tools/fix-commit.js.map +1 -0
  48. package/dist/tools/fix-mockups.d.ts +21 -0
  49. package/dist/tools/fix-mockups.d.ts.map +1 -0
  50. package/dist/tools/fix-mockups.js +595 -0
  51. package/dist/tools/fix-mockups.js.map +1 -0
  52. package/dist/tools/generate-api-route.d.ts +18 -0
  53. package/dist/tools/generate-api-route.d.ts.map +1 -0
  54. package/dist/tools/generate-api-route.js +212 -0
  55. package/dist/tools/generate-api-route.js.map +1 -0
  56. package/dist/tools/generate-chatbot.d.ts +20 -0
  57. package/dist/tools/generate-chatbot.d.ts.map +1 -0
  58. package/dist/tools/generate-chatbot.js +555 -0
  59. package/dist/tools/generate-chatbot.js.map +1 -0
  60. package/dist/tools/generate-component.d.ts +18 -0
  61. package/dist/tools/generate-component.d.ts.map +1 -0
  62. package/dist/tools/generate-component.js +159 -0
  63. package/dist/tools/generate-component.js.map +1 -0
  64. package/dist/tools/generate-docs.d.ts +21 -0
  65. package/dist/tools/generate-docs.d.ts.map +1 -0
  66. package/dist/tools/generate-docs.js +782 -0
  67. package/dist/tools/generate-docs.js.map +1 -0
  68. package/dist/tools/generate-e2e-tests.d.ts +12 -0
  69. package/dist/tools/generate-e2e-tests.d.ts.map +1 -0
  70. package/dist/tools/generate-e2e-tests.js +37 -0
  71. package/dist/tools/generate-e2e-tests.js.map +1 -0
  72. package/dist/tools/generate-migration.d.ts +21 -0
  73. package/dist/tools/generate-migration.d.ts.map +1 -0
  74. package/dist/tools/generate-migration.js +94 -0
  75. package/dist/tools/generate-migration.js.map +1 -0
  76. package/dist/tools/generate-schema.d.ts +18 -0
  77. package/dist/tools/generate-schema.d.ts.map +1 -0
  78. package/dist/tools/generate-schema.js +422 -0
  79. package/dist/tools/generate-schema.js.map +1 -0
  80. package/dist/tools/generate-spec.d.ts +18 -0
  81. package/dist/tools/generate-spec.d.ts.map +1 -0
  82. package/dist/tools/generate-spec.js +446 -0
  83. package/dist/tools/generate-spec.js.map +1 -0
  84. package/dist/tools/generate-store-contracts.d.ts +17 -0
  85. package/dist/tools/generate-store-contracts.d.ts.map +1 -0
  86. package/dist/tools/generate-store-contracts.js +356 -0
  87. package/dist/tools/generate-store-contracts.js.map +1 -0
  88. package/dist/tools/generate-store.d.ts +16 -0
  89. package/dist/tools/generate-store.d.ts.map +1 -0
  90. package/dist/tools/generate-store.js +166 -0
  91. package/dist/tools/generate-store.js.map +1 -0
  92. package/dist/tools/generate-unit-tests.d.ts +14 -0
  93. package/dist/tools/generate-unit-tests.d.ts.map +1 -0
  94. package/dist/tools/generate-unit-tests.js +85 -0
  95. package/dist/tools/generate-unit-tests.js.map +1 -0
  96. package/dist/tools/get-context.d.ts +35 -0
  97. package/dist/tools/get-context.d.ts.map +1 -0
  98. package/dist/tools/get-context.js +367 -0
  99. package/dist/tools/get-context.js.map +1 -0
  100. package/dist/tools/init-session.d.ts +22 -0
  101. package/dist/tools/init-session.d.ts.map +1 -0
  102. package/dist/tools/init-session.js +232 -0
  103. package/dist/tools/init-session.js.map +1 -0
  104. package/dist/tools/map-dependencies.d.ts +25 -0
  105. package/dist/tools/map-dependencies.d.ts.map +1 -0
  106. package/dist/tools/map-dependencies.js +480 -0
  107. package/dist/tools/map-dependencies.js.map +1 -0
  108. package/dist/tools/optimize-performance.d.ts +18 -0
  109. package/dist/tools/optimize-performance.d.ts.map +1 -0
  110. package/dist/tools/optimize-performance.js +285 -0
  111. package/dist/tools/optimize-performance.js.map +1 -0
  112. package/dist/tools/run-interview.d.ts +23 -0
  113. package/dist/tools/run-interview.d.ts.map +1 -0
  114. package/dist/tools/run-interview.js +371 -0
  115. package/dist/tools/run-interview.js.map +1 -0
  116. package/dist/tools/run-tests.d.ts +12 -0
  117. package/dist/tools/run-tests.d.ts.map +1 -0
  118. package/dist/tools/run-tests.js +30 -0
  119. package/dist/tools/run-tests.js.map +1 -0
  120. package/dist/tools/scan-security.d.ts +19 -0
  121. package/dist/tools/scan-security.d.ts.map +1 -0
  122. package/dist/tools/scan-security.js +358 -0
  123. package/dist/tools/scan-security.js.map +1 -0
  124. package/dist/tools/validate-accessibility.d.ts +18 -0
  125. package/dist/tools/validate-accessibility.d.ts.map +1 -0
  126. package/dist/tools/validate-accessibility.js +251 -0
  127. package/dist/tools/validate-accessibility.js.map +1 -0
  128. package/dist/tools/validate-mockups.d.ts +21 -0
  129. package/dist/tools/validate-mockups.d.ts.map +1 -0
  130. package/dist/tools/validate-mockups.js +433 -0
  131. package/dist/tools/validate-mockups.js.map +1 -0
  132. package/dist/tools/verify-completeness.d.ts +13 -0
  133. package/dist/tools/verify-completeness.d.ts.map +1 -0
  134. package/dist/tools/verify-completeness.js +68 -0
  135. package/dist/tools/verify-completeness.js.map +1 -0
  136. package/dist/tools/verify-mockups.d.ts +14 -0
  137. package/dist/tools/verify-mockups.d.ts.map +1 -0
  138. package/dist/tools/verify-mockups.js +85 -0
  139. package/dist/tools/verify-mockups.js.map +1 -0
  140. package/package.json +50 -0
@@ -0,0 +1,35 @@
1
+ /**
2
+ * codebakers_get_context
3
+ *
4
+ * Auto-detect project state and suggest next steps
5
+ * This runs before EVERY user interaction to make CodeBakers self-aware
6
+ */
7
+ interface ProjectContext {
8
+ current_phase: string;
9
+ phase_number: number;
10
+ progress_percent: number;
11
+ next_steps: NextStep[];
12
+ blockers: Blocker[];
13
+ suggestions: Suggestion[];
14
+ project_name?: string;
15
+ project_type?: string;
16
+ }
17
+ interface NextStep {
18
+ description: string;
19
+ command?: string;
20
+ estimated_time?: string;
21
+ }
22
+ interface Blocker {
23
+ type: string;
24
+ description: string;
25
+ solutions: string[];
26
+ }
27
+ interface Suggestion {
28
+ type: string;
29
+ message: string;
30
+ action: string;
31
+ command?: string;
32
+ }
33
+ export declare function getContext(args: any): Promise<ProjectContext>;
34
+ export {};
35
+ //# sourceMappingURL=get-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-context.d.ts","sourceRoot":"","sources":["../../src/tools/get-context.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,UAAU,cAAc;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,QAAQ,EAAE,CAAC;IACvB,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,UAAU,QAAQ;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,UAAU,OAAO;IACf,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,UAAU,UAAU;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,cAAc,CAAC,CA+BnE"}
@@ -0,0 +1,367 @@
1
+ /**
2
+ * codebakers_get_context
3
+ *
4
+ * Auto-detect project state and suggest next steps
5
+ * This runs before EVERY user interaction to make CodeBakers self-aware
6
+ */
7
+ import { promises as fs } from 'fs';
8
+ import * as path from 'path';
9
+ export async function getContext(args) {
10
+ const cwd = process.cwd();
11
+ // 1. DETECT PROJECT STATE
12
+ const state = await detectProjectState(cwd);
13
+ // 2. DETERMINE CURRENT PHASE
14
+ const phase = await determineCurrentPhase(state);
15
+ // 3. CALCULATE PROGRESS
16
+ const progress = calculateProgress(phase, state);
17
+ // 4. DETERMINE NEXT STEPS
18
+ const nextSteps = await determineNextSteps(phase, state);
19
+ // 5. DETECT BLOCKERS
20
+ const blockers = await detectBlockers(state);
21
+ // 6. GENERATE SUGGESTIONS
22
+ const suggestions = generateSuggestions(phase, state, blockers);
23
+ return {
24
+ current_phase: phase.name,
25
+ phase_number: phase.number,
26
+ progress_percent: progress,
27
+ next_steps: nextSteps,
28
+ blockers: blockers,
29
+ suggestions: suggestions,
30
+ project_name: state.projectName,
31
+ project_type: state.projectType,
32
+ };
33
+ }
34
+ async function detectProjectState(cwd) {
35
+ const state = {
36
+ hasCodabakersFolder: await exists(path.join(cwd, '.codebakers')),
37
+ hasBuildState: await exists(path.join(cwd, '.codebakers/BUILD-STATE.md')),
38
+ hasProjectSpec: await exists(path.join(cwd, '.codebakers/PROJECT-SPEC.md')),
39
+ hasRefsFolder: await exists(path.join(cwd, 'refs')),
40
+ hasMockups: await exists(path.join(cwd, 'refs/design')) && (await hasFiles(path.join(cwd, 'refs/design'))),
41
+ hasSchema: await exists(path.join(cwd, 'supabase/migrations')) || await exists(path.join(cwd, '.codebakers/SCHEMA.sql')),
42
+ hasDependencyMap: await exists(path.join(cwd, '.codebakers/DEPENDENCY-MAP.md')),
43
+ hasStoreContracts: await exists(path.join(cwd, '.codebakers/STORE-CONTRACTS.md')),
44
+ hasCode: await exists(path.join(cwd, 'app')) || await exists(path.join(cwd, 'src')),
45
+ hasPackageJson: await exists(path.join(cwd, 'package.json')),
46
+ hasGit: await exists(path.join(cwd, '.git')),
47
+ projectName: await getProjectName(cwd),
48
+ projectType: await getProjectType(cwd),
49
+ };
50
+ // Load BUILD-STATE if it exists
51
+ if (state.hasBuildState) {
52
+ try {
53
+ const buildStateContent = await fs.readFile(path.join(cwd, '.codebakers/BUILD-STATE.md'), 'utf-8');
54
+ state.buildState = parseBuildState(buildStateContent);
55
+ }
56
+ catch (error) {
57
+ // BUILD-STATE exists but couldn't read it
58
+ }
59
+ }
60
+ return state;
61
+ }
62
+ async function determineCurrentPhase(state) {
63
+ // If BUILD-STATE exists, read phase from there
64
+ if (state.buildState?.current_phase !== undefined) {
65
+ return {
66
+ number: state.buildState.current_phase,
67
+ name: getPhaseName(state.buildState.current_phase),
68
+ };
69
+ }
70
+ // Otherwise, infer from file existence
71
+ if (!state.hasCodabakersFolder) {
72
+ return { number: -1, name: 'PRE_INIT' };
73
+ }
74
+ if (!state.hasProjectSpec) {
75
+ return { number: 0, name: 'PHASE_0_SPEC' };
76
+ }
77
+ if (!state.hasMockups) {
78
+ return { number: 1, name: 'PHASE_1_MOCKUPS' };
79
+ }
80
+ if (!state.hasSchema || !state.hasDependencyMap) {
81
+ return { number: 2, name: 'PHASE_2_SCHEMA' };
82
+ }
83
+ if (!state.hasCode) {
84
+ return { number: 3, name: 'PHASE_3_FOUNDATION' };
85
+ }
86
+ // If has code, check BUILD-STATE for Phase 4/5/6
87
+ return { number: 4, name: 'PHASE_4_FEATURES' };
88
+ }
89
+ function getPhaseName(phaseNumber) {
90
+ const phases = [
91
+ 'PHASE_0_SPEC',
92
+ 'PHASE_1_MOCKUPS',
93
+ 'PHASE_2_SCHEMA',
94
+ 'PHASE_3_FOUNDATION',
95
+ 'PHASE_4_FEATURES',
96
+ 'PHASE_5_TESTING',
97
+ 'PHASE_6_DEPLOYMENT',
98
+ ];
99
+ return phases[phaseNumber] || 'UNKNOWN';
100
+ }
101
+ function calculateProgress(phase, state) {
102
+ // Simple progress calculation based on phase milestones
103
+ const phaseProgress = {
104
+ PRE_INIT: 0,
105
+ PHASE_0_SPEC: 10,
106
+ PHASE_1_MOCKUPS: 25,
107
+ PHASE_2_SCHEMA: 40,
108
+ PHASE_3_FOUNDATION: 55,
109
+ PHASE_4_FEATURES: 70,
110
+ PHASE_5_TESTING: 85,
111
+ PHASE_6_DEPLOYMENT: 95,
112
+ };
113
+ return phaseProgress[phase.name] || 0;
114
+ }
115
+ async function determineNextSteps(phase, state) {
116
+ const steps = [];
117
+ switch (phase.name) {
118
+ case 'PRE_INIT':
119
+ steps.push({
120
+ description: 'Initialize CodeBakers project structure',
121
+ command: 'codebakers_init_session',
122
+ estimated_time: '1 minute',
123
+ });
124
+ steps.push({
125
+ description: 'Start Phase 0: Generate project specification',
126
+ command: 'codebakers_generate_spec',
127
+ estimated_time: '5-10 minutes',
128
+ });
129
+ break;
130
+ case 'PHASE_0_SPEC':
131
+ steps.push({
132
+ description: 'Complete PROJECT-SPEC.md (Gates 0-5)',
133
+ command: 'codebakers_generate_spec',
134
+ estimated_time: '5-10 minutes',
135
+ });
136
+ break;
137
+ case 'PHASE_1_MOCKUPS':
138
+ if (!state.hasMockups) {
139
+ steps.push({
140
+ description: 'Generate UI mockups or upload existing mockups to refs/design/',
141
+ estimated_time: '15-30 minutes',
142
+ });
143
+ }
144
+ else {
145
+ steps.push({
146
+ description: 'Review mockups and proceed to Phase 2',
147
+ command: 'codebakers_check_gate 1',
148
+ });
149
+ }
150
+ break;
151
+ case 'PHASE_2_SCHEMA':
152
+ if (!state.hasDependencyMap) {
153
+ steps.push({
154
+ description: 'Analyze mockups and generate schema',
155
+ command: 'codebakers_analyze_mockups_deep',
156
+ estimated_time: '10-15 minutes',
157
+ });
158
+ }
159
+ else {
160
+ steps.push({
161
+ description: 'Verify Phase 2 gate and proceed to Phase 3',
162
+ command: 'codebakers_check_gate 2',
163
+ });
164
+ }
165
+ break;
166
+ case 'PHASE_3_FOUNDATION':
167
+ steps.push({
168
+ description: 'Build project scaffold, auth, and routing',
169
+ estimated_time: '20-30 minutes',
170
+ });
171
+ break;
172
+ case 'PHASE_4_FEATURES':
173
+ steps.push({
174
+ description: 'Build features from PROJECT-SPEC.md',
175
+ command: 'codebakers_enforce_feature',
176
+ estimated_time: 'Varies by feature',
177
+ });
178
+ break;
179
+ case 'PHASE_5_TESTING':
180
+ steps.push({
181
+ description: 'Run comprehensive testing suite',
182
+ estimated_time: '30-60 minutes',
183
+ });
184
+ break;
185
+ case 'PHASE_6_DEPLOYMENT':
186
+ steps.push({
187
+ description: 'Deploy to production and generate runbook',
188
+ estimated_time: '15-30 minutes',
189
+ });
190
+ break;
191
+ }
192
+ return steps;
193
+ }
194
+ async function detectBlockers(state) {
195
+ const blockers = [];
196
+ // No git repository
197
+ if (!state.hasGit) {
198
+ blockers.push({
199
+ type: 'CRITICAL',
200
+ description: 'No git repository detected. CodeBakers requires git for memory and crash recovery.',
201
+ solutions: [
202
+ 'Run: git init',
203
+ 'Create initial commit: git add . && git commit -m "initial commit"',
204
+ ],
205
+ });
206
+ }
207
+ // Mockups expected but missing
208
+ if (state.hasProjectSpec && !state.hasMockups && state.buildState?.current_phase === 1) {
209
+ blockers.push({
210
+ type: 'BLOCKED',
211
+ description: 'Phase 1 (Mockups) in progress but no mockups found in refs/design/',
212
+ solutions: [
213
+ 'Generate mockups with AI',
214
+ 'Upload your own mockups to refs/design/',
215
+ 'Skip mockups (not recommended - violates Method principle P2)',
216
+ ],
217
+ });
218
+ }
219
+ // Schema expected but missing
220
+ if (state.hasMockups && !state.hasSchema && state.buildState?.current_phase === 2) {
221
+ blockers.push({
222
+ type: 'BLOCKED',
223
+ description: 'Phase 2 (Schema) in progress but schema not generated',
224
+ solutions: [
225
+ 'Run: codebakers_analyze_mockups_deep',
226
+ 'Then: codebakers_generate_schema',
227
+ ],
228
+ });
229
+ }
230
+ return blockers;
231
+ }
232
+ function generateSuggestions(phase, state, blockers) {
233
+ const suggestions = [];
234
+ // If blockers exist, suggest fixes first
235
+ if (blockers.length > 0) {
236
+ suggestions.push({
237
+ type: 'blocker',
238
+ message: `${blockers.length} blocker(s) detected. Fix these first before proceeding.`,
239
+ action: 'Show blockers',
240
+ });
241
+ return suggestions; // Don't suggest next steps if blocked
242
+ }
243
+ // Phase-specific suggestions
244
+ switch (phase.name) {
245
+ case 'PRE_INIT':
246
+ suggestions.push({
247
+ type: 'get_started',
248
+ message: 'New project detected. Let me guide you through the CodeBakers Method (7 phases).',
249
+ action: 'Start Phase 0',
250
+ command: 'codebakers_init_session',
251
+ });
252
+ break;
253
+ case 'PHASE_0_SPEC':
254
+ if (state.hasProjectSpec) {
255
+ suggestions.push({
256
+ type: 'next_phase',
257
+ message: 'PROJECT-SPEC.md complete. Ready to start Phase 1 (Mockups)?',
258
+ action: 'Proceed to Phase 1',
259
+ });
260
+ }
261
+ break;
262
+ case 'PHASE_1_MOCKUPS':
263
+ if (state.hasMockups) {
264
+ suggestions.push({
265
+ type: 'next_phase',
266
+ message: 'Mockups ready. Run deep analysis to generate schema?',
267
+ action: 'Start Phase 2',
268
+ command: 'codebakers_analyze_mockups_deep',
269
+ });
270
+ }
271
+ break;
272
+ case 'PHASE_2_SCHEMA':
273
+ if (state.hasSchema && state.hasDependencyMap) {
274
+ suggestions.push({
275
+ type: 'next_phase',
276
+ message: 'Schema and dependencies mapped. Ready to build foundation?',
277
+ action: 'Start Phase 3',
278
+ });
279
+ }
280
+ break;
281
+ case 'PHASE_4_FEATURES':
282
+ suggestions.push({
283
+ type: 'feature_build',
284
+ message: 'Ready to build features. Use // [feature name] for full enforcement.',
285
+ action: 'Build next feature',
286
+ });
287
+ break;
288
+ }
289
+ return suggestions;
290
+ }
291
+ // Helper functions
292
+ async function exists(filePath) {
293
+ try {
294
+ await fs.access(filePath);
295
+ return true;
296
+ }
297
+ catch {
298
+ return false;
299
+ }
300
+ }
301
+ async function hasFiles(dirPath) {
302
+ try {
303
+ const files = await fs.readdir(dirPath);
304
+ return files.length > 0;
305
+ }
306
+ catch {
307
+ return false;
308
+ }
309
+ }
310
+ async function getProjectName(cwd) {
311
+ try {
312
+ const packageJsonPath = path.join(cwd, 'package.json');
313
+ if (await exists(packageJsonPath)) {
314
+ const content = await fs.readFile(packageJsonPath, 'utf-8');
315
+ const pkg = JSON.parse(content);
316
+ return pkg.name;
317
+ }
318
+ // Try BUILD-STATE
319
+ const buildStatePath = path.join(cwd, '.codebakers/BUILD-STATE.md');
320
+ if (await exists(buildStatePath)) {
321
+ const content = await fs.readFile(buildStatePath, 'utf-8');
322
+ const match = content.match(/Project:\s*(.+)/);
323
+ if (match)
324
+ return match[1].trim();
325
+ }
326
+ }
327
+ catch {
328
+ // Ignore errors
329
+ }
330
+ return undefined;
331
+ }
332
+ async function getProjectType(cwd) {
333
+ try {
334
+ const buildStatePath = path.join(cwd, '.codebakers/BUILD-STATE.md');
335
+ if (await exists(buildStatePath)) {
336
+ const content = await fs.readFile(buildStatePath, 'utf-8');
337
+ const match = content.match(/Type:\s*(.+)/);
338
+ if (match)
339
+ return match[1].trim();
340
+ }
341
+ const specPath = path.join(cwd, '.codebakers/PROJECT-SPEC.md');
342
+ if (await exists(specPath)) {
343
+ const content = await fs.readFile(specPath, 'utf-8');
344
+ const match = content.match(/Type:\s*(.+)/);
345
+ if (match)
346
+ return match[1].trim();
347
+ }
348
+ }
349
+ catch {
350
+ // Ignore errors
351
+ }
352
+ return undefined;
353
+ }
354
+ function parseBuildState(content) {
355
+ // Simple parser for BUILD-STATE.md
356
+ const state = {};
357
+ const phaseMatch = content.match(/Current Phase:\s*(\d+)/i);
358
+ if (phaseMatch) {
359
+ state.current_phase = parseInt(phaseMatch[1]);
360
+ }
361
+ const progressMatch = content.match(/Progress:\s*(\d+)%/i);
362
+ if (progressMatch) {
363
+ state.progress = parseInt(progressMatch[1]);
364
+ }
365
+ return state;
366
+ }
367
+ //# sourceMappingURL=get-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-context.js","sourceRoot":"","sources":["../../src/tools/get-context.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,IAAI,CAAC;AACpC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAgC7B,MAAM,CAAC,KAA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U,EAAE,CAAC;QACf,KAAK,CAAC,aAAa,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IAChD,CAAC;IAED,MAAM,aAAa,GAAG,OAAO,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;IAC3D,IAAI,aAAa,EAAE,CAAC;QAClB,KAAK,CAAC,QAAQ,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9C,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * codebakers_init_session
3
+ *
4
+ * Session Initialization Protocol (from CodeBakers Method)
5
+ * Loads BUILD-STATE.md, PROJECT-SPEC.md, and phase-specific context
6
+ * MUST run at the start of every AI session
7
+ */
8
+ interface SessionContext {
9
+ initialized: true;
10
+ project_name: string;
11
+ current_phase: number;
12
+ phase_name: string;
13
+ current_task: string;
14
+ build_state: any;
15
+ project_spec: any;
16
+ phase_artifacts: string[];
17
+ verification_gate: string[];
18
+ next_action: string;
19
+ }
20
+ export declare function initSession(args: any): Promise<SessionContext>;
21
+ export {};
22
+ //# sourceMappingURL=init-session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init-session.d.ts","sourceRoot":"","sources":["../../src/tools/init-session.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,UAAU,cAAc;IACtB,WAAW,EAAE,IAAI,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,GAAG,CAAC;IACjB,YAAY,EAAE,GAAG,CAAC;IAClB,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,wBAAsB,WAAW,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,cAAc,CAAC,CAwCpE"}
@@ -0,0 +1,232 @@
1
+ /**
2
+ * codebakers_init_session
3
+ *
4
+ * Session Initialization Protocol (from CodeBakers Method)
5
+ * Loads BUILD-STATE.md, PROJECT-SPEC.md, and phase-specific context
6
+ * MUST run at the start of every AI session
7
+ */
8
+ import { promises as fs } from 'fs';
9
+ import * as path from 'path';
10
+ export async function initSession(args) {
11
+ const cwd = process.cwd();
12
+ console.error('🍞 CodeBakers: Initializing session...');
13
+ // 1. Load BUILD-STATE.md (establishes current project context)
14
+ const buildState = await loadBuildState(cwd);
15
+ // 2. Load PROJECT-SPEC.md (confirms scope boundaries)
16
+ const projectSpec = await loadProjectSpec(cwd);
17
+ // 3. Load phase-specific artifacts
18
+ const phaseArtifacts = await loadPhaseArtifacts(cwd, buildState.current_phase);
19
+ // 4. Confirm current phase and task
20
+ const currentTask = buildState.current_task || determineCurrentTask(buildState);
21
+ // 5. Confirm verification gate requirements
22
+ const verificationGate = getVerificationGate(buildState.current_phase);
23
+ // 6. Determine next action
24
+ const nextAction = determineNextAction(buildState, projectSpec);
25
+ console.error(`✓ Session initialized`);
26
+ console.error(` Project: ${buildState.project_name}`);
27
+ console.error(` Phase: ${buildState.current_phase} (${getPhaseName(buildState.current_phase)})`);
28
+ console.error(` Task: ${currentTask}`);
29
+ return {
30
+ initialized: true,
31
+ project_name: buildState.project_name,
32
+ current_phase: buildState.current_phase,
33
+ phase_name: getPhaseName(buildState.current_phase),
34
+ current_task: currentTask,
35
+ build_state: buildState,
36
+ project_spec: projectSpec,
37
+ phase_artifacts: phaseArtifacts,
38
+ verification_gate: verificationGate,
39
+ next_action: nextAction,
40
+ };
41
+ }
42
+ async function loadBuildState(cwd) {
43
+ const buildStatePath = path.join(cwd, '.codebakers/BUILD-STATE.md');
44
+ try {
45
+ const content = await fs.readFile(buildStatePath, 'utf-8');
46
+ return parseBuildState(content);
47
+ }
48
+ catch (error) {
49
+ // BUILD-STATE doesn't exist - new project
50
+ // Initialize with defaults
51
+ return {
52
+ project_name: 'New Project',
53
+ current_phase: 0,
54
+ current_task: 'Generate PROJECT-SPEC.md',
55
+ created_at: new Date().toISOString(),
56
+ last_updated: new Date().toISOString(),
57
+ };
58
+ }
59
+ }
60
+ async function loadProjectSpec(cwd) {
61
+ const specPath = path.join(cwd, '.codebakers/PROJECT-SPEC.md');
62
+ try {
63
+ const content = await fs.readFile(specPath, 'utf-8');
64
+ return parseProjectSpec(content);
65
+ }
66
+ catch (error) {
67
+ // PROJECT-SPEC doesn't exist yet
68
+ return null;
69
+ }
70
+ }
71
+ async function loadPhaseArtifacts(cwd, phase) {
72
+ const artifacts = [];
73
+ const phaseArtifactPaths = {
74
+ 0: ['.codebakers/PROJECT-SPEC.md', '.codebakers/COMPETITIVE-ANALYSIS.md'],
75
+ 1: ['refs/design/', '.codebakers/DESIGN-SYSTEM.md'],
76
+ 2: [
77
+ '.codebakers/MOCK-ANALYSIS.md',
78
+ '.codebakers/SCHEMA.sql',
79
+ '.codebakers/DEPENDENCY-MAP.md',
80
+ '.codebakers/STORE-CONTRACTS.md',
81
+ ],
82
+ 3: ['app/', 'lib/', 'components/'],
83
+ 4: ['app/', 'lib/', 'components/'],
84
+ 5: ['.codebakers/TEST-REPORT.md'],
85
+ 6: ['.codebakers/RUNBOOK.md'],
86
+ };
87
+ const paths = phaseArtifactPaths[phase] || [];
88
+ for (const artifactPath of paths) {
89
+ const fullPath = path.join(cwd, artifactPath);
90
+ try {
91
+ await fs.access(fullPath);
92
+ artifacts.push(artifactPath);
93
+ }
94
+ catch {
95
+ // Artifact doesn't exist yet
96
+ }
97
+ }
98
+ return artifacts;
99
+ }
100
+ function determineCurrentTask(buildState) {
101
+ const phase = buildState.current_phase;
102
+ const defaultTasks = {
103
+ 0: 'Generate PROJECT-SPEC.md (Gates 0-5)',
104
+ 1: 'Design UI mockups for all screens',
105
+ 2: 'Analyze mockups and generate schema',
106
+ 3: 'Build project foundation and authentication',
107
+ 4: 'Build features from PROJECT-SPEC.md',
108
+ 5: 'Run comprehensive testing suite',
109
+ 6: 'Deploy to production',
110
+ };
111
+ return defaultTasks[phase] || 'Unknown task';
112
+ }
113
+ function getVerificationGate(phase) {
114
+ const gates = {
115
+ 0: [
116
+ 'PROJECT-SPEC.md complete through all 6 gates',
117
+ 'Feature list atomically decomposed',
118
+ 'All external dependencies identified',
119
+ 'Human reviewed and approved spec',
120
+ ],
121
+ 1: [
122
+ 'Every screen in spec has mockup',
123
+ 'All interactive states represented',
124
+ 'Design system tokens documented',
125
+ 'Human reviewed and approved all screens',
126
+ ],
127
+ 2: [
128
+ 'Every mockup field has database column',
129
+ 'All entity relationships captured',
130
+ 'Dependency map complete',
131
+ 'Schema reviewed for normalization and security',
132
+ ],
133
+ 3: [
134
+ 'Application runs without errors',
135
+ 'All routes resolve',
136
+ 'Auth flows work end-to-end',
137
+ 'Database migrations run cleanly',
138
+ 'Design system components render correctly',
139
+ ],
140
+ 4: [
141
+ 'Every feature in spec implemented',
142
+ 'Every screen matches mockup',
143
+ 'All forms validate correctly',
144
+ 'All data operations work',
145
+ 'No console errors or TypeScript violations',
146
+ ],
147
+ 5: [
148
+ 'All automated tests pass',
149
+ 'Lighthouse score >90',
150
+ 'No critical security vulnerabilities',
151
+ 'WCAG AA compliance met',
152
+ 'Zero known blocking bugs',
153
+ ],
154
+ 6: [
155
+ 'Application live and accessible',
156
+ 'CI/CD pipeline runs successfully',
157
+ 'Monitoring alerts firing correctly',
158
+ 'Backup and restore tested',
159
+ 'Runbook complete',
160
+ ],
161
+ };
162
+ return gates[phase] || [];
163
+ }
164
+ function determineNextAction(buildState, projectSpec) {
165
+ const phase = buildState.current_phase;
166
+ if (!projectSpec && phase === 0) {
167
+ return 'Run: codebakers_generate_spec (provide project description)';
168
+ }
169
+ if (projectSpec && phase === 0) {
170
+ return 'Review PROJECT-SPEC.md and proceed to Phase 1 (Mockups)';
171
+ }
172
+ if (phase === 1) {
173
+ return 'Design mockups or upload to refs/design/';
174
+ }
175
+ if (phase === 2) {
176
+ return 'Run: codebakers_analyze_mockups_deep';
177
+ }
178
+ return 'Continue with current phase tasks';
179
+ }
180
+ function getPhaseName(phase) {
181
+ const names = [
182
+ 'Domain Research & Spec',
183
+ 'UI Mockup & Design',
184
+ 'Mock Analysis & Schema',
185
+ 'Foundation Build',
186
+ 'Feature Build',
187
+ 'Testing & Verification',
188
+ 'Deployment & Ops',
189
+ ];
190
+ return names[phase] || 'Unknown Phase';
191
+ }
192
+ function parseBuildState(content) {
193
+ const state = {
194
+ project_name: 'Unknown',
195
+ current_phase: 0,
196
+ current_task: '',
197
+ created_at: new Date().toISOString(),
198
+ last_updated: new Date().toISOString(),
199
+ };
200
+ // Extract fields from BUILD-STATE.md
201
+ const projectMatch = content.match(/Project:\s*(.+)/);
202
+ if (projectMatch)
203
+ state.project_name = projectMatch[1].trim();
204
+ const phaseMatch = content.match(/Current Phase:\s*(\d+)/);
205
+ if (phaseMatch)
206
+ state.current_phase = parseInt(phaseMatch[1]);
207
+ const taskMatch = content.match(/Current Task:\s*(.+)/);
208
+ if (taskMatch)
209
+ state.current_task = taskMatch[1].trim();
210
+ const createdMatch = content.match(/Created:\s*(.+)/);
211
+ if (createdMatch)
212
+ state.created_at = createdMatch[1].trim();
213
+ const updatedMatch = content.match(/Last Updated:\s*(.+)/);
214
+ if (updatedMatch)
215
+ state.last_updated = updatedMatch[1].trim();
216
+ return state;
217
+ }
218
+ function parseProjectSpec(content) {
219
+ // Simple parser for PROJECT-SPEC.md
220
+ const spec = {
221
+ gates: {},
222
+ features: [],
223
+ };
224
+ // Extract features
225
+ const featuresSection = content.match(/## Features(.+?)(?=##|$)/s);
226
+ if (featuresSection) {
227
+ const featureLines = featuresSection[1].match(/- .+/g) || [];
228
+ spec.features = featureLines.map((line) => line.replace(/^- /, '').trim());
229
+ }
230
+ return spec;
231
+ }
232
+ //# sourceMappingURL=init-session.js.map