@quadient/skillshare 1.19.1 → 1.20.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 +1 -1
- package/dist/agents-process.js +23 -3
- package/dist/help.js +4 -3
- package/dist/index.js +10 -11
- package/dist/output.js +16 -1
- package/dist/pages-dev-tools.js +4 -4
- package/dist/pages-runtime.js +66 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -397,7 +397,7 @@ bunx @quadient/skillshare@^1.6.0 pages dev . --slug my-app
|
|
|
397
397
|
```
|
|
398
398
|
|
|
399
399
|
The directory must contain one `wrangler.json` or `wrangler.jsonc`. The CLI downloads
|
|
400
|
-
and verifies celld 0.6.
|
|
400
|
+
and verifies celld 0.6.3 on first use, caches it under `~/.cache/skillshare/celld`,
|
|
401
401
|
and uses its packaged esbuild. Supported hosts are macOS Apple Silicon and Linux
|
|
402
402
|
x64/ARM64; Windows users can use WSL2. `--celld <executable>` or `CELLD_EXECUTABLE`
|
|
403
403
|
selects an existing installation.
|
package/dist/agents-process.js
CHANGED
|
@@ -2,6 +2,7 @@ import { spawn } from 'node:child_process';
|
|
|
2
2
|
import { open } from 'node:fs/promises';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
4
|
import { createInterface } from 'node:readline';
|
|
5
|
+
import { setTimeout as delay } from 'node:timers/promises';
|
|
5
6
|
import { resolveAgentCommand } from './agents-executable.js';
|
|
6
7
|
/**
|
|
7
8
|
* Starts an agent that speaks newline-delimited JSON on stdio. Tokens go through the environment only. A separate
|
|
@@ -96,9 +97,11 @@ export async function startAgentProcess(options) {
|
|
|
96
97
|
};
|
|
97
98
|
child.stdin?.end();
|
|
98
99
|
signal('SIGTERM');
|
|
99
|
-
|
|
100
|
-
//
|
|
101
|
-
|
|
100
|
+
// The agent may exit while descendants are still flushing their data, even with no inherited stdio.
|
|
101
|
+
// Give the whole group the grace period; the parent's exit alone must not trigger SIGKILL.
|
|
102
|
+
const stopped = child.pid ? await waitForProcessGroupExit(child.pid) : await bounded(exited, 5000);
|
|
103
|
+
if (!stopped)
|
|
104
|
+
signal('SIGKILL');
|
|
102
105
|
}
|
|
103
106
|
else if (running && child.pid) {
|
|
104
107
|
// Kill the complete tree in one operation. Gracefully ending cmd first loses the descendant PIDs.
|
|
@@ -126,6 +129,23 @@ export async function startAgentProcess(options) {
|
|
|
126
129
|
},
|
|
127
130
|
};
|
|
128
131
|
}
|
|
132
|
+
async function waitForProcessGroupExit(pid) {
|
|
133
|
+
const deadline = performance.now() + 5000;
|
|
134
|
+
while (true) {
|
|
135
|
+
try {
|
|
136
|
+
process.kill(-pid, 0);
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
if (error.code === 'ESRCH')
|
|
140
|
+
return true;
|
|
141
|
+
// An inaccessible group is not proof that its processes have exited. Keep the wait bounded.
|
|
142
|
+
}
|
|
143
|
+
const remaining = deadline - performance.now();
|
|
144
|
+
if (remaining <= 0)
|
|
145
|
+
return false;
|
|
146
|
+
await delay(Math.min(50, remaining));
|
|
147
|
+
}
|
|
148
|
+
}
|
|
129
149
|
async function bounded(promise, milliseconds) {
|
|
130
150
|
let timer;
|
|
131
151
|
try {
|
package/dist/help.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
2
|
export const GLOBAL_FLAGS = ['token', 'server', 'help'];
|
|
3
|
-
export const BOOLEAN_FLAGS = new Set(['all', 'digest', 'disabled', 'dry-run', 'force', 'headless', 'help', 'json', 'keep-unread', 'no-teams-watch', 'no-update', 'notify-again', 'original', 'owners-only', 'resolved', 'review', 'sandbox', 'unread']);
|
|
3
|
+
export const BOOLEAN_FLAGS = new Set(['all', 'digest', 'disabled', 'dry-run', 'force', 'headless', 'help', 'json', 'keep-unread', 'no-teams-watch', 'no-update', 'notify-again', 'original', 'external', 'internal', 'always-on', 'owners-only', 'resolved', 'review', 'sandbox', 'unread']);
|
|
4
4
|
export const COMMANDS = [
|
|
5
5
|
{
|
|
6
6
|
name: 'login',
|
|
@@ -86,6 +86,7 @@ export const COMMANDS = [
|
|
|
86
86
|
'pages list [--json]',
|
|
87
87
|
'pages show <slug> [--json]',
|
|
88
88
|
'pages runtime <slug> [--json]',
|
|
89
|
+
'pages runtime set <slug> [--external|--internal] [--min <MiB>] [--max <MiB>] [--always-on true|false] [--json]',
|
|
89
90
|
'pages upload <directory> [--slug <slug>] [--json]',
|
|
90
91
|
'pages secrets list <slug> [--json]',
|
|
91
92
|
'pages secrets set <slug> <name> [--json]',
|
|
@@ -98,9 +99,9 @@ export const COMMANDS = [
|
|
|
98
99
|
'pages dev [directory] [--slug <slug>] [--port <port>] [--build <command> --watch-dir <sources>]',
|
|
99
100
|
' [--celld <executable>] [--user-id <id>] [--user-name <name>] [--user-email <email>]',
|
|
100
101
|
],
|
|
101
|
-
description: 'An upload replaces all content of the page. Without --slug the directory name is used; build output folders such as dist need an explicit --slug. Pages owned by someone else are refused unless you are an admin. pages secrets manages the write-only secrets an app reads through SKILLSHARE_SECRETS (owner or admin only, at most 32 per page, 16 KiB each); set reads the value from piped stdin or a masked prompt, never from the command line. pages comments reads and writes the annotations reviewers leave on a Page at /pa/<slug>/ (enable and disable decide whether the regular /p/<slug>/ address shows them too); add creates a page note, text without an argument (or -) is read from stdin, and list hides resolved threads unless --resolved is given.',
|
|
102
|
+
description: 'An upload replaces all content of the page. Without --slug the directory name is used; build output folders such as dist need an explicit --slug. Pages owned by someone else are refused unless you are an admin. pages secrets manages the write-only secrets an app reads through SKILLSHARE_SECRETS (owner or admin only, at most 32 per page, 16 KiB each); set reads the value from piped stdin or a masked prompt, never from the command line. pages runtime set is for administrators: --external moves the app into its own pod (its data is copied, the app is briefly unavailable), --internal back into SkillShare; external apps get memory automatically between --min and --max MiB, and --always-on keeps an app running without traffic. pages comments reads and writes the annotations reviewers leave on a Page at /pa/<slug>/ (enable and disable decide whether the regular /p/<slug>/ address shows them too); add creates a page note, text without an argument (or -) is read from stdin, and list hides resolved threads unless --resolved is given.',
|
|
102
103
|
examples: ['skillshare pages upload ./site --slug release-notes', 'skillshare pages dev . --slug my-app', 'skillshare pages secrets set my-app API_TOKEN', 'printf %s "$TOKEN" | skillshare pages secrets set my-app API_TOKEN', 'skillshare pages comments list my-app --author mine', 'skillshare pages comments reply my-app 12 "Fixed in revision 4"'],
|
|
103
|
-
flags: ['slug', 'path', 'author', 'resolved', 'json'],
|
|
104
|
+
flags: ['slug', 'path', 'author', 'resolved', 'external', 'internal', 'min', 'max', 'always-on', 'json'],
|
|
104
105
|
},
|
|
105
106
|
{
|
|
106
107
|
name: 'teams',
|
package/dist/index.js
CHANGED
|
@@ -10,10 +10,11 @@ import { findCommand, readCliVersion, renderCommandHelp, renderUsage } from './h
|
|
|
10
10
|
import { inspectInstallTarget, installFilesAtomically } from './install-files.js';
|
|
11
11
|
import { formatRemovedSkillCleanup, offerRemovedSkillUninstalls } from './removed-skills.js';
|
|
12
12
|
import { preparePageFiles, resolvePageSlug } from './pages.js';
|
|
13
|
-
import { formatByteSize, formatDateTime, pageUrl, plural, renderPageDetail, renderPageList,
|
|
13
|
+
import { formatByteSize, formatDateTime, pageUrl, plural, renderPageDetail, renderPageList, renderSkillDetail, renderSkillList, renderSkillVersion, renderUser, } from './output.js';
|
|
14
14
|
import { runPageDev } from './pages-dev.js';
|
|
15
15
|
import { runPageCommentsCommand } from './pages-comments.js';
|
|
16
16
|
import { runPageSecretsCommand } from './pages-secrets.js';
|
|
17
|
+
import { runPageRuntimeCommand } from './pages-runtime.js';
|
|
17
18
|
import { waitForLoginCallback } from './login-callback.js';
|
|
18
19
|
import { createHash, randomBytes } from 'node:crypto';
|
|
19
20
|
import { spawn } from 'node:child_process';
|
|
@@ -368,18 +369,16 @@ async function main() {
|
|
|
368
369
|
print(pages, () => renderPageList(pages));
|
|
369
370
|
return;
|
|
370
371
|
}
|
|
371
|
-
if (action === '
|
|
372
|
+
if (action === 'runtime') {
|
|
373
|
+
await runPageRuntimeCommand(client, options.positionals.slice(1), options.flags, print);
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
if (action === 'show') {
|
|
372
377
|
const slug = options.positionals[1];
|
|
373
378
|
if (!slug)
|
|
374
|
-
throw new Error(
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
print(page, () => renderPageDetail(page, client.baseUrl));
|
|
378
|
-
}
|
|
379
|
-
else {
|
|
380
|
-
const runtime = await client.get(`/api/pages/${encodeURIComponent(slug)}/runtime`);
|
|
381
|
-
print(runtime, () => renderPageRuntime(slug, runtime));
|
|
382
|
-
}
|
|
379
|
+
throw new Error('pages show requires <slug>');
|
|
380
|
+
const page = await client.get(`/api/pages/${encodeURIComponent(slug)}`);
|
|
381
|
+
print(page, () => renderPageDetail(page, client.baseUrl));
|
|
383
382
|
return;
|
|
384
383
|
}
|
|
385
384
|
if (action === 'upload') {
|
package/dist/output.js
CHANGED
|
@@ -135,11 +135,26 @@ export function renderPageDetail(page, baseUrl, now = new Date()) {
|
|
|
135
135
|
].join('\n');
|
|
136
136
|
}
|
|
137
137
|
export function renderPageRuntime(slug, runtime, logLimit = 20) {
|
|
138
|
+
const settings = runtime.settings;
|
|
138
139
|
const lines = [
|
|
139
|
-
`${slug}: ${runtime.state} · revision ${runtime.revision}${runtime.processId ? ` · pid ${runtime.processId}` : ''}`,
|
|
140
|
+
`${slug}: ${runtime.state} · revision ${runtime.revision}${runtime.processId ? ` · pid ${runtime.processId}` : ''}${settings ? ` · ${settings.placement}` : ''}`,
|
|
140
141
|
];
|
|
141
142
|
if (runtime.error)
|
|
142
143
|
lines.push(`Error: ${runtime.error}`);
|
|
144
|
+
if (settings) {
|
|
145
|
+
lines.push(`Always on: ${settings.alwaysOn ? 'yes' : 'no'}`);
|
|
146
|
+
if (settings.placement === 'external') {
|
|
147
|
+
const memory = runtime.memory;
|
|
148
|
+
const usage = [
|
|
149
|
+
memory?.currentMiB != null ? `using ${memory.currentMiB} MiB` : null,
|
|
150
|
+
memory?.peakMiB != null ? `4-day peak ${memory.peakMiB} MiB` : null,
|
|
151
|
+
memory?.outOfMemoryCount ? `${memory.outOfMemoryCount} out of memory` : null,
|
|
152
|
+
].filter(Boolean);
|
|
153
|
+
lines.push(`Memory: ${settings.limitMiB} MiB, automatic within ${settings.minMiB}–${settings.maxMiB} MiB · CPU ${settings.cpuRequestMilli}m${usage.length ? ` · ${usage.join(' · ')}` : ''}`);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
if (runtime.logsUrl)
|
|
157
|
+
lines.push(`Pod logs: ${runtime.logsUrl}`);
|
|
143
158
|
if (runtime.logs.length > 0) {
|
|
144
159
|
const shown = runtime.logs.slice(-logLimit);
|
|
145
160
|
lines.push('', `Last ${shown.length} of ${runtime.logs.length} log lines${runtime.logs.length > shown.length ? ' (use --json for all)' : ''}:`, ...shown);
|
package/dist/pages-dev-tools.js
CHANGED
|
@@ -3,19 +3,19 @@ import { chmod, mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises'
|
|
|
3
3
|
import { homedir } from 'node:os';
|
|
4
4
|
import { join, resolve } from 'node:path';
|
|
5
5
|
import { gunzipSync } from 'node:zlib';
|
|
6
|
-
const release = '0.6.
|
|
6
|
+
const release = '0.6.3';
|
|
7
7
|
const platforms = {
|
|
8
8
|
'darwin-arm64': [
|
|
9
9
|
'aarch64-apple-darwin',
|
|
10
|
-
'
|
|
10
|
+
'2df6b08369345db8c1f9a5edcf3932cecaa6fb35f4658575a6db17df28c22371',
|
|
11
11
|
],
|
|
12
12
|
'linux-x64': [
|
|
13
13
|
'x86_64-unknown-linux-gnu',
|
|
14
|
-
'
|
|
14
|
+
'5084a083472cf036551a7eac63fa24d22bb9a56323c517f63205724c12783047',
|
|
15
15
|
],
|
|
16
16
|
'linux-arm64': [
|
|
17
17
|
'aarch64-unknown-linux-gnu',
|
|
18
|
-
'
|
|
18
|
+
'6d617cdf9f049e43ca6a4e37c4cce5d8e35395c8e86b371c984d32ba7d803bf5',
|
|
19
19
|
],
|
|
20
20
|
};
|
|
21
21
|
export async function ensureCelld(override, signal) {
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { renderPageRuntime } from './output.js';
|
|
2
|
+
/**
|
|
3
|
+
* `pages runtime <slug>` shows the runtime to its owner or an administrator; `pages runtime set <slug>`
|
|
4
|
+
* lets an administrator move it between SkillShare and its own pod and set its automatic memory range.
|
|
5
|
+
*/
|
|
6
|
+
export async function runPageRuntimeCommand(client, positionals, flags, print) {
|
|
7
|
+
if (positionals[0] === 'set' && positionals[1]) {
|
|
8
|
+
const slug = positionals[1];
|
|
9
|
+
const body = settingsRequest(flags);
|
|
10
|
+
if (Object.keys(body).length === 0) {
|
|
11
|
+
throw new Error('pages runtime set needs --external, --internal, --min <MiB>, --max <MiB> or --always-on true|false');
|
|
12
|
+
}
|
|
13
|
+
const settings = await expect(slug, await client.request(`/api/pages/${encodeURIComponent(slug)}/runtime-settings`, {
|
|
14
|
+
method: 'PUT',
|
|
15
|
+
headers: { 'Content-Type': 'application/json' },
|
|
16
|
+
body: JSON.stringify(body),
|
|
17
|
+
}));
|
|
18
|
+
print(settings, () => `Updated /p/${slug}/: ${settings.placement}, always on ${settings.alwaysOn ? 'yes' : 'no'}, memory ${settings.minMiB}–${settings.maxMiB} MiB (now ${settings.limitMiB} MiB).`);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const slug = positionals[0];
|
|
22
|
+
if (!slug)
|
|
23
|
+
throw new Error('pages runtime requires <slug>');
|
|
24
|
+
const runtime = await expect(slug, await client.request(`/api/pages/${encodeURIComponent(slug)}/runtime`, { method: 'GET' }));
|
|
25
|
+
print(runtime, () => renderPageRuntime(slug, runtime));
|
|
26
|
+
}
|
|
27
|
+
export function settingsRequest(flags) {
|
|
28
|
+
const body = {};
|
|
29
|
+
const external = isTrue(flags.external);
|
|
30
|
+
const internal = isTrue(flags.internal);
|
|
31
|
+
if (external && internal)
|
|
32
|
+
throw new Error('Use either --external or --internal.');
|
|
33
|
+
if (external)
|
|
34
|
+
body.placement = 'external';
|
|
35
|
+
if (internal)
|
|
36
|
+
body.placement = 'internal';
|
|
37
|
+
if (flags.min !== undefined)
|
|
38
|
+
body.minMiB = mebibytes('--min', flags.min);
|
|
39
|
+
if (flags.max !== undefined)
|
|
40
|
+
body.maxMiB = mebibytes('--max', flags.max);
|
|
41
|
+
if (flags['always-on'] !== undefined)
|
|
42
|
+
body.alwaysOn = isTrue(flags['always-on']);
|
|
43
|
+
return body;
|
|
44
|
+
}
|
|
45
|
+
function isTrue(value) {
|
|
46
|
+
return value !== undefined && !['0', 'false', 'no', 'off'].includes(value.toLowerCase());
|
|
47
|
+
}
|
|
48
|
+
function mebibytes(flag, value) {
|
|
49
|
+
if (!/^\d+$/.test(value))
|
|
50
|
+
throw new Error(`${flag} takes a whole number of MiB, for example ${flag} 500.`);
|
|
51
|
+
return Number(value);
|
|
52
|
+
}
|
|
53
|
+
async function expect(slug, response) {
|
|
54
|
+
if (response.ok)
|
|
55
|
+
return await response.json();
|
|
56
|
+
if (response.status === 403)
|
|
57
|
+
throw new Error(`Only an administrator can change the runtime of /p/${slug}/; its owner can view it.`);
|
|
58
|
+
if (response.status === 404)
|
|
59
|
+
throw new Error(`Page /p/${slug}/ was not found.`);
|
|
60
|
+
let error = {};
|
|
61
|
+
try {
|
|
62
|
+
error = await response.json();
|
|
63
|
+
}
|
|
64
|
+
catch { }
|
|
65
|
+
throw new Error(error.error ?? `Skillshare returned HTTP ${response.status} for the Page runtime.`);
|
|
66
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quadient/skillshare",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.20.0",
|
|
4
4
|
"description": "Skillshare CLI for installing and publishing Quadient skills",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"build": "rm -rf dist && tsc -p tsconfig.build.json && node -e \"require('node:fs').copyFileSync('page-browser-client.js', 'dist/page-browser-client.js')\"",
|
|
17
17
|
"start": "node ./dist/index.js",
|
|
18
18
|
"prepublishOnly": "npm run build",
|
|
19
|
-
"test": "tsx --test session-auth.test.ts cli-args.test.ts install-files.test.ts removed-skills.test.ts output.test.ts pages.test.ts page-links.test.ts pages-secrets.test.ts pages-comments.test.ts news.test.ts pages-dev.test.ts teams-auth.test.ts teams-watch.test.ts teams-browser.test.ts salesforce.test.ts agents.test.ts agents-detection.test.ts agents-process.test.ts agents-probe.test.ts agents-lockdown.test.ts agents-approvals.test.ts agents-native-forms.test.ts agents-delivery.test.ts agents-request-upload.test.ts agents-update.test.ts login-callback.test.ts"
|
|
19
|
+
"test": "tsx --test session-auth.test.ts cli-args.test.ts install-files.test.ts removed-skills.test.ts output.test.ts pages.test.ts page-links.test.ts pages-secrets.test.ts pages-runtime.test.ts pages-comments.test.ts news.test.ts pages-dev.test.ts teams-auth.test.ts teams-watch.test.ts teams-browser.test.ts salesforce.test.ts agents.test.ts agents-detection.test.ts agents-process.test.ts agents-probe.test.ts agents-lockdown.test.ts agents-approvals.test.ts agents-native-forms.test.ts agents-delivery.test.ts agents-request-upload.test.ts agents-update.test.ts login-callback.test.ts"
|
|
20
20
|
},
|
|
21
21
|
"publishConfig": {
|
|
22
22
|
"access": "public"
|