@agent-commons/cli 0.6.1 → 0.6.2

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.
Files changed (2) hide show
  1. package/dist/bin.js +19 -6
  2. package/package.json +1 -1
package/dist/bin.js CHANGED
@@ -178,7 +178,7 @@ var sym = {
178
178
  bullet: import_chalk.default.dim("\u2022"),
179
179
  dot: import_chalk.default.dim("\xB7")
180
180
  };
181
- function banner(version = "0.6.1") {
181
+ function banner(version = "0.6.2") {
182
182
  console.log("");
183
183
  console.log(import_chalk.default.cyan(" \u25C7"));
184
184
  console.log(import_chalk.default.cyan(" \u256D\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256E"));
@@ -2195,6 +2195,7 @@ ${fileContextBlocks.join("\n\n")}
2195
2195
  You are running inside a CLI session with DIRECT access to the user's local machine. The following tools are in your tool list and execute on the user's machine in real time.
2196
2196
 
2197
2197
  **Session root:** ${rootDir}
2198
+ Use paths relative to this root: "." lists the selected folder; "file.txt" reads a file directly inside it. Do not prefix relative paths with the selected folder's own name. The current root overrides folder names in older messages.
2198
2199
 
2199
2200
  ### Current file system (live snapshot)
2200
2201
 
@@ -2313,6 +2314,16 @@ function safePath(root, userPath) {
2313
2314
  assertNotSensitive(canonicalAncestor);
2314
2315
  return (0, import_path3.resolve)(canonicalAncestor, (0, import_path3.relative)(ancestor, abs));
2315
2316
  }
2317
+ function readPath(root, userPath) {
2318
+ const path = safePath(root, userPath);
2319
+ if ((0, import_fs5.existsSync)(path) || (0, import_path3.isAbsolute)(userPath)) return path;
2320
+ const parts = userPath.split(/[\\/]/).filter(Boolean);
2321
+ if (parts[0] === (0, import_path3.basename)((0, import_fs5.realpathSync)(root))) {
2322
+ const candidate = safePath(root, parts.slice(1).join(import_path3.sep) || ".");
2323
+ if ((0, import_fs5.existsSync)(candidate)) return candidate;
2324
+ }
2325
+ return path;
2326
+ }
2316
2327
  function assertNotSensitive(abs) {
2317
2328
  const segments = abs.split(/[\\/]/);
2318
2329
  if (segments.some((part) => /^(?:\.ssh|\.gnupg|\.agc|\.aws|\.env(?:\..*)?|id_rsa|id_ed25519)$/i.test(part))) {
@@ -2431,7 +2442,7 @@ async function cachedDocumentText(abs, stat, ext) {
2431
2442
  async function toolReadFile(args, cfg) {
2432
2443
  const { path: userPath } = args;
2433
2444
  if (!userPath) throw new Error('read_file requires a "path" argument');
2434
- const abs = safePath(cfg.rootDir, userPath);
2445
+ const abs = readPath(cfg.rootDir, userPath);
2435
2446
  assertNotSensitive(abs);
2436
2447
  if (!(0, import_fs5.existsSync)(abs)) throw new Error(`File not found: ${userPath} (resolved to ${abs}). List the parent directory and use a path relative to the selected workspace root: ${cfg.rootDir}.`);
2437
2448
  const stat = (0, import_fs5.statSync)(abs);
@@ -2539,7 +2550,7 @@ ${preview}`,
2539
2550
  }
2540
2551
  async function toolListDirectory(args, cfg) {
2541
2552
  const userPath = args.path ?? ".";
2542
- const abs = safePath(cfg.rootDir, userPath);
2553
+ const abs = readPath(cfg.rootDir, userPath);
2543
2554
  assertNotSensitive(abs);
2544
2555
  if (!(0, import_fs5.existsSync)(abs)) throw new Error(`Directory not found: ${userPath}`);
2545
2556
  const entries = (0, import_fs5.readdirSync)(abs, { withFileTypes: true });
@@ -2547,7 +2558,9 @@ async function toolListDirectory(args, cfg) {
2547
2558
  const type = e.isDirectory() ? "d" : e.isSymbolicLink() ? "l" : "f";
2548
2559
  return `[${type}] ${e.name}`;
2549
2560
  });
2550
- return lines.join("\n") || "(empty directory)";
2561
+ return `Directory: ${abs}
2562
+ Session root: ${(0, import_fs5.realpathSync)(cfg.rootDir)}
2563
+ ${lines.join("\n") || "(empty directory)"}`;
2551
2564
  }
2552
2565
  async function toolDiskUsage(args, cfg) {
2553
2566
  const root = safePath(cfg.rootDir, String(args.path ?? "."));
@@ -2556,7 +2569,7 @@ async function toolDiskUsage(args, cfg) {
2556
2569
  async function toolSearchFiles(args, cfg) {
2557
2570
  const { pattern, directory } = args;
2558
2571
  if (!pattern) throw new Error('search_files requires a "pattern" argument');
2559
- const baseDir = safePath(cfg.rootDir, directory ?? ".");
2572
+ const baseDir = readPath(cfg.rootDir, directory ?? ".");
2560
2573
  assertNotSensitive(baseDir);
2561
2574
  const results = [];
2562
2575
  const pat = new RegExp(
@@ -6162,7 +6175,7 @@ async function pickAgentInteractively(action) {
6162
6175
  return agentId3;
6163
6176
  }
6164
6177
  var program = new import_commander24.Command();
6165
- program.name("agc").description("Agent Commons CLI \u2014 interact with the Agent Commons platform").version("0.6.1", "-v, --version").showHelpAfterError("(run `agc --help` for usage)").configureHelp({
6178
+ program.name("agc").description("Agent Commons CLI \u2014 interact with the Agent Commons platform").version("0.6.2", "-v, --version").showHelpAfterError("(run `agc --help` for usage)").configureHelp({
6166
6179
  sortOptions: true,
6167
6180
  sortSubcommands: true
6168
6181
  }).addHelpText(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-commons/cli",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "description": "Official Agent Commons CLI for building, running, and managing AI agents from the terminal",
5
5
  "license": "MIT",
6
6
  "keywords": [