@tea-agent/loop-agent 0.39.0-next.27 → 0.39.0-next.28
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/AGENTS.md +3 -0
- package/CHANGELOG.md +143 -96
- package/README.md +8 -4
- package/dist/build-stamp.json +3 -3
- package/dist/cli/command-definitions.js +16 -5
- package/dist/cli/program.js +16 -2
- package/dist/cli/update/notifier.js +2 -2
- package/dist/cli.js +2 -1
- package/dist/commands/init-model-catalog.js +464 -0
- package/dist/commands/init-upgrade.js +265 -97
- package/dist/commands/init.js +428 -27
- package/dist/commands/inspect-next.js +8 -0
- package/dist/executors/dag-pi-executor.js +18 -9
- package/dist/executors/shell-executor.js +50 -6
- package/dist/shared/operator/capabilities.js +7 -0
- package/dist/shared/update/console-notifier.js +100 -0
- package/dist/{cli → shared}/update/npm-client.js +41 -8
- package/dist/{cli → shared}/update/state.js +41 -13
- package/dist/worker/cli.js +31 -1
- package/dist/worker/console/chat/routes.js +1 -0
- package/dist/worker/console/operator-user-error.js +1 -1
- package/dist/worker/console/routes.js +3 -0
- package/dist/worker/console/security.js +53 -5
- package/dist/worker/console/server.js +10 -4
- package/dist/worker/console/static/assets/{abnfDiagram-N423BO3Z-C4kVYweA.js → abnfDiagram-N423BO3Z-DGn9iNrd.js} +1 -1
- package/dist/worker/console/static/assets/{arc-Bj2M8iO5.js → arc-Dc0C2Nyv.js} +1 -1
- package/dist/worker/console/static/assets/{architectureDiagram-T3A2C74G-CLlXe4-6.js → architectureDiagram-T3A2C74G-COnz_Bhe.js} +1 -1
- package/dist/worker/console/static/assets/{blockDiagram-VBNYF7ZC-psEp5xH0.js → blockDiagram-VBNYF7ZC-VhIP6vgf.js} +1 -1
- package/dist/worker/console/static/assets/{c4Diagram-5PPSVZJV-DeKcOCGJ.js → c4Diagram-5PPSVZJV-D74lpmlb.js} +1 -1
- package/dist/worker/console/static/assets/channel-DWcZjWB3.js +1 -0
- package/dist/worker/console/static/assets/{chunk-2GRJ4B5K-K0C744p1.js → chunk-2GRJ4B5K-BxmiogQE.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-2Q5K7J3B-xbNw4J9-.js → chunk-2Q5K7J3B-C00Oi-2I.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5RXB4S5H-DjLaSDUO.js → chunk-5RXB4S5H-DTrT1Vze.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5VM5RSS4-CtiPlKel.js → chunk-5VM5RSS4-DdKW7-fL.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-6Q2QTUOP-DZtolir7.js → chunk-6Q2QTUOP-D0q1WN6w.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-GF5L2VYU-CPcdNeew.js → chunk-GF5L2VYU-DBa14MSI.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-JWPE2WC7-NgHc6V37.js → chunk-JWPE2WC7-DkP-pEox.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-KBJHAD2P-DQ_T-hg8.js → chunk-KBJHAD2P-lgPogpcX.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-RYQCIY6F-DgLsxcVP.js → chunk-RYQCIY6F-D-apZer0.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-XXDRQBXY-UrVoM9z1.js → chunk-XXDRQBXY-B1T2yAIe.js} +1 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-IjoI3dqU.js +1 -0
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-IjoI3dqU.js +1 -0
- package/dist/worker/console/static/assets/{cose-bilkent-JH36ORCC-CLkYvTb3.js → cose-bilkent-JH36ORCC-0P6hi3jF.js} +1 -1
- package/dist/worker/console/static/assets/{cynefin-VYW2F7L2-BwT_xKrE.js → cynefin-VYW2F7L2-CntzMSR8.js} +1 -1
- package/dist/worker/console/static/assets/{cynefinDiagram-MW4NZA55-Bi9tuzif.js → cynefinDiagram-MW4NZA55-C9zmXJtG.js} +1 -1
- package/dist/worker/console/static/assets/{dagre-VZM6K2ZE-BCIqkWBV.js → dagre-VZM6K2ZE-DfBCZqZw.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-7IWD3JNH-Dip6l9_Z.js → diagram-7IWD3JNH-DLp-bhGL.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-B4RE2ZJO-B-xkh_wK.js → diagram-B4RE2ZJO-BksDcwZm.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-LBJQPF4R-DZO0kTt_.js → diagram-LBJQPF4R-Bdag7DYP.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-Q27KOJAE-D6ZplNbZ.js → diagram-Q27KOJAE-CoY5uNbk.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-UB23O5K3-BPekbhoS.js → diagram-UB23O5K3-KcgrDXHt.js} +1 -1
- package/dist/worker/console/static/assets/{ebnfDiagram-BXEA7PRR-BtmaJpK5.js → ebnfDiagram-BXEA7PRR-CikErwJb.js} +1 -1
- package/dist/worker/console/static/assets/{erDiagram-JOGREHBK-6DS0Xc44.js → erDiagram-JOGREHBK-DqmwwzvZ.js} +1 -1
- package/dist/worker/console/static/assets/{flowDiagram-UKHOOZJN-CihnROSm.js → flowDiagram-UKHOOZJN-35krh9WG.js} +1 -1
- package/dist/worker/console/static/assets/{ganttDiagram-PKOTCBZU-CZC4zOE2.js → ganttDiagram-PKOTCBZU-CvTF1gJ4.js} +1 -1
- package/dist/worker/console/static/assets/{gitGraphDiagram-DS77QQ5N-Dq1fhzGN.js → gitGraphDiagram-DS77QQ5N-BiOWWClJ.js} +1 -1
- package/dist/worker/console/static/assets/{index-DTZOKgAn.js → index-CqWlWE4l.js} +3 -3
- package/dist/worker/console/static/assets/{infoDiagram-6WML65LV-DlSl4BGx.js → infoDiagram-6WML65LV-Crha5dcA.js} +1 -1
- package/dist/worker/console/static/assets/{ishikawaDiagram-WSZJBQD7-snnzFl_U.js → ishikawaDiagram-WSZJBQD7-DEtbscOZ.js} +1 -1
- package/dist/worker/console/static/assets/{journeyDiagram-NVQOT4AX-BDE7qpMx.js → journeyDiagram-NVQOT4AX-D2YYzx3z.js} +1 -1
- package/dist/worker/console/static/assets/{kanban-definition-27J2QSJJ-CD2Ci04G.js → kanban-definition-27J2QSJJ-C7x18ttQ.js} +1 -1
- package/dist/worker/console/static/assets/{linear-DdnapKIH.js → linear-CCLZkz45.js} +1 -1
- package/dist/worker/console/static/assets/{mermaid.core-BVjAT9b8.js → mermaid.core-Dmy4lSGv.js} +5 -5
- package/dist/worker/console/static/assets/{mindmap-definition-FAOFIHXS-D0yJk-zA.js → mindmap-definition-FAOFIHXS-CmvIol59.js} +1 -1
- package/dist/worker/console/static/assets/{pegDiagram-VL7TDLO6-BVo9tFP-.js → pegDiagram-VL7TDLO6-DVpEdirN.js} +1 -1
- package/dist/worker/console/static/assets/{pieDiagram-7S7Q4E2Y-DnOV-mZ_.js → pieDiagram-7S7Q4E2Y-cKQy456v.js} +1 -1
- package/dist/worker/console/static/assets/{quadrantDiagram-CIZ2JOQS-CzUJo58i.js → quadrantDiagram-CIZ2JOQS-bx06I38m.js} +1 -1
- package/dist/worker/console/static/assets/{railroadDiagram-AXF67PYL-Bvikrolh.js → railroadDiagram-AXF67PYL-BjfIVIJr.js} +1 -1
- package/dist/worker/console/static/assets/{requirementDiagram-LRYGKXZP-DtaSVCap.js → requirementDiagram-LRYGKXZP-DcuPGbKM.js} +1 -1
- package/dist/worker/console/static/assets/{sankeyDiagram-W5VNT64P-C2c9A0wW.js → sankeyDiagram-W5VNT64P-DvgVeDoV.js} +1 -1
- package/dist/worker/console/static/assets/{sequenceDiagram-SI44F4Z6-DmXJcU7r.js → sequenceDiagram-SI44F4Z6-DLBG9nm-.js} +1 -1
- package/dist/worker/console/static/assets/{sizeCapture-X5ZJPWSS-B4GUFW92.js → sizeCapture-X5ZJPWSS-D33L7FBF.js} +1 -1
- package/dist/worker/console/static/assets/{stateDiagram-OKZ733FA-Dsad2MXf.js → stateDiagram-OKZ733FA-hvqD9TpS.js} +1 -1
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-C6MII0D1.js +1 -0
- package/dist/worker/console/static/assets/{swimlanes-SLNWSIFB-DGq48Fbi.js → swimlanes-SLNWSIFB-BtjH81Mz.js} +2 -2
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-D_tk0V8D.js +8 -0
- package/dist/worker/console/static/assets/{timeline-definition-Z64GVDOM-CSSi6OFf.js → timeline-definition-Z64GVDOM-CJ47Kraf.js} +1 -1
- package/dist/worker/console/static/assets/{vennDiagram-T6HMQDX7-BqyzPrWv.js → vennDiagram-T6HMQDX7-COVPl-wh.js} +1 -1
- package/dist/worker/console/static/assets/{wardleyDiagram-T6FBY63Y-DlznVb6S.js → wardleyDiagram-T6FBY63Y-CCoQJLUY.js} +1 -1
- package/dist/worker/console/static/assets/{xychartDiagram-ELKLHX3M-CfBcgJ_K.js → xychartDiagram-ELKLHX3M-DTWJvfAd.js} +1 -1
- package/dist/worker/console/static/index.html +1 -1
- package/dist/worker/console/static-src/operator-chat/mutation-gate.js +1 -1
- package/dist/worker/observe/static/views/dag-inspector.js +3 -1
- package/dist/worker/observe/static/views/session-timeline.js +60 -4
- package/dist/workflows/dag/failure-category.js +1 -0
- package/dist/workflows/dag/frontend-implementation-contract.js +5 -1
- package/dist/workflows/dag/init-hybrid.js +35 -10
- package/dist/workflows/dag/node-execution.js +20 -2
- package/dist/workflows/dag/retry-policy.js +91 -0
- package/dist/workflows/dag/types.js +9 -1
- package/docs/init-surface.manifest.json +5 -0
- package/docs/operations/README.md +1 -1
- package/docs/templates/init-managed-agents.md +13 -3
- package/package.json +5 -1
- package/scripts/next-info.mjs +356 -0
- package/scripts/next-publish-gate.mjs +238 -0
- package/scripts/release-source-binding.mjs +251 -0
- package/skills/loop-agent/references/command-reference.md +11 -4
- package/dist/worker/console/static/assets/channel-CPF4N7pf.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-C2DwA_Y1.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-C2DwA_Y1.js +0 -1
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-B8FB_cNk.js +0 -1
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-CrZYaWfx.js +0 -8
|
@@ -10,7 +10,7 @@ import { resolveContextPolicy } from "./context-policy.js";
|
|
|
10
10
|
import { buildDagNodePromptEnvelope, formatConvergenceFeedbackBlock, } from "./prompt.js";
|
|
11
11
|
import { persistLongNodeOutputArtifacts } from "./upstream-artifacts.js";
|
|
12
12
|
import { buildOutputLimitRecoverySection, loadBackendTestWriterProgressForRetry, } from "./backend-test-writer-completeness.js";
|
|
13
|
-
import { computeBackoffDelayMs, isRetryablePiFailureCategory, isSafeReadOnlyPiRetryCandidate, isWriterEmptyDiffRetryCandidate, isWriterTransportRetryCandidate, } from "./retry-policy.js";
|
|
13
|
+
import { computeBackoffDelayMs, isCanonicalFinalVerifyShellRetryCandidate, isRetryablePiFailureCategory, isSafeReadOnlyPiRetryCandidate, isTargetTemplateTransientRetryNode, isWriterEmptyDiffRetryCandidate, isWriterTransportRetryCandidate, VERIFY_SHELL_RETRY_POLICY, } from "./retry-policy.js";
|
|
14
14
|
import { applyNodeActivity, evaluateNodeLiveness, resolveLivenessPolicy, } from "./liveness-policy.js";
|
|
15
15
|
import { buildProtocolRetryInstruction, normalizeReviewVerdictAfterRetries, parseJsonReviewVerdict, validateOutputProtocol, } from "./output-protocol.js";
|
|
16
16
|
import { getStructuredContractValidator } from "./contract-output-registry.js";
|
|
@@ -260,6 +260,16 @@ function buildAttemptPrompt(task, basePrompt, attemptNumber, previousFailureCate
|
|
|
260
260
|
"</retry_instruction>",
|
|
261
261
|
].join("\n");
|
|
262
262
|
}
|
|
263
|
+
if (previousFailureCategory === "writer-clean-timeout") {
|
|
264
|
+
return [
|
|
265
|
+
basePrompt,
|
|
266
|
+
"",
|
|
267
|
+
"<retry_instruction>",
|
|
268
|
+
"Previous attempt ended in a clean provider/transport failure with zero attributed workspace writes and zero write/edit tool calls.",
|
|
269
|
+
"Do not invent existing implementation progress. Continue from the original task only if the workspace is still unchanged.",
|
|
270
|
+
"</retry_instruction>",
|
|
271
|
+
].join("\n");
|
|
272
|
+
}
|
|
263
273
|
if (previousFailureCategory !== "output-too-large") {
|
|
264
274
|
return basePrompt;
|
|
265
275
|
}
|
|
@@ -696,12 +706,18 @@ export async function executeDagNode(input) {
|
|
|
696
706
|
// Invalid or missing harness preserves the previous no-override behavior.
|
|
697
707
|
}
|
|
698
708
|
}
|
|
699
|
-
const
|
|
709
|
+
const specRetryPolicy = task.retryPolicy &&
|
|
700
710
|
(isSafeReadOnlyPiRetryCandidate(task) ||
|
|
701
711
|
isWriterEmptyDiffRetryCandidate(task) ||
|
|
702
712
|
isWriterTransportRetryCandidate(task))
|
|
703
713
|
? task.retryPolicy
|
|
704
714
|
: undefined;
|
|
715
|
+
const implicitVerifyRetryPolicy = specRetryPolicy === undefined &&
|
|
716
|
+
isCanonicalFinalVerifyShellRetryCandidate(task) &&
|
|
717
|
+
isTargetTemplateTransientRetryNode(task)
|
|
718
|
+
? VERIFY_SHELL_RETRY_POLICY
|
|
719
|
+
: undefined;
|
|
720
|
+
const retryPolicy = specRetryPolicy ?? implicitVerifyRetryPolicy;
|
|
705
721
|
const maxAttempts = retryPolicy?.maxAttempts ?? 1;
|
|
706
722
|
const attempts = [];
|
|
707
723
|
let totalAttemptWallDurationMs = 0;
|
|
@@ -943,6 +959,7 @@ export async function executeDagNode(input) {
|
|
|
943
959
|
const attemptFinishedAt = new Date().toISOString();
|
|
944
960
|
const attemptWallDurationMs = durationBetween(attemptStartedAt, attemptFinishedAt);
|
|
945
961
|
totalAttemptWallDurationMs += attemptWallDurationMs;
|
|
962
|
+
const rawFailureCategory = result.rawFailureCategory ?? result.failureCategory;
|
|
946
963
|
const attemptRecord = {
|
|
947
964
|
attempt: attemptNumber,
|
|
948
965
|
startedAt: attemptStartedAt,
|
|
@@ -954,6 +971,7 @@ export async function executeDagNode(input) {
|
|
|
954
971
|
stderr: result.stderr,
|
|
955
972
|
assistantText: result.assistantText,
|
|
956
973
|
failureCategory: result.failureCategory,
|
|
974
|
+
...(rawFailureCategory ? { rawFailureCategory } : {}),
|
|
957
975
|
backend: result.backend,
|
|
958
976
|
sdkAttempted: result.sdkAttempted,
|
|
959
977
|
tokensUsed: result.tokensUsed,
|
|
@@ -165,6 +165,36 @@ export const WRITER_TRANSPORT_RETRY_POLICY = {
|
|
|
165
165
|
maxDelayMs: 30000,
|
|
166
166
|
retryCategories: [WRITER_CLEAN_TIMEOUT_RETRY_CATEGORY],
|
|
167
167
|
};
|
|
168
|
+
/**
|
|
169
|
+
* Implicit runtime retry for canonical final verify shells. Not a DagRetryPolicy:
|
|
170
|
+
* `spawn-error` / `test-timeout` are runtime command categories and must not enter
|
|
171
|
+
* `dagRetryPolicySchema` / `ALL_DAG_RETRY_CATEGORIES`.
|
|
172
|
+
*/
|
|
173
|
+
export const VERIFY_SHELL_RETRY_CATEGORIES = [
|
|
174
|
+
"timeout",
|
|
175
|
+
"spawn-error",
|
|
176
|
+
"test-timeout",
|
|
177
|
+
];
|
|
178
|
+
export const VERIFY_SHELL_RETRY_POLICY = {
|
|
179
|
+
maxAttempts: 2,
|
|
180
|
+
backoff: "exponential",
|
|
181
|
+
initialDelayMs: 2000,
|
|
182
|
+
maxDelayMs: 30000,
|
|
183
|
+
retryCategories: VERIFY_SHELL_RETRY_CATEGORIES,
|
|
184
|
+
};
|
|
185
|
+
export const TARGET_TEMPLATE_TRANSIENT_RETRY_PROFILE = "standard-reviewed-supervised-v1";
|
|
186
|
+
/**
|
|
187
|
+
* Target-template exclusive implement-pi transport retry. Same schema category
|
|
188
|
+
* as frontend (`writer-clean-timeout`) so DagSpec validation stays unchanged;
|
|
189
|
+
* only the delay cap is wider. Do not mutate {@link WRITER_TRANSPORT_RETRY_POLICY}.
|
|
190
|
+
*/
|
|
191
|
+
export const TARGET_TEMPLATE_WRITER_TRANSPORT_RETRY_POLICY = {
|
|
192
|
+
maxAttempts: 2,
|
|
193
|
+
backoff: "exponential",
|
|
194
|
+
initialDelayMs: 5000,
|
|
195
|
+
maxDelayMs: 60000,
|
|
196
|
+
retryCategories: [WRITER_CLEAN_TIMEOUT_RETRY_CATEGORY],
|
|
197
|
+
};
|
|
168
198
|
/**
|
|
169
199
|
* Backend-test generation writers: empty-diff once, plus bounded incomplete-write-set
|
|
170
200
|
* recovery attempts driven by Completeness Gate (missing/broken target files).
|
|
@@ -238,6 +268,67 @@ export function isWriterTransportRetryCandidate(task) {
|
|
|
238
268
|
task.writerOutcomePolicy?.type === "implementation-outcome-v1" &&
|
|
239
269
|
task.writerOutcomePolicy.requireChangedFiles !== true);
|
|
240
270
|
}
|
|
271
|
+
/**
|
|
272
|
+
* Canonical standard exclusive `implement-pi` only. Frontend designers and
|
|
273
|
+
* completeness writers stay on the existing timeout-only transport candidate.
|
|
274
|
+
*/
|
|
275
|
+
export function isTargetTemplateImplementPi(task) {
|
|
276
|
+
return isWriterTransportRetryCandidate(task) && task.id === "implement-pi";
|
|
277
|
+
}
|
|
278
|
+
export function hasTargetTemplateTransientRetryProfile(task) {
|
|
279
|
+
return (task?.transientRetryProfile === TARGET_TEMPLATE_TRANSIENT_RETRY_PROFILE);
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Dual-condition eligibility: canonical shape AND generated-path stamp.
|
|
283
|
+
* Custom / other-template nodes that only match id or shape stay ineligible.
|
|
284
|
+
*/
|
|
285
|
+
export function isTargetTemplateTransientRetryNode(task) {
|
|
286
|
+
if (!hasTargetTemplateTransientRetryProfile(task))
|
|
287
|
+
return false;
|
|
288
|
+
return (isCanonicalFinalVerifyShellRetryCandidate(task) ||
|
|
289
|
+
isTargetTemplateImplementPi(task));
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Shape-based eligibility for implicit canonical final verify-shell retry.
|
|
293
|
+
* Does not consult node id or a template field.
|
|
294
|
+
*/
|
|
295
|
+
export function isCanonicalFinalVerifyShellRetryCandidate(task) {
|
|
296
|
+
if (task.executor !== "shell")
|
|
297
|
+
return false;
|
|
298
|
+
if (task.role !== "verifier")
|
|
299
|
+
return false;
|
|
300
|
+
if (task.writePolicy !== undefined &&
|
|
301
|
+
task.writePolicy !== "read-only" &&
|
|
302
|
+
task.writePolicy !== "none") {
|
|
303
|
+
return false;
|
|
304
|
+
}
|
|
305
|
+
if ((task.writeSet?.length ?? 0) > 0)
|
|
306
|
+
return false;
|
|
307
|
+
const shell = task.shell;
|
|
308
|
+
if (!shell || (shell.commands?.length ?? 0) === 0)
|
|
309
|
+
return false;
|
|
310
|
+
const evidence = shell.verifyEvidence;
|
|
311
|
+
if (!evidence)
|
|
312
|
+
return false;
|
|
313
|
+
if (evidence.phase !== "final")
|
|
314
|
+
return false;
|
|
315
|
+
if (evidence.quota !== "full")
|
|
316
|
+
return false;
|
|
317
|
+
if (evidence.commandSource !== "adapter")
|
|
318
|
+
return false;
|
|
319
|
+
if (evidence.finalFullRequired !== true)
|
|
320
|
+
return false;
|
|
321
|
+
if (shell.frontendPrewriteGate ||
|
|
322
|
+
shell.frontendVerificationBundle ||
|
|
323
|
+
shell.frontendBrowserToolPreflight ||
|
|
324
|
+
shell.backendTestPipeline ||
|
|
325
|
+
shell.jacocoCoverage ||
|
|
326
|
+
shell.repairArtifactGate ||
|
|
327
|
+
shell.verdictGate) {
|
|
328
|
+
return false;
|
|
329
|
+
}
|
|
330
|
+
return true;
|
|
331
|
+
}
|
|
241
332
|
export function isSafeReadOnlyPiRetryCandidate(task) {
|
|
242
333
|
if (task.executor !== "pi")
|
|
243
334
|
return false;
|
|
@@ -2,7 +2,7 @@ import { z } from "zod";
|
|
|
2
2
|
import { isOpenspecSpecFilePath } from "../../shared/openspec-spec.js";
|
|
3
3
|
import { campaignBudgetSchema, } from "../../application/evaluation/budget.js";
|
|
4
4
|
import { assertDagPromptSourceRule } from "./prompt-source.js";
|
|
5
|
-
import { dagRetryPolicySchema } from "./retry-policy.js";
|
|
5
|
+
import { dagRetryPolicySchema, TARGET_TEMPLATE_TRANSIENT_RETRY_PROFILE, } from "./retry-policy.js";
|
|
6
6
|
import { dagLivenessPolicySchema, } from "./liveness-policy.js";
|
|
7
7
|
import { dagOutputProtocolSchema } from "./output-protocol.js";
|
|
8
8
|
export const dagComplexitySchema = z.enum(["HIGH", "MED", "LOW"]);
|
|
@@ -849,6 +849,14 @@ export const dagTaskSchema = z.object({ id: z.string().regex(/^[a-z][a-z0-9-]*$/
|
|
|
849
849
|
forbiddenPaths: z.array(z.string()).optional().default([]),
|
|
850
850
|
decisionGate: dagDecisionGateSchema.optional(),
|
|
851
851
|
retryPolicy: dagRetryPolicySchema.optional(),
|
|
852
|
+
/**
|
|
853
|
+
* Generation-path stamp for implicit same-run transient retry. Only the
|
|
854
|
+
* three target templates stamp canonical final verify shells and
|
|
855
|
+
* exclusive `implement-pi`. Zod-declared so parseDagSpec does not strip it.
|
|
856
|
+
*/
|
|
857
|
+
transientRetryProfile: z
|
|
858
|
+
.literal(TARGET_TEMPLATE_TRANSIENT_RETRY_PROFILE)
|
|
859
|
+
.optional(),
|
|
852
860
|
/** Optional per-node adaptive liveness override (merged over defaults). */
|
|
853
861
|
livenessPolicy: dagLivenessPolicySchema,
|
|
854
862
|
dynamicExpansion: dagDynamicExpansionSchema.optional(),
|
|
@@ -50,6 +50,9 @@
|
|
|
50
50
|
"scripts/kb-graph-materialize.mjs",
|
|
51
51
|
"scripts/kb-graph-promote.mjs",
|
|
52
52
|
"scripts/kb-graph-incremental-prepare.mjs",
|
|
53
|
+
"scripts/next-info.mjs",
|
|
54
|
+
"scripts/next-publish-gate.mjs",
|
|
55
|
+
"scripts/release-source-binding.mjs",
|
|
53
56
|
"docs/templates/agent-dag.schema.json",
|
|
54
57
|
"examples/example-dag.json",
|
|
55
58
|
"skills/agent-worker/SKILL.md",
|
|
@@ -277,6 +280,7 @@
|
|
|
277
280
|
"harness.json",
|
|
278
281
|
"package.json",
|
|
279
282
|
"src/commands/init.ts",
|
|
283
|
+
"src/commands/init-model-catalog.ts",
|
|
280
284
|
"src/commands/client-recovery.ts",
|
|
281
285
|
"src/commands/init-upgrade.ts",
|
|
282
286
|
"src/cli.ts",
|
|
@@ -302,6 +306,7 @@
|
|
|
302
306
|
"description": "Changes that may alter target-project initialization behavior, default DAG role skills, skill resolution, or package/init contracts.",
|
|
303
307
|
"patterns": [
|
|
304
308
|
"src/commands/init.ts",
|
|
309
|
+
"src/commands/init-model-catalog.ts",
|
|
305
310
|
"src/commands/client-recovery.ts",
|
|
306
311
|
"src/commands/init-upgrade.ts",
|
|
307
312
|
"src/cli.ts",
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
- [`local-development-environment.md`](local-development-environment.md):本地环境、Windows 差异和常见排障。
|
|
8
8
|
- [`branch-merge-guideline.md`](branch-merge-guideline.md):按风险选择合并模式并留下 source-SHA 证据。
|
|
9
9
|
- [`github-collaboration.md`](github-collaboration.md):仓库内 GitHub 协作约定及发布通道。
|
|
10
|
-
- [`version-and-release-management.md`](version-and-release-management.md):版本发布管理——next / release-x.y / latest
|
|
10
|
+
- [`version-and-release-management.md`](version-and-release-management.md):版本发布管理——next / release-x.y / latest 渠道、移动式 `npm-next` ref、`inspect next` 查询入口、workflow 与 promote 手册。
|
|
11
11
|
- [`production-readiness.md`](production-readiness.md):交付前的生产就绪判断。
|
|
12
12
|
- [`agent-worker-production-readiness.md`](agent-worker-production-readiness.md):agent-worker Feature/Task Pool 外层编排的 Production Readiness v1 操作合同。
|
|
13
13
|
- [`backend-test-jacoco-coverage.md`](backend-test-jacoco-coverage.md):Java 被测服务挂载 JaCoCo tcpserver agent 的 Maven、`java -jar` 与 Docker 操作手册。
|
|
@@ -80,9 +80,19 @@ loop-agent init update --repo-root . --apply-safe
|
|
|
80
80
|
当用户要求初始化 loop-agent(“初始化 loop-agent”“loop agent 初始化”“loop agent初始化”“loop-agent 初始化”),或发现 `README.md` / `__LOOP_AGENT_GOVERNANCE_ROOT__/verification-matrix.md` 仍停留在通用初始化状态时,模型应在同一轮工作中完成初始化闭环,不要把补全文档和验证矩阵留给用户交互。
|
|
81
81
|
|
|
82
82
|
1. 运行 `loop-agent init instructions --repo-root .`。
|
|
83
|
-
2. 运行 `loop-agent init --repo-root . --
|
|
84
|
-
3.
|
|
85
|
-
4.
|
|
83
|
+
2. 运行 `loop-agent init model-catalog --repo-root . --json`。loop-agent 不直接打开或解析认证文件原文,只让 Pi/OpenCode 自己的 runtime 加载其配置,并输出白名单模型元数据、Pi setup 状态、Pi 兼容性与 credential-ready 布尔值;token、headers、URL、原始命令输出和认证路径不会进入 catalog。
|
|
84
|
+
3. 先处理 `piSetup`:如果没有模型定义,向用户索取无法推断的 provider/model id、API/base URL、上下文窗口、最大输出、输入/推理能力、成本约束和凭据方式,帮助按 Pi 原生 schema 合并 `~/.pi/agent/models.json`;不得让用户把凭据值写入对话、harness 或报告,优先 Pi 登录/auth storage 或环境变量引用。如果已有定义但凭据未就绪,只修复认证。随后重跑 catalog,未出现 credential-ready Pi model 前不得继续初始化。
|
|
85
|
+
4. 对已有 `harness.json`,逐档保留仍存在于 Pi 的 LOW/MED/HIGH 原值;只为已移除或缺失的档位重新选择。结合目标项目实际技术栈、模型能力、成本与上下文窗口,从 `eligibleForHarness=true` 的候选中自主选择,并直接运行带完整三档参数的 init/update;代码会拒绝改动仍有效的档位。三档可以相同。只有凭据、成本、合规或可用性存在无法推断的实质歧义时才询问用户;OpenCode-only 候选不能证明 Pi executor 可用。
|
|
86
|
+
5. 基于真实项目文件补全根 `README.md`、`__LOOP_AGENT_GOVERNANCE_ROOT__/verification-matrix.md`,必要时适配 `scripts/ci-tests.sh`。
|
|
87
|
+
6. 运行 `loop-agent init doctor --repo-root .`、`loop-agent inspect`、`loop-agent docs audit` 并完成 quick verification;doctor 未确认 Pi model matrix 时不得开始 DAG。
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
loop-agent init --repo-root . --profile full --merge \
|
|
91
|
+
--low-model <provider/model> --med-model <provider/model> --high-model <provider/model>
|
|
92
|
+
# 已初始化项目只替换失效档位;仍有效档位在完整参数中保持当前引用
|
|
93
|
+
loop-agent init update --repo-root . --apply-safe \
|
|
94
|
+
--low-model <current-or-selected> --med-model <current-or-selected> --high-model <current-or-selected>
|
|
95
|
+
```
|
|
86
96
|
|
|
87
97
|
信息不足时写明尚未识别到的事实;不要留下泛化占位符。
|
|
88
98
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tea-agent/loop-agent",
|
|
3
|
-
"version": "0.39.0-next.
|
|
3
|
+
"version": "0.39.0-next.28",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"loop-agent": "bin/loop-agent.js",
|
|
@@ -33,6 +33,9 @@
|
|
|
33
33
|
"scripts/kb-graph-materialize.mjs",
|
|
34
34
|
"scripts/kb-graph-promote.mjs",
|
|
35
35
|
"scripts/kb-graph-incremental-prepare.mjs",
|
|
36
|
+
"scripts/next-info.mjs",
|
|
37
|
+
"scripts/next-publish-gate.mjs",
|
|
38
|
+
"scripts/release-source-binding.mjs",
|
|
36
39
|
"README.md",
|
|
37
40
|
"CHANGELOG.md"
|
|
38
41
|
],
|
|
@@ -58,6 +61,7 @@
|
|
|
58
61
|
"test": "node scripts/run-tests.mjs",
|
|
59
62
|
"test:host": "vitest run test/init-upgrade.test.ts --maxWorkers=1 -t \"records and reuses|controller-authorized semantic merge|authority-sensitive\"",
|
|
60
63
|
"test:fast": "vitest run --config vitest.fast.config.ts",
|
|
64
|
+
"test:io-heavy": "vitest run --config vitest.io-heavy.config.ts",
|
|
61
65
|
"test:integration": "vitest run --config vitest.integration.config.ts",
|
|
62
66
|
"docs:dev": "npm --prefix website start",
|
|
63
67
|
"docs:build": "npm --prefix website run build",
|
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* next-info: read-only report of the current npm `next` binding.
|
|
4
|
+
*
|
|
5
|
+
* Resolves the moving git ref `npm-next` (local, then origin) and the
|
|
6
|
+
* published tarball build stamp. Does not write the repo, move dist-tags,
|
|
7
|
+
* or call GitHub APIs.
|
|
8
|
+
*/
|
|
9
|
+
import { execFileSync } from "node:child_process";
|
|
10
|
+
import { mkdtempSync, rmSync } from "node:fs";
|
|
11
|
+
import { tmpdir } from "node:os";
|
|
12
|
+
import { join } from "node:path";
|
|
13
|
+
import process from "node:process";
|
|
14
|
+
import {
|
|
15
|
+
commandLaunch,
|
|
16
|
+
defaultRun,
|
|
17
|
+
isAncestor,
|
|
18
|
+
normalizeCommandArgs,
|
|
19
|
+
npmViewDistTags,
|
|
20
|
+
} from "./next-publish-gate.mjs";
|
|
21
|
+
import {
|
|
22
|
+
downloadNpmTarball,
|
|
23
|
+
readTarballBuildStamp,
|
|
24
|
+
} from "./release-source-binding.mjs";
|
|
25
|
+
|
|
26
|
+
export const UNPUBLISHED_COMMIT_LIMIT_DEFAULT = 50;
|
|
27
|
+
const GIT_REF_CANDIDATES = ["refs/heads/npm-next", "origin/npm-next"];
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @param {string} cmd
|
|
31
|
+
* @param {string[]} args
|
|
32
|
+
* @param {string} [cwd]
|
|
33
|
+
*/
|
|
34
|
+
function runWithCwd(cmd, args, cwd) {
|
|
35
|
+
const launch = commandLaunch(cmd, normalizeCommandArgs(cmd, args));
|
|
36
|
+
return execFileSync(launch.cmd, launch.args, {
|
|
37
|
+
encoding: "utf8",
|
|
38
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
39
|
+
cwd,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function scriptEntryHref(argv1) {
|
|
44
|
+
try {
|
|
45
|
+
return argv1 ? new URL(`file://${argv1}`).href : "";
|
|
46
|
+
} catch {
|
|
47
|
+
return "";
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function trimSha(value) {
|
|
52
|
+
if (typeof value !== "string") return null;
|
|
53
|
+
const sha = value.trim();
|
|
54
|
+
return sha ? sha : null;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function equalSha(left, right) {
|
|
58
|
+
if (!left || !right) return false;
|
|
59
|
+
return left.toLowerCase() === right.toLowerCase();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function tryRevParse(run, ref) {
|
|
63
|
+
try {
|
|
64
|
+
return trimSha(run("git", ["rev-parse", ref]));
|
|
65
|
+
} catch {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function resolveGitRefSha(run) {
|
|
71
|
+
for (const ref of GIT_REF_CANDIDATES) {
|
|
72
|
+
const sha = tryRevParse(run, ref);
|
|
73
|
+
if (sha) return { ref, sha };
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function readStampBuiltAt(tarballPath, run) {
|
|
79
|
+
try {
|
|
80
|
+
const listing = run("tar", ["-tzf", tarballPath]);
|
|
81
|
+
const stampEntry = String(listing)
|
|
82
|
+
.split("\n")
|
|
83
|
+
.map((line) => line.trim())
|
|
84
|
+
.find((line) => /\/dist\/build-stamp\.json$/.test(line));
|
|
85
|
+
if (!stampEntry) return null;
|
|
86
|
+
const stampJson = run("tar", ["-xzf", tarballPath, "-O", stampEntry]);
|
|
87
|
+
const parsed = JSON.parse(String(stampJson));
|
|
88
|
+
return typeof parsed.builtAt === "string" ? parsed.builtAt : null;
|
|
89
|
+
} catch {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Download the published next tarball and read gitSha + builtAt. */
|
|
95
|
+
export function defaultNextStampProbe(version, run = defaultRun) {
|
|
96
|
+
const dir = mkdtempSync(join(tmpdir(), "loop-agent-next-info-"));
|
|
97
|
+
try {
|
|
98
|
+
const tarball = downloadNpmTarball(version, dir, run);
|
|
99
|
+
const stamp = readTarballBuildStamp(tarball, run);
|
|
100
|
+
return {
|
|
101
|
+
gitSha: stamp.gitSha,
|
|
102
|
+
version: stamp.version ?? null,
|
|
103
|
+
builtAt: readStampBuiltAt(tarball, run),
|
|
104
|
+
};
|
|
105
|
+
} catch {
|
|
106
|
+
return null;
|
|
107
|
+
} finally {
|
|
108
|
+
rmSync(dir, { recursive: true, force: true });
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function emptyResult(overrides) {
|
|
113
|
+
return {
|
|
114
|
+
ok: false,
|
|
115
|
+
exitCode: 1,
|
|
116
|
+
npmNextVersion: null,
|
|
117
|
+
gitSha: null,
|
|
118
|
+
gitRef: null,
|
|
119
|
+
gitRefSha: null,
|
|
120
|
+
stampSha: null,
|
|
121
|
+
builtAt: null,
|
|
122
|
+
source: null,
|
|
123
|
+
aheadBy: null,
|
|
124
|
+
aheadByReason: null,
|
|
125
|
+
unpublishedCommits: [],
|
|
126
|
+
unpublishedTruncated: false,
|
|
127
|
+
unpublishedLimit: UNPUBLISHED_COMMIT_LIMIT_DEFAULT,
|
|
128
|
+
drift: false,
|
|
129
|
+
error: null,
|
|
130
|
+
...overrides,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function collectAheadState(gitSha, run) {
|
|
135
|
+
if (!gitSha) {
|
|
136
|
+
return {
|
|
137
|
+
aheadBy: null,
|
|
138
|
+
aheadByReason: "no gitSha to compare against HEAD",
|
|
139
|
+
unpublishedCommits: [],
|
|
140
|
+
unpublishedTruncated: false,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
const headSha = tryRevParse(run, "HEAD");
|
|
144
|
+
if (!headSha) {
|
|
145
|
+
return {
|
|
146
|
+
aheadBy: null,
|
|
147
|
+
aheadByReason: "HEAD is unavailable",
|
|
148
|
+
unpublishedCommits: [],
|
|
149
|
+
unpublishedTruncated: false,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
let unpublishedCommits = [];
|
|
153
|
+
let unpublishedTruncated = false;
|
|
154
|
+
try {
|
|
155
|
+
const log = run("git", ["log", "--oneline", `${gitSha}..HEAD`]);
|
|
156
|
+
const lines = String(log ?? "")
|
|
157
|
+
.split("\n")
|
|
158
|
+
.map((line) => line.trim())
|
|
159
|
+
.filter(Boolean);
|
|
160
|
+
unpublishedTruncated = lines.length > UNPUBLISHED_COMMIT_LIMIT_DEFAULT;
|
|
161
|
+
unpublishedCommits = lines.slice(0, UNPUBLISHED_COMMIT_LIMIT_DEFAULT);
|
|
162
|
+
} catch {
|
|
163
|
+
unpublishedCommits = [];
|
|
164
|
+
}
|
|
165
|
+
if (!isAncestor(gitSha, headSha, run)) {
|
|
166
|
+
return {
|
|
167
|
+
aheadBy: null,
|
|
168
|
+
aheadByReason: "gitSha is not an ancestor of HEAD",
|
|
169
|
+
unpublishedCommits,
|
|
170
|
+
unpublishedTruncated,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
try {
|
|
174
|
+
const count = Number(
|
|
175
|
+
String(run("git", ["rev-list", "--count", `${gitSha}..HEAD`])).trim(),
|
|
176
|
+
);
|
|
177
|
+
if (!Number.isFinite(count)) {
|
|
178
|
+
return {
|
|
179
|
+
aheadBy: null,
|
|
180
|
+
aheadByReason: "rev-list count is not a number",
|
|
181
|
+
unpublishedCommits,
|
|
182
|
+
unpublishedTruncated,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
return {
|
|
186
|
+
aheadBy: count,
|
|
187
|
+
aheadByReason: null,
|
|
188
|
+
unpublishedCommits,
|
|
189
|
+
unpublishedTruncated,
|
|
190
|
+
};
|
|
191
|
+
} catch {
|
|
192
|
+
return {
|
|
193
|
+
aheadBy: null,
|
|
194
|
+
aheadByReason: "rev-list failed",
|
|
195
|
+
unpublishedCommits,
|
|
196
|
+
unpublishedTruncated,
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Pure-ish collector. Tests inject `run` / `viewDistTags` / `stampProbe`
|
|
203
|
+
* so this never hits the real npm registry.
|
|
204
|
+
*
|
|
205
|
+
* @param {{
|
|
206
|
+
* cwd?: string,
|
|
207
|
+
* run?: (cmd: string, args: string[]) => string,
|
|
208
|
+
* viewDistTags?: () => Record<string, string>,
|
|
209
|
+
* stampProbe?: (version: string) =>
|
|
210
|
+
* | { gitSha?: string, builtAt?: string | null }
|
|
211
|
+
* | null,
|
|
212
|
+
* }} [deps]
|
|
213
|
+
*/
|
|
214
|
+
export function collectNextInfo(deps = {}) {
|
|
215
|
+
const run =
|
|
216
|
+
deps.run ??
|
|
217
|
+
((cmd, args) =>
|
|
218
|
+
deps.cwd ? runWithCwd(cmd, args, deps.cwd) : defaultRun(cmd, args));
|
|
219
|
+
const viewDistTags = deps.viewDistTags ?? (() => npmViewDistTags(run));
|
|
220
|
+
const stampProbe =
|
|
221
|
+
deps.stampProbe ?? ((version) => defaultNextStampProbe(version, run));
|
|
222
|
+
|
|
223
|
+
let distTags = {};
|
|
224
|
+
try {
|
|
225
|
+
distTags = viewDistTags() ?? {};
|
|
226
|
+
} catch {
|
|
227
|
+
distTags = {};
|
|
228
|
+
}
|
|
229
|
+
const npmNextVersion = distTags.next ? String(distTags.next) : null;
|
|
230
|
+
const gitRef = resolveGitRefSha(run);
|
|
231
|
+
const gitRefSha = gitRef?.sha ?? null;
|
|
232
|
+
let stamp = null;
|
|
233
|
+
if (npmNextVersion) {
|
|
234
|
+
try {
|
|
235
|
+
stamp = stampProbe(npmNextVersion);
|
|
236
|
+
} catch {
|
|
237
|
+
stamp = null;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
const stampSha = trimSha(stamp?.gitSha);
|
|
241
|
+
const builtAt = typeof stamp?.builtAt === "string" ? stamp.builtAt : null;
|
|
242
|
+
|
|
243
|
+
if (!gitRefSha && !stampSha) {
|
|
244
|
+
const error = npmNextVersion
|
|
245
|
+
? `no npm-next git ref and tarball stamp unreadable for next=${npmNextVersion}`
|
|
246
|
+
: "no npm-next git ref and no dist-tags.next";
|
|
247
|
+
return emptyResult({ error, npmNextVersion });
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
let source;
|
|
251
|
+
let gitSha;
|
|
252
|
+
let drift = false;
|
|
253
|
+
let error = null;
|
|
254
|
+
let ok = true;
|
|
255
|
+
let exitCode = 0;
|
|
256
|
+
|
|
257
|
+
if (gitRefSha && stampSha) {
|
|
258
|
+
source = "both";
|
|
259
|
+
if (!equalSha(gitRefSha, stampSha)) {
|
|
260
|
+
drift = true;
|
|
261
|
+
ok = false;
|
|
262
|
+
exitCode = 1;
|
|
263
|
+
error =
|
|
264
|
+
`npm-next git ref (${gitRefSha}) does not match tarball stamp gitSha (${stampSha})`;
|
|
265
|
+
}
|
|
266
|
+
gitSha = gitRefSha;
|
|
267
|
+
} else if (gitRefSha) {
|
|
268
|
+
source = "git-ref";
|
|
269
|
+
gitSha = gitRefSha;
|
|
270
|
+
} else {
|
|
271
|
+
source = "tarball-stamp";
|
|
272
|
+
gitSha = stampSha;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
const ahead = collectAheadState(gitSha, run);
|
|
276
|
+
return {
|
|
277
|
+
ok,
|
|
278
|
+
exitCode,
|
|
279
|
+
npmNextVersion,
|
|
280
|
+
gitSha,
|
|
281
|
+
gitRef: gitRef?.ref ?? null,
|
|
282
|
+
gitRefSha,
|
|
283
|
+
stampSha,
|
|
284
|
+
builtAt,
|
|
285
|
+
source,
|
|
286
|
+
aheadBy: ahead.aheadBy,
|
|
287
|
+
aheadByReason: ahead.aheadByReason,
|
|
288
|
+
unpublishedCommits: ahead.unpublishedCommits,
|
|
289
|
+
unpublishedTruncated: ahead.unpublishedTruncated,
|
|
290
|
+
unpublishedLimit: UNPUBLISHED_COMMIT_LIMIT_DEFAULT,
|
|
291
|
+
drift,
|
|
292
|
+
error,
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export function formatNextInfo(result, { json = false } = {}) {
|
|
297
|
+
if (json) {
|
|
298
|
+
return `${JSON.stringify(result, null, 2)}\n`;
|
|
299
|
+
}
|
|
300
|
+
const lines = [];
|
|
301
|
+
if (result.npmNextVersion) {
|
|
302
|
+
lines.push(`npm next: ${result.npmNextVersion}`);
|
|
303
|
+
} else {
|
|
304
|
+
lines.push("npm next: (no dist-tags.next)");
|
|
305
|
+
}
|
|
306
|
+
if (result.gitSha) {
|
|
307
|
+
lines.push(`gitSha: ${result.gitSha} (source: ${result.source})`);
|
|
308
|
+
} else {
|
|
309
|
+
lines.push("gitSha: (unavailable)");
|
|
310
|
+
}
|
|
311
|
+
if (result.gitRefSha && result.stampSha && result.drift) {
|
|
312
|
+
lines.push(`git-ref SHA: ${result.gitRefSha}`);
|
|
313
|
+
lines.push(`tarball stamp SHA: ${result.stampSha}`);
|
|
314
|
+
}
|
|
315
|
+
if (result.builtAt) {
|
|
316
|
+
lines.push(`builtAt: ${result.builtAt}`);
|
|
317
|
+
}
|
|
318
|
+
if (result.aheadBy === null) {
|
|
319
|
+
lines.push(
|
|
320
|
+
`aheadBy: null${result.aheadByReason ? ` (${result.aheadByReason})` : ""}`,
|
|
321
|
+
);
|
|
322
|
+
} else {
|
|
323
|
+
lines.push(`aheadBy: ${result.aheadBy}`);
|
|
324
|
+
}
|
|
325
|
+
const commits = result.unpublishedCommits ?? [];
|
|
326
|
+
if (commits.length === 0) {
|
|
327
|
+
lines.push("unpublishedCommits: (none)");
|
|
328
|
+
} else {
|
|
329
|
+
lines.push("unpublishedCommits:");
|
|
330
|
+
for (const commit of commits) lines.push(` ${commit}`);
|
|
331
|
+
if (result.unpublishedTruncated) {
|
|
332
|
+
lines.push(
|
|
333
|
+
` … truncated to ${result.unpublishedLimit} commits`,
|
|
334
|
+
);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
if (result.error) {
|
|
338
|
+
lines.push(`error: ${result.error}`);
|
|
339
|
+
}
|
|
340
|
+
return `${lines.join("\n")}\n`;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
function main(argv = process.argv.slice(2)) {
|
|
344
|
+
const json = argv.includes("--json");
|
|
345
|
+
const result = collectNextInfo();
|
|
346
|
+
process.stdout.write(formatNextInfo(result, { json }));
|
|
347
|
+
process.exit(result.ok ? 0 : result.exitCode || 1);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
const invokedAsScript =
|
|
351
|
+
Boolean(process.argv[1]) &&
|
|
352
|
+
import.meta.url === scriptEntryHref(process.argv[1]);
|
|
353
|
+
|
|
354
|
+
if (invokedAsScript) {
|
|
355
|
+
main();
|
|
356
|
+
}
|