@bendyline/gezel-mcp 1.2.2 → 1.2.4

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/server.js +427 -53
  2. package/package.json +3 -3
package/dist/server.js CHANGED
@@ -9,9 +9,13 @@ import {
9
9
  CreateTaskInputSchema,
10
10
  EmptyInputSchema,
11
11
  EnsureGezelInputSchema,
12
+ FindFilesRequestSchema,
12
13
  GEZEL_TOOL_DESCRIPTIONS as GEZEL_TOOL_DESCRIPTIONS2,
13
14
  GetScriptRunInputSchema,
14
15
  GetTaskInputSchema,
16
+ KnowledgeIdSchema,
17
+ KnowledgeNearbyRequestSchema,
18
+ KnowledgeRadiusSchema,
15
19
  ListArtifactsInputSchema,
16
20
  ListDirectoryInputSchema,
17
21
  ListDocumentsInputSchema,
@@ -37,6 +41,7 @@ import {
37
41
  WriteTaskNoteInputSchema,
38
42
  findGezelInRoster,
39
43
  findProjectByReference,
44
+ formatMediaClock,
40
45
  gezelNotFoundMessage,
41
46
  gezelRosterHint,
42
47
  normalizeArtifactPath,
@@ -55,6 +60,7 @@ import {
55
60
  NpmPackageNameSchema,
56
61
  NpmRegistryVersionSchema,
57
62
  ProviderNameSchema,
63
+ RETRIEVAL_SOURCES,
58
64
  StepGateUnionSchema,
59
65
  addGezelToProjectText,
60
66
  advanceGateFailureText,
@@ -110,6 +116,7 @@ import {
110
116
  taskOwnedPrefixes,
111
117
  taskScopedWriteDeniedMessage,
112
118
  uniqueStepId,
119
+ unknownTaskStepText,
113
120
  workspaceDrawerPrefix,
114
121
  writeTaskNoteText
115
122
  } from "@bendyline/gezel";
@@ -361,7 +368,11 @@ function inferCraftbookJobParams(args) {
361
368
  });
362
369
  }
363
370
  function suggestedCraftbookInvocation(args) {
364
- const description = args.query.trim();
371
+ const query = args.query.trim();
372
+ const userRequest = args.jobDescription?.trim();
373
+ const description = userRequest && userRequest !== query ? `${userRequest}
374
+
375
+ Task context from craftbook search: ${query}` : query;
365
376
  const params = inferCraftbookJobParams({
366
377
  paramSchema: args.paramSchema,
367
378
  jobDescription: description
@@ -369,9 +380,23 @@ function suggestedCraftbookInvocation(args) {
369
380
  return {
370
381
  craftbookId: args.craftbookId,
371
382
  description,
383
+ ...args.project ? { project: args.project } : {},
372
384
  ...Object.keys(params).length > 0 ? { params } : {}
373
385
  };
374
386
  }
387
+ function craftbookSuggestionGuidance(invocation) {
388
+ const { project: searchProject, ...recipe } = invocation;
389
+ return [
390
+ "Compare these candidates with the full user request; choose a lower match or reject all of them if none fits.",
391
+ "Preserve the requested project: for a new project, use start_project; for an existing project, pass its id explicitly.",
392
+ "Keep the full task brief, deliverable destination, and acceptance criteria. If no candidate fits, use a generic build-loop task in the requested project.",
393
+ `
394
+
395
+ Candidate recipe details (not a launch call): ${JSON.stringify(recipe)}`,
396
+ `${searchProject ? `Search scope: ${JSON.stringify(searchProject)}. ` : ""}The search scope does not select a destination. Resolve the destination from the user request before launching; never copy the search scope into a launch call by default.`,
397
+ "Invocation installs exact trusted zero-configuration bundled dependencies; remaining setup blocks task creation."
398
+ ].join(" ");
399
+ }
375
400
  function normalizeCraftbookInvocationParams(params, outputPath) {
376
401
  const merged = {
377
402
  ...params ?? {},
@@ -449,6 +474,7 @@ function closestFileNames(target, names, limit = 3) {
449
474
 
450
475
  // src/tool-contracts.ts
451
476
  import { toolErrorText } from "@bendyline/gezel";
477
+ import { KnowledgeLocationSchema } from "@bendyline/gezel";
452
478
  import { z as z2 } from "zod";
453
479
 
454
480
  // src/tool-inventory.ts
@@ -599,11 +625,11 @@ var GitToolOutputSchema = ExecutionToolOutputSchema.extend({
599
625
  });
600
626
  var MemorySaveToolOutputSchema = ToolResultSummarySchema.extend({
601
627
  status: z2.enum(["saved", "duplicate"]),
602
- scope: z2.enum(["gezel", "project"]),
628
+ scope: z2.enum(["gezel", "project", "user"]),
603
629
  indexed: z2.boolean().optional()
604
630
  });
605
631
  var MemoryListToolOutputSchema = ToolResultSummarySchema.extend({
606
- scope: z2.enum(["gezel", "project"]),
632
+ scope: z2.enum(["gezel", "project", "user"]),
607
633
  days: z2.number().int().positive(),
608
634
  content: z2.string()
609
635
  });
@@ -651,6 +677,23 @@ var TOOL_OUTPUT_SCHEMAS = {
651
677
  list_tables: ListToolOutputSchema,
652
678
  describe_table: TableDescribeToolOutputSchema,
653
679
  query_table: TableQueryToolOutputSchema,
680
+ knowledge_nearby: z2.object({
681
+ documents: z2.array(
682
+ z2.object({
683
+ documentId: z2.string(),
684
+ title: z2.string(),
685
+ summary: z2.string().nullable(),
686
+ distanceMeters: z2.number().nonnegative(),
687
+ matchedLocation: KnowledgeLocationSchema,
688
+ uri: z2.string(),
689
+ publisherId: z2.string(),
690
+ catalogId: z2.string(),
691
+ catalogVersion: z2.string()
692
+ })
693
+ ),
694
+ total: z2.number().int().nonnegative(),
695
+ nextCursor: z2.string().optional()
696
+ }),
654
697
  search: SearchToolOutputSchema,
655
698
  search_memory: SearchToolOutputSchema,
656
699
  save_memory: MemorySaveToolOutputSchema,
@@ -738,6 +781,7 @@ var READ_ONLY_TOOLS = /* @__PURE__ */ new Set([
738
781
  "describe_table",
739
782
  "query_table",
740
783
  "search",
784
+ "knowledge_nearby",
741
785
  "search_memory",
742
786
  "list_memories",
743
787
  "list_dir",
@@ -798,6 +842,8 @@ var READ_ONLY_TOOLS = /* @__PURE__ */ new Set([
798
842
  "search_images",
799
843
  "find_similar_images",
800
844
  "describe_folder",
845
+ "list_photos",
846
+ "photo_groups",
801
847
  "find_entity",
802
848
  "list_entity_mentions",
803
849
  "list_archive",
@@ -1774,6 +1820,38 @@ function quantizeImageSize(size) {
1774
1820
  return Math.max(SIZE_MULTIPLE, Math.min(AGENT_IMAGE_MAX_SIDE_PX, rounded));
1775
1821
  }
1776
1822
 
1823
+ // src/installed-script-miss.ts
1824
+ var SCRIPT_DIRS = ["", "scripts/", "src/", "bin/", "tools/"];
1825
+ var SCRIPT_EXTS = [".mjs", ".js", ".ts", ".cjs"];
1826
+ function scriptFileCandidates(name) {
1827
+ const bare = name.trim();
1828
+ if (!/^[\w.-]+$/.test(bare)) return [];
1829
+ const stem = bare.replace(/\.(?:mjs|cjs|js|ts)$/i, "");
1830
+ return SCRIPT_DIRS.flatMap((dir) => SCRIPT_EXTS.map((ext) => `${dir}${stem}${ext}`));
1831
+ }
1832
+ function isPathShapedScriptName(name) {
1833
+ return /[/\\]/.test(name) || /\.(mjs|cjs|js|ts|py|sh)$/i.test(name);
1834
+ }
1835
+ function installedScriptMissHint(opts) {
1836
+ const { name, written, canRunFiles, canDerive, canWriteFiles = false } = opts;
1837
+ const file = written ?? (isPathShapedScriptName(name) ? name : void 0);
1838
+ const lead = isPathShapedScriptName(name) ? `"${name}" looks like a file path, but run_installed_script runs only scripts installed in the project (see list_scripts).` : written ? `"${name}" is not an installed script, but the project has \`${written}\`, a file you wrote.` : `run_installed_script only runs scripts installed in the project (see list_scripts), and "${name}" is not one.`;
1839
+ const steps = [];
1840
+ if (canRunFiles) {
1841
+ steps.push(
1842
+ file ? `Run that file with run_nodejs_script({ path: "${file}" }).` : "To run a script file you wrote, use run_nodejs_script({ path })."
1843
+ );
1844
+ }
1845
+ if (canDerive && !file) steps.push("To build a data file from other files, use derive_file.");
1846
+ if (canWriteFiles) {
1847
+ steps.push(
1848
+ canRunFiles ? "If run_nodejs_script is not in your tool list this turn, write the output file directly with write_file." : "Write the output file directly with write_file instead."
1849
+ );
1850
+ }
1851
+ const again = "Calling run_installed_script again with this name will fail the same way.";
1852
+ return [lead, ...steps, again].join(" ");
1853
+ }
1854
+
1777
1855
  // src/linked-workspace.ts
1778
1856
  function isLinkedWorkspacePath(inputPath) {
1779
1857
  const normalized = inputPath.replaceAll("\\", "/").replace(/\/{2,}/g, "/");
@@ -2663,6 +2741,9 @@ function staleTaskStepRefusal(err) {
2663
2741
  const { error, hint } = details;
2664
2742
  return error === "stale_task_step" && typeof hint === "string" && hint.trim() ? hint : null;
2665
2743
  }
2744
+ function sessionReboundToCurrentPass(args) {
2745
+ return args.activeStepId === args.sessionStepId && !!args.activeStepActivation && args.sessionActivation === args.activeStepActivation;
2746
+ }
2666
2747
 
2667
2748
  // src/validate.ts
2668
2749
  import ts2 from "typescript";
@@ -3731,10 +3812,29 @@ var linkedApi = new GezelClient({ baseUrl, token, fetch: linkedFetchImpl });
3731
3812
  var sessionStepCompleted = false;
3732
3813
  var sessionStepCompletion = "unknown";
3733
3814
  var sessionStepCheckedArtifacts = [];
3815
+ async function reboundToCurrentPass() {
3816
+ if (!sessionId) return false;
3817
+ try {
3818
+ const parsed = await parseRef(sessionTaskRef);
3819
+ const [task, session] = await Promise.all([
3820
+ api.getTask(parsed.projectId, parsed.num),
3821
+ api.getChatSession(sessionId)
3822
+ ]);
3823
+ return sessionReboundToCurrentPass({
3824
+ sessionStepId,
3825
+ activeStepId: task.activeStepId,
3826
+ activeStepActivation: task.craftbook.steps.find((s) => s.id === task.activeStepId)?.lastActivatedAt,
3827
+ sessionActivation: session.stepActivationId
3828
+ });
3829
+ } catch {
3830
+ return false;
3831
+ }
3832
+ }
3734
3833
  async function staleStepMutationResult() {
3735
3834
  if (!sessionTaskRef || !sessionStepId) return null;
3736
3835
  sessionStepCompletion = "unknown";
3737
3836
  sessionStepCheckedArtifacts = [];
3837
+ if (sessionStepCompleted && await reboundToCurrentPass()) sessionStepCompleted = false;
3738
3838
  let activeStepId;
3739
3839
  let activeStepOwnedBySession = false;
3740
3840
  if (!sessionStepCompleted) {
@@ -3858,6 +3958,19 @@ function editClient(target) {
3858
3958
  }
3859
3959
  return draftEditApi(client, diffpackId);
3860
3960
  }
3961
+ async function proposeDraftOperation(target, op) {
3962
+ if (target.kind === "linked") {
3963
+ throw new Error(
3964
+ `Cannot change ${target.displayPath} while drafting a change proposal \u2014 a proposal covers one project.`
3965
+ );
3966
+ }
3967
+ const res = await workspaceClient(target).proposeDiffpackDraftOperation(
3968
+ target.projectId,
3969
+ diffpackId,
3970
+ op
3971
+ );
3972
+ return res.message;
3973
+ }
3861
3974
  async function readWorkspaceFile(path) {
3862
3975
  const target = await concreteWorkspaceTarget(path);
3863
3976
  const client = isDrafting && target.kind === "current" ? draftEditApi(workspaceClient(target), diffpackId) : workspaceClient(target);
@@ -4087,6 +4200,9 @@ server.tool(
4087
4200
  }
4088
4201
  }
4089
4202
  );
4203
+ function memoryScopeId(scope) {
4204
+ return scope === "gezel" ? gezelId : scope === "project" ? projectId : "user";
4205
+ }
4090
4206
  server.tool(
4091
4207
  "save_memory",
4092
4208
  GEZEL_TOOL_DESCRIPTIONS2.save_memory,
@@ -4101,9 +4217,10 @@ server.tool(
4101
4217
  },
4102
4218
  body: JSON.stringify({
4103
4219
  scope,
4104
- id: scope === "gezel" ? gezelId : projectId,
4220
+ id: memoryScopeId(scope),
4105
4221
  text: normalizeMarkdown(text),
4106
- ...kind ? { kind } : {}
4222
+ ...kind ? { kind } : {},
4223
+ source: { project: projectId, gezel: gezelId }
4107
4224
  })
4108
4225
  });
4109
4226
  if (!res.ok) {
@@ -4130,14 +4247,14 @@ server.tool(
4130
4247
  );
4131
4248
  server.tool(
4132
4249
  "list_memories",
4133
- "List recent memory entries for the current agent or project.",
4250
+ "List recent memory entries: yours, the project\u2019s, or what you know about the person you work for.",
4134
4251
  {
4135
- scope: z5.enum(["gezel", "project"]).describe("Which memory to list"),
4252
+ scope: z5.enum(["gezel", "project", "user"]).describe('Which memory to list: "gezel" (yours), "project", or "user" (about the person)'),
4136
4253
  days: z5.number().int().positive().optional().describe("How many days back to look (default 7)")
4137
4254
  },
4138
4255
  async ({ scope, days }) => {
4139
4256
  try {
4140
- const id = scope === "gezel" ? gezelId : projectId;
4257
+ const id = memoryScopeId(scope);
4141
4258
  const res = await fetchImpl(
4142
4259
  `${baseUrl}/api/memory/recent?scope=${scope}&id=${encodeURIComponent(id)}&days=${days ?? 7}`,
4143
4260
  { headers: { Authorization: `Bearer ${token}` } }
@@ -5628,6 +5745,10 @@ server.tool(
5628
5745
  if (scoped) return scoped;
5629
5746
  try {
5630
5747
  const target = await concreteWorkspaceTarget(path);
5748
+ if (isDrafting) {
5749
+ const proposed = await proposeDraftOperation(target, { op: "mkdir", to: target.path });
5750
+ return { content: [{ type: "text", text: proposed }] };
5751
+ }
5631
5752
  await workspaceClient(target).mkdirProjectWorkspace(target.projectId, {
5632
5753
  path: target.path,
5633
5754
  ...gezelId ? { gezelId } : {},
@@ -5666,6 +5787,14 @@ server.tool(
5666
5787
  "rename cannot move files across project roots; read the source, write the destination, then delete the source explicitly"
5667
5788
  );
5668
5789
  }
5790
+ if (isDrafting) {
5791
+ const proposed = await proposeDraftOperation(fromTarget, {
5792
+ op: "move",
5793
+ from: fromTarget.path,
5794
+ to: toTarget.path
5795
+ });
5796
+ return { content: [{ type: "text", text: proposed }] };
5797
+ }
5669
5798
  await workspaceClient(fromTarget).renameProjectWorkspacePath(fromTarget.projectId, {
5670
5799
  fromPath: fromTarget.path,
5671
5800
  toPath: toTarget.path,
@@ -5681,6 +5810,51 @@ server.tool(
5681
5810
  }
5682
5811
  }
5683
5812
  );
5813
+ server.tool(
5814
+ "copy_path",
5815
+ "Copy a file or folder to a new path within the project with `copy_path({ fromPath, toPath })`. Never replaces an existing file: pick a destination nothing has.",
5816
+ {
5817
+ fromPath: z5.string().describe("The file or folder to copy, relative to the project root."),
5818
+ toPath: z5.string().describe("Where the copy goes, relative to the project root.")
5819
+ },
5820
+ async ({ fromPath, toPath }) => {
5821
+ const stale = await staleStepMutationResult();
5822
+ if (stale) return stale;
5823
+ const scoped = await taskScopedWriteRefusal(toPath, "workspace");
5824
+ if (scoped) return scoped;
5825
+ try {
5826
+ const [fromTarget, toTarget] = await Promise.all([
5827
+ concreteWorkspaceTarget(fromPath),
5828
+ concreteWorkspaceTarget(toPath)
5829
+ ]);
5830
+ if (fromTarget.projectId !== toTarget.projectId) {
5831
+ throw new Error(
5832
+ "copy_path cannot copy across project roots; read the source and write the destination instead"
5833
+ );
5834
+ }
5835
+ if (isDrafting) {
5836
+ const proposed = await proposeDraftOperation(fromTarget, {
5837
+ op: "copy",
5838
+ from: fromTarget.path,
5839
+ to: toTarget.path
5840
+ });
5841
+ return { content: [{ type: "text", text: proposed }] };
5842
+ }
5843
+ await workspaceClient(fromTarget).copyProjectWorkspacePath(fromTarget.projectId, {
5844
+ fromPath: fromTarget.path,
5845
+ toPath: toTarget.path,
5846
+ ...gezelId ? { gezelId } : {},
5847
+ ...sessionId ? { sessionId } : {}
5848
+ });
5849
+ return { content: [{ type: "text", text: `Copied ${fromPath} \u2192 ${toPath}` }] };
5850
+ } catch (err) {
5851
+ return {
5852
+ content: [{ type: "text", text: explainWriteFailure(err) }],
5853
+ isError: true
5854
+ };
5855
+ }
5856
+ }
5857
+ );
5684
5858
  server.tool(
5685
5859
  "npm_install",
5686
5860
  "Install one or more npm packages into the project workspace so you can `import` them from your scripts. Uses `pnpm add --ignore-scripts` under the hood. **ALWAYS BATCH**: list every package you need in a single `packages` array \u2014 each call that includes a package outside the pre-vetted list creates a user approval prompt, so calling this tool N times for N packages makes the user click N times. Common packages (zod, chalk, typescript, commander, date-fns, yaml, cheerio, marked, playwright-core, pino, tsx, undici, nanoid, mime-types) install immediately; unknown ones return `pending-approval` per package (all grouped into one question). When any package is pending, your turn ends; a follow-up message arrives once the user answers. Do NOT hallucinate package names \u2014 if you're not sure a package exists or does what you expect, ask the user first with `ask_user_question`.",
@@ -6714,7 +6888,7 @@ server.tool(
6714
6888
  );
6715
6889
  server.tool(
6716
6890
  "run_playwright_script",
6717
- "Run a Playwright script from the project's artifacts. **This is the main way gezels automate the browser.** The shape: call `write_artifact` to save a `.ts` file under `tests/` (test-runner mode, `*.spec.ts`) or `scripts/` (bare-script mode via Node's strip-types), then call this tool with the same path to run it. Use it for end-to-end tests, data extraction, multi-step automation, anything you'd want to re-run or tweak. The live `browser_navigate` / `browser_snapshot` tools exist too for quick interactive reads, but writing a short script and running it is usually the better shape \u2014 it leaves an artifact the team can build on.",
6891
+ "Run a Playwright script from the project's artifacts. **This is the main way gezels automate the browser.** The shape: call `write_artifact` to save a `.ts` file under `tests/` (test-runner mode, `*.spec.ts`) or `scripts/` (bare-script mode via Node's strip-types), then call this tool with the same path to run it. Use it for end-to-end tests, data extraction, multi-step automation, anything you'd want to re-run or tweak. The live `browser_navigate` / `browser_snapshot` tools exist too for quick interactive reads, but writing a short script and running it is usually the better shape \u2014 it leaves an artifact the team can build on. SECURITY: the script runs outside the script sandbox (it drives a real browser with network access), so the user approves each new or edited script before it runs; the approval covers that exact script and the local files it imports.",
6718
6892
  {
6719
6893
  path: z5.string().describe(
6720
6894
  'Script path relative to the artifacts root, e.g. "tests/home.spec.ts" or "scripts/scrape.ts".'
@@ -6724,7 +6898,28 @@ server.tool(
6724
6898
  )
6725
6899
  },
6726
6900
  async ({ path, mode }) => {
6727
- const res = await api.runPlaywrightScript(projectId, { path, ...mode ? { mode } : {} });
6901
+ const res = await api.runPlaywrightScript(projectId, {
6902
+ path,
6903
+ ...mode ? { mode } : {},
6904
+ ...gezelId ? { gezelId } : {},
6905
+ ...sessionId ? { sessionId } : {}
6906
+ });
6907
+ if (res.approvalPending) {
6908
+ const text2 = `Running ${path} needs user approval. Your turn ends here; a follow-up message arrives once the user answers. Don't retry in the meantime.`;
6909
+ return okResult(
6910
+ ExecutionToolOutputSchema,
6911
+ {
6912
+ summary: text2,
6913
+ state: "approval_pending",
6914
+ ok: false,
6915
+ approvalPending: true,
6916
+ ...res.questionId ? { questionId: res.questionId } : {},
6917
+ output: { path, ...mode ? { mode } : {} }
6918
+ },
6919
+ { text: text2 }
6920
+ );
6921
+ }
6922
+ if (res.declined) return errorResult(res.declined);
6728
6923
  const heading = res.ok ? `\u2713 ${path} completed successfully.` : `\u2717 ${path} failed${res.error ? ` (${res.error})` : ""}.`;
6729
6924
  const locallyTruncated = res.log.length > 3e4;
6730
6925
  const tail = locallyTruncated ? res.log.slice(-3e4) : res.log;
@@ -6783,6 +6978,24 @@ server.tool(
6783
6978
  ReadDocumentInputSchema.shape,
6784
6979
  async ({ path }) => {
6785
6980
  const knowledgeUri = parseKnowledgeUri(path);
6981
+ if (knowledgeUri?.fragment && "chunk" in knowledgeUri.fragment) {
6982
+ const passage = await api.readKnowledgePassage(
6983
+ knowledgeUri.catalogId,
6984
+ knowledgeUri.documentId,
6985
+ knowledgeUri.fragment.chunk
6986
+ );
6987
+ const articleUri = path.split("#")[0];
6988
+ const provenance = [
6989
+ `Source: ${passage.title} \u2014 ${path}`,
6990
+ ...passage.headingPath.length ? [`Section: ${passage.headingPath.join(" \u203A ")}`] : [],
6991
+ `Lines ${passage.lineStart}-${passage.lineEnd} of the article (whole article: read_document ${articleUri})`,
6992
+ ...passage.sourceUrl ? [`Origin: ${passage.sourceUrl}`] : [],
6993
+ ...passage.sourceUpdatedAt ? [`Snapshot: ${passage.sourceUpdatedAt}`] : []
6994
+ ].join("\n");
6995
+ return { content: [{ type: "text", text: `${provenance}
6996
+
6997
+ ${passage.text}` }] };
6998
+ }
6786
6999
  if (knowledgeUri) {
6787
7000
  const doc = await api.readKnowledgeDocument(knowledgeUri.catalogId, knowledgeUri.documentId);
6788
7001
  let body = doc.markdown;
@@ -7337,6 +7550,7 @@ async function launchCraftbookTask(args) {
7337
7550
  ...resolvedAssignee ? { assignee: resolvedAssignee } : {},
7338
7551
  ...args.craftbookInvocationKey ? { craftbookInvocationKey: args.craftbookInvocationKey } : {},
7339
7552
  ...gezelId ? { createdBy: { kind: "gezel", gezelId } } : {},
7553
+ ...args.tonight ? { nightShift: { enabled: true } } : {},
7340
7554
  dispatchEntry: true
7341
7555
  });
7342
7556
  return {
@@ -7429,7 +7643,7 @@ server.tool(
7429
7643
  content: [
7430
7644
  {
7431
7645
  type: "text",
7432
- text: 'No craftbook matched. Call invoke_craftbook with the generic "build-loop" procedure (design \u2192 build \u2192 evaluate \u2192 loop), or create_task with explicit phase steps. Do not call suggest_craftbook again with a rephrased query and do not claim work started until the action call succeeds.'
7646
+ text: 'No craftbook matched. Preserve the full user request and its destination: for a new project use start_project; for an existing project, invoke the generic "build-loop" procedure with that project id and the full task brief. Do not claim work started until the action call succeeds.'
7433
7647
  }
7434
7648
  ]
7435
7649
  };
@@ -7442,17 +7656,18 @@ server.tool(
7442
7656
  return `${i + 1}. ${s.name} (id: ${s.id}) [${s.source}, ${s.stepCount} step(s), ${pct}% match]${setup}${desc}`;
7443
7657
  }).join("\n");
7444
7658
  const top = res.suggestions[0];
7445
- const topMissing = projectCraftbooks?.missingToolsets[top.id] ?? [];
7446
7659
  const topManifest = projectCraftbooks?.items.find(
7447
7660
  (item) => item.manifest.kind === "craftbook-template" && item.manifest.id === top.id
7448
7661
  );
7662
+ const rootTurn = await currentRootTurnContext();
7449
7663
  const nextInvocation = suggestedCraftbookInvocation({
7450
7664
  craftbookId: top.id,
7451
7665
  query,
7666
+ jobDescription: rootTurn?.userText,
7667
+ project: resolvedProject,
7452
7668
  paramSchema: topManifest?.manifest.kind === "craftbook-template" ? topManifest.manifest.paramSchema : void 0
7453
7669
  });
7454
- const nextCall = nextInvocation.params ? `invoke_craftbook({"craftbookId":${JSON.stringify(nextInvocation.craftbookId)},"description":${JSON.stringify(nextInvocation.description)},"params":${JSON.stringify(nextInvocation.params)}})` : `invoke_craftbook({"craftbookId":${JSON.stringify(nextInvocation.craftbookId)},"description":${JSON.stringify(nextInvocation.description)}})`;
7455
- const nextAction = topMissing.length > 0 ? `Next call: ${nextCall}. It will install any exact trusted zero-configuration bundled dependency; if setup still remains, it returns a hard error and creates no task. Preserve the supplied description and params; do not call suggest_craftbook again with a rephrased query, switch to a generic project/job kickoff, or delegate the job raw.` : `Next call: ${nextCall} \u2014 send it now unless a lower match clearly fits the job better. Preserve the supplied description and params; do not call suggest_craftbook again with a rephrased query, switch to a generic project/job kickoff, delegate the job raw, or hand-write task steps; the recipe's gated steps already handle assignment and quality checks.`;
7670
+ const nextAction = craftbookSuggestionGuidance(nextInvocation);
7456
7671
  return {
7457
7672
  content: [
7458
7673
  {
@@ -7556,7 +7771,9 @@ server.tool(
7556
7771
  "Spawn and dispatch a task from a craftbook template \u2014 the procedure-first shorthand for create_task with a craftbookId. Exact trusted zero-configuration bundled dependencies install automatically at project scope; other zero-configuration MCP dependencies request the user's approval in chat. Dependencies that need credentials/configuration return a hard SETUP REQUIRED error and create no task. Invocation params are carried into recipe placeholders such as {{outputPath}}. Returns the new task ref.",
7557
7772
  {
7558
7773
  craftbookId: z5.string().describe('Craftbook id from list_craftbooks (e.g. "pull-request-review", "ship").'),
7559
- project: z5.string().optional().describe("Project id or name. Defaults to the current project."),
7774
+ project: z5.string().optional().describe(
7775
+ "Existing project id or name. Defaults to the current project; this tool does not create a new project. Use start_project when the user requests a new project."
7776
+ ),
7560
7777
  title: z5.string().optional().describe("Optional task title. Defaults to the craftbook name."),
7561
7778
  description: z5.string().optional().describe(
7562
7779
  "Optional task description \u2014 the job-to-be-done. Falls back to the craftbook description when omitted."
@@ -7566,9 +7783,22 @@ server.tool(
7566
7783
  params: CraftbookInvocationParamsArgSchema,
7567
7784
  outputPath: z5.string().optional().describe(
7568
7785
  "Convenience alias for params.outputPath. Preserves the requested project-workspace filename for document-production craftbooks."
7786
+ ),
7787
+ tonight: z5.boolean().optional().describe(
7788
+ "Run it in tonight's Night Shift instead of now. Use only when the user asks for it tonight or overnight."
7569
7789
  )
7570
7790
  },
7571
- async ({ craftbookId, project, title, description, version, assignee, params, outputPath }) => {
7791
+ async ({
7792
+ craftbookId,
7793
+ project,
7794
+ title,
7795
+ description,
7796
+ version,
7797
+ assignee,
7798
+ params,
7799
+ outputPath,
7800
+ tonight
7801
+ }) => {
7572
7802
  const resolvedProject = project ? await resolveProjectId(project) : projectId;
7573
7803
  try {
7574
7804
  const rootTurn = await currentRootTurnContext();
@@ -7581,7 +7811,8 @@ server.tool(
7581
7811
  description: effectiveDescription,
7582
7812
  version,
7583
7813
  assignee,
7584
- params: invocationParams
7814
+ params: invocationParams,
7815
+ ...tonight ? { tonight: true } : {}
7585
7816
  };
7586
7817
  const rootTurnId = rootTurn?.rootTurnId ?? null;
7587
7818
  const launchInvocation = rootTurnId ? {
@@ -8800,6 +9031,7 @@ server.tool(
8800
9031
  AskUserQuestionInputSchema.shape,
8801
9032
  async ({
8802
9033
  question,
9034
+ permissionRequest,
8803
9035
  prompt,
8804
9036
  description,
8805
9037
  choices,
@@ -8836,12 +9068,14 @@ server.tool(
8836
9068
  gezelId,
8837
9069
  sessionId,
8838
9070
  prompt: body,
9071
+ ...permissionRequest ? { permissionRequest } : {},
8839
9072
  ...choices ? { choices } : {},
8840
9073
  ...allowWriteIn !== void 0 ? { allowWriteIn } : {},
8841
9074
  ...multiSelect !== void 0 ? { multiSelect } : {},
8842
9075
  ...effectiveTaskRef ? { taskRef: effectiveTaskRef } : {},
8843
9076
  ...documentPath ? { documentPath } : {}
8844
9077
  });
9078
+ if (res.declined) return { content: [{ type: "text", text: res.declined }] };
8845
9079
  const colleague = toolIsAuthorizedForThisSession("message_gezel") ? await questionColleague(body) : void 0;
8846
9080
  return {
8847
9081
  content: [
@@ -9789,7 +10023,7 @@ server.tool(
9789
10023
  async function resolveAssigneeArg(raw) {
9790
10024
  const normalized = normalizeAssigneeArg(raw);
9791
10025
  if (!normalized) return void 0;
9792
- if (normalized.kind === "user") return { kind: "user" };
10026
+ if (normalized.kind === "user") return normalized;
9793
10027
  return { kind: "gezel", gezelId: await resolveGezelId(normalized.ref) };
9794
10028
  }
9795
10029
  function inferDraftDeliverable(task) {
@@ -9868,6 +10102,7 @@ function blueprintToStep(s) {
9868
10102
  const d = coerceBlueprintDeliverable(s.deliverable);
9869
10103
  return {
9870
10104
  name: s.name,
10105
+ ...s.assignee ? { assignee: s.assignee } : {},
9871
10106
  ...s.description ? { description: s.description } : {},
9872
10107
  ...s.prompt ? { prompt: s.prompt } : {},
9873
10108
  ...s.suggestedGezelId ? { suggestedGezelId: s.suggestedGezelId } : {},
@@ -9923,6 +10158,9 @@ server.tool(
9923
10158
  fanout: fanoutArg,
9924
10159
  dispatch: z5.boolean().optional().describe(
9925
10160
  "Hand the entry step to its assignee immediately as a task-scoped handoff (single-channel kickoff). Invalid on drafts and cron/fanout hosts."
10161
+ ),
10162
+ tonight: z5.boolean().optional().describe(
10163
+ "Run it in tonight's Night Shift instead of now. Use only when the user asks for it tonight or overnight."
9926
10164
  )
9927
10165
  }).shape,
9928
10166
  async ({
@@ -9940,12 +10178,14 @@ server.tool(
9940
10178
  cron,
9941
10179
  cronOverlap,
9942
10180
  fanout,
9943
- dispatch
10181
+ dispatch,
10182
+ tonight
9944
10183
  }) => {
9945
10184
  try {
9946
10185
  const projectId2 = await resolveProjectId(project);
9947
10186
  const resolvedAssignee = await resolveAssigneeArg(assignee);
9948
10187
  const created = await api.createTask(projectId2, {
10188
+ ...tonight ? { nightShift: { enabled: true } } : {},
9949
10189
  ...sessionTaskNamingMode,
9950
10190
  title,
9951
10191
  description,
@@ -10474,6 +10714,7 @@ server.tool(
10474
10714
  name: z5.string().min(1),
10475
10715
  description: z5.string().optional(),
10476
10716
  prompt: z5.string().optional(),
10717
+ assignee: StepBlueprintSchema.shape.assignee,
10477
10718
  suggestedGezelId: z5.string().optional(),
10478
10719
  suggestedRole: z5.string().optional().describe('Role hint, e.g. "developer", "reviewer".'),
10479
10720
  deliverable: deliverableArg,
@@ -10486,6 +10727,7 @@ server.tool(
10486
10727
  name,
10487
10728
  description,
10488
10729
  prompt,
10730
+ assignee,
10489
10731
  suggestedGezelId,
10490
10732
  suggestedRole,
10491
10733
  deliverable,
@@ -10505,6 +10747,7 @@ server.tool(
10505
10747
  name,
10506
10748
  ...description ? { description } : {},
10507
10749
  ...prompt ? { prompt } : {},
10750
+ ...assignee ? { assignee } : {},
10508
10751
  ...suggestedGezelId ? { suggestedGezelId } : {},
10509
10752
  ...suggestedRole ? { suggestedRole } : {},
10510
10753
  ...d ? { deliverable: d } : {},
@@ -10541,15 +10784,12 @@ async function explainAdvanceFailure(err, parsed, stepId, next) {
10541
10784
  }
10542
10785
  if (steps.length === 0) return base;
10543
10786
  const ids = steps.map((s) => s.id);
10544
- const roster = steps.map((s) => s.name ? `"${s.id}" (${s.name})` : `"${s.id}"`).join(", ");
10545
- if (next && next !== "next" && !ids.includes(next)) {
10787
+ if (next && next !== "next" && !ids.includes(next))
10546
10788
  return `${base}
10547
- This task has no step "${next}". Its steps are: ${roster}. Pass one of those ids as \`next\`, or omit \`next\` to advance to the following step in order.`;
10548
- }
10549
- if (!ids.includes(stepId)) {
10550
- return `${base}
10551
- This task has no step "${stepId}". Its steps are: ${roster}. Pass one of those ids as \`stepId\`.`;
10552
- }
10789
+ ${unknownTaskStepText("next", next, steps)}`;
10790
+ if (!ids.includes(stepId)) return `${base}
10791
+ ${unknownTaskStepText("stepId", stepId, steps)}`;
10792
+ const roster = steps.map((s) => s.name ? `"${s.id}" (${s.name})` : `"${s.id}"`).join(", ");
10553
10793
  return `${base}
10554
10794
  The task's steps are: ${roster}.`;
10555
10795
  }
@@ -11420,12 +11660,7 @@ server.tool(
11420
11660
  server.tool(
11421
11661
  "find_files",
11422
11662
  "Find files in the project workspace by glob (e.g. `**/*.spec.ts`). Complement to `grep_files`, which searches contents. Skips `node_modules` and `.git`.",
11423
- {
11424
- glob: z5.string().min(1),
11425
- path: z5.string().optional(),
11426
- caseInsensitive: z5.boolean().optional(),
11427
- maxResults: z5.number().int().positive().optional()
11428
- },
11663
+ FindFilesRequestSchema.shape,
11429
11664
  async (args) => {
11430
11665
  try {
11431
11666
  const res = await api.toolFindFiles(projectId, args);
@@ -11731,13 +11966,57 @@ server.tool(
11731
11966
  }
11732
11967
  }
11733
11968
  );
11969
+ server.tool(
11970
+ "knowledge_nearby",
11971
+ GEZEL_TOOL_DESCRIPTIONS2.knowledge_nearby,
11972
+ KnowledgeNearbyRequestSchema.shape,
11973
+ async (body) => {
11974
+ try {
11975
+ const found = await api.toolKnowledgeNearby(projectId, body);
11976
+ const result = {
11977
+ ...found,
11978
+ documents: found.documents.map((document) => ({
11979
+ documentId: document.id,
11980
+ title: document.title,
11981
+ summary: document.summary,
11982
+ distanceMeters: document.distanceMeters,
11983
+ matchedLocation: {
11984
+ id: document.matchedLocation.id,
11985
+ latitude: document.matchedLocation.latitude,
11986
+ longitude: document.matchedLocation.longitude,
11987
+ role: document.matchedLocation.role
11988
+ },
11989
+ uri: document.uri,
11990
+ publisherId: document.publisherId,
11991
+ catalogId: document.catalogId,
11992
+ catalogVersion: document.catalogVersion
11993
+ }))
11994
+ };
11995
+ return {
11996
+ content: [{ type: "text", text: JSON.stringify(result) }],
11997
+ structuredContent: result
11998
+ };
11999
+ } catch (error) {
12000
+ return {
12001
+ content: [
12002
+ { type: "text", text: `knowledge_nearby failed: ${unwrapApiError(error)}` }
12003
+ ],
12004
+ isError: true
12005
+ };
12006
+ }
12007
+ }
12008
+ );
11734
12009
  server.tool(
11735
12010
  "search",
11736
12011
  GEZEL_TOOL_DESCRIPTIONS2.search,
11737
12012
  SearchInputSchema.extend({
11738
- sources: z5.array(
11739
- z5.enum(["workspace", "artifacts", "project-memory", "gezel-memory", "shared", "knowledge"])
11740
- ).optional().describe("Optional corpus filter. Omit to search all knowledge available to this project."),
12013
+ spatial: KnowledgeRadiusSchema.optional().describe(
12014
+ "Restrict knowledge to subject locations within this radius, in meters."
12015
+ ),
12016
+ catalogs: z5.array(KnowledgeIdSchema).optional().describe(
12017
+ 'Search only these knowledge catalogs. Implies sources: ["knowledge"] unless sources is given.'
12018
+ ),
12019
+ sources: z5.array(z5.enum(RETRIEVAL_SOURCES)).optional().describe("Optional corpus filter. Omit to search all knowledge available to this project."),
11741
12020
  maxResults: z5.number().int().positive().max(100).optional().describe(
11742
12021
  "Maximum results to request (default 30). The rendered text may show fewer when output is budgeted to the context window."
11743
12022
  ),
@@ -11746,13 +12025,18 @@ server.tool(
11746
12025
  'Only results under this path prefix (e.g. "src/engine/" or "../<project-id>/docs/"). Narrowing only.'
11747
12026
  )
11748
12027
  }).shape,
11749
- async ({ query, sources, maxResults, cursor, pathPrefix }) => {
12028
+ async ({ query, sources, maxResults, cursor, pathPrefix, spatial, catalogs }) => {
11750
12029
  try {
11751
12030
  const res = await api.toolSearch(projectId, {
11752
12031
  query,
11753
12032
  gezelId,
11754
12033
  includeShared: true,
11755
- ...sources ? { sources } : {},
12034
+ // Naming catalogs is asking for reference material: without this the
12035
+ // workspace and shared library kept answering, and their rank-derived
12036
+ // "strong" hits crowded the named catalog off the page.
12037
+ ...sources ? { sources } : spatial || catalogs ? { sources: ["knowledge"] } : {},
12038
+ ...spatial ? { spatial } : {},
12039
+ ...catalogs ? { catalogs } : {},
11756
12040
  ...maxResults ? { maxResults } : {},
11757
12041
  ...cursor ? { offset: cursor } : {},
11758
12042
  ...pathPrefix ? { pathPrefix } : {}
@@ -12104,18 +12388,21 @@ ${fmt(res.sinks)}`
12104
12388
  );
12105
12389
  server.tool(
12106
12390
  "search_images",
12107
- "Find images in the workspace by filename, caption, or dimensions. Returns matching image paths with width/height/format and a caption when the index has one. Use describe_folder for a folder overview, find_similar_images for visual lookalikes.",
12391
+ 'Find images in the workspace by what they show (e.g. "whiteboard with a sprint plan", "red bicycle"), or by filename or caption. Set kinds to also find moments in audio and video files. Returns paths with width/height/format, a caption when the index has one, and for audio/video the matching time window. Use describe_folder for a folder overview, find_similar_images for visual lookalikes.',
12108
12392
  {
12109
- query: z5.string().min(1).describe("Keywords \u2014 filename words, caption terms, or format."),
12110
- maxResults: z5.number().int().positive().max(100).optional()
12393
+ query: z5.string().min(1).describe("What to find \u2014 a description of the content, or filename/caption words."),
12394
+ maxResults: z5.number().int().positive().max(100).optional(),
12395
+ kinds: z5.array(z5.enum(["image", "audio", "video"])).min(1).optional().describe('Media to search (default ["image"]).')
12111
12396
  },
12112
12397
  async (args) => {
12113
12398
  try {
12114
12399
  const res = await api.toolSearchImages(projectId, args);
12400
+ const clock = formatMediaClock;
12115
12401
  const lines = res.results.map(
12116
- (r) => `${r.path}${r.width ? ` (${r.width}x${r.height} ${r.format ?? ""})` : ""}${r.caption ? ` \u2014 ${r.caption}` : ""}`
12402
+ (r) => `${r.path}${r.kind && r.kind !== "image" ? ` [${r.kind}${r.startMs !== void 0 ? ` ${clock(r.startMs)}${r.endMs !== void 0 ? `\u2013${clock(r.endMs)}` : ""}` : ""}]` : ""}${r.width ? ` (${r.width}x${r.height} ${r.format ?? ""})` : ""}${r.caption ? ` \u2014 ${r.caption}` : ""}`
12117
12403
  );
12118
- const summary = `${res.results.length} image${res.results.length === 1 ? "" : "s"} (engine=${res.engine}${res.truncated ? ", truncated" : ""})`;
12404
+ const noun = args.kinds?.some((k) => k !== "image") ? "match" : "image";
12405
+ const summary = `${res.results.length} ${noun}${res.results.length === 1 ? "" : noun === "match" ? "es" : "s"} (engine=${res.engine}${res.truncated ? ", truncated" : ""})`;
12119
12406
  return okResult(
12120
12407
  SearchToolOutputSchema,
12121
12408
  {
@@ -12136,7 +12423,7 @@ ${lines.join("\n") || "(none)"}` }
12136
12423
  );
12137
12424
  server.tool(
12138
12425
  "find_similar_images",
12139
- "Find images visually similar to a given image (by CLIP embedding). The visual index fills in the background as images are indexed; returns engine=unavailable until this image has been embedded.",
12426
+ "Find images visually similar to a given image (on-device image embeddings). The visual index fills in the background as images are indexed; returns engine=unavailable until this image has been embedded.",
12140
12427
  {
12141
12428
  path: z5.string().min(1).describe("Workspace-relative path of the reference image."),
12142
12429
  maxResults: z5.number().int().positive().max(100).optional()
@@ -12200,6 +12487,80 @@ server.tool(
12200
12487
  }
12201
12488
  }
12202
12489
  );
12490
+ server.tool(
12491
+ "list_photos",
12492
+ "List photos in the workspace from the index, newest first, with when each was taken, the camera, size and a caption once described. Filter by folder, date range (YYYY, YYYY-MM or YYYY-MM-DD), camera, screenshots, or nearness to a place. Reads no files.",
12493
+ {
12494
+ path: z5.string().optional().describe("Folder to scope to (optional)."),
12495
+ from: z5.string().optional().describe("Taken on or after: YYYY, YYYY-MM or YYYY-MM-DD."),
12496
+ to: z5.string().optional().describe("Taken on or before: YYYY, YYYY-MM or YYYY-MM-DD."),
12497
+ camera: z5.string().optional().describe("Camera make or model, any part."),
12498
+ screenshots: z5.boolean().optional().describe("true for only screenshots, false to leave them out."),
12499
+ near: z5.object({ lat: z5.number(), lon: z5.number(), km: z5.number().optional() }).optional().describe("Within km (default 5) of a place."),
12500
+ limit: z5.number().int().positive().max(500).optional()
12501
+ },
12502
+ async (args) => {
12503
+ try {
12504
+ const res = await api.toolListPhotos(projectId, args);
12505
+ const lines = res.photos.map(
12506
+ (p) => [
12507
+ p.path,
12508
+ p.takenAt?.replace("T", " ").slice(0, 16),
12509
+ p.camera,
12510
+ p.width && p.height ? `${p.width}x${p.height}` : void 0,
12511
+ p.screenshot ? "screenshot" : void 0,
12512
+ p.cloudOnly ? "in the cloud" : void 0,
12513
+ p.location ? `${p.location.lat.toFixed(4)},${p.location.lon.toFixed(4)}` : void 0,
12514
+ p.caption ? `"${p.caption.slice(0, 140)}"` : void 0
12515
+ ].filter(Boolean).join(" \xB7 ")
12516
+ );
12517
+ const head = `${res.total} photo${res.total === 1 ? "" : "s"}${res.truncated ? ` (showing ${res.photos.length})` : ""}${res.locationWithheld ? "; locations withheld for this session" : ""}`;
12518
+ return { content: [{ type: "text", text: [head, ...lines].join("\n") }] };
12519
+ } catch (err) {
12520
+ return {
12521
+ content: [{ type: "text", text: `list_photos failed: ${unwrapApiError(err)}` }],
12522
+ isError: true
12523
+ };
12524
+ }
12525
+ }
12526
+ );
12527
+ server.tool(
12528
+ "photo_groups",
12529
+ 'Group the photos from the index: by "event" (taken together, apart from screenshots), "duplicate" (byte-identical copies, with the space the extra copies take) or "similar" (bursts and retakes that look alike; needs image embeddings). Use it to propose albums or clean-ups; it changes nothing.',
12530
+ {
12531
+ by: z5.enum(["event", "duplicate", "similar"]).describe("How to group."),
12532
+ path: z5.string().optional().describe("Folder to scope to (optional)."),
12533
+ limit: z5.number().int().positive().max(200).optional()
12534
+ },
12535
+ async (args) => {
12536
+ try {
12537
+ const res = await api.toolPhotoGroups(projectId, args);
12538
+ if (res.engine === "unavailable") {
12539
+ return {
12540
+ content: [
12541
+ {
12542
+ type: "text",
12543
+ text: 'No lookalike groups yet: the photos have no image embeddings. Try by "event" or "duplicate".'
12544
+ }
12545
+ ]
12546
+ };
12547
+ }
12548
+ const lines = res.groups.map((g, i) => {
12549
+ const span = g.from ? `${g.from.slice(0, 16).replace("T", " ")} to ${g.to?.slice(0, 16).replace("T", " ")}` : "";
12550
+ const bytes = g.bytes ? ` \xB7 ${(g.bytes / 1048576).toFixed(1)} MB in extra copies` : "";
12551
+ return `${i + 1}. ${g.count} photos${span ? ` \xB7 ${span}` : ""}${bytes}
12552
+ ${g.paths.join("\n ")}`;
12553
+ });
12554
+ const head = `${res.groups.length} ${res.by} group${res.groups.length === 1 ? "" : "s"}${res.truncated ? " (more not shown)" : ""}`;
12555
+ return { content: [{ type: "text", text: [head, ...lines].join("\n") }] };
12556
+ } catch (err) {
12557
+ return {
12558
+ content: [{ type: "text", text: `photo_groups failed: ${unwrapApiError(err)}` }],
12559
+ isError: true
12560
+ };
12561
+ }
12562
+ }
12563
+ );
12203
12564
  server.tool(
12204
12565
  "find_entity",
12205
12566
  "List entities the index has resolved across files \u2014 email senders, document parties, etc. \u2014 with how many files mention each. Pass a query to filter by name, or a kind (person|party). Follow up with list_entity_mentions to see where an entity appears.",
@@ -12541,7 +12902,7 @@ server.tool(
12541
12902
  );
12542
12903
  server.tool(
12543
12904
  "run_git",
12544
- "Run a restricted git subcommand in the project workspace. Allowed subcommands: `status`, `log`, `diff`, `show`, `blame`, `branch`, `rev-parse`, `ls-files`. Most are inspections, but `branch` arguments can create, rename, or delete local refs; use `branch` with no args for inspection, and only pass mutation args when the user explicitly requested that change. Args use a structured argv array rather than a shell and reject `-c`, `--exec`, and `--upload-pack`.",
12905
+ "Run a restricted git subcommand in the project workspace. Allowed subcommands: `status`, `log`, `diff`, `show`, `blame`, `branch`, `rev-parse`, `ls-files`. Most are inspections, but `branch` arguments can create, rename, or delete local refs; use `branch` with no args for inspection, and only pass mutation args when the user explicitly requested that change. Args use a structured argv array rather than a shell. Each subcommand accepts only its common inspection options (e.g. `--oneline`, `-n`, `--stat`, `--format=`, `--short`, `--porcelain`), spelled out in full; options that write or read files outside the repository are refused, and paths must be relative to the workspace without `..`.",
12545
12906
  {
12546
12907
  subcommand: z5.enum([
12547
12908
  "status",
@@ -12615,15 +12976,16 @@ server.tool(
12615
12976
  GEZEL_TOOL_DESCRIPTIONS2.run_installed_script,
12616
12977
  RunInstalledScriptInputSchema.shape,
12617
12978
  async ({ project, name, scope, input }) => {
12618
- const looksLikePath = /[/\\]/.test(name) || /\.(mjs|cjs|js|ts|py|sh)$/i.test(name);
12619
- if (looksLikePath) {
12979
+ const hintFor = (written) => installedScriptMissHint({
12980
+ name,
12981
+ ...written ? { written } : {},
12982
+ canRunFiles: toolIsAuthorizedForThisSession("run_nodejs_script"),
12983
+ canDerive: toolIsAuthorizedForThisSession("derive_file"),
12984
+ canWriteFiles: toolIsAuthorizedForThisSession("write_file")
12985
+ });
12986
+ if (isPathShapedScriptName(name)) {
12620
12987
  return {
12621
- content: [
12622
- {
12623
- type: "text",
12624
- text: `"${name}" looks like a file path, but run_installed_script takes the NAME of a script already installed in the project (see list_scripts). To run a script file you wrote yourself, use run_nodejs_script instead. To build a derived data file from other files, derive_file is usually better still.`
12625
- }
12626
- ],
12988
+ content: [{ type: "text", text: hintFor() }],
12627
12989
  isError: true
12628
12990
  };
12629
12991
  }
@@ -12638,6 +13000,18 @@ server.tool(
12638
13000
  return formatScriptRunResult(res);
12639
13001
  } catch (err) {
12640
13002
  const msg = unwrapApiError(err);
13003
+ if (/not found/i.test(msg)) {
13004
+ let written;
13005
+ for (const candidate of scriptFileCandidates(name)) {
13006
+ const stat = await statWorkspacePath(candidate).catch(() => null);
13007
+ if (stat?.kind === "file") {
13008
+ written = candidate;
13009
+ break;
13010
+ }
13011
+ }
13012
+ return errorResult(`run_installed_script failed: ${msg}
13013
+ ${hintFor(written)}`);
13014
+ }
12641
13015
  return errorResult(`run_installed_script failed: ${msg}`);
12642
13016
  }
12643
13017
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bendyline/gezel-mcp",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "description": "Gezel MCP server — gives agents access to memory, workspace, artifacts, and tools.",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -55,8 +55,8 @@
55
55
  "!dist/**/*.map"
56
56
  ],
57
57
  "dependencies": {
58
- "@bendyline/gezel": "1.2.2",
59
- "@bendyline/gezel-client": "1.2.2",
58
+ "@bendyline/gezel": "1.2.4",
59
+ "@bendyline/gezel-client": "1.2.4",
60
60
  "@modelcontextprotocol/sdk": "^1.29.0",
61
61
  "typescript": "^6.0.3",
62
62
  "zod": "^4.4.3"