@mestreyoda/fabrica 0.2.36 → 0.2.37
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/index.js +119 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -113905,8 +113905,8 @@ import fsSync from "node:fs";
|
|
|
113905
113905
|
import path5 from "node:path";
|
|
113906
113906
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
113907
113907
|
function getCurrentVersion() {
|
|
113908
|
-
if ("0.2.
|
|
113909
|
-
return "0.2.
|
|
113908
|
+
if ("0.2.37") {
|
|
113909
|
+
return "0.2.37";
|
|
113910
113910
|
}
|
|
113911
113911
|
try {
|
|
113912
113912
|
const pkgPath = path5.join(THIS_DIR, "..", "..", "package.json");
|
|
@@ -148951,6 +148951,103 @@ async function checkProjects(dataDir) {
|
|
|
148951
148951
|
return results;
|
|
148952
148952
|
}
|
|
148953
148953
|
|
|
148954
|
+
// lib/setup/doctor-run.ts
|
|
148955
|
+
async function runIssueDoctor(opts) {
|
|
148956
|
+
const data = await readProjects(opts.workspacePath);
|
|
148957
|
+
const project = data.projects[opts.projectSlug];
|
|
148958
|
+
if (!project) throw new Error(`Project not found: ${opts.projectSlug}`);
|
|
148959
|
+
const issueRuntime = getIssueRuntime(project, opts.issueId) ?? null;
|
|
148960
|
+
const hasArtifact = Boolean(
|
|
148961
|
+
issueRuntime?.currentPrUrl || issueRuntime?.currentPrNumber || issueRuntime?.artifactOfRecord
|
|
148962
|
+
);
|
|
148963
|
+
const { provider } = await createProvider({
|
|
148964
|
+
repo: project.repo,
|
|
148965
|
+
provider: project.provider,
|
|
148966
|
+
providerProfile: project.providerProfile,
|
|
148967
|
+
runCommand: opts.runCommand,
|
|
148968
|
+
pluginConfig: opts.pluginConfig
|
|
148969
|
+
});
|
|
148970
|
+
let prStatus = null;
|
|
148971
|
+
try {
|
|
148972
|
+
const pr = await provider.getPrStatus(opts.issueId);
|
|
148973
|
+
if (pr.url || pr.number) prStatus = pr;
|
|
148974
|
+
} catch {
|
|
148975
|
+
prStatus = null;
|
|
148976
|
+
}
|
|
148977
|
+
let issue2 = null;
|
|
148978
|
+
try {
|
|
148979
|
+
issue2 = await provider.getIssue(opts.issueId);
|
|
148980
|
+
} catch {
|
|
148981
|
+
issue2 = null;
|
|
148982
|
+
}
|
|
148983
|
+
const convergenceCause = issueRuntime?.lastConvergenceCause ?? null;
|
|
148984
|
+
const convergenceAction = issueRuntime?.lastConvergenceAction ?? null;
|
|
148985
|
+
const retryCount = issueRuntime?.lastConvergenceRetryCount ?? 0;
|
|
148986
|
+
const convergenceReason = issueRuntime?.lastConvergenceReason ?? issueRuntime?.inconclusiveCompletionReason ?? null;
|
|
148987
|
+
const summaryParts = [
|
|
148988
|
+
hasArtifact ? "artifact_present" : "artifact_missing",
|
|
148989
|
+
convergenceCause ? `cause=${convergenceCause}` : "cause=none",
|
|
148990
|
+
convergenceAction ? `action=${convergenceAction}` : "action=none",
|
|
148991
|
+
retryCount ? `retries=${retryCount}` : "retries=0",
|
|
148992
|
+
prStatus?.state ? `pr=${prStatus.state}` : "pr=unknown"
|
|
148993
|
+
];
|
|
148994
|
+
const likelyNextAction = (() => {
|
|
148995
|
+
if (convergenceAction === "escalate_human") return "human_intervention";
|
|
148996
|
+
if (convergenceCause === "invalid_qa_evidence") return "repair_qa_evidence";
|
|
148997
|
+
if (convergenceCause === "merge_conflict") return "repair_merge_conflict";
|
|
148998
|
+
if (convergenceCause === "stalled_with_artifact") return "force_convergence_review";
|
|
148999
|
+
if (hasArtifact) return "post_pr_convergence";
|
|
149000
|
+
return "redispatch_or_investigate";
|
|
149001
|
+
})();
|
|
149002
|
+
return {
|
|
149003
|
+
projectSlug: project.slug,
|
|
149004
|
+
projectName: project.name,
|
|
149005
|
+
issueId: opts.issueId,
|
|
149006
|
+
issueRuntime,
|
|
149007
|
+
hasArtifact,
|
|
149008
|
+
convergence: {
|
|
149009
|
+
cause: convergenceCause,
|
|
149010
|
+
action: convergenceAction,
|
|
149011
|
+
retryCount,
|
|
149012
|
+
reason: convergenceReason,
|
|
149013
|
+
at: issueRuntime?.lastConvergenceAt ?? null
|
|
149014
|
+
},
|
|
149015
|
+
pr: prStatus ? {
|
|
149016
|
+
url: prStatus.url ?? null,
|
|
149017
|
+
state: prStatus.state ?? null,
|
|
149018
|
+
number: prStatus.number ?? null,
|
|
149019
|
+
mergeable: prStatus.mergeable ?? null,
|
|
149020
|
+
currentIssueMatch: prStatus.currentIssueMatch ?? null,
|
|
149021
|
+
sourceBranch: prStatus.sourceBranch ?? null
|
|
149022
|
+
} : null,
|
|
149023
|
+
issue: issue2 ? {
|
|
149024
|
+
url: issue2.web_url ?? null,
|
|
149025
|
+
state: issue2.state ?? null,
|
|
149026
|
+
labels: issue2.labels ?? [],
|
|
149027
|
+
title: issue2.title ?? null
|
|
149028
|
+
} : null,
|
|
149029
|
+
recommendation: {
|
|
149030
|
+
summary: summaryParts.join(" | "),
|
|
149031
|
+
likelyNextAction
|
|
149032
|
+
}
|
|
149033
|
+
};
|
|
149034
|
+
}
|
|
149035
|
+
function formatIssueDoctor(result) {
|
|
149036
|
+
const lines = [
|
|
149037
|
+
`Issue run doctor \u2014 ${result.projectSlug}#${result.issueId}`,
|
|
149038
|
+
` Artifact: ${result.hasArtifact ? "yes" : "no"}`,
|
|
149039
|
+
` PR: ${result.pr?.url ?? "n/a"} (${result.pr?.state ?? "unknown"})`,
|
|
149040
|
+
` Issue: ${result.issue?.url ?? "n/a"} (${result.issue?.state ?? "unknown"})`,
|
|
149041
|
+
` Labels: ${result.issue?.labels?.join(", ") ?? "n/a"}`,
|
|
149042
|
+
` Convergence cause: ${result.convergence.cause ?? "none"}`,
|
|
149043
|
+
` Convergence action: ${result.convergence.action ?? "none"}`,
|
|
149044
|
+
` Retry count: ${result.convergence.retryCount}`,
|
|
149045
|
+
` Last reason: ${result.convergence.reason ?? "n/a"}`,
|
|
149046
|
+
` Suggested next action: ${result.recommendation.likelyNextAction}`
|
|
149047
|
+
];
|
|
149048
|
+
return lines.join("\n");
|
|
149049
|
+
}
|
|
149050
|
+
|
|
148954
149051
|
// lib/observability/metrics.ts
|
|
148955
149052
|
init_constants();
|
|
148956
149053
|
import { readFile as readFile3 } from "node:fs/promises";
|
|
@@ -149533,6 +149630,26 @@ function registerCli(program, ctx) {
|
|
|
149533
149630
|
${result.checks.length} checks: ${result.errors} errors, ${result.warnings} warnings`);
|
|
149534
149631
|
process.exit(result.errors > 0 ? 1 : 0);
|
|
149535
149632
|
});
|
|
149633
|
+
doctor.command("issue").description("Inspect one Fabrica issue/run with convergence and PR context").requiredOption("-p, --project <slug>", "Project slug").requiredOption("-i, --issue <id>", "Issue number").option("-w, --workspace <path>", "Workspace directory").option("--json", "Emit machine-readable JSON").action(async (opts) => {
|
|
149634
|
+
const workspaceDir = requireWorkspaceDir2(ctx.runtime, opts.workspace);
|
|
149635
|
+
const issueId = Number.parseInt(String(opts.issue), 10);
|
|
149636
|
+
if (!Number.isFinite(issueId)) {
|
|
149637
|
+
console.error(`Invalid issue id: ${opts.issue}`);
|
|
149638
|
+
process.exit(1);
|
|
149639
|
+
}
|
|
149640
|
+
const result = await runIssueDoctor({
|
|
149641
|
+
workspacePath: workspaceDir,
|
|
149642
|
+
projectSlug: String(opts.project),
|
|
149643
|
+
issueId,
|
|
149644
|
+
runCommand: ctx.runCommand,
|
|
149645
|
+
pluginConfig: ctx.pluginConfig
|
|
149646
|
+
});
|
|
149647
|
+
if (opts.json) {
|
|
149648
|
+
console.log(JSON.stringify(result, null, 2));
|
|
149649
|
+
return;
|
|
149650
|
+
}
|
|
149651
|
+
console.log(formatIssueDoctor(result));
|
|
149652
|
+
});
|
|
149536
149653
|
doctor.option("-w, --workspace <path>", "Workspace directory").option("--fix", "Apply fixes for detected issues").action(async (opts) => {
|
|
149537
149654
|
const workspaceDir = requireWorkspaceDir2(ctx.runtime, opts.workspace);
|
|
149538
149655
|
const result = await runDoctor({ workspacePath: workspaceDir, fix: opts.fix ?? false, pluginConfig: ctx.pluginConfig });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mestreyoda/fabrica",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.37",
|
|
4
4
|
"description": "Autonomous software engineering pipeline for OpenClaw. Turns ideas into deployed code via intake, dispatch, review, test, and merge.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|