@prevalentware/opencode-goal-plugin 0.1.34 → 0.1.35
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/server.js +23 -2
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -210,15 +210,36 @@ function isMissingStateFile(error) {
|
|
|
210
210
|
function mutableState(state) {
|
|
211
211
|
return JSON.parse(JSON.stringify(state));
|
|
212
212
|
}
|
|
213
|
+
var warnedEmptyStatePaths = new Set;
|
|
214
|
+
function isStatePadding(character) {
|
|
215
|
+
return character === "\x00" || character.trim() === "";
|
|
216
|
+
}
|
|
217
|
+
function parseStateText(raw, file) {
|
|
218
|
+
let start = 0;
|
|
219
|
+
let end = raw.length;
|
|
220
|
+
while (start < end && isStatePadding(raw[start]))
|
|
221
|
+
start += 1;
|
|
222
|
+
while (end > start && isStatePadding(raw[end - 1]))
|
|
223
|
+
end -= 1;
|
|
224
|
+
const content = raw.slice(start, end);
|
|
225
|
+
if (content)
|
|
226
|
+
return JSON.parse(content);
|
|
227
|
+
if (!warnedEmptyStatePaths.has(file)) {
|
|
228
|
+
warnedEmptyStatePaths.add(file);
|
|
229
|
+
console.warn(`[opencode-goal-plugin] Empty or zero-filled state file at ${file}; recovering with empty state.`);
|
|
230
|
+
}
|
|
231
|
+
return emptyState();
|
|
232
|
+
}
|
|
213
233
|
function decodeState(value) {
|
|
214
234
|
return Schema.decodeUnknown(StateSchema)(value).pipe(Effect.map(mutableState), Effect.map(normalizeState), Effect.mapError((cause) => new StateDecodeError({ cause })));
|
|
215
235
|
}
|
|
216
236
|
function readStateEffect() {
|
|
237
|
+
const file = statePath();
|
|
217
238
|
return Effect.tryPromise({
|
|
218
|
-
try: () => readFile(
|
|
239
|
+
try: () => readFile(file, "utf8"),
|
|
219
240
|
catch: (cause) => new StateReadError({ cause })
|
|
220
241
|
}).pipe(Effect.flatMap((raw) => Effect.try({
|
|
221
|
-
try: () =>
|
|
242
|
+
try: () => parseStateText(raw, file),
|
|
222
243
|
catch: (cause) => new StateDecodeError({ cause })
|
|
223
244
|
})), Effect.flatMap(decodeState), Effect.catchAll((error) => error._tag === "StateReadError" && isMissingStateFile(error.cause) ? Effect.succeed(emptyState()) : Effect.fail(error)));
|
|
224
245
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prevalentware/opencode-goal-plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.35",
|
|
4
4
|
"description": "OpenCode goal plugin that adds Codex-style long-running goal mode, /goal commands, persistence, and TUI status for AI coding agents.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"opencode",
|