@flowriki/agent 0.1.0-beta.40 → 0.1.0-beta.42

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.
@@ -6,7 +6,7 @@ import os from "os";
6
6
  import path from "path";
7
7
  import { createRequire } from "module";
8
8
  import { spawnSync } from "child_process";
9
- var AGENT_VERSION = "0.1.0-beta.40";
9
+ var AGENT_VERSION = "0.1.0-beta.42";
10
10
  async function prepareBrowsers() {
11
11
  if (browsersReady()) {
12
12
  return { ok: true, already: true, message: "chromium is already installed" };
@@ -1873,7 +1873,6 @@ var LibraryCaseSchema = z5.object({
1873
1873
  ctx.addIssue({ code: "custom", path: ["automation", "reason"], message: "Say why it cannot be automated" });
1874
1874
  }
1875
1875
  });
1876
- var normaliseText = (text) => text.toLowerCase().replace(/[^\p{L}\p{N}]+/gu, " ").trim();
1877
1876
  var SOURCE_KINDS = ["upload", "jira", "figma", "confluence", "linear", "github-issue", "notion", "url"];
1878
1877
  var SourceVersionSchema = z5.object({
1879
1878
  v: z5.number().int().positive(),
@@ -1999,15 +1998,6 @@ var BugSchema = z6.object({
1999
1998
  updatedAt: z6.string()
2000
1999
  }).strict();
2001
2000
  var STOP = new Set("a an the and or of to in on for with by is are be as at it this that from user users can should must shall will when then given".split(" "));
2002
- function similarity(a, b2) {
2003
- const words = (s2) => new Set(normaliseText(s2).split(" ").filter((w) => w.length > 1 && !STOP.has(w)));
2004
- const x = words(a);
2005
- const y = words(b2);
2006
- if (x.size === 0 || y.size === 0) return 0;
2007
- let shared = 0;
2008
- for (const w of x) if (y.has(w)) shared += 1;
2009
- return shared / (x.size + y.size - shared);
2010
- }
2011
2001
  var ConversationSchema = z7.object({
2012
2002
  id: z7.string().regex(/^conv_[A-Za-z0-9]+$/),
2013
2003
  projectId: z7.string().min(1),
@@ -10451,6 +10441,7 @@ import path10 from "path";
10451
10441
  import fs25 from "fs";
10452
10442
  import path24 from "path";
10453
10443
  import { randomUUID as randomUUID2 } from "crypto";
10444
+ import { execFile } from "child_process";
10454
10445
  import fs34 from "fs";
10455
10446
  import path34 from "path";
10456
10447
  import { spawn as nodeSpawn } from "child_process";
@@ -11199,6 +11190,30 @@ function setFolder(projectId, folder) {
11199
11190
  writeAll(all);
11200
11191
  return foldersFor(projectId);
11201
11192
  }
11193
+ var PROMPT = "Choose the folder your project's code is in";
11194
+ var WAIT_MS = 4 * 60 * 1e3;
11195
+ var NoFolderWindow = class extends Error {
11196
+ };
11197
+ async function chooseFolder(run, platform = process.platform) {
11198
+ const attempts = platform === "darwin" ? [["osascript", ["-e", "activate", "-e", `POSIX path of (choose folder with prompt "${PROMPT}")`]]] : platform === "win32" ? [["powershell", [
11199
+ "-NoProfile",
11200
+ "-STA",
11201
+ "-Command",
11202
+ `Add-Type -AssemblyName System.Windows.Forms; $d = New-Object System.Windows.Forms.FolderBrowserDialog; $d.Description = "${PROMPT}"; if ($d.ShowDialog() -eq 'OK') { $d.SelectedPath }`
11203
+ ]]] : [["zenity", ["--file-selection", "--directory", `--title=${PROMPT}`]], ["kdialog", ["--getexistingdirectory", ".", "--title", PROMPT]]];
11204
+ for (const [file2, args] of attempts) {
11205
+ let answer;
11206
+ try {
11207
+ answer = await run(file2, args, WAIT_MS);
11208
+ } catch {
11209
+ continue;
11210
+ }
11211
+ const picked = answer.stdout.trim();
11212
+ if (answer.code === 0 && picked) return picked.length > 1 ? picked.replace(/[\\/]+$/, "") : picked;
11213
+ return null;
11214
+ }
11215
+ throw new NoFolderWindow("this computer has no folder window to open \u2014 type the folder's path instead");
11216
+ }
11202
11217
  var MAX_PROMPT = 4e3;
11203
11218
  function assistantHandlers({ deps }) {
11204
11219
  const assistant = deps.assistant;
@@ -11246,7 +11261,12 @@ function assistantHandlers({ deps }) {
11246
11261
  * `folder` is answered too, for them: the first one. */
11247
11262
  "assistant.folder": async (command, project) => {
11248
11263
  try {
11249
- const { add, remove, path: asked } = command.args;
11264
+ const { add, remove, path: asked, choose } = command.args;
11265
+ if (choose === true) {
11266
+ const picked = await chooseFolder(runFile);
11267
+ const folders2 = picked ? addFolder(project.id, picked) : foldersFor(project.id);
11268
+ return { ok: true, result: { folders: folders2, folder: folders2[0] ?? null, chosen: picked } };
11269
+ }
11250
11270
  const folders = typeof add === "string" ? addFolder(project.id, add) : typeof remove === "string" ? removeFolder(project.id, remove) : asked !== void 0 ? setFolder(project.id, asked === null ? null : String(asked)) : foldersFor(project.id);
11251
11271
  return { ok: true, result: { folders, folder: folders[0] ?? null } };
11252
11272
  } catch (error) {
@@ -11259,6 +11279,13 @@ function assistantHandlers({ deps }) {
11259
11279
  }
11260
11280
  };
11261
11281
  }
11282
+ var runFile = (file2, args, timeoutMs) => new Promise((resolve2, reject) => {
11283
+ execFile(file2, args, { timeout: timeoutMs, windowsHide: false }, (error, stdout, stderr) => {
11284
+ if (error && error.code === "ENOENT") return reject(error);
11285
+ const code = error ? typeof error.code === "number" ? error.code : 1 : 0;
11286
+ resolve2({ code, stdout: String(stdout), stderr: String(stderr) });
11287
+ });
11288
+ });
11262
11289
  function buildHandlers(deps) {
11263
11290
  const context = {
11264
11291
  deps,
@@ -11343,12 +11370,6 @@ var ASK_MODE_TOOLS = [
11343
11370
  "project_brief",
11344
11371
  "knowledge_search",
11345
11372
  "knowledge_read",
11346
- "sources",
11347
- "requirements",
11348
- "find_similar_cases",
11349
- "library_cases",
11350
- "test_cycles",
11351
- "bugs",
11352
11373
  "list_my_branches"
11353
11374
  ];
11354
11375
  function buildAskArgs(opts) {
@@ -11356,7 +11377,7 @@ function buildAskArgs(opts) {
11356
11377
  const folders = opts.folders ?? [];
11357
11378
  const guidance = [
11358
11379
  `You are the Flowriki assistant for the project "${opts.projectName}" (id ${opts.projectId}). Use the Flowriki tools, and pass projectId "${opts.projectId}" wherever a tool takes one. Start with project_brief: it is this project's memory.`,
11359
- ask ? "ASK MODE: answer the question; change nothing. Cite what you rely on as [[testCase:TC-12]], [[source:src_x@v2]], [[requirement:req_x]], [[knowledge:features/checkout.md]], [[automation:tc_x]], [[cycle:cyc_x]], [[bug:BUG-3]] or [[file:path/in/repo.ts]]." : "DO MODE: do what is asked, on Claude's working branch, for a person to review. Ask in the chat and wait before publishing, deleting, or sending anything to another system. End by writing a short summary of what you did with write_knowledge (memory/sessions/<date>-<topic>.md, append) so the next session knows.",
11380
+ ask ? "ASK MODE: answer the question; change nothing. Cite what you rely on as [[testCase:<its id, tc_\u2026>]], [[knowledge:features/checkout.md]] or [[file:path/in/repo.ts]]." : "DO MODE: do what is asked, on Claude's working branch, for a person to review. Ask in the chat and wait before publishing, deleting, or sending anything to another system. End by writing a short summary of what you did with write_knowledge (memory/sessions/<date>-<topic>.md, append) so the next session knows.",
11360
11381
  folders.length ? `The project's code is in ${folders.join(" and ")}. Read it with Read, Grep and Glob when it helps; you cannot change it.` : ""
11361
11382
  ].filter(Boolean).join("\n");
11362
11383
  const flowriki = ask ? ASK_MODE_TOOLS.map((t) => `mcp__${MCP_SERVER_NAME}__${t}`) : [`mcp__${MCP_SERVER_NAME}`];
@@ -12019,7 +12040,6 @@ export {
12019
12040
  connect,
12020
12041
  RecordedStepSchema,
12021
12042
  mirrorCheckTargets,
12022
- similarity,
12023
12043
  runtimeValue,
12024
12044
  authenticationResolver,
12025
12045
  checkAssertion,
package/dist/cli.js CHANGED
@@ -20,10 +20,9 @@ import {
20
20
  resolveCheckouts,
21
21
  resolveService,
22
22
  runtimeValue,
23
- similarity,
24
23
  start,
25
24
  status
26
- } from "./chunk-T7I2US4Y.js";
25
+ } from "./chunk-FKD5OAUV.js";
27
26
 
28
27
  // src/cli.ts
29
28
  import { parseArgs } from "util";
@@ -754,7 +753,7 @@ ${lines.join("\n")}`;
754
753
  const note = others.length ? `
755
754
  Claude has ${others.length} other open branch${others.length === 1 ? "" : "es"} on this project \u2014 gather_branches puts them into this one, for one review.` : "";
756
755
  const after = draft.after?.length ? ` It starts after ${draft.after.map((a) => `"${a.name}"`).join(", ")}.` : "";
757
- return `${what} ${where_}.${after}${vault} Its ${checkCount} check${checkCount === 1 ? " is" : "s are"} saved switched off \u2014 an automation switches on the ones it is about. Nothing is published yet.
756
+ return `${what} ${where_}.${after}${vault} Its ${checkCount} check${checkCount === 1 ? " is" : "s are"} saved switched off \u2014 a test case switches on the ones it is about. Nothing is published yet.
758
757
  Review and publish it here: ${review}${note}`;
759
758
  }
760
759
  /** A test case built from flows, without saving: its rows and every check,
@@ -837,7 +836,7 @@ THE MODEL \u2014 get this right before recording anything:
837
836
  something different.
838
837
  - A flow records checks (add_check) that prove each thing happened, but they
839
838
  are SAVED SWITCHED OFF: which ones matter depends on the test.
840
- - An AUTOMATION is the test. It strings flows together as rows (in the same
839
+ - A TEST CASE is the test. It strings flows together as rows (in the same
841
840
  browser, or a new one for a second person) and switches on the checks it is
842
841
  about. Build it with preview_case, then save_case \u2014 which runs it first.
843
842
  - SIGN-IN is shared setup: a flow or case that needs somebody signed in uses a
@@ -862,19 +861,9 @@ THE MODEL \u2014 get this right before recording anything:
862
861
  "Ordering \u2013 Pizza builder", "Checkout \u2013 Payment". Flows (features) and the
863
862
  cases built from them use the same names. Keep one area per folder.
864
863
 
865
- THE TEST LIBRARY is what the team checks, written down: test cases (TC-1,
866
- TC-2\u2026) with steps, expected results, priority and status. An automation is how
867
- a test case is checked by a machine, and each test case lists the automations
868
- that check it. Read it with library_cases before deciding what to automate \u2014
869
- the important cases nothing checks yet come first. Write cases with
870
- save_test_cases (a case the library already has is skipped, so writing the
871
- same thing twice is harmless), and after save_case, link the automation to the
872
- test cases it proves with link_test_case.
873
-
874
- KNOWLEDGE: project_brief is the project's memory \u2014 read it first. Search
875
- everything (knowledge pages, documents, requirements, test cases) with
876
- knowledge_search; read a page with knowledge_read; read documents with
877
- sources. product.md is "About the product": the person's own description of
864
+ KNOWLEDGE: project_brief is the project's memory \u2014 read it first. Search the
865
+ knowledge pages with knowledge_search; read one with knowledge_read.
866
+ product.md is "About the product": the person's own description of
878
867
  the product, in their words, as long as they like \u2014 read it first. They
879
868
  write it, often with you in a conversation beside it; propose text there and
880
869
  let them decide, rather than writing product.md unless they ask you to.
@@ -885,32 +874,11 @@ as learned. Keep what you learn with write_knowledge (features/<name>.md,
885
874
  memory/decisions.md, a session summary), on Claude's branch for review \u2014
886
875
  never a password, key or token.
887
876
 
888
- FROM DOCUMENTS TO TESTS: documents (sources) are PRDs, CRs, feature docs.
889
- requirements lists what was found in them and what the latest version changed
890
- (new / changed / removed). For a new requirement: write test cases that cover
891
- it (save_test_cases with covers: [requirement id]) \u2014 but first check
892
- find_similar_cases, and link an existing case instead of writing a duplicate.
893
- For a changed one: update the cases that cover it. For a removed one: mark
894
- cases that only covered it deprecated. Never invent requirements.
895
-
896
- AUTOMATING A TEST CASE: first write the plan with save_automation_plan \u2014 flows
897
- to reuse, flows to record, which checks prove each expected result, accounts
898
- and helpers it needs, and anything that cannot be automated and why. Show it
899
- and wait for the person to approve before recording. Then record, save_case,
900
- and link_test_case.
901
-
902
- MANUAL TESTING: a test cycle is a set of library cases a person runs by hand
903
- ("Release 4.2 regression"); each case is marked passed, failed, blocked or
904
- skipped, step by step, with a bug raised from the step that broke. Read them
905
- with test_cycles and bugs; make and change cycles with manage_cycle; record
906
- what happened with record_result; raise or update bugs with save_bug. Never
907
- mark a case passed on a person's behalf without being told it passed.
908
-
909
877
  HOW TO WORK:
910
878
  1. Call project_catalog. Reuse what exists \u2014 published, and on Claude's working
911
879
  branch \u2014 rather than writing it again.
912
880
  2. Before recording, say the plan to the person: the folders, the building-block
913
- flows (and what each starts after), and the automations (rows + what each
881
+ flows (and what each starts after), and the test cases (rows + what each
914
882
  checks). Then record the blocks, earliest first.
915
883
  3. Record with start_flow (pass "after" for the flows it continues from), read
916
884
  the page with read_page, and act using the role and name EXACTLY as the page
@@ -921,7 +889,7 @@ HOW TO WORK:
921
889
  catalog, then type {{its saveAs name}} into the field that needs it.
922
890
  5. Add checks for what each step proves (a heading, a message, a value, the
923
891
  URL). replay_flow, then save_flow. A flow must record at least one check.
924
- 6. Build each automation: preview_case lists its rows and every check, numbered;
892
+ 6. Build each test case: preview_case lists its rows and every check, numbered;
925
893
  save_case with the numbers to switch on runs the whole case and saves it only
926
894
  if it passed. Give the person the review link.
927
895
  7. Saving the same name again replaces it on the working branch. Old branches
@@ -936,7 +904,7 @@ A test that types a fixed new email passes once and fails every run after.`;
936
904
  var CASE_INPUT = {
937
905
  type: "object",
938
906
  properties: {
939
- name: { type: "string", description: 'The automation: the scenario it proves, e.g. "Wrong password is refused".' },
907
+ name: { type: "string", description: 'The test case: the scenario it proves, e.g. "Wrong password is refused".' },
940
908
  folder: { type: "string", description: 'The case folder \u2014 area and topic, e.g. "Account \u2013 Sign in". Made if new.' },
941
909
  description: { type: "string" },
942
910
  rows: {
@@ -1303,8 +1271,8 @@ ${page}`);
1303
1271
  },
1304
1272
  {
1305
1273
  name: "preview_case",
1306
- title: "Preview an automation",
1307
- description: "Build an automation from flows without saving or running it: its rows (each flow with what it starts after folded in, and which browser it runs in) and every check, numbered, with which are on. Use the numbers in save_case.",
1274
+ title: "Preview a test case",
1275
+ description: "Build a test case from flows without saving or running it: its rows (each flow with what it starts after folded in, and which browser it runs in) and every check, numbered, with which are on. Use the numbers in save_case.",
1308
1276
  inputSchema: CASE_INPUT,
1309
1277
  annotations: { readOnlyHint: true },
1310
1278
  run: async (args) => {
@@ -1314,8 +1282,8 @@ ${page}`);
1314
1282
  },
1315
1283
  {
1316
1284
  name: "save_case",
1317
- title: "Run and save an automation",
1318
- description: "Build the automation, run it from the start in a fresh browser exactly as a test run will, and \u2014 only if every row passed \u2014 save it onto Claude's working branch. Saving the same name in the same folder again replaces it. Refused if it switches on no checks.",
1285
+ title: "Run and save a test case",
1286
+ description: "Build the test case, run it from the start in a fresh browser exactly as a test run will, and \u2014 only if every row passed \u2014 save it onto Claude's working branch. Saving the same name in the same folder again replaces it. Refused if it switches on no checks.",
1319
1287
  inputSchema: CASE_INPUT,
1320
1288
  annotations: { openWorldHint: true },
1321
1289
  run: async (args) => {
@@ -1328,7 +1296,7 @@ ${page}`);
1328
1296
  {
1329
1297
  name: "create_sign_in",
1330
1298
  title: "Make a sign-in profile",
1331
- description: "Turn a saved login flow into a sign-in profile that flows and automations can start signed in with. The flow must not itself sign in or start after other flows, and must end with a check proving the login worked \u2014 its last check is switched on here. Returns the fields an account fills in. Making the same name again replaces Claude's earlier one.",
1299
+ description: "Turn a saved login flow into a sign-in profile that flows and test cases can start signed in with. The flow must not itself sign in or start after other flows, and must end with a check proving the login worked \u2014 its last check is switched on here. Returns the fields an account fills in. Making the same name again replaces Claude's earlier one.",
1332
1300
  inputSchema: {
1333
1301
  type: "object",
1334
1302
  properties: {
@@ -1360,7 +1328,7 @@ Next: create_account for each person who signs in this way.`);
1360
1328
  {
1361
1329
  name: "create_account",
1362
1330
  title: "Make a sign-in account",
1363
- description: "An account for a sign-in profile: who signs in, and the values its login flow types, by field label (create_sign_in and project_catalog list them). Secret fields are sealed in the project's vault and never shown again. Then start_flow / automations can use signIn {profileId, accountId}. Making the same name again updates Claude's earlier one.",
1331
+ description: "An account for a sign-in profile: who signs in, and the values its login flow types, by field label (create_sign_in and project_catalog list them). Secret fields are sealed in the project's vault and never shown again. Then start_flow / test cases can use signIn {profileId, accountId}. Making the same name again updates Claude's earlier one.",
1364
1332
  inputSchema: {
1365
1333
  type: "object",
1366
1334
  properties: {
@@ -1419,134 +1387,15 @@ Use it with start_flow signIn {"profileId": "\u2026", "accountId": "${made.accou
1419
1387
  return text(`${made.replaced ? "Updated" : "Made"} the ${made.kind} helper "${made.name}" (id ${made.helperId}) on Claude's working branch ${made.branch}.${made.inputs.length ? ` A step supplies ${made.inputs.map((n) => `{{${n}}}`).join(", ")}.` : ""} Use it with use_helper.`);
1420
1388
  }
1421
1389
  },
1422
- {
1423
- name: "library_cases",
1424
- title: "Read the test library",
1425
- description: "The project's test cases \u2014 what the team checks \u2014 with their key (TC-n), priority, status, steps and expected results, and which automations check each one. Optional q (title, key or tag) and featureId narrow it. Read before planning automations: cases with priority P0/P1 and no automation are the gaps.",
1426
- inputSchema: {
1427
- type: "object",
1428
- properties: {
1429
- projectId: { type: "string" },
1430
- q: { type: "string", description: "Words in the title, a key like TC-12, or a tag." },
1431
- featureId: { type: "string", description: "Only this feature's cases, e.g. f_checkout." }
1432
- },
1433
- additionalProperties: false
1434
- },
1435
- annotations: { readOnlyHint: true },
1436
- run: async (args) => {
1437
- const projectId = await projectFor(args["projectId"]);
1438
- const { cases, total } = await service.library(projectId, {
1439
- ...str(args["q"]) ? { q: str(args["q"]) } : {},
1440
- ...str(args["featureId"]) ? { featureId: str(args["featureId"]) } : {}
1441
- });
1442
- if (cases.length === 0) return text(total ? "No test case matches." : "The test library is empty. Write cases with save_test_cases.");
1443
- const lines = cases.map((c) => {
1444
- const automated = c.automation.links.length ? `automated by ${c.automation.links.map((l) => l.automationId).join(", ")}${c.automation.links.some((l) => l.caseRevision < c.revision) ? " (case changed since \u2014 check it still matches)" : ""}` : c.automation.state === "not-automatable" ? `manual only: ${c.automation.reason ?? ""}` : c.automation.state === "planned" ? "automation planned" : "NOT AUTOMATED";
1445
- const steps = c.steps.map((st, i) => ` ${i + 1}. ${st.action}${st.data ? ` [${st.data}]` : ""}${st.expected ? ` \u2192 ${st.expected}` : ""}`).join("\n");
1446
- return `${c.key} (id ${c.id}, revision ${c.revision}) ${c.title} \u2014 ${c.featureId}, ${c.priority}, ${c.status}, ${automated}${c.preconditions.length ? `
1447
- Preconditions: ${c.preconditions.join("; ")}` : ""}${steps ? `
1448
- ${steps}` : ""}`;
1449
- });
1450
- return text(`${cases.length} of ${total} test cases:
1451
- ${lines.join("\n")}`);
1452
- }
1453
- },
1454
- {
1455
- name: "save_test_cases",
1456
- title: "Write test cases",
1457
- description: `Add test cases to the library, or edit existing ones, in one commit on Claude's working branch. create: [{feature: "Checkout" (or featureId), title, priority?: P0|P1|P2|P3, type?: functional|negative|edge|regression|smoke|accessibility|other, status?: draft|ready|deprecated, preconditions?: [..], steps: [{action, data?, expected?}], tags?: [..], description?}]. update: [{id, revision (from library_cases), ...only the fields to change}]. A new case the library already has is skipped and named in the answer \u2014 never duplicated.`,
1458
- inputSchema: {
1459
- type: "object",
1460
- properties: {
1461
- projectId: { type: "string" },
1462
- create: { type: "array", items: { type: "object" } },
1463
- update: { type: "array", items: { type: "object" } },
1464
- branch: { type: "string", description: "Optional: the id of one of Claude's open branches to write to (list_my_branches). Default: the working branch." }
1465
- },
1466
- additionalProperties: false
1467
- },
1468
- run: async (args) => {
1469
- const projectId = await projectFor(args["projectId"]);
1470
- const featureOf = (item) => {
1471
- const id = str(item["featureId"]);
1472
- if (id) return id;
1473
- const name = str(item["feature"]) ?? "General";
1474
- return `f_${name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "general"}`;
1475
- };
1476
- const create = (Array.isArray(args["create"]) ? args["create"] : []).map((raw) => {
1477
- const { feature: _feature, ...item } = raw;
1478
- return { ...item, featureId: featureOf(raw) };
1479
- });
1480
- const update = (Array.isArray(args["update"]) ? args["update"] : []).map((raw) => {
1481
- const item = raw;
1482
- if (item["feature"] === void 0) return item;
1483
- const { feature: _feature, ...rest } = item;
1484
- return { ...rest, featureId: featureOf(item) };
1485
- });
1486
- const saved = await service.saveLibrary(projectId, {
1487
- create,
1488
- update,
1489
- message: "Test cases written with Claude",
1490
- ...str(args["branch"]) ? { changeId: str(args["branch"]) } : {}
1491
- });
1492
- const made = saved.created.map((c) => `${c.key} ${c.title} (id ${c.id})`);
1493
- const edited = saved.updated.map((c) => `${c.key} ${c.title}`);
1494
- return text([
1495
- made.length ? `Added ${made.length}: ${made.join("; ")}.` : "",
1496
- edited.length ? `Updated ${edited.length}: ${edited.join("; ")}.` : "",
1497
- saved.duplicates.length ? `Skipped ${saved.duplicates.length} already in the library: ${saved.duplicates.map((d) => `"${d.title}" is ${d.matches}`).join("; ")}.` : "",
1498
- `On Claude's working branch ${saved.branch}.`
1499
- ].filter(Boolean).join(" "));
1500
- }
1501
- },
1502
- {
1503
- name: "link_test_case",
1504
- title: "Link an automation to a test case",
1505
- description: "Record that an automation (a case id from save_case or project_catalog) checks a library test case (its key like TC-12, or its id). unlink: true removes the link. Do this after save_case for every test case the automation proves.",
1506
- inputSchema: {
1507
- type: "object",
1508
- properties: {
1509
- projectId: { type: "string" },
1510
- testCase: { type: "string", description: "TC-12, or the test case id." },
1511
- automationId: { type: "string" },
1512
- unlink: { type: "boolean" },
1513
- branch: { type: "string" }
1514
- },
1515
- required: ["testCase", "automationId"],
1516
- additionalProperties: false
1517
- },
1518
- run: async (args) => {
1519
- const projectId = await projectFor(args["projectId"]);
1520
- const wanted = str(args["testCase"]) ?? "";
1521
- const automationId = str(args["automationId"]) ?? "";
1522
- const { cases } = await service.library(projectId);
1523
- const target = cases.find((c) => c.id === wanted || c.key.toLowerCase() === wanted.toLowerCase());
1524
- if (!target) return text(`No test case ${wanted} in the library \u2014 library_cases lists them.`);
1525
- const has = target.automation.links.some((l) => l.automationId === automationId);
1526
- const unlink = args["unlink"] === true;
1527
- if (has !== unlink) return text(`${target.key} is ${unlink ? "not" : "already"} linked to ${automationId}.`);
1528
- const links = unlink ? target.automation.links.filter((l) => l.automationId !== automationId) : [...target.automation.links, { automationId, caseRevision: target.revision + 1, at: (/* @__PURE__ */ new Date()).toISOString(), by: "Claude" }];
1529
- const state = links.length ? "automated" : target.automation.state === "automated" ? "none" : target.automation.state;
1530
- const saved = await service.saveLibrary(projectId, {
1531
- update: [{ id: target.id, revision: target.revision, automation: { ...target.automation, state, links } }],
1532
- message: `${unlink ? "Unlink" : "Link"} ${target.key} ${unlink ? "from" : "to"} ${automationId}`,
1533
- ...str(args["branch"]) ? { changeId: str(args["branch"]) } : {}
1534
- });
1535
- return text(`${unlink ? "Unlinked" : "Linked"} ${target.key} "${target.title}" ${unlink ? "from" : "to"} automation ${automationId}, on Claude's working branch ${saved.branch}.`);
1536
- }
1537
- },
1538
1390
  {
1539
1391
  name: "project_brief",
1540
1392
  title: "Read the project's memory",
1541
- description: "The project's own knowledge, in one call: About the product (product.md), memory/decisions.md, what each linked codebase folder was learned as, the list of feature pages and session summaries, and the documents it has. Call it first in every conversation.",
1393
+ description: "The project's own knowledge, in one call: About the product (product.md), memory/decisions.md, what each linked codebase folder was learned as, and the list of feature pages and session summaries. Call it first in every conversation.",
1542
1394
  inputSchema: { type: "object", properties: { projectId: { type: "string" } }, additionalProperties: false },
1543
1395
  annotations: { readOnlyHint: true },
1544
1396
  run: async (args) => {
1545
1397
  const projectId = await projectFor(args["projectId"]);
1546
- const [{ pages }, { sources }] = await Promise.all([
1547
- service.knowledgePages(projectId),
1548
- service.sources(projectId).catch(() => ({ sources: [] }))
1549
- ]);
1398
+ const { pages } = await service.knowledgePages(projectId);
1550
1399
  const read = async (path) => pages.some((p) => p.path === path) ? (await service.knowledgePage(projectId, path)).content : null;
1551
1400
  const [product, glossary, decisions] = await Promise.all(["product.md", "glossary.md", "memory/decisions.md"].map(read));
1552
1401
  const codebases = pages.filter((p) => p.path.startsWith("codebase/"));
@@ -1562,9 +1411,7 @@ ${decisions}` : "",
1562
1411
  codebases.length ? `## Codebase, as learned
1563
1412
  ${headers.join("\n")}` : "No codebase learned yet.",
1564
1413
  `## Other pages
1565
- ${pages.filter((p) => !shown.has(p.path)).map((p) => `- ${p.path}`).join("\n") || "none"}`,
1566
- `## Documents
1567
- ${sources.map((s) => `- ${s.title} (id ${s.id}, v${s.version}) \u2014 requirements: ${s.requirements["new"] ?? 0} new, ${s.requirements["changed"] ?? 0} changed, ${s.requirements["active"] ?? 0} unchanged, ${s.requirements["removed"] ?? 0} removed`).join("\n") || "none"}`
1414
+ ${pages.filter((p) => !shown.has(p.path)).map((p) => `- ${p.path}`).join("\n") || "none"}`
1568
1415
  ];
1569
1416
  return text(parts.filter(Boolean).join("\n\n"));
1570
1417
  }
@@ -1616,353 +1463,6 @@ ${sources.map((s) => `- ${s.title} (id ${s.id}, v${s.version}) \u2014 requiremen
1616
1463
  return text(`Wrote ${saved.path} (${saved.length} characters) on Claude's working branch ${saved.branch}.`);
1617
1464
  }
1618
1465
  },
1619
- {
1620
- name: "sources",
1621
- title: "Read source documents",
1622
- description: "Without sourceId: every source (PRDs, CRs, feature docs, Jira stories, Figma files\u2026) with its version and how many requirements are new, changed, unchanged or removed. With sourceId: the latest version's text.",
1623
- inputSchema: { type: "object", properties: { projectId: { type: "string" }, sourceId: { type: "string" } }, additionalProperties: false },
1624
- annotations: { readOnlyHint: true },
1625
- run: async (args) => {
1626
- const projectId = await projectFor(args["projectId"]);
1627
- const id = str(args["sourceId"]);
1628
- if (id) {
1629
- const source = await service.source(projectId, id);
1630
- return text(`# ${source.title} (v${source.version})
1631
-
1632
- ${source.text.slice(0, 6e4)}`);
1633
- }
1634
- const { sources } = await service.sources(projectId);
1635
- if (!sources.length) return text("No sources yet. add_source adds a document by text or link; the Knowledge screen takes files.");
1636
- return text(sources.map((s) => `${s.title} (id ${s.id}, v${s.version}, ${s.kind}${s.externalUrl ? `, ${s.externalUrl}` : ""}) \u2014 ${s.requirements["new"] ?? 0} new, ${s.requirements["changed"] ?? 0} changed, ${s.requirements["active"] ?? 0} unchanged, ${s.requirements["removed"] ?? 0} removed`).join("\n"));
1637
- }
1638
- },
1639
- {
1640
- name: "add_source",
1641
- title: "Add a source document",
1642
- description: "Add a document tests are written from \u2014 as text (Markdown is best: headings and lists are how requirements are found) or as a public link \u2014 or a new version of one (sourceId). The same text again is not a new version. Requirements are found and compared at once.",
1643
- inputSchema: {
1644
- type: "object",
1645
- properties: { projectId: { type: "string" }, title: { type: "string" }, text: { type: "string" }, url: { type: "string" }, sourceId: { type: "string" } },
1646
- additionalProperties: false
1647
- },
1648
- run: async (args) => {
1649
- const projectId = await projectFor(args["projectId"]);
1650
- const made = await service.addSource(projectId, {
1651
- ...str(args["title"]) ? { title: str(args["title"]) } : {},
1652
- ...typeof args["text"] === "string" ? { text: args["text"] } : {},
1653
- ...str(args["url"]) ? { url: str(args["url"]) } : {}
1654
- }, str(args["sourceId"]));
1655
- const r = made.requirements;
1656
- return text(made.changed ? `${made.source.title} is now v${made.source.version} (id ${made.source.id}). Requirements: ${r["added"] ?? 0} new, ${r["changed"] ?? 0} changed, ${r["unchanged"] ?? 0} unchanged, ${r["removed"] ?? 0} removed.` : `${made.source.title} has not changed since v${made.source.version}; nothing new.`);
1657
- }
1658
- },
1659
- {
1660
- name: "delete_source",
1661
- title: "Delete a source document",
1662
- description: "Delete a source and everything found in it, for good. Only after the person has said to.",
1663
- inputSchema: { type: "object", properties: { projectId: { type: "string" }, sourceId: { type: "string" } }, required: ["sourceId"], additionalProperties: false },
1664
- annotations: { destructiveHint: true },
1665
- run: async (args) => {
1666
- const projectId = await projectFor(args["projectId"]);
1667
- await service.deleteSource(projectId, str(args["sourceId"]) ?? "");
1668
- return text(`Deleted the source ${str(args["sourceId"])} and its requirements.`);
1669
- }
1670
- },
1671
- {
1672
- name: "update_requirement",
1673
- title: "File or correct a requirement",
1674
- description: "Set which feature a requirement belongs to (featureId like f_checkout), or correct its wording where extraction got it wrong.",
1675
- inputSchema: { type: "object", properties: { projectId: { type: "string" }, requirementId: { type: "string" }, featureId: { type: "string" }, text: { type: "string" } }, required: ["requirementId"], additionalProperties: false },
1676
- run: async (args) => {
1677
- const projectId = await projectFor(args["projectId"]);
1678
- const saved = await service.updateRequirement(projectId, str(args["requirementId"]) ?? "", {
1679
- ...typeof args["featureId"] === "string" ? { featureId: args["featureId"] } : {},
1680
- ...str(args["text"]) ? { text: str(args["text"]) } : {}
1681
- });
1682
- return text(`${saved.id}${saved.featureId ? ` is filed under ${saved.featureId}` : ""}: ${saved.text}`);
1683
- }
1684
- },
1685
- {
1686
- name: "requirements",
1687
- title: "Read requirements",
1688
- description: "Requirements found in sources, each with where it is (heading path), its state as of the source's latest version \u2014 new, changed (with what it said before), active (unchanged) or removed \u2014 and its id for covers. Optional sourceId and state narrow it.",
1689
- inputSchema: { type: "object", properties: { projectId: { type: "string" }, sourceId: { type: "string" }, state: { type: "string", enum: ["new", "changed", "active", "removed"] } }, additionalProperties: false },
1690
- annotations: { readOnlyHint: true },
1691
- run: async (args) => {
1692
- const projectId = await projectFor(args["projectId"]);
1693
- const [{ requirements }, { cases }] = await Promise.all([
1694
- service.requirements(projectId, { ...str(args["sourceId"]) ? { sourceId: str(args["sourceId"]) } : {}, ...str(args["state"]) ? { state: str(args["state"]) } : {} }),
1695
- service.library(projectId)
1696
- ]);
1697
- if (!requirements.length) return text("No requirements match.");
1698
- return text(requirements.map((r) => {
1699
- const covering = cases.filter((c) => c.covers.includes(r.id)).map((c) => c.key);
1700
- return `${r.id} [${r.state}] ${r.sourceTitle} \u203A ${r.anchor}: ${r.text}${r.state === "changed" && r.history.length ? `
1701
- was: ${r.history.at(-1).text}` : ""}
1702
- covered by: ${covering.join(", ") || "nothing yet"}`;
1703
- }).join("\n"));
1704
- }
1705
- },
1706
- {
1707
- name: "find_similar_cases",
1708
- title: "Find test cases like this one",
1709
- description: "Before writing a test case, find existing ones that may already check the same thing \u2014 by title and steps. You judge whether one is really the same; if it is, link the requirement to it (covers) instead of writing a duplicate.",
1710
- inputSchema: { type: "object", properties: { projectId: { type: "string" }, text: { type: "string", description: "The case you are about to write: its title and steps." } }, required: ["text"], additionalProperties: false },
1711
- annotations: { readOnlyHint: true },
1712
- run: async (args) => {
1713
- const projectId = await projectFor(args["projectId"]);
1714
- const wanted = String(args["text"] ?? "");
1715
- const { cases } = await service.library(projectId);
1716
- const scored = cases.map((c) => ({ c, score: similarity(wanted, [c.title, ...c.steps.flatMap((st) => [st.action, st.expected ?? ""])].join(" ")) })).filter((x) => x.score >= 0.2).sort((a, b) => b.score - a.score).slice(0, 8);
1717
- if (!scored.length) return text("Nothing similar in the library.");
1718
- return text(scored.map(({ c, score }) => `${c.key} (id ${c.id}, revision ${c.revision}, ${Math.round(score * 100)}% alike) ${c.title}
1719
- ${c.steps.map((st, i) => ` ${i + 1}. ${st.action}${st.expected ? ` \u2192 ${st.expected}` : ""}`).join("\n")}`).join("\n"));
1720
- }
1721
- },
1722
- {
1723
- name: "save_automation_plan",
1724
- title: "Write the plan to automate a test case",
1725
- description: "Save the plan for automating a test case (TC key or id) before recording anything: flows to reuse, flows to record, which check proves each expected result, accounts and helpers it needs, and what cannot be automated and why. Marks it planned. approved: true only when the person has said the plan is right.",
1726
- inputSchema: {
1727
- type: "object",
1728
- properties: { projectId: { type: "string" }, testCase: { type: "string" }, plan: { type: "string" }, approved: { type: "boolean" }, branch: { type: "string" } },
1729
- required: ["testCase", "plan"],
1730
- additionalProperties: false
1731
- },
1732
- run: async (args) => {
1733
- const projectId = await projectFor(args["projectId"]);
1734
- const ref = str(args["testCase"]) ?? "";
1735
- const { cases } = await service.library(projectId);
1736
- const target = cases.find((c) => c.id === ref || c.key.toLowerCase() === ref.toLowerCase());
1737
- if (!target) return text(`No test case ${ref} in the library.`);
1738
- const saved = await service.saveLibrary(projectId, {
1739
- update: [{
1740
- id: target.id,
1741
- revision: target.revision,
1742
- automation: {
1743
- ...target.automation,
1744
- plan: String(args["plan"] ?? ""),
1745
- planApproved: args["approved"] === true,
1746
- state: target.automation.links.length ? target.automation.state : "planned"
1747
- }
1748
- }],
1749
- message: `Automation plan for ${target.key}`,
1750
- ...str(args["branch"]) ? { changeId: str(args["branch"]) } : {}
1751
- });
1752
- return text(`Saved the ${args["approved"] === true ? "approved " : ""}automation plan for ${target.key} "${target.title}" on Claude's working branch ${saved.branch}.`);
1753
- }
1754
- },
1755
- {
1756
- name: "test_cycles",
1757
- title: "Read manual test cycles",
1758
- description: "Manual test cycles and how they are going. Without cycleId: every cycle with its counts (passed, failed, blocked, untested). With cycleId: each case in it \u2014 key, title, steps, the outcome of each step, notes, evidence and bugs.",
1759
- inputSchema: {
1760
- type: "object",
1761
- properties: { projectId: { type: "string" }, cycleId: { type: "string" } },
1762
- additionalProperties: false
1763
- },
1764
- annotations: { readOnlyHint: true },
1765
- run: async (args) => {
1766
- const projectId = await projectFor(args["projectId"]);
1767
- const counts = (s) => `${s.passed} passed, ${s.failed} failed, ${s.blocked} blocked, ${s.skipped} skipped, ${s.untested} untested of ${s.total}`;
1768
- const id = str(args["cycleId"]);
1769
- if (!id) {
1770
- const { cycles } = await service.cycles(projectId);
1771
- if (!cycles.length) return text("No test cycles yet. manage_cycle with action create makes one from library cases.");
1772
- return text(cycles.map((c) => `${c.name} (id ${c.id}, ${c.status}) \u2014 ${counts(c.summary)}`).join("\n"));
1773
- }
1774
- const cycle = await service.cycle(projectId, id);
1775
- const lines = cycle.entries.map((e) => {
1776
- const r = e.result;
1777
- const steps = e.steps.map((st, i) => {
1778
- const got = r?.steps.find((x) => x.stepId === st.id);
1779
- return ` ${i + 1}. ${st.action}${st.expected ? ` \u2192 ${st.expected}` : ""}: ${got?.outcome ?? "untested"}${got?.actual ? ` (actual: ${got.actual})` : ""}`;
1780
- }).join("\n");
1781
- return `${e.key} ${e.title} [${e.priority}] \u2014 ${r?.outcome ?? "untested"}${e.assignee ? `, assigned to ${e.assignee}` : ""}${r?.note ? `
1782
- Note: ${r.note}` : ""}${r?.bugIds.length ? `
1783
- Bugs: ${r.bugIds.join(", ")}` : ""}${r?.evidence.length ? `
1784
- Evidence: ${r.evidence.map((ev) => ev.url ? `${ev.name} <${ev.url}>` : ev.name).join(", ")}` : ""}${steps ? `
1785
- ${steps}` : ""}`;
1786
- });
1787
- return text(`${cycle.name} (${cycle.status}) \u2014 ${counts(cycle.summary)}
1788
- ${lines.join("\n")}`);
1789
- }
1790
- },
1791
- {
1792
- name: "manage_cycle",
1793
- title: "Make or change a test cycle",
1794
- description: "action create: {name, description?, testCases: [TC keys or ids]} \u2014 cases are taken from the library as they are now (on Claude's working branch when it has one). action update: {cycleId, name?, description?, addTestCases?, removeTestCases?, assign?: {testCase, assignee}}. action close / reopen: {cycleId}. action delete: {cycleId} \u2014 deletes the cycle and its results for good; only after the person has said to.",
1795
- inputSchema: {
1796
- type: "object",
1797
- properties: {
1798
- projectId: { type: "string" },
1799
- action: { type: "string", enum: ["create", "update", "close", "reopen", "delete"] },
1800
- cycleId: { type: "string" },
1801
- name: { type: "string" },
1802
- description: { type: "string" },
1803
- testCases: { type: "array", items: { type: "string" } },
1804
- addTestCases: { type: "array", items: { type: "string" } },
1805
- removeTestCases: { type: "array", items: { type: "string" } },
1806
- assign: { type: "object", properties: { testCase: { type: "string" }, assignee: { type: "string" } }, additionalProperties: false }
1807
- },
1808
- required: ["action"],
1809
- additionalProperties: false
1810
- },
1811
- run: async (args) => {
1812
- const projectId = await projectFor(args["projectId"]);
1813
- const action = str(args["action"]);
1814
- const cycleId = str(args["cycleId"]);
1815
- const resolve = async (refs) => {
1816
- const wanted = Array.isArray(refs) ? refs.map(String) : [];
1817
- if (!wanted.length) return { ids: [], changeId: void 0 };
1818
- const lib = await service.library(projectId);
1819
- const ids = wanted.map((ref) => lib.cases.find((c) => c.id === ref || c.key.toLowerCase() === ref.toLowerCase())?.id);
1820
- const missing = wanted.filter((_, i) => !ids[i]);
1821
- if (missing.length) throw new Error(`no test case ${missing.join(", ")} in the library \u2014 library_cases lists them`);
1822
- return { ids, changeId: lib.changeId };
1823
- };
1824
- if (action === "create") {
1825
- const name = str(args["name"]);
1826
- if (!name) return text("A cycle needs a name.");
1827
- const { ids, changeId } = await resolve(args["testCases"]);
1828
- const made = await service.createCycle(projectId, { name, ...str(args["description"]) ? { description: str(args["description"]) } : {}, testCaseIds: ids }, changeId);
1829
- return text(`Made the cycle "${made.name}" (id ${made.id}) with ${made.entries.length} case${made.entries.length === 1 ? "" : "s"}: ${made.entries.map((e) => e.key).join(", ")}.`);
1830
- }
1831
- if (!cycleId) return text("Say which cycle (cycleId \u2014 test_cycles lists them).");
1832
- if (action === "delete") {
1833
- await service.deleteCycle(projectId, cycleId);
1834
- return text(`Deleted the cycle ${cycleId} and its results.`);
1835
- }
1836
- if (action === "close" || action === "reopen") {
1837
- const saved2 = await service.updateCycle(projectId, cycleId, { status: action === "close" ? "closed" : "open" });
1838
- return text(`${saved2.name} is ${saved2.status}.`);
1839
- }
1840
- const current = await service.cycle(projectId, cycleId);
1841
- const inCycle = (ref) => current.entries.find((e) => e.testCaseId === ref || e.key.toLowerCase() === ref.toLowerCase())?.testCaseId;
1842
- const added = await resolve(args["addTestCases"]);
1843
- const body = {
1844
- ...str(args["name"]) ? { name: str(args["name"]) } : {},
1845
- ...typeof args["description"] === "string" ? { description: args["description"] } : {},
1846
- ...added.ids.length ? { addCaseIds: added.ids } : {},
1847
- ...Array.isArray(args["removeTestCases"]) ? { removeCaseIds: args["removeTestCases"].map(String).map((r) => inCycle(r) ?? r) } : {}
1848
- };
1849
- const assign = args["assign"];
1850
- if (assign?.testCase) body["assign"] = { testCaseId: inCycle(assign.testCase) ?? assign.testCase, assignee: assign.assignee ?? "" };
1851
- const saved = await service.updateCycle(projectId, cycleId, body, added.changeId);
1852
- return text(`Updated "${saved.name}": ${saved.entries.length} case${saved.entries.length === 1 ? "" : "s"} (${saved.entries.map((e) => e.key).join(", ")}).`);
1853
- }
1854
- },
1855
- {
1856
- name: "record_result",
1857
- title: "Record how a case went",
1858
- description: "Record a manual result for one case in a cycle: steps [{step: its number (1, 2\u2026), outcome: passed|failed|blocked|skipped|untested, actual?: what really happened}], or a whole outcome, a note, links as evidence ([{name, url}]). Any failed step fails the case. retest: true keeps the earlier attempt in the case's history. Only record what the person tells you happened.",
1859
- inputSchema: {
1860
- type: "object",
1861
- properties: {
1862
- projectId: { type: "string" },
1863
- cycleId: { type: "string" },
1864
- testCase: { type: "string", description: "TC-12, or the test case id." },
1865
- steps: { type: "array", items: { type: "object" } },
1866
- outcome: { type: "string", enum: ["passed", "failed", "blocked", "skipped", "untested"] },
1867
- note: { type: "string" },
1868
- retest: { type: "boolean" },
1869
- evidenceLinks: { type: "array", items: { type: "object", properties: { name: { type: "string" }, url: { type: "string" } }, additionalProperties: false } }
1870
- },
1871
- required: ["cycleId", "testCase"],
1872
- additionalProperties: false
1873
- },
1874
- run: async (args) => {
1875
- const projectId = await projectFor(args["projectId"]);
1876
- const cycleId = str(args["cycleId"]) ?? "";
1877
- const cycle = await service.cycle(projectId, cycleId);
1878
- const ref = str(args["testCase"]) ?? "";
1879
- const entry = cycle.entries.find((e) => e.testCaseId === ref || e.key.toLowerCase() === ref.toLowerCase());
1880
- if (!entry) return text(`${ref} is not in "${cycle.name}" \u2014 test_cycles lists its cases.`);
1881
- const steps = (Array.isArray(args["steps"]) ? args["steps"] : []).map((raw) => {
1882
- const item = raw;
1883
- const at = typeof item.step === "number" ? entry.steps[item.step - 1]?.id : void 0;
1884
- return { stepId: String(item.stepId ?? at ?? ""), outcome: String(item.outcome ?? ""), ...typeof item.actual === "string" ? { actual: item.actual } : {} };
1885
- });
1886
- const saved = await service.recordResult(projectId, cycleId, entry.testCaseId, {
1887
- steps,
1888
- ...str(args["outcome"]) ? { outcome: str(args["outcome"]) } : {},
1889
- ...typeof args["note"] === "string" ? { note: args["note"] } : {},
1890
- ...args["retest"] === true ? { retest: true } : {}
1891
- });
1892
- for (const link of Array.isArray(args["evidenceLinks"]) ? args["evidenceLinks"] : []) {
1893
- const { name, url } = link;
1894
- if (url) await service.addEvidenceLink(projectId, cycleId, entry.testCaseId, { name: name || "Evidence", url });
1895
- }
1896
- const now = saved.entries.find((e) => e.testCaseId === entry.testCaseId);
1897
- return text(`${entry.key} is ${now.result?.outcome ?? "untested"} in "${saved.name}". The cycle: ${saved.summary.passed} passed, ${saved.summary.failed} failed, ${saved.summary.blocked} blocked, ${saved.summary.untested} untested.`);
1898
- }
1899
- },
1900
- {
1901
- name: "bugs",
1902
- title: "Read bugs",
1903
- description: "The project's bugs: key (BUG-n), title, severity, status, and the test cases and cycle step they were found at. Optional status narrows it (open, in-progress, fixed, verified, closed, wont-fix).",
1904
- inputSchema: { type: "object", properties: { projectId: { type: "string" }, status: { type: "string" } }, additionalProperties: false },
1905
- annotations: { readOnlyHint: true },
1906
- run: async (args) => {
1907
- const projectId = await projectFor(args["projectId"]);
1908
- const { bugs } = await service.bugs(projectId);
1909
- const shown = str(args["status"]) ? bugs.filter((b) => b.status === str(args["status"])) : bugs;
1910
- if (!shown.length) return text("No bugs.");
1911
- return text(shown.map((b) => `${b.key} (id ${b.id}) ${b.title} \u2014 ${b.severity}, ${b.status}${b.testCaseIds.length ? `, test cases ${b.testCaseIds.join(", ")}` : ""}${b.description ? `
1912
- ${b.description.slice(0, 300)}` : ""}`).join("\n"));
1913
- }
1914
- },
1915
- {
1916
- name: "save_bug",
1917
- title: "Raise or update a bug",
1918
- description: "New: {title, description?, severity?: critical|major|minor|trivial, cycleId?, testCase?, step? (its number)} \u2014 found in a cycle, it is attached to that case's result there. Update: {bugId, title?, description?, severity?, status?: open|in-progress|fixed|verified|closed|wont-fix}.",
1919
- inputSchema: {
1920
- type: "object",
1921
- properties: {
1922
- projectId: { type: "string" },
1923
- bugId: { type: "string" },
1924
- title: { type: "string" },
1925
- description: { type: "string" },
1926
- severity: { type: "string" },
1927
- status: { type: "string" },
1928
- cycleId: { type: "string" },
1929
- testCase: { type: "string" },
1930
- step: { type: "number" }
1931
- },
1932
- additionalProperties: false
1933
- },
1934
- run: async (args) => {
1935
- const projectId = await projectFor(args["projectId"]);
1936
- const bugId = str(args["bugId"]);
1937
- if (bugId) {
1938
- const body2 = Object.fromEntries(["title", "description", "severity", "status"].filter((k) => typeof args[k] === "string").map((k) => [k, args[k]]));
1939
- const saved = await service.updateBug(projectId, bugId, body2);
1940
- return text(`${saved.key} "${saved.title}" is ${saved.status} (${saved.severity}).`);
1941
- }
1942
- const title = str(args["title"]);
1943
- if (!title) return text("A bug needs a title.");
1944
- const body = {
1945
- title,
1946
- ...typeof args["description"] === "string" ? { description: args["description"] } : {},
1947
- ...str(args["severity"]) ? { severity: str(args["severity"]) } : {}
1948
- };
1949
- const cycleId = str(args["cycleId"]);
1950
- const ref = str(args["testCase"]);
1951
- if (cycleId && ref) {
1952
- const cycle = await service.cycle(projectId, cycleId);
1953
- const entry = cycle.entries.find((e) => e.testCaseId === ref || e.key.toLowerCase() === ref.toLowerCase());
1954
- if (!entry) return text(`${ref} is not in that cycle.`);
1955
- const step = typeof args["step"] === "number" ? entry.steps[args["step"] - 1]?.id : void 0;
1956
- body["foundAt"] = { cycleId, testCaseId: entry.testCaseId, ...step ? { stepId: step } : {} };
1957
- } else if (ref) {
1958
- const lib = await service.library(projectId);
1959
- const found = lib.cases.find((c) => c.id === ref || c.key.toLowerCase() === ref.toLowerCase());
1960
- if (found) body["testCaseIds"] = [found.id];
1961
- }
1962
- const made = await service.createBug(projectId, body);
1963
- return text(`Raised ${made.key} "${made.title}" (${made.severity}).`);
1964
- }
1965
- },
1966
1466
  {
1967
1467
  name: "close_browser",
1968
1468
  title: "Close the browser",
package/dist/engine.js CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  resolveCheckouts,
10
10
  start,
11
11
  status
12
- } from "./chunk-T7I2US4Y.js";
12
+ } from "./chunk-FKD5OAUV.js";
13
13
  export {
14
14
  AGENT_VERSION,
15
15
  browsersReady,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowriki/agent",
3
- "version": "0.1.0-beta.40",
3
+ "version": "0.1.0-beta.42",
4
4
  "description": "Run Flowriki UI tests on your own computer. Connects this machine to your Flowriki account.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",