@cleocode/core 2026.9.16 → 2026.9.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (216) hide show
  1. package/dist/changesets/parser.d.ts.map +1 -1
  2. package/dist/changesets/parser.js +67 -0
  3. package/dist/changesets/parser.js.map +1 -1
  4. package/dist/crypto/credentials.d.ts +128 -26
  5. package/dist/crypto/credentials.d.ts.map +1 -1
  6. package/dist/crypto/credentials.js +183 -142
  7. package/dist/crypto/credentials.js.map +1 -1
  8. package/dist/docs/export-document.js +14705 -12949
  9. package/dist/docs/export-document.js.map +3 -3
  10. package/dist/doctor/index.d.ts +1 -1
  11. package/dist/doctor/index.d.ts.map +1 -1
  12. package/dist/doctor/index.js +1 -1
  13. package/dist/doctor/index.js.map +1 -1
  14. package/dist/doctor/nexus-schema-residency.d.ts +1 -1
  15. package/dist/doctor/nexus-schema-residency.d.ts.map +1 -1
  16. package/dist/doctor/nexus-schema-residency.js +1 -0
  17. package/dist/doctor/nexus-schema-residency.js.map +1 -1
  18. package/dist/doctor/project-identity.d.ts +124 -0
  19. package/dist/doctor/project-identity.d.ts.map +1 -0
  20. package/dist/doctor/project-identity.js +307 -0
  21. package/dist/doctor/project-identity.js.map +1 -0
  22. package/dist/doctor/superseded-store.d.ts +8 -0
  23. package/dist/doctor/superseded-store.d.ts.map +1 -1
  24. package/dist/doctor/superseded-store.js +48 -3
  25. package/dist/doctor/superseded-store.js.map +1 -1
  26. package/dist/init.d.ts +7 -0
  27. package/dist/init.d.ts.map +1 -1
  28. package/dist/init.js +17 -2
  29. package/dist/init.js.map +1 -1
  30. package/dist/internal.d.ts +5 -2
  31. package/dist/internal.d.ts.map +1 -1
  32. package/dist/internal.js +4 -2
  33. package/dist/internal.js.map +1 -1
  34. package/dist/llm/credentials-store.d.ts +10 -0
  35. package/dist/llm/credentials-store.d.ts.map +1 -1
  36. package/dist/llm/credentials-store.js +7 -1
  37. package/dist/llm/credentials-store.js.map +1 -1
  38. package/dist/llm/plugin-facade.js +13368 -1550
  39. package/dist/llm/plugin-facade.js.map +3 -3
  40. package/dist/nexus/analyze-orchestrator.d.ts +20 -3
  41. package/dist/nexus/analyze-orchestrator.d.ts.map +1 -1
  42. package/dist/nexus/analyze-orchestrator.js +159 -10
  43. package/dist/nexus/analyze-orchestrator.js.map +1 -1
  44. package/dist/nexus/assessment-store.d.ts +57 -0
  45. package/dist/nexus/assessment-store.d.ts.map +1 -0
  46. package/dist/nexus/assessment-store.js +73 -0
  47. package/dist/nexus/assessment-store.js.map +1 -0
  48. package/dist/nexus/freshness.d.ts +131 -0
  49. package/dist/nexus/freshness.d.ts.map +1 -0
  50. package/dist/nexus/freshness.js +391 -0
  51. package/dist/nexus/freshness.js.map +1 -0
  52. package/dist/nexus/graph-manifest.d.ts +88 -0
  53. package/dist/nexus/graph-manifest.d.ts.map +1 -0
  54. package/dist/nexus/graph-manifest.js +114 -0
  55. package/dist/nexus/graph-manifest.js.map +1 -0
  56. package/dist/nexus/knowledge.d.ts +21 -1
  57. package/dist/nexus/knowledge.d.ts.map +1 -1
  58. package/dist/nexus/knowledge.js +76 -37
  59. package/dist/nexus/knowledge.js.map +1 -1
  60. package/dist/nexus/path-map.d.ts +55 -0
  61. package/dist/nexus/path-map.d.ts.map +1 -0
  62. package/dist/nexus/path-map.js +87 -0
  63. package/dist/nexus/path-map.js.map +1 -0
  64. package/dist/nexus/projects-clean.d.ts +21 -28
  65. package/dist/nexus/projects-clean.d.ts.map +1 -1
  66. package/dist/nexus/projects-clean.js +168 -85
  67. package/dist/nexus/projects-clean.js.map +1 -1
  68. package/dist/nexus/query.d.ts.map +1 -1
  69. package/dist/nexus/query.js +3 -2
  70. package/dist/nexus/query.js.map +1 -1
  71. package/dist/nexus/registry-hygiene.d.ts +70 -0
  72. package/dist/nexus/registry-hygiene.d.ts.map +1 -0
  73. package/dist/nexus/registry-hygiene.js +113 -0
  74. package/dist/nexus/registry-hygiene.js.map +1 -0
  75. package/dist/nexus/registry.d.ts +2 -2
  76. package/dist/nexus/registry.d.ts.map +1 -1
  77. package/dist/nexus/registry.js +48 -12
  78. package/dist/nexus/registry.js.map +1 -1
  79. package/dist/paths.d.ts +26 -0
  80. package/dist/paths.d.ts.map +1 -1
  81. package/dist/paths.js +99 -6
  82. package/dist/paths.js.map +1 -1
  83. package/dist/render/nexus/graph/index.d.ts.map +1 -1
  84. package/dist/render/nexus/graph/index.js +8 -0
  85. package/dist/render/nexus/graph/index.js.map +1 -1
  86. package/dist/scaffold/ensure-config.d.ts +12 -3
  87. package/dist/scaffold/ensure-config.d.ts.map +1 -1
  88. package/dist/scaffold/ensure-config.js +61 -38
  89. package/dist/scaffold/ensure-config.js.map +1 -1
  90. package/dist/scaffold/project-identity.d.ts +136 -0
  91. package/dist/scaffold/project-identity.d.ts.map +1 -0
  92. package/dist/scaffold/project-identity.js +225 -0
  93. package/dist/scaffold/project-identity.js.map +1 -0
  94. package/dist/selfimprove/fix-gen.js +13319 -1556
  95. package/dist/selfimprove/fix-gen.js.map +3 -3
  96. package/dist/store/agent-api-key.d.ts +114 -0
  97. package/dist/store/agent-api-key.d.ts.map +1 -0
  98. package/dist/store/agent-api-key.js +136 -0
  99. package/dist/store/agent-api-key.js.map +1 -0
  100. package/dist/store/agent-registry-accessor.d.ts +4 -2
  101. package/dist/store/agent-registry-accessor.d.ts.map +1 -1
  102. package/dist/store/agent-registry-accessor.js +39 -89
  103. package/dist/store/agent-registry-accessor.js.map +1 -1
  104. package/dist/store/api-key-kdf.d.ts +7 -0
  105. package/dist/store/api-key-kdf.d.ts.map +1 -1
  106. package/dist/store/api-key-kdf.js +7 -0
  107. package/dist/store/api-key-kdf.js.map +1 -1
  108. package/dist/store/backup-crypto.d.ts +49 -0
  109. package/dist/store/backup-crypto.d.ts.map +1 -1
  110. package/dist/store/backup-crypto.js +154 -0
  111. package/dist/store/backup-crypto.js.map +1 -1
  112. package/dist/store/credential-transfer.d.ts +303 -0
  113. package/dist/store/credential-transfer.d.ts.map +1 -0
  114. package/dist/store/credential-transfer.js +774 -0
  115. package/dist/store/credential-transfer.js.map +1 -0
  116. package/dist/store/exodus/column-transforms.d.ts +79 -4
  117. package/dist/store/exodus/column-transforms.d.ts.map +1 -1
  118. package/dist/store/exodus/column-transforms.js +121 -4
  119. package/dist/store/exodus/column-transforms.js.map +1 -1
  120. package/dist/store/exodus/index.d.ts +1 -0
  121. package/dist/store/exodus/index.d.ts.map +1 -1
  122. package/dist/store/exodus/index.js +1 -0
  123. package/dist/store/exodus/index.js.map +1 -1
  124. package/dist/store/exodus/migrate.d.ts +17 -1
  125. package/dist/store/exodus/migrate.d.ts.map +1 -1
  126. package/dist/store/exodus/migrate.js +155 -33
  127. package/dist/store/exodus/migrate.js.map +1 -1
  128. package/dist/store/exodus/on-open.d.ts +14 -0
  129. package/dist/store/exodus/on-open.d.ts.map +1 -1
  130. package/dist/store/exodus/on-open.js +115 -6
  131. package/dist/store/exodus/on-open.js.map +1 -1
  132. package/dist/store/exodus/reconcile.d.ts +103 -0
  133. package/dist/store/exodus/reconcile.d.ts.map +1 -0
  134. package/dist/store/exodus/reconcile.js +728 -0
  135. package/dist/store/exodus/reconcile.js.map +1 -0
  136. package/dist/store/exodus/recovery.d.ts.map +1 -1
  137. package/dist/store/exodus/recovery.js +14 -2
  138. package/dist/store/exodus/recovery.js.map +1 -1
  139. package/dist/store/exodus/runtime-targets.d.ts +39 -0
  140. package/dist/store/exodus/runtime-targets.d.ts.map +1 -0
  141. package/dist/store/exodus/runtime-targets.js +63 -0
  142. package/dist/store/exodus/runtime-targets.js.map +1 -0
  143. package/dist/store/exodus/table-name-map.d.ts.map +1 -1
  144. package/dist/store/exodus/table-name-map.js +5 -0
  145. package/dist/store/exodus/table-name-map.js.map +1 -1
  146. package/dist/store/exodus/table-order.d.ts +35 -0
  147. package/dist/store/exodus/table-order.d.ts.map +1 -0
  148. package/dist/store/exodus/table-order.js +62 -0
  149. package/dist/store/exodus/table-order.js.map +1 -0
  150. package/dist/store/exodus/verify-migration.d.ts +4 -1
  151. package/dist/store/exodus/verify-migration.d.ts.map +1 -1
  152. package/dist/store/exodus/verify-migration.js +142 -10
  153. package/dist/store/exodus/verify-migration.js.map +1 -1
  154. package/dist/store/global-salt.d.ts +16 -0
  155. package/dist/store/global-salt.d.ts.map +1 -1
  156. package/dist/store/global-salt.js +22 -7
  157. package/dist/store/global-salt.js.map +1 -1
  158. package/dist/store/legacy-tasks-lineage.d.ts +86 -0
  159. package/dist/store/legacy-tasks-lineage.d.ts.map +1 -0
  160. package/dist/store/legacy-tasks-lineage.js +285 -0
  161. package/dist/store/legacy-tasks-lineage.js.map +1 -0
  162. package/dist/store/migration-manager.d.ts +27 -0
  163. package/dist/store/migration-manager.d.ts.map +1 -1
  164. package/dist/store/migration-manager.js +63 -0
  165. package/dist/store/migration-manager.js.map +1 -1
  166. package/dist/store/portable-bundle-import.d.ts +117 -0
  167. package/dist/store/portable-bundle-import.d.ts.map +1 -0
  168. package/dist/store/portable-bundle-import.js +589 -0
  169. package/dist/store/portable-bundle-import.js.map +1 -0
  170. package/dist/store/portable-bundle-relocate.d.ts +66 -0
  171. package/dist/store/portable-bundle-relocate.d.ts.map +1 -0
  172. package/dist/store/portable-bundle-relocate.js +304 -0
  173. package/dist/store/portable-bundle-relocate.js.map +1 -0
  174. package/dist/store/portable-bundle-scan.d.ts +167 -0
  175. package/dist/store/portable-bundle-scan.d.ts.map +1 -0
  176. package/dist/store/portable-bundle-scan.js +569 -0
  177. package/dist/store/portable-bundle-scan.js.map +1 -0
  178. package/dist/store/portable-bundle.d.ts +146 -0
  179. package/dist/store/portable-bundle.d.ts.map +1 -0
  180. package/dist/store/portable-bundle.js +674 -0
  181. package/dist/store/portable-bundle.js.map +1 -0
  182. package/dist/store/regenerators.d.ts +3 -1
  183. package/dist/store/regenerators.d.ts.map +1 -1
  184. package/dist/store/regenerators.js +6 -2
  185. package/dist/store/regenerators.js.map +1 -1
  186. package/dist/store/schema/cleo-global/nexus.d.ts +98 -0
  187. package/dist/store/schema/cleo-global/nexus.d.ts.map +1 -1
  188. package/dist/store/schema/cleo-global/nexus.js +19 -0
  189. package/dist/store/schema/cleo-global/nexus.js.map +1 -1
  190. package/dist/store/schema/nexus-schema.d.ts +102 -0
  191. package/dist/store/schema/nexus-schema.d.ts.map +1 -1
  192. package/dist/store/schema/nexus-schema.js +24 -0
  193. package/dist/store/schema/nexus-schema.js.map +1 -1
  194. package/dist/store/split-brain-import.d.ts +176 -0
  195. package/dist/store/split-brain-import.d.ts.map +1 -0
  196. package/dist/store/split-brain-import.js +680 -0
  197. package/dist/store/split-brain-import.js.map +1 -0
  198. package/dist/store/sqlite.d.ts +29 -0
  199. package/dist/store/sqlite.d.ts.map +1 -1
  200. package/dist/store/sqlite.js +57 -5
  201. package/dist/store/sqlite.js.map +1 -1
  202. package/dist/system/health.d.ts.map +1 -1
  203. package/dist/system/health.js +30 -5
  204. package/dist/system/health.js.map +1 -1
  205. package/dist/upgrade.d.ts.map +1 -1
  206. package/dist/upgrade.js +60 -0
  207. package/dist/upgrade.js.map +1 -1
  208. package/dist/validation/doctor/checks.d.ts +14 -0
  209. package/dist/validation/doctor/checks.d.ts.map +1 -1
  210. package/dist/validation/doctor/checks.js +33 -0
  211. package/dist/validation/doctor/checks.js.map +1 -1
  212. package/migrations/drizzle-cleo-global/20260924000000_t12354-project-paths/migration.sql +40 -0
  213. package/migrations/drizzle-nexus/20260924000000_t12315-nexus-parse-cache/migration.sql +21 -0
  214. package/package.json +13 -13
  215. package/templates/CLEO-INJECTION.md +3 -3
  216. package/templates/cleo-gitignore +7 -0
@@ -0,0 +1,117 @@
1
+ /**
2
+ * portable-bundle-import.ts — import side of the lossless machine-migration
3
+ * bundle (manifest v2).
4
+ *
5
+ * Order of operations (nothing is placed until everything is verified):
6
+ * 1. decrypt (streamed) and extract into a staging directory;
7
+ * 2. verify the manifest self-hash, every file's size + SHA-256, and
8
+ * `PRAGMA integrity_check` on every database;
9
+ * 3. resolve destinations (`--target` for a single project, `--map`
10
+ * prefix rewrites, else the original paths) and refuse to overwrite
11
+ * live data without `force`;
12
+ * 4. relocate the STAGED copies (paths, registry rows) when a project
13
+ * moves;
14
+ * 5. place files and databases (tmp + rename, stale WAL sidecars removed);
15
+ * 6. re-count every table of every placed database and compare with the
16
+ * manifest — any mismatch fails the import;
17
+ * 7. encrypted bundles: unseal the passphrase-sealed credentials and
18
+ * re-encrypt each under the TARGET home's machine-key (the bundle never
19
+ * carries the source machine-key), reporting any that must be re-entered.
20
+ *
21
+ * @task T12318
22
+ * @epic T12317
23
+ * @module store/portable-bundle-import
24
+ */
25
+ import type { PortableImportResult, PortableImportSectionResult } from '@cleocode/contracts';
26
+ /** One `--map <old>=<new>` prefix rewrite. */
27
+ export interface PathMapping {
28
+ /** Old absolute prefix. */
29
+ from: string;
30
+ /** New absolute prefix. */
31
+ to: string;
32
+ }
33
+ /** Input for {@link importPortableBundle}. */
34
+ export interface ImportPortableBundleInput {
35
+ /** Bundle file. */
36
+ bundlePath: string;
37
+ /** Passphrase for encrypted bundles. */
38
+ passphrase?: string;
39
+ /** Destination project root for a single-project bundle. */
40
+ target?: string;
41
+ /** Prefix rewrites applied to project paths (longest match wins). */
42
+ maps?: readonly PathMapping[];
43
+ /** Destination global home (defaults to `getCleoHome()`). */
44
+ cleoHome?: string;
45
+ /** Destination config home (defaults to `getCleoConfigDir()`). */
46
+ configHome?: string;
47
+ /** Overwrite existing live data. */
48
+ force?: boolean;
49
+ /**
50
+ * Throw `E_RESTORE_MISMATCH` (carrying the full report) when any restored
51
+ * table count differs from the manifest, instead of returning `lossless: false`.
52
+ */
53
+ requireLossless?: boolean;
54
+ /** Directory in which to create the staging directory (defaults to the parent of `cleoHome`). */
55
+ stagingParent?: string;
56
+ /**
57
+ * Called after placement for projects whose global registry row could not be
58
+ * rewritten in a bundled global store (project-only bundles). Receives the
59
+ * projectId and new root; returns the registry outcome.
60
+ */
61
+ registerProject?: (projectId: string | null, newRoot: string) => Promise<NonNullable<PortableImportSectionResult['registry']>>;
62
+ }
63
+ /**
64
+ * Parse `--map` values (`<old>=<new>`).
65
+ *
66
+ * @param values - Raw flag values.
67
+ * @returns Parsed mappings with resolved absolute prefixes.
68
+ * @throws {PortableBundleError} `E_BUNDLE_FORMAT` on a malformed value.
69
+ */
70
+ export declare function parsePathMappings(values: readonly string[]): PathMapping[];
71
+ /**
72
+ * Apply the longest matching prefix mapping to a path.
73
+ *
74
+ * @param original - Original absolute path.
75
+ * @param maps - Mappings.
76
+ * @returns The mapped path (unchanged when nothing matches).
77
+ */
78
+ export declare function applyPathMappings(original: string, maps: readonly PathMapping[]): string;
79
+ /**
80
+ * Peek at a bundle and report whether it is a portable (manifest v2) bundle.
81
+ *
82
+ * Encrypted bundles are identified by their format version byte; unencrypted
83
+ * ones by the `format` field of their first entry, `manifest.json`.
84
+ *
85
+ * @param bundlePath - Bundle file.
86
+ * @returns `v2`, `v1`, or `unknown`.
87
+ */
88
+ export declare function detectBundleFormat(bundlePath: string): Promise<'v1' | 'v2' | 'unknown'>;
89
+ /**
90
+ * Import a portable (manifest v2) bundle.
91
+ *
92
+ * @param input - Import options.
93
+ * @returns Per-section outcomes; `lossless` is true only when every table of
94
+ * every placed database re-counts to the manifest value.
95
+ * @throws {PortableBundleError} On decrypt/format/integrity failure, existing
96
+ * live data without `force`, or an ambiguous destination.
97
+ *
98
+ * @example
99
+ * ```ts
100
+ * const r = await importPortableBundle({ bundlePath: '/b/p.cleobundle.tar.gz', target: '/new/p' });
101
+ * if (!r.lossless) throw new Error('restore is not lossless');
102
+ * ```
103
+ */
104
+ export declare function importPortableBundle(input: ImportPortableBundleInput): Promise<PortableImportResult>;
105
+ /**
106
+ * Point the ambient global registry at a relocated project: move the existing
107
+ * row (keyed by projectId) or register the project when it is absent.
108
+ *
109
+ * Uses the canonical nexus registry API against the CURRENT `getCleoHome()`,
110
+ * so callers must run it with the destination home active.
111
+ *
112
+ * @param projectId - Stable projectId from project-info.json (null when absent).
113
+ * @param newRoot - New project root.
114
+ * @returns Registry outcome.
115
+ */
116
+ export declare function registerRelocatedProject(projectId: string | null, newRoot: string): Promise<NonNullable<PortableImportSectionResult['registry']>>;
117
+ //# sourceMappingURL=portable-bundle-import.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"portable-bundle-import.d.ts","sourceRoot":"","sources":["../../src/store/portable-bundle-import.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAMH,OAAO,KAAK,EAIV,oBAAoB,EACpB,2BAA2B,EAK5B,MAAM,qBAAqB,CAAC;AAyB7B,8CAA8C;AAC9C,MAAM,WAAW,WAAW;IAC1B,2BAA2B;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,2BAA2B;IAC3B,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,8CAA8C;AAC9C,MAAM,WAAW,yBAAyB;IACxC,mBAAmB;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,wCAAwC;IACxC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,4DAA4D;IAC5D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,qEAAqE;IACrE,IAAI,CAAC,EAAE,SAAS,WAAW,EAAE,CAAC;IAC9B,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kEAAkE;IAClE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oCAAoC;IACpC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,iGAAiG;IACjG,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,eAAe,CAAC,EAAE,CAChB,SAAS,EAAE,MAAM,GAAG,IAAI,EACxB,OAAO,EAAE,MAAM,KACZ,OAAO,CAAC,WAAW,CAAC,2BAA2B,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;CACpE;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,WAAW,EAAE,CAW1E;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,WAAW,EAAE,GAAG,MAAM,CAQxF;AAED;;;;;;;;GAQG;AACH,wBAAsB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,GAAG,SAAS,CAAC,CAqC7F;AA+UD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,yBAAyB,GAC/B,OAAO,CAAC,oBAAoB,CAAC,CAkM/B;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,wBAAwB,CAC5C,SAAS,EAAE,MAAM,GAAG,IAAI,EACxB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,WAAW,CAAC,2BAA2B,CAAC,UAAU,CAAC,CAAC,CAAC,CAkB/D"}