@aviaratech/ai-delivery 0.3.35 → 0.3.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/CONTRIBUTING.md +12 -206
- package/README.md +56 -554
- package/dist/agent.d.ts +1 -3
- package/dist/agent.js +74 -16
- package/dist/agent.js.map +7 -1
- package/dist/agentReadiness.test.js +73 -67
- package/dist/agentReadiness.test.js.map +7 -1
- package/dist/boardReconcile.test.js +1651 -1590
- package/dist/boardReconcile.test.js.map +7 -1
- package/dist/build.test.js +130 -0
- package/dist/build.test.js.map +7 -0
- package/dist/callerErrors.test.js +91 -0
- package/dist/callerErrors.test.js.map +7 -0
- package/dist/cli.js +389 -517
- package/dist/cli.js.map +7 -1
- package/dist/cliResult.d.ts +2 -2
- package/dist/cliResult.js +42 -45
- package/dist/cliResult.js.map +7 -1
- package/dist/cliResult.test.js +424 -369
- package/dist/cliResult.test.js.map +7 -1
- package/dist/config/deliveryConfig.d.ts +288 -14
- package/dist/config/deliveryConfig.js +472 -390
- package/dist/config/deliveryConfig.js.map +7 -1
- package/dist/config/deliveryConfig.test.js +773 -649
- package/dist/config/deliveryConfig.test.js.map +7 -1
- package/dist/contributorChecks.test.js +1694 -916
- package/dist/contributorChecks.test.js.map +7 -1
- package/dist/currentConsumer.test.js +819 -737
- package/dist/currentConsumer.test.js.map +7 -1
- package/dist/currentTrackingScenario.test.js +499 -479
- package/dist/currentTrackingScenario.test.js.map +7 -1
- package/dist/delivery/common.js +160 -172
- package/dist/delivery/common.js.map +7 -1
- package/dist/delivery/delivery.test.js +509 -431
- package/dist/delivery/delivery.test.js.map +7 -1
- package/dist/delivery/evidence.d.ts +2 -2
- package/dist/delivery/evidence.js +133 -120
- package/dist/delivery/evidence.js.map +7 -1
- package/dist/delivery/index.js +7 -2
- package/dist/delivery/index.js.map +7 -1
- package/dist/delivery/legacy.js +65 -5
- package/dist/delivery/legacy.js.map +7 -1
- package/dist/delivery/policy.d.ts +10 -10
- package/dist/delivery/policy.js +211 -238
- package/dist/delivery/policy.js.map +7 -1
- package/dist/delivery/stage.d.ts +18 -18
- package/dist/delivery/stage.js +220 -235
- package/dist/delivery/stage.js.map +7 -1
- package/dist/deliveryBoard.d.ts +74 -0
- package/dist/deliveryBoard.js +644 -0
- package/dist/deliveryBoard.js.map +7 -0
- package/dist/deliveryBoard.test.js +649 -0
- package/dist/deliveryBoard.test.js.map +7 -0
- package/dist/deliveryHealth.test.js +179 -155
- package/dist/deliveryHealth.test.js.map +7 -1
- package/dist/dependencyCompatibility.test.js +154 -140
- package/dist/dependencyCompatibility.test.js.map +7 -1
- package/dist/directoryIndependent.test.js +417 -383
- package/dist/directoryIndependent.test.js.map +7 -1
- package/dist/dispatch.d.ts +16 -11
- package/dist/dispatch.js +316 -354
- package/dist/dispatch.js.map +7 -1
- package/dist/errors.d.ts +3 -3
- package/dist/errors.js +103 -96
- package/dist/errors.js.map +7 -1
- package/dist/fixtures/deliveryBoardReplay.d.ts +56 -0
- package/dist/fixtures/deliveryBoardReplay.js +617 -0
- package/dist/fixtures/deliveryBoardReplay.js.map +7 -0
- package/dist/fixtures/discovery.d.ts +63 -23
- package/dist/fixtures/discovery.js +96 -90
- package/dist/fixtures/discovery.js.map +7 -1
- package/dist/fixtures/inertEntrypointChild.js +57 -56
- package/dist/fixtures/inertEntrypointChild.js.map +7 -1
- package/dist/fixtures/inertEntrypoints.d.ts +1 -1
- package/dist/fixtures/inertEntrypoints.js +321 -276
- package/dist/fixtures/inertEntrypoints.js.map +7 -1
- package/dist/fixtures/inertTarget.d.ts +78 -7
- package/dist/fixtures/inertTarget.js +769 -691
- package/dist/fixtures/inertTarget.js.map +7 -1
- package/dist/fixtures/issue63.d.ts +4 -3
- package/dist/fixtures/issue63.js +260 -274
- package/dist/fixtures/issue63.js.map +7 -1
- package/dist/fixtures/issueProjectItems.d.ts +20 -0
- package/dist/fixtures/issueProjectItems.js +15 -0
- package/dist/fixtures/issueProjectItems.js.map +7 -0
- package/dist/fixtures/readView.d.ts +120 -0
- package/dist/fixtures/readView.js +172 -0
- package/dist/fixtures/readView.js.map +7 -0
- package/dist/fixtures/recordedGitHubFlows.d.ts +120 -0
- package/dist/fixtures/recordedGitHubFlows.js +109 -0
- package/dist/fixtures/recordedGitHubFlows.js.map +7 -0
- package/dist/genericCompatibility.test.js +64 -55
- package/dist/genericCompatibility.test.js.map +7 -1
- package/dist/git.d.ts +0 -3
- package/dist/git.js +59 -76
- package/dist/git.js.map +7 -1
- package/dist/gitProcess.d.ts +1 -1
- package/dist/gitProcess.js +58 -53
- package/dist/gitProcess.js.map +7 -1
- package/dist/github/client.d.ts +2 -2
- package/dist/github/client.js +484 -379
- package/dist/github/client.js.map +7 -1
- package/dist/github/commandIdentityPolicy.js +42 -52
- package/dist/github/commandIdentityPolicy.js.map +7 -1
- package/dist/github/discovery.d.ts +1 -0
- package/dist/github/discovery.js +197 -215
- package/dist/github/discovery.js.map +7 -1
- package/dist/github/discovery.test.js +223 -177
- package/dist/github/discovery.test.js.map +7 -1
- package/dist/github/issueHistory.d.ts +2 -2
- package/dist/github/issueHistory.js +117 -125
- package/dist/github/issueHistory.js.map +7 -1
- package/dist/github/machineAuth.d.ts +1 -1
- package/dist/github/machineAuth.js +126 -117
- package/dist/github/machineAuth.js.map +7 -1
- package/dist/github/machineAuth.test.js +755 -639
- package/dist/github/machineAuth.test.js.map +7 -1
- package/dist/github/nativeIssueMetadata.js +286 -273
- package/dist/github/nativeIssueMetadata.js.map +7 -1
- package/dist/github/projectDelivery.d.ts +18 -2
- package/dist/github/projectDelivery.js +615 -557
- package/dist/github/projectDelivery.js.map +7 -1
- package/dist/github/relationships.js +433 -389
- package/dist/github/relationships.js.map +7 -1
- package/dist/github/repo.d.ts +1 -0
- package/dist/github/repo.js +123 -96
- package/dist/github/repo.js.map +7 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +7 -1
- package/dist/issue.d.ts +40 -9
- package/dist/issue.js +2102 -1742
- package/dist/issue.js.map +7 -1
- package/dist/issue63History.test.js +40 -42
- package/dist/issue63History.test.js.map +7 -1
- package/dist/issue63Routes.test.js +154 -143
- package/dist/issue63Routes.test.js.map +7 -1
- package/dist/issueBatchUpdate.test.js +989 -885
- package/dist/issueBatchUpdate.test.js.map +7 -1
- package/dist/issueBlockerGuard.test.js +262 -226
- package/dist/issueBlockerGuard.test.js.map +7 -1
- package/dist/issueContract.d.ts +23 -4
- package/dist/issueContract.js +416 -395
- package/dist/issueContract.js.map +7 -1
- package/dist/issueContract.test.d.ts +4 -3
- package/dist/issueContract.test.js +358 -321
- package/dist/issueContract.test.js.map +7 -1
- package/dist/issueDates.test.js +235 -233
- package/dist/issueDates.test.js.map +7 -1
- package/dist/issueInfoReadback.test.js +304 -190
- package/dist/issueInfoReadback.test.js.map +7 -1
- package/dist/issueIntake.test.js +1938 -1732
- package/dist/issueIntake.test.js.map +7 -1
- package/dist/issueJournal.d.ts +40 -19
- package/dist/issueJournal.js +229 -138
- package/dist/issueJournal.js.map +7 -1
- package/dist/issueJournal.test.js +605 -422
- package/dist/issueJournal.test.js.map +7 -1
- package/dist/issueRollup.test.d.ts +1 -0
- package/dist/issueRollup.test.js +476 -0
- package/dist/issueRollup.test.js.map +7 -0
- package/dist/issueTracking.test.js +1059 -989
- package/dist/issueTracking.test.js.map +7 -1
- package/dist/issueWriteRecovery.test.d.ts +1 -0
- package/dist/issueWriteRecovery.test.js +260 -0
- package/dist/issueWriteRecovery.test.js.map +7 -0
- package/dist/lifecycle.test.js +112 -441
- package/dist/lifecycle.test.js.map +7 -1
- package/dist/logger.js +80 -74
- package/dist/logger.js.map +7 -1
- package/dist/mcp/index.js +116 -94
- package/dist/mcp/index.js.map +7 -1
- package/dist/mcp/tools.d.ts +252 -310
- package/dist/mcp/tools.js +235 -342
- package/dist/mcp/tools.js.map +7 -1
- package/dist/pluginAuthProbe.js +63 -52
- package/dist/pluginAuthProbe.js.map +7 -1
- package/dist/pluginAuthProbe.test.js +85 -62
- package/dist/pluginAuthProbe.test.js.map +7 -1
- package/dist/pluginCredentials.test.js +282 -259
- package/dist/pluginCredentials.test.js.map +7 -1
- package/dist/pluginDoctor.test.js +653 -588
- package/dist/pluginDoctor.test.js.map +7 -1
- package/dist/pluginInstaller.d.ts +7 -5
- package/dist/pluginInstaller.js +1173 -1229
- package/dist/pluginInstaller.js.map +7 -1
- package/dist/pluginInstaller.test.js +1842 -1423
- package/dist/pluginInstaller.test.js.map +7 -1
- package/dist/pluginPackaging.test.js +417 -413
- package/dist/pluginPackaging.test.js.map +7 -1
- package/dist/pr.d.ts +114 -131
- package/dist/pr.js +1314 -1327
- package/dist/pr.js.map +7 -1
- package/dist/pr.test.js +967 -653
- package/dist/pr.test.js.map +7 -1
- package/dist/prAssociation.test.js +2419 -1788
- package/dist/prAssociation.test.js.map +7 -1
- package/dist/prDispatch.test.js +123 -89
- package/dist/prDispatch.test.js.map +7 -1
- package/dist/readView.d.ts +184 -0
- package/dist/readView.js +218 -0
- package/dist/readView.js.map +7 -0
- package/dist/readView.test.d.ts +1 -0
- package/dist/readView.test.js +146 -0
- package/dist/readView.test.js.map +7 -0
- package/dist/releaseReconciliation.test.js +267 -288
- package/dist/releaseReconciliation.test.js.map +7 -1
- package/dist/releaseWorkflow.test.js +2493 -422
- package/dist/releaseWorkflow.test.js.map +7 -1
- package/dist/review.d.ts +738 -2
- package/dist/review.js +601 -348
- package/dist/review.js.map +7 -1
- package/dist/review.test.js +1218 -812
- package/dist/review.test.js.map +7 -1
- package/dist/reviewSubmit.test.d.ts +1 -0
- package/dist/reviewSubmit.test.js +747 -0
- package/dist/reviewSubmit.test.js.map +7 -0
- package/dist/services/agentReadinessService.js +42 -37
- package/dist/services/agentReadinessService.js.map +7 -1
- package/dist/services/blockerGuardService.js +188 -188
- package/dist/services/blockerGuardService.js.map +7 -1
- package/dist/services/boardReconcileService.d.ts +125 -125
- package/dist/services/boardReconcileService.js +1295 -1421
- package/dist/services/boardReconcileService.js.map +7 -1
- package/dist/services/deliveryHealthService.js +197 -199
- package/dist/services/deliveryHealthService.js.map +7 -1
- package/dist/services/legacyIssueMigration.js +263 -277
- package/dist/services/legacyIssueMigration.js.map +7 -1
- package/dist/stagedChecks.test.js +396 -194
- package/dist/stagedChecks.test.js.map +7 -1
- package/dist/start.test.js +99 -95
- package/dist/start.test.js.map +7 -1
- package/dist/stdoutRegression.test.js +321 -358
- package/dist/stdoutRegression.test.js.map +7 -1
- package/dist/targetPolicyDiscovery.test.js +141 -143
- package/dist/targetPolicyDiscovery.test.js.map +7 -1
- package/dist/targetPolicyEntrypoints.test.js +308 -269
- package/dist/targetPolicyEntrypoints.test.js.map +7 -1
- package/dist/targetPolicyLocal.test.js +580 -1051
- package/dist/targetPolicyLocal.test.js.map +7 -1
- package/dist/targetPolicyRoutes.test.js +274 -281
- package/dist/targetPolicyRoutes.test.js.map +7 -1
- package/dist/targetRepositoryExecution.test.d.ts +1 -0
- package/dist/targetRepositoryExecution.test.js +451 -0
- package/dist/targetRepositoryExecution.test.js.map +7 -0
- package/dist/terminalMessages.js +41 -35
- package/dist/terminalMessages.js.map +7 -1
- package/dist/toolOutput.d.ts +2 -0
- package/dist/toolOutput.js +36 -0
- package/dist/toolOutput.js.map +7 -0
- package/dist/toolOutput.test.d.ts +1 -0
- package/dist/toolOutput.test.js +240 -0
- package/dist/toolOutput.test.js.map +7 -0
- package/dist/utils/atomicJson.d.ts +0 -2
- package/dist/utils/atomicJson.js +81 -77
- package/dist/utils/atomicJson.js.map +7 -1
- package/dist/utils/filesystem.d.ts +0 -8
- package/dist/utils/filesystem.js +5 -19
- package/dist/utils/filesystem.js.map +7 -1
- package/dist/utils/lockfile.js +68 -71
- package/dist/utils/lockfile.js.map +7 -1
- package/dist/verification.d.ts +1 -54
- package/dist/verification.js +976 -1941
- package/dist/verification.js.map +7 -1
- package/dist/verificationGate.test.js +127 -117
- package/dist/verificationGate.test.js.map +7 -1
- package/dist/version.js +45 -24
- package/dist/version.js.map +7 -1
- package/package.json +9 -8
- package/plugins/ai-delivery/.claude-plugin/plugin.json +2 -2
- package/plugins/ai-delivery/README.md +47 -156
- package/plugins/ai-delivery/plugin.json +1 -1
- package/plugins/ai-delivery/runtime/dist/THIRD-PARTY-NOTICES.md +238 -44
- package/plugins/ai-delivery/runtime/dist/cli.js +351 -115
- package/plugins/ai-delivery/runtime/package.json +1 -1
- package/plugins/ai-delivery/skills/intake-create/SKILL.md +14 -78
- package/plugins/ai-delivery/skills/pr-handoff/SKILL.md +35 -36
- package/plugins/ai-delivery/skills/worktree-lifecycle/SKILL.md +14 -15
- package/dist/investigationCompletion.test.js +0 -728
- package/dist/investigationCompletion.test.js.map +0 -1
- package/dist/services/deliveryAdmission.d.ts +0 -49
- package/dist/services/deliveryAdmission.js +0 -165
- package/dist/services/deliveryAdmission.js.map +0 -1
- package/dist/services/worktreeRegistry.d.ts +0 -434
- package/dist/services/worktreeRegistry.js +0 -1248
- package/dist/services/worktreeRegistry.js.map +0 -1
- package/dist/setup.d.ts +0 -60
- package/dist/setup.js +0 -585
- package/dist/setup.js.map +0 -1
- package/dist/setup.test.js +0 -3329
- package/dist/setup.test.js.map +0 -1
- package/dist/worktree.d.ts +0 -28
- package/dist/worktree.js +0 -188
- package/dist/worktree.js.map +0 -1
- package/dist/worktreeTransition.d.ts +0 -211
- package/dist/worktreeTransition.js +0 -1037
- package/dist/worktreeTransition.js.map +0 -1
- package/dist/worktreeTransition.test.js +0 -1191
- package/dist/worktreeTransition.test.js.map +0 -1
- /package/dist/{investigationCompletion.test.d.ts → build.test.d.ts} +0 -0
- /package/dist/{setup.test.d.ts → callerErrors.test.d.ts} +0 -0
- /package/dist/{worktreeTransition.test.d.ts → deliveryBoard.test.d.ts} +0 -0
package/dist/cliResult.test.js
CHANGED
|
@@ -1,395 +1,450 @@
|
|
|
1
|
-
import assert from
|
|
2
|
-
import { spawnSync } from
|
|
3
|
-
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from
|
|
4
|
-
import { tmpdir } from
|
|
5
|
-
import { join } from
|
|
6
|
-
import { test } from
|
|
7
|
-
import { pathToFileURL } from
|
|
8
|
-
import { DeliveryError, getMachineRequestDiagnostics, setMachineRequestDiagnostics } from
|
|
9
|
-
test(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { spawnSync } from "node:child_process";
|
|
3
|
+
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
import { test } from "vitest";
|
|
7
|
+
import { pathToFileURL } from "node:url";
|
|
8
|
+
import { DeliveryError, getMachineRequestDiagnostics, setMachineRequestDiagnostics } from "./errors.js";
|
|
9
|
+
test("actual CLI serializes incomplete native update evidence and exits nonzero", { tags: ["release"] }, () => {
|
|
10
|
+
const cli = pathToFileURL(join(process.cwd(), "dist", "cli.js")).href;
|
|
11
|
+
const dispatch = pathToFileURL(join(process.cwd(), "dist", "dispatch.js")).href;
|
|
12
|
+
const owner = pathToFileURL(join(process.cwd(), "dist", "issue.js")).href;
|
|
13
|
+
const partial = {
|
|
14
|
+
status: "update-incomplete",
|
|
15
|
+
native: { status: "unknown", repository: "example/widget", issueNumber: 17, readback: null },
|
|
16
|
+
project: { status: "pending", desiredStatus: "Done" },
|
|
17
|
+
recovery: { tool: "issue_batch_update" }
|
|
18
|
+
};
|
|
19
|
+
const result = spawnSync(
|
|
20
|
+
process.execPath,
|
|
21
|
+
[
|
|
22
|
+
"--experimental-test-module-mocks",
|
|
23
|
+
"--no-warnings",
|
|
24
|
+
"--input-type=module",
|
|
25
|
+
"-e",
|
|
26
|
+
`import assert from 'node:assert/strict'; import { mock } from 'node:test'; import { IssueUpdateIncompleteError } from ${JSON.stringify(owner)};
|
|
25
27
|
mock.module(${JSON.stringify(dispatch)}, { exports: {
|
|
26
28
|
contextFor: () => { throw new Error('Unexpected configuration access'); },
|
|
27
29
|
executeTool: async (name, input) => { assert.equal(name, 'issue_update'); assert.equal(input.issueNumber, 17); throw new IssueUpdateIncompleteError(${JSON.stringify(partial)}); }
|
|
28
30
|
}});
|
|
29
31
|
process.argv = [process.execPath, ${JSON.stringify(cli)}, '--repo', 'example/widget', 'update', '--issue', '17', '--state', 'closed', '--close-reason', 'completed'];
|
|
30
|
-
await import(${JSON.stringify(cli)})
|
|
31
|
-
],
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
await import(${JSON.stringify(cli)});`
|
|
33
|
+
],
|
|
34
|
+
{ encoding: "utf8" }
|
|
35
|
+
);
|
|
36
|
+
assert.equal(result.status, 1);
|
|
37
|
+
assert.deepEqual(JSON.parse(result.stdout), partial);
|
|
38
|
+
assert.equal(result.stderr, "");
|
|
35
39
|
});
|
|
36
40
|
test.each([
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
])(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
41
|
+
[{ schemaVersion: "ai-delivery.board-reconcile-plan@1", scopeComplete: true, summary: { unresolved: 4 } }, 0],
|
|
42
|
+
[{ schemaVersion: "ai-delivery.board-reconcile-plan@1", scopeComplete: false }, 1],
|
|
43
|
+
...["failed", "drifted", "refused", "unknown", "unresolved"].map((key) => [
|
|
44
|
+
{ schemaVersion: "ai-delivery.board-reconcile-result@1", scopeComplete: true, summary: { applied: 1, [key]: 1 } },
|
|
45
|
+
1
|
|
46
|
+
]),
|
|
47
|
+
[
|
|
48
|
+
{
|
|
49
|
+
schemaVersion: "ai-delivery.board-reconcile-result@1",
|
|
50
|
+
scopeComplete: true,
|
|
51
|
+
summary: { applied: 2, satisfied: 1, failed: 0, drifted: 0, refused: 0, unknown: 0, unresolved: 0 }
|
|
52
|
+
},
|
|
53
|
+
0
|
|
54
|
+
]
|
|
55
|
+
])(
|
|
56
|
+
"CLI prints the complete reconciliation result before selecting its exit status (%j)",
|
|
57
|
+
{ tags: ["release"] },
|
|
58
|
+
(value, exit) => {
|
|
59
|
+
const helper = pathToFileURL(join(process.cwd(), "dist", "cliResult.js")).href;
|
|
60
|
+
const result = spawnSync(
|
|
61
|
+
process.execPath,
|
|
62
|
+
[
|
|
63
|
+
"--input-type=module",
|
|
64
|
+
"-e",
|
|
65
|
+
`import { printCommandResult } from ${JSON.stringify(helper)}; printCommandResult('board_reconcile', ${JSON.stringify(value)});`
|
|
66
|
+
],
|
|
67
|
+
{ encoding: "utf8" }
|
|
68
|
+
);
|
|
58
69
|
assert.equal(result.status, exit);
|
|
59
70
|
assert.deepEqual(JSON.parse(result.stdout), value);
|
|
60
|
-
assert.equal(result.stderr,
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
71
|
+
assert.equal(result.stderr, "");
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
test(
|
|
75
|
+
"actual board CLI advertises bounded data-only files and validates them before credentials",
|
|
76
|
+
{ tags: ["release"] },
|
|
77
|
+
() => {
|
|
78
|
+
const root = mkdtempSync(join(tmpdir(), "board-cli-input-"));
|
|
79
|
+
const cli = join(process.cwd(), "dist", "cli.js");
|
|
65
80
|
try {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
81
|
+
const help = spawnSync(process.execPath, [cli, "board:reconcile", "--help"], { cwd: root, encoding: "utf8" });
|
|
82
|
+
assert.equal(help.status, 0);
|
|
83
|
+
for (const option of [
|
|
84
|
+
"--repositories",
|
|
85
|
+
"--checkouts-file",
|
|
86
|
+
"--dry-run",
|
|
87
|
+
"--apply",
|
|
88
|
+
"--plan-file",
|
|
89
|
+
"--prior-result-file"
|
|
90
|
+
])
|
|
91
|
+
assert.ok(help.stdout.includes(option));
|
|
92
|
+
const huge = join(root, "huge.json");
|
|
93
|
+
writeFileSync(huge, " ".repeat(16 * 1024 * 1024 + 1));
|
|
94
|
+
const invalid = spawnSync(
|
|
95
|
+
process.execPath,
|
|
96
|
+
[cli, "board:reconcile", "--repositories", "example/widget", "--apply", "--plan-file", huge],
|
|
97
|
+
{ cwd: root, env: { ...process.env, AI_DELIVERY_CONFIG: join(root, "missing-settings") }, encoding: "utf8" }
|
|
98
|
+
);
|
|
99
|
+
assert.equal(invalid.status, 1);
|
|
100
|
+
assert.match(invalid.stderr, /16 MiB/u);
|
|
101
|
+
assert.doesNotMatch(invalid.stderr, /missing-settings|credential/u);
|
|
102
|
+
const exclusive = spawnSync(
|
|
103
|
+
process.execPath,
|
|
104
|
+
[cli, "board:reconcile", "--repositories", "example/widget", "--dry-run", "--apply"],
|
|
105
|
+
{ cwd: root, encoding: "utf8" }
|
|
106
|
+
);
|
|
107
|
+
assert.equal(exclusive.status, 1);
|
|
108
|
+
assert.match(exclusive.stderr, /dry-run.*apply|apply.*dry-run/u);
|
|
109
|
+
} finally {
|
|
110
|
+
rmSync(root, { recursive: true, force: true });
|
|
89
111
|
}
|
|
112
|
+
}
|
|
113
|
+
);
|
|
114
|
+
test("CLI version agrees with its adjacent package independently of caller cwd", { tags: ["release"] }, () => {
|
|
115
|
+
const metadata = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
|
|
116
|
+
assert.ok(typeof metadata === "object" && metadata !== null && "version" in metadata);
|
|
117
|
+
assert.equal(typeof metadata.version, "string");
|
|
118
|
+
const cli = join(process.cwd(), "dist", "cli.js");
|
|
119
|
+
const caller = mkdtempSync(join(tmpdir(), "ai-delivery-version-caller-"));
|
|
120
|
+
try {
|
|
121
|
+
writeFileSync(join(caller, "package.json"), JSON.stringify({ name: "unrelated-caller", version: "9.9.9" }));
|
|
122
|
+
const result = spawnSync(process.execPath, [cli, "--version"], { cwd: caller, encoding: "utf8" });
|
|
123
|
+
assert.equal(result.status, 0);
|
|
124
|
+
assert.equal(result.stderr, "");
|
|
125
|
+
assert.equal(result.stdout.trim(), metadata.version);
|
|
126
|
+
const versionModule = pathToFileURL(join(process.cwd(), "dist", "version.js")).href;
|
|
127
|
+
const shared = spawnSync(
|
|
128
|
+
process.execPath,
|
|
129
|
+
[
|
|
130
|
+
"--input-type=module",
|
|
131
|
+
"-e",
|
|
132
|
+
`import { PACKAGE_VERSION } from ${JSON.stringify(versionModule)}; console.log(PACKAGE_VERSION);`
|
|
133
|
+
],
|
|
134
|
+
{ cwd: caller, encoding: "utf8" }
|
|
135
|
+
);
|
|
136
|
+
assert.equal(shared.status, 0, shared.stderr);
|
|
137
|
+
assert.equal(shared.stderr, "");
|
|
138
|
+
assert.equal(shared.stdout.trim(), metadata.version);
|
|
139
|
+
} finally {
|
|
140
|
+
rmSync(caller, { recursive: true, force: true });
|
|
141
|
+
}
|
|
90
142
|
});
|
|
91
|
-
test(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
143
|
+
test("CLI preserves recoverable start JSON and exits nonzero after creation failure", { tags: ["release"] }, () => {
|
|
144
|
+
const helper = pathToFileURL(join(process.cwd(), "dist", "cliResult.js")).href;
|
|
145
|
+
const failure = {
|
|
146
|
+
schemaVersion: "ai-delivery.issue-start-registration@1",
|
|
147
|
+
status: "created-not-started",
|
|
148
|
+
createdIssue: { number: 17 }
|
|
149
|
+
};
|
|
150
|
+
const code = `import { printCommandResult } from ${JSON.stringify(helper)};printCommandResult('issue_start', ${JSON.stringify(failure)});`;
|
|
151
|
+
const result = spawnSync(process.execPath, ["--input-type=module", "-e", code], { encoding: "utf8" });
|
|
152
|
+
assert.equal(result.status, 1);
|
|
153
|
+
assert.deepEqual(JSON.parse(result.stdout), failure);
|
|
154
|
+
assert.equal(result.stderr, "");
|
|
155
|
+
const ordinary = spawnSync(
|
|
156
|
+
process.execPath,
|
|
157
|
+
[
|
|
158
|
+
"--input-type=module",
|
|
159
|
+
"-e",
|
|
160
|
+
`import { printCommandResult } from ${JSON.stringify(helper)};printCommandResult('issue_start', {status:'started'});`
|
|
161
|
+
],
|
|
162
|
+
{ encoding: "utf8" }
|
|
163
|
+
);
|
|
164
|
+
assert.equal(ordinary.status, 0);
|
|
165
|
+
const parsed = JSON.parse(ordinary.stdout);
|
|
166
|
+
assert.ok(parsed !== null && typeof parsed === "object" && "status" in parsed);
|
|
167
|
+
assert.equal(parsed.status, "started");
|
|
116
168
|
});
|
|
117
|
-
test(
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
assert.ok(parsed !== null && typeof parsed === 'object' && 'status' in parsed);
|
|
139
|
-
assert.equal(parsed.status, 'started');
|
|
169
|
+
test("CLI known-issue incomplete start preserves recovery JSON and exits nonzero", { tags: ["release"] }, () => {
|
|
170
|
+
const helper = pathToFileURL(join(process.cwd(), "dist", "cliResult.js")).href;
|
|
171
|
+
const failure = {
|
|
172
|
+
status: "start-incomplete",
|
|
173
|
+
issueNumber: 17,
|
|
174
|
+
repository: "example/widget",
|
|
175
|
+
failure: { phase: "project-status", message: "Readback failed" },
|
|
176
|
+
safeResume: { tool: "issue_start", arguments: { repo: "example/widget", issueNumber: 17, branch: "issue/17" } }
|
|
177
|
+
};
|
|
178
|
+
const result = spawnSync(
|
|
179
|
+
process.execPath,
|
|
180
|
+
[
|
|
181
|
+
"--input-type=module",
|
|
182
|
+
"-e",
|
|
183
|
+
`import { printCommandResult } from ${JSON.stringify(helper)}; printCommandResult('issue_start', ${JSON.stringify(failure)});`
|
|
184
|
+
],
|
|
185
|
+
{ encoding: "utf8" }
|
|
186
|
+
);
|
|
187
|
+
assert.equal(result.status, 1);
|
|
188
|
+
assert.deepEqual(JSON.parse(result.stdout), failure);
|
|
189
|
+
assert.equal(result.stderr, "");
|
|
140
190
|
});
|
|
141
|
-
test(
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
assert.equal(result.status, 1);
|
|
156
|
-
assert.deepEqual(JSON.parse(result.stdout), failure);
|
|
157
|
-
assert.equal(result.stderr, '');
|
|
191
|
+
test("the extracted real CLI error renderer preserves ordinary refusal, exit and stdout", { tags: ["release"] }, () => {
|
|
192
|
+
const helper = pathToFileURL(join(process.cwd(), "dist", "cliResult.js")).href;
|
|
193
|
+
const result = spawnSync(
|
|
194
|
+
process.execPath,
|
|
195
|
+
[
|
|
196
|
+
"--input-type=module",
|
|
197
|
+
"-e",
|
|
198
|
+
`import { printCommandError } from ${JSON.stringify(helper)}; printCommandError(new Error('ordinary refusal'));`
|
|
199
|
+
],
|
|
200
|
+
{ encoding: "utf8" }
|
|
201
|
+
);
|
|
202
|
+
assert.equal(result.status, 1);
|
|
203
|
+
assert.equal(result.stdout, "");
|
|
204
|
+
assert.equal(result.stderr, "ai-delivery: ordinary refusal\n");
|
|
158
205
|
});
|
|
159
|
-
test(
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
206
|
+
test("machine diagnostics are immutable identity-bound data and do not change error serialization", () => {
|
|
207
|
+
const error = new DeliveryError("safe refusal");
|
|
208
|
+
Object.assign(error, { status: 503 });
|
|
209
|
+
const before = JSON.stringify(error);
|
|
210
|
+
const input = {
|
|
211
|
+
phase: "rest.request",
|
|
212
|
+
endpoint: "pulls.merge",
|
|
213
|
+
status: 503,
|
|
214
|
+
code: "ECONNRESET",
|
|
215
|
+
requestId: "ABCD:1234:5678:9ABC:DEF0"
|
|
216
|
+
};
|
|
217
|
+
setMachineRequestDiagnostics(error, input);
|
|
218
|
+
const diagnostic = getMachineRequestDiagnostics(error);
|
|
219
|
+
assert.deepEqual(diagnostic, {
|
|
220
|
+
phase: "rest.request",
|
|
221
|
+
endpoint: "pulls.merge",
|
|
222
|
+
status: 503,
|
|
223
|
+
code: "ECONNRESET",
|
|
224
|
+
requestId: "ABCD:1234:5678:9ABC:DEF0"
|
|
225
|
+
});
|
|
226
|
+
assert.ok(diagnostic && Object.isFrozen(diagnostic));
|
|
227
|
+
input.status = 401;
|
|
228
|
+
assert.equal(Reflect.set(diagnostic, "status", 401), false);
|
|
229
|
+
setMachineRequestDiagnostics(error, input);
|
|
230
|
+
assert.equal(getMachineRequestDiagnostics(error)?.status, 503);
|
|
231
|
+
assert.equal(JSON.stringify(error), before);
|
|
232
|
+
assert.equal(getMachineRequestDiagnostics(new Error("ordinary refusal")), void 0);
|
|
233
|
+
assert.equal(getMachineRequestDiagnostics({ name: "DeliveryError", status: 503, diagnostic }), void 0);
|
|
169
234
|
});
|
|
170
|
-
test(
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
235
|
+
test("invalid machine metadata remains UNKNOWN without getter or coercion execution", () => {
|
|
236
|
+
const invalidStatuses = [
|
|
237
|
+
void 0,
|
|
238
|
+
null,
|
|
239
|
+
NaN,
|
|
240
|
+
Infinity,
|
|
241
|
+
-Infinity,
|
|
242
|
+
99,
|
|
243
|
+
600,
|
|
244
|
+
401.5,
|
|
245
|
+
"403",
|
|
246
|
+
{},
|
|
247
|
+
[],
|
|
248
|
+
/* @__PURE__ */ Symbol("private")
|
|
249
|
+
];
|
|
250
|
+
for (const status of invalidStatuses) {
|
|
251
|
+
const error2 = new DeliveryError("safe refusal");
|
|
252
|
+
setMachineRequestDiagnostics(error2, {
|
|
253
|
+
phase: "private-phase",
|
|
254
|
+
endpoint: "https://private.invalid/token",
|
|
255
|
+
status,
|
|
256
|
+
code: "private-code",
|
|
257
|
+
requestId: "ghp_fictional_private_token"
|
|
189
258
|
});
|
|
190
|
-
assert.
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
assert.equal(getMachineRequestDiagnostics(new Error('ordinary refusal')), undefined);
|
|
197
|
-
assert.equal(getMachineRequestDiagnostics({ name: 'DeliveryError', status: 503, diagnostic }), undefined);
|
|
198
|
-
});
|
|
199
|
-
test('invalid machine metadata remains UNKNOWN without getter or coercion execution', () => {
|
|
200
|
-
const invalidStatuses = [
|
|
201
|
-
undefined,
|
|
202
|
-
null,
|
|
203
|
-
NaN,
|
|
204
|
-
Infinity,
|
|
205
|
-
-Infinity,
|
|
206
|
-
99,
|
|
207
|
-
600,
|
|
208
|
-
401.5,
|
|
209
|
-
'403',
|
|
210
|
-
{},
|
|
211
|
-
[],
|
|
212
|
-
Symbol('private'),
|
|
213
|
-
];
|
|
214
|
-
for (const status of invalidStatuses) {
|
|
215
|
-
const error = new DeliveryError('safe refusal');
|
|
216
|
-
setMachineRequestDiagnostics(error, {
|
|
217
|
-
phase: 'private-phase',
|
|
218
|
-
endpoint: 'https://private.invalid/token',
|
|
219
|
-
status,
|
|
220
|
-
code: 'private-code',
|
|
221
|
-
requestId: 'ghp_fictional_private_token',
|
|
222
|
-
});
|
|
223
|
-
assert.deepEqual(getMachineRequestDiagnostics(error), {
|
|
224
|
-
phase: 'UNKNOWN',
|
|
225
|
-
endpoint: 'UNKNOWN',
|
|
226
|
-
status: 'UNKNOWN',
|
|
227
|
-
code: 'UNKNOWN',
|
|
228
|
-
requestId: 'UNKNOWN',
|
|
229
|
-
});
|
|
230
|
-
assert.equal(JSON.stringify(error).includes('private'), false);
|
|
231
|
-
}
|
|
232
|
-
let invoked = 0;
|
|
233
|
-
const input = {
|
|
234
|
-
phase: 'rest.request',
|
|
235
|
-
endpoint: 'pulls.merge',
|
|
236
|
-
status: 500,
|
|
237
|
-
code: 'ECONNRESET',
|
|
238
|
-
requestId: 'ABCD:1234:5678:9ABC:DEF0',
|
|
239
|
-
};
|
|
240
|
-
for (const key of Object.keys(input))
|
|
241
|
-
Object.defineProperty(input, key, {
|
|
242
|
-
get() {
|
|
243
|
-
invoked++;
|
|
244
|
-
throw new Error('private getter');
|
|
245
|
-
},
|
|
246
|
-
});
|
|
247
|
-
const error = new DeliveryError('safe refusal');
|
|
248
|
-
setMachineRequestDiagnostics(error, input);
|
|
249
|
-
assert.equal(invoked, 0);
|
|
250
|
-
assert.deepEqual(getMachineRequestDiagnostics(error), {
|
|
251
|
-
phase: 'UNKNOWN',
|
|
252
|
-
endpoint: 'UNKNOWN',
|
|
253
|
-
status: 'UNKNOWN',
|
|
254
|
-
code: 'UNKNOWN',
|
|
255
|
-
requestId: 'UNKNOWN',
|
|
259
|
+
assert.deepEqual(getMachineRequestDiagnostics(error2), {
|
|
260
|
+
phase: "UNKNOWN",
|
|
261
|
+
endpoint: "UNKNOWN",
|
|
262
|
+
status: "UNKNOWN",
|
|
263
|
+
code: "UNKNOWN",
|
|
264
|
+
requestId: "UNKNOWN"
|
|
256
265
|
});
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
+
assert.equal(JSON.stringify(error2).includes("private"), false);
|
|
267
|
+
}
|
|
268
|
+
let invoked = 0;
|
|
269
|
+
const input = {
|
|
270
|
+
phase: "rest.request",
|
|
271
|
+
endpoint: "pulls.merge",
|
|
272
|
+
status: 500,
|
|
273
|
+
code: "ECONNRESET",
|
|
274
|
+
requestId: "ABCD:1234:5678:9ABC:DEF0"
|
|
275
|
+
};
|
|
276
|
+
for (const key of Object.keys(input))
|
|
277
|
+
Object.defineProperty(input, key, {
|
|
278
|
+
get() {
|
|
279
|
+
invoked++;
|
|
280
|
+
throw new Error("private getter");
|
|
281
|
+
}
|
|
266
282
|
});
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
`ABCD:${'A'.repeat(31)}:${'B'.repeat(30)}:${'C'.repeat(30)}:${'D'.repeat(30)}`,
|
|
286
|
-
];
|
|
287
|
-
for (const requestId of requestIds) {
|
|
288
|
-
const error = new DeliveryError('safe refusal');
|
|
289
|
-
setMachineRequestDiagnostics(error, {
|
|
290
|
-
phase: 'rest.request',
|
|
291
|
-
endpoint: 'pulls.merge',
|
|
292
|
-
status: 500,
|
|
293
|
-
code: 'ECONNRESET\n',
|
|
294
|
-
requestId,
|
|
295
|
-
});
|
|
296
|
-
assert.equal(getMachineRequestDiagnostics(error)?.requestId, 'UNKNOWN');
|
|
297
|
-
assert.equal(getMachineRequestDiagnostics(error)?.code, 'UNKNOWN');
|
|
298
|
-
}
|
|
299
|
-
for (const code of [
|
|
300
|
-
'ECONNRESET',
|
|
301
|
-
'ECONNREFUSED',
|
|
302
|
-
'ENOTFOUND',
|
|
303
|
-
'EAI_AGAIN',
|
|
304
|
-
'ETIMEDOUT',
|
|
305
|
-
'ABORT_ERR',
|
|
306
|
-
'UND_ERR_CONNECT_TIMEOUT',
|
|
307
|
-
'UND_ERR_SOCKET',
|
|
308
|
-
]) {
|
|
309
|
-
const error = new DeliveryError('safe refusal');
|
|
310
|
-
setMachineRequestDiagnostics(error, {
|
|
311
|
-
phase: 'graphql.request',
|
|
312
|
-
endpoint: 'graphql',
|
|
313
|
-
status: undefined,
|
|
314
|
-
code,
|
|
315
|
-
requestId: undefined,
|
|
316
|
-
});
|
|
317
|
-
assert.equal(getMachineRequestDiagnostics(error)?.code, code);
|
|
318
|
-
assert.equal(getMachineRequestDiagnostics(error)?.status, 'UNKNOWN');
|
|
283
|
+
const error = new DeliveryError("safe refusal");
|
|
284
|
+
setMachineRequestDiagnostics(error, input);
|
|
285
|
+
assert.equal(invoked, 0);
|
|
286
|
+
assert.deepEqual(getMachineRequestDiagnostics(error), {
|
|
287
|
+
phase: "UNKNOWN",
|
|
288
|
+
endpoint: "UNKNOWN",
|
|
289
|
+
status: "UNKNOWN",
|
|
290
|
+
code: "UNKNOWN",
|
|
291
|
+
requestId: "UNKNOWN"
|
|
292
|
+
});
|
|
293
|
+
const proxy = new Proxy(input, {
|
|
294
|
+
getOwnPropertyDescriptor() {
|
|
295
|
+
invoked++;
|
|
296
|
+
throw new Error("private trap");
|
|
297
|
+
},
|
|
298
|
+
get() {
|
|
299
|
+
invoked++;
|
|
300
|
+
throw new Error("private trap");
|
|
319
301
|
}
|
|
302
|
+
});
|
|
303
|
+
const proxyError = new DeliveryError("safe refusal");
|
|
304
|
+
setMachineRequestDiagnostics(proxyError, proxy);
|
|
305
|
+
assert.deepEqual(getMachineRequestDiagnostics(proxyError), getMachineRequestDiagnostics(error));
|
|
306
|
+
assert.equal(getMachineRequestDiagnostics(proxy), void 0);
|
|
307
|
+
assert.equal(invoked, 0);
|
|
320
308
|
});
|
|
321
|
-
test(
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
309
|
+
test("request identifiers and transport codes reject oversized, control and private-looking values", () => {
|
|
310
|
+
const requestIds = [
|
|
311
|
+
void 0,
|
|
312
|
+
null,
|
|
313
|
+
{},
|
|
314
|
+
[],
|
|
315
|
+
"ABCD:1234:5678",
|
|
316
|
+
"ABCD:1234:5678:9ABC:DEF0\r\n",
|
|
317
|
+
"ABCD:1234:5678:9ABC:\x1B",
|
|
318
|
+
"ABCD:1234:5678:9ABC:\u79D8\u5BC6",
|
|
319
|
+
"/private/credential.pem",
|
|
320
|
+
"Bearer fictional_private_token",
|
|
321
|
+
`ABCD:${"A".repeat(31)}:${"B".repeat(30)}:${"C".repeat(30)}:${"D".repeat(30)}`
|
|
322
|
+
];
|
|
323
|
+
for (const requestId of requestIds) {
|
|
324
|
+
const error = new DeliveryError("safe refusal");
|
|
325
|
+
setMachineRequestDiagnostics(error, {
|
|
326
|
+
phase: "rest.request",
|
|
327
|
+
endpoint: "pulls.merge",
|
|
328
|
+
status: 500,
|
|
329
|
+
code: "ECONNRESET\n",
|
|
330
|
+
requestId
|
|
331
|
+
});
|
|
332
|
+
assert.equal(getMachineRequestDiagnostics(error)?.requestId, "UNKNOWN");
|
|
333
|
+
assert.equal(getMachineRequestDiagnostics(error)?.code, "UNKNOWN");
|
|
334
|
+
}
|
|
335
|
+
for (const code of [
|
|
336
|
+
"ECONNRESET",
|
|
337
|
+
"ECONNREFUSED",
|
|
338
|
+
"ENOTFOUND",
|
|
339
|
+
"EAI_AGAIN",
|
|
340
|
+
"ETIMEDOUT",
|
|
341
|
+
"ABORT_ERR",
|
|
342
|
+
"UND_ERR_CONNECT_TIMEOUT",
|
|
343
|
+
"UND_ERR_SOCKET"
|
|
344
|
+
]) {
|
|
345
|
+
const error = new DeliveryError("safe refusal");
|
|
346
|
+
setMachineRequestDiagnostics(error, {
|
|
347
|
+
phase: "graphql.request",
|
|
348
|
+
endpoint: "graphql",
|
|
349
|
+
status: void 0,
|
|
350
|
+
code,
|
|
351
|
+
requestId: void 0
|
|
352
|
+
});
|
|
353
|
+
assert.equal(getMachineRequestDiagnostics(error)?.code, code);
|
|
354
|
+
assert.equal(getMachineRequestDiagnostics(error)?.status, "UNKNOWN");
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
test(
|
|
358
|
+
"the real CLI renderer bounds diagnostics and leaves the unchanged refusal line last",
|
|
359
|
+
{ tags: ["release"] },
|
|
360
|
+
() => {
|
|
361
|
+
const helper = pathToFileURL(join(process.cwd(), "dist", "cliResult.js")).href;
|
|
362
|
+
const errors = pathToFileURL(join(process.cwd(), "dist", "errors.js")).href;
|
|
363
|
+
const requestId = `ABCD:${"A".repeat(30)}:${"B".repeat(30)}:${"C".repeat(30)}:${"D".repeat(30)}`;
|
|
325
364
|
assert.equal(requestId.length, 128);
|
|
326
|
-
const code = `import { DeliveryError,setMachineRequestDiagnostics } from ${JSON.stringify(errors)}; import { printCommandError } from ${JSON.stringify(helper)}; const error=new DeliveryError('safe refusal','fictional_private_hint'); setMachineRequestDiagnostics(error,${JSON.stringify({ phase:
|
|
327
|
-
const result = spawnSync(process.execPath, [
|
|
365
|
+
const code = `import { DeliveryError,setMachineRequestDiagnostics } from ${JSON.stringify(errors)}; import { printCommandError } from ${JSON.stringify(helper)}; const error=new DeliveryError('safe refusal','fictional_private_hint'); setMachineRequestDiagnostics(error,${JSON.stringify({ phase: "rest.request", endpoint: "pulls.merge", status: 500, code: "UND_ERR_CONNECT_TIMEOUT", requestId })}); printCommandError(error);`;
|
|
366
|
+
const result = spawnSync(process.execPath, ["--input-type=module", "-e", code], { encoding: "utf8" });
|
|
328
367
|
assert.equal(result.status, 1);
|
|
329
|
-
assert.equal(result.stdout,
|
|
330
|
-
assert.equal(result.stderr.includes(
|
|
331
|
-
assert.ok(Buffer.byteLength(result.stderr.split(
|
|
332
|
-
assert.equal(result.stderr.trimEnd().split(
|
|
368
|
+
assert.equal(result.stdout, "");
|
|
369
|
+
assert.equal(result.stderr.includes("fictional_private_hint"), false);
|
|
370
|
+
assert.ok(Buffer.byteLength(result.stderr.split("\n")[0] + "\n") <= 512);
|
|
371
|
+
assert.equal(result.stderr.trimEnd().split("\n").at(-1), "ai-delivery: safe refusal");
|
|
372
|
+
}
|
|
373
|
+
);
|
|
374
|
+
test("CLI batch partial failure prints every result before returning nonzero", { tags: ["release"] }, () => {
|
|
375
|
+
const helper = pathToFileURL(join(process.cwd(), "dist", "cliResult.js")).href;
|
|
376
|
+
const partial = {
|
|
377
|
+
results: [
|
|
378
|
+
{ issueNumber: 1, status: "applied" },
|
|
379
|
+
{ issueNumber: 2, status: "failed", reason: "Native readback unavailable" }
|
|
380
|
+
],
|
|
381
|
+
summary: { failed: 1 }
|
|
382
|
+
};
|
|
383
|
+
const result = spawnSync(
|
|
384
|
+
process.execPath,
|
|
385
|
+
[
|
|
386
|
+
"--input-type=module",
|
|
387
|
+
"-e",
|
|
388
|
+
`import { printCommandResult } from ${JSON.stringify(helper)};printCommandResult('issue_batch_update',${JSON.stringify(partial)});`
|
|
389
|
+
],
|
|
390
|
+
{ encoding: "utf8" }
|
|
391
|
+
);
|
|
392
|
+
assert.equal(result.status, 1);
|
|
393
|
+
assert.deepEqual(JSON.parse(result.stdout), partial);
|
|
394
|
+
assert.equal(result.stderr, "");
|
|
395
|
+
const success = spawnSync(
|
|
396
|
+
process.execPath,
|
|
397
|
+
[
|
|
398
|
+
"--input-type=module",
|
|
399
|
+
"-e",
|
|
400
|
+
`import { printCommandResult } from ${JSON.stringify(helper)};printCommandResult('issue_batch_update',{summary:{failed:0}});`
|
|
401
|
+
],
|
|
402
|
+
{ encoding: "utf8" }
|
|
403
|
+
);
|
|
404
|
+
assert.equal(success.status, 0);
|
|
333
405
|
});
|
|
334
|
-
test(
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
406
|
+
test("actual CLI batch input validates before configuration or native access", { tags: ["release"] }, () => {
|
|
407
|
+
const root = mkdtempSync(join(tmpdir(), "batch-cli-refusal-"));
|
|
408
|
+
try {
|
|
409
|
+
const file = join(root, "items.json");
|
|
410
|
+
writeFileSync(file, "[]");
|
|
411
|
+
const result = spawnSync(
|
|
412
|
+
process.execPath,
|
|
413
|
+
[
|
|
414
|
+
join(process.cwd(), "dist", "cli.js"),
|
|
415
|
+
"--repo",
|
|
416
|
+
"example/widget",
|
|
417
|
+
"batch:update",
|
|
418
|
+
"--items-file",
|
|
419
|
+
file,
|
|
420
|
+
"--dry-run"
|
|
421
|
+
],
|
|
422
|
+
{
|
|
423
|
+
cwd: root,
|
|
424
|
+
encoding: "utf8",
|
|
425
|
+
env: { PATH: process.env.PATH, AI_DELIVERY_CONFIG: join(root, "absent-settings.json") }
|
|
426
|
+
}
|
|
427
|
+
);
|
|
348
428
|
assert.equal(result.status, 1);
|
|
349
|
-
assert.
|
|
350
|
-
assert.
|
|
351
|
-
const
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
file,
|
|
370
|
-
'--dry-run',
|
|
371
|
-
], {
|
|
372
|
-
cwd: root,
|
|
373
|
-
encoding: 'utf8',
|
|
374
|
-
env: { PATH: process.env.PATH, AI_DELIVERY_CONFIG: join(root, 'absent-settings.json') },
|
|
375
|
-
});
|
|
376
|
-
assert.equal(result.status, 1);
|
|
377
|
-
assert.equal(result.stdout, '');
|
|
378
|
-
assert.doesNotMatch(result.stderr, /absent-settings|credential|token/iu);
|
|
379
|
-
const diagnostic = JSON.parse(result.stderr.replace(/^ai-delivery: /u, '').trim());
|
|
380
|
-
assert.equal(diagnostic.failures[0].field, 'items');
|
|
381
|
-
assert.equal(diagnostic.failures[0].code, 'field.type');
|
|
382
|
-
writeFileSync(file, JSON.stringify([{ issueNumber: 1, PRIVATE_PROPERTY: 'PRIVATE_VALUE' }]));
|
|
383
|
-
const privateInput = spawnSync(process.execPath, [join(process.cwd(), 'dist', 'cli.js'), '--repo', 'example/widget', 'batch:update', '--items-file', file], {
|
|
384
|
-
cwd: root,
|
|
385
|
-
encoding: 'utf8',
|
|
386
|
-
env: { PATH: process.env.PATH, AI_DELIVERY_CONFIG: join(root, 'absent-settings.json') },
|
|
387
|
-
});
|
|
388
|
-
assert.equal(privateInput.status, 1);
|
|
389
|
-
assert.doesNotMatch(privateInput.stderr, /PRIVATE_PROPERTY|PRIVATE_VALUE|absent-settings/u);
|
|
390
|
-
}
|
|
391
|
-
finally {
|
|
392
|
-
rmSync(root, { recursive: true, force: true });
|
|
393
|
-
}
|
|
429
|
+
assert.equal(result.stdout, "");
|
|
430
|
+
assert.doesNotMatch(result.stderr, /absent-settings|credential|token/iu);
|
|
431
|
+
const diagnostic = JSON.parse(result.stderr.replace(/^ai-delivery: /u, "").trim());
|
|
432
|
+
assert.equal(diagnostic.failures[0].field, "items");
|
|
433
|
+
assert.equal(diagnostic.failures[0].code, "field.type");
|
|
434
|
+
writeFileSync(file, JSON.stringify([{ issueNumber: 1, PRIVATE_PROPERTY: "PRIVATE_VALUE" }]));
|
|
435
|
+
const privateInput = spawnSync(
|
|
436
|
+
process.execPath,
|
|
437
|
+
[join(process.cwd(), "dist", "cli.js"), "--repo", "example/widget", "batch:update", "--items-file", file],
|
|
438
|
+
{
|
|
439
|
+
cwd: root,
|
|
440
|
+
encoding: "utf8",
|
|
441
|
+
env: { PATH: process.env.PATH, AI_DELIVERY_CONFIG: join(root, "absent-settings.json") }
|
|
442
|
+
}
|
|
443
|
+
);
|
|
444
|
+
assert.equal(privateInput.status, 1);
|
|
445
|
+
assert.doesNotMatch(privateInput.stderr, /PRIVATE_PROPERTY|PRIVATE_VALUE|absent-settings/u);
|
|
446
|
+
} finally {
|
|
447
|
+
rmSync(root, { recursive: true, force: true });
|
|
448
|
+
}
|
|
394
449
|
});
|
|
395
|
-
//# sourceMappingURL=cliResult.test.js.map
|
|
450
|
+
//# sourceMappingURL=cliResult.test.js.map
|