unagent 0.0.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.
@@ -0,0 +1,132 @@
1
+ import { isAbsolute } from "node:path";
2
+
3
+ //#region src/source/providers.ts
4
+ function getProviderFromUrl(url) {
5
+ if (url.includes("github.com") || url.includes("github:")) return "github";
6
+ if (url.includes("gitlab.com") || url.includes("gitlab:")) return "gitlab";
7
+ if (url.includes("bitbucket.org") || url.includes("bitbucket:")) return "bitbucket";
8
+ return "url";
9
+ }
10
+ function parseGitHubUrl(url) {
11
+ const shortMatch = url.match(/^github:([^/]+)\/([^#@/]+)(?:\/([^#@]+))?(?:[#@](.+))?$/);
12
+ if (shortMatch) return {
13
+ provider: "github",
14
+ owner: shortMatch[1],
15
+ repo: shortMatch[2],
16
+ path: shortMatch[3],
17
+ ref: shortMatch[4]
18
+ };
19
+ const fullMatch = url.match(/github\.com\/([^/]+)\/([^/]+?)(?:\.git)?(?:\/tree\/([^/]+)(?:\/(.+))?)?(?:[#@](.+))?$/);
20
+ if (fullMatch) return {
21
+ provider: "github",
22
+ owner: fullMatch[1],
23
+ repo: fullMatch[2],
24
+ ref: fullMatch[3],
25
+ path: fullMatch[4]
26
+ };
27
+ }
28
+ function parseGitLabUrl(url) {
29
+ const shortMatch = url.match(/^gitlab:([^/]+)\/([^#@/]+)(?:\/([^#@]+))?(?:[#@](.+))?$/);
30
+ if (shortMatch) return {
31
+ provider: "gitlab",
32
+ owner: shortMatch[1],
33
+ repo: shortMatch[2],
34
+ path: shortMatch[3],
35
+ ref: shortMatch[4]
36
+ };
37
+ const fullMatch = url.match(/gitlab\.com\/([^/]+)\/([^/]+?)(?:\.git)?(?:\/-\/tree\/([^/]+)(?:\/(.+))?)?(?:[#@](.+))?$/);
38
+ if (fullMatch) return {
39
+ provider: "gitlab",
40
+ owner: fullMatch[1],
41
+ repo: fullMatch[2],
42
+ ref: fullMatch[3],
43
+ path: fullMatch[4]
44
+ };
45
+ }
46
+ function buildGitHubCloneUrl(owner, repo) {
47
+ return `https://github.com/${owner}/${repo}.git`;
48
+ }
49
+ function buildGitLabCloneUrl(owner, repo) {
50
+ return `https://gitlab.com/${owner}/${repo}.git`;
51
+ }
52
+
53
+ //#endregion
54
+ //#region src/source/parse.ts
55
+ function isLocalPath(source) {
56
+ if (source.startsWith("/") || source.startsWith("./") || source.startsWith("../")) return true;
57
+ if (source.startsWith("~")) return true;
58
+ if (isAbsolute(source)) return true;
59
+ if (/^[a-z]:[\\/]/i.test(source)) return true;
60
+ return false;
61
+ }
62
+ function isUrl(source) {
63
+ return /^https?:\/\//.test(source) || /^(github|gitlab|bitbucket):/.test(source);
64
+ }
65
+ function parseSource(source) {
66
+ const trimmed = source.trim();
67
+ if (isLocalPath(trimmed)) return {
68
+ type: "local",
69
+ raw: trimmed,
70
+ isLocal: true
71
+ };
72
+ if (trimmed.includes("github.com") || trimmed.startsWith("github:")) {
73
+ const info = parseGitHubUrl(trimmed);
74
+ if (info) return {
75
+ type: "github",
76
+ raw: trimmed,
77
+ owner: info.owner,
78
+ repo: info.repo,
79
+ path: info.path,
80
+ ref: info.ref,
81
+ isLocal: false
82
+ };
83
+ }
84
+ if (trimmed.includes("gitlab.com") || trimmed.startsWith("gitlab:")) {
85
+ const info = parseGitLabUrl(trimmed);
86
+ if (info) return {
87
+ type: "gitlab",
88
+ raw: trimmed,
89
+ owner: info.owner,
90
+ repo: info.repo,
91
+ path: info.path,
92
+ ref: info.ref,
93
+ isLocal: false
94
+ };
95
+ }
96
+ if (isUrl(trimmed)) return {
97
+ type: "url",
98
+ raw: trimmed,
99
+ url: trimmed,
100
+ isLocal: false
101
+ };
102
+ const ownerRepoMatch = trimmed.match(/^([^/]+)\/([^#@/]+)(?:\/([^#@]+))?(?:[#@](.+))?$/);
103
+ if (ownerRepoMatch) return {
104
+ type: "github",
105
+ raw: trimmed,
106
+ owner: ownerRepoMatch[1],
107
+ repo: ownerRepoMatch[2],
108
+ path: ownerRepoMatch[3],
109
+ ref: ownerRepoMatch[4],
110
+ isLocal: false
111
+ };
112
+ return {
113
+ type: "local",
114
+ raw: trimmed,
115
+ isLocal: true
116
+ };
117
+ }
118
+ function getOwnerRepo(parsed) {
119
+ if (!parsed.owner || !parsed.repo) return void 0;
120
+ return `${parsed.owner}/${parsed.repo}`;
121
+ }
122
+ function parseOwnerRepo(ownerRepo) {
123
+ const match = ownerRepo.match(/^([^/]+)\/([^/]+)$/);
124
+ if (!match) return void 0;
125
+ return {
126
+ owner: match[1],
127
+ repo: match[2]
128
+ };
129
+ }
130
+
131
+ //#endregion
132
+ export { parseSource as a, getProviderFromUrl as c, parseOwnerRepo as i, parseGitHubUrl as l, isLocalPath as n, buildGitHubCloneUrl as o, isUrl as r, buildGitLabCloneUrl as s, getOwnerRepo as t, parseGitLabUrl as u };
@@ -0,0 +1,2 @@
1
+ import { a as truncate, c as bold, d as gray, f as green, h as yellow, i as pluralize, l as cyan, m as stripAnsi, n as shortenPath, o as ANSI, p as red, r as formatList, s as blue, t as expandPath, u as dim } from "../index-CirIJDiq.js";
2
+ export { ANSI, blue, bold, cyan, dim, expandPath, formatList, gray, green, pluralize, red, shortenPath, stripAnsi, truncate, yellow };
@@ -0,0 +1,4 @@
1
+ import { n as shortenPath, t as expandPath } from "../path-nPuHl-f5.js";
2
+ import { a as blue, c as dim, d as red, f as stripAnsi, i as ANSI, l as gray, n as pluralize, o as bold, p as yellow, r as truncate, s as cyan, t as formatList, u as green } from "../utils-CDyPZons.js";
3
+
4
+ export { ANSI, blue, bold, cyan, dim, expandPath, formatList, gray, green, pluralize, red, shortenPath, stripAnsi, truncate, yellow };
@@ -0,0 +1,62 @@
1
+ //#region src/utils/ansi.ts
2
+ const ANSI = {
3
+ reset: "\x1B[0m",
4
+ bold: "\x1B[1m",
5
+ dim: "\x1B[2m",
6
+ red: "\x1B[31m",
7
+ green: "\x1B[32m",
8
+ yellow: "\x1B[33m",
9
+ blue: "\x1B[34m",
10
+ magenta: "\x1B[35m",
11
+ cyan: "\x1B[36m",
12
+ white: "\x1B[37m",
13
+ gray: "\x1B[90m"
14
+ };
15
+ const ANSI_REGEX = /\x1B\[[0-9;]*m/g;
16
+ function stripAnsi(str) {
17
+ return str.replace(ANSI_REGEX, "");
18
+ }
19
+ function bold(str) {
20
+ return `${ANSI.bold}${str}${ANSI.reset}`;
21
+ }
22
+ function dim(str) {
23
+ return `${ANSI.dim}${str}${ANSI.reset}`;
24
+ }
25
+ function red(str) {
26
+ return `${ANSI.red}${str}${ANSI.reset}`;
27
+ }
28
+ function green(str) {
29
+ return `${ANSI.green}${str}${ANSI.reset}`;
30
+ }
31
+ function yellow(str) {
32
+ return `${ANSI.yellow}${str}${ANSI.reset}`;
33
+ }
34
+ function blue(str) {
35
+ return `${ANSI.blue}${str}${ANSI.reset}`;
36
+ }
37
+ function cyan(str) {
38
+ return `${ANSI.cyan}${str}${ANSI.reset}`;
39
+ }
40
+ function gray(str) {
41
+ return `${ANSI.gray}${str}${ANSI.reset}`;
42
+ }
43
+
44
+ //#endregion
45
+ //#region src/utils/format.ts
46
+ function formatList(items, maxShow = 3) {
47
+ if (items.length === 0) return "";
48
+ if (items.length <= maxShow) return items.join(", ");
49
+ const shown = items.slice(0, maxShow);
50
+ const remaining = items.length - maxShow;
51
+ return `${shown.join(", ")} +${remaining} more`;
52
+ }
53
+ function pluralize(count, singular, plural) {
54
+ return count === 1 ? singular : plural ?? `${singular}s`;
55
+ }
56
+ function truncate(str, maxLength, suffix = "...") {
57
+ if (str.length <= maxLength) return str;
58
+ return str.slice(0, maxLength - suffix.length) + suffix;
59
+ }
60
+
61
+ //#endregion
62
+ export { blue as a, dim as c, red as d, stripAnsi as f, ANSI as i, gray as l, pluralize as n, bold as o, yellow as p, truncate as r, cyan as s, formatList as t, green as u };
package/package.json ADDED
@@ -0,0 +1,82 @@
1
+ {
2
+ "name": "unagent",
3
+ "type": "module",
4
+ "version": "0.0.1",
5
+ "description": "Unified agent primitives for AI coding agents",
6
+ "author": "",
7
+ "license": "MIT",
8
+ "homepage": "https://unagent.onmax.me",
9
+ "repository": "gh:onmax/unagent",
10
+ "keywords": [
11
+ "unjs",
12
+ "agent",
13
+ "ai",
14
+ "skills",
15
+ "claude",
16
+ "cursor",
17
+ "windsurf"
18
+ ],
19
+ "sideEffects": false,
20
+ "exports": {
21
+ ".": {
22
+ "types": "./dist/index.d.ts",
23
+ "import": "./dist/index.js"
24
+ },
25
+ "./env": {
26
+ "types": "./dist/env/index.d.ts",
27
+ "import": "./dist/env/index.js"
28
+ },
29
+ "./skill": {
30
+ "types": "./dist/skill/index.d.ts",
31
+ "import": "./dist/skill/index.js"
32
+ },
33
+ "./link": {
34
+ "types": "./dist/link/index.d.ts",
35
+ "import": "./dist/link/index.js"
36
+ },
37
+ "./lock": {
38
+ "types": "./dist/lock/index.d.ts",
39
+ "import": "./dist/lock/index.js"
40
+ },
41
+ "./source": {
42
+ "types": "./dist/source/index.d.ts",
43
+ "import": "./dist/source/index.js"
44
+ },
45
+ "./git": {
46
+ "types": "./dist/git/index.d.ts",
47
+ "import": "./dist/git/index.js"
48
+ },
49
+ "./utils": {
50
+ "types": "./dist/utils/index.d.ts",
51
+ "import": "./dist/utils/index.js"
52
+ }
53
+ },
54
+ "files": [
55
+ "dist"
56
+ ],
57
+ "scripts": {
58
+ "build": "tsdown",
59
+ "dev": "tsdown --watch",
60
+ "lint": "eslint .",
61
+ "lint:fix": "eslint . --fix",
62
+ "typecheck": "tsc --noEmit",
63
+ "test": "vitest",
64
+ "release": "bumpp",
65
+ "prepublishOnly": "pnpm build"
66
+ },
67
+ "dependencies": {
68
+ "gray-matter": "^4.0.0",
69
+ "pathe": "^2.0.3",
70
+ "simple-git": "^3.0.0",
71
+ "std-env": "^3.10.0"
72
+ },
73
+ "devDependencies": {
74
+ "@antfu/eslint-config": "^4.0.0",
75
+ "@types/node": "^25.1.0",
76
+ "bumpp": "^9.0.0",
77
+ "eslint": "^9.0.0",
78
+ "tsdown": "^0.15.0",
79
+ "typescript": "^5.7.0",
80
+ "vitest": "^3.0.0"
81
+ }
82
+ }