@netsirk/hippocampe 0.11.0 → 0.12.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.
Files changed (2) hide show
  1. package/bin/hippo.js +22 -10
  2. package/package.json +2 -2
package/bin/hippo.js CHANGED
@@ -3,17 +3,20 @@
3
3
  // the platform carries both, as esbuild carries its own.
4
4
  'use strict'
5
5
  const { spawnSync } = require('node:child_process')
6
+ const { existsSync } = require('node:fs')
6
7
  const { dirname, join } = require('node:path')
7
8
 
8
9
  const platform = `${process.platform}-${process.arch}`
9
- /** The folder of an installed package, looked for from `from` (this package by default). */
10
- const found = (name, from) => {
11
- try {
12
- return dirname(
13
- require.resolve(`${name}/package.json`, from === undefined ? {} : { paths: [from] }),
14
- )
15
- } catch {
16
- return undefined
10
+ /**
11
+ * The folder of an installed package, looked for in the `node_modules` of `from` (this launcher
12
+ * by default) and of each folder above it. Not through `require.resolve`: a package that declares
13
+ * `exports`, as the PostgreSQL one does, refuses its own `package.json`.
14
+ */
15
+ const found = (name, from = __dirname) => {
16
+ for (let folder = from; ; folder = dirname(folder)) {
17
+ const candidate = join(folder, 'node_modules', name)
18
+ if (existsSync(join(candidate, 'package.json'))) return candidate
19
+ if (dirname(folder) === folder) return undefined
17
20
  }
18
21
  }
19
22
  const own = found(`@netsirk/hippocampe-${platform}`)
@@ -23,8 +26,17 @@ if (own === undefined) {
23
26
  }
24
27
  // A dependency of the package of the platform: looked for from there.
25
28
  const postgres = found(`@embedded-postgres/${platform}`, own)
29
+ if (postgres === undefined) {
30
+ console.error(
31
+ `Hippocampe cannot find its PostgreSQL, the package @embedded-postgres/${platform}.`,
32
+ )
33
+ process.exit(1)
34
+ }
26
35
  const executable = join(own, 'bin', 'hippo')
27
- const env = { ...process.env, HIPPOCAMPE_EXECUTABLE: executable }
28
- if (postgres !== undefined) env.HIPPOCAMPE_POSTGRES_BINARIES = join(postgres, 'native')
36
+ const env = {
37
+ ...process.env,
38
+ HIPPOCAMPE_EXECUTABLE: executable,
39
+ HIPPOCAMPE_POSTGRES_BINARIES: join(postgres, 'native'),
40
+ }
29
41
  const ran = spawnSync(executable, process.argv.slice(2), { stdio: 'inherit', env })
30
42
  process.exit(ran.status ?? 1)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netsirk/hippocampe",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "description": "Hippocampe, a personal knowledge system kept by AI agents: the server, its MCP tools and its command line.",
5
5
  "license": "AGPL-3.0-only",
6
6
  "repository": "github:KristenJestin/hippocampe",
@@ -11,7 +11,7 @@
11
11
  "bin"
12
12
  ],
13
13
  "optionalDependencies": {
14
- "@netsirk/hippocampe-linux-x64": "0.11.0"
14
+ "@netsirk/hippocampe-linux-x64": "0.12.0"
15
15
  },
16
16
  "engines": {
17
17
  "node": ">=20"