toolcraft-openapi 0.0.71 → 0.0.73

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.
@@ -554,20 +554,47 @@ async function assertSafeProjectPath(fs, cwd, filePath) {
554
554
  path.isAbsolute(relativePath)) {
555
555
  throw new Error("Generated skill output must remain inside the project directory.");
556
556
  }
557
- const parentOfRoot = path.dirname(rootPath);
558
- let currentPath = resolvedFilePath;
559
- while (currentPath !== parentOfRoot) {
560
- try {
561
- if ((await fs.lstat(currentPath)).isSymbolicLink()) {
557
+ const canonicalRoot = await fs.realpath(cwd);
558
+ const canonicalFileParent = await realpathExistingAncestor(fs, path.dirname(filePath));
559
+ const relativeParentPath = path.relative(canonicalRoot, canonicalFileParent);
560
+ if (relativeParentPath === ".." ||
561
+ relativeParentPath.startsWith(`..${path.sep}`) ||
562
+ path.isAbsolute(relativeParentPath)) {
563
+ throw new Error("Generated skill output must remain inside the project directory.");
564
+ }
565
+ try {
566
+ if ((await fs.lstat(filePath)).isSymbolicLink()) {
567
+ const canonicalFilePath = await fs.realpath(filePath);
568
+ const relativeFilePath = path.relative(canonicalRoot, canonicalFilePath);
569
+ if (relativeFilePath === ".." ||
570
+ relativeFilePath.startsWith(`..${path.sep}`) ||
571
+ path.isAbsolute(relativeFilePath)) {
562
572
  throw new Error("Generated skill output must remain inside the project directory.");
563
573
  }
564
574
  }
575
+ }
576
+ catch (error) {
577
+ if (!isNotFoundError(error)) {
578
+ throw error;
579
+ }
580
+ }
581
+ }
582
+ async function realpathExistingAncestor(fs, targetPath) {
583
+ let currentPath = targetPath;
584
+ while (true) {
585
+ try {
586
+ return await fs.realpath(currentPath);
587
+ }
565
588
  catch (error) {
566
589
  if (!isNotFoundError(error)) {
567
590
  throw error;
568
591
  }
592
+ const parentPath = path.dirname(currentPath);
593
+ if (parentPath === currentPath) {
594
+ throw error;
595
+ }
596
+ currentPath = parentPath;
569
597
  }
570
- currentPath = path.dirname(currentPath);
571
598
  }
572
599
  }
573
600
  async function atomicWriteGeneratedFile(fs, outputDir, filePath, contents) {
@@ -41,7 +41,7 @@ export function renderList(state, screen, layout) {
41
41
  if (row.group && row.group !== lastGroup && y < bodyRect.height) {
42
42
  const hash = `group:${row.group}`;
43
43
  if (cache.get(y) !== hash) {
44
- writeLine(screen, bodyRect, y, row.group, styles.muted);
44
+ writeLine(screen, bodyRect, y, formatGroupHeader(row.group, bodyRect), styles.muted);
45
45
  cache.set(y, hash);
46
46
  }
47
47
  y += 1;
@@ -74,6 +74,14 @@ export function renderList(state, screen, layout) {
74
74
  }
75
75
  }
76
76
  }
77
+ function formatGroupHeader(label, rect) {
78
+ const text = ` ${label} `;
79
+ const labelWidth = cellWidth(text, rect.x);
80
+ if (labelWidth >= rect.width) {
81
+ return label;
82
+ }
83
+ return `${text}${"─".repeat(rect.width - labelWidth)}`;
84
+ }
77
85
  function renderRow(screen, rect, rowY, row, opts) {
78
86
  const styles = getExplorerStyles();
79
87
  const marker = opts.selected ? "┃" : " ";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toolcraft-openapi",
3
- "version": "0.0.71",
3
+ "version": "0.0.73",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -28,7 +28,7 @@
28
28
  "toolcraft-openapi-generate": "dist/bin/generate.js"
29
29
  },
30
30
  "dependencies": {
31
- "toolcraft": "0.0.71",
31
+ "toolcraft": "0.0.73",
32
32
  "auth-store": "^0.0.1",
33
33
  "fast-string-width": "^3.0.2",
34
34
  "fast-wrap-ansi": "^0.2.0",