@primitivedotdev/cli 3.0.0-preview.16 → 3.0.0-preview.18
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/README.md +37 -14
- package/dist/{api-command-D1LX7Tjj.js → api-command-BlfqpBjp.js} +2931 -4158
- package/dist/{json-output-ch756TXV.js → json-output-saHY68hr.js} +6 -4
- package/dist/{machine-session-DJoBSWTy.js → machine-session-cmk2oCPL.js} +5 -5
- package/dist/{notify-session-7oM8bkRx.js → notify-session-BIElQmDi.js} +70 -31
- package/dist/oclif/auto-signal-worker.js +3 -3
- package/dist/oclif/auto-signals.js +1 -1
- package/dist/oclif/command-not-found.js +23 -4
- package/dist/oclif/index.js +1552 -1767
- package/dist/oclif/proxy-auto-detect.js +1 -1
- package/dist/oclif/receiver-heal.js +2 -2
- package/dist/{repeats-Dj_o6c-X-BLUY-8zn.js → repeats-Dj_o6c-X-b-Y0Ejun.js} +14354 -14305
- package/dist/{scoped-chat-CrQpmC0K.js → scoped-chat-CaiJJRMA.js} +1 -1
- package/dist/{signal-command-Bkr_XwLC.js → signal-command-C4Eu4-1-.js} +12 -6
- package/man/primitive.1 +17 -9
- package/package.json +4 -1
|
@@ -172,7 +172,11 @@ function composeJsonDocument(input) {
|
|
|
172
172
|
if (!failed && errorPayload !== null) warnings = [...warnings, JSON.stringify(errorPayload)];
|
|
173
173
|
const failure = () => {
|
|
174
174
|
if (errorPayload !== null) return errorPayload;
|
|
175
|
-
if (input.thrown && !isExitSignal(input.thrown.error))
|
|
175
|
+
if (input.thrown && !isExitSignal(input.thrown.error)) {
|
|
176
|
+
const body = thrownErrorBody(input.thrown.error);
|
|
177
|
+
if (body.code === void 0) body.code = errorExitCode(input.thrown.error) === 2 ? "usage_error" : "cli_error";
|
|
178
|
+
return body;
|
|
179
|
+
}
|
|
176
180
|
return { message: warnings.at(-1) ?? `The command failed with exit code ${input.exitCode}.` };
|
|
177
181
|
};
|
|
178
182
|
const text = input.stdout.trim();
|
|
@@ -208,9 +212,7 @@ function composeJsonDocument(input) {
|
|
|
208
212
|
if (merged.exit_code === void 0) merged.exit_code = input.exitCode;
|
|
209
213
|
}
|
|
210
214
|
if (warnings.length > 0) {
|
|
211
|
-
|
|
212
|
-
if (existing === void 0 || existing === null) merged.warnings = warnings;
|
|
213
|
-
else if (Array.isArray(existing)) merged.warnings = [...existing, ...warnings.filter((warning) => !existing.includes(warning))];
|
|
215
|
+
if (merged.warnings === void 0 || merged.warnings === null) merged.warnings = warnings;
|
|
214
216
|
else merged.cli_warnings = warnings;
|
|
215
217
|
}
|
|
216
218
|
return merged;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { B as parseOwnerMemberAddress, F as agentProfilesDirectory, I as connectedAgentIdentity, L as connectedApiBaseUrl, M as AgentConnectionSetupError, N as agentProfileDirectory, P as agentProfileName, R as loadConnectedAgentProfile, U as saveConnectedAgentProfile, V as profileAlreadyConnectedMessage, W as PrimitiveApiClient, b as loadCliCredentials, j as AGENT_PROFILE_ENV, z as parseConnectedAgentProfile } from "./cli-config-Ms_0vNjq.js";
|
|
2
|
-
import { An as
|
|
3
|
-
import { Mt as cliInvocation, Pt as defaultConnectionName,
|
|
2
|
+
import { An as putAgentContact, Bt as getEmail, Ct as deleteContact, Ft as getAgentContactPolicy, Gn as sendEmail, Hn as searchEmails, It as getContact, Mn as putContact, St as deleteAgentContact, an as listAgentContacts, fr as __exportAll, in as listAgentConnections, jn as putAgentContactPolicy, sn as listContacts, tn as inviteAgentConnection, un as listDomains, wn as listSentEmails } from "./repeats-Dj_o6c-X-b-Y0Ejun.js";
|
|
3
|
+
import { Mt as cliInvocation, Pt as defaultConnectionName, nn as refreshStoredCliCredentials, rn as refuseOrgSelectionForProfile, zt as detectAgentRuntime } from "./api-command-BlfqpBjp.js";
|
|
4
4
|
import { _ as acquireListenLock, b as listenLockHeld, c as mailTime, d as readMailJson, f as removeMailFile, g as ListenStateError, h as writeMailJson, i as mailId, l as privateMailDirectory, o as mailObject, p as syncMailDirectory, r as mailAddress, s as mailString } from "./shared-mail-files-BAQSGxxz.js";
|
|
5
|
-
import {
|
|
5
|
+
import { C as readBundledConnectSkill, a as NotificationRetryError, b as installSkill, d as SESSION_UUID, f as connectNativeSession, m as NativeSessionDisconnectedError, p as defaultSessionSocket, t as notificationScope } from "./notify-session-BIElQmDi.js";
|
|
6
6
|
import { a as backgroundListenStatus, d as stopBackgroundListen } from "./listen-background-DyBYca28.js";
|
|
7
7
|
import { t as readSharedMailOwner } from "./shared-mail-watch-BAPMsFNv.js";
|
|
8
8
|
import { withoutOrgSelection } from "./oclif/global-org-flag.js";
|
|
9
|
-
import { o as scopedChatSenderTrust } from "./scoped-chat-
|
|
9
|
+
import { o as scopedChatSenderTrust } from "./scoped-chat-CaiJJRMA.js";
|
|
10
10
|
import { accessSync, chmodSync, closeSync, constants, copyFileSync, existsSync, fsyncSync, lstatSync, mkdirSync, openSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, rmdirSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
11
11
|
import { createHash, randomUUID } from "node:crypto";
|
|
12
12
|
import { basename, delimiter, dirname, isAbsolute, join, resolve } from "node:path";
|
|
@@ -4682,7 +4682,7 @@ function defaults(options) {
|
|
|
4682
4682
|
installClaudeWakeHook,
|
|
4683
4683
|
installSkill(runtime) {
|
|
4684
4684
|
const bundle = readBundledConnectSkill(options.packageRoot);
|
|
4685
|
-
return
|
|
4685
|
+
return installSkill({
|
|
4686
4686
|
bundle,
|
|
4687
4687
|
runtime,
|
|
4688
4688
|
project: options.project,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { H as wakeReadCommand, V as skillFirstLine, rt as wakeInteractionSentence } from "./api-command-
|
|
1
|
+
import { At as downloadEmailAttachmentPart, _ as isTrustedSender, c as classifySignalContent, g as isEmailReceivedEvent, v as parseWebhookEvent } from "./repeats-Dj_o6c-X-b-Y0Ejun.js";
|
|
2
|
+
import { H as wakeReadCommand, V as skillFirstLine, rt as wakeInteractionSentence } from "./api-command-BlfqpBjp.js";
|
|
3
3
|
import { _ as acquireListenLock, g as ListenStateError, y as listenIdentity } from "./shared-mail-files-BAQSGxxz.js";
|
|
4
4
|
import { closeSync, copyFileSync, existsSync, fsyncSync, lstatSync, mkdirSync, openSync, opendirSync, readFileSync, readdirSync, readlinkSync, renameSync, rmSync, statSync, symlinkSync, unlinkSync, writeFileSync } from "node:fs";
|
|
5
5
|
import { createHash, randomUUID, scryptSync } from "node:crypto";
|
|
@@ -14,11 +14,23 @@ import { request as request$1 } from "node:https";
|
|
|
14
14
|
import { performance } from "node:perf_hooks";
|
|
15
15
|
// src/oclif/connect-skill.ts
|
|
16
16
|
const CONNECT_SKILL_NAME = "primitive-connect";
|
|
17
|
-
|
|
17
|
+
/** A bundled skill's name is also a directory name, so it stays this plain. */
|
|
18
|
+
const SKILL_NAME_PATTERN = /^[a-z0-9][a-z0-9-]{0,63}$/;
|
|
19
|
+
function isSkillName(value) {
|
|
20
|
+
return SKILL_NAME_PATTERN.test(value);
|
|
21
|
+
}
|
|
22
|
+
/** Where one skill is installed for a runtime, user-level or in the project. */
|
|
23
|
+
function skillTarget(options) {
|
|
18
24
|
const env = options.env ?? process.env;
|
|
19
25
|
const cwd = resolve(options.cwd ?? process.cwd());
|
|
20
26
|
const root = options.runtime === "claude" ? options.project ? join(cwd, ".claude") : resolve(env.CLAUDE_CONFIG_DIR || join(homedir(), ".claude")) : options.project ? join(cwd, ".agents") : resolve(env.CODEX_HOME || join(homedir(), ".codex"));
|
|
21
|
-
return join(root, "skills",
|
|
27
|
+
return join(root, "skills", options.name);
|
|
28
|
+
}
|
|
29
|
+
function connectSkillTarget(options) {
|
|
30
|
+
return skillTarget({
|
|
31
|
+
...options,
|
|
32
|
+
name: CONNECT_SKILL_NAME
|
|
33
|
+
});
|
|
22
34
|
}
|
|
23
35
|
/** A path printed into agent instructions stays on one line. */
|
|
24
36
|
function printablePath(value) {
|
|
@@ -82,26 +94,49 @@ function hashFiles(root, files = listFiles(root)) {
|
|
|
82
94
|
for (const file of files) hashes[file] = createHash("sha256").update(readFileSync(join(root, file))).digest("hex");
|
|
83
95
|
return hashes;
|
|
84
96
|
}
|
|
85
|
-
function
|
|
97
|
+
function skillVersion(hashes) {
|
|
86
98
|
const digest = createHash("sha256");
|
|
87
99
|
for (const file of Object.keys(hashes).sort()) digest.update(`${file}\0${hashes[file]}\n`);
|
|
88
100
|
return digest.digest("hex").slice(0, 16);
|
|
89
101
|
}
|
|
90
|
-
/**
|
|
91
|
-
function
|
|
102
|
+
/** Names of the skills shipped in this CLI package, sorted. */
|
|
103
|
+
function bundledSkillNames(packageRoot) {
|
|
104
|
+
const skillsDir = join(packageRoot, "dist", "skills");
|
|
105
|
+
let entries;
|
|
106
|
+
try {
|
|
107
|
+
entries = readdirSync(skillsDir);
|
|
108
|
+
} catch {
|
|
109
|
+
return [];
|
|
110
|
+
}
|
|
111
|
+
return entries.filter((entry) => entry.endsWith(".json")).map((entry) => entry.slice(0, -5)).filter((name) => {
|
|
112
|
+
if (!isSkillName(name)) return false;
|
|
113
|
+
try {
|
|
114
|
+
return statSync(join(skillsDir, name)).isDirectory();
|
|
115
|
+
} catch {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
}).sort();
|
|
119
|
+
}
|
|
120
|
+
/** Read one skill shipped in this CLI package and refuse one that does not match its manifest. */
|
|
121
|
+
function readBundledSkill(packageRoot, name) {
|
|
122
|
+
if (!isSkillName(name)) throw new Error(`Not a skill name: ${name}`);
|
|
92
123
|
const skillsDir = join(packageRoot, "dist", "skills");
|
|
93
|
-
const directory = join(skillsDir,
|
|
94
|
-
const manifest = JSON.parse(readFileSync(join(skillsDir, `${
|
|
124
|
+
const directory = join(skillsDir, name);
|
|
125
|
+
const manifest = JSON.parse(readFileSync(join(skillsDir, `${name}.json`), "utf8"));
|
|
95
126
|
const expected = manifest.files && typeof manifest.files === "object" && !Array.isArray(manifest.files) ? manifest.files : null;
|
|
96
127
|
const actual = hashFiles(directory);
|
|
97
|
-
if (manifest.name !==
|
|
128
|
+
if (manifest.name !== name || !expected || typeof manifest.version !== "string" || skillVersion(actual) !== manifest.version || skillVersion(expected) !== manifest.version) throw new Error("The bundled skill does not match its manifest.");
|
|
98
129
|
return {
|
|
130
|
+
name,
|
|
99
131
|
directory,
|
|
100
132
|
version: manifest.version,
|
|
101
133
|
commit: typeof manifest.source?.commit === "string" ? manifest.source.commit : null,
|
|
102
134
|
files: actual
|
|
103
135
|
};
|
|
104
136
|
}
|
|
137
|
+
function readBundledConnectSkill(packageRoot) {
|
|
138
|
+
return readBundledSkill(packageRoot, CONNECT_SKILL_NAME);
|
|
139
|
+
}
|
|
105
140
|
/** Two skill copies declare the same helper dependencies. */
|
|
106
141
|
function sameDependencies(a, b) {
|
|
107
142
|
const digest = (path) => {
|
|
@@ -120,21 +155,21 @@ const STALE_LEFTOVER_MS = 6e4;
|
|
|
120
155
|
* process stopped between those renames, put the old copy back so the skill
|
|
121
156
|
* path is never left empty, and remove abandoned staging and retired copies.
|
|
122
157
|
*/
|
|
123
|
-
function recoverInterruptedInstall(root, target) {
|
|
158
|
+
function recoverInterruptedInstall(root, target, name) {
|
|
124
159
|
let entries;
|
|
125
160
|
try {
|
|
126
161
|
entries = readdirSync(root);
|
|
127
162
|
} catch {
|
|
128
163
|
return false;
|
|
129
164
|
}
|
|
130
|
-
const stale = (
|
|
165
|
+
const stale = (entry) => {
|
|
131
166
|
try {
|
|
132
|
-
return Date.now() - lstatSync(join(root,
|
|
167
|
+
return Date.now() - lstatSync(join(root, entry)).mtimeMs > STALE_LEFTOVER_MS;
|
|
133
168
|
} catch {
|
|
134
169
|
return false;
|
|
135
170
|
}
|
|
136
171
|
};
|
|
137
|
-
const retired = entries.filter((
|
|
172
|
+
const retired = entries.filter((entry) => entry.startsWith(`.${name}.retired-`)).filter(stale).sort((a, b) => lstatSync(join(root, b)).mtimeMs - lstatSync(join(root, a)).mtimeMs);
|
|
138
173
|
let recovered = false;
|
|
139
174
|
let missing = false;
|
|
140
175
|
try {
|
|
@@ -153,31 +188,31 @@ function recoverInterruptedInstall(root, target) {
|
|
|
153
188
|
} catch {
|
|
154
189
|
realDirectory = false;
|
|
155
190
|
}
|
|
156
|
-
for (const
|
|
157
|
-
const deps = join(root,
|
|
158
|
-
if (realDirectory && existsSync(deps) && !existsSync(join(target, "node_modules")) && sameDependencies(join(root,
|
|
191
|
+
for (const copy of retired) {
|
|
192
|
+
const deps = join(root, copy, "node_modules");
|
|
193
|
+
if (realDirectory && existsSync(deps) && !existsSync(join(target, "node_modules")) && sameDependencies(join(root, copy), target)) try {
|
|
159
194
|
renameSync(deps, join(target, "node_modules"));
|
|
160
195
|
} catch {}
|
|
161
196
|
}
|
|
162
|
-
for (const
|
|
197
|
+
for (const leftover of [...retired, ...entries.filter((entry) => entry.startsWith(`.${name}.staging-`)).filter(stale)]) rmSync(join(root, leftover), {
|
|
163
198
|
recursive: true,
|
|
164
199
|
force: true
|
|
165
200
|
});
|
|
166
201
|
return recovered;
|
|
167
202
|
}
|
|
168
|
-
function
|
|
203
|
+
function declaresSkill(directory, name) {
|
|
169
204
|
try {
|
|
170
205
|
const text = readFileSync(join(directory, "SKILL.md"), "utf8");
|
|
171
206
|
const frontmatter = /^---\r?\n([\s\S]*?)\r?\n---/.exec(text)?.[1] ?? "";
|
|
172
|
-
return
|
|
207
|
+
return new RegExp(`^name:\\s*["']?${name}["']?\\s*$`, "m").test(frontmatter);
|
|
173
208
|
} catch {
|
|
174
209
|
return false;
|
|
175
210
|
}
|
|
176
211
|
}
|
|
177
|
-
function otherCopies(target) {
|
|
212
|
+
function otherCopies(target, name) {
|
|
178
213
|
const root = dirname(target);
|
|
179
214
|
try {
|
|
180
|
-
return readdirSync(root, { withFileTypes: true }).filter((entry) => !entry.name.startsWith(".") && entry.name !==
|
|
215
|
+
return readdirSync(root, { withFileTypes: true }).filter((entry) => !entry.name.startsWith(".") && entry.name !== name && (entry.isDirectory() || entry.isSymbolicLink())).map((entry) => join(root, entry.name)).filter((directory) => declaresSkill(directory, name)).sort();
|
|
181
216
|
} catch {
|
|
182
217
|
return [];
|
|
183
218
|
}
|
|
@@ -186,7 +221,7 @@ function otherCopies(target) {
|
|
|
186
221
|
function installedVersion(target) {
|
|
187
222
|
try {
|
|
188
223
|
if (!statSync(target).isDirectory()) return null;
|
|
189
|
-
return
|
|
224
|
+
return skillVersion(hashFiles(target));
|
|
190
225
|
} catch {
|
|
191
226
|
return null;
|
|
192
227
|
}
|
|
@@ -196,19 +231,23 @@ function installedVersion(target) {
|
|
|
196
231
|
* left untouched. A different copy is replaced in one rename, never beside a
|
|
197
232
|
* second directory, and a symlink is replaced without touching its target.
|
|
198
233
|
*/
|
|
199
|
-
function
|
|
200
|
-
const
|
|
234
|
+
function installSkill(options) {
|
|
235
|
+
const name = options.bundle.name;
|
|
236
|
+
const target = skillTarget({
|
|
237
|
+
...options,
|
|
238
|
+
name
|
|
239
|
+
});
|
|
201
240
|
const base = {
|
|
202
241
|
runtime: options.runtime,
|
|
203
242
|
path: target,
|
|
204
243
|
version: options.bundle.version
|
|
205
244
|
};
|
|
206
245
|
const copies = () => {
|
|
207
|
-
const found = otherCopies(target);
|
|
246
|
+
const found = otherCopies(target, name);
|
|
208
247
|
return found.length ? { otherCopies: found } : {};
|
|
209
248
|
};
|
|
210
249
|
const root = dirname(target);
|
|
211
|
-
const recovered = recoverInterruptedInstall(root, target);
|
|
250
|
+
const recovered = recoverInterruptedInstall(root, target, name);
|
|
212
251
|
let existing = null;
|
|
213
252
|
try {
|
|
214
253
|
existing = lstatSync(target);
|
|
@@ -227,15 +266,15 @@ function installConnectSkill(options) {
|
|
|
227
266
|
...notes,
|
|
228
267
|
...copies()
|
|
229
268
|
};
|
|
230
|
-
const staging = join(root, `.${
|
|
231
|
-
const retired = join(root, `.${
|
|
269
|
+
const staging = join(root, `.${name}.staging-${randomUUID()}`);
|
|
270
|
+
const retired = join(root, `.${name}.retired-${randomUUID()}`);
|
|
232
271
|
try {
|
|
233
272
|
mkdirSync(root, { recursive: true });
|
|
234
273
|
for (const file of Object.keys(options.bundle.files)) {
|
|
235
274
|
mkdirSync(dirname(join(staging, file)), { recursive: true });
|
|
236
275
|
copyFileSync(join(options.bundle.directory, file), join(staging, file));
|
|
237
276
|
}
|
|
238
|
-
if (
|
|
277
|
+
if (skillVersion(hashFiles(staging)) !== options.bundle.version) throw new Error("Copied skill files do not match the bundle.");
|
|
239
278
|
let dependencies;
|
|
240
279
|
if (link === null && existing?.isDirectory() && existsSync(join(target, "node_modules"))) dependencies = sameDependencies(target, staging) ? "kept" : "reinstall_needed";
|
|
241
280
|
if (link !== null) unlinkSync(target);
|
|
@@ -1444,4 +1483,4 @@ async function openSessionNotifications(options) {
|
|
|
1444
1483
|
}
|
|
1445
1484
|
var ContactNoticeSuppressed = class extends Error {};
|
|
1446
1485
|
var ContactNoticeDeferred = class extends Error {};
|
|
1447
|
-
export { readBundledConnectSkill as S, NotificationOutcomeUnknownError as _, NotificationRetryError as a,
|
|
1486
|
+
export { readBundledConnectSkill as C, installedVersion as S, NotificationOutcomeUnknownError as _, NotificationRetryError as a, installSkill as b, readConversationStatusContent as c, SESSION_UUID as d, connectNativeSession as f, NativeSessionNotLoadedError as g, NativeSessionError as h, notificationReceiptPage as i, createListenHandler as l, NativeSessionDisconnectedError as m, notificationSenders as n, isRoutineNotificationContent as o, defaultSessionSocket as p, openSessionNotifications as r, notificationPartReader as s, notificationScope as t, readableDelivery as u, bundledSkillNames as v, readBundledSkill as w, installedConnectSkillFile as x, connectSkillTarget as y };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { L as readThreadContext,
|
|
1
|
+
import { Qt as getSentEmail } from "../repeats-Dj_o6c-X-b-Y0Ejun.js";
|
|
2
|
+
import { L as readThreadContext, en as createAuthenticatedCliApiClient } from "../api-command-BlfqpBjp.js";
|
|
3
3
|
import { AUTO_SIGNAL_KIND_ENV, AUTO_WORKING_RENEW_MS, autoSignalsDisabled, clearWorkingSending, markWorkingSending, readAutoClaim, readWorkingLease, recordRenewer, stopWorkingLease, writeWorkingLease } from "./auto-signals.js";
|
|
4
4
|
import { _ as acquireListenLock } from "../shared-mail-files-BAQSGxxz.js";
|
|
5
|
-
import { t as sendSignal } from "../signal-command-
|
|
5
|
+
import { t as sendSignal } from "../signal-command-C4Eu4-1-.js";
|
|
6
6
|
import { join } from "node:path";
|
|
7
7
|
import { homedir } from "node:os";
|
|
8
8
|
// src/oclif/auto-signal-worker.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as isPlainChatReply, o as scopedChatSenderTrust } from "../scoped-chat-
|
|
1
|
+
import { n as isPlainChatReply, o as scopedChatSenderTrust } from "../scoped-chat-CaiJJRMA.js";
|
|
2
2
|
import { d as readMailJson, h as writeMailJson, i as mailId, l as privateMailDirectory, r as mailAddress } from "../shared-mail-files-BAQSGxxz.js";
|
|
3
3
|
import { existsSync, readFileSync, readdirSync, unlinkSync, writeFileSync } from "node:fs";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
@@ -1,5 +1,23 @@
|
|
|
1
|
-
import { r as jsonOutputRequested } from "../json-output-
|
|
1
|
+
import { r as jsonOutputRequested } from "../json-output-saHY68hr.js";
|
|
2
2
|
// src/oclif/command-not-found.ts
|
|
3
|
+
/** At most this many commands are suggested for one word. */
|
|
4
|
+
const MOST_SUGGESTED = 3;
|
|
5
|
+
/**
|
|
6
|
+
* The commands in another group named by the word typed where a subcommand
|
|
7
|
+
* was expected, said as a question (`email-rules list-email-rule-objections`
|
|
8
|
+
* is `email-rule-oversight list-email-rule-objections`), or "" when there are
|
|
9
|
+
* none or too many to be a likely meaning. Only those words are looked up,
|
|
10
|
+
* never a value typed after them, which can be any word at all.
|
|
11
|
+
*/
|
|
12
|
+
function elsewhere(words, lookup) {
|
|
13
|
+
for (const word of words) {
|
|
14
|
+
const ids = lookup.named?.(word) ?? [];
|
|
15
|
+
if (ids.length === 0) continue;
|
|
16
|
+
if (ids.length > MOST_SUGGESTED) return "";
|
|
17
|
+
return ` Did you mean ${ids.map((id) => `"primitive ${id.split(":").join(" ")}"`).join(" or ")}?`;
|
|
18
|
+
}
|
|
19
|
+
return "";
|
|
20
|
+
}
|
|
3
21
|
/**
|
|
4
22
|
* What to say for an id no command has. oclif joins every word before the
|
|
5
23
|
* first flag into the id while no command along the way takes arguments, so
|
|
@@ -18,7 +36,7 @@ function commandNotFoundMessage(id, lookup) {
|
|
|
18
36
|
const rest = parts.slice(end).join(" ");
|
|
19
37
|
if (topic || !command) return {
|
|
20
38
|
code: "command_not_found",
|
|
21
|
-
message: `Unknown command "${typed}". Run "${shown} --help" to see the commands under it.`
|
|
39
|
+
message: `Unknown command "${typed}".${elsewhere(parts.slice(end, end + 1), lookup)} Run "${shown} --help" to see the commands under it.`
|
|
22
40
|
};
|
|
23
41
|
if (command.takesArguments) return {
|
|
24
42
|
code: "command_not_found",
|
|
@@ -31,7 +49,7 @@ function commandNotFoundMessage(id, lookup) {
|
|
|
31
49
|
}
|
|
32
50
|
return {
|
|
33
51
|
code: "command_not_found",
|
|
34
|
-
message: `Unknown command "${typed}". Run "primitive --help" to see the commands.`
|
|
52
|
+
message: `Unknown command "${typed}".${elsewhere(parts.slice(0, 2), lookup)} Run "primitive --help" to see the commands.`
|
|
35
53
|
};
|
|
36
54
|
}
|
|
37
55
|
/**
|
|
@@ -46,7 +64,8 @@ const hook = async (options) => {
|
|
|
46
64
|
const command = config.findCommand(id);
|
|
47
65
|
return command ? { takesArguments: Object.keys(command.args ?? {}).length > 0 } : void 0;
|
|
48
66
|
},
|
|
49
|
-
hasSubcommands: (id) => config.commandIDs.some((other) => other.startsWith(`${id}:`))
|
|
67
|
+
hasSubcommands: (id) => config.commandIDs.some((other) => other.startsWith(`${id}:`)),
|
|
68
|
+
named: (word) => config.commands.filter((command) => !command.hidden && command.id.split(":").at(-1) === word).map((command) => command.id).sort()
|
|
50
69
|
});
|
|
51
70
|
if (jsonOutputRequested([...process.argv.slice(2), ...options.argv ?? []])) process.stdout.write(`${JSON.stringify({
|
|
52
71
|
error: {
|