@aviaratech/ai-delivery 0.3.34 → 0.3.36
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 +57 -506
- package/dist/agent.d.ts +0 -2
- package/dist/agent.js +76 -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 +1746 -0
- package/dist/boardReconcile.test.js.map +7 -0
- package/dist/build.test.js +130 -0
- package/dist/build.test.js.map +7 -0
- package/dist/callerErrors.test.js +105 -0
- package/dist/callerErrors.test.js.map +7 -0
- package/dist/cli.js +406 -485
- package/dist/cli.js.map +7 -1
- package/dist/cliResult.d.ts +2 -2
- package/dist/cliResult.js +42 -25
- package/dist/cliResult.js.map +7 -1
- package/dist/cliResult.test.js +434 -297
- package/dist/cliResult.test.js.map +7 -1
- package/dist/config/deliveryConfig.d.ts +320 -14
- package/dist/config/deliveryConfig.js +472 -385
- package/dist/config/deliveryConfig.js.map +7 -1
- package/dist/config/deliveryConfig.test.js +775 -584
- 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 -477
- 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.d.ts +1 -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 +17 -12
- package/dist/dispatch.js +330 -322
- package/dist/dispatch.js.map +7 -1
- package/dist/errors.d.ts +16 -3
- package/dist/errors.js +104 -82
- 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 +59 -19
- 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.js +73 -67
- 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 +44 -51
- package/dist/github/commandIdentityPolicy.js.map +7 -1
- package/dist/github/discovery.d.ts +3 -0
- package/dist/github/discovery.js +197 -201
- 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 +53 -1
- package/dist/github/projectDelivery.js +623 -460
- package/dist/github/projectDelivery.js.map +7 -1
- package/dist/github/relationships.d.ts +5 -2
- package/dist/github/relationships.js +434 -333
- 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 +103 -7
- package/dist/issue.js +2104 -1547
- 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 +1004 -683
- 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 +1945 -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 +1088 -593
- 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 -90
- package/dist/mcp/index.js.map +7 -1
- package/dist/mcp/tools.d.ts +790 -220
- package/dist/mcp/tools.js +267 -333
- 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 -1231
- package/dist/pluginInstaller.js.map +7 -1
- package/dist/pluginInstaller.test.js +1822 -1283
- package/dist/pluginInstaller.test.js.map +7 -1
- package/dist/pluginPackaging.test.js +485 -305
- package/dist/pluginPackaging.test.js.map +7 -1
- package/dist/pr.d.ts +132 -94
- package/dist/pr.js +1521 -1323
- package/dist/pr.js.map +7 -1
- package/dist/pr.test.js +1678 -632
- 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 +150 -89
- package/dist/prDispatch.test.js.map +7 -1
- package/dist/readView.d.ts +183 -0
- package/dist/readView.js +217 -0
- package/dist/readView.js.map +7 -0
- package/dist/readView.test.d.ts +1 -0
- package/dist/readView.test.js +119 -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 +1204 -0
- package/dist/services/boardReconcileService.js +1445 -0
- package/dist/services/boardReconcileService.js.map +7 -0
- package/dist/services/deliveryAdmission.d.ts +2 -0
- package/dist/services/deliveryAdmission.js +129 -152
- package/dist/services/deliveryAdmission.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/services/worktreeRegistry.d.ts +27 -119
- package/dist/services/worktreeRegistry.js +765 -1182
- package/dist/services/worktreeRegistry.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 +354 -350
- 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 +305 -281
- package/dist/targetPolicyRoutes.test.js.map +7 -1
- package/dist/targetRepositoryExecution.test.d.ts +1 -0
- package/dist/targetRepositoryExecution.test.js +463 -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.js +84 -76
- package/dist/utils/atomicJson.js.map +7 -1
- package/dist/utils/filesystem.js +15 -18
- 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 -19
- package/dist/verification.js +1020 -1929
- 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.d.ts +6 -0
- package/dist/version.js +24 -10
- package/dist/version.js.map +7 -1
- package/dist/worktree.d.ts +3 -15
- package/dist/worktree.js +97 -177
- package/dist/worktree.js.map +7 -1
- package/package.json +10 -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 +261 -43
- package/plugins/ai-delivery/runtime/dist/cli.js +369 -125
- 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/setup.d.ts +0 -60
- package/dist/setup.js +0 -585
- package/dist/setup.js.map +0 -1
- package/dist/setup.test.js +0 -3058
- package/dist/setup.test.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 → boardReconcile.test.d.ts} +0 -0
- /package/dist/{setup.test.d.ts → build.test.d.ts} +0 -0
- /package/dist/{worktreeTransition.test.d.ts → callerErrors.test.d.ts} +0 -0
package/dist/issueContract.js
CHANGED
|
@@ -1,433 +1,454 @@
|
|
|
1
|
-
import { z } from
|
|
2
|
-
import { DeliveryError } from
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const DATA_PREFIX =
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { DeliveryError } from "./errors.js";
|
|
3
|
+
const ISSUE_CONTRACT_VERSION = "ai-delivery.issue@1";
|
|
4
|
+
const ISSUE_BODY_MARKER = "<!-- ai-delivery:issue@1 -->";
|
|
5
|
+
const DATA_PREFIX = "<!-- ai-delivery:issue-data@1 ";
|
|
6
6
|
const START_FOOTER = /\n\n<!-- ai-delivery-start-intent: sha256:[a-f0-9]{64} -->\n<!-- ai-delivery-start: sha256:[a-f0-9]{64} -->$/u;
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
function issueStartFooter(body) {
|
|
8
|
+
return START_FOOTER.exec(body)?.[0] ?? "";
|
|
9
|
+
}
|
|
10
|
+
const CREATE_FOOTER = /\n\n<!-- ai-delivery-create: sha256:[a-f0-9]{64} intent: sha256:[a-f0-9]{64} -->$/u;
|
|
11
|
+
function issueTrackingFooter(body) {
|
|
12
|
+
return CREATE_FOOTER.exec(body)?.[0] ?? issueStartFooter(body);
|
|
9
13
|
}
|
|
10
14
|
const Text = z.string();
|
|
11
15
|
const Strings = z.array(Text);
|
|
12
16
|
const AcceptanceCriterion = z.strictObject({ behavior: Text, verifiedBy: Text });
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
const IssueDeferral = z.strictObject({
|
|
18
|
+
until: z.iso.date().optional(),
|
|
19
|
+
trigger: z.string().trim().min(1).max(2e3).optional()
|
|
16
20
|
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
const IssueDeferralPatch = {
|
|
22
|
+
defer: IssueDeferral.optional(),
|
|
23
|
+
undefer: z.literal(true).optional()
|
|
20
24
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
function requireDeferralPatch(value) {
|
|
26
|
+
const parsed = z.strictObject(IssueDeferralPatch).safeParse(value);
|
|
27
|
+
if (!parsed.success || value.defer !== void 0 && value.undefer !== void 0)
|
|
28
|
+
throw new DeliveryError("Choose a valid defer condition or explicit undefer, never both.");
|
|
25
29
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
legacyBody: Text.optional(),
|
|
45
|
-
retainLegacyBody: z.boolean().optional(),
|
|
30
|
+
const IssueFields = z.strictObject({
|
|
31
|
+
title: Text.describe(
|
|
32
|
+
'Ready issues need 10\u201380 characters naming the specific change, with no "Bug:" or "[Task]" prefix.'
|
|
33
|
+
),
|
|
34
|
+
issueType: Text.optional(),
|
|
35
|
+
points: z.number().int().optional().describe("Ready non-epic issues need Points 1\u20138 from the Points field's options (usually 1, 2, 3, 5 or 8)."),
|
|
36
|
+
epic: z.literal(true).optional(),
|
|
37
|
+
problem: Text.default(""),
|
|
38
|
+
outcome: Text.default(""),
|
|
39
|
+
acceptanceCriteria: z.array(AcceptanceCriterion).default([]),
|
|
40
|
+
outOfScope: Strings.default([]),
|
|
41
|
+
openQuestions: Strings.default([]),
|
|
42
|
+
context: z.strictObject({ components: Strings.default([]), files: Strings.default([]), evidence: Strings.default([]) }).default({ components: [], files: [], evidence: [] }),
|
|
43
|
+
bug: z.strictObject({ steps: Strings, expected: Text, actual: Text, reproducibility: Text, environment: Text }).optional().describe("Ready Bug issues need non-empty steps, expected, actual, reproducibility and environment."),
|
|
44
|
+
draft: z.boolean().default(false),
|
|
45
|
+
deferral: IssueDeferral.optional(),
|
|
46
|
+
legacyBody: Text.optional(),
|
|
47
|
+
retainLegacyBody: z.boolean().optional()
|
|
46
48
|
});
|
|
47
|
-
const StatusText = z
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
49
|
+
const StatusText = z.string().trim().min(1).refine((value) => !/[\r\n]/u.test(value), "Use one status line.");
|
|
50
|
+
const CreateIssueStatus = z.strictObject({ nextMilestone: StatusText.optional() });
|
|
51
|
+
const IssueStatusPatch = CreateIssueStatus.extend({
|
|
52
|
+
blockers: StatusText.optional(),
|
|
53
|
+
latestJournal: StatusText.optional()
|
|
54
|
+
});
|
|
55
|
+
const ISSUE_COMMENT_BODY_LIMIT = 65536;
|
|
56
|
+
const ProjectStatusPatch = z.strictObject({
|
|
57
|
+
status: z.enum(["Todo", "In Progress", "Blocked", "Done"]),
|
|
58
|
+
reason: z.string().trim().min(1)
|
|
59
|
+
}).superRefine((value, ctx) => {
|
|
60
|
+
if (`Requested Project Status: ${value.status}.
|
|
61
|
+
|
|
62
|
+
${value.reason}`.length > ISSUE_COMMENT_BODY_LIMIT)
|
|
63
|
+
ctx.addIssue({
|
|
64
|
+
code: "custom",
|
|
65
|
+
path: ["reason"],
|
|
66
|
+
message: "Shorten the public reason to fit the issue comment limit."
|
|
67
|
+
});
|
|
68
|
+
if (secrets(value))
|
|
69
|
+
ctx.addIssue({
|
|
70
|
+
code: "custom",
|
|
71
|
+
path: ["reason"],
|
|
72
|
+
message: "Remove credentials and private keys from the public reason."
|
|
73
|
+
});
|
|
56
74
|
});
|
|
57
75
|
const IssueStatus = z.strictObject({
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
76
|
+
state: z.enum(["Ready", "Draft"]),
|
|
77
|
+
lastUpdated: z.iso.datetime(),
|
|
78
|
+
nextMilestone: StatusText,
|
|
79
|
+
blockers: StatusText,
|
|
80
|
+
latestJournal: StatusText
|
|
63
81
|
});
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
return result.data;
|
|
82
|
+
function requireIssueStatus(schema, value) {
|
|
83
|
+
const result = schema.safeParse(value);
|
|
84
|
+
if (!result.success) throw new IssueValidationError(issueDiagnostics(result.error.issues));
|
|
85
|
+
if (secrets(result.data))
|
|
86
|
+
throw new IssueValidationError([
|
|
87
|
+
hint("secrets", "status", "Remove credentials and private keys from public status fields.")
|
|
88
|
+
]);
|
|
89
|
+
return result.data;
|
|
73
90
|
}
|
|
74
91
|
const hint = (code, field, fixHint) => ({
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
92
|
+
code,
|
|
93
|
+
field,
|
|
94
|
+
fixHint,
|
|
95
|
+
message: fixHint
|
|
79
96
|
});
|
|
80
97
|
function secrets(value) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
? Object.values(item).flatMap(strings)
|
|
87
|
-
: [];
|
|
88
|
-
const text = strings(value).join('\n');
|
|
89
|
-
return /(?:-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----|\b(?:gh[pousr]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,}|sk-(?:proj-)?[A-Za-z0-9_-]{20,}|AKIA[A-Z0-9]{16})\b|\b(?:password|secret|api[_-]?key|access[_-]?token)\s*[=:]\s*["']?(?!<|\$|redacted\b|placeholder\b)[A-Za-z0-9_+/-]{8,})/iu.test(text);
|
|
98
|
+
const strings = (item) => typeof item === "string" ? [item] : Array.isArray(item) ? item.flatMap(strings) : item !== null && typeof item === "object" ? Object.values(item).flatMap(strings) : [];
|
|
99
|
+
const text = strings(value).join("\n");
|
|
100
|
+
return /(?:-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----|\b(?:gh[pousr]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,}|sk-(?:proj-)?[A-Za-z0-9_-]{20,}|AKIA[A-Z0-9]{16})\b|\b(?:password|secret|api[_-]?key|access[_-]?token)\s*[=:]\s*["']?(?!<|\$|redacted\b|placeholder\b)[A-Za-z0-9_+/-]{8,})/iu.test(
|
|
101
|
+
text
|
|
102
|
+
);
|
|
90
103
|
}
|
|
91
104
|
function secretRule(value, ctx) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
105
|
+
if (secrets(value))
|
|
106
|
+
ctx.addIssue({
|
|
107
|
+
code: "custom",
|
|
108
|
+
path: ["body"],
|
|
109
|
+
message: "Remove credentials and private keys from public issue fields.",
|
|
110
|
+
params: { issueCode: "secrets" }
|
|
111
|
+
});
|
|
99
112
|
}
|
|
100
|
-
|
|
113
|
+
const DraftIssue = IssueFields.superRefine(secretRule);
|
|
101
114
|
function readyRules(value, ctx) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
if (!
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
115
|
+
const add = (code, field, fixHint) => ctx.addIssue({ code: "custom", path: field, message: fixHint, params: { issueCode: code } });
|
|
116
|
+
if (value.draft) add("draft", ["draft"], "Resolve the draft fields and set draft to false before starting work.");
|
|
117
|
+
if (!value.epic && (value.points === void 0 || value.points < 1 || value.points > 8))
|
|
118
|
+
add("points", ["points"], "Choose Points from 1 through 8; split a 13-point issue into sub-issues.");
|
|
119
|
+
if (value.title.trim().length < 10 || !/[\p{L}]/u.test(value.title) || /^(?:fix|bug|task|feature|update|improve|test|issue|work)(?:\s+(?:it|this|stuff|things|issue))?[.!]?$/iu.test(
|
|
120
|
+
value.title.trim()
|
|
121
|
+
))
|
|
122
|
+
add("title.specific", ["title"], "Name the specific behavior or component that changes.");
|
|
123
|
+
if (value.title.length > 80) add("title.length", ["title"], "Shorten the title to at most 80 characters.");
|
|
124
|
+
if (/^\s*(?:\[\s*(?:bug|feature|task)\s*\]|(?:bug|feature|task)\s*:)/iu.test(value.title))
|
|
125
|
+
add("title.prefix", ["title"], "Remove the issue-type prefix; use the native Issue Type field.");
|
|
126
|
+
for (const field of ["problem", "outcome"])
|
|
127
|
+
if (!value[field].trim()) add(field, [field], `Describe the ${field} in concrete terms.`);
|
|
128
|
+
if (!value.acceptanceCriteria.length)
|
|
129
|
+
add("acceptance-criteria", ["acceptanceCriteria"], "Add an observable behavior and how it will be verified.");
|
|
130
|
+
value.acceptanceCriteria.forEach((ac, index) => {
|
|
131
|
+
if (!ac.behavior.trim() || !ac.verifiedBy.trim())
|
|
132
|
+
add(
|
|
133
|
+
"acceptance-criteria.fields",
|
|
134
|
+
["acceptanceCriteria", index],
|
|
135
|
+
"Provide both behavior and verifiedBy for this criterion."
|
|
136
|
+
);
|
|
137
|
+
if (/^(?:.{1,100}\s)?(?:works(?:\s+(?:correctly|as expected|well|properly))?|(?:is|are)\s+(?:done|verified|reviewed|robust|seamless|appropriate|user[- ]friendly))[\s.!]*$/iu.test(
|
|
138
|
+
ac.behavior
|
|
139
|
+
) || ac.behavior.trim().length < 12)
|
|
140
|
+
add(
|
|
141
|
+
"acceptance-criteria.vague",
|
|
142
|
+
["acceptanceCriteria", index, "behavior"],
|
|
143
|
+
"Replace vague wording with an observable input and result."
|
|
144
|
+
);
|
|
145
|
+
});
|
|
146
|
+
if (!value.outOfScope.some((item) => item.trim()))
|
|
147
|
+
add("out-of-scope", ["outOfScope"], "Name at least one explicit non-goal.");
|
|
148
|
+
if (value.openQuestions.length)
|
|
149
|
+
add("open-questions", ["openQuestions"], "Resolve each open question before marking the issue Ready.");
|
|
150
|
+
if (value.issueType?.toLowerCase() === "bug") {
|
|
151
|
+
if (!value.bug)
|
|
152
|
+
add("bug", ["bug"], "Include steps, expected and actual results, reproducibility, and environment.");
|
|
153
|
+
else {
|
|
154
|
+
if (!value.bug.steps.length || value.bug.steps.some((step) => !step.trim()))
|
|
155
|
+
add("bug.steps", ["bug", "steps"], "Provide nonempty ordered reproduction steps.");
|
|
156
|
+
for (const field of ["expected", "actual", "reproducibility", "environment"])
|
|
157
|
+
if (!value.bug[field].trim()) add(`bug.${field}`, ["bug", field], `Describe the bug's ${field}.`);
|
|
141
158
|
}
|
|
159
|
+
}
|
|
142
160
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
})
|
|
153
|
-
.superRefine(secretRule)
|
|
154
|
-
.superRefine(readyRules);
|
|
161
|
+
const ReadyIssue = IssueFields.extend({
|
|
162
|
+
title: Text.min(10).max(80),
|
|
163
|
+
points: z.number().int().min(1).max(8).optional(),
|
|
164
|
+
problem: Text.min(1),
|
|
165
|
+
outcome: Text.min(1),
|
|
166
|
+
acceptanceCriteria: z.array(AcceptanceCriterion).min(1),
|
|
167
|
+
outOfScope: Strings.min(1),
|
|
168
|
+
openQuestions: Strings.max(0).default([]),
|
|
169
|
+
draft: z.literal(false).default(false)
|
|
170
|
+
}).superRefine(secretRule).superRefine(readyRules).meta({ anyOf: [{ properties: { epic: { const: true } }, required: ["epic"] }, { required: ["points"] }] });
|
|
155
171
|
const ReadySemantics = IssueFields.superRefine(secretRule).superRefine(readyRules);
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
ready: z.toJSONSchema(ReadyIssue),
|
|
172
|
+
const ISSUE_JSON_SCHEMAS = {
|
|
173
|
+
version: ISSUE_CONTRACT_VERSION,
|
|
174
|
+
draft: z.toJSONSchema(DraftIssue),
|
|
175
|
+
ready: z.toJSONSchema(ReadyIssue)
|
|
161
176
|
};
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
177
|
+
const IssueWriteFields = {
|
|
178
|
+
title: IssueFields.shape.title.optional(),
|
|
179
|
+
issueType: IssueFields.shape.issueType,
|
|
180
|
+
points: IssueFields.shape.points,
|
|
181
|
+
epic: IssueFields.shape.epic,
|
|
182
|
+
problem: IssueFields.shape.problem.removeDefault().optional(),
|
|
183
|
+
outcome: IssueFields.shape.outcome.removeDefault().optional(),
|
|
184
|
+
acceptanceCriteria: IssueFields.shape.acceptanceCriteria.removeDefault().optional(),
|
|
185
|
+
outOfScope: IssueFields.shape.outOfScope.removeDefault().optional(),
|
|
186
|
+
openQuestions: IssueFields.shape.openQuestions.removeDefault().optional(),
|
|
187
|
+
context: IssueFields.shape.context.removeDefault().optional(),
|
|
188
|
+
bug: IssueFields.shape.bug,
|
|
189
|
+
draft: IssueFields.shape.draft.removeDefault().optional(),
|
|
190
|
+
retainLegacyBody: IssueFields.shape.retainLegacyBody
|
|
176
191
|
};
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
return true;
|
|
186
|
-
},
|
|
187
|
-
});
|
|
192
|
+
const IssueWriteSchema = z.strictObject(IssueWriteFields);
|
|
193
|
+
function issueInputSchema(schema) {
|
|
194
|
+
return schema.refine(() => true, {
|
|
195
|
+
when: ({ issues }) => {
|
|
196
|
+
if (issues.length) throw new IssueValidationError(issueDiagnostics(issues));
|
|
197
|
+
return true;
|
|
198
|
+
}
|
|
199
|
+
});
|
|
188
200
|
}
|
|
189
201
|
function issueDiagnostics(issues) {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
? 'acceptance-criteria'
|
|
206
|
-
: field === 'draft'
|
|
207
|
-
? 'draft'
|
|
208
|
-
: issue.code === 'unrecognized_keys'
|
|
209
|
-
? 'field.unknown'
|
|
210
|
-
: 'field.type';
|
|
211
|
-
return hint(code, field, code === 'points'
|
|
212
|
-
? 'Choose Points from 1 through 8; split a 13-point issue into sub-issues.'
|
|
213
|
-
: issue.code === 'unrecognized_keys'
|
|
214
|
-
? 'Remove unrecognized fields from ' + field + '.'
|
|
215
|
-
: (issue.message ??
|
|
216
|
-
(issue.code === 'invalid_type'
|
|
217
|
-
? 'Provide a valid ' + issue.expected + ' value.'
|
|
218
|
-
: 'Provide a value satisfying the declared issue field schema.')));
|
|
219
|
-
})
|
|
220
|
-
.filter((issue) => {
|
|
221
|
-
const key = issue.code + ':' + issue.field;
|
|
222
|
-
if (seen.has(key))
|
|
223
|
-
return false;
|
|
224
|
-
seen.add(key);
|
|
225
|
-
return true;
|
|
226
|
-
});
|
|
202
|
+
const seen = /* @__PURE__ */ new Set();
|
|
203
|
+
return issues.map((issue) => {
|
|
204
|
+
const field = (issue.path ?? []).map(String).join(".") || "issue";
|
|
205
|
+
const code = issue.code === "custom" && typeof issue.params?.issueCode === "string" ? issue.params.issueCode : field === "points" ? "points" : field === "title" ? "title.length" : field === "outOfScope" ? "out-of-scope" : field === "openQuestions" ? "open-questions" : field === "acceptanceCriteria" ? "acceptance-criteria" : field === "draft" ? "draft" : issue.code === "unrecognized_keys" ? "field.unknown" : "field.type";
|
|
206
|
+
return hint(
|
|
207
|
+
code,
|
|
208
|
+
field,
|
|
209
|
+
code === "points" ? "Choose Points from 1 through 8; split a 13-point issue into sub-issues." : issue.code === "unrecognized_keys" ? "Remove unrecognized fields from " + field + "." : issue.message ?? (issue.code === "invalid_type" ? "Provide a valid " + issue.expected + " value." : "Provide a value satisfying the declared issue field schema.")
|
|
210
|
+
);
|
|
211
|
+
}).filter((issue) => {
|
|
212
|
+
const key = issue.code + ":" + issue.field;
|
|
213
|
+
if (seen.has(key)) return false;
|
|
214
|
+
seen.add(key);
|
|
215
|
+
return true;
|
|
216
|
+
});
|
|
227
217
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
return { failures: issueDiagnostics(issues) };
|
|
218
|
+
function validateIssue(value, ready = true) {
|
|
219
|
+
const parsed = (ready ? ReadyIssue : DraftIssue).safeParse(value);
|
|
220
|
+
if (parsed.success) return { issue: parsed.data, failures: [] };
|
|
221
|
+
const semantic = ready ? ReadySemantics.safeParse(value) : void 0;
|
|
222
|
+
const issues = [...semantic?.success === false ? semantic.error.issues : [], ...parsed.error.issues];
|
|
223
|
+
return { failures: issueDiagnostics(issues) };
|
|
235
224
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
225
|
+
class IssueValidationError extends DeliveryError {
|
|
226
|
+
constructor(failures) {
|
|
227
|
+
super(JSON.stringify({ contract: ISSUE_CONTRACT_VERSION, failures }));
|
|
228
|
+
this.failures = failures;
|
|
229
|
+
}
|
|
230
|
+
failures;
|
|
242
231
|
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
return result.issue;
|
|
232
|
+
function requireIssue(value) {
|
|
233
|
+
const structural = IssueFields.safeParse(value);
|
|
234
|
+
const result = validateIssue(value, !structural.success || !structural.data.draft);
|
|
235
|
+
if (!result.issue) throw new IssueValidationError(result.failures);
|
|
236
|
+
return result.issue;
|
|
249
237
|
}
|
|
250
|
-
const escapeStatus = (value) => value
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
const
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
.
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
238
|
+
const escapeStatus = (value) => value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replace(/[\\`*_[\]]/gu, "\\$&");
|
|
239
|
+
const unescapeStatus = (value) => value.replace(/\\([\\`*_[\]])/gu, "$1").replaceAll("<", "<").replaceAll(">", ">").replaceAll("&", "&");
|
|
240
|
+
function renderIssueBody(value, status, legacyFormatting = false) {
|
|
241
|
+
const item = DraftIssue.parse(value);
|
|
242
|
+
if (status !== void 0) requireIssueStatus(IssueStatus, status);
|
|
243
|
+
const list = (values) => values.length ? values.map((v) => `- ${v}`).join("\n") : "(none)";
|
|
244
|
+
const parts = [
|
|
245
|
+
ISSUE_BODY_MARKER,
|
|
246
|
+
"## Status",
|
|
247
|
+
status === void 0 ? item.draft ? "Draft \u2014 parked; not ready to work." : "Ready" : `- **State:** ${status.state}
|
|
248
|
+
- **Last updated:** ${status.lastUpdated} UTC
|
|
249
|
+
- **Next milestone:** ${escapeStatus(status.nextMilestone)}
|
|
250
|
+
- **Blockers:** ${escapeStatus(status.blockers)}
|
|
251
|
+
- **Latest journal:** ${escapeStatus(status.latestJournal)}`,
|
|
252
|
+
"## Problem",
|
|
253
|
+
item.problem,
|
|
254
|
+
"## Outcome",
|
|
255
|
+
item.outcome,
|
|
256
|
+
...item.deferral === void 0 ? [] : ["## Deferral", `Deferred: ${JSON.stringify(item.deferral)}`],
|
|
257
|
+
"## Acceptance criteria",
|
|
258
|
+
item.acceptanceCriteria.map(
|
|
259
|
+
(ac) => legacyFormatting ? `- [ ] ${ac.behavior}
|
|
260
|
+
Verified by: ${ac.verifiedBy}` : `- [ ] ${ac.behavior.replace(/\n/gu, "\n ")}${ac.behavior.includes("\n") ? "\n" : ""}
|
|
261
|
+
Verified by: ${ac.verifiedBy.replace(/\n/gu, "\n ")}`
|
|
262
|
+
).join("\n"),
|
|
263
|
+
"## Out of scope",
|
|
264
|
+
list(item.outOfScope),
|
|
265
|
+
"## Open questions",
|
|
266
|
+
list(item.openQuestions),
|
|
267
|
+
"## Context",
|
|
268
|
+
`Components:
|
|
269
|
+
${list(item.context.components)}
|
|
270
|
+
|
|
271
|
+
Files:
|
|
272
|
+
${list(item.context.files)}
|
|
273
|
+
|
|
274
|
+
Evidence:
|
|
275
|
+
${list(item.context.evidence)}`
|
|
276
|
+
];
|
|
277
|
+
if (item.bug)
|
|
278
|
+
parts.push(
|
|
279
|
+
"## Bug",
|
|
280
|
+
`Steps:
|
|
281
|
+
${list(item.bug.steps)}
|
|
282
|
+
|
|
283
|
+
Expected: ${item.bug.expected}
|
|
284
|
+
|
|
285
|
+
Actual: ${item.bug.actual}
|
|
286
|
+
|
|
287
|
+
Reproducibility: ${item.bug.reproducibility}
|
|
288
|
+
|
|
289
|
+
Environment: ${item.bug.environment}`
|
|
290
|
+
);
|
|
291
|
+
if (item.legacyBody !== void 0 && item.retainLegacyBody !== false)
|
|
292
|
+
parts.push("## Preserved legacy body", item.legacyBody);
|
|
293
|
+
parts.push(`${DATA_PREFIX}${JSON.stringify(item).replaceAll("<", "\\u003c").replaceAll(">", "\\u003e")} -->`);
|
|
294
|
+
return parts.join("\n\n") + "\n";
|
|
298
295
|
}
|
|
299
296
|
function section(body, names) {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
.slice(start + 1, end < 0 ? undefined : end)
|
|
310
|
-
.join('\n')
|
|
311
|
-
.trim();
|
|
297
|
+
const lines = body.split(/\r?\n/u);
|
|
298
|
+
const start = lines.findIndex(
|
|
299
|
+
(line) => names.includes(
|
|
300
|
+
line.replace(/^#{1,6}\s+/u, "").trim().toLowerCase()
|
|
301
|
+
)
|
|
302
|
+
);
|
|
303
|
+
if (start < 0) return "";
|
|
304
|
+
const end = lines.findIndex((line, index) => index > start && /^#{1,6}\s/u.test(line));
|
|
305
|
+
return lines.slice(start + 1, end < 0 ? void 0 : end).join("\n").trim();
|
|
312
306
|
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
catch {
|
|
327
|
-
throw new IssueValidationError([hint('body.canonical', 'body', 'Restore valid canonical issue data.')]);
|
|
328
|
-
}
|
|
329
|
-
const result = validateIssue(decoded, false);
|
|
330
|
-
if (!result.issue)
|
|
331
|
-
throw new IssueValidationError(result.failures);
|
|
332
|
-
const displayed = body.slice((ISSUE_BODY_MARKER + '\n\n## Status\n\n').length, body.indexOf('\n\n## Problem\n\n'));
|
|
333
|
-
let status;
|
|
334
|
-
if (displayed !== 'Ready' && displayed !== 'Draft — parked; not ready to work.') {
|
|
335
|
-
const match = /^- \*\*State:\*\* (Ready|Draft)\n- \*\*Last updated:\*\* (\S+) UTC\n- \*\*Next milestone:\*\* ([^\r\n]+)\n- \*\*Blockers:\*\* ([^\r\n]+)\n- \*\*Latest journal:\*\* ([^\r\n]+)$/u.exec(displayed);
|
|
336
|
-
if (!match)
|
|
337
|
-
throw new IssueValidationError([
|
|
338
|
-
hint('body.canonical', 'status', 'Restore the complete unambiguous status block.'),
|
|
339
|
-
]);
|
|
340
|
-
status = requireIssueStatus(IssueStatus, {
|
|
341
|
-
state: match[1],
|
|
342
|
-
lastUpdated: match[2],
|
|
343
|
-
nextMilestone: unescapeStatus(match[3]),
|
|
344
|
-
blockers: unescapeStatus(match[4]),
|
|
345
|
-
latestJournal: unescapeStatus(match[5]),
|
|
346
|
-
});
|
|
347
|
-
if (status.state !== (result.issue.draft ? 'Draft' : 'Ready'))
|
|
348
|
-
throw new IssueValidationError([
|
|
349
|
-
hint('body.canonical', 'status', 'Status state must agree with the typed draft field.'),
|
|
350
|
-
]);
|
|
351
|
-
}
|
|
352
|
-
const footer = issueStartFooter(body);
|
|
353
|
-
const canonical = footer ? body.slice(0, -footer.length) : body;
|
|
354
|
-
const legacyFormatting = renderIssueBody(result.issue, status) !== canonical;
|
|
355
|
-
if ((legacyFormatting && renderIssueBody(result.issue, status, true) !== canonical) ||
|
|
356
|
-
result.issue.title !== metadata.title)
|
|
357
|
-
throw new IssueValidationError([
|
|
358
|
-
hint('body.canonical', 'body', 'Update typed fields instead of editing only one copy of canonical content.'),
|
|
359
|
-
]);
|
|
360
|
-
return {
|
|
361
|
-
issue: result.issue,
|
|
362
|
-
legacy: false,
|
|
363
|
-
...(status === undefined ? {} : { status }),
|
|
364
|
-
...(legacyFormatting ? { legacyFormatting: true } : {}),
|
|
365
|
-
};
|
|
307
|
+
function parseIssueBody(body, metadata) {
|
|
308
|
+
if (body.trimStart().startsWith(ISSUE_BODY_MARKER)) {
|
|
309
|
+
const start = body.lastIndexOf(DATA_PREFIX);
|
|
310
|
+
const end = body.indexOf(" -->", start);
|
|
311
|
+
if (start < 0 || end < 0)
|
|
312
|
+
throw new IssueValidationError([
|
|
313
|
+
hint("body.canonical", "body", "Restore the complete canonical issue data and generated body.")
|
|
314
|
+
]);
|
|
315
|
+
let decoded;
|
|
316
|
+
try {
|
|
317
|
+
decoded = JSON.parse(body.slice(start + DATA_PREFIX.length, end));
|
|
318
|
+
} catch {
|
|
319
|
+
throw new IssueValidationError([hint("body.canonical", "body", "Restore valid canonical issue data.")]);
|
|
366
320
|
}
|
|
367
|
-
const
|
|
368
|
-
|
|
369
|
-
const
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
321
|
+
const result = validateIssue(decoded, false);
|
|
322
|
+
if (!result.issue) throw new IssueValidationError(result.failures);
|
|
323
|
+
const displayed = body.slice((ISSUE_BODY_MARKER + "\n\n## Status\n\n").length, body.indexOf("\n\n## Problem\n\n"));
|
|
324
|
+
let status;
|
|
325
|
+
if (displayed !== "Ready" && displayed !== "Draft \u2014 parked; not ready to work.") {
|
|
326
|
+
const match = /^- \*\*State:\*\* (Ready|Draft)\n- \*\*Last updated:\*\* (\S+) UTC\n- \*\*Next milestone:\*\* ([^\r\n]+)\n- \*\*Blockers:\*\* ([^\r\n]+)\n- \*\*Latest journal:\*\* ([^\r\n]+)$/u.exec(
|
|
327
|
+
displayed
|
|
328
|
+
);
|
|
329
|
+
if (!match)
|
|
330
|
+
throw new IssueValidationError([
|
|
331
|
+
hint("body.canonical", "status", "Restore the complete unambiguous status block.")
|
|
332
|
+
]);
|
|
333
|
+
status = requireIssueStatus(IssueStatus, {
|
|
334
|
+
state: match[1],
|
|
335
|
+
lastUpdated: match[2],
|
|
336
|
+
nextMilestone: unescapeStatus(match[3]),
|
|
337
|
+
blockers: unescapeStatus(match[4]),
|
|
338
|
+
latestJournal: unescapeStatus(match[5])
|
|
339
|
+
});
|
|
340
|
+
if (status.state !== (result.issue.draft ? "Draft" : "Ready"))
|
|
341
|
+
throw new IssueValidationError([
|
|
342
|
+
hint("body.canonical", "status", "Status state must agree with the typed draft field.")
|
|
343
|
+
]);
|
|
344
|
+
}
|
|
345
|
+
const footer = issueTrackingFooter(body);
|
|
346
|
+
const canonical = footer ? body.slice(0, -footer.length) : body;
|
|
347
|
+
const legacyFormatting = renderIssueBody(result.issue, status) !== canonical;
|
|
348
|
+
if (legacyFormatting && renderIssueBody(result.issue, status, true) !== canonical || result.issue.title !== metadata.title)
|
|
349
|
+
throw new IssueValidationError([
|
|
350
|
+
hint("body.canonical", "body", "Update typed fields instead of editing only one copy of canonical content.")
|
|
351
|
+
]);
|
|
352
|
+
return {
|
|
353
|
+
issue: result.issue,
|
|
354
|
+
legacy: false,
|
|
355
|
+
...status === void 0 ? {} : { status },
|
|
356
|
+
...legacyFormatting ? { legacyFormatting: true } : {}
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
const verification = section(body, ["verification", "validation", "tests"]);
|
|
360
|
+
const acText = section(body, ["acceptance criteria", "acceptance"]);
|
|
361
|
+
const acceptanceCriteria = acText.split(/\n(?=\s*[-*+]\s+\[[ xX]\])/u).flatMap((block) => {
|
|
362
|
+
const match = /^\s*[-*+]\s+\[[ xX]\]\s+([\s\S]+)/u.exec(block);
|
|
363
|
+
if (!match) return [];
|
|
364
|
+
const [behavior = "", verifiedBy = verification] = match[1].split(/\n\s*(?:Verified by:|Verified by)\s*/iu);
|
|
365
|
+
return [{ behavior: behavior.trim(), verifiedBy: verifiedBy.trim() }];
|
|
366
|
+
});
|
|
367
|
+
const items = (s) => s.split(/\r?\n/u).map((line) => line.replace(/^\s*[-*+]\s+/u, "").trim()).filter(Boolean);
|
|
368
|
+
const scope = section(body, ["scope", "context"]);
|
|
369
|
+
const bug = metadata.issueType?.toLowerCase() === "bug" ? {
|
|
370
|
+
steps: items(section(body, ["steps", "steps to reproduce"])),
|
|
371
|
+
expected: section(body, ["expected", "expected results"]),
|
|
372
|
+
actual: section(body, ["actual", "actual results"]),
|
|
373
|
+
reproducibility: section(body, ["reproducibility"]),
|
|
374
|
+
environment: section(body, ["environment"])
|
|
375
|
+
} : void 0;
|
|
376
|
+
const converted = validateIssue(
|
|
377
|
+
{
|
|
378
|
+
...metadata,
|
|
379
|
+
problem: section(body, ["problem"]),
|
|
380
|
+
outcome: section(body, ["outcome"]),
|
|
381
|
+
acceptanceCriteria,
|
|
382
|
+
outOfScope: items(section(body, ["out of scope", "non-goals"])),
|
|
383
|
+
openQuestions: items(section(body, ["open questions"])),
|
|
384
|
+
context: { components: [], files: scope ? [scope] : [], evidence: verification ? [verification] : [] },
|
|
385
|
+
...bug === void 0 ? {} : { bug },
|
|
386
|
+
draft: /^draft\b/iu.test(section(body, ["status"])),
|
|
387
|
+
legacyBody: body
|
|
388
|
+
},
|
|
389
|
+
false
|
|
390
|
+
);
|
|
391
|
+
if (!converted.issue) throw new IssueValidationError(converted.failures);
|
|
392
|
+
return { issue: converted.issue, legacy: true };
|
|
405
393
|
}
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
394
|
+
function issueWarnings(issue, status, legacyFormatting = false) {
|
|
395
|
+
const warnings = [];
|
|
396
|
+
if (issue.acceptanceCriteria.length > 7)
|
|
397
|
+
warnings.push(
|
|
398
|
+
hint("many-criteria", "acceptanceCriteria", "Consider slicing more than seven criteria into smaller issues.")
|
|
399
|
+
);
|
|
400
|
+
if (!issue.acceptanceCriteria.some(
|
|
401
|
+
(ac) => /\b(?:edge|failure|fail|error|invalid|reject|refus|empty|missing|interrupt|timeout|boundary)/iu.test(ac.behavior)
|
|
402
|
+
))
|
|
403
|
+
warnings.push(hint("edge-case", "acceptanceCriteria", "Describe an edge or failure case."));
|
|
404
|
+
if (issue.issueType?.toLowerCase() === "bug" && !issue.acceptanceCriteria.some((ac) => /regression/iu.test(ac.behavior + " " + ac.verifiedBy)))
|
|
405
|
+
warnings.push(hint("bug.regression", "acceptanceCriteria", "Add a regression test criterion for the bug."));
|
|
406
|
+
if (![...issue.context.files, ...issue.context.components].some((item) => item.trim()))
|
|
407
|
+
warnings.push(hint("context", "context", "Name relevant components or files."));
|
|
408
|
+
const proofs = [...issue.context.evidence, ...issue.acceptanceCriteria.map((ac) => ac.verifiedBy)];
|
|
409
|
+
if (proofs.length && proofs.every((proof) => /^(?:\/|[A-Za-z]:\\|~\/)/u.test(proof.trim())))
|
|
410
|
+
warnings.push(
|
|
411
|
+
hint("local-evidence", "context.evidence", "Use portable evidence in addition to machine-local paths.")
|
|
412
|
+
);
|
|
413
|
+
const body = renderIssueBody(issue, status, legacyFormatting);
|
|
414
|
+
if (body.slice(0, body.lastIndexOf(DATA_PREFIX)).length > 4e3)
|
|
415
|
+
warnings.push(hint("body.length", "body", "Consider reducing a readable body over 4,000 characters."));
|
|
416
|
+
return warnings;
|
|
424
417
|
}
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
418
|
+
function issueBodyDiff(before, after) {
|
|
419
|
+
return [
|
|
420
|
+
"--- prior body",
|
|
421
|
+
"+++ canonical body",
|
|
422
|
+
...before.split("\n").map((line) => "-" + line),
|
|
423
|
+
...after.split("\n").map((line) => "+" + line)
|
|
424
|
+
].join("\n");
|
|
432
425
|
}
|
|
433
|
-
|
|
426
|
+
export {
|
|
427
|
+
CreateIssueStatus,
|
|
428
|
+
DraftIssue,
|
|
429
|
+
ISSUE_BODY_MARKER,
|
|
430
|
+
ISSUE_COMMENT_BODY_LIMIT,
|
|
431
|
+
ISSUE_CONTRACT_VERSION,
|
|
432
|
+
ISSUE_JSON_SCHEMAS,
|
|
433
|
+
IssueDeferral,
|
|
434
|
+
IssueDeferralPatch,
|
|
435
|
+
IssueFields,
|
|
436
|
+
IssueStatusPatch,
|
|
437
|
+
IssueValidationError,
|
|
438
|
+
IssueWriteFields,
|
|
439
|
+
IssueWriteSchema,
|
|
440
|
+
ProjectStatusPatch,
|
|
441
|
+
ReadyIssue,
|
|
442
|
+
issueBodyDiff,
|
|
443
|
+
issueInputSchema,
|
|
444
|
+
issueStartFooter,
|
|
445
|
+
issueTrackingFooter,
|
|
446
|
+
issueWarnings,
|
|
447
|
+
parseIssueBody,
|
|
448
|
+
renderIssueBody,
|
|
449
|
+
requireDeferralPatch,
|
|
450
|
+
requireIssue,
|
|
451
|
+
requireIssueStatus,
|
|
452
|
+
validateIssue
|
|
453
|
+
};
|
|
454
|
+
//# sourceMappingURL=issueContract.js.map
|