@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,22 +0,0 @@
1
- import { Command } from "commander";
2
- import chalk from "chalk";
3
- export function makeListCommand(adapter) {
4
- return new Command("list")
5
- .description("List installed agents")
6
- .action(async () => {
7
- const agents = await adapter.listInstalled();
8
- if (agents.length === 0) {
9
- console.log(chalk.yellow("No agents installed."));
10
- console.log(chalk.dim(`Run \`web42 ${adapter.name} install @user/agent\` to install one.`));
11
- return;
12
- }
13
- console.log(chalk.bold(`Installed ${adapter.name} agents:`));
14
- console.log();
15
- for (const agent of agents) {
16
- console.log(` ${chalk.cyan(agent.source ?? agent.name)}`);
17
- if (agent.workspace) {
18
- console.log(chalk.dim(` ${agent.workspace}`));
19
- }
20
- }
21
- });
22
- }
@@ -1,2 +0,0 @@
1
- import { Command } from "commander";
2
- export declare const packCommand: Command;
@@ -1,210 +0,0 @@
1
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
2
- import { join } from "path";
3
- import { Command } from "commander";
4
- import chalk from "chalk";
5
- import ora from "ora";
6
- import { resolvePlatform } from "../platforms/registry.js";
7
- import { parseSkillMd } from "../utils/skill.js";
8
- /**
9
- * Pack a single agent: run adapter.pack(), detect skills, write to dist.
10
- */
11
- async function packSingleAgent(opts) {
12
- const { cwd, adapter, agentName, dryRun } = opts;
13
- // Clone manifest so per-agent enrichment doesn't leak
14
- const manifest = JSON.parse(JSON.stringify(opts.manifest));
15
- const result = await adapter.pack({
16
- cwd,
17
- outputDir: opts.outputDir,
18
- agentName,
19
- });
20
- // Detect skills from packed files and strip internal ones
21
- const internalSkillPrefixes = [];
22
- const detectedSkills = [];
23
- for (const f of result.files) {
24
- const match = f.path.match(/^skills\/([^/]+)\/SKILL\.md$/);
25
- if (match) {
26
- const parsed = parseSkillMd(f.content, match[1]);
27
- if (parsed.internal) {
28
- internalSkillPrefixes.push(`skills/${match[1]}/`);
29
- }
30
- else {
31
- detectedSkills.push({ name: parsed.name, description: parsed.description });
32
- }
33
- }
34
- }
35
- if (internalSkillPrefixes.length > 0) {
36
- result.files = result.files.filter((f) => !internalSkillPrefixes.some((prefix) => f.path.startsWith(prefix)));
37
- }
38
- if (detectedSkills.length > 0) {
39
- manifest.skills = detectedSkills.sort((a, b) => a.name.localeCompare(b.name));
40
- }
41
- // Merge auto-generated config variables into manifest
42
- const existingKeys = new Set((manifest.configVariables ?? []).map((v) => v.key));
43
- for (const cv of result.configVariables) {
44
- if (!existingKeys.has(cv.key)) {
45
- if (!manifest.configVariables)
46
- manifest.configVariables = [];
47
- manifest.configVariables.push(cv);
48
- existingKeys.add(cv.key);
49
- }
50
- }
51
- if (dryRun) {
52
- const label = agentName ? `Dry run for ${chalk.bold(agentName)}` : "Dry run";
53
- console.log(chalk.bold(`${label} — would pack:`));
54
- console.log();
55
- for (const f of result.files) {
56
- console.log(chalk.dim(` ${f.path} (${f.content.length} bytes)`));
57
- }
58
- console.log();
59
- console.log(chalk.dim(`${result.files.length} files, ${result.configVariables.length} config variable(s)`));
60
- return { manifest, result };
61
- }
62
- const outputDir = join(cwd, opts.outputDir);
63
- mkdirSync(outputDir, { recursive: true });
64
- for (const file of result.files) {
65
- const filePath = join(outputDir, file.path);
66
- mkdirSync(join(filePath, ".."), { recursive: true });
67
- writeFileSync(filePath, file.content, "utf-8");
68
- }
69
- writeFileSync(join(outputDir, "manifest.json"), JSON.stringify(manifest, null, 2) + "\n");
70
- return { manifest, result };
71
- }
72
- export const packCommand = new Command("pack")
73
- .description("Pack your agent workspace into a distributable artifact")
74
- .option("-o, --output <dir>", "Output directory", ".web42/dist")
75
- .option("--dry-run", "Preview what would be packed without writing files")
76
- .option("--agent <name>", "Pack a specific agent (for multi-agent workspaces)")
77
- .action(async (opts) => {
78
- const cwd = process.cwd();
79
- // Determine platform: check for per-agent manifests first, then root manifest
80
- let platform = "openclaw"; // default
81
- let isMultiAgent = false;
82
- const agentManifests = new Map();
83
- // Check if this is a multi-agent workspace (per-agent manifests in .web42/{name}/)
84
- const web42Dir = join(cwd, ".web42");
85
- if (existsSync(web42Dir)) {
86
- const { readdirSync } = await import("fs");
87
- try {
88
- const entries = readdirSync(web42Dir, { withFileTypes: true });
89
- for (const entry of entries) {
90
- if (!entry.isDirectory())
91
- continue;
92
- const agentManifestPath = join(web42Dir, entry.name, "manifest.json");
93
- if (existsSync(agentManifestPath)) {
94
- try {
95
- const m = JSON.parse(readFileSync(agentManifestPath, "utf-8"));
96
- agentManifests.set(entry.name, m);
97
- if (m.platform)
98
- platform = m.platform;
99
- }
100
- catch {
101
- // skip invalid manifests
102
- }
103
- }
104
- }
105
- }
106
- catch {
107
- // .web42 not readable
108
- }
109
- }
110
- isMultiAgent = agentManifests.size > 0;
111
- // Fall back to root manifest.json (single-agent, e.g., OpenClaw)
112
- if (!isMultiAgent) {
113
- const manifestPath = join(cwd, "manifest.json");
114
- if (!existsSync(manifestPath)) {
115
- console.log(chalk.red("No manifest.json found. Run `web42 init` first."));
116
- process.exit(1);
117
- }
118
- const manifest = JSON.parse(readFileSync(manifestPath, "utf-8"));
119
- if (!manifest.name || !manifest.version || !manifest.author) {
120
- console.log(chalk.red("Invalid manifest.json. Must have name, version, and author."));
121
- process.exit(1);
122
- }
123
- if (manifest.platform)
124
- platform = manifest.platform;
125
- const adapter = resolvePlatform(platform);
126
- const spinner = ora("Packing agent...").start();
127
- try {
128
- const { manifest: enriched, result } = await packSingleAgent({
129
- cwd,
130
- manifest,
131
- manifestPath,
132
- adapter,
133
- outputDir: opts.output,
134
- dryRun: opts.dryRun,
135
- });
136
- if (opts.dryRun) {
137
- spinner.stop();
138
- return;
139
- }
140
- spinner.succeed(`Packed ${chalk.bold(enriched.name)} (${result.files.length} files) → ${opts.output}/`);
141
- if (result.configVariables.length > 0) {
142
- console.log(chalk.dim(` ${result.configVariables.length} config variable(s) detected`));
143
- }
144
- console.log();
145
- console.log(chalk.dim("Run `web42 push` to publish to the marketplace."));
146
- }
147
- catch (error) {
148
- spinner.fail("Pack failed");
149
- console.error(chalk.red(error.message));
150
- process.exit(1);
151
- }
152
- return;
153
- }
154
- // Multi-agent mode
155
- const adapter = resolvePlatform(platform);
156
- // Determine which agents to pack
157
- let agentsToPack;
158
- if (opts.agent) {
159
- const manifest = agentManifests.get(opts.agent);
160
- if (!manifest) {
161
- console.log(chalk.red(`Agent "${opts.agent}" not found. Available: ${[...agentManifests.keys()].join(", ")}`));
162
- process.exit(1);
163
- }
164
- agentsToPack = [[opts.agent, manifest]];
165
- }
166
- else {
167
- agentsToPack = [...agentManifests.entries()];
168
- }
169
- const spinner = ora(`Packing ${agentsToPack.length} agent(s)...`).start();
170
- try {
171
- for (const [agentName, manifest] of agentsToPack) {
172
- const agentOutputDir = join(".web42", agentName, "dist");
173
- spinner.text = `Packing ${agentName}...`;
174
- if (opts.dryRun) {
175
- spinner.stop();
176
- }
177
- const { manifest: enriched, result } = await packSingleAgent({
178
- cwd,
179
- manifest,
180
- manifestPath: join(web42Dir, agentName, "manifest.json"),
181
- adapter,
182
- agentName,
183
- outputDir: agentOutputDir,
184
- dryRun: opts.dryRun,
185
- });
186
- if (!opts.dryRun) {
187
- // Also write the enriched manifest back
188
- writeFileSync(join(web42Dir, agentName, "manifest.json"), JSON.stringify(enriched, null, 2) + "\n");
189
- console.log(chalk.green(` Packed ${chalk.bold(agentName)} (${result.files.length} files) → ${agentOutputDir}/`));
190
- }
191
- if (opts.dryRun) {
192
- console.log(); // spacing between agents
193
- spinner.start();
194
- }
195
- }
196
- if (opts.dryRun) {
197
- spinner.stop();
198
- }
199
- else {
200
- spinner.succeed(`Packed ${agentsToPack.length} agent(s)`);
201
- console.log();
202
- console.log(chalk.dim("Run `web42 push` to publish to the marketplace."));
203
- }
204
- }
205
- catch (error) {
206
- spinner.fail("Pack failed");
207
- console.error(chalk.red(error.message));
208
- process.exit(1);
209
- }
210
- });
@@ -1,2 +0,0 @@
1
- import { Command } from "commander";
2
- export declare const pullCommand: Command;
@@ -1,202 +0,0 @@
1
- import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "fs";
2
- import { dirname, join } from "path";
3
- import { Command } from "commander";
4
- import chalk from "chalk";
5
- import ora from "ora";
6
- import { apiGet } from "../utils/api.js";
7
- import { requireAuth } from "../utils/config.js";
8
- import { buildLocalSnapshot, computeHashFromSnapshot, readSyncState, writeSyncState, writeMarketplace, writeResourcesMeta, } from "../utils/sync.js";
9
- /**
10
- * Pull a single agent from the marketplace into a local directory.
11
- */
12
- async function pullSingleAgent(opts) {
13
- const { manifest, manifestPath, syncDir, writeDir, distDir, config, spinner } = opts;
14
- const name = manifest.name ?? "";
15
- // Step 1: Resolve agent ID
16
- let syncState = readSyncState(syncDir);
17
- let agentId = syncState?.agent_id ?? null;
18
- if (!agentId) {
19
- spinner.text = `Looking up ${name}...`;
20
- const agents = await apiGet(`/api/agents?username=${config.username}`);
21
- const agent = agents.find((a) => a.slug === name);
22
- if (!agent) {
23
- spinner.fail(`Agent @${config.username}/${name} not found on the marketplace. Run \`web42 push\` first.`);
24
- process.exit(1);
25
- }
26
- agentId = agent.id;
27
- }
28
- // Step 2: Compare remote hash with last known remote hash (unless --force)
29
- if (!opts.force && syncState?.last_remote_hash) {
30
- spinner.text = `Checking remote state for ${name}...`;
31
- const remote = await apiGet(`/api/agents/${agentId}/sync`);
32
- if (remote.hash === syncState.last_remote_hash) {
33
- console.log(chalk.dim(` ${chalk.bold(`@${config.username}/${name}`)} is already in sync.`));
34
- return;
35
- }
36
- }
37
- // Step 3: Pull full snapshot
38
- spinner.text = `Downloading ${name}...`;
39
- const pullResult = await apiGet(`/api/agents/${agentId}/sync/pull`);
40
- const { snapshot } = pullResult;
41
- let written = 0;
42
- // Step 4a: Write manifest.json
43
- const updatedManifest = {
44
- ...manifest,
45
- ...snapshot.manifest,
46
- name: snapshot.identity.slug,
47
- description: snapshot.identity.description,
48
- };
49
- writeFileSync(manifestPath, JSON.stringify(updatedManifest, null, 2) + "\n");
50
- written++;
51
- // Step 4b: Write README.md
52
- if (snapshot.readme) {
53
- writeFileSync(join(writeDir, "README.md"), snapshot.readme, "utf-8");
54
- written++;
55
- }
56
- // Step 4c: Write marketplace.json
57
- writeMarketplace(writeDir, snapshot.marketplace);
58
- written++;
59
- // Step 4d: Write agent files into dist/
60
- let skipped = 0;
61
- mkdirSync(distDir, { recursive: true });
62
- for (const file of snapshot.files) {
63
- if (file.content === null || file.content === undefined) {
64
- skipped++;
65
- continue;
66
- }
67
- if (file.path === ".openclaw/config.json") {
68
- skipped++;
69
- continue;
70
- }
71
- const filePath = join(distDir, file.path);
72
- mkdirSync(dirname(filePath), { recursive: true });
73
- writeFileSync(filePath, file.content, "utf-8");
74
- written++;
75
- }
76
- // Step 4e: Write resources metadata
77
- if (snapshot.resources.length > 0) {
78
- const resourcesMeta = snapshot.resources.map((r, i) => ({
79
- file: `resource-${i}-${r.title.replace(/[^a-zA-Z0-9.-]/g, "_")}`,
80
- title: r.title,
81
- description: r.description ?? undefined,
82
- type: r.type,
83
- sort_order: r.sort_order,
84
- }));
85
- writeResourcesMeta(writeDir, resourcesMeta);
86
- written++;
87
- }
88
- // Step 5: Save sync state
89
- const localSnapshot = buildLocalSnapshot(syncDir, distDir);
90
- const localHash = computeHashFromSnapshot(localSnapshot);
91
- writeSyncState(syncDir, {
92
- agent_id: agentId,
93
- last_remote_hash: pullResult.hash,
94
- last_local_hash: localHash,
95
- synced_at: new Date().toISOString(),
96
- });
97
- console.log(chalk.green(` Pulled @${config.username}/${name} (${written} files${skipped > 0 ? `, ${skipped} skipped` : ""})`));
98
- console.log(chalk.dim(` Sync hash: ${pullResult.hash.slice(0, 12)}...`));
99
- }
100
- export const pullCommand = new Command("pull")
101
- .description("Pull latest agent state from the Web42 marketplace into the current directory")
102
- .option("--force", "Skip hash comparison and always pull")
103
- .option("--agent <name>", "Pull a specific agent (for multi-agent workspaces)")
104
- .action(async (opts) => {
105
- const config = requireAuth();
106
- const cwd = process.cwd();
107
- // Detect multi-agent workspace (.web42/{name}/manifest.json)
108
- const web42Dir = join(cwd, ".web42");
109
- const agentManifests = new Map();
110
- if (existsSync(web42Dir)) {
111
- try {
112
- const entries = readdirSync(web42Dir, { withFileTypes: true });
113
- for (const entry of entries) {
114
- if (!entry.isDirectory())
115
- continue;
116
- const agentManifestPath = join(web42Dir, entry.name, "manifest.json");
117
- if (existsSync(agentManifestPath)) {
118
- try {
119
- const m = JSON.parse(readFileSync(agentManifestPath, "utf-8"));
120
- agentManifests.set(entry.name, m);
121
- }
122
- catch {
123
- // skip
124
- }
125
- }
126
- }
127
- }
128
- catch {
129
- // .web42 not readable
130
- }
131
- }
132
- const isMultiAgent = agentManifests.size > 0;
133
- // Single-agent mode
134
- if (!isMultiAgent) {
135
- const manifestPath = join(cwd, "manifest.json");
136
- if (!existsSync(manifestPath)) {
137
- console.log(chalk.red("No manifest.json found. Are you in an agent directory?"));
138
- process.exit(1);
139
- }
140
- const manifest = JSON.parse(readFileSync(manifestPath, "utf-8"));
141
- if (!manifest.name) {
142
- console.log(chalk.red("manifest.json is missing a name field."));
143
- process.exit(1);
144
- }
145
- const spinner = ora(`Pulling @${config.username}/${manifest.name}...`).start();
146
- try {
147
- await pullSingleAgent({
148
- manifest,
149
- manifestPath,
150
- syncDir: cwd,
151
- writeDir: cwd,
152
- distDir: join(cwd, ".web42", "dist"),
153
- config,
154
- force: opts.force,
155
- spinner,
156
- });
157
- spinner.succeed(`Pull complete`);
158
- }
159
- catch (error) {
160
- spinner.fail("Pull failed");
161
- console.error(chalk.red(error.message));
162
- process.exit(1);
163
- }
164
- return;
165
- }
166
- // Multi-agent mode
167
- let agentsToPull;
168
- if (opts.agent) {
169
- const manifest = agentManifests.get(opts.agent);
170
- if (!manifest) {
171
- console.log(chalk.red(`Agent "${opts.agent}" not found. Available: ${[...agentManifests.keys()].join(", ")}`));
172
- process.exit(1);
173
- }
174
- agentsToPull = [[opts.agent, manifest]];
175
- }
176
- else {
177
- agentsToPull = [...agentManifests.entries()];
178
- }
179
- const spinner = ora(`Pulling ${agentsToPull.length} agent(s)...`).start();
180
- try {
181
- for (const [agentName, manifest] of agentsToPull) {
182
- spinner.text = `Pulling ${agentName}...`;
183
- const agentWeb42Dir = join(web42Dir, agentName);
184
- await pullSingleAgent({
185
- manifest,
186
- manifestPath: join(agentWeb42Dir, "manifest.json"),
187
- syncDir: agentWeb42Dir,
188
- writeDir: agentWeb42Dir,
189
- distDir: join(agentWeb42Dir, "dist"),
190
- config,
191
- force: opts.force,
192
- spinner,
193
- });
194
- }
195
- spinner.succeed(`Pulled ${agentsToPull.length} agent(s)`);
196
- }
197
- catch (error) {
198
- spinner.fail("Pull failed");
199
- console.error(chalk.red(error.message));
200
- process.exit(1);
201
- }
202
- });
@@ -1,2 +0,0 @@
1
- import { Command } from "commander";
2
- export declare const pushCommand: Command;