@ducking-mind/proxy-app-cli 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ducking-mind/proxy-app-cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "CLI for creating, building and publishing Proxy platform apps",
5
5
  "repository": {
6
6
  "type": "git",
@@ -12,25 +12,42 @@
12
12
  "url": "https://github.com/duckingmind/app/issues"
13
13
  },
14
14
  "type": "module",
15
+ "exports": {
16
+ ".": "./proxy-app.mjs",
17
+ "./agent-contract": "./agent-contract.mjs",
18
+ "./agent-protocol": "./agent-runtime/protocol.mjs",
19
+ "./package-guide": "./agent-runtime/package-guide.mjs",
20
+ "./package.json": "./package.json"
21
+ },
15
22
  "bin": {
16
- "proxy-app": "./proxy-app.mjs"
23
+ "proxy-app": "./proxy-app.mjs",
24
+ "proxy-agent-contract": "./agent-contract.mjs"
17
25
  },
18
26
  "files": [
19
27
  "proxy-app.mjs",
20
- "local-dev-relay.mjs"
28
+ "local-dev-relay.mjs",
29
+ "local-dev-credentials.mjs",
30
+ "artifact-security.mjs",
31
+ "agent-contract.mjs",
32
+ "agent-runtime/*.mjs",
33
+ "release-runtime/*.mjs",
34
+ "prepare-agent-runtime.mjs"
21
35
  ],
22
36
  "scripts": {
23
- "test": "node --check proxy-app.mjs",
24
- "prepublishOnly": "npm test"
37
+ "test": "node --check proxy-app.mjs && node --check agent-contract.mjs && node --test *.test.mjs",
38
+ "prepublishOnly": "npm test",
39
+ "prepack": "node prepare-agent-runtime.mjs",
40
+ "pretest": "npm --prefix ../proxy-app-sdk run build"
25
41
  },
26
42
  "publishConfig": {
27
43
  "access": "public"
28
44
  },
29
45
  "dependencies": {
46
+ "@ducking-mind/proxy-app-desktop-runtime": "^0.1.0",
30
47
  "fflate": "^0.8.2"
31
48
  },
32
49
  "engines": {
33
- "node": ">=22.12"
50
+ "node": ">=22.18"
34
51
  },
35
52
  "license": "MIT"
36
53
  }
@@ -0,0 +1,43 @@
1
+ import { copyFile, mkdir, readFile, readdir, rm, stat, writeFile } from 'node:fs/promises'
2
+
3
+ const source = new URL('../desktop/agent/', import.meta.url)
4
+ const destination = new URL('./agent-runtime/', import.meta.url)
5
+ const modules = new Set()
6
+ async function collect(name) {
7
+ if (modules.has(name)) return
8
+ if (!/^[a-z][a-z0-9-]*\.mjs$/.test(name)) throw new Error(`Invalid agent runtime module: ${name}`)
9
+ modules.add(name)
10
+ const content = await readFile(new URL(name, source), 'utf8')
11
+ for (const match of content.matchAll(/(?:from\s*|import\s*)['"]\.\/([^'"]+)['"]/g)) await collect(match[1])
12
+ await writeFile(new URL(name, destination), content)
13
+ }
14
+
15
+ // Include the transitive local imports, never the Electron entry points.
16
+ // Repacking an installed npm package reuses its already bundled runtime.
17
+ const hasSource = await stat(source).then(() => true).catch(error => { if (error.code !== 'ENOENT') throw error; return false })
18
+ if (hasSource) {
19
+ await mkdir(destination, { recursive: true })
20
+ await collect('protocol.mjs')
21
+ await collect('package-guide.mjs')
22
+ for (const entry of await readdir(destination)) if (!modules.has(entry)) await rm(new URL(entry, destination), { recursive: true, force: true })
23
+ } else {
24
+ await import(new URL('package-guide.mjs', destination))
25
+ }
26
+ // The package contract resolver uses this same bundled validation, including
27
+ // when it is run as a project's direct build helper.
28
+ await import(new URL('./agent-contract.mjs', import.meta.url))
29
+
30
+ // The standalone CLI also exposes Electron release helpers. Keep a small copy
31
+ // in the npm package so an installed CLI does not depend on the monorepo's
32
+ // app/desktop directory. Source checkouts still use the live modules below.
33
+ const releaseSource = new URL('../desktop/scripts/', import.meta.url)
34
+ const releaseDestination = new URL('./release-runtime/', import.meta.url)
35
+ const releaseModules = ['release-config.mjs', 'release-target.mjs']
36
+ const hasReleaseSource = await stat(new URL(releaseModules[0], releaseSource)).then(() => true).catch(error => {
37
+ if (error.code !== 'ENOENT') throw error
38
+ return false
39
+ })
40
+ if (hasReleaseSource) {
41
+ await mkdir(releaseDestination, { recursive: true })
42
+ for (const name of releaseModules) await copyFile(new URL(name, releaseSource), new URL(name, releaseDestination))
43
+ }