Commit Graph

12 Commits

Author SHA1 Message Date
wbtiger 95fdee5cd8 fix: use cookie-based auth for login — resolves Windows 401
Root cause: GitLink login API returns session cookies (autologin_trustie),
not API access_tokens. The old code tried to use the cookie value as an
access_token query parameter, which GitLink rejects.

Fix: store auth cookies with "cookie:" prefix. Transport detects the
prefix and sends credentials as Cookie header instead of access_token
param. Private tokens (from --token mode) continue to use access_token
param — fully backward compatible.

Verified: login → store cookie → GetCurrentUser → repo list all pass.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-08 13:01:55 +08:00
wbtiger a27122ab76 fix: GetCurrentUser must check HTTP status and JSON status for token verification
GetCurrentUser() was not checking the HTTP status code or the JSON
"status" field. GitLink returns {"status":401,"message":"无效token"}
as valid JSON, so json.Unmarshal succeeds and the function returns nil
error — making any token appear valid.

Now properly checks HTTP status code, JSON status field, and requires
"login" field in response. If login API tokens fail verification,
shows clear guidance to use private token (--token mode).

Root cause of Windows 401: login API returns session/CSRF token, not
a valid API access_token. The broken verification masked this entirely.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-08 12:38:25 +08:00
wbtiger 78f435a57c fix: force binary re-download on version mismatch in postinstall
The postinstall script was only checking if the existing binary could
run (--help), not whether its version matched the npm package version.
This caused npm upgrades to skip downloading the new binary, leaving
users on stale versions without fixes.

Now checks `gitlink-cli version` output against package.json version.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-08 09:56:55 +08:00
wbtiger 993896ad6f fix: robust login token handling — verify token before storing
- Prefer autologin cookie over response body token (body token may be CSRF/session token)
- Use cookiejar to capture cookies across redirects
- Try all candidate tokens and verify each with /users/me API call
- Detect keyring store/load mismatch and auto-fallback to file storage
- Login now fails fast if no candidate token works, instead of silently storing a bad token

Fixes Windows 401 "无效token" after successful login. Also improves
reliability on headless Linux (no Secret Service) and edge cases on macOS.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-07 17:19:06 +08:00
wbtiger 5975c0759c feat: add gitlink-cli-install-skills command for cross-platform skills installation
- New bin/install-skills.js: resolves local skills path automatically
- Users just run `gitlink-cli-install-skills` on any platform
- No more bash-specific $(npm root -g) syntax that breaks on Windows
- Update README installation docs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-07 16:27:22 +08:00
wbtiger df8937316a fix: improve release asset matching with version fallback
- When exact version release not found, fallback to latest release
- Match assets by platform/arch pattern when version in filename differs
- Ensures npm install works even when release version != npm version

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-07 15:39:45 +08:00
wbtiger c3744936d9 fix: prepend domain to relative download URL in install.js
GitLink release API returns relative URLs for attachments (e.g.
/Gitlink/gitlink-cli/releases/download/...). Prepend RELEASE_BASE
to make them absolute, fixing "Invalid URL" error on Windows/Linux.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-07 15:08:01 +08:00
wbtiger d32f3b53c9 fix: npm package should not embed platform-specific binary
- Remove bin/ directory from npm files, only include bin/cli.js wrapper
- postinstall now always downloads the correct platform binary from release
- Add platform compatibility check: if pre-existing binary doesn't match
  current platform, re-download instead of silently failing

Fixes "cannot execute binary file" on Linux/Windows when npm package was
built on macOS.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-07 15:04:11 +08:00
wbtiger a6b9797869 chore: bump npm package to v0.1.3
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-07 13:35:13 +08:00
wbtiger 342badbdd2 feat: add Windows (x64/arm64) support
- Add windows/amd64 and windows/arm64 to build targets with .zip packaging
- Update npm install.js: win32 platform detection, .exe binary, PowerShell zip extraction
- Update npm cli.js wrapper to append .exe on Windows
- Fix credential path to use filepath.Join for cross-platform compatibility
- Update README with Windows support docs and FAQ

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-07 10:52:56 +08:00
Your GitHub Username 3c2e8f0580 feat: include skills in npm package, update README with AI Agent quick start
- Bundle skills/ directory into npm package for local installation
- Add npx skills add instructions for both human users and AI agents
- Update README installation section to match larksuite/cli style
- Bump npm version to 0.1.1

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-02 23:06:06 +08:00
Your GitHub Username 381a32a49f feat: add npm distribution support (@gitlink-ai/cli)
- Add npm package structure (package.json, install script, bin wrapper)
- Add cross-platform build script (darwin/linux × amd64/arm64)
- Add local pack script for embedding binary in npm package
- Update README with larksuite/cli-style installation docs
- Published as @gitlink-ai/cli@0.1.0 on npmjs.com

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-02 22:57:37 +08:00