mirror of
https://github.com/MoonshotAI/kimi-code.git
synced 2026-07-09 17:29:12 +00:00
* feat: add /connect command with models.dev catalog support Add a /connect slash command that configures a provider and model from a models.dev-style catalog. Users no longer need to hand-write model metadata (context window, output limit, capabilities). Architecture (3 layers): - kosong: pure data layer — Catalog schema, inferWireType, catalogModelToCapability - node-sdk: IO + config write — fetchCatalog, applyCatalogProvider, catalogModelToAlias - app: TUI flow — /connect command, provider/model selection, credential input, config persistence UI improvements in this PR: - ChoicePickerComponent: add searchable (fuzzy filter + search bar) - ModelSelectorComponent: add searchable (same) - Extract reusable paging.ts for list pagination Changesets included for kosong, kimi-code-sdk, and kimi-code. * feat: bundle pruned models.dev catalog for offline /connect When the network is unavailable, /connect now falls back to a built-in snapshot of the models.dev catalog. - `scripts/update-catalog.mjs`: fetches models.dev/api.json, strips unnecessary fields, and writes `src/built-in-catalog.ts` with the JSON string as a TS constant. - `loadBuiltInCatalog(text?)` in node-sdk: parses the JSON string safely; returns undefined on any failure. - `handleConnectCommand`: on fetch failure, shows an informative offline message and tries the built-in snapshot. - The snapshot file is a placeholder (`undefined`) in source control; `update-catalog.mjs` populates it before release builds so the actual catalog is inlined into the bundle by rolldown. * refactor(tui): share search and pagination across list pickers ChoicePicker and ModelSelector each carried their own copy of the cursor + fuzzy-search + pagination state machine. Extract it into a reusable SearchableList so both pickers share one implementation; behavior is unchanged. * fix(tui): filter unsupported catalog providers * docs(tui): clarify /connect stale-alias cleanup depends on removeProvider * fix(kimi-code): inject built-in catalog at release time * feat(tui): hint at /login and /connect when /model has no models Replace the bare "No models configured." error with a notice that points users to /login for Kimi and /connect for other providers. * fix(tui): tighten /connect error reporting for edge cases Two silent-failure cases in /connect could leave users without any feedback to act on: - Reject `--url` when its value is missing (e.g. `/connect --url` or `/connect --url=`). Previously the argument parser silently fell back to the default catalog, so a malformed flag still appeared to succeed but with the wrong source. - Show an explicit error when the resolved catalog yields no providers with supported wire types. Previously the picker resolved with no selection and the command returned without any UI feedback. * chore(tui): restore slash invalid intent type * fix(tui): support /logout for /connect-configured providers After /connect writes a non-managed provider (e.g. openai), /logout fell through to "Nothing to logout." because the handler only matched the managed default and isOpenPlatformId branches, leaving users no in-app way to drop the API key and model aliases they just configured. Collapse the OpenPlatform branch into a generic "provider is present in config" check so any non-managed provider in config — OpenPlatform OAuth targets and /connect catalog providers — goes through the same removeProvider path. * fix(tui): reject --url values that are not http(s) URLs `resolveConnectCatalogRequest` previously matched any non-space token after `--url` as the URL, so `/connect --url --refresh` parsed `--refresh` as the value and bypassed the missing-value error path. Bare non-URL tokens (`/connect --url not-a-url`) and non-http(s) schemes were also silently accepted. Constrain the captured value to `https?://...` so flag-like and non-URL tokens fall through to the existing `URL_FLAG_PRESENT_RE` check and surface a clear error. * ci(native): scope built-in catalog generation to signed macOS jobs The catalog-generation step ran whenever `inputs.sign-macos` was true, including Linux and Windows targets that take the local-profile build path and never consume the generated catalog. A transient models.dev outage would therefore fail unrelated artifact builds. Match the condition to the macOS signed release-profile build that actually consumes the bundled catalog. * fix(ci): embed built-in catalog in non-macOS native artifacts The earlier narrowing to `runner.os == 'macOS' && inputs.sign-macos` relied on a misread of build.mjs: its `profile === 'release'` guard only auto-fetches the catalog as a dev fallback. Whether the binary actually embeds the catalog is decided by tsdown's define at bundle time, which reads KIMI_CODE_BUILT_IN_CATALOG_FILE regardless of profile. Linux and Windows release artifacts therefore lost their bundled catalog and silently regressed offline /connect on those targets. Restore generation for all OS jobs when sign-macos is true. * chore(tui): mention /connect in welcome panel hints Align the welcome panel with the /model picker so the empty-state copy points users to both /login and /connect.
123 lines
4 KiB
YAML
123 lines
4 KiB
YAML
name: _native-build
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
upload-artifact-prefix:
|
|
description: 'Prefix for uploaded artifact name'
|
|
required: false
|
|
type: string
|
|
default: 'kimi-code-native'
|
|
retention-days:
|
|
description: 'Artifact retention in days'
|
|
required: false
|
|
type: number
|
|
default: 3
|
|
sign-macos:
|
|
description: 'Whether to sign + notarize macOS builds (requires Apple secrets)'
|
|
required: false
|
|
type: boolean
|
|
default: false
|
|
secrets:
|
|
APPLE_CERTIFICATE_P12:
|
|
required: false
|
|
APPLE_CERTIFICATE_PASSWORD:
|
|
required: false
|
|
APPLE_NOTARIZATION_KEY_P8:
|
|
required: false
|
|
APPLE_NOTARIZATION_KEY_ID:
|
|
required: false
|
|
APPLE_NOTARIZATION_ISSUER_ID:
|
|
required: false
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
native-bundle:
|
|
name: Native bundle (${{ matrix.target }})
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- os: ubuntu-24.04
|
|
target: linux-x64
|
|
- os: ubuntu-24.04-arm
|
|
target: linux-arm64
|
|
- os: macos-15-intel
|
|
target: darwin-x64
|
|
- os: macos-15
|
|
target: darwin-arm64
|
|
- os: windows-2025-vs2026
|
|
target: win32-x64
|
|
- os: windows-11-arm
|
|
target: win32-arm64
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v6
|
|
|
|
- name: Setup pnpm
|
|
uses: pnpm/action-setup@v6
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v6
|
|
with:
|
|
node-version-file: .nvmrc
|
|
cache: 'pnpm'
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: Setup macOS keychain (release only)
|
|
if: runner.os == 'macOS' && inputs.sign-macos
|
|
uses: ./.github/actions/macos-keychain-setup
|
|
with:
|
|
certificate-p12: ${{ secrets.APPLE_CERTIFICATE_P12 }}
|
|
certificate-password: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
|
|
|
|
- name: Generate built-in catalog (release artifacts)
|
|
if: inputs.sign-macos
|
|
shell: bash
|
|
run: |
|
|
CATALOG_FILE="$RUNNER_TEMP/kimi-code-built-in-catalog.json"
|
|
node apps/kimi-code/scripts/update-catalog.mjs --out "$CATALOG_FILE"
|
|
echo "KIMI_CODE_BUILT_IN_CATALOG_FILE=$CATALOG_FILE" >> "$GITHUB_ENV"
|
|
|
|
- name: Build native executable (release profile, macOS signed)
|
|
if: runner.os == 'macOS' && inputs.sign-macos
|
|
run: pnpm --filter @moonshot-ai/kimi-code run build:native:release
|
|
|
|
- name: Build native executable (local profile)
|
|
if: '!(runner.os == ''macOS'' && inputs.sign-macos)'
|
|
run: pnpm --filter @moonshot-ai/kimi-code run build:native:sea
|
|
|
|
- name: Notarize macOS binary
|
|
if: runner.os == 'macOS' && inputs.sign-macos
|
|
uses: ./.github/actions/macos-notarize
|
|
with:
|
|
binary-path: ${{ github.workspace }}/apps/kimi-code/dist-native/bin/${{ matrix.target }}/kimi
|
|
notarization-key-p8: ${{ secrets.APPLE_NOTARIZATION_KEY_P8 }}
|
|
notarization-key-id: ${{ secrets.APPLE_NOTARIZATION_KEY_ID }}
|
|
notarization-issuer-id: ${{ secrets.APPLE_NOTARIZATION_ISSUER_ID }}
|
|
|
|
- name: Cleanup macOS keychain
|
|
if: always() && runner.os == 'macOS' && inputs.sign-macos
|
|
uses: ./.github/actions/macos-keychain-cleanup
|
|
|
|
- name: Smoke test native executable
|
|
run: pnpm --filter @moonshot-ai/kimi-code run test:native:smoke
|
|
|
|
- name: Package native artifact
|
|
run: pnpm --filter @moonshot-ai/kimi-code run package:native
|
|
|
|
- name: Upload native artifact
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
name: ${{ inputs.upload-artifact-prefix }}-${{ matrix.target }}
|
|
retention-days: ${{ inputs.retention-days }}
|
|
path: |
|
|
apps/kimi-code/dist-native/artifacts/kimi-code-${{ matrix.target }}.zip
|
|
apps/kimi-code/dist-native/artifacts/kimi-code-${{ matrix.target }}.zip.sha256
|
|
if-no-files-found: ignore
|