ccpanel 0.1.7 → 0.2.0
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/server/app.ts
|
|
2
|
-
import { Hono as
|
|
2
|
+
import { Hono as Hono12 } from "hono";
|
|
3
3
|
import { serveStatic } from "@hono/node-server/serve-static";
|
|
4
4
|
import { ZodError } from "zod";
|
|
5
5
|
|
|
@@ -182,6 +182,17 @@ var ConfigFileWriteSchema = z.object({
|
|
|
182
182
|
content: z.string(),
|
|
183
183
|
baseMtime: BaseMtimeSchema
|
|
184
184
|
});
|
|
185
|
+
var ShellFileIdSchema = z.enum([
|
|
186
|
+
"bashrc",
|
|
187
|
+
"bash-profile",
|
|
188
|
+
"zshrc",
|
|
189
|
+
"zprofile",
|
|
190
|
+
"profile"
|
|
191
|
+
]);
|
|
192
|
+
var ShellFileWriteSchema = z.object({
|
|
193
|
+
content: z.string(),
|
|
194
|
+
baseMtime: BaseMtimeSchema
|
|
195
|
+
});
|
|
185
196
|
var ScopeQuerySchema = z.object({
|
|
186
197
|
scope: ScopeSchema,
|
|
187
198
|
projectPath: z.string().optional()
|
|
@@ -628,9 +639,26 @@ function agentCommandRoutes(deps, kind) {
|
|
|
628
639
|
return app;
|
|
629
640
|
}
|
|
630
641
|
|
|
642
|
+
// src/server/routes/shell-files.ts
|
|
643
|
+
import { Hono as Hono11 } from "hono";
|
|
644
|
+
function shellFileRoutes(deps) {
|
|
645
|
+
const app = new Hono11();
|
|
646
|
+
app.get("/:file", async (c) => {
|
|
647
|
+
const fileId = ShellFileIdSchema.parse(c.req.param("file"));
|
|
648
|
+
return c.json(await deps.shellFiles.read(fileId));
|
|
649
|
+
});
|
|
650
|
+
app.put("/:file", async (c) => {
|
|
651
|
+
const fileId = ShellFileIdSchema.parse(c.req.param("file"));
|
|
652
|
+
const { content, baseMtime } = ShellFileWriteSchema.parse(await c.req.json());
|
|
653
|
+
await deps.shellFiles.write(fileId, content, baseMtime);
|
|
654
|
+
return c.json({ ok: true });
|
|
655
|
+
});
|
|
656
|
+
return app;
|
|
657
|
+
}
|
|
658
|
+
|
|
631
659
|
// src/server/app.ts
|
|
632
660
|
function createApp(deps) {
|
|
633
|
-
const app = new
|
|
661
|
+
const app = new Hono12();
|
|
634
662
|
app.onError((err, c) => {
|
|
635
663
|
if (err instanceof ZodError) {
|
|
636
664
|
return c.json({ error: "\u6821\u9A8C\u5931\u8D25", issues: err.issues }, 400);
|
|
@@ -655,6 +683,7 @@ function createApp(deps) {
|
|
|
655
683
|
app.route("/api/sessions", sessionRoutes(deps));
|
|
656
684
|
app.route("/api/plugins", pluginRoutes(deps));
|
|
657
685
|
app.route("/api/config-files", configFileRoutes(deps));
|
|
686
|
+
app.route("/api/shell-files", shellFileRoutes(deps));
|
|
658
687
|
app.route("/api/agents", agentCommandRoutes(deps, "agents"));
|
|
659
688
|
app.route("/api/commands", agentCommandRoutes(deps, "commands"));
|
|
660
689
|
app.use("/*", serveStatic({ root: deps.webRoot ?? "./web/dist" }));
|
package/dist/cli.js
CHANGED
|
@@ -8,11 +8,11 @@ import {
|
|
|
8
8
|
assertNoConflict,
|
|
9
9
|
createApp,
|
|
10
10
|
currentMtime
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-ENKQJGKM.js";
|
|
12
12
|
|
|
13
13
|
// src/cli.ts
|
|
14
14
|
import { homedir, networkInterfaces } from "os";
|
|
15
|
-
import { join as
|
|
15
|
+
import { join as join13 } from "path";
|
|
16
16
|
import { createServer } from "net";
|
|
17
17
|
import { fileURLToPath } from "url";
|
|
18
18
|
import { realpathSync } from "fs";
|
|
@@ -2026,6 +2026,43 @@ var SyncService = class {
|
|
|
2026
2026
|
}
|
|
2027
2027
|
};
|
|
2028
2028
|
|
|
2029
|
+
// src/core/shell-file-service.ts
|
|
2030
|
+
import { readFile as readFile12 } from "fs/promises";
|
|
2031
|
+
import { join as join12 } from "path";
|
|
2032
|
+
var FILE_NAMES = {
|
|
2033
|
+
bashrc: ".bashrc",
|
|
2034
|
+
"bash-profile": ".bash_profile",
|
|
2035
|
+
zshrc: ".zshrc",
|
|
2036
|
+
zprofile: ".zprofile",
|
|
2037
|
+
profile: ".profile"
|
|
2038
|
+
};
|
|
2039
|
+
var ShellFileService = class {
|
|
2040
|
+
constructor(store, home) {
|
|
2041
|
+
this.store = store;
|
|
2042
|
+
this.home = home;
|
|
2043
|
+
}
|
|
2044
|
+
store;
|
|
2045
|
+
home;
|
|
2046
|
+
path(fileId) {
|
|
2047
|
+
return join12(this.home, FILE_NAMES[fileId]);
|
|
2048
|
+
}
|
|
2049
|
+
// 文件不存在视为「尚未创建」,返回空串与 null mtime(与 ConfigFileService 一致)。
|
|
2050
|
+
async read(fileId) {
|
|
2051
|
+
const file = this.path(fileId);
|
|
2052
|
+
try {
|
|
2053
|
+
return { content: await readFile12(file, "utf8"), mtime: await currentMtime(file) };
|
|
2054
|
+
} catch (err) {
|
|
2055
|
+
if (err.code === "ENOENT") return { content: "", mtime: null };
|
|
2056
|
+
throw err;
|
|
2057
|
+
}
|
|
2058
|
+
}
|
|
2059
|
+
async write(fileId, content, baseMtime) {
|
|
2060
|
+
const file = this.path(fileId);
|
|
2061
|
+
await assertNoConflict(file, baseMtime);
|
|
2062
|
+
await this.store.writeText(file, content);
|
|
2063
|
+
}
|
|
2064
|
+
};
|
|
2065
|
+
|
|
2029
2066
|
// src/cli.ts
|
|
2030
2067
|
function findFreePort(start) {
|
|
2031
2068
|
return new Promise((resolve8, reject) => {
|
|
@@ -2042,14 +2079,14 @@ function findFreePort(start) {
|
|
|
2042
2079
|
async function main() {
|
|
2043
2080
|
const home = homedir();
|
|
2044
2081
|
const store = new ConfigStore();
|
|
2045
|
-
const registryFile =
|
|
2082
|
+
const registryFile = join13(home, ".ccpanel", "ccpanel-projects.json");
|
|
2046
2083
|
const webRoot = fileURLToPath(new URL("../web/dist", import.meta.url));
|
|
2047
2084
|
const app = createApp({
|
|
2048
2085
|
home,
|
|
2049
2086
|
store,
|
|
2050
2087
|
mcp: new McpService(store),
|
|
2051
2088
|
skills: new SkillService(),
|
|
2052
|
-
projects: new ProjectService(store, registryFile,
|
|
2089
|
+
projects: new ProjectService(store, registryFile, join13(home, ".claude.json")),
|
|
2053
2090
|
memory: new MemoryService(),
|
|
2054
2091
|
memoryFiles: new MemoryFilesService(),
|
|
2055
2092
|
sessions: new SessionService(),
|
|
@@ -2060,6 +2097,7 @@ async function main() {
|
|
|
2060
2097
|
configFiles: new ConfigFileService(store),
|
|
2061
2098
|
agentCommands: new AgentCommandService(),
|
|
2062
2099
|
sync: new SyncService(home),
|
|
2100
|
+
shellFiles: new ShellFileService(store, home),
|
|
2063
2101
|
registryFile,
|
|
2064
2102
|
webRoot
|
|
2065
2103
|
});
|
package/dist/server/app.js
CHANGED