@defend-tech/opencode-optima 0.1.63 → 0.1.64
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/dist/index.js +3 -68
- package/dist/sanitize_cli.js +3 -68
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9342,11 +9342,6 @@ async function syncOpenChamberWorktreeVisibility({ openchamberBaseUrl, opencodeB
|
|
|
9342
9342
|
}
|
|
9343
9343
|
return visibility;
|
|
9344
9344
|
}
|
|
9345
|
-
function assertOpenChamberClickUpWorktreePath({ baseWorktree, worktreePath } = {}) {
|
|
9346
|
-
if (!isClickUpDerivedWorktreeSibling(worktreePath, baseWorktree)) {
|
|
9347
|
-
throw new Error(`OpenChamber worktree path is outside the configured ClickUp sibling scope: ${worktreePath}`);
|
|
9348
|
-
}
|
|
9349
|
-
}
|
|
9350
9345
|
async function createOpenChamberClickUpWorktree({ openchamberBaseUrl, baseUrl, baseWorktree, branch, worktreePath, startPoint, branchExists = false, fetchImpl = globalThis.fetch } = {}) {
|
|
9351
9346
|
const effectiveOpenChamberBaseUrl = openchamberBaseUrl || baseUrl;
|
|
9352
9347
|
const worktreeName = clickUpOpenChamberWorktreeName(branch);
|
|
@@ -9369,7 +9364,6 @@ async function createOpenChamberClickUpWorktree({ openchamberBaseUrl, baseUrl, b
|
|
|
9369
9364
|
return { created, worktree: path5.resolve(createdDirectory), branch: createdBranch, verified };
|
|
9370
9365
|
}
|
|
9371
9366
|
async function registerOpenChamberClickUpWorktree({ openchamberBaseUrl, opencodeBaseUrl, baseUrl, baseWorktree, branch, worktreePath, fetchImpl = globalThis.fetch, source = "reuse" } = {}) {
|
|
9372
|
-
assertOpenChamberClickUpWorktreePath({ baseWorktree, worktreePath });
|
|
9373
9367
|
const visibility = await syncOpenChamberWorktreeVisibility({ openchamberBaseUrl: openchamberBaseUrl || baseUrl, opencodeBaseUrl: opencodeBaseUrl || baseUrl, baseWorktree, worktreePath, branch, fetchImpl });
|
|
9374
9368
|
return { branch, worktree: path5.resolve(worktreePath), reused: true, provider: "openchamber", openChamber: { source, visibility } };
|
|
9375
9369
|
}
|
|
@@ -9423,30 +9417,6 @@ async function ensureClickUpTaskWorktreeForWebhook({ opencodeBaseUrl = "", openc
|
|
|
9423
9417
|
} catch (error) {
|
|
9424
9418
|
const message = `OpenChamber worktree provisioning failed for ${options.taskId || "unknown task"}; raw git fallback is disabled to avoid invisible worktrees. ${error.message}`;
|
|
9425
9419
|
appendClickUpWebhookLocalLog(webhookWorktree, { type: "openchamber_worktree_failed", taskId: options.taskId || null, message });
|
|
9426
|
-
if (typeof clickupClient?.postTaskComment === "function") {
|
|
9427
|
-
const taskId = options.taskId || "unknown task";
|
|
9428
|
-
const ledgerPath = clickUpCommentLedgerPath(webhookWorktree);
|
|
9429
|
-
const comment = `${message}
|
|
9430
|
-
|
|
9431
|
-
Optima did not run raw git worktree fallback. Please verify clickup.openchamber.base_url and OpenCode/OpenChamber endpoint configuration.`;
|
|
9432
|
-
let dedupe = { post: true, key: clickUpWorktreeFailureCommentKey({ taskId, message }) };
|
|
9433
|
-
try {
|
|
9434
|
-
dedupe = shouldPostClickUpWorktreeFailureComment({ ledgerPath, taskId, message });
|
|
9435
|
-
} catch (ledgerError) {
|
|
9436
|
-
appendClickUpWebhookLocalLog(webhookWorktree, { type: "openchamber_worktree_comment_dedupe_failed", taskId, message: ledgerError.message });
|
|
9437
|
-
}
|
|
9438
|
-
if (dedupe.post) {
|
|
9439
|
-
try {
|
|
9440
|
-
await clickupClient.postTaskComment({ taskId: options.taskId, comment });
|
|
9441
|
-
recordClickUpWorktreeFailureComment({ ledgerPath, taskId, message, posted: true });
|
|
9442
|
-
} catch (commentError) {
|
|
9443
|
-
appendClickUpWebhookLocalLog(webhookWorktree, { type: "openchamber_worktree_blocker_comment_failed", taskId: options.taskId || null, message: commentError.message });
|
|
9444
|
-
}
|
|
9445
|
-
} else {
|
|
9446
|
-
appendClickUpWebhookLocalLog(webhookWorktree, { type: "openchamber_worktree_blocker_comment_deduped", taskId, key: dedupe.key, reason: dedupe.reason });
|
|
9447
|
-
recordClickUpWorktreeFailureComment({ ledgerPath, taskId, message, posted: false, skippedReason: dedupe.reason });
|
|
9448
|
-
}
|
|
9449
|
-
}
|
|
9450
9420
|
throw new Error(message);
|
|
9451
9421
|
}
|
|
9452
9422
|
}
|
|
@@ -10392,35 +10362,6 @@ function recordClickUpCommentVersionProcessed({ ledgerPath, key, taskId, eventTy
|
|
|
10392
10362
|
recordedAt: at.toISOString()
|
|
10393
10363
|
});
|
|
10394
10364
|
}
|
|
10395
|
-
function clickUpWorktreeFailureCommentKey({ taskId, message } = {}) {
|
|
10396
|
-
const hash = crypto.createHash("sha256").update(String(message || "")).digest("hex").slice(0, 16);
|
|
10397
|
-
return [String(taskId || "unknown").trim() || "unknown", "worktree_failure", hash].join(":");
|
|
10398
|
-
}
|
|
10399
|
-
function shouldPostClickUpWorktreeFailureComment({ ledgerPath, taskId, message, now = /* @__PURE__ */ new Date(), windowMs = CLICKUP_WORKTREE_FAILURE_COMMENT_DEDUPE_MS } = {}) {
|
|
10400
|
-
const key = clickUpWorktreeFailureCommentKey({ taskId, message });
|
|
10401
|
-
const nowMs = now instanceof Date ? now.getTime() : new Date(now).getTime();
|
|
10402
|
-
for (const entry of readClickUpCommentLedgerEntries(ledgerPath).reverse()) {
|
|
10403
|
-
if (entry?.key !== key) continue;
|
|
10404
|
-
const postedAtMs = new Date(entry.postedAt || entry.recordedAt || entry.at || 0).getTime();
|
|
10405
|
-
if (Number.isFinite(postedAtMs) && Number.isFinite(nowMs) && nowMs - postedAtMs <= windowMs) {
|
|
10406
|
-
return { post: false, key, reason: "recent_duplicate" };
|
|
10407
|
-
}
|
|
10408
|
-
if (entry?.message === message) return { post: false, key, reason: "latest_equivalent" };
|
|
10409
|
-
}
|
|
10410
|
-
return { post: true, key };
|
|
10411
|
-
}
|
|
10412
|
-
function recordClickUpWorktreeFailureComment({ ledgerPath, taskId, message, posted = true, skippedReason = null, at = /* @__PURE__ */ new Date() } = {}) {
|
|
10413
|
-
appendClickUpCommentLedgerEntry(ledgerPath, {
|
|
10414
|
-
key: clickUpWorktreeFailureCommentKey({ taskId, message }),
|
|
10415
|
-
taskId,
|
|
10416
|
-
eventType: "worktree_failure",
|
|
10417
|
-
action: posted ? "worktree_failure_comment_posted" : "worktree_failure_comment_skipped",
|
|
10418
|
-
message,
|
|
10419
|
-
posted,
|
|
10420
|
-
skippedReason,
|
|
10421
|
-
postedAt: at.toISOString()
|
|
10422
|
-
});
|
|
10423
|
-
}
|
|
10424
10365
|
function clickUpTaskIdFromPayload(payload = {}) {
|
|
10425
10366
|
return String(payload.task_id || payload.taskId || payload.task?.id || payload.task?.task_id || "").trim();
|
|
10426
10367
|
}
|
|
@@ -10983,15 +10924,9 @@ async function verifyOpenCodeSessionEventDelivery(client, { sessionId, directory
|
|
|
10983
10924
|
return { ok: false, reason: lastError };
|
|
10984
10925
|
}
|
|
10985
10926
|
async function postClickUpLaunchFailureComment({ clickupClient, worktree, taskId, reason, source } = {}) {
|
|
10986
|
-
|
|
10987
|
-
|
|
10988
|
-
|
|
10989
|
-
appendClickUpWebhookLocalLog(worktree, { type: "launch_failure_comment_posted", taskId, reason, source });
|
|
10990
|
-
return { ok: true };
|
|
10991
|
-
} catch (error) {
|
|
10992
|
-
appendClickUpWebhookLocalLog(worktree, { type: "launch_failure_comment_failed", taskId, reason, source, message: error.message });
|
|
10993
|
-
return { ok: false, error: error.message };
|
|
10994
|
-
}
|
|
10927
|
+
void clickupClient;
|
|
10928
|
+
appendClickUpWebhookLocalLog(worktree, { type: "launch_failure_comment_skipped", taskId, reason, source, policy: "local_log_only" });
|
|
10929
|
+
return { ok: false, skipped: true, reason: "local_log_only" };
|
|
10995
10930
|
}
|
|
10996
10931
|
async function applyClickUpBlockerTag({ clickupClient, worktree, taskId, reason, source, tagName = CLICKUP_BLOCKER_TAG_NAME } = {}) {
|
|
10997
10932
|
if (typeof clickupClient?.addTaskTag !== "function") {
|
package/dist/sanitize_cli.js
CHANGED
|
@@ -9349,11 +9349,6 @@ async function syncOpenChamberWorktreeVisibility({ openchamberBaseUrl, opencodeB
|
|
|
9349
9349
|
}
|
|
9350
9350
|
return visibility;
|
|
9351
9351
|
}
|
|
9352
|
-
function assertOpenChamberClickUpWorktreePath({ baseWorktree, worktreePath } = {}) {
|
|
9353
|
-
if (!isClickUpDerivedWorktreeSibling(worktreePath, baseWorktree)) {
|
|
9354
|
-
throw new Error(`OpenChamber worktree path is outside the configured ClickUp sibling scope: ${worktreePath}`);
|
|
9355
|
-
}
|
|
9356
|
-
}
|
|
9357
9352
|
async function createOpenChamberClickUpWorktree({ openchamberBaseUrl, baseUrl, baseWorktree, branch, worktreePath, startPoint, branchExists = false, fetchImpl = globalThis.fetch } = {}) {
|
|
9358
9353
|
const effectiveOpenChamberBaseUrl = openchamberBaseUrl || baseUrl;
|
|
9359
9354
|
const worktreeName = clickUpOpenChamberWorktreeName(branch);
|
|
@@ -9376,7 +9371,6 @@ async function createOpenChamberClickUpWorktree({ openchamberBaseUrl, baseUrl, b
|
|
|
9376
9371
|
return { created, worktree: path5.resolve(createdDirectory), branch: createdBranch, verified };
|
|
9377
9372
|
}
|
|
9378
9373
|
async function registerOpenChamberClickUpWorktree({ openchamberBaseUrl, opencodeBaseUrl, baseUrl, baseWorktree, branch, worktreePath, fetchImpl = globalThis.fetch, source = "reuse" } = {}) {
|
|
9379
|
-
assertOpenChamberClickUpWorktreePath({ baseWorktree, worktreePath });
|
|
9380
9374
|
const visibility = await syncOpenChamberWorktreeVisibility({ openchamberBaseUrl: openchamberBaseUrl || baseUrl, opencodeBaseUrl: opencodeBaseUrl || baseUrl, baseWorktree, worktreePath, branch, fetchImpl });
|
|
9381
9375
|
return { branch, worktree: path5.resolve(worktreePath), reused: true, provider: "openchamber", openChamber: { source, visibility } };
|
|
9382
9376
|
}
|
|
@@ -9430,30 +9424,6 @@ async function ensureClickUpTaskWorktreeForWebhook({ opencodeBaseUrl = "", openc
|
|
|
9430
9424
|
} catch (error) {
|
|
9431
9425
|
const message = `OpenChamber worktree provisioning failed for ${options.taskId || "unknown task"}; raw git fallback is disabled to avoid invisible worktrees. ${error.message}`;
|
|
9432
9426
|
appendClickUpWebhookLocalLog(webhookWorktree, { type: "openchamber_worktree_failed", taskId: options.taskId || null, message });
|
|
9433
|
-
if (typeof clickupClient?.postTaskComment === "function") {
|
|
9434
|
-
const taskId = options.taskId || "unknown task";
|
|
9435
|
-
const ledgerPath = clickUpCommentLedgerPath(webhookWorktree);
|
|
9436
|
-
const comment = `${message}
|
|
9437
|
-
|
|
9438
|
-
Optima did not run raw git worktree fallback. Please verify clickup.openchamber.base_url and OpenCode/OpenChamber endpoint configuration.`;
|
|
9439
|
-
let dedupe = { post: true, key: clickUpWorktreeFailureCommentKey({ taskId, message }) };
|
|
9440
|
-
try {
|
|
9441
|
-
dedupe = shouldPostClickUpWorktreeFailureComment({ ledgerPath, taskId, message });
|
|
9442
|
-
} catch (ledgerError) {
|
|
9443
|
-
appendClickUpWebhookLocalLog(webhookWorktree, { type: "openchamber_worktree_comment_dedupe_failed", taskId, message: ledgerError.message });
|
|
9444
|
-
}
|
|
9445
|
-
if (dedupe.post) {
|
|
9446
|
-
try {
|
|
9447
|
-
await clickupClient.postTaskComment({ taskId: options.taskId, comment });
|
|
9448
|
-
recordClickUpWorktreeFailureComment({ ledgerPath, taskId, message, posted: true });
|
|
9449
|
-
} catch (commentError) {
|
|
9450
|
-
appendClickUpWebhookLocalLog(webhookWorktree, { type: "openchamber_worktree_blocker_comment_failed", taskId: options.taskId || null, message: commentError.message });
|
|
9451
|
-
}
|
|
9452
|
-
} else {
|
|
9453
|
-
appendClickUpWebhookLocalLog(webhookWorktree, { type: "openchamber_worktree_blocker_comment_deduped", taskId, key: dedupe.key, reason: dedupe.reason });
|
|
9454
|
-
recordClickUpWorktreeFailureComment({ ledgerPath, taskId, message, posted: false, skippedReason: dedupe.reason });
|
|
9455
|
-
}
|
|
9456
|
-
}
|
|
9457
9427
|
throw new Error(message);
|
|
9458
9428
|
}
|
|
9459
9429
|
}
|
|
@@ -10399,35 +10369,6 @@ function recordClickUpCommentVersionProcessed({ ledgerPath, key, taskId, eventTy
|
|
|
10399
10369
|
recordedAt: at.toISOString()
|
|
10400
10370
|
});
|
|
10401
10371
|
}
|
|
10402
|
-
function clickUpWorktreeFailureCommentKey({ taskId, message } = {}) {
|
|
10403
|
-
const hash = crypto.createHash("sha256").update(String(message || "")).digest("hex").slice(0, 16);
|
|
10404
|
-
return [String(taskId || "unknown").trim() || "unknown", "worktree_failure", hash].join(":");
|
|
10405
|
-
}
|
|
10406
|
-
function shouldPostClickUpWorktreeFailureComment({ ledgerPath, taskId, message, now = /* @__PURE__ */ new Date(), windowMs = CLICKUP_WORKTREE_FAILURE_COMMENT_DEDUPE_MS } = {}) {
|
|
10407
|
-
const key = clickUpWorktreeFailureCommentKey({ taskId, message });
|
|
10408
|
-
const nowMs = now instanceof Date ? now.getTime() : new Date(now).getTime();
|
|
10409
|
-
for (const entry of readClickUpCommentLedgerEntries(ledgerPath).reverse()) {
|
|
10410
|
-
if (entry?.key !== key) continue;
|
|
10411
|
-
const postedAtMs = new Date(entry.postedAt || entry.recordedAt || entry.at || 0).getTime();
|
|
10412
|
-
if (Number.isFinite(postedAtMs) && Number.isFinite(nowMs) && nowMs - postedAtMs <= windowMs) {
|
|
10413
|
-
return { post: false, key, reason: "recent_duplicate" };
|
|
10414
|
-
}
|
|
10415
|
-
if (entry?.message === message) return { post: false, key, reason: "latest_equivalent" };
|
|
10416
|
-
}
|
|
10417
|
-
return { post: true, key };
|
|
10418
|
-
}
|
|
10419
|
-
function recordClickUpWorktreeFailureComment({ ledgerPath, taskId, message, posted = true, skippedReason = null, at = /* @__PURE__ */ new Date() } = {}) {
|
|
10420
|
-
appendClickUpCommentLedgerEntry(ledgerPath, {
|
|
10421
|
-
key: clickUpWorktreeFailureCommentKey({ taskId, message }),
|
|
10422
|
-
taskId,
|
|
10423
|
-
eventType: "worktree_failure",
|
|
10424
|
-
action: posted ? "worktree_failure_comment_posted" : "worktree_failure_comment_skipped",
|
|
10425
|
-
message,
|
|
10426
|
-
posted,
|
|
10427
|
-
skippedReason,
|
|
10428
|
-
postedAt: at.toISOString()
|
|
10429
|
-
});
|
|
10430
|
-
}
|
|
10431
10372
|
function clickUpTaskIdFromPayload(payload = {}) {
|
|
10432
10373
|
return String(payload.task_id || payload.taskId || payload.task?.id || payload.task?.task_id || "").trim();
|
|
10433
10374
|
}
|
|
@@ -10990,15 +10931,9 @@ async function verifyOpenCodeSessionEventDelivery(client, { sessionId, directory
|
|
|
10990
10931
|
return { ok: false, reason: lastError };
|
|
10991
10932
|
}
|
|
10992
10933
|
async function postClickUpLaunchFailureComment({ clickupClient, worktree, taskId, reason, source } = {}) {
|
|
10993
|
-
|
|
10994
|
-
|
|
10995
|
-
|
|
10996
|
-
appendClickUpWebhookLocalLog(worktree, { type: "launch_failure_comment_posted", taskId, reason, source });
|
|
10997
|
-
return { ok: true };
|
|
10998
|
-
} catch (error) {
|
|
10999
|
-
appendClickUpWebhookLocalLog(worktree, { type: "launch_failure_comment_failed", taskId, reason, source, message: error.message });
|
|
11000
|
-
return { ok: false, error: error.message };
|
|
11001
|
-
}
|
|
10934
|
+
void clickupClient;
|
|
10935
|
+
appendClickUpWebhookLocalLog(worktree, { type: "launch_failure_comment_skipped", taskId, reason, source, policy: "local_log_only" });
|
|
10936
|
+
return { ok: false, skipped: true, reason: "local_log_only" };
|
|
11002
10937
|
}
|
|
11003
10938
|
async function applyClickUpBlockerTag({ clickupClient, worktree, taskId, reason, source, tagName = CLICKUP_BLOCKER_TAG_NAME } = {}) {
|
|
11004
10939
|
if (typeof clickupClient?.addTaskTag !== "function") {
|