提交

提交图

61 次代码提交

作者 SHA1 备注 提交日期
tjb-tech 17d1fcad77 fix(test): increase teammate max_turns to 20 and timeout to 120s
Task 5 (concurrent teammates with skills) was failing because
import-finder hit max_turns=8 before writing results. Increased to
max_turns=20 and timeout=120s. Both teammates now pass (37s).
2026-04-04 09:38:28 +00:00
tjb-tech d6ed87d4b9 test: real agent loop tests for hooks, skills, and plugins
5 tasks where hooks/skills/plugins are ACTIVELY used by the model in
the agent loop (not passive logging or manual injection):

1. Hook blocks bash → model sees error, adapts to glob (8s) PASS
   - pre_tool_use hook returns exit 1 for bash, model switches tool
2. Model invokes skill tool → follows checklist instructions (16s) PASS
   - skill tool returns code-review checklist, model greps for TODO/FIXME
3. Plugin skill → security scan in agent loop (80s) PASS
   - Plugin-provided scan-secrets skill loaded via skill tool, 28 tool calls
4. Hook gates writes + skill guides refactoring (17s) PASS
   - Hook blocks config.py writes, skill provides refactoring steps
5. Swarm teammates each use skills (45s) 4/5 PARTIAL
   - class-counter invoked skill and wrote result, import-finder timed out
2026-04-04 08:11:47 +00:00
tjb-tech 860f4f610d test: real large multi-feature tasks on unfamiliar AutoAgent codebase
6 end-to-end tasks combining 3+ features each, all using real Kimi K2.5 API
on the AutoAgent project (an unfamiliar 17K LOC Python codebase):

1. Security audit: hooks (35 logged entries) + grep + web_fetch + permissions
   - 34 tool calls, found real eval/exec/shell injection issues (204s)
2. Coordinator code review: swarm (2 concurrent workers) + team + mailbox
   + agent definitions (verification agent) + task notifications (51s)
3. Migration plan: skills + memory (add/list) + session save/export
   + Plan agent prompt + 3-turn analysis (295s, 176KB markdown export)
4. Bug fix in worktree: git worktree create + file edit + bash test
   - Fix verified, original untouched, worktree cleaned up (17s)
5. Full pipeline: coordinator + 2 research workers + permission sync
   (request→resolve) + team lifecycle (27s)
6. Refactoring with session: 3-turn edit + session save/load + cost tracking
   - Helper function extracted, valid Python, 18 messages saved (46s)
2026-04-04 07:34:13 +00:00
tjb-tech eff7d60df3 test: comprehensive integration tests for all previously untested features
15 tests covering: hooks (command block, post_tool_use, agent loop integration),
skills (load from dir, registry), plugins (manifest loading), memory (add/list/
search/remove lifecycle), session storage (save/load/export), config (settings,
overrides, paths), commands (registry, lookup, 55 default commands), web_fetch
(real httpbin.org URL), worktree (real git create/list/remove), MCP (type
validation), and combined tests (hooks+skills+agent, full swarm+team on
AutoAgent project).

All tests use real Kimi K2.5 API where agent loops are needed.
2026-04-04 07:15:18 +00:00
tjb-tech 31c3bc6425 feat(compact): implement auto-compaction from reference source
Three-layer compaction system faithfully translated from reference:

1. Microcompact: clear old tool results (COMPACTABLE_TOOLS set) keeping
   recent N results. Cheap, no LLM call. Saved ~7500 tokens in testing.

2. Full compact: LLM-based summarization with structured 9-section prompt
   (analysis + summary tags). Formats and injects summary message.

3. Auto-compact: integrated into query loop, checks token threshold each
   turn. Fires microcompact first, falls back to full compact if needed.
   Circuit breaker after 3 consecutive failures.

Key constants from reference: AUTOCOMPACT_BUFFER_TOKENS=13K,
MAX_OUTPUT_TOKENS_FOR_SUMMARY=20K, keep_recent=5, 4/3 token padding.

Tested: 5 tasks on shared engine against AutoAgent project (60K tokens)
without hitting Kimi 4MB limit. Previously crashed at Task 4.
2026-04-04 07:03:58 +00:00
tjb-tech 0a4b232635 feat: production-style system prompt, max_turns=200, health_check + mailbox async fix
- Replace minimal system prompt with reference-faithful version covering:
  system guidance, task execution, action safety, tool usage, tone/style
- Change default max_turns from 8 to 200 for large task support
- Add health_check() to BackendRegistry (found during live testing)
- Fix mailbox.py async I/O (wrap blocking ops with run_in_executor)

All changes validated with real Kimi K2.5 API: 5 large tasks passed including
deep architecture analysis (27 tool calls), multi-turn debug+fix, cross-module
trace, code generation with ruff validation.
2026-04-04 06:30:50 +00:00
tjb-tech 84f1bdad52 fix(swarm): use ConversationMessage.from_user_text() in in-process runner
The _run_query_loop was passing a raw string to ConversationMessage(content=...)
which expects a list. Use the from_user_text() factory method instead.

Found during real E2E testing with Kimi K2.5 model.
2026-04-04 05:47:41 +00:00
tjb-tech 05acd0611e fix(swarm): deep-fix permission sync and team lifecycle from source
- Add _kill_orphaned_teammate_panes() to team_lifecycle, mirroring TS
  killOrphanedTeammatePanes: kills pane-backed teammate processes before
  directory removal on ungraceful shutdown (SIGINT/SIGTERM)
- Update cleanup_session_teams() to kill orphaned panes first, then clean
  directories — matches TS cleanupSessionTeams two-phase teardown

Both permission_sync.py and team_lifecycle.py now faithfully translate
all exported and internal functions from permissionSync.ts / teamHelpers.ts.
2026-04-03 10:10:57 +00:00
tjb-tech 2e7c72c8e6 fix(coordinator): deep-fix agent definitions with 20+ fields from source
- Add dontAsk to PERMISSION_MODES
- Add statusline-setup built-in agent (tools: Read/Edit, model: sonnet, color: orange)
- Add claude-code-guide built-in agent (tools: Glob/Grep/Read/WebFetch/WebSearch, model: haiku, permissionMode: dontAsk)
- Update verification agent system prompt to match latest TS source:
  - Add Mobile (iOS/Android) verification strategy
  - Add browser automation check rationalization
  - Add 'Test suite results are context, not evidence' paragraph
  - Add Bad example to output format section
  - More precise BEFORE ISSUING FAIL guidance
2026-04-03 10:07:30 +00:00
tjb-tech 1e55f36b2b fix(swarm): deep-fix permission sync, mailbox and team lifecycle from source
- permission_sync.py: expand SwarmPermissionRequest with all TS fields
  (worker_id, worker_name, worker_color, status, resolved_by, resolved_at,
  feedback, updated_input, permission_updates, created_at); add
  PermissionResolution, PermissionResponse dataclasses; add directory-based
  storage with pending/ and resolved/ subdirs; add generate_request_id(),
  generate_sandbox_request_id(), write_permission_request() with fcntl locking,
  read_pending_permissions(), read_resolved_permission(), resolve_permission(),
  cleanup_old_resolutions(), delete_resolved_permission(), poll_for_response(),
  remove_worker_response(), submit_permission_request alias, is_team_leader(),
  is_swarm_worker(), get_leader_name(), send_permission_request_via_mailbox(),
  send_permission_response_via_mailbox(),
  send_sandbox_permission_request_via_mailbox(),
  send_sandbox_permission_response_via_mailbox()

- mailbox.py: add sandbox_permission_request/response to MessageType; add
  create_permission_request_message(), create_permission_response_message(),
  create_sandbox_permission_request_message(),
  create_sandbox_permission_response_message(); add is_permission_request(),
  is_permission_response(), is_sandbox_permission_request(),
  is_sandbox_permission_response(); add global write_to_mailbox() helper

- team_lifecycle.py: add sanitize_name(), sanitize_agent_name(); expand
  TeamMember with agent_type, model, prompt, color, plan_mode_required,
  session_id, subscriptions, is_active, mode, tmux_pane_id, cwd; add
  AllowedPath dataclass; expand TeamFile with lead_agent_id, lead_session_id,
  hidden_pane_ids, team_allowed_paths; add read_team_file(), read_team_file_async(),
  write_team_file(), write_team_file_async(), remove_teammate_from_team_file(),
  add_hidden_pane_id(), remove_hidden_pane_id(), remove_member_from_team(),
  remove_member_by_agent_id(), set_member_mode(), sync_teammate_mode(),
  set_multiple_member_modes(), set_member_active(), register_team_for_session_cleanup(),
  unregister_team_for_session_cleanup(), cleanup_session_teams(),
  cleanup_team_directories(), destroy_worktree()

All 121 swarm tests pass; ruff clean.
2026-04-03 10:06:57 +00:00
tjb-tech 1323072735 fix(coordinator): deep-fix coordinator prompt and agent definitions from source
Expand get_coordinator_system_prompt() to match the full TypeScript source
(coordinatorMode.ts ~237 lines):
- Section 2: add subscribe_pr_activity tool mention and inline task-notification
  example showing the full coordinator-turn / user-notification flow
- Section 4 Stopping Workers: add code block with stop+continue pattern
- Section 5: add "Add a purpose statement" guidance, "Choose continue vs. spawn
  by context overlap" table, "Continue mechanics" with code examples, and
  complete good/bad prompt examples with git operation specifics
- Section 6 (new): Example Session with realistic XML task-notification flow

Expand AgentDefinition (Pydantic model) from 7 fields to 25+ to match
TypeScript BaseAgentDefinition:
- disallowed_tools, skills, mcp_servers, required_mcp_servers, hooks
- color (validated against AGENT_COLORS frozenset)
- effort (str "low"/"medium"/"high" or positive int)
- permission_mode (PERMISSION_MODES tuple)
- max_turns (positive int turn limit)
- background, initial_prompt, memory (MEMORY_SCOPES), isolation (ISOLATION_MODES)
- filename, base_dir, critical_system_reminder, pending_snapshot_update, omit_claude_md

Update built-in agents to match TS builtInAgents.ts:
- general-purpose: tools=['*'], enriched system prompt
- Explore: disallowed_tools, model='haiku', omit_claude_md=True
- Plan: disallowed_tools, model='inherit', omit_claude_md=True
- verification (renamed from verifier): color='red', background=True,
  model='inherit', disallowed_tools, critical_system_reminder, full
  verification system prompt with adversarial probes and output format
- worker: implementation-focused prompt

Update _parse_agent_frontmatter() to use yaml.safe_load (supports nested
structures for hooks, mcpServers), with simple key:value fallback.

Update load_agents_dir() to parse all new frontmatter fields with validation
(camelCase and snake_case aliases, type coercion, debug logging for invalids).

Add has_required_mcp_servers() and filter_agents_by_mcp_requirements() helpers
matching TS equivalents.

Add AGENT_COLORS, EFFORT_LEVELS, PERMISSION_MODES, MEMORY_SCOPES, ISOLATION_MODES
module-level constants.
2026-04-03 10:03:26 +00:00
tjb-tech f244c37c63 fix(coordinator+mailbox): deep-fix system prompt and permission message factories from source
- Expand coordinator system prompt with full TS-faithful guidance: example session,
  verification strategies, prompt synthesis rules, continuation mechanics, good/bad
  prompt examples, concurrency guidance
- Add 8 permission message factory functions to mailbox: create/check permission
  request/response + sandbox variants
- Add write_to_mailbox convenience wrapper
2026-04-03 10:02:53 +00:00
tjb-tech 67ef849b5b fix(swarm): deep-fix backends, in-process, registry and spawn utils from source
- types.py: Add PaneId, PaneBackend protocol, CreatePaneResult, BackendDetectionResult,
  TeammateSpawnConfig new fields (system_prompt_mode, worktree_path, session_id,
  subscriptions, color_override), is_pane_backend() guard helper
- registry.py: Detection priority pipeline (in_process → tmux → subprocess), _detect_tmux(),
  _detect_iterm2(), _is_it2_cli_available(), platform-specific install messages,
  detect_pane_backend(), mark_in_process_fallback(), get_preferred_backend() with config
  and env override, caching with invalidation, logging at each step
- in_process.py: TeammateAbortController with cancel_event/force_cancel/is_cancelled/
  request_cancel(); TeammateContext enhanced with message_queue, status, started_at,
  tool_use_count, total_tokens; _drain_mailbox() helper; _run_query_loop() tracks
  tool_use_count/total_tokens, injects queued user messages as new turns;
  InProcessBackend._cleanup_teammate(), _on_teammate_error(), get_teammate_status(),
  list_teammates(); shutdown chain uses abort_controller
- spawn_utils.py: Shell-quote all flag values with shlex.quote (security fix);
  --settings, --plugin-dir, --teammate-mode propagation; get_teammate_command()
  with installed entry-point detection; doc comments explaining why each env var is forwarded
2026-04-03 09:58:14 +00:00
tjb-tech c366cdc714 test: add comprehensive unit tests for swarm and coordinator components
Adds 156 tests across 9 new test files covering:
- coordinator_mode: TaskNotification XML, is_coordinator_mode, WorkerConfig
- agent_definitions: AgentDefinition model, built-ins, load_agents_dir
- swarm/types: TeammateIdentity, SpawnResult, TeammateExecutor protocol
- swarm/registry: BackendRegistry register/detect/get_executor
- swarm/mailbox: TeammateMailbox write/read/mark_read/clear + factories
- swarm/in_process: InProcessBackend spawn/shutdown/send_message, contextvars
- swarm/permission_sync: create/send/poll/handle permission flow
- swarm/team_lifecycle: TeamLifecycleManager CRUD with tmp_path fixtures
- swarm/worktree: validate_worktree_slug edge cases, flatten/branch helpers
2026-04-03 09:28:24 +00:00
tjb-tech fe0f2e87e4 feat(tools): upgrade agent_tool and send_message_tool to use swarm backend
- agent_tool: uses BackendRegistry (in_process preferred, subprocess fallback),
  looks up AgentDefinition by subagent_type, applies system_prompt/permissions,
  returns agent_id and task_id in output
- send_message_tool: routes messages via swarm backend when task_id contains '@'
  (swarm agent_id format); falls back to task manager for legacy task IDs
- both tools preserve existing input/output schema compatibility
2026-04-03 09:16:35 +00:00
tjb-tech 5733a472a8 feat(swarm): implement WorktreeManager with slug validation and git worktree isolation
- validate_worktree_slug(): sanitize/validate slugs (64 char max, path-traversal safe)
- WorktreeInfo dataclass: slug, path, branch, original_path, created_at, agent_id
- WorktreeManager: create/remove/list worktrees, symlink common dirs, cleanup_stale()
- Compatible with existing EnterWorktreeTool and ExitWorktreeTool APIs
2026-04-03 09:14:49 +00:00
tjb-tech 15fb4ffc3a feat(swarm): implement permission sync protocol for leader-worker bridging
Add src/openharness/swarm/permission_sync.py with:
- SwarmPermissionRequest / SwarmPermissionResponse dataclasses
- create_permission_request() factory (uuid-based IDs)
- send_permission_request() – writes permission_request to leader mailbox
- poll_permission_response() – polls worker mailbox with configurable timeout
- handle_permission_request() – evaluates via PermissionChecker, auto-approves read-only tools
- send_permission_response() – routes resolved response back to worker mailbox

Update swarm/__init__.py to export all new public symbols.
2026-04-03 09:14:24 +00:00
tjb-tech 05a1cff51f feat(swarm): implement TeamLifecycleManager with persistent team file management
Phase 2.3 - adds TeamMember, TeamFile, and TeamLifecycleManager.
Teams are persisted to ~/.openharness/teams/<name>/team.json using
the same directory layout as the mailbox system.
2026-04-03 09:04:55 +00:00
tjb-tech ad99247c44 feat(swarm): implement InProcessBackend with contextvars isolation
Add src/openharness/swarm/in_process.py:
- TeammateContext dataclass + ContextVar for per-teammate isolation
- get_teammate_context / set_teammate_context accessors
- start_in_process_teammate() coroutine: sets context, drives query
  engine, polls mailbox for shutdown messages, notifies leader on exit
- InProcessBackend implementing TeammateExecutor: spawn() creates asyncio
  Tasks with copied context; send_message() writes to file mailbox;
  shutdown() sets cancel_event then awaits task with timeout/force-cancel

Register InProcessBackend in BackendRegistry._register_defaults() so
get_executor("in_process") works out of the box.
2026-04-03 09:04:51 +00:00
tjb-tech ef561cd1b2 feat(coordinator): implement full agent definition loading system
Replace the 23-LOC stub with a complete AgentDefinition Pydantic model,
5 built-in agents (general-purpose, Explore, Plan, worker, verifier),
YAML-frontmatter loader for user-defined .md agent files, and public
API functions get_all_agent_definitions() / get_agent_definition().
2026-04-03 09:04:38 +00:00
tjb-tech 96403f29e8 feat(swarm): add mailbox communication system for leader-worker messaging 2026-04-03 08:58:21 +00:00
tjb-tech cf5b47660a feat(swarm): add Phase 1.2 swarm backend abstraction layer
- types.py: BackendType, TeammateIdentity, TeammateSpawnConfig, SpawnResult,
  TeammateMessage, and TeammateExecutor Protocol
- spawn_utils.py: get_teammate_command(), build_inherited_cli_flags(),
  build_inherited_env_vars(), is_tmux_available(), is_inside_tmux()
- subprocess_backend.py: SubprocessBackend implementing TeammateExecutor via
  the existing BackgroundTaskManager
- registry.py: BackendRegistry with detect_backend(), get_executor(),
  register_backend(), and get_backend_registry() singleton
2026-04-03 08:52:55 +00:00
tjb-tech 0e88cfd3d2 feat(coordinator): implement full CoordinatorMode orchestration system
Add CoordinatorMode, TaskNotification, WorkerConfig dataclasses and
XML serialization helpers alongside the existing TeamRegistry.
2026-04-03 08:52:23 +00:00
tjb-tech 9db75cd1a8 ci: install without frozen lockfile 2026-04-03 05:49:59 +00:00
tjb-tech b9f1151ee6 docs: add repo docs and CI scaffolding 2026-04-03 04:58:40 +00:00
chaohuang-ai 2bfc389db8 Update README.md 2026-04-03 10:57:57 +08:00
chaohuang-ai 5b031003da Update README.md 2026-04-03 10:56:02 +08:00
chaohuang-ai 15bdac5c66 Update README.md 2026-04-03 10:53:11 +08:00
chaohuang-ai 5849f8a7ec Update README.md 2026-04-03 10:52:19 +08:00
chaohuang-ai 81b635994b Update README.md 2026-04-03 10:51:01 +08:00
chaohuang-ai dff40d764b Update README.md 2026-04-03 00:50:14 +08:00
chaohuang-ai 34ef32870a Update README.md 2026-04-03 00:49:33 +08:00
tjb-tech 6894bf5725 Add Key Harness Features section with 5 categories
Agent Loop, Harness Toolkit, Context & Memory, Governance, Swarm Coordination.
Each with icon, badge, and feature bullets. ClawTeam linked as swarm roadmap.
2026-04-02 16:10:54 +00:00
tjb-tech 369731ceab Revert "Add Harness Categories roadmap with infographic"
This reverts commit 2fcca37a5c.
2026-04-02 15:30:57 +00:00
tjb-tech 2fcca37a5c Add Harness Categories roadmap with infographic
6 harness types: Coding (shipped), Research, Finance, Swarm (in progress),
Lifecycle (shipped), Domain. Includes generated infographic.
2026-04-02 15:29:21 +00:00
tjb-tech db23f80281 Fix Windows compatibility: resolve npm.cmd via shutil.which
On Windows, asyncio.create_subprocess_exec("npm") fails with
FileNotFoundError because the executable is npm.cmd. Use
shutil.which("npm") to resolve the correct path on all platforms.

Fixes #2
2026-04-02 05:49:00 +00:00
Jiabin Tang 4c2ae2d1aa Update in README.md 2026-04-02 11:00:30 +08:00
chaohuang-ai deffd5541c Update README.md 2026-04-02 02:07:25 +08:00
chaohuang-ai a331be8c52 Update README.md 2026-04-02 01:47:37 +08:00
chaohuang-ai f91b0ecc07 Update README.md 2026-04-02 01:32:31 +08:00
chaohuang-ai 54f524e308 Update README.md 2026-04-02 01:31:42 +08:00
chaohuang-ai 2e99cda520 Update README.md 2026-04-02 01:27:16 +08:00
chaohuang-ai d330f36699 Update README.md 2026-04-02 01:26:48 +08:00
chaohuang-ai 5b602333f5 Update README.md 2026-04-02 01:24:54 +08:00
chaohuang-ai fd95bb5beb Update README.md 2026-04-02 01:23:26 +08:00
chaohuang-ai 7a623b8c11 Update README.md 2026-04-02 01:21:27 +08:00
chaohuang-ai 7cff2440b5 Update README.md 2026-04-02 01:19:45 +08:00
chaohuang-ai 760eeaacbe Update README.md 2026-04-02 01:19:26 +08:00
chaohuang-ai d767123e3e Update README.md 2026-04-02 01:16:55 +08:00
chaohuang-ai 418da3997c Update README.md 2026-04-02 01:16:22 +08:00