Repository navigation
fix: preserve built-in login prompts with custom rules (v0.1.2) - #16
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Koko's historical platform configuration added custom login patterns without disabling standard prompts. In v0.1.0 and v0.1.1, a custom username, password, or shell expression replaced the built-in matcher, so one shared configuration could stop recognizing otherwise supported devices.
This change prioritizes connection compatibility while retaining the current stream handling and diagnostic precedence.
Changes
UsernamePrompt,PasswordPrompt, andShellPromptsupplement the built-in matcher: either branch can recognize the prompt.regexp.Matchsemantics, explicit anchors, and case flags. Expressions are not rewritten, and no matching-mode parameter is added.FailurePrompt,PasswordChangePrompt, andContinuePromptreplacement behavior, diagnostic completion/precedence, UTF-8 checks, line limits, and session-data preservation.Why bare defaults require a completed line
A read ending at
Usermay continue asUsername:; a read ending atPasswordmay continue asPassword expired policy: disabled. Acting on those prefixes can consume a prompt early, send credentials prematurely, or report a repeated-prompt failure.The new bare defaults therefore wait for CRLF/LF. Devices that deliberately wait at a bare prompt without a newline can use an explicit expression such as
(?i)^Password$. No extra timer or delay is introduced.Compatibility and Koko integration
ShellPrompt: ^READY>$also accepts a built-inrouter#prompt..*wrappers.Last login,success, and成功are not restored.Release intent
This PR updates
VERSIONand the changelog tov0.1.2. Merging intomasterstarts the existing release workflow; publication proceeds only after its checks pass. Opening the PR does not publish a release.Validation
go test -race -timeout=3m ./...passed.go vet ./...passed.All 13 release-target tests passed with
VERSION=v0.1.2.Targeted regression tests and
git diff --checkpassed.Six new regression groups cover all eight built-in/custom combinations across four read sizes, ANSI normalization and preserved session data, completed-line bare prompts, fragmented prompt/banner prefixes, explicit custom prompts without newlines, built-in shell boundaries, and diagnostic precedence.
Existing six-field regexp tests now distinguish the three supplemental fields from the three replacement fields.
Independent implementation, test, and documentation review found no blocking issues.
All five PR CI jobs passed for
03942085c25981daf3dc2f07d1f7fd1d546c2055: Linux/Windows × Go 1.20.x/stable and the release snapshot. Race tests, vet, Linux PTY/TCP checks, release archive checksums, and the 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.