autodev-cli 1.4.0 → 1.4.4

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 (237) hide show
  1. package/bin/autodev.js +0 -0
  2. package/out/agentBackup/archive.d.ts +44 -0
  3. package/out/agentBackup/archive.js +131 -0
  4. package/out/agentBackup/archive.js.map +1 -0
  5. package/out/agentBackup/export.d.ts +18 -0
  6. package/out/agentBackup/export.js +92 -0
  7. package/out/agentBackup/export.js.map +1 -0
  8. package/out/agentBackup/import.d.ts +21 -0
  9. package/out/agentBackup/import.js +40 -0
  10. package/out/agentBackup/import.js.map +1 -0
  11. package/out/agentBackup/index.d.ts +6 -0
  12. package/out/agentBackup/index.js +11 -0
  13. package/out/agentBackup/index.js.map +1 -0
  14. package/out/agentBackup/layout.d.ts +30 -0
  15. package/out/agentBackup/layout.js +126 -0
  16. package/out/agentBackup/layout.js.map +1 -0
  17. package/out/agentBackup/manifest.d.ts +24 -0
  18. package/out/agentBackup/manifest.js +70 -0
  19. package/out/agentBackup/manifest.js.map +1 -0
  20. package/out/agentBackup/opencodeDb.d.ts +20 -0
  21. package/out/agentBackup/opencodeDb.js +213 -0
  22. package/out/agentBackup/opencodeDb.js.map +1 -0
  23. package/out/agentBackup/sessionProviders.d.ts +35 -0
  24. package/out/agentBackup/sessionProviders.js +263 -0
  25. package/out/agentBackup/sessionProviders.js.map +1 -0
  26. package/out/agentBackup/upload.d.ts +9 -0
  27. package/out/agentBackup/upload.js +121 -0
  28. package/out/agentBackup/upload.js.map +1 -0
  29. package/out/cli.d.ts +1 -0
  30. package/out/cli.js +8 -0
  31. package/out/cli.js.map +1 -1
  32. package/out/cliExit.d.ts +34 -0
  33. package/out/cliExit.js +159 -0
  34. package/out/cliExit.js.map +1 -0
  35. package/out/commands/config.d.ts +2 -0
  36. package/out/commands/config.js +7 -7
  37. package/out/commands/config.js.map +1 -1
  38. package/out/commands/connect.d.ts +2 -0
  39. package/out/commands/connect.js +11 -0
  40. package/out/commands/connect.js.map +1 -1
  41. package/out/commands/export.d.ts +2 -0
  42. package/out/commands/export.js +79 -0
  43. package/out/commands/export.js.map +1 -0
  44. package/out/commands/import.d.ts +2 -0
  45. package/out/commands/import.js +92 -0
  46. package/out/commands/import.js.map +1 -0
  47. package/out/commands/init.d.ts +16 -0
  48. package/out/commands/init.js +9 -5
  49. package/out/commands/init.js.map +1 -1
  50. package/out/commands/resume.d.ts +2 -0
  51. package/out/commands/resume.js +65 -0
  52. package/out/commands/resume.js.map +1 -0
  53. package/out/commands/sessions.d.ts +2 -0
  54. package/out/commands/sessions.js +64 -0
  55. package/out/commands/sessions.js.map +1 -0
  56. package/out/commands/start.d.ts +2 -0
  57. package/out/commands/start.js +40 -7
  58. package/out/commands/start.js.map +1 -1
  59. package/out/commands/status.d.ts +2 -0
  60. package/out/commands/status.js +3 -3
  61. package/out/commands/status.js.map +1 -1
  62. package/out/commands/tailOutput.d.ts +12 -0
  63. package/out/commands/up.d.ts +3 -0
  64. package/out/configManager.d.ts +42 -0
  65. package/out/configManager.js +447 -0
  66. package/out/configManager.js.map +1 -0
  67. package/out/connect.d.ts +4 -0
  68. package/out/connect.js +7 -7
  69. package/out/connect.js.map +1 -1
  70. package/out/core/adapters.d.ts +34 -0
  71. package/out/core/adapters.js +84 -0
  72. package/out/core/adapters.js.map +1 -0
  73. package/out/core/commandHelpers.d.ts +12 -0
  74. package/out/core/commandHelpers.js +96 -0
  75. package/out/core/commandHelpers.js.map +1 -0
  76. package/out/core/projectMcp.d.ts +34 -0
  77. package/out/core/projectMcp.js +160 -0
  78. package/out/core/projectMcp.js.map +1 -0
  79. package/out/core/provider/BaseProvider.d.ts +14 -0
  80. package/out/core/provider/BaseProvider.js +25 -0
  81. package/out/core/provider/BaseProvider.js.map +1 -0
  82. package/out/core/provider/ProviderRegistry.d.ts +12 -0
  83. package/out/core/provider/ProviderRegistry.js +40 -0
  84. package/out/core/provider/ProviderRegistry.js.map +1 -0
  85. package/out/core/provider/contract.d.ts +62 -0
  86. package/out/core/provider/contract.js +9 -0
  87. package/out/core/provider/contract.js.map +1 -0
  88. package/out/core/provider/implementations.d.ts +54 -0
  89. package/out/core/provider/implementations.js +147 -0
  90. package/out/core/provider/implementations.js.map +1 -0
  91. package/out/core/settingsLoader.d.ts +221 -0
  92. package/out/core/settingsLoader.js +176 -0
  93. package/out/core/settingsLoader.js.map +1 -0
  94. package/out/discordGateway.d.ts +26 -0
  95. package/out/discordGateway.js +230 -0
  96. package/out/discordGateway.js.map +1 -0
  97. package/out/discordPoller.d.ts +28 -0
  98. package/out/discordPoller.js +247 -0
  99. package/out/discordPoller.js.map +1 -0
  100. package/out/dispatcher.d.ts +12 -0
  101. package/out/dispatcher.js +214 -0
  102. package/out/dispatcher.js.map +1 -0
  103. package/out/emailPoller.d.ts +42 -0
  104. package/out/emailPoller.js +221 -0
  105. package/out/emailPoller.js.map +1 -0
  106. package/out/git/gitService.d.ts +36 -0
  107. package/out/git/gitService.js +165 -0
  108. package/out/git/gitService.js.map +1 -0
  109. package/out/hookEventNormalizer.d.ts +39 -0
  110. package/out/hookEventNormalizer.js +397 -0
  111. package/out/hookEventNormalizer.js.map +1 -0
  112. package/out/hooksManager.d.ts +25 -0
  113. package/out/hooksManager.js +471 -0
  114. package/out/hooksManager.js.map +1 -0
  115. package/out/launchIde.d.ts +14 -0
  116. package/out/logger.d.ts +12 -0
  117. package/out/mcpEmailTest.d.ts +29 -0
  118. package/out/mcpEmailTest.js +245 -0
  119. package/out/mcpEmailTest.js.map +1 -0
  120. package/out/mcpInstallCheck.d.ts +23 -0
  121. package/out/mcpInstallCheck.js +219 -0
  122. package/out/mcpInstallCheck.js.map +1 -0
  123. package/out/mcpManager.d.ts +35 -0
  124. package/out/mcpManager.js +371 -0
  125. package/out/mcpManager.js.map +1 -0
  126. package/out/messageBuilder.d.ts +54 -0
  127. package/out/messageBuilder.js +373 -0
  128. package/out/messageBuilder.js.map +1 -0
  129. package/out/openCodeHooksManager.d.ts +23 -0
  130. package/out/openCodeHooksManager.js +511 -0
  131. package/out/openCodeHooksManager.js.map +1 -0
  132. package/out/periodicActions.d.ts +63 -0
  133. package/out/periodicActions.js +237 -0
  134. package/out/periodicActions.js.map +1 -0
  135. package/out/profileBuilder.d.ts +29 -0
  136. package/out/profileBuilder.js +366 -0
  137. package/out/profileBuilder.js.map +1 -0
  138. package/out/prompt.d.ts +12 -0
  139. package/out/prompt.js +18 -0
  140. package/out/prompt.js.map +1 -0
  141. package/out/protocolSections.d.ts +26 -0
  142. package/out/protocolSections.js +209 -0
  143. package/out/protocolSections.js.map +1 -0
  144. package/out/providers/claudeCliProvider.d.ts +71 -0
  145. package/out/providers/claudeCliProvider.js +425 -0
  146. package/out/providers/claudeCliProvider.js.map +1 -0
  147. package/out/providers/claudeTuiProvider.d.ts +23 -0
  148. package/out/providers/claudeTuiProvider.js +296 -0
  149. package/out/providers/claudeTuiProvider.js.map +1 -0
  150. package/out/providers/copilotCliProvider.d.ts +16 -0
  151. package/out/providers/copilotCliProvider.js +44 -0
  152. package/out/providers/copilotCliProvider.js.map +1 -0
  153. package/out/providers/copilotSdkProvider.d.ts +12 -0
  154. package/out/providers/copilotSdkProvider.js +445 -0
  155. package/out/providers/copilotSdkProvider.js.map +1 -0
  156. package/out/providers/grokTuiProvider.d.ts +14 -0
  157. package/out/providers/grokTuiProvider.js +271 -0
  158. package/out/providers/grokTuiProvider.js.map +1 -0
  159. package/out/providers/opencodeCliProvider.d.ts +29 -0
  160. package/out/providers/opencodeCliProvider.js +199 -0
  161. package/out/providers/opencodeCliProvider.js.map +1 -0
  162. package/out/providers/opencodeSdkProvider.d.ts +22 -0
  163. package/out/providers/opencodeSdkProvider.js +557 -0
  164. package/out/providers/opencodeSdkProvider.js.map +1 -0
  165. package/out/providers.d.ts +9 -0
  166. package/out/providers.js +44 -0
  167. package/out/providers.js.map +1 -0
  168. package/out/rateLimit.d.ts +18 -0
  169. package/out/rateLimit.js +90 -0
  170. package/out/rateLimit.js.map +1 -0
  171. package/out/rdp/auth.d.ts +55 -0
  172. package/out/rdp/auth.js +197 -0
  173. package/out/rdp/auth.js.map +1 -0
  174. package/out/rdp/bridge.d.ts +86 -0
  175. package/out/rdp/bridge.js +1398 -0
  176. package/out/rdp/bridge.js.map +1 -0
  177. package/out/rdp/constants.d.ts +86 -0
  178. package/out/rdp/constants.js +182 -0
  179. package/out/rdp/constants.js.map +1 -0
  180. package/out/rdp/index.d.ts +7 -0
  181. package/out/rdp/index.js +14 -0
  182. package/out/rdp/index.js.map +1 -0
  183. package/out/rdp/session.d.ts +30 -0
  184. package/out/rdp/session.js +196 -0
  185. package/out/rdp/session.js.map +1 -0
  186. package/out/rdp/types.d.ts +27 -0
  187. package/out/rdp/types.js +6 -0
  188. package/out/rdp/types.js.map +1 -0
  189. package/out/sdk/index.d.ts +22 -0
  190. package/out/sdk/index.js +81 -0
  191. package/out/sdk/index.js.map +1 -0
  192. package/out/sessionState.d.ts +54 -0
  193. package/out/sessionState.js +284 -0
  194. package/out/sessionState.js.map +1 -0
  195. package/out/sessions.d.ts +11 -0
  196. package/out/sessions.js +32 -0
  197. package/out/sessions.js.map +1 -0
  198. package/out/taskLoop.d.ts +152 -0
  199. package/out/taskLoop.js +2505 -0
  200. package/out/taskLoop.js.map +1 -0
  201. package/out/todo.d.ts +42 -0
  202. package/out/todo.js +311 -0
  203. package/out/todo.js.map +1 -0
  204. package/out/todoWriteManager.d.ts +26 -0
  205. package/out/todoWriteManager.js +44 -0
  206. package/out/todoWriteManager.js.map +1 -0
  207. package/out/vnc/auth.d.ts +52 -0
  208. package/out/vnc/auth.js +181 -0
  209. package/out/vnc/auth.js.map +1 -0
  210. package/out/vnc/bridge.d.ts +40 -0
  211. package/out/vnc/bridge.js +540 -0
  212. package/out/vnc/bridge.js.map +1 -0
  213. package/out/vnc/constants.d.ts +8 -0
  214. package/out/vnc/constants.js +34 -0
  215. package/out/vnc/constants.js.map +1 -0
  216. package/out/vnc/des.d.ts +6 -0
  217. package/out/vnc/des.js +93 -0
  218. package/out/vnc/des.js.map +1 -0
  219. package/out/vnc/index.d.ts +7 -0
  220. package/out/vnc/index.js +13 -0
  221. package/out/vnc/index.js.map +1 -0
  222. package/out/vnc/session.d.ts +18 -0
  223. package/out/vnc/session.js +193 -0
  224. package/out/vnc/session.js.map +1 -0
  225. package/out/vnc/types.d.ts +16 -0
  226. package/out/vnc/types.js +6 -0
  227. package/out/vnc/types.js.map +1 -0
  228. package/out/webSocketPoller.d.ts +95 -0
  229. package/out/webSocketPoller.js +986 -0
  230. package/out/webSocketPoller.js.map +1 -0
  231. package/out/webhook.d.ts +37 -0
  232. package/out/webhook.js +265 -0
  233. package/out/webhook.js.map +1 -0
  234. package/out/webhookPoller.d.ts +40 -0
  235. package/out/webhookPoller.js +378 -0
  236. package/out/webhookPoller.js.map +1 -0
  237. package/package.json +54 -41
@@ -0,0 +1,237 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.PeriodicActionManager = exports.PERIODIC_ACTIONS = void 0;
37
+ const fs = __importStar(require("fs"));
38
+ const path = __importStar(require("path"));
39
+ exports.PERIODIC_ACTIONS = [
40
+ // ─── Compact context ─────────────────────────────────────────────────────
41
+ // ⚠️ WARNING: Auto-compact can cause INFINITE LOOPS!
42
+ // When compact runs, it loads all instruction files → context fills up →
43
+ // triggers another compact → infinite loop. KEEP THIS DISABLED (0) unless
44
+ // you're using a provider with native compact that doesn't reload instructions.
45
+ // Use manual compact (sidebar button) instead of auto-compact.
46
+ {
47
+ id: 'compact',
48
+ label: 'Auto compact',
49
+ settingKey: 'compactEveryNTasks',
50
+ icon: '🗜',
51
+ type: 'compact',
52
+ prompt: '', // unused — compact is a tool action, not an AI prompt
53
+ },
54
+ // ─── Skill files ──────────────────────────────────────────────────────────
55
+ // Protocol ref: media/profile/04-skill-files.md
56
+ {
57
+ id: 'skill',
58
+ label: 'Make skill',
59
+ settingKey: 'skillEveryNTasks',
60
+ icon: '📚',
61
+ prompt: `Before continuing to the next task, update your skills based on recent learnings.
62
+ If you discovered a new best practice, anti-pattern, or gotcha worth formalizing into a skill, create or update a markdown file in .claude/skills/ named after the pattern (e.g. .claude/skills/error-handling.md). The file should contain a concise description of the pattern, when to apply it, and an example. If the pattern is a gotcha or anti-pattern, clearly explain the potential pitfall and how to avoid it.
63
+ Your skills are your personal best practices distilled from experience in this codebase — use them to level up your performance on future tasks.
64
+ Update AGENTS.md with a one-paragraph summary of the new skill and why it matters. Then continue — pick up any new tasks .
65
+
66
+ `,
67
+ },
68
+ // ─── Memory / dated files ─────────────────────────────────────────────────
69
+ // Protocol ref: media/profile/02-memory-mcp.md
70
+ {
71
+ id: 'memory',
72
+ label: 'Update memory',
73
+ settingKey: 'memoryEveryNTasks',
74
+ icon: '🧠',
75
+ prompt: `Before continuing to the next task, consolidate what you have learned from recent tasks into the dated memory file system.
76
+
77
+ For each new durable fact (architectural discovery, decision, convention, gotcha, runbook, or bug fix) from recent work:
78
+ 1. Check .autodev/MEMORY.md — if a memory file for this topic already exists, update it in place instead of creating a duplicate.
79
+ 2. Otherwise create .autodev/memories/MEMORY-YYYY-MM-DD-slug.md with format:
80
+ # slug (YYYY-MM-DD)
81
+ type: <architecture|decision|bug|convention|gotcha|runbook>
82
+
83
+ <concise fact — one paragraph max>
84
+ 3. Append one line to .autodev/MEMORY.md:
85
+ - [YYYY-MM-DD slug](memories/MEMORY-YYYY-MM-DD-slug.md)
86
+ Create .autodev/MEMORY.md with a "# Memory Index" heading if it does not exist.
87
+
88
+ Also update SUMMARY.md with any new architectural bullets, and .autodev/LESSONS.md (using dated lesson files in .autodev/lessons/) if any preventable mistakes occurred.
89
+
90
+ Do NOT store credentials in memory files — use Memory MCP for credentials. Then continue — pick up any new tasks.`,
91
+ },
92
+ // ─── Full project summary ─────────────────────────────────────────────────
93
+ // Protocol ref: media/profile/01-learning.md
94
+ {
95
+ id: 'summary',
96
+ label: 'Write summary',
97
+ settingKey: 'summaryEveryNTasks',
98
+ icon: '📋',
99
+ prompt: `Before continuing to the next task, write a comprehensive up-to-date project state summary to SUMMARY.md in the project root. Cover: current architecture overview, module map, naming conventions, key files (entry points, config, router, DB schema), exact build & run commands (dev and prod), known gotchas, recent decisions, and non-obvious dependencies. If the file already exists, update it — preserve all valid existing content and add new learnings. Keep every entry concise — one bullet per fact. Then continue — pick up any new tasks .`,
100
+ },
101
+ // ─── Prune TODO.md ──────────────────────────────────────────────────────
102
+ // Moves completed [x] lines out of TODO.md into DONE.md.
103
+ // No AI prompt — done entirely by the extension.
104
+ {
105
+ id: 'pruneTodo',
106
+ label: 'Prune TODO',
107
+ settingKey: 'pruneTodoEveryNTasks',
108
+ icon: '🧹',
109
+ type: 'pruneTodo',
110
+ prompt: '', // unused — handled by the extension, not the AI
111
+ },
112
+ // ─── Journal auto-learn ──────────────────────────────────────────────────
113
+ // Prompts the agent to review dated journal files and distil patterns into dated lesson files.
114
+ {
115
+ id: 'journalLearn',
116
+ label: 'Auto-Learn (Journal Review)',
117
+ settingKey: 'journalLearnEveryNTasks',
118
+ icon: '🔬',
119
+ type: 'prompt',
120
+ prompt: `You are performing an autonomous research journal review. Follow these steps exactly:
121
+
122
+ 1. Read .autodev/JOURNAL.md index. Open all journal files in .autodev/journals/ that do not yet have a '## Auto-learn' marker at the bottom.
123
+ 2. For each unreviewed journal file, tally:
124
+ - Any hypothesis type in 2+ 'discard' rows → recurring anti-pattern.
125
+ - Any approach in 2+ 'keep' rows → best practice worth formalising.
126
+ - Any 'keep' row with ΔC = '-' → simplification win.
127
+ - Any row where Outcome contradicted Hypothesis → knowledge gap.
128
+ 3. For each new pattern: check .autodev/LESSONS.md index — if a lesson file for this topic already exists, update it in place. Otherwise create .autodev/lessons/LESSON-YYYY-MM-DD-slug.md:
129
+ # slug (YYYY-MM-DD)
130
+ type: <anti-pattern|best-practice|simplification|knowledge-gap>
131
+
132
+ <one sentence: what it is and why it matters in this codebase>
133
+ Then append one line to .autodev/LESSONS.md:
134
+ - [YYYY-MM-DD slug](lessons/LESSON-YYYY-MM-DD-slug.md)
135
+ Create .autodev/LESSONS.md with a '# Lessons Index' heading if missing.
136
+ 4. If any pattern appears 3+ times and is actionable, check for a matching skill file in .claude/skills/. Create or update it.
137
+ 5. Append to each reviewed journal file: '## Auto-learn YYYY-MM-DD' followed by a one-sentence summary of what was learned.
138
+ 6. Commit: git add .autodev/JOURNAL.md .autodev/journals/ .autodev/LESSONS.md .autodev/lessons/ && git commit -m 'chore: auto-learn journal review'
139
+ 7. Continue immediately with the next task — do not wait or ask for confirmation.`,
140
+ },
141
+ ];
142
+ // ---------------------------------------------------------------------------
143
+ // PeriodicActionManager
144
+ // ---------------------------------------------------------------------------
145
+ class PeriodicActionManager {
146
+ _state = new Map();
147
+ _ensureState(id) {
148
+ if (!this._state.has(id)) {
149
+ this._state.set(id, { counter: 0, lastTriggeredAt: 0, lastTriggeredTime: null });
150
+ }
151
+ return this._state.get(id);
152
+ }
153
+ /** Reset all counters (call at loop start). */
154
+ reset() {
155
+ this._state.clear();
156
+ }
157
+ /**
158
+ * Reset all counters and persist the cleared state to .autodev/loop-state.json.
159
+ * Call at loop start.
160
+ */
161
+ resetAndPersist(workspaceRoot) {
162
+ this._state.clear();
163
+ if (workspaceRoot) {
164
+ this._persist(0, workspaceRoot);
165
+ }
166
+ }
167
+ /**
168
+ * Increment all action counters by 1.
169
+ * @param iteration Current loop iteration number (used for debug state).
170
+ * @param workspaceRoot If provided, persists loop-state.json to .autodev/.
171
+ */
172
+ increment(iteration, workspaceRoot) {
173
+ for (const action of exports.PERIODIC_ACTIONS) {
174
+ const s = this._ensureState(action.id);
175
+ s.counter++;
176
+ }
177
+ if (workspaceRoot) {
178
+ this._persist(iteration, workspaceRoot);
179
+ }
180
+ }
181
+ /** Returns the actions whose counter has reached or exceeded the configured interval. */
182
+ getDue(settings) {
183
+ return exports.PERIODIC_ACTIONS.filter(action => {
184
+ const interval = settings[action.settingKey] ?? 0;
185
+ if (interval <= 0) {
186
+ return false;
187
+ }
188
+ return this._ensureState(action.id).counter >= interval;
189
+ });
190
+ }
191
+ /**
192
+ * Reset the counter for a specific action after it has been handled.
193
+ * Records the iteration + timestamp it was triggered at.
194
+ */
195
+ markHandled(id, iteration, workspaceRoot) {
196
+ const s = this._ensureState(id);
197
+ s.counter = 0;
198
+ s.lastTriggeredAt = iteration;
199
+ s.lastTriggeredTime = new Date().toISOString();
200
+ if (workspaceRoot) {
201
+ this._persist(iteration, workspaceRoot);
202
+ }
203
+ }
204
+ /** Returns the current counter value for an action (for debug / display). */
205
+ getCount(id) {
206
+ return this._state.get(id)?.counter ?? 0;
207
+ }
208
+ /** Snapshot of all action states — used for debug persistence. */
209
+ snapshot() {
210
+ const out = {};
211
+ for (const [id, s] of this._state) {
212
+ out[id] = { ...s };
213
+ }
214
+ return out;
215
+ }
216
+ /**
217
+ * Write .autodev/loop-state.json with current iteration + per-action counters.
218
+ * Safe — silently ignores write errors.
219
+ */
220
+ _persist(iteration, workspaceRoot) {
221
+ try {
222
+ const dir = path.join(workspaceRoot, '.autodev');
223
+ if (!fs.existsSync(dir)) {
224
+ fs.mkdirSync(dir, { recursive: true });
225
+ }
226
+ const payload = {
227
+ iteration,
228
+ updatedAt: new Date().toISOString(),
229
+ actions: this.snapshot(),
230
+ };
231
+ fs.writeFileSync(path.join(dir, 'loop-state.json'), JSON.stringify(payload, null, 2), 'utf8');
232
+ }
233
+ catch { /* non-fatal */ }
234
+ }
235
+ }
236
+ exports.PeriodicActionManager = PeriodicActionManager;
237
+ //# sourceMappingURL=periodicActions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"periodicActions.js","sourceRoot":"","sources":["../src/periodicActions.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAqChB,QAAA,gBAAgB,GAAwB;IACnD,4EAA4E;IAC5E,sDAAsD;IACtD,yEAAyE;IACzE,0EAA0E;IAC1E,gFAAgF;IAChF,+DAA+D;IAC/D;QACE,EAAE,EAAE,SAAS;QACb,KAAK,EAAE,cAAc;QACrB,UAAU,EAAE,oBAAoB;QAChC,IAAI,EAAE,IAAI;QACV,IAAI,EAAE,SAAS;QACf,MAAM,EAAE,EAAE,EAAE,sDAAsD;KACnE;IAED,6EAA6E;IAC7E,gDAAgD;IAChD;QACE,EAAE,EAAE,OAAO;QACX,KAAK,EAAE,YAAY;QACnB,UAAU,EAAE,kBAAkB;QAC9B,IAAI,EAAE,IAAI;QACV,MAAM,EAAE;;;;;KAKP;KAEA;IAEH,6EAA6E;IAC7E,+CAA+C;IAC/C;QACE,EAAE,EAAE,QAAQ;QACZ,KAAK,EAA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,sDA8FC"}
@@ -0,0 +1,29 @@
1
+ export interface ProfileSection {
2
+ /** Slug used in HTML comment markers and settings key */
3
+ id: string;
4
+ /** Human-readable label for the sidebar ProfileBuilder checkbox */
5
+ label: string;
6
+ /** Filename inside media/profile/ */
7
+ file: string;
8
+ /** 2–3 critical rules shown inline in the index. Full content lives in the file. */
9
+ keyRules: string[];
10
+ }
11
+ export declare const PROFILE_SECTIONS: ProfileSection[];
12
+ /** Returns all section IDs in order — useful as the default "all enabled" value. */
13
+ export declare const ALL_SECTION_IDS: string[];
14
+ /**
15
+ * Assemble AGENT_PROFILE.md as a compact **index**:
16
+ * - Each enabled section shows its key rules inline (immediate context).
17
+ * - A `@.autodev/profile/<file>` line lets agents load the full section on demand.
18
+ * - Full section files are copied to `<root>/.autodev/profile/` so the `@`
19
+ * references resolve inside the workspace.
20
+ * - Custom `@path` references are appended at the end.
21
+ *
22
+ * @param enabledIds Section IDs to include. Empty = all sections.
23
+ * @param root Workspace root. Required to deploy section files.
24
+ * @param customRefs Additional `@path` lines to append (from user settings).
25
+ */
26
+ export declare function assembleProfileBody(enabledIds: string[] | undefined, root: string, customRefs?: string[]): {
27
+ body: string;
28
+ sectionPaths: string[];
29
+ };
@@ -0,0 +1,366 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.ALL_SECTION_IDS = exports.PROFILE_SECTIONS = void 0;
37
+ exports.assembleProfileBody = assembleProfileBody;
38
+ const crypto = __importStar(require("crypto"));
39
+ const fs = __importStar(require("fs"));
40
+ const path = __importStar(require("path"));
41
+ exports.PROFILE_SECTIONS = [
42
+ {
43
+ id: '00-identity', label: 'Identity & Autonomous Mode', file: '00-identity.md',
44
+ keyRules: [
45
+ 'Fully autonomous — never ask questions or wait for confirmation. Decide and act.',
46
+ 'FIRST ACTION on every task: mark `[ ]` → `[~]` in TODO.md BEFORE anything else.',
47
+ 'Never end the session while `[ ]` or `[~]` tasks remain.',
48
+ ],
49
+ },
50
+ {
51
+ id: '01-learning', label: 'Session Start Order (SUMMARY.md)', file: '01-learning.md',
52
+ keyRules: [
53
+ 'Read in order: SOUL.md → AGENTS.md → SUMMARY.md → LESSONS.md → CONTRACTS.md → open issues → KB → TODO.md.',
54
+ 'Update SUMMARY.md whenever you discover non-obvious facts or make architectural decisions.',
55
+ ],
56
+ },
57
+ {
58
+ id: '02-memory-mcp', label: 'Memory MCP — State Persistence', file: '02-memory-mcp.md',
59
+ keyRules: [
60
+ 'Query Memory MCP before reading TODO.md — load all project nodes first.',
61
+ 'After every `[x]`: write ≥1 Memory MCP node (what changed, gotcha, convention).',
62
+ ],
63
+ },
64
+ {
65
+ id: '03-living-docs', label: 'Living Project Docs', file: '03-living-docs.md',
66
+ keyRules: [
67
+ 'Keep PROJECT.md, LESSONS.md, TROUBLESHOOTING.md, SETUP.md, CHANGELOG.md current every session.',
68
+ 'Every resolved error → TROUBLESHOOTING.md. Every `[x]` → CHANGELOG.md. Every correction → LESSONS.md.',
69
+ ],
70
+ },
71
+ {
72
+ id: '04-skill-files', label: 'Automatic Skill Development (AGENTS.md)', file: '04-skill-files.md',
73
+ keyRules: [
74
+ 'AGENTS.md is single source of truth — read it before starting any task.',
75
+ 'Update AGENTS.md (+ sync Copilot file) whenever a convention, pattern, or footgun is confirmed.',
76
+ ],
77
+ },
78
+ {
79
+ id: '05-skill-creation', label: 'Skill Creation Protocol', file: '05-skill-creation.md',
80
+ keyRules: [
81
+ 'Create .claude/skills/<slug>/SKILL.md when solution required 3+ failed attempts or agent would repeat mistake.',
82
+ 'Add slug + summary to AGENTS.md `## Project Skills` after creating a skill.',
83
+ ],
84
+ },
85
+ {
86
+ id: '06-core-rules', label: 'Core Rules & File Placement', file: '06-core-rules.md',
87
+ keyRules: [
88
+ 'Read every file before touching it. Never assume structure, conventions, or config.',
89
+ 'YOU run tests/lints/builds directly. Subagents only for: implementation (Code), test writing (QA), review (Reviewer).',
90
+ 'Think deeply; context unwieldy → summarise → spawn subagent with clean scope. Never silently degrade.',
91
+ ],
92
+ },
93
+ {
94
+ id: '07-core-loop', label: 'Core Loop & Task Classification', file: '07-core-loop.md',
95
+ keyRules: [
96
+ 'Loop: MARK [~] → PLAN → DISPATCH → VERIFY → MARK [x] → commit → next task.',
97
+ 'Re-read TODO.md after every [x]; never end while [ ] or [~] remain. Full loop: skill `autodev-core-loop`.',
98
+ ],
99
+ },
100
+ {
101
+ id: '08-thinking', label: 'Thinking, Decomposition & Validation', file: '08-thinking.md',
102
+ keyRules: [
103
+ 'Answer 6 questions before dispatching: Scope, Impact, Patterns, Risks, Approach, Done criteria.',
104
+ 'Validation panel (Simplicity · Assumption · User · Priority) must run before every [x].',
105
+ ],
106
+ },
107
+ {
108
+ id: '09-parallel-panel', label: 'Parallel Specialist Panel (§2)', file: '09-parallel-panel.md',
109
+ keyRules: [
110
+ 'Five specialists: Architect (design) → Coder (edit files) → Reviewer (review) → Tester (write tests) → Ops.',
111
+ 'Orchestrator runs tests/lints/builds directly after Coder finishes — NOT through subagent.',
112
+ 'BLOCKER from Reviewer or Tester failure → back to Coder → re-run both gates.',
113
+ ],
114
+ },
115
+ {
116
+ id: '10-codebase-verification', label: 'Codebase Orientation & Verification', file: '10-codebase-verification.md',
117
+ keyRules: [
118
+ 'Orient before dispatching: entry point, browser UI?, test runner, core modules, config.',
119
+ 'Verify: local tests + lint/build + browser (if UI) + browser test suite + security scan before every commit.',
120
+ ],
121
+ },
122
+ {
123
+ id: '11-git-debug-security', label: 'Git, Debugging & Security', file: '11-git-debug-security.md',
124
+ keyRules: [
125
+ 'Conventional commits. One logical change per commit. Commit only after Verifier passes.',
126
+ 'Debug: read full error → locate → context → trace → hypothesis → re-dispatch → re-verify.',
127
+ ],
128
+ },
129
+ {
130
+ id: '12-todo-format', label: 'TODO.md Format & Marking Rules', file: '12-todo-format.md',
131
+ keyRules: [
132
+ '`[ ]` pending · `[~]` in-progress · `[x] YYYY-MM-DD` done (two spaces after date, lowercase x).',
133
+ 'Non-trivial task → add checkable subtask list; final subtask is always verification.',
134
+ ],
135
+ },
136
+ {
137
+ id: '13-workflow-principles', label: 'Workflow, Quality & Principles', file: '13-workflow-principles.md',
138
+ keyRules: [
139
+ 'Quality: no magic values, explicit types, single responsibility, fail loudly, surgical changes, simplicity first.',
140
+ 'Principles: Plan before code · Read first always · Subagents are leverage · Own the outcome.',
141
+ ],
142
+ },
143
+ {
144
+ id: '14-contracts', label: 'Agent Contracts (CONTRACTS.md)', file: '14-contracts.md',
145
+ keyRules: [
146
+ 'Email is the primary agent-to-agent medium. Jira comments do NOT notify agents — email is mandatory.',
147
+ 'Never invent or guess an address. Read CONTRACTS.md before any contact. Full skeleton: skill `contracts`.',
148
+ ],
149
+ },
150
+ {
151
+ id: '15-soul', label: 'Soul Protocol — Agent Identity', file: '15-soul.md',
152
+ keyRules: [
153
+ 'Read SOUL.md first — before SUMMARY.md, before everything. It holds your name, addresses, history.',
154
+ 'Append Communication History after every message. Never invent addresses.',
155
+ ],
156
+ },
157
+ {
158
+ id: '16-journal', label: 'Research Journal & Auto-Learn Loop', file: '16-journal.md',
159
+ keyRules: [
160
+ 'Research loop: HYPOTHESIS → IMPLEMENT → VERIFY → LOG → KEEP/DISCARD → REPEAT.',
161
+ 'Write a row before/after any task that modifies 2+ files or involves a non-obvious fix.',
162
+ ],
163
+ },
164
+ {
165
+ id: '17-issue-tracking', label: 'Issue Tracking (.autodev/issues/)', file: '17-issue-tracking.md',
166
+ keyRules: [
167
+ 'Create .autodev/issues/ISSUE-NNN-kebab-title.md before doing any work on an issue.',
168
+ 'Append Work Log + attach artifacts on every session touching the issue. Resolved needs 1+ artifact.',
169
+ ],
170
+ },
171
+ {
172
+ id: '18-knowledgebase', label: 'Knowledge Base (.autodev/knowledgebase/)', file: '18-knowledgebase.md',
173
+ keyRules: [
174
+ 'Create KB-NNN-kebab-title.md the moment an architectural decision, pattern, or gotcha is confirmed.',
175
+ 'Never delete KB entries — deprecate with Status: Deprecated + Superseded by link.',
176
+ ],
177
+ },
178
+ {
179
+ id: '19-subagent-context-management', label: 'Subagent Context Management', file: '19-subagent-context-management.md',
180
+ keyRules: [
181
+ 'Create CONTEXT.md for complex multi-step tasks to prevent losing track of main goal during deep work.',
182
+ 'Subagents NEVER for: running tests/lints/builds, reading files, deciding what to do, or "compacting YOUR context".',
183
+ 'Before spawning subagent: decide approach, write detailed brief (mission, context, files, patterns, done criteria).',
184
+ ],
185
+ },
186
+ ];
187
+ /** Returns all section IDs in order — useful as the default "all enabled" value. */
188
+ exports.ALL_SECTION_IDS = exports.PROFILE_SECTIONS.map(s => s.id);
189
+ // ---------------------------------------------------------------------------
190
+ // Helpers
191
+ // ---------------------------------------------------------------------------
192
+ function profileMediaDir() {
193
+ return path.join(__dirname, '..', 'media', 'profile');
194
+ }
195
+ function md5(content) {
196
+ return crypto.createHash('md5').update(content).digest('hex');
197
+ }
198
+ /**
199
+ * Copy a section file from `media/profile/` to `<root>/.autodev/profile/`
200
+ * so it is accessible via `@.autodev/profile/<file>` references inside the
201
+ * workspace. Returns the workspace-relative `@` path, or null on failure.
202
+ */
203
+ function deploySectionFile(section, root) {
204
+ const src = path.join(profileMediaDir(), section.file);
205
+ if (!fs.existsSync(src)) {
206
+ return null;
207
+ }
208
+ const destDir = path.join(root, '.autodev', 'profile');
209
+ if (!fs.existsSync(destDir)) {
210
+ fs.mkdirSync(destDir, { recursive: true });
211
+ }
212
+ const dest = path.join(destDir, section.file);
213
+ try {
214
+ fs.copyFileSync(src, dest);
215
+ return `.autodev/profile/${section.file}`;
216
+ }
217
+ catch {
218
+ return null;
219
+ }
220
+ }
221
+ // ---------------------------------------------------------------------------
222
+ // Profile assembly — index format
223
+ // ---------------------------------------------------------------------------
224
+ /**
225
+ * Assemble AGENT_PROFILE.md as a compact **index**:
226
+ * - Each enabled section shows its key rules inline (immediate context).
227
+ * - A `@.autodev/profile/<file>` line lets agents load the full section on demand.
228
+ * - Full section files are copied to `<root>/.autodev/profile/` so the `@`
229
+ * references resolve inside the workspace.
230
+ * - Custom `@path` references are appended at the end.
231
+ *
232
+ * @param enabledIds Section IDs to include. Empty = all sections.
233
+ * @param root Workspace root. Required to deploy section files.
234
+ * @param customRefs Additional `@path` lines to append (from user settings).
235
+ */
236
+ function assembleProfileBody(enabledIds, root, customRefs = []) {
237
+ const ids = enabledIds && enabledIds.length > 0 ? enabledIds : exports.ALL_SECTION_IDS;
238
+ const orderedSections = exports.PROFILE_SECTIONS.filter(s => ids.includes(s.id));
239
+ const header = [
240
+ '# AutoDev Agent Profile',
241
+ '',
242
+ '> This is a **protocol index**. Each section file is loaded directly by the agent.',
243
+ '> Key rules are summarised below; full details live in the per-section files.',
244
+ '',
245
+ '---',
246
+ '',
247
+ ].join('\n');
248
+ const parts = [];
249
+ const sectionPaths = [];
250
+ for (const section of orderedSections) {
251
+ const refPath = deploySectionFile(section, root);
252
+ if (refPath) {
253
+ sectionPaths.push(refPath);
254
+ }
255
+ const rulesLines = section.keyRules.map(r => `- ${r}`).join('\n');
256
+ // Hash over key rules + ref so the marker changes if either is updated
257
+ const hash = md5(rulesLines + (refPath ?? ''));
258
+ const block = [
259
+ `<!-- AUTODEV:section:${section.id}:begin:md5=${hash} -->`,
260
+ `### ${section.label}`,
261
+ rulesLines,
262
+ `<!-- AUTODEV:section:${section.id}:end -->`,
263
+ ].join('\n');
264
+ parts.push(block);
265
+ }
266
+ let body = header + parts.join('\n\n') + '\n';
267
+ // Append custom references
268
+ const validCustom = customRefs.map(r => r.trim()).filter(r => r.length > 0);
269
+ if (validCustom.length > 0) {
270
+ body += '\n---\n\n## Custom References\n\n';
271
+ body += validCustom.map(r => {
272
+ // Remove @ prefix if present
273
+ const cleanPath = r.startsWith('@') ? r.substring(1) : r;
274
+ // Use a relative file:// path so the reference survives workspace moves.
275
+ const relPath = path.isAbsolute(cleanPath)
276
+ ? path.relative(root, cleanPath).replace(/\\/g, '/')
277
+ : cleanPath.replace(/\\/g, '/');
278
+ return `file://./${relPath}`;
279
+ }).join('\n');
280
+ body += '\n';
281
+ }
282
+ // Always append SOUL.md reference so agents load their identity anchor first.
283
+ body += [
284
+ '',
285
+ '---',
286
+ '',
287
+ '## Agent Identity Anchor',
288
+ '',
289
+ `file://./SOUL.md`,
290
+ '<think>',
291
+ 'IMPORTANT: Read SOUL.md before processing any incoming message.',
292
+ 'It contains your name, your contact addresses, and your full communication history.',
293
+ 'When a message arrives, check ## Communication History to recognise the thread.',
294
+ 'Never act confused about who you are — your identity is stable across all sessions.',
295
+ 'If SOUL.md does not exist yet, create it from the skeleton in §0.0.',
296
+ '</think>',
297
+ '',
298
+ ].join('\n');
299
+ // Always append JOURNAL.md reference so agents write and read the research log.
300
+ body += [
301
+ '',
302
+ '---',
303
+ '',
304
+ '## Research Journal',
305
+ '',
306
+ `file://./JOURNAL.md`,
307
+ '<think>',
308
+ 'IMPORTANT: Before every non-trivial task, write a hypothesis row in JOURNAL.md (status: pending).',
309
+ 'After the task: update the row to keep or discard. Apply the simplicity criterion.',
310
+ 'Commit JOURNAL.md together with the code change. Never delete rows — discards are valuable data.',
311
+ 'If JOURNAL.md does not exist yet, create it from the skeleton in §0.6.',
312
+ '</think>',
313
+ '',
314
+ ].join('\n');
315
+ // Always append a direct reference to CONTRACTS.md so agents auto-load
316
+ // the project's contact directory regardless of which sections are enabled.
317
+ body += [
318
+ '',
319
+ '---',
320
+ '',
321
+ '## Project Contact Directory',
322
+ '',
323
+ `file://./CONTRACTS.md`,
324
+ '<think>',
325
+ 'IMPORTANT: Read CONTRACTS.md before sending any email, message, or task to another agent.',
326
+ 'It lists every human and agent contact address, per-channel routing rules, and the escalation',
327
+ 'thresholds that must be met before contacting the human.',
328
+ 'Never invent or guess a contact address — if it is not in CONTRACTS.md, do not send.',
329
+ '</think>',
330
+ '',
331
+ ].join('\n');
332
+ // Always append issue tracking and knowledge base anchors.
333
+ body += [
334
+ '',
335
+ '---',
336
+ '',
337
+ '## Open Issues',
338
+ '',
339
+ `file://./.autodev/issues/`,
340
+ '<think>',
341
+ 'IMPORTANT: At session start, scan .autodev/issues/ for ISSUE-*.md files whose Status is not Resolved or Closed.',
342
+ 'Re-read each open issue file before starting work so context is fully loaded.',
343
+ 'When assigned a ticket or bug, create .autodev/issues/ISSUE-NNN-kebab-title.md immediately — before any code or email.',
344
+ 'If .autodev/issues/ does not exist yet, create it and the first issue file from the skeleton in §0.7.',
345
+ '</think>',
346
+ '',
347
+ ].join('\n');
348
+ body += [
349
+ '',
350
+ '---',
351
+ '',
352
+ '## Knowledge Base',
353
+ '',
354
+ `file://./.autodev/knowledgebase/`,
355
+ '<think>',
356
+ 'IMPORTANT: Before starting any non-trivial task, scan .autodev/knowledgebase/ for KB entries relevant to that task.',
357
+ 'When a session produces a reusable insight (architectural decision, pattern, gotcha, confirmed API behaviour),',
358
+ 'create .autodev/knowledgebase/KB-NNN-kebab-title.md immediately — do not wait until the end of the session.',
359
+ 'Cross-reference KB entries and issue files bidirectionally. Never delete KB entries — deprecate with a forward link.',
360
+ 'If .autodev/knowledgebase/ does not exist yet, create it and the first KB entry from the skeleton in §0.8.',
361
+ '</think>',
362
+ '',
363
+ ].join('\n');
364
+ return { body, sectionPaths };
365
+ }
366
+ //# sourceMappingURL=profileBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profileBuilder.js","sourceRoot":"","sources":["../src/profileBuilder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsNA,kDA8IC;AApWD,+CAAiC;AACjC,uCAAyB;AACzB,2CAA6B;AAiBhB,QAAA,gBAAgB,GAAqB;IAChD;QACE,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE,4BAA4B,EAAE,IAAI,EAAE,gBAAgB;QAC9E,QAAQ,EAAE;YACR,kFAAkF;YAClF,iFAAiF;YACjF,0DAA0D;SAC3D;KACF;IACD;QACE,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE,kCAAkC,EAAE,IAAI,EAAE,gBAAgB;QACpF,QAAQ,EAAE;YACR,2GAA2G;YAC3G,4FAA4F;SAC7F;KACF;IACD;QACE,EAAE,EAAE,eAAe,EAAE,KAAK,EAAE,gCAAgC,EAAE,IAAI,EAAE,kBAAkB;QACtF,QAAQ,EAAE;YACR,yEAAyE;YACzE,iFAAiF;SAClF;KACF;IACD;QACE,EAAE,EAAE,gBAAgB,EAAE,KAAK,EAAE,qBAAqB,EAAE,IAAI,EAAE,mBAAmB;QAC7E,QAAQ,EAAE;YACR,gGAAgG;YAChG,uGAAuG;SACxG;KACF;IACD;QACE,EAAE,EAAE,gBAAgB,EAAE,KAAK,EAAE,yCAAyC,EAAE,IAAI,EAAE,mBAAmB;QACjG,QAAQ,EAAE;YACR,yEA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