personal-bot 0.3.0 → 0.3.2

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 (256) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/README.md +1 -1
  4. package/README.zh-CN.md +1 -1
  5. package/bin/pbot-pi-acp.mjs +27 -11
  6. package/bin/pbot.mjs +1 -1
  7. package/docs/README.md +1 -1
  8. package/docs/architecture/design.md +23 -10
  9. package/docs/architecture/extensibility.md +20 -18
  10. package/docs/architecture/model-context.md +2 -2
  11. package/docs/architecture/principles.md +4 -3
  12. package/docs/guides/capabilities.md +3 -3
  13. package/docs/guides/history.md +50 -16
  14. package/docs/guides/workspace-configuration.md +31 -6
  15. package/docs/hosts/antigravity.md +2 -0
  16. package/docs/hosts/claude-code.md +1 -1
  17. package/docs/hosts/dsh.md +1 -1
  18. package/docs/hosts/pi.md +1 -1
  19. package/hooks/hooks.json +3 -0
  20. package/lib/antigravity-plugin/hooks.json +7 -0
  21. package/lib/antigravity-plugin/lib/claude.js +2 -2
  22. package/lib/antigravity-plugin/lib/extension/acp-worker.js +156 -11
  23. package/lib/antigravity-plugin/lib/extension/{plugin-runtime.d.ts → hosts/plugin-runtime.d.ts} +2 -2
  24. package/lib/antigravity-plugin/lib/extension/{plugin-runtime.js → hosts/plugin-runtime.js} +34 -8
  25. package/lib/antigravity-plugin/lib/extension/mcp.js +1113 -78
  26. package/lib/antigravity-plugin/lib/integrations/agent-resources.d.ts +1 -0
  27. package/lib/antigravity-plugin/lib/integrations/agent-resources.js +5 -1
  28. package/lib/antigravity-plugin/lib/integrations/hosts/antigravity/adapter.d.ts +6 -0
  29. package/lib/antigravity-plugin/lib/integrations/hosts/antigravity/adapter.js +171 -0
  30. package/lib/antigravity-plugin/lib/integrations/hosts/{claude.d.ts → claude/adapter.d.ts} +1 -1
  31. package/lib/antigravity-plugin/lib/integrations/hosts/{claude.js → claude/adapter.js} +32 -4
  32. package/lib/antigravity-plugin/lib/integrations/hosts/{registry.js → plugin-registry.js} +2 -2
  33. package/lib/antigravity-plugin/lib/model/history.d.ts +169 -0
  34. package/lib/antigravity-plugin/lib/model/plugin-host.d.ts +26 -0
  35. package/lib/antigravity-plugin/lib/model/workspace-config.d.ts +25 -0
  36. package/lib/antigravity-plugin/lib/plugin.js +2 -2
  37. package/lib/antigravity-plugin/lib/services/history/history-capture.d.ts +4 -0
  38. package/lib/antigravity-plugin/lib/services/history/history-capture.js +86 -0
  39. package/lib/antigravity-plugin/lib/services/history/history-index.d.ts +17 -0
  40. package/lib/antigravity-plugin/lib/services/history/history-index.js +112 -0
  41. package/lib/antigravity-plugin/lib/services/history/history-migrate.d.ts +12 -0
  42. package/lib/antigravity-plugin/lib/services/history/history-migrate.js +88 -0
  43. package/lib/antigravity-plugin/lib/services/history/summary-dimensions/monthly.d.ts +7 -0
  44. package/lib/antigravity-plugin/lib/services/history/summary-dimensions/monthly.js +121 -0
  45. package/lib/antigravity-plugin/lib/services/history/summary-dimensions/session.d.ts +7 -0
  46. package/lib/antigravity-plugin/lib/services/history/summary-dimensions/session.js +124 -0
  47. package/lib/antigravity-plugin/lib/services/history/summary-registry.d.ts +7 -0
  48. package/lib/antigravity-plugin/lib/services/history/summary-registry.js +36 -0
  49. package/lib/antigravity-plugin/lib/services/history/summary-runner.d.ts +37 -0
  50. package/lib/antigravity-plugin/lib/services/history/summary-runner.js +301 -0
  51. package/lib/antigravity-plugin/lib/services/workspace/workspace-config.d.ts +5 -1
  52. package/lib/antigravity-plugin/lib/services/workspace/workspace-config.js +75 -4
  53. package/lib/antigravity-plugin/lib/storage/file-access.d.ts +2 -0
  54. package/lib/antigravity-plugin/lib/storage/file-access.js +26 -0
  55. package/lib/antigravity-plugin/lib/storage/history-files.d.ts +54 -0
  56. package/lib/antigravity-plugin/lib/storage/history-files.js +467 -0
  57. package/lib/antigravity-plugin/lib/storage/history-format.d.ts +6 -0
  58. package/lib/antigravity-plugin/lib/storage/history-format.js +62 -0
  59. package/lib/antigravity-plugin/package.json +1 -1
  60. package/lib/antigravity-plugin/plugin.json +1 -1
  61. package/lib/antigravity-plugin/skills/provider-connections/SKILL.md +22 -12
  62. package/lib/claude.js +2 -2
  63. package/lib/client.js +21 -11
  64. package/lib/dsh.js +4 -4
  65. package/lib/extension/{acp-member.d.ts → acp/member.d.ts} +5 -5
  66. package/lib/extension/{acp-member.js → acp/member.js} +6 -6
  67. package/lib/extension/acp/worker.d.ts +1 -0
  68. package/lib/extension/acp/worker.js +384 -0
  69. package/lib/extension/acp-worker.js +156 -11
  70. package/lib/extension/{dsh → hosts/dsh}/acp-member.js +8 -8
  71. package/lib/extension/hosts/dsh/command.js +92 -0
  72. package/lib/extension/{dsh → hosts/dsh}/files.js +3 -3
  73. package/lib/extension/hosts/dsh/history.d.ts +4 -0
  74. package/lib/extension/hosts/dsh/history.js +62 -0
  75. package/lib/extension/{dsh → hosts/dsh}/management.d.ts +1 -1
  76. package/lib/extension/{dsh → hosts/dsh}/management.js +12 -10
  77. package/lib/extension/{dsh → hosts/dsh}/workspace.d.ts +3 -9
  78. package/lib/extension/{dsh → hosts/dsh}/workspace.js +32 -70
  79. package/lib/extension/{plugin-runtime.d.ts → hosts/plugin-runtime.d.ts} +2 -2
  80. package/lib/extension/{plugin-runtime.js → hosts/plugin-runtime.js} +34 -8
  81. package/lib/extension/{mcp-bridge.d.ts → mcp/bridge.d.ts} +1 -1
  82. package/lib/extension/{mcp-bridge.js → mcp/bridge.js} +4 -4
  83. package/lib/extension/{mcp-workers.d.ts → mcp/workers.d.ts} +222 -2
  84. package/lib/extension/{mcp-workers.js → mcp/workers.js} +229 -63
  85. package/lib/extension/mcp.js +1113 -78
  86. package/lib/extension/{setup-cli.js → setup/cli.js} +9 -9
  87. package/lib/integrations/acp/connection.d.ts +11 -10
  88. package/lib/integrations/acp/connection.js +6 -0
  89. package/lib/integrations/acp/harnesses/claude.js +1 -1
  90. package/lib/integrations/acp/harnesses/dsh.js +1 -1
  91. package/lib/integrations/acp/history-summary.d.ts +17 -0
  92. package/lib/integrations/acp/history-summary.js +100 -0
  93. package/lib/integrations/agent-resources.d.ts +1 -0
  94. package/lib/integrations/agent-resources.js +5 -1
  95. package/lib/integrations/hosts/antigravity/adapter.d.ts +6 -0
  96. package/lib/integrations/hosts/antigravity/adapter.js +171 -0
  97. package/lib/integrations/hosts/{claude.d.ts → claude/adapter.d.ts} +1 -1
  98. package/lib/integrations/hosts/{claude.js → claude/adapter.js} +32 -4
  99. package/lib/integrations/{dsh → hosts/dsh}/mcp.d.ts +1 -1
  100. package/lib/integrations/{dsh → hosts/dsh}/resources.d.ts +1 -1
  101. package/lib/integrations/{dsh → hosts/dsh}/resources.js +4 -4
  102. package/lib/integrations/{dsh → hosts/dsh}/schema.js +1 -1
  103. package/lib/integrations/{dsh → hosts/dsh}/skills.js +1 -1
  104. package/lib/integrations/hosts/{registry.js → plugin-registry.js} +2 -2
  105. package/lib/integrations/installation/pi-setup.js +1 -1
  106. package/lib/model/history.d.ts +133 -34
  107. package/lib/model/plugin-host.d.ts +26 -0
  108. package/lib/model/workspace-config.d.ts +25 -0
  109. package/lib/plugin.js +2 -2
  110. package/lib/services/agents/agent-run.d.ts +1 -1
  111. package/lib/services/history/history-capture.d.ts +4 -0
  112. package/lib/services/history/history-capture.js +86 -0
  113. package/lib/services/history/history-index.d.ts +16 -7
  114. package/lib/services/history/history-index.js +48 -70
  115. package/lib/services/history/history-migrate.d.ts +12 -0
  116. package/lib/services/history/history-migrate.js +88 -0
  117. package/lib/services/history/history-query.d.ts +51 -0
  118. package/lib/services/history/history-query.js +371 -0
  119. package/lib/services/history/summary-command.d.ts +20 -0
  120. package/lib/services/history/summary-command.js +68 -0
  121. package/lib/services/history/summary-dimensions/monthly.d.ts +7 -0
  122. package/lib/services/history/summary-dimensions/monthly.js +121 -0
  123. package/lib/services/history/summary-dimensions/session.d.ts +7 -0
  124. package/lib/services/history/summary-dimensions/session.js +124 -0
  125. package/lib/services/history/summary-registry.d.ts +7 -0
  126. package/lib/services/history/summary-registry.js +36 -0
  127. package/lib/services/history/summary-runner.d.ts +37 -0
  128. package/lib/services/history/summary-runner.js +301 -0
  129. package/lib/services/workspace/workspace-config.d.ts +5 -1
  130. package/lib/services/workspace/workspace-config.js +75 -4
  131. package/lib/storage/history-files.d.ts +45 -9
  132. package/lib/storage/history-files.js +373 -247
  133. package/lib/storage/history-format.d.ts +3 -12
  134. package/lib/storage/history-format.js +26 -50
  135. package/lib/tools/history/actions.d.ts +3 -68
  136. package/lib/tools/history/actions.js +7 -5
  137. package/lib/tools/history/contract.d.ts +14 -7
  138. package/lib/tools/history/contract.js +58 -18
  139. package/lib/tools/history/dsh-tool.d.ts +1 -2
  140. package/lib/tools/history/dsh-tool.js +11 -5
  141. package/lib/ui/dsh/management.js +18 -5
  142. package/package.json +1 -1
  143. package/resources/prompts/history-coordinator.md +1 -1
  144. package/resources/prompts/history-monthly-summary.md +13 -0
  145. package/resources/prompts/history-summary.md +10 -4
  146. package/resources/skills/provider-connections/SKILL.md +22 -12
  147. package/src/claude.ts +2 -2
  148. package/src/dsh.ts +4 -4
  149. package/src/extension/{acp-member.ts → acp/member.ts} +7 -7
  150. package/src/extension/{acp-worker.ts → acp/worker.ts} +131 -17
  151. package/src/extension/{dsh → hosts/dsh}/acp-member.ts +9 -9
  152. package/src/extension/hosts/dsh/command.ts +92 -0
  153. package/src/extension/{dsh → hosts/dsh}/files.ts +3 -3
  154. package/src/extension/hosts/dsh/history.ts +67 -0
  155. package/src/extension/{dsh → hosts/dsh}/management.ts +11 -9
  156. package/src/extension/{dsh → hosts/dsh}/workspace.ts +31 -50
  157. package/src/extension/{pi-acp-member.ts → hosts/pi/acp-member.ts} +9 -9
  158. package/src/extension/hosts/pi/command.ts +158 -0
  159. package/src/extension/{events.ts → hosts/pi/events.ts} +14 -4
  160. package/src/extension/hosts/pi/history.ts +45 -0
  161. package/src/extension/{lifecycle.ts → hosts/pi/lifecycle.ts} +7 -11
  162. package/src/extension/{plugin-runtime.ts → hosts/plugin-runtime.ts} +29 -9
  163. package/src/extension/{mcp-bridge.ts → mcp/bridge.ts} +5 -5
  164. package/src/extension/{mcp-workers.ts → mcp/workers.ts} +237 -64
  165. package/src/extension/{setup-cli.ts → setup/cli.ts} +11 -11
  166. package/src/integrations/acp/connection.ts +6 -0
  167. package/src/integrations/acp/harnesses/claude.ts +1 -1
  168. package/src/integrations/acp/harnesses/dsh.ts +1 -1
  169. package/src/integrations/acp/history-summary.ts +108 -0
  170. package/src/integrations/agent-resources.ts +6 -0
  171. package/src/integrations/hosts/antigravity/adapter.ts +161 -0
  172. package/src/integrations/hosts/{claude.ts → claude/adapter.ts} +28 -5
  173. package/src/integrations/{dsh → hosts/dsh}/mcp.ts +1 -1
  174. package/src/integrations/{dsh → hosts/dsh}/resources.ts +5 -5
  175. package/src/integrations/{dsh → hosts/dsh}/schema.ts +1 -1
  176. package/src/integrations/{dsh → hosts/dsh}/session.ts +2 -2
  177. package/src/integrations/{dsh → hosts/dsh}/skills.ts +1 -1
  178. package/src/integrations/{pi → hosts/pi}/mcp.ts +1 -1
  179. package/src/integrations/{pi → hosts/pi}/skills.ts +1 -1
  180. package/src/integrations/hosts/{registry.ts → plugin-registry.ts} +2 -2
  181. package/src/integrations/installation/pi-setup.ts +1 -1
  182. package/src/mcp.ts +1 -1
  183. package/src/model/history.ts +151 -26
  184. package/src/model/plugin-host.ts +26 -2
  185. package/src/model/workspace-config.ts +30 -0
  186. package/src/pbot.ts +13 -22
  187. package/src/plugin.ts +2 -2
  188. package/src/services/history/history-capture.ts +83 -0
  189. package/src/services/history/history-index.ts +48 -62
  190. package/src/services/history/history-migrate.ts +89 -0
  191. package/src/services/history/history-query.ts +415 -0
  192. package/src/services/history/summary-command.ts +69 -0
  193. package/src/services/history/summary-dimensions/monthly.ts +139 -0
  194. package/src/services/history/summary-dimensions/session.ts +149 -0
  195. package/src/services/history/summary-registry.ts +44 -0
  196. package/src/services/history/summary-runner.ts +352 -0
  197. package/src/services/workspace/workspace-config.ts +93 -5
  198. package/src/storage/history-files.ts +408 -188
  199. package/src/storage/history-format.ts +46 -60
  200. package/src/tools/history/actions.ts +8 -6
  201. package/src/tools/history/contract.ts +65 -20
  202. package/src/tools/history/dsh-tool.ts +17 -8
  203. package/src/tools/history/pi-tool.ts +21 -0
  204. package/src/tools/register.ts +3 -4
  205. package/src/ui/dsh/management.ts +27 -11
  206. package/src/ui/{confirmation.ts → pi/confirmation.ts} +1 -1
  207. package/lib/antigravity-plugin/lib/integrations/hosts/antigravity.d.ts +0 -4
  208. package/lib/antigravity-plugin/lib/integrations/hosts/antigravity.js +0 -79
  209. package/lib/extension/dsh/command.js +0 -50
  210. package/lib/extension/dsh/history.d.ts +0 -15
  211. package/lib/extension/dsh/history.js +0 -87
  212. package/lib/integrations/dsh/history-summary.d.ts +0 -11
  213. package/lib/integrations/dsh/history-summary.js +0 -36
  214. package/lib/integrations/dsh/history.d.ts +0 -16
  215. package/lib/integrations/dsh/history.js +0 -167
  216. package/lib/integrations/history-summary.d.ts +0 -4
  217. package/lib/integrations/history-summary.js +0 -32
  218. package/lib/integrations/hosts/antigravity.d.ts +0 -4
  219. package/lib/integrations/hosts/antigravity.js +0 -79
  220. package/lib/services/history/history-service.d.ts +0 -106
  221. package/lib/services/history/history-service.js +0 -242
  222. package/lib/storage/acp-history.d.ts +0 -10
  223. package/lib/storage/acp-history.js +0 -57
  224. package/src/extension/command.ts +0 -76
  225. package/src/extension/dsh/command.ts +0 -54
  226. package/src/extension/dsh/history.ts +0 -74
  227. package/src/extension/history.ts +0 -26
  228. package/src/integrations/dsh/history-summary.ts +0 -39
  229. package/src/integrations/dsh/history.ts +0 -84
  230. package/src/integrations/history-summary.ts +0 -30
  231. package/src/integrations/hosts/antigravity.ts +0 -83
  232. package/src/integrations/pi/history.ts +0 -99
  233. package/src/services/history/history-service.ts +0 -195
  234. package/src/storage/acp-history.ts +0 -49
  235. package/src/tools/history/tool.ts +0 -19
  236. /package/lib/antigravity-plugin/lib/integrations/hosts/{registry.d.ts → plugin-registry.d.ts} +0 -0
  237. /package/lib/{extension/acp-worker.d.ts → antigravity-plugin/lib/model/history.js} +0 -0
  238. /package/lib/extension/{dsh → hosts/dsh}/acp-member.d.ts +0 -0
  239. /package/lib/extension/{dsh → hosts/dsh}/command.d.ts +0 -0
  240. /package/lib/extension/{dsh → hosts/dsh}/files.d.ts +0 -0
  241. /package/lib/extension/{setup-guard.js → setup/guard.js} +0 -0
  242. /package/lib/integrations/acp/{claude.d.ts → claude-settings.d.ts} +0 -0
  243. /package/lib/integrations/acp/{claude.js → claude-settings.js} +0 -0
  244. /package/lib/integrations/{dsh → hosts/dsh}/mcp.js +0 -0
  245. /package/lib/integrations/{dsh → hosts/dsh}/messages.d.ts +0 -0
  246. /package/lib/integrations/{dsh → hosts/dsh}/messages.js +0 -0
  247. /package/lib/integrations/{dsh → hosts/dsh}/root-agents.d.ts +0 -0
  248. /package/lib/integrations/{dsh → hosts/dsh}/root-agents.js +0 -0
  249. /package/lib/integrations/{dsh → hosts/dsh}/schema.d.ts +0 -0
  250. /package/lib/integrations/{dsh → hosts/dsh}/skills.d.ts +0 -0
  251. /package/lib/integrations/hosts/{registry.d.ts → plugin-registry.d.ts} +0 -0
  252. /package/src/extension/{setup-guard.ts → setup/guard.ts} +0 -0
  253. /package/src/integrations/acp/{claude.ts → claude-settings.ts} +0 -0
  254. /package/src/integrations/{dsh → hosts/dsh}/messages.ts +0 -0
  255. /package/src/integrations/{dsh → hosts/dsh}/root-agents.ts +0 -0
  256. /package/src/integrations/{pi → hosts/pi}/agent-tools.ts +0 -0
@@ -1,3 +1,6 @@
1
+ import type { HistoryLayout } from "./workspace-config.js";
2
+ export type { HistoryLayout };
3
+ export type HistoryHost = string;
1
4
  export interface HistoryExchange {
2
5
  entryIds: string[];
3
6
  text: string;
@@ -23,44 +26,25 @@ export interface RawHistory extends HistoryIdentity {
23
26
  exchanges: (HistoryExchange & {
24
27
  id: string;
25
28
  })[];
26
- /** Ordered paths observed in the native source. Legacy exchanges can have no known path. */
29
+ /** Ordered paths observed in the native source. */
27
30
  branches: string[][];
28
31
  }
29
- export interface HistorySummary extends HistoryExchange {
30
- id: string;
31
- level: number;
32
- children: string[];
33
- ready: boolean;
34
- }
35
- export interface HistoryArchive {
36
- raw: RawHistory;
37
- /** Empty if absent; null if the derived file is unreadable. */
38
- summaries: HistorySummary[] | null;
39
- }
40
- export interface HistoryNode extends HistorySummary {
41
- kind: "session" | "exchange" | "summary";
42
- parents: string[];
32
+ export interface SummarySource {
33
+ rawIds: string[];
34
+ exchangeIds: string[];
35
+ fingerprint: string;
43
36
  }
44
- /** Query view and legacy on-disk format. New writers persist raw exchanges and summaries separately. */
45
- export interface HistoryRecord extends HistoryIdentity {
46
- name: string;
47
- nodes: HistoryNode[];
48
- }
49
- export type HistoryHost = "pi" | "dsh" | "claude";
50
- export type HistoryLocation = {
51
- host: "pi";
52
- directory: string;
53
- file?: string;
54
- } | {
55
- host: "dsh";
37
+ export interface SummaryArtifact {
38
+ id: string;
39
+ dimension: string;
40
+ host?: HistoryHost;
56
41
  sessionId?: string;
57
- };
58
- export interface HistorySource {
59
- readonly host: HistoryLocation["host"];
60
- scan(location: HistoryLocation, signal?: AbortSignal, excluded?: ReadonlySet<string>): Promise<{
61
- sessions: HistorySession[];
62
- warnings: string[];
63
- }>;
42
+ title: string;
43
+ text: string;
44
+ from: string;
45
+ to: string;
46
+ updatedAt: string;
47
+ source: SummarySource;
64
48
  }
65
49
  export interface HistorySummaryRequest {
66
50
  system: string;
@@ -68,3 +52,118 @@ export interface HistorySummaryRequest {
68
52
  maxTokens: number;
69
53
  }
70
54
  export type HistorySummarizer = (request: HistorySummaryRequest, signal: AbortSignal) => Promise<string>;
55
+ export type SummaryTaskMode = "create" | "incremental" | "rebuild";
56
+ export interface SummaryTask {
57
+ id: string;
58
+ dimension: string;
59
+ mode: SummaryTaskMode;
60
+ title: string;
61
+ host?: HistoryHost;
62
+ sessionId?: string;
63
+ from: string;
64
+ to: string;
65
+ source: SummarySource;
66
+ exchanges: readonly (HistoryExchange & {
67
+ id: string;
68
+ })[];
69
+ existing?: SummaryArtifact;
70
+ addedExchanges?: readonly (HistoryExchange & {
71
+ id: string;
72
+ })[];
73
+ sourceSummaries?: readonly SummaryArtifact[];
74
+ }
75
+ export interface SummaryPlanOptions {
76
+ force?: boolean;
77
+ summariesByDimension?: ReadonlyMap<string, ReadonlyMap<string, SummaryArtifact>>;
78
+ }
79
+ export interface SummaryPlanResult {
80
+ tasks: SummaryTask[];
81
+ skipped: number;
82
+ }
83
+ export interface SummaryDimension {
84
+ readonly id: string;
85
+ readonly title: string;
86
+ readonly description: string;
87
+ readonly requiresMonthlyLayout?: boolean;
88
+ plan(raws: readonly RawHistory[], existing: ReadonlyMap<string, SummaryArtifact>, options?: SummaryPlanOptions): SummaryPlanResult;
89
+ buildRequest(task: SummaryTask): HistorySummaryRequest;
90
+ finalize(task: SummaryTask, output: string, now: string): SummaryArtifact;
91
+ }
92
+ export interface HistoryMigrationItem {
93
+ kind: "raw" | "summary";
94
+ dimension?: string;
95
+ id: string;
96
+ from: string;
97
+ to: string;
98
+ }
99
+ export interface HistoryMigrationConflict {
100
+ kind: "raw" | "summary";
101
+ dimension?: string;
102
+ from: string;
103
+ to: string;
104
+ reason: string;
105
+ }
106
+ export interface HistoryMigrationReport {
107
+ layout: HistoryLayout;
108
+ dryRun: boolean;
109
+ moved: HistoryMigrationItem[];
110
+ skipped: HistoryMigrationConflict[];
111
+ errors: {
112
+ path: string;
113
+ error: string;
114
+ }[];
115
+ }
116
+ export interface SummaryDimensionStatus {
117
+ dimension: string;
118
+ title: string;
119
+ description: string;
120
+ total: number;
121
+ ready: number;
122
+ pendingCreate: number;
123
+ pendingIncremental: number;
124
+ pendingRebuild: number;
125
+ }
126
+ export interface HistorySummaryReminder {
127
+ rawCount: number;
128
+ pendingCount: number;
129
+ oldestRawAt: string;
130
+ latestSummaryAt?: string;
131
+ rawAgeDays: number;
132
+ daysSinceLastSummary?: number;
133
+ thresholdDays: number;
134
+ message: string;
135
+ }
136
+ export interface SummaryRunProgress {
137
+ dimension: string;
138
+ completed: number;
139
+ total: number;
140
+ currentId: string;
141
+ mode: SummaryTaskMode;
142
+ }
143
+ export interface SummaryDimensionReport {
144
+ dimension: string;
145
+ scanned: number;
146
+ skipped: number;
147
+ created: number;
148
+ incremental: number;
149
+ rebuilt: number;
150
+ failed: {
151
+ id: string;
152
+ error: string;
153
+ }[];
154
+ }
155
+ export interface SummaryRunReport {
156
+ dimensions: SummaryDimensionReport[];
157
+ durationMs: number;
158
+ warnings: string[];
159
+ }
160
+ export interface HistoryQuery {
161
+ host?: HistoryHost;
162
+ query?: string;
163
+ sessionId?: string;
164
+ dimension?: string;
165
+ from?: string;
166
+ to?: string;
167
+ offset?: number;
168
+ limit?: number;
169
+ }
@@ -1,3 +1,4 @@
1
+ import type { HistorySession } from "./history.js";
1
2
  import type { WorkspaceSkillMeta } from "./workspace-mcp.js";
2
3
  export type HostId = string;
3
4
  export type PluginHostId = string;
@@ -15,12 +16,30 @@ export interface WorkspaceContext {
15
16
  environment: WorkspaceEnvironment;
16
17
  text: string;
17
18
  }
19
+ export type HistoryCapture = {
20
+ kind: "input";
21
+ sessionId: string;
22
+ text: string;
23
+ timestamp?: string;
24
+ } | {
25
+ kind: "answer";
26
+ sessionId: string;
27
+ userText?: string;
28
+ assistantText: string;
29
+ completed: boolean;
30
+ isContinuation?: boolean;
31
+ timestamp?: string;
32
+ } | {
33
+ kind: "session";
34
+ session: HistorySession;
35
+ };
18
36
  export type HostEvent = {
19
37
  kind: "ignore";
20
38
  } | {
21
39
  kind: "inject-context";
22
40
  role: WorkspaceRole;
23
41
  localRoleOnly?: boolean;
42
+ isSessionStart?: boolean;
24
43
  cwd: string;
25
44
  raw: unknown;
26
45
  } | {
@@ -28,6 +47,10 @@ export type HostEvent = {
28
47
  skill: string;
29
48
  cwd: string;
30
49
  raw: unknown;
50
+ } | {
51
+ kind: "record-history";
52
+ cwd: string;
53
+ raw: unknown;
31
54
  };
32
55
  export interface PluginHostAdapter {
33
56
  readonly host: PluginHostId;
@@ -38,6 +61,9 @@ export interface PluginHostAdapter {
38
61
  readonly usage: string;
39
62
  resolveRoot(cwd: string, rawPayload?: unknown): Promise<string>;
40
63
  parseEvent(payload: unknown): HostEvent;
64
+ extractHistory?(event: Extract<HostEvent, {
65
+ kind: "inject-context" | "record-history";
66
+ }>): Promise<HistoryCapture | undefined>;
41
67
  formatPass(payload: unknown): Record<string, unknown>;
42
68
  formatContext(event: Extract<HostEvent, {
43
69
  kind: "inject-context";
@@ -3,16 +3,39 @@ export interface WorkspaceFeatures {
3
3
  prompts?: boolean;
4
4
  skills?: boolean;
5
5
  mcp?: boolean;
6
+ history?: boolean;
6
7
  }
7
8
  export interface ResolvedWorkspaceFeatures {
8
9
  readonly prompts: boolean;
9
10
  readonly skills: boolean;
10
11
  readonly mcp: boolean;
12
+ readonly history: boolean;
13
+ }
14
+ export interface WorkspaceSummaryConfig {
15
+ backend?: string;
16
+ model?: string;
17
+ thinking?: string;
18
+ concurrency?: number;
19
+ }
20
+ export interface ResolvedWorkspaceSummaryConfig {
21
+ readonly backend: string;
22
+ readonly model?: string;
23
+ readonly thinking?: string;
24
+ readonly concurrency: number;
25
+ }
26
+ export type HistoryLayout = "monthly" | "flat";
27
+ export interface WorkspaceHistoryConfig {
28
+ layout?: HistoryLayout;
29
+ }
30
+ export interface ResolvedWorkspaceHistoryConfig {
31
+ readonly layout: HistoryLayout;
11
32
  }
12
33
  export interface WorkspaceConfig {
13
34
  enabled?: boolean;
14
35
  features?: WorkspaceFeatures;
15
36
  acp?: AcpCommands;
37
+ summary?: WorkspaceSummaryConfig;
38
+ history?: WorkspaceHistoryConfig;
16
39
  }
17
40
  export interface WorkspaceConfiguration {
18
41
  path: string;
@@ -21,4 +44,6 @@ export interface WorkspaceConfiguration {
21
44
  error?: string;
22
45
  features?: WorkspaceFeatures;
23
46
  acp?: AcpCommands;
47
+ summary?: WorkspaceSummaryConfig;
48
+ history?: WorkspaceHistoryConfig;
24
49
  }
package/lib/plugin.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { realpathSync } from "node:fs";
2
2
  import { pathToFileURL } from "node:url";
3
3
  import { requireThat } from "./common/validation.js";
4
- import { runPluginHost } from "./extension/plugin-runtime.js";
5
- import { listPluginHosts, pluginHosts } from "./integrations/hosts/registry.js";
4
+ import { runPluginHost } from "./extension/hosts/plugin-runtime.js";
5
+ import { listPluginHosts, pluginHosts } from "./integrations/hosts/plugin-registry.js";
6
6
  export async function main(args) {
7
7
  const [host, ...rest] = args;
8
8
  const adapter = host ? pluginHosts.get(host) : undefined;
@@ -8,7 +8,7 @@ export declare class AgentRun {
8
8
  readonly generation: string;
9
9
  constructor(files: AgentFiles, id: string, generation: string);
10
10
  get current(): Readonly<AgentCycle> | undefined;
11
- get state(): "starting" | "busy" | "idle" | "stopping" | "stopped" | "error";
11
+ get state(): "error" | "starting" | "busy" | "idle" | "stopping" | "stopped";
12
12
  get pending(): number;
13
13
  get interactive(): boolean;
14
14
  accepted(requestId: string): boolean;
@@ -0,0 +1,4 @@
1
+ import type { HistoryHost } from "../../model/history.js";
2
+ import type { HistoryCapture } from "../../model/plugin-host.js";
3
+ /** Persist a host raw history observation atomically into .pbot/history/raw/. */
4
+ export declare function recordHistoryCapture(root: string, host: HistoryHost, capture: HistoryCapture): void;
@@ -0,0 +1,86 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { join } from "node:path";
3
+ import { isDeepStrictEqual } from "node:util";
4
+ import { HistoryFiles } from "../../storage/history-files.js";
5
+ import { readWorkspaceHistoryLayoutSync } from "../workspace/workspace-config.js";
6
+ import { indexHistory, orderedRawExchanges } from "./history-index.js";
7
+ function orderedExchanges(raw) {
8
+ if (!raw)
9
+ return [];
10
+ return orderedRawExchanges(raw).map(({ entryIds, text, from, to, completed }) => ({
11
+ entryIds: [...entryIds],
12
+ text,
13
+ from,
14
+ to,
15
+ completed,
16
+ }));
17
+ }
18
+ function replaceAssistantSuffix(text, assistantText) {
19
+ const marker = "\n\n助手:\n";
20
+ const index = text.lastIndexOf(marker);
21
+ if (index >= 0)
22
+ return text.slice(0, index) + marker + assistantText;
23
+ return text ? `${text}${marker}${assistantText}` : `助手:\n${assistantText}`;
24
+ }
25
+ function buildSession(host, capture, previous) {
26
+ if (capture.kind === "session") {
27
+ return capture.session.branches.length ? capture.session : undefined;
28
+ }
29
+ const timestamp = capture.timestamp ?? new Date().toISOString();
30
+ const branch = orderedExchanges(previous);
31
+ if (capture.kind === "input") {
32
+ const text = capture.text.trim();
33
+ if (!text)
34
+ return undefined;
35
+ const entryId = `${host}:${Date.now()}:${randomUUID().slice(0, 8)}`;
36
+ branch.push({
37
+ entryIds: [entryId],
38
+ text: "用户:\n" + text,
39
+ from: timestamp,
40
+ to: timestamp,
41
+ completed: false,
42
+ });
43
+ return { sessionId: capture.sessionId, name: previous?.name ?? "", branches: [branch] };
44
+ }
45
+ const assistantText = capture.assistantText.trim();
46
+ if (!assistantText)
47
+ return undefined;
48
+ const last = branch.at(-1);
49
+ if (last && (!last.completed || capture.isContinuation)) {
50
+ last.text = replaceAssistantSuffix(last.text, assistantText);
51
+ last.to = timestamp;
52
+ last.completed = capture.completed;
53
+ }
54
+ else {
55
+ const entryId = `${host}:${Date.now()}:${randomUUID().slice(0, 8)}`;
56
+ const userText = capture.userText?.trim();
57
+ branch.push({
58
+ entryIds: [entryId],
59
+ text: userText ? `用户:\n${userText}\n\n助手:\n${assistantText}` : `助手:\n${assistantText}`,
60
+ from: timestamp,
61
+ to: timestamp,
62
+ completed: capture.completed,
63
+ });
64
+ }
65
+ return { sessionId: capture.sessionId, name: previous?.name ?? "", branches: [branch] };
66
+ }
67
+ /** Persist a host raw history observation atomically into .pbot/history/raw/. */
68
+ export function recordHistoryCapture(root, host, capture) {
69
+ const sessionId = capture.kind === "session" ? capture.session.sessionId : capture.sessionId;
70
+ if (!sessionId)
71
+ return;
72
+ const layout = readWorkspaceHistoryLayoutSync(root);
73
+ const files = new HistoryFiles(join(root, ".pbot/history"), host, layout);
74
+ files.control(() => {
75
+ const previous = files.listRaw(host).find(raw => raw.sessionId === sessionId);
76
+ if (!previous && files.rawWarnings.length)
77
+ return;
78
+ const session = buildSession(host, capture, previous);
79
+ if (!session || !session.branches.length)
80
+ return;
81
+ const raw = indexHistory(session, previous, host);
82
+ if (isDeepStrictEqual(raw, previous))
83
+ return;
84
+ files.saveRaw(raw);
85
+ });
86
+ }
@@ -1,8 +1,17 @@
1
- import type { HistoryHost, HistoryRecord, HistorySession, HistorySummary, RawHistory } from "../../model/history.js";
2
- /** Only a native observation can change exchanges or establish branch order. */
1
+ import type { HistoryExchange, HistoryHost, HistorySession, RawHistory } from "../../model/history.js";
2
+ /** Merge a native session observation into its raw archive without modifying persisted order invariants. */
3
3
  export declare function indexHistory(session: HistorySession, previous?: RawHistory, host?: HistoryHost): RawHistory;
4
- /** Retire results using changed inputs before publishing a native correction. New groups need no disk write. */
5
- export declare function retainHistorySummaries(before: RawHistory, after: RawHistory, summaries: HistorySummary[]): HistorySummary[];
6
- /** The four-way tree is a query view, never the source of native branch order. */
7
- export declare function historyView(raw: RawHistory, saved?: readonly HistorySummary[] | null): HistoryRecord;
8
- export declare function historySummaries(record: HistoryRecord): HistorySummary[];
4
+ /** Return deduplicated exchanges in conversation order (branch order first, then any unbranched entries by timestamp). */
5
+ export declare function orderedRawExchanges(raw: RawHistory): (HistoryExchange & {
6
+ id: string;
7
+ })[];
8
+ export declare function rawSessionTitle(raw: RawHistory): string;
9
+ export declare function rawSessionSpan(exchanges: readonly HistoryExchange[]): {
10
+ from: string;
11
+ to: string;
12
+ completed: boolean;
13
+ };
14
+ /** Stable SHA-256 fingerprint over ordered exchange contents for exact deduplication and prefix matching. */
15
+ export declare function fingerprintExchanges(exchanges: readonly (HistoryExchange & {
16
+ id: string;
17
+ })[]): string;
@@ -1,5 +1,4 @@
1
- import { randomUUID } from "node:crypto";
2
- import { isDeepStrictEqual } from "node:util";
1
+ import { createHash, randomUUID } from "node:crypto";
3
2
  import { requireThat } from "../../common/validation.js";
4
3
  /** Each native entry has one predecessor. A shortened observation can extend a known path, not erase its prefix. */
5
4
  function mergeBranches(previous, observed, removed) {
@@ -31,9 +30,9 @@ function mergeBranches(previous, observed, removed) {
31
30
  requireThat(seen.size === parents.size, "历史分支包含循环引用。");
32
31
  return branches;
33
32
  }
34
- /** Only a native observation can change exchanges or establish branch order. */
33
+ /** Merge a native session observation into its raw archive without modifying persisted order invariants. */
35
34
  export function indexHistory(session, previous, host = previous?.host ?? "pi") {
36
- requireThat(!previous || previous.host === host && previous.sessionId === session.sessionId, "历史会话与归档来源不匹配。");
35
+ requireThat(!previous || (previous.host === host && previous.sessionId === session.sessionId), "历史会话与归档来源不匹配。");
37
36
  const id = previous?.id ?? (host === "pi" ? "" : host + "-") + randomUUID();
38
37
  const exchanges = new Map(previous?.exchanges.map(item => [item.id, item]));
39
38
  const byEnd = new Map(previous?.exchanges.map(item => [item.entryIds.at(-1), item.id]));
@@ -60,75 +59,54 @@ export function indexHistory(session, previous, host = previous?.host ?? "pi") {
60
59
  exchanges.delete(item.id);
61
60
  }
62
61
  }
63
- return { host, id, sessionId: session.sessionId, name: session.name, exchanges: [...exchanges.values()],
64
- branches: mergeBranches(previous?.branches ?? [], branches, removed) };
62
+ return {
63
+ host,
64
+ id,
65
+ sessionId: session.sessionId,
66
+ name: session.name,
67
+ exchanges: [...exchanges.values()],
68
+ branches: mergeBranches(previous?.branches ?? [], branches, removed),
69
+ };
65
70
  }
66
- function span(children) {
67
- const first = children[0], last = children.at(-1);
68
- return { entryIds: [first.entryIds[0], last.entryIds.at(-1)], from: first.from, to: last.to, completed: children.every(child => child.completed) };
69
- }
70
- /** Retire results using changed inputs before publishing a native correction. New groups need no disk write. */
71
- export function retainHistorySummaries(before, after, summaries) {
72
- const inputs = new Map(after.exchanges.map(item => [item.id, item]));
73
- const changed = new Set(before.exchanges.filter(item => !isDeepStrictEqual(item, inputs.get(item.id))).map(item => item.id));
74
- if (!changed.size || !summaries.length)
75
- return summaries;
76
- const retained = new Map();
77
- for (const item of [...summaries].sort((a, b) => a.level - b.level)) {
78
- const children = item.children.map(id => inputs.get(id));
79
- if (!children.length || !children.every(child => child !== undefined)) {
80
- changed.add(item.id);
81
- continue;
82
- }
83
- let summary = item;
84
- if (item.children.some(id => changed.has(id))) {
85
- summary = { ...item, ...span(children), text: "", ready: false };
86
- changed.add(item.id);
87
- }
88
- retained.set(item.id, summary);
89
- inputs.set(item.id, summary);
90
- }
91
- return summaries.flatMap(item => retained.get(item.id) ?? []);
92
- }
93
- /** The four-way tree is a query view, never the source of native branch order. */
94
- export function historyView(raw, saved = []) {
95
- const nodes = new Map(raw.exchanges.map(value => [value.id,
96
- { ...value, kind: "exchange", level: 0, ready: true, children: [], parents: [] }]));
97
- const stored = new Map(saved?.map(value => [value.id, value]));
98
- const groups = new Map(stored);
71
+ /** Return deduplicated exchanges in conversation order (branch order first, then any unbranched entries by timestamp). */
72
+ export function orderedRawExchanges(raw) {
73
+ const lookup = new Map(raw.exchanges.map(item => [item.id, item]));
74
+ const seen = new Set();
75
+ const ordered = [];
99
76
  for (const branch of raw.branches) {
100
- let layer = branch.map(id => ({ id, end: nodes.get(id).entryIds.at(-1) }));
101
- for (let level = 1; layer.length >= 4; level++) {
102
- const next = [];
103
- for (let i = 0; i + 4 <= layer.length; i += 4) {
104
- const end = layer[i + 3].end, id = `${raw.id}:${level}:${end}`;
105
- groups.set(id, { id, level, children: layer.slice(i, i + 4).map(child => child.id) });
106
- next.push({ id, end });
107
- }
108
- layer = next;
77
+ for (const id of branch) {
78
+ if (seen.has(id))
79
+ continue;
80
+ const item = lookup.get(id);
81
+ if (!item)
82
+ continue;
83
+ seen.add(id);
84
+ ordered.push(item);
109
85
  }
110
86
  }
111
- for (const group of [...groups.values()].sort((a, b) => a.level - b.level)) {
112
- const children = group.children.map(id => nodes.get(id));
113
- if (!children.length || !children.every(child => child !== undefined))
114
- continue;
115
- const old = stored.get(group.id);
116
- const summary = old && isDeepStrictEqual(old.children, group.children) && (!old.ready || children.every(child => child.ready)) ? old :
117
- { ...group, ...span(children), text: "", ready: false };
118
- nodes.set(group.id, { ...summary, kind: "summary", parents: [] });
119
- }
120
- for (const node of nodes.values())
121
- for (const child of node.children)
122
- nodes.get(child).parents.push(node.id);
123
- const top = [...nodes.values()].filter(node => !node.parents.length).sort((a, b) => a.from.localeCompare(b.from));
124
- for (const child of top)
125
- child.parents.push(raw.id);
126
- const dates = raw.exchanges.flatMap(item => [item.from, item.to]).sort();
127
- const name = raw.name || raw.exchanges[0]?.text.replace(/\s+/g, " ").slice(0, 80) || "";
128
- nodes.set(raw.id, { id: raw.id, kind: "session", level: -1, entryIds: [], text: name, ready: true,
129
- completed: raw.exchanges.every(item => item.completed), from: dates[0] ?? "", to: dates.at(-1) ?? "", parents: [], children: top.map(node => node.id) });
130
- return { host: raw.host, id: raw.id, sessionId: raw.sessionId, name, nodes: [...nodes.values()] };
87
+ const rest = raw.exchanges
88
+ .filter(item => !seen.has(item.id))
89
+ .sort((a, b) => a.from.localeCompare(b.from) || a.id.localeCompare(b.id));
90
+ ordered.push(...rest);
91
+ return ordered;
92
+ }
93
+ export function rawSessionTitle(raw) {
94
+ return raw.name.trim();
131
95
  }
132
- export function historySummaries(record) {
133
- return record.nodes.filter(node => node.kind === "summary").map(({ kind: _kind, parents: _parents, ...summary }) => summary);
96
+ export function rawSessionSpan(exchanges) {
97
+ const dates = exchanges.flatMap(item => [item.from, item.to]).filter(Boolean).sort();
98
+ return {
99
+ from: dates[0] ?? "",
100
+ to: dates.at(-1) ?? "",
101
+ completed: exchanges.every(item => item.completed),
102
+ };
103
+ }
104
+ /** Stable SHA-256 fingerprint over ordered exchange contents for exact deduplication and prefix matching. */
105
+ export function fingerprintExchanges(exchanges) {
106
+ const hash = createHash("sha256");
107
+ for (const item of exchanges) {
108
+ hash.update(JSON.stringify([item.id, item.entryIds, item.text, item.from, item.to, item.completed]));
109
+ hash.update("\n");
110
+ }
111
+ return hash.digest("hex");
134
112
  }
@@ -0,0 +1,12 @@
1
+ import type { HistoryMigrationReport } from "../../model/history.js";
2
+ export interface MigrateHistoryOptions {
3
+ dryRun?: boolean;
4
+ }
5
+ /** Read-only check for unmigrated flat history files when running under monthly layout. */
6
+ export declare function checkHistoryMigrationNotice(root: string): string | undefined;
7
+ /**
8
+ * Explicitly migrate flat .pbot/history/raw/*.json and .pbot/history/summaries/<dim>/*.json
9
+ * into UTC YYYY/MM/ (or unknown/) buckets. Moves files directly without keeping duplicates
10
+ * and never modifies .pbot/config.json or overwrites existing destinations.
11
+ */
12
+ export declare function migrateWorkspaceHistory(root: string, options?: MigrateHistoryOptions): HistoryMigrationReport;
@@ -0,0 +1,88 @@
1
+ import { lstatSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { requireThat } from "../../common/validation.js";
4
+ import { HistoryFiles, rawHistoryBucket, summaryArtifactBucket } from "../../storage/history-files.js";
5
+ import { readWorkspaceHistoryLayoutSync } from "../workspace/workspace-config.js";
6
+ /** Read-only check for unmigrated flat history files when running under monthly layout. */
7
+ export function checkHistoryMigrationNotice(root) {
8
+ const layout = readWorkspaceHistoryLayoutSync(root);
9
+ if (layout !== "monthly")
10
+ return undefined;
11
+ const files = new HistoryFiles(join(root, ".pbot/history"), "pi", layout);
12
+ return files.detectFlatFiles().message;
13
+ }
14
+ /**
15
+ * Explicitly migrate flat .pbot/history/raw/*.json and .pbot/history/summaries/<dim>/*.json
16
+ * into UTC YYYY/MM/ (or unknown/) buckets. Moves files directly without keeping duplicates
17
+ * and never modifies .pbot/config.json or overwrites existing destinations.
18
+ */
19
+ export function migrateWorkspaceHistory(root, options = {}) {
20
+ const layout = readWorkspaceHistoryLayoutSync(root);
21
+ requireThat(layout === "monthly", '当前工作区配置为平铺布局(history.layout: "flat"),无需迁移到年月目录;如需迁移,请先在 .pbot/config.json 中将 history.layout 设为 "monthly" 或移除该配置项。');
22
+ const dryRun = Boolean(options.dryRun);
23
+ const files = new HistoryFiles(join(root, ".pbot/history"), "pi", "monthly");
24
+ const moved = [];
25
+ const skipped = [];
26
+ const errors = [];
27
+ const run = () => {
28
+ for (const name of files.listFlatRawFiles()) {
29
+ const from = `raw/${name}`;
30
+ try {
31
+ const raw = files.readFlatRawFile(name);
32
+ const bucket = rawHistoryBucket(raw);
33
+ const to = `raw/${bucket}/${name}`;
34
+ if (dryRun) {
35
+ if (lstatSync(join(files.directory, to), { throwIfNoEntry: false })) {
36
+ skipped.push({ kind: "raw", from, to, reason: "目标路径已存在同名文件。" });
37
+ }
38
+ else {
39
+ moved.push({ kind: "raw", id: raw.id, from, to });
40
+ }
41
+ }
42
+ else {
43
+ const outcome = files.moveHistoryFile(from, to);
44
+ if (outcome === "moved")
45
+ moved.push({ kind: "raw", id: raw.id, from, to });
46
+ else
47
+ skipped.push({ kind: "raw", from, to, reason: "目标路径已存在同名文件。" });
48
+ }
49
+ }
50
+ catch (error) {
51
+ errors.push({ path: join(files.directory, from), error: error instanceof Error ? error.message : String(error) });
52
+ }
53
+ }
54
+ for (const dimension of files.listDimensions()) {
55
+ for (const name of files.listFlatSummaryFiles(dimension)) {
56
+ const from = `summaries/${dimension}/${name}`;
57
+ try {
58
+ const artifact = files.readFlatSummaryFile(dimension, name);
59
+ const bucket = summaryArtifactBucket(artifact);
60
+ const to = `summaries/${dimension}/${bucket}/${name}`;
61
+ if (dryRun) {
62
+ if (lstatSync(join(files.directory, to), { throwIfNoEntry: false })) {
63
+ skipped.push({ kind: "summary", dimension, from, to, reason: "目标路径已存在同名文件。" });
64
+ }
65
+ else {
66
+ moved.push({ kind: "summary", dimension, id: artifact.id, from, to });
67
+ }
68
+ }
69
+ else {
70
+ const outcome = files.moveHistoryFile(from, to);
71
+ if (outcome === "moved")
72
+ moved.push({ kind: "summary", dimension, id: artifact.id, from, to });
73
+ else
74
+ skipped.push({ kind: "summary", dimension, from, to, reason: "目标路径已存在同名文件。" });
75
+ }
76
+ }
77
+ catch (error) {
78
+ errors.push({ path: join(files.directory, from), error: error instanceof Error ? error.message : String(error) });
79
+ }
80
+ }
81
+ }
82
+ };
83
+ if (dryRun)
84
+ run();
85
+ else
86
+ files.controlMigration(run);
87
+ return { layout, dryRun, moved, skipped, errors };
88
+ }