@quandev104/pi-style 0.1.5 → 0.1.6

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.
@@ -1,16 +1,19 @@
1
1
  import type { NormalizedPiStyleConfig } from "./config-types.js";
2
2
 
3
3
  export interface TierCAuthorizationInput {
4
- readonly certifiedHost: boolean;
5
4
  readonly coreFlag: boolean;
6
5
  readonly surfaceFlag: boolean;
7
6
  readonly surface: "messages" | "tools" | "assistantMessage" | "specialBlocks";
8
7
  readonly config: NormalizedPiStyleConfig;
9
8
  }
10
9
 
11
- /** Persisted and ordinary command state is intentionally not an input: authorization is session-bound. */
10
+ /**
11
+ * Tier C surface authorization is session-bound to the core/surface flags and
12
+ * normalized config; runtime compatibility is decided per-surface by the probe's
13
+ * identity (fingerprint) check, never by a hard-pinned Pi version.
14
+ */
12
15
  export function isTierCAuthorized(input: TierCAuthorizationInput): boolean {
13
- if (!input.certifiedHost || !input.coreFlag || !input.surfaceFlag || !input.config.enabled) return false;
16
+ if (!input.coreFlag || !input.surfaceFlag || !input.config.enabled) return false;
14
17
  if (input.surface === "tools") return input.config.tools.enabled;
15
18
  if (input.surface === "assistantMessage")
16
19
  return input.config.messages.enabled && input.config.messages.assistantPrefix;
@@ -6,6 +6,7 @@ import {
6
6
  detectPiVersion,
7
7
  disposePiCompatibilityProbe,
8
8
  probePiCompatibility,
9
+ SUPPORTED_VERSION_RANGE,
9
10
  } from "./compatibility-probe.js";
10
11
 
11
12
  export interface CompatibilityCoordinator {
@@ -60,8 +61,10 @@ export function createCompatibilityCoordinator(dispose = disposePiCompatibilityP
60
61
  report?.unsupported.filter((item) =>
61
62
  feature === "messages" ? item.subtype.includes("message") : item.subtype.includes("tool"),
62
63
  ) ?? [];
63
- const failed = records.some((item) => /identity|failed|unsupported shape/i.test(item.reason));
64
- const fallback = records.some((item) => /fallback|authorization|disabled/i.test(item.reason));
64
+ // Identity drift degrades only the affected surface to native (graceful);
65
+ // a feature is only "failed" when an install/shape error occurred.
66
+ const failed = records.some((item) => /failed|rejected|rolled back|shape is not/i.test(item.reason));
67
+ const fallback = records.some((item) => /fallback|authorization|disabled|identity/i.test(item.reason));
65
68
  const authorized = Boolean(authorization?.core && surfaceAuthorized);
66
69
  const installedRecord = report?.recordSnapshots.some(
67
70
  (item) => item.feature === feature && !item.disposed && (subtype === undefined || item.subtype === subtype),
@@ -69,7 +72,7 @@ export function createCompatibilityCoordinator(dispose = disposePiCompatibilityP
69
72
  return {
70
73
  configured,
71
74
  authorized,
72
- installed: Boolean(installedRecord && !failed && authorized && configured),
75
+ installed: Boolean(installedRecord && authorized && configured),
73
76
  conflicted: records.some((item) => item.reason.includes("owner")),
74
77
  failed,
75
78
  cleanupPending,
@@ -81,12 +84,13 @@ export function createCompatibilityCoordinator(dispose = disposePiCompatibilityP
81
84
  configured: messagesConfigured || toolsConfigured,
82
85
  authorized: authorization?.core ?? false,
83
86
  installed: report !== undefined,
84
- conflicted: report?.unsupported.some((item) => item.reason.includes("identity")) ?? false,
85
- failed: report?.unsupported.some((item) => item.reason.includes("failed")) ?? false,
87
+ conflicted: report?.unsupported.some((item) => item.reason.includes("owner")) ?? false,
88
+ failed: report?.unsupported.some((item) => /failed|rejected|rolled back/i.test(item.reason)) ?? false,
86
89
  cleanupPending,
87
- nativeFallbacks: report?.unsupported.filter((item) => item.reason.includes("fallback")).length ?? 0,
90
+ nativeFallbacks: report?.unsupported.filter((item) => /fallback|identity/i.test(item.reason)).length ?? 0,
88
91
  piVersion: version.version ?? report?.piVersion ?? "unknown",
89
- versionRange: report?.versionRange ?? ">=0.83.0 <0.84.0",
92
+ versionRange: report?.versionRange ?? SUPPORTED_VERSION_RANGE,
93
+ supportedVersions: report?.supportedVersions ?? [],
90
94
  assistantMessage: surface(
91
95
  "messages",
92
96
  config.enabled && config.messages.enabled && config.messages.assistantPrefix,
@@ -105,11 +109,13 @@ export function createCompatibilityCoordinator(dispose = disposePiCompatibilityP
105
109
  const productDenied = productGate === "deny";
106
110
  if (cleanupPending && !report) cleanupPending = false;
107
111
  if (cleanupPending || !tui || !config.enabled || !authorization?.core || productDenied) return undefined;
108
- const certifiedHost = detectPiVersion().version === "0.83.0";
112
+ // Certification is per-surface identity (fingerprint) based, never pinned to
113
+ // a Pi version: authorization only needs the session flags + config. Version
114
+ // drift that preserves identities keeps working; changed identities degrade
115
+ // per-surface inside the probe.
109
116
  const assistantEnabled =
110
117
  authorization.assistant &&
111
118
  isTierCAuthorized({
112
- certifiedHost,
113
119
  coreFlag: authorization.core,
114
120
  surfaceFlag: true,
115
121
  surface: "assistantMessage",
@@ -118,7 +124,6 @@ export function createCompatibilityCoordinator(dispose = disposePiCompatibilityP
118
124
  const specialBlocksEnabled =
119
125
  authorization.specialBlocks &&
120
126
  isTierCAuthorized({
121
- certifiedHost,
122
127
  coreFlag: authorization.core,
123
128
  surfaceFlag: true,
124
129
  surface: "specialBlocks",
@@ -133,7 +138,6 @@ export function createCompatibilityCoordinator(dispose = disposePiCompatibilityP
133
138
  config.messages.enabled &&
134
139
  config.messages.hideThinkingLabel &&
135
140
  isTierCAuthorized({
136
- certifiedHost,
137
141
  coreFlag: authorization.core,
138
142
  surfaceFlag: true,
139
143
  surface: "messages",
@@ -142,7 +146,7 @@ export function createCompatibilityCoordinator(dispose = disposePiCompatibilityP
142
146
  );
143
147
  const toolsEnabled =
144
148
  authorization.tools &&
145
- isTierCAuthorized({ certifiedHost, coreFlag: authorization.core, surfaceFlag: true, surface: "tools", config });
149
+ isTierCAuthorized({ coreFlag: authorization.core, surfaceFlag: true, surface: "tools", config });
146
150
  if (!messagesEnabled && !toolsEnabled) return undefined;
147
151
  const detected = detectPiVersion();
148
152
  report = probePiCompatibility(detected.version, {