ocx 1.2.0 → 1.2.1

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/index.js CHANGED
@@ -10528,7 +10528,7 @@ class GhostConfigProvider {
10528
10528
  // package.json
10529
10529
  var package_default = {
10530
10530
  name: "ocx",
10531
- version: "1.2.0",
10531
+ version: "1.2.1",
10532
10532
  description: "OCX CLI - ShadCN-style registry for OpenCode extensions. Install agents, plugins, skills, and MCP servers.",
10533
10533
  author: "kdcokenny",
10534
10534
  license: "MIT",
@@ -10921,14 +10921,15 @@ var isCI = Boolean(process.env.CI || process.env.GITHUB_ACTIONS || process.env.G
10921
10921
  var isTTY = Boolean(process.stdout.isTTY && !isCI);
10922
10922
  var supportsColor = Boolean(isTTY && process.env.FORCE_COLOR !== "0" && process.env.NO_COLOR === undefined);
10923
10923
  // src/utils/git-context.ts
10924
- import { resolve } from "path";
10924
+ import { basename, resolve } from "path";
10925
+ function getGitEnv() {
10926
+ const { GIT_DIR: _, GIT_WORK_TREE: __, ...cleanEnv } = process.env;
10927
+ return cleanEnv;
10928
+ }
10925
10929
  async function detectGitRepo(cwd) {
10926
- const cleanEnv = { ...process.env };
10927
- delete cleanEnv.GIT_DIR;
10928
- delete cleanEnv.GIT_WORK_TREE;
10929
10930
  const gitDirProc = Bun.spawn(["git", "rev-parse", "--git-dir"], {
10930
10931
  cwd,
10931
- env: cleanEnv,
10932
+ env: getGitEnv(),
10932
10933
  stdout: "pipe",
10933
10934
  stderr: "pipe"
10934
10935
  });
@@ -10943,7 +10944,7 @@ async function detectGitRepo(cwd) {
10943
10944
  }
10944
10945
  const workTreeProc = Bun.spawn(["git", "rev-parse", "--show-toplevel"], {
10945
10946
  cwd,
10946
- env: cleanEnv,
10947
+ env: getGitEnv(),
10947
10948
  stdout: "pipe",
10948
10949
  stderr: "pipe"
10949
10950
  });
@@ -10959,6 +10960,73 @@ async function detectGitRepo(cwd) {
10959
10960
  const gitDir = resolve(cwd, gitDirRaw);
10960
10961
  return { gitDir, workTree };
10961
10962
  }
10963
+ async function getBranch(cwd) {
10964
+ const symbolicProc = Bun.spawn(["git", "symbolic-ref", "--short", "HEAD"], {
10965
+ cwd,
10966
+ env: getGitEnv(),
10967
+ stdout: "pipe",
10968
+ stderr: "pipe"
10969
+ });
10970
+ const symbolicExitCode = await symbolicProc.exited;
10971
+ if (symbolicExitCode === 0) {
10972
+ const output = await new Response(symbolicProc.stdout).text();
10973
+ const branch = output.trim();
10974
+ if (branch) {
10975
+ return branch;
10976
+ }
10977
+ }
10978
+ const tagProc = Bun.spawn(["git", "describe", "--tags", "--exact-match", "HEAD"], {
10979
+ cwd,
10980
+ env: getGitEnv(),
10981
+ stdout: "pipe",
10982
+ stderr: "pipe"
10983
+ });
10984
+ const tagExitCode = await tagProc.exited;
10985
+ if (tagExitCode === 0) {
10986
+ const output = await new Response(tagProc.stdout).text();
10987
+ const tag = output.trim();
10988
+ if (tag) {
10989
+ return tag;
10990
+ }
10991
+ }
10992
+ const hashProc = Bun.spawn(["git", "rev-parse", "--short", "HEAD"], {
10993
+ cwd,
10994
+ env: getGitEnv(),
10995
+ stdout: "pipe",
10996
+ stderr: "pipe"
10997
+ });
10998
+ const hashExitCode = await hashProc.exited;
10999
+ if (hashExitCode === 0) {
11000
+ const output = await new Response(hashProc.stdout).text();
11001
+ const hash = output.trim();
11002
+ if (hash) {
11003
+ return hash;
11004
+ }
11005
+ }
11006
+ return null;
11007
+ }
11008
+ async function getRepoName(cwd) {
11009
+ const proc = Bun.spawn(["git", "rev-parse", "--show-toplevel"], {
11010
+ cwd,
11011
+ env: getGitEnv(),
11012
+ stdout: "pipe",
11013
+ stderr: "pipe"
11014
+ });
11015
+ const exitCode = await proc.exited;
11016
+ if (exitCode !== 0) {
11017
+ return null;
11018
+ }
11019
+ const output = await new Response(proc.stdout).text();
11020
+ const rootPath = output.trim();
11021
+ if (!rootPath) {
11022
+ return null;
11023
+ }
11024
+ return basename(rootPath);
11025
+ }
11026
+ async function getGitInfo(cwd) {
11027
+ const [repoName, branch] = await Promise.all([getRepoName(cwd), getBranch(cwd)]);
11028
+ return { repoName, branch };
11029
+ }
10962
11030
  // ../../node_modules/.bun/kleur@4.1.5/node_modules/kleur/index.mjs
10963
11031
  var FORCE_COLOR;
10964
11032
  var NODE_DISABLE_COLORS;
@@ -14454,7 +14522,7 @@ Profile location:`);
14454
14522
  // src/commands/ghost/opencode.ts
14455
14523
  import { renameSync, rmSync } from "fs";
14456
14524
  import { copyFile as copyFilePromise } from "fs/promises";
14457
- import path6 from "path";
14525
+ import path7 from "path";
14458
14526
 
14459
14527
  // src/utils/opencode-discovery.ts
14460
14528
  import { exists } from "fs/promises";
@@ -14650,6 +14718,38 @@ async function cleanupOrphanedGhostDirs(tempBase = tmpdir()) {
14650
14718
  return cleanedCount;
14651
14719
  }
14652
14720
 
14721
+ // src/utils/terminal-title.ts
14722
+ import path6 from "path";
14723
+ var MAX_BRANCH_LENGTH = 20;
14724
+ function isInsideTmux() {
14725
+ return Boolean(process.env.TMUX);
14726
+ }
14727
+ function setTmuxWindowName(name) {
14728
+ if (!isInsideTmux()) {
14729
+ return;
14730
+ }
14731
+ Bun.spawnSync(["tmux", "rename-window", name]);
14732
+ Bun.spawnSync(["tmux", "set-window-option", "automatic-rename", "off"]);
14733
+ }
14734
+ function setTerminalTitle(title) {
14735
+ if (!isTTY) {
14736
+ return;
14737
+ }
14738
+ process.stdout.write(`\x1B]0;${title}\x07`);
14739
+ }
14740
+ function setTerminalName(name) {
14741
+ setTmuxWindowName(name);
14742
+ setTerminalTitle(name);
14743
+ }
14744
+ function formatTerminalName(cwd, profileName, gitInfo) {
14745
+ const repoName = gitInfo.repoName ?? path6.basename(cwd);
14746
+ if (!gitInfo.branch) {
14747
+ return `ghost[${profileName}]:${repoName}`;
14748
+ }
14749
+ const branch = gitInfo.branch.length > MAX_BRANCH_LENGTH ? `${gitInfo.branch.slice(0, MAX_BRANCH_LENGTH - 3)}...` : gitInfo.branch;
14750
+ return `ghost[${profileName}]:${repoName}/${branch}`;
14751
+ }
14752
+
14653
14753
  // src/commands/ghost/opencode.ts
14654
14754
  function registerGhostOpenCodeCommand(parent) {
14655
14755
  parent.command("opencode").description("Launch OpenCode with ghost mode configuration").option("-p, --profile <name>", "Use specific profile").addOption(sharedOptions.json()).addOption(sharedOptions.quiet()).allowUnknownOption().allowExcessArguments(true).action(async (options2, command) => {
@@ -14692,7 +14792,7 @@ async function runGhostOpenCode(args, options2) {
14692
14792
  await injectGhostFiles(tempDir, profileDir, ghostFiles);
14693
14793
  if (profile.hasAgents) {
14694
14794
  const agentsPath = getProfileAgents(profileName);
14695
- const destAgentsPath = path6.join(tempDir, "AGENTS.md");
14795
+ const destAgentsPath = path7.join(tempDir, "AGENTS.md");
14696
14796
  await copyFilePromise(agentsPath, destAgentsPath);
14697
14797
  }
14698
14798
  let cleanupDone = false;
@@ -14717,6 +14817,8 @@ async function runGhostOpenCode(args, options2) {
14717
14817
  const sigtermHandler = () => proc?.kill("SIGTERM");
14718
14818
  process.on("SIGINT", sigintHandler);
14719
14819
  process.on("SIGTERM", sigtermHandler);
14820
+ const gitInfo = await getGitInfo(cwd);
14821
+ setTerminalName(formatTerminalName(cwd, profileName, gitInfo));
14720
14822
  proc = Bun.spawn({
14721
14823
  cmd: ["opencode", ...args],
14722
14824
  cwd: tempDir,
@@ -14833,7 +14935,7 @@ async function runProfileList(options2) {
14833
14935
 
14834
14936
  // src/commands/ghost/profile/remove.ts
14835
14937
  function registerProfileRemoveCommand(parent) {
14836
- parent.command("remove <name>").alias("rm").description("Delete a ghost profile").option("-f, --force", "Skip confirmation and allow deleting current profile").action(async (name, options2) => {
14938
+ parent.command("remove <name>").alias("rm").description("Delete a ghost profile").option("-f, --force", "Allow deleting current profile").action(async (name, options2) => {
14837
14939
  try {
14838
14940
  await runProfileRemove(name, options2);
14839
14941
  } catch (error) {
@@ -14846,23 +14948,9 @@ async function runProfileRemove(name, options2) {
14846
14948
  if (!await manager.exists(name)) {
14847
14949
  throw new ProfileNotFoundError(name);
14848
14950
  }
14849
- if (!options2.force) {
14850
- if (!isTTY) {
14851
- throw new ValidationError("Cannot confirm deletion in non-interactive mode. Use --force to delete without confirmation.");
14852
- }
14853
- const confirmed = confirmDeletion(name);
14854
- if (!confirmed) {
14855
- console.log("Aborted.");
14856
- return;
14857
- }
14858
- }
14859
- await manager.remove(name, options2.force);
14951
+ await manager.remove(name, options2.force ?? false);
14860
14952
  logger.success(`Deleted profile "${name}"`);
14861
14953
  }
14862
- function confirmDeletion(name) {
14863
- const answer = prompt(`Delete profile "${name}"? This cannot be undone. [y/N]`);
14864
- return answer?.toLowerCase() === "y";
14865
- }
14866
14954
 
14867
14955
  // src/commands/ghost/profile/show.ts
14868
14956
  function registerProfileShowCommand(parent) {
@@ -15748,7 +15836,7 @@ async function hashBundle2(files) {
15748
15836
  `));
15749
15837
  }
15750
15838
  // src/index.ts
15751
- var version = "1.2.0";
15839
+ var version = "1.2.1";
15752
15840
  async function main2() {
15753
15841
  const program2 = new Command().name("ocx").description("OpenCode Extensions - Install agents, skills, plugins, and commands").version(version);
15754
15842
  registerInitCommand(program2);
@@ -15775,4 +15863,4 @@ export {
15775
15863
  buildRegistry
15776
15864
  };
15777
15865
 
15778
- //# debugId=4A36829C127A179064756E2164756E21
15866
+ //# debugId=FF19E8C89476382D64756E2164756E21