primcli 1.75.0 → 3.0.0-preview.1
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 +116 -63
- package/bin/claude-pending-mail.mjs +1 -1
- package/bin/run.js +14 -0
- package/dist/{api-command-rlS3eTlZ.js → api-command-ctHBqTL5.js} +752 -56
- package/dist/{cli-config-B80p0pLk.js → cli-config-Ms_0vNjq.js} +59 -16
- package/dist/{machine-session-Cq_nD5eF.js → machine-session-Cp_eQ9t_.js} +25 -12
- package/dist/{notify-session-CbY4FYUt.js → notify-session-BN0JTPZ3.js} +334 -4
- package/dist/oclif/auto-signal-worker.js +3 -3
- package/dist/oclif/auto-signals.js +2 -2
- package/dist/oclif/global-org-flag.js +76 -0
- package/dist/oclif/index.js +112940 -51725
- package/dist/oclif/receiver-heal.js +3 -3
- package/dist/oclif/root-signup-hint.js +2 -2
- package/dist/receiver.d.ts +95 -0
- package/dist/receiver.js +569 -0
- package/dist/{repeats-Dj_o6c-X-LyCkKYjp.js → repeats-Dj_o6c-X-Bf9G0xds.js} +4916 -2382
- package/dist/{scoped-chat-B0thCwME.js → scoped-chat-DZ42V3jq.js} +1 -1
- package/dist/{signal-command-DCPsJBdz.js → signal-command-CRUMUCNa.js} +9 -8
- package/man/primitive.1 +34 -0
- package/package.json +53 -8
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// src/oclif/global-org-flag.ts
|
|
2
|
+
/**
|
|
3
|
+
* The global `--org <org>` flag. bin/run.js takes it out of argv before oclif
|
|
4
|
+
* parses the command, so every command accepts it, and passes it on as
|
|
5
|
+
* PRIMITIVE_CLI_ORG. Only a saved `primitive login` made as yourself can switch
|
|
6
|
+
* organizations; every other credential refuses a different organization.
|
|
7
|
+
*
|
|
8
|
+
* No oclif import here: this runs before oclif loads.
|
|
9
|
+
*/
|
|
10
|
+
/** Selects the organization for one command. */
|
|
11
|
+
const ORG_SELECTION_ENV = "PRIMITIVE_CLI_ORG";
|
|
12
|
+
/** Split `--org <value>` and `--org=<value>` out of argv, before any `--`. */
|
|
13
|
+
function extractGlobalOrgFlag(argv) {
|
|
14
|
+
const separator = argv.indexOf("--");
|
|
15
|
+
const head = separator === -1 ? [...argv] : argv.slice(0, separator);
|
|
16
|
+
const tail = separator === -1 ? [] : argv.slice(separator);
|
|
17
|
+
const command = head[0] ?? "";
|
|
18
|
+
if (command === "memories" || command.startsWith("memories:")) return {
|
|
19
|
+
ok: true,
|
|
20
|
+
argv: [...argv],
|
|
21
|
+
org: null
|
|
22
|
+
};
|
|
23
|
+
const kept = [];
|
|
24
|
+
let org = null;
|
|
25
|
+
for (let index = 0; index < head.length; index += 1) {
|
|
26
|
+
const arg = head[index];
|
|
27
|
+
if (arg === "--org") {
|
|
28
|
+
const value = head[index + 1];
|
|
29
|
+
if (value === void 0 || value.startsWith("-") || !value.trim()) return {
|
|
30
|
+
ok: false,
|
|
31
|
+
message: "--org needs an organization id or name, for example `--org acme`."
|
|
32
|
+
};
|
|
33
|
+
org = value.trim();
|
|
34
|
+
index += 1;
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
if (arg.startsWith("--org=")) {
|
|
38
|
+
const value = arg.slice(6).trim();
|
|
39
|
+
if (!value) return {
|
|
40
|
+
ok: false,
|
|
41
|
+
message: "--org needs an organization id or name, for example `--org=acme`."
|
|
42
|
+
};
|
|
43
|
+
org = value;
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
kept.push(arg);
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
ok: true,
|
|
50
|
+
argv: [...kept, ...tail],
|
|
51
|
+
org
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Apply the flag to this process: strip it from `process.argv` and set
|
|
56
|
+
* PRIMITIVE_CLI_ORG. Returns an error message for a malformed flag.
|
|
57
|
+
*/
|
|
58
|
+
function applyGlobalOrgFlag(processArgv = process.argv, env = process.env) {
|
|
59
|
+
const parsed = extractGlobalOrgFlag(processArgv.slice(2));
|
|
60
|
+
if (!parsed.ok) return parsed.message;
|
|
61
|
+
if (parsed.org !== null) {
|
|
62
|
+
processArgv.splice(2, processArgv.length - 2, ...parsed.argv);
|
|
63
|
+
env[ORG_SELECTION_ENV] = parsed.org;
|
|
64
|
+
}
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* `env` without an organization selection, for a child that acts as a
|
|
69
|
+
* connected agent profile: the profile acts in its own organization.
|
|
70
|
+
*/
|
|
71
|
+
function withoutOrgSelection(env) {
|
|
72
|
+
const next = { ...env };
|
|
73
|
+
delete next[ORG_SELECTION_ENV];
|
|
74
|
+
return next;
|
|
75
|
+
}
|
|
76
|
+
export { ORG_SELECTION_ENV, applyGlobalOrgFlag, extractGlobalOrgFlag, withoutOrgSelection };
|