@agentxm/extension-sources 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/README.md +9 -0
- package/dist/src/axm-skill-gate.d.ts +64 -0
- package/dist/src/axm-skill-gate.js +25 -0
- package/dist/src/errors.d.ts +116 -0
- package/dist/src/errors.js +98 -0
- package/dist/src/failure-category.d.ts +10 -0
- package/dist/src/failure-category.js +2 -0
- package/dist/src/file-url.d.ts +9 -0
- package/dist/src/file-url.js +12 -0
- package/dist/src/git/detect.d.ts +7 -0
- package/dist/src/git/detect.js +23 -0
- package/dist/src/git/operations.d.ts +37 -0
- package/dist/src/git/operations.js +101 -0
- package/dist/src/glob.d.ts +39 -0
- package/dist/src/glob.js +79 -0
- package/dist/src/hook-package-discovery.d.ts +19 -0
- package/dist/src/hook-package-discovery.js +14 -0
- package/dist/src/index.d.ts +30 -0
- package/dist/src/index.js +35 -0
- package/dist/src/integrity.d.ts +13 -0
- package/dist/src/integrity.js +17 -0
- package/dist/src/live.d.ts +29 -0
- package/dist/src/live.js +131 -0
- package/dist/src/manifest-package-discovery.d.ts +28 -0
- package/dist/src/manifest-package-discovery.js +96 -0
- package/dist/src/package-discovery.d.ts +19 -0
- package/dist/src/package-discovery.js +137 -0
- package/dist/src/package-sources.d.ts +25 -0
- package/dist/src/package-sources.js +102 -0
- package/dist/src/providers/azurerepos/index.d.ts +11 -0
- package/dist/src/providers/azurerepos/index.js +11 -0
- package/dist/src/providers/azurerepos/repo-exists.d.ts +5 -0
- package/dist/src/providers/azurerepos/repo-exists.js +21 -0
- package/dist/src/providers/azurerepos/scp.d.ts +12 -0
- package/dist/src/providers/azurerepos/scp.js +29 -0
- package/dist/src/providers/azurerepos/shorthand.d.ts +12 -0
- package/dist/src/providers/azurerepos/shorthand.js +45 -0
- package/dist/src/providers/azurerepos/url.d.ts +14 -0
- package/dist/src/providers/azurerepos/url.js +38 -0
- package/dist/src/providers/bitbucket/index.d.ts +11 -0
- package/dist/src/providers/bitbucket/index.js +11 -0
- package/dist/src/providers/bitbucket/resolve-repo.d.ts +11 -0
- package/dist/src/providers/bitbucket/resolve-repo.js +33 -0
- package/dist/src/providers/bitbucket/scp.d.ts +11 -0
- package/dist/src/providers/bitbucket/scp.js +28 -0
- package/dist/src/providers/bitbucket/shorthand.d.ts +10 -0
- package/dist/src/providers/bitbucket/shorthand.js +11 -0
- package/dist/src/providers/bitbucket/url.d.ts +13 -0
- package/dist/src/providers/bitbucket/url.js +42 -0
- package/dist/src/providers/convention-discovery.d.ts +11 -0
- package/dist/src/providers/convention-discovery.js +473 -0
- package/dist/src/providers/git-hosting.d.ts +31 -0
- package/dist/src/providers/git-hosting.js +73 -0
- package/dist/src/providers/git.d.ts +22 -0
- package/dist/src/providers/git.js +46 -0
- package/dist/src/providers/github/index.d.ts +11 -0
- package/dist/src/providers/github/index.js +11 -0
- package/dist/src/providers/github/resolve-repo.d.ts +11 -0
- package/dist/src/providers/github/resolve-repo.js +34 -0
- package/dist/src/providers/github/scp.d.ts +11 -0
- package/dist/src/providers/github/scp.js +28 -0
- package/dist/src/providers/github/shorthand.d.ts +10 -0
- package/dist/src/providers/github/shorthand.js +11 -0
- package/dist/src/providers/github/url.d.ts +13 -0
- package/dist/src/providers/github/url.js +42 -0
- package/dist/src/providers/gitlab/index.d.ts +11 -0
- package/dist/src/providers/gitlab/index.js +11 -0
- package/dist/src/providers/gitlab/resolve-repo.d.ts +11 -0
- package/dist/src/providers/gitlab/resolve-repo.js +33 -0
- package/dist/src/providers/gitlab/scp.d.ts +11 -0
- package/dist/src/providers/gitlab/scp.js +28 -0
- package/dist/src/providers/gitlab/shorthand.d.ts +10 -0
- package/dist/src/providers/gitlab/shorthand.js +11 -0
- package/dist/src/providers/gitlab/url.d.ts +13 -0
- package/dist/src/providers/gitlab/url.js +42 -0
- package/dist/src/providers/local-parser/index.d.ts +8 -0
- package/dist/src/providers/local-parser/index.js +8 -0
- package/dist/src/providers/local-parser/parser.d.ts +13 -0
- package/dist/src/providers/local-parser/parser.js +14 -0
- package/dist/src/providers/local.d.ts +23 -0
- package/dist/src/providers/local.js +39 -0
- package/dist/src/providers/parse-provider-shorthand.d.ts +18 -0
- package/dist/src/providers/parse-provider-shorthand.js +74 -0
- package/dist/src/providers/registry/host-provider.d.ts +47 -0
- package/dist/src/providers/registry/host-provider.js +584 -0
- package/dist/src/resolve-identifier.d.ts +73 -0
- package/dist/src/resolve-identifier.js +273 -0
- package/dist/src/resolve-source-pattern.d.ts +29 -0
- package/dist/src/resolve-source-pattern.js +77 -0
- package/dist/src/resolve-source.d.ts +79 -0
- package/dist/src/resolve-source.js +503 -0
- package/dist/src/rule-package-discovery.d.ts +19 -0
- package/dist/src/rule-package-discovery.js +14 -0
- package/dist/src/service.d.ts +72 -0
- package/dist/src/service.js +109 -0
- package/dist/src/url-fragment.d.ts +5 -0
- package/dist/src/url-fragment.js +19 -0
- package/dist/src/workspace-catalog.d.ts +79 -0
- package/dist/src/workspace-catalog.js +26 -0
- package/package.json +57 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Source provider for generic git repositories.
|
|
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 FileSystem from "effect/FileSystem";
|
|
9
|
+
import * as Option from "effect/Option";
|
|
10
|
+
import * as Path from "effect/Path";
|
|
11
|
+
import { SourceNetworkFailure } from "../errors.js";
|
|
12
|
+
import { shallowClone } from "../git/operations.js";
|
|
13
|
+
import { fileUrlToPath } from "../file-url.js";
|
|
14
|
+
import { discoverConventionRefs } from "./convention-discovery.js";
|
|
15
|
+
/**
|
|
16
|
+
* Source host provider for generic git URLs.
|
|
17
|
+
*
|
|
18
|
+
* Self-describing — no host config needed.
|
|
19
|
+
* `match` returns true for git://, ssh://, and git@... URL schemes.
|
|
20
|
+
*
|
|
21
|
+
* @experimental This API is unstable and may change without notice.
|
|
22
|
+
*/
|
|
23
|
+
export const createGitSourceHostProvider = () => ({
|
|
24
|
+
type: "git",
|
|
25
|
+
match: (url) => Effect.succeed(url.protocol === "git:" || url.protocol === "ssh:" || url.href.startsWith("git@")),
|
|
26
|
+
find: (source, options) => Effect.gen(function* () {
|
|
27
|
+
const fs = yield* FileSystem.FileSystem;
|
|
28
|
+
const tempDir = yield* Effect.acquireRelease(fs.makeTempDirectory({ prefix: "axm-source-discovery-" }).pipe(Effect.mapError((error) => new SourceNetworkFailure({
|
|
29
|
+
detail: "Temporary source directory could not be created",
|
|
30
|
+
cause: error,
|
|
31
|
+
}))), (dir) => fs.remove(dir, { recursive: true }).pipe(Effect.ignore));
|
|
32
|
+
yield* shallowClone(source.url.href, tempDir, Option.getOrUndefined(source.ref));
|
|
33
|
+
return yield* discoverConventionRefs(source, tempDir, options);
|
|
34
|
+
}),
|
|
35
|
+
fetch: (_source, ref) => {
|
|
36
|
+
if (ref.refType !== "git-hosted") {
|
|
37
|
+
return Effect.fail(new SourceNetworkFailure({
|
|
38
|
+
detail: "Expected ref with location for git source, but none was provided",
|
|
39
|
+
}));
|
|
40
|
+
}
|
|
41
|
+
return Effect.succeed({
|
|
42
|
+
directory: fileUrlToPath(ref.location),
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
//# sourceMappingURL=git.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitHub source parsing and API operations.
|
|
3
|
+
*
|
|
4
|
+
* @experimental This API is unstable and may change without notice.
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
export { resolveRepo } from "./resolve-repo.js";
|
|
8
|
+
export { parseShorthand } from "./shorthand.js";
|
|
9
|
+
export { parseUrl } from "./url.js";
|
|
10
|
+
export { parseScp } from "./scp.js";
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitHub source parsing and API operations.
|
|
3
|
+
*
|
|
4
|
+
* @experimental This API is unstable and may change without notice.
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
export { resolveRepo } from "./resolve-repo.js";
|
|
8
|
+
export { parseShorthand } from "./shorthand.js";
|
|
9
|
+
export { parseUrl } from "./url.js";
|
|
10
|
+
export { parseScp } from "./scp.js";
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as HttpClient from "effect/unstable/http/HttpClient";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Option from "effect/Option";
|
|
4
|
+
import { SourceNotResolvable } from "../../errors.js";
|
|
5
|
+
import type { GitHubSourceParams } from "@agentxm/extension-model/unstable/sources/types";
|
|
6
|
+
export declare const resolveRepo: (args: {
|
|
7
|
+
readonly owner: string;
|
|
8
|
+
readonly repo: string;
|
|
9
|
+
readonly subPath: Option.Option<string>;
|
|
10
|
+
}) => Effect.Effect<Option.Option<GitHubSourceParams>, SourceNotResolvable, HttpClient.HttpClient>;
|
|
11
|
+
//# sourceMappingURL=resolve-repo.d.ts.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as HttpClient from "effect/unstable/http/HttpClient";
|
|
2
|
+
import * as HttpClientRequest from "effect/unstable/http/HttpClientRequest";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import * as Option from "effect/Option";
|
|
5
|
+
import { SourceNotResolvable } from "../../errors.js";
|
|
6
|
+
const headRequest = (url, _input) => Effect.gen(function* () {
|
|
7
|
+
const client = yield* HttpClient.HttpClient;
|
|
8
|
+
const request = HttpClientRequest.head(url);
|
|
9
|
+
return yield* client.execute(request).pipe(Effect.mapError((error) => new SourceNotResolvable({
|
|
10
|
+
category: "validation",
|
|
11
|
+
detail: `Failed to check GitHub: ${error.reason._tag === "TransportError" ? String(error.reason.cause) : `HTTP error`}`,
|
|
12
|
+
cause: error,
|
|
13
|
+
})));
|
|
14
|
+
});
|
|
15
|
+
export const resolveRepo = (args) => Effect.gen(function* () {
|
|
16
|
+
const repoUrl = `https://github.com/${args.owner}/${args.repo}`;
|
|
17
|
+
const repoResponse = yield* headRequest(repoUrl, `${args.owner}/${args.repo}`);
|
|
18
|
+
if (repoResponse.status !== 200)
|
|
19
|
+
return Option.none();
|
|
20
|
+
if (Option.isSome(args.subPath)) {
|
|
21
|
+
const subPathUrl = `${repoUrl}/tree/HEAD/${args.subPath.value}`;
|
|
22
|
+
const subPathResponse = yield* headRequest(subPathUrl, `${args.owner}/${args.repo}/${args.subPath.value}`);
|
|
23
|
+
if (subPathResponse.status !== 200)
|
|
24
|
+
return Option.none();
|
|
25
|
+
}
|
|
26
|
+
return Option.some({
|
|
27
|
+
type: "github",
|
|
28
|
+
owner: args.owner,
|
|
29
|
+
repo: args.repo,
|
|
30
|
+
ref: Option.none(),
|
|
31
|
+
subPath: args.subPath,
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
//# sourceMappingURL=resolve-repo.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import { SourceSyntaxInvalid } from "../../errors.js";
|
|
3
|
+
export declare const parseScp: (input: string, hostname?: string) => Effect.Effect<never, SourceSyntaxInvalid, never> | Effect.Effect<{
|
|
4
|
+
readonly owner: string;
|
|
5
|
+
readonly type: "github";
|
|
6
|
+
readonly repo: string;
|
|
7
|
+
readonly ref: import("effect/Option").Option<string>;
|
|
8
|
+
readonly subPath: import("effect/Option").Option<string>;
|
|
9
|
+
readonly sourceName?: string | undefined;
|
|
10
|
+
}, never, never>;
|
|
11
|
+
//# sourceMappingURL=scp.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Result from "effect/Result";
|
|
3
|
+
import * as Schema from "effect/Schema";
|
|
4
|
+
import { SourceSyntaxInvalid } from "../../errors.js";
|
|
5
|
+
import { GitHubSourceParamsSchema, } from "@agentxm/extension-model/unstable/sources/types";
|
|
6
|
+
import { CANONICAL_HOSTNAME } from "./url.js";
|
|
7
|
+
/** Matches: git@{hostname}:owner/repo.git */
|
|
8
|
+
const SCP_PATTERN = /^git@([^:]+):([^/]+)\/([^/]+?)(?:\.git)?$/;
|
|
9
|
+
const decodeGitHubSourceParams = Schema.decodeUnknownResult(GitHubSourceParamsSchema);
|
|
10
|
+
export const parseScp = (input, hostname = CANONICAL_HOSTNAME) => {
|
|
11
|
+
const match = input.match(SCP_PATTERN);
|
|
12
|
+
if (!match || !match[1] || !match[2] || !match[3] || match[1] !== hostname) {
|
|
13
|
+
return Effect.fail(new SourceSyntaxInvalid({
|
|
14
|
+
detail: "Invalid GitHub SSH URL format",
|
|
15
|
+
}));
|
|
16
|
+
}
|
|
17
|
+
const decoded = decodeGitHubSourceParams({
|
|
18
|
+
type: "github",
|
|
19
|
+
owner: match[2],
|
|
20
|
+
repo: match[3],
|
|
21
|
+
});
|
|
22
|
+
return Result.isSuccess(decoded)
|
|
23
|
+
? Effect.succeed(decoded.success)
|
|
24
|
+
: Effect.fail(new SourceSyntaxInvalid({
|
|
25
|
+
detail: "Invalid GitHub SSH URL format",
|
|
26
|
+
}));
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=scp.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
export declare const parseShorthand: (input: string) => Effect.Effect<{
|
|
3
|
+
owner: string;
|
|
4
|
+
repo: string;
|
|
5
|
+
ref: import("effect/Option").Option<string>;
|
|
6
|
+
subPath: import("effect/Option").Option<string>;
|
|
7
|
+
sourceName?: string | undefined;
|
|
8
|
+
type: "github";
|
|
9
|
+
}, import("../../errors.ts").SourceSyntaxInvalid, never>;
|
|
10
|
+
//# sourceMappingURL=shorthand.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import { parseProviderShorthand } from "../parse-provider-shorthand.js";
|
|
3
|
+
export const parseShorthand = (input) => Effect.gen(function* () {
|
|
4
|
+
const body = input.slice("github:".length);
|
|
5
|
+
const parts = yield* parseProviderShorthand(body, input);
|
|
6
|
+
return {
|
|
7
|
+
type: "github",
|
|
8
|
+
...parts,
|
|
9
|
+
};
|
|
10
|
+
});
|
|
11
|
+
//# sourceMappingURL=shorthand.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Option from "effect/Option";
|
|
3
|
+
import { SourceSyntaxInvalid } from "../../errors.js";
|
|
4
|
+
export declare const CANONICAL_HOSTNAME = "github.com";
|
|
5
|
+
export declare const parseUrl: (url: URL, hostname?: string) => Effect.Effect<never, SourceSyntaxInvalid, never> | Effect.Effect<{
|
|
6
|
+
readonly owner: string;
|
|
7
|
+
readonly type: "github";
|
|
8
|
+
readonly repo: string;
|
|
9
|
+
readonly ref: Option.Option<string>;
|
|
10
|
+
readonly subPath: Option.Option<string>;
|
|
11
|
+
readonly sourceName?: string | undefined;
|
|
12
|
+
}, never, never>;
|
|
13
|
+
//# sourceMappingURL=url.d.ts.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Option from "effect/Option";
|
|
3
|
+
import * as Result from "effect/Result";
|
|
4
|
+
import * as Schema from "effect/Schema";
|
|
5
|
+
import { SourceSyntaxInvalid } from "../../errors.js";
|
|
6
|
+
import { GitHubSourceParamsSchema, } from "@agentxm/extension-model/unstable/sources/types";
|
|
7
|
+
import { refFromUrlHash } from "../../url-fragment.js";
|
|
8
|
+
export const CANONICAL_HOSTNAME = "github.com";
|
|
9
|
+
/** Matches: /owner/repo[/tree/ref/path] */
|
|
10
|
+
const GITHUB_PATH_PATTERN = /^\/([^/]+)\/([^/]+?)(?:\.git)?(?:\/tree\/([^/]+)(?:\/(.+))?)?$/;
|
|
11
|
+
const decodeGitHubSourceParams = Schema.decodeUnknownResult(GitHubSourceParamsSchema);
|
|
12
|
+
export const parseUrl = (url, hostname = CANONICAL_HOSTNAME) => {
|
|
13
|
+
if (url.hostname !== hostname) {
|
|
14
|
+
return Effect.fail(new SourceSyntaxInvalid({
|
|
15
|
+
detail: "Invalid GitHub URL format",
|
|
16
|
+
}));
|
|
17
|
+
}
|
|
18
|
+
const match = url.pathname.match(GITHUB_PATH_PATTERN);
|
|
19
|
+
if (!match || !match[1] || !match[2]) {
|
|
20
|
+
return Effect.fail(new SourceSyntaxInvalid({
|
|
21
|
+
detail: "Invalid GitHub URL format",
|
|
22
|
+
}));
|
|
23
|
+
}
|
|
24
|
+
const fragmentRef = Option.getOrUndefined(refFromUrlHash(url));
|
|
25
|
+
const decoded = decodeGitHubSourceParams({
|
|
26
|
+
type: "github",
|
|
27
|
+
owner: match[1],
|
|
28
|
+
repo: match[2],
|
|
29
|
+
...(match[3] === undefined
|
|
30
|
+
? fragmentRef === undefined
|
|
31
|
+
? {}
|
|
32
|
+
: { ref: fragmentRef }
|
|
33
|
+
: { ref: match[3] }),
|
|
34
|
+
...(match[4] === undefined ? {} : { subPath: match[4] }),
|
|
35
|
+
});
|
|
36
|
+
return Result.isSuccess(decoded)
|
|
37
|
+
? Effect.succeed(decoded.success)
|
|
38
|
+
: Effect.fail(new SourceSyntaxInvalid({
|
|
39
|
+
detail: "Invalid GitHub URL format",
|
|
40
|
+
}));
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=url.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitLab source parsing.
|
|
3
|
+
*
|
|
4
|
+
* @experimental This API is unstable and may change without notice.
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
export { resolveRepo } from "./resolve-repo.js";
|
|
8
|
+
export { parseShorthand } from "./shorthand.js";
|
|
9
|
+
export { parseUrl } from "./url.js";
|
|
10
|
+
export { parseScp } from "./scp.js";
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitLab source parsing.
|
|
3
|
+
*
|
|
4
|
+
* @experimental This API is unstable and may change without notice.
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
export { resolveRepo } from "./resolve-repo.js";
|
|
8
|
+
export { parseShorthand } from "./shorthand.js";
|
|
9
|
+
export { parseUrl } from "./url.js";
|
|
10
|
+
export { parseScp } from "./scp.js";
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Option from "effect/Option";
|
|
3
|
+
import * as HttpClient from "effect/unstable/http/HttpClient";
|
|
4
|
+
import { SourceNotResolvable } from "../../errors.js";
|
|
5
|
+
import type { GitLabSourceParams } from "@agentxm/extension-model/unstable/sources/types";
|
|
6
|
+
export declare const resolveRepo: (args: {
|
|
7
|
+
readonly owner: string;
|
|
8
|
+
readonly repo: string;
|
|
9
|
+
readonly subPath: Option.Option<string>;
|
|
10
|
+
}) => Effect.Effect<Option.Option<GitLabSourceParams>, SourceNotResolvable, HttpClient.HttpClient>;
|
|
11
|
+
//# sourceMappingURL=resolve-repo.d.ts.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Option from "effect/Option";
|
|
3
|
+
import * as HttpClient from "effect/unstable/http/HttpClient";
|
|
4
|
+
import * as HttpClientRequest from "effect/unstable/http/HttpClientRequest";
|
|
5
|
+
import { SourceNotResolvable } from "../../errors.js";
|
|
6
|
+
const headRequest = (url, _input) => Effect.gen(function* () {
|
|
7
|
+
const client = yield* HttpClient.HttpClient;
|
|
8
|
+
return yield* client.execute(HttpClientRequest.head(url)).pipe(Effect.mapError((error) => new SourceNotResolvable({
|
|
9
|
+
category: "validation",
|
|
10
|
+
detail: `Failed to check GitLab: ${error instanceof Error ? error.message : String(error)}`,
|
|
11
|
+
cause: error,
|
|
12
|
+
})));
|
|
13
|
+
});
|
|
14
|
+
export const resolveRepo = (args) => Effect.gen(function* () {
|
|
15
|
+
const repoUrl = `https://gitlab.com/${args.owner}/${args.repo}`;
|
|
16
|
+
const repoResponse = yield* headRequest(repoUrl, `${args.owner}/${args.repo}`);
|
|
17
|
+
if (repoResponse.status !== 200)
|
|
18
|
+
return Option.none();
|
|
19
|
+
if (Option.isSome(args.subPath)) {
|
|
20
|
+
const subPathUrl = `${repoUrl}/-/tree/HEAD/${args.subPath.value}`;
|
|
21
|
+
const subPathResponse = yield* headRequest(subPathUrl, `${args.owner}/${args.repo}/${args.subPath.value}`);
|
|
22
|
+
if (subPathResponse.status !== 200)
|
|
23
|
+
return Option.none();
|
|
24
|
+
}
|
|
25
|
+
return Option.some({
|
|
26
|
+
type: "gitlab",
|
|
27
|
+
owner: args.owner,
|
|
28
|
+
repo: args.repo,
|
|
29
|
+
ref: Option.none(),
|
|
30
|
+
subPath: args.subPath,
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=resolve-repo.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import { SourceSyntaxInvalid } from "../../errors.js";
|
|
3
|
+
export declare const parseScp: (input: string, hostname?: string) => Effect.Effect<never, SourceSyntaxInvalid, never> | Effect.Effect<{
|
|
4
|
+
readonly owner: string;
|
|
5
|
+
readonly type: "gitlab";
|
|
6
|
+
readonly repo: string;
|
|
7
|
+
readonly ref: import("effect/Option").Option<string>;
|
|
8
|
+
readonly subPath: import("effect/Option").Option<string>;
|
|
9
|
+
readonly sourceName?: string | undefined;
|
|
10
|
+
}, never, never>;
|
|
11
|
+
//# sourceMappingURL=scp.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Result from "effect/Result";
|
|
3
|
+
import * as Schema from "effect/Schema";
|
|
4
|
+
import { SourceSyntaxInvalid } from "../../errors.js";
|
|
5
|
+
import { GitLabSourceParamsSchema, } from "@agentxm/extension-model/unstable/sources/types";
|
|
6
|
+
import { CANONICAL_HOSTNAME } from "./url.js";
|
|
7
|
+
/** Matches: git@{hostname}:owner/repo.git */
|
|
8
|
+
const SCP_PATTERN = /^git@([^:]+):([^/]+)\/([^/]+?)(?:\.git)?$/;
|
|
9
|
+
const decodeGitLabSourceParams = Schema.decodeUnknownResult(GitLabSourceParamsSchema);
|
|
10
|
+
export const parseScp = (input, hostname = CANONICAL_HOSTNAME) => {
|
|
11
|
+
const match = input.match(SCP_PATTERN);
|
|
12
|
+
if (!match || !match[1] || !match[2] || !match[3] || match[1] !== hostname) {
|
|
13
|
+
return Effect.fail(new SourceSyntaxInvalid({
|
|
14
|
+
detail: "Invalid GitLab SSH URL format",
|
|
15
|
+
}));
|
|
16
|
+
}
|
|
17
|
+
const decoded = decodeGitLabSourceParams({
|
|
18
|
+
type: "gitlab",
|
|
19
|
+
owner: match[2],
|
|
20
|
+
repo: match[3],
|
|
21
|
+
});
|
|
22
|
+
return Result.isSuccess(decoded)
|
|
23
|
+
? Effect.succeed(decoded.success)
|
|
24
|
+
: Effect.fail(new SourceSyntaxInvalid({
|
|
25
|
+
detail: "Invalid GitLab SSH URL format",
|
|
26
|
+
}));
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=scp.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
export declare const parseShorthand: (input: string) => Effect.Effect<{
|
|
3
|
+
owner: string;
|
|
4
|
+
repo: string;
|
|
5
|
+
ref: import("effect/Option").Option<string>;
|
|
6
|
+
subPath: import("effect/Option").Option<string>;
|
|
7
|
+
sourceName?: string | undefined;
|
|
8
|
+
type: "gitlab";
|
|
9
|
+
}, import("../../errors.ts").SourceSyntaxInvalid, never>;
|
|
10
|
+
//# sourceMappingURL=shorthand.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import { parseProviderShorthand } from "../parse-provider-shorthand.js";
|
|
3
|
+
export const parseShorthand = (input) => Effect.gen(function* () {
|
|
4
|
+
const body = input.slice("gitlab:".length);
|
|
5
|
+
const parts = yield* parseProviderShorthand(body, input);
|
|
6
|
+
return {
|
|
7
|
+
type: "gitlab",
|
|
8
|
+
...parts,
|
|
9
|
+
};
|
|
10
|
+
});
|
|
11
|
+
//# sourceMappingURL=shorthand.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Option from "effect/Option";
|
|
3
|
+
import { SourceSyntaxInvalid } from "../../errors.js";
|
|
4
|
+
export declare const CANONICAL_HOSTNAME = "gitlab.com";
|
|
5
|
+
export declare const parseUrl: (url: URL, hostname?: string) => Effect.Effect<never, SourceSyntaxInvalid, never> | Effect.Effect<{
|
|
6
|
+
readonly owner: string;
|
|
7
|
+
readonly type: "gitlab";
|
|
8
|
+
readonly repo: string;
|
|
9
|
+
readonly ref: Option.Option<string>;
|
|
10
|
+
readonly subPath: Option.Option<string>;
|
|
11
|
+
readonly sourceName?: string | undefined;
|
|
12
|
+
}, never, never>;
|
|
13
|
+
//# sourceMappingURL=url.d.ts.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Option from "effect/Option";
|
|
3
|
+
import * as Result from "effect/Result";
|
|
4
|
+
import * as Schema from "effect/Schema";
|
|
5
|
+
import { SourceSyntaxInvalid } from "../../errors.js";
|
|
6
|
+
import { GitLabSourceParamsSchema, } from "@agentxm/extension-model/unstable/sources/types";
|
|
7
|
+
import { refFromUrlHash } from "../../url-fragment.js";
|
|
8
|
+
export const CANONICAL_HOSTNAME = "gitlab.com";
|
|
9
|
+
/** Matches: /owner/repo[/-/tree/ref/path] */
|
|
10
|
+
const GITLAB_PATH_PATTERN = /^\/([^/]+)\/([^/]+?)(?:\.git)?(?:\/-\/tree\/([^/]+)(?:\/(.+))?)?$/;
|
|
11
|
+
const decodeGitLabSourceParams = Schema.decodeUnknownResult(GitLabSourceParamsSchema);
|
|
12
|
+
export const parseUrl = (url, hostname = CANONICAL_HOSTNAME) => {
|
|
13
|
+
if (url.hostname !== hostname) {
|
|
14
|
+
return Effect.fail(new SourceSyntaxInvalid({
|
|
15
|
+
detail: "Invalid GitLab URL format",
|
|
16
|
+
}));
|
|
17
|
+
}
|
|
18
|
+
const match = url.pathname.match(GITLAB_PATH_PATTERN);
|
|
19
|
+
if (!match || !match[1] || !match[2]) {
|
|
20
|
+
return Effect.fail(new SourceSyntaxInvalid({
|
|
21
|
+
detail: "Invalid GitLab URL format",
|
|
22
|
+
}));
|
|
23
|
+
}
|
|
24
|
+
const fragmentRef = Option.getOrUndefined(refFromUrlHash(url));
|
|
25
|
+
const decoded = decodeGitLabSourceParams({
|
|
26
|
+
type: "gitlab",
|
|
27
|
+
owner: match[1],
|
|
28
|
+
repo: match[2],
|
|
29
|
+
...(match[3] === undefined
|
|
30
|
+
? fragmentRef === undefined
|
|
31
|
+
? {}
|
|
32
|
+
: { ref: fragmentRef }
|
|
33
|
+
: { ref: match[3] }),
|
|
34
|
+
...(match[4] === undefined ? {} : { subPath: match[4] }),
|
|
35
|
+
});
|
|
36
|
+
return Result.isSuccess(decoded)
|
|
37
|
+
? Effect.succeed(decoded.success)
|
|
38
|
+
: Effect.fail(new SourceSyntaxInvalid({
|
|
39
|
+
detail: "Invalid GitLab URL format",
|
|
40
|
+
}));
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=url.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local source parsers.
|
|
3
|
+
*
|
|
4
|
+
* @experimental This API is unstable and may change without notice.
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
import * as Effect from "effect/Effect";
|
|
8
|
+
import type { LocalSourceParams } from "@agentxm/extension-model/unstable/sources/types";
|
|
9
|
+
/**
|
|
10
|
+
* Parse a local filesystem path.
|
|
11
|
+
*/
|
|
12
|
+
export declare const parseLocalPath: (input: string) => Effect.Effect<LocalSourceParams>;
|
|
13
|
+
//# sourceMappingURL=parser.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local source parsers.
|
|
3
|
+
*
|
|
4
|
+
* @experimental This API is unstable and may change without notice.
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
import * as Effect from "effect/Effect";
|
|
8
|
+
/**
|
|
9
|
+
* Parse a local filesystem path.
|
|
10
|
+
*/
|
|
11
|
+
export const parseLocalPath = (input) => {
|
|
12
|
+
return Effect.succeed({ type: "local", path: input });
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=parser.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Source provider for local filesystem paths.
|
|
3
|
+
*
|
|
4
|
+
* Wraps the existing `skillsInDir` logic into the `SourceHostProvider` interface.
|
|
5
|
+
*
|
|
6
|
+
* @experimental This API is unstable and may change without notice.
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
import type * as FileSystem from "effect/FileSystem";
|
|
10
|
+
import type * as Path from "effect/Path";
|
|
11
|
+
import { type SourceError } from "../errors.js";
|
|
12
|
+
import type { SourceHostProvider } from "@agentxm/extension-model/unstable/sources/source-host-provider";
|
|
13
|
+
import type { LocalSource } from "@agentxm/extension-model/unstable/sources/types";
|
|
14
|
+
/**
|
|
15
|
+
* Source host provider for local filesystem paths.
|
|
16
|
+
*
|
|
17
|
+
* Self-describing — no host config needed.
|
|
18
|
+
* `match` returns true for file:// URLs and absolute/relative paths.
|
|
19
|
+
*
|
|
20
|
+
* @experimental This API is unstable and may change without notice.
|
|
21
|
+
*/
|
|
22
|
+
export declare const createLocalSourceHostProvider: () => SourceHostProvider<LocalSource, FileSystem.FileSystem | Path.Path, SourceError>;
|
|
23
|
+
//# sourceMappingURL=local.d.ts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Source provider for local filesystem paths.
|
|
3
|
+
*
|
|
4
|
+
* Wraps the existing `skillsInDir` logic into the `SourceHostProvider` interface.
|
|
5
|
+
*
|
|
6
|
+
* @experimental This API is unstable and may change without notice.
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
import * as Effect from "effect/Effect";
|
|
10
|
+
import { SourceNetworkFailure } from "../errors.js";
|
|
11
|
+
import { fileUrlToPath } from "../file-url.js";
|
|
12
|
+
import { discoverConventionRefs } from "./convention-discovery.js";
|
|
13
|
+
/**
|
|
14
|
+
* Source host provider for local filesystem paths.
|
|
15
|
+
*
|
|
16
|
+
* Self-describing — no host config needed.
|
|
17
|
+
* `match` returns true for file:// URLs and absolute/relative paths.
|
|
18
|
+
*
|
|
19
|
+
* @experimental This API is unstable and may change without notice.
|
|
20
|
+
*/
|
|
21
|
+
export const createLocalSourceHostProvider = () => ({
|
|
22
|
+
type: "local",
|
|
23
|
+
match: (url) => Effect.succeed(url.protocol === "file:"),
|
|
24
|
+
find: (source, options) => discoverConventionRefs(source, source.path, options).pipe(Effect.mapError((error) => new SourceNetworkFailure({
|
|
25
|
+
detail: "Failed to discover extensions",
|
|
26
|
+
cause: error,
|
|
27
|
+
}))),
|
|
28
|
+
fetch: (_source, ref) => {
|
|
29
|
+
if (ref.refType !== "local") {
|
|
30
|
+
return Effect.fail(new SourceNetworkFailure({
|
|
31
|
+
detail: "Expected ref with location for local source, but none was provided",
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
return Effect.succeed({
|
|
35
|
+
directory: fileUrlToPath(ref.location),
|
|
36
|
+
});
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=local.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared helper for parsing provider shorthand patterns.
|
|
3
|
+
*
|
|
4
|
+
* Parses the `owner/repo[//subpath][@ref]` portion (after stripping the prefix)
|
|
5
|
+
* into constituent parts.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
import * as Effect from "effect/Effect";
|
|
10
|
+
import { SourceSyntaxInvalid } from "../errors.js";
|
|
11
|
+
import { type GitHostedSourceParamParts } from "@agentxm/extension-model/unstable/sources/types";
|
|
12
|
+
/**
|
|
13
|
+
* Parse the body of a provider shorthand (the part after the `prefix:` prefix).
|
|
14
|
+
*
|
|
15
|
+
* Returns `{ owner, repo, subPath?, ref? }` or fails with `SourceSyntaxInvalid`.
|
|
16
|
+
*/
|
|
17
|
+
export declare const parseProviderShorthand: (input: string, original: string) => Effect.Effect<GitHostedSourceParamParts, SourceSyntaxInvalid>;
|
|
18
|
+
//# sourceMappingURL=parse-provider-shorthand.d.ts.map
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared helper for parsing provider shorthand patterns.
|
|
3
|
+
*
|
|
4
|
+
* Parses the `owner/repo[//subpath][@ref]` portion (after stripping the prefix)
|
|
5
|
+
* into constituent parts.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
import * as Effect from "effect/Effect";
|
|
10
|
+
import * as Result from "effect/Result";
|
|
11
|
+
import * as Schema from "effect/Schema";
|
|
12
|
+
import { SourceSyntaxInvalid } from "../errors.js";
|
|
13
|
+
import { GitHostedSourceParamPartsSchema, } from "@agentxm/extension-model/unstable/sources/types";
|
|
14
|
+
const decodeGitHostedSourceParamParts = Schema.decodeUnknownResult(GitHostedSourceParamPartsSchema);
|
|
15
|
+
const parseRef = (input) => {
|
|
16
|
+
const refIndex = input.lastIndexOf("@");
|
|
17
|
+
if (refIndex <= 0) {
|
|
18
|
+
return { coordinate: input };
|
|
19
|
+
}
|
|
20
|
+
const ref = input.slice(refIndex + 1);
|
|
21
|
+
if (ref.length === 0) {
|
|
22
|
+
return { coordinate: input };
|
|
23
|
+
}
|
|
24
|
+
const subPathMarker = input.indexOf("//");
|
|
25
|
+
const isAtPathSegment = subPathMarker !== -1 &&
|
|
26
|
+
refIndex > subPathMarker + 1 &&
|
|
27
|
+
input[refIndex - 1] === "/" &&
|
|
28
|
+
ref.includes("/");
|
|
29
|
+
if (isAtPathSegment) {
|
|
30
|
+
return { coordinate: input };
|
|
31
|
+
}
|
|
32
|
+
return { coordinate: input.slice(0, refIndex), ref };
|
|
33
|
+
};
|
|
34
|
+
const parseCoordinate = (input) => {
|
|
35
|
+
const { coordinate, ref } = parseRef(input);
|
|
36
|
+
const subPathMarker = coordinate.indexOf("//");
|
|
37
|
+
const repoCoordinate = subPathMarker === -1 ? coordinate : coordinate.slice(0, subPathMarker);
|
|
38
|
+
const subPath = subPathMarker === -1 ? undefined : coordinate.slice(subPathMarker + 2);
|
|
39
|
+
const segments = repoCoordinate.split("/");
|
|
40
|
+
const repo = segments.at(-1);
|
|
41
|
+
const ownerSegments = segments.slice(0, -1);
|
|
42
|
+
if (repo === undefined || repo.length === 0 || ownerSegments.length === 0) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
const owner = ownerSegments.join("/");
|
|
46
|
+
return {
|
|
47
|
+
owner,
|
|
48
|
+
repo,
|
|
49
|
+
...(subPath === undefined ? {} : { subPath }),
|
|
50
|
+
...(ref === undefined ? {} : { ref }),
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Parse the body of a provider shorthand (the part after the `prefix:` prefix).
|
|
55
|
+
*
|
|
56
|
+
* Returns `{ owner, repo, subPath?, ref? }` or fails with `SourceSyntaxInvalid`.
|
|
57
|
+
*/
|
|
58
|
+
export const parseProviderShorthand = (input, original) => Effect.gen(function* () {
|
|
59
|
+
const parsed = parseCoordinate(input);
|
|
60
|
+
if (parsed === undefined) {
|
|
61
|
+
return yield* new SourceSyntaxInvalid({
|
|
62
|
+
detail: `Invalid provider shorthand "${original}": expected owner/repo[//subpath][@ref]`,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
const decoded = decodeGitHostedSourceParamParts(parsed);
|
|
66
|
+
if (Result.isFailure(decoded)) {
|
|
67
|
+
return yield* new SourceSyntaxInvalid({
|
|
68
|
+
detail: `Invalid provider shorthand "${original}": subpaths cannot traverse outside the repository, and shorthand refs cannot contain "/"`,
|
|
69
|
+
cause: decoded.failure,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
return decoded.success;
|
|
73
|
+
});
|
|
74
|
+
//# sourceMappingURL=parse-provider-shorthand.js.map
|