@aspects-ai/workspace-cli 0.1.7 → 0.1.8

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/index.js +20 -13
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -436,6 +436,9 @@ import chalk5 from "chalk";
436
436
  import { Command as Command5 } from "commander";
437
437
  import fs5 from "fs-extra";
438
438
  import path5 from "path";
439
+ function generateId() {
440
+ return Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString();
441
+ }
439
442
  function parseManifestOption(manifestStr) {
440
443
  try {
441
444
  return JSON.parse(manifestStr);
@@ -446,7 +449,8 @@ function parseManifestOption(manifestStr) {
446
449
  function validateAndFixManifest(manifest, toolName, frameName) {
447
450
  const now = (/* @__PURE__ */ new Date()).toISOString();
448
451
  const validatedManifest = {
449
- id: manifest.id || frameName,
452
+ id: frameName,
453
+ // Always match the directory name
450
454
  projectId: manifest.projectId || "default-project",
451
455
  title: manifest.title || frameName.split("-").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" "),
452
456
  description: manifest.description || `Frame for ${toolName}`,
@@ -459,17 +463,20 @@ function validateAndFixManifest(manifest, toolName, frameName) {
459
463
  }
460
464
  return validatedManifest;
461
465
  }
462
- async function getNextFrameName(framesDir, baseName) {
463
- if (!await fs5.pathExists(path5.join(framesDir, baseName))) {
464
- return baseName;
466
+ async function getNextFrameName(framesDir, customName) {
467
+ let frameName;
468
+ if (customName) {
469
+ const truncatedName = customName.slice(0, 20);
470
+ const uniqueId = generateId();
471
+ frameName = `${truncatedName}-${uniqueId}`;
472
+ } else {
473
+ frameName = generateId();
465
474
  }
466
- let counter = 1;
467
- let nextName = `${baseName}-${counter}`;
468
- while (await fs5.pathExists(path5.join(framesDir, nextName))) {
469
- counter++;
470
- nextName = `${baseName}-${counter}`;
475
+ while (await fs5.pathExists(path5.join(framesDir, frameName))) {
476
+ const uniqueId = generateId();
477
+ frameName = customName ? `${customName.slice(0, 20)}-${uniqueId}` : uniqueId;
471
478
  }
472
- return nextName;
479
+ return frameName;
473
480
  }
474
481
  async function fetchExampleFrame(toolName, targetPath) {
475
482
  const library = await getLibrary(toolName);
@@ -490,8 +497,8 @@ function createCreateFrameCommand() {
490
497
  const workspaceRoot = await ensureWorkspaceRoot();
491
498
  const framesDir = path5.join(workspaceRoot, "frames");
492
499
  await fs5.ensureDir(framesDir);
493
- const baseName = options.name || "new-frame";
494
- const frameName = await getNextFrameName(framesDir, baseName);
500
+ const customName = options.name && options.name !== "new-frame" ? options.name : void 0;
501
+ const frameName = await getNextFrameName(framesDir, customName);
495
502
  const frameDir = path5.join(framesDir, frameName);
496
503
  logger.info(`Creating frame: ${chalk5.cyan(frameName)} for ${chalk5.cyan(toolName)}`);
497
504
  await fetchExampleFrame(toolName, frameDir);
@@ -591,7 +598,7 @@ async function fetchFileFromGit(options) {
591
598
  // package.json
592
599
  var package_default = {
593
600
  name: "@aspects-ai/workspace-cli",
594
- version: "0.1.6",
601
+ version: "0.1.7",
595
602
  private: false,
596
603
  description: "Lightweight CLI for installing libraries into workspaces",
597
604
  type: "module",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aspects-ai/workspace-cli",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "private": false,
5
5
  "description": "Lightweight CLI for installing libraries into workspaces",
6
6
  "type": "module",