Skip to content

[codex] Add Cline-inspired workflow features#7

Merged
Telli merged 2 commits intomainfrom
codex/cline-parity-workflows
Apr 22, 2026
Merged

[codex] Add Cline-inspired workflow features#7
Telli merged 2 commits intomainfrom
codex/cline-parity-workflows

Conversation

@Telli
Copy link
Copy Markdown
Contributor

@Telli Telli commented Apr 21, 2026

What changed

This PR adds a broad Cline-parity slice across the SharpClaw runtime and CLI.

  • added instruction rule ingestion from repository and user rule files into prompt context assembly
  • added bounded read-only subagent orchestration and child agent event plumbing
  • added headless CLI prompt invocation with stdin support and yolo mode routing
  • added deep planning workflow state with persisted plan summaries and planning-owned todos
  • added finer-grained approval settings, approval budget tracking, and REPL/CLI approval controls
  • added git worktree inspection and management commands plus worktree-aware git context

Why

SharpClaw already had much of the baseline agent surface, but several high-value workflow features from Cline were still missing or only partially modeled. This change makes those capabilities real in the runtime instead of leaving them as protocol or UX gaps.

Impact

  • repository and user instruction files now influence prompt context consistently
  • agents can delegate bounded read-only research to subagents
  • CLI usage is more usable in headless and piped environments
  • planning mode produces durable workflow state instead of plain prose only
  • approvals can be tuned by capability and budget instead of relying on coarse global modes
  • parallel work can be isolated with native git worktree flows

Validation

  • dotnet build SharpClawCode.sln --no-restore
  • dotnet test tests/SharpClaw.Code.UnitTests/SharpClaw.Code.UnitTests.csproj --no-restore --filter "FullyQualifiedName~ModeAndCliOptionsTests|FullyQualifiedName~PermissionPolicyEngineTests|FullyQualifiedName~MemorySkillsGitServiceTests|FullyQualifiedName~OperationalReportsJsonTests|FullyQualifiedName~ProtocolJsonContextTests|FullyQualifiedName~PromptReferenceResolverTests"
  • dotnet test tests/SharpClaw.Code.IntegrationTests/SharpClaw.Code.IntegrationTests.csproj --no-restore --filter "FullyQualifiedName~PromptInteractivityFlowTests|FullyQualifiedName~PlanModeWorkflowTests|FullyQualifiedName~PromptContextAssemblyTests|FullyQualifiedName~CliCommandSurfaceTests"
  • dotnet test SharpClawCode.sln --no-restore

@Telli Telli marked this pull request as ready for review April 21, 2026 21:53
Copilot AI review requested due to automatic review settings April 21, 2026 21:53
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR expands SharpClaw’s runtime + CLI workflow surface toward Cline parity by adding persisted instruction rules, deep planning mode with managed todos, bounded sub-agent delegation, approval settings/budget tracking, and git worktree operations.

Changes:

  • Add persistent instruction rule ingestion + prompt-context injection (workspace + user rule sources).
  • Add deep plan mode workflow (structured JSON parsing, session metadata persistence, planning-owned todo sync).
  • Add bounded auto-approval scopes/budget plumbing across CLI/REPL/runtime + introduce git worktree list/create/prune commands and worktree-aware git context.

Reviewed changes

Copilot reviewed 75 out of 75 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/SharpClaw.Code.UnitTests/Tools/ToolRegistryAndExecutionTests.cs Updates policy engine construction to include auto-approval budget tracker.
tests/SharpClaw.Code.UnitTests/Runtime/PromptReferenceResolverTests.cs Updates policy engine construction to include auto-approval budget tracker.
tests/SharpClaw.Code.UnitTests/Protocol/ProtocolJsonContextTests.cs Adds serialization coverage for plan-mode execution results.
tests/SharpClaw.Code.UnitTests/Permissions/PermissionPolicyEngineTests.cs Adds tests for auto-approve scope matching and budget exhaustion behavior.
tests/SharpClaw.Code.UnitTests/Operational/OperationalReportsJsonTests.cs Adds approval settings to runtime status report round-trip tests.
tests/SharpClaw.Code.UnitTests/MemorySkillsGit/MemorySkillsGitServiceTests.cs Adds worktree snapshot fields + tests list/create/prune worktree operations.
tests/SharpClaw.Code.UnitTests/Commands/PromptInvocationServiceTests.cs New unit tests for stdin/prompt token composition and headless execution errors.
tests/SharpClaw.Code.UnitTests/Commands/ModeAndCliOptionsTests.cs Adds yolo + auto-approve CLI parsing and REPL approvals slash command test.
tests/SharpClaw.Code.UnitTests/Agents/ToolCallDispatcherTests.cs Extends dispatcher tests to cover synthetic sub-agent tool calls.
tests/SharpClaw.Code.IntegrationTests/Smoke/CliCommandSurfaceTests.cs Extends CLI surface expectations for worktree + new global options.
tests/SharpClaw.Code.IntegrationTests/Runtime/SubAgentOrchestrationTests.cs New integration test validating sub-agent delegation and emitted child events.
tests/SharpClaw.Code.IntegrationTests/Runtime/PromptInteractivityFlowTests.cs Adds integration coverage for auto-approved outside-workspace prompt reads.
tests/SharpClaw.Code.IntegrationTests/Runtime/PromptContextAssemblyTests.cs Asserts instruction rules + worktree-aware git context are injected into prompts.
tests/SharpClaw.Code.IntegrationTests/Runtime/PlanModeWorkflowTests.cs New integration test validating plan-mode structured result + todo sync.
src/SharpClaw.Code.Tools/Models/ToolExecutionContext.cs Extends tool context with model/agent metadata + approval settings passthrough.
src/SharpClaw.Code.Tools/Execution/ToolExecutor.cs Forwards approval settings into permission evaluation context.
src/SharpClaw.Code.Runtime/Workflow/TodoService.cs Adds managed session-todo reconciliation API and implementation.
src/SharpClaw.Code.Runtime/Workflow/PlanWorkflowService.cs New plan-mode post-processing (parse JSON, sync todos, persist plan summary/next action).
src/SharpClaw.Code.Runtime/Workflow/ApprovalSettingsResolver.cs New resolver for effective approval settings (request vs session metadata).
src/SharpClaw.Code.Runtime/Turns/DefaultTurnRunner.cs Plumbs approval settings into agent/tool execution context.
src/SharpClaw.Code.Runtime/Prompts/PromptReferenceResolver.cs Forwards approval settings into outside-workspace prompt-read approval decisions.
src/SharpClaw.Code.Runtime/Orchestration/ConversationRuntime.cs Persists/merges approval settings; adds plan-mode materialization + result attachment.
src/SharpClaw.Code.Runtime/Diagnostics/OperationalDiagnosticsInput.cs Adds approval settings to diagnostics input model.
src/SharpClaw.Code.Runtime/Diagnostics/OperationalDiagnosticsCoordinator.cs Includes approval settings in runtime status report.
src/SharpClaw.Code.Runtime/Context/PromptContextAssembler.cs Loads instruction rules; injects deep-plan summary + plan/spec mode instructions.
src/SharpClaw.Code.Runtime/Context/InstructionRuleSnapshot.cs New snapshot model for persisted instruction documents.
src/SharpClaw.Code.Runtime/Context/InstructionRuleService.cs New rule discovery + normalization/truncation/budgeting for instruction docs.
src/SharpClaw.Code.Runtime/Composition/RuntimeServiceCollectionExtensions.cs Registers instruction rule + plan workflow services.
src/SharpClaw.Code.Runtime/Abstractions/ITodoService.cs Adds managed todo sync API surface.
src/SharpClaw.Code.Runtime/Abstractions/IRuntimeCommandService.cs Adds approval settings to runtime command context.
src/SharpClaw.Code.Runtime/Abstractions/IPlanWorkflowService.cs New plan workflow service abstraction.
src/SharpClaw.Code.Runtime/Abstractions/IInstructionRuleService.cs New instruction rule service abstraction.
src/SharpClaw.Code.Protocol/Serialization/ProtocolJsonContext.cs Adds source-gen serializers for approvals, sub-agent, plan, and managed todo models.
src/SharpClaw.Code.Protocol/Operational/RuntimeStatusReport.cs Adds approval settings to status report contract.
src/SharpClaw.Code.Protocol/Models/SubAgentModels.cs New protocol models for sub-agent batch requests/results.
src/SharpClaw.Code.Protocol/Models/SharpClawWorkflowMetadataKeys.cs Adds metadata keys for approvals + deep planning + managed todo map keys.
src/SharpClaw.Code.Protocol/Models/PlanModels.cs New protocol models for plan payload/result + managed todo sync.
src/SharpClaw.Code.Protocol/Models/ApprovalSettings.cs New approval settings model.
src/SharpClaw.Code.Protocol/Commands/TurnExecutionResult.cs Adds plan result field to turn execution contract.
src/SharpClaw.Code.Protocol/Commands/RunPromptRequest.cs Adds approval settings to prompt request contract.
src/SharpClaw.Code.Permissions/Services/PermissionPolicyEngine.cs Adds auto-approval flow with optional budget tracking.
src/SharpClaw.Code.Permissions/Services/AutoApprovalBudgetTracker.cs New process-local session/tenant budget tracker.
src/SharpClaw.Code.Permissions/PermissionsServiceCollectionExtensions.cs Registers auto-approval budget tracker in DI.
src/SharpClaw.Code.Permissions/Models/PermissionEvaluationContext.cs Adds approval settings to permission evaluation context.
src/SharpClaw.Code.Permissions/Abstractions/IAutoApprovalBudgetTracker.cs New abstraction for budget tracking.
src/SharpClaw.Code.Git/Services/GitWorkspaceService.cs Adds worktree awareness (list/create/prune + snapshot fields).
src/SharpClaw.Code.Git/Models/GitWorktreeModels.cs New worktree list/create/prune models.
src/SharpClaw.Code.Git/Models/GitWorkspaceSnapshot.cs Adds worktree metadata to git prompt rendering.
src/SharpClaw.Code.Git/Abstractions/IGitWorkspaceService.cs Extends git service interface with worktree operations.
src/SharpClaw.Code.Commands/Repl/ReplInteractionState.cs Adds REPL approval settings override state.
src/SharpClaw.Code.Commands/Repl/ReplHost.cs Supports optional initial prompt; plumbs approval override into prompt execution.
src/SharpClaw.Code.Commands/PromptInvocationService.cs New service for headless prompt execution + stdin composition.
src/SharpClaw.Code.Commands/Options/GlobalCliOptions.cs Adds --auto-approve, --auto-approve-budget, and --yolo options.
src/SharpClaw.Code.Commands/Options/ApprovalSettingsText.cs New parser/renderer for approval scope + budget CLI text.
src/SharpClaw.Code.Commands/Models/CommandExecutionContext.cs Adds approval settings to CLI execution context and runtime context conversion.
src/SharpClaw.Code.Commands/Handlers/WorktreeCommandHandler.cs New CLI + slash command surface for git worktree operations.
src/SharpClaw.Code.Commands/Handlers/ReplCommandHandler.cs Adjusts REPL invocation for new IReplHost signature.
src/SharpClaw.Code.Commands/Handlers/PromptCommandHandler.cs Routes prompt execution through PromptInvocationService; supports stdin.
src/SharpClaw.Code.Commands/Handlers/ApprovalsSlashCommandHandler.cs New REPL slash command to show/set/reset auto-approval overrides.
src/SharpClaw.Code.Commands/CliCommandFactory.cs Adds root-level optional prompt tokens; routes to headless vs REPL based on IO/yolo/json.
src/SharpClaw.Code.Commands/Abstractions/IReplHost.cs Extends REPL host to accept optional initial prompt.
src/SharpClaw.Code.Commands/Abstractions/ICliInvocationEnvironment.cs New abstraction for stdin/stdout redirection detection + stdin reading.
src/SharpClaw.Code.Cli/Terminal/ConsoleInvocationEnvironment.cs Implements ICliInvocationEnvironment using Console streams.
src/SharpClaw.Code.Cli/Composition/CliServiceCollectionExtensions.cs Registers invocation environment, prompt invocation service, worktree + approvals handlers.
src/SharpClaw.Code.Agents/Services/AgentFrameworkBridge.cs Adds synthetic sub-agent tool exposure; forwards model/agent metadata and approval settings into tools.
src/SharpClaw.Code.Agents/Models/SubAgentBatchExecutionResult.cs New model bundling sub-agent batch result + emitted runtime events.
src/SharpClaw.Code.Agents/Models/AgentRunContext.cs Adds approval settings to agent run context.
src/SharpClaw.Code.Agents/Internal/ToolCallDispatcher.cs Adds handling for synthetic use_subagents tool and returns child agent events.
src/SharpClaw.Code.Agents/Internal/SubAgentToolContract.cs New schema + constraints for use_subagents synthetic tool.
src/SharpClaw.Code.Agents/Internal/SubAgentOrchestrator.cs New orchestrator executing bounded read-only sub-agent runs and collecting events.
src/SharpClaw.Code.Agents/AgentsServiceCollectionExtensions.cs Registers sub-agent orchestrator in DI.
src/SharpClaw.Code.Agents/Abstractions/ISubAgentOrchestrator.cs New sub-agent orchestrator abstraction.
docs/runtime.md Documents new plan workflow behavior and managed todo sync.
docs/permissions.md Documents bounded auto-approval settings and budget behavior.
README.md Updates CLI examples/options and command list (adds worktree, auto-approve flags, plan behavior).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +158 to +162
var commonDirResult = await commonDirTask.ConfigureAwait(false);
var listResult = await listTask.ConfigureAwait(false);
if (listResult.ExitCode != 0)
{
throw new InvalidOperationException(BuildGitFailureMessage("Failed to list git worktrees.", listResult));
Comment on lines +379 to +383
if (commonDir.EndsWith($"{Path.DirectorySeparatorChar}.git", OperatingSystem.IsWindows() ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal))
{
return Path.GetDirectoryName(commonDir) ?? repositoryRoot;
}

Comment on lines +34 to +38
var scopes = settings.AutoApproveScopes
.Where(scope => scope != ApprovalScope.None)
.Distinct()
.OrderBy(static scope => scope)
.ToArray();
Comment on lines +173 to +177
var maxForDocument = Math.Min(MaxDocumentCharacters, remaining);
var isTruncated = normalized.Length > maxForDocument;
var trimmed = isTruncated
? normalized[..Math.Max(0, maxForDocument - 28)].TrimEnd() + Environment.NewLine + "[Instruction truncated]"
: normalized;
if (string.Equals(command.Arguments[0], "reset", StringComparison.OrdinalIgnoreCase)
|| string.Equals(command.Arguments[0], "clear", StringComparison.OrdinalIgnoreCase))
{
replState.ApprovalSettingsOverride = ApprovalSettings.Empty;
@Telli Telli merged commit 3544969 into main Apr 22, 2026
2 of 3 checks passed
@Telli Telli deleted the codex/cline-parity-workflows branch April 22, 2026 01:07
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.

2 participants