@web42/cli 0.2.7 → 0.2.9

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.
Files changed (58) hide show
  1. package/dist/commands/search.js +20 -15
  2. package/dist/commands/send.js +75 -41
  3. package/dist/commands/serve.d.ts +1 -1
  4. package/dist/commands/serve.js +160 -114
  5. package/dist/index.js +1 -19
  6. package/dist/version.d.ts +1 -1
  7. package/dist/version.js +1 -1
  8. package/package.json +1 -1
  9. package/dist/commands/config.d.ts +0 -2
  10. package/dist/commands/config.js +0 -27
  11. package/dist/commands/init.d.ts +0 -2
  12. package/dist/commands/init.js +0 -451
  13. package/dist/commands/install.d.ts +0 -3
  14. package/dist/commands/install.js +0 -231
  15. package/dist/commands/list.d.ts +0 -3
  16. package/dist/commands/list.js +0 -22
  17. package/dist/commands/pack.d.ts +0 -2
  18. package/dist/commands/pack.js +0 -210
  19. package/dist/commands/pull.d.ts +0 -2
  20. package/dist/commands/pull.js +0 -202
  21. package/dist/commands/push.d.ts +0 -2
  22. package/dist/commands/push.js +0 -374
  23. package/dist/commands/remix.d.ts +0 -2
  24. package/dist/commands/remix.js +0 -49
  25. package/dist/commands/sync.d.ts +0 -2
  26. package/dist/commands/sync.js +0 -98
  27. package/dist/commands/uninstall.d.ts +0 -3
  28. package/dist/commands/uninstall.js +0 -54
  29. package/dist/commands/update.d.ts +0 -3
  30. package/dist/commands/update.js +0 -59
  31. package/dist/platforms/base.d.ts +0 -82
  32. package/dist/platforms/base.js +0 -1
  33. package/dist/platforms/claude/__tests__/adapter.test.d.ts +0 -1
  34. package/dist/platforms/claude/__tests__/adapter.test.js +0 -257
  35. package/dist/platforms/claude/__tests__/security.test.d.ts +0 -1
  36. package/dist/platforms/claude/__tests__/security.test.js +0 -166
  37. package/dist/platforms/claude/adapter.d.ts +0 -34
  38. package/dist/platforms/claude/adapter.js +0 -525
  39. package/dist/platforms/claude/security.d.ts +0 -15
  40. package/dist/platforms/claude/security.js +0 -67
  41. package/dist/platforms/claude/templates.d.ts +0 -5
  42. package/dist/platforms/claude/templates.js +0 -22
  43. package/dist/platforms/openclaw/adapter.d.ts +0 -12
  44. package/dist/platforms/openclaw/adapter.js +0 -476
  45. package/dist/platforms/openclaw/templates.d.ts +0 -7
  46. package/dist/platforms/openclaw/templates.js +0 -369
  47. package/dist/platforms/registry.d.ts +0 -6
  48. package/dist/platforms/registry.js +0 -32
  49. package/dist/types/sync.d.ts +0 -74
  50. package/dist/types/sync.js +0 -7
  51. package/dist/utils/bundled-skills.d.ts +0 -6
  52. package/dist/utils/bundled-skills.js +0 -29
  53. package/dist/utils/secrets.d.ts +0 -32
  54. package/dist/utils/secrets.js +0 -118
  55. package/dist/utils/skill.d.ts +0 -6
  56. package/dist/utils/skill.js +0 -42
  57. package/dist/utils/sync.d.ts +0 -14
  58. package/dist/utils/sync.js +0 -242
@@ -1,42 +0,0 @@
1
- function parseFrontmatter(lines) {
2
- const frontmatter = {};
3
- if (lines[0]?.trim() !== "---")
4
- return { frontmatter, bodyStartIndex: 0 };
5
- let i = 1;
6
- for (; i < lines.length; i++) {
7
- if (lines[i].trim() === "---")
8
- return { frontmatter, bodyStartIndex: i + 1 };
9
- const match = lines[i].match(/^(\w+)\s*:\s*(.*)$/);
10
- if (match) {
11
- const val = match[2].trim().replace(/^["']|["']$/g, "");
12
- frontmatter[match[1]] = val;
13
- }
14
- }
15
- return { frontmatter, bodyStartIndex: 0 };
16
- }
17
- export function parseSkillMd(content, fallbackName) {
18
- const lines = content.split("\n");
19
- const { frontmatter, bodyStartIndex } = parseFrontmatter(lines);
20
- let name = frontmatter.name || fallbackName;
21
- const internal = frontmatter.internal === "true";
22
- const descriptionLines = [];
23
- let i = bodyStartIndex;
24
- for (; i < lines.length; i++) {
25
- const headingMatch = lines[i].match(/^#\s+(.+)/);
26
- if (headingMatch) {
27
- if (!frontmatter.name)
28
- name = headingMatch[1].trim();
29
- i++;
30
- break;
31
- }
32
- }
33
- for (; i < lines.length; i++) {
34
- if (lines[i].match(/^#/))
35
- break;
36
- descriptionLines.push(lines[i]);
37
- }
38
- const description = frontmatter.description ||
39
- descriptionLines.join("\n").trim() ||
40
- `Skill: ${fallbackName}`;
41
- return { name, description, internal };
42
- }
@@ -1,14 +0,0 @@
1
- import type { AgentSnapshot, MarketplaceConfig, ResourceMeta, SyncState } from "../types/sync.js";
2
- export declare function sha256(input: string): string;
3
- export declare function canonicalJson(obj: unknown): string;
4
- export declare function computeHashFromSnapshot(snapshot: AgentSnapshot): string;
5
- export declare function readSyncState(cwd: string): SyncState | null;
6
- export declare function writeSyncState(cwd: string, state: SyncState): void;
7
- export declare function readMarketplace(cwd: string): MarketplaceConfig;
8
- export declare function writeMarketplace(cwd: string, data: MarketplaceConfig): void;
9
- export declare function findLocalAvatar(cwd: string): string | null;
10
- export declare function findAgentAvatar(cwd: string): string | null;
11
- export declare function discoverResources(cwd: string): ResourceMeta[];
12
- export declare function readResourcesMeta(cwd: string): ResourceMeta[];
13
- export declare function writeResourcesMeta(cwd: string, meta: ResourceMeta[]): void;
14
- export declare function buildLocalSnapshot(cwd: string, overrideDistDir?: string): AgentSnapshot;
@@ -1,242 +0,0 @@
1
- import { createHash } from "crypto";
2
- import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync, } from "fs";
3
- import { join, relative } from "path";
4
- const AVATAR_EXTENSIONS = ["png", "jpg", "jpeg", "webp", "svg"];
5
- // ---------------------------------------------------------------------------
6
- // Hash functions -- exact mirror of lib/sync/agent-sync.ts
7
- // ---------------------------------------------------------------------------
8
- export function sha256(input) {
9
- return createHash("sha256").update(input, "utf-8").digest("hex");
10
- }
11
- export function canonicalJson(obj) {
12
- return JSON.stringify(obj, (_key, value) => {
13
- if (value && typeof value === "object" && !Array.isArray(value)) {
14
- const sorted = {};
15
- for (const k of Object.keys(value).sort()) {
16
- sorted[k] = value[k];
17
- }
18
- return sorted;
19
- }
20
- return value;
21
- });
22
- }
23
- export function computeHashFromSnapshot(snapshot) {
24
- const parts = [
25
- canonicalJson(snapshot.identity),
26
- snapshot.readme,
27
- canonicalJson(snapshot.manifest),
28
- canonicalJson(snapshot.marketplace),
29
- snapshot.avatar_url ?? "",
30
- canonicalJson(snapshot.resources
31
- .slice()
32
- .sort((a, b) => a.sort_order - b.sort_order)
33
- .map((r) => ({
34
- description: r.description,
35
- sort_order: r.sort_order,
36
- thumbnail_url: r.thumbnail_url,
37
- title: r.title,
38
- type: r.type,
39
- url: r.url,
40
- }))),
41
- snapshot.files
42
- .slice()
43
- .sort((a, b) => a.path.localeCompare(b.path))
44
- .map((f) => f.content_hash)
45
- .join("|"),
46
- ];
47
- return sha256(parts.join("\x00"));
48
- }
49
- // ---------------------------------------------------------------------------
50
- // .web42/sync.json
51
- // ---------------------------------------------------------------------------
52
- export function readSyncState(cwd) {
53
- const p = join(cwd, ".web42", "sync.json");
54
- if (!existsSync(p))
55
- return null;
56
- try {
57
- return JSON.parse(readFileSync(p, "utf-8"));
58
- }
59
- catch {
60
- return null;
61
- }
62
- }
63
- export function writeSyncState(cwd, state) {
64
- const dir = join(cwd, ".web42");
65
- mkdirSync(dir, { recursive: true });
66
- writeFileSync(join(dir, "sync.json"), JSON.stringify(state, null, 2) + "\n");
67
- }
68
- // ---------------------------------------------------------------------------
69
- // .web42/marketplace.json
70
- // ---------------------------------------------------------------------------
71
- const MARKETPLACE_DEFAULTS = {
72
- price_cents: 0,
73
- currency: "usd",
74
- license: null,
75
- visibility: "private",
76
- tags: [],
77
- };
78
- export function readMarketplace(cwd) {
79
- const p = join(cwd, ".web42", "marketplace.json");
80
- if (!existsSync(p))
81
- return { ...MARKETPLACE_DEFAULTS };
82
- try {
83
- const raw = JSON.parse(readFileSync(p, "utf-8"));
84
- return {
85
- price_cents: raw.price_cents ?? MARKETPLACE_DEFAULTS.price_cents,
86
- currency: raw.currency ?? MARKETPLACE_DEFAULTS.currency,
87
- license: raw.license ?? MARKETPLACE_DEFAULTS.license,
88
- visibility: raw.visibility ?? MARKETPLACE_DEFAULTS.visibility,
89
- tags: Array.isArray(raw.tags) ? raw.tags : MARKETPLACE_DEFAULTS.tags,
90
- };
91
- }
92
- catch {
93
- return { ...MARKETPLACE_DEFAULTS };
94
- }
95
- }
96
- export function writeMarketplace(cwd, data) {
97
- const dir = join(cwd, ".web42");
98
- mkdirSync(dir, { recursive: true });
99
- writeFileSync(join(dir, "marketplace.json"), JSON.stringify(data, null, 2) + "\n");
100
- }
101
- // ---------------------------------------------------------------------------
102
- // .web42/avatar.*
103
- // ---------------------------------------------------------------------------
104
- export function findLocalAvatar(cwd) {
105
- const dir = join(cwd, ".web42");
106
- if (!existsSync(dir))
107
- return null;
108
- for (const ext of AVATAR_EXTENSIONS) {
109
- const p = join(dir, `avatar.${ext}`);
110
- if (existsSync(p))
111
- return p;
112
- }
113
- return null;
114
- }
115
- export function findAgentAvatar(cwd) {
116
- const avatarSearchPaths = [
117
- join(cwd, "avatar/avatar.png"),
118
- join(cwd, "avatars/avatar.png"),
119
- join(cwd, "avatar.png"),
120
- ];
121
- for (const ap of avatarSearchPaths) {
122
- if (existsSync(ap))
123
- return ap;
124
- }
125
- return null;
126
- }
127
- // ---------------------------------------------------------------------------
128
- // .web42/resources.json + .web42/resources/ + root resources/
129
- // ---------------------------------------------------------------------------
130
- const RESOURCE_IMAGE_EXTENSIONS = ["png", "jpg", "jpeg", "webp", "svg"];
131
- const RESOURCE_VIDEO_EXTENSIONS = ["mp4", "webm"];
132
- export function discoverResources(cwd) {
133
- const resourcesDir = join(cwd, "resources");
134
- if (!existsSync(resourcesDir))
135
- return [];
136
- const meta = [];
137
- const entries = readdirSync(resourcesDir, { withFileTypes: true });
138
- for (const entry of entries) {
139
- if (entry.name.startsWith("."))
140
- continue;
141
- if (entry.isDirectory())
142
- continue;
143
- const ext = entry.name.split(".").pop()?.toLowerCase() || "";
144
- let type = null;
145
- if (RESOURCE_IMAGE_EXTENSIONS.includes(ext)) {
146
- type = "image";
147
- }
148
- else if (RESOURCE_VIDEO_EXTENSIONS.includes(ext)) {
149
- type = "video";
150
- }
151
- if (!type) {
152
- throw new Error(`Unsupported file type in resources/ folder: ${entry.name}. Only images and videos are allowed.`);
153
- }
154
- meta.push({
155
- file: entry.name,
156
- title: entry.name.split(".").slice(0, -1).join("."),
157
- type,
158
- sort_order: meta.length,
159
- });
160
- }
161
- return meta;
162
- }
163
- export function readResourcesMeta(cwd) {
164
- const p = join(cwd, ".web42", "resources.json");
165
- if (!existsSync(p))
166
- return [];
167
- try {
168
- const raw = JSON.parse(readFileSync(p, "utf-8"));
169
- return Array.isArray(raw) ? raw : [];
170
- }
171
- catch {
172
- return [];
173
- }
174
- }
175
- export function writeResourcesMeta(cwd, meta) {
176
- const dir = join(cwd, ".web42");
177
- mkdirSync(dir, { recursive: true });
178
- writeFileSync(join(dir, "resources.json"), JSON.stringify(meta, null, 2) + "\n");
179
- }
180
- // ---------------------------------------------------------------------------
181
- // Read packed files from .web42/dist/
182
- // ---------------------------------------------------------------------------
183
- function readPackedFiles(dir) {
184
- const files = [];
185
- function walk(currentDir) {
186
- const entries = readdirSync(currentDir, { withFileTypes: true });
187
- for (const entry of entries) {
188
- const fullPath = join(currentDir, entry.name);
189
- if (entry.isDirectory()) {
190
- walk(fullPath);
191
- }
192
- else {
193
- if (entry.name === "manifest.json" && currentDir === dir)
194
- continue;
195
- const stat = statSync(fullPath);
196
- if (stat.size > 1024 * 1024)
197
- continue;
198
- try {
199
- const content = readFileSync(fullPath, "utf-8");
200
- const relPath = relative(dir, fullPath);
201
- files.push({ path: relPath, content, content_hash: sha256(content) });
202
- }
203
- catch {
204
- // skip binary files
205
- }
206
- }
207
- }
208
- }
209
- if (existsSync(dir))
210
- walk(dir);
211
- return files;
212
- }
213
- // ---------------------------------------------------------------------------
214
- // Build a full AgentSnapshot from local workspace
215
- // ---------------------------------------------------------------------------
216
- export function buildLocalSnapshot(cwd, overrideDistDir) {
217
- const manifestPath = join(cwd, "manifest.json");
218
- const manifest = existsSync(manifestPath)
219
- ? JSON.parse(readFileSync(manifestPath, "utf-8"))
220
- : {};
221
- const name = manifest.name ?? "";
222
- const description = manifest.description ?? "";
223
- const slug = name;
224
- const readmePath = join(cwd, "README.md");
225
- const readme = existsSync(readmePath)
226
- ? readFileSync(readmePath, "utf-8")
227
- : "";
228
- const marketplace = readMarketplace(cwd);
229
- const avatarPath = findLocalAvatar(cwd);
230
- const syncState = readSyncState(cwd);
231
- const distDir = overrideDistDir ?? join(cwd, ".web42", "dist");
232
- const files = readPackedFiles(distDir);
233
- return {
234
- identity: { name, slug, description },
235
- readme,
236
- manifest,
237
- marketplace,
238
- avatar_url: null,
239
- resources: [],
240
- files,
241
- };
242
- }