Merge pull request #1817 from samcharles93/fix/repo-tooling-stage

feat(workflow): install a repository's declared tooling before its gate
This commit is contained in:
sam authored and GitHub committed 2026-10-21 23:11:52 +11:00
commit 2f8d375692
10 files changed
+207 -3

No files matched your search

+12
View File
@@ -173,6 +173,18 @@ _needs a repository._
|---|---|---|
| `branch` | `fresh` \| `task` | fresh starts a new branch from the base; task resumes the branch this task pushed. |
### `repo.tooling`
_needs a repository._
No settings. It runs the repository policy's `tooling` commands, in order, in
the task worktree — the installs a gate needs and the container does not ship
(protoc plugins, linters, generators). A repository that declares none installs
nothing and the step succeeds. Place it after `repo.prepare` and before any
`gate.*` step: a failing install fails the step with the command and its output
and says the gate did not run, so a missing toolchain is not read as a red
repository.
### `gate.diff-rules`
_needs a repository._
+3
View File
@@ -439,6 +439,9 @@ target = "127.0.0.1:9090" # REQUIRED. The State Store gRPC address arch
# # Override the ecosystem defaults when needed:
# # preflight = [["go", "version"]]
# # test_glob = "*_test.go"
# # Install what the gate needs and the image does not ship; repo.tooling runs
# # these in the worktree, in order, before any gate step:
# # tooling = [["go", "install", "google.golang.org/protobuf/cmd/protoc-gen-go@latest"]]
# protect = ["_templ.go"]
# gate = [
# ["templ", "generate", "./components/"],
+6
View File
@@ -107,6 +107,11 @@ type Repo struct {
// ["task","check"]]. The last command is the test runner, which TDD's repro
// stage expects to fail.
Gate [][]string `toml:"gate" json:"gate" yaml:"gate"`
// Tooling is the commands that install what this repository's gate needs
// (protoc plugins, linters, code generators) in the order they run. They
// run in the task worktree before any gate step; an empty list installs
// nothing, which is the default for a repository that needs nothing.
Tooling [][]string `toml:"tooling" json:"tooling" yaml:"tooling"`
// Protect lists path suffixes agents must never write directly --
// generated files (e.g. "_templ.go") whose sources they should edit
// instead. Enforced environmentally via agentloop.ProtectPaths.
@@ -600,6 +605,7 @@ func cloneRepos(repos []Repo) []Repo {
out := make([]Repo, len(repos))
for i, r := range repos {
r.Gate = cloneStringSlices(r.Gate)
r.Tooling = cloneStringSlices(r.Tooling)
r.Protect = append([]string(nil), r.Protect...)
r.Preflight = cloneStringSlices(r.Preflight)
out[i] = r
+2 -1
View File
@@ -298,7 +298,8 @@ func checkStepAliases(workflowID string, steps []StepRecord, aliases map[string]
var modelFreeStepTypes = map[string]bool{
FinishStepName: true, HandoffStepName: true, ApproveStepName: true,
CloseIssueStepName: true, CommentStepName: true, CommandRunStepName: true,
WorkflowCallStepName: true, RepoPrepareStepName: true, RepoCommitStepName: true,
WorkflowCallStepName: true, RepoPrepareStepName: true, RepoToolingStepName: true,
RepoCommitStepName: true,
RepoOpenPRStepName: true, GateRepositoryName: true, GateDiffSizeStepName: true, DiffRulesStepName: true,
}
+37
View File
@@ -14,6 +14,7 @@ import (
// The general repository step types. Each needs a repository.
const (
RepoPrepareStepName = "repo.prepare"
RepoToolingStepName = "repo.tooling"
RepoCommitStepName = "repo.commit"
RepoOpenPRStepName = "repo.open-pr"
GateRepositoryName = "gate.repository"
@@ -26,6 +27,7 @@ const (
func RepoStepTypes() []StepType {
return []StepType{
{Name: RepoPrepareStepName, Factory: newRepoPrepareStage, Settings: repoPrepareSettings{}},
{Name: RepoToolingStepName, Factory: newRepoToolingStage},
{Name: RepoCommitStepName, Factory: newRepoCommitStage, Settings: repoCommitSettings{}},
{Name: RepoOpenPRStepName, Factory: newRepoOpenPRStage, Settings: repoOpenPRSettings{}},
{Name: GateRepositoryName, Factory: newGateRepositoryStage, Settings: gateRepositorySettings{}},
@@ -84,6 +86,41 @@ func newRepoPrepareStage(settings yaml.Node) (Stage, error) {
return stage, nil
}
// newRepoToolingStage installs what the repository's policy declares, in the
// task worktree, before any gate step runs. The declarations live with the
// repository, not the definition, so one workflow serves repositories with
// different toolchains and one that needs none installs nothing.
func newRepoToolingStage(settings yaml.Node) (Stage, error) {
if err := noSettings(RepoToolingStepName, settings); err != nil {
return Stage{}, err
}
return Stage{Name: RepoToolingStepName, Run: runRepoTooling}, nil
}
func runRepoTooling(ctx context.Context, tc *TaskContext) error {
commands := make([]agentrun.Command, 0, len(tc.Repo.Tooling))
for _, argv := range tc.Repo.Tooling {
if len(argv) == 0 {
continue
}
commands = append(commands, agentrun.Command{Name: argv[0], Argv: argv})
}
if len(commands) == 0 {
return nil
}
if tc.Dir == "" {
return fmt.Errorf("%s: no worktree; run it after the step that prepares one", RepoToolingStepName)
}
detail, err := runCommands(ctx, commands, tc.Dir)
if err != nil {
// The gate did not run, so the text says what failed: an operator
// reading a parked task must not mistake a missing toolchain for a
// red repository.
return fmt.Errorf("%s: installing the repository's declared tooling failed (%w), so no gate step ran; this is an install failure, not a failing test:\n%s", RepoToolingStepName, err, detail)
}
return nil
}
type repoCommitSettings struct {
Message string `yaml:"message" doc:"The commit message."`
// Reference is the verb that links the commit to the task's issue
@@ -0,0 +1,138 @@
package workflow
import (
"context"
"log/slog"
"os"
"path/filepath"
"strings"
"testing"
"gopkg.in/yaml.v3"
"github.com/samcharles93/archie-core/internal/config"
"github.com/samcharles93/archie-core/internal/domain/workflow/task"
)
// repo.tooling takes its commands from the repository's policy document, so the
// stage reads tc.Repo rather than any settings. The tests below resolve it
// through the registered vocabulary: a missing step type fails the assertion
// instead of the build.
const repoToolingStepName = "repo.tooling"
func newRepoToolingTestStage(t *testing.T) Stage {
t.Helper()
for _, stepType := range RepoStepTypes() {
if stepType.Name != repoToolingStepName {
continue
}
stage, err := stepType.Factory(yaml.Node{})
if err != nil {
t.Fatalf("%s: factory: %v", repoToolingStepName, err)
}
return stage
}
t.Fatalf("%s is not a registered repository step type", repoToolingStepName)
return Stage{}
}
func repoToolingContext(t *testing.T, dir string, tooling [][]string) *TaskContext {
t.Helper()
return &TaskContext{
Task: &task.Task{ID: 1, Attempt: 1, Source: task.SourceTest},
Repo: config.Repo{Owner: "acme", Name: "widgets", Tooling: tooling},
Dir: dir,
Log: slog.Default(),
}
}
// A repository that declares no tooling is not a repository that failed to
// install any: the stage is a no-op and the workflow continues.
func TestRepoToolingWithoutDeclarationsSucceeds(t *testing.T) {
dir := t.TempDir()
stage := newRepoToolingTestStage(t)
for _, tooling := range [][][]string{nil, {}, {{}}} {
if err := stage.Run(context.Background(), repoToolingContext(t, dir, tooling)); err != nil {
t.Fatalf("tooling %v: err = %v, want none", tooling, err)
}
}
entries, err := os.ReadDir(dir)
if err != nil {
t.Fatal(err)
}
if len(entries) != 0 {
t.Fatalf("worktree holds %v, want nothing written", entries)
}
}
// The commands run in the task worktree, in the declared order: installing a
// toolchain that landed somewhere other than the repository would leave the
// gate unable to find it.
func TestRepoToolingRunsDeclaredCommandsInOrderInTheWorktree(t *testing.T) {
dir := t.TempDir()
stage := newRepoToolingTestStage(t)
tc := repoToolingContext(t, dir, [][]string{
{"sh", "-c", "printf first > order.txt"},
{"sh", "-c", "printf second >> order.txt"},
{"sh", "-c", "pwd > where.txt"},
})
if err := stage.Run(context.Background(), tc); err != nil {
t.Fatalf("err = %v, want none", err)
}
order, err := os.ReadFile(filepath.Join(dir, "order.txt"))
if err != nil {
t.Fatalf("declared command did not run in the worktree: %v", err)
}
if got, want := string(order), "firstsecond"; got != want {
t.Fatalf("commands ran out of order: got %q, want %q", got, want)
}
where, err := os.ReadFile(filepath.Join(dir, "where.txt"))
if err != nil {
t.Fatalf("declared command did not run in the worktree: %v", err)
}
if got := strings.TrimSpace(string(where)); got != dir {
t.Fatalf("command ran in %q, want the worktree %q", got, dir)
}
}
// A failed install is a failure to install, not a red repository: the error
// carries the command and its output and says so, so an operator (and the
// baseline-fix builder) does not read it as failing tests.
func TestRepoToolingFailureNamesTheInstallAndItsOutput(t *testing.T) {
dir := t.TempDir()
stage := newRepoToolingTestStage(t)
tc := repoToolingContext(t, dir, [][]string{
{"sh", "-c", "printf first > ran.txt"},
{"sh", "-c", "echo 'no such toolchain: protoc-gen-nope' >&2; exit 7"},
{"sh", "-c", "printf third > after.txt"},
})
err := stage.Run(context.Background(), tc)
if err == nil {
t.Fatal("err = nil, want the failed install reported")
}
message := err.Error()
for _, want := range []string{"protoc-gen-nope", "no such toolchain", "install"} {
if !strings.Contains(message, want) {
t.Fatalf("err = %q, want it to name %q", message, want)
}
}
if strings.Contains(strings.ToLower(message), "test failure") {
t.Fatalf("err = %q, want it not to read as a failing test", message)
}
if _, err := os.Stat(filepath.Join(dir, "after.txt")); !os.IsNotExist(err) {
t.Fatalf("a command after the failure ran; the step must stop at the first failure (stat err = %v)", err)
}
}
// The step needs a worktree to install into: running it before repo.prepare is
// a definition error, not a silent install in the daemon's own directory.
func TestRepoToolingWithoutWorktreeFails(t *testing.T) {
stage := newRepoToolingTestStage(t)
err := stage.Run(context.Background(), repoToolingContext(t, "", [][]string{{"sh", "-c", "true"}}))
if err == nil {
t.Fatal("err = nil, want a failure naming the missing worktree")
}
}
@@ -2,6 +2,7 @@ id: implement
identity: 6f129e29-0e26-5246-99bd-74cb4496203b
steps:
- type: repo.prepare
- type: repo.tooling
- type: gate.repository
settings:
repair: true
@@ -2,6 +2,7 @@ id: tdd
identity: 6f129e29-0e26-5246-99bd-74cb4496203b
steps:
- type: repo.prepare
- type: repo.tooling
- type: gate.repository
settings:
repair: true
+1 -1
View File
@@ -167,7 +167,7 @@ XID_Start XIDS`.split(/\s/).map(e=>[$b(e),e])),qx=new Map([[`s`,jx(383)],[jx(383
`));return(t,r)=>e.tool.path?(L(),q(cne,{key:0,path:e.tool.path,label:e.tool.label},null,8,[`path`,`label`])):s.value?(L(),q(V(zp),{key:1,"default-open":i.value},{default:I(()=>[A(V(Hp),null,{default:I(()=>[A(V(Wp),{status:i.value?`error`:o.value?`running`:void 0},{default:I(()=>[A(V(Vp),null,{default:I(()=>[A(V(hu))]),_:1}),A(V(Gp),null,{default:I(()=>[H(B(n.value),1)]),_:1})]),_:1},8,[`status`])]),_:1}),A(V(Bp),null,{default:I(()=>[A(V(qp),{size:`sm`},{default:I(()=>[A(V(Qp),{wrap:``,class:`max-h-64`},{default:I(()=>[H(B(s.value),1)]),_:1})]),_:1})]),_:1})]),_:1},8,[`default-open`])):(L(),q(V(Wp),{key:2,status:i.value?`error`:o.value?`running`:void 0},{default:I(()=>[A(V(Vp),null,{default:I(()=>[A(V(hu))]),_:1}),A(V(Gp),null,{default:I(()=>[H(B(n.value),1)]),_:1})]),_:1},8,[`status`]))}}),une={key:1,class:`mb-2 flex flex-wrap gap-1.5`},dne={key:3,class:`whitespace-pre-wrap`},fne=P({__name:`ChatBubble`,props:{text:{},tools:{default:()=>[]},media:{default:()=>[]},assistant:{type:Boolean,default:!1},streaming:{type:Boolean,default:!1}},setup(e){return(t,n)=>(L(),q(V(dC),{align:e.assistant?`start`:`end`},{default:I(()=>[A(V(fC),null,{default:I(()=>[A(V(Mp),{variant:e.assistant?`muted`:`tinted`,class:`max-w-[min(78ch,92%)]`},{default:I(()=>[A(V(Np),{class:`[overflow-wrap:anywhere]`},{default:I(()=>[e.assistant&&e.tools.length?(L(),q(V(Fp),{key:0,class:`mb-2`},{default:I(()=>[(L(!0),j(U,null,M(e.tools,(t,n)=>(L(),q(lne,{key:n,tool:t,streaming:e.streaming},null,8,[`tool`,`streaming`]))),128))]),_:1})):F(``,!0),e.media.length?(L(),j(`div`,une,[(L(!0),j(U,null,M(e.media,(e,t)=>(L(),q(_C,{key:t,attachment:e},null,8,[`attachment`]))),128))])):F(``,!0),e.assistant?(L(),q(one,{key:2,text:e.text},null,8,[`text`])):(L(),j(`div`,dne,B(e.text),1)),K(t.$slots,`default`)]),_:3})]),_:3},8,[`variant`]),e.assistant&&!e.streaming&&e.text?(L(),q(V(pC),{key:0,class:`px-0 transition-opacity focus-within:opacity-100 [@media(hover:hover)]:opacity-0 [@media(hover:hover)]:group-hover/message:opacity-100`},{default:I(()=>[A(V(em),{value:e.text},null,8,[`value`])]),_:1})):F(``,!0)]),_:3})]),_:3},8,[`align`]))}}),pne={class:`text-sm`},mne={key:0,class:`mt-1 text-fg-muted`},hne={key:1,class:`mt-2 flex flex-wrap gap-2`},gne=P({__name:`ChatChooseCard`,props:{choose:{}},setup(e){let t=Y(()=>Wu.value.models??[]);return(e,n)=>(L(),j(`div`,pne,[n[0]||=R(`p`,{class:`font-medium`},`Choose a model`,-1),t.value.length?(L(),j(`div`,hne,[(L(!0),j(U,null,M(t.value,e=>(L(),q(V(X),{key:e,size:`sm`,variant:e===V(Wu).active_model?`default`:`outline`,class:`font-mono`,onClick:t=>void V(rd)(e)},{default:I(()=>[H(B(e),1)]),_:2},1032,[`variant`,`onClick`]))),128))])):(L(),j(`p`,mne,`None configured.`))]))}}),_ne={class:`text-sm`},vne={key:0},yne={class:`mt-1 space-y-0.5`},bne={class:`font-mono`},xne=[`href`],Sne={key:0,class:`mt-3 flex gap-2`},Cne={key:1,class:`mt-2 text-fg-muted`},wne={key:2,class:`mt-2 text-fg-muted`},Tne={key:3,class:`mt-2 text-ok`},Ene={key:4,class:`mt-2 text-danger`},Dne={key:5,class:`mt-2 text-xs text-fg-muted`},One=P({__name:`ChatUpdateCard`,props:{update:{}},setup(e){let t=e,n=Y(()=>t.update.available??[]),r=J(`idle`),i=J(``);async function a(){r.value=`installing`;try{let e=(await Z.updateInstall(t.update.snapshot)).result?.installed;i.value=e?Object.entries(e).map(([e,t])=>`${e} → ${t}`).join(`, `)+`. Archie restarts to apply it.`:`Update finished.`,r.value=`done`}catch(e){i.value=e.message,r.value=`failed`}}async function o(){try{await Z.updateDefer(t.update.snapshot),r.value=`deferred`}catch(e){i.value=e.message,r.value=`failed`}}return(t,s)=>(L(),j(`div`,_ne,[n.value.length?(L(),j(U,{key:1},[s[2]||=R(`p`,{class:`font-medium`},`An update is available`,-1),R(`ul`,yne,[(L(!0),j(U,null,M(n.value,e=>(L(),j(`li`,{key:e.ID},[H(B(e.Label||e.ID)+`: `,1),R(`span`,bne,B(e.Installed||`?`)+` → `+B(e.Available),1),e.Changelog?(L(),j(`a`,{key:0,href:e.Changelog,target:`_blank`,rel:`noopener`,class:`ml-1 text-xs underline`},`changes`,8,xne)):F(``,!0)]))),128))]),r.value===`idle`?(L(),j(`div`,Sne,[e.update.can_install?(L(),q(V(X),{key:0,size:`sm`,onClick:a},{default:I(()=>[...s[0]||=[H(`Install`,-1)]]),_:1})):F(``,!0),A(V(X),{size:`sm`,variant:`ghost`,onClick:o},{default:I(()=>[...s[1]||=[H(`Not now`,-1)]]),_:1})])):r.value===`installing`?(L(),j(`p`,Cne,`Installing…`)):r.value===`deferred`?(L(),j(`p`,wne,`Skipped until a newer release.`)):r.value===`done`?(L(),j(`p`,Tne,B(i.value),1)):(L(),j(`p`,Ene,B(i.value),1)),r.value===`idle`&&!e.update.can_install?(L(),j(`p`,Dne,`No install script on this host.`)):F(``,!0)],64)):(L(),j(`p`,vne,`Up to date`))]))}}),kne={class:`w-full self-center justify-self-center py-6 text-center`},Ane={class:`flex flex-wrap justify-center gap-2`},jne=P({__name:`ChatEmptyState`,emits:[`prompt`],setup(e,{emit:t}){let n=t,r=[`Summarise active tasks`,`Show running agents`,`Check system status`];return(e,t)=>(L(),j(`div`,kne,[t[0]||=R(`span`,{"aria-hidden":`true`,class:`mx-auto mb-3 grid size-9 place-items-center roundeLine truncated
`).map(e=>e.trim()).find(Boolean)||``,i=r.length>uT?`${r.slice(0,uT).trimEnd()}…`:r;return{text:i,full:n,truncated:i!==n}}function Pie(e){return String(e||`event`).replaceAll(`_`,` `).replace(/\b\w/g,e=>e.toUpperCase())}function fT(e){let t=Number(e);if(!Number.isFinite(t)||t<0)return``;if(t<1e3)return`under 1 s`;let n=t/1e3;if(n<60)return`${n.toFixed(+(n<10))} s`;let r=Math.round(n),i=Math.floor(r/60),a=r%60;if(i<60)return a===0?`${i} min`:`${i} min ${a} s`;let o=Math.floor(i/60),s=i-o*60;return s===0?`${o} h`:`${o} h ${s} min`}function pT(e){let t=Number(e);return!Number.isFinite(t)||t<=0?``:t.toLocaleString(`en-US`)}function mT(e){return typeof e==`string`?e:``}function hT(e={}){let t=e.data||{},n=e.stage||`unknown stage`,r=e.workflow?`${e.workflow} workflow`:``;if(e.kind===`stage_start`)return{title:`Started stage: ${n}`,detail:r};if(e.kind===`stage_finish`){let e=fT(t.duration_ms),i=[r,e&&`ran for ${e}`].filter(Boolean).join(` · `);return{title:t.interrupted?`Stage interrupted: ${n}`:t.skipped?`Skipped stage: ${n}`:t.error?`Stage failed: ${n}`:`Finished stage: ${n}`,detail:[i,mT(t.error),mT(t.when)].filter(Boolean).join(` · `)}}if(e.kind===`task_retried`){let n=Number(t.retry_count);return{title:Number.isFinite(n)&&n>0?`Retry ${n}`:`Retry requested`,detail:[mT(t.previous_stage)&&`after ${mT(t.previous_stage)}`,mT(t.previous_reason)].filter(Boolean).join(`: `)||e.detail||``}}if(e.kind===`agent_finish`){let r=pT(t.iterations),i=pT(t.tokens),a=Number(t.cached_tokens)||0,o=pT((Number(t.prompt_tokens)||0)-a),s=pT(t.completion_tokens),c=pT(t.cached_tokens),l=[r&&`${r} iterations`,i&&`${i} tokens`,o&&`${o} fresh prompt`,s&&`${s} completion`,c&&`${c} cached`,mT(t.model)].filter(Boolean);return{title:`Agent ${mT(t.status)||`finished`}: ${n}`,detail:l.join(` · `)||e.detail||``}}if(e.kind===`remediation_round`){let e=Number(t.of),n=mT(t.author);return{title:`Remediation ${mT(t.round)}${e>0?` of ${e}`:``}`,detail:[n&&`answers ${n}'s review`,t.review_id?`#${mT(t.review_id)}`:``].filter(Boolean).join(` `)}}if(e.kind===`review_approved`){let e=mT(t.pr_number);return{title:`Pull request approved`,detail:[mT(t.author),e&&`#${e}`].filter(Boolean).join(` · `)}}if(e.kind===`step_retried`)return{title:`Attempt ${mT(t.attempt)} of ${mT(t.of)} failed: ${e.stage||`step`}`,detail:mT(t.error),tone:`warn`};if(e.kind===`config_captured`)return{title:`Configuration captured`,detail:`The effective task-runtime configuration for this run.`};if(e.kind===`binding_started`){let e=mT(t.source),n=mT(t.capture_id),r=[{label:`binding ${mT(t.binding_name)||mT(t.binding_id)}`,to:`/events?tab=bindings`},...n?[{label:`captured event`,to:`/events?tab=inspector&capture=${encodeURIComponent(n)}`}]:[]];return t.unsigned===!0?{title:`Started by an unsigned event`,detail:e?`source ${e}`:``,tone:`warn`,links:r}:{title:`Started by an event`,detail:e?`source ${e}`:``,links:r}}if(e.kind===`changes_captured`){let e=t.totals??{},n=Number(e.files);return{title:`Change capture recorded`,detail:[Number.isFinite(n)&&n>0?`${n} file${n===1?``:`s`} changed`:``,t.captured_after?`captured after ${mT(t.captured_after)}`:``].filter(Boolean).join(` · `)}}return{title:Pie(e.kind||e.type),detail:e.detail||``}}var Fie=[`title`],gT=P({__name:`ActivityRow`,props:{event:{}},emits:[`open`],setup(e,{emit:t}){let n=lT();n.watchIdentities();let r=e,i=t,a=$w(),o=Y(()=>a.taskIDFor(r.event)),s=Y(()=>dT(r.event,n.identityName));function c(){o.value>0&&i(`open`,o.value)}let l=Y(()=>r.event.at?RC(r.event.at):`–`);return(e,t)=>(L(),q(V(aT),{class:z(o.value>0?`cursor-pointer`:``),role:o.value>0?`link`:void 0,tabindex:o.value>0?0:void 0,title:o.value>0?`Open task details`:void 0,onClick:c,onKeydown:[wt(bt(c,[`prevent`]),[`enter`]),wt(bt(c,[`prevent`]),[`space`])]},{default:I(()=>[A(V(iT),{class:`font-medium`},{default:I(()=>[H(B(V(hT)({...r.event,at:void 0,detail:void 0}).title),1)]),_:1}),A(V(iT),{class:`font-mono`},{default:I(()=>[H(B(o.value>0?`#${o.value}`:`–`),1)]),_:1}),A(V(iT),{class:`w-[55%] max-w-0`},{default:I(()=>[R(`span`,{class:`block truncate`,title:s.value.truncated?s.value.full:void 0},B(s.value.text),9,Fie)]),_:1}),A(V(iT),null,{default:I(()=>[H(B(l.value),1)]),_:1})]),_:1},8,[`class`,`role`,`tabindex`,`title`,`onKeydown`]))}}),Iie=[{value:`all`,label:`All`},{value:`tasks`,label:`Tasks`},{value:`system`,label:`System`}];function _T(e){return(Number(e?.task_id)||0)>0}function Lie(e,t){return t===`tasks`?_T(e):t!==`system`||!_T(e)}function Rie(e,t){return e.filter(e=>Lie(e,t))}function zie(e,t){return e>0?``:t===`all`?`Waiting for activity`:t===`tasks`?`No task events yet`:`No system events yet`}function Bie(e,t){return`${e}:${t??0}`}function Vie(e){let t=[];for(let n of e){let e=n.kind||n.type||`event`,r=Number(n.task_id)||0,i=Bie(dT(n).text,r),a=t[t.length-1];a&&a.key===i?(a.count+=1,a.events.push(n)):t.push({key:i,label:e,taskID:r,count:1,representative:n,events:[n]})}return t}var Hie={key:0,class:`font-normal text-fg-subtle`},Uie={role:`region`,"aria-labe Line truncated
`,1)[0]??``;return t.length>80?`${t.slice(0,79)}…`:t}function gE(e){return(e?.merged||0)+(e?.completed||0)}function _E(e){return Object.entries(e?.inputs??{}).map(([e,t])=>({name:e,type:t.type,required:t.required===!0})).sort((e,t)=>e.name.localeCompare(t.name))}function vE(e,t){return e.filter(e=>e.required&&!(t[e.name]??``).trim()).map(e=>e.name)}function yE(e,t){switch(t){case`number`:{let t=e.trim();return t!==``&&!Number.isNaN(Number(t))?Number(t):e}case`bool`:return e===`true`||e!==`false`&&e;case`string`:return e;default:try{return JSON.parse(e)}catch{return e}}}function bE(e,t){let n={};for(let r of e){let e=t[r.name];e!==void 0&&e!==``&&(n[r.name]=yE(e,r.type))}return n}var xE=[`onKeydown`],SE={key:0,class:`text-sm text-danger`,role:`alert`},CE={key:1,class:`grid gap-1.5`},wE=[`for`],TE={key:0,class:`font-normal text-fg-subtle`},EE=[`id`],DE=[`value`],OE={key:0,class:`text-xs text-fg-subtle`},kE={key:2,class:`grid gap-1.5`},AE=[`id`],jE={class:`block truncate text-[13px] font-medium`},ME={class:`block text-xs text-fg-subtle`},NE={key:0,class:`text-xs text-fg-subtle`},PE={key:3,class:`grid gap-3`},FE=[`for`],IE={class:`font-mono`},LE={key:0,class:`text-fg-subtle`},RE={class:`grid gap-1.5`},zE=[`for`],BE={class:`grid gap-1.5`},VE=[`for`],HE={key:4,class:`text-sm text-danger`,role:`alert`},UE={class:`flex items-center gap-2 border-t border-border pt-4`},WE={class:`mr-auto text-xs text-fg-subtle`},GE=P({__name:`NewTaskForm`,props:{workflow:{},draft:{},initialWorkflow:{},initialInstructions:{}},emits:[`started`,`cancel`],setup(e,{emit:t}){let n=e,r=t,i=De(),a=J([]),o=J([]),s=J([]),c=J(``);Ue(async()=>{try{let[e,t]=await Promise.all([Z.workflows(),Z.repositories()]);a.value=(e?.definitions??[]).filter(e=>e.enabled),o.value=e?.workflows??[],s.value=(t??[]).map(e=>`${e.owner}/${e.name}`)}catch(e){c.value=String(e.message||e)}});let l=J(``),u=J(n.workflow??n.initialWorkflow??``),d=J(n.initialInstructions??``),f=J(hE(d.value)),p=J({});Ee(()=>{!u.value&&a.value[0]&&(u.value=a.value[0].id)});let m=Y(()=>a.value.find(e=>e.id===u.value)),h=Y(()=>_E(m.value)),g=Y(()=>vE(h.value,p.value)),_=Y(()=>m.value?.repository??`required`),v=Y(()=>_.value!==`optional`&&_.value!==`none`),y=e=>o.value.find(t=>t.workflow===e),b=J(!1),x=J(``),S=Y(()=>!(!l.value.trim()&&v.value||!u.value||!f.value.trim())&&g.value.length===0);async function C(){if(S.value&&!b.value){b.value=!0,x.value=``;try{let e=await Z.workRequest({repository:_.value===`none`?``:l.value.trim(),workflow:u.value,title:f.value.trim(),instructions:d.value,inputs:bE(h.value,p.value),...n.draft?{draft:n.draft}:{}});r(`started`,e.task_id)}catch(e){x.value=String(e.message||e)}finally{b.value=!1}}}return(e,t)=>(L(),j(`form`,{class:`grid gap-5`,onSubmit:bt(C,[`prevent`]),onKeydown:[wt(bt(C,[`meta`,`prevent`]),[`enter`]),wt(bt(C,[`ctrl`,`prevent`]),[`enter`])]},[c.value?(L(),j(`p`,SE,B(c.value),1)):F(``,!0),_.value===`none`?F(``,!0):(L(),j(`div`,CE,[R(`label`,{for:`${V(i)}-repo`,class:`text-[13px] font-medium`},[t[5]||=H(`Repository`,-1),v.value?F(``,!0):(L(),j(`span`,TE,` (optional)`))],8,wE),A(V(Q),{id:`${V(i)}-repo`,modelValue:l.value,"onUpdate:modelValue":t[0]||=e=>l.value=e,class:`font-mono`,placeholder:`owner/repository`,list:`${V(i)}-repos`,required:v.value},null,8,[`id`,`modelValue`,`list`,`required`]),R(`datalist`,{id:`${V(i)}-repos`},[(L(!0),j(U,null,M(s.value,e=>(L(),j(`option`,{key:e,value:e},null,8,DE))),128))],8,EE),s.value.length?(L(),j(`p`,OE,[t[6]||=H(`Configured: `,-1),(L(!0),j(U,null,M(s.value,e=>(L(),q(V(X),{key:e,type:`button`,variant:`link`,size:`xs`,class:`h-auto px-1 font-mono text-fg-subtle`,onClick:t=>l.value=e},{default:I(()=>[H(B(e),1)]),_:2},1032,[`onClick`]))),128))])):F(``,!0)])),n.workflow?F(``,!0):(L(),j(`div`,kE,[R(`span`,{id:`${V(i)}-wf`,class:`text-[13px] font-medium`},`Workflow`,8,AE),A(V(vs),{modelValue:u.value,"onUpdate:modelValue":t[1]||=e=>u.value=e,"aria-labelledby":`${V(i)}-wf`,class:`grid grid-cols-1 gap-2 sm:grid-cols-3`,loop:``},{default:I(()=>[(L(!0),j(U,null,M(a.value,e=>(L(),q(V(bs),{key:e.id,value:e.id,class:`rounded-md border border-border bg-card px-3 py-2.5 text-left transition-colors hover:bg-secondary focus-visible:outline-2 focus-visible:outline-ring data-[state=checked]:border-primary data-[state=checked]:bg-secondary`},{default:I(()=>[R(`span`,jE,B(e.name||e.id),1),R(`span`,ME,[H(B(y(e.id)?.runs||0)+` runs`,1),y(e.id)?.runs?(L(),j(U,{key:0},[H(` · `+B(Math.round(V(gE)(y(e.id))/(y(e.id)?.runs||1)*100))+`% delivered`,1)],64)):F(``,!0)])]),_:2},1032,[`value`]))),128))]),_:1},8,[`modelValue`,`aria-labelledby`]),!a.value.length&&!c.value?(L(),j(`p`,NE,`No enabled workflows.`)):F(``,!0)])),h.value.length?(L(),j(`div`,PE,[(L(!0),j(U,null,M(h.value,e=>(L(),j(`div`,{key:e.name,class:`grid gap-1.5`},[R(`label`,{for:`${V(i)}-input-${e.name}`,class:`text-[13px] font-medium`},[R(`span`,IE,B(e.name),1),e.required?(L(),j(`span`,LE,` · required`)):F(``,!0)],8,FE),A(V(Q),{id:`${V(i)}-input-${e.name}`,"model-value":p.value[e. Line truncated
`)){let e=n.indexOf(`:`);if(e<=0)continue;let r=n.slice(0,e).trim();r&&(t[r]=n.slice(e+1).trim())}return t}function sD(e,t){if(!e.event_type)return{label:`Unidentified`,identified:!1};let n=t.find(t=>t.id===e.event_type);return{label:n?n.name:`Deleted type`,identified:!0}}function cD(e,t){if(!e)return`No event type`;let n=t.find(t=>t.id===e);return n?`${n.source} / ${n.name}`:`Deleted type`}function lD(e){let t=[...(e.headers||[]).map(e=>`${e.name} = ${e.value}`),...(e.payload||[]).map(e=>e.op===`present`?`${e.path} present`:`${e.path} = ${e.value??``}`)];return t.length?t.join(` · `):`any event`}function uD(e){return{headers:(e.headers||[]).filter(e=>e.name.trim()!==``).map(e=>({name:e.name.trim(),value:e.value})),payload:(e.payload||[]).filter(e=>e.path.trim()!==``).map(e=>e.op===`present`?{path:e.path.trim(),op:e.op}:{path:e.path.trim(),op:e.op,value:e.value??``})}}var dD=J([]),fD=J([]),pD=J(!0),mD=J(null),hD=J(!0),gD=J(null),_D=J(!1),vD=J(null);async function yD(){try{let e=await Z.eventTypes(aD().workspace);pD.value=e.enabled!==!1,dD.value=e.event_types||[],fD.value=e.proposals||[],mD.value=null}catch(e){mD.value=e.message||String(e)}finally{hD.value=!1}}function bD(e){return{headers:(e.headers||[]).map(e=>({...e})),payload:(e.payload||[]).map(e=>({...e}))}}function xD(e){vD.value=null,gD.value=e}function SD(e){let t=AD.value.find(t=>String(t.id)===e.sample_id);xD({mode:`proposal`,id:null,source:e.source,name:``,rule:bD(e.rule),headersText:``,body:t?.body||``,exampleHeaders:e.headers||{}})}function CD(e=``){xD({mode:`paste`,id:null,source:e,name:``,rule:{headers:[],payload:[]},headersText:``,body:``,exampleHeaders:{}})}function wD(e){xD({mode:`edit`,id:e.id,source:e.source,name:e.name,rule:bD(e.rule),headersText:``,body:``,exampleHeaders:{}})}function TD(){gD.value=null}async function ED(){let e=gD.value;if(e){_D.value=!0;try{if(e.mode===`edit`&&e.id)await Z.eventTypeUpdate(e.id,{name:e.name,rule:uD(e.rule)});else{let t=e.mode===`paste`?oD(e.headersText):e.exampleHeaders;await Z.eventTypeCreate({source:e.source,name:e.name,rule:e.mode===`paste`?void 0:uD(e.rule),example:{headers:t,body:e.body}})}gD.value=null,await yD()}catch(e){vD.value=e.message||String(e)}finally{_D.value=!1}}}var DD=J(null);async function OD(){let e=DD.value;if(DD.value=null,e)try{await Z.eventTypeDelete(e.id),await yD()}catch(e){mD.value=e.message||String(e)}}var kD=100,AD=J([]),jD=J(!0),MD=J(null),ND=J(!0),PD=J(null);async function FD(){try{let e=await Z.captures(kD);jD.value=e.enabled!==!1,AD.value=e.captures||[],MD.value=null}catch(e){MD.value=e.message||String(e)}finally{ND.value=!1}}function ID(e){let t=AD.value.find(t=>t.id===e);return t&&(PD.value=t),!!t}function LD(){AD.value.length&&(PD.value=AD.value[0])}function RD(){VC(`captures`,()=>{FD(),yD()})}var zD=P({__name:`Tabs`,props:{defaultValue:{},orientation:{},dir:{},activationMode:{},modelValue:{},unmountOnHide:{type:Boolean},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},emits:[`update:modelValue`],setup(e,{emit:t}){let n=e,r=t,i=ft(n,`class`),a=ue(i,r);return(e,t)=>(L(),q(V(dc),G({"data-slot":`tabs`,"data-orientation":V(a).orientation||`horizontal`},V(a),{class:V(W)(`gap-2 group/tabs flex data-horizontal:flex-col`,n.class)}),{default:I(t=>[K(e.$slots,`default`,Xe(Ce(t)))]),_:3},16,[`data-orientation`,`class`]))}}),BD=P({__name:`TabsContent`,props:{value:{},forceMount:{type:Boolean},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){let t=e,n=ft(t,`class`);return(e,r)=>(L(),q(V(mc),G({"data-slot":`tabs-content`,class:V(W)(`text-sm flex-1 outline-none`,t.class)},V(n)),{default:I(()=>[K(e.$slots,`default`)]),_:3},16,[`class`]))}}),VD=P({__name:`TabsList`,props:{loop:{type:Boolean},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]},variant:{default:`default`}},setup(e){let t=e,n=ft(t,`class`,`variant`);return(r,i)=>(L(),q(V(hc),G({"data-slot":`tabs-list`,"data-variant":e.variant},V(n),{class:V(W)(V(UD)({variant:e.variant}),t.class)}),{default:I(()=>[K(r.$slots,`default`)]),_:3},16,[`data-variant`,`class`]))}}),HD=P({__name:`TabsTrigger`,props:{value:{},disabled:{type:Boolean},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){let t=e,n=ft(t,`class`),r=pe(n);return(e,n)=>(L(),q(V(gc),G({"data-slot":`tabs-trigger`,class:V(W)(`gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg:not([class*=size-])]:size-4 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:outline-1 focus-visibleLine truncated
`)){let e=n.indexOf(`:`);if(e<=0)continue;let r=n.slice(0,e).trim();r&&(t[r]=n.slice(e+1).trim())}return t}function sD(e,t){if(!e.event_type)return{label:`Unidentified`,identified:!1};let n=t.find(t=>t.id===e.event_type);return{label:n?n.name:`Deleted type`,identified:!0}}function cD(e,t){if(!e)return`No event type`;let n=t.find(t=>t.id===e);return n?`${n.source} / ${n.name}`:`Deleted type`}function lD(e){let t=[...(e.headers||[]).map(e=>`${e.name} = ${e.value}`),...(e.payload||[]).map(e=>e.op===`present`?`${e.path} present`:`${e.path} = ${e.value??``}`)];return t.length?t.join(` · `):`any event`}function uD(e){return{headers:(e.headers||[]).filter(e=>e.name.trim()!==``).map(e=>({name:e.name.trim(),value:e.value})),payload:(e.payload||[]).filter(e=>e.path.trim()!==``).map(e=>e.op===`present`?{path:e.path.trim(),op:e.op}:{path:e.path.trim(),op:e.op,value:e.value??``})}}var dD=J([]),fD=J([]),pD=J(!0),mD=J(null),hD=J(!0),gD=J(null),_D=J(!1),vD=J(null);async function yD(){try{let e=await Z.eventTypes(aD().workspace);pD.value=e.enabled!==!1,dD.value=e.event_types||[],fD.value=e.proposals||[],mD.value=null}catch(e){mD.value=e.message||String(e)}finally{hD.value=!1}}function bD(e){return{headers:(e.headers||[]).map(e=>({...e})),payload:(e.payload||[]).map(e=>({...e}))}}function xD(e){vD.value=null,gD.value=e}function SD(e){let t=AD.value.find(t=>String(t.id)===e.sample_id);xD({mode:`proposal`,id:null,source:e.source,name:``,rule:bD(e.rule),headersText:``,body:t?.body||``,exampleHeaders:e.headers||{}})}function CD(e=``){xD({mode:`paste`,id:null,source:e,name:``,rule:{headers:[],payload:[]},headersText:``,body:``,exampleHeaders:{}})}function wD(e){xD({mode:`edit`,id:e.id,source:e.source,name:e.name,rule:bD(e.rule),headersText:``,body:``,exampleHeaders:{}})}function TD(){gD.value=null}async function ED(){let e=gD.value;if(e){_D.value=!0;try{if(e.mode===`edit`&&e.id)await Z.eventTypeUpdate(e.id,{name:e.name,rule:uD(e.rule)});else{let t=e.mode===`paste`?oD(e.headersText):e.exampleHeaders;await Z.eventTypeCreate({source:e.source,name:e.name,rule:e.mode===`paste`?void 0:uD(e.rule),example:{headers:t,body:e.body}})}gD.value=null,await yD()}catch(e){vD.value=e.message||String(e)}finally{_D.value=!1}}}var DD=J(null);async function OD(){let e=DD.value;if(DD.value=null,e)try{await Z.eventTypeDelete(e.id),await yD()}catch(e){mD.value=e.message||String(e)}}var kD=100,AD=J([]),jD=J(!0),MD=J(null),ND=J(!0),PD=J(null);async function FD(){try{let e=await Z.captures(kD);jD.value=e.enabled!==!1,AD.value=e.captures||[],MD.value=null}catch(e){MD.value=e.message||String(e)}finally{ND.value=!1}}function ID(e){let t=AD.value.find(t=>t.id===e);return t&&(PD.value=t),!!t}function LD(){AD.value.length&&(PD.value=AD.value[0])}function RD(){VC(`captures`,()=>{FD(),yD()})}var zD=P({__name:`Tabs`,props:{defaultValue:{},orientation:{},dir:{},activationMode:{},modelValue:{},unmountOnHide:{type:Boolean},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},emits:[`update:modelValue`],setup(e,{emit:t}){let n=e,r=t,i=ft(n,`class`),a=ue(i,r);return(e,t)=>(L(),q(V(dc),G({"data-slot":`tabs`,"data-orientation":V(a).orientation||`horizontal`},V(a),{class:V(W)(`gap-2 group/tabs flex data-horizontal:flex-col`,n.class)}),{default:I(t=>[K(e.$slots,`default`,Xe(Ce(t)))]),_:3},16,[`data-orientation`,`class`]))}}),BD=P({__name:`TabsContent`,props:{value:{},forceMount:{type:Boolean},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){let t=e,n=ft(t,`class`);return(e,r)=>(L(),q(V(mc),G({"data-slot":`tabs-content`,class:V(W)(`text-sm flex-1 outline-none`,t.class)},V(n)),{default:I(()=>[K(e.$slots,`default`)]),_:3},16,[`class`]))}}),VD=P({__name:`TabsList`,props:{loop:{type:Boolean},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]},variant:{default:`default`}},setup(e){let t=e,n=ft(t,`class`,`variant`);return(r,i)=>(L(),q(V(hc),G({"data-slot":`tabs-list`,"data-variant":e.variant},V(n),{class:V(W)(V(UD)({variant:e.variant}),t.class)}),{default:I(()=>[K(r.$slots,`default`)]),_:3},16,[`data-variant`,`class`]))}}),HD=P({__name:`TabsTrigger`,props:{value:{},disabled:{type:Boolean},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){let t=e,n=ft(t,`class`),r=pe(n);return(e,n)=>(L(),q(V(gc),G({"data-slot":`tabs-trigger`,class:V(W)(`gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg:not([class*=size-])]:size-4 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:outline-1 focus-visibleLine truncated
WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}var hB=tB(`CharSizeService`),gB=tB(`CoreBrowserService`),_B=tB(`MouseService`),vB=tB(`RenderService`),yB=tB(`SelectionService`),bB=tB(`CharacterJoinerService`),xB=tB(`ThemeService`),SB=tB(`LinkProviderService`),CB=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?kB.isErrorNoTelemetry(e)?new kB(e.message+`
+6 -1
View File
@@ -49,6 +49,7 @@ interface Repo {
base: string;
ecosystem: string;
gate: string[][] | null;
tooling: string[][] | null;
preflight: string[][] | null;
protect: string[] | null;
test_glob: string;
@@ -88,7 +89,7 @@ function addRepo() {
if (!draft.value || !owner || !name) return;
draft.value.value ??= [];
(draft.value.value as Repo[]).push({
owner, name, connection: "", base: "main", ecosystem: "go", gate: [], preflight: null, protect: null,
owner, name, connection: "", base: "main", ecosystem: "go", gate: [], tooling: null, preflight: null, protect: null,
test_glob: "", persistent_storage: false, max_retries: 0, allow_concurrent: false,
});
newRepo.value = "";
@@ -173,6 +174,10 @@ async function checkAccess(repo:Repo):Promise<void>{
<CommandListEditor v-model="repo.gate" label="Gate" empty-text="No gate." />
<DraftHint :kind="KIND" :path="`${i}.gate`" />
</SettingRow>
<SettingRow label="Tooling" hint="Installs the gate needs; runs before it.">
<CommandListEditor v-model="repo.tooling" label="Tooling" empty-text="Nothing to install." />
<DraftHint :kind="KIND" :path="`${i}.tooling`" />
</SettingRow>
<SettingRow label="Preflight" hint="Empty: ecosystem default.">
<CommandListEditor v-model="repo.preflight" label="Preflight" empty-text="Ecosystem default." />
<DraftHint :kind="KIND" :path="`${i}.preflight`" />