Skip to content

[Refactor] Extract system prompt & context management from Task.ts #25

Open

Description

@doctarock

Parent Issue

Part of #8 — Code Refactor on Monolith Files

Related upstream issues

Summary

Extract the system prompt construction, context condensing/truncation, and environment detail logic from src/core/task/Task.ts into a dedicated module.

Scope

Methods to extract:

  • condenseContext()
  • getSystemPrompt()
  • handleContextWindowExceededError()
  • buildCleanConversationHistory()
  • getEnabledMcpToolsCount()
  • getFilesReadByRooSafely()
  • getCurrentProfileId()

State owned: None directly — read-only access to other state

Estimated size: ~300–400 lines

Notes

This cluster integrates with MCP, prompt generation, and context management subsystems but owns no mutable state itself, making it a clean extraction target. Resolving this directly reduces the file size AI coding agents must load when working on Task.ts (see cline/cline#3095).

Constraints (from #8)

  • Preserve call signatures and return types
  • Avoid circular dependencies with MCP and prompt modules
  • Run type checks after extraction
  • One extraction per commit

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions