@postplus/cli 0.1.21 → 0.1.22
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.
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { readLocalConfig, updateLocalConfig } from './local-state.js';
|
|
3
|
+
export const POSTPLUS_CLIENT_CONTRACT_VERSION = 1;
|
|
4
|
+
export const POSTPLUS_CLIENT_RUNTIME = 'postplus-cli';
|
|
5
|
+
export const POSTPLUS_CLIENT_COMPATIBILITY_HEADERS = {
|
|
6
|
+
cliVersion: 'x-postplus-cli-version',
|
|
7
|
+
contractVersion: 'x-postplus-client-contract-version',
|
|
8
|
+
runtime: 'x-postplus-client-runtime',
|
|
9
|
+
skillCatalogRevision: 'x-postplus-skill-catalog-revision',
|
|
10
|
+
skillName: 'x-postplus-skill-name',
|
|
11
|
+
};
|
|
12
|
+
export async function buildPostPlusClientCompatibilityHeaders(input = {}) {
|
|
13
|
+
const [cliVersion, config] = await Promise.all([
|
|
14
|
+
readCurrentCliVersion(),
|
|
15
|
+
readLocalConfig(),
|
|
16
|
+
]);
|
|
17
|
+
const headers = {
|
|
18
|
+
[POSTPLUS_CLIENT_COMPATIBILITY_HEADERS.cliVersion]: cliVersion,
|
|
19
|
+
[POSTPLUS_CLIENT_COMPATIBILITY_HEADERS.contractVersion]: String(POSTPLUS_CLIENT_CONTRACT_VERSION),
|
|
20
|
+
[POSTPLUS_CLIENT_COMPATIBILITY_HEADERS.runtime]: POSTPLUS_CLIENT_RUNTIME,
|
|
21
|
+
};
|
|
22
|
+
const skillCatalogRevision = config?.managedSkills?.revision?.trim();
|
|
23
|
+
const skillName = input.skillName?.trim();
|
|
24
|
+
if (skillCatalogRevision) {
|
|
25
|
+
headers[POSTPLUS_CLIENT_COMPATIBILITY_HEADERS.skillCatalogRevision] =
|
|
26
|
+
skillCatalogRevision;
|
|
27
|
+
}
|
|
28
|
+
if (skillName) {
|
|
29
|
+
headers[POSTPLUS_CLIENT_COMPATIBILITY_HEADERS.skillName] = skillName;
|
|
30
|
+
}
|
|
31
|
+
return headers;
|
|
32
|
+
}
|
|
33
|
+
export async function writeCurrentCliVersionToLocalConfig() {
|
|
34
|
+
const cliVersion = await readCurrentCliVersion();
|
|
35
|
+
await updateLocalConfig((current) => ({
|
|
36
|
+
...(current ?? {}),
|
|
37
|
+
cliVersion,
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
export async function readCurrentCliVersion() {
|
|
41
|
+
const packageJsonPath = new URL('../package.json', import.meta.url);
|
|
42
|
+
const raw = await readFile(packageJsonPath, 'utf8');
|
|
43
|
+
const parsed = JSON.parse(raw);
|
|
44
|
+
if (typeof parsed.version !== 'string' || !parsed.version.trim()) {
|
|
45
|
+
throw new Error('Could not read the current PostPlus CLI version.');
|
|
46
|
+
}
|
|
47
|
+
return parsed.version.trim();
|
|
48
|
+
}
|
|
49
|
+
export function formatPostPlusClientUpgradeError(payload) {
|
|
50
|
+
const record = payload && typeof payload === 'object' && !Array.isArray(payload)
|
|
51
|
+
? payload
|
|
52
|
+
: {};
|
|
53
|
+
const cliCommand = record.compatibility?.upgrade?.cli?.command ??
|
|
54
|
+
'npm install -g @postplus/cli';
|
|
55
|
+
const skillsCommand = record.compatibility?.upgrade?.skills?.command ?? 'postplus update';
|
|
56
|
+
const restart = record.compatibility?.upgrade?.restartAgentSession
|
|
57
|
+
? ' Then restart your agent session.'
|
|
58
|
+
: '';
|
|
59
|
+
return [
|
|
60
|
+
typeof record.error === 'string' && record.error.trim().length > 0
|
|
61
|
+
? record.error.trim()
|
|
62
|
+
: 'Your PostPlus CLI or PostPlus skills are out of date.',
|
|
63
|
+
`Update CLI: ${cliCommand}.`,
|
|
64
|
+
`Update skills: ${skillsCommand}.`,
|
|
65
|
+
restart.trim(),
|
|
66
|
+
]
|
|
67
|
+
.filter(Boolean)
|
|
68
|
+
.join(' ');
|
|
69
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@postplus/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.22",
|
|
4
4
|
"packageManager": "pnpm@10.30.3+sha512.c961d1e0a2d8e354ecaa5166b822516668b7f44cb5bd95122d590dd81922f606f5473b6d23ec4a5be05e7fcd18e8488d47d978bbe981872f1145d06e9a740017",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "PostPlus CLI for PostPlus Cloud auth, status, and diagnostics.",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"build/auth-session.js",
|
|
12
12
|
"build/auth-validate.js",
|
|
13
13
|
"build/auth.js",
|
|
14
|
+
"build/client-compatibility.js",
|
|
14
15
|
"build/command-runner.js",
|
|
15
16
|
"build/doctor.js",
|
|
16
17
|
"build/hosted-release.js",
|