@askexenow/exe-os 0.9.294 → 0.9.296
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/deploy/compose/cloudflared/config.yml.example +14 -9
- package/deploy/compose/docker-compose.yml +86 -8
- package/deploy/compose/sso-edge/default.conf.template +87 -0
- package/deploy/compose/sso-edge/entrypoint.sh +23 -0
- package/deploy/compose/sso-edge/sso-redirect.conf +63 -0
- package/deploy/stack-manifests/v0.9.json +2 -2
- package/dist/active-agent-AFX2FODG.js +28 -0
- package/dist/active-agent-E2IJA7YX.js +27 -0
- package/dist/agentic-ontology-A2YUZK5O.js +25 -0
- package/dist/assets/com.askexe.exed.plist +4 -1
- package/dist/backfill-metadata-OC7EOD5U.js +600 -0
- package/dist/behaviors-H5ZOVHDH.js +46 -0
- package/dist/bin/agentic-ontology-backfill.js +5 -5
- package/dist/bin/agentic-reflection-backfill.js +6 -6
- package/dist/bin/agentic-semantic-label.js +5 -5
- package/dist/bin/backfill-conversations.js +6 -6
- package/dist/bin/backfill-responses.js +6 -6
- package/dist/bin/backfill-vectors.js +8 -8
- package/dist/bin/bulk-sync-postgres.js +7 -7
- package/dist/bin/cc-doctor.js +4 -4
- package/dist/bin/cleanup-stale-review-tasks.js +11 -11
- package/dist/bin/cli.js +16 -16
- package/dist/bin/deferred-daemon-restart.js +1 -1
- package/dist/bin/exe-agent-config.js +2 -2
- package/dist/bin/exe-agent.js +4 -4
- package/dist/bin/exe-assign.js +8 -8
- package/dist/bin/exe-boot.js +21 -18
- package/dist/bin/exe-call.js +4 -4
- package/dist/bin/exe-cloud.js +7 -7
- package/dist/bin/exe-dispatch.js +11 -11
- package/dist/bin/exe-doctor.js +3 -2
- package/dist/bin/exe-export-behaviors.js +7 -7
- package/dist/bin/exe-forget.js +6 -6
- package/dist/bin/exe-gateway.js +7 -7
- package/dist/bin/exe-healthcheck.js +6 -4
- package/dist/bin/exe-heartbeat.js +11 -11
- package/dist/bin/exe-kill.js +14 -14
- package/dist/bin/exe-launch-agent.js +18 -18
- package/dist/bin/exe-new-employee.js +6 -6
- package/dist/bin/exe-pending-messages.js +12 -12
- package/dist/bin/exe-pending-notifications.js +11 -11
- package/dist/bin/exe-pending-reviews.js +11 -11
- package/dist/bin/exe-rename.js +4 -4
- package/dist/bin/exe-review.js +13 -13
- package/dist/bin/exe-search.js +5 -5
- package/dist/bin/exe-session-cleanup.js +16 -16
- package/dist/bin/exe-settings.js +39 -9
- package/dist/bin/exe-start-codex.js +11 -11
- package/dist/bin/exe-start-opencode.js +8 -8
- package/dist/bin/exe-status.js +12 -12
- package/dist/bin/exe-team.js +3 -3
- package/dist/bin/git-sweep.js +12 -12
- package/dist/bin/graph-backfill.js +4 -4
- package/dist/bin/graph-export.js +5 -5
- package/dist/bin/import-history.js +7 -7
- package/dist/bin/install-launchd.js +13 -6
- package/dist/bin/install.js +26 -14
- package/dist/bin/intercom-check.js +4 -4
- package/dist/bin/mcp-sessions.js +2 -2
- package/dist/bin/orchestration-metrics.js +4 -4
- package/dist/bin/postgres-agentic-reflection-backfill.js +2 -2
- package/dist/bin/postgres-agentic-semantic-backfill.js +1 -1
- package/dist/bin/scan-tasks.js +11 -11
- package/dist/bin/setup.js +1 -1
- package/dist/bin/shard-migrate.js +4 -4
- package/dist/bin/stack-update.js +2 -2
- package/dist/bin/vps-health-gate.js +1 -1
- package/dist/capability-cards-4USI7CUW.js +89 -0
- package/dist/capacity-monitor-WLCBTEYR.js +51 -0
- package/dist/catchup-brief-ZR3NX6LZ.js +175 -0
- package/dist/chunk-22TVSRQQ.js +226 -0
- package/dist/chunk-2E43UXRH.js +395 -0
- package/dist/chunk-2PIGT6UJ.js +460 -0
- package/dist/chunk-3XTMW2MZ.js +535 -0
- package/dist/chunk-465PQFTH.js +262 -0
- package/dist/chunk-5CCXU2AW.js +129 -0
- package/dist/chunk-5D6MPWR7.js +1094 -0
- package/dist/chunk-5Q4MR6SL.js +123 -0
- package/dist/chunk-6327RBWR.js +345 -0
- package/dist/chunk-6MZZREZY.js +199 -0
- package/dist/chunk-7DI2Q4O5.js +1186 -0
- package/dist/chunk-7PW5VNIY.js +122 -0
- package/dist/chunk-7T7Y56HW.js +43 -0
- package/dist/chunk-7UHCWCLT.js +128 -0
- package/dist/chunk-A2ZUMF6L.js +1350 -0
- package/dist/chunk-AKV44JEH.js +185 -0
- package/dist/chunk-ANHWGX5N.js +735 -0
- package/dist/chunk-BQ3P4TKD.js +97 -0
- package/dist/chunk-BUZMT3KZ.js +604 -0
- package/dist/chunk-C2SBESBO.js +210 -0
- package/dist/chunk-CLSXZUZW.js +51 -0
- package/dist/chunk-CONHLVAR.js +1079 -0
- package/dist/chunk-D3WTZPFX.js +456 -0
- package/dist/chunk-DE6SOIYL.js +197 -0
- package/dist/chunk-EIVNMA3Q.js +284 -0
- package/dist/chunk-EJIF4FNT.js +12 -0
- package/dist/chunk-FDFOW564.js +171 -0
- package/dist/chunk-GZUBJ5EC.js +127 -0
- package/dist/chunk-HGZITN22.js +105 -0
- package/dist/chunk-HSRKDU6X.js +362 -0
- package/dist/chunk-IIEN2PHV.js +85 -0
- package/dist/chunk-JQ56VLMM.js +567 -0
- package/dist/chunk-JVHHXRFY.js +280 -0
- package/dist/chunk-JXCXGZ3S.js +55 -0
- package/dist/chunk-K5ZO532Q.js +4388 -0
- package/dist/chunk-K6CAAMXF.js +97 -0
- package/dist/chunk-KA26YTNU.js +81 -0
- package/dist/chunk-KMUW5C3R.js +381 -0
- package/dist/chunk-KOO3J5PV.js +20 -0
- package/dist/chunk-LSV7OFIH.js +290 -0
- package/dist/chunk-LSVFDVNY.js +1158 -0
- package/dist/chunk-LXDQTW32.js +230 -0
- package/dist/chunk-MEP7OUVZ.js +181 -0
- package/dist/chunk-MN2B2LKS.js +240 -0
- package/dist/chunk-N2EAYPYQ.js +1352 -0
- package/dist/chunk-N7I2A667.js +70 -0
- package/dist/chunk-NLZHVIOP.js +630 -0
- package/dist/chunk-NUH5TRZL.js +227 -0
- package/dist/chunk-OAHEIH3G.js +167 -0
- package/dist/chunk-OBHRQGCK.js +58 -0
- package/dist/chunk-ODFA7B2V.js +54 -0
- package/dist/chunk-OSNUP45F.js +731 -0
- package/dist/chunk-OTPRHBTO.js +33 -0
- package/dist/chunk-P6MUA4QU.js +157 -0
- package/dist/chunk-PGIOFKSK.js +2093 -0
- package/dist/chunk-PSE7VHWK.js +50 -0
- package/dist/chunk-QIFUVZFW.js +331 -0
- package/dist/chunk-RDPXKTVK.js +221 -0
- package/dist/chunk-RKYTYJGB.js +76 -0
- package/dist/chunk-RXLR6EFM.js +348 -0
- package/dist/chunk-SDB67PQJ.js +159 -0
- package/dist/chunk-SF2T7MP3.js +402 -0
- package/dist/chunk-SLU3FRFQ.js +2133 -0
- package/dist/chunk-SNDZJ5IV.js +214 -0
- package/dist/chunk-STEEAABW.js +448 -0
- package/dist/chunk-TUTWNHIQ.js +244 -0
- package/dist/chunk-UDP35QBR.js +30 -0
- package/dist/chunk-UKFHNJBI.js +85 -0
- package/dist/chunk-VC2DTK2X.js +382 -0
- package/dist/chunk-VRRAE5JX.js +836 -0
- package/dist/chunk-VVJTBQPR.js +38 -0
- package/dist/chunk-W3EQ362K.js +581 -0
- package/dist/chunk-WHIXIFHC.js +2242 -0
- package/dist/chunk-WRNGJJNR.js +377 -0
- package/dist/chunk-WUKHLCBE.js +3313 -0
- package/dist/chunk-WVPLHGDG.js +150 -0
- package/dist/chunk-XJZBSTL5.js +204 -0
- package/dist/chunk-Y3PMNUM5.js +304 -0
- package/dist/chunk-YHVS4QOV.js +14597 -0
- package/dist/chunk-YJ2OYAOC.js +668 -0
- package/dist/chunk-YYAD2GXX.js +128 -0
- package/dist/chunk-ZQML7EWE.js +333 -0
- package/dist/co-activation-XJLH46OX.js +74 -0
- package/dist/co-occurrence-GNN2X526.js +95 -0
- package/dist/code-context-index-OCPRLFG5.js +30 -0
- package/dist/core-memory-J4W2IYOF.js +110 -0
- package/dist/crdt-sync-QCBTSHIH.js +33 -0
- package/dist/crm-webhook-EM442VUW.js +10 -0
- package/dist/cto-delegation-gate-MLJMVHBK.js +280 -0
- package/dist/daemon-orchestration-2VNLZVTW.js +139 -0
- package/dist/db-backup-VUGFTPJ4.js +43 -0
- package/dist/doc-graph-extractor-PNRSFPSS.js +133 -0
- package/dist/dreaming-SK5VEQRF.js +34 -0
- package/dist/entity-boost-TQWWJUC2.js +375 -0
- package/dist/exe-drift-N34UPO7S.js +70 -0
- package/dist/exe-export-KACBKGVV.js +77 -0
- package/dist/exe-import-GXGDWACG.js +80 -0
- package/dist/exe-key-XPDOZBWW.js +673 -0
- package/dist/exe-snapshot-32GQKGQ5.js +338 -0
- package/dist/fast-db-init-F3TDD5VV.js +7 -0
- package/dist/gateway/index.js +8 -8
- package/dist/git-staleness-J45WNYRF.js +112 -0
- package/dist/git-task-sweep-BTGVQPFB.js +42 -0
- package/dist/global-procedures-6JCQWU4D.js +22 -0
- package/dist/graph-auto-extract-3ZQNXTPC.js +183 -0
- package/dist/hooks/bug-report-worker.js +13 -13
- package/dist/hooks/codex-stop-task-finalizer.js +13 -13
- package/dist/hooks/commit-complete.js +13 -13
- package/dist/hooks/error-recall.js +6 -6
- package/dist/hooks/exe-heartbeat-hook.js +3 -3
- package/dist/hooks/ingest-worker.js +3 -3
- package/dist/hooks/ingest.js +6 -6
- package/dist/hooks/instructions-loaded.js +4 -4
- package/dist/hooks/manifest.json +20 -20
- package/dist/hooks/notification.js +4 -4
- package/dist/hooks/post-compact.js +12 -12
- package/dist/hooks/post-tool-combined.js +6 -6
- package/dist/hooks/pre-compact.js +16 -16
- package/dist/hooks/pre-tool-use.js +16 -16
- package/dist/hooks/prompt-submit.js +24 -24
- package/dist/hooks/session-end.js +21 -21
- package/dist/hooks/session-start.js +12 -12
- package/dist/hooks/stop.js +19 -19
- package/dist/hooks/subagent-stop.js +12 -12
- package/dist/hooks/summary-worker.js +19 -19
- package/dist/index.js +19 -19
- package/dist/installer-5VPFY7SB.js +298 -0
- package/dist/installer-OENFPMA2.js +344 -0
- package/dist/installer-OIX4QOG5.js +40 -0
- package/dist/lib/cloud-sync.js +7 -7
- package/dist/lib/consolidation.js +6 -5
- package/dist/lib/database.js +2 -2
- package/dist/lib/db-daemon-client.js +2 -2
- package/dist/lib/db.js +2 -2
- package/dist/lib/embed-worker.js +1 -0
- package/dist/lib/embedder.js +7 -3
- package/dist/lib/employee-templates.js +4 -4
- package/dist/lib/employees.js +2 -2
- package/dist/lib/exe-daemon-client.js +2 -2
- package/dist/lib/exe-daemon.js +160 -79
- package/dist/lib/hybrid-search.js +5 -5
- package/dist/lib/identity.js +2 -2
- package/dist/lib/messaging.js +11 -11
- package/dist/lib/reminders.js +3 -3
- package/dist/lib/schedules.js +5 -5
- package/dist/lib/session-registry.js +4 -4
- package/dist/lib/skill-learning.js +6 -6
- package/dist/lib/store.js +4 -4
- package/dist/lib/task-router.js +3 -3
- package/dist/lib/tasks.js +12 -12
- package/dist/lib/tmux-routing.js +12 -10
- package/dist/lib/tmux-transport.js +1 -1
- package/dist/lib/token-spend.js +3 -3
- package/dist/lib/transport.js +2 -2
- package/dist/mcp/register-tools.js +62 -61
- package/dist/mcp/server.js +63 -62
- package/dist/mcp/tools/complete-reminder.js +4 -4
- package/dist/mcp/tools/create-reminder.js +4 -4
- package/dist/mcp/tools/create-task.js +14 -14
- package/dist/mcp/tools/deactivate-behavior.js +7 -7
- package/dist/mcp/tools/list-reminders.js +4 -4
- package/dist/mcp/tools/list-tasks.js +14 -14
- package/dist/mcp/tools/send-message.js +13 -13
- package/dist/mcp/tools/update-task.js +13 -13
- package/dist/mcp-http-config-PQTOLCTP.js +29 -0
- package/dist/memory-cards-4RVDZIY2.js +180 -0
- package/dist/memory-graph-extractor-L6YC7G4M.js +22 -0
- package/dist/memory-poisoning-defense-4YVJYH4G.js +224 -0
- package/dist/memory-queue-client-MVAUOZNJ.js +16 -0
- package/dist/memory-reflection-SHHDQNOH.js +244 -0
- package/dist/message-queue-client-DCKZT6X2.js +92 -0
- package/dist/notifications-JFR3G42W.js +47 -0
- package/dist/orchestration-events-MGCGPTDN.js +27 -0
- package/dist/orchestrator-DAFL2YZB.js +35 -0
- package/dist/pipeline-router-WWSZVPCH.js +15 -0
- package/dist/plan-limits-C7XCSDZC.js +28 -0
- package/dist/project-boot-N3NTBVLE.js +299 -0
- package/dist/projection-worker-MTPAPCWX.js +1084 -0
- package/dist/prospective-memory-BTIVUJSB.js +232 -0
- package/dist/reranker-UA6WVESJ.js +19 -0
- package/dist/retrieval-health-7XNZJEBF.js +12 -0
- package/dist/review-polling-4ALGMXC3.js +126 -0
- package/dist/runtime/index.js +13 -13
- package/dist/self-query-router-MROFQLQB.js +192 -0
- package/dist/session-events-CK44XOU4.js +38 -0
- package/dist/session-kill-telemetry-MT6ITDOG.js +31 -0
- package/dist/session-scope-3XDBWV65.js +88 -0
- package/dist/setup-wizard-X6DOD7MC.js +12 -0
- package/dist/skill-refinement-G2CCY3GM.js +159 -0
- package/dist/stack-update-JF7F56AS.js +84 -0
- package/dist/steward-gate-YF2CYXE7.js +15 -0
- package/dist/task-enforcement-YN6HK7NE.js +506 -0
- package/dist/task-scope-CVK6ISCZ.js +37 -0
- package/dist/tasks-crud-NTNET4JE.js +79 -0
- package/dist/tasks-notify-4LJVFPCV.js +40 -0
- package/dist/tasks-review-3V4WOIRG.js +49 -0
- package/dist/telemetry-upload-5PNUKGTM.js +741 -0
- package/dist/token-budget-E46G7ZAQ.js +86 -0
- package/dist/tool-capability-index-JDSMKJER.js +10 -0
- package/dist/tool-telemetry-J3NLS3LJ.js +17 -0
- package/dist/tui/App.js +18 -18
- package/dist/tui-data-6DOMUUCM.js +260 -0
- package/dist/wiki-acl-5UK37LKF.js +111 -0
- package/dist/worker-gate-FM7AEC7G.js +21 -0
- package/dist/workflow-engine-2EDUHUIY.js +28 -0
- package/dist/worktree-7YKKJIYR.js +28 -0
- package/dist/worktree-sweep-C3ELFGDN.js +21 -0
- package/package.json +1 -1
- package/release-notes.json +88 -88
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import {
|
|
2
|
+
recordOrchestrationEventBestEffort
|
|
3
|
+
} from "./chunk-NLZHVIOP.js";
|
|
4
|
+
|
|
5
|
+
// src/lib/worktree.ts
|
|
6
|
+
import { execSync } from "child_process";
|
|
7
|
+
import { existsSync, readFileSync, appendFileSync, mkdirSync, realpathSync } from "fs";
|
|
8
|
+
import path from "path";
|
|
9
|
+
var GIT_TIMEOUT_MS = 1e4;
|
|
10
|
+
function getGitRoot(dir) {
|
|
11
|
+
try {
|
|
12
|
+
const root = execSync("git rev-parse --show-toplevel", {
|
|
13
|
+
cwd: dir,
|
|
14
|
+
encoding: "utf-8",
|
|
15
|
+
timeout: GIT_TIMEOUT_MS,
|
|
16
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
17
|
+
}).trim();
|
|
18
|
+
return realpath(root);
|
|
19
|
+
} catch {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function getMainRepoRoot(dir) {
|
|
24
|
+
try {
|
|
25
|
+
const commonDir = execSync(
|
|
26
|
+
"git rev-parse --path-format=absolute --git-common-dir",
|
|
27
|
+
{ cwd: dir, encoding: "utf-8", timeout: GIT_TIMEOUT_MS, stdio: ["pipe", "pipe", "pipe"] }
|
|
28
|
+
).trim();
|
|
29
|
+
return realpath(path.dirname(commonDir));
|
|
30
|
+
} catch {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function worktreePath(repoRoot, employeeName, instance) {
|
|
35
|
+
const label = instanceLabel(employeeName, instance);
|
|
36
|
+
return path.join(repoRoot, ".worktrees", label);
|
|
37
|
+
}
|
|
38
|
+
function worktreeBranch(employeeName, instance, taskSlug) {
|
|
39
|
+
const label = instanceLabel(employeeName, instance);
|
|
40
|
+
if (taskSlug) {
|
|
41
|
+
const slug = taskSlug.slice(0, 40).replace(/[^a-z0-9-]/gi, "-").replace(/-+/g, "-").replace(/^-|-$/g, "").toLowerCase();
|
|
42
|
+
return `${label}-${slug}`;
|
|
43
|
+
}
|
|
44
|
+
return `${label}-work`;
|
|
45
|
+
}
|
|
46
|
+
function instanceLabel(name, instance) {
|
|
47
|
+
return instance != null && instance > 0 ? `${name}${instance}` : name;
|
|
48
|
+
}
|
|
49
|
+
function ensureWorktree(projectDir, employeeName, instance) {
|
|
50
|
+
const repoRoot = getGitRoot(projectDir);
|
|
51
|
+
if (!repoRoot) return null;
|
|
52
|
+
const wtPath = worktreePath(repoRoot, employeeName, instance);
|
|
53
|
+
const branch = worktreeBranch(employeeName, instance);
|
|
54
|
+
if (existsSync(path.join(wtPath, ".git"))) {
|
|
55
|
+
recordOrchestrationEventBestEffort({
|
|
56
|
+
eventType: "worktree.reused",
|
|
57
|
+
source: "worktree.ensureWorktree",
|
|
58
|
+
agentId: employeeName,
|
|
59
|
+
instanceId: instance != null ? String(instance) : null,
|
|
60
|
+
payload: { branch }
|
|
61
|
+
});
|
|
62
|
+
return wtPath;
|
|
63
|
+
}
|
|
64
|
+
const worktreesDir = path.join(repoRoot, ".worktrees");
|
|
65
|
+
mkdirSync(worktreesDir, { recursive: true });
|
|
66
|
+
ensureGitignoreEntry(repoRoot, "/.worktrees/");
|
|
67
|
+
try {
|
|
68
|
+
execSync("git worktree prune", {
|
|
69
|
+
cwd: repoRoot,
|
|
70
|
+
encoding: "utf-8",
|
|
71
|
+
timeout: GIT_TIMEOUT_MS,
|
|
72
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
73
|
+
});
|
|
74
|
+
} catch {
|
|
75
|
+
}
|
|
76
|
+
const branchExists = branchExistsLocally(repoRoot, branch);
|
|
77
|
+
try {
|
|
78
|
+
if (branchExists) {
|
|
79
|
+
execSync(`git worktree add "${wtPath}" "${branch}"`, {
|
|
80
|
+
cwd: repoRoot,
|
|
81
|
+
encoding: "utf-8",
|
|
82
|
+
timeout: GIT_TIMEOUT_MS,
|
|
83
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
84
|
+
});
|
|
85
|
+
} else {
|
|
86
|
+
execSync(`git worktree add "${wtPath}" -b "${branch}" HEAD`, {
|
|
87
|
+
cwd: repoRoot,
|
|
88
|
+
encoding: "utf-8",
|
|
89
|
+
timeout: GIT_TIMEOUT_MS,
|
|
90
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
recordOrchestrationEventBestEffort({
|
|
94
|
+
eventType: "worktree.created",
|
|
95
|
+
source: "worktree.ensureWorktree",
|
|
96
|
+
agentId: employeeName,
|
|
97
|
+
instanceId: instance != null ? String(instance) : null,
|
|
98
|
+
payload: { branch, reusedBranch: branchExists }
|
|
99
|
+
});
|
|
100
|
+
return wtPath;
|
|
101
|
+
} catch (err) {
|
|
102
|
+
recordOrchestrationEventBestEffort({
|
|
103
|
+
eventType: "worktree.failed",
|
|
104
|
+
source: "worktree.ensureWorktree",
|
|
105
|
+
severity: "warn",
|
|
106
|
+
agentId: employeeName,
|
|
107
|
+
instanceId: instance != null ? String(instance) : null,
|
|
108
|
+
errorCode: err instanceof Error ? err.name : "worktree_create_failed",
|
|
109
|
+
payload: { branch }
|
|
110
|
+
});
|
|
111
|
+
process.stderr.write(
|
|
112
|
+
`[worktree] Failed to create worktree for ${employeeName}: ${err instanceof Error ? err.message : String(err)}
|
|
113
|
+
`
|
|
114
|
+
);
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function isWorktreeDirty(wtPath) {
|
|
119
|
+
try {
|
|
120
|
+
const status = execSync("git status --porcelain", {
|
|
121
|
+
cwd: wtPath,
|
|
122
|
+
encoding: "utf-8",
|
|
123
|
+
timeout: GIT_TIMEOUT_MS,
|
|
124
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
125
|
+
}).trim();
|
|
126
|
+
return status.length > 0;
|
|
127
|
+
} catch {
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function cleanupWorktree(projectDir, employeeName, instance) {
|
|
132
|
+
const repoRoot = getMainRepoRoot(projectDir);
|
|
133
|
+
if (!repoRoot) return { cleaned: false, reason: "not a git repo" };
|
|
134
|
+
const wtPath = worktreePath(repoRoot, employeeName, instance);
|
|
135
|
+
const branch = worktreeBranch(employeeName, instance);
|
|
136
|
+
if (!existsSync(wtPath)) {
|
|
137
|
+
recordOrchestrationEventBestEffort({
|
|
138
|
+
eventType: "worktree.skipped",
|
|
139
|
+
source: "worktree.cleanupWorktree",
|
|
140
|
+
agentId: employeeName,
|
|
141
|
+
instanceId: instance != null ? String(instance) : null,
|
|
142
|
+
payload: { reason: "worktree does not exist", branch }
|
|
143
|
+
});
|
|
144
|
+
return { cleaned: false, reason: "worktree does not exist" };
|
|
145
|
+
}
|
|
146
|
+
if (isWorktreeDirty(wtPath)) {
|
|
147
|
+
recordOrchestrationEventBestEffort({
|
|
148
|
+
eventType: "worktree.skipped",
|
|
149
|
+
source: "worktree.cleanupWorktree",
|
|
150
|
+
agentId: employeeName,
|
|
151
|
+
instanceId: instance != null ? String(instance) : null,
|
|
152
|
+
payload: { reason: "worktree has uncommitted changes", branch }
|
|
153
|
+
});
|
|
154
|
+
return { cleaned: false, reason: "worktree has uncommitted changes" };
|
|
155
|
+
}
|
|
156
|
+
const mainBranch = detectMainBranch(repoRoot);
|
|
157
|
+
if (!mainBranch) {
|
|
158
|
+
recordOrchestrationEventBestEffort({
|
|
159
|
+
eventType: "worktree.skipped",
|
|
160
|
+
source: "worktree.cleanupWorktree",
|
|
161
|
+
agentId: employeeName,
|
|
162
|
+
instanceId: instance != null ? String(instance) : null,
|
|
163
|
+
payload: { reason: "could not determine main branch", branch }
|
|
164
|
+
});
|
|
165
|
+
return { cleaned: false, reason: "could not determine main branch" };
|
|
166
|
+
}
|
|
167
|
+
if (!isBranchMerged(repoRoot, branch, mainBranch)) {
|
|
168
|
+
recordOrchestrationEventBestEffort({
|
|
169
|
+
eventType: "worktree.skipped",
|
|
170
|
+
source: "worktree.cleanupWorktree",
|
|
171
|
+
agentId: employeeName,
|
|
172
|
+
instanceId: instance != null ? String(instance) : null,
|
|
173
|
+
payload: { reason: "branch not merged", branch, mainBranch }
|
|
174
|
+
});
|
|
175
|
+
return { cleaned: false, reason: `branch ${branch} not merged into ${mainBranch}` };
|
|
176
|
+
}
|
|
177
|
+
try {
|
|
178
|
+
execSync(`git worktree remove "${wtPath}"`, {
|
|
179
|
+
cwd: repoRoot,
|
|
180
|
+
encoding: "utf-8",
|
|
181
|
+
timeout: GIT_TIMEOUT_MS,
|
|
182
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
183
|
+
});
|
|
184
|
+
} catch (err) {
|
|
185
|
+
recordOrchestrationEventBestEffort({
|
|
186
|
+
eventType: "worktree.failed",
|
|
187
|
+
source: "worktree.cleanupWorktree",
|
|
188
|
+
severity: "warn",
|
|
189
|
+
agentId: employeeName,
|
|
190
|
+
instanceId: instance != null ? String(instance) : null,
|
|
191
|
+
errorCode: err instanceof Error ? err.name : "worktree_remove_failed",
|
|
192
|
+
payload: { branch, mainBranch }
|
|
193
|
+
});
|
|
194
|
+
return {
|
|
195
|
+
cleaned: false,
|
|
196
|
+
reason: `git worktree remove failed: ${err instanceof Error ? err.message : String(err)}`
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
try {
|
|
200
|
+
execSync(`git branch -d "${branch}"`, {
|
|
201
|
+
cwd: repoRoot,
|
|
202
|
+
encoding: "utf-8",
|
|
203
|
+
timeout: GIT_TIMEOUT_MS,
|
|
204
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
205
|
+
});
|
|
206
|
+
} catch {
|
|
207
|
+
}
|
|
208
|
+
recordOrchestrationEventBestEffort({
|
|
209
|
+
eventType: "worktree.pruned",
|
|
210
|
+
source: "worktree.cleanupWorktree",
|
|
211
|
+
agentId: employeeName,
|
|
212
|
+
instanceId: instance != null ? String(instance) : null,
|
|
213
|
+
payload: { branch, mainBranch }
|
|
214
|
+
});
|
|
215
|
+
return { cleaned: true, reason: `worktree and branch ${branch} removed (merged into ${mainBranch})` };
|
|
216
|
+
}
|
|
217
|
+
function branchExistsLocally(repoRoot, branch) {
|
|
218
|
+
try {
|
|
219
|
+
execSync(`git rev-parse --verify "refs/heads/${branch}"`, {
|
|
220
|
+
cwd: repoRoot,
|
|
221
|
+
encoding: "utf-8",
|
|
222
|
+
timeout: GIT_TIMEOUT_MS,
|
|
223
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
224
|
+
});
|
|
225
|
+
return true;
|
|
226
|
+
} catch {
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
function detectMainBranch(repoRoot) {
|
|
231
|
+
for (const candidate of ["main", "master"]) {
|
|
232
|
+
if (branchExistsLocally(repoRoot, candidate)) return candidate;
|
|
233
|
+
}
|
|
234
|
+
return null;
|
|
235
|
+
}
|
|
236
|
+
function isBranchMerged(repoRoot, branch, into) {
|
|
237
|
+
try {
|
|
238
|
+
const merged = execSync(`git branch --merged "${into}"`, {
|
|
239
|
+
cwd: repoRoot,
|
|
240
|
+
encoding: "utf-8",
|
|
241
|
+
timeout: GIT_TIMEOUT_MS,
|
|
242
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
243
|
+
});
|
|
244
|
+
return merged.split("\n").map((l) => l.replace(/^[*+]?\s+/, "").trim()).includes(branch);
|
|
245
|
+
} catch {
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
function realpath(p) {
|
|
250
|
+
try {
|
|
251
|
+
return realpathSync(p);
|
|
252
|
+
} catch {
|
|
253
|
+
return p;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
function ensureGitignoreEntry(repoRoot, entry) {
|
|
257
|
+
try {
|
|
258
|
+
const gitignorePath = path.join(repoRoot, ".gitignore");
|
|
259
|
+
if (existsSync(gitignorePath)) {
|
|
260
|
+
const content = readFileSync(gitignorePath, "utf-8");
|
|
261
|
+
if (content.includes(entry)) return;
|
|
262
|
+
appendFileSync(gitignorePath, `
|
|
263
|
+
# Agent worktrees (exe-os)
|
|
264
|
+
${entry}
|
|
265
|
+
`);
|
|
266
|
+
} else {
|
|
267
|
+
}
|
|
268
|
+
} catch {
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export {
|
|
273
|
+
getGitRoot,
|
|
274
|
+
getMainRepoRoot,
|
|
275
|
+
worktreePath,
|
|
276
|
+
worktreeBranch,
|
|
277
|
+
ensureWorktree,
|
|
278
|
+
isWorktreeDirty,
|
|
279
|
+
cleanupWorktree
|
|
280
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import {
|
|
2
|
+
enqueueMemory
|
|
3
|
+
} from "./chunk-MEWGYH6Z.js";
|
|
4
|
+
import {
|
|
5
|
+
isClientConnected,
|
|
6
|
+
sendDaemonRequest
|
|
7
|
+
} from "./chunk-W3EQ362K.js";
|
|
8
|
+
|
|
9
|
+
// src/lib/memory-queue-client.ts
|
|
10
|
+
async function writeMemoryViaDaemon(entry) {
|
|
11
|
+
if (process.env.EXE_IS_DAEMON === "1") {
|
|
12
|
+
enqueueMemory(entry);
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
if (!isClientConnected()) {
|
|
16
|
+
enqueueMemory(entry);
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
const response = await sendDaemonRequest({
|
|
21
|
+
type: "write-memory",
|
|
22
|
+
entry
|
|
23
|
+
});
|
|
24
|
+
if (response.ok) return true;
|
|
25
|
+
enqueueMemory(entry);
|
|
26
|
+
return false;
|
|
27
|
+
} catch {
|
|
28
|
+
enqueueMemory(entry);
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
async function batchWriteMemoryViaDaemon(entries) {
|
|
33
|
+
if (entries.length === 0) return 0;
|
|
34
|
+
if (process.env.EXE_IS_DAEMON === "1" || !isClientConnected()) {
|
|
35
|
+
for (const entry of entries) enqueueMemory(entry);
|
|
36
|
+
return 0;
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
const response = await sendDaemonRequest({
|
|
40
|
+
type: "batch-write-memory",
|
|
41
|
+
entries
|
|
42
|
+
});
|
|
43
|
+
if (response.ok) return response.count ?? entries.length;
|
|
44
|
+
for (const entry of entries) enqueueMemory(entry);
|
|
45
|
+
return 0;
|
|
46
|
+
} catch {
|
|
47
|
+
for (const entry of entries) enqueueMemory(entry);
|
|
48
|
+
return 0;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export {
|
|
53
|
+
writeMemoryViaDaemon,
|
|
54
|
+
batchWriteMemoryViaDaemon
|
|
55
|
+
};
|