@fro.bot/systematic 3.27.0 → 3.27.2

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/ATTRIBUTIONS.md CHANGED
@@ -272,7 +272,7 @@ The following is the full Apache License, Version 2.0 text, reproduced here in c
272
272
  ## vercel-labs/agent-browser — Apache-2.0
273
273
 
274
274
  **Source repository:** [`vercel-labs/agent-browser`](https://github.com/vercel-labs/agent-browser)
275
- **Pinned version:** `v0.39.2` (npm `agent-browser@0.39.2`)
275
+ **Pinned version:** `v0.39.3` (npm `agent-browser@0.39.3`)
276
276
  **License:** Apache-2.0
277
277
  **Copyright:** Copyright 2025 Vercel Inc.
278
278
 
@@ -296,7 +296,7 @@ This is fully automated — no human adaptation pass is required, in contrast to
296
296
 
297
297
  ### Upstream Apache-2.0 license text
298
298
 
299
- The following is the full Apache License, Version 2.0 text from `agent-browser@0.39.2`, reproduced here in compliance with the license's notice requirements:
299
+ The following is the full Apache License, Version 2.0 text from `agent-browser@0.39.3`, reproduced here in compliance with the license's notice requirements:
300
300
 
301
301
  ```
302
302
  Apache License
package/HARNESSES.md CHANGED
@@ -41,7 +41,7 @@ Each v2 mechanism was chosen by a probe against OpenCode 2.2.0 on 2026-10-27. Th
41
41
  | Native skill tool | Partial | The host tool loads plugin-added skills and refuses denied ones, but takes only an `{id}`, so `$ARGUMENTS` cannot be passed. `systematic_skill` is ported | [OC2-SKILL] |
42
42
  | Plugin tool registration | Passed | `ctx.tool.transform` with a JSON Schema input and `options: {codemode: false}` (the default registration is reachable only through Code Mode) | [OC2-TOOL] |
43
43
  | Output truncation | Truncates | The host cuts tool output at 2000 lines or 51200 bytes after the plugin's `execute.after` hook sees the full text. The full text is kept by call id and put back in the `context` hook; nothing depends on the marker text | [OC2-TRUNC] |
44
- | Commands | Passed, with constraints | `ctx.command.transform`; a plugin command receives only the typed text and does its own expansion; routing is not offered to plugin commands, so a command that declares `agent`, `model` or `subtask` is refused; a name that matches a built-in replaces it | [OC2-CMD] |
44
+ | Commands | Passed, with constraints | `ctx.command.transform`; a plugin command receives only the typed text and does its own expansion; routing is not offered to plugin commands, so a bundled command that declares `agent`, `model` or `subtask` is refused, while a discovered skill's fields are dropped with a note; a name that matches a built-in replaces it | [OC2-CMD] |
45
45
  | Apply order | Documented | Plugin transforms run first, then user config and discovered sources; `reload()` replays transforms on a fresh editor and does not re-run `setup` | [OC2-ORDER] |
46
46
  | Error handling | Documented | A rejected `setup` leaves the plugin unloaded and the host running; a throwing transform disables the whole plugin; a throwing hook breaks the turn. Every callback is guarded, and invalid config rejects `setup` as it throws on v1 | [OC2-ERR] |
47
47
  | Project directory | Documented | `ctx.location.directory` is the project directory (the service's working directory is not); each location gets a fresh module instance and its own `setup` | [OC2-TRUST] |
@@ -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:215-226` (`loadSkillAsCommand`), `:517-536` (bundled skills as `systematic:<name>` commands), `:538-603` (discovered skills as commands); `src/lib/config-handler.ts:250-260` (`registerSkillsPaths`, the v1 skill path); `src/lib/config-handler.ts:160-243` (the v1 config hook that writes the plan into the host config).
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).
@@ -215,7 +215,7 @@ Migrated-skill discipline is enforced by the [content-integrity gate](scripts/co
215
215
  - **OC2-SKILL** — CI job `Host Contract v2 shard N/4` (OpenCode 2.2.0): `tests/integration/opencode-v2.test.ts` › "the native skill tool sees the registered bundled skills, and not a disabled one" and "an on-disk skill with the same id replaces the registered one in the native tool, with no diagnostic". Local probe, OpenCode 2.2.0, 2026-10-27: the native tool refuses denied skills per agent, including in subagents; `<available_skills>` lists only the skills the agent may load; the permission resource is the skill id; an inline skill's base directory is `dirname(path)`; the tool takes only `{id}`, so `$ARGUMENTS` stays literal.
216
216
  - **OC2-TOOL** — CI job `Host Contract v2 shard N/4` (OpenCode 2.2.0): `tests/integration/opencode-v2.test.ts` › "systematic_skill is offered to the model and loads an enabled skill by bare and prefixed name", "arguments are substituted into the skill the model receives" and "a skill in disabled_skills is refused by systematic_skill". Local probe, OpenCode 2.2.0, 2026-10-27: a plugin tool takes a JSON Schema input; the default registration is reachable only through Code Mode, and `options: {codemode: false}` makes it a direct tool (`pinned: true` did not).
217
217
  - **OC2-TRUNC** — CI job `Host Contract v2 shard N/4` (OpenCode 2.2.0): `tests/integration/opencode-v2.test.ts` › "a skill above the host output limit reaches the model in full on the continuation request and later turns" and "a discovered project skill above the host output limit reaches the model whole as a command, with its arguments". Local probe, OpenCode 2.2.0, 2026-10-27: tool output over 2000 lines or 51200 bytes is cut after the plugin's `execute.after` hook has seen the full text, with a trailing `[showing lines a-b of N; full output saved to <path>]` part; the bundled `ce-review`, `ce-plan` and `ce-compound-refresh` skills are over the limit. Restoration matches the tool result by call id and does not read the marker. v2 has no runtime prune placeholder: `[Old tool result content cleared]` exists only in the v1-to-v2 migration converter, so v1's compacted-result restore has no v2 counterpart.
218
- - **OC2-CMD** — CI job `Host Contract v2 shard N/4` (OpenCode 2.2.0): `tests/integration/opencode-v2.test.ts` › "a command with $ARGUMENTS reaches the model expanded, on the invoking session as it is", "a command that declares agent is refused with a message and nothing is prompted" (and the same for `model` and `subtask`), "a !-backtick block in a command stays literal text in the prompt", "the command names and descriptions match the v1 set" and "a discovered skill named like a built-in command is skipped and the built-in stays". Local probe, OpenCode 2.2.0, 2026-10-27: a plugin command receives `{sessionID, prompt: {text, files, agents, skills}, delivery}` with the raw typed text; `prompt` takes no agent or model; `switchAgent` to an unregistered agent succeeds and the next turn fails; a plugin command named like a built-in replaces it; the command editor has only `add`; a throwing `execute` makes `session.command` reject with `CommandExecutionError` and leaves the plugin loaded. A session created with no agent or model reports neither from `session.get`, even after a turn; it runs on the host's default agent (`build` here) and the model `model.default` returns. `switchAgent` and `switchModel` make a session's choice explicit and persistent, and no call clears it; the host also reads a session's agent and model for every model request, so a switch made during a running turn changes that turn's later requests. Because of those three facts a plugin command cannot route without leaving the user's session changed or racing a running turn, so Systematic does not route: a command whose plan declares `agent`, `model` or `subtask` is refused with a message that points to an OpenCode command in Markdown or JSON. Only bundled skills can declare those fields (discovered skills drop them on both hosts), and no bundled skill does.
218
+ - **OC2-CMD** — CI job `Host Contract v2 shard N/4` (OpenCode 2.2.0): `tests/integration/opencode-v2.test.ts` › "a command with $ARGUMENTS reaches the model expanded, on the invoking session as it is", "a command that declares agent is refused with a message and nothing is prompted" (and the same for `model` and `subtask`), "a !-backtick block in a command stays literal text in the prompt", "the command names and descriptions match the v1 set" and "a discovered skill named like a built-in command is skipped and the built-in stays". Local probe, OpenCode 2.2.0, 2026-10-27: a plugin command receives `{sessionID, prompt: {text, files, agents, skills}, delivery}` with the raw typed text; `prompt` takes no agent or model; `switchAgent` to an unregistered agent succeeds and the next turn fails; a plugin command named like a built-in replaces it; the command editor has only `add`; a throwing `execute` makes `session.command` reject with `CommandExecutionError` and leaves the plugin loaded. A session created with no agent or model reports neither from `session.get`, even after a turn; it runs on the host's default agent (`build` here) and the model `model.default` returns. `switchAgent` and `switchModel` make a session's choice explicit and persistent, and no call clears it; the host also reads a session's agent and model for every model request, so a switch made during a running turn changes that turn's later requests. Because of those three facts a plugin command cannot route without leaving the user's session changed or racing a running turn, so Systematic does not route: a command whose plan declares `agent`, `model` or `subtask` is refused with a message that points to an OpenCode command in Markdown or JSON. Only bundled skills can reach that refusal, and no bundled skill declares those fields. A discovered skill is never refused: its fields are dropped with one note per skill (`tests/unit/opencode-v2-commands.test.ts` › "a discovered skill that declares routing"; `tests/integration/opencode-v2.test.ts` › "a discovered skill that declares routing is not refused"). On OpenCode v1 the same skill's `subtask` passes through, `agent` passes only for a subtask that names a known agent, and `model` passes only as `provider/model`; anything else is dropped with a warning (`tests/unit/config-handler.test.ts` › "routing fields").
219
219
  - **OC2-ORDER** — CI job `Host Contract v2 shard N/4` (OpenCode 2.2.0): `tests/integration/opencode-v2.test.ts` › "a user agent with the same id in config keeps the user system prompt" and "an on-disk skill with the same id replaces the registered one in the native tool, with no diagnostic" (user config and disk sources win over plugin transforms); `tests/unit/opencode-v2.test.ts` › "agents installer" › "replaying the transform on a fresh editor yields the same single agent set" (replay on a fresh editor). Local probe, OpenCode 2.2.0, 2026-10-27: plugins apply in config order and see earlier plugins' edits; `reload()` replays transforms and does not re-run `setup`.
220
220
  - **OC2-ERR** — CI job `Host Contract v2 shard N/4` (OpenCode 2.2.0): `tests/integration/opencode-v2.test.ts` › "invalid systematic.json fails the plugin load, is logged, and the session still answers" and "a command that declares %s is refused with a message and nothing is prompted" (a `systematic:` diagnostic reaches the server's standard error); `tests/unit/opencode-v2.test.ts` › "createSafeGuard". Local probe, OpenCode 2.2.0, 2026-10-27: a rejected `setup` leaves the plugin unloaded with one `WARN failed to load plugin` and the host and other plugins unaffected; a throwing transform disables the whole plugin; a throwing `prompt` hook returns HTTP 500; a throwing `context` hook fails the turn; a throwing `execute.before` or `execute.after` turns the tool result into an error; `console.error` reaches only the server's standard error.
221
221
  - **OC2-TRUST** — CI job `Host Contract v2 shard N/4` (OpenCode 2.2.0): `tests/integration/opencode-v2.test.ts` › "the packed plugin loads, setup runs once and stderr carries nothing unexpected" and every test that writes a project `.opencode/systematic.json`, such as "a skill in disabled_skills is refused by systematic_skill". Local probe, OpenCode 2.2.0, 2026-10-27: `ctx.location.directory` is the project directory and `ctx.location.project` has `id`, `directory` and `canonical`; one shared service creates one plugin instance per location, with a fresh module instance and its own `setup`; project config plugins load with no trust prompt.
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({ permission, pattern, setting });
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) {
@@ -665,8 +670,17 @@ function loadDiscoveredSkillAsCommand(skill) {
665
670
  description
666
671
  };
667
672
  }
673
+ function declaredRoutingOf(skill) {
674
+ const { agent, model, subtask } = skill.frontmatter;
675
+ return {
676
+ ...agent === undefined ? {} : { agent },
677
+ ...model === undefined ? {} : { model },
678
+ ...subtask === undefined ? {} : { subtask }
679
+ };
680
+ }
668
681
  function collectDiscoveredSkillsAsCommands(startDir, homeDir, configDir, opencodeConfigDirOverride, disabledCommands) {
669
682
  const commands = {};
683
+ const routing = {};
670
684
  let discovered;
671
685
  try {
672
686
  discovered = discoverSkills({
@@ -676,7 +690,7 @@ function collectDiscoveredSkillsAsCommands(startDir, homeDir, configDir, opencod
676
690
  opencodeConfigDirOverride
677
691
  });
678
692
  } catch {
679
- return commands;
693
+ return { commands, routing };
680
694
  }
681
695
  for (const skill of discovered) {
682
696
  if (skill.frontmatter.userInvocable === false)
@@ -685,9 +699,12 @@ function collectDiscoveredSkillsAsCommands(startDir, homeDir, configDir, opencod
685
699
  continue;
686
700
  try {
687
701
  commands[skill.name] = loadDiscoveredSkillAsCommand(skill);
702
+ const declared = declaredRoutingOf(skill);
703
+ if (Object.keys(declared).length > 0)
704
+ routing[skill.name] = declared;
688
705
  } catch {}
689
706
  }
690
- return commands;
707
+ return { commands, routing };
691
708
  }
692
709
  function collectEnabledSkillNames(dir, disabledSkills) {
693
710
  const disabledSet = new Set(disabledSkills);
@@ -708,7 +725,7 @@ function buildAssetPlan(input) {
708
725
  const resolvedOverlays = resolveAgentOverlaySet(validatedOverlays);
709
726
  const agents = collectAgents(bundledAgentsDir, config.disabled_agents, nativeAgentNames, resolvedOverlays, overlays);
710
727
  const bundledCommands = collectCommands(input.bundledCommandsDir, config.disabled_commands);
711
- const discoveredSkillCommands = config.skills_as_commands !== false ? collectDiscoveredSkillsAsCommands(input.directory, input.homeDir, input.opencodeConfigDir, input.opencodeConfigDirOverride, config.disabled_commands) : {};
728
+ const discovered = config.skills_as_commands !== false ? collectDiscoveredSkillsAsCommands(input.directory, input.homeDir, input.opencodeConfigDir, input.opencodeConfigDirOverride, config.disabled_commands) : { commands: {}, routing: {} };
712
729
  return {
713
730
  skillsDir: bundledSkillsDir,
714
731
  enabledSkills,
@@ -716,8 +733,9 @@ function buildAssetPlan(input) {
716
733
  commands: {
717
734
  ...bundledCommands,
718
735
  ...skillCommands,
719
- ...discoveredSkillCommands
720
- }
736
+ ...discovered.commands
737
+ },
738
+ discoveredRouting: discovered.routing
721
739
  };
722
740
  }
723
741
 
@@ -745,13 +763,30 @@ function mergeSystematicEntries(existing, emitted, shouldDropExisting) {
745
763
  return merged;
746
764
  }
747
765
  function foldPermissionRulesToV1Map(rules) {
766
+ const explicitSkillSettings = new Map;
767
+ for (const rule of rules) {
768
+ if (rule.permission === "skill" && !rule.fromSkillsList) {
769
+ explicitSkillSettings.set(rule.pattern, rule.setting);
770
+ }
771
+ }
748
772
  const byPermission = new Map;
749
- for (const { permission, pattern, setting } of rules) {
773
+ const setRule = (permission, pattern, setting) => {
750
774
  const patterns = byPermission.get(permission) ?? new Map;
751
775
  if (patterns.has(pattern))
752
776
  patterns.delete(pattern);
753
777
  patterns.set(pattern, setting);
754
778
  byPermission.set(permission, patterns);
779
+ };
780
+ for (const { permission, pattern, setting, fromSkillsList } of rules) {
781
+ setRule(permission, pattern, setting);
782
+ if (permission !== "skill" || setting !== "allow" || !fromSkillsList) {
783
+ continue;
784
+ }
785
+ const prefixed = formatSkillCommandName(pattern);
786
+ const explicit = explicitSkillSettings.get(prefixed);
787
+ if (prefixed !== pattern && (explicit ?? "allow") === "allow") {
788
+ setRule(permission, prefixed, setting);
789
+ }
755
790
  }
756
791
  const folded = {};
757
792
  for (const [permission, patterns] of byPermission) {
@@ -771,11 +806,71 @@ function toV1AgentConfig(planned) {
771
806
  }
772
807
  return result;
773
808
  }
809
+ var OPENCODE_V1_BUILT_IN_AGENTS = [
810
+ "build",
811
+ "plan",
812
+ "general",
813
+ "explore"
814
+ ];
815
+ function knownAgentNames(agents) {
816
+ const known = new Set(OPENCODE_V1_BUILT_IN_AGENTS);
817
+ for (const [name, agent] of Object.entries(agents ?? {})) {
818
+ if (agent?.disable === true)
819
+ known.delete(name);
820
+ else
821
+ known.add(name);
822
+ }
823
+ return known;
824
+ }
825
+ function agentProblem(agent, isSubtask, known) {
826
+ if (!isSubtask) {
827
+ return `sets agent "${agent}" but does not run as a subtask (context: fork or subtask: true)`;
828
+ }
829
+ return known.has(agent) ? undefined : `sets agent "${agent}", which is not an OpenCode agent`;
830
+ }
831
+ function modelProblem(model) {
832
+ const slash = model.indexOf("/");
833
+ return slash > 0 && slash < model.length - 1 ? undefined : `sets model "${model}", which is not in provider/model form`;
834
+ }
835
+ var IGNORED_ROUTING_HINT = "it is ignored. Write an OpenCode command to route it.";
836
+ function applyDiscoveredRouting(config, plan, reported) {
837
+ const known = knownAgentNames(config.agent);
838
+ const drop = (name, field, reason) => {
839
+ const key = `${name}\x00${field}`;
840
+ if (reported.has(key))
841
+ return;
842
+ reported.add(key);
843
+ console.warn(`[systematic] skill "${name}" ${reason}; ${IGNORED_ROUTING_HINT}`);
844
+ };
845
+ for (const [name, declared] of Object.entries(plan.discoveredRouting)) {
846
+ const command = config.command?.[name];
847
+ if (command === undefined || command !== plan.commands[name])
848
+ continue;
849
+ const { agent, model, subtask } = declared;
850
+ if (agent !== undefined) {
851
+ const problem = agentProblem(agent, subtask === true, known);
852
+ if (problem === undefined)
853
+ command.agent = agent;
854
+ else
855
+ drop(name, "agent", problem);
856
+ }
857
+ if (model !== undefined) {
858
+ const problem = modelProblem(model);
859
+ if (problem === undefined)
860
+ command.model = model;
861
+ else
862
+ drop(name, "model", problem);
863
+ }
864
+ if (subtask !== undefined)
865
+ command.subtask = subtask;
866
+ }
867
+ }
774
868
  function createConfigHandler(deps) {
775
869
  const { directory, bundledSkillsDir, bundledAgentsDir, bundledCommandsDir } = deps;
776
870
  const homeDir = deps.homeDir ?? os2.homedir();
777
871
  const opencodeConfigDir = deps.opencodeConfigDir ?? path4.join(homeDir, ".config/opencode");
778
872
  const opencodeConfigDirOverride = process.env.OPENCODE_CONFIG_DIR?.trim() ? process.env.OPENCODE_CONFIG_DIR : undefined;
873
+ const reportedRouting = new Set;
779
874
  return async (config) => {
780
875
  const { config: systematicConfig, overlays } = loadConfigWithSources(directory);
781
876
  const existingAgents = { ...config.agent ?? {} };
@@ -800,9 +895,59 @@ function createConfigHandler(deps) {
800
895
  const bundledAgentKeys = new Set(Object.keys(bundledAgents));
801
896
  config.agent = mergeSystematicEntries(existingAgents, bundledAgents, (key, agent) => bundledAgentKeys.has(key) && isSystematicAgentConfig(agent));
802
897
  config.command = mergeSystematicEntries(existingCommands, plan.commands, (_key, command) => isSystematicCommandConfig(command));
898
+ applyDiscoveredRouting(config, plan, reportedRouting);
803
899
  registerSkillsPaths(config, plan.skillsDir);
900
+ denyDisabledSkills(config, systematicConfig.disabled_skills);
804
901
  };
805
902
  }
903
+ var ownedSkillDenies = new WeakMap;
904
+ function readPermissionMap(host) {
905
+ if (isRecord(host.permission))
906
+ return host.permission;
907
+ return typeof host.permission === "string" ? { "*": host.permission } : {};
908
+ }
909
+ function readSkillRuleMap(permission) {
910
+ if (isRecord(permission.skill))
911
+ return permission.skill;
912
+ return typeof permission.skill === "string" ? { "*": permission.skill } : {};
913
+ }
914
+ function skillDenyPatterns(skills) {
915
+ return [...new Set(skills.flatMap((s) => [s, formatSkillCommandName(s)]))];
916
+ }
917
+ function denyDisabledSkills(config, disabledSkills) {
918
+ const host = config;
919
+ const owned = ownedSkillDenies.get(config);
920
+ const current = isRecord(host.permission) ? host.permission : undefined;
921
+ const stillOurs = owned !== undefined && owned.permission === current && owned.skill === current.skill;
922
+ const previous = stillOurs ? owned.patterns : [];
923
+ const wanted = skillDenyPatterns(disabledSkills);
924
+ if (previous.length === 0 && wanted.length === 0) {
925
+ ownedSkillDenies.delete(config);
926
+ return;
927
+ }
928
+ const permission = readPermissionMap(host);
929
+ const skill = readSkillRuleMap(permission);
930
+ for (const pattern of previous) {
931
+ if (skill[pattern] === "deny")
932
+ delete skill[pattern];
933
+ }
934
+ const added = wanted.filter((pattern) => !Object.hasOwn(skill, pattern));
935
+ for (const pattern of added)
936
+ skill[pattern] = "deny";
937
+ if (Object.keys(skill).length > 0)
938
+ permission.skill = skill;
939
+ else
940
+ delete permission.skill;
941
+ if (Object.keys(permission).length > 0)
942
+ host.permission = permission;
943
+ else
944
+ delete host.permission;
945
+ if (added.length > 0) {
946
+ ownedSkillDenies.set(config, { permission, skill, patterns: added });
947
+ } else {
948
+ ownedSkillDenies.delete(config);
949
+ }
950
+ }
806
951
  function registerSkillsPaths(config, skillsDir) {
807
952
  const extended = config;
808
953
  const paths = extended.skills?.paths ?? [];
@@ -1356,6 +1501,10 @@ function declaredRouting(planned) {
1356
1501
  function refusalMessage(name, field) {
1357
1502
  return `Systematic command "${name}" declares ${field}, which OpenCode v2 plugin commands cannot route. Define it as an OpenCode command in Markdown or JSON to choose its agent or model.`;
1358
1503
  }
1504
+ function ignoredRoutingMessage(name, declared) {
1505
+ const fields = ["agent", "model", "subtask"].filter((field) => declared[field] !== undefined);
1506
+ return `skill "${name}" declares ${fields.join(", ")}, which OpenCode v2 plugin commands cannot route; it is ignored and the skill runs as it is. Write an OpenCode command in Markdown or JSON to route it.`;
1507
+ }
1359
1508
  async function submit(runtime, planned, invocation) {
1360
1509
  const text = substituteSkillArguments(planned.template, invocation.prompt.text);
1361
1510
  const { files, agents, skills } = invocation.prompt;
@@ -1405,6 +1554,10 @@ var installCommands = async ({
1405
1554
  guard.sync(`command "${name}"`, () => {
1406
1555
  editor.add(buildCommand(runtime, name, planned));
1407
1556
  })();
1557
+ const declared = snapshot.plan.discoveredRouting[name];
1558
+ if (declared !== undefined) {
1559
+ reportOnce(runtime, `ignored-routing:${name}`, ignoredRoutingMessage(name, declared));
1560
+ }
1408
1561
  }
1409
1562
  });
1410
1563
  await guard.async("command registration", () => ctx.command.transform(transform))();
@@ -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.
@@ -52,6 +60,17 @@ export interface PlannedCommand {
52
60
  model?: string;
53
61
  subtask?: boolean;
54
62
  }
63
+ /**
64
+ * Routing fields a discovered skill declared in its frontmatter, as written.
65
+ * Discovered skills are the user's own and are often written for other agent
66
+ * harnesses, so the values are not trusted: each host decides what to do with
67
+ * them.
68
+ */
69
+ export interface DeclaredRouting {
70
+ agent?: string;
71
+ model?: string;
72
+ subtask?: boolean;
73
+ }
55
74
  export interface AssetPlan {
56
75
  /** Bundled skills directory, for hosts that register it for native discovery. */
57
76
  skillsDir: string;
@@ -59,8 +78,19 @@ export interface AssetPlan {
59
78
  enabledSkills: readonly string[];
60
79
  /** Agents keyed by emitted agent name, in discovery order. */
61
80
  agents: Record<string, PlannedAgent>;
62
- /** Commands keyed by emitted command name: bundled commands, then skills, then discovered skills. */
81
+ /**
82
+ * Commands keyed by emitted command name: bundled commands, then skills,
83
+ * then discovered skills. A discovered command never carries `agent`,
84
+ * `model` or `subtask`; see `discoveredRouting`.
85
+ */
63
86
  commands: Record<string, PlannedCommand>;
87
+ /**
88
+ * What each discovered skill declared, keyed by its command name. Only
89
+ * skills that declare at least one routing field, and whose command is in
90
+ * `commands`, are listed. A host that can route validates these and applies
91
+ * what is valid; a host that cannot reports them.
92
+ */
93
+ discoveredRouting: Record<string, DeclaredRouting>;
64
94
  }
65
95
  export interface AssetPlanInput {
66
96
  /** Loaded Systematic config. The builder reads only the disabled lists and `skills_as_commands`. */
@@ -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 { PermissionSetting } from './validation.js';
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
  /**
@@ -13,9 +13,10 @@ import type { V2Installer } from './opencode-v2.js';
13
13
  *
14
14
  * It does not route. A v2 plugin command cannot choose an agent or a model for
15
15
  * its prompt, and switching the session around the turn leaves the user's
16
- * session changed. A command that declares `agent`, `model` or `subtask` is
17
- * refused with a message instead; OpenCode commands written in Markdown or JSON
18
- * can do that routing.
16
+ * session changed. A bundled command that declares `agent`, `model` or
17
+ * `subtask` is refused with a message instead; OpenCode commands written in
18
+ * Markdown or JSON can do that routing. A discovered skill is never refused: its
19
+ * routing fields are dropped with a note and it runs on the invoking session.
19
20
  */
20
21
  type CommandEditor = Parameters<Parameters<Plugin.Context['command']['transform']>[0]>[0];
21
22
  export type V2CommandDefinition = Parameters<CommandEditor['add']>[0];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fro.bot/systematic",
3
- "version": "3.27.0",
3
+ "version": "3.27.2",
4
4
  "description": "Compound-engineering loops for OpenCode, Pi, and Claude Code",
5
5
  "type": "module",
6
6
  "homepage": "https://fro.bot/systematic",
@@ -127,7 +127,7 @@
127
127
  "@types/bun": "latest",
128
128
  "@types/js-yaml": "4.0.9",
129
129
  "@types/node": "26.6.5",
130
- "agent-browser": "0.39.2",
130
+ "agent-browser": "0.39.3",
131
131
  "ajv": "8.20.0",
132
132
  "ajv-formats": "3.0.1",
133
133
  "conventional-changelog-conventionalcommits": "10.4.1",