@decohere/flux 0.0.1-dev.20261201.423 → 0.0.1-dev.20261201.426

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 CHANGED
@@ -167,7 +167,7 @@ Flux clears its reference to the object *before* calling dispose, so a failed bo
167
167
 
168
168
  ## Directory slice (`flux serve <token>…`)
169
169
 
170
- A slice is a path token. Flux keeps workspace packages whose directory sits under that token, then [classifies](#classification-convention) each one. `flux serve shop` and `flux serve projects/shop` are the same token.
170
+ A slice is a path token. Flux keeps workspace packages whose directory sits under that token, then [classifies](#classification-convention) each one. A token can be an explicit workspace-relative path (`projects/shop`, `src/ledger/shop`) or a bare module name (`shop`), which resolves under the workspace's `includeProjects` roots from `.decohere.js` (default `projects/`). `flux serve shop` and `flux serve projects/shop` are the same token in the default layout.
171
171
 
172
172
  Example workspace (every leaf directory here has its own `package.json`):
173
173
 
@@ -43,7 +43,7 @@ export class ServeAction {
43
43
  }
44
44
  async runSlices(options, slices) {
45
45
  const views = await this.toSliceViews(options.configuration);
46
- const classified = classifySliceProjects(views, slices);
46
+ const classified = classifySliceProjects(views, slices, this.workspace.projectRoots);
47
47
  const label = slices.join(" ");
48
48
  for (const skipped of classified.skip){
49
49
  this.logger.info(`skipped ${skipped.projectDirectory} — library (no Flux entry / scripts)`);
@@ -6,18 +6,24 @@
6
6
  "dev",
7
7
  "serve"
8
8
  ];
9
- /**
10
- * Normalize a CLI slice token to a `projects/…` prefix without a trailing slash.
11
- * `funding` and `projects/funding` both become `projects/funding`.
12
- */ export function normalizeSlicePrefix(slice) {
13
- const trimmed = slice.replaceAll("\\", "/").replace(/\/+$/, "");
9
+ function cleanSliceToken(slice) {
10
+ const trimmed = slice.replaceAll("\\", "/").replace(/^(?:\.\/)+/, "").replace(/\/+$/, "");
14
11
  if (trimmed === "" || trimmed === ".") {
15
12
  throw new Error("Slice directory must be a non-empty path");
16
13
  }
17
- if (trimmed === "projects" || trimmed.startsWith("projects/")) {
14
+ return trimmed;
15
+ }
16
+ /**
17
+ * Normalize a CLI slice token under `projectRoot` (default `"projects"`) without a trailing slash.
18
+ * `funding` and `projects/funding` both become `projects/funding`; with `projectRoot = "src/ledger"`,
19
+ * `funding` and `src/ledger/funding` both become `src/ledger/funding`.
20
+ */ export function normalizeSlicePrefix(slice, projectRoot = "projects") {
21
+ const trimmed = cleanSliceToken(slice);
22
+ const root = projectRoot.replaceAll("\\", "/").replace(/^(?:\.\/)+/, "").replace(/\/+$/, "");
23
+ if (root === "" || trimmed === root || trimmed.startsWith(`${root}/`)) {
18
24
  return trimmed;
19
25
  }
20
- return `projects/${trimmed}`;
26
+ return `${root}/${trimmed}`;
21
27
  }
22
28
  /**
23
29
  * True when `projectDirectory` belongs to the slice token.
@@ -33,17 +39,32 @@
33
39
  if (dir === prefix || dir.startsWith(`${prefix}/`)) {
34
40
  return true;
35
41
  }
36
- // Flat monorepo packages: projects/<module>.<role>
42
+ // Flat monorepo packages: <root>/<module>.<role>
37
43
  return dir.startsWith(`${prefix}.`);
38
44
  }
39
- export function projectsInSlice(projects, slice) {
40
- const prefix = normalizeSlicePrefix(slice);
41
- return projects.filter((p)=>isUnderSlice(p.projectDirectory, prefix));
45
+ export function projectsInSlice(projects, slice, projectRoots = [
46
+ "projects"
47
+ ]) {
48
+ const trimmed = cleanSliceToken(slice);
49
+ const prefixes = new Set([
50
+ trimmed,
51
+ ...projectRoots.map((root)=>normalizeSlicePrefix(trimmed, root))
52
+ ]);
53
+ return projects.filter((p)=>{
54
+ for (const prefix of prefixes){
55
+ if (isUnderSlice(p.projectDirectory, prefix)) {
56
+ return true;
57
+ }
58
+ }
59
+ return false;
60
+ });
42
61
  }
43
- /** Union of packages under any of the slice tokens (deduped by package name). */ export function projectsInSlices(projects, slices) {
62
+ /** Union of packages under any of the slice tokens (deduped by package name). */ export function projectsInSlices(projects, slices, projectRoots = [
63
+ "projects"
64
+ ]) {
44
65
  const byName = new Map();
45
66
  for (const slice of slices){
46
- for (const project of projectsInSlice(projects, slice)){
67
+ for (const project of projectsInSlice(projects, slice, projectRoots)){
47
68
  byName.set(project.name, project);
48
69
  }
49
70
  }
@@ -73,13 +94,15 @@ export function projectsInSlice(projects, slice) {
73
94
  }
74
95
  return "skip";
75
96
  }
76
- export function classifySliceProjects(projects, slices) {
97
+ export function classifySliceProjects(projects, slices, projectRoots = [
98
+ "projects"
99
+ ]) {
77
100
  const tokens = typeof slices === "string" ? [
78
101
  slices
79
102
  ] : [
80
103
  ...slices
81
104
  ];
82
- const inSlice = projectsInSlices(projects, tokens);
105
+ const inSlice = projectsInSlices(projects, tokens, projectRoots);
83
106
  const flux = [];
84
107
  const defer = [];
85
108
  const skip = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decohere/flux",
3
- "version": "0.0.1-dev.20261201.423",
3
+ "version": "0.0.1-dev.20261201.426",
4
4
  "description": "Hot module reload server for Node.js ESM applications",
5
5
  "keywords": [
6
6
  "typescript",
@@ -33,12 +33,12 @@
33
33
  "test": "echo \"Error: no test specified\" && exit 1"
34
34
  },
35
35
  "dependencies": {
36
- "@decohere/core": "0.0.1-dev.20261201.423",
37
- "@decohere/crucible": "0.0.1-dev.20261201.423",
38
- "@decohere/devkit": "0.0.1-dev.20261201.423",
39
- "@decohere/forge": "0.0.1-dev.20261201.423",
40
- "@decohere/scribe": "0.0.1-dev.20261201.423",
41
- "@decohere/workspace": "0.0.1-dev.20261201.423",
36
+ "@decohere/core": "0.0.1-dev.20261201.426",
37
+ "@decohere/crucible": "0.0.1-dev.20261201.426",
38
+ "@decohere/devkit": "0.0.1-dev.20261201.426",
39
+ "@decohere/forge": "0.0.1-dev.20261201.426",
40
+ "@decohere/scribe": "0.0.1-dev.20261201.426",
41
+ "@decohere/workspace": "0.0.1-dev.20261201.426",
42
42
  "commander": "^13.1.0"
43
43
  },
44
44
  "devDependencies": {}
@@ -18,10 +18,11 @@ export type ClassifiedSlice = {
18
18
  /** Preferred package scripts for foreign toolchains (Nixpacks-style). */
19
19
  export declare const DEFER_SCRIPT_CANDIDATES: readonly ["dev", "serve"];
20
20
  /**
21
- * Normalize a CLI slice token to a `projects/…` prefix without a trailing slash.
22
- * `funding` and `projects/funding` both become `projects/funding`.
21
+ * Normalize a CLI slice token under `projectRoot` (default `"projects"`) without a trailing slash.
22
+ * `funding` and `projects/funding` both become `projects/funding`; with `projectRoot = "src/ledger"`,
23
+ * `funding` and `src/ledger/funding` both become `src/ledger/funding`.
23
24
  */
24
- export declare function normalizeSlicePrefix(slice: string): string;
25
+ export declare function normalizeSlicePrefix(slice: string, projectRoot?: string): string;
25
26
  /**
26
27
  * True when `projectDirectory` belongs to the slice token.
27
28
  *
@@ -32,9 +33,9 @@ export declare function normalizeSlicePrefix(slice: string): string;
32
33
  * Does not match siblings that only share a string prefix (`funding` vs `funding-fee.api`).
33
34
  */
34
35
  export declare function isUnderSlice(projectDirectory: string, slicePrefix: string): boolean;
35
- export declare function projectsInSlice(projects: readonly SliceProjectView[], slice: string): SliceProjectView[];
36
+ export declare function projectsInSlice(projects: readonly SliceProjectView[], slice: string, projectRoots?: readonly string[]): SliceProjectView[];
36
37
  /** Union of packages under any of the slice tokens (deduped by package name). */
37
- export declare function projectsInSlices(projects: readonly SliceProjectView[], slices: readonly string[]): SliceProjectView[];
38
+ export declare function projectsInSlices(projects: readonly SliceProjectView[], slices: readonly string[], projectRoots?: readonly string[]): SliceProjectView[];
38
39
  /**
39
40
  * The project's own serve script, `dev` before `serve`, by the rule forge uses for `build`: one
40
41
  * that calls flux (or another Decohere tool) stays with Flux.
@@ -47,4 +48,4 @@ export declare function isFluxAppMain(main: string): boolean;
47
48
  * often have a main entry but must not be HMR-booted by Flux).
48
49
  */
49
50
  export declare function classifySliceProject(project: SliceProjectView): SliceKind;
50
- export declare function classifySliceProjects(projects: readonly SliceProjectView[], slices: string | readonly string[]): ClassifiedSlice;
51
+ export declare function classifySliceProjects(projects: readonly SliceProjectView[], slices: string | readonly string[], projectRoots?: readonly string[]): ClassifiedSlice;