@hasna/skills 0.10.83 → 0.10.89

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.
Files changed (35) hide show
  1. package/README.md +166 -15
  2. package/bin/index.js +5829 -2913
  3. package/bin/mcp.js +1766 -835
  4. package/bin/migrate.js +1 -1
  5. package/bin/server.js +1 -1
  6. package/bin/worker.js +1 -1
  7. package/dist/cli/commands/agent-integration.d.ts +55 -0
  8. package/dist/cli/commands/context.d.ts +8 -0
  9. package/dist/cli/commands/runtime-launcher.d.ts +4 -9
  10. package/dist/index.js +3039 -1531
  11. package/dist/lib/agent-adapters.d.ts +5 -2
  12. package/dist/lib/agent-discovery.d.ts +22 -4
  13. package/dist/lib/agent-hermes.d.ts +7 -1
  14. package/dist/lib/agent-integration.d.ts +31 -2
  15. package/dist/lib/agent-opencode.d.ts +4 -0
  16. package/dist/lib/claude-hook-disable.d.ts +32 -0
  17. package/dist/lib/claude-settings-witness.d.ts +28 -0
  18. package/dist/lib/codex-settings-witness.d.ts +20 -0
  19. package/dist/lib/guarded-agent-config.d.ts +3 -0
  20. package/dist/lib/hook-diagnostics.d.ts +3 -1
  21. package/dist/lib/narrowed-witness-ledger.d.ts +24 -0
  22. package/dist/lib/native-discovery-roots.d.ts +8 -0
  23. package/dist/lib/native-drift-receipt.d.ts +55 -0
  24. package/dist/lib/opencode-hook-protocol.d.ts +5 -0
  25. package/dist/lib/profile-client.d.ts +1 -0
  26. package/dist/lib/selection-cache.d.ts +47 -2
  27. package/dist/lib/selection-resolver.d.ts +13 -1
  28. package/dist/lib/session-background-renewal.d.ts +118 -0
  29. package/dist/lib/session-reconciliation.d.ts +82 -2
  30. package/dist/lib/skill-context.d.ts +50 -1
  31. package/dist/lib/skill-relevance.d.ts +95 -0
  32. package/dist/runtime-prerequisites.js +570 -165
  33. package/dist/sdk/index.js +2629 -1396
  34. package/docs/plugin-admission.md +132 -3
  35. package/package.json +1 -1
@@ -408,9 +408,11 @@ What the software currently enforces is narrower:
408
408
  byte witness keeps its meaning. If the root reappears, its sources are
409
409
  checked again.
410
410
  - It is detection-only. Later checks re-hash the stored sources and re-walk any
411
- reviewed `directories` witnesses. Drift makes the
412
- Skills hooks refuse with `NATIVE_SKILL_DRIFT`; it does not stop, unload or
413
- sandbox plugin code, which the native client keeps running.
411
+ reviewed `directories` witnesses. Drift makes the live
412
+ Skills hooks report `NATIVE_SKILL_DRIFT` (a warning, the Skills context
413
+ omitted for that turn and a drift receipt) without blocking the prompt;
414
+ install, trust and migration refuse it. It does not stop, unload or sandbox
415
+ plugin code, which the native client keeps running.
414
416
  - It is a tripwire, not a security boundary. A process running as the same user
415
417
  can rewrite the plugin files and the managed policy that holds the witnesses.
416
418
 
@@ -661,6 +663,133 @@ Install a runtime that recognizes `claude-settings-v4`, including any bundled
661
663
  copy of the verifier, before a policy carries it; an older runtime refuses the
662
664
  unknown hash mode.
663
665
 
666
+ ### Narrowed discovery reviews: `claude-settings-v5` and `codex-settings-v7`
667
+
668
+ Earlier modes bind almost the whole settings file, so ordinary use tripped
669
+ discovery drift: switching to any model not on a fixed list (for example
670
+ `deepseek-flash` or `claude-opus-5-5`), an "always allow" rule, a status line,
671
+ or Codex rewriting `config.toml` for a model change, a folder trust or its own
672
+ notices. The narrowed modes bind only what can add, remove or redirect native
673
+ skills, hooks or plugins:
674
+
675
+ - `claude-settings-v5`: every top-level key whose name mentions a skill, plugin,
676
+ hook or marketplace, in full (`hooks`, `disableAllHooks`, `enabledPlugins`,
677
+ `extraKnownMarketplaces`, `pluginConfigs`, `disableBundledSkills`,
678
+ `syncClaudeAiSkills` and any future key of that kind); in `permissions`, only
679
+ `Skill` rules in `allow`/`deny`/`ask` and `additionalDirectories`; in `env`,
680
+ only `CLAUDE_CONFIG_DIR` and variables with such a name; settings that run a
681
+ command the way a hook does (`apiKeyHelper`, `awsAuthRefresh`,
682
+ `awsCredentialExport`, `otelHeadersHelper`, `fileSuggestion`) and settings
683
+ that select injected instructions (`outputStyle`, `agent`). Any model value,
684
+ `modelSettings`, effort, other permission rules and modes, `statusLine`, other
685
+ environment, `theme`, `tui`, view and unknown preference keys vary freely.
686
+ There is no model allow-list. Skills-owned hook entries stay bound: `skills
687
+ hook install` rebinds the witness when it rewrites them, and matching them by
688
+ command text would accept a lookalike.
689
+ - `codex-settings-v7`: every root key with such a name (`hooks` without the
690
+ native `hooks.state` trust ledger, `plugins`, `marketplaces`, `skills`
691
+ without disable-only registrations), every `[mcp_servers.*]` table in full (a
692
+ hook handler of type `mcp_tool` runs through a named server, so a redirected
693
+ server `command` or `url` redirects a reviewed hook), instruction sources
694
+ (`instructions`, `developer_instructions`, `model_instructions_file`,
695
+ `experimental_instructions_file`, `project_doc_fallback_filenames`,
696
+ `compact_prompt`, `experimental_compact_prompt_file` and any key naming
697
+ instructions), every `[agents.*]` role table in full (a role's `config_file`
698
+ loads a layer whose `developer_instructions` reach subagents, and its
699
+ `description` is shown to the model), `[features]` flags with a skill, plugin, hook or marketplace
700
+ name at the root and in each profile, and keys of each of those kinds inside
701
+ `[profiles.*]`, so the `profile` selector itself can vary. Model, effort,
702
+ verbosity, service tier, `model_provider` and `[model_providers.*]`,
703
+ `[projects.*]` trust, `[tui]`, `[notice]`, `notify` and sandbox or approval
704
+ settings vary freely. Because every MCP server is bound, V7 needs no hook
705
+ dependency metadata; V6 keeps its own contract and is never narrowed.
706
+
707
+ Deliberately unbound, and therefore not drift: `statusLine` and Codex `notify`
708
+ (the owner's request names both as ordinary use, although each runs a
709
+ command), and model routing (`env` such as `ANTHROPIC_BASE_URL`, Codex
710
+ `model_provider` and `[model_providers.*]`). Adding any MCP server to a V7
711
+ review is drift: it is reported, not blocking.
712
+
713
+ Opt in through a fresh review (`skills hook witness --kind claude-settings-v5`
714
+ or `--kind codex-settings-v7`) or a preserved-preimage upgrade
715
+ (`skills hook rebind-settings --claude-witness-version 5` or
716
+ `--codex-witness-version 7`). The upgrade accepts a raw or any earlier typed
717
+ witness except Codex V6, proves the preimage in its original mode, and refuses
718
+ when any narrowed field differs.
719
+
720
+ Existing Claude and Codex reviews keep verifying after an upgrade without a new
721
+ review. A legacy full-file settings witness (raw bytes,
722
+ `claude-settings-v1`–`v4`, `codex-settings-v1`–`v5`) binds everything the
723
+ narrowed projection binds, except that `codex-settings-v3`–`v5` omit ordinary
724
+ local stdio MCP servers, which V7 binds. So while it still matches, the narrowed
725
+ digest of the current file is the narrowed digest of a state that review
726
+ accepts. The live hook records that observation, computed from the same bytes
727
+ that matched, in `native-witness-narrowed.json` beside `agent-policy.json`.
728
+ When the legacy witness later stops matching, the change is accepted only if the
729
+ current narrowed digest equals the recorded one; the first observation is never
730
+ replaced, so a local MCP server added after it is reported once the legacy
731
+ witness stops matching. Nothing is recorded from a file the legacy witness does
732
+ not verify, and an entry is bound to the exact stored witness. The same ledger
733
+ check covers the configuration witness of a Codex semantic-cache binding
734
+ (`skills hook rebind-cache`) and the settings check for retired Claude plugin
735
+ versions; the cache witness itself still compares the current disable rules.
736
+
737
+ Exceptions that still need one fresh review or an explicit
738
+ `skills hook rebind-settings` to v5/v7:
739
+
740
+ - a station that had already drifted before the upgrade (no entry is recorded
741
+ from a file the legacy witness does not verify), for example station03, whose
742
+ Claude model changed to `deepseek-flash` before the release;
743
+ - Codex `codex-settings-v6` witnesses and any witness with review artifacts,
744
+ managed-plugin rules or a field projection, which are never narrowed;
745
+ - Sumi `sumi.json` witnesses (raw bytes or `sumi-settings-v1`): there is no
746
+ narrowed Sumi projection yet, so a Sumi model or settings change is still
747
+ drift there. It does not block, but the Skills context is omitted until the
748
+ binding is reviewed again.
749
+
750
+ Install, trust, migrate, upgrade and portable-authoring checks stay strict and
751
+ do not consult the ledger, so after an ordinary settings change on a
752
+ legacy-witness station they still ask for a fresh review; `skills hook
753
+ rebind-settings --claude-witness-version 5` or `--codex-witness-version 7` with
754
+ the preserved preimage is the one-time repair that removes this.
755
+
756
+ ### Drift reports instead of blocking
757
+
758
+ A live lifecycle hook (Claude, Codex, Gemini, Cursor, Sumi and Hermes prompt,
759
+ session, subagent and tool events) no longer blocks on `NATIVE_SKILL_DRIFT`.
760
+ For that turn it omits the Skills context, shows one bounded warning naming the
761
+ drift and the repair command, and records
762
+ `<skills-data>/native-drift/<agent>.json` (schema
763
+ `hasna.skills.native-drift-receipt.v1`, mode 0600) with the full reason, first
764
+ and last occurrence and a count. The next clean check marks the receipt
765
+ `cleared`. `skills hook drift [--agent <agent>] [--json]` lists the receipts.
766
+ New hooks, plugins and native copies are still detected and reported; they are
767
+ never adopted silently. On a live hook, a check that cannot complete (a changed
768
+ root alias, an unreadable settings file, an inventory error) is reported the
769
+ same way, as `NATIVE_SKILL_DRIFT: native discovery could not be verified: …`.
770
+
771
+ Refusals that keep blocking because they are policy, not drift:
772
+
773
+ - invoking a native payload skill instead of the `skills-cli` bridge (Claude
774
+ `PreToolUse`, Gemini `BeforeTool`, Hermes `skill_view`/`skill_manage`);
775
+ - invoking the `skills-cli` bridge itself while it cannot be verified: the
776
+ bridge is missing or modified, the managed binding that names it is missing
777
+ or incompatible, its root aliases changed, or the Sumi or OpenCode bridge
778
+ plugin or skill permissions changed. A payload written under the bridge's own
779
+ name would otherwise load through the auto-allowed `Skill(skills-cli)` rule.
780
+ The prompt, session or subagent still proceeds; its notice tells the agent not
781
+ to invoke the bridge and to run the `skills` command directly;
782
+ - `DISCOVERY_ROOT_UNRESOLVED` and Sumi path-resolver refusals.
783
+
784
+ Install, trust, migrate, sync and upgrade commands still refuse drift exactly as
785
+ before.
786
+
787
+ Limit: Claude, Codex, Gemini and Cursor show the warning in their user-visible
788
+ channel (`systemMessage`, `user_message`). The Sumi and OpenCode plugins and
789
+ Hermes accept only model context on these events, so there the warning reaches
790
+ the model, not a separate user-visible line; the receipt and `skills hook drift`
791
+ are the operator's record on every host.
792
+
664
793
  ## Verification and limits
665
794
 
666
795
  Unit tests cover provenance and mapping failures, offline/revoked authorities,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/skills",
3
- "version": "0.10.83",
3
+ "version": "0.10.89",
4
4
  "description": "Skills library for AI coding agents",
5
5
  "type": "module",
6
6
  "bin": {