orchestrar 0.3.3 → 0.3.4

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/orchestrator.js +46 -55
  2. package/package.json +1 -1
package/orchestrator.js CHANGED
@@ -58,7 +58,7 @@ async function runWorkInstance(createOpencode, docs, root) {
58
58
  );
59
59
  await waitForMessageComplete(client, sessionID, workMessageID, root);
60
60
 
61
- await runReviewLoop(createOpencode, client, sessionID, root);
61
+ await runReviewLoop(client, sessionID, root);
62
62
 
63
63
  const markTasksMessageID = await sendPrompt(
64
64
  client,
@@ -100,7 +100,7 @@ async function runCommitInstance(createOpencode, root) {
100
100
  }
101
101
  }
102
102
 
103
- async function runReviewLoop(createOpencode, client, sessionID, root) {
103
+ async function runReviewLoop(client, sessionID, root) {
104
104
  const maxIterations = parseNumber(
105
105
  process.env.ORCHESTRATOR_MAX_REVIEW_ITERATIONS,
106
106
  DEFAULT_MAX_REVIEW_ITERATIONS
@@ -108,7 +108,7 @@ async function runReviewLoop(createOpencode, client, sessionID, root) {
108
108
 
109
109
  for (let iteration = 1; iteration <= maxIterations; iteration += 1) {
110
110
  logStep(`Running review (${iteration}/${maxIterations})`);
111
- const reviewResult = await runReviewCommand(createOpencode, root);
111
+ const reviewResult = await runReviewCommand(client, root);
112
112
  if (isFindingsEmpty(reviewResult)) {
113
113
  logStep("Review clean; no findings.");
114
114
  return;
@@ -132,7 +132,7 @@ async function runReviewLoop(createOpencode, client, sessionID, root) {
132
132
  );
133
133
  }
134
134
 
135
- async function runReviewCommand(createOpencode, root) {
135
+ async function runReviewCommand(client, root) {
136
136
  const commandName =
137
137
  process.env.ORCHESTRATOR_REVIEW_COMMAND || DEFAULT_REVIEW_COMMAND_NAME;
138
138
  const commandArguments =
@@ -142,65 +142,56 @@ async function runReviewCommand(createOpencode, root) {
142
142
  process.env.ORCHESTRATOR_REVIEW_TIMEOUT_MS,
143
143
  DEFAULT_REVIEW_TIMEOUT_MS
144
144
  );
145
+ const session = await unwrap(
146
+ client.session.create({
147
+ query: { directory: root },
148
+ body: { title: "Review" },
149
+ }),
150
+ "session.create"
151
+ );
145
152
 
146
- const { client, server } = await createOpencode({
147
- config: buildConfig(DEFAULT_MODEL),
148
- });
153
+ const sessionID = extractSessionID(session, "session.create (review instance)");
154
+ const commandResult = await unwrap(
155
+ client.session.command({
156
+ path: { id: sessionID },
157
+ query: { directory: root },
158
+ body: {
159
+ command: commandName,
160
+ arguments: commandArguments,
161
+ agent: DEFAULT_AGENT,
162
+ model: DEFAULT_MODEL,
163
+ },
164
+ }),
165
+ "session.command"
166
+ );
149
167
 
150
- try {
151
- const session = await unwrap(
152
- client.session.create({
153
- query: { directory: root },
154
- body: { title: "Review" },
155
- }),
156
- "session.create"
157
- );
168
+ const commandMessageID = extractMessageID(commandResult);
169
+ await waitForMessageComplete(
170
+ client,
171
+ sessionID,
172
+ commandMessageID,
173
+ root,
174
+ timeoutMs
175
+ );
158
176
 
159
- const sessionID = extractSessionID(session, "session.create (review instance)");
160
- const commandResult = await unwrap(
161
- client.session.command({
162
- path: { id: sessionID },
177
+ let parts = commandResult?.parts ?? [];
178
+ const messageID = extractMessageID(commandResult);
179
+ if (messageID) {
180
+ const message = await unwrap(
181
+ client.session.message({
182
+ path: { id: sessionID, messageID },
163
183
  query: { directory: root },
164
- body: {
165
- command: commandName,
166
- arguments: commandArguments,
167
- agent: DEFAULT_AGENT,
168
- model: DEFAULT_MODEL,
169
- },
170
184
  }),
171
- "session.command"
172
- );
173
-
174
- const commandMessageID = extractMessageID(commandResult);
175
- await waitForMessageComplete(
176
- client,
177
- sessionID,
178
- commandMessageID,
179
- root,
180
- timeoutMs
185
+ "session.message"
181
186
  );
187
+ parts = message?.parts ?? parts;
188
+ }
182
189
 
183
- let parts = commandResult?.parts ?? [];
184
- const messageID = extractMessageID(commandResult);
185
- if (messageID) {
186
- const message = await unwrap(
187
- client.session.message({
188
- path: { id: sessionID, messageID },
189
- query: { directory: root },
190
- }),
191
- "session.message"
192
- );
193
- parts = message?.parts ?? parts;
194
- }
195
-
196
- const output = collectCommandOutput(parts);
197
- if (!output.trim()) {
198
- throw new Error("Review command produced no output.");
199
- }
200
- return extractReviewJson(output);
201
- } finally {
202
- await disposeInstance(client, server, root);
190
+ const output = collectCommandOutput(parts);
191
+ if (!output.trim()) {
192
+ throw new Error("Review command produced no output.");
203
193
  }
194
+ return extractReviewJson(output);
204
195
  }
205
196
 
206
197
  async function sendPrompt(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orchestrar",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "description": "OpenCode milestone orchestrator",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",