opencode-swarm 7.66.3 → 7.68.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/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 +1886 -951
- package/dist/commands/index.d.ts +1 -0
- package/dist/commands/learning.d.ts +1 -0
- 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 +28 -0
- package/dist/config/evidence-schema.d.ts +214 -0
- package/dist/config/schema.d.ts +37 -0
- package/dist/git/pr.d.ts +80 -0
- package/dist/hooks/curator.d.ts +4 -1
- package/dist/hooks/skill-usage-log.d.ts +10 -0
- package/dist/index.js +5517 -3173
- package/dist/mutation/engine.d.ts +12 -1
- package/dist/services/learning-metrics.d.ts +63 -0
- package/dist/services/skill-changelog.d.ts +21 -0
- package/dist/services/skill-generator.d.ts +7 -1
- package/dist/services/skill-reviser.d.ts +59 -0
- package/dist/state.d.ts +25 -0
- package/package.json +1 -1
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import { spawnSync } from 'node:child_process';
|
|
2
2
|
type SpawnSyncFn = typeof spawnSync;
|
|
3
3
|
export type MutationOutcome = 'killed' | 'survived' | 'timeout' | 'error' | 'equivalent' | 'skipped';
|
|
4
|
+
/**
|
|
5
|
+
* Known test runner executables permitted as the first element of testCommand.
|
|
6
|
+
* Validated as the basename (without extension) to support platform-specific
|
|
7
|
+
* variants like `bun.exe` on Windows or full paths like `/usr/local/bin/jest`.
|
|
8
|
+
*/
|
|
9
|
+
export declare const ALLOWED_TEST_RUNNERS: Set<string>;
|
|
10
|
+
/**
|
|
11
|
+
* Validate that testCommand[0] is a known test runner.
|
|
12
|
+
* Returns an error string if invalid, or null if valid.
|
|
13
|
+
*/
|
|
14
|
+
export declare function validateTestCommand(testCommand: string[]): string | null;
|
|
4
15
|
export interface MutationPatch {
|
|
5
16
|
id: string;
|
|
6
17
|
filePath: string;
|
|
@@ -50,7 +61,7 @@ export declare const _internals: {
|
|
|
50
61
|
executeMutationSuite: typeof executeMutationSuite;
|
|
51
62
|
spawnSync: SpawnSyncFn;
|
|
52
63
|
};
|
|
53
|
-
export declare function executeMutation(patch: MutationPatch, testCommand: string[],
|
|
64
|
+
export declare function executeMutation(patch: MutationPatch, testCommand: string[], testFiles: string[], workingDir: string): Promise<MutationResult>;
|
|
54
65
|
export declare function computeReport(results: MutationResult[], durationMs: number, budgetMs?: number): MutationReport;
|
|
55
66
|
export declare function executeMutationSuite(patches: MutationPatch[], testCommand: string[], testFiles: string[], workingDir: string, budgetMs?: number, onProgress?: (completed: number, total: number, result: MutationResult) => void, sourceFiles?: Map<string, string>): Promise<MutationReport>;
|
|
56
67
|
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
export interface LearningMetrics {
|
|
2
|
+
violationTrends: ViolationTrend[];
|
|
3
|
+
overallViolationRate: {
|
|
4
|
+
window7d: number;
|
|
5
|
+
window30d: number;
|
|
6
|
+
};
|
|
7
|
+
applicationRateByPriority: Record<string, {
|
|
8
|
+
applied: number;
|
|
9
|
+
total: number;
|
|
10
|
+
rate: number;
|
|
11
|
+
}>;
|
|
12
|
+
timeToLatestApplication: TimeToApply[];
|
|
13
|
+
escalationFrequency: {
|
|
14
|
+
total: number;
|
|
15
|
+
last7d: number;
|
|
16
|
+
last30d: number;
|
|
17
|
+
};
|
|
18
|
+
unacknowledgedCriticalCount: number;
|
|
19
|
+
entryROI: EntryROI[];
|
|
20
|
+
neverApplied: NeverAppliedEntry[];
|
|
21
|
+
learningSummary: string;
|
|
22
|
+
sessionCount: number;
|
|
23
|
+
}
|
|
24
|
+
export interface ViolationTrend {
|
|
25
|
+
entryId: string;
|
|
26
|
+
lesson: string;
|
|
27
|
+
priority: string;
|
|
28
|
+
violationRate7d: number;
|
|
29
|
+
violationRate30d: number;
|
|
30
|
+
trend: 'improving' | 'worsening' | 'stable' | 'no_data';
|
|
31
|
+
}
|
|
32
|
+
export interface EntryROI {
|
|
33
|
+
entryId: string;
|
|
34
|
+
lesson: string;
|
|
35
|
+
appliedCount: number;
|
|
36
|
+
shownCount: number;
|
|
37
|
+
succeededCount: number;
|
|
38
|
+
failedCount: number;
|
|
39
|
+
roi: 'high' | 'medium' | 'low' | 'unused';
|
|
40
|
+
}
|
|
41
|
+
export interface TimeToApply {
|
|
42
|
+
entryId: string;
|
|
43
|
+
lesson: string;
|
|
44
|
+
daysToApply: number | null;
|
|
45
|
+
}
|
|
46
|
+
export interface NeverAppliedEntry {
|
|
47
|
+
entryId: string;
|
|
48
|
+
lesson: string;
|
|
49
|
+
phasesAlive: number;
|
|
50
|
+
}
|
|
51
|
+
export declare function computeLearningMetrics(directory: string, options?: {
|
|
52
|
+
now?: Date;
|
|
53
|
+
currentPhase?: number;
|
|
54
|
+
}): Promise<LearningMetrics>;
|
|
55
|
+
export declare function formatLearningMarkdown(metrics: LearningMetrics): string;
|
|
56
|
+
export declare function formatLearningJSON(metrics: LearningMetrics): object;
|
|
57
|
+
export declare function formatLearningSummary(metrics: LearningMetrics): string;
|
|
58
|
+
export declare const _internals: {
|
|
59
|
+
computeLearningMetrics: typeof computeLearningMetrics;
|
|
60
|
+
formatLearningMarkdown: typeof formatLearningMarkdown;
|
|
61
|
+
formatLearningJSON: typeof formatLearningJSON;
|
|
62
|
+
formatLearningSummary: typeof formatLearningSummary;
|
|
63
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const MAX_CHANGELOG_ENTRIES_PER_SKILL = 200;
|
|
2
|
+
export interface SkillChangelogEntry {
|
|
3
|
+
version: number;
|
|
4
|
+
timestamp: string;
|
|
5
|
+
action: 'generated' | 'regenerated' | 'revised' | 'promoted';
|
|
6
|
+
reason: string;
|
|
7
|
+
triggeringVerdicts?: {
|
|
8
|
+
taskId: string;
|
|
9
|
+
verdict: string;
|
|
10
|
+
agent: string;
|
|
11
|
+
}[];
|
|
12
|
+
sectionsChanged?: string[];
|
|
13
|
+
}
|
|
14
|
+
export declare function resolveSkillChangelogPath(directory: string, slug: string): string;
|
|
15
|
+
export declare function appendSkillChangelog(directory: string, slug: string, entry: SkillChangelogEntry): Promise<void>;
|
|
16
|
+
export declare function readSkillChangelog(directory: string, slug: string): Promise<SkillChangelogEntry[]>;
|
|
17
|
+
export declare const _internals: {
|
|
18
|
+
resolveSkillChangelogPath: typeof resolveSkillChangelogPath;
|
|
19
|
+
appendSkillChangelog: typeof appendSkillChangelog;
|
|
20
|
+
readSkillChangelog: typeof readSkillChangelog;
|
|
21
|
+
};
|
|
@@ -42,7 +42,11 @@ export declare function selectCandidateEntries(directory: string, opts: Candidat
|
|
|
42
42
|
*/
|
|
43
43
|
declare function jaccardSimilarity(setA: string[], setB: string[]): number;
|
|
44
44
|
export declare function clusterEntries(entries: KnowledgeEntryBase[]): KnowledgeCluster[];
|
|
45
|
-
export
|
|
45
|
+
export interface SkillFrontmatterOverrides {
|
|
46
|
+
version?: number;
|
|
47
|
+
skillOrigin?: 'generated' | 'promoted_external';
|
|
48
|
+
}
|
|
49
|
+
export declare function renderSkillMarkdown(cluster: KnowledgeCluster, mode?: GenerateMode, generatedAt?: string, overrides?: SkillFrontmatterOverrides): string;
|
|
46
50
|
export type GenerateMode = 'draft' | 'active';
|
|
47
51
|
export interface GenerateRequest {
|
|
48
52
|
directory: string;
|
|
@@ -86,6 +90,8 @@ export declare function parseDraftFrontmatter(content: string): {
|
|
|
86
90
|
status?: string;
|
|
87
91
|
generatedAt?: string;
|
|
88
92
|
sourceKnowledgeIds: string[];
|
|
93
|
+
version?: number;
|
|
94
|
+
skillOrigin?: string;
|
|
89
95
|
} | null;
|
|
90
96
|
export declare function activateProposal(directory: string, slug: string, force?: boolean): Promise<{
|
|
91
97
|
activated: boolean;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skill revision service.
|
|
3
|
+
*
|
|
4
|
+
* When a skill's violation rate crosses a soft threshold (>15% but ≤30%),
|
|
5
|
+
* produces a revised version by feeding violation contexts into a bounded
|
|
6
|
+
* LLM rewrite of the violated sections. Reuses the skill_improver.max_calls_per_day
|
|
7
|
+
* quota budget but is capped to max 3 LLM calls per curator phase to avoid
|
|
8
|
+
* starving manual skill-improve runs.
|
|
9
|
+
*
|
|
10
|
+
* Falls back to deterministic revision (append revision notes) when no LLM
|
|
11
|
+
* delegate is available or quota is exhausted.
|
|
12
|
+
*/
|
|
13
|
+
import type { SkillImproverLLMDelegate } from '../hooks/skill-improver-llm-factory.js';
|
|
14
|
+
import type { QuotaWindow } from './skill-improver-quota.js';
|
|
15
|
+
export declare const REVISION_VIOLATION_THRESHOLD = 0.15;
|
|
16
|
+
export declare const MAX_REVISION_CALLS_PER_PHASE = 3;
|
|
17
|
+
export interface ViolationContext {
|
|
18
|
+
taskId: string;
|
|
19
|
+
agent: string;
|
|
20
|
+
verdict: string;
|
|
21
|
+
reviewerNotes?: string;
|
|
22
|
+
timestamp: string;
|
|
23
|
+
}
|
|
24
|
+
export interface SkillRevisionResult {
|
|
25
|
+
revised: boolean;
|
|
26
|
+
reason: string;
|
|
27
|
+
newVersion?: number;
|
|
28
|
+
quotaConsumed: boolean;
|
|
29
|
+
}
|
|
30
|
+
export interface ReviseSkillParams {
|
|
31
|
+
directory: string;
|
|
32
|
+
slug: string;
|
|
33
|
+
skillPath: string;
|
|
34
|
+
violationContexts: ViolationContext[];
|
|
35
|
+
currentContent: string;
|
|
36
|
+
currentVersion: number;
|
|
37
|
+
maxCalls?: number;
|
|
38
|
+
quotaWindow?: QuotaWindow;
|
|
39
|
+
delegate?: SkillImproverLLMDelegate;
|
|
40
|
+
now?: Date;
|
|
41
|
+
}
|
|
42
|
+
export declare function getSkillVersion(skillPath: string): Promise<number>;
|
|
43
|
+
export declare function buildDeterministicRevision(currentContent: string, currentVersion: number, violationContexts: ViolationContext[]): string;
|
|
44
|
+
declare function buildLLMPrompt(currentContent: string, currentVersion: number, violationContexts: ViolationContext[]): {
|
|
45
|
+
systemPrompt: string;
|
|
46
|
+
userPrompt: string;
|
|
47
|
+
};
|
|
48
|
+
declare function validateLLMOutput(output: string): boolean;
|
|
49
|
+
export declare function reviseSkill(params: ReviseSkillParams): Promise<SkillRevisionResult>;
|
|
50
|
+
export declare const _internals: {
|
|
51
|
+
reviseSkill: typeof reviseSkill;
|
|
52
|
+
getSkillVersion: typeof getSkillVersion;
|
|
53
|
+
buildDeterministicRevision: typeof buildDeterministicRevision;
|
|
54
|
+
buildLLMPrompt: typeof buildLLMPrompt;
|
|
55
|
+
validateLLMOutput: typeof validateLLMOutput;
|
|
56
|
+
REVISION_VIOLATION_THRESHOLD: number;
|
|
57
|
+
MAX_REVISION_CALLS_PER_PHASE: number;
|
|
58
|
+
};
|
|
59
|
+
export {};
|
package/dist/state.d.ts
CHANGED
|
@@ -46,6 +46,19 @@ export interface DelegationEntry {
|
|
|
46
46
|
* Used by delegation-tracker.ts to record why a delegation occurred.
|
|
47
47
|
*/
|
|
48
48
|
export type DelegationReason = 'normal_delegation' | 'review_rejected' | 'critic_consultation' | 'retry_circuit_breaker' | 'conflict_escalation' | 'stale_recovery';
|
|
49
|
+
/**
|
|
50
|
+
* Per-session PR subscription state for the background PR poller.
|
|
51
|
+
* Keyed by `${repoFullName}::${prNumber}` within the session's prSubscriptions Map.
|
|
52
|
+
*/
|
|
53
|
+
export interface PrSubscriptionState {
|
|
54
|
+
prNumber: number;
|
|
55
|
+
repoFullName: string;
|
|
56
|
+
prUrl: string;
|
|
57
|
+
lastKnownStatus: string;
|
|
58
|
+
lastPollTime: number;
|
|
59
|
+
errorCount: number;
|
|
60
|
+
isWatching: boolean;
|
|
61
|
+
}
|
|
49
62
|
/**
|
|
50
63
|
* Per-task workflow state for gate progression tracking.
|
|
51
64
|
* Transitions must be forward-only: idle → coder_delegated → pre_check_passed → reviewer_run → tests_run → complete
|
|
@@ -226,6 +239,8 @@ export interface AgentSessionState {
|
|
|
226
239
|
prmHardStopPending: boolean;
|
|
227
240
|
/** Per-session escalation tracker instance (set lazily by PRM hook) */
|
|
228
241
|
prmEscalationTracker?: EscalationTracker;
|
|
242
|
+
/** Active PR subscriptions for the background poller, keyed by `${repoFullName}::${prNumber}` */
|
|
243
|
+
prSubscriptions: Map<string, PrSubscriptionState>;
|
|
229
244
|
}
|
|
230
245
|
/**
|
|
231
246
|
* Represents a single agent invocation window with isolated guardrail budgets.
|
|
@@ -628,6 +643,16 @@ export declare function clearCriticalShownIds(sessionID: string): boolean;
|
|
|
628
643
|
/** Add a knowledge ack dedup key, FIFO-evicting the oldest if the cap is
|
|
629
644
|
* exceeded. Sets preserve insertion order in JS. */
|
|
630
645
|
export declare function addKnowledgeAckDedup(key: string): void;
|
|
646
|
+
/**
|
|
647
|
+
* Rehydrate PR subscriptions for a given session from durable storage.
|
|
648
|
+
* Reads active subscriptions from the JSONL store and filters to those
|
|
649
|
+
* belonging to the specified sessionID, converting each to a PrSubscriptionState.
|
|
650
|
+
*
|
|
651
|
+
* @param sessionID - The session identifier to filter subscriptions by
|
|
652
|
+
* @param directory - Project root containing .swarm/ subdirectory
|
|
653
|
+
* @returns Map of PrSubscriptionState keyed by `${repoFullName}::${prNumber}`
|
|
654
|
+
*/
|
|
655
|
+
export declare function rehydratePrSubscriptions(sessionID: string, directory: string): Promise<Map<string, PrSubscriptionState>>;
|
|
631
656
|
/**
|
|
632
657
|
* Test-only dependency-injection seam. Production code calls
|
|
633
658
|
* `_internals.*` for key exported functions and objects so tests can replace
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-swarm",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.68.0",
|
|
4
4
|
"description": "Architect-centric agentic swarm plugin for OpenCode - hub-and-spoke orchestration with SME consultation, code generation, and QA review",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|