@quadient/skillshare 1.13.1 → 1.14.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 CHANGED
@@ -372,7 +372,7 @@ bunx @quadient/skillshare@^1.6.0 pages dev . --slug my-app
372
372
  ```
373
373
 
374
374
  The directory must contain one `wrangler.json` or `wrangler.jsonc`. The CLI downloads
375
- and verifies celld 0.4.1 on first use, caches it under `~/.cache/skillshare/celld`,
375
+ and verifies celld 0.6.2 on first use, caches it under `~/.cache/skillshare/celld`,
376
376
  and uses its packaged esbuild. Supported hosts are macOS Apple Silicon and Linux
377
377
  x64/ARM64; Windows users can use WSL2. `--celld <executable>` or `CELLD_EXECUTABLE`
378
378
  selects an existing installation.
@@ -1,10 +1,10 @@
1
1
  import { randomUUID } from 'node:crypto';
2
2
  import { readFileSync } from 'node:fs';
3
3
  import { mkdtemp, rm, writeFile } from 'node:fs/promises';
4
- import { tmpdir } from 'node:os';
5
- import { join } from 'node:path';
4
+ import { homedir, tmpdir } from 'node:os';
5
+ import { dirname, join, resolve } from 'node:path';
6
6
  import { startAgentProcess } from './agents-process.js';
7
- import { CLAUDE_SANDBOX_TOOLS, DEFAULT, SANDBOX_NOTE, clip, isSandboxed, mcpServerName, mcpTokenEnvironment, oneLine, } from './agents-session.js';
7
+ import { CLAUDE_SANDBOX_TOOLS, DEFAULT, SANDBOX_NOTE, clip, isSandboxed, mcpServerName, mcpTokenEnvironment, oneLine, shadowedMcpServers, } from './agents-session.js';
8
8
  /**
9
9
  * Claude Code in print mode with stream-json in both directions: the same protocol the Agent SDK speaks, but against the
10
10
  * user's own claude install, so their login and settings apply. MCP config and the session's instructions are passed per
@@ -28,7 +28,7 @@ export function claudeContent(message) {
28
28
  export function claudeInstructions(context) {
29
29
  return [context.start.instructions?.trim(), isSandboxed(context.start.configuration, context) ? SANDBOX_NOTE : undefined].filter(Boolean).join('\n\n');
30
30
  }
31
- export function claudeArgs(context, mcpConfigPath, instructionsPath) {
31
+ export function claudeArgs(context, mcpConfigPath, instructionsPath, settingsPath) {
32
32
  const { start } = context;
33
33
  const sandbox = isSandboxed(start.configuration, context);
34
34
  const servers = start.mcpServers ?? [];
@@ -46,6 +46,8 @@ export function claudeArgs(context, mcpConfigPath, instructionsPath) {
46
46
  args.push('--mcp-config', mcpConfigPath);
47
47
  if (instructionsPath)
48
48
  args.push('--append-system-prompt-file', instructionsPath);
49
+ if (settingsPath)
50
+ args.push('--settings', settingsPath);
49
51
  if (start.resumeThreadId)
50
52
  args.push('--resume', start.resumeThreadId);
51
53
  return [...args, ...(context.profile?.args ?? [])];
@@ -56,6 +58,35 @@ export function claudeMcpConfig(servers) {
56
58
  { type: 'http', url: server.url, headers: { Authorization: `Bearer \${SKILLSHARE_MCP_TOKEN_${index}}` } }])),
57
59
  }, null, 2);
58
60
  }
61
+ /**
62
+ * The MCP servers Claude Code loads from its own configuration in this folder: user scope and local scope from .claude.json,
63
+ * project scope from .mcp.json. Claude Code merges them with --mcp-config, so they run beside the session's servers.
64
+ */
65
+ export function claudeConfiguredMcpServers(workdir, configDir = process.env.CLAUDE_CONFIG_DIR) {
66
+ const read = (path) => { try {
67
+ return JSON.parse(readFileSync(path, 'utf8'));
68
+ }
69
+ catch {
70
+ return undefined;
71
+ } };
72
+ const servers = (value) => value && typeof value === 'object'
73
+ ? Object.entries(value).map(([name, server]) => ({ name, url: server?.url })) : [];
74
+ const folders = [];
75
+ for (let folder = resolve(workdir);; folder = dirname(folder)) {
76
+ folders.push(folder);
77
+ if (dirname(folder) === folder)
78
+ break;
79
+ }
80
+ const config = read(configDir ? join(configDir, '.claude.json') : join(homedir(), '.claude.json'));
81
+ return [
82
+ ...servers(config?.mcpServers),
83
+ ...folders.flatMap(folder => [...servers(config?.projects?.[folder]?.mcpServers), ...servers(read(join(folder, '.mcp.json'))?.mcpServers)]),
84
+ ];
85
+ }
86
+ /** Settings that turn off the user's servers on a gateway the session already reaches with its own, narrower token. */
87
+ export function claudeSettings(shadowed) {
88
+ return JSON.stringify({ deniedMcpServers: shadowed.map(serverName => ({ serverName })) }, null, 2);
89
+ }
59
90
  /** A tool call as a transcript entry: shell commands and file edits get their own kinds, everything else is a tool. */
60
91
  export function claudeToolItem(block) {
61
92
  const input = block.input ?? {};
@@ -116,20 +147,27 @@ class ClaudeDriver {
116
147
  const instructions = claudeInstructions(this.context);
117
148
  let mcpConfig;
118
149
  let instructionsFile;
150
+ let settingsFile;
151
+ const workdir = this.context.profile?.workdir ?? this.context.workdir;
152
+ const shadowed = servers.length > 0 ? shadowedMcpServers(claudeConfiguredMcpServers(workdir), servers) : [];
119
153
  if (servers.length > 0 || instructions)
120
154
  this.directory = await mkdtemp(join(tmpdir(), 'skillshare-session-'));
121
155
  if (servers.length > 0) {
122
156
  mcpConfig = join(this.directory, 'mcp.json');
123
157
  await writeFile(mcpConfig, claudeMcpConfig(servers), { mode: 0o600 });
124
158
  }
159
+ if (shadowed.length > 0) {
160
+ settingsFile = join(this.directory, 'settings.json');
161
+ await writeFile(settingsFile, claudeSettings(shadowed), { mode: 0o600 });
162
+ }
125
163
  if (instructions) {
126
164
  instructionsFile = join(this.directory, 'instructions.md');
127
165
  await writeFile(instructionsFile, instructions, { mode: 0o600 });
128
166
  }
129
167
  this.process = startAgentProcess({
130
168
  command: this.options.command ?? 'claude',
131
- args: claudeArgs(this.context, mcpConfig, instructionsFile),
132
- cwd: this.context.profile?.workdir ?? this.context.workdir,
169
+ args: claudeArgs(this.context, mcpConfig, instructionsFile, settingsFile),
170
+ cwd: workdir,
133
171
  env: {
134
172
  ...mcpTokenEnvironment(servers), SKILLSHARE_SESSION_ID: this.context.sessionId,
135
173
  // Claude Code lets auto-memory write to its own folder even under the read-only allowlist; a sandboxed session writes nothing.
@@ -1,5 +1,5 @@
1
1
  import { startAgentProcess } from './agents-process.js';
2
- import { DEFAULT, SANDBOX_NOTE, clip, isSandboxed, mcpServerName, mcpTokenEnvironment, oneLine, } from './agents-session.js';
2
+ import { DEFAULT, SANDBOX_NOTE, clip, isSandboxed, mcpServerName, mcpTokenEnvironment, oneLine, shadowedMcpServers, } from './agents-session.js';
3
3
  /** Profile arguments that make sense for a long-running app-server; anything else belongs to codex exec only. */
4
4
  export function codexConfigArgs(args) {
5
5
  const kept = [];
@@ -20,7 +20,29 @@ export function codexInput(message) {
20
20
  ...(message.images ?? []).filter(image => image.path).map(image => ({ type: 'localImage', path: image.path })),
21
21
  ];
22
22
  }
23
- export function codexThreadParams(context) {
23
+ /**
24
+ * The session's servers join the user's own as separate keys, and the user's servers on the same gateway are turned off.
25
+ * Without the user's configuration (an older Codex), the session's servers replace the whole table instead.
26
+ */
27
+ function codexMcpConfig(servers, shadowed) {
28
+ if (servers.length === 0)
29
+ return {};
30
+ const entries = servers.map((server, index) => [mcpServerName(server, index), { url: server.url, bearer_token_env_var: `SKILLSHARE_MCP_TOKEN_${index}` }]);
31
+ if (!shadowed)
32
+ return { mcp_servers: Object.fromEntries(entries) };
33
+ return {
34
+ ...Object.fromEntries(entries.map(([name, server]) => [`mcp_servers.${name}`, server])),
35
+ ...Object.fromEntries(shadowed.map(name => [`mcp_servers.${name}.enabled`, false])),
36
+ };
37
+ }
38
+ /** The user's MCP servers from Codex's effective configuration (user, project and profile layers), as config/read returns them. */
39
+ export function codexConfiguredMcpServers(result) {
40
+ const servers = result?.config?.mcp_servers;
41
+ if (!servers || typeof servers !== 'object')
42
+ return [];
43
+ return Object.entries(servers).map(([name, server]) => ({ name, url: server?.url }));
44
+ }
45
+ export function codexThreadParams(context, shadowed) {
24
46
  const { start } = context;
25
47
  const sandbox = isSandboxed(start.configuration, context);
26
48
  const servers = start.mcpServers ?? [];
@@ -34,9 +56,7 @@ export function codexThreadParams(context) {
34
56
  ...(instructions ? { developerInstructions: instructions } : {}),
35
57
  config: {
36
58
  'tools.update_plan.enabled': true,
37
- ...(servers.length > 0 ? {
38
- mcp_servers: Object.fromEntries(servers.map((server, index) => [mcpServerName(server, index), { url: server.url, bearer_token_env_var: `SKILLSHARE_MCP_TOKEN_${index}` }])),
39
- } : {}),
59
+ ...codexMcpConfig(servers, shadowed),
40
60
  },
41
61
  };
42
62
  }
@@ -120,7 +140,7 @@ class CodexDriver {
120
140
  capabilities: { experimentalApi: true, optOutNotificationMethods: ['turn/diff/updated', 'mcpServer/startupStatus/updated'] },
121
141
  });
122
142
  this.notify('initialized');
123
- const params = codexThreadParams(this.context);
143
+ const params = codexThreadParams(this.context, await this.shadowedServers(servers));
124
144
  const result = start.resumeThreadId
125
145
  ? await this.request('thread/resume', { threadId: start.resumeThreadId, ...params })
126
146
  : await this.request('thread/start', params);
@@ -130,6 +150,18 @@ class CodexDriver {
130
150
  this.threadId = threadId;
131
151
  this.context.thread(threadId);
132
152
  }
153
+ /** Undefined when Codex cannot report its configuration; the session's servers then replace the user's. */
154
+ async shadowedServers(servers) {
155
+ if (servers.length === 0)
156
+ return [];
157
+ try {
158
+ const result = await this.request('config/read', { cwd: this.context.profile?.workdir ?? this.context.workdir });
159
+ return shadowedMcpServers(codexConfiguredMcpServers(result), servers);
160
+ }
161
+ catch {
162
+ return undefined;
163
+ }
164
+ }
133
165
  turn(message) {
134
166
  const { configuration } = this.context.start;
135
167
  return new Promise((resolve, reject) => {
@@ -12,6 +12,24 @@ export function isSandboxed(configuration, options) {
12
12
  export function mcpServerName(server, index) {
13
13
  return server.name.replace(/[^A-Za-z0-9_-]/g, '_') || `server_${index}`;
14
14
  }
15
+ /**
16
+ * The user's own MCP servers that reach the same Skillshare gateway as a server the session brings. The session's server
17
+ * carries a token scoped to the session (read-only for Teams and Azure DevOps); the user's copy carries their full access,
18
+ * so it is turned off for the session. Matched on the path, because the same gateway answers on several hosts.
19
+ */
20
+ export function shadowedMcpServers(configured, servers) {
21
+ const path = (url) => {
22
+ try {
23
+ return typeof url === 'string' ? new URL(url).pathname.replace(/\/+$/, '').toLowerCase() : undefined;
24
+ }
25
+ catch {
26
+ return undefined;
27
+ }
28
+ };
29
+ const sessionNames = new Set(servers.map(mcpServerName));
30
+ const sessionPaths = new Set(servers.map(server => path(server.url)).filter(Boolean));
31
+ return configured.filter(server => !sessionNames.has(server.name) && sessionPaths.has(path(server.url))).map(server => server.name);
32
+ }
15
33
  /** Tokens go to environment variables only, so they never appear in a command line or a protocol frame. */
16
34
  export function mcpTokenEnvironment(servers) {
17
35
  return Object.fromEntries(servers.map((server, index) => [`SKILLSHARE_MCP_TOKEN_${index}`, server.bearerToken]));
@@ -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.4.1';
6
+ const release = '0.6.2';
7
7
  const platforms = {
8
8
  'darwin-arm64': [
9
9
  'aarch64-apple-darwin',
10
- '95c689769f66c08fd0d191fbfc731adb4c8340b49678b11979698ecf2e73393d',
10
+ 'b81a38299800679e9651fd7c1544540185682dcb59eed1a24c8cc36c6b31e76d',
11
11
  ],
12
12
  'linux-x64': [
13
13
  'x86_64-unknown-linux-gnu',
14
- '7b42a410e340bca4dbadd08ecb7f8983854aa855aa7467c29ab0e08b8b7f2007',
14
+ 'ce0ee3552cc8d55dde3998dc3b1b0c8f547bbcb4bc803d2a94842368b047646c',
15
15
  ],
16
16
  'linux-arm64': [
17
17
  'aarch64-unknown-linux-gnu',
18
- '5cc2281493a896b2cc7c7b6c46b2188753832d6b028457338c8eea774a1dd9a1',
18
+ '4eca87c6797590000a344c1b768364e9696e8817f5fbc16193f459d2edac7cd0',
19
19
  ],
20
20
  };
21
21
  export async function ensureCelld(override, signal) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quadient/skillshare",
3
- "version": "1.13.1",
3
+ "version": "1.14.0",
4
4
  "description": "Skillshare CLI for installing and publishing Quadient skills",
5
5
  "type": "module",
6
6
  "bin": {