@sayoriqwq/effect-harness 0.0.3 → 0.0.5
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/dist/bin/effect-harness.js +2 -13
- package/dist/bin/effect-harness.js.map +1 -1
- package/dist/src/harness/ProviderDiscovery.d.ts +96 -10
- package/dist/src/harness/ProviderDiscovery.js +107 -18
- package/dist/src/harness/ProviderDiscovery.js.map +1 -1
- package/dist/src/harness/verify/ProviderProfile.js +45 -19
- package/dist/src/harness/verify/ProviderProfile.js.map +1 -1
- package/dist/src/harness/verify/TsgoPolicy.d.ts +3 -0
- package/dist/src/harness/verify/TsgoPolicy.js +3 -0
- package/dist/src/harness/verify/TsgoPolicy.js.map +1 -1
- package/dist/src/index.d.ts +8 -0
- package/dist/src/index.js +16 -0
- package/dist/src/index.js.map +1 -0
- package/harness/diagnostic-layers.md +1 -1
- package/package.json +9 -2
- package/provider/docs/discovery.md +26 -0
- package/provider/docs/package-config.md +16 -0
- package/provider/docs/quality-policy.md +14 -4
- package/provider/effect-harness.provider.json +48 -11
- package/provider/index.md +8 -0
- package/repos/effect.subtree.json +2 -2
- package/repos/tsgo.subtree.json +2 -2
|
@@ -6,23 +6,12 @@ import * as NodeServices from '@effect/platform-node/NodeServices';
|
|
|
6
6
|
import { Effect, Layer } from 'effect';
|
|
7
7
|
import { runCli } from "../src/cli/Main.js";
|
|
8
8
|
import { errorMessage } from "../src/harness/Errors.js";
|
|
9
|
-
|
|
9
|
+
import { resolvePackageArtifactRoot } from "../src/harness/ProviderDiscovery.js";
|
|
10
|
+
const harnessRoot = resolvePackageArtifactRoot(fileURLToPath(import.meta.url));
|
|
10
11
|
NodeRuntime.runMain(runCli({
|
|
11
12
|
harnessRoot,
|
|
12
13
|
version: '0.0.0',
|
|
13
14
|
}).pipe(withNodeServices));
|
|
14
|
-
function resolveHarnessRoot(entrypoint) {
|
|
15
|
-
const marker = '/dist/bin/';
|
|
16
|
-
const index = entrypoint.indexOf(marker);
|
|
17
|
-
if (index >= 0) {
|
|
18
|
-
return entrypoint.slice(0, index);
|
|
19
|
-
}
|
|
20
|
-
const sourceBinIndex = entrypoint.lastIndexOf('/bin/');
|
|
21
|
-
if (sourceBinIndex >= 0) {
|
|
22
|
-
return entrypoint.slice(0, sourceBinIndex);
|
|
23
|
-
}
|
|
24
|
-
return process.cwd();
|
|
25
|
-
}
|
|
26
15
|
function withNodeServices(effect) {
|
|
27
16
|
return Effect.scoped(Effect.gen(function* () {
|
|
28
17
|
const context = yield* Layer.build(NodeServices.layer);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"effect-harness.js","sourceRoot":"","sources":["../../bin/effect-harness.ts"],"names":[],"mappings":";AAEA,OAAO,OAAO,MAAM,cAAc,CAAA;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,KAAK,WAAW,MAAM,mCAAmC,CAAA;AAChE,OAAO,KAAK,YAAY,MAAM,oCAAoC,CAAA;AAClE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;
|
|
1
|
+
{"version":3,"file":"effect-harness.js","sourceRoot":"","sources":["../../bin/effect-harness.ts"],"names":[],"mappings":";AAEA,OAAO,OAAO,MAAM,cAAc,CAAA;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,KAAK,WAAW,MAAM,mCAAmC,CAAA;AAChE,OAAO,KAAK,YAAY,MAAM,oCAAoC,CAAA;AAClE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACvD,OAAO,EAAE,0BAA0B,EAAE,MAAM,qCAAqC,CAAA;AAEhF,MAAM,WAAW,GAAG,0BAA0B,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;AAE9E,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC;IACzB,WAAW;IACX,OAAO,EAAE,OAAO;CACjB,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAA;AAE1B,SAAS,gBAAgB,CACvB,MAAyD;IAEzD,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QACvC,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,CAAA;QACtD,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,IAAI,CAC3E,MAAM,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE,CAC9B,MAAM,CAAC,OAAO,CACZ,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,EACpC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE;YACf,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAA;QACtB,CAAC,CAAC,CACH,CAAC,CACL,CAAC,CAAC,CAAA;IACL,CAAC,CAAC,CAAC,CAAA;AACL,CAAC","sourcesContent":["#!/usr/bin/env node\n\nimport process from 'node:process'\nimport { fileURLToPath } from 'node:url'\nimport * as NodeRuntime from '@effect/platform-node/NodeRuntime'\nimport * as NodeServices from '@effect/platform-node/NodeServices'\nimport { Effect, Layer } from 'effect'\nimport { runCli } from '../src/cli/Main.ts'\nimport { errorMessage } from '../src/harness/Errors.ts'\nimport { resolvePackageArtifactRoot } from '../src/harness/ProviderDiscovery.ts'\n\nconst harnessRoot = resolvePackageArtifactRoot(fileURLToPath(import.meta.url))\n\nNodeRuntime.runMain(runCli({\n harnessRoot,\n version: '0.0.0',\n}).pipe(withNodeServices))\n\nfunction withNodeServices<E>(\n effect: Effect.Effect<void, E, NodeServices.NodeServices>,\n): Effect.Effect<void, never> {\n return Effect.scoped(Effect.gen(function* () {\n const context = yield* Layer.build(NodeServices.layer)\n return yield* Effect.promise(() => Effect.runPromiseWith(context)(effect.pipe(\n Effect.catch((error: unknown) =>\n Effect.andThen(\n Effect.logError(errorMessage(error)),\n Effect.sync(() => {\n process.exitCode = 1\n }),\n )),\n )))\n }))\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Effect, Path } from 'effect';
|
|
1
|
+
import { Effect, FileSystem, Path } from 'effect';
|
|
2
2
|
import { HarnessError } from './Errors.ts';
|
|
3
3
|
type JsonRecord = Record<string, unknown>;
|
|
4
4
|
interface ManagedFileDeclaration {
|
|
@@ -7,6 +7,7 @@ interface ManagedFileDeclaration {
|
|
|
7
7
|
readonly targetPath: string;
|
|
8
8
|
readonly contentType: string;
|
|
9
9
|
readonly managed: boolean;
|
|
10
|
+
readonly content: string;
|
|
10
11
|
readonly targetUsage?: string;
|
|
11
12
|
}
|
|
12
13
|
interface ManagedFilesContribution {
|
|
@@ -14,11 +15,62 @@ interface ManagedFilesContribution {
|
|
|
14
15
|
readonly targetBasePath: string;
|
|
15
16
|
readonly files: ReadonlyArray<ManagedFileDeclaration>;
|
|
16
17
|
}
|
|
18
|
+
interface SemanticContributions {
|
|
19
|
+
readonly packageJson: JsonRecord;
|
|
20
|
+
readonly tsconfig: JsonRecord;
|
|
21
|
+
readonly editorPolicy: JsonRecord;
|
|
22
|
+
readonly lintGuardrails: JsonRecord;
|
|
23
|
+
readonly testPolicy: JsonRecord;
|
|
24
|
+
readonly verificationPolicy: JsonRecord;
|
|
25
|
+
}
|
|
26
|
+
interface ArtifactOnlyReferenceAuditEntry {
|
|
27
|
+
readonly id: string;
|
|
28
|
+
readonly path: string;
|
|
29
|
+
readonly sourceEntry: string;
|
|
30
|
+
readonly targetDelivery: string;
|
|
31
|
+
readonly available: true;
|
|
32
|
+
}
|
|
33
|
+
interface ArtifactOnlyReferenceAudit {
|
|
34
|
+
readonly mode: 'artifact-only-reference-audit';
|
|
35
|
+
readonly references: ReadonlyArray<ArtifactOnlyReferenceAuditEntry>;
|
|
36
|
+
}
|
|
37
|
+
interface NpmInvocationFailureClassification {
|
|
38
|
+
readonly classification: 'npm-invocation-failure';
|
|
39
|
+
readonly code: 'npm-command-failed' | 'npm-same-name-cwd-short-circuit';
|
|
40
|
+
readonly providerDiscoveryStarted: false;
|
|
41
|
+
}
|
|
42
|
+
interface ProviderDiscoveryFailureClassification {
|
|
43
|
+
readonly classification: 'provider-discovery-failure';
|
|
44
|
+
readonly code: 'provider-discovery-error';
|
|
45
|
+
readonly providerDiscoveryStarted: true;
|
|
46
|
+
}
|
|
47
|
+
export interface ProviderDiscoveryFailureInput {
|
|
48
|
+
readonly stderr: string;
|
|
49
|
+
readonly stdout?: string;
|
|
50
|
+
readonly cwdPackageName?: string;
|
|
51
|
+
readonly cwdPackageVersion?: string;
|
|
52
|
+
readonly requestedPackageName?: string;
|
|
53
|
+
readonly requestedPackageVersion?: string;
|
|
54
|
+
}
|
|
55
|
+
export type ProviderDiscoveryFailure = NpmInvocationFailureClassification | ProviderDiscoveryFailureClassification;
|
|
17
56
|
export interface ProviderDiscovery {
|
|
18
57
|
readonly schemaVersion: 1;
|
|
19
58
|
readonly artifactRoot: string;
|
|
20
59
|
readonly providerProfilePath: string;
|
|
21
60
|
readonly providerProfileRelativePath: 'provider/effect-harness.provider.json';
|
|
61
|
+
readonly packageArtifactIdentity: {
|
|
62
|
+
readonly packageName: string;
|
|
63
|
+
readonly packageVersion: string;
|
|
64
|
+
readonly packageManager: string;
|
|
65
|
+
readonly artifactRoot: string;
|
|
66
|
+
readonly packageJsonPath: string;
|
|
67
|
+
readonly providerProfilePath: string;
|
|
68
|
+
readonly npmSelector: string;
|
|
69
|
+
readonly neutralDiscoveryCommand: string;
|
|
70
|
+
readonly invocationFailureClassification: {
|
|
71
|
+
readonly sameNameCwdShortCircuit: NpmInvocationFailureClassification;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
22
74
|
readonly packageLocator: {
|
|
23
75
|
readonly packageName: string;
|
|
24
76
|
readonly packageVersion: string;
|
|
@@ -45,19 +97,13 @@ export interface ProviderDiscovery {
|
|
|
45
97
|
readonly providerArtifactReference: JsonRecord;
|
|
46
98
|
readonly exportedHarness: JsonRecord;
|
|
47
99
|
};
|
|
100
|
+
readonly semanticContributions: SemanticContributions;
|
|
48
101
|
readonly targetManagedSurfaces: {
|
|
49
102
|
readonly targetReceives: ReadonlyArray<string>;
|
|
50
103
|
readonly targetDoesNotReceive: ReadonlyArray<string>;
|
|
51
104
|
readonly documentationBundle: ManagedFilesContribution;
|
|
52
105
|
readonly snippets: ManagedFilesContribution;
|
|
53
|
-
readonly contributions:
|
|
54
|
-
readonly packageJson: JsonRecord;
|
|
55
|
-
readonly tsconfig: JsonRecord;
|
|
56
|
-
readonly editorPolicy: JsonRecord;
|
|
57
|
-
readonly lintGuardrails: JsonRecord;
|
|
58
|
-
readonly testPolicy: JsonRecord;
|
|
59
|
-
readonly verificationPolicy: JsonRecord;
|
|
60
|
-
};
|
|
106
|
+
readonly contributions: SemanticContributions;
|
|
61
107
|
};
|
|
62
108
|
readonly artifactOnlyReferences: {
|
|
63
109
|
readonly mode: string;
|
|
@@ -65,6 +111,7 @@ export interface ProviderDiscovery {
|
|
|
65
111
|
readonly packageSurface: ReadonlyArray<string>;
|
|
66
112
|
readonly references: JsonRecord;
|
|
67
113
|
};
|
|
114
|
+
readonly artifactOnlyReferenceAudit: ArtifactOnlyReferenceAudit;
|
|
68
115
|
readonly sourceIdentities: {
|
|
69
116
|
readonly defaultSourceEntry: string;
|
|
70
117
|
readonly sourceEntries: ReadonlyArray<string>;
|
|
@@ -79,11 +126,30 @@ export interface ProviderDiscovery {
|
|
|
79
126
|
};
|
|
80
127
|
readonly internalHarnessSurfaces: JsonRecord;
|
|
81
128
|
}
|
|
129
|
+
export declare function resolvePackageArtifactRoot(entrypoint: string): string;
|
|
130
|
+
export declare function classifyProviderDiscoveryFailure(input: ProviderDiscoveryFailureInput): ProviderDiscoveryFailure;
|
|
82
131
|
export declare const discoverProvider: (harness: string) => Effect.Effect<{
|
|
83
132
|
schemaVersion: 1;
|
|
84
133
|
artifactRoot: string;
|
|
85
134
|
providerProfilePath: string;
|
|
86
135
|
providerProfileRelativePath: "provider/effect-harness.provider.json";
|
|
136
|
+
packageArtifactIdentity: {
|
|
137
|
+
packageName: string;
|
|
138
|
+
packageVersion: string;
|
|
139
|
+
packageManager: string;
|
|
140
|
+
artifactRoot: string;
|
|
141
|
+
packageJsonPath: string;
|
|
142
|
+
providerProfilePath: string;
|
|
143
|
+
npmSelector: string;
|
|
144
|
+
neutralDiscoveryCommand: string;
|
|
145
|
+
invocationFailureClassification: {
|
|
146
|
+
sameNameCwdShortCircuit: {
|
|
147
|
+
classification: "npm-invocation-failure";
|
|
148
|
+
code: "npm-same-name-cwd-short-circuit";
|
|
149
|
+
providerDiscoveryStarted: false;
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
};
|
|
87
153
|
packageLocator: {
|
|
88
154
|
packageName: string;
|
|
89
155
|
packageVersion: string;
|
|
@@ -110,6 +176,14 @@ export declare const discoverProvider: (harness: string) => Effect.Effect<{
|
|
|
110
176
|
providerArtifactReference: JsonRecord;
|
|
111
177
|
exportedHarness: JsonRecord;
|
|
112
178
|
};
|
|
179
|
+
semanticContributions: {
|
|
180
|
+
packageJson: JsonRecord;
|
|
181
|
+
tsconfig: JsonRecord;
|
|
182
|
+
editorPolicy: JsonRecord;
|
|
183
|
+
lintGuardrails: JsonRecord;
|
|
184
|
+
testPolicy: JsonRecord;
|
|
185
|
+
verificationPolicy: JsonRecord;
|
|
186
|
+
};
|
|
113
187
|
targetManagedSurfaces: {
|
|
114
188
|
targetReceives: string[];
|
|
115
189
|
targetDoesNotReceive: string[];
|
|
@@ -123,6 +197,7 @@ export declare const discoverProvider: (harness: string) => Effect.Effect<{
|
|
|
123
197
|
targetPath: string;
|
|
124
198
|
contentType: string;
|
|
125
199
|
managed: boolean;
|
|
200
|
+
content: string;
|
|
126
201
|
}[];
|
|
127
202
|
};
|
|
128
203
|
snippets: {
|
|
@@ -135,6 +210,7 @@ export declare const discoverProvider: (harness: string) => Effect.Effect<{
|
|
|
135
210
|
targetPath: string;
|
|
136
211
|
contentType: string;
|
|
137
212
|
managed: boolean;
|
|
213
|
+
content: string;
|
|
138
214
|
}[];
|
|
139
215
|
};
|
|
140
216
|
contributions: {
|
|
@@ -152,6 +228,16 @@ export declare const discoverProvider: (harness: string) => Effect.Effect<{
|
|
|
152
228
|
packageSurface: string[];
|
|
153
229
|
references: JsonRecord;
|
|
154
230
|
};
|
|
231
|
+
artifactOnlyReferenceAudit: {
|
|
232
|
+
mode: "artifact-only-reference-audit";
|
|
233
|
+
references: {
|
|
234
|
+
available: true;
|
|
235
|
+
id: string;
|
|
236
|
+
path: string;
|
|
237
|
+
sourceEntry: string;
|
|
238
|
+
targetDelivery: string;
|
|
239
|
+
}[];
|
|
240
|
+
};
|
|
155
241
|
sourceIdentities: {
|
|
156
242
|
defaultSourceEntry: string;
|
|
157
243
|
sourceEntries: string[];
|
|
@@ -165,5 +251,5 @@ export declare const discoverProvider: (harness: string) => Effect.Effect<{
|
|
|
165
251
|
artifactReferences: JsonRecord;
|
|
166
252
|
};
|
|
167
253
|
internalHarnessSurfaces: JsonRecord;
|
|
168
|
-
}, HarnessError | import("effect/PlatformError").PlatformError,
|
|
254
|
+
}, HarnessError | import("effect/PlatformError").PlatformError, FileSystem.FileSystem | Path.Path>;
|
|
169
255
|
export {};
|
|
@@ -1,7 +1,40 @@
|
|
|
1
|
-
import { Effect, Path } from 'effect';
|
|
1
|
+
import { Effect, FileSystem, Path } from 'effect';
|
|
2
2
|
import { readJson } from "../platform/Json.js";
|
|
3
3
|
import { HarnessError } from "./Errors.js";
|
|
4
4
|
import { isRecord } from "./verify/JsonFields.js";
|
|
5
|
+
export function resolvePackageArtifactRoot(entrypoint) {
|
|
6
|
+
for (const marker of ['/dist/bin/', '/dist/src/', '/bin/', '/src/']) {
|
|
7
|
+
const index = entrypoint.indexOf(marker);
|
|
8
|
+
if (index >= 0) {
|
|
9
|
+
return entrypoint.slice(0, index);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return entrypoint;
|
|
13
|
+
}
|
|
14
|
+
export function classifyProviderDiscoveryFailure(input) {
|
|
15
|
+
const sameRequestedPackage = input.cwdPackageName === input.requestedPackageName
|
|
16
|
+
&& input.cwdPackageVersion === input.requestedPackageVersion;
|
|
17
|
+
const commandNotFound = /(?:^|\n)(?:sh: )?effect-harness: command not found(?:\n|$)/u.test(input.stderr);
|
|
18
|
+
if (sameRequestedPackage && commandNotFound) {
|
|
19
|
+
return {
|
|
20
|
+
classification: 'npm-invocation-failure',
|
|
21
|
+
code: 'npm-same-name-cwd-short-circuit',
|
|
22
|
+
providerDiscoveryStarted: false,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
if (commandNotFound || input.stderr.includes('Cannot find package') || input.stderr.includes('npm ERR!')) {
|
|
26
|
+
return {
|
|
27
|
+
classification: 'npm-invocation-failure',
|
|
28
|
+
code: 'npm-command-failed',
|
|
29
|
+
providerDiscoveryStarted: false,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
classification: 'provider-discovery-failure',
|
|
34
|
+
code: 'provider-discovery-error',
|
|
35
|
+
providerDiscoveryStarted: true,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
5
38
|
function decodeJsonRecord(value, source) {
|
|
6
39
|
return isRecord(value)
|
|
7
40
|
? Effect.succeed(value)
|
|
@@ -17,6 +50,9 @@ function expectString(value, source) {
|
|
|
17
50
|
? Effect.succeed(value)
|
|
18
51
|
: Effect.fail(new HarnessError({ message: `${source} must be a string` }));
|
|
19
52
|
}
|
|
53
|
+
function optionalString(value, fallback) {
|
|
54
|
+
return typeof value === 'string' ? value : fallback;
|
|
55
|
+
}
|
|
20
56
|
function expectBoolean(value, source) {
|
|
21
57
|
return typeof value === 'boolean'
|
|
22
58
|
? Effect.succeed(value)
|
|
@@ -31,27 +67,31 @@ const expectStringArray = Effect.fnUntraced(function* (value, source) {
|
|
|
31
67
|
const array = yield* expectArray(value, source);
|
|
32
68
|
return yield* Effect.forEach(array, (entry, index) => expectString(entry, `${source}[${index}]`));
|
|
33
69
|
});
|
|
34
|
-
const expectManagedFileDeclaration = Effect.fnUntraced(function* (value, source) {
|
|
70
|
+
const expectManagedFileDeclaration = Effect.fnUntraced(function* (value, source, artifactRoot) {
|
|
35
71
|
const file = yield* expectRecord(value, source);
|
|
72
|
+
const path = yield* Path.Path;
|
|
73
|
+
const fs = yield* FileSystem.FileSystem;
|
|
74
|
+
const sourcePath = yield* expectString(file.sourcePath, `${source}.sourcePath`);
|
|
36
75
|
const targetUsage = file.targetUsage === undefined
|
|
37
76
|
? undefined
|
|
38
77
|
: yield* expectString(file.targetUsage, `${source}.targetUsage`);
|
|
39
78
|
return {
|
|
40
79
|
id: yield* expectString(file.id, `${source}.id`),
|
|
41
|
-
sourcePath
|
|
80
|
+
sourcePath,
|
|
42
81
|
targetPath: yield* expectString(file.targetPath, `${source}.targetPath`),
|
|
43
82
|
contentType: yield* expectString(file.contentType, `${source}.contentType`),
|
|
44
83
|
managed: yield* expectBoolean(file.managed, `${source}.managed`),
|
|
84
|
+
content: yield* fs.readFileString(path.join(artifactRoot, sourcePath)),
|
|
45
85
|
...(targetUsage === undefined ? {} : { targetUsage }),
|
|
46
86
|
};
|
|
47
87
|
});
|
|
48
|
-
const expectManagedFilesContribution = Effect.fnUntraced(function* (value, source) {
|
|
88
|
+
const expectManagedFilesContribution = Effect.fnUntraced(function* (value, source, artifactRoot) {
|
|
49
89
|
const contribution = yield* expectRecord(value, source);
|
|
50
90
|
const files = yield* expectArray(contribution.files, `${source}.files`);
|
|
51
91
|
return {
|
|
52
92
|
mode: yield* expectString(contribution.mode, `${source}.mode`),
|
|
53
93
|
targetBasePath: yield* expectString(contribution.targetBasePath, `${source}.targetBasePath`),
|
|
54
|
-
files: yield* Effect.forEach(files, (file, index) => expectManagedFileDeclaration(file, `${source}.files[${index}]
|
|
94
|
+
files: yield* Effect.forEach(files, (file, index) => expectManagedFileDeclaration(file, `${source}.files[${index}]`, artifactRoot)),
|
|
55
95
|
};
|
|
56
96
|
});
|
|
57
97
|
function expectNamedRecord(record, field, source) {
|
|
@@ -75,13 +115,38 @@ const expectArtifactReferences = Effect.fnUntraced(function* (providerProfile) {
|
|
|
75
115
|
references,
|
|
76
116
|
};
|
|
77
117
|
});
|
|
118
|
+
const expectArtifactOnlyReferenceAudit = Effect.fnUntraced(function* (references, artifactRoot) {
|
|
119
|
+
const fs = yield* FileSystem.FileSystem;
|
|
120
|
+
const path = yield* Path.Path;
|
|
121
|
+
const entries = yield* Effect.forEach(Object.entries(references), ([id, value]) => Effect.gen(function* () {
|
|
122
|
+
const reference = yield* expectRecord(value, `provider profile.artifactReferences.references.${id}`);
|
|
123
|
+
const referencePath = yield* expectString(reference.path, `provider profile.artifactReferences.references.${id}.path`);
|
|
124
|
+
const absolutePath = path.join(artifactRoot, referencePath);
|
|
125
|
+
const available = yield* fs.exists(absolutePath);
|
|
126
|
+
if (!available) {
|
|
127
|
+
return yield* new HarnessError({ message: `artifact-only reference ${id} is missing from package artifact at ${referencePath}` });
|
|
128
|
+
}
|
|
129
|
+
return {
|
|
130
|
+
available: true,
|
|
131
|
+
id,
|
|
132
|
+
path: referencePath,
|
|
133
|
+
sourceEntry: yield* expectString(reference.sourceEntry, `provider profile.artifactReferences.references.${id}.sourceEntry`),
|
|
134
|
+
targetDelivery: yield* expectString(reference.targetDelivery, `provider profile.artifactReferences.references.${id}.targetDelivery`),
|
|
135
|
+
};
|
|
136
|
+
}));
|
|
137
|
+
return {
|
|
138
|
+
mode: 'artifact-only-reference-audit',
|
|
139
|
+
references: entries,
|
|
140
|
+
};
|
|
141
|
+
});
|
|
78
142
|
export const discoverProvider = Effect.fnUntraced(function* (harness) {
|
|
79
143
|
const path = yield* Path.Path;
|
|
80
144
|
const artifactRoot = path.resolve(harness);
|
|
81
145
|
const providerProfileRelativePath = 'provider/effect-harness.provider.json';
|
|
82
146
|
const providerProfilePath = path.join(artifactRoot, providerProfileRelativePath);
|
|
147
|
+
const packageJsonPath = path.join(artifactRoot, 'package.json');
|
|
83
148
|
const providerProfile = yield* readJson(providerProfilePath, decodeJsonRecord);
|
|
84
|
-
const packageManifest = yield* readJson(
|
|
149
|
+
const packageManifest = yield* readJson(packageJsonPath, decodeJsonRecord);
|
|
85
150
|
const provider = yield* expectNamedRecord(providerProfile, 'provider', 'provider profile');
|
|
86
151
|
const profiles = yield* expectNamedRecord(providerProfile, 'profiles', 'provider profile');
|
|
87
152
|
const defaultProfile = yield* expectString(provider.defaultProfile, 'provider profile.provider.defaultProfile');
|
|
@@ -93,14 +158,43 @@ export const discoverProvider = Effect.fnUntraced(function* (harness) {
|
|
|
93
158
|
const packageBin = yield* expectNamedRecord(packageManifest, 'bin', 'package.json');
|
|
94
159
|
const artifactOnlyReferences = yield* expectArtifactReferences(providerProfile);
|
|
95
160
|
const deliveryModes = yield* expectDeliveryModes(providerProfile);
|
|
161
|
+
const packageName = yield* expectString(packageManifest.name, 'package.json.name');
|
|
162
|
+
const packageVersion = yield* expectString(packageManifest.version, 'package.json.version');
|
|
163
|
+
const packageManager = optionalString(packageManifest.packageManager, 'unknown');
|
|
164
|
+
const npmSelector = `${packageName}@${packageVersion}`;
|
|
165
|
+
const semanticContributions = {
|
|
166
|
+
packageJson: yield* expectNamedRecord(contributions, 'packageJson', `provider profile.profiles.${defaultProfile}.contributions`),
|
|
167
|
+
tsconfig: yield* expectNamedRecord(contributions, 'tsconfig', `provider profile.profiles.${defaultProfile}.contributions`),
|
|
168
|
+
editorPolicy: yield* expectNamedRecord(contributions, 'editorPolicy', `provider profile.profiles.${defaultProfile}.contributions`),
|
|
169
|
+
lintGuardrails: yield* expectNamedRecord(contributions, 'lintGuardrails', `provider profile.profiles.${defaultProfile}.contributions`),
|
|
170
|
+
testPolicy: yield* expectNamedRecord(contributions, 'testPolicy', `provider profile.profiles.${defaultProfile}.contributions`),
|
|
171
|
+
verificationPolicy: yield* expectNamedRecord(contributions, 'verificationPolicy', `provider profile.profiles.${defaultProfile}.contributions`),
|
|
172
|
+
};
|
|
96
173
|
return {
|
|
97
174
|
schemaVersion: 1,
|
|
98
175
|
artifactRoot,
|
|
99
176
|
providerProfilePath,
|
|
100
177
|
providerProfileRelativePath,
|
|
178
|
+
packageArtifactIdentity: {
|
|
179
|
+
packageName,
|
|
180
|
+
packageVersion,
|
|
181
|
+
packageManager,
|
|
182
|
+
artifactRoot,
|
|
183
|
+
packageJsonPath,
|
|
184
|
+
providerProfilePath,
|
|
185
|
+
npmSelector,
|
|
186
|
+
neutralDiscoveryCommand: `npx --yes --package ${npmSelector} effect-harness provider-discover`,
|
|
187
|
+
invocationFailureClassification: {
|
|
188
|
+
sameNameCwdShortCircuit: {
|
|
189
|
+
classification: 'npm-invocation-failure',
|
|
190
|
+
code: 'npm-same-name-cwd-short-circuit',
|
|
191
|
+
providerDiscoveryStarted: false,
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
},
|
|
101
195
|
packageLocator: {
|
|
102
|
-
packageName
|
|
103
|
-
packageVersion
|
|
196
|
+
packageName,
|
|
197
|
+
packageVersion,
|
|
104
198
|
binName: 'effect-harness',
|
|
105
199
|
binPath: yield* expectString(packageBin['effect-harness'], 'package.json.bin.effect-harness'),
|
|
106
200
|
discoveryCommand: 'npx --yes @sayoriqwq/effect-harness provider-discover',
|
|
@@ -120,21 +214,16 @@ export const discoverProvider = Effect.fnUntraced(function* (harness) {
|
|
|
120
214
|
targetLifecycleOwner: yield* expectString(selfConformance.lifecycleOwner, 'provider profile.selfConformance.lifecycleOwner'),
|
|
121
215
|
},
|
|
122
216
|
deliveryModes,
|
|
217
|
+
semanticContributions,
|
|
123
218
|
targetManagedSurfaces: {
|
|
124
219
|
targetReceives: yield* expectStringArray(managedSurfaces.targetReceives, `provider profile.profiles.${defaultProfile}.managedSurfaces.targetReceives`),
|
|
125
220
|
targetDoesNotReceive: yield* expectStringArray(managedSurfaces.targetDoesNotReceive, `provider profile.profiles.${defaultProfile}.managedSurfaces.targetDoesNotReceive`),
|
|
126
|
-
documentationBundle: yield* expectManagedFilesContribution(contributions.documentationBundle, `provider profile.profiles.${defaultProfile}.contributions.documentationBundle
|
|
127
|
-
snippets: yield* expectManagedFilesContribution(contributions.snippets, `provider profile.profiles.${defaultProfile}.contributions.snippets
|
|
128
|
-
contributions:
|
|
129
|
-
packageJson: yield* expectNamedRecord(contributions, 'packageJson', `provider profile.profiles.${defaultProfile}.contributions`),
|
|
130
|
-
tsconfig: yield* expectNamedRecord(contributions, 'tsconfig', `provider profile.profiles.${defaultProfile}.contributions`),
|
|
131
|
-
editorPolicy: yield* expectNamedRecord(contributions, 'editorPolicy', `provider profile.profiles.${defaultProfile}.contributions`),
|
|
132
|
-
lintGuardrails: yield* expectNamedRecord(contributions, 'lintGuardrails', `provider profile.profiles.${defaultProfile}.contributions`),
|
|
133
|
-
testPolicy: yield* expectNamedRecord(contributions, 'testPolicy', `provider profile.profiles.${defaultProfile}.contributions`),
|
|
134
|
-
verificationPolicy: yield* expectNamedRecord(contributions, 'verificationPolicy', `provider profile.profiles.${defaultProfile}.contributions`),
|
|
135
|
-
},
|
|
221
|
+
documentationBundle: yield* expectManagedFilesContribution(contributions.documentationBundle, `provider profile.profiles.${defaultProfile}.contributions.documentationBundle`, artifactRoot),
|
|
222
|
+
snippets: yield* expectManagedFilesContribution(contributions.snippets, `provider profile.profiles.${defaultProfile}.contributions.snippets`, artifactRoot),
|
|
223
|
+
contributions: semanticContributions,
|
|
136
224
|
},
|
|
137
225
|
artifactOnlyReferences,
|
|
226
|
+
artifactOnlyReferenceAudit: yield* expectArtifactOnlyReferenceAudit(artifactOnlyReferences.references, artifactRoot),
|
|
138
227
|
sourceIdentities: {
|
|
139
228
|
defaultSourceEntry: yield* expectString(selectedProfile.sourceEntry, `provider profile.profiles.${defaultProfile}.sourceEntry`),
|
|
140
229
|
sourceEntries: yield* expectStringArray(selectedProfile.sourceEntries, `provider profile.profiles.${defaultProfile}.sourceEntries`),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProviderDiscovery.js","sourceRoot":"","sources":["../../../src/harness/ProviderDiscovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AAqFjD,SAAS,gBAAgB,CAAC,KAAc,EAAE,MAAc;IACtD,OAAO,QAAQ,CAAC,KAAK,CAAC;QACpB,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;QACvB,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,YAAY,CAAC,EAAE,OAAO,EAAE,GAAG,MAAM,wBAAwB,EAAE,CAAC,CAAC,CAAA;AACnF,CAAC;AAED,SAAS,YAAY,CAAC,KAAc,EAAE,MAAc;IAClD,OAAO,QAAQ,CAAC,KAAK,CAAC;QACpB,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;QACvB,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,YAAY,CAAC,EAAE,OAAO,EAAE,GAAG,MAAM,wBAAwB,EAAE,CAAC,CAAC,CAAA;AACnF,CAAC;AAED,SAAS,YAAY,CAAC,KAAc,EAAE,MAAc;IAClD,OAAO,OAAO,KAAK,KAAK,QAAQ;QAC9B,CAAC,CAAC,MAAM,C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AAqB,EAAE,KAAK,CAAC,CAAC,iBAAiB,CAAC,eAAe,EAAE,eAAe,EAAE,kBAAkB,CAAC;YACrG,kBAAkB,EAAE,sBAAsB,CAAC,UAAU;SACtD;QACD,uBAAuB,EAAE,aAAa,CAAC,eAAe;KAC3B,CAAA;AAC/B,CAAC,CAAC,CAAA","sourcesContent":["import { Effect, Path } from 'effect'\nimport { readJson } from '../platform/Json.ts'\nimport { HarnessError } from './Errors.ts'\nimport { isRecord } from './verify/JsonFields.ts'\n\ntype JsonRecord = Record<string, unknown>\n\ninterface ManagedFileDeclaration {\n readonly id: string\n readonly sourcePath: string\n readonly targetPath: string\n readonly contentType: string\n readonly managed: boolean\n readonly targetUsage?: string\n}\n\ninterface ManagedFilesContribution {\n readonly mode: string\n readonly targetBasePath: string\n readonly files: ReadonlyArray<ManagedFileDeclaration>\n}\n\nexport interface ProviderDiscovery {\n readonly schemaVersion: 1\n readonly artifactRoot: string\n readonly providerProfilePath: string\n readonly providerProfileRelativePath: 'provider/effect-harness.provider.json'\n readonly packageLocator: {\n readonly packageName: string\n readonly packageVersion: string\n readonly binName: 'effect-harness'\n readonly binPath: string\n readonly discoveryCommand: string\n readonly packageFiles: ReadonlyArray<string>\n }\n readonly provider: {\n readonly id: string\n readonly contractVersion: string\n readonly providerVersion: string\n readonly defaultProfile: string\n }\n readonly selectedProfile: string\n readonly discovery: {\n readonly mode: 'provider-discovery'\n readonly consumer: 'prelude'\n readonly profileSource: 'provider/effect-harness.provider.json'\n readonly targetLifecycleOwner: string\n }\n readonly deliveryModes: {\n readonly internalHarness: JsonRecord\n readonly providerArtifactReference: JsonRecord\n readonly exportedHarness: JsonRecord\n }\n readonly targetManagedSurfaces: {\n readonly targetReceives: ReadonlyArray<string>\n readonly targetDoesNotReceive: ReadonlyArray<string>\n readonly documentationBundle: ManagedFilesContribution\n readonly snippets: ManagedFilesContribution\n readonly contributions: {\n readonly packageJson: JsonRecord\n readonly tsconfig: JsonRecord\n readonly editorPolicy: JsonRecord\n readonly lintGuardrails: JsonRecord\n readonly testPolicy: JsonRecord\n readonly verificationPolicy: JsonRecord\n }\n }\n readonly artifactOnlyReferences: {\n readonly mode: string\n readonly targetDelivery: string\n readonly packageSurface: ReadonlyArray<string>\n readonly references: JsonRecord\n }\n readonly sourceIdentities: {\n readonly defaultSourceEntry: string\n readonly sourceEntries: ReadonlyArray<string>\n readonly sourceBoundary: {\n readonly providerRepoInternal: boolean\n readonly targetDelivery: string\n readonly targetMustNotReceive: ReadonlyArray<string>\n readonly allowedTargetSourceIdentity: ReadonlyArray<string>\n }\n readonly providerSourceEntries: JsonRecord\n readonly artifactReferences: JsonRecord\n }\n readonly internalHarnessSurfaces: JsonRecord\n}\n\nfunction decodeJsonRecord(value: unknown, source: string): Effect.Effect<JsonRecord, HarnessError> {\n return isRecord(value)\n ? Effect.succeed(value)\n : Effect.fail(new HarnessError({ message: `${source} must be a JSON object` }))\n}\n\nfunction expectRecord(value: unknown, source: string): Effect.Effect<JsonRecord, HarnessError> {\n return isRecord(value)\n ? Effect.succeed(value)\n : Effect.fail(new HarnessError({ message: `${source} must be a JSON object` }))\n}\n\nfunction expectString(value: unknown, source: string): Effect.Effect<string, HarnessError> {\n return typeof value === 'string'\n ? Effect.succeed(value)\n : Effect.fail(new HarnessError({ message: `${source} must be a string` }))\n}\n\nfunction expectBoolean(value: unknown, source: string): Effect.Effect<boolean, HarnessError> {\n return typeof value === 'boolean'\n ? Effect.succeed(value)\n : Effect.fail(new HarnessError({ message: `${source} must be a boolean` }))\n}\n\nfunction expectArray(value: unknown, source: string): Effect.Effect<ReadonlyArray<unknown>, HarnessError> {\n return Array.isArray(value)\n ? Effect.succeed(value)\n : Effect.fail(new HarnessError({ message: `${source} must be an array` }))\n}\n\nconst expectStringArray = Effect.fnUntraced(function* (value: unknown, source: string) {\n const array = yield* expectArray(value, source)\n return yield* Effect.forEach(array, (entry, index) => expectString(entry, `${source}[${index}]`))\n})\n\nconst expectManagedFileDeclaration = Effect.fnUntraced(function* (value: unknown, source: string) {\n const file = yield* expectRecord(value, source)\n const targetUsage = file.targetUsage === undefined\n ? undefined\n : yield* expectString(file.targetUsage, `${source}.targetUsage`)\n\n return {\n id: yield* expectString(file.id, `${source}.id`),\n sourcePath: yield* expectString(file.sourcePath, `${source}.sourcePath`),\n targetPath: yield* expectString(file.targetPath, `${source}.targetPath`),\n contentType: yield* expectString(file.contentType, `${source}.contentType`),\n managed: yield* expectBoolean(file.managed, `${source}.managed`),\n ...(targetUsage === undefined ? {} : { targetUsage }),\n } satisfies ManagedFileDeclaration\n})\n\nconst expectManagedFilesContribution = Effect.fnUntraced(function* (value: unknown, source: string) {\n const contribution = yield* expectRecord(value, source)\n const files = yield* expectArray(contribution.files, `${source}.files`)\n return {\n mode: yield* expectString(contribution.mode, `${source}.mode`),\n targetBasePath: yield* expectString(contribution.targetBasePath, `${source}.targetBasePath`),\n files: yield* Effect.forEach(files, (file, index) => expectManagedFileDeclaration(file, `${source}.files[${index}]`)),\n } satisfies ManagedFilesContribution\n})\n\nfunction expectNamedRecord(record: JsonRecord, field: string, source: string): Effect.Effect<JsonRecord, HarnessError> {\n return expectRecord(record[field], `${source}.${field}`)\n}\n\nconst expectDeliveryModes = Effect.fnUntraced(function* (providerProfile: JsonRecord) {\n const deliveryModes = yield* expectNamedRecord(providerProfile, 'deliveryModes', 'provider profile')\n return {\n internalHarness: yield* expectNamedRecord(deliveryModes, 'internalHarness', 'provider profile.deliveryModes'),\n providerArtifactReference: yield* expectNamedRecord(deliveryModes, 'providerArtifactReference', 'provider profile.deliveryModes'),\n exportedHarness: yield* expectNamedRecord(deliveryModes, 'exportedHarness', 'provider profile.deliveryModes'),\n }\n})\n\nconst expectArtifactReferences = Effect.fnUntraced(function* (providerProfile: JsonRecord) {\n const artifactReferences = yield* expectNamedRecord(providerProfile, 'artifactReferences', 'provider profile')\n const references = yield* expectNamedRecord(artifactReferences, 'references', 'provider profile.artifactReferences')\n return {\n mode: yield* expectString(artifactReferences.mode, 'provider profile.artifactReferences.mode'),\n targetDelivery: yield* expectString(artifactReferences.targetDelivery, 'provider profile.artifactReferences.targetDelivery'),\n packageSurface: yield* expectStringArray(artifactReferences.packageSurface, 'provider profile.artifactReferences.packageSurface'),\n references,\n }\n})\n\nexport const discoverProvider = Effect.fnUntraced(function* (harness: string) {\n const path = yield* Path.Path\n const artifactRoot = path.resolve(harness)\n const providerProfileRelativePath = 'provider/effect-harness.provider.json'\n const providerProfilePath = path.join(artifactRoot, providerProfileRelativePath)\n\n const providerProfile = yield* readJson(providerProfilePath, decodeJsonRecord)\n const packageManifest = yield* readJson(path.join(artifactRoot, 'package.json'), decodeJsonRecord)\n const provider = yield* expectNamedRecord(providerProfile, 'provider', 'provider profile')\n const profiles = yield* expectNamedRecord(providerProfile, 'profiles', 'provider profile')\n const defaultProfile = yield* expectString(provider.defaultProfile, 'provider profile.provider.defaultProfile')\n const selectedProfile = yield* expectNamedRecord(profiles, defaultProfile, `provider profile.profiles.${defaultProfile}`)\n const contributions = yield* expectNamedRecord(selectedProfile, 'contributions', `provider profile.profiles.${defaultProfile}`)\n const managedSurfaces = yield* expectNamedRecord(selectedProfile, 'managedSurfaces', `provider profile.profiles.${defaultProfile}`)\n const sourceBoundary = yield* expectNamedRecord(selectedProfile, 'sourceBoundary', `provider profile.profiles.${defaultProfile}`)\n const selfConformance = yield* expectNamedRecord(providerProfile, 'selfConformance', 'provider profile')\n const packageBin = yield* expectNamedRecord(packageManifest, 'bin', 'package.json')\n const artifactOnlyReferences = yield* expectArtifactReferences(providerProfile)\n const deliveryModes = yield* expectDeliveryModes(providerProfile)\n\n return {\n schemaVersion: 1,\n artifactRoot,\n providerProfilePath,\n providerProfileRelativePath,\n packageLocator: {\n packageName: yield* expectString(packageManifest.name, 'package.json.name'),\n packageVersion: yield* expectString(packageManifest.version, 'package.json.version'),\n binName: 'effect-harness',\n binPath: yield* expectString(packageBin['effect-harness'], 'package.json.bin.effect-harness'),\n discoveryCommand: 'npx --yes @sayoriqwq/effect-harness provider-discover',\n packageFiles: yield* expectStringArray(packageManifest.files, 'package.json.files'),\n },\n provider: {\n id: yield* expectString(provider.id, 'provider profile.provider.id'),\n contractVersion: yield* expectString(provider.contractVersion, 'provider profile.provider.contractVersion'),\n providerVersion: yield* expectString(provider.providerVersion, 'provider profile.provider.providerVersion'),\n defaultProfile,\n },\n selectedProfile: defaultProfile,\n discovery: {\n mode: 'provider-discovery',\n consumer: 'prelude',\n profileSource: providerProfileRelativePath,\n targetLifecycleOwner: yield* expectString(selfConformance.lifecycleOwner, 'provider profile.selfConformance.lifecycleOwner'),\n },\n deliveryModes,\n targetManagedSurfaces: {\n targetReceives: yield* expectStringArray(managedSurfaces.targetReceives, `provider profile.profiles.${defaultProfile}.managedSurfaces.targetReceives`),\n targetDoesNotReceive: yield* expectStringArray(managedSurfaces.targetDoesNotReceive, `provider profile.profiles.${defaultProfile}.managedSurfaces.targetDoesNotReceive`),\n documentationBundle: yield* expectManagedFilesContribution(contributions.documentationBundle, `provider profile.profiles.${defaultProfile}.contributions.documentationBundle`),\n snippets: yield* expectManagedFilesContribution(contributions.snippets, `provider profile.profiles.${defaultProfile}.contributions.snippets`),\n contributions: {\n packageJson: yield* expectNamedRecord(contributions, 'packageJson', `provider profile.profiles.${defaultProfile}.contributions`),\n tsconfig: yield* expectNamedRecord(contributions, 'tsconfig', `provider profile.profiles.${defaultProfile}.contributions`),\n editorPolicy: yield* expectNamedRecord(contributions, 'editorPolicy', `provider profile.profiles.${defaultProfile}.contributions`),\n lintGuardrails: yield* expectNamedRecord(contributions, 'lintGuardrails', `provider profile.profiles.${defaultProfile}.contributions`),\n testPolicy: yield* expectNamedRecord(contributions, 'testPolicy', `provider profile.profiles.${defaultProfile}.contributions`),\n verificationPolicy: yield* expectNamedRecord(contributions, 'verificationPolicy', `provider profile.profiles.${defaultProfile}.contributions`),\n },\n },\n artifactOnlyReferences,\n sourceIdentities: {\n defaultSourceEntry: yield* expectString(selectedProfile.sourceEntry, `provider profile.profiles.${defaultProfile}.sourceEntry`),\n sourceEntries: yield* expectStringArray(selectedProfile.sourceEntries, `provider profile.profiles.${defaultProfile}.sourceEntries`),\n sourceBoundary: {\n providerRepoInternal: yield* expectBoolean(sourceBoundary.providerRepoInternal, `provider profile.profiles.${defaultProfile}.sourceBoundary.providerRepoInternal`),\n targetDelivery: yield* expectString(sourceBoundary.targetDelivery, `provider profile.profiles.${defaultProfile}.sourceBoundary.targetDelivery`),\n targetMustNotReceive: yield* expectStringArray(sourceBoundary.targetMustNotReceive, `provider profile.profiles.${defaultProfile}.sourceBoundary.targetMustNotReceive`),\n allowedTargetSourceIdentity: yield* expectStringArray(sourceBoundary.allowedTargetSourceIdentity, `provider profile.profiles.${defaultProfile}.sourceBoundary.allowedTargetSourceIdentity`),\n },\n providerSourceEntries: yield* expectNamedRecord(providerProfile, 'sourceEntries', 'provider profile'),\n artifactReferences: artifactOnlyReferences.references,\n },\n internalHarnessSurfaces: deliveryModes.internalHarness,\n } satisfies ProviderDiscovery\n})\n"]}
|
|
1
|
+
{"version":3,"file":"ProviderDiscovery.js","sourceRoot":"","sources":["../../../src/harness/ProviderDiscovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AA6IjD,MAAM,UAAU,0BAA0B,CAAC,UAAkB;IAC3D,KAAK,MAAM,MAAM,IAAI,CAAC,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,CAAC;QACpE,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QACxC,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;YACf,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC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K,CAAC,CAAC,YAAY,CAAC,cAAc,CAAC,cAAc,EAAE,6BAA6B,cAAc,gCAAgC,CAAC;gBAC/I,oBAAoB,EAAE,KAAK,CAAC,CAAC,iBAAiB,CAAC,cAAc,CAAC,oBAAoB,EAAE,6BAA6B,cAAc,sCAAsC,CAAC;gBACtK,2BAA2B,EAAE,KAAK,CAAC,CAAC,iBAAiB,CAAC,cAAc,CAAC,2BAA2B,EAAE,6BAA6B,cAAc,6CAA6C,CAAC;aAC5L;YACD,qBAAqB,EAAE,KAAK,CAAC,CAAC,iBAAiB,CAAC,eAAe,EAAE,eAAe,EAAE,kBAAkB,CAAC;YACrG,kBAAkB,EAAE,sBAAsB,CAAC,UAAU;SACtD;QACD,uBAAuB,EAAE,aAAa,CAAC,eAAe;KAC3B,CAAA;AAC/B,CAAC,CAAC,CAAA","sourcesContent":["import { Effect, FileSystem, Path } from 'effect'\nimport { readJson } from '../platform/Json.ts'\nimport { HarnessError } from './Errors.ts'\nimport { isRecord } from './verify/JsonFields.ts'\n\ntype JsonRecord = Record<string, unknown>\n\ninterface ManagedFileDeclaration {\n readonly id: string\n readonly sourcePath: string\n readonly targetPath: string\n readonly contentType: string\n readonly managed: boolean\n readonly content: string\n readonly targetUsage?: string\n}\n\ninterface ManagedFilesContribution {\n readonly mode: string\n readonly targetBasePath: string\n readonly files: ReadonlyArray<ManagedFileDeclaration>\n}\n\ninterface SemanticContributions {\n readonly packageJson: JsonRecord\n readonly tsconfig: JsonRecord\n readonly editorPolicy: JsonRecord\n readonly lintGuardrails: JsonRecord\n readonly testPolicy: JsonRecord\n readonly verificationPolicy: JsonRecord\n}\n\ninterface ArtifactOnlyReferenceAuditEntry {\n readonly id: string\n readonly path: string\n readonly sourceEntry: string\n readonly targetDelivery: string\n readonly available: true\n}\n\ninterface ArtifactOnlyReferenceAudit {\n readonly mode: 'artifact-only-reference-audit'\n readonly references: ReadonlyArray<ArtifactOnlyReferenceAuditEntry>\n}\n\ninterface NpmInvocationFailureClassification {\n readonly classification: 'npm-invocation-failure'\n readonly code: 'npm-command-failed' | 'npm-same-name-cwd-short-circuit'\n readonly providerDiscoveryStarted: false\n}\n\ninterface ProviderDiscoveryFailureClassification {\n readonly classification: 'provider-discovery-failure'\n readonly code: 'provider-discovery-error'\n readonly providerDiscoveryStarted: true\n}\n\nexport interface ProviderDiscoveryFailureInput {\n readonly stderr: string\n readonly stdout?: string\n readonly cwdPackageName?: string\n readonly cwdPackageVersion?: string\n readonly requestedPackageName?: string\n readonly requestedPackageVersion?: string\n}\n\nexport type ProviderDiscoveryFailure\n = | NpmInvocationFailureClassification\n | ProviderDiscoveryFailureClassification\n\nexport interface ProviderDiscovery {\n readonly schemaVersion: 1\n readonly artifactRoot: string\n readonly providerProfilePath: string\n readonly providerProfileRelativePath: 'provider/effect-harness.provider.json'\n readonly packageArtifactIdentity: {\n readonly packageName: string\n readonly packageVersion: string\n readonly packageManager: string\n readonly artifactRoot: string\n readonly packageJsonPath: string\n readonly providerProfilePath: string\n readonly npmSelector: string\n readonly neutralDiscoveryCommand: string\n readonly invocationFailureClassification: {\n readonly sameNameCwdShortCircuit: NpmInvocationFailureClassification\n }\n }\n readonly packageLocator: {\n readonly packageName: string\n readonly packageVersion: string\n readonly binName: 'effect-harness'\n readonly binPath: string\n readonly discoveryCommand: string\n readonly packageFiles: ReadonlyArray<string>\n }\n readonly provider: {\n readonly id: string\n readonly contractVersion: string\n readonly providerVersion: string\n readonly defaultProfile: string\n }\n readonly selectedProfile: string\n readonly discovery: {\n readonly mode: 'provider-discovery'\n readonly consumer: 'prelude'\n readonly profileSource: 'provider/effect-harness.provider.json'\n readonly targetLifecycleOwner: string\n }\n readonly deliveryModes: {\n readonly internalHarness: JsonRecord\n readonly providerArtifactReference: JsonRecord\n readonly exportedHarness: JsonRecord\n }\n readonly semanticContributions: SemanticContributions\n readonly targetManagedSurfaces: {\n readonly targetReceives: ReadonlyArray<string>\n readonly targetDoesNotReceive: ReadonlyArray<string>\n readonly documentationBundle: ManagedFilesContribution\n readonly snippets: ManagedFilesContribution\n readonly contributions: SemanticContributions\n }\n readonly artifactOnlyReferences: {\n readonly mode: string\n readonly targetDelivery: string\n readonly packageSurface: ReadonlyArray<string>\n readonly references: JsonRecord\n }\n readonly artifactOnlyReferenceAudit: ArtifactOnlyReferenceAudit\n readonly sourceIdentities: {\n readonly defaultSourceEntry: string\n readonly sourceEntries: ReadonlyArray<string>\n readonly sourceBoundary: {\n readonly providerRepoInternal: boolean\n readonly targetDelivery: string\n readonly targetMustNotReceive: ReadonlyArray<string>\n readonly allowedTargetSourceIdentity: ReadonlyArray<string>\n }\n readonly providerSourceEntries: JsonRecord\n readonly artifactReferences: JsonRecord\n }\n readonly internalHarnessSurfaces: JsonRecord\n}\n\nexport function resolvePackageArtifactRoot(entrypoint: string): string {\n for (const marker of ['/dist/bin/', '/dist/src/', '/bin/', '/src/']) {\n const index = entrypoint.indexOf(marker)\n if (index >= 0) {\n return entrypoint.slice(0, index)\n }\n }\n return entrypoint\n}\n\nexport function classifyProviderDiscoveryFailure(input: ProviderDiscoveryFailureInput): ProviderDiscoveryFailure {\n const sameRequestedPackage = input.cwdPackageName === input.requestedPackageName\n && input.cwdPackageVersion === input.requestedPackageVersion\n const commandNotFound = /(?:^|\\n)(?:sh: )?effect-harness: command not found(?:\\n|$)/u.test(input.stderr)\n\n if (sameRequestedPackage && commandNotFound) {\n return {\n classification: 'npm-invocation-failure',\n code: 'npm-same-name-cwd-short-circuit',\n providerDiscoveryStarted: false,\n }\n }\n\n if (commandNotFound || input.stderr.includes('Cannot find package') || input.stderr.includes('npm ERR!')) {\n return {\n classification: 'npm-invocation-failure',\n code: 'npm-command-failed',\n providerDiscoveryStarted: false,\n }\n }\n\n return {\n classification: 'provider-discovery-failure',\n code: 'provider-discovery-error',\n providerDiscoveryStarted: true,\n }\n}\n\nfunction decodeJsonRecord(value: unknown, source: string): Effect.Effect<JsonRecord, HarnessError> {\n return isRecord(value)\n ? Effect.succeed(value)\n : Effect.fail(new HarnessError({ message: `${source} must be a JSON object` }))\n}\n\nfunction expectRecord(value: unknown, source: string): Effect.Effect<JsonRecord, HarnessError> {\n return isRecord(value)\n ? Effect.succeed(value)\n : Effect.fail(new HarnessError({ message: `${source} must be a JSON object` }))\n}\n\nfunction expectString(value: unknown, source: string): Effect.Effect<string, HarnessError> {\n return typeof value === 'string'\n ? Effect.succeed(value)\n : Effect.fail(new HarnessError({ message: `${source} must be a string` }))\n}\n\nfunction optionalString(value: unknown, fallback: string): string {\n return typeof value === 'string' ? value : fallback\n}\n\nfunction expectBoolean(value: unknown, source: string): Effect.Effect<boolean, HarnessError> {\n return typeof value === 'boolean'\n ? Effect.succeed(value)\n : Effect.fail(new HarnessError({ message: `${source} must be a boolean` }))\n}\n\nfunction expectArray(value: unknown, source: string): Effect.Effect<ReadonlyArray<unknown>, HarnessError> {\n return Array.isArray(value)\n ? Effect.succeed(value)\n : Effect.fail(new HarnessError({ message: `${source} must be an array` }))\n}\n\nconst expectStringArray = Effect.fnUntraced(function* (value: unknown, source: string) {\n const array = yield* expectArray(value, source)\n return yield* Effect.forEach(array, (entry, index) => expectString(entry, `${source}[${index}]`))\n})\n\nconst expectManagedFileDeclaration = Effect.fnUntraced(function* (value: unknown, source: string, artifactRoot: string) {\n const file = yield* expectRecord(value, source)\n const path = yield* Path.Path\n const fs = yield* FileSystem.FileSystem\n const sourcePath = yield* expectString(file.sourcePath, `${source}.sourcePath`)\n const targetUsage = file.targetUsage === undefined\n ? undefined\n : yield* expectString(file.targetUsage, `${source}.targetUsage`)\n\n return {\n id: yield* expectString(file.id, `${source}.id`),\n sourcePath,\n targetPath: yield* expectString(file.targetPath, `${source}.targetPath`),\n contentType: yield* expectString(file.contentType, `${source}.contentType`),\n managed: yield* expectBoolean(file.managed, `${source}.managed`),\n content: yield* fs.readFileString(path.join(artifactRoot, sourcePath)),\n ...(targetUsage === undefined ? {} : { targetUsage }),\n } satisfies ManagedFileDeclaration\n})\n\nconst expectManagedFilesContribution = Effect.fnUntraced(function* (value: unknown, source: string, artifactRoot: string) {\n const contribution = yield* expectRecord(value, source)\n const files = yield* expectArray(contribution.files, `${source}.files`)\n return {\n mode: yield* expectString(contribution.mode, `${source}.mode`),\n targetBasePath: yield* expectString(contribution.targetBasePath, `${source}.targetBasePath`),\n files: yield* Effect.forEach(files, (file, index) => expectManagedFileDeclaration(file, `${source}.files[${index}]`, artifactRoot)),\n } satisfies ManagedFilesContribution\n})\n\nfunction expectNamedRecord(record: JsonRecord, field: string, source: string): Effect.Effect<JsonRecord, HarnessError> {\n return expectRecord(record[field], `${source}.${field}`)\n}\n\nconst expectDeliveryModes = Effect.fnUntraced(function* (providerProfile: JsonRecord) {\n const deliveryModes = yield* expectNamedRecord(providerProfile, 'deliveryModes', 'provider profile')\n return {\n internalHarness: yield* expectNamedRecord(deliveryModes, 'internalHarness', 'provider profile.deliveryModes'),\n providerArtifactReference: yield* expectNamedRecord(deliveryModes, 'providerArtifactReference', 'provider profile.deliveryModes'),\n exportedHarness: yield* expectNamedRecord(deliveryModes, 'exportedHarness', 'provider profile.deliveryModes'),\n }\n})\n\nconst expectArtifactReferences = Effect.fnUntraced(function* (providerProfile: JsonRecord) {\n const artifactReferences = yield* expectNamedRecord(providerProfile, 'artifactReferences', 'provider profile')\n const references = yield* expectNamedRecord(artifactReferences, 'references', 'provider profile.artifactReferences')\n return {\n mode: yield* expectString(artifactReferences.mode, 'provider profile.artifactReferences.mode'),\n targetDelivery: yield* expectString(artifactReferences.targetDelivery, 'provider profile.artifactReferences.targetDelivery'),\n packageSurface: yield* expectStringArray(artifactReferences.packageSurface, 'provider profile.artifactReferences.packageSurface'),\n references,\n }\n})\n\nconst expectArtifactOnlyReferenceAudit = Effect.fnUntraced(function* (references: JsonRecord, artifactRoot: string) {\n const fs = yield* FileSystem.FileSystem\n const path = yield* Path.Path\n const entries = yield* Effect.forEach(Object.entries(references), ([id, value]) => Effect.gen(function* () {\n const reference = yield* expectRecord(value, `provider profile.artifactReferences.references.${id}`)\n const referencePath = yield* expectString(reference.path, `provider profile.artifactReferences.references.${id}.path`)\n const absolutePath = path.join(artifactRoot, referencePath)\n const available = yield* fs.exists(absolutePath)\n if (!available) {\n return yield* new HarnessError({ message: `artifact-only reference ${id} is missing from package artifact at ${referencePath}` })\n }\n return {\n available: true,\n id,\n path: referencePath,\n sourceEntry: yield* expectString(reference.sourceEntry, `provider profile.artifactReferences.references.${id}.sourceEntry`),\n targetDelivery: yield* expectString(reference.targetDelivery, `provider profile.artifactReferences.references.${id}.targetDelivery`),\n } satisfies ArtifactOnlyReferenceAuditEntry\n }))\n\n return {\n mode: 'artifact-only-reference-audit',\n references: entries,\n } satisfies ArtifactOnlyReferenceAudit\n})\n\nexport const discoverProvider = Effect.fnUntraced(function* (harness: string) {\n const path = yield* Path.Path\n const artifactRoot = path.resolve(harness)\n const providerProfileRelativePath = 'provider/effect-harness.provider.json'\n const providerProfilePath = path.join(artifactRoot, providerProfileRelativePath)\n const packageJsonPath = path.join(artifactRoot, 'package.json')\n\n const providerProfile = yield* readJson(providerProfilePath, decodeJsonRecord)\n const packageManifest = yield* readJson(packageJsonPath, decodeJsonRecord)\n const provider = yield* expectNamedRecord(providerProfile, 'provider', 'provider profile')\n const profiles = yield* expectNamedRecord(providerProfile, 'profiles', 'provider profile')\n const defaultProfile = yield* expectString(provider.defaultProfile, 'provider profile.provider.defaultProfile')\n const selectedProfile = yield* expectNamedRecord(profiles, defaultProfile, `provider profile.profiles.${defaultProfile}`)\n const contributions = yield* expectNamedRecord(selectedProfile, 'contributions', `provider profile.profiles.${defaultProfile}`)\n const managedSurfaces = yield* expectNamedRecord(selectedProfile, 'managedSurfaces', `provider profile.profiles.${defaultProfile}`)\n const sourceBoundary = yield* expectNamedRecord(selectedProfile, 'sourceBoundary', `provider profile.profiles.${defaultProfile}`)\n const selfConformance = yield* expectNamedRecord(providerProfile, 'selfConformance', 'provider profile')\n const packageBin = yield* expectNamedRecord(packageManifest, 'bin', 'package.json')\n const artifactOnlyReferences = yield* expectArtifactReferences(providerProfile)\n const deliveryModes = yield* expectDeliveryModes(providerProfile)\n const packageName = yield* expectString(packageManifest.name, 'package.json.name')\n const packageVersion = yield* expectString(packageManifest.version, 'package.json.version')\n const packageManager = optionalString(packageManifest.packageManager, 'unknown')\n const npmSelector = `${packageName}@${packageVersion}`\n const semanticContributions = {\n packageJson: yield* expectNamedRecord(contributions, 'packageJson', `provider profile.profiles.${defaultProfile}.contributions`),\n tsconfig: yield* expectNamedRecord(contributions, 'tsconfig', `provider profile.profiles.${defaultProfile}.contributions`),\n editorPolicy: yield* expectNamedRecord(contributions, 'editorPolicy', `provider profile.profiles.${defaultProfile}.contributions`),\n lintGuardrails: yield* expectNamedRecord(contributions, 'lintGuardrails', `provider profile.profiles.${defaultProfile}.contributions`),\n testPolicy: yield* expectNamedRecord(contributions, 'testPolicy', `provider profile.profiles.${defaultProfile}.contributions`),\n verificationPolicy: yield* expectNamedRecord(contributions, 'verificationPolicy', `provider profile.profiles.${defaultProfile}.contributions`),\n } satisfies SemanticContributions\n\n return {\n schemaVersion: 1,\n artifactRoot,\n providerProfilePath,\n providerProfileRelativePath,\n packageArtifactIdentity: {\n packageName,\n packageVersion,\n packageManager,\n artifactRoot,\n packageJsonPath,\n providerProfilePath,\n npmSelector,\n neutralDiscoveryCommand: `npx --yes --package ${npmSelector} effect-harness provider-discover`,\n invocationFailureClassification: {\n sameNameCwdShortCircuit: {\n classification: 'npm-invocation-failure',\n code: 'npm-same-name-cwd-short-circuit',\n providerDiscoveryStarted: false,\n },\n },\n },\n packageLocator: {\n packageName,\n packageVersion,\n binName: 'effect-harness',\n binPath: yield* expectString(packageBin['effect-harness'], 'package.json.bin.effect-harness'),\n discoveryCommand: 'npx --yes @sayoriqwq/effect-harness provider-discover',\n packageFiles: yield* expectStringArray(packageManifest.files, 'package.json.files'),\n },\n provider: {\n id: yield* expectString(provider.id, 'provider profile.provider.id'),\n contractVersion: yield* expectString(provider.contractVersion, 'provider profile.provider.contractVersion'),\n providerVersion: yield* expectString(provider.providerVersion, 'provider profile.provider.providerVersion'),\n defaultProfile,\n },\n selectedProfile: defaultProfile,\n discovery: {\n mode: 'provider-discovery',\n consumer: 'prelude',\n profileSource: providerProfileRelativePath,\n targetLifecycleOwner: yield* expectString(selfConformance.lifecycleOwner, 'provider profile.selfConformance.lifecycleOwner'),\n },\n deliveryModes,\n semanticContributions,\n targetManagedSurfaces: {\n targetReceives: yield* expectStringArray(managedSurfaces.targetReceives, `provider profile.profiles.${defaultProfile}.managedSurfaces.targetReceives`),\n targetDoesNotReceive: yield* expectStringArray(managedSurfaces.targetDoesNotReceive, `provider profile.profiles.${defaultProfile}.managedSurfaces.targetDoesNotReceive`),\n documentationBundle: yield* expectManagedFilesContribution(contributions.documentationBundle, `provider profile.profiles.${defaultProfile}.contributions.documentationBundle`, artifactRoot),\n snippets: yield* expectManagedFilesContribution(contributions.snippets, `provider profile.profiles.${defaultProfile}.contributions.snippets`, artifactRoot),\n contributions: semanticContributions,\n },\n artifactOnlyReferences,\n artifactOnlyReferenceAudit: yield* expectArtifactOnlyReferenceAudit(artifactOnlyReferences.references, artifactRoot),\n sourceIdentities: {\n defaultSourceEntry: yield* expectString(selectedProfile.sourceEntry, `provider profile.profiles.${defaultProfile}.sourceEntry`),\n sourceEntries: yield* expectStringArray(selectedProfile.sourceEntries, `provider profile.profiles.${defaultProfile}.sourceEntries`),\n sourceBoundary: {\n providerRepoInternal: yield* expectBoolean(sourceBoundary.providerRepoInternal, `provider profile.profiles.${defaultProfile}.sourceBoundary.providerRepoInternal`),\n targetDelivery: yield* expectString(sourceBoundary.targetDelivery, `provider profile.profiles.${defaultProfile}.sourceBoundary.targetDelivery`),\n targetMustNotReceive: yield* expectStringArray(sourceBoundary.targetMustNotReceive, `provider profile.profiles.${defaultProfile}.sourceBoundary.targetMustNotReceive`),\n allowedTargetSourceIdentity: yield* expectStringArray(sourceBoundary.allowedTargetSourceIdentity, `provider profile.profiles.${defaultProfile}.sourceBoundary.allowedTargetSourceIdentity`),\n },\n providerSourceEntries: yield* expectNamedRecord(providerProfile, 'sourceEntries', 'provider profile'),\n artifactReferences: artifactOnlyReferences.references,\n },\n internalHarnessSurfaces: deliveryModes.internalHarness,\n } satisfies ProviderDiscovery\n})\n"]}
|