@fro.bot/systematic 3.27.0 → 3.27.1
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/HARNESSES.md +1 -1
- package/dist/index.js +78 -7
- package/dist/lib/asset-plan.d.ts +8 -0
- package/dist/lib/config-handler.d.ts +11 -1
- package/package.json +1 -1
package/HARNESSES.md
CHANGED
|
@@ -200,7 +200,7 @@ Migrated-skill discipline is enforced by the [content-integrity gate](scripts/co
|
|
|
200
200
|
- **OC-1** — cloned OpenCode source, `.slim/clonedeps/repos/anomalyco__opencode/packages/opencode/src/tool/task.ts:24-62`.
|
|
201
201
|
- **OC-2** — cloned OpenCode source, `.slim/clonedeps/repos/anomalyco__opencode/packages/core/src/tool/question.ts:10-25`.
|
|
202
202
|
- **OC-3** — cloned OpenCode source, `.slim/clonedeps/repos/anomalyco__opencode/packages/core/src/tool/todowrite.ts:1-10`.
|
|
203
|
-
- **OC-4** — `src/lib/asset-plan.ts:
|
|
203
|
+
- **OC-4** — `src/lib/asset-plan.ts:223-234` (`loadSkillAsCommand`), `:532-551` (bundled skills as `systematic:<name>` commands), `:553-618` (discovered skills as commands); `src/lib/config-handler.ts:367-377` (`registerSkillsPaths`, the v1 skill path); `src/lib/config-handler.ts:188-274` (the v1 config hook that writes the plan into the host config); `src/lib/config-handler.ts:112-170` (`foldPermissionRulesToV1Map`, which writes each managed skill allow under both the bare and the `systematic:` name unless the user wrote a rule for the prefixed name, because v1's native `skill` tool asks with the bare name and `systematic_skill` with the prefixed one); `src/lib/config-handler.ts:276-360` (`denyDisabledSkills`, the top-level `permission.skill` deny in both name forms for each disabled skill, because the registered skills folder is not filtered). Real v1 host, 1.19.4: `tests/integration/opencode-v1.test.ts` (a managed `skills` list loads through `systematic_skill`; the native `skill` tool refuses a disabled skill).
|
|
204
204
|
- **OC-5** — `src/lib/skill-tool.ts:146-230` (`createSkillTool`, the v1 tool with the `context.ask` permission check at `:198-203`).
|
|
205
205
|
- **OC-6** — `ARCHITECTURE.md:217-223` (invariant 2) and `agents/`.
|
|
206
206
|
- **OC-7** — `src/lib/asset-plan.ts:274-380` (a model reaches an agent only through `applyAgentOverlays`, `applyAgentOverlayPass` and `applyRoutingModel`, all driven by user-owned overlays); `tests/unit/config-handler.test.ts:1173-1330` (overlay model emitted, `model: null` restores inheritance, native same-name replacement stays model-free).
|
package/dist/index.js
CHANGED
|
@@ -602,27 +602,32 @@ function addPermissionRules(accumulator, permission) {
|
|
|
602
602
|
}
|
|
603
603
|
}
|
|
604
604
|
function addManagedSkillRules(accumulator, skills) {
|
|
605
|
-
setPermissionRule(accumulator, "skill", "*", "deny");
|
|
605
|
+
setPermissionRule(accumulator, "skill", "*", "deny", true);
|
|
606
606
|
for (const skill of skills) {
|
|
607
607
|
if (typeof skill === "string") {
|
|
608
|
-
setPermissionRule(accumulator, "skill", skill, "allow");
|
|
608
|
+
setPermissionRule(accumulator, "skill", skill, "allow", true);
|
|
609
609
|
}
|
|
610
610
|
}
|
|
611
611
|
}
|
|
612
612
|
function permissionRulesToTriples(accumulator) {
|
|
613
613
|
const triples = [];
|
|
614
614
|
for (const [permission, rules] of accumulator) {
|
|
615
|
-
for (const [pattern, setting] of rules) {
|
|
616
|
-
triples.push({
|
|
615
|
+
for (const [pattern, { setting, fromSkillsList }] of rules) {
|
|
616
|
+
triples.push({
|
|
617
|
+
permission,
|
|
618
|
+
pattern,
|
|
619
|
+
setting,
|
|
620
|
+
...fromSkillsList && { fromSkillsList: true }
|
|
621
|
+
});
|
|
617
622
|
}
|
|
618
623
|
}
|
|
619
624
|
return triples;
|
|
620
625
|
}
|
|
621
|
-
function setPermissionRule(accumulator, tool, pattern, setting) {
|
|
626
|
+
function setPermissionRule(accumulator, tool, pattern, setting, fromSkillsList = false) {
|
|
622
627
|
const rules = accumulator.get(tool) ?? new Map;
|
|
623
628
|
if (rules.has(pattern))
|
|
624
629
|
rules.delete(pattern);
|
|
625
|
-
rules.set(pattern, setting);
|
|
630
|
+
rules.set(pattern, { setting, fromSkillsList });
|
|
626
631
|
accumulator.set(tool, rules);
|
|
627
632
|
}
|
|
628
633
|
function isPermissionSettingValue(value) {
|
|
@@ -745,13 +750,30 @@ function mergeSystematicEntries(existing, emitted, shouldDropExisting) {
|
|
|
745
750
|
return merged;
|
|
746
751
|
}
|
|
747
752
|
function foldPermissionRulesToV1Map(rules) {
|
|
753
|
+
const explicitSkillSettings = new Map;
|
|
754
|
+
for (const rule of rules) {
|
|
755
|
+
if (rule.permission === "skill" && !rule.fromSkillsList) {
|
|
756
|
+
explicitSkillSettings.set(rule.pattern, rule.setting);
|
|
757
|
+
}
|
|
758
|
+
}
|
|
748
759
|
const byPermission = new Map;
|
|
749
|
-
|
|
760
|
+
const setRule = (permission, pattern, setting) => {
|
|
750
761
|
const patterns = byPermission.get(permission) ?? new Map;
|
|
751
762
|
if (patterns.has(pattern))
|
|
752
763
|
patterns.delete(pattern);
|
|
753
764
|
patterns.set(pattern, setting);
|
|
754
765
|
byPermission.set(permission, patterns);
|
|
766
|
+
};
|
|
767
|
+
for (const { permission, pattern, setting, fromSkillsList } of rules) {
|
|
768
|
+
setRule(permission, pattern, setting);
|
|
769
|
+
if (permission !== "skill" || setting !== "allow" || !fromSkillsList) {
|
|
770
|
+
continue;
|
|
771
|
+
}
|
|
772
|
+
const prefixed = formatSkillCommandName(pattern);
|
|
773
|
+
const explicit = explicitSkillSettings.get(prefixed);
|
|
774
|
+
if (prefixed !== pattern && (explicit ?? "allow") === "allow") {
|
|
775
|
+
setRule(permission, prefixed, setting);
|
|
776
|
+
}
|
|
755
777
|
}
|
|
756
778
|
const folded = {};
|
|
757
779
|
for (const [permission, patterns] of byPermission) {
|
|
@@ -801,8 +823,57 @@ function createConfigHandler(deps) {
|
|
|
801
823
|
config.agent = mergeSystematicEntries(existingAgents, bundledAgents, (key, agent) => bundledAgentKeys.has(key) && isSystematicAgentConfig(agent));
|
|
802
824
|
config.command = mergeSystematicEntries(existingCommands, plan.commands, (_key, command) => isSystematicCommandConfig(command));
|
|
803
825
|
registerSkillsPaths(config, plan.skillsDir);
|
|
826
|
+
denyDisabledSkills(config, systematicConfig.disabled_skills);
|
|
804
827
|
};
|
|
805
828
|
}
|
|
829
|
+
var ownedSkillDenies = new WeakMap;
|
|
830
|
+
function readPermissionMap(host) {
|
|
831
|
+
if (isRecord(host.permission))
|
|
832
|
+
return host.permission;
|
|
833
|
+
return typeof host.permission === "string" ? { "*": host.permission } : {};
|
|
834
|
+
}
|
|
835
|
+
function readSkillRuleMap(permission) {
|
|
836
|
+
if (isRecord(permission.skill))
|
|
837
|
+
return permission.skill;
|
|
838
|
+
return typeof permission.skill === "string" ? { "*": permission.skill } : {};
|
|
839
|
+
}
|
|
840
|
+
function skillDenyPatterns(skills) {
|
|
841
|
+
return [...new Set(skills.flatMap((s) => [s, formatSkillCommandName(s)]))];
|
|
842
|
+
}
|
|
843
|
+
function denyDisabledSkills(config, disabledSkills) {
|
|
844
|
+
const host = config;
|
|
845
|
+
const owned = ownedSkillDenies.get(config);
|
|
846
|
+
const current = isRecord(host.permission) ? host.permission : undefined;
|
|
847
|
+
const stillOurs = owned !== undefined && owned.permission === current && owned.skill === current.skill;
|
|
848
|
+
const previous = stillOurs ? owned.patterns : [];
|
|
849
|
+
const wanted = skillDenyPatterns(disabledSkills);
|
|
850
|
+
if (previous.length === 0 && wanted.length === 0) {
|
|
851
|
+
ownedSkillDenies.delete(config);
|
|
852
|
+
return;
|
|
853
|
+
}
|
|
854
|
+
const permission = readPermissionMap(host);
|
|
855
|
+
const skill = readSkillRuleMap(permission);
|
|
856
|
+
for (const pattern of previous) {
|
|
857
|
+
if (skill[pattern] === "deny")
|
|
858
|
+
delete skill[pattern];
|
|
859
|
+
}
|
|
860
|
+
const added = wanted.filter((pattern) => !Object.hasOwn(skill, pattern));
|
|
861
|
+
for (const pattern of added)
|
|
862
|
+
skill[pattern] = "deny";
|
|
863
|
+
if (Object.keys(skill).length > 0)
|
|
864
|
+
permission.skill = skill;
|
|
865
|
+
else
|
|
866
|
+
delete permission.skill;
|
|
867
|
+
if (Object.keys(permission).length > 0)
|
|
868
|
+
host.permission = permission;
|
|
869
|
+
else
|
|
870
|
+
delete host.permission;
|
|
871
|
+
if (added.length > 0) {
|
|
872
|
+
ownedSkillDenies.set(config, { permission, skill, patterns: added });
|
|
873
|
+
} else {
|
|
874
|
+
ownedSkillDenies.delete(config);
|
|
875
|
+
}
|
|
876
|
+
}
|
|
806
877
|
function registerSkillsPaths(config, skillsDir) {
|
|
807
878
|
const extended = config;
|
|
808
879
|
const paths = extended.skills?.paths ?? [];
|
package/dist/lib/asset-plan.d.ts
CHANGED
|
@@ -23,6 +23,14 @@ export interface PermissionRuleTriple {
|
|
|
23
23
|
permission: string;
|
|
24
24
|
pattern: string;
|
|
25
25
|
setting: PermissionSetting;
|
|
26
|
+
/**
|
|
27
|
+
* Set only when the rule that wins for this pattern was written by a managed
|
|
28
|
+
* `skills` list, not by a permission the user wrote. An adapter can then tell
|
|
29
|
+
* a generated allow from a hand-written one. Only the OpenCode v1 adapter
|
|
30
|
+
* reads it, because only v1 has two skill tools that ask under two names;
|
|
31
|
+
* the other adapters ignore it.
|
|
32
|
+
*/
|
|
33
|
+
fromSkillsList?: true;
|
|
26
34
|
}
|
|
27
35
|
/**
|
|
28
36
|
* Permission state of a planned agent.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Config } from '@opencode-ai/plugin';
|
|
2
2
|
import type { AgentConfig } from '@opencode-ai/sdk';
|
|
3
3
|
import { type PermissionRuleTriple, type PlannedAgent } from './asset-plan.js';
|
|
4
|
-
import type
|
|
4
|
+
import { type PermissionSetting } from './validation.js';
|
|
5
5
|
export { formatAgentDescription, toTitleCase } from './asset-plan.js';
|
|
6
6
|
export interface ConfigHandlerDeps {
|
|
7
7
|
directory: string;
|
|
@@ -60,6 +60,16 @@ export declare function readEmittedAgentPermission(agent: AgentConfig | undefine
|
|
|
60
60
|
* A repeated permission and pattern is last-match-wins and moves to the end,
|
|
61
61
|
* as in the accumulator that produced the list. Returns `undefined` for an
|
|
62
62
|
* empty list.
|
|
63
|
+
*
|
|
64
|
+
* v1 has two skill tools that ask permission under two names: the native
|
|
65
|
+
* `skill` tool with the bare name, `systematic_skill` with `systematic:<name>`.
|
|
66
|
+
* A rule reaches only the tool whose form it uses. A bare allow whose winning
|
|
67
|
+
* rule came from a managed `skills` list (`fromSkillsList`) is followed by the
|
|
68
|
+
* same allow for the prefixed form, so the list reaches both tools. A rule the
|
|
69
|
+
* user wrote by hand is never mirrored, and a mirror never replaces a deny or
|
|
70
|
+
* ask the user wrote for the prefixed name, wherever it sits in the list:
|
|
71
|
+
* explicit rules beat generated ones. A hand-written prefixed allow agrees with
|
|
72
|
+
* the mirror, so the mirror still moves it after the list's `*` deny.
|
|
63
73
|
*/
|
|
64
74
|
export declare function foldPermissionRulesToV1Map(rules: readonly PermissionRuleTriple[]): Record<string, Record<string, PermissionSetting>> | undefined;
|
|
65
75
|
/**
|