@rallycry/conveyor-agent 10.7.0 → 10.7.2
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.
|
@@ -5521,6 +5521,8 @@ function formatIncidents(incidents) {
|
|
|
5521
5521
|
// src/execution/tag-context-resolver.ts
|
|
5522
5522
|
import { readFile as readFile2, readdir, stat as stat4 } from "fs/promises";
|
|
5523
5523
|
var TYPE_PRIORITY = { rule: 0, file: 1, folder: 2, doc: 3 };
|
|
5524
|
+
var SUMMARY_SCAN_CHARS = 4e3;
|
|
5525
|
+
var SUMMARY_MAX_CHARS = 160;
|
|
5524
5526
|
var BINARY_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
5525
5527
|
".png",
|
|
5526
5528
|
".jpg",
|
|
@@ -5554,19 +5556,41 @@ function isBinaryPath(filePath) {
|
|
|
5554
5556
|
const ext = filePath.slice(filePath.lastIndexOf(".")).toLowerCase();
|
|
5555
5557
|
return BINARY_EXTENSIONS.has(ext);
|
|
5556
5558
|
}
|
|
5557
|
-
var
|
|
5559
|
+
var fileSummaryCache = /* @__PURE__ */ new Map();
|
|
5558
5560
|
var folderListingCache = /* @__PURE__ */ new Map();
|
|
5559
5561
|
var fileReadCount = 0;
|
|
5560
5562
|
var folderReadCount = 0;
|
|
5561
|
-
function
|
|
5562
|
-
|
|
5563
|
-
|
|
5564
|
-
|
|
5563
|
+
function deriveSummary(raw) {
|
|
5564
|
+
let body = raw;
|
|
5565
|
+
let frontmatter = "";
|
|
5566
|
+
if (raw.startsWith("---")) {
|
|
5567
|
+
const end = raw.indexOf("\n---", 3);
|
|
5568
|
+
if (end !== -1) {
|
|
5569
|
+
frontmatter = raw.slice(3, end);
|
|
5570
|
+
const afterClose = raw.indexOf("\n", end + 1);
|
|
5571
|
+
body = afterClose === -1 ? "" : raw.slice(afterClose + 1);
|
|
5572
|
+
}
|
|
5573
|
+
}
|
|
5574
|
+
const fmDescription = frontmatter.split("\n").map((l) => l.trim()).find((l) => /^(description|title):/i.test(l));
|
|
5575
|
+
if (fmDescription) {
|
|
5576
|
+
const value = fmDescription.slice(fmDescription.indexOf(":") + 1).trim().replace(/^["']|["']$/g, "");
|
|
5577
|
+
if (value) return truncateSummary(value);
|
|
5578
|
+
}
|
|
5579
|
+
for (const rawLine of body.split("\n")) {
|
|
5580
|
+
const line = rawLine.trim();
|
|
5581
|
+
if (!line) continue;
|
|
5582
|
+
const cleaned = line.replace(/^#+\s*/, "").replace(/^[-*]\s+/, "").trim();
|
|
5583
|
+
if (cleaned) return truncateSummary(cleaned);
|
|
5584
|
+
}
|
|
5585
|
+
return null;
|
|
5565
5586
|
}
|
|
5566
|
-
|
|
5587
|
+
function truncateSummary(text) {
|
|
5588
|
+
const collapsed = text.replace(/\s+/g, " ").trim();
|
|
5589
|
+
return collapsed.length > SUMMARY_MAX_CHARS ? collapsed.slice(0, SUMMARY_MAX_CHARS - 1).trimEnd() + "\u2026" : collapsed;
|
|
5590
|
+
}
|
|
5591
|
+
async function readFileSummary(filePath) {
|
|
5567
5592
|
try {
|
|
5568
5593
|
if (isBinaryPath(filePath)) return null;
|
|
5569
|
-
let rawContent;
|
|
5570
5594
|
let mtimeMs;
|
|
5571
5595
|
try {
|
|
5572
5596
|
const st = await stat4(filePath);
|
|
@@ -5574,20 +5598,15 @@ async function readFileContent(filePath, maxChars) {
|
|
|
5574
5598
|
} catch {
|
|
5575
5599
|
return null;
|
|
5576
5600
|
}
|
|
5577
|
-
const cached =
|
|
5601
|
+
const cached = fileSummaryCache.get(filePath);
|
|
5578
5602
|
if (cached && cached.mtimeMs === mtimeMs) {
|
|
5579
|
-
|
|
5580
|
-
} else {
|
|
5581
|
-
rawContent = await readFile2(filePath, "utf-8");
|
|
5582
|
-
fileReadCount++;
|
|
5583
|
-
fileContentCache.set(filePath, { mtimeMs, content: rawContent });
|
|
5603
|
+
return cached.summary;
|
|
5584
5604
|
}
|
|
5585
|
-
|
|
5586
|
-
|
|
5587
|
-
|
|
5588
|
-
|
|
5589
|
-
|
|
5590
|
-
return rawContent;
|
|
5605
|
+
const raw = await readFile2(filePath, "utf-8");
|
|
5606
|
+
fileReadCount++;
|
|
5607
|
+
const summary = deriveSummary(raw.slice(0, SUMMARY_SCAN_CHARS));
|
|
5608
|
+
fileSummaryCache.set(filePath, { mtimeMs, summary });
|
|
5609
|
+
return summary;
|
|
5591
5610
|
} catch {
|
|
5592
5611
|
return null;
|
|
5593
5612
|
}
|
|
@@ -5614,76 +5633,49 @@ async function readFolderListing(folderPath) {
|
|
|
5614
5633
|
return null;
|
|
5615
5634
|
}
|
|
5616
5635
|
}
|
|
5617
|
-
async function resolveEntry(entry
|
|
5636
|
+
async function resolveEntry(entry) {
|
|
5618
5637
|
const result = {
|
|
5619
5638
|
type: entry.type,
|
|
5620
5639
|
path: entry.path,
|
|
5621
5640
|
label: entry.label,
|
|
5622
|
-
|
|
5623
|
-
charCount: 0
|
|
5641
|
+
summary: null
|
|
5624
5642
|
};
|
|
5625
|
-
if (
|
|
5643
|
+
if (entry.label) {
|
|
5644
|
+
result.summary = truncateSummary(entry.label);
|
|
5645
|
+
return result;
|
|
5646
|
+
}
|
|
5626
5647
|
if (entry.type === "doc") {
|
|
5627
5648
|
return result;
|
|
5628
5649
|
}
|
|
5629
5650
|
if (entry.type === "folder") {
|
|
5630
|
-
|
|
5631
|
-
if (listing) {
|
|
5632
|
-
result.content = listing;
|
|
5633
|
-
result.charCount = listing.length;
|
|
5634
|
-
budget.remaining -= listing.length;
|
|
5635
|
-
}
|
|
5651
|
+
result.summary = await readFolderListing(entry.path);
|
|
5636
5652
|
return result;
|
|
5637
5653
|
}
|
|
5638
|
-
|
|
5639
|
-
const content = await readFileContent(entry.path, maxChars);
|
|
5640
|
-
if (content) {
|
|
5641
|
-
result.content = content;
|
|
5642
|
-
result.charCount = content.length;
|
|
5643
|
-
budget.remaining -= content.length;
|
|
5644
|
-
}
|
|
5654
|
+
result.summary = await readFileSummary(entry.path);
|
|
5645
5655
|
return result;
|
|
5646
5656
|
}
|
|
5647
5657
|
function formatEntry(entry) {
|
|
5648
|
-
const
|
|
5649
|
-
|
|
5650
|
-
if (entry.content === null) {
|
|
5651
|
-
return `> ${entry.type}: ${entry.path}${label}`;
|
|
5652
|
-
}
|
|
5653
|
-
if (entry.type === "folder") {
|
|
5654
|
-
return `${header}
|
|
5655
|
-
${entry.content}`;
|
|
5656
|
-
}
|
|
5657
|
-
return `${header}
|
|
5658
|
-
\`\`\`
|
|
5659
|
-
${entry.content}
|
|
5660
|
-
\`\`\``;
|
|
5658
|
+
const suffix = entry.summary ? ` \u2014 ${entry.summary}` : "";
|
|
5659
|
+
return `- \`${entry.path}\`${suffix}`;
|
|
5661
5660
|
}
|
|
5662
5661
|
function formatResolvedTags(resolved) {
|
|
5663
|
-
const parts = [
|
|
5664
|
-
|
|
5662
|
+
const parts = [
|
|
5663
|
+
`
|
|
5664
|
+
## Reference Guides (load on demand)`,
|
|
5665
|
+
`These docs match this task's tags. They auto-load when you edit matching files, and you can Read any of them the moment you need its detail \u2014 do NOT read them all up front.`
|
|
5666
|
+
];
|
|
5665
5667
|
for (const tag of resolved) {
|
|
5666
5668
|
if (tag.entries.length === 0) continue;
|
|
5667
5669
|
const desc = tag.description ? ` \u2014 ${tag.description}` : "";
|
|
5668
5670
|
parts.push(`
|
|
5669
5671
|
### Tag: "${tag.tagName}"${desc}`);
|
|
5670
|
-
const
|
|
5671
|
-
|
|
5672
|
-
for (const entry of contentEntries) {
|
|
5673
|
-
parts.push(`
|
|
5674
|
-
${formatEntry(entry)}`);
|
|
5675
|
-
}
|
|
5676
|
-
if (pointerEntries.length > 0) {
|
|
5677
|
-
parts.push(``);
|
|
5678
|
-
parts.push(`> Budget limit reached. Remaining linked files (read manually if needed):`);
|
|
5679
|
-
for (const entry of pointerEntries) {
|
|
5680
|
-
parts.push(formatEntry(entry));
|
|
5681
|
-
}
|
|
5672
|
+
for (const entry of tag.entries) {
|
|
5673
|
+
parts.push(formatEntry(entry));
|
|
5682
5674
|
}
|
|
5683
5675
|
}
|
|
5684
5676
|
return parts.join("\n");
|
|
5685
5677
|
}
|
|
5686
|
-
async function resolveTagContext(projectTags, taskTagIds,
|
|
5678
|
+
async function resolveTagContext(projectTags, taskTagIds, _model, _betas, _runnerMode) {
|
|
5687
5679
|
if (!projectTags?.length || !taskTagIds.length) {
|
|
5688
5680
|
return { injectedSection: "", stats: { injected: 0, skipped: 0 } };
|
|
5689
5681
|
}
|
|
@@ -5706,8 +5698,6 @@ async function resolveTagContext(projectTags, taskTagIds, model, betas, runnerMo
|
|
|
5706
5698
|
if (allEntries.length === 0) {
|
|
5707
5699
|
return { injectedSection: "", stats: { injected: 0, skipped: 0 } };
|
|
5708
5700
|
}
|
|
5709
|
-
const budgetChars = getContextBudgetChars(model, betas, runnerMode);
|
|
5710
|
-
const budget = { remaining: budgetChars };
|
|
5711
5701
|
let injected = 0;
|
|
5712
5702
|
let skipped = 0;
|
|
5713
5703
|
const resolved = assignedTags.map((t) => ({
|
|
@@ -5716,9 +5706,9 @@ async function resolveTagContext(projectTags, taskTagIds, model, betas, runnerMo
|
|
|
5716
5706
|
entries: []
|
|
5717
5707
|
}));
|
|
5718
5708
|
for (const { tagIndex, entry } of allEntries) {
|
|
5719
|
-
const result = await resolveEntry(entry
|
|
5709
|
+
const result = await resolveEntry(entry);
|
|
5720
5710
|
resolved[tagIndex].entries.push(result);
|
|
5721
|
-
if (result.
|
|
5711
|
+
if (result.summary === null) {
|
|
5722
5712
|
skipped++;
|
|
5723
5713
|
} else {
|
|
5724
5714
|
injected++;
|
|
@@ -9586,6 +9576,10 @@ function parseUsageGauges(stdout) {
|
|
|
9586
9576
|
// src/usage/run-probe.ts
|
|
9587
9577
|
import { spawn } from "child_process";
|
|
9588
9578
|
var PROBE_TIMEOUT_MS = 15e3;
|
|
9579
|
+
function buildProbeEnv(env = process.env) {
|
|
9580
|
+
const { CLAUDE_CODE_OAUTH_TOKEN: _oauth, ANTHROPIC_API_KEY: _apiKey, ...rest } = env;
|
|
9581
|
+
return rest;
|
|
9582
|
+
}
|
|
9589
9583
|
function runUsageProbe(binary = resolveClaudeBinary(), args = ["-p", "/usage"]) {
|
|
9590
9584
|
return new Promise((resolve) => {
|
|
9591
9585
|
let stdout = "";
|
|
@@ -9597,7 +9591,7 @@ function runUsageProbe(binary = resolveClaudeBinary(), args = ["-p", "/usage"])
|
|
|
9597
9591
|
};
|
|
9598
9592
|
let child;
|
|
9599
9593
|
try {
|
|
9600
|
-
child = spawn(binary, args, { stdio: ["ignore", "pipe", "ignore"] });
|
|
9594
|
+
child = spawn(binary, args, { stdio: ["ignore", "pipe", "ignore"], env: buildProbeEnv() });
|
|
9601
9595
|
} catch {
|
|
9602
9596
|
finish("");
|
|
9603
9597
|
return;
|
|
@@ -9639,7 +9633,10 @@ async function sampleKeyUsage(token, probe = runUsageProbe) {
|
|
|
9639
9633
|
samples.push({ rateLimitType: "seven_day", utilization: weeklyUsage, status: "allowed" });
|
|
9640
9634
|
}
|
|
9641
9635
|
if (samples.length === 0) {
|
|
9642
|
-
logger4.info("usage sample produced no gauges", {
|
|
9636
|
+
logger4.info("usage sample produced no gauges", {
|
|
9637
|
+
stdoutLength: stdout.length,
|
|
9638
|
+
stdoutHead: stdout.slice(0, 200).replaceAll("\n", " ")
|
|
9639
|
+
});
|
|
9643
9640
|
}
|
|
9644
9641
|
return samples;
|
|
9645
9642
|
} catch (error) {
|
|
@@ -11001,4 +10998,4 @@ export {
|
|
|
11001
10998
|
runStartCommand,
|
|
11002
10999
|
unshallowRepo
|
|
11003
11000
|
};
|
|
11004
|
-
//# sourceMappingURL=chunk-
|
|
11001
|
+
//# sourceMappingURL=chunk-DDDLYATP.js.map
|