@commonlyai/cli 0.1.117 → 0.1.118

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commonlyai/cli",
3
- "version": "0.1.117",
3
+ "version": "0.1.118",
4
4
  "license": "Apache-2.0",
5
5
  "description": "The Commonly CLI — connect agents, manage pods, iterate fast",
6
6
  "type": "module",
@@ -135,6 +135,12 @@ How to reach out:
135
135
  not for offloading work you can do yourself. If you can do the thing, do it; a
136
136
  capable peer should pick up stalled work, not queue it behind a note.
137
137
 
138
+ **Close every handoff with an @mention.** An agent wakes only when it's
139
+ @mentioned. When you hand a peer work you'll check, ask it to @mention you when
140
+ it's done. When you finish work someone handed you, post the result and
141
+ @mention them. Without that mention the result sits unread, and the review you
142
+ promised never happens.
143
+
138
144
  **Post intentionally — updates yes, echoes no.** More than one message per turn
139
145
  is *good* when each carries something new: "On it — pulling the numbers." … then,
140
146
  after the work … "Done — here's what I found: …". What's noise is *restating* what
@@ -79,6 +79,7 @@ import {
79
79
  prepareMcpSpawn, PUBLIC_MCP_UNAVAILABLE_CODE, publicMcpUnavailableError, selectedMcpVersionDir,
80
80
  } from '../mcp-home.js';
81
81
  import { buildMemoryPreamble } from '../memory-bridge.js';
82
+ import { skillsAsText } from '../skill-prompt.js';
82
83
  import { adapterFailure, spawnCredentials } from '../upstream-refusal.js';
83
84
 
84
85
  // See codex.js for the rationale on bumping the default + env override.
@@ -274,41 +275,9 @@ const buildPublicClaudePolicyArgs = (mcpToolPatterns) => {
274
275
  // be admitted through Seatbelt. Linux caps one argv string at 128 KiB, so the
275
276
  // total is capped well under it.
276
277
  const PUBLIC_SKILL_PROMPT_MAX_BYTES = 96 * 1024;
277
- const SKILL_FRONTMATTER_RE = /^---\r?\n([\s\S]*?)\r?\n---[ \t]*\r?\n?/;
278
-
279
278
  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
- ];
279
+ const text = await skillsAsText(skillSources, { maxBytes: PUBLIC_SKILL_PROMPT_MAX_BYTES, label: 'claude' });
280
+ return text ? ['--append-system-prompt', text] : [];
312
281
  };
313
282
 
314
283
  const runClaude = ({ cmd, args, cwd, env, timeoutMs, credentials = [], spawnImpl = childSpawn }) => new Promise((resolve, reject) => {
@@ -47,9 +47,11 @@ import {
47
47
  mkdtemp,
48
48
  readFile,
49
49
  readlink,
50
+ rename,
50
51
  rm,
51
52
  symlink,
52
53
  unlink,
54
+ writeFile,
53
55
  } from 'fs/promises';
54
56
  import { homedir, tmpdir } from 'os';
55
57
  import {
@@ -62,6 +64,7 @@ import { supportedGitHooks } from '../commit-attribution.js';
62
64
  import { deliverSeatCredential, withholdRuntimeCredential } from '../mcp-credential-delivery.js';
63
65
  import { prepareMcpSpawn, publicMcpUnavailableError, selectedMcpVersionDir } from '../mcp-home.js';
64
66
  import { buildMemoryPreamble } from '../memory-bridge.js';
67
+ import { resolveSkillSource, skillsAsText } from '../skill-prompt.js';
65
68
  import { isLegacySandboxTrust, normalizeSandboxTrust } from '../environment.js';
66
69
  import { adapterFailure, spawnCredentials } from '../upstream-refusal.js';
67
70
 
@@ -308,6 +311,52 @@ const preparePublicCodexHome = async (ctx) => {
308
311
  return publicHome;
309
312
  };
310
313
 
314
+ // A public seat ran with none of its declared skills: this adapter never read
315
+ // `environment.skills`, so every outsider's Codex worked without the house
316
+ // rules buildDefaultEnvironment declares for it (found 2026-10-20 beside the
317
+ // Claude half of the same gap, #2354). `codex exec` has no skill loader a
318
+ // public seat can use, but it reads $CODEX_HOME/AGENTS.md as the user's own
319
+ // instructions, and the public home is one this CLI owns. Measured on
320
+ // codex-cli 0.162.1 with this adapter's public flags (`--ignore-user-config`
321
+ // skips config.toml only): a marker in that file came back verbatim on a new
322
+ // thread, and a changed marker came back on `exec resume` of the same thread,
323
+ // so a seat picks the skills up on its next turn either way.
324
+ //
325
+ // `skills.claude` is ADR-008's SKILL.md list ("drivers copy or symlink as
326
+ // appropriate"); Codex reads the same format, so no new key. Rewritten each
327
+ // spawn (staged, then renamed, so a concurrent read never sees half a file),
328
+ // and removed when nothing is declared so a dropped skill stops applying.
329
+ // The cap is our own, set at Codex's `project_doc_max_bytes` (32768 in
330
+ // codex-cli 0.162.1's shipped default config, read from the binary 2026-10-21).
331
+ // It is not a limit Codex applies to this file. At rust-v0.162.1 the global
332
+ // `$CODEX_HOME/AGENTS.md` is read whole and trimmed
333
+ // (codex-home/src/instructions/mod.rs) and passed in as user instructions,
334
+ // outside the project-doc budget, which counts only the project AGENTS.md files
335
+ // discovered from the working directory (core/src/agents_md.rs,
336
+ // load_project_instructions). So the skills never share a budget with a
337
+ // workspace's own AGENTS.md, and nothing past the cap would be cut. The cap is
338
+ // what keeps the injected text to the size Codex allows a project doc. It
339
+ // bounds the file as written, final newline included, and a skill that would
340
+ // cross it is left out whole.
341
+ const PUBLIC_CODEX_INSTRUCTIONS_MAX_BYTES = 32 * 1024;
342
+
343
+ const writePublicCodexInstructions = async (publicHome, ctx) => {
344
+ const declared = Array.isArray(ctx.environment?.skills?.claude) ? ctx.environment.skills.claude : [];
345
+ const baseDir = ctx.cwd || process.cwd();
346
+ const text = await skillsAsText(
347
+ declared.map((source) => resolveSkillSource(source, baseDir)),
348
+ { maxBytes: PUBLIC_CODEX_INSTRUCTIONS_MAX_BYTES, label: 'codex', trailer: '\n' },
349
+ );
350
+ const target = join(publicHome, 'AGENTS.md');
351
+ if (!text) {
352
+ await rm(target, { force: true });
353
+ return;
354
+ }
355
+ const staged = `${target}.${process.pid}.tmp`;
356
+ await writeFile(staged, text, { encoding: 'utf8', mode: 0o600 });
357
+ await rename(staged, target);
358
+ };
359
+
311
360
  const publicPermissionProfileFlags = (
312
361
  mode,
313
362
  commitAttributionEnv = null,
@@ -653,6 +702,7 @@ export default {
653
702
  }
654
703
  if (publicSandboxMode !== null) {
655
704
  childEnv.CODEX_HOME = await preparePublicCodexHome(ctx);
705
+ await writePublicCodexInstructions(childEnv.CODEX_HOME, ctx);
656
706
  }
657
707
 
658
708
  const { threadId } = await runCodex({
@@ -20,6 +20,7 @@ import {
20
20
  import { existsSync } from 'fs';
21
21
  import { isAbsolute, join, resolve as pathResolve, basename } from 'path';
22
22
  import { homedir } from 'os';
23
+ import { resolveSkillSource } from './skill-prompt.js';
23
24
 
24
25
  // ── Schema — keep the allow-list narrow; ADR-008 §invariants #1+#2 ──────────
25
26
  //
@@ -524,10 +525,7 @@ export const mountSkills = async (spec, workspacePath, envFileDir = null) => {
524
525
  await mkdir(skillsDir, { recursive: true });
525
526
 
526
527
  for (const rawSource of sources) {
527
- const source = expandHome(rawSource);
528
- const absSource = isAbsolute(source)
529
- ? source
530
- : pathResolve(envFileDir || workspacePath, source);
528
+ const absSource = resolveSkillSource(rawSource, envFileDir || workspacePath);
531
529
  if (!existsSync(absSource)) {
532
530
  conflicted.push({ path: absSource, reason: 'missing-source' });
533
531
  continue;
@@ -0,0 +1,73 @@
1
+ // A public seat cannot load its declared skills as files, so each adapter
2
+ // delivers the SKILL.md bodies as instructions text instead:
3
+ // - claude: skills are disabled outright (`--disable-slash-commands`,
4
+ // `--setting-sources ''`), so the text rides as `--append-system-prompt`;
5
+ // - codex: `exec` has no skill loader the seat can use, and a public seat's
6
+ // CODEX_HOME is one this CLI owns, so the text is that home's AGENTS.md.
7
+ // One reader for both, so the two runtimes cannot drift on what a skill says.
8
+ import { readFile } from 'fs/promises';
9
+ import { isAbsolute, join, resolve as pathResolve } from 'path';
10
+ import { homedir } from 'os';
11
+
12
+ const SKILL_FRONTMATTER_RE = /^---\r?\n([\s\S]*?)\r?\n---[ \t]*\r?\n?/;
13
+
14
+ export const SKILLS_AS_TEXT_PREAMBLE = 'These skills are part of how you work here. Skills are not loaded as files in this seat, '
15
+ + 'so each one is given in full below. Follow them as you would a loaded skill.';
16
+
17
+ /**
18
+ * A declared skill path as the environment spec means it: `~/` expanded,
19
+ * relative paths taken from `baseDir`. The same resolution mountSkills applies.
20
+ */
21
+ export const resolveSkillSource = (rawSource, baseDir) => {
22
+ let source = rawSource;
23
+ if (source === '~') source = homedir();
24
+ else if (typeof source === 'string' && source.startsWith('~/')) source = join(homedir(), source.slice(2));
25
+ return isAbsolute(source) ? source : pathResolve(baseDir, source);
26
+ };
27
+
28
+ const SECTION_SEPARATOR = '\n\n';
29
+
30
+ /**
31
+ * Each source's SKILL.md as `## Skill: <name>` plus its body without the
32
+ * frontmatter, in declared order. `maxBytes` bounds the whole text
33
+ * skillsAsText returns (preamble, separators and `trailer` included), so a cap
34
+ * is the size of what the runtime reads. A source with no SKILL.md, or one that
35
+ * would cross the cap, is skipped with a warning naming the runtime (`label`)
36
+ * rather than failing the spawn.
37
+ */
38
+ export const readSkillSections = async (skillSources, { maxBytes, label, trailer = '' }) => {
39
+ const sections = [];
40
+ let total = Buffer.byteLength(SKILLS_AS_TEXT_PREAMBLE, 'utf8') + Buffer.byteLength(trailer, 'utf8');
41
+ for (const source of skillSources || []) {
42
+ let markdown;
43
+ try {
44
+ // eslint-disable-next-line no-await-in-loop
45
+ markdown = await readFile(join(source, 'SKILL.md'), 'utf8');
46
+ } catch {
47
+ // eslint-disable-next-line no-console
48
+ console.warn(`[${label}] public seat: no SKILL.md to inline at ${source}`);
49
+ continue;
50
+ }
51
+ const frontmatter = SKILL_FRONTMATTER_RE.exec(markdown);
52
+ const name = (frontmatter && /^name:\s*(.+)$/m.exec(frontmatter[1])?.[1].trim())
53
+ || source.split(/[\\/]/).filter(Boolean).pop();
54
+ const section = `## Skill: ${name}\n\n${markdown.slice(frontmatter ? frontmatter[0].length : 0).trim()}`;
55
+ const bytes = Buffer.byteLength(SECTION_SEPARATOR, 'utf8') + Buffer.byteLength(section, 'utf8');
56
+ if (total + bytes > maxBytes) {
57
+ // eslint-disable-next-line no-console
58
+ console.warn(`[${label}] public seat: skill ${name} not inlined (over ${maxBytes} bytes in total)`);
59
+ continue;
60
+ }
61
+ total += bytes;
62
+ sections.push(section);
63
+ }
64
+ return sections;
65
+ };
66
+
67
+ /** The preamble, every section and `trailer`, or null when no skill could be read. */
68
+ export const skillsAsText = async (skillSources, options) => {
69
+ const sections = await readSkillSections(skillSources, options);
70
+ return sections.length
71
+ ? `${SKILLS_AS_TEXT_PREAMBLE}${SECTION_SEPARATOR}${sections.join(SECTION_SEPARATOR)}${options.trailer || ''}`
72
+ : null;
73
+ };