@zq-silk/yui 0.2.0 → 0.4.2
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/ARCHITECTURE.md +603 -133
- package/README.md +806 -31
- package/dist/agent/agent.js +2 -1
- package/dist/agent/argumentPolicy.js +3 -1
- package/dist/agent/launchEnvironment.js +106 -0
- package/dist/agent/managedRuntimeEnvironment.js +34 -0
- package/dist/brief/taskBrief.js +11 -1
- package/dist/cli/agentConfigurationPicker.js +287 -0
- package/dist/cli/commandCatalog.js +488 -60
- package/dist/cli/completion.js +146 -22
- package/dist/cli/helpRenderer.js +3 -1
- package/dist/cli/interactionCandidates.js +53 -15
- package/dist/cli/interactionPolicy.js +267 -30
- package/dist/cli/interactiveSelection.js +6 -2
- package/dist/cli/invocationRouter.js +5 -1
- package/dist/cli/operatorWizard.js +87 -0
- package/dist/cli/roleOptionCatalog.js +1 -0
- package/dist/cli/roleWizard.js +185 -21
- package/dist/cli/updateCommand.js +62 -19
- package/dist/cli/updateOrchestrator.js +539 -0
- package/dist/cli/updatePorts.js +1119 -0
- package/dist/cli/upgradeCommand.js +112 -0
- package/dist/cli.js +1420 -86
- package/dist/commands/agentCommands.js +146 -3
- package/dist/commands/configCommands.js +126 -0
- package/dist/commands/controllerCommands.js +365 -0
- package/dist/commands/globalRoleCommands.js +168 -126
- package/dist/commands/jobCommands.js +18 -8
- package/dist/commands/operatorCommands.js +159 -9
- package/dist/commands/profileCommands.js +203 -0
- package/dist/commands/projectCommands.js +650 -0
- package/dist/commands/roleConfiguration.js +85 -24
- package/dist/commands/roleRuntimeGuard.js +12 -0
- package/dist/commands/roleSkillValidation.js +47 -0
- package/dist/commands/taskActor.js +127 -0
- package/dist/commands/taskCommands.js +4201 -313
- package/dist/commands/taskCompletionGate.js +131 -0
- package/dist/commands/taskContextCommand.js +244 -30
- package/dist/commands/taskInputCommands.js +177 -59
- package/dist/commands/taskIntegrationCommands.js +303 -0
- package/dist/commands/taskOverviewCommand.js +363 -0
- package/dist/commands/taskRoleRuntimeStatus.js +125 -19
- package/dist/commands/textInput.js +15 -0
- package/dist/completion/completionInstaller.js +26 -22
- package/dist/config/yuiConfig.js +4 -3
- package/dist/context/dispatchContext.js +90 -38
- package/dist/context/roleSessionContext.js +119 -0
- package/dist/controller/claudeLifecycleHook.js +203 -0
- package/dist/controller/clientRuntime.js +408 -56
- package/dist/controller/codexLifecycleHook.js +108 -0
- package/dist/controller/controller.js +1089 -32
- package/dist/controller/domainIdentity.js +505 -0
- package/dist/controller/ephemeralResourceReaper.js +131 -0
- package/dist/controller/fileSchedulerStoreAdapter.js +2153 -103
- package/dist/controller/providerHookRunFence.js +127 -0
- package/dist/controller/resourceCleanupLinux.js +286 -0
- package/dist/controller/resourceInventory.js +531 -0
- package/dist/controller/resourceInventoryLinux.js +610 -0
- package/dist/controller/runtime.js +629 -10
- package/dist/controller/runtimeEventInbox.js +564 -0
- package/dist/controller/runtimeEventProcessor.js +248 -0
- package/dist/controller/runtimeLaunchCoordinator.js +477 -0
- package/dist/controller/sessionNotify.js +121 -78
- package/dist/coordination/deadlineScheduler.js +15 -0
- package/dist/coordination/mailboxScheduler.js +108 -0
- package/dist/coordination/workMailbox.js +329 -0
- package/dist/coordination/workMailboxQueue.js +86 -0
- package/dist/core/controllerClient.js +19 -5
- package/dist/core/controllerEndpoint.js +37 -0
- package/dist/core/controllerServer.js +218 -10
- package/dist/core/protocol.js +6 -2
- package/dist/decision/decision.js +2 -1
- package/dist/doctor/doctor.js +681 -32
- package/dist/domain/validation.js +53 -0
- package/dist/errors/cliError.js +5 -3
- package/dist/event/taskEvent.js +7 -3
- package/dist/execution/codexThreadNaming.js +160 -0
- package/dist/execution/executionGroup.js +579 -0
- package/dist/executor/agentAdapter.js +255 -40
- package/dist/executor/agentConfigurationCatalog.js +326 -0
- package/dist/executor/agentConfigurationProbe.js +506 -0
- package/dist/executor/agentExecutor.js +625 -10
- package/dist/executor/codexConfigConflict.js +290 -0
- package/dist/executor/effectiveLaunch.js +340 -0
- package/dist/executor/executorRegistry.js +238 -36
- package/dist/executor/fileRoleLaunchPlanner.js +550 -40
- package/dist/executor/turnCompletion.js +126 -0
- package/dist/input/inputRequest.js +30 -9
- package/dist/integration/changeSet.js +36 -0
- package/dist/integration/checkResult.js +24 -0
- package/dist/integration/gitIntegrationService.js +695 -0
- package/dist/integration/integrationAttempt.js +142 -0
- package/dist/interaction/operatorPresentation.js +96 -0
- package/dist/lifecycle/canonicalLifecycleEvent.js +342 -0
- package/dist/lifecycle/exactRunTerminalization.js +572 -0
- package/dist/lifecycle/providerLifecycleMapping.js +190 -0
- package/dist/lifecycle/taskRoleSessionReset.js +124 -0
- package/dist/message/message.js +23 -7
- package/dist/milestone/milestone.js +2 -1
- package/dist/operator/operatorSessionHistory.js +124 -0
- package/dist/output/agentConfigurationPresentation.js +43 -0
- package/dist/output/rolePresentation.js +34 -10
- package/dist/output/terminal.js +8 -0
- package/dist/output/timePresentation.js +55 -0
- package/dist/profile/agentProfile.js +128 -0
- package/dist/repository/gitWorkspace.js +578 -24
- package/dist/repository/project.js +213 -0
- package/dist/repository/taskWorkspaceCoordinator.js +392 -0
- package/dist/repository/taskWorkspacePreparer.js +1688 -191
- package/dist/review/reviewConfig.js +11 -0
- package/dist/review/reviewRound.js +399 -0
- package/dist/review/taskFinalReviewContract.js +90 -0
- package/dist/role/role.js +124 -23
- package/dist/run/agentRun.js +155 -12
- package/dist/run/runIdentity.js +82 -0
- package/dist/runtime/exactControlPlane.js +472 -0
- package/dist/runtime/index.js +8 -0
- package/dist/runtime/lifecycleReservation.js +38 -0
- package/dist/runtime/ports.js +11 -0
- package/dist/runtime/preallocatedNativeSession.js +13 -0
- package/dist/runtime/promptEnvelope.js +30 -0
- package/dist/runtime/runtimeBinding.js +31 -0
- package/dist/runtime/runtimeOwner.js +14 -0
- package/dist/runtime/sessionLaunchRequest.js +62 -0
- package/dist/runtime/sessionTitle.js +54 -0
- package/dist/runtime/taskRuntimeIsolation.js +643 -0
- package/dist/runtime/tmuxAdapters.js +315 -0
- package/dist/runtime/turnCompletion.js +3 -0
- package/dist/runtime/validation.js +23 -0
- package/dist/scheduler/activeRoleRunDelivery.js +342 -32
- package/dist/scheduler/activeTaskProgress.js +63 -0
- package/dist/scheduler/leaderFailure.js +2 -1
- package/dist/scheduler/leaderWakeupProcessor.js +307 -66
- package/dist/scheduler/operatorInputNotificationProcessor.js +109 -46
- package/dist/scheduler/operatorNotification.js +44 -2
- package/dist/scheduler/ports.js +28 -1
- package/dist/scheduler/roleRunLiveness.js +131 -25
- package/dist/scheduler/roleRunStall.js +951 -0
- package/dist/scheduler/taskExecutionProjection.js +544 -0
- package/dist/scheduler/wakeupQueue.js +3 -0
- package/dist/setup/setupCommand.js +302 -52
- package/dist/storage/compatibleTaskStore.js +102 -0
- package/dist/storage/migration/baseline.js +78 -0
- package/dist/storage/migration/classifier.js +51 -0
- package/dist/storage/migration/compatibleCodec.js +53 -0
- package/dist/storage/migration/engine.js +147 -0
- package/dist/storage/migration/index.js +33 -0
- package/dist/storage/migration/planner.js +154 -0
- package/dist/storage/migration/productionRegistry.js +486 -0
- package/dist/storage/migration/registry.js +169 -0
- package/dist/storage/migration/report.js +54 -0
- package/dist/storage/migration/types.js +31 -0
- package/dist/storage/storageSchema.js +147 -123
- package/dist/storage/storageVersions.js +11 -0
- package/dist/storage/taskStore.js +1793 -197
- package/dist/storage/upgrade/homeClassification.js +156 -0
- package/dist/storage/upgrade/homeMigrationTarget.js +595 -0
- package/dist/storage/upgrade/offlineUpgradeInventory.js +315 -0
- package/dist/storage/upgrade/productionMigrationRegistry.js +6 -0
- package/dist/storage/upgrade/recordVersionScan.js +176 -0
- package/dist/storage/upgrade/recordVersions.js +159 -0
- package/dist/storage/upgrade/switchProgress.js +80 -0
- package/dist/storage/upgrade/upgradeOrchestrator.js +948 -0
- package/dist/storage/upgrade/upgradeReceipt.js +161 -0
- package/dist/storage/upgradeCoordination.js +186 -0
- package/dist/storage/upgradeFence.js +366 -0
- package/dist/task/task.js +132 -26
- package/dist/task/taskRecordReference.js +66 -0
- package/dist/tmux/commandExecutor.js +75 -2
- package/dist/tmux/tmuxManager.js +747 -49
- package/dist/version.js +23 -0
- package/dist/web/assets/assetManifest.js +62 -0
- package/dist/web/assets/client/app.js +631 -0
- package/dist/web/assets/client/components.js +605 -0
- package/dist/web/assets/client/dom.js +14 -0
- package/dist/web/assets/client/format.js +28 -0
- package/dist/web/assets/client/i18n.js +494 -0
- package/dist/web/assets/client/markdown.js +114 -0
- package/dist/web/assets/client/theme.js +32 -0
- package/dist/web/assets/client/view.js +458 -0
- package/dist/web/assets/fontData.js +12 -0
- package/dist/web/assets/fonts.js +12 -0
- package/dist/web/assets/shell.js +114 -0
- package/dist/web/assets/styles/cards.js +135 -0
- package/dist/web/assets/styles/layout.js +47 -0
- package/dist/web/assets/styles/markdown.js +29 -0
- package/dist/web/assets/styles/responsive.js +39 -0
- package/dist/web/assets/styles/tokens.js +101 -0
- package/dist/web/assets/styles/widgets.js +147 -0
- package/dist/web/tmuxWebTerminal.js +158 -0
- package/dist/web/webServer.js +463 -0
- package/dist/web/webSnapshot.js +148 -0
- package/dist/workItem/workItem.js +642 -23
- package/dist/workspace/gitChangeSetCapture.js +86 -0
- package/dist/workspace/workItemChangeSetManager.js +445 -0
- package/dist/worktree/managedWorkspace.js +202 -0
- package/docs/task-local-identity.md +62 -0
- package/i18n/README.zh-CN.md +406 -31
- package/package.json +10 -2
- package/skills/yui-leader/SKILL.md +601 -39
- package/skills/yui-operator/SKILL.md +255 -34
- package/skills/yui-reviewer/SKILL.md +57 -0
- package/skills/yui-worker/SKILL.md +214 -17
- package/dist/commands/repositoryCommands.js +0 -86
- package/dist/operator/operatorContext.js +0 -66
- package/dist/repository/repository.js +0 -55
- package/dist/scheduler/archivedTaskRuntime.js +0 -12
- package/dist/worktree/roleWorkspace.js +0 -62
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export const DEFAULT_TIME_ZONE = "Asia/Shanghai";
|
|
2
|
+
export function resolveTimeZone(value) {
|
|
3
|
+
const timeZone = value ?? DEFAULT_TIME_ZONE;
|
|
4
|
+
if (typeof timeZone !== "string" || timeZone.trim() !== timeZone || timeZone.length === 0) {
|
|
5
|
+
throw new TypeError("timeZone must be a valid IANA timezone.");
|
|
6
|
+
}
|
|
7
|
+
try {
|
|
8
|
+
new Intl.DateTimeFormat("en", { timeZone }).format(0);
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
throw new TypeError("timeZone must be a valid IANA timezone.");
|
|
12
|
+
}
|
|
13
|
+
return timeZone;
|
|
14
|
+
}
|
|
15
|
+
/** Formats persisted UTC/RFC 3339 timestamps for human-facing CLI output. */
|
|
16
|
+
export function formatTimestamp(value, configuredTimeZone) {
|
|
17
|
+
const instant = new Date(value);
|
|
18
|
+
if (!Number.isFinite(instant.getTime()))
|
|
19
|
+
throw new TypeError("Timestamp is invalid.");
|
|
20
|
+
const timeZone = resolveTimeZone(configuredTimeZone);
|
|
21
|
+
const parts = Object.fromEntries(new Intl.DateTimeFormat("en-CA", {
|
|
22
|
+
timeZone,
|
|
23
|
+
year: "numeric",
|
|
24
|
+
month: "2-digit",
|
|
25
|
+
day: "2-digit",
|
|
26
|
+
hour: "2-digit",
|
|
27
|
+
minute: "2-digit",
|
|
28
|
+
second: "2-digit",
|
|
29
|
+
hourCycle: "h23",
|
|
30
|
+
timeZoneName: "longOffset"
|
|
31
|
+
}).formatToParts(instant).map(({ type, value: part }) => [type, part]));
|
|
32
|
+
const offset = parts.timeZoneName === "GMT"
|
|
33
|
+
? "+00:00"
|
|
34
|
+
: parts.timeZoneName?.replace(/^GMT/, "");
|
|
35
|
+
if (offset === undefined)
|
|
36
|
+
throw new TypeError("Timezone offset is unavailable.");
|
|
37
|
+
return `${parts.year}-${parts.month}-${parts.day} ${parts.hour}:${parts.minute}:${parts.second} ${offset}`;
|
|
38
|
+
}
|
|
39
|
+
/** Compact elapsed time for recent human-facing activity lists. */
|
|
40
|
+
export function formatRelativeTimestamp(value, now = new Date()) {
|
|
41
|
+
const instant = new Date(value);
|
|
42
|
+
if (!Number.isFinite(instant.getTime()) || !Number.isFinite(now.getTime())) {
|
|
43
|
+
throw new TypeError("Timestamp is invalid.");
|
|
44
|
+
}
|
|
45
|
+
const seconds = Math.floor(Math.max(0, now.getTime() - instant.getTime()) / 1_000);
|
|
46
|
+
if (seconds < 60)
|
|
47
|
+
return seconds <= 5 ? "now" : `${seconds}s ago`;
|
|
48
|
+
const minutes = Math.floor(seconds / 60);
|
|
49
|
+
if (minutes < 60)
|
|
50
|
+
return `${minutes}m ago`;
|
|
51
|
+
const hours = Math.floor(minutes / 60);
|
|
52
|
+
if (hours < 24)
|
|
53
|
+
return `${hours}h ago`;
|
|
54
|
+
return `${Math.floor(hours / 24)}d ago`;
|
|
55
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { cloneJson, normalizedUniqueText, optionalText, requireIdentity, requirePositiveInteger, requireTimestamp } from "../domain/validation.js";
|
|
2
|
+
export const BUILTIN_PROFILE_IDS = Object.freeze([
|
|
3
|
+
"worker",
|
|
4
|
+
"explorer",
|
|
5
|
+
"implementer",
|
|
6
|
+
"reviewer"
|
|
7
|
+
]);
|
|
8
|
+
export function createAgentProfile(input, now) {
|
|
9
|
+
const timestamp = now.toISOString();
|
|
10
|
+
return validateAgentProfile({
|
|
11
|
+
schemaVersion: 2,
|
|
12
|
+
id: requireIdentity(input.id, "Agent Profile id"),
|
|
13
|
+
revision: 1,
|
|
14
|
+
...normalizeInput(input),
|
|
15
|
+
createdAt: timestamp,
|
|
16
|
+
updatedAt: timestamp
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
export function updateAgentProfile(profile, patch, now) {
|
|
20
|
+
validateAgentProfile(profile);
|
|
21
|
+
const candidate = {
|
|
22
|
+
...cloneJson(profile),
|
|
23
|
+
...normalizePatch(patch),
|
|
24
|
+
revision: profile.revision + 1,
|
|
25
|
+
updatedAt: now.toISOString()
|
|
26
|
+
};
|
|
27
|
+
for (const key of ["description", "instructions", "skills", "model", "effort"]) {
|
|
28
|
+
if (candidate[key] === undefined)
|
|
29
|
+
delete candidate[key];
|
|
30
|
+
}
|
|
31
|
+
return validateAgentProfile(candidate);
|
|
32
|
+
}
|
|
33
|
+
export function validateAgentProfile(profile) {
|
|
34
|
+
if (profile.schemaVersion !== 2) {
|
|
35
|
+
throw new Error("AgentProfile must use schemaVersion 2.");
|
|
36
|
+
}
|
|
37
|
+
requireIdentity(profile.id, "Agent Profile id");
|
|
38
|
+
requirePositiveInteger(profile.revision, "Agent Profile revision");
|
|
39
|
+
validateAccess(profile.defaultAccess);
|
|
40
|
+
if (profile.description !== undefined)
|
|
41
|
+
optionalText(profile.description, "Profile description");
|
|
42
|
+
if (profile.instructions !== undefined)
|
|
43
|
+
optionalText(profile.instructions, "Profile instructions");
|
|
44
|
+
if (profile.skills !== undefined)
|
|
45
|
+
normalizedUniqueText(profile.skills, "Profile skill");
|
|
46
|
+
if (profile.model !== undefined)
|
|
47
|
+
optionalText(profile.model, "Profile model");
|
|
48
|
+
if (profile.effort !== undefined)
|
|
49
|
+
optionalText(profile.effort, "Profile effort");
|
|
50
|
+
requireTimestamp(profile.createdAt, "Agent Profile createdAt");
|
|
51
|
+
requireTimestamp(profile.updatedAt, "Agent Profile updatedAt");
|
|
52
|
+
if (Date.parse(profile.updatedAt) < Date.parse(profile.createdAt)) {
|
|
53
|
+
throw new Error("Agent Profile updatedAt cannot precede createdAt.");
|
|
54
|
+
}
|
|
55
|
+
return profile;
|
|
56
|
+
}
|
|
57
|
+
export function builtinAgentProfileInputs() {
|
|
58
|
+
return [
|
|
59
|
+
{
|
|
60
|
+
id: "worker",
|
|
61
|
+
description: "Implement and validate one bounded delegated WorkItem.",
|
|
62
|
+
defaultAccess: "write"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
id: "explorer",
|
|
66
|
+
description: "Inspect sources and return evidence without modifying them.",
|
|
67
|
+
instructions: "Do not modify files or external state.",
|
|
68
|
+
defaultAccess: "read"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
id: "implementer",
|
|
72
|
+
description: "Implement and validate one bounded result.",
|
|
73
|
+
defaultAccess: "write"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
id: "reviewer",
|
|
77
|
+
description: "Review one candidate against the user's core outcome, supported behavior, and direct evidence.",
|
|
78
|
+
instructions: "Start from user intent and acceptance criteria. Inspect the complete relevant change and report only reachable, material, actionable problems with direct evidence. Separate defects from verification gaps, and prefer the smallest sufficient correction. Follow the bound Project's Policy and Knowledge for build, test, migration, release, and review expectations; do not import rules from another Project or Task. For normal software delivery, review the frozen integrated Task result as one final ReviewRound rather than inventing a per-WorkItem protocol unless the Project Policy explicitly requires one. Do not turn speculative or extreme edge cases into new state, retries, fallbacks, or protocol. In a ReviewRound-owned workspace you may edit source or tests, run local checks, and optionally commit diagnostic evidence. Never push, integrate, mutate Task state, touch another workspace or stable checkout, or write the real Yui control-plane home. Report complete findings, checks actually run, uncertainty, and bounded next actions through the exact Review yield; Yui preserves the full free-form report. Expose evidence and options to the Leader, who decides.",
|
|
79
|
+
defaultAccess: "write"
|
|
80
|
+
}
|
|
81
|
+
];
|
|
82
|
+
}
|
|
83
|
+
function normalizeInput(input) {
|
|
84
|
+
return {
|
|
85
|
+
defaultAccess: validatedAccess(input.defaultAccess ?? "read"),
|
|
86
|
+
...(input.description === undefined
|
|
87
|
+
? {}
|
|
88
|
+
: { description: optionalText(input.description, "Profile description") }),
|
|
89
|
+
...(input.instructions === undefined
|
|
90
|
+
? {}
|
|
91
|
+
: { instructions: optionalText(input.instructions, "Profile instructions") }),
|
|
92
|
+
...(input.skills === undefined
|
|
93
|
+
? {}
|
|
94
|
+
: { skills: normalizedUniqueText(input.skills, "Profile skill") }),
|
|
95
|
+
...(input.model === undefined ? {} : { model: optionalText(input.model, "Profile model") }),
|
|
96
|
+
...(input.effort === undefined ? {} : { effort: optionalText(input.effort, "Profile effort") })
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function normalizePatch(patch) {
|
|
100
|
+
const result = {};
|
|
101
|
+
if (Object.hasOwn(patch, "defaultAccess")) {
|
|
102
|
+
result.defaultAccess = validatedAccess(patch.defaultAccess);
|
|
103
|
+
}
|
|
104
|
+
for (const key of ["description", "instructions", "model", "effort"]) {
|
|
105
|
+
if (!Object.hasOwn(patch, key))
|
|
106
|
+
continue;
|
|
107
|
+
result[key] = patch[key] === undefined
|
|
108
|
+
? undefined
|
|
109
|
+
: optionalText(patch[key], `Profile ${key}`);
|
|
110
|
+
}
|
|
111
|
+
if (Object.hasOwn(patch, "skills")) {
|
|
112
|
+
result.skills = patch.skills === undefined
|
|
113
|
+
? undefined
|
|
114
|
+
: normalizedUniqueText(patch.skills, "Profile skill");
|
|
115
|
+
}
|
|
116
|
+
return result;
|
|
117
|
+
}
|
|
118
|
+
function validatedAccess(value) {
|
|
119
|
+
if (value === undefined)
|
|
120
|
+
throw new Error("Agent Profile default access is required.");
|
|
121
|
+
validateAccess(value);
|
|
122
|
+
return value;
|
|
123
|
+
}
|
|
124
|
+
function validateAccess(value) {
|
|
125
|
+
if (value !== "read" && value !== "write") {
|
|
126
|
+
throw new Error(`Agent Profile default access is invalid: ${String(value)}.`);
|
|
127
|
+
}
|
|
128
|
+
}
|