agent-config-detect 0.0.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 +21 -0
- package/README.md +1 -0
- package/dist/cjs/errors.js +105 -0
- package/dist/cjs/errors.js.map +1 -0
- package/dist/cjs/index.js +89 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/platform/Platform.js +13 -0
- package/dist/cjs/platform/Platform.js.map +1 -0
- package/dist/cjs/platform/TestPlatform.js +65 -0
- package/dist/cjs/platform/TestPlatform.js.map +1 -0
- package/dist/cjs/platform/index.js +118 -0
- package/dist/cjs/platform/index.js.map +1 -0
- package/dist/cjs/platform/internal/common.js +40 -0
- package/dist/cjs/platform/internal/common.js.map +1 -0
- package/dist/cjs/platform/internal/darwin.js +40 -0
- package/dist/cjs/platform/internal/darwin.js.map +1 -0
- package/dist/cjs/platform/internal/linux.js +69 -0
- package/dist/cjs/platform/internal/linux.js.map +1 -0
- package/dist/cjs/platform/internal/testUtils.js +79 -0
- package/dist/cjs/platform/internal/testUtils.js.map +1 -0
- package/dist/cjs/platform/internal/windows.js +61 -0
- package/dist/cjs/platform/internal/windows.js.map +1 -0
- package/dist/cjs/types/ConfigResource.js +44 -0
- package/dist/cjs/types/ConfigResource.js.map +1 -0
- package/dist/cjs/types/DirectoryResource.js +42 -0
- package/dist/cjs/types/DirectoryResource.js.map +1 -0
- package/dist/cjs/types/DirectoryStructure.js +56 -0
- package/dist/cjs/types/DirectoryStructure.js.map +1 -0
- package/dist/cjs/types/EnvValue.js +199 -0
- package/dist/cjs/types/EnvValue.js.map +1 -0
- package/dist/cjs/types/FileFormat.js +25 -0
- package/dist/cjs/types/FileFormat.js.map +1 -0
- package/dist/cjs/types/HarnessKind.js +130 -0
- package/dist/cjs/types/HarnessKind.js.map +1 -0
- package/dist/cjs/types/InstallationStatus.js +119 -0
- package/dist/cjs/types/InstallationStatus.js.map +1 -0
- package/dist/cjs/types/PathType.js +25 -0
- package/dist/cjs/types/PathType.js.map +1 -0
- package/dist/cjs/types/ResourceKind.js +26 -0
- package/dist/cjs/types/ResourceKind.js.map +1 -0
- package/dist/cjs/types/Scope.js +59 -0
- package/dist/cjs/types/Scope.js.map +1 -0
- package/dist/cjs/types/index.js +116 -0
- package/dist/cjs/types/index.js.map +1 -0
- package/dist/dts/errors.d.ts +125 -0
- package/dist/dts/errors.d.ts.map +1 -0
- package/dist/dts/index.d.ts +11 -0
- package/dist/dts/index.d.ts.map +1 -0
- package/dist/dts/platform/Platform.d.ts +61 -0
- package/dist/dts/platform/Platform.d.ts.map +1 -0
- package/dist/dts/platform/TestPlatform.d.ts +52 -0
- package/dist/dts/platform/TestPlatform.d.ts.map +1 -0
- package/dist/dts/platform/index.d.ts +20 -0
- package/dist/dts/platform/index.d.ts.map +1 -0
- package/dist/dts/platform/internal/common.d.ts +20 -0
- package/dist/dts/platform/internal/common.d.ts.map +1 -0
- package/dist/dts/platform/internal/darwin.d.ts +33 -0
- package/dist/dts/platform/internal/darwin.d.ts.map +1 -0
- package/dist/dts/platform/internal/linux.d.ts +29 -0
- package/dist/dts/platform/internal/linux.d.ts.map +1 -0
- package/dist/dts/platform/internal/testUtils.d.ts +32 -0
- package/dist/dts/platform/internal/testUtils.d.ts.map +1 -0
- package/dist/dts/platform/internal/windows.d.ts +38 -0
- package/dist/dts/platform/internal/windows.d.ts.map +1 -0
- package/dist/dts/types/ConfigResource.d.ts +34 -0
- package/dist/dts/types/ConfigResource.d.ts.map +1 -0
- package/dist/dts/types/DirectoryResource.d.ts +33 -0
- package/dist/dts/types/DirectoryResource.d.ts.map +1 -0
- package/dist/dts/types/DirectoryStructure.d.ts +61 -0
- package/dist/dts/types/DirectoryStructure.d.ts.map +1 -0
- package/dist/dts/types/EnvValue.d.ts +102 -0
- package/dist/dts/types/EnvValue.d.ts.map +1 -0
- package/dist/dts/types/FileFormat.d.ts +22 -0
- package/dist/dts/types/FileFormat.d.ts.map +1 -0
- package/dist/dts/types/HarnessKind.d.ts +45 -0
- package/dist/dts/types/HarnessKind.d.ts.map +1 -0
- package/dist/dts/types/InstallationStatus.d.ts +89 -0
- package/dist/dts/types/InstallationStatus.d.ts.map +1 -0
- package/dist/dts/types/PathType.d.ts +22 -0
- package/dist/dts/types/PathType.d.ts.map +1 -0
- package/dist/dts/types/ResourceKind.d.ts +23 -0
- package/dist/dts/types/ResourceKind.d.ts.map +1 -0
- package/dist/dts/types/Scope.d.ts +59 -0
- package/dist/dts/types/Scope.d.ts.map +1 -0
- package/dist/dts/types/index.d.ts +16 -0
- package/dist/dts/types/index.d.ts.map +1 -0
- package/dist/esm/errors.js +87 -0
- package/dist/esm/errors.js.map +1 -0
- package/dist/esm/index.js +14 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/package.json +4 -0
- package/dist/esm/platform/Platform.js +6 -0
- package/dist/esm/platform/Platform.js.map +1 -0
- package/dist/esm/platform/TestPlatform.js +54 -0
- package/dist/esm/platform/TestPlatform.js.map +1 -0
- package/dist/esm/platform/index.js +68 -0
- package/dist/esm/platform/index.js.map +1 -0
- package/dist/esm/platform/internal/common.js +30 -0
- package/dist/esm/platform/internal/common.js.map +1 -0
- package/dist/esm/platform/internal/darwin.js +33 -0
- package/dist/esm/platform/internal/darwin.js.map +1 -0
- package/dist/esm/platform/internal/linux.js +62 -0
- package/dist/esm/platform/internal/linux.js.map +1 -0
- package/dist/esm/platform/internal/testUtils.js +70 -0
- package/dist/esm/platform/internal/testUtils.js.map +1 -0
- package/dist/esm/platform/internal/windows.js +54 -0
- package/dist/esm/platform/internal/windows.js.map +1 -0
- package/dist/esm/types/ConfigResource.js +36 -0
- package/dist/esm/types/ConfigResource.js.map +1 -0
- package/dist/esm/types/DirectoryResource.js +34 -0
- package/dist/esm/types/DirectoryResource.js.map +1 -0
- package/dist/esm/types/DirectoryStructure.js +45 -0
- package/dist/esm/types/DirectoryStructure.js.map +1 -0
- package/dist/esm/types/EnvValue.js +182 -0
- package/dist/esm/types/EnvValue.js.map +1 -0
- package/dist/esm/types/FileFormat.js +18 -0
- package/dist/esm/types/FileFormat.js.map +1 -0
- package/dist/esm/types/HarnessKind.js +120 -0
- package/dist/esm/types/HarnessKind.js.map +1 -0
- package/dist/esm/types/InstallationStatus.js +101 -0
- package/dist/esm/types/InstallationStatus.js.map +1 -0
- package/dist/esm/types/PathType.js +18 -0
- package/dist/esm/types/PathType.js.map +1 -0
- package/dist/esm/types/ResourceKind.js +19 -0
- package/dist/esm/types/ResourceKind.js.map +1 -0
- package/dist/esm/types/Scope.js +46 -0
- package/dist/esm/types/Scope.js.map +1 -0
- package/dist/esm/types/index.js +17 -0
- package/dist/esm/types/index.js.map +1 -0
- package/errors/package.json +6 -0
- package/package.json +135 -0
- package/platform/Platform/package.json +6 -0
- package/platform/TestPlatform/package.json +6 -0
- package/src/errors.ts +135 -0
- package/src/index.ts +27 -0
- package/src/platform/Platform.ts +64 -0
- package/src/platform/TestPlatform.ts +93 -0
- package/src/platform/index.ts +72 -0
- package/src/platform/internal/common.ts +30 -0
- package/src/platform/internal/darwin.ts +43 -0
- package/src/platform/internal/linux.ts +66 -0
- package/src/platform/internal/testUtils.ts +82 -0
- package/src/platform/internal/windows.ts +58 -0
- package/src/types/ConfigResource.ts +48 -0
- package/src/types/DirectoryResource.ts +45 -0
- package/src/types/DirectoryStructure.ts +64 -0
- package/src/types/EnvValue.ts +189 -0
- package/src/types/FileFormat.ts +36 -0
- package/src/types/HarnessKind.ts +150 -0
- package/src/types/InstallationStatus.ts +119 -0
- package/src/types/PathType.ts +24 -0
- package/src/types/ResourceKind.ts +27 -0
- package/src/types/Scope.ts +57 -0
- package/src/types/index.ts +17 -0
- package/types/ConfigResource/package.json +6 -0
- package/types/DirectoryResource/package.json +6 -0
- package/types/DirectoryStructure/package.json +6 -0
- package/types/EnvValue/package.json +6 -0
- package/types/FileFormat/package.json +6 -0
- package/types/HarnessKind/package.json +6 -0
- package/types/InstallationStatus/package.json +6 -0
- package/types/PathType/package.json +6 -0
- package/types/ResourceKind/package.json +6 -0
- package/types/Scope/package.json +6 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Scope.js","names":["Data","Schema","Global","TaggedClass","Project","Custom","Scope","Union","TaggedStruct","path","String","global","project","custom"],"sources":["../../../src/types/Scope.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;AAQA,SAASA,IAAI,EAAEC,MAAM,QAAQ,QAAQ;AAErC;;;AAGA,OAAM,MAAOC,MAAO,sBAAQF,IAAI,CAACG,WAAW,CAAC,QAAQ,CAAK;AAE1D;;;AAGA,OAAM,MAAOC,OAAQ,sBAAQJ,IAAI,CAACG,WAAW,CAAC,SAAS,CAErD;AAEF;;;AAGA,OAAM,MAAOE,MAAO,sBAAQL,IAAI,CAACG,WAAW,CAAC,QAAQ,CAEnD;AAOF;;;AAGA,OAAO,MAAMG,KAAK,gBAAyBL,MAAM,CAACM,KAAK,cACrDN,MAAM,CAACO,YAAY,CAAC,QAAQ,EAAE,EAAE,CAAC,eACjCP,MAAM,CAACO,YAAY,CAAC,SAAS,EAAE;EAAEC,IAAI,EAAER,MAAM,CAACS;AAAM,CAAE,CAAC,eACvDT,MAAM,CAACO,YAAY,CAAC,QAAQ,EAAE;EAAEC,IAAI,EAAER,MAAM,CAACS;AAAM,CAAE,CAAC,CAC/B;AAEzB;;;AAGA,OAAO,MAAMC,MAAM,GAAGA,CAAA,KAAa,IAAIT,MAAM,EAAE;AAE/C;;;AAGA,OAAO,MAAMU,OAAO,GAAIH,IAAY,IAAY,IAAIL,OAAO,CAAC;EAAEK;AAAI,CAAE,CAAC;AAErE;;;AAGA,OAAO,MAAMI,MAAM,GAAIJ,IAAY,IAAY,IAAIJ,MAAM,CAAC;EAAEI;AAAI,CAAE,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core type definitions for harness path resolution.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
// Re-export all types
|
|
7
|
+
export * from "./ConfigResource.js";
|
|
8
|
+
export * from "./DirectoryResource.js";
|
|
9
|
+
export * from "./DirectoryStructure.js";
|
|
10
|
+
export * from "./EnvValue.js";
|
|
11
|
+
export * from "./FileFormat.js";
|
|
12
|
+
export * from "./HarnessKind.js";
|
|
13
|
+
export * from "./InstallationStatus.js";
|
|
14
|
+
export * from "./PathType.js";
|
|
15
|
+
export * from "./ResourceKind.js";
|
|
16
|
+
export * from "./Scope.js";
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/types/index.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;AAMA;AACA,cAAc,qBAAqB;AACnC,cAAc,wBAAwB;AACtC,cAAc,yBAAyB;AACvC,cAAc,eAAe;AAC7B,cAAc,iBAAiB;AAC/B,cAAc,kBAAkB;AAChC,cAAc,yBAAyB;AACvC,cAAc,eAAe;AAC7B,cAAc,mBAAmB;AACjC,cAAc,YAAY","ignoreList":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "agent-config-detect",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Agent config detection",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/AtelyPham/agent-locate-ts.git",
|
|
9
|
+
"directory": "packages/agent-config-detect"
|
|
10
|
+
},
|
|
11
|
+
"sideEffects": [],
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@effect/platform": "latest",
|
|
14
|
+
"effect": "latest"
|
|
15
|
+
},
|
|
16
|
+
"main": "./dist/cjs/index.js",
|
|
17
|
+
"module": "./dist/esm/index.js",
|
|
18
|
+
"types": "./dist/dts/index.d.ts",
|
|
19
|
+
"exports": {
|
|
20
|
+
"./package.json": "./package.json",
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./dist/dts/index.d.ts",
|
|
23
|
+
"import": "./dist/esm/index.js",
|
|
24
|
+
"default": "./dist/cjs/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./errors": {
|
|
27
|
+
"types": "./dist/dts/errors.d.ts",
|
|
28
|
+
"import": "./dist/esm/errors.js",
|
|
29
|
+
"default": "./dist/cjs/errors.js"
|
|
30
|
+
},
|
|
31
|
+
"./platform/Platform": {
|
|
32
|
+
"types": "./dist/dts/platform/Platform.d.ts",
|
|
33
|
+
"import": "./dist/esm/platform/Platform.js",
|
|
34
|
+
"default": "./dist/cjs/platform/Platform.js"
|
|
35
|
+
},
|
|
36
|
+
"./platform/TestPlatform": {
|
|
37
|
+
"types": "./dist/dts/platform/TestPlatform.d.ts",
|
|
38
|
+
"import": "./dist/esm/platform/TestPlatform.js",
|
|
39
|
+
"default": "./dist/cjs/platform/TestPlatform.js"
|
|
40
|
+
},
|
|
41
|
+
"./types/ConfigResource": {
|
|
42
|
+
"types": "./dist/dts/types/ConfigResource.d.ts",
|
|
43
|
+
"import": "./dist/esm/types/ConfigResource.js",
|
|
44
|
+
"default": "./dist/cjs/types/ConfigResource.js"
|
|
45
|
+
},
|
|
46
|
+
"./types/DirectoryResource": {
|
|
47
|
+
"types": "./dist/dts/types/DirectoryResource.d.ts",
|
|
48
|
+
"import": "./dist/esm/types/DirectoryResource.js",
|
|
49
|
+
"default": "./dist/cjs/types/DirectoryResource.js"
|
|
50
|
+
},
|
|
51
|
+
"./types/DirectoryStructure": {
|
|
52
|
+
"types": "./dist/dts/types/DirectoryStructure.d.ts",
|
|
53
|
+
"import": "./dist/esm/types/DirectoryStructure.js",
|
|
54
|
+
"default": "./dist/cjs/types/DirectoryStructure.js"
|
|
55
|
+
},
|
|
56
|
+
"./types/EnvValue": {
|
|
57
|
+
"types": "./dist/dts/types/EnvValue.d.ts",
|
|
58
|
+
"import": "./dist/esm/types/EnvValue.js",
|
|
59
|
+
"default": "./dist/cjs/types/EnvValue.js"
|
|
60
|
+
},
|
|
61
|
+
"./types/FileFormat": {
|
|
62
|
+
"types": "./dist/dts/types/FileFormat.d.ts",
|
|
63
|
+
"import": "./dist/esm/types/FileFormat.js",
|
|
64
|
+
"default": "./dist/cjs/types/FileFormat.js"
|
|
65
|
+
},
|
|
66
|
+
"./types/HarnessKind": {
|
|
67
|
+
"types": "./dist/dts/types/HarnessKind.d.ts",
|
|
68
|
+
"import": "./dist/esm/types/HarnessKind.js",
|
|
69
|
+
"default": "./dist/cjs/types/HarnessKind.js"
|
|
70
|
+
},
|
|
71
|
+
"./types/InstallationStatus": {
|
|
72
|
+
"types": "./dist/dts/types/InstallationStatus.d.ts",
|
|
73
|
+
"import": "./dist/esm/types/InstallationStatus.js",
|
|
74
|
+
"default": "./dist/cjs/types/InstallationStatus.js"
|
|
75
|
+
},
|
|
76
|
+
"./types/PathType": {
|
|
77
|
+
"types": "./dist/dts/types/PathType.d.ts",
|
|
78
|
+
"import": "./dist/esm/types/PathType.js",
|
|
79
|
+
"default": "./dist/cjs/types/PathType.js"
|
|
80
|
+
},
|
|
81
|
+
"./types/ResourceKind": {
|
|
82
|
+
"types": "./dist/dts/types/ResourceKind.d.ts",
|
|
83
|
+
"import": "./dist/esm/types/ResourceKind.js",
|
|
84
|
+
"default": "./dist/cjs/types/ResourceKind.js"
|
|
85
|
+
},
|
|
86
|
+
"./types/Scope": {
|
|
87
|
+
"types": "./dist/dts/types/Scope.d.ts",
|
|
88
|
+
"import": "./dist/esm/types/Scope.js",
|
|
89
|
+
"default": "./dist/cjs/types/Scope.js"
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
"typesVersions": {
|
|
93
|
+
"*": {
|
|
94
|
+
"errors": [
|
|
95
|
+
"./dist/dts/errors.d.ts"
|
|
96
|
+
],
|
|
97
|
+
"platform/Platform": [
|
|
98
|
+
"./dist/dts/platform/Platform.d.ts"
|
|
99
|
+
],
|
|
100
|
+
"platform/TestPlatform": [
|
|
101
|
+
"./dist/dts/platform/TestPlatform.d.ts"
|
|
102
|
+
],
|
|
103
|
+
"types/ConfigResource": [
|
|
104
|
+
"./dist/dts/types/ConfigResource.d.ts"
|
|
105
|
+
],
|
|
106
|
+
"types/DirectoryResource": [
|
|
107
|
+
"./dist/dts/types/DirectoryResource.d.ts"
|
|
108
|
+
],
|
|
109
|
+
"types/DirectoryStructure": [
|
|
110
|
+
"./dist/dts/types/DirectoryStructure.d.ts"
|
|
111
|
+
],
|
|
112
|
+
"types/EnvValue": [
|
|
113
|
+
"./dist/dts/types/EnvValue.d.ts"
|
|
114
|
+
],
|
|
115
|
+
"types/FileFormat": [
|
|
116
|
+
"./dist/dts/types/FileFormat.d.ts"
|
|
117
|
+
],
|
|
118
|
+
"types/HarnessKind": [
|
|
119
|
+
"./dist/dts/types/HarnessKind.d.ts"
|
|
120
|
+
],
|
|
121
|
+
"types/InstallationStatus": [
|
|
122
|
+
"./dist/dts/types/InstallationStatus.d.ts"
|
|
123
|
+
],
|
|
124
|
+
"types/PathType": [
|
|
125
|
+
"./dist/dts/types/PathType.d.ts"
|
|
126
|
+
],
|
|
127
|
+
"types/ResourceKind": [
|
|
128
|
+
"./dist/dts/types/ResourceKind.d.ts"
|
|
129
|
+
],
|
|
130
|
+
"types/Scope": [
|
|
131
|
+
"./dist/dts/types/Scope.d.ts"
|
|
132
|
+
]
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
package/src/errors.ts
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error types for harness operations.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { Data } from "effect"
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The requested harness was not found on this system.
|
|
10
|
+
*/
|
|
11
|
+
export class NotFoundError extends Data.TaggedError("NotFoundError")<{
|
|
12
|
+
readonly message: string
|
|
13
|
+
}> {}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The path is invalid or inaccessible.
|
|
17
|
+
*/
|
|
18
|
+
export class InvalidPathError extends Data.TaggedError("InvalidPathError")<{
|
|
19
|
+
readonly path: string
|
|
20
|
+
}> {
|
|
21
|
+
get message() {
|
|
22
|
+
return `invalid path: ${this.path}`
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* An environment variable could not be read.
|
|
28
|
+
*/
|
|
29
|
+
export class EnvVarError extends Data.TaggedError("EnvVarError")<{
|
|
30
|
+
readonly cause: Error
|
|
31
|
+
}> {
|
|
32
|
+
get message() {
|
|
33
|
+
return `environment variable error: ${this.cause.message}`
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The current platform is not supported.
|
|
39
|
+
*/
|
|
40
|
+
export class UnsupportedPlatformError extends Data.TaggedError("UnsupportedPlatformError")<{}> {
|
|
41
|
+
get message() {
|
|
42
|
+
return "unsupported platform"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* An I/O error occurred.
|
|
48
|
+
*/
|
|
49
|
+
export class IoError extends Data.TaggedError("IoError")<{
|
|
50
|
+
readonly cause: Error
|
|
51
|
+
}> {
|
|
52
|
+
get message() {
|
|
53
|
+
return `IO error: ${this.cause.message}`
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* MCP server uses unsupported features for target harness.
|
|
59
|
+
*/
|
|
60
|
+
export class UnsupportedMcpConfigError extends Data.TaggedError("UnsupportedMcpConfigError")<{
|
|
61
|
+
readonly harness: string
|
|
62
|
+
readonly reason: string
|
|
63
|
+
}> {
|
|
64
|
+
get message() {
|
|
65
|
+
return `unsupported MCP config for ${this.harness}: ${this.reason}`
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Binary detection failed due to system error.
|
|
71
|
+
*/
|
|
72
|
+
export class BinaryDetectionError extends Data.TaggedError("BinaryDetectionError")<{
|
|
73
|
+
readonly message: string
|
|
74
|
+
}> {}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* The requested scope is not supported by this harness.
|
|
78
|
+
*/
|
|
79
|
+
export class UnsupportedScopeError extends Data.TaggedError("UnsupportedScopeError")<{
|
|
80
|
+
readonly harness: string
|
|
81
|
+
readonly scope: string
|
|
82
|
+
}> {
|
|
83
|
+
get message() {
|
|
84
|
+
return `${this.harness} does not support ${this.scope} scope`
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* YAML parsing failed.
|
|
90
|
+
*/
|
|
91
|
+
export class YamlParseError extends Data.TaggedError("YamlParseError")<{
|
|
92
|
+
readonly cause: Error
|
|
93
|
+
}> {
|
|
94
|
+
get message() {
|
|
95
|
+
return `YAML parse error: ${this.cause.message}`
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* A required field is missing from the input.
|
|
101
|
+
*/
|
|
102
|
+
export class MissingFieldError extends Data.TaggedError("MissingFieldError")<{
|
|
103
|
+
readonly field: string
|
|
104
|
+
}> {
|
|
105
|
+
get message() {
|
|
106
|
+
return `missing required field: ${this.field}`
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* An environment variable referenced by EnvValue is not set.
|
|
112
|
+
*/
|
|
113
|
+
export class MissingEnvVarError extends Data.TaggedError("MissingEnvVarError")<{
|
|
114
|
+
readonly name: string
|
|
115
|
+
}> {
|
|
116
|
+
get message() {
|
|
117
|
+
return `missing environment variable: ${this.name}`
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Union of all platform errors.
|
|
123
|
+
*/
|
|
124
|
+
export type PlatformError =
|
|
125
|
+
| NotFoundError
|
|
126
|
+
| InvalidPathError
|
|
127
|
+
| EnvVarError
|
|
128
|
+
| UnsupportedPlatformError
|
|
129
|
+
| IoError
|
|
130
|
+
| UnsupportedMcpConfigError
|
|
131
|
+
| BinaryDetectionError
|
|
132
|
+
| UnsupportedScopeError
|
|
133
|
+
| YamlParseError
|
|
134
|
+
| MissingFieldError
|
|
135
|
+
| MissingEnvVarError
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent config detection library.
|
|
3
|
+
*
|
|
4
|
+
* Port of harness-locate Rust crate to TypeScript + Effect.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
// Types
|
|
10
|
+
export * from "./types/index.js"
|
|
11
|
+
|
|
12
|
+
// Errors
|
|
13
|
+
export * from "./errors.js"
|
|
14
|
+
|
|
15
|
+
// Platform
|
|
16
|
+
export {
|
|
17
|
+
type OS,
|
|
18
|
+
Platform,
|
|
19
|
+
PlatformLive,
|
|
20
|
+
type PlatformService,
|
|
21
|
+
TestPlatform,
|
|
22
|
+
TestPlatformDarwin,
|
|
23
|
+
TestPlatformLinux,
|
|
24
|
+
TestPlatformWindows,
|
|
25
|
+
withEnv,
|
|
26
|
+
withoutEnv
|
|
27
|
+
} from "./platform/index.js"
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform service interface for cross-platform path resolution.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import type { Effect } from "effect"
|
|
7
|
+
import { Context } from "effect"
|
|
8
|
+
import type { PlatformError } from "../errors.js"
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Supported operating systems.
|
|
12
|
+
*/
|
|
13
|
+
export type OS = "darwin" | "linux" | "win32"
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Platform service interface.
|
|
17
|
+
*
|
|
18
|
+
* Provides platform-specific directory resolution.
|
|
19
|
+
*/
|
|
20
|
+
export interface PlatformService {
|
|
21
|
+
/**
|
|
22
|
+
* The current operating system.
|
|
23
|
+
*/
|
|
24
|
+
readonly os: OS
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Returns the user's home directory.
|
|
28
|
+
*/
|
|
29
|
+
readonly homeDir: Effect.Effect<string, PlatformError>
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Returns the user's config directory.
|
|
33
|
+
*
|
|
34
|
+
* Platform-specific behavior:
|
|
35
|
+
* - **macOS**: `~/.config/`
|
|
36
|
+
* - **Linux**: `$XDG_CONFIG_HOME` or `~/.config/`
|
|
37
|
+
* - **Windows**: `%APPDATA%`
|
|
38
|
+
*/
|
|
39
|
+
readonly configDir: Effect.Effect<string, PlatformError>
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Returns the user's data directory.
|
|
43
|
+
*
|
|
44
|
+
* Platform-specific behavior:
|
|
45
|
+
* - **macOS**: `~/Library/Application Support/`
|
|
46
|
+
* - **Linux**: `$XDG_DATA_HOME` or `~/.local/share/`
|
|
47
|
+
* - **Windows**: `%LOCALAPPDATA%`
|
|
48
|
+
*/
|
|
49
|
+
readonly dataDir: Effect.Effect<string, PlatformError>
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Returns the user's cache directory (Linux-specific, optional elsewhere).
|
|
53
|
+
*
|
|
54
|
+
* Platform-specific behavior:
|
|
55
|
+
* - **Linux**: `$XDG_CACHE_HOME` or `~/.cache/`
|
|
56
|
+
* - **macOS/Windows**: Same as dataDir
|
|
57
|
+
*/
|
|
58
|
+
readonly cacheDir: Effect.Effect<string, PlatformError>
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Platform service tag.
|
|
63
|
+
*/
|
|
64
|
+
export class Platform extends Context.Tag("Platform")<Platform, PlatformService>() {}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test platform layer for mocking in tests.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { Effect, Layer } from "effect"
|
|
7
|
+
import { type OS, Platform, type PlatformService } from "./Platform.js"
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Configuration for creating a test platform.
|
|
11
|
+
*/
|
|
12
|
+
export interface TestPlatformConfig {
|
|
13
|
+
/**
|
|
14
|
+
* The OS to simulate.
|
|
15
|
+
*/
|
|
16
|
+
readonly os?: OS
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The home directory path.
|
|
20
|
+
*/
|
|
21
|
+
readonly home?: string
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The config directory path.
|
|
25
|
+
*/
|
|
26
|
+
readonly config?: string
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The data directory path.
|
|
30
|
+
*/
|
|
31
|
+
readonly data?: string
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The cache directory path.
|
|
35
|
+
*/
|
|
36
|
+
readonly cache?: string
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Creates a test platform layer with the given configuration.
|
|
41
|
+
*
|
|
42
|
+
* Useful for testing platform-dependent code without relying on
|
|
43
|
+
* the actual filesystem or environment.
|
|
44
|
+
*/
|
|
45
|
+
export const TestPlatform = (config: TestPlatformConfig = {}): Layer.Layer<Platform> => {
|
|
46
|
+
const service: PlatformService = {
|
|
47
|
+
os: config.os ?? "darwin",
|
|
48
|
+
homeDir: Effect.succeed(config.home ?? "/home/testuser"),
|
|
49
|
+
configDir: Effect.succeed(config.config ?? "/home/testuser/.config"),
|
|
50
|
+
dataDir: Effect.succeed(config.data ?? "/home/testuser/.local/share"),
|
|
51
|
+
cacheDir: Effect.succeed(config.cache ?? "/home/testuser/.cache")
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return Layer.succeed(Platform, service)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Creates a macOS test platform.
|
|
59
|
+
*/
|
|
60
|
+
export const TestPlatformDarwin = (home = "/Users/testuser"): Layer.Layer<Platform> =>
|
|
61
|
+
TestPlatform({
|
|
62
|
+
os: "darwin",
|
|
63
|
+
home,
|
|
64
|
+
config: `${home}/.config`,
|
|
65
|
+
data: `${home}/Library/Application Support`,
|
|
66
|
+
cache: `${home}/Library/Application Support`
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Creates a Linux test platform.
|
|
71
|
+
*/
|
|
72
|
+
export const TestPlatformLinux = (home = "/home/testuser"): Layer.Layer<Platform> =>
|
|
73
|
+
TestPlatform({
|
|
74
|
+
os: "linux",
|
|
75
|
+
home,
|
|
76
|
+
config: `${home}/.config`,
|
|
77
|
+
data: `${home}/.local/share`,
|
|
78
|
+
cache: `${home}/.cache`
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Creates a Windows test platform.
|
|
83
|
+
*/
|
|
84
|
+
export const TestPlatformWindows = (
|
|
85
|
+
home = "C:\\Users\\testuser"
|
|
86
|
+
): Layer.Layer<Platform> =>
|
|
87
|
+
TestPlatform({
|
|
88
|
+
os: "win32",
|
|
89
|
+
home,
|
|
90
|
+
config: `${home}\\AppData\\Roaming`,
|
|
91
|
+
data: `${home}\\AppData\\Local`,
|
|
92
|
+
cache: `${home}\\AppData\\Local`
|
|
93
|
+
})
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform-specific path resolution.
|
|
3
|
+
*
|
|
4
|
+
* This module provides the Platform service for resolving base configuration
|
|
5
|
+
* directories on each supported platform (macOS, Linux, Windows).
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import { Layer } from "effect"
|
|
10
|
+
import { UnsupportedPlatformError } from "../errors.js"
|
|
11
|
+
import { homeDir } from "./internal/common.js"
|
|
12
|
+
import * as darwin from "./internal/darwin.js"
|
|
13
|
+
import * as linux from "./internal/linux.js"
|
|
14
|
+
import * as windows from "./internal/windows.js"
|
|
15
|
+
import { type OS, Platform, type PlatformService } from "./Platform.js"
|
|
16
|
+
|
|
17
|
+
// Re-export types and service
|
|
18
|
+
export { withEnv, withoutEnv } from "./internal/testUtils.js"
|
|
19
|
+
export { type OS, Platform, type PlatformService } from "./Platform.js"
|
|
20
|
+
export { TestPlatform, TestPlatformDarwin, TestPlatformLinux, TestPlatformWindows } from "./TestPlatform.js"
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Detects the current operating system.
|
|
24
|
+
*/
|
|
25
|
+
const detectOS = (): OS => {
|
|
26
|
+
const platform = process.platform
|
|
27
|
+
if (platform === "darwin" || platform === "linux" || platform === "win32") {
|
|
28
|
+
return platform
|
|
29
|
+
}
|
|
30
|
+
throw new UnsupportedPlatformError()
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Creates a platform service for the current OS.
|
|
35
|
+
*/
|
|
36
|
+
const createPlatformService = (): PlatformService => {
|
|
37
|
+
const os = detectOS()
|
|
38
|
+
|
|
39
|
+
switch (os) {
|
|
40
|
+
case "darwin":
|
|
41
|
+
return {
|
|
42
|
+
os,
|
|
43
|
+
homeDir,
|
|
44
|
+
configDir: darwin.configDir,
|
|
45
|
+
dataDir: darwin.dataDir,
|
|
46
|
+
cacheDir: darwin.cacheDir
|
|
47
|
+
}
|
|
48
|
+
case "linux":
|
|
49
|
+
return {
|
|
50
|
+
os,
|
|
51
|
+
homeDir,
|
|
52
|
+
configDir: linux.configDir,
|
|
53
|
+
dataDir: linux.dataDir,
|
|
54
|
+
cacheDir: linux.cacheDir
|
|
55
|
+
}
|
|
56
|
+
case "win32":
|
|
57
|
+
return {
|
|
58
|
+
os,
|
|
59
|
+
homeDir,
|
|
60
|
+
configDir: windows.configDir,
|
|
61
|
+
dataDir: windows.dataDir,
|
|
62
|
+
cacheDir: windows.cacheDir
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Live platform layer that uses the actual system paths.
|
|
69
|
+
*
|
|
70
|
+
* Uses runtime platform detection to select the appropriate implementation.
|
|
71
|
+
*/
|
|
72
|
+
export const PlatformLive: Layer.Layer<Platform> = Layer.sync(Platform, createPlatformService)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Common platform utilities.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { Effect } from "effect"
|
|
7
|
+
import * as os from "node:os"
|
|
8
|
+
import * as path from "node:path"
|
|
9
|
+
import { NotFoundError } from "../../errors.js"
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Returns the user's home directory.
|
|
13
|
+
*/
|
|
14
|
+
export const homeDir = Effect.sync(() => {
|
|
15
|
+
const home = os.homedir()
|
|
16
|
+
if (!home) {
|
|
17
|
+
return Effect.fail(new NotFoundError({ message: "home directory" }))
|
|
18
|
+
}
|
|
19
|
+
return Effect.succeed(home)
|
|
20
|
+
}).pipe(Effect.flatten)
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Joins path segments.
|
|
24
|
+
*/
|
|
25
|
+
export const joinPath = (...segments: Array<string>): string => path.join(...segments)
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Checks if a path is absolute.
|
|
29
|
+
*/
|
|
30
|
+
export const isAbsolute = (p: string): boolean => path.isAbsolute(p)
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* macOS-specific path resolution.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { Effect } from "effect"
|
|
7
|
+
import type { PlatformError } from "../../errors.js"
|
|
8
|
+
import { homeDir, joinPath } from "./common.js"
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Returns the user's config directory on macOS.
|
|
12
|
+
*
|
|
13
|
+
* Most CLI tools use `~/.config/` following XDG conventions,
|
|
14
|
+
* though native macOS apps prefer `~/Library/Application Support/`.
|
|
15
|
+
*/
|
|
16
|
+
export const configDir: Effect.Effect<string, PlatformError> = Effect.map(
|
|
17
|
+
homeDir,
|
|
18
|
+
(home) => joinPath(home, ".config")
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Returns the user's data directory on macOS.
|
|
23
|
+
*
|
|
24
|
+
* Returns `~/Library/Application Support/` for native macOS conventions.
|
|
25
|
+
*/
|
|
26
|
+
export const dataDir: Effect.Effect<string, PlatformError> = Effect.map(
|
|
27
|
+
homeDir,
|
|
28
|
+
(home) => joinPath(home, "Library", "Application Support")
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Returns the Application Support directory on macOS.
|
|
33
|
+
*
|
|
34
|
+
* This is `~/Library/Application Support/`, used by native macOS applications.
|
|
35
|
+
*/
|
|
36
|
+
export const applicationSupportDir: Effect.Effect<string, PlatformError> = dataDir
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Returns the cache directory on macOS.
|
|
40
|
+
*
|
|
41
|
+
* On macOS, we use the data directory as there's no standard XDG cache.
|
|
42
|
+
*/
|
|
43
|
+
export const cacheDir: Effect.Effect<string, PlatformError> = dataDir
|