@quadient/skillshare 1.15.0 → 1.15.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.
@@ -67,7 +67,10 @@ export function npmCommand() {
67
67
  * Installs a CLI version into its own directory under versions, without touching a global install, so no administrator
68
68
  * rights are needed. It lands under a temporary name first, so a listener never starts a half-installed version.
69
69
  */
70
+ export const isReleaseVersion = (version) => /^\d{1,6}\.\d{1,6}\.\d{1,6}$/.test(version);
70
71
  export async function installVersion(appDir, version, options = {}) {
72
+ if (!isReleaseVersion(version))
73
+ throw new Error(`Refusing to install an invalid CLI version "${version}".`);
71
74
  if ((await installedVersions(appDir)).includes(version))
72
75
  return;
73
76
  const target = join(versionsDirectory(appDir), version);
@@ -79,7 +82,8 @@ export async function installVersion(appDir, version, options = {}) {
79
82
  await writeFile(join(staging, 'package.json'), JSON.stringify({ private: true }));
80
83
  const npm = npmCommand();
81
84
  const result = await (options.run ?? runCommand)(npm.command, [...npm.args, 'install', '--prefix', staging, '--no-audit', '--no-fund',
82
- '--omit=dev', '--no-package-lock', options.spec ?? `${PACKAGE_NAME}@${version}`], { cwd: staging });
85
+ // Package scripts never run during an update; the CLI and its dependencies do not need them.
86
+ '--omit=dev', '--no-package-lock', '--ignore-scripts', options.spec ?? `${PACKAGE_NAME}@${version}`], { cwd: staging });
83
87
  if (result.code !== 0)
84
88
  throw new Error(`npm could not install ${PACKAGE_NAME}@${version}: ${lastLine(result.stderr) || `exit code ${result.code}`}`);
85
89
  const installed = join(staging, 'node_modules', '@quadient', 'skillshare');
package/dist/agents.js CHANGED
@@ -8,7 +8,7 @@ import { defaultServiceEnvironment, detectServiceAgents, installService, renderS
8
8
  import { createCodexDriver } from './agents-codex.js';
9
9
  import { detectAgents, expandHome, profilesPath } from './agents-detect.js';
10
10
  import { SessionRunner, errorMessage, } from './agents-session.js';
11
- import { RESTART_FOR_UPDATE, SERVICE_ENV, WORKER_ENV, acquireListenerLock, compareVersions, describeOtherListener, installVersion, releaseListenerLock, superviseListener, } from './agents-update.js';
11
+ import { RESTART_FOR_UPDATE, SERVICE_ENV, WORKER_ENV, acquireListenerLock, compareVersions, describeOtherListener, installVersion, isReleaseVersion, releaseListenerLock, superviseListener, } from './agents-update.js';
12
12
  import { readCliVersion } from './help.js';
13
13
  const root = '/api/agents';
14
14
  const PROFILE_HINT = 'Declare named profiles in ' + profilesPath() + ' to set a working directory or extra arguments.';
@@ -253,7 +253,8 @@ export async function listen(options) {
253
253
  let result = 'stopped';
254
254
  function considerUpdate(version) {
255
255
  const current = options.updater?.currentVersion ?? readCliVersion();
256
- if (!version || compareVersions(version, current) <= 0 || updateReady === version || updating === version)
256
+ // Only a plain release number; npm would read anything else as a git, URL or file package spec.
257
+ if (!version || !isReleaseVersion(version) || compareVersions(version, current) <= 0 || updateReady === version || updating === version)
257
258
  return;
258
259
  if (!options.updater) {
259
260
  if (updateMentioned !== version)
@@ -336,6 +337,9 @@ export async function listen(options) {
336
337
  deliveries.delete(runner.sessionId); });
337
338
  }
338
339
  function handle(command) {
340
+ // The id names a local directory that is later deleted, so it must not be able to point elsewhere.
341
+ if (!isSessionId(command.sessionId))
342
+ return log(`! Ignored a command for an invalid session id.`);
339
343
  const runner = sessions.get(command.sessionId);
340
344
  switch (command.type) {
341
345
  case 'start': return start(command);
@@ -408,3 +412,5 @@ function describe(detected) {
408
412
  const profiles = detected.profiles.length ? `, profiles ${detected.profiles.map(p => p.name).join(', ')}` : '';
409
413
  return (agents.length ? agents.join(', ') : 'no supported agent found') + profiles;
410
414
  }
415
+ // Session ids from the server name local directories (pasted images); only plain identifiers are accepted.
416
+ export const isSessionId = (id) => typeof id === 'string' && /^[A-Za-z0-9_-]{1,64}$/.test(id);
package/dist/help.js CHANGED
@@ -166,7 +166,7 @@ export function renderUsage(defaultUrl) {
166
166
  ...COMMANDS.map((command) => ` ${command.name.padEnd(width)} ${command.summary}`),
167
167
  '',
168
168
  'Options:',
169
- ' --token <token> Bearer token for API requests (overrides SKILLSHARE_TOKEN)',
169
+ ' --token <token> Bearer token for API requests; visible in the process list, prefer SKILLSHARE_TOKEN',
170
170
  ' --server <url> Skillshare origin for login and Teams commands',
171
171
  ' --json Print machine-readable JSON (whoami, list, show, upload, pages, teams, salesforce, agents)',
172
172
  ' -h, --help Show help for a command',
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ import { createServer } from 'node:http';
14
14
  import { createHash, randomBytes } from 'node:crypto';
15
15
  import { spawn } from 'node:child_process';
16
16
  import { existsSync } from 'node:fs';
17
- import { mkdir, open, readFile, readdir, rm, stat, writeFile } from 'node:fs/promises';
17
+ import { chmod, mkdir, open, readFile, readdir, rm, stat, writeFile } from 'node:fs/promises';
18
18
  import { basename, join, relative, resolve } from 'node:path';
19
19
  import { homedir } from 'node:os';
20
20
  import { cancel, confirm, intro, isCancel, log, multiselect, outro, progress, select, spinner, text } from '@clack/prompts';
@@ -1887,10 +1887,15 @@ async function loadAnySession() {
1887
1887
  }
1888
1888
  }
1889
1889
  async function storeSession(session) {
1890
- await mkdir(APP_DIR, { recursive: true });
1891
- await writeFile(SESSION_PATH, JSON.stringify(session), {
1892
- mode: process.platform === 'win32' ? undefined : 0o600,
1893
- });
1890
+ await writePrivateFile(SESSION_PATH, JSON.stringify(session));
1891
+ }
1892
+ // Tokens and state stay readable by the current user only; the mode of writeFile applies just to new files.
1893
+ async function writePrivateFile(path, content) {
1894
+ const posix = process.platform !== 'win32';
1895
+ await mkdir(APP_DIR, { recursive: true, mode: posix ? 0o700 : undefined });
1896
+ await writeFile(path, content, { mode: posix ? 0o600 : undefined });
1897
+ if (posix)
1898
+ await chmod(path, 0o600);
1894
1899
  }
1895
1900
  async function logoutSession() {
1896
1901
  try {
@@ -2120,10 +2125,7 @@ async function readStateFile(path) {
2120
2125
  }
2121
2126
  }
2122
2127
  async function writeStateFile(path, value) {
2123
- await mkdir(APP_DIR, { recursive: true });
2124
- await writeFile(path, `${JSON.stringify(value, null, 2)}\n`, {
2125
- mode: process.platform === 'win32' ? undefined : 0o600,
2126
- });
2128
+ await writePrivateFile(path, `${JSON.stringify(value, null, 2)}\n`);
2127
2129
  }
2128
2130
  async function removeLegacyLocalSkillMetadata(directory) {
2129
2131
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quadient/skillshare",
3
- "version": "1.15.0",
3
+ "version": "1.15.1",
4
4
  "description": "Skillshare CLI for installing and publishing Quadient skills",
5
5
  "type": "module",
6
6
  "bin": {