pi-crew 0.9.68 → 0.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +222 -0
- package/NOTICE.md +21 -0
- package/README.md +44 -2
- package/agents/analyst.md +1 -1
- package/agents/cold-verifier.md +3 -1
- package/agents/critic.md +1 -1
- package/agents/executor.md +1 -1
- package/agents/explorer.md +1 -1
- package/agents/planner.md +1 -1
- package/agents/reviewer.md +1 -1
- package/agents/security-reviewer.md +1 -1
- package/agents/test-engineer.md +1 -1
- package/agents/verifier.md +1 -1
- package/agents/writer.md +1 -1
- package/dist/index.mjs +68113 -60774
- package/docs/README.md +2 -0
- package/docs/actions-reference.md +31 -0
- package/docs/commands-reference.md +17 -6
- package/docs/resource-formats.md +13 -0
- package/package.json +4 -2
- package/schema.json +503 -91
- package/scripts/resource-sampler.mjs +36 -2
- package/skills/requirements-to-task-packet/SKILL.md +26 -0
- package/skills/widget-rendering/SKILL.md +7 -7
- package/src/agents/agent-config.ts +2 -1
- package/src/agents/discover-agents.ts +23 -14
- package/src/config/config-merge.ts +183 -0
- package/src/config/config-validation.ts +687 -0
- package/src/config/config.ts +22 -864
- package/src/config/defaults.ts +43 -2
- package/src/config/drift-detector.ts +1 -1
- package/src/config/env-vars.ts +691 -0
- package/src/config/role-tools.ts +11 -9
- package/src/config/sanitize-project-config.ts +172 -0
- package/src/config/types.ts +49 -1
- package/src/extension/async-notifier.ts +25 -2
- package/src/extension/crew-cleanup.ts +13 -0
- package/src/extension/crew-vibes/config.ts +2 -1
- package/src/extension/crew-vibes/footer.ts +19 -0
- package/src/extension/crew-vibes/index.ts +11 -1
- package/src/extension/plan-orchestrate.ts +132 -0
- package/src/extension/register.ts +8 -0
- package/src/extension/registration/command-registration.ts +1 -0
- package/src/extension/registration/commands/dashboard.ts +158 -0
- package/src/extension/registration/commands/index.ts +35 -0
- package/src/extension/registration/commands/manage.ts +303 -0
- package/src/extension/registration/commands/run.ts +228 -0
- package/src/extension/registration/commands/shared.ts +639 -0
- package/src/extension/registration/commands/status.ts +60 -0
- package/src/extension/registration/commands.ts +13 -1224
- package/src/extension/registration/foreground-run-controller.ts +10 -2
- package/src/extension/registration/lifecycle-handlers.ts +178 -17
- package/src/extension/registration/runtime-cleanup.ts +23 -5
- package/src/extension/registration/subagent-tools.ts +218 -9
- package/src/extension/registration/team-tool.ts +5 -1
- package/src/extension/registration/ui.ts +5 -4
- package/src/extension/rpc-hmac.ts +5 -3
- package/src/extension/team-tool/api/heartbeat.ts +47 -10
- package/src/extension/team-tool/api/plan-approval.ts +9 -0
- package/src/extension/team-tool/api/task-claims.ts +109 -40
- package/src/extension/team-tool/cancel.ts +84 -50
- package/src/extension/team-tool/dispatch/index.ts +1 -0
- package/src/extension/team-tool/dispatch/run.ts +4 -1
- package/src/extension/team-tool/doctor.ts +103 -1
- package/src/extension/team-tool/orchestrate.ts +66 -1
- package/src/extension/team-tool/plans.ts +192 -0
- package/src/extension/team-tool/respond.ts +197 -65
- package/src/extension/team-tool/run-deadline.ts +35 -3
- package/src/extension/team-tool/run-intent.ts +63 -0
- package/src/extension/team-tool/run.ts +74 -20
- package/src/extension/team-tool/status.ts +84 -26
- package/src/extension/team-tool.ts +11 -2
- package/src/hooks/registry.ts +1 -6
- package/src/i18n.ts +9 -0
- package/src/prompt/prompt-runtime.ts +521 -2
- package/src/prompt/worker-events-channel.ts +173 -0
- package/src/runtime/README.md +8 -8
- package/src/runtime/async-runner.ts +7 -3
- package/src/runtime/background-runner.ts +42 -14
- package/src/runtime/broker/broker-issuer.ts +9 -2
- package/src/runtime/broker/crew-broker-tokens.ts +43 -6
- package/src/runtime/broker/crew-broker.ts +838 -10
- package/src/runtime/broker/wait-status-cache.ts +157 -0
- package/src/runtime/budget-enforcement.ts +281 -0
- package/src/runtime/child-pi/child-pi-constants.ts +8 -0
- package/src/runtime/child-pi/child-pi-spawn.ts +60 -14
- package/src/runtime/child-pi/child-pi-streams.ts +21 -1
- package/src/runtime/child-pi/child-pi-timers.ts +324 -0
- package/src/runtime/child-pi/child-pi.ts +97 -201
- package/src/runtime/child-pi/mock-fixtures.ts +16 -2
- package/src/runtime/crew-agent-records.ts +259 -14
- package/src/runtime/delegate-spawn.ts +148 -0
- package/src/runtime/detached-run-results.ts +90 -0
- package/src/runtime/deterministic-ast.ts +2 -1
- package/src/runtime/dispatch-batch.ts +945 -0
- package/src/runtime/finalize-run.ts +557 -0
- package/src/runtime/goal-workflow/adaptive-plan.ts +116 -15
- package/src/runtime/goal-workflow/dynamic-workflow-runner.ts +8 -3
- package/src/runtime/goal-workflow/goal-state-store.ts +1 -1
- package/src/runtime/group-join.ts +11 -125
- package/src/runtime/live-session/live-session-runtime.ts +26 -1
- package/src/runtime/merge-gate.ts +32 -10
- package/src/runtime/merge-loop.ts +130 -0
- package/src/runtime/model/model-budget-summary.ts +53 -0
- package/src/runtime/model/model-fallback.ts +36 -2
- package/src/runtime/model/pi-args.ts +10 -0
- package/src/runtime/model/provider-extensions.ts +10 -0
- package/src/runtime/orphan-worker-registry.ts +1 -1
- package/src/runtime/output/output-validator.ts +45 -0
- package/src/runtime/parent-guard.ts +3 -1
- package/src/runtime/peer-dep.ts +2 -1
- package/src/runtime/per-write-validator.ts +0 -5
- package/src/runtime/pi-spawn.ts +61 -15
- package/src/runtime/plan-approval.ts +125 -0
- package/src/runtime/plan-replan.ts +151 -0
- package/src/runtime/process-status.ts +16 -1
- package/src/runtime/recovery/checkpoint.ts +0 -18
- package/src/runtime/recovery/crash-recovery.ts +111 -46
- package/src/runtime/run-tracker.ts +77 -10
- package/src/runtime/scheduler-context.ts +98 -0
- package/src/runtime/scheduling/coalesce-tasks.ts +5 -0
- package/src/runtime/scheduling/global-worker-cap.ts +2 -1
- package/src/runtime/scheduling/nested-slots.ts +70 -0
- package/src/runtime/scheduling/run-coalesced-task-group.ts +64 -13
- package/src/runtime/scheduling/task-graph-scheduler.ts +0 -10
- package/src/runtime/settings-store.ts +219 -0
- package/src/runtime/spawn-policy.ts +217 -0
- package/src/runtime/stale-reconciler.ts +87 -6
- package/src/runtime/subagent-manager.ts +25 -1
- package/src/runtime/task-output-context.ts +230 -9
- package/src/runtime/task-packet.ts +23 -1
- package/src/runtime/task-runner/child-executor.ts +106 -7
- package/src/runtime/task-runner/post-execution.ts +125 -1
- package/src/runtime/task-runner/pre-execution.ts +39 -1
- package/src/runtime/task-runner/prompt-builder.ts +51 -1
- package/src/runtime/task-runner/retrieval-orchestrator.ts +72 -18
- package/src/runtime/task-runner/spec-evidence.ts +403 -0
- package/src/runtime/task-runner/state-helpers.ts +26 -24
- package/src/runtime/task-runner.ts +11 -0
- package/src/runtime/team-runner.ts +132 -1673
- package/src/runtime/verification/spec-sandbox.ts +255 -0
- package/src/runtime/verification/verification-gates.ts +3 -2
- package/src/runtime/verification/verification-worktree.ts +2 -1
- package/src/runtime/workflow-phase-advance.ts +100 -0
- package/src/runtime/workspace-tree.ts +9 -0
- package/src/schema/config-schema.ts +66 -26
- package/src/schema/sensitive-config-paths.ts +64 -0
- package/src/schema/team-tool-schema.ts +13 -3
- package/src/state/README.md +4 -10
- package/src/state/atomic-write.ts +20 -3
- package/src/state/contracts.ts +38 -0
- package/src/state/coordination/mailbox.ts +12 -2
- package/src/state/event-log/cursor.ts +223 -0
- package/src/state/event-log/event-log-rotation.ts +12 -4
- package/src/state/event-log/event-log.ts +152 -369
- package/src/state/event-log/sequence-cache.ts +373 -0
- package/src/state/event-log/worker-atomic-writer.ts +2 -1
- package/src/state/stores/active-run-registry.ts +3 -2
- package/src/state/stores/manifest-io.ts +237 -0
- package/src/state/stores/ownership-map.ts +162 -0
- package/src/state/stores/plan-store.ts +241 -0
- package/src/state/stores/run-cache.ts +0 -90
- package/src/state/stores/spec-store.ts +189 -0
- package/src/state/stores/state-store.ts +139 -232
- package/src/state/types.ts +199 -0
- package/src/ui/dashboard-panes/plan-pane.ts +136 -0
- package/src/ui/dashboard-panes/progress-pane.ts +6 -0
- package/src/ui/dashboard-panes/transcript-pane.ts +31 -0
- package/src/ui/dock-footer.ts +49 -0
- package/src/ui/heartbeat-aggregator.ts +9 -1
- package/src/ui/inline-panel/agent-pane.ts +375 -0
- package/src/ui/inline-panel/agent-transcript.ts +338 -0
- package/src/ui/inline-panel/agent-view-overlay.ts +225 -0
- package/src/ui/inline-panel/crew-editor.ts +192 -0
- package/src/ui/inline-panel/index.ts +290 -0
- package/src/ui/inline-panel/panel-rows.ts +37 -0
- package/src/ui/inline-panel/panel-selection.ts +157 -0
- package/src/ui/inline-panel/panel-store.ts +111 -0
- package/src/ui/inline-panel/view-session-store.ts +36 -0
- package/src/ui/keybinding-map.ts +54 -13
- package/src/ui/pi-ui-compat.ts +9 -0
- package/src/ui/powerbar-publisher.ts +52 -1
- package/src/ui/run-dashboard.ts +31 -5
- package/src/ui/run-snapshot-cache.ts +57 -30
- package/src/ui/snapshot-types.ts +6 -1
- package/src/ui/widget/index.ts +176 -22
- package/src/ui/widget/task-list.ts +198 -0
- package/src/ui/widget/widget-formatters.ts +240 -4
- package/src/ui/widget/widget-renderer.ts +243 -38
- package/src/ui/widget/widget-types.ts +11 -0
- package/src/utils/child-process-shield.ts +106 -0
- package/src/utils/file-coalescer.ts +0 -4
- package/src/utils/fs-errno.ts +66 -0
- package/src/utils/fs-watch.ts +1 -1
- package/src/utils/internal-error.ts +3 -1
- package/src/utils/paths.ts +11 -3
- package/src/utils/redaction.ts +7 -0
- package/src/utils/safe-abort.ts +45 -0
- package/src/utils/task-name-generator.ts +1 -8
- package/src/workflows/discover-workflows.ts +20 -2
- package/src/workflows/validate-workflow.ts +7 -1
- package/src/workflows/workflow-config.ts +17 -0
- package/src/workflows/workflow-serializer.ts +3 -0
- package/src/worktree/worktree-manager.ts +22 -0
- package/workflows/default.workflow.md +36 -26
- package/workflows/strict-fast-fix.workflow.md +26 -0
- package/src/agents/agent-search.ts +0 -98
- package/src/benchmark/benchmark-runner.ts +0 -313
- package/src/benchmark/feedback-loop.ts +0 -73
- package/src/config/resilient-parser.ts +0 -117
- package/src/extension/crew-vibes/cat-frames.ts +0 -18
- package/src/extension/result-watcher.ts +0 -139
- package/src/observability/exporters/prometheus-exporter.ts +0 -54
- package/src/observability/metric-retention.ts +0 -64
- package/src/runtime/compaction/compaction-summary.ts +0 -278
- package/src/runtime/errors/crew-errors.ts +0 -162
- package/src/runtime/live-session/intercom-bridge.ts +0 -187
- package/src/runtime/loop-gates.ts +0 -128
- package/src/runtime/metric-parser.ts +0 -36
- package/src/runtime/output/stream-preview.ts +0 -184
- package/src/runtime/output/tool-progress.ts +0 -278
- package/src/runtime/phase-tracker.ts +0 -385
- package/src/runtime/pipeline-runner.ts +0 -523
- package/src/runtime/process/process-lifecycle.ts +0 -491
- package/src/runtime/recovery/retry-runner.ts +0 -330
- package/src/runtime/run-drift.ts +0 -219
- package/src/runtime/task-quality.ts +0 -199
- package/src/runtime/task-runner/run-projection.ts +0 -128
- package/src/runtime/verification/post-checks.ts +0 -142
- package/src/state/coordination/schedule.ts +0 -166
- package/src/state/event-log/jsonl-writer.ts +0 -115
- package/src/state/hook-instinct-bridge.ts +0 -94
- package/src/state/hook-integrations.ts +0 -51
- package/src/state/session-state-map.ts +0 -51
- package/src/state/stores/blob-store.ts +0 -308
- package/src/state/stores/instinct-store.ts +0 -275
- package/src/state/stores/observation-store.ts +0 -176
- package/src/state/tiered-eval.ts +0 -480
- package/src/state/types-eval.ts +0 -58
- package/src/tools/safe-bash-extension.ts +0 -54
- package/src/tools/safe-bash.ts +0 -505
- package/src/ui/agent-management-overlay.ts +0 -160
- package/src/ui/crew-footer.ts +0 -102
- package/src/ui/crew-select-list.ts +0 -114
- package/src/ui/dashboard-panes/capability-pane.ts +0 -77
- package/src/ui/transcript-entries.ts +0 -256
- package/src/utils/conflict-detect.ts +0 -721
- package/src/utils/fingerprint.ts +0 -180
- package/src/utils/gh-protocol.ts +0 -556
- package/src/utils/project-detector.ts +0 -160
- package/src/utils/sse-parser.ts +0 -131
- package/src/workflows/cost-estimator.ts +0 -34
- package/src/workflows/intermediate-store.ts +0 -166
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import type { ExtensionAPI, ExtensionCommandContext, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { suggestRunIds, suggestTeams } from "../../command-completions.ts";
|
|
3
|
+
import { commandText, notifyCommandResult, parseRunArgs, parseScalar } from "../command-utils.ts";
|
|
4
|
+
import type { RegisterTeamCommandsDeps } from "./shared.ts";
|
|
5
|
+
import { handleTeamTool, teamCommandContext } from "./shared.ts";
|
|
6
|
+
|
|
7
|
+
export function registerRunCommands(pi: ExtensionAPI, deps: RegisterTeamCommandsDeps): void {
|
|
8
|
+
pi.registerCommand("team-run", {
|
|
9
|
+
description: "Manually start a pi-crew run (agent may also use the team tool autonomously)",
|
|
10
|
+
// Round 13 UX: suggest team names for Tab-completion of the first positional arg.
|
|
11
|
+
getArgumentCompletions: (argumentPrefix: string) => suggestTeams(argumentPrefix),
|
|
12
|
+
handler: async (args: string, ctx: ExtensionCommandContext) => {
|
|
13
|
+
const result = await handleTeamTool(parseRunArgs(args), {
|
|
14
|
+
...teamCommandContext(ctx),
|
|
15
|
+
metricRegistry: deps.getMetricRegistry?.(),
|
|
16
|
+
startForegroundRun: (runner, runId) => deps.startForegroundRun(ctx as ExtensionContext, runner, runId),
|
|
17
|
+
abortForegroundRun: deps.abortForegroundRun,
|
|
18
|
+
onRunStarted: undefined,
|
|
19
|
+
});
|
|
20
|
+
// A foreground run can span a session switch (e.g. the user opens
|
|
21
|
+
// an agent view mid-run and the run finishes there). The captured
|
|
22
|
+
// ctx is stale after the switch: ANY access to it (even reading a
|
|
23
|
+
// field) throws pi's "This extension ctx is stale ..." error, which
|
|
24
|
+
// pi then prints into whichever session is active. Probe
|
|
25
|
+
// defensively and skip the notification when the session moved on
|
|
26
|
+
// (the result is still visible via /team-status).
|
|
27
|
+
try {
|
|
28
|
+
const capturedFile = ctx.sessionManager?.getSessionFile?.();
|
|
29
|
+
const currentFile = deps.getCurrentSessionFile?.();
|
|
30
|
+
if (capturedFile && currentFile && capturedFile !== currentFile) return;
|
|
31
|
+
await notifyCommandResult(ctx, commandText(result));
|
|
32
|
+
} catch {
|
|
33
|
+
// Stale ctx during the probe or notify — nothing to do here.
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
for (const [name, action, description] of [
|
|
39
|
+
["team-resume", "resume", "Resume a pi-crew run by re-queueing failed/cancelled/skipped/running tasks"],
|
|
40
|
+
["team-export", "export", "Export a pi-crew run bundle to artifacts/export"],
|
|
41
|
+
["team-cancel", "cancel", "Cancel a pi-crew run"],
|
|
42
|
+
] as const) {
|
|
43
|
+
pi.registerCommand(name, {
|
|
44
|
+
description,
|
|
45
|
+
// Round 13 UX: suggest recent run IDs for Tab-completion.
|
|
46
|
+
getArgumentCompletions: (argumentPrefix: string) => suggestRunIds(argumentPrefix),
|
|
47
|
+
handler: async (args: string, ctx: ExtensionCommandContext) => {
|
|
48
|
+
const runId = args.trim() || undefined;
|
|
49
|
+
const result = await handleTeamTool(
|
|
50
|
+
{ action, runId },
|
|
51
|
+
{
|
|
52
|
+
...teamCommandContext(ctx),
|
|
53
|
+
getRunSnapshotCache: deps.getRunSnapshotCache,
|
|
54
|
+
},
|
|
55
|
+
);
|
|
56
|
+
await notifyCommandResult(ctx, commandText(result));
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
pi.registerCommand("team-invalidate", {
|
|
62
|
+
description: "Invalidate the snapshot cache for a run so the UI refreshes immediately: <runId>",
|
|
63
|
+
getArgumentCompletions: (argumentPrefix: string) => suggestRunIds(argumentPrefix),
|
|
64
|
+
handler: async (args: string, ctx: ExtensionCommandContext) => {
|
|
65
|
+
const runId = args.trim() || undefined;
|
|
66
|
+
if (!runId) {
|
|
67
|
+
await notifyCommandResult(ctx, "Usage: /team-invalidate <runId>");
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const result = await handleTeamTool(
|
|
71
|
+
{ action: "invalidate", runId },
|
|
72
|
+
{
|
|
73
|
+
...teamCommandContext(ctx),
|
|
74
|
+
getRunSnapshotCache: deps.getRunSnapshotCache,
|
|
75
|
+
},
|
|
76
|
+
);
|
|
77
|
+
await notifyCommandResult(ctx, commandText(result));
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
pi.registerCommand("team-retry", {
|
|
82
|
+
description: "Retry failed/cancelled pi-crew tasks: <runId> [taskId]",
|
|
83
|
+
getArgumentCompletions: (argumentPrefix: string) => suggestRunIds(argumentPrefix),
|
|
84
|
+
handler: async (args: string, ctx: ExtensionCommandContext) => {
|
|
85
|
+
const tokens = args.trim().split(/\s+/).filter(Boolean);
|
|
86
|
+
const runId = tokens.shift();
|
|
87
|
+
const taskId = tokens.shift();
|
|
88
|
+
if (!runId) {
|
|
89
|
+
await notifyCommandResult(ctx, "Usage: /team-retry <runId> [taskId]");
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const retryResult = await handleTeamTool(
|
|
93
|
+
{ action: "retry", runId, taskId },
|
|
94
|
+
{
|
|
95
|
+
...teamCommandContext(ctx),
|
|
96
|
+
getRunSnapshotCache: deps.getRunSnapshotCache,
|
|
97
|
+
},
|
|
98
|
+
);
|
|
99
|
+
await notifyCommandResult(ctx, commandText(retryResult));
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
pi.registerCommand("team-respond", {
|
|
104
|
+
description: "Respond to a waiting pi-crew task: <runId> <taskId|--all> <message>",
|
|
105
|
+
getArgumentCompletions: (argumentPrefix: string) => suggestRunIds(argumentPrefix),
|
|
106
|
+
handler: async (args: string, ctx: ExtensionCommandContext) => {
|
|
107
|
+
const tokens = args.trim().split(/\s+/).filter(Boolean);
|
|
108
|
+
const runId = tokens.shift();
|
|
109
|
+
const taskToken = tokens[0] === "--all" ? tokens.shift() : tokens.shift();
|
|
110
|
+
const taskId = taskToken === "--all" ? undefined : taskToken;
|
|
111
|
+
const message = tokens.join(" ") || undefined;
|
|
112
|
+
const result = await handleTeamTool({ action: "respond", runId, taskId, message }, teamCommandContext(ctx));
|
|
113
|
+
await notifyCommandResult(ctx, commandText(result));
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
pi.registerCommand("team-follow-up", {
|
|
118
|
+
description: "Send a follow-up prompt to a pi-crew task: <runId> <taskId> <prompt>",
|
|
119
|
+
getArgumentCompletions: (argumentPrefix: string) => suggestRunIds(argumentPrefix),
|
|
120
|
+
handler: async (args: string, ctx: ExtensionCommandContext) => {
|
|
121
|
+
const tokens = args.trim().split(/\s+/).filter(Boolean);
|
|
122
|
+
const runId = tokens.shift();
|
|
123
|
+
const taskId = tokens.shift();
|
|
124
|
+
const prompt = tokens.join(" ") || undefined;
|
|
125
|
+
if (!runId || !taskId || !prompt) {
|
|
126
|
+
await notifyCommandResult(
|
|
127
|
+
ctx,
|
|
128
|
+
"Usage: /team-follow-up <runId> <taskId> <prompt>. Use /team-respond for waiting-task replies.",
|
|
129
|
+
);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
const result = await handleTeamTool(
|
|
133
|
+
{
|
|
134
|
+
action: "api",
|
|
135
|
+
runId,
|
|
136
|
+
config: { operation: "follow-up-agent", taskId, prompt },
|
|
137
|
+
},
|
|
138
|
+
teamCommandContext(ctx),
|
|
139
|
+
);
|
|
140
|
+
await notifyCommandResult(ctx, commandText(result));
|
|
141
|
+
},
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
pi.registerCommand("team-api", {
|
|
145
|
+
description: "Run safe pi-crew API interop operations: <runId> <operation> [key=value]",
|
|
146
|
+
getArgumentCompletions: (argumentPrefix: string) => suggestRunIds(argumentPrefix),
|
|
147
|
+
handler: async (args: string, ctx: ExtensionCommandContext) => {
|
|
148
|
+
const tokens = args.trim().split(/\s+/).filter(Boolean);
|
|
149
|
+
const positional = tokens.filter((token) => !token.includes("=") && !token.startsWith("--"));
|
|
150
|
+
const runIdLessOperations = new Set(["metrics-snapshot"]);
|
|
151
|
+
const first = positional[0];
|
|
152
|
+
const runId = first && runIdLessOperations.has(first) ? undefined : first;
|
|
153
|
+
const operation = runId ? (positional[1] ?? "read-manifest") : (first ?? "read-manifest");
|
|
154
|
+
const config: Record<string, unknown> = { operation };
|
|
155
|
+
for (const token of tokens.filter((item) => item.includes("="))) {
|
|
156
|
+
const [key, ...rest] = token.split("=");
|
|
157
|
+
if (key) config[key] = parseScalar(rest.join("="));
|
|
158
|
+
}
|
|
159
|
+
const result = await handleTeamTool({ action: "api", runId, config }, teamCommandContext(ctx));
|
|
160
|
+
await notifyCommandResult(ctx, commandText(result));
|
|
161
|
+
},
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
pi.registerCommand("team-goal", {
|
|
165
|
+
description:
|
|
166
|
+
"Autonomous goal loop control: [start|status|pause|resume|stop|step|clear] [goalId] [--objective=...] [--evaluatorModel=...] [--maxTurns=N]",
|
|
167
|
+
handler: async (args: string, ctx: ExtensionCommandContext) => {
|
|
168
|
+
const tokens = args.trim().split(/\s+/).filter(Boolean);
|
|
169
|
+
const knownSubs = new Set(["start", "status", "pause", "resume", "stop", "step", "clear", "cancel", "reset"]);
|
|
170
|
+
const subAction = tokens[0] && knownSubs.has(tokens[0]) ? tokens[0] : "status";
|
|
171
|
+
const positional = tokens.filter((token) => !token.includes("=") && !token.startsWith("--") && token !== subAction);
|
|
172
|
+
const goalId = positional[0];
|
|
173
|
+
const config: Record<string, unknown> = { subAction };
|
|
174
|
+
if (goalId) config.goalId = goalId;
|
|
175
|
+
for (const token of tokens.filter((item) => item.includes("="))) {
|
|
176
|
+
const [key, ...rest] = token.split("=");
|
|
177
|
+
if (key) config[key.replace(/^--/, "")] = parseScalar(rest.join("="));
|
|
178
|
+
}
|
|
179
|
+
const result = await handleTeamTool({ action: "goal", config }, teamCommandContext(ctx));
|
|
180
|
+
await notifyCommandResult(ctx, commandText(result));
|
|
181
|
+
},
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
pi.registerCommand("workflows", {
|
|
185
|
+
description: "List all workflows (static + dynamic .dwf.ts)",
|
|
186
|
+
handler: async (_args: string, ctx: ExtensionCommandContext) => {
|
|
187
|
+
const result = await handleTeamTool({ action: "workflow-list" }, teamCommandContext(ctx));
|
|
188
|
+
await notifyCommandResult(ctx, commandText(result));
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
pi.registerCommand("team-metrics", {
|
|
193
|
+
description: "Show pi-crew metrics snapshot: [filter]",
|
|
194
|
+
handler: async (args: string, ctx: ExtensionCommandContext) => {
|
|
195
|
+
const filter = args.trim() || undefined;
|
|
196
|
+
const result = await handleTeamTool(
|
|
197
|
+
{
|
|
198
|
+
action: "api",
|
|
199
|
+
config: { operation: "metrics-snapshot", filter },
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
...teamCommandContext(ctx),
|
|
203
|
+
metricRegistry: deps.getMetricRegistry?.(),
|
|
204
|
+
},
|
|
205
|
+
);
|
|
206
|
+
await notifyCommandResult(ctx, commandText(result));
|
|
207
|
+
},
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
pi.registerCommand("team-imports", {
|
|
211
|
+
description: "List imported pi-crew run bundles",
|
|
212
|
+
handler: async (_args: string, ctx: ExtensionCommandContext) => {
|
|
213
|
+
const result = await handleTeamTool({ action: "imports" }, teamCommandContext(ctx));
|
|
214
|
+
await notifyCommandResult(ctx, commandText(result));
|
|
215
|
+
},
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
pi.registerCommand("team-import", {
|
|
219
|
+
description: "Import a pi-crew run-export.json bundle into local imports",
|
|
220
|
+
handler: async (args: string, ctx: ExtensionCommandContext) => {
|
|
221
|
+
const tokens = args.trim().split(/\s+/).filter(Boolean);
|
|
222
|
+
const pathArg = tokens.find((token) => !token.startsWith("--"));
|
|
223
|
+
const scope = tokens.includes("--user") ? "user" : "project";
|
|
224
|
+
const result = await handleTeamTool({ action: "import", config: { path: pathArg, scope } }, teamCommandContext(ctx));
|
|
225
|
+
await notifyCommandResult(ctx, commandText(result));
|
|
226
|
+
},
|
|
227
|
+
});
|
|
228
|
+
}
|