@corbat-tech/coco 2.9.0 → 2.10.0
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/cli/index.js +3967 -2170
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +251 -173
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5,8 +5,8 @@ import * as fs4 from 'fs';
|
|
|
5
5
|
import fs4__default, { readFileSync, constants } from 'fs';
|
|
6
6
|
import * as fs15 from 'fs/promises';
|
|
7
7
|
import fs15__default, { readFile, access, readdir } from 'fs/promises';
|
|
8
|
-
import
|
|
9
|
-
import * as
|
|
8
|
+
import chalk4 from 'chalk';
|
|
9
|
+
import * as p4 from '@clack/prompts';
|
|
10
10
|
import { fileURLToPath } from 'url';
|
|
11
11
|
import { randomUUID } from 'crypto';
|
|
12
12
|
import { execa } from 'execa';
|
|
@@ -399,10 +399,10 @@ __export(allow_path_prompt_exports, {
|
|
|
399
399
|
async function promptAllowPath(dirPath) {
|
|
400
400
|
const absolute = path16__default.resolve(dirPath);
|
|
401
401
|
console.log();
|
|
402
|
-
console.log(
|
|
403
|
-
console.log(
|
|
402
|
+
console.log(chalk4.yellow(" \u26A0 Access denied \u2014 path is outside the project directory"));
|
|
403
|
+
console.log(chalk4.dim(` \u{1F4C1} ${absolute}`));
|
|
404
404
|
console.log();
|
|
405
|
-
const action = await
|
|
405
|
+
const action = await p4.select({
|
|
406
406
|
message: "Grant access to this directory?",
|
|
407
407
|
options: [
|
|
408
408
|
{ value: "session-write", label: "\u2713 Allow write (this session)" },
|
|
@@ -412,7 +412,7 @@ async function promptAllowPath(dirPath) {
|
|
|
412
412
|
{ value: "no", label: "\u2717 Deny" }
|
|
413
413
|
]
|
|
414
414
|
});
|
|
415
|
-
if (
|
|
415
|
+
if (p4.isCancel(action) || action === "no") {
|
|
416
416
|
return false;
|
|
417
417
|
}
|
|
418
418
|
const level = action.includes("read") ? "read" : "write";
|
|
@@ -423,7 +423,7 @@ async function promptAllowPath(dirPath) {
|
|
|
423
423
|
}
|
|
424
424
|
const levelLabel = level === "write" ? "write" : "read-only";
|
|
425
425
|
const persistLabel = persist ? " (remembered)" : "";
|
|
426
|
-
console.log(
|
|
426
|
+
console.log(chalk4.green(` \u2713 Access granted: ${levelLabel}${persistLabel}`));
|
|
427
427
|
return true;
|
|
428
428
|
}
|
|
429
429
|
var init_allow_path_prompt = __esm({
|
|
@@ -15968,9 +15968,9 @@ Examples:
|
|
|
15968
15968
|
if (file) {
|
|
15969
15969
|
options.file = file;
|
|
15970
15970
|
}
|
|
15971
|
-
const
|
|
15971
|
+
const log3 = await git.log(options);
|
|
15972
15972
|
return {
|
|
15973
|
-
commits:
|
|
15973
|
+
commits: log3.all.map((commit) => ({
|
|
15974
15974
|
hash: commit.hash,
|
|
15975
15975
|
message: commit.message,
|
|
15976
15976
|
author: commit.author_name,
|
|
@@ -16282,6 +16282,34 @@ var simpleAutoCommitTool = defineTool({
|
|
|
16282
16282
|
}
|
|
16283
16283
|
});
|
|
16284
16284
|
var gitSimpleTools = [checkProtectedBranchTool, simpleAutoCommitTool];
|
|
16285
|
+
var AGENT_NAMES = {
|
|
16286
|
+
explore: "Explorer",
|
|
16287
|
+
plan: "Planner",
|
|
16288
|
+
test: "Tester",
|
|
16289
|
+
debug: "Debugger",
|
|
16290
|
+
review: "Reviewer",
|
|
16291
|
+
architect: "Architect",
|
|
16292
|
+
security: "Security Auditor",
|
|
16293
|
+
tdd: "TDD Guide",
|
|
16294
|
+
refactor: "Refactorer",
|
|
16295
|
+
e2e: "E2E Tester",
|
|
16296
|
+
docs: "Docs Writer",
|
|
16297
|
+
database: "Database Engineer"
|
|
16298
|
+
};
|
|
16299
|
+
var AGENT_DESCRIPTIONS = {
|
|
16300
|
+
explore: "Search the codebase to answer questions and gather information",
|
|
16301
|
+
plan: "Design implementation approaches and create detailed plans",
|
|
16302
|
+
test: "Write and run tests to ensure code quality",
|
|
16303
|
+
debug: "Analyze errors and fix issues",
|
|
16304
|
+
review: "Review code for quality and best practices",
|
|
16305
|
+
architect: "Design system architecture and create architectural decision records",
|
|
16306
|
+
security: "Audit code for security vulnerabilities using OWASP Top 10",
|
|
16307
|
+
tdd: "Drive development with test-first methodology and RED-GREEN-REFACTOR cycle",
|
|
16308
|
+
refactor: "Improve code structure and quality without changing behavior",
|
|
16309
|
+
e2e: "Write and run end-to-end tests covering full user workflows",
|
|
16310
|
+
docs: "Generate and maintain documentation for code, APIs, and architecture",
|
|
16311
|
+
database: "Design database schemas, write migrations, and optimize queries"
|
|
16312
|
+
};
|
|
16285
16313
|
|
|
16286
16314
|
// src/agents/provider-bridge.ts
|
|
16287
16315
|
var agentProvider = null;
|
|
@@ -16292,103 +16320,80 @@ function getAgentProvider() {
|
|
|
16292
16320
|
function getAgentToolRegistry() {
|
|
16293
16321
|
return agentToolRegistry;
|
|
16294
16322
|
}
|
|
16295
|
-
|
|
16296
|
-
|
|
16297
|
-
|
|
16298
|
-
systemPrompt: `You are a code researcher agent. Your role is to:
|
|
16299
|
-
- Explore and understand existing codebases
|
|
16300
|
-
- Find relevant code patterns and examples
|
|
16301
|
-
- Identify dependencies and relationships
|
|
16302
|
-
- Document your findings clearly
|
|
16303
|
-
|
|
16304
|
-
Use tools to search, read files, and analyze code structure.`,
|
|
16305
|
-
allowedTools: ["read_file", "grep", "find_in_file", "glob", "codebase_map"]
|
|
16306
|
-
},
|
|
16307
|
-
coder: {
|
|
16308
|
-
role: "coder",
|
|
16309
|
-
systemPrompt: `You are a code generation agent. Your role is to:
|
|
16310
|
-
- Write high-quality, production-ready code
|
|
16311
|
-
- Follow best practices and coding standards
|
|
16312
|
-
- Ensure code is syntactically valid
|
|
16313
|
-
- Write clean, maintainable code
|
|
16314
|
-
|
|
16315
|
-
Use tools to read existing code, write new files, and validate syntax.`,
|
|
16316
|
-
allowedTools: ["read_file", "write_file", "edit_file", "bash_exec", "validateCode"]
|
|
16317
|
-
},
|
|
16318
|
-
tester: {
|
|
16319
|
-
role: "tester",
|
|
16320
|
-
systemPrompt: `You are a test generation agent. Your role is to:
|
|
16321
|
-
- Write comprehensive test suites
|
|
16322
|
-
- Achieve high code coverage
|
|
16323
|
-
- Test edge cases and error conditions
|
|
16324
|
-
- Ensure tests are reliable and maintainable
|
|
16325
|
-
|
|
16326
|
-
Use tools to read code, write tests, and run them.`,
|
|
16327
|
-
allowedTools: ["read_file", "write_file", "run_tests", "get_coverage", "run_test_file"]
|
|
16328
|
-
},
|
|
16329
|
-
reviewer: {
|
|
16330
|
-
role: "reviewer",
|
|
16331
|
-
systemPrompt: `You are a code review agent. Your role is to:
|
|
16332
|
-
- Identify code quality issues
|
|
16333
|
-
- Check for security vulnerabilities
|
|
16334
|
-
- Ensure best practices are followed
|
|
16335
|
-
- Provide actionable feedback
|
|
16336
|
-
|
|
16337
|
-
Use tools to read and analyze code quality.`,
|
|
16338
|
-
allowedTools: ["read_file", "calculate_quality", "analyze_complexity", "grep"]
|
|
16339
|
-
},
|
|
16340
|
-
optimizer: {
|
|
16341
|
-
role: "optimizer",
|
|
16342
|
-
systemPrompt: `You are a code optimization agent. Your role is to:
|
|
16343
|
-
- Reduce code complexity
|
|
16344
|
-
- Eliminate duplication
|
|
16345
|
-
- Improve performance
|
|
16346
|
-
- Refactor for maintainability
|
|
16347
|
-
|
|
16348
|
-
Use tools to analyze and improve code.`,
|
|
16349
|
-
allowedTools: ["read_file", "write_file", "edit_file", "analyze_complexity", "grep"]
|
|
16350
|
-
},
|
|
16351
|
-
planner: {
|
|
16352
|
-
role: "planner",
|
|
16353
|
-
systemPrompt: `You are a task planning agent. Your role is to:
|
|
16354
|
-
- Break down complex tasks into subtasks
|
|
16355
|
-
- Identify dependencies between tasks
|
|
16356
|
-
- Estimate complexity and effort
|
|
16357
|
-
- Create actionable plans
|
|
16358
|
-
|
|
16359
|
-
Use tools to analyze requirements and explore the codebase.`,
|
|
16360
|
-
allowedTools: ["read_file", "grep", "glob", "codebase_map"]
|
|
16323
|
+
function getAgentManager() {
|
|
16324
|
+
{
|
|
16325
|
+
return null;
|
|
16361
16326
|
}
|
|
16362
|
-
}
|
|
16327
|
+
}
|
|
16363
16328
|
|
|
16364
16329
|
// src/tools/simple-agent.ts
|
|
16330
|
+
var AGENT_TYPES = [
|
|
16331
|
+
"explore",
|
|
16332
|
+
"plan",
|
|
16333
|
+
"test",
|
|
16334
|
+
"debug",
|
|
16335
|
+
"review",
|
|
16336
|
+
"architect",
|
|
16337
|
+
"security",
|
|
16338
|
+
"tdd",
|
|
16339
|
+
"refactor",
|
|
16340
|
+
"e2e",
|
|
16341
|
+
"docs",
|
|
16342
|
+
"database"
|
|
16343
|
+
];
|
|
16344
|
+
var LEGACY_ROLE_MAP = {
|
|
16345
|
+
researcher: "explore",
|
|
16346
|
+
coder: "debug",
|
|
16347
|
+
// "debug" has write + bash + read — closest to general coding
|
|
16348
|
+
tester: "test",
|
|
16349
|
+
reviewer: "review",
|
|
16350
|
+
optimizer: "refactor",
|
|
16351
|
+
planner: "plan"
|
|
16352
|
+
};
|
|
16365
16353
|
var SpawnSimpleAgentSchema = z.object({
|
|
16366
16354
|
task: z.string().describe("Task description for the sub-agent"),
|
|
16367
16355
|
context: z.string().optional().describe("Additional context or instructions for the agent"),
|
|
16368
|
-
|
|
16356
|
+
type: z.enum(AGENT_TYPES).optional().describe(
|
|
16357
|
+
"Specialized agent type. Use 'explore' for codebase search, 'plan' for design, 'test' for testing, 'review' for code review, 'architect' for system design, 'security' for security audit, 'tdd' for test-driven development, 'debug' for debugging, 'refactor' for code improvement, 'e2e' for integration tests, 'docs' for documentation, 'database' for DB operations."
|
|
16358
|
+
),
|
|
16359
|
+
role: z.enum(["researcher", "coder", "tester", "reviewer", "optimizer", "planner"]).optional().describe("DEPRECATED: Use 'type' instead. Legacy role name, mapped to new agent types."),
|
|
16369
16360
|
maxTurns: z.number().default(10).describe("Maximum tool-use turns for the agent")
|
|
16370
16361
|
});
|
|
16362
|
+
function resolveAgentType(input) {
|
|
16363
|
+
if (input.type) return input.type;
|
|
16364
|
+
if (input.role && input.role in LEGACY_ROLE_MAP) return LEGACY_ROLE_MAP[input.role];
|
|
16365
|
+
return "explore";
|
|
16366
|
+
}
|
|
16371
16367
|
var spawnSimpleAgentTool = defineTool({
|
|
16372
16368
|
name: "spawnSimpleAgent",
|
|
16373
|
-
description: `Spawn a sub-agent to handle a specific task
|
|
16374
|
-
|
|
16375
|
-
|
|
16376
|
-
-
|
|
16377
|
-
-
|
|
16378
|
-
-
|
|
16379
|
-
|
|
16380
|
-
|
|
16381
|
-
|
|
16382
|
-
|
|
16369
|
+
description: `Spawn a specialized sub-agent to handle a specific task autonomously.
|
|
16370
|
+
|
|
16371
|
+
Available agent types:
|
|
16372
|
+
- explore: Search and understand codebases (read-only, fast)
|
|
16373
|
+
- plan: Design implementation approaches (read-only)
|
|
16374
|
+
- test: Write and run tests
|
|
16375
|
+
- debug: Analyze errors and fix issues
|
|
16376
|
+
- review: Review code for quality and best practices (read-only)
|
|
16377
|
+
- architect: Design system architecture (read-only)
|
|
16378
|
+
- security: Audit code for security vulnerabilities (read-only)
|
|
16379
|
+
- tdd: Test-driven development with RED-GREEN-REFACTOR
|
|
16380
|
+
- refactor: Improve code structure without changing behavior
|
|
16381
|
+
- e2e: End-to-end integration testing
|
|
16382
|
+
- docs: Generate and maintain documentation
|
|
16383
|
+
- database: Design schemas, migrations, and optimize queries
|
|
16384
|
+
|
|
16385
|
+
Each type has a filtered set of tools appropriate for its role.
|
|
16386
|
+
Use 'explore' for quick codebase searches, 'plan' for design before execution.`,
|
|
16383
16387
|
category: "build",
|
|
16384
16388
|
parameters: SpawnSimpleAgentSchema,
|
|
16385
16389
|
async execute(input) {
|
|
16386
16390
|
const typedInput = input;
|
|
16387
|
-
|
|
16388
|
-
|
|
16391
|
+
const manager = getAgentManager();
|
|
16392
|
+
if (!manager) {
|
|
16393
|
+
const agentId = `agent-${Date.now()}-${Math.random().toString(36).slice(2, 7)}`;
|
|
16389
16394
|
return {
|
|
16390
16395
|
stdout: JSON.stringify({
|
|
16391
|
-
agentId
|
|
16396
|
+
agentId,
|
|
16392
16397
|
status: "unavailable",
|
|
16393
16398
|
task: typedInput.task,
|
|
16394
16399
|
message: "Agent provider not initialized. Call setAgentProvider() during orchestrator startup.",
|
|
@@ -16399,6 +16404,31 @@ Example: "Write unit tests for the authentication module"`,
|
|
|
16399
16404
|
duration: 0
|
|
16400
16405
|
};
|
|
16401
16406
|
}
|
|
16407
|
+
const agentType = resolveAgentType(typedInput);
|
|
16408
|
+
const taskDescription = typedInput.context ? `${typedInput.task}
|
|
16409
|
+
|
|
16410
|
+
Additional context: ${typedInput.context}` : typedInput.task;
|
|
16411
|
+
const startTime = Date.now();
|
|
16412
|
+
const result = await manager.spawn(agentType, taskDescription, {
|
|
16413
|
+
timeout: typedInput.maxTurns * 6e4
|
|
16414
|
+
// rough estimate: 1 min per turn
|
|
16415
|
+
});
|
|
16416
|
+
const duration = Date.now() - startTime;
|
|
16417
|
+
return {
|
|
16418
|
+
stdout: JSON.stringify({
|
|
16419
|
+
agentId: result.agent.id,
|
|
16420
|
+
agentType,
|
|
16421
|
+
status: result.success ? "completed" : "failed",
|
|
16422
|
+
task: typedInput.task,
|
|
16423
|
+
output: result.output,
|
|
16424
|
+
success: result.success,
|
|
16425
|
+
usage: result.usage,
|
|
16426
|
+
duration
|
|
16427
|
+
}),
|
|
16428
|
+
stderr: "",
|
|
16429
|
+
exitCode: result.success ? 0 : 1,
|
|
16430
|
+
duration
|
|
16431
|
+
};
|
|
16402
16432
|
}
|
|
16403
16433
|
});
|
|
16404
16434
|
var checkAgentCapabilityTool = defineTool({
|
|
@@ -16410,17 +16440,23 @@ var checkAgentCapabilityTool = defineTool({
|
|
|
16410
16440
|
const provider = getAgentProvider();
|
|
16411
16441
|
const toolRegistry = getAgentToolRegistry();
|
|
16412
16442
|
const isReady = provider !== null;
|
|
16443
|
+
const agentTypes = Object.entries(AGENT_DESCRIPTIONS).map(([type, description]) => ({
|
|
16444
|
+
type,
|
|
16445
|
+
name: AGENT_NAMES[type],
|
|
16446
|
+
description
|
|
16447
|
+
}));
|
|
16413
16448
|
return {
|
|
16414
16449
|
stdout: JSON.stringify({
|
|
16415
16450
|
multiAgentSupported: true,
|
|
16416
16451
|
providerConfigured: provider !== null,
|
|
16417
16452
|
toolRegistryConfigured: toolRegistry !== null,
|
|
16418
16453
|
ready: isReady,
|
|
16419
|
-
|
|
16454
|
+
availableTypes: agentTypes,
|
|
16420
16455
|
features: {
|
|
16421
16456
|
taskDelegation: "requires provider initialization",
|
|
16422
16457
|
parallelSpawn: "requires provider initialization",
|
|
16423
|
-
multiTurnToolUse: "requires provider initialization"
|
|
16458
|
+
multiTurnToolUse: "requires provider initialization",
|
|
16459
|
+
specializedAgents: "requires provider initialization"
|
|
16424
16460
|
},
|
|
16425
16461
|
status: "Provider not initialized. Call setAgentProvider() during startup."
|
|
16426
16462
|
}),
|
|
@@ -17132,7 +17168,7 @@ Examples:
|
|
|
17132
17168
|
}
|
|
17133
17169
|
});
|
|
17134
17170
|
var searchTools = [grepTool, findInFileTool];
|
|
17135
|
-
var
|
|
17171
|
+
var DEFAULT_TIMEOUT_MS3 = 3e4;
|
|
17136
17172
|
var MAX_RESPONSE_SIZE = 5 * 1024 * 1024;
|
|
17137
17173
|
var httpFetchTool = defineTool({
|
|
17138
17174
|
name: "http_fetch",
|
|
@@ -17155,7 +17191,7 @@ Examples:
|
|
|
17155
17191
|
}),
|
|
17156
17192
|
async execute({ url, method, headers, body, timeout, maxSize }) {
|
|
17157
17193
|
const startTime = performance.now();
|
|
17158
|
-
const timeoutMs = timeout ??
|
|
17194
|
+
const timeoutMs = timeout ?? DEFAULT_TIMEOUT_MS3;
|
|
17159
17195
|
const maxBytes = maxSize ?? MAX_RESPONSE_SIZE;
|
|
17160
17196
|
try {
|
|
17161
17197
|
const controller = new AbortController();
|
|
@@ -17273,7 +17309,7 @@ Examples:
|
|
|
17273
17309
|
}
|
|
17274
17310
|
});
|
|
17275
17311
|
var httpTools = [httpFetchTool, httpJsonTool];
|
|
17276
|
-
var
|
|
17312
|
+
var DEFAULT_TIMEOUT_MS4 = 6e5;
|
|
17277
17313
|
var MAX_OUTPUT_SIZE2 = 2 * 1024 * 1024;
|
|
17278
17314
|
function getBuildHint(stderr, tool) {
|
|
17279
17315
|
if (/MODULE_NOT_FOUND|Cannot find module/i.test(stderr))
|
|
@@ -17337,7 +17373,7 @@ Examples:
|
|
|
17337
17373
|
async execute({ script, cwd, packageManager, args, env: env2, timeout }) {
|
|
17338
17374
|
const projectDir = cwd ?? process.cwd();
|
|
17339
17375
|
const startTime = performance.now();
|
|
17340
|
-
const timeoutMs = timeout ??
|
|
17376
|
+
const timeoutMs = timeout ?? DEFAULT_TIMEOUT_MS4;
|
|
17341
17377
|
const { CommandHeartbeat: CommandHeartbeat2 } = await Promise.resolve().then(() => (init_heartbeat(), heartbeat_exports));
|
|
17342
17378
|
const heartbeat = new CommandHeartbeat2({
|
|
17343
17379
|
onUpdate: (stats) => {
|
|
@@ -17433,7 +17469,7 @@ Examples:
|
|
|
17433
17469
|
async execute({ cwd, packageManager, packages, dev, frozen, timeout }) {
|
|
17434
17470
|
const projectDir = cwd ?? process.cwd();
|
|
17435
17471
|
const startTime = performance.now();
|
|
17436
|
-
const timeoutMs = timeout ??
|
|
17472
|
+
const timeoutMs = timeout ?? DEFAULT_TIMEOUT_MS4;
|
|
17437
17473
|
const { CommandHeartbeat: CommandHeartbeat2 } = await Promise.resolve().then(() => (init_heartbeat(), heartbeat_exports));
|
|
17438
17474
|
const heartbeat = new CommandHeartbeat2({
|
|
17439
17475
|
onUpdate: (stats) => {
|
|
@@ -17557,7 +17593,7 @@ Examples:
|
|
|
17557
17593
|
async execute({ target, cwd, args, env: env2, timeout }) {
|
|
17558
17594
|
const projectDir = cwd ?? process.cwd();
|
|
17559
17595
|
const startTime = performance.now();
|
|
17560
|
-
const timeoutMs = timeout ??
|
|
17596
|
+
const timeoutMs = timeout ?? DEFAULT_TIMEOUT_MS4;
|
|
17561
17597
|
const { CommandHeartbeat: CommandHeartbeat2 } = await Promise.resolve().then(() => (init_heartbeat(), heartbeat_exports));
|
|
17562
17598
|
const heartbeat = new CommandHeartbeat2({
|
|
17563
17599
|
onUpdate: (stats) => {
|
|
@@ -17660,7 +17696,7 @@ Examples:
|
|
|
17660
17696
|
async execute({ cwd, project, noEmit, watch: watch2, args, timeout }) {
|
|
17661
17697
|
const projectDir = cwd ?? process.cwd();
|
|
17662
17698
|
const startTime = performance.now();
|
|
17663
|
-
const timeoutMs = timeout ??
|
|
17699
|
+
const timeoutMs = timeout ?? DEFAULT_TIMEOUT_MS4;
|
|
17664
17700
|
const { CommandHeartbeat: CommandHeartbeat2 } = await Promise.resolve().then(() => (init_heartbeat(), heartbeat_exports));
|
|
17665
17701
|
const heartbeat = new CommandHeartbeat2({
|
|
17666
17702
|
onUpdate: (stats) => {
|
|
@@ -18440,7 +18476,7 @@ Examples:
|
|
|
18440
18476
|
}
|
|
18441
18477
|
}
|
|
18442
18478
|
});
|
|
18443
|
-
var
|
|
18479
|
+
var DEFAULT_TIMEOUT_MS5 = 3e4;
|
|
18444
18480
|
var DEFAULT_MAX_LENGTH = 5e4;
|
|
18445
18481
|
var MAX_DOWNLOAD_SIZE = 10 * 1024 * 1024;
|
|
18446
18482
|
var BLOCKED_SCHEMES = ["file:", "ftp:", "data:", "javascript:"];
|
|
@@ -18671,12 +18707,12 @@ Examples:
|
|
|
18671
18707
|
url: z.string().url().describe("URL to fetch"),
|
|
18672
18708
|
extractContent: z.boolean().optional().default(true).describe("Extract and clean main content (true) or return raw (false)"),
|
|
18673
18709
|
maxLength: z.number().min(1e3).max(2e5).optional().default(DEFAULT_MAX_LENGTH).describe("Maximum content length in characters"),
|
|
18674
|
-
timeout: z.number().min(1e3).max(12e4).optional().default(
|
|
18710
|
+
timeout: z.number().min(1e3).max(12e4).optional().default(DEFAULT_TIMEOUT_MS5).describe("Timeout in milliseconds")
|
|
18675
18711
|
}),
|
|
18676
18712
|
async execute({ url, extractContent, maxLength, timeout }) {
|
|
18677
18713
|
const startTime = performance.now();
|
|
18678
18714
|
const effectiveMaxLength = maxLength ?? DEFAULT_MAX_LENGTH;
|
|
18679
|
-
const effectiveTimeout = timeout ??
|
|
18715
|
+
const effectiveTimeout = timeout ?? DEFAULT_TIMEOUT_MS5;
|
|
18680
18716
|
validateUrl(url);
|
|
18681
18717
|
const controller = new AbortController();
|
|
18682
18718
|
const timeoutId = setTimeout(() => controller.abort(), effectiveTimeout);
|
|
@@ -18805,63 +18841,63 @@ var LANG_ALIASES = {
|
|
|
18805
18841
|
};
|
|
18806
18842
|
var TOKEN_COLORS = {
|
|
18807
18843
|
// Keywords & control flow
|
|
18808
|
-
keyword: (t) =>
|
|
18809
|
-
"keyword.control": (t) =>
|
|
18844
|
+
keyword: (t) => chalk4.blue(t),
|
|
18845
|
+
"keyword.control": (t) => chalk4.blue(t),
|
|
18810
18846
|
// Built-in types and literals
|
|
18811
|
-
built_in: (t) =>
|
|
18812
|
-
type: (t) =>
|
|
18813
|
-
class: (t) =>
|
|
18814
|
-
"title.class": (t) =>
|
|
18815
|
-
"title.class.inherited": (t) =>
|
|
18847
|
+
built_in: (t) => chalk4.cyan(t),
|
|
18848
|
+
type: (t) => chalk4.cyan(t),
|
|
18849
|
+
class: (t) => chalk4.cyan(t),
|
|
18850
|
+
"title.class": (t) => chalk4.cyan(t),
|
|
18851
|
+
"title.class.inherited": (t) => chalk4.cyan(t),
|
|
18816
18852
|
// Functions
|
|
18817
|
-
"title.function": (t) =>
|
|
18818
|
-
"title.function.invoke": (t) =>
|
|
18819
|
-
title: (t) =>
|
|
18853
|
+
"title.function": (t) => chalk4.green(t),
|
|
18854
|
+
"title.function.invoke": (t) => chalk4.green(t),
|
|
18855
|
+
title: (t) => chalk4.green(t),
|
|
18820
18856
|
// Strings
|
|
18821
|
-
string: (t) =>
|
|
18822
|
-
"template-tag": (t) =>
|
|
18823
|
-
"template-variable": (t) =>
|
|
18857
|
+
string: (t) => chalk4.yellow(t),
|
|
18858
|
+
"template-tag": (t) => chalk4.yellow(t),
|
|
18859
|
+
"template-variable": (t) => chalk4.green(t),
|
|
18824
18860
|
// Numbers
|
|
18825
|
-
number: (t) =>
|
|
18861
|
+
number: (t) => chalk4.magenta(t),
|
|
18826
18862
|
// Literals (true, false, null)
|
|
18827
|
-
literal: (t) =>
|
|
18863
|
+
literal: (t) => chalk4.magenta(t),
|
|
18828
18864
|
// Comments
|
|
18829
|
-
comment: (t) =>
|
|
18830
|
-
doctag: (t) =>
|
|
18865
|
+
comment: (t) => chalk4.dim(t),
|
|
18866
|
+
doctag: (t) => chalk4.dim.bold(t),
|
|
18831
18867
|
// Regular expressions
|
|
18832
|
-
regexp: (t) =>
|
|
18868
|
+
regexp: (t) => chalk4.red(t),
|
|
18833
18869
|
// Attributes & properties
|
|
18834
|
-
attr: (t) =>
|
|
18835
|
-
attribute: (t) =>
|
|
18836
|
-
property: (t) =>
|
|
18870
|
+
attr: (t) => chalk4.cyan(t),
|
|
18871
|
+
attribute: (t) => chalk4.cyan(t),
|
|
18872
|
+
property: (t) => chalk4.white(t),
|
|
18837
18873
|
// Operators & punctuation
|
|
18838
|
-
operator: (t) =>
|
|
18839
|
-
punctuation: (t) =>
|
|
18874
|
+
operator: (t) => chalk4.dim.white(t),
|
|
18875
|
+
punctuation: (t) => chalk4.dim.white(t),
|
|
18840
18876
|
// Meta / preprocessor
|
|
18841
|
-
meta: (t) =>
|
|
18842
|
-
"meta keyword": (t) =>
|
|
18843
|
-
"meta string": (t) =>
|
|
18877
|
+
meta: (t) => chalk4.dim(t),
|
|
18878
|
+
"meta keyword": (t) => chalk4.blue(t),
|
|
18879
|
+
"meta string": (t) => chalk4.yellow(t),
|
|
18844
18880
|
// Variables & params
|
|
18845
|
-
variable: (t) =>
|
|
18846
|
-
"variable.language": (t) =>
|
|
18847
|
-
params: (t) =>
|
|
18881
|
+
variable: (t) => chalk4.white(t),
|
|
18882
|
+
"variable.language": (t) => chalk4.blue(t),
|
|
18883
|
+
params: (t) => chalk4.white(t),
|
|
18848
18884
|
// Tags (HTML/XML)
|
|
18849
|
-
tag: (t) =>
|
|
18850
|
-
name: (t) =>
|
|
18885
|
+
tag: (t) => chalk4.blue(t),
|
|
18886
|
+
name: (t) => chalk4.blue(t),
|
|
18851
18887
|
// Symbols & selectors (CSS, Ruby)
|
|
18852
|
-
symbol: (t) =>
|
|
18853
|
-
selector: (t) =>
|
|
18854
|
-
"selector-tag": (t) =>
|
|
18855
|
-
"selector-class": (t) =>
|
|
18856
|
-
"selector-id": (t) =>
|
|
18888
|
+
symbol: (t) => chalk4.magenta(t),
|
|
18889
|
+
selector: (t) => chalk4.green(t),
|
|
18890
|
+
"selector-tag": (t) => chalk4.blue(t),
|
|
18891
|
+
"selector-class": (t) => chalk4.green(t),
|
|
18892
|
+
"selector-id": (t) => chalk4.cyan(t),
|
|
18857
18893
|
// Additions/deletions (diffs)
|
|
18858
|
-
addition: (t) =>
|
|
18859
|
-
deletion: (t) =>
|
|
18894
|
+
addition: (t) => chalk4.green(t),
|
|
18895
|
+
deletion: (t) => chalk4.red(t),
|
|
18860
18896
|
// Section headers
|
|
18861
|
-
section: (t) =>
|
|
18897
|
+
section: (t) => chalk4.bold(t),
|
|
18862
18898
|
// Emphasis
|
|
18863
|
-
emphasis: (t) =>
|
|
18864
|
-
strong: (t) =>
|
|
18899
|
+
emphasis: (t) => chalk4.italic(t),
|
|
18900
|
+
strong: (t) => chalk4.bold(t)
|
|
18865
18901
|
};
|
|
18866
18902
|
function hljsToChalk(html) {
|
|
18867
18903
|
const safeSpans = [];
|
|
@@ -18916,10 +18952,10 @@ function highlightLine(line, lang) {
|
|
|
18916
18952
|
}
|
|
18917
18953
|
|
|
18918
18954
|
// src/cli/repl/output/diff-renderer.ts
|
|
18919
|
-
var bgDeleteLine =
|
|
18920
|
-
var bgAddLine =
|
|
18921
|
-
var bgDeleteWord =
|
|
18922
|
-
var bgAddWord =
|
|
18955
|
+
var bgDeleteLine = chalk4.bgRgb(80, 20, 20);
|
|
18956
|
+
var bgAddLine = chalk4.bgRgb(20, 60, 20);
|
|
18957
|
+
var bgDeleteWord = chalk4.bgRgb(160, 40, 40);
|
|
18958
|
+
var bgAddWord = chalk4.bgRgb(40, 120, 40);
|
|
18923
18959
|
function parseDiff(raw) {
|
|
18924
18960
|
const files = [];
|
|
18925
18961
|
const lines = raw.split("\n");
|
|
@@ -19116,7 +19152,7 @@ function renderDiff(diff, options) {
|
|
|
19116
19152
|
const maxWidth = options?.maxWidth ?? Math.min(getTerminalWidth() - 2, 120);
|
|
19117
19153
|
const compact = options?.compact ?? false;
|
|
19118
19154
|
if (diff.files.length === 0) {
|
|
19119
|
-
console.log(
|
|
19155
|
+
console.log(chalk4.dim("\n No changes\n"));
|
|
19120
19156
|
return;
|
|
19121
19157
|
}
|
|
19122
19158
|
for (const file of diff.files) {
|
|
@@ -19125,9 +19161,9 @@ function renderDiff(diff, options) {
|
|
|
19125
19161
|
const { stats } = diff;
|
|
19126
19162
|
const parts = [];
|
|
19127
19163
|
parts.push(`${stats.filesChanged} file${stats.filesChanged !== 1 ? "s" : ""}`);
|
|
19128
|
-
if (stats.additions > 0) parts.push(
|
|
19129
|
-
if (stats.deletions > 0) parts.push(
|
|
19130
|
-
console.log(
|
|
19164
|
+
if (stats.additions > 0) parts.push(chalk4.green(`+${stats.additions}`));
|
|
19165
|
+
if (stats.deletions > 0) parts.push(chalk4.red(`-${stats.deletions}`));
|
|
19166
|
+
console.log(chalk4.dim(`
|
|
19131
19167
|
${parts.join(", ")}
|
|
19132
19168
|
`));
|
|
19133
19169
|
}
|
|
@@ -19140,22 +19176,22 @@ function renderFileBlock(file, opts) {
|
|
|
19140
19176
|
const title = ` ${file.path} (${typeLabel}${statsLabel}) `;
|
|
19141
19177
|
const topFill = Math.max(0, maxWidth - 2 - stripAnsi(title).length);
|
|
19142
19178
|
console.log(
|
|
19143
|
-
|
|
19179
|
+
chalk4.magenta("\u256D\u2500\u2500") + chalk4.cyan.bold(title) + chalk4.magenta("\u2500".repeat(topFill) + "\u256E")
|
|
19144
19180
|
);
|
|
19145
19181
|
for (let h = 0; h < file.hunks.length; h++) {
|
|
19146
19182
|
const hunk = file.hunks[h];
|
|
19147
19183
|
if (!compact || h > 0) {
|
|
19148
|
-
const hunkLabel = hunk.heading ? ` ${
|
|
19184
|
+
const hunkLabel = hunk.heading ? ` ${chalk4.dim(hunk.heading)}` : "";
|
|
19149
19185
|
console.log(
|
|
19150
|
-
|
|
19186
|
+
chalk4.magenta("\u2502") + " " + chalk4.cyan(
|
|
19151
19187
|
`@@ -${hunk.oldStart},${hunk.oldLines} +${hunk.newStart},${hunk.newLines} @@`
|
|
19152
19188
|
) + hunkLabel
|
|
19153
19189
|
);
|
|
19154
19190
|
}
|
|
19155
19191
|
const pairs = pairAdjacentLines(hunk.lines);
|
|
19156
|
-
const pairedDeleteIndices = new Set(pairs.map((
|
|
19157
|
-
const pairedAddIndices = new Set(pairs.map((
|
|
19158
|
-
const pairByAdd = new Map(pairs.map((
|
|
19192
|
+
const pairedDeleteIndices = new Set(pairs.map((p5) => p5.deleteIdx));
|
|
19193
|
+
const pairedAddIndices = new Set(pairs.map((p5) => p5.addIdx));
|
|
19194
|
+
const pairByAdd = new Map(pairs.map((p5) => [p5.addIdx, p5.deleteIdx]));
|
|
19159
19195
|
const wordHighlights = /* @__PURE__ */ new Map();
|
|
19160
19196
|
for (const pair of pairs) {
|
|
19161
19197
|
const delLine = hunk.lines[pair.deleteIdx];
|
|
@@ -19179,7 +19215,7 @@ function renderFileBlock(file, opts) {
|
|
|
19179
19215
|
const plainLen = stripAnsi(innerText).length + 1;
|
|
19180
19216
|
const pad = Math.max(0, contentWidth - plainLen);
|
|
19181
19217
|
console.log(
|
|
19182
|
-
|
|
19218
|
+
chalk4.magenta("\u2502") + bgAddLine(` ${innerText}` + " ".repeat(pad + 2)) + chalk4.magenta("\u2502")
|
|
19183
19219
|
);
|
|
19184
19220
|
} else if (line.type === "delete") {
|
|
19185
19221
|
const isPaired = pairedDeleteIndices.has(li);
|
|
@@ -19193,7 +19229,7 @@ function renderFileBlock(file, opts) {
|
|
|
19193
19229
|
const plainLen = stripAnsi(innerText).length + 1;
|
|
19194
19230
|
const pad = Math.max(0, contentWidth - plainLen);
|
|
19195
19231
|
console.log(
|
|
19196
|
-
|
|
19232
|
+
chalk4.magenta("\u2502") + bgDeleteLine(` ${innerText}` + " ".repeat(pad + 2)) + chalk4.magenta("\u2502")
|
|
19197
19233
|
);
|
|
19198
19234
|
} else {
|
|
19199
19235
|
let content = line.content;
|
|
@@ -19204,17 +19240,17 @@ function renderFileBlock(file, opts) {
|
|
|
19204
19240
|
const plainLen = stripAnsi(lineStr).length;
|
|
19205
19241
|
const pad = Math.max(0, contentWidth - plainLen);
|
|
19206
19242
|
console.log(
|
|
19207
|
-
|
|
19243
|
+
chalk4.magenta("\u2502") + chalk4.dim(` ${lineStr}`) + " ".repeat(pad) + " " + chalk4.magenta("\u2502")
|
|
19208
19244
|
);
|
|
19209
19245
|
}
|
|
19210
19246
|
}
|
|
19211
19247
|
}
|
|
19212
|
-
console.log(
|
|
19248
|
+
console.log(chalk4.magenta("\u2570" + "\u2500".repeat(Math.max(0, maxWidth - 2)) + "\u256F"));
|
|
19213
19249
|
}
|
|
19214
19250
|
function formatLineNo(line, show) {
|
|
19215
19251
|
if (!show) return "";
|
|
19216
19252
|
const lineNo = line.type === "delete" ? line.oldLineNo : line.newLineNo;
|
|
19217
|
-
return
|
|
19253
|
+
return chalk4.dim(`${String(lineNo ?? "").padStart(5)} `);
|
|
19218
19254
|
}
|
|
19219
19255
|
function getChangedLines(diff) {
|
|
19220
19256
|
const result = /* @__PURE__ */ new Map();
|
|
@@ -22121,6 +22157,13 @@ var createAgentPlanTool = defineTool({
|
|
|
22121
22157
|
};
|
|
22122
22158
|
}
|
|
22123
22159
|
});
|
|
22160
|
+
var LEGACY_ROLE_TO_TYPE = {
|
|
22161
|
+
researcher: "explore",
|
|
22162
|
+
coder: "debug",
|
|
22163
|
+
reviewer: "review",
|
|
22164
|
+
tester: "test",
|
|
22165
|
+
optimizer: "refactor"
|
|
22166
|
+
};
|
|
22124
22167
|
var delegateTaskTool = defineTool({
|
|
22125
22168
|
name: "delegateTask",
|
|
22126
22169
|
description: "Delegate a task to a specialized sub-agent with real LLM tool-use execution.",
|
|
@@ -22128,22 +22171,57 @@ var delegateTaskTool = defineTool({
|
|
|
22128
22171
|
parameters: z.object({
|
|
22129
22172
|
taskId: z.string(),
|
|
22130
22173
|
task: z.string().describe("Description of the task for the agent to execute"),
|
|
22131
|
-
|
|
22174
|
+
agentType: z.enum([
|
|
22175
|
+
"explore",
|
|
22176
|
+
"plan",
|
|
22177
|
+
"test",
|
|
22178
|
+
"debug",
|
|
22179
|
+
"review",
|
|
22180
|
+
"architect",
|
|
22181
|
+
"security",
|
|
22182
|
+
"tdd",
|
|
22183
|
+
"refactor",
|
|
22184
|
+
"e2e",
|
|
22185
|
+
"docs",
|
|
22186
|
+
"database"
|
|
22187
|
+
]).optional().describe("Specialized agent type to use"),
|
|
22188
|
+
agentRole: z.enum(["researcher", "coder", "reviewer", "tester", "optimizer"]).optional().describe("DEPRECATED: Use agentType instead"),
|
|
22132
22189
|
context: z.string().optional(),
|
|
22133
22190
|
maxTurns: z.number().default(10)
|
|
22134
22191
|
}),
|
|
22135
22192
|
async execute(input) {
|
|
22136
22193
|
const typedInput = input;
|
|
22137
|
-
|
|
22194
|
+
const manager = getAgentManager();
|
|
22195
|
+
if (!manager) {
|
|
22196
|
+
const resolvedType = typedInput.agentType ?? "explore";
|
|
22138
22197
|
return {
|
|
22139
|
-
agentId: `agent-${Date.now()}-${
|
|
22198
|
+
agentId: `agent-${Date.now()}-${resolvedType}`,
|
|
22140
22199
|
taskId: typedInput.taskId,
|
|
22141
|
-
|
|
22200
|
+
agentType: resolvedType,
|
|
22142
22201
|
status: "unavailable",
|
|
22143
22202
|
message: "Agent provider not initialized. Call setAgentProvider() during orchestrator startup.",
|
|
22144
22203
|
success: false
|
|
22145
22204
|
};
|
|
22146
22205
|
}
|
|
22206
|
+
const agentType = typedInput.agentType ?? (typedInput.agentRole ? LEGACY_ROLE_TO_TYPE[typedInput.agentRole] ?? "explore" : "explore");
|
|
22207
|
+
const taskDescription = typedInput.context ? `${typedInput.task}
|
|
22208
|
+
|
|
22209
|
+
Additional context: ${typedInput.context}` : typedInput.task;
|
|
22210
|
+
const startTime = Date.now();
|
|
22211
|
+
const result = await manager.spawn(agentType, taskDescription, {
|
|
22212
|
+
timeout: typedInput.maxTurns * 6e4
|
|
22213
|
+
});
|
|
22214
|
+
const duration = Date.now() - startTime;
|
|
22215
|
+
return {
|
|
22216
|
+
agentId: result.agent.id,
|
|
22217
|
+
taskId: typedInput.taskId,
|
|
22218
|
+
agentType,
|
|
22219
|
+
status: result.success ? "completed" : "failed",
|
|
22220
|
+
output: result.output,
|
|
22221
|
+
success: result.success,
|
|
22222
|
+
usage: result.usage,
|
|
22223
|
+
duration
|
|
22224
|
+
};
|
|
22147
22225
|
}
|
|
22148
22226
|
});
|
|
22149
22227
|
var aggregateResultsTool = defineTool({
|
|
@@ -22575,11 +22653,11 @@ var getLearnedPatternsTool = defineTool({
|
|
|
22575
22653
|
const patterns = store.getFrequentPatterns(typedInput.limit);
|
|
22576
22654
|
return {
|
|
22577
22655
|
totalPatterns: patterns.length,
|
|
22578
|
-
patterns: patterns.map((
|
|
22579
|
-
pattern:
|
|
22580
|
-
preference:
|
|
22581
|
-
frequency:
|
|
22582
|
-
lastUsed: new Date(
|
|
22656
|
+
patterns: patterns.map((p5) => ({
|
|
22657
|
+
pattern: p5.pattern,
|
|
22658
|
+
preference: p5.userPreference,
|
|
22659
|
+
frequency: p5.frequency,
|
|
22660
|
+
lastUsed: new Date(p5.lastUsed).toISOString()
|
|
22583
22661
|
}))
|
|
22584
22662
|
};
|
|
22585
22663
|
}
|
|
@@ -23160,11 +23238,11 @@ function isBlockedPath(absolute) {
|
|
|
23160
23238
|
return void 0;
|
|
23161
23239
|
}
|
|
23162
23240
|
function isBlockedExecFile(filePath) {
|
|
23163
|
-
return BLOCKED_EXEC_PATTERNS.some((
|
|
23241
|
+
return BLOCKED_EXEC_PATTERNS.some((p5) => p5.test(filePath));
|
|
23164
23242
|
}
|
|
23165
23243
|
function hasDangerousArgs(args) {
|
|
23166
23244
|
const joined = args.join(" ");
|
|
23167
|
-
return DANGEROUS_ARG_PATTERNS.some((
|
|
23245
|
+
return DANGEROUS_ARG_PATTERNS.some((p5) => p5.test(joined));
|
|
23168
23246
|
}
|
|
23169
23247
|
function getInterpreter(ext) {
|
|
23170
23248
|
return INTERPRETER_MAP[ext.toLowerCase()];
|