autodev-cli 1.4.0 → 1.4.3

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 +430 -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 +25 -0
  77. package/out/core/projectMcp.js +144 -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,373 @@
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.ATTACHMENTS_DIR = exports.MESSAGES_DIR = exports.AGENT_PROFILE_FILE = void 0;
37
+ exports.parseFrontmatter = parseFrontmatter;
38
+ exports.saveAttachment = saveAttachment;
39
+ exports.writeMessageFile = writeMessageFile;
40
+ exports.rebuildProfile = rebuildProfile;
41
+ exports.buildMessage = buildMessage;
42
+ const crypto = __importStar(require("crypto"));
43
+ const fs = __importStar(require("fs"));
44
+ const path = __importStar(require("path"));
45
+ const sessionState_1 = require("./sessionState");
46
+ const protocolSections_1 = require("./protocolSections");
47
+ const profileBuilder_1 = require("./profileBuilder");
48
+ const settingsLoader_1 = require("./core/settingsLoader");
49
+ // ---------------------------------------------------------------------------
50
+ // File path constants — all files live under <workspace>/.autodev/
51
+ // ---------------------------------------------------------------------------
52
+ /** Agent profile instructions written for each task run */
53
+ exports.AGENT_PROFILE_FILE = '.autodev/AGENT_PROFILE.md';
54
+ /** Directory where per-task message files are stored */
55
+ exports.MESSAGES_DIR = '.autodev/messages';
56
+ /** Directory where attachments are saved, grouped by timestamp+hash */
57
+ exports.ATTACHMENTS_DIR = '.autodev/messages/attachments';
58
+ // Marker pair used to identify the autodev-managed block in CLAUDE.md / AGENTS.md
59
+ const AGENT_REF_BEGIN = '<!-- autodev:profile-ref:begin -->';
60
+ const AGENT_REF_END = '<!-- autodev:profile-ref:end -->';
61
+ /**
62
+ * Ensure `CLAUDE.md` and `AGENTS.md` in `root` contain an import reference
63
+ * to `.autodev/AGENT_PROFILE.md` inside autodev marker tags.
64
+ * Idempotent — replaces the existing block on every rebuild.
65
+ * Creates the file with just the reference block if it doesn't exist yet.
66
+ */
67
+ function injectAgentProfileRef(root, sectionPaths = []) {
68
+ // Inject AGENT_PROFILE.md plus every deployed section file using relative
69
+ // file:// paths so references survive workspace folder moves/renames.
70
+ const allPaths = [exports.AGENT_PROFILE_FILE, ...sectionPaths];
71
+ const markerRe = /<!-- autodev:profile-ref:begin -->[\s\S]*?<!-- autodev:profile-ref:end -->/;
72
+ for (const filename of ['AGENTS.md', 'CLAUDE.md']) {
73
+ const filePath = path.join(root, filename);
74
+ let block;
75
+ if (filename === 'CLAUDE.md' && fs.existsSync(path.join(root, 'AGENTS.md'))) {
76
+ // CLAUDE.md: thin redirect → points to AGENTS.md which is the primary file.
77
+ // Claude reads AGENTS.md first; all real profile refs live there.
78
+ block = [
79
+ AGENT_REF_BEGIN,
80
+ // Relative file:// path — works regardless of absolute workspace location
81
+ `file://./AGENTS.md`,
82
+ `<think>`,
83
+ `IMPORTANT: AGENTS.md is the primary instruction file. Read and follow all instructions in AGENTS.md before proceeding.`,
84
+ `</think>`,
85
+ AGENT_REF_END,
86
+ ].join('\n');
87
+ }
88
+ else {
89
+ // AGENTS.md (primary) — or CLAUDE.md when no AGENTS.md exists: full reference block.
90
+ // Use relative file:// paths so references survive workspace moves.
91
+ const fileLines = allPaths
92
+ .map(p => `file://./${p.replace(/\\/g, '/')}`)
93
+ .join('\n');
94
+ const thinkBlock = `<think>\nIMPORTANT: Read all the instruction files listed above before proceeding.\nThey contain your core protocols, rules, and operational guidelines.\n</think>`;
95
+ block = `${AGENT_REF_BEGIN}\n${fileLines}\n${thinkBlock}\n${AGENT_REF_END}`;
96
+ }
97
+ let content = '';
98
+ if (fs.existsSync(filePath)) {
99
+ content = fs.readFileSync(filePath, 'utf8');
100
+ }
101
+ if (markerRe.test(content)) {
102
+ // Replace existing block
103
+ content = content.replace(markerRe, block);
104
+ }
105
+ else {
106
+ // Prepend block — agents read the top of the file first
107
+ content = block + (content ? '\n\n' + content : '');
108
+ }
109
+ fs.writeFileSync(filePath, content, 'utf8');
110
+ }
111
+ }
112
+ const COPILOT_INSTRUCTIONS_FILE = '.github/copilot-instructions.md';
113
+ const COPILOT_BEGIN = '<!-- autodev:profile:begin -->';
114
+ const COPILOT_END = '<!-- autodev:profile:end -->';
115
+ /**
116
+ * Sync the assembled profile body into `.github/copilot-instructions.md`.
117
+ * GitHub Copilot cannot follow `@`-import references, so the content is
118
+ * written inline, wrapped in idempotent autodev marker tags.
119
+ * The file is created (including the `.github/` directory) if absent.
120
+ */
121
+ function syncCopilotInstructions(root, _profileBody) {
122
+ // GitHub Copilot cannot follow @-import references, but the full profile is
123
+ // already maintained in CLAUDE.md. Keep copilot-instructions.md as a slim
124
+ // one-liner so there is no duplication to maintain.
125
+ const refLine = 'See `AGENTS.md` in the project root for full agent instructions (AGENTS.md is the primary file; CLAUDE.md redirects to it).';
126
+ const block = `${COPILOT_BEGIN}\n${refLine}\n${COPILOT_END}`;
127
+ const markerRe = /<!-- autodev:profile:begin -->[\s\S]*?<!-- autodev:profile:end -->/;
128
+ const githubDir = path.join(root, '.github');
129
+ if (!fs.existsSync(githubDir)) {
130
+ fs.mkdirSync(githubDir, { recursive: true });
131
+ }
132
+ const filePath = path.join(root, COPILOT_INSTRUCTIONS_FILE);
133
+ let content = '';
134
+ if (fs.existsSync(filePath)) {
135
+ content = fs.readFileSync(filePath, 'utf8');
136
+ }
137
+ if (markerRe.test(content)) {
138
+ content = content.replace(markerRe, block);
139
+ }
140
+ else {
141
+ content = block + (content ? '\n\n' + content : '');
142
+ }
143
+ fs.writeFileSync(filePath, content, 'utf8');
144
+ }
145
+ /**
146
+ * Parse YAML-like frontmatter from a markdown file.
147
+ * Returns metadata and the body with frontmatter stripped.
148
+ */
149
+ function parseFrontmatter(content) {
150
+ if (!content.startsWith('---')) {
151
+ return { meta: {}, body: content };
152
+ }
153
+ const end = content.indexOf('\n---', 3);
154
+ if (end === -1) {
155
+ return { meta: {}, body: content };
156
+ }
157
+ const block = content.slice(3, end).trim();
158
+ const body = content.slice(end + 4).trimStart();
159
+ const meta = {};
160
+ for (const line of block.split('\n')) {
161
+ const m = line.match(/^(\w+):\s*"?(.+?)"?\s*$/);
162
+ if (!m) {
163
+ continue;
164
+ }
165
+ const [, key, val] = m;
166
+ const clean = val.replace(/^"|"$/g, '');
167
+ if (key === 'title') {
168
+ meta.title = clean;
169
+ }
170
+ if (key === 'description') {
171
+ meta.description = clean;
172
+ }
173
+ if (key === 'noCommit') {
174
+ meta.noCommit = clean === 'true';
175
+ }
176
+ }
177
+ return { meta, body };
178
+ }
179
+ // ---------------------------------------------------------------------------
180
+ // Message builder
181
+ // ---------------------------------------------------------------------------
182
+ /** Returns the .autodev/messages directory, creating it if needed. */
183
+ function messagesDir(root) {
184
+ const dir = path.join(root, exports.MESSAGES_DIR);
185
+ if (!fs.existsSync(dir)) {
186
+ fs.mkdirSync(dir, { recursive: true });
187
+ }
188
+ return dir;
189
+ }
190
+ /** Generates a timestamp string like 20250410_143022 for use in filenames. */
191
+ function timestamp() {
192
+ const d = new Date();
193
+ const pad = (n, w = 2) => String(n).padStart(w, '0');
194
+ return `${d.getFullYear()}${pad(d.getMonth() + 1)}${pad(d.getDate())}_${pad(d.getHours())}${pad(d.getMinutes())}${pad(d.getSeconds())}`;
195
+ }
196
+ /**
197
+ * Save an attachment to `.autodev/messages/attachments/<groupId>/filename`.
198
+ * If `groupId` is omitted a new `<timestamp>_<hex>` folder is created.
199
+ * Returns the workspace-relative forward-slash path (suitable for embedding in .md).
200
+ */
201
+ function saveAttachment(workspaceRoot, filename, data, groupId) {
202
+ const group = groupId ?? `${timestamp()}_${crypto.randomBytes(4).toString('hex')}`;
203
+ const dir = path.join(workspaceRoot, exports.ATTACHMENTS_DIR, group);
204
+ if (!fs.existsSync(dir)) {
205
+ fs.mkdirSync(dir, { recursive: true });
206
+ }
207
+ const filePath = path.join(dir, filename);
208
+ if (Buffer.isBuffer(data)) {
209
+ fs.writeFileSync(filePath, data);
210
+ }
211
+ else {
212
+ fs.writeFileSync(filePath, data, 'utf8');
213
+ }
214
+ return path.relative(workspaceRoot, filePath).replace(/\\/g, '/');
215
+ }
216
+ /**
217
+ * Write arbitrary content to a timestamped message file and return the full path.
218
+ * Used for reminder/check-in messages that bypass buildMessage().
219
+ */
220
+ function writeMessageFile(root, content) {
221
+ const dir = messagesDir(root);
222
+ const filePath = path.join(dir, `MESSAGE_${timestamp()}.md`);
223
+ fs.writeFileSync(filePath, content, 'utf8');
224
+ return filePath;
225
+ }
226
+ function readOrEmpty(filePath) {
227
+ try {
228
+ return fs.existsSync(filePath) ? fs.readFileSync(filePath, 'utf8') : '';
229
+ }
230
+ catch {
231
+ return '';
232
+ }
233
+ }
234
+ function buildTaskInstruction(task, todoPath, root, noCommit = false) {
235
+ const date = new Date().toISOString().slice(0, 10);
236
+ // Full raw task marker line as it appears (or will appear) in TODO.md
237
+ const taskId = task.id ? `[${task.id}] ` : '';
238
+ const taskLine = `- [ ] ${taskId}${task.text}`;
239
+ const doneLine = `- [x] ${date} ${taskId}${task.text}`;
240
+ // Relative file:// URI for the profile — works regardless of absolute workspace location.
241
+ const profileRef = `@file://./${exports.AGENT_PROFILE_FILE}`;
242
+ // Inline attachment files from task.attachments (populated at parse time by todo.ts).
243
+ // Only .md files are inlined as text — binary attachments (images, PDFs, etc.)
244
+ // are listed in the header reference but not embedded.
245
+ const inlinedFiles = [];
246
+ for (const relPath of task.attachments ?? []) {
247
+ if (!relPath.toLowerCase().endsWith('.md')) {
248
+ continue;
249
+ }
250
+ const absPath = path.join(root, relPath);
251
+ if (fs.existsSync(absPath)) {
252
+ try {
253
+ const content = fs.readFileSync(absPath, 'utf8').trim();
254
+ inlinedFiles.push(`### Attachment: ${path.basename(absPath)}\n\n${content}`);
255
+ }
256
+ catch { /* skip unreadable files */ }
257
+ }
258
+ }
259
+ const inlinedSection = inlinedFiles.length > 0
260
+ ? `\n---\n\n## Message Content (inlined — do not try to open the file)\n\n${inlinedFiles.join('\n\n---\n\n')}\n`
261
+ : '';
262
+ const attachmentRef = task.attachments && task.attachments.length > 0
263
+ ? `**Attachments:** ${task.attachments.map(p => `\`${p}\``).join(', ')}\n`
264
+ : '';
265
+ return `> **NEXT TASK TO BEGIN, DO NOT STOP WORK**
266
+
267
+ ## Current task
268
+
269
+ **Task ID:** \`${taskId.trim() || '(no id)'}\`
270
+ **Task text:** ${task.text}
271
+ **TODO.md:** \`${todoPath}\` line ${task.line}
272
+ ${attachmentRef}
273
+ see in
274
+ > **IMPORTANT:** Even if you have done a similar task before, this is a **new independent task** that requires real work. Do NOT just mark it done — actually complete the task fully.
275
+
276
+ ### Steps required
277
+
278
+ 1. Open \`${todoPath}\` and find line ${task.line}:
279
+ \`${taskLine}\`
280
+ 2. Mark it in-progress **before** starting: change \`[ ]\` to \`[~]\`
281
+ 3. **Actually do the work** described by the task text above. Follow all protocol instructions from your agent profile.
282
+ 3.1 Discover the real task by opening the attachment files related to the todo entry, which are part of the task instructions. The files are listed above and may include important context, data, or subtasks. They are embedded in the message for your convenience, so read them carefully.
283
+ 4. When the work is fully done, mark it complete:
284
+ \`${doneLine}\`
285
+ 5. Continue to the next \`[ ]\` task in \`${todoPath}\` — do not stop until all tasks are done.
286
+
287
+ > This loop runs continuously. Each task dispatch is a fresh task. "Standing by" or "already done" is not acceptable — complete the work.
288
+
289
+ ---
290
+
291
+ **Full protocol and agent instructions:** ${profileRef}
292
+ ${inlinedSection}`;
293
+ }
294
+ /**
295
+ * Builds the agent message for a task, writing two separate files:
296
+ * - `.autodev/AGENT_PROFILE.md` — profile instructions (frontmatter stripped)
297
+ * - `.autodev/messages/MESSAGE_<timestamp>.md` — task + current TODO
298
+ *
299
+ * Returns `{ prompt, messageFile }` where `prompt` is the combined string for UI
300
+ * providers that cannot read files via @-references, and `messageFile` is the
301
+ * absolute path of the written message file for CLI providers.
302
+ */
303
+ /**
304
+ * Assembles and writes `.autodev/AGENT_PROFILE.md` from the currently enabled
305
+ * profile sections + any active MCP protocol injections. Also deploys / removes
306
+ * Claude skill files for enabled / disabled MCPs.
307
+ *
308
+ * Called directly from the sidebar "Save & Rebuild Profile" button so the file
309
+ * is updated immediately without waiting for a task run.
310
+ */
311
+ function rebuildProfile(root) {
312
+ (0, sessionState_1.autodevDir)(root);
313
+ let settings;
314
+ try {
315
+ settings = (0, settingsLoader_1.loadSettingsForRoot)(root);
316
+ }
317
+ catch { /* ignore */ }
318
+ const enabledSections = settings?.enabledProfileSections ?? [];
319
+ const customRefs = settings?.customProfileRefs ?? [];
320
+ const { body: profileBody, sectionPaths } = (0, profileBuilder_1.assembleProfileBody)(enabledSections, root, customRefs);
321
+ const finalProfileBody = (0, protocolSections_1.applyProtocolSections)(profileBody, settings);
322
+ (0, protocolSections_1.applyMcpSkills)(root, settings);
323
+ const profileFilePath = path.join(root, exports.AGENT_PROFILE_FILE);
324
+ fs.writeFileSync(profileFilePath, finalProfileBody, 'utf8');
325
+ injectAgentProfileRef(root, sectionPaths);
326
+ syncCopilotInstructions(root, finalProfileBody);
327
+ }
328
+ function buildMessage(task, root, todoDir, includeProfile = true) {
329
+ (0, sessionState_1.autodevDir)(root);
330
+ // Load workspace settings (MCP servers, enabled profile sections, etc.)
331
+ let settings;
332
+ try {
333
+ settings = (0, settingsLoader_1.loadSettingsForRoot)(root);
334
+ }
335
+ catch { /* ignore */ }
336
+ // Read the noCommit flag from the identity section frontmatter
337
+ const identityFile = path.join(__dirname, '..', 'media', 'profile', '00-identity.md');
338
+ const { meta } = parseFrontmatter(readOrEmpty(identityFile));
339
+ // Assemble the profile index from the enabled section files
340
+ const enabledSections = settings?.enabledProfileSections ?? [];
341
+ const customRefs = settings?.customProfileRefs ?? [];
342
+ const { body: profileBody, sectionPaths } = (0, profileBuilder_1.assembleProfileBody)(enabledSections, root, customRefs);
343
+ // Inject protocol sections (email, jira, ...) for any MCP currently enabled
344
+ // in the workspace settings. Toggling an MCP off cleanly removes its block
345
+ // on the next regeneration.
346
+ const finalProfileBody = (0, protocolSections_1.applyProtocolSections)(profileBody, settings);
347
+ // Copy all general skills from media/skills/ to .claude/skills/
348
+ if (root) {
349
+ (0, protocolSections_1.applyAllSkills)(root);
350
+ }
351
+ // Deploy / remove Claude skill files for enabled / disabled MCPs
352
+ if (root) {
353
+ (0, protocolSections_1.applyMcpSkills)(root, settings);
354
+ }
355
+ // Always write the profile file so the LLM can @-reference it
356
+ const profileFilePath = path.join(root, exports.AGENT_PROFILE_FILE);
357
+ fs.writeFileSync(profileFilePath, finalProfileBody, 'utf8');
358
+ injectAgentProfileRef(root, sectionPaths);
359
+ syncCopilotInstructions(root, finalProfileBody);
360
+ // Build the task trigger message — profile is loaded by agents via AGENTS.md → @.autodev/AGENT_PROFILE.md
361
+ const todoPath = path.join(todoDir, 'TODO.md');
362
+ const taskMessage = buildTaskInstruction(task, todoPath, root, meta.noCommit);
363
+ const messageFile = writeMessageFile(root, taskMessage);
364
+ // Task message FIRST so the agent sees what to do immediately,
365
+ // then the full protocol/profile follows as context.
366
+ const parts = [];
367
+ parts.push(taskMessage);
368
+ if (includeProfile && finalProfileBody.trim()) {
369
+ parts.push(`# Project Instructions (AUTODEV.md)\n\n${finalProfileBody.trim()}`);
370
+ }
371
+ return { prompt: parts.join('\n\n---\n\n'), messageFile };
372
+ }
373
+ //# sourceMappingURL=messageBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messageBuilder.js","sourceRoot":"","sources":["../src/messageBuilder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmIA,4CAqBC;AA2BD,wCAgBC;AAMD,4CAKC;AAsFD,wCAeC;AAED,oCAmDC;AAxWD,+CAAiC;AACjC,uCAAyB;AACzB,2CAA6B;AAE7B,iDAA4C;AAC5C,yDAA2F;AAC3F,qDAAuD;AACvD,0DAA4D;AAE5D,8EAA8E;AAC9E,mEAAmE;AACnE,8EAA8E;AAE9E,2DAA2D;AAC9C,QAAA,kBAAkB,GAAG,2BAA2B,CAAC;AAE9D,wDAAwD;AAC3C,QAAA,YAAY,GAAG,mBAAmB,CAAC;AAEhD,uEAAuE;AAC1D,QAAA,eAAe,GAAG,+B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,IAAI,EAAE,gBAAgB,CAAC,CAAC;IAChD,0GAA0G;IAC1G,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IAC/C,MAAM,WAAW,GAAG,oBAAoB,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IAE9E,MAAM,WAAW,GAAG,gBAAgB,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IAExD,+DAA+D;IAC/D,qDAAqD;IACrD,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACxB,IAAI,cAAc,IAAI,gBAAgB,CAAC,IAAI,EAAE,EAAE,CAAC;QAC9C,KAAK,CAAC,IAAI,CAAC,0CAA0C,gBAAgB,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAClF,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,WAAW,EAAE,CAAC;AAC5D,CAAC"}
@@ -0,0 +1,23 @@
1
+ export declare function isOpenCodeHooksInstalled(workspaceRoot: string): boolean;
2
+ export declare function installOpenCodeHooks(workspaceRoot: string): void;
3
+ /**
4
+ * Return true if an opencode process is actively writing to the hooks JSONL.
5
+ * Prefers the per-session file when sessionId is known; falls back to the global file.
6
+ */
7
+ export declare function isOpenCodeCliActive(workspaceRoot: string, windowMs?: number, sessionId?: string): boolean;
8
+ /**
9
+ * Return true if the most recent opencode session exited cleanly (Stop event present).
10
+ * Prefers the per-session file when sessionId is known.
11
+ */
12
+ export declare function openCodeExitedCleanly(workspaceRoot: string, sessionId?: string): boolean;
13
+ /**
14
+ * Read the workspace-scoped hooks-events.jsonl and return the session ID from
15
+ * the most recent OpenCode session event.
16
+ * Returns undefined if the file is absent or no session event has been seen yet.
17
+ *
18
+ * @param notBefore Only consider events with a timestamp >= this ISO string or
19
+ * epoch-ms number. Pass the task-start time to avoid picking
20
+ * up stale/foreign sessions from before this dispatch.
21
+ */
22
+ export declare function getOpenCodeSessionIdFromHooks(workspaceRoot: string, notBefore?: string | number): string | undefined;
23
+ export declare function uninstallOpenCodeHooks(workspaceRoot: string): void;