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.
119 lines
3.7 KiB
YAML
119 lines
3.7 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
concurrency: ${{ github.workflow }}-${{ github.ref }}
|
|
|
|
jobs:
|
|
release:
|
|
name: Release
|
|
runs-on: ubuntu-latest
|
|
if: github.repository_owner == 'MoonshotAI'
|
|
outputs:
|
|
kimi_native_release: ${{ steps.kimi-release.outputs.should_publish }}
|
|
kimi_release_tag: ${{ steps.kimi-release.outputs.tag }}
|
|
permissions:
|
|
contents: write
|
|
pull-requests: write
|
|
id-token: write # Required for NPM Trusted Publishing (OIDC)
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v6
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Setup pnpm
|
|
uses: pnpm/action-setup@v6
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v6
|
|
with:
|
|
node-version-file: .nvmrc
|
|
cache: 'pnpm'
|
|
registry-url: 'https://registry.npmjs.org'
|
|
|
|
- name: Upgrade npm for Trusted Publishing
|
|
run: npm install -g npm@latest
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: Generate Kimi Code built-in catalog
|
|
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 packages
|
|
run: pnpm build
|
|
|
|
- name: Create Release Pull Request or Publish to npm
|
|
id: changesets
|
|
uses: changesets/action@v1
|
|
with:
|
|
publish: pnpm changeset publish
|
|
version: pnpm changeset version
|
|
commit: 'ci: release packages'
|
|
title: 'ci: release packages'
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
# NPM_TOKEN is not needed with Trusted Publishing (OIDC)
|
|
|
|
- name: Resolve Kimi Code native release
|
|
if: steps.changesets.outputs.published == 'true'
|
|
id: kimi-release
|
|
run: node apps/kimi-code/scripts/native/resolve-release.mjs
|
|
env:
|
|
CHANGESETS_PUBLISHED_PACKAGES: ${{ steps.changesets.outputs.publishedPackages }}
|
|
|
|
native-artifacts:
|
|
name: Native release artifact
|
|
needs: release
|
|
if: needs.release.outputs.kimi_native_release == 'true'
|
|
uses: ./.github/workflows/_native-build.yml
|
|
with:
|
|
upload-artifact-prefix: kimi-code-native
|
|
retention-days: 7
|
|
sign-macos: true
|
|
secrets:
|
|
APPLE_CERTIFICATE_P12: ${{ secrets.APPLE_CERTIFICATE_P12 }}
|
|
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
|
|
APPLE_NOTARIZATION_KEY_P8: ${{ secrets.APPLE_NOTARIZATION_KEY_P8 }}
|
|
APPLE_NOTARIZATION_KEY_ID: ${{ secrets.APPLE_NOTARIZATION_KEY_ID }}
|
|
APPLE_NOTARIZATION_ISSUER_ID: ${{ secrets.APPLE_NOTARIZATION_ISSUER_ID }}
|
|
|
|
publish-native-assets:
|
|
name: Publish native release assets
|
|
needs:
|
|
- release
|
|
- native-artifacts
|
|
if: needs.release.outputs.kimi_native_release == 'true'
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v6
|
|
|
|
- name: Download native artifacts
|
|
uses: actions/download-artifact@v8
|
|
with:
|
|
pattern: kimi-code-native-*
|
|
path: dist-native-release
|
|
merge-multiple: true
|
|
|
|
- name: Produce manifest.json
|
|
env:
|
|
RELEASE_TAG: ${{ needs.release.outputs.kimi_release_tag }}
|
|
run: node apps/kimi-code/scripts/native/produce-manifest.mjs dist-native-release "$RELEASE_TAG"
|
|
|
|
- name: Upload assets to GitHub Release
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
RELEASE_TAG: ${{ needs.release.outputs.kimi_release_tag }}
|
|
run: gh release upload "$RELEASE_TAG" dist-native-release/* --clobber
|