poe-code 11.0.5 → 11.0.7
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 +8 -3
- package/dist/index.js.map +2 -2
- package/dist/metafile.json +1 -1
- package/package.json +1 -1
- package/packages/safejs/dist/chunks/{chunk-EWC7GLGM.js → chunk-M3VDOFN5.js} +15 -8
- package/packages/safejs/dist/chunks/chunk-M3VDOFN5.js.map +7 -0
- package/packages/safejs/dist/chunks/{chunk-WC2N7PM5.js → chunk-OPNWSDXC.js} +8 -3
- package/packages/safejs/dist/chunks/chunk-OPNWSDXC.js.map +7 -0
- package/packages/safejs/dist/cli.js +9 -12
- package/packages/safejs/dist/cli.js.map +2 -2
- package/packages/safejs/dist/core.js +1 -1
- package/packages/safejs/dist/example-runner.js +6 -6
- package/packages/safejs/dist/index.js +8 -10
- package/packages/safejs/dist/index.js.map +2 -2
- package/packages/safejs/dist/loader/extract-block.d.ts +1 -0
- package/packages/safejs/dist/loader/extract-block.js +9 -6
- package/packages/safejs/dist/parse/parser.js +7 -1
- package/packages/safejs/dist/parse/tokenizer.js +0 -1
- package/packages/safejs/dist/runner/run-harness.js +6 -9
- package/packages/safejs/dist/chunks/chunk-EWC7GLGM.js.map +0 -7
- package/packages/safejs/dist/chunks/chunk-WC2N7PM5.js.map +0 -7
|
@@ -39,12 +39,7 @@ export function extractBlock(markdown, startLine = 1) {
|
|
|
39
39
|
const parts = [];
|
|
40
40
|
let cursor = first.start;
|
|
41
41
|
for (const block of blocks) {
|
|
42
|
-
|
|
43
|
-
for (let offset = cursor; offset < block.start; offset++) {
|
|
44
|
-
const character = markdown[offset];
|
|
45
|
-
gap += character === "\n" || character === "\r" ? character : " ";
|
|
46
|
-
}
|
|
47
|
-
parts.push(gap, markdown.slice(block.start, block.end));
|
|
42
|
+
parts.push(maskSource(markdown.slice(cursor, block.start)), markdown.slice(block.start, block.end));
|
|
48
43
|
cursor = block.end;
|
|
49
44
|
}
|
|
50
45
|
return {
|
|
@@ -55,6 +50,14 @@ export function extractBlock(markdown, startLine = 1) {
|
|
|
55
50
|
ranges: blocks.map((block) => [block.start, block.end])
|
|
56
51
|
};
|
|
57
52
|
}
|
|
53
|
+
export function maskSource(source) {
|
|
54
|
+
let masked = "";
|
|
55
|
+
for (let offset = 0; offset < source.length; offset++) {
|
|
56
|
+
const character = source[offset];
|
|
57
|
+
masked += character === "\n" || character === "\r" ? character : " ";
|
|
58
|
+
}
|
|
59
|
+
return masked;
|
|
60
|
+
}
|
|
58
61
|
function readOpeningFence(line) {
|
|
59
62
|
const fenceStart = readFenceStart(line);
|
|
60
63
|
if (fenceStart === undefined) {
|
|
@@ -759,7 +759,13 @@ class Parser {
|
|
|
759
759
|
}
|
|
760
760
|
];
|
|
761
761
|
}
|
|
762
|
-
this.
|
|
762
|
+
const fromToken = this.currentToken();
|
|
763
|
+
if (fromToken.type !== "identifier" ||
|
|
764
|
+
fromToken.value !== "from" ||
|
|
765
|
+
fromToken.end.offset - fromToken.start.offset !== fromToken.value.length) {
|
|
766
|
+
throw new Error(`Expected 'from' at line ${fromToken.start.line}, column ${fromToken.start.column}.`);
|
|
767
|
+
}
|
|
768
|
+
this.index += 1;
|
|
763
769
|
const sourceToken = this.currentToken();
|
|
764
770
|
if (sourceToken.type !== "string") {
|
|
765
771
|
throw unexpectedTokenError(sourceToken);
|
|
@@ -3,7 +3,7 @@ import { extname } from "node:path";
|
|
|
3
3
|
import { supportsSpawnMode } from "@poe-code/agent-spawn/configs";
|
|
4
4
|
import { SPAWN_MODES } from "@poe-code/agent-spawn/types";
|
|
5
5
|
import { hasOwnErrorCode } from "../error-codes.js";
|
|
6
|
-
import { countLineBreaks, extractBlock } from "../loader/extract-block.js";
|
|
6
|
+
import { countLineBreaks, extractBlock, maskSource } from "../loader/extract-block.js";
|
|
7
7
|
import { splitFrontmatter } from "../loader/frontmatter.js";
|
|
8
8
|
import { lint } from "../lint.js";
|
|
9
9
|
import { createLintModulesFromRuntimeRegistry } from "../lint/runtime-modules.js";
|
|
@@ -52,7 +52,7 @@ export class LintError extends Error {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
export async function runHarness(filepath, options) {
|
|
55
|
-
const rawSource =
|
|
55
|
+
const rawSource = await readHarnessFile(filepath);
|
|
56
56
|
const { executableSource, frontmatter, isRawScript } = loadExecutableSource(filepath, rawSource);
|
|
57
57
|
assertFrontmatterAgentModes(frontmatter);
|
|
58
58
|
const meta = createHarnessMeta(filepath, frontmatter);
|
|
@@ -137,11 +137,12 @@ async function readHarnessFile(filepath) {
|
|
|
137
137
|
}
|
|
138
138
|
function loadExecutableSource(filepath, source) {
|
|
139
139
|
if (isRawScriptPath(filepath)) {
|
|
140
|
-
|
|
140
|
+
const executableSource = stripByteOrderMark(source);
|
|
141
|
+
if (executableSource.length === 0) {
|
|
141
142
|
throw new Error(`No code block found in empty harness file: ${filepath}`);
|
|
142
143
|
}
|
|
143
144
|
return {
|
|
144
|
-
executableSource
|
|
145
|
+
executableSource,
|
|
145
146
|
frontmatter: {},
|
|
146
147
|
isRawScript: true
|
|
147
148
|
};
|
|
@@ -152,9 +153,8 @@ function loadExecutableSource(filepath, source) {
|
|
|
152
153
|
}
|
|
153
154
|
const bodyStartOffset = source.length - body.length;
|
|
154
155
|
const { source: executableBlock, startOffset } = extractBlock(body, countLineBreaks(source, 0, bodyStartOffset) + 1);
|
|
155
|
-
const absoluteLineOffset = countLineBreaks(source, 0, bodyStartOffset + startOffset);
|
|
156
156
|
return {
|
|
157
|
-
executableSource:
|
|
157
|
+
executableSource: maskSource(source.slice(0, bodyStartOffset + startOffset)) + stripHashbang(executableBlock),
|
|
158
158
|
frontmatter,
|
|
159
159
|
isRawScript: false
|
|
160
160
|
};
|
|
@@ -238,9 +238,6 @@ function stripHashbang(source) {
|
|
|
238
238
|
end += 1;
|
|
239
239
|
return `${" ".repeat(end)}${source.slice(end)}`;
|
|
240
240
|
}
|
|
241
|
-
function createLineOffsetSource(source, lineOffset) {
|
|
242
|
-
return `${"\n".repeat(Math.max(lineOffset, 0))}${source}`;
|
|
243
|
-
}
|
|
244
241
|
function formatLintErrorMessage(diagnostics) {
|
|
245
242
|
if (diagnostics.length === 0) {
|
|
246
243
|
return "Script lint failed.";
|