ctx7 0.3.11 → 0.3.13

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
@@ -844,7 +844,7 @@ async function installSkillFiles(skillName, files, targetDir) {
844
844
  const skillDir = resolve(targetDir, skillName);
845
845
  for (const file of files) {
846
846
  const filePath = resolve(skillDir, file.path);
847
- if (!filePath.startsWith(skillDir + "/") && filePath !== skillDir) {
847
+ if (!filePath.startsWith(skillDir + "/") && !filePath.startsWith(skillDir + "\\") && filePath !== skillDir) {
848
848
  throw new Error(`Skill file path "${file.path}" resolves outside the target directory`);
849
849
  }
850
850
  const fileDir = dirname3(filePath);
@@ -2785,6 +2785,7 @@ alwaysApply: true
2785
2785
  ---
2786
2786
 
2787
2787
  `;
2788
+ var CODEX_CLI_SANDBOX_GUIDANCE = `Run Context7 CLI requests outside Codex's default sandbox. If a Context7 CLI command fails with DNS or network errors such as ENOTFOUND, host resolution failures, or fetch failed, rerun it outside the sandbox instead of retrying inside the sandbox.`;
2788
2789
  async function fetchRule(filename, fallback) {
2789
2790
  for (const base of GITHUB_RAW_URLS) {
2790
2791
  try {
@@ -2798,9 +2799,40 @@ async function fetchRule(filename, fallback) {
2798
2799
  }
2799
2800
  async function getRuleContent(mode, agent) {
2800
2801
  const [filename, fallback] = mode === "mcp" ? ["context7-mcp.md", FALLBACK_MCP] : ["context7-cli.md", FALLBACK_CLI];
2801
- const body = await fetchRule(filename, fallback);
2802
+ let body = await fetchRule(filename, fallback);
2803
+ if (mode === "cli" && agent === "codex" && !body.includes(CODEX_CLI_SANDBOX_GUIDANCE)) {
2804
+ body = `${body.trimEnd()}
2805
+ ${CODEX_CLI_SANDBOX_GUIDANCE}
2806
+ `;
2807
+ }
2802
2808
  return agent === "cursor" ? `${CURSOR_FRONTMATTER}${body}` : body;
2803
2809
  }
2810
+ function customizeSkillFilesForAgent(agent, skillName, files) {
2811
+ if (agent !== "codex" || skillName !== "find-docs") {
2812
+ return files;
2813
+ }
2814
+ return files.map((file) => {
2815
+ if (file.path !== "SKILL.md" || file.content.includes(CODEX_CLI_SANDBOX_GUIDANCE)) {
2816
+ return file;
2817
+ }
2818
+ const marker = "## Step 1: Resolve a Library";
2819
+ const guidance = `${CODEX_CLI_SANDBOX_GUIDANCE}
2820
+
2821
+ `;
2822
+ if (file.content.includes(marker)) {
2823
+ return {
2824
+ ...file,
2825
+ content: file.content.replace(marker, `${guidance}${marker}`)
2826
+ };
2827
+ }
2828
+ const separator = file.content.endsWith("\n") ? "\n" : "\n\n";
2829
+ return {
2830
+ ...file,
2831
+ content: `${file.content}${separator}${CODEX_CLI_SANDBOX_GUIDANCE}
2832
+ `
2833
+ };
2834
+ });
2835
+ }
2804
2836
 
2805
2837
  // src/setup/mcp-writer.ts
2806
2838
  import { access as access3, readFile as readFile3, writeFile as writeFile3, mkdir as mkdir3 } from "fs/promises";
@@ -3184,7 +3216,8 @@ async function setupCliAgent(agentName, scope, downloadData) {
3184
3216
  const skillDir = scope === "global" ? agent.skill.dir("global") : join9(process.cwd(), agent.skill.dir("project"));
3185
3217
  let skillStatus;
3186
3218
  try {
3187
- await installSkillFiles("find-docs", downloadData.files, skillDir);
3219
+ const files = customizeSkillFilesForAgent(agentName, "find-docs", downloadData.files);
3220
+ await installSkillFiles("find-docs", files, skillDir);
3188
3221
  skillStatus = "installed";
3189
3222
  } catch (err) {
3190
3223
  skillStatus = `failed: ${err instanceof Error ? err.message : String(err)}`;