connectbase-client 0.10.1 → 0.10.2

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 (2) hide show
  1. package/dist/cli.js +90 -3
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -608,12 +608,56 @@ function getGitRoot() {
608
608
  return null;
609
609
  }
610
610
  }
611
+ function detectMonorepo(gitRoot) {
612
+ const cwd = process.cwd();
613
+ const result = { type: "none", root: gitRoot, isSubPackage: false };
614
+ if (fs.existsSync(path.join(gitRoot, "pnpm-workspace.yaml"))) {
615
+ result.type = "pnpm";
616
+ } else if (fs.existsSync(path.join(gitRoot, "turbo.json"))) {
617
+ result.type = "turborepo";
618
+ } else if (fs.existsSync(path.join(gitRoot, "nx.json"))) {
619
+ result.type = "nx";
620
+ } else if (fs.existsSync(path.join(gitRoot, "lerna.json"))) {
621
+ result.type = "lerna";
622
+ } else {
623
+ const rootPkgPath = path.join(gitRoot, "package.json");
624
+ if (fs.existsSync(rootPkgPath)) {
625
+ try {
626
+ const pkg = JSON.parse(fs.readFileSync(rootPkgPath, "utf-8"));
627
+ if (pkg.workspaces) {
628
+ result.type = fs.existsSync(path.join(gitRoot, "yarn.lock")) ? "yarn" : "npm";
629
+ }
630
+ } catch {
631
+ }
632
+ }
633
+ }
634
+ if (result.type !== "none" && cwd !== gitRoot) {
635
+ const cwdPkgPath = path.join(cwd, "package.json");
636
+ if (fs.existsSync(cwdPkgPath)) {
637
+ result.isSubPackage = true;
638
+ try {
639
+ const pkg = JSON.parse(fs.readFileSync(cwdPkgPath, "utf-8"));
640
+ result.subPackageName = pkg.name;
641
+ } catch {
642
+ }
643
+ }
644
+ }
645
+ return result;
646
+ }
611
647
  async function downloadDocs(apiKey, templates, baseDir) {
612
648
  if (!baseDir) {
613
649
  baseDir = getProjectRoot();
614
650
  }
615
- const docsDir = path.join(baseDir, ".claude", "docs");
616
- const rootClaudeMd = path.join(baseDir, "CLAUDE.md");
651
+ const gitRoot = getGitRoot() || baseDir;
652
+ const monorepo = detectMonorepo(gitRoot);
653
+ if (monorepo.type !== "none") {
654
+ info(`\uBAA8\uB178\uB808\uD3EC \uAC10\uC9C0: ${monorepo.type} (\uB8E8\uD2B8: ${gitRoot})`);
655
+ if (monorepo.isSubPackage) {
656
+ info(`\uD604\uC7AC \uC11C\uBE0C \uD328\uD0A4\uC9C0: ${monorepo.subPackageName || path.basename(process.cwd())}`);
657
+ }
658
+ }
659
+ const docsDir = path.join(gitRoot, ".claude", "docs");
660
+ const rootClaudeMd = path.join(gitRoot, "CLAUDE.md");
617
661
  if (!fs.existsSync(docsDir)) {
618
662
  fs.mkdirSync(docsDir, { recursive: true });
619
663
  }
@@ -637,8 +681,12 @@ async function downloadDocs(apiKey, templates, baseDir) {
637
681
  const filePath = path.join(docsDir, section.filename);
638
682
  fs.writeFileSync(filePath, section.content);
639
683
  }
640
- success(`.claude/docs/ \uC5D0 ${sections.length}\uAC1C \uBB38\uC11C \uC800\uC7A5 \uC644\uB8CC`);
684
+ success(`${gitRoot}/.claude/docs/ \uC5D0 ${sections.length}\uAC1C \uBB38\uC11C \uC800\uC7A5 \uC644\uB8CC`);
641
685
  updateRootClaudeMd(rootClaudeMd);
686
+ if (monorepo.isSubPackage) {
687
+ const subClaudeMd = path.join(process.cwd(), "CLAUDE.md");
688
+ createSubPackageClaudeMd(subClaudeMd, gitRoot);
689
+ }
642
690
  log(`${colors.dim}\u203B SDK \uBB38\uC11C\uB294 MCP search_sdk_docs\uB85C \uAC80\uC0C9\uD558\uC138\uC694${colors.reset}`);
643
691
  } catch {
644
692
  warn("SDK \uAC00\uC774\uB4DC \uB2E4\uC6B4\uB85C\uB4DC \uC2E4\uD328, \uAE30\uBCF8 \uBB38\uC11C\uB97C \uC0DD\uC131\uD569\uB2C8\uB2E4");
@@ -650,6 +698,10 @@ async function downloadDocs(apiKey, templates, baseDir) {
650
698
  `;
651
699
  fs.writeFileSync(path.join(docsDir, "project-rules.md"), fallbackContent);
652
700
  updateRootClaudeMd(rootClaudeMd);
701
+ if (monorepo.isSubPackage) {
702
+ const subClaudeMd = path.join(process.cwd(), "CLAUDE.md");
703
+ createSubPackageClaudeMd(subClaudeMd, gitRoot);
704
+ }
653
705
  success(`.claude/docs/ \uC0DD\uC131 \uC644\uB8CC (\uAE30\uBCF8)`);
654
706
  }
655
707
  }
@@ -695,6 +747,41 @@ ${sdkBlock}
695
747
  success("CLAUDE.md \uC0DD\uC131 \uC644\uB8CC");
696
748
  }
697
749
  }
750
+ function createSubPackageClaudeMd(subClaudeMdPath, gitRoot) {
751
+ const startMarker = "<!-- CONNECTBASE_SUB_START -->";
752
+ const endMarker = "<!-- CONNECTBASE_SUB_END -->";
753
+ const relPath = path.relative(path.dirname(subClaudeMdPath), gitRoot);
754
+ const subBlock = `${startMarker}
755
+ ## ConnectBase SDK
756
+
757
+ \uC774 \uD328\uD0A4\uC9C0\uB294 **ConnectBase**\uB97C \uBC31\uC5D4\uB4DC\uB85C \uC0AC\uC6A9\uD569\uB2C8\uB2E4.
758
+
759
+ ### AI \uD544\uB3C5
760
+
761
+ 1. \uD504\uB85C\uC81D\uD2B8 \uB8E8\uD2B8\uC758 \`${relPath}/.claude/docs/project-rules.md\`\uB97C **Read tool\uB85C \uC77D\uC73C\uC138\uC694**
762
+ 2. \`search_sdk_docs("\uD0A4\uC6CC\uB4DC")\`\uB85C SDK \uAD6C\uD604 \uBC29\uBC95\uC744 \uAC80\uC0C9\uD558\uC138\uC694
763
+ 3. \uD504\uB85C\uC81D\uD2B8 \uB8E8\uD2B8\uC758 \`${relPath}/CLAUDE.md\`\uB3C4 \uCC38\uACE0\uD558\uC138\uC694
764
+ ${endMarker}`;
765
+ if (fs.existsSync(subClaudeMdPath)) {
766
+ let content = fs.readFileSync(subClaudeMdPath, "utf-8");
767
+ const startIdx = content.indexOf(startMarker);
768
+ const endIdx = content.indexOf(endMarker);
769
+ if (startIdx !== -1 && endIdx !== -1) {
770
+ content = content.substring(0, startIdx) + subBlock + content.substring(endIdx + endMarker.length);
771
+ } else if (content.indexOf("<!-- CONNECTBASE_START -->") === -1) {
772
+ content = content.trimEnd() + "\n\n" + subBlock + "\n";
773
+ } else {
774
+ return;
775
+ }
776
+ fs.writeFileSync(subClaudeMdPath, content);
777
+ } else {
778
+ fs.writeFileSync(subClaudeMdPath, `# ${path.basename(path.dirname(subClaudeMdPath))}
779
+
780
+ ${subBlock}
781
+ `);
782
+ }
783
+ success(`\uC11C\uBE0C \uD328\uD0A4\uC9C0 CLAUDE.md \uC0DD\uC131 \uC644\uB8CC: ${subClaudeMdPath}`);
784
+ }
698
785
  async function setupClaudeCode(apiKey, secretKey, projectRoot) {
699
786
  const root = projectRoot || getProjectRoot();
700
787
  const mcpConfigPath = path.join(root, ".mcp.json");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "connectbase-client",
3
- "version": "0.10.1",
3
+ "version": "0.10.2",
4
4
  "description": "Connect Base JavaScript/TypeScript SDK for browser and Node.js",
5
5
  "repository": {
6
6
  "type": "git",