@north-light/cli 0.3.755 → 0.3.757
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/dist/api/client.d.ts +1 -2
- package/dist/api/client.js +3 -3
- package/dist/api/contract.d.ts +1 -1
- package/dist/api/contract.js +1 -1
- package/dist/api/dto/health.d.ts +0 -54
- package/dist/api/routes.d.ts +0 -1
- package/dist/api/routes.js +1 -1
- package/dist/build-root.d.ts +0 -3
- package/dist/build-root.js +1 -1
- package/dist/builtin-memory/internal/storage-tiers.md +3 -3
- package/dist/cli.js +8 -9
- package/dist/clients/attach/viewer.js +474 -474
- package/dist/commands/profile/new.js +1 -1
- package/dist/commands/profile/project.js +1 -1
- package/dist/commands/sys/branch.js +1 -1
- package/dist/commands/sys/daemon.js +1 -1
- package/dist/commands/sys.js +1 -1
- package/dist/core/bootstrap.js +1 -1
- package/dist/core/canvas/boot.d.ts +0 -25
- package/dist/core/canvas/boot.js +1 -1
- package/dist/core/canvas/executions.d.ts +0 -3
- package/dist/core/canvas/executions.js +1 -1
- package/dist/core/canvas/pid.d.ts +0 -10
- package/dist/core/canvas/pid.js +5 -5
- package/dist/core/directory/join.js +1 -1
- package/dist/core/grants/mirror.d.ts +0 -5
- package/dist/core/grants/mirror.js +6 -6
- package/dist/core/grants/sync.js +1 -1
- package/dist/core/human/page-schema.d.ts +1 -1
- package/dist/core/io.js +4 -4
- package/dist/core/layout.d.ts +0 -2
- package/dist/core/layout.js +2 -2
- package/dist/core/profiles/manifest.js +1 -1
- package/dist/core/profiles/project-dir.d.ts +3 -0
- package/dist/core/profiles/project-dir.js +1 -0
- package/dist/core/scoped-state/db.js +2 -2
- package/dist/daemon/api/handlers/daemon.js +1 -1
- package/dist/daemon/api/handlers/profiles.js +1 -1
- package/dist/daemon/api/map.d.ts +1 -6
- package/dist/daemon/api/map.js +2 -2
- package/dist/daemon/api/operations.js +1 -1
- package/dist/daemon/api/server.js +1 -1
- package/dist/daemon/control.d.ts +0 -8
- package/dist/daemon/crtrd.js +18 -20
- package/dist/daemon/manage.js +3 -3
- package/package.json +3 -3
- package/packages/crouter-api/dist/api/client.js +0 -3
- package/packages/crouter-api/dist/api/contract.js +1 -1
- package/packages/crouter-api/dist/api/routes.js +0 -1
- package/packages/crouter-api/dist/build-root.js +0 -9
- package/packages/crouter-api/dist/commands/profile/new.js +2 -2
- package/packages/crouter-api/dist/commands/profile/project.js +2 -1
- package/packages/crouter-api/dist/commands/sys/branch.js +1 -1
- package/packages/crouter-api/dist/commands/sys/daemon.js +1 -1
- package/packages/crouter-api/dist/commands/sys.js +1 -2
- package/packages/crouter-api/dist/core/canvas/executions.js +1 -17
- package/packages/crouter-api/dist/core/canvas/pid.js +0 -16
- package/packages/crouter-api/dist/core/directory/join.js +18 -1
- package/packages/crouter-api/dist/core/grants/mirror.js +0 -7
- package/packages/crouter-api/dist/core/grants/sync.js +2 -2
- package/packages/crouter-api/dist/core/io.js +0 -5
- package/packages/crouter-api/dist/core/layout.js +2 -19
- package/packages/crouter-api/dist/core/profiles/manifest.js +12 -18
- package/packages/crouter-api/dist/core/profiles/project-dir.js +20 -0
- package/packages/crouter-api/dist/daemon/api/map.js +0 -16
- package/packages/crouter-api/dist/daemon/api/operations.js +0 -1
- package/packages/crouter-api/dist/daemon/manage.js +1 -1
- package/packages/crouter-api/package.json +1 -1
- package/packages/crouter-identity/package.json +1 -1
- package/packages/crouter-plugin/package.json +3 -3
- package/runtime.lock.json +14 -14
- package/scripts/install-runtime.mjs +1 -30
- package/dist/commands/sys/migrate.d.ts +0 -1
- package/dist/commands/sys/migrate.js +0 -1
- package/dist/core/canvas/import-sqlite.d.ts +0 -46
- package/dist/core/canvas/import-sqlite.js +0 -19
- package/dist/core/canvas/migrations.d.ts +0 -16
- package/dist/core/canvas/migrations.js +0 -1073
- package/dist/core/feed/inbox-migrate.d.ts +0 -11
- package/dist/core/feed/inbox-migrate.js +0 -3
- package/dist/core/graph/bodies-boot-copy.d.ts +0 -28
- package/dist/core/graph/bodies-boot-copy.js +0 -1
- package/dist/core/layout-migrate/index.d.ts +0 -38
- package/dist/core/layout-migrate/index.js +0 -4
- package/dist/core/layout-migrate/loose-keys.d.ts +0 -2
- package/dist/core/layout-migrate/loose-keys.js +0 -1
- package/dist/core/layout-migrate/paths.d.ts +0 -30
- package/dist/core/layout-migrate/paths.js +0 -1
- package/dist/core/layout-migrate/stored-paths.d.ts +0 -9
- package/dist/core/layout-migrate/stored-paths.js +0 -11
- package/dist/core/layout-migrate/stores.d.ts +0 -30
- package/dist/core/layout-migrate/stores.js +0 -3
- package/dist/core/scoped-state/migrate.d.ts +0 -15
- package/dist/core/scoped-state/migrate.js +0 -3
- package/dist/daemon/boot-migrations.d.ts +0 -14
- package/dist/daemon/boot-migrations.js +0 -1
- package/dist/migrations/004-canvas-documents/apply.d.ts +0 -8
- package/dist/migrations/004-canvas-documents/apply.js +0 -1
- package/dist/migrations/004-canvas-documents/index.d.ts +0 -16
- package/dist/migrations/004-canvas-documents/index.js +0 -2
- package/dist/migrations/004-canvas-documents/legacy/discover.d.ts +0 -16
- package/dist/migrations/004-canvas-documents/legacy/discover.js +0 -1
- package/dist/migrations/004-canvas-documents/legacy/history.d.ts +0 -5
- package/dist/migrations/004-canvas-documents/legacy/history.js +0 -2
- package/dist/migrations/004-canvas-documents/legacy/nested.d.ts +0 -7
- package/dist/migrations/004-canvas-documents/legacy/nested.js +0 -1
- package/dist/migrations/004-canvas-documents/legacy/parse.d.ts +0 -14
- package/dist/migrations/004-canvas-documents/legacy/parse.js +0 -1
- package/dist/migrations/004-canvas-documents/legacy/types.d.ts +0 -91
- package/dist/migrations/004-canvas-documents/legacy/types.js +0 -0
- package/dist/migrations/004-canvas-documents/legacy-edges.d.ts +0 -6
- package/dist/migrations/004-canvas-documents/legacy-edges.js +0 -18
- package/dist/migrations/004-canvas-documents/plan.d.ts +0 -102
- package/dist/migrations/004-canvas-documents/plan.js +0 -3
- package/dist/migrations/004-canvas-documents/pointers.d.ts +0 -23
- package/dist/migrations/004-canvas-documents/pointers.js +0 -4
- package/dist/migrations/activation.d.ts +0 -17
- package/dist/migrations/activation.js +0 -2
- package/packages/crouter-api/dist/commands/sys/migrate.js +0 -79
- package/packages/crouter-api/dist/core/layout-migrate/index.js +0 -523
- package/packages/crouter-api/dist/core/layout-migrate/paths.js +0 -118
- package/packages/crouter-api/dist/core/layout-migrate/stored-paths.js +0 -424
- package/packages/crouter-api/dist/core/layout-migrate/stores.js +0 -543
- package/packages/crouter-api/dist/core/locked-file.js +0 -121
- package/packages/crouter-api/dist/core/scoped-state/db.js +0 -271
- package/packages/crouter-api/dist/core/scoped-state/legacy-profiles.js +0 -65
- package/packages/crouter-api/dist/core/scoped-state/migrate.js +0 -332
- package/packages/crouter-api/dist/core/scoped-state/schema.js +0 -52
- package/packages/crouter-api/dist/migrations/004-canvas-documents/apply.js +0 -113
- package/packages/crouter-api/dist/migrations/004-canvas-documents/index.js +0 -89
- package/packages/crouter-api/dist/migrations/004-canvas-documents/legacy/discover.js +0 -251
- package/packages/crouter-api/dist/migrations/004-canvas-documents/legacy/history.js +0 -37
- package/packages/crouter-api/dist/migrations/004-canvas-documents/legacy/nested.js +0 -37
- package/packages/crouter-api/dist/migrations/004-canvas-documents/legacy/parse.js +0 -24
- package/packages/crouter-api/dist/migrations/004-canvas-documents/legacy/types.js +0 -3
- package/packages/crouter-api/dist/migrations/004-canvas-documents/plan.js +0 -410
- package/packages/crouter-api/dist/migrations/004-canvas-documents/pointers.js +0 -95
- package/packages/crouter-api/dist/migrations/activation.js +0 -46
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
/** Frozen copy of the history record shape the retired store-file history wrote. */
|
|
2
|
-
export interface LegacyHistoryRecord {
|
|
3
|
-
op: 'create' | 'edit' | 'delete' | 'move';
|
|
4
|
-
at: string;
|
|
5
|
-
node?: string;
|
|
6
|
-
cwd: string;
|
|
7
|
-
from?: string;
|
|
8
|
-
rationale?: string;
|
|
9
|
-
verbatim?: boolean;
|
|
10
|
-
before: string;
|
|
11
|
-
after: string;
|
|
12
|
-
}
|
|
13
|
-
export interface LegacyProfile {
|
|
14
|
-
id: string;
|
|
15
|
-
name: string;
|
|
16
|
-
/** The owning app (`grantee`), `app:terminal` for older manifests without one. */
|
|
17
|
-
app: string;
|
|
18
|
-
/** The profile's store (`<app space>/profiles/<id>`), resolved by the caller. */
|
|
19
|
-
memory: string;
|
|
20
|
-
/** Every `projects[].path` in the manifest. */
|
|
21
|
-
projects: string[];
|
|
22
|
-
/** The manifest as parsed JSON, for fields the plan converts (`projects[].memory`). */
|
|
23
|
-
raw?: Record<string, unknown>;
|
|
24
|
-
manifestPath?: string;
|
|
25
|
-
}
|
|
26
|
-
export interface LegacyRoots {
|
|
27
|
-
userMemory: string;
|
|
28
|
-
profiles: LegacyProfile[];
|
|
29
|
-
nodeCwds: string[];
|
|
30
|
-
/** Node rows that exist in canvas.db and their folders (`<nodes>/<id>`). */
|
|
31
|
-
nodes: Array<{
|
|
32
|
-
id: string;
|
|
33
|
-
dir: string;
|
|
34
|
-
}>;
|
|
35
|
-
}
|
|
36
|
-
export type LegacyOwnerRef = {
|
|
37
|
-
type: 'person';
|
|
38
|
-
} | {
|
|
39
|
-
type: 'profile';
|
|
40
|
-
id: string;
|
|
41
|
-
} | {
|
|
42
|
-
type: 'repo';
|
|
43
|
-
root: string;
|
|
44
|
-
commonDir: string | null;
|
|
45
|
-
namespace: string | null;
|
|
46
|
-
} | {
|
|
47
|
-
type: 'node';
|
|
48
|
-
id: string;
|
|
49
|
-
};
|
|
50
|
-
export interface LegacyDoc {
|
|
51
|
-
path: string;
|
|
52
|
-
owner: LegacyOwnerRef;
|
|
53
|
-
/** The document name under its owner (INDEX folding, nested prefix, `reports/<stem>`, root `INDEX.md` → `index`). */
|
|
54
|
-
name: string;
|
|
55
|
-
source: 'store' | 'context' | 'report';
|
|
56
|
-
frontmatter: Record<string, unknown> | null;
|
|
57
|
-
body: string;
|
|
58
|
-
mtime: string;
|
|
59
|
-
/** Records of the file's current life (after its last `delete`), in file order; store documents only. */
|
|
60
|
-
history: LegacyHistoryRecord[];
|
|
61
|
-
/** Set when the file could not be read as written: `invalid-source` (unparseable
|
|
62
|
-
* frontmatter; `body` is the whole file and `frontmatter` null) or `invalid-history`
|
|
63
|
-
* (its history log is unreadable; `history` is empty). */
|
|
64
|
-
invalid?: {
|
|
65
|
-
kind: 'invalid-source' | 'invalid-history';
|
|
66
|
-
reason: string;
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
export interface LegacyStoreRoot {
|
|
70
|
-
root: string;
|
|
71
|
-
owner: LegacyOwnerRef;
|
|
72
|
-
docs: number;
|
|
73
|
-
skipped?: 'duplicate-worktree';
|
|
74
|
-
}
|
|
75
|
-
export interface LegacyCorpus {
|
|
76
|
-
docs: LegacyDoc[];
|
|
77
|
-
storeRoots: LegacyStoreRoot[];
|
|
78
|
-
/** Files or roots not read, with the reason; informational. */
|
|
79
|
-
skipped: Array<{
|
|
80
|
-
path: string;
|
|
81
|
-
reason: string;
|
|
82
|
-
}>;
|
|
83
|
-
/** History logs whose document file no longer exists. */
|
|
84
|
-
orphanHistory: number;
|
|
85
|
-
/** Folders beside the given node folders with no node row. */
|
|
86
|
-
orphanNodeDirs: number;
|
|
87
|
-
/** Non-markdown files under node `context/` and `reports/` folders (not imported). */
|
|
88
|
-
nonMarkdown: number;
|
|
89
|
-
/** `injected-docs.json` ledgers found in node folders (not imported; the roll ends their sessions). */
|
|
90
|
-
injectedDocs: number;
|
|
91
|
-
}
|
|
File without changes
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { DatabaseSync } from 'node:sqlite';
|
|
2
|
-
/** canvas.db chain step: converts the node-only `legacy_edges` rows into graph rows, then drops it.
|
|
3
|
-
* `spawned_by(child, parent)` → `edges(acted-on, parent → child)`.
|
|
4
|
-
* `subscribes_to(watcher, object)` → an in-tree watch with one `>` subscription, started `spawn`
|
|
5
|
-
* when the object was spawned by the watcher, else `ask`; a passive row listens at next-turn. */
|
|
6
|
-
export declare function convertLegacyEdges(db: DatabaseSync): void;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
var n=Object.defineProperty;var s=(e,t)=>n(e,"name",{value:t,configurable:!0});function _(e){if(!e.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'legacy_edges'").get())return;const t=s(d=>e.prepare(d).get().n,"count"),c=t("SELECT COUNT(*) AS n FROM legacy_edges WHERE type = 'spawned_by'"),r=t("SELECT COUNT(*) AS n FROM legacy_edges WHERE type = 'subscribes_to'"),o=t("SELECT COUNT(*) AS n FROM legacy_edges WHERE type NOT IN ('spawned_by', 'subscribes_to')");if(o>0)throw new Error(`convertLegacyEdges: ${o} legacy edge(s) of an unknown type`);const a=e.prepare(`INSERT INTO edges (type, src, dst, written_as, created_at)
|
|
2
|
-
SELECT 'acted-on', p.rowid, c.rowid, NULL, e.created
|
|
3
|
-
FROM legacy_edges e JOIN objects c ON c.id = e.from_id JOIN objects p ON p.id = e.to_id
|
|
4
|
-
WHERE e.type = 'spawned_by'
|
|
5
|
-
ON CONFLICT (type, src, dst) DO NOTHING`).run().changes,E=e.prepare(`INSERT INTO watches (watcher, object, in_tree, read_heads_key, created_at)
|
|
6
|
-
SELECT w.rowid, o.rowid, 1, NULL, e.created
|
|
7
|
-
FROM legacy_edges e JOIN objects w ON w.id = e.from_id JOIN objects o ON o.id = e.to_id
|
|
8
|
-
WHERE e.type = 'subscribes_to'
|
|
9
|
-
ON CONFLICT (watcher, object) DO UPDATE SET in_tree = 1`).run().changes;if(e.exec(`INSERT INTO watch_subscriptions (watch, pattern, filter_json, config_json, started_by, ends_on, created_at)
|
|
10
|
-
SELECT wt.rowid, '>', NULL,
|
|
11
|
-
CASE WHEN e.active = 1 THEN NULL ELSE '{"3":"next-turn"}' END,
|
|
12
|
-
CASE WHEN EXISTS (SELECT 1 FROM legacy_edges s
|
|
13
|
-
WHERE s.type = 'spawned_by' AND s.from_id = e.to_id AND s.to_id = e.from_id)
|
|
14
|
-
THEN 'spawn' ELSE 'ask' END,
|
|
15
|
-
NULL, e.created
|
|
16
|
-
FROM legacy_edges e JOIN objects w ON w.id = e.from_id JOIN objects o ON o.id = e.to_id
|
|
17
|
-
JOIN watches wt ON wt.watcher = w.rowid AND wt.object = o.rowid
|
|
18
|
-
WHERE e.type = 'subscribes_to'`),a!==c||E!==r)throw new Error(`convertLegacyEdges: converted ${a}/${c} spawned_by and ${E}/${r} subscribes_to rows`);e.exec("DROP TABLE legacy_edges")}s(_,"convertLegacyEdges");export{_ as convertLegacyEdges};
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { type CheckoutIdentity } from '../../core/graph/repo-sync/identity.js';
|
|
2
|
-
import type { Privacy, RuleSpec } from '../../core/graph/types.js';
|
|
3
|
-
import { type DocumentKind } from './fields.js';
|
|
4
|
-
import type { LegacyCorpus, LegacyRoots } from './legacy/types.js';
|
|
5
|
-
/** The store migrations every plan assumes already ran (the previous release's lanes). */
|
|
6
|
-
export declare const CONVERGED_MARKER_IDS: readonly ["001-surfaces-frontmatter", "002-profile-project-memory", "003-repository-root-memory-identity"];
|
|
7
|
-
export type OwnerType = 'person' | 'app' | 'profile' | 'repo' | 'node';
|
|
8
|
-
export interface PlannedOwner {
|
|
9
|
-
/** Stable key documents point at: `person`, `app:<handle>`, `profile:<id>`, `repo:<externalId>`, `node:<id>`. */
|
|
10
|
-
key: string;
|
|
11
|
-
type: OwnerType;
|
|
12
|
-
handle: string;
|
|
13
|
-
/** Repo identity (`ensureRepo`). */
|
|
14
|
-
scheme?: 'git' | 'local-path';
|
|
15
|
-
externalId?: string;
|
|
16
|
-
/** A profile's owning app, as an owner key (`app:<handle>`). */
|
|
17
|
-
ownerKey?: string;
|
|
18
|
-
}
|
|
19
|
-
export interface PlannedRevision {
|
|
20
|
-
body: string;
|
|
21
|
-
authorNodeId: string | null;
|
|
22
|
-
rationale: string | null;
|
|
23
|
-
createdAt: string;
|
|
24
|
-
}
|
|
25
|
-
export interface PlannedDocument {
|
|
26
|
-
ownerKey: string;
|
|
27
|
-
name: string;
|
|
28
|
-
kind: DocumentKind;
|
|
29
|
-
privacy: Privacy;
|
|
30
|
-
preview: string;
|
|
31
|
-
summary: string | null;
|
|
32
|
-
whyItExists: string | null;
|
|
33
|
-
unlisted: boolean;
|
|
34
|
-
lintIgnore: unknown;
|
|
35
|
-
extensions: unknown;
|
|
36
|
-
rules: RuleSpec[];
|
|
37
|
-
/** Oldest first; the last one is the head, whose body carries the pointer rewrite. */
|
|
38
|
-
revisions: PlannedRevision[];
|
|
39
|
-
sourcePath: string;
|
|
40
|
-
}
|
|
41
|
-
/** A stored-profile update (scoped-state `profiles.delivery_limits_json`): the legacy
|
|
42
|
-
* profile.json `projects[].memory` caps, keyed by repo handle, merged over the row's limits. */
|
|
43
|
-
export interface PlannedProfileLimits {
|
|
44
|
-
profileId: string;
|
|
45
|
-
deliveryLimits: Record<string, string>;
|
|
46
|
-
}
|
|
47
|
-
/** Something that stops the import. Only a runtime that skipped the previous
|
|
48
|
-
* release's store migrations blocks; every other finding resolves itself. */
|
|
49
|
-
export interface ImportBlocker {
|
|
50
|
-
kind: 'marker';
|
|
51
|
-
message: string;
|
|
52
|
-
paths: string[];
|
|
53
|
-
}
|
|
54
|
-
/** One finding the plan resolved on its own, with what it did. */
|
|
55
|
-
export interface ImportResolution {
|
|
56
|
-
kind: 'invalid-source' | 'invalid-history' | 'name-clash' | 'repo-handle' | 'profile-handle' | 'repo-identity' | 'delivery-limit' | 'empty-preview';
|
|
57
|
-
message: string;
|
|
58
|
-
paths: string[];
|
|
59
|
-
}
|
|
60
|
-
export interface ImportReport {
|
|
61
|
-
stores: LegacyCorpus['storeRoots'];
|
|
62
|
-
counts: Record<string, number>;
|
|
63
|
-
rewrites: Array<{
|
|
64
|
-
path: string;
|
|
65
|
-
from: string;
|
|
66
|
-
to: string;
|
|
67
|
-
}>;
|
|
68
|
-
droppedFields: Array<{
|
|
69
|
-
path: string;
|
|
70
|
-
field: string;
|
|
71
|
-
}>;
|
|
72
|
-
skipped: LegacyCorpus['skipped'];
|
|
73
|
-
/** Every clash or unreadable source the plan resolved, one line each. */
|
|
74
|
-
resolutions: ImportResolution[];
|
|
75
|
-
}
|
|
76
|
-
export interface ImportPlan {
|
|
77
|
-
owners: PlannedOwner[];
|
|
78
|
-
documents: PlannedDocument[];
|
|
79
|
-
profileLimits: PlannedProfileLimits[];
|
|
80
|
-
blockers: ImportBlocker[];
|
|
81
|
-
report: ImportReport;
|
|
82
|
-
}
|
|
83
|
-
export interface PlanContext {
|
|
84
|
-
roots: LegacyRoots;
|
|
85
|
-
/** Ids in `on-disk-migrations.json`, or null when it is absent. */
|
|
86
|
-
markerIds: string[] | null;
|
|
87
|
-
/** Repo identity of a git checkout root (repo-sync `identifyCheckout`). */
|
|
88
|
-
repoIdentity: (root: string) => CheckoutIdentity;
|
|
89
|
-
/** Owner objects already in canvas.db; a new handle must not take one of theirs. */
|
|
90
|
-
existingOwners: Array<{
|
|
91
|
-
type: string;
|
|
92
|
-
handle: string;
|
|
93
|
-
externalId: string | null;
|
|
94
|
-
}>;
|
|
95
|
-
/** Stored profile rows (scoped-state) with their current `delivery_limits`. */
|
|
96
|
-
storedProfiles: Array<{
|
|
97
|
-
id: string;
|
|
98
|
-
deliveryLimits: Record<string, string>;
|
|
99
|
-
}>;
|
|
100
|
-
home?: string;
|
|
101
|
-
}
|
|
102
|
-
export declare function planImport(corpus: LegacyCorpus, ctx: PlanContext): ImportPlan;
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
var ae=Object.defineProperty;var c=(o,a)=>ae(o,"name",{value:a,configurable:!0});import{realpathSync as de}from"node:fs";import{homedir as pe}from"node:os";import{isAbsolute as le,join as ce,relative as fe}from"node:path";import{parseFrontmatterGeneric as he}from"../../core/frontmatter.js";import{handleHint as me}from"../../core/graph/repo-sync/identity.js";import{andIntoRules as ue,documentFields as ye}from"./fields.js";import{rewritePointers as we}from"./pointers.js";const $e=["001-surfaces-frontmatter","002-profile-project-memory","003-repository-root-memory-identity"],U=["none","name","preview","content"];function O(o){try{return de(o)}catch{return o}}c(O,"real");const X=c(o=>o.replace(/^app:/,""),"appHandle");function Re(o,a){const v=[],m={},d=c((e,n=1)=>{m[e]=(m[e]??0)+n},"count"),p=[],u=[],g=[],l=c(e=>{g.push(e),d(`resolutions.${e.kind}`)},"resolve");o.docs.length>0&&[...a.markerIds??[]].sort().join(`
|
|
2
|
-
`)!==[...$e].sort().join(`
|
|
3
|
-
`)&&v.push({kind:"marker",paths:[],message:`this runtime skipped the store migrations of the previous release (on-disk-migrations.json lists ${a.markerIds===null?"nothing":JSON.stringify(a.markerIds)}); start the previous crtr release once, then upgrade`});for(const e of o.docs)e.invalid!==void 0&&l({kind:e.invalid.kind,paths:[e.path],message:e.invalid.kind==="invalid-source"?`${e.path}: ${e.invalid.reason} \u2014 imported the whole file as the body, with no rules`:`${e.path}: ${e.invalid.reason} \u2014 imported the current file without its history`});const k=new Map,G=new Map,x=c((e,n)=>G.get(`${e}\0${n}`),"held"),S=c((e,n,t)=>{G.set(`${e}\0${n}`,t)},"hold"),Y=c(e=>e.type==="repo"&&e.externalId!==null?`repo:${e.externalId}`:e.type==="person"?"person":e.type==="profile"&&e.externalId!==null?`profile:${e.externalId}`:`${e.type}:${e.handle}`,"keyOfExisting");for(const e of a.existingOwners)S(e.type,e.handle,Y(e));const W=c((e,n)=>{let t=2;for(;x(e,`${n}-${t}`)!==void 0;)t+=1;return`${n}-${t}`},"freeHandle"),M=c(e=>{const n=k.get(e.key);if(n!==void 0)return n;const t=x(e.type,e.handle),r=t!==void 0&&t!==e.key?W(e.type,e.handle):e.handle,s={...e,handle:r};return S(s.type,r,s.key),k.set(s.key,s),s},"claim");for(const e of a.existingOwners)e.type==="person"&&k.set("person",{key:"person",type:"person",handle:e.handle});const z=M({key:"person",type:"person",handle:"user"}),Z=new Map(a.roots.profiles.map(e=>[e.id,e])),ee=new Set(a.roots.nodes.map(e=>e.id)),te=new Map(a.roots.nodes.map(e=>[e.id,e.dir])),C=new Map;for(const e of[...a.roots.profiles].sort((n,t)=>n.id.localeCompare(t.id))){const n=x("profile",e.name);if(n===void 0||n===`profile:${e.id}`){C.set(e.id,e.name),S("profile",e.name,`profile:${e.id}`);continue}const t=x("profile",e.id)===void 0?e.id:W("profile",e.id);C.set(e.id,t),S("profile",t,`profile:${e.id}`),l({kind:"profile-handle",paths:e.manifestPath===void 0?[]:[e.manifestPath],message:`profile ${e.id} shares the name \`${e.name}\` with ${n}; it takes the handle \`${t}\``})}const N=new Map,E=new Map,B=c((e,n)=>{if(E.has(e.root))return;const t=e.commonDir===null?{ok:!1,code:"not-a-repo",dir:e.root,reason:"no .git"}:a.repoIdentity(e.root);let r="local-path",s=O(e.root),i=me(s);t.ok?(r=t.scheme,s=t.externalId,i=t.handleHint):t.code!=="not-a-repo"&&l({kind:"repo-identity",paths:n,message:`${e.root}: repo identity lookup failed (${t.code}: ${t.reason}); imported as the local-path repo ${s}`});const f=`repo:${s}`;E.set(e.root,f);const h=a.existingOwners.find(y=>y.type==="repo"&&y.externalId===s),w=N.get(f);w!==void 0?w.roots.push(e.root):N.set(f,{key:f,scheme:r,externalId:s,wanted:h?.handle??e.namespace??i,roots:[e.root]})},"identify");for(const e of o.storeRoots)e.owner.type==="repo"&&e.skipped===void 0&&B(e.owner,[e.root]);for(const e of o.docs)e.owner.type==="repo"&&B(e.owner,[e.path]);const J=new Map,K=new Map;for(const e of N.values())K.set(e.wanted,[...K.get(e.wanted)??[],e]);for(const[e,n]of[...K].sort(([t],[r])=>t.localeCompare(r))){const t=c(r=>x("repo",e)===r.key?0:r.scheme==="git"?1:2,"rank");n.sort((r,s)=>t(r)-t(s)||r.externalId.localeCompare(s.externalId));for(const r of n){const s=M({key:r.key,type:"repo",handle:e,scheme:r.scheme,externalId:r.externalId});s.handle!==e&&(J.set(r.key,{from:e,to:s.handle}),l({kind:"repo-handle",paths:r.roots,message:`repo ${r.externalId} (${r.roots.join(", ")}) wanted the handle \`${e}\`, held by ${x("repo",e)}; it takes \`${s.handle}\` and its documents' \`[[${e}/\u2026]]\` links are rewritten to match`}))}}const P=new Map;for(const[e,n]of E)P.set(e,k.get(n));const ne=c(e=>P.get(e.root),"repoOwner"),oe=c(e=>{const n=Z.get(e),t=M({key:`app:${X(n?.app??"app:terminal")}`,type:"app",handle:X(n?.app??"app:terminal")});return M({key:`profile:${e}`,type:"profile",handle:C.get(e)??n?.name??e,ownerKey:t.key})},"profileOwner"),re=c(e=>{switch(e.owner.type){case"person":return z;case"profile":return oe(e.owner.id);case"repo":return ne(e.owner);case"node":return M({key:`node:${e.owner.id}`,type:"node",handle:e.owner.id})}},"ownerFor"),R=new Map;for(const e of o.docs)e.owner.type==="repo"&&e.mtime>(R.get(e.owner.root)??"")&&R.set(e.owner.root,e.mtime);const D=new Map;for(const[e,n]of P){const t=D.get(n.key);(t===void 0||(R.get(e)??"")>(R.get(t)??""))&&D.set(n.key,e)}const A=[...o.skipped],T=new Set,H=[],j=new Map;for(const e of o.docs){const n=re(e);if(e.owner.type==="repo"&&D.get(n.key)!==e.owner.root){T.has(e.owner.root)||(T.add(e.owner.root),A.push({path:e.owner.root,reason:`duplicate-clone: ${n.handle} imports from ${D.get(n.key)}`})),d("documents.duplicate-clone");continue}let t=n.key,r=e.name;const s=e.source==="report",i=ye(e.invalid?.kind==="invalid-source"?null:e.frontmatter,e.body,{...s?{kind:"report"}:{},missingPrivacy:n.type==="repo"?"public":"private"});for(const $ of i.dropped)p.push({path:e.path,field:$});let f=i.rules,h=i.preview;e.source==="context"&&r==="roadmap"&&(f=[...f,{on:"boot",deliver:"content"}],h=h||`The roadmap of node ${n.handle}`),h.trim()===""&&(h=e.name,l({kind:"empty-preview",paths:[e.path],message:`${e.path} has no text to preview; its preview is its name, ${e.name}`})),n.type==="repo"&&i.privacy!=="public"&&(f=ue(f,{repo:n.handle}),t=z.key,r=`${n.handle}/${r}`,d("documents.private-repo-to-person"));const w=ke(e,ee,l),y=k.get(t).handle,b={doc:e,qualified:`${y}/${r}`,contextDir:e.owner.type==="node"?ce(te.get(e.owner.id)??"","context"):null,repoKey:e.owner.type==="repo"?n.key:null,planned:{ownerKey:t,name:r,kind:i.kind,privacy:i.privacy,preview:h,summary:i.summary,whyItExists:i.whyItExists,unlisted:i.unlisted,lintIgnore:i.lintIgnore,extensions:i.extensions,rules:f,revisions:w,sourcePath:e.path}},_=`${t}\0${r}`,I=j.get(_);if(I!==void 0){const $=I.doc.mtime<=e.mtime?I:b;let L=1;for(;j.has(`${t}\0${r}.conflict-${L}`);)L+=1;$.planned.name=`${r}.conflict-${L}`,$.qualified=`${y}/${$.planned.name}`,j.set(`${t}\0${$.planned.name}`,$),j.set(_,$===I?b:I),l({kind:"name-clash",paths:[I.doc.path,e.path],message:`${I.doc.path} and ${e.path} both import as \`${y}/${r}\`; the newer keeps the name and ${$.doc.path} imports as \`${$.planned.name}\``})}else j.set(_,b);H.push(b),d(`documents.${i.kind}`),d(`documents.owner.${k.get(t).type}`),d("revisions",w.length)}const q=new Map,V=new Set,Q=new Set;for(const e of H){q.set(e.doc.path,e.qualified),q.set(O(e.doc.path),e.qualified),e.doc.source==="report"&&V.add(e.qualified);const n=k.get(e.planned.ownerKey);e.planned.name==="index"&&n.type!=="node"&&Q.add(n.handle)}const ie={byPath:q,reports:V,indexHandles:Q,home:a.home??pe(),real:O};for(const e of H){const n=e.planned.revisions[e.planned.revisions.length-1],t=we(n.body,ie,{contextDir:e.contextDir}),r=e.repoKey===null?void 0:J.get(e.repoKey);if(r!==void 0){const s=`[[${r.from}/`,i=`[[${r.to}/`;t.body.includes(s)&&(t.body=t.body.split(s).join(i),t.rewrites.push({from:s,to:i}))}if(t.rewrites.length!==0){n.body=t.body;for(const s of t.rewrites)u.push({path:e.doc.path,...s});d("documents.rewritten")}}const F=[],se=new Map(a.storedProfiles.map(e=>[e.id,e.deliveryLimits]));for(const e of a.roots.profiles){if(e.raw===void 0||e.manifestPath===void 0)continue;const n=Array.isArray(e.raw.projects)?e.raw.projects:[];if(!n.some(i=>i!==null&&typeof i=="object"&&"memory"in i))continue;const t=se.get(e.id);if(t===void 0){A.push({path:e.manifestPath,reason:`profile-not-stored: profile ${e.id} has a manifest but no stored profile row; its memory caps are not carried over`});continue}const r={...t},s=new Map;n.forEach(i=>{if(i===null||typeof i!="object"||!("memory"in i))return i;const{memory:f,...h}=i;if(f==="content"||typeof h.path!="string")return h;const w=ge(h.path,a,P);if(w===null)return A.push({path:e.manifestPath,reason:`delivery-limit-dropped: project ${h.path} (memory ${String(f)}) is in no repo and has no project store`}),h;const y=r[w];if(y!==void 0&&y!==f){const b=U.indexOf(String(f))>U.indexOf(y)?String(f):y;if(l({kind:"delivery-limit",paths:[e.manifestPath],message:`profile ${e.name}: ${s.get(w)??"delivery_limits"} and ${h.path} both map to repo \`${w}\` with different memory caps (${y}, ${String(f)}); kept the larger, ${b}`}),b===y)return h}return r[w]=String(f),s.set(w,h.path),h}),Object.keys(r).some(i=>r[i]!==t[i])&&F.push({profileId:e.id,deliveryLimits:r})}return d("profile-limits",F.length),m.stores=o.storeRoots.filter(e=>e.skipped===void 0).length,m["stores.duplicate-worktree"]=o.storeRoots.filter(e=>e.skipped!==void 0).length,m.owners=k.size,m["orphan-history"]=o.orphanHistory,m["orphan-node-dirs"]=o.orphanNodeDirs,m["non-markdown"]=o.nonMarkdown,m["exposure-ledgers-not-imported"]=o.injectedDocs,{owners:[...k.values()],documents:H.map(e=>e.planned),profileLimits:F,blockers:v,report:{stores:o.storeRoots,counts:m,rewrites:u,droppedFields:p,skipped:A,resolutions:g}}}c(Re,"planImport");function ge(o,a,v){const m=O(o);let d=null;for(const[u,g]of v){const l=fe(O(u),m);(l===""||!l.startsWith("..")&&!le(l))&&(d===null||u.length>d.root.length)&&(d={root:u,owner:g})}const p=a.repoIdentity(m);if(p.ok){const u=[...v.values()].find(l=>l.externalId===p.externalId);return u?u.handle:a.existingOwners.find(l=>l.type==="repo"&&l.externalId===p.externalId)?.handle??p.handleHint}return d?.owner.handle??null}c(ge,"projectHandle");function ke(o,a,v){const m=c(p=>typeof p=="string"&&a.has(p)?p:null,"author");if(o.source!=="store")return[{body:o.body,authorNodeId:o.owner.type==="node"&&a.has(o.owner.id)?o.owner.id:null,rationale:null,createdAt:o.mtime}];const d=[];for(const p of o.history){if(p.op!=="create"&&p.op!=="edit"&&p.op!=="move")continue;let u;try{u=he(p.after).body}catch(g){return v({kind:"invalid-history",paths:[o.path],message:`${o.path}: history record at ${p.at} has invalid frontmatter (${g.message}); imported the current file without its history`}),[{body:o.body,authorNodeId:null,rationale:null,createdAt:o.mtime}]}d.length>0&&d[d.length-1].body===u||d.push({body:u,authorNodeId:m(p.node),rationale:p.rationale??null,createdAt:p.at})}if(d.length===0){const p=o.frontmatter?.origin??{},u=c(l=>typeof l=="string"?l:l instanceof Date?l.toISOString():null,"stamp"),g=u(p.created)??u(o.frontmatter?.["last-updated"])??o.mtime;return[{body:o.body,authorNodeId:m(p.node),rationale:null,createdAt:g}]}return d[d.length-1].body!==o.body&&d.push({body:o.body,authorNodeId:null,rationale:"changed outside crtr before import",createdAt:o.mtime}),d}c(ke,"revisionsOf");export{$e as CONVERGED_MARKER_IDS,Re as planImport};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export interface PointerTargets {
|
|
2
|
-
/** Absolute file path (as read and realpath) → qualified document name. */
|
|
3
|
-
byPath: ReadonlyMap<string, string>;
|
|
4
|
-
/** `<node-id>/reports/<stem>` of every imported report. */
|
|
5
|
-
reports: ReadonlySet<string>;
|
|
6
|
-
/** Owner handles that have an imported `index` document. */
|
|
7
|
-
indexHandles: ReadonlySet<string>;
|
|
8
|
-
home: string;
|
|
9
|
-
/** Resolve symlinks of a path that is not in `byPath` as written; returns the input when it does not exist. */
|
|
10
|
-
real: (path: string) => string;
|
|
11
|
-
}
|
|
12
|
-
export interface PointerContext {
|
|
13
|
-
/** The node folder's `context/` dir when the document is owned by a node (for `$CRTR_CONTEXT_DIR/…`). */
|
|
14
|
-
contextDir: string | null;
|
|
15
|
-
}
|
|
16
|
-
/** Rewrite one head body; `rewrites` receives every replacement made. */
|
|
17
|
-
export declare function rewritePointers(body: string, t: PointerTargets, ctx: PointerContext): {
|
|
18
|
-
body: string;
|
|
19
|
-
rewrites: Array<{
|
|
20
|
-
from: string;
|
|
21
|
-
to: string;
|
|
22
|
-
}>;
|
|
23
|
-
};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
var T=Object.defineProperty;var f=(s,t)=>T(s,"name",{value:t,configurable:!0});import{join as a}from"node:path";const _=/(?<![\w./$-])((?:~|\$CRTR_CONTEXT_DIR|\$\{CRTR_CONTEXT_DIR\})?\/[^\s()[\]<>`'"]*?\.md)(?![\w-]|\.[\w-])/g,m=/(?<![\w/-])([a-z0-9]+(?:-[a-z0-9]+)+):reports\/([A-Za-z0-9._-]+?)(?:\.md)?(?![\w-]|\.[\w-])/g,g=/\[\[([^\]|#/\s]+)((?:[|#][^\]]*)?)\]\]/g;function R(s,t,l){let r;if(s.startsWith("~/"))r=a(t.home,s.slice(2));else if(s.startsWith("$")){if(l.contextDir===null)return null;r=a(l.contextDir,s.slice(s.indexOf("/")+1))}else r=s;return t.byPath.get(r)??t.byPath.get(t.real(r))??null}f(R,"resolvePointer");function $(s,t,l){const r=`${s}/reports/${t}`;return l.reports.has(r)?r:null}f($,"resolveReport");function d(s,t,l,r){const c=f((e,n)=>n===null?e:(r.push({from:e,to:`[[${n}]]`}),`[[${n}]]`),"sub");return s.replace(_,(e,n)=>c(e,R(n,t,l))).replace(m,(e,n,u)=>c(e,$(n,u,t))).replace(g,(e,n,u)=>{if(!t.indexHandles.has(n))return e;const o=`[[${n}/index${u}]]`;return r.push({from:e,to:o}),o})}f(d,"rewriteText");function x(s,t,l,r,c){const e=t.trim(),n=/^([a-z0-9]+(?:-[a-z0-9]+)+):reports\/([A-Za-z0-9._-]+?)(?:\.md)?$/.exec(e),u=n!==null?$(n[1],n[2],l):/^(?:~|\$CRTR_CONTEXT_DIR|\$\{CRTR_CONTEXT_DIR\})?\/\S*\.md$/.test(e)?R(e,l,r):null;return u===null?s:(c.push({from:s,to:`[[${u}]]`}),`[[${u}]]`)}f(x,"rewriteCodeSpan");function D(s,t,l){const r=[],c=[];let e=null,n=[];const u=f(()=>{if(n.length===0)return;const o=n.join(`
|
|
2
|
-
`),i=[];let h=0;for(const p of o.matchAll(/(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/g))i.push(d(o.slice(h,p.index),t,l,r)),i.push(x(p[0],p[2],t,l,r)),h=p.index+p[0].length;i.push(d(o.slice(h),t,l,r)),c.push(i.join("")),n=[]},"flush");for(const o of s.split(`
|
|
3
|
-
`)){const i=/^\s*(`{3,}|~{3,})/.exec(o)?.[1];e===null&&i!==void 0?(u(),e=i,c.push(o)):e!==null?(c.push(o),i!==void 0&&i[0]===e[0]&&i.length>=e.length&&o.trim()===i&&(e=null)):n.push(o)}return u(),{body:c.join(`
|
|
4
|
-
`),rewrites:r}}f(D,"rewritePointers");export{D as rewritePointers};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { type CanvasImportResult } from './004-canvas-documents/index.js';
|
|
2
|
-
export type { CanvasImportResult } from './004-canvas-documents/index.js';
|
|
3
|
-
/** A migration blocker is a STANDING condition, not a transient fault: the same
|
|
4
|
-
* stores produce the same blockers on every boot, so a caller that retries a
|
|
5
|
-
* daemon start against one retries forever. Typing it lets the startup path
|
|
6
|
-
* tell "try again" apart from "this needs a human", and carry the repair line
|
|
7
|
-
* to whoever can act on it. */
|
|
8
|
-
export declare class MigrationBlockedError extends Error {
|
|
9
|
-
readonly blockerPaths: readonly string[];
|
|
10
|
-
constructor(message: string, blockerPaths: readonly string[]);
|
|
11
|
-
}
|
|
12
|
-
/** Startup: import the legacy stores unless already recorded. Throws `MigrationBlockedError` when the plan has blockers. */
|
|
13
|
-
export declare function activateCanvasImport(): Promise<CanvasImportResult | null>;
|
|
14
|
-
/** `crtr sys migrate`: plan (and unless `dryRun`, apply) regardless of startup state. */
|
|
15
|
-
export declare function runForcedCanvasImport(opts: {
|
|
16
|
-
dryRun: boolean;
|
|
17
|
-
}): Promise<CanvasImportResult>;
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var s=Object.defineProperty;var o=(r,t)=>s(r,"name",{value:t,configurable:!0});import{mkdirSync as c}from"node:fs";import{dirname as m}from"node:path";import{onDiskMigrationLockPath as u}from"../core/canvas/paths.js";import{withExclusiveDirectoryLockAsync as p}from"../core/exclusive-lock.js";import{DAEMON_STARTUP_WINDOW_MS as l}from"../daemon/startup-policy.js";import{canvasImportDone as h,runCanvasImport as e}from"./004-canvas-documents/index.js";class d extends Error{static{o(this,"MigrationBlockedError")}blockerPaths;constructor(t,n){super(t),this.name="MigrationBlockedError",this.blockerPaths=n}}function i(r){const t=u();return c(m(t),{recursive:!0,mode:448}),p(t,async()=>r(),{timeoutMs:l,timeoutError:o(()=>new Error(`timed out waiting for the canvas import lock: ${t}`),"timeoutError")})}o(i,"coordinate");async function E(){return await i(async()=>{if(await h())return null;const r=await e({dryRun:!1});if(r.blockers.length>0){const t=[...new Set(r.blockers.flatMap(a=>a.paths))],n=[`canvas import (004-canvas-documents) blocked by ${r.blockers.length} finding(s)`,...r.blockers.map(a=>`${a.kind}: ${a.message}`)];throw n.push("Repair each finding, then: crtr sys migrate --dry-run, then crtr sys migrate"),new d(n.join(`
|
|
2
|
-
`),t)}return r})}o(E,"activateCanvasImport");async function M(r){return await i(async()=>await e(r))}o(M,"runForcedCanvasImport");export{d as MigrationBlockedError,E as activateCanvasImport,M as runForcedCanvasImport};
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
// `crtr sys migrate`: the offline layout migration, then the daemon-owned
|
|
2
|
-
// canvas import (004-canvas-documents) of the legacy memory stores.
|
|
3
|
-
import { defineLeaf } from '../../core/command.js';
|
|
4
|
-
import { general } from '../../core/errors.js';
|
|
5
|
-
import { cliClient, rethrowAsCliError } from '../api-client.js';
|
|
6
|
-
import { layoutNeedsMigration } from '../../core/layout.js';
|
|
7
|
-
import { migrateLayout } from '../../core/layout-migrate/index.js';
|
|
8
|
-
export const sysMigrateLeaf = defineLeaf({
|
|
9
|
-
name: 'migrate',
|
|
10
|
-
description: 'migrate an old runtime layout offline, then import the legacy memory stores into the canvas',
|
|
11
|
-
whenToUse: 'when the daemon reports startup `blocked` by the canvas import, or after moving from a release that kept memory as markdown stores. Run --dry-run first to see the plan and what it resolves; a write run on an imported home does nothing.',
|
|
12
|
-
help: {
|
|
13
|
-
name: 'sys migrate',
|
|
14
|
-
summary: 'move an old runtime layout offline, then plan or run the daemon-owned canvas import',
|
|
15
|
-
guide: 'A layout migration requires the daemon to be stopped, runs in this process, and stops after writing the layout version; start the daemon and run `crtr sys migrate` again. The daemon then plans the canvas import: every legacy store (the user store, each profile store, every repository `.crouter/memory` reached from a profile project or a node\'s cwd, node context folders and reports) becomes documents with their revision history, owned by the person, a profile, a repo, or a node. Both stages resolve leftovers and clashes themselves (a folder with no node row is set aside, two repos with one namespace get distinct handles, an unparseable file imports as its raw text, and so on) and list each in `layout_resolutions` and `resolutions`, on the dry run too. The daemon runs the import itself at startup; only a blocker (the store migrations of a skipped release never ran) makes it write nothing and hold startup in `blocked`. The import writes in one transaction and resumes startup. The markdown files are left on disk and are never read again.',
|
|
16
|
-
params: [
|
|
17
|
-
{ kind: 'flag', name: 'dry-run', type: 'bool', required: false, constraint: 'Plan and report without writing. On an imported home, returns the recorded report with pending false.' },
|
|
18
|
-
],
|
|
19
|
-
output: [
|
|
20
|
-
{ name: 'loose_keys', type: 'string[]', required: false, constraint: 'Loose credential paths moved or set aside; never values.' },
|
|
21
|
-
{ name: 'layout_moved', type: 'number', required: false, constraint: 'Old-layout paths moved or stored paths rewritten on this run; present when the layout migration ran.' },
|
|
22
|
-
{ name: 'layout_resolutions', type: 'string[]', required: false, constraint: 'One line per leftover the layout migration resolved (or, under --dry-run, will resolve): set-aside folders, moved profile files, closed worktree rows, cleared transcript paths.' },
|
|
23
|
-
{ name: 'layout_absent_credentials', type: 'string[]', required: false, constraint: 'Old credential files the layout migration looked for and did not find (or, under --dry-run, will not find); present when the layout migration ran. An absent file is legitimate when the old home never held that credential.' },
|
|
24
|
-
{ name: 'stores', type: 'object[]', required: false, constraint: 'Every store root found: {root, owner, docs, skipped?}; skipped is duplicate-worktree for a second checkout of an imported repo.' },
|
|
25
|
-
{ name: 'counts', type: 'object', required: false, constraint: 'Planned (or written) totals: documents.<kind>, documents.owner.<person|profile|repo|node>, revisions, documents.rewritten, owners, stores, profile-limits, and informational counts. Empty on a write run over an imported home.' },
|
|
26
|
-
{ name: 'rewrites', type: 'object[]', required: false, constraint: 'Pointer rewrites in head bodies: {path, from, to}.' },
|
|
27
|
-
{ name: 'dropped_fields', type: 'object[]', required: false, constraint: 'Frontmatter fields with no canvas equivalent: {path, field}.' },
|
|
28
|
-
{ name: 'skipped', type: 'object[]', required: false, constraint: 'Files or roots not imported, with the reason: {path, reason}.' },
|
|
29
|
-
{ name: 'resolutions', type: 'object[]', required: false, constraint: 'Clashes the import resolved itself: {kind, message, paths}; kind is invalid-source, invalid-history, name-clash, repo-handle, profile-handle, repo-identity, or delivery-limit.' },
|
|
30
|
-
{ name: 'blockers', type: 'object[]', required: false, constraint: '{kind, message, paths}; kind is marker (the store migrations of a skipped release never ran). A blocker makes the command fail with this whole report in `received`; nothing is written.' },
|
|
31
|
-
{ name: 'dryRun', type: 'boolean', required: true, constraint: 'True when nothing was written.' },
|
|
32
|
-
{ name: 'pending', type: 'boolean', required: false, constraint: 'True while this home has not been imported.' },
|
|
33
|
-
{ name: 'resumed', type: 'boolean', required: false, constraint: 'True only when this run resumed a blocked daemon startup.' },
|
|
34
|
-
{ name: 'resume_error', type: 'string', required: false, constraint: 'Present when the import succeeded but normal daemon startup then failed.' },
|
|
35
|
-
],
|
|
36
|
-
outputKind: 'object',
|
|
37
|
-
effects: [
|
|
38
|
-
'With an old layout and no layout version, refuses while a daemon answers, moves the runtime records, sets aside leftovers under runtime/set-aside/, rewrites stored paths and writes the layout version last, then stops; the next run, with the daemon started, plans or runs the canvas import.',
|
|
39
|
-
'Without --dry-run and with no blockers: stores revision bodies, converts profile project memory caps into profile delivery limits, and writes owners, documents, revisions, links, and the authoring nodes\' watches in one canvas transaction, recorded so it runs once.',
|
|
40
|
-
'Under --dry-run: read-only, writes nothing.',
|
|
41
|
-
],
|
|
42
|
-
},
|
|
43
|
-
run: async (input) => {
|
|
44
|
-
const dryRun = input.dryRun === true;
|
|
45
|
-
const layout = layoutNeedsMigration() ? await migrateLayout(dryRun) : null;
|
|
46
|
-
if (dryRun && layout !== null) {
|
|
47
|
-
return { layout_resolutions: layout.resolutions, layout_absent_credentials: layout.absentCredentials, dryRun, follow_up: 'Preview only — re-run without --dry-run to migrate the layout; the canvas import is planned after it.' };
|
|
48
|
-
}
|
|
49
|
-
// The layout run is offline: no daemon owns this volume yet.
|
|
50
|
-
if (layout !== null) {
|
|
51
|
-
return {
|
|
52
|
-
layout_moved: layout.moved,
|
|
53
|
-
layout_resolutions: layout.resolutions,
|
|
54
|
-
layout_absent_credentials: layout.absentCredentials,
|
|
55
|
-
dryRun,
|
|
56
|
-
follow_up: 'Layout migrated. Start the daemon (in a container, `docker compose exec`), then run `crtr sys migrate --dry-run` against it to plan the canvas import.',
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
let report;
|
|
60
|
-
try {
|
|
61
|
-
report = await cliClient().migrateState({ dry_run: dryRun });
|
|
62
|
-
}
|
|
63
|
-
catch (error) {
|
|
64
|
-
rethrowAsCliError(error);
|
|
65
|
-
}
|
|
66
|
-
if (report.blockers.length > 0) {
|
|
67
|
-
throw general(`canvas import blocked by ${report.blockers.length} finding(s) — nothing was written`, {
|
|
68
|
-
received: report,
|
|
69
|
-
next: 'Do what received.blockers[].message says, then run `crtr sys migrate` again.',
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
return {
|
|
73
|
-
...report,
|
|
74
|
-
follow_up: !report.pending
|
|
75
|
-
? (dryRun ? 'Already imported — this is the recorded report.' : undefined)
|
|
76
|
-
: 'Preview only — re-run without --dry-run to import.',
|
|
77
|
-
};
|
|
78
|
-
},
|
|
79
|
-
});
|