poe-code 3.0.220 → 3.0.221
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/README.md +8 -0
- package/dist/cli/commands/harness.js +107 -15
- package/dist/cli/commands/harness.js.map +1 -1
- package/dist/index.js +767 -38
- package/dist/index.js.map +3 -3
- package/dist/providers/claude-code.js.map +1 -1
- package/dist/providers/codex.js.map +1 -1
- package/dist/providers/goose.js.map +1 -1
- package/dist/providers/kimi.js.map +1 -1
- package/dist/providers/opencode.js.map +1 -1
- package/dist/providers/poe-agent.js.map +2 -2
- package/package.json +4 -2
- package/packages/design-system/dist/prompts/index.d.ts +1 -1
- package/packages/design-system/dist/prompts/index.js +3 -2
- package/packages/memory/dist/index.js.map +1 -1
- package/scripts/postinstall-sync-skills.mjs +31 -0
package/dist/index.js
CHANGED
|
@@ -9154,6 +9154,7 @@ function formatElapsed2(ms) {
|
|
|
9154
9154
|
}
|
|
9155
9155
|
async function withSpinner(options) {
|
|
9156
9156
|
const { message: message2, fn, stopMessage, subtext } = options;
|
|
9157
|
+
const readMessage = () => typeof message2 === "function" ? message2() : message2;
|
|
9157
9158
|
if (resolveOutputFormat() === "json") {
|
|
9158
9159
|
const result = await fn();
|
|
9159
9160
|
const sub = subtext ? subtext(result) : void 0;
|
|
@@ -9182,9 +9183,9 @@ async function withSpinner(options) {
|
|
|
9182
9183
|
}
|
|
9183
9184
|
const s = spinner();
|
|
9184
9185
|
const start = Date.now();
|
|
9185
|
-
s.start(
|
|
9186
|
+
s.start(readMessage());
|
|
9186
9187
|
const timer = setInterval(() => {
|
|
9187
|
-
s.message(`${
|
|
9188
|
+
s.message(`${readMessage()} [${formatElapsed2(Date.now() - start)}]`);
|
|
9188
9189
|
}, 1e3);
|
|
9189
9190
|
try {
|
|
9190
9191
|
const result = await fn();
|
|
@@ -70879,6 +70880,29 @@ function isImportMetaReference(node) {
|
|
|
70879
70880
|
}
|
|
70880
70881
|
return node.type === "MemberExpression" && (isImportMetaReference(node.object) || node.computed && isImportMetaReference(node.property));
|
|
70881
70882
|
}
|
|
70883
|
+
function isAssignmentOperator(value) {
|
|
70884
|
+
switch (value) {
|
|
70885
|
+
case "=":
|
|
70886
|
+
case "+=":
|
|
70887
|
+
case "-=":
|
|
70888
|
+
case "*=":
|
|
70889
|
+
case "/=":
|
|
70890
|
+
case "%=":
|
|
70891
|
+
case "**=":
|
|
70892
|
+
case "&=":
|
|
70893
|
+
case "|=":
|
|
70894
|
+
case "^=":
|
|
70895
|
+
case "<<=":
|
|
70896
|
+
case ">>=":
|
|
70897
|
+
case ">>>=":
|
|
70898
|
+
case "&&=":
|
|
70899
|
+
case "||=":
|
|
70900
|
+
case "??=":
|
|
70901
|
+
return true;
|
|
70902
|
+
default:
|
|
70903
|
+
return false;
|
|
70904
|
+
}
|
|
70905
|
+
}
|
|
70882
70906
|
function createNumericLiteral(token) {
|
|
70883
70907
|
return {
|
|
70884
70908
|
type: "NumericLiteral",
|
|
@@ -71404,14 +71428,15 @@ var init_parser3 = __esm({
|
|
|
71404
71428
|
};
|
|
71405
71429
|
}
|
|
71406
71430
|
const left = this.parseConditionalExpression();
|
|
71407
|
-
|
|
71431
|
+
const operator = this.consumeAssignmentOperator();
|
|
71432
|
+
if (operator === void 0) {
|
|
71408
71433
|
return left;
|
|
71409
71434
|
}
|
|
71410
71435
|
const right = this.parseAssignmentExpression();
|
|
71411
71436
|
return {
|
|
71412
71437
|
node: {
|
|
71413
71438
|
type: "AssignmentExpression",
|
|
71414
|
-
operator
|
|
71439
|
+
operator,
|
|
71415
71440
|
left: this.toAssignmentTarget(left.node),
|
|
71416
71441
|
right: right.node,
|
|
71417
71442
|
span: createSpan2(left.node.span.start, right.node.span.end)
|
|
@@ -73130,6 +73155,14 @@ var init_parser3 = __esm({
|
|
|
73130
73155
|
this.index += 1;
|
|
73131
73156
|
return token;
|
|
73132
73157
|
}
|
|
73158
|
+
consumeAssignmentOperator() {
|
|
73159
|
+
const token = this.currentToken();
|
|
73160
|
+
if (token.type !== "punctuator" || !isAssignmentOperator(token.value)) {
|
|
73161
|
+
return void 0;
|
|
73162
|
+
}
|
|
73163
|
+
this.index += 1;
|
|
73164
|
+
return token.value;
|
|
73165
|
+
}
|
|
73133
73166
|
expectPunctuator(value) {
|
|
73134
73167
|
const token = this.currentToken();
|
|
73135
73168
|
if (token.type !== "punctuator" || token.value !== value) {
|
|
@@ -74380,7 +74413,10 @@ var init_AS002 = __esm({
|
|
|
74380
74413
|
|
|
74381
74414
|
// packages/agent-script/src/lint/rules/AS003.ts
|
|
74382
74415
|
function AS003(source, options = {}) {
|
|
74383
|
-
return new AS003Scanner(
|
|
74416
|
+
return new AS003Scanner(
|
|
74417
|
+
options.filename ?? "<input>",
|
|
74418
|
+
/* @__PURE__ */ new Set([...DEFAULT_ALLOWED_GLOBALS, ...options.allowedGlobals ?? []])
|
|
74419
|
+
).scan(source);
|
|
74384
74420
|
}
|
|
74385
74421
|
function formatNearMatchMessage(names) {
|
|
74386
74422
|
if (names.length === 1) {
|
|
@@ -74413,16 +74449,31 @@ function getLevenshteinDistance2(left, right) {
|
|
|
74413
74449
|
}
|
|
74414
74450
|
return previous[right.length];
|
|
74415
74451
|
}
|
|
74416
|
-
var AS003Scanner;
|
|
74452
|
+
var DEFAULT_ALLOWED_GLOBALS, AS003Scanner;
|
|
74417
74453
|
var init_AS003 = __esm({
|
|
74418
74454
|
"packages/agent-script/src/lint/rules/AS003.ts"() {
|
|
74419
74455
|
"use strict";
|
|
74420
74456
|
init_parser3();
|
|
74457
|
+
DEFAULT_ALLOWED_GLOBALS = [
|
|
74458
|
+
"Array",
|
|
74459
|
+
"Boolean",
|
|
74460
|
+
"Error",
|
|
74461
|
+
"JSON",
|
|
74462
|
+
"Math",
|
|
74463
|
+
"Number",
|
|
74464
|
+
"Object",
|
|
74465
|
+
"Promise",
|
|
74466
|
+
"String",
|
|
74467
|
+
"TypeError",
|
|
74468
|
+
"console"
|
|
74469
|
+
];
|
|
74421
74470
|
AS003Scanner = class {
|
|
74422
|
-
constructor(filename) {
|
|
74471
|
+
constructor(filename, allowedGlobals) {
|
|
74423
74472
|
this.filename = filename;
|
|
74473
|
+
this.allowedGlobals = allowedGlobals;
|
|
74424
74474
|
}
|
|
74425
74475
|
filename;
|
|
74476
|
+
allowedGlobals;
|
|
74426
74477
|
diagnostics = [];
|
|
74427
74478
|
scopes = [];
|
|
74428
74479
|
scan(source) {
|
|
@@ -74780,8 +74831,11 @@ var init_AS003 = __esm({
|
|
|
74780
74831
|
if (this.resolveBinding(node.name) !== void 0) {
|
|
74781
74832
|
return;
|
|
74782
74833
|
}
|
|
74834
|
+
if (this.allowedGlobals.has(node.name)) {
|
|
74835
|
+
return;
|
|
74836
|
+
}
|
|
74783
74837
|
const visibleNames = this.collectVisibleNames();
|
|
74784
|
-
const nearMatches = visibleNames.map((name) => ({ distance: getLevenshteinDistance2(node.name, name), name })).filter((entry) => entry.distance <= 2).sort((left, right) => left.distance - right.distance || left.name.localeCompare(right.name)).map((entry) => entry.name);
|
|
74838
|
+
const nearMatches = this.collectSuggestionNames(visibleNames).map((name) => ({ distance: getLevenshteinDistance2(node.name, name), name })).filter((entry) => entry.distance <= 2).sort((left, right) => left.distance - right.distance || left.name.localeCompare(right.name)).map((entry) => entry.name);
|
|
74785
74839
|
const message2 = nearMatches.length > 0 ? `Unknown identifier '${node.name}'. ${formatNearMatchMessage(nearMatches)}` : `Unknown identifier '${node.name}'. ${formatVisibleNamesMessage(visibleNames)}`;
|
|
74786
74840
|
this.diagnostics.push({
|
|
74787
74841
|
code: "AS003",
|
|
@@ -74820,6 +74874,10 @@ var init_AS003 = __esm({
|
|
|
74820
74874
|
}
|
|
74821
74875
|
return [...names].sort((left, right) => left.localeCompare(right));
|
|
74822
74876
|
}
|
|
74877
|
+
collectSuggestionNames(visibleNames) {
|
|
74878
|
+
const names = /* @__PURE__ */ new Set([...visibleNames, ...this.allowedGlobals]);
|
|
74879
|
+
return [...names].sort((left, right) => left.localeCompare(right));
|
|
74880
|
+
}
|
|
74823
74881
|
collectModuleBindings(body) {
|
|
74824
74882
|
const bindings = [];
|
|
74825
74883
|
for (const statement of body) {
|
|
@@ -80989,12 +81047,138 @@ async function evaluateObjectExpression(node, context) {
|
|
|
80989
81047
|
value: object
|
|
80990
81048
|
};
|
|
80991
81049
|
}
|
|
81050
|
+
async function evaluateTemplateLiteral(node, context) {
|
|
81051
|
+
let value = context.budget.allocateString(node.quasis[0]?.value.cooked ?? "");
|
|
81052
|
+
for (let index = 0; index < node.expressions.length; index += 1) {
|
|
81053
|
+
const expression = await evaluateNode(node.expressions[index], context);
|
|
81054
|
+
if (expression.kind !== "normal") {
|
|
81055
|
+
return expression;
|
|
81056
|
+
}
|
|
81057
|
+
const expressionText = context.budget.allocateString(String(expression.value));
|
|
81058
|
+
value = context.budget.allocateString(value + expressionText);
|
|
81059
|
+
const quasiText = context.budget.allocateString(node.quasis[index + 1]?.value.cooked ?? "");
|
|
81060
|
+
value = context.budget.allocateString(value + quasiText);
|
|
81061
|
+
}
|
|
81062
|
+
return {
|
|
81063
|
+
kind: "normal",
|
|
81064
|
+
hasValue: true,
|
|
81065
|
+
value
|
|
81066
|
+
};
|
|
81067
|
+
}
|
|
80992
81068
|
async function evaluateArrowFunction(node, context) {
|
|
80993
81069
|
return evaluateArrowFunctionExpression(node, context, evaluateNode);
|
|
80994
81070
|
}
|
|
80995
81071
|
async function evaluateAwait(node, context) {
|
|
80996
81072
|
return evaluateAwaitExpression(node, context, evaluateNode);
|
|
80997
81073
|
}
|
|
81074
|
+
async function evaluateBinaryExpression(node, context) {
|
|
81075
|
+
const left = await evaluateNode(node.left, context);
|
|
81076
|
+
if (left.kind !== "normal") {
|
|
81077
|
+
return left;
|
|
81078
|
+
}
|
|
81079
|
+
const right = await evaluateNode(node.right, context);
|
|
81080
|
+
if (right.kind !== "normal") {
|
|
81081
|
+
return right;
|
|
81082
|
+
}
|
|
81083
|
+
const value = applyBinaryOperator(node, left.value, right.value, context);
|
|
81084
|
+
return {
|
|
81085
|
+
kind: "normal",
|
|
81086
|
+
hasValue: true,
|
|
81087
|
+
value
|
|
81088
|
+
};
|
|
81089
|
+
}
|
|
81090
|
+
async function evaluateAssignmentExpression(node, context) {
|
|
81091
|
+
if (node.left.type === "MemberExpression") {
|
|
81092
|
+
throw new Error("member-target assignment is not supported");
|
|
81093
|
+
}
|
|
81094
|
+
if (node.left.type !== "Identifier") {
|
|
81095
|
+
return {
|
|
81096
|
+
kind: "error",
|
|
81097
|
+
error: createError(
|
|
81098
|
+
"UNSUPPORTED_NODE",
|
|
81099
|
+
node,
|
|
81100
|
+
`Unsupported assignment target '${node.left.type}'.`
|
|
81101
|
+
)
|
|
81102
|
+
};
|
|
81103
|
+
}
|
|
81104
|
+
const binding = context.scope.lookup(node.left.name);
|
|
81105
|
+
if (!binding.found) {
|
|
81106
|
+
return {
|
|
81107
|
+
kind: "error",
|
|
81108
|
+
error: createError(
|
|
81109
|
+
"UNBOUND_IDENTIFIER",
|
|
81110
|
+
node.left,
|
|
81111
|
+
`Identifier '${node.left.name}' is not defined.`
|
|
81112
|
+
)
|
|
81113
|
+
};
|
|
81114
|
+
}
|
|
81115
|
+
if (binding.kind === "const") {
|
|
81116
|
+
throw new Error(`Cannot assign to const '${node.left.name}'`);
|
|
81117
|
+
}
|
|
81118
|
+
if (node.operator === "&&=" && !isTruthy(binding.value)) {
|
|
81119
|
+
return {
|
|
81120
|
+
kind: "normal",
|
|
81121
|
+
hasValue: true,
|
|
81122
|
+
value: binding.value
|
|
81123
|
+
};
|
|
81124
|
+
}
|
|
81125
|
+
if (node.operator === "||=" && isTruthy(binding.value)) {
|
|
81126
|
+
return {
|
|
81127
|
+
kind: "normal",
|
|
81128
|
+
hasValue: true,
|
|
81129
|
+
value: binding.value
|
|
81130
|
+
};
|
|
81131
|
+
}
|
|
81132
|
+
if (node.operator === "??=" && binding.value !== null && binding.value !== void 0) {
|
|
81133
|
+
return {
|
|
81134
|
+
kind: "normal",
|
|
81135
|
+
hasValue: true,
|
|
81136
|
+
value: binding.value
|
|
81137
|
+
};
|
|
81138
|
+
}
|
|
81139
|
+
const right = await evaluateNode(node.right, context);
|
|
81140
|
+
if (right.kind !== "normal") {
|
|
81141
|
+
return right;
|
|
81142
|
+
}
|
|
81143
|
+
const value = node.operator === "=" || node.operator === "&&=" || node.operator === "||=" || node.operator === "??=" ? right.value : applyCompoundAssignmentOperator(node.operator, binding.value, right.value, context);
|
|
81144
|
+
context.scope.assign(node.left.name, value);
|
|
81145
|
+
return {
|
|
81146
|
+
kind: "normal",
|
|
81147
|
+
hasValue: true,
|
|
81148
|
+
value
|
|
81149
|
+
};
|
|
81150
|
+
}
|
|
81151
|
+
async function evaluateLogicalExpression(node, context) {
|
|
81152
|
+
const left = await evaluateNode(node.left, context);
|
|
81153
|
+
if (left.kind !== "normal") {
|
|
81154
|
+
return left;
|
|
81155
|
+
}
|
|
81156
|
+
switch (node.operator) {
|
|
81157
|
+
case "&&":
|
|
81158
|
+
if (!isTruthy(left.value)) {
|
|
81159
|
+
return left;
|
|
81160
|
+
}
|
|
81161
|
+
break;
|
|
81162
|
+
case "||":
|
|
81163
|
+
if (isTruthy(left.value)) {
|
|
81164
|
+
return left;
|
|
81165
|
+
}
|
|
81166
|
+
break;
|
|
81167
|
+
case "??":
|
|
81168
|
+
if (left.value !== null && left.value !== void 0) {
|
|
81169
|
+
return left;
|
|
81170
|
+
}
|
|
81171
|
+
break;
|
|
81172
|
+
}
|
|
81173
|
+
return evaluateNode(node.right, context);
|
|
81174
|
+
}
|
|
81175
|
+
async function evaluateConditionalExpression(node, context) {
|
|
81176
|
+
const test = await evaluateNode(node.test, context);
|
|
81177
|
+
if (test.kind !== "normal") {
|
|
81178
|
+
return test;
|
|
81179
|
+
}
|
|
81180
|
+
return evaluateNode(isTruthy(test.value) ? node.consequent : node.alternate, context);
|
|
81181
|
+
}
|
|
80998
81182
|
async function evaluateIdentifier(node, context) {
|
|
80999
81183
|
const binding = context.scope.lookup(node.name);
|
|
81000
81184
|
if (!binding.found) {
|
|
@@ -81033,9 +81217,6 @@ async function evaluateExportNamedDeclaration(node, context) {
|
|
|
81033
81217
|
}
|
|
81034
81218
|
async function evaluateVariableDeclaration(node, context) {
|
|
81035
81219
|
for (const declarator of node.declarations) {
|
|
81036
|
-
if (declarator.id.type !== "Identifier") {
|
|
81037
|
-
throw new TypeError(`Unsupported variable declaration pattern '${declarator.id.type}'.`);
|
|
81038
|
-
}
|
|
81039
81220
|
const value = declarator.init === void 0 ? {
|
|
81040
81221
|
kind: "normal",
|
|
81041
81222
|
hasValue: true,
|
|
@@ -81044,7 +81225,10 @@ async function evaluateVariableDeclaration(node, context) {
|
|
|
81044
81225
|
if (value.kind !== "normal") {
|
|
81045
81226
|
return value;
|
|
81046
81227
|
}
|
|
81047
|
-
|
|
81228
|
+
const binding = await bindDeclarationPattern(declarator.id, value.value, node.kind, context);
|
|
81229
|
+
if (!binding.ok) {
|
|
81230
|
+
return binding.result;
|
|
81231
|
+
}
|
|
81048
81232
|
}
|
|
81049
81233
|
return {
|
|
81050
81234
|
kind: "normal",
|
|
@@ -81052,6 +81236,107 @@ async function evaluateVariableDeclaration(node, context) {
|
|
|
81052
81236
|
value: void 0
|
|
81053
81237
|
};
|
|
81054
81238
|
}
|
|
81239
|
+
async function bindDeclarationPattern(pattern, value, kind, context) {
|
|
81240
|
+
switch (pattern.type) {
|
|
81241
|
+
case "Identifier":
|
|
81242
|
+
context.scope.declare(pattern.name, kind, value);
|
|
81243
|
+
return { ok: true };
|
|
81244
|
+
case "MemberExpression":
|
|
81245
|
+
throw new TypeError("Destructuring declarations cannot bind to member expressions.");
|
|
81246
|
+
case "AssignmentPattern":
|
|
81247
|
+
return bindDeclarationAssignmentPattern(pattern, value, kind, context);
|
|
81248
|
+
case "ArrayPattern":
|
|
81249
|
+
return bindDeclarationArrayPattern(pattern, value, kind, context);
|
|
81250
|
+
case "ObjectPattern":
|
|
81251
|
+
return bindDeclarationObjectPattern(pattern, value, kind, context);
|
|
81252
|
+
case "RestElement":
|
|
81253
|
+
return bindDeclarationPattern(pattern.argument, value, kind, context);
|
|
81254
|
+
}
|
|
81255
|
+
}
|
|
81256
|
+
async function bindDeclarationAssignmentPattern(pattern, value, kind, context) {
|
|
81257
|
+
if (value !== void 0) {
|
|
81258
|
+
return bindDeclarationPattern(pattern.left, value, kind, context);
|
|
81259
|
+
}
|
|
81260
|
+
const defaultValue = await evaluateNode(pattern.right, context);
|
|
81261
|
+
if (defaultValue.kind !== "normal") {
|
|
81262
|
+
return {
|
|
81263
|
+
ok: false,
|
|
81264
|
+
result: defaultValue
|
|
81265
|
+
};
|
|
81266
|
+
}
|
|
81267
|
+
return bindDeclarationPattern(pattern.left, defaultValue.value, kind, context);
|
|
81268
|
+
}
|
|
81269
|
+
async function bindDeclarationArrayPattern(pattern, value, kind, context) {
|
|
81270
|
+
if (!Array.isArray(value)) {
|
|
81271
|
+
throw new TypeError("Array destructuring declarations require an array value.");
|
|
81272
|
+
}
|
|
81273
|
+
for (let index = 0; index < pattern.elements.length; index += 1) {
|
|
81274
|
+
const element = pattern.elements[index];
|
|
81275
|
+
if (element === null) {
|
|
81276
|
+
continue;
|
|
81277
|
+
}
|
|
81278
|
+
const elementValue = element.type === "RestElement" ? value.slice(index) : value[index];
|
|
81279
|
+
const binding = await bindDeclarationPattern(element, elementValue, kind, context);
|
|
81280
|
+
if (!binding.ok) {
|
|
81281
|
+
return binding;
|
|
81282
|
+
}
|
|
81283
|
+
}
|
|
81284
|
+
return { ok: true };
|
|
81285
|
+
}
|
|
81286
|
+
async function bindDeclarationObjectPattern(pattern, value, kind, context) {
|
|
81287
|
+
if (typeof value !== "object" || value === null) {
|
|
81288
|
+
throw new TypeError("Object destructuring declarations require a non-null object value.");
|
|
81289
|
+
}
|
|
81290
|
+
const excludedKeys = /* @__PURE__ */ new Set();
|
|
81291
|
+
for (const property of pattern.properties) {
|
|
81292
|
+
if (property.type === "RestElement") {
|
|
81293
|
+
const binding2 = await bindDeclarationPattern(
|
|
81294
|
+
property,
|
|
81295
|
+
copyObjectRestValue(value, excludedKeys),
|
|
81296
|
+
kind,
|
|
81297
|
+
context
|
|
81298
|
+
);
|
|
81299
|
+
if (!binding2.ok) {
|
|
81300
|
+
return binding2;
|
|
81301
|
+
}
|
|
81302
|
+
continue;
|
|
81303
|
+
}
|
|
81304
|
+
const key2 = await evaluateDeclarationPatternKey(property, context);
|
|
81305
|
+
if (!key2.ok) {
|
|
81306
|
+
return key2;
|
|
81307
|
+
}
|
|
81308
|
+
excludedKeys.add(String(key2.value));
|
|
81309
|
+
const binding = await bindDeclarationPattern(
|
|
81310
|
+
property.value,
|
|
81311
|
+
value[key2.value],
|
|
81312
|
+
kind,
|
|
81313
|
+
context
|
|
81314
|
+
);
|
|
81315
|
+
if (!binding.ok) {
|
|
81316
|
+
return binding;
|
|
81317
|
+
}
|
|
81318
|
+
}
|
|
81319
|
+
return { ok: true };
|
|
81320
|
+
}
|
|
81321
|
+
async function evaluateDeclarationPatternKey(property, context) {
|
|
81322
|
+
if (!property.computed) {
|
|
81323
|
+
return {
|
|
81324
|
+
ok: true,
|
|
81325
|
+
value: getStaticPropertyName(property.key)
|
|
81326
|
+
};
|
|
81327
|
+
}
|
|
81328
|
+
return evaluateMemberProperty(property.key, context);
|
|
81329
|
+
}
|
|
81330
|
+
function copyObjectRestValue(value, excludedKeys) {
|
|
81331
|
+
const rest = /* @__PURE__ */ Object.create(null);
|
|
81332
|
+
for (const [key2, entryValue] of Object.entries(value)) {
|
|
81333
|
+
if (excludedKeys.has(key2)) {
|
|
81334
|
+
continue;
|
|
81335
|
+
}
|
|
81336
|
+
defineSandboxProperty(rest, key2, entryValue);
|
|
81337
|
+
}
|
|
81338
|
+
return rest;
|
|
81339
|
+
}
|
|
81055
81340
|
async function evaluateBlockStatement(node, context) {
|
|
81056
81341
|
for (const statement of node.body) {
|
|
81057
81342
|
const result = await evaluateNode(statement, context);
|
|
@@ -81065,6 +81350,144 @@ async function evaluateBlockStatement(node, context) {
|
|
|
81065
81350
|
value: void 0
|
|
81066
81351
|
};
|
|
81067
81352
|
}
|
|
81353
|
+
async function evaluateIfStatement(node, context) {
|
|
81354
|
+
const test = await evaluateNode(node.test, context);
|
|
81355
|
+
if (test.kind !== "normal") {
|
|
81356
|
+
return test;
|
|
81357
|
+
}
|
|
81358
|
+
const branch = isTruthy(test.value) ? node.consequent : node.alternate;
|
|
81359
|
+
if (branch === void 0) {
|
|
81360
|
+
return {
|
|
81361
|
+
kind: "normal",
|
|
81362
|
+
hasValue: false,
|
|
81363
|
+
value: void 0
|
|
81364
|
+
};
|
|
81365
|
+
}
|
|
81366
|
+
return evaluateNode(branch, context);
|
|
81367
|
+
}
|
|
81368
|
+
async function evaluateForOfStatement(node, context) {
|
|
81369
|
+
const iterable = await evaluateNode(node.right, context);
|
|
81370
|
+
if (iterable.kind !== "normal") {
|
|
81371
|
+
return iterable;
|
|
81372
|
+
}
|
|
81373
|
+
if (!Array.isArray(iterable.value)) {
|
|
81374
|
+
throw new TypeError(`${String(iterable.value)} is not a supported iterable`);
|
|
81375
|
+
}
|
|
81376
|
+
for (const entry of iterable.value) {
|
|
81377
|
+
const scope = context.scope.child();
|
|
81378
|
+
bindForOfLoopVariable(node.left, entry, scope);
|
|
81379
|
+
const result = await evaluateNode(node.body, {
|
|
81380
|
+
...context,
|
|
81381
|
+
scope
|
|
81382
|
+
});
|
|
81383
|
+
if (result.kind === "break") {
|
|
81384
|
+
return {
|
|
81385
|
+
kind: "normal",
|
|
81386
|
+
hasValue: false,
|
|
81387
|
+
value: void 0
|
|
81388
|
+
};
|
|
81389
|
+
}
|
|
81390
|
+
if (result.kind === "continue") {
|
|
81391
|
+
continue;
|
|
81392
|
+
}
|
|
81393
|
+
if (result.kind !== "normal") {
|
|
81394
|
+
return result;
|
|
81395
|
+
}
|
|
81396
|
+
}
|
|
81397
|
+
return {
|
|
81398
|
+
kind: "normal",
|
|
81399
|
+
hasValue: false,
|
|
81400
|
+
value: void 0
|
|
81401
|
+
};
|
|
81402
|
+
}
|
|
81403
|
+
async function evaluateForStatement(node, context) {
|
|
81404
|
+
const loopContext = {
|
|
81405
|
+
...context,
|
|
81406
|
+
scope: context.scope.child()
|
|
81407
|
+
};
|
|
81408
|
+
if (node.init !== void 0) {
|
|
81409
|
+
const init = await evaluateNode(node.init, loopContext);
|
|
81410
|
+
if (init.kind !== "normal") {
|
|
81411
|
+
return init;
|
|
81412
|
+
}
|
|
81413
|
+
}
|
|
81414
|
+
while (true) {
|
|
81415
|
+
context.budget.visitNode();
|
|
81416
|
+
context.stats.nodeVisits += 1;
|
|
81417
|
+
if (node.test !== void 0) {
|
|
81418
|
+
const test = await evaluateNode(node.test, loopContext);
|
|
81419
|
+
if (test.kind !== "normal") {
|
|
81420
|
+
return test;
|
|
81421
|
+
}
|
|
81422
|
+
if (!isTruthy(test.value)) {
|
|
81423
|
+
return {
|
|
81424
|
+
kind: "normal",
|
|
81425
|
+
hasValue: false,
|
|
81426
|
+
value: void 0
|
|
81427
|
+
};
|
|
81428
|
+
}
|
|
81429
|
+
}
|
|
81430
|
+
const result = await evaluateNode(node.body, loopContext);
|
|
81431
|
+
if (result.kind === "break") {
|
|
81432
|
+
return {
|
|
81433
|
+
kind: "normal",
|
|
81434
|
+
hasValue: false,
|
|
81435
|
+
value: void 0
|
|
81436
|
+
};
|
|
81437
|
+
}
|
|
81438
|
+
if (result.kind !== "normal" && result.kind !== "continue") {
|
|
81439
|
+
return result;
|
|
81440
|
+
}
|
|
81441
|
+
if (node.update !== void 0) {
|
|
81442
|
+
const update = await evaluateNode(node.update, loopContext);
|
|
81443
|
+
if (update.kind !== "normal") {
|
|
81444
|
+
return update;
|
|
81445
|
+
}
|
|
81446
|
+
}
|
|
81447
|
+
}
|
|
81448
|
+
}
|
|
81449
|
+
async function evaluateWhileStatement(node, context) {
|
|
81450
|
+
while (true) {
|
|
81451
|
+
const test = await evaluateNode(node.test, context);
|
|
81452
|
+
if (test.kind !== "normal") {
|
|
81453
|
+
return test;
|
|
81454
|
+
}
|
|
81455
|
+
if (!isTruthy(test.value)) {
|
|
81456
|
+
return {
|
|
81457
|
+
kind: "normal",
|
|
81458
|
+
hasValue: false,
|
|
81459
|
+
value: void 0
|
|
81460
|
+
};
|
|
81461
|
+
}
|
|
81462
|
+
const result = await evaluateNode(node.body, context);
|
|
81463
|
+
if (result.kind === "break") {
|
|
81464
|
+
return {
|
|
81465
|
+
kind: "normal",
|
|
81466
|
+
hasValue: false,
|
|
81467
|
+
value: void 0
|
|
81468
|
+
};
|
|
81469
|
+
}
|
|
81470
|
+
if (result.kind === "continue") {
|
|
81471
|
+
continue;
|
|
81472
|
+
}
|
|
81473
|
+
if (result.kind !== "normal") {
|
|
81474
|
+
return result;
|
|
81475
|
+
}
|
|
81476
|
+
}
|
|
81477
|
+
}
|
|
81478
|
+
function bindForOfLoopVariable(left, value, scope) {
|
|
81479
|
+
if (left.type !== "VariableDeclaration") {
|
|
81480
|
+
throw new TypeError(`Unsupported for...of left-hand side '${left.type}'.`);
|
|
81481
|
+
}
|
|
81482
|
+
const [declarator] = left.declarations;
|
|
81483
|
+
if (left.declarations.length !== 1 || declarator === void 0) {
|
|
81484
|
+
throw new TypeError("for...of declarations must include exactly one declarator.");
|
|
81485
|
+
}
|
|
81486
|
+
if (declarator.id.type !== "Identifier") {
|
|
81487
|
+
throw new TypeError(`Unsupported for...of declaration pattern '${declarator.id.type}'.`);
|
|
81488
|
+
}
|
|
81489
|
+
scope.declare(declarator.id.name, left.kind, value);
|
|
81490
|
+
}
|
|
81068
81491
|
async function evaluateExpressionStatement(node, context) {
|
|
81069
81492
|
return evaluateNode(node.expression, context);
|
|
81070
81493
|
}
|
|
@@ -81376,6 +81799,99 @@ function applyUnaryOperator(operator, value) {
|
|
|
81376
81799
|
return ~value;
|
|
81377
81800
|
}
|
|
81378
81801
|
}
|
|
81802
|
+
function isTruthy(value) {
|
|
81803
|
+
return applyUnaryOperator("!", value) === false;
|
|
81804
|
+
}
|
|
81805
|
+
function applyBinaryOperator(node, left, right, context) {
|
|
81806
|
+
switch (node.operator) {
|
|
81807
|
+
case "+":
|
|
81808
|
+
return applyAdditionOperator(left, right, context);
|
|
81809
|
+
case "-":
|
|
81810
|
+
return Number(left) - Number(right);
|
|
81811
|
+
case "*":
|
|
81812
|
+
return Number(left) * Number(right);
|
|
81813
|
+
case "/":
|
|
81814
|
+
return Number(left) / Number(right);
|
|
81815
|
+
case "%":
|
|
81816
|
+
return Number(left) % Number(right);
|
|
81817
|
+
case "**":
|
|
81818
|
+
return Number(left) ** Number(right);
|
|
81819
|
+
case "<":
|
|
81820
|
+
return compareLessThan(left, right);
|
|
81821
|
+
case "<=":
|
|
81822
|
+
return compareLessThanOrEqual(left, right);
|
|
81823
|
+
case ">":
|
|
81824
|
+
return compareGreaterThan(left, right);
|
|
81825
|
+
case ">=":
|
|
81826
|
+
return compareGreaterThanOrEqual(left, right);
|
|
81827
|
+
case "===":
|
|
81828
|
+
case "==":
|
|
81829
|
+
return left === right;
|
|
81830
|
+
case "!==":
|
|
81831
|
+
case "!=":
|
|
81832
|
+
return left !== right;
|
|
81833
|
+
case "&":
|
|
81834
|
+
return Number(left) & Number(right);
|
|
81835
|
+
case "|":
|
|
81836
|
+
return Number(left) | Number(right);
|
|
81837
|
+
case "^":
|
|
81838
|
+
return Number(left) ^ Number(right);
|
|
81839
|
+
case "<<":
|
|
81840
|
+
return Number(left) << Number(right);
|
|
81841
|
+
case ">>":
|
|
81842
|
+
return Number(left) >> Number(right);
|
|
81843
|
+
case ">>>":
|
|
81844
|
+
return Number(left) >>> Number(right);
|
|
81845
|
+
case "in":
|
|
81846
|
+
throw createError("UNSUPPORTED_NODE", node, "Binary operator 'in' is not supported.");
|
|
81847
|
+
}
|
|
81848
|
+
}
|
|
81849
|
+
function applyCompoundAssignmentOperator(operator, left, right, context) {
|
|
81850
|
+
switch (operator) {
|
|
81851
|
+
case "+=":
|
|
81852
|
+
return applyAdditionOperator(left, right, context);
|
|
81853
|
+
case "-=":
|
|
81854
|
+
return Number(left) - Number(right);
|
|
81855
|
+
case "*=":
|
|
81856
|
+
return Number(left) * Number(right);
|
|
81857
|
+
case "/=":
|
|
81858
|
+
return Number(left) / Number(right);
|
|
81859
|
+
case "%=":
|
|
81860
|
+
return Number(left) % Number(right);
|
|
81861
|
+
case "**=":
|
|
81862
|
+
return Number(left) ** Number(right);
|
|
81863
|
+
case "&=":
|
|
81864
|
+
return Number(left) & Number(right);
|
|
81865
|
+
case "|=":
|
|
81866
|
+
return Number(left) | Number(right);
|
|
81867
|
+
case "^=":
|
|
81868
|
+
return Number(left) ^ Number(right);
|
|
81869
|
+
case "<<=":
|
|
81870
|
+
return Number(left) << Number(right);
|
|
81871
|
+
case ">>=":
|
|
81872
|
+
return Number(left) >> Number(right);
|
|
81873
|
+
case ">>>=":
|
|
81874
|
+
return Number(left) >>> Number(right);
|
|
81875
|
+
}
|
|
81876
|
+
}
|
|
81877
|
+
function applyAdditionOperator(left, right, context) {
|
|
81878
|
+
if (typeof left === "string" || typeof right === "string") {
|
|
81879
|
+
return context.budget.allocateString(String(left) + String(right));
|
|
81880
|
+
}
|
|
81881
|
+
return Number(left) + Number(right);
|
|
81882
|
+
}
|
|
81883
|
+
function compareLessThan(left, right) {
|
|
81884
|
+
return typeof left === "string" && typeof right === "string" ? left < right : Number(left) < Number(right);
|
|
81885
|
+
}
|
|
81886
|
+
function compareLessThanOrEqual(left, right) {
|
|
81887
|
+
return typeof left === "string" && typeof right === "string" ? left <= right : Number(left) <= Number(right);
|
|
81888
|
+
}
|
|
81889
|
+
function compareGreaterThan(left, right) {
|
|
81890
|
+
return typeof left === "string" && typeof right === "string" ? left > right : Number(left) > Number(right);
|
|
81891
|
+
}
|
|
81892
|
+
function compareGreaterThanOrEqual(left, right) {
|
|
81893
|
+
return typeof left === "string" && typeof right === "string" ? left >= right : Number(left) >= Number(right);
|
|
81894
|
+
}
|
|
81379
81895
|
function isIndexableSandboxValue(value) {
|
|
81380
81896
|
return Array.isArray(value) || isPlainSandboxObject(value);
|
|
81381
81897
|
}
|
|
@@ -81504,15 +82020,37 @@ async function evaluateObjectSpread(node, context) {
|
|
|
81504
82020
|
result: value
|
|
81505
82021
|
};
|
|
81506
82022
|
}
|
|
81507
|
-
if (
|
|
81508
|
-
throw new TypeError("
|
|
82023
|
+
if (Array.isArray(value.value)) {
|
|
82024
|
+
throw new TypeError("Cannot spread array into object literal.");
|
|
82025
|
+
}
|
|
82026
|
+
if (!isPlainSandboxObject(value.value)) {
|
|
82027
|
+
throw new TypeError(
|
|
82028
|
+
`Cannot spread ${describeObjectSpreadValue(value.value)} into object literal.`
|
|
82029
|
+
);
|
|
81509
82030
|
}
|
|
81510
82031
|
const spreadValue = value.value;
|
|
82032
|
+
const keys = Object.keys(spreadValue);
|
|
82033
|
+
context.budget.allocateArrayLength(keys.length);
|
|
81511
82034
|
return {
|
|
81512
82035
|
ok: true,
|
|
81513
|
-
value:
|
|
82036
|
+
value: keys.map((key2) => [key2, spreadValue[key2]])
|
|
81514
82037
|
};
|
|
81515
82038
|
}
|
|
82039
|
+
function describeObjectSpreadValue(value) {
|
|
82040
|
+
if (value === null) {
|
|
82041
|
+
return "null";
|
|
82042
|
+
}
|
|
82043
|
+
if (value === void 0) {
|
|
82044
|
+
return "undefined";
|
|
82045
|
+
}
|
|
82046
|
+
if (isSandboxClosure(value)) {
|
|
82047
|
+
return "function";
|
|
82048
|
+
}
|
|
82049
|
+
if (isSandboxPromise(value)) {
|
|
82050
|
+
return "promise";
|
|
82051
|
+
}
|
|
82052
|
+
return typeof value;
|
|
82053
|
+
}
|
|
81516
82054
|
function defineSandboxProperty(target, key2, value) {
|
|
81517
82055
|
Object.defineProperty(target, key2, {
|
|
81518
82056
|
configurable: true,
|
|
@@ -81559,16 +82097,23 @@ var init_interpreter = __esm({
|
|
|
81559
82097
|
init_scope();
|
|
81560
82098
|
dispatchTable = {
|
|
81561
82099
|
ArrayExpression: evaluateArrayExpression,
|
|
82100
|
+
AssignmentExpression: evaluateAssignmentExpression,
|
|
81562
82101
|
ArrowFunctionExpression: evaluateArrowFunction,
|
|
81563
82102
|
AwaitExpression: evaluateAwait,
|
|
82103
|
+
BinaryExpression: evaluateBinaryExpression,
|
|
81564
82104
|
BlockStatement: evaluateBlockStatement,
|
|
81565
82105
|
BooleanLiteral: evaluatePrimitiveLiteral,
|
|
81566
82106
|
CallExpression: evaluateCallExpression,
|
|
82107
|
+
ConditionalExpression: evaluateConditionalExpression,
|
|
81567
82108
|
ContinueStatement: evaluateContinueStatement,
|
|
81568
82109
|
ExportDefaultDeclaration: evaluateExportDefaultDeclaration,
|
|
81569
82110
|
ExportNamedDeclaration: evaluateExportNamedDeclaration,
|
|
81570
82111
|
ExpressionStatement: evaluateExpressionStatement,
|
|
82112
|
+
ForOfStatement: evaluateForOfStatement,
|
|
82113
|
+
ForStatement: evaluateForStatement,
|
|
82114
|
+
IfStatement: evaluateIfStatement,
|
|
81571
82115
|
Identifier: evaluateIdentifier,
|
|
82116
|
+
LogicalExpression: evaluateLogicalExpression,
|
|
81572
82117
|
MemberExpression: evaluateMemberExpression,
|
|
81573
82118
|
MetaProperty: evaluateMetaProperty,
|
|
81574
82119
|
NullLiteral: evaluatePrimitiveLiteral,
|
|
@@ -81577,10 +82122,12 @@ var init_interpreter = __esm({
|
|
|
81577
82122
|
BreakStatement: evaluateBreakStatement,
|
|
81578
82123
|
ReturnStatement: evaluateReturnStatement,
|
|
81579
82124
|
StringLiteral: evaluatePrimitiveLiteral,
|
|
82125
|
+
TemplateLiteral: evaluateTemplateLiteral,
|
|
81580
82126
|
ThrowStatement: evaluateThrowStatement2,
|
|
81581
82127
|
TryStatement: evaluateTryStatement2,
|
|
81582
82128
|
UnaryExpression: evaluateUnaryExpression,
|
|
81583
82129
|
VariableDeclaration: evaluateVariableDeclaration,
|
|
82130
|
+
WhileStatement: evaluateWhileStatement,
|
|
81584
82131
|
UndefinedLiteral: evaluatePrimitiveLiteral
|
|
81585
82132
|
};
|
|
81586
82133
|
}
|
|
@@ -85315,6 +85862,7 @@ var init_git2 = __esm({
|
|
|
85315
85862
|
// packages/agent-script/src/modules/harness.ts
|
|
85316
85863
|
function makeHarnessModule(frontmatter, meta) {
|
|
85317
85864
|
const copiedFrontmatter = copyHarnessValue(frontmatter);
|
|
85865
|
+
const constraints = readConstraints(copiedFrontmatter);
|
|
85318
85866
|
return {
|
|
85319
85867
|
tasks: copyHarnessValue(copiedFrontmatter.tasks),
|
|
85320
85868
|
agents: copyHarnessValue(copiedFrontmatter.agents),
|
|
@@ -85323,12 +85871,40 @@ function makeHarnessModule(frontmatter, meta) {
|
|
|
85323
85871
|
version: copyHarnessValue(meta.version),
|
|
85324
85872
|
filepath: meta.filepath,
|
|
85325
85873
|
frontmatter: copiedFrontmatter
|
|
85326
|
-
}
|
|
85874
|
+
},
|
|
85875
|
+
applyConstraints: (prompt) => applyConstraints(prompt, constraints)
|
|
85327
85876
|
};
|
|
85328
85877
|
}
|
|
85329
85878
|
function copyHarnessValue(value) {
|
|
85330
85879
|
return deepCopyToSandbox(value);
|
|
85331
85880
|
}
|
|
85881
|
+
function readConstraints(frontmatter) {
|
|
85882
|
+
const constraints = /* @__PURE__ */ new Set();
|
|
85883
|
+
appendConstraintValues(constraints, frontmatter.principles);
|
|
85884
|
+
appendConstraintValues(constraints, frontmatter.constraints);
|
|
85885
|
+
return [...constraints];
|
|
85886
|
+
}
|
|
85887
|
+
function appendConstraintValues(constraints, value) {
|
|
85888
|
+
if (!Array.isArray(value)) {
|
|
85889
|
+
return;
|
|
85890
|
+
}
|
|
85891
|
+
for (const item of value) {
|
|
85892
|
+
if (typeof item !== "string") {
|
|
85893
|
+
throw new Error("constraints/principles must be strings");
|
|
85894
|
+
}
|
|
85895
|
+
constraints.add(item);
|
|
85896
|
+
}
|
|
85897
|
+
}
|
|
85898
|
+
function applyConstraints(prompt, constraints) {
|
|
85899
|
+
if (constraints.length === 0) {
|
|
85900
|
+
return prompt;
|
|
85901
|
+
}
|
|
85902
|
+
const preamble = `CONSTRAINTS (hard rules, honor all):
|
|
85903
|
+
${constraints.map((constraint) => `- ${constraint}`).join("\n")}`;
|
|
85904
|
+
return prompt.length === 0 ? preamble : `${preamble}
|
|
85905
|
+
|
|
85906
|
+
${prompt}`;
|
|
85907
|
+
}
|
|
85332
85908
|
var init_harness = __esm({
|
|
85333
85909
|
"packages/agent-script/src/modules/harness.ts"() {
|
|
85334
85910
|
"use strict";
|
|
@@ -85546,7 +86122,11 @@ async function extractSchema(ajsSource, ajsPath) {
|
|
|
85546
86122
|
);
|
|
85547
86123
|
const result = await evaluateSchemaInitializer(initializerSource, ajsPath);
|
|
85548
86124
|
if (!result.ok) {
|
|
85549
|
-
throwSchemaInitializerError(
|
|
86125
|
+
throwSchemaInitializerError(
|
|
86126
|
+
ajsPath,
|
|
86127
|
+
result.error,
|
|
86128
|
+
findPriorOuterSchemaBinding(module, initializer.span.start.offset, result.error)
|
|
86129
|
+
);
|
|
85550
86130
|
}
|
|
85551
86131
|
return await deepCopyFromSandbox(result.returnValue);
|
|
85552
86132
|
}
|
|
@@ -85563,13 +86143,62 @@ async function evaluateSchemaInitializer(initializerSource, ajsPath) {
|
|
|
85563
86143
|
throwSchemaInitializerError(ajsPath, error3);
|
|
85564
86144
|
}
|
|
85565
86145
|
}
|
|
85566
|
-
function throwSchemaInitializerError(ajsPath, cause) {
|
|
86146
|
+
function throwSchemaInitializerError(ajsPath, cause, outerSchemaBindingName) {
|
|
86147
|
+
if (outerSchemaBindingName !== void 0) {
|
|
86148
|
+
throw new Error(
|
|
86149
|
+
`Failed to evaluate schema initializer in ${ajsPath}: schema initializer is evaluated in isolation; outer const '${outerSchemaBindingName}' is not in scope. Inline the value or move it into the schema literal.`,
|
|
86150
|
+
{ cause }
|
|
86151
|
+
);
|
|
86152
|
+
}
|
|
85567
86153
|
const detail = readErrorMessage2(cause);
|
|
85568
86154
|
throw new Error(
|
|
85569
86155
|
`Failed to evaluate schema initializer in ${ajsPath}: schema initializer must be pure; only "schema" module imports allowed. ${detail}`,
|
|
85570
86156
|
{ cause }
|
|
85571
86157
|
);
|
|
85572
86158
|
}
|
|
86159
|
+
function findPriorOuterSchemaBinding(module, initializerStartOffset, cause) {
|
|
86160
|
+
const unboundName = readUnboundIdentifierName(cause);
|
|
86161
|
+
if (unboundName === void 0) {
|
|
86162
|
+
return void 0;
|
|
86163
|
+
}
|
|
86164
|
+
return collectPriorTopLevelBindings(module, initializerStartOffset).has(unboundName) ? unboundName : void 0;
|
|
86165
|
+
}
|
|
86166
|
+
function collectPriorTopLevelBindings(module, initializerStartOffset) {
|
|
86167
|
+
const bindingNames = /* @__PURE__ */ new Set();
|
|
86168
|
+
for (const statement of module.body) {
|
|
86169
|
+
const declaration = readVariableDeclaration(statement);
|
|
86170
|
+
if (declaration === void 0 || declaration.kind !== "const" && declaration.kind !== "let") {
|
|
86171
|
+
continue;
|
|
86172
|
+
}
|
|
86173
|
+
for (const declarator of declaration.declarations) {
|
|
86174
|
+
if (declarator.id.type === "Identifier" && declarator.id.span.start.offset < initializerStartOffset) {
|
|
86175
|
+
bindingNames.add(declarator.id.name);
|
|
86176
|
+
}
|
|
86177
|
+
}
|
|
86178
|
+
}
|
|
86179
|
+
return bindingNames;
|
|
86180
|
+
}
|
|
86181
|
+
function readVariableDeclaration(statement) {
|
|
86182
|
+
if (statement.type === "VariableDeclaration") {
|
|
86183
|
+
return statement;
|
|
86184
|
+
}
|
|
86185
|
+
if (statement.type === "ExportNamedDeclaration") {
|
|
86186
|
+
return statement.declaration;
|
|
86187
|
+
}
|
|
86188
|
+
return void 0;
|
|
86189
|
+
}
|
|
86190
|
+
function readUnboundIdentifierName(error3) {
|
|
86191
|
+
if (typeof error3 !== "object" || error3 === null || !("code" in error3) || error3.code !== "UNBOUND_IDENTIFIER") {
|
|
86192
|
+
return void 0;
|
|
86193
|
+
}
|
|
86194
|
+
const message2 = readErrorMessage2(error3);
|
|
86195
|
+
const prefix = "Identifier '";
|
|
86196
|
+
if (!message2.startsWith(prefix)) {
|
|
86197
|
+
return void 0;
|
|
86198
|
+
}
|
|
86199
|
+
const nameEnd = message2.indexOf("'", prefix.length);
|
|
86200
|
+
return nameEnd === -1 ? void 0 : message2.slice(prefix.length, nameEnd);
|
|
86201
|
+
}
|
|
85573
86202
|
function readErrorMessage2(error3) {
|
|
85574
86203
|
if (error3 instanceof Error) {
|
|
85575
86204
|
return error3.message;
|
|
@@ -85770,17 +86399,24 @@ async function runHarnessPair(mdPath, options) {
|
|
|
85770
86399
|
body
|
|
85771
86400
|
};
|
|
85772
86401
|
const snapshotPath = resolveSnapshotPath(pair.mdPath, options.snapshotPath);
|
|
86402
|
+
const shouldResume = options.resume ?? true;
|
|
86403
|
+
if (!shouldResume) {
|
|
86404
|
+
await cleanupCompletedSnapshot(snapshotPath);
|
|
86405
|
+
}
|
|
85773
86406
|
const hostCallReplay = await createHostCallReplay(snapshotPath);
|
|
85774
|
-
const modules = withSchemaModule(
|
|
86407
|
+
const modules = withSchemaModule(
|
|
86408
|
+
hostCallReplay.wrapModules(options.modulesFor(validated, meta))
|
|
86409
|
+
);
|
|
85775
86410
|
throwOnLintErrors([
|
|
85776
86411
|
...lint(ajsSource, {
|
|
85777
86412
|
allowedExportNames: ["schema"],
|
|
86413
|
+
allowedGlobals: options.allowedGlobals,
|
|
85778
86414
|
filename: pair.ajsPath,
|
|
85779
86415
|
modules: createLintModules(modules)
|
|
85780
86416
|
}),
|
|
85781
86417
|
...missingDefaultExportDiagnostics(ajsSource, pair.ajsPath)
|
|
85782
86418
|
]);
|
|
85783
|
-
const snapshot2 = await readSnapshot(snapshotPath);
|
|
86419
|
+
const snapshot2 = shouldResume ? await readSnapshot(snapshotPath) : void 0;
|
|
85784
86420
|
let result;
|
|
85785
86421
|
try {
|
|
85786
86422
|
result = await run(ajsSource, {
|
|
@@ -85825,7 +86461,9 @@ function throwOnLintErrors(diagnostics) {
|
|
|
85825
86461
|
}
|
|
85826
86462
|
function missingDefaultExportDiagnostics(source, filename) {
|
|
85827
86463
|
const module = parseModule(source, filename);
|
|
85828
|
-
const hasDefaultExport = module.body.some(
|
|
86464
|
+
const hasDefaultExport = module.body.some(
|
|
86465
|
+
(statement) => statement.type === "ExportDefaultDeclaration"
|
|
86466
|
+
);
|
|
85829
86467
|
if (hasDefaultExport) {
|
|
85830
86468
|
return [];
|
|
85831
86469
|
}
|
|
@@ -85985,7 +86623,9 @@ function isPromiseLike5(value) {
|
|
|
85985
86623
|
function createLintModules(modules) {
|
|
85986
86624
|
const entries = modules instanceof Map ? [...modules.entries()] : Object.entries(modules);
|
|
85987
86625
|
return new Map(
|
|
85988
|
-
entries.map(
|
|
86626
|
+
entries.map(
|
|
86627
|
+
([moduleName, moduleExports]) => [moduleName, listModuleExports(moduleExports)]
|
|
86628
|
+
)
|
|
85989
86629
|
);
|
|
85990
86630
|
}
|
|
85991
86631
|
function listModuleExports(moduleExports) {
|
|
@@ -86056,6 +86696,7 @@ import { fileURLToPath as fileURLToPath14 } from "node:url";
|
|
|
86056
86696
|
function listBuiltinTemplates() {
|
|
86057
86697
|
return [
|
|
86058
86698
|
template("ralph-demo"),
|
|
86699
|
+
template("coverage-demo"),
|
|
86059
86700
|
template("experiment-demo"),
|
|
86060
86701
|
template("pipeline-demo"),
|
|
86061
86702
|
template("superintendent-demo")
|
|
@@ -86094,7 +86735,7 @@ import path111 from "node:path";
|
|
|
86094
86735
|
import { readFile as readFile47 } from "node:fs/promises";
|
|
86095
86736
|
function registerHarnessCommand(program, container) {
|
|
86096
86737
|
const harness = program.command("harness").description("Run and manage agent harness pairs.");
|
|
86097
|
-
harness.command("run").description("Run a harness pair.").argument("[md-path]", "Path to the harness .md file").option("-y, --yes", "Accept defaults without prompting.").action(async (mdPath, options) => {
|
|
86738
|
+
harness.command("run").description("Run a harness pair.").argument("[md-path]", "Path to the harness .md file").option("--snapshot-path <path>", "File to write/read harness snapshots.").option("--resume", "Resume from the snapshot file when it exists.").option("-y, --yes", "Accept defaults without prompting.").action(async (mdPath, options) => {
|
|
86098
86739
|
await executeHarnessRun(program, container, mdPath, options);
|
|
86099
86740
|
});
|
|
86100
86741
|
harness.command("new").description("Scaffold a harness pair from a built-in template.").argument("<kind>", "Built-in template kind").argument("<basename>", "New harness basename").option("--dir <path>", "Output directory for the harness pair").option("-y, --yes", "Accept defaults without prompting.").action(async (kind, basename4, options) => {
|
|
@@ -86108,16 +86749,113 @@ async function executeHarnessRun(program, container, mdPath, options) {
|
|
|
86108
86749
|
const flags = resolveHarnessFlags(program, options.yes);
|
|
86109
86750
|
const resources = createExecutionResources(container, flags, "harness:run");
|
|
86110
86751
|
const selectedPath = mdPath ? path111.resolve(container.env.cwd, mdPath) : (await resolveDiscoveredHarness(container, flags.assumeYes)).mdPath;
|
|
86752
|
+
const snapshotPath = resolveRunSnapshotPath(container, selectedPath, options.snapshotPath);
|
|
86753
|
+
await prepareHarnessSnapshot(container, selectedPath, snapshotPath, Boolean(options.resume));
|
|
86111
86754
|
resources.logger.intro("harness run");
|
|
86755
|
+
const baseMessage = `Running ${formatDisplayPath2(container, selectedPath)}`;
|
|
86756
|
+
const progress = createSnapshotProgressReader(container, snapshotPath);
|
|
86112
86757
|
const result = await withSpinner({
|
|
86113
|
-
message:
|
|
86758
|
+
message: () => formatRunMessage(baseMessage, progress.current()),
|
|
86114
86759
|
fn: () => runHarnessPair(selectedPath, {
|
|
86115
|
-
modulesFor: (frontmatter, meta) => createHarnessModules(container, frontmatter, meta)
|
|
86760
|
+
modulesFor: (frontmatter, meta) => createHarnessModules(container, frontmatter, meta),
|
|
86761
|
+
resume: Boolean(options.resume),
|
|
86762
|
+
snapshotPath
|
|
86116
86763
|
}),
|
|
86117
86764
|
stopMessage: () => `Ran ${formatDisplayPath2(container, selectedPath)}`
|
|
86118
86765
|
});
|
|
86119
86766
|
resources.logger.info(JSON.stringify(result, null, 2));
|
|
86120
86767
|
}
|
|
86768
|
+
function resolveRunSnapshotPath(container, mdPath, snapshotPath) {
|
|
86769
|
+
if (snapshotPath !== void 0) {
|
|
86770
|
+
return path111.resolve(container.env.cwd, snapshotPath);
|
|
86771
|
+
}
|
|
86772
|
+
const basename4 = path111.basename(mdPath, path111.extname(mdPath));
|
|
86773
|
+
return path111.join(container.env.cwd, ".poe-code", "harnesses", basename4, "snapshot.json");
|
|
86774
|
+
}
|
|
86775
|
+
async function prepareHarnessSnapshot(container, mdPath, snapshotPath, resumeRequested) {
|
|
86776
|
+
const snapshotExists = await pathExists10(container, snapshotPath);
|
|
86777
|
+
if (!resumeRequested) {
|
|
86778
|
+
return;
|
|
86779
|
+
}
|
|
86780
|
+
if (!snapshotExists) {
|
|
86781
|
+
return;
|
|
86782
|
+
}
|
|
86783
|
+
const [snapshotSource, scriptSource] = await Promise.all([
|
|
86784
|
+
container.fs.readFile(snapshotPath, "utf8"),
|
|
86785
|
+
container.fs.readFile(resolveAjsPath(mdPath), "utf8")
|
|
86786
|
+
]);
|
|
86787
|
+
try {
|
|
86788
|
+
restore(JSON.parse(snapshotSource), { source: scriptSource });
|
|
86789
|
+
} catch (error3) {
|
|
86790
|
+
if (error3 instanceof Error && error3.message.includes("source changed since snapshot was taken")) {
|
|
86791
|
+
throw new ValidationError(
|
|
86792
|
+
`Cannot resume harness from ${formatDisplayPath2(container, snapshotPath)}: source changed since the snapshot was taken. The .ajs script was edited; start a fresh run without --resume to discard the old snapshot.`
|
|
86793
|
+
);
|
|
86794
|
+
}
|
|
86795
|
+
throw error3;
|
|
86796
|
+
}
|
|
86797
|
+
}
|
|
86798
|
+
function createSnapshotProgressReader(container, snapshotPath) {
|
|
86799
|
+
let progress;
|
|
86800
|
+
let lastReadStartedAt = 0;
|
|
86801
|
+
return {
|
|
86802
|
+
current() {
|
|
86803
|
+
const now = Date.now();
|
|
86804
|
+
if (now - lastReadStartedAt > 750) {
|
|
86805
|
+
lastReadStartedAt = now;
|
|
86806
|
+
void readSnapshotProgress(container, snapshotPath).then((next) => {
|
|
86807
|
+
if (next !== void 0) {
|
|
86808
|
+
progress = next;
|
|
86809
|
+
}
|
|
86810
|
+
});
|
|
86811
|
+
}
|
|
86812
|
+
return progress;
|
|
86813
|
+
}
|
|
86814
|
+
};
|
|
86815
|
+
}
|
|
86816
|
+
async function readSnapshotProgress(container, snapshotPath) {
|
|
86817
|
+
try {
|
|
86818
|
+
const parsed = JSON.parse(await container.fs.readFile(snapshotPath, "utf8"));
|
|
86819
|
+
const step2 = readSnapshotStep(parsed);
|
|
86820
|
+
return step2 === void 0 ? void 0 : `step ${step2}`;
|
|
86821
|
+
} catch {
|
|
86822
|
+
return void 0;
|
|
86823
|
+
}
|
|
86824
|
+
}
|
|
86825
|
+
function readSnapshotStep(snapshot2) {
|
|
86826
|
+
if (typeof snapshot2 !== "object" || snapshot2 === null) {
|
|
86827
|
+
return void 0;
|
|
86828
|
+
}
|
|
86829
|
+
const record = snapshot2;
|
|
86830
|
+
for (const key2 of ["step", "currentStep", "currentAstNodeId"]) {
|
|
86831
|
+
const value = record[key2];
|
|
86832
|
+
if (typeof value === "number" && Number.isFinite(value)) {
|
|
86833
|
+
return value;
|
|
86834
|
+
}
|
|
86835
|
+
}
|
|
86836
|
+
return void 0;
|
|
86837
|
+
}
|
|
86838
|
+
function formatRunMessage(baseMessage, progress) {
|
|
86839
|
+
return progress === void 0 ? baseMessage : `${baseMessage} (${progress})`;
|
|
86840
|
+
}
|
|
86841
|
+
function resolveAjsPath(mdPath) {
|
|
86842
|
+
const parsed = path111.parse(mdPath);
|
|
86843
|
+
return path111.join(parsed.dir, `${parsed.name}.ajs`);
|
|
86844
|
+
}
|
|
86845
|
+
async function pathExists10(container, targetPath) {
|
|
86846
|
+
try {
|
|
86847
|
+
await container.fs.stat(targetPath);
|
|
86848
|
+
return true;
|
|
86849
|
+
} catch (error3) {
|
|
86850
|
+
if (hasErrorCode7(error3, "ENOENT")) {
|
|
86851
|
+
return false;
|
|
86852
|
+
}
|
|
86853
|
+
throw error3;
|
|
86854
|
+
}
|
|
86855
|
+
}
|
|
86856
|
+
function hasErrorCode7(error3, code) {
|
|
86857
|
+
return typeof error3 === "object" && error3 !== null && "code" in error3 && error3.code === code;
|
|
86858
|
+
}
|
|
86121
86859
|
async function executeHarnessNew(program, container, kind, basename4, options) {
|
|
86122
86860
|
const flags = resolveHarnessFlags(program, options.yes);
|
|
86123
86861
|
const resources = createExecutionResources(container, flags, "harness:new");
|
|
@@ -86263,17 +87001,6 @@ async function assertFilesDoNotExist(container, filePaths) {
|
|
|
86263
87001
|
}
|
|
86264
87002
|
}
|
|
86265
87003
|
}
|
|
86266
|
-
async function pathExists10(container, filePath) {
|
|
86267
|
-
try {
|
|
86268
|
-
await container.fs.stat(filePath);
|
|
86269
|
-
return true;
|
|
86270
|
-
} catch (error3) {
|
|
86271
|
-
if (error3 && typeof error3 === "object" && "code" in error3 && error3.code === "ENOENT") {
|
|
86272
|
-
return false;
|
|
86273
|
-
}
|
|
86274
|
-
throw error3;
|
|
86275
|
-
}
|
|
86276
|
-
}
|
|
86277
87004
|
function createHarnessModules(container, frontmatter, meta) {
|
|
86278
87005
|
const harnessMeta = {
|
|
86279
87006
|
kind: meta.kind,
|
|
@@ -86688,7 +87415,7 @@ var init_package2 = __esm({
|
|
|
86688
87415
|
"package.json"() {
|
|
86689
87416
|
package_default2 = {
|
|
86690
87417
|
name: "poe-code",
|
|
86691
|
-
version: "3.0.
|
|
87418
|
+
version: "3.0.221",
|
|
86692
87419
|
description: "CLI tool to configure Poe API for developer workflows.",
|
|
86693
87420
|
type: "module",
|
|
86694
87421
|
main: "./dist/index.js",
|
|
@@ -86763,7 +87490,8 @@ var init_package2 = __esm({
|
|
|
86763
87490
|
"codegen:plan-schemas": "tsx scripts/generate-plan-schemas.ts",
|
|
86764
87491
|
"codegen:harness-schemas": "tsx scripts/generate-harness-schemas.ts",
|
|
86765
87492
|
"smoke:toolcraft-standalone": "node scripts/verify-toolcraft-standalone.mjs",
|
|
86766
|
-
"sync-skills": "tsx scripts/sync-skills.ts"
|
|
87493
|
+
"sync-skills": "tsx scripts/sync-skills.ts",
|
|
87494
|
+
postinstall: "node scripts/postinstall-sync-skills.mjs"
|
|
86767
87495
|
},
|
|
86768
87496
|
bin: {
|
|
86769
87497
|
poe: "dist/bin.cjs",
|
|
@@ -86784,6 +87512,7 @@ var init_package2 = __esm({
|
|
|
86784
87512
|
"packages/config-mutations/dist",
|
|
86785
87513
|
"packages/design-system/dist",
|
|
86786
87514
|
"packages/memory/dist",
|
|
87515
|
+
"scripts/postinstall-sync-skills.mjs",
|
|
86787
87516
|
"packages/superintendent/dist",
|
|
86788
87517
|
"packages/tiny-stdio-mcp-server/dist"
|
|
86789
87518
|
],
|