agent-enderun 1.1.10 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (254) hide show
  1. package/README.md +294 -19
  2. package/bin/cli.js +7 -0
  3. package/bin/enderun-dashboard.js +16 -857
  4. package/bin/validate-agent-army.js +12 -12
  5. package/dist/framework-mcp/src/index.js +14 -2
  6. package/dist/framework-mcp/src/index.js.map +1 -1
  7. package/dist/framework-mcp/src/tools/file_system/batch_surgical_edit.js +2 -1
  8. package/dist/framework-mcp/src/tools/file_system/batch_surgical_edit.js.map +1 -1
  9. package/dist/framework-mcp/src/tools/file_system/replace_text.js +2 -1
  10. package/dist/framework-mcp/src/tools/file_system/replace_text.js.map +1 -1
  11. package/dist/framework-mcp/src/tools/file_system/write_file.js +3 -3
  12. package/dist/framework-mcp/src/tools/file_system/write_file.js.map +1 -1
  13. package/dist/framework-mcp/src/utils/fs.d.ts +16 -0
  14. package/dist/framework-mcp/src/utils/fs.js +45 -0
  15. package/dist/framework-mcp/src/utils/fs.js.map +1 -0
  16. package/dist/framework-mcp/src/utils/metrics.js.map +1 -1
  17. package/dist/src/cli/adapters/core.js.map +1 -1
  18. package/dist/src/cli/adapters/scaffold.js +4 -3
  19. package/dist/src/cli/adapters/scaffold.js.map +1 -1
  20. package/dist/src/cli/commands/app.js +20 -5
  21. package/dist/src/cli/commands/app.js.map +1 -1
  22. package/dist/src/cli/commands/approve.d.ts +1 -1
  23. package/dist/src/cli/commands/approve.js +7 -7
  24. package/dist/src/cli/commands/approve.js.map +1 -1
  25. package/dist/src/cli/commands/check.d.ts +1 -1
  26. package/dist/src/cli/commands/check.js +35 -4
  27. package/dist/src/cli/commands/check.js.map +1 -1
  28. package/dist/src/cli/commands/compliance.d.ts +1 -1
  29. package/dist/src/cli/commands/compliance.js +1 -1
  30. package/dist/src/cli/commands/compliance.js.map +1 -1
  31. package/dist/src/cli/commands/contract.d.ts +2 -2
  32. package/dist/src/cli/commands/contract.js +8 -14
  33. package/dist/src/cli/commands/contract.js.map +1 -1
  34. package/dist/src/cli/commands/dashboard/data-service.d.ts +33 -0
  35. package/dist/src/cli/commands/dashboard/data-service.js +120 -0
  36. package/dist/src/cli/commands/dashboard/data-service.js.map +1 -0
  37. package/dist/src/cli/commands/dashboard/html-template.d.ts +4 -0
  38. package/dist/src/cli/commands/dashboard/html-template.js +697 -0
  39. package/dist/src/cli/commands/dashboard/html-template.js.map +1 -0
  40. package/dist/src/cli/commands/dashboard/server.d.ts +2 -0
  41. package/dist/src/cli/commands/dashboard/server.js +38 -0
  42. package/dist/src/cli/commands/dashboard/server.js.map +1 -0
  43. package/dist/src/cli/commands/dashboard.d.ts +4 -0
  44. package/dist/src/cli/commands/dashboard.js +10 -0
  45. package/dist/src/cli/commands/dashboard.js.map +1 -0
  46. package/dist/src/cli/commands/explorer.d.ts +2 -2
  47. package/dist/src/cli/commands/explorer.js +2 -2
  48. package/dist/src/cli/commands/explorer.js.map +1 -1
  49. package/dist/src/cli/commands/git.d.ts +2 -2
  50. package/dist/src/cli/commands/git.js +2 -2
  51. package/dist/src/cli/commands/git.js.map +1 -1
  52. package/dist/src/cli/commands/init/scaffold-core.d.ts +4 -0
  53. package/dist/src/cli/commands/init/scaffold-core.js +65 -0
  54. package/dist/src/cli/commands/init/scaffold-core.js.map +1 -0
  55. package/dist/src/cli/commands/init/scaffold-ops.d.ts +1 -0
  56. package/dist/src/cli/commands/init/scaffold-ops.js +83 -0
  57. package/dist/src/cli/commands/init/scaffold-ops.js.map +1 -0
  58. package/dist/src/cli/commands/init/scaffold-standards.d.ts +2 -0
  59. package/dist/src/cli/commands/init/scaffold-standards.js +58 -0
  60. package/dist/src/cli/commands/init/scaffold-standards.js.map +1 -0
  61. package/dist/src/cli/commands/init.js +14 -275
  62. package/dist/src/cli/commands/init.js.map +1 -1
  63. package/dist/src/cli/commands/knowledge.d.ts +2 -2
  64. package/dist/src/cli/commands/knowledge.js +4 -3
  65. package/dist/src/cli/commands/knowledge.js.map +1 -1
  66. package/dist/src/cli/commands/lint.d.ts +1 -1
  67. package/dist/src/cli/commands/lint.js +2 -3
  68. package/dist/src/cli/commands/lint.js.map +1 -1
  69. package/dist/src/cli/commands/log.d.ts +1 -1
  70. package/dist/src/cli/commands/log.js +3 -2
  71. package/dist/src/cli/commands/log.js.map +1 -1
  72. package/dist/src/cli/commands/memory.d.ts +1 -1
  73. package/dist/src/cli/commands/memory.js +1 -1
  74. package/dist/src/cli/commands/memory.js.map +1 -1
  75. package/dist/src/cli/commands/orchestrate.js +169 -140
  76. package/dist/src/cli/commands/orchestrate.js.map +1 -1
  77. package/dist/src/cli/commands/plan.d.ts +1 -1
  78. package/dist/src/cli/commands/plan.js +1 -1
  79. package/dist/src/cli/commands/plan.js.map +1 -1
  80. package/dist/src/cli/commands/script.d.ts +1 -1
  81. package/dist/src/cli/commands/script.js +1 -1
  82. package/dist/src/cli/commands/script.js.map +1 -1
  83. package/dist/src/cli/commands/security.d.ts +1 -1
  84. package/dist/src/cli/commands/security.js +1 -1
  85. package/dist/src/cli/commands/security.js.map +1 -1
  86. package/dist/src/cli/commands/status.d.ts +1 -1
  87. package/dist/src/cli/commands/status.js +1 -1
  88. package/dist/src/cli/commands/status.js.map +1 -1
  89. package/dist/src/cli/commands/trace.d.ts +1 -1
  90. package/dist/src/cli/commands/trace.js +1 -1
  91. package/dist/src/cli/commands/trace.js.map +1 -1
  92. package/dist/src/cli/index.js +36 -21
  93. package/dist/src/cli/index.js.map +1 -1
  94. package/dist/src/cli/shims.js +6 -6
  95. package/dist/src/cli/utils/app-backend.js +7 -0
  96. package/dist/src/cli/utils/app-backend.js.map +1 -1
  97. package/dist/src/cli/utils/app-docs.js +23 -5
  98. package/dist/src/cli/utils/app-docs.js.map +1 -1
  99. package/dist/src/cli/utils/app-frontend.js +5 -0
  100. package/dist/src/cli/utils/app-frontend.js.map +1 -1
  101. package/dist/src/cli/utils/app-inferrer.d.ts +1 -0
  102. package/dist/src/cli/utils/app-inferrer.js +12 -1
  103. package/dist/src/cli/utils/app-inferrer.js.map +1 -1
  104. package/dist/src/cli/utils/app-mobile.d.ts +2 -0
  105. package/dist/src/cli/utils/app-mobile.js +106 -0
  106. package/dist/src/cli/utils/app-mobile.js.map +1 -0
  107. package/dist/src/cli/utils/app-types.js +8 -4
  108. package/dist/src/cli/utils/app-types.js.map +1 -1
  109. package/dist/src/cli/utils/app.d.ts +1 -0
  110. package/dist/src/cli/utils/app.js +1 -0
  111. package/dist/src/cli/utils/app.js.map +1 -1
  112. package/dist/src/cli/utils/claude.js +2 -1
  113. package/dist/src/cli/utils/claude.js.map +1 -1
  114. package/dist/src/cli/utils/compliance.js +37 -6
  115. package/dist/src/cli/utils/compliance.js.map +1 -1
  116. package/dist/src/cli/utils/config-schema.d.ts +3 -3
  117. package/dist/src/cli/utils/config-schema.js +3 -3
  118. package/dist/src/cli/utils/config-schema.js.map +1 -1
  119. package/dist/src/cli/utils/fs.d.ts +2 -2
  120. package/dist/src/cli/utils/fs.js +9 -13
  121. package/dist/src/cli/utils/fs.js.map +1 -1
  122. package/dist/src/cli/utils/memory.d.ts +9 -2
  123. package/dist/src/cli/utils/memory.js +87 -16
  124. package/dist/src/cli/utils/memory.js.map +1 -1
  125. package/dist/src/cli/utils/pkg.js +14 -13
  126. package/dist/src/cli/utils/pkg.js.map +1 -1
  127. package/dist/src/cli/utils/string.js +1 -1
  128. package/dist/src/cli/utils/string.js.map +1 -1
  129. package/dist/src/cli/utils/ui.d.ts +1 -1
  130. package/dist/src/cli/utils/ui.js +1 -1
  131. package/dist/src/modules/adapters/shared.js +7 -7
  132. package/dist/src/modules/adapters/shared.js.map +1 -1
  133. package/dist/src/modules/agents/definitions.d.ts +3 -34
  134. package/dist/src/modules/agents/definitions.js +35 -511
  135. package/dist/src/modules/agents/definitions.js.map +1 -1
  136. package/dist/src/modules/agents/registry/analyst.d.ts +2 -0
  137. package/dist/src/modules/agents/registry/analyst.js +36 -0
  138. package/dist/src/modules/agents/registry/analyst.js.map +1 -0
  139. package/dist/src/modules/agents/registry/architect.d.ts +2 -0
  140. package/dist/src/modules/agents/registry/architect.js +42 -0
  141. package/dist/src/modules/agents/registry/architect.js.map +1 -0
  142. package/dist/src/modules/agents/registry/backend.d.ts +2 -0
  143. package/dist/src/modules/agents/registry/backend.js +43 -0
  144. package/dist/src/modules/agents/registry/backend.js.map +1 -0
  145. package/dist/src/modules/agents/registry/database.d.ts +2 -0
  146. package/dist/src/modules/agents/registry/database.js +38 -0
  147. package/dist/src/modules/agents/registry/database.js.map +1 -0
  148. package/dist/src/modules/agents/registry/devops.d.ts +2 -0
  149. package/dist/src/modules/agents/registry/devops.js +38 -0
  150. package/dist/src/modules/agents/registry/devops.js.map +1 -0
  151. package/dist/src/modules/agents/registry/explorer.d.ts +2 -0
  152. package/dist/src/modules/agents/registry/explorer.js +36 -0
  153. package/dist/src/modules/agents/registry/explorer.js.map +1 -0
  154. package/dist/src/modules/agents/registry/frontend.d.ts +2 -0
  155. package/dist/src/modules/agents/registry/frontend.js +44 -0
  156. package/dist/src/modules/agents/registry/frontend.js.map +1 -0
  157. package/dist/src/modules/agents/registry/git.d.ts +2 -0
  158. package/dist/src/modules/agents/registry/git.js +35 -0
  159. package/dist/src/modules/agents/registry/git.js.map +1 -0
  160. package/dist/src/modules/agents/registry/manager.d.ts +2 -0
  161. package/dist/src/modules/agents/registry/manager.js +49 -0
  162. package/dist/src/modules/agents/registry/manager.js.map +1 -0
  163. package/dist/src/modules/agents/registry/mobile.d.ts +2 -0
  164. package/dist/src/modules/agents/registry/mobile.js +40 -0
  165. package/dist/src/modules/agents/registry/mobile.js.map +1 -0
  166. package/dist/src/modules/agents/registry/native.d.ts +2 -0
  167. package/dist/src/modules/agents/registry/native.js +36 -0
  168. package/dist/src/modules/agents/registry/native.js.map +1 -0
  169. package/dist/src/modules/agents/registry/quality.d.ts +2 -0
  170. package/dist/src/modules/agents/registry/quality.js +41 -0
  171. package/dist/src/modules/agents/registry/quality.js.map +1 -0
  172. package/dist/src/modules/agents/registry/security.d.ts +2 -0
  173. package/dist/src/modules/agents/registry/security.js +37 -0
  174. package/dist/src/modules/agents/registry/security.js.map +1 -0
  175. package/dist/src/modules/agents/types.d.ts +31 -0
  176. package/dist/src/modules/agents/types.js +2 -0
  177. package/dist/src/modules/agents/types.js.map +1 -0
  178. package/dist/src/modules/skills/definitions.d.ts +1 -1
  179. package/dist/src/modules/skills/definitions.js +1 -1
  180. package/dist/src/shared/errors.d.ts +8 -6
  181. package/dist/src/shared/errors.js +13 -10
  182. package/dist/src/shared/errors.js.map +1 -1
  183. package/dist/src/shared/fs.d.ts +4 -0
  184. package/dist/src/shared/fs.js +17 -2
  185. package/dist/src/shared/fs.js.map +1 -1
  186. package/dist/src/shared/types.d.ts +19 -0
  187. package/dist/src/shared/types.js +13 -0
  188. package/dist/src/shared/types.js.map +1 -0
  189. package/package.json +3 -5
  190. package/src/cli/adapters/core.ts +0 -1
  191. package/src/cli/adapters/scaffold.ts +4 -3
  192. package/src/cli/commands/app.ts +23 -5
  193. package/src/cli/commands/approve.ts +15 -7
  194. package/src/cli/commands/check.ts +38 -5
  195. package/src/cli/commands/compliance.ts +1 -1
  196. package/src/cli/commands/contract.ts +20 -14
  197. package/src/cli/commands/dashboard/data-service.ts +119 -0
  198. package/src/cli/commands/dashboard/html-template.ts +696 -0
  199. package/src/cli/commands/dashboard/server.ts +43 -0
  200. package/src/cli/commands/dashboard.ts +11 -0
  201. package/src/cli/commands/explorer.ts +2 -2
  202. package/src/cli/commands/git.ts +2 -2
  203. package/src/cli/commands/init/scaffold-core.ts +71 -0
  204. package/src/cli/commands/init/scaffold-ops.ts +86 -0
  205. package/src/cli/commands/init/scaffold-standards.ts +59 -0
  206. package/src/cli/commands/init.ts +21 -292
  207. package/src/cli/commands/knowledge.ts +5 -3
  208. package/src/cli/commands/lint.ts +2 -4
  209. package/src/cli/commands/log.ts +4 -2
  210. package/src/cli/commands/memory.ts +1 -1
  211. package/src/cli/commands/orchestrate.ts +177 -142
  212. package/src/cli/commands/plan.ts +1 -1
  213. package/src/cli/commands/script.ts +1 -1
  214. package/src/cli/commands/security.ts +1 -1
  215. package/src/cli/commands/status.ts +1 -1
  216. package/src/cli/commands/trace.ts +1 -1
  217. package/src/cli/index.ts +37 -21
  218. package/src/cli/shims.ts +6 -6
  219. package/src/cli/utils/app-backend.ts +8 -0
  220. package/src/cli/utils/app-docs.ts +23 -5
  221. package/src/cli/utils/app-frontend.ts +6 -0
  222. package/src/cli/utils/app-inferrer.ts +11 -1
  223. package/src/cli/utils/app-mobile.ts +113 -0
  224. package/src/cli/utils/app-types.ts +9 -4
  225. package/src/cli/utils/app.ts +1 -0
  226. package/src/cli/utils/claude.ts +2 -1
  227. package/src/cli/utils/compliance.ts +38 -7
  228. package/src/cli/utils/config-schema.ts +4 -4
  229. package/src/cli/utils/fs.ts +9 -14
  230. package/src/cli/utils/memory.ts +103 -20
  231. package/src/cli/utils/pkg.ts +14 -13
  232. package/src/cli/utils/string.ts +1 -1
  233. package/src/cli/utils/ui.ts +1 -1
  234. package/src/modules/adapters/shared.ts +7 -7
  235. package/src/modules/agents/definitions.ts +39 -598
  236. package/src/modules/agents/registry/analyst.ts +40 -0
  237. package/src/modules/agents/registry/architect.ts +46 -0
  238. package/src/modules/agents/registry/backend.ts +47 -0
  239. package/src/modules/agents/registry/database.ts +42 -0
  240. package/src/modules/agents/registry/devops.ts +42 -0
  241. package/src/modules/agents/registry/explorer.ts +40 -0
  242. package/src/modules/agents/registry/frontend.ts +48 -0
  243. package/src/modules/agents/registry/git.ts +39 -0
  244. package/src/modules/agents/registry/manager.ts +53 -0
  245. package/src/modules/agents/registry/mobile.ts +44 -0
  246. package/src/modules/agents/registry/native.ts +40 -0
  247. package/src/modules/agents/registry/quality.ts +45 -0
  248. package/src/modules/agents/registry/security.ts +41 -0
  249. package/src/modules/agents/types.ts +37 -0
  250. package/src/modules/skills/definitions.ts +1 -1
  251. package/src/shared/errors.ts +13 -10
  252. package/src/shared/fs.ts +17 -2
  253. package/src/shared/types.ts +20 -0
  254. package/bin/utils/docgen.ts +0 -24
@@ -2,9 +2,9 @@ import fs from "fs";
2
2
  import os from "os";
3
3
  import path from "path";
4
4
  import { logger } from "../../shared/logger.js";
5
- import { ensureDir } from "../../shared/fs.js";
6
- import { sleep } from "./time.js";
5
+ import { ensureDir, writeTextFile, writeJsonFile } from "../../shared/fs.js";
7
6
  import { StateSchema, AgentStatusSchema, TaskSchema } from "./schemas.js";
7
+ import type { TraceID } from "../../shared/types.js";
8
8
 
9
9
  export { generateULID } from "./time.js";
10
10
  export { FRAMEWORK_DIR_CANDIDATES } from "../adapters/index.js";
@@ -36,6 +36,14 @@ export function getLocalFrameworkDir(): string {
36
36
  export function getConfigDir(): string {
37
37
  const localDir = findFrameworkDir(CWD);
38
38
  if (localDir) return localDir;
39
+
40
+ // Check for standard local directories if package.json doesn't specify
41
+ const localCandidates = [".enderun", ".gemini", ".claude", ".cursor", ".antigravity", ".agent"];
42
+ for (const cand of localCandidates) {
43
+ const p = path.join(CWD, cand);
44
+ if (fs.existsSync(p)) return p;
45
+ }
46
+
39
47
  return path.join(HOME, ".gemini");
40
48
  }
41
49
 
@@ -46,9 +54,7 @@ export function getFrameworkDir(): string {
46
54
 
47
55
  export function getDocumentStorePath() {
48
56
  const frameworkDir = getFrameworkDir();
49
- const store = path.join(frameworkDir, "memory");
50
- console.warn(`[DEBUG] getDocumentStorePath returning ${store}`);
51
- return store;
57
+ return path.join(frameworkDir, "memory");
52
58
  }
53
59
 
54
60
  export function initDocumentStore(frameworkDir?: string) {
@@ -59,12 +65,15 @@ export function initDocumentStore(frameworkDir?: string) {
59
65
 
60
66
  const stateFile = path.join(storePath, "state.json");
61
67
  if (!fs.existsSync(stateFile)) {
62
- fs.writeFileSync(stateFile, JSON.stringify({ phase: "PHASE_0", traceId: "T-000", managerState: "ACTIVE" }, null, 2));
68
+ writeJsonFile(stateFile, { phase: "PHASE_0", traceId: "T-000", managerState: "ACTIVE" });
63
69
  }
64
70
  const statusFile = path.join(storePath, "status.json");
65
71
  if (!fs.existsSync(statusFile)) {
66
- fs.writeFileSync(statusFile, JSON.stringify({}, null, 2));
72
+ writeJsonFile(statusFile, {});
67
73
  }
74
+
75
+ // Ensure the initial Markdown view is created
76
+ syncMarkdownMemory(frameworkDir);
68
77
  }
69
78
 
70
79
  export function readState() {
@@ -111,14 +120,14 @@ export function updateProjectMemory(section: string, content: string) {
111
120
  }
112
121
  }
113
122
 
114
- export function initializeMemory(memoryPathOrBase: string, targetBaseOrDryRun?: string | boolean, dryRun = false): void {
115
- const targetBase = typeof targetBaseOrDryRun === 'string' ? targetBaseOrDryRun : memoryPathOrBase;
123
+ export function initializeMemory(memoryPathOrBase: string, targetBaseOrDryRun?: string | boolean): void {
124
+ const targetBase = typeof targetBaseOrDryRun === "string" ? targetBaseOrDryRun : memoryPathOrBase;
116
125
  initDocumentStore(targetBase);
117
126
  logger.info("✅ Document store initialized.");
118
127
  }
119
128
 
120
- export function getConfiguredPaths(): { backend: string; frontend: string; docs: string; tests: string } {
121
- const defaultPaths = { backend: "apps/backend", frontend: "apps/web", docs: "docs", tests: "tests" };
129
+ export function getConfiguredPaths(): { backend: string; frontend: string; mobile: string; docs: string; tests: string } {
130
+ const defaultPaths = { backend: "apps/backend", frontend: "apps/web", mobile: "apps/mobile", docs: "docs", tests: "tests" };
122
131
  try {
123
132
  const frameworkDir = getConfigDir();
124
133
  const configPath = path.join(frameworkDir, "config.json");
@@ -132,43 +141,117 @@ export function getConfiguredPaths(): { backend: string; frontend: string; docs:
132
141
  return defaultPaths;
133
142
  }
134
143
 
135
- export function updateDocumentStore(type: "state" | "task" | "history" | "status", data: unknown, id?: string, frameworkDir?: string) {
144
+ export function updateDocumentStore(type: "state" | "task" | "history" | "status", data: unknown, id?: string | TraceID, frameworkDir?: string) {
136
145
  const storePath = frameworkDir ? path.join(frameworkDir, "memory") : getDocumentStorePath();
137
146
  ensureDir(storePath);
138
147
 
139
148
  switch (type) {
140
149
  case "state":
141
150
  StateSchema.parse(data);
142
- fs.writeFileSync(path.join(storePath, "state.json"), JSON.stringify(data, null, 2));
151
+ writeJsonFile(path.join(storePath, "state.json"), data);
143
152
  break;
144
153
  case "status":
145
154
  AgentStatusSchema.parse(data);
146
- fs.writeFileSync(path.join(storePath, "status.json"), JSON.stringify(data, null, 2));
155
+ writeJsonFile(path.join(storePath, "status.json"), data);
147
156
  break;
148
157
  case "task":
149
158
  TaskSchema.parse(data);
150
159
  ensureDir(path.join(storePath, "tasks"));
151
- fs.writeFileSync(path.join(storePath, "tasks", `${id}.json`), JSON.stringify(data, null, 2));
160
+ writeJsonFile(path.join(storePath, "tasks", `${id}.json`), data);
152
161
  break;
153
162
  case "history":
154
163
  ensureDir(path.join(storePath, "history"));
155
- fs.writeFileSync(path.join(storePath, "history", `${id}.json`), JSON.stringify(data, null, 2));
164
+ writeJsonFile(path.join(storePath, "history", `${id}.json`), data);
156
165
  break;
157
166
  }
167
+
168
+ // Auto-sync Markdown view after any change
169
+ syncMarkdownMemory(frameworkDir);
170
+ }
171
+
172
+ /**
173
+ * Single Source of Truth Bridge: JSON -> Markdown
174
+ * Regenerates PROJECT_MEMORY.md from structured state.
175
+ */
176
+ export function syncMarkdownMemory(fDir?: string) {
177
+ const frameworkDir = fDir || getFrameworkDir();
178
+ const storePath = path.join(frameworkDir, "memory");
179
+ const mdPath = path.join(storePath, "PROJECT_MEMORY.md");
180
+
181
+ try {
182
+ const state = readState();
183
+ const status = readStatus();
184
+ const tasks = listTasks();
185
+
186
+ if (!state) return;
187
+
188
+ const lines = [
189
+ "# 🧠 Agent Enderun — Project Memory",
190
+ "",
191
+ "## 📍 Current State",
192
+ `- **Phase:** ${state.phase || "PHASE_0"}`,
193
+ `- **Trace ID:** ${state.traceId || "N/A"}`,
194
+ `- **@manager state:** ${state.managerState || "ACTIVE"}`,
195
+ "",
196
+ "## 📋 Active Tasks",
197
+ "| Trace ID | Task | Agent | Priority | Status |",
198
+ "| :--- | :--- | :--- | :--- | :--- |",
199
+ ];
200
+
201
+ tasks.forEach(t => {
202
+ if (t.status !== "COMPLETED") {
203
+ lines.push(`| ${t.traceId} | ${t.description} | ${t.agent} | ${t.priority} | ${t.status} |`);
204
+ }
205
+ });
206
+
207
+ lines.push("", "## 🤖 Agent Statuses");
208
+ lines.push("| Agent | State | Active Task | Last Updated |");
209
+ lines.push("| :--- | :--- | :--- | :--- |");
210
+
211
+ for (const [agent, info] of Object.entries(status)) {
212
+ const data = info as { state: string; task: string; lastUpdated?: string };
213
+ lines.push(`| @${agent} | ${data.state} | ${data.task} | ${data.lastUpdated || "-"} |`);
214
+ }
215
+
216
+ lines.push("", "## 📜 HISTORY");
217
+
218
+ // Add last 5 history items
219
+ const historyDir = path.join(storePath, "history");
220
+ if (fs.existsSync(historyDir)) {
221
+ const histFiles = fs.readdirSync(historyDir)
222
+ .filter(f => f.endsWith(".json"))
223
+ .sort()
224
+ .reverse()
225
+ .slice(0, 10);
226
+
227
+ histFiles.forEach(f => {
228
+ const hist = JSON.parse(fs.readFileSync(path.join(historyDir, f), "utf8"));
229
+ lines.push(`### ${f.replace(".json", "")}`);
230
+ lines.push(hist.content);
231
+ lines.push("");
232
+ });
233
+ }
234
+
235
+ writeTextFile(mdPath, lines.join("\n"));
236
+ logger.debug("Markdown memory synchronized.");
237
+ } catch (err) {
238
+ logger.debug("Markdown memory sync failed", err);
239
+ }
158
240
  }
159
241
 
160
242
 
161
243
  export function acquireMemoryLock(lockPath: string): boolean {
162
244
  try {
163
- fs.writeFileSync(lockPath, String(Date.now()), { flag: 'wx' });
245
+ fs.writeFileSync(lockPath, String(Date.now()), { flag: "wx" });
164
246
  return true;
165
- } catch (err: any) {
166
- if (err.code === 'EEXIST') {
247
+ } catch (err: unknown) {
248
+ const error = err as { code?: string };
249
+ if (error.code === "EEXIST") {
167
250
  try {
168
251
  const stat = fs.statSync(lockPath);
169
252
  if (Date.now() - stat.mtimeMs > 10000) {
170
253
  fs.unlinkSync(lockPath);
171
- fs.writeFileSync(lockPath, String(Date.now()), { flag: 'wx' });
254
+ fs.writeFileSync(lockPath, String(Date.now()), { flag: "wx" });
172
255
  return true;
173
256
  }
174
257
  } catch {
@@ -1,5 +1,6 @@
1
1
  import fs from "fs";
2
2
  import path from "path";
3
+ import { writeTextFile, writeJsonFile } from "./fs.js";
3
4
 
4
5
  export function getPackageVersion() {
5
6
  const root = getPackageRoot();
@@ -43,7 +44,7 @@ function findAgentEnderunPackageRoot(): string {
43
44
  if (fs.existsSync(pkgPath)) {
44
45
  try {
45
46
  const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
46
- if (pkg.name === "agent-enderun" || pkg.name === "enderun-core") {
47
+ if (pkg.name === "agent-enderun") {
47
48
  return current;
48
49
  }
49
50
  } catch {
@@ -203,7 +204,7 @@ export function mergePackageJson(targetPath: string, sourcePath: string): void {
203
204
  initializedAt: new Date().toISOString(),
204
205
  };
205
206
 
206
- fs.writeFileSync(targetPath, JSON.stringify(targetPkg, null, 2));
207
+ writeJsonFile(targetPath, targetPkg);
207
208
  console.warn("✅ package.json updated with Enderun scripts and dependencies.");
208
209
  }
209
210
 
@@ -226,20 +227,20 @@ export function sanitizeJson(obj: unknown, targetScope = ""): unknown {
226
227
  if (targetScope) {
227
228
  const scopeName = targetScope.startsWith("@") ? targetScope.slice(1) : targetScope;
228
229
 
229
- // Handle scoped: @ai-enderun/foo -> @target/foo
230
- if (typeof key === "string" && key.startsWith("@ai-enderun/")) {
231
- finalKey = key.replace("@ai-enderun/", `${targetScope}/`);
230
+ // Handle scoped: @agent-enderun/foo -> @target/foo
231
+ if (typeof key === "string" && key.startsWith("@agent-enderun/")) {
232
+ finalKey = key.replace("@agent-enderun/", `${targetScope}/`);
232
233
  }
233
- if (typeof value === "string" && value.startsWith("@ai-enderun/")) {
234
- finalValue = value.replace("@ai-enderun/", `${targetScope}/`);
234
+ if (typeof value === "string" && value.startsWith("@agent-enderun/")) {
235
+ finalValue = value.replace("@agent-enderun/", `${targetScope}/`);
235
236
  }
236
237
 
237
- // Handle unscoped: ai-enderun-foo -> target-foo
238
- if (typeof key === "string" && key.startsWith("ai-enderun-")) {
239
- finalKey = key.replace("ai-enderun-", `${scopeName}-`);
238
+ // Handle unscoped: agent-enderun-foo -> target-foo
239
+ if (typeof key === "string" && key.startsWith("agent-enderun-")) {
240
+ finalKey = key.replace("agent-enderun-", `${scopeName}-`);
240
241
  }
241
- if (typeof value === "string" && value.startsWith("ai-enderun-")) {
242
- finalValue = value.replace("ai-enderun-", `${scopeName}-`);
242
+ if (typeof value === "string" && value.startsWith("agent-enderun-")) {
243
+ finalValue = value.replace("agent-enderun-", `${scopeName}-`);
243
244
  }
244
245
 
245
246
  // Handle agent-enderun -> target (ONLY for the package name)
@@ -276,7 +277,7 @@ export function deepCleanProtocols(dir: string, targetScope = ""): void {
276
277
  const content = fs.readFileSync(fullPath, "utf8");
277
278
  const json = JSON.parse(content);
278
279
  const cleaned = JSON.stringify(sanitizeJson(json, targetScope), null, 2);
279
- fs.writeFileSync(fullPath, cleaned);
280
+ writeTextFile(fullPath, cleaned);
280
281
  } catch {
281
282
  // ignore malformed json
282
283
  }
@@ -18,7 +18,7 @@ export function insertTaskRow(memoryContent: string, row: string): string | null
18
18
  export function sanitizeInput(input: string): string {
19
19
  return String(input)
20
20
  .replace(/\\/g, "\\\\")
21
- .replace(/"/g, '\\"')
21
+ .replace(/"/g, "\\\"")
22
22
  .replace(/[\r\n]+/g, " ")
23
23
  .replace(/<script\b[^>]*>([\s\S]*?)<\/script>/gim, "")
24
24
  .replace(/--/g, "-")
@@ -1,7 +1,7 @@
1
1
  import chalk from "chalk";
2
2
 
3
3
  /**
4
- * Professional UI Utilities for Enderun Core CLI.
4
+ * Professional UI Utilities for Agent Enderun CLI.
5
5
  * Standardizes headers, status boxes, and strategic intent reporting.
6
6
  */
7
7
 
@@ -1,7 +1,7 @@
1
1
  import path from "path";
2
2
  import fs from "fs";
3
3
  import os from "os";
4
- import { writeJsonFile } from "../../shared/fs.js";
4
+ import { writeJsonFile, writeTextFile } from "../../shared/fs.js";
5
5
  import { ALL_AGENTS, toAntigravityJson } from "../agents/definitions.js";
6
6
  import { CORE_SKILLS } from "../skills/definitions.js";
7
7
 
@@ -42,10 +42,10 @@ export function registerGlobalAntigravityPlugins(mcpBlock: unknown): void {
42
42
  // 1. Nested format (agents/{agent_name}/agent.json)
43
43
  const nestedAgentDir = path.join(agentsBaseDir, ag.name);
44
44
  fs.mkdirSync(nestedAgentDir, { recursive: true });
45
- fs.writeFileSync(path.join(nestedAgentDir, "agent.json"), agentJson);
45
+ writeTextFile(path.join(nestedAgentDir, "agent.json"), agentJson);
46
46
 
47
- // 2. Direct flat format (agents/{agent_name}.json) as subagent definition templates
48
- fs.writeFileSync(path.join(agentsBaseDir, `${ag.name}.json`), agentJson);
47
+ // 2. Direct flat format (agents/{agent_name}.json)
48
+ writeTextFile(path.join(agentsBaseDir, `${ag.name}.json`), agentJson);
49
49
  }
50
50
 
51
51
  // Scaffold skills
@@ -53,10 +53,10 @@ export function registerGlobalAntigravityPlugins(mcpBlock: unknown): void {
53
53
  fs.mkdirSync(skillsDir, { recursive: true });
54
54
  for (const [key, skill] of Object.entries(CORE_SKILLS)) {
55
55
  const skillContent = `# 🛠️ Skill — ${skill.name}\n\n${skill.mandates.join("\n")}\n`;
56
- fs.writeFileSync(path.join(skillsDir, `${key.toLowerCase()}.md`), skillContent);
56
+ writeTextFile(path.join(skillsDir, `${key.toLowerCase()}.md`), skillContent);
57
57
  }
58
58
 
59
- // Scaffold rules (Optional custom codebase rules files)
59
+ // Scaffold rules
60
60
  const rulesDir = path.join(globalPluginDir, "rules");
61
61
  fs.mkdirSync(rulesDir, { recursive: true });
62
62
  for (const ag of ALL_AGENTS) {
@@ -78,7 +78,7 @@ ${ag.instructions.rules.map(r => `- ${r}`).join("\n")}
78
78
  - **Traceability:** Inherit and pass the active Trace ID across all delegations.
79
79
  - **Approval Signature:** High-risk actions require manager approval signature.
80
80
  `;
81
- fs.writeFileSync(path.join(rulesDir, `${ag.name}.md`), ruleContent);
81
+ writeTextFile(path.join(rulesDir, `${ag.name}.md`), ruleContent);
82
82
  }
83
83
 
84
84
  // Scaffold optional empty hooks.json