mirror of
https://github.com/NeuralNomadsAI/CodeNomad.git
synced 2026-11-20 15:33:37 +00:00
Ship native integration Status sections and catalogue installation by integration ID, including the complete change from #1280. Keep plugin package management in Plugins, per-conversation attachment authority in Status, guarded installation, shared controls, persistent section customization and all ten UI/help locales.
Merge current origin/dev into the feature branch with an ordinary merge, preserving file-reader lifetime and the latest native browser fixture contracts. Resolve conflicts in instance-shell2.tsx, right-panel/core-runtime.tsx, automation-forms.test.ts and session-child-activity.test.ts without weakening assertions or deadlines.
ADMIN-FORCED MERGE AT THE HUMAN'S EXPLICIT REQUEST. The human accepts exactly these two remaining Missions browser failures for this merge:
- mission-schedule-list: fresh-read Start scenario, 15-second SSE setup timeout; reproduced on dev cc5961a797 and established as pre-existing.
- mission-lifecycle-revision: 409 without certified code scenario, 30-second bootstrap timeout; not reproduced by the bounded diagnosis, attribution UNKNOWN, not claimed as pre-existing.
Diagnosis evidence: https://github.com/NeuralNomadsAI/CodeNomad/pull/1283#issuecomment-6617704358
Original full-suite record: https://github.com/NeuralNomadsAI/CodeNomad/pull/1283#issuecomment-6617213011 (1805 pass / 2 fail / 0 skip).
Post-synchronization validation on aba257802949123028741982ba64da988abcbb01: root/server/UI typechecks pass; relevant unit and route suites 142/142; help 31/31; integration browser plus conflicted Forms/session-child suites 144/144; additional file-preview browser regression 5/5. Zero skips or weakened assertions/deadlines.
Foreground gh pr checks --watch completed. Ready-for-review CI run 41737660774 succeeded on this exact head, including all four browser shards, unit tests, compatibility, runtime contracts, native pruning and desktop builds: https://github.com/NeuralNomadsAI/CodeNomad/actions/runs/41737660774 . The preceding run 41737659582 was cancelled; its four cancelled jobs have no steps and remain displayed as fail by gh. These are cancellation records, not executed test failures. The historical two-failure local full result and its limited acceptance remain recorded above.
This exception is limited to this administrative merge. Separate desktop/manual/privacy and publication gates remain scoped independently. No release, tag, npm publication or catalogue change.
92 lines
7.7 KiB
JavaScript
92 lines
7.7 KiB
JavaScript
// OpenCode integration recognition against a real isolated daemon (dev-docs/OPENCODE_INTEGRATIONS.md, Recognition):
|
|
// the loopback fake registry installs the fake integration (loaded, answering `status`), a marker-mismatch variant
|
|
// (non-conforming) and a third one disabled by its exact `-neuralnomads.<id>` rule, which OpenCode does not list. The
|
|
// integrations read recognises each by the catalog, calls only the catalog's RPC IDs, and adding a native
|
|
// integration to Project is refused before any write. A package absent from the registry fails before exporting its
|
|
// plugin ID and is still attributed by its one exact source; installation by catalog ID writes the catalog spec and
|
|
// refuses Project, declared and loaded integrations without writing.
|
|
import assert from "node:assert/strict"
|
|
import { readFile, writeFile } from "node:fs/promises"
|
|
import path from "node:path"
|
|
import { setTimeout as delay } from "node:timers/promises"
|
|
import { packFakeIntegration } from "./fixtures/fake-integration/index.mjs"
|
|
import { startFakeNpmRegistry } from "./fixtures/fake-npm-registry.mjs"
|
|
import { withProductRuntime } from "./native-product-fixture.mjs"
|
|
import { catalogEntry, catalogOf } from "../packages/server/src/opencode/integrations/catalog-fixture.ts"
|
|
import { IntegrationInstaller } from "../packages/server/src/opencode/integrations/install.ts"
|
|
import { IntegrationsReader } from "../packages/server/src/opencode/integrations/integrations.ts"
|
|
import { PluginControls } from "../packages/server/src/opencode/plugin-controls.ts"
|
|
import { PluginSources } from "../packages/server/src/opencode/plugin-sources.ts"
|
|
|
|
const registry = await startFakeNpmRegistry()
|
|
const catalog = catalogOf(catalogEntry("fixture"), catalogEntry("drift"), catalogEntry("off"), catalogEntry("absent"), catalogEntry("broken"),
|
|
catalogEntry("later"))
|
|
const catalogSource = { read: async () => ({ state: "fresh", fetchedAt: new Date(0).toISOString(), catalog }) }
|
|
let configDirectory
|
|
try {
|
|
await withProductRuntime(process.argv[2], async ({ root, configDirectory: directory }) => {
|
|
configDirectory = directory
|
|
const packs = [await packFakeIntegration(root), await packFakeIntegration(root, { id: "drift", markerMismatch: true }), await packFakeIntegration(root, { id: "off" })]
|
|
for (const pack of packs) registry.publish(pack.name, pack.version, pack.tarball)
|
|
await writeFile(path.join(directory, "opencode.jsonc"), JSON.stringify({
|
|
plugins: [...packs.map(pack => `${pack.name}@${pack.version}`), "-neuralnomads.off", "@neuralnomads/opencode-broken@0.1.0"] }))
|
|
return {}
|
|
}, async ({ client, root, connection }) => {
|
|
const location = { directory: root }
|
|
await client.location.get({ location })
|
|
const calls = []
|
|
const recorded = { ...connection, client: { ...connection.client, rpc: { call: (request, options) => {
|
|
calls.push(request.rpcID)
|
|
return connection.client.rpc.call(request, options)
|
|
} } } }
|
|
const workspaceManager = {
|
|
get: () => ({}), getSharedServiceConnection: async () => recorded,
|
|
getServiceDirectoryForPath: async (_id, value) => value === root ? root : undefined,
|
|
ownsLocation: async (_id, candidate) => candidate.directory === root,
|
|
getWorktreeIdentityForPath: async () => "fixture-root", getServicePathStyle: () => process.platform === "win32" ? "win32" : "posix",
|
|
getServiceWslDistro: () => undefined, getHostPathForServicePath: async (_id, value) => value,
|
|
}
|
|
const controls = new PluginControls({ workspaceManager, worktreeDeletionFence: { enter: () => () => {} }, logger: { info() {} } })
|
|
const reader = new IntegrationsReader({ controls, workspaceManager, catalog: catalogSource })
|
|
const states = response => Object.fromEntries(response.integrations.map(item => [item.id, item.state]))
|
|
let response
|
|
for (const deadline = Date.now() + 90_000; ; await delay(250)) {
|
|
response = await reader.read("fixture", location)
|
|
if (states(response).fixture === "ok" && states(response).drift !== "inactive" && states(response).broken === "failed") break
|
|
if (Date.now() > deadline) assert.fail(`Integrations did not load: ${JSON.stringify(states(response))}`)
|
|
}
|
|
assert.deepEqual(states(response), { fixture: "ok", drift: "non-conforming", off: "inactive", absent: "absent", broken: "failed", later: "absent" })
|
|
const off = response.integrations.find(item => item.id === "off")
|
|
assert.equal(off.configured, true, "The disabled integration is recognised by its exact rule")
|
|
assert.deepEqual(off.scopes, ["global"])
|
|
const facts = Object.fromEntries(response.integrations.map(item => [item.id, item.plugin]))
|
|
assert.deepEqual(facts, { fixture: { declared: true, runtime: "loaded" }, drift: { declared: true, runtime: "loaded" },
|
|
off: { declared: true }, absent: { declared: false }, broken: { declared: true, runtime: "failed" }, later: { declared: false } })
|
|
assert.equal(response.integrations.some(item => item.ambiguous), false)
|
|
assert.equal(response.integrations.find(item => item.id === "drift").ambiguous, undefined, "a marker mismatch is not ambiguity")
|
|
const failed = (await controls.read("fixture", location)).runtime.find(item => item.source.type === "package"
|
|
&& item.source.target === "@neuralnomads/opencode-broken@0.1.0")
|
|
assert.equal(failed?.id, undefined, "A real native failure precedes the exported plugin ID")
|
|
assert.equal(JSON.stringify(response).includes("127.0.0.1"), false, "Registry addresses and native errors stay out of the projection")
|
|
assert.deepEqual(response.integrations.find(item => item.id === "fixture").status.host, { state: "absent", expectedRange: "^0.1.0", action: "install" })
|
|
assert.deepEqual([...new Set(calls)].sort(), ["neuralnomads.drift", "neuralnomads.fixture"], "Only loaded integrations are called, under catalog RPC IDs")
|
|
|
|
const before = await readFile(path.join(configDirectory, "opencode.jsonc"), "utf8")
|
|
const sources = new PluginSources({ documents: controls, logger: { info() {} }, catalog: catalogSource })
|
|
await assert.rejects(sources.add("fixture", { location, scope: "project", spec: "@neuralnomads/opencode-absent@0.1.0" }), error => error.code === "global-only")
|
|
await assert.rejects(sources.add("fixture", { location, scope: "global", spec: "@neuralnomads/opencode-fixture@latest" }), error => error.code === "duplicate")
|
|
assert.equal(await readFile(path.join(configDirectory, "opencode.jsonc"), "utf8"), before, "Refused adds write nothing")
|
|
|
|
const installer = new IntegrationInstaller({ controls, workspaceManager, catalog: catalogSource, sources })
|
|
for (const [id, scope, code] of [["later", "project", "global-only"], ["fixture", "global", "duplicate"], ["off", "global", "duplicate"], ["broken", "global", "duplicate"]]) {
|
|
await assert.rejects(installer.install("fixture", id, location, scope), error => error.code === code, `${id} ${scope}`)
|
|
}
|
|
assert.equal(await readFile(path.join(configDirectory, "opencode.jsonc"), "utf8"), before, "Refused installs write nothing")
|
|
assert.deepEqual(await installer.install("fixture", "later", location, "global"), { scope: "global", spec: "@neuralnomads/opencode-later@^0.1", reloadPending: true })
|
|
assert.deepEqual(JSON.parse(await readFile(path.join(configDirectory, "opencode.jsonc"), "utf8")).plugins.at(-1), "@neuralnomads/opencode-later@^0.1")
|
|
await assert.rejects(installer.install("fixture", "later", location, "global"), error => error.code === "duplicate", "A written install is a declaration")
|
|
}, { registry: registry.url })
|
|
console.log("PASS integration recognition: loaded, marker mismatch, normalized disabled rule, absent, failed package without ID, plugin facts; Global-only and duplicate adds and installs refused, install by catalog ID written")
|
|
} finally {
|
|
await registry.close()
|
|
}
|