@llamaventures/cli 1.8.0 → 1.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.
package/AGENT_BRIEFING.md CHANGED
@@ -11,6 +11,15 @@ You are not just an AI assistant. You're an **extension of a team member** — w
11
11
  - **Be direct, terse, action-oriented.** Save your words for the genuine judgment calls.
12
12
  - **Critical when thinking, helpful when executing.** Push back on weak logic, then ship the work cleanly.
13
13
 
14
+ ## Onboard the human (teach as you go)
15
+
16
+ Most teammates don't know everything this CLI can do. Part of your job is to surface capabilities — without turning into a feature brochure.
17
+
18
+ - **First substantive interaction:** in one or two lines, point at the 2-3 capabilities most relevant to what they're doing right now, then do the work. Don't dump the whole command surface. (Examples by intent: someone pasting deal info → "I'll split that into facts vs notes and file it"; someone with a write-up → the artifact decision tree below; someone exploring → `llama deal search` / `llama deal feed`.)
19
+ - **Teach in context, one line at a time.** When they do something that touches a feature they may not know, mention it once — e.g. after filing a fact: "Filed. `llama deal feed <id>` shows everything the team's added on this deal." Never more than one such aside per turn.
20
+ - **Point at `llama --help`** for the full surface rather than reciting it. The CLI uses progressive help: `llama --help` is a short overview, `llama <area> --help` drills in.
21
+ - **Stay current.** If you suspect the CLI is stale, run `llama version --check`; if it reports an upgrade, tell the user the one-line `npm i -g @llamaventures/cli@latest` command. Don't nag repeatedly.
22
+
14
23
  ## Pipeline First (hard rule)
15
24
 
16
25
  Any time the user mentions a company name or founder name:
package/bin/llama.mjs CHANGED
@@ -30,6 +30,7 @@ import {
30
30
  } from "../lib/external.mjs";
31
31
  import { LLAMA_CLI_CLIENT_ID, pkceLoopbackFlow, revokeToken as revokeOAuthToken } from "../lib/oauth-flow.mjs";
32
32
  import { deleteBundle, detectBackend, readBundle, writeBundle } from "../lib/oauth-storage.mjs";
33
+ import { maybeNudgeUpdate, getUpdateNudge } from "../lib/version-check.mjs";
33
34
 
34
35
  function parseFlags(args, knownFlags = null) {
35
36
  const flags = {};
@@ -763,6 +764,14 @@ async function main() {
763
764
  const { createRequire } = await import("module");
764
765
  const requireFromHere = createRequire(import.meta.url);
765
766
  const { version } = requireFromHere("../package.json");
767
+ // `llama version --check` — explicitly check npm for a newer release and
768
+ // print the upgrade line (or "up to date"). Lets an agent surface the
769
+ // nudge on demand, separate from the throttled, TTY-gated auto-nudge.
770
+ if (action === "--check" || action === "check") {
771
+ const nudge = await getUpdateNudge();
772
+ console.log(nudge || `llama CLI ${version} — up to date`);
773
+ return;
774
+ }
766
775
  console.log(version);
767
776
  return;
768
777
  }
@@ -2633,7 +2642,12 @@ Routing — is this the right command?
2633
2642
  process.exitCode = 1;
2634
2643
  }
2635
2644
 
2636
- main().catch((error) => {
2637
- console.error(`Error: ${error.message}`);
2638
- process.exit(1);
2639
- });
2645
+ main()
2646
+ // Soft, throttled, TTY-gated update nudge. Runs AFTER the command's own
2647
+ // output and is awaited so the registry check completes before exit — but
2648
+ // it can never fail the command (all errors swallowed internally).
2649
+ .then(() => maybeNudgeUpdate())
2650
+ .catch((error) => {
2651
+ console.error(`Error: ${error.message}`);
2652
+ process.exit(1);
2653
+ });
@@ -0,0 +1,118 @@
1
+ // Soft update nudge for @llamaventures/cli.
2
+ //
3
+ // Philosophy: minimal friction. We NEVER block a command and we NEVER spam.
4
+ // The npm registry is the source of truth for "latest published", so we
5
+ // query it directly — no llama-command changes, nothing to keep in sync.
6
+ //
7
+ // Friction controls, all of which must pass before we print anything:
8
+ // 1. TTY-gated — only nudge an interactive human (process.stdout.isTTY).
9
+ // MCP server / piped output / CI → silent, so agents and
10
+ // scripts never see noise that could corrupt parsed output.
11
+ // 2. Throttled — at most once per 24h, tracked by a timestamp file.
12
+ // 3. stderr only — the nudge never touches stdout, so `llama ... | jq` etc
13
+ // stay clean even in the rare case it does print.
14
+ // 4. Best-effort — every error path (offline, registry down, parse fail) is
15
+ // swallowed. A nudge must never break or delay a command.
16
+
17
+ import fs from "fs";
18
+ import path from "path";
19
+ import { createRequire } from "module";
20
+ import { TOKEN_DIR } from "./client.mjs";
21
+
22
+ const REGISTRY_URL = "https://registry.npmjs.org/@llamaventures/cli/latest";
23
+ const STAMP_FILE = path.join(TOKEN_DIR, ".update-check");
24
+ const THROTTLE_MS = 24 * 60 * 60 * 1000; // once per day
25
+ const FETCH_TIMEOUT_MS = 2000;
26
+
27
+ function installedVersion() {
28
+ try {
29
+ const requireFromHere = createRequire(import.meta.url);
30
+ return requireFromHere("../package.json").version;
31
+ } catch {
32
+ return null;
33
+ }
34
+ }
35
+
36
+ // Compare two semver strings. Returns true if `latest` is strictly newer than
37
+ // `current`. Pre-release tags are ignored (we only ship plain x.y.z).
38
+ function isNewer(latest, current) {
39
+ const a = String(latest).split(".").map((n) => parseInt(n, 10));
40
+ const b = String(current).split(".").map((n) => parseInt(n, 10));
41
+ for (let i = 0; i < 3; i++) {
42
+ const x = a[i] || 0;
43
+ const y = b[i] || 0;
44
+ if (x > y) return true;
45
+ if (x < y) return false;
46
+ }
47
+ return false;
48
+ }
49
+
50
+ function checkedRecently() {
51
+ try {
52
+ const last = parseInt(fs.readFileSync(STAMP_FILE, "utf8").trim(), 10);
53
+ return Number.isFinite(last) && Date.now() - last < THROTTLE_MS;
54
+ } catch {
55
+ return false;
56
+ }
57
+ }
58
+
59
+ function touchStamp() {
60
+ try {
61
+ fs.mkdirSync(TOKEN_DIR, { recursive: true, mode: 0o700 });
62
+ fs.writeFileSync(STAMP_FILE, `${Date.now()}\n`, { mode: 0o600 });
63
+ } catch {
64
+ // Best-effort. If we can't write the stamp we may nudge again tomorrow —
65
+ // harmless. Never throw.
66
+ }
67
+ }
68
+
69
+ async function fetchLatest() {
70
+ const controller = new AbortController();
71
+ const timer = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
72
+ try {
73
+ // The /latest convenience endpoint returns full JSON under the default
74
+ // Accept. (The abbreviated "vnd.npm.install-v1+json" metadata type is only
75
+ // valid on the full packument endpoint — it 406s here.)
76
+ const res = await fetch(REGISTRY_URL, { signal: controller.signal });
77
+ if (!res.ok) return null;
78
+ const data = await res.json();
79
+ return typeof data?.version === "string" ? data.version : null;
80
+ } catch {
81
+ return null;
82
+ } finally {
83
+ clearTimeout(timer);
84
+ }
85
+ }
86
+
87
+ /**
88
+ * Compute the nudge line without any side effects (no TTY/throttle gating).
89
+ * Returns the one-line string if an upgrade is available, else null. Used by
90
+ * the explicit `llama version --check` command so an agent can surface it.
91
+ */
92
+ export async function getUpdateNudge() {
93
+ const current = installedVersion();
94
+ if (!current) return null;
95
+ const latest = await fetchLatest();
96
+ if (!latest || !isNewer(latest, current)) return null;
97
+ return `⬆ llama CLI ${current} → ${latest} available · npm i -g @llamaventures/cli@latest`;
98
+ }
99
+
100
+ /**
101
+ * Fire-and-forget soft nudge for interactive humans. Safe to call without
102
+ * awaiting; resolves to true if it printed a nudge, false otherwise. Honors
103
+ * all four friction controls above. Set $LLAMA_NO_UPDATE_CHECK=1 to disable.
104
+ */
105
+ export async function maybeNudgeUpdate() {
106
+ try {
107
+ if (process.env.LLAMA_NO_UPDATE_CHECK) return false;
108
+ if (!process.stdout.isTTY) return false; // humans only
109
+ if (checkedRecently()) return false;
110
+ touchStamp(); // stamp before the network call so a slow/failed check still throttles
111
+ const nudge = await getUpdateNudge();
112
+ if (!nudge) return false;
113
+ process.stderr.write(`${nudge}\n`);
114
+ return true;
115
+ } catch {
116
+ return false;
117
+ }
118
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@llamaventures/cli",
3
- "version": "1.8.0",
3
+ "version": "1.9.0",
4
4
  "description": "CLI + MCP server for the Llama Ventures investment workbench (command.llamaventures.vc).",
5
5
  "type": "module",
6
6
  "bin": {