@llblab/pi-state-flow 0.9.5 → 0.10.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/lib/status.ts CHANGED
@@ -57,16 +57,11 @@ export function detailedStatus(snapshot: Snapshot, diagnostics: StatusDiagnostic
57
57
  diagnostics.recent,
58
58
  );
59
59
  const available = diagnostics.temporal !== undefined && diagnostics.durableStateError === undefined;
60
- const materialized = !available ? undefined : {
61
- global: diagnostics.scopeStates.global,
62
- cwd: diagnostics.scopeStates.cwd,
63
- session: diagnostics.scopeStates.session,
64
- effective: overlayStates(
65
- diagnostics.scopeStates.global,
66
- diagnostics.scopeStates.cwd,
67
- diagnostics.scopeStates.session,
68
- ),
69
- };
60
+ const materialized = !available ? undefined : overlayStates(
61
+ diagnostics.scopeStates.global,
62
+ diagnostics.scopeStates.cwd,
63
+ diagnostics.scopeStates.session,
64
+ );
70
65
  const stateJson = materialized === undefined ? undefined : JSON.stringify(materialized, null, 2);
71
66
  const freshnessError = diagnostics.artifactFreshnessError ?? (available ? undefined : "temporal global artifact registry is unavailable");
72
67
  const stale = freshnessError === undefined
@@ -124,7 +119,7 @@ export function detailedStatus(snapshot: Snapshot, diagnostics: StatusDiagnostic
124
119
  `Publication: ${publication}`,
125
120
  ...staleLines,
126
121
  ...(stateJson === undefined
127
- ? ["Materialized states: unavailable (global/CWD/session/effective)"]
128
- : [`Materialized states (${Buffer.byteLength(stateJson, "utf8")} bytes; global/CWD/session Git-backed, effective overlay):`, "", stateJson]),
122
+ ? ["Effective memory: unavailable"]
123
+ : [`Effective memory (${Buffer.byteLength(stateJson, "utf8")} JSON bytes; global → CWD → session overlay):`, "", stateJson]),
129
124
  ].join("\n");
130
125
  }
package/lib/storage.ts CHANGED
@@ -90,7 +90,8 @@ export function planTemporalPublication(
90
90
  changedScopes.push(scope);
91
91
  }
92
92
  const provenanceUpdates: OwnedFileUpdate[] = [];
93
- if (provenance !== undefined) {
93
+ // Shared provenance belongs to its semantic scopes, not the session config being saved.
94
+ if (!runtimeOnly && provenance !== undefined) {
94
95
  for (const scope of ["global", "cwd"] as const) {
95
96
  const paths = temporalScopePaths(cwd, sessionId, scope, root, sessionKey);
96
97
  const registry = provenance[scope];
package/lib/telegram.ts CHANGED
@@ -75,12 +75,22 @@ export interface StateFlowTelegramAdapter {
75
75
 
76
76
  /** Main-menu section label doubles as the live status value: the spiral identity is constant, the value is not. */
77
77
  export function formatStateFlowSectionLabel(snapshot: StateFlowTelegramSnapshot): string {
78
- return snapshot.enabled ? `🌀 State Flow: #${snapshot.step}` : "🌀 State Flow: off";
78
+ return `🌀 State Flow: ${stateFlowLabelValue(snapshot)}`;
79
+ }
80
+
81
+ /** Shared live value: plain in the button label, monospaced in the submenu state line. */
82
+ function stateFlowLabelValue(snapshot: StateFlowTelegramSnapshot): string {
83
+ return snapshot.enabled ? `#${snapshot.step}` : "off";
84
+ }
85
+
86
+ /** Submenu state line: the same identity as the button label, with the live value in monospace. */
87
+ function formatStateFlowSectionHeader(snapshot: StateFlowTelegramSnapshot): string {
88
+ return `<b>🌀 State Flow: <code>${stateFlowLabelValue(snapshot)}</code></b>`;
79
89
  }
80
90
 
81
91
  /** Short help under the state line: what State Flow is and why its action button exists. */
82
92
  const STATE_FLOW_SECTION_HELP =
83
- "Records the latest accepted state after every turn, so a new session resumes from the last committed point. Start it to keep memory live on this branch, stop it to pause.";
93
+ "Records the latest accepted state after every turn, so a new session resumes from the last committed point.";
84
94
 
85
95
  /** The submenu header repeats the button's state line; the single action matches the current state. */
86
96
  export function buildStateFlowSectionView(
@@ -91,7 +101,7 @@ export function buildStateFlowSectionView(
91
101
  ? { text: "⏹ Stop", callback_data: callbackData("stop") }
92
102
  : { text: "▶️ Start", callback_data: callbackData("start") };
93
103
  return {
94
- text: [`<b>${formatStateFlowSectionLabel(snapshot)}</b>`, "", STATE_FLOW_SECTION_HELP].join("\n"),
104
+ text: [formatStateFlowSectionHeader(snapshot), "", STATE_FLOW_SECTION_HELP].join("\n"),
95
105
  parseMode: "html",
96
106
  replyMarkup: { inline_keyboard: [[action]] },
97
107
  };
package/lib/transition.ts CHANGED
@@ -3,6 +3,7 @@ import {
3
3
  ORDINARY_ARTIFACT_COMPILER,
4
4
  validateArtifactMetadata,
5
5
  validateArtifactRegistry,
6
+ validateModelArtifactPatch,
6
7
  type ArtifactCompilerOutput,
7
8
  type ArtifactProvenance,
8
9
  } from "./artifact.ts";
@@ -77,9 +78,6 @@ function compileReadSkills(
77
78
  if (!isObject(output)) {
78
79
  throw new Error(`Every successfully read Skill must have a CWD artifact compiler output at artifacts[exactReadPath]; missing: ${read.path}`);
79
80
  }
80
- if (Object.hasOwn(output, "hash") || Object.hasOwn(output, "compiler")) {
81
- throw new Error(`Skill artifact compiler output at ${read.path} cannot set runtime-owned hash or compiler fields`);
82
- }
83
81
  if (typeof output.description !== "string" || output.description.trim().length === 0) {
84
82
  throw new Error(`Skill artifact compiler output at ${read.path} must have a non-empty description`);
85
83
  }
@@ -133,6 +131,7 @@ function validateScopePatch(scope: unknown, patch: unknown): asserts patch is Sc
133
131
  throw new Error(`Scoped State Flow patch field ${key} must be a JSON object`);
134
132
  }
135
133
  }
134
+ if (isObject(patch.artifacts)) validateModelArtifactPatch(patch.artifacts);
136
135
  }
137
136
 
138
137
  function completePatch(patch: ScopePatch, response: string): StatePatch {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@llblab/pi-state-flow",
3
- "version": "0.9.5",
3
+ "version": "0.10.0",
4
4
  "private": false,
5
5
  "description": "Incremental scoped state/context compiler for Pi, inspired by SKILL.state",
6
6
  "keywords": [
@@ -30,6 +30,7 @@
30
30
  "scripts": {
31
31
  "check": "node --experimental-strip-types -e \"await import('./index.ts')\"",
32
32
  "test": "node --experimental-strip-types --test tests/*.test.ts",
33
+ "benchmark": "node --experimental-strip-types benchmarks/benchmark.ts",
33
34
  "typecheck": "tsc --noEmit",
34
35
  "validate": "npm run typecheck && npm test && npm run check",
35
36
  "prepack": "npm run validate"
@@ -50,9 +51,9 @@
50
51
  "node": ">=22.19.0"
51
52
  },
52
53
  "peerDependencies": {
53
- "@earendil-works/pi-agent-core": "^0.84.4",
54
- "@earendil-works/pi-ai": "^0.84.4",
55
- "@earendil-works/pi-coding-agent": "^0.84.4"
54
+ "@earendil-works/pi-agent-core": "^0.84.4 || ^0.85.1",
55
+ "@earendil-works/pi-ai": "^0.84.4 || ^0.85.1",
56
+ "@earendil-works/pi-coding-agent": "^0.84.4 || ^0.85.1"
56
57
  },
57
58
  "devDependencies": {
58
59
  "@types/node": "latest",