@getanima/core 0.2.0 → 0.2.1

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 (76) hide show
  1. package/README.md +148 -113
  2. package/dist/alme/core/KnowledgeGraph.d.ts +58 -0
  3. package/dist/alme/core/KnowledgeGraph.d.ts.map +1 -0
  4. package/dist/alme/core/KnowledgeGraph.js +114 -0
  5. package/dist/alme/core/KnowledgeGraph.js.map +1 -0
  6. package/dist/alme/core/MetacognitionEngine.d.ts +35 -0
  7. package/dist/alme/core/MetacognitionEngine.d.ts.map +1 -0
  8. package/dist/alme/core/MetacognitionEngine.js +90 -0
  9. package/dist/alme/core/MetacognitionEngine.js.map +1 -0
  10. package/dist/alme/core/PerformanceAnalyzer.d.ts +68 -0
  11. package/dist/alme/core/PerformanceAnalyzer.d.ts.map +1 -0
  12. package/dist/alme/core/PerformanceAnalyzer.js +142 -0
  13. package/dist/alme/core/PerformanceAnalyzer.js.map +1 -0
  14. package/dist/alme/core/SelfReflectionModule.d.ts +41 -0
  15. package/dist/alme/core/SelfReflectionModule.d.ts.map +1 -0
  16. package/dist/alme/core/SelfReflectionModule.js +101 -0
  17. package/dist/alme/core/SelfReflectionModule.js.map +1 -0
  18. package/dist/alme/core/SkillProfile.d.ts +52 -0
  19. package/dist/alme/core/SkillProfile.d.ts.map +1 -0
  20. package/dist/alme/core/SkillProfile.js +97 -0
  21. package/dist/alme/core/SkillProfile.js.map +1 -0
  22. package/dist/anima.d.ts +28 -0
  23. package/dist/anima.d.ts.map +1 -1
  24. package/dist/anima.js +60 -8
  25. package/dist/anima.js.map +1 -1
  26. package/dist/codegen/ArchitecturalDesignGenerator.d.ts +77 -0
  27. package/dist/codegen/ArchitecturalDesignGenerator.d.ts.map +1 -0
  28. package/dist/codegen/ArchitecturalDesignGenerator.js +194 -0
  29. package/dist/codegen/ArchitecturalDesignGenerator.js.map +1 -0
  30. package/dist/codegen/ContextAwareGenerator.d.ts +67 -0
  31. package/dist/codegen/ContextAwareGenerator.d.ts.map +1 -0
  32. package/dist/codegen/ContextAwareGenerator.js +158 -0
  33. package/dist/codegen/ContextAwareGenerator.js.map +1 -0
  34. package/dist/codegen/SystemInteractionSimulator.d.ts +87 -0
  35. package/dist/codegen/SystemInteractionSimulator.d.ts.map +1 -0
  36. package/dist/codegen/SystemInteractionSimulator.js +203 -0
  37. package/dist/codegen/SystemInteractionSimulator.js.map +1 -0
  38. package/dist/codegen/multiStageCodegen.d.ts +30 -0
  39. package/dist/codegen/multiStageCodegen.d.ts.map +1 -0
  40. package/dist/codegen/multiStageCodegen.js +60 -0
  41. package/dist/codegen/multiStageCodegen.js.map +1 -0
  42. package/dist/esm/anima.js +340 -0
  43. package/dist/esm/anima.js.map +1 -0
  44. package/dist/esm/identity.js +205 -0
  45. package/dist/esm/identity.js.map +1 -0
  46. package/dist/esm/index.js +14 -0
  47. package/dist/esm/index.js.map +1 -0
  48. package/dist/esm/memory.js +429 -0
  49. package/dist/esm/memory.js.map +1 -0
  50. package/dist/esm/reflection.js +86 -0
  51. package/dist/esm/reflection.js.map +1 -0
  52. package/dist/esm/signing.js +194 -0
  53. package/dist/esm/signing.js.map +1 -0
  54. package/dist/esm/types.js +6 -0
  55. package/dist/esm/types.js.map +1 -0
  56. package/dist/esm/utils.js +155 -0
  57. package/dist/esm/utils.js.map +1 -0
  58. package/dist/ideation/InnovationEngine.d.ts +47 -0
  59. package/dist/ideation/InnovationEngine.d.ts.map +1 -0
  60. package/dist/ideation/InnovationEngine.js +127 -0
  61. package/dist/ideation/InnovationEngine.js.map +1 -0
  62. package/dist/learning-tracker/LearningVisualizer.d.ts +26 -0
  63. package/dist/learning-tracker/LearningVisualizer.d.ts.map +1 -0
  64. package/dist/learning-tracker/LearningVisualizer.js +61 -0
  65. package/dist/learning-tracker/LearningVisualizer.js.map +1 -0
  66. package/dist/memory.d.ts +28 -0
  67. package/dist/memory.d.ts.map +1 -1
  68. package/dist/memory.js +77 -0
  69. package/dist/memory.js.map +1 -1
  70. package/dist/types.d.ts +6 -0
  71. package/dist/types.d.ts.map +1 -1
  72. package/dist/utils.d.ts +8 -2
  73. package/dist/utils.d.ts.map +1 -1
  74. package/dist/utils.js +28 -9
  75. package/dist/utils.js.map +1 -1
  76. package/package.json +5 -2
package/dist/anima.js CHANGED
@@ -64,6 +64,18 @@ class Anima {
64
64
  * Returns a WakeContext with everything the agent needs to start working.
65
65
  * Target: productive state in <60 seconds.
66
66
  */
67
+ /**
68
+ * QuickLoad — lightweight init for CLI commands that don't need full boot context.
69
+ * Loads index + opinions without logging a boot event or returning full context.
70
+ */
71
+ async quickLoad() {
72
+ if (this.booted)
73
+ return;
74
+ await this.identity.load();
75
+ // Load memory index and opinions silently
76
+ await this.memory.loadIndexPublic();
77
+ this.booted = true;
78
+ }
67
79
  async boot() {
68
80
  const startTime = Date.now();
69
81
  // Step 1: Load identity (SOUL.md + identity.json) — ~5s
@@ -105,6 +117,8 @@ class Anima {
105
117
  relevantOpinions: opinions,
106
118
  relationships: [], // TODO: relationship engine
107
119
  sessionId: this.session,
120
+ instanceId: (0, utils_1.sessionId)(), // Unique per boot — prevents identity confusion when forked
121
+ parentInstanceId: undefined, // Set by caller if this is a forked instance
108
122
  lastSessionSummary: todayLog || yesterdayLog || undefined,
109
123
  tokenBudget: 4000, // reasonable default
110
124
  tokensUsed: this.estimateTokens(identityData, recentMemories, opinions),
@@ -165,6 +179,25 @@ class Anima {
165
179
  this.ensureBooted();
166
180
  return this.memory.opine({ topic, opinion, confidence });
167
181
  }
182
+ // ============ CURATE ============
183
+ /**
184
+ * Curate — review raw memories and distill what matters into long-term memory.
185
+ *
186
+ * The missing piece between storage and retrieval.
187
+ * Raw daily logs are your journal. MEMORY.md is your identity.
188
+ * This method bridges the two.
189
+ *
190
+ * Call periodically (heartbeats, daily, whenever feels right).
191
+ *
192
+ * ```typescript
193
+ * const result = await anima.curate();
194
+ * console.log(`Curated ${result.curated.length} memories`);
195
+ * ```
196
+ */
197
+ async curate(options) {
198
+ this.ensureBooted();
199
+ return this.memory.curate(options);
200
+ }
168
201
  // ============ REFLECT (End of session) ============
169
202
  /**
170
203
  * Reflect — end-of-session consolidation.
@@ -173,6 +206,8 @@ class Anima {
173
206
  async reflect() {
174
207
  this.ensureBooted();
175
208
  const startTime = Date.now();
209
+ // Curate before decay — promote important memories to MEMORY.md
210
+ const curationResult = await this.memory.curate({ hoursBack: 24, minImportance: 'medium' });
176
211
  // Run memory decay
177
212
  const decayResult = await this.memory.runDecay();
178
213
  // Get all opinions for summary
@@ -180,7 +215,7 @@ class Anima {
180
215
  // Generate session summary
181
216
  const summary = {
182
217
  sessionId: this.session,
183
- startedAt: new Date(Date.now() - (Date.now() - this.bootTime)).toISOString(),
218
+ startedAt: new Date(Date.now() - this.bootTime).toISOString(),
184
219
  endedAt: (0, utils_1.now)(),
185
220
  summary: `Session ${this.session}: ${this.memoriesThisSession} memories created. Decay: ${decayResult.decayed} removed, ${decayResult.archived} archived, ${decayResult.kept} kept.`,
186
221
  memoriesCreated: this.memoriesThisSession,
@@ -200,13 +235,30 @@ class Anima {
200
235
  importance: 'low',
201
236
  tags: ['system', 'session-summary'],
202
237
  });
203
- // Clear lifeboat (session ended normally)
204
- await this.memory.updateLifeboat({
205
- activeTask: 'No active task session ended normally',
206
- status: 'done',
207
- resumePoint: 'Start fresh next session',
208
- updatedAt: (0, utils_1.now)(),
209
- });
238
+ // Update lifeboat with session summary — PRESERVE existing content
239
+ // The lifeboat may contain a hand-written letter from the agent to future-self.
240
+ // Append session summary instead of nuking everything.
241
+ const existingLifeboat = await this.memory.readLifeboat();
242
+ const sessionEndNote = [
243
+ `\n## Last Session Summary (${(0, utils_1.now)()})`,
244
+ summary.summary,
245
+ `Curated ${curationResult.curated.length} memories to long-term.`,
246
+ `\n## Status`,
247
+ `done — session ended normally. Read everything above for context.`,
248
+ ].join('\n');
249
+ if (existingLifeboat && !existingLifeboat.includes('session ended normally')) {
250
+ // Preserve existing lifeboat, append summary
251
+ await this.memory.writeLifeboatRaw(existingLifeboat + '\n' + sessionEndNote);
252
+ }
253
+ else {
254
+ // No meaningful lifeboat content — write clean end state
255
+ await this.memory.updateLifeboat({
256
+ activeTask: 'No active task — session ended normally',
257
+ status: 'done',
258
+ resumePoint: 'Start fresh next session',
259
+ updatedAt: (0, utils_1.now)(),
260
+ });
261
+ }
210
262
  return summary;
211
263
  }
212
264
  // ============ SIGNING ============
package/dist/anima.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"anima.js","sourceRoot":"","sources":["../src/anima.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;;;AAGH,qCAAwC;AACxC,yCAA6C;AAC7C,uCAA0C;AAE1C,mCAAkD;AAElD,MAAa,KAAK;IACR,MAAM,CAAwB;IAC9B,OAAO,CAAS;IAChB,QAAQ,CAAkB;IAC1B,MAAM,CAAe;IACrB,QAAQ,GAAW,CAAC,CAAC;IACrB,mBAAmB,GAAW,CAAC,CAAC;IAChC,OAAO,CAAgB;IACvB,MAAM,GAAY,KAAK,CAAC;IAEhC,YAAY,MAAmB;QAC7B,IAAI,CAAC,MAAM,GAAG;YACZ,WAAW,EAAE,cAAc;YAC3B,gBAAgB,EAAE,EAAE;YACpB,KAAK,EAAE,QAAQ;YACf,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE;YAC/D,QAAQ,EAAE,EAAE;YACZ,GAAG,MAAM;SACV,CAAC;QAEF,IAAI,CAAC,OAAO,GAAG,IAAA,iBAAS,GAAE,CAAC;QAC3B,IAAI,CAAC,QAAQ,GAAG,IAAI,0BAAe,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACnF,IAAI,CAAC,MAAM,GAAG,IAAI,qBAAY,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,IAAI,C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BA2XC"}
@@ -0,0 +1,77 @@
1
+ import { KnowledgeGraph } from '../alme/core/KnowledgeGraph';
2
+ declare enum ArchitecturalPattern {
3
+ Microservices = 0,
4
+ EventDriven = 1,
5
+ Monolithic = 2,
6
+ Serverless = 3,
7
+ Hexagonal = 4,
8
+ CleanArchitecture = 5
9
+ }
10
+ interface TechnologyStack {
11
+ backend: string[];
12
+ frontend: string[];
13
+ database: string[];
14
+ deployment: string[];
15
+ }
16
+ interface ProjectRequirements {
17
+ domain: string;
18
+ scalabilityNeeds: 'low' | 'medium' | 'high';
19
+ performanceConstraints: {
20
+ responseTime: number;
21
+ concurrentUsers: number;
22
+ };
23
+ complexityLevel: 'simple' | 'moderate' | 'complex';
24
+ }
25
+ export declare class ArchitecturalDesignGenerator {
26
+ private knowledgeGraph;
27
+ private architecturalTemplates;
28
+ private technologyStacks;
29
+ constructor(knowledgeGraph: KnowledgeGraph);
30
+ /**
31
+ * Generate architectural design
32
+ * @param requirements Project requirements
33
+ * @returns Comprehensive architectural design
34
+ */
35
+ generateArchitecture(requirements: ProjectRequirements): {
36
+ selectedPattern: ArchitecturalPattern;
37
+ technologyStack: TechnologyStack;
38
+ architecturalBlueprint: string;
39
+ designRecommendations: string[];
40
+ };
41
+ /**
42
+ * Select optimal architectural pattern
43
+ * @param requirements Project requirements
44
+ * @returns Best matching architectural pattern
45
+ */
46
+ private selectArchitecturalPattern;
47
+ /**
48
+ * Retrieve technology stack for pattern
49
+ * @param pattern Selected architectural pattern
50
+ * @returns Recommended technology stack
51
+ */
52
+ private getTechnologyStack;
53
+ /**
54
+ * Create architectural blueprint
55
+ * @param pattern Selected architectural pattern
56
+ * @param requirements Project requirements
57
+ * @returns Architectural blueprint
58
+ */
59
+ private createArchitecturalBlueprint;
60
+ /**
61
+ * Enrich blueprint with knowledge graph insights
62
+ * @param blueprint Base architectural blueprint
63
+ * @param requirements Project requirements
64
+ * @returns Enriched blueprint
65
+ */
66
+ private enrichBlueprintWithKnowledgeInsights;
67
+ /**
68
+ * Generate design recommendations
69
+ * @param pattern Selected architectural pattern
70
+ * @param requirements Project requirements
71
+ * @returns Design recommendations
72
+ */
73
+ private generateDesignRecommendations;
74
+ }
75
+ export declare const architecturalDesignGenerator: ArchitecturalDesignGenerator;
76
+ export {};
77
+ //# sourceMappingURL=ArchitecturalDesignGenerator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ArchitecturalDesignGenerator.d.ts","sourceRoot":"","sources":["../../src/codegen/ArchitecturalDesignGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAG7D,aAAK,oBAAoB;IACvB,aAAa,IAAA;IACb,WAAW,IAAA;IACX,UAAU,IAAA;IACV,UAAU,IAAA;IACV,SAAS,IAAA;IACT,iBAAiB,IAAA;CAClB;AAGD,UAAU,eAAe;IACvB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB;AAGD,UAAU,mBAAmB;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;IAC5C,sBAAsB,EAAE;QACtB,YAAY,EAAE,MAAM,CAAC;QACrB,eAAe,EAAE,MAAM,CAAC;KACzB,CAAC;IACF,eAAe,EAAE,QAAQ,GAAG,UAAU,GAAG,SAAS,CAAC;CACpD;AAED,qBAAa,4BAA4B;IACvC,OAAO,CAAC,cAAc,CAAiB;IAGvC,OAAO,CAAC,sBAAsB,CAsC3B;IAGH,OAAO,CAAC,gBAAgB,CAarB;gBAES,cAAc,EAAE,cAAc;IAI1C;;;;OAIG;IACH,oBAAoB,CAClB,YAAY,EAAE,mBAAmB,GAChC;QACD,eAAe,EAAE,oBAAoB,CAAC;QACtC,eAAe,EAAE,eAAe,CAAC;QACjC,sBAAsB,EAAE,MAAM,CAAC;QAC/B,qBAAqB,EAAE,MAAM,EAAE,CAAC;KACjC;IAiCD;;;;OAIG;IACH,OAAO,CAAC,0BAA0B;IAelC;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;IAU1B;;;;;OAKG;IACH,OAAO,CAAC,4BAA4B;IAqBpC;;;;;OAKG;IACH,OAAO,CAAC,oCAAoC;IAkB5C;;;;;OAKG;IACH,OAAO,CAAC,6BAA6B;CA8BtC;AAGD,eAAO,MAAM,4BAA4B,8BAExC,CAAC"}
@@ -0,0 +1,194 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.architecturalDesignGenerator = exports.ArchitecturalDesignGenerator = void 0;
4
+ const KnowledgeGraph_1 = require("../alme/core/KnowledgeGraph");
5
+ // Architectural patterns and styles
6
+ var ArchitecturalPattern;
7
+ (function (ArchitecturalPattern) {
8
+ ArchitecturalPattern[ArchitecturalPattern["Microservices"] = 0] = "Microservices";
9
+ ArchitecturalPattern[ArchitecturalPattern["EventDriven"] = 1] = "EventDriven";
10
+ ArchitecturalPattern[ArchitecturalPattern["Monolithic"] = 2] = "Monolithic";
11
+ ArchitecturalPattern[ArchitecturalPattern["Serverless"] = 3] = "Serverless";
12
+ ArchitecturalPattern[ArchitecturalPattern["Hexagonal"] = 4] = "Hexagonal";
13
+ ArchitecturalPattern[ArchitecturalPattern["CleanArchitecture"] = 5] = "CleanArchitecture";
14
+ })(ArchitecturalPattern || (ArchitecturalPattern = {}));
15
+ class ArchitecturalDesignGenerator {
16
+ knowledgeGraph;
17
+ // Predefined architectural templates
18
+ architecturalTemplates = new Map([
19
+ [ArchitecturalPattern.Microservices, {
20
+ description: 'Distributed system with independently deployable services',
21
+ bestPractices: [
22
+ 'Use lightweight communication protocols',
23
+ 'Implement service discovery',
24
+ 'Design for fault tolerance'
25
+ ],
26
+ componentStructure: `
27
+ microservices/
28
+ ├── service-discovery/
29
+ ├── api-gateway/
30
+ ├── auth-service/
31
+ ├── core-service/
32
+ └── monitoring/
33
+ `
34
+ }],
35
+ [ArchitecturalPattern.Serverless, {
36
+ description: 'Event-driven, cloud-native architecture',
37
+ bestPractices: [
38
+ 'Minimize cold start times',
39
+ 'Design stateless functions',
40
+ 'Implement robust error handling'
41
+ ],
42
+ componentStructure: `
43
+ serverless/
44
+ ├── functions/
45
+ │ ├── authentication/
46
+ │ ├── data-processing/
47
+ │ └── notification/
48
+ ├── event-sources/
49
+ └── infrastructure/
50
+ `
51
+ }]
52
+ ]);
53
+ // Recommended technology stacks
54
+ technologyStacks = new Map([
55
+ [ArchitecturalPattern.Microservices, {
56
+ backend: ['Node.js', 'Kotlin', 'Go'],
57
+ frontend: ['React', 'Vue.js'],
58
+ database: ['MongoDB', 'Cassandra'],
59
+ deployment: ['Kubernetes', 'Docker']
60
+ }],
61
+ [ArchitecturalPattern.Serverless, {
62
+ backend: ['AWS Lambda', 'Azure Functions'],
63
+ frontend: ['Next.js', 'Svelte'],
64
+ database: ['DynamoDB', 'Firestore'],
65
+ deployment: ['Terraform', 'Serverless Framework']
66
+ }]
67
+ ]);
68
+ constructor(knowledgeGraph) {
69
+ this.knowledgeGraph = knowledgeGraph;
70
+ }
71
+ /**
72
+ * Generate architectural design
73
+ * @param requirements Project requirements
74
+ * @returns Comprehensive architectural design
75
+ */
76
+ generateArchitecture(requirements) {
77
+ // 1. Select appropriate architectural pattern
78
+ const selectedPattern = this.selectArchitecturalPattern(requirements);
79
+ // 2. Retrieve technology stack
80
+ const technologyStack = this.getTechnologyStack(selectedPattern);
81
+ // 3. Generate architectural blueprint
82
+ const architecturalBlueprint = this.createArchitecturalBlueprint(selectedPattern, requirements);
83
+ // 4. Generate design recommendations
84
+ const designRecommendations = this.generateDesignRecommendations(selectedPattern, requirements);
85
+ // 5. Enrich with knowledge graph insights
86
+ const enrichedBlueprint = this.enrichBlueprintWithKnowledgeInsights(architecturalBlueprint, requirements);
87
+ return {
88
+ selectedPattern,
89
+ technologyStack,
90
+ architecturalBlueprint: enrichedBlueprint,
91
+ designRecommendations
92
+ };
93
+ }
94
+ /**
95
+ * Select optimal architectural pattern
96
+ * @param requirements Project requirements
97
+ * @returns Best matching architectural pattern
98
+ */
99
+ selectArchitecturalPattern(requirements) {
100
+ // Intelligent pattern selection logic
101
+ if (requirements.scalabilityNeeds === 'high') {
102
+ return ArchitecturalPattern.Microservices;
103
+ }
104
+ if (requirements.performanceConstraints.concurrentUsers > 10000) {
105
+ return ArchitecturalPattern.Serverless;
106
+ }
107
+ return ArchitecturalPattern.Microservices; // Default fallback
108
+ }
109
+ /**
110
+ * Retrieve technology stack for pattern
111
+ * @param pattern Selected architectural pattern
112
+ * @returns Recommended technology stack
113
+ */
114
+ getTechnologyStack(pattern) {
115
+ const stack = this.technologyStacks.get(pattern);
116
+ if (!stack) {
117
+ throw new Error(`No technology stack found for pattern: ${pattern}`);
118
+ }
119
+ return stack;
120
+ }
121
+ /**
122
+ * Create architectural blueprint
123
+ * @param pattern Selected architectural pattern
124
+ * @param requirements Project requirements
125
+ * @returns Architectural blueprint
126
+ */
127
+ createArchitecturalBlueprint(pattern, requirements) {
128
+ const template = this.architecturalTemplates.get(pattern);
129
+ if (!template) {
130
+ throw new Error(`No template found for pattern: ${pattern}`);
131
+ }
132
+ return `
133
+ # Architectural Design: ${requirements.domain}
134
+ ## Pattern: ${ArchitecturalPattern[pattern]}
135
+ ## Complexity: ${requirements.complexityLevel}
136
+
137
+ ${template.componentStructure}
138
+
139
+ ## Best Practices:
140
+ ${template.bestPractices.map(practice => `- ${practice}`).join('\n')}
141
+ `;
142
+ }
143
+ /**
144
+ * Enrich blueprint with knowledge graph insights
145
+ * @param blueprint Base architectural blueprint
146
+ * @param requirements Project requirements
147
+ * @returns Enriched blueprint
148
+ */
149
+ enrichBlueprintWithKnowledgeInsights(blueprint, requirements) {
150
+ // Find related concepts in knowledge graph
151
+ const relatedConcepts = this.knowledgeGraph.findRelatedConcepts(requirements.domain, 2 // Depth of exploration
152
+ );
153
+ // Extract and integrate insights
154
+ const conceptInsights = relatedConcepts
155
+ .map(concept => `## Domain Insight: ${concept.content}`)
156
+ .join('\n');
157
+ return `${blueprint}\n\n${conceptInsights}`;
158
+ }
159
+ /**
160
+ * Generate design recommendations
161
+ * @param pattern Selected architectural pattern
162
+ * @param requirements Project requirements
163
+ * @returns Design recommendations
164
+ */
165
+ generateDesignRecommendations(pattern, requirements) {
166
+ const baseRecommendations = [
167
+ `Optimize for ${requirements.scalabilityNeeds} scalability`,
168
+ `Design to support ${requirements.performanceConstraints.concurrentUsers} concurrent users`,
169
+ `Implement ${requirements.complexityLevel} complexity architecture`
170
+ ];
171
+ const patternSpecificRecommendations = {
172
+ [ArchitecturalPattern.Microservices]: [
173
+ 'Implement robust service discovery',
174
+ 'Design for independent service deployment'
175
+ ],
176
+ [ArchitecturalPattern.Serverless]: [
177
+ 'Minimize cold start times',
178
+ 'Design stateless, event-driven functions'
179
+ ],
180
+ [ArchitecturalPattern.EventDriven]: [],
181
+ [ArchitecturalPattern.Monolithic]: [],
182
+ [ArchitecturalPattern.Hexagonal]: [],
183
+ [ArchitecturalPattern.CleanArchitecture]: []
184
+ };
185
+ return [
186
+ ...baseRecommendations,
187
+ ...(patternSpecificRecommendations[pattern] || [])
188
+ ];
189
+ }
190
+ }
191
+ exports.ArchitecturalDesignGenerator = ArchitecturalDesignGenerator;
192
+ // Singleton instance for global use
193
+ exports.architecturalDesignGenerator = new ArchitecturalDesignGenerator(new KnowledgeGraph_1.KnowledgeGraph());
194
+ //# sourceMappingURL=ArchitecturalDesignGenerator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ArchitecturalDesignGenerator.js","sourceRoot":"","sources":["../../src/codegen/ArchitecturalDesignGenerator.ts"],"names":[],"mappings":";;;AAAA,gEAA6D;AAE7D,oCAAoC;AACpC,IAAK,oBAOJ;AAPD,WAAK,oBAAoB;IACvB,iFAAa,CAAA;IACb,6EAAW,CAAA;IACX,2EAAU,CAAA;IACV,2EAAU,CAAA;IACV,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a,CAAC,EAAE;gBACpC,oCAAoC;gBACpC,2CAA2C;aAC5C;YACD,CAAC,oBAAoB,CAAC,UAAU,CAAC,EAAE;gBACjC,2BAA2B;gBAC3B,0CAA0C;aAC3C;YACD,CAAC,oBAAoB,CAAC,WAAW,CAAC,EAAE,EAAE;YACtC,CAAC,oBAAoB,CAAC,UAAU,CAAC,EAAE,EAAE;YACrC,CAAC,oBAAoB,CAAC,SAAS,CAAC,EAAE,EAAE;YACpC,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,EAAE;SAC7C,CAAC;QAEF,OAAO;YACL,GAAG,mBAAmB;YACtB,GAAG,CAAC,8BAA8B,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;SACnD,CAAC;IACJ,CAAC;CACF;AAvOD,oEAuOC;AAED,oCAAoC;AACvB,QAAA,4BAA4B,GAAG,IAAI,4BAA4B,CAC1E,IAAI,+BAAc,EAAE,CACrB,CAAC"}
@@ -0,0 +1,67 @@
1
+ import { KnowledgeGraph } from '../../alme/core/KnowledgeGraph';
2
+ declare enum CodeGenerationContext {
3
+ MobileApp = 0,
4
+ WebService = 1,
5
+ SystemIntegration = 2,
6
+ MachineLearning = 3,
7
+ ServerlessArchitecture = 4
8
+ }
9
+ interface CodeGenerationRequest {
10
+ context: CodeGenerationContext;
11
+ domain: string;
12
+ specificRequirements: string[];
13
+ constraints: {
14
+ performanceTarget?: number;
15
+ memoryLimit?: number;
16
+ scalabilityRequirements?: string;
17
+ };
18
+ }
19
+ export declare class ContextAwareCodeGenerator {
20
+ private knowledgeGraph;
21
+ private codeTemplates;
22
+ constructor(knowledgeGraph: KnowledgeGraph);
23
+ /**
24
+ * Generate context-aware code
25
+ * @param request Code generation requirements
26
+ * @returns Generated code snippet
27
+ */
28
+ generateCode(request: CodeGenerationRequest): Promise<string>;
29
+ /**
30
+ * Retrieve appropriate code template
31
+ * @param context Generation context
32
+ * @returns Matching code template
33
+ */
34
+ private getCodeTemplate;
35
+ /**
36
+ * Enrich template with contextual insights
37
+ * @param template Base code template
38
+ * @param contextNodes Related knowledge graph nodes
39
+ * @param request Generation request
40
+ * @returns Enhanced template
41
+ */
42
+ private enrichTemplateWithContextualInsights;
43
+ /**
44
+ * Fill template with specific implementation details
45
+ * @param template Enhanced code template
46
+ * @param request Generation request
47
+ * @returns Specific code implementation
48
+ */
49
+ private fillTemplateWithSpecifics;
50
+ /**
51
+ * Validate generated code
52
+ * @param code Generated code snippet
53
+ * @param request Original generation request
54
+ * @returns Validation result
55
+ */
56
+ private validateGeneratedCode;
57
+ /**
58
+ * Refine generated code based on feedback
59
+ * @param code Original generated code
60
+ * @param feedback Validation feedback
61
+ * @returns Improved code
62
+ */
63
+ private refineCode;
64
+ }
65
+ export declare const contextAwareCodeGenerator: ContextAwareCodeGenerator;
66
+ export {};
67
+ //# sourceMappingURL=ContextAwareGenerator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContextAwareGenerator.d.ts","sourceRoot":"","sources":["../../src/codegen/ContextAwareGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAGhE,aAAK,qBAAqB;IACxB,SAAS,IAAA;IACT,UAAU,IAAA;IACV,iBAAiB,IAAA;IACjB,eAAe,IAAA;IACf,sBAAsB,IAAA;CACvB;AAGD,UAAU,qBAAqB;IAC7B,OAAO,EAAE,qBAAqB,CAAC;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,WAAW,EAAE;QACX,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,uBAAuB,CAAC,EAAE,MAAM,CAAC;KAClC,CAAC;CACH;AASD,qBAAa,yBAAyB;IACpC,OAAO,CAAC,cAAc,CAAiB;IAGvC,OAAO,CAAC,aAAa,CA2ClB;gBAES,cAAc,EAAE,cAAc;IAI1C;;;;OAIG;IACG,YAAY,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,MAAM,CAAC;IA+BnE;;;;OAIG;IACH,OAAO,CAAC,eAAe;IAQvB;;;;;;OAMG;IACH,OAAO,CAAC,oCAAoC;IAmB5C;;;;;OAKG;IACH,OAAO,CAAC,yBAAyB;IAUjC;;;;;OAKG;YACW,qBAAqB;IAoBnC;;;;;OAKG;IACH,OAAO,CAAC,UAAU;CAMnB;AAGD,eAAO,MAAM,yBAAyB,2BAErC,CAAC"}
@@ -0,0 +1,158 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.contextAwareCodeGenerator = exports.ContextAwareCodeGenerator = void 0;
4
+ const KnowledgeGraph_1 = require("../../alme/core/KnowledgeGraph");
5
+ // Enum for different code generation contexts
6
+ var CodeGenerationContext;
7
+ (function (CodeGenerationContext) {
8
+ CodeGenerationContext[CodeGenerationContext["MobileApp"] = 0] = "MobileApp";
9
+ CodeGenerationContext[CodeGenerationContext["WebService"] = 1] = "WebService";
10
+ CodeGenerationContext[CodeGenerationContext["SystemIntegration"] = 2] = "SystemIntegration";
11
+ CodeGenerationContext[CodeGenerationContext["MachineLearning"] = 3] = "MachineLearning";
12
+ CodeGenerationContext[CodeGenerationContext["ServerlessArchitecture"] = 4] = "ServerlessArchitecture";
13
+ })(CodeGenerationContext || (CodeGenerationContext = {}));
14
+ class ContextAwareCodeGenerator {
15
+ knowledgeGraph;
16
+ // Predefined code templates for different contexts
17
+ codeTemplates = new Map([
18
+ [CodeGenerationContext.MobileApp, {
19
+ language: 'Swift',
20
+ structure: `
21
+ import UIKit
22
+ import DeviceActivity
23
+
24
+ class {ClassName}: {BaseClass} {
25
+ // Context-aware app blocking implementation
26
+ func implementAppBlocking() {
27
+ // Dynamic implementation based on context
28
+ }
29
+ }`,
30
+ bestPractices: [
31
+ 'Use DeviceActivity framework',
32
+ 'Implement granular permission handling',
33
+ 'Ensure privacy compliance'
34
+ ]
35
+ }],
36
+ [CodeGenerationContext.WebService, {
37
+ language: 'TypeScript',
38
+ structure: `
39
+ import express from 'express';
40
+ import { AuthMiddleware } from './middleware/auth';
41
+
42
+ class {ClassName} {
43
+ private app: express.Application;
44
+
45
+ constructor() {
46
+ this.app = express();
47
+ this.configureMiddlewares();
48
+ }
49
+
50
+ private configureMiddlewares() {
51
+ // Intelligent middleware configuration
52
+ }
53
+ }`,
54
+ bestPractices: [
55
+ 'Implement robust error handling',
56
+ 'Use dependency injection',
57
+ 'Create modular architecture'
58
+ ]
59
+ }]
60
+ ]);
61
+ constructor(knowledgeGraph) {
62
+ this.knowledgeGraph = knowledgeGraph;
63
+ }
64
+ /**
65
+ * Generate context-aware code
66
+ * @param request Code generation requirements
67
+ * @returns Generated code snippet
68
+ */
69
+ async generateCode(request) {
70
+ // 1. Retrieve appropriate code template
71
+ const template = this.getCodeTemplate(request.context);
72
+ // 2. Analyze related knowledge graph nodes
73
+ const contextNodes = this.knowledgeGraph.findRelatedConcepts(request.domain, 2 // Depth of knowledge exploration
74
+ );
75
+ // 3. Enhance template with contextual insights
76
+ const enhancedTemplate = this.enrichTemplateWithContextualInsights(template, contextNodes, request);
77
+ // 4. Generate specific implementation
78
+ const generatedCode = this.fillTemplateWithSpecifics(enhancedTemplate, request);
79
+ // 5. Validate generated code
80
+ const validationResult = await this.validateGeneratedCode(generatedCode, request);
81
+ return validationResult.isValid
82
+ ? generatedCode
83
+ : this.refineCode(generatedCode, validationResult.feedback);
84
+ }
85
+ /**
86
+ * Retrieve appropriate code template
87
+ * @param context Generation context
88
+ * @returns Matching code template
89
+ */
90
+ getCodeTemplate(context) {
91
+ const template = this.codeTemplates.get(context);
92
+ if (!template) {
93
+ throw new Error(`No template found for context: ${context}`);
94
+ }
95
+ return template;
96
+ }
97
+ /**
98
+ * Enrich template with contextual insights
99
+ * @param template Base code template
100
+ * @param contextNodes Related knowledge graph nodes
101
+ * @param request Generation request
102
+ * @returns Enhanced template
103
+ */
104
+ enrichTemplateWithContextualInsights(template, contextNodes, request) {
105
+ // Extract insights from knowledge graph
106
+ const contextualInsights = contextNodes.map(node => node.content).join('\n');
107
+ return {
108
+ ...template,
109
+ structure: template.structure.replace('// Dynamic implementation based on context', `// Contextual insights: ${contextualInsights}\n // Dynamic implementation`)
110
+ };
111
+ }
112
+ /**
113
+ * Fill template with specific implementation details
114
+ * @param template Enhanced code template
115
+ * @param request Generation request
116
+ * @returns Specific code implementation
117
+ */
118
+ fillTemplateWithSpecifics(template, request) {
119
+ // Replace placeholders with specific implementation
120
+ return template.structure
121
+ .replace('{ClassName}', `${request.domain}Generator`)
122
+ .replace('{BaseClass}', 'NSObject');
123
+ }
124
+ /**
125
+ * Validate generated code
126
+ * @param code Generated code snippet
127
+ * @param request Original generation request
128
+ * @returns Validation result
129
+ */
130
+ async validateGeneratedCode(code, request) {
131
+ // Simulate code validation
132
+ // In a real implementation, this would use more sophisticated
133
+ // static analysis and potential compilation checking
134
+ const hasRequiredImplementation = code.includes('implementAppBlocking');
135
+ return {
136
+ isValid: hasRequiredImplementation,
137
+ feedback: !hasRequiredImplementation
138
+ ? 'Missing required method implementation'
139
+ : undefined
140
+ };
141
+ }
142
+ /**
143
+ * Refine generated code based on feedback
144
+ * @param code Original generated code
145
+ * @param feedback Validation feedback
146
+ * @returns Improved code
147
+ */
148
+ refineCode(code, feedback) {
149
+ if (!feedback)
150
+ return code;
151
+ // Simple refinement strategy
152
+ return code + `\n // Refined based on: ${feedback}`;
153
+ }
154
+ }
155
+ exports.ContextAwareCodeGenerator = ContextAwareCodeGenerator;
156
+ // Singleton instance for global use
157
+ exports.contextAwareCodeGenerator = new ContextAwareCodeGenerator(new KnowledgeGraph_1.KnowledgeGraph());
158
+ //# sourceMappingURL=ContextAwareGenerator.js.map