ctx7 0.4.0 → 0.4.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.
package/dist/index.js CHANGED
@@ -453,11 +453,9 @@ async function getLibraryContext(libraryId, query, options, accessToken) {
453
453
  if (options?.type) {
454
454
  params.set("type", options.type);
455
455
  }
456
- if (options?.researchMode) {
457
- params.set("researchMode", "true");
458
- }
456
+ const headers = getAuthHeaders(accessToken);
459
457
  const response = await fetch(`${baseUrl}/api/v2/context?${params}`, {
460
- headers: getAuthHeaders(accessToken)
458
+ headers
461
459
  });
462
460
  if (!response.ok) {
463
461
  const errorData = await response.json().catch(() => ({}));
@@ -2783,8 +2781,7 @@ Do not use for: refactoring, writing scripts from scratch, debugging business lo
2783
2781
  1. \`resolve-library-id\` with the library name and the user's question. Use the official library name with proper punctuation (e.g., "Next.js" not "nextjs", "Customer.io" not "customerio", "Three.js" not "threejs")
2784
2782
  2. Pick the best match by: exact name match, description relevance, code snippet count, source reputation (High/Medium preferred), and benchmark score (higher is better). Use version-specific IDs when the user mentions a version
2785
2783
  3. \`query-docs\` with the selected library ID and the user's full question (not single words)
2786
- 4. If you weren't satisfied with the answer, call \`query-docs\` again for the same library with \`researchMode: true\`. This retries with sandboxed agents that git-pull the actual source repos plus a live web search, then synthesizes a fresh answer. More costly than the default
2787
- 5. Answer using the fetched docs
2784
+ 4. Answer using the fetched docs
2788
2785
  `;
2789
2786
  var FALLBACK_CLI = `Use the \`ctx7\` CLI to fetch current documentation whenever the user asks about a library, framework, SDK, API, CLI tool, or cloud service -- even well-known ones like React, Next.js, Prisma, Express, Tailwind, Django, or Spring Boot. This includes API syntax, configuration, version migration, library-specific debugging, setup instructions, and CLI tool usage. Use even when you think you know the answer -- your training data may not reflect recent changes. Prefer this over web search for library docs.
2790
2787
 
@@ -2795,8 +2792,7 @@ Do not use for: refactoring, writing scripts from scratch, debugging business lo
2795
2792
  1. Resolve library: \`npx ctx7@latest library <name> "<user's question>"\`
2796
2793
  2. Pick the best match by: exact name match, description relevance, code snippet count, source reputation (High/Medium preferred), and benchmark score (higher is better). If results don't look right, try the full name with punctuation (e.g., "next.js" not "nextjs")
2797
2794
  3. Fetch docs: \`npx ctx7@latest docs <libraryId> "<user's question>"\`
2798
- 4. If you weren't satisfied with the answer, re-run the same command with \`--research\`. This retries with sandboxed agents that git-pull the actual source repos plus a live web search, then synthesizes a fresh answer. More costly than the default
2799
- 5. Answer using the fetched documentation
2795
+ 4. Answer using the fetched documentation
2800
2796
 
2801
2797
  You MUST call \`library\` first to get a valid ID (format: \`/org/project\`) unless the user provides one directly. Use the user's full question as the query -- specific and detailed queries return better results than vague single words. Do not run more than 3 commands per question. Do not include sensitive information (API keys, passwords, credentials) in queries.
2802
2798
 
@@ -3806,19 +3802,12 @@ async function queryCommand(libraryId, query, options) {
3806
3802
  process.exitCode = 1;
3807
3803
  return;
3808
3804
  }
3809
- const spinner = isTTY ? ora6(
3810
- options.research ? `Researching "${libraryId}"...` : `Fetching docs for "${libraryId}"...`
3811
- ).start() : null;
3812
3805
  const accessToken = getAccessToken();
3806
+ const spinner = isTTY ? ora6(`Fetching docs for "${libraryId}"...`).start() : null;
3813
3807
  const outputType = options.json ? "json" : "txt";
3814
3808
  let result;
3815
3809
  try {
3816
- result = await getLibraryContext(
3817
- libraryId,
3818
- query,
3819
- { type: outputType, researchMode: options.research },
3820
- accessToken
3821
- );
3810
+ result = await getLibraryContext(libraryId, query, { type: outputType }, accessToken);
3822
3811
  } catch (err) {
3823
3812
  spinner?.fail(`Error: ${err instanceof Error ? err.message : String(err)}`);
3824
3813
  if (!spinner) log.error(err instanceof Error ? err.message : String(err));
@@ -3882,14 +3871,9 @@ function registerDocsCommands(program2) {
3882
3871
  program2.command("library").argument("<name>", "Library name to search for").argument("[query]", "Question or task for relevance ranking").option("--json", "Output as JSON").description("Resolve a library name to a Context7 library ID").action(async (name, query, options) => {
3883
3872
  await resolveCommand(name, query, options);
3884
3873
  });
3885
- program2.command("docs").argument("<libraryId>", "Context7 library ID (e.g., /facebook/react)").argument("<query>", "Question or task to get docs for").option("--json", "Output as JSON").option(
3886
- "--research",
3887
- "Retry the query with deep research: spins up sandboxed agents that read the actual source repos (git pull + inspect) and runs a live web search, then synthesizes a fresh answer. Use on retry if you weren't satisfied with the first answer. More costly than the default."
3888
- ).description("Query documentation for a library").action(
3889
- async (libraryId, query, options) => {
3890
- await queryCommand(libraryId, query, options);
3891
- }
3892
- );
3874
+ program2.command("docs").argument("<libraryId>", "Context7 library ID (e.g., /facebook/react)").argument("<query>", "Question or task to get docs for").option("--json", "Output as JSON").description("Query documentation for a library").action(async (libraryId, query, options) => {
3875
+ await queryCommand(libraryId, query, options);
3876
+ });
3893
3877
  }
3894
3878
 
3895
3879
  // src/commands/upgrade.ts