knarr 0.1.3 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/README.md +1 -1
  2. package/dist/add-Clbi3vJ2.mjs +3 -0
  3. package/dist/add-flow-DdDziP5M.mjs +5 -0
  4. package/dist/batch-push-pVkjhRbp.mjs +3 -0
  5. package/dist/bell-BJuCym_5.mjs +11 -0
  6. package/dist/bell-CIzHg0kw.mjs +3 -0
  7. package/dist/bell-UNNirKkz.mjs +3 -0
  8. package/dist/build-detect-mSo9jKXK.mjs +3 -0
  9. package/dist/bundler-detect-Cx8_R2hT.mjs +3 -0
  10. package/dist/check-Boh8WU_W.mjs +3 -0
  11. package/dist/chokidar-BkIWf7Ix.mjs +3 -0
  12. package/dist/clean-DHh6fpmR.mjs +3 -0
  13. package/dist/cli.mjs +4 -4
  14. package/dist/config-CQpgsGyL.mjs +4 -0
  15. package/dist/console-BxhMcj-D.mjs +81 -0
  16. package/dist/console-X31Y_QS5.mjs +3 -0
  17. package/dist/dev-DeOwxr_7.mjs +3 -0
  18. package/dist/dist-CFkjiIqD.mjs +7 -0
  19. package/dist/doctor-XEdsr84Q.mjs +6 -0
  20. package/dist/dry-run-BxVjpNqJ.mjs +3 -0
  21. package/dist/errors-CV7G61Hr.mjs +3 -0
  22. package/dist/explain-BBv3U-D3.mjs +3 -0
  23. package/dist/format-DRqD29u-.mjs +3 -0
  24. package/dist/fs-BjaNhdzt.mjs +683 -0
  25. package/dist/fs-Cf1JTFyh.mjs +3 -0
  26. package/dist/fs-DUcoWJ1g.mjs +3 -0
  27. package/dist/hints-Hz3V4h3A.mjs +3 -0
  28. package/dist/history-BZS2YUIt.mjs +3 -0
  29. package/dist/history-C5ehozRy.mjs +3 -0
  30. package/dist/index.d.ts +242 -260
  31. package/dist/index.mjs +3349 -4669
  32. package/dist/init-Dwf-EIG3.mjs +4 -0
  33. package/dist/init-helpers-BfDosqvf.mjs +15 -0
  34. package/dist/injector-XwK_LBUh.mjs +3 -0
  35. package/dist/json-C6XtcMC4.mjs +46 -0
  36. package/dist/json-CWzEb9Rt.mjs +3 -0
  37. package/dist/list-DcREV9JM.mjs +3 -0
  38. package/dist/logger-DlikgOlh.mjs +3 -0
  39. package/dist/migrate-DW5KQeDq.mjs +5 -0
  40. package/dist/nextjs-config-BfHv8mBE.mjs +3 -0
  41. package/dist/nextjs-config-CA4N_9VY.mjs +4 -0
  42. package/dist/output-BxyRer_F.mjs +3 -0
  43. package/dist/package-manager-DBBQ0XtZ.mjs +13 -0
  44. package/dist/picomatch-B0_Pxgms.mjs +3 -0
  45. package/dist/preflight-B17VQJs0.mjs +3 -0
  46. package/dist/preflight-B8ypfoKV.mjs +3 -0
  47. package/dist/publish-BLk5_qx1.mjs +3 -0
  48. package/dist/publisher-Br4Od-iL.mjs +4 -0
  49. package/dist/push-C6UFcNGO.mjs +3 -0
  50. package/dist/push-engine-D3rfg2Tj.mjs +3 -0
  51. package/dist/remove-Bz9dNgDM.mjs +3 -0
  52. package/dist/remove-DMj6k2PK.mjs +3 -0
  53. package/dist/reset--AuvAPTc.mjs +3 -0
  54. package/dist/restore-CIBe2F1d.mjs +3 -0
  55. package/dist/rollback-CFLIncnW.mjs +3 -0
  56. package/dist/rolldown-runtime-BZbIAPMk.mjs +3 -0
  57. package/dist/rolldown-runtime-D3KUYPsf.mjs +12 -0
  58. package/dist/shell-RQ7Hf1kp.mjs +3 -0
  59. package/dist/status-Dy-e_RtI.mjs +3 -0
  60. package/dist/store-BNeGfW_b.mjs +3 -0
  61. package/dist/tailwind-source-Cgva0Hte.mjs +5 -0
  62. package/dist/timer-DqgB175x.mjs +3 -0
  63. package/dist/topo-sort-DOCpHjT7.mjs +3 -0
  64. package/dist/topo-sort-yd4jxr_E.mjs +3 -0
  65. package/dist/tracker-DXSo5wXO.mjs +3 -0
  66. package/dist/tracker-DofCXLTP.mjs +3 -0
  67. package/dist/update-Dacjzw4f.mjs +3 -0
  68. package/dist/use-BSCV4IQ5.mjs +3 -0
  69. package/dist/vite-config-CbYEhn5K.mjs +3 -0
  70. package/dist/vite-config-DqxvL5TW.mjs +12 -0
  71. package/dist/vite-plugin.d.ts +6 -5
  72. package/dist/vite-plugin.mjs +206 -211
  73. package/dist/watch-orchestrator-CghvwrNS.mjs +3 -0
  74. package/dist/watcher-Bw_qcI0M.mjs +3 -0
  75. package/dist/webpack-plugin.d.ts +29 -30
  76. package/dist/webpack-plugin.mjs +140 -138
  77. package/dist/workspace-D4vhzpO4.mjs +3 -0
  78. package/dist/workspace-DVY5o1g8.mjs +3 -0
  79. package/dist/xxhash-wasm-D_QjdUuv.mjs +3 -0
  80. package/package.json +21 -30
  81. package/dist/add-LQ6WMCGD.mjs +0 -3
  82. package/dist/bell-SIN4ERLS.mjs +0 -2
  83. package/dist/check-7CJHAF6Y.mjs +0 -6
  84. package/dist/chokidar-2G63V464.mjs +0 -4
  85. package/dist/chunk-3SXN6MQL.mjs +0 -4
  86. package/dist/chunk-7GCKCCHU.mjs +0 -3
  87. package/dist/chunk-BH2WXCLS.mjs +0 -4
  88. package/dist/chunk-CBOYKBSM.mjs +0 -13
  89. package/dist/chunk-E3HZCU3S.mjs +0 -5
  90. package/dist/chunk-G7HFTV5Y.mjs +0 -3
  91. package/dist/chunk-HVN6HBWZ.mjs +0 -3
  92. package/dist/chunk-ICU4V73X.mjs +0 -3
  93. package/dist/chunk-IP5ROSRE.mjs +0 -3
  94. package/dist/chunk-J6HZHQVL.mjs +0 -3
  95. package/dist/chunk-K6OAYJKS.mjs +0 -6
  96. package/dist/chunk-KRX4JX6V.mjs +0 -4
  97. package/dist/chunk-KUQULMM6.mjs +0 -3
  98. package/dist/chunk-L7O2RSTN.mjs +0 -3
  99. package/dist/chunk-M3TRMEJV.mjs +0 -3
  100. package/dist/chunk-MN4DV2NO.mjs +0 -3
  101. package/dist/chunk-N3B2JO4H.mjs +0 -13
  102. package/dist/chunk-NGPAGRK4.mjs +0 -7
  103. package/dist/chunk-NV3ASN6X.mjs +0 -3
  104. package/dist/chunk-OQDZJP55.mjs +0 -3
  105. package/dist/chunk-QEH5VHRO.mjs +0 -13
  106. package/dist/chunk-QFHYSC3K.mjs +0 -3
  107. package/dist/chunk-QHNHLR6T.mjs +0 -3
  108. package/dist/chunk-RIHOZDFW.mjs +0 -22
  109. package/dist/chunk-SMR4HT6A.mjs +0 -3
  110. package/dist/chunk-SPHWZS5P.mjs +0 -3
  111. package/dist/chunk-U6O35NZ7.mjs +0 -3
  112. package/dist/chunk-W2MMKBWU.mjs +0 -3
  113. package/dist/chunk-WBTSRLB6.mjs +0 -7
  114. package/dist/chunk-WN3DOKIM.mjs +0 -3
  115. package/dist/chunk-XDWZZBCM.mjs +0 -3
  116. package/dist/chunk-Z5K6DFA6.mjs +0 -3
  117. package/dist/clean-EJIYYQZM.mjs +0 -3
  118. package/dist/dev-WU5KB5PJ.mjs +0 -3
  119. package/dist/doctor-W2G34POC.mjs +0 -6
  120. package/dist/explain-LZLNIMVZ.mjs +0 -5
  121. package/dist/fs-NU36NNEG.mjs +0 -2
  122. package/dist/history-MLJHRV3Q.mjs +0 -2
  123. package/dist/init-SNG5LBZK.mjs +0 -7
  124. package/dist/list-4PTHMIQ4.mjs +0 -5
  125. package/dist/migrate-USY26Y5R.mjs +0 -8
  126. package/dist/nextjs-config-T5D6LOJE.mjs +0 -2
  127. package/dist/preflight-IXICTR6G.mjs +0 -2
  128. package/dist/publish-2IH7IQV4.mjs +0 -3
  129. package/dist/push-W3TM2QYK.mjs +0 -3
  130. package/dist/remove-MVQOIN2I.mjs +0 -2
  131. package/dist/reset-BTOJ54MJ.mjs +0 -3
  132. package/dist/restore-TWOOF2BN.mjs +0 -3
  133. package/dist/rollback-CFYSE5YG.mjs +0 -3
  134. package/dist/status-3ZXM3CRH.mjs +0 -4
  135. package/dist/tailwind-source-HCTY2XDU.mjs +0 -5
  136. package/dist/topo-sort-ZNGR6D7M.mjs +0 -2
  137. package/dist/tracker-QAKEXYUJ.mjs +0 -2
  138. package/dist/update-TGGCUOOO.mjs +0 -3
  139. package/dist/use-4Z5KXRVR.mjs +0 -3
  140. package/dist/vite-config-XOGAKYGQ.mjs +0 -2
  141. package/dist/watch-orchestrator-6BQYU5YS.mjs +0 -3
  142. package/dist/watcher-ES2APFH4.mjs +0 -3
  143. package/dist/workspace-T6PNO4L3.mjs +0 -2
  144. package/dist/xxhash-wasm-I6Q3T2SL.mjs +0 -3
package/dist/index.d.ts CHANGED
@@ -1,21 +1,21 @@
1
1
  interface PublishOptions {
2
- allowPrivate?: boolean;
3
- /** Whether to run prepack/postpack lifecycle hooks (default: true) */
4
- runScripts?: boolean;
5
- /** Force publish, bypassing hash comparison */
6
- force?: boolean;
7
- /** Max historical builds to keep (default: 3). Set to 0 to disable. */
8
- historyLimit?: number;
2
+ allowPrivate?: boolean;
3
+ /** Whether to run prepack/postpack lifecycle hooks (default: true) */
4
+ runScripts?: boolean;
5
+ /** Force publish, bypassing hash comparison */
6
+ force?: boolean;
7
+ /** Max historical builds to keep (default: 3). Set to 0 to disable. */
8
+ historyLimit?: number;
9
9
  }
10
10
  interface PublishResult {
11
- name: string;
12
- version: string;
13
- fileCount: number;
14
- /** True if content was unchanged and publish was skipped */
15
- skipped: boolean;
16
- contentHash: string;
17
- /** 8-char hex identifier generated on each successful publish */
18
- buildId: string;
11
+ name: string;
12
+ version: string;
13
+ fileCount: number;
14
+ /** True if content was unchanged and publish was skipped */
15
+ skipped: boolean;
16
+ contentHash: string;
17
+ /** 8-char hex identifier generated on each successful publish */
18
+ buildId: string;
19
19
  }
20
20
  /**
21
21
  * Publish a package from a directory to the Knarr store.
@@ -27,121 +27,121 @@ interface PublishResult {
27
27
  * 5. Copy files to temp dir, then atomic rename to store
28
28
  * 6. Write .knarr-meta.json
29
29
  */
30
- declare function publish(packageDir: string, options?: PublishOptions): Promise<PublishResult>;
31
-
30
+ export declare function publish(packageDir: string, options?: PublishOptions): Promise<PublishResult>;
32
31
  /** Metadata stored alongside each package in the Knarr store */
33
32
  interface KnarrMeta {
34
- schemaVersion?: number;
35
- contentHash: string;
36
- publishedAt: string;
37
- sourcePath: string;
38
- /** 8-char hex ID derived from content hash. Missing in pre-buildId store entries. */
39
- buildId?: string;
33
+ schemaVersion?: number;
34
+ contentHash: string;
35
+ publishedAt: string;
36
+ sourcePath: string;
37
+ /** 8-char hex ID derived from content hash. Missing in pre-buildId store entries. */
38
+ buildId?: string;
40
39
  }
41
40
  /** A store entry representing a published package */
42
41
  interface StoreEntry {
43
- name: string;
44
- version: string;
45
- packageDir: string;
46
- meta: KnarrMeta;
42
+ name: string;
43
+ version: string;
44
+ packageDir: string;
45
+ meta: KnarrMeta;
47
46
  }
48
47
  /** Tracks a single linked package in a consumer project */
49
48
  interface LinkEntry {
50
- version: string;
51
- contentHash: string;
52
- linkedAt: string;
53
- sourcePath: string;
54
- backupExists: boolean;
55
- packageManager: PackageManager;
56
- /** 8-char hex ID. Missing in pre-buildId state files. */
57
- buildId?: string;
49
+ version: string;
50
+ contentHash: string;
51
+ linkedAt: string;
52
+ sourcePath: string;
53
+ backupExists: boolean;
54
+ packageManager: PackageManager;
55
+ /** 8-char hex ID. Missing in pre-buildId state files. */
56
+ buildId?: string;
58
57
  }
59
58
  /** Consumer project state file (.knarr/state.json) */
60
59
  interface ConsumerState {
61
- version: "1";
62
- packageManager?: PackageManager;
63
- role?: "consumer" | "library";
64
- links: Record<string, LinkEntry>;
60
+ version: "1";
61
+ packageManager?: PackageManager;
62
+ role?: "consumer" | "library";
63
+ links: Record<string, LinkEntry>;
65
64
  }
66
65
  /** Global consumers registry (~/.knarr/consumers.json) */
67
66
  interface ConsumersRegistry {
68
- /** Maps package name → array of consumer project paths */
69
- [packageName: string]: string[];
67
+ /** Maps package name → array of consumer project paths */
68
+ [packageName: string]: string[];
70
69
  }
71
70
  type PackageManager = "npm" | "pnpm" | "yarn" | "bun";
72
71
  /** A historical build stored in the store's history directory */
73
72
  interface HistoryEntry {
74
- buildId: string;
75
- contentHash: string;
76
- publishedAt: string;
77
- sourcePath: string;
78
- /** Path to the history entry's package directory */
79
- packageDir: string;
73
+ buildId: string;
74
+ contentHash: string;
75
+ publishedAt: string;
76
+ sourcePath: string;
77
+ /** Path to the history entry's package directory */
78
+ packageDir: string;
80
79
  }
81
80
  /** Options for the watch mode */
82
81
  interface WatchOptions {
83
- /** Glob patterns to watch (default: src, lib, dist) */
84
- patterns?: string[];
85
- /** Build command to run before publishing */
86
- buildCmd?: string;
87
- /** Debounce delay in ms (default: 500) */
88
- debounce?: number;
89
- /** Minimum time between builds in ms (default: 500) */
90
- cooldown?: number;
91
- /** Ring terminal bell on push success/failure */
92
- notify?: boolean;
93
- /** Enable awaitWriteFinish for large/slow writes (auto-enabled when no buildCmd) */
94
- awaitWriteFinish?: boolean | {
95
- stabilityThreshold: number;
96
- pollInterval: number;
97
- };
82
+ /** Glob patterns to watch (default: src, lib, dist) */
83
+ patterns?: string[];
84
+ /** Build command to run before publishing */
85
+ buildCmd?: string;
86
+ /** Debounce delay in ms (default: 500) */
87
+ debounce?: number;
88
+ /** Minimum time between builds in ms (default: 500) */
89
+ cooldown?: number;
90
+ /** Ring terminal bell on push success/failure */
91
+ notify?: boolean;
92
+ /** Prefix for log lines, e.g. the package name when several watchers run (dev --all) */
93
+ label?: string;
94
+ /** Enable awaitWriteFinish for large/slow writes (auto-enabled when no buildCmd) */
95
+ awaitWriteFinish?: boolean | {
96
+ stabilityThreshold: number;
97
+ pollInterval: number;
98
+ };
98
99
  }
99
100
  /** Package.json fields we care about */
100
101
  interface PackageJson {
101
- name: string;
102
- version: string;
103
- files?: string[];
104
- bin?: string | Record<string, string>;
105
- dependencies?: Record<string, string>;
106
- devDependencies?: Record<string, string>;
107
- peerDependencies?: Record<string, string>;
108
- optionalDependencies?: Record<string, string>;
109
- peerDependenciesMeta?: Record<string, {
110
- optional?: boolean;
111
- }>;
102
+ name: string;
103
+ version: string;
104
+ files?: string[];
105
+ bin?: string | Record<string, string>;
106
+ dependencies?: Record<string, string>;
107
+ devDependencies?: Record<string, string>;
108
+ peerDependencies?: Record<string, string>;
109
+ optionalDependencies?: Record<string, string>;
110
+ peerDependenciesMeta?: Record<string, {
111
+ optional?: boolean;
112
+ }>;
113
+ main?: string;
114
+ module?: string;
115
+ exports?: unknown;
116
+ type?: string;
117
+ private?: boolean;
118
+ scripts?: Record<string, string>;
119
+ types?: string;
120
+ typings?: string;
121
+ browser?: string | Record<string, string>;
122
+ /** Corepack packageManager field, e.g. "pnpm@9.0.0" */
123
+ packageManager?: string;
124
+ publishConfig?: {
112
125
  main?: string;
113
126
  module?: string;
114
127
  exports?: unknown;
115
- type?: string;
116
- private?: boolean;
117
- scripts?: Record<string, string>;
118
128
  types?: string;
119
129
  typings?: string;
120
130
  browser?: string | Record<string, string>;
121
- /** Corepack packageManager field, e.g. "pnpm@9.0.0" */
122
- packageManager?: string;
123
- publishConfig?: {
124
- main?: string;
125
- module?: string;
126
- exports?: unknown;
127
- types?: string;
128
- typings?: string;
129
- browser?: string | Record<string, string>;
130
- bin?: string | Record<string, string>;
131
- directory?: string;
132
- };
131
+ bin?: string | Record<string, string>;
132
+ directory?: string;
133
+ };
133
134
  }
134
-
135
135
  interface InjectResult {
136
- copied: number;
137
- removed: number;
138
- skipped: number;
139
- binLinks: number;
140
- cacheInvalidations: number;
136
+ copied: number;
137
+ removed: number;
138
+ skipped: number;
139
+ binLinks: number;
140
+ cacheInvalidations: number;
141
141
  }
142
142
  interface InjectOptions {
143
- /** Force copy all files, bypassing hash comparison */
144
- force?: boolean;
143
+ /** Force copy all files, bypassing hash comparison */
144
+ force?: boolean;
145
145
  }
146
146
  /**
147
147
  * Inject a package from the store into a consumer's node_modules.
@@ -150,200 +150,193 @@ interface InjectOptions {
150
150
  * - pnpm: follow .pnpm/ structure
151
151
  * - yarn with nodeLinker: pnpm: follow .store/ structure
152
152
  */
153
- declare function inject(storeEntry: StoreEntry, consumerPath: string, pm: PackageManager, options?: InjectOptions): Promise<InjectResult>;
153
+ export declare function inject(storeEntry: StoreEntry, consumerPath: string, pm: PackageManager, options?: InjectOptions): Promise<InjectResult>;
154
154
  /**
155
155
  * Back up the existing installed version of a package before overwriting.
156
156
  */
157
- declare function backupExisting(consumerPath: string, packageName: string, pm: PackageManager): Promise<boolean>;
157
+ export declare function backupExisting(consumerPath: string, packageName: string, pm: PackageManager): Promise<boolean>;
158
158
  /**
159
159
  * Restore a backed-up package to node_modules.
160
160
  */
161
- declare function restoreBackup(consumerPath: string, packageName: string, pm: PackageManager, version?: string): Promise<boolean>;
161
+ export declare function restoreBackup(consumerPath: string, packageName: string, pm: PackageManager, version?: string): Promise<boolean>;
162
162
  /**
163
163
  * Remove an injected package from node_modules.
164
164
  */
165
- declare function removeInjected(consumerPath: string, packageName: string, pm: PackageManager, version?: string): Promise<void>;
165
+ export declare function removeInjected(consumerPath: string, packageName: string, pm: PackageManager, version?: string): Promise<void>;
166
166
  /**
167
167
  * Check for missing transitive dependencies.
168
168
  * Returns a list of dependency names that are in the linked package's
169
169
  * dependencies but not installed in the consumer's node_modules.
170
170
  */
171
- declare function checkMissingDeps(storeEntry: StoreEntry, consumerPath: string, pm?: PackageManager): Promise<string[]>;
172
-
171
+ export declare function checkMissingDeps(storeEntry: StoreEntry, consumerPath: string, pm?: PackageManager): Promise<string[]>;
173
172
  /** Get a store entry if it exists */
174
- declare function getStoreEntry(name: string, version: string): Promise<StoreEntry | null>;
173
+ export declare function getStoreEntry(name: string, version: string): Promise<StoreEntry | null>;
175
174
  /** Find a store entry by name (any version). Returns the latest by publishedAt. */
176
- declare function findStoreEntry(name: string): Promise<StoreEntry | null>;
175
+ export declare function findStoreEntry(name: string): Promise<StoreEntry | null>;
177
176
  /** List all entries in the store */
178
- declare function listStoreEntries(): Promise<StoreEntry[]>;
179
-
177
+ export declare function listStoreEntries(): Promise<StoreEntry[]>;
180
178
  /** Read the consumer state file, or return an empty state if not found */
181
- declare function readConsumerState(consumerPath: string): Promise<ConsumerState>;
179
+ export declare function readConsumerState(consumerPath: string): Promise<ConsumerState>;
182
180
  /**
183
181
  * Read consumer state with reliability information.
184
182
  * Returns `reliable: true` when the state is trustworthy (valid file or ENOENT).
185
183
  * Returns `reliable: false` when the file exists but is corrupt/unreadable,
186
184
  * meaning the consumer might have links we can't see.
187
185
  */
188
- declare function readConsumerStateSafe(consumerPath: string): Promise<{
189
- state: ConsumerState;
190
- reliable: boolean;
186
+ export declare function readConsumerStateSafe(consumerPath: string): Promise<{
187
+ state: ConsumerState;
188
+ reliable: boolean;
191
189
  }>;
192
190
  /** Add or update a link entry in the consumer state */
193
- declare function addLink(consumerPath: string, packageName: string, entry: LinkEntry): Promise<void>;
191
+ export declare function addLink(consumerPath: string, packageName: string, entry: LinkEntry): Promise<void>;
194
192
  /** Remove a link entry from the consumer state */
195
- declare function removeLink(consumerPath: string, packageName: string): Promise<void>;
193
+ export declare function removeLink(consumerPath: string, packageName: string): Promise<void>;
196
194
  /** Get a specific link entry */
197
- declare function getLink(consumerPath: string, packageName: string): Promise<LinkEntry | null>;
195
+ export declare function getLink(consumerPath: string, packageName: string): Promise<LinkEntry | null>;
198
196
  /** Register a consumer for a package */
199
- declare function registerConsumer(packageName: string, consumerPath: string): Promise<void>;
197
+ export declare function registerConsumer(packageName: string, consumerPath: string): Promise<void>;
200
198
  /** Unregister a consumer for a package */
201
- declare function unregisterConsumer(packageName: string, consumerPath: string): Promise<void>;
199
+ export declare function unregisterConsumer(packageName: string, consumerPath: string): Promise<void>;
202
200
  /** Get all consumers for a package */
203
- declare function getConsumers(packageName: string): Promise<string[]>;
201
+ export declare function getConsumers(packageName: string): Promise<string[]>;
204
202
  /**
205
203
  * Clean stale consumers — remove registrations for directories that no longer exist.
206
204
  * Returns the number of stale entries removed.
207
205
  */
208
- declare function cleanStaleConsumers(): Promise<{
209
- removedConsumers: number;
210
- removedPackages: number;
211
- removedMissingLinks: number;
212
- skippedUnreliableConsumers: number;
206
+ export declare function cleanStaleConsumers(): Promise<{
207
+ removedConsumers: number;
208
+ removedPackages: number;
209
+ removedMissingLinks: number;
210
+ skippedUnreliableConsumers: number;
213
211
  }>;
214
- declare function cleanStaleConsumers(options: {
215
- removeMissingLinks?: boolean;
212
+ export declare function cleanStaleConsumers(options: {
213
+ removeMissingLinks?: boolean;
216
214
  }): Promise<{
217
- removedConsumers: number;
218
- removedPackages: number;
219
- removedMissingLinks: number;
220
- skippedUnreliableConsumers: number;
215
+ removedConsumers: number;
216
+ removedPackages: number;
217
+ removedMissingLinks: number;
218
+ skippedUnreliableConsumers: number;
221
219
  }>;
222
-
223
220
  /**
224
221
  * knarr configuration stored in package.json under the "knarr" key.
225
222
  * Provides persistent defaults for watch/build/dev behavior.
226
223
  */
227
224
  interface KnarrConfig {
228
- buildCmd?: string;
229
- watchPatterns?: string[];
230
- debounce?: number;
231
- cooldown?: number;
232
- historyLimit?: number;
233
- notify?: boolean;
225
+ buildCmd?: string;
226
+ watchPatterns?: string[];
227
+ debounce?: number;
228
+ cooldown?: number;
229
+ historyLimit?: number;
230
+ notify?: boolean;
234
231
  }
235
232
  /**
236
- * Load knarr configuration from package.json#knarr.
233
+ * Load knarr configuration from package.json#knarr. Every field is validated:
234
+ * wrong types are ignored rather than trusted.
237
235
  */
238
- declare function loadKnarrConfig(projectDir: string): Promise<KnarrConfig>;
239
-
236
+ export declare function loadKnarrConfig(projectDir: string): Promise<KnarrConfig>;
240
237
  /**
241
238
  * Simple timer for measuring command execution time.
242
239
  */
243
- declare class Timer {
244
- private start;
245
- /** Return elapsed time in ms */
246
- elapsedMs(): number;
247
- /** Return human-readable elapsed time (e.g., "1.2s" or "150ms") */
248
- elapsed(): string;
240
+ export declare class Timer {
241
+ private start;
242
+ /** Return elapsed time in ms */
243
+ elapsedMs(): number;
244
+ /** Return human-readable elapsed time (e.g., "1.2s" or "150ms") */
245
+ elapsed(): string;
249
246
  }
250
-
251
247
  interface PushOptions {
252
- runScripts?: boolean;
253
- /** Force copy all files, bypassing hash comparison */
254
- force?: boolean;
255
- /** Max historical builds to keep per package */
256
- historyLimit?: number;
248
+ runScripts?: boolean;
249
+ /** Force copy all files, bypassing hash comparison */
250
+ force?: boolean;
251
+ /** Max historical builds to keep per package */
252
+ historyLimit?: number;
257
253
  }
258
254
  interface PushConsumerResult {
259
- consumerPath: string;
260
- status: "updated" | "failed" | "skipped";
261
- copied: number;
262
- removed: number;
263
- skipped: number;
264
- binLinks: number;
265
- cacheInvalidations: number;
266
- reason?: string;
267
- error?: string;
255
+ consumerPath: string;
256
+ status: "updated" | "failed" | "skipped";
257
+ copied: number;
258
+ removed: number;
259
+ skipped: number;
260
+ binLinks: number;
261
+ cacheInvalidations: number;
262
+ reason?: string;
263
+ error?: string;
268
264
  }
269
265
  interface PushSummary {
270
- name: string;
271
- version: string;
272
- buildId: string;
273
- noChange: boolean;
274
- skippedReason?: string;
275
- consumers: number;
276
- updatedConsumers: number;
277
- failedConsumers: number;
278
- skippedConsumers: number;
279
- copied: number;
280
- removed: number;
281
- skipped: number;
282
- binLinks: number;
283
- cacheInvalidations: number;
284
- elapsed: number;
285
- consumerResults: PushConsumerResult[];
266
+ name: string;
267
+ version: string;
268
+ buildId: string;
269
+ noChange: boolean;
270
+ skippedReason?: string;
271
+ consumers: number;
272
+ updatedConsumers: number;
273
+ failedConsumers: number;
274
+ skippedConsumers: number;
275
+ copied: number;
276
+ removed: number;
277
+ skipped: number;
278
+ binLinks: number;
279
+ cacheInvalidations: number;
280
+ elapsed: number;
281
+ consumerResults: PushConsumerResult[];
286
282
  }
287
283
  /**
288
284
  * Publish a package to the store, then inject into all registered consumers.
289
285
  * Shared by both `push` and `dev` commands.
290
286
  */
291
- declare function doPush(packageDir: string, options?: PushOptions): Promise<PushSummary>;
287
+ export declare function doPush(packageDir: string, options?: PushOptions): Promise<PushSummary>;
292
288
  /** Common CLI args shared by push --watch and dev */
293
289
  interface WatchArgs {
294
- build?: string;
295
- "skip-build"?: boolean;
296
- debounce?: string;
297
- cooldown?: string;
298
- notify?: boolean;
299
- "no-cascade"?: boolean;
290
+ build?: string;
291
+ "skip-build"?: boolean;
292
+ debounce?: string;
293
+ cooldown?: string;
294
+ notify?: boolean;
295
+ "no-cascade"?: boolean;
300
296
  }
301
-
302
297
  interface PushAllOptions extends PushOptions {
303
- /**
304
- * Workspace packages to skip before pushing. Used by watch-mode initial
305
- * builds so a failed build does not publish stale output.
306
- */
307
- skipPackages?: Iterable<string>;
298
+ /**
299
+ * Workspace packages to skip before pushing. Used by watch-mode initial
300
+ * builds so a failed build does not publish stale output.
301
+ */
302
+ skipPackages?: Iterable<string>;
308
303
  }
309
304
  /**
310
305
  * Push all workspace packages in topological (dependency-first) order.
311
306
  * Each package is published and injected sequentially to ensure
312
307
  * dependencies are available before dependents.
313
308
  */
314
- declare function doPushAll(startDir: string, options?: PushAllOptions): Promise<void>;
315
-
309
+ export declare function doPushAll(startDir: string, options?: PushAllOptions): Promise<void>;
316
310
  /**
317
311
  * Capture the current store entry as a history entry before it gets replaced.
318
312
  * Moves the old package/ and .knarr-meta.json into history/<buildId>/.
319
313
  */
320
- declare function captureHistory(name: string, version: string, oldEntryDir: string, historyLimit?: number): Promise<void>;
314
+ export declare function captureHistory(name: string, version: string, oldEntryDir: string, historyLimit?: number): Promise<void>;
321
315
  /**
322
316
  * List all history entries for a package, sorted by publishedAt (newest first).
323
317
  */
324
- declare function listHistory(name: string, version: string): Promise<HistoryEntry[]>;
318
+ export declare function listHistory(name: string, version: string): Promise<HistoryEntry[]>;
325
319
  /**
326
320
  * Get a specific history entry by buildId.
327
321
  */
328
- declare function getHistoryEntry(name: string, version: string, buildId: string): Promise<HistoryEntry | null>;
322
+ export declare function getHistoryEntry(name: string, version: string, buildId: string): Promise<HistoryEntry | null>;
329
323
  /**
330
324
  * Restore a history entry as the current store entry.
331
325
  * Moves the history entry back to the main store position.
332
326
  */
333
- declare function restoreHistoryEntry(name: string, version: string, buildId: string, historyLimit?: number): Promise<HistoryEntry | null>;
327
+ export declare function restoreHistoryEntry(name: string, version: string, buildId: string, historyLimit?: number): Promise<HistoryEntry | null>;
334
328
  /**
335
329
  * Prune history entries to keep only the most recent `limit` entries.
336
330
  */
337
- declare function pruneHistory(name: string, version: string, limit: number): Promise<number>;
331
+ export declare function pruneHistory(name: string, version: string, limit: number): Promise<number>;
338
332
  /**
339
333
  * Remove all history for a package.
340
334
  */
341
- declare function clearHistory(name: string, version: string): Promise<void>;
335
+ export declare function clearHistory(name: string, version: string): Promise<void>;
342
336
  /** Resolve the effective history limit from config or default */
343
- declare function resolveHistoryLimit(configValue?: number): number;
344
-
337
+ export declare function resolveHistoryLimit(configValue?: number): number;
345
338
  /** Kill the active build process if one is running */
346
- declare function killActiveBuild(): void;
339
+ export declare function killActiveBuild(): void;
347
340
  /**
348
341
  * Start watching a directory for changes and trigger a callback.
349
342
  *
@@ -353,14 +346,13 @@ declare function killActiveBuild(): void;
353
346
  * - If a push is already running when new changes arrive, a re-push is queued
354
347
  * so the final state is always pushed
355
348
  */
356
- declare function startWatcher(watchDir: string, options: WatchOptions, onChange: () => Promise<void>): Promise<{
357
- close: () => Promise<void>;
349
+ export declare function startWatcher(watchDir: string, options: WatchOptions, onChange: () => Promise<void>): Promise<{
350
+ close: () => Promise<void>;
358
351
  }>;
359
352
  /**
360
353
  * Run a build command and return true if it succeeds.
361
354
  */
362
- declare function runBuildCommand(cmd: string, cwd: string): Promise<boolean>;
363
-
355
+ export declare function runBuildCommand(cmd: string, cwd: string, label?: string): Promise<boolean>;
364
356
  /**
365
357
  * Orchestrates watch mode for all workspace packages with optional
366
358
  * cascading rebuilds. When a package is pushed, its dependents in
@@ -371,25 +363,24 @@ declare function runBuildCommand(cmd: string, cwd: string): Promise<boolean>;
371
363
  * building + trigger → queued → building (coalesced)
372
364
  * queued + trigger → queued (no-op)
373
365
  */
374
- declare class WatchOrchestrator {
375
- private packages;
376
- private dependents;
377
- private cascade;
378
- private pushOptions;
379
- constructor(cascade: boolean);
380
- start(startDir: string, args: WatchArgs, pushOptions: PushOptions): Promise<void>;
381
- private onPackagePushed;
382
- private runExclusive;
383
- private requestRebuild;
384
- close(): Promise<void>;
366
+ export declare class WatchOrchestrator {
367
+ private packages;
368
+ private dependents;
369
+ private cascade;
370
+ private pushOptions;
371
+ constructor(cascade: boolean);
372
+ start(startDir: string, args: WatchArgs, pushOptions: PushOptions): Promise<void>;
373
+ private onPackagePushed;
374
+ private runExclusive;
375
+ private requestRebuild;
376
+ close(): Promise<void>;
385
377
  }
386
-
387
378
  type PackageManagerDetectionSource = "packageManager" | "lockfile" | "yarnArtifact" | "default";
388
379
  interface PackageManagerDetection {
389
- packageManager: PackageManager;
390
- source: PackageManagerDetectionSource;
391
- dir: string;
392
- file?: string;
380
+ packageManager: PackageManager;
381
+ source: PackageManagerDetectionSource;
382
+ dir: string;
383
+ file?: string;
393
384
  }
394
385
  /**
395
386
  * Detect the package manager used in a project directory.
@@ -398,20 +389,19 @@ interface PackageManagerDetection {
398
389
  * Closest match wins. Within the same directory, priority order is maintained.
399
390
  * Falls back to "npm" if nothing is found.
400
391
  */
401
- declare function detectPackageManager(projectDir: string): Promise<PackageManager>;
392
+ export declare function detectPackageManager(projectDir: string): Promise<PackageManager>;
402
393
  /**
403
394
  * Detect the package manager and return where the decision came from.
404
395
  * Useful for distinguishing an explicit npm project from the npm fallback.
405
396
  */
406
- declare function detectPackageManagerInfo(projectDir: string): Promise<PackageManagerDetection>;
407
-
397
+ export declare function detectPackageManagerInfo(projectDir: string): Promise<PackageManagerDetection>;
408
398
  /**
409
399
  * Topological sort using Kahn's algorithm.
410
400
  * Used to order workspace packages so dependencies are processed first.
411
401
  */
412
- declare class CycleError extends Error {
413
- readonly cycle: string[];
414
- constructor(cycle: string[]);
402
+ export declare class CycleError extends Error {
403
+ readonly cycle: string[];
404
+ constructor(cycle: string[]);
415
405
  }
416
406
  /**
417
407
  * Sort nodes topologically (dependency-first order).
@@ -419,77 +409,69 @@ declare class CycleError extends Error {
419
409
  * @returns Nodes in dependency-first order
420
410
  * @throws CycleError if a cycle is detected
421
411
  */
422
- declare function topoSort(graph: Map<string, Set<string>>): string[];
423
-
412
+ export declare function topoSort(graph: Map<string, Set<string>>): string[];
424
413
  interface WorkspacePackage {
425
- name: string;
426
- version: string;
427
- dir: string;
428
- pkg: PackageJson;
414
+ name: string;
415
+ version: string;
416
+ dir: string;
417
+ pkg: PackageJson;
429
418
  }
430
419
  interface WorkspaceGraph {
431
- packages: WorkspacePackage[];
432
- /** Map of package name → Set of in-workspace dependency names */
433
- adjacency: Map<string, Set<string>>;
420
+ packages: WorkspacePackage[];
421
+ /** Map of package name → Set of in-workspace dependency names */
422
+ adjacency: Map<string, Set<string>>;
434
423
  }
435
424
  /**
436
425
  * Build a workspace dependency graph for topological sorting.
437
426
  * Reads all workspace packages and builds an adjacency map of
438
427
  * in-workspace dependencies (both dependencies and devDependencies).
439
428
  */
440
- declare function buildWorkspaceGraph(startDir: string): Promise<WorkspaceGraph>;
429
+ export declare function buildWorkspaceGraph(startDir: string): Promise<WorkspaceGraph>;
441
430
  /**
442
431
  * Build a reverse adjacency map: for each package, which packages depend on it.
443
432
  * Used by WatchOrchestrator to trigger cascading rebuilds.
444
433
  */
445
- declare function buildReverseAdjacency(adjacency: Map<string, Set<string>>): Map<string, Set<string>>;
446
-
434
+ export declare function buildReverseAdjacency(adjacency: Map<string, Set<string>>): Map<string, Set<string>>;
447
435
  type PreflightSeverity = "warn" | "error";
448
436
  interface PreflightIssue {
449
- code: string;
450
- severity: PreflightSeverity;
451
- message: string;
437
+ code: string;
438
+ severity: PreflightSeverity;
439
+ message: string;
452
440
  }
453
441
  /**
454
442
  * Run pre-flight validation checks on a package before publishing.
455
443
  * Checks entry points, exports, types, and bin paths exist on disk.
456
444
  * Returns an array of issues found (empty = all good).
457
445
  */
458
- declare function runPreflightChecks(packageDir: string): Promise<PreflightIssue[]>;
459
-
446
+ export declare function runPreflightChecks(packageDir: string): Promise<PreflightIssue[]>;
460
447
  /**
461
448
  * Ring the terminal bell (BEL character).
462
449
  * Writes to stderr so it doesn't interfere with --json output on stdout.
463
450
  */
464
- declare function ringBell(enabled: boolean): void;
465
-
451
+ export declare function ringBell(enabled: boolean): void;
466
452
  /** Type guard for Node.js system errors with an error code */
467
- declare function isNodeError(err: unknown): err is NodeJS.ErrnoException;
468
-
453
+ export declare function isNodeError(err: unknown): err is NodeJS.ErrnoException;
469
454
  /** Normalize a file path to use forward slashes (for cross-platform consistency). */
470
- declare function normalizePath(p: string): string;
471
-
455
+ export declare function normalizePath(p: string): string;
472
456
  type MutationType = "copy" | "remove" | "move" | "mkdir" | "write" | "bin-link" | "bin-unlink" | "cache-invalidate" | "lock-skip" | "lifecycle-skip" | "command-skip";
473
457
  interface DryRunMutation {
474
- type: MutationType;
475
- path: string;
476
- dest?: string;
477
- detail?: string;
458
+ type: MutationType;
459
+ path: string;
460
+ dest?: string;
461
+ detail?: string;
478
462
  }
479
463
  /** Record a mutation that was skipped due to --dry-run */
480
- declare function recordMutation(mutation: DryRunMutation): void;
464
+ export declare function recordMutation(mutation: DryRunMutation): void;
481
465
  /** Print a summary of all recorded dry-run mutations */
482
- declare function printDryRunReport(): void;
466
+ export declare function printDryRunReport(): void;
483
467
  /** Reset recorded mutations (for testing) */
484
- declare function resetMutations(): void;
485
-
468
+ export declare function resetMutations(): void;
486
469
  /**
487
470
  * Heuristic to detect configs that are too complex for automatic rewriting.
488
471
  * Returns null if safe to rewrite, or a reason string if too complex.
489
472
  */
490
- declare function isComplexConfig(content: string): {
491
- complex: boolean;
492
- reason?: string;
473
+ export declare function isComplexConfig(content: string): {
474
+ complex: boolean;
475
+ reason?: string;
493
476
  };
494
-
495
- export { type ConsumerState, type ConsumersRegistry, CycleError, type DryRunMutation, type HistoryEntry, type InjectOptions, type InjectResult, type KnarrConfig, type KnarrMeta, type LinkEntry, type MutationType, type PackageJson, type PackageManager, type PackageManagerDetection, type PackageManagerDetectionSource, type PreflightIssue, type PreflightSeverity, type PublishOptions, type PublishResult, type PushOptions, type StoreEntry, Timer, type WatchOptions, WatchOrchestrator, type WorkspaceGraph, type WorkspacePackage, addLink, backupExisting, buildReverseAdjacency, buildWorkspaceGraph, captureHistory, checkMissingDeps, cleanStaleConsumers, clearHistory, detectPackageManager, detectPackageManagerInfo, doPush, doPushAll, findStoreEntry, getConsumers, getHistoryEntry, getLink, getStoreEntry, inject, isComplexConfig, isNodeError, killActiveBuild, listHistory, listStoreEntries, loadKnarrConfig, normalizePath, printDryRunReport, pruneHistory, publish, readConsumerState, readConsumerStateSafe, recordMutation, registerConsumer, removeInjected, removeLink, resetMutations, resolveHistoryLimit, restoreBackup, restoreHistoryEntry, ringBell, runBuildCommand, runPreflightChecks, startWatcher, topoSort, unregisterConsumer };
477
+ export type { ConsumerState, ConsumersRegistry, DryRunMutation, HistoryEntry, InjectOptions, InjectResult, KnarrConfig, KnarrMeta, LinkEntry, MutationType, PackageJson, PackageManager, PackageManagerDetection, PackageManagerDetectionSource, PreflightIssue, PreflightSeverity, PublishOptions, PublishResult, PushOptions, StoreEntry, WatchOptions, WorkspaceGraph, WorkspacePackage };