primcli 1.74.1 → 1.75.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/README.md +49 -9
- package/dist/{api-command-fKP3NYa7.js → api-command-rlS3eTlZ.js} +77 -43
- package/dist/{cli-config-C0Y_Ppol.js → cli-config-B80p0pLk.js} +7 -12
- package/dist/{client.gen-CaaMP86o.js → client.gen-6rZvmHfx.js} +7 -14
- package/dist/{json-output-Ce10AsSb.js → json-output-BzSBR-KX.js} +1 -2
- package/dist/{listen-background-cD6n8VYO.js → listen-background-C0F9gNDD.js} +2 -3
- package/dist/{machine-session-B6V5-grn.js → machine-session-Cq_nD5eF.js} +144 -92
- package/dist/{notify-session-DJAb9SGm.js → notify-session-CbY4FYUt.js} +10 -30
- package/dist/oclif/auto-signal-worker.js +5 -6
- package/dist/oclif/auto-signals.js +3 -4
- package/dist/oclif/help.js +127 -0
- package/dist/oclif/index.js +414 -344
- package/dist/oclif/listen-supervisor.js +1 -1
- package/dist/oclif/proxy-auto-detect.js +2 -3
- package/dist/oclif/receiver-heal.js +6 -6
- package/dist/oclif/root-signup-hint.js +2 -3
- package/dist/{repeats-BL7ZC-_6-B_ESsWTH.js → repeats-Dj_o6c-X-LyCkKYjp.js} +552 -213
- package/dist/{scoped-chat-DAiOb622.js → scoped-chat-B0thCwME.js} +3 -5
- package/dist/{shared-mail-files-CZfm7E2k.js → shared-mail-files-BAQSGxxz.js} +2 -4
- package/dist/{shared-mail-watch-DyQB0MK0.js → shared-mail-watch-BAPMsFNv.js} +2 -3
- package/dist/{signal-command-Cte4mAL3.js → signal-command-DCPsJBdz.js} +14 -23
- package/dist/skills/primitive-connect/references/connect.md +3 -1
- package/dist/skills/primitive-connect/references/contacts.md +9 -4
- package/dist/skills/primitive-connect.json +4 -4
- package/man/primitive.1 +10 -3
- package/package.json +14 -9
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { Help } from "@oclif/core";
|
|
2
|
+
// src/oclif/help.ts
|
|
3
|
+
const FULL_HELP_FLAG = "--help-full";
|
|
4
|
+
const NON_TTY_WIDTH = 100;
|
|
5
|
+
const MAX_FLAG_NAME_WIDTH = 32;
|
|
6
|
+
const EXAMPLE_LIMIT = 2;
|
|
7
|
+
/**
|
|
8
|
+
* Commands whose `--help` text is read as a capability check by code already
|
|
9
|
+
* on users' machines: the bundled primitive-connect skill's preflight and
|
|
10
|
+
* agent guidance, and the Claude wake hook, match phrases from these
|
|
11
|
+
* descriptions. They keep the full text on `--help` so those checks still pass.
|
|
12
|
+
*/
|
|
13
|
+
const FULL_HELP_COMMANDS = /* @__PURE__ */ new Set([
|
|
14
|
+
"agent:check-mail",
|
|
15
|
+
"agent:connect",
|
|
16
|
+
"agent:enroll",
|
|
17
|
+
"listen",
|
|
18
|
+
"signal"
|
|
19
|
+
]);
|
|
20
|
+
function renderTemplate(text, bin) {
|
|
21
|
+
return text.replaceAll(/<%=\s*config\.bin\s*%>/g, bin);
|
|
22
|
+
}
|
|
23
|
+
/** The first sentence of the first paragraph, on one line. */
|
|
24
|
+
function firstSentence(text) {
|
|
25
|
+
const line = (text.trim().split(/\n\s*\n/, 1)[0] ?? "").replaceAll(/\s+/g, " ").trim();
|
|
26
|
+
const end = /[.!?](?=\s+[A-Z`(]|$)/.exec(line);
|
|
27
|
+
return end ? line.slice(0, end.index + 1) : line;
|
|
28
|
+
}
|
|
29
|
+
function clip(line, width) {
|
|
30
|
+
return line.length <= width ? line : `${line.slice(0, width - 3).trimEnd()}...`;
|
|
31
|
+
}
|
|
32
|
+
function flagName(name, flag) {
|
|
33
|
+
const long = flag.type === "boolean" && flag.allowNo ? `--${name}, --no-${name}` : `--${name}`;
|
|
34
|
+
const value = flag.type === "option" ? `=${typeof flag.helpValue === "string" ? flag.helpValue : "<value>"}${flag.multiple ? "..." : ""}` : "";
|
|
35
|
+
return `${flag.char ? `-${flag.char}, ` : ""}${long}${value}`;
|
|
36
|
+
}
|
|
37
|
+
function usageLine(command, bin) {
|
|
38
|
+
const args = Object.entries(command.args ?? {}).filter(([, arg]) => !arg.hidden).map(([name, arg]) => arg.required ? name.toUpperCase() : `[${name.toUpperCase()}]`);
|
|
39
|
+
return [
|
|
40
|
+
"$",
|
|
41
|
+
bin,
|
|
42
|
+
command.id,
|
|
43
|
+
...args,
|
|
44
|
+
"[flags]"
|
|
45
|
+
].join(" ");
|
|
46
|
+
}
|
|
47
|
+
/** A shell line that runs the CLI, alone, after a pipe, or after env assignments. */
|
|
48
|
+
function runsBin(line, bin) {
|
|
49
|
+
return line.split("|").some((part) => part.trim().replace(/^(?:[A-Z_][A-Z0-9_]*=\S*\s+)*/, "").startsWith(`${bin} `));
|
|
50
|
+
}
|
|
51
|
+
function exampleCommands(example, bin) {
|
|
52
|
+
return (typeof example === "string" ? example.split("\n").map((line) => line.trim()) : [example.command.trim()]).map((line) => renderTemplate(line, bin)).filter((line) => line.startsWith("$ ") || runsBin(line, bin)).map((line) => line.startsWith("$ ") ? line : `$ ${line}`);
|
|
53
|
+
}
|
|
54
|
+
function section(header, lines) {
|
|
55
|
+
return lines.length === 0 ? [] : [
|
|
56
|
+
"",
|
|
57
|
+
header,
|
|
58
|
+
...lines.map((line) => ` ${line}`)
|
|
59
|
+
];
|
|
60
|
+
}
|
|
61
|
+
/** A rule the parser enforces, kept in front so clipping never drops it. */
|
|
62
|
+
function flagRule(flag) {
|
|
63
|
+
if (flag.required) return "(required) ";
|
|
64
|
+
if (flag.exactlyOne?.length) return `(exactly one of ${flag.exactlyOne.map((name) => `--${name}`).join(", ")}) `;
|
|
65
|
+
return "";
|
|
66
|
+
}
|
|
67
|
+
/** One screen of help: what the command does, how to call it, and each flag in a line. */
|
|
68
|
+
function formatShortHelp(command, { bin, subcommands = [], width }) {
|
|
69
|
+
const render = (text) => renderTemplate(text, bin);
|
|
70
|
+
const summary = render(command.summary ?? firstSentence(command.description ?? ""));
|
|
71
|
+
const flags = Object.entries(command.flags ?? {}).filter(([, flag]) => !flag.hidden).sort(([a], [b]) => a.localeCompare(b)).map(([name, flag]) => ({
|
|
72
|
+
name: flagName(name, flag),
|
|
73
|
+
text: flagRule(flag) + render(firstSentence(flag.summary ?? flag.description ?? ""))
|
|
74
|
+
}));
|
|
75
|
+
const nameWidth = Math.min(MAX_FLAG_NAME_WIDTH, Math.max(0, ...flags.map(({ name }) => name.length)));
|
|
76
|
+
const listLine = (name, text) => clip(text ? ` ${name.padEnd(nameWidth)} ${text}` : ` ${name}`, width).slice(2);
|
|
77
|
+
const examples = (command.examples ?? []).flatMap((example) => exampleCommands(example, bin)).slice(0, EXAMPLE_LIMIT);
|
|
78
|
+
return [
|
|
79
|
+
...summary ? [summary] : [],
|
|
80
|
+
...section("USAGE", [usageLine(command, bin)]),
|
|
81
|
+
...section("FLAGS", flags.map(({ name, text }) => listLine(name, text))),
|
|
82
|
+
...section("COMMANDS", subcommands.map(({ id, summary: text }) => listLine(id, render(firstSentence(text ?? ""))))),
|
|
83
|
+
...section("EXAMPLES", examples),
|
|
84
|
+
"",
|
|
85
|
+
`Full help: ${bin} ${command.id} ${FULL_HELP_FLAG}`
|
|
86
|
+
].join("\n");
|
|
87
|
+
}
|
|
88
|
+
function terminalWidth() {
|
|
89
|
+
return process.stdout.isTTY && process.stdout.columns ? process.stdout.columns : NON_TTY_WIDTH;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Command help is short by default because agents read it into their context.
|
|
93
|
+
* `--help-full` prints oclif's full help.
|
|
94
|
+
*/
|
|
95
|
+
var PrimitiveHelp = class extends Help {
|
|
96
|
+
full = false;
|
|
97
|
+
async showHelp(argv) {
|
|
98
|
+
this.full = argv.includes(FULL_HELP_FLAG);
|
|
99
|
+
await super.showHelp(argv);
|
|
100
|
+
}
|
|
101
|
+
async showCommandHelp(command) {
|
|
102
|
+
if (this.full || FULL_HELP_COMMANDS.has(command.id)) {
|
|
103
|
+
await super.showCommandHelp(command);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
const depth = command.id.split(":").length;
|
|
107
|
+
const subcommands = this.sortedCommands.filter((sub) => sub.id.startsWith(`${command.id}:`) && sub.id.split(":").length === depth + 1).map((sub) => ({
|
|
108
|
+
id: sub.id.replaceAll(":", " "),
|
|
109
|
+
summary: sub.summary ?? sub.description
|
|
110
|
+
}));
|
|
111
|
+
const loaded = await command.load();
|
|
112
|
+
const flags = Object.fromEntries(Object.entries(command.flags ?? {}).map(([name, flag]) => [name, {
|
|
113
|
+
...flag,
|
|
114
|
+
exactlyOne: loaded.flags?.[name]?.exactlyOne
|
|
115
|
+
}]));
|
|
116
|
+
this.log(formatShortHelp({
|
|
117
|
+
...command,
|
|
118
|
+
flags,
|
|
119
|
+
id: command.id.replaceAll(":", " ")
|
|
120
|
+
}, {
|
|
121
|
+
bin: this.config.bin,
|
|
122
|
+
subcommands,
|
|
123
|
+
width: terminalWidth()
|
|
124
|
+
}));
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
export { FULL_HELP_COMMANDS, FULL_HELP_FLAG, PrimitiveHelp as default };
|