crewly 1.4.40 → 1.4.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/orchestrator_tasks/prompts/orchestrator-prompt.md +11 -11
- package/config/roles/architect/prompt.md +1 -5
- package/config/roles/backend-developer/prompt.md +1 -5
- package/config/roles/content-strategist/prompt.md +1 -5
- package/config/roles/designer/prompt.md +1 -5
- package/config/roles/developer/prompt.md +1 -7
- package/config/roles/developer/soul.md +18 -0
- package/config/roles/frontend-developer/prompt.md +1 -5
- package/config/roles/fullstack-dev/prompt.md +1 -5
- package/config/roles/generalist/prompt.md +1 -7
- package/config/roles/ops/prompt.md +1 -7
- package/config/roles/orchestrator/prompt.md +44 -44
- package/config/roles/orchestrator/soul.md +18 -0
- package/config/roles/product-manager/prompt.md +1 -5
- package/config/roles/qa/prompt.md +1 -5
- package/config/roles/qa-engineer/prompt.md +1 -5
- package/config/roles/researcher/prompt.md +1 -5
- package/config/roles/researcher/soul.md +18 -0
- package/config/roles/sales/prompt.md +1 -5
- package/config/roles/support/prompt.md +1 -5
- package/config/roles/team-leader/prompt.md +2 -6
- package/config/roles/tpm/prompt.md +1 -5
- package/config/roles/ux-designer/prompt.md +1 -5
- package/config/souls/developer.md +30 -0
- package/config/souls/orchestrator.md +30 -0
- package/config/souls/researcher.md +30 -0
- package/config/templates/agent-claude-md.md +1 -1
- package/dist/backend/backend/src/services/agent/agent-registration.service.d.ts.map +1 -1
- package/dist/backend/backend/src/services/agent/agent-registration.service.js +12 -7
- package/dist/backend/backend/src/services/agent/agent-registration.service.js.map +1 -1
- package/dist/backend/backend/src/services/agent/oauth-relogin-monitor.service.d.ts.map +1 -1
- package/dist/backend/backend/src/services/agent/oauth-relogin-monitor.service.js +16 -4
- package/dist/backend/backend/src/services/agent/oauth-relogin-monitor.service.js.map +1 -1
- package/dist/backend/backend/src/services/agent/runtime-agent.service.abstract.d.ts.map +1 -1
- package/dist/backend/backend/src/services/agent/runtime-agent.service.abstract.js +11 -0
- package/dist/backend/backend/src/services/agent/runtime-agent.service.abstract.js.map +1 -1
- package/dist/backend/backend/src/services/ai/prompt-modules/communication.module.d.ts +46 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/communication.module.d.ts.map +1 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/communication.module.js +145 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/communication.module.js.map +1 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/context-assembly.service.d.ts +129 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/context-assembly.service.d.ts.map +1 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/context-assembly.service.js +202 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/context-assembly.service.js.map +1 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/identity.module.d.ts +28 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/identity.module.d.ts.map +1 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/identity.module.js +47 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/identity.module.js.map +1 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/index.d.ts +22 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/index.d.ts.map +1 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/index.js +26 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/index.js.map +1 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/learning-reference.module.d.ts +28 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/learning-reference.module.d.ts.map +1 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/learning-reference.module.js +55 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/learning-reference.module.js.map +1 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/lifecycle.module.d.ts +44 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/lifecycle.module.d.ts.map +1 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/lifecycle.module.js +112 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/lifecycle.module.js.map +1 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/memory-reference.module.d.ts +28 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/memory-reference.module.d.ts.map +1 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/memory-reference.module.js +46 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/memory-reference.module.js.map +1 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/project-reference.module.d.ts +29 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/project-reference.module.d.ts.map +1 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/project-reference.module.js +50 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/project-reference.module.js.map +1 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/prompt-assembly.service.d.ts +86 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/prompt-assembly.service.d.ts.map +1 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/prompt-assembly.service.js +212 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/prompt-assembly.service.js.map +1 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/prompt-module.interface.d.ts +100 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/prompt-module.interface.d.ts.map +1 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/prompt-module.interface.js +23 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/prompt-module.interface.js.map +1 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/recovery.module.d.ts +34 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/recovery.module.d.ts.map +1 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/recovery.module.js +61 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/recovery.module.js.map +1 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/scheduled-messages.loader.d.ts +55 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/scheduled-messages.loader.d.ts.map +1 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/scheduled-messages.loader.js +96 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/scheduled-messages.loader.js.map +1 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/skills-reference.module.d.ts +28 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/skills-reference.module.d.ts.map +1 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/skills-reference.module.js +65 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/skills-reference.module.js.map +1 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/soul.module.d.ts +60 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/soul.module.d.ts.map +1 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/soul.module.js +112 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/soul.module.js.map +1 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/team-reference.module.d.ts +54 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/team-reference.module.d.ts.map +1 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/team-reference.module.js +149 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/team-reference.module.js.map +1 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/user-profile-reference.module.d.ts +28 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/user-profile-reference.module.d.ts.map +1 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/user-profile-reference.module.js +53 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/user-profile-reference.module.js.map +1 -0
- package/dist/backend/backend/src/services/prompt/prompt-generator.service.d.ts.map +1 -1
- package/dist/backend/backend/src/services/prompt/prompt-generator.service.js +9 -11
- package/dist/backend/backend/src/services/prompt/prompt-generator.service.js.map +1 -1
- package/dist/backend/backend/src/services/skill/skill-catalog.service.d.ts.map +1 -1
- package/dist/backend/backend/src/services/skill/skill-catalog.service.js +3 -1
- package/dist/backend/backend/src/services/skill/skill-catalog.service.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { LoggerService } from '../../core/logger.service.js';
|
|
2
|
+
import { estimateTokens } from './prompt-module.interface.js';
|
|
3
|
+
/**
|
|
4
|
+
* Default total token budget for all context modules combined.
|
|
5
|
+
*/
|
|
6
|
+
const DEFAULT_CONTEXT_BUDGET = 15000;
|
|
7
|
+
/**
|
|
8
|
+
* Service that manages runtime context assembly for agents.
|
|
9
|
+
*
|
|
10
|
+
* Unlike prompt modules (static, assembled once at startup), context modules
|
|
11
|
+
* contain dynamic data that can be refreshed mid-session. Context is compactable
|
|
12
|
+
* by F13 ContextWindowMonitor.
|
|
13
|
+
*
|
|
14
|
+
* Responsibilities:
|
|
15
|
+
* - Registers context loaders for different data sources
|
|
16
|
+
* - Loads and assembles context on demand
|
|
17
|
+
* - Supports mid-session refresh without full rebuild
|
|
18
|
+
* - Enforces context token budgets
|
|
19
|
+
* - Tracks loaded context for cache/refresh management
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const contextService = new ContextAssemblyService();
|
|
24
|
+
*
|
|
25
|
+
* contextService.registerLoader('memory', async (config) => {
|
|
26
|
+
* const memoryService = MemoryService.getInstance();
|
|
27
|
+
* return memoryService.getFullContext(config.agentId, config.projectPath);
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* const context = await contextService.loadAll({
|
|
31
|
+
* agentId: 'crewly-dev-001',
|
|
32
|
+
* role: 'developer',
|
|
33
|
+
* projectPath: '/path/to/project',
|
|
34
|
+
* });
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export class ContextAssemblyService {
|
|
38
|
+
logger;
|
|
39
|
+
loaders = new Map();
|
|
40
|
+
cache = new Map();
|
|
41
|
+
totalTokenBudget;
|
|
42
|
+
constructor(tokenBudget = DEFAULT_CONTEXT_BUDGET) {
|
|
43
|
+
this.logger = LoggerService.getInstance().createComponentLogger('ContextAssemblyService');
|
|
44
|
+
this.totalTokenBudget = tokenBudget;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Register a context loader for a named context module.
|
|
48
|
+
*
|
|
49
|
+
* @param name - Context module name (e.g., 'memory', 'team_context')
|
|
50
|
+
* @param loader - Async function that loads context data
|
|
51
|
+
*/
|
|
52
|
+
registerLoader(name, loader) {
|
|
53
|
+
this.loaders.set(name, loader);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Remove a registered context loader.
|
|
57
|
+
*
|
|
58
|
+
* @param name - Context module name to remove
|
|
59
|
+
*/
|
|
60
|
+
removeLoader(name) {
|
|
61
|
+
this.loaders.delete(name);
|
|
62
|
+
this.cache.delete(name);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Get names of all registered loaders.
|
|
66
|
+
*
|
|
67
|
+
* @returns Array of registered loader names
|
|
68
|
+
*/
|
|
69
|
+
getLoaderNames() {
|
|
70
|
+
return Array.from(this.loaders.keys());
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Load a single context module by name.
|
|
74
|
+
*
|
|
75
|
+
* @param name - Context module name
|
|
76
|
+
* @param config - Loader configuration
|
|
77
|
+
* @param useCache - Whether to return cached result if available (default: false)
|
|
78
|
+
* @returns Context load result or null if loader not found
|
|
79
|
+
*/
|
|
80
|
+
async load(name, config, useCache = false) {
|
|
81
|
+
if (useCache && this.cache.has(name)) {
|
|
82
|
+
return this.cache.get(name) || null;
|
|
83
|
+
}
|
|
84
|
+
const loader = this.loaders.get(name);
|
|
85
|
+
if (!loader) {
|
|
86
|
+
this.logger.warn(`No context loader registered for '${name}'`);
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
try {
|
|
90
|
+
const content = await loader(config);
|
|
91
|
+
const result = {
|
|
92
|
+
name,
|
|
93
|
+
content: content || '',
|
|
94
|
+
estimatedTokens: estimateTokens(content || ''),
|
|
95
|
+
loadedAt: new Date(),
|
|
96
|
+
};
|
|
97
|
+
this.cache.set(name, result);
|
|
98
|
+
this.logger.debug(`Context '${name}' loaded`, {
|
|
99
|
+
agentId: config.agentId,
|
|
100
|
+
tokens: result.estimatedTokens,
|
|
101
|
+
});
|
|
102
|
+
return result;
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
this.logger.error(`Context loader '${name}' failed`, {
|
|
106
|
+
agentId: config.agentId,
|
|
107
|
+
error: error instanceof Error ? error.message : String(error),
|
|
108
|
+
});
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Load all registered context modules and assemble into a single string.
|
|
114
|
+
*
|
|
115
|
+
* @param config - Loader configuration
|
|
116
|
+
* @returns Assembled context string
|
|
117
|
+
*/
|
|
118
|
+
async loadAll(config) {
|
|
119
|
+
const results = [];
|
|
120
|
+
let totalTokens = 0;
|
|
121
|
+
for (const [name, loader] of this.loaders.entries()) {
|
|
122
|
+
try {
|
|
123
|
+
const content = await loader(config);
|
|
124
|
+
if (content && content.trim()) {
|
|
125
|
+
const tokens = estimateTokens(content);
|
|
126
|
+
// Skip if adding this context would exceed budget
|
|
127
|
+
if (totalTokens + tokens > this.totalTokenBudget) {
|
|
128
|
+
this.logger.info(`Context '${name}' skipped (budget exceeded)`, {
|
|
129
|
+
agentId: config.agentId,
|
|
130
|
+
currentTokens: totalTokens,
|
|
131
|
+
contextTokens: tokens,
|
|
132
|
+
budget: this.totalTokenBudget,
|
|
133
|
+
});
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
const result = {
|
|
137
|
+
name,
|
|
138
|
+
content: content.trim(),
|
|
139
|
+
estimatedTokens: tokens,
|
|
140
|
+
loadedAt: new Date(),
|
|
141
|
+
};
|
|
142
|
+
results.push(result);
|
|
143
|
+
this.cache.set(name, result);
|
|
144
|
+
totalTokens += tokens;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
this.logger.error(`Context loader '${name}' failed`, {
|
|
149
|
+
agentId: config.agentId,
|
|
150
|
+
error: error instanceof Error ? error.message : String(error),
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
this.logger.info('Context assembly complete', {
|
|
155
|
+
agentId: config.agentId,
|
|
156
|
+
loaderCount: results.length,
|
|
157
|
+
totalTokens,
|
|
158
|
+
budget: this.totalTokenBudget,
|
|
159
|
+
modules: results.map((r) => r.name),
|
|
160
|
+
});
|
|
161
|
+
return results.map((r) => r.content).join('\n\n---\n\n');
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Refresh a specific context module (reload from source).
|
|
165
|
+
*
|
|
166
|
+
* @param name - Context module name to refresh
|
|
167
|
+
* @param config - Loader configuration
|
|
168
|
+
* @returns Refreshed context or null
|
|
169
|
+
*/
|
|
170
|
+
async refresh(name, config) {
|
|
171
|
+
this.cache.delete(name);
|
|
172
|
+
return this.load(name, config, false);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Clear all cached context data.
|
|
176
|
+
*/
|
|
177
|
+
clearCache() {
|
|
178
|
+
this.cache.clear();
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Get cached context by name (without reloading).
|
|
182
|
+
*
|
|
183
|
+
* @param name - Context module name
|
|
184
|
+
* @returns Cached result or null
|
|
185
|
+
*/
|
|
186
|
+
getCached(name) {
|
|
187
|
+
return this.cache.get(name) || null;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Get or set the total token budget.
|
|
191
|
+
*
|
|
192
|
+
* @param budget - Optional new budget to set
|
|
193
|
+
* @returns Current token budget
|
|
194
|
+
*/
|
|
195
|
+
tokenBudget(budget) {
|
|
196
|
+
if (budget !== undefined) {
|
|
197
|
+
this.totalTokenBudget = budget;
|
|
198
|
+
}
|
|
199
|
+
return this.totalTokenBudget;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
//# sourceMappingURL=context-assembly.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-assembly.service.js","sourceRoot":"","s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AC;iBAC7D,CAAC,CAAC;YACJ,CAAC;QACF,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,2BAA2B,EAAE;YAC7C,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,WAAW,EAAE,OAAO,CAAC,MAAM;YAC3B,WAAW;YACX,MAAM,EAAE,IAAI,CAAC,gBAAgB;YAC7B,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;SACnC,CAAC,CAAC;QAEH,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC1D,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,OAAO,CAAC,IAAY,EAAE,MAA2B;QACtD,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACxB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IACvC,CAAC;IAED;;OAEG;IACH,UAAU;QACT,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACpB,CAAC;IAED;;;;;OAKG;IACH,SAAS,CAAC,IAAY;QACrB,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;IACrC,CAAC;IAED;;;;;OAKG;IACH,WAAW,CAAC,MAAe;QAC1B,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YAC1B,IAAI,CAAC,gBAAgB,GAAG,MAAM,CAAC;QAChC,CAAC;QACD,OAAO,IAAI,CAAC,gBAAgB,CAAC;IAC9B,CAAC;CACD"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { PromptModule, ModuleConfig } from './prompt-module.interface.js';
|
|
2
|
+
/**
|
|
3
|
+
* Identity module — provides the agent's core identification.
|
|
4
|
+
*
|
|
5
|
+
* Assembles session name, member ID, role, team, and project path
|
|
6
|
+
* into a structured identity section. This is the highest-priority
|
|
7
|
+
* module and is never truncated.
|
|
8
|
+
*
|
|
9
|
+
* Sources: Path A Step 2+10, Path B Section 6, Path C header.
|
|
10
|
+
*/
|
|
11
|
+
export declare class IdentityModule implements PromptModule {
|
|
12
|
+
name: string;
|
|
13
|
+
priority: number;
|
|
14
|
+
maxTokens: number;
|
|
15
|
+
compactable: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Always included — every agent needs an identity.
|
|
18
|
+
*/
|
|
19
|
+
shouldInclude(_config: ModuleConfig): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Build the identity section with all available fields.
|
|
22
|
+
*
|
|
23
|
+
* @param config - Module configuration with agent details
|
|
24
|
+
* @returns Formatted markdown identity section
|
|
25
|
+
*/
|
|
26
|
+
build(config: ModuleConfig): Promise<string>;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=identity.module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.module.d.ts","sourceRoot":"","sources":["../../../../../../../backend/src/services/ai/prompt-modules/identity.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE1E;;;;;;;;GAQG;AACH,qBAAa,cAAe,YAAW,YAAY;IAClD,IAAI,SAAc;IAClB,QAAQ,SAAK;IACb,SAAS,SAAO;IAChB,WAAW,UAAS;IAEpB;;OAEG;IACH,aAAa,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO;IAI7C;;;;;OAKG;IACG,KAAK,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC;CAqBlD"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identity module — provides the agent's core identification.
|
|
3
|
+
*
|
|
4
|
+
* Assembles session name, member ID, role, team, and project path
|
|
5
|
+
* into a structured identity section. This is the highest-priority
|
|
6
|
+
* module and is never truncated.
|
|
7
|
+
*
|
|
8
|
+
* Sources: Path A Step 2+10, Path B Section 6, Path C header.
|
|
9
|
+
*/
|
|
10
|
+
export class IdentityModule {
|
|
11
|
+
name = 'identity';
|
|
12
|
+
priority = 1;
|
|
13
|
+
maxTokens = 150;
|
|
14
|
+
compactable = false;
|
|
15
|
+
/**
|
|
16
|
+
* Always included — every agent needs an identity.
|
|
17
|
+
*/
|
|
18
|
+
shouldInclude(_config) {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Build the identity section with all available fields.
|
|
23
|
+
*
|
|
24
|
+
* @param config - Module configuration with agent details
|
|
25
|
+
* @returns Formatted markdown identity section
|
|
26
|
+
*/
|
|
27
|
+
async build(config) {
|
|
28
|
+
const lines = ['## Your Identity'];
|
|
29
|
+
if (config.sessionName) {
|
|
30
|
+
lines.push(`- **Session Name:** ${config.sessionName}`);
|
|
31
|
+
}
|
|
32
|
+
if (config.memberId) {
|
|
33
|
+
lines.push(`- **Member ID:** ${config.memberId}`);
|
|
34
|
+
}
|
|
35
|
+
if (config.role) {
|
|
36
|
+
lines.push(`- **Role:** ${config.role}`);
|
|
37
|
+
}
|
|
38
|
+
if (config.teamId) {
|
|
39
|
+
lines.push(`- **Team:** ${config.teamId}`);
|
|
40
|
+
}
|
|
41
|
+
if (config.projectPath) {
|
|
42
|
+
lines.push(`- **Project Path:** ${config.projectPath}`);
|
|
43
|
+
}
|
|
44
|
+
return lines.join('\n');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=identity.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.module.js","sourceRoot":"","sources":["../../../../../../../backend/src/services/ai/prompt-modules/identity.module.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,MAAM,OAAO,cAAc;IAC1B,IAAI,GAAG,UAAU,CAAC;IAClB,QAAQ,GAAG,CAAC,CAAC;IACb,SAAS,GAAG,GAAG,CAAC;IAChB,WAAW,GAAG,KAAK,CAAC;IAEpB;;OAEG;IACH,aAAa,CAAC,OAAqB;QAClC,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,KAAK,CAAC,MAAoB;QAC/B,MAAM,KAAK,GAAa,CAAC,kBAAkB,CAAC,CAAC;QAE7C,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;YACxB,KAAK,CAAC,IAAI,CAAC,uBAAuB,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC;QACzD,CAAC;QACD,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;YACrB,KAAK,CAAC,IAAI,CAAC,oBAAoB,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;QACnD,CAAC;QACD,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;YACjB,KAAK,CAAC,IAAI,CAAC,eAAe,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;QAC1C,CAAC;QACD,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YACnB,KAAK,CAAC,IAAI,CAAC,eAAe,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;QAC5C,CAAC;QACD,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;YACxB,KAAK,CAAC,IAAI,CAAC,uBAAuB,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC;QACzD,CAAC;QAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;CACD"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompt Modules — Modular prompt assembly system.
|
|
3
|
+
*
|
|
4
|
+
* Re-exports all prompt module interfaces, implementations,
|
|
5
|
+
* and assembly services from a single entry point.
|
|
6
|
+
*/
|
|
7
|
+
export { PromptModule, ModuleConfig, SubordinateInfoCompat, ModuleBuildResult, estimateTokens, } from './prompt-module.interface.js';
|
|
8
|
+
export { IdentityModule } from './identity.module.js';
|
|
9
|
+
export { SoulModule } from './soul.module.js';
|
|
10
|
+
export { SkillsReferenceModule } from './skills-reference.module.js';
|
|
11
|
+
export { MemoryReferenceModule } from './memory-reference.module.js';
|
|
12
|
+
export { TeamReferenceModule } from './team-reference.module.js';
|
|
13
|
+
export { ProjectReferenceModule } from './project-reference.module.js';
|
|
14
|
+
export { UserProfileReferenceModule } from './user-profile-reference.module.js';
|
|
15
|
+
export { LearningReferenceModule } from './learning-reference.module.js';
|
|
16
|
+
export { CommunicationModule } from './communication.module.js';
|
|
17
|
+
export { RecoveryModule } from './recovery.module.js';
|
|
18
|
+
export { LifecycleModule } from './lifecycle.module.js';
|
|
19
|
+
export { createScheduledMessagesLoader, ScheduledCheckInfo, ScheduledChecksProvider, } from './scheduled-messages.loader.js';
|
|
20
|
+
export { PromptAssemblyService } from './prompt-assembly.service.js';
|
|
21
|
+
export { ContextAssemblyService } from './context-assembly.service.js';
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../backend/src/services/ai/prompt-modules/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACN,YAAY,EACZ,YAAY,EACZ,qBAAqB,EACrB,iBAAiB,EACjB,cAAc,GACd,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAChF,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAGxD,OAAO,EACN,6BAA6B,EAC7B,kBAAkB,EAClB,uBAAuB,GACvB,MAAM,gCAAgC,CAAC;AAGxC,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompt Modules — Modular prompt assembly system.
|
|
3
|
+
*
|
|
4
|
+
* Re-exports all prompt module interfaces, implementations,
|
|
5
|
+
* and assembly services from a single entry point.
|
|
6
|
+
*/
|
|
7
|
+
// Interface and utilities
|
|
8
|
+
export { estimateTokens, } from './prompt-module.interface.js';
|
|
9
|
+
// Prompt modules
|
|
10
|
+
export { IdentityModule } from './identity.module.js';
|
|
11
|
+
export { SoulModule } from './soul.module.js';
|
|
12
|
+
export { SkillsReferenceModule } from './skills-reference.module.js';
|
|
13
|
+
export { MemoryReferenceModule } from './memory-reference.module.js';
|
|
14
|
+
export { TeamReferenceModule } from './team-reference.module.js';
|
|
15
|
+
export { ProjectReferenceModule } from './project-reference.module.js';
|
|
16
|
+
export { UserProfileReferenceModule } from './user-profile-reference.module.js';
|
|
17
|
+
export { LearningReferenceModule } from './learning-reference.module.js';
|
|
18
|
+
export { CommunicationModule } from './communication.module.js';
|
|
19
|
+
export { RecoveryModule } from './recovery.module.js';
|
|
20
|
+
export { LifecycleModule } from './lifecycle.module.js';
|
|
21
|
+
// Context loaders
|
|
22
|
+
export { createScheduledMessagesLoader, } from './scheduled-messages.loader.js';
|
|
23
|
+
// Assembly services
|
|
24
|
+
export { PromptAssemblyService } from './prompt-assembly.service.js';
|
|
25
|
+
export { ContextAssemblyService } from './context-assembly.service.js';
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../backend/src/services/ai/prompt-modules/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,0BAA0B;AAC1B,OAAO,EAKN,cAAc,GACd,MAAM,8BAA8B,CAAC;AAEtC,iBAAiB;AACjB,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAChF,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,kBAAkB;AAClB,OAAO,EACN,6BAA6B,GAG7B,MAAM,gCAAgC,CAAC;AAExC,oBAAoB;AACpB,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { PromptModule, ModuleConfig } from './prompt-module.interface.js';
|
|
2
|
+
/**
|
|
3
|
+
* Learning reference module — tells the agent how to access and leverage past learnings.
|
|
4
|
+
*
|
|
5
|
+
* Provides instructions for using record-learning, recalling past experiences,
|
|
6
|
+
* and applying lessons learned from previous sessions.
|
|
7
|
+
*
|
|
8
|
+
* Sources: LearningAccumulationService, record-learning skill.
|
|
9
|
+
*/
|
|
10
|
+
export declare class LearningReferenceModule implements PromptModule {
|
|
11
|
+
name: string;
|
|
12
|
+
priority: number;
|
|
13
|
+
maxTokens: number;
|
|
14
|
+
compactable: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Always included — agents should know how to learn from experience.
|
|
17
|
+
*/
|
|
18
|
+
shouldInclude(_config: ModuleConfig): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Build the learning reference section with instructions
|
|
21
|
+
* on how to record and recall past learnings.
|
|
22
|
+
*
|
|
23
|
+
* @param config - Module configuration with agent skill paths
|
|
24
|
+
* @returns Formatted markdown learning reference section
|
|
25
|
+
*/
|
|
26
|
+
build(config: ModuleConfig): Promise<string>;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=learning-reference.module.d.ts.map
|
package/dist/backend/backend/src/services/ai/prompt-modules/learning-reference.module.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"learning-reference.module.d.ts","sourceRoot":"","sources":["../../../../../../../backend/src/services/ai/prompt-modules/learning-reference.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE1E;;;;;;;GAOG;AACH,qBAAa,uBAAwB,YAAW,YAAY;IAC3D,IAAI,SAAyB;IAC7B,QAAQ,SAAM;IACd,SAAS,SAAO;IAChB,WAAW,UAAQ;IAEnB;;OAEG;IACH,aAAa,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO;IAI7C;;;;;;OAMG;IACG,KAAK,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC;CA2BlD"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Learning reference module — tells the agent how to access and leverage past learnings.
|
|
3
|
+
*
|
|
4
|
+
* Provides instructions for using record-learning, recalling past experiences,
|
|
5
|
+
* and applying lessons learned from previous sessions.
|
|
6
|
+
*
|
|
7
|
+
* Sources: LearningAccumulationService, record-learning skill.
|
|
8
|
+
*/
|
|
9
|
+
export class LearningReferenceModule {
|
|
10
|
+
name = 'learning_references';
|
|
11
|
+
priority = 10;
|
|
12
|
+
maxTokens = 250;
|
|
13
|
+
compactable = true;
|
|
14
|
+
/**
|
|
15
|
+
* Always included — agents should know how to learn from experience.
|
|
16
|
+
*/
|
|
17
|
+
shouldInclude(_config) {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Build the learning reference section with instructions
|
|
22
|
+
* on how to record and recall past learnings.
|
|
23
|
+
*
|
|
24
|
+
* @param config - Module configuration with agent skill paths
|
|
25
|
+
* @returns Formatted markdown learning reference section
|
|
26
|
+
*/
|
|
27
|
+
async build(config) {
|
|
28
|
+
return `## Learning from Experience
|
|
29
|
+
|
|
30
|
+
### Recording Learnings
|
|
31
|
+
When you discover something worth remembering for future sessions, record it immediately:
|
|
32
|
+
\`\`\`bash
|
|
33
|
+
bash ${config.agentSkillsPath}/core/record-learning/execute.sh '{"agentId":"${config.sessionName}","agentRole":"${config.role}","projectPath":"${config.projectPath || ''}","learning":"<what you learned>"}'
|
|
34
|
+
\`\`\`
|
|
35
|
+
|
|
36
|
+
**When to record:**
|
|
37
|
+
- After resolving a bug — capture the root cause and fix
|
|
38
|
+
- After discovering a code pattern or convention
|
|
39
|
+
- After a failed approach — capture what didn't work and why
|
|
40
|
+
- After completing a task — capture key findings and gotchas
|
|
41
|
+
- When you find something that contradicts your assumptions
|
|
42
|
+
|
|
43
|
+
### Recalling Learnings
|
|
44
|
+
Before starting a task, check what you or other agents have learned:
|
|
45
|
+
\`\`\`bash
|
|
46
|
+
bash ${config.agentSkillsPath}/core/recall/execute.sh '{"agentId":"${config.sessionName}","context":"learnings about <topic>","projectPath":"${config.projectPath || ''}"}'
|
|
47
|
+
\`\`\`
|
|
48
|
+
|
|
49
|
+
### Applying Learnings
|
|
50
|
+
- Check for relevant learnings before repeating an approach that may have failed before
|
|
51
|
+
- Cross-reference learnings from other agents working on the same project
|
|
52
|
+
- Update or correct stale learnings when you discover they no longer apply`;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=learning-reference.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"learning-reference.module.js","sourceRoot":"","sources":["../../../../../../../backend/src/services/ai/prompt-modules/learning-reference.module.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,MAAM,OAAO,uBAAuB;IACnC,IAAI,GAAG,qBAAqB,CAAC;IAC7B,QAAQ,GAAG,EAAE,CAAC;IACd,SAAS,GAAG,GAAG,CAAC;IAChB,WAAW,GAAG,IAAI,CAAC;IAEnB;;OAEG;IACH,aAAa,CAAC,OAAqB;QAClC,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,KAAK,CAAC,MAAoB;QAC/B,OAAO;;;;;OAKF,MAAM,CAAC,eAAe,iDAAiD,MAAM,CAAC,WAAW,kBAAkB,MAAM,CAAC,IAAI,oBAAoB,MAAM,CAAC,WAAW,IAAI,EAAE;;;;;;;;;;;;;OAalK,MAAM,CAAC,eAAe,wCAAwC,MAAM,CAAC,WAAW,wDAAwD,MAAM,CAAC,WAAW,IAAI,EAAE;;;;;;2EAM5F,CAAC;IAC3E,CAAC;CACD"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { PromptModule, ModuleConfig } from './prompt-module.interface.js';
|
|
2
|
+
/**
|
|
3
|
+
* Lifecycle module — agent lifecycle behaviors and cognitive loop.
|
|
4
|
+
*
|
|
5
|
+
* Consolidates proactive monitoring, auto progress heartbeat,
|
|
6
|
+
* work rhythm, session management, and the 4-stage cognitive
|
|
7
|
+
* lifecycle (Intent → Observation → Strategy → Adaptation).
|
|
8
|
+
*
|
|
9
|
+
* Orchestrator/TL agents get the full lifecycle spec including
|
|
10
|
+
* proactive monitoring and event subscription patterns.
|
|
11
|
+
* Workers get a compact work-rhythm-only version.
|
|
12
|
+
*
|
|
13
|
+
* Sources: orchestrator prompt.md §Proactive Monitoring,
|
|
14
|
+
* §Auto Progress Heartbeat, §Session Management,
|
|
15
|
+
* developer prompt.md §Work Rhythm.
|
|
16
|
+
*/
|
|
17
|
+
export declare class LifecycleModule implements PromptModule {
|
|
18
|
+
name: string;
|
|
19
|
+
priority: number;
|
|
20
|
+
maxTokens: number;
|
|
21
|
+
compactable: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Always included — all agents need lifecycle guidance.
|
|
24
|
+
*/
|
|
25
|
+
shouldInclude(_config: ModuleConfig): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Build the lifecycle section.
|
|
28
|
+
* Orchestrators/TLs get the full spec; workers get a compact version.
|
|
29
|
+
*
|
|
30
|
+
* @param config - Module configuration with agent details
|
|
31
|
+
* @returns Formatted markdown lifecycle section
|
|
32
|
+
*/
|
|
33
|
+
build(config: ModuleConfig): Promise<string>;
|
|
34
|
+
/**
|
|
35
|
+
* Full lifecycle for orchestrators and team leaders —
|
|
36
|
+
* includes proactive monitoring, cognitive loop, heartbeat, and session management.
|
|
37
|
+
*/
|
|
38
|
+
private buildFullLifecycle;
|
|
39
|
+
/**
|
|
40
|
+
* Compact lifecycle for workers — work rhythm and context management only.
|
|
41
|
+
*/
|
|
42
|
+
private buildWorkerLifecycle;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=lifecycle.module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lifecycle.module.d.ts","sourceRoot":"","sources":["../../../../../../../backend/src/services/ai/prompt-modules/lifecycle.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE1E;;;;;;;;;;;;;;GAcG;AACH,qBAAa,eAAgB,YAAW,YAAY;IACnD,IAAI,SAAe;IACnB,QAAQ,SAAM;IACd,SAAS,SAAO;IAChB,WAAW,UAAQ;IAEnB;;OAEG;IACH,aAAa,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO;IAI7C;;;;;;OAMG;IACG,KAAK,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC;IAUlD;;;OAGG;IACH,OAAO,CAAC,kBAAkB;IAyC1B;;OAEG;IACH,OAAO,CAAC,oBAAoB;CAwB5B"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lifecycle module — agent lifecycle behaviors and cognitive loop.
|
|
3
|
+
*
|
|
4
|
+
* Consolidates proactive monitoring, auto progress heartbeat,
|
|
5
|
+
* work rhythm, session management, and the 4-stage cognitive
|
|
6
|
+
* lifecycle (Intent → Observation → Strategy → Adaptation).
|
|
7
|
+
*
|
|
8
|
+
* Orchestrator/TL agents get the full lifecycle spec including
|
|
9
|
+
* proactive monitoring and event subscription patterns.
|
|
10
|
+
* Workers get a compact work-rhythm-only version.
|
|
11
|
+
*
|
|
12
|
+
* Sources: orchestrator prompt.md §Proactive Monitoring,
|
|
13
|
+
* §Auto Progress Heartbeat, §Session Management,
|
|
14
|
+
* developer prompt.md §Work Rhythm.
|
|
15
|
+
*/
|
|
16
|
+
export class LifecycleModule {
|
|
17
|
+
name = 'lifecycle';
|
|
18
|
+
priority = 11;
|
|
19
|
+
maxTokens = 800;
|
|
20
|
+
compactable = true;
|
|
21
|
+
/**
|
|
22
|
+
* Always included — all agents need lifecycle guidance.
|
|
23
|
+
*/
|
|
24
|
+
shouldInclude(_config) {
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Build the lifecycle section.
|
|
29
|
+
* Orchestrators/TLs get the full spec; workers get a compact version.
|
|
30
|
+
*
|
|
31
|
+
* @param config - Module configuration with agent details
|
|
32
|
+
* @returns Formatted markdown lifecycle section
|
|
33
|
+
*/
|
|
34
|
+
async build(config) {
|
|
35
|
+
const isOrchestrator = config.role === 'orchestrator';
|
|
36
|
+
const isTL = config.canDelegate === true;
|
|
37
|
+
if (isOrchestrator || isTL) {
|
|
38
|
+
return this.buildFullLifecycle(config);
|
|
39
|
+
}
|
|
40
|
+
return this.buildWorkerLifecycle(config);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Full lifecycle for orchestrators and team leaders —
|
|
44
|
+
* includes proactive monitoring, cognitive loop, heartbeat, and session management.
|
|
45
|
+
*/
|
|
46
|
+
buildFullLifecycle(config) {
|
|
47
|
+
const skillsPath = config.agentSkillsPath;
|
|
48
|
+
const sessionName = config.sessionName;
|
|
49
|
+
const projectPath = config.projectPath || config.projectRoot;
|
|
50
|
+
return `## Lifecycle Management
|
|
51
|
+
|
|
52
|
+
### Cognitive Lifecycle (4 Stages)
|
|
53
|
+
Continuously cycle through these stages during operation:
|
|
54
|
+
|
|
55
|
+
1. **Intent** — Determine what needs to happen next (read tasks, check goals)
|
|
56
|
+
2. **Observation** — Gather current state (team status, blockers, progress)
|
|
57
|
+
3. **Strategy** — Decide the best approach (delegate, implement, escalate)
|
|
58
|
+
4. **Adaptation** — Learn from results, adjust approach for next cycle
|
|
59
|
+
|
|
60
|
+
### Proactive Monitoring
|
|
61
|
+
- Periodically check team member status for idle/error states
|
|
62
|
+
- Use \`schedule-check\` to set follow-up reminders after delegations
|
|
63
|
+
- Monitor for stale tasks — if no progress in 15 minutes, investigate
|
|
64
|
+
- Track context window usage — save progress before running low
|
|
65
|
+
|
|
66
|
+
### Auto Progress Heartbeat
|
|
67
|
+
Report your status periodically to maintain visibility:
|
|
68
|
+
\`\`\`bash
|
|
69
|
+
bash ${skillsPath}/core/report-status/execute.sh '{"sessionName":"${sessionName}","status":"in_progress","summary":"<current activity>","projectPath":"${projectPath}"}'
|
|
70
|
+
\`\`\`
|
|
71
|
+
|
|
72
|
+
### Session Management
|
|
73
|
+
- **On startup**: Execute recovery protocol, load context, check pending work
|
|
74
|
+
- **During work**: Report progress, save learnings, delegate effectively
|
|
75
|
+
- **Before context runs low**: Save current state via \`record-learning\`
|
|
76
|
+
- **On shutdown**: Generate session summary for next session handoff
|
|
77
|
+
|
|
78
|
+
### Daily Workflow
|
|
79
|
+
1. Start → Recovery protocol → Check pending tasks
|
|
80
|
+
2. Process incoming messages and events
|
|
81
|
+
3. Execute cognitive lifecycle loop (Intent → Observation → Strategy → Adaptation)
|
|
82
|
+
4. Report progress at natural milestones
|
|
83
|
+
5. Save learnings and handoff summary before session ends`;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Compact lifecycle for workers — work rhythm and context management only.
|
|
87
|
+
*/
|
|
88
|
+
buildWorkerLifecycle(config) {
|
|
89
|
+
const skillsPath = config.agentSkillsPath;
|
|
90
|
+
const sessionName = config.sessionName;
|
|
91
|
+
const projectPath = config.projectPath || config.projectRoot;
|
|
92
|
+
return `## Work Rhythm
|
|
93
|
+
|
|
94
|
+
### On Session Start
|
|
95
|
+
1. Execute recovery protocol (recall + get-my-context)
|
|
96
|
+
2. Review recovered context for unfinished work or blockers
|
|
97
|
+
3. Report readiness to team leader
|
|
98
|
+
|
|
99
|
+
### During Work
|
|
100
|
+
- Report progress periodically so your team leader stays informed
|
|
101
|
+
- When you discover important patterns or gotchas, call \`record-learning\` immediately
|
|
102
|
+
- If you feel your context window is getting large, save progress:
|
|
103
|
+
\`\`\`bash
|
|
104
|
+
bash ${skillsPath}/core/record-learning/execute.sh '{"agentId":"${sessionName}","agentRole":"${config.role}","projectPath":"${projectPath}","learning":"Current progress: [what was done]. Remaining: [what is left]. Key findings: [important notes]"}'
|
|
105
|
+
\`\`\`
|
|
106
|
+
|
|
107
|
+
### Before Context Runs Low
|
|
108
|
+
- Proactively save your progress via \`record-learning\`
|
|
109
|
+
- Report current status so the team leader can reassign if needed`;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=lifecycle.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lifecycle.module.js","sourceRoot":"","sources":["../../../../../../../backend/src/services/ai/prompt-modules/lifecycle.module.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,eAAe;IAC3B,IAAI,GAAG,WAAW,CAAC;IACnB,QAAQ,GAAG,EAAE,CAAC;IACd,SAAS,GAAG,GAAG,CAAC;IAChB,WAAW,GAAG,IAAI,CAAC;IAEnB;;OAEG;IACH,aAAa,CAAC,OAAqB;QAClC,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,KAAK,CAAC,MAAoB;QAC/B,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,KAAK,cAAc,CAAC;QACtD,MAAM,IAAI,GAAG,MAAM,CAAC,WAAW,KAAK,IAAI,CAAC;QAEzC,IAAI,cAAc,IAAI,IAAI,EAAE,CAAC;YAC5B,OAAO,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;QACxC,CAAC;QACD,OAAO,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAC1C,CAAC;IAED;;;OAGG;IACK,kBAAkB,CAAC,MAAoB;QAC9C,MAAM,UAAU,GAAG,MAAM,CAAC,eAAe,CAAC;QAC1C,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;QACvC,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,IAAI,MAAM,CAAC,WAAW,CAAC;QAE7D,OAAO;;;;;;;;;;;;;;;;;;;OAmBF,UAAU,mDAAmD,WAAW,0EAA0E,WAAW;;;;;;;;;;;;;;0DAc1G,CAAC;IAC1D,CAAC;IAED;;OAEG;IACK,oBAAoB,CAAC,MAAoB;QAChD,MAAM,UAAU,GAAG,MAAM,CAAC,eAAe,CAAC;QAC1C,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;QACvC,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,IAAI,MAAM,CAAC,WAAW,CAAC;QAE7D,OAAO;;;;;;;;;;;;OAYF,UAAU,iDAAiD,WAAW,kBAAkB,MAAM,CAAC,IAAI,oBAAoB,WAAW;;;;;kEAKvE,CAAC;IAClE,CAAC;CACD"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { PromptModule, ModuleConfig } from './prompt-module.interface.js';
|
|
2
|
+
/**
|
|
3
|
+
* Memory reference module — tells the agent how to access and store memories.
|
|
4
|
+
*
|
|
5
|
+
* Consolidates memory routing rules and session recovery protocol
|
|
6
|
+
* into a single module. Contains "how-to" instructions, not actual data.
|
|
7
|
+
*
|
|
8
|
+
* Sources: Path A Steps 8+9, Path B Section 7.
|
|
9
|
+
*/
|
|
10
|
+
export declare class MemoryReferenceModule implements PromptModule {
|
|
11
|
+
name: string;
|
|
12
|
+
priority: number;
|
|
13
|
+
maxTokens: number;
|
|
14
|
+
compactable: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Always included — memory access is fundamental to agent continuity.
|
|
17
|
+
*/
|
|
18
|
+
shouldInclude(_config: ModuleConfig): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Build the memory reference section with routing rules
|
|
21
|
+
* that tell the agent where to store different types of knowledge.
|
|
22
|
+
*
|
|
23
|
+
* @param config - Module configuration
|
|
24
|
+
* @returns Formatted markdown memory reference section
|
|
25
|
+
*/
|
|
26
|
+
build(_config: ModuleConfig): Promise<string>;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=memory-reference.module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-reference.module.d.ts","sourceRoot":"","sources":["../../../../../../../backend/src/services/ai/prompt-modules/memory-reference.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE1E;;;;;;;GAOG;AACH,qBAAa,qBAAsB,YAAW,YAAY;IACzD,IAAI,SAAuB;IAC3B,QAAQ,SAAK;IACb,SAAS,SAAO;IAChB,WAAW,UAAS;IAEpB;;OAEG;IACH,aAAa,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO;IAI7C;;;;;;OAMG;IACG,KAAK,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC;CAkBnD"}
|