autosnippet
Version:
Extract code patterns into a knowledge base for AI coding assistants
167 lines (166 loc) • 4.76 kB
TypeScript
/**
* FileManifest — 所有可部署文件的单一真实来源
*
* Setup 和 Upgrade 共享同一份清单,由 FileDeployer 按策略执行。
*
* 字段说明:
* id — 唯一标识(用于日志和结果报告)
* src — 模板相对路径(相对于 templates/),null 表示需要 generate 函数
* dest — 目标相对路径(相对于 projectRoot)
* strategy — 部署策略(见 FileDeployer.STRATEGIES)
* on — 适用场景:'both' | 'setup' | 'upgrade'
* chmod — 是否需要 chmod +x(.sh 文件)
* generate — 自定义生成函数名(strategy 为 'generate' 时使用)
* category — 分组标签(用于 stepIDE 结果汇报)
*/
/**
* 部署策略:
* 'overwrite' — AutoSnippet 完全拥有,始终覆盖
* 'overwrite-dir' — 递归覆盖整个目录(只覆盖 AutoSnippet 的文件)
* 'signature-safe' — 检查 AutoSnippet 签名再覆盖(保护用户自建文件)
* 'create-only' — 仅在文件不存在时创建(不更新)
* 'merge-json' — JSON 深度合并(只写入 autosnippet 键)
* 'merge-gitignore' — 增量追加缺失的 gitignore 规则
* 'backup-overwrite' — 备份旧文件后覆盖
* 'generate' — 自定义生成逻辑(由 generate 函数处理)
* 'inject-marker' — 在 <!-- autosnippet:begin/end --> 标记间注入/替换
*/
export declare const MANIFEST: ({
id: string;
dest: string;
strategy: string;
on: string;
category: string;
jsonKey: string;
generate?: undefined;
src?: undefined;
chmod?: undefined;
resolveDest?: undefined;
requireDir?: undefined;
} | {
id: string;
strategy: string;
generate: string;
dest: string;
on: string;
category: string;
jsonKey?: undefined;
src?: undefined;
chmod?: undefined;
resolveDest?: undefined;
requireDir?: undefined;
} | {
id: string;
src: string;
dest: string;
strategy: string;
on: string;
category: string;
jsonKey?: undefined;
generate?: undefined;
chmod?: undefined;
resolveDest?: undefined;
requireDir?: undefined;
} | {
id: string;
src: string;
dest: string;
strategy: string;
on: string;
category: string;
chmod: boolean;
jsonKey?: undefined;
generate?: undefined;
resolveDest?: undefined;
requireDir?: undefined;
} | {
id: string;
src: string;
dest: null;
strategy: string;
on: string;
category: string;
chmod: boolean;
resolveDest: string;
jsonKey?: undefined;
generate?: undefined;
requireDir?: undefined;
} | {
id: string;
src: string;
dest: string;
strategy: string;
on: string;
category: string;
requireDir: string;
jsonKey?: undefined;
generate?: undefined;
chmod?: undefined;
resolveDest?: undefined;
} | {
id: string;
strategy: string;
dest: string;
on: string;
category: string;
jsonKey?: undefined;
generate?: undefined;
src?: undefined;
chmod?: undefined;
resolveDest?: undefined;
requireDir?: undefined;
} | {
id: string;
strategy: string;
generate: string;
on: string;
category: string;
dest?: undefined;
jsonKey?: undefined;
src?: undefined;
chmod?: undefined;
resolveDest?: undefined;
requireDir?: undefined;
})[];
/**
* .gitignore 规则清单 — Setup 和 Upgrade 共用
* 每条规则:{ pattern, comment, negation? }
*/
/**
* Section markers for the AutoSnippet block inside .gitignore.
* merge-gitignore uses these to insert/replace the entire block atomically.
*/
export declare const GITIGNORE_SECTION_BEGIN = "# >>> AutoSnippet (managed block \u2014 do not edit) >>>";
export declare const GITIGNORE_SECTION_END = "# <<< AutoSnippet <<<";
/**
* AutoSnippet-specific .gitignore rules.
* Only patterns that are AutoSnippet runtime/build artifacts belong here.
* Generic OS/editor patterns (.DS_Store, *.swp, nohup.out) are NOT our business.
*/
export declare const GITIGNORE_RULES: ({
pattern: string;
comment: string;
negation?: undefined;
} | {
pattern: string;
negation: boolean;
comment?: undefined;
})[];
/** .gitignore 迁移规则 — 升级时清理旧格式 */
export declare const GITIGNORE_MIGRATIONS: {
find: RegExp;
replace: string;
}[];
/** MCP Server 配置生成器 */
export declare function buildMcpServerEntry(projectRoot: string, ide: 'cursor' | 'vscode'): {
command: string;
env: {
ASD_PROJECT_DIR: string;
};
} | {
command: string;
env: {
ASD_PROJECT_DIR: string;
};
type: string;
};