@commonlyai/cli 0.1.108 → 0.1.112
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/package.json +1 -1
- package/src/lib/adapters/claude.js +61 -0
package/package.json
CHANGED
|
@@ -258,6 +258,59 @@ const buildPublicClaudePolicyArgs = (mcpToolPatterns) => {
|
|
|
258
258
|
];
|
|
259
259
|
};
|
|
260
260
|
|
|
261
|
+
// A public seat's skills, as appended system-prompt text.
|
|
262
|
+
//
|
|
263
|
+
// `--disable-slash-commands` above is Claude's switch for ALL skills, and
|
|
264
|
+
// `--setting-sources ''` drops the project source the mounted copies live in.
|
|
265
|
+
// So the skills this adapter mounts into <cwd>/.claude/skills never load in a
|
|
266
|
+
// public seat: measured 2026-10-19 on a Bring your own page seat, which
|
|
267
|
+
// answered "I don't see a skill named commonly, or any skills list or Skill
|
|
268
|
+
// tool"; the same workspace with `--setting-sources project` found it. Every
|
|
269
|
+
// self-serve seat is public (COMMONLY_DEFAULT_SANDBOX), so every outsider's
|
|
270
|
+
// Claude ran without the house rules buildDefaultEnvironment mounts for it.
|
|
271
|
+
// Re-enabling skills would also hand a public seat the built-in ones
|
|
272
|
+
// (computer-use, the browser skills), so the flags stay and the declared text
|
|
273
|
+
// is delivered as prompt instead. Inline rather than a file: nothing new has to
|
|
274
|
+
// be admitted through Seatbelt. Linux caps one argv string at 128 KiB, so the
|
|
275
|
+
// total is capped well under it.
|
|
276
|
+
const PUBLIC_SKILL_PROMPT_MAX_BYTES = 96 * 1024;
|
|
277
|
+
const SKILL_FRONTMATTER_RE = /^---\r?\n([\s\S]*?)\r?\n---[ \t]*\r?\n?/;
|
|
278
|
+
|
|
279
|
+
const publicSkillPromptArgs = async (skillSources) => {
|
|
280
|
+
const sections = [];
|
|
281
|
+
let total = 0;
|
|
282
|
+
for (const source of skillSources || []) {
|
|
283
|
+
let markdown;
|
|
284
|
+
try {
|
|
285
|
+
// eslint-disable-next-line no-await-in-loop
|
|
286
|
+
markdown = await readFile(join(source, 'SKILL.md'), 'utf8');
|
|
287
|
+
} catch {
|
|
288
|
+
// eslint-disable-next-line no-console
|
|
289
|
+
console.warn(`[claude] public seat: no SKILL.md to inline at ${source}`);
|
|
290
|
+
continue;
|
|
291
|
+
}
|
|
292
|
+
const frontmatter = SKILL_FRONTMATTER_RE.exec(markdown);
|
|
293
|
+
const name = (frontmatter && /^name:\s*(.+)$/m.exec(frontmatter[1])?.[1].trim())
|
|
294
|
+
|| source.split(/[\\/]/).filter(Boolean).pop();
|
|
295
|
+
const section = `## Skill: ${name}\n\n${markdown.slice(frontmatter ? frontmatter[0].length : 0).trim()}`;
|
|
296
|
+
const bytes = Buffer.byteLength(section, 'utf8');
|
|
297
|
+
if (total + bytes > PUBLIC_SKILL_PROMPT_MAX_BYTES) {
|
|
298
|
+
// eslint-disable-next-line no-console
|
|
299
|
+
console.warn(`[claude] public seat: skill ${name} not inlined (over ${PUBLIC_SKILL_PROMPT_MAX_BYTES} bytes in total)`);
|
|
300
|
+
continue;
|
|
301
|
+
}
|
|
302
|
+
total += bytes;
|
|
303
|
+
sections.push(section);
|
|
304
|
+
}
|
|
305
|
+
if (sections.length === 0) return [];
|
|
306
|
+
return [
|
|
307
|
+
'--append-system-prompt',
|
|
308
|
+
'These skills are part of how you work here. Skills are not loaded as files in this seat, '
|
|
309
|
+
+ 'so each one is given in full below. Follow them as you would a loaded skill.\n\n'
|
|
310
|
+
+ sections.join('\n\n'),
|
|
311
|
+
];
|
|
312
|
+
};
|
|
313
|
+
|
|
261
314
|
const runClaude = ({ cmd, args, cwd, env, timeoutMs, credentials = [], spawnImpl = childSpawn }) => new Promise((resolve, reject) => {
|
|
262
315
|
const proc = spawnImpl(cmd, args, {
|
|
263
316
|
cwd,
|
|
@@ -637,6 +690,7 @@ const prepareArgv = async (innerArgv, ctx) => {
|
|
|
637
690
|
innerArgv = [
|
|
638
691
|
...innerArgv,
|
|
639
692
|
...buildPublicClaudePolicyArgs(allowedPatterns),
|
|
693
|
+
...(ctx.publicSkillArgs || []),
|
|
640
694
|
];
|
|
641
695
|
const claudeBin = resolveClaudePath(claudeEnv);
|
|
642
696
|
// Only stdio servers have a `command`; an HTTP entry (the grant broker)
|
|
@@ -674,6 +728,7 @@ const prepareArgv = async (innerArgv, ctx) => {
|
|
|
674
728
|
innerArgv = [
|
|
675
729
|
...innerArgv,
|
|
676
730
|
...buildPublicClaudePolicyArgs(allowedPatterns),
|
|
731
|
+
...(ctx.publicSkillArgs || []),
|
|
677
732
|
];
|
|
678
733
|
} else if (allowedPatterns.length > 0) {
|
|
679
734
|
innerArgv = [...innerArgv, '--allowedTools', ...allowedPatterns];
|
|
@@ -779,8 +834,10 @@ export default {
|
|
|
779
834
|
];
|
|
780
835
|
const baseArgs = ['-p', fullPrompt, '--output-format', 'text', sessionFlag, sessionId, ...modelArgs];
|
|
781
836
|
|
|
837
|
+
let mountedSkills = [];
|
|
782
838
|
if (ctx.environment && ctx.cwd) {
|
|
783
839
|
const skills = await mountSkills(ctx.environment, ctx.cwd);
|
|
840
|
+
mountedSkills = skills.mounted;
|
|
784
841
|
if (skills.conflicted.length > 0) {
|
|
785
842
|
for (const c of skills.conflicted) {
|
|
786
843
|
// eslint-disable-next-line no-console
|
|
@@ -792,6 +849,7 @@ export default {
|
|
|
792
849
|
|
|
793
850
|
let mcpConfig = null;
|
|
794
851
|
let publicClaudeState = null;
|
|
852
|
+
let publicSkillArgs = [];
|
|
795
853
|
try {
|
|
796
854
|
// Trust is normalized at entry (legacy `internal` reads as public). The
|
|
797
855
|
// MCP policy follows trust alone, whatever confines the seat: a public
|
|
@@ -803,6 +861,7 @@ export default {
|
|
|
803
861
|
if (publicNativeSandbox) {
|
|
804
862
|
publicClaudeState = await preparePublicClaudeState(ctx);
|
|
805
863
|
}
|
|
864
|
+
if (publicTrust) publicSkillArgs = await publicSkillPromptArgs(mountedSkills);
|
|
806
865
|
if (Array.isArray(ctx.environment?.mcp) && ctx.environment.mcp.length > 0) {
|
|
807
866
|
mcpConfig = await createMcpConfig(ctx.environment.mcp, {
|
|
808
867
|
runtimeToken: ctx.runtimeToken,
|
|
@@ -827,6 +886,7 @@ export default {
|
|
|
827
886
|
mcpConfigDir: mcpConfig?.dir || null,
|
|
828
887
|
mcpReadDirectories: mcpConfig?.mcpReadDirectories || [],
|
|
829
888
|
publicClaudeState,
|
|
889
|
+
publicSkillArgs,
|
|
830
890
|
claudeEnv,
|
|
831
891
|
};
|
|
832
892
|
const { cmd, args, env } = await prepareArgv(baseArgs, spawnCtx);
|
|
@@ -867,6 +927,7 @@ export default {
|
|
|
867
927
|
mcpConfigDir: mcpConfig?.dir || null,
|
|
868
928
|
mcpReadDirectories: mcpConfig?.mcpReadDirectories || [],
|
|
869
929
|
publicClaudeState,
|
|
930
|
+
publicSkillArgs,
|
|
870
931
|
claudeEnv: buildClaudeEnv(
|
|
871
932
|
ctx.env,
|
|
872
933
|
publicClaudeState,
|