Skip to content

scriptrun: Generic runner + shared protocol surface - #1188

Open
ed-irl wants to merge 1 commit into
ed-irl/scripts-protocol-guidefrom
ed-irl/scriptrun
Open

scriptrun: Generic runner + shared protocol surface#1188
ed-irl wants to merge 1 commit into
ed-irl/scripts-protocol-guidefrom
ed-irl/scriptrun

Conversation

@ed-irl

@ed-irl ed-irl commented May 22, 2026

Copy link
Copy Markdown
Collaborator

Adds the script-execution foundation and the cross-feature protocol
surface that the message generator and both auto-resolvers will use.

Runner (existing): executes a user-configured script either via
'sh -c' or by writing a shebang script to a temp file and exec'ing it.
stdout, stderr, and the exit code are returned without interpretation
so each feature can plug its own handler on top.

Shared protocol (new in this commit):

  • ResolveResponse: the JSON document scripts emit on stdout (the
    union of {title, body, assumptions, questions, unresolved_files}
    fields). ParseResponse with ErrEmptyOutput / InvalidOutputError
    for diagnostics.
  • QAPair: per-question persistent-resolution-file record.
  • Operation enum and EnvFor(operation, branch, base) returning the
    shared GS_OPERATION / GS_BRANCH / GS_BASE env that every script
    receives. Feature-specific env layers on top.

Per-repo scratch directory (new in this commit):

  • internal/spice/spicedir owns /.spice/.
  • Path / EnsureDir for the directory; ResolutionPath /
    EnsureResolutionsDir for per-feature resolution files at
    .spice/resolutions/.json. Does not modify .gitignore --
    that's a project policy decision left to the user.

Configurable iteration cap (new in this commit):

  • spice.scriptResolve.maxIterations (int, default 10) bounds the
    questions Q&A loop across all features.
  • Config.ScriptResolveMaxIterations() reads it with default+warning
    fallback for invalid values.

Unit tests cover EnvFor, ParseResponse (empty/invalid/valid),
spicedir path + EnsureDir, and ScriptResolveMaxIterations parsing.

Together these are the surfaces that ed-irl/restack-auto-resolve,
ed-irl/integration-auto-resolve, and ed-irl/ai-message-gen will
consume in their respective fixups to collapse the existing
per-feature divergences. See doc/src/guide/scripts.md on
ed-irl/scripts-protocol-guide for the user-facing protocol contract.

@ed-irl

ed-irl commented May 22, 2026

Copy link
Copy Markdown
Collaborator Author

@ed-irl
ed-irl force-pushed the ed-irl/scriptrun branch from 86a0965 to 0c984c4 Compare June 2, 2026 18:57
@ed-irl ed-irl added the skip changelog PRs that don't need a changelog. label Jun 2, 2026
@ed-irl
ed-irl force-pushed the ed-irl/scriptrun branch from 0c984c4 to 5d13e29 Compare June 8, 2026 10:18
@ed-irl
ed-irl requested a review from abhinav June 12, 2026 11:23
@ed-irl
ed-irl force-pushed the ed-irl/scriptrun branch from 5d13e29 to 3e9d081 Compare June 12, 2026 20:07
@ed-irl
ed-irl changed the base branch from main to ed-irl/scripts-protocol-guide June 12, 2026 20:07
@ed-irl
ed-irl force-pushed the ed-irl/scripts-protocol-guide branch from 640febe to f59037a Compare June 13, 2026 13:39
@ed-irl
ed-irl force-pushed the ed-irl/scriptrun branch from 3e9d081 to 1373b7f Compare June 13, 2026 13:39
@abhinav

abhinav commented Jun 13, 2026

Copy link
Copy Markdown
Owner

extracted just the scriptrun functionality into #1276

abhinav added a commit that referenced this pull request Jun 14, 2026
Introduces a small, single-responsibility package for executing
user-configured shell scripts and capturing their output.

Scripts may be either plain shell snippets (passed to 'sh -c') or
self-contained executables starting with a shebang line (written to
a temp file and executed directly).

stdout and stderr are captured independently and returned alongside
the exit code. The package does not interpret script output; that's
the caller's responsibility. This keeps scriptrun reusable across
different output protocols (commit messages, conflict resolutions,
etc).

A non-zero exit is reported in the RunResult rather than as an error,
so callers can distinguish 'script ran and disagreed' from 'script
could not be run at all.'

Part of #1243

This intentionally narrows PR #1188 to only the core scriptrun
functionality described in issue #1243: the generic script runner.

---------

Co-authored-by: Edmund Kohlwey <ed@irl.llc>
@ed-irl
ed-irl force-pushed the ed-irl/scripts-protocol-guide branch from f59037a to 70afff3 Compare June 15, 2026 09:52
@ed-irl
ed-irl force-pushed the ed-irl/scriptrun branch from 1373b7f to 4cbacbc Compare June 15, 2026 09:52
@ed-irl
ed-irl force-pushed the ed-irl/scripts-protocol-guide branch from 70afff3 to 0460c55 Compare June 19, 2026 01:01
@ed-irl ed-irl changed the title scriptrun: Add generic script-runner utility feat(worktree): Add worktree commands, per-worktree trunks, and worktree-aware filtering Jun 19, 2026
@ed-irl
ed-irl force-pushed the ed-irl/scriptrun branch from 4cbacbc to f700687 Compare June 19, 2026 01:01
Adds the script-execution foundation and the cross-feature protocol
surface that the message generator and both auto-resolvers will use.

Runner (existing): executes a user-configured script either via
'sh -c' or by writing a shebang script to a temp file and exec'ing it.
stdout, stderr, and the exit code are returned without interpretation
so each feature can plug its own handler on top.

Shared protocol (new in this commit):

  - ResolveResponse: the JSON document scripts emit on stdout (the
    union of {title, body, assumptions, questions, unresolved_files}
    fields). ParseResponse with ErrEmptyOutput / InvalidOutputError
    for diagnostics.
  - QAPair: per-question persistent-resolution-file record.
  - Operation enum and EnvFor(operation, branch, base) returning the
    shared GS_OPERATION / GS_BRANCH / GS_BASE env that every script
    receives. Feature-specific env layers on top.

Per-repo scratch directory (new in this commit):

  - internal/spice/spicedir owns <repo-root>/.spice/.
  - Path / EnsureDir for the directory; ResolutionPath /
    EnsureResolutionsDir for per-feature resolution files at
    .spice/resolutions/<feature>.json. Does not modify .gitignore --
    that's a project policy decision left to the user.

Configurable iteration cap (new in this commit):

  - spice.scriptResolve.maxIterations (int, default 10) bounds the
    questions Q&A loop across all features.
  - Config.ScriptResolveMaxIterations() reads it with default+warning
    fallback for invalid values.

Unit tests cover EnvFor, ParseResponse (empty/invalid/valid),
spicedir path + EnsureDir, and ScriptResolveMaxIterations parsing.

Together these are the surfaces that ed-irl/restack-auto-resolve,
ed-irl/integration-auto-resolve, and ed-irl/ai-message-gen will
consume in their respective fixups to collapse the existing
per-feature divergences. See doc/src/guide/scripts.md on
ed-irl/scripts-protocol-guide for the user-facing protocol contract.
@ed-irl
ed-irl force-pushed the ed-irl/scripts-protocol-guide branch from 0460c55 to 253532c Compare June 24, 2026 01:31
@ed-irl
ed-irl force-pushed the ed-irl/scriptrun branch from f700687 to 3601ecc Compare June 24, 2026 01:31
@abhinav abhinav changed the title feat(worktree): Add worktree commands, per-worktree trunks, and worktree-aware filtering scriptrun: Generic runner + shared protocol surface Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip changelog PRs that don't need a changelog.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants