@beastmode-develeap/beastmode 0.1.383 → 0.1.384

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -4466,7 +4466,26 @@ function getBoardUrl(factoryPath) {
4466
4466
  }
4467
4467
  return "http://127.0.0.1:8080";
4468
4468
  }
4469
- async function executeTool(toolName, toolInput, factoryPath) {
4469
+ async function projectHasNoContext(factoryPath, scope) {
4470
+ if (!scope || scope === "factory") return false;
4471
+ const guideDir = join14(factoryPath, ".beastmode", "projects", scope);
4472
+ const hasGuide = existsSync15(join14(guideDir, "codebase-guide.md")) || existsSync15(join14(guideDir, "codebase-guide.l1.md")) || existsSync15(join14(guideDir, "codebase-guide.l0.txt"));
4473
+ if (hasGuide) return false;
4474
+ try {
4475
+ const boardUrl = getBoardUrl(factoryPath);
4476
+ const pollData = await boardGet(`/api/poll?board=${encodeURIComponent(scope)}`, boardUrl);
4477
+ const poll = JSON.parse(pollData);
4478
+ let total = 0;
4479
+ for (const items of Object.values(poll)) {
4480
+ if (Array.isArray(items)) total += items.length;
4481
+ }
4482
+ return total === 0;
4483
+ } catch {
4484
+ return false;
4485
+ }
4486
+ }
4487
+ async function executeTool(toolName, toolInput, factoryPath, scope = "factory") {
4488
+ const boardParam = scope && scope !== "factory" ? `?board=${encodeURIComponent(scope)}` : "";
4470
4489
  try {
4471
4490
  switch (toolName) {
4472
4491
  case "factory_status": {
@@ -4519,7 +4538,7 @@ async function executeTool(toolName, toolInput, factoryPath) {
4519
4538
  let boardSummary = "board unreachable";
4520
4539
  try {
4521
4540
  const boardUrl = getBoardUrl(factoryPath);
4522
- const pollData = await boardGet("/api/poll", boardUrl);
4541
+ const pollData = await boardGet(`/api/poll${boardParam}`, boardUrl);
4523
4542
  const poll = JSON.parse(pollData);
4524
4543
  const counts = {};
4525
4544
  let total = 0;
@@ -4547,7 +4566,7 @@ async function executeTool(toolName, toolInput, factoryPath) {
4547
4566
  }
4548
4567
  case "board_items": {
4549
4568
  const boardUrl = getBoardUrl(factoryPath);
4550
- const pollData = await boardGet("/api/poll", boardUrl);
4569
+ const pollData = await boardGet(`/api/poll${boardParam}`, boardUrl);
4551
4570
  try {
4552
4571
  const poll = JSON.parse(pollData);
4553
4572
  const allItems = [];
@@ -4579,7 +4598,7 @@ async function executeTool(toolName, toolInput, factoryPath) {
4579
4598
  case "board_item_updates": {
4580
4599
  const itemId = toolInput.item_id;
4581
4600
  const boardUrl = getBoardUrl(factoryPath);
4582
- const data = await boardGet(`/api/items/${itemId}/updates`, boardUrl);
4601
+ const data = await boardGet(`/api/items/${itemId}/updates${boardParam}`, boardUrl);
4583
4602
  try {
4584
4603
  const updates = JSON.parse(data);
4585
4604
  const list = Array.isArray(updates) ? updates : [];
@@ -4938,6 +4957,9 @@ IMPORTANT RULES:
4938
4957
  await runViaCli(session, content, scope);
4939
4958
  }
4940
4959
  }
4960
+ const NO_CONTEXT_DIRECTIVE = `
4961
+ IMPORTANT: This project has no codebase analysis and no board items yet \u2014 there is NO information about what it is or does. Do NOT invent or assume a product name, features, architecture, or requirements. If asked about this project, say plainly that there is no context yet and ask the user to describe it, add tasks, or run codebase analysis. Never fabricate details.
4962
+ `;
4941
4963
  async function runViaApi(session, content, scope = "factory", systemPromptOverride) {
4942
4964
  session.busy = true;
4943
4965
  try {
@@ -4950,6 +4972,9 @@ IMPORTANT RULES:
4950
4972
 
4951
4973
  You are currently scoped to project "${scope}". Focus your answers on this project. When using tools, prioritize data relevant to this project.
4952
4974
  `;
4975
+ if (await projectHasNoContext(session.factoryPath, scope)) {
4976
+ scopePrefix += NO_CONTEXT_DIRECTIVE;
4977
+ }
4953
4978
  }
4954
4979
  if (!systemPromptOverride && session.inception?.mode === "quick_brainstorm" && session.inception.productName) {
4955
4980
  try {
@@ -5004,7 +5029,8 @@ You are currently scoped to project "${scope}". Focus your answers on this proje
5004
5029
  const result = await executeTool(
5005
5030
  block.name,
5006
5031
  block.input,
5007
- session.factoryPath
5032
+ session.factoryPath,
5033
+ scope
5008
5034
  );
5009
5035
  toolResultsMap.set(block.id, result);
5010
5036
  sendToClient(session, {
@@ -5068,10 +5094,11 @@ You are currently scoped to project "${scope}". Focus your answers on this proje
5068
5094
  session.busy = true;
5069
5095
  try {
5070
5096
  const { spawn: spawn4 } = await import("child_process");
5097
+ const boardParam = scope && scope !== "factory" ? `?board=${encodeURIComponent(scope)}` : "";
5071
5098
  let boardContext = "";
5072
5099
  try {
5073
5100
  const boardUrl = getBoardUrl(session.factoryPath);
5074
- const pollData = await boardGet("/api/poll", boardUrl);
5101
+ const pollData = await boardGet(`/api/poll${boardParam}`, boardUrl);
5075
5102
  const poll = JSON.parse(pollData);
5076
5103
  const summary = [];
5077
5104
  for (const [status, items] of Object.entries(poll)) {
@@ -5110,7 +5137,6 @@ ${formatted}
5110
5137
  `;
5111
5138
  }
5112
5139
  const boardApiUrl = getBoardUrl(session.factoryPath);
5113
- const boardParam = scope !== "factory" ? `?board=${scope}` : "";
5114
5140
  const prompt = `CRITICAL CONTEXT \u2014 YOU MUST READ THIS:
5115
5141
  You are the BeastMode chat assistant running inside a BeastMode factory.
5116
5142