toolcraft-openapi 0.0.72 → 0.0.74
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/bin/generate.js
CHANGED
|
@@ -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
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
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) {
|
|
@@ -74,14 +74,24 @@ class ExplorerRuntime {
|
|
|
74
74
|
this.driver.enterAltScreen();
|
|
75
75
|
this.driver.disableLineWrap();
|
|
76
76
|
this.driver.hideCursor();
|
|
77
|
-
this.
|
|
78
|
-
this.dispatch({ type: "key", key });
|
|
79
|
-
});
|
|
77
|
+
this.subscribeKeypress();
|
|
80
78
|
this.unsubscribeResize = this.driver.onResize(() => {
|
|
81
79
|
const size = this.driver.getSize();
|
|
82
80
|
this.dispatch({ type: "resize", cols: size.cols, rows: size.rows });
|
|
83
81
|
});
|
|
84
82
|
}
|
|
83
|
+
subscribeKeypress() {
|
|
84
|
+
if (this.unsubscribeKeypress !== undefined) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
this.unsubscribeKeypress = this.driver.onKeypress((key) => {
|
|
88
|
+
this.dispatch({ type: "key", key });
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
pauseKeypress() {
|
|
92
|
+
this.unsubscribeKeypress?.();
|
|
93
|
+
this.unsubscribeKeypress = undefined;
|
|
94
|
+
}
|
|
85
95
|
async loadRows(requestToken = ++this.rowsRequestToken) {
|
|
86
96
|
const rows = await this.config.rows();
|
|
87
97
|
if (requestToken === this.rowsRequestToken) {
|
|
@@ -161,7 +171,13 @@ class ExplorerRuntime {
|
|
|
161
171
|
if (typeof content === "string") {
|
|
162
172
|
return { ...item, renderedContent: content };
|
|
163
173
|
}
|
|
164
|
-
this.track(content.then((resolved) => this.dispatch({
|
|
174
|
+
this.track(content.then((resolved) => this.dispatch({
|
|
175
|
+
type: "detailItemRendered",
|
|
176
|
+
rowId,
|
|
177
|
+
token,
|
|
178
|
+
itemIndex,
|
|
179
|
+
content: resolved
|
|
180
|
+
}), (error) => this.dispatch({
|
|
165
181
|
type: "detailItemRendered",
|
|
166
182
|
rowId,
|
|
167
183
|
token,
|
|
@@ -204,6 +220,7 @@ class ExplorerRuntime {
|
|
|
204
220
|
}
|
|
205
221
|
}
|
|
206
222
|
async suspendAnd(fn) {
|
|
223
|
+
this.pauseKeypress();
|
|
207
224
|
this.driver.exitAltScreen();
|
|
208
225
|
this.driver.enableLineWrap();
|
|
209
226
|
this.driver.showCursor();
|
|
@@ -217,6 +234,7 @@ class ExplorerRuntime {
|
|
|
217
234
|
this.driver.enterAltScreen();
|
|
218
235
|
this.driver.disableLineWrap();
|
|
219
236
|
this.driver.hideCursor();
|
|
237
|
+
this.subscribeKeypress();
|
|
220
238
|
const size = this.driver.getSize();
|
|
221
239
|
this.dispatch({
|
|
222
240
|
type: "suspendResumed",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "toolcraft-openapi",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.74",
|
|
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.
|
|
31
|
+
"toolcraft": "0.0.74",
|
|
32
32
|
"auth-store": "^0.0.1",
|
|
33
33
|
"fast-string-width": "^3.0.2",
|
|
34
34
|
"fast-wrap-ansi": "^0.2.0",
|