UNPKG

@lark-project/cli

Version:

飞书项目插件开发工具

74 lines (73 loc) 3.55 kB
export interface UpdateLocalConfigOptions { fromPath: string; /** Bypass the "draft drops remote points" deletion gate (user-confirmed deletion). */ allowDelete?: boolean; } export declare const updateLocalConfig: ({ fromPath, allowDelete }: UpdateLocalConfigOptions) => Promise<void>; type PointDiffStatus = 'added' | 'modified' | 'deleted'; /** * 点位 diff 状态配色:删除红、修改黄、新增默认(不上色)。 * chalk@4 在非 TTY(被 skill 子进程捕获 / jest)下 level=0、原样返回不加 ANSI, * 故确认块被 AI 转呈时仍是干净文本、测试断言也不受影响——颜色只在终端交互时出现。 */ export declare function colorizeByStatus(status: PointDiffStatus, text: string): string; /** 单个字段的 local→remote 明细(仅 modified 项填充,纯展示用,闸口不读)。 */ export interface PointFieldChange { field: string; /** 经 fieldCanon 折叠后的预览串(空≡缺失统一显示 `(空/缺失)`),过长截断。 */ local: string; remote: string; } export interface PointDiffEntry { type: string; key: string; name?: string; status: PointDiffStatus; /** * 仅 `modified` 项填充:列出"两端 canonical 不等"的字段及其 local/remote 预览值。 * 与 modified 判定**同源一致**(见 computeFieldChanges):判为 modified 必有 ≥1 条; * 方案 A 视为相等的空兜底字段绝不出现在此。纯展示用——删除闸口只 filter `status`,不读本字段。 */ changes?: PointFieldChange[]; } /** * Diff an arbitrary full config object against the current remote. * `set` passes the draft (to gate "didn't build on remote → would drop points"), * `update` / `diff` pass the on-disk `point.config.local.json`. */ export declare function computeConfigVsRemoteDiff(local: Record<string, any>): Promise<PointDiffEntry[]>; /** * Compare local `point.config.local.json` with remote plugin config. * Groups by point type + key; classifies each key as added / modified / deleted. * Used by both `local-config diff` (AI-facing preview) and `update --source-type=local` * (pre-push deletion gate). */ export declare function computeLocalVsRemoteDiff(): Promise<PointDiffEntry[]>; /** * Shared deletion gate for `set` and `update --source-type=local`. * A config that drops points still present on remote would delete them on push — * almost always the symptom of a config NOT built on the current remote baseline * ("treated as new" instead of "get --remote → edit on top"). Writes a verbatim * deletion list + recovery guidance to stderr. Callers exit(2) after this unless * the user explicitly opted in with --allow-delete. */ export declare function writeDeletionBlockNotice(deletions: PointDiffEntry[]): void; /** * `lpm local-config diff` entry. * - stdout: human-readable diff lines * - stderr (only on deletion): DELETION_REQUIRES_CONFIRMATION notice * - exit: 0 if no deletions, 2 if any deletion present, 1 on error */ export declare const diffLocalConfig: () => Promise<void>; interface GetLocalConfigOptions { remote?: boolean; compareSnapshot?: boolean; caseId?: string; } /** * Always writes remote config snapshot to `.lpm-cache/config/remote.json` and * prints that path on stdout. AI/scripts consume the file, not the JSON blob, * so conversation context stays clean. */ export declare const getLocalConfig: ({ remote, compareSnapshot, caseId, }?: GetLocalConfigOptions) => Promise<unknown>; export {};