alphamilk 0.0.6 → 0.0.8

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 (2) hide show
  1. package/dist/cli.js +26 -9
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -44,7 +44,7 @@ function clearSession() {
44
44
  // src/api.ts
45
45
  import { Effect, Data } from "effect";
46
46
  import { HttpClient, HttpClientRequest } from "@effect/platform";
47
- var CLI_VERSION = "0.0.6";
47
+ var CLI_VERSION = "0.0.8";
48
48
  var ApiError = class extends Data.TaggedError("ApiError") {
49
49
  };
50
50
  var apiGet = (baseUrl, path3, params) => Effect.gen(function* () {
@@ -166,9 +166,19 @@ var requireSession = Effect3.gen(function* () {
166
166
  }
167
167
  return session;
168
168
  });
169
+ var formatErrorMessage = (e) => {
170
+ const raw = e instanceof Error ? e.message : String(e);
171
+ try {
172
+ const parsed = JSON.parse(raw);
173
+ if (typeof parsed === "object" && parsed !== null && "message" in parsed) {
174
+ return String(parsed.message);
175
+ }
176
+ } catch {
177
+ }
178
+ return raw;
179
+ };
169
180
  var handleApiError = (context) => Effect3.catchAll((e) => {
170
- const msg = e instanceof Error ? e.message : String(e);
171
- return exitWithError(`${context}: ${msg}`);
181
+ return exitWithError(`${context}: ${formatErrorMessage(e)}`);
172
182
  });
173
183
  var loginToken = Options.text("token").pipe(
174
184
  Options.withAlias("t"),
@@ -292,7 +302,7 @@ var artifactSaveData = Options.text("data").pipe(
292
302
  );
293
303
  var artifactSaveFile = Options.text("file").pipe(
294
304
  Options.withAlias("f"),
295
- Options.withDescription("Path to a file (markdown for document, JSON for report/metrics)"),
305
+ Options.withDescription("Path to a file (markdown for document/report, JSON for metrics)"),
296
306
  Options.optional
297
307
  );
298
308
  var artifactSaveContent = Options.text("content").pipe(
@@ -336,12 +346,19 @@ Example: alphamilk artifact save --type ${type} --tags step:discovery --data "ex
336
346
  body.content = content.value;
337
347
  }
338
348
  } else if (type === "report") {
339
- if (file._tag === "None") {
349
+ if (file._tag === "None" && content._tag === "None") {
340
350
  return yield* exitWithError(
341
- 'Report artifacts require --file with a JSON manifest.\n\nExample: alphamilk artifact save --type report --title "Final Report" --tags report --file ./manifest.json'
351
+ 'Report artifacts require --file or --content.\n\nExample:\n alphamilk artifact save --type report --title "Report" --tags report --file ./report.md\n alphamilk artifact save --type report --title "Report" --tags report --content "# Report\\n..."'
342
352
  );
343
353
  }
344
- body.content = yield* readFile(file.value);
354
+ if (file._tag === "Some" && content._tag === "Some") {
355
+ return yield* exitWithError("Cannot use both --file and --content. Provide one or the other.");
356
+ }
357
+ if (file._tag === "Some") {
358
+ body.content = yield* readFile(file.value);
359
+ } else {
360
+ body.content = content.value;
361
+ }
345
362
  } else if (type === "metrics") {
346
363
  if (file._tag === "Some") {
347
364
  body.content = yield* readFile(file.value);
@@ -446,7 +463,7 @@ var artifactRenderCommand = Command.make(
446
463
  ).pipe(handleApiError("Failed to render artifact"));
447
464
  yield* Console2.log(response);
448
465
  })
449
- ).pipe(Command.withDescription("Render an artifact (assembles reports from referenced artifacts)"));
466
+ ).pipe(Command.withDescription("Render an artifact's content"));
450
467
  var artifactListType = Options.text("type").pipe(
451
468
  Options.withDescription("Filter by artifact type"),
452
469
  Options.optional
@@ -620,7 +637,7 @@ var root = Command.make("alphamilk").pipe(
620
637
  );
621
638
  var cli = Command.run(root, {
622
639
  name: "alphamilk",
623
- version: "0.0.6"
640
+ version: "0.0.8"
624
641
  });
625
642
  var MainLayer = Layer.mergeAll(
626
643
  NodeContext.layer,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alphamilk",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Alpha Milk CLI - AI-powered SEO research from your terminal",