@bodhi-ventures/aiocs 0.3.0 → 0.3.1

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.
@@ -5601,6 +5601,9 @@ function stripTaggedReasoningBlocks(content) {
5601
5601
  function stripChannelMarkers(lines) {
5602
5602
  return lines.filter((line) => !/^<\|[^>]+>.*$/.test(line.trim()));
5603
5603
  }
5604
+ function normalizeMetaCandidate(line) {
5605
+ return line.trim().replace(/^[-*]\s+/, "").replace(/^[*_`]+/, "").replace(/[*_`]+:?\s*$/, "").replace(/^\(([^)]+)\):?/, "$1").trim();
5606
+ }
5604
5607
  function isLikelyDocumentStart(line) {
5605
5608
  const trimmed = line.trim();
5606
5609
  if (trimmed.length === 0) {
@@ -5616,8 +5619,15 @@ function isLikelyReasoningLine(line) {
5616
5619
  return /^(?:[-*]\s+)?(?:goal|requirements?|plan|reasoning|thoughts?|thinking|analysis|approach|notes?)\b[::]/i.test(trimmed);
5617
5620
  }
5618
5621
  function isLikelyMetaLeakLine(line) {
5619
- const trimmed = line.trim();
5620
- return /\b(?:Actually, looking at the text|let'?s check|context says)\b/i.test(trimmed);
5622
+ const normalized = normalizeMetaCandidate(line);
5623
+ return /\b(?:Actually, looking at the text|let'?s check|context says)\b/i.test(normalized) || /^(?:user question|workspace context(?: provided)?|the user asks|looking through the text)\b/i.test(normalized);
5624
+ }
5625
+ function isLikelyReasoningTailStart(line) {
5626
+ const normalized = normalizeMetaCandidate(line);
5627
+ if (normalized.length === 0) {
5628
+ return false;
5629
+ }
5630
+ return /^(?:final check|double check|sanity check|one detail|one more look|final polish|final structure|self-correction|self correction|wait|actually)\b/i.test(normalized) || /^(?:looking at the user question again|looking at the context|one more look at the context|let me check|i will|i'll|i should|i can|i need to|i am going to|since the context)\b/i.test(normalized);
5621
5631
  }
5622
5632
  function dedentCommonIndentation(lines) {
5623
5633
  const indents = lines.filter((line) => line.trim().length > 0).map((line) => line.match(/^ +/)?.[0].length ?? 0).filter((indent) => indent > 0);
@@ -5642,8 +5652,11 @@ function sanitizeGeneratedMarkdown(content) {
5642
5652
  while (firstMeaningfulIndex < candidateLines.length && isLikelyReasoningLine(candidateLines[firstMeaningfulIndex] ?? "")) {
5643
5653
  firstMeaningfulIndex += 1;
5644
5654
  }
5655
+ const meaningfulLines = candidateLines.slice(firstMeaningfulIndex);
5656
+ const reasoningTailIndex = meaningfulLines.findIndex((line) => isLikelyReasoningTailStart(line));
5657
+ const boundedLines = reasoningTailIndex >= 0 ? meaningfulLines.slice(0, reasoningTailIndex) : meaningfulLines;
5645
5658
  const cleanedLines = dedentCommonIndentation(
5646
- candidateLines.slice(firstMeaningfulIndex).filter((line) => !isLikelyMetaLeakLine(line))
5659
+ boundedLines.filter((line) => !isLikelyMetaLeakLine(line))
5647
5660
  );
5648
5661
  return cleanedLines.join("\n").replace(/httpshttps:\/\//g, "https://").replace(/httphttp:\/\//g, "http://").replace(/httpss:\/\//g, "https://").trim();
5649
5662
  }
@@ -7145,7 +7158,7 @@ async function startDaemon(input) {
7145
7158
  // package.json
7146
7159
  var package_default = {
7147
7160
  name: "@bodhi-ventures/aiocs",
7148
- version: "0.3.0",
7161
+ version: "0.3.1",
7149
7162
  license: "MIT",
7150
7163
  type: "module",
7151
7164
  description: "Local-only documentation store, fetcher, and search CLI for AI agents.",
@@ -8231,6 +8244,44 @@ async function searchHybridCatalog(input) {
8231
8244
  }
8232
8245
 
8233
8246
  // src/workspace/output.ts
8247
+ function boundWorkspaceGenerationContext(input) {
8248
+ const budget = Math.max(2e3, input.maxInputChars - 1e3);
8249
+ const boundedEntries = [];
8250
+ let totalLength = 0;
8251
+ for (const entry of input.entries) {
8252
+ const availableForEntry = budget - totalLength - 2;
8253
+ if (availableForEntry <= 0) {
8254
+ break;
8255
+ }
8256
+ const content = entry.content.length > availableForEntry ? `${entry.content.slice(0, Math.max(0, availableForEntry - 16)).trimEnd()}
8257
+
8258
+ [truncated]` : entry.content;
8259
+ if (content.trim().length === 0) {
8260
+ continue;
8261
+ }
8262
+ boundedEntries.push({
8263
+ ...entry,
8264
+ content
8265
+ });
8266
+ totalLength += content.length + 2;
8267
+ if (totalLength >= budget) {
8268
+ break;
8269
+ }
8270
+ }
8271
+ if (boundedEntries.length === 0) {
8272
+ throw new AiocsError(
8273
+ AIOCS_ERROR_CODES.invalidArgument,
8274
+ "Workspace output generation has no usable context after applying the compiler input budget."
8275
+ );
8276
+ }
8277
+ return {
8278
+ contextEntries: boundedEntries,
8279
+ contextSections: boundedEntries.map((entry) => entry.content),
8280
+ contextArtifactPaths: boundedEntries.map((entry) => entry.artifactPath),
8281
+ provenanceEntries: boundedEntries.flatMap((entry) => entry.provenanceEntries),
8282
+ rawInputProvenanceEntries: boundedEntries.flatMap((entry) => entry.rawInputProvenanceEntries)
8283
+ };
8284
+ }
8234
8285
  function ensureLeadingTitle2(content, title) {
8235
8286
  const lines = content.trim().split("\n");
8236
8287
  let cursor = 0;
@@ -8306,6 +8357,15 @@ function buildOutputPrompt(format, prompt, context) {
8306
8357
  "- Do not include reasoning, analysis, `<think>` blocks, or channel/control tokens.",
8307
8358
  "- Preserve identifiers, package names, runtimes, and URLs exactly as they appear in the workspace context.",
8308
8359
  "- Use standard Markdown headings, paragraphs, and bullet lists inside slides."
8360
+ ] : format === "note" ? [
8361
+ "- Output valid Markdown only.",
8362
+ "- Start with an H1 title.",
8363
+ "- Answer the question directly in the opening section.",
8364
+ "- Do not include headings or bullets named `User Question`, `Workspace Context`, `Looking through the text`, or similar prompt scaffolding.",
8365
+ "- Do not narrate your reasoning process or mention the prompt, context window, or user instructions.",
8366
+ "- Do not include reasoning, analysis, `<think>` blocks, or channel/control tokens.",
8367
+ "- Preserve identifiers, package names, runtimes, and URLs exactly as they appear in the workspace context.",
8368
+ "- Use standard Markdown headings, paragraphs, and bullet lists."
8309
8369
  ] : [
8310
8370
  "- Output valid Markdown only.",
8311
8371
  "- Start with an H1 title.",
@@ -8366,10 +8426,7 @@ async function collectWorkspaceGenerationContext(input) {
8366
8426
  }
8367
8427
  const staleArtifactPaths = [];
8368
8428
  const freshArtifactPaths = [];
8369
- const contextSections = [];
8370
- const contextArtifactPaths = [];
8371
- const provenanceEntries = [];
8372
- const rawInputProvenanceEntries = [];
8429
+ const contextEntries = [];
8373
8430
  const indexArtifact = input.catalog.getWorkspaceArtifact(input.workspaceId, getWorkspaceIndexPath());
8374
8431
  if (indexArtifact) {
8375
8432
  const freshness = assessWorkspaceArtifactFreshness({
@@ -8389,10 +8446,12 @@ async function collectWorkspaceGenerationContext(input) {
8389
8446
  workspaceId: input.workspaceId,
8390
8447
  path: getWorkspaceIndexPath()
8391
8448
  });
8392
- contextSections.push(indexContent.content);
8393
- contextArtifactPaths.push(getWorkspaceIndexPath());
8394
- provenanceEntries.push(...input.catalog.listWorkspaceArtifactProvenance(input.workspaceId, getWorkspaceIndexPath()));
8395
- rawInputProvenanceEntries.push(...input.catalog.listWorkspaceArtifactRawInputProvenance(input.workspaceId, getWorkspaceIndexPath()));
8449
+ contextEntries.push({
8450
+ content: indexContent.content,
8451
+ artifactPath: getWorkspaceIndexPath(),
8452
+ provenanceEntries: input.catalog.listWorkspaceArtifactProvenance(input.workspaceId, getWorkspaceIndexPath()),
8453
+ rawInputProvenanceEntries: input.catalog.listWorkspaceArtifactRawInputProvenance(input.workspaceId, getWorkspaceIndexPath())
8454
+ });
8396
8455
  }
8397
8456
  for (const binding of bindings) {
8398
8457
  const bundle = getSourceArtifactBundle(binding.sourceId);
@@ -8421,10 +8480,12 @@ async function collectWorkspaceGenerationContext(input) {
8421
8480
  workspaceId: input.workspaceId,
8422
8481
  path
8423
8482
  });
8424
- contextSections.push(content.content);
8425
- contextArtifactPaths.push(path);
8426
- provenanceEntries.push(...input.catalog.listWorkspaceArtifactProvenance(input.workspaceId, path));
8427
- rawInputProvenanceEntries.push(...input.catalog.listWorkspaceArtifactRawInputProvenance(input.workspaceId, path));
8483
+ contextEntries.push({
8484
+ content: content.content,
8485
+ artifactPath: path,
8486
+ provenanceEntries: input.catalog.listWorkspaceArtifactProvenance(input.workspaceId, path),
8487
+ rawInputProvenanceEntries: input.catalog.listWorkspaceArtifactRawInputProvenance(input.workspaceId, path)
8488
+ });
8428
8489
  }
8429
8490
  }
8430
8491
  for (const rawInput of rawInputs) {
@@ -8450,10 +8511,12 @@ async function collectWorkspaceGenerationContext(input) {
8450
8511
  workspaceId: input.workspaceId,
8451
8512
  path
8452
8513
  });
8453
- contextSections.push(content.content);
8454
- contextArtifactPaths.push(path);
8455
- provenanceEntries.push(...input.catalog.listWorkspaceArtifactProvenance(input.workspaceId, path));
8456
- rawInputProvenanceEntries.push(...rawInputProvenance);
8514
+ contextEntries.push({
8515
+ content: content.content,
8516
+ artifactPath: path,
8517
+ provenanceEntries: input.catalog.listWorkspaceArtifactProvenance(input.workspaceId, path),
8518
+ rawInputProvenanceEntries: rawInputProvenance
8519
+ });
8457
8520
  }
8458
8521
  }
8459
8522
  input.catalog.setWorkspaceArtifactsStale({
@@ -8476,10 +8539,11 @@ async function collectWorkspaceGenerationContext(input) {
8476
8539
  );
8477
8540
  }
8478
8541
  return {
8479
- contextSections,
8480
- contextArtifactPaths,
8481
- provenanceEntries,
8482
- rawInputProvenanceEntries
8542
+ contextEntries,
8543
+ contextSections: contextEntries.map((entry) => entry.content),
8544
+ contextArtifactPaths: contextEntries.map((entry) => entry.artifactPath),
8545
+ provenanceEntries: contextEntries.flatMap((entry) => entry.provenanceEntries),
8546
+ rawInputProvenanceEntries: contextEntries.flatMap((entry) => entry.rawInputProvenanceEntries)
8483
8547
  };
8484
8548
  }
8485
8549
  async function generateWorkspaceArtifact(input) {
@@ -8491,7 +8555,11 @@ async function generateWorkspaceArtifact(input) {
8491
8555
  );
8492
8556
  }
8493
8557
  const effectiveCompilerProfile = resolveEffectiveWorkspaceCompilerProfile(workspace.compilerProfile, input.env);
8494
- const prompt = buildOutputPrompt(input.format, input.prompt, input.context.contextSections.join("\n\n"));
8558
+ const boundedContext = boundWorkspaceGenerationContext({
8559
+ entries: input.context.contextEntries,
8560
+ maxInputChars: effectiveCompilerProfile.maxInputChars
8561
+ });
8562
+ const prompt = buildOutputPrompt(input.format, input.prompt, boundedContext.contextSections.join("\n\n"));
8495
8563
  const generated = await compileWithLmStudio({
8496
8564
  profile: effectiveCompilerProfile,
8497
8565
  systemPrompt: "You create provenance-backed workspace outputs. Return only the final Markdown document. Never emit reasoning, analysis, tool traces, <think> tags, or channel/control tokens.",
@@ -8527,12 +8595,12 @@ async function generateWorkspaceArtifact(input) {
8527
8595
  markdown: content
8528
8596
  }
8529
8597
  ],
8530
- provenance: mergeProvenance(input.context.provenanceEntries),
8531
- ...input.context.rawInputProvenanceEntries.length > 0 ? { rawInputProvenance: mergeRawInputProvenance(input.context.rawInputProvenanceEntries) } : {},
8598
+ provenance: mergeProvenance(boundedContext.provenanceEntries),
8599
+ ...boundedContext.rawInputProvenanceEntries.length > 0 ? { rawInputProvenance: mergeRawInputProvenance(boundedContext.rawInputProvenanceEntries) } : {},
8532
8600
  links: buildArtifactLinks(
8533
8601
  input.path,
8534
8602
  content,
8535
- [...new Set(input.context.contextArtifactPaths)].map((artifactPath) => ({
8603
+ [...new Set(boundedContext.contextArtifactPaths)].map((artifactPath) => ({
8536
8604
  toPath: artifactPath,
8537
8605
  relationKind: "derived_from",
8538
8606
  anchorText: artifactPath
package/dist/cli.js CHANGED
@@ -51,7 +51,7 @@ import {
51
51
  updateWorkspaceSettings,
52
52
  upsertSourceFromSpecFile,
53
53
  verifyCoverage
54
- } from "./chunk-GX6CZOO7.js";
54
+ } from "./chunk-TJG2DPJU.js";
55
55
 
56
56
  // src/cli.ts
57
57
  import { Command, CommanderError as CommanderError2 } from "commander";
@@ -46,7 +46,7 @@ import {
46
46
  updateWorkspaceSettings,
47
47
  upsertSourceFromSpecFile,
48
48
  verifyCoverage
49
- } from "./chunk-GX6CZOO7.js";
49
+ } from "./chunk-TJG2DPJU.js";
50
50
 
51
51
  // src/mcp-server.ts
52
52
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bodhi-ventures/aiocs",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "Local-only documentation store, fetcher, and search CLI for AI agents.",