@bli-cockpit/cli 0.2.54 → 0.2.56

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.
Files changed (60) hide show
  1. package/dist/adapters/attribution-core-fallbacks.js +247 -0
  2. package/dist/adapters/attribution-core-paths.js +182 -0
  3. package/dist/adapters/attribution-core-score.js +159 -0
  4. package/dist/adapters/attribution-core-types.js +13 -0
  5. package/dist/adapters/attribution-core.js +13 -565
  6. package/dist/adapters/claude-attribution-discovery.js +186 -0
  7. package/dist/adapters/claude-attribution-score.js +204 -0
  8. package/dist/adapters/claude-attribution-signals.js +180 -0
  9. package/dist/adapters/claude-attribution-types.js +25 -0
  10. package/dist/adapters/claude-attribution.js +14 -569
  11. package/dist/commands/doctor-access.js +129 -0
  12. package/dist/commands/doctor-pipeline.js +326 -0
  13. package/dist/commands/doctor-registration.js +105 -0
  14. package/dist/commands/doctor-report.js +111 -0
  15. package/dist/commands/doctor-update.js +120 -0
  16. package/dist/commands/doctor.js +8 -753
  17. package/dist/commands/heartbeat.js +8 -0
  18. package/dist/commands/jarvis-contracts.js +8 -0
  19. package/dist/commands/jarvis-render.js +413 -0
  20. package/dist/commands/jarvis-turn.js +305 -0
  21. package/dist/commands/jarvis.js +23 -698
  22. package/dist/commands/local-args-collector-setup.js +250 -0
  23. package/dist/commands/local-args-collector-status.js +227 -0
  24. package/dist/commands/local-args-collector-work.js +175 -0
  25. package/dist/commands/local-args-collector.js +19 -624
  26. package/dist/commands/local-args-tower-admin.js +456 -0
  27. package/dist/commands/local-args-tower-chat.js +194 -0
  28. package/dist/commands/local-args-tower-pages.js +314 -0
  29. package/dist/commands/local-args-tower.js +13 -880
  30. package/dist/commands/local-help.js +10 -2
  31. package/dist/commands/onboard-completion.js +136 -0
  32. package/dist/commands/onboard-flows.js +165 -0
  33. package/dist/commands/onboard-setup.js +102 -0
  34. package/dist/commands/onboard.js +5 -392
  35. package/dist/commands/public-root.js +1 -1
  36. package/dist/commands/session-sync-counters.js +55 -0
  37. package/dist/commands/session-sync-health.js +8 -1
  38. package/dist/commands/session-sync-plan.js +47 -7
  39. package/dist/commands/session-sync-scan.js +4 -4
  40. package/dist/commands/session-sync.js +6 -0
  41. package/dist/commands/settings-render.js +27 -0
  42. package/dist/commands/sync-followups.js +5 -1
  43. package/dist/commands/sync.js +5 -1
  44. package/dist/commands/team-device-reasons.js +16 -0
  45. package/dist/commands/team.js +87 -7
  46. package/dist/evidence-upload-client.js +14 -763
  47. package/dist/evidence-upload-object.js +181 -0
  48. package/dist/evidence-upload-plan.js +233 -0
  49. package/dist/evidence-upload-terminal.js +309 -0
  50. package/dist/evidence-upload-transport.js +104 -0
  51. package/dist/spool/local-spool-io.js +122 -0
  52. package/dist/spool/local-spool-mutations.js +174 -0
  53. package/dist/spool/local-spool-parse.js +143 -0
  54. package/dist/spool/local-spool-types.js +22 -0
  55. package/dist/spool/local-spool.js +20 -426
  56. package/dist/upload-evidence-delivery-offer.js +144 -0
  57. package/dist/upload-evidence-delivery-reconcile.js +134 -0
  58. package/dist/upload-evidence-delivery-summary.js +205 -0
  59. package/dist/upload-evidence-delivery.js +12 -482
  60. package/package.json +3 -3
@@ -0,0 +1,120 @@
1
+ import { DEFAULT_DASHBOARD_URL, LOCAL_COLLECTOR_VERSION } from "../local-state.js";
2
+ import { createInteractiveExecRunner } from "../process-runner.js";
3
+ import { asRecord, fail, needsFix, ok } from "./doctor-report.js";
4
+ /**
5
+ * The `cli-latest` check family: is this machine running the npm `latest`
6
+ * (or `--update-tag`) build, and if not, self-update and re-exec the new
7
+ * binary so every later check in the run sees the refreshed CLI.
8
+ */
9
+ export async function checkCliLatest(context) {
10
+ const latest = await context.deps.latestCliVersion(context);
11
+ if (!latest) {
12
+ return needsFix("cli-latest", "latest_version_unknown", `could not confirm npm latest; will run npm install for ${LOCAL_COLLECTOR_VERSION}`);
13
+ }
14
+ if (latest === LOCAL_COLLECTOR_VERSION) {
15
+ return ok("cli-latest", "already_latest", `current ${LOCAL_COLLECTOR_VERSION}`);
16
+ }
17
+ return needsFix("cli-latest", "stale_cli", `current ${LOCAL_COLLECTOR_VERSION}; npm latest ${latest}`);
18
+ }
19
+ export async function fixCliLatest(context, state) {
20
+ try {
21
+ await context.deps.selfUpdate(context.io, {
22
+ json: context.command.json,
23
+ tag: context.command.updateTag,
24
+ });
25
+ }
26
+ catch (error) {
27
+ return fail("cli-latest", selfUpdateFailureCode(error), selfUpdateFailureMessage(error));
28
+ }
29
+ if (context.io.env["COCKPIT_DOCTOR_REEXEC"] === "1") {
30
+ if (state.code === "stale_cli") {
31
+ return fail("cli-latest", "stale_after_self_update", "self-update ran but this process still reports the old CLI version; rerun `cockpit do-everything`.");
32
+ }
33
+ return ok("cli-latest", "updated_reexec_guarded", "self-update ran; re-exec guard already set, continuing.");
34
+ }
35
+ const code = await context.deps.reexecDoctor(context.command, context.io);
36
+ return {
37
+ ...ok("cli-latest", "reexeced", "self-update ran; re-execed the new cockpit binary."),
38
+ reexecExitCode: code,
39
+ };
40
+ }
41
+ export async function latestCliVersionFromNpm(context) {
42
+ const exec = context.io.exec;
43
+ if (!exec)
44
+ return null;
45
+ const packageSpec = context.command.updateTag
46
+ ? `@bli-cockpit/cli@${context.command.updateTag}`
47
+ : "@bli-cockpit/cli";
48
+ const result = await exec("npm", ["view", packageSpec, "version", "--json"]);
49
+ if (result.code !== 0)
50
+ return null;
51
+ return parseNpmVersion(result.stdout);
52
+ }
53
+ function parseNpmVersion(stdout) {
54
+ const trimmed = stdout.trim();
55
+ if (!trimmed)
56
+ return null;
57
+ try {
58
+ const parsed = JSON.parse(trimmed);
59
+ return typeof parsed === "string" && parsed.trim() ? parsed.trim() : null;
60
+ }
61
+ catch {
62
+ // Deliberately silent (BLI-3238). `npm view ... version` prints a bare
63
+ // `1.2.3` without `--json` and a quoted `"1.2.3"` with it; the parse is
64
+ // the test for which one this npm produced, and the unquoted fallback is
65
+ // the intended handling of the other form, not a failure.
66
+ return trimmed.replace(/^"|"$/gu, "") || null;
67
+ }
68
+ }
69
+ export function reexecDoctor(command, io) {
70
+ const args = ["do-everything"];
71
+ if (command.repoRoot)
72
+ args.push("--workspace", command.repoRoot);
73
+ if (command.dashboardUrl !== DEFAULT_DASHBOARD_URL) {
74
+ args.push("--dashboard-url", command.dashboardUrl);
75
+ }
76
+ if (command.updateTag)
77
+ args.push("--update-tag", command.updateTag);
78
+ if (command.json)
79
+ args.push("--json");
80
+ const exec = io.interactiveExec ?? createInteractiveExecRunner();
81
+ return exec("cockpit", args, {
82
+ env: {
83
+ ...process.env,
84
+ ...io.env,
85
+ COCKPIT_DOCTOR_REEXEC: "1",
86
+ },
87
+ }).then((result) => result.code);
88
+ }
89
+ function selfUpdateFailureCode(error) {
90
+ const record = asRecord(error);
91
+ if (record && record["eacces"] === true)
92
+ return "eacces_needs_chown";
93
+ return "npm_install_failed";
94
+ }
95
+ function selfUpdateFailureMessage(error) {
96
+ const record = asRecord(error);
97
+ const stderr = asRecord(record?.["result"])?.["stderr"] &&
98
+ typeof asRecord(record?.["result"])?.["stderr"] === "string"
99
+ ? String(asRecord(record?.["result"])?.["stderr"])
100
+ : "";
101
+ if (record?.["eacces"] === true) {
102
+ const prefix = npmPrefixFromError(stderr);
103
+ return [
104
+ "npm global install hit a permissions problem.",
105
+ "What you can do:",
106
+ ` 1) Fix npm ownership once: sudo chown -R $(whoami) ${prefix}/lib/node_modules/@bli-cockpit ${prefix}/bin/cockpit`,
107
+ " 2) No sudo? Send this output to Edward.",
108
+ " 3) Do not use `sudo npm i -g`; it makes the ownership problem come back.",
109
+ ].join("\n");
110
+ }
111
+ return "npm install failed; Tower CLI was not refreshed.";
112
+ }
113
+ function npmPrefixFromError(stderr) {
114
+ if (stderr.includes("/usr/local/"))
115
+ return "/usr/local";
116
+ if (stderr.includes("/opt/homebrew/"))
117
+ return "/opt/homebrew";
118
+ const nvm = stderr.match(/(\/Users\/[^/\s]+\/\.nvm\/versions\/node\/[^/\s]+)/u);
119
+ return nvm?.[1] ?? "/opt/homebrew";
120
+ }