@archon-claw/cli 0.1.0 → 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.
- package/dist/cli.js +120 -28
- package/dist/dev.d.ts +8 -8
- package/dist/dev.js +115 -66
- package/dist/mcp-server.d.ts +5 -0
- package/dist/mcp-server.js +106 -0
- package/dist/public/assets/{chat-input-Cx9bd-IU.js → chat-input-Cpyxmt8J.js} +54 -54
- package/dist/public/assets/embed-CIS9O-0V.js +1 -0
- package/dist/public/assets/main-CfVKtiE-.js +16 -0
- package/dist/public/embed.html +2 -2
- package/dist/public/index.html +2 -2
- package/dist/scaffold.d.ts +7 -2
- package/dist/scaffold.js +61 -25
- package/dist/server.d.ts +8 -1
- package/dist/server.js +162 -120
- package/dist/session.d.ts +13 -7
- package/dist/session.js +74 -70
- package/dist/templates/workspace/README.md +13 -0
- package/dist/templates/workspace/package.json +17 -0
- package/package.json +4 -2
- package/dist/public/assets/embed-Cn1IPR8U.js +0 -1
- package/dist/public/assets/main-CAioKyQy.js +0 -16
package/dist/session.js
CHANGED
|
@@ -1,82 +1,86 @@
|
|
|
1
1
|
import crypto from "node:crypto";
|
|
2
2
|
import fs from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
await fs.mkdir(sessionsDir, { recursive: true });
|
|
10
|
-
}
|
|
11
|
-
function sessionPath(id) {
|
|
12
|
-
return path.join(sessionsDir, `${id}.json`);
|
|
13
|
-
}
|
|
14
|
-
export async function saveSession(session) {
|
|
15
|
-
session.updatedAt = Date.now();
|
|
16
|
-
sessionCache.set(session.id, session);
|
|
17
|
-
await fs.writeFile(sessionPath(session.id), JSON.stringify(session, null, 2));
|
|
18
|
-
}
|
|
19
|
-
export async function createSession() {
|
|
20
|
-
const now = Date.now();
|
|
21
|
-
const session = {
|
|
22
|
-
id: crypto.randomUUID(),
|
|
23
|
-
messages: [],
|
|
24
|
-
createdAt: now,
|
|
25
|
-
updatedAt: now,
|
|
26
|
-
};
|
|
27
|
-
await saveSession(session);
|
|
28
|
-
return session;
|
|
29
|
-
}
|
|
30
|
-
export async function getSession(id) {
|
|
31
|
-
const cached = sessionCache.get(id);
|
|
32
|
-
if (cached)
|
|
33
|
-
return cached;
|
|
34
|
-
try {
|
|
35
|
-
const data = await fs.readFile(sessionPath(id), "utf-8");
|
|
36
|
-
const session = JSON.parse(data);
|
|
37
|
-
sessionCache.set(id, session);
|
|
38
|
-
return session;
|
|
4
|
+
export class SessionStore {
|
|
5
|
+
dir;
|
|
6
|
+
cache = new Map();
|
|
7
|
+
constructor(agentDir) {
|
|
8
|
+
this.dir = path.join(agentDir, "sessions");
|
|
39
9
|
}
|
|
40
|
-
|
|
41
|
-
|
|
10
|
+
async init() {
|
|
11
|
+
this.cache.clear();
|
|
12
|
+
await fs.mkdir(this.dir, { recursive: true });
|
|
42
13
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (id) {
|
|
46
|
-
const existing = await getSession(id);
|
|
47
|
-
if (existing)
|
|
48
|
-
return existing;
|
|
14
|
+
filePath(id) {
|
|
15
|
+
return path.join(this.dir, `${id}.json`);
|
|
49
16
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
try {
|
|
55
|
-
await fs.unlink(sessionPath(id));
|
|
56
|
-
return true;
|
|
17
|
+
async save(session) {
|
|
18
|
+
session.updatedAt = Date.now();
|
|
19
|
+
this.cache.set(session.id, session);
|
|
20
|
+
await fs.writeFile(this.filePath(session.id), JSON.stringify(session, null, 2));
|
|
57
21
|
}
|
|
58
|
-
|
|
59
|
-
|
|
22
|
+
async create() {
|
|
23
|
+
const now = Date.now();
|
|
24
|
+
const session = {
|
|
25
|
+
id: crypto.randomUUID(),
|
|
26
|
+
messages: [],
|
|
27
|
+
createdAt: now,
|
|
28
|
+
updatedAt: now,
|
|
29
|
+
};
|
|
30
|
+
await this.save(session);
|
|
31
|
+
return session;
|
|
60
32
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
33
|
+
async get(id) {
|
|
34
|
+
const cached = this.cache.get(id);
|
|
35
|
+
if (cached)
|
|
36
|
+
return cached;
|
|
37
|
+
try {
|
|
38
|
+
const data = await fs.readFile(this.filePath(id), "utf-8");
|
|
39
|
+
const session = JSON.parse(data);
|
|
40
|
+
this.cache.set(id, session);
|
|
41
|
+
return session;
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
async getOrCreate(id) {
|
|
48
|
+
if (id) {
|
|
49
|
+
const existing = await this.get(id);
|
|
50
|
+
if (existing)
|
|
51
|
+
return existing;
|
|
52
|
+
}
|
|
53
|
+
return this.create();
|
|
54
|
+
}
|
|
55
|
+
async delete(id) {
|
|
56
|
+
this.cache.delete(id);
|
|
57
|
+
try {
|
|
58
|
+
await fs.unlink(this.filePath(id));
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return false;
|
|
76
63
|
}
|
|
77
|
-
return sessions;
|
|
78
64
|
}
|
|
79
|
-
|
|
80
|
-
|
|
65
|
+
async list() {
|
|
66
|
+
try {
|
|
67
|
+
const files = await fs.readdir(this.dir);
|
|
68
|
+
const sessions = [];
|
|
69
|
+
for (const file of files) {
|
|
70
|
+
if (!file.endsWith(".json"))
|
|
71
|
+
continue;
|
|
72
|
+
try {
|
|
73
|
+
const data = await fs.readFile(path.join(this.dir, file), "utf-8");
|
|
74
|
+
sessions.push(JSON.parse(data));
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
// skip corrupt files
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return sessions;
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
return [];
|
|
84
|
+
}
|
|
81
85
|
}
|
|
82
86
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{name}}",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "archon-claw dev agents/my-agent",
|
|
8
|
+
"start": "archon-claw start agents/my-agent -p ${PORT:-5100}",
|
|
9
|
+
"create:agent": "archon-claw create-agent",
|
|
10
|
+
"update:skills": "archon-claw update-skills"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [],
|
|
13
|
+
"license": "ISC",
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@archon-claw/cli": "^{{cliVersion}}"
|
|
16
|
+
}
|
|
17
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@archon-claw/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "AI Agent CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -33,6 +33,8 @@
|
|
|
33
33
|
"vitest": "^4.0.18"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
+
"@archon-claw/skills": "workspace:*",
|
|
37
|
+
"@clack/prompts": "^1.1.0",
|
|
36
38
|
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
37
39
|
"chokidar": "^5.0.0",
|
|
38
40
|
"commander": "^14.0.3",
|
|
@@ -42,6 +44,6 @@
|
|
|
42
44
|
"open": "^10.2.0",
|
|
43
45
|
"openai": "^6.25.0",
|
|
44
46
|
"picomatch": "^4.0.3",
|
|
45
|
-
"zod": "^3.
|
|
47
|
+
"zod": "^3.25.76"
|
|
46
48
|
}
|
|
47
49
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{u as r,r as t,i as a,j as e,b as c,C as i,X as d,d as l}from"./chat-input-Cx9bd-IU.js";function x(){return e.jsxs("div",{className:"flex h-10 shrink-0 items-center justify-between border-b px-3",children:[e.jsx("span",{className:"text-sm font-semibold",children:"Archon Claw"}),e.jsx("button",{type:"button",className:"text-muted-foreground hover:bg-accent rounded p-1 transition-colors",onClick:()=>window.parent.postMessage({type:"archon-claw:request-close"},"*"),children:e.jsx(d,{className:"h-4 w-4"})})]})}function u(){const n=r(s=>s.createSession),o=r(s=>s.activeSession());return t.useEffect(()=>{o||n()},[o,n]),t.useEffect(()=>{a()},[]),e.jsxs("div",{className:"flex h-dvh flex-col bg-background text-foreground",children:[e.jsx(x,{}),e.jsx(c,{}),e.jsx(i,{})]})}l.createRoot(document.getElementById("embed-root")).render(e.jsx(t.StrictMode,{children:e.jsx(u,{})}));
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import{c as x,r as h,j as e,a as d,u as t,B as i,X as f,M as p,b,C as j,d as y}from"./chat-input-Cx9bd-IU.js";/**
|
|
2
|
-
* @license lucide-react v0.469.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const v=x("Menu",[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]]);/**
|
|
7
|
-
* @license lucide-react v0.469.0 - ISC
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the ISC license.
|
|
10
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const g=x("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
|
|
12
|
-
* @license lucide-react v0.469.0 - ISC
|
|
13
|
-
*
|
|
14
|
-
* This source code is licensed under the ISC license.
|
|
15
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const N=x("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);function w({content:a,children:o,side:n="top"}){const[r,l]=h.useState(!1),c={top:"bottom-full left-1/2 -translate-x-1/2 mb-2",bottom:"top-full left-1/2 -translate-x-1/2 mt-2",left:"right-full top-1/2 -translate-y-1/2 mr-2",right:"left-full top-1/2 -translate-y-1/2 ml-2"};return e.jsxs("div",{className:"relative inline-flex",onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),children:[o,r&&e.jsx("div",{className:d("absolute z-50 whitespace-nowrap rounded-md bg-popover px-3 py-1.5 text-xs text-popover-foreground shadow-md border border-border animate-in fade-in-0",c[n]),children:a})]})}function k(){const a=t(s=>s.sessions),o=t(s=>s.activeLocalId),n=t(s=>s.sidebarOpen),r=t(s=>s.setSidebarOpen),l=t(s=>s.createSession),c=t(s=>s.switchSession),m=t(s=>s.deleteSession);return e.jsxs(e.Fragment,{children:[n&&e.jsx("div",{className:"fixed inset-0 z-40 bg-black/60 md:hidden",onClick:()=>r(!1)}),e.jsxs("aside",{className:d("fixed inset-y-0 left-0 z-50 flex w-60 flex-col border-r border-border bg-secondary transition-transform duration-200 md:relative md:translate-x-0",n?"translate-x-0":"-translate-x-full"),children:[e.jsxs("div",{className:"flex h-14 items-center justify-between border-b border-border px-4",children:[e.jsx("h1",{className:"text-sm font-semibold text-foreground",children:"Archon Claw"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(w,{content:"New chat",side:"bottom",children:e.jsx(i,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:l,children:e.jsx(g,{className:"h-4 w-4"})})}),e.jsx(i,{variant:"ghost",size:"icon",className:"h-8 w-8 md:hidden",onClick:()=>r(!1),children:e.jsx(f,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-2",children:[a.length===0&&e.jsx("p",{className:"px-2 py-4 text-center text-xs text-muted-foreground",children:"No conversations yet"}),a.map(s=>e.jsxs("div",{className:d("group flex items-center gap-2 rounded-lg px-3 py-2 text-sm cursor-pointer transition-colors",s.localId===o?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:bg-accent"),onClick:()=>c(s.localId),children:[e.jsx(p,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"flex-1 truncate",children:s.title}),e.jsx(i,{variant:"ghost",size:"icon",className:"h-6 w-6 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:u=>{u.stopPropagation(),m(s.localId)},children:e.jsx(N,{className:"h-3.5 w-3.5 text-muted-foreground hover:text-destructive"})})]},s.localId))]})]})]})}function S(){const a=t(n=>n.setSidebarOpen),o=t(n=>n.activeSession());return e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsxs("div",{className:"flex h-14 items-center gap-3 border-b border-border px-4",children:[e.jsx(i,{variant:"ghost",size:"icon",className:"md:hidden",onClick:()=>a(!0),children:e.jsx(v,{className:"h-5 w-5"})}),e.jsx("h2",{className:"truncate text-sm font-medium text-foreground",children:(o==null?void 0:o.title)??""})]}),e.jsx(b,{}),e.jsx(j,{})]})}function M(){const a=t(o=>o.loadSessions);return h.useEffect(()=>{a()},[a]),e.jsxs("div",{className:"flex h-dvh overflow-hidden bg-background text-foreground",children:[e.jsx(k,{}),e.jsx("main",{className:"flex-1 overflow-hidden",children:e.jsx(S,{})})]})}y.createRoot(document.getElementById("root")).render(e.jsx(h.StrictMode,{children:e.jsx(M,{})}));
|