@llblab/pi-state-flow 0.12.0 → 0.12.1
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/CHANGELOG.md +4 -0
- package/docs/usage.md +1 -1
- package/lib/extension.ts +20 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
## Unreleased
|
|
6
6
|
|
|
7
|
+
## 0.12.1: Cleaner successful patch rendering
|
|
8
|
+
|
|
9
|
+
- `Successful patch rendering`: Successful visible `patch_state` rows now contain only valid pretty-printed JSON, without the redundant materialized-scope summary, and separate adjacent memory sections with blank lines.
|
|
10
|
+
|
|
7
11
|
## 0.12.0: Unified state reads and visible patches
|
|
8
12
|
|
|
9
13
|
- `Unified state reads`: `read_state` now resolves current-as-index-zero paths for effective/scoped materializations and retained scope patches while preserving the prior offset/scope input for compatibility. Materialization paths share the composed causal timeline; patch paths walk accepted records for their selected scope.
|
package/docs/usage.md
CHANGED
|
@@ -43,7 +43,7 @@ Optional `state-flow.json` beneath Pi's agent directory, normally `~/.pi/agent/s
|
|
|
43
43
|
- `directory`: State store. The default is `state-flow/` beneath the agent directory. Absolute paths, `~`/`~/`, and relative paths are accepted; relative paths resolve from the configuration directory, not project CWD.
|
|
44
44
|
- `autoStart`: Defaults to `false`. When `true`, genuinely new sessions use the same initialization as explicit Start, including fresh CWDs.
|
|
45
45
|
- `logging`: Defaults to `false`. When enabled, records rejected patches and unresolved terminal/fallback diagnostics locally at `tmp/state-flow/logs.jsonl` beneath the agent directory.
|
|
46
|
-
- `showSuccessfulPatches`: Defaults to `true`. In interactive Pi, successful `patch_state` rows show the applied JSON arguments
|
|
46
|
+
- `showSuccessfulPatches`: Defaults to `true`. In interactive Pi, successful `patch_state` rows show only the applied pretty-printed JSON arguments, with blank lines between adjacent memory sections; set it to `false` to keep only the compact summary. Rejected calls still use ordinary error rendering and private validation details are never added.
|
|
47
47
|
- `remotePublication`: New-runtime policy: `turn-end` queues the newest accepted commit for asynchronous push; `off` keeps commits local; `transition` retains synchronous compatibility behavior. Existing branches keep their persisted policy.
|
|
48
48
|
|
|
49
49
|
Settings are read once at extension load. After editing, use `/reload` or restart Pi. A missing file uses defaults without creating a configuration file; malformed JSON, unknown keys, or invalid values fail loading rather than silently selecting another store.
|
package/lib/extension.ts
CHANGED
|
@@ -57,6 +57,25 @@ export const READ_STATE_TOOL_NAME = "read_state";
|
|
|
57
57
|
export const MAX_FALLBACK_ATTEMPTS: number = 2;
|
|
58
58
|
const PASSIVE_STOP_ENTRY_TYPE = "state-flow-passive-stop";
|
|
59
59
|
const PUBLICATION_SHUTDOWN_WAIT_MS = 2_000;
|
|
60
|
+
const MEMORY_SECTION_KEYS = new Set(["artifacts", "contract", "working", "response"]);
|
|
61
|
+
|
|
62
|
+
/** Keep successful patch JSON valid while separating adjacent memory sections visually. */
|
|
63
|
+
export function formatPatchStateArguments(args: unknown): string {
|
|
64
|
+
const seenAtIndent = new Set<number>();
|
|
65
|
+
return JSON.stringify(args, null, 2).split("\n").flatMap((line) => {
|
|
66
|
+
const indent = line.length - line.trimStart().length;
|
|
67
|
+
const match = /^(\s+)"([^"]+)":/.exec(line);
|
|
68
|
+
if (match === null || !MEMORY_SECTION_KEYS.has(match[2])) {
|
|
69
|
+
for (const seenIndent of seenAtIndent) {
|
|
70
|
+
if (seenIndent > indent) seenAtIndent.delete(seenIndent);
|
|
71
|
+
}
|
|
72
|
+
return [line];
|
|
73
|
+
}
|
|
74
|
+
const separator = seenAtIndent.has(indent) ? [""] : [];
|
|
75
|
+
seenAtIndent.add(indent);
|
|
76
|
+
return [...separator, line];
|
|
77
|
+
}).join("\n");
|
|
78
|
+
}
|
|
60
79
|
|
|
61
80
|
/** Normalize a bounded compatibility superset without advertising aliases in the model-facing contract. */
|
|
62
81
|
export function normalizePatchStateArguments(args: unknown): any {
|
|
@@ -819,7 +838,7 @@ export default function stateFlowExtension(pi: ExtensionAPI, options: StateFlowE
|
|
|
819
838
|
renderResult(result, { isPartial }, theme, context) {
|
|
820
839
|
const text = result.content.find((block) => block.type === "text")?.text ?? "";
|
|
821
840
|
if (isPartial || context.isError || !config.showSuccessfulPatches) return new Text(text, 0, 0);
|
|
822
|
-
return new Text(
|
|
841
|
+
return new Text(theme.fg("dim", formatPatchStateArguments(context.args)), 0, 0);
|
|
823
842
|
},
|
|
824
843
|
async execute(toolCallId, params, signal, _onUpdate, ctx) {
|
|
825
844
|
try {
|