@archon-claw/cli 0.1.0 → 0.2.1

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/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
- let sessionsDir = "";
5
- const sessionCache = new Map();
6
- export async function initSessionStore(agentDir) {
7
- sessionsDir = path.join(agentDir, "sessions");
8
- sessionCache.clear();
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
- catch {
41
- return undefined;
10
+ async init() {
11
+ this.cache.clear();
12
+ await fs.mkdir(this.dir, { recursive: true });
42
13
  }
43
- }
44
- export async function getOrCreateSession(id) {
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
- return createSession();
51
- }
52
- export async function deleteSession(id) {
53
- sessionCache.delete(id);
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
- catch {
59
- return false;
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
- export async function listSessions() {
63
- try {
64
- const files = await fs.readdir(sessionsDir);
65
- const sessions = [];
66
- for (const file of files) {
67
- if (!file.endsWith(".json"))
68
- continue;
69
- try {
70
- const data = await fs.readFile(path.join(sessionsDir, file), "utf-8");
71
- sessions.push(JSON.parse(data));
72
- }
73
- catch {
74
- // skip corrupt files
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
- catch {
80
- return [];
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,13 @@
1
+ # {{name}}
2
+
3
+ Built with [archon-claw](https://github.com/anthropics/archon-claw).
4
+
5
+ ## Getting Started
6
+
7
+ ```bash
8
+ # Start dev server
9
+ npm run dev
10
+
11
+ # Start production server
12
+ npm run start
13
+ ```
@@ -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,20 +1,11 @@
1
1
  {
2
2
  "name": "@archon-claw/cli",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "description": "AI Agent CLI",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "archon-claw": "./dist/cli.js"
8
8
  },
9
- "scripts": {
10
- "build": "tsc -p tsconfig.build.json && cp -r templates dist/ && rm -rf dist/public && cp -r ../web/dist dist/public",
11
- "dev": "tsx src/cli.ts start examples/my-agent",
12
- "start": "node dist/cli.js",
13
- "test": "vitest run --exclude dist --exclude examples",
14
- "test:watch": "vitest --exclude dist --exclude examples",
15
- "e2e": "playwright test",
16
- "e2e:ui": "playwright test --ui"
17
- },
18
9
  "files": [
19
10
  "dist"
20
11
  ],
@@ -23,16 +14,17 @@
23
14
  },
24
15
  "license": "MIT",
25
16
  "devDependencies": {
26
- "@archon-claw/web": "workspace:*",
27
17
  "@playwright/test": "^1.58.2",
28
18
  "@types/node": "^25.3.3",
29
19
  "@types/picomatch": "^4.0.2",
30
20
  "@vitest/coverage-v8": "^4.0.18",
31
21
  "tsx": "^4.21.0",
32
22
  "typescript": "^5.9.3",
33
- "vitest": "^4.0.18"
23
+ "vitest": "^4.0.18",
24
+ "@archon-claw/web": "0.1.0"
34
25
  },
35
26
  "dependencies": {
27
+ "@clack/prompts": "^1.1.0",
36
28
  "@modelcontextprotocol/sdk": "^1.27.1",
37
29
  "chokidar": "^5.0.0",
38
30
  "commander": "^14.0.3",
@@ -42,6 +34,16 @@
42
34
  "open": "^10.2.0",
43
35
  "openai": "^6.25.0",
44
36
  "picomatch": "^4.0.3",
45
- "zod": "^3.24.0"
37
+ "zod": "^3.25.76",
38
+ "@archon-claw/skills": "0.2.1"
39
+ },
40
+ "scripts": {
41
+ "build": "tsc -p tsconfig.build.json && cp -r templates dist/ && rm -rf dist/public && cp -r ../web/dist dist/public",
42
+ "dev": "tsx src/cli.ts start examples/my-agent",
43
+ "start": "node dist/cli.js",
44
+ "test": "vitest run --exclude dist --exclude examples",
45
+ "test:watch": "vitest --exclude dist --exclude examples",
46
+ "e2e": "playwright test",
47
+ "e2e:ui": "playwright test --ui"
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,{})}));