micro-models-agent 0.20.2 → 0.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +53 -11
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -2303,6 +2303,7 @@ Command: {command}`,
|
|
|
2303
2303
|
"tool.friendly.process_list": "Listing background processes",
|
|
2304
2304
|
"tool.friendly.process_log": "Process output",
|
|
2305
2305
|
"tool.friendly.process_kill": "Stopping process",
|
|
2306
|
+
"plan.no_steps": "No plan steps specified. Provide concrete steps with files and commands.",
|
|
2306
2307
|
"plan.created": "Plan created: {title} ({steps} steps)",
|
|
2307
2308
|
"plan.step_done": "Step {n}/{total}: {description} ✓",
|
|
2308
2309
|
"plan.complete": "Task complete: {summary}",
|
|
@@ -2800,6 +2801,7 @@ var init_ru = __esm(() => {
|
|
|
2800
2801
|
"tool.friendly.process_list": "Список фоновых процессов",
|
|
2801
2802
|
"tool.friendly.process_log": "Вывод процесса",
|
|
2802
2803
|
"tool.friendly.process_kill": "Остановка процесса",
|
|
2804
|
+
"plan.no_steps": "Не указаны шаги плана. Укажите конкретные шаги с файлами и командами.",
|
|
2803
2805
|
"plan.created": "План создан: {title} ({steps} шагов)",
|
|
2804
2806
|
"plan.step_done": "Шаг {n}/{total}: {description} ✓",
|
|
2805
2807
|
"plan.complete": "Задача выполнена: {summary}",
|
|
@@ -12381,29 +12383,57 @@ var init_notify = __esm(() => {
|
|
|
12381
12383
|
});
|
|
12382
12384
|
|
|
12383
12385
|
// src/modules/execution/planner.ts
|
|
12386
|
+
function generatePlanId() {
|
|
12387
|
+
const chars = "abcdefghijklmnopqrstuvwxyz0123456789";
|
|
12388
|
+
let id = "";
|
|
12389
|
+
for (let i = 0;i < 6; i++) {
|
|
12390
|
+
id += chars[Math.floor(Math.random() * chars.length)];
|
|
12391
|
+
}
|
|
12392
|
+
return `plan_${id}`;
|
|
12393
|
+
}
|
|
12394
|
+
|
|
12384
12395
|
class PlanCreator {
|
|
12385
12396
|
static isMultiStep(task) {
|
|
12386
12397
|
const fileCount = (task.match(/\b[\w./-]+\.[a-z]+\b/gi) || []).length;
|
|
12387
12398
|
if (fileCount > 1)
|
|
12388
12399
|
return true;
|
|
12389
|
-
const actionWords = [
|
|
12400
|
+
const actionWords = [
|
|
12401
|
+
"implement",
|
|
12402
|
+
"create",
|
|
12403
|
+
"add",
|
|
12404
|
+
"build",
|
|
12405
|
+
"setup",
|
|
12406
|
+
"configure",
|
|
12407
|
+
"write",
|
|
12408
|
+
"make",
|
|
12409
|
+
"develop"
|
|
12410
|
+
];
|
|
12390
12411
|
const words = task.split(/\s+/);
|
|
12391
12412
|
const hasActionWord = actionWords.some((w) => task.toLowerCase().includes(w));
|
|
12392
12413
|
return hasActionWord && words.length > 8;
|
|
12393
12414
|
}
|
|
12394
|
-
static createPlan(title, stepDescriptions) {
|
|
12415
|
+
static createPlan(title, stepDescriptions, baseDir) {
|
|
12416
|
+
const stepCount = stepDescriptions.length;
|
|
12395
12417
|
return {
|
|
12396
|
-
|
|
12418
|
+
id: generatePlanId(),
|
|
12419
|
+
title: `[${stepCount} ст.] ${title}`,
|
|
12397
12420
|
steps: stepDescriptions.map((desc, i) => ({
|
|
12398
12421
|
id: i + 1,
|
|
12399
12422
|
description: desc,
|
|
12400
12423
|
status: "pending"
|
|
12401
12424
|
})),
|
|
12402
|
-
createdAt: new Date().toISOString()
|
|
12425
|
+
createdAt: new Date().toISOString(),
|
|
12426
|
+
baseDir
|
|
12403
12427
|
};
|
|
12404
12428
|
}
|
|
12405
12429
|
static toPromptBlock(plan, currentStepIndex) {
|
|
12406
|
-
const
|
|
12430
|
+
const date = plan.createdAt.slice(0, 10);
|
|
12431
|
+
const lines = [
|
|
12432
|
+
`[${plan.id}] ${plan.title}`,
|
|
12433
|
+
`Dir: ${plan.baseDir}`,
|
|
12434
|
+
`Created: ${date} | Progress: ${plan.steps.filter((s) => s.status === "done").length}/${plan.steps.length} done, current: step ${currentStepIndex + 1}`,
|
|
12435
|
+
``
|
|
12436
|
+
];
|
|
12407
12437
|
for (const step of plan.steps) {
|
|
12408
12438
|
const icon = step.status === "done" ? "[x]" : step.status === "in_progress" ? "[*]" : step.status === "failed" ? "[!]" : step.status === "skipped" ? "[-]" : "[ ]";
|
|
12409
12439
|
const note = step.note ? ` — ${step.note}` : "";
|
|
@@ -12461,7 +12491,7 @@ class PlanTracker {
|
|
|
12461
12491
|
const barWidth = 10;
|
|
12462
12492
|
const filled = Math.round(done / total * barWidth);
|
|
12463
12493
|
const bar = "█".repeat(filled) + "░".repeat(barWidth - filled);
|
|
12464
|
-
return `[
|
|
12494
|
+
return `[${this.plan.id}] ${this.plan.title} ${done}/${total} ${bar} ${pct}%`;
|
|
12465
12495
|
}
|
|
12466
12496
|
toPromptBlock() {
|
|
12467
12497
|
return PlanCreator.toPromptBlock(this.plan, this.currentStepIndex);
|
|
@@ -12710,10 +12740,12 @@ class PlanPersister {
|
|
|
12710
12740
|
}
|
|
12711
12741
|
save(plan) {
|
|
12712
12742
|
const file = {
|
|
12743
|
+
id: plan.id,
|
|
12713
12744
|
title: plan.title,
|
|
12714
12745
|
steps: plan.steps,
|
|
12715
12746
|
createdAt: plan.createdAt,
|
|
12716
|
-
updatedAt: new Date().toISOString()
|
|
12747
|
+
updatedAt: new Date().toISOString(),
|
|
12748
|
+
baseDir: plan.baseDir
|
|
12717
12749
|
};
|
|
12718
12750
|
writeFileSync9(this.filePath, JSON.stringify(file, null, 2), "utf-8");
|
|
12719
12751
|
}
|
|
@@ -12724,9 +12756,11 @@ class PlanPersister {
|
|
|
12724
12756
|
const raw = readFileSync14(this.filePath, "utf-8");
|
|
12725
12757
|
const file = JSON.parse(raw);
|
|
12726
12758
|
return {
|
|
12759
|
+
id: file.id || "plan_legacy",
|
|
12727
12760
|
title: file.title,
|
|
12728
12761
|
steps: file.steps,
|
|
12729
|
-
createdAt: file.createdAt
|
|
12762
|
+
createdAt: file.createdAt,
|
|
12763
|
+
baseDir: file.baseDir || process.cwd()
|
|
12730
12764
|
};
|
|
12731
12765
|
} catch {
|
|
12732
12766
|
return null;
|
|
@@ -12814,7 +12848,15 @@ class ExecutionModule {
|
|
|
12814
12848
|
return [
|
|
12815
12849
|
{
|
|
12816
12850
|
name: "plan",
|
|
12817
|
-
description:
|
|
12851
|
+
description: `Create, update, show, or abort a multi-step plan. Use "create" at the start of complex tasks. Use "update" after completing each step to track progress. Use "show" to re-print the current plan checklist.
|
|
12852
|
+
|
|
12853
|
+
IMPORTANT — each step MUST be detailed and concrete (≥50 chars):
|
|
12854
|
+
- Specify WHICH files to create with exact paths (e.g. "create src/components/Header.tsx with navigation and logo")
|
|
12855
|
+
- Specify WHICH packages to install with exact versions (e.g. "run npm install react@18.3 react-dom@18.3")
|
|
12856
|
+
- Specify WHICH CLI commands to run with exact arguments
|
|
12857
|
+
- Must contain at least one file extension (.ts, .tsx, .json, etc.) OR a command verb (install, create, build, run, add, init)
|
|
12858
|
+
- BAD: "Настройка проекта и установка зависимостей" (too vague, no files, no versions)
|
|
12859
|
+
- GOOD: "Создать package.json с зависимостями react@18.3 и vite@5.4, затем выполнить npm install в корне проекта"`,
|
|
12818
12860
|
parameters: {
|
|
12819
12861
|
type: "object",
|
|
12820
12862
|
properties: {
|
|
@@ -12838,7 +12880,7 @@ class ExecutionModule {
|
|
|
12838
12880
|
if (steps.length === 0) {
|
|
12839
12881
|
return { success: false, output: t("plan.no_steps") };
|
|
12840
12882
|
}
|
|
12841
|
-
const plan = PlanCreator.createPlan(title, steps);
|
|
12883
|
+
const plan = PlanCreator.createPlan(title, steps, this.baseDir);
|
|
12842
12884
|
this.setPlan(plan);
|
|
12843
12885
|
const display = PlanCreator.toPromptBlock(plan, 0);
|
|
12844
12886
|
return {
|
|
@@ -14583,7 +14625,7 @@ function buildSystemInfo(config, baseDir, profileCompressed) {
|
|
|
14583
14625
|
lines.push(``, `Windows environment — use Windows-compatible commands:`, `- Use "dir" instead of "ls". Use "dir /b" for bare listing.`, `- Use "type" or "Get-Content" instead of "cat".`, `- Use "cd" instead of "pwd". Use "echo %cd%" to print working directory.`, `- Use "copy" instead of "cp", "move" instead of "mv", "del" instead of "rm".`, `- Do not use "mkdir -p" — Windows mkdir creates intermediate dirs by default. Use the create_dir tool instead.`, `- Use forward slashes (/) or escaped backslashes (\\\\) in file paths.`, `- Your working directory is: ${baseDir}`);
|
|
14584
14626
|
}
|
|
14585
14627
|
lines.push(``, `Bash tool rules:`, `- Use the "workdir" parameter to run commands in a specific directory. Do NOT chain "cd dir && cmd" — the security module blocks the "&&" operator.`, `- Run one command per tool call. Split multi-step shell operations into separate bash calls.`, `- Background processes (dev servers, watchers, long-running npm install): use the "background: true" parameter or the tool will auto-detect and background them. Check output with process_log.`);
|
|
14586
|
-
lines.push(``, `=== DEVELOPMENT RULES — follow these strictly ===`, ``, `1. DEPENDENCIES FIRST: Before writing any source code, ALWAYS install project dependencies (e.g., "npm install", "pip install -r requirements.txt", "cargo build", "go mod tidy"). Verify the package manager's lock file or dependency directory exists. Never write code that imports/uses packages that aren't installed yet.`, `2. TOOLKIT/FWK FIRST: If the task specifies a framework or UI library, initialize and configure it BEFORE writing application code. Run its project init command first, then add components/modules. Never write your own version of what the framework already provides.`, `3. ONE STEP AT A TIME: Follow the plan sequentially. Complete step N before starting step N+1. When a step is done: verify the deliverables exist and have real content (not empty), then call "plan update step=N status=done". Do not redo completed work.`, `4. VERIFY YOUR WORK: After creating/modifying files, verify they exist on disk. After installing dependencies, verify the package manager completed successfully. After any command, check its output for errors. Don't assume operations succeeded.`, `5. NO PREMATURE WORK: Do not create files for future steps. Do not add imports/references to packages or modules that haven't been installed yet. Do not reference files or components that don't exist yet. Build incrementally — one layer at a time.`, `6. WHEN STUCK: If a command fails 2+ times, STOP and try a different approach. Write files directly instead of using commands. Ask the user for help. Never repeat the same failing command more than twice.`);
|
|
14628
|
+
lines.push(``, `=== DEVELOPMENT RULES — follow these strictly ===`, ``, `1. DEPENDENCIES FIRST: Before writing any source code, ALWAYS install project dependencies (e.g., "npm install", "pip install -r requirements.txt", "cargo build", "go mod tidy"). Verify the package manager's lock file or dependency directory exists. Never write code that imports/uses packages that aren't installed yet.`, `2. TOOLKIT/FWK FIRST: If the task specifies a framework or UI library, initialize and configure it BEFORE writing application code. Run its project init command first, then add components/modules. Never write your own version of what the framework already provides.`, `3. ONE STEP AT A TIME: Follow the plan sequentially. Complete step N before starting step N+1. When a step is done: verify the deliverables exist and have real content (not empty), then call "plan update step=N status=done". Do not redo completed work.`, `4. VERIFY YOUR WORK: After creating/modifying files, verify they exist on disk. After installing dependencies, verify the package manager completed successfully. After any command, check its output for errors. Don't assume operations succeeded.`, `5. NO PREMATURE WORK: Do not create files for future steps. Do not add imports/references to packages or modules that haven't been installed yet. Do not reference files or components that don't exist yet. Build incrementally — one layer at a time.`, `6. WHEN STUCK: If a command fails 2+ times, STOP and try a different approach. Write files directly instead of using commands. Ask the user for help. Never repeat the same failing command more than twice.`, ``, `=== PLAN QUALITY RULES — your plan MUST follow these ===`, ``, `- Each step must describe CONCRETE deliverables: exact filenames with paths, exact packages to install, exact CLI commands to run. Steps shorter than 50 characters or without file paths/commands are REJECTED.`, `- A step like "Настройка проекта" or "Setup the project" is USELESS and will be REJECTED.`, `- A step like "Создать src/components/Header.tsx с навигацией и логотипом, добавить в src/App.tsx импорт <Header />" is GOOD.`, `- Include file extensions (.tsx, .css, .json) and directory paths. Every step must mention at least one file or command.`, `- The plan must cover EVERYTHING needed: init → deps → framework setup → code → verification.`, `- Number of steps: 5-8 for a typical task. Too few means you're being vague. Too many means you're over-splitting.`);
|
|
14587
14629
|
if (config.autoPlan) {
|
|
14588
14630
|
lines.push(``, `Plan rule (MANDATORY): For ANY task that requires creating files, installing packages, or multiple actions — you MUST create a plan using the "plan" tool BEFORE starting work. Each step must describe a concrete deliverable (specific files to create, packages to install, commands to run). Do not combine unrelated work into one step.`);
|
|
14589
14631
|
}
|