opencode-swarm 6.56.0 → 6.57.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 +43 -0
- package/dist/cli/index.js +4 -1
- package/dist/config/schema.d.ts +9 -0
- package/dist/hooks/guardrails.d.ts +3 -0
- package/dist/index.js +2049 -11
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -689,8 +689,11 @@ Override default rules in `.opencode/opencode-swarm.json`:
|
|
|
689
689
|
|-------|------|-------------|
|
|
690
690
|
| `readOnly` | boolean | If `true`, agent cannot write anywhere |
|
|
691
691
|
| `blockedExact` | string[] | Exact file paths that are blocked |
|
|
692
|
+
| `allowedExact` | string[] | Exact file paths that are allowed (overrides prefix/glob restrictions) |
|
|
692
693
|
| `blockedPrefix` | string[] | Path prefixes that are blocked (e.g., `.swarm/`) |
|
|
693
694
|
| `allowedPrefix` | string[] | Only these path prefixes are allowed. Omit to remove restriction; set `[]` to deny all |
|
|
695
|
+
| `blockedGlobs` | string[] | Glob patterns that are blocked (uses picomatch: `**`, `*`, `?`) |
|
|
696
|
+
| `allowedGlobs` | string[] | Glob patterns that are allowed (uses picomatch: `**`, `*`, `?`) |
|
|
694
697
|
| `blockedZones` | string[] | File zones to block: `production`, `test`, `config`, `generated`, `docs`, `build` |
|
|
695
698
|
|
|
696
699
|
### Merge Behavior
|
|
@@ -726,6 +729,46 @@ To safely restrict a custom agent, always set `allowedPrefix` explicitly:
|
|
|
726
729
|
}
|
|
727
730
|
```
|
|
728
731
|
|
|
732
|
+
### Advanced Examples
|
|
733
|
+
|
|
734
|
+
#### Glob Pattern Support
|
|
735
|
+
|
|
736
|
+
Use glob patterns for complex path matching:
|
|
737
|
+
|
|
738
|
+
```json
|
|
739
|
+
{
|
|
740
|
+
"authority": {
|
|
741
|
+
"rules": {
|
|
742
|
+
"coder": {
|
|
743
|
+
"allowedGlobs": ["src/**/*.ts", "tests/**/*.test.ts"],
|
|
744
|
+
"blockedGlobs": ["src/**/*.generated.ts", "**/*.d.ts"],
|
|
745
|
+
"allowedExact": ["src/index.ts", "package.json"]
|
|
746
|
+
},
|
|
747
|
+
"docs_agent": {
|
|
748
|
+
"allowedGlobs": ["docs/**/*.md", "*.md"],
|
|
749
|
+
"blockedExact": [".swarm/plan.md"]
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
```
|
|
755
|
+
|
|
756
|
+
**Glob Pattern Features:**
|
|
757
|
+
- `**` — Match any number of directories: `src/**/*.ts` matches all TypeScript files in src/ and subdirectories
|
|
758
|
+
- `*` — Match any characters except path separators: `*.md` matches all Markdown files in current directory
|
|
759
|
+
- `?` — Match single character: `test?.js` matches `test1.js`, `testa.js`
|
|
760
|
+
- Uses [picomatch](https://github.com/micromatch/picomatch) for cross-platform compatibility
|
|
761
|
+
|
|
762
|
+
**Evaluation Order:**
|
|
763
|
+
1. `readOnly` check (if true, deny all writes)
|
|
764
|
+
2. `blockedExact` (exact path matches, highest priority)
|
|
765
|
+
3. `blockedGlobs` (glob pattern matches)
|
|
766
|
+
4. `allowedExact` (exact path matches, overrides prefix/glob restrictions)
|
|
767
|
+
5. `allowedGlobs` (glob pattern matches)
|
|
768
|
+
6. `allowedPrefix` (prefix matches)
|
|
769
|
+
7. `blockedPrefix` (prefix matches)
|
|
770
|
+
8. `blockedZones` (zone classification)
|
|
771
|
+
|
|
729
772
|
</details>
|
|
730
773
|
|
|
731
774
|
<details>
|
package/dist/cli/index.js
CHANGED
|
@@ -18783,9 +18783,12 @@ var CompactionConfigSchema = exports_external.object({
|
|
|
18783
18783
|
var AgentAuthorityRuleSchema = exports_external.object({
|
|
18784
18784
|
readOnly: exports_external.boolean().optional(),
|
|
18785
18785
|
blockedExact: exports_external.array(exports_external.string()).optional(),
|
|
18786
|
+
allowedExact: exports_external.array(exports_external.string()).optional(),
|
|
18786
18787
|
blockedPrefix: exports_external.array(exports_external.string()).optional(),
|
|
18787
18788
|
allowedPrefix: exports_external.array(exports_external.string()).optional(),
|
|
18788
|
-
blockedZones: exports_external.array(exports_external.enum(["production", "test", "config", "generated", "docs", "build"])).optional()
|
|
18789
|
+
blockedZones: exports_external.array(exports_external.enum(["production", "test", "config", "generated", "docs", "build"])).optional(),
|
|
18790
|
+
blockedGlobs: exports_external.array(exports_external.string()).optional(),
|
|
18791
|
+
allowedGlobs: exports_external.array(exports_external.string()).optional()
|
|
18789
18792
|
});
|
|
18790
18793
|
var AuthorityConfigSchema = exports_external.object({
|
|
18791
18794
|
enabled: exports_external.boolean().default(true),
|
package/dist/config/schema.d.ts
CHANGED
|
@@ -474,6 +474,7 @@ export type CompactionConfig = z.infer<typeof CompactionConfigSchema>;
|
|
|
474
474
|
export declare const AgentAuthorityRuleSchema: z.ZodObject<{
|
|
475
475
|
readOnly: z.ZodOptional<z.ZodBoolean>;
|
|
476
476
|
blockedExact: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
477
|
+
allowedExact: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
477
478
|
blockedPrefix: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
478
479
|
allowedPrefix: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
479
480
|
blockedZones: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
@@ -484,6 +485,8 @@ export declare const AgentAuthorityRuleSchema: z.ZodObject<{
|
|
|
484
485
|
generated: "generated";
|
|
485
486
|
build: "build";
|
|
486
487
|
}>>>;
|
|
488
|
+
blockedGlobs: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
489
|
+
allowedGlobs: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
487
490
|
}, z.core.$strip>;
|
|
488
491
|
export type AgentAuthorityRule = z.infer<typeof AgentAuthorityRuleSchema>;
|
|
489
492
|
export declare const AuthorityConfigSchema: z.ZodObject<{
|
|
@@ -491,6 +494,7 @@ export declare const AuthorityConfigSchema: z.ZodObject<{
|
|
|
491
494
|
rules: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
492
495
|
readOnly: z.ZodOptional<z.ZodBoolean>;
|
|
493
496
|
blockedExact: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
497
|
+
allowedExact: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
494
498
|
blockedPrefix: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
495
499
|
allowedPrefix: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
496
500
|
blockedZones: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
@@ -501,6 +505,8 @@ export declare const AuthorityConfigSchema: z.ZodObject<{
|
|
|
501
505
|
generated: "generated";
|
|
502
506
|
build: "build";
|
|
503
507
|
}>>>;
|
|
508
|
+
blockedGlobs: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
509
|
+
allowedGlobs: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
504
510
|
}, z.core.$strip>>>;
|
|
505
511
|
}, z.core.$strip>;
|
|
506
512
|
export type AuthorityConfig = z.infer<typeof AuthorityConfigSchema>;
|
|
@@ -668,6 +674,7 @@ export declare const PluginConfigSchema: z.ZodObject<{
|
|
|
668
674
|
rules: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
669
675
|
readOnly: z.ZodOptional<z.ZodBoolean>;
|
|
670
676
|
blockedExact: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
677
|
+
allowedExact: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
671
678
|
blockedPrefix: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
672
679
|
allowedPrefix: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
673
680
|
blockedZones: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
@@ -678,6 +685,8 @@ export declare const PluginConfigSchema: z.ZodObject<{
|
|
|
678
685
|
generated: "generated";
|
|
679
686
|
build: "build";
|
|
680
687
|
}>>>;
|
|
688
|
+
blockedGlobs: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
689
|
+
allowedGlobs: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
681
690
|
}, z.core.$strip>>>;
|
|
682
691
|
}, z.core.$strip>>;
|
|
683
692
|
plan_cursor: z.ZodOptional<z.ZodObject<{
|
|
@@ -106,9 +106,12 @@ export declare function validateAndRecordAttestation(dir: string, findingId: str
|
|
|
106
106
|
type AgentRule = {
|
|
107
107
|
readOnly?: boolean;
|
|
108
108
|
blockedExact?: string[];
|
|
109
|
+
allowedExact?: string[];
|
|
109
110
|
blockedPrefix?: string[];
|
|
110
111
|
allowedPrefix?: string[];
|
|
111
112
|
blockedZones?: FileZone[];
|
|
113
|
+
blockedGlobs?: string[];
|
|
114
|
+
allowedGlobs?: string[];
|
|
112
115
|
};
|
|
113
116
|
export declare const DEFAULT_AGENT_AUTHORITY_RULES: Record<string, AgentRule>;
|
|
114
117
|
/**
|