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.
- package/README.md +294 -19
- package/bin/cli.js +7 -0
- package/bin/enderun-dashboard.js +16 -857
- package/bin/validate-agent-army.js +12 -12
- package/dist/framework-mcp/src/index.js +14 -2
- package/dist/framework-mcp/src/index.js.map +1 -1
- package/dist/framework-mcp/src/tools/file_system/batch_surgical_edit.js +2 -1
- package/dist/framework-mcp/src/tools/file_system/batch_surgical_edit.js.map +1 -1
- package/dist/framework-mcp/src/tools/file_system/replace_text.js +2 -1
- package/dist/framework-mcp/src/tools/file_system/replace_text.js.map +1 -1
- package/dist/framework-mcp/src/tools/file_system/write_file.js +3 -3
- package/dist/framework-mcp/src/tools/file_system/write_file.js.map +1 -1
- package/dist/framework-mcp/src/utils/fs.d.ts +16 -0
- package/dist/framework-mcp/src/utils/fs.js +45 -0
- package/dist/framework-mcp/src/utils/fs.js.map +1 -0
- package/dist/framework-mcp/src/utils/metrics.js.map +1 -1
- package/dist/src/cli/adapters/core.js.map +1 -1
- package/dist/src/cli/adapters/scaffold.js +4 -3
- package/dist/src/cli/adapters/scaffold.js.map +1 -1
- package/dist/src/cli/commands/app.js +20 -5
- package/dist/src/cli/commands/app.js.map +1 -1
- package/dist/src/cli/commands/approve.d.ts +1 -1
- package/dist/src/cli/commands/approve.js +7 -7
- package/dist/src/cli/commands/approve.js.map +1 -1
- package/dist/src/cli/commands/check.d.ts +1 -1
- package/dist/src/cli/commands/check.js +35 -4
- package/dist/src/cli/commands/check.js.map +1 -1
- package/dist/src/cli/commands/compliance.d.ts +1 -1
- package/dist/src/cli/commands/compliance.js +1 -1
- package/dist/src/cli/commands/compliance.js.map +1 -1
- package/dist/src/cli/commands/contract.d.ts +2 -2
- package/dist/src/cli/commands/contract.js +8 -14
- package/dist/src/cli/commands/contract.js.map +1 -1
- package/dist/src/cli/commands/dashboard/data-service.d.ts +33 -0
- package/dist/src/cli/commands/dashboard/data-service.js +120 -0
- package/dist/src/cli/commands/dashboard/data-service.js.map +1 -0
- package/dist/src/cli/commands/dashboard/html-template.d.ts +4 -0
- package/dist/src/cli/commands/dashboard/html-template.js +697 -0
- package/dist/src/cli/commands/dashboard/html-template.js.map +1 -0
- package/dist/src/cli/commands/dashboard/server.d.ts +2 -0
- package/dist/src/cli/commands/dashboard/server.js +38 -0
- package/dist/src/cli/commands/dashboard/server.js.map +1 -0
- package/dist/src/cli/commands/dashboard.d.ts +4 -0
- package/dist/src/cli/commands/dashboard.js +10 -0
- package/dist/src/cli/commands/dashboard.js.map +1 -0
- package/dist/src/cli/commands/explorer.d.ts +2 -2
- package/dist/src/cli/commands/explorer.js +2 -2
- package/dist/src/cli/commands/explorer.js.map +1 -1
- package/dist/src/cli/commands/git.d.ts +2 -2
- package/dist/src/cli/commands/git.js +2 -2
- package/dist/src/cli/commands/git.js.map +1 -1
- package/dist/src/cli/commands/init/scaffold-core.d.ts +4 -0
- package/dist/src/cli/commands/init/scaffold-core.js +65 -0
- package/dist/src/cli/commands/init/scaffold-core.js.map +1 -0
- package/dist/src/cli/commands/init/scaffold-ops.d.ts +1 -0
- package/dist/src/cli/commands/init/scaffold-ops.js +83 -0
- package/dist/src/cli/commands/init/scaffold-ops.js.map +1 -0
- package/dist/src/cli/commands/init/scaffold-standards.d.ts +2 -0
- package/dist/src/cli/commands/init/scaffold-standards.js +58 -0
- package/dist/src/cli/commands/init/scaffold-standards.js.map +1 -0
- package/dist/src/cli/commands/init.js +14 -275
- package/dist/src/cli/commands/init.js.map +1 -1
- package/dist/src/cli/commands/knowledge.d.ts +2 -2
- package/dist/src/cli/commands/knowledge.js +4 -3
- package/dist/src/cli/commands/knowledge.js.map +1 -1
- package/dist/src/cli/commands/lint.d.ts +1 -1
- package/dist/src/cli/commands/lint.js +2 -3
- package/dist/src/cli/commands/lint.js.map +1 -1
- package/dist/src/cli/commands/log.d.ts +1 -1
- package/dist/src/cli/commands/log.js +3 -2
- package/dist/src/cli/commands/log.js.map +1 -1
- package/dist/src/cli/commands/memory.d.ts +1 -1
- package/dist/src/cli/commands/memory.js +1 -1
- package/dist/src/cli/commands/memory.js.map +1 -1
- package/dist/src/cli/commands/orchestrate.js +169 -140
- package/dist/src/cli/commands/orchestrate.js.map +1 -1
- package/dist/src/cli/commands/plan.d.ts +1 -1
- package/dist/src/cli/commands/plan.js +1 -1
- package/dist/src/cli/commands/plan.js.map +1 -1
- package/dist/src/cli/commands/script.d.ts +1 -1
- package/dist/src/cli/commands/script.js +1 -1
- package/dist/src/cli/commands/script.js.map +1 -1
- package/dist/src/cli/commands/security.d.ts +1 -1
- package/dist/src/cli/commands/security.js +1 -1
- package/dist/src/cli/commands/security.js.map +1 -1
- package/dist/src/cli/commands/status.d.ts +1 -1
- package/dist/src/cli/commands/status.js +1 -1
- package/dist/src/cli/commands/status.js.map +1 -1
- package/dist/src/cli/commands/trace.d.ts +1 -1
- package/dist/src/cli/commands/trace.js +1 -1
- package/dist/src/cli/commands/trace.js.map +1 -1
- package/dist/src/cli/index.js +36 -21
- package/dist/src/cli/index.js.map +1 -1
- package/dist/src/cli/shims.js +6 -6
- package/dist/src/cli/utils/app-backend.js +7 -0
- package/dist/src/cli/utils/app-backend.js.map +1 -1
- package/dist/src/cli/utils/app-docs.js +23 -5
- package/dist/src/cli/utils/app-docs.js.map +1 -1
- package/dist/src/cli/utils/app-frontend.js +5 -0
- package/dist/src/cli/utils/app-frontend.js.map +1 -1
- package/dist/src/cli/utils/app-inferrer.d.ts +1 -0
- package/dist/src/cli/utils/app-inferrer.js +12 -1
- package/dist/src/cli/utils/app-inferrer.js.map +1 -1
- package/dist/src/cli/utils/app-mobile.d.ts +2 -0
- package/dist/src/cli/utils/app-mobile.js +106 -0
- package/dist/src/cli/utils/app-mobile.js.map +1 -0
- package/dist/src/cli/utils/app-types.js +8 -4
- package/dist/src/cli/utils/app-types.js.map +1 -1
- package/dist/src/cli/utils/app.d.ts +1 -0
- package/dist/src/cli/utils/app.js +1 -0
- package/dist/src/cli/utils/app.js.map +1 -1
- package/dist/src/cli/utils/claude.js +2 -1
- package/dist/src/cli/utils/claude.js.map +1 -1
- package/dist/src/cli/utils/compliance.js +37 -6
- package/dist/src/cli/utils/compliance.js.map +1 -1
- package/dist/src/cli/utils/config-schema.d.ts +3 -3
- package/dist/src/cli/utils/config-schema.js +3 -3
- package/dist/src/cli/utils/config-schema.js.map +1 -1
- package/dist/src/cli/utils/fs.d.ts +2 -2
- package/dist/src/cli/utils/fs.js +9 -13
- package/dist/src/cli/utils/fs.js.map +1 -1
- package/dist/src/cli/utils/memory.d.ts +9 -2
- package/dist/src/cli/utils/memory.js +87 -16
- package/dist/src/cli/utils/memory.js.map +1 -1
- package/dist/src/cli/utils/pkg.js +14 -13
- package/dist/src/cli/utils/pkg.js.map +1 -1
- package/dist/src/cli/utils/string.js +1 -1
- package/dist/src/cli/utils/string.js.map +1 -1
- package/dist/src/cli/utils/ui.d.ts +1 -1
- package/dist/src/cli/utils/ui.js +1 -1
- package/dist/src/modules/adapters/shared.js +7 -7
- package/dist/src/modules/adapters/shared.js.map +1 -1
- package/dist/src/modules/agents/definitions.d.ts +3 -34
- package/dist/src/modules/agents/definitions.js +35 -511
- package/dist/src/modules/agents/definitions.js.map +1 -1
- package/dist/src/modules/agents/registry/analyst.d.ts +2 -0
- package/dist/src/modules/agents/registry/analyst.js +36 -0
- package/dist/src/modules/agents/registry/analyst.js.map +1 -0
- package/dist/src/modules/agents/registry/architect.d.ts +2 -0
- package/dist/src/modules/agents/registry/architect.js +42 -0
- package/dist/src/modules/agents/registry/architect.js.map +1 -0
- package/dist/src/modules/agents/registry/backend.d.ts +2 -0
- package/dist/src/modules/agents/registry/backend.js +43 -0
- package/dist/src/modules/agents/registry/backend.js.map +1 -0
- package/dist/src/modules/agents/registry/database.d.ts +2 -0
- package/dist/src/modules/agents/registry/database.js +38 -0
- package/dist/src/modules/agents/registry/database.js.map +1 -0
- package/dist/src/modules/agents/registry/devops.d.ts +2 -0
- package/dist/src/modules/agents/registry/devops.js +38 -0
- package/dist/src/modules/agents/registry/devops.js.map +1 -0
- package/dist/src/modules/agents/registry/explorer.d.ts +2 -0
- package/dist/src/modules/agents/registry/explorer.js +36 -0
- package/dist/src/modules/agents/registry/explorer.js.map +1 -0
- package/dist/src/modules/agents/registry/frontend.d.ts +2 -0
- package/dist/src/modules/agents/registry/frontend.js +44 -0
- package/dist/src/modules/agents/registry/frontend.js.map +1 -0
- package/dist/src/modules/agents/registry/git.d.ts +2 -0
- package/dist/src/modules/agents/registry/git.js +35 -0
- package/dist/src/modules/agents/registry/git.js.map +1 -0
- package/dist/src/modules/agents/registry/manager.d.ts +2 -0
- package/dist/src/modules/agents/registry/manager.js +49 -0
- package/dist/src/modules/agents/registry/manager.js.map +1 -0
- package/dist/src/modules/agents/registry/mobile.d.ts +2 -0
- package/dist/src/modules/agents/registry/mobile.js +40 -0
- package/dist/src/modules/agents/registry/mobile.js.map +1 -0
- package/dist/src/modules/agents/registry/native.d.ts +2 -0
- package/dist/src/modules/agents/registry/native.js +36 -0
- package/dist/src/modules/agents/registry/native.js.map +1 -0
- package/dist/src/modules/agents/registry/quality.d.ts +2 -0
- package/dist/src/modules/agents/registry/quality.js +41 -0
- package/dist/src/modules/agents/registry/quality.js.map +1 -0
- package/dist/src/modules/agents/registry/security.d.ts +2 -0
- package/dist/src/modules/agents/registry/security.js +37 -0
- package/dist/src/modules/agents/registry/security.js.map +1 -0
- package/dist/src/modules/agents/types.d.ts +31 -0
- package/dist/src/modules/agents/types.js +2 -0
- package/dist/src/modules/agents/types.js.map +1 -0
- package/dist/src/modules/skills/definitions.d.ts +1 -1
- package/dist/src/modules/skills/definitions.js +1 -1
- package/dist/src/shared/errors.d.ts +8 -6
- package/dist/src/shared/errors.js +13 -10
- package/dist/src/shared/errors.js.map +1 -1
- package/dist/src/shared/fs.d.ts +4 -0
- package/dist/src/shared/fs.js +17 -2
- package/dist/src/shared/fs.js.map +1 -1
- package/dist/src/shared/types.d.ts +19 -0
- package/dist/src/shared/types.js +13 -0
- package/dist/src/shared/types.js.map +1 -0
- package/package.json +3 -5
- package/src/cli/adapters/core.ts +0 -1
- package/src/cli/adapters/scaffold.ts +4 -3
- package/src/cli/commands/app.ts +23 -5
- package/src/cli/commands/approve.ts +15 -7
- package/src/cli/commands/check.ts +38 -5
- package/src/cli/commands/compliance.ts +1 -1
- package/src/cli/commands/contract.ts +20 -14
- package/src/cli/commands/dashboard/data-service.ts +119 -0
- package/src/cli/commands/dashboard/html-template.ts +696 -0
- package/src/cli/commands/dashboard/server.ts +43 -0
- package/src/cli/commands/dashboard.ts +11 -0
- package/src/cli/commands/explorer.ts +2 -2
- package/src/cli/commands/git.ts +2 -2
- package/src/cli/commands/init/scaffold-core.ts +71 -0
- package/src/cli/commands/init/scaffold-ops.ts +86 -0
- package/src/cli/commands/init/scaffold-standards.ts +59 -0
- package/src/cli/commands/init.ts +21 -292
- package/src/cli/commands/knowledge.ts +5 -3
- package/src/cli/commands/lint.ts +2 -4
- package/src/cli/commands/log.ts +4 -2
- package/src/cli/commands/memory.ts +1 -1
- package/src/cli/commands/orchestrate.ts +177 -142
- package/src/cli/commands/plan.ts +1 -1
- package/src/cli/commands/script.ts +1 -1
- package/src/cli/commands/security.ts +1 -1
- package/src/cli/commands/status.ts +1 -1
- package/src/cli/commands/trace.ts +1 -1
- package/src/cli/index.ts +37 -21
- package/src/cli/shims.ts +6 -6
- package/src/cli/utils/app-backend.ts +8 -0
- package/src/cli/utils/app-docs.ts +23 -5
- package/src/cli/utils/app-frontend.ts +6 -0
- package/src/cli/utils/app-inferrer.ts +11 -1
- package/src/cli/utils/app-mobile.ts +113 -0
- package/src/cli/utils/app-types.ts +9 -4
- package/src/cli/utils/app.ts +1 -0
- package/src/cli/utils/claude.ts +2 -1
- package/src/cli/utils/compliance.ts +38 -7
- package/src/cli/utils/config-schema.ts +4 -4
- package/src/cli/utils/fs.ts +9 -14
- package/src/cli/utils/memory.ts +103 -20
- package/src/cli/utils/pkg.ts +14 -13
- package/src/cli/utils/string.ts +1 -1
- package/src/cli/utils/ui.ts +1 -1
- package/src/modules/adapters/shared.ts +7 -7
- package/src/modules/agents/definitions.ts +39 -598
- package/src/modules/agents/registry/analyst.ts +40 -0
- package/src/modules/agents/registry/architect.ts +46 -0
- package/src/modules/agents/registry/backend.ts +47 -0
- package/src/modules/agents/registry/database.ts +42 -0
- package/src/modules/agents/registry/devops.ts +42 -0
- package/src/modules/agents/registry/explorer.ts +40 -0
- package/src/modules/agents/registry/frontend.ts +48 -0
- package/src/modules/agents/registry/git.ts +39 -0
- package/src/modules/agents/registry/manager.ts +53 -0
- package/src/modules/agents/registry/mobile.ts +44 -0
- package/src/modules/agents/registry/native.ts +40 -0
- package/src/modules/agents/registry/quality.ts +45 -0
- package/src/modules/agents/registry/security.ts +41 -0
- package/src/modules/agents/types.ts +37 -0
- package/src/modules/skills/definitions.ts +1 -1
- package/src/shared/errors.ts +13 -10
- package/src/shared/fs.ts +17 -2
- package/src/shared/types.ts +20 -0
- package/bin/utils/docgen.ts +0 -24
package/src/cli/utils/memory.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
115
|
-
const targetBase = typeof targetBaseOrDryRun ===
|
|
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
|
-
|
|
151
|
+
writeJsonFile(path.join(storePath, "state.json"), data);
|
|
143
152
|
break;
|
|
144
153
|
case "status":
|
|
145
154
|
AgentStatusSchema.parse(data);
|
|
146
|
-
|
|
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
|
-
|
|
160
|
+
writeJsonFile(path.join(storePath, "tasks", `${id}.json`), data);
|
|
152
161
|
break;
|
|
153
162
|
case "history":
|
|
154
163
|
ensureDir(path.join(storePath, "history"));
|
|
155
|
-
|
|
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:
|
|
245
|
+
fs.writeFileSync(lockPath, String(Date.now()), { flag: "wx" });
|
|
164
246
|
return true;
|
|
165
|
-
} catch (err:
|
|
166
|
-
|
|
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:
|
|
254
|
+
fs.writeFileSync(lockPath, String(Date.now()), { flag: "wx" });
|
|
172
255
|
return true;
|
|
173
256
|
}
|
|
174
257
|
} catch {
|
package/src/cli/utils/pkg.ts
CHANGED
|
@@ -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"
|
|
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
|
-
|
|
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: @
|
|
230
|
-
if (typeof key === "string" && key.startsWith("@
|
|
231
|
-
finalKey = key.replace("@
|
|
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("@
|
|
234
|
-
finalValue = value.replace("@
|
|
234
|
+
if (typeof value === "string" && value.startsWith("@agent-enderun/")) {
|
|
235
|
+
finalValue = value.replace("@agent-enderun/", `${targetScope}/`);
|
|
235
236
|
}
|
|
236
237
|
|
|
237
|
-
// Handle unscoped:
|
|
238
|
-
if (typeof key === "string" && key.startsWith("
|
|
239
|
-
finalKey = key.replace("
|
|
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("
|
|
242
|
-
finalValue = value.replace("
|
|
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
|
-
|
|
280
|
+
writeTextFile(fullPath, cleaned);
|
|
280
281
|
} catch {
|
|
281
282
|
// ignore malformed json
|
|
282
283
|
}
|
package/src/cli/utils/string.ts
CHANGED
|
@@ -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, "-")
|
package/src/cli/utils/ui.ts
CHANGED
|
@@ -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
|
-
|
|
45
|
+
writeTextFile(path.join(nestedAgentDir, "agent.json"), agentJson);
|
|
46
46
|
|
|
47
|
-
// 2. Direct flat format (agents/{agent_name}.json)
|
|
48
|
-
|
|
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
|
-
|
|
56
|
+
writeTextFile(path.join(skillsDir, `${key.toLowerCase()}.md`), skillContent);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
// Scaffold rules
|
|
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
|
-
|
|
81
|
+
writeTextFile(path.join(rulesDir, `${ag.name}.md`), ruleContent);
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
// Scaffold optional empty hooks.json
|