@nick848/sf-cli 1.0.8 → 1.0.11
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/CHANGELOG.md +39 -0
- package/dist/cli/index.js +3536 -3451
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.mts +374 -382
- package/dist/index.d.ts +374 -382
- package/dist/index.js +1653 -1701
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1648 -1700
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -408,6 +408,7 @@ interface CLIConfig {
|
|
|
408
408
|
theme: 'light' | 'dark' | 'auto';
|
|
409
409
|
}
|
|
410
410
|
type WorkflowStep = 'explore' | 'new' | 'continue' | 'apply' | 'archive' | 'propose';
|
|
411
|
+
type WorkflowPhase = 'context' | 'clarify' | 'analysis' | 'bdd' | 'spec' | 'tdd' | 'develop' | 'review';
|
|
411
412
|
type WorkflowType = 'complex' | 'simple';
|
|
412
413
|
type WorkflowStatus = 'pending' | 'running' | 'completed' | 'failed' | 'cancelled';
|
|
413
414
|
interface WorkflowState {
|
|
@@ -1376,157 +1377,426 @@ interface REPLState {
|
|
|
1376
1377
|
}
|
|
1377
1378
|
|
|
1378
1379
|
/**
|
|
1379
|
-
*
|
|
1380
|
-
*
|
|
1380
|
+
* 命令执行器
|
|
1381
|
+
* 执行解析后的命令
|
|
1381
1382
|
*/
|
|
1382
1383
|
|
|
1384
|
+
interface ExecutorContext {
|
|
1385
|
+
contextManager: ContextManager;
|
|
1386
|
+
configManager: ConfigManager;
|
|
1387
|
+
modelService: ModelService;
|
|
1388
|
+
normsManager?: NormsManager;
|
|
1389
|
+
state: REPLState;
|
|
1390
|
+
options: {
|
|
1391
|
+
workingDirectory: string;
|
|
1392
|
+
model?: string;
|
|
1393
|
+
yolo?: boolean;
|
|
1394
|
+
};
|
|
1395
|
+
}
|
|
1396
|
+
interface ExecutionResult {
|
|
1397
|
+
output?: string;
|
|
1398
|
+
exit?: boolean;
|
|
1399
|
+
contextUsed?: number;
|
|
1400
|
+
}
|
|
1401
|
+
declare class CommandExecutor {
|
|
1402
|
+
execute(parseResult: ParseResult, ctx: ExecutorContext): Promise<ExecutionResult>;
|
|
1403
|
+
private executeSlashCommand;
|
|
1404
|
+
private executeFileReference;
|
|
1405
|
+
private executeAgent;
|
|
1406
|
+
private executeShell;
|
|
1407
|
+
private executeNaturalLanguage;
|
|
1408
|
+
private executeYolo;
|
|
1409
|
+
}
|
|
1410
|
+
|
|
1383
1411
|
/**
|
|
1384
|
-
*
|
|
1412
|
+
* Agent 运行器
|
|
1413
|
+
* 简化的 Agent 调度入口,提供统一的 Agent 执行接口
|
|
1385
1414
|
*/
|
|
1386
|
-
|
|
1415
|
+
|
|
1416
|
+
interface AgentResult {
|
|
1417
|
+
output: string;
|
|
1418
|
+
contextUsed: number;
|
|
1419
|
+
}
|
|
1387
1420
|
/**
|
|
1388
|
-
*
|
|
1421
|
+
* 运行 Agent(简化版)
|
|
1389
1422
|
*/
|
|
1390
|
-
|
|
1391
|
-
type: ConfirmationPointType;
|
|
1392
|
-
name: string;
|
|
1393
|
-
description: string;
|
|
1394
|
-
triggerStep: WorkflowStep;
|
|
1395
|
-
targetStep: WorkflowStep;
|
|
1396
|
-
required: boolean;
|
|
1397
|
-
timeout?: number;
|
|
1398
|
-
}
|
|
1423
|
+
declare function runAgent(agentId: string, args: string[], ctx: ExecutorContext): Promise<AgentResult>;
|
|
1399
1424
|
/**
|
|
1400
|
-
*
|
|
1425
|
+
* 获取 Agent 定义
|
|
1401
1426
|
*/
|
|
1402
|
-
|
|
1403
|
-
type: ConfirmationPointType;
|
|
1404
|
-
confirmed: boolean;
|
|
1405
|
-
confirmedAt?: Date;
|
|
1406
|
-
confirmedBy?: string;
|
|
1407
|
-
comment?: string;
|
|
1408
|
-
}
|
|
1427
|
+
declare function getAgent(agentId: AgentId): AgentDefinition | undefined;
|
|
1409
1428
|
/**
|
|
1410
|
-
*
|
|
1411
|
-
* 定义从哪些阶段可以回滚到哪些阶段
|
|
1412
|
-
*
|
|
1413
|
-
* 复杂流程: explore → new → continue → apply → archive
|
|
1414
|
-
* 简单流程: propose → apply → archive
|
|
1429
|
+
* 列出所有 Agent
|
|
1415
1430
|
*/
|
|
1416
|
-
declare
|
|
1431
|
+
declare function listAgents(): AgentDefinition[];
|
|
1417
1432
|
/**
|
|
1418
|
-
*
|
|
1433
|
+
* 获取工作流阶段对应的 Agent
|
|
1419
1434
|
*/
|
|
1420
|
-
|
|
1435
|
+
declare function getAgentsForStep(step: string): AgentDefinition[];
|
|
1436
|
+
|
|
1421
1437
|
/**
|
|
1422
|
-
*
|
|
1438
|
+
* Agent 执行引擎
|
|
1439
|
+
* 负责调度和执行 Agent,包括 Prompt 构建、模型调用、工具执行
|
|
1423
1440
|
*/
|
|
1424
|
-
|
|
1425
|
-
fromStep: WorkflowStep;
|
|
1426
|
-
toStep: WorkflowStep;
|
|
1427
|
-
reason: RollbackReason;
|
|
1428
|
-
description: string;
|
|
1429
|
-
timestamp: Date;
|
|
1430
|
-
}
|
|
1441
|
+
|
|
1431
1442
|
/**
|
|
1432
|
-
*
|
|
1443
|
+
* Agent 执行器
|
|
1433
1444
|
*/
|
|
1434
|
-
declare class
|
|
1435
|
-
private
|
|
1436
|
-
private
|
|
1437
|
-
|
|
1445
|
+
declare class AgentExecutor {
|
|
1446
|
+
private modelService;
|
|
1447
|
+
private normsManager;
|
|
1448
|
+
private contextManager;
|
|
1449
|
+
private sessions;
|
|
1450
|
+
private eventListeners;
|
|
1451
|
+
constructor(modelService: ModelService, normsManager: NormsManager, contextManager: ContextManager);
|
|
1438
1452
|
/**
|
|
1439
|
-
*
|
|
1453
|
+
* 执行 Agent
|
|
1440
1454
|
*/
|
|
1441
|
-
|
|
1455
|
+
execute(request: AgentScheduleRequest): Promise<AgentExecutionResult>;
|
|
1442
1456
|
/**
|
|
1443
|
-
*
|
|
1457
|
+
* 流式执行 Agent
|
|
1444
1458
|
*/
|
|
1445
|
-
|
|
1459
|
+
executeStream(request: AgentScheduleRequest): AsyncGenerator<string, AgentExecutionResult, unknown>;
|
|
1446
1460
|
/**
|
|
1447
|
-
*
|
|
1461
|
+
* 获取会话状态
|
|
1448
1462
|
*/
|
|
1449
|
-
|
|
1463
|
+
getSession(sessionId: string): AgentSession | undefined;
|
|
1450
1464
|
/**
|
|
1451
|
-
*
|
|
1465
|
+
* 取消执行
|
|
1452
1466
|
*/
|
|
1453
|
-
|
|
1467
|
+
cancel(sessionId: string): boolean;
|
|
1454
1468
|
/**
|
|
1455
|
-
*
|
|
1469
|
+
* 添加事件监听器
|
|
1456
1470
|
*/
|
|
1457
|
-
|
|
1471
|
+
addEventListener(listener: (event: AgentEvent) => void): void;
|
|
1458
1472
|
/**
|
|
1459
|
-
*
|
|
1473
|
+
* 移除事件监听器
|
|
1460
1474
|
*/
|
|
1461
|
-
|
|
1475
|
+
removeEventListener(listener: (event: AgentEvent) => void): void;
|
|
1462
1476
|
/**
|
|
1463
|
-
*
|
|
1477
|
+
* 创建会话
|
|
1464
1478
|
*/
|
|
1465
|
-
|
|
1479
|
+
private createSession;
|
|
1466
1480
|
/**
|
|
1467
|
-
*
|
|
1481
|
+
* 构建消息列表
|
|
1468
1482
|
*/
|
|
1469
|
-
|
|
1483
|
+
private buildMessages;
|
|
1470
1484
|
/**
|
|
1471
|
-
*
|
|
1485
|
+
* 摘要上下文(限制长度)
|
|
1472
1486
|
*/
|
|
1473
|
-
|
|
1487
|
+
private summarizeContext;
|
|
1474
1488
|
/**
|
|
1475
|
-
*
|
|
1489
|
+
* 提取关键规范(从 devstanded.md)
|
|
1476
1490
|
*/
|
|
1477
|
-
|
|
1491
|
+
private extractKeyStandards;
|
|
1492
|
+
/**
|
|
1493
|
+
* 构建任务提示
|
|
1494
|
+
*/
|
|
1495
|
+
private buildTaskPrompt;
|
|
1496
|
+
/**
|
|
1497
|
+
* 解析输出
|
|
1498
|
+
*/
|
|
1499
|
+
private parseOutput;
|
|
1500
|
+
/**
|
|
1501
|
+
* 发送事件
|
|
1502
|
+
*/
|
|
1503
|
+
private emitEvent;
|
|
1478
1504
|
}
|
|
1479
1505
|
/**
|
|
1480
|
-
*
|
|
1506
|
+
* 创建默认的 Agent 执行器
|
|
1481
1507
|
*/
|
|
1482
|
-
declare function
|
|
1508
|
+
declare function createAgentExecutor(modelService: ModelService, normsManager: NormsManager, contextManager: ContextManager): AgentExecutor;
|
|
1509
|
+
|
|
1483
1510
|
/**
|
|
1484
|
-
*
|
|
1511
|
+
* 内置 Agent 定义
|
|
1512
|
+
* 包含每个 Agent 的角色、能力、工具权限和 Prompt 模板
|
|
1485
1513
|
*/
|
|
1486
|
-
declare function generateRollbackPrompt(fromStep: WorkflowStep): string;
|
|
1487
1514
|
|
|
1488
1515
|
/**
|
|
1489
|
-
*
|
|
1490
|
-
*
|
|
1516
|
+
* 前端开发 Agent
|
|
1517
|
+
* 负责代码实现、组件开发、样式编写
|
|
1518
|
+
*/
|
|
1519
|
+
declare const FRONTEND_DEV_AGENT: AgentDefinition;
|
|
1520
|
+
/**
|
|
1521
|
+
* 代码审核 Agent
|
|
1522
|
+
* 负责代码质量检查、安全审查、最佳实践建议、回归测试
|
|
1523
|
+
*/
|
|
1524
|
+
declare const CODE_REVIEWER_AGENT: AgentDefinition;
|
|
1525
|
+
/**
|
|
1526
|
+
* 架构师 Agent
|
|
1527
|
+
* 负责技术方案设计、架构决策、技术选型
|
|
1528
|
+
*/
|
|
1529
|
+
declare const ARCHITECT_AGENT: AgentDefinition;
|
|
1530
|
+
/**
|
|
1531
|
+
* 测试 Agent
|
|
1532
|
+
* 负责测试用例编写、测试执行、测试报告
|
|
1533
|
+
*/
|
|
1534
|
+
declare const TESTER_AGENT: AgentDefinition;
|
|
1535
|
+
/**
|
|
1536
|
+
* 所有内置 Agent 的映射表
|
|
1537
|
+
*/
|
|
1538
|
+
declare const BUILTIN_AGENTS: Record<AgentId, AgentDefinition>;
|
|
1539
|
+
/**
|
|
1540
|
+
* 获取 Agent 定义
|
|
1541
|
+
*/
|
|
1542
|
+
declare function getAgentDefinition(id: AgentId): AgentDefinition | undefined;
|
|
1543
|
+
/**
|
|
1544
|
+
* 获取所有内置 Agent
|
|
1545
|
+
*/
|
|
1546
|
+
declare function getAllAgents(): AgentDefinition[];
|
|
1547
|
+
/**
|
|
1548
|
+
* 根据工作流阶段获取应触发的 Agent
|
|
1491
1549
|
*/
|
|
1550
|
+
declare function getAgentsForWorkflowStep(step: string): AgentDefinition[];
|
|
1492
1551
|
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1552
|
+
/**
|
|
1553
|
+
* Agent 自动调度器
|
|
1554
|
+
* 根据工作流阶段自动触发对应的 Agent 执行
|
|
1555
|
+
*/
|
|
1556
|
+
|
|
1557
|
+
/**
|
|
1558
|
+
* 调度策略
|
|
1559
|
+
*/
|
|
1560
|
+
type ScheduleStrategy = 'auto' | 'recommend' | 'manual';
|
|
1561
|
+
/**
|
|
1562
|
+
* 调度配置
|
|
1563
|
+
*/
|
|
1564
|
+
interface ScheduleConfig {
|
|
1565
|
+
agent: AgentId;
|
|
1566
|
+
strategy: ScheduleStrategy;
|
|
1567
|
+
waitForResult: boolean;
|
|
1568
|
+
requireConfirmation: boolean;
|
|
1569
|
+
fallbackAgent?: AgentId;
|
|
1498
1570
|
}
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1571
|
+
/**
|
|
1572
|
+
* 调度结果
|
|
1573
|
+
*/
|
|
1574
|
+
interface ScheduleResult {
|
|
1575
|
+
scheduled: boolean;
|
|
1576
|
+
agent?: AgentId;
|
|
1577
|
+
strategy: ScheduleStrategy;
|
|
1578
|
+
result?: AgentExecutionResult;
|
|
1503
1579
|
message: string;
|
|
1504
|
-
snapshot?: WorkflowSnapshot;
|
|
1505
1580
|
}
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1581
|
+
/**
|
|
1582
|
+
* 工作流阶段 → Agent 调度规则
|
|
1583
|
+
*
|
|
1584
|
+
* 设计原则:
|
|
1585
|
+
* - explore 阶段:架构师分析需求,输出技术方案
|
|
1586
|
+
* - new 阶段:前端开发实现核心代码
|
|
1587
|
+
* - continue 阶段:前端开发继续迭代
|
|
1588
|
+
* - apply 阶段:代码审核检查质量
|
|
1589
|
+
*/
|
|
1590
|
+
declare const SCHEDULE_RULES: Partial<Record<WorkflowStep, ScheduleConfig>>;
|
|
1591
|
+
/**
|
|
1592
|
+
* Agent 调度器
|
|
1593
|
+
*/
|
|
1594
|
+
declare class AgentScheduler {
|
|
1595
|
+
private executor;
|
|
1596
|
+
private lastScheduleResult;
|
|
1597
|
+
private onSchedule?;
|
|
1598
|
+
constructor(executor: AgentExecutor);
|
|
1599
|
+
/**
|
|
1600
|
+
* 设置调度回调
|
|
1601
|
+
*/
|
|
1602
|
+
setOnSchedule(callback: (result: ScheduleResult) => void): void;
|
|
1603
|
+
/**
|
|
1604
|
+
* 根据工作流阶段调度 Agent
|
|
1605
|
+
*/
|
|
1606
|
+
scheduleForStep(step: WorkflowStep, state: WorkflowState, options?: {
|
|
1607
|
+
strategy?: ScheduleStrategy;
|
|
1608
|
+
context?: Partial<AgentExecutionContext>;
|
|
1609
|
+
}): Promise<ScheduleResult>;
|
|
1610
|
+
/**
|
|
1611
|
+
* 执行 Agent
|
|
1612
|
+
*/
|
|
1613
|
+
private executeAgent;
|
|
1614
|
+
/**
|
|
1615
|
+
* 获取阶段的调度配置
|
|
1616
|
+
*/
|
|
1617
|
+
getScheduleConfig(step: WorkflowStep): ScheduleConfig | undefined;
|
|
1618
|
+
/**
|
|
1619
|
+
* 获取阶段的推荐 Agent
|
|
1620
|
+
*/
|
|
1621
|
+
getRecommendedAgent(step: WorkflowStep): AgentId | undefined;
|
|
1622
|
+
/**
|
|
1623
|
+
* 获取所有调度规则
|
|
1624
|
+
*/
|
|
1625
|
+
getAllScheduleRules(): Partial<Record<WorkflowStep, ScheduleConfig>>;
|
|
1626
|
+
/**
|
|
1627
|
+
* 获取上次调度结果
|
|
1628
|
+
*/
|
|
1629
|
+
getLastScheduleResult(): ScheduleResult | null;
|
|
1630
|
+
/**
|
|
1631
|
+
* 判断阶段是否需要自动调度
|
|
1632
|
+
*/
|
|
1633
|
+
shouldAutoSchedule(step: WorkflowStep): boolean;
|
|
1634
|
+
/**
|
|
1635
|
+
* 获取阶段可用的 Agent 列表
|
|
1636
|
+
*/
|
|
1637
|
+
getAvailableAgents(step: WorkflowStep): AgentId[];
|
|
1638
|
+
}
|
|
1639
|
+
/**
|
|
1640
|
+
* 创建调度器
|
|
1641
|
+
*/
|
|
1642
|
+
declare function createAgentScheduler(executor: AgentExecutor): AgentScheduler;
|
|
1643
|
+
/**
|
|
1644
|
+
* 获取调度规则描述
|
|
1645
|
+
*/
|
|
1646
|
+
declare function getScheduleRuleDescription(step: WorkflowStep): string;
|
|
1647
|
+
|
|
1648
|
+
/**
|
|
1649
|
+
* 工作流确认点系统
|
|
1650
|
+
* 在关键节点要求开发者确认才能继续
|
|
1651
|
+
*/
|
|
1652
|
+
|
|
1653
|
+
/**
|
|
1654
|
+
* 确认点类型
|
|
1655
|
+
*/
|
|
1656
|
+
type ConfirmationPointType = 'spec-review' | 'architecture' | 'code-review';
|
|
1657
|
+
/**
|
|
1658
|
+
* 确认点定义
|
|
1659
|
+
*/
|
|
1660
|
+
interface ConfirmationPoint {
|
|
1661
|
+
type: ConfirmationPointType;
|
|
1662
|
+
name: string;
|
|
1663
|
+
description: string;
|
|
1664
|
+
triggerStep: WorkflowStep;
|
|
1665
|
+
targetStep: WorkflowStep;
|
|
1666
|
+
required: boolean;
|
|
1667
|
+
timeout?: number;
|
|
1668
|
+
}
|
|
1669
|
+
/**
|
|
1670
|
+
* 确认状态
|
|
1671
|
+
*/
|
|
1672
|
+
interface ConfirmationStatus {
|
|
1673
|
+
type: ConfirmationPointType;
|
|
1674
|
+
confirmed: boolean;
|
|
1675
|
+
confirmedAt?: Date;
|
|
1676
|
+
confirmedBy?: string;
|
|
1677
|
+
comment?: string;
|
|
1678
|
+
}
|
|
1679
|
+
/**
|
|
1680
|
+
* 回滚规则
|
|
1681
|
+
* 定义从哪些阶段可以回滚到哪些阶段
|
|
1682
|
+
*
|
|
1683
|
+
* 复杂流程: explore → new → continue → apply → archive
|
|
1684
|
+
* 简单流程: propose → apply → archive
|
|
1685
|
+
*/
|
|
1686
|
+
declare const ROLLBACK_RULES: Record<WorkflowStep, WorkflowStep[]>;
|
|
1687
|
+
/**
|
|
1688
|
+
* 回滚原因类型
|
|
1689
|
+
*/
|
|
1690
|
+
type RollbackReason = 'code-review-failed' | 'requirement-changed' | 'design-issue' | 'user-request';
|
|
1691
|
+
/**
|
|
1692
|
+
* 回滚请求
|
|
1693
|
+
*/
|
|
1694
|
+
interface RollbackRequest {
|
|
1695
|
+
fromStep: WorkflowStep;
|
|
1696
|
+
toStep: WorkflowStep;
|
|
1697
|
+
reason: RollbackReason;
|
|
1698
|
+
description: string;
|
|
1699
|
+
timestamp: Date;
|
|
1700
|
+
}
|
|
1701
|
+
/**
|
|
1702
|
+
* 确认点管理器
|
|
1703
|
+
*/
|
|
1704
|
+
declare class ConfirmationManager {
|
|
1705
|
+
private confirmationPoints;
|
|
1706
|
+
private confirmations;
|
|
1707
|
+
constructor(customPoints?: ConfirmationPoint[]);
|
|
1708
|
+
/**
|
|
1709
|
+
* 获取指定阶段的确认点
|
|
1710
|
+
*/
|
|
1711
|
+
getConfirmationPointForTransition(from: WorkflowStep, to: WorkflowStep): ConfirmationPoint | undefined;
|
|
1712
|
+
/**
|
|
1713
|
+
* 检查是否需要确认
|
|
1714
|
+
*/
|
|
1715
|
+
needsConfirmation(from: WorkflowStep, to: WorkflowStep): boolean;
|
|
1716
|
+
/**
|
|
1717
|
+
* 获取确认点详情
|
|
1718
|
+
*/
|
|
1719
|
+
getConfirmationPoint(type: ConfirmationPointType): ConfirmationPoint | undefined;
|
|
1720
|
+
/**
|
|
1721
|
+
* 记录确认
|
|
1722
|
+
*/
|
|
1723
|
+
confirm(type: ConfirmationPointType, comment?: string): ConfirmationStatus;
|
|
1724
|
+
/**
|
|
1725
|
+
* 获取确认状态
|
|
1726
|
+
*/
|
|
1727
|
+
getConfirmationStatus(type: ConfirmationPointType): ConfirmationStatus | undefined;
|
|
1728
|
+
/**
|
|
1729
|
+
* 检查确认点是否已确认
|
|
1730
|
+
*/
|
|
1731
|
+
isConfirmed(type: ConfirmationPointType): boolean;
|
|
1732
|
+
/**
|
|
1733
|
+
* 清除确认状态(用于回滚后)
|
|
1734
|
+
*/
|
|
1735
|
+
clearConfirmation(type: ConfirmationPointType): void;
|
|
1736
|
+
/**
|
|
1737
|
+
* 清除所有确认状态
|
|
1738
|
+
*/
|
|
1739
|
+
clearAllConfirmations(): void;
|
|
1740
|
+
/**
|
|
1741
|
+
* 获取所有确认点
|
|
1742
|
+
*/
|
|
1743
|
+
getAllConfirmationPoints(): ConfirmationPoint[];
|
|
1744
|
+
/**
|
|
1745
|
+
* 获取指定阶段需要清除的确认点
|
|
1746
|
+
*/
|
|
1747
|
+
getConfirmationsToClear(targetStep: WorkflowStep): ConfirmationPointType[];
|
|
1748
|
+
}
|
|
1749
|
+
/**
|
|
1750
|
+
* 生成确认提示消息
|
|
1751
|
+
*/
|
|
1752
|
+
declare function generateConfirmationPrompt(point: ConfirmationPoint): string;
|
|
1753
|
+
/**
|
|
1754
|
+
* 生成回滚选项提示
|
|
1755
|
+
*/
|
|
1756
|
+
declare function generateRollbackPrompt(fromStep: WorkflowStep): string;
|
|
1757
|
+
|
|
1758
|
+
/**
|
|
1759
|
+
* OpenSpec 工作流引擎
|
|
1760
|
+
* 管理工作流状态、状态转换、确认点、回滚
|
|
1761
|
+
*/
|
|
1762
|
+
|
|
1763
|
+
interface WorkflowSnapshot {
|
|
1764
|
+
step: WorkflowStep;
|
|
1765
|
+
timestamp: Date;
|
|
1766
|
+
state: WorkflowState;
|
|
1767
|
+
artifacts: string[];
|
|
1768
|
+
}
|
|
1769
|
+
interface RollbackResult {
|
|
1770
|
+
success: boolean;
|
|
1771
|
+
from: WorkflowStep;
|
|
1772
|
+
to: WorkflowStep | null;
|
|
1773
|
+
message: string;
|
|
1774
|
+
snapshot?: WorkflowSnapshot;
|
|
1775
|
+
}
|
|
1776
|
+
interface ConfirmationResult {
|
|
1777
|
+
required: boolean;
|
|
1778
|
+
confirmed: boolean;
|
|
1779
|
+
point?: ConfirmationPoint;
|
|
1780
|
+
}
|
|
1781
|
+
declare class WorkflowEngine {
|
|
1782
|
+
private state;
|
|
1783
|
+
private projectPath;
|
|
1784
|
+
private openspecPath;
|
|
1785
|
+
private confirmationManager;
|
|
1786
|
+
private snapshots;
|
|
1787
|
+
private projectContext;
|
|
1788
|
+
private projectConfig;
|
|
1789
|
+
private devStandards;
|
|
1790
|
+
constructor();
|
|
1791
|
+
/**
|
|
1792
|
+
* 初始化工作流引擎
|
|
1793
|
+
*/
|
|
1794
|
+
initialize(projectPath: string): Promise<void>;
|
|
1795
|
+
/**
|
|
1796
|
+
* 加载项目上下文(AGENTS.md 和 config.yaml)
|
|
1797
|
+
*/
|
|
1798
|
+
private loadProjectContext;
|
|
1799
|
+
/**
|
|
1530
1800
|
* 获取项目上下文
|
|
1531
1801
|
*/
|
|
1532
1802
|
getProjectContext(): {
|
|
@@ -1640,284 +1910,6 @@ declare class ConfirmationRequiredError extends Error {
|
|
|
1640
1910
|
constructor(message: string, point: ConfirmationPoint);
|
|
1641
1911
|
}
|
|
1642
1912
|
|
|
1643
|
-
/**
|
|
1644
|
-
* 命令执行器
|
|
1645
|
-
* 执行解析后的命令
|
|
1646
|
-
*
|
|
1647
|
-
* 强制工作流机制:
|
|
1648
|
-
* - 没有活跃工作流时,只允许基础命令(/help, /init, /model, /new, /exit, /clear, /update, /version)
|
|
1649
|
-
* - 有活跃工作流时,根据当前阶段限制操作
|
|
1650
|
-
*/
|
|
1651
|
-
|
|
1652
|
-
interface ExecutorContext {
|
|
1653
|
-
contextManager: ContextManager;
|
|
1654
|
-
configManager: ConfigManager;
|
|
1655
|
-
modelService: ModelService;
|
|
1656
|
-
normsManager?: NormsManager;
|
|
1657
|
-
workflowEngine?: WorkflowEngine;
|
|
1658
|
-
state: REPLState;
|
|
1659
|
-
options: {
|
|
1660
|
-
workingDirectory: string;
|
|
1661
|
-
model?: string;
|
|
1662
|
-
yolo?: boolean;
|
|
1663
|
-
};
|
|
1664
|
-
}
|
|
1665
|
-
interface ExecutionResult {
|
|
1666
|
-
output?: string;
|
|
1667
|
-
exit?: boolean;
|
|
1668
|
-
contextUsed?: number;
|
|
1669
|
-
}
|
|
1670
|
-
declare class CommandExecutor {
|
|
1671
|
-
execute(parseResult: ParseResult, ctx: ExecutorContext): Promise<ExecutionResult>;
|
|
1672
|
-
/**
|
|
1673
|
-
* 检查工作流权限
|
|
1674
|
-
*/
|
|
1675
|
-
private checkWorkflowPermission;
|
|
1676
|
-
private executeSlashCommand;
|
|
1677
|
-
private executeFileReference;
|
|
1678
|
-
private executeAgent;
|
|
1679
|
-
private executeShell;
|
|
1680
|
-
private executeNaturalLanguage;
|
|
1681
|
-
private executeYolo;
|
|
1682
|
-
}
|
|
1683
|
-
|
|
1684
|
-
/**
|
|
1685
|
-
* Agent 运行器
|
|
1686
|
-
* 简化的 Agent 调度入口,提供统一的 Agent 执行接口
|
|
1687
|
-
*/
|
|
1688
|
-
|
|
1689
|
-
interface AgentResult {
|
|
1690
|
-
output: string;
|
|
1691
|
-
contextUsed: number;
|
|
1692
|
-
}
|
|
1693
|
-
/**
|
|
1694
|
-
* 运行 Agent(简化版)
|
|
1695
|
-
*/
|
|
1696
|
-
declare function runAgent(agentId: string, args: string[], ctx: ExecutorContext): Promise<AgentResult>;
|
|
1697
|
-
/**
|
|
1698
|
-
* 获取 Agent 定义
|
|
1699
|
-
*/
|
|
1700
|
-
declare function getAgent(agentId: AgentId): AgentDefinition | undefined;
|
|
1701
|
-
/**
|
|
1702
|
-
* 列出所有 Agent
|
|
1703
|
-
*/
|
|
1704
|
-
declare function listAgents(): AgentDefinition[];
|
|
1705
|
-
/**
|
|
1706
|
-
* 获取工作流阶段对应的 Agent
|
|
1707
|
-
*/
|
|
1708
|
-
declare function getAgentsForStep(step: string): AgentDefinition[];
|
|
1709
|
-
|
|
1710
|
-
/**
|
|
1711
|
-
* Agent 执行引擎
|
|
1712
|
-
* 负责调度和执行 Agent,包括 Prompt 构建、模型调用、工具执行
|
|
1713
|
-
*/
|
|
1714
|
-
|
|
1715
|
-
/**
|
|
1716
|
-
* Agent 执行器
|
|
1717
|
-
*/
|
|
1718
|
-
declare class AgentExecutor {
|
|
1719
|
-
private modelService;
|
|
1720
|
-
private normsManager;
|
|
1721
|
-
private contextManager;
|
|
1722
|
-
private sessions;
|
|
1723
|
-
private eventListeners;
|
|
1724
|
-
constructor(modelService: ModelService, normsManager: NormsManager, contextManager: ContextManager);
|
|
1725
|
-
/**
|
|
1726
|
-
* 执行 Agent
|
|
1727
|
-
*/
|
|
1728
|
-
execute(request: AgentScheduleRequest): Promise<AgentExecutionResult>;
|
|
1729
|
-
/**
|
|
1730
|
-
* 流式执行 Agent
|
|
1731
|
-
*/
|
|
1732
|
-
executeStream(request: AgentScheduleRequest): AsyncGenerator<string, AgentExecutionResult, unknown>;
|
|
1733
|
-
/**
|
|
1734
|
-
* 获取会话状态
|
|
1735
|
-
*/
|
|
1736
|
-
getSession(sessionId: string): AgentSession | undefined;
|
|
1737
|
-
/**
|
|
1738
|
-
* 取消执行
|
|
1739
|
-
*/
|
|
1740
|
-
cancel(sessionId: string): boolean;
|
|
1741
|
-
/**
|
|
1742
|
-
* 添加事件监听器
|
|
1743
|
-
*/
|
|
1744
|
-
addEventListener(listener: (event: AgentEvent) => void): void;
|
|
1745
|
-
/**
|
|
1746
|
-
* 移除事件监听器
|
|
1747
|
-
*/
|
|
1748
|
-
removeEventListener(listener: (event: AgentEvent) => void): void;
|
|
1749
|
-
/**
|
|
1750
|
-
* 创建会话
|
|
1751
|
-
*/
|
|
1752
|
-
private createSession;
|
|
1753
|
-
/**
|
|
1754
|
-
* 构建消息列表
|
|
1755
|
-
*/
|
|
1756
|
-
private buildMessages;
|
|
1757
|
-
/**
|
|
1758
|
-
* 摘要上下文(限制长度)
|
|
1759
|
-
*/
|
|
1760
|
-
private summarizeContext;
|
|
1761
|
-
/**
|
|
1762
|
-
* 提取关键规范(从 devstanded.md)
|
|
1763
|
-
*/
|
|
1764
|
-
private extractKeyStandards;
|
|
1765
|
-
/**
|
|
1766
|
-
* 构建任务提示
|
|
1767
|
-
*/
|
|
1768
|
-
private buildTaskPrompt;
|
|
1769
|
-
/**
|
|
1770
|
-
* 解析输出
|
|
1771
|
-
*/
|
|
1772
|
-
private parseOutput;
|
|
1773
|
-
/**
|
|
1774
|
-
* 发送事件
|
|
1775
|
-
*/
|
|
1776
|
-
private emitEvent;
|
|
1777
|
-
}
|
|
1778
|
-
/**
|
|
1779
|
-
* 创建默认的 Agent 执行器
|
|
1780
|
-
*/
|
|
1781
|
-
declare function createAgentExecutor(modelService: ModelService, normsManager: NormsManager, contextManager: ContextManager): AgentExecutor;
|
|
1782
|
-
|
|
1783
|
-
/**
|
|
1784
|
-
* 内置 Agent 定义
|
|
1785
|
-
* 包含每个 Agent 的角色、能力、工具权限和 Prompt 模板
|
|
1786
|
-
*/
|
|
1787
|
-
|
|
1788
|
-
/**
|
|
1789
|
-
* 前端开发 Agent
|
|
1790
|
-
* 负责代码实现、组件开发、样式编写
|
|
1791
|
-
*/
|
|
1792
|
-
declare const FRONTEND_DEV_AGENT: AgentDefinition;
|
|
1793
|
-
/**
|
|
1794
|
-
* 代码审核 Agent
|
|
1795
|
-
* 负责代码质量检查、安全审查、最佳实践建议、回归测试
|
|
1796
|
-
*/
|
|
1797
|
-
declare const CODE_REVIEWER_AGENT: AgentDefinition;
|
|
1798
|
-
/**
|
|
1799
|
-
* 架构师 Agent
|
|
1800
|
-
* 负责技术方案设计、架构决策、技术选型
|
|
1801
|
-
*/
|
|
1802
|
-
declare const ARCHITECT_AGENT: AgentDefinition;
|
|
1803
|
-
/**
|
|
1804
|
-
* 测试 Agent
|
|
1805
|
-
* 负责测试用例编写、测试执行、测试报告
|
|
1806
|
-
*/
|
|
1807
|
-
declare const TESTER_AGENT: AgentDefinition;
|
|
1808
|
-
/**
|
|
1809
|
-
* 所有内置 Agent 的映射表
|
|
1810
|
-
*/
|
|
1811
|
-
declare const BUILTIN_AGENTS: Record<AgentId, AgentDefinition>;
|
|
1812
|
-
/**
|
|
1813
|
-
* 获取 Agent 定义
|
|
1814
|
-
*/
|
|
1815
|
-
declare function getAgentDefinition(id: AgentId): AgentDefinition | undefined;
|
|
1816
|
-
/**
|
|
1817
|
-
* 获取所有内置 Agent
|
|
1818
|
-
*/
|
|
1819
|
-
declare function getAllAgents(): AgentDefinition[];
|
|
1820
|
-
/**
|
|
1821
|
-
* 根据工作流阶段获取应触发的 Agent
|
|
1822
|
-
*/
|
|
1823
|
-
declare function getAgentsForWorkflowStep(step: string): AgentDefinition[];
|
|
1824
|
-
|
|
1825
|
-
/**
|
|
1826
|
-
* Agent 自动调度器
|
|
1827
|
-
* 根据工作流阶段自动触发对应的 Agent 执行
|
|
1828
|
-
*/
|
|
1829
|
-
|
|
1830
|
-
/**
|
|
1831
|
-
* 调度策略
|
|
1832
|
-
*/
|
|
1833
|
-
type ScheduleStrategy = 'auto' | 'recommend' | 'manual';
|
|
1834
|
-
/**
|
|
1835
|
-
* 调度配置
|
|
1836
|
-
*/
|
|
1837
|
-
interface ScheduleConfig {
|
|
1838
|
-
agent: AgentId;
|
|
1839
|
-
strategy: ScheduleStrategy;
|
|
1840
|
-
waitForResult: boolean;
|
|
1841
|
-
requireConfirmation: boolean;
|
|
1842
|
-
fallbackAgent?: AgentId;
|
|
1843
|
-
}
|
|
1844
|
-
/**
|
|
1845
|
-
* 调度结果
|
|
1846
|
-
*/
|
|
1847
|
-
interface ScheduleResult {
|
|
1848
|
-
scheduled: boolean;
|
|
1849
|
-
agent?: AgentId;
|
|
1850
|
-
strategy: ScheduleStrategy;
|
|
1851
|
-
result?: AgentExecutionResult;
|
|
1852
|
-
message: string;
|
|
1853
|
-
}
|
|
1854
|
-
/**
|
|
1855
|
-
* 工作流阶段 → Agent 调度规则
|
|
1856
|
-
*
|
|
1857
|
-
* 设计原则:
|
|
1858
|
-
* - explore 阶段:架构师分析需求,输出技术方案
|
|
1859
|
-
* - new 阶段:前端开发实现核心代码
|
|
1860
|
-
* - continue 阶段:前端开发继续迭代
|
|
1861
|
-
* - apply 阶段:代码审核检查质量
|
|
1862
|
-
*/
|
|
1863
|
-
declare const SCHEDULE_RULES: Partial<Record<WorkflowStep, ScheduleConfig>>;
|
|
1864
|
-
/**
|
|
1865
|
-
* Agent 调度器
|
|
1866
|
-
*/
|
|
1867
|
-
declare class AgentScheduler {
|
|
1868
|
-
private executor;
|
|
1869
|
-
private lastScheduleResult;
|
|
1870
|
-
private onSchedule?;
|
|
1871
|
-
constructor(executor: AgentExecutor);
|
|
1872
|
-
/**
|
|
1873
|
-
* 设置调度回调
|
|
1874
|
-
*/
|
|
1875
|
-
setOnSchedule(callback: (result: ScheduleResult) => void): void;
|
|
1876
|
-
/**
|
|
1877
|
-
* 根据工作流阶段调度 Agent
|
|
1878
|
-
*/
|
|
1879
|
-
scheduleForStep(step: WorkflowStep, state: WorkflowState, options?: {
|
|
1880
|
-
strategy?: ScheduleStrategy;
|
|
1881
|
-
context?: Partial<AgentExecutionContext>;
|
|
1882
|
-
}): Promise<ScheduleResult>;
|
|
1883
|
-
/**
|
|
1884
|
-
* 执行 Agent
|
|
1885
|
-
*/
|
|
1886
|
-
private executeAgent;
|
|
1887
|
-
/**
|
|
1888
|
-
* 获取阶段的调度配置
|
|
1889
|
-
*/
|
|
1890
|
-
getScheduleConfig(step: WorkflowStep): ScheduleConfig | undefined;
|
|
1891
|
-
/**
|
|
1892
|
-
* 获取阶段的推荐 Agent
|
|
1893
|
-
*/
|
|
1894
|
-
getRecommendedAgent(step: WorkflowStep): AgentId | undefined;
|
|
1895
|
-
/**
|
|
1896
|
-
* 获取所有调度规则
|
|
1897
|
-
*/
|
|
1898
|
-
getAllScheduleRules(): Partial<Record<WorkflowStep, ScheduleConfig>>;
|
|
1899
|
-
/**
|
|
1900
|
-
* 获取上次调度结果
|
|
1901
|
-
*/
|
|
1902
|
-
getLastScheduleResult(): ScheduleResult | null;
|
|
1903
|
-
/**
|
|
1904
|
-
* 判断阶段是否需要自动调度
|
|
1905
|
-
*/
|
|
1906
|
-
shouldAutoSchedule(step: WorkflowStep): boolean;
|
|
1907
|
-
/**
|
|
1908
|
-
* 获取阶段可用的 Agent 列表
|
|
1909
|
-
*/
|
|
1910
|
-
getAvailableAgents(step: WorkflowStep): AgentId[];
|
|
1911
|
-
}
|
|
1912
|
-
/**
|
|
1913
|
-
* 创建调度器
|
|
1914
|
-
*/
|
|
1915
|
-
declare function createAgentScheduler(executor: AgentExecutor): AgentScheduler;
|
|
1916
|
-
/**
|
|
1917
|
-
* 获取调度规则描述
|
|
1918
|
-
*/
|
|
1919
|
-
declare function getScheduleRuleDescription(step: WorkflowStep): string;
|
|
1920
|
-
|
|
1921
1913
|
/**
|
|
1922
1914
|
* 自动补全器
|
|
1923
1915
|
* 提供命令、文件路径、历史记录的自动补全
|
|
@@ -1987,4 +1979,4 @@ declare class Completer {
|
|
|
1987
1979
|
getAgents(): CompletionItem[];
|
|
1988
1980
|
}
|
|
1989
1981
|
|
|
1990
|
-
export { ARCHITECT_AGENT, type AgentCapability, type AgentConstraints, type AgentDefinition, type AgentEvent, type AgentExecutionContext, type AgentExecutionResult, AgentExecutor, type AgentId, type AgentRegistry, type AgentResult, type AgentScheduleRequest, AgentScheduler, type AgentSession, type AgentStatus, type AgentTool, type AgentTrigger, type AgentTriggerType, BUILTIN_AGENTS, type CLIConfig, CODE_REVIEWER_AGENT, type ChangeRecord, type CodeGenOptions, CommandExecutor, CommandParser, CommandType, Completer, ConfigManager, ConfirmationManager, type ConfirmationPoint, type ConfirmationPointType, ConfirmationRequiredError, type ConfirmationStatus, ContextManager, type ContextMessage, type ContextState, type DesignAsset, type DesignBorder, type DesignColor, type DesignLayer, type DesignParseResult, type DesignShadow, type DesignSpacing, type DesignSpec, type DesignStyle, type DesignTypography, type DevStandard, FRONTEND_DEV_AGENT, FigmaMCPAdapter, type FileChange, type FileOperation, type HealthIssue, type HealthReport, type IMCPAdapter, LanhuMCPAdapter, MCPAdapterBase, type MCPClientConfig, type MCPConnectionState, type MCPConnectionStatus, MCPManager, type MCPManagerState, type MCPResource, type MCPResourceContent, type MCPServerConfig, type MCPToolCall, type MCPToolResult, type MCPToolSchema, type MCPTransportType, ModelService, NormsManager, type ProjectContext, ROLLBACK_RULES, type RollbackReason, type RollbackRequest, SCHEDULE_RULES, type ScheduleConfig, type ScheduleResult, type ScheduleStrategy, type StandardWeight, TESTER_AGENT, type Task, type TokenUsage, type ToolExecutor, type ToolPermissionLevel, WorkflowEngine, type WorkflowState, type WorkflowStatus, type WorkflowStep, type WorkflowStepRecord, type WorkflowTransition, type WorkflowType, createAgentExecutor, createAgentScheduler, createMCPManager, generateConfirmationPrompt, generateRollbackPrompt, getAgent, getAgentDefinition, getAgentsForStep, getAgentsForWorkflowStep, getAllAgents, getScheduleRuleDescription, listAgents, runAgent };
|
|
1982
|
+
export { ARCHITECT_AGENT, type AgentCapability, type AgentConstraints, type AgentDefinition, type AgentEvent, type AgentExecutionContext, type AgentExecutionResult, AgentExecutor, type AgentId, type AgentRegistry, type AgentResult, type AgentScheduleRequest, AgentScheduler, type AgentSession, type AgentStatus, type AgentTool, type AgentTrigger, type AgentTriggerType, BUILTIN_AGENTS, type CLIConfig, CODE_REVIEWER_AGENT, type ChangeRecord, type CodeGenOptions, CommandExecutor, CommandParser, CommandType, Completer, ConfigManager, ConfirmationManager, type ConfirmationPoint, type ConfirmationPointType, ConfirmationRequiredError, type ConfirmationStatus, ContextManager, type ContextMessage, type ContextState, type DesignAsset, type DesignBorder, type DesignColor, type DesignLayer, type DesignParseResult, type DesignShadow, type DesignSpacing, type DesignSpec, type DesignStyle, type DesignTypography, type DevStandard, FRONTEND_DEV_AGENT, FigmaMCPAdapter, type FileChange, type FileOperation, type HealthIssue, type HealthReport, type IMCPAdapter, LanhuMCPAdapter, MCPAdapterBase, type MCPClientConfig, type MCPConnectionState, type MCPConnectionStatus, MCPManager, type MCPManagerState, type MCPResource, type MCPResourceContent, type MCPServerConfig, type MCPToolCall, type MCPToolResult, type MCPToolSchema, type MCPTransportType, ModelService, NormsManager, type ProjectContext, ROLLBACK_RULES, type RollbackReason, type RollbackRequest, SCHEDULE_RULES, type ScheduleConfig, type ScheduleResult, type ScheduleStrategy, type StandardWeight, TESTER_AGENT, type Task, type TokenUsage, type ToolExecutor, type ToolPermissionLevel, WorkflowEngine, type WorkflowPhase, type WorkflowState, type WorkflowStatus, type WorkflowStep, type WorkflowStepRecord, type WorkflowTransition, type WorkflowType, createAgentExecutor, createAgentScheduler, createMCPManager, generateConfirmationPrompt, generateRollbackPrompt, getAgent, getAgentDefinition, getAgentsForStep, getAgentsForWorkflowStep, getAllAgents, getScheduleRuleDescription, listAgents, runAgent };
|