M0: compilable skeleton — Kigi 0.1.0 fork surgery

Hard fork of xai-org/grok-build (Apache-2.0) re-targeted as Kigi, an
unofficial Kimi Code CLI community build.

Rename & identity
- 72 xai-*/xai-grok-* crates -> kigi-* (explicit: xai-grok-pager-bin ->
  kigi-bin [binary `kigi`], xai-grok-pager -> kigi-tui; rest mechanical);
  ptyctl, ptyctl-cli, third_party/ unchanged; proto package
  xai.grok.tools.v1 -> kigi.tools.v1
- Config home ~/.kigi (KIGI_SHARE_DIR override), env prefix GROK_* ->
  KIGI_*, `kigi --version` carries the unofficial-community-build notice
- clap identity, help text, startup banner, prompt templates rebranded
  (templates re-encrypted)

Deletions (PRD removal list #5/#6/#7/#9/#10)
- voice input (xai-grok-voice) and all TUI wiring
- telemetry: Mixpanel client, external OTel stream, Sentry, OTLP layers,
  trace/GCS/S3 upload queues (kigi-file-utils halved), workspace upload
  module & dc_log, heap-profile uploader, auth-diagnostics uploader,
  session-analytics halves of feedback; local zero-egress observability
  preserved in new kigi-log crate (unified log, --debug firehose,
  subsystem file logs, opt-in instrumentation)
- announcements (crate, remote-settings fields, TUI surfaces)
- plugin marketplace (crate, sources/browse/CTA/extensions-modal tab);
  direct plugin install/uninstall/update via kigi-agent git_install kept
- relay/gateway/assets endpoints and features (agent relay, headless
  relay transport, gateway bridge, LeaderEnvUrls); leader IPC socket now
  ~/.kigi/leader.sock + KIGI_LEADER_SOCKET, no ws-url derivation
- functional types rehomed instead of deleted: PermissionMode ->
  kigi-config-types, McpInitStrategy -> kigi-mcp, PrCreationSource ->
  session signals, TerminalDiagnostics -> kigi-pager-render, agent_id ->
  shell util

Endpoints
- kigi-env rewritten: single production KigiEndpoints {coding_api_base_url
  https://api.kimi.com/coding/v1 (KIGI_CODE_BASE_URL), oauth_host
  https://auth.kimi.com (KIGI_OAUTH_HOST), update_base_url (GitHub
  Releases API), upgrade_page_url}; GrokBuildEnvironment enum deleted

Toolchain & workspace hygiene
- Rust 1.97.0 pinned; edition 2024; full cargo update; git2 hoisted to
  workspace at 0.21 (Option->Result API migration), quick-xml 0.41
- Root Cargo.toml hand-maintained (PRD §8.1): version 0.1.0 inherited by
  all members, members sorted, unused deps pruned
- cargo-deny advisories gate (deny.toml with documented transitive
  exceptions); CI workflow (check/clippy/fmt/deny/test, macOS+Linux)
- cross-crate test seams re-gated behind `test-support` cargo feature;
  insta snapshot baselines renamed to the kigi_tui prefix
- clippy --workspace --all-targets: zero warnings; fmt clean

Fixes surfaced by the port
- updater probe/installer divergence (bin/kigi vs bin/grok symlink set)
- idle model-metadata refresh dead under KIGI_CODE_BASE_URL override
  (new is_effective_coding_endpoint_url, loopback+override aware)
- macOS symlinked-TMPDIR fixture canonicalization (foreign_sessions,
  fast-worktree); RSS measurement tests serialized via serial_test

Docs & legal (Apache §4)
- NOTICE added (upstream attribution + change statement); THIRD-PARTY
  notices sustained; kigi-tools ported-code notices extended; README,
  CONTRIBUTING, SECURITY, AGENTS.md rewritten

Out of scope for M0 (tracked): Kimi auth/inference (M1), search/fetch,
command parity, config import (M2), Computer Hub excision & final
brand-token sweep (M2), distribution & self-update rewrite (M3).
This commit is contained in:
2026-07-17 05:31:01 -04:00
commit d6c20fc13f
2612 changed files with 1353757 additions and 0 deletions
@@ -0,0 +1,241 @@
use crate::languages::types::TSLanguageConfig;
pub fn ts_lang() -> TSLanguageConfig {
TSLanguageConfig::new(
vec![
"Typescript".to_owned(),
"TSX".to_owned(),
"typescript".to_owned(),
"tsx".to_owned(),
],
vec!["ts".to_owned(), "tsx".to_owned()],
vec![vec![
"function".to_owned(),
"class".to_owned(),
"interface".to_owned(),
"type".to_owned(),
"enum".to_owned(),
"variable".to_owned(),
"const".to_owned(),
"let".to_owned(),
]],
// Comprehensive TypeScript query with full type coverage
r#"
;; === DEFINITIONS ===
(function_signature
name: (identifier) @name.definition.function) @definition.function
(method_signature
name: (property_identifier) @name.definition.method) @definition.method
(abstract_method_signature
name: (property_identifier) @name.definition.method) @definition.method
(abstract_class_declaration
name: (type_identifier) @name.definition.class) @definition.class
(module
name: (identifier) @name.definition.module) @definition.module
(interface_declaration
name: (type_identifier) @name.definition.interface) @definition.interface
(function_declaration
name: (identifier) @name.definition.function) @definition.function
(method_definition
name: (property_identifier) @name.definition.method) @definition.method
(class_declaration
name: (type_identifier) @name.definition.class) @definition.class
(type_alias_declaration
name: (type_identifier) @name.definition.type) @definition.type
(enum_declaration
name: (identifier) @name.definition.enum) @definition.enum
;; Arrow function assigned to variable: const foo = () => {}
(lexical_declaration
(variable_declarator
name: (identifier) @name.definition.function
value: (arrow_function))) @definition.function
;; React component patterns: const Foo = React.forwardRef(...), React.memo(...)
(lexical_declaration
(variable_declarator
name: (identifier) @name.definition.function
value: (call_expression))) @definition.function
;; Variable declarations (const/let)
(lexical_declaration
(variable_declarator
name: (identifier) @name.definition.variable)) @definition.variable
;; Var declarations
(variable_declaration
(variable_declarator
name: (identifier) @name.definition.variable)) @definition.variable
;; Exported variable declarations: export const foo = ...
(export_statement
(lexical_declaration
(variable_declarator
name: (identifier) @name.definition.variable))) @definition.variable
;; === DESTRUCTURING DEFINITIONS ===
;; For-of/for-in loop with array destructuring: for (const [a, b] of items)
(for_in_statement
left: (array_pattern
(identifier) @name.definition.variable))
;; For-of/for-in loop with object destructuring: for (const { a, b } of items)
(for_in_statement
left: (object_pattern
(shorthand_property_identifier_pattern) @name.definition.variable))
;; For-of/for-in loop with object destructuring (aliased): for (const { a: b } of items)
(for_in_statement
left: (object_pattern
(pair_pattern
value: (identifier) @name.definition.variable)))
;; Regular array destructuring: const [a, b] = someArray
(lexical_declaration
(variable_declarator
name: (array_pattern
(identifier) @name.definition.variable)))
;; Regular object destructuring (shorthand): const { a, b } = someObject
(lexical_declaration
(variable_declarator
name: (object_pattern
(shorthand_property_identifier_pattern) @name.definition.variable)))
;; Regular object destructuring (aliased): const { a: b } = someObject
(lexical_declaration
(variable_declarator
name: (object_pattern
(pair_pattern
value: (identifier) @name.definition.variable))))
;; Var array destructuring: var [a, b] = someArray
(variable_declaration
(variable_declarator
name: (array_pattern
(identifier) @name.definition.variable)))
;; Var object destructuring (shorthand): var { a, b } = someObject
(variable_declaration
(variable_declarator
name: (object_pattern
(shorthand_property_identifier_pattern) @name.definition.variable)))
;; Var object destructuring (aliased): var { a: b } = someObject
(variable_declaration
(variable_declarator
name: (object_pattern
(pair_pattern
value: (identifier) @name.definition.variable))))
;; Function parameters with array destructuring: function foo([a, b]) {}
(formal_parameters
(required_parameter
pattern: (array_pattern
(identifier) @name.definition.variable)))
;; Function parameters with object destructuring (shorthand): function foo({ a, b }) {}
(formal_parameters
(required_parameter
pattern: (object_pattern
(shorthand_property_identifier_pattern) @name.definition.variable)))
;; Function parameters with object destructuring (aliased): function foo({ a: b }) {}
(formal_parameters
(required_parameter
pattern: (object_pattern
(pair_pattern
value: (identifier) @name.definition.variable))))
;; Function parameters (simple): function foo(a, b) {}
(formal_parameters
(required_parameter
pattern: (identifier) @name.definition.variable))
;; === REFERENCES ===
;; Member expression object: foo.bar (capture foo as reference)
(member_expression
object: (identifier) @name.reference.variable)
;; Capture ALL type identifiers as references (comprehensive)
(type_identifier) @name.reference.type
;; new expressions: new SomeClass()
(new_expression
constructor: (identifier) @name.reference.class) @reference.class
;; Named imports (simple): import { DiffViewer } from './code-viewer'
(import_specifier
name: (identifier) @name.reference.variable
!alias) @reference.import
;; Named imports with alias: import { Foo as Bar } from './module'
(import_specifier
name: (identifier) @alias.original
alias: (identifier) @alias.name) @reference.import.alias
;; Default imports: import Foo from 'bar'
(import_clause
(identifier) @name.reference.import)
;; JSX opening element: <DiffViewer ...>
(jsx_opening_element
name: (identifier) @name.reference.class)
;; JSX self-closing element: <DiffViewer ... />
(jsx_self_closing_element
name: (identifier) @name.reference.class)
;; JSX member expression element: <Foo.Bar />
(jsx_opening_element
name: (member_expression
object: (identifier) @name.reference.variable))
(jsx_self_closing_element
name: (member_expression
object: (identifier) @name.reference.variable))
;; Function calls: someFunction()
(call_expression
function: (identifier) @name.reference.call)
;; Method calls on objects: object.method()
(call_expression
function: (member_expression
object: (identifier) @name.reference.variable))
;; Extends clause in class: class Foo extends Bar
(class_heritage
(extends_clause
value: (identifier) @name.reference.class))
;; Implements clause: class Foo implements Bar
(class_heritage
(implements_clause
(type_identifier) @name.reference.interface))
;; Named exports: export { Foo }
(export_specifier
name: (identifier) @name.reference.export)
;; Array element identifiers: [foo, bar] (e.g., React useCallback/useEffect dependency arrays)
(array
(identifier) @name.reference.variable)
"#
.to_owned(),
|| tree_sitter_typescript::LANGUAGE_TSX.into(),
)
}