@grovehq/cli 0.38.4 → 0.39.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.
Files changed (2) hide show
  1. package/cli.cjs +324 -182
  2. package/package.json +1 -1
package/cli.cjs CHANGED
@@ -3331,87 +3331,14 @@ var require_commander = __commonJS({
3331
3331
  }
3332
3332
  });
3333
3333
 
3334
- // src/lib/install-method.ts
3335
- var import_node_fs2 = require("fs");
3336
- var import_node_path2 = require("path");
3337
-
3338
- // src/env.ts
3339
- var env = {
3340
- get GROVE_API_URL() {
3341
- return process.env["GROVE_API_URL"];
3342
- },
3343
- get PATH() {
3344
- return process.env["PATH"];
3345
- },
3346
- get GROVE_DIR() {
3347
- return process.env["GROVE_DIR"];
3348
- },
3349
- get WORKOS_BASE_URL() {
3350
- return process.env["WORKOS_BASE_URL"];
3351
- },
3352
- get WORKOS_CLIENT_ID() {
3353
- return process.env["WORKOS_CLIENT_ID"];
3354
- }
3355
- };
3356
-
3357
- // src/lib/config.ts
3358
- var import_node_fs = require("fs");
3359
- var import_node_os = require("os");
3360
- var import_node_path = require("path");
3361
- var GROVE_DIR = env.GROVE_DIR ?? (0, import_node_path.join)((0, import_node_os.homedir)(), ".grove");
3362
- var AUTH_FILE = (0, import_node_path.join)(GROVE_DIR, "auth.json");
3363
- var CONFIG_FILE = (0, import_node_path.join)(GROVE_DIR, "config.json");
3364
- var PRODUCTION_API_URL = "https://grovehq.app";
3365
- var DEFAULT_API_URL = PRODUCTION_API_URL;
3366
- var DEFAULT_WORKOS_BASE_URL = "https://api.workos.com";
3367
- var cachedConfig;
3368
- function readUserConfig() {
3369
- if (cachedConfig !== void 0) return cachedConfig;
3370
- try {
3371
- const raw = (0, import_node_fs.readFileSync)(CONFIG_FILE, "utf-8");
3372
- cachedConfig = JSON.parse(raw);
3373
- } catch {
3374
- cachedConfig = null;
3375
- }
3376
- return cachedConfig;
3377
- }
3378
- function getGroveDir() {
3379
- return GROVE_DIR;
3380
- }
3381
- function getAuthFilePath() {
3382
- return AUTH_FILE;
3383
- }
3384
- function getInstalledCliPath() {
3385
- return (0, import_node_path.join)(GROVE_DIR, "cli", "cli.cjs");
3386
- }
3387
- function ensureGroveDir() {
3388
- (0, import_node_fs.mkdirSync)(GROVE_DIR, { recursive: true, mode: 448 });
3389
- }
3390
- function getApiUrl() {
3391
- return env.GROVE_API_URL ?? readUserConfig()?.apiUrl ?? DEFAULT_API_URL;
3392
- }
3393
- function getClientId() {
3394
- const fromEnv = env.WORKOS_CLIENT_ID;
3395
- if (fromEnv) return fromEnv;
3396
- const fromConfig = readUserConfig()?.workosClientId;
3397
- if (fromConfig) return fromConfig;
3398
- throw new Error(
3399
- "WORKOS_CLIENT_ID is not set. Either re-run the install script or set the env var."
3400
- );
3401
- }
3402
- function setStoredClientId(clientId) {
3403
- const next = { ...readUserConfig() ?? {}, workosClientId: clientId };
3404
- ensureGroveDir();
3405
- (0, import_node_fs.writeFileSync)(CONFIG_FILE, `${JSON.stringify(next, null, 2)}
3406
- `, "utf-8");
3407
- cachedConfig = next;
3408
- }
3409
- function getStoredClientId() {
3410
- return readUserConfig()?.workosClientId ?? null;
3411
- }
3412
- function getWorkOSBaseUrl() {
3413
- return env.WORKOS_BASE_URL ?? readUserConfig()?.workosBaseUrl ?? DEFAULT_WORKOS_BASE_URL;
3414
- }
3334
+ // ../../packages/convex-backend-flow/src/convex/lib/constants.ts
3335
+ var ARCHIVE_PROJECT_JOB_CANCELS = 1;
3336
+ var ARCHIVE_PROJECT_WRITES = 2 + ARCHIVE_PROJECT_JOB_CANCELS;
3337
+ var TOUCHED_RECENTLY_MS = 7 * 24 * 60 * 60 * 1e3;
3338
+ var MAX_FILE_BYTES = 1e8;
3339
+ var MAX_FILES_PER_POST = 10;
3340
+ var SESSION_WINDOW_MS = 5 * 60 * 60 * 1e3;
3341
+ var WEEKLY_WINDOW_MS = 7 * 24 * 60 * 60 * 1e3;
3415
3342
 
3416
3343
  // src/lib/output.ts
3417
3344
  var import_promises = require("readline/promises");
@@ -3447,62 +3374,10 @@ function success(message) {
3447
3374
  console.log(`\u2713 ${message}`);
3448
3375
  }
3449
3376
 
3450
- // src/lib/install-method.ts
3451
- var NPM_PACKAGE = "@grovehq/cli";
3452
- function realPath(path) {
3453
- try {
3454
- return (0, import_node_fs2.realpathSync)(path).replaceAll("\\", "/");
3455
- } catch {
3456
- return path.replaceAll("\\", "/");
3457
- }
3458
- }
3459
- function isNpmPackagePath(path) {
3460
- return realPath(path).includes(`/node_modules/${NPM_PACKAGE}/`);
3461
- }
3462
- function detectInstallMethod(entry = process.argv[1] ?? "") {
3463
- if (!isNpmPackagePath(entry)) return "script";
3464
- return realPath(entry).includes("/_npx/") ? "npx" : "npm";
3465
- }
3466
- function upgradeCommandFor(method = detectInstallMethod()) {
3467
- switch (method) {
3468
- case "npm":
3469
- return `npm install -g ${NPM_PACKAGE}@latest`;
3470
- case "npx":
3471
- return `npx ${NPM_PACKAGE}@latest`;
3472
- case "script":
3473
- return "grove upgrade";
3474
- }
3475
- }
3476
- function findNpmCopyOnPath(pathEnv = env.PATH ?? "") {
3477
- for (const dir of pathEnv.split(import_node_path2.delimiter)) {
3478
- if (!dir) continue;
3479
- const candidate = (0, import_node_path2.join)(dir, "grove");
3480
- if ((0, import_node_fs2.existsSync)(candidate) && isNpmPackagePath(candidate)) return candidate;
3481
- }
3482
- return null;
3483
- }
3484
- function warnIfShadowingNpmCopy(entry = process.argv[1] ?? "") {
3485
- if (!isStdoutTTY()) return;
3486
- if (realPath(entry) !== realPath(getInstalledCliPath())) return;
3487
- if (findNpmCopyOnPath() === null) return;
3488
- const dir = getGroveDir();
3489
- console.error(
3490
- `\u26A0 This is the grove the install script put in ${dir}, and an npm-installed grove is also on this machine. To use the npm one, delete ${(0, import_node_path2.join)(dir, "bin")} and ${(0, import_node_path2.join)(dir, "cli")}. Your sign-in and settings stay.`
3491
- );
3492
- }
3493
-
3494
- // ../../packages/convex-backend-flow/src/convex/lib/constants.ts
3495
- var ARCHIVE_PROJECT_JOB_CANCELS = 1;
3496
- var ARCHIVE_PROJECT_WRITES = 2 + ARCHIVE_PROJECT_JOB_CANCELS;
3497
- var TOUCHED_RECENTLY_MS = 7 * 24 * 60 * 60 * 1e3;
3498
- var MAX_FILE_BYTES = 1e8;
3499
- var MAX_FILES_PER_POST = 10;
3500
- var SESSION_WINDOW_MS = 5 * 60 * 60 * 1e3;
3501
- var WEEKLY_WINDOW_MS = 7 * 24 * 60 * 60 * 1e3;
3502
-
3503
3377
  // src/commands/help.ts
3504
3378
  var EDIT_OR_COMMENT_POINTER = " `grove project view <P-NNN>` states when to comment, not write.";
3505
3379
  var ARTIFACT_KIND_GUIDANCE = "A document \u2014 A Scratchpad document holds what the work turned up: a write-up, what an investigation found, the material a decision was made against. Outcomes belong in the summary; the rules the work is built and tested against belong in Requirements. A note whose subject is technical is still a Scratchpad document. Customer context, research, discovery inputs and anything that informs more than one project belong in the feature's Scratchpad; what serves one project belongs in that project's. The name is the title readers see. Grove mints the file's slug from it. The name is an input, not a heading: the content starts at the body. A visual \u2014 A visual is one self-contained HTML file: inline script and style, images and fonts as `data:` URIs, nothing fetched over the network. Link to anything; embed nothing remote. It is read at a narrow width as well as a wide one. The name is the title readers see. Grove mints the file's slug from it.";
3380
+ var FINDER_MISS_FLAG = "--finder-miss Mark it as a finder miss: an issue Grove's finders should have flagged in the plan. Only when the developer asks";
3506
3381
  var COMMANDS = [
3507
3382
  {
3508
3383
  name: "login",
@@ -3732,7 +3607,8 @@ var COMMANDS = [
3732
3607
  "--attach <path> A file to attach, under 100 MB; repeat for up to " + MAX_FILES_PER_POST + ". The post still needs --message",
3733
3608
  '--also-on <json> Further places the same point is about, as a JSON list: each names a project ("stableId") or a feature ("featureSlug") plus optional "documentName", "quote", "quoteBefore", "quoteAfter". One thread points at all of them',
3734
3609
  '--target <target> the subject as a whole (default \u2014 "project" or "feature", matching which you named), document or passage; implied by --document / --quote, so pass it only to be explicit',
3735
- "--agent <label> Your own name as the composing agent; omit only if they typed it (never blank)"
3610
+ "--agent <label> Your own name as the composing agent; omit only if they typed it (never blank)",
3611
+ FINDER_MISS_FLAG
3736
3612
  ],
3737
3613
  related: ["thread list", "thread show", "project view", "project list"]
3738
3614
  },
@@ -3782,6 +3658,20 @@ var COMMANDS = [
3782
3658
  description: "Usage: grove thread reopen <threadId>. Moves a resolved thread back to open and clears who resolved it and when. It posts nothing, and a reply never reopens a thread, so this is how one comes back. Reopen only when the developer asks; if they gave a reason, post it first with `grove thread reply`, then reopen. Reopening an already-open thread succeeds and changes nothing, so re-running is always safe. The thread id is the one the raise or `grove thread list` reported, and it is the whole address. Not interactive.",
3783
3659
  related: ["thread reply", "thread resolve", "thread show"]
3784
3660
  },
3661
+ {
3662
+ name: "thread mark-finder-miss",
3663
+ summary: "Mark a thread as one Grove's finders missed.",
3664
+ description: "Usage: grove thread mark-finder-miss <threadId> [--agent <label>]. A finder miss is an issue Grove's finders should have flagged in the plan. Mark one only when the developer asks; `grove thread raise --finder-miss` marks a thread as it is raised.",
3665
+ flags: ["--agent <label> Your own name as the agent marking it; omit only if the developer runs this command themselves (never blank)"],
3666
+ related: ["thread unmark-finder-miss", "thread raise"]
3667
+ },
3668
+ {
3669
+ name: "thread unmark-finder-miss",
3670
+ summary: "Clear a finder-miss mark from a thread.",
3671
+ description: "Usage: grove thread unmark-finder-miss <threadId> [--agent <label>]. Clears the mark `grove thread mark-finder-miss` set. Only when the developer asks.",
3672
+ flags: ["--agent <label> Your own name as the agent unmarking it; omit only if the developer runs this command themselves (never blank)"],
3673
+ related: ["thread mark-finder-miss"]
3674
+ },
3785
3675
  {
3786
3676
  name: "feature list",
3787
3677
  summary: "List every feature you can see, with its status and projects.",
@@ -3843,8 +3733,16 @@ var logCommandsEnabled = true;
3843
3733
  function setLogCommandsEnabled(enabled) {
3844
3734
  logCommandsEnabled = enabled;
3845
3735
  }
3736
+ var finderMissEnabled = true;
3737
+ function setFinderMissEnabled(enabled) {
3738
+ finderMissEnabled = enabled;
3739
+ }
3740
+ function withoutFinderMiss(commands) {
3741
+ return commands.filter((c) => c.name !== "thread mark-finder-miss" && c.name !== "thread unmark-finder-miss").map((c) => c.flags?.includes(FINDER_MISS_FLAG) ? { ...c, flags: c.flags.filter((f) => f !== FINDER_MISS_FLAG) } : c);
3742
+ }
3846
3743
  function visibleCommands() {
3847
- return logCommandsEnabled ? COMMANDS : COMMANDS.filter((c) => c.name !== "log" && !c.name.startsWith("log "));
3744
+ const commands = logCommandsEnabled ? COMMANDS : COMMANDS.filter((c) => c.name !== "log" && !c.name.startsWith("log "));
3745
+ return finderMissEnabled ? commands : withoutFinderMiss(commands);
3848
3746
  }
3849
3747
  function byName(name) {
3850
3748
  return visibleCommands().find((c) => c.name === name);
@@ -3925,8 +3823,90 @@ function unknownCommand(name) {
3925
3823
 
3926
3824
  // src/lib/auth.ts
3927
3825
  var import_node_crypto = require("crypto");
3928
- var import_node_fs3 = require("fs");
3826
+ var import_node_fs2 = require("fs");
3929
3827
  var import_node_http = require("http");
3828
+
3829
+ // src/lib/config.ts
3830
+ var import_node_fs = require("fs");
3831
+ var import_node_os = require("os");
3832
+ var import_node_path = require("path");
3833
+
3834
+ // src/env.ts
3835
+ var env = {
3836
+ get GROVE_API_URL() {
3837
+ return process.env["GROVE_API_URL"];
3838
+ },
3839
+ get PATH() {
3840
+ return process.env["PATH"];
3841
+ },
3842
+ get GROVE_DIR() {
3843
+ return process.env["GROVE_DIR"];
3844
+ },
3845
+ get WORKOS_BASE_URL() {
3846
+ return process.env["WORKOS_BASE_URL"];
3847
+ },
3848
+ get WORKOS_CLIENT_ID() {
3849
+ return process.env["WORKOS_CLIENT_ID"];
3850
+ }
3851
+ };
3852
+
3853
+ // src/lib/config.ts
3854
+ var GROVE_DIR = env.GROVE_DIR ?? (0, import_node_path.join)((0, import_node_os.homedir)(), ".grove");
3855
+ var AUTH_FILE = (0, import_node_path.join)(GROVE_DIR, "auth.json");
3856
+ var CONFIG_FILE = (0, import_node_path.join)(GROVE_DIR, "config.json");
3857
+ var PRODUCTION_API_URL = "https://grovehq.app";
3858
+ var DEFAULT_API_URL = PRODUCTION_API_URL;
3859
+ var DEFAULT_WORKOS_BASE_URL = "https://api.workos.com";
3860
+ var cachedConfig;
3861
+ function readUserConfig() {
3862
+ if (cachedConfig !== void 0) return cachedConfig;
3863
+ try {
3864
+ const raw = (0, import_node_fs.readFileSync)(CONFIG_FILE, "utf-8");
3865
+ cachedConfig = JSON.parse(raw);
3866
+ } catch {
3867
+ cachedConfig = null;
3868
+ }
3869
+ return cachedConfig;
3870
+ }
3871
+ function getGroveDir() {
3872
+ return GROVE_DIR;
3873
+ }
3874
+ function getAuthFilePath() {
3875
+ return AUTH_FILE;
3876
+ }
3877
+ function getInstalledCliPath() {
3878
+ return (0, import_node_path.join)(GROVE_DIR, "cli", "cli.cjs");
3879
+ }
3880
+ function ensureGroveDir() {
3881
+ (0, import_node_fs.mkdirSync)(GROVE_DIR, { recursive: true, mode: 448 });
3882
+ }
3883
+ function getApiUrl() {
3884
+ return env.GROVE_API_URL ?? readUserConfig()?.apiUrl ?? DEFAULT_API_URL;
3885
+ }
3886
+ function getClientId() {
3887
+ const fromEnv = env.WORKOS_CLIENT_ID;
3888
+ if (fromEnv) return fromEnv;
3889
+ const fromConfig = readUserConfig()?.workosClientId;
3890
+ if (fromConfig) return fromConfig;
3891
+ throw new Error(
3892
+ "WORKOS_CLIENT_ID is not set. Either re-run the install script or set the env var."
3893
+ );
3894
+ }
3895
+ function setStoredClientId(clientId) {
3896
+ const next = { ...readUserConfig() ?? {}, workosClientId: clientId };
3897
+ ensureGroveDir();
3898
+ (0, import_node_fs.writeFileSync)(CONFIG_FILE, `${JSON.stringify(next, null, 2)}
3899
+ `, "utf-8");
3900
+ cachedConfig = next;
3901
+ }
3902
+ function getStoredClientId() {
3903
+ return readUserConfig()?.workosClientId ?? null;
3904
+ }
3905
+ function getWorkOSBaseUrl() {
3906
+ return env.WORKOS_BASE_URL ?? readUserConfig()?.workosBaseUrl ?? DEFAULT_WORKOS_BASE_URL;
3907
+ }
3908
+
3909
+ // src/lib/auth.ts
3930
3910
  var AUTHENTICATE_PATH = "/user_management/authenticate";
3931
3911
  var DEFAULT_TOKEN_EXPIRY_SECONDS = 300;
3932
3912
  var AUTH_TIMEOUT_MS = 12e4;
@@ -3965,7 +3945,7 @@ function isStoredAuth(value) {
3965
3945
  }
3966
3946
  function loadAuth() {
3967
3947
  try {
3968
- const parsed = JSON.parse((0, import_node_fs3.readFileSync)(getAuthFilePath(), "utf-8"));
3948
+ const parsed = JSON.parse((0, import_node_fs2.readFileSync)(getAuthFilePath(), "utf-8"));
3969
3949
  return isStoredAuth(parsed) ? parsed : null;
3970
3950
  } catch {
3971
3951
  return null;
@@ -3974,12 +3954,12 @@ function loadAuth() {
3974
3954
  function saveAuth(auth) {
3975
3955
  ensureGroveDir();
3976
3956
  const path = getAuthFilePath();
3977
- (0, import_node_fs3.writeFileSync)(path, JSON.stringify(auth, null, 2), "utf-8");
3978
- (0, import_node_fs3.chmodSync)(path, 384);
3957
+ (0, import_node_fs2.writeFileSync)(path, JSON.stringify(auth, null, 2), "utf-8");
3958
+ (0, import_node_fs2.chmodSync)(path, 384);
3979
3959
  }
3980
3960
  function clearAuth() {
3981
3961
  try {
3982
- (0, import_node_fs3.unlinkSync)(getAuthFilePath());
3962
+ (0, import_node_fs2.unlinkSync)(getAuthFilePath());
3983
3963
  } catch {
3984
3964
  }
3985
3965
  }
@@ -4191,6 +4171,52 @@ function buildAuthorizeUrl(redirectUri, codeChallenge, state) {
4191
4171
  return `${getWorkOSBaseUrl()}/user_management/authorize?${params.toString()}`;
4192
4172
  }
4193
4173
 
4174
+ // src/lib/install-method.ts
4175
+ var import_node_fs3 = require("fs");
4176
+ var import_node_path2 = require("path");
4177
+ var NPM_PACKAGE = "@grovehq/cli";
4178
+ function realPath(path) {
4179
+ try {
4180
+ return (0, import_node_fs3.realpathSync)(path).replaceAll("\\", "/");
4181
+ } catch {
4182
+ return path.replaceAll("\\", "/");
4183
+ }
4184
+ }
4185
+ function isNpmPackagePath(path) {
4186
+ return realPath(path).includes(`/node_modules/${NPM_PACKAGE}/`);
4187
+ }
4188
+ function detectInstallMethod(entry = process.argv[1] ?? "") {
4189
+ if (!isNpmPackagePath(entry)) return "script";
4190
+ return realPath(entry).includes("/_npx/") ? "npx" : "npm";
4191
+ }
4192
+ function upgradeCommandFor(method = detectInstallMethod()) {
4193
+ switch (method) {
4194
+ case "npm":
4195
+ return `npm install -g ${NPM_PACKAGE}@latest`;
4196
+ case "npx":
4197
+ return `npx ${NPM_PACKAGE}@latest`;
4198
+ case "script":
4199
+ return "grove upgrade";
4200
+ }
4201
+ }
4202
+ function findNpmCopyOnPath(pathEnv = env.PATH ?? "") {
4203
+ for (const dir of pathEnv.split(import_node_path2.delimiter)) {
4204
+ if (!dir) continue;
4205
+ const candidate = (0, import_node_path2.join)(dir, "grove");
4206
+ if ((0, import_node_fs3.existsSync)(candidate) && isNpmPackagePath(candidate)) return candidate;
4207
+ }
4208
+ return null;
4209
+ }
4210
+ function warnIfShadowingNpmCopy(entry = process.argv[1] ?? "") {
4211
+ if (!isStdoutTTY()) return;
4212
+ if (realPath(entry) !== realPath(getInstalledCliPath())) return;
4213
+ if (findNpmCopyOnPath() === null) return;
4214
+ const dir = getGroveDir();
4215
+ console.error(
4216
+ `\u26A0 This is the grove the install script put in ${dir}, and an npm-installed grove is also on this machine. To use the npm one, delete ${(0, import_node_path2.join)(dir, "bin")} and ${(0, import_node_path2.join)(dir, "cli")}. Your sign-in and settings stay.`
4217
+ );
4218
+ }
4219
+
4194
4220
  // src/lib/cli-release.ts
4195
4221
  var FLOOR_TIMEOUT_MS = 3e3;
4196
4222
  async function fetchCompatFloor(signal) {
@@ -4234,7 +4260,7 @@ async function fetchNpmLatest(signal) {
4234
4260
  }
4235
4261
 
4236
4262
  // src/lib/version.ts
4237
- var CLI_VERSION = true ? "0.38.4" : "0.0.0-dev";
4263
+ var CLI_VERSION = true ? "0.39.0" : "0.0.0-dev";
4238
4264
  function compareSemver(a, b) {
4239
4265
  const parse = (v) => (v.split("-")[0] ?? v).split(".").map((n) => Number.parseInt(n, 10) || 0);
4240
4266
  const pa = parse(a);
@@ -4330,6 +4356,7 @@ function isPreflightFailure(err) {
4330
4356
  }
4331
4357
  var REQUEST_TIMEOUT_MS = 9e4;
4332
4358
  var AGENT_ACTIVITY_LOG_CHECK_TIMEOUT_MS = 5e3;
4359
+ var FINDER_FEEDBACK_CHECK_TIMEOUT_MS = 5e3;
4333
4360
  var DOWNLOAD_TIMEOUT_MS = 15 * 6e4;
4334
4361
  function send(path, init, accessToken, timeoutMs = REQUEST_TIMEOUT_MS) {
4335
4362
  return fetch(`${getApiUrl()}${path}`, {
@@ -5007,6 +5034,20 @@ var api = {
5007
5034
  `/api/grove/features/${encodeURIComponent(initiativeSlug)}/threads`
5008
5035
  );
5009
5036
  },
5037
+ /** Whether the signed-in person has finder feedback — gates the finder-miss flag and commands. */
5038
+ getFinderFeedbackEnabled() {
5039
+ return request("/api/grove/finder-feedback/enabled", {
5040
+ signal: AbortSignal.timeout(FINDER_FEEDBACK_CHECK_TIMEOUT_MS)
5041
+ });
5042
+ },
5043
+ /** Mark or unmark a thread as one Grove's finders missed. Idempotent either way. */
5044
+ setFinderMiss(input) {
5045
+ const { threadId, ...body } = input;
5046
+ return request(
5047
+ `/api/grove/threads/${encodeURIComponent(threadId)}/finder-miss`,
5048
+ { method: "PATCH", body: JSON.stringify(body) }
5049
+ );
5050
+ },
5010
5051
  /** Whether the signed-in org's agent activity log flag is on — checked
5011
5052
  * live since the CLI has no offline signal for it. */
5012
5053
  getAgentActivityLogEnabled() {
@@ -5082,44 +5123,6 @@ var api = {
5082
5123
  }
5083
5124
  };
5084
5125
 
5085
- // src/lib/agent-activity-log-capability.ts
5086
- async function agentActivityLogEnabled() {
5087
- try {
5088
- const { data } = await api.getAgentActivityLogEnabled();
5089
- return data.enabled;
5090
- } catch (err) {
5091
- if (isPreflightFailure(err)) throw err;
5092
- return false;
5093
- }
5094
- }
5095
-
5096
- // src/lib/log-gate.ts
5097
- function touchesLog(argv) {
5098
- if (argv[0] === "log") return true;
5099
- if (argv[0] === "--help" || argv[0] === "-h") return true;
5100
- return argv[0] === "help" && (argv.length <= 1 || argv[1] === "log" || argv[1]?.startsWith("log ") === true);
5101
- }
5102
- async function gateLogCommands(argv) {
5103
- if (!touchesLog(argv)) return true;
5104
- let enabled;
5105
- try {
5106
- enabled = await agentActivityLogEnabled();
5107
- } catch (err) {
5108
- if (argv[0] === "log" && isPreflightFailure(err)) {
5109
- handleCommandError(err);
5110
- return false;
5111
- }
5112
- setLogCommandsEnabled(false);
5113
- return true;
5114
- }
5115
- setLogCommandsEnabled(enabled);
5116
- if (!enabled && argv[0] === "log") {
5117
- unknownCommand("log");
5118
- return false;
5119
- }
5120
- return true;
5121
- }
5122
-
5123
5126
  // ../../node_modules/.pnpm/commander@13.1.0/node_modules/commander/esm.mjs
5124
5127
  var import_index = __toESM(require_commander(), 1);
5125
5128
  var {
@@ -5877,6 +5880,17 @@ async function listActivityLogCommand(stableId, opts = {}) {
5877
5880
  }
5878
5881
  }
5879
5882
 
5883
+ // src/lib/agent-activity-log-capability.ts
5884
+ async function agentActivityLogEnabled() {
5885
+ try {
5886
+ const { data } = await api.getAgentActivityLogEnabled();
5887
+ return data.enabled;
5888
+ } catch (err) {
5889
+ if (isPreflightFailure(err)) throw err;
5890
+ return false;
5891
+ }
5892
+ }
5893
+
5880
5894
  // src/lib/log-nudge.ts
5881
5895
  async function logNudgesEnabled() {
5882
5896
  try {
@@ -7986,6 +8000,41 @@ async function downloadAttachmentCommand(threadId, attachmentId, opts) {
7986
8000
  }
7987
8001
  }
7988
8002
 
8003
+ // src/commands/thread/finder-miss.ts
8004
+ async function setFinderMissCommand(thread2, marked, opts) {
8005
+ const threadId = thread2?.trim() ?? "";
8006
+ if (threadId === "") {
8007
+ error("Name the thread as the first argument, as `grove thread raise` or `grove thread list` reported it. Nothing was changed.");
8008
+ process.exitCode = 1;
8009
+ return;
8010
+ }
8011
+ const agentLabel = opts.agent?.trim();
8012
+ if (agentLabel === "") {
8013
+ error("Blank --agent: pass your own name as the agent, or omit the flag only if the developer is running this command themselves. Nothing was changed.");
8014
+ process.exitCode = 1;
8015
+ return;
8016
+ }
8017
+ try {
8018
+ const { data } = await api.setFinderMiss({ threadId, marked, ...agentLabel === void 0 ? {} : { agentLabel } });
8019
+ info(marked ? `Marked. Thread ${data.threadId} is recorded as one Grove's finders missed.` : `Unmarked. Thread ${data.threadId} is no longer recorded as a finder miss.`);
8020
+ } catch (err) {
8021
+ if (isPreflightFailure(err)) {
8022
+ handleCommandError(err);
8023
+ error("Nothing was changed. After fixing the above, re-run the same command.");
8024
+ return;
8025
+ }
8026
+ const detail = err instanceof ApiError ? err.message : err instanceof Error ? err.message : String(err);
8027
+ if (err instanceof ApiError && isSettledRejection(err.status)) {
8028
+ error(`Rejected: ${detail}`);
8029
+ if (err.hint) error(err.hint);
8030
+ } else {
8031
+ error(`Failed to reach Grove: ${detail}`);
8032
+ error("Whether it landed is UNKNOWN. It is safe to re-run the same command unchanged.");
8033
+ }
8034
+ process.exitCode = 1;
8035
+ }
8036
+ }
8037
+
7989
8038
  // src/commands/thread/list.ts
7990
8039
  var INDENT4 = " ";
7991
8040
  var CELL_SEPARATOR3 = " ";
@@ -8310,6 +8359,7 @@ async function raiseThreadCommand(stableId, opts) {
8310
8359
  // convention, not a second field.
8311
8360
  text: message,
8312
8361
  ...agentLabel === void 0 ? {} : { agentLabel },
8362
+ ...opts.finderMiss === true ? { finderMiss: true } : {},
8313
8363
  // A bare `--document requirements.md` implies the document target, because
8314
8364
  // naming a document and then having to say a second time that the thread is
8315
8365
  // about a document is a step with no decision in it. Spelling `--target`
@@ -8376,6 +8426,7 @@ async function raiseOnInitiative(initiativeSlug, message, agentLabel, opts, also
8376
8426
  initiativeSlug,
8377
8427
  text: message,
8378
8428
  ...agentLabel === void 0 ? {} : { agentLabel },
8429
+ ...opts.finderMiss === true ? { finderMiss: true } : {},
8379
8430
  // An omitted --document/--quote send no target — the server reads that
8380
8431
  // as the initiative as a whole, same as an omitted target on a project.
8381
8432
  ...target === void 0 ? quote !== void 0 ? { target: "passage" } : documentName === void 0 ? {} : { target: "document" } : { target },
@@ -9107,7 +9158,7 @@ featureOption(
9107
9158
  thread.command("raise [stableId]").description("Raise a thread on a project or a feature \u2014 by the project stable ID (P-NNN), or --feature <slug>. Never both, never neither").requiredOption("--message <text>", "The point being raised \u2014 markdown, any length, never abbreviated").option("--agent <label>", "Your own name as the agent that composed it; omit ONLY if the developer typed the post themselves"),
9108
9159
  "slug",
9109
9160
  "A feature's slug, exactly as `grove feature list` prints it \u2014 raises on that feature instead of a project"
9110
- ).option("--document <name>", "One of the subject's documents, named as you read it (requirements.md) \u2014 the thread is about that document in its entirety; omit for the subject as a whole").option("--quote <text>", "The passage's words as the document renders them, not the markdown source \u2014 the thread is about that passage; requires --document. Refused unless the text appears in the document exactly once").option("--quote-before <text>", "The document's own text immediately before the quote, as it renders \u2014 pass it when the quote may appear more than once, to say which occurrence you mean").option("--quote-after <text>", "The document's own text immediately after the quote, as it renders \u2014 the companion to --quote-before; either or both").option("--target <target>", 'What the thread is about: the subject as a whole (the default \u2014 "project" or "feature", matching which you named), document or passage. Implied by --document and --quote, so pass it only to be explicit').option("--attach <path>", "A file to attach to the opening post, under 100 MB; repeat for several. The post still needs --message", collectValue, []).option("--also-on <json>", 'Further places the same point is about, as a JSON list: each names a project ("stableId") or a feature ("featureSlug") plus optional "documentName", "quote", "quoteBefore", "quoteAfter". One thread points at all of them').configureHelp({ formatHelp: () => formatHelp("thread raise") }).action(async (stableId, opts) => {
9161
+ ).option("--document <name>", "One of the subject's documents, named as you read it (requirements.md) \u2014 the thread is about that document in its entirety; omit for the subject as a whole").option("--quote <text>", "The passage's words as the document renders them, not the markdown source \u2014 the thread is about that passage; requires --document. Refused unless the text appears in the document exactly once").option("--quote-before <text>", "The document's own text immediately before the quote, as it renders \u2014 pass it when the quote may appear more than once, to say which occurrence you mean").option("--quote-after <text>", "The document's own text immediately after the quote, as it renders \u2014 the companion to --quote-before; either or both").option("--target <target>", 'What the thread is about: the subject as a whole (the default \u2014 "project" or "feature", matching which you named), document or passage. Implied by --document and --quote, so pass it only to be explicit').option("--attach <path>", "A file to attach to the opening post, under 100 MB; repeat for several. The post still needs --message", collectValue, []).option("--also-on <json>", 'Further places the same point is about, as a JSON list: each names a project ("stableId") or a feature ("featureSlug") plus optional "documentName", "quote", "quoteBefore", "quoteAfter". One thread points at all of them').option("--finder-miss", "Mark the thread as one Grove's finders missed. Only when the developer asks").configureHelp({ formatHelp: () => formatHelp("thread raise") }).action(async (stableId, opts) => {
9111
9162
  await raiseThreadCommand(stableId, readFeatureOption(opts));
9112
9163
  });
9113
9164
  thread.command("reply <threadId>").description("Reply in a thread \u2014 append a post").option("--message <text>", "The reply \u2014 markdown, any length, never abbreviated; may be omitted when --attach is given").option("--attach <path>", "A file to attach, under 100 MB; repeat for several", collectValue, []).option("--agent <label>", "Your own name as the agent that composed it; omit ONLY if the developer typed the reply themselves").configureHelp({ formatHelp: () => formatHelp("thread reply") }).action(async (threadId, opts) => {
@@ -9119,6 +9170,12 @@ thread.command("resolve <threadId>").alias("settle").description("Resolve a thre
9119
9170
  thread.command("reopen <threadId>").description("Reopen a resolved thread, posting nothing").configureHelp({ formatHelp: () => formatHelp("thread reopen") }).action(async (threadId) => {
9120
9171
  await reopenThreadCommand(threadId);
9121
9172
  });
9173
+ thread.command("mark-finder-miss <threadId>").description("Mark a thread as one Grove's finders missed").option("--agent <label>", "Your own name as the agent marking it; omit ONLY if the developer runs this command themselves").configureHelp({ formatHelp: () => formatHelp("thread mark-finder-miss") }).action(async (threadId, opts) => {
9174
+ await setFinderMissCommand(threadId, true, opts);
9175
+ });
9176
+ thread.command("unmark-finder-miss <threadId>").description("Clear a finder-miss mark from a thread").option("--agent <label>", "Your own name as the agent unmarking it; omit ONLY if the developer runs this command themselves").configureHelp({ formatHelp: () => formatHelp("thread unmark-finder-miss") }).action(async (threadId, opts) => {
9177
+ await setFinderMissCommand(threadId, false, opts);
9178
+ });
9122
9179
  var initiative = program2.command("feature").alias("initiative").description("List features, and create the one a project lives in").configureHelp({ formatHelp: () => formatHelp("feature") });
9123
9180
  initiative.command("list").description("List every feature you can see, with its status and projects").option("--status <status>", "Filter by status: unplanned, planning, building, built (repeatable)", collectValue, []).option("--priority <priority>", "Filter by priority: urgent, high, medium, low, none (repeatable)", collectValue, []).configureHelp({ formatHelp: () => formatHelp("feature list") }).action(async (opts) => {
9124
9181
  await listInitiativesCommand(opts);
@@ -9142,10 +9199,95 @@ program2.command("help [command...]").description("Show help").action((words) =>
9142
9199
  helpCommand(words.join(" ") || void 0);
9143
9200
  });
9144
9201
 
9202
+ // src/lib/finder-miss-gate.ts
9203
+ var MISS_VERBS = /* @__PURE__ */ new Set(["mark-finder-miss", "unmark-finder-miss"]);
9204
+ var HELP_FLAGS = /* @__PURE__ */ new Set(["--help", "-h"]);
9205
+ function usesFinderMiss(argv) {
9206
+ const [noun, verb] = argv;
9207
+ if (noun !== "thread" || verb === void 0) return false;
9208
+ return MISS_VERBS.has(verb) || verb === "raise" && raisePassesFinderMiss(argv.slice(2));
9209
+ }
9210
+ function raisePassesFinderMiss(args) {
9211
+ const raise = program2.commands.find((cmd) => cmd.name() === "thread")?.commands.find((cmd) => cmd.name() === "raise");
9212
+ const takesValue = new Set(raise?.options.filter((option) => option.required).map((option) => option.long));
9213
+ for (let i = 0; i < args.length; i++) {
9214
+ const arg = args[i];
9215
+ if (arg === "--") return false;
9216
+ if (arg === "--finder-miss") return true;
9217
+ if (takesValue.has(arg)) i++;
9218
+ }
9219
+ return false;
9220
+ }
9221
+ function touchesFinderMiss(argv) {
9222
+ const [noun, verb] = argv;
9223
+ if (usesFinderMiss(argv)) return true;
9224
+ if (noun !== void 0 && HELP_FLAGS.has(noun)) return true;
9225
+ if (noun === "help") return verb === void 0 || verb === "thread" || verb.startsWith("thread ");
9226
+ if (noun !== "thread") return false;
9227
+ return verb === void 0 || HELP_FLAGS.has(verb) || verb === "raise" && argv.some((arg) => HELP_FLAGS.has(arg));
9228
+ }
9229
+ function refuseUnavailable(argv) {
9230
+ const verb = argv[1];
9231
+ if (MISS_VERBS.has(verb)) {
9232
+ unknownCommand(`thread ${verb}`);
9233
+ return;
9234
+ }
9235
+ error("error: unknown option '--finder-miss'");
9236
+ process.exitCode = 1;
9237
+ }
9238
+ async function gateFinderMiss(argv) {
9239
+ if (!touchesFinderMiss(argv)) return true;
9240
+ let enabled;
9241
+ try {
9242
+ enabled = (await api.getFinderFeedbackEnabled()).data.enabled;
9243
+ } catch (err) {
9244
+ if (isPreflightFailure(err) && usesFinderMiss(argv)) {
9245
+ handleCommandError(err);
9246
+ return false;
9247
+ }
9248
+ enabled = false;
9249
+ }
9250
+ setFinderMissEnabled(enabled);
9251
+ if (!enabled && usesFinderMiss(argv)) {
9252
+ refuseUnavailable(argv);
9253
+ return false;
9254
+ }
9255
+ return true;
9256
+ }
9257
+
9258
+ // src/lib/log-gate.ts
9259
+ function touchesLog(argv) {
9260
+ if (argv[0] === "log") return true;
9261
+ if (argv[0] === "--help" || argv[0] === "-h") return true;
9262
+ return argv[0] === "help" && (argv.length <= 1 || argv[1] === "log" || argv[1]?.startsWith("log ") === true);
9263
+ }
9264
+ async function gateLogCommands(argv) {
9265
+ if (!touchesLog(argv)) return true;
9266
+ let enabled;
9267
+ try {
9268
+ enabled = await agentActivityLogEnabled();
9269
+ } catch (err) {
9270
+ if (argv[0] === "log" && isPreflightFailure(err)) {
9271
+ handleCommandError(err);
9272
+ return false;
9273
+ }
9274
+ setLogCommandsEnabled(false);
9275
+ return true;
9276
+ }
9277
+ setLogCommandsEnabled(enabled);
9278
+ if (!enabled && argv[0] === "log") {
9279
+ unknownCommand("log");
9280
+ return false;
9281
+ }
9282
+ return true;
9283
+ }
9284
+
9145
9285
  // src/cli.ts
9146
9286
  async function main() {
9147
9287
  warnIfShadowingNpmCopy();
9148
- if (await gateLogCommands(process.argv.slice(2))) {
9288
+ const argv = process.argv.slice(2);
9289
+ const [logOk, finderMissOk] = await Promise.all([gateLogCommands(argv), gateFinderMiss(argv)]);
9290
+ if (logOk && finderMissOk) {
9149
9291
  await program2.parseAsync();
9150
9292
  }
9151
9293
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grovehq/cli",
3
- "version": "0.38.4",
3
+ "version": "0.39.0",
4
4
  "description": "Grove's command line, for coding agents building Grove projects.",
5
5
  "homepage": "https://grovehq.com",
6
6
  "license": "UNLICENSED",