ECC/tests/lib
Affaan Mustafa ab5e17fea9
feat: extend session-adapter layer with codex-worktree + opencode adapters (#2145)
* feat: add codex-worktree session adapter

Adds the third session adapter (after dmux-tmux and claude-history),
normalizing Codex rollout sessions into the harness-neutral
ecc.session.v1 snapshot. Reads ~/.codex/sessions rollout JSONL,
derives objective (skipping the AGENTS.md preamble + leading message
UUID), model, originator, worktree cwd, and best-effort git branch.

This is step 1 of ECC-2.0-SESSION-ADAPTER-DISCOVERY (move the
abstraction beyond tmux + Claude-history) and supports the
wrap/adapt control-pane strategy: ECC reads sessions from any
harness rather than owning one UX.

- scripts/lib/session-adapters/codex-worktree.js: adapter + rollout parser
- canonical-session.js: normalizeCodexWorktreeSession
- registry.js: register adapter, codex/codex-worktree target types
- tests/lib/session-adapters-codex.test.js: 4 tests (unit + registry routing)

* feat: add opencode session adapter + allow empty intent objective

Adds the fourth session adapter (after dmux-tmux, claude-history,
codex-worktree), normalizing OpenCode sessions into ecc.session.v1.

Reads ~/.local/share/opencode/storage: session/<project>/ses_*.json
for metadata (id, directory, title, version, projectID, time) and
message/<session>/msg_*.json to extract the model (modelID/providerID
from the first assistant message). Derives objective from the session
title, treating the auto-generated "New session - <date>" title as no
objective. Recency-based active/recorded state.

Schema: relax intent.objective from non-empty to allow empty string
(ensureStringAllowEmpty). Sessions legitimately have no objective yet
(fresh/auto-titled), and claude-history already emitted "" via
metadata.title fallback. This fixes a latent over-strict validation.

- scripts/lib/session-adapters/opencode.js: adapter + storage parser
- canonical-session.js: normalizeOpencodeSession + ensureStringAllowEmpty
- registry.js: register adapter + opencode target type
- tests/lib/session-adapters-opencode.test.js: 5 tests

Tests: opencode 5/0, codex 4/0, session-adapters 14/0,
control-pane-state 10/0, session-inspect 8/0, control-pane 12/0.
Smoke-tested on a real OpenCode session (140 messages, gpt-5.3-codex).

* test: cover error/fallback branches for codex-worktree + opencode adapters

Lift global branch coverage past the 80% gate (was 79.53%). Adds error
and fallback path tests: missing-session/unknown-id throws, findRolloutById/
findSessionInfoById, direct file targets, objective truncation, model
fallbacks, corrupt-line skip, mtime activity fallback, and the real
resolveGitBranch path outside a repo.

codex-worktree.js branch 52.8%->78.3%; global branch 80.04%.
2026-06-06 03:55:00 +08:00
..
agent-compress.test.js feat: agent description compression with lazy loading (#696) 2026-03-20 03:53:22 -07:00
changed-files-store.test.js fix: port safe ci cleanup from backlog 2026-04-01 16:09:54 -07:00
command-plugin-root.test.js fix(hooks): avoid escaped quotes in plugin bootstrap 2026-05-19 05:15:42 -04:00
control-pane-actions.test.js feat: add ECC2 local control pane (#2131) 2026-06-03 21:54:30 +08:00
control-pane-state.test.js feat: add dynamic workflow team orchestration surface 2026-06-04 21:45:13 +08:00
cost-estimate.test.js feat: add ECC statusline observability hooks 2026-05-11 23:44:06 -04:00
inspection.test.js feat: agent compression, inspection logic, governance hooks (#491, #485, #482) (#688) 2026-03-20 01:38:13 -07:00
install-config.test.js feat: add install catalog and project config autodetection 2026-03-27 05:56:39 -04:00
install-executor.test.js feat: add Ruby and Rails rules 2026-05-13 06:27:08 -04:00
install-lifecycle.test.js test: cover install lifecycle edge paths 2026-04-29 17:56:25 -04:00
install-manifests.test.js feat: add zed install target 2026-05-17 07:06:49 -04:00
install-request.test.js fix(installer): harden locale docs install 2026-05-17 20:46:04 -04:00
install-state.test.js fix: harden release surface version and packaging sync (#1388) 2026-04-12 22:33:32 -07:00
install-targets.test.js fix(install-targets): validate compiled OpenCode plugin before install (#2041) 2026-05-25 14:07:52 -04:00
locale-install.test.js docs(i18n): add German localization scout (#2029) 2026-05-25 14:12:01 -04:00
mcp-config.test.js feat: support disabling bundled mcp servers 2026-04-05 14:37:28 -07:00
observer-sessions.test.js fix: port continuous-learning observer fixes 2026-05-11 03:35:42 -04:00
orchestration-session.test.js fix: retire legacy command shims from default surface 2026-04-29 23:56:40 -04:00
package-manager.test.js fix: harden Trae install ownership (#1013) 2026-03-30 02:01:54 -04:00
project-detect.test.js docs: salvage F# agent and language guidance 2026-05-11 21:43:17 -04:00
resolve-ecc-root.test.js fix: salvage remaining stale queue fixes (#1754) 2026-05-11 16:41:08 -04:00
resolve-formatter.test.js fix: harden Trae install ownership (#1013) 2026-03-30 02:01:54 -04:00
selective-install.test.js test: normalize zed install path assertion 2026-05-17 07:27:05 -04:00
session-adapters-codex.test.js feat: extend session-adapter layer with codex-worktree + opencode adapters (#2145) 2026-06-06 03:55:00 +08:00
session-adapters-opencode.test.js feat: extend session-adapter layer with codex-worktree + opencode adapters (#2145) 2026-06-06 03:55:00 +08:00
session-adapters.test.js test: cover session adapter edge cases 2026-04-29 18:21:31 -04:00
session-aliases.test.js fix: narrow unicode cleanup scope 2026-03-29 21:21:18 -04:00
session-bridge.test.js test(lib): make concurrent-write test actually concurrent + use regex matcher for assert.throws 2026-05-19 04:57:10 -04:00
session-manager.test.js test: cover canonical session duplicate precedence 2026-03-25 04:01:23 -04:00
shell-split.test.js fix(hooks): allow tmux-wrapped dev server commands (#321) 2026-03-07 14:47:49 -08:00
skill-dashboard.test.js test: cover skill dashboard edge paths 2026-04-29 19:15:47 -04:00
skill-evolution.test.js test: cover skill tracker edge paths 2026-04-29 19:21:03 -04:00
skill-improvement.test.js feat: self-improving skills loop — observe, inspect, amend, evaluate 2026-03-14 23:21:18 -07:00
state-store.test.js feat: sync GitHub queue into work items 2026-05-11 13:07:29 -04:00
tmux-worktree-orchestrator.test.js fix: retire legacy command shims from default surface 2026-04-29 23:56:40 -04:00
utils.test.js fix: respect home overrides in hook utilities 2026-04-02 18:22:07 -07:00