@codemcp/workflows-opencode 6.5.1 → 6.6.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.
Files changed (2) hide show
  1. package/dist/index.js +92 -5
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -16919,11 +16919,30 @@ var ConversationManager = class {
16919
16919
  database;
16920
16920
  projectPath;
16921
16921
  workflowManager;
16922
+ currentSessionMetadata = null;
16922
16923
  constructor(database, workflowManager, projectPath) {
16923
16924
  this.database = database;
16924
16925
  this.workflowManager = workflowManager;
16925
16926
  this.projectPath = projectPath;
16926
16927
  }
16928
+ /**
16929
+ * Set session metadata for subsequent conversation state operations.
16930
+ * This links the workflow state to an external session context.
16931
+ *
16932
+ * @param sessionMetadata - Session metadata to store with conversation state
16933
+ */
16934
+ setSessionMetadata(sessionMetadata) {
16935
+ this.currentSessionMetadata = sessionMetadata;
16936
+ logger8.debug("Session metadata set", {
16937
+ referenceId: sessionMetadata.referenceId
16938
+ });
16939
+ }
16940
+ /**
16941
+ * Get current session metadata
16942
+ */
16943
+ getSessionMetadata() {
16944
+ return this.currentSessionMetadata;
16945
+ }
16927
16946
  /**
16928
16947
  * Get conversation state by ID
16929
16948
  */
@@ -17065,7 +17084,10 @@ var ConversationManager = class {
17065
17084
  requireReviewsBeforePhaseTransition: false,
17066
17085
  // Default to false for new conversations
17067
17086
  createdAt: timestamp22,
17068
- updatedAt: timestamp22
17087
+ updatedAt: timestamp22,
17088
+ ...this.currentSessionMetadata && {
17089
+ sessionMetadata: this.currentSessionMetadata
17090
+ }
17069
17091
  };
17070
17092
  await this.database.saveConversationState(newState);
17071
17093
  logger8.info("New conversation state created", {
@@ -26866,11 +26888,30 @@ var ConversationManager2 = class {
26866
26888
  database;
26867
26889
  projectPath;
26868
26890
  workflowManager;
26891
+ currentSessionMetadata = null;
26869
26892
  constructor(database, workflowManager, projectPath) {
26870
26893
  this.database = database;
26871
26894
  this.workflowManager = workflowManager;
26872
26895
  this.projectPath = projectPath;
26873
26896
  }
26897
+ /**
26898
+ * Set session metadata for subsequent conversation state operations.
26899
+ * This links the workflow state to an external session context.
26900
+ *
26901
+ * @param sessionMetadata - Session metadata to store with conversation state
26902
+ */
26903
+ setSessionMetadata(sessionMetadata) {
26904
+ this.currentSessionMetadata = sessionMetadata;
26905
+ logger31.debug("Session metadata set", {
26906
+ referenceId: sessionMetadata.referenceId
26907
+ });
26908
+ }
26909
+ /**
26910
+ * Get current session metadata
26911
+ */
26912
+ getSessionMetadata() {
26913
+ return this.currentSessionMetadata;
26914
+ }
26874
26915
  /**
26875
26916
  * Get conversation state by ID
26876
26917
  */
@@ -27012,7 +27053,10 @@ var ConversationManager2 = class {
27012
27053
  requireReviewsBeforePhaseTransition: false,
27013
27054
  // Default to false for new conversations
27014
27055
  createdAt: timestamp3,
27015
- updatedAt: timestamp3
27056
+ updatedAt: timestamp3,
27057
+ ...this.currentSessionMetadata && {
27058
+ sessionMetadata: this.currentSessionMetadata
27059
+ }
27016
27060
  };
27017
27061
  await this.database.saveConversationState(newState);
27018
27062
  logger31.info("New conversation state created", {
@@ -27869,7 +27913,13 @@ var logger36 = createLogger2("SystemPromptGenerator");
27869
27913
  // src/server-context.ts
27870
27914
  import * as path9 from "path";
27871
27915
  function createServerContext(options) {
27872
- const { projectDir, planManager, instructionGenerator, loggerFactory } = options;
27916
+ const {
27917
+ projectDir,
27918
+ planManager,
27919
+ instructionGenerator,
27920
+ loggerFactory,
27921
+ sessionMetadata
27922
+ } = options;
27873
27923
  const workflowManager = new WorkflowManager2();
27874
27924
  workflowManager.loadProjectWorkflows(projectDir);
27875
27925
  const fileStorage = new FileStorage2(
@@ -27896,7 +27946,8 @@ function createServerContext(options) {
27896
27946
  interactionLogger,
27897
27947
  projectPath: projectDir,
27898
27948
  pluginRegistry,
27899
- loggerFactory
27949
+ loggerFactory,
27950
+ sessionMetadata
27900
27951
  };
27901
27952
  }
27902
27953
  async function initializeServerContext(context) {
@@ -28306,6 +28357,8 @@ var WorkflowsPlugin = async (input) => {
28306
28357
  const instructionGenerator = new InstructionGenerator2();
28307
28358
  let cachedServerContext = null;
28308
28359
  let serverContextInitialized = false;
28360
+ let currentSessionId = null;
28361
+ let lastKnownSessionId = null;
28309
28362
  let bufferedInstructions = null;
28310
28363
  function setBufferedInstructions(result) {
28311
28364
  bufferedInstructions = {
@@ -28316,13 +28369,32 @@ var WorkflowsPlugin = async (input) => {
28316
28369
  };
28317
28370
  }
28318
28371
  async function getServerContext() {
28372
+ if (currentSessionId && currentSessionId !== lastKnownSessionId) {
28373
+ logger37.debug("Session ID changed, invalidating cached ServerContext", {
28374
+ oldSessionId: lastKnownSessionId,
28375
+ newSessionId: currentSessionId
28376
+ });
28377
+ cachedServerContext = null;
28378
+ serverContextInitialized = false;
28379
+ lastKnownSessionId = currentSessionId;
28380
+ }
28319
28381
  if (!cachedServerContext) {
28382
+ const sessionMetadata = currentSessionId ? {
28383
+ referenceId: currentSessionId,
28384
+ createdAt: (/* @__PURE__ */ new Date()).toISOString()
28385
+ } : void 0;
28320
28386
  cachedServerContext = createServerContext({
28321
28387
  projectDir: input.directory,
28322
28388
  planManager,
28323
28389
  instructionGenerator,
28324
- loggerFactory
28390
+ loggerFactory,
28391
+ sessionMetadata
28325
28392
  });
28393
+ if (sessionMetadata) {
28394
+ cachedServerContext.conversationManager.setSessionMetadata(
28395
+ sessionMetadata
28396
+ );
28397
+ }
28326
28398
  }
28327
28399
  if (!serverContextInitialized) {
28328
28400
  await initializeServerContext(cachedServerContext);
@@ -28365,6 +28437,21 @@ var WorkflowsPlugin = async (input) => {
28365
28437
  * We add a synthetic part with phase instructions.
28366
28438
  */
28367
28439
  "chat.message": async (hookInput, output) => {
28440
+ if (hookInput.sessionID) {
28441
+ if (!currentSessionId) {
28442
+ currentSessionId = hookInput.sessionID;
28443
+ lastKnownSessionId = hookInput.sessionID;
28444
+ logger37.debug("Captured initial session ID", {
28445
+ sessionId: currentSessionId
28446
+ });
28447
+ } else if (currentSessionId !== hookInput.sessionID) {
28448
+ currentSessionId = hookInput.sessionID;
28449
+ logger37.info("Session ID changed", {
28450
+ oldSessionId: lastKnownSessionId,
28451
+ newSessionId: currentSessionId
28452
+ });
28453
+ }
28454
+ }
28368
28455
  if (!workflowsEnabled) {
28369
28456
  logger37.debug("chat.message: Workflows disabled, skipping hook");
28370
28457
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemcp/workflows-opencode",
3
- "version": "6.5.1",
3
+ "version": "6.6.1",
4
4
  "description": "OpenCode plugin for structured development workflows",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -19,8 +19,8 @@
19
19
  "rimraf": "^6.0.1",
20
20
  "tsup": "^8.0.0",
21
21
  "vitest": "4.0.18",
22
- "@codemcp/workflows-core": "6.5.1",
23
- "@codemcp/workflows-server": "6.5.1"
22
+ "@codemcp/workflows-core": "6.6.1",
23
+ "@codemcp/workflows-server": "6.6.1"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "@anthropic-ai/sdk": "*"