@cbartens/bkit 5.2.4 → 5.4.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 +27 -11
- package/.bkit/core/.agents/context.md +1 -1
- package/.bkit/core/.agents/docs.md +1 -1
- package/.bkit/core/.agents/plugins/bkit/hooks/bkit-guardrails.cjs +1 -1
- package/.bkit/core/.agents/rules.md +18 -1
- package/.bkit/core/.bkit/README.md +26 -10
- package/.bkit/core/.bkit/cloud.md +40 -39
- package/.bkit/core/.bkit/comparison.md +68 -345
- package/.bkit/core/.bkit/install.md +16 -9
- package/.bkit/core/.bkit/lite.md +73 -0
- package/.bkit/core/.bkit/pipeline.md +346 -0
- package/.bkit/core/.bkit/prompts.md +90 -74
- package/.bkit/core/.bkit/providers.md +42 -23
- package/.bkit/core/.bkit/templates.md +138 -19
- package/.bkit/core/.bkit/trackers.md +49 -4
- package/.bkit/core/.bkit/workflows.md +144 -123
- package/.bkit/core/.claude/hooks/bkit-guardrails.cjs +1 -1
- package/.bkit/core/.codex/hooks/bkit-guardrails.cjs +7 -4
- package/.bkit/core/.cursor/hooks/bkit-guardrails.cjs +8 -5
- package/.bkit/core/docs/templates/bkit-audit-accessibility.md +3 -2
- package/.bkit/core/docs/templates/bkit-audit-adoption.md +2 -2
- package/.bkit/core/docs/templates/bkit-audit-agents.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-aio-seo.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-analytics.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-annotations.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-app-performance.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-app-store.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-architecture.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-ci-performance.md +4 -2
- package/.bkit/core/docs/templates/bkit-audit-config.md +3 -2
- package/.bkit/core/docs/templates/bkit-audit-cost.md +3 -2
- package/.bkit/core/docs/templates/bkit-audit-coverage.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-database.md +3 -2
- package/.bkit/core/docs/templates/bkit-audit-dead-code.md +5 -5
- package/.bkit/core/docs/templates/bkit-audit-deferrals.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-dependencies.md +26 -21
- package/.bkit/core/docs/templates/bkit-audit-documentation.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-duplication.md +2 -2
- package/.bkit/core/docs/templates/bkit-audit-failures.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-flakes.md +3 -2
- package/.bkit/core/docs/templates/bkit-audit-gates.md +5 -2
- package/.bkit/core/docs/templates/bkit-audit-issues.md +3 -2
- package/.bkit/core/docs/templates/bkit-audit-llm.md +22 -15
- package/.bkit/core/docs/templates/bkit-audit-logs.md +10 -6
- package/.bkit/core/docs/templates/bkit-audit-models.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-privacy.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-prompts.md +7 -7
- package/.bkit/core/docs/templates/bkit-audit-red-team.md +12 -9
- package/.bkit/core/docs/templates/bkit-audit-reliability.md +3 -2
- package/.bkit/core/docs/templates/bkit-audit-repo.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-security.md +14 -12
- package/.bkit/core/docs/templates/bkit-audit-slop.md +1 -1
- package/.bkit/core/docs/templates/bkit-audit-testing.md +10 -8
- package/.bkit/core/docs/templates/bkit-audit-usability.md +1 -1
- package/.bkit/core/docs/templates/bkit-plan.md +8 -6
- package/.bkit/core/engine/checks/after/auth.ts +9 -9
- package/.bkit/core/engine/checks/after/ci-yml.ts +14 -12
- package/.bkit/core/engine/checks/after/github.ts +29 -120
- package/.bkit/core/engine/checks/after/index.ts +2 -2
- package/.bkit/core/engine/checks/after/managed.ts +8 -28
- package/.bkit/core/engine/checks/after/tools.ts +3 -15
- package/.bkit/core/engine/checks/before/context-fetch.ts +1 -21
- package/.bkit/core/engine/checks/before/index.ts +7 -43
- package/.bkit/core/engine/checks/before/mcp.ts +17 -8
- package/.bkit/core/engine/checks/before/repo.ts +9 -12
- package/.bkit/core/engine/checks/status-holes.ts +4 -6
- package/.bkit/core/engine/checks/tips/catalogue.ts +76 -24
- package/.bkit/core/engine/checks/tips/detect.ts +45 -2
- package/.bkit/core/engine/checks/tips/index.ts +77 -26
- package/.bkit/core/engine/cli.ts +57 -27
- package/.bkit/core/engine/commands/analysis.ts +36 -26
- package/.bkit/core/engine/commands/comply.ts +42 -32
- package/.bkit/core/engine/commands/harvest.ts +12 -12
- package/.bkit/core/engine/commands/install/doctor.ts +57 -28
- package/.bkit/core/engine/commands/install/install.ts +73 -130
- package/.bkit/core/engine/commands/install/uninstall.ts +191 -33
- package/.bkit/core/engine/commands/install/upgrade.ts +49 -43
- package/.bkit/core/engine/commands/land.ts +156 -0
- package/.bkit/core/engine/commands/lib.ts +45 -18
- package/.bkit/core/engine/commands/registry.ts +2 -0
- package/.bkit/core/engine/commands/tips.ts +12 -5
- package/.bkit/core/engine/commands/workflow/branches.ts +386 -286
- package/.bkit/core/engine/commands/workflow/counters.ts +21 -12
- package/.bkit/core/engine/commands/workflow/disk.ts +556 -0
- package/.bkit/core/engine/commands/workflow/fids.ts +46 -0
- package/.bkit/core/engine/commands/workflow/issues.ts +73 -28
- package/.bkit/core/engine/commands/workflow/ledgers.ts +3 -1
- package/.bkit/core/engine/commands/workflow/locks.ts +38 -152
- package/.bkit/core/engine/commands/workflow/prs.ts +15 -4
- package/.bkit/core/engine/commands/workflow/repo.ts +2 -2
- package/.bkit/core/engine/commands/workflow/roadmap.ts +49 -53
- package/.bkit/core/engine/commands/workflow/runs.ts +8 -7
- package/.bkit/core/engine/commands/workflow/runtime.ts +3 -2
- package/.bkit/core/engine/commands/workflow/status.ts +33 -11
- package/.bkit/core/engine/commands/workflow/steps.ts +25 -15
- package/.bkit/core/engine/commands/workflow/tests.ts +17 -5
- package/.bkit/core/engine/commands/workflow/workflows.ts +436 -267
- package/.bkit/core/engine/commands/workflow/workstreams.ts +4 -2
- package/.bkit/core/engine/commands/workflow/worktrees.ts +24 -6
- package/.bkit/core/engine/install/cloud-env.ts +10 -31
- package/.bkit/core/engine/install/manifest.ts +14 -7
- package/.bkit/core/engine/install/modules/antigravity.ts +15 -26
- package/.bkit/core/engine/install/modules/claude.ts +20 -28
- package/.bkit/core/engine/install/modules/cloud.ts +5 -2
- package/.bkit/core/engine/install/modules/codex.ts +15 -29
- package/.bkit/core/engine/install/modules/core.ts +106 -70
- package/.bkit/core/engine/install/modules/cursor.ts +6 -20
- package/.bkit/core/engine/install/modules/index.ts +7 -1
- package/.bkit/core/engine/install/modules/opencode.ts +48 -70
- package/.bkit/core/engine/install/network-allowlist.ts +73 -0
- package/.bkit/core/engine/install/placeholders.ts +16 -35
- package/.bkit/core/engine/install/write.ts +59 -12
- package/.bkit/core/engine/ledgers/telemetry.ts +6 -4
- package/.bkit/core/engine/render/hosts.ts +47 -67
- package/.bkit/core/engine/render/models.ts +29 -11
- package/.bkit/core/engine/shared/branches.ts +13 -0
- package/.bkit/core/engine/shared/egress.ts +3 -3
- package/.bkit/core/engine/shared/json.ts +18 -1
- package/.bkit/core/engine/shared/package-json.ts +63 -0
- package/.bkit/core/engine/shared/package-roots.ts +0 -10
- package/.bkit/core/engine/shared/protected-paths.ts +5 -130
- package/.bkit/core/engine/shared/settings.ts +44 -0
- package/.bkit/core/engine/shared/timeouts.ts +8 -7
- package/.bkit/core/hooks/antigravity-hook.js +1 -0
- package/.bkit/core/hooks/guardrails-shell.js +186 -40
- package/.bkit/core/hooks/guardrails-tiers.js +5 -78
- package/.bkit/core/prompts/bkit-audit-generate.md +103 -7
- package/.bkit/core/prompts/bkit-build-challenge-1.md +1 -1
- package/.bkit/core/prompts/bkit-build-challenge-2.md +1 -1
- package/.bkit/core/prompts/bkit-build-challenge-reconcile.md +1 -1
- package/.bkit/core/prompts/bkit-build-challenge-remediate.md +1 -1
- package/.bkit/core/prompts/bkit-build-challenge-tests.md +1 -1
- package/.bkit/core/prompts/bkit-build-install-skills.md +1 -1
- package/.bkit/core/prompts/bkit-build-plan-current.md +1 -1
- package/.bkit/core/prompts/bkit-build-plan-execute.md +4 -4
- package/.bkit/core/prompts/bkit-build-plan-gaps-remediate.md +1 -1
- package/.bkit/core/prompts/bkit-build-plan-verify.md +2 -2
- package/.bkit/core/prompts/bkit-debug-abort-handover.md +1 -1
- package/.bkit/core/prompts/bkit-debug-failure-diagnose.md +1 -1
- package/.bkit/core/prompts/bkit-debug-failure-remediate.md +1 -1
- package/.bkit/core/prompts/bkit-debug-failure-reproduce.md +78 -0
- package/.bkit/core/prompts/bkit-debug-failure-soak.md +1 -1
- package/.bkit/core/prompts/bkit-debug-summary.md +3 -3
- package/.bkit/core/prompts/bkit-design-spike.md +1 -1
- package/.bkit/core/prompts/bkit-design-summary.md +2 -2
- package/.bkit/core/prompts/bkit-design-update.md +1 -1
- package/.bkit/core/prompts/bkit-plan-complexity-check.md +1 -1
- package/.bkit/core/prompts/bkit-plan-generate.md +1 -1
- package/.bkit/core/prompts/bkit-plan-scope-check-1.md +1 -1
- package/.bkit/core/prompts/bkit-plan-scope-check-2.md +1 -1
- package/.bkit/core/prompts/bkit-plan-summary.md +1 -1
- package/.bkit/core/prompts/bkit-plan-update.md +1 -1
- package/.bkit/core/prompts/bkit-ship-conflict-resolve.md +1 -1
- package/.bkit/core/prompts/bkit-ship-deferred-sweep.md +1 -1
- package/.bkit/core/prompts/bkit-ship-update-docs.md +1 -1
- package/.bkit/core/prompts/bkit-utility-update-decisions.md +9 -2
- package/.bkit/core/prompts/bkit-utility-update-deferrals.md +9 -2
- package/.bkit/core/prompts/bkit-utility-update-documentation.md +2 -1
- package/.bkit/core/prompts/bkit-utility-update-failures.md +9 -2
- package/.bkit/core/prompts/bkit-utility-update-knowledge.md +9 -2
- package/.bkit/core/prompts/bkit-utility-update-roadmap.md +11 -4
- package/.bkit/core/workflows/bkit-auto.md +2 -2
- package/.bkit/core/workflows/bkit-build.md +10 -10
- package/.bkit/core/workflows/bkit-debug.md +80 -44
- package/.bkit/core/workflows/bkit-design.md +22 -13
- package/.bkit/core/workflows/bkit-plan.md +33 -16
- package/.bkit/core/workflows/bkit-ship.md +87 -98
- package/.bkit/shared/.claude/bkit-cloud.md +58 -25
- package/.bkit/shared/.claude/settings.json +19 -0
- package/.bkit/shared/.cursor/mcp.json +2 -1
- package/.bkit/shared/.opencode/opencode.json +19 -1
- package/.bkit/shared/docs/deployments.md +49 -29
- package/.bkit/shared/docs/security.md +8 -6
- package/.bkit/shared/docs/testing.md +9 -5
- package/.bkit/shared/gitignore +1 -2
- package/.bkit/templates/.cursor/Dockerfile +30 -16
- package/.bkit/templates/.github/ISSUE_TEMPLATE/bkit-bug.yml +78 -0
- package/.bkit/templates/.github/ISSUE_TEMPLATE/bkit-change.yml +91 -0
- package/.bkit/templates/.github/ISSUE_TEMPLATE/bkit-idea.yml +56 -0
- package/.bkit/templates/.github/renovate.json5 +91 -12
- package/.bkit/templates/.github/workflows/bkit-ci.yml +73 -55
- package/.bkit/templates/.github/workflows/bkit-cloud.yml +3 -1
- package/.bkit/templates/.github/workflows/bkit-renovate.yml +8 -1
- package/.bkit/templates/.github/workflows/bkit-trivy.yml +67 -0
- package/.bkit/templates/.husky/pre-commit +6 -0
- package/.bkit/templates/.husky/pre-push +15 -3
- package/.bkit/templates/.lintstagedrc.json +5 -1
- package/.bkit/templates/.oxlintrc.json +21 -0
- package/.bkit/templates/docs/capabilities.md +1 -1
- package/.bkit/templates/scripts/ci/check-capstone.mjs +176 -0
- package/.bkit/templates/scripts/ci/check-capstone.test.mjs +311 -0
- package/.bkit/templates/scripts/cleanup/bkit-disk-prune.machine.mjs +197 -0
- package/.bkit/templates/scripts/cleanup/bkit-disk-prune.mjs +164 -0
- package/.bkit/templates/scripts/graphify/bkit-graph-eager.py +2 -2
- package/.bkit/templates/scripts/graphify/bkit-graph-imports.py +43 -20
- package/.bkit/templates/scripts/graphify/bkit-graph-pre-push.sh +33 -11
- package/.bkit/templates/scripts/graphify/bkit-graph-repair.py +3 -2
- package/.bkit/templates/scripts/graphify/bkit-graphify-rollup.py +5 -5
- package/.bkit/templates/scripts/graphify/bkit-graphify.sh +79 -19
- package/CHANGELOG.md +98 -3
- package/README.md +252 -122
- package/dist/checks/after/auth.js +10 -11
- package/dist/checks/after/ci-yml.js +11 -14
- package/dist/checks/after/github.js +32 -125
- package/dist/checks/after/index.js +3 -2
- package/dist/checks/after/managed.js +8 -24
- package/dist/checks/after/tools.js +3 -16
- package/dist/checks/before/context-fetch.js +1 -21
- package/dist/checks/before/index.js +6 -42
- package/dist/checks/before/mcp.js +14 -9
- package/dist/checks/before/repo.js +8 -11
- package/dist/checks/status-holes.js +5 -7
- package/dist/checks/tips/catalogue.js +65 -18
- package/dist/checks/tips/detect.js +41 -2
- package/dist/checks/tips/index.js +61 -25
- package/dist/cli.js +52 -26
- package/dist/commands/analysis.js +21 -5
- package/dist/commands/comply.js +40 -31
- package/dist/commands/harvest.js +12 -13
- package/dist/commands/install/doctor.js +55 -23
- package/dist/commands/install/install.js +72 -122
- package/dist/commands/install/uninstall.js +165 -31
- package/dist/commands/install/upgrade.js +46 -39
- package/dist/commands/land.js +129 -0
- package/dist/commands/lib.js +41 -16
- package/dist/commands/registry.js +2 -0
- package/dist/commands/tips.js +10 -3
- package/dist/commands/workflow/branches.js +303 -248
- package/dist/commands/workflow/counters.js +17 -7
- package/dist/commands/workflow/disk.js +452 -0
- package/dist/commands/workflow/fids.js +39 -0
- package/dist/commands/workflow/issues.js +63 -27
- package/dist/commands/workflow/ledgers.js +3 -1
- package/dist/commands/workflow/locks.js +35 -130
- package/dist/commands/workflow/prs.js +8 -5
- package/dist/commands/workflow/repo.js +2 -2
- package/dist/commands/workflow/roadmap.js +50 -57
- package/dist/commands/workflow/runs.js +5 -5
- package/dist/commands/workflow/runtime.js +3 -2
- package/dist/commands/workflow/status.js +32 -12
- package/dist/commands/workflow/steps.js +19 -11
- package/dist/commands/workflow/tests.js +16 -3
- package/dist/commands/workflow/workflows.js +390 -249
- package/dist/commands/workflow/workstreams.js +4 -2
- package/dist/commands/workflow/worktrees.js +15 -6
- package/dist/install/cloud-env.js +10 -23
- package/dist/install/manifest.js +14 -7
- package/dist/install/modules/antigravity.js +15 -26
- package/dist/install/modules/claude.js +17 -21
- package/dist/install/modules/cloud.js +6 -2
- package/dist/install/modules/codex.js +15 -29
- package/dist/install/modules/core.js +95 -63
- package/dist/install/modules/cursor.js +6 -9
- package/dist/install/modules/index.js +6 -1
- package/dist/install/modules/opencode.js +41 -72
- package/dist/install/network-allowlist.js +62 -0
- package/dist/install/placeholders.js +16 -35
- package/dist/install/write.js +55 -15
- package/dist/ledgers/telemetry.js +5 -4
- package/dist/render/hosts.js +30 -55
- package/dist/render/models.js +20 -9
- package/dist/shared/branches.js +11 -0
- package/dist/shared/egress.js +0 -2
- package/dist/shared/json.js +14 -0
- package/dist/shared/package-json.js +61 -0
- package/dist/shared/package-roots.js +0 -8
- package/dist/shared/protected-paths.js +5 -122
- package/dist/shared/settings.js +23 -1
- package/dist/shared/timeouts.js +8 -7
- package/package.json +21 -17
- package/.bkit/core/.agents/shortcuts.md +0 -73
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
// checks/tips/catalogue.ts — the setup-tip catalogue: one entry per template, tool or
|
|
2
|
-
// setting a consumer has not set up yet. Each workflow
|
|
3
|
-
// (`bkit tips --workflow=<name
|
|
4
|
-
//
|
|
2
|
+
// setting a consumer has not set up yet. Each workflow, `@bkit-audit-generate` and the
|
|
3
|
+
// ledger / roadmap updaters print one tip at their close (`bkit tips --workflow=<name>`,
|
|
4
|
+
// `audit` / `utility` for the agents); `bkit tips` prints the top three;
|
|
5
|
+
// `.bkit/advisories.md` lists every firing tip under `Setup tips`.
|
|
5
6
|
//
|
|
6
7
|
// Array order is the priority: comms first (can workflows reach anything), then change
|
|
7
8
|
// quality (design → build), delivery (debug → ship), running cost, nice-to-have, and
|
|
8
9
|
// setup-specific plumbing last. `workflows` names where a tip matters: a workflow shows
|
|
9
|
-
// its own tips first, in array order, then the rest. Comms tips name every
|
|
10
|
+
// its own tips first, in array order, then the rest. Comms tips name every context, so
|
|
10
11
|
// they lead everywhere until fixed.
|
|
11
12
|
//
|
|
12
13
|
// Text rules: `line`, `why`, `caution` and `ask` are for the person, in plain English, and
|
|
@@ -20,6 +21,9 @@
|
|
|
20
21
|
// names its ids, so the tip and the advisory can never disagree and one
|
|
21
22
|
// `bkit.ignoreAdvisories` entry silences both.
|
|
22
23
|
|
|
24
|
+
import * as fs from "node:fs";
|
|
25
|
+
|
|
26
|
+
import { machineStepsPath, REPO_STEPS } from "../../commands/workflow/disk.js";
|
|
23
27
|
import { detectContextFetchMissing } from "../before/context-fetch.js";
|
|
24
28
|
import {
|
|
25
29
|
detectBlankDotenvKeys,
|
|
@@ -29,29 +33,28 @@ import {
|
|
|
29
33
|
isCloudOrCi,
|
|
30
34
|
} from "../before/env.js";
|
|
31
35
|
import { detectGhMcpToken, hasGithubMcpServer } from "../after/auth.js";
|
|
32
|
-
import {
|
|
33
|
-
buildTrackerSetupAdvisory,
|
|
34
|
-
readConsumerCloudAgents,
|
|
35
|
-
readConsumerIssueTracker,
|
|
36
|
-
} from "../after/github.js";
|
|
36
|
+
import { buildTrackerSetupAdvisory } from "../after/github.js";
|
|
37
37
|
import { buildDepUpdaterSetupAdvisory } from "../after/tools.js";
|
|
38
38
|
import { detectInstalledHostModules } from "../../install/hosts.js";
|
|
39
39
|
import { readBkitConfig } from "../../shared/settings.js";
|
|
40
|
-
import type { ComplyPhase } from "../../cli.js";
|
|
40
|
+
import type { ComplyPhase, TipsContext } from "../../cli.js";
|
|
41
41
|
import {
|
|
42
|
+
anyWorkflowMentions,
|
|
42
43
|
claudeSettingsHas,
|
|
43
44
|
codexTopLevelHas,
|
|
44
45
|
exists,
|
|
46
|
+
hasJsTestRunner,
|
|
45
47
|
hasLintStagedConfig,
|
|
46
48
|
hasMcpServer,
|
|
49
|
+
hasTestLinter,
|
|
47
50
|
unlockedMcpServers,
|
|
48
51
|
} from "./detect.js";
|
|
49
52
|
|
|
50
53
|
export interface SetupTip {
|
|
51
54
|
/** `bkit.ignoreAdvisories` key; never an advisory id (those go in `advisories`). */
|
|
52
55
|
id: string;
|
|
53
|
-
/**
|
|
54
|
-
workflows?: readonly
|
|
56
|
+
/** Contexts the tip matters in; absent = shown only after every context's own tips. */
|
|
57
|
+
workflows?: readonly TipsContext[];
|
|
55
58
|
/** Short label. */
|
|
56
59
|
title: string;
|
|
57
60
|
/** What `bkit tips` prints: what goes wrong today, then what to do. */
|
|
@@ -75,11 +78,14 @@ const hosts = (cwd: string) => detectInstalledHostModules(cwd);
|
|
|
75
78
|
/** Every phase workflow. A value import of `COMPLY_PHASES` would cycle through cli.ts. */
|
|
76
79
|
export const ALL_WORKFLOWS: readonly ComplyPhase[] = ["design", "plan", "build", "debug", "ship"];
|
|
77
80
|
|
|
81
|
+
/** Every `bkit tips --workflow=` context: the phase workflows, then the two agent closes. */
|
|
82
|
+
export const EVERY_CONTEXT: readonly TipsContext[] = [...ALL_WORKFLOWS, "audit", "utility"];
|
|
83
|
+
|
|
78
84
|
export const SETUP_TIPS: readonly SetupTip[] = [
|
|
79
85
|
// --- connect: can bkit talk to anything at all -------------------------------------
|
|
80
86
|
{
|
|
81
87
|
id: "tracker",
|
|
82
|
-
workflows:
|
|
88
|
+
workflows: EVERY_CONTEXT,
|
|
83
89
|
title: "Connect an issue tracker",
|
|
84
90
|
line: "bkit isn't connected to an issue tracker, so it can't read the task it's working on or record what it did. Connect GitHub or Linear, or switch this tip off if you don't want one.",
|
|
85
91
|
why: "Every workflow starts by reading the issue it's working on and reports progress back to it as it goes. Without a tracker, you have to paste in what the agent should look at each time, and nothing records what changed or why.",
|
|
@@ -91,7 +97,7 @@ export const SETUP_TIPS: readonly SetupTip[] = [
|
|
|
91
97
|
},
|
|
92
98
|
{
|
|
93
99
|
id: "gh-mcp",
|
|
94
|
-
workflows:
|
|
100
|
+
workflows: EVERY_CONTEXT,
|
|
95
101
|
title: "Give bkit its GitHub token",
|
|
96
102
|
line: "You chose GitHub as your tracker, but bkit has no GitHub token, so every attempt to read an issue or open a pull request will fail. Add the token.",
|
|
97
103
|
why: "Choosing GitHub only tells bkit where your issues live. The token is what lets it actually sign in. Without it the setting looks right but nothing works, which is confusing to track down.",
|
|
@@ -100,12 +106,12 @@ export const SETUP_TIPS: readonly SetupTip[] = [
|
|
|
100
106
|
"`.bkit/install.md` § Local env setup. The `github` server entry belongs in `.mcp.json` / `.cursor/mcp.json` (`.bkit/cloud.md` § MCP issue-tracker integration).",
|
|
101
107
|
advisories: ["gh-mcp-token-unset-shell", "gh-mcp-token-empty-shell"],
|
|
102
108
|
fires: (cwd) =>
|
|
103
|
-
|
|
109
|
+
readBkitConfig(cwd).issueTracker === "github" &&
|
|
104
110
|
(!hasGithubMcpServer(cwd) || detectGhMcpToken(cwd) !== null),
|
|
105
111
|
},
|
|
106
112
|
{
|
|
107
113
|
id: "bkit-env",
|
|
108
|
-
workflows:
|
|
114
|
+
workflows: EVERY_CONTEXT,
|
|
109
115
|
title: "Create bkit's private settings file",
|
|
110
116
|
line: "bkit's private settings file (.bkit/.env) is missing or has blank entries, so nothing that needs to sign in can. Create it and fill it in.",
|
|
111
117
|
why: "This one file holds the sign-in tokens every bkit tool reads. It's never shared or committed. Most other tips depend on it, so do this one early.",
|
|
@@ -114,7 +120,7 @@ export const SETUP_TIPS: readonly SetupTip[] = [
|
|
|
114
120
|
advisories: ["mcp-env-missing-dotenv", "mcp-env-blank-key-*"],
|
|
115
121
|
fires: (cwd) => {
|
|
116
122
|
if (isCloudOrCi()) return false;
|
|
117
|
-
const tracker =
|
|
123
|
+
const tracker = readBkitConfig(cwd).issueTracker;
|
|
118
124
|
return (
|
|
119
125
|
detectMissingDotenv(cwd, tracker) !== null || detectBlankDotenvKeys(cwd, tracker).length > 0
|
|
120
126
|
);
|
|
@@ -122,7 +128,7 @@ export const SETUP_TIPS: readonly SetupTip[] = [
|
|
|
122
128
|
},
|
|
123
129
|
{
|
|
124
130
|
id: "direnv",
|
|
125
|
-
workflows:
|
|
131
|
+
workflows: EVERY_CONTEXT,
|
|
126
132
|
title: "Load your tokens automatically",
|
|
127
133
|
line: "Your sign-in tokens are saved in .bkit/.env but not being loaded, so sign-ins will fail even though the file looks right. Set up direnv so they load whenever you open the project.",
|
|
128
134
|
why: "A saved file does nothing until something reads it. This is the most frustrating kind of breakage: nothing looks wrong, but every sign-in fails. direnv (a small tool that loads settings when you open a folder) fixes it once.",
|
|
@@ -131,7 +137,7 @@ export const SETUP_TIPS: readonly SetupTip[] = [
|
|
|
131
137
|
advisories: ["mcp-env-direnv-missing", "mcp-env-direnv-not-allowed"],
|
|
132
138
|
fires: (cwd) => {
|
|
133
139
|
if (isCloudOrCi() || !exists(cwd, ".bkit/.env")) return false;
|
|
134
|
-
const tracker =
|
|
140
|
+
const tracker = readBkitConfig(cwd).issueTracker;
|
|
135
141
|
return (
|
|
136
142
|
!exists(cwd, ".envrc") ||
|
|
137
143
|
detectDirenvMissing(cwd, tracker) !== null ||
|
|
@@ -143,7 +149,7 @@ export const SETUP_TIPS: readonly SetupTip[] = [
|
|
|
143
149
|
// --- quality: is the change good -----------------------------------------------------
|
|
144
150
|
{
|
|
145
151
|
id: "serena",
|
|
146
|
-
workflows: ["design", "plan", "build"],
|
|
152
|
+
workflows: ["design", "plan", "build", "audit", "utility"],
|
|
147
153
|
title: "Let agents look code up directly",
|
|
148
154
|
line: "Agents are finding code by searching for words, which is slower, costs more, and misses things. Set up Serena so they can look code up directly.",
|
|
149
155
|
why: 'Serena lets agents look up code the way your editor does ("where is this defined, and what uses it?") instead of guessing from text search and reading whole files. That means fewer accidental changes, fewer rounds of you correcting them, and lower running costs because they read less. It can only look things up, never change your files.',
|
|
@@ -153,7 +159,7 @@ export const SETUP_TIPS: readonly SetupTip[] = [
|
|
|
153
159
|
},
|
|
154
160
|
{
|
|
155
161
|
id: "ci-workflow",
|
|
156
|
-
workflows: ["build", "ship"],
|
|
162
|
+
workflows: ["build", "ship", "audit"],
|
|
157
163
|
title: "Automatic checks on every change",
|
|
158
164
|
line: "Nothing checks your changes automatically before they're merged, so broken code can land unnoticed. Add bkit's check workflow.",
|
|
159
165
|
why: 'This runs your tests and checks on GitHub every time something changes, and bkit\'s ship step waits for it to pass before merging. Without it, "shipped" only means "merged", not "checked".',
|
|
@@ -191,6 +197,16 @@ export const SETUP_TIPS: readonly SetupTip[] = [
|
|
|
191
197
|
steps: "`.bkit/templates.md` § slop-scan.",
|
|
192
198
|
fires: (cwd) => !exists(cwd, "slop-scan.config.json"),
|
|
193
199
|
},
|
|
200
|
+
{
|
|
201
|
+
id: "test-lint",
|
|
202
|
+
workflows: ["build"],
|
|
203
|
+
title: "Catch tests that can't fail",
|
|
204
|
+
line: "Nothing checks your test files, so a test that asserts nothing, or asserts only inside an if, still passes and the suite stays green having proved nothing. Add Oxlint with bkit's test rules.",
|
|
205
|
+
why: "Oxlint (a fast code linter) fails the check on a test with no assertion, a branch inside a test, an assertion that may never run, a malformed assertion, or a promise nobody waits for. Without it those tests pass whatever the code does.",
|
|
206
|
+
ask: "Run `pnpm add -D oxlint oxlint-tsgolint`, copy .bkit/templates/.oxlintrc.json to .oxlintrc.json, and set the `lint` script in package.json to run `oxlint -c .oxlintrc.json --type-aware --deny-warnings` (add `&&` and the current lint command if the script already has one). Then fix every hit in the tests themselves.",
|
|
207
|
+
steps: "`.bkit/templates.md` § Oxlint.",
|
|
208
|
+
fires: (cwd) => hasJsTestRunner(cwd) && !hasTestLinter(cwd),
|
|
209
|
+
},
|
|
194
210
|
{
|
|
195
211
|
id: "vale",
|
|
196
212
|
workflows: ["design", "plan"],
|
|
@@ -222,7 +238,7 @@ export const SETUP_TIPS: readonly SetupTip[] = [
|
|
|
222
238
|
ask: "Check my cloud-agent setup against .bkit/cloud.md: copy .bkit/templates/.github/workflows/bkit-cloud.yml to .github/workflows/bkit-cloud.yml and .bkit/templates/.claude/hooks/bkit-cloud-bootstrap.sh to .claude/hooks/ (for Cursor: .bkit/templates/.cursor/environment.json and .bkit/templates/.cursor/Dockerfile to .cursor/), run `gh secret set ANTHROPIC_API_KEY`, then tell me which dashboard settings are left.",
|
|
223
239
|
steps: "`.bkit/cloud.md`; `.bkit/templates.md` § Cloud-agent workflow and § Cursor.",
|
|
224
240
|
fires: (cwd) => {
|
|
225
|
-
const cloud =
|
|
241
|
+
const cloud = readBkitConfig(cwd).cloudAgents;
|
|
226
242
|
if (cloud === "none") return false;
|
|
227
243
|
if (cloud === "cursor") {
|
|
228
244
|
return !exists(cwd, ".cursor/environment.json") || !exists(cwd, ".cursor/Dockerfile");
|
|
@@ -298,9 +314,20 @@ export const SETUP_TIPS: readonly SetupTip[] = [
|
|
|
298
314
|
},
|
|
299
315
|
|
|
300
316
|
// --- optional: nice to have ------------------------------------------------------------
|
|
317
|
+
{
|
|
318
|
+
id: "issue-forms",
|
|
319
|
+
workflows: ["design", "plan", "debug"],
|
|
320
|
+
title: "Issue forms",
|
|
321
|
+
line: "Optional: add issue forms so every new issue asks for what the agent reads first.",
|
|
322
|
+
why: "Each workflow starts from the issue. A form for an idea, a well-defined change or a bug asks for the problem, what done looks like, or the steps to reproduce. Without one, issues often arrive as a title and a line, and the agent has to guess.",
|
|
323
|
+
ask: "Copy .bkit/templates/.github/ISSUE_TEMPLATE/ to .github/ISSUE_TEMPLATE/ and commit it to the default branch.",
|
|
324
|
+
steps: "`.bkit/templates.md` § Issue forms.",
|
|
325
|
+
fires: (cwd) =>
|
|
326
|
+
readBkitConfig(cwd).issueTracker === "github" && !exists(cwd, ".github/ISSUE_TEMPLATE"),
|
|
327
|
+
},
|
|
301
328
|
{
|
|
302
329
|
id: "graphify",
|
|
303
|
-
workflows: ["design", "plan"],
|
|
330
|
+
workflows: ["design", "plan", "audit"],
|
|
304
331
|
title: "A map of the code",
|
|
305
332
|
line: "Optional: add graphify to keep an up-to-date map of how your code fits together.",
|
|
306
333
|
why: "With a map, agents check what already exists before building it again. Without one, agents and reviews work out the structure from scratch each time. That's slower, and it's easy to miss how one change ripples into another part of the code.",
|
|
@@ -310,7 +337,7 @@ export const SETUP_TIPS: readonly SetupTip[] = [
|
|
|
310
337
|
},
|
|
311
338
|
{
|
|
312
339
|
id: "dependabot-renovate",
|
|
313
|
-
workflows: ["ship"],
|
|
340
|
+
workflows: ["ship", "audit"],
|
|
314
341
|
title: "Automatic updates",
|
|
315
342
|
line: "Nothing keeps the project's libraries up to date. Add an updater so you get small, safe updates instead of one big risky one later.",
|
|
316
343
|
why: "An updater opens a small pull request whenever a library you use has a new version. Skip it and updates pile up into one large upgrade that's far more likely to break something.",
|
|
@@ -319,6 +346,18 @@ export const SETUP_TIPS: readonly SetupTip[] = [
|
|
|
319
346
|
advisories: ["dep-updater-absent"],
|
|
320
347
|
fires: (cwd) => buildDepUpdaterSetupAdvisory(cwd)?.id === "dep-updater-absent",
|
|
321
348
|
},
|
|
349
|
+
{
|
|
350
|
+
id: "trivy",
|
|
351
|
+
workflows: ["ship", "audit"],
|
|
352
|
+
title: "Security scan",
|
|
353
|
+
line: "Nothing stops a change that adds a known-vulnerable library, a risky container setting or a leaked password from merging. Add the scan that fails the check when it finds one.",
|
|
354
|
+
why: "An updater only offers fixes, and only once a fixed version exists. The scan checks every change, plus once a day, so a known problem fails the check before it merges and one with no fix yet still shows up.",
|
|
355
|
+
ask: "Copy .bkit/templates/.github/workflows/bkit-trivy.yml to .github/workflows/bkit-trivy.yml, replace {{DEFAULT_BRANCH}} with my default branch, and commit it.",
|
|
356
|
+
steps:
|
|
357
|
+
"`.bkit/templates.md` § Trivy. Accept a finding in `.trivyignore.yaml` with `statement` + `expired_at`; never drop `--include-dev-deps`.",
|
|
358
|
+
fires: (cwd) =>
|
|
359
|
+
exists(cwd, ".github/workflows") && !anyWorkflowMentions(cwd, "aquasecurity/trivy"),
|
|
360
|
+
},
|
|
322
361
|
{
|
|
323
362
|
id: "prettier-tables",
|
|
324
363
|
workflows: ["design", "plan"],
|
|
@@ -339,6 +378,19 @@ export const SETUP_TIPS: readonly SetupTip[] = [
|
|
|
339
378
|
fires: (cwd) =>
|
|
340
379
|
exists(cwd, ".husky/pre-push") && !exists(cwd, "scripts/cleanup/bkit-tmp-prune.mjs"),
|
|
341
380
|
},
|
|
381
|
+
{
|
|
382
|
+
id: "disk-prune",
|
|
383
|
+
workflows: ALL_WORKFLOWS,
|
|
384
|
+
title: "Keep enough disk free for new worktrees",
|
|
385
|
+
line: "Build caches, Docker images and simulators fill the disk until a workflow cannot make its worktree. Add your own clean-up steps, run after commits and pushes.",
|
|
386
|
+
why: "bkit deletes nothing on its own: you choose the steps, starting from examples that only delete what comes back by itself. Commits run the cheap steps, pushes run the rest, and a workflow runs them before making a worktree on a nearly full disk.",
|
|
387
|
+
ask: "Copy .bkit/templates/scripts/cleanup/bkit-disk-prune.mjs to scripts/cleanup/ and/or .bkit/templates/scripts/cleanup/bkit-disk-prune.machine.mjs to ~/.config/bkit/disk-prune.mjs, edit the steps, then paste the `disk prune` block from the end of each .bkit/templates/.husky hook at the end of yours.",
|
|
388
|
+
steps: "`.bkit/templates.md` § Disk prune.",
|
|
389
|
+
fires: (cwd) =>
|
|
390
|
+
exists(cwd, ".husky/pre-push") &&
|
|
391
|
+
!exists(cwd, REPO_STEPS) &&
|
|
392
|
+
!fs.existsSync(machineStepsPath()),
|
|
393
|
+
},
|
|
342
394
|
|
|
343
395
|
// --- setup: only some setups -----------------------------------------------------------
|
|
344
396
|
{
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// checks/tips/detect.ts — local-only probes the setup-tip catalogue keys on: host MCP
|
|
2
|
-
// configs, host settings files, lint-staged config forms. No network.
|
|
2
|
+
// configs, host settings files, lint-staged and test-linter config forms. No network.
|
|
3
3
|
|
|
4
4
|
import * as fs from "node:fs";
|
|
5
5
|
import * as path from "node:path";
|
|
6
6
|
import { parseJson } from "../../shared/json.js";
|
|
7
|
-
import { readPackageJson } from "../../shared/package-json.js";
|
|
7
|
+
import { readDependencyNames, readPackageJson } from "../../shared/package-json.js";
|
|
8
8
|
|
|
9
9
|
/** True when `rel` exists under `cwd`. */
|
|
10
10
|
export const exists = (cwd: string, rel: string): boolean => fs.existsSync(path.join(cwd, rel));
|
|
@@ -136,9 +136,52 @@ const LINT_STAGED_CONFIGS = [
|
|
|
136
136
|
"lint-staged.config.js",
|
|
137
137
|
];
|
|
138
138
|
|
|
139
|
+
/** True when any `.github/workflows/*.yml` / `*.yaml` contains `needle`. */
|
|
140
|
+
export function anyWorkflowMentions(cwd: string, needle: string): boolean {
|
|
141
|
+
const dir = path.join(cwd, ".github", "workflows");
|
|
142
|
+
if (!fs.existsSync(dir)) return false;
|
|
143
|
+
return fs
|
|
144
|
+
.readdirSync(dir)
|
|
145
|
+
.filter((f) => f.endsWith(".yml") || f.endsWith(".yaml"))
|
|
146
|
+
.some((f) => readText(cwd, path.join(".github", "workflows", f)).includes(needle));
|
|
147
|
+
}
|
|
148
|
+
|
|
139
149
|
/** True when lint-staged is configured: any of its config files, or `package.json` `lint-staged`. */
|
|
140
150
|
export function hasLintStagedConfig(cwd: string): boolean {
|
|
141
151
|
if (LINT_STAGED_CONFIGS.some((rel) => exists(cwd, rel))) return true;
|
|
142
152
|
const pkg = readPackageJson(cwd);
|
|
143
153
|
return pkg.ok && pkg.pkg["lint-staged"] !== undefined;
|
|
144
154
|
}
|
|
155
|
+
|
|
156
|
+
const OXLINT_CONFIGS = [
|
|
157
|
+
".oxlintrc.json",
|
|
158
|
+
...["ts", "mts", "cts", "js", "mjs", "cjs"].map((ext) => `oxlint.config.${ext}`),
|
|
159
|
+
];
|
|
160
|
+
|
|
161
|
+
const ESLINT_CONFIGS = [
|
|
162
|
+
".eslintrc",
|
|
163
|
+
...["json", "js", "cjs", "yaml", "yml"].map((ext) => `.eslintrc.${ext}`),
|
|
164
|
+
...["js", "mjs", "cjs", "ts", "mts", "cts"].map((ext) => `eslint.config.${ext}`),
|
|
165
|
+
];
|
|
166
|
+
|
|
167
|
+
/** A test-framework or test-library name inside an ESLint config means it lints tests. */
|
|
168
|
+
const TEST_LINT_PLUGIN = /vitest|jest|playwright|testing-library/i;
|
|
169
|
+
|
|
170
|
+
/** True when `package.json` lists a JS / TS test runner (Vitest or Jest) as a dependency. */
|
|
171
|
+
export const hasJsTestRunner = (cwd: string): boolean =>
|
|
172
|
+
readDependencyNames(cwd).some((name) => name === "vitest" || name === "jest");
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* True when the repo already lints its test files: an Oxlint config or `oxlint` dependency,
|
|
176
|
+
* or an ESLint config (file or `package.json` `eslintConfig`) that names a test plugin.
|
|
177
|
+
*/
|
|
178
|
+
export function hasTestLinter(cwd: string): boolean {
|
|
179
|
+
if (OXLINT_CONFIGS.some((rel) => exists(cwd, rel))) return true;
|
|
180
|
+
if (readDependencyNames(cwd).includes("oxlint")) return true;
|
|
181
|
+
const eslintConfigs = ESLINT_CONFIGS.map((rel) => readText(cwd, rel));
|
|
182
|
+
const pkg = readPackageJson(cwd);
|
|
183
|
+
if (pkg.ok && pkg.pkg["eslintConfig"] !== undefined) {
|
|
184
|
+
eslintConfigs.push(JSON.stringify(pkg.pkg["eslintConfig"]));
|
|
185
|
+
}
|
|
186
|
+
return eslintConfigs.some((text) => TEST_LINT_PLUGIN.test(text));
|
|
187
|
+
}
|
|
@@ -7,8 +7,8 @@ import {
|
|
|
7
7
|
type SuppressionNote,
|
|
8
8
|
type SuppressionReporter,
|
|
9
9
|
} from "../after/suppression.js";
|
|
10
|
-
import type {
|
|
11
|
-
import { SETUP_TIPS, type SetupTip } from "./catalogue.js";
|
|
10
|
+
import type { TipsContext } from "../../cli.js";
|
|
11
|
+
import { ALL_WORKFLOWS, SETUP_TIPS, type SetupTip } from "./catalogue.js";
|
|
12
12
|
|
|
13
13
|
/** Tips `bkit tips` prints without `--all` or `--workflow`. */
|
|
14
14
|
export const TIPS_CAP = 3;
|
|
@@ -27,6 +27,28 @@ export const tipsIntro = (n: number) =>
|
|
|
27
27
|
export const TIPS_DETAILS_POINTER =
|
|
28
28
|
"Details for every tip: .bkit/advisories.md § Setup tips (refreshed by `bkit check`).";
|
|
29
29
|
|
|
30
|
+
/** Last line of a workflow's `## bkit Tips`: how to silence what it shows, by id. */
|
|
31
|
+
export function silenceLine(ids: readonly string[]): string {
|
|
32
|
+
const names = ids.map((id) => `\`${id}\``);
|
|
33
|
+
const list = names.length > 1 ? `${names.slice(0, -1).join(", ")} and ${names.at(-1)}` : names[0];
|
|
34
|
+
const what = ids.length > 1 ? "these tips" : "this tip";
|
|
35
|
+
return `Want to silence ${what}? Ask your agent to "add ${list} to \`bkit.ignoreAdvisories\` in package.json".`;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** `bkit.ignoreAdvisories` key that silences `STAR_TIP`. */
|
|
39
|
+
export const STAR_TIP_ID = "bkit-star";
|
|
40
|
+
|
|
41
|
+
/** Older key that also silences `STAR_TIP`, so repos that set it keep the line off. */
|
|
42
|
+
export const STAR_TIP_OLD_ID = "star";
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Last line of `bkit tips` output while not silenced, in bare `bkit tips` and the phase
|
|
46
|
+
* workflows only — audits and the ledger / roadmap updaters often run back to back. Not a
|
|
47
|
+
* gap, so never in the checklist.
|
|
48
|
+
*/
|
|
49
|
+
export const STAR_TIP =
|
|
50
|
+
"Do you like bkit? Then give it a star at [https://github.com/cbartens/bkit](https://github.com/cbartens/bkit)!";
|
|
51
|
+
|
|
30
52
|
/** Intro of the Setup tips section: who reads which field, and how to silence a tip. */
|
|
31
53
|
export const TIPS_SECTION_INTRO =
|
|
32
54
|
"Things not set up yet, most useful first. For the person: each tip says what goes wrong today and a sentence to ask your agent. For an AI agent: follow each tip's Agent steps unless the person declines it. Silence a tip by adding its id to `bkit.ignoreAdvisories` in package.json. Full template catalogue: .bkit/templates.md.";
|
|
@@ -48,6 +70,8 @@ export interface TipsResult {
|
|
|
48
70
|
tips: SetupTip[];
|
|
49
71
|
/** Firing tips the root `bkit.ignoreAdvisories` silenced. */
|
|
50
72
|
suppressed: SuppressionNote[];
|
|
73
|
+
/** False when the root `bkit.ignoreAdvisories` names `STAR_TIP_ID` or `STAR_TIP_OLD_ID`. */
|
|
74
|
+
star: boolean;
|
|
51
75
|
}
|
|
52
76
|
|
|
53
77
|
/** Every firing tip in priority order, minus the ones the root package.json silences. */
|
|
@@ -60,7 +84,8 @@ export function collectTips(cwd: string, catalogue: readonly SetupTip[] = SETUP_
|
|
|
60
84
|
if (isTipSilenced(tip, ignored)) suppressed.push({ id: tip.id, scope: "." });
|
|
61
85
|
else tips.push(tip);
|
|
62
86
|
}
|
|
63
|
-
|
|
87
|
+
const star = !ignored.has(STAR_TIP_ID) && !ignored.has(STAR_TIP_OLD_ID);
|
|
88
|
+
return { tips, suppressed, star };
|
|
64
89
|
}
|
|
65
90
|
|
|
66
91
|
/**
|
|
@@ -93,51 +118,77 @@ function tipTextLines(tip: SetupTip, n: number): string[] {
|
|
|
93
118
|
return lines;
|
|
94
119
|
}
|
|
95
120
|
|
|
96
|
-
/** One tip as markdown
|
|
97
|
-
function
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
return lines;
|
|
121
|
+
/** One tip as one markdown paragraph for a workflow's `## bkit Tips` section. */
|
|
122
|
+
function tipParagraph(tip: SetupTip): string {
|
|
123
|
+
const caution = tip.caution ? ` Caution: ${tip.caution}` : "";
|
|
124
|
+
return `**${tip.title}.** ${tip.line} Ask your agent: "${tip.ask}"${caution}`;
|
|
101
125
|
}
|
|
102
126
|
|
|
103
127
|
/**
|
|
104
128
|
* `tips` with the ones that matter in `workflow` first, each group in catalogue order.
|
|
105
129
|
* Comms tips name every workflow, so they stay first everywhere.
|
|
106
130
|
*/
|
|
107
|
-
export function orderForWorkflow(tips: readonly SetupTip[], workflow:
|
|
131
|
+
export function orderForWorkflow(tips: readonly SetupTip[], workflow: TipsContext): SetupTip[] {
|
|
108
132
|
const own = tips.filter((t) => t.workflows?.includes(workflow));
|
|
109
133
|
return [...own, ...tips.filter((t) => !own.includes(t))];
|
|
110
134
|
}
|
|
111
135
|
|
|
136
|
+
/** True when `STAR_TIP` closes the output in `workflow`: bare `bkit tips` or a phase workflow. */
|
|
137
|
+
export function starShownIn(workflow: TipsContext | null | undefined): boolean {
|
|
138
|
+
return !workflow || (ALL_WORKFLOWS as readonly string[]).includes(workflow);
|
|
139
|
+
}
|
|
140
|
+
|
|
112
141
|
/**
|
|
113
|
-
* `bkit tips` output
|
|
114
|
-
* - `workflow`: the `WORKFLOW_TIPS_CAP` tips that matter most in that workflow
|
|
115
|
-
* markdown
|
|
116
|
-
* own `##
|
|
117
|
-
* - neither: the top `TIPS_CAP` tips as a numbered terminal list
|
|
142
|
+
* `bkit tips` output. `""` when no tip fires and no star line shows.
|
|
143
|
+
* - `workflow`: the `WORKFLOW_TIPS_CAP` tips that matter most in that workflow as
|
|
144
|
+
* one markdown paragraph each, then `STAR_TIP` when shown, then `silenceLine` naming both — the
|
|
145
|
+
* workflow appends them under its own `## bkit Tips` heading.
|
|
146
|
+
* - neither: the top `TIPS_CAP` tips as a numbered terminal list, where the rest live,
|
|
147
|
+
* then `STAR_TIP` when shown.
|
|
118
148
|
* - `all`: every tip as a numbered list (in the workflow's order when `workflow` is set).
|
|
149
|
+
* `STAR_TIP` shows when `opts.star` is set and `starShownIn(workflow)`.
|
|
119
150
|
*/
|
|
120
151
|
export function formatTips(
|
|
121
152
|
tips: readonly SetupTip[],
|
|
122
|
-
opts: { all?: boolean; workflow?:
|
|
153
|
+
opts: { all?: boolean; workflow?: TipsContext | null; star?: boolean } = {},
|
|
154
|
+
): string {
|
|
155
|
+
const star = !!opts.star && starShownIn(opts.workflow);
|
|
156
|
+
if (opts.workflow && !opts.all) return formatWorkflowTips(tips, opts.workflow, star);
|
|
157
|
+
const body = formatSetupTips(tips, opts);
|
|
158
|
+
if (!star) return body;
|
|
159
|
+
return body ? `${body}\n\n${STAR_TIP}` : STAR_TIP;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** `formatTips` for a workflow's `## bkit Tips`: tips, star line, how to silence both. */
|
|
163
|
+
function formatWorkflowTips(
|
|
164
|
+
tips: readonly SetupTip[],
|
|
165
|
+
workflow: TipsContext,
|
|
166
|
+
star: boolean,
|
|
167
|
+
): string {
|
|
168
|
+
const shown = orderForWorkflow(tips, workflow).slice(0, WORKFLOW_TIPS_CAP);
|
|
169
|
+
const ids = shown.map((t) => t.id);
|
|
170
|
+
const parts = shown.map(tipParagraph);
|
|
171
|
+
if (star) {
|
|
172
|
+
parts.push(STAR_TIP);
|
|
173
|
+
ids.push(STAR_TIP_ID);
|
|
174
|
+
}
|
|
175
|
+
if (ids.length === 0) return "";
|
|
176
|
+
return [...parts, silenceLine(ids)].join("\n\n");
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** `formatTips` as a terminal list, without `STAR_TIP`. */
|
|
180
|
+
function formatSetupTips(
|
|
181
|
+
tips: readonly SetupTip[],
|
|
182
|
+
opts: { all?: boolean; workflow?: TipsContext | null },
|
|
123
183
|
): string {
|
|
124
184
|
if (tips.length === 0) return "";
|
|
125
185
|
const ordered = opts.workflow ? orderForWorkflow(tips, opts.workflow) : [...tips];
|
|
126
|
-
const
|
|
127
|
-
const shown = opts.all ? ordered : ordered.slice(0, cap);
|
|
186
|
+
const shown = opts.all ? ordered : ordered.slice(0, TIPS_CAP);
|
|
128
187
|
const rest = tips.length - shown.length;
|
|
129
|
-
const more = rest > 0 ? `${rest} more: \`bkit tips --all\`. ` : "";
|
|
130
|
-
|
|
131
|
-
if (opts.workflow && !opts.all) {
|
|
132
|
-
const lines: string[] = [];
|
|
133
|
-
for (const tip of shown) lines.push(...tipMarkdownLines(tip), "");
|
|
134
|
-
lines.push(`${more}${TIPS_DETAILS_POINTER}`);
|
|
135
|
-
return lines.join("\n");
|
|
136
|
-
}
|
|
137
188
|
|
|
138
189
|
const lines = [tipsIntro(shown.length), ""];
|
|
139
190
|
shown.forEach((tip, i) => lines.push(...tipTextLines(tip, i + 1), ""));
|
|
140
|
-
if (
|
|
191
|
+
if (rest > 0) lines.push(`${rest} more: \`bkit tips --all\`.`);
|
|
141
192
|
lines.push(TIPS_DETAILS_POINTER);
|
|
142
193
|
return lines.join("\n");
|
|
143
194
|
}
|