Skip to content

fix: harden client detection and Windows auth handling - #1

Merged
moyu-by merged 1 commit into
moyu-by:mainfrom
liuhaodeyu:main
Sep 15, 2026
Merged

moyu-by merged 1 commit into
moyu-by:mainfrom
liuhaodeyu:main

Conversation

@liuhaodeyu

Copy link
Copy Markdown

Windows-focused hardening, split from review of the plugin.

Changes

  • detect host by executable basename (kilo first) to avoid parent-dir false positives
  • prefer ~/.local/share for auth.json, fall back to the other client's store
  • atomic state writes with temp-dir fallback when the plugin dir is read-only
  • install.ps1: -LiteralPath, legacy cleanup, duplicate-plugin warning, UTF-8 BOM (PS 5.1 needs it for non-ASCII comments)
  • docs: Windows env examples; tests: regression coverage; add .gitattributes

Verification

  • node --check index.js
  • npm test -> 11 passed
  • PowerShell 5.1 Parser::ParseFile -> 0 errors

- detect host by executable basename (kilo first) to avoid parent-dir false positives

- prefer ~/.local/share for auth.json, fall back to the other client's store

- atomic state writes with temp-dir fallback when the plugin dir is read-only

- install.ps1: -LiteralPath, legacy cleanup, duplicate-plugin warning, UTF-8 BOM

- docs: Windows env examples; tests: regression coverage; add .gitattributes
@moyu-by
moyu-by merged commit b6b1673 into moyu-by:main Sep 15, 2026
moyu-by added a commit that referenced this pull request Sep 15, 2026
OpenCode's plugin loader scans every module export and throws
`TypeError("Plugin export is not a function")` for anything that is not a
plugin factory, then swallows the error — so the `_internal` export added in
#1 silently dropped the whole plugin on OpenCode (Kilo only skips such
exports). Move the test-only helpers onto `CommandCode._internal` so index.js
exports nothing but functions.

- detectClient: split on `\` and `/`, so Windows paths are analysed the same
  on every platform (the previous test asserted this but failed on Linux)
- use a single writable state dir for reads and writes, so a plugin dir that
  later turns read-only can no longer shadow fresh caches in the temp dir;
  the temp dir is per-uid and created with mode 0700
- document the intentional cross-client credential fallback in the comment and
  README (the old comment claimed the two stores must stay separate)
- install.ps1: match the quoted npm package name exactly (a file:// reference
  to this repo was reported as an npm plugin), warn on such references too,
  only delete the known legacy plugin file names, fix the kilo.json path
- tests: isolate the credential store from the developer machine, cover the
  export shape and the read-only state-dir fallback
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