@hexagen-monaco/sync 0.12.1 → 0.14.0
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 +729 -0
- package/dist/cli.js +7635 -516
- package/dist/cli.js.map +1 -1
- package/dist/commands/arch/edit.d.ts.map +1 -1
- package/dist/commands/contract/evaluate.d.ts +99 -0
- package/dist/commands/contract/evaluate.d.ts.map +1 -0
- package/dist/commands/contract/growth.d.ts +22 -0
- package/dist/commands/contract/growth.d.ts.map +1 -0
- package/dist/commands/contract/index.d.ts +32 -0
- package/dist/commands/contract/index.d.ts.map +1 -0
- package/dist/commands/evidence/check.d.ts +33 -0
- package/dist/commands/evidence/check.d.ts.map +1 -0
- package/dist/commands/evidence/index.d.ts +3 -0
- package/dist/commands/evidence/index.d.ts.map +1 -0
- package/dist/commands/evidence/pack.d.ts +41 -0
- package/dist/commands/evidence/pack.d.ts.map +1 -0
- package/dist/commands/evidence/verify.d.ts +83 -0
- package/dist/commands/evidence/verify.d.ts.map +1 -0
- package/dist/commands/grant/build.d.ts +53 -0
- package/dist/commands/grant/build.d.ts.map +1 -0
- package/dist/commands/grant/canonical.d.ts +27 -0
- package/dist/commands/grant/canonical.d.ts.map +1 -0
- package/dist/commands/grant/check.d.ts +26 -0
- package/dist/commands/grant/check.d.ts.map +1 -0
- package/dist/commands/grant/duration.d.ts +8 -0
- package/dist/commands/grant/duration.d.ts.map +1 -0
- package/dist/commands/grant/index.d.ts +2 -0
- package/dist/commands/grant/index.d.ts.map +1 -0
- package/dist/commands/grant/issue.d.ts +23 -0
- package/dist/commands/grant/issue.d.ts.map +1 -0
- package/dist/commands/grant/key-init.d.ts +16 -0
- package/dist/commands/grant/key-init.d.ts.map +1 -0
- package/dist/commands/grant/list.d.ts +72 -0
- package/dist/commands/grant/list.d.ts.map +1 -0
- package/dist/commands/grant/revoke.d.ts +35 -0
- package/dist/commands/grant/revoke.d.ts.map +1 -0
- package/dist/commands/grant/show.d.ts +18 -0
- package/dist/commands/grant/show.d.ts.map +1 -0
- package/dist/commands/grant/sign.d.ts +3 -0
- package/dist/commands/grant/sign.d.ts.map +1 -0
- package/dist/commands/grant/signing-key.d.ts +22 -0
- package/dist/commands/grant/signing-key.d.ts.map +1 -0
- package/dist/commands/grant/verify.d.ts +51 -0
- package/dist/commands/grant/verify.d.ts.map +1 -0
- package/dist/commands/grant/workspace.d.ts +11 -0
- package/dist/commands/grant/workspace.d.ts.map +1 -0
- package/dist/commands/observe/imports/jsonc.d.ts +6 -0
- package/dist/commands/observe/imports/jsonc.d.ts.map +1 -0
- package/dist/commands/observe/imports/pass.d.ts +45 -0
- package/dist/commands/observe/imports/pass.d.ts.map +1 -0
- package/dist/commands/observe/imports/resolve.d.ts +44 -0
- package/dist/commands/observe/imports/resolve.d.ts.map +1 -0
- package/dist/commands/observe/imports/safe-read.d.ts +30 -0
- package/dist/commands/observe/imports/safe-read.d.ts.map +1 -0
- package/dist/commands/observe/imports/scan.d.ts +59 -0
- package/dist/commands/observe/imports/scan.d.ts.map +1 -0
- package/dist/commands/observe/index.d.ts +59 -0
- package/dist/commands/observe/index.d.ts.map +1 -0
- package/dist/commands/observe/same-path.d.ts +9 -0
- package/dist/commands/observe/same-path.d.ts.map +1 -0
- package/dist/commands/observe/walk.d.ts +29 -0
- package/dist/commands/observe/walk.d.ts.map +1 -0
- package/dist/commands/report/exec-git.d.ts.map +1 -1
- package/dist/commands/shared/brownfield-sidecar.d.ts +98 -0
- package/dist/commands/shared/brownfield-sidecar.d.ts.map +1 -0
- package/dist/commands/shared/git-exclude.d.ts +36 -0
- package/dist/commands/shared/git-exclude.d.ts.map +1 -0
- package/dist/commands/shared/glob.d.ts +29 -0
- package/dist/commands/shared/glob.d.ts.map +1 -0
- package/dist/commands/shared/grant-enumerator.d.ts +32 -0
- package/dist/commands/shared/grant-enumerator.d.ts.map +1 -0
- package/dist/commands/shared/ignore.d.ts +32 -0
- package/dist/commands/shared/ignore.d.ts.map +1 -0
- package/dist/commands/shared/sidecar-out.d.ts +6 -0
- package/dist/commands/shared/sidecar-out.d.ts.map +1 -0
- package/dist/commands/shared/sidecar-write.d.ts +2 -0
- package/dist/commands/shared/sidecar-write.d.ts.map +1 -0
- package/dist/commands/slice/index.d.ts +23 -0
- package/dist/commands/slice/index.d.ts.map +1 -0
- package/dist/commands/workbook/allow-list.d.ts +27 -0
- package/dist/commands/workbook/allow-list.d.ts.map +1 -0
- package/dist/commands/workbook/export.d.ts +41 -0
- package/dist/commands/workbook/export.d.ts.map +1 -0
- package/dist/commands/workbook/index.d.ts +3 -0
- package/dist/commands/workbook/index.d.ts.map +1 -0
- package/dist/commands/workbook/zip-read.d.ts +7 -0
- package/dist/commands/workbook/zip-read.d.ts.map +1 -0
- package/dist/fs-utils.d.ts.map +1 -1
- package/dist/generators/root-file-templates.d.ts +5 -4
- package/dist/generators/root-file-templates.d.ts.map +1 -1
- package/dist/generators/root-files.d.ts.map +1 -1
- package/dist/index.js +367 -37
- package/dist/index.js.map +1 -1
- package/dist/templates/agents-md/findings/0001-session-log-grows-unbounded.md +35 -0
- package/dist/templates/ci-github-actions/findings/0001-ci-runners-have-no-zsh.md +34 -0
- package/dist/templates/orchestration/README.md +88 -0
- package/dist/templates/orchestration/files/.agents/skills/orchestrate-wave/SKILL.md +511 -0
- package/dist/templates/orchestration/files/.agents/skills/orchestrate-wave/references/briefs.md +178 -0
- package/dist/templates/orchestration/files/.agents/skills/orchestrate-wave/references/rationale.md +520 -0
- package/dist/templates/orchestration/files/.agents/skills/orchestrate-wave/scripts/wave-event.sh +17 -0
- package/dist/templates/orchestration/files/.github/workflows/gate.yml +66 -0
- package/dist/templates/orchestration/findings/0001-relative-runbook-links-escape-the-skill.md +48 -0
- package/dist/templates/orchestration/findings/0002-interpolation-hazard-in-graphql-line.md +46 -0
- package/dist/templates/orchestration/manifest.json +41 -0
- package/dist/types/manifest/monorepo.d.ts +5 -0
- package/dist/types/manifest/monorepo.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -378,6 +378,7 @@ var protectedFiles = /* @__PURE__ */ new Set([
|
|
|
378
378
|
".gitignore",
|
|
379
379
|
".yarnrc.yml",
|
|
380
380
|
"SETUP.md",
|
|
381
|
+
".prettierrc.json",
|
|
381
382
|
"package.json",
|
|
382
383
|
"tsconfig.base.json",
|
|
383
384
|
"turbo.json",
|
|
@@ -1316,6 +1317,217 @@ z.object({
|
|
|
1316
1317
|
error: z.string().nullable().optional()
|
|
1317
1318
|
}).passthrough();
|
|
1318
1319
|
|
|
1320
|
+
// ../shared/dist/types/brownfield/slice-path.js
|
|
1321
|
+
function hasControlCharacter(text) {
|
|
1322
|
+
for (let i = 0; i < text.length; i++) {
|
|
1323
|
+
const c = text.charCodeAt(i);
|
|
1324
|
+
if (c <= 31 || c === 127 || c === 8232 || c === 8233)
|
|
1325
|
+
return true;
|
|
1326
|
+
}
|
|
1327
|
+
return false;
|
|
1328
|
+
}
|
|
1329
|
+
function normalizeSlicePath(input) {
|
|
1330
|
+
if (input.length === 0)
|
|
1331
|
+
return { ok: false, reason: "empty path" };
|
|
1332
|
+
if (hasControlCharacter(input)) {
|
|
1333
|
+
return { ok: false, reason: "control character in path" };
|
|
1334
|
+
}
|
|
1335
|
+
if (input.includes("\\"))
|
|
1336
|
+
return { ok: false, reason: "backslash in path" };
|
|
1337
|
+
if (input.startsWith("/") || /^[A-Za-z]:/.test(input)) {
|
|
1338
|
+
return { ok: false, reason: "absolute path" };
|
|
1339
|
+
}
|
|
1340
|
+
const segments = input.split("/");
|
|
1341
|
+
const body = input.endsWith("/") ? segments.slice(0, -1) : segments;
|
|
1342
|
+
for (const segment of body) {
|
|
1343
|
+
if (segment === "")
|
|
1344
|
+
return { ok: false, reason: "empty path segment" };
|
|
1345
|
+
if (segment === "." || segment === "..") {
|
|
1346
|
+
return { ok: false, reason: `"${segment}" path segment` };
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
return { ok: true, path: input };
|
|
1350
|
+
}
|
|
1351
|
+
|
|
1352
|
+
// ../shared/dist/types/brownfield/common.js
|
|
1353
|
+
var SCHEMA_VERSION_PATTERN = "^1\\.\\d+\\.\\d+$";
|
|
1354
|
+
var SchemaVersion = z.string().regex(new RegExp(SCHEMA_VERSION_PATTERN), {
|
|
1355
|
+
message: "Unsupported schemaVersion; this consumer understands 1.x.y"
|
|
1356
|
+
});
|
|
1357
|
+
var SlicePathString = z.string().refine((p) => normalizeSlicePath(p).ok, {
|
|
1358
|
+
message: "invalid slice path"
|
|
1359
|
+
});
|
|
1360
|
+
var FilePathString = SlicePathString.refine((p) => !p.endsWith("/"), {
|
|
1361
|
+
message: "a file path must not end in /"
|
|
1362
|
+
});
|
|
1363
|
+
var Repo = z.object({
|
|
1364
|
+
remote: z.string().min(1).optional(),
|
|
1365
|
+
commit: z.string().min(1)
|
|
1366
|
+
}).strict();
|
|
1367
|
+
var Sha256Hex = z.string().regex(/^[0-9a-f]{64}$/);
|
|
1368
|
+
var IsoDateTime = z.string().datetime({ offset: true });
|
|
1369
|
+
function section(item) {
|
|
1370
|
+
return z.union([
|
|
1371
|
+
z.object({ collected: z.literal(true), items: z.array(item) }).strict(),
|
|
1372
|
+
z.object({ collected: z.literal(false), reason: z.string().min(1) }).strict()
|
|
1373
|
+
]);
|
|
1374
|
+
}
|
|
1375
|
+
var PackageItem = z.object({
|
|
1376
|
+
/** Exactly as written in the package manifest, scope included. */
|
|
1377
|
+
name: z.string().min(1),
|
|
1378
|
+
/** The literal "." is the repo root (a repo with no workspaces); else a directory path. */
|
|
1379
|
+
root: z.union([z.literal("."), SlicePathString]),
|
|
1380
|
+
manifestFile: FilePathString
|
|
1381
|
+
}).strict();
|
|
1382
|
+
var LanguageItem = z.object({ name: z.string().min(1), fileCount: z.number().int().min(0) }).strict();
|
|
1383
|
+
var BuildItem = z.object({ marker: z.string().min(1), path: FilePathString }).strict();
|
|
1384
|
+
var GeneratedItem = z.object({
|
|
1385
|
+
path: SlicePathString,
|
|
1386
|
+
source: z.enum(["linguist-generated", "header", "gitignored-build-dir"])
|
|
1387
|
+
}).strict();
|
|
1388
|
+
var DontTouchItem = z.object({
|
|
1389
|
+
path: SlicePathString,
|
|
1390
|
+
source: z.enum(["flag", "codeowners"]),
|
|
1391
|
+
owner: z.string().min(1).optional()
|
|
1392
|
+
}).strict();
|
|
1393
|
+
var EdgeItem = z.object({
|
|
1394
|
+
/** Repo-relative file. */
|
|
1395
|
+
from: FilePathString,
|
|
1396
|
+
/** Repo-relative file or package root; "." is a root package. */
|
|
1397
|
+
to: z.union([z.literal("."), SlicePathString]),
|
|
1398
|
+
specifier: z.string().min(1)
|
|
1399
|
+
}).strict();
|
|
1400
|
+
var UnresolvedItem = z.object({
|
|
1401
|
+
from: FilePathString,
|
|
1402
|
+
specifier: z.string().min(1),
|
|
1403
|
+
reason: z.string().min(1)
|
|
1404
|
+
}).strict();
|
|
1405
|
+
var EdgesSection = z.union([
|
|
1406
|
+
z.object({
|
|
1407
|
+
collected: z.literal(true),
|
|
1408
|
+
unreadLanguages: z.array(z.string().min(1)),
|
|
1409
|
+
items: z.array(EdgeItem)
|
|
1410
|
+
}).strict(),
|
|
1411
|
+
z.object({ collected: z.literal(false), reason: z.string().min(1) }).strict()
|
|
1412
|
+
]);
|
|
1413
|
+
var Limits = z.object({
|
|
1414
|
+
truncated: z.boolean(),
|
|
1415
|
+
reasons: z.array(z.string().min(1)),
|
|
1416
|
+
maxFiles: z.number().int().positive().optional()
|
|
1417
|
+
}).strict();
|
|
1418
|
+
z.object({
|
|
1419
|
+
schemaVersion: SchemaVersion,
|
|
1420
|
+
repo: Repo,
|
|
1421
|
+
generatedAt: IsoDateTime,
|
|
1422
|
+
packages: section(PackageItem),
|
|
1423
|
+
languages: section(LanguageItem),
|
|
1424
|
+
build: section(BuildItem),
|
|
1425
|
+
generated: section(GeneratedItem),
|
|
1426
|
+
dontTouch: section(DontTouchItem),
|
|
1427
|
+
edges: EdgesSection,
|
|
1428
|
+
unresolved: section(UnresolvedItem),
|
|
1429
|
+
limits: Limits
|
|
1430
|
+
}).strict();
|
|
1431
|
+
z.object({
|
|
1432
|
+
schemaVersion: SchemaVersion,
|
|
1433
|
+
id: z.string().min(1),
|
|
1434
|
+
repo: Repo,
|
|
1435
|
+
paths: z.array(SlicePathString),
|
|
1436
|
+
excludes: z.array(SlicePathString),
|
|
1437
|
+
createdBy: z.string().min(1),
|
|
1438
|
+
createdAt: IsoDateTime
|
|
1439
|
+
}).strict();
|
|
1440
|
+
var UNRESOLVED_IMPORT_RULE_ID = "unresolved-import";
|
|
1441
|
+
var BUILTIN_RULE_IDS = [UNRESOLVED_IMPORT_RULE_ID];
|
|
1442
|
+
var RuleId = z.string().min(1).refine((id) => !BUILTIN_RULE_IDS.includes(id), {
|
|
1443
|
+
message: "rule id is reserved for a built-in rule"
|
|
1444
|
+
});
|
|
1445
|
+
var RuleSeverity = z.enum(["error", "warn"]);
|
|
1446
|
+
var PrefixRule = z.object({
|
|
1447
|
+
id: RuleId,
|
|
1448
|
+
kind: z.enum(["forbid", "allow-only"]),
|
|
1449
|
+
from: SlicePathString,
|
|
1450
|
+
to: SlicePathString,
|
|
1451
|
+
severity: RuleSeverity
|
|
1452
|
+
}).strict();
|
|
1453
|
+
var ClosedRule = z.object({
|
|
1454
|
+
id: RuleId,
|
|
1455
|
+
kind: z.literal("closed"),
|
|
1456
|
+
except: z.array(SlicePathString),
|
|
1457
|
+
severity: RuleSeverity
|
|
1458
|
+
}).strict();
|
|
1459
|
+
var Rule = z.discriminatedUnion("kind", [PrefixRule, ClosedRule]);
|
|
1460
|
+
function isRealCalendarDate(text) {
|
|
1461
|
+
const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(text);
|
|
1462
|
+
if (!m)
|
|
1463
|
+
return false;
|
|
1464
|
+
const [y, mo, d] = [Number(m[1]), Number(m[2]), Number(m[3])];
|
|
1465
|
+
const utc = new Date(Date.UTC(y, mo - 1, d));
|
|
1466
|
+
return utc.getUTCFullYear() === y && utc.getUTCMonth() === mo - 1 && utc.getUTCDate() === d;
|
|
1467
|
+
}
|
|
1468
|
+
var KnownViolation = z.object({
|
|
1469
|
+
rule: z.string().min(1),
|
|
1470
|
+
file: FilePathString,
|
|
1471
|
+
specifier: z.string(),
|
|
1472
|
+
reason: z.string().min(1).optional(),
|
|
1473
|
+
expires: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional()
|
|
1474
|
+
}).strict().superRefine((k, ctx) => {
|
|
1475
|
+
if (k.expires !== void 0 && !isRealCalendarDate(k.expires)) {
|
|
1476
|
+
ctx.addIssue({
|
|
1477
|
+
code: "custom",
|
|
1478
|
+
path: ["expires"],
|
|
1479
|
+
message: `knownViolations entry ${k.rule} ${k.file} ${k.specifier}: 'expires' is not a real calendar date (${k.expires})`
|
|
1480
|
+
});
|
|
1481
|
+
}
|
|
1482
|
+
});
|
|
1483
|
+
z.object({
|
|
1484
|
+
schemaVersion: SchemaVersion,
|
|
1485
|
+
sliceId: z.string().min(1),
|
|
1486
|
+
rules: z.array(Rule),
|
|
1487
|
+
knownViolations: z.array(KnownViolation)
|
|
1488
|
+
}).strict();
|
|
1489
|
+
z.object({
|
|
1490
|
+
id: z.string().min(1),
|
|
1491
|
+
grantId: z.string().min(1),
|
|
1492
|
+
sliceId: z.string().min(1),
|
|
1493
|
+
tool: z.string().min(1),
|
|
1494
|
+
paths: z.array(FilePathString),
|
|
1495
|
+
/** The evidence line's seq; null when the trace is unchained (no seq). */
|
|
1496
|
+
traceSeq: z.number().int().min(0).nullable(),
|
|
1497
|
+
createdAt: IsoDateTime
|
|
1498
|
+
}).strict();
|
|
1499
|
+
var BUNDLE_FORBIDDEN_PATH_PATTERN = "(^|/)(grant-signing\\.key|[^/]*\\.key|keys|\\.env[^/]*)(/|$)";
|
|
1500
|
+
var forbidden = new RegExp(BUNDLE_FORBIDDEN_PATH_PATTERN);
|
|
1501
|
+
var BundlePath = FilePathString.refine((p) => !forbidden.test(p), {
|
|
1502
|
+
message: "key and env files are never part of a bundle"
|
|
1503
|
+
});
|
|
1504
|
+
var BUNDLE_FILE_ROLES = [
|
|
1505
|
+
"observed",
|
|
1506
|
+
"slice",
|
|
1507
|
+
"contract",
|
|
1508
|
+
"grant",
|
|
1509
|
+
"proposal",
|
|
1510
|
+
"evidence",
|
|
1511
|
+
"tip"
|
|
1512
|
+
];
|
|
1513
|
+
var BundleFile = z.object({
|
|
1514
|
+
path: BundlePath,
|
|
1515
|
+
role: z.enum(BUNDLE_FILE_ROLES),
|
|
1516
|
+
sha256: Sha256Hex
|
|
1517
|
+
}).strict();
|
|
1518
|
+
z.object({
|
|
1519
|
+
schemaVersion: SchemaVersion,
|
|
1520
|
+
createdAt: IsoDateTime,
|
|
1521
|
+
sliceId: z.string().min(1),
|
|
1522
|
+
files: z.array(BundleFile),
|
|
1523
|
+
hmac: Sha256Hex
|
|
1524
|
+
}).strict();
|
|
1525
|
+
z.object({
|
|
1526
|
+
seq: z.number().int().min(0),
|
|
1527
|
+
hash: Sha256Hex,
|
|
1528
|
+
hmac: Sha256Hex
|
|
1529
|
+
}).strict();
|
|
1530
|
+
|
|
1319
1531
|
// src/generators/root-file-templates.ts
|
|
1320
1532
|
var BUILTIN_PACKAGE_JSON_TEMPLATE = `{
|
|
1321
1533
|
"name": "{system}",
|
|
@@ -1337,17 +1549,18 @@ var BUILTIN_PACKAGE_JSON_TEMPLATE = `{
|
|
|
1337
1549
|
"lint:arch": "hexagen arch validate",
|
|
1338
1550
|
"templates:add": "hexagen add",
|
|
1339
1551
|
"templates:validate": "hexagen validate-templates",
|
|
1340
|
-
"format": "prettier --write \\"**/*.{ts,tsx
|
|
1552
|
+
"format": "prettier --write \\"**/*.{ts,tsx}\\""
|
|
1341
1553
|
},
|
|
1342
1554
|
"devDependencies": {
|
|
1343
|
-
"turbo": "^2.
|
|
1555
|
+
"turbo": "^2.11.5",
|
|
1344
1556
|
"typescript": "^5.5.4",
|
|
1345
1557
|
"eslint": "^9.0.0",
|
|
1346
1558
|
"prettier": "^3.0.0",
|
|
1347
1559
|
"@hexagen-monaco/sync": "^{toolchainVersion}",
|
|
1348
1560
|
"@hexagen-monaco/arch-linter": "^{toolchainVersion}"
|
|
1349
1561
|
}
|
|
1350
|
-
}
|
|
1562
|
+
}
|
|
1563
|
+
`;
|
|
1351
1564
|
var BUILTIN_TSCONFIG_BASE_TEMPLATE = `{
|
|
1352
1565
|
"compilerOptions": {
|
|
1353
1566
|
"target": "ES2022",
|
|
@@ -1359,46 +1572,37 @@ var BUILTIN_TSCONFIG_BASE_TEMPLATE = `{
|
|
|
1359
1572
|
"declaration": true,
|
|
1360
1573
|
"emitDeclarationOnly": true,
|
|
1361
1574
|
"paths": {
|
|
1362
|
-
"@{scope}/*": [
|
|
1363
|
-
"./packages/*/src/index.ts"
|
|
1364
|
-
]
|
|
1575
|
+
"@{scope}/*": ["./packages/*/src/index.ts"]
|
|
1365
1576
|
}
|
|
1366
1577
|
}
|
|
1367
|
-
}
|
|
1578
|
+
}
|
|
1579
|
+
`;
|
|
1368
1580
|
var BUILTIN_TURBO_TEMPLATE = `{
|
|
1369
1581
|
"$schema": "https://turbo.build/schema.json",
|
|
1582
|
+
"agentGuidance": false,
|
|
1370
1583
|
"tasks": {
|
|
1371
1584
|
"build": {
|
|
1372
|
-
"dependsOn": [
|
|
1373
|
-
|
|
1374
|
-
],
|
|
1375
|
-
"outputs": [
|
|
1376
|
-
"dist/**"
|
|
1377
|
-
]
|
|
1585
|
+
"dependsOn": ["^build"],
|
|
1586
|
+
"outputs": ["dist/**"]
|
|
1378
1587
|
},
|
|
1379
1588
|
"dev": {
|
|
1380
1589
|
"cache": false,
|
|
1381
1590
|
"persistent": true
|
|
1382
1591
|
},
|
|
1383
1592
|
"lint": {
|
|
1384
|
-
"dependsOn": [
|
|
1385
|
-
"^build"
|
|
1386
|
-
]
|
|
1593
|
+
"dependsOn": ["^build"]
|
|
1387
1594
|
},
|
|
1388
1595
|
"typecheck": {
|
|
1389
|
-
"dependsOn": [
|
|
1390
|
-
"^build"
|
|
1391
|
-
],
|
|
1596
|
+
"dependsOn": ["^build"],
|
|
1392
1597
|
"outputs": [],
|
|
1393
1598
|
"cache": true
|
|
1394
1599
|
},
|
|
1395
1600
|
"test": {
|
|
1396
|
-
"dependsOn": [
|
|
1397
|
-
"^build"
|
|
1398
|
-
]
|
|
1601
|
+
"dependsOn": ["^build"]
|
|
1399
1602
|
}
|
|
1400
1603
|
}
|
|
1401
|
-
}
|
|
1604
|
+
}
|
|
1605
|
+
`;
|
|
1402
1606
|
var BUILTIN_GITIGNORE_TEMPLATE = `# Dependencies
|
|
1403
1607
|
node_modules/
|
|
1404
1608
|
.yarn/cache
|
|
@@ -1466,6 +1670,17 @@ adding \`--immutable\` to the \`yarn install\` step in
|
|
|
1466
1670
|
Its pre-lockfile guidance goes stale once \`yarn.lock\` is committed. (Run
|
|
1467
1671
|
\`hexagen sync\` won't bring it back — it's a protected root file.)
|
|
1468
1672
|
`;
|
|
1673
|
+
var BUILTIN_PRETTIERRC_TEMPLATE = `{
|
|
1674
|
+
"semi": true,
|
|
1675
|
+
"singleQuote": false,
|
|
1676
|
+
"trailingComma": "all",
|
|
1677
|
+
"printWidth": 80,
|
|
1678
|
+
"tabWidth": 2,
|
|
1679
|
+
"arrowParens": "always",
|
|
1680
|
+
"endOfLine": "lf",
|
|
1681
|
+
"objectWrap": "preserve"
|
|
1682
|
+
}
|
|
1683
|
+
`;
|
|
1469
1684
|
var SEMVER_2_0_0 = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
|
|
1470
1685
|
function assertValidToolchainVersion(version, source) {
|
|
1471
1686
|
const invalid = !SEMVER_2_0_0.test(version) || /^0\.0\.0(?:$|[-+])/.test(version);
|
|
@@ -1479,13 +1694,74 @@ function assertValidToolchainVersion(version, source) {
|
|
|
1479
1694
|
function resolveToolchainVersion() {
|
|
1480
1695
|
{
|
|
1481
1696
|
return assertValidToolchainVersion(
|
|
1482
|
-
"0.
|
|
1697
|
+
"0.14.0",
|
|
1483
1698
|
"build-injected __HEXAGEN_TOOLCHAIN_VERSION__"
|
|
1484
1699
|
);
|
|
1485
1700
|
}
|
|
1486
1701
|
}
|
|
1487
1702
|
|
|
1488
1703
|
// src/generators/root-files.ts
|
|
1704
|
+
var DEFAULT_PRETTIER_PRINT_WIDTH = 80;
|
|
1705
|
+
var DEFAULT_PRETTIER_TAB_WIDTH = 2;
|
|
1706
|
+
function resolveEffectivePrettierOptions(prettierrcContent, logger) {
|
|
1707
|
+
try {
|
|
1708
|
+
const parsed = JSON.parse(prettierrcContent);
|
|
1709
|
+
const printWidth = typeof parsed.printWidth === "number" && parsed.printWidth > 0 ? parsed.printWidth : DEFAULT_PRETTIER_PRINT_WIDTH;
|
|
1710
|
+
const tabWidth = typeof parsed.tabWidth === "number" && parsed.tabWidth > 0 ? parsed.tabWidth : DEFAULT_PRETTIER_TAB_WIDTH;
|
|
1711
|
+
return { printWidth, tabWidth };
|
|
1712
|
+
} catch {
|
|
1713
|
+
logger.debug(
|
|
1714
|
+
"root-files: .prettierrc.json content is not valid JSON — falling back to Prettier's own defaults (printWidth 80, tabWidth 2) when deciding the generator's own JSON array formatting"
|
|
1715
|
+
);
|
|
1716
|
+
return {
|
|
1717
|
+
printWidth: DEFAULT_PRETTIER_PRINT_WIDTH,
|
|
1718
|
+
tabWidth: DEFAULT_PRETTIER_TAB_WIDTH
|
|
1719
|
+
};
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
function reindentJson(text, tabWidth) {
|
|
1723
|
+
if (tabWidth === 2) return text;
|
|
1724
|
+
return text.replace(
|
|
1725
|
+
/^( +)/gm,
|
|
1726
|
+
(spaces) => " ".repeat(Math.round(spaces.length / 2) * tabWidth)
|
|
1727
|
+
);
|
|
1728
|
+
}
|
|
1729
|
+
function formatJsonArray(items, indent, linePrefix, printWidth, tabWidth, hasTrailingComma) {
|
|
1730
|
+
const rendered = items.map((item) => JSON.stringify(item));
|
|
1731
|
+
const inline = `[${rendered.join(", ")}]`;
|
|
1732
|
+
const commaWidth = hasTrailingComma ? 1 : 0;
|
|
1733
|
+
if (linePrefix.length + inline.length + commaWidth <= printWidth) {
|
|
1734
|
+
return inline;
|
|
1735
|
+
}
|
|
1736
|
+
const inner = rendered.map((r) => `${" ".repeat(indent + tabWidth)}${r}`).join(",\n");
|
|
1737
|
+
return `[
|
|
1738
|
+
${inner}
|
|
1739
|
+
${" ".repeat(indent)}]`;
|
|
1740
|
+
}
|
|
1741
|
+
var TURBO_COLLAPSIBLE_ARRAY_FIELDS = [
|
|
1742
|
+
"dependsOn",
|
|
1743
|
+
"outputs",
|
|
1744
|
+
"inputs",
|
|
1745
|
+
"env",
|
|
1746
|
+
"passThroughEnv",
|
|
1747
|
+
"globalDependencies"
|
|
1748
|
+
];
|
|
1749
|
+
function collapseShortJsonArrays(json, printWidth, tabWidth) {
|
|
1750
|
+
const fieldPattern = TURBO_COLLAPSIBLE_ARRAY_FIELDS.join("|");
|
|
1751
|
+
const re = new RegExp(
|
|
1752
|
+
`^([ \\t]*)"(${fieldPattern})": \\[\\n([\\s\\S]*?)\\n\\1\\](,?)`,
|
|
1753
|
+
"gm"
|
|
1754
|
+
);
|
|
1755
|
+
return json.replace(
|
|
1756
|
+
re,
|
|
1757
|
+
(_match, indent, field, body, trailingComma) => {
|
|
1758
|
+
const items = body.split(",\n").map((line) => JSON.parse(line.trim()));
|
|
1759
|
+
const linePrefix = `${indent}"${field}": `;
|
|
1760
|
+
const hasTrailingComma = trailingComma === ",";
|
|
1761
|
+
return `${linePrefix}${formatJsonArray(items, indent.length, linePrefix, printWidth, tabWidth, hasTrailingComma)}${trailingComma}`;
|
|
1762
|
+
}
|
|
1763
|
+
);
|
|
1764
|
+
}
|
|
1489
1765
|
function buildVars(manifest, toolchainVersion) {
|
|
1490
1766
|
const system = typeof manifest.system === "string" && manifest.system.length > 0 ? manifest.system : "generated-project";
|
|
1491
1767
|
const scope = resolveScope(manifest);
|
|
@@ -1511,7 +1787,7 @@ function frameworkBuildOutputs(manifest) {
|
|
|
1511
1787
|
}
|
|
1512
1788
|
return extras;
|
|
1513
1789
|
}
|
|
1514
|
-
function buildTurboContentFromConfig(manifest) {
|
|
1790
|
+
function buildTurboContentFromConfig(manifest, prettierOptions) {
|
|
1515
1791
|
const turboConfig = manifest.monorepo?.turboConfig ?? {};
|
|
1516
1792
|
const builtin = JSON.parse(BUILTIN_TURBO_TEMPLATE);
|
|
1517
1793
|
const tasks = { ...builtin.tasks };
|
|
@@ -1531,10 +1807,19 @@ function buildTurboContentFromConfig(manifest) {
|
|
|
1531
1807
|
const globalDependencies = turboConfig.globalDependencies ?? [];
|
|
1532
1808
|
const doc = {
|
|
1533
1809
|
$schema: builtin.$schema,
|
|
1810
|
+
// The opt-out the built-in template also carries (see its comment). Only a
|
|
1811
|
+
// manifest that states the key wins — an absent or non-boolean value keeps
|
|
1812
|
+
// the safe default rather than emitting turbo's own agent-rules block into
|
|
1813
|
+
// a project whose tree the generator owns.
|
|
1814
|
+
agentGuidance: typeof turboConfig.agentGuidance === "boolean" ? turboConfig.agentGuidance : false,
|
|
1534
1815
|
...globalDependencies.length > 0 ? { globalDependencies } : {},
|
|
1535
1816
|
tasks
|
|
1536
1817
|
};
|
|
1537
|
-
return
|
|
1818
|
+
return collapseShortJsonArrays(
|
|
1819
|
+
JSON.stringify(doc, null, prettierOptions.tabWidth),
|
|
1820
|
+
prettierOptions.printWidth,
|
|
1821
|
+
prettierOptions.tabWidth
|
|
1822
|
+
) + "\n";
|
|
1538
1823
|
}
|
|
1539
1824
|
function interpolateAndWarn(template, vars, config, fileLabel) {
|
|
1540
1825
|
const { output, warnings } = interpolate(template, vars);
|
|
@@ -1562,16 +1847,37 @@ async function generateRootFiles(config, report) {
|
|
|
1562
1847
|
try {
|
|
1563
1848
|
const rootFiles = config.manifest.monorepo?.rootFiles;
|
|
1564
1849
|
const vars = buildVars(config.manifest, toolchainVersion);
|
|
1850
|
+
const prettierrcTemplate = resolveTemplate(
|
|
1851
|
+
rootFiles?.prettierrc?.template,
|
|
1852
|
+
BUILTIN_PRETTIERRC_TEMPLATE
|
|
1853
|
+
);
|
|
1854
|
+
const prettierrcContent = interpolateAndWarn(
|
|
1855
|
+
prettierrcTemplate,
|
|
1856
|
+
vars,
|
|
1857
|
+
config,
|
|
1858
|
+
".prettierrc.json"
|
|
1859
|
+
);
|
|
1860
|
+
const prettierOptions = resolveEffectivePrettierOptions(
|
|
1861
|
+
prettierrcContent,
|
|
1862
|
+
config.logger
|
|
1863
|
+
);
|
|
1864
|
+
const usingBuiltinPackageJson = !rootFiles?.packageJson?.template;
|
|
1565
1865
|
const packageJsonTemplate = resolveTemplate(
|
|
1566
1866
|
rootFiles?.packageJson?.template,
|
|
1567
1867
|
BUILTIN_PACKAGE_JSON_TEMPLATE
|
|
1568
1868
|
);
|
|
1569
|
-
|
|
1869
|
+
let packageJsonContent = interpolateAndWarn(
|
|
1570
1870
|
packageJsonTemplate,
|
|
1571
1871
|
vars,
|
|
1572
1872
|
config,
|
|
1573
1873
|
"package.json"
|
|
1574
1874
|
);
|
|
1875
|
+
if (usingBuiltinPackageJson) {
|
|
1876
|
+
packageJsonContent = reindentJson(
|
|
1877
|
+
packageJsonContent,
|
|
1878
|
+
prettierOptions.tabWidth
|
|
1879
|
+
);
|
|
1880
|
+
}
|
|
1575
1881
|
await writeRootFile(
|
|
1576
1882
|
path7.join(config.workspaceRoot, "package.json"),
|
|
1577
1883
|
packageJsonContent,
|
|
@@ -1579,16 +1885,20 @@ async function generateRootFiles(config, report) {
|
|
|
1579
1885
|
report,
|
|
1580
1886
|
result
|
|
1581
1887
|
);
|
|
1888
|
+
const usingBuiltinTsconfig = !rootFiles?.tsConfig?.template;
|
|
1582
1889
|
const tsconfigTemplate = resolveTemplate(
|
|
1583
1890
|
rootFiles?.tsConfig?.template,
|
|
1584
1891
|
BUILTIN_TSCONFIG_BASE_TEMPLATE
|
|
1585
1892
|
);
|
|
1586
|
-
|
|
1893
|
+
let tsconfigContent = interpolateAndWarn(
|
|
1587
1894
|
tsconfigTemplate,
|
|
1588
1895
|
vars,
|
|
1589
1896
|
config,
|
|
1590
1897
|
"tsconfig.base.json"
|
|
1591
1898
|
);
|
|
1899
|
+
if (usingBuiltinTsconfig) {
|
|
1900
|
+
tsconfigContent = reindentJson(tsconfigContent, prettierOptions.tabWidth);
|
|
1901
|
+
}
|
|
1592
1902
|
await writeRootFile(
|
|
1593
1903
|
path7.join(config.workspaceRoot, "tsconfig.base.json"),
|
|
1594
1904
|
tsconfigContent,
|
|
@@ -1598,12 +1908,25 @@ async function generateRootFiles(config, report) {
|
|
|
1598
1908
|
);
|
|
1599
1909
|
const explicitTurboTemplate = rootFiles?.turbo?.template;
|
|
1600
1910
|
const hasExplicitTurboTemplate = typeof explicitTurboTemplate === "string" && explicitTurboTemplate.length > 0;
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1911
|
+
let turboContent;
|
|
1912
|
+
if (!hasExplicitTurboTemplate && config.manifest.monorepo?.turboConfig) {
|
|
1913
|
+
turboContent = buildTurboContentFromConfig(
|
|
1914
|
+
config.manifest,
|
|
1915
|
+
prettierOptions
|
|
1916
|
+
);
|
|
1917
|
+
} else if (!hasExplicitTurboTemplate) {
|
|
1918
|
+
turboContent = reindentJson(
|
|
1919
|
+
interpolateAndWarn(BUILTIN_TURBO_TEMPLATE, vars, config, "turbo.json"),
|
|
1920
|
+
prettierOptions.tabWidth
|
|
1921
|
+
);
|
|
1922
|
+
} else {
|
|
1923
|
+
turboContent = interpolateAndWarn(
|
|
1924
|
+
explicitTurboTemplate,
|
|
1925
|
+
vars,
|
|
1926
|
+
config,
|
|
1927
|
+
"turbo.json"
|
|
1928
|
+
);
|
|
1929
|
+
}
|
|
1607
1930
|
await writeRootFile(
|
|
1608
1931
|
path7.join(config.workspaceRoot, "turbo.json"),
|
|
1609
1932
|
turboContent,
|
|
@@ -1644,6 +1967,13 @@ async function generateRootFiles(config, report) {
|
|
|
1644
1967
|
report,
|
|
1645
1968
|
result
|
|
1646
1969
|
);
|
|
1970
|
+
await writeRootFile(
|
|
1971
|
+
path7.join(config.workspaceRoot, ".prettierrc.json"),
|
|
1972
|
+
prettierrcContent,
|
|
1973
|
+
config,
|
|
1974
|
+
report,
|
|
1975
|
+
result
|
|
1976
|
+
);
|
|
1647
1977
|
return result;
|
|
1648
1978
|
} catch (err3) {
|
|
1649
1979
|
const message = err3 instanceof Error ? err3.message : String(err3);
|
|
@@ -2150,12 +2480,12 @@ var FASTIFY_TSCONFIG = {
|
|
|
2150
2480
|
exclude: ["node_modules", "dist"]
|
|
2151
2481
|
};
|
|
2152
2482
|
var FASTIFY_ENTRY_TEMPLATE = `// Auto-generated Fastify application
|
|
2153
|
-
import fastify from
|
|
2483
|
+
import fastify from "fastify";
|
|
2154
2484
|
|
|
2155
2485
|
const server = fastify();
|
|
2156
2486
|
|
|
2157
|
-
server.get(
|
|
2158
|
-
return { status:
|
|
2487
|
+
server.get("/", async () => {
|
|
2488
|
+
return { status: "ok" };
|
|
2159
2489
|
});
|
|
2160
2490
|
|
|
2161
2491
|
export default server;
|