opencode-swarm 7.83.0 → 7.85.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/.opencode/skills/codebase-review-swarm/references/review-protocol-v8.2.md +4 -0
- package/.opencode/skills/council/SKILL.md +6 -1
- package/.opencode/skills/deep-dive/SKILL.md +2 -0
- package/.opencode/skills/deep-research/SKILL.md +6 -0
- package/.opencode/skills/swarm-pr-feedback/SKILL.md +6 -0
- package/.opencode/skills/swarm-pr-review/SKILL.md +4 -0
- package/README.md +3 -1
- package/dist/background/lane-output-store.d.ts +72 -0
- package/dist/background/pending-delegations.d.ts +6 -0
- package/dist/cli/capability-probe-jevmgwmf.js +18 -0
- package/dist/cli/config-doctor-zejarrr6.js +35 -0
- package/dist/cli/dispatch-k86d928w.js +477 -0
- package/dist/cli/evidence-summary-service-g2znnd33.js +320 -0
- package/dist/cli/explorer-gz70sm9b.js +16 -0
- package/dist/cli/gate-evidence-y8zn7fe2.js +29 -0
- package/dist/cli/guardrail-explain-w4txg349.js +30 -0
- package/dist/cli/guardrail-log-80116wmz.js +15 -0
- package/dist/cli/index-0sxvwjt0.js +1241 -0
- package/dist/cli/index-293f68mj.js +13538 -0
- package/dist/cli/index-5cb86007.js +110 -0
- package/dist/cli/index-a76rekgs.js +67 -0
- package/dist/cli/index-b9v501fr.js +371 -0
- package/dist/cli/index-bcp79s17.js +1673 -0
- package/dist/cli/index-ckntc5gf.js +91 -0
- package/dist/cli/index-d9fbxaqd.js +2314 -0
- package/dist/cli/index-e7h9bb6v.js +233 -0
- package/dist/cli/index-e8pk68cc.js +540 -0
- package/dist/cli/index-eb85wtx9.js +242 -0
- package/dist/cli/index-f8r50m3h.js +14505 -0
- package/dist/cli/index-fjwwrwr5.js +37 -0
- package/dist/cli/index-hw9b2xng.js +2046 -0
- package/dist/cli/index-hz59hg4h.js +452 -0
- package/dist/cli/index-jtqkh8jf.js +119 -0
- package/dist/cli/index-p0arc26j.js +28 -0
- package/dist/cli/index-p0ye10nd.js +222 -0
- package/dist/cli/index-qqabjns2.js +412 -0
- package/dist/cli/index-red8fm8p.js +2914 -0
- package/dist/cli/index-vq2321gg.js +2391 -0
- package/dist/cli/index-x7qck34v.js +583 -0
- package/dist/cli/index-yhqt45de.js +29027 -0
- package/dist/cli/index-yhsmmv2z.js +339 -0
- package/dist/cli/index-yx44zd0p.js +40 -0
- package/dist/cli/index-zfsbaaqh.js +29 -0
- package/dist/cli/index.js +73 -69708
- package/dist/cli/knowledge-store-n4x6zyk7.js +73 -0
- package/dist/cli/pending-delegations-rd40tv9s.js +261 -0
- package/dist/cli/pr-subscriptions-y1nn36e5.js +33 -0
- package/dist/cli/schema-8d32b2v6.js +168 -0
- package/dist/cli/skill-generator-a5ehggyg.js +55 -0
- package/dist/cli/task-envelope-qn0qtnh0.js +90 -0
- package/dist/cli/telemetry-9bbyxrvn.js +20 -0
- package/dist/cli/workspace-snapshot-w58jr2ga.js +90 -0
- package/dist/commands/guardrail-explain.d.ts +1 -0
- package/dist/commands/guardrail-log.d.ts +1 -0
- package/dist/commands/index.d.ts +2 -0
- package/dist/commands/registry.d.ts +14 -0
- package/dist/hooks/guardrails/audit-log.d.ts +114 -0
- package/dist/index.js +4005 -2432
- package/dist/services/diagnose-service.d.ts +5 -0
- package/dist/services/guardrail-explain-service.d.ts +42 -0
- package/dist/services/guardrail-log-service.d.ts +10 -0
- package/dist/tools/dispatch-lanes.d.ts +14 -3
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/manifest.d.ts +1 -0
- package/dist/tools/retrieve-lane-output.d.ts +2 -0
- package/dist/tools/tool-metadata.d.ts +4 -0
- package/package.json +2 -2
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import"./index-a76rekgs.js";
|
|
3
|
+
|
|
4
|
+
// src/background/workspace-snapshot.ts
|
|
5
|
+
import * as child_process from "child_process";
|
|
6
|
+
import { createHash } from "crypto";
|
|
7
|
+
import * as path from "path";
|
|
8
|
+
var GIT_SNAPSHOT_TIMEOUT_MS = 3000;
|
|
9
|
+
var GIT_SNAPSHOT_MAX_BUFFER = 512 * 1024;
|
|
10
|
+
function runGit(directory, args) {
|
|
11
|
+
const result = _internals.spawnSync("git", ["-C", directory, ...args], {
|
|
12
|
+
cwd: directory,
|
|
13
|
+
encoding: "utf-8",
|
|
14
|
+
timeout: GIT_SNAPSHOT_TIMEOUT_MS,
|
|
15
|
+
maxBuffer: GIT_SNAPSHOT_MAX_BUFFER,
|
|
16
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
17
|
+
});
|
|
18
|
+
if (result.error || result.status !== 0)
|
|
19
|
+
return null;
|
|
20
|
+
return typeof result.stdout === "string" ? result.stdout.trimEnd() : null;
|
|
21
|
+
}
|
|
22
|
+
function captureWorkspaceSnapshot(directory, optionsOrScope = null, prHeadShaArg = null) {
|
|
23
|
+
const scope = typeof optionsOrScope === "object" && optionsOrScope !== null ? optionsOrScope.scope ?? null : optionsOrScope;
|
|
24
|
+
const prHeadSha = (() => {
|
|
25
|
+
if (typeof optionsOrScope !== "object" || optionsOrScope === null) {
|
|
26
|
+
return prHeadShaArg;
|
|
27
|
+
}
|
|
28
|
+
if (optionsOrScope.resolveCurrentPrHeadSha) {
|
|
29
|
+
return runGit(directory, ["rev-parse", "@{upstream}"]);
|
|
30
|
+
}
|
|
31
|
+
return optionsOrScope.prHeadSha ?? null;
|
|
32
|
+
})();
|
|
33
|
+
const gitHead = runGit(directory, ["rev-parse", "HEAD"]);
|
|
34
|
+
const porcelain = runGit(directory, [
|
|
35
|
+
"status",
|
|
36
|
+
"--porcelain=v1",
|
|
37
|
+
"--untracked-files=all"
|
|
38
|
+
]);
|
|
39
|
+
return {
|
|
40
|
+
directory: path.resolve(directory),
|
|
41
|
+
gitHead,
|
|
42
|
+
dirtyHash: porcelain === null ? null : digest(porcelain),
|
|
43
|
+
prHeadSha,
|
|
44
|
+
scope
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function workspaceSnapshotMatches(expected, current) {
|
|
48
|
+
if (!expected)
|
|
49
|
+
return { ok: true };
|
|
50
|
+
if (path.resolve(expected.directory) !== path.resolve(current.directory)) {
|
|
51
|
+
return {
|
|
52
|
+
ok: false,
|
|
53
|
+
reason: `directory changed: expected ${expected.directory}, got ${current.directory}`
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
const checks = ["gitHead", "dirtyHash", "prHeadSha"];
|
|
57
|
+
for (const key of checks) {
|
|
58
|
+
const expectedValue = expected[key];
|
|
59
|
+
if (expectedValue === null)
|
|
60
|
+
continue;
|
|
61
|
+
if (current[key] !== expectedValue) {
|
|
62
|
+
return {
|
|
63
|
+
ok: false,
|
|
64
|
+
reason: `${key} changed: expected ${expectedValue}, got ${current[key] ?? "unknown"}`
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return { ok: true };
|
|
69
|
+
}
|
|
70
|
+
var compareWorkspaceSnapshot = workspaceSnapshotMatches;
|
|
71
|
+
function compareWorkspaceSnapshots(expected, current) {
|
|
72
|
+
const result = workspaceSnapshotMatches(expected, current);
|
|
73
|
+
if (result.ok)
|
|
74
|
+
return { stale: false };
|
|
75
|
+
return { stale: true, reason: result.reason };
|
|
76
|
+
}
|
|
77
|
+
function digest(text) {
|
|
78
|
+
return createHash("sha256").update(text).digest("hex");
|
|
79
|
+
}
|
|
80
|
+
var _internals = {
|
|
81
|
+
spawnSync: child_process.spawnSync
|
|
82
|
+
};
|
|
83
|
+
export {
|
|
84
|
+
workspaceSnapshotMatches,
|
|
85
|
+
digest,
|
|
86
|
+
compareWorkspaceSnapshots,
|
|
87
|
+
compareWorkspaceSnapshot,
|
|
88
|
+
captureWorkspaceSnapshot,
|
|
89
|
+
_internals
|
|
90
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { handleGuardrailExplain } from '../services/guardrail-explain-service';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { handleGuardrailLog } from '../services/guardrail-log-service';
|
package/dist/commands/index.d.ts
CHANGED
|
@@ -26,6 +26,8 @@ export { handleDoctorCommand } from './doctor';
|
|
|
26
26
|
export { handleEvidenceCommand, handleEvidenceSummaryCommand, } from './evidence';
|
|
27
27
|
export { handleExportCommand } from './export';
|
|
28
28
|
export { handleFullAutoCommand } from './full-auto';
|
|
29
|
+
export { handleGuardrailExplain } from './guardrail-explain';
|
|
30
|
+
export { handleGuardrailLog } from './guardrail-log';
|
|
29
31
|
export { handleHandoffCommand } from './handoff';
|
|
30
32
|
export { handleHistoryCommand } from './history';
|
|
31
33
|
export { handleKnowledgeListCommand, handleKnowledgeMigrateCommand, handleKnowledgeQuarantineCommand, handleKnowledgeRestoreCommand, handleKnowledgeRetryHardeningCommand, handleKnowledgeUnactionableCommand, } from './knowledge';
|
|
@@ -168,6 +168,20 @@ export declare const COMMAND_REGISTRY: {
|
|
|
168
168
|
readonly aliasOf: "diagnose";
|
|
169
169
|
readonly deprecated: true;
|
|
170
170
|
};
|
|
171
|
+
readonly 'guardrail explain': {
|
|
172
|
+
readonly handler: (ctx: CommandContext) => Promise<string>;
|
|
173
|
+
readonly description: "Dry-run: show what the guardrails would do to a command or write target (executes nothing)";
|
|
174
|
+
readonly category: "diagnostics";
|
|
175
|
+
readonly toolPolicy: "agent";
|
|
176
|
+
readonly toolNoArgs: false;
|
|
177
|
+
};
|
|
178
|
+
readonly 'guardrail-log': {
|
|
179
|
+
readonly handler: (ctx: CommandContext) => Promise<string>;
|
|
180
|
+
readonly description: "Read the guardrail decision log (use --blocks-only for blocks)";
|
|
181
|
+
readonly category: "diagnostics";
|
|
182
|
+
readonly toolPolicy: "agent";
|
|
183
|
+
readonly toolNoArgs: false;
|
|
184
|
+
};
|
|
171
185
|
readonly preflight: {
|
|
172
186
|
readonly handler: (ctx: CommandContext) => Promise<string>;
|
|
173
187
|
readonly description: "Run preflight automation checks";
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified Guardrail Decision Audit Log
|
|
3
|
+
*
|
|
4
|
+
* Additive JSONL schema for guardrail decisions. Each append writes one
|
|
5
|
+
* validated JSON line to the configured audit path under `.swarm/session/`.
|
|
6
|
+
*
|
|
7
|
+
* The existing shell audit entry shape is preserved byte-for-byte when
|
|
8
|
+
* `type: 'shell'` is used (fields: ts, sessionID, agent, tool, command).
|
|
9
|
+
*
|
|
10
|
+
* Path redaction: there is no cross-cutting path-redaction helper in this
|
|
11
|
+
* module today. Callers MAY pass a pre-redacted path via `redactPath(...)`
|
|
12
|
+
* before constructing the entry; the module itself does not mutate path
|
|
13
|
+
* strings beyond normalizing separators. Future hardening: add a shared
|
|
14
|
+
* path-redaction utility and call it here.
|
|
15
|
+
*/
|
|
16
|
+
import * as fs from 'node:fs/promises';
|
|
17
|
+
export declare const _internals: {
|
|
18
|
+
mkdir: typeof fs.mkdir;
|
|
19
|
+
appendFile: typeof fs.appendFile;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Discriminated union of guardrail decision types.
|
|
23
|
+
*
|
|
24
|
+
* Invariants:
|
|
25
|
+
* - `ts` is an ISO-8601 datetime string.
|
|
26
|
+
* - `sessionID` is the swarm session identifier.
|
|
27
|
+
* - `agent` is the role string (e.g. "architect", "coder").
|
|
28
|
+
* - `tool` is the original tool name as invoked.
|
|
29
|
+
*/
|
|
30
|
+
export type GuardrailDecisionType = 'shell' | 'file_write' | 'scope_violation' | 'destructive_block' | 'sandbox_wrap' | 'sandbox_skip';
|
|
31
|
+
export interface ShellDecision {
|
|
32
|
+
type: 'shell';
|
|
33
|
+
ts: string;
|
|
34
|
+
sessionID: string;
|
|
35
|
+
agent: string;
|
|
36
|
+
tool: string;
|
|
37
|
+
command: string;
|
|
38
|
+
}
|
|
39
|
+
export interface FileWriteDecision {
|
|
40
|
+
type: 'file_write';
|
|
41
|
+
ts: string;
|
|
42
|
+
sessionID: string;
|
|
43
|
+
agent: string;
|
|
44
|
+
tool: string;
|
|
45
|
+
path: string;
|
|
46
|
+
reason: string;
|
|
47
|
+
resolvedScope: string;
|
|
48
|
+
}
|
|
49
|
+
export interface ScopeViolationDecision {
|
|
50
|
+
type: 'scope_violation';
|
|
51
|
+
ts: string;
|
|
52
|
+
sessionID: string;
|
|
53
|
+
agent: string;
|
|
54
|
+
tool: string;
|
|
55
|
+
path: string;
|
|
56
|
+
declaredScope: string;
|
|
57
|
+
resolvedScope: string;
|
|
58
|
+
action: string;
|
|
59
|
+
}
|
|
60
|
+
export interface DestructiveBlockDecision {
|
|
61
|
+
type: 'destructive_block';
|
|
62
|
+
ts: string;
|
|
63
|
+
sessionID: string;
|
|
64
|
+
agent: string;
|
|
65
|
+
tool: string;
|
|
66
|
+
command: string;
|
|
67
|
+
destructiveCategory: string;
|
|
68
|
+
}
|
|
69
|
+
export interface SandboxWrapDecision {
|
|
70
|
+
type: 'sandbox_wrap';
|
|
71
|
+
ts: string;
|
|
72
|
+
sessionID: string;
|
|
73
|
+
agent: string;
|
|
74
|
+
tool: string;
|
|
75
|
+
command: string;
|
|
76
|
+
executorMechanism: string;
|
|
77
|
+
}
|
|
78
|
+
export interface SandboxSkipDecision {
|
|
79
|
+
type: 'sandbox_skip';
|
|
80
|
+
ts: string;
|
|
81
|
+
sessionID: string;
|
|
82
|
+
agent: string;
|
|
83
|
+
tool: string;
|
|
84
|
+
command: string;
|
|
85
|
+
executorMechanism: string;
|
|
86
|
+
skipReason: string;
|
|
87
|
+
}
|
|
88
|
+
export type GuardrailDecisionEntry = ShellDecision | FileWriteDecision | ScopeViolationDecision | DestructiveBlockDecision | SandboxWrapDecision | SandboxSkipDecision;
|
|
89
|
+
/**
|
|
90
|
+
* Best-effort path redaction for audit logs.
|
|
91
|
+
*
|
|
92
|
+
* Replaces leading home/profile segments with a tilde placeholder so
|
|
93
|
+
* absolute paths do not leak user-specific directory names.
|
|
94
|
+
*
|
|
95
|
+
* This is intentionally minimal — callers remain responsible for
|
|
96
|
+
* stripping any domain-specific secrets that may appear in path segments.
|
|
97
|
+
*/
|
|
98
|
+
export declare function redactPath(filePath: string): string;
|
|
99
|
+
export interface AppendGuardrailDecisionOptions {
|
|
100
|
+
auditPath: string;
|
|
101
|
+
enabled: boolean;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Append a validated guardrail decision entry to the JSONL audit log.
|
|
105
|
+
*
|
|
106
|
+
* - Writes exactly one JSON line per call (`JSON.stringify(entry) + '\n'`).
|
|
107
|
+
* - Skips silently when `enabled` is false.
|
|
108
|
+
* - Skips malformed entries after debug logging; never throws.
|
|
109
|
+
* - `.swarm/` containment is enforced by the caller-supplied `auditPath`.
|
|
110
|
+
*
|
|
111
|
+
* @param entry Decision entry to persist.
|
|
112
|
+
* @param ctx Audit destination and enablement flag.
|
|
113
|
+
*/
|
|
114
|
+
export declare function appendGuardrailDecision(entry: GuardrailDecisionEntry, ctx: AppendGuardrailDecisionOptions): Promise<void>;
|