learn-anything-cli 0.4.0-beta.1 → 0.4.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.
package/README.md CHANGED
@@ -23,6 +23,12 @@ npm install -g learn-anything-cli
23
23
  learn-anything init
24
24
  ```
25
25
 
26
+ ### Context7 Integration (Optional)
27
+
28
+ When running `init` or `update`, you'll be prompted to enable **Context7** for documentation verification. When enabled, the AI will fetch official documentation and verify its explanations against authoritative sources — improving teaching accuracy.
29
+
30
+ If you haven't set up Context7 yet, run `npx ctx7 setup` or visit the [Context7 docs](https://context7.com/docs/resources/all-clients) for your specific AI tool.
31
+
26
32
  After init, your AI assistant gains five learning commands:
27
33
 
28
34
  | Command | What it does |
package/README.zh-CN.md CHANGED
@@ -21,6 +21,12 @@ npm install -g learn-anything-cli
21
21
  learn-anything init
22
22
  ```
23
23
 
24
+ ### Context7 集成(可选)
25
+
26
+ 在执行 `init` 或 `update` 时,会提示是否启用 **Context7** 文档验证。启用后,AI 会获取官方文档并对照权威来源验证其教学内容——提高教学准确性。
27
+
28
+ 如果你还没有配置 Context7,运行 `npx ctx7 setup` 或访问 [Context7 文档](https://context7.com/docs/resources/all-clients) 查看你使用的 AI 工具的配置方式。
29
+
24
30
  初始化后,你的 AI 助手获得五个学习命令:
25
31
 
26
32
  | 命令 | 功能 |
package/dist/cli/index.js CHANGED
@@ -24,6 +24,8 @@ program
24
24
  .option('--tools <tools>', m.cli.toolsOptionDescription(availableToolIds.join(', ')))
25
25
  .option('--force', m.cli.forceOption)
26
26
  .option('--lang <locale>', m.cli.langOption)
27
+ .option('--context7', 'Enable Context7 documentation verification')
28
+ .option('--no-context7', 'Disable Context7 documentation verification')
27
29
  .action(async (targetPath = '.', options) => {
28
30
  const cliLocale = resolveLocale(options?.lang);
29
31
  const mc = cliLocale !== earlyLocale ? getMessages(cliLocale).cli : m.cli;
@@ -51,6 +53,7 @@ program
51
53
  tools: options?.tools,
52
54
  force: options?.force,
53
55
  locale: cliLocale,
56
+ context7: options?.context7,
54
57
  });
55
58
  await initCommand.execute(targetPath);
56
59
  }
@@ -4,14 +4,18 @@ type InitCommandOptions = {
4
4
  force?: boolean;
5
5
  locale?: SupportedLocale;
6
6
  update?: boolean;
7
+ context7?: boolean;
7
8
  };
8
9
  export declare class InitCommand {
9
10
  private readonly toolsArg?;
10
11
  private readonly force;
11
12
  private readonly locale;
12
13
  private readonly isUpdate;
14
+ private readonly context7Arg?;
15
+ private context7Enabled;
13
16
  constructor(options?: InitCommandOptions);
14
17
  execute(targetPath?: string): Promise<void>;
18
+ private promptContext7;
15
19
  private detectTools;
16
20
  private hasToolDir;
17
21
  private interactiveSelect;
package/dist/core/init.js CHANGED
@@ -9,6 +9,7 @@ import { isInteractive } from '../utils/interactive.js';
9
9
  import { generateCommands, CommandAdapterRegistry } from './command-generation/index.js';
10
10
  import { getSkillTemplates, getCommandContents, generateSkillContent } from './shared/index.js';
11
11
  import { getMessages } from '../i18n/index.js';
12
+ import { CONTEXT7_GUIDANCE } from './templates/context7-guidance.js';
12
13
  const require = createRequire(import.meta.url);
13
14
  const { version: VERSION } = require('../../package.json');
14
15
  export class InitCommand {
@@ -16,11 +17,14 @@ export class InitCommand {
16
17
  force;
17
18
  locale;
18
19
  isUpdate;
20
+ context7Arg;
21
+ context7Enabled = false;
19
22
  constructor(options = {}) {
20
23
  this.toolsArg = options.tools;
21
24
  this.force = options.force ?? false;
22
25
  this.locale = options.locale ?? 'en';
23
26
  this.isUpdate = options.update ?? false;
27
+ this.context7Arg = options.context7;
24
28
  }
25
29
  async execute(targetPath = '.') {
26
30
  const resolvedPath = path.resolve(targetPath);
@@ -67,6 +71,12 @@ export class InitCommand {
67
71
  .join(', '))));
68
72
  return;
69
73
  }
74
+ // Context7 setup
75
+ this.context7Enabled = await this.promptContext7();
76
+ if (this.context7Enabled) {
77
+ console.log(chalk.dim(m.init.context7Enabled));
78
+ }
79
+ console.log('');
70
80
  // Generate skill files for each tool
71
81
  for (const tool of selectedTools) {
72
82
  if (!tool.skillsDir)
@@ -87,6 +97,21 @@ export class InitCommand {
87
97
  console.log(cmd(chalk.cyan('/learn:review [topic-name]'), chalk.dim(' — Review progress, spaced repetition recommendations')));
88
98
  console.log(cmd(chalk.cyan('/learn:status [topic-name]'), chalk.dim(' — Visualize learning state as knowledge map heatmap')));
89
99
  console.log('');
100
+ if (this.context7Enabled) {
101
+ console.log(chalk.dim(m.init.context7SetupHint));
102
+ console.log('');
103
+ }
104
+ }
105
+ async promptContext7() {
106
+ const m = getMessages(this.locale);
107
+ if (this.context7Arg === true)
108
+ return true;
109
+ if (this.context7Arg === false)
110
+ return false;
111
+ if (!isInteractive())
112
+ return true;
113
+ const { confirm } = await import('@inquirer/prompts');
114
+ return confirm({ message: m.init.context7Prompt, default: true });
90
115
  }
91
116
  async detectTools(_resolvedPath) {
92
117
  return AI_TOOLS;
@@ -125,7 +150,9 @@ export class InitCommand {
125
150
  for (const entry of skillTemplates) {
126
151
  const skillDir = path.join(resolvedPath, tool.skillsDir, 'skills', entry.dirName);
127
152
  const skillFile = path.join(skillDir, 'SKILL.md');
128
- const content = generateSkillContent(entry.template, VERSION);
153
+ const content = generateSkillContent(entry.template, VERSION, this.context7Enabled && isDocVerificationTemplate(entry.workflowId)
154
+ ? injectContext7Guidance
155
+ : undefined);
129
156
  await FileSystemUtils.writeFile(skillFile, content);
130
157
  const scriptsDir = path.join(skillDir, 'scripts');
131
158
  // topic / explain / practice → utils.mjs + render.mjs
@@ -160,4 +187,15 @@ export class InitCommand {
160
187
  }
161
188
  }
162
189
  }
190
+ const DOC_VERIFICATION_WORKFLOWS = new Set(['topic', 'explain', 'practice']);
191
+ function isDocVerificationTemplate(workflowId) {
192
+ return DOC_VERIFICATION_WORKFLOWS.has(workflowId);
193
+ }
194
+ function injectContext7Guidance(instructions) {
195
+ const marker = '\n## Command:';
196
+ const index = instructions.indexOf(marker);
197
+ if (index === -1)
198
+ return instructions + CONTEXT7_GUIDANCE;
199
+ return instructions.slice(0, index) + CONTEXT7_GUIDANCE + instructions.slice(index);
200
+ }
163
201
  //# sourceMappingURL=init.js.map
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Context7 documentation verification guidance.
3
+ * Injected into topic/explain/practice skill templates when Context7 is enabled.
4
+ *
5
+ * Instructs the AI to use Context7 MCP tools at runtime:
6
+ * - resolve-library-id: resolves library name to Context7 ID
7
+ * - query-docs: fetches docs by library ID + query
8
+ *
9
+ * NOT injected into review/status templates (those are about progress review
10
+ * and visualization, not teaching content).
11
+ */
12
+ export declare const CONTEXT7_GUIDANCE = "\n## Documentation Verification (Context7)\n\nWhen teaching about a specific library or framework, verify your explanations against official documentation using Context7 MCP tools:\n\n1. **Resolve the library**: Call `resolve-library-id` with the library name (e.g., \"React\", \"TypeScript\")\n2. **Fetch relevant docs**: Call `query-docs` with the resolved library ID and the concept you are teaching as the query\n3. **Cross-reference**: Ensure your explanations, code examples, and API usage match the official documentation\n4. **Defer to docs**: If your explanation conflicts with official documentation, use the official documentation as the authoritative source\n\nIf Context7 MCP tools are not available in your environment, proceed with your built-in knowledge.\n";
13
+ //# sourceMappingURL=context7-guidance.d.ts.map
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Context7 documentation verification guidance.
3
+ * Injected into topic/explain/practice skill templates when Context7 is enabled.
4
+ *
5
+ * Instructs the AI to use Context7 MCP tools at runtime:
6
+ * - resolve-library-id: resolves library name to Context7 ID
7
+ * - query-docs: fetches docs by library ID + query
8
+ *
9
+ * NOT injected into review/status templates (those are about progress review
10
+ * and visualization, not teaching content).
11
+ */
12
+ export const CONTEXT7_GUIDANCE = `
13
+ ## Documentation Verification (Context7)
14
+
15
+ When teaching about a specific library or framework, verify your explanations against official documentation using Context7 MCP tools:
16
+
17
+ 1. **Resolve the library**: Call \`resolve-library-id\` with the library name (e.g., "React", "TypeScript")
18
+ 2. **Fetch relevant docs**: Call \`query-docs\` with the resolved library ID and the concept you are teaching as the query
19
+ 3. **Cross-reference**: Ensure your explanations, code examples, and API usage match the official documentation
20
+ 4. **Defer to docs**: If your explanation conflicts with official documentation, use the official documentation as the authoritative source
21
+
22
+ If Context7 MCP tools are not available in your environment, proceed with your built-in knowledge.
23
+ `;
24
+ //# sourceMappingURL=context7-guidance.js.map
@@ -24,6 +24,9 @@ export const en = {
24
24
  cmdLine: (cmd, desc) => ` ${cmd}${desc}`,
25
25
  interactiveSelectPrompt: 'Select AI tools to generate skills for (space to select, enter to confirm):',
26
26
  migrationComplete: (count) => `Migrated ${count} topic(s) from v0 to v1 format (backups created).`,
27
+ context7Prompt: 'Enable Context7 for documentation verification? (Provides on-demand access to official library docs)',
28
+ context7Enabled: ' 📚 Context7 guidance enabled.',
29
+ context7SetupHint: ' 💡 To set up Context7 MCP, run `npx ctx7 setup` or visit https://context7.com/docs/resources/all-clients',
27
30
  },
28
31
  };
29
32
  //# sourceMappingURL=en.js.map
@@ -24,6 +24,9 @@ export const zhCN = {
24
24
  cmdLine: (cmd, desc) => ` ${cmd}${desc}`,
25
25
  interactiveSelectPrompt: '选择要生成技能的 AI 工具(空格选择,回车确认):',
26
26
  migrationComplete: (count) => `已迁移 ${count} 个主题从 v0 到 v1 格式(已创建备份)。`,
27
+ context7Prompt: '是否启用 Context7 进行文档验证?(提供按需访问官方库文档的能力)',
28
+ context7Enabled: ' 📚 已启用 Context7 文档验证引导。',
29
+ context7SetupHint: ' 💡 配置 Context7 MCP:运行 `npx ctx7 setup` 或访问 https://context7.com/docs/resources/all-clients',
27
30
  },
28
31
  };
29
32
  //# sourceMappingURL=zh-CN.js.map
@@ -24,6 +24,9 @@ export interface InitMessages {
24
24
  cmdLine: (cmd: string, desc: string) => string;
25
25
  interactiveSelectPrompt: string;
26
26
  migrationComplete: (count: number) => string;
27
+ context7Prompt: string;
28
+ context7Enabled: string;
29
+ context7SetupHint: string;
27
30
  }
28
31
  export interface LocaleMessages {
29
32
  cli: CLIMessages;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "learn-anything-cli",
3
- "version": "0.4.0-beta.1",
3
+ "version": "0.4.0",
4
4
  "description": "AI-powered recursive learning system with Socratic method and TDD practice",
5
5
  "keywords": [
6
6
  "learn-anything-cli",