mcoda 0.1.37 → 0.1.38

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 +1 @@
1
- {"version":3,"file":"McodaEntrypoint.d.ts","sourceRoot":"","sources":["../../src/bin/McodaEntrypoint.ts"],"names":[],"mappings":";AA+BA,qBAAa,eAAe;WACb,GAAG,CAAC,IAAI,GAAE,MAAM,EAA0B,GAAG,OAAO,CAAC,IAAI,CAAC;CAuMxE"}
1
+ {"version":3,"file":"McodaEntrypoint.d.ts","sourceRoot":"","sources":["../../src/bin/McodaEntrypoint.ts"],"names":[],"mappings":";AAiCA,qBAAa,eAAe;WACb,GAAG,CAAC,IAAI,GAAE,MAAM,EAA0B,GAAG,OAAO,CAAC,IAAI,CAAC;CAqNxE"}
@@ -3,6 +3,8 @@ import { realpathSync } from "node:fs";
3
3
  import { fileURLToPath } from "node:url";
4
4
  import packageJson from "../../package.json" with { type: "json" };
5
5
  import { AgentsCommands } from "../commands/agents/AgentsCommands.js";
6
+ import { CloudCommands } from "../commands/cloud/CloudCommands.js";
7
+ import { ConfigCommands } from "../commands/config/ConfigCommands.js";
6
8
  import { GatewayAgentCommand } from "../commands/agents/GatewayAgentCommand.js";
7
9
  import { DocsCommands } from "../commands/docs/DocsCommands.js";
8
10
  import { JobsCommands } from "../commands/jobs/JobsCommands.js";
@@ -83,8 +85,10 @@ export class McodaEntrypoint {
83
85
  return;
84
86
  }
85
87
  if (!command) {
86
- throw new Error("Usage: mcoda <agent|gateway-agent|test-agent|agent-run|routing|docs|openapi|job|jobs|tokens|telemetry|create-tasks|migrate-tasks|refine-tasks|task-sufficiency-audit|sds-preflight|order-tasks|tasks|add-tests|work-on-tasks|gateway-trio|code-review|qa-tasks|backlog|task|task-detail|estimate|update|set-workspace|project-guidance|pdr|sds> [...args]\n" +
88
+ throw new Error("Usage: mcoda <agent|cloud|cloud-agent|config|gateway-agent|test-agent|agent-run|routing|docs|openapi|job|jobs|tokens|telemetry|create-tasks|migrate-tasks|refine-tasks|task-sufficiency-audit|sds-preflight|order-tasks|tasks|add-tests|work-on-tasks|gateway-trio|code-review|qa-tasks|backlog|task|task-detail|estimate|update|set-workspace|project-guidance|pdr|sds> [...args]\n" +
89
+ "Config: use `mcoda config set mswarm-api-key <KEY>` to persist an encrypted mswarm API key in the resolved global mcoda config file.\n" +
87
90
  "Routing: use `mcoda routing defaults` to view/update workspace/global defaults, `mcoda routing preview|explain` to inspect agent selection/provenance (override → workspace_default → global_default).\n" +
91
+ "Cloud agents: use `mcoda cloud agent list|details|sync` to discover and materialize mswarm-managed remote agents.\n" +
88
92
  "Aliases: `tasks order-by-deps` forwards to `order-tasks` (dependency-aware ordering), `task`/`task-detail` show a single task.\n" +
89
93
  "Job commands (mcoda job --help for details): list|status|watch|logs|inspect|resume|cancel|tokens\n" +
90
94
  "Jobs API required for job commands (set MCODA_API_BASE_URL/MCODA_JOBS_API_URL or workspace api.baseUrl). status/watch/logs exit non-zero on failed/cancelled jobs per SDS.");
@@ -93,6 +97,18 @@ export class McodaEntrypoint {
93
97
  await AgentsCommands.run(rest);
94
98
  return;
95
99
  }
100
+ if (command === "cloud") {
101
+ await CloudCommands.run(rest);
102
+ return;
103
+ }
104
+ if (command === "config") {
105
+ await ConfigCommands.run(rest);
106
+ return;
107
+ }
108
+ if (command === "cloud-agent") {
109
+ await CloudCommands.run(["agent", ...rest]);
110
+ return;
111
+ }
96
112
  if (command === "gateway-agent") {
97
113
  await GatewayAgentCommand.run(rest);
98
114
  return;
@@ -0,0 +1,4 @@
1
+ export declare class CloudCommands {
2
+ static run(argv: string[]): Promise<void>;
3
+ }
4
+ //# sourceMappingURL=CloudCommands.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CloudCommands.d.ts","sourceRoot":"","sources":["../../../src/commands/cloud/CloudCommands.ts"],"names":[],"mappings":"AAyLA,qBAAa,aAAa;WACX,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CA+EhD"}
@@ -0,0 +1,249 @@
1
+ import { MswarmApi } from "@mcoda/core";
2
+ const USAGE = `
3
+ Usage: mcoda cloud agent <list|details|sync> [options]
4
+
5
+ Subcommands:
6
+ agent list List mswarm cloud agents (supports --json)
7
+ --provider <NAME> Filter by provider
8
+ --limit <N> Limit returned agents
9
+ agent details <SLUG> Show a single mswarm cloud agent (supports --json)
10
+ agent sync Sync mswarm cloud agents into the local mcoda registry
11
+ --provider <NAME> Filter by provider before syncing
12
+ --limit <N> Limit synced agents
13
+ --agent-slug-prefix <P> Override the local managed-agent slug prefix
14
+
15
+ Connection options:
16
+ --base-url <URL> Override MCODA_MSWARM_BASE_URL (default: https://api.mswarm.org/)
17
+ --openai-base-url <URL> Override MCODA_MSWARM_OPENAI_BASE_URL for synced managed-agent execution
18
+ --api-key <KEY> Override MCODA_MSWARM_API_KEY
19
+ --timeout-ms <N> Override MCODA_MSWARM_TIMEOUT_MS
20
+
21
+ Environment:
22
+ MCODA_MSWARM_BASE_URL
23
+ MCODA_MSWARM_OPENAI_BASE_URL
24
+ MCODA_MSWARM_API_KEY
25
+ MCODA_MSWARM_TIMEOUT_MS
26
+ MCODA_MSWARM_AGENT_SLUG_PREFIX
27
+ Or persist the API key with: mcoda config set mswarm-api-key <KEY>
28
+
29
+ Flags:
30
+ --json Emit JSON for supported commands
31
+ --help Show this help
32
+ `.trim();
33
+ const parseArgs = (argv) => {
34
+ const flags = {};
35
+ const positionals = [];
36
+ for (let index = 0; index < argv.length; index += 1) {
37
+ const arg = argv[index];
38
+ if (arg.startsWith("--")) {
39
+ const key = arg.replace(/^--/, "");
40
+ const next = argv[index + 1];
41
+ if (next && !next.startsWith("--")) {
42
+ const current = flags[key];
43
+ if (current === undefined) {
44
+ flags[key] = next;
45
+ }
46
+ else if (Array.isArray(current)) {
47
+ flags[key] = [...current, next];
48
+ }
49
+ else if (typeof current === "string") {
50
+ flags[key] = [current, next];
51
+ }
52
+ else {
53
+ flags[key] = [next];
54
+ }
55
+ index += 1;
56
+ }
57
+ else {
58
+ flags[key] = true;
59
+ }
60
+ continue;
61
+ }
62
+ positionals.push(arg);
63
+ }
64
+ return { flags, positionals };
65
+ };
66
+ const resolveString = (value) => {
67
+ if (value === undefined || typeof value === "boolean")
68
+ return undefined;
69
+ return Array.isArray(value) ? value[value.length - 1] : value;
70
+ };
71
+ const resolvePositiveInt = (value, label) => {
72
+ const raw = resolveString(value);
73
+ if (raw === undefined)
74
+ return undefined;
75
+ const parsed = Number.parseInt(raw, 10);
76
+ if (!Number.isFinite(parsed) || parsed <= 0) {
77
+ throw new Error(`Invalid ${label}; expected a positive integer`);
78
+ }
79
+ return parsed;
80
+ };
81
+ const formatNumber = (value) => value === undefined || Number.isNaN(value) ? "-" : String(value);
82
+ const formatCapabilities = (capabilities) => capabilities && capabilities.length > 0 ? capabilities.join(",") : "-";
83
+ const formatBoolean = (value) => value === undefined ? "-" : value ? "yes" : "no";
84
+ const pad = (value, width) => value.padEnd(width, " ");
85
+ const renderTable = (headers, rows) => {
86
+ const widths = headers.map((header, columnIndex) => Math.max(header.length, ...rows.map((row) => row[columnIndex]?.length ?? 0)));
87
+ const lines = [
88
+ headers.map((header, index) => pad(header, widths[index] ?? header.length)).join(" "),
89
+ widths.map((width) => "-".repeat(width)).join(" "),
90
+ ...rows.map((row) => row.map((cell, index) => pad(cell, widths[index] ?? cell.length)).join(" ")),
91
+ ];
92
+ return lines.join("\n");
93
+ };
94
+ const printAgentList = (agents) => {
95
+ if (agents.length === 0) {
96
+ // eslint-disable-next-line no-console
97
+ console.log("No cloud agents found.");
98
+ return;
99
+ }
100
+ const headers = [
101
+ "REMOTE SLUG",
102
+ "PROVIDER",
103
+ "MODEL",
104
+ "RATING",
105
+ "REASON",
106
+ "MAX CPLX",
107
+ "TOOLS",
108
+ "HEALTH",
109
+ "PRICING",
110
+ "CAPABILITIES",
111
+ ];
112
+ const rows = agents.map((agent) => [
113
+ agent.slug,
114
+ agent.provider,
115
+ agent.default_model,
116
+ formatNumber(agent.rating),
117
+ formatNumber(agent.reasoning_rating),
118
+ formatNumber(agent.max_complexity),
119
+ formatBoolean(agent.supports_tools),
120
+ agent.health_status ?? "-",
121
+ agent.pricing_version ?? "-",
122
+ formatCapabilities(agent.capabilities),
123
+ ]);
124
+ // eslint-disable-next-line no-console
125
+ console.log(renderTable(headers, rows));
126
+ };
127
+ const printAgentDetails = (agent) => {
128
+ const entries = [
129
+ ["Slug", agent.slug],
130
+ ["Provider", agent.provider],
131
+ ["Model", agent.default_model],
132
+ ["Model ID", agent.model_id ?? "-"],
133
+ ["Display name", agent.display_name ?? "-"],
134
+ ["Description", agent.description ?? "-"],
135
+ ["Rating", formatNumber(agent.rating)],
136
+ ["Reasoning rating", formatNumber(agent.reasoning_rating)],
137
+ ["Max complexity", formatNumber(agent.max_complexity)],
138
+ ["Context window", formatNumber(agent.context_window)],
139
+ ["Supports tools", formatBoolean(agent.supports_tools)],
140
+ ["Supports reasoning", formatBoolean(agent.supports_reasoning)],
141
+ ["Health", agent.health_status ?? "-"],
142
+ ["Pricing version", agent.pricing_version ?? "-"],
143
+ ["Pricing snapshot", agent.pricing_snapshot_id ?? "-"],
144
+ ["Capabilities", formatCapabilities(agent.capabilities)],
145
+ ];
146
+ const labelWidth = Math.max(...entries.map(([label]) => label.length));
147
+ for (const [label, value] of entries) {
148
+ // eslint-disable-next-line no-console
149
+ console.log(`${label.padEnd(labelWidth, " ")} : ${value}`);
150
+ }
151
+ };
152
+ const printSyncSummary = (summary) => {
153
+ // eslint-disable-next-line no-console
154
+ console.log(`Synced ${summary.agents.length} cloud agents (created=${summary.created}, updated=${summary.updated}).`);
155
+ if (summary.agents.length === 0) {
156
+ return;
157
+ }
158
+ const rows = summary.agents.map((record) => [
159
+ record.remoteSlug,
160
+ record.localSlug,
161
+ record.action,
162
+ record.provider,
163
+ record.defaultModel,
164
+ record.pricingVersion ?? "-",
165
+ ]);
166
+ // eslint-disable-next-line no-console
167
+ console.log(renderTable(["REMOTE SLUG", "LOCAL SLUG", "ACTION", "PROVIDER", "MODEL", "PRICING"], rows));
168
+ };
169
+ export class CloudCommands {
170
+ static async run(argv) {
171
+ const [topic, rawSubcommand, ...rest] = argv;
172
+ if (!topic || argv.includes("--help") || argv.includes("-h")) {
173
+ // eslint-disable-next-line no-console
174
+ console.log(USAGE);
175
+ return;
176
+ }
177
+ if (topic !== "agent" && topic !== "agents") {
178
+ throw new Error(`Unknown cloud topic: ${topic}`);
179
+ }
180
+ const subcommand = rawSubcommand === "detail" || rawSubcommand === "show"
181
+ ? "details"
182
+ : rawSubcommand;
183
+ if (!subcommand) {
184
+ // eslint-disable-next-line no-console
185
+ console.log(USAGE);
186
+ return;
187
+ }
188
+ const parsed = parseArgs(rest);
189
+ const api = await MswarmApi.create({
190
+ baseUrl: resolveString(parsed.flags["base-url"]),
191
+ openAiBaseUrl: resolveString(parsed.flags["openai-base-url"]),
192
+ apiKey: resolveString(parsed.flags["api-key"]),
193
+ timeoutMs: resolvePositiveInt(parsed.flags["timeout-ms"], "--timeout-ms"),
194
+ agentSlugPrefix: resolveString(parsed.flags["agent-slug-prefix"]),
195
+ });
196
+ try {
197
+ switch (subcommand) {
198
+ case "list": {
199
+ const agents = await api.listCloudAgents({
200
+ provider: resolveString(parsed.flags.provider),
201
+ limit: resolvePositiveInt(parsed.flags.limit, "--limit"),
202
+ });
203
+ if (parsed.flags.json) {
204
+ // eslint-disable-next-line no-console
205
+ console.log(JSON.stringify(agents, null, 2));
206
+ }
207
+ else {
208
+ printAgentList(agents);
209
+ }
210
+ break;
211
+ }
212
+ case "details": {
213
+ const slug = parsed.positionals[0];
214
+ if (!slug) {
215
+ throw new Error("Usage: mcoda cloud agent details <SLUG> [--json]");
216
+ }
217
+ const agent = await api.getCloudAgent(slug);
218
+ if (parsed.flags.json) {
219
+ // eslint-disable-next-line no-console
220
+ console.log(JSON.stringify(agent, null, 2));
221
+ }
222
+ else {
223
+ printAgentDetails(agent);
224
+ }
225
+ break;
226
+ }
227
+ case "sync": {
228
+ const summary = await api.syncCloudAgents({
229
+ provider: resolveString(parsed.flags.provider),
230
+ limit: resolvePositiveInt(parsed.flags.limit, "--limit"),
231
+ });
232
+ if (parsed.flags.json) {
233
+ // eslint-disable-next-line no-console
234
+ console.log(JSON.stringify(summary, null, 2));
235
+ }
236
+ else {
237
+ printSyncSummary(summary);
238
+ }
239
+ break;
240
+ }
241
+ default:
242
+ throw new Error(`Unknown cloud subcommand: ${subcommand}`);
243
+ }
244
+ }
245
+ finally {
246
+ await api.close();
247
+ }
248
+ }
249
+ }
@@ -0,0 +1,4 @@
1
+ export declare class ConfigCommands {
2
+ static run(argv: string[]): Promise<void>;
3
+ }
4
+ //# sourceMappingURL=ConfigCommands.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConfigCommands.d.ts","sourceRoot":"","sources":["../../../src/commands/config/ConfigCommands.ts"],"names":[],"mappings":"AAYA,qBAAa,cAAc;WACZ,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAsBhD"}
@@ -0,0 +1,33 @@
1
+ import { MswarmConfigStore } from "@mcoda/core";
2
+ const USAGE = `
3
+ Usage: mcoda config set mswarm-api-key <KEY>
4
+
5
+ Subcommands:
6
+ set mswarm-api-key <KEY> Persist an encrypted global mswarm API key in the resolved global mcoda config file
7
+
8
+ Flags:
9
+ --help Show this help
10
+ `.trim();
11
+ export class ConfigCommands {
12
+ static async run(argv) {
13
+ const [subcommand, key, value] = argv;
14
+ if (!subcommand || argv.includes("--help") || argv.includes("-h")) {
15
+ // eslint-disable-next-line no-console
16
+ console.log(USAGE);
17
+ return;
18
+ }
19
+ if (subcommand !== "set") {
20
+ throw new Error(`Unknown config subcommand: ${subcommand}`);
21
+ }
22
+ if (key !== "mswarm-api-key") {
23
+ throw new Error(`Unknown config key: ${key ?? "<missing>"}`);
24
+ }
25
+ if (!value?.trim()) {
26
+ throw new Error("Usage: mcoda config set mswarm-api-key <KEY>");
27
+ }
28
+ const store = new MswarmConfigStore();
29
+ await store.saveApiKey(value);
30
+ // eslint-disable-next-line no-console
31
+ console.log(`Saved encrypted mswarm API key to ${store.configPath()}.`);
32
+ }
33
+ }
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  export * from "./commands/agents/AgentsCommands.js";
2
2
  export * from "./bin/McodaEntrypoint.js";
3
+ export * from "./commands/cloud/CloudCommands.js";
4
+ export * from "./commands/config/ConfigCommands.js";
3
5
  export * from "./commands/docs/DocsCommands.js";
4
6
  export * from "./commands/jobs/JobsCommands.js";
5
7
  export * from "./commands/openapi/OpenapiCommands.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qCAAqC,CAAC;AACpD,cAAc,0BAA0B,CAAC;AACzC,cAAc,iCAAiC,CAAC;AAChD,cAAc,iCAAiC,CAAC;AAChD,cAAc,uCAAuC,CAAC;AACtD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,uCAAuC,CAAC;AACtD,cAAc,wCAAwC,CAAC;AACvD,cAAc,yCAAyC,CAAC;AACxD,cAAc,yCAAyC,CAAC;AACxD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,2CAA2C,CAAC;AAC1D,cAAc,oDAAoD,CAAC;AACnE,cAAc,4CAA4C,CAAC;AAC3D,cAAc,uCAAuC,CAAC;AACtD,cAAc,uCAAuC,CAAC;AACtD,cAAc,wCAAwC,CAAC;AACvD,cAAc,uCAAuC,CAAC;AACtD,cAAc,qCAAqC,CAAC;AACpD,cAAc,uCAAuC,CAAC;AACtD,cAAc,uCAAuC,CAAC;AACtD,cAAc,gDAAgD,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qCAAqC,CAAC;AACpD,cAAc,0BAA0B,CAAC;AACzC,cAAc,mCAAmC,CAAC;AAClD,cAAc,qCAAqC,CAAC;AACpD,cAAc,iCAAiC,CAAC;AAChD,cAAc,iCAAiC,CAAC;AAChD,cAAc,uCAAuC,CAAC;AACtD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,uCAAuC,CAAC;AACtD,cAAc,wCAAwC,CAAC;AACvD,cAAc,yCAAyC,CAAC;AACxD,cAAc,yCAAyC,CAAC;AACxD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,2CAA2C,CAAC;AAC1D,cAAc,oDAAoD,CAAC;AACnE,cAAc,4CAA4C,CAAC;AAC3D,cAAc,uCAAuC,CAAC;AACtD,cAAc,uCAAuC,CAAC;AACtD,cAAc,wCAAwC,CAAC;AACvD,cAAc,uCAAuC,CAAC;AACtD,cAAc,qCAAqC,CAAC;AACpD,cAAc,uCAAuC,CAAC;AACtD,cAAc,uCAAuC,CAAC;AACtD,cAAc,gDAAgD,CAAC"}
package/dist/index.js CHANGED
@@ -1,5 +1,7 @@
1
1
  export * from "./commands/agents/AgentsCommands.js";
2
2
  export * from "./bin/McodaEntrypoint.js";
3
+ export * from "./commands/cloud/CloudCommands.js";
4
+ export * from "./commands/config/ConfigCommands.js";
3
5
  export * from "./commands/docs/DocsCommands.js";
4
6
  export * from "./commands/jobs/JobsCommands.js";
5
7
  export * from "./commands/openapi/OpenapiCommands.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcoda",
3
- "version": "0.1.37",
3
+ "version": "0.1.38",
4
4
  "description": "Local-first CLI for planning, documentation, and execution workflows with agent assistance.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -45,12 +45,12 @@
45
45
  },
46
46
  "dependencies": {
47
47
  "yaml": "^2.4.2",
48
- "@mcoda/shared": "0.1.37",
49
- "@mcoda/core": "0.1.37"
48
+ "@mcoda/core": "0.1.38",
49
+ "@mcoda/shared": "0.1.38"
50
50
  },
51
51
  "devDependencies": {
52
- "@mcoda/integrations": "0.1.37",
53
- "@mcoda/db": "0.1.37"
52
+ "@mcoda/db": "0.1.38",
53
+ "@mcoda/integrations": "0.1.38"
54
54
  },
55
55
  "scripts": {
56
56
  "build": "tsc -p tsconfig.json",