pi-herdsman 0.48.0 → 0.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +63 -0
- package/dist/coordinators/flexible-lead.md +1 -0
- package/dist/coordinators/managed-lead.md +7 -0
- package/dist/coordinators/manager.md +11 -1
- package/dist/index.js +758 -438
- package/dist/index.js.map +3 -3
- package/docs/adr/0040-separate-repository-settings-from-manager-authority.md +37 -0
- package/docs/concepts/coordination.md +1 -1
- package/docs/coordination-api.md +8 -11
- package/docs/development/smoke-testing.md +23 -15
- package/docs/development/validation.md +24 -13
- package/docs/guides/container-deployment.md +86 -28
- package/docs/guides/customizing-agents.md +22 -16
- package/docs/guides/project-orchestration.md +8 -6
- package/docs/guides/recovery.md +2 -2
- package/docs/reference/agent-definition-schema.md +8 -8
- package/docs/reference/await-owner.md +17 -6
- package/docs/reference/commands.md +66 -50
- package/docs/reference/configuration.md +24 -18
- package/package.json +2 -2
- package/skills/agent-definitions/SKILL.md +14 -14
package/dist/index.js
CHANGED
|
@@ -13776,7 +13776,7 @@ function effectiveMergePolicy(config, repoKey) {
|
|
|
13776
13776
|
source: Object.hasOwn(config.managerMergeOverrides, repoKey) ? "repository" : "global"
|
|
13777
13777
|
};
|
|
13778
13778
|
}
|
|
13779
|
-
function setManagerMergeOverride(repoKey, enabled) {
|
|
13779
|
+
function setManagerMergeOverride(repoKey, enabled, expected) {
|
|
13780
13780
|
if (!validRepoIdentity(repoKey) || enabled !== void 0 && !validManagerMergeSetting(enabled))
|
|
13781
13781
|
throw new Error(
|
|
13782
13782
|
"A verified repository identity and optional merge policy are required"
|
|
@@ -13787,6 +13787,10 @@ function setManagerMergeOverride(repoKey, enabled) {
|
|
|
13787
13787
|
});
|
|
13788
13788
|
try {
|
|
13789
13789
|
const current = readRawConfig();
|
|
13790
|
+
if (expected && ((current.managerMergeEnabled ?? DEFAULT_CONFIG.managerMergeEnabled) !== expected.global || current.managerMergeOverrides?.[repoKey] !== expected.override))
|
|
13791
|
+
throw new Error(
|
|
13792
|
+
"Manager integration policy changed; reopen the selector."
|
|
13793
|
+
);
|
|
13790
13794
|
const overrides = { ...current.managerMergeOverrides };
|
|
13791
13795
|
if (enabled === void 0) delete overrides[repoKey];
|
|
13792
13796
|
else overrides[repoKey] = enabled;
|
|
@@ -13807,7 +13811,7 @@ function setManagerMergeOverride(repoKey, enabled) {
|
|
|
13807
13811
|
release();
|
|
13808
13812
|
}
|
|
13809
13813
|
}
|
|
13810
|
-
function setWorktreeRemovalPreapproved(repoKey, enabled) {
|
|
13814
|
+
function setWorktreeRemovalPreapproved(repoKey, enabled, expected) {
|
|
13811
13815
|
if (!repoKey || typeof enabled !== "boolean")
|
|
13812
13816
|
throw new Error(
|
|
13813
13817
|
"A verified repository identity and boolean policy are required"
|
|
@@ -13819,6 +13823,8 @@ function setWorktreeRemovalPreapproved(repoKey, enabled) {
|
|
|
13819
13823
|
try {
|
|
13820
13824
|
const current = readRawConfig();
|
|
13821
13825
|
const repos = new Set(current.worktreeRemovalPreapprovedRepos ?? []);
|
|
13826
|
+
if (expected !== void 0 && repos.has(repoKey) !== expected)
|
|
13827
|
+
throw new Error("Removal policy changed before saving the setting");
|
|
13822
13828
|
if (enabled) repos.add(repoKey);
|
|
13823
13829
|
else repos.delete(repoKey);
|
|
13824
13830
|
if (repos.size) current.worktreeRemovalPreapprovedRepos = [...repos];
|
|
@@ -14006,13 +14012,18 @@ function writeConfigAtomically(path, content, mode = 384) {
|
|
|
14006
14012
|
}
|
|
14007
14013
|
if (cleanupFailed) throw cleanupError;
|
|
14008
14014
|
}
|
|
14009
|
-
function updateConfig(key, value2) {
|
|
14015
|
+
function updateConfig(key, value2, expectedManagerMergeEnabled) {
|
|
14010
14016
|
const path = herdsmanConfigPath();
|
|
14011
14017
|
const release = claimProcessLock(`${path}.lock`, {
|
|
14012
14018
|
name: "Pi Herdsman config update"
|
|
14013
14019
|
});
|
|
14014
14020
|
try {
|
|
14015
14021
|
const current = readRawConfig();
|
|
14022
|
+
if (expectedManagerMergeEnabled !== void 0 && (key !== "managerMergeEnabled" || (current.managerMergeEnabled ?? DEFAULT_CONFIG.managerMergeEnabled) !== expectedManagerMergeEnabled))
|
|
14023
|
+
throw new Error(
|
|
14024
|
+
"Global Manager integration policy changed; reopen the selector."
|
|
14025
|
+
);
|
|
14026
|
+
if (value2 === void 0 && !Object.hasOwn(current, key)) return;
|
|
14016
14027
|
if (value2 !== void 0) {
|
|
14017
14028
|
if (key === "statusWidgetMaxRows" && !validStatusWidgetMaxRows(value2))
|
|
14018
14029
|
throw new Error("Invalid Pi Herdsman config field statusWidgetMaxRows");
|
|
@@ -18724,7 +18735,7 @@ function createAgentController(pi, options) {
|
|
|
18724
18735
|
const unresolved = unresolvedDirectChildCount === 0 ? "all direct agent assignments are resolved" : `${unresolvedDirectChildCount} direct agent assignment${unresolvedDirectChildCount === 1 ? "" : "s"} remain${unresolvedDirectChildCount === 1 ? "s" : ""} unresolved`;
|
|
18725
18736
|
const content = `Delegation status: ${active2}; ${pending}; ${unresolved}.`;
|
|
18726
18737
|
return {
|
|
18727
|
-
content: unresolvedDirectChildCount ? `${content} ${AGENT_EXECUTION_OWNERSHIP_GUIDANCE} ${
|
|
18738
|
+
content: unresolvedDirectChildCount ? `${content} ${AGENT_EXECUTION_OWNERSHIP_GUIDANCE} ${AGENT_UNRESOLVED_NAVIGATION_GUIDANCE}` : content,
|
|
18728
18739
|
activeDirectChildCount,
|
|
18729
18740
|
pendingDirectResultCount,
|
|
18730
18741
|
unresolvedDirectChildCount
|
|
@@ -21075,7 +21086,7 @@ ${result.stderr ?? ""}`.trim(),
|
|
|
21075
21086
|
pi.sendMessage(
|
|
21076
21087
|
{
|
|
21077
21088
|
customType: "pi-herdsman-delegation-guidance",
|
|
21078
|
-
content: `${AGENT_EXECUTION_OWNERSHIP_GUIDANCE} ${
|
|
21089
|
+
content: `${AGENT_EXECUTION_OWNERSHIP_GUIDANCE} ${AGENT_UNRESOLVED_NAVIGATION_GUIDANCE}`,
|
|
21079
21090
|
display: false
|
|
21080
21091
|
},
|
|
21081
21092
|
{ triggerTurn: true, deliverAs: "steer" }
|
|
@@ -21165,7 +21176,7 @@ ${result.stderr ?? ""}`.trim(),
|
|
|
21165
21176
|
name: "delegate_agent",
|
|
21166
21177
|
label: "delegate agent",
|
|
21167
21178
|
exposure: "direct",
|
|
21168
|
-
description: "Start one fresh bounded assignment. Choose the most focused eligible Agent definition capable of completing the full task.
|
|
21179
|
+
description: "Start one fresh bounded assignment. Choose the most focused eligible Agent definition capable of completing the full task using its effective tools. The Agent roster describes potential child capabilities, not your own callable tools. Parent and child tool permissions are independent; delegation does not grant either session the other's tools. Prefer the most focused definition; use a general-purpose definition when broader capabilities are needed or no focused definition fits.",
|
|
21169
21180
|
parameters: agentDelegateParameters,
|
|
21170
21181
|
promptSnippet: void 0,
|
|
21171
21182
|
promptGuidelines: [FILE_HANDOFF_GUIDANCE],
|
|
@@ -22440,7 +22451,7 @@ function collectSessionUsage(ctx, ownedChildren, openOwnedSession, leadRoots = [
|
|
|
22440
22451
|
breakdown
|
|
22441
22452
|
};
|
|
22442
22453
|
}
|
|
22443
|
-
var delegationLockPath, claimDelegationLock, waitForDelegationLock, SHARED_AGENT_INSTRUCTIONS, INTEGRATION_SESSION_RETRY_MS, INTEGRATION_SESSION_RETRIES, HEALTH_STALE_AFTER_MS, HEALTH_STALE_SCAN_MS, HEALTH_STALE_DIAGNOSTIC_TIMEOUT_MS, HEALTH_STALE_DIAGNOSTIC_LINES, HEALTH_ATTENTION_REPEAT_MIN_MS, HEALTH_ATTENTION_FIRST_REPEAT_MS, AGENT_LABEL_PATTERN, validAgentLabel, modelToken, messageLimits, AGENT_DEFINITION_ENTRY, AGENT_EXECUTION_OWNERSHIP_GUIDANCE, AGENT_UNRESOLVED_GUIDANCE, AGENT_DELEGATION_GUIDANCE, AGENT_HANDOFF_GUIDANCE, LEAD_SCOPE_DESCRIPTION, DELEGATING_AGENT_SCOPE_DESCRIPTION, STOP_CLOSURE_ENTRY, ACCEPTED_ASSIGNMENT_ENTRY, RESULT_REF_ENTRY, TRANSCRIPT_MAX_BYTES, TRANSCRIPT_TOOL_RESULT_MAX_BYTES, TRANSCRIPT_TOOL_RESULT_OMISSION;
|
|
22454
|
+
var delegationLockPath, claimDelegationLock, waitForDelegationLock, AUTHORITY_GUIDANCE, SHARED_AGENT_INSTRUCTIONS, INTEGRATION_SESSION_RETRY_MS, INTEGRATION_SESSION_RETRIES, HEALTH_STALE_AFTER_MS, HEALTH_STALE_SCAN_MS, HEALTH_STALE_DIAGNOSTIC_TIMEOUT_MS, HEALTH_STALE_DIAGNOSTIC_LINES, HEALTH_ATTENTION_REPEAT_MIN_MS, HEALTH_ATTENTION_FIRST_REPEAT_MS, AGENT_LABEL_PATTERN, validAgentLabel, modelToken, messageLimits, AGENT_DEFINITION_ENTRY, AGENT_EXECUTION_OWNERSHIP_GUIDANCE, AGENT_UNRESOLVED_NAVIGATION_GUIDANCE, AGENT_UNRESOLVED_GUIDANCE, AGENT_DELEGATION_GUIDANCE, AGENT_HANDOFF_GUIDANCE, LEAD_SCOPE_DESCRIPTION, DELEGATING_AGENT_SCOPE_DESCRIPTION, STOP_CLOSURE_ENTRY, ACCEPTED_ASSIGNMENT_ENTRY, RESULT_REF_ENTRY, TRANSCRIPT_MAX_BYTES, TRANSCRIPT_TOOL_RESULT_MAX_BYTES, TRANSCRIPT_TOOL_RESULT_OMISSION;
|
|
22444
22455
|
var init_agent_controller = __esm({
|
|
22445
22456
|
"extension/agent-controller.ts"() {
|
|
22446
22457
|
"use strict";
|
|
@@ -22498,7 +22509,16 @@ var init_agent_controller = __esm({
|
|
|
22498
22509
|
}
|
|
22499
22510
|
}
|
|
22500
22511
|
};
|
|
22501
|
-
|
|
22512
|
+
AUTHORITY_GUIDANCE = `The human user has the final say on decisions within their authority.
|
|
22513
|
+
|
|
22514
|
+
Respect the authority hierarchy within verified supervision and ownership boundaries: Human > Chief > Manager > Lead > Agent. Higher-level decisions take precedence over subordinate judgment, preferences, and defaults. Agents may advise but must follow applicable decisions.
|
|
22515
|
+
|
|
22516
|
+
Authority flows through the responsible direct supervisor or owner. Higher rank does not grant additional capabilities, ownership, or permission to cross role or assignment boundaries.
|
|
22517
|
+
|
|
22518
|
+
When unable to follow an instruction, identify the specific applicable constraint. Never invent restrictions or elevate conventions, recommendations, or personal judgment into binding requirements.`;
|
|
22519
|
+
SHARED_AGENT_INSTRUCTIONS = `${AUTHORITY_GUIDANCE}
|
|
22520
|
+
|
|
22521
|
+
Work only on the assigned objective and preserve its stated scope, constraints,
|
|
22502
22522
|
authority, and acceptance criteria.
|
|
22503
22523
|
|
|
22504
22524
|
Treat supplied files as message evidence. Explicit Agent attachments must contain
|
|
@@ -22507,7 +22527,7 @@ rejected. Retained assignment evidence may instead be presented by an authorized
|
|
|
22507
22527
|
semantic reference and retrieved with \`read_evidence\`. Reuse adequate existing
|
|
22508
22528
|
evidence instead of repeating completed
|
|
22509
22529
|
work.
|
|
22510
|
-
Do not overlap writers in a worktree or file-ownership boundary. For dependent
|
|
22530
|
+
Do not overlap writers in a worktree or file-ownership boundary. When assessing competing execution, compare observed session and process identity with your verified direct owner before treating a process as an independent writer. A matching session ID alone does not prove exclusive execution or authorize overlapping writes. For dependent
|
|
22511
22531
|
work, pass reusable direct-agent result refs through \`files\`. Preserve
|
|
22512
22532
|
canonical result:<request-id> refs already supplied as file evidence exactly
|
|
22513
22533
|
when forwarding them.
|
|
@@ -22524,10 +22544,18 @@ the normal final handoff, or for an explicitly requested meaningful
|
|
|
22524
22544
|
checkpoint. Do not send routine progress, duplicate an imminent final result,
|
|
22525
22545
|
or notify merely to show activity.
|
|
22526
22546
|
|
|
22527
|
-
Use await_owner only
|
|
22528
|
-
|
|
22529
|
-
|
|
22530
|
-
|
|
22547
|
+
Use await_owner only when required input from your direct
|
|
22548
|
+
owner prevents further correct progress: an unresolved decision,
|
|
22549
|
+
authorization, or specific information the owner must supply.
|
|
22550
|
+
Complete independently safe work first. Do not ask for progress,
|
|
22551
|
+
repeat an already pending request, or reopen a settled decision
|
|
22552
|
+
without materially new evidence.
|
|
22553
|
+
|
|
22554
|
+
If a required owner-provided readiness signal will only become
|
|
22555
|
+
available later, one pending await_owner request may preserve the
|
|
22556
|
+
assignment until that signal arrives. Do not require an
|
|
22557
|
+
immediate acknowledgment or repeatedly ask when it will arrive.
|
|
22558
|
+
After an accepted await_owner call, end your turn;
|
|
22531
22559
|
Herdsman retains the blocked assignment until the owner replies. Explicit attachments must be supported UTF-8
|
|
22532
22560
|
text fully embedded within the applicable per-file and complete-message
|
|
22533
22561
|
budgets. Call await_owner alone as the final tool call of the turn. Wait for the
|
|
@@ -22563,7 +22591,8 @@ blockers, remaining work, and reusable paths or artifacts.`;
|
|
|
22563
22591
|
};
|
|
22564
22592
|
AGENT_DEFINITION_ENTRY = "pi-herdsman-agent-definition";
|
|
22565
22593
|
AGENT_EXECUTION_OWNERSHIP_GUIDANCE = "Each unresolved unit of work has one executor. Using delegate_agent transfers that assignment's execution ownership to the Agent until it resolves. After delegation succeeds, stop executing, inspecting, or analyzing that delegated scope locally; do not assign overlapping work. Continue only concrete, necessary work clearly outside the delegated scope that you still own.";
|
|
22566
|
-
|
|
22594
|
+
AGENT_UNRESOLVED_NAVIGATION_GUIDANCE = "When Agent work is unresolved, handle required control, then continue only necessary work you still own or end the turn without concluding; results or attention resume the session automatically. Do not poll with status requests, sleep, or other waiting mechanisms.";
|
|
22595
|
+
AGENT_UNRESOLVED_GUIDANCE = `Use list_agents when fresh Agent state or ownership is materially needed for a control or recovery decision, or to refresh the definition roster; do not use it for progress polling. Follow current available_tools and revalidation: steer_agent queues a cooperative correction for Pi to deliver after the current assistant turn and its tool calls reach a steering boundary; it does not preempt the current operation. interrupt_agent cancels the current operation and replaces its direction. Use reply_agent only to answer that Agent's exact pending await_owner question. stop_agent abandons an eligible Agent generation and its unfinished assignment. inspect_agent provides bounded live terminal/process evidence; read_agent_transcript provides bounded persisted conversation/tool evidence. ${AGENT_UNRESOLVED_NAVIGATION_GUIDANCE} Stale health attention is diagnosis, not progress polling: use attached evidence first and, when absent or insufficient, perform at most one bounded diagnostic read before passive waiting. A repeated reminder for the same stale episode is additional recovery evidence: unchanged qualifying activity means the Agent has not crossed an execution boundary since the previous reminder. A steer queued during that unchanged episode cannot have taken effect yet. Do not repeat diagnostic reads solely because a reminder fired. Continue waiting only while existing evidence still positively supports a legitimate long-running operation; otherwise use interrupt_agent to stop the current operation and continue the same assignment. A proven lost Agent remains unresolved; physical disappearance is not completion. A physically unknown Agent remains fail-closed: do not control, close, replace, or infer completion of that generation. Unknown Agent identity does not by itself prove a currently active competing writer. For a concrete recovery decision, use available current evidence and at most one bounded diagnostic read when necessary; distinguish historical Agent identity from current execution and delegated scope. Continue necessary independent work that remains authorized and has no unresolved execution conflict. Do not take over the Agent's unresolved assignment. Do not take over or replace unresolved delegated work until the current generation is resolved or explicitly closed. If evidence is insufficient to exclude competing execution, preserve the affected scope and identify the specific missing evidence or external action. Do not repeat the same identity investigation without new evidence.`;
|
|
22567
22596
|
AGENT_DELEGATION_GUIDANCE = "Delegate bounded execution work when an Agent can reasonably own it and delegation is useful. Keep work local when it is trivial, inseparable from work you must own, otherwise unsuitable for an Agent, or delegation would add more coordination than value.";
|
|
22568
22597
|
AGENT_HANDOFF_GUIDANCE = "When delegating a bounded task, prefer continue_agent if a known exact historical managed-Agent Pi session carries substantial context relevant to that task and remains eligible; otherwise use delegate_agent to start fresh from a definition. When a result ref is shown, prefer it to the exact session UUID or path. Retired sessions cannot be continued while context retirement is enabled. If further work is needed, delegate a fresh Agent with the prior handoff and relevant files. Each live Agent generation exists for one assignment; after its terminal result is delivered, Herdsman cleans up that generation. Agent labels identify the current live generation; exact Pi sessions identify historical context and continuation. For new or updated assignments, `task`/`message` and `files` carry assignment evidence. Accepted managed-Agent tasks are retained for descendants as context, not authority; ordinary attachments remain per handoff unless retained. Explicit Agent attachments must contain complete supported UTF-8 text within configured limits, or the handoff is rejected. Retained assignment evidence can instead be presented by an authorized semantic reference and retrieved with read_evidence. Do not attach or mention agent instruction files such as AGENTS.md, CLAUDE.md, GEMINI.md, or equivalents merely because they exist. Rely on normal project or runtime discovery when it supplies those instructions. Attach such a file only when the task itself requires inspecting, modifying, comparing, or transmitting it, the user explicitly requests it, or required instructions would not otherwise reach the target. Skills are separate; attach SKILL.md only when the task needs it and the selected definition does not already provide that skill.";
|
|
22569
22598
|
LEAD_SCOPE_DESCRIPTION = `Own architecture, approved scope, acceptance of Agent outputs, integration, conflict resolution,
|
|
@@ -22573,6 +22602,7 @@ dependent work, to the recipient through \`files\`; omit unrelated evidence and
|
|
|
22573
22602
|
required version, but explicitly forward changed versions. Summaries do not transfer
|
|
22574
22603
|
evidence; a supervisor message does not transfer it to the child.
|
|
22575
22604
|
Decompose only as far as useful.
|
|
22605
|
+
Reassess the remaining authorized objective after each handoff, including verification and requested delivery. If your effective tools cannot perform necessary work, consider an eligible Agent with suitable effective capabilities before reporting a blocker. Agent capability summaries do not prove installed tools, credentials, or external authorization. Verify outcomes from returned evidence; if no permitted execution route exists, report the specific limitation without claiming completion. Respect explicit restrictions on delegation.
|
|
22576
22606
|
Reuse adequate existing evidence instead of duplicating work.
|
|
22577
22607
|
Your herd is your internal team: you and your recursively owned Agents.
|
|
22578
22608
|
Any review conducted within the herd is internal feedback, not user or supervisor
|
|
@@ -23705,15 +23735,15 @@ function registerManagedAgentAskOwnerTool(pi, execute) {
|
|
|
23705
23735
|
name: "await_owner",
|
|
23706
23736
|
label: "Ask owner",
|
|
23707
23737
|
exposure: "model-only",
|
|
23708
|
-
promptSnippet: "
|
|
23738
|
+
promptSnippet: "Request essential input from this managed Agent's direct owner",
|
|
23709
23739
|
promptGuidelines: [FILE_HANDOFF_GUIDANCE],
|
|
23710
|
-
description: "
|
|
23740
|
+
description: "Request a necessary owner decision, authorization, or specific input required to continue. A future readiness signal may remain pending until available. Do not use this for progress polling. Call alone as the final tool call of the turn; wait for the reply only after acceptance. Only one question may be outstanding.",
|
|
23711
23741
|
executionMode: "sequential",
|
|
23712
23742
|
parameters: Type2.Object(
|
|
23713
23743
|
{
|
|
23714
23744
|
question: Type2.String({
|
|
23715
23745
|
minLength: 1,
|
|
23716
|
-
description: "Non-empty
|
|
23746
|
+
description: "Non-empty request for required direct-owner input."
|
|
23717
23747
|
}),
|
|
23718
23748
|
files
|
|
23719
23749
|
},
|
|
@@ -24648,9 +24678,11 @@ function registerManagedAgentRuntime(pi, options) {
|
|
|
24648
24678
|
pi.on("before_agent_start", (event, ctx) => {
|
|
24649
24679
|
const definition = process.env.PI_HERDSMAN_AGENT_DEFINITION;
|
|
24650
24680
|
const label = process.env.PI_HERDSMAN_LABEL;
|
|
24681
|
+
const owner = execution.initialized ? execution.assignment : void 0;
|
|
24651
24682
|
event.systemPromptOptions.sections.pi_herdsman_agent = [
|
|
24652
24683
|
`identity: ${displayIdentity(definition, label)}`,
|
|
24653
|
-
`direct_owner: ${process.env.PI_HERDSMAN_OWNER_DISPLAY}
|
|
24684
|
+
`direct_owner: ${process.env.PI_HERDSMAN_OWNER_DISPLAY}`,
|
|
24685
|
+
...owner ? [`direct_owner_session: ${owner.ownerSessionId}`] : []
|
|
24654
24686
|
].join("\n");
|
|
24655
24687
|
if (delegationEnabled) {
|
|
24656
24688
|
const roster = startupDefinitionRoster;
|
|
@@ -25859,7 +25891,7 @@ import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
|
25859
25891
|
// package.json
|
|
25860
25892
|
var package_default = {
|
|
25861
25893
|
name: "pi-herdsman",
|
|
25862
|
-
version: "0.
|
|
25894
|
+
version: "0.50.0",
|
|
25863
25895
|
type: "module",
|
|
25864
25896
|
description: "Asynchronous Pi subagents and agent fleet orchestration for parallel coding agents with nested delegation, background work, and supervision in herdr.",
|
|
25865
25897
|
license: "Apache-2.0",
|
|
@@ -25950,7 +25982,7 @@ var package_default = {
|
|
|
25950
25982
|
"@types/node": "22.20.5",
|
|
25951
25983
|
"@types/proper-lockfile": "4.1.4",
|
|
25952
25984
|
esbuild: "^0.28.2",
|
|
25953
|
-
oxlint: "1.
|
|
25985
|
+
oxlint: "1.94.0",
|
|
25954
25986
|
prettier: "3.10.1",
|
|
25955
25987
|
typebox: "^1.3.7",
|
|
25956
25988
|
typescript: "7.0.2"
|
|
@@ -27355,58 +27387,127 @@ Type forget ${branch} to confirm.`,
|
|
|
27355
27387
|
)
|
|
27356
27388
|
);
|
|
27357
27389
|
};
|
|
27358
|
-
const
|
|
27359
|
-
|
|
27360
|
-
|
|
27390
|
+
const sameRepositorySettingsIdentity = (a, b) => a.repoKey === b.repoKey && a.checkoutPath === b.checkoutPath && a.isPrimary === b.isPrimary && a.workspaceId === b.workspaceId && a.paneId === b.paneId && a.tabId === b.tabId && a.cwd === b.cwd && a.sessionId === b.sessionId && a.sessionFile === b.sessionFile;
|
|
27391
|
+
const repositorySettingsIdentity = async (ctx) => {
|
|
27392
|
+
const workspaceId = process.env.HERDR_WORKSPACE_ID;
|
|
27393
|
+
const paneId = process.env.HERDR_PANE_ID;
|
|
27394
|
+
const tabId = process.env.HERDR_TAB_ID;
|
|
27395
|
+
const sessionId = ctx.sessionManager.getSessionId();
|
|
27396
|
+
const sessionFile = ctx.sessionManager.getSessionFile();
|
|
27397
|
+
const cwd = ctx.cwd;
|
|
27398
|
+
if (!workspaceId || !paneId || !tabId || !sessionId)
|
|
27361
27399
|
throw new Error(
|
|
27362
|
-
"
|
|
27400
|
+
"Verified workspace, pane, tab and session identity are required"
|
|
27363
27401
|
);
|
|
27364
|
-
const
|
|
27365
|
-
|
|
27366
|
-
|
|
27367
|
-
|
|
27368
|
-
|
|
27402
|
+
const agent = await verifiedHerdrAgent(
|
|
27403
|
+
{
|
|
27404
|
+
piSessionId: sessionId,
|
|
27405
|
+
piSessionFile: sessionFile,
|
|
27406
|
+
workspaceId,
|
|
27407
|
+
paneId,
|
|
27408
|
+
tabId
|
|
27409
|
+
},
|
|
27410
|
+
{
|
|
27411
|
+
listAgents: async () => (await host.listAgents(ctx)).agents,
|
|
27412
|
+
getAgent: async (id) => (await host.runHerdr(host.pi, ctx, ["agent", "get", id], {
|
|
27413
|
+
signal: ctx.signal
|
|
27414
|
+
}))?.agent,
|
|
27415
|
+
expectedSession: host.expectedSession,
|
|
27416
|
+
isPiAgent: host.isPiAgent,
|
|
27417
|
+
matchesExpectedSession
|
|
27418
|
+
}
|
|
27369
27419
|
);
|
|
27370
|
-
if (
|
|
27371
|
-
throw new Error(
|
|
27372
|
-
|
|
27373
|
-
const answer = await ctx.ui.input(
|
|
27374
|
-
`Skip worktree removal confirmation for this verified repository?
|
|
27375
|
-
|
|
27376
|
-
${manager.repoKey}
|
|
27377
|
-
|
|
27378
|
-
Subsequent explicitly requested removals here can proceed without a per-removal prompt. All safety checks remain active. Type enable to confirm.`,
|
|
27379
|
-
void 0,
|
|
27380
|
-
{ signal: ctx.signal }
|
|
27420
|
+
if (!agent)
|
|
27421
|
+
throw new Error(
|
|
27422
|
+
"Herdr session-to-workspace identity is unavailable or conflicting"
|
|
27381
27423
|
);
|
|
27382
|
-
|
|
27383
|
-
}
|
|
27384
|
-
const current = await host.currentManager(ctx);
|
|
27385
|
-
if (!current || !host.sameManagerDescriptor(current, manager))
|
|
27386
|
-
throw new Error("Manager authority changed before saving the setting");
|
|
27387
|
-
setWorktreeRemovalPreapproved(manager.repoKey, enabled);
|
|
27388
|
-
return isWorktreeRemovalPreapproved(manager.repoKey) === enabled;
|
|
27389
|
-
};
|
|
27390
|
-
const getRemovalPreauthorization = async (ctx) => {
|
|
27391
|
-
const manager = await host.currentManager(ctx);
|
|
27392
|
-
if (host.activeRole() !== "manager" || !manager)
|
|
27393
|
-
throw new Error("Only the active Manager can inspect this setting");
|
|
27394
|
-
const group = await host.worktreeGroupScope(
|
|
27424
|
+
const scope = await (host.localRepositoryScope ?? localRepositoryScope)(
|
|
27395
27425
|
host.pi,
|
|
27396
27426
|
ctx,
|
|
27397
|
-
|
|
27427
|
+
workspaceId,
|
|
27398
27428
|
ctx.signal
|
|
27399
27429
|
);
|
|
27400
|
-
if (
|
|
27401
|
-
throw new Error("
|
|
27402
|
-
const current = await host.currentManager(ctx);
|
|
27403
|
-
if (!current || !host.sameManagerDescriptor(current, manager))
|
|
27404
|
-
throw new Error("Manager authority changed while reading this setting");
|
|
27430
|
+
if (workspaceId !== process.env.HERDR_WORKSPACE_ID || paneId !== process.env.HERDR_PANE_ID || tabId !== process.env.HERDR_TAB_ID || sessionId !== ctx.sessionManager.getSessionId() || sessionFile !== ctx.sessionManager.getSessionFile() || cwd !== ctx.cwd)
|
|
27431
|
+
throw new Error("Session context changed while verifying repository");
|
|
27405
27432
|
return {
|
|
27406
|
-
|
|
27407
|
-
|
|
27433
|
+
...scope,
|
|
27434
|
+
workspaceId,
|
|
27435
|
+
paneId,
|
|
27436
|
+
tabId,
|
|
27437
|
+
sessionId,
|
|
27438
|
+
sessionFile,
|
|
27439
|
+
cwd
|
|
27408
27440
|
};
|
|
27409
27441
|
};
|
|
27442
|
+
const revalidateRepositorySettings = async (ctx, expected) => {
|
|
27443
|
+
const current = await repositorySettingsIdentity(ctx);
|
|
27444
|
+
ctx.signal?.throwIfAborted();
|
|
27445
|
+
if (!ctx.hasUI)
|
|
27446
|
+
throw new Error("Interactive session is no longer available");
|
|
27447
|
+
if (!sameRepositorySettingsIdentity(current, expected))
|
|
27448
|
+
throw new Error("Repository or session changed; reopen the selector");
|
|
27449
|
+
};
|
|
27450
|
+
const getRemovalPreauthorization = async (ctx) => {
|
|
27451
|
+
const identity = await repositorySettingsIdentity(ctx);
|
|
27452
|
+
return {
|
|
27453
|
+
identity,
|
|
27454
|
+
repoKey: identity.repoKey,
|
|
27455
|
+
enabled: isWorktreeRemovalPreapproved(identity.repoKey)
|
|
27456
|
+
};
|
|
27457
|
+
};
|
|
27458
|
+
const setRemovalPreauthorization = async (enabled, ctx, expectedIdentity) => {
|
|
27459
|
+
if (!ctx.hasUI)
|
|
27460
|
+
throw new Error(
|
|
27461
|
+
"An interactive user is required to change repository settings"
|
|
27462
|
+
);
|
|
27463
|
+
const identity = await repositorySettingsIdentity(ctx);
|
|
27464
|
+
if (expectedIdentity && !sameRepositorySettingsIdentity(identity, expectedIdentity))
|
|
27465
|
+
throw new Error("Repository or session changed; reopen the selector");
|
|
27466
|
+
const previous = isWorktreeRemovalPreapproved(identity.repoKey);
|
|
27467
|
+
if (enabled && !previous) {
|
|
27468
|
+
const confirmed = await ctx.ui.confirm(
|
|
27469
|
+
"Allow worktree removal without individual approval?",
|
|
27470
|
+
[
|
|
27471
|
+
`Repository: ${identity.repoKey}`,
|
|
27472
|
+
"",
|
|
27473
|
+
"The Manager may execute explicitly requested, eligible",
|
|
27474
|
+
"worktree removals without asking again.",
|
|
27475
|
+
"Existing safety checks remain active."
|
|
27476
|
+
].join("\n"),
|
|
27477
|
+
{ signal: ctx.signal }
|
|
27478
|
+
);
|
|
27479
|
+
if (!confirmed) return false;
|
|
27480
|
+
}
|
|
27481
|
+
await revalidateRepositorySettings(ctx, identity);
|
|
27482
|
+
if (isWorktreeRemovalPreapproved(identity.repoKey) !== previous)
|
|
27483
|
+
throw new Error("Removal policy changed before saving the setting");
|
|
27484
|
+
if (previous !== enabled)
|
|
27485
|
+
setWorktreeRemovalPreapproved(identity.repoKey, enabled, previous);
|
|
27486
|
+
return true;
|
|
27487
|
+
};
|
|
27488
|
+
const setRepositoryMergeOverride = async (enabled, ctx, expectedIdentity, expected) => {
|
|
27489
|
+
if (!ctx.hasUI)
|
|
27490
|
+
throw new Error(
|
|
27491
|
+
"An interactive user is required to change repository settings"
|
|
27492
|
+
);
|
|
27493
|
+
const identity = await repositorySettingsIdentity(ctx);
|
|
27494
|
+
if (!sameRepositorySettingsIdentity(identity, expectedIdentity))
|
|
27495
|
+
throw new Error("Repository or session changed; reopen the selector");
|
|
27496
|
+
const level = (value2) => value2 === false ? 0 : value2 === true ? 1 : 2;
|
|
27497
|
+
const previous = expected.override ?? expected.global;
|
|
27498
|
+
const next = enabled ?? expected.global;
|
|
27499
|
+
if (next !== false && (level(next) > level(previous) || enabled !== void 0 && expected.override === void 0)) {
|
|
27500
|
+
const confirmed = await ctx.ui.confirm(
|
|
27501
|
+
`Allow Manager integration for ${identity.repoKey}?`,
|
|
27502
|
+
next === "divergent" ? "Allow conflict-free divergent merges? Git may create a merge commit and verified integration may automatically remove the exact source worktree." : "Allow fast-forward integration and automatic cleanup of successfully integrated source worktrees?",
|
|
27503
|
+
{ signal: ctx.signal }
|
|
27504
|
+
);
|
|
27505
|
+
if (!confirmed) return false;
|
|
27506
|
+
}
|
|
27507
|
+
await revalidateRepositorySettings(ctx, identity);
|
|
27508
|
+
setManagerMergeOverride(identity.repoKey, enabled, expected);
|
|
27509
|
+
return true;
|
|
27510
|
+
};
|
|
27410
27511
|
const {
|
|
27411
27512
|
pi,
|
|
27412
27513
|
leadRuntime,
|
|
@@ -30321,6 +30422,7 @@ ${(updated.requiredEvidence ?? []).map((entry) => `- ${entry.id}: ${entry.name}`
|
|
|
30321
30422
|
cancelPendingRemoval,
|
|
30322
30423
|
setRemovalPreauthorization,
|
|
30323
30424
|
getRemovalPreauthorization,
|
|
30425
|
+
setRepositoryMergeOverride,
|
|
30324
30426
|
forgetLegacyProjectAssignment,
|
|
30325
30427
|
executeStaff,
|
|
30326
30428
|
updateAssignmentEvidence,
|
|
@@ -30440,6 +30542,17 @@ import {
|
|
|
30440
30542
|
getSupportedThinkingLevels
|
|
30441
30543
|
} from "@earendil-works/pi-ai";
|
|
30442
30544
|
function createLeadCommandRuntime(host) {
|
|
30545
|
+
const confirmMergeGrant = (ctx, setting, scope) => ctx.ui.confirm(
|
|
30546
|
+
`Allow Manager integration for ${scope}?`,
|
|
30547
|
+
setting === "divergent" ? "Allow conflict-free divergent merges? Git may create a merge commit and verified integration may automatically remove the exact source worktree." : "Allow fast-forward integration and automatic cleanup of successfully integrated source worktrees?",
|
|
30548
|
+
{ signal: ctx.signal }
|
|
30549
|
+
);
|
|
30550
|
+
const markCurrent = (items, current) => items.map(
|
|
30551
|
+
(item) => item.value === current ? {
|
|
30552
|
+
...item,
|
|
30553
|
+
description: item.description ? `${item.description} \xB7 current` : "current"
|
|
30554
|
+
} : item
|
|
30555
|
+
);
|
|
30443
30556
|
const modelToken2 = (model) => `${model.provider}/${model.id}`;
|
|
30444
30557
|
return {
|
|
30445
30558
|
async openPlacementMenu(ctx) {
|
|
@@ -30469,7 +30582,7 @@ function createLeadCommandRuntime(host) {
|
|
|
30469
30582
|
],
|
|
30470
30583
|
current.effective
|
|
30471
30584
|
);
|
|
30472
|
-
if (!selected) return;
|
|
30585
|
+
if (!selected || selected === current.effective) return;
|
|
30473
30586
|
host.updateSpawnPlacement(selected);
|
|
30474
30587
|
const verified = await host.placementSettings(ctx);
|
|
30475
30588
|
if (verified.effective !== selected)
|
|
@@ -30507,22 +30620,35 @@ function createLeadCommandRuntime(host) {
|
|
|
30507
30620
|
);
|
|
30508
30621
|
if (!setting) return;
|
|
30509
30622
|
selectedLimit = setting;
|
|
30510
|
-
const
|
|
30511
|
-
|
|
30512
|
-
|
|
30513
|
-
|
|
30514
|
-
|
|
30515
|
-
|
|
30516
|
-
|
|
30517
|
-
|
|
30518
|
-
|
|
30519
|
-
|
|
30520
|
-
|
|
30521
|
-
|
|
30522
|
-
|
|
30523
|
-
|
|
30524
|
-
|
|
30525
|
-
|
|
30623
|
+
const currentBytes = setting === "inlineAttachmentLimitBytes" ? limits.inline.bytes : limits.mailbox.bytes;
|
|
30624
|
+
const currentChoice = presets.some(
|
|
30625
|
+
({ bytes }) => bytes === currentBytes
|
|
30626
|
+
) ? String(currentBytes) : "custom";
|
|
30627
|
+
const choice = await host.selectMenu(
|
|
30628
|
+
ctx,
|
|
30629
|
+
"Limit",
|
|
30630
|
+
markCurrent(
|
|
30631
|
+
[
|
|
30632
|
+
...presets.map(({ label, bytes }) => ({
|
|
30633
|
+
value: String(bytes),
|
|
30634
|
+
label
|
|
30635
|
+
})),
|
|
30636
|
+
{
|
|
30637
|
+
value: "custom",
|
|
30638
|
+
label: "Custom\u2026",
|
|
30639
|
+
description: currentChoice === "custom" ? host.formatMessageLimit(currentBytes) : void 0,
|
|
30640
|
+
help: "Enter a custom limit in KiB, from 1 through 1024."
|
|
30641
|
+
},
|
|
30642
|
+
{
|
|
30643
|
+
value: "reset",
|
|
30644
|
+
label: "Reset",
|
|
30645
|
+
help: "Remove the configured override and use the default."
|
|
30646
|
+
}
|
|
30647
|
+
],
|
|
30648
|
+
currentChoice
|
|
30649
|
+
),
|
|
30650
|
+
currentChoice
|
|
30651
|
+
);
|
|
30526
30652
|
if (!choice) continue;
|
|
30527
30653
|
let value2;
|
|
30528
30654
|
if (choice === "reset") value2 = void 0;
|
|
@@ -30536,6 +30662,7 @@ function createLeadCommandRuntime(host) {
|
|
|
30536
30662
|
}
|
|
30537
30663
|
value2 = kib * 1024;
|
|
30538
30664
|
} else value2 = Number(choice);
|
|
30665
|
+
if (value2 !== void 0 && value2 === currentBytes) continue;
|
|
30539
30666
|
host.updateMessageLimit(selectedLimit, value2);
|
|
30540
30667
|
ctx.ui.notify(
|
|
30541
30668
|
`${selectedLimit}: ${value2 === void 0 ? "reset" : host.formatMessageLimit(value2)}`
|
|
@@ -30559,7 +30686,7 @@ function createLeadCommandRuntime(host) {
|
|
|
30559
30686
|
);
|
|
30560
30687
|
return compactMatches.length === 1 ? compactMatches[0] : void 0;
|
|
30561
30688
|
},
|
|
30562
|
-
async openDefinitionsMenu(ctx) {
|
|
30689
|
+
async openDefinitionsMenu(ctx, initialSection) {
|
|
30563
30690
|
let selectedSection = "agents";
|
|
30564
30691
|
const selectedDefinitions = {};
|
|
30565
30692
|
const loadDefinitions = async (section, includeProject = true, onWarning) => section === "agents" ? (await host.contextAgentDefinitions(ctx, onWarning)).definitions : discoverRoleDefinitions({
|
|
@@ -30576,18 +30703,18 @@ function createLeadCommandRuntime(host) {
|
|
|
30576
30703
|
return loaded.find((candidate) => candidate.name === name);
|
|
30577
30704
|
};
|
|
30578
30705
|
while (true) {
|
|
30579
|
-
const section = await host.selectMenu(
|
|
30706
|
+
const section = initialSection ?? await host.selectMenu(
|
|
30580
30707
|
ctx,
|
|
30581
30708
|
"Agents & Coordinators",
|
|
30582
30709
|
[
|
|
30583
30710
|
{
|
|
30584
30711
|
value: "agents",
|
|
30585
|
-
label: "
|
|
30712
|
+
label: "Agent definitions",
|
|
30586
30713
|
help: "Definitions available for Agent delegation."
|
|
30587
30714
|
},
|
|
30588
30715
|
{
|
|
30589
30716
|
value: "roles",
|
|
30590
|
-
label: "
|
|
30717
|
+
label: "Coordinator profiles",
|
|
30591
30718
|
help: "Profiles for existing Lead, Manager, and Chief roles; these do not grant authority."
|
|
30592
30719
|
}
|
|
30593
30720
|
],
|
|
@@ -31123,6 +31250,7 @@ function createLeadCommandRuntime(host) {
|
|
|
31123
31250
|
definition = verified;
|
|
31124
31251
|
}
|
|
31125
31252
|
}
|
|
31253
|
+
if (initialSection) return;
|
|
31126
31254
|
}
|
|
31127
31255
|
},
|
|
31128
31256
|
async openRunningAgentsMenu(ctx) {
|
|
@@ -31274,7 +31402,7 @@ Continuity proof saved for ${persisted} stopped Agent${persisted === 1 ? "" : "s
|
|
|
31274
31402
|
}
|
|
31275
31403
|
const mode = await host.selectMenu(
|
|
31276
31404
|
ctx,
|
|
31277
|
-
"
|
|
31405
|
+
"Lead mode",
|
|
31278
31406
|
[
|
|
31279
31407
|
{
|
|
31280
31408
|
value: "flexible",
|
|
@@ -31298,7 +31426,25 @@ Continuity proof saved for ${persisted} stopped Agent${persisted === 1 ? "" : "s
|
|
|
31298
31426
|
}
|
|
31299
31427
|
},
|
|
31300
31428
|
async openSettingsMenu(ctx) {
|
|
31301
|
-
let
|
|
31429
|
+
let selectedCategory = "sessions";
|
|
31430
|
+
while (true) {
|
|
31431
|
+
const category = await host.selectMenu(
|
|
31432
|
+
ctx,
|
|
31433
|
+
"Settings",
|
|
31434
|
+
[
|
|
31435
|
+
{ value: "sessions", label: "Sessions & agents" },
|
|
31436
|
+
{ value: "manager", label: "Manager & repositories" },
|
|
31437
|
+
{ value: "interface", label: "Interface" }
|
|
31438
|
+
],
|
|
31439
|
+
selectedCategory
|
|
31440
|
+
);
|
|
31441
|
+
if (!category) return;
|
|
31442
|
+
selectedCategory = category;
|
|
31443
|
+
await this.openSettingsCategory(ctx, category);
|
|
31444
|
+
}
|
|
31445
|
+
},
|
|
31446
|
+
async openSettingsCategory(ctx, category) {
|
|
31447
|
+
let selectedSetting = category === "sessions" ? "default-lead-execution" : category === "manager" ? "auto-activate-manager" : "agent-layout";
|
|
31302
31448
|
const loadProjectState = () => {
|
|
31303
31449
|
if (!ctx.isProjectTrusted())
|
|
31304
31450
|
return { trusted: false, overrides: {} };
|
|
@@ -31318,14 +31464,36 @@ Continuity proof saved for ${persisted} stopped Agent${persisted === 1 ? "" : "s
|
|
|
31318
31464
|
while (true) {
|
|
31319
31465
|
const config = host.readConfig();
|
|
31320
31466
|
const project = loadProjectState();
|
|
31467
|
+
let repository;
|
|
31468
|
+
if (category === "manager") {
|
|
31469
|
+
try {
|
|
31470
|
+
repository = await host.getRemovalPreauthorization(ctx);
|
|
31471
|
+
} catch {
|
|
31472
|
+
}
|
|
31473
|
+
}
|
|
31474
|
+
const merge = repository ? effectiveMergePolicy(config, repository.repoKey) : void 0;
|
|
31475
|
+
let messageSummary;
|
|
31476
|
+
if (category === "sessions") {
|
|
31477
|
+
try {
|
|
31478
|
+
const limits = await host.messageLimits(ctx);
|
|
31479
|
+
messageSummary = `Inline ${host.formatMessageLimit(limits.inline.bytes)} \xB7 mailbox ${host.formatMessageLimit(limits.mailbox.bytes)}`;
|
|
31480
|
+
} catch {
|
|
31481
|
+
messageSummary = "Unavailable";
|
|
31482
|
+
}
|
|
31483
|
+
}
|
|
31321
31484
|
const projectDescription = (key) => !project.trusted ? `Effective ${config[key] ? "on" : "off"} (global; untrusted project)` : "error" in project ? "Project value unavailable" : `Effective ${(Object.hasOwn(project.overrides, key) ? project.overrides[key] : config[key]) ? "on" : "off"}${Object.hasOwn(project.overrides, key) ? " (project)" : " (global)"}`;
|
|
31322
31485
|
const selected = await host.selectMenu(
|
|
31323
31486
|
ctx,
|
|
31324
|
-
"
|
|
31487
|
+
category === "sessions" ? "Sessions & agents" : category === "manager" ? "Manager & repositories" : "Interface",
|
|
31325
31488
|
[
|
|
31489
|
+
{
|
|
31490
|
+
value: "agent-layout",
|
|
31491
|
+
label: "Agent pane layout",
|
|
31492
|
+
description: category === "interface" ? (await host.placementSettings(ctx)).effective : void 0
|
|
31493
|
+
},
|
|
31326
31494
|
{
|
|
31327
31495
|
value: "default-lead-execution",
|
|
31328
|
-
label: "Default Lead
|
|
31496
|
+
label: "Default Lead mode",
|
|
31329
31497
|
description: config.defaultLeadExecution,
|
|
31330
31498
|
help: "Used when a future ordinary Lead session has no persisted execution choice."
|
|
31331
31499
|
},
|
|
@@ -31337,8 +31505,8 @@ Continuity proof saved for ${persisted} stopped Agent${persisted === 1 ? "" : "s
|
|
|
31337
31505
|
},
|
|
31338
31506
|
{
|
|
31339
31507
|
value: "manager-git-bootstrap-confirmation",
|
|
31340
|
-
label: "
|
|
31341
|
-
description:
|
|
31508
|
+
label: "Git initialization prompt",
|
|
31509
|
+
description: config.managerGitBootstrapWithoutConfirmation ? "Skipped" : "Required",
|
|
31342
31510
|
help: "Automatically initialize a non-Git workspace when Manager is started explicitly. Off by default."
|
|
31343
31511
|
},
|
|
31344
31512
|
{
|
|
@@ -31349,8 +31517,8 @@ Continuity proof saved for ${persisted} stopped Agent${persisted === 1 ? "" : "s
|
|
|
31349
31517
|
},
|
|
31350
31518
|
{
|
|
31351
31519
|
value: "manager-merge",
|
|
31352
|
-
label: "
|
|
31353
|
-
description:
|
|
31520
|
+
label: "Local branch integration",
|
|
31521
|
+
description: merge ? `${!merge.enabled ? "Off" : merge.allowDivergence ? "Conflict-free merges" : "Fast-forward"} (${merge.source})` : "Repository unavailable",
|
|
31354
31522
|
help: "Choose whether Managers may integrate accepted local branches only by fast-forward or also by clean divergent merge, with guarded cleanup."
|
|
31355
31523
|
},
|
|
31356
31524
|
{
|
|
@@ -31361,41 +31529,96 @@ Continuity proof saved for ${persisted} stopped Agent${persisted === 1 ? "" : "s
|
|
|
31361
31529
|
},
|
|
31362
31530
|
{
|
|
31363
31531
|
value: "max-agent-depth",
|
|
31364
|
-
label: "
|
|
31532
|
+
label: "Maximum delegation depth",
|
|
31365
31533
|
description: String(config.maxAgentDepth),
|
|
31366
31534
|
help: "Longest chain of nested Agents below the Lead, Manager or Chief (1 = Agents never delegate). Global only; checked at each launch. Existing Agents stay manageable when it is lowered."
|
|
31367
31535
|
},
|
|
31368
31536
|
{
|
|
31369
31537
|
value: "message-limits",
|
|
31370
|
-
label: "Message limits",
|
|
31538
|
+
label: "Message size limits",
|
|
31539
|
+
description: messageSummary,
|
|
31371
31540
|
help: "Configure inline attachment and managed mailbox payload byte limits."
|
|
31372
31541
|
},
|
|
31373
31542
|
{
|
|
31374
|
-
value: "
|
|
31375
|
-
label: "
|
|
31376
|
-
|
|
31543
|
+
value: "removal-confirmation",
|
|
31544
|
+
label: "Worktree removal approval",
|
|
31545
|
+
description: repository ? `${repository.enabled ? "Skipped" : "Required"} (repository)` : "Repository unavailable"
|
|
31377
31546
|
}
|
|
31378
|
-
]
|
|
31547
|
+
].filter(
|
|
31548
|
+
(item) => (category === "sessions" ? [
|
|
31549
|
+
"default-lead-execution",
|
|
31550
|
+
"context-retirement",
|
|
31551
|
+
"max-agent-depth",
|
|
31552
|
+
"message-limits"
|
|
31553
|
+
] : category === "manager" ? [
|
|
31554
|
+
"auto-activate-manager",
|
|
31555
|
+
"manager-git-bootstrap-confirmation",
|
|
31556
|
+
"manager-merge",
|
|
31557
|
+
"removal-confirmation"
|
|
31558
|
+
] : ["agent-layout", "status-widget-rows"]).includes(item.value)
|
|
31559
|
+
),
|
|
31379
31560
|
selectedSetting
|
|
31380
31561
|
);
|
|
31381
31562
|
if (!selected) return;
|
|
31382
31563
|
selectedSetting = selected;
|
|
31383
|
-
if (selected === "
|
|
31384
|
-
await this.
|
|
31564
|
+
if (selected === "agent-layout") {
|
|
31565
|
+
await this.openPlacementMenu(ctx);
|
|
31566
|
+
} else if (selected === "manager-git-bootstrap-confirmation") {
|
|
31567
|
+
const choice = await host.selectMenu(
|
|
31568
|
+
ctx,
|
|
31569
|
+
"Manager Git setup prompt",
|
|
31570
|
+
markCurrent(
|
|
31571
|
+
[
|
|
31572
|
+
{ value: "required", label: "Require confirmation" },
|
|
31573
|
+
{
|
|
31574
|
+
value: "skip",
|
|
31575
|
+
label: "Skip confirmation on explicit Manager start"
|
|
31576
|
+
}
|
|
31577
|
+
],
|
|
31578
|
+
config.managerGitBootstrapWithoutConfirmation ? "skip" : "required"
|
|
31579
|
+
),
|
|
31580
|
+
config.managerGitBootstrapWithoutConfirmation ? "skip" : "required"
|
|
31581
|
+
);
|
|
31582
|
+
if (choice && choice === "skip" !== config.managerGitBootstrapWithoutConfirmation) {
|
|
31583
|
+
if (choice === "skip" && !await ctx.ui.confirm(
|
|
31584
|
+
"Skip Manager Git setup confirmation?",
|
|
31585
|
+
"Explicit Manager activation may initialize a non-Git workspace without asking again.",
|
|
31586
|
+
{ signal: ctx.signal }
|
|
31587
|
+
))
|
|
31588
|
+
continue;
|
|
31589
|
+
if (ctx.signal?.aborted) continue;
|
|
31590
|
+
host.updateConfig(
|
|
31591
|
+
"managerGitBootstrapWithoutConfirmation",
|
|
31592
|
+
choice === "skip"
|
|
31593
|
+
);
|
|
31594
|
+
}
|
|
31385
31595
|
} else if (selected === "status-widget-rows") {
|
|
31386
31596
|
while (true) {
|
|
31387
|
-
const
|
|
31388
|
-
|
|
31389
|
-
|
|
31390
|
-
|
|
31391
|
-
|
|
31392
|
-
|
|
31393
|
-
|
|
31394
|
-
|
|
31395
|
-
|
|
31396
|
-
|
|
31397
|
-
|
|
31398
|
-
|
|
31597
|
+
const currentChoice = config.statusWidgetMaxRows === DEFAULT_STATUS_WIDGET_MAX_ROWS ? "default" : [3, 5, 8, 12, 20].includes(config.statusWidgetMaxRows) ? String(config.statusWidgetMaxRows) : "custom";
|
|
31598
|
+
const choice = await host.selectMenu(
|
|
31599
|
+
ctx,
|
|
31600
|
+
"Status widget rows",
|
|
31601
|
+
markCurrent(
|
|
31602
|
+
[
|
|
31603
|
+
{
|
|
31604
|
+
value: "default",
|
|
31605
|
+
label: `Default (${DEFAULT_STATUS_WIDGET_MAX_ROWS})`
|
|
31606
|
+
},
|
|
31607
|
+
...[3, 5, 8, 12, 20].map((rows) => ({
|
|
31608
|
+
value: String(rows),
|
|
31609
|
+
label: String(rows)
|
|
31610
|
+
})),
|
|
31611
|
+
{
|
|
31612
|
+
value: "custom",
|
|
31613
|
+
label: "Custom\u2026",
|
|
31614
|
+
description: currentChoice === "custom" ? String(config.statusWidgetMaxRows) : void 0
|
|
31615
|
+
},
|
|
31616
|
+
{ value: "reset", label: "Reset" }
|
|
31617
|
+
],
|
|
31618
|
+
currentChoice
|
|
31619
|
+
),
|
|
31620
|
+
currentChoice
|
|
31621
|
+
);
|
|
31399
31622
|
if (!choice) break;
|
|
31400
31623
|
let value2;
|
|
31401
31624
|
if (choice === "reset") value2 = void 0;
|
|
@@ -31412,6 +31635,8 @@ Continuity proof saved for ${persisted} stopped Agent${persisted === 1 ? "" : "s
|
|
|
31412
31635
|
}
|
|
31413
31636
|
} else
|
|
31414
31637
|
value2 = choice === "default" ? DEFAULT_STATUS_WIDGET_MAX_ROWS : Number(choice);
|
|
31638
|
+
if (value2 !== void 0 && value2 === config.statusWidgetMaxRows)
|
|
31639
|
+
break;
|
|
31415
31640
|
try {
|
|
31416
31641
|
host.updateConfig("statusWidgetMaxRows", value2);
|
|
31417
31642
|
ctx.ui.notify(
|
|
@@ -31427,18 +31652,31 @@ Continuity proof saved for ${persisted} stopped Agent${persisted === 1 ? "" : "s
|
|
|
31427
31652
|
}
|
|
31428
31653
|
} else if (selected === "max-agent-depth") {
|
|
31429
31654
|
while (true) {
|
|
31430
|
-
const
|
|
31431
|
-
|
|
31432
|
-
|
|
31433
|
-
|
|
31434
|
-
|
|
31435
|
-
|
|
31436
|
-
|
|
31437
|
-
|
|
31438
|
-
|
|
31439
|
-
|
|
31440
|
-
|
|
31441
|
-
|
|
31655
|
+
const currentChoice = config.maxAgentDepth === DEFAULT_MAX_AGENT_DEPTH ? "default" : [1, 2, 3, 4, 5].includes(config.maxAgentDepth) ? String(config.maxAgentDepth) : "custom";
|
|
31656
|
+
const choice = await host.selectMenu(
|
|
31657
|
+
ctx,
|
|
31658
|
+
"Max Agent depth",
|
|
31659
|
+
markCurrent(
|
|
31660
|
+
[
|
|
31661
|
+
{
|
|
31662
|
+
value: "default",
|
|
31663
|
+
label: `Default (${DEFAULT_MAX_AGENT_DEPTH})`
|
|
31664
|
+
},
|
|
31665
|
+
...[1, 2, 3, 4, 5].map((depth) => ({
|
|
31666
|
+
value: String(depth),
|
|
31667
|
+
label: String(depth)
|
|
31668
|
+
})),
|
|
31669
|
+
{
|
|
31670
|
+
value: "custom",
|
|
31671
|
+
label: "Custom\u2026",
|
|
31672
|
+
description: currentChoice === "custom" ? String(config.maxAgentDepth) : void 0
|
|
31673
|
+
},
|
|
31674
|
+
{ value: "reset", label: "Reset" }
|
|
31675
|
+
],
|
|
31676
|
+
currentChoice
|
|
31677
|
+
),
|
|
31678
|
+
currentChoice
|
|
31679
|
+
);
|
|
31442
31680
|
if (!choice) break;
|
|
31443
31681
|
let value2;
|
|
31444
31682
|
if (choice === "reset") value2 = void 0;
|
|
@@ -31455,6 +31693,7 @@ Continuity proof saved for ${persisted} stopped Agent${persisted === 1 ? "" : "s
|
|
|
31455
31693
|
}
|
|
31456
31694
|
} else
|
|
31457
31695
|
value2 = choice === "default" ? DEFAULT_MAX_AGENT_DEPTH : Number(choice);
|
|
31696
|
+
if (value2 !== void 0 && value2 === config.maxAgentDepth) break;
|
|
31458
31697
|
try {
|
|
31459
31698
|
host.updateConfig("maxAgentDepth", value2);
|
|
31460
31699
|
ctx.ui.notify(
|
|
@@ -31474,251 +31713,283 @@ Continuity proof saved for ${persisted} stopped Agent${persisted === 1 ? "" : "s
|
|
|
31474
31713
|
const mode = await host.selectMenu(
|
|
31475
31714
|
ctx,
|
|
31476
31715
|
"Default Lead execution",
|
|
31477
|
-
|
|
31478
|
-
|
|
31479
|
-
|
|
31480
|
-
|
|
31716
|
+
markCurrent(
|
|
31717
|
+
[
|
|
31718
|
+
{ value: "flexible", label: "flexible" },
|
|
31719
|
+
{ value: "orchestrate", label: "orchestrate" }
|
|
31720
|
+
],
|
|
31721
|
+
config.defaultLeadExecution
|
|
31722
|
+
),
|
|
31481
31723
|
config.defaultLeadExecution
|
|
31482
31724
|
);
|
|
31483
|
-
if (mode
|
|
31484
|
-
|
|
31485
|
-
|
|
31486
|
-
const enabled = !host.readConfig()[key];
|
|
31487
|
-
host.updateConfig(key, enabled);
|
|
31488
|
-
ctx.ui.notify(
|
|
31489
|
-
`Global ${key === "contextRetirement" ? "context retirement" : key === "autoActivateManager" ? "Manager auto-start" : "Manager Git setup confirmation skip"}: ${enabled ? "on" : "off"}`
|
|
31490
|
-
);
|
|
31491
|
-
} else if (selected === "manager-merge") {
|
|
31492
|
-
const current = host.readConfig().managerMergeEnabled;
|
|
31493
|
-
const choice = await host.selectMenu(
|
|
31494
|
-
ctx,
|
|
31495
|
-
"Global Manager local merge",
|
|
31496
|
-
[
|
|
31497
|
-
{ value: "off", label: "Off" },
|
|
31498
|
-
{ value: "fast-forward", label: "Fast-forward only" },
|
|
31499
|
-
{ value: "divergent", label: "Conflict-free merges" }
|
|
31500
|
-
],
|
|
31501
|
-
current === false ? "off" : current === true ? "fast-forward" : "divergent"
|
|
31502
|
-
);
|
|
31503
|
-
if (!choice) continue;
|
|
31504
|
-
const setting = choice === "off" ? false : choice === "fast-forward" ? true : "divergent";
|
|
31505
|
-
if (setting !== false && (current === false || setting === "divergent" && current !== "divergent")) {
|
|
31506
|
-
const confirm = await ctx.ui.input(
|
|
31507
|
-
setting === "divergent" ? "Enable conflict-free divergent Manager merges? Git may create a new merge commit, and successful integration can automatically remove the exact source worktree. Type enable to confirm." : "Enable fast-forward Manager integration and automatic cleanup of successfully integrated source worktrees. Type enable to confirm.",
|
|
31508
|
-
void 0
|
|
31509
|
-
);
|
|
31510
|
-
if (confirm !== "enable") continue;
|
|
31725
|
+
if (mode && mode !== config.defaultLeadExecution) {
|
|
31726
|
+
host.updateConfig("defaultLeadExecution", mode);
|
|
31727
|
+
ctx.ui.notify(`Default Lead mode: ${mode}`);
|
|
31511
31728
|
}
|
|
31512
|
-
|
|
31513
|
-
|
|
31514
|
-
|
|
31729
|
+
} else if (selected === "context-retirement" || selected === "auto-activate-manager") {
|
|
31730
|
+
await this.openProjectSetting(
|
|
31731
|
+
ctx,
|
|
31732
|
+
selected === "context-retirement" ? "contextRetirement" : "autoActivateManager"
|
|
31515
31733
|
);
|
|
31734
|
+
} else if (selected === "manager-merge") {
|
|
31735
|
+
await this.openMergeSetting(ctx);
|
|
31736
|
+
} else if (selected === "removal-confirmation") {
|
|
31737
|
+
await this.openRemovalSetting(ctx);
|
|
31516
31738
|
}
|
|
31517
31739
|
}
|
|
31518
31740
|
},
|
|
31519
|
-
async
|
|
31741
|
+
async openProjectSetting(ctx, key) {
|
|
31742
|
+
const title = key === "autoActivateManager" ? "Manager auto-start" : "Context retirement";
|
|
31743
|
+
let selectedScope = "global";
|
|
31520
31744
|
while (true) {
|
|
31745
|
+
const global2 = host.readConfig()[key];
|
|
31521
31746
|
let overrides;
|
|
31522
|
-
let
|
|
31523
|
-
if (ctx.isProjectTrusted())
|
|
31747
|
+
let unavailable;
|
|
31748
|
+
if (!ctx.isProjectTrusted()) unavailable = "Project is not trusted";
|
|
31749
|
+
else
|
|
31524
31750
|
try {
|
|
31525
31751
|
overrides = host.readProjectOverrides(ctx);
|
|
31526
31752
|
} catch (error2) {
|
|
31527
|
-
|
|
31753
|
+
unavailable = `Project settings unavailable: ${String(error2).replace(/^Error: /, "")}`;
|
|
31528
31754
|
}
|
|
31755
|
+
const projectValue = overrides && Object.hasOwn(overrides, key) ? overrides[key] : void 0;
|
|
31756
|
+
const scope = await host.selectMenu(
|
|
31757
|
+
ctx,
|
|
31758
|
+
title,
|
|
31759
|
+
[
|
|
31760
|
+
{
|
|
31761
|
+
value: "global",
|
|
31762
|
+
label: "Global default",
|
|
31763
|
+
description: global2 ? "On" : "Off"
|
|
31764
|
+
},
|
|
31765
|
+
{
|
|
31766
|
+
value: "project",
|
|
31767
|
+
label: "Current project",
|
|
31768
|
+
description: unavailable ?? (projectValue === void 0 ? `Inherit global (${global2 ? "on" : "off"})` : projectValue ? "On" : "Off")
|
|
31769
|
+
}
|
|
31770
|
+
],
|
|
31771
|
+
selectedScope
|
|
31772
|
+
);
|
|
31773
|
+
if (!scope) return;
|
|
31774
|
+
selectedScope = scope;
|
|
31775
|
+
if (scope === "project" && unavailable) {
|
|
31776
|
+
ctx.ui.notify(unavailable, "warning");
|
|
31777
|
+
continue;
|
|
31529
31778
|
}
|
|
31530
|
-
|
|
31531
|
-
|
|
31532
|
-
|
|
31533
|
-
|
|
31534
|
-
|
|
31535
|
-
|
|
31779
|
+
const currentChoice = scope === "global" ? global2 ? "on" : "off" : projectValue === void 0 ? "inherit" : projectValue ? "on" : "off";
|
|
31780
|
+
const choice = await host.selectMenu(
|
|
31781
|
+
ctx,
|
|
31782
|
+
scope === "global" ? `Global ${title}` : `Project ${title}`,
|
|
31783
|
+
markCurrent(
|
|
31784
|
+
[
|
|
31785
|
+
...scope === "project" ? [
|
|
31786
|
+
{
|
|
31787
|
+
value: "inherit",
|
|
31788
|
+
label: `Inherit global (${global2 ? "on" : "off"})`
|
|
31789
|
+
}
|
|
31790
|
+
] : [],
|
|
31791
|
+
{ value: "on", label: "On" },
|
|
31792
|
+
{ value: "off", label: "Off" }
|
|
31793
|
+
],
|
|
31794
|
+
currentChoice
|
|
31795
|
+
),
|
|
31796
|
+
currentChoice
|
|
31797
|
+
);
|
|
31798
|
+
if (!choice) continue;
|
|
31799
|
+
const value2 = choice === "inherit" ? void 0 : choice === "on";
|
|
31536
31800
|
try {
|
|
31537
|
-
|
|
31538
|
-
|
|
31539
|
-
host.
|
|
31540
|
-
|
|
31541
|
-
|
|
31542
|
-
|
|
31543
|
-
|
|
31544
|
-
}
|
|
31545
|
-
if (!ctx.isProjectTrusted() && !removalPolicy) {
|
|
31801
|
+
if (scope === "global") {
|
|
31802
|
+
if (value2 === global2 || value2 === void 0) continue;
|
|
31803
|
+
host.updateConfig(key, value2);
|
|
31804
|
+
} else {
|
|
31805
|
+
if (value2 === projectValue) continue;
|
|
31806
|
+
host.updateProjectOverride(ctx, key, value2);
|
|
31807
|
+
}
|
|
31546
31808
|
ctx.ui.notify(
|
|
31547
|
-
|
|
31548
|
-
"warning"
|
|
31809
|
+
`${title}: ${value2 === void 0 ? "inherited" : value2 ? "on" : "off"} (${scope}).`
|
|
31549
31810
|
);
|
|
31550
|
-
|
|
31811
|
+
} catch (error2) {
|
|
31812
|
+
ctx.ui.notify(String(error2).replace(/^Error: /, ""), "error");
|
|
31551
31813
|
}
|
|
31552
|
-
|
|
31553
|
-
|
|
31554
|
-
|
|
31814
|
+
}
|
|
31815
|
+
},
|
|
31816
|
+
async openMergeSetting(ctx) {
|
|
31817
|
+
let selectedScope = "global";
|
|
31818
|
+
while (true) {
|
|
31819
|
+
const config = host.readConfig();
|
|
31820
|
+
const global2 = config.managerMergeEnabled;
|
|
31821
|
+
let policy;
|
|
31822
|
+
let unavailable = "";
|
|
31823
|
+
try {
|
|
31824
|
+
policy = await host.getRemovalPreauthorization(ctx);
|
|
31825
|
+
} catch (error2) {
|
|
31826
|
+
unavailable = String(error2).replace(/^Error: /, "");
|
|
31555
31827
|
}
|
|
31556
|
-
const
|
|
31557
|
-
|
|
31828
|
+
const repositoryPolicy = policy ? effectiveMergePolicy(config, policy.repoKey) : void 0;
|
|
31829
|
+
const label = (value2) => value2 === false ? "Off" : value2 === true ? "Fast-forward" : "Conflict-free merges";
|
|
31830
|
+
const scope = await host.selectMenu(
|
|
31831
|
+
ctx,
|
|
31832
|
+
"Local branch integration",
|
|
31833
|
+
[
|
|
31558
31834
|
{
|
|
31559
|
-
value: "
|
|
31560
|
-
label: "
|
|
31561
|
-
|
|
31835
|
+
value: "global",
|
|
31836
|
+
label: "Global default",
|
|
31837
|
+
description: label(global2)
|
|
31562
31838
|
},
|
|
31563
31839
|
{
|
|
31564
|
-
value: "
|
|
31565
|
-
label: "
|
|
31566
|
-
|
|
31840
|
+
value: "repository",
|
|
31841
|
+
label: "Current repository",
|
|
31842
|
+
description: repositoryPolicy ? `${!repositoryPolicy.enabled ? "Off" : repositoryPolicy.allowDivergence ? "Conflict-free merges" : "Fast-forward"} (${repositoryPolicy.source})` : "Unavailable"
|
|
31567
31843
|
}
|
|
31568
|
-
]
|
|
31569
|
-
|
|
31570
|
-
|
|
31571
|
-
|
|
31572
|
-
|
|
31573
|
-
|
|
31574
|
-
|
|
31575
|
-
|
|
31576
|
-
|
|
31577
|
-
|
|
31578
|
-
|
|
31579
|
-
|
|
31580
|
-
help: `Controls local integration and guarded cleanup for verified repository ${mergePolicy.repoKey}.`
|
|
31581
|
-
}
|
|
31582
|
-
] : []
|
|
31583
|
-
];
|
|
31584
|
-
const field = await host.selectMenu(ctx, "Project overrides", [
|
|
31585
|
-
...fields
|
|
31586
|
-
]);
|
|
31587
|
-
if (!field) return;
|
|
31588
|
-
if (field === "removal-confirmation") {
|
|
31589
|
-
const policy = await host.getRemovalPreauthorization(ctx);
|
|
31844
|
+
],
|
|
31845
|
+
selectedScope
|
|
31846
|
+
);
|
|
31847
|
+
if (!scope) return;
|
|
31848
|
+
selectedScope = scope;
|
|
31849
|
+
if (scope === "repository") {
|
|
31850
|
+
if (!policy || !repositoryPolicy) {
|
|
31851
|
+
ctx.ui.notify(`Repository unavailable: ${unavailable}`, "warning");
|
|
31852
|
+
continue;
|
|
31853
|
+
}
|
|
31854
|
+
const override = config.managerMergeOverrides[policy.repoKey];
|
|
31855
|
+
const currentChoice2 = override === void 0 ? "inherit" : override === false ? "off" : override === true ? "fast-forward" : "divergent";
|
|
31590
31856
|
const choice2 = await host.selectMenu(
|
|
31591
31857
|
ctx,
|
|
31592
|
-
`
|
|
31593
|
-
|
|
31594
|
-
|
|
31595
|
-
|
|
31596
|
-
|
|
31597
|
-
|
|
31598
|
-
|
|
31599
|
-
|
|
31600
|
-
|
|
31858
|
+
`Local branch integration \xB7 ${policy.repoKey}`,
|
|
31859
|
+
markCurrent(
|
|
31860
|
+
[
|
|
31861
|
+
{
|
|
31862
|
+
value: "inherit",
|
|
31863
|
+
label: `Inherit global (${label(global2)})`
|
|
31864
|
+
},
|
|
31865
|
+
{ value: "off", label: "Off" },
|
|
31866
|
+
{ value: "fast-forward", label: "Fast-forward only" },
|
|
31867
|
+
{ value: "divergent", label: "Conflict-free merges" }
|
|
31868
|
+
],
|
|
31869
|
+
currentChoice2
|
|
31870
|
+
),
|
|
31871
|
+
currentChoice2
|
|
31601
31872
|
);
|
|
31602
|
-
if (choice2
|
|
31603
|
-
|
|
31604
|
-
|
|
31605
|
-
|
|
31606
|
-
|
|
31607
|
-
|
|
31608
|
-
|
|
31609
|
-
|
|
31873
|
+
if (!choice2) continue;
|
|
31874
|
+
const value2 = choice2 === "inherit" ? void 0 : choice2 === "off" ? false : choice2 === "fast-forward" ? true : "divergent";
|
|
31875
|
+
if (value2 === override) continue;
|
|
31876
|
+
try {
|
|
31877
|
+
const stored = await host.setRepositoryMergeOverride(
|
|
31878
|
+
value2,
|
|
31879
|
+
ctx,
|
|
31880
|
+
policy.identity,
|
|
31881
|
+
{ global: global2, override }
|
|
31610
31882
|
);
|
|
31883
|
+
if (stored)
|
|
31884
|
+
ctx.ui.notify(
|
|
31885
|
+
`Local branch integration updated for ${policy.repoKey}.`
|
|
31886
|
+
);
|
|
31887
|
+
} catch (error2) {
|
|
31888
|
+
ctx.ui.notify(String(error2).replace(/^Error: /, ""), "error");
|
|
31611
31889
|
}
|
|
31612
31890
|
continue;
|
|
31613
31891
|
}
|
|
31614
|
-
|
|
31615
|
-
|
|
31616
|
-
|
|
31617
|
-
|
|
31618
|
-
|
|
31619
|
-
|
|
31620
|
-
const choice2 = await host.selectMenu(
|
|
31621
|
-
ctx,
|
|
31622
|
-
`Manager local merge \xB7 ${mergePolicy.repoKey}`,
|
|
31892
|
+
const current = host.readConfig().managerMergeEnabled;
|
|
31893
|
+
const currentChoice = current === false ? "off" : current === true ? "fast-forward" : "divergent";
|
|
31894
|
+
const choice = await host.selectMenu(
|
|
31895
|
+
ctx,
|
|
31896
|
+
"Global Manager local merge",
|
|
31897
|
+
markCurrent(
|
|
31623
31898
|
[
|
|
31624
|
-
{
|
|
31625
|
-
value: "inherit",
|
|
31626
|
-
label: `Inherit global (${global3 === "divergent" ? "conflict-free merges" : global3 ? "fast-forward only" : "off"})`
|
|
31627
|
-
},
|
|
31628
31899
|
{ value: "off", label: "Off" },
|
|
31629
31900
|
{ value: "fast-forward", label: "Fast-forward only" },
|
|
31630
31901
|
{ value: "divergent", label: "Conflict-free merges" }
|
|
31631
31902
|
],
|
|
31632
|
-
|
|
31633
|
-
)
|
|
31634
|
-
|
|
31635
|
-
|
|
31636
|
-
|
|
31637
|
-
|
|
31638
|
-
|
|
31639
|
-
|
|
31640
|
-
|
|
31641
|
-
|
|
31642
|
-
|
|
31643
|
-
|
|
31644
|
-
|
|
31645
|
-
throw new Error(
|
|
31646
|
-
"Manager repository changed; policy was not updated"
|
|
31647
|
-
);
|
|
31648
|
-
setManagerMergeOverride(mergePolicy.repoKey, enabled);
|
|
31903
|
+
currentChoice
|
|
31904
|
+
),
|
|
31905
|
+
currentChoice
|
|
31906
|
+
);
|
|
31907
|
+
if (!choice) continue;
|
|
31908
|
+
const setting = choice === "off" ? false : choice === "fast-forward" ? true : "divergent";
|
|
31909
|
+
if (setting === current) continue;
|
|
31910
|
+
if (setting !== false && (current === false || setting === "divergent" && current !== "divergent")) {
|
|
31911
|
+
if (!await confirmMergeGrant(ctx, setting, "global settings") || ctx.signal?.aborted)
|
|
31912
|
+
continue;
|
|
31913
|
+
}
|
|
31914
|
+
if (ctx.signal?.aborted) continue;
|
|
31915
|
+
if (host.readConfig().managerMergeEnabled !== current) {
|
|
31649
31916
|
ctx.ui.notify(
|
|
31650
|
-
|
|
31917
|
+
"Global Manager integration policy changed; reopen the selector.",
|
|
31918
|
+
"warning"
|
|
31651
31919
|
);
|
|
31652
31920
|
continue;
|
|
31653
31921
|
}
|
|
31654
|
-
|
|
31655
|
-
|
|
31656
|
-
|
|
31922
|
+
try {
|
|
31923
|
+
host.updateConfig("managerMergeEnabled", setting, current);
|
|
31924
|
+
} catch (error2) {
|
|
31925
|
+
ctx.ui.notify(String(error2).replace(/^Error: /, ""), "error");
|
|
31926
|
+
continue;
|
|
31927
|
+
}
|
|
31928
|
+
ctx.ui.notify(
|
|
31929
|
+
`Global Manager local merge: ${setting === "divergent" ? "conflict-free merges" : setting ? "fast-forward only" : "off"}`
|
|
31930
|
+
);
|
|
31931
|
+
}
|
|
31932
|
+
},
|
|
31933
|
+
async openRemovalSetting(ctx) {
|
|
31934
|
+
try {
|
|
31935
|
+
const policy = await host.getRemovalPreauthorization(ctx);
|
|
31657
31936
|
const choice = await host.selectMenu(
|
|
31658
31937
|
ctx,
|
|
31659
|
-
|
|
31660
|
-
|
|
31661
|
-
|
|
31662
|
-
value: "
|
|
31663
|
-
|
|
31664
|
-
|
|
31665
|
-
|
|
31666
|
-
|
|
31667
|
-
|
|
31668
|
-
|
|
31669
|
-
|
|
31670
|
-
|
|
31671
|
-
{
|
|
31672
|
-
value: "off",
|
|
31673
|
-
label: "Off for this project",
|
|
31674
|
-
help: "Disable this preference in this trusted project."
|
|
31675
|
-
}
|
|
31676
|
-
],
|
|
31677
|
-
Object.hasOwn(overrides, key) ? overrides[key] ? "on" : "off" : "inherit"
|
|
31938
|
+
`Worktree removal approval \xB7 ${policy.repoKey}`,
|
|
31939
|
+
markCurrent(
|
|
31940
|
+
[
|
|
31941
|
+
{ value: "required", label: "Require approval for each removal" },
|
|
31942
|
+
{
|
|
31943
|
+
value: "skip",
|
|
31944
|
+
label: "Allow explicit removals without individual approval"
|
|
31945
|
+
}
|
|
31946
|
+
],
|
|
31947
|
+
policy.enabled ? "skip" : "required"
|
|
31948
|
+
),
|
|
31949
|
+
policy.enabled ? "skip" : "required"
|
|
31678
31950
|
);
|
|
31679
|
-
if (!choice)
|
|
31680
|
-
|
|
31681
|
-
|
|
31682
|
-
|
|
31683
|
-
|
|
31684
|
-
|
|
31685
|
-
|
|
31951
|
+
if (!choice || choice === "skip" === policy.enabled) return;
|
|
31952
|
+
const stored = await host.setRemovalPreauthorization(
|
|
31953
|
+
choice === "skip",
|
|
31954
|
+
ctx,
|
|
31955
|
+
policy.identity
|
|
31956
|
+
);
|
|
31957
|
+
if (stored)
|
|
31686
31958
|
ctx.ui.notify(
|
|
31687
|
-
|
|
31959
|
+
`Worktree removal approval ${choice === "skip" ? "skipped" : "required"} for ${policy.repoKey}.`
|
|
31688
31960
|
);
|
|
31689
|
-
|
|
31690
|
-
|
|
31691
|
-
}
|
|
31961
|
+
} catch (error2) {
|
|
31962
|
+
ctx.ui.notify(String(error2).replace(/^Error: /, ""), "error");
|
|
31692
31963
|
}
|
|
31693
31964
|
},
|
|
31694
31965
|
async openAgentsMenu(ctx) {
|
|
31695
31966
|
let selectedSection = "running";
|
|
31696
31967
|
while (true) {
|
|
31697
|
-
|
|
31698
|
-
|
|
31699
|
-
host.
|
|
31700
|
-
|
|
31701
|
-
|
|
31702
|
-
|
|
31968
|
+
let running = "Unavailable";
|
|
31969
|
+
try {
|
|
31970
|
+
const snapshot = await host.loadStatusSnapshot(
|
|
31971
|
+
ctx,
|
|
31972
|
+
host.controller.sessionSignal()
|
|
31973
|
+
);
|
|
31974
|
+
running = host.formatStatusCounts(snapshot.agents) || "0";
|
|
31975
|
+
} catch {
|
|
31976
|
+
if (ctx.signal?.aborted) return;
|
|
31977
|
+
}
|
|
31703
31978
|
const selected = await host.selectMenu(
|
|
31704
31979
|
ctx,
|
|
31705
|
-
"Agents",
|
|
31980
|
+
"Agents & definitions",
|
|
31706
31981
|
[
|
|
31707
31982
|
{
|
|
31708
31983
|
value: "running",
|
|
31709
|
-
label: "Running",
|
|
31984
|
+
label: "Running agents",
|
|
31710
31985
|
description: running,
|
|
31711
31986
|
help: "Focus a live managed Agent."
|
|
31712
31987
|
},
|
|
31713
|
-
{
|
|
31714
|
-
|
|
31715
|
-
label: "Layout",
|
|
31716
|
-
description: placement.effective,
|
|
31717
|
-
help: "Choose where newly delegated Lead-direct Agents are placed in Herdr."
|
|
31718
|
-
},
|
|
31988
|
+
{ value: "agent-definitions", label: "Agent definitions" },
|
|
31989
|
+
{ value: "coordinator-profiles", label: "Coordinator profiles" },
|
|
31719
31990
|
{
|
|
31720
31991
|
value: "stop-all",
|
|
31721
|
-
label: "Stop all\u2026",
|
|
31992
|
+
label: "Stop all agents\u2026",
|
|
31722
31993
|
help: "Emergency stop for the owned Agent tree. Active work or pending results may be discarded."
|
|
31723
31994
|
}
|
|
31724
31995
|
],
|
|
@@ -31727,7 +31998,10 @@ Continuity proof saved for ${persisted} stopped Agent${persisted === 1 ? "" : "s
|
|
|
31727
31998
|
if (!selected) return;
|
|
31728
31999
|
selectedSection = selected;
|
|
31729
32000
|
if (selected === "running") await this.openRunningAgentsMenu(ctx);
|
|
31730
|
-
else if (selected === "
|
|
32001
|
+
else if (selected === "agent-definitions")
|
|
32002
|
+
await this.openDefinitionsMenu(ctx, "agents");
|
|
32003
|
+
else if (selected === "coordinator-profiles")
|
|
32004
|
+
await this.openDefinitionsMenu(ctx, "roles");
|
|
31731
32005
|
else if (selected === "stop-all") await this.confirmAndStopAll(ctx);
|
|
31732
32006
|
}
|
|
31733
32007
|
},
|
|
@@ -31735,36 +32009,37 @@ Continuity proof saved for ${persisted} stopped Agent${persisted === 1 ? "" : "s
|
|
|
31735
32009
|
let selectedSection = "execution";
|
|
31736
32010
|
while (true) {
|
|
31737
32011
|
const execution = host.leadExecutionPresentation();
|
|
32012
|
+
const showLeadMode = host.isLead() && !execution.managed;
|
|
32013
|
+
if (!showLeadMode && selectedSection === "execution")
|
|
32014
|
+
selectedSection = "agents";
|
|
31738
32015
|
const selected = await host.selectMenu(
|
|
31739
32016
|
ctx,
|
|
31740
32017
|
`Pi Herdsman \xB7 v${host.version}`,
|
|
31741
32018
|
[
|
|
31742
|
-
|
|
31743
|
-
|
|
31744
|
-
|
|
31745
|
-
|
|
31746
|
-
|
|
31747
|
-
|
|
32019
|
+
...showLeadMode ? [
|
|
32020
|
+
{
|
|
32021
|
+
value: "execution",
|
|
32022
|
+
label: "Lead mode",
|
|
32023
|
+
description: execution.mode,
|
|
32024
|
+
help: "Choose whether this Lead works directly or primarily delegates tasks."
|
|
32025
|
+
}
|
|
32026
|
+
] : [],
|
|
31748
32027
|
{
|
|
31749
32028
|
value: "agents",
|
|
31750
|
-
label: "Agents",
|
|
31751
|
-
help: "
|
|
32029
|
+
label: "Agents & definitions",
|
|
32030
|
+
help: "Manage running Agents and inspect definitions."
|
|
31752
32031
|
},
|
|
31753
32032
|
{
|
|
31754
32033
|
value: "manager",
|
|
31755
|
-
label: "Project
|
|
31756
|
-
description: host.roleActive("manager") ? "
|
|
32034
|
+
label: "Project management",
|
|
32035
|
+
description: host.roleActive("manager") ? "Active" : "Inactive",
|
|
31757
32036
|
help: "Coordinate independent project work across Git branches."
|
|
31758
32037
|
},
|
|
31759
32038
|
{
|
|
31760
|
-
value: "
|
|
31761
|
-
label: "
|
|
31762
|
-
|
|
31763
|
-
|
|
31764
|
-
{
|
|
31765
|
-
value: "definitions",
|
|
31766
|
-
label: "Definitions",
|
|
31767
|
-
help: "Inspect available Agents and their configuration."
|
|
32039
|
+
value: "chief",
|
|
32040
|
+
label: "Chief coordination",
|
|
32041
|
+
description: host.roleActive("chief") ? "Active" : "Inactive",
|
|
32042
|
+
help: "Supervise Managers and unassigned Leads across Herdsman."
|
|
31768
32043
|
},
|
|
31769
32044
|
{
|
|
31770
32045
|
value: "settings",
|
|
@@ -31772,10 +32047,9 @@ Continuity proof saved for ${persisted} stopped Agent${persisted === 1 ? "" : "s
|
|
|
31772
32047
|
help: "Change Herdsman preferences."
|
|
31773
32048
|
},
|
|
31774
32049
|
{
|
|
31775
|
-
value: "
|
|
31776
|
-
label: "
|
|
31777
|
-
|
|
31778
|
-
help: "Open advanced Herdsman coordination controls."
|
|
32050
|
+
value: "stats",
|
|
32051
|
+
label: "Usage & costs",
|
|
32052
|
+
help: "View token usage and model costs for this session and its managed work."
|
|
31779
32053
|
}
|
|
31780
32054
|
],
|
|
31781
32055
|
selectedSection
|
|
@@ -31787,46 +32061,50 @@ Continuity proof saved for ${persisted} stopped Agent${persisted === 1 ? "" : "s
|
|
|
31787
32061
|
else if (selected === "manager")
|
|
31788
32062
|
await this.openRoleMenu("manager", ctx);
|
|
31789
32063
|
else if (selected === "stats") await this.showSessionStats(ctx);
|
|
31790
|
-
else if (selected === "definitions")
|
|
31791
|
-
await this.openDefinitionsMenu(ctx);
|
|
31792
32064
|
else if (selected === "settings") await this.openSettingsMenu(ctx);
|
|
31793
|
-
else if (selected === "
|
|
32065
|
+
else if (selected === "chief") await this.openRoleMenu("chief", ctx);
|
|
31794
32066
|
}
|
|
31795
32067
|
},
|
|
31796
|
-
async openAdvancedMenu(ctx) {
|
|
31797
|
-
const selected = await host.selectMenu(ctx, "Advanced", [
|
|
31798
|
-
{
|
|
31799
|
-
value: "chief",
|
|
31800
|
-
label: "Chief mode",
|
|
31801
|
-
description: host.roleActive("chief") ? "active" : void 0,
|
|
31802
|
-
help: "Supervise Managers and unassigned Leads across Herdsman."
|
|
31803
|
-
}
|
|
31804
|
-
]);
|
|
31805
|
-
if (selected === "chief") await this.openRoleMenu("chief", ctx);
|
|
31806
|
-
},
|
|
31807
32068
|
async openRoleMenu(role2, ctx) {
|
|
31808
|
-
const active = host.roleActive(role2);
|
|
31809
32069
|
const name = role2 === "manager" ? "Manager" : "Chief";
|
|
31810
|
-
const title = role2 === "manager" ? "Project
|
|
31811
|
-
|
|
31812
|
-
|
|
31813
|
-
|
|
31814
|
-
|
|
31815
|
-
|
|
31816
|
-
|
|
31817
|
-
|
|
31818
|
-
|
|
31819
|
-
|
|
31820
|
-
|
|
31821
|
-
|
|
31822
|
-
|
|
31823
|
-
|
|
31824
|
-
|
|
31825
|
-
|
|
31826
|
-
|
|
31827
|
-
|
|
31828
|
-
|
|
31829
|
-
|
|
32070
|
+
const title = role2 === "manager" ? "Project management" : "Chief mode";
|
|
32071
|
+
let selectedAction;
|
|
32072
|
+
while (true) {
|
|
32073
|
+
const active = host.roleActive(role2);
|
|
32074
|
+
const selected = await host.selectMenu(
|
|
32075
|
+
ctx,
|
|
32076
|
+
title,
|
|
32077
|
+
active ? [
|
|
32078
|
+
{
|
|
32079
|
+
value: "overview",
|
|
32080
|
+
label: role2 === "manager" ? "Project overview" : "Overview"
|
|
32081
|
+
},
|
|
32082
|
+
...role2 === "manager" ? [
|
|
32083
|
+
{
|
|
32084
|
+
value: "pending-removals",
|
|
32085
|
+
label: "Pending removal requests"
|
|
32086
|
+
}
|
|
32087
|
+
] : [],
|
|
32088
|
+
{
|
|
32089
|
+
value: "refresh",
|
|
32090
|
+
label: role2 === "manager" ? "Refresh Manager profile" : "Refresh profile",
|
|
32091
|
+
help: "Apply definition changes after the current turn becomes idle."
|
|
32092
|
+
},
|
|
32093
|
+
{ value: "leave", label: `Leave ${name} mode` }
|
|
32094
|
+
] : [{ value: "start", label: `Start ${name} mode` }],
|
|
32095
|
+
selectedAction
|
|
32096
|
+
);
|
|
32097
|
+
if (!selected) return;
|
|
32098
|
+
selectedAction = selected;
|
|
32099
|
+
if (selected === "overview" || selected === "start")
|
|
32100
|
+
await this.runRoleCommand(role2, "", ctx);
|
|
32101
|
+
else if (selected === "pending-removals")
|
|
32102
|
+
await host.reviewPendingRemoval(ctx);
|
|
32103
|
+
else if (selected === "refresh")
|
|
32104
|
+
await this.runRoleCommand(role2, "refresh", ctx);
|
|
32105
|
+
else if (selected === "leave")
|
|
32106
|
+
await this.runRoleCommand(role2, "leave", ctx);
|
|
32107
|
+
}
|
|
31830
32108
|
},
|
|
31831
32109
|
async runRoleCommand(role2, rawArgs, ctx) {
|
|
31832
32110
|
const args = rawArgs.trim().split(/\s+/u).filter(Boolean);
|
|
@@ -36515,6 +36793,7 @@ function registerLeadRuntime(pi, options) {
|
|
|
36515
36793
|
removeProjectMessagesForAssignment: options.roleTransitionHost.removeProjectMessagesForAssignment,
|
|
36516
36794
|
appendDurableError: options.herdRunServices.appendDurableError,
|
|
36517
36795
|
writeProjectAssignment: writeProjectAssignment2,
|
|
36796
|
+
listAgents: options.identityHost.listAgents,
|
|
36518
36797
|
liveAgent,
|
|
36519
36798
|
liveLead,
|
|
36520
36799
|
currentManager: (...args) => roleTransitions.currentManager(...args),
|
|
@@ -36588,7 +36867,8 @@ function registerLeadRuntime(pi, options) {
|
|
|
36588
36867
|
pi,
|
|
36589
36868
|
persistStopClosures: (ctx, closures) => projectRuntime.persistStopClosures(ctx, closures),
|
|
36590
36869
|
getRemovalPreauthorization: (ctx) => projectRuntime.getRemovalPreauthorization(ctx),
|
|
36591
|
-
setRemovalPreauthorization: (
|
|
36870
|
+
setRemovalPreauthorization: (...args) => projectRuntime.setRemovalPreauthorization(...args),
|
|
36871
|
+
setRepositoryMergeOverride: (...args) => projectRuntime.setRepositoryMergeOverride(...args),
|
|
36592
36872
|
collectOwnedSessionUsage: (ctx) => {
|
|
36593
36873
|
const managerActive = activeLeadRole(leadRuntime) === "manager" && !leadRuntime.roleSuspended;
|
|
36594
36874
|
if (!managerActive)
|
|
@@ -37061,12 +37341,14 @@ function registerLeadRuntime(pi, options) {
|
|
|
37061
37341
|
pi.setActiveTools(executionTools());
|
|
37062
37342
|
return;
|
|
37063
37343
|
}
|
|
37344
|
+
const restoredTools = pi.getActiveTools();
|
|
37345
|
+
const branch = ctx.sessionManager.getBranch();
|
|
37346
|
+
const sessionId = ctx.sessionManager.getSessionId();
|
|
37064
37347
|
let saved;
|
|
37348
|
+
let branchRole;
|
|
37065
37349
|
try {
|
|
37066
|
-
saved = sessionLeadExecutionState(
|
|
37067
|
-
|
|
37068
|
-
ctx.sessionManager.getSessionId()
|
|
37069
|
-
);
|
|
37350
|
+
saved = sessionLeadExecutionState(branch, sessionId);
|
|
37351
|
+
branchRole = roleHost.sessionLeadRoleState(branch, sessionId);
|
|
37070
37352
|
} catch (error2) {
|
|
37071
37353
|
leadExecution = {
|
|
37072
37354
|
mode: leadExecution?.mode ?? options.commandHost.readConfig().defaultLeadExecution,
|
|
@@ -37075,11 +37357,42 @@ function registerLeadRuntime(pi, options) {
|
|
|
37075
37357
|
};
|
|
37076
37358
|
throw error2;
|
|
37077
37359
|
}
|
|
37078
|
-
const baseline = saved ? [...saved.leadTools] : leadToolState.normalizeBaseTools(
|
|
37360
|
+
const baseline = saved ? [...saved.leadTools] : leadToolState.normalizeBaseTools(restoredTools);
|
|
37079
37361
|
const mode = saved?.mode ?? options.commandHost.readConfig().defaultLeadExecution;
|
|
37080
37362
|
leadToolState.setLeadTools(baseline);
|
|
37363
|
+
const currentExecution = () => leadExecution;
|
|
37081
37364
|
leadExecution = { mode, valid: false, managed: !!leadExecution?.managed };
|
|
37082
37365
|
await restoreLeadExecution(ctx);
|
|
37366
|
+
let checkpointIndex = -1;
|
|
37367
|
+
let toolChangeIndex = -1;
|
|
37368
|
+
for (const [index, entry] of branch.entries()) {
|
|
37369
|
+
if (entry.type === "custom" && entry.data?.sessionId === sessionId && (entry.customType === "pi-herdsman-lead-execution" || entry.customType === "pi-herdsman-role"))
|
|
37370
|
+
checkpointIndex = index;
|
|
37371
|
+
if (entry.type === "message" && entry.message.role === "system" && ((entry.message.toolsAdded?.length ?? 0) > 0 || (entry.message.toolsRemoved?.length ?? 0) > 0))
|
|
37372
|
+
toolChangeIndex = index;
|
|
37373
|
+
}
|
|
37374
|
+
const restoredExecution = currentExecution();
|
|
37375
|
+
if (saved && sessionKind?.kind === "ordinary" && (branchRole?.role ?? "lead") === "lead" && restoredExecution?.valid && !restoredExecution.managed && toolChangeIndex > checkpointIndex) {
|
|
37376
|
+
const projection = inheritedProjectionFor(
|
|
37377
|
+
mode,
|
|
37378
|
+
restoredExecution.definition,
|
|
37379
|
+
baseline,
|
|
37380
|
+
leadToolState.projectLeadTools(baseline, restoredExecution.definition)
|
|
37381
|
+
);
|
|
37382
|
+
if (projection) {
|
|
37383
|
+
const excluded = (name) => projection.excluded.some(
|
|
37384
|
+
(pattern) => matchesToolPattern(pattern, name)
|
|
37385
|
+
);
|
|
37386
|
+
leadToolState.setLeadTools(
|
|
37387
|
+
leadToolState.normalizeBaseTools([
|
|
37388
|
+
...restoredTools.filter(
|
|
37389
|
+
(name) => !excluded(name) && !projection.injected.includes(name)
|
|
37390
|
+
),
|
|
37391
|
+
...baseline.filter(excluded)
|
|
37392
|
+
])
|
|
37393
|
+
);
|
|
37394
|
+
}
|
|
37395
|
+
}
|
|
37083
37396
|
pi.setActiveTools(executionTools());
|
|
37084
37397
|
};
|
|
37085
37398
|
const agentEvents = createLeadAgentEventRuntime({
|
|
@@ -42437,7 +42750,8 @@ var LEAD_COORDINATION_TOOLS = [
|
|
|
42437
42750
|
var CHIEF_TOOLS = STAFF_TOOLS;
|
|
42438
42751
|
var INTERNAL_MESSAGE_PROVENANCE_GUIDANCE = "Herdsman-delivered coordination messages, Agent results, and lifecycle notices are internal communications, even when Pi represents them as user-role messages. Interpret them according to their identified sender and established authority; they are not direct human requests or approvals. Their receipt alone does not require a reply or acknowledgment. Follow your existing role-specific coordination and reporting rules.";
|
|
42439
42752
|
var LEAD_SUPERVISOR_PEER_GUIDANCE = "Use message_supervisor for material coordination or evidence your direct supervisor needs. Use list_peers/message_peer for concrete, task-relevant coordination with eligible peers. Avoid unsolicited routine progress updates, unnecessary acknowledgments, and redundant result announcements. Continue work or report normally when no coordination is needed.";
|
|
42440
|
-
var COMMON_LEAD_GUIDANCE = `${
|
|
42753
|
+
var COMMON_LEAD_GUIDANCE = `${AUTHORITY_GUIDANCE}
|
|
42754
|
+
${LEAD_SCOPE_DESCRIPTION}
|
|
42441
42755
|
${INTERNAL_MESSAGE_PROVENANCE_GUIDANCE}
|
|
42442
42756
|
${LEAD_SUPERVISOR_PEER_GUIDANCE}`;
|
|
42443
42757
|
var ORDINARY_LEAD_CHARTER = `## Lead role
|
|
@@ -42448,7 +42762,7 @@ var MANAGED_LEAD_GUIDANCE = `Managed Lead identity is permanent for this exact P
|
|
|
42448
42762
|
For a verified managed project assignment, assignment required evidence is automatically inherited by newly accepted descendant Agent assignments; sibling Lead assignments do not automatically inherit it.
|
|
42449
42763
|
A Lead's delegation task and ordinary files are recipient-specific; they do not create assignment requirements.
|
|
42450
42764
|
When a previous Agent execution is unresolvable, retain its unresolved assignment and preserve its execution scope. Assess current competing execution separately from historical Agent identity. Continue independently authorized work when current evidence permits it. Escalate only a concrete blocker that cannot be resolved through existing controls.
|
|
42451
|
-
Only the Manager can designate continuing requirements for an assignment.
|
|
42765
|
+
Only the Manager can designate continuing requirements for an assignment. When a proposed scope or continuing-requirement change needs Manager authorization, do not execute or delegate that change before the decision. Continue independently authorized work.
|
|
42452
42766
|
An overlap with another assignment or unanswered coordination message does not itself block your assignment. Continue independently safe work. Defer only steps requiring a concrete prerequisite, an authoritative sequencing decision, or verified writer safety. Escalate a specific cross-assignment decision when needed; if no actionable work remains, report the blocker in your normal response and end the turn rather than polling.
|
|
42453
42767
|
For assigned project work, include findings, proposed continuing
|
|
42454
42768
|
requirements, validation, completion, and review readiness in your
|
|
@@ -42465,6 +42779,7 @@ ${MANAGED_LEAD_GUIDANCE}`;
|
|
|
42465
42779
|
var SUPERVISION_EVENT_GUIDANCE = "Supervision is event-driven. Do not poll staff tools, send repeated messages, or sleep solely to wait for Lead progress. When no independent work remains, end the turn; incoming Lead updates resume coordination.";
|
|
42466
42780
|
var MANAGER_ROLE_CONTRACT = `## Manager role
|
|
42467
42781
|
You are the verified Manager for this Pi session. Supervise eligible Leads in your verified project worktree group. Manage project execution only through exact current project assignments; supervision alone grants no Agent ownership or project lifecycle authority. Configuration changes operating guidance and ordinary tool availability, never authority.
|
|
42782
|
+
${AUTHORITY_GUIDANCE}
|
|
42468
42783
|
${INTERNAL_MESSAGE_PROVENANCE_GUIDANCE}
|
|
42469
42784
|
Project execution belongs to assigned Leads and their Agent trees. Recovery of a Lead's directly owned Agents belongs to that Lead. Coordinate the existing project assignment through the Lead. Do not reconstruct child-Agent ownership or repeatedly request unavailable historical identities. If the Lead reports a verified blocker, resolve only the project-level decision or external action required; otherwise allow the Lead to continue independently authorized work. Coordination messages and reports are nonterminal and do not establish completion. Use remove_worktree only for an explicitly requested checkout-removal action; never infer removal from completion, review, or inactivity. Unless this repository has been explicitly preauthorized by a human, the tool registers a pending approval and returns promptly. Direct the user to /manager remove to review it, then continue unrelated coordination. Do not repeat or poll a pending request; its result is not evidence of removal.
|
|
42470
42785
|
Subject to existing writer and authority safeguards, overlapping assignments
|
|
@@ -42477,6 +42792,7 @@ If a concrete cross-assignment blocker requires a scope, priority, sequencing,
|
|
|
42477
42792
|
or other project-level decision not settled by existing user instructions,
|
|
42478
42793
|
report the evidence and affected work to the user for direction before
|
|
42479
42794
|
redirecting Leads. Keep unaffected assignments progressing independently.
|
|
42795
|
+
For a new objective requiring independent project-assignment ownership, use delegate_work when authorized; do not route it through message_staff to an unrelated existing Lead. message_staff changes or coordinates work within an existing assignment; resume_work recovers a paused assignment. list_staff reports current assignments and direct reports, not a limit on creating another assignment. Keep work with an existing Lead when the user intends that ownership and the existing assignment authorizes it.
|
|
42480
42796
|
For assigned project work, use message_staff when the assignment is active, including when its Lead's runtime state is idle or done. Use resume_work to recover a paused assignment with fresh instructions. Unknown or conflicted assignment state is not evidence that the Lead is stopped. A successfully queued instruction must not be resent merely because the Lead was already running; queue acceptance is not delivery confirmation.
|
|
42481
42797
|
${SUPERVISION_EVENT_GUIDANCE}`;
|
|
42482
42798
|
var SUPERVISION_CONTEXT_TYPE = "pi-herdsman-supervision-context";
|
|
@@ -42491,6 +42807,7 @@ function formatMessageLimit(bytes) {
|
|
|
42491
42807
|
}
|
|
42492
42808
|
var CHIEF_ROLE_CONTRACT = `## Chief role
|
|
42493
42809
|
You are the verified workspace-neutral Chief for this Pi session. Supervise only verified direct-report Managers and eligible unassigned top-level Leads; never bypass a Manager to control assigned Leads or their Agents. Role configuration does not establish authority. Supervision snapshots are non-authoritative coordination data. Do not perform local implementation work or assume this Pi process's working directory is the supervised scope.
|
|
42810
|
+
${AUTHORITY_GUIDANCE}
|
|
42494
42811
|
${INTERNAL_MESSAGE_PROVENANCE_GUIDANCE}
|
|
42495
42812
|
${AGENT_EXECUTION_OWNERSHIP_GUIDANCE}
|
|
42496
42813
|
${AGENT_UNRESOLVED_GUIDANCE}
|
|
@@ -42940,7 +43257,12 @@ If needed, install the Pi integration once:
|
|
|
42940
43257
|
|
|
42941
43258
|
${ask.question}
|
|
42942
43259
|
|
|
42943
|
-
Use reply_agent with agent="${ask.agentLabel}" to answer this question
|
|
43260
|
+
Use reply_agent with agent="${ask.agentLabel}" to answer this question.
|
|
43261
|
+
|
|
43262
|
+
Reply only when you can provide the requested input or an
|
|
43263
|
+
actionable alternative. For an external condition that is not
|
|
43264
|
+
yet satisfied, leave the question pending rather than replying
|
|
43265
|
+
with a promise to provide the answer later.`,
|
|
42944
43266
|
display: true,
|
|
42945
43267
|
details: {
|
|
42946
43268
|
askId: ask.askId,
|
|
@@ -42964,7 +43286,9 @@ Use reply_agent with agent="${ask.agentLabel}" to answer this question.`,
|
|
|
42964
43286
|
customType: "pi-herdsman-agent-owner-message",
|
|
42965
43287
|
content: `Agent ${ownerMessage.agentLabel} notification:
|
|
42966
43288
|
|
|
42967
|
-
${ownerMessage.text}
|
|
43289
|
+
${ownerMessage.text}
|
|
43290
|
+
|
|
43291
|
+
This is a nonblocking notification, not a pending await_owner request. Do not use reply_agent to acknowledge it. Use eligible Agent control only when an actual correction is needed.`,
|
|
42968
43292
|
display: true,
|
|
42969
43293
|
details: {
|
|
42970
43294
|
messageId: ownerMessage.messageId,
|
|
@@ -43534,12 +43858,56 @@ ${summary}`,
|
|
|
43534
43858
|
{ triggerTurn: false }
|
|
43535
43859
|
);
|
|
43536
43860
|
};
|
|
43861
|
+
const reviewPendingRemoval = async (ctx) => {
|
|
43862
|
+
const pending = projectRuntime.listPendingRemovals(ctx);
|
|
43863
|
+
if (!pending.length) {
|
|
43864
|
+
ctx.ui.notify("There are no pending worktree removals.", "info");
|
|
43865
|
+
return;
|
|
43866
|
+
}
|
|
43867
|
+
const selected = await selectMenu(
|
|
43868
|
+
ctx,
|
|
43869
|
+
"Review pending worktree removal",
|
|
43870
|
+
pending.map(({ branch, checkoutPath }) => ({
|
|
43871
|
+
value: branch,
|
|
43872
|
+
label: `${branch} \xB7 ${checkoutPath}`
|
|
43873
|
+
}))
|
|
43874
|
+
);
|
|
43875
|
+
if (!selected) return;
|
|
43876
|
+
const request = pending.find((item) => item.branch === selected);
|
|
43877
|
+
if (!request) throw new Error("Pending removal is unavailable");
|
|
43878
|
+
const action = await selectMenu(ctx, `Pending removal \xB7 ${selected}`, [
|
|
43879
|
+
{ value: "approve", label: "Approve removal\u2026" },
|
|
43880
|
+
{ value: "dismiss", label: "Dismiss request" }
|
|
43881
|
+
]);
|
|
43882
|
+
if (!action) return;
|
|
43883
|
+
if (action === "dismiss") {
|
|
43884
|
+
if (!projectRuntime.cancelPendingRemoval(request, ctx))
|
|
43885
|
+
throw new Error("Pending removal changed; review the new request");
|
|
43886
|
+
ctx.ui.notify(
|
|
43887
|
+
`Pending removal of ${request.branch} dismissed.`,
|
|
43888
|
+
"info"
|
|
43889
|
+
);
|
|
43890
|
+
return;
|
|
43891
|
+
}
|
|
43892
|
+
const result = await projectRuntime.approvePendingRemoval(request, ctx);
|
|
43893
|
+
ctx.ui.notify(
|
|
43894
|
+
result.content[0]?.text ?? "Removal finished.",
|
|
43895
|
+
result.details.ok || "cancelled" in result.details && result.details.cancelled ? "info" : "warning"
|
|
43896
|
+
);
|
|
43897
|
+
return;
|
|
43898
|
+
};
|
|
43537
43899
|
let leadCommandRuntime;
|
|
43538
43900
|
const leadCommandHost = {
|
|
43539
43901
|
pi,
|
|
43902
|
+
reviewPendingRemoval,
|
|
43540
43903
|
persistStopClosures: (ctx, closures) => projectRuntime.persistStopClosures(ctx, closures),
|
|
43541
43904
|
getRemovalPreauthorization: (ctx) => projectRuntime.getRemovalPreauthorization(ctx),
|
|
43542
|
-
setRemovalPreauthorization: (enabled, ctx) => projectRuntime.setRemovalPreauthorization(
|
|
43905
|
+
setRemovalPreauthorization: (enabled, ctx, expectedManager) => projectRuntime.setRemovalPreauthorization(
|
|
43906
|
+
enabled,
|
|
43907
|
+
ctx,
|
|
43908
|
+
expectedManager
|
|
43909
|
+
),
|
|
43910
|
+
setRepositoryMergeOverride: (...args) => projectRuntime.setRepositoryMergeOverride(...args),
|
|
43543
43911
|
runHerdr,
|
|
43544
43912
|
presentStopSummary,
|
|
43545
43913
|
version: HERDSMAN_VERSION,
|
|
@@ -43582,8 +43950,8 @@ ${summary}`,
|
|
|
43582
43950
|
input: (ctx, label) => ctx.ui.input(label),
|
|
43583
43951
|
updateSpawnPlacement: (placement) => updateConfig("spawnPlacement", placement),
|
|
43584
43952
|
updateMessageLimit: (key, value2) => updateConfig(key, value2),
|
|
43585
|
-
updateConfig: (key, value2) => {
|
|
43586
|
-
updateConfig(key, value2);
|
|
43953
|
+
updateConfig: (key, value2, expectedManagerMergeEnabled) => {
|
|
43954
|
+
updateConfig(key, value2, expectedManagerMergeEnabled);
|
|
43587
43955
|
if (key === "statusWidgetMaxRows") {
|
|
43588
43956
|
const rows = value2 === void 0 ? DEFAULT_STATUS_WIDGET_MAX_ROWS : value2;
|
|
43589
43957
|
leadRuntimes.statusRuntime?.setStatusWidgetMaxRows(rows);
|
|
@@ -43610,7 +43978,7 @@ ${summary}`,
|
|
|
43610
43978
|
"leave",
|
|
43611
43979
|
"remove",
|
|
43612
43980
|
"forget",
|
|
43613
|
-
"
|
|
43981
|
+
"removal-confirmation"
|
|
43614
43982
|
];
|
|
43615
43983
|
const input = prefix.trimStart();
|
|
43616
43984
|
const [command, branchPrefix] = input.split(/\s+/u);
|
|
@@ -43619,9 +43987,9 @@ ${summary}`,
|
|
|
43619
43987
|
value: value2,
|
|
43620
43988
|
label: value2
|
|
43621
43989
|
}));
|
|
43622
|
-
if (command === "
|
|
43623
|
-
return input.trim().split(/\s+/u).length
|
|
43624
|
-
value: `
|
|
43990
|
+
if (command === "removal-confirmation")
|
|
43991
|
+
return input.includes(" ") && input.trim().split(/\s+/u).length <= 2 ? ["required", "skip"].filter((value2) => value2.startsWith(branchPrefix ?? "")).map((value2) => ({
|
|
43992
|
+
value: `removal-confirmation ${value2}`,
|
|
43625
43993
|
label: value2
|
|
43626
43994
|
})) : null;
|
|
43627
43995
|
if (command !== "remove" && command !== "forget")
|
|
@@ -43644,84 +44012,36 @@ ${summary}`,
|
|
|
43644
44012
|
},
|
|
43645
44013
|
handler: async (rawArgs, ctx) => {
|
|
43646
44014
|
const args = rawArgs.trim().split(/\s+/u).filter(Boolean);
|
|
43647
|
-
if (args[0] === "
|
|
44015
|
+
if (args[0] === "removal-confirmation") {
|
|
43648
44016
|
if (args.length === 1) {
|
|
43649
44017
|
const policy = await projectRuntime.getRemovalPreauthorization(ctx);
|
|
43650
44018
|
ctx.ui.notify(
|
|
43651
|
-
`Worktree removal
|
|
44019
|
+
`Worktree removal approval: ${policy.enabled ? "Skipped" : "Required"} for ${policy.repoKey}.`,
|
|
43652
44020
|
"info"
|
|
43653
44021
|
);
|
|
43654
44022
|
return;
|
|
43655
44023
|
}
|
|
43656
|
-
if (args.length !== 2 || !["
|
|
44024
|
+
if (args.length !== 2 || !["required", "skip"].includes(args[1])) {
|
|
43657
44025
|
ctx.ui.notify(
|
|
43658
|
-
"Usage: /manager
|
|
44026
|
+
"Usage: /manager removal-confirmation [required|skip]",
|
|
43659
44027
|
"error"
|
|
43660
44028
|
);
|
|
43661
44029
|
return;
|
|
43662
44030
|
}
|
|
43663
|
-
const enabled = args[1] === "
|
|
44031
|
+
const enabled = args[1] === "skip";
|
|
43664
44032
|
const stored = await projectRuntime.setRemovalPreauthorization(
|
|
43665
44033
|
enabled,
|
|
43666
44034
|
ctx
|
|
43667
44035
|
);
|
|
43668
44036
|
ctx.ui.notify(
|
|
43669
|
-
`
|
|
44037
|
+
stored ? `Worktree removal approval: ${enabled ? "Skipped" : "Required"}.` : "Worktree removal approval setting unchanged.",
|
|
43670
44038
|
stored ? "info" : "warning"
|
|
43671
44039
|
);
|
|
43672
44040
|
return;
|
|
43673
44041
|
}
|
|
43674
44042
|
if (args[0] === "remove") {
|
|
43675
44043
|
if (args.length === 1) {
|
|
43676
|
-
|
|
43677
|
-
if (!pending.length) {
|
|
43678
|
-
ctx.ui.notify(
|
|
43679
|
-
"There are no pending worktree removals.",
|
|
43680
|
-
"info"
|
|
43681
|
-
);
|
|
43682
|
-
return;
|
|
43683
|
-
}
|
|
43684
|
-
const selected = await selectMenu(
|
|
43685
|
-
ctx,
|
|
43686
|
-
"Review pending worktree removal",
|
|
43687
|
-
pending.map(({ branch, checkoutPath }) => ({
|
|
43688
|
-
value: branch,
|
|
43689
|
-
label: `${branch} \xB7 ${checkoutPath}`
|
|
43690
|
-
}))
|
|
43691
|
-
);
|
|
43692
|
-
if (!selected) return;
|
|
43693
|
-
const request = pending.find(
|
|
43694
|
-
(item) => item.branch === selected
|
|
43695
|
-
);
|
|
43696
|
-
if (!request) throw new Error("Pending removal is unavailable");
|
|
43697
|
-
const action = await selectMenu(
|
|
43698
|
-
ctx,
|
|
43699
|
-
`Pending removal \xB7 ${selected}`,
|
|
43700
|
-
[
|
|
43701
|
-
{ value: "approve", label: "Approve removal\u2026" },
|
|
43702
|
-
{ value: "dismiss", label: "Dismiss request" }
|
|
43703
|
-
]
|
|
43704
|
-
);
|
|
43705
|
-
if (!action) return;
|
|
43706
|
-
if (action === "dismiss") {
|
|
43707
|
-
if (!projectRuntime.cancelPendingRemoval(request, ctx))
|
|
43708
|
-
throw new Error(
|
|
43709
|
-
"Pending removal changed; review the new request"
|
|
43710
|
-
);
|
|
43711
|
-
ctx.ui.notify(
|
|
43712
|
-
`Pending removal of ${request.branch} dismissed.`,
|
|
43713
|
-
"info"
|
|
43714
|
-
);
|
|
43715
|
-
return;
|
|
43716
|
-
}
|
|
43717
|
-
const result2 = await projectRuntime.approvePendingRemoval(
|
|
43718
|
-
request,
|
|
43719
|
-
ctx
|
|
43720
|
-
);
|
|
43721
|
-
ctx.ui.notify(
|
|
43722
|
-
result2.content[0]?.text ?? "Removal finished.",
|
|
43723
|
-
result2.details.ok || "cancelled" in result2.details && result2.details.cancelled ? "info" : "warning"
|
|
43724
|
-
);
|
|
44044
|
+
await reviewPendingRemoval(ctx);
|
|
43725
44045
|
return;
|
|
43726
44046
|
}
|
|
43727
44047
|
if (args.length !== 2) {
|