parallax-opencode 0.3.7 → 0.3.8

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/plugin.js CHANGED
@@ -96,7 +96,41 @@ function loadConfig() {
96
96
  // State persistence (Phase 2.1)
97
97
  // ---------------------------------------------------------------------------
98
98
  let stateDebounceTimer = null;
99
- function writeState() {
99
+ function flushState() {
100
+ try {
101
+ const s = getFriction();
102
+ const m = getMode();
103
+ const p = getProtocol();
104
+ const state = {
105
+ sessionId: currentSessionId,
106
+ sessionStart: getTrace(sessionId()).session.startedAt,
107
+ mode: m.mode,
108
+ friction: {
109
+ successes: s.successes,
110
+ trials: s.trials,
111
+ retriesLeft: s.retriesLeft,
112
+ lastObservation: s.lastObservation,
113
+ },
114
+ protocol: {
115
+ ambiguityDone: p.ambiguityDone,
116
+ invariantsDone: p.invariantsDone,
117
+ gateDone: p.gateDone,
118
+ designDone: p.designDone,
119
+ commitDone: p.commitDone,
120
+ summaryDone: p.summaryDone,
121
+ writesBeforeGate: p.writesBeforeGate,
122
+ gateBlocked: p.gateBlocked,
123
+ },
124
+ };
125
+ writeFileSync(STATE_FILE, JSON.stringify(state, null, 2), "utf8");
126
+ }
127
+ catch { }
128
+ }
129
+ function writeState(immediate = false) {
130
+ if (immediate) {
131
+ flushState();
132
+ return;
133
+ }
100
134
  if (stateDebounceTimer)
101
135
  clearTimeout(stateDebounceTimer);
102
136
  stateDebounceTimer = setTimeout(() => {
@@ -286,7 +320,7 @@ export default {
286
320
  if (step === "ambiguity" && !p.ambiguityDone) {
287
321
  p.ambiguityDone = true;
288
322
  addPhase(sid, "ambiguity_check");
289
- writeState();
323
+ writeState(true);
290
324
  return "[parallax] Step 1/6: Ambiguity Check marked complete.";
291
325
  }
292
326
  if (step === "invariants") {
@@ -295,7 +329,7 @@ export default {
295
329
  }
296
330
  p.invariantsDone = true;
297
331
  addPhase(sid, "four_invariants");
298
- writeState();
332
+ writeState(true);
299
333
  return "[parallax] Step 2/6: 4 Invariants marked complete.";
300
334
  }
301
335
  if (step === "gate") {
@@ -304,7 +338,7 @@ export default {
304
338
  }
305
339
  p.gateDone = true;
306
340
  addPhase(sid, "verification_gate");
307
- writeState();
341
+ writeState(true);
308
342
  return "[parallax] Step 3/6: Verification Gate marked complete.";
309
343
  }
310
344
  if (step === "design") {
@@ -313,19 +347,19 @@ export default {
313
347
  }
314
348
  p.designDone = true;
315
349
  addPhase(sid, "design_check");
316
- writeState();
350
+ writeState(true);
317
351
  return "[parallax] Step 4/6: Design Doc marked complete.";
318
352
  }
319
353
  if (step === "commit") {
320
354
  p.commitDone = true;
321
355
  addPhase(sid, "commit_decision");
322
- writeState();
356
+ writeState(true);
323
357
  return "[parallax] Step 5/6: Commit Decision marked complete.";
324
358
  }
325
359
  if (step === "summary") {
326
360
  p.summaryDone = true;
327
361
  addPhase(sid, "summary");
328
- writeState();
362
+ writeState(true);
329
363
  // Phase 2.3: Post-session retrospective
330
364
  const trace = getTrace(sid);
331
365
  const breakdown = computeCoherenceScore(trace);
@@ -287,7 +287,41 @@ function loadConfig() {
287
287
  return configCache || {};
288
288
  }
289
289
  var stateDebounceTimer = null;
290
- function writeState() {
290
+ function flushState() {
291
+ try {
292
+ const s = getFriction();
293
+ const m = getMode();
294
+ const p = getProtocol();
295
+ const state = {
296
+ sessionId: currentSessionId,
297
+ sessionStart: getTrace(sessionId()).session.startedAt,
298
+ mode: m.mode,
299
+ friction: {
300
+ successes: s.successes,
301
+ trials: s.trials,
302
+ retriesLeft: s.retriesLeft,
303
+ lastObservation: s.lastObservation
304
+ },
305
+ protocol: {
306
+ ambiguityDone: p.ambiguityDone,
307
+ invariantsDone: p.invariantsDone,
308
+ gateDone: p.gateDone,
309
+ designDone: p.designDone,
310
+ commitDone: p.commitDone,
311
+ summaryDone: p.summaryDone,
312
+ writesBeforeGate: p.writesBeforeGate,
313
+ gateBlocked: p.gateBlocked
314
+ }
315
+ };
316
+ writeFileSync2(STATE_FILE, JSON.stringify(state, null, 2), "utf8");
317
+ } catch {
318
+ }
319
+ }
320
+ function writeState(immediate = false) {
321
+ if (immediate) {
322
+ flushState();
323
+ return;
324
+ }
291
325
  if (stateDebounceTimer) clearTimeout(stateDebounceTimer);
292
326
  stateDebounceTimer = setTimeout(() => {
293
327
  stateDebounceTimer = null;
@@ -455,7 +489,7 @@ Use grep and read to investigate ${args.topic} in the codebase, then proceed wit
455
489
  if (step === "ambiguity" && !p.ambiguityDone) {
456
490
  p.ambiguityDone = true;
457
491
  addPhase(sid, "ambiguity_check");
458
- writeState();
492
+ writeState(true);
459
493
  return "[parallax] Step 1/6: Ambiguity Check marked complete.";
460
494
  }
461
495
  if (step === "invariants") {
@@ -464,7 +498,7 @@ Use grep and read to investigate ${args.topic} in the codebase, then proceed wit
464
498
  }
465
499
  p.invariantsDone = true;
466
500
  addPhase(sid, "four_invariants");
467
- writeState();
501
+ writeState(true);
468
502
  return "[parallax] Step 2/6: 4 Invariants marked complete.";
469
503
  }
470
504
  if (step === "gate") {
@@ -473,7 +507,7 @@ Use grep and read to investigate ${args.topic} in the codebase, then proceed wit
473
507
  }
474
508
  p.gateDone = true;
475
509
  addPhase(sid, "verification_gate");
476
- writeState();
510
+ writeState(true);
477
511
  return "[parallax] Step 3/6: Verification Gate marked complete.";
478
512
  }
479
513
  if (step === "design") {
@@ -482,19 +516,19 @@ Use grep and read to investigate ${args.topic} in the codebase, then proceed wit
482
516
  }
483
517
  p.designDone = true;
484
518
  addPhase(sid, "design_check");
485
- writeState();
519
+ writeState(true);
486
520
  return "[parallax] Step 4/6: Design Doc marked complete.";
487
521
  }
488
522
  if (step === "commit") {
489
523
  p.commitDone = true;
490
524
  addPhase(sid, "commit_decision");
491
- writeState();
525
+ writeState(true);
492
526
  return "[parallax] Step 5/6: Commit Decision marked complete.";
493
527
  }
494
528
  if (step === "summary") {
495
529
  p.summaryDone = true;
496
530
  addPhase(sid, "summary");
497
- writeState();
531
+ writeState(true);
498
532
  const trace = getTrace(sid);
499
533
  const breakdown = computeCoherenceScore(trace);
500
534
  const s = getFriction();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "parallax-opencode",
3
- "version": "0.3.7",
3
+ "version": "0.3.8",
4
4
  "description": "PARALLAX ENGINE plugin for OpenCode -- protocol enforcement, friction-loop verification, mode switching (plan/build/debug), trace recording, coherence scoring, CI gate, and PR-ready trace artifacts",
5
5
  "type": "module",
6
6
  "main": "./dist/plugin.js",