poe-code 3.0.312 → 3.0.313
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 +80 -33
- package/dist/index.js.map +3 -3
- package/dist/metafile.json +1 -1
- package/package.json +1 -1
- package/packages/markdown-reader/dist/core/document.js +6 -0
- package/packages/markdown-reader/dist/core/read-section.js +4 -0
- package/packages/markdown-reader/dist/core/resolve.js +6 -3
- package/packages/markdown-reader/dist/core/scan.js +28 -1
- package/packages/markdown-reader/dist/mcp/tools.js +11 -4
package/dist/index.js
CHANGED
|
@@ -3473,21 +3473,21 @@ function sliceOffsetMap(offsets, start, end) {
|
|
|
3473
3473
|
}
|
|
3474
3474
|
function createOffsetMap(input, absoluteStart = 0) {
|
|
3475
3475
|
const offsets = new Array(input.length + 1).fill(absoluteStart);
|
|
3476
|
-
let
|
|
3476
|
+
let byteOffset2 = absoluteStart;
|
|
3477
3477
|
let index = 0;
|
|
3478
3478
|
while (index < input.length) {
|
|
3479
|
-
offsets[index] =
|
|
3479
|
+
offsets[index] = byteOffset2;
|
|
3480
3480
|
const codePoint = input.codePointAt(index) ?? 0;
|
|
3481
3481
|
const codeUnitLength = codePoint > 65535 ? 2 : 1;
|
|
3482
3482
|
const byteLength = codePoint <= 127 ? 1 : codePoint <= 2047 ? 2 : codePoint <= 65535 ? 3 : 4;
|
|
3483
3483
|
for (let offsetIndex = 1; offsetIndex < codeUnitLength; offsetIndex += 1) {
|
|
3484
|
-
offsets[index + offsetIndex] =
|
|
3484
|
+
offsets[index + offsetIndex] = byteOffset2;
|
|
3485
3485
|
}
|
|
3486
|
-
|
|
3486
|
+
byteOffset2 += byteLength;
|
|
3487
3487
|
index += codeUnitLength;
|
|
3488
|
-
offsets[index] =
|
|
3488
|
+
offsets[index] = byteOffset2;
|
|
3489
3489
|
}
|
|
3490
|
-
offsets[input.length] =
|
|
3490
|
+
offsets[input.length] = byteOffset2;
|
|
3491
3491
|
return offsets;
|
|
3492
3492
|
}
|
|
3493
3493
|
var INLINE_HTML_TAGS;
|
|
@@ -4102,21 +4102,21 @@ function getTextNodeSourceOffsets(node) {
|
|
|
4102
4102
|
}
|
|
4103
4103
|
function createOffsetMap2(input, absoluteStart = 0, absoluteEnd) {
|
|
4104
4104
|
const offsets = new Array(input.length + 1).fill(absoluteStart);
|
|
4105
|
-
let
|
|
4105
|
+
let byteOffset2 = absoluteStart;
|
|
4106
4106
|
let index = 0;
|
|
4107
4107
|
while (index < input.length) {
|
|
4108
|
-
offsets[index] =
|
|
4108
|
+
offsets[index] = byteOffset2;
|
|
4109
4109
|
const codePoint = input.codePointAt(index) ?? 0;
|
|
4110
4110
|
const codeUnitLength = codePoint > 65535 ? 2 : 1;
|
|
4111
4111
|
const byteLength = codePoint <= 127 ? 1 : codePoint <= 2047 ? 2 : codePoint <= 65535 ? 3 : 4;
|
|
4112
4112
|
for (let offsetIndex = 1; offsetIndex < codeUnitLength; offsetIndex += 1) {
|
|
4113
|
-
offsets[index + offsetIndex] =
|
|
4113
|
+
offsets[index + offsetIndex] = byteOffset2;
|
|
4114
4114
|
}
|
|
4115
|
-
|
|
4115
|
+
byteOffset2 += byteLength;
|
|
4116
4116
|
index += codeUnitLength;
|
|
4117
|
-
offsets[index] =
|
|
4117
|
+
offsets[index] = byteOffset2;
|
|
4118
4118
|
}
|
|
4119
|
-
offsets[input.length] = absoluteEnd ??
|
|
4119
|
+
offsets[input.length] = absoluteEnd ?? byteOffset2;
|
|
4120
4120
|
return offsets;
|
|
4121
4121
|
}
|
|
4122
4122
|
function createMappedText(value, offsets) {
|
|
@@ -21301,9 +21301,9 @@ function createContainerJob(containerId, runner, engine, context, detachedJobCon
|
|
|
21301
21301
|
const sinceCondition = opts?.since === void 0 ? "" : ` && test $(stat -c %Y ${logFile} 2>/dev/null || stat -f %m ${logFile}) -ge ${Math.ceil(
|
|
21302
21302
|
opts.since.getTime() / 1e3
|
|
21303
21303
|
)}`;
|
|
21304
|
-
let
|
|
21304
|
+
let byteOffset2 = opts?.sinceByte ?? 0;
|
|
21305
21305
|
let pendingBytes = Buffer.alloc(0);
|
|
21306
|
-
let pendingByteOffset =
|
|
21306
|
+
let pendingByteOffset = byteOffset2;
|
|
21307
21307
|
while (true) {
|
|
21308
21308
|
const stdout = await runAndReadBytes(runner, {
|
|
21309
21309
|
command: engine,
|
|
@@ -21313,7 +21313,7 @@ function createContainerJob(containerId, runner, engine, context, detachedJobCon
|
|
|
21313
21313
|
containerId,
|
|
21314
21314
|
"sh",
|
|
21315
21315
|
"-c",
|
|
21316
|
-
`test -f ${logFile}${sinceCondition} && tail -c +${
|
|
21316
|
+
`test -f ${logFile}${sinceCondition} && tail -c +${byteOffset2 + 1} ${logFile} || true`
|
|
21317
21317
|
],
|
|
21318
21318
|
stdout: "pipe",
|
|
21319
21319
|
stderr: "pipe"
|
|
@@ -21321,7 +21321,7 @@ function createContainerJob(containerId, runner, engine, context, detachedJobCon
|
|
|
21321
21321
|
if (stdout.byteLength > 0) {
|
|
21322
21322
|
const combined = pendingBytes.byteLength === 0 ? stdout : Buffer.concat([pendingBytes, stdout]);
|
|
21323
21323
|
const completeLength = completeUtf8PrefixLength(combined);
|
|
21324
|
-
|
|
21324
|
+
byteOffset2 += stdout.byteLength;
|
|
21325
21325
|
pendingBytes = combined.subarray(completeLength);
|
|
21326
21326
|
const data = combined.subarray(0, completeLength).toString("utf8");
|
|
21327
21327
|
if (data.length > 0) {
|
|
@@ -26087,19 +26087,19 @@ async function* streamLogFile(env, jobId, opts) {
|
|
|
26087
26087
|
assertSafeJobId2(jobId);
|
|
26088
26088
|
const fs28 = env.fs ?? nodeFs3;
|
|
26089
26089
|
const file = jobLogPath(jobId);
|
|
26090
|
-
let
|
|
26090
|
+
let byteOffset2 = opts.sinceByte ?? (opts.since === void 0 ? 0 : await readCurrentByteLength(fs28, file));
|
|
26091
26091
|
let pendingBytes = Buffer.alloc(0);
|
|
26092
|
-
let pendingByteOffset =
|
|
26092
|
+
let pendingByteOffset = byteOffset2;
|
|
26093
26093
|
while (true) {
|
|
26094
26094
|
if (opts.since !== void 0 && !await wasModifiedSince(fs28, file, opts.since)) {
|
|
26095
26095
|
await waitForLogChange(fs28, file);
|
|
26096
26096
|
continue;
|
|
26097
26097
|
}
|
|
26098
|
-
const result = await readLogChunk(fs28, file,
|
|
26098
|
+
const result = await readLogChunk(fs28, file, byteOffset2);
|
|
26099
26099
|
if (result !== null) {
|
|
26100
26100
|
const combined = pendingBytes.length === 0 ? result.bytes : Buffer.concat([pendingBytes, result.bytes]);
|
|
26101
26101
|
const completeLength = completeUtf8PrefixLength2(combined);
|
|
26102
|
-
|
|
26102
|
+
byteOffset2 = result.nextByteOffset;
|
|
26103
26103
|
pendingBytes = combined.subarray(completeLength);
|
|
26104
26104
|
const data = combined.subarray(0, completeLength).toString("utf8");
|
|
26105
26105
|
if (data.length > 0) {
|
|
@@ -26166,13 +26166,13 @@ function assertSafeJobId2(jobId) {
|
|
|
26166
26166
|
throw new Error(`Invalid job id "${jobId}". Job ids must be single filename components.`);
|
|
26167
26167
|
}
|
|
26168
26168
|
}
|
|
26169
|
-
async function readLogChunk(fs28, file,
|
|
26169
|
+
async function readLogChunk(fs28, file, byteOffset2) {
|
|
26170
26170
|
const contents = await readFileIfExists3(fs28, file);
|
|
26171
|
-
if (contents === null ||
|
|
26171
|
+
if (contents === null || byteOffset2 >= contents.byteLength) {
|
|
26172
26172
|
return null;
|
|
26173
26173
|
}
|
|
26174
26174
|
return {
|
|
26175
|
-
bytes: contents.subarray(
|
|
26175
|
+
bytes: contents.subarray(byteOffset2),
|
|
26176
26176
|
nextByteOffset: contents.byteLength
|
|
26177
26177
|
};
|
|
26178
26178
|
}
|
|
@@ -70937,7 +70937,8 @@ function scanMarkdown(source) {
|
|
|
70937
70937
|
if (ast.type !== "root") {
|
|
70938
70938
|
return [];
|
|
70939
70939
|
}
|
|
70940
|
-
const
|
|
70940
|
+
const htmlCommentRanges = collectHtmlCommentRanges(source);
|
|
70941
|
+
const headings = ast.children.filter(isHeadingNode).filter((heading) => !isInsideHtmlComment(getRequiredRange(heading).start, htmlCommentRanges));
|
|
70941
70942
|
if (headings.length === 0) {
|
|
70942
70943
|
return [];
|
|
70943
70944
|
}
|
|
@@ -70958,6 +70959,30 @@ function scanMarkdown(source) {
|
|
|
70958
70959
|
applyNumbers(sections, baselineDepth);
|
|
70959
70960
|
return sections;
|
|
70960
70961
|
}
|
|
70962
|
+
function collectHtmlCommentRanges(source) {
|
|
70963
|
+
const ranges = [];
|
|
70964
|
+
let searchStart = 0;
|
|
70965
|
+
while (searchStart < source.length) {
|
|
70966
|
+
const commentStart = source.indexOf("<!--", searchStart);
|
|
70967
|
+
if (commentStart === -1) {
|
|
70968
|
+
return ranges;
|
|
70969
|
+
}
|
|
70970
|
+
const commentEndMarker = source.indexOf("-->", commentStart + "<!--".length);
|
|
70971
|
+
const commentEnd = commentEndMarker === -1 ? source.length : commentEndMarker + "-->".length;
|
|
70972
|
+
ranges.push({
|
|
70973
|
+
start: byteOffset(source, commentStart),
|
|
70974
|
+
end: byteOffset(source, commentEnd)
|
|
70975
|
+
});
|
|
70976
|
+
searchStart = commentEnd;
|
|
70977
|
+
}
|
|
70978
|
+
return ranges;
|
|
70979
|
+
}
|
|
70980
|
+
function isInsideHtmlComment(offset, ranges) {
|
|
70981
|
+
return ranges.some((range) => offset >= range.start && offset < range.end);
|
|
70982
|
+
}
|
|
70983
|
+
function byteOffset(source, index) {
|
|
70984
|
+
return Buffer.byteLength(source.slice(0, index), "utf8");
|
|
70985
|
+
}
|
|
70961
70986
|
function isHeadingNode(node) {
|
|
70962
70987
|
return node.type === "heading";
|
|
70963
70988
|
}
|
|
@@ -71053,6 +71078,9 @@ async function loadMarkdownDocument(file, dependencies = {}) {
|
|
|
71053
71078
|
};
|
|
71054
71079
|
}
|
|
71055
71080
|
function resolveMarkdownPath(file, cwd = process.cwd()) {
|
|
71081
|
+
if (file.trim().length === 0) {
|
|
71082
|
+
throw new UserError("invalid file: expected a non-empty path");
|
|
71083
|
+
}
|
|
71056
71084
|
return path92.isAbsolute(file) ? file : path92.resolve(cwd, file);
|
|
71057
71085
|
}
|
|
71058
71086
|
function sliceMarkdownBytes(source, start, end) {
|
|
@@ -71088,6 +71116,9 @@ function hasYamlLikeLeadingFrontmatter(source) {
|
|
|
71088
71116
|
if (lines[0] !== "---") {
|
|
71089
71117
|
return false;
|
|
71090
71118
|
}
|
|
71119
|
+
if (lines[1]?.trim().length === 0) {
|
|
71120
|
+
return false;
|
|
71121
|
+
}
|
|
71091
71122
|
for (const line of lines.slice(1)) {
|
|
71092
71123
|
const trimmed = line.trim();
|
|
71093
71124
|
if (trimmed.length === 0) {
|
|
@@ -71153,16 +71184,19 @@ var init_read_markdown = __esm({
|
|
|
71153
71184
|
// packages/markdown-reader/src/core/resolve.ts
|
|
71154
71185
|
function resolveSection(sections, id) {
|
|
71155
71186
|
const trimmedId = id.trim();
|
|
71187
|
+
if (trimmedId.length === 0) {
|
|
71188
|
+
throw new UserError("invalid section: expected a non-empty section id");
|
|
71189
|
+
}
|
|
71190
|
+
const sectionByNumber = sections.find((section) => section.number === trimmedId);
|
|
71191
|
+
if (sectionByNumber !== void 0) {
|
|
71192
|
+
return sectionByNumber;
|
|
71193
|
+
}
|
|
71156
71194
|
const unnumberedTitleMatch = sections.find(
|
|
71157
71195
|
(section) => section.number === null && section.title === trimmedId
|
|
71158
71196
|
);
|
|
71159
71197
|
if (unnumberedTitleMatch !== void 0) {
|
|
71160
71198
|
return unnumberedTitleMatch;
|
|
71161
71199
|
}
|
|
71162
|
-
const sectionByNumber = sections.find((section) => section.number === trimmedId);
|
|
71163
|
-
if (sectionByNumber !== void 0) {
|
|
71164
|
-
return sectionByNumber;
|
|
71165
|
-
}
|
|
71166
71200
|
const titleMatches = sections.filter((section) => section.title === trimmedId);
|
|
71167
71201
|
if (titleMatches.length === 1) {
|
|
71168
71202
|
return titleMatches[0];
|
|
@@ -71184,6 +71218,9 @@ var init_resolve5 = __esm({
|
|
|
71184
71218
|
// packages/markdown-reader/src/core/read-section.ts
|
|
71185
71219
|
function createReadSection(dependencies = {}) {
|
|
71186
71220
|
return async function readSection2(params) {
|
|
71221
|
+
if (params.section.trim().length === 0) {
|
|
71222
|
+
throw new UserError("invalid section: expected a non-empty section id");
|
|
71223
|
+
}
|
|
71187
71224
|
const { source, sections } = await loadMarkdownDocument(params.file, dependencies);
|
|
71188
71225
|
const section = resolveSection(sections, params.section);
|
|
71189
71226
|
const end = params.includeChildren === false ? section.bodyEndNoChildren : section.bodyEnd;
|
|
@@ -71204,6 +71241,7 @@ var init_read_section = __esm({
|
|
|
71204
71241
|
"use strict";
|
|
71205
71242
|
init_document();
|
|
71206
71243
|
init_resolve5();
|
|
71244
|
+
init_src21();
|
|
71207
71245
|
readSection = createReadSection();
|
|
71208
71246
|
}
|
|
71209
71247
|
});
|
|
@@ -71218,8 +71256,14 @@ var init_tools2 = __esm({
|
|
|
71218
71256
|
init_read_markdown();
|
|
71219
71257
|
init_read_section();
|
|
71220
71258
|
readParams = S.Object({
|
|
71221
|
-
file: S.String({ description: "Path to the markdown file" }),
|
|
71222
|
-
depth: S.Optional(
|
|
71259
|
+
file: S.String({ description: "Path to the markdown file", minLength: 1 }),
|
|
71260
|
+
depth: S.Optional(
|
|
71261
|
+
S.Number({
|
|
71262
|
+
description: "Limit TOC to headings at depth <= n",
|
|
71263
|
+
jsonType: "integer",
|
|
71264
|
+
minimum: 0
|
|
71265
|
+
})
|
|
71266
|
+
)
|
|
71223
71267
|
});
|
|
71224
71268
|
tocEntryResult = S.Object({
|
|
71225
71269
|
depth: S.Number(),
|
|
@@ -71239,8 +71283,11 @@ var init_tools2 = __esm({
|
|
|
71239
71283
|
handler: async ({ params }) => readMarkdown(params)
|
|
71240
71284
|
});
|
|
71241
71285
|
readSectionParams = S.Object({
|
|
71242
|
-
file: S.String({ description: "Path to the markdown file" }),
|
|
71243
|
-
section: S.String({
|
|
71286
|
+
file: S.String({ description: "Path to the markdown file", minLength: 1 }),
|
|
71287
|
+
section: S.String({
|
|
71288
|
+
description: "Numeric path or exact heading text to read",
|
|
71289
|
+
minLength: 1
|
|
71290
|
+
}),
|
|
71244
71291
|
includeChildren: S.Optional(S.Boolean({ description: "Include nested child sections" }))
|
|
71245
71292
|
});
|
|
71246
71293
|
readSectionTool = defineCommand({
|
|
@@ -137462,7 +137509,7 @@ var init_package2 = __esm({
|
|
|
137462
137509
|
"package.json"() {
|
|
137463
137510
|
package_default2 = {
|
|
137464
137511
|
name: "poe-code",
|
|
137465
|
-
version: "3.0.
|
|
137512
|
+
version: "3.0.313",
|
|
137466
137513
|
description: "CLI tool to configure Poe API for developer workflows.",
|
|
137467
137514
|
type: "module",
|
|
137468
137515
|
main: "./dist/index.js",
|