@cbartens/bkit 5.5.0 → 6.0.0
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/.bkit/README.md +30 -20
- package/.bkit/core/.agents/docs.md +1 -0
- package/.bkit/core/.agents/rules.md +51 -26
- package/.bkit/core/.bkit/README.md +29 -19
- package/.bkit/core/.bkit/authoring.md +117 -0
- package/.bkit/core/.bkit/cloud.md +11 -11
- package/.bkit/core/.bkit/comparison.md +5 -5
- package/.bkit/core/.bkit/install.md +20 -20
- package/.bkit/core/.bkit/jsonl.md +202 -122
- package/.bkit/core/.bkit/lite.md +1 -1
- package/.bkit/core/.bkit/pipeline.md +49 -52
- package/.bkit/core/.bkit/prompts.md +106 -167
- package/.bkit/core/.bkit/providers.md +29 -32
- package/.bkit/core/.bkit/templates.md +44 -18
- package/.bkit/core/.bkit/trackers.md +60 -28
- package/.bkit/core/.bkit/workflows.md +399 -359
- package/.bkit/core/AGENTS.md +16 -22
- package/.bkit/core/docs/templates/bkit-audit-accessibility.md +14 -38
- package/.bkit/core/docs/templates/bkit-audit-adoption.md +16 -40
- package/.bkit/core/docs/templates/bkit-audit-agents.md +19 -43
- package/.bkit/core/docs/templates/bkit-audit-aio-seo.md +16 -40
- package/.bkit/core/docs/templates/bkit-audit-analytics.md +14 -38
- package/.bkit/core/docs/templates/bkit-audit-annotations.md +11 -35
- package/.bkit/core/docs/templates/bkit-audit-app-performance.md +15 -39
- package/.bkit/core/docs/templates/bkit-audit-app-store.md +12 -36
- package/.bkit/core/docs/templates/bkit-audit-architecture.md +16 -40
- package/.bkit/core/docs/templates/bkit-audit-ci-performance.md +16 -40
- package/.bkit/core/docs/templates/bkit-audit-config.md +18 -42
- package/.bkit/core/docs/templates/bkit-audit-cost.md +16 -40
- package/.bkit/core/docs/templates/bkit-audit-coverage.md +15 -39
- package/.bkit/core/docs/templates/bkit-audit-database.md +16 -40
- package/.bkit/core/docs/templates/bkit-audit-dead-code.md +15 -39
- package/.bkit/core/docs/templates/bkit-audit-deferrals.md +15 -38
- package/.bkit/core/docs/templates/bkit-audit-dependencies.md +16 -40
- package/.bkit/core/docs/templates/bkit-audit-documentation.md +11 -35
- package/.bkit/core/docs/templates/bkit-audit-duplication.md +18 -42
- package/.bkit/core/docs/templates/bkit-audit-failures.md +13 -37
- package/.bkit/core/docs/templates/bkit-audit-flakes.md +12 -36
- package/.bkit/core/docs/templates/bkit-audit-gates.md +14 -38
- package/.bkit/core/docs/templates/bkit-audit-issues.md +15 -39
- package/.bkit/core/docs/templates/bkit-audit-llm.md +16 -40
- package/.bkit/core/docs/templates/bkit-audit-logs.md +14 -38
- package/.bkit/core/docs/templates/bkit-audit-models.md +12 -36
- package/.bkit/core/docs/templates/bkit-audit-privacy.md +12 -36
- package/.bkit/core/docs/templates/bkit-audit-prompts.md +15 -39
- package/.bkit/core/docs/templates/bkit-audit-red-team.md +15 -39
- package/.bkit/core/docs/templates/bkit-audit-reliability.md +15 -39
- package/.bkit/core/docs/templates/bkit-audit-repo.md +12 -36
- package/.bkit/core/docs/templates/bkit-audit-security.md +13 -37
- package/.bkit/core/docs/templates/bkit-audit-slop.md +14 -38
- package/.bkit/core/docs/templates/bkit-audit-testing.md +12 -36
- package/.bkit/core/docs/templates/bkit-audit-usability.md +16 -40
- package/.bkit/core/docs/templates/bkit-plan.md +97 -226
- package/.bkit/core/engine/checks/after/ci-yml.ts +39 -30
- package/.bkit/core/engine/checks/after/github.ts +101 -72
- package/.bkit/core/engine/checks/after/index.ts +10 -12
- package/.bkit/core/engine/checks/after/suppression.ts +8 -5
- package/.bkit/core/engine/checks/after/tools.ts +47 -92
- package/.bkit/core/engine/checks/before/env.ts +2 -2
- package/.bkit/core/engine/checks/before/files.ts +5 -4
- package/.bkit/core/engine/checks/before/index.ts +18 -1
- package/.bkit/core/engine/checks/before/repo.ts +168 -2
- package/.bkit/core/engine/checks/tips/catalogue.ts +16 -5
- package/.bkit/core/engine/checks/tips/detect.ts +34 -0
- package/.bkit/core/engine/checks/tips/index.ts +10 -7
- package/.bkit/core/engine/cli.ts +20 -53
- package/.bkit/core/engine/commands/analysis.ts +171 -140
- package/.bkit/core/engine/commands/ci/ci.ts +6 -6
- package/.bkit/core/engine/commands/comply.ts +77 -103
- package/.bkit/core/engine/commands/install/doctor.ts +2 -2
- package/.bkit/core/engine/commands/install/install.ts +57 -18
- package/.bkit/core/engine/commands/install/uninstall.ts +65 -28
- package/.bkit/core/engine/commands/land.ts +18 -12
- package/.bkit/core/engine/commands/lib.ts +79 -17
- package/.bkit/core/engine/commands/registry.ts +4 -0
- package/.bkit/core/engine/commands/setup/setup.ts +7 -7
- package/.bkit/core/engine/commands/stats.ts +204 -0
- package/.bkit/core/engine/commands/tips.ts +10 -5
- package/.bkit/core/engine/commands/workflow/branches.ts +741 -62
- package/.bkit/core/engine/commands/workflow/challenge.ts +673 -0
- package/.bkit/core/engine/commands/workflow/context.ts +853 -29
- package/.bkit/core/engine/commands/workflow/counters.ts +267 -84
- package/.bkit/core/engine/commands/workflow/decisions.ts +541 -0
- package/.bkit/core/engine/commands/workflow/disk.ts +2 -2
- package/.bkit/core/engine/commands/workflow/fids.ts +793 -33
- package/.bkit/core/engine/commands/workflow/issues.ts +427 -105
- package/.bkit/core/engine/commands/workflow/ledgers.ts +884 -27
- package/.bkit/core/engine/commands/workflow/locks.ts +26 -2
- package/.bkit/core/engine/commands/workflow/plan-blocks.ts +582 -0
- package/.bkit/core/engine/commands/workflow/plan-versions.ts +21 -0
- package/.bkit/core/engine/commands/workflow/prs.ts +166 -30
- package/.bkit/core/engine/commands/workflow/repo.ts +59 -7
- package/.bkit/core/engine/commands/workflow/roadmap.ts +16 -7
- package/.bkit/core/engine/commands/workflow/run-facts.ts +501 -0
- package/.bkit/core/engine/commands/workflow/runs.ts +179 -49
- package/.bkit/core/engine/commands/workflow/runtime.ts +22 -1
- package/.bkit/core/engine/commands/workflow/status.ts +142 -29
- package/.bkit/core/engine/commands/workflow/step-table.ts +339 -0
- package/.bkit/core/engine/commands/workflow/steps.ts +213 -88
- package/.bkit/core/engine/commands/workflow/summary.ts +398 -0
- package/.bkit/core/engine/commands/workflow/tests.ts +1013 -148
- package/.bkit/core/engine/commands/workflow/tracker.ts +1195 -0
- package/.bkit/core/engine/commands/workflow/workflows.ts +984 -207
- package/.bkit/core/engine/commands/workflow/workstreams.ts +11 -5
- package/.bkit/core/engine/commands/workflow/worktrees.ts +276 -22
- package/.bkit/core/engine/install/manifest.ts +11 -9
- package/.bkit/core/engine/install/modules/cloud.ts +21 -13
- package/.bkit/core/engine/install/modules/core.ts +325 -7
- package/.bkit/core/engine/install/modules/opencode.ts +2 -2
- package/.bkit/core/engine/install/version-file.ts +6 -2
- package/.bkit/core/engine/ledgers/migrate.ts +92 -0
- package/.bkit/core/engine/ledgers/status.ts +92 -15
- package/.bkit/core/engine/ledgers/telemetry.ts +1261 -254
- package/.bkit/core/engine/render/hosts.ts +4 -0
- package/.bkit/core/engine/render/models.ts +12 -0
- package/.bkit/core/engine/shared/branches.ts +4 -1
- package/.bkit/core/engine/shared/egress.ts +7 -0
- package/.bkit/core/engine/shared/json.ts +25 -7
- package/.bkit/core/engine/shared/settings.ts +202 -33
- package/.bkit/core/engine/shared/text.ts +361 -0
- package/.bkit/core/engine/tools/grammar-density.ts +215 -0
- package/.bkit/core/engine/tools/instructions-sources.ts +834 -0
- package/.bkit/core/engine/tools/instructions.ts +1751 -0
- package/.bkit/core/hooks/gateguard-engine.js +24 -23
- package/.bkit/core/hooks/guardrails-shell.js +2 -3
- package/.bkit/core/hooks/guardrails-tiers.js +7 -1
- package/.bkit/core/hooks/readguard-engine.js +2 -2
- package/.bkit/core/prompts/bkit-audit-generate.md +62 -25
- package/.bkit/core/prompts/bkit-build-challenge-1.md +40 -17
- package/.bkit/core/prompts/bkit-build-challenge-2.md +44 -17
- package/.bkit/core/prompts/bkit-build-install-skills.md +26 -13
- package/.bkit/core/prompts/bkit-build-plan-convert.md +74 -0
- package/.bkit/core/prompts/bkit-build-plan-current.md +26 -13
- package/.bkit/core/prompts/bkit-build-plan-execute.md +74 -26
- package/.bkit/core/prompts/bkit-build-plan-gaps-remediate.md +64 -23
- package/.bkit/core/prompts/bkit-build-plan-verify.md +57 -33
- package/.bkit/core/prompts/bkit-debug-abort-handover.md +30 -14
- package/.bkit/core/prompts/bkit-debug-failure-diagnose.md +34 -14
- package/.bkit/core/prompts/bkit-debug-failure-remediate.md +34 -17
- package/.bkit/core/prompts/bkit-debug-failure-reproduce.md +26 -13
- package/.bkit/core/prompts/bkit-debug-failure-soak.md +31 -16
- package/.bkit/core/prompts/bkit-design-brainstorm-ideate-1.md +21 -11
- package/.bkit/core/prompts/bkit-design-brainstorm-ideate-2.md +20 -11
- package/.bkit/core/prompts/bkit-design-brainstorm-ideate-3.md +20 -11
- package/.bkit/core/prompts/bkit-design-generate.md +33 -13
- package/.bkit/core/prompts/bkit-design-organise.md +25 -12
- package/.bkit/core/prompts/bkit-design-review-1.md +31 -15
- package/.bkit/core/prompts/bkit-design-review-2.md +28 -13
- package/.bkit/core/prompts/bkit-design-spike.md +30 -13
- package/.bkit/core/prompts/bkit-design-update.md +33 -19
- package/.bkit/core/prompts/bkit-plan-generate.md +75 -19
- package/.bkit/core/prompts/bkit-plan-review-1.md +50 -27
- package/.bkit/core/prompts/bkit-plan-review-2.md +59 -28
- package/.bkit/core/prompts/bkit-plan-scope-check.md +109 -0
- package/.bkit/core/prompts/bkit-plan-update.md +61 -24
- package/.bkit/core/prompts/bkit-ship-conflict-resolve.md +27 -15
- package/.bkit/core/prompts/bkit-ship-deferred-sweep.md +31 -16
- package/.bkit/core/prompts/bkit-ship-update-docs.md +30 -15
- package/.bkit/core/prompts/bkit-utility-compress-markdown.md +24 -14
- package/.bkit/core/prompts/bkit-utility-update-decisions.md +32 -14
- package/.bkit/core/prompts/bkit-utility-update-deferrals.md +29 -14
- package/.bkit/core/prompts/bkit-utility-update-documentation.md +28 -13
- package/.bkit/core/prompts/bkit-utility-update-failures.md +31 -14
- package/.bkit/core/prompts/bkit-utility-update-knowledge.md +33 -14
- package/.bkit/core/prompts/bkit-utility-update-roadmap.md +38 -17
- package/.bkit/core/prompts/bkit-utility-update-tracker.md +43 -20
- package/.bkit/core/workflows/bkit-auto.md +54 -46
- package/.bkit/core/workflows/bkit-build.md +577 -458
- package/.bkit/core/workflows/bkit-debug.md +348 -333
- package/.bkit/core/workflows/bkit-design.md +201 -237
- package/.bkit/core/workflows/bkit-plan.md +210 -321
- package/.bkit/core/workflows/bkit-ship.md +328 -278
- package/.bkit/shared/.bkit/.env.example +2 -2
- package/.bkit/shared/.claude/settings.json +11 -0
- package/.bkit/shared/.cursor/mcp.json +1 -1
- package/.bkit/shared/.cursor/rules/bkit-rules.mdc +1 -1
- package/.bkit/shared/.gitattributes +1 -1
- package/.bkit/shared/.mcp.json +1 -1
- package/.bkit/shared/.opencode/opencode.json +11 -0
- package/.bkit/shared/CLAUDE.md +2 -2
- package/.bkit/shared/GEMINI.md +2 -2
- package/.bkit/shared/docs/architecture.md +1 -1
- package/.bkit/shared/docs/data-schema.md +1 -1
- package/.bkit/shared/docs/deployments.md +16 -28
- package/.bkit/shared/docs/design.md +1 -1
- package/.bkit/shared/docs/noise.md +1 -1
- package/.bkit/shared/docs/observability.md +2 -2
- package/.bkit/shared/docs/security.md +1 -1
- package/.bkit/shared/docs/setup.md +1 -1
- package/.bkit/shared/docs/technology.md +1 -1
- package/.bkit/shared/docs/testing.md +27 -10
- package/.bkit/templates/.claude/hooks/bkit-cloud-bootstrap.sh +1 -1
- package/.bkit/templates/.github/ISSUE_TEMPLATE/bkit-change.yml +26 -5
- package/.bkit/templates/.github/workflows/bkit-ci.yml +22 -84
- package/.bkit/templates/.github/workflows/bkit-cloud.yml +21 -19
- package/.bkit/templates/.husky/pre-push +52 -13
- package/.bkit/templates/.prettierignore +7 -0
- package/.bkit/templates/scripts/ci/bkit-local-stack-lock.sh +194 -0
- package/.bkit/templates/scripts/ci/check-capstone.mjs +2 -4
- package/.bkit/templates/scripts/ci/check-capstone.test.mjs +4 -23
- package/.bkit/templates/scripts/ci/lanes/resolve-push-base.mjs +104 -23
- package/.bkit/templates/scripts/ci/lanes/resolve-push-base.test.mjs +103 -6
- package/.bkit/templates/scripts/cleanup/bkit-disk-prune.mjs +1 -1
- package/.bkit/templates/scripts/graphify/bkit-graph-pre-push.sh +3 -1
- package/.bkit/templates/scripts/prettier/bkit-insert-ignore.mjs +49 -29
- package/CHANGELOG.md +142 -0
- package/README.md +58 -34
- package/dist/checks/after/ci-yml.js +39 -29
- package/dist/checks/after/github.js +99 -72
- package/dist/checks/after/index.js +11 -13
- package/dist/checks/after/suppression.js +8 -5
- package/dist/checks/after/tools.js +40 -83
- package/dist/checks/before/env.js +2 -2
- package/dist/checks/before/files.js +5 -3
- package/dist/checks/before/index.js +15 -2
- package/dist/checks/before/repo.js +163 -2
- package/dist/checks/tips/catalogue.js +14 -5
- package/dist/checks/tips/detect.js +32 -0
- package/dist/checks/tips/index.js +7 -5
- package/dist/cli.js +19 -47
- package/dist/commands/analysis.js +109 -100
- package/dist/commands/ci/ci.js +6 -6
- package/dist/commands/comply.js +54 -91
- package/dist/commands/install/doctor.js +2 -2
- package/dist/commands/install/install.js +50 -19
- package/dist/commands/install/uninstall.js +59 -28
- package/dist/commands/land.js +16 -12
- package/dist/commands/lib.js +51 -16
- package/dist/commands/registry.js +4 -0
- package/dist/commands/setup/setup.js +7 -7
- package/dist/commands/stats.js +136 -0
- package/dist/commands/tips.js +7 -3
- package/dist/commands/workflow/branches.js +656 -56
- package/dist/commands/workflow/challenge.js +556 -0
- package/dist/commands/workflow/context.js +709 -30
- package/dist/commands/workflow/counters.js +208 -75
- package/dist/commands/workflow/decisions.js +441 -0
- package/dist/commands/workflow/disk.js +2 -2
- package/dist/commands/workflow/fids.js +689 -33
- package/dist/commands/workflow/issues.js +362 -99
- package/dist/commands/workflow/ledgers.js +762 -27
- package/dist/commands/workflow/locks.js +24 -2
- package/dist/commands/workflow/plan-blocks.js +437 -0
- package/dist/commands/workflow/plan-versions.js +22 -0
- package/dist/commands/workflow/prs.js +142 -32
- package/dist/commands/workflow/repo.js +52 -7
- package/dist/commands/workflow/roadmap.js +9 -7
- package/dist/commands/workflow/run-facts.js +426 -0
- package/dist/commands/workflow/runs.js +144 -43
- package/dist/commands/workflow/runtime.js +12 -1
- package/dist/commands/workflow/status.js +130 -29
- package/dist/commands/workflow/step-table.js +276 -0
- package/dist/commands/workflow/steps.js +171 -80
- package/dist/commands/workflow/summary.js +275 -0
- package/dist/commands/workflow/tests.js +834 -136
- package/dist/commands/workflow/tracker.js +983 -0
- package/dist/commands/workflow/workflows.js +834 -195
- package/dist/commands/workflow/workstreams.js +11 -5
- package/dist/commands/workflow/worktrees.js +221 -22
- package/dist/install/manifest.js +11 -9
- package/dist/install/modules/cloud.js +22 -13
- package/dist/install/modules/core.js +326 -7
- package/dist/install/modules/opencode.js +2 -2
- package/dist/install/version-file.js +6 -2
- package/dist/ledgers/migrate.js +81 -0
- package/dist/ledgers/status.js +61 -8
- package/dist/ledgers/telemetry.js +905 -124
- package/dist/render/hosts.js +4 -0
- package/dist/render/models.js +12 -0
- package/dist/shared/branches.js +3 -1
- package/dist/shared/egress.js +7 -0
- package/dist/shared/json.js +20 -7
- package/dist/shared/settings.js +147 -26
- package/dist/shared/text.js +333 -0
- package/dist/tools/grammar-density.js +183 -0
- package/dist/tools/instructions-sources.js +721 -0
- package/dist/tools/instructions.js +1579 -0
- package/package.json +114 -23
- package/.bkit/core/engine/commands/harvest.ts +0 -459
- package/.bkit/core/engine/tools/wording.ts +0 -748
- package/.bkit/core/prompts/bkit-build-challenge-reconcile.md +0 -69
- package/.bkit/core/prompts/bkit-build-challenge-remediate.md +0 -71
- package/.bkit/core/prompts/bkit-build-challenge-tests.md +0 -74
- package/.bkit/core/prompts/bkit-build-summary.md +0 -94
- package/.bkit/core/prompts/bkit-debug-summary.md +0 -96
- package/.bkit/core/prompts/bkit-design-summary.md +0 -107
- package/.bkit/core/prompts/bkit-plan-complexity-check.md +0 -67
- package/.bkit/core/prompts/bkit-plan-complexity-split.md +0 -88
- package/.bkit/core/prompts/bkit-plan-review-3.md +0 -93
- package/.bkit/core/prompts/bkit-plan-scope-check-1.md +0 -85
- package/.bkit/core/prompts/bkit-plan-scope-check-2.md +0 -85
- package/.bkit/core/prompts/bkit-plan-summary.md +0 -107
- package/.bkit/core/prompts/bkit-ship-summary.md +0 -78
- package/.bkit/templates/scripts/ci/lanes/check-tree-cache.mjs +0 -138
- package/.bkit/templates/scripts/ci/lanes/check-tree-cache.test.mjs +0 -181
- package/dist/commands/harvest.js +0 -353
- package/dist/tools/wording.js +0 -680
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
// bkit issues text|labels|comment — tracker payloads,
|
|
1
|
+
// bkit issues text|labels|comment — tracker payloads, and with --post / --write the call itself.
|
|
2
2
|
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
3
|
+
// These verbs do the arithmetic the workflows stated as prose — which comments count
|
|
4
|
+
// as human input, which labels a transition adds and drops, the board update, and the
|
|
5
|
+
// exact text of every `###### bkit:generated` comment — so no step re-derives it by
|
|
6
|
+
// hand. A workflow touches only its own issue. The tracker I/O goes through
|
|
7
|
+
// `tracker.ts`; when it fails the verb prints `tracker.done: false` and the workflow
|
|
8
|
+
// sends the same payload through the tracker's MCP server.
|
|
8
9
|
import * as fs from "node:fs";
|
|
9
10
|
import * as path from "node:path";
|
|
10
11
|
import { CommandError, EXIT, parseJson, repoRoot, } from "../lib.js";
|
|
11
12
|
import { readBkitConfig } from "../../shared/settings.js";
|
|
12
13
|
import { str } from "./status.js";
|
|
14
|
+
import { isCloudOrCi } from "../../checks/before/env.js";
|
|
15
|
+
import { COMMENT_FILE_OUTPUT, GENERATED_MARKER, POST_FLAG, TRACKER_OUTPUT, attempt, classifyFailure, commentFileOf, fetchIssue, moveOnBoard, postForVerb, readBlockers, readLabels, redact, runActionKey, skipOf, stampMarker, trackerTarget, writeLabels, } from "./tracker.js";
|
|
13
16
|
/** Exit code: an input file is missing or not in the expected shape. */
|
|
14
17
|
export const EXIT_BAD_INPUT = 3;
|
|
15
18
|
function readInput(cwd, file, flag) {
|
|
@@ -21,30 +24,22 @@ function readInput(cwd, file, flag) {
|
|
|
21
24
|
// ---------------------------------------------------------------------------
|
|
22
25
|
// text
|
|
23
26
|
// ---------------------------------------------------------------------------
|
|
24
|
-
|
|
25
|
-
export const GENERATED_MARKER = "###### bkit:generated";
|
|
27
|
+
export { GENERATED_MARKER };
|
|
26
28
|
/** A human writes this as a whole line to discard everything above it. */
|
|
27
29
|
export const CUT_MARKER = "###### bkit:ignore-earlier";
|
|
28
30
|
// Whole line only: naming the token inline is prose, not a live marker.
|
|
29
31
|
const CUT_LINE = /^[ \t]*###### bkit:ignore-earlier[ \t]*\r?$/;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
// The same cut as Jira's HTML comment page renders it: its own `<h6>` element.
|
|
33
|
+
const CUT_ANY = /^[ \t]*###### bkit:ignore-earlier[ \t]*\r?$|<h6\b[^>]*>\s*bkit:ignore-earlier\s*<\/h6>/gm;
|
|
34
|
+
// The marker as a whole first line (bare or stamped with its hash), or as Jira's HTML `<h6>`.
|
|
35
|
+
const GENERATED_FIRST = /^(?:######[ \t]+bkit:generated(?:[ \t]+[0-9a-f]{12})?[ \t]*$|<h6\b[^>]*>\s*bkit:generated(?:\s+[0-9a-f]{12})?\s*<\/h6>)/;
|
|
36
|
+
export const isGenerated = (body) => GENERATED_FIRST.test(body.replace(/^\s+/, "").split(/\r?\n/, 1)[0] ?? "");
|
|
37
|
+
/** Keep only what follows the LAST cut marker (whole line, or Jira's HTML `<h6>`); the marker itself goes too. */
|
|
32
38
|
export function cutEarlier(text) {
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
lines.forEach((line, i) => {
|
|
36
|
-
if (CUT_LINE.test(line))
|
|
37
|
-
last = i;
|
|
38
|
-
});
|
|
39
|
-
if (last === -1)
|
|
39
|
+
const last = [...text.matchAll(CUT_ANY)].at(-1);
|
|
40
|
+
if (last === undefined)
|
|
40
41
|
return { text, cut: false };
|
|
41
|
-
return {
|
|
42
|
-
text: lines
|
|
43
|
-
.slice(last + 1)
|
|
44
|
-
.join("\n")
|
|
45
|
-
.replace(/^\s*\n/, ""),
|
|
46
|
-
cut: true,
|
|
47
|
-
};
|
|
42
|
+
return { text: text.slice(last.index + last[0].length).replace(/^\s*\n/, ""), cut: true };
|
|
48
43
|
}
|
|
49
44
|
/**
|
|
50
45
|
* Comments as an MCP read returns them: a bare array, or one wrapped under
|
|
@@ -105,6 +100,24 @@ export function issueText(description, comments) {
|
|
|
105
100
|
const { text, cut } = cutEarlier(joined);
|
|
106
101
|
return { text, kept: human.length, dropped: comments.length - human.length, cut };
|
|
107
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* The issue as separate parts, oldest first: the description, then each human comment.
|
|
105
|
+
* The last cut marker drops every part above it and the text above it in its own part;
|
|
106
|
+
* nothing else is dropped.
|
|
107
|
+
*/
|
|
108
|
+
export function issueParts(description, comments) {
|
|
109
|
+
const parts = [
|
|
110
|
+
{ kind: "description", text: description },
|
|
111
|
+
...comments
|
|
112
|
+
.filter((c) => !isGenerated(c.body))
|
|
113
|
+
.map((c) => ({ kind: "comment", text: c.body, createdAt: c.createdAt })),
|
|
114
|
+
];
|
|
115
|
+
const last = parts.map((p) => cutEarlier(p.text).cut).lastIndexOf(true);
|
|
116
|
+
const kept = last === -1
|
|
117
|
+
? parts
|
|
118
|
+
: [{ ...parts[last], text: cutEarlier(parts[last].text).text }, ...parts.slice(last + 1)];
|
|
119
|
+
return kept.map((p) => ({ ...p, text: p.text.trim() })).filter((p) => p.text !== "");
|
|
120
|
+
}
|
|
108
121
|
function textVerb(ctx) {
|
|
109
122
|
const descFile = str(ctx.flags.descriptionFile);
|
|
110
123
|
const commentsFile = str(ctx.flags.commentsFile);
|
|
@@ -178,7 +191,7 @@ export function transitionLabels(current, t) {
|
|
|
178
191
|
}
|
|
179
192
|
/**
|
|
180
193
|
* The issue state the workflows set for the same transition, on a tracker whose
|
|
181
|
-
* board status is the issue state: `bkit.linear` or `bkit.jira`. A shipped
|
|
194
|
+
* board status is the issue state: `bkit.tracker.linear` or `bkit.tracker.jira`. A shipped
|
|
182
195
|
* or failed issue waits on a human (`review`); a phase starting is `progress`.
|
|
183
196
|
* The workflows write it alone, so a name the team or project lacks leaves the
|
|
184
197
|
* labels landed. Null under github (the Projects v2 board moves instead) and
|
|
@@ -207,75 +220,53 @@ function onOff(v, flag) {
|
|
|
207
220
|
throw new CommandError(EXIT.USAGE, `--${flag} must be on or off`);
|
|
208
221
|
return b;
|
|
209
222
|
}
|
|
210
|
-
const
|
|
211
|
-
progress: "progressOptionId",
|
|
212
|
-
review: "reviewOptionId",
|
|
213
|
-
};
|
|
223
|
+
const BOARD_STATES = new Set(["progress", "review"]);
|
|
214
224
|
/**
|
|
215
|
-
* The
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
* `listItems` entry whose issue number matches.
|
|
225
|
+
* The two `projects_write` payloads that move an issue on the Projects v2 board,
|
|
226
|
+
* from `bkit.tracker.github`. Payload keys are the MCP tool's own argument names: the
|
|
227
|
+
* board item is found by its issue, and Status is set by option name.
|
|
219
228
|
*/
|
|
220
|
-
function boardPayload(ctx, status) {
|
|
221
|
-
const
|
|
222
|
-
const tracker = readBkitConfig(root).issueTracker;
|
|
229
|
+
function boardPayload(ctx, status, target) {
|
|
230
|
+
const { issueTracker: tracker, github } = readBkitConfig(repoRoot(ctx.cwd));
|
|
223
231
|
if (tracker !== "github") {
|
|
224
232
|
if (tracker === "linear" || tracker === "jira")
|
|
225
233
|
ctx.log("Board status carried by issue state — no separate update.");
|
|
226
234
|
return { board: null, boardSkipped: `tracker-${tracker}` };
|
|
227
235
|
}
|
|
228
|
-
|
|
229
|
-
if (gp === false)
|
|
236
|
+
if (github.project === false)
|
|
230
237
|
return { board: null, boardSkipped: "opted-out" };
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
// projects_write rejects anything but the numeric field id (a `PVTSSF_…` node id
|
|
239
|
-
// included), so a wrong value is a skip with a reason, not a silent no-op.
|
|
240
|
-
const raw = cfg.statusFieldId;
|
|
241
|
-
const fieldId = typeof raw === "number" ? raw : /^[0-9]+$/.test(String(raw)) ? Number(raw) : NaN;
|
|
242
|
-
if (!Number.isInteger(fieldId)) {
|
|
243
|
-
ctx.log(`bkit.githubProject.statusFieldId "${String(raw)}" is not the numeric Status field id`);
|
|
244
|
-
return { board: null, boardSkipped: "status-field-id-not-number" };
|
|
245
|
-
}
|
|
246
|
-
const option = cfg[BOARD_OPTION[status]];
|
|
247
|
-
if (typeof option !== "string" || option === "") {
|
|
248
|
-
ctx.log(`bkit.githubProject.${BOARD_OPTION[status]} is not set`);
|
|
249
|
-
return { board: null, boardSkipped: "option-id-missing" };
|
|
238
|
+
if (github.project === null) {
|
|
239
|
+
if (github.projectUrl === null) {
|
|
240
|
+
ctx.log("GitHub project not configured in package.json");
|
|
241
|
+
return { board: null, boardSkipped: "not-configured" };
|
|
242
|
+
}
|
|
243
|
+
ctx.log(`bkit.tracker.github.project "${github.projectUrl}" is not a GitHub Projects board URL`);
|
|
244
|
+
return { board: null, boardSkipped: "project-url-invalid" };
|
|
250
245
|
}
|
|
251
|
-
const issue = String(ctx.flags.issue ?? "").replace(/^#/, "");
|
|
252
|
-
const ownerRepo = String(ctx.flags.ownerRepo ?? "");
|
|
246
|
+
const issue = (target?.issue ?? String(ctx.flags.issue ?? "")).replace(/^#/, "");
|
|
247
|
+
const ownerRepo = target?.ownerRepo ?? String(ctx.flags.ownerRepo ?? "");
|
|
253
248
|
const [itemOwner, itemRepo, extra] = ownerRepo.split("/");
|
|
254
249
|
if (!/^[0-9]+$/.test(issue) || !itemOwner || !itemRepo || extra !== undefined) {
|
|
255
250
|
throw new CommandError(EXIT.USAGE, "--board needs --issue=<number> and --owner-repo=<owner>/<repo>");
|
|
256
251
|
}
|
|
257
|
-
const
|
|
252
|
+
const { owner, ownerType, number } = github.project;
|
|
253
|
+
const project = { owner, owner_type: ownerType, project_number: number };
|
|
254
|
+
const item = { item_owner: itemOwner, item_repo: itemRepo, issue_number: Number(issue) };
|
|
258
255
|
return {
|
|
259
256
|
board: {
|
|
260
|
-
addItem: {
|
|
261
|
-
method: "add_project_item",
|
|
262
|
-
...project,
|
|
263
|
-
item_type: "issue",
|
|
264
|
-
item_owner: itemOwner,
|
|
265
|
-
item_repo: itemRepo,
|
|
266
|
-
issue_number: Number(issue),
|
|
267
|
-
},
|
|
268
|
-
listItems: { method: "list_project_items", ...project, query: issue },
|
|
257
|
+
addItem: { method: "add_project_item", ...project, item_type: "issue", ...item },
|
|
269
258
|
updateItem: {
|
|
270
259
|
method: "update_project_item",
|
|
271
260
|
...project,
|
|
272
|
-
|
|
261
|
+
...item,
|
|
262
|
+
updated_field: { name: "Status", value: github[status] },
|
|
273
263
|
},
|
|
274
264
|
},
|
|
275
265
|
boardSkipped: null,
|
|
276
266
|
};
|
|
277
267
|
}
|
|
278
|
-
|
|
268
|
+
/** The flags of a label transition, checked. */
|
|
269
|
+
function labelTransition(ctx) {
|
|
279
270
|
const phase = str(ctx.flags.phase);
|
|
280
271
|
if (phase !== undefined && !PHASE_LABELS.includes(`bkit:${phase}`)) {
|
|
281
272
|
throw new CommandError(EXIT.USAGE, "--phase must be design, plan, build, debug, ship, or merged");
|
|
@@ -284,22 +275,85 @@ function labelsVerb(ctx) {
|
|
|
284
275
|
if (phase !== undefined && failed === true)
|
|
285
276
|
throw new CommandError(EXIT.USAGE, "--phase clears bkit:failed; drop --failed=on");
|
|
286
277
|
const board = str(ctx.flags.board);
|
|
287
|
-
if (board !== undefined &&
|
|
278
|
+
if (board !== undefined && !BOARD_STATES.has(board)) {
|
|
288
279
|
throw new CommandError(EXIT.USAGE, "--board must be progress or review");
|
|
289
280
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
281
|
+
return { t: { phase, failed }, board: board };
|
|
282
|
+
}
|
|
283
|
+
/** The printed transition for `current` labels. */
|
|
284
|
+
function transitionOut(ctx, current, t, board) {
|
|
285
|
+
const { add, remove, labels } = transitionLabels(current, t);
|
|
286
|
+
return {
|
|
294
287
|
add,
|
|
295
288
|
remove,
|
|
296
289
|
labels,
|
|
297
290
|
changed: add.length + remove.length > 0,
|
|
298
291
|
autoRouteSuffix: labels.includes(AUTO_LABEL) ? AUTO_ROUTE_SUFFIX : "",
|
|
299
292
|
trackerState: trackerState(t, board, readBkitConfig(repoRoot(ctx.cwd))),
|
|
300
|
-
|
|
301
|
-
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
function labelsVerb(ctx) {
|
|
296
|
+
if (ctx.flags.write === true)
|
|
297
|
+
return labelsWrite(ctx);
|
|
298
|
+
const { t, board } = labelTransition(ctx);
|
|
299
|
+
const out = transitionOut(ctx, ctx.flags.label ?? [], t, board);
|
|
300
|
+
const { board: payload, boardSkipped } = board === undefined ? { board: null, boardSkipped: null } : boardPayload(ctx, board);
|
|
301
|
+
ctx.emit({ ...out, board: payload, boardSkipped });
|
|
302
|
+
return EXIT.OK;
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* `--write`: read the issue's labels, write the transition (and the Linear / Jira
|
|
306
|
+
* state), then move the board item. Each write that fails prints `done: false`
|
|
307
|
+
* with its reason; the workflow sends the printed payload through the MCP instead.
|
|
308
|
+
*/
|
|
309
|
+
async function labelsWrite(ctx) {
|
|
310
|
+
const { t, board } = labelTransition(ctx);
|
|
311
|
+
const target = trackerTarget(ctx.cwd, { fid: str(ctx.flags.fid), issue: str(ctx.flags.issue) });
|
|
312
|
+
const skip = skipOf(target);
|
|
313
|
+
const given = ctx.flags.label ?? [];
|
|
314
|
+
if (skip) {
|
|
315
|
+
ctx.emit({
|
|
316
|
+
...transitionOut(ctx, given, t, board),
|
|
317
|
+
board: null,
|
|
318
|
+
boardSkipped: null,
|
|
319
|
+
tracker: skip,
|
|
320
|
+
});
|
|
321
|
+
return EXIT.OK;
|
|
322
|
+
}
|
|
323
|
+
// A malformed board target is a usage error: refused before any label is written.
|
|
324
|
+
let { board: payload, boardSkipped } = board === undefined
|
|
325
|
+
? { board: null, boardSkipped: null }
|
|
326
|
+
: boardPayload(ctx, board, {
|
|
327
|
+
issue: target.issue ?? "",
|
|
328
|
+
ownerRepo: target.ownerRepo || String(ctx.flags.ownerRepo ?? ""),
|
|
329
|
+
});
|
|
330
|
+
let current = given;
|
|
331
|
+
const read = await attempt("labels", ctx.log, async () => {
|
|
332
|
+
current = await readLabels(target);
|
|
302
333
|
});
|
|
334
|
+
const out = transitionOut(ctx, current, t, board);
|
|
335
|
+
const tracker = "done" in read && !read.done
|
|
336
|
+
? read
|
|
337
|
+
: await attempt("labels", ctx.log, () => writeLabels(target, {
|
|
338
|
+
add: out.add,
|
|
339
|
+
remove: out.remove,
|
|
340
|
+
labels: out.labels,
|
|
341
|
+
state: out.trackerState,
|
|
342
|
+
}));
|
|
343
|
+
let boardWrite = null;
|
|
344
|
+
const project = readBkitConfig(repoRoot(ctx.cwd)).github;
|
|
345
|
+
if (payload !== null && board !== undefined && project.project) {
|
|
346
|
+
if (isCloudOrCi()) {
|
|
347
|
+
// A cloud run's token can comment and label but never reach a Projects v2 board.
|
|
348
|
+
payload = null;
|
|
349
|
+
boardSkipped = "cloud";
|
|
350
|
+
}
|
|
351
|
+
else {
|
|
352
|
+
const { owner, number } = project.project;
|
|
353
|
+
boardWrite = await attempt("board", ctx.log, () => moveOnBoard(target, { owner, number, status: project[board] }));
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
ctx.emit({ ...out, board: payload, boardSkipped, tracker, boardWrite });
|
|
303
357
|
return EXIT.OK;
|
|
304
358
|
}
|
|
305
359
|
// ---------------------------------------------------------------------------
|
|
@@ -318,7 +372,7 @@ const FIELD_LABELS = {
|
|
|
318
372
|
verdict: "Verdict",
|
|
319
373
|
failures: "Failures",
|
|
320
374
|
scope: "Scope",
|
|
321
|
-
|
|
375
|
+
group: "Group",
|
|
322
376
|
attempt: "Attempt",
|
|
323
377
|
strategy: "Strategy",
|
|
324
378
|
};
|
|
@@ -338,12 +392,9 @@ function headerFields(ctx) {
|
|
|
338
392
|
out.push([f.slice(0, eq), f.slice(eq + 1)]);
|
|
339
393
|
}
|
|
340
394
|
}
|
|
341
|
-
else if (key === "
|
|
342
|
-
const count = str(ctx.flags.
|
|
343
|
-
out.push([
|
|
344
|
-
"Sub-plan",
|
|
345
|
-
`${String(ctx.flags.subPlan)}${count === undefined ? "" : `/${count}`}`,
|
|
346
|
-
]);
|
|
395
|
+
else if (key === "group") {
|
|
396
|
+
const count = str(ctx.flags.groupCount);
|
|
397
|
+
out.push(["Group", `${String(ctx.flags.group)}${count === undefined ? "" : `/${count}`}`]);
|
|
347
398
|
}
|
|
348
399
|
else if (FIELD_LABELS[key] !== undefined) {
|
|
349
400
|
out.push([FIELD_LABELS[key], String(ctx.flags[key])]);
|
|
@@ -469,18 +520,19 @@ export function buildComment(cwd, o) {
|
|
|
469
520
|
lines.push(readInput(cwd, s.slice(eq + 1), "section").replace(/\n+$/, ""));
|
|
470
521
|
}
|
|
471
522
|
// A whole-line cut marker copied in from an artifact would fire on the next
|
|
472
|
-
// run's issue text; inline, it is only a mention.
|
|
473
|
-
|
|
523
|
+
// run's issue text; inline, it is only a mention. The marker carries the body's
|
|
524
|
+
// hash, which is how a re-run finds the comment already posted.
|
|
525
|
+
return stampMarker(lines
|
|
474
526
|
.join("\n")
|
|
475
527
|
.split("\n")
|
|
476
528
|
.map((l) => (CUT_LINE.test(l) ? `\`${CUT_MARKER}\`` : l))
|
|
477
|
-
.join("\n");
|
|
529
|
+
.join("\n"));
|
|
478
530
|
}
|
|
479
531
|
/** `bkit issues comment`'s flags as a `CommentInput`. */
|
|
480
532
|
export function commentBody(ctx) {
|
|
481
533
|
const kind = str(ctx.flags.kind) ?? "step";
|
|
482
|
-
if (ctx.flags.
|
|
483
|
-
throw new CommandError(EXIT.USAGE, "--
|
|
534
|
+
if (ctx.flags.groupCount !== undefined && ctx.flags.group === undefined) {
|
|
535
|
+
throw new CommandError(EXIT.USAGE, "--group-count needs --group");
|
|
484
536
|
}
|
|
485
537
|
return buildComment(ctx.cwd, {
|
|
486
538
|
kind: kind,
|
|
@@ -507,11 +559,117 @@ export function commentBody(ctx) {
|
|
|
507
559
|
});
|
|
508
560
|
}
|
|
509
561
|
// ---------------------------------------------------------------------------
|
|
562
|
+
// fetch / related — issue text straight to files, never through the orchestrator
|
|
563
|
+
// ---------------------------------------------------------------------------
|
|
564
|
+
/** Exit code 80 with the failure's reason, for the verbs that only talk to the tracker. */
|
|
565
|
+
function useMcp(ctx, err) {
|
|
566
|
+
const reason = classifyFailure(err);
|
|
567
|
+
ctx.log(redact(`tracker read failed (${reason}): ${err.message ?? String(err)}`));
|
|
568
|
+
ctx.emit({ reason });
|
|
569
|
+
return EXIT.USE_MCP;
|
|
570
|
+
}
|
|
571
|
+
async function fetchVerb(ctx) {
|
|
572
|
+
const out = str(ctx.flags.sessionDir) || str(ctx.flags.outbox);
|
|
573
|
+
if (!out)
|
|
574
|
+
throw new CommandError(EXIT.USAGE, "give --session-dir or --outbox");
|
|
575
|
+
const t = trackerTarget(ctx.cwd, { fid: str(ctx.flags.fid), issue: str(ctx.flags.issue) });
|
|
576
|
+
const skip = skipOf(t);
|
|
577
|
+
if (skip) {
|
|
578
|
+
ctx.emit(skip);
|
|
579
|
+
return EXIT.OK;
|
|
580
|
+
}
|
|
581
|
+
let issue;
|
|
582
|
+
try {
|
|
583
|
+
issue = await fetchIssue(t);
|
|
584
|
+
}
|
|
585
|
+
catch (err) {
|
|
586
|
+
return useMcp(ctx, err);
|
|
587
|
+
}
|
|
588
|
+
const dir = path.resolve(ctx.cwd, out);
|
|
589
|
+
const files = {
|
|
590
|
+
description: path.join(dir, "issue-description.md"),
|
|
591
|
+
comments: path.join(dir, "issue-comments.json"),
|
|
592
|
+
facts: path.join(dir, "issue-facts.json"),
|
|
593
|
+
};
|
|
594
|
+
const facts = { title: issue.title, url: issue.url, state: issue.state, labels: issue.labels };
|
|
595
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
596
|
+
fs.writeFileSync(files.description, issue.body);
|
|
597
|
+
const comments = sortOldestFirst(issue.comments).comments;
|
|
598
|
+
fs.writeFileSync(files.comments, `${JSON.stringify(comments, null, 2)}\n`);
|
|
599
|
+
fs.writeFileSync(files.facts, `${JSON.stringify(facts, null, 2)}\n`);
|
|
600
|
+
ctx.emit({ ...facts, files });
|
|
601
|
+
return EXIT.OK;
|
|
602
|
+
}
|
|
603
|
+
/** Hit ids from a search the orchestrator ran: ids, or objects carrying `number` / `identifier` / `key` / `id`. */
|
|
604
|
+
function readHits(cwd, file) {
|
|
605
|
+
const parsed = parseJson(readInput(cwd, file, "hits-file"));
|
|
606
|
+
const bad = () => new CommandError(EXIT_BAD_INPUT, `--hits-file ${file} is not a JSON list of issue ids`);
|
|
607
|
+
if (!parsed.ok || !Array.isArray(parsed.value))
|
|
608
|
+
throw bad();
|
|
609
|
+
return parsed.value.map((h) => {
|
|
610
|
+
const o = (h ?? {});
|
|
611
|
+
const id = typeof h === "object" ? (o.number ?? o.identifier ?? o.key ?? o.id) : h;
|
|
612
|
+
if (typeof id !== "string" && typeof id !== "number")
|
|
613
|
+
throw bad();
|
|
614
|
+
return String(id).trim().replace(/^#/, "").toUpperCase();
|
|
615
|
+
});
|
|
616
|
+
}
|
|
617
|
+
async function relatedVerb(ctx) {
|
|
618
|
+
const hitsFile = String(ctx.flags.hitsFile);
|
|
619
|
+
const outFile = String(ctx.flags.out);
|
|
620
|
+
const top = ctx.flags.top === undefined ? 10 : Number(ctx.flags.top);
|
|
621
|
+
if (!Number.isInteger(top) || top < 1)
|
|
622
|
+
throw new CommandError(EXIT.USAGE, "--top must be a positive integer");
|
|
623
|
+
const own = trackerTarget(ctx.cwd, { fid: str(ctx.flags.fid), issue: str(ctx.flags.issue) });
|
|
624
|
+
const hits = [...new Set(readHits(ctx.cwd, hitsFile))]
|
|
625
|
+
.filter((id) => id !== own.issue)
|
|
626
|
+
.slice(0, top);
|
|
627
|
+
const sections = [];
|
|
628
|
+
for (const id of hits) {
|
|
629
|
+
let issue;
|
|
630
|
+
try {
|
|
631
|
+
issue = await fetchIssue({ ...own, issue: id });
|
|
632
|
+
}
|
|
633
|
+
catch (err) {
|
|
634
|
+
return useMcp(ctx, err);
|
|
635
|
+
}
|
|
636
|
+
const ref = own.tracker === "github" ? `#${id}` : id;
|
|
637
|
+
const { text } = issueText(issue.body, sortOldestFirst(issue.comments).comments);
|
|
638
|
+
sections.push(`## ${ref} — ${issue.title} (${issue.state})${text ? `\n\n${text}` : ""}\n`);
|
|
639
|
+
}
|
|
640
|
+
const body = sections.length === 0 ? "None.\n" : sections.join("\n");
|
|
641
|
+
const abs = path.resolve(ctx.cwd, outFile);
|
|
642
|
+
fs.mkdirSync(path.dirname(abs), { recursive: true });
|
|
643
|
+
fs.writeFileSync(abs, body);
|
|
644
|
+
ctx.emit({ path: outFile, bytes: Buffer.byteLength(body), hits: hits.length });
|
|
645
|
+
return EXIT.OK;
|
|
646
|
+
}
|
|
647
|
+
async function blockedByVerb(ctx) {
|
|
648
|
+
const t = trackerTarget(ctx.cwd, { fid: str(ctx.flags.fid), issue: str(ctx.flags.issue) });
|
|
649
|
+
const skip = skipOf(t);
|
|
650
|
+
if (skip) {
|
|
651
|
+
ctx.emit(skip);
|
|
652
|
+
return EXIT.OK;
|
|
653
|
+
}
|
|
654
|
+
let blockers;
|
|
655
|
+
try {
|
|
656
|
+
blockers = await readBlockers(t);
|
|
657
|
+
}
|
|
658
|
+
catch (err) {
|
|
659
|
+
return useMcp(ctx, err);
|
|
660
|
+
}
|
|
661
|
+
ctx.emit({
|
|
662
|
+
blockers: blockers.map(({ id, state }) => ({ id, state })),
|
|
663
|
+
open: blockers.filter((b) => b.open).length,
|
|
664
|
+
});
|
|
665
|
+
return EXIT.OK;
|
|
666
|
+
}
|
|
667
|
+
// ---------------------------------------------------------------------------
|
|
510
668
|
// Command
|
|
511
669
|
// ---------------------------------------------------------------------------
|
|
512
670
|
export const issuesCommand = {
|
|
513
671
|
noun: "issues",
|
|
514
|
-
summary: "
|
|
672
|
+
summary: "Tracker payloads (issue text, label transitions, comments); --post / --write send them.",
|
|
515
673
|
verbs: {
|
|
516
674
|
text: {
|
|
517
675
|
summary: "ISSUE_TEXT: description + human comments, after the bkit:ignore-earlier cut.",
|
|
@@ -532,6 +690,72 @@ export const issuesCommand = {
|
|
|
532
690
|
exitCodes: { [EXIT_BAD_INPUT]: "an input file is missing or not a list of comments" },
|
|
533
691
|
run: textVerb,
|
|
534
692
|
},
|
|
693
|
+
fetch: {
|
|
694
|
+
summary: "Read the run's issue into issue-description.md, issue-comments.json and issue-facts.json; prints the facts, never the body.",
|
|
695
|
+
flags: [
|
|
696
|
+
{ name: "fid", type: "string", help: "the run's FID (names the issue)" },
|
|
697
|
+
{ name: "issue", type: "string", help: "the issue id (instead of --fid)" },
|
|
698
|
+
{ name: "session-dir", type: "string", help: "write the three files here" },
|
|
699
|
+
{
|
|
700
|
+
name: "outbox",
|
|
701
|
+
type: "string",
|
|
702
|
+
help: "write the three files here (instead of --session-dir)",
|
|
703
|
+
},
|
|
704
|
+
],
|
|
705
|
+
output: {
|
|
706
|
+
title: "issue title",
|
|
707
|
+
url: "issue URL",
|
|
708
|
+
state: "tracker state name (GitHub: open | closed)",
|
|
709
|
+
labels: "label names",
|
|
710
|
+
files: "{description, comments, facts}: raw description, comments oldest first as JSON, {title, url, state, labels} as JSON",
|
|
711
|
+
skipped: "no-issue | tracker-none: nothing read, nothing written",
|
|
712
|
+
reason: "exit 80: network | auth | scope | rate-limit | not-found | http-<n>; read the issue via the tracker MCP",
|
|
713
|
+
},
|
|
714
|
+
exitCodes: {},
|
|
715
|
+
run: fetchVerb,
|
|
716
|
+
},
|
|
717
|
+
related: {
|
|
718
|
+
summary: "Fetch each hit of the orchestrator's related-issue search and write the related-issues file.",
|
|
719
|
+
flags: [
|
|
720
|
+
{
|
|
721
|
+
name: "hits-file",
|
|
722
|
+
type: "string",
|
|
723
|
+
required: true,
|
|
724
|
+
help: "JSON list of hit ids (or objects with number / identifier / key) in rank order",
|
|
725
|
+
},
|
|
726
|
+
{ name: "out", type: "string", required: true, help: "the related-issues file to write" },
|
|
727
|
+
{ name: "top", type: "string", help: "keep the first N hits (default 10)" },
|
|
728
|
+
{
|
|
729
|
+
name: "fid",
|
|
730
|
+
type: "string",
|
|
731
|
+
help: "the run's FID: its own issue is dropped from the hits",
|
|
732
|
+
},
|
|
733
|
+
{ name: "issue", type: "string", help: "the run's issue id (instead of --fid)" },
|
|
734
|
+
],
|
|
735
|
+
output: {
|
|
736
|
+
path: "the file written: one `## {ref} — {title} ({state})` section per hit, else `None.`",
|
|
737
|
+
bytes: "its size in bytes",
|
|
738
|
+
hits: "hits fetched",
|
|
739
|
+
reason: "exit 80: why a hit could not be read; nothing was written",
|
|
740
|
+
},
|
|
741
|
+
exitCodes: { [EXIT_BAD_INPUT]: "--hits-file is missing or not a JSON list of issue ids" },
|
|
742
|
+
run: relatedVerb,
|
|
743
|
+
},
|
|
744
|
+
"blocked-by": {
|
|
745
|
+
summary: "The issues blocking the run's issue, with their states and the ones still open.",
|
|
746
|
+
flags: [
|
|
747
|
+
{ name: "fid", type: "string", help: "the run's FID (names the issue)" },
|
|
748
|
+
{ name: "issue", type: "string", help: "the issue id (instead of --fid)" },
|
|
749
|
+
],
|
|
750
|
+
output: {
|
|
751
|
+
blockers: "[{id, state}]: GitHub from the body's bkit:blocked-by block, Linear from blocks relations, Jira from is-blocked-by links",
|
|
752
|
+
open: "how many blockers are not closed / done / canceled (0 = unblocked)",
|
|
753
|
+
skipped: "no-issue | tracker-none: nothing read",
|
|
754
|
+
reason: "exit 80: network | auth | scope | rate-limit | not-found | http-<n>; read the blockers via the tracker MCP",
|
|
755
|
+
},
|
|
756
|
+
exitCodes: {},
|
|
757
|
+
run: blockedByVerb,
|
|
758
|
+
},
|
|
535
759
|
labels: {
|
|
536
760
|
summary: "Label arithmetic for a transition, the tracker state, and the board payload.",
|
|
537
761
|
flags: [
|
|
@@ -547,8 +771,18 @@ export const issuesCommand = {
|
|
|
547
771
|
type: "string",
|
|
548
772
|
help: "also move the Projects v2 item: progress | review",
|
|
549
773
|
},
|
|
550
|
-
{
|
|
774
|
+
{
|
|
775
|
+
name: "issue",
|
|
776
|
+
type: "string",
|
|
777
|
+
help: "issue number (with --board); with --write, the issue to write (instead of --fid)",
|
|
778
|
+
},
|
|
551
779
|
{ name: "owner-repo", type: "string", help: "<owner>/<repo> of the issue (with --board)" },
|
|
780
|
+
{
|
|
781
|
+
name: "write",
|
|
782
|
+
type: "boolean",
|
|
783
|
+
help: "read the issue's labels, write the transition and state, move the board; prints `tracker` and `boardWrite`",
|
|
784
|
+
},
|
|
785
|
+
{ name: "fid", type: "string", help: "with --write: the run's FID (names the issue)" },
|
|
552
786
|
],
|
|
553
787
|
output: {
|
|
554
788
|
add: "labels to add",
|
|
@@ -557,8 +791,10 @@ export const issuesCommand = {
|
|
|
557
791
|
changed: "whether add or remove is non-empty",
|
|
558
792
|
autoRouteSuffix: `"${AUTO_ROUTE_SUFFIX}" when the label set carries ${AUTO_LABEL}, else ""`,
|
|
559
793
|
trackerState: "Linear or Jira issue state for this transition, from package.json; null under github, none, or no state move",
|
|
560
|
-
board: "
|
|
561
|
-
boardSkipped: "why board is null with --board: opted-out | not-configured | tracker-<name> |
|
|
794
|
+
board: "projects_write payloads {addItem, updateItem}, or null",
|
|
795
|
+
boardSkipped: "why board is null with --board: opted-out | not-configured | project-url-invalid | tracker-<name> | cloud (--write on a cloud or CI runtime: the next local run moves it)",
|
|
796
|
+
tracker: "with --write: the label (and state) write: {done: true, action: labels} | {done: false, action, reason} (write `labels` / `trackerState` via the tracker MCP) | {skipped}",
|
|
797
|
+
boardWrite: "with --write and a board payload: {done: true, action: board} | {done: false, action, reason} (send `board` via the MCP); null when nothing to move",
|
|
562
798
|
},
|
|
563
799
|
run: labelsVerb,
|
|
564
800
|
},
|
|
@@ -578,8 +814,8 @@ export const issuesCommand = {
|
|
|
578
814
|
{ name: "verdict", type: "string", help: "header field Verdict" },
|
|
579
815
|
{ name: "failures", type: "string", help: "header field Failures" },
|
|
580
816
|
{ name: "scope", type: "string", help: "header field Scope" },
|
|
581
|
-
{ name: "
|
|
582
|
-
{ name: "
|
|
817
|
+
{ name: "group", type: "string", help: "header field Group (x of x/y)" },
|
|
818
|
+
{ name: "group-count", type: "string", help: "y of Group x/y" },
|
|
583
819
|
{ name: "attempt", type: "string", help: "header field Attempt" },
|
|
584
820
|
{ name: "strategy", type: "string", help: "header field Strategy" },
|
|
585
821
|
{
|
|
@@ -620,13 +856,40 @@ export const issuesCommand = {
|
|
|
620
856
|
type: "string",
|
|
621
857
|
help: "failure: captured stderr (last 20 lines kept)",
|
|
622
858
|
},
|
|
859
|
+
POST_FLAG,
|
|
860
|
+
{ name: "fid", type: "string", help: "with --post: the run's FID (names the issue)" },
|
|
861
|
+
{ name: "issue", type: "string", help: "with --post: the issue id (instead of --fid)" },
|
|
862
|
+
{
|
|
863
|
+
name: "file",
|
|
864
|
+
type: "string",
|
|
865
|
+
help: "with --post: the run's status.jsonl; the post is recorded there and a re-run of the same comment is deduped by that row",
|
|
866
|
+
},
|
|
623
867
|
],
|
|
624
|
-
output: {
|
|
868
|
+
output: {
|
|
869
|
+
comment: "the comment body",
|
|
870
|
+
commentFile: COMMENT_FILE_OUTPUT,
|
|
871
|
+
tracker: TRACKER_OUTPUT,
|
|
872
|
+
},
|
|
625
873
|
exitCodes: {
|
|
626
874
|
[EXIT_BAD_INPUT]: "a --body-file / --section / --stderr-file / --error-file file is missing",
|
|
627
875
|
},
|
|
628
|
-
run: (ctx) => {
|
|
629
|
-
|
|
876
|
+
run: async (ctx) => {
|
|
877
|
+
const comment = commentBody(ctx);
|
|
878
|
+
const commentFile = commentFileOf(ctx.cwd, comment);
|
|
879
|
+
if (ctx.flags.post !== true) {
|
|
880
|
+
ctx.emit({ comment, commentFile });
|
|
881
|
+
return EXIT.OK;
|
|
882
|
+
}
|
|
883
|
+
const file = str(ctx.flags.file)
|
|
884
|
+
? path.resolve(ctx.cwd, String(ctx.flags.file))
|
|
885
|
+
: undefined;
|
|
886
|
+
const key = runActionKey(file, str(ctx.flags.workflow), str(ctx.flags.kind) ?? "step", str(ctx.flags.stepNumber), str(ctx.flags.subStep), str(ctx.flags.attempt));
|
|
887
|
+
const tracker = await postForVerb(ctx, comment, {
|
|
888
|
+
fid: str(ctx.flags.fid),
|
|
889
|
+
issue: str(ctx.flags.issue),
|
|
890
|
+
...(key === undefined ? {} : { file, key }),
|
|
891
|
+
});
|
|
892
|
+
ctx.emit({ comment, commentFile, tracker });
|
|
630
893
|
return EXIT.OK;
|
|
631
894
|
},
|
|
632
895
|
},
|