opencode-swarm 7.66.2 → 7.67.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/README.md +4 -0
- package/dist/agents/index.d.ts +14 -1
- package/dist/background/event-bus.d.ts +1 -1
- package/dist/background/index.d.ts +2 -0
- package/dist/background/pr-event-subscribers.d.ts +46 -0
- package/dist/background/pr-monitor-worker.d.ts +154 -0
- package/dist/background/pr-subscriptions.d.ts +115 -0
- package/dist/cli/index.js +893 -472
- package/dist/commands/pr-monitor-status.d.ts +36 -0
- package/dist/commands/pr-subscribe.d.ts +33 -0
- package/dist/commands/pr-unsubscribe.d.ts +32 -0
- package/dist/commands/registry.d.ts +21 -0
- package/dist/config/schema.d.ts +37 -0
- package/dist/git/pr.d.ts +80 -0
- package/dist/hooks/guardrails.d.ts +2 -1
- package/dist/index.js +3706 -2270
- package/dist/state.d.ts +25 -0
- package/package.json +1 -1
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handle /swarm pr status command.
|
|
3
|
+
*
|
|
4
|
+
* Displays all active PR monitoring subscriptions for the current session.
|
|
5
|
+
* Shows PR URL, repo#number, last checked time (relative), watching status,
|
|
6
|
+
* and error count per subscription. Also reports the total number of active
|
|
7
|
+
* subscriptions across all sessions.
|
|
8
|
+
*
|
|
9
|
+
* Input contract (no args):
|
|
10
|
+
* /swarm pr status → show session subscriptions
|
|
11
|
+
*/
|
|
12
|
+
import { listActive } from '../background/pr-subscriptions.js';
|
|
13
|
+
/**
|
|
14
|
+
* Format an epoch-ms timestamp as a human-friendly relative time string.
|
|
15
|
+
*
|
|
16
|
+
* Returns "just now" for timestamps within the last 5 seconds, otherwise
|
|
17
|
+
* uses the largest whole unit (seconds, minutes, hours, or days).
|
|
18
|
+
*/
|
|
19
|
+
declare function formatRelativeTime(epochMs: number): string;
|
|
20
|
+
/**
|
|
21
|
+
* Exposed for unit testing via _internals.
|
|
22
|
+
*/
|
|
23
|
+
export declare const _internals: {
|
|
24
|
+
formatRelativeTime: typeof formatRelativeTime;
|
|
25
|
+
listActive: typeof listActive;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Show PR monitor subscription status for the current session.
|
|
29
|
+
*
|
|
30
|
+
* Lists all active subscriptions filtered to the current sessionID,
|
|
31
|
+
* formatted as a numbered table with PR URL, relative last-checked
|
|
32
|
+
* time, watching status, and error count. Appends a cross-session
|
|
33
|
+
* total at the end.
|
|
34
|
+
*/
|
|
35
|
+
export declare function handlePrMonitorStatusCommand(directory: string, _args: string[], sessionID: string): Promise<string>;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handle /swarm pr subscribe command.
|
|
3
|
+
*
|
|
4
|
+
* Subscribes the current session to PR state-change notifications. When
|
|
5
|
+
* `pr_monitor.enabled` is true, the background polling worker will detect CI
|
|
6
|
+
* failures, new comments, merge conflicts, review state changes, and
|
|
7
|
+
* merge/close events. Notifications are delivered as session-scoped advisories
|
|
8
|
+
* with dedup tokens.
|
|
9
|
+
*
|
|
10
|
+
* Input contract (PR reference is required):
|
|
11
|
+
* /swarm pr subscribe 155 → subscribe via bare number
|
|
12
|
+
* /swarm pr subscribe owner/repo#155 → shorthand
|
|
13
|
+
* /swarm pr subscribe https://github.com/.../pull/155
|
|
14
|
+
* /swarm pr subscribe → usage (no bare invocation)
|
|
15
|
+
*
|
|
16
|
+
* PR-reference parsing is shared with /swarm pr-review and /swarm pr-feedback
|
|
17
|
+
* via ./pr-ref.ts.
|
|
18
|
+
*/
|
|
19
|
+
import { subscribe } from '../background/pr-subscriptions.js';
|
|
20
|
+
import { loadPluginConfig } from '../config/loader.js';
|
|
21
|
+
/**
|
|
22
|
+
* Subscribe the current session to PR monitoring notifications.
|
|
23
|
+
*
|
|
24
|
+
* Requires a PR reference argument (no bare invocation). The subscription is
|
|
25
|
+
* idempotent — if an active subscription with the same composite key
|
|
26
|
+
* (`sessionID::repoFullName::prNumber`) already exists, the existing record
|
|
27
|
+
* is returned without duplication.
|
|
28
|
+
*/
|
|
29
|
+
export declare function handlePrSubscribeCommand(directory: string, args: string[], sessionID: string): Promise<string>;
|
|
30
|
+
export declare const _internals: {
|
|
31
|
+
loadPluginConfig: typeof loadPluginConfig;
|
|
32
|
+
subscribe: typeof subscribe;
|
|
33
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handle /swarm pr unsubscribe command.
|
|
3
|
+
*
|
|
4
|
+
* Unsubscribes the current session from PR state-change notifications.
|
|
5
|
+
* Removes the active subscription record so the background polling
|
|
6
|
+
* worker will no longer watch this PR for the current session.
|
|
7
|
+
*
|
|
8
|
+
* Input contract (PR reference is required):
|
|
9
|
+
* /swarm pr unsubscribe 155 → unsubscribe via bare number
|
|
10
|
+
* /swarm pr unsubscribe owner/repo#155 → shorthand
|
|
11
|
+
* /swarm pr unsubscribe https://github.com/.../pull/155
|
|
12
|
+
* /swarm pr unsubscribe → usage (no bare invocation)
|
|
13
|
+
*
|
|
14
|
+
* PR-reference parsing is shared with /swarm pr-review, /swarm pr-feedback,
|
|
15
|
+
* and /swarm pr subscribe via ./pr-ref.ts.
|
|
16
|
+
*/
|
|
17
|
+
import { buildCorrelationId, unsubscribe } from '../background/pr-subscriptions.js';
|
|
18
|
+
import { looksLikePrRef, parsePrRef } from './pr-ref.js';
|
|
19
|
+
/**
|
|
20
|
+
* Unsubscribe the current session from PR monitoring notifications.
|
|
21
|
+
*
|
|
22
|
+
* Requires a PR reference argument (no bare invocation). Looks up the active
|
|
23
|
+
* subscription for the current session and PR; if none is found, returns an
|
|
24
|
+
* informational message. If found, marks the subscription as removed.
|
|
25
|
+
*/
|
|
26
|
+
export declare function handlePrUnsubscribeCommand(directory: string, args: string[], sessionID: string): Promise<string>;
|
|
27
|
+
export declare const _internals: {
|
|
28
|
+
unsubscribe: typeof unsubscribe;
|
|
29
|
+
buildCorrelationId: typeof buildCorrelationId;
|
|
30
|
+
parsePrRef: typeof parsePrRef;
|
|
31
|
+
looksLikePrRef: typeof looksLikePrRef;
|
|
32
|
+
};
|
|
@@ -344,6 +344,27 @@ export declare const COMMAND_REGISTRY: {
|
|
|
344
344
|
readonly details: "Triggers MODE: PR_FEEDBACK — ingests existing pull-request feedback (review threads, requested changes, CI/check failures, merge conflicts, stale branch state, pasted notes), verifies every claim against source, clusters related problems, fixes confirmed items, validates the branch, and reports closure status for every ledger item. Distinct from /swarm pr-review, which discovers new findings. The PR reference is optional: with none, the architect builds the ledger from the current PR/branch; text after the reference is forwarded as extra instructions. Supports full GitHub URL, owner/repo#N shorthand, or bare PR number (resolved against origin).";
|
|
345
345
|
readonly category: "agent";
|
|
346
346
|
};
|
|
347
|
+
readonly 'pr subscribe': {
|
|
348
|
+
readonly handler: (ctx: CommandContext) => Promise<string>;
|
|
349
|
+
readonly description: "Subscribe the current session to PR state-change notifications";
|
|
350
|
+
readonly args: "<pr-url|owner/repo#N|N>";
|
|
351
|
+
readonly details: "Subscribes the current session to receive advisory notifications for the specified PR. When pr_monitor.enabled is true, the background polling worker will detect CI failures, new comments, merge conflicts, review state changes, and merge/close events. Notifications are delivered as session-scoped advisories with dedup tokens. Supports full GitHub URL, owner/repo#N shorthand, or bare PR number (resolved against origin). Requires pr_monitor.enabled: true in config.";
|
|
352
|
+
readonly category: "agent";
|
|
353
|
+
};
|
|
354
|
+
readonly 'pr unsubscribe': {
|
|
355
|
+
readonly handler: (ctx: CommandContext) => Promise<string>;
|
|
356
|
+
readonly description: "Unsubscribe the current session from PR state-change notifications";
|
|
357
|
+
readonly args: "<pr-url|owner/repo#N|N>";
|
|
358
|
+
readonly details: "Unsubscribes the current session from receiving advisory notifications for the specified PR. Removes the active subscription record. Supports full GitHub URL, owner/repo#N shorthand, or bare PR number (resolved against origin).";
|
|
359
|
+
readonly category: "agent";
|
|
360
|
+
};
|
|
361
|
+
readonly 'pr status': {
|
|
362
|
+
readonly handler: (ctx: CommandContext) => Promise<string>;
|
|
363
|
+
readonly description: "Show PR monitor subscription status for the current session";
|
|
364
|
+
readonly args: "";
|
|
365
|
+
readonly details: "Displays all active PR subscriptions for the current session. Shows PR URL, last checked time, watching status, and error count per subscription. Also shows total active subscriptions across all sessions.";
|
|
366
|
+
readonly category: "agent";
|
|
367
|
+
};
|
|
347
368
|
readonly 'deep-dive': {
|
|
348
369
|
readonly handler: (ctx: CommandContext) => CommandResult;
|
|
349
370
|
readonly description: "Launch deep codebase audit with parallel explorer waves, dual reviewers, and critic challenge [scope]";
|
package/dist/config/schema.d.ts
CHANGED
|
@@ -823,6 +823,25 @@ export declare const CouncilConfigSchema: z.ZodObject<{
|
|
|
823
823
|
}, z.core.$strict>>;
|
|
824
824
|
}, z.core.$strict>;
|
|
825
825
|
export type CouncilConfig = z.infer<typeof CouncilConfigSchema>;
|
|
826
|
+
export declare const PrMonitorConfigSchema: z.ZodObject<{
|
|
827
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
828
|
+
poll_interval_seconds: z.ZodDefault<z.ZodNumber>;
|
|
829
|
+
max_subscriptions: z.ZodDefault<z.ZodNumber>;
|
|
830
|
+
max_prs_per_cycle: z.ZodDefault<z.ZodNumber>;
|
|
831
|
+
max_concurrent_pr_polls: z.ZodDefault<z.ZodNumber>;
|
|
832
|
+
poll_timeout_ms: z.ZodDefault<z.ZodNumber>;
|
|
833
|
+
failure_threshold: z.ZodDefault<z.ZodNumber>;
|
|
834
|
+
cooldown_seconds: z.ZodDefault<z.ZodNumber>;
|
|
835
|
+
max_cooldown_seconds: z.ZodDefault<z.ZodNumber>;
|
|
836
|
+
cleanup_ttl_days: z.ZodDefault<z.ZodNumber>;
|
|
837
|
+
auto_unsubscribe_on_merge: z.ZodDefault<z.ZodBoolean>;
|
|
838
|
+
auto_unsubscribe_on_close: z.ZodDefault<z.ZodBoolean>;
|
|
839
|
+
notify_ci_failure: z.ZodDefault<z.ZodBoolean>;
|
|
840
|
+
notify_new_comments: z.ZodDefault<z.ZodBoolean>;
|
|
841
|
+
notify_merge_conflict: z.ZodDefault<z.ZodBoolean>;
|
|
842
|
+
auto_pr_feedback: z.ZodDefault<z.ZodBoolean>;
|
|
843
|
+
}, z.core.$strict>;
|
|
844
|
+
export type PrMonitorConfig = z.infer<typeof PrMonitorConfigSchema>;
|
|
826
845
|
export declare const ParallelizationConfigSchema: z.ZodObject<{
|
|
827
846
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
828
847
|
maxConcurrentTasks: z.ZodDefault<z.ZodNumber>;
|
|
@@ -1782,6 +1801,24 @@ export declare const PluginConfigSchema: z.ZodObject<{
|
|
|
1782
1801
|
every_minutes: z.ZodDefault<z.ZodNumber>;
|
|
1783
1802
|
}, z.core.$strip>>;
|
|
1784
1803
|
}, z.core.$strip>>>;
|
|
1804
|
+
pr_monitor: z.ZodOptional<z.ZodObject<{
|
|
1805
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
1806
|
+
poll_interval_seconds: z.ZodDefault<z.ZodNumber>;
|
|
1807
|
+
max_subscriptions: z.ZodDefault<z.ZodNumber>;
|
|
1808
|
+
max_prs_per_cycle: z.ZodDefault<z.ZodNumber>;
|
|
1809
|
+
max_concurrent_pr_polls: z.ZodDefault<z.ZodNumber>;
|
|
1810
|
+
poll_timeout_ms: z.ZodDefault<z.ZodNumber>;
|
|
1811
|
+
failure_threshold: z.ZodDefault<z.ZodNumber>;
|
|
1812
|
+
cooldown_seconds: z.ZodDefault<z.ZodNumber>;
|
|
1813
|
+
max_cooldown_seconds: z.ZodDefault<z.ZodNumber>;
|
|
1814
|
+
cleanup_ttl_days: z.ZodDefault<z.ZodNumber>;
|
|
1815
|
+
auto_unsubscribe_on_merge: z.ZodDefault<z.ZodBoolean>;
|
|
1816
|
+
auto_unsubscribe_on_close: z.ZodDefault<z.ZodBoolean>;
|
|
1817
|
+
notify_ci_failure: z.ZodDefault<z.ZodBoolean>;
|
|
1818
|
+
notify_new_comments: z.ZodDefault<z.ZodBoolean>;
|
|
1819
|
+
notify_merge_conflict: z.ZodDefault<z.ZodBoolean>;
|
|
1820
|
+
auto_pr_feedback: z.ZodDefault<z.ZodBoolean>;
|
|
1821
|
+
}, z.core.$strict>>;
|
|
1785
1822
|
external_skills: z.ZodOptional<z.ZodObject<{
|
|
1786
1823
|
curation_enabled: z.ZodDefault<z.ZodBoolean>;
|
|
1787
1824
|
max_candidates: z.ZodDefault<z.ZodNumber>;
|
package/dist/git/pr.d.ts
CHANGED
|
@@ -1,8 +1,29 @@
|
|
|
1
|
+
export declare const GIT_TIMEOUT_MS = 30000;
|
|
1
2
|
/**
|
|
2
3
|
* Sanitize input string to prevent command injection
|
|
3
4
|
* Removes or escapes shell metacharacters
|
|
4
5
|
*/
|
|
5
6
|
export declare function sanitizeInput(input: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* Execute gh CLI command
|
|
9
|
+
*/
|
|
10
|
+
export declare function ghExec(args: string[], cwd: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Execute gh CLI command asynchronously (non-blocking).
|
|
13
|
+
* Used by background workers that must not block the event loop.
|
|
14
|
+
* Follows AGENTS.md Invariant 3: array-form spawn, explicit cwd,
|
|
15
|
+
* stdin: 'ignore', timeout, bounded stdout/stderr, proc.kill() in finally.
|
|
16
|
+
*/
|
|
17
|
+
export declare function ghExecAsync(args: string[], cwd: string): Promise<string>;
|
|
18
|
+
/**
|
|
19
|
+
* Test-only dependency-injection seam — see `gitignore-warning.ts:_internals`.
|
|
20
|
+
* Production code calls `_internals.ghExec(...)` so tests can replace the
|
|
21
|
+
* function on this object without touching the real `child_process.spawnSync`.
|
|
22
|
+
*/
|
|
23
|
+
export declare const _internals: {
|
|
24
|
+
ghExec: typeof ghExec;
|
|
25
|
+
ghExecAsync: typeof ghExecAsync;
|
|
26
|
+
};
|
|
6
27
|
/**
|
|
7
28
|
* Check if gh CLI is available
|
|
8
29
|
*/
|
|
@@ -26,3 +47,62 @@ export declare function createPullRequest(cwd: string, title: string, body?: str
|
|
|
26
47
|
* Commit and push current changes
|
|
27
48
|
*/
|
|
28
49
|
export declare function commitAndPush(cwd: string, message: string): void;
|
|
50
|
+
export interface PRStatusResult {
|
|
51
|
+
number: number;
|
|
52
|
+
state: 'OPEN' | 'CLOSED' | 'MERGED';
|
|
53
|
+
mergeable: 'MERGEABLE' | 'CONFLICTING' | 'UNKNOWN';
|
|
54
|
+
mergeStateStatus: string;
|
|
55
|
+
headRefOid: string;
|
|
56
|
+
statusCheckRollup: Array<{
|
|
57
|
+
name: string;
|
|
58
|
+
status: string;
|
|
59
|
+
conclusion: string | null;
|
|
60
|
+
}>;
|
|
61
|
+
}
|
|
62
|
+
export interface PRCheckResult {
|
|
63
|
+
name: string;
|
|
64
|
+
bucket: string;
|
|
65
|
+
state: string;
|
|
66
|
+
startedAt: string | null;
|
|
67
|
+
completedAt: string | null;
|
|
68
|
+
}
|
|
69
|
+
export interface PRCommentResult {
|
|
70
|
+
id: string;
|
|
71
|
+
author: string;
|
|
72
|
+
body: string;
|
|
73
|
+
createdAt: string;
|
|
74
|
+
isReviewComment: boolean;
|
|
75
|
+
}
|
|
76
|
+
export interface MergeStateResult {
|
|
77
|
+
mergeable: 'MERGEABLE' | 'CONFLICTING' | 'UNKNOWN';
|
|
78
|
+
mergeStateStatus: string;
|
|
79
|
+
headRefOid: string;
|
|
80
|
+
}
|
|
81
|
+
export interface ReviewStateResult {
|
|
82
|
+
/** Current review decision: APPROVED, CHANGES_REQUESTED, REVIEW_REQUIRED, or empty string. */
|
|
83
|
+
reviewDecision: string;
|
|
84
|
+
/** Number of requesting reviewers (non-zero means reviews are still pending). */
|
|
85
|
+
reviewRequestCount: number;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Fetch PR status via gh pr view --json
|
|
89
|
+
*/
|
|
90
|
+
export declare function getPRStatus(prNumber: number, repoFullName: string, cwd: string): Promise<PRStatusResult>;
|
|
91
|
+
/**
|
|
92
|
+
* Fetch CI check results via gh pr checks --json
|
|
93
|
+
*/
|
|
94
|
+
export declare function getPRChecks(prNumber: number, repoFullName: string, cwd: string): Promise<PRCheckResult[]>;
|
|
95
|
+
/**
|
|
96
|
+
* Fetch PR comments since a given timestamp via gh api
|
|
97
|
+
* Returns both issue comments and pull request review comments, merged together
|
|
98
|
+
*/
|
|
99
|
+
export declare function getPRComments(prNumber: number, repoFullName: string, cwd: string, since?: string): Promise<PRCommentResult[]>;
|
|
100
|
+
/**
|
|
101
|
+
* Fetch merge state (mergeable + mergeStateStatus) via gh pr view --json
|
|
102
|
+
*/
|
|
103
|
+
export declare function getMergeState(prNumber: number, repoFullName: string, cwd: string): Promise<MergeStateResult>;
|
|
104
|
+
/**
|
|
105
|
+
* Fetch the current review state for a PR using `gh pr view --json reviewDecision,reviewRequests`.
|
|
106
|
+
* Uses async ghExecAsync to avoid blocking the event loop.
|
|
107
|
+
*/
|
|
108
|
+
export declare function getPRReviewState(prNumber: number, repoFullName: string, cwd: string): Promise<ReviewStateResult>;
|
|
@@ -7,10 +7,11 @@
|
|
|
7
7
|
* - Layer 2 (Hard Block @ 100%): Throws error in toolBefore to block further calls, injects STOP message
|
|
8
8
|
*/
|
|
9
9
|
import * as path from 'node:path';
|
|
10
|
-
import { getSwarmAgents, resolveFallbackModel } from '../agents/index';
|
|
10
|
+
import { extractSwarmIdFromAgentName, getSwarmAgents, resolveFallbackModel } from '../agents/index';
|
|
11
11
|
import { type AuthorityConfig, type GuardrailsConfig } from '../config/schema';
|
|
12
12
|
import { type FileZone } from '../context/zone-classifier';
|
|
13
13
|
export declare const _internals: {
|
|
14
|
+
extractSwarmIdFromAgentName: typeof extractSwarmIdFromAgentName;
|
|
14
15
|
getSwarmAgents: typeof getSwarmAgents;
|
|
15
16
|
getMostRecentAssistantText: typeof getMostRecentAssistantText;
|
|
16
17
|
getProviderFailureFingerprint: typeof getProviderFailureFingerprint;
|