Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Rebuild Multi-Agent Communication (Quick Dev Flow Demo)

## Requirement (2025-11-14T16:13:10.912Z)
- The Feature-Plan stage MUST support interrupt/abort when it detects conflicts with existing requirements.
- On interrupt, the sequential pipeline MUST short-circuit and emit a structured failure payload (e.g., { ok: false, code: 'CONFLICT', message, details }) or a controlled abort that the orchestrator maps to a failure, preventing downstream stages (feature-edit, YAML validator, report).

- Task ID: 20251114-2255-rebuild-multi-agent-comm-demo
- Goal: Rebuild/streamline multi-agent communication (DevHub ↔ LoopAgent/SequentialAgent) for a quick development flow demo.
- Notes:
- Focus on task-id centric collaboration across agents
- Keep CLI UX stable; prefer npx usage
- Prepare minimal demo path via DevHub + Blueprint + Coder/Review

## Additional Notes (2025-11-14T15:00:15.263Z)
- Atomic agent types: Prompt Agent and Programming Agent
- Prompt Agent is prompt-driven, focusing on a specific task type's working method
- Programming Agent can have multiple nodes; nodes are connected via program logic, and can be defined so each node can be emitted independently

## Design Target & Use Case (2025-11-14T15:08:00.563Z)
- Agent design is centered on artifacts + working method, not just raw prompts.
- Use Case: feature-updater agent
- Goal: After edits, ensure features.yaml remains well-structured.
- Validate: No duplicate or conflicting feature entries (避免重复/冲突).
- Problem with pure Prompt Agent: LLM can introduce subtle structural mistakes that propagate downstream.
- Decision: Use Programming Agent architecture (multi-node, logic-enforced) to guarantee deterministic validation & merge rules before committing updates.
- Rationale: Programming Agent nodes can emit structured events (parse, diff, validate, normalize) ensuring post-edit artifact integrity and reducing cascading errors in later workflow stages.

## Code Review By Features Agent (2025-11-14T15:40:26.943Z)
- Purpose: Verify whether new code changes (commit diffs) risk breaking previously implemented features.
- Context: When adding new features quickly, we validate the new one but often skip deep regression of old ones.
- Approach: Iterate existing features (from features.yaml or feature artifacts) and cross-check each feature's logic paths against changed code segments.
- Detection: Identify overlaps (cross points) where modified functions, modules, or data contracts intersect a feature's required invariants.
- Output: Structured report listing per-feature risk status, with:
- feature_id / name
- risk_level (none/low/medium/high)
- impacted elements (files, functions, lines)
- rationale (what change introduces the potential break)
- Architecture Choice: Programming Agent (multi-node) for deterministic traversal: nodes = [collect_diff, enumerate_features, map_dependencies, detect_cross, score_risk, generate_report].
- Benefit: Early surfacing of silent regressions without full test suite expansion.

## Planned Upgrade: Feature-Updater Sequential Agent (2025-11-14T15:59:12.767Z)
- Goal: Upgrade to feature-updater with a sequential architecture; rename feature-writer to feature-edit.
- Composition:
- Feature-Plan (Prompt Agent; new agent)
- Loop (LoopAgent; current: blueprint loop)
- Stage: feature-edit (Prompt Agent; renamed from feature-writer; supports add/delete/change) → YAML validator
- Feature-Changes Review (Prompt Agent) to check and produce a report
- Pipeline: feature-plan → loop(feature-edit → yaml validator) → feature-changes report.
- Rationale: Combine prompt-driven ideation with programmatic validation to reduce LLM-induced structural errors while producing a final human-readable risk/change report.

> 2025-11-14T16:00:41.950Z: Note — feature-edit is a Prompt Agent.

## Additional Agent Evolution (2025-11-14T16:21:31.043Z)
- Blueprint will become a Prompt Agent (was LoopAgent) focused on direct user dialogue and selectively invoking other agents when needed (not a full orchestrator/central workflow controller).
- Selection logic: interpret user intent → choose Feature-Updater, UI Review, Notes Agent, or others; skip calls when no added value.
- UI Review (ui-review) remains a Prompt Agent for UI/UX; legacy structure requires audit/refactor.
- Notes Agent (new Prompt Agent): writes fragments to notes-<timestamp>.md in task workspace; appends decisions, conflicts, risks chronologically.
- Example interaction path: user intent → blueprint (dialog) → conditional calls: (feature-updater loop) and/or (ui-review) → notes-agent summary.
- Abort policy: On conflict detected in feature-plan or validation failure, blueprint stops further calls and invokes notes-agent to persist the issue.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ coverage/

# Bundlers and frameworks
.parcel-cache/
.vite-cache/
.next/
.nuxt/
.svelte-kit/
Expand Down
125 changes: 125 additions & 0 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
"tsup": "^8.5.1",
"tsx": "^4.20.6",
"typescript": "^5.9.3",
"vite": "^6.0.1",
"vite-tsconfig-paths": "^5.1.2",
"vitest": "^4.0.6"
},
"keywords": [],
Expand All @@ -45,7 +47,7 @@
"scripts": {
"start": "tsx packages/cli/main.tsx --",
"build": "tsup --config tsup.config.ts && node scripts/copy-assets.js",
"prepublishOnly": "yarn build",
"prepack": "yarn build",
"start:test": "concurrently --raw --kill-others --success first \"yarn start\" \"sleep 10\"",
"test:story": "yarn start -- --blueprint -p \"Say [Hi]. Don't say anything else.\" --auto-allow --auto-exit",
"test:glossary": "yarn start -- --glossary -p \"Say [Hi]. Don't say anything else.\" --auto-allow --auto-exit",
Expand All @@ -57,7 +59,7 @@
"test:devhub:add_pending": "concurrently --raw --kill-others --success first \"yarn start -- --workspace $(mktemp -d)/taskagent-tmp --newsession --devhub --auto-allow --auto-exit -p 'Hello, please use send_to_looper tool with command add_pending and task Refactor logging system'\" \"sleep 20\"",
"test:devhub:stop": "concurrently --raw --kill-others --success first \"yarn start -- --workspace $(mktemp -d)/taskagent-tmp --newsession --devhub --auto-allow --auto-exit -p 'Hello, please use send_to_looper tool with command stop'\" \"sleep 20\"",
"test:watch": "vitest watch",
"publish": "echo \"Use yarn npm publish --access public\"",
"publish": "yarn npm publish --access public",
"test:pack": "node scripts/test-pack.js"
},
"_note_postbuild": "Yarn 4 hardened mode skips postbuild hooks, so asset copy runs inline in the build script.",
Expand Down
4 changes: 2 additions & 2 deletions packages/agents/blueprint/BlueprintLoop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import yaml from 'js-yaml';
import { LoopAgent } from '../workflow-agents/LoopAgent.js';
import type { RunnableAgent, AgentStartContext, AgentStartSinks, AgentToolContext } from '../runtime/types.js';
import type { AgentRegistry } from '../registry/AgentRegistry.js';
import type { EventBus } from '@taskagent/core/event-bus';
import { addLog } from '@taskagent/shared/logger';
import type { EventBus } from '@core/event-bus';
import { addLog } from '@shared/logger';
import { runAgent, emitProgress } from '../runtime/async-task/helpers.js';
import type { AsyncTaskContext } from '../runtime/async-task/types.js';

Expand Down
3 changes: 2 additions & 1 deletion packages/agents/blueprint/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { RunnableAgent } from '../runtime/types.js';
import type { EventBus } from '@taskagent/core/event-bus';

import type { EventBus } from '@core/event-bus';
import { BlueprintLoop } from './BlueprintLoop.js';

export async function createAgent(options?: {
Expand Down
2 changes: 1 addition & 1 deletion packages/agents/coder/CoderAgent.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { PromptAgent, type AgentContext, type AgentToolContext, type RunnableAgent, type AgentStartContext, type AgentStartSinks, type ExecutionHandle } from '../runtime/types.js';
import { buildPromptAgentStart } from '../runtime/runPromptAgentStart.js';
import type { AgentRegistry } from '../registry/AgentRegistry.js';
import type { EventBus } from '@taskagent/core/event-bus';
import type { EventBus } from '@core/event-bus';
import type { AgentDefinition } from '@anthropic-ai/claude-agent-sdk';

const CODER_AGENT_ID = 'coder';
Expand Down
2 changes: 1 addition & 1 deletion packages/agents/coder/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { fileURLToPath } from 'url';
import { loadAgentPipelineConfig } from '../runtime/agentLoader.js';
import type { RunnableAgent } from '../runtime/types.js';
import type { TabExecutor } from '../../execution/TabExecutor.js';
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This relative import should be updated to use the new path alias @execution/TabExecutor.js instead of ../../execution/TabExecutor.js to be consistent with the rest of the PR's refactoring.

Suggested change
import type { TabExecutor } from '../../execution/TabExecutor.js';
import type { TabExecutor } from '@execution/TabExecutor.js';

Copilot uses AI. Check for mistakes.
import type { EventBus } from '@taskagent/core/event-bus';
import type { EventBus } from '@core/event-bus';
import type { AgentRegistry } from '../registry/AgentRegistry.js';
import { CoderAgent } from './CoderAgent.js';

Expand Down
4 changes: 2 additions & 2 deletions packages/agents/desktop/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import { buildPromptAgentStart } from '../runtime/runPromptAgentStart.js';
import { loadAgentPipelineConfig } from '../runtime/agentLoader.js';
import type { tool as createSdkTool } from '@anthropic-ai/claude-agent-sdk';
import type { AgentContext, AgentStartContext, AgentStartSinks, ExecutionHandle, RunnableAgent } from '../runtime/types.js';
import type { EventBus } from '@taskagent/core/event-bus';
import { addLog } from '@taskagent/shared/logger';
import type { EventBus } from '@core/event-bus';
import { addLog } from '@shared/logger';
import type { AgentRegistry } from '../registry/AgentRegistry.js';

const START_AGENT_ID = 'start';
Expand Down
6 changes: 3 additions & 3 deletions packages/agents/devhub/DevHub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import { PromptAgent, type AgentContext, type AgentToolContext, type RunnableAge
import { buildPromptAgentStart } from '../runtime/runPromptAgentStart.js';
import { loadAgentPipelineConfig } from '../runtime/agentLoader.js';
import type { AgentDefinition } from '@anthropic-ai/claude-agent-sdk';
import type { EventBus } from '@taskagent/core/event-bus';
import type { TaskManager } from '@taskagent/shared/task-manager';
import type { EventBus } from '@core/event-bus';
import type { TaskManager } from '@shared/task-manager';
import type { AgentRegistry } from '../registry/AgentRegistry.js';
import { CodingLoop } from './coding-loop/index.js';
import type { LooperCommand } from './coding-loop/command.js';
import { addLog } from '@taskagent/shared/logger';
import { addLog } from '@shared/logger';

const DEV_HUB_AGENT_ID = 'devhub';
const DEV_HUB_DESCRIPTION = 'DevHub Agent - 理解开发需求,协调 Coder 与 Reviewer 循环开发直到代码通过审查';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import type { AgentCallback } from '../../workflow-agents/AgentCallback.js';
import type { RunnableAgent } from '../../runtime/types.js';
import { EventCollector } from './event-collector.js';
import { addLog } from '@taskagent/shared/logger';
import { addLog } from '@shared/logger';

export class SummarizationCallback implements AgentCallback {
private eventCollector = new EventCollector();
Expand Down
2 changes: 1 addition & 1 deletion packages/agents/devhub/coding-loop/event-collector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* - Determine when to trigger summary (time-based or count-based)
*/

import { addLog } from '@taskagent/shared/logger';
import { addLog } from '@shared/logger';

export interface TruncatedEvent {
type: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/agents/devhub/coding-loop/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { createJudgeAgent, parseJudgeOutput } from '../judge/index.js';
import { createSummarizerAgent } from '../summarizer/index.js';
import { SummarizationCallback } from './SummarizationCallback.js';
import { SinglePass } from './SinglePass.js';
import { addLog } from '@taskagent/shared/logger';
import { addLog } from '@shared/logger';
import path from 'node:path';
import { fileURLToPath } from 'node:url';

Expand Down
2 changes: 1 addition & 1 deletion packages/agents/devhub/judge/JudgeAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { fileURLToPath } from 'url';
import { PromptAgent, type AgentContext, type AgentToolContext, type RunnableAgent, type AgentStartContext, type AgentStartSinks, type ExecutionHandle } from '../../runtime/types.js';
import { buildPromptAgentStart } from '../../runtime/runPromptAgentStart.js';
import { JudgeDecisionSchema, type JudgeDecision } from './schema.js';
import { addLog } from '@taskagent/shared/logger';
import { addLog } from '@shared/logger';
import fs from 'fs/promises';

const JUDGE_AGENT_ID = 'judge';
Expand Down
Loading