jinzd-ai-cli 0.4.158 → 0.4.159
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/{batch-OZMO6RYN.js → batch-KIILPYHR.js} +2 -2
- package/dist/{chunk-XM2OQUU6.js → chunk-2QG5X6MP.js} +1 -1
- package/dist/{chunk-42NJBSWM.js → chunk-HMP5B62N.js} +1 -1
- package/dist/{chunk-EGPR6N2V.js → chunk-KIDZGNSY.js} +1 -1
- package/dist/{chunk-O2DTCEFR.js → chunk-LFZPDZAJ.js} +1 -1
- package/dist/{chunk-OQIOCWRQ.js → chunk-P5IF6HHE.js} +1 -1
- package/dist/{chunk-DLCRWPOH.js → chunk-PRM3WBVJ.js} +2 -2
- package/dist/{chunk-QBA2FGN7.js → chunk-X6DB62UQ.js} +1 -1
- package/dist/{chunk-F5EIB4RL.js → chunk-XRCOA5BM.js} +3 -3
- package/dist/{ci-GXPDJQN5.js → ci-BBGNA27B.js} +2 -2
- package/dist/{constants-ULU6R4KD.js → constants-UJRWM4GF.js} +1 -1
- package/dist/{doctor-cli-CKZLEQNH.js → doctor-cli-MS3TNDZN.js} +4 -4
- package/dist/electron-server.js +2 -2
- package/dist/{hub-OLRMJ55R.js → hub-YOTYEDR6.js} +1 -1
- package/dist/index.js +15 -15
- package/dist/{run-tests-DBQ5ISUY.js → run-tests-2XBWWVGO.js} +2 -2
- package/dist/{run-tests-25AJ4GFH.js → run-tests-XU2DSE36.js} +1 -1
- package/dist/{server-Z3UEW3S7.js → server-FAMTEGDZ.js} +7 -7
- package/dist/{server-CFOYC72D.js → server-FF3DFTAS.js} +4 -4
- package/dist/{task-orchestrator-KSSPHRG5.js → task-orchestrator-RTZJSVVR.js} +4 -4
- package/dist/web/client/index.html +13 -1
- package/dist/web/client/sw.js +33 -19
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
ConfigManager
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-KIDZGNSY.js";
|
|
5
5
|
import "./chunk-2ZD3YTVM.js";
|
|
6
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-X6DB62UQ.js";
|
|
7
7
|
import "./chunk-PDX44BCA.js";
|
|
8
8
|
|
|
9
9
|
// src/cli/batch.ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
truncateForPersist
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-XRCOA5BM.js";
|
|
5
5
|
import {
|
|
6
6
|
APP_NAME,
|
|
7
7
|
CONFIG_DIR_NAME,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
MCP_PROTOCOL_VERSION,
|
|
12
12
|
MCP_TOOL_PREFIX,
|
|
13
13
|
VERSION
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-X6DB62UQ.js";
|
|
15
15
|
|
|
16
16
|
// src/mcp/client.ts
|
|
17
17
|
import { spawn } from "child_process";
|
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
} from "./chunk-HDSKW7Q3.js";
|
|
6
6
|
import {
|
|
7
7
|
runTestsTool
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-P5IF6HHE.js";
|
|
9
9
|
import {
|
|
10
10
|
runTool
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-2QG5X6MP.js";
|
|
12
12
|
import {
|
|
13
13
|
getDangerLevel,
|
|
14
14
|
isFileWriteTool
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
SUBAGENT_ALLOWED_TOOLS,
|
|
26
26
|
SUBAGENT_DEFAULT_MAX_ROUNDS,
|
|
27
27
|
SUBAGENT_MAX_ROUNDS_LIMIT
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-X6DB62UQ.js";
|
|
29
29
|
import {
|
|
30
30
|
fileCheckpoints
|
|
31
31
|
} from "./chunk-4BKXL7SM.js";
|
|
@@ -10,11 +10,11 @@ import {
|
|
|
10
10
|
import "./chunk-NXXNLLSG.js";
|
|
11
11
|
import {
|
|
12
12
|
ConfigManager
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-KIDZGNSY.js";
|
|
14
14
|
import "./chunk-2ZD3YTVM.js";
|
|
15
15
|
import {
|
|
16
16
|
VERSION
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-X6DB62UQ.js";
|
|
18
18
|
import "./chunk-PDX44BCA.js";
|
|
19
19
|
|
|
20
20
|
// src/cli/ci.ts
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
getConfigDirUsage,
|
|
4
4
|
listRecentCrashes
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-HMP5B62N.js";
|
|
6
6
|
import {
|
|
7
7
|
ProviderRegistry
|
|
8
8
|
} from "./chunk-AIZOARZY.js";
|
|
@@ -11,17 +11,17 @@ import {
|
|
|
11
11
|
getTopFailingTools,
|
|
12
12
|
getTopUsedTools,
|
|
13
13
|
resetStats
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-2QG5X6MP.js";
|
|
15
15
|
import "./chunk-NXXNLLSG.js";
|
|
16
16
|
import {
|
|
17
17
|
ConfigManager
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-KIDZGNSY.js";
|
|
19
19
|
import "./chunk-2ZD3YTVM.js";
|
|
20
20
|
import {
|
|
21
21
|
DEV_STATE_FILE_NAME,
|
|
22
22
|
MEMORY_FILE_NAME,
|
|
23
23
|
VERSION
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-X6DB62UQ.js";
|
|
25
25
|
import "./chunk-PDX44BCA.js";
|
|
26
26
|
|
|
27
27
|
// src/diagnostics/doctor-cli.ts
|
package/dist/electron-server.js
CHANGED
|
@@ -36,7 +36,7 @@ import {
|
|
|
36
36
|
VERSION,
|
|
37
37
|
buildUserIdentityPrompt,
|
|
38
38
|
runTestsTool
|
|
39
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-LFZPDZAJ.js";
|
|
40
40
|
import {
|
|
41
41
|
hasSemanticIndex,
|
|
42
42
|
semanticSearch
|
|
@@ -13429,7 +13429,7 @@ ${undoResults.map((r) => ` \u2022 ${r}`).join("\n")}` });
|
|
|
13429
13429
|
case "test": {
|
|
13430
13430
|
this.send({ type: "info", message: "\u{1F9EA} Running tests..." });
|
|
13431
13431
|
try {
|
|
13432
|
-
const { executeTests } = await import("./run-tests-
|
|
13432
|
+
const { executeTests } = await import("./run-tests-XU2DSE36.js");
|
|
13433
13433
|
const argStr = args.join(" ").trim();
|
|
13434
13434
|
let testArgs = {};
|
|
13435
13435
|
if (argStr) {
|
|
@@ -155,7 +155,7 @@ ${content}`);
|
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
async function runTaskMode(config, providers, configManager, topic) {
|
|
158
|
-
const { TaskOrchestrator } = await import("./task-orchestrator-
|
|
158
|
+
const { TaskOrchestrator } = await import("./task-orchestrator-RTZJSVVR.js");
|
|
159
159
|
const orchestrator = new TaskOrchestrator(config, providers, configManager);
|
|
160
160
|
let interrupted = false;
|
|
161
161
|
const onSigint = () => {
|
package/dist/index.js
CHANGED
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
saveDevState,
|
|
19
19
|
sessionHasMeaningfulContent,
|
|
20
20
|
setupProxy
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-PRM3WBVJ.js";
|
|
22
22
|
import {
|
|
23
23
|
ToolExecutor,
|
|
24
24
|
ToolRegistry,
|
|
@@ -37,10 +37,10 @@ import {
|
|
|
37
37
|
spawnAgentContext,
|
|
38
38
|
theme,
|
|
39
39
|
undoStack
|
|
40
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-XRCOA5BM.js";
|
|
41
41
|
import "./chunk-HDSKW7Q3.js";
|
|
42
42
|
import "./chunk-ZWVIDFGY.js";
|
|
43
|
-
import "./chunk-
|
|
43
|
+
import "./chunk-P5IF6HHE.js";
|
|
44
44
|
import {
|
|
45
45
|
SessionManager,
|
|
46
46
|
getContentText
|
|
@@ -49,7 +49,7 @@ import {
|
|
|
49
49
|
getConfigDirUsage,
|
|
50
50
|
listRecentCrashes,
|
|
51
51
|
writeCrashLog
|
|
52
|
-
} from "./chunk-
|
|
52
|
+
} from "./chunk-HMP5B62N.js";
|
|
53
53
|
import {
|
|
54
54
|
CONTENT_ONLY_STREAM_REMINDER,
|
|
55
55
|
HALLUCINATION_CORRECTION_MESSAGE,
|
|
@@ -73,11 +73,11 @@ import {
|
|
|
73
73
|
getTopFailingTools,
|
|
74
74
|
getTopUsedTools,
|
|
75
75
|
installFlushOnExit
|
|
76
|
-
} from "./chunk-
|
|
76
|
+
} from "./chunk-2QG5X6MP.js";
|
|
77
77
|
import "./chunk-NXXNLLSG.js";
|
|
78
78
|
import {
|
|
79
79
|
ConfigManager
|
|
80
|
-
} from "./chunk-
|
|
80
|
+
} from "./chunk-KIDZGNSY.js";
|
|
81
81
|
import {
|
|
82
82
|
AuthError,
|
|
83
83
|
ProviderError,
|
|
@@ -104,7 +104,7 @@ import {
|
|
|
104
104
|
SKILLS_DIR_NAME,
|
|
105
105
|
VERSION,
|
|
106
106
|
buildUserIdentityPrompt
|
|
107
|
-
} from "./chunk-
|
|
107
|
+
} from "./chunk-X6DB62UQ.js";
|
|
108
108
|
import {
|
|
109
109
|
formatGitContextForPrompt,
|
|
110
110
|
getGitContext,
|
|
@@ -1773,7 +1773,7 @@ No tools match "${filter}".
|
|
|
1773
1773
|
const { join: join6 } = await import("path");
|
|
1774
1774
|
const { existsSync: existsSync6 } = await import("fs");
|
|
1775
1775
|
const { getGitRoot: getGitRoot2 } = await import("./git-context-7KIP4X2V.js");
|
|
1776
|
-
const { MCP_PROJECT_CONFIG_NAME: MCP_PROJECT_CONFIG_NAME2 } = await import("./constants-
|
|
1776
|
+
const { MCP_PROJECT_CONFIG_NAME: MCP_PROJECT_CONFIG_NAME2 } = await import("./constants-UJRWM4GF.js");
|
|
1777
1777
|
const { approveProject, hashMcpFile } = await import("./project-trust-IFM7FXEV.js");
|
|
1778
1778
|
const cwd = process.cwd();
|
|
1779
1779
|
const projectRoot = getGitRoot2(cwd) ?? cwd;
|
|
@@ -2834,7 +2834,7 @@ ${hint}` : "")
|
|
|
2834
2834
|
usage: "/test [command|filter]",
|
|
2835
2835
|
async execute(args, ctx) {
|
|
2836
2836
|
try {
|
|
2837
|
-
const { executeTests } = await import("./run-tests-
|
|
2837
|
+
const { executeTests } = await import("./run-tests-2XBWWVGO.js");
|
|
2838
2838
|
const argStr = args.join(" ").trim();
|
|
2839
2839
|
let testArgs = {};
|
|
2840
2840
|
if (argStr) {
|
|
@@ -7534,7 +7534,7 @@ program.command("web").description("Start Web UI server with browser-based chat
|
|
|
7534
7534
|
console.error("Error: Invalid port number. Must be between 1 and 65535.");
|
|
7535
7535
|
process.exit(1);
|
|
7536
7536
|
}
|
|
7537
|
-
const { startWebServer } = await import("./server-
|
|
7537
|
+
const { startWebServer } = await import("./server-FAMTEGDZ.js");
|
|
7538
7538
|
await startWebServer({ port, host: options.host });
|
|
7539
7539
|
});
|
|
7540
7540
|
program.command("user [action] [username]").description("Manage Web UI users (list | create <name> | delete <name> | reset-password <name> | logout-all <name> | migrate <name>)").action(async (action, username) => {
|
|
@@ -7701,12 +7701,12 @@ program.command("sessions").description("List recent conversation sessions").opt
|
|
|
7701
7701
|
console.log(footer + "\n");
|
|
7702
7702
|
});
|
|
7703
7703
|
program.command("doctor").description("Health check: API keys, config, MCP, recent crashes, tool usage, disk usage").option("--json", "Output as JSON (for scripting)").option("--reset-stats", "Reset accumulated tool usage statistics").action(async (options) => {
|
|
7704
|
-
const { runDoctorCli } = await import("./doctor-cli-
|
|
7704
|
+
const { runDoctorCli } = await import("./doctor-cli-MS3TNDZN.js");
|
|
7705
7705
|
await runDoctorCli({ json: !!options.json, resetStats: !!options.resetStats });
|
|
7706
7706
|
});
|
|
7707
7707
|
program.command("batch <action> [arg] [arg2]").description("Anthropic Message Batches: submit | list | status <id> | results <id> [out] | cancel <id>").option("--dry-run", "Parse and validate input without submitting (submit only)").action(async (action, arg, arg2, options) => {
|
|
7708
7708
|
try {
|
|
7709
|
-
const batch = await import("./batch-
|
|
7709
|
+
const batch = await import("./batch-KIILPYHR.js");
|
|
7710
7710
|
switch (action) {
|
|
7711
7711
|
case "submit":
|
|
7712
7712
|
if (!arg) {
|
|
@@ -7749,7 +7749,7 @@ program.command("batch <action> [arg] [arg2]").description("Anthropic Message Ba
|
|
|
7749
7749
|
}
|
|
7750
7750
|
});
|
|
7751
7751
|
program.command("mcp-serve").description("Start an MCP server over STDIO, exposing aicli's built-in tools to Claude Desktop / Cursor / other MCP clients").option("--allow-destructive", "Allow bash / run_interactive / task_create (always destructive in MCP mode)").option("--allow-outside-cwd", "Allow tool path arguments to escape the sandbox root \u2014 disabled by default").option("--tools <list>", "Comma-separated whitelist of tools to expose (default: all eligible tools)").option("--cwd <path>", "Working directory AND sandbox root (default: current directory)").action(async (options) => {
|
|
7752
|
-
const { startMcpServer } = await import("./server-
|
|
7752
|
+
const { startMcpServer } = await import("./server-FF3DFTAS.js");
|
|
7753
7753
|
await startMcpServer({
|
|
7754
7754
|
allowDestructive: !!options.allowDestructive,
|
|
7755
7755
|
allowOutsideCwd: !!options.allowOutsideCwd,
|
|
@@ -7758,7 +7758,7 @@ program.command("mcp-serve").description("Start an MCP server over STDIO, exposi
|
|
|
7758
7758
|
});
|
|
7759
7759
|
});
|
|
7760
7760
|
program.command("ci").description("Headless PR review (code + security) \u2014 reads git/gh diff, optionally posts to PR. Designed for GitHub Actions.").option("--pr <num>", "PR number; diff fetched via `gh pr diff <num>`", (v) => parseInt(v, 10)).option("--base <ref>", "Base ref for `git diff <ref>...HEAD` (ignored when --pr set)").option("--post", "Post review as a PR comment (requires gh CLI + GH_TOKEN, needs --pr)").option("--no-update", "Always create a new comment instead of updating the previous aicli review").option("--skip-code", "Skip the code review section").option("--skip-security", "Skip the security review section").option("--detailed", "Use the detailed code-review prompt").option("--max-diff <n>", "Max diff chars sent to the model (default 30000)", (v) => parseInt(v, 10)).option("--provider <id>", "Override provider (default: config.defaultProvider)").option("--model <id>", "Override model").option("--dry-run", "Print result to stdout instead of posting (overrides --post)").action(async (options) => {
|
|
7761
|
-
const { runCi } = await import("./ci-
|
|
7761
|
+
const { runCi } = await import("./ci-BBGNA27B.js");
|
|
7762
7762
|
const result = await runCi({
|
|
7763
7763
|
pr: options.pr,
|
|
7764
7764
|
base: options.base,
|
|
@@ -7903,7 +7903,7 @@ program.command("hub [topic]").description("Start multi-agent hub (discuss / bra
|
|
|
7903
7903
|
}),
|
|
7904
7904
|
config.get("customProviders")
|
|
7905
7905
|
);
|
|
7906
|
-
const { startHub } = await import("./hub-
|
|
7906
|
+
const { startHub } = await import("./hub-YOTYEDR6.js");
|
|
7907
7907
|
await startHub(
|
|
7908
7908
|
{
|
|
7909
7909
|
topic: topic ?? "",
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
loadDevState,
|
|
22
22
|
persistToolRound,
|
|
23
23
|
setupProxy
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-PRM3WBVJ.js";
|
|
25
25
|
import {
|
|
26
26
|
ToolExecutor,
|
|
27
27
|
ToolRegistry,
|
|
@@ -39,10 +39,10 @@ import {
|
|
|
39
39
|
spawnAgentContext,
|
|
40
40
|
truncateOutput,
|
|
41
41
|
undoStack
|
|
42
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-XRCOA5BM.js";
|
|
43
43
|
import "./chunk-HDSKW7Q3.js";
|
|
44
44
|
import "./chunk-ZWVIDFGY.js";
|
|
45
|
-
import "./chunk-
|
|
45
|
+
import "./chunk-P5IF6HHE.js";
|
|
46
46
|
import {
|
|
47
47
|
SessionManager,
|
|
48
48
|
getContentText
|
|
@@ -63,13 +63,13 @@ import {
|
|
|
63
63
|
} from "./chunk-AIZOARZY.js";
|
|
64
64
|
import {
|
|
65
65
|
runTool
|
|
66
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-2QG5X6MP.js";
|
|
67
67
|
import {
|
|
68
68
|
getDangerLevel
|
|
69
69
|
} from "./chunk-NXXNLLSG.js";
|
|
70
70
|
import {
|
|
71
71
|
ConfigManager
|
|
72
|
-
} from "./chunk-
|
|
72
|
+
} from "./chunk-KIDZGNSY.js";
|
|
73
73
|
import "./chunk-2ZD3YTVM.js";
|
|
74
74
|
import {
|
|
75
75
|
AGENTIC_BEHAVIOR_GUIDELINE,
|
|
@@ -89,7 +89,7 @@ import {
|
|
|
89
89
|
SKILLS_DIR_NAME,
|
|
90
90
|
VERSION,
|
|
91
91
|
buildUserIdentityPrompt
|
|
92
|
-
} from "./chunk-
|
|
92
|
+
} from "./chunk-X6DB62UQ.js";
|
|
93
93
|
import {
|
|
94
94
|
formatGitContextForPrompt,
|
|
95
95
|
getGitContext,
|
|
@@ -2575,7 +2575,7 @@ ${undoResults.map((r) => ` \u2022 ${r}`).join("\n")}` });
|
|
|
2575
2575
|
case "test": {
|
|
2576
2576
|
this.send({ type: "info", message: "\u{1F9EA} Running tests..." });
|
|
2577
2577
|
try {
|
|
2578
|
-
const { executeTests } = await import("./run-tests-
|
|
2578
|
+
const { executeTests } = await import("./run-tests-2XBWWVGO.js");
|
|
2579
2579
|
const argStr = args.join(" ").trim();
|
|
2580
2580
|
let testArgs = {};
|
|
2581
2581
|
if (argStr) {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
ToolRegistry
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-XRCOA5BM.js";
|
|
5
5
|
import "./chunk-HDSKW7Q3.js";
|
|
6
6
|
import "./chunk-ZWVIDFGY.js";
|
|
7
|
-
import "./chunk-
|
|
7
|
+
import "./chunk-P5IF6HHE.js";
|
|
8
8
|
import {
|
|
9
9
|
runTool
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-2QG5X6MP.js";
|
|
11
11
|
import {
|
|
12
12
|
getDangerLevel,
|
|
13
13
|
schemaToJsonSchema
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
import "./chunk-2ZD3YTVM.js";
|
|
16
16
|
import {
|
|
17
17
|
VERSION
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-X6DB62UQ.js";
|
|
19
19
|
import "./chunk-4BKXL7SM.js";
|
|
20
20
|
import "./chunk-MM3F43H6.js";
|
|
21
21
|
import "./chunk-KHYD3WXE.js";
|
|
@@ -3,20 +3,20 @@ import {
|
|
|
3
3
|
ToolRegistry,
|
|
4
4
|
googleSearchContext,
|
|
5
5
|
truncateOutput
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-XRCOA5BM.js";
|
|
7
7
|
import "./chunk-HDSKW7Q3.js";
|
|
8
8
|
import "./chunk-ZWVIDFGY.js";
|
|
9
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-P5IF6HHE.js";
|
|
10
10
|
import {
|
|
11
11
|
runTool
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-2QG5X6MP.js";
|
|
13
13
|
import {
|
|
14
14
|
getDangerLevel
|
|
15
15
|
} from "./chunk-NXXNLLSG.js";
|
|
16
16
|
import "./chunk-2ZD3YTVM.js";
|
|
17
17
|
import {
|
|
18
18
|
SUBAGENT_ALLOWED_TOOLS
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-X6DB62UQ.js";
|
|
20
20
|
import "./chunk-4BKXL7SM.js";
|
|
21
21
|
import "./chunk-MM3F43H6.js";
|
|
22
22
|
import "./chunk-KHYD3WXE.js";
|
|
@@ -339,8 +339,20 @@
|
|
|
339
339
|
|
|
340
340
|
<script src="app.js"></script>
|
|
341
341
|
<script>
|
|
342
|
+
// Self-updating service worker (v0.4.159). A new SW postMessages
|
|
343
|
+
// 'sw-updated' (and triggers controllerchange) when it takes over; we
|
|
344
|
+
// reload once so the user never gets stuck on a stale index.html/app.js
|
|
345
|
+
// after upgrading aicli. index.html/app.js are also network-only in sw.js.
|
|
342
346
|
if ('serviceWorker' in navigator) {
|
|
343
|
-
|
|
347
|
+
let swReloaded = false;
|
|
348
|
+
const reloadOnce = () => { if (!swReloaded) { swReloaded = true; location.reload(); } };
|
|
349
|
+
navigator.serviceWorker.addEventListener('message', (e) => {
|
|
350
|
+
if (e.data && e.data.type === 'sw-updated') reloadOnce();
|
|
351
|
+
});
|
|
352
|
+
navigator.serviceWorker.addEventListener('controllerchange', reloadOnce);
|
|
353
|
+
navigator.serviceWorker.register('sw.js').then((reg) => {
|
|
354
|
+
reg.update();
|
|
355
|
+
}).catch(() => {});
|
|
344
356
|
}
|
|
345
357
|
</script>
|
|
346
358
|
</body>
|
package/dist/web/client/sw.js
CHANGED
|
@@ -4,19 +4,24 @@
|
|
|
4
4
|
* API calls and WebSocket are always network-first.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
// v0.4.
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
|
|
7
|
+
// v0.4.159: self-updating SW. Bumped to v3. The old v1/v2 service workers kept
|
|
8
|
+
// serving a stale index.html/app.js (no Hub tab, broken Light theme) because a
|
|
9
|
+
// new SW only "waits" — it never told the page to reload. Now: install →
|
|
10
|
+
// skipWaiting (take over immediately), activate → evict old caches + claim +
|
|
11
|
+
// postMessage('reload') so every open tab refreshes once onto the new version.
|
|
12
|
+
// index.html / app.js are NEVER cached (always network), so a plain refresh
|
|
13
|
+
// after upgrade is enough even before the SW turns over.
|
|
14
|
+
const CACHE_NAME = 'aicli-v3';
|
|
11
15
|
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
16
|
+
// HTML/JS that must always be fresh — never served from the SW cache, so an
|
|
17
|
+
// upgraded server is reflected on the very next load. Other assets (vendored
|
|
18
|
+
// CSS/JS, icons) are large + content-stable and fine to cache.
|
|
19
|
+
const NEVER_CACHE = new Set(['/', '/index.html', '/app.js']);
|
|
20
|
+
|
|
21
|
+
// App shell to precache (offline-capable startup). Deliberately EXCLUDES the
|
|
22
|
+
// always-fresh HTML/JS in NEVER_CACHE — only large content-stable assets.
|
|
15
23
|
const APP_SHELL = [
|
|
16
|
-
'/',
|
|
17
|
-
'/index.html',
|
|
18
24
|
'/style.css',
|
|
19
|
-
'/app.js',
|
|
20
25
|
'/manifest.json',
|
|
21
26
|
'/icon.svg',
|
|
22
27
|
'/icon-192.png',
|
|
@@ -30,6 +35,7 @@ const APP_SHELL = [
|
|
|
30
35
|
];
|
|
31
36
|
|
|
32
37
|
self.addEventListener('install', (event) => {
|
|
38
|
+
// Take over immediately rather than waiting for all old tabs to close.
|
|
33
39
|
event.waitUntil(
|
|
34
40
|
caches.open(CACHE_NAME)
|
|
35
41
|
.then(cache => cache.addAll(APP_SHELL))
|
|
@@ -39,25 +45,33 @@ self.addEventListener('install', (event) => {
|
|
|
39
45
|
|
|
40
46
|
self.addEventListener('activate', (event) => {
|
|
41
47
|
event.waitUntil(
|
|
42
|
-
caches.keys()
|
|
43
|
-
Promise.all(keys
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
caches.keys()
|
|
49
|
+
.then(keys => Promise.all(keys.filter(k => k !== CACHE_NAME).map(k => caches.delete(k))))
|
|
50
|
+
.then(() => self.clients.claim())
|
|
51
|
+
.then(async () => {
|
|
52
|
+
// Tell every open tab a new version is live so it can reload once.
|
|
53
|
+
const clients = await self.clients.matchAll({ type: 'window' });
|
|
54
|
+
for (const c of clients) c.postMessage({ type: 'sw-updated' });
|
|
55
|
+
})
|
|
48
56
|
);
|
|
49
57
|
});
|
|
50
58
|
|
|
51
59
|
self.addEventListener('fetch', (event) => {
|
|
52
60
|
const url = new URL(event.request.url);
|
|
53
61
|
|
|
54
|
-
// Never
|
|
62
|
+
// Never intercept API calls or WebSocket upgrades.
|
|
55
63
|
if (url.pathname.startsWith('/api/') || event.request.headers.get('upgrade') === 'websocket') {
|
|
56
64
|
return;
|
|
57
65
|
}
|
|
58
66
|
|
|
59
|
-
//
|
|
60
|
-
//
|
|
67
|
+
// Always-fresh HTML/JS: network-only, never touch the cache. Guarantees an
|
|
68
|
+
// upgraded server shows up on the next load even if the SW hasn't turned over.
|
|
69
|
+
if (NEVER_CACHE.has(url.pathname)) {
|
|
70
|
+
event.respondWith(fetch(event.request).catch(() => caches.match(event.request)));
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Everything else: network-first with cache fallback (offline support).
|
|
61
75
|
event.respondWith(
|
|
62
76
|
fetch(event.request)
|
|
63
77
|
.then(response => {
|