@agjs/tsforge 0.2.2 → 0.2.3

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@agjs/tsforge",
3
3
  "type": "module",
4
- "version": "0.2.2",
4
+ "version": "0.2.3",
5
5
  "license": "MIT",
6
6
  "description": "TypeScript coding harness with a deterministic gate, stack-aware guardrails, and stream-level correction.",
7
7
  "repository": {
@@ -12,7 +12,8 @@ export const FAILURE_CLASS = {
12
12
  none: "none",
13
13
  /** Model emitted tool calls the parser couldn't read (repair L3 / salvage). */
14
14
  toolMalformed: "tool-malformed",
15
- /** Edits kept missing their target (missing-file / not-found / ambiguous). */
15
+ /** Edits/tool calls were rejected — missing target (missing-file / not-found /
16
+ * ambiguous) or out-of-scope (the dispatcher's tool_rejected). */
16
17
  editReject: "edit-reject",
17
18
  /** Hit the turn cap or the gate stalled with no decisive error class. */
18
19
  noProgress: "no-progress",
@@ -44,6 +45,8 @@ export interface IFailureSignals {
44
45
  salvages: number;
45
46
  editRejects: number;
46
47
  degenerated: boolean;
48
+ timedOut: boolean;
49
+ toolUseFailed: boolean;
47
50
  tsErrors: number;
48
51
  lintErrors: number;
49
52
  missingModule: number;
@@ -60,10 +63,25 @@ export interface IFailureSummary {
60
63
 
61
64
  const TS_CODE = /^TS\d+$/;
62
65
  const MISSING_MODULE = /cannot find module/i;
63
- const DEGENERATE = /degenerat/i;
66
+ // The terminal degeneration stops say "repetition loop" (run.ts, session.ts) —
67
+ // NOT "degenerate". Match both the user-facing phrase and the internal term.
68
+ const DEGENERATE = /repetition loop|degenerat/i;
69
+ // Salvage telemetry on the tool channel ("recovered N malformed tool call(s)").
64
70
  const TOOL_MALFORMED = /salvage|recovered|malformed|re-ask/i;
71
+ // Terminal stops where the model never produced usable tool calls: the leaked
72
+ // malformed-tool-call stop and the narrate-instead-of-build stop (session.ts).
73
+ const TOOL_USE_FAILED =
74
+ /malformed tool-call|writing files as chat|instead of creating them/i;
75
+ // Edit/scope rejections surface on TWO channels: model-agent emits a `kind:"edit"`
76
+ // "<file> — rejected (<reason>)"; the tool dispatcher emits `kind:"tool"`
77
+ // "tool_rejected:" / "tool_input_rejected:". Both contain "reject".
65
78
  const REJECTED = /reject/i;
66
- const BROWSER = /blank|did not render|did not mount|page error|uncaught/i;
79
+ // The TERMINAL timeout stop ("timed out repeatedly … stopped"), NOT the transient
80
+ // per-turn re-steer ("timed out … re-steering (1/3)") — only the former ends a run.
81
+ const TIMED_OUT = /timed out repeatedly/i;
82
+ // The actual browser-oracle failure strings (oracle.ts): "rendered blank",
83
+ // "app did not mount", "console error:", "uncaught:", "route X failed to load".
84
+ const BROWSER = /blank|did not mount|console error|uncaught|failed to load/i;
67
85
  const ROUTE = /route|phantom|stub/i;
68
86
  const BUILD = /vite|esbuild|build failed|bundl/i;
69
87
 
@@ -146,10 +164,15 @@ function gatherSignals(
146
164
  salvages: events.filter(
147
165
  (e) => e.kind === "tool" && TOOL_MALFORMED.test(e.message)
148
166
  ).length,
167
+ // Rejections come on both the "edit" channel (model-agent) and the "tool"
168
+ // channel (dispatcher: tool_rejected / tool_input_rejected).
149
169
  editRejects: events.filter(
150
- (e) => e.kind === "edit" && REJECTED.test(e.message)
170
+ (e) =>
171
+ (e.kind === "edit" || e.kind === "tool") && REJECTED.test(e.message)
151
172
  ).length,
152
173
  degenerated: events.some((e) => DEGENERATE.test(e.message)),
174
+ timedOut: events.some((e) => TIMED_OUT.test(e.message)),
175
+ toolUseFailed: events.some((e) => TOOL_USE_FAILED.test(e.message)),
153
176
  tsErrors: rules.filter((r) => TS_CODE.test(r) && r !== "TS2307").length,
154
177
  lintErrors: rules.filter((r) => !TS_CODE.test(r)).length,
155
178
  missingModule,
@@ -203,11 +226,7 @@ function classifyGateErrors(
203
226
 
204
227
  /** Behavioral fallback when no gate-error class dominates. */
205
228
  function classifyBehavior(signals: IFailureSignals): FailureClass {
206
- if (signals.degenerated) {
207
- return FAILURE_CLASS.degeneration;
208
- }
209
-
210
- if (signals.salvages > 0 || signals.repairs > 0) {
229
+ if (signals.toolUseFailed || signals.salvages > 0 || signals.repairs > 0) {
211
230
  return FAILURE_CLASS.toolMalformed;
212
231
  }
213
232
 
@@ -234,6 +253,18 @@ export function classifyRun(
234
253
  return { failureClass: FAILURE_CLASS.none, signals };
235
254
  }
236
255
 
256
+ // A repeated request timeout is the terminal cause — the model couldn't even
257
+ // respond — so it outranks any stale gate error from an earlier turn.
258
+ if (signals.timedOut) {
259
+ return { failureClass: FAILURE_CLASS.timeout, signals };
260
+ }
261
+
262
+ // Likewise a repetition-loop stop: the run died because generation degenerated,
263
+ // not because of whatever the gate last reported.
264
+ if (signals.degenerated) {
265
+ return { failureClass: FAILURE_CLASS.degeneration, signals };
266
+ }
267
+
237
268
  if (signals.missingModule > 0) {
238
269
  return { failureClass: FAILURE_CLASS.hallucinatedImport, signals };
239
270
  }