@theholocron/cli 5.0.0-alpha.165 → 5.0.0-alpha.167

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/dist/cli.mjs CHANGED
@@ -23,7 +23,7 @@ import chalk from "chalk";
23
23
  import search from "@inquirer/search";
24
24
  import { execFileSync, spawn, spawnSync } from "node:child_process";
25
25
  import ora from "ora";
26
- import { findRootSync, walkFilesSync } from "@theholocron/fs-utils";
26
+ import { findRootSync, isWorkspaceRoot, walkFilesSync } from "@theholocron/fs-utils";
27
27
  import { access, copyFile, mkdir, readFile, readdir, rename, rm, stat, symlink, unlink, writeFile } from "node:fs/promises";
28
28
  import { stringifyJson } from "@theholocron/json-utils";
29
29
  import { createHash, randomUUID } from "node:crypto";
@@ -5877,14 +5877,35 @@ async function installSkills({ agent, skills, repoRoot }) {
5877
5877
  try {
5878
5878
  skillsRoot = dirname(require.resolve("@theholocron/skills/package.json"));
5879
5879
  } catch {
5880
- if (spawnSync("pnpm", [
5880
+ const atWorkspaceRoot = await isWorkspaceRoot(repoRoot);
5881
+ let result = spawnSync("pnpm", [
5881
5882
  "add",
5882
5883
  "-D",
5884
+ ...atWorkspaceRoot ? ["-w"] : [],
5883
5885
  "@theholocron/skills"
5884
5886
  ], {
5885
5887
  cwd: repoRoot,
5886
- stdio: "inherit"
5887
- }).status !== 0) throw new Error("failed to auto-install @theholocron/skills");
5888
+ stdio: [
5889
+ "inherit",
5890
+ "inherit",
5891
+ "pipe"
5892
+ ],
5893
+ encoding: "utf8"
5894
+ });
5895
+ if (result.status !== 0 && !atWorkspaceRoot && result.stderr?.includes("ERR_PNPM_ADDING_TO_ROOT")) {
5896
+ process.stderr.write(result.stderr);
5897
+ result = spawnSync("pnpm", [
5898
+ "add",
5899
+ "-D",
5900
+ "-w",
5901
+ "@theholocron/skills"
5902
+ ], {
5903
+ cwd: repoRoot,
5904
+ stdio: "inherit",
5905
+ encoding: "utf8"
5906
+ });
5907
+ } else if (result.status !== 0 && result.stderr) process.stderr.write(result.stderr);
5908
+ if (result.status !== 0) throw new Error("failed to auto-install @theholocron/skills");
5888
5909
  try {
5889
5910
  skillsRoot = dirname(require.resolve("@theholocron/skills/package.json"));
5890
5911
  } catch {
@@ -6276,7 +6297,7 @@ async function runSetup(input) {
6276
6297
  }
6277
6298
  const properties = {};
6278
6299
  if (effectivePreset && effectivePreset !== "none") properties["holocron_branch_protection_level"] = effectivePreset;
6279
- const isMonorepo = await access(join(input.context.repoRoot, "pnpm-workspace.yaml")).then(() => true).catch(() => false);
6300
+ const isMonorepo = await isWorkspaceRoot(input.context.repoRoot);
6280
6301
  properties["monorepo"] = String(isMonorepo);
6281
6302
  const manual = repo?.properties ?? {};
6282
6303
  if (manual.lifecycle) properties["lifecycle"] = manual.lifecycle;
@@ -7262,7 +7283,7 @@ async function runSync(input) {
7262
7283
  const properties = {};
7263
7284
  const effectivePreset = repo?.protection;
7264
7285
  if (effectivePreset && effectivePreset !== "none") properties["holocron_branch_protection_level"] = effectivePreset;
7265
- const isMonorepo = await access(join(gitRoot, "pnpm-workspace.yaml")).then(() => true).catch(() => false);
7286
+ const isMonorepo = await isWorkspaceRoot(gitRoot);
7266
7287
  properties["monorepo"] = String(isMonorepo);
7267
7288
  const manual = repo?.properties ?? {};
7268
7289
  if (manual.lifecycle) properties["lifecycle"] = manual.lifecycle;