alphamilk 0.0.5 → 0.0.6
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/cli.js +70 -33
- 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.
|
|
47
|
+
var CLI_VERSION = "0.0.6";
|
|
48
48
|
var ApiError = class extends Data.TaggedError("ApiError") {
|
|
49
49
|
};
|
|
50
50
|
var apiGet = (baseUrl, path3, params) => Effect.gen(function* () {
|
|
@@ -64,7 +64,9 @@ var apiGet = (baseUrl, path3, params) => Effect.gen(function* () {
|
|
|
64
64
|
const response = yield* client.execute(request).pipe(Effect.scoped);
|
|
65
65
|
const body = yield* response.text;
|
|
66
66
|
if (response.status >= 400) {
|
|
67
|
-
return yield* Effect.fail(
|
|
67
|
+
return yield* Effect.fail(
|
|
68
|
+
new ApiError({ statusCode: response.status, message: body })
|
|
69
|
+
);
|
|
68
70
|
}
|
|
69
71
|
return body;
|
|
70
72
|
});
|
|
@@ -79,7 +81,9 @@ var apiPut = (baseUrl, path3, body) => Effect.gen(function* () {
|
|
|
79
81
|
const response = yield* client.execute(request).pipe(Effect.scoped);
|
|
80
82
|
const responseBody = yield* response.text;
|
|
81
83
|
if (response.status >= 400) {
|
|
82
|
-
return yield* Effect.fail(
|
|
84
|
+
return yield* Effect.fail(
|
|
85
|
+
new ApiError({ statusCode: response.status, message: responseBody })
|
|
86
|
+
);
|
|
83
87
|
}
|
|
84
88
|
return responseBody;
|
|
85
89
|
});
|
|
@@ -94,7 +98,9 @@ var apiPost = (baseUrl, path3, body) => Effect.gen(function* () {
|
|
|
94
98
|
const response = yield* client.execute(request).pipe(Effect.scoped);
|
|
95
99
|
const responseBody = yield* response.text;
|
|
96
100
|
if (response.status >= 400) {
|
|
97
|
-
return yield* Effect.fail(
|
|
101
|
+
return yield* Effect.fail(
|
|
102
|
+
new ApiError({ statusCode: response.status, message: responseBody })
|
|
103
|
+
);
|
|
98
104
|
}
|
|
99
105
|
return responseBody;
|
|
100
106
|
});
|
|
@@ -111,17 +117,13 @@ var parseExpiresAt = (markdown) => {
|
|
|
111
117
|
const match = markdown.match(/\*\*Expires\*\*\s*\|\s*(\S+)/);
|
|
112
118
|
return match ? match[1] : null;
|
|
113
119
|
};
|
|
114
|
-
var
|
|
120
|
+
var readFile = (filePath) => Effect2.gen(function* () {
|
|
115
121
|
const resolved = path2.resolve(filePath);
|
|
116
122
|
if (!fs2.existsSync(resolved)) {
|
|
117
123
|
yield* Console.error(
|
|
118
124
|
`File not found: ${resolved}
|
|
119
125
|
|
|
120
|
-
Check the path and try again. Use an absolute path or a path relative to your current directory
|
|
121
|
-
|
|
122
|
-
Example:
|
|
123
|
-
alphamilk report save --name "My Report" --file ./report.md
|
|
124
|
-
alphamilk report save --name "My Report" --file /tmp/report.md`
|
|
126
|
+
Check the path and try again. Use an absolute path or a path relative to your current directory.`
|
|
125
127
|
);
|
|
126
128
|
return yield* Effect2.die("File not found");
|
|
127
129
|
}
|
|
@@ -143,11 +145,7 @@ Check file permissions and try again.`
|
|
|
143
145
|
yield* Console.error(
|
|
144
146
|
`File is empty: ${resolved}
|
|
145
147
|
|
|
146
|
-
The
|
|
147
|
-
|
|
148
|
-
Example workflow:
|
|
149
|
-
1. Write your report to report.md
|
|
150
|
-
2. alphamilk report save --name "My Report" --file ./report.md`
|
|
148
|
+
The file must contain content. Write to the file first, then run this command.`
|
|
151
149
|
);
|
|
152
150
|
return yield* Effect2.die("Empty file");
|
|
153
151
|
}
|
|
@@ -227,11 +225,6 @@ var playbooksCommand = Command.make(
|
|
|
227
225
|
var playbookSlug = Args.text({ name: "slug" }).pipe(
|
|
228
226
|
Args.withDescription("Playbook slug (e.g., competitor-discovery)")
|
|
229
227
|
);
|
|
230
|
-
var playbookReport = Options.boolean("report").pipe(
|
|
231
|
-
Options.withAlias("r"),
|
|
232
|
-
Options.withDefault(false),
|
|
233
|
-
Options.withDescription("Get the report template instead of playbook content")
|
|
234
|
-
);
|
|
235
228
|
var playbookStep = Options.text("step").pipe(
|
|
236
229
|
Options.withAlias("s"),
|
|
237
230
|
Options.withDescription("Get a single step's instructions by step ID"),
|
|
@@ -239,13 +232,11 @@ var playbookStep = Options.text("step").pipe(
|
|
|
239
232
|
);
|
|
240
233
|
var playbookCommand = Command.make(
|
|
241
234
|
"playbook",
|
|
242
|
-
{ slug: playbookSlug,
|
|
243
|
-
({ slug,
|
|
235
|
+
{ slug: playbookSlug, step: playbookStep },
|
|
236
|
+
({ slug, step }) => Effect3.gen(function* () {
|
|
244
237
|
const session = yield* requireSession;
|
|
245
238
|
let urlPath;
|
|
246
|
-
if (
|
|
247
|
-
urlPath = `/milk/playbook/${session.sessionId}/${slug}/report`;
|
|
248
|
-
} else if (step._tag === "Some") {
|
|
239
|
+
if (step._tag === "Some") {
|
|
249
240
|
urlPath = `/milk/playbook/${session.sessionId}/${slug}?step=${encodeURIComponent(step.value)}`;
|
|
250
241
|
} else {
|
|
251
242
|
urlPath = `/milk/playbook/${session.sessionId}/${slug}`;
|
|
@@ -255,7 +246,7 @@ var playbookCommand = Command.make(
|
|
|
255
246
|
);
|
|
256
247
|
yield* Console2.log(response);
|
|
257
248
|
})
|
|
258
|
-
).pipe(Command.withDescription("Open a playbook
|
|
249
|
+
).pipe(Command.withDescription("Open a playbook or a specific step"));
|
|
259
250
|
var probeSlug = Args.text({ name: "slug" }).pipe(
|
|
260
251
|
Args.withDescription("Probe slug (e.g., serp-google, ranked-keywords)")
|
|
261
252
|
);
|
|
@@ -340,7 +331,7 @@ Example: alphamilk artifact save --type ${type} --tags step:discovery --data "ex
|
|
|
340
331
|
return yield* exitWithError("Cannot use both --file and --content. Provide one or the other.");
|
|
341
332
|
}
|
|
342
333
|
if (file._tag === "Some") {
|
|
343
|
-
body.content = yield*
|
|
334
|
+
body.content = yield* readFile(file.value);
|
|
344
335
|
} else {
|
|
345
336
|
body.content = content.value;
|
|
346
337
|
}
|
|
@@ -350,10 +341,10 @@ Example: alphamilk artifact save --type ${type} --tags step:discovery --data "ex
|
|
|
350
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
342
|
);
|
|
352
343
|
}
|
|
353
|
-
body.content = yield*
|
|
344
|
+
body.content = yield* readFile(file.value);
|
|
354
345
|
} else if (type === "metrics") {
|
|
355
346
|
if (file._tag === "Some") {
|
|
356
|
-
body.content = yield*
|
|
347
|
+
body.content = yield* readFile(file.value);
|
|
357
348
|
} else if (data._tag === "Some") {
|
|
358
349
|
const rows = data.value.split(",").map((pair) => {
|
|
359
350
|
const [label, rest] = pair.trim().split(":");
|
|
@@ -406,7 +397,7 @@ var artifactUpdateCommand = Command.make(
|
|
|
406
397
|
const body = {};
|
|
407
398
|
if (title._tag === "Some") body.title = title.value;
|
|
408
399
|
if (file._tag === "Some") {
|
|
409
|
-
body.content = yield*
|
|
400
|
+
body.content = yield* readFile(file.value);
|
|
410
401
|
} else if (content._tag === "Some") {
|
|
411
402
|
body.content = content.value;
|
|
412
403
|
}
|
|
@@ -493,7 +484,7 @@ var planSaveCommand = Command.make(
|
|
|
493
484
|
{ file: planSaveFile },
|
|
494
485
|
({ file }) => Effect3.gen(function* () {
|
|
495
486
|
const session = yield* requireSession;
|
|
496
|
-
const xmlContent = yield*
|
|
487
|
+
const xmlContent = yield* readFile(file);
|
|
497
488
|
const response = yield* apiPost(
|
|
498
489
|
session.baseUrl,
|
|
499
490
|
`/milk/plan/${session.sessionId}/save`,
|
|
@@ -560,6 +551,51 @@ var planCommand = Command.make("plan").pipe(
|
|
|
560
551
|
Command.withDescription("Save and manage research plans"),
|
|
561
552
|
Command.withSubcommands([planSaveCommand, planStatusCommand, planCheckCommand, planSkipCommand])
|
|
562
553
|
);
|
|
554
|
+
var eventGetId = Args.text({ name: "eventId" }).pipe(
|
|
555
|
+
Args.withDescription("Event ID to retrieve")
|
|
556
|
+
);
|
|
557
|
+
var eventGetCommand = Command.make(
|
|
558
|
+
"get",
|
|
559
|
+
{ eventId: eventGetId },
|
|
560
|
+
({ eventId }) => Effect3.gen(function* () {
|
|
561
|
+
const session = yield* requireSession;
|
|
562
|
+
const response = yield* apiGet(
|
|
563
|
+
session.baseUrl,
|
|
564
|
+
`/milk/event/${session.sessionId}/${eventId}`
|
|
565
|
+
).pipe(handleApiError("Failed to retrieve event"));
|
|
566
|
+
yield* Console2.log(response);
|
|
567
|
+
})
|
|
568
|
+
).pipe(Command.withDescription("Retrieve cached data from a session event"));
|
|
569
|
+
var eventListFormat = Options.text("format").pipe(
|
|
570
|
+
Options.withAlias("f"),
|
|
571
|
+
Options.withDescription("Output format: markdown (default) or json"),
|
|
572
|
+
Options.optional
|
|
573
|
+
);
|
|
574
|
+
var eventListLimit = Options.integer("limit").pipe(
|
|
575
|
+
Options.withAlias("l"),
|
|
576
|
+
Options.withDescription("Maximum number of events to return (default: 50)"),
|
|
577
|
+
Options.optional
|
|
578
|
+
);
|
|
579
|
+
var eventListCommand = Command.make(
|
|
580
|
+
"list",
|
|
581
|
+
{ format: eventListFormat, limit: eventListLimit },
|
|
582
|
+
({ format, limit }) => Effect3.gen(function* () {
|
|
583
|
+
const session = yield* requireSession;
|
|
584
|
+
const params = {};
|
|
585
|
+
if (format._tag === "Some") params.format = format.value;
|
|
586
|
+
if (limit._tag === "Some") params.limit = String(limit.value);
|
|
587
|
+
const response = yield* apiGet(
|
|
588
|
+
session.baseUrl,
|
|
589
|
+
`/milk/event/${session.sessionId}`,
|
|
590
|
+
params
|
|
591
|
+
).pipe(handleApiError("Failed to list events"));
|
|
592
|
+
yield* Console2.log(response);
|
|
593
|
+
})
|
|
594
|
+
).pipe(Command.withDescription("List session activity and events"));
|
|
595
|
+
var eventCommand = Command.make("event").pipe(
|
|
596
|
+
Command.withDescription("View session events and retrieve cached data"),
|
|
597
|
+
Command.withSubcommands([eventGetCommand, eventListCommand])
|
|
598
|
+
);
|
|
563
599
|
var logoutCommand = Command.make(
|
|
564
600
|
"logout",
|
|
565
601
|
{},
|
|
@@ -578,12 +614,13 @@ var root = Command.make("alphamilk").pipe(
|
|
|
578
614
|
playbookCommand,
|
|
579
615
|
probeCommand,
|
|
580
616
|
artifactCommand,
|
|
581
|
-
planCommand
|
|
617
|
+
planCommand,
|
|
618
|
+
eventCommand
|
|
582
619
|
])
|
|
583
620
|
);
|
|
584
621
|
var cli = Command.run(root, {
|
|
585
622
|
name: "alphamilk",
|
|
586
|
-
version: "0.0.
|
|
623
|
+
version: "0.0.6"
|
|
587
624
|
});
|
|
588
625
|
var MainLayer = Layer.mergeAll(
|
|
589
626
|
NodeContext.layer,
|