repoburg 1.3.12 → 1.3.14
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/dist/packages/tokenpatch/index.d.ts +5 -1
- package/backend/dist/packages/tokenpatch/index.js +39 -22
- package/backend/dist/packages/tokenpatch/index.js.map +1 -1
- package/backend/dist/packages/tokenpatch/patcher.js +57 -16
- package/backend/dist/packages/tokenpatch/patcher.js.map +1 -1
- package/backend/dist/packages/tokenpatch/strategies/tiktoken-tokenizer.d.ts +6 -0
- package/backend/dist/packages/tokenpatch/strategies/tiktoken-tokenizer.js +28 -0
- package/backend/dist/packages/tokenpatch/strategies/tiktoken-tokenizer.js.map +1 -0
- package/backend/dist/packages/tokenpatch/strategies/tree-sitter-tokenizer.d.ts +9 -0
- package/backend/dist/packages/tokenpatch/strategies/tree-sitter-tokenizer.js +36 -0
- package/backend/dist/packages/tokenpatch/strategies/tree-sitter-tokenizer.js.map +1 -0
- package/backend/dist/packages/tokenpatch/tokenizer.interface.d.ts +4 -0
- package/backend/dist/packages/tokenpatch/tokenizer.interface.js +3 -0
- package/backend/dist/packages/tokenpatch/tokenizer.interface.js.map +1 -0
- package/backend/dist/packages/tokenpatch/tokens.d.ts +0 -2
- package/backend/dist/packages/tokenpatch/tokens.js +4 -23
- package/backend/dist/packages/tokenpatch/tokens.js.map +1 -1
- package/backend/dist/packages/tokenpatch/types.d.ts +2 -2
- package/backend/dist/src/ai-actions/ai-actions.service.d.ts +3 -1
- package/backend/dist/src/ai-actions/ai-actions.service.js +4 -0
- package/backend/dist/src/ai-actions/ai-actions.service.js.map +1 -1
- package/backend/dist/src/llm-orchestration/action-handlers/dto/execute-shell.args.dto.d.ts +4 -0
- package/backend/dist/src/llm-orchestration/action-handlers/dto/execute-shell.args.dto.js +27 -0
- package/backend/dist/src/llm-orchestration/action-handlers/dto/execute-shell.args.dto.js.map +1 -0
- package/backend/dist/src/llm-orchestration/action-handlers/dto/write-todo.args.dto.d.ts +4 -0
- package/backend/dist/src/llm-orchestration/action-handlers/dto/write-todo.args.dto.js +31 -0
- package/backend/dist/src/llm-orchestration/action-handlers/dto/write-todo.args.dto.js.map +1 -0
- package/backend/dist/src/llm-orchestration/action-handlers/execute-shell.handler.d.ts +11 -0
- package/backend/dist/src/llm-orchestration/action-handlers/execute-shell.handler.js +111 -0
- package/backend/dist/src/llm-orchestration/action-handlers/execute-shell.handler.js.map +1 -0
- package/backend/dist/src/llm-orchestration/action-handlers/howto.handler.js +2 -0
- package/backend/dist/src/llm-orchestration/action-handlers/howto.handler.js.map +1 -1
- package/backend/dist/src/llm-orchestration/action-handlers/patch.handler.js +125 -47
- package/backend/dist/src/llm-orchestration/action-handlers/patch.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 +12 -19
- package/backend/dist/src/llm-orchestration/action-handlers/run-command.handler.js.map +1 -1
- package/backend/dist/src/llm-orchestration/action-handlers/write-todo.handler.d.ts +13 -0
- package/backend/dist/src/llm-orchestration/action-handlers/write-todo.handler.js +116 -0
- package/backend/dist/src/llm-orchestration/action-handlers/write-todo.handler.js.map +1 -0
- package/backend/dist/src/llm-orchestration/llm-orchestration.module.js +4 -0
- package/backend/dist/src/llm-orchestration/llm-orchestration.module.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 +50 -493
- package/backend/dist/src/seeding/data/system-prompts/default_master-agent.js.map +1 -1
- package/backend/dist/tsconfig.build.tsbuildinfo +1 -1
- package/backend/packages/tokenpatch/index.spec.ts +44 -30
- package/backend/packages/tokenpatch/index.ts +54 -32
- package/backend/packages/tokenpatch/patcher.ts +107 -26
- package/backend/packages/tokenpatch/strategies/tiktoken-tokenizer.ts +35 -0
- package/backend/packages/tokenpatch/strategies/tree-sitter-tokenizer.ts +37 -0
- package/backend/packages/tokenpatch/tokenizer.interface.ts +5 -0
- package/backend/packages/tokenpatch/tokens.ts +10 -28
- package/backend/packages/tokenpatch/types.ts +4 -4
- package/package.json +2 -1
- package/backend/dist/src/seeding/data/system-prompts/carryover-agent.d.ts +0 -2
- package/backend/dist/src/seeding/data/system-prompts/carryover-agent.js +0 -107
- package/backend/dist/src/seeding/data/system-prompts/carryover-agent.js.map +0 -1
- package/backend/dist/src/seeding/data/system-prompts/experimental_eta_master-agent.d.ts +0 -2
- package/backend/dist/src/seeding/data/system-prompts/experimental_eta_master-agent.js +0 -62
- package/backend/dist/src/seeding/data/system-prompts/experimental_eta_master-agent.js.map +0 -1
- package/backend/dist/src/seeding/data/system-prompts/experimental_master-agent.d.ts +0 -2
- package/backend/dist/src/seeding/data/system-prompts/experimental_master-agent.js +0 -633
- package/backend/dist/src/seeding/data/system-prompts/experimental_master-agent.js.map +0 -1
- package/backend/dist/src/seeding/data/system-prompts/experimental_patch_master-agent.d.ts +0 -2
- package/backend/dist/src/seeding/data/system-prompts/experimental_patch_master-agent.js +0 -463
- package/backend/dist/src/seeding/data/system-prompts/experimental_patch_master-agent.js.map +0 -1
- package/backend/dist/src/seeding/data/system-prompts/refactor-split.d.ts +0 -2
- package/backend/dist/src/seeding/data/system-prompts/refactor-split.js +0 -57
- package/backend/dist/src/seeding/data/system-prompts/refactor-split.js.map +0 -1
|
@@ -0,0 +1,31 @@
|
|
|
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.WriteTodoArgsDto = void 0;
|
|
13
|
+
const class_validator_1 = require("class-validator");
|
|
14
|
+
const sanitizer_decorator_1 = require("./sanitizer.decorator");
|
|
15
|
+
class WriteTodoArgsDto {
|
|
16
|
+
}
|
|
17
|
+
exports.WriteTodoArgsDto = WriteTodoArgsDto;
|
|
18
|
+
__decorate([
|
|
19
|
+
(0, class_validator_1.IsString)({ message: 'file_path must be a string.' }),
|
|
20
|
+
(0, class_validator_1.IsNotEmpty)({ message: 'file_path must not be empty.' }),
|
|
21
|
+
__metadata("design:type", String)
|
|
22
|
+
], WriteTodoArgsDto.prototype, "file_path", void 0);
|
|
23
|
+
__decorate([
|
|
24
|
+
(0, sanitizer_decorator_1.SanitizeCodeBlock)(),
|
|
25
|
+
(0, class_validator_1.IsString)({ message: 'content must be a string.' }),
|
|
26
|
+
(0, class_validator_1.IsDefined)({
|
|
27
|
+
message: 'content is a required field for writing a todo file.',
|
|
28
|
+
}),
|
|
29
|
+
__metadata("design:type", String)
|
|
30
|
+
], WriteTodoArgsDto.prototype, "content", void 0);
|
|
31
|
+
//# sourceMappingURL=write-todo.args.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write-todo.args.dto.js","sourceRoot":"","sources":["../../../../../src/llm-orchestration/action-handlers/dto/write-todo.args.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAkE;AAClE,+DAA0D;AAE1D,MAAa,gBAAgB;CAW5B;AAXD,4CAWC;AARC;IAFC,IAAA,0BAAQ,EAAC,EAAE,OAAO,EAAE,6BAA6B,EAAE,CAAC;IACpD,IAAA,4BAAU,EAAC,EAAE,OAAO,EAAE,8BAA8B,EAAE,CAAC;;mDACtC;AAOlB;IALC,IAAA,uCAAiB,GAAE;IACnB,IAAA,0BAAQ,EAAC,EAAE,OAAO,EAAE,2BAA2B,EAAE,CAAC;IAClD,IAAA,2BAAS,EAAC;QACT,OAAO,EAAE,sDAAsD;KAChE,CAAC;;iDACc"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ActionHandler } from './action-handler.interface';
|
|
2
|
+
import { ActionExecutionResult, PlanExecutionContext } from '../llm-orchestration.interfaces';
|
|
3
|
+
export declare class ExecuteShellHandler implements ActionHandler {
|
|
4
|
+
readonly toolName = "execute_shell";
|
|
5
|
+
private readonly logger;
|
|
6
|
+
private readonly projectRoot;
|
|
7
|
+
getDefinition(): string;
|
|
8
|
+
execute(args: {
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
}, context: PlanExecutionContext): Promise<ActionExecutionResult>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
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 ExecuteShellHandler_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.ExecuteShellHandler = void 0;
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const child_process_1 = require("child_process");
|
|
13
|
+
const util_1 = require("util");
|
|
14
|
+
const execute_shell_args_dto_1 = require("./dto/execute-shell.args.dto");
|
|
15
|
+
const class_transformer_1 = require("class-transformer");
|
|
16
|
+
const class_validator_1 = require("class-validator");
|
|
17
|
+
const handler_validation_error_1 = require("../errors/handler-validation.error");
|
|
18
|
+
const utils_1 = require("../../utils");
|
|
19
|
+
const execAsync = (0, util_1.promisify)(child_process_1.exec);
|
|
20
|
+
let ExecuteShellHandler = ExecuteShellHandler_1 = class ExecuteShellHandler {
|
|
21
|
+
constructor() {
|
|
22
|
+
this.toolName = 'execute_shell';
|
|
23
|
+
this.logger = new common_1.Logger(ExecuteShellHandler_1.name);
|
|
24
|
+
this.projectRoot = process.env.REPOBURG_PROJECT_PATH || process.cwd();
|
|
25
|
+
}
|
|
26
|
+
getDefinition() {
|
|
27
|
+
const installExample = (0, utils_1.generateToolCall)({
|
|
28
|
+
tool_name: this.toolName,
|
|
29
|
+
command_string: 'npm install lodash',
|
|
30
|
+
});
|
|
31
|
+
const gitExample = (0, utils_1.generateToolCall)({
|
|
32
|
+
tool_name: this.toolName,
|
|
33
|
+
command_string: 'git status',
|
|
34
|
+
});
|
|
35
|
+
const scriptExample = (0, utils_1.generateToolCall)({
|
|
36
|
+
tool_name: this.toolName,
|
|
37
|
+
command_string: './scripts/deploy.sh --env=prod',
|
|
38
|
+
});
|
|
39
|
+
const definition = `
|
|
40
|
+
<${this.toolName}>
|
|
41
|
+
Executes an arbitrary shell command in the root of the project.
|
|
42
|
+
Used for system modifications, running scripts, package management, or git operations.
|
|
43
|
+
WARNING: This tool allows unrestricted execution. Use with caution.
|
|
44
|
+
|
|
45
|
+
Parameters:
|
|
46
|
+
- "command_string": (string) The shell command to execute.
|
|
47
|
+
|
|
48
|
+
<example>
|
|
49
|
+
${installExample}
|
|
50
|
+
</example>
|
|
51
|
+
|
|
52
|
+
<example>
|
|
53
|
+
${gitExample}
|
|
54
|
+
</example>
|
|
55
|
+
|
|
56
|
+
<example>
|
|
57
|
+
${scriptExample}
|
|
58
|
+
</example>
|
|
59
|
+
</${this.toolName}>
|
|
60
|
+
`;
|
|
61
|
+
return definition.trim();
|
|
62
|
+
}
|
|
63
|
+
async execute(args, context) {
|
|
64
|
+
const validatedArgs = (0, class_transformer_1.plainToClass)(execute_shell_args_dto_1.ExecuteShellArgsDto, args);
|
|
65
|
+
const errors = await (0, class_validator_1.validate)(validatedArgs);
|
|
66
|
+
if (errors.length > 0) {
|
|
67
|
+
const errorMessages = errors
|
|
68
|
+
.map((err) => Object.values(err.constraints || {}).join(', '))
|
|
69
|
+
.join('; ');
|
|
70
|
+
throw new handler_validation_error_1.HandlerValidationError(errorMessages);
|
|
71
|
+
}
|
|
72
|
+
const { command_string } = validatedArgs;
|
|
73
|
+
let unifiedOutput;
|
|
74
|
+
let summary;
|
|
75
|
+
let status = 'SUCCESS';
|
|
76
|
+
let errorMessage;
|
|
77
|
+
try {
|
|
78
|
+
const { stdout, stderr } = await execAsync(command_string, {
|
|
79
|
+
cwd: this.projectRoot,
|
|
80
|
+
maxBuffer: 128 * 1024 * 1024,
|
|
81
|
+
timeout: 60000,
|
|
82
|
+
});
|
|
83
|
+
unifiedOutput = stdout || stderr || '(Command produced no output)';
|
|
84
|
+
summary = `Shell command "${command_string}" executed.`;
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
const execError = error;
|
|
88
|
+
unifiedOutput = `COMMAND FAILED: ${execError.message}\n\nSTDOUT:\n${execError.stdout || 'N/A'}\n\nSTDERR:\n${execError.stderr || 'N/A'}`;
|
|
89
|
+
summary = `Shell command "${command_string}" failed.`;
|
|
90
|
+
status = 'FAILURE';
|
|
91
|
+
errorMessage = execError.message;
|
|
92
|
+
this.logger.error(`Error executing shell command: ${unifiedOutput}`);
|
|
93
|
+
}
|
|
94
|
+
context.outputs.commands.push({
|
|
95
|
+
command: command_string,
|
|
96
|
+
output: unifiedOutput,
|
|
97
|
+
});
|
|
98
|
+
return {
|
|
99
|
+
status,
|
|
100
|
+
summary: `${summary} Output captured.`,
|
|
101
|
+
persisted_args: { command_string },
|
|
102
|
+
error_message: errorMessage,
|
|
103
|
+
execution_log: { output: unifiedOutput, error_message: errorMessage },
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
exports.ExecuteShellHandler = ExecuteShellHandler;
|
|
108
|
+
exports.ExecuteShellHandler = ExecuteShellHandler = ExecuteShellHandler_1 = __decorate([
|
|
109
|
+
(0, common_1.Injectable)()
|
|
110
|
+
], ExecuteShellHandler);
|
|
111
|
+
//# sourceMappingURL=execute-shell.handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute-shell.handler.js","sourceRoot":"","sources":["../../../../src/llm-orchestration/action-handlers/execute-shell.handler.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAoD;AAMpD,iDAAqC;AACrC,+BAAiC;AACjC,yEAAmE;AACnE,yDAAiD;AACjD,qDAA2C;AAC3C,iFAA4E;AAC5E,uCAA+C;AAE/C,MAAM,SAAS,GAAG,IAAA,gBAAS,EAAC,oBAAI,CAAC,CAAC;AAG3B,IAAM,mBAAmB,2BAAzB,MAAM,mBAAmB;IAAzB;QACI,aAAQ,GAAG,eAAe,CAAC;QACnB,WAAM,GAAG,IAAI,eAAM,CAAC,qBAAmB,CAAC,IAAI,CAAC,CAAC;QAC9C,gBAAW,GAC1B,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IA8FvD,CAAC;IA5FC,aAAa;QACX,MAAM,cAAc,GAAG,IAAA,wBAAgB,EAAC;YACtC,SAAS,EAAE,IAAI,CAAC,QAAQ;YACxB,cAAc,EAAE,oBAAoB;SACrC,CAAC,CAAC;QAEH,MAAM,UAAU,GAAG,IAAA,wBAAgB,EAAC;YAClC,SAAS,EAAE,IAAI,CAAC,QAAQ;YACxB,cAAc,EAAE,YAAY;SAC7B,CAAC,CAAC;QAEH,MAAM,aAAa,GAAG,IAAA,wBAAgB,EAAC;YACrC,SAAS,EAAE,IAAI,CAAC,QAAQ;YACxB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,aAAa,CAAC;QAC1D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,SAAS,GAAG,KAAY,CAAC;YAC/B,aAAa,GAAG,mBAAmB,SAAS,CAAC,OAAO,gBAClD,SAAS,CAAC,MAAM,IAAI,KACtB,gBAAgB,SAAS,CAAC,MAAM,IAAI,KAAK,EAAE,CAAC;YAC5C,OAAO,GAAG,kBAAkB,cAAc,WAAW,CAAC;YACtD,MAAM,GAAG,SAAS,CAAC;YACnB,YAAY,GAAG,SAAS,CAAC,OAAO,CAAC;YACjC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,kCAAkC,aAAa,EAAE,CAAC,CAAC;QACvE,CAAC;QAED,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;YAC5B,OAAO,EAAE,cAAc;YACvB,MAAM,EAAE,aAAa;SACtB,CAAC,CAAC;QAEH,OAAO;YACL,MAAM;YACN,OAAO,EAAE,GAAG,OAAO,mBAAmB;YACtC,cAAc,EAAE,EAAE,cAAc,EAAE;YAClC,aAAa,EAAE,YAAY;YAC3B,aAAa,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE;SACtE,CAAC;IACJ,CAAC;CACF,CAAA;AAlGY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,mBAAU,GAAE;GACA,mBAAmB,CAkG/B"}
|
|
@@ -53,6 +53,8 @@ let HowtoHandler = class HowtoHandler {
|
|
|
53
53
|
Fields are defined using the \`${parsing_constants_1.SPECIAL_FIELD_TOKEN}\` delimiter (e.g., \`${parsing_constants_1.SPECIAL_FIELD_TOKEN}field_name${parsing_constants_1.SPECIAL_FIELD_TOKEN} value\`).
|
|
54
54
|
The \`${parsing_constants_1.SPECIAL_FIELD_TOKEN}${parsing_constants_1.FIELD_TOOL_NAME}${parsing_constants_1.SPECIAL_FIELD_TOKEN}\` field is mandatory for all tools. Other arguments are tool-specific.
|
|
55
55
|
|
|
56
|
+
**CRITICAL RULE**: Never ever use a tool that is not explicitly available in the system instructions.
|
|
57
|
+
|
|
56
58
|
## Single Tool Call
|
|
57
59
|
|
|
58
60
|
Each tool call must be enclosed in its own action item block. The tool name is mandatory, followed by its arguments.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"howto.handler.js","sourceRoot":"","sources":["../../../../src/llm-orchestration/action-handlers/howto.handler.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAiE;AAMjE,uCAA+C;AAC/C,yDAAoD;AACpD,yDAAiD;AACjD,qDAA2C;AAC3C,mEAKqC;AAG9B,IAAM,YAAY,GAAlB,MAAM,YAAY;IAAlB;QACI,aAAQ,GAAG,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"howto.handler.js","sourceRoot":"","sources":["../../../../src/llm-orchestration/action-handlers/howto.handler.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAiE;AAMjE,uCAA+C;AAC/C,yDAAoD;AACpD,yDAAiD;AACjD,qDAA2C;AAC3C,mEAKqC;AAG9B,IAAM,YAAY,GAAlB,MAAM,YAAY;IAAlB;QACI,aAAQ,GAAG,OAAO,CAAC;IA4E9B,CAAC;IA1EC,aAAa;QACX,MAAM,iBAAiB,GAAG,IAAA,wBAAgB,EAAC;YACzC,SAAS,EAAE,cAAc;YACzB,WAAW,EAAE,8BAA8B;YAC3C,MAAM,EAAE,+CAA+C;SACxD,CAAC,CAAC;QAEH,MAAM,YAAY,GAAG;YACnB,IAAA,wBAAgB,EAAC;gBACf,SAAS,EAAE,OAAO;gBAClB,IAAI,EAAE,kBAAkB;gBACxB,IAAI,EAAE,eAAe;aACtB,CAAC;YACF,IAAA,wBAAgB,EAAC;gBACf,SAAS,EAAE,OAAO;gBAClB,WAAW,EAAE,kCAAkC;gBAC/C,IAAI,EAAE,WAAW;aAClB,CAAC;YACF,IAAA,wBAAgB,EAAC;gBACf,SAAS,EAAE,OAAO;gBAClB,aAAa,EAAE,kBAAkB;gBACjC,KAAK,EAAE,IAAI;aACZ,CAAC;YACF,IAAA,wBAAgB,EAAC;gBACf,SAAS,EAAE,OAAO;gBAClB,IAAI,EAAE,8BAA8B;gBACpC,IAAI,EAAE,mBAAmB;aAC1B,CAAC;SACH,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAElB,MAAM,UAAU,GAAG;GACpB,IAAI,CAAC,QAAQ;;;qCAGqB,yCAAqB,YAAY,uCAAmB;mCACtD,uCAAmB,yBAAyB,uCAAmB,aAAa,uCAAmB;UACxH,uCAAmB,GAAG,mCAAe,GAAG,uCAAmB;;;;;;;;;EASnE,iBAAiB;;;;;;;;EAQjB,YAAY;;IAEV,IAAI,CAAC,QAAQ;CAChB,CAAC;QACE,OAAO,UAAU,CAAC,IAAI,EAAE,CAAC;IAC3B,CAAC;IAED,KAAK,CAAC,OAAO,CACX,IAA4B,EAE5B,QAA8B;QAG9B,MAAM,aAAa,GAAG,IAAA,gCAAY,EAAC,6BAAY,EAAE,IAAI,CAAC,CAAC;QACvD,MAAM,IAAA,0BAAQ,EAAC,aAAa,CAAC,CAAC;QAG9B,MAAM,IAAI,4BAAmB,CAC3B,IAAI,IAAI,CAAC,QAAQ,8DAA8D,CAChF,CAAC;IACJ,CAAC;CACF,CAAA;AA7EY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,mBAAU,GAAE;GACA,YAAY,CA6ExB"}
|
|
@@ -19,6 +19,7 @@ const patch_args_dto_1 = require("./dto/patch.args.dto");
|
|
|
19
19
|
const tokenpatch_1 = require("../../../packages/tokenpatch");
|
|
20
20
|
const utils_1 = require("../../utils");
|
|
21
21
|
const parsing_constants_1 = require("../parser/parsing.constants");
|
|
22
|
+
const ENABLE_TREE_SITTER = false;
|
|
22
23
|
const grammarMap = {
|
|
23
24
|
'.js': 'tree-sitter-javascript.wasm',
|
|
24
25
|
'.jsx': 'tree-sitter-javascript.wasm',
|
|
@@ -53,36 +54,56 @@ let PatchHandler = PatchHandler_1 = class PatchHandler {
|
|
|
53
54
|
})();
|
|
54
55
|
}
|
|
55
56
|
getDefinition() {
|
|
57
|
+
const genericExample = `\`\`\`typescript
|
|
58
|
+
// ... 3-4 lines (or ~20+ tokens) of existing code (Unique Prefix Anchor) ...
|
|
59
|
+
|
|
60
|
+
// ... THE CODE YOU WANT TO CHANGE OR INSERT ...
|
|
61
|
+
|
|
62
|
+
// ... 3-4 lines (or ~20+ tokens) of existing code (Unique Suffix Anchor) ...
|
|
63
|
+
\`\`\``;
|
|
56
64
|
const goodAnchorExample = (0, utils_1.generateToolCall)({
|
|
57
65
|
tool_name: this.toolName,
|
|
58
|
-
file_path: 'src/
|
|
66
|
+
file_path: 'src/utils/formatting.ts',
|
|
59
67
|
patch_code: `\`\`\`typescript
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
protocol: 'https'
|
|
64
|
-
};
|
|
68
|
+
export function formatDate(date: Date): string {
|
|
69
|
+
return date.toISOString();
|
|
70
|
+
}
|
|
65
71
|
|
|
66
|
-
|
|
72
|
+
/**
|
|
73
|
+
* Capitalizes the first letter of a string.
|
|
74
|
+
*/
|
|
75
|
+
export function capitalize(str: string): string {
|
|
76
|
+
if (!str) return '';
|
|
77
|
+
// MODIFIED: Handle non-string inputs gracefully
|
|
78
|
+
if (typeof str !== 'string') return String(str);
|
|
79
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function formatCurrency(amount: number): string {
|
|
67
83
|
\`\`\``,
|
|
68
84
|
});
|
|
69
85
|
const badAnchorExample = (0, utils_1.generateToolCall)({
|
|
70
86
|
tool_name: this.toolName,
|
|
71
|
-
file_path: 'src/
|
|
87
|
+
file_path: 'src/utils/formatting.ts',
|
|
72
88
|
patch_code: `\`\`\`typescript
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
protocol: 'https'
|
|
77
|
-
};
|
|
89
|
+
// MODIFIED: Handle non-string inputs gracefully
|
|
90
|
+
if (typeof str !== 'string') return String(str);
|
|
91
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
78
92
|
\`\`\``,
|
|
79
93
|
});
|
|
80
94
|
const appendExample = (0, utils_1.generateToolCall)({
|
|
81
95
|
tool_name: this.toolName,
|
|
82
|
-
file_path: 'src/
|
|
96
|
+
file_path: 'src/services/auth.service.ts',
|
|
83
97
|
patch_code: `\`\`\`typescript
|
|
84
|
-
|
|
85
|
-
|
|
98
|
+
async validateSession(token: string): Promise<boolean> {
|
|
99
|
+
return this.tokenService.verify(token);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Helper for legacy clients
|
|
104
|
+
export function isLegacyToken(token: string): boolean {
|
|
105
|
+
return token.startsWith('leg_');
|
|
106
|
+
}
|
|
86
107
|
// ${parsing_constants_1.SPECIAL_PATCH_END_FILE_MARKER}
|
|
87
108
|
\`\`\``,
|
|
88
109
|
});
|
|
@@ -91,8 +112,21 @@ export { sum };
|
|
|
91
112
|
file_path: 'src/main.ts',
|
|
92
113
|
patch_code: `\`\`\`typescript
|
|
93
114
|
// ${parsing_constants_1.SPECIAL_PATCH_BEGIN_FILE_MARKER}
|
|
94
|
-
import
|
|
95
|
-
import {
|
|
115
|
+
import 'dotenv/config';
|
|
116
|
+
import { NestFactory } from '@nestjs/core';
|
|
117
|
+
import { ValidationPipe } from '@nestjs/common';
|
|
118
|
+
import { AppModule } from './app.module';
|
|
119
|
+
|
|
120
|
+
// Global types
|
|
121
|
+
declare global {
|
|
122
|
+
namespace NodeJS {
|
|
123
|
+
interface ProcessEnv {
|
|
124
|
+
PORT?: string;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
async function bootstrap() {
|
|
96
130
|
\`\`\``,
|
|
97
131
|
});
|
|
98
132
|
const definition = `
|
|
@@ -105,51 +139,100 @@ import { ModuleA } from './moduleA';
|
|
|
105
139
|
1. **The 'patch_code' is a literal replacement**: The entire content of your 'patch_code' will replace the section of the original file that it matches. It is not a diff or a partial change.
|
|
106
140
|
2. **Provide valid, parsable code**: The snippet in 'patch_code' must be syntactically correct. Do not provide incomplete lines or half-finished code blocks, as the parser will fail.
|
|
107
141
|
3. **Include unique anchors**: Your 'patch_code' MUST include enough surrounding, unchanged context (a few lines before and after your change) to serve as a unique anchor. If the context is not unique, the patch will fail.
|
|
142
|
+
4. **Small, atomic patches**: Prefer multiple small patches over one large patch. Large patches are harder to anchor uniquely. You can send multiple patch actions for the same file in a single turn.
|
|
108
143
|
|
|
109
144
|
Special Markers for Edge Cases:
|
|
110
|
-
|
|
111
|
-
|
|
145
|
+
Standard anchoring requires unique context both above and below the change. This is impossible at the very start or end of a file, OR when the surrounding code is too short (e.g., only a closing brace \`}\` follows your change).
|
|
146
|
+
Use these markers to tell the patcher to skip the missing anchor:
|
|
147
|
+
- \`// ${parsing_constants_1.SPECIAL_PATCH_BEGIN_FILE_MARKER}\`: Use this as the first line of 'patch_code' when adding imports or top-level definitions to the START of a file.
|
|
148
|
+
- \`// ${parsing_constants_1.SPECIAL_PATCH_END_FILE_MARKER}\`: Use this as the last line of 'patch_code' when appending new functions or exports to the END of a file.
|
|
149
|
+
|
|
150
|
+
ABSOLUTELY FORBIDDEN:
|
|
151
|
+
- Unified diff style (lines starting with + or -). providing this will cause the patch to fail.
|
|
152
|
+
- Ellipses (...) or comments like '// ... rest of code' in place of required syntax.
|
|
112
153
|
|
|
113
154
|
Parameters:
|
|
114
155
|
- "file_path": (string) The relative path to the file to be patched.
|
|
115
156
|
- "patch_code": (string) A code snippet containing your changes, with enough surrounding context to serve as a unique anchor.
|
|
116
157
|
|
|
158
|
+
<conceptual_example>
|
|
159
|
+
Explanation: Your patch code must follow this structure. The context anchors are crucial for locating the correct insertion point.
|
|
160
|
+
${genericExample}
|
|
161
|
+
</conceptual_example>
|
|
162
|
+
|
|
117
163
|
<example_good_anchoring>
|
|
118
|
-
Explanation:
|
|
164
|
+
Explanation: Notice how the patch includes the function above ('formatDate') and the start of the function below ('formatCurrency') as anchors. This guarantees the patch location is unique.
|
|
119
165
|
|
|
120
166
|
Original File Content:
|
|
121
167
|
\`\`\`typescript
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
};
|
|
168
|
+
export function formatDate(date: Date): string {
|
|
169
|
+
return date.toISOString();
|
|
170
|
+
}
|
|
126
171
|
|
|
127
|
-
function
|
|
128
|
-
|
|
172
|
+
export function capitalize(str: string): string {
|
|
173
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
129
174
|
}
|
|
130
175
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
};
|
|
176
|
+
export function formatCurrency(amount: number): string {
|
|
177
|
+
return '$' + amount.toFixed(2);
|
|
178
|
+
}
|
|
135
179
|
\`\`\`
|
|
136
180
|
|
|
137
181
|
${goodAnchorExample}
|
|
138
182
|
</example_good_anchoring>
|
|
139
183
|
|
|
140
184
|
<example_bad_anchoring>
|
|
141
|
-
Explanation: This is a **bad example**. The 'patch_code'
|
|
185
|
+
Explanation: This is a **bad example**. The 'patch_code' contains NO surrounding context. The patcher has no way of knowing *where* in the file this code belongs, or what it is replacing. This will result in an error.
|
|
186
|
+
|
|
187
|
+
Original File Content:
|
|
188
|
+
\`\`\`typescript
|
|
189
|
+
export function formatDate(date: Date): string {
|
|
190
|
+
return date.toISOString();
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export function capitalize(str: string): string {
|
|
194
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export function formatCurrency(amount: number): string {
|
|
198
|
+
return '$' + amount.toFixed(2);
|
|
199
|
+
}
|
|
200
|
+
\`\`\`
|
|
142
201
|
|
|
143
202
|
${badAnchorExample}
|
|
144
203
|
</example_bad_anchoring>
|
|
145
204
|
|
|
146
205
|
<example_append>
|
|
147
206
|
Explanation: Use the '// ${parsing_constants_1.SPECIAL_PATCH_END_FILE_MARKER}' marker to add content to the end of a file.
|
|
207
|
+
|
|
208
|
+
Original File Content:
|
|
209
|
+
\`\`\`typescript
|
|
210
|
+
export class AuthService {
|
|
211
|
+
// ... other methods ...
|
|
212
|
+
async validateSession(token: string): Promise<boolean> {
|
|
213
|
+
return this.tokenService.verify(token);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
\`\`\`
|
|
217
|
+
|
|
148
218
|
${appendExample}
|
|
149
219
|
</example_append>
|
|
150
220
|
|
|
151
221
|
<example_prepend>
|
|
152
222
|
Explanation: Use the '// ${parsing_constants_1.SPECIAL_PATCH_BEGIN_FILE_MARKER}' marker to add content to the beginning of a file.
|
|
223
|
+
|
|
224
|
+
Original File Content:
|
|
225
|
+
\`\`\`typescript
|
|
226
|
+
import { NestFactory } from '@nestjs/core';
|
|
227
|
+
import { AppModule } from './app.module';
|
|
228
|
+
|
|
229
|
+
async function bootstrap() {
|
|
230
|
+
const app = await NestFactory.create(AppModule);
|
|
231
|
+
await app.listen(3000);
|
|
232
|
+
}
|
|
233
|
+
bootstrap();
|
|
234
|
+
\`\`\`
|
|
235
|
+
|
|
153
236
|
${prependExample}
|
|
154
237
|
</example_prepend>
|
|
155
238
|
</${this.toolName}>
|
|
@@ -180,20 +263,15 @@ ${prependExample}
|
|
|
180
263
|
const safePath = this.resolveAndValidatePath(file_path);
|
|
181
264
|
const fileExtension = path.extname(file_path);
|
|
182
265
|
const grammarFile = grammarMap[fileExtension];
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
summary: `Patch on "${file_path}" failed: Unsupported file type.`,
|
|
192
|
-
error_message: errorMessage,
|
|
193
|
-
persisted_args: validatedArgs,
|
|
194
|
-
};
|
|
266
|
+
let applyPatchOptions = {};
|
|
267
|
+
if (grammarFile && ENABLE_TREE_SITTER) {
|
|
268
|
+
const grammarPath = path.join(this.grammarDir, grammarFile);
|
|
269
|
+
applyPatchOptions = { grammarPath };
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
this.logger.log(`No Tree-sitter grammar found for ${fileExtension}, using Tiktoken strategy.`);
|
|
273
|
+
applyPatchOptions = { useTiktoken: true };
|
|
195
274
|
}
|
|
196
|
-
const grammarPath = path.join(this.grammarDir, grammarFile);
|
|
197
275
|
const originalContent = await fs
|
|
198
276
|
.readFile(safePath, 'utf8')
|
|
199
277
|
.catch((error) => {
|
|
@@ -216,7 +294,7 @@ ${prependExample}
|
|
|
216
294
|
};
|
|
217
295
|
}
|
|
218
296
|
try {
|
|
219
|
-
const newFileContent = await (0, tokenpatch_1.applySnippetPatch)(originalContent, patch_code,
|
|
297
|
+
const newFileContent = await (0, tokenpatch_1.applySnippetPatch)(originalContent, patch_code, applyPatchOptions);
|
|
220
298
|
await fs.writeFile(safePath, newFileContent, 'utf8');
|
|
221
299
|
return {
|
|
222
300
|
status: 'SUCCESS',
|
|
@@ -227,7 +305,7 @@ ${prependExample}
|
|
|
227
305
|
}
|
|
228
306
|
catch (error) {
|
|
229
307
|
this.logger.error(`Failed to apply patch for ${file_path}: ${error.message}`);
|
|
230
|
-
const errorMessage = `Failed to apply patch for "${file_path}": ${error.message}\n\n**CORRECTION HINT:** The patch could not be applied. This is often because the prefix or suffix anchors in the patch code could not be uniquely located in the original file. Use \`request_context\` on \`'${file_path}'\` to get the latest version and try again with a more specific patch.`;
|
|
308
|
+
const errorMessage = `Failed to apply patch for "${file_path}": ${error.message}\n\n**CORRECTION HINT:** The patch could not be applied. This is often because the prefix or suffix anchors in the patch code could not be uniquely located in the original file. Use \`request_context\` on \`'${file_path}'\` to get the latest version and try again with a more specific patch. If the patch continues to fail, consider using \`edit_file\` to replace the entire file content.`;
|
|
231
309
|
context.feedback.validationErrors.push({
|
|
232
310
|
tool_name: this.toolName,
|
|
233
311
|
error: errorMessage,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"patch.handler.js","sourceRoot":"","sources":["../../../../src/llm-orchestration/action-handlers/patch.handler.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAyE;AACzE,kCAAkC;AAClC,2BAAgC;AAChC,6BAA6B;AAC7B,yDAAiD;AACjD,qDAA2C;AAM3C,iFAA4E;AAC5E,yDAAoD;AACpD,6DAAiE;AACjE,uCAA+C;AAC/C,mEAGqC;
|
|
1
|
+
{"version":3,"file":"patch.handler.js","sourceRoot":"","sources":["../../../../src/llm-orchestration/action-handlers/patch.handler.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAyE;AACzE,kCAAkC;AAClC,2BAAgC;AAChC,6BAA6B;AAC7B,yDAAiD;AACjD,qDAA2C;AAM3C,iFAA4E;AAC5E,yDAAoD;AACpD,6DAAiE;AACjE,uCAA+C;AAC/C,mEAGqC;AAErC,MAAM,kBAAkB,GAAG,KAAK,CAAC;AAGjC,MAAM,UAAU,GAA2B;IACzC,KAAK,EAAE,6BAA6B;IACpC,MAAM,EAAE,6BAA6B;IACrC,KAAK,EAAE,6BAA6B;IACpC,MAAM,EAAE,sBAAsB;IAC9B,OAAO,EAAE,uBAAuB;IAChC,OAAO,EAAE,uBAAuB;IAChC,MAAM,EAAE,sBAAsB;IAC9B,KAAK,EAAE,yBAAyB;IAChC,KAAK,EAAE,uBAAuB;IAC9B,OAAO,EAAE,uBAAuB;IAChC,OAAO,EAAE,uBAAuB;IAChC,MAAM,EAAE,uBAAuB;IAC/B,KAAK,EAAE,uBAAuB;CAC/B,CAAC;AAGK,IAAM,YAAY,oBAAlB,MAAM,YAAY;IAAlB;QACI,aAAQ,GAAG,OAAO,CAAC;QACX,WAAM,GAAG,IAAI,eAAM,CAAC,cAAY,CAAC,IAAI,CAAC,CAAC;QACvC,gBAAW,GAC1B,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QAkMpC,eAAU,GAAG,CAAC,GAAG,EAAE;YAElC,MAAM,QAAQ,GAAG,IAAI,CAAC,OA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|
|
@@ -22,6 +22,7 @@ let RunCommandHandler = RunCommandHandler_1 = class RunCommandHandler {
|
|
|
22
22
|
this.toolName = 'run_command';
|
|
23
23
|
this.logger = new common_1.Logger(RunCommandHandler_1.name);
|
|
24
24
|
this.projectRoot = process.env.REPOBURG_PROJECT_PATH || process.cwd();
|
|
25
|
+
this.ALLOWED_COMMANDS = ['ls', 'tree', 'rg'];
|
|
25
26
|
}
|
|
26
27
|
getDefinition() {
|
|
27
28
|
const treeExample = (0, utils_1.generateToolCall)({
|
|
@@ -32,21 +33,14 @@ let RunCommandHandler = RunCommandHandler_1 = class RunCommandHandler {
|
|
|
32
33
|
tool_name: this.toolName,
|
|
33
34
|
command_string: 'rg "TODO|FIXME" .',
|
|
34
35
|
});
|
|
35
|
-
const rgExample2 = (0, utils_1.generateToolCall)({
|
|
36
|
-
tool_name: this.toolName,
|
|
37
|
-
command_string: 'rg "function App" .',
|
|
38
|
-
});
|
|
39
|
-
const rgExample3 = (0, utils_1.generateToolCall)({
|
|
40
|
-
tool_name: this.toolName,
|
|
41
|
-
command_string: `rg --files-with-matches "from '../utils'" .`,
|
|
42
|
-
});
|
|
43
36
|
const definition = `
|
|
44
37
|
<${this.toolName}>
|
|
45
|
-
Executes a shell command
|
|
46
|
-
|
|
38
|
+
Executes a SAFE, READ-ONLY shell command for exploration.
|
|
39
|
+
Restricted to the following commands: ${this.ALLOWED_COMMANDS.join(', ')}.
|
|
40
|
+
Use 'execute_shell' for other commands.
|
|
47
41
|
|
|
48
42
|
Parameters:
|
|
49
|
-
- "command_string": (string) The shell command to execute.
|
|
43
|
+
- "command_string": (string) The shell command to execute. Must start with an allowed command. No chaining or piping.
|
|
50
44
|
|
|
51
45
|
<example>
|
|
52
46
|
${treeExample}
|
|
@@ -55,14 +49,6 @@ ${treeExample}
|
|
|
55
49
|
<example>
|
|
56
50
|
${rgExample1}
|
|
57
51
|
</example>
|
|
58
|
-
|
|
59
|
-
<example>
|
|
60
|
-
${rgExample2}
|
|
61
|
-
</example>
|
|
62
|
-
|
|
63
|
-
<example>
|
|
64
|
-
${rgExample3}
|
|
65
|
-
</example>
|
|
66
52
|
</${this.toolName}>
|
|
67
53
|
`;
|
|
68
54
|
return definition.trim();
|
|
@@ -77,6 +63,13 @@ ${rgExample3}
|
|
|
77
63
|
throw new handler_validation_error_1.HandlerValidationError(errorMessages);
|
|
78
64
|
}
|
|
79
65
|
const { command_string } = validatedArgs;
|
|
66
|
+
if (/[;&|><$`()]/.test(command_string)) {
|
|
67
|
+
throw new handler_validation_error_1.HandlerValidationError(`Command validation failed: Shell operators and chaining (;, &&, |, >) are not allowed in '${this.toolName}'. Use 'execute_shell' if you need complex commands.`);
|
|
68
|
+
}
|
|
69
|
+
const baseCommand = command_string.trim().split(/\s+/)[0];
|
|
70
|
+
if (!this.ALLOWED_COMMANDS.includes(baseCommand)) {
|
|
71
|
+
throw new handler_validation_error_1.HandlerValidationError(`Command '${baseCommand}' is not allowed in '${this.toolName}'. Allowed commands: ${this.ALLOWED_COMMANDS.join(', ')}. Use 'execute_shell' for unrestricted execution.`);
|
|
72
|
+
}
|
|
80
73
|
let unifiedOutput;
|
|
81
74
|
let summary;
|
|
82
75
|
let status = 'SUCCESS';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-command.handler.js","sourceRoot":"","sources":["../../../../src/llm-orchestration/action-handlers/run-command.handler.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAoD;AAMpD,iDAAqC;AACrC,+BAAiC;AACjC,qEAA+D;AAC/D,yDAAiD;AACjD,qDAA2C;AAC3C,iFAA4E;AAC5E,uCAA+C;AAE/C,MAAM,SAAS,GAAG,IAAA,gBAAS,EAAC,oBAAI,CAAC,CAAC;AAG3B,IAAM,iBAAiB,yBAAvB,MAAM,iBAAiB;IAAvB;QACI,aAAQ,GAAG,aAAa,CAAC;QACjB,WAAM,GAAG,IAAI,eAAM,CAAC,mBAAiB,CAAC,IAAI,CAAC,CAAC;QAC5C,gBAAW,GAC1B,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"run-command.handler.js","sourceRoot":"","sources":["../../../../src/llm-orchestration/action-handlers/run-command.handler.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAoD;AAMpD,iDAAqC;AACrC,+BAAiC;AACjC,qEAA+D;AAC/D,yDAAiD;AACjD,qDAA2C;AAC3C,iFAA4E;AAC5E,uCAA+C;AAE/C,MAAM,SAAS,GAAG,IAAA,gBAAS,EAAC,oBAAI,CAAC,CAAC;AAG3B,IAAM,iBAAiB,yBAAvB,MAAM,iBAAiB;IAAvB;QACI,aAAQ,GAAG,aAAa,CAAC;QACjB,WAAM,GAAG,IAAI,eAAM,CAAC,mBAAiB,CAAC,IAAI,CAAC,CAAC;QAC5C,gBAAW,GAC1B,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QACpC,qBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IAqG3D,CAAC;IAnGC,aAAa;QACX,MAAM,WAAW,GAAG,IAAA,wBAAgB,EAAC;YACnC,SAAS,EAAE,IAAI,CAAC,QAAQ;YACxB,cAAc,EAAE,eAAe;SAChC,CAAC,CAAC;QAEH,MAAM,UAAU,GAAG,IAAA,wBAAgB,EAAC;YAClC,SAAS,EAAE,IAAI,CAAC,QAAQ;YACxB,cAAc,EAAE,mBAAmB;SACpC,CAAC,CAAC;QAEH,MAAM,UAAU,GAAG;GACpB,IAAI,CAAC,QAAQ;;0CAE0B,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC;;;;;;;EAOxE,WAAW;;;;EAIX,UAAU;;IAER,IAAI,CAAC,QAAQ;CAChB,CAAC;QACE,OAAO,UAAU,CAAC,IAAI,EAAE,CAAC;IAC3B,CAAC;IAED,KAAK,CAAC,OAAO,CACX,IAA4B,E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,CAAC,cAAc,EAAE;gBACzD,GAAG,EAAE,IAAI,CAAC,WAAW;gBACrB,SAAS,EAAE,GAAG,GAAG,IAAI,GAAG,IAAI;gBAC5B,OAAO,EAAE,KAAK;aACf,CAAC,CAAC;YACH,aAAa,GAAG,MAAM,IAAI,MAAM,IAAI,8BAA8B,CAAC;YACnE,OAAO,GAAG,YAAY,cAAc,aAAa,CAAC;QACpD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,SAAS,GAAG,KAAY,CAAC;YAC/B,aAAa,GAAG,mBAAmB,SAAS,CAAC,OAAO,gBAClD,SAAS,CAAC,MAAM,IAAI,KACtB,gBAAgB,SAAS,CAAC,MAAM,IAAI,KAAK,EAAE,CAAC;YAC5C,OAAO,GAAG,YAAY,cAAc,WAAW,CAAC;YAChD,MAAM,GAAG,SAAS,CAAC;YACnB,YAAY,GAAG,SAAS,CAAC,OAAO,CAAC;YACjC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,4BAA4B,aAAa,EAAE,CAAC,CAAC;QACjE,CAAC;QAED,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;YAC5B,OAAO,EAAE,cAAc;YACvB,MAAM,EAAE,aAAa;SACtB,CAAC,CAAC;QAEH,OAAO;YACL,MAAM;YACN,OAAO,EAAE,GAAG,OAAO,mBAAmB;YACtC,cAAc,EAAE,EAAE,cAAc,EAAE;YAClC,aAAa,EAAE,YAAY;YAC3B,aAAa,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE;SACtE,CAAC;IACJ,CAAC;CACF,CAAA;AA1GY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;GACA,iBAAiB,CA0G7B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ActionHandler } from './action-handler.interface';
|
|
2
|
+
import { ActionExecutionResult, PlanExecutionContext } from '../llm-orchestration.interfaces';
|
|
3
|
+
export declare class WriteTodoHandler implements ActionHandler {
|
|
4
|
+
readonly toolName = "write_todo";
|
|
5
|
+
private readonly logger;
|
|
6
|
+
private readonly projectRoot;
|
|
7
|
+
getDefinition(): string;
|
|
8
|
+
private resolveAndValidatePath;
|
|
9
|
+
private readFileContent;
|
|
10
|
+
execute(args: {
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
}, _context: PlanExecutionContext): Promise<ActionExecutionResult>;
|
|
13
|
+
}
|