@dadado/agent-kit-cli 6.8.0 → 6.9.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.
@@ -35,19 +35,29 @@ and published as `docs/contracts/mission-control-snapshot.schema.json`. The Flig
35
35
  operator tickets (gate exits awaiting triage) read-only from `gateExit`
36
36
  (`lib/gate-exit-tickets.mjs`, the no-fetch mirror of `agent-kit ground-control status`).
37
37
 
38
- ## Git tab and DevOps tab
39
-
40
- The Git tab (`#git`) keeps the pre-rendered `git log --graph` markdown block and adds a
38
+ ## Git e CI/CD section
39
+
40
+ The former Git and DevOps tabs are one section, **Git e CI/CD** (`#git`; `#devops` and
41
+ `#git-cicd` still deep-link there through `SECTION_ALIASES`), laid out as a bento grid
42
+ (`.bento`, 6 columns on the skin tokens; one column below 900px). Tiles: Ship lane, Promotion
43
+ flow, Open pull requests, CI/CD pipeline, Deploy activity, Branch graph, and Changed files when
44
+ the tree is dirty. The Ship lane and Open pull requests tiles read the snapshot's `shipLane`
45
+ field (1.8.0, `lib/ship-lane.mjs`) and show an empty state on an older engine. Every action is
46
+ copy-only: the ship lane copy buttons carry their command in `data-ship-copy` and go through one
47
+ delegated listener into `copyForPaste`, with no inline handler. ADR
48
+ `2026-10-23_git-cicd-tab-read-in-mc-act-in-colony.md`.
49
+
50
+ The branch graph tile keeps the pre-rendered `git log --graph` markdown block and adds a
41
51
  second, state-colored visual tree next to it, reusing the `.now-stepper`/`.now-step-marker`
42
52
  timeline component built for the Current Mission panel (`renderGitVisualTree` in
43
53
  `dashboard.html`, parsing `SNAPSHOT.git.graph`). It is single-lane by design — the markdown
44
54
  block keeps the true branch-lane geometry; the stepper trades that for an at-a-glance
45
55
  promotion read (HEAD, promoted to `origin/main`/`origin/staging`, or neither).
46
56
 
47
- The DevOps tab (`#devops`) is scoped to CI/CD + deploy signal, separate from the
48
- local-process-only Processes tab. `dashboard-data.mjs`'s `collectPipelineRuns()` shells to
57
+ The CI/CD pipeline and Deploy activity tiles are scoped to CI/CD + deploy signal, separate
58
+ from the local-process-only Processes tab. `dashboard-data.mjs`'s `collectPipelineRuns()` shells to
49
59
  `gh run list` (budget-guarded via `withinSnapshotBudget()`, fails soft to an honest
50
60
  empty-state when `gh` is unavailable/unauthenticated); `collectDeploySignal()` reads `v*`
51
61
  git tags plus the latest non-`Unreleased` `CHANGELOG.md` entry as a best-effort "what
52
- shipped recently" proxy. Neither collector polls live infra/hosting — the DevOps tab never
62
+ shipped recently" proxy. Neither collector polls live infra/hosting — the section never
53
63
  implies monitoring it does not perform.
@@ -4,7 +4,7 @@
4
4
  // Scans .cursor/plans, HANDOFF, memory, config, git status, terminals, processes
5
5
  // Outputs JSON to stdout (consumed by dashboard.html)
6
6
 
7
- import { execFileSync } from "node:child_process";
7
+ import { execFile, execFileSync } from "node:child_process";
8
8
  import { existsSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
9
9
  import { dirname, join, resolve } from "node:path";
10
10
  import { collectChats } from "./lib/chat-sessions.mjs";
@@ -48,6 +48,22 @@ import {
48
48
  serializeFlightLogLedger,
49
49
  serializeMissionTimingLedger,
50
50
  } from "./lib/semantic-model.mjs";
51
+ import {
52
+ buildShipLaneRows,
53
+ classifyGhFailure,
54
+ FACTORY_PUBLIC_REPO,
55
+ isFactorySlug,
56
+ parseForgeRemote,
57
+ readCachedShipLaneRemote,
58
+ SHIP_LANE_CACHE_ENV,
59
+ SHIP_LANE_GH_TIMEOUT_MS,
60
+ SHIP_LANE_NPM_TIMEOUT_MS,
61
+ safeNpmName,
62
+ safeTagName,
63
+ shipLaneGhArgs,
64
+ shipLaneReasonNote,
65
+ trimShipLaneGraphql,
66
+ } from "./lib/ship-lane.mjs";
51
67
  import { buildTerminalSnapshotFields, MAX_TERMINAL_BYTES } from "./lib/terminal-snapshot.mjs";
52
68
 
53
69
  const KIT_ROOT = resolve(import.meta.dirname, "..");
@@ -135,7 +151,7 @@ function redactTerminalOutput(text) {
135
151
 
136
152
  const SNAPSHOT = {
137
153
  _schema: {
138
- version: "1.7.0",
154
+ version: "1.8.0",
139
155
  description: "Mission Control dashboard data model",
140
156
  fields: {
141
157
  generatedAt: "ISO-8601 timestamp of snapshot generation",
@@ -158,6 +174,8 @@ const SNAPSHOT = {
158
174
  "Pending operator tickets (read-only, never fetches): {marker: absent|ok|invalid, base, tickets[] (stamp, headline, askId, labels, trigger, openedAt, url, branch, branchState unmerged|merged|none, inMarker), skipped[] (latest launcher skip records), truncated} from .cursor/context/gate-exit.json and gate-exit/<stamp> branches; same contract as agent-kit ground-control status (1.6.0)",
159
175
  chats:
160
176
  "Saved agent chats of this workspace: {withheld, vendors[]} with one envelope per vendor {vendor: claude|codex|cursor, status: ok|unsupported|none, projectDir, sessions[] ({id, title, titleSource: custom|ai|first-prompt|none, modified unix ms, sizeBytes}, newest first, capped at 200), total}; same contract as agent-kit sessions --json. withheld is true (vendors empty) in broadcast mode: chat titles never leave the machine (1.7.0)",
177
+ shipLane:
178
+ "Release ship lane for the Git e CI/CD section (read-only, copy-only next commands): {lane: factory|consumer|null, repo, publicRepo, local {latestTag, version, mainRef, stagingAheadOfMain, mainInStaging, tagOnMain}, remote ({available, reason?, fetchedAt?, repo, tag, prs[] (number, capped title, base, head, draft, mergeable, mergeState, stackedOn, checks {state, total, failing[], pending, signatureScan}), prsTotal, originRelease, tagCi {workflow, runId, jobs[]}, public {release, syncPrs[]}, npm {name, version}}; one gh api graphql call + one npm registry read, run alongside gh run list and reused from serve.mjs for up to 120s; reason budget|gh-missing|gh-auth|timeout|call-failed|no-remote|provider-unsupported), rows[] ({id, label, state: green|red|pending|unknown, detail, next {text, destination}|null}) mirroring the /kit-prod Done rows} (1.8.0)",
161
179
  processes:
162
180
  "Running process snapshots (node, serve.mjs, git operations) with elapsed time and a generated narration per process",
163
181
  skills: "Available skills discovered in .cursor/skills/",
@@ -166,7 +184,7 @@ const SNAPSHOT = {
166
184
  },
167
185
  },
168
186
  generatedAt: new Date().toISOString(),
169
- dashboardDataVersion: "1.7.0",
187
+ dashboardDataVersion: "1.8.0",
170
188
  plans: [],
171
189
  system: {
172
190
  repoRoot: ROOT,
@@ -736,6 +754,181 @@ function collectDeploySignal() {
736
754
  return { tags, changelog };
737
755
  }
738
756
 
757
+ // 6c. Ship lane (Git e CI/CD section; ADR 2026-10-23
758
+ // git-cicd-tab-read-in-mc-act-in-colony). Local half: cheap git reads, every
759
+ // snapshot. Forge half: one `gh api graphql` call plus one npm registry read,
760
+ // started asynchronously right before collectPipelineRuns() so the two network
761
+ // waits overlap instead of adding up. That is why SNAPSHOT_BUDGET_MS did not
762
+ // grow with this collector: its reserve is checked against the same budget
763
+ // before gh run list starts, and the await at the end waits at most
764
+ // max(remaining gh graphql time, 0) after gh run list returns.
765
+ function readPackageManifest(rel) {
766
+ try {
767
+ const pkg = JSON.parse(readFileSync(join(ROOT, rel), "utf-8"));
768
+ return pkg && typeof pkg === "object" ? pkg : null;
769
+ } catch {
770
+ return null;
771
+ }
772
+ }
773
+
774
+ function collectShipLaneLocal() {
775
+ const gitOpts = {
776
+ cwd: ROOT,
777
+ encoding: "utf-8",
778
+ timeout: 5000,
779
+ stdio: ["ignore", "pipe", "ignore"],
780
+ };
781
+ const gitText = (args) => {
782
+ try {
783
+ return execFileSync("git", args, gitOpts).trim();
784
+ } catch {
785
+ return null;
786
+ }
787
+ };
788
+ /** true / false from an exit code (0 / 1); null when git itself failed. */
789
+ const isAncestor = (a, b) => {
790
+ try {
791
+ execFileSync("git", ["merge-base", "--is-ancestor", a, b], gitOpts);
792
+ return true;
793
+ } catch (err) {
794
+ return err?.status === 1 ? false : null;
795
+ }
796
+ };
797
+ const refExists = (ref) => gitText(["rev-parse", "--verify", "--quiet", ref]) != null;
798
+ const originUrl = gitText(["remote", "get-url", "origin"]);
799
+ const forge = parseForgeRemote(originUrl);
800
+ const lane = forge ? (isFactorySlug(forge.slug) ? "factory" : "consumer") : null;
801
+ let publicRepo = null;
802
+ if (lane === "factory") {
803
+ publicRepo =
804
+ parseForgeRemote(gitText(["remote", "get-url", "public"]))?.slug ?? FACTORY_PUBLIC_REPO;
805
+ }
806
+ const rawTag =
807
+ gitText([
808
+ "for-each-ref",
809
+ "--sort=-creatordate",
810
+ "--format=%(refname:short)",
811
+ "--count=1",
812
+ "refs/tags/v*",
813
+ ]) || null;
814
+ // Tag names reach copyable shell commands and the gh argv: drop unsafe ones.
815
+ const latestTag = safeTagName(rawTag);
816
+ const mainRef = refExists("origin/main")
817
+ ? "origin/main"
818
+ : refExists("origin/master")
819
+ ? "origin/master"
820
+ : null;
821
+ const hasStaging = refExists("origin/staging");
822
+ let stagingAheadOfMain = null;
823
+ if (mainRef && hasStaging) {
824
+ const n = Number.parseInt(
825
+ gitText(["rev-list", "--count", `${mainRef}..origin/staging`]) ?? "",
826
+ 10,
827
+ );
828
+ stagingAheadOfMain = Number.isFinite(n) ? n : null;
829
+ }
830
+ const manifest = readPackageManifest(
831
+ lane === "factory" ? "packages/cli/package.json" : "package.json",
832
+ );
833
+ const version = typeof manifest?.version === "string" ? manifest.version : null;
834
+ const npmName =
835
+ manifest && manifest.private !== true && !manifest.publishConfig?.registry
836
+ ? safeNpmName(manifest.name)
837
+ : null;
838
+ return {
839
+ forge,
840
+ lane,
841
+ publicRepo,
842
+ npmName,
843
+ local: {
844
+ latestTag,
845
+ unsafeTag: rawTag != null && latestTag == null,
846
+ version,
847
+ mainRef,
848
+ stagingAheadOfMain,
849
+ mainInStaging: mainRef && hasStaging ? isAncestor(mainRef, "origin/staging") : null,
850
+ tagOnMain: latestTag && mainRef ? isAncestor(latestTag, mainRef) : null,
851
+ },
852
+ };
853
+ }
854
+
855
+ /** execFile as a promise that never rejects: { err, stdout, stderr }. */
856
+ function execFileSettled(bin, args, timeout) {
857
+ return new Promise((resolveExec) => {
858
+ execFile(
859
+ bin,
860
+ args,
861
+ { cwd: ROOT, encoding: "utf-8", timeout, maxBuffer: 2 * 1024 * 1024 },
862
+ (err, stdout, stderr) =>
863
+ resolveExec({ err, stdout: String(stdout || ""), stderr: String(stderr || "") }),
864
+ );
865
+ });
866
+ }
867
+
868
+ /** Registry read in a child node (fetch + abort timeout); no npm CLI spawn. */
869
+ const NPM_LATEST_SCRIPT =
870
+ 'const n=process.argv[1];fetch("https://registry.npmjs.org/"+n.replace("/","%2f")+"/latest",{signal:AbortSignal.timeout(Number(process.argv[2]))}).then(r=>r.ok?r.json():Promise.reject(r.status)).then(j=>process.stdout.write(String(j.version||""))).catch(()=>process.exit(1))';
871
+
872
+ /** @returns {Promise<object>} the forge half of SNAPSHOT.shipLane (remote). */
873
+ function startShipLaneRemote(ship) {
874
+ const { forge, local, publicRepo, npmName } = ship;
875
+ if (!forge) return Promise.resolve({ available: false, reason: "no-remote", repo: null });
876
+ if (forge.provider !== "github") {
877
+ return Promise.resolve({ available: false, reason: "provider-unsupported", repo: forge.slug });
878
+ }
879
+ const cached = readCachedShipLaneRemote(process.env[SHIP_LANE_CACHE_ENV], Date.now(), {
880
+ repo: forge.slug,
881
+ tag: local.latestTag,
882
+ });
883
+ if (cached) return Promise.resolve(cached);
884
+ if (!withinSnapshotBudget(SHIP_LANE_GH_TIMEOUT_MS + 400)) {
885
+ return Promise.resolve({ available: false, reason: "budget", repo: forge.slug });
886
+ }
887
+ const fetchedAt = new Date().toISOString();
888
+ const gh = execFileSettled(
889
+ "gh",
890
+ shipLaneGhArgs({ owner: forge.owner, name: forge.name, tag: local.latestTag, publicRepo }),
891
+ SHIP_LANE_GH_TIMEOUT_MS,
892
+ );
893
+ const npm = npmName
894
+ ? execFileSettled(
895
+ process.execPath,
896
+ ["-e", NPM_LATEST_SCRIPT, npmName, String(SHIP_LANE_NPM_TIMEOUT_MS)],
897
+ SHIP_LANE_NPM_TIMEOUT_MS + 1000,
898
+ )
899
+ : Promise.resolve(null);
900
+ return Promise.all([gh, npm]).then(([ghRes, npmRes]) => {
901
+ let parsed = null;
902
+ try {
903
+ parsed = JSON.parse(ghRes.stdout);
904
+ } catch {
905
+ parsed = null;
906
+ }
907
+ // gh exits non-zero when GraphQL returns errors next to partial data (an
908
+ // unreadable public repo): keep the data when the origin half is there.
909
+ const remote = trimShipLaneGraphql(parsed, {
910
+ repo: forge.slug,
911
+ tag: local.latestTag,
912
+ publicRepo,
913
+ fetchedAt,
914
+ });
915
+ if (!remote) {
916
+ return {
917
+ available: false,
918
+ reason: classifyGhFailure(ghRes.err, ghRes.stderr),
919
+ fetchedAt,
920
+ repo: forge.slug,
921
+ tag: local.latestTag,
922
+ };
923
+ }
924
+ if (npmName) {
925
+ const v = npmRes && !npmRes.err ? npmRes.stdout.trim() : "";
926
+ remote.npm = { name: npmName, version: /^\d+\.\d+\.\d+[\w.+-]*$/.test(v) ? v : null };
927
+ }
928
+ return remote;
929
+ });
930
+ }
931
+
739
932
  // SNAPSHOT.devops is assigned near the end of the snapshot build (after the
740
933
  // transcripts/reports/ps collectors below), not here — gh run list is a
741
934
  // network call that must not run ahead of and starve the local-only
@@ -1415,9 +1608,50 @@ SNAPSHOT._gitRecentLog = undefined;
1415
1608
  // a network call (gh run list) unlike every other collector in this file, so
1416
1609
  // it must not run ahead of and eat into the shared SNAPSHOT_BUDGET_MS budget
1417
1610
  // that the local-only collectors also need.
1611
+ // The ship lane's forge half starts first and runs while gh run list blocks.
1612
+ let shipLaneLocal = null;
1613
+ let shipLaneRemote;
1614
+ try {
1615
+ shipLaneLocal = collectShipLaneLocal();
1616
+ shipLaneRemote = startShipLaneRemote(shipLaneLocal);
1617
+ } catch {
1618
+ shipLaneRemote = Promise.resolve({ available: false, reason: "call-failed", repo: null });
1619
+ }
1418
1620
  SNAPSHOT.devops = {
1419
1621
  pipeline: collectPipelineRuns(),
1420
1622
  deploy: collectDeploySignal(),
1421
1623
  };
1624
+ {
1625
+ const remote = await shipLaneRemote;
1626
+ const local = shipLaneLocal?.local ?? {
1627
+ latestTag: null,
1628
+ version: null,
1629
+ mainRef: null,
1630
+ stagingAheadOfMain: null,
1631
+ mainInStaging: null,
1632
+ tagOnMain: null,
1633
+ };
1634
+ let rows = [];
1635
+ try {
1636
+ rows = buildShipLaneRows({
1637
+ lane: shipLaneLocal?.lane ?? "consumer",
1638
+ repo: shipLaneLocal?.forge?.slug ?? null,
1639
+ publicRepo: shipLaneLocal?.publicRepo ?? null,
1640
+ local,
1641
+ remote,
1642
+ });
1643
+ } catch {
1644
+ rows = [];
1645
+ }
1646
+ SNAPSHOT.shipLane = {
1647
+ lane: shipLaneLocal?.lane ?? null,
1648
+ repo: shipLaneLocal?.forge?.slug ?? null,
1649
+ publicRepo: shipLaneLocal?.publicRepo ?? null,
1650
+ local,
1651
+ remote,
1652
+ note: remote.available ? null : shipLaneReasonNote(remote.reason),
1653
+ rows,
1654
+ };
1655
+ }
1422
1656
 
1423
1657
  process.stdout.write(JSON.stringify(SNAPSHOT, null, 2));