[codex] Add Cline-inspired workflow features#7
Merged
Conversation
There was a problem hiding this comment.
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
This PR adds a broad Cline-parity slice across the SharpClaw runtime and CLI.
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
Validation
dotnet build SharpClawCode.sln --no-restoredotnet 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