@bybrawe/opencode-loop 0.5.38 → 0.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 (70) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +33 -1
  3. package/examples/OPENCODE2-0.6.0.md +54 -0
  4. package/examples/OPENCODE2-0.6.1.md +60 -0
  5. package/package.json +15 -9
  6. package/scripts/branch-hygiene.mjs +326 -0
  7. package/scripts/comprehensive-test.mjs +12 -6
  8. package/scripts/control-plane-until-test.mjs +39 -0
  9. package/scripts/goal-compaction-safety-test.mjs +68 -0
  10. package/scripts/goal-companion-test.mjs +1 -1
  11. package/scripts/host-adapter-contract-test.mjs +1 -0
  12. package/scripts/install-node.mjs +118 -60
  13. package/scripts/install-test.mjs +3 -3
  14. package/scripts/install-with-goals.mjs +17 -4
  15. package/scripts/job-workspace-test.mjs +11 -1
  16. package/scripts/loopd-test.mjs +74 -4
  17. package/scripts/loopd.mjs +153 -25
  18. package/scripts/native-cli-host-canary.mjs +118 -0
  19. package/scripts/native-cli-io-test.mjs +66 -0
  20. package/scripts/native-cli-test.mjs +130 -0
  21. package/scripts/native-coexistence-test.mjs +38 -0
  22. package/scripts/native-entry-test.mjs +77 -0
  23. package/scripts/native-guide-test.mjs +45 -0
  24. package/scripts/native-install-pair-test.mjs +73 -0
  25. package/scripts/native-install-test.mjs +114 -0
  26. package/scripts/native-lifecycle-test.mjs +100 -0
  27. package/scripts/native-plugin-lifetime-test.mjs +92 -0
  28. package/scripts/native-presets-test.mjs +227 -0
  29. package/scripts/native-process-tree-fixture.mjs +72 -0
  30. package/scripts/native-process-tree-test.mjs +40 -0
  31. package/scripts/native-release.mjs +121 -0
  32. package/scripts/native-session-location-test.mjs +86 -0
  33. package/scripts/native-shell-test.mjs +38 -0
  34. package/scripts/native-v2-test.mjs +262 -0
  35. package/scripts/opencode-host.mjs +47 -0
  36. package/scripts/opencode2-loop-canary.mjs +72 -4
  37. package/scripts/package-native-smoke.mjs +31 -0
  38. package/scripts/publish-workflow-test.mjs +60 -19
  39. package/scripts/pulse-check.mjs +246 -0
  40. package/scripts/session-status-test.mjs +12 -0
  41. package/src/index.js +87 -48
  42. package/src/native.js +3135 -0
  43. package/src/plugin.js +19 -0
  44. package/src/server.js +2164 -4560
  45. package/src/source/core/jobs.js +17 -0
  46. package/src/source/core/process.js +6 -4
  47. package/src/source/core/progress.js +58 -0
  48. package/src/source/legacy-v1.js +9 -3
  49. package/src/source/native.js +1 -0
  50. package/src/source/opencode/host.js +1 -0
  51. package/src/source/opencode/loop-commands.js +1 -27
  52. package/src/source/opencode/loop-registration.js +2 -12
  53. package/src/source/opencode/messages.js +1 -1
  54. package/src/source/opencode2/commands.js +9 -4
  55. package/src/source/opencode2/event-bridge.js +15 -3
  56. package/src/source/opencode2/events.js +20 -0
  57. package/src/source/opencode2/experimental.js +2 -0
  58. package/src/source/opencode2/native-companion.js +24 -0
  59. package/src/source/opencode2/native-plugin.js +153 -0
  60. package/src/source/opencode2/native-policy.js +106 -0
  61. package/src/source/opencode2/native-runtime.js +464 -0
  62. package/src/source/opencode2/native-shell.js +81 -0
  63. package/src/source/opencode2/prompt-runtime.js +2 -0
  64. package/src/source/opencode2/session-location.js +16 -0
  65. package/src/source/runtime/goal-steering.js +17 -3
  66. package/src/source/runtime/job-workspace.js +11 -2
  67. package/src/source/runtime/session-status.js +11 -1
  68. package/src/source/server.js +9 -1
  69. package/src/v1.js +1 -0
  70. package/src/v2.js +10 -0
@@ -113,7 +113,17 @@ export function createSessionStatusRuntime(options = {}) {
113
113
 
114
114
  async function canFinalizeActiveRun(directory, client, sessionID, active, options = {}) {
115
115
  if (hasActiveToolCalls(sessionID) || hasBusyDescendant(sessionID)) return false
116
- if (!options.requireIdle && !options.forceStale) return true
116
+
117
+ // OpenCode 1.x can emit transient session.idle boundaries between tool
118
+ // steps while the same assistant turn is still in progress. When the
119
+ // message API can prove that the current assistant message is incomplete,
120
+ // keep the Loop-owned run active instead of treating that transient idle
121
+ // as a completed turn. Preserve the historical fallback when message
122
+ // completion evidence is unavailable.
123
+ if (!options.requireIdle && !options.forceStale) {
124
+ const completion = await activeRunCompletionFromMessages(directory, client, sessionID, active)
125
+ return completion !== "incomplete"
126
+ }
117
127
 
118
128
  const completion = options.forceStale
119
129
  ? await activeRunCompletionFromMessages(directory, client, sessionID, active)
@@ -1,6 +1,14 @@
1
- import OpenCodeLoopPlugin from "./v1.js"
2
1
  import OpenCodeLoopV2ExperimentalPlugin from "./opencode2/experimental.js"
3
2
 
3
+ // Load the legacy runtime only when a V1 host invokes its server contract.
4
+ // A runtime URL prevents bundlers from inlining the legacy implementation.
5
+ // Both source and package entries have a sibling v1.js; the package shim
6
+ // delegates to the standalone V1 bundle, without initializing it on V2.
7
+ async function OpenCodeLoopPlugin(...args) {
8
+ const { default: legacy } = await import(new URL("./v1.js", import.meta.url).href)
9
+ return legacy(...args)
10
+ }
11
+
4
12
  export const OPENCODE_LOOP_PLUGIN_ID = "@bybrawe/opencode-loop"
5
13
 
6
14
  export const OpenCodeLoopPluginModule = Object.freeze({
package/src/v1.js ADDED
@@ -0,0 +1 @@
1
+ export { default } from "./index.js"
package/src/v2.js ADDED
@@ -0,0 +1,10 @@
1
+ import { Plugin } from "@opencode/plugin"
2
+ import bundled from "./native.js"
3
+
4
+ const native = Plugin.define({
5
+ id: "@bybrawe/opencode-loop",
6
+ setup: (context) => bundled.setup(context),
7
+ })
8
+
9
+ export const OpenCodeLoopNativePlugin = native
10
+ export default native