bobo-ai-cli 1.0.1

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 (234) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +216 -0
  3. package/dist/agent.d.ts +9 -0
  4. package/dist/agent.js +144 -0
  5. package/dist/agent.js.map +1 -0
  6. package/dist/config.d.ts +15 -0
  7. package/dist/config.js +76 -0
  8. package/dist/config.js.map +1 -0
  9. package/dist/index.d.ts +2 -0
  10. package/dist/index.js +366 -0
  11. package/dist/index.js.map +1 -0
  12. package/dist/knowledge-commands.d.ts +2 -0
  13. package/dist/knowledge-commands.js +40 -0
  14. package/dist/knowledge-commands.js.map +1 -0
  15. package/dist/knowledge.d.ts +17 -0
  16. package/dist/knowledge.js +112 -0
  17. package/dist/knowledge.js.map +1 -0
  18. package/dist/memory.d.ts +17 -0
  19. package/dist/memory.js +215 -0
  20. package/dist/memory.js.map +1 -0
  21. package/dist/planner.d.ts +22 -0
  22. package/dist/planner.js +130 -0
  23. package/dist/planner.js.map +1 -0
  24. package/dist/project.d.ts +25 -0
  25. package/dist/project.js +117 -0
  26. package/dist/project.js.map +1 -0
  27. package/dist/rules-commands.d.ts +2 -0
  28. package/dist/rules-commands.js +51 -0
  29. package/dist/rules-commands.js.map +1 -0
  30. package/dist/skills.d.ts +28 -0
  31. package/dist/skills.js +349 -0
  32. package/dist/skills.js.map +1 -0
  33. package/dist/structured/loader.d.ts +19 -0
  34. package/dist/structured/loader.js +147 -0
  35. package/dist/structured/loader.js.map +1 -0
  36. package/dist/structured/paths.d.ts +2 -0
  37. package/dist/structured/paths.js +14 -0
  38. package/dist/structured/paths.js.map +1 -0
  39. package/dist/structured/project-scaffold.d.ts +7 -0
  40. package/dist/structured/project-scaffold.js +60 -0
  41. package/dist/structured/project-scaffold.js.map +1 -0
  42. package/dist/structured/render-markdown.d.ts +37 -0
  43. package/dist/structured/render-markdown.js +47 -0
  44. package/dist/structured/render-markdown.js.map +1 -0
  45. package/dist/structured/render-table.d.ts +1 -0
  46. package/dist/structured/render-table.js +15 -0
  47. package/dist/structured/render-table.js.map +1 -0
  48. package/dist/structured/search.d.ts +10 -0
  49. package/dist/structured/search.js +104 -0
  50. package/dist/structured/search.js.map +1 -0
  51. package/dist/structured/skill-runner.d.ts +15 -0
  52. package/dist/structured/skill-runner.js +60 -0
  53. package/dist/structured/skill-runner.js.map +1 -0
  54. package/dist/structured/types.d.ts +212 -0
  55. package/dist/structured/types.js +97 -0
  56. package/dist/structured/types.js.map +1 -0
  57. package/dist/structured-skills-commands.d.ts +3 -0
  58. package/dist/structured-skills-commands.js +126 -0
  59. package/dist/structured-skills-commands.js.map +1 -0
  60. package/dist/structured-template-commands.d.ts +2 -0
  61. package/dist/structured-template-commands.js +34 -0
  62. package/dist/structured-template-commands.js.map +1 -0
  63. package/dist/tools/index.d.ts +3 -0
  64. package/dist/tools/index.js +450 -0
  65. package/dist/tools/index.js.map +1 -0
  66. package/dist/ui.d.ts +19 -0
  67. package/dist/ui.js +72 -0
  68. package/dist/ui.js.map +1 -0
  69. package/dist/web.d.ts +4 -0
  70. package/dist/web.js +124 -0
  71. package/dist/web.js.map +1 -0
  72. package/knowledge/advanced-patterns.md +70 -0
  73. package/knowledge/agent-directives.md +74 -0
  74. package/knowledge/dream.md +36 -0
  75. package/knowledge/engineering.md +46 -0
  76. package/knowledge/error-catalog.md +33 -0
  77. package/knowledge/index.json +170 -0
  78. package/knowledge/memory/cache-optimization-and-skill-integration.md +102 -0
  79. package/knowledge/memory/engineering-patterns.md +134 -0
  80. package/knowledge/memory/feedback_root_structure.md +16 -0
  81. package/knowledge/memory/project-contexts.md +69 -0
  82. package/knowledge/memory/tools-and-services.md +85 -0
  83. package/knowledge/rules/agents.md +62 -0
  84. package/knowledge/rules/blocking-rules.md +323 -0
  85. package/knowledge/rules/cache-management.md +379 -0
  86. package/knowledge/rules/capability-evolution.md +132 -0
  87. package/knowledge/rules/coding.md +126 -0
  88. package/knowledge/rules/engineering-workflows.md +225 -0
  89. package/knowledge/rules/evomap-content-guidelines.md +354 -0
  90. package/knowledge/rules/evomap-guide.md +224 -0
  91. package/knowledge/rules/git.md +31 -0
  92. package/knowledge/rules/hooks.md +106 -0
  93. package/knowledge/rules/performance.md +101 -0
  94. package/knowledge/rules/remotion-auto-production.md +1120 -0
  95. package/knowledge/rules/security.md +46 -0
  96. package/knowledge/rules/testing.md +32 -0
  97. package/knowledge/rules/work-mode.md +208 -0
  98. package/knowledge/rules.md +62 -0
  99. package/knowledge/skills/Skill_Seekers.md +1722 -0
  100. package/knowledge/skills/ab-test-setup.md +557 -0
  101. package/knowledge/skills/agent-sdk-dev.md +238 -0
  102. package/knowledge/skills/agent-tools.md +136 -0
  103. package/knowledge/skills/analytics-tracking.md +597 -0
  104. package/knowledge/skills/artifacts-builder.md +89 -0
  105. package/knowledge/skills/asana.md +13 -0
  106. package/knowledge/skills/backend-expert.md +97 -0
  107. package/knowledge/skills/brand-voice.md +481 -0
  108. package/knowledge/skills/browser-use.md +419 -0
  109. package/knowledge/skills/cache-optimization-skill.md +179 -0
  110. package/knowledge/skills/canvas-design.md +147 -0
  111. package/knowledge/skills/citation-validator.md +203 -0
  112. package/knowledge/skills/clangd-lsp.md +52 -0
  113. package/knowledge/skills/code-review-expert.md +85 -0
  114. package/knowledge/skills/code-review.md +280 -0
  115. package/knowledge/skills/code-simplifier.md +13 -0
  116. package/knowledge/skills/commit-commands.md +258 -0
  117. package/knowledge/skills/competitor-alternatives.md +795 -0
  118. package/knowledge/skills/content-atomizer.md +910 -0
  119. package/knowledge/skills/content-research-writer.md +605 -0
  120. package/knowledge/skills/context-optimization-suite.md +162 -0
  121. package/knowledge/skills/context7.md +13 -0
  122. package/knowledge/skills/copy-editing.md +494 -0
  123. package/knowledge/skills/copywriting.md +510 -0
  124. package/knowledge/skills/csharp-lsp.md +40 -0
  125. package/knowledge/skills/decision-making-framework.md +154 -0
  126. package/knowledge/skills/developer-growth-analysis.md +335 -0
  127. package/knowledge/skills/direct-response-copy.md +2336 -0
  128. package/knowledge/skills/docker-expert.md +229 -0
  129. package/knowledge/skills/document-skills.md +13 -0
  130. package/knowledge/skills/documentation-expert.md +126 -0
  131. package/knowledge/skills/email-sequence.md +1061 -0
  132. package/knowledge/skills/email-sequences.md +910 -0
  133. package/knowledge/skills/example-plugin.md +72 -0
  134. package/knowledge/skills/explanatory-output-style.md +82 -0
  135. package/knowledge/skills/feature-dev.md +458 -0
  136. package/knowledge/skills/file-organizer.md +466 -0
  137. package/knowledge/skills/firebase.disabled.md +13 -0
  138. package/knowledge/skills/form-cro.md +488 -0
  139. package/knowledge/skills/free-tool-strategy.md +636 -0
  140. package/knowledge/skills/frontend-design-offical.md +55 -0
  141. package/knowledge/skills/frontend-design.md +41 -0
  142. package/knowledge/skills/frontend-expert.md +93 -0
  143. package/knowledge/skills/github.md +13 -0
  144. package/knowledge/skills/gitlab.md +13 -0
  145. package/knowledge/skills/gopls-lsp.md +32 -0
  146. package/knowledge/skills/got-controller.md +218 -0
  147. package/knowledge/skills/greptile.md +72 -0
  148. package/knowledge/skills/hookify.md +376 -0
  149. package/knowledge/skills/image-editor.md +189 -0
  150. package/knowledge/skills/image-enhancer.md +109 -0
  151. package/knowledge/skills/jdtls-lsp.md +49 -0
  152. package/knowledge/skills/json-canvas.md +654 -0
  153. package/knowledge/skills/keyword-research.md +559 -0
  154. package/knowledge/skills/kotlin-lsp.md +28 -0
  155. package/knowledge/skills/laravel-boost.md +13 -0
  156. package/knowledge/skills/launch-strategy.md +394 -0
  157. package/knowledge/skills/lead-magnet.md +393 -0
  158. package/knowledge/skills/learning-output-style.md +106 -0
  159. package/knowledge/skills/linear.md +13 -0
  160. package/knowledge/skills/lua-lsp.md +47 -0
  161. package/knowledge/skills/marketing-ideas.md +720 -0
  162. package/knowledge/skills/marketing-psychology.md +534 -0
  163. package/knowledge/skills/mcp-builder.md +369 -0
  164. package/knowledge/skills/meeting-insights-analyzer.md +347 -0
  165. package/knowledge/skills/memory-evolution-system.md +172 -0
  166. package/knowledge/skills/multi-lens-thinking.md +407 -0
  167. package/knowledge/skills/nano-banana-pro.md +116 -0
  168. package/knowledge/skills/newsletter.md +736 -0
  169. package/knowledge/skills/notebooklm.md +296 -0
  170. package/knowledge/skills/obsidian-bases.md +634 -0
  171. package/knowledge/skills/obsidian-markdown.md +651 -0
  172. package/knowledge/skills/onboarding-cro.md +494 -0
  173. package/knowledge/skills/orchestrator.md +681 -0
  174. package/knowledge/skills/page-cro.md +379 -0
  175. package/knowledge/skills/paid-ads.md +624 -0
  176. package/knowledge/skills/paywall-upgrade-cro.md +651 -0
  177. package/knowledge/skills/php-lsp.md +36 -0
  178. package/knowledge/skills/planning-with-files.md +193 -0
  179. package/knowledge/skills/playwright.md +13 -0
  180. package/knowledge/skills/plugin-dev.md +434 -0
  181. package/knowledge/skills/popup-cro.md +520 -0
  182. package/knowledge/skills/positioning-angles.md +330 -0
  183. package/knowledge/skills/pr-review-toolkit.md +359 -0
  184. package/knowledge/skills/pricing-strategy.md +777 -0
  185. package/knowledge/skills/programmatic-seo.md +714 -0
  186. package/knowledge/skills/pyright-lsp.md +43 -0
  187. package/knowledge/skills/quality-assurance-framework.md +168 -0
  188. package/knowledge/skills/question-refiner.md +160 -0
  189. package/knowledge/skills/ralph-loop.md +205 -0
  190. package/knowledge/skills/refactoring-expert.md +103 -0
  191. package/knowledge/skills/referral-program.md +668 -0
  192. package/knowledge/skills/research-executor.md +164 -0
  193. package/knowledge/skills/review-with-security.md +12 -0
  194. package/knowledge/skills/rust-analyzer-lsp.md +50 -0
  195. package/knowledge/skills/schema-markup.md +647 -0
  196. package/knowledge/skills/security-audit-expert.md +124 -0
  197. package/knowledge/skills/security-expert.md +140 -0
  198. package/knowledge/skills/security-guidance.md +13 -0
  199. package/knowledge/skills/seedance-prompt.md +139 -0
  200. package/knowledge/skills/self-evolution.md +1160 -0
  201. package/knowledge/skills/seo-audit.md +432 -0
  202. package/knowledge/skills/seo-content.md +787 -0
  203. package/knowledge/skills/serena.md +13 -0
  204. package/knowledge/skills/signup-flow-cro.md +409 -0
  205. package/knowledge/skills/skill-creator.md +220 -0
  206. package/knowledge/skills/skill-manager.md +226 -0
  207. package/knowledge/skills/skill-share.md +98 -0
  208. package/knowledge/skills/slack.md +13 -0
  209. package/knowledge/skills/social-content.md +878 -0
  210. package/knowledge/skills/spec-flow-skill.md +124 -0
  211. package/knowledge/skills/stripe.md +13 -0
  212. package/knowledge/skills/supabase.md +13 -0
  213. package/knowledge/skills/swift-lsp.md +40 -0
  214. package/knowledge/skills/synthesizer.md +236 -0
  215. package/knowledge/skills/template-skill.md +16 -0
  216. package/knowledge/skills/testing-expert.md +99 -0
  217. package/knowledge/skills/theme-factory.md +72 -0
  218. package/knowledge/skills/tiktok-research.md +208 -0
  219. package/knowledge/skills/typescript-lsp.md +36 -0
  220. package/knowledge/skills/ui-ux-pro-max.md +247 -0
  221. package/knowledge/skills/verify.md +15 -0
  222. package/knowledge/skills/visual-prompt-engineer.md +102 -0
  223. package/knowledge/skills/webapp-testing.md +111 -0
  224. package/knowledge/skills/wide-research.md +191 -0
  225. package/knowledge/system.md +93 -0
  226. package/knowledge/task-router.md +37 -0
  227. package/knowledge/verification.md +38 -0
  228. package/knowledge/workflows/3d-viz.md +47 -0
  229. package/knowledge/workflows/data-pipeline.md +47 -0
  230. package/knowledge/workflows/db-migration.md +51 -0
  231. package/knowledge/workflows/feature-dev.md +41 -0
  232. package/knowledge/workflows/tdd-flow.md +52 -0
  233. package/knowledge/workflows/ui-verify.md +51 -0
  234. package/package.json +60 -0
@@ -0,0 +1,126 @@
1
+ import chalk from 'chalk';
2
+ import { mkdir, readFile, writeFile } from 'node:fs/promises';
3
+ import { dirname, join } from 'node:path';
4
+ import matter from 'gray-matter';
5
+ import { KnowledgeLoader } from './structured/loader.js';
6
+ import { KnowledgeSearch } from './structured/search.js';
7
+ import { SkillRunner } from './structured/skill-runner.js';
8
+ import { createProjectScaffold } from './structured/project-scaffold.js';
9
+ import { getStructuredKnowledgePath } from './structured/paths.js';
10
+ import { renderSearchResult, renderSkill } from './structured/render-markdown.js';
11
+ import { renderTable } from './structured/render-table.js';
12
+ export function registerStructuredSkillsCommand(program) {
13
+ const skills = program.command('skills').description('Browse and compose structured skills');
14
+ skills
15
+ .command('list')
16
+ .description('List structured skills')
17
+ .option('-c, --category <cat>', '按分类过滤')
18
+ .action(async (opts) => {
19
+ const loader = new KnowledgeLoader(getStructuredKnowledgePath());
20
+ const all = await loader.listSkills();
21
+ const filtered = opts.category ? all.filter((skill) => skill.category === opts.category) : all;
22
+ if (filtered.length === 0) {
23
+ console.log(chalk.dim('No skills found.'));
24
+ return;
25
+ }
26
+ renderTable(['ID', 'Title', 'Category', 'Tags'], filtered.map((skill) => [skill.id, skill.title, skill.category, skill.tags.join(', ')]));
27
+ console.log(chalk.dim(`\n${filtered.length} skills`));
28
+ });
29
+ skills
30
+ .command('show <id>')
31
+ .description('Show full skill content')
32
+ .action(async (id) => {
33
+ const loader = new KnowledgeLoader(getStructuredKnowledgePath());
34
+ const skill = await loader.loadSkill(id);
35
+ if (!skill) {
36
+ console.log(chalk.red(`Skill not found: ${id}`));
37
+ process.exit(1);
38
+ }
39
+ renderSkill(skill);
40
+ });
41
+ skills
42
+ .command('search <query>')
43
+ .description('Search structured skills')
44
+ .action(async (query) => {
45
+ const loader = new KnowledgeLoader(getStructuredKnowledgePath());
46
+ const search = new KnowledgeSearch(loader);
47
+ const results = await search.searchByType(query, 'skill');
48
+ if (results.length === 0) {
49
+ console.log(chalk.dim('No matching skills.'));
50
+ return;
51
+ }
52
+ results.forEach(renderSearchResult);
53
+ });
54
+ skills
55
+ .command('deps <id>')
56
+ .description('Show skill dependency order')
57
+ .action(async (id) => {
58
+ const loader = new KnowledgeLoader(getStructuredKnowledgePath());
59
+ const runner = new SkillRunner(loader);
60
+ const resolved = await runner.resolveDependencies(id);
61
+ console.log(chalk.bold(`\nDependency order for ${id}`));
62
+ resolved.forEach((skill, index) => {
63
+ console.log(` ${index + 1}. ${skill.id}`);
64
+ });
65
+ });
66
+ skills
67
+ .command('bundle <id>')
68
+ .description('构建技能依赖 bundle')
69
+ .action(async (id) => {
70
+ const loader = new KnowledgeLoader(getStructuredKnowledgePath());
71
+ const runner = new SkillRunner(loader);
72
+ const bundle = await runner.buildBundle(id);
73
+ console.log(chalk.bold(`\nRoot: ${bundle.root.id}`));
74
+ console.log(chalk.dim(`Dependencies: ${bundle.dependencies.map((skill) => skill.id).join(', ') || 'none'}`));
75
+ console.log(chalk.dim('─'.repeat(60)));
76
+ console.log(bundle.combinedContent);
77
+ });
78
+ skills
79
+ .command('export <id>')
80
+ .description('Export structured skill as markdown')
81
+ .option('-o, --output <file>', '输出文件路径')
82
+ .action(async (id, opts) => {
83
+ const loader = new KnowledgeLoader(getStructuredKnowledgePath());
84
+ const runner = new SkillRunner(loader);
85
+ const markdown = await runner.exportSkill(id);
86
+ if (!opts.output) {
87
+ console.log(markdown);
88
+ return;
89
+ }
90
+ await mkdir(dirname(opts.output), { recursive: true });
91
+ await writeFile(opts.output, markdown, 'utf-8');
92
+ console.log(chalk.green(`Exported ${id} to ${opts.output}`));
93
+ });
94
+ skills
95
+ .command('import <file>')
96
+ .description('Import skill markdown into knowledge base')
97
+ .action(async (file) => {
98
+ const raw = await readFile(file, 'utf-8');
99
+ const parsed = matter(raw);
100
+ const skillId = parsed.data.id;
101
+ if (!skillId) {
102
+ console.log(chalk.red('Imported skill is missing frontmatter id.'));
103
+ process.exit(1);
104
+ }
105
+ const outputPath = join(getStructuredKnowledgePath(), 'skills', `${skillId}.md`);
106
+ await writeFile(outputPath, raw, 'utf-8');
107
+ console.log(chalk.green(`Imported skill ${skillId} to ${outputPath}`));
108
+ });
109
+ return skills;
110
+ }
111
+ export function registerTemplateProjectSubcommand(template) {
112
+ template
113
+ .command('project')
114
+ .description('生成 .claude 项目脚手架')
115
+ .requiredOption('-d, --dir <dir>', '目标项目目录')
116
+ .option('-n, --name <name>', '项目名称', 'My Project')
117
+ .action(async (opts) => {
118
+ const created = await createProjectScaffold({
119
+ targetDir: opts.dir,
120
+ projectName: opts.name,
121
+ });
122
+ console.log(chalk.green(`Generated project scaffold in ${opts.dir}`));
123
+ created.forEach((file) => console.log(chalk.dim(` - ${file}`)));
124
+ });
125
+ }
126
+ //# sourceMappingURL=structured-skills-commands.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"structured-skills-commands.js","sourceRoot":"","sources":["../src/structured-skills-commands.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAClF,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE3D,MAAM,UAAU,+BAA+B,CAAC,OAAgB;IAC9D,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,WAAW,CAAC,sCAAsC,CAAC,CAAC;IAE7F,MAAM;SACH,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CAAC,wBAAwB,CAAC;SACrC,MAAM,CAAC,sBAAsB,EAAE,OAAO,CAAC;SACvC,MAAM,CAAC,KAAK,EAAE,IAA2B,EAAE,EAAE;QAC5C,MAAM,MAAM,GAAG,IA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,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,kBAAkB,OAAO,OAAO,UAAU,EAAE,CAAC,CAAC,CAAC;IACzE,CAAC,CAAC,CAAC;IAEL,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,iCAAiC,CAAC,QAAiB;IACjE,QAAQ;SACL,OAAO,CAAC,SAAS,CAAC;SAClB,WAAW,CAAC,kBAAkB,CAAC;SAC/B,cAAc,CAAC,iBAAiB,EAAE,QAAQ,CAAC;SAC3C,MAAM,CAAC,mBAAmB,EAAE,MAAM,EAAE,YAAY,CAAC;SACjD,MAAM,CAAC,KAAK,EAAE,IAAmC,EAAE,EAAE;QACpD,MAAM,OAAO,GAAG,MAAM,qBAAqB,CAAC;YAC1C,SAAS,EAAE,IAAI,CAAC,GAAG;YACnB,WAAW,EAAE,IAAI,CAAC,IAAI;SACvB,CAAC,CAAC;QAEH,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,iCAAiC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QACtE,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IACnE,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare function registerStructuredTemplateCommand(program: Command): Command;
@@ -0,0 +1,34 @@
1
+ import chalk from 'chalk';
2
+ import { registerTemplateProjectSubcommand } from './structured-skills-commands.js';
3
+ export function registerStructuredTemplateCommand(program) {
4
+ const template = program.command('template').description('Generate structured templates');
5
+ template
6
+ .command('skill')
7
+ .description('Generate skill template')
8
+ .option('-n, --name <name>', '技能名称')
9
+ .action((opts) => {
10
+ const name = opts.name || 'my-new-skill';
11
+ const title = name.replace(/-/g, ' ').replace(/\b\w/g, (value) => value.toUpperCase());
12
+ console.log(chalk.green('Skill scaffold:'));
13
+ console.log(chalk.dim('─'.repeat(40)));
14
+ console.log(`---\nid: ${name}\ntitle: "${title}"\ncategory: other\ntags: []\ntriggers: []\ndependencies: []\n---\n\n# ${title}\n\nDescribe what this skill does and when to trigger it.\n`);
15
+ console.log(chalk.dim('─'.repeat(40)));
16
+ console.log(chalk.dim(`Save to: .claude/skills/${name}/SKILL.md`));
17
+ });
18
+ template
19
+ .command('rule')
20
+ .description('Generate rule template')
21
+ .option('-n, --name <name>', '规则名称')
22
+ .action((opts) => {
23
+ const name = opts.name || 'my-new-rule';
24
+ const title = name.replace(/-/g, ' ').replace(/\b\w/g, (value) => value.toUpperCase());
25
+ console.log(chalk.green('Rule scaffold:'));
26
+ console.log(chalk.dim('─'.repeat(40)));
27
+ console.log(`---\nid: ${name}\ntitle: "${title}"\ncategory: domain\ntags: []\n---\n\n# ${title}\n\nDescribe the rule and when it applies.\n`);
28
+ console.log(chalk.dim('─'.repeat(40)));
29
+ console.log(chalk.dim(`Save to: .claude/rules/domain/${name}.md`));
30
+ });
31
+ registerTemplateProjectSubcommand(template);
32
+ return template;
33
+ }
34
+ //# sourceMappingURL=structured-template-commands.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"structured-template-commands.js","sourceRoot":"","sources":["../src/structured-template-commands.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,iCAAiC,EAAE,MAAM,iCAAiC,CAAC;AAEpF,MAAM,UAAU,iCAAiC,CAAC,OAAgB;IAChE,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,WAAW,CAAC,+BAA+B,CAAC,CAAC;IAE1F,QAAQ;SACL,OAAO,CAAC,OAAO,CAAC;SAChB,WAAW,CAAC,yBAAyB,CAAC;SACtC,MAAM,CAAC,mBAAmB,EAAE,MAAM,CAAC;SACnC,MAAM,CAAC,CAAC,IAAuB,EAAE,EAAE;QACl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KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QACvC,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,aAAa,KAAK,2CAA2C,KAAK,8CAA8C,CAAC,CAAC;QAC9I,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QACvC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,iCAAiC,IAAI,KAAK,CAAC,CAAC,CAAC;IACrE,CAAC,CAAC,CAAC;IAEL,iCAAiC,CAAC,QAAQ,CAAC,CAAC;IAE5C,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { ChatCompletionTool } from 'openai/resources/index.js';
2
+ export declare const toolDefinitions: ChatCompletionTool[];
3
+ export declare function executeTool(name: string, args: Record<string, unknown>): string;
@@ -0,0 +1,450 @@
1
+ import { readFileSync, writeFileSync, existsSync, mkdirSync, statSync } from 'node:fs';
2
+ import { resolve, dirname } from 'node:path';
3
+ import { execSync } from 'node:child_process';
4
+ import { glob } from 'glob';
5
+ import { saveMemory, searchMemory } from '../memory.js';
6
+ import { plannerToolDefinitions, executePlannerTool, isPlannerTool } from '../planner.js';
7
+ import { webToolDefinitions, executeWebTool, isWebTool } from '../web.js';
8
+ // ─── Core Tool Definitions ───────────────────────────────────
9
+ const coreToolDefinitions = [
10
+ {
11
+ type: 'function',
12
+ function: {
13
+ name: 'read_file',
14
+ description: 'Read the contents of a file. Returns the file content as a string.',
15
+ parameters: {
16
+ type: 'object',
17
+ properties: {
18
+ path: { type: 'string', description: 'Path to the file (relative to CWD or absolute)' },
19
+ offset: { type: 'number', description: 'Line number to start reading from (1-indexed)' },
20
+ limit: { type: 'number', description: 'Max number of lines to read' },
21
+ },
22
+ required: ['path'],
23
+ },
24
+ },
25
+ },
26
+ {
27
+ type: 'function',
28
+ function: {
29
+ name: 'write_file',
30
+ description: 'Write content to a file. Creates parent directories if needed. Overwrites existing files.',
31
+ parameters: {
32
+ type: 'object',
33
+ properties: {
34
+ path: { type: 'string', description: 'Path to the file' },
35
+ content: { type: 'string', description: 'Content to write' },
36
+ },
37
+ required: ['path', 'content'],
38
+ },
39
+ },
40
+ },
41
+ {
42
+ type: 'function',
43
+ function: {
44
+ name: 'edit_file',
45
+ description: 'Replace exact text in a file. oldText must match exactly.',
46
+ parameters: {
47
+ type: 'object',
48
+ properties: {
49
+ path: { type: 'string', description: 'Path to the file' },
50
+ oldText: { type: 'string', description: 'Exact text to find' },
51
+ newText: { type: 'string', description: 'Replacement text' },
52
+ },
53
+ required: ['path', 'oldText', 'newText'],
54
+ },
55
+ },
56
+ },
57
+ {
58
+ type: 'function',
59
+ function: {
60
+ name: 'search_files',
61
+ description: 'Search for files matching a glob pattern, optionally grep for content.',
62
+ parameters: {
63
+ type: 'object',
64
+ properties: {
65
+ pattern: { type: 'string', description: 'Glob pattern (e.g. "src/**/*.ts")' },
66
+ grep: { type: 'string', description: 'Optional regex to search in file contents' },
67
+ maxResults: { type: 'number', description: 'Max results to return (default 20)' },
68
+ },
69
+ required: ['pattern'],
70
+ },
71
+ },
72
+ },
73
+ {
74
+ type: 'function',
75
+ function: {
76
+ name: 'list_directory',
77
+ description: 'List files and directories in a given path.',
78
+ parameters: {
79
+ type: 'object',
80
+ properties: {
81
+ path: { type: 'string', description: 'Directory path (default: CWD)' },
82
+ },
83
+ required: [],
84
+ },
85
+ },
86
+ },
87
+ {
88
+ type: 'function',
89
+ function: {
90
+ name: 'shell',
91
+ description: 'Execute a shell command. Returns stdout and stderr.',
92
+ parameters: {
93
+ type: 'object',
94
+ properties: {
95
+ command: { type: 'string', description: 'Shell command to execute' },
96
+ cwd: { type: 'string', description: 'Working directory (default: CWD)' },
97
+ timeout: { type: 'number', description: 'Timeout in seconds (default: 30)' },
98
+ },
99
+ required: ['command'],
100
+ },
101
+ },
102
+ },
103
+ // ─── Memory Tools ──────────────────────────────────────────
104
+ {
105
+ type: 'function',
106
+ function: {
107
+ name: 'save_memory',
108
+ description: 'Save important information to persistent memory. Categories: user (preferences), feedback (corrections), project (active tasks), reference (knowledge), experience (lessons learned).',
109
+ parameters: {
110
+ type: 'object',
111
+ properties: {
112
+ category: {
113
+ type: 'string',
114
+ enum: ['user', 'feedback', 'project', 'reference', 'experience'],
115
+ description: 'Memory category',
116
+ },
117
+ content: { type: 'string', description: 'What to remember' },
118
+ },
119
+ required: ['category', 'content'],
120
+ },
121
+ },
122
+ },
123
+ {
124
+ type: 'function',
125
+ function: {
126
+ name: 'search_memory',
127
+ description: 'Search persistent memory for relevant past information, preferences, or learnings.',
128
+ parameters: {
129
+ type: 'object',
130
+ properties: {
131
+ query: { type: 'string', description: 'Search query' },
132
+ },
133
+ required: ['query'],
134
+ },
135
+ },
136
+ },
137
+ // ─── Git Tools ─────────────────────────────────────────────
138
+ {
139
+ type: 'function',
140
+ function: {
141
+ name: 'git_status',
142
+ description: 'Get git status of the current repository.',
143
+ parameters: {
144
+ type: 'object',
145
+ properties: {
146
+ cwd: { type: 'string', description: 'Repository path (default: CWD)' },
147
+ },
148
+ required: [],
149
+ },
150
+ },
151
+ },
152
+ {
153
+ type: 'function',
154
+ function: {
155
+ name: 'git_diff',
156
+ description: 'Show git diff (staged, unstaged, or between refs).',
157
+ parameters: {
158
+ type: 'object',
159
+ properties: {
160
+ ref: { type: 'string', description: 'Git ref to diff against (e.g. HEAD~1, main)' },
161
+ staged: { type: 'boolean', description: 'Show staged changes only' },
162
+ cwd: { type: 'string', description: 'Repository path (default: CWD)' },
163
+ },
164
+ required: [],
165
+ },
166
+ },
167
+ },
168
+ {
169
+ type: 'function',
170
+ function: {
171
+ name: 'git_log',
172
+ description: 'Show recent git log entries.',
173
+ parameters: {
174
+ type: 'object',
175
+ properties: {
176
+ count: { type: 'number', description: 'Number of entries (default: 10)' },
177
+ oneline: { type: 'boolean', description: 'One-line format (default: true)' },
178
+ cwd: { type: 'string', description: 'Repository path (default: CWD)' },
179
+ },
180
+ required: [],
181
+ },
182
+ },
183
+ },
184
+ {
185
+ type: 'function',
186
+ function: {
187
+ name: 'git_commit',
188
+ description: 'Stage all changes and commit with a message. Use after making file edits.',
189
+ parameters: {
190
+ type: 'object',
191
+ properties: {
192
+ message: { type: 'string', description: 'Commit message' },
193
+ addAll: { type: 'boolean', description: 'Run git add -A before commit (default: true)' },
194
+ cwd: { type: 'string', description: 'Repository path (default: CWD)' },
195
+ },
196
+ required: ['message'],
197
+ },
198
+ },
199
+ },
200
+ {
201
+ type: 'function',
202
+ function: {
203
+ name: 'git_push',
204
+ description: 'Push commits to remote repository.',
205
+ parameters: {
206
+ type: 'object',
207
+ properties: {
208
+ remote: { type: 'string', description: 'Remote name (default: origin)' },
209
+ branch: { type: 'string', description: 'Branch name (default: current branch)' },
210
+ cwd: { type: 'string', description: 'Repository path (default: CWD)' },
211
+ },
212
+ required: [],
213
+ },
214
+ },
215
+ },
216
+ ];
217
+ // ─── Combined Tool Definitions ───────────────────────────────
218
+ export const toolDefinitions = [
219
+ ...coreToolDefinitions,
220
+ ...plannerToolDefinitions,
221
+ ...webToolDefinitions,
222
+ ];
223
+ // ─── Unified Tool Execution ──────────────────────────────────
224
+ export function executeTool(name, args) {
225
+ try {
226
+ // Check delegated tools first
227
+ if (isPlannerTool(name))
228
+ return executePlannerTool(name, args);
229
+ if (isWebTool(name))
230
+ return executeWebTool(name, args);
231
+ // Core tools
232
+ switch (name) {
233
+ case 'read_file': return readFile(args);
234
+ case 'write_file': return writeFile(args);
235
+ case 'edit_file': return editFile(args);
236
+ case 'search_files': return searchFiles(args);
237
+ case 'list_directory': return listDirectory(args);
238
+ case 'shell': return shellExec(args);
239
+ case 'save_memory': return saveMemoryTool(args);
240
+ case 'search_memory': return searchMemoryTool(args);
241
+ case 'git_status': return gitStatus(args);
242
+ case 'git_diff': return gitDiff(args);
243
+ case 'git_log': return gitLog(args);
244
+ case 'git_commit': return gitCommit(args);
245
+ case 'git_push': return gitPush(args);
246
+ default: return `Error: Unknown tool "${name}"`;
247
+ }
248
+ }
249
+ catch (e) {
250
+ return `Error: ${e instanceof Error ? e.message : String(e)}`;
251
+ }
252
+ }
253
+ // ─── Core Tool Implementations ───────────────────────────────
254
+ function resolvePath(p) {
255
+ return resolve(process.cwd(), p);
256
+ }
257
+ function readFile(args) {
258
+ const filePath = resolvePath(args.path);
259
+ if (!existsSync(filePath))
260
+ return `File not found: ${filePath}`;
261
+ const stat = statSync(filePath);
262
+ if (stat.isDirectory())
263
+ return `Path is a directory: ${filePath}`;
264
+ const content = readFileSync(filePath, 'utf-8');
265
+ const lines = content.split('\n');
266
+ const offset = (args.offset || 1) - 1;
267
+ const limit = args.limit || lines.length;
268
+ const slice = lines.slice(offset, offset + limit);
269
+ return slice.map((line, i) => `${offset + i + 1} | ${line}`).join('\n');
270
+ }
271
+ function writeFile(args) {
272
+ const filePath = resolvePath(args.path);
273
+ const dir = dirname(filePath);
274
+ if (!existsSync(dir))
275
+ mkdirSync(dir, { recursive: true });
276
+ writeFileSync(filePath, args.content);
277
+ return `Written ${args.content.length} bytes to ${filePath}`;
278
+ }
279
+ function editFile(args) {
280
+ const filePath = resolvePath(args.path);
281
+ if (!existsSync(filePath))
282
+ return `File not found: ${filePath}`;
283
+ const content = readFileSync(filePath, 'utf-8');
284
+ const oldText = args.oldText;
285
+ const newText = args.newText;
286
+ if (!content.includes(oldText)) {
287
+ return `oldText not found in file. Make sure it matches exactly (including whitespace).`;
288
+ }
289
+ const updated = content.replace(oldText, newText);
290
+ writeFileSync(filePath, updated);
291
+ return `Edited ${filePath}`;
292
+ }
293
+ function searchFiles(args) {
294
+ const pattern = args.pattern;
295
+ const grepPattern = args.grep;
296
+ const maxResults = args.maxResults || 20;
297
+ const files = glob.sync(pattern, { cwd: process.cwd(), nodir: true });
298
+ if (files.length === 0)
299
+ return `No files match pattern: ${pattern}`;
300
+ if (!grepPattern) {
301
+ return files.slice(0, maxResults).join('\n');
302
+ }
303
+ const regex = new RegExp(grepPattern, 'i');
304
+ const results = [];
305
+ for (const file of files) {
306
+ if (results.length >= maxResults)
307
+ break;
308
+ try {
309
+ const content = readFileSync(resolvePath(file), 'utf-8');
310
+ const lines = content.split('\n');
311
+ for (let i = 0; i < lines.length; i++) {
312
+ if (regex.test(lines[i])) {
313
+ results.push(`${file}:${i + 1}: ${lines[i].trim()}`);
314
+ if (results.length >= maxResults)
315
+ break;
316
+ }
317
+ }
318
+ }
319
+ catch { /* skip unreadable */ }
320
+ }
321
+ return results.length > 0 ? results.join('\n') : `No matches for "${grepPattern}" in ${files.length} files`;
322
+ }
323
+ function listDirectory(args) {
324
+ const dirPath = resolvePath(args.path || '.');
325
+ if (!existsSync(dirPath))
326
+ return `Directory not found: ${dirPath}`;
327
+ try {
328
+ const result = execSync(`ls -la "${dirPath}"`, { encoding: 'utf-8', timeout: 5000 });
329
+ return result.trim();
330
+ }
331
+ catch (e) {
332
+ return `Error listing directory: ${e instanceof Error ? e.message : String(e)}`;
333
+ }
334
+ }
335
+ function shellExec(args) {
336
+ const command = args.command;
337
+ const cwd = args.cwd ? resolvePath(args.cwd) : process.cwd();
338
+ const timeout = (args.timeout || 30) * 1000;
339
+ try {
340
+ const result = execSync(command, {
341
+ cwd,
342
+ encoding: 'utf-8',
343
+ timeout,
344
+ maxBuffer: 1024 * 1024,
345
+ stdio: ['pipe', 'pipe', 'pipe'],
346
+ });
347
+ return result.trim() || '(no output)';
348
+ }
349
+ catch (e) {
350
+ const err = e;
351
+ const stdout = err.stdout || '';
352
+ const stderr = err.stderr || '';
353
+ const code = err.status ?? 1;
354
+ return `Exit code: ${code}\n${stdout}\n${stderr}`.trim();
355
+ }
356
+ }
357
+ function saveMemoryTool(args) {
358
+ const now = new Date();
359
+ const timestamp = now.toISOString().split('T')[0] + ' ' + now.toTimeString().split(' ')[0];
360
+ return saveMemory({
361
+ category: args.category,
362
+ content: args.content,
363
+ timestamp,
364
+ });
365
+ }
366
+ function searchMemoryTool(args) {
367
+ return searchMemory(args.query);
368
+ }
369
+ // ─── Git Tool Implementations ────────────────────────────────
370
+ function gitStatus(args) {
371
+ const cwd = args.cwd ? resolvePath(args.cwd) : process.cwd();
372
+ try {
373
+ const status = execSync('git status --short', { cwd, encoding: 'utf-8', timeout: 5000 });
374
+ const branch = execSync('git branch --show-current', { cwd, encoding: 'utf-8', timeout: 5000 }).trim();
375
+ return `Branch: ${branch}\n${status.trim() || '(clean)'}`;
376
+ }
377
+ catch (e) {
378
+ return `Not a git repo or git error: ${e.message}`;
379
+ }
380
+ }
381
+ function gitDiff(args) {
382
+ const cwd = args.cwd ? resolvePath(args.cwd) : process.cwd();
383
+ const ref = args.ref;
384
+ const staged = args.staged;
385
+ let cmd = 'git diff';
386
+ if (staged)
387
+ cmd += ' --staged';
388
+ if (ref)
389
+ cmd += ` ${ref}`;
390
+ cmd += ' --stat';
391
+ try {
392
+ const stat = execSync(cmd, { cwd, encoding: 'utf-8', timeout: 10000 });
393
+ return stat.trim() || '(no changes)';
394
+ }
395
+ catch (e) {
396
+ return `Git diff error: ${e.message}`;
397
+ }
398
+ }
399
+ function gitLog(args) {
400
+ const cwd = args.cwd ? resolvePath(args.cwd) : process.cwd();
401
+ const count = args.count || 10;
402
+ const oneline = args.oneline !== false;
403
+ const format = oneline ? '--oneline' : '--format=%h %s (%ar) <%an>';
404
+ try {
405
+ const log = execSync(`git log ${format} -${count}`, { cwd, encoding: 'utf-8', timeout: 5000 });
406
+ return log.trim() || '(no commits)';
407
+ }
408
+ catch (e) {
409
+ return `Git log error: ${e.message}`;
410
+ }
411
+ }
412
+ function gitCommit(args) {
413
+ const cwd = args.cwd ? resolvePath(args.cwd) : process.cwd();
414
+ const message = args.message;
415
+ const addAll = args.addAll !== false;
416
+ try {
417
+ if (addAll) {
418
+ execSync('git add -A', { cwd, encoding: 'utf-8', timeout: 5000 });
419
+ }
420
+ const result = execSync(`git commit -m "${message.replace(/"/g, '\\"')}"`, {
421
+ cwd,
422
+ encoding: 'utf-8',
423
+ timeout: 10000,
424
+ });
425
+ return result.trim();
426
+ }
427
+ catch (e) {
428
+ const err = e;
429
+ return `Git commit error: ${err.stdout || err.stderr || e.message}`.trim();
430
+ }
431
+ }
432
+ function gitPush(args) {
433
+ const cwd = args.cwd ? resolvePath(args.cwd) : process.cwd();
434
+ const remote = args.remote || 'origin';
435
+ const branch = args.branch;
436
+ try {
437
+ const cmd = branch ? `git push ${remote} ${branch}` : `git push ${remote}`;
438
+ const result = execSync(cmd, { cwd, encoding: 'utf-8', timeout: 30000, stdio: ['pipe', 'pipe', 'pipe'] });
439
+ return result.trim() || 'Push successful';
440
+ }
441
+ catch (e) {
442
+ const err = e;
443
+ // git push outputs to stderr on success
444
+ const output = (err.stderr || '') + (err.stdout || '');
445
+ if (output.includes('->'))
446
+ return output.trim();
447
+ return `Git push error: ${output || e.message}`.trim();
448
+ }
449
+ }
450
+ //# sourceMappingURL=index.js.map