@zhongqian97-code/ecode 0.5.16 → 0.5.18
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/index.js +64 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5234,12 +5234,13 @@ function generateAccessToken() {
|
|
|
5234
5234
|
}
|
|
5235
5235
|
function createAuthHook(token) {
|
|
5236
5236
|
return function authHook(request, reply, done) {
|
|
5237
|
-
const
|
|
5238
|
-
|
|
5239
|
-
|
|
5237
|
+
const headerToken = request.headers["x-ecode-token"];
|
|
5238
|
+
const queryToken = request.query?.["token"];
|
|
5239
|
+
if (headerToken === token || queryToken === token) {
|
|
5240
|
+
done();
|
|
5240
5241
|
return;
|
|
5241
5242
|
}
|
|
5242
|
-
|
|
5243
|
+
reply.code(401).send({ success: false, error: "Unauthorized" });
|
|
5243
5244
|
};
|
|
5244
5245
|
}
|
|
5245
5246
|
|
|
@@ -5935,6 +5936,60 @@ var require2 = createRequire(import.meta.url);
|
|
|
5935
5936
|
var { version } = require2("../package.json");
|
|
5936
5937
|
var VERSION = version;
|
|
5937
5938
|
var rawArgs = process.argv.slice(2);
|
|
5939
|
+
function isHelpFlag(arg) {
|
|
5940
|
+
return arg === "-h" || arg === "--help" || arg === "-help";
|
|
5941
|
+
}
|
|
5942
|
+
function renderRootHelp() {
|
|
5943
|
+
return `ecode \u2014 terminal + web AI coding assistant
|
|
5944
|
+
|
|
5945
|
+
Usage:
|
|
5946
|
+
ecode [options]
|
|
5947
|
+
ecode sessions <subcommand> [args]
|
|
5948
|
+
ecode web [options]
|
|
5949
|
+
|
|
5950
|
+
Options:
|
|
5951
|
+
-h, --help, -help Show help
|
|
5952
|
+
-v, --version Show version
|
|
5953
|
+
--auto Auto-approve normal shell commands
|
|
5954
|
+
--log-dir <dir> Override JSONL log directory
|
|
5955
|
+
--replay <file> Replay a session log
|
|
5956
|
+
--fork <file:turn> Fork a session log at a turn
|
|
5957
|
+
--pipe Read prompt from stdin and output JSONL
|
|
5958
|
+
|
|
5959
|
+
Commands:
|
|
5960
|
+
sessions Inspect, replay, and fork logged sessions
|
|
5961
|
+
web Start the web admin server
|
|
5962
|
+
|
|
5963
|
+
Run \`ecode sessions -h\` or \`ecode web -h\` for command-specific help.`;
|
|
5964
|
+
}
|
|
5965
|
+
function renderSessionsHelp() {
|
|
5966
|
+
return `Usage: ecode sessions <list|inspect|replay|fork> [args...]
|
|
5967
|
+
|
|
5968
|
+
list \u5217\u51FA\u6240\u6709\u5386\u53F2\u4F1A\u8BDD
|
|
5969
|
+
inspect <id> \u663E\u793A\u4F1A\u8BDD\u8BE6\u60C5
|
|
5970
|
+
replay <id> \u8F93\u51FA\u7528\u4E8E\u56DE\u653E\u7684\u547D\u4EE4
|
|
5971
|
+
fork <id> [turn] \u8F93\u51FA\u7528\u4E8E\u5206\u53C9\u5230\u6307\u5B9A\u8F6E\u6B21\u7684\u547D\u4EE4`;
|
|
5972
|
+
}
|
|
5973
|
+
function renderWebHelp() {
|
|
5974
|
+
return `Usage: ecode web [options]
|
|
5975
|
+
|
|
5976
|
+
Options:
|
|
5977
|
+
-h, --help, -help Show help
|
|
5978
|
+
--host <host> Bind host (default: 127.0.0.1)
|
|
5979
|
+
--port <port> Bind port (default: 4310)`;
|
|
5980
|
+
}
|
|
5981
|
+
if (isHelpFlag(rawArgs[0])) {
|
|
5982
|
+
console.log(renderRootHelp());
|
|
5983
|
+
process.exit(0);
|
|
5984
|
+
}
|
|
5985
|
+
if (rawArgs[0] === "sessions" && (!rawArgs[1] || isHelpFlag(rawArgs[1]))) {
|
|
5986
|
+
console.log(renderSessionsHelp());
|
|
5987
|
+
process.exit(0);
|
|
5988
|
+
}
|
|
5989
|
+
if (rawArgs[0] === "web" && isHelpFlag(rawArgs[1])) {
|
|
5990
|
+
console.log(renderWebHelp());
|
|
5991
|
+
process.exit(0);
|
|
5992
|
+
}
|
|
5938
5993
|
var autoMode = false;
|
|
5939
5994
|
var cliLogDir;
|
|
5940
5995
|
var replayFile;
|
|
@@ -6025,7 +6080,7 @@ if (rawArgs[0] === "sessions") {
|
|
|
6025
6080
|
}
|
|
6026
6081
|
if (rawArgs[0] === "web") {
|
|
6027
6082
|
let webPort = 4310;
|
|
6028
|
-
let webHost = "
|
|
6083
|
+
let webHost = "127.0.0.1";
|
|
6029
6084
|
for (let i = 1; i < rawArgs.length; i++) {
|
|
6030
6085
|
const arg = rawArgs[i];
|
|
6031
6086
|
const next = rawArgs[i + 1];
|
|
@@ -6047,11 +6102,12 @@ if (rawArgs[0] === "web") {
|
|
|
6047
6102
|
version: VERSION
|
|
6048
6103
|
});
|
|
6049
6104
|
await server.listen({ port: webPort, host: webHost });
|
|
6050
|
-
const
|
|
6105
|
+
const browserHost = webHost === "0.0.0.0" ? "localhost" : webHost;
|
|
6106
|
+
const accessUrl = `http://${browserHost}:${webPort}?token=${token}`;
|
|
6051
6107
|
console.log(`
|
|
6052
6108
|
ecode web admin started`);
|
|
6053
|
-
console.log(`
|
|
6054
|
-
console.log(`
|
|
6109
|
+
console.log(` Bind: ${webHost}:${webPort}`);
|
|
6110
|
+
console.log(` URL: ${accessUrl}`);
|
|
6055
6111
|
console.log(`
|
|
6056
6112
|
Press Ctrl+C to stop.
|
|
6057
6113
|
`);
|