@powerformer/refly-cli 0.1.12 → 0.1.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/bin/refly.js +117 -92
- package/dist/bin/refly.js.map +1 -1
- package/dist/index.js +34 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/bin/refly.js
CHANGED
|
@@ -3141,13 +3141,13 @@ function redact(message) {
|
|
|
3141
3141
|
}
|
|
3142
3142
|
return result;
|
|
3143
3143
|
}
|
|
3144
|
-
var
|
|
3144
|
+
var fs3, path3, LOG_FILE, MAX_LOG_SIZE, LOG_LEVELS, SENSITIVE_PATTERNS, Logger, logger;
|
|
3145
3145
|
var init_logger = __esm({
|
|
3146
3146
|
"src/utils/logger.ts"() {
|
|
3147
3147
|
"use strict";
|
|
3148
3148
|
init_cjs_shims();
|
|
3149
|
-
|
|
3150
|
-
|
|
3149
|
+
fs3 = __toESM(require("fs"));
|
|
3150
|
+
path3 = __toESM(require("path"));
|
|
3151
3151
|
init_paths();
|
|
3152
3152
|
LOG_FILE = "cli.log";
|
|
3153
3153
|
MAX_LOG_SIZE = 5 * 1024 * 1024;
|
|
@@ -3183,15 +3183,15 @@ var init_logger = __esm({
|
|
|
3183
3183
|
writeToFile(formatted) {
|
|
3184
3184
|
if (!this.logToFile) return;
|
|
3185
3185
|
try {
|
|
3186
|
-
const logPath =
|
|
3186
|
+
const logPath = path3.join(getReflyDir(), LOG_FILE);
|
|
3187
3187
|
try {
|
|
3188
|
-
const stats =
|
|
3188
|
+
const stats = fs3.statSync(logPath);
|
|
3189
3189
|
if (stats.size > MAX_LOG_SIZE) {
|
|
3190
|
-
|
|
3190
|
+
fs3.renameSync(logPath, `${logPath}.old`);
|
|
3191
3191
|
}
|
|
3192
3192
|
} catch {
|
|
3193
3193
|
}
|
|
3194
|
-
|
|
3194
|
+
fs3.appendFileSync(logPath, `${formatted}
|
|
3195
3195
|
`);
|
|
3196
3196
|
} catch {
|
|
3197
3197
|
}
|
|
@@ -4441,12 +4441,6 @@ var path10 = __toESM(require("path"));
|
|
|
4441
4441
|
// src/commands/init.ts
|
|
4442
4442
|
init_cjs_shims();
|
|
4443
4443
|
|
|
4444
|
-
// src/skill/installer.ts
|
|
4445
|
-
init_cjs_shims();
|
|
4446
|
-
var fs3 = __toESM(require("fs"));
|
|
4447
|
-
var path3 = __toESM(require("path"));
|
|
4448
|
-
init_paths();
|
|
4449
|
-
|
|
4450
4444
|
// src/config/config.ts
|
|
4451
4445
|
init_cjs_shims();
|
|
4452
4446
|
var fs2 = __toESM(require("fs"));
|
|
@@ -8545,8 +8539,8 @@ var ConfigSchema = external_exports.object({
|
|
|
8545
8539
|
installedAt: external_exports.string().optional()
|
|
8546
8540
|
}).optional()
|
|
8547
8541
|
});
|
|
8548
|
-
var DEFAULT_API_ENDPOINT = "https://
|
|
8549
|
-
var DEFAULT_WEB_URL = "https://
|
|
8542
|
+
var DEFAULT_API_ENDPOINT = "https://api.refly.ai";
|
|
8543
|
+
var DEFAULT_WEB_URL = "https://refly.ai";
|
|
8550
8544
|
var DEFAULT_CONFIG = {
|
|
8551
8545
|
version: 1,
|
|
8552
8546
|
api: {
|
|
@@ -8675,20 +8669,34 @@ function getApiKeyInfo() {
|
|
|
8675
8669
|
return void 0;
|
|
8676
8670
|
}
|
|
8677
8671
|
|
|
8672
|
+
// src/commands/init.ts
|
|
8673
|
+
init_paths();
|
|
8674
|
+
|
|
8678
8675
|
// src/skill/installer.ts
|
|
8676
|
+
init_cjs_shims();
|
|
8677
|
+
var fs4 = __toESM(require("fs"));
|
|
8678
|
+
var path4 = __toESM(require("path"));
|
|
8679
|
+
init_paths();
|
|
8680
|
+
init_logger();
|
|
8679
8681
|
function getPackageSkillDir() {
|
|
8680
8682
|
const possiblePaths = [
|
|
8681
|
-
|
|
8682
|
-
// Built package
|
|
8683
|
-
|
|
8684
|
-
// Development
|
|
8683
|
+
path4.join(__dirname, "..", "..", "skill"),
|
|
8684
|
+
// Built package: dist/bin/../../skill
|
|
8685
|
+
path4.join(__dirname, "..", "..", "..", "skill"),
|
|
8686
|
+
// Development: dist/bin/../../../skill
|
|
8687
|
+
path4.join(__dirname, "..", "skill")
|
|
8688
|
+
// Alternative: dist/../skill
|
|
8685
8689
|
];
|
|
8690
|
+
logger.debug("Looking for skill files, __dirname:", __dirname);
|
|
8686
8691
|
for (const p of possiblePaths) {
|
|
8687
|
-
|
|
8688
|
-
|
|
8692
|
+
const resolved = path4.resolve(p);
|
|
8693
|
+
const exists = fs4.existsSync(resolved);
|
|
8694
|
+
logger.debug(` Checking path: ${resolved} - exists: ${exists}`);
|
|
8695
|
+
if (exists) {
|
|
8696
|
+
return resolved;
|
|
8689
8697
|
}
|
|
8690
8698
|
}
|
|
8691
|
-
throw new Error(
|
|
8699
|
+
throw new Error(`Skill files not found in package. Searched paths from __dirname=${__dirname}`);
|
|
8692
8700
|
}
|
|
8693
8701
|
function installSkill() {
|
|
8694
8702
|
const result = {
|
|
@@ -8699,43 +8707,62 @@ function installSkill() {
|
|
|
8699
8707
|
version: getSkillVersion()
|
|
8700
8708
|
};
|
|
8701
8709
|
const sourceDir = getPackageSkillDir();
|
|
8710
|
+
logger.debug("Source skill directory:", sourceDir);
|
|
8702
8711
|
const targetDir = getClaudeSkillDir();
|
|
8703
|
-
|
|
8704
|
-
|
|
8705
|
-
|
|
8706
|
-
|
|
8707
|
-
|
|
8708
|
-
|
|
8712
|
+
logger.debug("Target skill directory:", targetDir);
|
|
8713
|
+
try {
|
|
8714
|
+
ensureDir(targetDir);
|
|
8715
|
+
ensureDir(path4.join(targetDir, "references"));
|
|
8716
|
+
logger.debug("Created target directories");
|
|
8717
|
+
} catch (err) {
|
|
8718
|
+
logger.error("Failed to create target directories:", err);
|
|
8719
|
+
throw err;
|
|
8720
|
+
}
|
|
8721
|
+
const skillSource = path4.join(sourceDir, "SKILL.md");
|
|
8722
|
+
const skillTarget = path4.join(targetDir, "SKILL.md");
|
|
8723
|
+
logger.debug(`Copying SKILL.md: ${skillSource} -> ${skillTarget}`);
|
|
8724
|
+
if (fs4.existsSync(skillSource)) {
|
|
8725
|
+
fs4.copyFileSync(skillSource, skillTarget);
|
|
8709
8726
|
result.skillInstalled = true;
|
|
8710
8727
|
result.skillPath = targetDir;
|
|
8728
|
+
logger.debug("SKILL.md copied successfully");
|
|
8729
|
+
} else {
|
|
8730
|
+
logger.warn("SKILL.md source not found:", skillSource);
|
|
8711
8731
|
}
|
|
8712
|
-
const refsSource =
|
|
8713
|
-
const refsTarget =
|
|
8714
|
-
if (
|
|
8715
|
-
const files =
|
|
8732
|
+
const refsSource = path4.join(sourceDir, "references");
|
|
8733
|
+
const refsTarget = path4.join(targetDir, "references");
|
|
8734
|
+
if (fs4.existsSync(refsSource)) {
|
|
8735
|
+
const files = fs4.readdirSync(refsSource);
|
|
8736
|
+
logger.debug(`Copying ${files.length} reference files`);
|
|
8716
8737
|
for (const file of files) {
|
|
8717
|
-
|
|
8738
|
+
fs4.copyFileSync(path4.join(refsSource, file), path4.join(refsTarget, file));
|
|
8718
8739
|
}
|
|
8719
8740
|
}
|
|
8720
8741
|
const commandsDir = getClaudeCommandsDir();
|
|
8742
|
+
logger.debug("Commands directory:", commandsDir);
|
|
8721
8743
|
ensureDir(commandsDir);
|
|
8722
8744
|
result.commandsInstalled = installSlashCommands(sourceDir, commandsDir);
|
|
8723
8745
|
if (result.commandsInstalled) {
|
|
8724
8746
|
result.commandsPath = commandsDir;
|
|
8725
8747
|
}
|
|
8748
|
+
logger.debug("Commands installed:", result.commandsInstalled);
|
|
8726
8749
|
updateSkillInfo(result.version);
|
|
8750
|
+
logger.info("Skill installation complete:", {
|
|
8751
|
+
skillInstalled: result.skillInstalled,
|
|
8752
|
+
commandsInstalled: result.commandsInstalled
|
|
8753
|
+
});
|
|
8727
8754
|
return result;
|
|
8728
8755
|
}
|
|
8729
8756
|
function installSlashCommands(sourceDir, targetDir) {
|
|
8730
|
-
const commandsSource =
|
|
8731
|
-
if (!
|
|
8757
|
+
const commandsSource = path4.join(sourceDir, "..", "commands");
|
|
8758
|
+
if (!fs4.existsSync(commandsSource)) {
|
|
8732
8759
|
return false;
|
|
8733
8760
|
}
|
|
8734
8761
|
try {
|
|
8735
|
-
const files =
|
|
8762
|
+
const files = fs4.readdirSync(commandsSource);
|
|
8736
8763
|
for (const file of files) {
|
|
8737
8764
|
if (file.endsWith(".md")) {
|
|
8738
|
-
|
|
8765
|
+
fs4.copyFileSync(path4.join(commandsSource, file), path4.join(targetDir, file));
|
|
8739
8766
|
}
|
|
8740
8767
|
}
|
|
8741
8768
|
return files.length > 0;
|
|
@@ -8745,8 +8772,8 @@ function installSlashCommands(sourceDir, targetDir) {
|
|
|
8745
8772
|
}
|
|
8746
8773
|
function getSkillVersion() {
|
|
8747
8774
|
try {
|
|
8748
|
-
const skillPath =
|
|
8749
|
-
const content =
|
|
8775
|
+
const skillPath = path4.join(getPackageSkillDir(), "SKILL.md");
|
|
8776
|
+
const content = fs4.readFileSync(skillPath, "utf-8");
|
|
8750
8777
|
const versionMatch = content.match(/version:\s*(\d+\.\d+\.\d+)/);
|
|
8751
8778
|
if (versionMatch) {
|
|
8752
8779
|
return versionMatch[1];
|
|
@@ -8754,16 +8781,16 @@ function getSkillVersion() {
|
|
|
8754
8781
|
} catch {
|
|
8755
8782
|
}
|
|
8756
8783
|
try {
|
|
8757
|
-
const pkgPath =
|
|
8758
|
-
const pkg = JSON.parse(
|
|
8784
|
+
const pkgPath = path4.join(__dirname, "..", "..", "package.json");
|
|
8785
|
+
const pkg = JSON.parse(fs4.readFileSync(pkgPath, "utf-8"));
|
|
8759
8786
|
return pkg.version;
|
|
8760
8787
|
} catch {
|
|
8761
8788
|
return "0.1.0";
|
|
8762
8789
|
}
|
|
8763
8790
|
}
|
|
8764
8791
|
function isSkillInstalled() {
|
|
8765
|
-
const skillPath =
|
|
8766
|
-
if (!
|
|
8792
|
+
const skillPath = path4.join(getClaudeSkillDir(), "SKILL.md");
|
|
8793
|
+
if (!fs4.existsSync(skillPath)) {
|
|
8767
8794
|
return { installed: false, upToDate: false };
|
|
8768
8795
|
}
|
|
8769
8796
|
const currentVersion = getSkillVersion();
|
|
@@ -8774,8 +8801,41 @@ function isSkillInstalled() {
|
|
|
8774
8801
|
};
|
|
8775
8802
|
}
|
|
8776
8803
|
|
|
8777
|
-
// src/
|
|
8778
|
-
|
|
8804
|
+
// src/utils/logo.ts
|
|
8805
|
+
init_cjs_shims();
|
|
8806
|
+
var REFLY_LOGO = `\u2588\u2580\u2588 \u2588\u2580\u2580 \u2588\u2580\u2580 \u2588 \u2588 \u2588 \u2588\u2580\u2588 \u2588
|
|
8807
|
+
\u2588\u2580\u2584 \u2588\u2580\u2580 \u2588\u2580\u2580 \u2588 \u2588\u2584\u2588 \u2580 \u2588\u2580\u2588 \u2588
|
|
8808
|
+
\u2580 \u2580 \u2580\u2580\u2580 \u2580 \u2580\u2580\u2580 \u2580 \u2580 \u2580 \u2580`;
|
|
8809
|
+
function printLogo(options) {
|
|
8810
|
+
const useColor = options?.color ?? shouldUseColor();
|
|
8811
|
+
const tty = isTTY();
|
|
8812
|
+
if (!tty && !options?.force) {
|
|
8813
|
+
return;
|
|
8814
|
+
}
|
|
8815
|
+
if (useColor) {
|
|
8816
|
+
process.stderr.write(`${Style.TEXT_SUCCESS}${REFLY_LOGO}${Style.RESET}
|
|
8817
|
+
`);
|
|
8818
|
+
} else {
|
|
8819
|
+
process.stderr.write(`${REFLY_LOGO}
|
|
8820
|
+
`);
|
|
8821
|
+
}
|
|
8822
|
+
}
|
|
8823
|
+
function printSuccess(message) {
|
|
8824
|
+
process.stderr.write(`${UI.successMsg(message)}
|
|
8825
|
+
`);
|
|
8826
|
+
}
|
|
8827
|
+
function printError2(message) {
|
|
8828
|
+
process.stderr.write(`${UI.errorMsg(message)}
|
|
8829
|
+
`);
|
|
8830
|
+
}
|
|
8831
|
+
function printDim(message) {
|
|
8832
|
+
process.stderr.write(`${UI.dim(message)}
|
|
8833
|
+
`);
|
|
8834
|
+
}
|
|
8835
|
+
function println(message) {
|
|
8836
|
+
process.stderr.write(`${message}
|
|
8837
|
+
`);
|
|
8838
|
+
}
|
|
8779
8839
|
|
|
8780
8840
|
// src/commands/login.ts
|
|
8781
8841
|
init_cjs_shims();
|
|
@@ -9222,14 +9282,14 @@ var baseOpen = async (options) => {
|
|
|
9222
9282
|
}
|
|
9223
9283
|
const subprocess = import_node_child_process5.default.spawn(command, cliArguments, childProcessOptions);
|
|
9224
9284
|
if (options.wait) {
|
|
9225
|
-
return new Promise((
|
|
9285
|
+
return new Promise((resolve3, reject) => {
|
|
9226
9286
|
subprocess.once("error", reject);
|
|
9227
9287
|
subprocess.once("close", (exitCode) => {
|
|
9228
9288
|
if (!options.allowNonzeroExitCode && exitCode > 0) {
|
|
9229
9289
|
reject(new Error(`Exited with code ${exitCode}`));
|
|
9230
9290
|
return;
|
|
9231
9291
|
}
|
|
9232
|
-
|
|
9292
|
+
resolve3(subprocess);
|
|
9233
9293
|
});
|
|
9234
9294
|
});
|
|
9235
9295
|
}
|
|
@@ -9791,47 +9851,11 @@ async function getUserInfoFromToken(accessToken) {
|
|
|
9791
9851
|
};
|
|
9792
9852
|
}
|
|
9793
9853
|
function sleep(ms) {
|
|
9794
|
-
return new Promise((
|
|
9795
|
-
}
|
|
9796
|
-
|
|
9797
|
-
// src/utils/logo.ts
|
|
9798
|
-
init_cjs_shims();
|
|
9799
|
-
var REFLY_LOGO = `\u2588\u2580\u2588 \u2588\u2580\u2580 \u2588\u2580\u2580 \u2588 \u2588 \u2588 \u2588\u2580\u2588 \u2588
|
|
9800
|
-
\u2588\u2580\u2584 \u2588\u2580\u2580 \u2588\u2580\u2580 \u2588 \u2588\u2584\u2588 \u2580 \u2588\u2580\u2588 \u2588
|
|
9801
|
-
\u2580 \u2580 \u2580\u2580\u2580 \u2580 \u2580\u2580\u2580 \u2580 \u2580 \u2580 \u2580`;
|
|
9802
|
-
function printLogo(options) {
|
|
9803
|
-
const useColor = options?.color ?? shouldUseColor();
|
|
9804
|
-
const tty = isTTY();
|
|
9805
|
-
if (!tty && !options?.force) {
|
|
9806
|
-
return;
|
|
9807
|
-
}
|
|
9808
|
-
if (useColor) {
|
|
9809
|
-
process.stderr.write(`${Style.TEXT_SUCCESS}${REFLY_LOGO}${Style.RESET}
|
|
9810
|
-
`);
|
|
9811
|
-
} else {
|
|
9812
|
-
process.stderr.write(`${REFLY_LOGO}
|
|
9813
|
-
`);
|
|
9814
|
-
}
|
|
9815
|
-
}
|
|
9816
|
-
function printSuccess(message) {
|
|
9817
|
-
process.stderr.write(`${UI.successMsg(message)}
|
|
9818
|
-
`);
|
|
9819
|
-
}
|
|
9820
|
-
function printError2(message) {
|
|
9821
|
-
process.stderr.write(`${UI.errorMsg(message)}
|
|
9822
|
-
`);
|
|
9823
|
-
}
|
|
9824
|
-
function printDim(message) {
|
|
9825
|
-
process.stderr.write(`${UI.dim(message)}
|
|
9826
|
-
`);
|
|
9827
|
-
}
|
|
9828
|
-
function println(message) {
|
|
9829
|
-
process.stderr.write(`${message}
|
|
9830
|
-
`);
|
|
9854
|
+
return new Promise((resolve3) => setTimeout(resolve3, ms));
|
|
9831
9855
|
}
|
|
9832
9856
|
|
|
9833
9857
|
// src/commands/init.ts
|
|
9834
|
-
var DEFAULT_API_ENDPOINT2 = "https://
|
|
9858
|
+
var DEFAULT_API_ENDPOINT2 = "https://api.refly.ai";
|
|
9835
9859
|
var initCommand = new Command("init").description("Initialize Refly CLI, install skill files, and authenticate").option("--force", "Force reinstall even if already installed").option("--host <url>", "API server URL", DEFAULT_API_ENDPOINT2).option("--skip-login", "Skip automatic login after initialization").action(async (options) => {
|
|
9836
9860
|
try {
|
|
9837
9861
|
const { force, host, skipLogin } = options;
|
|
@@ -9905,22 +9929,23 @@ var initCommand = new Command("init").description("Initialize Refly CLI, install
|
|
|
9905
9929
|
printDim("A browser window will open for login.");
|
|
9906
9930
|
println("");
|
|
9907
9931
|
}
|
|
9908
|
-
const
|
|
9932
|
+
const loginSuccess = await loginWithDeviceFlow();
|
|
9909
9933
|
if (pretty && tty) {
|
|
9910
|
-
if (
|
|
9934
|
+
if (loginSuccess) {
|
|
9911
9935
|
printSuccess("Authentication successful");
|
|
9912
|
-
|
|
9913
|
-
|
|
9936
|
+
const user = getAuthUser();
|
|
9937
|
+
if (user?.email) {
|
|
9938
|
+
printDim(` Welcome, ${user.email}!`);
|
|
9914
9939
|
}
|
|
9915
9940
|
} else {
|
|
9916
9941
|
printError2("Authentication was not completed");
|
|
9917
9942
|
printDim(" Run `refly login` to authenticate later.");
|
|
9918
9943
|
}
|
|
9919
9944
|
println("");
|
|
9920
|
-
} else if (!pretty &&
|
|
9945
|
+
} else if (!pretty && loginSuccess) {
|
|
9921
9946
|
print("login", {
|
|
9922
9947
|
message: "Successfully authenticated",
|
|
9923
|
-
user:
|
|
9948
|
+
user: getAuthUser()
|
|
9924
9949
|
});
|
|
9925
9950
|
}
|
|
9926
9951
|
} else if (pretty && tty) {
|
|
@@ -11842,7 +11867,7 @@ var workflowStatusCommand = new Command("status").description("Get detailed work
|
|
|
11842
11867
|
});
|
|
11843
11868
|
prevStatus = status;
|
|
11844
11869
|
while (status.status === "init" || status.status === "executing") {
|
|
11845
|
-
await new Promise((
|
|
11870
|
+
await new Promise((resolve3) => setTimeout(resolve3, pollInterval));
|
|
11846
11871
|
status = await fetchStatus();
|
|
11847
11872
|
if (options.full || hasStatusChanged(prevStatus, status)) {
|
|
11848
11873
|
if (options.full) {
|