Skip to content

feat(codemode): versioned program-source libraries + std v1 pure helpers (bind, chunk, uniqBy, keyBy, pick, omit) (design #800, phase 1) #802

Closed

Description

@dezren39

Sub-issue of #800 (design: Code Mode's missing standard library). Implements phase 1 of that design; the mechanism for #765's adopted Code Mode helper library.

Scope

  1. libraries option in @opencode/codemode (packages/codemode): CodeMode.make accepts named, versioned libraries — { name, version, source } where source is JavaScript in the interpreter's supported subset. At execution start each library is evaluated in the program scope and its exports bound to one frozen global per library. Library evaluation must not shift program diagnostic locations (Diagnostic.location in packages/codemode/src/codemode.ts still points at the program's own line/column).
  2. std library v1.0.0 — pure set only: std.version, std.bind(target, defaults) (wraps a tool callable or a whole namespace object; defaults merged under explicit arguments, explicit wins), std.chunk, std.uniqBy, std.keyBy, std.pick, std.omit. No async helpers in this phase (they are phase 2, a sibling sub-issue).
  3. Core wiring: packages/core/src/codemode/tool.ts runtime passes the std library. A bound tool call must still record, display, and hook as the original tool (the wrapper calls the same callable — hooks and toolCalls unchanged).
  4. Instructions: packages/core/src/codemode/instructions.ts lists std@1.0.0 with one signature line per member, through the existing Instructions diff machinery.
  5. packages/codemode/interpreter-support.md gains checklist entries for the library surface (it is a checklist, not a changelog — per packages/codemode/AGENTS.md).

Acceptance criteria

  • A Code Mode program can call std.chunk/uniqBy/keyBy/pick/omit and read std.version — covered by tests in packages/codemode that run the library inside the interpreter itself.
  • std.bind on a namespace with a fixed default (e.g. aws_profile) produces calls with the default applied; an explicit argument overrides it; the recorded/displayed tool call is the original tool.
  • A program that never touches std behaves exactly as today; a deliberate error after library installation reports the program's own line/column in its diagnostic.
  • The Code Mode instructions render the std listing with its version.
  • bun run check from the repo root passes, or pre-existing failures on the base branch are named in the closing note. Tests run from package directories per repo AGENTS.md, never the root.

Design: #800 (full text in the keep-the-four-repos-healthy goal workspace, files/designs/opencode-codemode-stdlib.md, §§1–2, 4).

Activity

  1. added
    kind/featureNew feature or capability request
    priority/normalOrdinary priority (the default)
    app/corePackage: core (pkgs/ or apps/ in this repo)
    on Oct 29, 2026
  2. developing-today commented on Oct 29, 2026

    @developing-today
  3. dezren39 commented on Oct 29, 2026

    @dezren39
    Author

    🤖 Agent note · filed

  4. added
    work/assignedAn agent holds this item via the queue (claimed task)
    queue/claimedA queue worker has claimed the task for this item
    and removed on Oct 29, 2026
  5. dezren39 commented on Oct 29, 2026

    @dezren39
    Author

    🤖 Agent note · done

    Triage verdict: CONFIRMED at origin/main 59d692b36e (2026-10-29T02:13Z)

    Issue stays open with queue/queued for follow-up task 2982.

  6. 14 remaining items

  7. dezren39 commented on Oct 29, 2026

    @dezren39
    Author

    Status by queue worker (lane A), task 2982: read the sealed unit logs from run 40807380452 and addressed the Codex review on PR #812; new head 93cec21bf1 pushed, CI re-running (run 40815525561). Parking until it lands.

    Unit failures on the previous head were both outside codemode (PR touches only codemode + core codemode files):

    • unit (linux): 1 fail — config plugin reloads > loads skills when home/.claude appears after startup (@opencode/core, watcher timing); codemode suites all passed (7019 pass in that run's core+codemode aggregate, this was the only fail).
    • unit (windows): 1 fail — upgrade command > is registered in root help and documents its options (@opencode/cli, hit the 30s test timeout).

    All three Codex findings were reproduced in the interpreter first, then fixed:

    • Library names that are reserved words (incl. this) are now rejected at make — a library named this previously overwrote the top-level this binding (typeof this returned "object").
    • std.bind now binds namespaces with children named name/length (namespace-object fallback when assignment over a function wrapper's read-only metadata throws) instead of failing with Cannot assign to read only property 'name'.
    • Library freezing routes through the shared SetIntegrityLevel implementation (freezeValue in stdlib/object) instead of a duplicate subclass ladder in execute.ts.

    Local verification on the new head: packages/codemode bun test 1409 pass / 0 fail (incl. new regression tests), packages/core codemode tests 29 pass, bun run check 36/36. PR body rewritten to the repo template (compliance bot had flagged it).

    Resume: when run 40815525561 finishes, if unit failures are only these same unrelated flakes, merge PR #812 per the standing directive, confirm #802 closed, complete task 2982 — that also unblocks parked task 2964 (#803 phase 2).

  8. added
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    status/parkedDeliberately paused with a recorded resume condition
    and removed
    queue/claimedA queue worker has claimed the task for this item
    on Oct 29, 2026
  9. dezren39 commented on Oct 29, 2026

    @dezren39
    Author

    CI rechecked by queue worker (lane B), task 2982: PR #812 head 93cec21bf1 — typecheck, affected-packages and nix-eval pass, remaining checks still in-progress/queued since 04:02Z with no failures (checked 2026-10-29T04:51Z). Task 2982 is re-parked 1h rather than waiting on the CI backlog; resume merges PR #812 once unit checks settle (allowing only the known unrelated flakes named in the queue resume brief).

  10. added
    queue/claimedA queue worker has claimed the task for this item
    and removed
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    on Oct 29, 2026
  11. removed
    queue/claimedA queue worker has claimed the task for this item
    work/assignedAn agent holds this item via the queue (claimed task)
    on Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    app/corePackage: core (pkgs/ or apps/ in this repo)effort/mMedium: expected under 1 day of workkind/featureNew feature or capability requestpriority/normalOrdinary priority (the default)source/design-architectFiled by the repo design architect jobstatus:done

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions