uniweb 1.24.13 → 1.24.15

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": "uniweb",
3
- "version": "1.24.13",
3
+ "version": "1.24.15",
4
4
  "description": "Create structured Vite + React sites with content/code separation",
5
5
  "type": "module",
6
6
  "bin": {
@@ -41,15 +41,15 @@
41
41
  "js-yaml": "^4.3.2",
42
42
  "prompts": "^2.4.2",
43
43
  "tar": "^7.5.21",
44
- "@uniweb/content-writer": "~1.3.1",
45
44
  "@uniweb/schemas": "~1.6.7",
46
45
  "@uniweb/semantic-parser": "~1.13.0",
47
- "@uniweb/core": "~1.5.1"
46
+ "@uniweb/core": "~1.5.1",
47
+ "@uniweb/content-writer": "~1.3.1"
48
48
  },
49
49
  "peerDependencies": {
50
- "@uniweb/build": "~1.13.6",
50
+ "@uniweb/semantic-parser": "~1.13.0",
51
51
  "@uniweb/content-reader": "~1.5.7",
52
- "@uniweb/semantic-parser": "~1.13.0"
52
+ "@uniweb/build": "~1.13.8"
53
53
  },
54
54
  "peerDependenciesMeta": {
55
55
  "@uniweb/build": {
@@ -178,7 +178,7 @@ This is the highest-bandwidth way to learn the framework, and it works with no n
178
178
  ### The loop
179
179
 
180
180
  ```bash
181
- uniweb dev # from the workspace root; it picks the site for you
181
+ uniweb dev # the site you are in; from the workspace root, it picks one for you
182
182
  pnpm build # production build (SSG + SPA)
183
183
  pnpm preview # preview the production build
184
184
  ```
@@ -295,7 +295,7 @@ The architecture exists to keep content and code separate. Your task sits in one
295
295
  ### 4. The loop
296
296
 
297
297
  ```bash
298
- uniweb dev # from the workspace root; it picks the site
298
+ uniweb dev # the site you are in; from the workspace root, it picks one
299
299
  uniweb dev --status # the address it is serving at — read it, never assume a port
300
300
  uniweb dev --stop # stop it when you are done
301
301
  ```
@@ -69,6 +69,7 @@ import {
69
69
  promptSelect
70
70
  } from '../utils/workspace.js'
71
71
  import { isNonInteractive, getCliPrefix } from '../utils/interactive.js'
72
+ import { siteAround } from '../utils/pick-site.js'
72
73
 
73
74
  const c = {
74
75
  reset: '\x1b[0m',
@@ -500,6 +501,8 @@ export async function resolveSiteDir(args, verb = 'deploy') {
500
501
  const workspaceRoot = findWorkspaceRoot(cwd)
501
502
  if (workspaceRoot) {
502
503
  const sites = await findSites(workspaceRoot)
504
+ const here = siteAround(sites, workspaceRoot, cwd)
505
+ if (here) return resolve(workspaceRoot, here)
503
506
  if (sites.length === 1) return resolve(workspaceRoot, sites[0])
504
507
  if (sites.length > 1) {
505
508
  if (isNonInteractive(args)) {
@@ -24,16 +24,17 @@
24
24
  * asks it to stop, which it does with exit 0. ⛔ Until 2026-10-25 a caller had to pick a port to
25
25
  * know the address, and `--port` was read as the site's name.
26
26
  *
27
- * Resolution order for which site to launch:
28
- * 1. --site <name> (if passed)
29
- * 2. Positional <site> arg
27
+ * Resolution order for which site to launch (`utils/pick-site.js`):
28
+ * 1. --site <name> (if passed), or a positional <site>: a package's name, a
29
+ * site's folder, or a project's folder
30
+ * 2. The site the working directory means: the one you are in, or the one
31
+ * in the project folder you are in
30
32
  * 3. The single site in the workspace (if exactly one)
31
33
  * 4. The first site in the workspace, with a "multiple sites" notice
32
34
  * pointing at --site for explicit selection
33
35
  *
34
- * Multi-site workspaces with no positional / flag will run the first
35
- * site by default (mirrors the `pnpm dev` shortcut `uniweb create` writes).
36
- * Use `--site` to pick a different one without editing the root scripts.
36
+ * From the root of a multi-site workspace, with no positional / flag, it runs
37
+ * the first site (mirrors the `pnpm dev` shortcut `uniweb create` writes).
37
38
  *
38
39
  * A site whose foundation is a catalog ref — every clone — has no build of it, and
39
40
  * only the backend the site is on can say where that version is served. So `dev`
@@ -45,7 +46,12 @@
45
46
  *
46
47
  * Implementation: shells out to the package manager that invoked the CLI
47
48
  * (detected via npm_config_user_agent), running the workspace-filtered
48
- * dev command (`pnpm --filter <name> dev` or `npm -w <name> run dev`).
49
+ * dev command (`pnpm --filter <name> dev` or `npm -w <folder> run dev`).
50
+ *
51
+ * ⛔ UNDER NPM, BY THE SITE'S FOLDER. npm reads `-w <x>` as a package's name and also as a parent
52
+ * folder, every package in it selected. A site named for the folder around it (`marketing`, in
53
+ * `marketing/site`) then started the foundation beside it first, whose dev server answered 404
54
+ * and never gave way to the site's. pnpm's `--filter` reads a name as a name.
49
55
  * No special handling of vite directly — the site package already owns
50
56
  * its dev script, and shelling through pnpm/npm respects whatever the
51
57
  * site has configured (Vite plugins, env vars, port overrides, etc.).
@@ -54,7 +60,8 @@
54
60
  import { spawn } from 'node:child_process'
55
61
  import { join } from 'node:path'
56
62
 
57
- import { detectPackageManager, filterCmd } from '../utils/pm.js'
63
+ import { detectPackageManager, filterArgs } from '../utils/pm.js'
64
+ import { pickSite } from '../utils/pick-site.js'
58
65
  import { readWorkspaceConfig } from '../utils/config.js'
59
66
  import { discoverSites } from '../utils/discover.js'
60
67
  import { findWorkspaceRoot } from '../utils/workspace.js'
@@ -111,6 +118,15 @@ export function readDevArgs(args) {
111
118
  return wanted
112
119
  }
113
120
 
121
+ /**
122
+ * What starts a site's dev server: under pnpm by its name, and under npm by its folder, since npm
123
+ * also reads a name as a folder, every package in it selected.
124
+ * @returns {string[]} the program and its arguments
125
+ */
126
+ export function devCommand(pm, site) {
127
+ return filterArgs(pm, pm === 'npm' ? site.path : site.name, 'dev')
128
+ }
129
+
114
130
  export async function dev(args = []) {
115
131
  const badFlag = checkFlags('dev', args)
116
132
  if (badFlag) {
@@ -154,20 +170,13 @@ export async function dev(args = []) {
154
170
  // Pick the site
155
171
  const requested = wanted.site
156
172
 
157
- let site
158
- if (requested) {
159
- site =
160
- sites.find((s) => s.name === requested) ||
161
- sites.find((s) => s.path === requested)
162
- if (!site) {
163
- console.error(`${RED}✗${RESET} Site "${requested}" not found.`)
164
- console.error(` Available: ${sites.map((s) => s.name).join(', ')}`)
165
- process.exit(1)
166
- }
167
- } else if (sites.length === 1) {
168
- site = sites[0]
169
- } else {
170
- site = sites[0]
173
+ const { site, ambiguous } = pickSite(sites, rootDir, { requested, cwd })
174
+ if (requested && !site) {
175
+ console.error(`${RED}✗${RESET} Site "${requested}" not found.`)
176
+ console.error(` Available: ${sites.map((s) => s.name).join(', ')}`)
177
+ process.exit(1)
178
+ }
179
+ if (ambiguous) {
171
180
  console.error(
172
181
  `${YELLOW}⚠${RESET} Multiple sites found; using ${CYAN}${site.name}${RESET}.`
173
182
  )
@@ -220,8 +229,8 @@ export async function dev(args = []) {
220
229
  await warnOnStaleInstall(rootDir, site)
221
230
 
222
231
  const pm = detectPackageManager()
223
- const command = filterCmd(pm, site.name, 'dev')
224
- const [bin, ...rest] = command.split(' ')
232
+ const [bin, ...rest] = devCommand(pm, site)
233
+ const command = [bin, ...rest].join(' ')
225
234
 
226
235
  // ⭐ A SITE WHOSE FOUNDATION IS A CATALOG REF — a clone — is previewed with what the backend
227
236
  // it is on says: where that version is served. Asked here, for this dev server alone, and
@@ -11,7 +11,7 @@ import {
11
11
  mkdirSync,
12
12
  rmSync
13
13
  } from 'node:fs'
14
- import { join, resolve, basename, dirname, relative } from 'node:path'
14
+ import { join, resolve, dirname, relative } from 'node:path'
15
15
  import yaml from 'js-yaml'
16
16
  import {
17
17
  resolveFoundationSrcPath,
@@ -800,6 +800,38 @@ const SERVICE_GATES = [
800
800
  * using it reads as gated. Both are warnings about a real smell either way, and
801
801
  * neither can produce a wrong artifact.
802
802
  */
803
+ /**
804
+ * A site whose package is named for a folder holding other packages. npm reads `-w <x>` as a
805
+ * package's name and also as a parent folder, so `npm -w marketing run preview` runs the script of
806
+ * every package in `marketing/`, the foundation first, and its dev server never gives way to the
807
+ * site's. `uniweb dev` targets the site by folder; a script written by hand does not.
808
+ */
809
+ export function checkSiteNameIsAFolder({ siteName, sitePath, packagePaths, issues }) {
810
+ if (!siteName || siteName.includes('/')) return
811
+ const others = [...new Set(packagePaths)].filter((p) => p !== sitePath && p.startsWith(`${siteName}/`))
812
+ if (others.length === 0) return
813
+ const id = 'site-name-is-a-folder'
814
+ issues.push({ id, type: 'warn', site: siteName, message: `${siteName} is named for a folder holding other packages` })
815
+ warn(`[${id}] The site package ${siteName} has the name of a folder holding ${others.join(', ')}`)
816
+ log(` npm reads \`npm -w ${siteName}\` as every package in ${siteName}/, so a script using it runs theirs too, before the site's.`)
817
+ log(` Name the package ${siteName}-site, as \`uniweb add project\` does, and update the scripts that name it.`)
818
+ }
819
+
820
+ /**
821
+ * The `@source` lines of a foundation's stylesheet that find nothing (`staleSources`, `@uniweb/build`).
822
+ * Loaded here, not with this file's imports: a project may hold a build older than this CLI.
823
+ */
824
+ export async function checkStaleSources({ foundationName, srcDir, issues }) {
825
+ const { staleSources, staleSourceNote } = await import('@uniweb/build')
826
+ const stale = staleSources?.(join(srcDir, 'styles.css')) || []
827
+ if (stale.length === 0) return
828
+ const id = 'stale-source'
829
+ issues.push({ id, type: 'warn', foundation: foundationName, message: `${foundationName} has a @source that finds nothing` })
830
+ warn(`[${id}] ${foundationName} has a @source that finds nothing, so its CSS is missing every class that was only there`)
831
+ for (const line of stale) log(` @source "${line.source}" (${staleSourceNote(line)})`)
832
+ log(` Paths are relative to styles.css.`)
833
+ }
834
+
803
835
  /**
804
836
  * Source with its comments removed.
805
837
  *
@@ -1662,8 +1694,8 @@ async function runDoctor(args = []) {
1662
1694
  const extensions = []
1663
1695
  for (const f of discovered) {
1664
1696
  const fullPath = join(workspaceDir, f.path)
1665
- const folderName = basename(f.path)
1666
- const entry = { path: fullPath, name: f.name, folderName }
1697
+ // From the workspace root: in a workspace of projects, every foundation's folder is `src`.
1698
+ const entry = { path: fullPath, name: f.name, folderName: f.path }
1667
1699
  if (buildIsExtensionPackage(fullPath)) {
1668
1700
  extensions.push(entry)
1669
1701
  } else {
@@ -1699,15 +1731,19 @@ async function runDoctor(args = []) {
1699
1731
  // who does not, which is the case kit cannot reach.
1700
1732
  for (const f of foundations) {
1701
1733
  // `f.path` is already absolute (built above with join(workspaceDir, …)).
1702
- const stylesPath = join(f.path, 'styles.css')
1734
+ // ⛔ The stylesheet is where the foundation's source is. Until 2026-10-31 this read the
1735
+ // package root, so a foundation with `src/` inside its package was never checked.
1736
+ const stylesPath = join(resolveFoundationSrcPath(f.path), 'styles.css')
1703
1737
  if (!existsSync(stylesPath)) continue
1704
1738
 
1705
1739
  const styles = readFileSync(stylesPath, 'utf8')
1706
1740
  if (styles.includes('@uniweb/kit/prose-tokens.css')) continue
1741
+ // Tailwind Typography styles `prose` too, so this prose is not unstyled.
1742
+ if (loadsTypographyPlugin(styles)) continue
1707
1743
 
1708
1744
  // Does anything here actually ask for prose? Either the class in the
1709
1745
  // stylesheet, or kit's components, which render it.
1710
- const usesProseComponent = rendersKitProse(f.path)
1746
+ const usesProseComponent = rendersKitProse(resolveFoundationSrcPath(f.path))
1711
1747
  const usesProseClass = /(^|[\s"'`])prose(\s|["'`]|$)/m.test(styles)
1712
1748
 
1713
1749
  if (!usesProseClass && !usesProseComponent) continue
@@ -1727,10 +1763,16 @@ async function runDoctor(args = []) {
1727
1763
  ` kit's prose layer supplies the rules and it is not imported, so the ` +
1728
1764
  `markup is correct and completely unstyled — silently.`
1729
1765
  )
1730
- log(` Add to ${f.folderName}/styles.css:`)
1766
+ log(` Add to ${relative(workspaceDir, stylesPath)}:`)
1731
1767
  log(` ${colors.dim}@import "@uniweb/kit/prose-tokens.css";${colors.reset}`)
1732
1768
  }
1733
1769
 
1770
+ // A `@source` that finds nothing: the build succeeds and the CSS is short every class that was
1771
+ // only there. The build says so too; here it reaches `uniweb status`.
1772
+ for (const f of foundations) {
1773
+ await checkStaleSources({ foundationName: f.name, srcDir: resolveFoundationSrcPath(f.path), issues })
1774
+ }
1775
+
1734
1776
  // A modifier kit's prose layer does not have — `prose-slate`, `prose-invert`
1735
1777
  // and the rest of Tailwind Typography's palettes. Since 2026-10-19 the layer
1736
1778
  // takes every color from the section's theme tokens, so a class list still
@@ -1738,7 +1780,7 @@ async function runDoctor(args = []) {
1738
1780
  // Only where the foundation imports kit's layer and does not load the plugin
1739
1781
  // itself — with its own `@plugin`, the modifier still means what it says.
1740
1782
  for (const f of foundations) {
1741
- const stylesPath = join(f.path, 'styles.css')
1783
+ const stylesPath = join(resolveFoundationSrcPath(f.path), 'styles.css')
1742
1784
  if (!existsSync(stylesPath)) continue
1743
1785
  const styles = readFileSync(stylesPath, 'utf8')
1744
1786
  if (!styles.includes('@uniweb/kit/prose-tokens.css')) continue
@@ -1757,11 +1799,11 @@ async function runDoctor(args = []) {
1757
1799
  ` The plugin's rules sit above kit's and win: prose takes the plugin's greys, not the ` +
1758
1800
  `theme's colors, and the --prose-* variables reach nothing.`
1759
1801
  )
1760
- log(` Remove the @plugin line from ${f.folderName}/styles.css to use kit's layer alone.`)
1802
+ log(` Remove the @plugin line from ${relative(workspaceDir, stylesPath)} to use kit's layer alone.`)
1761
1803
  continue
1762
1804
  }
1763
1805
 
1764
- const found = inertProseModifiers(f.path)
1806
+ const found = inertProseModifiers(resolveFoundationSrcPath(f.path))
1765
1807
  if (found.length === 0) continue
1766
1808
 
1767
1809
  const id = 'prose-modifier-inert'
@@ -1898,6 +1940,12 @@ async function runDoctor(args = []) {
1898
1940
  success(`Found ${sites.length} site(s):`)
1899
1941
  for (const s of sites) {
1900
1942
  log(` • ${s.name}`)
1943
+ checkSiteNameIsAFolder({
1944
+ siteName: s.name,
1945
+ sitePath: relative(workspaceDir, s.path),
1946
+ packagePaths: [...discovered.map((f) => f.path), ...sites.map((o) => relative(workspaceDir, o.path))],
1947
+ issues
1948
+ })
1901
1949
  }
1902
1950
  }
1903
1951
 
@@ -107,7 +107,8 @@ import {
107
107
  commitWriteBacks,
108
108
  reportWriteBacks,
109
109
  writeItemUuids,
110
- writeFolderItemUuids
110
+ writeFolderItemUuids,
111
+ readItemBaseVersions
111
112
  } from '../backend/site-sync.js'
112
113
  import { resolveWorkspace } from '../backend/workspace.js'
113
114
  import { siteContentRoots, siteLaneRoots } from '../utils/git.js'
@@ -118,6 +119,8 @@ import {
118
119
  ignoringRepo,
119
120
  isAncestor,
120
121
  historySyncPoint,
122
+ movedFrom,
123
+ siteTreeIn,
121
124
  madeOnto,
122
125
  baseFor,
123
126
  openStandIn,
@@ -260,7 +263,8 @@ export function readPullCache(siteDir) {
260
263
  * Whether the ETags this copy banked still describe its files — the condition a
261
264
  * conditional GET is sent on. Outside git, always. In a repository, only while HEAD's
262
265
  * history holds the sync point they were banked with: a merge abandoned, a branch reset,
263
- * and the backend did not move but the files did.
266
+ * and the backend did not move but the files did. And only while that sync point holds the
267
+ * site where it is now: after a move, a pull that heard 304 would never record the new path.
264
268
  *
265
269
  * One rule for both readers of the lanes — this pull and `uniweb status`, which asks the
266
270
  * same question without taking the answer.
@@ -268,7 +272,7 @@ export function readPullCache(siteDir) {
268
272
  export function etagsHold(siteDir, origin, repo = repoOf(siteDir)) {
269
273
  if (!repo) return true
270
274
  const held = readSyncPoint(siteDir, origin)
271
- return Boolean(held && isAncestor(repo, held))
275
+ return Boolean(held && isAncestor(repo, held) && siteTreeIn(repo, held))
272
276
  }
273
277
  function writePullCache(siteDir, { content, folder }) {
274
278
  const p = pullCachePath(siteDir)
@@ -1080,6 +1084,7 @@ export async function pull(args = [], deps = {}) {
1080
1084
  let base = null
1081
1085
  let onto = null
1082
1086
  let standIn = null
1087
+ let siteMovedFrom = null
1083
1088
  if (repo && projected) {
1084
1089
  // The bases this copy knows of itself — then what the backend names, per lane.
1085
1090
  const known = [
@@ -1104,6 +1109,8 @@ export async function pull(args = [], deps = {}) {
1104
1109
  // what differs, and which way is the person's to read (`noBase`, below). ⛔ Until 2026-10-26
1105
1110
  // it said nothing at all, and status could not size a copied project's first pull.
1106
1111
  onto = force || !base ? repo.head : base
1112
+ // Why there is no base, when it is a move. Read now: the sync point this pull makes names the new path.
1113
+ if (!base) siteMovedFrom = movedFrom(repo, { origin: client.origin, siteUuid: siteContentUuid })
1107
1114
  try {
1108
1115
  standIn = openStandIn(repo, { roots, rev: onto })
1109
1116
  } catch (err) {
@@ -1272,9 +1279,19 @@ export async function pull(args = [], deps = {}) {
1272
1279
  // from the base is what the backend changed — or, with no base, what differs at all, which
1273
1280
  // way unknown (`noBase`). Nothing is banked; `finally` closes it.
1274
1281
  if (probe) {
1282
+ // The items the backend holds at another version than this copy last saw. With no file to
1283
+ // show for them, it is a page a pull does not write (a mounted folder's), or a push from
1284
+ // another copy these files already hold; either way a push from here may be refused.
1285
+ const seen = readItemBaseVersions(siteDir, client.origin)
1286
+ const itemsBehind = Object.entries(content?.itemVersions || {}).filter(([uuid, v]) => seen[uuid] && seen[uuid] !== v).length
1275
1287
  return {
1276
1288
  exitCode: 0,
1277
- probe: { files: standIn.changes(), recordsNotPlaced: Boolean(recordsNotPlaced), ...(base ? {} : { noBase: true }) }
1289
+ probe: {
1290
+ files: standIn.changes(),
1291
+ itemsBehind,
1292
+ recordsNotPlaced: Boolean(recordsNotPlaced),
1293
+ ...(base ? {} : { noBase: true, movedFrom: siteMovedFrom })
1294
+ }
1278
1295
  }
1279
1296
  }
1280
1297
 
@@ -1389,6 +1406,7 @@ export async function pull(args = [], deps = {}) {
1389
1406
  // Whether anything was set aside for the merge: the files as they were, against HEAD.
1390
1407
  merge.setAside = files !== repo.head
1391
1408
  merge.noBase = !force && !base
1409
+ merge.movedFrom = merge.noBase ? siteMovedFrom : null
1392
1410
  merge.changed = changedInFiles(repo, {
1393
1411
  from: repo.head,
1394
1412
  files,
@@ -1476,6 +1494,7 @@ export async function pull(args = [], deps = {}) {
1476
1494
  note('To use it, add the language in the app (Site ▸ Languages), then pull again.')
1477
1495
  }
1478
1496
  if (repo && !notTaken) {
1497
+ if (merge.movedFrom) note(`The site's folder moved from ${merge.movedFrom}. This pull records where it is now.`)
1479
1498
  // ⭐ What the pull changed in the files — not the backend's content against the base,
1480
1499
  // which also lists what the files already held (`changedInFiles`).
1481
1500
  if (projected && merge.changed.length) {
@@ -1514,7 +1533,11 @@ export async function pull(args = [], deps = {}) {
1514
1533
  note('Settle the markers and `git add` each file, then `git stash drop` — git kept those changes in the stash as well.')
1515
1534
  } else {
1516
1535
  if (merge.noBase) {
1517
- note(`No commit in this history is one ${client.origin}'s content came from, so nothing tells`)
1536
+ note(
1537
+ merge.movedFrom
1538
+ ? `No commit in this history holds the site where it is now, so nothing tells`
1539
+ : `No commit in this history is one ${client.origin}'s content came from, so nothing tells`
1540
+ )
1518
1541
  note("your changes from the backend's: each file that says something else is a conflict, yours against the backend's.")
1519
1542
  note('Once this merge is committed, later pulls merge from it.')
1520
1543
  }
@@ -54,6 +54,7 @@ import {
54
54
  saveSnapshotSettings
55
55
  } from '../utils/snapshot-settings.js'
56
56
  import { findWorkspaceRoot } from '../utils/workspace.js'
57
+ import { pickSite } from '../utils/pick-site.js'
57
58
 
58
59
  const RED = '\x1b[31m'
59
60
  const GREEN = '\x1b[32m'
@@ -220,19 +221,6 @@ export function shareImageDecision(current, next) {
220
221
  return current === next ? 'unchanged' : 'keep'
221
222
  }
222
223
 
223
- /** The site the command applies to: named, else the one containing cwd, else the only one. */
224
- export function pickSite(sites, rootDir, { requested, cwd }) {
225
- if (requested) {
226
- return { site: sites.find((s) => s.name === requested || s.path === requested) ?? null }
227
- }
228
- const containing = sites.find((s) => {
229
- const rel = relative(join(rootDir, s.path), cwd)
230
- return !rel.startsWith('..') && !isAbsolute(rel)
231
- })
232
- if (containing) return { site: containing }
233
- return { site: sites[0] ?? null, ambiguous: sites.length > 1 }
234
- }
235
-
236
224
  /** Import `@uniweb/snapshot` from the site, the workspace, or next to this CLI. */
237
225
  async function loadSnapshotPackage(dirs) {
238
226
  for (const dir of dirs) {
@@ -44,7 +44,7 @@
44
44
 
45
45
  import { execFileSync } from 'node:child_process'
46
46
  import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs'
47
- import { basename, dirname, join, relative, resolve, sep } from 'node:path'
47
+ import { basename, dirname, isAbsolute, join, posix, relative, resolve, sep } from 'node:path'
48
48
  import yaml from 'js-yaml'
49
49
 
50
50
  import {
@@ -76,6 +76,7 @@ import {
76
76
  mergeInProgress,
77
77
  readSyncPoint,
78
78
  repoOf,
79
+ siteTreeIn,
79
80
  unmergedPaths
80
81
  } from '../utils/sync-point.js'
81
82
  import { aheadBehind, remoteMoved, upstreamOf } from '../utils/git.js'
@@ -83,6 +84,7 @@ import { getLatestVersion, isBehind } from '../utils/update-check.js'
83
84
  import { syncedElsewhere } from '../utils/site-identity.js'
84
85
  import { DEFAULT_BACKEND_ORIGIN } from '../utils/config.js'
85
86
  import { classifyPackage, findSites, findWorkspaceRoot, isWorkspaceRoot } from '../utils/workspace.js'
87
+ import { siteAround } from '../utils/pick-site.js'
86
88
  import { getCliVersion } from '../versions.js'
87
89
  import { planNext } from '../utils/status-next.js'
88
90
 
@@ -186,14 +188,16 @@ function readSiteYml(siteDir) {
186
188
 
187
189
  /**
188
190
  * The site this status is about — never asked for: a status prompts for nothing. A site
189
- * folder is its own; a workspace with one site, that one; with several, none, and the
190
- * caller names them.
191
+ * folder is its own; the folder you stand in may mean one (`siteAround`); a workspace with
192
+ * one site, that one; with several, none, and the caller names them.
191
193
  */
192
194
  async function findSite(cwd) {
193
195
  if ((await classifyPackage(cwd)) === 'site') return { siteDir: cwd }
194
196
  const root = findWorkspaceRoot(cwd)
195
197
  if (!root) return { none: true }
196
198
  const sites = await findSites(root)
199
+ const here = siteAround(sites, root, cwd)
200
+ if (here) return { siteDir: resolve(root, here) }
197
201
  if (sites.length === 1) return { siteDir: resolve(root, sites[0]) }
198
202
  return sites.length ? { several: sites, root } : { none: true, root }
199
203
  }
@@ -295,6 +299,22 @@ function otherUncommitted(siteDir, repo) {
295
299
  .map((abs) => relative(siteDir, abs) || '.')
296
300
  }
297
301
 
302
+ /**
303
+ * The folders this site mounts from elsewhere in its repository, relative to the site: a push
304
+ * sends their pages as they are on disk, so they wait to be pushed like the site's own.
305
+ *
306
+ * ⛔ Until 2026-10-31 `status` read the site's own folder alone: it said "nothing waiting" over
307
+ * four commits of mounted docs, and the push that followed sent them. A mount in a repository of
308
+ * its own is a submodule's pin here, and reads as changed when the pin moves; one outside this
309
+ * repository has no commit to compare with, and is left out.
310
+ */
311
+ async function mountedRoots(siteDir, repo) {
312
+ const { mountEntriesOf } = await import('@uniweb/build/site')
313
+ return mountEntriesOf(readSiteYml(siteDir)?.paths)
314
+ .map(([, dir]) => dir)
315
+ .filter((dir) => !isAbsolute(dir) && !posix.normalize(`${repo.prefix}${dir}`).startsWith('..'))
316
+ }
317
+
298
318
  /**
299
319
  * Git: conflicts, a merge waiting, what is not committed, and the git remote.
300
320
  * @returns {Promise<{ checks: object[], proposals: object[], localFiles: string[]|null }>}
@@ -377,10 +397,13 @@ async function gitChecks(siteDir, { offline, origin }) {
377
397
  }
378
398
 
379
399
  // What this copy changed since its last sync, file by file — while its branch holds the
380
- // sync point that sync recorded.
400
+ // sync point that sync recorded, with the site where it is now. ⛔ Compared from before the
401
+ // site's folder moved, every file read as changed: "124 files hold changes" on a clean site.
381
402
  let localFiles = null
382
403
  const point = readSyncPoint(siteDir, origin)
383
- if (repo.head && point && isAncestor(repo, point)) localFiles = filesDifferFrom(repo, point, sentRoots(siteDir))
404
+ if (repo.head && point && isAncestor(repo, point) && siteTreeIn(repo, point)) {
405
+ localFiles = filesDifferFrom(repo, point, [...sentRoots(siteDir), ...(await mountedRoots(siteDir, repo))])
406
+ }
384
407
 
385
408
  const upstream = upstreamOf(siteDir)
386
409
  if (!upstream) {
@@ -770,8 +793,28 @@ function changeChecks(siteDir, changes, unpushedFiles, proposals, { elsewhere =
770
793
  * `app.changes` from the pull's own answer (`probePull`): the files it would change, each
771
794
  * as the pull would write it.
772
795
  */
773
- function probedChanges({ files: list, recordsNotPlaced, noBase }, unpushedFiles, proposals) {
796
+ function probedChanges({ files: list, recordsNotPlaced, noBase, movedFrom, itemsBehind = 0 }, unpushedFiles, proposals) {
797
+ if (noBase && movedFrom) {
798
+ if (!proposals.some((p) => p.step === 'pull')) {
799
+ proposals.push({ step: 'pull', command: 'npx uniweb pull', why: 'record where the site is now' })
800
+ }
801
+ return noBaseChanges(list, recordsNotPlaced, movedFrom)
802
+ }
774
803
  if (noBase) return noBaseChanges(list, recordsNotPlaced)
804
+ // ⛔ Until 2026-10-31 this said nothing changed, and the push that followed was refused: the
805
+ // backend held newer versions of a mounted folder's pages, which a pull does not write.
806
+ if (!list.length && itemsBehind) {
807
+ proposals.push({ step: 'pull', command: 'npx uniweb pull', why: 'record what moved on the backend' })
808
+ return [
809
+ {
810
+ id: 'app.changes',
811
+ state: 'attention',
812
+ summary:
813
+ 'The backend moved with no file here to show it: a push from another copy, or pages from a mounted folder. A pull changes no file and records that, and a push before it may be refused.',
814
+ detail: { source: 'pull', files: [], itemsBehind }
815
+ }
816
+ ]
817
+ }
775
818
  if (!list.length) {
776
819
  return [{ id: 'app.changes', state: 'ok', summary: 'Nothing changed on the backend since this copy last synced.', detail: { source: 'pull', files: [] } }]
777
820
  }
@@ -809,7 +852,7 @@ function probedChanges({ files: list, recordsNotPlaced, noBase }, unpushedFiles,
809
852
  * another way, it leaves alone, and it is not listed (`keepWhatMeansTheSame`, `commands/pull.js`).
810
853
  * The pull itself is `app.base`'s step.
811
854
  */
812
- function noBaseChanges(list, recordsNotPlaced) {
855
+ function noBaseChanges(list, recordsNotPlaced, movedFrom = null) {
813
856
  const differ = list.filter(([s]) => s === 'M').map(([, p]) => p)
814
857
  const added = list.filter(([s]) => s === 'A').map(([, p]) => p)
815
858
  const lines = []
@@ -819,9 +862,13 @@ function noBaseChanges(list, recordsNotPlaced) {
819
862
  {
820
863
  id: 'app.changes',
821
864
  state: 'attention',
822
- summary: differ.length
823
- ? `This copy shares no history with the site's content on the backend — brought from another repository, most likely. ${count(differ.length, 'file')} here ${differ.length === 1 ? 'says' : 'say'} something else, and the first pull makes ${differ.length === 1 ? 'it a conflict' : 'each a conflict'} to settle, yours against the backend's.`
824
- : "This copy shares no history with the site's content on the backend, and its files say what the site holds: the first pull records where they meet, with nothing to settle.",
865
+ summary: movedFrom
866
+ ? differ.length
867
+ ? `The site's folder moved from ${movedFrom} since it last synced. ${count(differ.length, 'file')} here ${differ.length === 1 ? 'says' : 'say'} something else than the backend, and the next pull makes ${differ.length === 1 ? 'it a conflict' : 'each a conflict'} to settle, yours against the backend's.`
868
+ : `The site's folder moved from ${movedFrom} since it last synced, and its files say what the backend holds: the next pull records where it is now, with nothing to settle.`
869
+ : differ.length
870
+ ? `This copy shares no history with the site's content on the backend — brought from another repository, most likely. ${count(differ.length, 'file')} here ${differ.length === 1 ? 'says' : 'say'} something else, and the first pull makes ${differ.length === 1 ? 'it a conflict' : 'each a conflict'} to settle, yours against the backend's.`
871
+ : "This copy shares no history with the site's content on the backend, and its files say what the site holds: the first pull records where they meet, with nothing to settle.",
825
872
  files: differ,
826
873
  lines,
827
874
  detail: { source: 'pull', noBase: true, files: list.map(([s, p]) => ({ path: p, change: CHANGE[s] || s })) }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "generatedAt": "2026-10-31T19:33:39.638Z",
3
+ "generatedAt": "2026-10-31T23:29:29.041Z",
4
4
  "packages": {
5
5
  "@uniweb/api": {
6
6
  "version": "1.6.7"
7
7
  },
8
8
  "@uniweb/build": {
9
- "version": "1.13.6"
9
+ "version": "1.13.8"
10
10
  },
11
11
  "@uniweb/content-reader": {
12
12
  "version": "1.5.7"
@@ -30,13 +30,13 @@
30
30
  "version": "1.1.2"
31
31
  },
32
32
  "@uniweb/press": {
33
- "version": "1.1.4"
33
+ "version": "1.1.5"
34
34
  },
35
35
  "@uniweb/projections": {
36
36
  "version": "1.2.9"
37
37
  },
38
38
  "@uniweb/runtime": {
39
- "version": "1.3.4"
39
+ "version": "1.3.5"
40
40
  },
41
41
  "@uniweb/scene": {
42
42
  "version": "1.0.1"
@@ -60,7 +60,7 @@
60
60
  "version": "1.2.1"
61
61
  },
62
62
  "@uniweb/unipress": {
63
- "version": "1.1.19"
63
+ "version": "1.1.21"
64
64
  }
65
65
  },
66
66
  "templates": {
package/src/index.js CHANGED
@@ -1598,8 +1598,8 @@ anywhere. To run a site's dev server, use \`uniweb dev\`.
1598
1598
  ${colors.cyan}${colors.bright}uniweb dev${colors.reset} ${colors.dim}— Start a dev server for a site${colors.reset}
1599
1599
 
1600
1600
  ${colors.bright}Usage:${colors.reset}
1601
- uniweb dev Start dev server for the (single) site
1602
- uniweb dev <site> Start dev server for a specific site
1601
+ uniweb dev Start dev server for the site you are in, or the single site
1602
+ uniweb dev <site> Start dev server for a site: its package name, or its project's folder
1603
1603
  uniweb dev --site <name> Same, with explicit flag form
1604
1604
  uniweb dev --port <n> On that port, or not at all
1605
1605
  uniweb dev --status Print the running dev server's address
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Which site a command means, in a workspace of several.
3
+ *
4
+ * ⭐ ONE RULE, for every verb that works on a site. A name says which, and with none the folder
5
+ * you stand in does: inside a site, that site; elsewhere, the one site in the nearest folder that
6
+ * holds any, so `marketing/` and `marketing/src/` both mean `marketing/site`. A folder holding
7
+ * several says nothing, and the workspace root is never that folder: from there, each verb does
8
+ * what it does with no answer (`dev` the first site, a push asks).
9
+ *
10
+ * ⛔ Until 2026-10-31 only `snapshot` looked. `uniweb dev` inside `marketing/site` served the
11
+ * workspace's first site, and a push from `docs/` asked which site, or stopped when nothing
12
+ * could ask.
13
+ *
14
+ * Dependency-free, like what is reached before a project's packages are installed.
15
+ */
16
+
17
+ import { dirname, isAbsolute, join, relative, sep } from 'node:path'
18
+
19
+ /** Is `path` the folder `dir`, or inside it? */
20
+ const within = (dir, path) => {
21
+ const rel = relative(dir, path)
22
+ return rel === '' || (rel !== '..' && !rel.startsWith(`..${sep}`) && !isAbsolute(rel))
23
+ }
24
+
25
+ /**
26
+ * The site a working directory means, or null when it says nothing.
27
+ *
28
+ * @param {string[]} paths - the workspace's sites, relative to its root
29
+ * @param {string} rootDir - the workspace root
30
+ * @param {string} cwd - the working directory
31
+ * @returns {string|null} one of `paths`
32
+ */
33
+ export function siteAround(paths, rootDir, cwd) {
34
+ const inside = paths.find((p) => within(join(rootDir, p), cwd))
35
+ if (inside) return inside
36
+ for (let dir = cwd; dir !== rootDir && within(rootDir, dir); dir = dirname(dir)) {
37
+ const held = paths.filter((p) => within(dir, join(rootDir, p)))
38
+ if (held.length === 1) return held[0]
39
+ if (held.length > 1) return null
40
+ }
41
+ return null
42
+ }
43
+
44
+ /**
45
+ * The site a name means: a package's name, a site's folder, or a folder holding exactly one site
46
+ * (a project's name, `marketing` for `marketing/site`). Null when it means none.
47
+ *
48
+ * @param {Array<{name: string, path: string}>} sites
49
+ * @param {string} name
50
+ */
51
+ export function siteNamed(sites, name) {
52
+ const exact = sites.find((s) => s.name === name) || sites.find((s) => s.path === name)
53
+ if (exact) return exact
54
+ const folder = name.replace(/\/+$/, '')
55
+ const held = sites.filter((s) => s.path === folder || s.path.startsWith(`${folder}/`))
56
+ return held.length === 1 ? held[0] : null
57
+ }
58
+
59
+ /**
60
+ * The site a command applies to: named, else the one the working directory means, else the only
61
+ * one. With several and nothing to say which, the first, marked `ambiguous`, for the caller to say so.
62
+ *
63
+ * @param {Array<{name: string, path: string}>} sites
64
+ * @param {string} rootDir
65
+ * @param {{ requested?: string|null, cwd: string }} opts
66
+ * @returns {{ site: {name: string, path: string}|null, ambiguous?: boolean }}
67
+ */
68
+ export function pickSite(sites, rootDir, { requested, cwd }) {
69
+ if (requested) return { site: siteNamed(sites, requested) }
70
+ const here = siteAround(sites.map((s) => s.path), rootDir, cwd)
71
+ if (here) return { site: sites.find((s) => s.path === here) }
72
+ return { site: sites[0] ?? null, ambiguous: sites.length > 1 }
73
+ }
@@ -17,9 +17,8 @@ import { isAbsolute, relative, sep } from 'node:path'
17
17
  // `pnpm-workspace.yaml` record `/tmp/x`. The two disagree, and the manifests are
18
18
  // committed files carrying a path that exists on exactly one machine.
19
19
  //
20
- // Reported by the backend lane 2026-09-18 from a `clone --path <abs>`: the site
21
- // landed under `company-websites/tmp/claude-502/clonetest/` and both manifests
22
- // gained the absolute string.
20
+ // Measured 2026-09-18 on a `clone --path <abs>`: the site landed under
21
+ // `<workspace>/tmp/<dir>/clonetest/` and both manifests gained the absolute string.
23
22
  //
24
23
  // So: accept an absolute path when it names a folder inside the root (people type
25
24
  // one, and it is unambiguous), by rewriting it to the root-relative form every
package/src/utils/pm.js CHANGED
@@ -122,9 +122,15 @@ export function globalCliUpdateCmd(pm) {
122
122
  * @returns {string}
123
123
  */
124
124
  export function filterCmd(pm, pkg, cmd) {
125
- return pm === 'pnpm'
126
- ? `pnpm --filter ${pkg} ${cmd}`
127
- : `npm -w ${pkg} run ${cmd}`
125
+ return filterArgs(pm, pkg, cmd).join(' ')
126
+ }
127
+
128
+ /**
129
+ * The same command as a program and its arguments, to run rather than to print.
130
+ * @returns {string[]}
131
+ */
132
+ export function filterArgs(pm, pkg, cmd) {
133
+ return pm === 'pnpm' ? ['pnpm', '--filter', pkg, cmd] : ['npm', '-w', pkg, 'run', cmd]
128
134
  }
129
135
 
130
136
  /**
@@ -272,8 +272,39 @@ export function madeOnto(repo, sha, { origin, siteUuid }) {
272
272
  }
273
273
 
274
274
  /**
275
- * The base a pull merges from: the newest of the candidates HEAD descends from. One that
276
- * descends from all the others is the newest; with none, the most recently committed.
275
+ * Can a pull merge from this commit? HEAD's history holds it, and it holds the site where the
276
+ * site is now.
277
+ *
278
+ * ⛔ A BASE IS READ AT THE SITE'S CURRENT PATH (`openStandIn`), so a commit from before the site's
279
+ * folder moved reads as an empty site, and every file as new on both sides. Until 2026-10-31 such
280
+ * a commit was a base like any other: a plain pull after a move gave 98 conflicts and 126 other
281
+ * changes across four sites that had changed nothing, and a wrong file name beside each section
282
+ * it could not place. With no base, a pull finds that the files already say what the backend
283
+ * holds, and records where the site is now.
284
+ */
285
+ function canBeBase(repo, sha) {
286
+ return isCommit(repo, sha) && isAncestor(repo, sha) && Boolean(siteTreeIn(repo, sha))
287
+ }
288
+
289
+ /**
290
+ * The path this site last synced at, when it is somewhere else now: what the newest sync point
291
+ * of this site and backend names, or null. For saying why a pull has no base.
292
+ */
293
+ export function movedFrom(repo, { origin, siteUuid }) {
294
+ if (!repo?.head) return null
295
+ try {
296
+ const body = gitText(repo.top, ['log', '-1', '--fixed-strings', `--grep=${SYNC_TRAILER}: ${origin} ${siteUuid}`, '--format=%B', 'HEAD'])
297
+ const { path } = trailersOf(body)
298
+ return path && path !== repo.path ? path : null
299
+ } catch {
300
+ return null
301
+ }
302
+ }
303
+
304
+ /**
305
+ * The base a pull merges from: the newest of the candidates HEAD descends from that can be one
306
+ * (`canBeBase`). One that descends from all the others is the newest; with none, the most
307
+ * recently committed.
277
308
  *
278
309
  * ⚖️ Any of them is a state both sides descend from, but only the newest such state — the
279
310
  * commit the backend's content last came from — merges exactly. An older one costs a
@@ -283,7 +314,7 @@ export function madeOnto(repo, sha, { origin, siteUuid }) {
283
314
  * 2026-10-17 this said an older base "costs precision at worst".
284
315
  */
285
316
  export function newestBase(repo, candidates) {
286
- const shas = [...new Set(candidates.filter(Boolean))].filter((s) => isCommit(repo, s) && isAncestor(repo, s))
317
+ const shas = [...new Set(candidates.filter(Boolean))].filter((s) => canBeBase(repo, s))
287
318
  if (shas.length <= 1) return shas[0] || null
288
319
  const newest = shas.find((s) => shas.every((o) => o === s || isAncestor(repo, o, s)))
289
320
  if (newest) return newest
@@ -316,7 +347,7 @@ export function newestBase(repo, candidates) {
316
347
  * real backend — a reverted change came back (A18), a re-wrap and six pushed edits conflicted.
317
348
  */
318
349
  export function baseFor(repo, { known = [], lanes = [], origin, siteUuid }) {
319
- const held = (s) => Boolean(s) && isCommit(repo, s) && isAncestor(repo, s)
350
+ const held = (s) => Boolean(s) && canBeBase(repo, s)
320
351
  const fallback = newestBase(repo, known)
321
352
  const refs = lanes.map(({ source, roots }) => ({
322
353
  roots,
@@ -770,14 +801,14 @@ export function fileAt(repo, rev, path) {
770
801
 
771
802
  /**
772
803
  * The files under the roots that differ from what `rev` holds there — changed, deleted, or
773
- * new and not ignored — relative to the site.
804
+ * new and not ignored — relative to the site, one outside it (a mounted folder's) included.
774
805
  */
775
806
  export function filesDifferFrom(repo, rev, roots) {
776
- const full = roots.map((r) => `${repo.prefix}${r}`)
807
+ const full = roots.map((r) => underTop(repo, r))
777
808
  try {
778
809
  const changed = zlist(git(repo.top, ['diff', '--name-only', '-z', '--no-renames', rev, '--', ...full]))
779
810
  const added = zlist(git(repo.top, ['ls-files', '--others', '--exclude-standard', '-z', '--', ...full]))
780
- return [...new Set([...changed, ...added].map((p) => siteRelative(repo, p)))]
811
+ return [...new Set([...changed, ...added].map((p) => posix.relative(repo.prefix, p)))]
781
812
  } catch {
782
813
  return []
783
814
  }