@opscompass/skills 0.2.0 → 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/manifest.json +2 -2
- package/package.json +1 -1
- package/skills/opscompass-oracle-licensing/.opscompass-runtime/tools/opsc-cli-context.js +10 -0
- package/skills/opscompass-oracle-licensing/.opscompass-runtime/tools/opsc-cli.js +24 -12
- package/skills/opscompass-oracle-licensing/scripts/tools.js +1 -0
- package/skills/opscompass-resources/.opscompass-runtime/tools/opsc-cli-context.js +10 -0
- package/skills/opscompass-resources/.opscompass-runtime/tools/opsc-cli.js +24 -12
- package/skills/opscompass-resources/scripts/build_resources_command.js +4 -2
- package/skills/opscompass-resources/scripts/list_and_fetch_latest_configs.js +4 -4
- package/skills/opscompass-resources/scripts/tools.js +1 -0
package/manifest.json
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"scope": "public",
|
|
4
4
|
"name": "@opscompass/skills",
|
|
5
|
-
"version": "0.2.
|
|
5
|
+
"version": "0.2.1",
|
|
6
6
|
"source": {
|
|
7
7
|
"repository": "https://gitlab.com/opscompass-hob/opscompass-ai/opscompassai.git",
|
|
8
|
-
"revision": "
|
|
8
|
+
"revision": "e71529c9bf8952fa65fc291216a07c54e15e29ad",
|
|
9
9
|
"dirty": false
|
|
10
10
|
},
|
|
11
11
|
"skills": [
|
package/package.json
CHANGED
|
@@ -22,3 +22,13 @@ export function resolveCliContext(cliCommand) {
|
|
|
22
22
|
opscompassHome: path.join(os.homedir(), `.${selectedCommand}`),
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
|
+
export function resolveCliInvocation(context, args) {
|
|
26
|
+
return {
|
|
27
|
+
executable: context.cliInvocation?.executable ?? context.cliEntryPoint,
|
|
28
|
+
args: [...(context.cliInvocation?.args ?? []), ...args],
|
|
29
|
+
env: {
|
|
30
|
+
...(context.cliInvocation?.env ?? process.env),
|
|
31
|
+
OPSCOMPASS_CLI_ENTRYPOINT: context.cliEntryPoint,
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -1,31 +1,41 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
|
+
import { resolveCliInvocation } from "./opsc-cli-context.js";
|
|
2
3
|
const MAX_TIMEOUT_SECONDS = 120;
|
|
3
4
|
const MAX_OUTPUT_BYTES = 100_000;
|
|
4
5
|
export async function runCli(context, args) {
|
|
5
|
-
|
|
6
|
+
if (context.signal.aborted)
|
|
7
|
+
throw new Error("Opscompass command aborted.");
|
|
8
|
+
const invocation = resolveCliInvocation(context, args);
|
|
9
|
+
const child = spawn(invocation.executable, invocation.args, {
|
|
10
|
+
shell: false,
|
|
6
11
|
cwd: context.workspaceRoot,
|
|
7
12
|
// The host-selected executable must win over ambient standalone overrides.
|
|
8
13
|
env: {
|
|
9
|
-
...
|
|
10
|
-
OPSCOMPASS_CLI_ENTRYPOINT: context.cliEntryPoint,
|
|
14
|
+
...invocation.env,
|
|
11
15
|
ELECTRON_RUN_AS_NODE: "1",
|
|
12
16
|
OPSCOMPASS_STUDIO: "1",
|
|
13
17
|
},
|
|
14
18
|
stdio: ["ignore", "pipe", "pipe"],
|
|
15
19
|
detached: process.platform !== "win32",
|
|
16
20
|
});
|
|
17
|
-
const
|
|
18
|
-
|
|
21
|
+
const stdout = [];
|
|
22
|
+
const stderr = [];
|
|
23
|
+
let stdoutBytes = 0;
|
|
24
|
+
let stderrBytes = 0;
|
|
19
25
|
let timedOut = false;
|
|
20
|
-
const collect = (chunk) => {
|
|
26
|
+
const collect = (chunks, chunk, outputBytes) => {
|
|
21
27
|
if (outputBytes >= MAX_OUTPUT_BYTES)
|
|
22
|
-
return;
|
|
28
|
+
return outputBytes;
|
|
23
29
|
const bounded = chunk.subarray(0, MAX_OUTPUT_BYTES - outputBytes);
|
|
24
30
|
chunks.push(bounded);
|
|
25
|
-
outputBytes
|
|
31
|
+
return outputBytes + bounded.length;
|
|
26
32
|
};
|
|
27
|
-
child.stdout?.on("data",
|
|
28
|
-
|
|
33
|
+
child.stdout?.on("data", (chunk) => {
|
|
34
|
+
stdoutBytes = collect(stdout, chunk, stdoutBytes);
|
|
35
|
+
});
|
|
36
|
+
child.stderr?.on("data", (chunk) => {
|
|
37
|
+
stderrBytes = collect(stderr, chunk, stderrBytes);
|
|
38
|
+
});
|
|
29
39
|
let graceTimer;
|
|
30
40
|
const forceKill = () => {
|
|
31
41
|
try {
|
|
@@ -59,13 +69,15 @@ export async function runCli(context, args) {
|
|
|
59
69
|
const result = new Promise((resolve, reject) => {
|
|
60
70
|
child.once("error", reject);
|
|
61
71
|
child.once("close", (code) => {
|
|
62
|
-
const output = Buffer.concat(
|
|
72
|
+
const output = Buffer.concat(stdout).toString("utf8");
|
|
73
|
+
const diagnostic = Buffer.concat(stderr).toString("utf8");
|
|
63
74
|
if (context.signal.aborted)
|
|
64
75
|
reject(new Error("Opscompass command aborted."));
|
|
65
76
|
else if (timedOut)
|
|
66
77
|
reject(new Error(`Opscompass command timed out after ${MAX_TIMEOUT_SECONDS} seconds.`));
|
|
67
78
|
else if (code !== 0)
|
|
68
|
-
reject(new Error(
|
|
79
|
+
reject(new Error(diagnostic.trim() ||
|
|
80
|
+
output.trim() ||
|
|
69
81
|
`Opscompass command failed with exit code ${code}.`));
|
|
70
82
|
else
|
|
71
83
|
resolve(output);
|
|
@@ -22,3 +22,13 @@ export function resolveCliContext(cliCommand) {
|
|
|
22
22
|
opscompassHome: path.join(os.homedir(), `.${selectedCommand}`),
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
|
+
export function resolveCliInvocation(context, args) {
|
|
26
|
+
return {
|
|
27
|
+
executable: context.cliInvocation?.executable ?? context.cliEntryPoint,
|
|
28
|
+
args: [...(context.cliInvocation?.args ?? []), ...args],
|
|
29
|
+
env: {
|
|
30
|
+
...(context.cliInvocation?.env ?? process.env),
|
|
31
|
+
OPSCOMPASS_CLI_ENTRYPOINT: context.cliEntryPoint,
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -1,31 +1,41 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
|
+
import { resolveCliInvocation } from "./opsc-cli-context.js";
|
|
2
3
|
const MAX_TIMEOUT_SECONDS = 120;
|
|
3
4
|
const MAX_OUTPUT_BYTES = 100_000;
|
|
4
5
|
export async function runCli(context, args) {
|
|
5
|
-
|
|
6
|
+
if (context.signal.aborted)
|
|
7
|
+
throw new Error("Opscompass command aborted.");
|
|
8
|
+
const invocation = resolveCliInvocation(context, args);
|
|
9
|
+
const child = spawn(invocation.executable, invocation.args, {
|
|
10
|
+
shell: false,
|
|
6
11
|
cwd: context.workspaceRoot,
|
|
7
12
|
// The host-selected executable must win over ambient standalone overrides.
|
|
8
13
|
env: {
|
|
9
|
-
...
|
|
10
|
-
OPSCOMPASS_CLI_ENTRYPOINT: context.cliEntryPoint,
|
|
14
|
+
...invocation.env,
|
|
11
15
|
ELECTRON_RUN_AS_NODE: "1",
|
|
12
16
|
OPSCOMPASS_STUDIO: "1",
|
|
13
17
|
},
|
|
14
18
|
stdio: ["ignore", "pipe", "pipe"],
|
|
15
19
|
detached: process.platform !== "win32",
|
|
16
20
|
});
|
|
17
|
-
const
|
|
18
|
-
|
|
21
|
+
const stdout = [];
|
|
22
|
+
const stderr = [];
|
|
23
|
+
let stdoutBytes = 0;
|
|
24
|
+
let stderrBytes = 0;
|
|
19
25
|
let timedOut = false;
|
|
20
|
-
const collect = (chunk) => {
|
|
26
|
+
const collect = (chunks, chunk, outputBytes) => {
|
|
21
27
|
if (outputBytes >= MAX_OUTPUT_BYTES)
|
|
22
|
-
return;
|
|
28
|
+
return outputBytes;
|
|
23
29
|
const bounded = chunk.subarray(0, MAX_OUTPUT_BYTES - outputBytes);
|
|
24
30
|
chunks.push(bounded);
|
|
25
|
-
outputBytes
|
|
31
|
+
return outputBytes + bounded.length;
|
|
26
32
|
};
|
|
27
|
-
child.stdout?.on("data",
|
|
28
|
-
|
|
33
|
+
child.stdout?.on("data", (chunk) => {
|
|
34
|
+
stdoutBytes = collect(stdout, chunk, stdoutBytes);
|
|
35
|
+
});
|
|
36
|
+
child.stderr?.on("data", (chunk) => {
|
|
37
|
+
stderrBytes = collect(stderr, chunk, stderrBytes);
|
|
38
|
+
});
|
|
29
39
|
let graceTimer;
|
|
30
40
|
const forceKill = () => {
|
|
31
41
|
try {
|
|
@@ -59,13 +69,15 @@ export async function runCli(context, args) {
|
|
|
59
69
|
const result = new Promise((resolve, reject) => {
|
|
60
70
|
child.once("error", reject);
|
|
61
71
|
child.once("close", (code) => {
|
|
62
|
-
const output = Buffer.concat(
|
|
72
|
+
const output = Buffer.concat(stdout).toString("utf8");
|
|
73
|
+
const diagnostic = Buffer.concat(stderr).toString("utf8");
|
|
63
74
|
if (context.signal.aborted)
|
|
64
75
|
reject(new Error("Opscompass command aborted."));
|
|
65
76
|
else if (timedOut)
|
|
66
77
|
reject(new Error(`Opscompass command timed out after ${MAX_TIMEOUT_SECONDS} seconds.`));
|
|
67
78
|
else if (code !== 0)
|
|
68
|
-
reject(new Error(
|
|
79
|
+
reject(new Error(diagnostic.trim() ||
|
|
80
|
+
output.trim() ||
|
|
69
81
|
`Opscompass command failed with exit code ${code}.`));
|
|
70
82
|
else
|
|
71
83
|
resolve(output);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
2
|
import { isMainModule } from "../.opscompass-runtime/tools/cli-entrypoint.js";
|
|
3
|
-
import { resolveCliContext } from "../.opscompass-runtime/tools/opsc-cli-context.js";
|
|
3
|
+
import { resolveCliContext, resolveCliInvocation, } from "../.opscompass-runtime/tools/opsc-cli-context.js";
|
|
4
4
|
import { resolveCompany } from "../.opscompass-runtime/tools/opsc-cli-defaults.js";
|
|
5
5
|
export { resolveCompany };
|
|
6
6
|
export const ALLOWED_LIST_PARAMS = new Set([
|
|
@@ -81,7 +81,9 @@ const shellQuote = (value) => /^[A-Za-z0-9_./:-]+$/.test(value)
|
|
|
81
81
|
export const commandText = (command) => command.map(shellQuote).join(" ");
|
|
82
82
|
function runCommand(command, context) {
|
|
83
83
|
return new Promise((resolve, reject) => {
|
|
84
|
-
const
|
|
84
|
+
const invocation = resolveCliInvocation(context, command.slice(1));
|
|
85
|
+
const child = spawn(invocation.executable, invocation.args, {
|
|
86
|
+
env: invocation.env,
|
|
85
87
|
shell: false,
|
|
86
88
|
stdio: "inherit",
|
|
87
89
|
});
|
|
@@ -2,7 +2,7 @@ import { mkdirSync, writeFileSync } from "node:fs";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { spawn } from "node:child_process";
|
|
4
4
|
import { isMainModule } from "../.opscompass-runtime/tools/cli-entrypoint.js";
|
|
5
|
-
import { resolveCliContext } from "../.opscompass-runtime/tools/opsc-cli-context.js";
|
|
5
|
+
import { resolveCliContext, resolveCliInvocation, } from "../.opscompass-runtime/tools/opsc-cli-context.js";
|
|
6
6
|
import * as brc from "./build_resources_command.js";
|
|
7
7
|
import * as moc from "./map_oracle_workloads_to_platform_cpus.js";
|
|
8
8
|
import * as slc from "./summarize_latest_configuration.js";
|
|
@@ -23,7 +23,8 @@ function runJsonCommand(command, verbose, logger, execution) {
|
|
|
23
23
|
if (verbose)
|
|
24
24
|
logger.error(`$ ${command.join(" ")}`);
|
|
25
25
|
let stdout = "", stderr = "";
|
|
26
|
-
const
|
|
26
|
+
const invocation = resolveCliInvocation(execution.context, command.slice(1));
|
|
27
|
+
const child = spawn(invocation.executable, invocation.args, {
|
|
27
28
|
shell: false,
|
|
28
29
|
stdio: ["ignore", "pipe", "pipe"],
|
|
29
30
|
cwd: execution.workspaceRoot,
|
|
@@ -503,8 +504,7 @@ async function runWorkflow(argv, logger, execution, signal) {
|
|
|
503
504
|
: process.cwd(),
|
|
504
505
|
signal,
|
|
505
506
|
env: {
|
|
506
|
-
...
|
|
507
|
-
OPSCOMPASS_CLI_ENTRYPOINT: context.cliEntryPoint,
|
|
507
|
+
...resolveCliInvocation(context, []).env,
|
|
508
508
|
...(execution
|
|
509
509
|
? { ELECTRON_RUN_AS_NODE: "1", OPSCOMPASS_STUDIO: "1" }
|
|
510
510
|
: {}),
|
|
@@ -5,6 +5,7 @@ import { opscompassDefaultsTool } from "./opscompass-defaults.tool.js";
|
|
|
5
5
|
import { opscompassResourcesTool } from "./opscompass-resources.tool.js";
|
|
6
6
|
import { summarizeLatestConfigurationTool } from "./summarize-latest-configuration.tool.js";
|
|
7
7
|
import { summarizeResourcesListTool } from "./summarize-resources-list.tool.js";
|
|
8
|
+
export const supportsCliInvocation = true;
|
|
8
9
|
export const tools = [
|
|
9
10
|
opscompassResourcesTool,
|
|
10
11
|
buildResourcesCommandTool,
|