repoburg 1.3.19 → 1.3.21
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/backend/.repoburg/hooks/README.md +53 -0
- package/backend/.repoburg/hooks/eslint-hook.ts +46 -0
- package/backend/.repoburg/hooks/example-hook.ts +62 -0
- package/backend/dist/src/app.module.js +4 -0
- package/backend/dist/src/app.module.js.map +1 -1
- package/backend/dist/src/core-entities/index.d.ts +1 -0
- package/backend/dist/src/core-entities/index.js +1 -0
- package/backend/dist/src/core-entities/index.js.map +1 -1
- package/backend/dist/src/core-entities/tool-hook.entity.d.ts +7 -0
- package/backend/dist/src/core-entities/tool-hook.entity.js +37 -0
- package/backend/dist/src/core-entities/tool-hook.entity.js.map +1 -0
- package/backend/dist/src/llm-orchestration/action-handlers/execute-shell.handler.d.ts +1 -0
- package/backend/dist/src/llm-orchestration/action-handlers/execute-shell.handler.js +16 -3
- package/backend/dist/src/llm-orchestration/action-handlers/execute-shell.handler.js.map +1 -1
- package/backend/dist/src/llm-orchestration/action-handlers/run-command.handler.d.ts +1 -0
- package/backend/dist/src/llm-orchestration/action-handlers/run-command.handler.js +18 -1
- package/backend/dist/src/llm-orchestration/action-handlers/run-command.handler.js.map +1 -1
- package/backend/dist/src/llm-orchestration/llm-orchestration.interfaces.d.ts +1 -1
- package/backend/dist/src/llm-orchestration/llm-orchestration.module.js +87 -50
- package/backend/dist/src/llm-orchestration/llm-orchestration.module.js.map +1 -1
- package/backend/dist/src/llm-orchestration/llm-turn-processor.service.d.ts +3 -1
- package/backend/dist/src/llm-orchestration/llm-turn-processor.service.js +70 -2
- package/backend/dist/src/llm-orchestration/llm-turn-processor.service.js.map +1 -1
- package/backend/dist/src/seeding/data/system-prompts/default_master-agent.d.ts +1 -1
- package/backend/dist/src/seeding/data/system-prompts/default_master-agent.js +2 -2
- package/backend/dist/src/seeding/data/tool-hooks/eslint-hook.d.ts +2 -0
- package/backend/dist/src/seeding/data/tool-hooks/eslint-hook.js +52 -0
- package/backend/dist/src/seeding/data/tool-hooks/eslint-hook.js.map +1 -0
- package/backend/dist/src/seeding/data/tool-hooks/example-hook.d.ts +2 -0
- package/backend/dist/src/seeding/data/tool-hooks/example-hook.js +68 -0
- package/backend/dist/src/seeding/data/tool-hooks/example-hook.js.map +1 -0
- package/backend/dist/src/seeding/data/tool-hooks/readme.d.ts +2 -0
- package/backend/dist/src/seeding/data/tool-hooks/readme.js +59 -0
- package/backend/dist/src/seeding/data/tool-hooks/readme.js.map +1 -0
- package/backend/dist/src/tool-hooks/dto/create-tool-hook.dto.d.ts +6 -0
- package/backend/dist/src/tool-hooks/dto/create-tool-hook.dto.js +36 -0
- package/backend/dist/src/tool-hooks/dto/create-tool-hook.dto.js.map +1 -0
- package/backend/dist/src/tool-hooks/dto/update-tool-hook.dto.d.ts +6 -0
- package/backend/dist/src/tool-hooks/dto/update-tool-hook.dto.js +38 -0
- package/backend/dist/src/tool-hooks/dto/update-tool-hook.dto.js.map +1 -0
- package/backend/dist/src/tool-hooks/tool-hooks.controller.d.ts +27 -0
- package/backend/dist/src/tool-hooks/tool-hooks.controller.js +123 -0
- package/backend/dist/src/tool-hooks/tool-hooks.controller.js.map +1 -0
- package/backend/dist/src/tool-hooks/tool-hooks.module.d.ts +2 -0
- package/backend/dist/src/tool-hooks/tool-hooks.module.js +27 -0
- package/backend/dist/src/tool-hooks/tool-hooks.module.js.map +1 -0
- package/backend/dist/src/tool-hooks/tool-hooks.service.d.ts +31 -0
- package/backend/dist/src/tool-hooks/tool-hooks.service.js +337 -0
- package/backend/dist/src/tool-hooks/tool-hooks.service.js.map +1 -0
- package/backend/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -5,6 +5,7 @@ import { ActionHandler } from './action-handlers/action-handler.interface';
|
|
|
5
5
|
import { PostExecutionHook } from './hooks/post-execution-hook.interface';
|
|
6
6
|
import { ApplicationStateService } from '../application-state/application-state.service';
|
|
7
7
|
import { ExecutionLogsService } from '../execution-logs/execution-logs.service';
|
|
8
|
+
import { ToolHooksService } from '../tool-hooks/tool-hooks.service';
|
|
8
9
|
export declare class LlmTurnProcessorService {
|
|
9
10
|
private readonly parser;
|
|
10
11
|
private readonly handlerRegistry;
|
|
@@ -13,8 +14,9 @@ export declare class LlmTurnProcessorService {
|
|
|
13
14
|
private readonly sessionInputsRepository;
|
|
14
15
|
private readonly applicationStateService;
|
|
15
16
|
private readonly executionLogsService;
|
|
17
|
+
private readonly toolHooksService;
|
|
16
18
|
private readonly logger;
|
|
17
|
-
constructor(parser: LlmOutputParserService, handlerRegistry: Map<string, ActionHandler>, postExecutionHooks: PostExecutionHook[], aiActionsRepository: Repository<AIAction>, sessionInputsRepository: Repository<SessionInput>, applicationStateService: ApplicationStateService, executionLogsService: ExecutionLogsService);
|
|
19
|
+
constructor(parser: LlmOutputParserService, handlerRegistry: Map<string, ActionHandler>, postExecutionHooks: PostExecutionHook[], aiActionsRepository: Repository<AIAction>, sessionInputsRepository: Repository<SessionInput>, applicationStateService: ApplicationStateService, executionLogsService: ExecutionLogsService, toolHooksService: ToolHooksService);
|
|
18
20
|
processTurn(sessionInput: SessionInput): Promise<SessionInput>;
|
|
19
21
|
private getSuccessStatusForStrategy;
|
|
20
22
|
}
|
|
@@ -24,8 +24,9 @@ const handler_validation_error_1 = require("./errors/handler-validation.error");
|
|
|
24
24
|
const ai_actions_service_1 = require("../ai-actions/ai-actions.service");
|
|
25
25
|
const application_state_service_1 = require("../application-state/application-state.service");
|
|
26
26
|
const execution_logs_service_1 = require("../execution-logs/execution-logs.service");
|
|
27
|
+
const tool_hooks_service_1 = require("../tool-hooks/tool-hooks.service");
|
|
27
28
|
let LlmTurnProcessorService = LlmTurnProcessorService_1 = class LlmTurnProcessorService {
|
|
28
|
-
constructor(parser, handlerRegistry, postExecutionHooks, aiActionsRepository, sessionInputsRepository, applicationStateService, executionLogsService) {
|
|
29
|
+
constructor(parser, handlerRegistry, postExecutionHooks, aiActionsRepository, sessionInputsRepository, applicationStateService, executionLogsService, toolHooksService) {
|
|
29
30
|
this.parser = parser;
|
|
30
31
|
this.handlerRegistry = handlerRegistry;
|
|
31
32
|
this.postExecutionHooks = postExecutionHooks;
|
|
@@ -33,6 +34,7 @@ let LlmTurnProcessorService = LlmTurnProcessorService_1 = class LlmTurnProcessor
|
|
|
33
34
|
this.sessionInputsRepository = sessionInputsRepository;
|
|
34
35
|
this.applicationStateService = applicationStateService;
|
|
35
36
|
this.executionLogsService = executionLogsService;
|
|
37
|
+
this.toolHooksService = toolHooksService;
|
|
36
38
|
this.logger = new common_1.Logger(LlmTurnProcessorService_1.name);
|
|
37
39
|
}
|
|
38
40
|
async processTurn(sessionInput) {
|
|
@@ -68,6 +70,47 @@ let LlmTurnProcessorService = LlmTurnProcessorService_1 = class LlmTurnProcessor
|
|
|
68
70
|
for (const action of parsedActions) {
|
|
69
71
|
const handler = this.handlerRegistry.get(action.tool_name);
|
|
70
72
|
let result;
|
|
73
|
+
const beforeHooks = await this.toolHooksService.findByTrigger(action.tool_name, 'before');
|
|
74
|
+
let hookHalted = false;
|
|
75
|
+
for (const hook of beforeHooks) {
|
|
76
|
+
try {
|
|
77
|
+
this.logger.log(`Running BEFORE hook: ${hook.script_filename} for tool ${action.tool_name}`);
|
|
78
|
+
const hookResult = await this.toolHooksService.executeHook(hook.script_filename, {
|
|
79
|
+
hook_type: 'before',
|
|
80
|
+
action: { tool_name: action.tool_name, args: action.arguments },
|
|
81
|
+
plan_context: executionContext,
|
|
82
|
+
});
|
|
83
|
+
if (hookResult.should_halt_plan) {
|
|
84
|
+
this.logger.warn(`Hook ${hook.script_filename} halted execution.`);
|
|
85
|
+
executionContext.flags.should_halt = true;
|
|
86
|
+
executionContext.flags.halt_reason = `Hook ${hook.script_filename} returned halt signal.`;
|
|
87
|
+
hookHalted = true;
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
catch (e) {
|
|
92
|
+
this.logger.error(`Before-hook failed: ${e.message}`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (hookHalted) {
|
|
96
|
+
const aiActionEntity = this.aiActionsRepository.create({
|
|
97
|
+
input_id: sessionInput.id,
|
|
98
|
+
sessionInput: { id: sessionInput.id },
|
|
99
|
+
action_type: action.tool_name,
|
|
100
|
+
status: ai_actions_service_1.AIActionStatus.EXECUTION_FAILED,
|
|
101
|
+
order_of_execution: createdActions.length,
|
|
102
|
+
original_content_for_revert: null,
|
|
103
|
+
...action.arguments,
|
|
104
|
+
});
|
|
105
|
+
const savedAction = await this.aiActionsRepository.save(aiActionEntity);
|
|
106
|
+
createdActions.push(savedAction);
|
|
107
|
+
await this.executionLogsService.createLog({
|
|
108
|
+
action_id: savedAction.id,
|
|
109
|
+
error_message: executionContext.flags.halt_reason || 'Blocked by tool hook.',
|
|
110
|
+
output: 'Action execution prevented by a "before" hook.',
|
|
111
|
+
});
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
71
114
|
if (!handler) {
|
|
72
115
|
this.logger.warn(`No handler found for tool: ${action.tool_name}. Skipping.`);
|
|
73
116
|
executionContext.feedback.invalidToolErrors.push({
|
|
@@ -112,6 +155,30 @@ let LlmTurnProcessorService = LlmTurnProcessorService_1 = class LlmTurnProcessor
|
|
|
112
155
|
}
|
|
113
156
|
}
|
|
114
157
|
}
|
|
158
|
+
if (result) {
|
|
159
|
+
const afterHooks = await this.toolHooksService.findByTrigger(action.tool_name, 'after');
|
|
160
|
+
for (const hook of afterHooks) {
|
|
161
|
+
try {
|
|
162
|
+
this.logger.log(`Running AFTER hook: ${hook.script_filename} for tool ${action.tool_name}`);
|
|
163
|
+
await this.toolHooksService.executeHook(hook.script_filename, {
|
|
164
|
+
hook_type: 'after',
|
|
165
|
+
action: {
|
|
166
|
+
tool_name: action.tool_name,
|
|
167
|
+
args: action.arguments,
|
|
168
|
+
result: {
|
|
169
|
+
status: result.status,
|
|
170
|
+
output: result.execution_log?.output,
|
|
171
|
+
error: result.error_message,
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
plan_context: executionContext,
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
catch (e) {
|
|
178
|
+
this.logger.error(`After-hook failed: ${e.message}`);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
115
182
|
const executionStrategy = await this.applicationStateService.getExecutionStrategy();
|
|
116
183
|
this.logger.log(`Using execution strategy: ${executionStrategy}`);
|
|
117
184
|
const successStatus = this.getSuccessStatusForStrategy(executionStrategy);
|
|
@@ -181,6 +248,7 @@ exports.LlmTurnProcessorService = LlmTurnProcessorService = LlmTurnProcessorServ
|
|
|
181
248
|
Map, Array, typeorm_2.Repository,
|
|
182
249
|
typeorm_2.Repository,
|
|
183
250
|
application_state_service_1.ApplicationStateService,
|
|
184
|
-
execution_logs_service_1.ExecutionLogsService
|
|
251
|
+
execution_logs_service_1.ExecutionLogsService,
|
|
252
|
+
tool_hooks_service_1.ToolHooksService])
|
|
185
253
|
], LlmTurnProcessorService);
|
|
186
254
|
//# sourceMappingURL=llm-turn-processor.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"llm-turn-processor.service.js","sourceRoot":"","sources":["../../../src/llm-orchestration/llm-turn-processor.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAA4D;AAC5D,6CAAmD;AACnD,qCAAqC;AACrC,oDAA0D;AAC1D,kFAA4E;AAC5E,iFAGwC;AAGxC,gFAA2E;AAC3E,yEAAkE;AAClE,8FAAyF;AACzF,qFAAgF;
|
|
1
|
+
{"version":3,"file":"llm-turn-processor.service.js","sourceRoot":"","sources":["../../../src/llm-orchestration/llm-turn-processor.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAA4D;AAC5D,6CAAmD;AACnD,qCAAqC;AACrC,oDAA0D;AAC1D,kFAA4E;AAC5E,iFAGwC;AAGxC,gFAA2E;AAC3E,yEAAkE;AAClE,8FAAyF;AACzF,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BAIjB,OAAO,mCAAc,CAAC,sBAAsB,CAAC;YAC/C;gBAEE,IAAI,CAAC,MAAM,CAAC,IAAI,CACd,gCAAgC,QAAQ,0CAA0C,CACnF,CAAC;gBACF,OAAO,mCAAc,CAAC,sBAAsB,CAAC;QACjD,CAAC;IACH,CAAC;CACF,CAAA;AA/RY,0DAAuB;kCAAvB,uBAAuB;IADnC,IAAA,mBAAU,GAAE;IAMR,WAAA,IAAA,eAAM,EAAC,yBAAyB,CAAC,CAAA;IAEjC,WAAA,IAAA,eAAM,EAAC,sBAAsB,CAAC,CAAA;IAE9B,WAAA,IAAA,0BAAgB,EAAC,wBAAQ,CAAC,CAAA;IAE1B,WAAA,IAAA,0BAAgB,EAAC,4BAAY,CAAC,CAAA;qCAPN,kDAAsB;QAEb,GAAG,SAIC,oBAAU;QAEN,oBAAU;QACV,mDAAuB;QAC1B,6CAAoB;QACxB,qCAAgB;GAf1C,uBAAuB,CA+RnC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const name = "Master Agent";
|
|
2
|
-
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
|
|
2
|
+
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.\n</instructions>\n\n<current_state>\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 `edit_file`.\n<% } %>\n</current_state>\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.edit_file %>\n <%~ it.tools.execute_shell %>\n <%~ it.tools.execute_code %>\n \n <% } %>\n</tools_configuration>";
|
|
@@ -5,8 +5,8 @@ exports.name = 'Master Agent';
|
|
|
5
5
|
exports.content = `You are an expert software engineer. You write clean, efficient, and well-documented code.
|
|
6
6
|
|
|
7
7
|
<instructions>
|
|
8
|
-
1. **Think First:** Before executing any tool or providing an answer, analyze the request
|
|
9
|
-
2. **Conciseness:**
|
|
8
|
+
1. **Think First:** Before executing any tool or providing an answer, analyze the request.
|
|
9
|
+
2. **Conciseness:** Be extremely brief.
|
|
10
10
|
3. **Best Practices:** Follow SOLID principles and keep code DRY.
|
|
11
11
|
4. **Strict Scope:** Do ONLY what is asked. Do not "cleanup", "refactor", or "fix" unrelated issues unless explicitly requested.
|
|
12
12
|
</instructions>
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const filename = "eslint-hook.ts";
|
|
2
|
+
export declare const content = "/**\n * ESLint Validation Hook\n * \n * Usage: Attach as 'after' hook to 'create_file', 'edit_file', 'patch'.\n */\nimport { exec } from 'child_process';\nimport { promisify } from 'util';\n\nconst execAsync = promisify(exec);\n\n// Redefining types locally since this runs in a standalone VM context\nexport interface HookContext {\n action: {\n tool_name: string;\n args: { file_path?: string; [key: string]: any };\n };\n plan_context: {\n feedback: {\n validationErrors: Array<{ tool_name: string; error: string }>;\n };\n };\n}\n\nexport default async function(context: HookContext) {\n const filePath = context.action.args.file_path;\n if (!filePath) return;\n\n console.log(`[Hook] Running ESLint on ${filePath}`);\n\n try {\n // Adjust command as needed for your project structure\n // We use --no-color to keep the error message clean for the AI\n await execAsync(`npx eslint \"${filePath}\" --no-color`);\n } catch (e: any) {\n const errorOutput = e.stdout || e.stderr || e.message;\n \n console.log(`[Hook] ESLint failed for ${filePath}`);\n\n // Inject error into the shared plan context\n // The orchestration engine will pick this up and present it to the AI in the next turn (or immediate feedback)\n context.plan_context.feedback.validationErrors.push({\n tool_name: context.action.tool_name,\n error: `ESLint check failed:\\n${errorOutput}`\n });\n }\n}\n";
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.content = exports.filename = void 0;
|
|
4
|
+
exports.filename = 'eslint-hook.ts';
|
|
5
|
+
exports.content = `/**
|
|
6
|
+
* ESLint Validation Hook
|
|
7
|
+
*
|
|
8
|
+
* Usage: Attach as 'after' hook to 'create_file', 'edit_file', 'patch'.
|
|
9
|
+
*/
|
|
10
|
+
import { exec } from 'child_process';
|
|
11
|
+
import { promisify } from 'util';
|
|
12
|
+
|
|
13
|
+
const execAsync = promisify(exec);
|
|
14
|
+
|
|
15
|
+
// Redefining types locally since this runs in a standalone VM context
|
|
16
|
+
export interface HookContext {
|
|
17
|
+
action: {
|
|
18
|
+
tool_name: string;
|
|
19
|
+
args: { file_path?: string; [key: string]: any };
|
|
20
|
+
};
|
|
21
|
+
plan_context: {
|
|
22
|
+
feedback: {
|
|
23
|
+
validationErrors: Array<{ tool_name: string; error: string }>;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default async function(context: HookContext) {
|
|
29
|
+
const filePath = context.action.args.file_path;
|
|
30
|
+
if (!filePath) return;
|
|
31
|
+
|
|
32
|
+
console.log(\`[Hook] Running ESLint on \${filePath}\`);
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
// Adjust command as needed for your project structure
|
|
36
|
+
// We use --no-color to keep the error message clean for the AI
|
|
37
|
+
await execAsync(\`npx eslint "\${filePath}" --no-color\`);
|
|
38
|
+
} catch (e: any) {
|
|
39
|
+
const errorOutput = e.stdout || e.stderr || e.message;
|
|
40
|
+
|
|
41
|
+
console.log(\`[Hook] ESLint failed for \${filePath}\`);
|
|
42
|
+
|
|
43
|
+
// Inject error into the shared plan context
|
|
44
|
+
// The orchestration engine will pick this up and present it to the AI in the next turn (or immediate feedback)
|
|
45
|
+
context.plan_context.feedback.validationErrors.push({
|
|
46
|
+
tool_name: context.action.tool_name,
|
|
47
|
+
error: \`ESLint check failed:\\n\${errorOutput}\`
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
`;
|
|
52
|
+
//# sourceMappingURL=eslint-hook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eslint-hook.js","sourceRoot":"","sources":["../../../../../src/seeding/data/tool-hooks/eslint-hook.ts"],"names":[],"mappings":";;;AAAa,QAAA,QAAQ,GAAG,gBAAgB,CAAC;AAC5B,QAAA,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8CtB,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const filename = "example-hook.ts";
|
|
2
|
+
export declare const content = "/**\n * Example Hook Script\n * \n * Usage: \n * 1. Attach to 'patch' or 'edit_file' tool as a 'before' hook.\n * 2. It will block edits to any file with 'lock' in the name.\n */\n\n// --- Type Definitions ---\n\nexport interface HookAction {\n tool_name: string;\n args: Record<string, any>;\n // Only present for 'after' hooks\n result?: {\n status: 'SUCCESS' | 'FAILURE';\n output?: string;\n error?: string;\n };\n}\n\nexport interface HookContext {\n hook_type: 'before' | 'after';\n action: HookAction;\n plan_context: any; // Shared state of the current AI plan\n}\n\nexport interface HookOutput {\n // If true, the AI plan stops immediately.\n should_halt_plan?: boolean;\n \n // Optional message to log in the UI\n message?: string;\n \n // Optional data to merge back into the plan context\n update_context?: Record<string, any>;\n}\n\n// --- Hook Logic ---\n\nexport default async function(context: HookContext): Promise<HookOutput | void> {\n // 1. Extract Data\n const filePath = context.action?.args?.file_path || '';\n \n // Log to console (appears in backend logs)\n console.log(`[Hook] analyzing action on: ${filePath}`);\n\n // 2. Logic\n if (filePath.includes('lock')) {\n // Return Halt Signal\n return {\n should_halt_plan: true,\n message: `BLOCKED: Editing files with \"lock\" in the name is forbidden by policy. File: ${filePath}`\n };\n } else {\n // Return Pass Signal\n return {\n should_halt_plan: false,\n message: `Hook allowed action on ${filePath}`\n };\n }\n}\n";
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.content = exports.filename = void 0;
|
|
4
|
+
exports.filename = 'example-hook.ts';
|
|
5
|
+
exports.content = `/**
|
|
6
|
+
* Example Hook Script
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* 1. Attach to 'patch' or 'edit_file' tool as a 'before' hook.
|
|
10
|
+
* 2. It will block edits to any file with 'lock' in the name.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
// --- Type Definitions ---
|
|
14
|
+
|
|
15
|
+
export interface HookAction {
|
|
16
|
+
tool_name: string;
|
|
17
|
+
args: Record<string, any>;
|
|
18
|
+
// Only present for 'after' hooks
|
|
19
|
+
result?: {
|
|
20
|
+
status: 'SUCCESS' | 'FAILURE';
|
|
21
|
+
output?: string;
|
|
22
|
+
error?: string;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface HookContext {
|
|
27
|
+
hook_type: 'before' | 'after';
|
|
28
|
+
action: HookAction;
|
|
29
|
+
plan_context: any; // Shared state of the current AI plan
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface HookOutput {
|
|
33
|
+
// If true, the AI plan stops immediately.
|
|
34
|
+
should_halt_plan?: boolean;
|
|
35
|
+
|
|
36
|
+
// Optional message to log in the UI
|
|
37
|
+
message?: string;
|
|
38
|
+
|
|
39
|
+
// Optional data to merge back into the plan context
|
|
40
|
+
update_context?: Record<string, any>;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// --- Hook Logic ---
|
|
44
|
+
|
|
45
|
+
export default async function(context: HookContext): Promise<HookOutput | void> {
|
|
46
|
+
// 1. Extract Data
|
|
47
|
+
const filePath = context.action?.args?.file_path || '';
|
|
48
|
+
|
|
49
|
+
// Log to console (appears in backend logs)
|
|
50
|
+
console.log(\`[Hook] analyzing action on: \${filePath}\`);
|
|
51
|
+
|
|
52
|
+
// 2. Logic
|
|
53
|
+
if (filePath.includes('lock')) {
|
|
54
|
+
// Return Halt Signal
|
|
55
|
+
return {
|
|
56
|
+
should_halt_plan: true,
|
|
57
|
+
message: \`BLOCKED: Editing files with "lock" in the name is forbidden by policy. File: \${filePath}\`
|
|
58
|
+
};
|
|
59
|
+
} else {
|
|
60
|
+
// Return Pass Signal
|
|
61
|
+
return {
|
|
62
|
+
should_halt_plan: false,
|
|
63
|
+
message: \`Hook allowed action on \${filePath}\`
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
`;
|
|
68
|
+
//# sourceMappingURL=example-hook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"example-hook.js","sourceRoot":"","sources":["../../../../../src/seeding/data/tool-hooks/example-hook.ts"],"names":[],"mappings":";;;AAAa,QAAA,QAAQ,GAAG,iBAAiB,CAAC;AAC7B,QAAA,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8DtB,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const filename = "README.md";
|
|
2
|
+
export declare const content = "# Repoburg Tool Hooks\n\nThis directory contains TypeScript scripts that can be attached to AI tool execution events.\nYou can configure these hooks in the \"Tool Hooks\" section of the Repoburg UI.\n\n## How it works\n\n1. **Create a script** in this folder (e.g., `audit-patch.ts`).\n2. **Go to UI**: Open Repoburg -> Tool Hooks -> Add Hook.\n3. **Configure**: Select the tool (e.g., `patch`), timing (`before` or `after`), and your script.\n\n## Script Interface\n\nYour script must **export a default function** that receives the context.\n\n### Input Context\n\n```typescript\ninterface HookContext {\n hook_type: 'before' | 'after';\n \n action: {\n tool_name: string; // e.g. \"patch\"\n args: any; // e.g. { file_path: \"src/app.ts\", patch_code: \"...\" }\n \n // Only present for 'after' hooks\n result?: {\n status: 'SUCCESS' | 'FAILURE';\n output?: string;\n error?: string;\n };\n };\n\n plan_context: any; // Shared state of the current AI plan\n}\n```\n\n### Output Format\n\nYour function should return an object (or void if passive):\n\n```typescript\ninterface HookOutput {\n // If true, the AI plan stops immediately.\n should_halt_plan?: boolean;\n \n // Optional message to log in the UI\n message?: string;\n \n // Optional data to merge back into the plan context\n update_context?: Record<string, any>;\n}\n```\n";
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.content = exports.filename = void 0;
|
|
4
|
+
exports.filename = 'README.md';
|
|
5
|
+
exports.content = `# Repoburg Tool Hooks
|
|
6
|
+
|
|
7
|
+
This directory contains TypeScript scripts that can be attached to AI tool execution events.
|
|
8
|
+
You can configure these hooks in the "Tool Hooks" section of the Repoburg UI.
|
|
9
|
+
|
|
10
|
+
## How it works
|
|
11
|
+
|
|
12
|
+
1. **Create a script** in this folder (e.g., \`audit-patch.ts\`).
|
|
13
|
+
2. **Go to UI**: Open Repoburg -> Tool Hooks -> Add Hook.
|
|
14
|
+
3. **Configure**: Select the tool (e.g., \`patch\`), timing (\`before\` or \`after\`), and your script.
|
|
15
|
+
|
|
16
|
+
## Script Interface
|
|
17
|
+
|
|
18
|
+
Your script must **export a default function** that receives the context.
|
|
19
|
+
|
|
20
|
+
### Input Context
|
|
21
|
+
|
|
22
|
+
\`\`\`typescript
|
|
23
|
+
interface HookContext {
|
|
24
|
+
hook_type: 'before' | 'after';
|
|
25
|
+
|
|
26
|
+
action: {
|
|
27
|
+
tool_name: string; // e.g. "patch"
|
|
28
|
+
args: any; // e.g. { file_path: "src/app.ts", patch_code: "..." }
|
|
29
|
+
|
|
30
|
+
// Only present for 'after' hooks
|
|
31
|
+
result?: {
|
|
32
|
+
status: 'SUCCESS' | 'FAILURE';
|
|
33
|
+
output?: string;
|
|
34
|
+
error?: string;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
plan_context: any; // Shared state of the current AI plan
|
|
39
|
+
}
|
|
40
|
+
\`\`\`
|
|
41
|
+
|
|
42
|
+
### Output Format
|
|
43
|
+
|
|
44
|
+
Your function should return an object (or void if passive):
|
|
45
|
+
|
|
46
|
+
\`\`\`typescript
|
|
47
|
+
interface HookOutput {
|
|
48
|
+
// If true, the AI plan stops immediately.
|
|
49
|
+
should_halt_plan?: boolean;
|
|
50
|
+
|
|
51
|
+
// Optional message to log in the UI
|
|
52
|
+
message?: string;
|
|
53
|
+
|
|
54
|
+
// Optional data to merge back into the plan context
|
|
55
|
+
update_context?: Record<string, any>;
|
|
56
|
+
}
|
|
57
|
+
\`\`\`
|
|
58
|
+
`;
|
|
59
|
+
//# sourceMappingURL=readme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readme.js","sourceRoot":"","sources":["../../../../../src/seeding/data/tool-hooks/readme.ts"],"names":[],"mappings":";;;AAAa,QAAA,QAAQ,GAAG,WAAW,CAAC;AACvB,QAAA,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqDtB,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
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.CreateToolHookDto = void 0;
|
|
13
|
+
const class_validator_1 = require("class-validator");
|
|
14
|
+
class CreateToolHookDto {
|
|
15
|
+
}
|
|
16
|
+
exports.CreateToolHookDto = CreateToolHookDto;
|
|
17
|
+
__decorate([
|
|
18
|
+
(0, class_validator_1.IsString)(),
|
|
19
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
20
|
+
__metadata("design:type", String)
|
|
21
|
+
], CreateToolHookDto.prototype, "tool_name", void 0);
|
|
22
|
+
__decorate([
|
|
23
|
+
(0, class_validator_1.IsString)(),
|
|
24
|
+
(0, class_validator_1.IsIn)(['before', 'after']),
|
|
25
|
+
__metadata("design:type", String)
|
|
26
|
+
], CreateToolHookDto.prototype, "timing", void 0);
|
|
27
|
+
__decorate([
|
|
28
|
+
(0, class_validator_1.IsString)(),
|
|
29
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
30
|
+
__metadata("design:type", String)
|
|
31
|
+
], CreateToolHookDto.prototype, "script_filename", void 0);
|
|
32
|
+
__decorate([
|
|
33
|
+
(0, class_validator_1.IsBoolean)(),
|
|
34
|
+
__metadata("design:type", Boolean)
|
|
35
|
+
], CreateToolHookDto.prototype, "is_active", void 0);
|
|
36
|
+
//# sourceMappingURL=create-tool-hook.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-tool-hook.dto.js","sourceRoot":"","sources":["../../../../src/tool-hooks/dto/create-tool-hook.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAwE;AAExE,MAAa,iBAAiB;CAe7B;AAfD,8CAeC;AAZC;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;oDACK;AAIlB;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,sBAAI,EAAC,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;;iDACC;AAI3B;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;0DACW;AAGxB;IADC,IAAA,2BAAS,GAAE;;oDACO"}
|
|
@@ -0,0 +1,38 @@
|
|
|
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.UpdateToolHookDto = void 0;
|
|
13
|
+
const class_validator_1 = require("class-validator");
|
|
14
|
+
class UpdateToolHookDto {
|
|
15
|
+
}
|
|
16
|
+
exports.UpdateToolHookDto = UpdateToolHookDto;
|
|
17
|
+
__decorate([
|
|
18
|
+
(0, class_validator_1.IsString)(),
|
|
19
|
+
(0, class_validator_1.IsOptional)(),
|
|
20
|
+
__metadata("design:type", String)
|
|
21
|
+
], UpdateToolHookDto.prototype, "tool_name", void 0);
|
|
22
|
+
__decorate([
|
|
23
|
+
(0, class_validator_1.IsString)(),
|
|
24
|
+
(0, class_validator_1.IsOptional)(),
|
|
25
|
+
(0, class_validator_1.IsIn)(['before', 'after']),
|
|
26
|
+
__metadata("design:type", String)
|
|
27
|
+
], UpdateToolHookDto.prototype, "timing", void 0);
|
|
28
|
+
__decorate([
|
|
29
|
+
(0, class_validator_1.IsString)(),
|
|
30
|
+
(0, class_validator_1.IsOptional)(),
|
|
31
|
+
__metadata("design:type", String)
|
|
32
|
+
], UpdateToolHookDto.prototype, "script_filename", void 0);
|
|
33
|
+
__decorate([
|
|
34
|
+
(0, class_validator_1.IsBoolean)(),
|
|
35
|
+
(0, class_validator_1.IsOptional)(),
|
|
36
|
+
__metadata("design:type", Boolean)
|
|
37
|
+
], UpdateToolHookDto.prototype, "is_active", void 0);
|
|
38
|
+
//# sourceMappingURL=update-tool-hook.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-tool-hook.dto.js","sourceRoot":"","sources":["../../../../src/tool-hooks/dto/update-tool-hook.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAwE;AAExE,MAAa,iBAAiB;CAiB7B;AAjBD,8CAiBC;AAdC;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;oDACM;AAKnB;IAHC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;IACZ,IAAA,sBAAI,EAAC,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;;iDACE;AAI5B;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;0DACY;AAIzB;IAFC,IAAA,2BAAS,GAAE;IACX,IAAA,4BAAU,GAAE;;oDACO"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ToolHooksService } from './tool-hooks.service';
|
|
2
|
+
import { CreateToolHookDto } from './dto/create-tool-hook.dto';
|
|
3
|
+
import { UpdateToolHookDto } from './dto/update-tool-hook.dto';
|
|
4
|
+
export declare class ToolHooksController {
|
|
5
|
+
private readonly toolHooksService;
|
|
6
|
+
constructor(toolHooksService: ToolHooksService);
|
|
7
|
+
findAll(): Promise<import("../core-entities").ToolHook[]>;
|
|
8
|
+
listScripts(): Promise<string[]>;
|
|
9
|
+
getTemplate(toolName: string): {
|
|
10
|
+
content: string;
|
|
11
|
+
};
|
|
12
|
+
getSamplePayload(toolName: string, timing: 'before' | 'after'): any;
|
|
13
|
+
testHook(body: {
|
|
14
|
+
script_filename: string;
|
|
15
|
+
payload: any;
|
|
16
|
+
}): Promise<{
|
|
17
|
+
result: any;
|
|
18
|
+
logs: string[];
|
|
19
|
+
}>;
|
|
20
|
+
createScript(body: {
|
|
21
|
+
filename: string;
|
|
22
|
+
content: string;
|
|
23
|
+
}): Promise<void>;
|
|
24
|
+
create(createToolHookDto: CreateToolHookDto): Promise<import("../core-entities").ToolHook>;
|
|
25
|
+
update(id: string, updateToolHookDto: UpdateToolHookDto): Promise<import("../core-entities").ToolHook>;
|
|
26
|
+
remove(id: string): Promise<void>;
|
|
27
|
+
}
|