opencode-swarm 7.52.2 → 7.53.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 +52 -31
- package/dist/cli/index.js +205 -105
- package/dist/commands/pr-feedback.d.ts +23 -0
- package/dist/commands/pr-ref.d.ts +106 -0
- package/dist/commands/pr-review.d.ts +8 -2
- package/dist/commands/registry.d.ts +7 -0
- package/dist/index.js +481 -329
- package/dist/state.d.ts +16 -0
- package/package.json +1 -1
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handle /swarm pr-feedback command.
|
|
3
|
+
*
|
|
4
|
+
* Triggers the architect to enter MODE: PR_FEEDBACK — the swarm workflow for
|
|
5
|
+
* ingesting and closing KNOWN pull-request feedback (review comments, requested
|
|
6
|
+
* changes, CI failures, merge conflicts, stale branches, pasted notes). This is
|
|
7
|
+
* distinct from /swarm pr-review, which discovers NEW findings.
|
|
8
|
+
*
|
|
9
|
+
* Input contract (PR reference is optional):
|
|
10
|
+
* /swarm pr-feedback 155 → feedback pass on PR 155
|
|
11
|
+
* /swarm pr-feedback 155 also fix the lint errors → PR 155 + extra instructions
|
|
12
|
+
* /swarm pr-feedback owner/repo#155 → shorthand
|
|
13
|
+
* /swarm pr-feedback https://github.com/.../pull/155
|
|
14
|
+
* /swarm pr-feedback → bare signal; architect builds
|
|
15
|
+
* the ledger from current PR/branch
|
|
16
|
+
* /swarm pr-feedback address the review notes about error handling
|
|
17
|
+
* → no parseable PR ref ⇒ the whole
|
|
18
|
+
* input is forwarded as instructions
|
|
19
|
+
*
|
|
20
|
+
* PR-reference parsing and injection-hardening are shared with /swarm pr-review
|
|
21
|
+
* via ./pr-ref.ts.
|
|
22
|
+
*/
|
|
23
|
+
export declare function handlePrFeedbackCommand(directory: string, args: string[]): string;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared GitHub PR-reference parsing and sanitization for the
|
|
3
|
+
* `/swarm pr-review` and `/swarm pr-feedback` commands.
|
|
4
|
+
*
|
|
5
|
+
* Both commands accept a PR reference in three formats (full URL,
|
|
6
|
+
* `owner/repo#N`, or a bare PR number resolved against the `origin` remote)
|
|
7
|
+
* and may be followed by free-text instructions that are forwarded to the
|
|
8
|
+
* architect in the emitted `[MODE: ...]` signal. All parsing here is hardened
|
|
9
|
+
* against prompt injection: rival `[MODE: ...]` headers, query strings,
|
|
10
|
+
* fragments, and embedded credentials are stripped before the value is ever
|
|
11
|
+
* placed back into a signal string.
|
|
12
|
+
*/
|
|
13
|
+
import { execSync } from 'node:child_process';
|
|
14
|
+
/**
|
|
15
|
+
* File-scoped indirection seam for the subprocess call. Tests override
|
|
16
|
+
* `_internals.execSync` (no `mock.module`) to assert the working directory is
|
|
17
|
+
* threaded through and to simulate a missing `origin` remote.
|
|
18
|
+
*/
|
|
19
|
+
export declare const _internals: {
|
|
20
|
+
execSync: typeof execSync;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Strip query strings, fragments, injected MODE headers, and credentials from
|
|
24
|
+
* a URL string.
|
|
25
|
+
*/
|
|
26
|
+
export declare function sanitizeUrl(raw: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* Sanitize free-text instructions so they cannot forge a competing MODE
|
|
29
|
+
* header, inject control sequences, or break out of the signal line.
|
|
30
|
+
* Collapses whitespace (including newlines), strips bracketed `[MODE: ...]`
|
|
31
|
+
* headers, and truncates to a bounded length.
|
|
32
|
+
*/
|
|
33
|
+
export declare function sanitizeInstructions(raw: string): string;
|
|
34
|
+
/**
|
|
35
|
+
* Blocklist of private/localhost hostnames and IP ranges.
|
|
36
|
+
*/
|
|
37
|
+
export declare function isPrivateHost(url: URL): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Validate and sanitize a GitHub PR URL.
|
|
40
|
+
* Returns the sanitized URL on success, or an error message on failure.
|
|
41
|
+
*/
|
|
42
|
+
export type ValidationResult = {
|
|
43
|
+
sanitized: string;
|
|
44
|
+
} | {
|
|
45
|
+
error: string;
|
|
46
|
+
};
|
|
47
|
+
export declare function validateAndSanitizeUrl(rawUrl: string): ValidationResult;
|
|
48
|
+
export interface ParsedPr {
|
|
49
|
+
owner: string;
|
|
50
|
+
repo: string;
|
|
51
|
+
number: number;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Parse a PR reference from three formats:
|
|
55
|
+
* 1. Full URL: https://github.com/owner/repo/pull/N
|
|
56
|
+
* 2. Shorthand: owner/repo#N
|
|
57
|
+
* 3. Bare number: N (resolved against the `origin` git remote in `cwd`)
|
|
58
|
+
*/
|
|
59
|
+
export declare function parsePrRef(input: string, cwd?: string): ParsedPr | null;
|
|
60
|
+
/**
|
|
61
|
+
* Detect the `origin` remote URL from git config.
|
|
62
|
+
*
|
|
63
|
+
* `cwd` should be the project directory the command was invoked for. Without it
|
|
64
|
+
* the lookup runs in `process.cwd()`, which in a plugin host is frequently not
|
|
65
|
+
* the repository root — so bare-number PR resolution would silently fail or
|
|
66
|
+
* resolve against the wrong repo (invariant #3: subprocesses run in an explicit
|
|
67
|
+
* working directory).
|
|
68
|
+
*/
|
|
69
|
+
export declare function detectGitRemote(cwd?: string): string | null;
|
|
70
|
+
/**
|
|
71
|
+
* Parse owner/repo from a git remote URL.
|
|
72
|
+
* Supports HTTPS (https://github.com/owner/repo.git) and SSH (git@github.com:owner/repo.git).
|
|
73
|
+
*/
|
|
74
|
+
export declare function parseGitRemoteUrl(remoteUrl: string): {
|
|
75
|
+
owner: string;
|
|
76
|
+
repo: string;
|
|
77
|
+
} | null;
|
|
78
|
+
/**
|
|
79
|
+
* Whether a token is *shaped* like a PR reference — a full `http(s)` URL, an
|
|
80
|
+
* `owner/repo#N` shorthand, or a bare number. This is intent detection, not
|
|
81
|
+
* validation: a token can look like a PR ref yet still fail to resolve (e.g. a
|
|
82
|
+
* bare number when no `origin` remote exists, or a non-GitHub URL). Callers that
|
|
83
|
+
* accept free-text fallbacks (pr-feedback) use this to tell "the user meant a PR
|
|
84
|
+
* reference but it didn't resolve" (surface an error) from "the user typed
|
|
85
|
+
* instructions" (forward them).
|
|
86
|
+
*/
|
|
87
|
+
export declare function looksLikePrRef(token: string): boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Resolve the leading token of a PR command's positional args into a validated
|
|
90
|
+
* GitHub PR URL, and collect any trailing tokens as free-text instructions.
|
|
91
|
+
*
|
|
92
|
+
* `rest` is the positional token list AFTER flag parsing (e.g. `--council`
|
|
93
|
+
* already removed). The first token is the PR reference; everything after it
|
|
94
|
+
* is sanitized and returned as `instructions` for forwarding in the MODE
|
|
95
|
+
* signal. `cwd` is the project directory used to resolve a bare PR number
|
|
96
|
+
* against the `origin` remote.
|
|
97
|
+
*
|
|
98
|
+
* Returns `null` when there are no positional tokens (caller shows usage).
|
|
99
|
+
*/
|
|
100
|
+
export type PrCommandInput = {
|
|
101
|
+
prUrl: string;
|
|
102
|
+
instructions: string;
|
|
103
|
+
} | {
|
|
104
|
+
error: string;
|
|
105
|
+
};
|
|
106
|
+
export declare function resolvePrCommandInput(rest: string[], cwd?: string): PrCommandInput | null;
|
|
@@ -2,10 +2,16 @@
|
|
|
2
2
|
* Handle /swarm pr-review command.
|
|
3
3
|
*
|
|
4
4
|
* Triggers the architect to enter MODE: PR_REVIEW — the swarm PR review workflow.
|
|
5
|
-
* Accepts PR
|
|
5
|
+
* Accepts a PR reference in multiple formats (full URL, owner/repo#N, or a bare
|
|
6
|
+
* PR number resolved against the origin remote) optionally followed by
|
|
7
|
+
* free-text instructions, and sanitizes all inputs against injection.
|
|
6
8
|
*
|
|
7
9
|
* Flag parsing:
|
|
8
10
|
* --council → appends council=true to emitted signal
|
|
11
|
+
* <ref> <text...> → trailing text becomes forwarded instructions
|
|
9
12
|
* no args → returns usage string (no throw)
|
|
13
|
+
*
|
|
14
|
+
* PR-reference parsing and sanitization are shared with /swarm pr-feedback via
|
|
15
|
+
* ./pr-ref.ts.
|
|
10
16
|
*/
|
|
11
|
-
export declare function handlePrReviewCommand(
|
|
17
|
+
export declare function handlePrReviewCommand(directory: string, args: string[]): string;
|
|
@@ -308,6 +308,13 @@ export declare const COMMAND_REGISTRY: {
|
|
|
308
308
|
readonly details: "Launches a structured PR review: reconstructs PR intent via obligation extraction cascade, runs 6 parallel explorer lanes (correctness, security, dependencies, docs-intent-vs-actual, tests, performance-architecture), validates findings through independent reviewer confirmation, applies critic challenge to HIGH/CRITICAL findings, synthesizes structured report. --council variant fires adversarial multi-model review. Supports full GitHub URL, owner/repo#N shorthand, or bare PR number (resolves against origin remote).";
|
|
309
309
|
readonly category: "agent";
|
|
310
310
|
};
|
|
311
|
+
readonly 'pr-feedback': {
|
|
312
|
+
readonly handler: (ctx: CommandContext) => Promise<string>;
|
|
313
|
+
readonly description: "Ingest and close known PR feedback (review comments, CI failures, conflicts) [pr] [instructions]";
|
|
314
|
+
readonly args: "[url|owner/repo#N|N] [instructions...]";
|
|
315
|
+
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).";
|
|
316
|
+
readonly category: "agent";
|
|
317
|
+
};
|
|
311
318
|
readonly 'deep-dive': {
|
|
312
319
|
readonly handler: (ctx: CommandContext) => Promise<string>;
|
|
313
320
|
readonly description: "Launch deep codebase audit with parallel explorer waves, dual reviewers, and critic challenge [scope]";
|