Skip to content

feat: limit learning commands to learn mode - #37

Merged
vmiloserdov merged 3 commits into
mainfrom
learn-commands
Oct 9, 2026
Merged

vmiloserdov merged 3 commits into
mainfrom
learn-commands

Conversation

@vmiloserdov

@vmiloserdov vmiloserdov commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Issue for this PR

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

User story

As a student using Learn mode to understand a codebase without making changes, I want the learning-oriented commands to be available only in Learn mode, so that Build and other modes do not expose workflows intended for read-only exploration.

Changes

  • Makes /newcomer and /associate Learn-only commands.
    • Both commands are registered with the learn agent.
    • They appear in slash-command autocomplete only when Learn is selected.
    • The server rejects direct attempts to execute either command from a non-Learn mode, so the restriction is enforced even if a client bypasses autocomplete.
  • Restricts the teammate-added /group repository-learning-map command to Learn mode by registering it only while Learn is selected.
  • Preserves normal Learn behavior for the intended commands:
    • /newcomer continues to collect experience level and learning scope.
    • /associate continues to inspect a source file and report its associated tests.
    • /group continues to build repository learning groups and request read-only guidance through Learn.
  • Adds focused tests for:
    • Hiding Learn-only commands outside Learn mode.
    • Showing them while Learn is selected.
    • Rejecting /associate execution from Build mode before model execution.
    • Running the /associate TUI flow with Learn selected.
    • Recognizing Learn mode for the /group registration path.

How did you verify your code works?

Automated verification to run from the development container:

  • bun test test/session/prompt.test.ts from packages/opencode
  • bun test test/prompt/command.test.ts test/associate.e2e.test.ts test/group-map.e2e.test.ts from packages/tui
  • bun typecheck from packages/opencode
  • bun typecheck from packages/tui

Static verification completed:

  • git diff --check

Manual verification to perform:

  • Select Learn and confirm /newcomer, /associate, and /group are available.
  • Switch to Build and confirm those commands no longer appear in slash-command autocomplete.
  • Attempt /associate from Build and confirm the server rejects it with “only available in Learn mode.”
  • Confirm /newcomer, /associate, and /group continue to work in Learn mode.
  • Confirm unrelated commands and normal Build editing behavior remain available in Build mode.

Screenshots / recordings

The command behavior uses the existing mode selector and slash-command interface. I will attach a short recording showing:

  1. Learn mode displaying /newcomer, /associate, and /group.
  2. Build mode hiding those commands.
  3. A direct non-Learn /associate request being rejected.

GDrive Demo Link: https://drive.google.com/drive/folders/1WfCPocHSSPkcaTQu6bXUQeSjJbSU-zrr

Checklist

  • I have run the automated tests listed above in the container.
  • I have not included unrelated changes in this PR.

@carnegiedude carnegiedude left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like this Pull Request is mostly replacing the attributes of some of the commands with learn mode from build mode. The unit tests are good, it just might be pertinent to have a positive case and not just reject bad inputs. I hope you can run some tests locally before you merge or indicate if you have.

},
)

it.instance("Learn-only commands reject execution from other modes", () =>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good test for the rejection of learn commands in other modes. Is there a test for acceptance of learn mode commands in learn mode?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like the validation is included in the already existing tests, but I am not sure.

@vmiloserdov
vmiloserdov marked this pull request as ready for review October 9, 2026 16:28
@vmiloserdov
vmiloserdov merged commit 4bc1f29 into main Oct 9, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants