MCPcopy Create free account
hub / github.com/Gan-Xing/CodexBridge / buildDefaultCodeAgentPlan

Function buildDefaultCodeAgentPlan

src/core/bridge_coordinator.ts:13610–13663  ·  view source on GitHub ↗
(
  goal: string,
  expectedOutput: string,
  templateContext: AgentDraftTemplateContext,
  isZh: boolean,
)

Source from the content-addressed store, hash-verified

13608}
13609
13610function buildDefaultCodeAgentPlan(
13611 goal: string,
13612 expectedOutput: string,
13613 templateContext: AgentDraftTemplateContext,
13614 isZh: boolean,
13615): string[] {
13616 const mustRead = dedupeStrings((templateContext.mustRead ?? []).map((entry) => compactWhitespace(entry)).filter(Boolean)).slice(0, 3);
13617 const preflight = dedupeStrings((templateContext.preflight ?? []).map((entry) => compactWhitespace(entry)).filter(Boolean)).slice(0, 2);
13618 const boundaries = dedupeStrings((templateContext.executionBoundaries ?? []).map((entry) => compactWhitespace(entry)).filter(Boolean)).slice(0, 2);
13619 const allowedPaths = dedupeStrings((templateContext.allowedPaths ?? []).map((entry) => compactWhitespace(entry)).filter(Boolean)).slice(0, 3);
13620 const validationCommands = dedupeStrings((templateContext.validationCommands ?? []).map((entry) => compactWhitespace(entry)).filter(Boolean)).slice(0, 3);
13621 const plan: string[] = [];
13622 if (mustRead.length > 0) {
13623 plan.push(isZh
13624 ? `先阅读并对齐 ${mustRead.join('、')},锁定“${goal}”的最小改动范围`
13625 : `Read and align ${mustRead.join(', ')} to lock the smallest change surface for "${goal}"`);
13626 } else {
13627 plan.push(isZh
13628 ? `先阅读与“${goal}”直接相关的文档、代码和测试,锁定最小改动范围`
13629 : `Read the docs, code, and tests directly related to "${goal}" to lock the smallest change surface`);
13630 }
13631 if (allowedPaths.length > 0) {
13632 plan.push(isZh
13633 ? `只在 ${allowedPaths.join('、')} 范围内完成最小实现,并保持修改边界清晰`
13634 : `Complete the smallest implementation inside ${allowedPaths.join(', ')} and keep the change boundary clear`);
13635 } else {
13636 plan.push(isZh
13637 ? '在当前仓库里完成最小可验证实现,并避免扩散到无关模块'
13638 : 'Complete the smallest verifiable implementation in the current repo and avoid unrelated modules');
13639 }
13640 if (preflight.length > 0) {
13641 plan.push(isZh
13642 ? `先完成前置检查:${preflight.join(';')}`
13643 : `Complete the preflight checks first: ${preflight.join('; ')}`);
13644 }
13645 if (boundaries.length > 0) {
13646 plan.push(isZh
13647 ? `严格遵守执行边界:${boundaries.join(';')}`
13648 : `Respect the execution boundaries: ${boundaries.join('; ')}`);
13649 }
13650 if (validationCommands.length > 0) {
13651 plan.push(isZh
13652 ? `运行验证:${validationCommands.join(';')}`
13653 : `Run validation with: ${validationCommands.join('; ')}`);
13654 } else {
13655 plan.push(isZh
13656 ? `运行相关验证,确认“${expectedOutput}”可以被实际交付`
13657 : `Run relevant validation to confirm "${expectedOutput}" can be delivered`);
13658 }
13659 plan.push(isZh
13660 ? '更新相关 TODO / 文档并整理结果、风险和下一步'
13661 : 'Update the related TODO/docs and summarize the result, risks, and next step');
13662 return dedupeStrings(plan).slice(0, 6);
13663}
13664
13665function buildDefaultGenericAgentPlan(
13666 goal: string,

Callers 1

buildDefaultAgentPlanFunction · 0.85

Calls 2

dedupeStringsFunction · 0.70
compactWhitespaceFunction · 0.70

Tested by

no test coverage detected