repoburg 1.3.113 → 1.3.120

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 (19) hide show
  1. package/backend/.env +2 -2
  2. package/backend/dist/src/llm-orchestration/action-handlers/discard-messages.handler.d.ts +20 -0
  3. package/backend/dist/src/llm-orchestration/action-handlers/discard-messages.handler.js +192 -0
  4. package/backend/dist/src/llm-orchestration/action-handlers/discard-messages.handler.js.map +1 -0
  5. package/backend/dist/src/llm-orchestration/action-handlers/get-messages.handler.d.ts +16 -0
  6. package/backend/dist/src/llm-orchestration/action-handlers/get-messages.handler.js +180 -0
  7. package/backend/dist/src/llm-orchestration/action-handlers/get-messages.handler.js.map +1 -0
  8. package/backend/dist/src/llm-orchestration/llm-orchestration.module.js +9 -1
  9. package/backend/dist/src/llm-orchestration/llm-orchestration.module.js.map +1 -1
  10. package/backend/dist/src/seeding/data/system-prompts/default_native_tool_agent.d.ts +1 -1
  11. package/backend/dist/src/seeding/data/system-prompts/default_native_tool_agent.js +10 -8
  12. package/backend/dist/src/seeding/data/system-prompts/default_native_tool_agent.js.map +1 -1
  13. package/backend/dist/src/seeding/data/system-prompts/master-agent.d.ts +1 -1
  14. package/backend/dist/src/seeding/data/system-prompts/master-agent.js +8 -0
  15. package/backend/dist/src/seeding/data/system-prompts/master-agent.js.map +1 -1
  16. package/backend/dist/src/system-prompts/system-prompts.service.js +2 -0
  17. package/backend/dist/src/system-prompts/system-prompts.service.js.map +1 -1
  18. package/backend/dist/tsconfig.build.tsbuildinfo +1 -1
  19. package/package.json +1 -1
package/backend/.env CHANGED
@@ -12,11 +12,11 @@
12
12
  # webcoder
13
13
  # REPOBURG_PROJECT_PATH=/Users/celalertug/github/webcoder
14
14
 
15
- REPOBURG_PROJECT_PATH=/Users/celalertug/tmp/randomproject
15
+ # REPOBURG_PROJECT_PATH=/Users/celalertug/tmp/randomproject
16
16
  # REPOBURG_PROJECT_PATH=/Users/celalertug/repoburg-projects/simple-erp
17
17
 
18
18
  # appdev
19
- # REPOBURG_PROJECT_PATH=/Users/celalertug/everest/tmpappdev2
19
+ REPOBURG_PROJECT_PATH=/Users/celalertug/everest/tmpappdev2
20
20
  # REPOBURG_PROJECT_PATH=/Users/celalertug/everest/tmpappdev2-session2
21
21
 
22
22
 
@@ -0,0 +1,20 @@
1
+ import { ActionHandler } from './action-handler.interface';
2
+ import { ActionExecutionResult, PlanExecutionContext } from '../llm-orchestration.interfaces';
3
+ import { SessionInputsService } from '../../session-inputs/session-inputs.service';
4
+ export declare class DiscardMessagesHandler implements ActionHandler {
5
+ private readonly sessionInputsService;
6
+ readonly toolName = "discard_messages";
7
+ constructor(sessionInputsService: SessionInputsService);
8
+ getMetadata(): {
9
+ name: string;
10
+ description: string;
11
+ arguments: {
12
+ name: string;
13
+ type: "string";
14
+ description: string;
15
+ required: boolean;
16
+ }[];
17
+ };
18
+ getDefinition(): string;
19
+ execute(args: Record<string, any>, context: PlanExecutionContext): Promise<ActionExecutionResult>;
20
+ }
@@ -0,0 +1,192 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.DiscardMessagesHandler = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ const session_inputs_service_1 = require("../../session-inputs/session-inputs.service");
15
+ function toShortId(uuid) {
16
+ const cleaned = uuid.replace(/-/g, '');
17
+ return cleaned.slice(0, 3) + cleaned.slice(-2);
18
+ }
19
+ let DiscardMessagesHandler = class DiscardMessagesHandler {
20
+ constructor(sessionInputsService) {
21
+ this.sessionInputsService = sessionInputsService;
22
+ this.toolName = 'discard_messages';
23
+ }
24
+ getMetadata() {
25
+ return {
26
+ name: this.toolName,
27
+ description: 'Discard messages from the LLM context window. Discarded messages are excluded from future LLM calls but preserved in history. Use get_messages first to see short_ids. THIS IS A TERMINAL ACTION — the AI loop stops after calling this. Call get_messages first, then discard_messages ONCE with all IDs to discard.',
28
+ arguments: [
29
+ {
30
+ name: 'input_ids',
31
+ type: 'string',
32
+ description: 'Comma-separated list of short_ids to discard (e.g., "a1b90,cd3ef"). Use get_messages to find short_ids.',
33
+ required: true,
34
+ },
35
+ {
36
+ name: 'reason',
37
+ type: 'string',
38
+ description: 'Brief explanation (2-3 sentences max) of what is being discarded, what is kept, and why.',
39
+ required: true,
40
+ },
41
+ ],
42
+ };
43
+ }
44
+ getDefinition() {
45
+ return `## discard_messages
46
+
47
+ Discard messages from the LLM context window. Discarded messages are excluded from future LLM calls but preserved in history. Use \`get_messages\` first to see short_ids.
48
+
49
+ **THIS IS A TERMINAL ACTION** — the AI loop stops after calling this. Call \`get_messages\` first, then \`discard_messages\` ONCE with all IDs to discard. Do NOT call any other tools after this.
50
+
51
+ ### Parameters:
52
+ - \`input_ids\` (string, required): Comma-separated list of short_ids to discard (e.g., "a1b90,cd3ef,ghi45"). Use \`get_messages\` to find short_ids.
53
+ - \`reason\` (string, required): Brief explanation (2-3 sentences max) of what is being discarded, what is kept, and why.
54
+
55
+ ### Example:
56
+ \`\`\`typescript
57
+ tool: discard_messages
58
+ args: {
59
+ input_ids: "a1b90,cd3ef,ghi45",
60
+ reason: "Discarding old request_context calls and completed run_command outputs to free up context window. Keeping recent user prompts and code changes."
61
+ }
62
+ \`\`\``;
63
+ }
64
+ async execute(args, context) {
65
+ try {
66
+ const { input_ids, reason } = args;
67
+ if (!input_ids ||
68
+ typeof input_ids !== 'string' ||
69
+ input_ids.trim() === '') {
70
+ return {
71
+ status: 'FAILURE',
72
+ summary: 'Failed to discard messages',
73
+ error_message: 'input_ids is required and must be a non-empty comma-separated string of short_ids',
74
+ execution_log: {
75
+ output: '',
76
+ error_message: 'input_ids is required and must be a non-empty comma-separated string of short_ids',
77
+ },
78
+ };
79
+ }
80
+ if (!reason || typeof reason !== 'string' || reason.trim() === '') {
81
+ return {
82
+ status: 'FAILURE',
83
+ summary: 'Failed to discard messages',
84
+ error_message: 'reason is required and must be a non-empty string explaining what is discarded, what is kept, and why',
85
+ execution_log: {
86
+ output: '',
87
+ error_message: 'reason is required and must be a non-empty string explaining what is discarded, what is kept, and why',
88
+ },
89
+ };
90
+ }
91
+ const shortIds = input_ids
92
+ .split(',')
93
+ .map((id) => id.trim())
94
+ .filter((id) => id.length > 0);
95
+ if (shortIds.length === 0) {
96
+ return {
97
+ status: 'FAILURE',
98
+ summary: 'Failed to discard messages',
99
+ error_message: 'No valid IDs provided after parsing input_ids',
100
+ execution_log: {
101
+ output: '',
102
+ error_message: 'No valid IDs provided after parsing input_ids',
103
+ },
104
+ };
105
+ }
106
+ const allInputs = await this.sessionInputsService.findAllBySessionId(context.session_id);
107
+ const shortToFull = new Map();
108
+ for (const inp of allInputs) {
109
+ shortToFull.set(toShortId(inp.id), inp.id);
110
+ }
111
+ const resolvedIds = [];
112
+ const unresolved = [];
113
+ for (const shortId of shortIds) {
114
+ const fullId = shortToFull.get(shortId);
115
+ if (fullId) {
116
+ resolvedIds.push(fullId);
117
+ }
118
+ else {
119
+ unresolved.push(shortId);
120
+ }
121
+ }
122
+ if (unresolved.length > 0) {
123
+ return {
124
+ status: 'FAILURE',
125
+ summary: 'Failed to discard messages',
126
+ error_message: `Could not resolve short_ids: ${unresolved.join(', ')}. Use get_messages to find valid short_ids.`,
127
+ execution_log: {
128
+ output: '',
129
+ error_message: `Could not resolve short_ids: ${unresolved.join(', ')}`,
130
+ },
131
+ };
132
+ }
133
+ const result = await this.sessionInputsService.toggleDiscardedBatch(context.session_id, {
134
+ input_ids: resolvedIds,
135
+ is_discarded: true,
136
+ });
137
+ const getMessagesInputIds = allInputs
138
+ .filter((inp) => inp.role === 'model' &&
139
+ inp.aiActions &&
140
+ inp.aiActions.some((a) => a.action_type === 'get_messages'))
141
+ .map((inp) => inp.id)
142
+ .filter((id) => !resolvedIds.includes(id));
143
+ let autoDiscardedCount = 0;
144
+ if (getMessagesInputIds.length > 0) {
145
+ const autoResult = await this.sessionInputsService.toggleDiscardedBatch(context.session_id, {
146
+ input_ids: getMessagesInputIds,
147
+ is_discarded: true,
148
+ });
149
+ autoDiscardedCount = autoResult.affected;
150
+ }
151
+ context.flags.is_final = true;
152
+ const summary = autoDiscardedCount > 0
153
+ ? `Discarded ${result.affected} message(s) + ${autoDiscardedCount} get_messages call(s)`
154
+ : `Discarded ${result.affected} message(s)`;
155
+ return {
156
+ status: 'SUCCESS',
157
+ summary,
158
+ execution_log: {
159
+ output: JSON.stringify({
160
+ affected: result.affected,
161
+ short_ids: shortIds,
162
+ reason: reason.trim(),
163
+ auto_discarded_get_messages: autoDiscardedCount,
164
+ }),
165
+ },
166
+ persisted_args: {
167
+ arguments: JSON.stringify({
168
+ input_ids: shortIds,
169
+ reason: reason.trim(),
170
+ }),
171
+ },
172
+ };
173
+ }
174
+ catch (error) {
175
+ return {
176
+ status: 'FAILURE',
177
+ summary: 'Failed to discard messages',
178
+ error_message: error.message,
179
+ execution_log: {
180
+ output: '',
181
+ error_message: error.message,
182
+ },
183
+ };
184
+ }
185
+ }
186
+ };
187
+ exports.DiscardMessagesHandler = DiscardMessagesHandler;
188
+ exports.DiscardMessagesHandler = DiscardMessagesHandler = __decorate([
189
+ (0, common_1.Injectable)(),
190
+ __metadata("design:paramtypes", [session_inputs_service_1.SessionInputsService])
191
+ ], DiscardMessagesHandler);
192
+ //# sourceMappingURL=discard-messages.handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discard-messages.handler.js","sourceRoot":"","sources":["../../../../src/llm-orchestration/action-handlers/discard-messages.handler.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAM5C,wFAAmF;AAMnF,SAAS,SAAS,CAAC,IAAY;IAC7B,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACvC,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AACjD,CAAC;AAGM,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IAGjC,YAA6B,oBAA0C;QAA1C,yBAAoB,GAApB,oBAAoB,CAAsB;QAF9D,aAAQ,GAAG,kBAAkB,CAAC;IAEmC,CAAC;IAE3E,WAAW;QACT,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,QAAQ;YACnB,WAAW,EACT,uTAAuT;YACzT,SAAS,EAAE;gBACT;oBACE,IAAI,EAAE,WAAW;oBACjB,IAAI,EAAE,QAAiB;oBACvB,WAAW,EACT,yGAAyG;oBAC3G,QAAQ,EAAE,IAAI;iBACf;gBACD;oBACE,IAAI,EAAE,QAAQ;oBACd,IAAI,EAAE,QAAiB;oBACvB,WAAW,EACT,0FAA0F;oBAC5F,QAAQ,EAAE,IAAI;iBACf;aACF;SACF,CAAC;IACJ,CAAC;IAED,aAAa;QACX,OAAO;;;;;;;;;;;;;;;;;OAiBJ,CAAC;IACN,CAAC;IAED,KAAK,CAAC,OAAO,CACX,IAAyB,EACzB,OAA6B;QAE7B,IAAI,CAAC;YACH,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;YAGnC,IACE,CAAC,SAAS;gBACV,OAAO,SAAS,KAAK,QAAQ;gBAC7B,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,EACvB,CAAC;gBACD,OAAO;oBACL,MAAM,EAA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AAE;oBACb,MAAM,EAAE,EAAE;oBACV,aAAa,EAAE,KAAK,CAAC,OAAO;iBAC7B;aACF,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAA;AAnNY,wDAAsB;iCAAtB,sBAAsB;IADlC,IAAA,mBAAU,GAAE;qCAIwC,6CAAoB;GAH5D,sBAAsB,CAmNlC"}
@@ -0,0 +1,16 @@
1
+ import { Repository } from 'typeorm';
2
+ import { ActionHandler } from './action-handler.interface';
3
+ import { ActionExecutionResult, PlanExecutionContext } from '../llm-orchestration.interfaces';
4
+ import { SessionInput } from '../../core-entities';
5
+ export declare class GetMessagesHandler implements ActionHandler {
6
+ private readonly sessionInputsRepository;
7
+ readonly toolName = "get_messages";
8
+ constructor(sessionInputsRepository: Repository<SessionInput>);
9
+ getMetadata(): {
10
+ name: string;
11
+ description: string;
12
+ arguments: any[];
13
+ };
14
+ getDefinition(): string;
15
+ execute(_args: Record<string, any>, context: PlanExecutionContext): Promise<ActionExecutionResult>;
16
+ }
@@ -0,0 +1,180 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.GetMessagesHandler = void 0;
16
+ const common_1 = require("@nestjs/common");
17
+ const typeorm_1 = require("@nestjs/typeorm");
18
+ const typeorm_2 = require("typeorm");
19
+ const core_entities_1 = require("../../core-entities");
20
+ const PREVIEW_MAX_LENGTH = 120;
21
+ function toShortId(uuid) {
22
+ const cleaned = uuid.replace(/-/g, '');
23
+ return cleaned.slice(0, 3) + cleaned.slice(-2);
24
+ }
25
+ function truncate(text, maxLen = PREVIEW_MAX_LENGTH) {
26
+ if (!text)
27
+ return '';
28
+ const cleaned = text.replace(/\n/g, ' ').trim();
29
+ if (cleaned.length <= maxLen)
30
+ return cleaned;
31
+ return cleaned.slice(0, maxLen - 3) + '...';
32
+ }
33
+ function buildActionPreview(action) {
34
+ switch (action.action_type) {
35
+ case 'create_file':
36
+ return `create_file: ${action.file_path || ''}`;
37
+ case 'overwrite_file':
38
+ return `overwrite_file: ${action.file_path || ''}`;
39
+ case 'delete_file':
40
+ return `delete_file: ${action.file_path || ''}`;
41
+ case 'patch':
42
+ return `patch: ${action.file_path || ''}`;
43
+ case 'quick_edit':
44
+ return `quick_edit: ${action.file_path || ''}`;
45
+ case 'apply_diff':
46
+ return `apply_diff: ${action.file_path || ''}`;
47
+ case 'run_command':
48
+ return `run_command: ${truncate(action.command_string || '')}`;
49
+ case 'request_context':
50
+ return `request_context: ${truncate(action.files || action.folders || '')}`;
51
+ case 'execute_code':
52
+ return `execute_code: ${truncate(action.command_string || '')}`;
53
+ case 'use_mcp_tool':
54
+ return `use_mcp_tool: ${action.server_name || ''}/${action.tool_name || ''}`;
55
+ case 'final':
56
+ if (action.selections) {
57
+ return `final: user selection`;
58
+ }
59
+ return `final: ${truncate(action.plain || '')}`;
60
+ case 'invoke_subagent':
61
+ return `invoke_subagent: ${truncate(action.arguments || '')}`;
62
+ case 'list_sub_agents':
63
+ return 'list_sub_agents';
64
+ case 'new_session':
65
+ return `new_session: ${truncate(action.handover_string || '')}`;
66
+ case 'get_session_history':
67
+ return 'get_session_history';
68
+ case 'generate_title':
69
+ return 'generate_title';
70
+ case 'ask_user':
71
+ return `ask_user: ${truncate(action.plain || '')}`;
72
+ case 'write_todo':
73
+ return `write_todo: ${action.file_path || ''}`;
74
+ case 'howto':
75
+ return 'howto';
76
+ case 'get_messages':
77
+ return 'get_messages';
78
+ case 'discard_messages':
79
+ return 'discard_messages';
80
+ default:
81
+ return `${action.action_type}: ${truncate(action.file_path || action.command_string || action.plain || '')}`;
82
+ }
83
+ }
84
+ let GetMessagesHandler = class GetMessagesHandler {
85
+ constructor(sessionInputsRepository) {
86
+ this.sessionInputsRepository = sessionInputsRepository;
87
+ this.toolName = 'get_messages';
88
+ }
89
+ getMetadata() {
90
+ return {
91
+ name: this.toolName,
92
+ description: 'Get a summary of non-discarded messages in the current session. Returns short_id, role, and preview for each message. Use this to identify messages to discard from context.',
93
+ arguments: [],
94
+ };
95
+ }
96
+ getDefinition() {
97
+ return `## get_messages
98
+
99
+ Get a summary of non-discarded messages in the current session. Returns a lightweight list showing each message's short_id, role, and preview. Use this to decide which messages to discard from the LLM context window.
100
+
101
+ ### Parameters:
102
+ No parameters required. Uses the current session context.
103
+
104
+ ### Returns:
105
+ JSON array of message summaries:
106
+ - \`short_id\`: Compact ID (first 3 + last 2 chars of UUID, e.g. "a1b90") — use this with \`discard_messages\`
107
+ - \`role\`: "user" or "model"
108
+ - \`preview\`: brief description (user prompt text or tool name + args)
109
+
110
+ ### Example:
111
+ \`\`\`typescript
112
+ tool: get_messages
113
+ args: {}
114
+ \`\`\``;
115
+ }
116
+ async execute(_args, context) {
117
+ try {
118
+ const inputs = await this.sessionInputsRepository.find({
119
+ where: { session: { id: context.session_id }, is_discarded: false },
120
+ relations: ['aiActions'],
121
+ order: { sequence_number: 'ASC' },
122
+ });
123
+ const summaries = inputs.map((input) => {
124
+ let preview;
125
+ if (input.role === 'user') {
126
+ preview = truncate(input.user_prompt || '');
127
+ }
128
+ else if (input.aiActions && input.aiActions.length > 0) {
129
+ preview = input.aiActions
130
+ .sort((a, b) => a.order_of_execution - b.order_of_execution)
131
+ .map((a) => buildActionPreview(a))
132
+ .join(', ');
133
+ if (preview.length > PREVIEW_MAX_LENGTH) {
134
+ preview = preview.slice(0, PREVIEW_MAX_LENGTH - 3) + '...';
135
+ }
136
+ }
137
+ else if (input.error_message) {
138
+ preview = `error: ${truncate(input.error_message)}`;
139
+ }
140
+ else if (input.llm_response_explanation) {
141
+ preview = truncate(input.llm_response_explanation);
142
+ }
143
+ else {
144
+ preview = '(empty response)';
145
+ }
146
+ return {
147
+ short_id: toShortId(input.id),
148
+ role: input.role || 'user',
149
+ preview,
150
+ };
151
+ });
152
+ return {
153
+ status: 'SUCCESS',
154
+ summary: `${summaries.length} messages`,
155
+ execution_log: {
156
+ output: JSON.stringify(summaries, null, 2),
157
+ },
158
+ persisted_args: {},
159
+ };
160
+ }
161
+ catch (error) {
162
+ return {
163
+ status: 'FAILURE',
164
+ summary: 'Failed to get messages',
165
+ error_message: error.message,
166
+ execution_log: {
167
+ output: '',
168
+ error_message: error.message,
169
+ },
170
+ };
171
+ }
172
+ }
173
+ };
174
+ exports.GetMessagesHandler = GetMessagesHandler;
175
+ exports.GetMessagesHandler = GetMessagesHandler = __decorate([
176
+ (0, common_1.Injectable)(),
177
+ __param(0, (0, typeorm_1.InjectRepository)(core_entities_1.SessionInput)),
178
+ __metadata("design:paramtypes", [typeorm_2.Repository])
179
+ ], GetMessagesHandler);
180
+ //# sourceMappingURL=get-messages.handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-messages.handler.js","sourceRoot":"","sources":["../../../../src/llm-orchestration/action-handlers/get-messages.handler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,6CAAmD;AACnD,qCAAqC;AAMrC,uDAA6D;AAE7D,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAM/B,SAAS,SAAS,CAAC,IAAY;IAC7B,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACvC,OAAO,OAAO,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J,CAAC;IACH,CAAC;CACF,CAAA;AAjGY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,mBAAU,GAAE;IAKR,WAAA,IAAA,0BAAgB,EAAC,4BAAY,CAAC,CAAA;qCACW,oBAAU;GAL3C,kBAAkB,CAiG9B"}
@@ -48,6 +48,8 @@ const list_sub_agents_handler_1 = require("./action-handlers/list-sub-agents.han
48
48
  const get_session_history_handler_1 = require("./action-handlers/get-session-history.handler");
49
49
  const generate_title_handler_1 = require("./action-handlers/generate-title.handler");
50
50
  const ask_user_handler_1 = require("./action-handlers/ask-user.handler");
51
+ const get_messages_handler_1 = require("./action-handlers/get-messages.handler");
52
+ const discard_messages_handler_1 = require("./action-handlers/discard-messages.handler");
51
53
  const invalid_tool_feedback_hook_1 = require("./hooks/invalid-tool-feedback.hook");
52
54
  const sub_agent_final_response_hook_1 = require("./hooks/sub-agent-final-response.hook");
53
55
  const frontend_notification_hook_1 = require("./hooks/frontend-notification.hook");
@@ -100,6 +102,8 @@ exports.LlmOrchestrationModule = LlmOrchestrationModule = __decorate([
100
102
  get_session_history_handler_1.GetSessionHistoryHandler,
101
103
  generate_title_handler_1.GenerateTitleHandler,
102
104
  ask_user_handler_1.AskUserHandler,
105
+ get_messages_handler_1.GetMessagesHandler,
106
+ discard_messages_handler_1.DiscardMessagesHandler,
103
107
  invalid_tool_feedback_hook_1.InvalidToolFeedbackHook,
104
108
  frontend_notification_hook_1.FrontendNotificationHook,
105
109
  follow_up_post_execution_hook_1.FollowUpPostExecutionHook,
@@ -107,7 +111,7 @@ exports.LlmOrchestrationModule = LlmOrchestrationModule = __decorate([
107
111
  sub_agent_final_response_hook_1.SubAgentFinalResponseHook,
108
112
  {
109
113
  provide: 'ACTION_HANDLER_REGISTRY',
110
- useFactory: (createFile, deleteFile, overwriteFile, runCommand, requestContext, final, useMcpTool, quickEdit, applyDiff, patch, newSession, writeTodo, executeCode, howto, invokeSubAgent, listSubAgents, getSessionHistory, generateTitle, askUser) => {
114
+ useFactory: (createFile, deleteFile, overwriteFile, runCommand, requestContext, final, useMcpTool, quickEdit, applyDiff, patch, newSession, writeTodo, executeCode, howto, invokeSubAgent, listSubAgents, getSessionHistory, generateTitle, askUser, getMessages, discardMessages) => {
111
115
  const registry = new Map();
112
116
  registry.set(createFile.toolName, createFile);
113
117
  registry.set(deleteFile.toolName, deleteFile);
@@ -128,6 +132,8 @@ exports.LlmOrchestrationModule = LlmOrchestrationModule = __decorate([
128
132
  registry.set(getSessionHistory.toolName, getSessionHistory);
129
133
  registry.set(generateTitle.toolName, generateTitle);
130
134
  registry.set(askUser.toolName, askUser);
135
+ registry.set(getMessages.toolName, getMessages);
136
+ registry.set(discardMessages.toolName, discardMessages);
131
137
  return registry;
132
138
  },
133
139
  inject: [
@@ -150,6 +156,8 @@ exports.LlmOrchestrationModule = LlmOrchestrationModule = __decorate([
150
156
  get_session_history_handler_1.GetSessionHistoryHandler,
151
157
  generate_title_handler_1.GenerateTitleHandler,
152
158
  ask_user_handler_1.AskUserHandler,
159
+ get_messages_handler_1.GetMessagesHandler,
160
+ discard_messages_handler_1.DiscardMessagesHandler,
153
161
  ],
154
162
  },
155
163
  {
@@ -1 +1 @@
1
- {"version":3,"file":"llm-orchestration.module.js","sourceRoot":"","sources":["../../../src/llm-orchestration/llm-orchestration.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAoD;AACpD,6CAAgD;AAChD,kFAA4E;AAC5E,6EAAuE;AACvE,+DAA0D;AAC1D,+EAA0E;AAC1E,uEAAkE;AAClE,mFAA8E;AAC9E,iEAAwE;AAExE,2DAAuD;AACvD,4FAAuF;AACvF,0EAAqE;AACrE,oDAK0B;AAC1B,mFAA8E;AAE9E,mFAA8E;AAC9E,iEAA6D;AAC7D,oEAAgE;AAChE,kDAA8C;AAC9C,uEAAkE;AAClE,uEAAkE;AAClE,4FAAuF;AACvF,+FAA0F;AAG1F,+EAA0E;AAC1E,+EAA0E;AAC1E,qFAAgF;AAChF,+EAA0E;AAC1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AAqB;wBACrB,QAAQ;wBACR,oBAAoB;qBACrB,CAAC;gBACJ,CAAC;gBACD,MAAM,EAAE;oBACN,oDAAuB;oBACvB,qDAAwB;oBACxB,yDAAyB;oBACzB,yDAAyB;oBACzB,yDAAyB;iBAC1B;aACF;SACF;QACD,OAAO,EAAE;YACP,oDAAuB;YACvB,uCAAiB;YACjB,uDAAyB;YACzB,yBAAyB;SAC1B;KACF,CAAC;GACW,sBAAsB,CAAG"}
1
+ {"version":3,"file":"llm-orchestration.module.js","sourceRoot":"","sources":["../../../src/llm-orchestration/llm-orchestration.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAoD;AACpD,6CAAgD;AAChD,kFAA4E;AAC5E,6EAAuE;AACvE,+DAA0D;AAC1D,+EAA0E;AAC1E,uEAAkE;AAClE,mFAA8E;AAC9E,iEAAwE;AAExE,2DAAuD;AACvD,4FAAuF;AACvF,0EAAqE;AACrE,oDAK0B;AAC1B,mFAA8E;AAE9E,mFAA8E;AAC9E,iEAA6D;AAC7D,oEAAgE;AAChE,kDAA8C;AAC9C,uEAAkE;AAClE,uEAAkE;AAClE,4FAAuF;AACvF,+FAA0F;AAG1F,+EAA0E;AAC1E,+EAA0E;AAC1E,qFAAgF;AAChF,+EAA0E;AAC1E,uFAAkF;AAClF,mEAA+D;AAC/D,iFAA2E;AAC3E,6EAAwE;AACxE,6EAAwE;AACxE,mEAA+D;AAC/D,+EAA0E;AAC1E,6EAAwE;AACxE,iFAA4E;AAC5E,mEAA+D;AAC/D,uFAAkF;AAClF,uFAAiF;AACjF,+FAAyF;AACzF,qFAAgF;AAChF,yEAAoE;AACpE,iFAA4E;AAC5E,yFAAoF;AAGpF,mFAA6E;AAC7E,yFAAkF;AAClF,mFAA8E;AAC9E,yFAAkF;AAClF,yFAAkF;AAkK3E,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;CAAG,CAAA;AAAzB,wDAAsB;iCAAtB,sBAAsB;IAhKlC,IAAA,eAAM,EAAC;QACN,O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,OAAO,EAAE;YACP,oDAAuB;YACvB,uCAAiB;YACjB,uDAAyB;YACzB,yBAAyB;SAC1B;KACF,CAAC;GACW,sBAAsB,CAAG"}
@@ -1,3 +1,3 @@
1
1
  export declare const name = "Native Tool Agent";
2
2
  export declare const enabled_tools: string[];
3
- export declare const content = "You are an expert software engineer. You write clean, efficient, and well-documented code.\n\n## Instructions\n1. **Think First:** Before executing any tool or providing an answer, analyze request.\n2. **Conciseness:** Be extremely brief.\n3. **Best Practices:** Follow SOLID principles and keep code DRY.\n4. **Strict Scope:** Do ONLY what is asked. Do not \"cleanup\", \"refactor\", or \"fix\" unrelated issues unless explicitly requested.\n5. **Memory Management & Handover:** When asked to \"remember session\", \"update memory\", \"new session\", or \"handover\":\n - Delegate to the `handover-session` sub-agent using `invoke_subagent`.\n - **Always pass your session ID in the prompt**:\n `invoke_subagent { agent_name: \"handover-session\", prompt: \"Compress session <%= it.VAR.METADATA.session_id %> using instance <%= it.VAR.METADATA.instance_name %>\" }`\n - The handover agent will export, compress, and import as a new session.\n - Do NOT manually write files - use the specialized sub-agent for this.\n6. **Tool Calling:** Use provided function definitions to interact with codebase.\n7. **Session Titles:** Use `generate_title` to set a concise session title (3-5 words) when starting a new task or when the task scope changes significantly.\n\n## Sub-Agents\nSpecialized agents available for delegation.\n\n\n\n**Tools:**\n- `list_sub_agents` - Discover available sub-agents\n- `invoke_subagent` - Delegate a task to a sub-agent\n\n**Available Sub-Agents:**\n- `handover-session` - Session compression, summarization, and handover. Use for \"new session\" or \"handover\" requests.\n- `explore-codebase` - Read-only codebase exploration. Use when you need to understand project structure.\n\n**Sub Agent Rules**\n\n- Never send followup message to an existing subagent. you must wait until it finishes its work. you can invoke a new one but never send followup message to existing subagent\n\n## Current State\nSession: <%= it.VAR.METADATA.session_name %>\nID: <%= it.VAR.METADATA.session_id %>\n\n<% if (it.VAR.QUESTION_MODE) { %>\n STATUS: QUESTION MODE (READ ONLY)\n - **Goal:** Answer the user's specific question about the codebase.\n - **Constraint:** You are READ-ONLY. Do not edit, create, or delete files.\n - **Constraint:** Do NOT propose an implementation plan or RFC. Just answer the question.\n - **Process:** Search context -> Read files -> Explain to user.\n\n<% } else if (it.VAR.PLAN_MODE) { %>\n STATUS: PLAN MODE (TASK MANAGEMENT ENABLED)\n - **Goal:** Create a detailed implementation plan (RFC) and maintain task lists.\n - **Constraint:** Code editing is FORBIDDEN.\n - **Available Tools:** `request_context`, `run_command`, `write_todo`.\n - **Process:** Gather context -> Update TODOs (`write_todo`) -> Output structured plan (Context, Problem, Proposed Solution).\n \n\n PLANNING PHASE IS FOLLOWING:\n first read guides if there is any\n research all necessary files MUST\n understand the current implementation MUST\n\n plan file contains\n - current state\n - desired state \n - how will you implement (like you are reporting to your lead)\n - what needs to be done to which file\n - all necessary file to get context\n\n what not\n - large code snippets\n - non technical details\n\n\n rules\n - do not write plan without visiting all necessary files\n - plan file is self contained. it should not require reading other files to understand the plan. if you need to reference other files, summarize them in the plan file.\n - mention your exploration briefly and put dead end in the plan file. \n\n\n ### Codebase Exploration\n If context is insufficient:\n 1. delegate exploration via `explore-codebase` sub-agent. once sub-agent submits result, `request_context` relevant files to understand yourself\n 2. Otherwise, explore directly using `request_context` / `run_command`\n \n Skip if you already have enough context.\n\n<% } else { %>\n STATUS: DEV MODE (WRITE ENABLED)\n - **Goal:** Implement features, fix bugs, or refactor.\n - **Authority:** You have full permission to modify the codebase. Never refuse a coding request.\n - **Strategy:** Use native function calls to read, write, and execute.\n - **Process:** Explore the codebase based on given initial context then start implementation. Even if you need to request context for 100 files do it.\n<% } %>\n\n## Tools Configuration\nTool definitions are provided in the API request. Use the native tool calling interface to perform operations.\n\n## Tool Usage Guidelines\n- Use `ask_user` when you need the user to make a choice or answer a question before continuing. This pauses the loop and waits for their response. Always provide selections.\n- Use `final` when you are done and have a conclusion or summary for the user.\n\n";
3
+ export declare const content = "You are an expert software engineer. You write clean, efficient, and well-documented code.\n\n## Instructions\n1. **Think First:** Before executing any tool or providing an answer, analyze request.\n2. **Conciseness:** Be extremely brief.\n3. **Best Practices:** Follow SOLID principles and keep code DRY.\n4. **Strict Scope:** Do ONLY what is asked. Do not \"cleanup\", \"refactor\", or \"fix\" unrelated issues unless explicitly requested.\n5. **Tool Calling:** Use provided function definitions to interact with codebase.\n6. **Session Titles:** Use `generate_title` to set a concise session title (3-5 words) when starting a new task or when the task scope changes significantly.\n\n## Sub-Agents\nSpecialized agents available for delegation.\n\n\n\n**Tools:**\n- `list_sub_agents` - Discover available sub-agents\n- `invoke_subagent` - Delegate a task to a sub-agent\n\n**Available Sub-Agents:**\n- `handover-session` - Session compression, summarization, and handover. Use for \"new session\" or \"handover\" requests.\n- `explore-codebase` - Read-only codebase exploration. Use when you need to understand project structure.\n\n**Sub Agent Rules**\n\n- Never send followup message to an existing subagent. you must wait until it finishes its work. you can invoke a new one but never send followup message to existing subagent\n\n## Current State\nSession: <%= it.VAR.METADATA.session_name %>\nID: <%= it.VAR.METADATA.session_id %>\n\n<% if (it.VAR.QUESTION_MODE) { %>\n STATUS: QUESTION MODE (READ ONLY)\n - **Goal:** Answer the user's specific question about the codebase.\n - **Constraint:** You are READ-ONLY. Do not edit, create, or delete files.\n - **Constraint:** Do NOT propose an implementation plan or RFC. Just answer the question.\n - **Process:** Search context -> Read files -> Explain to user.\n\n<% } else if (it.VAR.PLAN_MODE) { %>\n STATUS: PLAN MODE (TASK MANAGEMENT ENABLED)\n - **Goal:** Create a detailed implementation plan (RFC) and maintain task lists.\n - **Constraint:** Code editing is FORBIDDEN.\n - **Available Tools:** `request_context`, `run_command`, `write_todo`.\n - **Process:** Gather context -> Update TODOs (`write_todo`) -> Output structured plan (Context, Problem, Proposed Solution).\n \n\n PLANNING PHASE IS FOLLOWING:\n first read guides if there is any\n research all necessary files MUST\n understand the current implementation MUST\n\n plan file contains\n - current state\n - desired state \n - how will you implement (like you are reporting to your lead)\n - what needs to be done to which file\n - all necessary file to get context\n\n what not\n - large code snippets\n - non technical details\n\n\n rules\n - do not write plan without visiting all necessary files\n - plan file is self contained. it should not require reading other files to understand the plan. if you need to reference other files, summarize them in the plan file.\n - mention your exploration briefly and put dead end in the plan file. \n\n\n ### Codebase Exploration\n If context is insufficient:\n 1. delegate exploration via `explore-codebase` sub-agent. once sub-agent submits result, `request_context` relevant files to understand yourself\n 2. Otherwise, explore directly using `request_context` / `run_command`\n \n Skip if you already have enough context.\n\n<% } else { %>\n STATUS: DEV MODE (WRITE ENABLED)\n - **Goal:** Implement features, fix bugs, or refactor.\n - **Authority:** You have full permission to modify the codebase. Never refuse a coding request.\n - **Strategy:** Use native function calls to read, write, and execute.\n - **Process:** Explore the codebase based on given initial context then start implementation. Even if you need to request context for 100 files do it.\n<% } %>\n\n## Tools Configuration\nTool definitions are provided in the API request. Use the native tool calling interface to perform operations.\n\n## Context Management\nWhen asked to compress context or reduce tokens:\n1. Call `get_messages` to see non-discarded messages with `short_id`.\n2. Discard priority: **intermediary tools** (`request_context`, `run_command`, `execute_code`, `get_messages`) first \u2192 then **completed scopes** (keep only the final AI summary with no tool calls as an anchor) \u2192 **never** discard active plan conclusions or code changes.\n3. Call `discard_messages` ONCE with short_ids and a reason naming topics (e.g., `{ input_ids: \"a1b90,cd3ef\", reason: \"Discarding exploration of auth module. Keeping OAuth2 refactor plan.\" }`). Terminal action \u2014 no tools after this.\n\n## Tool Usage Guidelines\n- Use `ask_user` when you need the user to make a choice or answer a question before continuing. This pauses the loop and waits for their response. Always provide selections.\n- Use `final` when you are done and have a conclusion or summary for the user.\n\n";
@@ -16,6 +16,8 @@ exports.enabled_tools = [
16
16
  'generate_title',
17
17
  'ask_user',
18
18
  'final',
19
+ 'get_messages',
20
+ 'discard_messages',
19
21
  ];
20
22
  exports.content = `You are an expert software engineer. You write clean, efficient, and well-documented code.
21
23
 
@@ -24,14 +26,8 @@ exports.content = `You are an expert software engineer. You write clean, efficie
24
26
  2. **Conciseness:** Be extremely brief.
25
27
  3. **Best Practices:** Follow SOLID principles and keep code DRY.
26
28
  4. **Strict Scope:** Do ONLY what is asked. Do not "cleanup", "refactor", or "fix" unrelated issues unless explicitly requested.
27
- 5. **Memory Management & Handover:** When asked to "remember session", "update memory", "new session", or "handover":
28
- - Delegate to the \`handover-session\` sub-agent using \`invoke_subagent\`.
29
- - **Always pass your session ID in the prompt**:
30
- \`invoke_subagent { agent_name: "handover-session", prompt: "Compress session <%= it.VAR.METADATA.session_id %> using instance <%= it.VAR.METADATA.instance_name %>" }\`
31
- - The handover agent will export, compress, and import as a new session.
32
- - Do NOT manually write files - use the specialized sub-agent for this.
33
- 6. **Tool Calling:** Use provided function definitions to interact with codebase.
34
- 7. **Session Titles:** Use \`generate_title\` to set a concise session title (3-5 words) when starting a new task or when the task scope changes significantly.
29
+ 5. **Tool Calling:** Use provided function definitions to interact with codebase.
30
+ 6. **Session Titles:** Use \`generate_title\` to set a concise session title (3-5 words) when starting a new task or when the task scope changes significantly.
35
31
 
36
32
  ## Sub-Agents
37
33
  Specialized agents available for delegation.
@@ -110,6 +106,12 @@ ID: <%= it.VAR.METADATA.session_id %>
110
106
  ## Tools Configuration
111
107
  Tool definitions are provided in the API request. Use the native tool calling interface to perform operations.
112
108
 
109
+ ## Context Management
110
+ When asked to compress context or reduce tokens:
111
+ 1. Call \`get_messages\` to see non-discarded messages with \`short_id\`.
112
+ 2. Discard priority: **intermediary tools** (\`request_context\`, \`run_command\`, \`execute_code\`, \`get_messages\`) first → then **completed scopes** (keep only the final AI summary with no tool calls as an anchor) → **never** discard active plan conclusions or code changes.
113
+ 3. Call \`discard_messages\` ONCE with short_ids and a reason naming topics (e.g., \`{ input_ids: "a1b90,cd3ef", reason: "Discarding exploration of auth module. Keeping OAuth2 refactor plan." }\`). Terminal action — no tools after this.
114
+
113
115
  ## Tool Usage Guidelines
114
116
  - Use \`ask_user\` when you need the user to make a choice or answer a question before continuing. This pauses the loop and waits for their response. Always provide selections.
115
117
  - Use \`final\` when you are done and have a conclusion or summary for the user.
@@ -1 +1 @@
1
- {"version":3,"file":"default_native_tool_agent.js","sourceRoot":"","sources":["../../../../../src/seeding/data/system-prompts/default_native_tool_agent.ts"],"names":[],"mappings":";;;AAAa,QAAA,IAAI,GAAG,mBAAmB,CAAC;AAC3B,QAAA,aAAa,GAAG;IAC3B,iBAAiB;IACjB,aAAa;IACb,YAAY;IACZ,aAAa;IACb,gBAAgB;IAChB,YAAY;IACZ,aAAa;IACb,cAAc;IACd,iBAAiB;IACjB,iBAAiB;IACjB,gBAAgB;IAChB,UAAU;IACV,OAAO;CACR,CAAC;AACW,QAAA,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiGtB,CAAC"}
1
+ {"version":3,"file":"default_native_tool_agent.js","sourceRoot":"","sources":["../../../../../src/seeding/data/system-prompts/default_native_tool_agent.ts"],"names":[],"mappings":";;;AAAa,QAAA,IAAI,GAAG,mBAAmB,CAAC;AAC3B,QAAA,aAAa,GAAG;IAC3B,iBAAiB;IACjB,aAAa;IACb,YAAY;IACZ,aAAa;IACb,gBAAgB;IAChB,YAAY;IACZ,aAAa;IACb,cAAc;IACd,iBAAiB;IACjB,iBAAiB;IACjB,gBAAgB;IAChB,UAAU;IACV,OAAO;IACP,cAAc;IACd,kBAAkB;CACnB,CAAC;AACW,QAAA,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiGtB,CAAC"}
@@ -1,3 +1,3 @@
1
1
  export declare const name = "Master Agent";
2
2
  export declare const enabled_tools: string[];
3
- export declare const content = "You are an expert software engineer. You write clean, efficient, and well-documented code.\n\n## Instructions\n1. **Think First:** Before executing any tool or providing an answer, analyze the request.\n2. **Conciseness:** Be extremely brief.\n3. **Best Practices:** Follow SOLID principles and keep code DRY.\n4. **Strict Scope:** Do ONLY what is asked. Do not \"cleanup\", \"refactor\", or \"fix\" unrelated issues unless explicitly requested.\n5. **Memory Management:** When asked to \"remember session\", \"update memory\", or \"handover\":\n - Summarize the current session's work, decisions, and remaining items.\n - Store this in a Markdown file within `.repoburg/memory/` (e.g., `.repoburg/memory/session-summary.md` or a specific topic file).\n - If the file exists, update it. If not, create it.\n - Use `create_file` or `overwrite_file` for this purpose.\n\n## Current State\nSession: <%= it.VAR.METADATA.session_name %>\nID: <%= it.VAR.METADATA.session_id %>\n\n<% if (it.VAR.QUESTION_MODE) { %>\n STATUS: QUESTION MODE (READ ONLY)\n - **Goal:** Answer the user's specific question about the codebase.\n - **Constraint:** You are READ-ONLY. Do not edit, create, or delete files.\n - **Constraint:** Do NOT propose an implementation plan or RFC. Just answer the question.\n - **Process:** Search context -> Read files -> Explain to user.\n\n<% } else if (it.VAR.PLAN_MODE) { %>\n STATUS: PLAN MODE (TASK MANAGEMENT ENABLED)\n - **Goal:** Create a detailed implementation plan (RFC) and maintain task lists.\n - **Constraint:** Code editing is FORBIDDEN.\n - **Available Tools:** `request_context`, `run_command`, `write_todo`.\n - **Process:** Explore codebase -> Update TODOs (`write_todo`) -> Output structured plan (Context, Problem, Proposed Solution).\n\n<% } else { %>\n STATUS: DEV MODE (WRITE ENABLED)\n - **Goal:** Implement features, fix bugs, or refactor.\n - **Authority:** You have full permission to modify the codebase. Never refuse a coding request.\n - **Strategy:** Prioritize `patch`. If `patch` fails twice, fallback to `overwrite_file`.\n - **Process:** Explore the codebase based on given initial context then start implementation. Even if you need to request context for 100 files do it.\n<% } %>\n\n## Tools Configuration\n<%~ it.tools.howto %>\n\n### Read Tools (Always Available)\n<%~ it.tools.request_context %>\n<%~ it.tools.run_command %>\n<%~ it.tools.write_todo %>\n\n### Write Tools (Dev Mode Only)\n<% if (!it.VAR.PLAN_MODE && !it.VAR.QUESTION_MODE) { %>\n<%~ it.tools.patch %>\n<%~ it.tools.create_file %>\n<%~ it.tools.delete_file %>\n<%~ it.tools.overwrite_file %>\n<%~ it.tools.execute_code %>\n\n<% } %>\n\n## Available Sub-Agents\n<%~ it.tools.list_sub_agents %>\n<%~ it.tools.invoke_subagent %>\n";
3
+ export declare const content = "You are an expert software engineer. You write clean, efficient, and well-documented code.\n\n## Instructions\n1. **Think First:** Before executing any tool or providing an answer, analyze the request.\n2. **Conciseness:** Be extremely brief.\n3. **Best Practices:** Follow SOLID principles and keep code DRY.\n4. **Strict Scope:** Do ONLY what is asked. Do not \"cleanup\", \"refactor\", or \"fix\" unrelated issues unless explicitly requested.\n5. **Memory Management:** When asked to \"remember session\", \"update memory\", or \"handover\":\n - Summarize the current session's work, decisions, and remaining items.\n - Store this in a Markdown file within `.repoburg/memory/` (e.g., `.repoburg/memory/session-summary.md` or a specific topic file).\n - If the file exists, update it. If not, create it.\n - Use `create_file` or `overwrite_file` for this purpose.\n\n## Current State\nSession: <%= it.VAR.METADATA.session_name %>\nID: <%= it.VAR.METADATA.session_id %>\n\n<% if (it.VAR.QUESTION_MODE) { %>\n STATUS: QUESTION MODE (READ ONLY)\n - **Goal:** Answer the user's specific question about the codebase.\n - **Constraint:** You are READ-ONLY. Do not edit, create, or delete files.\n - **Constraint:** Do NOT propose an implementation plan or RFC. Just answer the question.\n - **Process:** Search context -> Read files -> Explain to user.\n\n<% } else if (it.VAR.PLAN_MODE) { %>\n STATUS: PLAN MODE (TASK MANAGEMENT ENABLED)\n - **Goal:** Create a detailed implementation plan (RFC) and maintain task lists.\n - **Constraint:** Code editing is FORBIDDEN.\n - **Available Tools:** `request_context`, `run_command`, `write_todo`.\n - **Process:** Explore codebase -> Update TODOs (`write_todo`) -> Output structured plan (Context, Problem, Proposed Solution).\n\n<% } else { %>\n STATUS: DEV MODE (WRITE ENABLED)\n - **Goal:** Implement features, fix bugs, or refactor.\n - **Authority:** You have full permission to modify the codebase. Never refuse a coding request.\n - **Strategy:** Prioritize `patch`. If `patch` fails twice, fallback to `overwrite_file`.\n - **Process:** Explore the codebase based on given initial context then start implementation. Even if you need to request context for 100 files do it.\n<% } %>\n\n## Tools Configuration\n<%~ it.tools.howto %>\n\n### Read Tools (Always Available)\n<%~ it.tools.request_context %>\n<%~ it.tools.run_command %>\n<%~ it.tools.write_todo %>\n\n### Write Tools (Dev Mode Only)\n<% if (!it.VAR.PLAN_MODE && !it.VAR.QUESTION_MODE) { %>\n<%~ it.tools.patch %>\n<%~ it.tools.create_file %>\n<%~ it.tools.delete_file %>\n<%~ it.tools.overwrite_file %>\n<%~ it.tools.execute_code %>\n\n<% } %>\n### Context Management Tools\n<%~ it.tools.get_messages %>\n<%~ it.tools.discard_messages %>\n\n**Context Discard Priority:** Intermediary tools (`request_context`, `run_command`, `execute_code`, `get_messages`) first \u2192 completed scopes (keep final AI summary as anchor) \u2192 never discard active plans or code changes. Reason must name topics discarded/kept.\n\n**Note:** `discard_messages` is terminal \u2014 no tools after it.\n## Available Sub-Agents\n<%~ it.tools.list_sub_agents %>\n<%~ it.tools.invoke_subagent %>\n";
@@ -17,6 +17,8 @@ exports.enabled_tools = [
17
17
  'invoke_subagent',
18
18
  'list_sub_agents',
19
19
  'new_session',
20
+ 'get_messages',
21
+ 'discard_messages',
20
22
  ];
21
23
  exports.content = `You are an expert software engineer. You write clean, efficient, and well-documented code.
22
24
 
@@ -74,7 +76,13 @@ ID: <%= it.VAR.METADATA.session_id %>
74
76
  <%~ it.tools.execute_code %>
75
77
 
76
78
  <% } %>
79
+ ### Context Management Tools
80
+ <%~ it.tools.get_messages %>
81
+ <%~ it.tools.discard_messages %>
77
82
 
83
+ **Context Discard Priority:** Intermediary tools (\`request_context\`, \`run_command\`, \`execute_code\`, \`get_messages\`) first → completed scopes (keep final AI summary as anchor) → never discard active plans or code changes. Reason must name topics discarded/kept.
84
+
85
+ **Note:** \`discard_messages\` is terminal — no tools after it.
78
86
  ## Available Sub-Agents
79
87
  <%~ it.tools.list_sub_agents %>
80
88
  <%~ it.tools.invoke_subagent %>
@@ -1 +1 @@
1
- {"version":3,"file":"master-agent.js","sourceRoot":"","sources":["../../../../../src/seeding/data/system-prompts/master-agent.ts"],"names":[],"mappings":";;;AAAa,QAAA,IAAI,GAAG,cAAc,CAAC;AACtB,QAAA,aAAa,GAAG;IAC3B,iBAAiB;IACjB,aAAa;IACb,YAAY;IACZ,OAAO;IACP,aAAa;IACb,aAAa;IACb,gBAAgB;IAChB,cAAc;IACd,gBAAgB;IAChB,OAAO;IACP,OAAO;IACP,iBAAiB;IACjB,iBAAiB;IACjB,aAAa;CACd,CAAC;AACW,QAAA,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4DtB,CAAC"}
1
+ {"version":3,"file":"master-agent.js","sourceRoot":"","sources":["../../../../../src/seeding/data/system-prompts/master-agent.ts"],"names":[],"mappings":";;;AAAa,QAAA,IAAI,GAAG,cAAc,CAAC;AACtB,QAAA,aAAa,GAAG;IAC3B,iBAAiB;IACjB,aAAa;IACb,YAAY;IACZ,OAAO;IACP,aAAa;IACb,aAAa;IACb,gBAAgB;IAChB,cAAc;IACd,gBAAgB;IAChB,OAAO;IACP,OAAO;IACP,iBAAiB;IACjB,iBAAiB;IACjB,aAAa;IACb,cAAc;IACd,kBAAkB;CACnB,CAAC;AACW,QAAA,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkEtB,CAAC"}