@agentxm/extension-discovery 0.28.4-bootstrap.0
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/LICENSE +110 -0
- package/dist/src/discover.d.ts +34 -0
- package/dist/src/discover.js +133 -0
- package/dist/src/index.d.ts +13 -0
- package/dist/src/index.js +12 -0
- package/dist/src/internal/environment.d.ts +14 -0
- package/dist/src/internal/environment.js +15 -0
- package/dist/src/packaging/bazel.d.ts +27 -0
- package/dist/src/packaging/bazel.js +125 -0
- package/dist/src/packaging/cargo.d.ts +32 -0
- package/dist/src/packaging/cargo.js +270 -0
- package/dist/src/packaging/cocoapods.d.ts +26 -0
- package/dist/src/packaging/cocoapods.js +187 -0
- package/dist/src/packaging/composer.d.ts +26 -0
- package/dist/src/packaging/composer.js +144 -0
- package/dist/src/packaging/conan.d.ts +30 -0
- package/dist/src/packaging/conan.js +238 -0
- package/dist/src/packaging/conda.d.ts +26 -0
- package/dist/src/packaging/conda.js +320 -0
- package/dist/src/packaging/cpan.d.ts +29 -0
- package/dist/src/packaging/cpan.js +189 -0
- package/dist/src/packaging/cran.d.ts +29 -0
- package/dist/src/packaging/cran.js +176 -0
- package/dist/src/packaging/detect.d.ts +16 -0
- package/dist/src/packaging/detect.js +25 -0
- package/dist/src/packaging/detected-package.d.ts +14 -0
- package/dist/src/packaging/detected-package.js +20 -0
- package/dist/src/packaging/docker.d.ts +27 -0
- package/dist/src/packaging/docker.js +256 -0
- package/dist/src/packaging/gem.d.ts +26 -0
- package/dist/src/packaging/gem.js +234 -0
- package/dist/src/packaging/golang.d.ts +26 -0
- package/dist/src/packaging/golang.js +169 -0
- package/dist/src/packaging/hackage.d.ts +26 -0
- package/dist/src/packaging/hackage.js +305 -0
- package/dist/src/packaging/hex.d.ts +28 -0
- package/dist/src/packaging/hex.js +186 -0
- package/dist/src/packaging/huggingface.d.ts +20 -0
- package/dist/src/packaging/huggingface.js +112 -0
- package/dist/src/packaging/index.d.ts +44 -0
- package/dist/src/packaging/index.js +120 -0
- package/dist/src/packaging/jsr.d.ts +30 -0
- package/dist/src/packaging/jsr.js +227 -0
- package/dist/src/packaging/julia.d.ts +27 -0
- package/dist/src/packaging/julia.js +165 -0
- package/dist/src/packaging/luarocks.d.ts +28 -0
- package/dist/src/packaging/luarocks.js +159 -0
- package/dist/src/packaging/maven.d.ts +27 -0
- package/dist/src/packaging/maven.js +471 -0
- package/dist/src/packaging/mojo.d.ts +29 -0
- package/dist/src/packaging/mojo.js +148 -0
- package/dist/src/packaging/npm.d.ts +26 -0
- package/dist/src/packaging/npm.js +190 -0
- package/dist/src/packaging/nuget.d.ts +26 -0
- package/dist/src/packaging/nuget.js +240 -0
- package/dist/src/packaging/opam.d.ts +27 -0
- package/dist/src/packaging/opam.js +287 -0
- package/dist/src/packaging/pub.d.ts +26 -0
- package/dist/src/packaging/pub.js +357 -0
- package/dist/src/packaging/pypi.d.ts +23 -0
- package/dist/src/packaging/pypi.js +448 -0
- package/dist/src/packaging/read.d.ts +20 -0
- package/dist/src/packaging/read.js +31 -0
- package/dist/src/packaging/reader-io.d.ts +29 -0
- package/dist/src/packaging/reader-io.js +29 -0
- package/dist/src/packaging/swift.d.ts +26 -0
- package/dist/src/packaging/swift.js +141 -0
- package/dist/src/packaging/types.d.ts +43 -0
- package/dist/src/packaging/types.js +8 -0
- package/dist/src/packaging/zig.d.ts +32 -0
- package/dist/src/packaging/zig.js +151 -0
- package/package.json +54 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# Functional Source License, Version 1.1, MIT Future License
|
|
2
|
+
|
|
3
|
+
## Abbreviation
|
|
4
|
+
|
|
5
|
+
FSL-1.1-MIT
|
|
6
|
+
|
|
7
|
+
## Notice
|
|
8
|
+
|
|
9
|
+
Copyright 2025-2026 AgentXM, Inc.
|
|
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 MIT license that is effective on the second anniversary of the date we make
|
|
91
|
+
the Software available. On or after that date, you may use the Software under
|
|
92
|
+
the MIT license, in which case the following will apply:
|
|
93
|
+
|
|
94
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
95
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
96
|
+
the Software without restriction, including without limitation the rights to
|
|
97
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
98
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
|
99
|
+
so, subject to the following conditions:
|
|
100
|
+
|
|
101
|
+
The above copyright notice and this permission notice shall be included in all
|
|
102
|
+
copies or substantial portions of the Software.
|
|
103
|
+
|
|
104
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
105
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
106
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
107
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
108
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
109
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
110
|
+
SOFTWARE.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Discover pipeline: detect direct packages, read package-native extension
|
|
3
|
+
* declarations, submit them to the registry, and render attestation results.
|
|
4
|
+
*
|
|
5
|
+
* @experimental This API is unstable and may change without notice.
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
import * as Effect from "effect/Effect";
|
|
9
|
+
import type { RegistryClient } from "@agentxm/registry-client";
|
|
10
|
+
import type { DiscoveryExtensionResult } from "@agentxm/registry-protocol/unstable/registry/discover-schema";
|
|
11
|
+
import type { PackageUrlParts } from "@agentxm/extension-model/unstable/packaging/package-url";
|
|
12
|
+
export interface DiscoverResultEntry {
|
|
13
|
+
readonly ref: string;
|
|
14
|
+
readonly resolved: boolean;
|
|
15
|
+
readonly extension: DiscoveryExtensionResult["extension"];
|
|
16
|
+
readonly attestedBy: ReadonlyArray<"package" | "extension">;
|
|
17
|
+
readonly official: boolean;
|
|
18
|
+
readonly packageVersionInRange: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface DiscoverPackageResult {
|
|
21
|
+
readonly detectedPackage: PackageUrlParts;
|
|
22
|
+
readonly extensions: ReadonlyArray<DiscoverResultEntry>;
|
|
23
|
+
}
|
|
24
|
+
export interface DiscoverResult {
|
|
25
|
+
readonly packages: ReadonlyArray<DiscoverPackageResult>;
|
|
26
|
+
readonly totalDetected: number;
|
|
27
|
+
readonly registryAvailable: boolean;
|
|
28
|
+
}
|
|
29
|
+
export declare const discover: (projectDir: string, registryClient: RegistryClient) => Effect.Effect<{
|
|
30
|
+
packages: readonly DiscoverPackageResult[];
|
|
31
|
+
totalDetected: number;
|
|
32
|
+
registryAvailable: boolean;
|
|
33
|
+
}, never, import("effect/FileSystem").FileSystem | import("effect/Path").Path>;
|
|
34
|
+
//# sourceMappingURL=discover.d.ts.map
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Discover pipeline: detect direct packages, read package-native extension
|
|
3
|
+
* declarations, submit them to the registry, and render attestation results.
|
|
4
|
+
*
|
|
5
|
+
* @experimental This API is unstable and may change without notice.
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
import * as Effect from "effect/Effect";
|
|
9
|
+
import * as HashMap from "effect/HashMap";
|
|
10
|
+
import * as Option from "effect/Option";
|
|
11
|
+
import * as Result from "effect/Result";
|
|
12
|
+
import * as Schema from "effect/Schema";
|
|
13
|
+
import { parseExtensionFqnParts, toExtensionTypePlural, } from "@agentxm/extension-model/unstable/extensions/common";
|
|
14
|
+
import { decodeVersionSync } from "@agentxm/extension-model/unstable/version-constraints";
|
|
15
|
+
import { detectPackages } from "./packaging/detect.js";
|
|
16
|
+
import { packageDetectors, packageReaders } from "./packaging/index.js";
|
|
17
|
+
import { PackageUrlSchema } from "@agentxm/extension-model/unstable/packaging/package-url";
|
|
18
|
+
import { readLocalRecommendations } from "./packaging/read.js";
|
|
19
|
+
const encodePurl = Schema.encodeSync(PackageUrlSchema);
|
|
20
|
+
const packageIdentity = (parts) => ({
|
|
21
|
+
type: parts.type,
|
|
22
|
+
name: parts.name,
|
|
23
|
+
...(parts.namespace === undefined ? {} : { namespace: parts.namespace }),
|
|
24
|
+
...(parts.qualifiers === undefined ? {} : { qualifiers: parts.qualifiers }),
|
|
25
|
+
...(parts.subpath === undefined ? {} : { subpath: parts.subpath }),
|
|
26
|
+
});
|
|
27
|
+
const extensionDeclarationToRef = (value) => {
|
|
28
|
+
const parts = parseExtensionFqnParts(value.ref);
|
|
29
|
+
if (parts === undefined) {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
return `${parts.owner}/${toExtensionTypePlural(parts.type)}/${parts.name}`;
|
|
33
|
+
};
|
|
34
|
+
export const discover = (projectDir, registryClient) => Effect.gen(function* () {
|
|
35
|
+
const detected = yield* detectPackages(projectDir, packageDetectors).pipe(Effect.withSpan("discover.detect"));
|
|
36
|
+
if (detected.length === 0) {
|
|
37
|
+
return {
|
|
38
|
+
packages: [],
|
|
39
|
+
totalDetected: 0,
|
|
40
|
+
registryAvailable: true,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
const localExtensions = yield* readLocalRecommendations(detected, packageReaders).pipe(Effect.withSpan("discover.readLocal"));
|
|
44
|
+
// v1 submits direct dependencies only. Revisit transitive submission and
|
|
45
|
+
// privacy-mode filtering together so users get one coherent consent model.
|
|
46
|
+
const submittedPackages = detected.flatMap((pkg) => {
|
|
47
|
+
if (pkg.purl.version === undefined) {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
const purl = encodePurl(pkg.purl);
|
|
51
|
+
const declaredExtensions = Option.match(HashMap.get(localExtensions, purl), {
|
|
52
|
+
onNone: () => [],
|
|
53
|
+
onSome: (value) => value,
|
|
54
|
+
});
|
|
55
|
+
return [
|
|
56
|
+
{
|
|
57
|
+
purl: packageIdentity(pkg.purl),
|
|
58
|
+
version: pkg.purl.version,
|
|
59
|
+
declaredExtensions,
|
|
60
|
+
},
|
|
61
|
+
];
|
|
62
|
+
});
|
|
63
|
+
const registryResult = yield* Effect.result(registryClient.discoverPackages({ packages: submittedPackages })).pipe(Effect.withSpan("discover.queryRegistry"));
|
|
64
|
+
if (Result.isFailure(registryResult)) {
|
|
65
|
+
yield* Effect.logWarning("Registry is unreachable; showing local package declarations only");
|
|
66
|
+
}
|
|
67
|
+
const registryAvailable = Result.isSuccess(registryResult);
|
|
68
|
+
const packages = registryAvailable
|
|
69
|
+
? mergeRegistryResults(detected, registryResult.success.results)
|
|
70
|
+
: buildLocalOnlyResults(detected, localExtensions);
|
|
71
|
+
return {
|
|
72
|
+
packages,
|
|
73
|
+
totalDetected: detected.length,
|
|
74
|
+
registryAvailable,
|
|
75
|
+
};
|
|
76
|
+
}).pipe(Effect.annotateLogs({ command: "discover", projectDir }), Effect.withSpan("discover"));
|
|
77
|
+
const mergeRegistryResults = (detected, results) => {
|
|
78
|
+
const detectedByIdentity = new Map(detected.map((pkg) => [encodePurl(packageIdentity(pkg.purl)), pkg.purl]));
|
|
79
|
+
return results.flatMap((result) => {
|
|
80
|
+
const detectedPackage = detectedByIdentity.get(result.purl);
|
|
81
|
+
if (detectedPackage === undefined || result.extensions.length === 0) {
|
|
82
|
+
return [];
|
|
83
|
+
}
|
|
84
|
+
return [
|
|
85
|
+
{
|
|
86
|
+
detectedPackage,
|
|
87
|
+
extensions: result.extensions.map((entry) => ({
|
|
88
|
+
ref: entry.ref,
|
|
89
|
+
resolved: entry.resolved,
|
|
90
|
+
extension: entry.extension,
|
|
91
|
+
attestedBy: entry.attestedBy,
|
|
92
|
+
official: entry.official,
|
|
93
|
+
packageVersionInRange: entry.packageVersionInRange,
|
|
94
|
+
})),
|
|
95
|
+
},
|
|
96
|
+
];
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
const buildLocalOnlyResults = (detected, localExtensions) => {
|
|
100
|
+
const fallbackVersion = decodeVersionSync("0.0.0");
|
|
101
|
+
return detected.flatMap((pkg) => {
|
|
102
|
+
const refs = HashMap.get(localExtensions, encodePurl(pkg.purl));
|
|
103
|
+
if (Option.isNone(refs) || refs.value.length === 0) {
|
|
104
|
+
return [];
|
|
105
|
+
}
|
|
106
|
+
const extensions = refs.value.flatMap((entry) => {
|
|
107
|
+
const parts = parseExtensionFqnParts(entry.ref);
|
|
108
|
+
const ref = extensionDeclarationToRef(entry);
|
|
109
|
+
if (parts === undefined || ref === undefined) {
|
|
110
|
+
return [];
|
|
111
|
+
}
|
|
112
|
+
return [
|
|
113
|
+
{
|
|
114
|
+
ref,
|
|
115
|
+
resolved: true,
|
|
116
|
+
extension: {
|
|
117
|
+
owner: parts.owner,
|
|
118
|
+
type: parts.type,
|
|
119
|
+
name: parts.name,
|
|
120
|
+
installVersion: fallbackVersion,
|
|
121
|
+
},
|
|
122
|
+
attestedBy: ["package"],
|
|
123
|
+
official: false,
|
|
124
|
+
packageVersionInRange: true,
|
|
125
|
+
},
|
|
126
|
+
];
|
|
127
|
+
});
|
|
128
|
+
return extensions.length === 0
|
|
129
|
+
? []
|
|
130
|
+
: [{ detectedPackage: pkg.purl, extensions }];
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
//# sourceMappingURL=discover.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extension-discovery feature: project package detectors, package-native
|
|
3
|
+
* extension declarations, Registry recommendations, and discovery results.
|
|
4
|
+
*
|
|
5
|
+
* @experimental All exports from this module are unstable and may change without notice.
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
export { discover, type DiscoverResult, type DiscoverPackageResult, type DiscoverResultEntry, } from "./discover.js";
|
|
9
|
+
export type { DetectedPackage, PackageDetector, PackageReader } from "./packaging/types.js";
|
|
10
|
+
export { detectPackages } from "./packaging/detect.js";
|
|
11
|
+
export { readLocalRecommendations } from "./packaging/read.js";
|
|
12
|
+
export { packageDetectors, packageReaders } from "./packaging/index.js";
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extension-discovery feature: project package detectors, package-native
|
|
3
|
+
* extension declarations, Registry recommendations, and discovery results.
|
|
4
|
+
*
|
|
5
|
+
* @experimental All exports from this module are unstable and may change without notice.
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
export { discover, } from "./discover.js";
|
|
9
|
+
export { detectPackages } from "./packaging/detect.js";
|
|
10
|
+
export { readLocalRecommendations } from "./packaging/read.js";
|
|
11
|
+
export { packageDetectors, packageReaders } from "./packaging/index.js";
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment variable access for package detectors.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the shared helpers the extracted kernels carry; a generic utils
|
|
5
|
+
* package is deliberately not created.
|
|
6
|
+
*/
|
|
7
|
+
import * as Effect from "effect/Effect";
|
|
8
|
+
import * as Option from "effect/Option";
|
|
9
|
+
export declare const readEnv: (name: string) => string | undefined;
|
|
10
|
+
/** Read an optional env var. Centralized access point for process.env. */
|
|
11
|
+
export declare const envOption: (name: string) => Effect.Effect<Option.Option<string>>;
|
|
12
|
+
/** Read an env var with a default value. Centralized access point for process.env. */
|
|
13
|
+
export declare const envWithDefault: (name: string, fallback: string) => Effect.Effect<string>;
|
|
14
|
+
//# sourceMappingURL=environment.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment variable access for package detectors.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the shared helpers the extracted kernels carry; a generic utils
|
|
5
|
+
* package is deliberately not created.
|
|
6
|
+
*/
|
|
7
|
+
import * as Effect from "effect/Effect";
|
|
8
|
+
import * as Option from "effect/Option";
|
|
9
|
+
// eslint-disable-next-line no-restricted-properties -- Centralized env var access point; all callers use these helpers
|
|
10
|
+
export const readEnv = (name) => process.env[name];
|
|
11
|
+
/** Read an optional env var. Centralized access point for process.env. */
|
|
12
|
+
export const envOption = (name) => Effect.sync(() => Option.fromUndefinedOr(readEnv(name)));
|
|
13
|
+
/** Read an env var with a default value. Centralized access point for process.env. */
|
|
14
|
+
export const envWithDefault = (name, fallback) => Effect.sync(() => readEnv(name) ?? fallback);
|
|
15
|
+
//# sourceMappingURL=environment.js.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bazel package detector and reader for package-compatibility discovery.
|
|
3
|
+
*
|
|
4
|
+
* @experimental This API is unstable and may change without notice.
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
import type { PackageDetector, PackageReader } from "./types.js";
|
|
8
|
+
/**
|
|
9
|
+
* Bazel package detector.
|
|
10
|
+
*
|
|
11
|
+
* Scans `MODULE.bazel` for `bazel_dep()` calls. Dependencies are deduplicated
|
|
12
|
+
* by name.
|
|
13
|
+
*
|
|
14
|
+
* @experimental This API is unstable and may change without notice.
|
|
15
|
+
*/
|
|
16
|
+
export declare const bazelDetector: PackageDetector;
|
|
17
|
+
/**
|
|
18
|
+
* Bazel package reader.
|
|
19
|
+
*
|
|
20
|
+
* Reads `axm.json` from the Bazel external repository directory under
|
|
21
|
+
* the output base (`external/<repo>/`). The output base is checked via
|
|
22
|
+
* the BAZEL_OUTPUT_BASE environment variable or a default location.
|
|
23
|
+
*
|
|
24
|
+
* @experimental This API is unstable and may change without notice.
|
|
25
|
+
*/
|
|
26
|
+
export declare const bazelReader: PackageReader;
|
|
27
|
+
//# sourceMappingURL=bazel.d.ts.map
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bazel package detector and reader for package-compatibility discovery.
|
|
3
|
+
*
|
|
4
|
+
* @experimental This API is unstable and may change without notice.
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
import * as Effect from "effect/Effect";
|
|
8
|
+
import * as Option from "effect/Option";
|
|
9
|
+
import * as Path from "effect/Path";
|
|
10
|
+
import * as Result from "effect/Result";
|
|
11
|
+
import * as Schema from "effect/Schema";
|
|
12
|
+
import { PackageURL } from "packageurl-js";
|
|
13
|
+
import { readEnv } from "../internal/environment.js";
|
|
14
|
+
import { PackageTypeSchema } from "@agentxm/extension-model/unstable/packaging/package-type";
|
|
15
|
+
import { decodeAxmMeta, decodePurl, parseJsonOptional, readFileOptional } from "./reader-io.js";
|
|
16
|
+
const bazelType = Schema.decodeUnknownSync(PackageTypeSchema)("bazel");
|
|
17
|
+
/**
|
|
18
|
+
* Parse MODULE.bazel content for bazel_dep() calls.
|
|
19
|
+
* Format: bazel_dep(name = "rules_go", version = "0.41.0")
|
|
20
|
+
*/
|
|
21
|
+
const parseModuleBazel = (content, source) => {
|
|
22
|
+
const results = [];
|
|
23
|
+
// Match bazel_dep(...) calls, handling multi-line
|
|
24
|
+
const bazelDepRegex = /bazel_dep\s*\(([^)]*)\)/g;
|
|
25
|
+
let match;
|
|
26
|
+
while ((match = bazelDepRegex.exec(content)) !== null) {
|
|
27
|
+
const args = match[1];
|
|
28
|
+
if (args === undefined)
|
|
29
|
+
continue;
|
|
30
|
+
// Extract name attribute
|
|
31
|
+
const nameMatch = /name\s*=\s*"([^"]+)"/.exec(args);
|
|
32
|
+
if (nameMatch === null || nameMatch[1] === undefined)
|
|
33
|
+
continue;
|
|
34
|
+
const name = nameMatch[1];
|
|
35
|
+
// Extract optional version attribute
|
|
36
|
+
const versionMatch = /version\s*=\s*"([^"]+)"/.exec(args);
|
|
37
|
+
const version = versionMatch?.[1];
|
|
38
|
+
const purl = new PackageURL("bazel", null, name, version ?? null, null, null);
|
|
39
|
+
const purlParts = decodePurl(purl.toString());
|
|
40
|
+
results.push({ purl: purlParts, type: bazelType, source });
|
|
41
|
+
}
|
|
42
|
+
return results;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Bazel package detector.
|
|
46
|
+
*
|
|
47
|
+
* Scans `MODULE.bazel` for `bazel_dep()` calls. Dependencies are deduplicated
|
|
48
|
+
* by name.
|
|
49
|
+
*
|
|
50
|
+
* @experimental This API is unstable and may change without notice.
|
|
51
|
+
*/
|
|
52
|
+
export const bazelDetector = {
|
|
53
|
+
type: bazelType,
|
|
54
|
+
detect: Effect.fn("detect.bazel")(function* (projectDir) {
|
|
55
|
+
const path = yield* Path.Path;
|
|
56
|
+
const allDeps = [];
|
|
57
|
+
const seenNames = new Set();
|
|
58
|
+
const addDeps = (deps) => {
|
|
59
|
+
for (const dep of deps) {
|
|
60
|
+
if (!seenNames.has(dep.purl.name)) {
|
|
61
|
+
seenNames.add(dep.purl.name);
|
|
62
|
+
allDeps.push(dep);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
// Parse MODULE.bazel (preferred Bzlmod format)
|
|
67
|
+
const moduleBazelPath = path.join(projectDir, "MODULE.bazel");
|
|
68
|
+
const moduleContent = yield* readFileOptional(moduleBazelPath);
|
|
69
|
+
if (Option.isSome(moduleContent)) {
|
|
70
|
+
const deps = parseModuleBazel(moduleContent.value, moduleBazelPath);
|
|
71
|
+
if (deps.length === 0 && moduleContent.value.trim().length > 0) {
|
|
72
|
+
if (!moduleContent.value.includes("module(") &&
|
|
73
|
+
!moduleContent.value.includes("bazel_dep")) {
|
|
74
|
+
yield* Effect.logWarning("Malformed MODULE.bazel, skipping");
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
addDeps(deps);
|
|
78
|
+
}
|
|
79
|
+
return allDeps;
|
|
80
|
+
}, Effect.annotateLogs({ detector: "bazel" }), Effect.withSpan("detect.bazel")),
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Bazel package reader.
|
|
84
|
+
*
|
|
85
|
+
* Reads `axm.json` from the Bazel external repository directory under
|
|
86
|
+
* the output base (`external/<repo>/`). The output base is checked via
|
|
87
|
+
* the BAZEL_OUTPUT_BASE environment variable or a default location.
|
|
88
|
+
*
|
|
89
|
+
* @experimental This API is unstable and may change without notice.
|
|
90
|
+
*/
|
|
91
|
+
export const bazelReader = {
|
|
92
|
+
type: bazelType,
|
|
93
|
+
read: Effect.fn("read.bazel")(function* (pkg) {
|
|
94
|
+
const path = yield* Path.Path;
|
|
95
|
+
const pkgName = pkg.purl.name;
|
|
96
|
+
// Derive project directory from the source manifest path
|
|
97
|
+
const projectDir = path.dirname(pkg.source);
|
|
98
|
+
// Try to find output base from environment or common location
|
|
99
|
+
const outputBase = readEnv("BAZEL_OUTPUT_BASE");
|
|
100
|
+
// Candidate paths for axm.json
|
|
101
|
+
const candidatePaths = [];
|
|
102
|
+
if (outputBase !== undefined) {
|
|
103
|
+
candidatePaths.push(path.join(outputBase, "external", pkgName, "axm.json"));
|
|
104
|
+
}
|
|
105
|
+
// Also try project-local bazel-out external directory
|
|
106
|
+
candidatePaths.push(path.join(projectDir, "bazel-out", "external", pkgName, "axm.json"));
|
|
107
|
+
candidatePaths.push(path.join(projectDir, "bazel-" + path.basename(projectDir), "external", pkgName, "axm.json"));
|
|
108
|
+
for (const candidatePath of candidatePaths) {
|
|
109
|
+
const content = yield* readFileOptional(candidatePath);
|
|
110
|
+
if (Option.isNone(content))
|
|
111
|
+
continue;
|
|
112
|
+
const parsed = yield* parseJsonOptional(content.value, `${pkgName}/axm.json`);
|
|
113
|
+
if (Option.isNone(parsed))
|
|
114
|
+
return Option.none();
|
|
115
|
+
const metaResult = decodeAxmMeta(parsed.value);
|
|
116
|
+
if (Result.isFailure(metaResult)) {
|
|
117
|
+
yield* Effect.logWarning(`Invalid axm metadata in ${pkgName}: schema validation failed`);
|
|
118
|
+
return Option.none();
|
|
119
|
+
}
|
|
120
|
+
return Option.some(metaResult.success.extensions);
|
|
121
|
+
}
|
|
122
|
+
return Option.none();
|
|
123
|
+
}, Effect.annotateLogs({ reader: "bazel" }), Effect.withSpan("read.bazel")),
|
|
124
|
+
};
|
|
125
|
+
//# sourceMappingURL=bazel.js.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cargo (Rust) package detector and reader for package-compatibility discovery.
|
|
3
|
+
*
|
|
4
|
+
* @experimental This API is unstable and may change without notice.
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
import type { PackageDetector, PackageReader } from "./types.js";
|
|
8
|
+
/**
|
|
9
|
+
* Cargo package detector.
|
|
10
|
+
*
|
|
11
|
+
* Scans `Cargo.toml` in the project directory and extracts dependencies
|
|
12
|
+
* from `[dependencies]`, `[dev-dependencies]`, and `[build-dependencies]`.
|
|
13
|
+
*
|
|
14
|
+
* @experimental This API is unstable and may change without notice.
|
|
15
|
+
*/
|
|
16
|
+
export declare const cargoDetector: PackageDetector;
|
|
17
|
+
/**
|
|
18
|
+
* Cargo package reader.
|
|
19
|
+
*
|
|
20
|
+
* Reads `[package.metadata.axm]` from
|
|
21
|
+
* `$CARGO_HOME/registry/src/<index>/<crate>-<version>/Cargo.toml` for each
|
|
22
|
+
* detected cargo crate. `[package.metadata.*]` is Cargo's standard
|
|
23
|
+
* extensibility mechanism for third-party tools (used by docs.rs, cargo-deb,
|
|
24
|
+
* cargo-bundle, etc.).
|
|
25
|
+
*
|
|
26
|
+
* When the crate version is unknown, scans the registry source directory
|
|
27
|
+
* for any matching crate directory.
|
|
28
|
+
*
|
|
29
|
+
* @experimental This API is unstable and may change without notice.
|
|
30
|
+
*/
|
|
31
|
+
export declare const cargoReader: PackageReader;
|
|
32
|
+
//# sourceMappingURL=cargo.d.ts.map
|