skills-layer 0.1.9 → 0.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/THIRD_PARTY_NOTICES.md +718 -0
- package/package.json +2 -1
- package/public/skills-layer-public.mjs +1024 -465
- package/scripts/skills-layer.mjs +48 -7
package/scripts/skills-layer.mjs
CHANGED
|
@@ -1,15 +1,56 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import { executePublicCli } from "../public/skills-layer-public.mjs";
|
|
3
|
+
import { createCliProgress, createRevealSkipController, executePublicCli, prepareCliPresentation, writeCliResult } from "../public/skills-layer-public.mjs";
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
process.stdout.
|
|
5
|
+
const args = process.argv.slice(2);
|
|
6
|
+
const capabilities = {
|
|
7
|
+
stdinIsTty: Boolean(process.stdin.isTTY),
|
|
8
|
+
stdoutIsTty: Boolean(process.stdout.isTTY),
|
|
9
|
+
stderrIsTty: Boolean(process.stderr.isTTY)
|
|
10
|
+
};
|
|
11
|
+
let presentation;
|
|
12
|
+
try {
|
|
13
|
+
presentation = prepareCliPresentation(args, process.env, capabilities);
|
|
14
|
+
} catch {
|
|
15
|
+
const outputFormatIndex = args.indexOf("--output-format");
|
|
16
|
+
const inlineOutputFormat = args.find((argument) => argument.startsWith("--output-format="))?.slice("--output-format=".length);
|
|
17
|
+
const requestedOutputFormat = outputFormatIndex >= 0 ? args[outputFormatIndex + 1] : inlineOutputFormat;
|
|
18
|
+
const kind = requestedOutputFormat === "stream-json" ? "json-stream" : args.includes("--json") || requestedOutputFormat === "json" ? "json-static" : "human-static";
|
|
19
|
+
presentation = { args, mode: { kind, color: false, motion: false, interactive: false, unicode: true, screenReader: false, classic: true, detail: "standard" } };
|
|
20
|
+
}
|
|
21
|
+
const human = presentation.mode.kind === "human-interactive" || presentation.mode.kind === "human-static";
|
|
22
|
+
const commandName = presentation.args?.find((argument) => !argument.startsWith("-")) ?? "skills-layer";
|
|
23
|
+
const lightweight = args.length === 0 || args.includes("--help") || args.includes("-h") || args.includes("--version") || args.includes("-v") || commandName === "help" || commandName === "version";
|
|
24
|
+
const progress = lightweight
|
|
25
|
+
? { info() {}, pause() {}, resume() {}, finish() {} }
|
|
26
|
+
: createCliProgress({ mode: presentation.mode, commandName, stream: process.stderr });
|
|
27
|
+
if (human && !lightweight) {
|
|
28
|
+
progress.info(`Running ${commandName}…`);
|
|
9
29
|
}
|
|
30
|
+
const result = await executePublicCli(args, {
|
|
31
|
+
stdinIsTty: capabilities.stdinIsTty,
|
|
32
|
+
stdoutIsTty: capabilities.stdoutIsTty,
|
|
33
|
+
stderrIsTty: capabilities.stderrIsTty,
|
|
34
|
+
...(presentation.mode.kind === "json-stream" ? {
|
|
35
|
+
emitCliEvent: (event) => process.stdout.write(`${JSON.stringify(event)}\n`)
|
|
36
|
+
} : {}),
|
|
37
|
+
...(human ? { emitInfo: progress.info } : {}),
|
|
38
|
+
...(human ? { onPromptStart: progress.pause, onPromptEnd: progress.resume } : {})
|
|
39
|
+
});
|
|
40
|
+
progress.finish(result);
|
|
10
41
|
|
|
11
|
-
|
|
12
|
-
|
|
42
|
+
const revealSkip = createRevealSkipController(process.stdin);
|
|
43
|
+
try {
|
|
44
|
+
await writeCliResult(result, {
|
|
45
|
+
mode: presentation.mode,
|
|
46
|
+
writeStdout: (value) => process.stdout.write(value),
|
|
47
|
+
writeStderr: (value) => process.stderr.write(value),
|
|
48
|
+
sleep: (milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds)),
|
|
49
|
+
shouldSkip: revealSkip.shouldSkip,
|
|
50
|
+
width: process.stdout.columns
|
|
51
|
+
});
|
|
52
|
+
} finally {
|
|
53
|
+
revealSkip.dispose();
|
|
13
54
|
}
|
|
14
55
|
|
|
15
56
|
process.exitCode = result.exitCode;
|