Skip to content

fix: honor custom prompt regexp semantics (v0.1.1) - #15

Merged
LeeEirc merged 1 commit into
masterfrom
fix/custom-prompt-regexp
Nov 4, 2026
Merged

LeeEirc merged 1 commit into
masterfrom
fix/custom-prompt-regexp

Conversation

@LeeEirc

@LeeEirc LeeEirc commented Nov 4, 2026 •

Copy link
Copy Markdown
Owner

Why

Custom prompt expressions in v0.1.0 were required to cover the entire normalized line, even when the caller provided an unanchored regexp. This changes ordinary Go regexp semantics and forces adapters such as Koko to add .* wrappers to restore in-line matching.

Changes

  • Use the caller's compiled expression directly with Regexp.Match for username, password, shell, failure, password-change, and continuation prompts.
  • Allow unanchored substring matches. Honor explicit start/end anchors, ordinary case sensitivity, (?i), and scoped regexp flags without rewriting the expression.
  • Keep built-in anchors, default shell/banners checks, diagnostic precedence and completion rules, normalization, and buffering limits. No matching-mode parameter is added.
  • Document that matching applies only to the current normalized line with surrounding whitespace trimmed. An accepted candidate line is consumed as a whole; a substring match does not split session data at the regexp match's end.
  • Add table-driven and stream regression coverage, and change the previous implicit-full-line test to use an explicit ^login:$ expression.

Koko integration

After upgrading its dependency to a version containing this fix, Koko's new adapter can pass compiled custom patterns directly and remove the .* compatibility wrapper. It should retain its explicit legacy-default fallback and rejection of configurations that match the empty string. Those application configuration policies do not move into this library.

This PR validates the library-side contract; it does not claim to have tested or modified Koko's separate, unpushed adapter changes.

Release intent

This PR updates VERSION and the changelog to v0.1.1. Merging it into master starts the existing release workflow; publication proceeds only after the release checks pass. Creating or updating the PR does not publish.

Callers that depended on v0.1.0's implicit whole-line restriction should add explicit ^ and $ anchors.

Validation

  • go test -race -timeout=3m ./... and go vet ./... passed.
  • Additional targeted race tests passed after adding the case-flag scenarios.
  • Five new regression-test groups cover all six fields, substring/full/start/end matching, case flags, default replacement, diagnostic precedence, password-change input, logical-line isolation, ANSI/backspace normalization, and preserved subsequent session data.
  • All 13 release-target tests passed with VERSION=v0.1.1; git diff --check passed.
  • Independent code, documentation, and test review found no blocking issues.
  • All five PR CI jobs passed for 3e6a5dc1d03c2b167c560c5a2b25b407195b1900: Linux/Windows × Go 1.20.x/stable and the six-platform release snapshot. The race tests, vet, Linux PTY/TCP checks, archive checksums, and extracted Linux CLI smoke checks passed.
  • GitHub automatically requested Copilot review, but Copilot reported insufficient account quota and did not produce a code review. Independent review completed with no blocking findings.

Copilot AI balanced review requested due to automatic review settings November 4, 2026 07:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@LeeEirc
LeeEirc merged commit e13e7d6 into master Nov 4, 2026
5 checks passed
@LeeEirc
LeeEirc deleted the fix/custom-prompt-regexp branch November 4, 2026 08:06
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