@cfxdevkit/llm-tools
CLI dispatcher for local LLM automation workflows.
Install
pnpm
pnpm add @cfxdevkit/llm-toolsLocal LLM automation tools for the Conflux DevKit monorepo.
This package is the CLI dispatcher for the current LLM worker layer. Provider/runtime resolution and repo workflow loading now both delegate through @cfxdevkit/cdk-ai. It lives in repos/cfx-tools/infra/llm-tools because local LLM and AI-assisted maintenance are isolated from the general developer tooling surface.
At the workspace root, pnpm run cdk -- agent ... is now the primary entrypoint. Root pnpm run llm:* scripts remain as compatibility shims during the migration, and pnpm run llm:wiki is deprecated in favor of pnpm run docs:wiki.
Interactive, print, and RPC agent modes now delegate through @cfxdevkit/cdk-ai into the PI runtime instead of launching
ad hoc worker scripts directly. The compatibility layer keeps llm-tools entrypoints available while
the canonical control plane stays on cdk agent.
Commands
| Command | Purpose |
|---|---|
llm:commit | Hardened local LLM commit pipeline with code-hotspot checks, prechecks, Changeset guidance, approval, explicit staging, and commit execution |
llm:docs-upkeep | Delegate documentation maintenance recommendations to the local LLM after deterministic docs checks have produced context |
llm:test-audit | Ask the local LLM whether changed code has meaningful test and precheck coverage |
llm:health | Ask the local LLM to summarize repo health, drift, and automation gaps |
llm:validation | Ask the local LLM to choose the minimum useful validation commands for the current change |
llm:changeset, llm:release, llm:ci-cd, llm:docs-pipeline | Repo-aware provider-backed actions for Changesets, npm publishing, GitHub Actions, docs image publishing, and VPS deploy readiness |
llm:all, llm:review | Compatibility aliases for aggregate and review upkeep flows; the preferred surface is `cdk agent exploratory all |
PI-backed compatibility entrypoints:
| Command | Preferred surface |
|---|---|
pnpm --filter @cfxdevkit/llm-tools llm -- ask -- <prompt> | pnpm run cdk -- agent print -- <prompt> |
pnpm --filter @cfxdevkit/llm-tools llm -- interactive | pnpm run cdk -- agent interactive |
pnpm --filter @cfxdevkit/llm-tools llm -- print -- <prompt> | pnpm run cdk -- agent print -- <prompt> |
pnpm --filter @cfxdevkit/llm-tools llm -- rpc | pnpm run cdk -- agent rpc |
Root pnpm run llm:* scripts remain available as short compatibility commands, but new automation should target cdk agent directly.
Commit flows now have an explicit split:
pnpm run cdk -- repo commitremains the deterministic commit pipeline for stable scripted runs.pnpm run cdk -- agent commitstarts the PI-backed interactive commit session, keeps remediation in-session, and pauses at the final approval boundary.
llm:commit runs check:hotspots as a non-bypassable quality gate. The scanner applies the framework design-principles file budget across source files in the whole repository, writes artifacts/llm/reports/code-hotspots.md, and blocks commits while any source file exceeds the hard 300-line limit.
llm:commit no longer edits package changelogs directly. Changesets own version bumps and release changelogs. When publishable package changes are detected and no .changeset/*.md file is present, the commit pipeline can generate a draft Changeset and stage it with the commit. Use --changeset-bump patch|minor|major to force the bump level, or --skip-changeset / --no-changeset when the package change is intentionally unreleased.
Release and CI/CD
pnpm run check:ci performs deterministic checks for the docs image workflow, VPS deploy workflow, Changesets release workflow, npm publish helper, docs Dockerfile, wiki sync script, and Ansible deployment files. It writes artifacts/llm/reports/ci-cd.md.
The delegated LLM actions use that deterministic report plus workflow and infrastructure context:
pnpm run llm:changeset
pnpm run llm:release
pnpm run llm:ci-cd
pnpm run llm:docs-pipelineUse these after touching .changeset/, package manifests, .github/workflows/, repos/cfx-tools/packages/docs-site/, or infrastructure/ansible/.
Docs Upkeep
pnpm run llm:docs-upkeep runs a four-phase documentation maintenance loop:
- Refresh deterministic docs alignment artifacts with
check:docs. - Discover markdown folder scopes across the repo.
- Process each folder serially with bounded context from that folder plus repository docs signals.
- Write per-folder artifacts under
artifacts/llm/reports/docs-upkeep/and an index atartifacts/llm/reports/docs-upkeep.md.
Useful flags:
pnpm run llm:docs-upkeep -- --quick
pnpm run llm:docs-upkeep -- --docs-only --quick
pnpm run llm:docs-upkeep -- --scope docs/architecture --max-folders 1
pnpm run llm:docs-upkeep -- --quick --write --yes --max-folders 3By default the command produces reviewable artifacts only. Add --write to let the local model return exact search/replace edits for existing markdown files in the current folder scope. Write mode never creates new files, skips updates outside the folder scope, and only applies replacements whose old text matches exactly once.
Backend
Delegated commands resolve providers through the PI runtime bridge exposed by @cfxdevkit/cdk-ai: repo-local .pi/providers.json, scoped unit overlays, direct Lemonade configuration, optional LiteLLM gateway settings, OpenAI-compatible env vars, and GitHub Models via GITHUB_TOKEN.
For PI-backed runtime modes, llm-tools delegates into the same provider bridge used by cdk agent,
so scoped config, model selection, and repository-local .pi resources stay aligned across both entrypoints.
The shared PI config now supports named provider profiles plus action and phase policies.
That lets cdk agent commit pick a backend intentionally for the commit session while still splitting model
selection between commit-message generation and failure analysis.
Sub-paths
| Sub-path | Exports |
|---|---|
. | 7 symbols |
.
export type LlmWorker = 'llm' | 'deterministic';
export type LlmCommandName = (typeof llmCommands)[number]['name'];
export interface LlmCommandDefinition {
name: LlmCommandName;
description: string;
worker: LlmWorker;
}
export declare const llmCommands: readonly [
{ name: 'llm:commit'; description: 'Run hardened commit pipeline with hotspot checks'; worker: 'deterministic' },
{ name: 'llm:docs-upkeep'; description: 'Delegate documentation upkeep to LLM'; worker: 'llm' },
{ name: 'llm:test-audit'; description: 'Audit test coverage of changed code'; worker: 'llm' },
{ name: 'llm:health'; description: 'Summarize repo health and automation gaps'; worker: 'llm' },
{ name: 'llm:validation'; description: 'Select minimal validation commands'; worker: 'llm' },
{ name: 'llm:changeset'; description: 'Generate or update Changesets'; worker: 'llm' },
{ name: 'llm:release'; description: 'Prepare and execute release'; worker: 'llm' },
{ name: 'llm:ci-cd'; description: 'Validate and update CI/CD workflows'; worker: 'llm' },
{ name: 'llm:docs-pipeline'; description: 'Build and deploy docs artifacts'; worker: 'llm' },
{ name: 'llm:all'; description: 'Run all repo upkeep agents'; worker: 'llm' },
{ name: 'llm:review'; description: 'Run LLM review agent'; worker: 'llm' }
];
export declare function findLlmCommand(name: string): LlmCommandDefinition | undefined;
export declare function runCli(): Promise<void>;
export declare const llmToolingNamespace: {
name: string;
description: string;
usage: string;
};Usage
import { findLlmCommand, llmCommands, runCli } from '@cfxdevkit/llm-tools';
// Find a command definition by name
const commitCmd = findLlmCommand('llm:commit');
// => { name: 'llm:commit', description: 'Run hardened commit pipeline with hotspot checks', worker: 'deterministic' }
// List all available commands
console.log(llmCommands);
// Run the CLI (typically invoked via `pnpm run llm:*`)
runCli();API Reference
See API.md for the full public surface.
Tier
Tier 1 — platform — May import Tier 0 framework packages.
API Reference
.
Usage
import { findLlmCommand, llmCommands, LlmCommandDefinition, LlmCommandName, LlmWorker, llmToolingNamespace, runCli } from '@cfxdevkit/llm-tools';
// Example usage of the `findLlmCommand` function
const command = findLlmCommand('chat');
console.log(command); // Output: 'chat'
// Example usage of the `llmCommands` array
const commands = llmCommands;
console.log(commands); // Output: ['chat', 'generate', 'analyze']
// Example usage of the `LlmCommandDefinition` interface
const definition = new LlmCommandDefinition('chat', 'Chat with a model', 'chat');
console.log(definition); // Output: LlmCommandDefinition { name: 'chat', description: 'Chat with a model', usage: 'chat' }
// Example usage of the `LlmCommandName` enum
const name = LlmCommandName.chat;
console.log(name); // Output: chat
// Example usage of the `LlmWorker` class
const worker = new LlmWorker();
console.log(worker); // Output: LlmWorker { name: 'chat', description: 'Chat with a model', usage: 'chat' }
// Example usage of the `llmToolingNamespace` namespace
const namespace = llmToolingNamespace;
console.log(namespace); // Output: llmToolingNamespace { name: 'chat', description: 'Chat with a model', usage: 'chat' }
// Example usage of the `runCli` function
runCli();// Locates a specific LLM command by its identifier.
// Returns the command name if found, otherwise `undefined`.
export { findLlmCommand }
// A collection of all available LLM command names.
// Contains the identifiers for supported LLM operations.
export { llmCommands }
// Defines the structure and metadata for an LLM command.
// Used to register or describe LLM commands with name, description, and usage.
export { LlmCommandDefinition }
// Enumeration of valid LLM command identifiers.
// Provides type-safe access to supported command names.
export { LlmCommandName }
// Orchestrates the execution of LLM-based tasks.
// Wraps command metadata and provides execution logic for LLM workflows.
export { LlmWorker }
// Provides a grouped namespace for LLM tooling utilities.
// Exposes shared utilities and configuration for LLM automation.
export { llmToolingNamespace }
// Starts the command-line interface for LLM automation.
// Parses CLI arguments and dispatches to the appropriate LLM command handler.
export { runCli }