opencode-work-context 0.1.5 → 0.1.6
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 +1 -1
- package/src/core.js +13 -5
package/package.json
CHANGED
package/src/core.js
CHANGED
|
@@ -140,11 +140,11 @@ export class WorkContext {
|
|
|
140
140
|
return reduceSessions(this.storage.readEvents()).find((session) => session.session_id === sessionId) || null;
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
sessionByOpenCodeId(opencodeSessionId, workspace = null, stage = null) {
|
|
143
|
+
sessionByOpenCodeId(opencodeSessionId, workspace = null, stage = null, state = "active") {
|
|
144
144
|
return reduceSessions(this.storage.readEvents()).filter((session) => session.opencode_session_id === opencodeSessionId
|
|
145
145
|
&& (!workspace || session.workspace === workspace)
|
|
146
146
|
&& (!stage || session.stage === stage)
|
|
147
|
-
&& session.state ===
|
|
147
|
+
&& (!state || session.state === state)).at(-1) || null;
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
assertDependenciesCompleted(workspace, stageRecord) {
|
|
@@ -404,7 +404,15 @@ export class WorkContext {
|
|
|
404
404
|
current.data.updated_at = new Date().toISOString();
|
|
405
405
|
this.storage.writeMarkdown(this.storage.stageFile(workspace, stage), current.data, `${current.body}\n\n## Result\n\n${options.result || "Stage completed."}`);
|
|
406
406
|
generateProjections(this.storage);
|
|
407
|
-
|
|
407
|
+
const data = { session_id: sessionId, workspace, stage, state: "closed", status: "completed", knowledge_review: knowledgeReview, ...(knowledgeEntries ? { knowledge_entries: knowledgeEntries.length } : {}) };
|
|
408
|
+
const incompleteStages = this.listStages(workspace).data.stages.filter((item) => !["completed", "archived"].includes(item.status));
|
|
409
|
+
const next = incompleteStages.length ? null : {
|
|
410
|
+
action: "workspace_finish",
|
|
411
|
+
workspace,
|
|
412
|
+
command: `/wc workspace finish ${workspace}`,
|
|
413
|
+
reason: "All workspace stages are completed",
|
|
414
|
+
};
|
|
415
|
+
return this.result(data, [workspace, stage], next);
|
|
408
416
|
});
|
|
409
417
|
}
|
|
410
418
|
|
|
@@ -412,7 +420,7 @@ export class WorkContext {
|
|
|
412
420
|
return this.result({ command, syntax: "/wc [create|list|workspace list|workspace rename|workspace finish|resume|stage add|stage rename|stage update|stage archive|stage handoff|stage abandon|stage finish|link-issue|session rename|knowledge list|knowledge add|knowledge update|knowledge supersede|help]", note: "workspace is optional for stage add/rename/update/archive when the current session identifies one workspace; workspace finish requires all non-archived stages to be completed; archived stages retain their IDs and history and are hidden from the TUI by default; stage finish reviews Knowledge Base automatically by default (knowledgeReview=auto); mutating commands call structured tools; only explicit lifecycle operations change storage." }, []);
|
|
413
421
|
}
|
|
414
422
|
|
|
415
|
-
result(data, changed) {
|
|
416
|
-
return { ok: true, data, changed, next
|
|
423
|
+
result(data, changed, next = null) {
|
|
424
|
+
return { ok: true, data, changed, next };
|
|
417
425
|
}
|
|
418
426
|
}
|