@farmslot/adapter-sdk 0.7.1 → 0.8.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/CHANGELOG.md CHANGED
@@ -6,6 +6,16 @@ All notable changes to `@farmslot/adapter-sdk` are tracked here.
6
6
 
7
7
  - Active-development baseline; add user-facing changes here before release or package publication.
8
8
 
9
+ ## 0.8.0 - 2026-10-09
10
+
11
+ - Add `adapterDetectFromSpec(spec)` and `AdapterDetectSpec`: the `AdapterDetect` predicates a recipe library's `detect` declaration describes. `remote` matches when the origin URL contains any entry; `files` matches when every path exists (a trailing `/` requires a directory) and package.json lists every `packageDependencies` entry. A path (package.json included) counts only when its real path stays inside the checkout, so a symlink out of it matches nothing.
12
+ - `PlatformAdapter.detect` documents the host rule recipe-cli now applies: any remote match beats any file match, an adapter beats one it extends, and more than one match left is ambiguous (it was registration order).
13
+ - Publish with protocol 0.35.0 and recipe-runner 0.28.0.
14
+
15
+ ## 0.7.2 - 2026-10-09
16
+
17
+ - Publish with protocol 0.34.0 and recipe-runner 0.27.1 so consumers share one recipe-runner copy. No code change.
18
+
9
19
  ## 0.7.1 - 2026-10-08
10
20
 
11
21
  - Publish with protocol 0.34.0 and recipe-runner 0.27.0 so consumers share one recipe-runner copy. No code change.
@@ -0,0 +1,14 @@
1
+ import type { RecipeLibraryAdapterDetect } from '@farmslot/recipe-runner';
2
+ import type { AdapterDetect } from './types.js';
3
+ /** `detect` in a recipe-library.json `adapters` entry. */
4
+ export type AdapterDetectSpec = Readonly<RecipeLibraryAdapterDetect>;
5
+ /**
6
+ * The predicates a spec describes. `remote` matches when the origin URL contains
7
+ * any entry. `files` matches when every path exists (a trailing `/` requires a
8
+ * directory) and package.json lists every `packageDependencies` entry in
9
+ * dependencies or devDependencies. A path counts only when its real path stays
10
+ * inside the checkout, so a symlink out of it matches nothing. A predicate with
11
+ * no entries is left out.
12
+ */
13
+ export declare function adapterDetectFromSpec(spec: AdapterDetectSpec): AdapterDetect;
14
+ //# sourceMappingURL=detect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detect.d.ts","sourceRoot":"","sources":["../src/detect.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAE1E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,0DAA0D;AAC1D,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC,0BAA0B,CAAC,CAAC;AAErE;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,iBAAiB,GAAG,aAAa,CAe5E"}
package/dist/detect.js ADDED
@@ -0,0 +1,74 @@
1
+ // AdapterDetect from data: the predicates a recipe library declares for its
2
+ // adapter plugin in recipe-library.json, which a host matches before it loads
3
+ // the plugin. A built-in adapter may use it too.
4
+ import fs from 'node:fs';
5
+ import path from 'node:path';
6
+ /**
7
+ * The predicates a spec describes. `remote` matches when the origin URL contains
8
+ * any entry. `files` matches when every path exists (a trailing `/` requires a
9
+ * directory) and package.json lists every `packageDependencies` entry in
10
+ * dependencies or devDependencies. A path counts only when its real path stays
11
+ * inside the checkout, so a symlink out of it matches nothing. A predicate with
12
+ * no entries is left out.
13
+ */
14
+ export function adapterDetectFromSpec(spec) {
15
+ const remotes = spec.remote ?? [];
16
+ const files = spec.files ?? [];
17
+ const dependencies = spec.packageDependencies ?? [];
18
+ const detect = {};
19
+ if (remotes.length > 0)
20
+ detect.remote = (url) => remotes.some((entry) => url.includes(entry));
21
+ if (files.length > 0 || dependencies.length > 0) {
22
+ detect.files = (target) => {
23
+ if (!files.every((file) => exists(target, file)))
24
+ return false;
25
+ if (dependencies.length === 0)
26
+ return true;
27
+ const listed = packageDependencies(target);
28
+ return dependencies.every((name) => listed.has(name));
29
+ };
30
+ }
31
+ return detect;
32
+ }
33
+ // The real path of `file` in the checkout, or undefined when it is missing or
34
+ // resolves outside the checkout.
35
+ function inCheckout(target, file) {
36
+ try {
37
+ const root = fs.realpathSync(target);
38
+ const real = fs.realpathSync(path.join(target, file));
39
+ const relative = path.relative(root, real);
40
+ const outside = relative === '..' || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative);
41
+ return outside ? undefined : real;
42
+ }
43
+ catch {
44
+ // Missing, or unreadable: the checkout does not have it.
45
+ return undefined;
46
+ }
47
+ }
48
+ function exists(target, file) {
49
+ const real = inCheckout(target, file);
50
+ if (real === undefined)
51
+ return false;
52
+ try {
53
+ return !file.endsWith('/') || fs.statSync(real).isDirectory();
54
+ }
55
+ catch {
56
+ // Removed since: the checkout does not have it.
57
+ return false;
58
+ }
59
+ }
60
+ function packageDependencies(target) {
61
+ const manifest = inCheckout(target, 'package.json');
62
+ if (manifest === undefined)
63
+ return new Set();
64
+ try {
65
+ const pkg = JSON.parse(fs.readFileSync(manifest, 'utf8'));
66
+ const names = (value) => value !== null && typeof value === 'object' ? Object.keys(value) : [];
67
+ return new Set([...names(pkg.dependencies), ...names(pkg.devDependencies)]);
68
+ }
69
+ catch {
70
+ // No package.json, or one that does not parse: no dependencies.
71
+ return new Set();
72
+ }
73
+ }
74
+ //# sourceMappingURL=detect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detect.js","sourceRoot":"","sources":["../src/detect.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,8EAA8E;AAC9E,iDAAiD;AACjD,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAS7B;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAuB;IAC3D,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC;IAClC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;IAC/B,MAAM,YAAY,GAAG,IAAI,CAAC,mBAAmB,IAAI,EAAE,CAAC;IACpD,MAAM,MAAM,GAAkB,EAAE,CAAC;IACjC,IAAI,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,CAAC;IAC9E,CAAC;IAAC,MAAM,CAAC;QACP,gEAAgE;QAChE,OAAO,IAAI,GAAG,EAAE,CAAC;IACnB,CAAC;AACH,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export { adapterDetectFromSpec, type AdapterDetectSpec } from './detect.js';
1
2
  export { type AdapterRegistry, createAdapterRegistry, defineAdapter } from './registry.js';
2
3
  export { ADAPTER_SDK_VERSION, type AdapterActions, type AdapterBrowser, type AdapterCdpTarget, type AdapterConsoleFiles, type AdapterDependencyBlock, type AdapterDetect, type AdapterDevice, type AdapterDeviceLiveView, type AdapterDevices, type AdapterDeviceView, type AdapterDevServer, type AdapterDevServerStop, type AdapterDiagnostics, type AdapterDoctorCheck, type AdapterFailurePatterns, type AdapterFlags, type AdapterHarness, type AdapterHarnessLeaf, type AdapterHarnessVerify, type AdapterHints, type AdapterLaunchContext, type AdapterLogFinding, type AdapterLogSource, type AdapterObservation, type AdapterPaint, type AdapterPinnedFlags, type AdapterPrepare, type AdapterReadiness, type AdapterRecording, type AdapterRun, type AdapterRunPrepareContext, type AdapterRuntimeContextSpec, type AdapterRuntimeStatus, type AdapterSdkVersion, type AdapterUiHarness, type AdapterUiTransport, type CommandEventStream, type CommandOptions, type HealBoundViolation, type HealMutation, type HealPolicy, type HealState, type NativeUiTransport, type NativeUiTransportOptions, type NetworkCaptureBackend, noopStage, type PlatformAdapter, type RecipeNodeEvent, type RecipeRunOptions, type RunObserver, type StageHandle, type StageProgress, } from './types.js';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC3F,OAAO,EACL,mBAAmB,EACnB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,E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,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,qBAAqB,EAC1B,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,YAAY,EACjB,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,UAAU,EACf,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC9B,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC7B,KAAK,qBAAqB,EAC1B,SAAS,EACT,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,aAAa,GACnB,MAAM,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ export { adapterDetectFromSpec } from './detect.js';
1
2
  export { createAdapterRegistry, defineAdapter } from './registry.js';
2
3
  export { ADAPTER_SDK_VERSION, noopStage, } from './types.js';
3
4
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,qBAAqB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC3F,OAAO,EACL,mBAAmB,EA8CnB,SAAS,GAOV,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAA0B,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAwB,qBAAqB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC3F,OAAO,EACL,mBAAmB,EA8CnB,SAAS,GAOV,MAAM,YAAY,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farmslot/adapter-sdk",
3
- "version": "0.7.1",
3
+ "version": "0.8.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -24,8 +24,8 @@
24
24
  "prepublishOnly": "node ../../scripts/quality/check-farmslot-package-readiness.mjs --publish --packages @farmslot/adapter-sdk"
25
25
  },
26
26
  "dependencies": {
27
- "@farmslot/protocol": "0.34.0",
28
- "@farmslot/recipe-runner": "0.27.0"
27
+ "@farmslot/protocol": "0.35.0",
28
+ "@farmslot/recipe-runner": "0.28.0"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/node": "^22.0.0",