cortex-sync 0.4.11 → 0.4.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/cli.js +27 -9
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -321,7 +321,8 @@ var GitHubBackend = class {
|
|
|
321
321
|
apiBase;
|
|
322
322
|
headers;
|
|
323
323
|
url(path) {
|
|
324
|
-
|
|
324
|
+
const encoded = path.split("/").map(encodeURIComponent).join("/");
|
|
325
|
+
return `${this.apiBase}/contents/${encoded}`;
|
|
325
326
|
}
|
|
326
327
|
async getSha(path) {
|
|
327
328
|
const res = await fetch(this.url(path), { headers: this.headers });
|
|
@@ -1444,6 +1445,25 @@ async function writeFileToPath(filePath, content) {
|
|
|
1444
1445
|
await mkdir9(dirname7(filePath), { recursive: true });
|
|
1445
1446
|
await writeFile9(filePath, content, "utf-8");
|
|
1446
1447
|
}
|
|
1448
|
+
var CORTEX_BLOCK_START = "<!-- cortex-sync:start -->";
|
|
1449
|
+
var CORTEX_BLOCK_END = "<!-- cortex-sync:end -->";
|
|
1450
|
+
function injectCortexPathBlock(content, cwd) {
|
|
1451
|
+
const block = [
|
|
1452
|
+
CORTEX_BLOCK_START,
|
|
1453
|
+
`> **[cortex-sync]** Project root on this machine: \`${cwd}\``,
|
|
1454
|
+
`> Sessions shared via cortex-sync may reference paths from other machines. Always resolve file operations against the project root above.`,
|
|
1455
|
+
CORTEX_BLOCK_END
|
|
1456
|
+
].join("\n");
|
|
1457
|
+
const startIdx = content.indexOf(CORTEX_BLOCK_START);
|
|
1458
|
+
const endIdx = content.indexOf(CORTEX_BLOCK_END);
|
|
1459
|
+
if (startIdx !== -1 && endIdx !== -1 && endIdx > startIdx) {
|
|
1460
|
+
const before = content.slice(0, startIdx);
|
|
1461
|
+
const after = content.slice(endIdx + CORTEX_BLOCK_END.length);
|
|
1462
|
+
return before + block + after;
|
|
1463
|
+
}
|
|
1464
|
+
const separator = content.length > 0 ? "\n\n" : "";
|
|
1465
|
+
return block + separator + content;
|
|
1466
|
+
}
|
|
1447
1467
|
|
|
1448
1468
|
// src/lib/claude-plugins.ts
|
|
1449
1469
|
import { readFile as readFile11 } from "fs/promises";
|
|
@@ -1785,15 +1805,15 @@ async function teamPullCommand() {
|
|
|
1785
1805
|
if (remoteMd) {
|
|
1786
1806
|
const localMd = await readFileFromPath(LOCAL_CLAUDE_MD);
|
|
1787
1807
|
if (!localMd) {
|
|
1788
|
-
await writeFileToPath(LOCAL_CLAUDE_MD, remoteMd);
|
|
1808
|
+
await writeFileToPath(LOCAL_CLAUDE_MD, injectCortexPathBlock(remoteMd, process.cwd()));
|
|
1789
1809
|
console.log(" + CLAUDE.md (new)");
|
|
1790
1810
|
} else if (hasConflict(localMd, remoteMd)) {
|
|
1791
1811
|
const resolution = await promptConflict("CLAUDE.md", localMd, remoteMd);
|
|
1792
1812
|
if (resolution === "overwrite") {
|
|
1793
|
-
await writeFileToPath(LOCAL_CLAUDE_MD, remoteMd);
|
|
1813
|
+
await writeFileToPath(LOCAL_CLAUDE_MD, injectCortexPathBlock(remoteMd, process.cwd()));
|
|
1794
1814
|
console.log(" \u2713 CLAUDE.md overwritten");
|
|
1795
1815
|
} else if (resolution === "merge") {
|
|
1796
|
-
await writeFileToPath(LOCAL_CLAUDE_MD, mergeContent(localMd, remoteMd));
|
|
1816
|
+
await writeFileToPath(LOCAL_CLAUDE_MD, injectCortexPathBlock(mergeContent(localMd, remoteMd), process.cwd()));
|
|
1797
1817
|
console.log(" \u2713 CLAUDE.md merged");
|
|
1798
1818
|
} else {
|
|
1799
1819
|
console.log(" ~ CLAUDE.md skipped");
|
|
@@ -1853,11 +1873,9 @@ async function installCommand(opts) {
|
|
|
1853
1873
|
await writeSkillToDir(LOCAL_SKILLS_DIR, filename, content);
|
|
1854
1874
|
console.log(` + .claude/skills/${filename}`);
|
|
1855
1875
|
}
|
|
1856
|
-
const
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
console.log(" + .claude/CLAUDE.md");
|
|
1860
|
-
}
|
|
1876
|
+
const teamMd = await readFileFromPath(join20(TEAM_DIR, "CLAUDE.md")) ?? "";
|
|
1877
|
+
await writeFileToPath(LOCAL_CLAUDE_MD, injectCortexPathBlock(teamMd, process.cwd()));
|
|
1878
|
+
if (teamMd) console.log(" + .claude/CLAUDE.md");
|
|
1861
1879
|
let cortexJson = {};
|
|
1862
1880
|
try {
|
|
1863
1881
|
cortexJson = JSON.parse(await readFile15(join20(TEAM_DIR, "cortex.json"), "utf-8"));
|