@commonlyai/cli 0.1.336 → 0.1.337

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.336",
3
+ "version": "0.1.337",
4
4
  "license": "Apache-2.0",
5
5
  "description": "The Commonly CLI — connect agents, manage pods, iterate fast",
6
6
  "type": "module",
@@ -1998,9 +1998,14 @@ export default {
1998
1998
  }
1999
1999
  // F153: a Seatbelt seat with no key signs in only through the keychain.
2000
2000
  // When that fails, say how to give it a key instead, as bwrap does.
2001
+ // F171: `commonly daemon install` carries no ANTHROPIC_API_KEY (claude
2002
+ // declares no providerKeyEnv), so the key route is a seat run from a
2003
+ // shell that has it; the hint must not send a daemon operator to a
2004
+ // service file that never receives the key.
2001
2005
  if (publicNativeSandbox && !providerProxy && /not logged in/i.test(String(err?.message))) {
2002
2006
  err.message = `${err.message}. Sign in with \`claude\` in your own terminal on this Mac, `
2003
- + 'or set ANTHROPIC_API_KEY (in the service env for daemon seats)';
2007
+ + `or run the agent with ANTHROPIC_API_KEY set (\`${CLI} agent run\` from a shell that has it; `
2008
+ + 'the background daemon does not carry it)';
2004
2009
  }
2005
2010
  throw err;
2006
2011
  } finally {
@@ -544,6 +544,43 @@ const freezeFiles = async (dir) => {
544
544
  }
545
545
  };
546
546
 
547
+ // F171: skills are written only into a real .claude/skills directory inside
548
+ // the workspace. Each component is read with lstat and never followed. A
549
+ // missing one is created with a plain mkdir inside the real directory just
550
+ // checked, then read again; a link, or anything that is not a real directory,
551
+ // returns null and mountSkills writes nothing.
552
+ const SKILLS_DIR_PARTS = ['.claude', 'skills'];
553
+
554
+ const lstatOrNull = async (p) => {
555
+ try {
556
+ return await lstat(p);
557
+ } catch (err) {
558
+ if (err.code === 'ENOENT') return null;
559
+ throw err;
560
+ }
561
+ };
562
+
563
+ const realSkillsDir = async (workspacePath) => {
564
+ let dir = workspacePath;
565
+ for (const part of SKILLS_DIR_PARTS) {
566
+ dir = join(dir, part);
567
+ // eslint-disable-next-line no-await-in-loop
568
+ let st = await lstatOrNull(dir);
569
+ if (!st) {
570
+ try {
571
+ // eslint-disable-next-line no-await-in-loop
572
+ await mkdir(dir);
573
+ } catch (err) {
574
+ if (err.code !== 'EEXIST') throw err;
575
+ }
576
+ // eslint-disable-next-line no-await-in-loop
577
+ st = await lstatOrNull(dir);
578
+ }
579
+ if (!st || st.isSymbolicLink() || !st.isDirectory()) return null;
580
+ }
581
+ return dir;
582
+ };
583
+
547
584
  /**
548
585
  * Mount each `skills.claude[]` source into `<workspacePath>/.claude/skills/`
549
586
  * as a READ-ONLY SNAPSHOT COPY.
@@ -570,10 +607,14 @@ const freezeFiles = async (dir) => {
570
607
  * skill paths). Optional — when omitted, relative paths fall back to
571
608
  * `workspacePath`.
572
609
  *
610
+ * A workspace whose .claude or .claude/skills is a link, or not a directory,
611
+ * gets no mount at all: every source is reported as 'unsafe-skill-dir' and
612
+ * nothing is written (F171).
613
+ *
573
614
  * Returns `{ mounted, conflicted }`:
574
615
  * - `mounted`: string[] — absolute source paths snapshotted
575
616
  * - `conflicted`: Array<{path, reason}> where reason ∈
576
- * 'not-a-mount' | 'missing-source'
617
+ * 'not-a-mount' | 'missing-source' | 'unsafe-skill-dir'
577
618
  */
578
619
  export const mountSkills = async (spec, workspacePath, envFileDir = null) => {
579
620
  const sources = Array.isArray(spec?.skills?.claude) ? spec.skills.claude : [];
@@ -581,8 +622,16 @@ export const mountSkills = async (spec, workspacePath, envFileDir = null) => {
581
622
  const conflicted = [];
582
623
  if (sources.length === 0) return { mounted, conflicted };
583
624
 
584
- const skillsDir = join(workspacePath, '.claude', 'skills');
585
- await mkdir(skillsDir, { recursive: true });
625
+ const skillsDir = await realSkillsDir(workspacePath);
626
+ if (!skillsDir) {
627
+ return {
628
+ mounted,
629
+ conflicted: sources.map((rawSource) => ({
630
+ path: resolveSkillSource(rawSource, envFileDir || workspacePath),
631
+ reason: 'unsafe-skill-dir',
632
+ })),
633
+ };
634
+ }
586
635
 
587
636
  for (const rawSource of sources) {
588
637
  const absSource = resolveSkillSource(rawSource, envFileDir || workspacePath);