pi-one-ui 0.2.2 → 0.3.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/CHANGELOG.md +39 -0
- package/README.en.md +256 -0
- package/README.md +12 -11
- package/extensions/app/config/renderer.ts +5 -17
- package/extensions/app/config/shell.ts +118 -422
- package/extensions/app/config/store.ts +23 -92
- package/extensions/app/presets.ts +1 -2
- package/package.json +10 -1
|
@@ -19,20 +19,12 @@ export type ConfigRecord = Record<string, unknown>;
|
|
|
19
19
|
|
|
20
20
|
export type ConfigStorePaths = {
|
|
21
21
|
canonical: string;
|
|
22
|
-
legacyUnified: string;
|
|
23
|
-
legacyShell: string;
|
|
24
|
-
legacyRenderer: string;
|
|
25
22
|
};
|
|
26
23
|
|
|
27
|
-
/**
|
|
28
|
-
* Returns canonical and legacy configuration locations for an agent directory.
|
|
29
|
-
*/
|
|
24
|
+
/** Returns the canonical configuration location for an agent directory. */
|
|
30
25
|
export function configPaths(agentDir = getAgentDir()): ConfigStorePaths {
|
|
31
26
|
return {
|
|
32
27
|
canonical: join(agentDir, "pi-one-ui.json"),
|
|
33
|
-
legacyUnified: join(agentDir, "pi-mine-ui.json"),
|
|
34
|
-
legacyShell: join(agentDir, "zentui.json"),
|
|
35
|
-
legacyRenderer: join(agentDir, "claude-code-style.json"),
|
|
36
28
|
};
|
|
37
29
|
}
|
|
38
30
|
|
|
@@ -138,7 +130,7 @@ function configReadError(path: string, error: unknown): Error {
|
|
|
138
130
|
}
|
|
139
131
|
|
|
140
132
|
/**
|
|
141
|
-
* Builds the
|
|
133
|
+
* Builds the safety error used when a config write is unsafe.
|
|
142
134
|
*/
|
|
143
135
|
function configWriteError(path: string, label: string, error: unknown): Error {
|
|
144
136
|
const detail = error instanceof Error ? ` (${error.message})` : "";
|
|
@@ -147,79 +139,15 @@ function configWriteError(path: string, label: string, error: unknown): Error {
|
|
|
147
139
|
);
|
|
148
140
|
}
|
|
149
141
|
|
|
150
|
-
|
|
151
|
-
record: ConfigRecord;
|
|
152
|
-
writePath: string;
|
|
153
|
-
mode?: number;
|
|
154
|
-
materialize: boolean;
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Reads an optional config source and turns corruption into an explicit error.
|
|
159
|
-
*/
|
|
160
|
-
function optionalConfig(
|
|
161
|
-
path: string,
|
|
162
|
-
): { record: ConfigRecord; writePath: string; mode: number } | undefined {
|
|
163
|
-
const state = readConfigFileState(path);
|
|
164
|
-
if (state.kind === "missing") return undefined;
|
|
165
|
-
if (state.kind === "corrupt") throw configReadError(path, state.error);
|
|
166
|
-
return state;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Selects the active source and the destination used by a later update.
|
|
171
|
-
*/
|
|
172
|
-
function selectUnifiedConfig(paths: ConfigStorePaths): SelectedConfig {
|
|
173
|
-
const canonical = optionalConfig(paths.canonical);
|
|
174
|
-
if (canonical) return { ...canonical, materialize: false };
|
|
175
|
-
|
|
176
|
-
const legacyUnified = optionalConfig(paths.legacyUnified);
|
|
177
|
-
if (legacyUnified)
|
|
178
|
-
return {
|
|
179
|
-
...legacyUnified,
|
|
180
|
-
writePath: paths.canonical,
|
|
181
|
-
materialize: true,
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
const shell = optionalConfig(paths.legacyShell);
|
|
185
|
-
const renderer = optionalConfig(paths.legacyRenderer);
|
|
186
|
-
if (!shell && !renderer) {
|
|
187
|
-
return {
|
|
188
|
-
record: {},
|
|
189
|
-
writePath: paths.canonical,
|
|
190
|
-
materialize: false,
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
return {
|
|
195
|
-
record: {
|
|
196
|
-
...(shell?.record ?? {}),
|
|
197
|
-
version: 1,
|
|
198
|
-
renderer: renderer?.record ?? {},
|
|
199
|
-
},
|
|
200
|
-
writePath: paths.canonical,
|
|
201
|
-
mode: shell?.mode ?? renderer?.mode,
|
|
202
|
-
materialize: true,
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* Read the one raw unified record used by all configuration domains.
|
|
208
|
-
* Legacy sources are best-effort materialized through the same atomic writer;
|
|
209
|
-
* the in-memory record remains usable if the agent directory is read-only.
|
|
210
|
-
*/
|
|
142
|
+
/** Reads the raw canonical record used by every configuration domain. */
|
|
211
143
|
export function readUnifiedConfigRecord(
|
|
212
144
|
paths: ConfigStorePaths = defaultConfigPaths,
|
|
213
145
|
): ConfigRecord {
|
|
214
|
-
const
|
|
215
|
-
if (
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
// Keep using the selected legacy record in memory when migration cannot be written.
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
return selected.record;
|
|
146
|
+
const state = readConfigFileState(paths.canonical);
|
|
147
|
+
if (state.kind === "missing") return {};
|
|
148
|
+
if (state.kind === "corrupt")
|
|
149
|
+
throw configReadError(paths.canonical, state.error);
|
|
150
|
+
return state.record;
|
|
223
151
|
}
|
|
224
152
|
|
|
225
153
|
/**
|
|
@@ -247,22 +175,18 @@ export type ConfigStoreListener = (record: ConfigRecord) => void;
|
|
|
247
175
|
|
|
248
176
|
/**
|
|
249
177
|
* Process-wide raw configuration store. Domain config modules own parsing and
|
|
250
|
-
* selectors; this module owns
|
|
178
|
+
* selectors; this module owns canonical persistence.
|
|
251
179
|
*/
|
|
252
180
|
export class ConfigStore {
|
|
253
181
|
readonly paths: ConfigStorePaths;
|
|
254
182
|
private readonly listeners = new Set<ConfigStoreListener>();
|
|
255
183
|
|
|
256
|
-
/**
|
|
257
|
-
* Creates a store for canonical and legacy paths.
|
|
258
|
-
*/
|
|
184
|
+
/** Creates a store for the canonical path. */
|
|
259
185
|
constructor(paths: ConfigStorePaths = defaultConfigPaths) {
|
|
260
186
|
this.paths = paths;
|
|
261
187
|
}
|
|
262
188
|
|
|
263
|
-
/**
|
|
264
|
-
* Reads the current canonical or legacy-backed raw configuration record.
|
|
265
|
-
*/
|
|
189
|
+
/** Reads the current canonical raw configuration record. */
|
|
266
190
|
read(): ConfigRecord {
|
|
267
191
|
return readUnifiedConfigRecord(this.paths);
|
|
268
192
|
}
|
|
@@ -271,11 +195,18 @@ export class ConfigStore {
|
|
|
271
195
|
* Mutates and atomically persists the active raw configuration record.
|
|
272
196
|
*/
|
|
273
197
|
update(mutate: (record: ConfigRecord) => void): ConfigRecord {
|
|
274
|
-
const
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
198
|
+
const state = readConfigFileState(this.paths.canonical);
|
|
199
|
+
if (state.kind === "corrupt")
|
|
200
|
+
throw configReadError(this.paths.canonical, state.error);
|
|
201
|
+
|
|
202
|
+
mutate(state.record);
|
|
203
|
+
writeConfigAtomically(
|
|
204
|
+
state.writePath,
|
|
205
|
+
state.record,
|
|
206
|
+
state.kind === "valid" ? state.mode : undefined,
|
|
207
|
+
);
|
|
208
|
+
for (const listener of this.listeners) listener(state.record);
|
|
209
|
+
return state.record;
|
|
279
210
|
}
|
|
280
211
|
|
|
281
212
|
/**
|
|
@@ -21,7 +21,7 @@ export function applyPreset(preset: Preset): void {
|
|
|
21
21
|
saveUserMessagesComponentPatch({ enabled: false });
|
|
22
22
|
saveWorkingLineComponentPatch({ enabled: false });
|
|
23
23
|
saveFooterComponentPatch({ style: "native" });
|
|
24
|
-
updateRendererConfig({ mode: "off"
|
|
24
|
+
updateRendererConfig({ mode: "off" });
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -31,6 +31,5 @@ export function applyPreset(preset: Preset): void {
|
|
|
31
31
|
saveFooterComponentPatch({ style: "starship" });
|
|
32
32
|
updateRendererConfig({
|
|
33
33
|
mode: preset === "compact" ? "compact" : "on",
|
|
34
|
-
enableWorkingMessage: false,
|
|
35
34
|
});
|
|
36
35
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-one-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "A single, customizable Pi UI package with layout-oriented Context and Shell rendering for Pi.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"pi-package",
|
|
9
|
+
"pi-extension",
|
|
10
|
+
"pi",
|
|
11
|
+
"pi-coding-agent",
|
|
12
|
+
"tui"
|
|
13
|
+
],
|
|
7
14
|
"repository": {
|
|
8
15
|
"type": "git",
|
|
9
16
|
"url": "https://github.com/kerolt/pi-one-ui"
|
|
@@ -16,6 +23,8 @@
|
|
|
16
23
|
"extensions",
|
|
17
24
|
"themes",
|
|
18
25
|
"README.md",
|
|
26
|
+
"README.en.md",
|
|
27
|
+
"CHANGELOG.md",
|
|
19
28
|
"LICENSE"
|
|
20
29
|
],
|
|
21
30
|
"scripts": {
|