compivia 0.0.1 → 0.0.1128
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/bin/compivia.mjs +40 -0
- package/dist/compivia.mjs +16787 -0
- package/dist/files.json +1 -0
- package/dist/loader.mjs +681 -0
- package/dist/plugin/host-entry.mjs +192 -0
- package/package.json +35 -8
- package/LICENSE +0 -105
- package/README.md +0 -7
- package/bin/compivia.js +0 -2
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
// SPDX-License-Identifier: FSL-1.1-ALv2
|
|
2
|
+
// Plain-JS ESM entry плагина-хоста (child процесс): грузит вклад только из
|
|
3
|
+
// --dir, говорит с runner'ом по IPC process.send (спека #410 §4.8).
|
|
4
|
+
|
|
5
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
6
|
+
import { join } from "node:path";
|
|
7
|
+
import { pathToFileURL } from "node:url";
|
|
8
|
+
|
|
9
|
+
const SUPPORTED_API_VERSIONS = [1]; // дубликат SUPPORTED_PLUGIN_API_VERSIONS (@compivia/plugin-sdk)
|
|
10
|
+
|
|
11
|
+
function fail(message) {
|
|
12
|
+
process.stderr.write(`${message}\n`);
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function parseArgv(argv) {
|
|
17
|
+
let dir;
|
|
18
|
+
let contribution;
|
|
19
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
20
|
+
if (argv[i] === "--dir") { dir = argv[i + 1]; i += 1; }
|
|
21
|
+
else if (argv[i] === "--contribution") { contribution = argv[i + 1]; i += 1; }
|
|
22
|
+
else fail(`unknown argument ${argv[i] ?? "(missing)"}`);
|
|
23
|
+
}
|
|
24
|
+
if (typeof dir !== "string" || dir === "") fail("missing --dir");
|
|
25
|
+
if (typeof contribution !== "string" || !/^[a-z]+:[a-z][a-z0-9-]{0,31}$/.test(contribution)) fail("missing or invalid --contribution");
|
|
26
|
+
return { dir, contribution };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const { dir, contribution } = parseArgv(process.argv.slice(2));
|
|
30
|
+
const sep = contribution.indexOf(":");
|
|
31
|
+
const kind = contribution.slice(0, sep);
|
|
32
|
+
const id = contribution.slice(sep + 1);
|
|
33
|
+
if (kind !== "harness" && kind !== "reporter") fail(`unsupported kind ${kind}`);
|
|
34
|
+
|
|
35
|
+
const manifestPath = join(dir, "package.json");
|
|
36
|
+
if (!existsSync(manifestPath)) fail(`package.json not found in ${dir}`);
|
|
37
|
+
let manifest;
|
|
38
|
+
let pkgVersion = "";
|
|
39
|
+
let pkgName = "";
|
|
40
|
+
try {
|
|
41
|
+
const pkg = JSON.parse(readFileSync(manifestPath, "utf8"));
|
|
42
|
+
manifest = pkg.compivia.plugin;
|
|
43
|
+
pkgVersion = String(pkg.version ?? "");
|
|
44
|
+
pkgName = String(pkg.name ?? "");
|
|
45
|
+
} catch (error) {
|
|
46
|
+
fail(`invalid plugin package: ${error && typeof error === "object" ? String(error.message) : "read error"}`);
|
|
47
|
+
}
|
|
48
|
+
if (manifest === null || typeof manifest !== "object") fail("missing compivia.plugin manifest");
|
|
49
|
+
if (!SUPPORTED_API_VERSIONS.includes(manifest.apiVersion)) fail(`unsupported plugin apiVersion ${JSON.stringify(manifest.apiVersion)}; supported: [${SUPPORTED_API_VERSIONS.join(", ")}]`);
|
|
50
|
+
const entry = (manifest.contributions ?? []).find((c) => c && c.kind === kind && c.id === id);
|
|
51
|
+
if (entry === undefined) fail(`contribution ${contribution} not found in manifest`);
|
|
52
|
+
if (typeof entry.module !== "string" || entry.module === "") fail("manifest contribution.module: expected a string");
|
|
53
|
+
|
|
54
|
+
let def;
|
|
55
|
+
try {
|
|
56
|
+
const module = await import(pathToFileURL(join(dir, entry.module)).href);
|
|
57
|
+
def = module.default;
|
|
58
|
+
} catch (error) {
|
|
59
|
+
fail(`module load failed: ${error && typeof error === "object" ? String(error.message).split("\n")[0] : "unknown"}`);
|
|
60
|
+
}
|
|
61
|
+
if (def === null || typeof def !== "object" || Array.isArray(def)) fail("default export: not an object");
|
|
62
|
+
if (def.id !== id) fail("default export: id mismatch");
|
|
63
|
+
|
|
64
|
+
const secrets = kind === "reporter" && Array.isArray(entry.secrets) ? entry.secrets : [];
|
|
65
|
+
function mask(text) {
|
|
66
|
+
let out = String(text);
|
|
67
|
+
for (const name of secrets) {
|
|
68
|
+
const value = process.env[name];
|
|
69
|
+
if (value !== undefined && value !== "") out = out.split(value).join("***");
|
|
70
|
+
}
|
|
71
|
+
return out;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function send(message) {
|
|
75
|
+
if (process.send === undefined || process.channel === null) return;
|
|
76
|
+
process.send(message);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
send({ type: "ready", contribution: { kind, id, package: pkgName, version: process.env.COMPIVIA_PLUGIN_VERSION ?? pkgVersion, apiVersion: manifest.apiVersion } });
|
|
80
|
+
|
|
81
|
+
let initOptions = {};
|
|
82
|
+
let disposed = false;
|
|
83
|
+
|
|
84
|
+
function makeLogger() {
|
|
85
|
+
return {
|
|
86
|
+
debug: (msg, fields) => send({ type: "log", level: "debug", msg: mask(msg), ...(fields !== undefined ? { fields } : {}) }),
|
|
87
|
+
info: (msg, fields) => send({ type: "log", level: "info", msg: mask(msg), ...(fields !== undefined ? { fields } : {}) }),
|
|
88
|
+
warn: (msg, fields) => send({ type: "log", level: "warn", msg: mask(msg), ...(fields !== undefined ? { fields } : {}) }),
|
|
89
|
+
error: (msg, fields) => send({ type: "log", level: "error", msg: mask(msg), ...(fields !== undefined ? { fields } : {}) }),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
async function initReporter() {
|
|
94
|
+
const env = Object.fromEntries(secrets.map((name) => [name, typeof process.env[name] === "string" ? process.env[name] : ""]));
|
|
95
|
+
const ctx = { subscription: `plugin:${kind}:${id}`, options: initOptions, env, logger: makeLogger() };
|
|
96
|
+
if (typeof def.init === "function") await def.init(ctx);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
process.on("message", (message) => {
|
|
100
|
+
if (message === null || typeof message !== "object") {
|
|
101
|
+
fail("protocol violation");
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (disposed) return;
|
|
105
|
+
if (message.type === "dispose") {
|
|
106
|
+
void (async () => {
|
|
107
|
+
disposed = true;
|
|
108
|
+
try {
|
|
109
|
+
if (kind === "reporter" && typeof def.dispose === "function") {
|
|
110
|
+
const timer = setTimeout(() => process.exit(0), 5000);
|
|
111
|
+
timer.unref?.();
|
|
112
|
+
await def.dispose();
|
|
113
|
+
}
|
|
114
|
+
} catch { /* dispose не должен валить хост */ }
|
|
115
|
+
process.exit(0);
|
|
116
|
+
})().catch(() => {});
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
// FIFO: init полностью завершается до первого call — плагин с async init
|
|
120
|
+
// никогда не вызывается в неинициализированном состоянии.
|
|
121
|
+
messageQueue = messageQueue.then(() => handleMessage(message)).catch(() => fail("dispatcher failure"));
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
let messageQueue = Promise.resolve();
|
|
125
|
+
|
|
126
|
+
async function handleMessage(parsed) {
|
|
127
|
+
if (parsed.type === "init") {
|
|
128
|
+
try {
|
|
129
|
+
initOptions = parsed.options ?? {};
|
|
130
|
+
if (kind === "reporter") await initReporter();
|
|
131
|
+
return;
|
|
132
|
+
} catch (error) {
|
|
133
|
+
send({ type: "failure", requestId: null, class: "plugin_error", message: mask(String(error?.message ?? error)) });
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (parsed.type !== "call") fail(`unknown message type ${String(parsed.type)}`);
|
|
138
|
+
const { requestId, method, timeoutMs } = parsed;
|
|
139
|
+
const harnessMethods = ["detect", "launch", "classifyLine", "locateSession", "finalOf", "checksOf", "normalizeLine", "classify", "finalFromOutput"];
|
|
140
|
+
const reporterMethods = ["probe"];
|
|
141
|
+
const allowed = kind === "harness" ? harnessMethods : reporterMethods;
|
|
142
|
+
if (!allowed.includes(method)) {
|
|
143
|
+
send({ type: "failure", requestId, class: "method_unknown", message: `method ${method} is not implemented by ${kind} contributions` });
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
// Abort-таймеры собираются и снимаются по завершении вызова.
|
|
147
|
+
const timers = [];
|
|
148
|
+
const abortSignalAfter = (ms) => {
|
|
149
|
+
const controller = new AbortController();
|
|
150
|
+
const timer = setTimeout(() => controller.abort(), ms ?? 30_000);
|
|
151
|
+
timer.unref?.();
|
|
152
|
+
timers.push(timer);
|
|
153
|
+
return controller.signal;
|
|
154
|
+
};
|
|
155
|
+
const dispatch = async () => {
|
|
156
|
+
switch (method) {
|
|
157
|
+
case "detect": return def.detect({ logger: makeLogger(), signal: abortSignalAfter(timeoutMs) });
|
|
158
|
+
case "launch": return def.launch(parsed.params);
|
|
159
|
+
case "classifyLine": return def.classifyLine(parsed.params);
|
|
160
|
+
case "locateSession": return def.locateSession(parsed.params);
|
|
161
|
+
case "finalOf": return def.finalOf(parsed.params?.location, parsed.params?.turn);
|
|
162
|
+
case "checksOf": {
|
|
163
|
+
if (typeof def.checksOf !== "function") return [];
|
|
164
|
+
return def.checksOf(parsed.params?.location ?? parsed.params);
|
|
165
|
+
}
|
|
166
|
+
case "normalizeLine": return def.normalizeLine(parsed.params?.sessionId, parsed.params?.line);
|
|
167
|
+
case "classify": return def.classify(parsed.params);
|
|
168
|
+
case "finalFromOutput": return def.finalFromOutput(parsed.params);
|
|
169
|
+
case "probe": return def.probe({ subscription: `plugin:${kind}:${id}`, options: initOptions, env: reporterEnv(), logger: makeLogger() }, abortSignalAfter(timeoutMs));
|
|
170
|
+
default: return { __unknownMethod: true };
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
try {
|
|
174
|
+
const result = await dispatch();
|
|
175
|
+
if (result !== undefined && result !== null && typeof result === "object" && result.__unknownMethod === true) {
|
|
176
|
+
send({ type: "failure", requestId, class: "method_unknown", message: `method ${method} is not implemented by this contribution` });
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
send({ type: "result", requestId, result });
|
|
180
|
+
} catch (error) {
|
|
181
|
+
send({ type: "failure", requestId, class: "plugin_error", message: mask(String(error?.message ?? error).split("\n")[0]) });
|
|
182
|
+
} finally {
|
|
183
|
+
for (const timer of timers.splice(0)) clearTimeout(timer);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function reporterEnv() {
|
|
188
|
+
return Object.fromEntries(secrets.map((name) => [name, typeof process.env[name] === "string" ? process.env[name] : ""]));
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
process.on("disconnect", () => process.exit(0));
|
|
192
|
+
process.on("SIGTERM", () => process.exit(0));
|
package/package.json
CHANGED
|
@@ -1,12 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "compivia",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "Compivia
|
|
3
|
+
"version": "0.0.1128",
|
|
4
|
+
"description": "Compivia CLI wrapper: installs and proxies self-host engine components",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"compivia",
|
|
7
|
+
"cli",
|
|
8
|
+
"engine",
|
|
9
|
+
"self-host"
|
|
10
|
+
],
|
|
11
|
+
"engines": {
|
|
12
|
+
"node": ">=24"
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/compivia/compivia-core-dev.git",
|
|
17
|
+
"directory": "packages/cli"
|
|
18
|
+
},
|
|
19
|
+
"type": "module",
|
|
5
20
|
"license": "FSL-1.1-ALv2",
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"files": [
|
|
10
|
-
|
|
11
|
-
|
|
21
|
+
"bin": {
|
|
22
|
+
"compivia": "bin/compivia.mjs"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"bin/",
|
|
26
|
+
"dist/"
|
|
27
|
+
],
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "node build.mjs",
|
|
30
|
+
"test": "vitest run",
|
|
31
|
+
"typecheck": "tsc --noEmit"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {},
|
|
34
|
+
"dependencies": {},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"registry": "https://registry.npmjs.org/",
|
|
37
|
+
"access": "public"
|
|
38
|
+
}
|
|
12
39
|
}
|
package/LICENSE
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
# Functional Source License, Version 1.1, ALv2 Future License
|
|
2
|
-
|
|
3
|
-
## Abbreviation
|
|
4
|
-
|
|
5
|
-
FSL-1.1-ALv2
|
|
6
|
-
|
|
7
|
-
## Notice
|
|
8
|
-
|
|
9
|
-
Copyright 2026 Sickfar
|
|
10
|
-
|
|
11
|
-
## Terms and Conditions
|
|
12
|
-
|
|
13
|
-
### Licensor ("We")
|
|
14
|
-
|
|
15
|
-
The party offering the Software under these Terms and Conditions.
|
|
16
|
-
|
|
17
|
-
### The Software
|
|
18
|
-
|
|
19
|
-
The "Software" is each version of the software that we make available under
|
|
20
|
-
these Terms and Conditions, as indicated by our inclusion of these Terms and
|
|
21
|
-
Conditions with the Software.
|
|
22
|
-
|
|
23
|
-
### License Grant
|
|
24
|
-
|
|
25
|
-
Subject to your compliance with this License Grant and the Patents,
|
|
26
|
-
Redistribution and Trademark clauses below, we hereby grant you the right to
|
|
27
|
-
use, copy, modify, create derivative works, publicly perform, publicly display
|
|
28
|
-
and redistribute the Software for any Permitted Purpose identified below.
|
|
29
|
-
|
|
30
|
-
### Permitted Purpose
|
|
31
|
-
|
|
32
|
-
A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
|
|
33
|
-
means making the Software available to others in a commercial product or
|
|
34
|
-
service that:
|
|
35
|
-
|
|
36
|
-
1. substitutes for the Software;
|
|
37
|
-
|
|
38
|
-
2. substitutes for any other product or service we offer using the Software
|
|
39
|
-
that exists as of the date we make the Software available; or
|
|
40
|
-
|
|
41
|
-
3. offers the same or substantially similar functionality as the Software.
|
|
42
|
-
|
|
43
|
-
Permitted Purposes specifically include using the Software:
|
|
44
|
-
|
|
45
|
-
1. for your internal use and access;
|
|
46
|
-
|
|
47
|
-
2. for non-commercial education;
|
|
48
|
-
|
|
49
|
-
3. for non-commercial research; and
|
|
50
|
-
|
|
51
|
-
4. in connection with professional services that you provide to a licensee
|
|
52
|
-
using the Software in accordance with these Terms and Conditions.
|
|
53
|
-
|
|
54
|
-
### Patents
|
|
55
|
-
|
|
56
|
-
To the extent your use for a Permitted Purpose would necessarily infringe our
|
|
57
|
-
patents, the license grant above includes a license under our patents. If you
|
|
58
|
-
make a claim against any party that the Software infringes or contributes to
|
|
59
|
-
the infringement of any patent, then your patent license to the Software ends
|
|
60
|
-
immediately.
|
|
61
|
-
|
|
62
|
-
### Redistribution
|
|
63
|
-
|
|
64
|
-
The Terms and Conditions apply to all copies, modifications and derivatives of
|
|
65
|
-
the Software.
|
|
66
|
-
|
|
67
|
-
If you redistribute any copies, modifications or derivatives of the Software,
|
|
68
|
-
you must include a copy of or a link to these Terms and Conditions and not
|
|
69
|
-
remove any copyright notices provided in or with the Software.
|
|
70
|
-
|
|
71
|
-
### Disclaimer
|
|
72
|
-
|
|
73
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
|
|
74
|
-
IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
|
|
75
|
-
PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
|
|
76
|
-
|
|
77
|
-
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
|
|
78
|
-
SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
|
|
79
|
-
EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
|
|
80
|
-
|
|
81
|
-
### Trademarks
|
|
82
|
-
|
|
83
|
-
Except for displaying the License Details and identifying us as the origin of
|
|
84
|
-
the Software, you have no right under these Terms and Conditions to use our
|
|
85
|
-
trademarks, trade names, service marks or product names.
|
|
86
|
-
|
|
87
|
-
## Grant of Future License
|
|
88
|
-
|
|
89
|
-
We hereby irrevocably grant you an additional license to use the Software under
|
|
90
|
-
the Apache License, Version 2.0 that is effective on the second anniversary of
|
|
91
|
-
the date we make the Software available. On or after that date, you may use the
|
|
92
|
-
Software under the Apache License, Version 2.0, in which case the following
|
|
93
|
-
will apply:
|
|
94
|
-
|
|
95
|
-
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
96
|
-
this file except in compliance with the License.
|
|
97
|
-
|
|
98
|
-
You may obtain a copy of the License at
|
|
99
|
-
|
|
100
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
101
|
-
|
|
102
|
-
Unless required by applicable law or agreed to in writing, software distributed
|
|
103
|
-
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
104
|
-
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
105
|
-
specific language governing permissions and limitations under the License.
|
package/README.md
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
# compivia
|
|
2
|
-
|
|
3
|
-
Compivia is an autonomous software delivery workflow that plans, implements, validates and delivers development tasks end to end.
|
|
4
|
-
|
|
5
|
-
This is a placeholder release. The `compivia` CLI is under active development and will be published here.
|
|
6
|
-
|
|
7
|
-
- Source: https://github.com/compivia/compivia-core
|
package/bin/compivia.js
DELETED