@leiax00/yushe-agent-kit 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/.agents/dsh/plugins/yushe-user-rules/README.md +66 -0
  2. package/.agents/dsh/plugins/yushe-user-rules/cordis.patch.yml +5 -0
  3. package/.agents/dsh/plugins/yushe-user-rules/index.js +561 -0
  4. package/.agents/dsh/plugins/yushe-user-rules/package.json +9 -0
  5. package/.agents/rules/docs-management.md +16 -0
  6. package/.agents/rules/git-workflow.md +74 -0
  7. package/.agents/rules/interaction.md +35 -0
  8. package/.agents/skills/yx-api-design/SKILL.md +15 -0
  9. package/.agents/skills/yx-api-design/references/evolution.md +11 -0
  10. package/.agents/skills/yx-api-design/references/http-contract.md +33 -0
  11. package/.agents/skills/yx-api-design/references/idempotency.md +13 -0
  12. package/.agents/skills/yx-backend-architecture/SKILL.md +77 -0
  13. package/.agents/skills/yx-backend-architecture/references/common/clean-design.md +51 -0
  14. package/.agents/skills/yx-backend-architecture/references/common/common.md +31 -0
  15. package/.agents/skills/yx-backend-architecture/references/go/guide.md +9 -0
  16. package/.agents/skills/yx-backend-architecture/references/java/api-layout.md +103 -0
  17. package/.agents/skills/yx-backend-architecture/references/java/coding-style.md +36 -0
  18. package/.agents/skills/yx-backend-architecture/references/java/data-objects.md +68 -0
  19. package/.agents/skills/yx-backend-architecture/references/java/enums-and-constants.md +42 -0
  20. package/.agents/skills/yx-backend-architecture/references/java/framework-boundaries.md +25 -0
  21. package/.agents/skills/yx-backend-architecture/references/java/input-contracts.md +39 -0
  22. package/.agents/skills/yx-backend-architecture/references/java/integrations.md +54 -0
  23. package/.agents/skills/yx-backend-architecture/references/java/logging-and-audit.md +29 -0
  24. package/.agents/skills/yx-backend-architecture/references/java/mybatis-plus.md +65 -0
  25. package/.agents/skills/yx-backend-architecture/references/java/record-vs-class.md +74 -0
  26. package/.agents/skills/yx-backend-architecture/references/java/repositories-and-modules.md +95 -0
  27. package/.agents/skills/yx-backend-architecture/references/java/spring-boot.md +35 -0
  28. package/.agents/skills/yx-backend-architecture/references/java/structure.md +69 -0
  29. package/.agents/skills/yx-backend-architecture/references/java/verification.md +36 -0
  30. package/.agents/skills/yx-backend-architecture/references/python/guide.md +9 -0
  31. package/.agents/skills/yx-backend-architecture/references/typescript/guide.md +9 -0
  32. package/.agents/skills/yx-database-design/SKILL.md +16 -0
  33. package/.agents/skills/yx-database-design/references/engines.md +17 -0
  34. package/.agents/skills/yx-database-design/references/index-and-transactions.md +11 -0
  35. package/.agents/skills/yx-database-design/references/migrations.md +13 -0
  36. package/.agents/skills/yx-database-design/references/modeling.md +13 -0
  37. package/.agents/skills/yx-docs/SKILL.md +32 -0
  38. package/.agents/skills/yx-docs/references/layout.md +102 -0
  39. package/.agents/skills/yx-docs/references/module-docs.md +60 -0
  40. package/.agents/skills/yx-docs/references/notes.md +39 -0
  41. package/.agents/skills/yx-docs/references/reading-protocol.md +25 -0
  42. package/.agents/skills/yx-docs/references/releases.md +63 -0
  43. package/.agents/skills/yx-docs/references/when-to-write.md +33 -0
  44. package/.agents/skills/yx-docs/references/writing-guide.md +80 -0
  45. package/.agents/skills/yx-frontend-architecture/SKILL.md +16 -0
  46. package/.agents/skills/yx-frontend-architecture/references/frameworks.md +15 -0
  47. package/.agents/skills/yx-frontend-architecture/references/state-and-interaction.md +11 -0
  48. package/.agents/skills/yx-frontend-architecture/references/structure.md +11 -0
  49. package/LICENSE +21 -0
  50. package/README.md +76 -2
  51. package/dist/bin/yak.js +11 -0
  52. package/dist/cli/fsx.js +72 -0
  53. package/dist/cli/kit.js +47 -0
  54. package/dist/cli/main.js +132 -0
  55. package/dist/cli/targets/claude.js +47 -0
  56. package/dist/cli/targets/dsh.js +61 -0
  57. package/dist/cli/targets/registry.js +33 -0
  58. package/dist/cli/targets/types.js +1 -0
  59. package/package.json +40 -4
package/README.md CHANGED
@@ -1,3 +1,77 @@
1
- # Temporary Holding Version
1
+ # Yushe Agent Kit
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ > One-command install of skills, commands, rules & hooks for AI coding agents — Claude Code, Codex, OpenCode, Gemini CLI, DSH and more.
4
+
5
+ 一套围绕 vibe coding 沉淀的智能体脚手架资源库:skills、commands、rules、hooks 等,单一源目录维护,一键安装到各类 agent CLI。
6
+
7
+ ## 仓库结构
8
+
9
+ ```text
10
+ yushe-agent-kit/
11
+ ├── README.md / AGENTS.md # 入口路由 / 维护约定
12
+ ├── package.json / bin/ # yak CLI(单包发布,资源即载荷)
13
+ ├── src/cli/ # CLI 实现(targets/registry.js 为映射唯一权威)
14
+ ├── docs/ # 本仓库文档(yx-docs 单服务形态)
15
+ │ ├── usage/ # 安装、DSH 发现机制
16
+ │ ├── tech/ # 架构综述(资源模型、rules/skills 分工)
17
+ │ ├── standards/ # skill 编写规范
18
+ │ ├── releases/ # 发版记录
19
+ │ ├── glossary.md # 术语表
20
+ │ └── AUTHORING.md # 贡献指南
21
+ └── .agents/
22
+ ├── rules/ # 协作规则源(机制注入,见下节)
23
+ ├── notes/ # 决策记录(proposed/implemented/rejected)
24
+ ├── dsh/ # DSH 专属资源(plugins/yushe-user-rules:rules 注入机制)
25
+ ├── skills/ # skill 源(单一事实来源)
26
+ └── (claude/ opencode/ … 其他工具专属目录随内容建立)
27
+ ```
28
+
29
+ `.agents/skills/` 是多个 agent CLI 正在收敛的项目级 skills 约定路径,本仓库本身就是一个合法的 agent 工作区——克隆即可被识别,无需先安装。文档体系遵循本 kit 的 `yx-docs` skill 约定(何时写、放哪里、怎么读写详见该 skill)。
30
+
31
+ ## Rules(协作规则)
32
+
33
+ `.agents/rules/` 存放**由机制注入、不依赖模型判断**的强制约定(Claude Code rules 语义):
34
+
35
+ | Rule | 注入方式 | 内容 |
36
+ |---|---|---|
37
+ | `interaction.md` | `alwaysApply: true`,每会话首步注入 | vibe coding 交互原则:简体中文语言规则、先读后写、小步推进、诚实汇报 |
38
+ | `git-workflow.md` | `alwaysApply: true`,每会话首步注入 | 简化 trunk-based 分支、`type(scope): 中文描述` 提交格式、提交/推送双授权安全边界 |
39
+ | `docs-management.md` | `paths: **/*.md` 门控,首次读写 md 时注入 | 文档放置、单一权威定义、链接同步、写作风格 |
40
+
41
+ **加载机制**:DSH 通过 `yushe-user-rules` 插件(`.agents/rules` 为最高优先级源)自动注入——插件源在本仓库 [`.agents/dsh/plugins/yushe-user-rules/`](.agents/dsh/plugins/yushe-user-rules/README.md),安装方式见 [docs/usage/install.md](docs/usage/install.md);Claude Code 原生支持 rules 目录;其余 CLI 由安装器映射。规则与 skills 的分工:**rules = 机制注入的强制约定,skills = 模型按任务加载的领域知识**。
42
+
43
+ ## Skills 一览
44
+
45
+ | Skill | 覆盖范围 |
46
+ |---|---|
47
+ | `yx-backend-architecture` | 后端模块、服务编排与持久化边界;Java/Spring Boot/MyBatis-Plus 完整规范,TypeScript/Python/Go 基础指南 |
48
+ | `yx-frontend-architecture` | 前端业务模块、组件边界、状态、表单与异步交互(React/Vue + TS) |
49
+ | `yx-api-design` | HTTP API 契约、资源命名、分页、错误、幂等与兼容性 |
50
+ | `yx-database-design` | 关系型表、约束、索引、事务策略与可演进迁移(MySQL/PostgreSQL) |
51
+ | `yx-docs` | 文档读取与写作:分形布局(单服务/monorepo/模块)、产品/技术/使用文档、决策记录(notes)、发版记录(docs/releases/) |
52
+
53
+ 各 skill 互相按任务显式协作(改契约加载 yx-api-design、改模型加载 yx-database-design),不自动依赖。
54
+
55
+ ## 安装
56
+
57
+ 推荐 yak CLI(发布后 `npx @leiax00/yushe-agent-kit install <target>`;开发期 `npm run dev -- <cmd>` 或 `npm run build && node dist/bin/yak.js <cmd>`):
58
+
59
+ ```bash
60
+ npx @leiax00/yushe-agent-kit install dsh # skills 软链 + rules 插件安装
61
+ npx @leiax00/yushe-agent-kit install claude # skills 软链 + rules 复制到项目 .claude/rules/
62
+ npx @leiax00/yushe-agent-kit doctor # 诊断遮蔽、双源、失效软链
63
+ ```
64
+
65
+ 详见 [docs/usage/install.md](docs/usage/install.md);DSH 发现机制与排障见 [docs/usage/dsh-discovery.md](docs/usage/dsh-discovery.md)。未核实目录约定的目标(opencode/codex/gemini)CLI 会拒绝安装,核实后在 [src/cli/targets/registry.js](src/cli/targets/registry.js) 登记映射。
66
+
67
+ ## 维护原则
68
+
69
+ - **单一源**:所有资源只在 `.agents/` 下维护一份,各 CLI 目录一律由源映射(复制或软链),不双写。
70
+ - **条件加载**:skill 采用路由式 SKILL.md + 按任务加载的 references,反对一次性灌入全部规范。
71
+ - **跨语言原则上浮**:原则性内容(KISS/YAGNI、代码整洁、设计模式选择)放 `references/common/`,语言专属细则放各自语言目录。
72
+
73
+ 详见 [AGENTS.md](AGENTS.md) 与 [docs/](docs/)。
74
+
75
+ ## License
76
+
77
+ MIT
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env node
2
+ /** yak — yushe-agent-kit CLI entry (compiled to dist/bin/yak.js). */
3
+ import { run } from '../cli/main.js';
4
+ process.title = 'yak';
5
+ try {
6
+ process.exitCode = await run();
7
+ }
8
+ catch (error) {
9
+ console.error(`yak: ${error instanceof Error ? error.message : String(error)}`);
10
+ process.exitCode = 1;
11
+ }
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Filesystem helpers: symlink-first installation with copy fallback.
3
+ */
4
+ import { symlinkSync, unlinkSync, mkdirSync, cpSync, lstatSync, readlinkSync, statSync, } from 'node:fs';
5
+ import { dirname } from 'node:path';
6
+ function lstatIfExists(target) {
7
+ try {
8
+ lstatSync(target);
9
+ return true;
10
+ }
11
+ catch {
12
+ return false;
13
+ }
14
+ }
15
+ /** What currently sits at `target` (for reporting and doctor). */
16
+ export function linkState(target) {
17
+ if (!lstatIfExists(target))
18
+ return 'absent';
19
+ const st = lstatSync(target);
20
+ if (st.isSymbolicLink()) {
21
+ try {
22
+ return statSync(target) ? 'symlink-ok' : 'symlink-broken';
23
+ }
24
+ catch {
25
+ return 'symlink-broken';
26
+ }
27
+ }
28
+ return st.isDirectory() ? 'dir' : 'file';
29
+ }
30
+ /** Where an existing symlink points, or undefined. */
31
+ export function symlinkTarget(target) {
32
+ try {
33
+ return readlinkSync(target);
34
+ }
35
+ catch {
36
+ return undefined;
37
+ }
38
+ }
39
+ /** Install `source` (a directory or file) at `target` as symlink, else copy. */
40
+ export function place(source, target, { copy = false } = {}) {
41
+ const state = linkState(target);
42
+ if (state === 'symlink-ok' && symlinkTarget(target) === source)
43
+ return 'kept';
44
+ if (state === 'dir' || state === 'file')
45
+ return 'conflict'; // user-owned install, refuse to clobber
46
+ if (state.startsWith('symlink'))
47
+ unlinkSync(target);
48
+ mkdirSync(dirname(target), { recursive: true });
49
+ if (copy) {
50
+ cpSync(source, target, { recursive: true });
51
+ return 'copied';
52
+ }
53
+ try {
54
+ symlinkSync(source, target);
55
+ return 'linked';
56
+ }
57
+ catch {
58
+ cpSync(source, target, { recursive: true });
59
+ return 'copied';
60
+ }
61
+ }
62
+ /** Refresh a previously copied install (or create one). */
63
+ export function refreshCopy(source, target) {
64
+ const state = linkState(target);
65
+ if (state === 'symlink-ok')
66
+ return 'symlink';
67
+ if (state !== 'absent')
68
+ unlinkSync(target);
69
+ mkdirSync(dirname(target), { recursive: true });
70
+ cpSync(source, target, { recursive: true });
71
+ return 'copied';
72
+ }
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Kit resource inventory: the `.agents/` payload is the single source of truth.
3
+ * Everything the CLI installs is enumerated here — no hardcoded skill lists.
4
+ */
5
+ import { readdirSync, readFileSync, existsSync } from 'node:fs';
6
+ import { join, dirname } from 'node:path';
7
+ import { fileURLToPath } from 'node:url';
8
+ /** Repository / package root. In dev this file runs from src/, in prod from dist/. */
9
+ export const kitRoot = join(dirname(fileURLToPath(import.meta.url)), '..', '..');
10
+ export const paths = {
11
+ skills: join(kitRoot, '.agents', 'skills'),
12
+ rules: join(kitRoot, '.agents', 'rules'),
13
+ dshPlugins: join(kitRoot, '.agents', 'dsh', 'plugins'),
14
+ };
15
+ export function listSkills() {
16
+ return subdirs(paths.skills);
17
+ }
18
+ export function listRules() {
19
+ if (!existsSync(paths.rules))
20
+ return [];
21
+ return readdirSync(paths.rules).filter(f => f.endsWith('.md')).sort();
22
+ }
23
+ export function listDshPlugins() {
24
+ return subdirs(paths.dshPlugins);
25
+ }
26
+ export function version() {
27
+ return JSON.parse(readFileSync(join(kitRoot, 'package.json'), 'utf8')).version;
28
+ }
29
+ /** SKILL.md frontmatter name of a skill dir, for name/dir consistency checks. */
30
+ export function skillEntryName(skillDir) {
31
+ const file = join(paths.skills, skillDir, 'SKILL.md');
32
+ if (!existsSync(file))
33
+ return undefined;
34
+ const text = readFileSync(file, 'utf8');
35
+ const match = text.match(/^---\r?\n([\s\S]*?)\r?\n---/);
36
+ if (!match)
37
+ return undefined;
38
+ return match[1].match(/^name:\s*(.+)$/m)?.[1]?.trim();
39
+ }
40
+ function subdirs(dir) {
41
+ if (!existsSync(dir))
42
+ return [];
43
+ return readdirSync(dir, { withFileTypes: true })
44
+ .filter(e => e.isDirectory())
45
+ .map(e => e.name)
46
+ .sort();
47
+ }
@@ -0,0 +1,132 @@
1
+ /**
2
+ * Commands (commander-based) and shared kit-level doctor findings.
3
+ */
4
+ import { Command, InvalidArgumentError } from 'commander';
5
+ import { join } from 'node:path';
6
+ import { existsSync } from 'node:fs';
7
+ import { listSkills, listRules, listDshPlugins, skillEntryName, version, paths } from './kit.js';
8
+ import { targetNames, targets, getTarget, loadInstaller } from './targets/registry.js';
9
+ const program = new Command();
10
+ program
11
+ .name('yak')
12
+ .description('yushe-agent-kit — 把 kit 资源安装到各 vibe coding 工具')
13
+ .version(version());
14
+ function parseTargets(value, previous) {
15
+ return [...previous, value];
16
+ }
17
+ program.command('install')
18
+ .description('安装 kit 资源到目标工具(可多个,或 --all)')
19
+ .argument('<target...>', '目标工具(dsh/claude/…)', parseTargets, [])
20
+ .option('--all', '安装全部已核实目标')
21
+ .option('--copy', '强制复制而非软链')
22
+ .option('--project <dir>', '项目级安装(rules 落到该项目;默认当前目录)')
23
+ .option('--profile <name>', 'DSH 插件安装目标 profile')
24
+ .option('--no-plugin', '跳过 DSH 插件安装')
25
+ .action(async (targetList, opts) => {
26
+ const names = opts.all ? targetNames() : targetList;
27
+ if (names.length === 0)
28
+ throw new InvalidArgumentError(`缺少目标工具(可用:${targetNames().join(', ')},或 --all)`);
29
+ let failed = false;
30
+ for (const name of names) {
31
+ const t = getTarget(name); // unknown target throws with the list
32
+ const mod = await loadInstaller(name);
33
+ console.log(`\n== ${t.label} ==`);
34
+ try {
35
+ const lines = await mod.install(opts);
36
+ for (const line of lines)
37
+ console.log(` ${line}`);
38
+ }
39
+ catch (error) {
40
+ failed = true;
41
+ console.error(` 安装失败:${error instanceof Error ? error.message : String(error)}`);
42
+ }
43
+ }
44
+ if (failed)
45
+ process.exitCode = 1;
46
+ });
47
+ program.command('update')
48
+ .description('刷新复制型安装(软链安装实时生效,无需 update)')
49
+ .argument('<target...>', '目标工具', parseTargets, [])
50
+ .option('--project <dir>', '项目级安装目标')
51
+ .action(async (targetList, opts) => {
52
+ let failed = false;
53
+ for (const name of targetList) {
54
+ const t = getTarget(name);
55
+ const mod = await loadInstaller(name);
56
+ console.log(`\n== ${t.label} ==`);
57
+ try {
58
+ const fn = mod.update ?? mod.install;
59
+ const lines = await fn(opts);
60
+ for (const line of lines)
61
+ console.log(` ${line}`);
62
+ }
63
+ catch (error) {
64
+ failed = true;
65
+ console.error(` 更新失败:${error instanceof Error ? error.message : String(error)}`);
66
+ }
67
+ }
68
+ if (failed)
69
+ process.exitCode = 1;
70
+ });
71
+ program.command('list')
72
+ .description('列出 kit 资源与各目标工具映射')
73
+ .action(() => {
74
+ const skills = listSkills();
75
+ console.log(`yushe-agent-kit v${version()} 资源清单\n`);
76
+ console.log(`skills (${skills.length})`);
77
+ for (const s of skills) {
78
+ const entry = skillEntryName(s);
79
+ console.log(` ${s}${entry === s ? '' : ` ⚠ SKILL.md name 不一致: ${entry}`}`);
80
+ }
81
+ console.log(`\nrules (${listRules().length})`);
82
+ for (const r of listRules())
83
+ console.log(` ${r}`);
84
+ console.log(`\ndsh plugins (${listDshPlugins().length})`);
85
+ for (const p of listDshPlugins())
86
+ console.log(` ${p}`);
87
+ console.log('\n目标工具映射:');
88
+ for (const name of targetNames()) {
89
+ const t = targets[name];
90
+ console.log(` ${name.padEnd(9)} ${t.verified ? '✓' : '未核实'} ${t.notes}`);
91
+ }
92
+ });
93
+ program.command('doctor')
94
+ .description('诊断安装问题(遮蔽、双源、失效软链、命名不一致)')
95
+ .action(async () => {
96
+ let bad = 0;
97
+ const report = (line) => {
98
+ if (line.startsWith('FAIL'))
99
+ bad += 1;
100
+ console.log(` ${line}`);
101
+ };
102
+ console.log('kit 层:');
103
+ for (const s of listSkills()) {
104
+ const entry = skillEntryName(s);
105
+ if (entry === undefined)
106
+ report(`FAIL ${s}/SKILL.md 缺少 name 字段或 frontmatter`);
107
+ else if (entry !== s)
108
+ report(`FAIL ${s} 目录名与 name: ${entry} 不一致`);
109
+ if (!existsSync(join(paths.skills, s, 'SKILL.md')))
110
+ report(`FAIL ${s} 缺少 SKILL.md`);
111
+ }
112
+ if (listRules().length === 0)
113
+ report('WARN 没有发现任何 rule');
114
+ for (const name of ['dsh', 'claude']) {
115
+ console.log(`\n${getTarget(name).label}:`);
116
+ const mod = await loadInstaller(name);
117
+ for (const line of mod.doctor())
118
+ report(line);
119
+ }
120
+ console.log(bad === 0 ? '\n结论:未发现问题' : `\n结论:${bad} 项失败需要处理`);
121
+ if (bad > 0)
122
+ process.exitCode = 1;
123
+ });
124
+ export async function run(argv) {
125
+ if (argv === undefined) {
126
+ await program.parseAsync(process.argv);
127
+ }
128
+ else {
129
+ await program.parseAsync(argv, { from: 'user' });
130
+ }
131
+ return typeof process.exitCode === 'number' ? process.exitCode : 0;
132
+ }
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Claude Code installer: skills → ~/.claude/skills/<name>(软链);
3
+ * rules → 项目 .claude/rules/(Claude Code 原生 rules 目录约定,
4
+ * 与 yushe-user-rules 扫描的 tier 2 一致)。
5
+ */
6
+ import { join } from 'node:path';
7
+ import { homedir } from 'node:os';
8
+ import { listRules, listSkills, paths } from '../kit.js';
9
+ import { place, refreshCopy, linkState } from '../fsx.js';
10
+ function claudeSkillsRoot() {
11
+ return join(homedir(), '.claude', 'skills');
12
+ }
13
+ function projectRulesRoot(project) {
14
+ return join(project ?? process.cwd(), '.claude', 'rules');
15
+ }
16
+ export const install = async (opts) => {
17
+ const lines = [];
18
+ const root = claudeSkillsRoot();
19
+ for (const skill of listSkills()) {
20
+ const action = place(join(paths.skills, skill), join(root, skill), { copy: opts.copy });
21
+ lines.push(`${action.padEnd(7)} ${root}/${skill}`);
22
+ }
23
+ const rulesRoot = projectRulesRoot(opts.project);
24
+ for (const rule of listRules()) {
25
+ const target = join(rulesRoot, rule);
26
+ const action = opts.copy
27
+ ? refreshCopy(join(paths.rules, rule), target)
28
+ : place(join(paths.rules, rule), target, { copy: true });
29
+ lines.push(`${action.padEnd(7)} ${target}`);
30
+ }
31
+ return lines;
32
+ };
33
+ export const update = async (opts) => {
34
+ return install({ ...opts, copy: true });
35
+ };
36
+ export const doctor = () => {
37
+ const lines = [];
38
+ const root = claudeSkillsRoot();
39
+ for (const skill of listSkills()) {
40
+ const state = linkState(join(root, skill));
41
+ if (state === 'symlink-broken')
42
+ lines.push(`FAIL ${root}/${skill} 软链失效`);
43
+ if (state === 'dir')
44
+ lines.push(`WARN ${root}/${skill} 是实体目录,可能是过时副本(update 可刷新)`);
45
+ }
46
+ return lines;
47
+ };
@@ -0,0 +1,61 @@
1
+ /**
2
+ * DSH installer: skills → user skills root as symlinks; rules → project
3
+ * `.agents/rules/`, injected by the yushe-user-rules plugin; plugin →
4
+ * `dsh plugin add link:` into the active profile.
5
+ */
6
+ import { join } from 'node:path';
7
+ import { homedir } from 'node:os';
8
+ import { existsSync } from 'node:fs';
9
+ import { spawnSync } from 'node:child_process';
10
+ import { listSkills, listRules, listDshPlugins, paths } from '../kit.js';
11
+ import { place, linkState } from '../fsx.js';
12
+ function dshHome() {
13
+ return process.env.DSH_HOME ?? join(homedir(), '.dsh');
14
+ }
15
+ function skillsRoot() {
16
+ return join(dshHome(), 'skills');
17
+ }
18
+ export const install = async (opts) => {
19
+ const lines = [];
20
+ const root = skillsRoot();
21
+ for (const skill of listSkills()) {
22
+ const action = place(join(paths.skills, skill), join(root, skill), { copy: opts.copy });
23
+ lines.push(`${action.padEnd(7)} ${root}/${skill}`);
24
+ }
25
+ lines.push(`rules: 项目 .agents/rules/ 由 yushe-user-rules 插件注入(kit 自带 ${listRules().length} 条规则,随项目放置即可)`);
26
+ if (opts.plugin !== false) {
27
+ for (const plugin of listDshPlugins()) {
28
+ lines.push(...installPlugin(join(paths.dshPlugins, plugin), opts));
29
+ }
30
+ }
31
+ return lines;
32
+ };
33
+ function installPlugin(pluginDir, opts) {
34
+ const profile = opts.profile ? ['--profile', opts.profile] : [];
35
+ const link = `link:${pluginDir}`;
36
+ const res = spawnSync('dsh', ['plugin', ...profile, 'add', link], { encoding: 'utf8' });
37
+ if (res.error) {
38
+ return [`plugin: 无法调用 dsh(${res.error.message}),请手动执行:dsh plugin ${profile.join(' ')} add ${link}`];
39
+ }
40
+ return [`plugin: dsh plugin ${profile.join(' ')} add ${link}${res.status === 0 ? '' : `(失败,exit ${res.status})`}`];
41
+ }
42
+ export const doctor = () => {
43
+ const lines = [];
44
+ const root = skillsRoot();
45
+ for (const skill of listSkills()) {
46
+ const userState = linkState(join(root, skill));
47
+ if (userState === 'symlink-broken')
48
+ lines.push(`FAIL ${root}/${skill} 软链失效`);
49
+ if (userState === 'dir')
50
+ lines.push(`WARN ${root}/${skill} 是实体目录(非 kit 软链),可能双源或过时副本`);
51
+ }
52
+ // Project .dsh/skills shadows .agents/skills in DSH discovery order.
53
+ const projDsh = join(process.cwd(), '.dsh', 'skills');
54
+ if (existsSync(projDsh)) {
55
+ const shadowing = listSkills().filter(s => existsSync(join(projDsh, s)));
56
+ if (shadowing.length > 0) {
57
+ lines.push(`FAIL 项目 .dsh/skills/ 遮蔽同名 skill(DSH 发现顺序 .dsh 优先):${shadowing.join(', ')}`);
58
+ }
59
+ }
60
+ return lines;
61
+ };
@@ -0,0 +1,33 @@
1
+ export const targets = {
2
+ dsh: {
3
+ label: 'DSH (DeepSeek Harness)',
4
+ installer: './dsh.js',
5
+ verified: true,
6
+ notes: 'skills 软链到用户 skills 根;rules 由 yushe-user-rules 插件读取项目 .agents/rules/,插件可一并 link 安装',
7
+ },
8
+ claude: {
9
+ label: 'Claude Code',
10
+ installer: './claude.js',
11
+ verified: true,
12
+ notes: 'skills 软链到 ~/.claude/skills/;rules 复制到项目 .claude/rules/(Claude Code 原生 rules)',
13
+ },
14
+ opencode: { label: 'OpenCode', verified: false, notes: '目录约定未核实,暂不安装;核实后在此登记映射' },
15
+ codex: { label: 'Codex', verified: false, notes: '目录约定未核实,暂不安装;核实后在此登记映射' },
16
+ gemini: { label: 'Gemini CLI', verified: false, notes: '目录约定未核实,暂不安装;核实后在此登记映射' },
17
+ };
18
+ export function targetNames() {
19
+ return Object.keys(targets);
20
+ }
21
+ export function getTarget(name) {
22
+ const t = targets[name];
23
+ if (!t)
24
+ throw new Error(`未知目标工具:${name}(可用:${targetNames().join(', ')})`);
25
+ return t;
26
+ }
27
+ export async function loadInstaller(name) {
28
+ const t = getTarget(name);
29
+ if (!t.verified || !t.installer) {
30
+ throw new Error(`${t.label} 的目录约定尚未核实,拒绝凭印象安装(见 src/cli/targets/registry.ts)`);
31
+ }
32
+ return import(t.installer);
33
+ }
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,42 @@
1
1
  {
2
2
  "name": "@leiax00/yushe-agent-kit",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "One-command install of skills, rules & plugins for AI coding agents (DSH, Claude Code, ...)",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "bin": {
8
+ "yushe-agent-kit": "dist/bin/yak.js",
9
+ "yak": "dist/bin/yak.js"
10
+ },
11
+ "files": [
12
+ "dist/",
13
+ ".agents/skills/",
14
+ ".agents/rules/",
15
+ ".agents/dsh/",
16
+ "README.md"
17
+ ],
18
+ "scripts": {
19
+ "build": "tsc -p tsconfig.json",
20
+ "dev": "tsx src/bin/yak.ts",
21
+ "prepublishOnly": "npm run build"
22
+ },
23
+ "dependencies": {
24
+ "commander": "^14.0.0"
25
+ },
26
+ "devDependencies": {
27
+ "@types/node": "^24.0.0",
28
+ "tsx": "^4.20.0",
29
+ "typescript": "^5.9.0"
30
+ },
31
+ "engines": {
32
+ "node": ">=18"
33
+ },
34
+ "publishConfig": {
35
+ "registry": "https://registry.npmjs.org/",
36
+ "access": "public"
37
+ },
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "https://github.com/leiax00/yushe-agent-kit.git"
41
+ }
42
+ }