Skip to content

feat: integrate 5 feature branches#256

Closed
amDosion wants to merge 1 commit intoclaude-code-best:mainfrom
amDosion:feat/integrate-5-branches
Closed

feat: integrate 5 feature branches#256
amDosion wants to merge 1 commit intoclaude-code-best:mainfrom
amDosion:feat/integrate-5-branches

Conversation

@amDosion
Copy link
Copy Markdown
Collaborator

@amDosion amDosion commented Apr 13, 2026

Summary

  • fix/mcp-tsc-errors — MCP 工具层 TypeScript 类型修复
  • feat/pipe-mute-disconnect — Pipe 静音断开功能
  • feat/stub-recovery-all — 25 个 stub 模块恢复 + 52 个新测试
  • feat/kairos-activation — KAIROS 助手面板激活
  • feat/openclaw-autonomy — OpenClaw 自主模式基线

Test plan

  • bunx tsc --noEmit 零错误
  • bun test 全部通过
  • 各功能模块手动验证

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • New Features

    • Assistant session discovery and selection interface
    • Background session management commands (ps, logs, kill, attach)
    • Template-based job creation and management system
    • Language preference setting (/lang command)
    • Daemon status and stop commands
    • Autonomy run tracking and flow management
  • Bug Fixes

    • Push notification delivery via bridge when available
    • User file sending functionality with local verification
  • Documentation

    • Design specifications for daemon control, background sessions, templates, and assistant attachment
    • Baseline test plan for autonomy features

…y, KAIROS activation, openclaw autonomy

Squashed merge of:
1. fix/mcp-tsc-errors — 修复上游 MCP 重构后的 tsc 错误和测试失败
2. feat/pipe-mute-disconnect — Pipe IPC 逻辑断开、/lang 命令、mute 状态机
3. feat/stub-recovery-all — 实现全部 stub 恢复 (task 001-012)
4. feat/kairos-activation — KAIROS 激活解除阻塞 + 工具实现
5. codex/openclaw-autonomy-pr — 自治权限系统、运行记录、managed flows

Conflicts resolved:
- src/commands/assistant/assistant.tsx (stub-recovery + kairos)
- src/services/api/openai/__tests__/queryModelOpenAI.test.ts (mcp-fix + autonomy)

Tested: bun test (2695 pass, 0 fail)
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 13, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

Implements persistent KAIROS assistant mode with autonomy run tracking and managed flow orchestration, background session management commands (ps/logs/kill/attach), template-based job creation, language selection, pipe communication control, and comprehensive supporting infrastructure including state persistence, daemon management, and baseline testing.

Changes

Cohort / File(s) Summary
Documentation & Planning
.gitignore, 02-kairos (1).md, docs/features/*, docs/task/*, docs/test-plans/*
Added comprehensive design documentation for KAIROS persistent assistant, recovery strategies, task specifications, test baselines, and updated ignore patterns.
Build & Configuration
build.ts, scripts/dev.ts, tsconfig.json
Enabled BG_SESSIONS and TEMPLATES feature flags in build and dev; added path aliases for new package modules.
Daemon & State Persistence
src/daemon/state.ts, src/daemon/main.ts
New daemon state file management (remote-control.json) with cross-process status querying, PID liveness checks, and supervisor lifecycle integration.
KAIROS Assistant Activation
src/assistant/index.ts, src/assistant/gate.ts, src/assistant/sessionDiscovery.ts, src/assistant/AssistantSessionChooser.tsx
Replaced stubs with real KAIROS state tracking, session discovery from session registry, interactive session chooser UI, and activation gating.
Assistant Command Implementation
src/commands/assistant/assistant.tsx, src/main.tsx
New wizard UI and install directory resolution for KAIROS daemon startup; updated CLI gating to support forced assistant mode.
Autonomy Authority & Prompt Generation
src/utils/autonomyAuthority.ts
New module for discovering and parsing .claude/autonomy directory structure (agents, heartbeat tasks), computing due scheduled tasks, and building autonomy turn prompts with injected authority context.
Autonomy Run Lifecycle
src/utils/autonomyRuns.ts
Comprehensive run persistence and orchestration: creating runs, tracking status transitions (queued/running/completed/failed), coordinating with managed flows, and supporting prompt recovery.
Autonomy Managed Flows
src/utils/autonomyFlows.ts
Complex state machine for multi-step flows with step execution, waiting states, step-level results, and cancellation; persisted under .claude/autonomy/flows.json.
Autonomy Persistence & Locking
src/utils/autonomyPersistence.ts
Lock-based concurrency control for atomic read-modify-write of autonomy state files with in-process chaining and filesystem-level locking.
Autonomy Integration in Execution
src/cli/print.ts, src/utils/handlePromptSubmit.ts, src/screens/REPL.tsx
Wired autonomy run lifecycle (marking running/completed/failed) into proactive tick execution, scheduled task handling, and incoming prompt processing.
Autonomy Commands
src/commands/autonomy.ts
New /autonomy command supporting status, runs, flows, flow resume, flow cancel with multi-subcommand dispatch.
Background Sessions (BG_SESSIONS)
src/cli/bg.ts
Full background session implementation: ps (enumerate sessions), logs (tail session logs), kill (terminate with signal), attach (tmux attach), --bg flag (spawn detached).
Template Jobs System
src/jobs/state.ts, src/jobs/templates.ts, src/jobs/classifier.ts, src/cli/handlers/templateJobs.ts
MVP for template-based jobs: directory discovery, template parsing (with frontmatter), job creation/state persistence, and CLI handlers for list/new/reply.
Language Support
src/utils/language.ts, src/services/awaySummary.ts, src/commands/lang/*
New language resolution (auto/en/zh) with system locale fallback; language selection command and locale-aware prompt generation.
Pipe Communication Control
src/utils/pipeMuteState.ts, src/utils/pipePermissionRelay.ts, src/utils/pipeTransport.ts, src/hooks/usePipeMuteSync.ts
Added master-side mute state tracking, permission relay muting, relay_mute/relay_unmute message types, and hook for synchronizing mute state across routing modes.
Permission & Message Relay Updates
src/hooks/useMasterMonitor.ts, src/hooks/usePipeRelay.ts, src/hooks/usePipeIpc.ts, src/hooks/usePipePermissionForward.ts
Integrated mute gating, send overrides, permission request auto-denial on mute, and IPC relay mute control messages.
Message/Command Infrastructure
src/types/textInputTypes.ts, src/tasks/InProcessTeammateTask/*
Extended QueuedCommand with optional autonomy field (runId, trigger, flow context); updated teammate message injection to carry autonomy run ID and message origin.
Teammate & Swarm Execution
src/utils/swarm/inProcessRunner.ts, src/utils/swarm/spawnInProcess.ts
Added autonomy run lifecycle tracking in teammate message handling; mark runs as running/completed/failed; abort cleanup on teammate kill.
CLI & Command Handlers
src/cli/handlers/ant.ts, src/cli/handlers/templateJobs.ts, src/cli/rollback.ts, src/cli/up.ts
Replaced stubs with full implementations for task/activity logs, template job CLI, rollback installation, and claude up script extraction/execution.
Command Registration
src/commands.ts, src/commands/send/send.ts, src/commands/torch.ts, src/commands/init.ts
Registered new autonomy and lang commands; added send override control; updated init prompt to reference autonomy agents path.
Test Suites
src/__tests__/context.baseline.test.ts, src/commands/__tests__/*, src/daemon/__tests__/*, src/jobs/__tests__/*, src/proactive/__tests__/*, src/utils/__tests__/*, src/services/api/openai/__tests__/*, src/services/langfuse/__tests__/*
Extensive baseline and functional testing for context injection, proactive/autonomy commands, daemon state, jobs/templates, autonomy authority/runs/flows, language resolution, pipe mute state, cron scheduling, task summary, and isolated OpenAI/Langfuse integration.
Utility Functions & Hooks
src/utils/taskSummary.ts, src/proactive/useProactive.ts, src/hooks/useScheduledTasks.ts, src/services/analytics/growthbook.ts
Implemented task summary generation for background sessions, refactored proactive tick to use autonomy commands, integrated autonomy prompts into scheduled task firing, and added local GrowthBook gate defaults.
Test Infrastructure
tests/mocks/file-system.ts
Minor style and functional improvements to temp file/directory utilities (ensured parent directory creation).

Sequence Diagram(s)

sequenceDiagram
    participant User as User / CLI
    participant REPL as REPL Screen
    participant ProactiveHook as Proactive Hook
    participant AutonomyAuth as Autonomy Authority
    participant AutonomyRuns as Autonomy Runs
    participant ManagedFlows as Managed Flows
    participant TaskExecution as Task Execution
    participant Teammate as In-Process Teammate

    User->>REPL: Activate proactive mode
    activate REPL
    REPL->>ProactiveHook: onQueueTick(command)
    activate ProactiveHook
    
    ProactiveHook->>AutonomyAuth: createProactiveAutonomyCommands()
    activate AutonomyAuth
    AutonomyAuth->>AutonomyAuth: loadAutonomyAuthority()
    AutonomyAuth->>AutonomyAuth: collectDueHeartbeatTasks()
    AutonomyAuth-->>ProactiveHook: [QueuedCommand, ...]
    deactivate AutonomyAuth
    
    ProactiveHook->>AutonomyRuns: createAutonomyQueuedPrompt()
    activate AutonomyRuns
    AutonomyRuns->>AutonomyRuns: createAutonomyRun(trigger: 'proactive-tick')
    Note over AutonomyRuns: Persist run with status: queued
    AutonomyRuns-->>ProactiveHook: QueuedCommand
    deactivate AutonomyRuns
    
    ProactiveHook->>REPL: enqueue(command)
    deactivate ProactiveHook
    deactivate REPL
    
    REPL->>REPL: handleIncomingPrompt(command)
    activate REPL
    
    REPL->>AutonomyRuns: markAutonomyRunRunning(runId)
    Note over AutonomyRuns: Update run status: running
    
    REPL->>TaskExecution: processUserInput(prompt)
    activate TaskExecution
    TaskExecution->>Teammate: injectUserMessageToTeammate()
    activate Teammate
    Note over Teammate: Enqueue with autonomyRunId
    Teammate-->>TaskExecution: true
    deactivate Teammate
    TaskExecution-->>REPL: result
    deactivate TaskExecution
    
    REPL->>AutonomyRuns: finalizeAutonomyRunCompleted(runId)
    activate AutonomyRuns
    alt Has Managed Parent Flow
        AutonomyRuns->>ManagedFlows: resumeManagedAutonomyFlow()
        activate ManagedFlows
        ManagedFlows-->>AutonomyRuns: nextStep
        deactivate ManagedFlows
        AutonomyRuns->>REPL: enqueue(nextCommand)
    end
    Note over AutonomyRuns: Update run status: completed
    deactivate AutonomyRuns
    deactivate REPL
Loading
sequenceDiagram
    participant CLI as CLI (bg.ts)
    participant SessionReg as Session Registry
    participant Filesystem as Filesystem
    participant Tmux as Tmux Session
    participant LogFile as Log File

    User->>CLI: claude bg ps
    activate CLI
    CLI->>SessionReg: Read sessions from config dir
    activate SessionReg
    SessionReg->>Filesystem: Read ~/.claude/sessions/
    SessionReg-->>CLI: [SessionEntry, ...]
    deactivate SessionReg
    CLI->>CLI: Filter by PID liveness
    CLI-->>User: Display session table
    deactivate CLI

    User->>CLI: claude bg logs [sessionId]
    activate CLI
    CLI->>SessionReg: resolveTargetSession(sessionId)
    SessionReg-->>CLI: SessionEntry with logPath
    CLI->>LogFile: Read log file
    LogFile-->>CLI: Log contents
    CLI-->>User: Print log
    deactivate CLI

    User->>CLI: claude bg attach [sessionId]
    activate CLI
    CLI->>SessionReg: resolveTargetSession(sessionId)
    SessionReg-->>CLI: SessionEntry with tmuxSessionName
    CLI->>Tmux: tmux attach-session -t <name>
    activate Tmux
    Note over Tmux: User interacts with session
    Tmux-->>User: (attached)
    deactivate Tmux
    deactivate CLI

    User->>CLI: claude --bg <command>
    activate CLI
    CLI->>Filesystem: Generate unique tmux session name
    CLI->>Filesystem: Compute log path
    CLI->>Tmux: tmux new-session -d -s <name> <command>
    activate Tmux
    Tmux-->>CLI: Session started
    deactivate Tmux
    CLI->>Filesystem: Write session metadata to config
    CLI-->>User: Print connection info
    deactivate CLI
Loading

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~120 minutes

Possibly related PRs

  • PR #242: Directly related through shared Langfuse integration modifications in src/services/langfuse/*, initialization/shutdown hooks, and test structure changes.
  • PR #243: Directly related through overlapping pipe/UDS/LAN communication infrastructure (src/utils/pipeTransport.ts, IPC messaging, relay permissions) and command registration updates.
  • PR #153: Related through shared GrowthBook gate changes (src/services/analytics/growthbook.ts), local gate defaults, and feature evaluation fallback logic.

Suggested labels

v6

Suggested reviewers

  • KonghaYao

Poem

🐰 With whiskers twitching, I spy a grand design,
Autonomous flows and sessions that align,
From heartbeat tasks to managed steps so fine,
Assistant daemons ready to shine!
The tunnels hum with muted pipes of thought,
A symphony of systems deftly wrought! 🌟

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

@amDosion amDosion closed this Apr 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant