@agjs/tsforge 0.2.1 → 0.2.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.
- package/package.json +1 -1
- package/scripts/sweep.ts +11 -6
- package/src/cli.ts +2 -1
- package/src/detect-gate.ts +16 -0
- package/strict.eslint.config.mjs +24 -1
package/package.json
CHANGED
package/scripts/sweep.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { mkdir, readdir, rm, stat } from "node:fs/promises";
|
|
7
7
|
import { join } from "node:path";
|
|
8
8
|
import { parseSpec } from "../src/spec";
|
|
9
|
-
import { buildGate,
|
|
9
|
+
import { buildGate, buildCoreFix } from "../src/detect-gate";
|
|
10
10
|
import { runSpec, qualityRepair } from "../src/loop";
|
|
11
11
|
import { modelAgent } from "../src/agent";
|
|
12
12
|
import { OpenAICompatibleProvider } from "../src/inference";
|
|
@@ -258,17 +258,22 @@ async function runOne(
|
|
|
258
258
|
// (an unguarded index access, an `as any`) slipped through as GREEN. Now
|
|
259
259
|
// every task and the whole-spec verify must clear the strict floor BEFORE
|
|
260
260
|
// its functional tests count.
|
|
261
|
-
//
|
|
262
|
-
//
|
|
263
|
-
|
|
261
|
+
// buildCoreFix (eslint --fix + prettier) runs as task.fix before each gate
|
|
262
|
+
// check — same janitor as the interactive CLI — so padding-line, prefer-const,
|
|
263
|
+
// etc. are squashed without model turns.
|
|
264
|
+
const gateCommand = (await buildGate(runDir)).command;
|
|
265
|
+
const fixCommand = buildCoreFix();
|
|
264
266
|
const gatedSpec = {
|
|
265
267
|
...spec,
|
|
266
268
|
tasks: spec.tasks.map((t) => ({
|
|
267
269
|
...t,
|
|
268
|
-
|
|
270
|
+
fix: fixCommand,
|
|
271
|
+
accept: `${gateCommand} && ${t.accept}`,
|
|
269
272
|
})),
|
|
270
273
|
verify:
|
|
271
|
-
spec.verify.length > 0
|
|
274
|
+
spec.verify.length > 0
|
|
275
|
+
? `${gateCommand} && ${spec.verify}`
|
|
276
|
+
: gateCommand,
|
|
272
277
|
};
|
|
273
278
|
|
|
274
279
|
// Every run gets a full transcript at <runDir>/run.log; stream to the
|
package/src/cli.ts
CHANGED
|
@@ -38,6 +38,7 @@ import {
|
|
|
38
38
|
buildGate,
|
|
39
39
|
buildWebGate,
|
|
40
40
|
buildWebFix,
|
|
41
|
+
buildCoreFix,
|
|
41
42
|
buildWebTypeGate,
|
|
42
43
|
buildWebTscCheck,
|
|
43
44
|
scaffoldWeb,
|
|
@@ -903,7 +904,7 @@ async function repl(args: ICliArgs): Promise<number> {
|
|
|
903
904
|
fix: buildWebFix("react"),
|
|
904
905
|
incrementalCheck: buildWebTscCheck(),
|
|
905
906
|
}
|
|
906
|
-
: { scaffoldWeb: true }),
|
|
907
|
+
: { scaffoldWeb: true, fix: buildCoreFix() }),
|
|
907
908
|
...(thinkingTokenBudget === undefined ? {} : { thinkingTokenBudget }),
|
|
908
909
|
...(autoCompactAt === undefined ? {} : { autoCompactAt }),
|
|
909
910
|
// Thinking OFF for interactive replies so they STREAM immediately instead of
|
package/src/detect-gate.ts
CHANGED
|
@@ -462,6 +462,22 @@ export function buildWebFix(framework: WebFramework): string {
|
|
|
462
462
|
return `${lintFix} ; ${format}`;
|
|
463
463
|
}
|
|
464
464
|
|
|
465
|
+
/**
|
|
466
|
+
* The core (non-web) auto-fix command — same janitor as buildWebFix but uses the
|
|
467
|
+
* bundled strict.eslint.config.mjs. Run BEFORE the gate each cycle so padding-line,
|
|
468
|
+
* prefer-const, curly, etc. are squashed without model turns.
|
|
469
|
+
*/
|
|
470
|
+
export function buildCoreFix(): string {
|
|
471
|
+
const lintFix =
|
|
472
|
+
`"${ESLINT_BIN}" --no-config-lookup -c "${STRICT_CONFIG}" --fix .`.replace(
|
|
473
|
+
/\s+/g,
|
|
474
|
+
" "
|
|
475
|
+
);
|
|
476
|
+
const format = `"${PRETTIER_BIN}" --write .`;
|
|
477
|
+
|
|
478
|
+
return `${lintFix} ; ${format}`;
|
|
479
|
+
}
|
|
480
|
+
|
|
465
481
|
async function ensureFile(
|
|
466
482
|
cwd: string,
|
|
467
483
|
name: string,
|
package/strict.eslint.config.mjs
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
// Rule overrides are loaded via TSFORGE_RULE_OVERRIDES env var (JSON-encoded
|
|
13
13
|
// map of bare rule names to "error" | "warn" | "off").
|
|
14
14
|
import tseslint from "typescript-eslint";
|
|
15
|
+
import stylistic from "@stylistic/eslint-plugin";
|
|
15
16
|
|
|
16
17
|
// Load stack-aware packs if TSFORGE_PACKS env var is set
|
|
17
18
|
let packConfig = [];
|
|
@@ -52,7 +53,10 @@ export default tseslint.config(
|
|
|
52
53
|
{
|
|
53
54
|
files: ["**/*.ts", "**/*.tsx"],
|
|
54
55
|
languageOptions: { parser: tseslint.parser },
|
|
55
|
-
plugins: {
|
|
56
|
+
plugins: {
|
|
57
|
+
"@typescript-eslint": tseslint.plugin,
|
|
58
|
+
"@stylistic": stylistic,
|
|
59
|
+
},
|
|
56
60
|
rules: {
|
|
57
61
|
// The idioms the model habitually violates — all caught WITHOUT type info.
|
|
58
62
|
"@typescript-eslint/consistent-type-assertions": [
|
|
@@ -69,6 +73,25 @@ export default tseslint.config(
|
|
|
69
73
|
"prefer-const": "error",
|
|
70
74
|
"prefer-template": "error",
|
|
71
75
|
"no-var": "error",
|
|
76
|
+
// Blank-line discipline — the model rarely gets spacing right, so
|
|
77
|
+
// eslint --fix + prettier make it free. Uses @stylistic (the rule's
|
|
78
|
+
// maintained home; the core rule is deprecated and spams usedDeprecatedRules
|
|
79
|
+
// into eslint's --format json gate output).
|
|
80
|
+
"@stylistic/padding-line-between-statements": [
|
|
81
|
+
"error",
|
|
82
|
+
{ blankLine: "always", prev: "import", next: "*" },
|
|
83
|
+
{ blankLine: "any", prev: "import", next: "import" },
|
|
84
|
+
{ blankLine: "always", prev: "*", next: "return" },
|
|
85
|
+
{ blankLine: "always", prev: "*", next: "throw" },
|
|
86
|
+
{ blankLine: "always", prev: ["const", "let", "var"], next: "*" },
|
|
87
|
+
{
|
|
88
|
+
blankLine: "any",
|
|
89
|
+
prev: ["const", "let", "var"],
|
|
90
|
+
next: ["const", "let", "var"],
|
|
91
|
+
},
|
|
92
|
+
{ blankLine: "always", prev: "block-like", next: "*" },
|
|
93
|
+
{ blankLine: "always", prev: "*", next: "block-like" },
|
|
94
|
+
],
|
|
72
95
|
eqeqeq: ["error", "always"],
|
|
73
96
|
curly: ["error", "all"],
|
|
74
97
|
"no-restricted-syntax": [
|