@nathapp/nax 0.91.5 → 0.91.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/nax.js +387 -123
- package/package.json +2 -2
package/dist/nax.js
CHANGED
|
@@ -38332,7 +38332,7 @@ ${WORKFLOW_ARTIFACTS_RULE}
|
|
|
38332
38332
|
|
|
38333
38333
|
${WORKFLOW_REPLY_CONTRACT}`;
|
|
38334
38334
|
}
|
|
38335
|
-
var WORKFLOW_ARTIFACTS_RULE = "The report is the only place for evidence, command output and notes: write it with the Write or Edit tool (shell redirects into it are blocked). Do not create evidence, log or note files anywhere else in the repository; use your scratchpad (.nax/scratchpad/) for throwaway files.", WORKFLOW_REPLY_CONTRACT = `End your reply with exactly one fenced json block:
|
|
38335
|
+
var WORKFLOW_ARTIFACTS_RULE = "The report is the only place for evidence, command output and notes: write it with the Write or Edit tool (shell redirects into it are blocked). Do not create evidence, log or note files anywhere else in the repository; use your scratchpad (.nax/scratchpad/) for throwaway files.", REPAIR_VERIFICATION_RULE = 'If you cannot run a check here (for example the sandbox blocks its network, or its tool is missing), reply DONE_WITH_CONCERNS and name each such check in "concerns". Never reply DONE for a check you only reasoned about.', WORKFLOW_REPLY_CONTRACT = `End your reply with exactly one fenced json block:
|
|
38336
38336
|
|
|
38337
38337
|
\`\`\`json
|
|
38338
38338
|
{"status": "DONE" | "DONE_WITH_CONCERNS" | "NEEDS_CONTEXT" | "BLOCKED", "commits": ["<sha>"], "testSummary": "<one line>", "concerns": "<empty unless status is not DONE>"}
|
|
@@ -38361,11 +38361,13 @@ function instructions(input) {
|
|
|
38361
38361
|
case "repair":
|
|
38362
38362
|
return `- The items are the gates that were red after the fix.
|
|
38363
38363
|
- Make every command in The bar pass, changing code where the fix broke it.
|
|
38364
|
-
- Commit your changes
|
|
38364
|
+
- Commit your changes.
|
|
38365
|
+
- ${REPAIR_VERIFICATION_RULE}`;
|
|
38365
38366
|
case "prepare":
|
|
38366
38367
|
return `- The items are gates that fail on the unmodified PR head too while CI is green on it, so this checkout differs from CI.
|
|
38367
38368
|
- Make The bar pass by running setup only (code generation, installs, builds).
|
|
38368
|
-
- Do not change, stage or commit any tracked file. A tracked change ends the run without a push
|
|
38369
|
+
- Do not change, stage or commit any tracked file. A tracked change ends the run without a push.
|
|
38370
|
+
- ${REPAIR_VERIFICATION_RULE}`;
|
|
38369
38371
|
}
|
|
38370
38372
|
}
|
|
38371
38373
|
function buildBotPrFixPrompt(input) {
|
|
@@ -38457,7 +38459,8 @@ ${input.checks.map((command) => `- ${command}`).join(`
|
|
|
38457
38459
|
`)}`);
|
|
38458
38460
|
if (input.checkoutState !== undefined)
|
|
38459
38461
|
sections.push(`## Checkout state
|
|
38460
|
-
${input.checkoutState}
|
|
38462
|
+
${input.checkoutState}
|
|
38463
|
+
${COULD_NOT_START_RULE}`);
|
|
38461
38464
|
if (input.ci)
|
|
38462
38465
|
sections.push(ciSection(input.ci));
|
|
38463
38466
|
if (input.settled?.length)
|
|
@@ -38568,7 +38571,7 @@ ${markdownFence(request)}
|
|
|
38568
38571
|
Agreed because:
|
|
38569
38572
|
${markdownFence(reason)}`;
|
|
38570
38573
|
}
|
|
38571
|
-
var MAX_EARLIER_THREADS = 50, MAX_SETTLED_RULINGS = 50, CHECKLIST, INCREMENTAL_REVIEW_NOTE = (sha) => `This is an incremental review: every commit up to ${sha} was already reviewed by an earlier nax review of this pull request. Review only the commits in this range. Judge intent only for what this range changes. Do not list earlier commits, or parts of the PRD or spec this range does not change, in cannotVerify.`, REPLY_TASK = `## Your task
|
|
38574
|
+
var MAX_EARLIER_THREADS = 50, MAX_SETTLED_RULINGS = 50, COULD_NOT_START_RULE = 'If a check stops before it runs any test, for example because a module or workspace package cannot be resolved, it did not run: list it in "cannotVerify" as "could not start: <check>: <reason>" and name the setup step it needs. Never report it as a defect in the change.', CHECKLIST, INCREMENTAL_REVIEW_NOTE = (sha) => `This is an incremental review: every commit up to ${sha} was already reviewed by an earlier nax review of this pull request. Review only the commits in this range. Judge intent only for what this range changes. Do not list earlier commits, or parts of the PRD or spec this range does not change, in cannotVerify.`, REPLY_TASK = `## Your task
|
|
38572
38575
|
Review whether the code fulfills the stated intent and assess its quality. List every file you inspected in inspectedFiles.
|
|
38573
38576
|
Answer every listed thread id and comment id exactly once.
|
|
38574
38577
|
"agree" = the request is right and the code should change; "disagree" = the request is wrong or not worth doing, with the reason; "handled" = the current code already does it.
|
|
@@ -45261,7 +45264,8 @@ var init_session_role = __esm(() => {
|
|
|
45261
45264
|
"wf-story-review",
|
|
45262
45265
|
"wf-rereview",
|
|
45263
45266
|
"wf-branch-review",
|
|
45264
|
-
"wf-branch-fix"
|
|
45267
|
+
"wf-branch-fix",
|
|
45268
|
+
"wf-repair"
|
|
45265
45269
|
];
|
|
45266
45270
|
});
|
|
45267
45271
|
|
|
@@ -49823,7 +49827,7 @@ var package_default;
|
|
|
49823
49827
|
var init_package = __esm(() => {
|
|
49824
49828
|
package_default = {
|
|
49825
49829
|
name: "@nathapp/nax",
|
|
49826
|
-
version: "0.91.
|
|
49830
|
+
version: "0.91.6",
|
|
49827
49831
|
description: "AI Coding Agent Orchestrator \u2014 loops until done",
|
|
49828
49832
|
type: "module",
|
|
49829
49833
|
bin: {
|
|
@@ -49909,7 +49913,7 @@ var init_package = __esm(() => {
|
|
|
49909
49913
|
"@agentclientprotocol/sdk": "~1.7.0",
|
|
49910
49914
|
"@anthropic-ai/sandbox-runtime": "0.0.77",
|
|
49911
49915
|
"@modelcontextprotocol/sdk": "^1.32.1",
|
|
49912
|
-
"@nathapp/nax-ai": "0.91.
|
|
49916
|
+
"@nathapp/nax-ai": "0.91.6",
|
|
49913
49917
|
chalk: "^5.6.2",
|
|
49914
49918
|
commander: "^13.1.0",
|
|
49915
49919
|
ink: "^6.7.0",
|
|
@@ -75199,8 +75203,8 @@ var init_version = __esm(() => {
|
|
|
75199
75203
|
NAX_AI_VERSION = CATALOG_VERSION;
|
|
75200
75204
|
NAX_COMMIT = (() => {
|
|
75201
75205
|
try {
|
|
75202
|
-
if (/^[0-9a-f]{6,10}$/.test("
|
|
75203
|
-
return "
|
|
75206
|
+
if (/^[0-9a-f]{6,10}$/.test("5035cd4"))
|
|
75207
|
+
return "5035cd4";
|
|
75204
75208
|
} catch {}
|
|
75205
75209
|
try {
|
|
75206
75210
|
const result = Bun.spawnSync(["git", "rev-parse", "--short", "HEAD"], {
|
|
@@ -85721,6 +85725,37 @@ var init_workflow_branch_builder = __esm(() => {
|
|
|
85721
85725
|
init_workflow_implementer_builder();
|
|
85722
85726
|
});
|
|
85723
85727
|
|
|
85728
|
+
// src/prompts/builders/workflow-ci-repair-builder.ts
|
|
85729
|
+
function buildWorkflowCiRepairPrompt(input) {
|
|
85730
|
+
const where = input.prUrl ? `pull request ${input.prUrl}` : "this pull request";
|
|
85731
|
+
const documents = [
|
|
85732
|
+
...input.specPath ? [`the spec (${input.specPath})`] : [],
|
|
85733
|
+
...input.prdPath !== undefined ? [`the PRD (${input.prdPath})`] : []
|
|
85734
|
+
];
|
|
85735
|
+
const read = documents.length > 0 ? ` Read ${documents.join(" and ")} for what the feature must do.` : "";
|
|
85736
|
+
return `You are repairing the CI of ${where}.${read} The feature is already on the branch: the failing checks below are the whole of your work.
|
|
85737
|
+
|
|
85738
|
+
## Failing checks
|
|
85739
|
+
${renderWorkflowFindings(input.findings)}
|
|
85740
|
+
|
|
85741
|
+
## How to work
|
|
85742
|
+
- ${CI_REPAIR_NO_SHORTCUTS_RULE}
|
|
85743
|
+
- ${CI_REPAIR_STEP_REPRODUCTION_RULE}
|
|
85744
|
+
- Fix the cause each check reports, then re-run that check's command before you commit.
|
|
85745
|
+
- Before you commit, run the full test command of every package you changed, not only the tests you touched: the repository gates run every suite, and a repair that breaks an unrelated test turns the branch red again.
|
|
85746
|
+
- Commit, then append a "CI repair r${input.round}" section to ${input.reportPath}: what you changed for each check, the test evidence, and any Decisions & assumptions.
|
|
85747
|
+
- ${WORKFLOW_ARTIFACTS_RULE}
|
|
85748
|
+
- Do not dispatch sub-agents or reviewers.
|
|
85749
|
+
|
|
85750
|
+
${REPAIR_VERIFICATION_RULE}
|
|
85751
|
+
|
|
85752
|
+
${WORKFLOW_REPLY_CONTRACT}`;
|
|
85753
|
+
}
|
|
85754
|
+
var CI_REPAIR_NO_SHORTCUTS_RULE = "Never skip, disable or ignore a failing check, and never edit the CI configuration to make it pass.", CI_REPAIR_STEP_REPRODUCTION_RULE = "A CI job stops at its first failing step, so a step CI skipped never ran: reproduce the failing step and every skipped step locally.";
|
|
85755
|
+
var init_workflow_ci_repair_builder = __esm(() => {
|
|
85756
|
+
init_workflow_implementer_builder();
|
|
85757
|
+
});
|
|
85758
|
+
|
|
85724
85759
|
// src/prompts/builders/workflow-re-review-builder.ts
|
|
85725
85760
|
function buildWorkflowReReviewPrompt(input) {
|
|
85726
85761
|
return `You are checking one fix round. Read the brief (${input.briefPath}), the report (${input.reportPath}, see its latest "Fix round" section) and the fix package (${input.packagePath}). The package holds only this fix diff.
|
|
@@ -85860,6 +85895,7 @@ var init_prompts = __esm(() => {
|
|
|
85860
85895
|
init_rules_index_builder();
|
|
85861
85896
|
init_tdd_builder();
|
|
85862
85897
|
init_workflow_branch_builder();
|
|
85898
|
+
init_workflow_ci_repair_builder();
|
|
85863
85899
|
init_workflow_implementer_builder();
|
|
85864
85900
|
init_workflow_re_review_builder();
|
|
85865
85901
|
init_workflow_story_review_builder();
|
|
@@ -93957,6 +93993,17 @@ var init_workflow_re_review = __esm(() => {
|
|
|
93957
93993
|
};
|
|
93958
93994
|
});
|
|
93959
93995
|
|
|
93996
|
+
// src/operations/workflow-repair.ts
|
|
93997
|
+
var workflowRepairOp;
|
|
93998
|
+
var init_workflow_repair = __esm(() => {
|
|
93999
|
+
init_workflow_branch_fix();
|
|
94000
|
+
workflowRepairOp = {
|
|
94001
|
+
...workflowBranchFixOp,
|
|
94002
|
+
name: "workflow-repair",
|
|
94003
|
+
session: { role: "wf-repair", lifetime: "fresh" }
|
|
94004
|
+
};
|
|
94005
|
+
});
|
|
94006
|
+
|
|
93960
94007
|
// src/operations/write-test.ts
|
|
93961
94008
|
var testWriterOp;
|
|
93962
94009
|
var init_write_test = __esm(() => {
|
|
@@ -94080,6 +94127,7 @@ var init_operations = __esm(() => {
|
|
|
94080
94127
|
init_workflow_branch_review();
|
|
94081
94128
|
init_workflow_implement();
|
|
94082
94129
|
init_workflow_re_review();
|
|
94130
|
+
init_workflow_repair();
|
|
94083
94131
|
init_workflow_replies();
|
|
94084
94132
|
init_workflow_review_coverage();
|
|
94085
94133
|
init_workflow_story_review();
|
|
@@ -99507,6 +99555,50 @@ var init_job_log = __esm(() => {
|
|
|
99507
99555
|
ANSI_CSI = /\u001b\[[\x20-\x3f]*[\x40-\x7e]/g;
|
|
99508
99556
|
});
|
|
99509
99557
|
|
|
99558
|
+
// src/forge/job-steps.ts
|
|
99559
|
+
function stepsOf(reply) {
|
|
99560
|
+
if (typeof reply !== "object" || reply === null)
|
|
99561
|
+
return null;
|
|
99562
|
+
const steps = reply.steps;
|
|
99563
|
+
return Array.isArray(steps) ? steps : null;
|
|
99564
|
+
}
|
|
99565
|
+
function toStep(value) {
|
|
99566
|
+
if (typeof value !== "object" || value === null)
|
|
99567
|
+
return null;
|
|
99568
|
+
const step = value;
|
|
99569
|
+
if (typeof step.name !== "string" || step.name.length === 0)
|
|
99570
|
+
return null;
|
|
99571
|
+
return { name: step.name, conclusion: typeof step.conclusion === "string" ? step.conclusion : "" };
|
|
99572
|
+
}
|
|
99573
|
+
function summarize(steps) {
|
|
99574
|
+
const at = steps.findIndex((step) => step.conclusion === FAILED);
|
|
99575
|
+
const after = at === -1 ? [] : steps.slice(at);
|
|
99576
|
+
const failedStep = after[0]?.name;
|
|
99577
|
+
if (failedStep === undefined)
|
|
99578
|
+
return {};
|
|
99579
|
+
const skippedSteps = after.slice(1).filter((step) => step.conclusion === SKIPPED).map((step) => step.name);
|
|
99580
|
+
return { failedStep, ...skippedSteps.length === 0 ? {} : { skippedSteps } };
|
|
99581
|
+
}
|
|
99582
|
+
function jobStepsArgv(ref, jobId) {
|
|
99583
|
+
return ["gh", "api", "--hostname", ref.host, `repos/${ref.repo}/actions/jobs/${jobId}`];
|
|
99584
|
+
}
|
|
99585
|
+
async function readJobSteps(ref, jobId, deps, cwd) {
|
|
99586
|
+
let reply;
|
|
99587
|
+
try {
|
|
99588
|
+
const result = await deps.run(jobStepsArgv(ref, jobId), { cwd });
|
|
99589
|
+
if (result.exitCode !== 0)
|
|
99590
|
+
return {};
|
|
99591
|
+
reply = JSON.parse(result.stdout);
|
|
99592
|
+
} catch {
|
|
99593
|
+
return {};
|
|
99594
|
+
}
|
|
99595
|
+
const steps = stepsOf(reply);
|
|
99596
|
+
if (steps === null)
|
|
99597
|
+
return {};
|
|
99598
|
+
return summarize(steps.map(toStep).filter((step) => step !== null));
|
|
99599
|
+
}
|
|
99600
|
+
var FAILED = "failure", SKIPPED = "skipped";
|
|
99601
|
+
|
|
99510
99602
|
// src/forge/ci-failures.ts
|
|
99511
99603
|
function prNumberFromUrl(url) {
|
|
99512
99604
|
const match = PR_NUMBER.exec(url);
|
|
@@ -99617,16 +99709,26 @@ function invalidReply(what, context) {
|
|
|
99617
99709
|
...context
|
|
99618
99710
|
});
|
|
99619
99711
|
}
|
|
99712
|
+
function actionsJobId(run) {
|
|
99713
|
+
if (run.app?.slug !== ACTIONS_APP)
|
|
99714
|
+
return;
|
|
99715
|
+
return run.id === undefined ? undefined : String(run.id);
|
|
99716
|
+
}
|
|
99620
99717
|
async function readExcerpt(run, ref, deps, cwd) {
|
|
99621
|
-
const jobId = run
|
|
99718
|
+
const jobId = actionsJobId(run);
|
|
99622
99719
|
if (jobId === undefined)
|
|
99623
99720
|
return { excerpt: ciExcerpt(outputText(run)) };
|
|
99624
|
-
return logExcerpt(await readJobLog(ref,
|
|
99721
|
+
return logExcerpt(await readJobLog(ref, jobId, deps, cwd), true);
|
|
99722
|
+
}
|
|
99723
|
+
async function readSteps(run, ref, deps, cwd) {
|
|
99724
|
+
const jobId = actionsJobId(run);
|
|
99725
|
+
return jobId === undefined ? {} : readJobSteps(ref, jobId, deps, cwd);
|
|
99625
99726
|
}
|
|
99626
99727
|
async function toFailedCheck(run, ref, deps, cwd) {
|
|
99627
99728
|
const log = await readExcerpt(run, ref, deps, cwd);
|
|
99729
|
+
const steps = await readSteps(run, ref, deps, cwd);
|
|
99628
99730
|
const url = run.html_url && run.html_url.length > 0 ? run.html_url : undefined;
|
|
99629
|
-
return { name: run.name ?? "", ...url === undefined ? {} : { url }, ...log };
|
|
99731
|
+
return { name: run.name ?? "", ...url === undefined ? {} : { url }, ...log, ...steps };
|
|
99630
99732
|
}
|
|
99631
99733
|
async function readGithubFailedChecks(ref, headSha, deps, cwd) {
|
|
99632
99734
|
const endpoint = `repos/${ref.repo}/commits/${headSha}/check-runs?per_page=100&filter=latest`;
|
|
@@ -99703,7 +99805,7 @@ async function readFailedChecks(ref, headSha, deps, cwd) {
|
|
|
99703
99805
|
var MAX_FAILED_CHECKS = 5, CI_EXCERPT_LINES = 200, PR_NUMBER, PASSED_CONCLUSIONS, ANNOTATION_HEADER = "GitHub Actions error annotations:", LOG_TAIL_SEPARATOR = `
|
|
99704
99806
|
|
|
99705
99807
|
Log tail:
|
|
99706
|
-
|
|
99808
|
+
`, ACTIONS_APP = "github-actions";
|
|
99707
99809
|
var init_ci_failures = __esm(() => {
|
|
99708
99810
|
init_errors4();
|
|
99709
99811
|
init_logger2();
|
|
@@ -116711,11 +116813,12 @@ var init_rule_delivery = __esm(() => {
|
|
|
116711
116813
|
RULE_READ_ROLES = Object.freeze([
|
|
116712
116814
|
"wf-implementer",
|
|
116713
116815
|
"wf-branch-fix",
|
|
116816
|
+
"wf-repair",
|
|
116714
116817
|
"wf-story-review",
|
|
116715
116818
|
"wf-rereview",
|
|
116716
116819
|
"wf-branch-review"
|
|
116717
116820
|
]);
|
|
116718
|
-
RULE_WRITE_ROLES = Object.freeze(["wf-implementer", "wf-branch-fix"]);
|
|
116821
|
+
RULE_WRITE_ROLES = Object.freeze(["wf-implementer", "wf-branch-fix", "wf-repair"]);
|
|
116719
116822
|
_ruleDeliveryDeps = { rulesForFile, resolveRuleSet };
|
|
116720
116823
|
});
|
|
116721
116824
|
|
|
@@ -125698,13 +125801,13 @@ async function ensureReport(fc) {
|
|
|
125698
125801
|
The branch fix appends its section below.
|
|
125699
125802
|
`);
|
|
125700
125803
|
}
|
|
125701
|
-
async function commitLeftovers(fc) {
|
|
125804
|
+
async function commitLeftovers(fc, role) {
|
|
125702
125805
|
let hasEdits = false;
|
|
125703
125806
|
try {
|
|
125704
125807
|
if ((await listUncommitted(fc.projectDir)).length === 0)
|
|
125705
125808
|
return { autoCommitted: false, dirty: false };
|
|
125706
125809
|
hasEdits = true;
|
|
125707
|
-
await _workflowDeps.autoCommitIfDirty(fc.projectDir, "workflow",
|
|
125810
|
+
await _workflowDeps.autoCommitIfDirty(fc.projectDir, "workflow", role, FEATURE_SCOPE, undefined, fc.dryRun, fc.runGit);
|
|
125708
125811
|
return { autoCommitted: true, dirty: false };
|
|
125709
125812
|
} catch (err) {
|
|
125710
125813
|
if (fc.runSignal?.aborted)
|
|
@@ -125716,11 +125819,14 @@ async function commitLeftovers(fc) {
|
|
|
125716
125819
|
return { autoCommitted: false, dirty: hasEdits };
|
|
125717
125820
|
}
|
|
125718
125821
|
}
|
|
125719
|
-
|
|
125720
|
-
|
|
125822
|
+
function dispatchFor(kind) {
|
|
125823
|
+
return kind === "repair" ? { op: workflowRepairOp, role: "wf-repair" } : { op: workflowBranchFixOp, role: "wf-branch-fix" };
|
|
125824
|
+
}
|
|
125825
|
+
async function runFixSession(fc, op, input) {
|
|
125826
|
+
const { model, toolProviders, prompt } = input;
|
|
125721
125827
|
const callCtx = toolProviders?.length ? { ...fc.callCtx, toolProviders } : fc.callCtx;
|
|
125722
125828
|
try {
|
|
125723
|
-
const reply = await _workflowDeps.callOp(callCtx,
|
|
125829
|
+
const reply = await _workflowDeps.callOp(callCtx, op, {
|
|
125724
125830
|
prompt,
|
|
125725
125831
|
...model !== undefined ? { model } : {},
|
|
125726
125832
|
timeoutMs: fc.workflow.timeouts.fixMs,
|
|
@@ -125733,16 +125839,28 @@ async function runFixSession(fc, prompt, input) {
|
|
|
125733
125839
|
return { failure: errorMessage(err) };
|
|
125734
125840
|
}
|
|
125735
125841
|
}
|
|
125842
|
+
function promptFor(fc, input) {
|
|
125843
|
+
if (input.prompt !== undefined)
|
|
125844
|
+
return input.prompt;
|
|
125845
|
+
const prd = fc.prdPath !== undefined ? { prdPath: fc.prdPath } : {};
|
|
125846
|
+
const spec = input.specPath ? { specPath: input.specPath } : {};
|
|
125847
|
+
if (input.ciRepair) {
|
|
125848
|
+
return buildWorkflowCiRepairPrompt({
|
|
125849
|
+
...spec,
|
|
125850
|
+
...prd,
|
|
125851
|
+
round: input.ciRepair.round,
|
|
125852
|
+
...input.ciRepair.prUrl ? { prUrl: input.ciRepair.prUrl } : {},
|
|
125853
|
+
reportPath: fc.reportPath,
|
|
125854
|
+
findings: input.findings
|
|
125855
|
+
});
|
|
125856
|
+
}
|
|
125857
|
+
return buildWorkflowBranchFixPrompt({ ...spec, ...prd, reportPath: fc.reportPath, findings: input.findings });
|
|
125858
|
+
}
|
|
125736
125859
|
async function runBranchFix(fc, input) {
|
|
125737
125860
|
await ensureReport(fc);
|
|
125738
|
-
const
|
|
125739
|
-
|
|
125740
|
-
|
|
125741
|
-
reportPath: fc.reportPath,
|
|
125742
|
-
findings: input.findings
|
|
125743
|
-
});
|
|
125744
|
-
const session = await runFixSession(fc, prompt, input);
|
|
125745
|
-
return { ...session, ...await commitLeftovers(fc) };
|
|
125861
|
+
const { op, role } = dispatchFor(input.kind);
|
|
125862
|
+
const session = await runFixSession(fc, op, { ...input, prompt: promptFor(fc, input) });
|
|
125863
|
+
return { ...session, ...await commitLeftovers(fc, role) };
|
|
125746
125864
|
}
|
|
125747
125865
|
var init_branch_fix = __esm(() => {
|
|
125748
125866
|
init_internal();
|
|
@@ -128864,7 +128982,7 @@ function turnTimeoutMs(sc, turn) {
|
|
|
128864
128982
|
return Math.floor(continueLimitMs(sc, turn) * sc.workflow.interruptRetry.budgetMultiplier);
|
|
128865
128983
|
return turn.kind === "implement" || turn.kind === "restart" || turn.kind === "answer" && turn.limit === "implement" ? sc.workflow.timeouts.implementMs : sc.workflow.timeouts.fixMs;
|
|
128866
128984
|
}
|
|
128867
|
-
function
|
|
128985
|
+
function promptFor2(sc, turn) {
|
|
128868
128986
|
const paths = { storyId: sc.story.id, briefPath: sc.briefPath, reportPath: sc.reportPath };
|
|
128869
128987
|
const e2eGate = sc.config.quality?.commands?.e2e !== undefined;
|
|
128870
128988
|
if (turn.kind === "implement")
|
|
@@ -128948,7 +129066,7 @@ async function runImplementerTurn(sc, turn) {
|
|
|
128948
129066
|
try {
|
|
128949
129067
|
reply = await _workflowDeps.callOp(sc.callCtx, workflowImplementOp, {
|
|
128950
129068
|
story: sc.story,
|
|
128951
|
-
prompt:
|
|
129069
|
+
prompt: promptFor2(sc, turn),
|
|
128952
129070
|
reportPath: sc.reportPath,
|
|
128953
129071
|
...model !== undefined ? { model } : {},
|
|
128954
129072
|
timeoutMs: turnTimeoutMs(sc, turn)
|
|
@@ -129208,6 +129326,8 @@ function buildFeatureEnv(fc, input, ctx) {
|
|
|
129208
129326
|
branchFix: (findings, opts) => toolErrors("branch-fix", () => runBranchFix(fc, {
|
|
129209
129327
|
...spec,
|
|
129210
129328
|
findings,
|
|
129329
|
+
...opts?.repair ? { kind: "repair" } : {},
|
|
129330
|
+
...opts?.ciRound !== undefined ? { ciRepair: { round: opts.ciRound, ...opts.prUrl ? { prUrl: opts.prUrl } : {} } } : {},
|
|
129211
129331
|
...opts?.prUrl ? { toolProviders: [forgeReadProviderForUrl(opts.prUrl, _featureDeps.forge, fc.projectDir)] } : {}
|
|
129212
129332
|
})),
|
|
129213
129333
|
branchReReview: (findings, fixBase) => toolErrors("branch-rereview", () => runBranchReReview(fc, { ...spec, findings, fixBase })),
|
|
@@ -129576,6 +129696,164 @@ var init_branch_fix_rounds = __esm(() => {
|
|
|
129576
129696
|
NONE4 = { targets: [], notes: [] };
|
|
129577
129697
|
});
|
|
129578
129698
|
|
|
129699
|
+
// src/workflow/feature-step-helpers.ts
|
|
129700
|
+
var DEFAULT_LIMITS2, limitsOf = (env) => env.limits ?? DEFAULT_LIMITS2, costExceeded = (env) => env.costExceeded?.() === true, NO_MIRROR, featureStep = (label, announce = true, bare = false, model) => startStep(FEATURE_SCOPE, label, { announce, bare, model }), roundLabel = (base, round) => round > 1 ? `${base} r${round}` : base;
|
|
129701
|
+
var init_feature_step_helpers = __esm(() => {
|
|
129702
|
+
init_config();
|
|
129703
|
+
init_advisor_live();
|
|
129704
|
+
init_run_log();
|
|
129705
|
+
DEFAULT_LIMITS2 = {
|
|
129706
|
+
maxBranchFixRounds: WORKFLOW_DEFAULTS.maxBranchFixRounds,
|
|
129707
|
+
finalGateRepairRounds: WORKFLOW_DEFAULTS.finalGateRepairRounds,
|
|
129708
|
+
ciRepairRounds: WORKFLOW_DEFAULTS.ciRepairRounds
|
|
129709
|
+
};
|
|
129710
|
+
NO_MIRROR = { mirror: false };
|
|
129711
|
+
});
|
|
129712
|
+
|
|
129713
|
+
// src/workflow/ci-repair-steps.ts
|
|
129714
|
+
function ciCheckIssue(check) {
|
|
129715
|
+
if (!check.failedStep)
|
|
129716
|
+
return `CI check ${check.name} failed:
|
|
129717
|
+
${check.excerpt}`;
|
|
129718
|
+
const skipped = check.skippedSteps ?? [];
|
|
129719
|
+
const skippedLine = skipped.length > 0 ? `
|
|
129720
|
+
Steps CI skipped after it, which never ran: ${skipped.join(", ")}` : "";
|
|
129721
|
+
return `CI check ${check.name} failed at step "${check.failedStep}".${skippedLine}
|
|
129722
|
+
${check.excerpt}`;
|
|
129723
|
+
}
|
|
129724
|
+
function ciRepairFindingsOf(checks) {
|
|
129725
|
+
return checks.map((check) => ({
|
|
129726
|
+
kind: "gate",
|
|
129727
|
+
severity: "important",
|
|
129728
|
+
issue: ciCheckIssue(check),
|
|
129729
|
+
...check.url ? { suggestion: `See ${check.url}` } : {}
|
|
129730
|
+
}));
|
|
129731
|
+
}
|
|
129732
|
+
function ciRepairTargetsOf(checks) {
|
|
129733
|
+
return checks.map((check) => ({
|
|
129734
|
+
name: check.name,
|
|
129735
|
+
...check.failedStep ? { failedStep: check.failedStep } : {}
|
|
129736
|
+
}));
|
|
129737
|
+
}
|
|
129738
|
+
async function readCiFailuresForRepair(env, reader, url, head) {
|
|
129739
|
+
let checks;
|
|
129740
|
+
try {
|
|
129741
|
+
checks = await reader({ url, head });
|
|
129742
|
+
} catch (err) {
|
|
129743
|
+
await env.sink.ledger(ledgerText.note(`CI logs unavailable: ${errorMessage(err)}`), NO_MIRROR);
|
|
129744
|
+
return;
|
|
129745
|
+
}
|
|
129746
|
+
if (checks.length === 0) {
|
|
129747
|
+
await env.sink.ledger(ledgerText.note(`CI failed but no failed check was found for ${head}`), NO_MIRROR);
|
|
129748
|
+
return;
|
|
129749
|
+
}
|
|
129750
|
+
if (checks.every((check) => check.logUnavailable === true)) {
|
|
129751
|
+
await env.sink.ledger(ledgerText.note(`CI repair skipped: no failed check's log could be read (${checks.map((check) => check.name).join(", ")})`), NO_MIRROR);
|
|
129752
|
+
return;
|
|
129753
|
+
}
|
|
129754
|
+
await env.sink.ledger(ledgerText.note(`CI failed: ${checks.map((check) => check.name).join(", ")} (repairing)`), NO_MIRROR);
|
|
129755
|
+
return { findings: ciRepairFindingsOf(checks), targets: ciRepairTargetsOf(checks) };
|
|
129756
|
+
}
|
|
129757
|
+
async function ciRepairPlan(env, rec, out, head) {
|
|
129758
|
+
const reader = env.steps.readCiFailures;
|
|
129759
|
+
if (!reader)
|
|
129760
|
+
return;
|
|
129761
|
+
if (out.outcome !== "draft" || out.ci !== "failed")
|
|
129762
|
+
return;
|
|
129763
|
+
if (!out.url || !head)
|
|
129764
|
+
return;
|
|
129765
|
+
if ((rec.ciRepairRounds ?? 0) >= (limitsOf(env).ciRepairRounds ?? 0))
|
|
129766
|
+
return;
|
|
129767
|
+
if (costExceeded(env))
|
|
129768
|
+
return;
|
|
129769
|
+
return await readCiFailuresForRepair(env, reader, out.url, head);
|
|
129770
|
+
}
|
|
129771
|
+
function repairRoundsSpent(env, rounds) {
|
|
129772
|
+
return rounds >= 1 && rounds >= (limitsOf(env).ciRepairRounds ?? 0);
|
|
129773
|
+
}
|
|
129774
|
+
function sameTarget(target, check) {
|
|
129775
|
+
return target.name === check.name && target.failedStep === check.failedStep;
|
|
129776
|
+
}
|
|
129777
|
+
function ciRemainingCheckOf(targets, check) {
|
|
129778
|
+
return {
|
|
129779
|
+
name: check.name,
|
|
129780
|
+
...check.failedStep ? { failedStep: check.failedStep } : {},
|
|
129781
|
+
newFailure: !targets.some((target) => sameTarget(target, check))
|
|
129782
|
+
};
|
|
129783
|
+
}
|
|
129784
|
+
function stillFailingNote(rounds, remaining) {
|
|
129785
|
+
const checks = remaining.map((check) => {
|
|
129786
|
+
const step = check.failedStep ? ` at step "${check.failedStep}"` : "";
|
|
129787
|
+
return `${check.name}${step} (${check.newFailure ? "new failure" : "still failing"})`;
|
|
129788
|
+
});
|
|
129789
|
+
return `CI still failing after ${rounds} repair round(s): ${checks.join("; ")}`;
|
|
129790
|
+
}
|
|
129791
|
+
async function ciRemainingAfterRepair(env, rec, out, head) {
|
|
129792
|
+
const reader = env.steps.readCiFailures;
|
|
129793
|
+
if (!reader)
|
|
129794
|
+
return;
|
|
129795
|
+
if (out.outcome !== "draft" || out.ci !== "failed")
|
|
129796
|
+
return;
|
|
129797
|
+
if (!out.url || !head)
|
|
129798
|
+
return;
|
|
129799
|
+
const rounds = rec.ciRepairRounds ?? 0;
|
|
129800
|
+
if (!repairRoundsSpent(env, rounds))
|
|
129801
|
+
return;
|
|
129802
|
+
let checks;
|
|
129803
|
+
try {
|
|
129804
|
+
checks = await reader({ url: out.url, head });
|
|
129805
|
+
} catch (err) {
|
|
129806
|
+
await env.sink.ledger(ledgerText.note(`CI logs unavailable: ${errorMessage(err)}`), NO_MIRROR);
|
|
129807
|
+
return;
|
|
129808
|
+
}
|
|
129809
|
+
if (checks.length === 0)
|
|
129810
|
+
return;
|
|
129811
|
+
const targets = rec.ciRepairTargets ?? [];
|
|
129812
|
+
const remaining = checks.map((check) => ciRemainingCheckOf(targets, check));
|
|
129813
|
+
await env.sink.ledger(ledgerText.note(stillFailingNote(rounds, remaining)), NO_MIRROR);
|
|
129814
|
+
return remaining;
|
|
129815
|
+
}
|
|
129816
|
+
async function ciRepairStep(env, rec) {
|
|
129817
|
+
const round = (rec.ciRepairRounds ?? 0) + 1;
|
|
129818
|
+
const max = limitsOf(env).ciRepairRounds ?? 0;
|
|
129819
|
+
if (round > max) {
|
|
129820
|
+
await env.sink.ledger(ledgerText.note(`CI repair skipped: round ${round} is past workflow.ciRepairRounds (${max})`), NO_MIRROR);
|
|
129821
|
+
return { patch: {} };
|
|
129822
|
+
}
|
|
129823
|
+
const findings = (rec.ciRepairFindings ?? []).map((d, i) => ({ ...d, id: `C${i + 1}` }));
|
|
129824
|
+
if (findings.length === 0)
|
|
129825
|
+
return { patch: { ciRepairRounds: round } };
|
|
129826
|
+
const list = findings.map((f) => f.id);
|
|
129827
|
+
await env.sink.ledger(ledgerText.note(`CI repair r${round}: ${findings.length} item(s): ${list.join(", ")}`), NO_MIRROR);
|
|
129828
|
+
const log = featureStep(roundLabel("ci-repair", round), true, false, env.steps.modelFor?.("branch-fix"));
|
|
129829
|
+
const out = await env.steps.branchFix(findings, {
|
|
129830
|
+
repair: true,
|
|
129831
|
+
...rec.url ? { prUrl: rec.url } : {},
|
|
129832
|
+
ciRound: round
|
|
129833
|
+
});
|
|
129834
|
+
log.done(`${list.join(" ")}${out.failure ? ` (session failed: ${out.failure})` : ""}`);
|
|
129835
|
+
if (out.failure)
|
|
129836
|
+
await env.sink.ledger(ledgerText.note(`CI repair session failed: ${out.failure}`), NO_MIRROR);
|
|
129837
|
+
if (out.autoCommitted)
|
|
129838
|
+
await env.sink.ledger(ledgerText.note("auto-committed the CI repair's edits"));
|
|
129839
|
+
if (out.dirty)
|
|
129840
|
+
await env.sink.ledger(ledgerText.note("CI repair left uncommitted edits: the auto-commit failed"));
|
|
129841
|
+
const concerns = out.reply?.concerns?.trim() ?? "";
|
|
129842
|
+
const raised = await noteConcerns(env, round, concerns, rec.ciRepairConcerns ?? []);
|
|
129843
|
+
return { patch: { ciRepairRounds: round, ciRepairFindings: undefined, ...raised } };
|
|
129844
|
+
}
|
|
129845
|
+
async function noteConcerns(env, round, concerns, history) {
|
|
129846
|
+
if (concerns.length === 0)
|
|
129847
|
+
return {};
|
|
129848
|
+
await env.sink.ledger(ledgerText.note(`CI repair r${round} concerns: ${concerns}`), NO_MIRROR);
|
|
129849
|
+
return { ciRepairConcerns: [...history, `r${round}: ${concerns}`] };
|
|
129850
|
+
}
|
|
129851
|
+
var init_ci_repair_steps = __esm(() => {
|
|
129852
|
+
init_internal();
|
|
129853
|
+
init_feature_step_helpers();
|
|
129854
|
+
init_ledger3();
|
|
129855
|
+
});
|
|
129856
|
+
|
|
129579
129857
|
// src/workflow/gate-timing.ts
|
|
129580
129858
|
function isGateTimingItem(text) {
|
|
129581
129859
|
const body = text.replace(ZERO_FAIL, "");
|
|
@@ -129985,7 +130263,7 @@ async function gateRepairStep(env, rec) {
|
|
|
129985
130263
|
const list = findings.map((f) => f.id);
|
|
129986
130264
|
await env.sink.ledger(ledgerText.note(`gate repair r${round}: ${findings.length} item(s): ${list.join(", ")}`), NO_MIRROR);
|
|
129987
130265
|
const log = featureStep(roundLabel("gate-repair", round), true, false, env.steps.modelFor?.("branch-fix"));
|
|
129988
|
-
const out = await env.steps.branchFix(findings);
|
|
130266
|
+
const out = await env.steps.branchFix(findings, { repair: true });
|
|
129989
130267
|
log.done(`${list.join(" ")}${out.failure ? ` (session failed: ${out.failure})` : ""}`);
|
|
129990
130268
|
if (out.failure)
|
|
129991
130269
|
await env.sink.ledger(ledgerText.note(`gate repair session failed: ${out.failure}`), NO_MIRROR);
|
|
@@ -129995,29 +130273,6 @@ async function gateRepairStep(env, rec) {
|
|
|
129995
130273
|
await env.sink.ledger(ledgerText.note("gate repair left uncommitted edits: the auto-commit failed"));
|
|
129996
130274
|
return { patch: { gateRepairRounds: round } };
|
|
129997
130275
|
}
|
|
129998
|
-
async function ciRepairStep(env, rec) {
|
|
129999
|
-
const round = (rec.ciRepairRounds ?? 0) + 1;
|
|
130000
|
-
const max = limitsOf(env).ciRepairRounds ?? 0;
|
|
130001
|
-
if (round > max) {
|
|
130002
|
-
await env.sink.ledger(ledgerText.note(`CI repair skipped: round ${round} is past workflow.ciRepairRounds (${max})`), NO_MIRROR);
|
|
130003
|
-
return { patch: {} };
|
|
130004
|
-
}
|
|
130005
|
-
const findings = (rec.ciRepairFindings ?? []).map((d, i) => ({ ...d, id: `C${i + 1}` }));
|
|
130006
|
-
if (findings.length === 0)
|
|
130007
|
-
return { patch: { ciRepairRounds: round } };
|
|
130008
|
-
const list = findings.map((f) => f.id);
|
|
130009
|
-
await env.sink.ledger(ledgerText.note(`CI repair r${round}: ${findings.length} item(s): ${list.join(", ")}`), NO_MIRROR);
|
|
130010
|
-
const log = featureStep(roundLabel("ci-repair", round), true, false, env.steps.modelFor?.("branch-fix"));
|
|
130011
|
-
const out = await (rec.url ? env.steps.branchFix(findings, { prUrl: rec.url }) : env.steps.branchFix(findings));
|
|
130012
|
-
log.done(`${list.join(" ")}${out.failure ? ` (session failed: ${out.failure})` : ""}`);
|
|
130013
|
-
if (out.failure)
|
|
130014
|
-
await env.sink.ledger(ledgerText.note(`CI repair session failed: ${out.failure}`), NO_MIRROR);
|
|
130015
|
-
if (out.autoCommitted)
|
|
130016
|
-
await env.sink.ledger(ledgerText.note("auto-committed the CI repair's edits"));
|
|
130017
|
-
if (out.dirty)
|
|
130018
|
-
await env.sink.ledger(ledgerText.note("CI repair left uncommitted edits: the auto-commit failed"));
|
|
130019
|
-
return { patch: { ciRepairRounds: round, ciRepairFindings: undefined } };
|
|
130020
|
-
}
|
|
130021
130276
|
async function collectFlaggedDecisions(env) {
|
|
130022
130277
|
if (!env.steps.flaggedDecisions)
|
|
130023
130278
|
return [];
|
|
@@ -130042,48 +130297,6 @@ async function readHeadSoft(env) {
|
|
|
130042
130297
|
return;
|
|
130043
130298
|
}
|
|
130044
130299
|
}
|
|
130045
|
-
function ciRepairFindingsOf(checks) {
|
|
130046
|
-
return checks.map((check) => ({
|
|
130047
|
-
kind: "gate",
|
|
130048
|
-
severity: "important",
|
|
130049
|
-
issue: `CI check ${check.name} failed:
|
|
130050
|
-
${check.excerpt}`,
|
|
130051
|
-
...check.url ? { suggestion: `See ${check.url}` } : {}
|
|
130052
|
-
}));
|
|
130053
|
-
}
|
|
130054
|
-
async function readCiFailuresForRepair(env, reader, url, head) {
|
|
130055
|
-
let checks;
|
|
130056
|
-
try {
|
|
130057
|
-
checks = await reader({ url, head });
|
|
130058
|
-
} catch (err) {
|
|
130059
|
-
await env.sink.ledger(ledgerText.note(`CI logs unavailable: ${errorMessage(err)}`), NO_MIRROR);
|
|
130060
|
-
return;
|
|
130061
|
-
}
|
|
130062
|
-
if (checks.length === 0) {
|
|
130063
|
-
await env.sink.ledger(ledgerText.note(`CI failed but no failed check was found for ${head}`), NO_MIRROR);
|
|
130064
|
-
return;
|
|
130065
|
-
}
|
|
130066
|
-
if (checks.every((check) => check.logUnavailable === true)) {
|
|
130067
|
-
await env.sink.ledger(ledgerText.note(`CI repair skipped: no failed check's log could be read (${checks.map((check) => check.name).join(", ")})`), NO_MIRROR);
|
|
130068
|
-
return;
|
|
130069
|
-
}
|
|
130070
|
-
await env.sink.ledger(ledgerText.note(`CI failed: ${checks.map((check) => check.name).join(", ")} (repairing)`), NO_MIRROR);
|
|
130071
|
-
return ciRepairFindingsOf(checks);
|
|
130072
|
-
}
|
|
130073
|
-
async function ciRepairDecision(env, rec, out, head) {
|
|
130074
|
-
const reader = env.steps.readCiFailures;
|
|
130075
|
-
if (!reader)
|
|
130076
|
-
return;
|
|
130077
|
-
if (out.outcome !== "draft" || out.ci !== "failed")
|
|
130078
|
-
return;
|
|
130079
|
-
if (!out.url || !head)
|
|
130080
|
-
return;
|
|
130081
|
-
if ((rec.ciRepairRounds ?? 0) >= (limitsOf(env).ciRepairRounds ?? 0))
|
|
130082
|
-
return;
|
|
130083
|
-
if (costExceeded(env))
|
|
130084
|
-
return;
|
|
130085
|
-
return await readCiFailuresForRepair(env, reader, out.url, head);
|
|
130086
|
-
}
|
|
130087
130300
|
async function publishStep(env, rec) {
|
|
130088
130301
|
const log = featureStep("publish", false, true);
|
|
130089
130302
|
const out = await env.steps.publish(rec);
|
|
@@ -130093,7 +130306,8 @@ async function publishStep(env, rec) {
|
|
|
130093
130306
|
const why = out.reasons.length > 0 ? `: ${out.reasons.join("; ")}` : "";
|
|
130094
130307
|
log.done(`${out.outcome}${out.url ? ` ${out.url}` : ""}${why}`);
|
|
130095
130308
|
await env.sink.ledger(ledgerText.note(`feature ${out.outcome}${out.url ? ` ${out.url}` : ""}${why}`), NO_MIRROR);
|
|
130096
|
-
const
|
|
130309
|
+
const ciPlan = await ciRepairPlan(env, rec, out, head);
|
|
130310
|
+
const ciRemaining = await ciRemainingAfterRepair(env, rec, out, head);
|
|
130097
130311
|
return {
|
|
130098
130312
|
patch: {
|
|
130099
130313
|
outcome: out.outcome,
|
|
@@ -130110,31 +130324,27 @@ async function publishStep(env, rec) {
|
|
|
130110
130324
|
...head ? { head } : {},
|
|
130111
130325
|
passed: featurePassed({ ...rec.finalGates ? { finalGates: rec.finalGates } : {}, stories: env.facts.stories }),
|
|
130112
130326
|
...flagged.length > 0 || rec.flaggedDecisions !== undefined ? { flaggedDecisions: flagged } : {},
|
|
130113
|
-
...
|
|
130327
|
+
...ciPlan ? { ciRepairFindings: ciPlan.findings, ciRepairTargets: ciPlan.targets } : {},
|
|
130328
|
+
...ciRemaining ? { ciRemaining } : {},
|
|
130114
130329
|
endedAt: new Date().toISOString()
|
|
130115
130330
|
},
|
|
130116
|
-
...
|
|
130331
|
+
...ciPlan ? { exit: "ci-repair" } : {}
|
|
130117
130332
|
};
|
|
130118
130333
|
}
|
|
130119
|
-
var
|
|
130334
|
+
var isBlocking = (f) => f.severity !== "minor", minorIssues = (drafts) => drafts.filter((f) => !isBlocking(f)).map((f) => f.issue), fixRoundsOf = (rec) => rec.fixRounds ?? (rec.fixRan ? 1 : 0), isFollowUpRound = (rec) => fixRoundsOf(rec) >= 1 && (rec.fixTargets?.length ?? 0) > 0, gatesText = (failing) => failing.length > 0 ? `red (${failing.join(", ")})` : "green", QUALITY_CHANGES_ISSUE = "quality: reviewer reported changes without a finding";
|
|
130120
130335
|
var init_feature_steps = __esm(() => {
|
|
130121
130336
|
init_internal();
|
|
130122
|
-
init_config();
|
|
130123
130337
|
init_logger2();
|
|
130124
|
-
init_advisor_live();
|
|
130125
130338
|
init_approval();
|
|
130126
130339
|
init_branch_fix_rounds();
|
|
130340
|
+
init_ci_repair_steps();
|
|
130341
|
+
init_feature_step_helpers();
|
|
130127
130342
|
init_gate_timing();
|
|
130128
130343
|
init_ledger3();
|
|
130129
130344
|
init_publish_item_threads();
|
|
130130
130345
|
init_restated_minors();
|
|
130131
130346
|
init_run_log();
|
|
130132
|
-
|
|
130133
|
-
maxBranchFixRounds: WORKFLOW_DEFAULTS.maxBranchFixRounds,
|
|
130134
|
-
finalGateRepairRounds: WORKFLOW_DEFAULTS.finalGateRepairRounds,
|
|
130135
|
-
ciRepairRounds: WORKFLOW_DEFAULTS.ciRepairRounds
|
|
130136
|
-
};
|
|
130137
|
-
NO_MIRROR = { mirror: false };
|
|
130347
|
+
init_ci_repair_steps();
|
|
130138
130348
|
});
|
|
130139
130349
|
|
|
130140
130350
|
// src/workflow/feature-graph.ts
|
|
@@ -130221,7 +130431,7 @@ var init_feature_graph = __esm(() => {
|
|
|
130221
130431
|
"ci-repair": {
|
|
130222
130432
|
kind: "agent",
|
|
130223
130433
|
commits: true,
|
|
130224
|
-
produces: ["ciRepairRounds", "ciRepairFindings"],
|
|
130434
|
+
produces: ["ciRepairRounds", "ciRepairFindings", "ciRepairConcerns"],
|
|
130225
130435
|
transitions: [{ to: "final-gates" }],
|
|
130226
130436
|
run: ciRepairStep
|
|
130227
130437
|
},
|
|
@@ -130240,6 +130450,8 @@ var init_feature_graph = __esm(() => {
|
|
|
130240
130450
|
"passed",
|
|
130241
130451
|
"flaggedDecisions",
|
|
130242
130452
|
"ciRepairFindings",
|
|
130453
|
+
"ciRepairTargets",
|
|
130454
|
+
"ciRemaining",
|
|
130243
130455
|
"endedAt"
|
|
130244
130456
|
],
|
|
130245
130457
|
exits: ["ci-repair"],
|
|
@@ -130695,12 +130907,19 @@ function flaggedOf(rec, feature) {
|
|
|
130695
130907
|
return;
|
|
130696
130908
|
return { ids: [...ids], hint: flaggedHint(feature) };
|
|
130697
130909
|
}
|
|
130910
|
+
function ciRemainingOf(rec) {
|
|
130911
|
+
const checks = rec?.ciRemaining;
|
|
130912
|
+
if (!checks || checks.length === 0)
|
|
130913
|
+
return;
|
|
130914
|
+
return checks.map((check) => check.failedStep ? `${check.name} at step "${check.failedStep}"` : check.name);
|
|
130915
|
+
}
|
|
130698
130916
|
function buildWorkflowRunSummary(result, timing, feature) {
|
|
130699
130917
|
if (!result)
|
|
130700
130918
|
return null;
|
|
130701
130919
|
const rec = result.featureWorkflow;
|
|
130702
130920
|
const finalGates = rec?.finalGates ?? rec?.repoGates;
|
|
130703
130921
|
const flagged = flaggedOf(rec, feature);
|
|
130922
|
+
const ciRemaining = ciRemainingOf(rec);
|
|
130704
130923
|
return {
|
|
130705
130924
|
...timing,
|
|
130706
130925
|
roles: rolesOf(result),
|
|
@@ -130715,6 +130934,8 @@ function buildWorkflowRunSummary(result, timing, feature) {
|
|
|
130715
130934
|
...finalGates ? { finalGates: finalGates.failing.length === 0 ? "green" : "red" } : {},
|
|
130716
130935
|
...rec?.gateRepairRounds ? { gateRepairRounds: rec.gateRepairRounds } : {},
|
|
130717
130936
|
...rec?.ciRepairRounds ? { ciRepairRounds: rec.ciRepairRounds } : {},
|
|
130937
|
+
...rec?.ciRepairConcerns && rec.ciRepairConcerns.length > 0 ? { ciRepairConcerns: rec.ciRepairConcerns } : {},
|
|
130938
|
+
...ciRemaining ? { ciRemaining } : {},
|
|
130718
130939
|
...rec?.outcome ? { publish: { outcome: rec.outcome, ...rec.url ? { url: rec.url } : {}, reasons: rec.reasons } } : {},
|
|
130719
130940
|
...flagged ? { flagged } : {}
|
|
130720
130941
|
};
|
|
@@ -131971,6 +132192,10 @@ function summaryLine(view) {
|
|
|
131971
132192
|
parts.push(`gate repair rounds ${view.gateRepairRounds}`);
|
|
131972
132193
|
if (view.ciRepairRounds)
|
|
131973
132194
|
parts.push(`CI repair rounds ${view.ciRepairRounds}`);
|
|
132195
|
+
if (view.ciRemaining && view.ciRemaining.length > 0)
|
|
132196
|
+
parts.push(`CI still failing: ${view.ciRemaining.join(", ")}`);
|
|
132197
|
+
if (view.ciRepairConcerns && view.ciRepairConcerns.length > 0)
|
|
132198
|
+
parts.push(`CI repair concerns: ${view.ciRepairConcerns.join("; ")}`);
|
|
131974
132199
|
if (view.publish)
|
|
131975
132200
|
parts.push(`publish ${view.publish.outcome}`);
|
|
131976
132201
|
if (view.flagged)
|
|
@@ -136730,13 +136955,21 @@ function barCommands(checks) {
|
|
|
136730
136955
|
function checkCommands(checks) {
|
|
136731
136956
|
return checks.gates.flatMap(({ command }) => typeof command === "string" ? [command] : command);
|
|
136732
136957
|
}
|
|
136733
|
-
|
|
136958
|
+
function reviewBuildSteps(checks) {
|
|
136959
|
+
const build = checks.gates.find(({ name }) => name === "build");
|
|
136960
|
+
if (build === undefined)
|
|
136961
|
+
return [];
|
|
136962
|
+
const commands = typeof build.command === "string" ? [build.command] : build.command;
|
|
136963
|
+
return commands.map((command) => ({ command, timeoutSeconds: REVIEW_BUILD_TIMEOUT_SECONDS }));
|
|
136964
|
+
}
|
|
136965
|
+
var DERIVED_INSTALL_TIMEOUT_SECONDS = 600, REVIEW_BUILD_TIMEOUT_SECONDS, MAX_INSTRUCTION_BYTES = 65536, _botChecksDeps, LOCKFILE_COMMANDS;
|
|
136734
136966
|
var init_checks5 = __esm(() => {
|
|
136735
136967
|
init_internal();
|
|
136736
136968
|
init_errors4();
|
|
136737
136969
|
init_finish();
|
|
136738
136970
|
init_logger2();
|
|
136739
136971
|
init_git3();
|
|
136972
|
+
REVIEW_BUILD_TIMEOUT_SECONDS = DEFAULT_GATE_TIMEOUT_MS / 1000;
|
|
136740
136973
|
_botChecksDeps = { runGit: botGit, resolveGateCommands };
|
|
136741
136974
|
LOCKFILE_COMMANDS = [
|
|
136742
136975
|
{ path: "bun.lock", prefix: "bun run", install: "bun install --frozen-lockfile" },
|
|
@@ -136986,6 +137219,9 @@ function readinessLines(input) {
|
|
|
136986
137219
|
if (input.preRunFailed !== undefined) {
|
|
136987
137220
|
lines.push(`Install step failed (${safeText(input.preRunFailed, TEXT_LIMIT)}); checks may not have run.`);
|
|
136988
137221
|
}
|
|
137222
|
+
if (input.buildFailed !== undefined) {
|
|
137223
|
+
lines.push(`Build step failed (${safeText(input.buildFailed, TEXT_LIMIT)}); checks that import built workspace packages may not have started.`);
|
|
137224
|
+
}
|
|
136989
137225
|
return lines;
|
|
136990
137226
|
}
|
|
136991
137227
|
function scopeSuffix(scope, incrementalSince) {
|
|
@@ -137425,6 +137661,7 @@ async function postSummary(input, findings, threads) {
|
|
|
137425
137661
|
earlier: earlierCounts(input),
|
|
137426
137662
|
checks: input.staticMode ? null : input.checks,
|
|
137427
137663
|
preRunFailed: input.preRunFailed,
|
|
137664
|
+
...input.buildFailed === undefined ? {} : { buildFailed: input.buildFailed },
|
|
137428
137665
|
...input.ci === undefined ? {} : { ci: input.ci },
|
|
137429
137666
|
...findings,
|
|
137430
137667
|
...threads,
|
|
@@ -138924,6 +139161,7 @@ async function repairStep(env, state) {
|
|
|
138924
139161
|
findings: [],
|
|
138925
139162
|
model: botModel(env.config, "fix", env.model),
|
|
138926
139163
|
prompt,
|
|
139164
|
+
kind: "repair",
|
|
138927
139165
|
toolProviders: [createForgeReadProvider({ resolveRef: async () => env.ref, deps: env.forge, cwd: env.repoRoot })]
|
|
138928
139166
|
});
|
|
138929
139167
|
const patch = {
|
|
@@ -139275,10 +139513,22 @@ function reviewConfig(loaded, staticMode) {
|
|
|
139275
139513
|
}
|
|
139276
139514
|
async function prepareReviewChecks(prepared, ctx) {
|
|
139277
139515
|
if (prepared.staticMode)
|
|
139278
|
-
return { checks: null };
|
|
139516
|
+
return { checks: null, buildRan: [] };
|
|
139517
|
+
const { checkout } = prepared;
|
|
139518
|
+
const checks = await resolveReviewChecks(prepared, ctx);
|
|
139519
|
+
getLogger2().info("bot", "Checks resolved", { source: checks.source, commands: checkCommands(checks) });
|
|
139520
|
+
try {
|
|
139521
|
+
await _botReviewDeps.runPreRunSteps({ steps: checks.preRun, workdir: checkout.worktree });
|
|
139522
|
+
} catch (err) {
|
|
139523
|
+
const failed = preRunFailedCommand(err, "Install step failed");
|
|
139524
|
+
return { checks, buildRan: [], ...failed === undefined ? {} : { preRunFailed: failed } };
|
|
139525
|
+
}
|
|
139526
|
+
return { checks, ...await runReviewBuild(prepared, checks) };
|
|
139527
|
+
}
|
|
139528
|
+
async function resolveReviewChecks(prepared, ctx) {
|
|
139279
139529
|
const { repoRoot, checkout } = prepared;
|
|
139280
139530
|
const config = ctx.config;
|
|
139281
|
-
|
|
139531
|
+
return _botReviewDeps.resolveBotChecks({
|
|
139282
139532
|
repoRoot,
|
|
139283
139533
|
baseSha: checkout.baseSha,
|
|
139284
139534
|
snapshotDir: checkout.snapshotDir,
|
|
@@ -139286,18 +139536,32 @@ async function prepareReviewChecks(prepared, ctx) {
|
|
|
139286
139536
|
config,
|
|
139287
139537
|
extract: (input) => _workflowDeps.callOp(ctx.callCtx, botChecksExtractOp, { ...input, model: config.bot?.models.checks })
|
|
139288
139538
|
});
|
|
139289
|
-
|
|
139290
|
-
|
|
139291
|
-
|
|
139292
|
-
|
|
139539
|
+
}
|
|
139540
|
+
function preRunFailedCommand(err, message) {
|
|
139541
|
+
if (!(err instanceof NaxError) || err.code !== "PRE_RUN_FAILED")
|
|
139542
|
+
throw err;
|
|
139543
|
+
const command = err.context?.command;
|
|
139544
|
+
getLogger2().warn("bot", message, { command });
|
|
139545
|
+
return typeof command === "string" ? command : undefined;
|
|
139546
|
+
}
|
|
139547
|
+
async function runReviewBuild(prepared, checks) {
|
|
139548
|
+
const steps = reviewBuildSteps(checks);
|
|
139549
|
+
const { inPlace, worktree } = prepared.checkout;
|
|
139550
|
+
if (inPlace === true || steps.length === 0)
|
|
139551
|
+
return { buildRan: [] };
|
|
139552
|
+
const buildRan = steps.map(({ command }) => command);
|
|
139553
|
+
try {
|
|
139554
|
+
await _botReviewDeps.runPreRunSteps({ steps, workdir: worktree });
|
|
139555
|
+
return { buildRan };
|
|
139293
139556
|
} catch (err) {
|
|
139294
|
-
|
|
139295
|
-
|
|
139296
|
-
const command = err.context?.command;
|
|
139297
|
-
getLogger2().warn("bot", "Install step failed", { command });
|
|
139298
|
-
return { checks, ...typeof command === "string" ? { preRunFailed: command } : {} };
|
|
139557
|
+
const failed = preRunFailedCommand(err, "Build step failed");
|
|
139558
|
+
return { buildRan, ...failed === undefined ? {} : { buildFailed: failed } };
|
|
139299
139559
|
}
|
|
139300
139560
|
}
|
|
139561
|
+
function setupCommands(preparation) {
|
|
139562
|
+
const install = preparation.checks?.preRun.map((step) => step.command) ?? [];
|
|
139563
|
+
return [...install, ...preparation.buildRan];
|
|
139564
|
+
}
|
|
139301
139565
|
async function reviewEnvironment(input, prepared, context) {
|
|
139302
139566
|
const { repoRoot, ref, info, checkout, staticMode } = prepared;
|
|
139303
139567
|
const { ctx, stateDir } = context;
|
|
@@ -139347,8 +139611,8 @@ async function reviewEnvironment(input, prepared, context) {
|
|
|
139347
139611
|
const checkoutState = staticMode ? undefined : renderCheckoutState({
|
|
139348
139612
|
phase: "fresh",
|
|
139349
139613
|
headSha: info.headSha,
|
|
139350
|
-
setup: preparation
|
|
139351
|
-
setupFailed: preparation.preRunFailed,
|
|
139614
|
+
setup: setupCommands(preparation),
|
|
139615
|
+
setupFailed: preparation.preRunFailed ?? preparation.buildFailed,
|
|
139352
139616
|
ciFiles: await listCiConfigFiles(checkout.worktree)
|
|
139353
139617
|
});
|
|
139354
139618
|
const range = input.full === true ? { rangeBase: checkout.mergeBase } : await reviewRange({ index: reviewedIndex, checkout, head: info.headSha }, _botReviewDeps.isAncestor);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nathapp/nax",
|
|
3
|
-
"version": "0.91.
|
|
3
|
+
"version": "0.91.6",
|
|
4
4
|
"description": "AI Coding Agent Orchestrator — loops until done",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"@agentclientprotocol/sdk": "~1.7.0",
|
|
87
87
|
"@anthropic-ai/sandbox-runtime": "0.0.77",
|
|
88
88
|
"@modelcontextprotocol/sdk": "^1.32.1",
|
|
89
|
-
"@nathapp/nax-ai": "0.91.
|
|
89
|
+
"@nathapp/nax-ai": "0.91.6",
|
|
90
90
|
"chalk": "^5.6.2",
|
|
91
91
|
"commander": "^13.1.0",
|
|
92
92
|
"ink": "^6.7.0",
|