@anhlp/alp-core 0.0.0-beta.2 → 0.0.1-beta.10
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/backup.js +106 -4
- package/dist/bridges.d.ts +26 -0
- package/dist/bridges.js +96 -0
- package/dist/gate-ledger.d.ts +30 -0
- package/dist/gate-ledger.js +99 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/library-edit.d.ts +57 -5
- package/dist/library-edit.js +216 -11
- package/dist/library.d.ts +14 -1
- package/dist/library.js +73 -5
- package/dist/migrations.js +1 -1
- package/dist/models.d.ts +74 -0
- package/dist/models.js +67 -1
- package/dist/packaged.d.ts +122 -0
- package/dist/packaged.js +125 -0
- package/dist/packs.d.ts +57 -0
- package/dist/packs.js +247 -0
- package/dist/permissions.d.ts +3 -2
- package/dist/permissions.js +6 -3
- package/dist/profiles.js +6 -6
- package/dist/providers.d.ts +4 -5
- package/dist/providers.js +26 -5
- package/dist/skill-validate.d.ts +85 -0
- package/dist/skill-validate.js +298 -0
- package/dist/task-rows.d.ts +5 -0
- package/dist/task-rows.js +1 -1
- package/dist/tasks.d.ts +23 -4
- package/dist/tasks.js +103 -9
- package/dist/types.d.ts +3 -0
- package/dist/upgrade.d.ts +10 -0
- package/dist/upgrade.js +112 -6
- package/dist/user-settings.d.ts +2 -0
- package/dist/user-settings.js +40 -1
- package/dist/user-worktree.d.ts +29 -0
- package/dist/user-worktree.js +242 -0
- package/dist/validation.d.ts +1 -0
- package/dist/validation.js +35 -13
- package/package.json +34 -2
- package/src/backup.js +106 -5
- package/src/bridges.js +113 -0
- package/src/gate-ledger.js +125 -0
- package/src/index.js +1 -0
- package/src/library-edit.js +227 -12
- package/src/library.js +96 -6
- package/src/migrations.js +1 -1
- package/src/models.js +87 -1
- package/src/packaged.js +207 -0
- package/src/packs.js +246 -0
- package/src/permissions.d.ts +3 -2
- package/src/permissions.js +13 -3
- package/src/profiles.js +7 -7
- package/src/providers.js +23 -7
- package/src/resolver.js +1 -1
- package/src/skill-validate.js +287 -0
- package/src/task-rows.js +1 -1
- package/src/tasks.d.ts +23 -4
- package/src/tasks.js +137 -10
- package/src/types.d.ts +3 -0
- package/src/upgrade.js +54 -6
- package/src/user-settings.d.ts +2 -0
- package/src/user-settings.js +51 -1
- package/src/user-worktree.js +259 -0
- package/src/validation.d.ts +1 -0
- package/src/validation.js +43 -14
- package/templates/ALP.md +52 -52
- package/templates/agents/lead/AGENT.md +77 -74
- package/templates/agents/main/AGENT.md +153 -141
- package/templates/agents/oracle/AGENT.md +38 -37
- package/templates/agents/peer/AGENT.md +56 -52
- package/templates/agents/reviewer/AGENT.md +63 -65
- package/templates/agents/supervisor/AGENT.md +63 -63
- package/templates/packs/architecture/agents/architect/AGENT.md +41 -0
- package/templates/packs/architecture/agents/architect/agent.json +5 -0
- package/templates/packs/architecture/agents/docs-maintainer/AGENT.md +33 -0
- package/templates/packs/architecture/agents/docs-maintainer/agent.json +4 -0
- package/templates/packs/architecture/pack.json +7 -0
- package/templates/packs/architecture/teams/blueprint/HOUSE_RULES.md +12 -0
- package/templates/packs/architecture/teams/blueprint/team.json +19 -0
- package/templates/packs/backend/pack.json +6 -0
- package/templates/packs/backend/skills/backend-development/SKILL.md +102 -0
- package/templates/packs/backend/skills/backend-development/references/api-design.md +96 -0
- package/templates/packs/backend/skills/backend-development/references/authentication.md +78 -0
- package/templates/packs/backend/skills/backend-development/references/error-handling.md +86 -0
- package/templates/packs/backend/skills/backend-development/references/testing.md +81 -0
- package/templates/packs/backend/skills/databases/SKILL.md +103 -0
- package/templates/packs/backend/skills/databases/references/query-performance.md +87 -0
- package/templates/packs/backend/skills/databases/references/schema-and-migrations.md +87 -0
- package/templates/packs/design/pack.json +6 -0
- package/templates/packs/design/skills/ui-design/SKILL.md +86 -0
- package/templates/packs/design/skills/ui-design/references/design-tokens.md +67 -0
- package/templates/packs/design/skills/ui-design/references/interaction-states.md +73 -0
- package/templates/packs/design/skills/ui-design/references/layout-and-typography.md +71 -0
- package/templates/packs/design/skills/ui-design/references/ui-review.md +83 -0
- package/templates/packs/frontend/pack.json +6 -0
- package/templates/packs/frontend/skills/frontend-development/SKILL.md +105 -0
- package/templates/packs/frontend/skills/frontend-development/references/accessibility.md +86 -0
- package/templates/packs/frontend/skills/frontend-development/references/components-and-state.md +79 -0
- package/templates/packs/frontend/skills/frontend-development/references/data-fetching.md +86 -0
- package/templates/packs/frontend/skills/frontend-development/references/frameworks.md +77 -0
- package/templates/packs/frontend/skills/frontend-development/references/performance.md +78 -0
- package/templates/packs/integration/pack.json +6 -0
- package/templates/packs/integration/skills/mcp-integration/SKILL.md +100 -0
- package/templates/packs/integration/skills/mcp-integration/references/server-implementation.md +95 -0
- package/templates/packs/integration/skills/mcp-integration/references/testing.md +78 -0
- package/templates/packs/integration/skills/mcp-integration/references/tool-design.md +97 -0
- package/templates/packs/operations/pack.json +6 -0
- package/templates/packs/operations/skills/devops/SKILL.md +85 -0
- package/templates/packs/operations/skills/devops/references/ci-cd.md +84 -0
- package/templates/packs/operations/skills/devops/references/containers.md +85 -0
- package/templates/packs/operations/skills/devops/references/deployment-and-rollback.md +85 -0
- package/templates/packs/operations/skills/devops/references/observability.md +86 -0
- package/templates/packs/quality/pack.json +6 -0
- package/templates/packs/quality/skills/web-testing/SKILL.md +102 -0
- package/templates/packs/quality/skills/web-testing/references/e2e.md +85 -0
- package/templates/packs/quality/skills/web-testing/references/performance-testing.md +85 -0
- package/templates/packs/quality/skills/web-testing/references/security-testing.md +78 -0
- package/templates/packs/quality/skills/web-testing/references/unit-and-component.md +78 -0
- package/templates/role-skills.json +4 -4
- package/templates/skills/architecture-docs/SKILL.md +81 -0
- package/templates/skills/architecture-docs/references/adr.md +62 -0
- package/templates/skills/architecture-docs/references/diagrams.md +60 -0
- package/templates/skills/architecture-docs/references/evidence-rules.md +49 -0
- package/templates/skills/bug-loop/SKILL.md +41 -40
- package/templates/skills/bug-loop/references/test-proof.md +21 -19
- package/templates/skills/compact/SKILL.md +34 -0
- package/templates/skills/curate/SKILL.md +36 -0
- package/templates/skills/feature-architecture/SKILL.md +90 -0
- package/templates/skills/feature-architecture/references/architecture-contract.md +95 -0
- package/templates/skills/feature-architecture/references/feature-design.md +69 -0
- package/templates/skills/feature-architecture/scripts/check-boundaries.mjs +270 -0
- package/templates/skills/goal-griller/SKILL.md +27 -27
- package/templates/skills/prompt-leverage/SKILL.md +29 -27
- package/templates/skills/prompt-leverage/references/brief-template.md +9 -9
- package/templates/skills/release-readiness/SKILL.md +83 -0
- package/templates/skills/release-readiness/references/checklist.md +40 -0
- package/templates/skills/release-readiness/references/verdict-template.md +53 -0
- package/templates/skills/safe-refactor/SKILL.md +84 -0
- package/templates/skills/safe-refactor/references/characterization-tests.md +57 -0
- package/templates/skills/safe-refactor/references/compatibility-checklist.md +56 -0
- package/templates/skills/security-review/SKILL.md +87 -0
- package/templates/skills/security-review/references/checklist.md +74 -0
- package/templates/skills/security-review/references/severity.md +61 -0
- package/templates/skills/sequence-execution-plan/SKILL.md +41 -38
- package/templates/skills/sequence-execution-plan/references/plan-template.md +5 -5
- package/templates/skills/skill-authoring/SKILL.md +84 -0
- package/templates/skills/skill-authoring/references/evaluation.md +45 -0
- package/templates/skills/skill-authoring/references/skill-anatomy.md +74 -0
- package/templates/skills/skill-authoring/references/trigger-design.md +52 -0
- package/templates/skills/smart-commits/SKILL.md +37 -36
- package/templates/skills/test-strategy/SKILL.md +83 -0
- package/templates/skills/test-strategy/references/contract-tests.md +46 -0
- package/templates/skills/test-strategy/references/risk-matrix.md +53 -0
- package/templates/skills/xia/SKILL.md +40 -38
- package/templates/teams/cafe/HOUSE_RULES.md +1 -1
- package/templates/teams/cafe/team.json +1 -1
- package/templates/teams/pho/HOUSE_RULES.md +1 -1
- package/templates/teams/pho/team.json +1 -1
package/dist/tasks.js
CHANGED
|
@@ -6,6 +6,9 @@ import path from "node:path";
|
|
|
6
6
|
import { AlpError } from "./errors.js";
|
|
7
7
|
import { assertNoSymlinks } from "./safe-path.js";
|
|
8
8
|
import { describeVerification } from "./verify.js";
|
|
9
|
+
import { applyLedger, ledgerAdopt, ledgerPrune, ledgerResolve, readLedger } from "./gate-ledger.js";
|
|
10
|
+
var AGENT_MARKER = "ALP_AGENT_SESSION";
|
|
11
|
+
var isAgentProcess = (env = process.env) => typeof env[AGENT_MARKER] === "string" && env[AGENT_MARKER] !== "";
|
|
9
12
|
var TASKS_DIR = ".alp/tasks";
|
|
10
13
|
var TASK_TYPES = ["task", "bug", "feature", "chore", "epic"];
|
|
11
14
|
var TASK_STATUSES = ["open", "in_progress", "review", "closed"];
|
|
@@ -66,6 +69,7 @@ async function loadTasks(projectRoot) {
|
|
|
66
69
|
errors.push({ file: path.relative(path.resolve(projectRoot), file), error: error.message });
|
|
67
70
|
}
|
|
68
71
|
}
|
|
72
|
+
applyLedger(tasks, await readLedger(projectRoot));
|
|
69
73
|
return { tasks, errors };
|
|
70
74
|
}
|
|
71
75
|
function normalize(task) {
|
|
@@ -265,6 +269,8 @@ async function save(projectRoot, task) {
|
|
|
265
269
|
const temporary = `${file}.${randomUUID().slice(0, 8)}.tmp`;
|
|
266
270
|
await writeFile(temporary, JSON.stringify(task, null, 2) + "\n");
|
|
267
271
|
await moveFile(temporary, file);
|
|
272
|
+
await ledgerAdopt(projectRoot, task).catch(() => {
|
|
273
|
+
});
|
|
268
274
|
return task;
|
|
269
275
|
}
|
|
270
276
|
function newId(tasks, title, parent) {
|
|
@@ -419,8 +425,8 @@ function startTask(projectRoot, id, assignee, by, options) {
|
|
|
419
425
|
addLog(task, by, rework ? "reworked" : "started", { to: assignee.agent, ...assignee.assignment ? { assignment: assignee.assignment } : {} });
|
|
420
426
|
}, options);
|
|
421
427
|
}
|
|
422
|
-
function closeTask(projectRoot, id, { reason = "done", summary, unverified } = {}, by, options) {
|
|
423
|
-
return mutate(projectRoot, id, (task, tasks) => {
|
|
428
|
+
function closeTask(projectRoot, id, { reason = "done", summary, unverified, agent = false, channel } = {}, by, options) {
|
|
429
|
+
return mutate(projectRoot, id, async (task, tasks) => {
|
|
424
430
|
if (!CLOSE_REASONS.includes(reason)) fail("INVALID_TASK", `reason must be one of ${CLOSE_REASONS.join(", ")}`);
|
|
425
431
|
const closing = checkText(summary, "summary", NOTE_CHARS);
|
|
426
432
|
let excuse = checkText(unverified, "unverified", NOTE_CHARS);
|
|
@@ -431,6 +437,15 @@ function closeTask(projectRoot, id, { reason = "done", summary, unverified } = {
|
|
|
431
437
|
if (by !== "user") fail("TASK_UNVERIFIED", `${id}'s last ${describeVerification(task.verified)}; fix it and verify again, or close it with unverified saying why it is done anyway`);
|
|
432
438
|
excuse = `the user closed it after ${describeVerification(task.verified)}`;
|
|
433
439
|
}
|
|
440
|
+
const held = (task.gates ?? []).filter((gate) => gate.kind === "human" && !gate.resolved);
|
|
441
|
+
if (held.length || task.step?.human) {
|
|
442
|
+
if (agent || by !== "user") fail("GATE_USER_ONLY", `Only the user closes ${id}: ${held.length ? `it waits on ${held.map(describeGate).join("; ")}` : "it is a step for the user"}. Ask the user to decide it`);
|
|
443
|
+
checkChannel(channel);
|
|
444
|
+
for (const gate of held) await ledgerResolve(projectRoot, task.id, gate, { by, channel });
|
|
445
|
+
const note = `overridden: the user closed ${id} (${reason})`;
|
|
446
|
+
task.gates = task.gates.map((gate) => held.includes(gate) ? { ...gate, resolved: { at: now(), by, note, overridden: true, ...channel ? { channel } : {} } } : gate);
|
|
447
|
+
for (const gate of held) addLog(task, by, "gate overridden", { gate: describeGate(gate), ...channel ? { channel } : {} });
|
|
448
|
+
}
|
|
434
449
|
task.status = "closed";
|
|
435
450
|
task.closed = { at: now(), by, reason, ...closing ? { summary: closing } : {}, ...excuse ? { unverified: excuse } : {} };
|
|
436
451
|
task.assignee = null;
|
|
@@ -604,7 +619,7 @@ function taskDigest(tasks, errors = []) {
|
|
|
604
619
|
}
|
|
605
620
|
var DURATION = /^\+(\d+)([mhd])$/;
|
|
606
621
|
var GH_REF = /^(?:([\w.-]+\/[\w.-]+)#)?(\d+)$/;
|
|
607
|
-
function addGate(projectRoot, id, { kind, note, until, ref } = {}, by) {
|
|
622
|
+
function addGate(projectRoot, id, { kind, note, until, ref, options } = {}, by) {
|
|
608
623
|
return mutate(projectRoot, id, (task) => {
|
|
609
624
|
if (!GATE_KINDS.includes(kind)) fail("INVALID_TASK", `kind must be one of ${GATE_KINDS.join(", ")}`);
|
|
610
625
|
if (task.status === "closed") fail("INVALID_TASK", `${id} is closed`);
|
|
@@ -612,6 +627,11 @@ function addGate(projectRoot, id, { kind, note, until, ref } = {}, by) {
|
|
|
612
627
|
const gate = { id: `g${Math.max(0, ...(task.gates ?? []).map((entry) => Number(entry.id.slice(1)) || 0)) + 1}`, kind };
|
|
613
628
|
if (kind === "human") gate.note = checkText(note, "note", NOTE_CHARS, { required: true });
|
|
614
629
|
else if (note !== void 0) gate.note = checkText(note, "note", NOTE_CHARS);
|
|
630
|
+
if (options !== void 0) {
|
|
631
|
+
if (kind !== "human") fail("INVALID_TASK", "Only a human gate has options");
|
|
632
|
+
const choices = gateOptions(options);
|
|
633
|
+
if (choices.length) gate.options = choices;
|
|
634
|
+
}
|
|
615
635
|
if (kind === "timer") {
|
|
616
636
|
const relative = typeof until === "string" ? DURATION.exec(until.trim()) : null;
|
|
617
637
|
const time = relative ? Date.now() + Number(relative[1]) * { m: 6e4, h: 36e5, d: 864e5 }[relative[2]] : Date.parse(until);
|
|
@@ -630,20 +650,49 @@ function addGate(projectRoot, id, { kind, note, until, ref } = {}, by) {
|
|
|
630
650
|
addLog(task, by, "gated", { gate: describeGate(gate) });
|
|
631
651
|
});
|
|
632
652
|
}
|
|
633
|
-
|
|
634
|
-
|
|
653
|
+
var GATE_OPTIONS = 10;
|
|
654
|
+
var GATE_OPTION_CHARS = 200;
|
|
655
|
+
var GATE_CHANNELS = ["paseo", "web", "cli"];
|
|
656
|
+
var GATE_REJECT_LABELS = ["Reject", "T\u1EEB ch\u1ED1i"];
|
|
657
|
+
var labelKey = (text) => text.normalize("NFC").trim().toLowerCase();
|
|
658
|
+
var REJECT_KEYS = new Set(GATE_REJECT_LABELS.map(labelKey));
|
|
659
|
+
function gateOptions(value) {
|
|
660
|
+
if (!Array.isArray(value) || value.length > GATE_OPTIONS || !value.every((item) => typeof item === "string" && !!item.trim() && item.trim().length <= GATE_OPTION_CHARS)) {
|
|
661
|
+
fail("INVALID_TASK", `options must list at most ${GATE_OPTIONS} nonempty answers of at most ${GATE_OPTION_CHARS} characters`);
|
|
662
|
+
}
|
|
663
|
+
const reserved = value.find((item) => REJECT_KEYS.has(labelKey(item)));
|
|
664
|
+
if (reserved !== void 0) fail("INVALID_TASK", `"${reserved.trim()}" is the Reject answer every gate card already offers; name the options for approving only`);
|
|
665
|
+
return [...new Set(value.map((item) => item.trim()))];
|
|
666
|
+
}
|
|
667
|
+
var checkChannel = (channel) => {
|
|
668
|
+
if (channel !== void 0 && !GATE_CHANNELS.includes(channel)) fail("INVALID_TASK", `channel must be one of ${GATE_CHANNELS.join(", ")}`);
|
|
669
|
+
return channel;
|
|
670
|
+
};
|
|
671
|
+
function resolveGate(projectRoot, id, gateId, { by, note, remove = false, ifRev, choice, channel } = {}) {
|
|
672
|
+
return mutate(projectRoot, id, async (task) => {
|
|
635
673
|
const gate = (task.gates ?? []).find((entry) => entry.id === gateId) ?? fail("INVALID_TASK", `${id} has no gate ${gateId}`);
|
|
674
|
+
const record = () => gate.kind === "human" ? ledgerResolve(projectRoot, task.id, gate, { by, channel, removed: remove }) : void 0;
|
|
636
675
|
if (remove) {
|
|
676
|
+
await record();
|
|
637
677
|
task.gates = task.gates.filter((entry) => entry !== gate);
|
|
638
678
|
addLog(task, by, "ungated", { gate: describeGate(gate) });
|
|
639
679
|
return;
|
|
640
680
|
}
|
|
641
681
|
if (!gateOpen(gate)) fail("INVALID_TASK", `Gate ${gateId} of ${id} is already clear`);
|
|
642
682
|
const text = checkText(note, "note", NOTE_CHARS);
|
|
643
|
-
|
|
644
|
-
|
|
683
|
+
checkChannel(channel);
|
|
684
|
+
if (choice !== void 0) {
|
|
685
|
+
if (gate.kind !== "human") fail("INVALID_TASK", "Only a human gate takes a choice");
|
|
686
|
+
if (typeof choice !== "string" || !choice.trim() || (gate.options ? !gate.options.includes(choice.trim()) : choice.trim().length > GATE_OPTION_CHARS)) {
|
|
687
|
+
fail("INVALID_TASK", gate.options ? `choice must be one of: ${gate.options.join(", ")}` : `choice must be nonempty text of at most ${GATE_OPTION_CHARS} characters`);
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
const picked = choice?.trim();
|
|
691
|
+
await record();
|
|
692
|
+
task.gates = task.gates.map((entry) => entry === gate ? { ...entry, resolved: { at: now(), by, ...text ? { note: text } : {}, ...picked ? { choice: picked } : {}, ...channel ? { channel } : {} } } : entry);
|
|
693
|
+
addLog(task, by, "gate cleared", { gate: describeGate(gate), ...picked ? { choice: picked } : {}, ...channel ? { channel } : {}, ...text ? { note: text } : {} });
|
|
645
694
|
if (task.step?.human && task.status !== "closed" && !task.gates.some((entry) => gateOpen(entry))) {
|
|
646
|
-
const summary = `Approved by ${by}${text ? `: ${text}` : ""}`;
|
|
695
|
+
const summary = `Approved by ${by}${picked ? ` (${picked})` : ""}${text ? `: ${text}` : ""}`;
|
|
647
696
|
task.status = "closed";
|
|
648
697
|
task.assignee = null;
|
|
649
698
|
task.closed = { at: now(), by, reason: "done", summary };
|
|
@@ -651,6 +700,39 @@ function resolveGate(projectRoot, id, gateId, { by, note, remove = false, ifRev
|
|
|
651
700
|
}
|
|
652
701
|
}, { ifRev });
|
|
653
702
|
}
|
|
703
|
+
function rejectGate(projectRoot, id, gateId, { by, reason, ifRev, channel } = {}) {
|
|
704
|
+
return mutate(projectRoot, id, (task) => {
|
|
705
|
+
const gate = (task.gates ?? []).find((entry) => entry.id === gateId) ?? fail("INVALID_TASK", `${id} has no gate ${gateId}`);
|
|
706
|
+
if (gate.kind !== "human") fail("INVALID_TASK", "Only a human gate is rejected; remove another gate instead");
|
|
707
|
+
if (!gateOpen(gate)) fail("INVALID_TASK", `Gate ${gateId} of ${id} is already clear`);
|
|
708
|
+
const text = checkText(reason, "reason", NOTE_CHARS);
|
|
709
|
+
checkChannel(channel);
|
|
710
|
+
task.gates = task.gates.map((entry) => entry === gate ? { ...entry, rejected: { at: now(), by, ...text ? { reason: text } : {}, ...channel ? { channel } : {} } } : entry);
|
|
711
|
+
addLog(task, by, "gate rejected", { gate: describeGate(gate), ...channel ? { channel } : {}, ...text ? { note: text } : {} });
|
|
712
|
+
}, { ifRev });
|
|
713
|
+
}
|
|
714
|
+
function gateDecisions(tasks) {
|
|
715
|
+
const found = [];
|
|
716
|
+
for (const task of tasks) for (const gate of task.gates ?? []) {
|
|
717
|
+
if (gate.kind !== "human") continue;
|
|
718
|
+
if (gate.resolved?.overridden) continue;
|
|
719
|
+
if (gate.resolved?.channel && !gate.resolved.notified) found.push({ task, gate, decision: "approved", record: gate.resolved });
|
|
720
|
+
else if (!gate.resolved && gate.rejected?.channel && !gate.rejected.notified) found.push({ task, gate, decision: "rejected", record: gate.rejected });
|
|
721
|
+
}
|
|
722
|
+
return found;
|
|
723
|
+
}
|
|
724
|
+
function markGateNotified(projectRoot, id, gateId, decision, at) {
|
|
725
|
+
return locked(projectRoot, async () => {
|
|
726
|
+
const { tasks } = await loadTasks(projectRoot);
|
|
727
|
+
const task = tasks.find((entry) => entry.id === id);
|
|
728
|
+
const gate = task?.gates?.find((entry) => entry.id === gateId);
|
|
729
|
+
const record = decision === "approved" ? gate?.resolved : gate?.rejected;
|
|
730
|
+
if (!task || !record?.channel || record.notified || at !== void 0 && record.at !== at) return false;
|
|
731
|
+
record.notified = now();
|
|
732
|
+
await save(projectRoot, task);
|
|
733
|
+
return true;
|
|
734
|
+
});
|
|
735
|
+
}
|
|
654
736
|
async function checkGates(projectRoot, gh) {
|
|
655
737
|
const { tasks } = await loadTasks(projectRoot);
|
|
656
738
|
const cleared = [];
|
|
@@ -695,7 +777,8 @@ async function compactTasks(projectRoot, { days = 30, dryRun = false } = {}, by)
|
|
|
695
777
|
...task,
|
|
696
778
|
description: clipText(task.description, COMPACT_TEXT),
|
|
697
779
|
handoff: task.handoff ? { outcome: task.handoff.outcome, summary: clipText(String(task.handoff.summary ?? ""), COMPACT_TEXT), agent: task.handoff.agent, at: task.handoff.at } : null,
|
|
698
|
-
|
|
780
|
+
// `at` stays: it names the gate in the gate ledger (t-ca1f); an open human gate keeps its note too.
|
|
781
|
+
gates: task.gates.map(({ id, kind, at, note, resolved }) => ({ id, kind, ...at ? { at } : {}, ...kind === "human" && !resolved && note ? { note } : {}, ...resolved ? { resolved: { at: resolved.at, by: resolved.by } } : {} })),
|
|
699
782
|
log: [created, closed].filter(Boolean),
|
|
700
783
|
rev: task.rev + 1,
|
|
701
784
|
updatedAt: now()
|
|
@@ -706,6 +789,8 @@ async function compactTasks(projectRoot, { days = 30, dryRun = false } = {}, by)
|
|
|
706
789
|
compacted.push({ id: task.id, before, after });
|
|
707
790
|
if (!dryRun) await save(projectRoot, next);
|
|
708
791
|
}
|
|
792
|
+
if (!dryRun) await ledgerPrune(projectRoot).catch(() => {
|
|
793
|
+
});
|
|
709
794
|
return compacted;
|
|
710
795
|
});
|
|
711
796
|
}
|
|
@@ -785,9 +870,14 @@ function batch(projectRoot, work, { dryRun = false } = {}) {
|
|
|
785
870
|
});
|
|
786
871
|
}
|
|
787
872
|
export {
|
|
873
|
+
AGENT_MARKER,
|
|
788
874
|
CLOSE_REASONS,
|
|
789
875
|
DESCRIPTION_CHARS,
|
|
876
|
+
GATE_CHANNELS,
|
|
790
877
|
GATE_KINDS,
|
|
878
|
+
GATE_OPTIONS,
|
|
879
|
+
GATE_OPTION_CHARS,
|
|
880
|
+
GATE_REJECT_LABELS,
|
|
791
881
|
MAX_GATES,
|
|
792
882
|
MAX_LABELS,
|
|
793
883
|
MAX_LINKS,
|
|
@@ -807,17 +897,21 @@ export {
|
|
|
807
897
|
createTask,
|
|
808
898
|
describeGate,
|
|
809
899
|
epicReport,
|
|
900
|
+
gateDecisions,
|
|
810
901
|
gateOpen,
|
|
811
902
|
gatesOf,
|
|
812
903
|
getTask,
|
|
904
|
+
isAgentProcess,
|
|
813
905
|
isTaskId,
|
|
814
906
|
landedParents,
|
|
815
907
|
linkTask,
|
|
816
908
|
listTasks,
|
|
817
909
|
loadTasks,
|
|
910
|
+
markGateNotified,
|
|
818
911
|
orphanedEntry,
|
|
819
912
|
readyTasks,
|
|
820
913
|
recordVerification,
|
|
914
|
+
rejectGate,
|
|
821
915
|
releaseOrphans,
|
|
822
916
|
releaseTask,
|
|
823
917
|
reopenTask,
|
package/dist/types.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ export type AgentProfilesConfig = {
|
|
|
4
4
|
/** "provider:model", "provider:*" for any model of that provider, or the earlier object form. */
|
|
5
5
|
profiles?: Array<string | AgentModelConfig>;
|
|
6
6
|
autocompact?: AutoCompact;
|
|
7
|
+
/** The runtime's own commands and skills the "/" list offers besides the agent's ALP skills; none by default (t-efa3). */
|
|
8
|
+
commands?: string[];
|
|
7
9
|
claude?: AgentModelConfig;
|
|
8
10
|
codex?: AgentModelConfig;
|
|
9
11
|
} & AgentModelConfig;
|
|
@@ -17,6 +19,7 @@ export interface RawSettings {
|
|
|
17
19
|
workflow?: { mode?: 'pho' | 'cafe' | 'smart' | 'supervised'; maxPeers?: number; supervisor?: boolean };
|
|
18
20
|
delegation?: Record<string, string[]>;
|
|
19
21
|
runtime?: { provider?: string; model?: string; reasoning?: string };
|
|
22
|
+
compact?: { auto?: boolean; threshold?: number };
|
|
20
23
|
}
|
|
21
24
|
export interface RawMcpServer {
|
|
22
25
|
command?: string;
|
package/dist/upgrade.d.ts
CHANGED
|
@@ -8,3 +8,13 @@ export function upgradeProject(projectRoot: any, { library, templates }?: {}): P
|
|
|
8
8
|
created: string[];
|
|
9
9
|
preserved: string[];
|
|
10
10
|
}>;
|
|
11
|
+
/** The hashes above, by project-relative path, so a test can hold the list to the templates. */
|
|
12
|
+
export const shippedRoleHashes: {
|
|
13
|
+
'ALP.md': string[];
|
|
14
|
+
'.alp/agents/main/AGENT.md': string[];
|
|
15
|
+
'.alp/agents/lead/AGENT.md': string[];
|
|
16
|
+
'.alp/agents/peer/AGENT.md': string[];
|
|
17
|
+
'.alp/agents/oracle/AGENT.md': string[];
|
|
18
|
+
'.alp/agents/reviewer/AGENT.md': string[];
|
|
19
|
+
'.alp/agents/supervisor/AGENT.md': string[];
|
|
20
|
+
};
|
package/dist/upgrade.js
CHANGED
|
@@ -13,13 +13,118 @@ var legacy = {
|
|
|
13
13
|
".alp/agents/main/AGENT.md": "# Main agent\n\nHelp with tasks in this project.\n"
|
|
14
14
|
};
|
|
15
15
|
var teamV1 = {
|
|
16
|
-
"ALP.md": [
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
"ALP.md": [
|
|
17
|
+
"c2785aac6538d10e79bd6fb59b11066ccdec77287edf950fad59aa57bf3417f1",
|
|
18
|
+
"0875293195d35d965effb70bb150d1edbc789f66f72c545f7760dea4346b1a9a",
|
|
19
|
+
"fe0d5e6f64ef5a5030ee99feaf083f062a8e5136ac52d451e2ca7cdacb21d14f",
|
|
20
|
+
"e04fe558a26d6e3c9b08211c426a83c368e4f0d15b0929e55df8ab4e5c4bb932",
|
|
21
|
+
// 61181b5
|
|
22
|
+
"ff1a7da448b735a9b4f88e3d9b6006d048114d3becee96a331d225b63e453c56",
|
|
23
|
+
// ca2a971
|
|
24
|
+
"263135a3139eb40501f6e502271e946ec3db4692b63e39c2dd349ac0aaae6d62",
|
|
25
|
+
// 818ab2e
|
|
26
|
+
"e855f56ca0af0691c731ac5f2eb93d2528e339f2dbfd6f2376594f878d2c11e1",
|
|
27
|
+
// 1f827c6
|
|
28
|
+
"48c6a0f80b41958457f8dbaaad7a4b3118efeaf5feb6ae626501c2f7896b077d"
|
|
29
|
+
],
|
|
30
|
+
// PR #330 (replaces 83388aa's hash, which never reached main)
|
|
31
|
+
".alp/agents/main/AGENT.md": [
|
|
32
|
+
"15d217cbc5ede782790d1086124598d9a2b5ff13bcf971a37231962fcef1b47c",
|
|
33
|
+
"e7201a1ed7800d7500b5c8091bd8a435aa9d5138f247c2b02b8bf76299387c90",
|
|
34
|
+
"5001b807bbb686aa1a3b7ecadf9501428909e052e8231281454fd41cbe0ebf27",
|
|
35
|
+
"90f9903fcc97ddf6336e1a28b81103dddc60a6038dcf74d326be8998862cb022",
|
|
36
|
+
"9085ab906e2744a4151ae5c63dd66a545115cd4c876be1fd80f0a0ed4e623da8",
|
|
37
|
+
"fb55cfb0852d07592090de2c49e6c5c2b57936cbffc823dd24767c2db5e5f7fb",
|
|
38
|
+
"91b71f5750e75f707488b70618e1d65a63aabf7518762f97ea0fde999d36fead",
|
|
39
|
+
"60d92fa634e178244a38e99c074e169af1847d7512e268262148ec15ebf08bed",
|
|
40
|
+
// 61181b5
|
|
41
|
+
"b501142ebff430e2ac6d0c3ecb2673cbf0fe0e1fa123b73b113ba9b4aa5f3a39",
|
|
42
|
+
// ca2a971
|
|
43
|
+
"ddbd75ebacf5f13615fa3da4941a389b14b534742032c3046e0e6c214a46c989",
|
|
44
|
+
// ec26e6c
|
|
45
|
+
"5d610e7639bc8eaa29ad4119a5c090cbd286bd217f2f4a7d3abdd59725a985c1",
|
|
46
|
+
// a1acd92
|
|
47
|
+
"28037d678457a392a42510d57919b14a643ea729c2a358fa7aeee4b7a33e6727",
|
|
48
|
+
// 8d0e12a
|
|
49
|
+
"b4435cf5ef8cfab2238eee86298f21cfa508e3fdeb6b3e697fde94160c341fe7",
|
|
50
|
+
// 105f68f
|
|
51
|
+
"973539ce5dd998440cb59938f37260760f96f66a67b66369fcb28421acd49903",
|
|
52
|
+
// 40ce2de
|
|
53
|
+
"ab85e561f62a46e8838cc955984b66583a7325e69c1e7f2fd049479241553751",
|
|
54
|
+
// cc9215e
|
|
55
|
+
"8b8d0bff45d245543f543ecd15043be38fd03edd364c6750aac58b87785c1afa",
|
|
56
|
+
// 818ab2e
|
|
57
|
+
"2e82f110b108032c3c4444c306e73409bb6b481e5dc9ab080fe1ee2eb583fb78",
|
|
58
|
+
// b8d2fbc
|
|
59
|
+
"cde93f41883b26c2ef7636735d88be8fb202b143c479821647799c83b7d673dc",
|
|
60
|
+
// 9180aa1
|
|
61
|
+
"29f181001edfee5521d8f4965b33f501f8ef869f6af3abf74a05e5f1623809ac",
|
|
62
|
+
// f4d7986
|
|
63
|
+
"d6f8002a81e3e0b7bb5868a6834d7be37731cc307877d7a03513067be10cad2f",
|
|
64
|
+
// 1f827c6
|
|
65
|
+
"b9bdd073e22903e3813f13caf87c9341215476ed692b3f04bc0971b66fd93ac5"
|
|
66
|
+
],
|
|
67
|
+
// 83388aa
|
|
68
|
+
".alp/agents/lead/AGENT.md": [
|
|
69
|
+
"c259b085a3c102445f97e5c7d402ca68347bcc1a9b02d6ab96e02be6d8b6f9af",
|
|
70
|
+
"2eef2a4474f757cd89b35b50638a1b23fe49a54c26bf0dedb24a96d7117ddd92",
|
|
71
|
+
"6c71393c9b3aa655c4731bda96396ea3ec0d4da62cddb3ad50d1a24113416b77",
|
|
72
|
+
"a382f0faa724e23a0ba9c212205978aa3fef87c3aecdf8823fba136e04568487",
|
|
73
|
+
"547e3f8fc354b22c7beb3432182d68f4de1f24938375c8bfb167ae8afbf97de2",
|
|
74
|
+
"f3609df1486c0911459d8ee7d823b344369df0538654b0de6e9bc23170186b22",
|
|
75
|
+
"1674d7b96450824111ce885c828af51aa8924c38888bdeb583f4f31684c2bf60",
|
|
76
|
+
// 61181b5
|
|
77
|
+
"7cd01a44200fda79ae0979a4975c483494a35e2e8c144b4e56f0b61046fc1a67",
|
|
78
|
+
// ca2a971
|
|
79
|
+
"c622392fcb94aeec18efcb12fe9ed574117304af02c303d0f575a2181991b454",
|
|
80
|
+
// 8d0e12a
|
|
81
|
+
"6e9166b3b72333b76b4b2ef5a7778e142d6fd3c1023efd8a792bec1b12516415",
|
|
82
|
+
// 40ce2de
|
|
83
|
+
"8aef2591deb1ca12f3cbc843445688140aeb03f7c42bff8e15ef74bdd03be940",
|
|
84
|
+
// 1f827c6
|
|
85
|
+
"e241608ee9579ed894024cba8f9b7b60e75283179d68ebbd4cb28a526c78965d"
|
|
86
|
+
],
|
|
87
|
+
// 83388aa
|
|
88
|
+
".alp/agents/peer/AGENT.md": [
|
|
89
|
+
"f3dcf16c8c899a5378a468e922ca3956fd72cbb3e3798ed1109f11e01aa8f476",
|
|
90
|
+
"39ccf3317eba3003faad77ebad4489fae3eb3c4d89258a03f619d1d3d65af0b7",
|
|
91
|
+
"c59e45e8f22eb0daca9b8b5e1b19e90666156807f160e75a21eca48b5fee1102",
|
|
92
|
+
"9623dbf76eda598f6267629e993663c149acb0efd253f3900a4ee1eda8f2f9e7",
|
|
93
|
+
"20b0d2b6be74597ea1f39cf6d2d56c0ef2bffe39cb3bfe1ae41761748ef9bfae",
|
|
94
|
+
"da389b7fa194fcf4cb8683664d30e06197999d804ec4ee94c1889bb397f540a9",
|
|
95
|
+
// 61181b5
|
|
96
|
+
"c7c8f4c5468484bab165f8f32b141398a259d4e6e9966e304528d82858e6807e",
|
|
97
|
+
// ca2a971
|
|
98
|
+
"d7cbdac679c82086ce2601d0a2c82480f6b2300ea011a9e07862f1b900d6ac75"
|
|
99
|
+
],
|
|
100
|
+
// 1f827c6
|
|
101
|
+
".alp/agents/oracle/AGENT.md": [
|
|
102
|
+
"cdce1babcd587a190dc94a32a951ed70ce2c75f99c205a4049df940851ac7059",
|
|
103
|
+
"0907091b17aa8e54215b65171433f222b8491e9490a16a66b6a2b8cffc3f9023",
|
|
104
|
+
"ae6219e0141d290705ed45992f0cc78688d17c78757f7f1f72f1639432e110cc"
|
|
105
|
+
],
|
|
106
|
+
// 1f827c6
|
|
107
|
+
".alp/agents/reviewer/AGENT.md": [
|
|
108
|
+
"6eab9f918c79335a0665bf4e3a3a26b66258684d6725c4c95637e70e8d355123",
|
|
109
|
+
"1809de0be6473d5f9ceeae2d35128d52a0c0cde3968b45a7569ceae7a8a74416",
|
|
110
|
+
"56bebc192fda9d67bc2ceaf14d4f0cf274eaa40bf3e652caaf85c239eba1a253"
|
|
111
|
+
],
|
|
112
|
+
// 1f827c6
|
|
113
|
+
".alp/agents/supervisor/AGENT.md": [
|
|
114
|
+
"81ac93f4fbf2337224f838d39a9c4ef13fdba12d5fc7de681a00628bf9e69a27",
|
|
115
|
+
"a2be7e682b030d2ff122ba4e836b1c89858493a05937fa11ad1fa808e0df9c8d",
|
|
116
|
+
// 61181b5
|
|
117
|
+
"d26d642128bedb6c90d4a84b227877ae4ea8be0838de75f40d786c0ba55183ae",
|
|
118
|
+
// ec26e6c
|
|
119
|
+
"f920b505cda38c90f7014827352225846b6b1e35a40675e2f5d01b03cee250ce",
|
|
120
|
+
// cdbc297
|
|
121
|
+
"10e22e451264a901a7ad62e04189a91fae70940a62f4646f22c1135244986d03",
|
|
122
|
+
// cc9215e
|
|
123
|
+
"6c306170ee5218313c93dc8bc1049e1dd9daf401073fda4c476ff4b5630765ab"
|
|
124
|
+
]
|
|
125
|
+
// 1f827c6
|
|
22
126
|
};
|
|
127
|
+
var shippedRoleHashes = teamV1;
|
|
23
128
|
var renamedProfiles = { smart: "pho", supervised: "cafe" };
|
|
24
129
|
async function skillFiles(directory) {
|
|
25
130
|
const files = /* @__PURE__ */ new Map();
|
|
@@ -196,5 +301,6 @@ async function retireAgentCopies(root, result, backupPath, replace) {
|
|
|
196
301
|
});
|
|
197
302
|
}
|
|
198
303
|
export {
|
|
304
|
+
shippedRoleHashes,
|
|
199
305
|
upgradeProject
|
|
200
306
|
};
|
package/dist/user-settings.d.ts
CHANGED
|
@@ -4,3 +4,5 @@ export function userLanguage(home?: string): Promise<string>;
|
|
|
4
4
|
export function languageSetting(home: string): Promise<{ language: string | null; applies: string; default: string }>;
|
|
5
5
|
export function setLanguage(home: string | undefined, language: string | null): Promise<{ language: string | null; applies: string; default: string }>;
|
|
6
6
|
export function setWebRelay(home: string, patch: { enabled?: boolean; endpoint?: string; useTls?: boolean }): Promise<{ enabled?: boolean; endpoint?: string; useTls?: boolean }>;
|
|
7
|
+
export function dashboardSettings(settings: unknown): { enabled?: boolean; port?: number; permissions?: string[] };
|
|
8
|
+
export function migrateDashboardSettings(home: string): Promise<{ moved: string[]; conflicts: string[] }>;
|
package/dist/user-settings.js
CHANGED
|
@@ -4,7 +4,7 @@ import { moveFile } from "./atomic.js";
|
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { AlpError } from "./errors.js";
|
|
7
|
-
import { validateUserSettings } from "./validation.js";
|
|
7
|
+
import { DASHBOARD_SETTINGS, validateUserSettings } from "./validation.js";
|
|
8
8
|
var DEFAULT_LANGUAGE = "Vietnamese";
|
|
9
9
|
var LANGUAGE_CHARS = 40;
|
|
10
10
|
async function readSettings(home) {
|
|
@@ -62,10 +62,49 @@ async function setWebRelay(home, patch) {
|
|
|
62
62
|
await moveFile(temporary, file);
|
|
63
63
|
return next.web.relay;
|
|
64
64
|
}
|
|
65
|
+
function dashboardSettings(settings) {
|
|
66
|
+
const now = settings?.dashboard ?? {};
|
|
67
|
+
const before = settings?.web ?? {};
|
|
68
|
+
const result = {};
|
|
69
|
+
for (const key of DASHBOARD_SETTINGS) {
|
|
70
|
+
const value = now[key] !== void 0 ? now[key] : before[key];
|
|
71
|
+
if (value !== void 0) result[key] = value;
|
|
72
|
+
}
|
|
73
|
+
return result;
|
|
74
|
+
}
|
|
75
|
+
async function migrateDashboardSettings(home) {
|
|
76
|
+
const { file, settings } = await readSettings(home);
|
|
77
|
+
const web = settings.web;
|
|
78
|
+
if (!web || typeof web !== "object") return { moved: [], conflicts: [] };
|
|
79
|
+
const moved = [], conflicts = [];
|
|
80
|
+
const dashboard = { ...settings.dashboard };
|
|
81
|
+
const rest = { ...web };
|
|
82
|
+
for (const key of DASHBOARD_SETTINGS) {
|
|
83
|
+
if (web[key] === void 0) continue;
|
|
84
|
+
if (dashboard[key] !== void 0) {
|
|
85
|
+
conflicts.push(key);
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
dashboard[key] = web[key];
|
|
89
|
+
delete rest[key];
|
|
90
|
+
moved.push(key);
|
|
91
|
+
}
|
|
92
|
+
if (!moved.length) return { moved, conflicts };
|
|
93
|
+
const next = { ...settings, dashboard };
|
|
94
|
+
if (Object.keys(rest).length) next.web = rest;
|
|
95
|
+
else delete next.web;
|
|
96
|
+
validateUserSettings(next, file);
|
|
97
|
+
const temporary = `${file}.${randomUUID().slice(0, 8)}.tmp`;
|
|
98
|
+
await writeFile(temporary, JSON.stringify(next, null, 2) + "\n", { mode: 384 });
|
|
99
|
+
await moveFile(temporary, file);
|
|
100
|
+
return { moved, conflicts };
|
|
101
|
+
}
|
|
65
102
|
export {
|
|
66
103
|
DEFAULT_LANGUAGE,
|
|
67
104
|
LANGUAGE_CHARS,
|
|
105
|
+
dashboardSettings,
|
|
68
106
|
languageSetting,
|
|
107
|
+
migrateDashboardSettings,
|
|
69
108
|
setLanguage,
|
|
70
109
|
setWebRelay,
|
|
71
110
|
userLanguage
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export function repositoryIdentity(directory: any): Promise<{
|
|
2
|
+
gitDir: string;
|
|
3
|
+
commonDir: string;
|
|
4
|
+
branch: string | null;
|
|
5
|
+
}>;
|
|
6
|
+
/** User workspace primitives. Assignment cleanup's force/rm semantics must never be used here. */
|
|
7
|
+
export function userWorktreeGit({ executable, timeoutMs, maxBytes }?: {
|
|
8
|
+
executable?: string | undefined;
|
|
9
|
+
timeoutMs?: number | undefined;
|
|
10
|
+
maxBytes?: number | undefined;
|
|
11
|
+
}): {
|
|
12
|
+
facts: (source: any) => Promise<{
|
|
13
|
+
commonDir: string;
|
|
14
|
+
gitDir: string;
|
|
15
|
+
head: any;
|
|
16
|
+
branch: any;
|
|
17
|
+
}>;
|
|
18
|
+
inspect: (source: any, target: any, branch: any) => Promise<any>;
|
|
19
|
+
assertClean: (target: any) => Promise<void>;
|
|
20
|
+
checkoutFacts(directory: any): Promise<{
|
|
21
|
+
isGit: true;
|
|
22
|
+
repoRoot: any;
|
|
23
|
+
currentBranch: any;
|
|
24
|
+
remoteUrl: any;
|
|
25
|
+
isDirty: boolean;
|
|
26
|
+
}>;
|
|
27
|
+
create(source: any, parent: any, name: any, branch: any, head: any): Promise<string>;
|
|
28
|
+
remove(source: any, target: any, branch: any): Promise<void>;
|
|
29
|
+
};
|