@intentic/constants 1.224.0 → 1.226.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/README.md +9 -9
- package/package.json +2 -2
- package/src/node.mjs +6 -6
package/README.md
CHANGED
|
@@ -9,17 +9,17 @@ The ports, paths and image references the daemon, the CLIs and the desktop app a
|
|
|
9
9
|
|
|
10
10
|
## Key files
|
|
11
11
|
|
|
12
|
-
- [src/index.ts](src/index.ts)
|
|
12
|
+
- [src/index.ts](src/index.ts), the constants themselves: ports, the fixed directory layouts, legal and origin
|
|
13
13
|
values. Isomorphic, imported by browser code, so nothing here may touch `node:fs`.
|
|
14
|
-
- [src/node.mjs](src/node.mjs)
|
|
14
|
+
- [src/node.mjs](src/node.mjs): `repoRoot()` and `packageRoot()`, behind the `@intentic/constants/node`
|
|
15
15
|
subpath. Node-only, and hand-written JavaScript rather than compiled TypeScript.
|
|
16
16
|
|
|
17
17
|
## How it fits
|
|
18
18
|
|
|
19
19
|
The bottom of the dependency graph: it imports nothing and almost everything imports it. A port number that lives
|
|
20
20
|
in two files is a port number that will eventually be two different numbers, which is the entire argument for
|
|
21
|
-
this package existing. The same argument covers the directory layouts
|
|
22
|
-
`/opt/intentic
|
|
21
|
+
this package existing. The same argument covers the directory layouts: `/work`, `/history`, `.intentic`,
|
|
22
|
+
`/opt/intentic`: which were previously typed out by hand across dozens of files with nothing linking the copies.
|
|
23
23
|
|
|
24
24
|
The two root-finders answer the other half of that problem. Code used to locate the repo root by counting how
|
|
25
25
|
deep it sat (`../..`, `../../..`, `../../../..`), a number correct only for the file's current depth and checked
|
|
@@ -30,22 +30,22 @@ by nothing. Walking up to a marker has no such coupling, so a file can move anyw
|
|
|
30
30
|
- If a constant is used by exactly one package, it belongs in that package. This is for the ones that cross a
|
|
31
31
|
boundary.
|
|
32
32
|
- `src/node.mjs` is plain JavaScript with a hand-written `.d.mts` **on purpose**. Its earliest callers run before
|
|
33
|
-
anything is built
|
|
33
|
+
anything is built (the prepass is what performs the build, and the byte and path checks run ahead of it) so a
|
|
34
34
|
helper importable only from `dist/` is one they cannot import at all, which is how a second copy of the walk
|
|
35
35
|
gets written. It is also why the root `package.json` depends on this package: without that link, scripts under
|
|
36
36
|
`_tools/scripts/` cannot resolve it by name.
|
|
37
37
|
- **The name only resolves once `pnpm install` has run**, because a bare specifier is looked up through
|
|
38
|
-
`node_modules`. The two callers that run before any install
|
|
39
|
-
hook and the CI `preflight` job invoke on a bare checkout
|
|
38
|
+
`node_modules`. The two callers that run before any install: `prepass.mjs --checks-only`, which the `pre-push`
|
|
39
|
+
hook and the CI `preflight` job invoke on a bare checkout: therefore import `../constants/src/node.mjs` by
|
|
40
40
|
path. Same file, same single copy of the walk, no install required. Everything that runs after the install
|
|
41
41
|
imports it by name.
|
|
42
|
-
- **Extensions cannot import this package
|
|
42
|
+
- **Extensions cannot import this package**: the boundary rule (`.oxlintrc.json`, `_extensions/README.md`) allows
|
|
43
43
|
them only the SDK halves and `@intentic/sandbox-contract`, so an extension can't couple itself to app or engine
|
|
44
44
|
internals. That rule stands; the contract package re-exports the four layout constants so extensions can still
|
|
45
45
|
name a location instead of spelling it. One definition, reached by two paths.
|
|
46
46
|
- `WORKSPACE_ROOT` and `HISTORY_ROOT` are **defaults, not laws**. The daemon takes both as overridable config and
|
|
47
47
|
an isolated turn re-points them, so code holding a `Config` must read the config value. The constants are what
|
|
48
48
|
that config defaults to, and what code with no config in reach can still name correctly.
|
|
49
|
-
- Prefer the daemon's own `statePath()` over joining `STATE_DIR` by hand wherever it is reachable
|
|
49
|
+
- Prefer the daemon's own `statePath()` over joining `STATE_DIR` by hand wherever it is reachable: it is typed
|
|
50
50
|
against the table of state files, so it catches a name the table doesn't declare. `STATE_DIR` is for callers
|
|
51
51
|
outside that table.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intentic/constants",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Shared constants for the intentic packages
|
|
3
|
+
"version": "1.226.0",
|
|
4
|
+
"description": "Shared constants for the intentic packages, ports, paths, and image references the daemon, CLIs and desktop app all agree on",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"repository": {
|
package/src/node.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import { fileURLToPath } from "node:url";
|
|
|
7
7
|
* Two dozen files used to work out where the monorepo root was by counting how deep they sat: `../..` from a
|
|
8
8
|
* package's own directory, `../../..` from its `src/`, `../../../..` from the installer scripts. Every one of
|
|
9
9
|
* those numbers is correct only for the file's CURRENT depth, and nothing anywhere checks it. Move the file
|
|
10
|
-
* one directory and it silently resolves somewhere else
|
|
10
|
+
* one directory and it silently resolves somewhere else: no import fails, no type breaks; you find out when
|
|
11
11
|
* something reads the wrong .env at runtime, or reads nothing and falls back to a default.
|
|
12
12
|
*
|
|
13
13
|
* Walking up until a marker appears has none of that coupling. A file can sit at any depth, move between
|
|
@@ -22,7 +22,7 @@ import { fileURLToPath } from "node:url";
|
|
|
22
22
|
*
|
|
23
23
|
* A caller that runs before `pnpm install` has one more constraint: `@intentic/constants/node` is a BARE
|
|
24
24
|
* specifier and bare specifiers resolve through node_modules, which a bare checkout has none of. Those callers
|
|
25
|
-
*
|
|
25
|
+
* (`prepass.mjs`, run by the pre-push hook and by CI's preflight job) import THIS FILE by relative path
|
|
26
26
|
* instead. Still one walk; only the way in differs.
|
|
27
27
|
*
|
|
28
28
|
* NOT EXPORTED FROM THE PACKAGE INDEX, and that is deliberate: the index is imported by browser code
|
|
@@ -51,7 +51,7 @@ const startDir = (from) => {
|
|
|
51
51
|
};
|
|
52
52
|
|
|
53
53
|
// Walk up from `dir` until `marker` is found beside us, or we run out of parents. Returns "" for not-found so
|
|
54
|
-
// each caller decides whether that is fatal
|
|
54
|
+
// each caller decides whether that is fatal: the installers treat it as "not run from a checkout" and carry
|
|
55
55
|
// on, while everything inside the repo treats it as impossible and throws.
|
|
56
56
|
const walkUp = (dir, marker) => {
|
|
57
57
|
let current = dir;
|
|
@@ -63,7 +63,7 @@ const walkUp = (dir, marker) => {
|
|
|
63
63
|
}
|
|
64
64
|
};
|
|
65
65
|
|
|
66
|
-
/* THE MONOREPO ROOT, from anywhere inside it. Pass `import.meta.url
|
|
66
|
+
/* THE MONOREPO ROOT, from anywhere inside it. Pass `import.meta.url`: the caller's own location is the only
|
|
67
67
|
* thing this needs, and it is the one thing every module already knows about itself.
|
|
68
68
|
*
|
|
69
69
|
* Throws when the marker is nowhere above the caller, which inside this repo means the checkout is broken. The
|
|
@@ -71,11 +71,11 @@ const walkUp = (dir, marker) => {
|
|
|
71
71
|
* wrong directory is how a config loader silently reads no .env and every credential arrives empty. */
|
|
72
72
|
export const repoRoot = (from) => {
|
|
73
73
|
const found = walkUp(startDir(from), REPO_MARKER);
|
|
74
|
-
if (found === "") throw new Error(`repoRoot: no ${REPO_MARKER} above ${startDir(from)}
|
|
74
|
+
if (found === "") throw new Error(`repoRoot: no ${REPO_MARKER} above ${startDir(from)}, is this a complete checkout?`);
|
|
75
75
|
return found;
|
|
76
76
|
};
|
|
77
77
|
|
|
78
|
-
/* THE CALLING PACKAGE'S OWN ROOT
|
|
78
|
+
/* THE CALLING PACKAGE'S OWN ROOT: the directory its package.json sits in. The other thing the dot-counting
|
|
79
79
|
* was reaching for: `createRequire(import.meta.url)("../../package.json")` in three different version.ts files,
|
|
80
80
|
* each with a different number of dots because each sat at a different depth, all of them meaning "mine".
|
|
81
81
|
*
|