@distlang/opencode-plugin 0.1.8 → 0.1.9

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@distlang/opencode-plugin",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "OpenCode plugin for Distlang AI Debugger",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
package/src/index.js CHANGED
@@ -19,7 +19,7 @@ function debugLogFile() {
19
19
 
20
20
  export const DistlangAIDebugger = async ({ project, directory, client }) => {
21
21
  const debug = debugEnabled();
22
- const recorder = createRecorder({ project, directory });
22
+ const recorder = createRecorder({ project, directory, initialPrompt: extractOpenCodeRunPrompt(process.argv) });
23
23
  let loggedInit = false;
24
24
  let authWarningLogged = false;
25
25
  let distlangMissingLogged = false;
@@ -293,6 +293,39 @@ export const DistlangAIDebugger = async ({ project, directory, client }) => {
293
293
  return new Promise((resolve) => setTimeout(resolve, ms));
294
294
  }
295
295
 
296
+ function extractOpenCodeRunPrompt(argv) {
297
+ const args = Array.isArray(argv) ? argv : [];
298
+ const runIndex = args.findIndex((arg) => arg === "run");
299
+ if (runIndex < 0) {
300
+ return "";
301
+ }
302
+ const promptParts = [];
303
+ for (let index = runIndex + 1; index < args.length; index += 1) {
304
+ const arg = configuredValue(args[index], "");
305
+ if (!arg) {
306
+ continue;
307
+ }
308
+ if (arg === "--") {
309
+ continue;
310
+ }
311
+ if (arg === "--dangerously-skip-permissions") {
312
+ continue;
313
+ }
314
+ if (arg === "--model" || arg === "-m") {
315
+ index += 1;
316
+ continue;
317
+ }
318
+ if (arg.startsWith("--model=")) {
319
+ continue;
320
+ }
321
+ if (arg.startsWith("-")) {
322
+ continue;
323
+ }
324
+ promptParts.push(arg);
325
+ }
326
+ return promptParts.join(" ").trim();
327
+ }
328
+
296
329
  function messageShape(event) {
297
330
  const info = event && typeof event === "object" ? event.info ?? event.properties?.info : null;
298
331
  if (!info || typeof info !== "object") {
package/src/recorder.js CHANGED
@@ -32,8 +32,9 @@ const extensionLanguages = {
32
32
  ".yml": "yaml",
33
33
  };
34
34
 
35
- export function createRecorder({ project, directory }) {
35
+ export function createRecorder({ project, directory, initialPrompt = "" }) {
36
36
  const projectName = deriveProjectName(project, directory);
37
+ const configuredInitialPrompt = sanitizeDebuggerText(initialPrompt);
37
38
  const sessions = new Map();
38
39
 
39
40
  function activeSessionID() {
@@ -56,6 +57,7 @@ export function createRecorder({ project, directory }) {
56
57
  status: "success",
57
58
  summary: "",
58
59
  title: "",
60
+ initialPrompt: configuredInitialPrompt,
59
61
  interactions: [],
60
62
  currentInteractionID: "",
61
63
  interactionCounter: 0,
@@ -98,7 +100,7 @@ export function createRecorder({ project, directory }) {
98
100
  }
99
101
  return current;
100
102
  }
101
- return createInteraction(recorder, prompt, timestampMs);
103
+ return createInteraction(recorder, configuredValue(prompt, recorder.initialPrompt), timestampMs);
102
104
  }
103
105
 
104
106
  function addStep(recorder, interaction, step) {