@easysociable/cli 0.1.31 → 0.1.32
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/easysociable.js +42 -27
- package/dist/easysociable.js.map +1 -1
- package/package.json +1 -1
package/dist/easysociable.js
CHANGED
|
@@ -34602,16 +34602,16 @@ var init_v1_mcp = __esm({
|
|
|
34602
34602
|
|
|
34603
34603
|
// src/v1-cli.ts
|
|
34604
34604
|
init_src2();
|
|
34605
|
-
import { cp, readFile, writeFile, mkdir, chmod,
|
|
34605
|
+
import { cp, readFile, writeFile, mkdir, chmod, rm } from "fs/promises";
|
|
34606
34606
|
import { existsSync as existsSync4, readFileSync as readFileSync3, statSync as statSync2 } from "fs";
|
|
34607
34607
|
import { homedir as homedir3 } from "os";
|
|
34608
|
-
import { basename as
|
|
34608
|
+
import { basename as basename3, join as join4, resolve as resolve2 } from "path";
|
|
34609
34609
|
import { Command } from "commander";
|
|
34610
34610
|
|
|
34611
34611
|
// src/runtime/mcp-hosts.ts
|
|
34612
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
34612
|
+
import { existsSync, mkdirSync, readdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "fs";
|
|
34613
34613
|
import { homedir } from "os";
|
|
34614
|
-
import { dirname, join } from "path";
|
|
34614
|
+
import { basename, dirname, join } from "path";
|
|
34615
34615
|
var UNIFIED_MCP_SERVER_KEY = "easysociable";
|
|
34616
34616
|
var LEGACY_MCP_SERVER_KEYS = ["easysociable-content", "easysociable-template", "easysociable-slideshow"];
|
|
34617
34617
|
var defaultHostPaths = {
|
|
@@ -34634,14 +34634,22 @@ function installHostConfig(options) {
|
|
|
34634
34634
|
}
|
|
34635
34635
|
}
|
|
34636
34636
|
};
|
|
34637
|
+
const text = `${JSON.stringify(next, null, 2)}
|
|
34638
|
+
`;
|
|
34639
|
+
const before = existsSync(configPath) ? readFileSync(configPath, "utf8") : null;
|
|
34640
|
+
const backup = before !== null && before !== text ? `${configPath}.bak` : void 0;
|
|
34637
34641
|
mkdirSync(dirname(configPath), { recursive: true });
|
|
34638
|
-
|
|
34639
|
-
|
|
34642
|
+
pruneTimestampedBackups(configPath);
|
|
34643
|
+
if (backup)
|
|
34644
|
+
writeFileSync(backup, before);
|
|
34645
|
+
if (before !== text)
|
|
34646
|
+
writeFileSync(configPath, text);
|
|
34640
34647
|
return {
|
|
34641
34648
|
host: options.host,
|
|
34642
34649
|
configPath,
|
|
34643
34650
|
compatible: isUnifiedConfigCompatible(next),
|
|
34644
|
-
migratedFromLegacy: migrated.migrated
|
|
34651
|
+
migratedFromLegacy: migrated.migrated,
|
|
34652
|
+
backup
|
|
34645
34653
|
};
|
|
34646
34654
|
}
|
|
34647
34655
|
function migrateLegacyMcpServer(config2) {
|
|
@@ -34670,6 +34678,17 @@ function stripLegacyServer(servers) {
|
|
|
34670
34678
|
delete next[key];
|
|
34671
34679
|
return next;
|
|
34672
34680
|
}
|
|
34681
|
+
function pruneTimestampedBackups(configPath) {
|
|
34682
|
+
const dir = dirname(configPath);
|
|
34683
|
+
const stamped = readdirSync(dir).filter((f) => f.startsWith(`${basename(configPath)}.bak.`)).sort();
|
|
34684
|
+
const newest = stamped.pop();
|
|
34685
|
+
if (newest && !existsSync(`${configPath}.bak`))
|
|
34686
|
+
renameSync(join(dir, newest), `${configPath}.bak`);
|
|
34687
|
+
else if (newest)
|
|
34688
|
+
stamped.push(newest);
|
|
34689
|
+
for (const f of stamped)
|
|
34690
|
+
rmSync(join(dir, f), { force: true });
|
|
34691
|
+
}
|
|
34673
34692
|
function readConfig(configPath) {
|
|
34674
34693
|
if (!existsSync(configPath))
|
|
34675
34694
|
return {};
|
|
@@ -34742,15 +34761,15 @@ import {
|
|
|
34742
34761
|
cpSync,
|
|
34743
34762
|
existsSync as existsSync3,
|
|
34744
34763
|
mkdirSync as mkdirSync2,
|
|
34745
|
-
readdirSync,
|
|
34764
|
+
readdirSync as readdirSync2,
|
|
34746
34765
|
readFileSync as readFileSync2,
|
|
34747
|
-
rmSync,
|
|
34766
|
+
rmSync as rmSync2,
|
|
34748
34767
|
statSync,
|
|
34749
34768
|
writeFileSync as writeFileSync2
|
|
34750
34769
|
} from "fs";
|
|
34751
34770
|
import net from "net";
|
|
34752
34771
|
import { homedir as homedir2 } from "os";
|
|
34753
|
-
import { basename, dirname as dirname3, join as join3, resolve } from "path";
|
|
34772
|
+
import { basename as basename2, dirname as dirname3, join as join3, resolve } from "path";
|
|
34754
34773
|
var ENGINE_ROOT_NAME = "Content Engine";
|
|
34755
34774
|
var WORKBENCH_PORT = 8765;
|
|
34756
34775
|
var WORKBENCH_URL = `http://127.0.0.1:${WORKBENCH_PORT}/workbench/`;
|
|
@@ -34805,13 +34824,13 @@ function ensureCoreCheckout({ update = false } = {}) {
|
|
|
34805
34824
|
if (existsSync3(marker) && update) {
|
|
34806
34825
|
const pull = spawnSync("git", ["-C", cache, "pull", "--ff-only"], { encoding: "utf8" });
|
|
34807
34826
|
if (pull.status !== 0) {
|
|
34808
|
-
|
|
34827
|
+
rmSync2(cache, { recursive: true, force: true });
|
|
34809
34828
|
} else {
|
|
34810
34829
|
return cache;
|
|
34811
34830
|
}
|
|
34812
34831
|
}
|
|
34813
34832
|
if (existsSync3(cache))
|
|
34814
|
-
|
|
34833
|
+
rmSync2(cache, { recursive: true, force: true });
|
|
34815
34834
|
const clone2 = spawnSync("git", ["clone", "--depth", "1", contentEngineRepoUrl(), cache], { encoding: "utf8" });
|
|
34816
34835
|
if (clone2.status !== 0 || !existsSync3(marker)) {
|
|
34817
34836
|
throw new Error(
|
|
@@ -34825,7 +34844,7 @@ function isEngine(path) {
|
|
|
34825
34844
|
}
|
|
34826
34845
|
function resolveEngine(rootOrEngine) {
|
|
34827
34846
|
const absolute = resolve(rootOrEngine);
|
|
34828
|
-
if (isEngine(absolute) ||
|
|
34847
|
+
if (isEngine(absolute) || basename2(absolute) === ENGINE_ROOT_NAME)
|
|
34829
34848
|
return absolute;
|
|
34830
34849
|
return join3(absolute, ENGINE_ROOT_NAME);
|
|
34831
34850
|
}
|
|
@@ -35073,7 +35092,7 @@ async function initEngine(rootOrEngine, moduleUrl, {
|
|
|
35073
35092
|
}
|
|
35074
35093
|
const created = [];
|
|
35075
35094
|
if (isEngine(engine)) {
|
|
35076
|
-
} else if (existsSync3(engine) &&
|
|
35095
|
+
} else if (existsSync3(engine) && readdirSync2(engine).filter((n) => n !== ".DS_Store").length > 0) {
|
|
35077
35096
|
return {
|
|
35078
35097
|
...validateEngine(engine, moduleUrl),
|
|
35079
35098
|
created,
|
|
@@ -35085,9 +35104,9 @@ async function initEngine(rootOrEngine, moduleUrl, {
|
|
|
35085
35104
|
} else {
|
|
35086
35105
|
const core = ensureCoreCheckout();
|
|
35087
35106
|
if (existsSync3(engine))
|
|
35088
|
-
|
|
35107
|
+
rmSync2(engine, { recursive: true, force: true });
|
|
35089
35108
|
cpSync(core, engine, { recursive: true });
|
|
35090
|
-
|
|
35109
|
+
rmSync2(join3(engine, ".git"), { recursive: true, force: true });
|
|
35091
35110
|
created.push("CLAUDE.md", "engine.json", "workbench/", "(cloned public core)");
|
|
35092
35111
|
}
|
|
35093
35112
|
const workbench = ensureWorkbench(engine, moduleUrl);
|
|
@@ -35141,7 +35160,7 @@ function classifyCoreFile(rel) {
|
|
|
35141
35160
|
return "refresh";
|
|
35142
35161
|
if (parts[0] === "platforms" && rel.endsWith(".md"))
|
|
35143
35162
|
return "refresh";
|
|
35144
|
-
if (
|
|
35163
|
+
if (basename2(rel) === "_template.md" || parts.includes("_template"))
|
|
35145
35164
|
return "refresh";
|
|
35146
35165
|
return "skip";
|
|
35147
35166
|
}
|
|
@@ -35150,7 +35169,7 @@ function walkCoreFiles(core, relDir = "") {
|
|
|
35150
35169
|
const absDir = join3(core, relDir);
|
|
35151
35170
|
if (!isDir(absDir))
|
|
35152
35171
|
return out;
|
|
35153
|
-
for (const name of
|
|
35172
|
+
for (const name of readdirSync2(absDir)) {
|
|
35154
35173
|
if (name === ".git" || name === ".DS_Store")
|
|
35155
35174
|
continue;
|
|
35156
35175
|
const rel = relDir ? `${relDir}/${name}` : name;
|
|
@@ -35254,7 +35273,7 @@ function detectEngines() {
|
|
|
35254
35273
|
if (isEngine(direct) || isDir(direct))
|
|
35255
35274
|
found.push(direct);
|
|
35256
35275
|
try {
|
|
35257
|
-
for (const name of
|
|
35276
|
+
for (const name of readdirSync2(root)) {
|
|
35258
35277
|
const child = join3(root, name, ENGINE_ROOT_NAME);
|
|
35259
35278
|
if (isDir(child))
|
|
35260
35279
|
found.push(child);
|
|
@@ -35626,15 +35645,11 @@ async function applyInstallation(options) {
|
|
|
35626
35645
|
throw new Error("No supported host detected. Install Codex or Claude Code first, or use --home with a fixture host directory.");
|
|
35627
35646
|
if (options.yes !== true)
|
|
35628
35647
|
throw new Error("Installation changes are planned only. Re-run with --yes after reviewing the paths.");
|
|
35629
|
-
const backupSuffix = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
35630
35648
|
const backups = [];
|
|
35631
35649
|
for (const host of detectedHosts(String(plan.home))) {
|
|
35632
|
-
|
|
35633
|
-
|
|
35634
|
-
|
|
35635
|
-
backups.push(backupPath);
|
|
35636
|
-
}
|
|
35637
|
-
await installHostConfig({ host: host.host, dataDir: "", configPath: host.configPath });
|
|
35650
|
+
const { backup } = installHostConfig({ host: host.host, dataDir: "", configPath: host.configPath });
|
|
35651
|
+
if (backup)
|
|
35652
|
+
backups.push(backup);
|
|
35638
35653
|
await mkdir(host.skillsPath, { recursive: true, mode: 448 });
|
|
35639
35654
|
for (const skill of hostSkillIds(host.skillsPath, options)) {
|
|
35640
35655
|
const target = join4(host.skillsPath, skill);
|
|
@@ -35833,7 +35848,7 @@ Waiting for approval\u2026
|
|
|
35833
35848
|
jsonOption(images.command("upload").option("--path <files...>", "Image files (PNG/JPEG/WebP), uploaded in parallel").option("--file <path>", "JSON body { file: dataUrl, filename }")).action(withClient(async (client, opts) => {
|
|
35834
35849
|
if (!opts.path)
|
|
35835
35850
|
return client.requestJson("POST", "/v1/images/imports", JSON.parse(await readFile(String(opts.file), "utf8")));
|
|
35836
|
-
const results = await Promise.allSettled(opts.path.map(async (path) => client.requestJson("POST", "/v1/images/imports", { file: `data:${mimeTypeFor(path)};base64,${(await readFile(path)).toString("base64")}`, filename:
|
|
35851
|
+
const results = await Promise.allSettled(opts.path.map(async (path) => client.requestJson("POST", "/v1/images/imports", { file: `data:${mimeTypeFor(path)};base64,${(await readFile(path)).toString("base64")}`, filename: basename3(path) })));
|
|
35837
35852
|
const data = results.map((r, i) => r.status === "fulfilled" ? { path: opts.path[i], asset: r.value.data?.asset } : { path: opts.path[i], error: r.reason instanceof Error ? r.reason.message : String(r.reason) });
|
|
35838
35853
|
if (data.some((d) => "error" in d))
|
|
35839
35854
|
process.exitCode = 1;
|