Skip to main content
Welcome. This site supports keyboard navigation and screen readers. Press ? at any time for keyboard shortcuts. Press [ to focus the sidebar, ] to focus the content. High-contrast themes are available via the toolbar.
serard@dev00:~/cv

The Agent Workflow

The agent turns the question into an observation contract, then produces two kinds of reusable code: a provider when functionality is absent, and a task script that answers the current request. It executes the task after the required providers are available and validated.

Copyable agent instructions

Use PowerShell 7.4+ Core.
Before a potentially long operation, read the shared OutputPumps index
and only the selected software sheet. Check the tool's documented
machine format and options that narrow the request.

Define the required domain fields, units, completion conditions and failure
semantics before implementing a parser. Reuse a verified contract when it
covers the operation and supported tool format.

Initialize the session with Setup-OutputPumps and an explicit configuration.
Inspect Get-OutputPump for the required identifiers and argument prefixes.
Reject missing routes before Pump-Me: an unknown native route can pass through.

If a route or required business field is missing, generate an independent
provider with New-OPumperModule. Implement, test, document and register it
before executing the request. Keep general functionality out of task scripts.
Test field meaning, incomplete analysis and native failures as well as shape.
Keep the provider, fixtures and documentation in version control for reuse.

Generate the .ps1 caller with New-OutputPumpScript -TaskScriptBlock
and pass external values with ArgumentList. Wrap every locally consumed
pump invocation in Invoke-OutputPumpStep. Compute intermediate values locally.
Emit the requested projection once; read only the caller's compact JSON.

Inspect Outcome, Data.Status, Data.Issues and Truncation before deciding.
Narrow incomplete or overlarge requests. Never retry automatically or
fall back to a noisy raw command. A preview omission does not by itself
invalidate a count certified by Data.Complete.

These instructions are an execution policy for the agent. They do not introduce an engine switch that rejects all unknown routes. The example explicitly checks its required registrations.

Discover, then fill the missing route

Start in this series directory with the library path configured. Setup and Optional DevPoSh gives the standalone activation.

Get-OutputPump -ProviderId git
Get-OutputPump -Id gitworktrees.list

The Git catalogue contains status, diff, changes and log. A missing gitworktrees.list result is the trigger to create the independent provider described in Building a Reusable Provider. Once its implementation and documentary validation pass, Setup-OutputPumps activates it from configuration.

The runnable example ships that completed provider alongside the article. Initialize-Examples.ps1 selects only GitWorktrees, Git, ripgrep and PowerShell, using a separate YAML configuration and inventory.

Generate and execute the request

Set $repo to an existing repository containing a src directory. Run this block in the initialized session. External values are passed through ArgumentList, rather than interpolated into executable text.

$caller = New-OutputPumpScript -MaxOutputBytes 2048 -ArgumentList @($repo) -TaskScriptBlock {
    param($repo)
    foreach ($required in @(
        @{Id='gitworktrees.list';Executable='git';Prefix='worktree list'},
        @{Id='git.status';Executable='git';Prefix='status'},
        @{Id='ripgrep.search';Executable='rg';Prefix=''}
    )) {
        $route = Get-OutputPump -Id $required.Id
        if ($route.Outcome -ne 'Success' -or $route.Truncation.Applied -or
            $route.Data.Items.Count -ne 1 -or
            $route.Data.Items[0].Executable -ne $required.Executable -or
            ($route.Data.Items[0].ArgumentPrefix -join ' ') -ne $required.Prefix) {
            throw "Missing route: $($required.Id)"
        }
    }
    $worktrees = Invoke-OutputPumpStep -Name worktrees -ScriptBlock {
        Pump-Me git -NativeArguments @('worktree','list') -WorkingDirectory $repo -MaxItems 1
    }
    $status = Invoke-OutputPumpStep -Name status -ScriptBlock {
        Pump-Me git -NativeArguments @('status') -WorkingDirectory $repo
    }
    $todos = Invoke-OutputPumpStep -Name todos -ScriptBlock {
        Pump-Me rg -NativeArguments @('TODO','src') -WorkingDirectory $repo -MaxItems 1
    }
    [pscustomobject]@{
        WorktreeCount = $worktrees.Data.WorktreeCount
        Branch = $status.Data.Branch
        TodoMatchingLines = $(if ($todos.Data.Complete) { $todos.Data.MatchLines } else { $null })
    }
}
if ($caller.Outcome -ne 'Success') { throw 'Task generation failed.' }
& $caller.Data.Items[0].ScriptPath

The generated .ps1 invokes Invoke-OutputPumpTask and emits compact JSON. Do not wrap this caller in another task aggregator. New-Walkthrough.ps1 supplies the same workflow as a reusable generator.

The fixture result contains WorktreeCount=2, Branch=main and TodoMatchingLines=3, with three recorded steps. The worktree and search previews contain only one record each, so aggregate truncation remains visible even though their complete counts are usable. See the executed result.

Reuse in the next request

A second request can ask only for the worktree count. The provider and its tests already exist.

$caller = & ./scripts/New-Walkthrough.ps1 -Repository $repo -Reuse
if ($caller.Outcome -ne 'Success') { throw 'Task generation failed.' }
& $caller.Data.Items[0].ScriptPath

The reuse result records one step. Reuse avoids generating and debugging the same CLI parser in every request; it does not eliminate command execution or output qualification.

To run the complete disposable walkthrough and verification, use ./scripts/Invoke-Examples.ps1 -LibraryRoot $library. It creates its own repositories and configuration, then removes the temporary fixtures.

Previous: The Core Requirement · Next: Setup and Optional DevPoSh

⬇ Download