@curviate/cli 0.32.0 → 0.34.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 (41) hide show
  1. package/CHANGELOG.md +264 -1
  2. package/README.md +13 -1
  3. package/dist/{account-JDSZC633.js → account-463D5EVY.js} +90 -47
  4. package/dist/{chunk-JRKM4OV2.js → chunk-6W7364S3.js} +1 -1
  5. package/dist/{chunk-KQXYEQAD.js → chunk-7JU4IXXG.js} +172 -8
  6. package/dist/{chunk-5EJDQ47B.js → chunk-BN7L7WSY.js} +16 -16
  7. package/dist/chunk-DCZR4M7G.js +327 -0
  8. package/dist/{chunk-V3PB4HSF.js → chunk-MNDXMGPX.js} +68 -24
  9. package/dist/chunk-TCUYH5GO.js +34 -0
  10. package/dist/{chunk-SKJNLN37.js → chunk-XDQHNUEU.js} +86 -2
  11. package/dist/{chunk-LJR4LJG6.js → chunk-XP2LN6F6.js} +53 -0
  12. package/dist/{chunk-EIEF2KFH.js → chunk-XZJQQJBE.js} +6 -4
  13. package/dist/{chunk-6P52Q2GK.js → chunk-ZJ7D3NFS.js} +5 -4
  14. package/dist/cli.js +104 -37
  15. package/dist/{comment-YOFNFQUE.js → comment-G6RB2PBZ.js} +32 -26
  16. package/dist/{company-6PKHDK6L.js → company-OWND3W3L.js} +53 -35
  17. package/dist/{config-FUHT23SX.js → config-RUBXWFQ3.js} +74 -29
  18. package/dist/{connect-DG2AVGVL.js → connect-3E7EC5ZM.js} +35 -32
  19. package/dist/{doctor-FK7B6754.js → doctor-Z6OSCGKT.js} +22 -16
  20. package/dist/{exit-codes-AAFTOAXF.js → exit-codes-YSFFFWMS.js} +1 -1
  21. package/dist/{feed-HXBKXKAQ.js → feed-VDTFIMKN.js} +18 -17
  22. package/dist/{group-UYX3KTX3.js → group-KDJHY2IM.js} +21 -18
  23. package/dist/{inbox-EVE2ZTHC.js → inbox-DQLX2LR7.js} +39 -23
  24. package/dist/{inboxes-JBB34WMQ.js → inboxes-WMNHOPY7.js} +18 -17
  25. package/dist/{job-GXUZANYN.js → job-ESKS2LDJ.js} +44 -30
  26. package/dist/{login-3OAUY7TG.js → login-YTVPIN27.js} +15 -3
  27. package/dist/{message-34AGROW2.js → message-5W2R3YHS.js} +7 -9
  28. package/dist/{notification-SKKZS2C5.js → notification-IGNUH2GR.js} +20 -19
  29. package/dist/{post-FIW522Q6.js → post-NLI76K74.js} +34 -26
  30. package/dist/{profile-SX6JOYMD.js → profile-TBKKIICM.js} +71 -90
  31. package/dist/{recruiter-H7ROBEVC.js → recruiter-AEJRHIX5.js} +42 -29
  32. package/dist/{sales-nav-7KCK562X.js → sales-nav-SW6WJVMD.js} +43 -29
  33. package/dist/{search-PASMDQEH.js → search-CS6VN5AG.js} +58 -44
  34. package/dist/{setup-YV5PVIU5.js → setup-ANHJZJ2S.js} +12 -8
  35. package/dist/{webhook-GPLFPC6N.js → webhook-NGMRJMQ5.js} +25 -22
  36. package/package.json +2 -2
  37. package/dist/chunk-LKF5MZIP.js +0 -90
  38. package/dist/chunk-PKSKQ3LN.js +0 -68
  39. package/dist/chunk-R3VLWLVV.js +0 -23
  40. package/dist/chunk-TD2ZIXFR.js +0 -67
  41. package/dist/chunk-TQJ77SL4.js +0 -147
@@ -1,10 +1,13 @@
1
1
  #!/usr/bin/env node
2
+ import {
3
+ readablePage
4
+ } from "./chunk-7JU4IXXG.js";
2
5
  import {
3
6
  getExitCode
4
- } from "./chunk-EIEF2KFH.js";
7
+ } from "./chunk-XZJQQJBE.js";
5
8
  import {
6
9
  assertNoStdinPlaceholder
7
- } from "./chunk-SKJNLN37.js";
10
+ } from "./chunk-XDQHNUEU.js";
8
11
 
9
12
  // src/lib/path-safety.ts
10
13
  var UNSAFE_CHARS = /[\u0000-\u0020\u007F/\\?#%]/;
@@ -71,18 +74,20 @@ function listConnectedAccounts(client) {
71
74
  if (cached) return cached;
72
75
  const pending = (async () => {
73
76
  const accounts = [];
77
+ let unreadableRow = false;
74
78
  let cursor;
75
79
  for (let page = 0; page < MAX_LOOKUP_PAGES; page++) {
76
80
  const params = { limit: 250 };
77
81
  if (cursor) params["cursor"] = cursor;
78
- const result = await client.accounts.list(
79
- params
82
+ const result = readablePage(
83
+ await client.accounts.list(params)
80
84
  );
81
- for (const item of result.items ?? []) {
85
+ for (const item of result.items) {
82
86
  const account = toConnectedAccount(item);
83
87
  if (account) accounts.push(account);
88
+ else unreadableRow = true;
84
89
  }
85
- if (!result.cursor) return { accounts, complete: true };
90
+ if (!result.cursor) return { accounts, complete: !unreadableRow };
86
91
  cursor = result.cursor;
87
92
  }
88
93
  return { accounts, complete: false };
@@ -104,14 +109,67 @@ function matchAccounts(accounts, selector) {
104
109
  if (exactName.length > 0) return exactName;
105
110
  return accounts.filter((a) => a.fullName?.toLowerCase().startsWith(needle));
106
111
  }
112
+ async function listOrExit(client, out, purpose) {
113
+ try {
114
+ return await listConnectedAccounts(client);
115
+ } catch (err) {
116
+ const { CurviateError } = await import("@curviate/sdk");
117
+ if (err instanceof CurviateError) {
118
+ const e = err;
119
+ out.stderr.write(`error: [${e.code}] could not look up connected accounts to ${purpose}: ${e.message}
120
+ `);
121
+ process.exit(getExitCode(e));
122
+ }
123
+ throw err;
124
+ }
125
+ }
126
+ var SET_ACCOUNT = "Pass --account, set CURVIATE_ACCOUNT, or run `curviate config set-account`.";
127
+ async function soleConnectedAccount(client, flags, out) {
128
+ if (flags.preview === true) {
129
+ out.stderr.write(`error: --account is required with --preview, which does not call the API to find it. ${SET_ACCOUNT}
130
+ `);
131
+ process.exit(2);
132
+ }
133
+ const listed = await listOrExit(client, out, "pick the account for this command");
134
+ if (!listed.complete) {
135
+ out.stderr.write(
136
+ `error: [ACCOUNT_LIST_TRUNCATED] --account is required: the connected accounts could not be read in full (more of them than the resolver reads, or an entry it could not read), so none can be picked for you. ${SET_ACCOUNT}
137
+ `
138
+ );
139
+ process.exit(2);
140
+ }
141
+ const { accounts } = listed;
142
+ if (accounts.length === 0) {
143
+ out.stderr.write(
144
+ "error: no LinkedIn account is connected to this workspace yet. Connect one with `curviate account link`, then retry.\n"
145
+ );
146
+ process.exit(2);
147
+ }
148
+ if (accounts.length > 1) {
149
+ out.stderr.write(
150
+ `error: --account is required: ${accounts.length} accounts are connected (${describeAll(accounts)}). ${SET_ACCOUNT}
151
+ `
152
+ );
153
+ process.exit(2);
154
+ }
155
+ const resolved = accounts[0].accountId;
156
+ const bad = pathSegmentViolation(resolved);
157
+ if (bad !== null) {
158
+ out.stderr.write(pathSegmentErrorMessage("the connected account id", resolved, bad));
159
+ process.exit(2);
160
+ }
161
+ return resolved;
162
+ }
107
163
  async function requireAccount(client, flags, out) {
108
164
  const account = flags.account;
109
- if (!account) {
165
+ if (account !== void 0 && account.trim() === "") {
110
166
  out.stderr.write(
111
- "error: --account is required for this command. Set it via --account, CURVIATE_ACCOUNT, or `curviate config set-account`.\n"
167
+ `error: --account was given an empty value. ${SET_ACCOUNT} Omit it entirely to use the only connected account.
168
+ `
112
169
  );
113
170
  process.exit(2);
114
171
  }
172
+ if (!account) return soleConnectedAccount(client, flags, out);
115
173
  const selector = account.trim();
116
174
  assertNoStdinPlaceholder("the --account value", [selector]);
117
175
  const redirecting = redirectingViolation(selector);
@@ -127,24 +185,10 @@ async function requireAccount(client, flags, out) {
127
185
  );
128
186
  return selector;
129
187
  }
130
- let listed;
131
- try {
132
- listed = await listConnectedAccounts(client);
133
- } catch (err) {
134
- const { CurviateError } = await import("@curviate/sdk");
135
- if (err instanceof CurviateError) {
136
- const e = err;
137
- out.stderr.write(
138
- `error: [${e.code}] could not look up connected accounts to resolve --account "${selector}": ${e.message}
139
- `
140
- );
141
- process.exit(getExitCode(e.code));
142
- }
143
- throw err;
144
- }
188
+ const listed = await listOrExit(client, out, `resolve --account "${selector}"`);
145
189
  if (!listed.complete) {
146
190
  out.stderr.write(
147
- `error: [ACCOUNT_LIST_TRUNCATED] --account "${selector}" cannot be resolved by name: this API key has more connected accounts than the resolver reads (it stops after ${MAX_LOOKUP_PAGES} pages of 250), so the name would be matched against an incomplete list and a single match would not prove there is only one. Pass the account id instead; an id is used as given and needs no lookup.
191
+ `error: [ACCOUNT_LIST_TRUNCATED] --account "${selector}" cannot be resolved by name: the connected accounts could not be read in full (this API key has more of them than the resolver reads, which stops after ${MAX_LOOKUP_PAGES} pages of 250, or the list carried an entry it could not read), so the name would be matched against an incomplete list and a single match would not prove there is only one. Pass the account id instead; an id is used as given and needs no lookup.
148
192
  `
149
193
  );
150
194
  process.exit(2);
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/lib/preview.ts
4
+ var SECRET_FLAGS = ["api-key", "password", "proxy-password", "li-at", "li-a", "code", "secret"];
5
+ var SECRET_KEYS = new Set(SECRET_FLAGS.map((flag) => flag.replace(/-/g, "_")));
6
+ var SECRET_MASK = "\u2022\u2022\u2022\u2022";
7
+ function maskSecrets(value) {
8
+ if (Array.isArray(value)) return value.map(maskSecrets);
9
+ if (typeof value !== "object" || value === null || Buffer.isBuffer(value)) return value;
10
+ return Object.fromEntries(
11
+ Object.entries(value).map(([key, v]) => [key, SECRET_KEYS.has(key) && v !== void 0 && v !== null ? SECRET_MASK : maskSecrets(v)])
12
+ );
13
+ }
14
+ function buildPreviewOutput(req) {
15
+ const result = {
16
+ method: req.method,
17
+ args: maskSecrets(req.args),
18
+ body: maskSecrets(req.body)
19
+ };
20
+ if (req.account !== void 0) {
21
+ result.account = req.account;
22
+ }
23
+ if (req.attachments && req.attachments.length > 0) {
24
+ result.attachments = req.attachments.map(
25
+ (a) => `${a.name} (${a.buffer.byteLength} bytes)`
26
+ );
27
+ }
28
+ return result;
29
+ }
30
+
31
+ export {
32
+ SECRET_FLAGS,
33
+ buildPreviewOutput
34
+ };
@@ -86,7 +86,7 @@ var GLOBAL_FLAGS = {
86
86
  },
87
87
  account: {
88
88
  type: "string",
89
- description: "Account id for account-scoped commands."
89
+ description: "Account id for account-scoped commands. Optional when exactly one account is connected."
90
90
  },
91
91
  "base-url": {
92
92
  type: "string",
@@ -146,6 +146,20 @@ var GLOBAL_FLAGS = {
146
146
  description: "Allow beta operations for THIS call only (--beta, --beta=false). A gated operation refuses BETA_NOT_ENABLED (exit 5) until a human enables beta in Settings, or you pass --beta for this call. Persists nothing."
147
147
  }
148
148
  };
149
+ var NON_STREAM_FLAGS = {
150
+ "api-key": GLOBAL_FLAGS["api-key"],
151
+ profile: GLOBAL_FLAGS.profile,
152
+ account: GLOBAL_FLAGS.account,
153
+ "base-url": GLOBAL_FLAGS["base-url"],
154
+ timeout: GLOBAL_FLAGS.timeout,
155
+ json: GLOBAL_FLAGS.json,
156
+ fields: GLOBAL_FLAGS.fields,
157
+ limit: GLOBAL_FLAGS.limit,
158
+ cursor: GLOBAL_FLAGS.cursor,
159
+ preview: GLOBAL_FLAGS.preview,
160
+ verbose: GLOBAL_FLAGS.verbose,
161
+ beta: GLOBAL_FLAGS.beta
162
+ };
149
163
  var WRITE_FLAGS = {
150
164
  "api-key": GLOBAL_FLAGS["api-key"],
151
165
  profile: GLOBAL_FLAGS.profile,
@@ -171,6 +185,72 @@ var READ_SINGLE_FLAGS = {
171
185
  };
172
186
  var WRITE_SINGLE_FLAGS = READ_SINGLE_FLAGS;
173
187
 
188
+ // src/lib/beta.ts
189
+ var BETA_CONSENT_HEADER = "X-Curviate-Beta";
190
+ var TRUE_TOKENS = /* @__PURE__ */ new Set(["true", "1", "on", "yes"]);
191
+ var FALSE_TOKENS = /* @__PURE__ */ new Set(["false", "0", "off", "no"]);
192
+ var BETA_ACCEPTED_VALUES = "true|false, 1|0, on|off, yes|no (case-insensitive)";
193
+ function parseBetaFlag(rawArgs) {
194
+ let value;
195
+ const rest = [];
196
+ let endOfFlags = false;
197
+ let seen = false;
198
+ for (const arg of rawArgs) {
199
+ if (endOfFlags) {
200
+ rest.push(arg);
201
+ continue;
202
+ }
203
+ if (arg === "--") {
204
+ endOfFlags = true;
205
+ rest.push(arg);
206
+ continue;
207
+ }
208
+ if (arg === "--beta" || arg === "--no-beta" || arg.startsWith("--beta=") || arg.startsWith("--no-beta=")) {
209
+ if (seen) return { ok: false, error: "--beta was given more than once. Pass it once." };
210
+ seen = true;
211
+ }
212
+ if (arg === "--beta") {
213
+ value = true;
214
+ continue;
215
+ }
216
+ if (arg === "--no-beta") {
217
+ value = false;
218
+ continue;
219
+ }
220
+ if (arg.startsWith("--no-beta=")) {
221
+ return {
222
+ ok: false,
223
+ error: `--no-beta takes no value. Use --no-beta, or --beta=${BETA_ACCEPTED_VALUES.split(",")[0].split("|")[1]}.`
224
+ };
225
+ }
226
+ if (arg.startsWith("--beta=")) {
227
+ const raw = arg.slice("--beta=".length).trim().toLowerCase();
228
+ if (TRUE_TOKENS.has(raw)) {
229
+ value = true;
230
+ continue;
231
+ }
232
+ if (FALSE_TOKENS.has(raw)) {
233
+ value = false;
234
+ continue;
235
+ }
236
+ return {
237
+ ok: false,
238
+ error: `--beta must be one of ${BETA_ACCEPTED_VALUES}.`
239
+ };
240
+ }
241
+ rest.push(arg);
242
+ }
243
+ return { ok: true, value, rest };
244
+ }
245
+ var override;
246
+ function setBetaOverride(value) {
247
+ override = value;
248
+ }
249
+ function betaOverrideHeader() {
250
+ if (override === void 0) return {};
251
+ return { [BETA_CONSENT_HEADER]: override ? "true" : "false" };
252
+ }
253
+
174
254
  export {
175
255
  STDIN_SENTINEL,
176
256
  defaultReadStdin,
@@ -179,7 +259,11 @@ export {
179
259
  assertNoStdinPlaceholder,
180
260
  resolveTextOrStdin,
181
261
  GLOBAL_FLAGS,
262
+ NON_STREAM_FLAGS,
182
263
  WRITE_FLAGS,
183
264
  READ_SINGLE_FLAGS,
184
- WRITE_SINGLE_FLAGS
265
+ WRITE_SINGLE_FLAGS,
266
+ parseBetaFlag,
267
+ setBetaOverride,
268
+ betaOverrideHeader
185
269
  };
@@ -1,5 +1,46 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ // src/lib/sections.ts
4
+ var SECTION_BASE_NAMES = [
5
+ "experience",
6
+ "education",
7
+ "languages",
8
+ "skills",
9
+ "certifications",
10
+ "volunteer_experience",
11
+ "projects",
12
+ "recommendations",
13
+ "interests"
14
+ ];
15
+ var VALID_LINKEDIN_SECTIONS = /* @__PURE__ */ new Set([
16
+ "linkedin_*",
17
+ ...SECTION_BASE_NAMES.flatMap((n) => [`linkedin_${n}`, `linkedin_${n}_preview`])
18
+ ]);
19
+ var CANONICAL_SECTION_VALUES = [
20
+ "linkedin_*",
21
+ ...SECTION_BASE_NAMES.map((n) => `linkedin_${n}`)
22
+ ];
23
+ function parseSectionsFlag(raw) {
24
+ const values = raw.split(",").map((s) => s.trim()).filter(Boolean);
25
+ const sections = [];
26
+ for (const value of values) {
27
+ const canonical = value.startsWith("linkedin_") ? value : `linkedin_${value}`;
28
+ if (!VALID_LINKEDIN_SECTIONS.has(canonical)) {
29
+ return {
30
+ ok: false,
31
+ error: `error: --sections: unknown section "${value}". Valid values: ${CANONICAL_SECTION_VALUES.join(", ")} (each also has a _preview variant).
32
+ `
33
+ };
34
+ }
35
+ sections.push(canonical);
36
+ }
37
+ return { ok: true, sections };
38
+ }
39
+ function sectionKeys(sections) {
40
+ if (sections.includes("linkedin_*")) return [...SECTION_BASE_NAMES];
41
+ return [...new Set(sections.map((s) => s.replace(/^linkedin_/, "").replace(/_preview$/, "")))];
42
+ }
43
+
3
44
  // src/lib/slim.ts
4
45
  function synthesizeCurrentPosition(workExperience) {
5
46
  if (!Array.isArray(workExperience) || workExperience.length === 0) {
@@ -33,6 +74,16 @@ function getSpecifics(d) {
33
74
  function extractExperience(specifics) {
34
75
  return Array.isArray(specifics?.["experience"]) ? specifics["experience"] : [];
35
76
  }
77
+ function withRequestedSections(slim, sections) {
78
+ if (!sections?.length) return slim;
79
+ return (data) => {
80
+ const d = data !== null && typeof data === "object" ? data : {};
81
+ const specifics = getSpecifics(d);
82
+ const out = slim(data);
83
+ for (const key of sectionKeys(sections)) out[key] = specifics?.[key] ?? null;
84
+ return out;
85
+ };
86
+ }
36
87
  function slimProfileMe(data) {
37
88
  const d = data !== null && data !== void 0 && typeof data === "object" ? data : {};
38
89
  const specifics = getSpecifics(d);
@@ -286,6 +337,8 @@ function slimCompanyInvitableFollowers(data) {
286
337
  }
287
338
 
288
339
  export {
340
+ parseSectionsFlag,
341
+ withRequestedSections,
289
342
  slimProfileMe,
290
343
  slimProfile,
291
344
  slimInviteSentItem,
@@ -66,7 +66,7 @@ var EXIT_CODE_MAP = {
66
66
  // may exist perfectly well on LinkedIn, and this API simply holds no copy of
67
67
  // it, so it is NOT "not found" and re-checking the id is the wrong move. It
68
68
  // is not 1 either: nothing failed. It is user_fixable and not retryable AS
69
- // SENT — the fix is another mode (`refill` fetches it once, `auto` fetches
69
+ // SENT: the fix is another mode (`refill` fetches it once, `auto` fetches
70
70
  // now), which is the same shape as exit 2 but reached without a malformed
71
71
  // request, so it earns its own number rather than muddying either.
72
72
  // A 502 under cache_only stays 7: "we could not look" and "we hold nothing"
@@ -76,7 +76,7 @@ var EXIT_CODE_MAP = {
76
76
  //
77
77
  // Each of these is returned by a `/v1` route, the `/v1` catch-all, or a
78
78
  // shared handler one of them calls, and each was absent from the SDK's
79
- // exported union until 0.30.0 — so it decoded to `INTERNAL` and landed here
79
+ // exported union until 0.30.0, so it decoded to `INTERNAL` and landed here
80
80
  // on exit 1, which reads as "the tool broke" for a refusal that is usually
81
81
  // the caller's to fix. They are bucketed by what the caller does next, taken
82
82
  // from each code's own HTTP status and retry contract rather than by name.
@@ -134,8 +134,10 @@ var EXIT_CODE_MAP = {
134
134
  // and here it is not. The `--json` envelope still names the real code.
135
135
  STRIPE_DRIFT_DETECTED: 1
136
136
  };
137
- function getExitCode(code) {
138
- return EXIT_CODE_MAP[code] ?? 1;
137
+ function getExitCode(error) {
138
+ if (typeof error === "string") return EXIT_CODE_MAP[error] ?? 1;
139
+ if (error.code === "INTERNAL" && error.httpStatus === void 0 && error.retryLikelyToSucceed === true) return 7;
140
+ return EXIT_CODE_MAP[error.code] ?? 1;
139
141
  }
140
142
  var AUTH_NEEDED = 12;
141
143
 
@@ -2,20 +2,21 @@
2
2
  import {
3
3
  resolveIdentifier
4
4
  } from "./chunk-UEAX6KUB.js";
5
+ import {
6
+ readableId
7
+ } from "./chunk-7JU4IXXG.js";
5
8
 
6
9
  // src/lib/member-id.ts
7
10
  var MEMBER_PROVIDER_ID_RE = /^A[CDE][A-Za-z0-9_-]{4,}$/;
8
11
  async function resolveMemberProviderId(ns, raw) {
9
12
  const normalized = resolveIdentifier(raw);
10
13
  if (MEMBER_PROVIDER_ID_RE.test(normalized)) return normalized;
11
- const profile = await ns.users.get(normalized, {});
12
- return profile.id;
14
+ return readableId(await ns.users.get(normalized, {}));
13
15
  }
14
16
  async function resolveMemberOrMeProviderId(ns, raw, query = {}) {
15
17
  const normalized = resolveIdentifier(raw);
16
18
  if (normalized === "me" || MEMBER_PROVIDER_ID_RE.test(normalized)) return normalized;
17
- const profile = await ns.users.get(normalized, query);
18
- return profile.id;
19
+ return readableId(await ns.users.get(normalized, query));
19
20
  }
20
21
 
21
22
  export {
package/dist/cli.js CHANGED
@@ -1,13 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
- parseBetaFlag,
4
- setBetaOverride
5
- } from "./chunk-PKSKQ3LN.js";
3
+ SECRET_FLAGS
4
+ } from "./chunk-TCUYH5GO.js";
6
5
  import {
7
6
  GLOBAL_FLAGS,
8
7
  STDIN_SENTINEL,
9
- restoreLiteralDashes
10
- } from "./chunk-SKJNLN37.js";
8
+ parseBetaFlag,
9
+ restoreLiteralDashes,
10
+ setBetaOverride
11
+ } from "./chunk-XDQHNUEU.js";
11
12
 
12
13
  // src/cli.ts
13
14
  import { defineCommand } from "citty";
@@ -19,6 +20,34 @@ var GLOBAL_FLAG_NAMES = new Set(Object.keys(GLOBAL_FLAGS));
19
20
  var GLOBAL_BOOLEAN_FLAG_NAMES = new Set(
20
21
  Object.entries(GLOBAL_FLAGS).filter(([, def]) => def.type === "boolean").map(([name]) => name)
21
22
  );
23
+ var saysRepeatable = (def) => /\brepeatable\b/i.test(def?.description ?? "");
24
+ async function repeatedFlag(leaf, flags) {
25
+ const defs = await resolveValue(leaf.args ?? {});
26
+ const canonical = /* @__PURE__ */ new Map();
27
+ for (const [name, def] of Object.entries(defs)) {
28
+ if (def?.type === "boolean" && !(`no-${name}` in defs)) canonical.set(`no-${name}`, name);
29
+ }
30
+ for (const [name, def] of Object.entries(defs)) {
31
+ canonical.set(name, name);
32
+ for (const a of [].concat(def?.alias ?? [])) canonical.set(a, name);
33
+ }
34
+ const seen = /* @__PURE__ */ new Set();
35
+ for (const { name } of flags) {
36
+ const flag = canonical.get(name);
37
+ if (flag === void 0 || saysRepeatable(defs[flag])) continue;
38
+ if (seen.has(flag)) return flag;
39
+ seen.add(flag);
40
+ }
41
+ return null;
42
+ }
43
+ function argumentAt(index) {
44
+ return `argument ${index + 1}`;
45
+ }
46
+ function shownFlag(flag, index) {
47
+ const name = flag.replace(/^-+/, "");
48
+ const runsOn = !SECRET_FLAGS.includes(name) && SECRET_FLAGS.some((secret) => name.startsWith(secret));
49
+ return runsOn ? `at ${argumentAt(index)}` : `\`${flag}\``;
50
+ }
22
51
  var REMOVED_COMMANDS = {
23
52
  post: {
24
53
  list: "`post list` was removed. Use `post user-posts <user_id>` (accepts `me`).",
@@ -172,11 +201,12 @@ async function assertLeafConsumesPositionals(leaf, leafArgs, path, siblings) {
172
201
  const extras = await extraPositionals(leaf, leafArgs);
173
202
  if (extras.length === 0) return;
174
203
  const token = extras[0].token;
204
+ const shown = argumentAt(extras[0].index);
175
205
  const form = renderPath(path);
176
206
  const arity = arityPhrase(await nodePositionalCount(leaf));
177
207
  const hint = siblings && Object.prototype.hasOwnProperty.call(siblings, token) ? `Did you mean \`${renderPath([...path.slice(0, -1), token])}\`?` : void 0;
178
208
  usageError(
179
- `unexpected argument \`${token}\` after \`${form}\`. \`${form}\` takes ${arity}. Run \`${form} --help\` for its usage.`,
209
+ `unexpected ${shown} after \`${form}\`. \`${form}\` takes ${arity}. Run \`${form} --help\` for its usage.`,
180
210
  hint
181
211
  );
182
212
  }
@@ -191,11 +221,14 @@ async function declaredArgNames(cmd) {
191
221
  }
192
222
  return names;
193
223
  }
194
- function findUnknownFlag(flags, declared) {
195
- for (const { token, name } of flags) {
196
- if (declared.has(name)) continue;
197
- if (name.startsWith("no-") && declared.has(name.slice(3))) continue;
198
- return token;
224
+ function findUnknownFlag(flags, declared, booleans) {
225
+ for (const { token, name, index } of flags) {
226
+ const dashes = /^-*/.exec(token)[0].length;
227
+ if (dashes === 2 || dashes === 1 && name.length === 1) {
228
+ if (declared.has(name)) continue;
229
+ if (name.startsWith("no-") && booleans.has(name.slice(3))) continue;
230
+ }
231
+ return shownFlag(token.split("=")[0], index);
199
232
  }
200
233
  return null;
201
234
  }
@@ -212,6 +245,22 @@ function hasEmptyFields(rawArgs) {
212
245
  }
213
246
  return false;
214
247
  }
248
+ var HINT_ABBREVIATIONS = /(?:^|[\s(])(?:e\.g|i\.e|incl|etc|vs)$/i;
249
+ function firstSentenceHint(description) {
250
+ if (!description) return "";
251
+ let depth = 0;
252
+ let end = description.length;
253
+ for (let i = 0; i < description.length; i++) {
254
+ const ch = description[i];
255
+ if (ch === "(") depth++;
256
+ else if (ch === ")") depth = Math.max(0, depth - 1);
257
+ else if (depth === 0 && (ch === "." || ch === "!" || ch === "?") && (i + 1 === description.length || /\s/.test(description[i + 1])) && !HINT_ABBREVIATIONS.test(description.slice(0, i))) {
258
+ end = i + 1;
259
+ break;
260
+ }
261
+ }
262
+ return description.slice(0, end).replace(/\s*\(required\)/g, "").trim();
263
+ }
215
264
  function usageError(message, hint) {
216
265
  process.stderr.write(`error: ${message}
217
266
  `);
@@ -241,7 +290,7 @@ async function resolveLeaf(cmd, rawArgs, descent) {
241
290
  if (token !== void 0) {
242
291
  const hint = successorHint(await nodeName(cmd), token);
243
292
  if (hint) {
244
- usageError(`unknown command \`${token}\``, hint);
293
+ usageError(`unknown command at ${argumentAt(idx)}`, hint);
245
294
  }
246
295
  }
247
296
  if (token !== void 0 && hasBarePositional) {
@@ -258,13 +307,13 @@ async function resolveLeaf(cmd, rawArgs, descent) {
258
307
  }
259
308
  const name = await nodeName(cmd);
260
309
  usageError(
261
- `unexpected argument \`${first.token}\` after \`${name}\`. It is neither a positional \`${name}\` accepts nor one of its subcommands. Run \`curviate ${name} --help\` for the available subcommands.`
310
+ `unexpected ${argumentAt(first.index)} after \`${name}\`. It is neither a positional \`${name}\` accepts nor one of its subcommands. Run \`curviate ${name} --help\` for the available subcommands.`
262
311
  );
263
312
  }
264
313
  return { leaf: cmd, leafArgs: rawArgs };
265
314
  }
266
315
  if (token !== void 0) {
267
- usageError(`unknown command \`${token}\``);
316
+ usageError(`unknown command at ${argumentAt(idx)}`);
268
317
  }
269
318
  return { leaf: cmd, leafArgs: rawArgs };
270
319
  }
@@ -293,17 +342,23 @@ async function dispatch(root, rawArgs) {
293
342
  }
294
343
  setBetaOverride(beta.ok ? beta.value : void 0);
295
344
  const argsAfterBeta = beta.ok ? beta.rest : rawArgs;
345
+ let hintLeaf;
296
346
  try {
297
347
  const { leaf, leafArgs } = await resolveLeaf(root, argsAfterBeta);
348
+ hintLeaf = leaf;
298
349
  if (hasEmptyFields(leafArgs)) {
299
350
  usageError("--fields must not be empty.");
300
351
  }
301
352
  const booleanFlags = await booleanFlagNames(leaf);
302
353
  const declared = await declaredArgNames(leaf);
303
354
  const walk = walkTokens(leafArgs, booleanFlags, declared);
304
- const unknown = findUnknownFlag(walk.flags, declared);
355
+ const unknown = findUnknownFlag(walk.flags, declared, booleanFlags);
305
356
  if (unknown !== null) {
306
- usageError(`unknown flag \`${unknown}\`.`);
357
+ usageError(`unknown flag ${unknown}.`);
358
+ }
359
+ const repeated = await repeatedFlag(leaf, walk.flags);
360
+ if (repeated !== null) {
361
+ usageError(`--${repeated} was given more than once. Pass it once.`);
307
362
  }
308
363
  const mergedLeafArgs = mergeDashPrefixedValues(leafArgs, walk.merges);
309
364
  const processedLeafArgs = mergedLeafArgs.map((a) => a === "-" ? STDIN_SENTINEL : a);
@@ -328,6 +383,18 @@ async function dispatch(root, rawArgs) {
328
383
  const code = err?.code;
329
384
  process.stderr.write(`error: ${message}
330
385
  `);
386
+ const missing = code === "EARG" ? /^Missing required argument: --([\w-]+)$/.exec(message)?.[1] : void 0;
387
+ if (missing && hintLeaf) {
388
+ const defs = await resolveValue(hintLeaf.args ?? {});
389
+ const hint = firstSentenceHint(defs[missing]?.description);
390
+ if (hint) process.stderr.write(`hint: --${missing}: ${hint}
391
+ `);
392
+ }
393
+ const { CurviateError } = await import("@curviate/sdk");
394
+ if (err instanceof CurviateError) {
395
+ const { getExitCode } = await import("./exit-codes-YSFFFWMS.js");
396
+ process.exit(getExitCode(err));
397
+ }
331
398
  process.exit(code === "EARG" ? 2 : 1);
332
399
  }
333
400
  }
@@ -347,30 +414,30 @@ var main = defineCommand({
347
414
  // Subcommand registry, names and descriptions are static for help rendering;
348
415
  // the handler implementation is loaded lazily on first invocation.
349
416
  subCommands: {
350
- setup: () => import("./setup-YV5PVIU5.js").then((m) => m.setupCommand),
351
- doctor: () => import("./doctor-FK7B6754.js").then((m) => m.doctorCommand),
352
- login: () => import("./login-3OAUY7TG.js").then((m) => m.loginCommand),
353
- config: () => import("./config-FUHT23SX.js").then((m) => m.configCommand),
417
+ setup: () => import("./setup-ANHJZJ2S.js").then((m) => m.setupCommand),
418
+ doctor: () => import("./doctor-Z6OSCGKT.js").then((m) => m.doctorCommand),
419
+ login: () => import("./login-YTVPIN27.js").then((m) => m.loginCommand),
420
+ config: () => import("./config-RUBXWFQ3.js").then((m) => m.configCommand),
354
421
  // ---------------------------------------------------------------------------
355
422
  // Noun groups, lazy-loaded on first invocation.
356
423
  // ---------------------------------------------------------------------------
357
- profile: () => import("./profile-SX6JOYMD.js").then((m) => m.profileCommand),
358
- company: () => import("./company-6PKHDK6L.js").then((m) => m.companyCommand),
359
- job: () => import("./job-GXUZANYN.js").then((m) => m.jobCommand),
360
- connect: () => import("./connect-DG2AVGVL.js").then((m) => m.connectCommand),
361
- search: () => import("./search-PASMDQEH.js").then((m) => m.searchCommand),
362
- inbox: () => import("./inbox-EVE2ZTHC.js").then((m) => m.inboxCommand),
363
- inboxes: () => import("./inboxes-JBB34WMQ.js").then((m) => m.inboxesCommand),
364
- message: () => import("./message-34AGROW2.js").then((m) => m.messageCommand),
365
- post: () => import("./post-FIW522Q6.js").then((m) => m.postCommand),
366
- comment: () => import("./comment-YOFNFQUE.js").then((m) => m.commentCommand),
367
- account: () => import("./account-JDSZC633.js").then((m) => m.accountCommand),
368
- webhook: () => import("./webhook-GPLFPC6N.js").then((m) => m.webhookCommand),
369
- "sales-nav": () => import("./sales-nav-7KCK562X.js").then((m) => m.salesNavCommand),
370
- recruiter: () => import("./recruiter-H7ROBEVC.js").then((m) => m.recruiterCommand),
371
- group: () => import("./group-UYX3KTX3.js").then((m) => m.groupCommand),
372
- feed: () => import("./feed-HXBKXKAQ.js").then((m) => m.feedCommand),
373
- notification: () => import("./notification-SKKZS2C5.js").then((m) => m.notificationCommand)
424
+ profile: () => import("./profile-TBKKIICM.js").then((m) => m.profileCommand),
425
+ company: () => import("./company-OWND3W3L.js").then((m) => m.companyCommand),
426
+ job: () => import("./job-ESKS2LDJ.js").then((m) => m.jobCommand),
427
+ connect: () => import("./connect-3E7EC5ZM.js").then((m) => m.connectCommand),
428
+ search: () => import("./search-CS6VN5AG.js").then((m) => m.searchCommand),
429
+ inbox: () => import("./inbox-DQLX2LR7.js").then((m) => m.inboxCommand),
430
+ inboxes: () => import("./inboxes-WMNHOPY7.js").then((m) => m.inboxesCommand),
431
+ message: () => import("./message-5W2R3YHS.js").then((m) => m.messageCommand),
432
+ post: () => import("./post-NLI76K74.js").then((m) => m.postCommand),
433
+ comment: () => import("./comment-G6RB2PBZ.js").then((m) => m.commentCommand),
434
+ account: () => import("./account-463D5EVY.js").then((m) => m.accountCommand),
435
+ webhook: () => import("./webhook-NGMRJMQ5.js").then((m) => m.webhookCommand),
436
+ "sales-nav": () => import("./sales-nav-SW6WJVMD.js").then((m) => m.salesNavCommand),
437
+ recruiter: () => import("./recruiter-AEJRHIX5.js").then((m) => m.recruiterCommand),
438
+ group: () => import("./group-KDJHY2IM.js").then((m) => m.groupCommand),
439
+ feed: () => import("./feed-VDTFIMKN.js").then((m) => m.feedCommand),
440
+ notification: () => import("./notification-IGNUH2GR.js").then((m) => m.notificationCommand)
374
441
  },
375
442
  async run() {
376
443
  const { runMain } = await import("citty");