@overscore/cli 0.8.1 → 0.9.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.
Files changed (2) hide show
  1. package/dist/index.js +57 -0
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -287,6 +287,8 @@ async function deploy() {
287
287
  // Non-fatal
288
288
  }
289
289
  }
290
+ // Pull latest platform rules so the local project stays up to date
291
+ await syncPlatformRules(process.cwd(), baseUrl, apiKey);
290
292
  }
291
293
  async function queryList() {
292
294
  const { dashboardSlug } = loadEnv();
@@ -543,6 +545,26 @@ VITE_OVERSCORE_API_URL=https://overscore.dev/api
543
545
  catch {
544
546
  // Non-fatal — the version from the source zip is fine
545
547
  }
548
+ // Pull dashboard context from Hub (may be newer than the source zip)
549
+ try {
550
+ const dashCtxRes = await fetch(`${baseUrl}/api/dashboards/${dashboardSlug}/context`, {
551
+ headers: { Authorization: `Bearer ${apiKey}` },
552
+ });
553
+ if (dashCtxRes.ok) {
554
+ const dashCtxData = (await dashCtxRes.json());
555
+ if (dashCtxData.context_md) {
556
+ const rulesDir = path.join(targetDir, ".claude", "rules");
557
+ fs.mkdirSync(rulesDir, { recursive: true });
558
+ fs.writeFileSync(path.join(rulesDir, "dashboard-context.md"), dashCtxData.context_md);
559
+ console.log(" Updated dashboard context from Hub.");
560
+ }
561
+ }
562
+ }
563
+ catch {
564
+ // Non-fatal
565
+ }
566
+ // Pull latest platform rules
567
+ await syncPlatformRules(targetDir, baseUrl, apiKey);
546
568
  console.log(`
547
569
  Pulled v${version}${commitMsg ? ` — "${commitMsg}"` : ""}
548
570
 
@@ -754,6 +776,41 @@ async function syncHubManagedRules(targetDir, baseUrl, projectSlug, apiKey) {
754
776
  // Non-fatal
755
777
  }
756
778
  }
779
+ /**
780
+ * Fetch the latest platform-owned Claude Code rules from the Hub and write
781
+ * them into the project's .claude/ directory. This keeps rules like
782
+ * data-fetching.md, query-performance.md, and skills up to date even in
783
+ * projects that were scaffolded months ago.
784
+ *
785
+ * Called from `deploy` (before uploading) and `pull` (after extracting).
786
+ * User-owned files (company-context.md, dashboard-context.md) are NOT
787
+ * touched — those sync via separate mechanisms.
788
+ */
789
+ async function syncPlatformRules(targetDir, baseUrl, apiKey) {
790
+ try {
791
+ const res = await fetch(`${baseUrl}/api/platform-rules`, {
792
+ headers: { Authorization: `Bearer ${apiKey}` },
793
+ });
794
+ if (!res.ok)
795
+ return;
796
+ const data = (await res.json());
797
+ if (!data.files)
798
+ return;
799
+ let count = 0;
800
+ for (const [relPath, content] of Object.entries(data.files)) {
801
+ const fullPath = path.join(targetDir, ".claude", relPath);
802
+ fs.mkdirSync(path.dirname(fullPath), { recursive: true });
803
+ fs.writeFileSync(fullPath, content);
804
+ count++;
805
+ }
806
+ if (count > 0) {
807
+ console.log(` Platform rules synced (${count} files).`);
808
+ }
809
+ }
810
+ catch {
811
+ // Non-fatal — existing rules stay in place
812
+ }
813
+ }
757
814
  /**
758
815
  * Recursively copies a template directory to a target directory, substituting
759
816
  * `{{KEY}}` placeholders in text files. Mirrors directory structure.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@overscore/cli",
3
- "version": "0.8.1",
3
+ "version": "0.9.0",
4
4
  "description": "CLI for deploying Overscore dashboards and publishing analyses",
5
5
  "bin": {
6
6
  "overscore": "dist/index.js"