cueloop 0.1.0-alpha.6 → 0.1.0-alpha.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cueloop",
3
- "version": "0.1.0-alpha.6",
3
+ "version": "0.1.0-alpha.7",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "bin": {
@@ -10,9 +10,9 @@
10
10
  ".": "./src/main.ts"
11
11
  },
12
12
  "dependencies": {
13
- "@cueloop/schema": "0.1.0-alpha.6",
14
- "@cueloop/daemon": "0.1.0-alpha.6",
15
- "@cueloop/client": "0.1.0-alpha.6"
13
+ "@cueloop/schema": "0.1.0-alpha.7",
14
+ "@cueloop/daemon": "0.1.0-alpha.7",
15
+ "@cueloop/client": "0.1.0-alpha.7"
16
16
  },
17
17
  "publishConfig": {
18
18
  "access": "public"
package/src/main.ts CHANGED
@@ -9,8 +9,9 @@
9
9
 
10
10
  import { parseArgs, flagStr } from "./args";
11
11
  import { sessionCommand } from "./session-cmds";
12
- import { resolveWorkspace, workingTreeDiff } from "./workspace";
12
+ import { workingTreeDiff } from "./working-tree";
13
13
  import { DaemonClient } from "@cueloop/daemon/client";
14
+ import { openReview, resolveWorkspace } from "@cueloop/daemon/review";
14
15
 
15
16
  const argv = process.argv.slice(2);
16
17
  const cmd = argv[0];
@@ -39,13 +40,14 @@ async function main(): Promise<number> {
39
40
  return 1;
40
41
  }
41
42
  const client = await DaemonClient.connect({ autostart: true });
42
- const session = await client.sessionCreate(workspace, {
43
+ const review = await openReview(client, {
43
44
  type: "diff",
44
45
  content: diff,
45
- meta: { title: `working tree @ ${workspace.branch}`, cwd: process.cwd() },
46
+ workspace,
47
+ title: `working tree @ ${workspace.branch}`,
46
48
  });
47
49
  client.close();
48
- return runTui(session.id);
50
+ return runTui(review.id);
49
51
  }
50
52
  case "serve": {
51
53
  const { positional, flags } = parseArgs(argv.slice(1));
package/src/pr.ts CHANGED
@@ -8,8 +8,8 @@
8
8
 
9
9
  import type { ReviewSession, VerdictKind } from "@cueloop/schema";
10
10
  import { DaemonClient } from "@cueloop/daemon/client";
11
+ import { openReview } from "@cueloop/daemon/review";
11
12
  import { parseArgs } from "./args";
12
- import { resolveWorkspace } from "./workspace";
13
13
 
14
14
  /** The gh binary is injectable so tests can stub it. */
15
15
  function ghBin(): string {
@@ -55,13 +55,14 @@ export async function reviewCommand(argv: string[]): Promise<number> {
55
55
  console.error(`PR ${pr} has an empty diff - nothing to review`);
56
56
  return 1;
57
57
  }
58
- const workspace = await resolveWorkspace();
59
58
  const client = await DaemonClient.connect({ autostart: true });
60
- const session = await client.sessionCreate(workspace, {
59
+ const review = await openReview(client, {
61
60
  type: "diff",
62
61
  content: diff.stdout,
63
- meta: { title: `PR ${pr}`, pr, cwd: process.cwd() },
62
+ title: `PR ${pr}`,
63
+ pr,
64
64
  });
65
+ const session = review.session;
65
66
  client.close();
66
67
 
67
68
  if (flags["no-tui"]) {
@@ -4,10 +4,10 @@
4
4
  * JSON on stdout; exit code 0 unless the daemon returned an error.
5
5
  */
6
6
 
7
- import type { ArtifactType, VerdictKind } from "@cueloop/schema";
7
+ import { newAnnotationId, type ArtifactType, type VerdictKind } from "@cueloop/schema";
8
8
  import { DaemonClient } from "@cueloop/daemon/client";
9
+ import { openReview, verdictResponse } from "@cueloop/daemon/review";
9
10
  import { parseArgs, flagStr } from "./args";
10
- import { resolveWorkspace } from "./workspace";
11
11
 
12
12
  async function readStdin(): Promise<string> {
13
13
  return await new Response(Bun.stdin.stream()).text();
@@ -24,21 +24,18 @@ export async function sessionCommand(argv: string[]): Promise<number> {
24
24
  try {
25
25
  switch (verb) {
26
26
  case "create": {
27
- const workspace = await resolveWorkspace(flagStr(flags, "cwd"));
28
27
  const contentFile = flagStr(flags, "content-file");
29
28
  const content = contentFile ? await Bun.file(contentFile).text() : await readStdin();
30
- const session = await client.sessionCreate(workspace, {
29
+ const review = await openReview(client, {
31
30
  type: (flagStr(flags, "type") ?? "plan") as ArtifactType,
32
31
  content,
33
- meta: {
34
- agent: flagStr(flags, "agent"),
35
- agentSessionId: flagStr(flags, "agent-session-id"),
36
- planPath: flagStr(flags, "plan-path"),
37
- title: flagStr(flags, "title"),
38
- cwd: flagStr(flags, "cwd") ?? process.cwd(),
39
- },
32
+ cwd: flagStr(flags, "cwd"),
33
+ agent: flagStr(flags, "agent"),
34
+ agentSessionId: flagStr(flags, "agent-session-id"),
35
+ planPath: flagStr(flags, "plan-path"),
36
+ title: flagStr(flags, "title"),
40
37
  });
41
- out(session);
38
+ out(review.session);
42
39
  return 0;
43
40
  }
44
41
  case "get": {
@@ -58,12 +55,8 @@ export async function sessionCommand(argv: string[]): Promise<number> {
58
55
  out({ status: "pending" });
59
56
  return 0;
60
57
  }
61
- out({
62
- status: "resolved",
63
- allow: session.verdict!.kind === "approve",
64
- verdict: session.verdict!.kind,
65
- feedback: session.verdict!.feedback,
66
- });
58
+ const { allow, feedback } = verdictResponse(session);
59
+ out({ status: "resolved", allow, verdict: session.verdict!.kind, feedback });
67
60
  return 0;
68
61
  }
69
62
  case "annotate": {
@@ -72,7 +65,7 @@ export async function sessionCommand(argv: string[]): Promise<number> {
72
65
  const quote = required(flagStr(flags, "quote"), "--quote");
73
66
  out(
74
67
  await client.sessionAnnotate(id, {
75
- id: flagStr(flags, "annotation-id") ?? `a_${Date.now().toString(36)}`,
68
+ id: flagStr(flags, "annotation-id") ?? newAnnotationId(),
76
69
  kind: flagStr(flags, "kind") ?? "comment",
77
70
  anchor: {
78
71
  quote,
@@ -1,6 +1,4 @@
1
- /** Workspace key resolution (#9): repo root + branch from the cwd. */
2
-
3
- import type { WorkspaceKey } from "@cueloop/schema";
1
+ /** Working-tree diff capture for `cueloop diff`, untracked files included. */
4
2
 
5
3
  async function git(args: string[], cwd: string): Promise<string | null> {
6
4
  const proc = Bun.spawn(["git", ...args], { cwd, stdout: "pipe", stderr: "ignore" });
@@ -9,12 +7,6 @@ async function git(args: string[], cwd: string): Promise<string | null> {
9
7
  return out.trim();
10
8
  }
11
9
 
12
- export async function resolveWorkspace(cwd = process.cwd()): Promise<WorkspaceKey> {
13
- const repoRoot = (await git(["rev-parse", "--show-toplevel"], cwd)) ?? cwd;
14
- const branch = (await git(["rev-parse", "--abbrev-ref", "HEAD"], cwd)) ?? "detached";
15
- return { repoRoot, branch };
16
- }
17
-
18
10
  export async function workingTreeDiff(cwd = process.cwd()): Promise<string> {
19
11
  const tracked = (await git(["diff", "HEAD"], cwd)) ?? "";
20
12
  // untracked files included by default (map note: changed-first)