opencode-work-context 0.2.0 → 0.2.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "opencode-work-context",
3
3
  "type": "module",
4
- "version": "0.2.0",
4
+ "version": "0.2.1",
5
5
  "description": "Filesystem work-context core and OpenCode adapter",
6
6
  "license": "MIT",
7
7
  "author": {
@@ -2,6 +2,7 @@ import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { contextFor } from "../src/opencode-adapter.js";
4
4
  import { atomicWrite } from "../src/storage.js";
5
+ import { isDependencySatisfied } from "../src/stage-status.js";
5
6
 
6
7
  const TERMINAL_STATUSES = new Set(["completed", "cancelled", "archived"]);
7
8
  const SESSION_STATE_RANK = { active: 0, handed_off: 1, abandoned: 2, closed: 3 };
@@ -69,7 +70,6 @@ export const readStageSwitcherSnapshot = ({ projectRoot: root, sessionId } = {})
69
70
  const listed = context.listStages(current.workspace).data;
70
71
  const workspace = context.listWorkspaces().data.find((item) => item.workspace === current.workspace);
71
72
  if (!workspace) return errorResult("NOT_FOUND", "The current work-context workspace no longer exists");
72
- const completed = new Set(listed.stages.filter((stage) => stage.status === "completed").map((stage) => stage.stage));
73
73
  return {
74
74
  ok: true,
75
75
  data: {
@@ -77,7 +77,7 @@ export const readStageSwitcherSnapshot = ({ projectRoot: root, sessionId } = {})
77
77
  currentStage: current.stage,
78
78
  stages: listed.stages.map((stage) => {
79
79
  const sessions = listed.sessions.filter((session) => session.stage === stage.stage);
80
- const blockers = (stage.depends_on || []).filter((dependency) => !completed.has(dependency));
80
+ const blockers = (stage.depends_on || []).filter((dependency) => !isDependencySatisfied(listed.stages.find((item) => item.stage === dependency)));
81
81
  return {
82
82
  id: stage.stage,
83
83
  title: stage.title,
package/src/core.js CHANGED
@@ -7,6 +7,7 @@ import { event, reduceSessions, activeSession, assertActive } from "./sessions.j
7
7
  import { generateProjections, renderSessions } from "./projections.js";
8
8
  import { nextKnowledgeId, parseKnowledge, renderKnowledge, validateKnowledgeInput, validateKnowledgeRecords } from "./knowledge.js";
9
9
  import { normalizeStageId, normalizeWorkspaceId } from "./identifiers.js";
10
+ import { isDependencySatisfied } from "./stage-status.js";
10
11
 
11
12
  const actor = (options) => options.actor || "OpenCode";
12
13
  const activeKnowledge = (records) => records
@@ -152,7 +153,7 @@ export class WorkContext {
152
153
  const stages = this.listStages(workspace).data.stages;
153
154
  for (const dependency of stageRecord.data.depends_on) {
154
155
  const record = stages.find((item) => item.stage === dependency);
155
- if (!record || record.status !== "completed") fail(ERROR_CODES.INVALID_STATE, `Stage dependency is not completed: ${dependency}`);
156
+ if (!isDependencySatisfied(record)) fail(ERROR_CODES.INVALID_STATE, `Stage dependency is not completed: ${dependency}`);
156
157
  }
157
158
  }
158
159
 
@@ -0,0 +1,3 @@
1
+ const DEPENDENCY_SATISFIED_STATUSES = new Set(["completed", "archived"]);
2
+
3
+ export const isDependencySatisfied = (stage) => DEPENDENCY_SATISFIED_STATUSES.has(stage?.status);