@postplus/cli 0.1.23 → 0.1.25
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 +1 -1
- package/build/auth-lifecycle.js +2 -1
- package/build/auth-validate.js +29 -6
- package/build/client-compatibility.js +1 -1
- package/build/doctor.js +3 -6
- package/build/index.js +5 -1
- package/build/local-dependencies.js +4 -1
- package/build/subscription-status.js +27 -0
- package/build/update-check.js +48 -2
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -31,7 +31,7 @@ PostPlus has three public surfaces that work together:
|
|
|
31
31
|
Requires Node.js and npm.
|
|
32
32
|
|
|
33
33
|
```bash
|
|
34
|
-
npm install -g @postplus/cli
|
|
34
|
+
npm install -g @postplus/cli@latest
|
|
35
35
|
postplus auth login
|
|
36
36
|
npx -y skills add PostPlusAI/postplus-skills --global --full-depth --skill '*' --agent claude-code codex cursor github-copilot windsurf trae trae-cn --yes
|
|
37
37
|
```
|
package/build/auth-lifecycle.js
CHANGED
|
@@ -3,6 +3,7 @@ import { clearAuthState, generateAuthStatusReport } from './auth.js';
|
|
|
3
3
|
import { buildPostPlusClientCompatibilityHeaders, formatPostPlusCompatibilityError, } from './client-compatibility.js';
|
|
4
4
|
import { requireHostedBaseUrl } from './hosted-release.js';
|
|
5
5
|
import { resolveCliSessionTokenState } from './local-state.js';
|
|
6
|
+
import { readSubscriptionStatusField } from './subscription-status.js';
|
|
6
7
|
export async function refreshRemoteAuth() {
|
|
7
8
|
const refreshed = await refreshRemoteAuthSession();
|
|
8
9
|
return {
|
|
@@ -22,7 +23,7 @@ export function formatAuthRefreshReport(report) {
|
|
|
22
23
|
`PostPlus Cloud: ${report.apiBaseUrl}`,
|
|
23
24
|
`Account: ${report.accountId}`,
|
|
24
25
|
`User: ${report.userEmail ?? report.userId}`,
|
|
25
|
-
`Subscription: ${report.
|
|
26
|
+
`Subscription: ${readSubscriptionStatusField(report).label}`,
|
|
26
27
|
].join('\n');
|
|
27
28
|
}
|
|
28
29
|
export async function revokeRemoteAuth() {
|
package/build/auth-validate.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { resolveFreshRemoteAuth } from './auth-session.js';
|
|
2
2
|
import { buildPostPlusClientCompatibilityHeaders, formatPostPlusCompatibilityError, } from './client-compatibility.js';
|
|
3
|
+
import { readSubscriptionStatusField } from './subscription-status.js';
|
|
3
4
|
export async function validateRemoteAuth() {
|
|
4
5
|
let auth = await resolveFreshRemoteAuth();
|
|
5
6
|
let response = await fetchWhoami(auth);
|
|
@@ -19,15 +20,20 @@ export async function validateRemoteAuth() {
|
|
|
19
20
|
? payload.error
|
|
20
21
|
: 'Failed to validate remote PostPlus auth.');
|
|
21
22
|
}
|
|
22
|
-
const
|
|
23
|
+
const hasSubscriptionStatus = Object.prototype.hasOwnProperty.call(payload, 'subscriptionStatus');
|
|
24
|
+
const accountId = readRequiredString(payload, 'accountId');
|
|
25
|
+
const userId = readRequiredString(payload, 'userId');
|
|
26
|
+
const userEmail = readNullableString(payload, 'userEmail');
|
|
23
27
|
return {
|
|
24
|
-
accountId
|
|
28
|
+
accountId,
|
|
25
29
|
apiBaseUrl: auth.apiBaseUrl,
|
|
26
30
|
ok: true,
|
|
27
31
|
source: auth.source,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
32
|
+
...(hasSubscriptionStatus
|
|
33
|
+
? { subscriptionStatus: payload.subscriptionStatus }
|
|
34
|
+
: {}),
|
|
35
|
+
userEmail,
|
|
36
|
+
userId,
|
|
31
37
|
};
|
|
32
38
|
}
|
|
33
39
|
export function formatAuthValidateReport(report) {
|
|
@@ -38,7 +44,7 @@ export function formatAuthValidateReport(report) {
|
|
|
38
44
|
`PostPlus Cloud: ${report.apiBaseUrl}`,
|
|
39
45
|
`Account: ${report.accountId}`,
|
|
40
46
|
`User: ${report.userEmail ?? report.userId}`,
|
|
41
|
-
`Subscription: ${report.
|
|
47
|
+
`Subscription: ${readSubscriptionStatusField(report).label}`,
|
|
42
48
|
].join('\n');
|
|
43
49
|
}
|
|
44
50
|
async function fetchWhoami(input) {
|
|
@@ -53,3 +59,20 @@ async function fetchWhoami(input) {
|
|
|
53
59
|
signal: AbortSignal.timeout(15000),
|
|
54
60
|
});
|
|
55
61
|
}
|
|
62
|
+
function readRequiredString(payload, fieldName) {
|
|
63
|
+
const value = payload[fieldName];
|
|
64
|
+
if (typeof value !== 'string' || !value.trim()) {
|
|
65
|
+
throw new Error(`Invalid PostPlus auth response: ${fieldName} must be a non-empty string.`);
|
|
66
|
+
}
|
|
67
|
+
return value.trim();
|
|
68
|
+
}
|
|
69
|
+
function readNullableString(payload, fieldName) {
|
|
70
|
+
const value = payload[fieldName];
|
|
71
|
+
if (value === null) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
if (typeof value !== 'string') {
|
|
75
|
+
throw new Error(`Invalid PostPlus auth response: ${fieldName} must be a string or null.`);
|
|
76
|
+
}
|
|
77
|
+
return value;
|
|
78
|
+
}
|
|
@@ -51,7 +51,7 @@ export function formatPostPlusClientUpgradeError(payload) {
|
|
|
51
51
|
? payload
|
|
52
52
|
: {};
|
|
53
53
|
const cliCommand = record.compatibility?.upgrade?.cli?.command ??
|
|
54
|
-
'npm install -g @postplus/cli';
|
|
54
|
+
'npm install -g @postplus/cli@latest';
|
|
55
55
|
const skillsCommand = record.compatibility?.upgrade?.skills?.command ?? 'postplus update';
|
|
56
56
|
const restart = record.compatibility?.upgrade?.restartAgentSession
|
|
57
57
|
? ' Then restart your agent session.'
|
package/build/doctor.js
CHANGED
|
@@ -2,6 +2,7 @@ import { resolveFreshRemoteAuth, } from './auth-session.js';
|
|
|
2
2
|
import { buildPostPlusClientCompatibilityHeaders, formatPostPlusCompatibilityError, } from './client-compatibility.js';
|
|
3
3
|
import { resolveHostedBaseUrl } from './hosted-release.js';
|
|
4
4
|
import { formatLocalDependencyReport, generateLocalDependencyReport, } from './local-dependencies.js';
|
|
5
|
+
import { readSubscriptionStatusField } from './subscription-status.js';
|
|
5
6
|
function createPass(id, label, detail, severity = 'required') {
|
|
6
7
|
return {
|
|
7
8
|
id,
|
|
@@ -104,9 +105,7 @@ async function checkRemoteAuth(input) {
|
|
|
104
105
|
: typeof payload.userId === 'string'
|
|
105
106
|
? payload.userId
|
|
106
107
|
: 'unknown';
|
|
107
|
-
const subscription =
|
|
108
|
-
? payload.subscriptionStatus
|
|
109
|
-
: 'unknown';
|
|
108
|
+
const subscription = readSubscriptionStatusField(payload).label;
|
|
110
109
|
return createPass('remote_auth', 'Remote auth', `Account ${accountId}; user ${user}; subscription ${subscription}`);
|
|
111
110
|
}
|
|
112
111
|
catch (error) {
|
|
@@ -137,9 +136,7 @@ async function checkHostedCapabilities(input) {
|
|
|
137
136
|
if (payload.ok !== true || failedLabels.length > 0) {
|
|
138
137
|
return createFail('hosted_capabilities', 'Hosted capabilities', `Not ready: ${failedLabels.join(', ') || 'unknown capability failure'}`, 'Check PostPlus Cloud provider configuration and subscription state.');
|
|
139
138
|
}
|
|
140
|
-
const subscription =
|
|
141
|
-
? payload.subscriptionStatus
|
|
142
|
-
: 'unknown';
|
|
139
|
+
const subscription = readSubscriptionStatusField(payload).label;
|
|
143
140
|
return createPass('hosted_capabilities', 'Hosted capabilities', `Ready (${capabilities.length} capability checks passed; subscription ${subscription})`);
|
|
144
141
|
}
|
|
145
142
|
catch (error) {
|
package/build/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { assertConfigFilePermissions } from './local-state.js';
|
|
|
9
9
|
import { POSTPLUS_SKILLS_INSTALL_COMMAND, loadPublicSkillCatalog, } from './skill-catalog.js';
|
|
10
10
|
import { runPostPlusSkillUninstall, runPostPlusSkillUpdate, } from './skill-management.js';
|
|
11
11
|
import { formatStatusReport, generateStatusReport } from './status.js';
|
|
12
|
-
import { refreshUpdateCheckCache } from './update-check.js';
|
|
12
|
+
import { refreshUpdateCheckCache, runCliSelfUpdateIfOutdated, } from './update-check.js';
|
|
13
13
|
function printAuthHelp() {
|
|
14
14
|
process.stdout.write(`PostPlus CLI — auth commands
|
|
15
15
|
|
|
@@ -103,6 +103,10 @@ async function runVersion() {
|
|
|
103
103
|
return 0;
|
|
104
104
|
}
|
|
105
105
|
async function runSkillUpdateCommand() {
|
|
106
|
+
const cliSelfUpdate = await runCliSelfUpdateIfOutdated();
|
|
107
|
+
if (cliSelfUpdate.updateAvailable) {
|
|
108
|
+
return cliSelfUpdate.exitCode ?? 1;
|
|
109
|
+
}
|
|
106
110
|
const exitCode = await runPostPlusSkillUpdate();
|
|
107
111
|
if (exitCode === 0) {
|
|
108
112
|
await refreshUpdateCheckCache().catch(() => { });
|
|
@@ -69,9 +69,12 @@ async function checkLocalDependency(dependency, skillIds, runDependencyCheck) {
|
|
|
69
69
|
function buildLocalDependencyCommand(dependency) {
|
|
70
70
|
const parts = dependency.split(':');
|
|
71
71
|
if (parts.length === 1) {
|
|
72
|
+
const args = dependency === 'ffmpeg' || dependency === 'ffprobe'
|
|
73
|
+
? ['-version']
|
|
74
|
+
: ['--version'];
|
|
72
75
|
return {
|
|
73
76
|
command: dependency,
|
|
74
|
-
args
|
|
77
|
+
args,
|
|
75
78
|
};
|
|
76
79
|
}
|
|
77
80
|
const [runtime, moduleName] = parts;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export function readSubscriptionStatusField(payload, fieldName = 'subscriptionStatus') {
|
|
2
|
+
if (!Object.prototype.hasOwnProperty.call(payload, fieldName)) {
|
|
3
|
+
return {
|
|
4
|
+
label: 'unknown',
|
|
5
|
+
state: 'missing',
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
const value = payload[fieldName];
|
|
9
|
+
if (value === null) {
|
|
10
|
+
return {
|
|
11
|
+
label: 'none',
|
|
12
|
+
state: 'none',
|
|
13
|
+
value: null,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
if (typeof value === 'string') {
|
|
17
|
+
return {
|
|
18
|
+
label: value,
|
|
19
|
+
state: 'string',
|
|
20
|
+
value,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
label: 'invalid',
|
|
25
|
+
state: 'invalid',
|
|
26
|
+
};
|
|
27
|
+
}
|
package/build/update-check.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
2
2
|
import { dirname, join } from 'node:path';
|
|
3
3
|
import { readCurrentCliVersion } from './client-compatibility.js';
|
|
4
|
+
import { runInteractiveCommand as runDefaultInteractiveCommand, } from './command-runner.js';
|
|
4
5
|
import { getPostPlusConfigDir, readManagedSkillBaseline, } from './local-state.js';
|
|
5
6
|
import { POSTPLUS_SKILLS_REPO, loadPublicSkillCatalog, } from './skill-catalog.js';
|
|
6
7
|
const UPDATE_CHECK_TTL_MS = 24 * 60 * 60 * 1000;
|
|
7
8
|
const UPDATE_CHECK_CACHE_FILE = 'update-check.json';
|
|
8
9
|
const NPM_PACKAGE_NAME = '@postplus/cli';
|
|
9
10
|
const NPM_LATEST_URL = `https://registry.npmjs.org/${encodeURIComponent(NPM_PACKAGE_NAME)}/latest`;
|
|
11
|
+
export const POSTPLUS_CLI_UPDATE_COMMAND = 'npm install -g @postplus/cli@latest';
|
|
12
|
+
const POSTPLUS_CLI_UPDATE_ARGS = ['install', '-g', '@postplus/cli@latest'];
|
|
10
13
|
export async function generateUpdateStatusReport(input = {}, dependencies = {
|
|
11
14
|
fetchFn: fetch,
|
|
12
15
|
}) {
|
|
@@ -68,7 +71,7 @@ export async function generateUpdateStatusReport(input = {}, dependencies = {
|
|
|
68
71
|
currentVersion,
|
|
69
72
|
latestVersion: null,
|
|
70
73
|
updateAvailable: false,
|
|
71
|
-
updateCommand:
|
|
74
|
+
updateCommand: POSTPLUS_CLI_UPDATE_COMMAND,
|
|
72
75
|
},
|
|
73
76
|
skills: {
|
|
74
77
|
currentReleaseId: managedSkillBaseline.releaseId,
|
|
@@ -85,6 +88,49 @@ export async function refreshUpdateCheckCache() {
|
|
|
85
88
|
force: true,
|
|
86
89
|
});
|
|
87
90
|
}
|
|
91
|
+
export async function runCliSelfUpdateIfOutdated(dependencies = {}) {
|
|
92
|
+
const fetchFn = dependencies.fetchFn ?? fetch;
|
|
93
|
+
const runInteractiveCommand = dependencies.runInteractiveCommand ?? runDefaultInteractiveCommand;
|
|
94
|
+
const writeOutput = dependencies.writeOutput ?? ((message) => process.stdout.write(message));
|
|
95
|
+
const currentVersion = await readCurrentCliVersion();
|
|
96
|
+
const latestVersion = await fetchLatestCliVersion(fetchFn);
|
|
97
|
+
if (compareVersions(latestVersion, currentVersion) <= 0) {
|
|
98
|
+
return {
|
|
99
|
+
command: POSTPLUS_CLI_UPDATE_COMMAND,
|
|
100
|
+
currentVersion,
|
|
101
|
+
exitCode: null,
|
|
102
|
+
latestVersion,
|
|
103
|
+
updateAvailable: false,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
writeOutput([
|
|
107
|
+
`PostPlus CLI ${currentVersion} is older than latest ${latestVersion}.`,
|
|
108
|
+
`Updating CLI: ${POSTPLUS_CLI_UPDATE_COMMAND}`,
|
|
109
|
+
'',
|
|
110
|
+
].join('\n'));
|
|
111
|
+
const exitCode = await runInteractiveCommand('npm', POSTPLUS_CLI_UPDATE_ARGS);
|
|
112
|
+
if (exitCode === 0) {
|
|
113
|
+
writeOutput([
|
|
114
|
+
`PostPlus CLI updated to ${latestVersion}.`,
|
|
115
|
+
'Re-run `postplus update` to update skills with the new CLI process.',
|
|
116
|
+
'',
|
|
117
|
+
].join('\n'));
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
writeOutput([
|
|
121
|
+
`PostPlus CLI update failed with exit code ${exitCode}.`,
|
|
122
|
+
`Fix the npm install error, then run: ${POSTPLUS_CLI_UPDATE_COMMAND}`,
|
|
123
|
+
'',
|
|
124
|
+
].join('\n'));
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
command: POSTPLUS_CLI_UPDATE_COMMAND,
|
|
128
|
+
currentVersion,
|
|
129
|
+
exitCode,
|
|
130
|
+
latestVersion,
|
|
131
|
+
updateAvailable: true,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
88
134
|
export function formatUpdateStatusReport(report) {
|
|
89
135
|
const lines = ['PostPlus update status', ''];
|
|
90
136
|
const cliMarker = report.cli.updateAvailable ? '[WARN]' : '[PASS]';
|
|
@@ -115,7 +161,7 @@ function buildUpdateReport(input) {
|
|
|
115
161
|
latestVersion: input.cache.cli.latestVersion,
|
|
116
162
|
updateAvailable: compareVersions(input.cache.cli.latestVersion, input.currentVersion) >
|
|
117
163
|
0,
|
|
118
|
-
updateCommand:
|
|
164
|
+
updateCommand: POSTPLUS_CLI_UPDATE_COMMAND,
|
|
119
165
|
},
|
|
120
166
|
skills: {
|
|
121
167
|
currentReleaseId: input.currentSkillsReleaseId,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@postplus/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.25",
|
|
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.",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"build/skill-catalog.js",
|
|
22
22
|
"build/skill-management.js",
|
|
23
23
|
"build/status.js",
|
|
24
|
+
"build/subscription-status.js",
|
|
24
25
|
"build/update-check.js",
|
|
25
26
|
"LICENSE",
|
|
26
27
|
"NOTICE",
|