pi-fabric 0.71.0 → 0.72.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/dist/index.js CHANGED
@@ -91,6 +91,7 @@ import {
91
91
  DEFAULT_FABRIC_CONFIG,
92
92
  effectiveToolCaptureConfig,
93
93
  loadFabricConfig,
94
+ loadFabricConfigForScope,
94
95
  saveFabricConfig
95
96
  } from "./chunks/chunk-R7MJZJX2.js";
96
97
  import {
@@ -804,6 +805,7 @@ function registerFabricCommand(pi, deps) {
804
805
  "status",
805
806
  "dashboard",
806
807
  "settings",
808
+ "schema",
807
809
  "prewalk",
808
810
  "reload",
809
811
  "providers",
@@ -841,6 +843,10 @@ function registerFabricCommand(pi, deps) {
841
843
  const subcommand = argumentPrefix.slice(0, firstSpace);
842
844
  const idPrefix = argumentPrefix.slice(firstSpace + 1);
843
845
  if (!state.initialized) return null;
846
+ if (subcommand === "schema") {
847
+ const modes = ["off", "audit", "enforce"].filter((mode) => mode.startsWith(idPrefix));
848
+ return modes.length > 0 ? modes.map((value) => ({ value, label: value })) : null;
849
+ }
844
850
  if (subcommand === "import") {
845
851
  const items2 = [];
846
852
  try {
@@ -917,7 +923,7 @@ function registerFabricCommand(pi, deps) {
917
923
  return;
918
924
  }
919
925
  if (command === "settings") {
920
- const { openFabricSettings } = await import("./chunks/settings-6MBYNMHI.js");
926
+ const { openFabricSettings } = await import("./chunks/settings-ILDKW6BG.js");
921
927
  await openFabricSettings(context, {
922
928
  state,
923
929
  applyFabricMode,
@@ -936,6 +942,35 @@ function registerFabricCommand(pi, deps) {
936
942
  });
937
943
  return;
938
944
  }
945
+ if (command === "schema") {
946
+ const requested = argumentsList[0];
947
+ if (requested === void 0) {
948
+ const status = state.schemaStatus(context);
949
+ context.ui.notify(
950
+ `Schema mode: ${status.mode} (${status.source}) \xB7 executor: ${status.executorRuntime} \xB7 /fabric schema [off|audit|enforce] overrides this session only`,
951
+ "info"
952
+ );
953
+ return;
954
+ }
955
+ if (requested !== "off" && requested !== "audit" && requested !== "enforce") {
956
+ context.ui.notify("Usage: /fabric schema [off|audit|enforce]", "warning");
957
+ return;
958
+ }
959
+ try {
960
+ state.setSchemaMode(context, requested);
961
+ } catch (error) {
962
+ context.ui.notify(
963
+ error instanceof Error ? error.message : String(error),
964
+ "error"
965
+ );
966
+ return;
967
+ }
968
+ context.ui.notify(
969
+ `Schema mode set to ${requested} for this session (config file unchanged; the next session starts from the configured mode)`,
970
+ "info"
971
+ );
972
+ return;
973
+ }
939
974
  if (command === "prewalk") {
940
975
  const option = argumentsList[0];
941
976
  if (option === "--disable" || option === "--enable") {
@@ -3687,10 +3722,49 @@ var FabricState = class {
3687
3722
  agentDir: resolveAgentDir(),
3688
3723
  projectTrusted: context.isProjectTrusted()
3689
3724
  });
3690
- if (this.#config) next.schema.mode = this.#config.schema.mode;
3725
+ if (this.#config) {
3726
+ next.schema.mode = this.#config.schema.mode;
3727
+ if (next.schema.mode === "enforce") next.executor.runtime = this.#config.executor.runtime;
3728
+ }
3691
3729
  this.#config = next;
3692
3730
  this.#runtime?.reloadConfig(context, next);
3693
3731
  }
3732
+ // Ephemeral, session-only schema mode: mutates the live config (guidance,
3733
+ // resolved-action gate, and executor runtime all read it per call) without
3734
+ // touching fabric.json, so the next session starts from the configured mode.
3735
+ // reloadConfig preserves the override like the startup mode does.
3736
+ setSchemaMode(context, mode) {
3737
+ if (!this.#config) throw new Error("Fabric is not initialized");
3738
+ const previous = this.#config.schema.mode;
3739
+ if (mode === "enforce" && previous !== "enforce" && !this.#config.fullCodeMode) {
3740
+ throw new Error(
3741
+ "Schema enforce requires full code mode; enable fullCodeMode or start a session with schema.mode=enforce"
3742
+ );
3743
+ }
3744
+ this.#config.schema.mode = mode;
3745
+ if (mode === "enforce") {
3746
+ this.#config.executor.runtime = "quickjs";
3747
+ } else if (previous === "enforce") {
3748
+ this.#config.executor.runtime = this.#diskConfig(context).executor.runtime;
3749
+ }
3750
+ this.#runtime?.setSchemaMode(mode, this.#config.executor.runtime);
3751
+ }
3752
+ schemaStatus(context) {
3753
+ const disk = this.#diskConfig(context);
3754
+ const mode = this.#config?.schema.mode ?? disk.schema.mode;
3755
+ return {
3756
+ mode,
3757
+ source: this.#config && this.#config.schema.mode !== disk.schema.mode ? "session override" : "config",
3758
+ executorRuntime: this.#config?.executor.runtime ?? disk.executor.runtime
3759
+ };
3760
+ }
3761
+ #diskConfig(context) {
3762
+ const projectTrusted = context.isProjectTrusted();
3763
+ return loadFabricConfigForScope(
3764
+ { cwd: context.cwd, agentDir: resolveAgentDir(), projectTrusted },
3765
+ projectTrusted ? "project" : "global"
3766
+ );
3767
+ }
3694
3768
  async shutdown() {
3695
3769
  const generation = ++this.#generation;
3696
3770
  const activation = this.#activation;
@@ -3780,7 +3854,7 @@ var FabricState = class {
3780
3854
  return activation;
3781
3855
  }
3782
3856
  async #createRuntime() {
3783
- const module = await (this.#options.runtimeLoader?.() ?? import("./chunks/fabric-runtime-state-GWMWTS7Y.js"));
3857
+ const module = await (this.#options.runtimeLoader?.() ?? import("./chunks/fabric-runtime-state-RTHTHOLE.js"));
3784
3858
  return new module.FabricRuntimeState(
3785
3859
  this.pi,
3786
3860
  this.capturedTools,