@elvis1513/auto-coding-skill 4.2.3 → 4.2.5
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 +16 -1
- package/cli/assets/managed-install.json +1 -1
- package/cli/assets/skill/data/policies/workflow-migrations-v1.json +2 -2
- package/cli/assets/skill/data/templates/ENGINEERING.md +2 -2
- package/cli/assets/skill/data/templates/bridges/AGENTS.md +1 -1
- package/cli/assets/skill/scripts/ap.py +316 -59
- package/cli/tests/ap_profiles_test.py +471 -0
- package/cli/tests/index.test.js +15 -15
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,7 +9,9 @@ The Skill is a selectable guardrail, not a command sequence that must run for
|
|
|
9
9
|
every task. The model skips machinery whose expected benefit does not exceed its
|
|
10
10
|
cost; read-only work and obvious small clean-checkout changes normally stay direct.
|
|
11
11
|
|
|
12
|
-
Version 4.2.
|
|
12
|
+
Version 4.2.5 keeps JSX self-closing and closing-tag slashes out of regex state.
|
|
13
|
+
Version 4.2.4 fixes TypeScript function-body detection after an explicit return
|
|
14
|
+
type. Version 4.2.3 restores an explicit opt-in strict size-warning policy without
|
|
13
15
|
changing the default, makes semicolon-terminated Java/Kotlin imports visible to
|
|
14
16
|
project layer rules, and hardens function-range detection. Version 4.2.2 preserves
|
|
15
17
|
project-owned risk and structure policy during upgrades, restores explicit full
|
|
@@ -289,6 +291,19 @@ model overrides, complete project `risk.rules`, supported project/access/
|
|
|
289
291
|
concurrency/route/structure values, and an existing project-owned structure
|
|
290
292
|
standard byte-for-byte. Removed content is archived outside active docs.
|
|
291
293
|
|
|
294
|
+
## What changed in 4.2.5
|
|
295
|
+
|
|
296
|
+
- Prevented standalone JSX `/>` and closing-tag `</...>` slashes from starting a
|
|
297
|
+
JavaScript regex token during function-range scans. GeeStack now matches its
|
|
298
|
+
TypeScript AST size baseline, and XJMate strict full structure passes cleanly.
|
|
299
|
+
|
|
300
|
+
## What changed in 4.2.4
|
|
301
|
+
|
|
302
|
+
- Fixed TypeScript/TSX named and arrow function ranges across generic constraints,
|
|
303
|
+
predicates, conditional/object/function return types, and multiple same-line
|
|
304
|
+
arrows. Exact arrow locations are evaluated with bounded longest-range selection,
|
|
305
|
+
so type arrows neither truncate real bodies nor create duplicate findings.
|
|
306
|
+
|
|
292
307
|
## What changed in 4.2.3
|
|
293
308
|
|
|
294
309
|
- Added the explicit `structure.block_warnings` policy with a default of `false`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"schema_version":1,"skill_version":"4.2.
|
|
1
|
+
{"schema_version":1,"skill_version":"4.2.5","manifest_path":".agents/managed-install.json","entries":[{"path":".agents/agents/browser-debugger.toml","source":"agents/browser-debugger.toml","ownership":"normalized-agent","sha256":"40727952944917eb0b573bb96dca2906c27bc794737f3b6b392b56df7b4208aa","executable":false,"scope":"shared","version":"4.2.5"},{"path":".agents/agents/docs-researcher.toml","source":"agents/docs-researcher.toml","ownership":"normalized-agent","sha256":"aa1fed6a6a1cde282fc152c7a88b8e097a6c53bcf447d35978607d594e3cb3e4","executable":false,"scope":"shared","version":"4.2.5"},{"path":".agents/agents/explorer.toml","source":"agents/explorer.toml","ownership":"normalized-agent","sha256":"4cd89888acf7c0c04fbbcd0b9a0f346c6efed42fb723ec2037af9331a84a1cac","executable":false,"scope":"shared","version":"4.2.5"},{"path":".agents/agents/fixer.toml","source":"agents/fixer.toml","ownership":"normalized-agent","sha256":"7bc00a45b9d1bcc90b8b0f06d773556eba1d52effff664472c3cb81073f6abfb","executable":false,"scope":"shared","version":"4.2.5"},{"path":".agents/agents/reviewer.toml","source":"agents/reviewer.toml","ownership":"normalized-agent","sha256":"d68c472fab6aef7679330798d753b3c495515545522b6f0a54cabccc0f523c39","executable":false,"scope":"shared","version":"4.2.5"},{"path":".agents/skills/auto-coding-skill/SKILL.md","source":"skill/SKILL.md","ownership":"exact","sha256":"f4c5a340bf3387700385959848dbfa2cc4d90d1312f330d11b0cedc307426eb5","executable":false,"scope":"shared","version":"4.2.5"},{"path":".agents/skills/auto-coding-skill/data/contracts/orchestration-v1.schema.json","source":"skill/data/contracts/orchestration-v1.schema.json","ownership":"exact","sha256":"0e8d5ebb06b47414be1218a1fc93cdbba94a7300fc7ba1c0e12d9c1ca60aeb43","executable":false,"scope":"shared","version":"4.2.5"},{"path":".agents/skills/auto-coding-skill/data/policies/workflow-migrations-v1.json","source":"skill/data/policies/workflow-migrations-v1.json","ownership":"exact","sha256":"2e312960a4778de96753590dbf6b910f505280fb418d86fc3e1d0b64b4ba1367","executable":false,"scope":"shared","version":"4.2.5"},{"path":".agents/skills/auto-coding-skill/data/templates/ENGINEERING.md","source":"skill/data/templates/ENGINEERING.md","ownership":"exact","sha256":"3f1aa5c89af4faa8738a3b348b3c977e4a5ce9084a0f526b8741d415c8518034","executable":false,"scope":"shared","version":"4.2.5"},{"path":".agents/skills/auto-coding-skill/data/templates/bridges/AGENTS.md","source":"skill/data/templates/bridges/AGENTS.md","ownership":"exact","sha256":"cfff9ef1e2575dfcd9701565240e9c59399ce67feb7a3c0902aee6dea25649b0","executable":false,"scope":"shared","version":"4.2.5"},{"path":".agents/skills/auto-coding-skill/data/templates/tools/ap.py","source":"skill/data/templates/tools/ap.py","ownership":"exact","sha256":"c352fbf2cbcb9692a34fd952d8541b1cbe6d475c6e11e64500a1f6b5283a00be","executable":false,"scope":"shared","version":"4.2.5"},{"path":".agents/skills/auto-coding-skill/requirements.txt","source":"skill/requirements.txt","ownership":"exact","sha256":"0969da99a0bc2a1b71ed50584560f4588a37567ac63af3ddbaf3c4617ca5621a","executable":false,"scope":"shared","version":"4.2.5"},{"path":".agents/skills/auto-coding-skill/scripts/ap.py","source":"skill/scripts/ap.py","ownership":"exact","sha256":"7888829396f649e5eab4a81ede25be4e272e5947eb891f98f662286b53724076","executable":false,"scope":"shared","version":"4.2.5"},{"path":".agents/skills/auto-coding-skill/scripts/core.py","source":"skill/scripts/core.py","ownership":"exact","sha256":"640c37e8b274d90d6b7765d4243e054360d5a5a85b3150fbfe6449527c1cd28f","executable":true,"scope":"shared","version":"4.2.5"},{"path":".agents/skills/auto-coding-skill/scripts/http_checks.py","source":"skill/scripts/http_checks.py","ownership":"exact","sha256":"5620e187a0129f135621425a84b3a4e8f31137263c7e549a36a801fc36ff54ea","executable":false,"scope":"shared","version":"4.2.5"},{"path":".agents/skills/auto-coding-skill/scripts/install_integrity.py","source":"skill/scripts/install_integrity.py","ownership":"exact","sha256":"a9ca7bd67893bbd2d7b35ece30a40457f0cbcb9ae01580cfc5daca2cd96fd676","executable":false,"scope":"shared","version":"4.2.5"},{"path":".agents/skills/auto-coding-skill/scripts/scaffold_templates.py","source":"skill/scripts/scaffold_templates.py","ownership":"exact","sha256":"6f0ee92eff2d5db9627a64b332738c9c917a93cc559d5bbacf771c5966215821","executable":false,"scope":"shared","version":"4.2.5"},{"path":"AGENTS.md","source":"skill/data/templates/bridges/AGENTS.md","ownership":"exact","sha256":"cfff9ef1e2575dfcd9701565240e9c59399ce67feb7a3c0902aee6dea25649b0","executable":false,"scope":"project","version":"4.2.5"},{"path":"docs/ENGINEERING.md","source":"skill/data/templates/ENGINEERING.md#managed-workflow","ownership":"managed-workflow","sha256":"7b88b6a5283fc2f5755933e182e0e80a1d72e13be13d16b417a75503ee1a9720","executable":false,"scope":"project","version":"4.2.5"},{"path":"docs/architecture/adr/_TEMPLATE-ADR.md","source":"generated:scaffold_templates:docs/architecture/adr/_TEMPLATE-ADR.md","ownership":"exact","sha256":"88c89065ae0f8555412dbe096c05342152efc7becae8d8981e6442cdfee8e672","executable":false,"scope":"project","version":"4.2.5"},{"path":"docs/deployment/deploy-records/_TEMPLATE-DEPLOY-RECORD.md","source":"generated:scaffold_templates:docs/deployment/deploy-records/_TEMPLATE-DEPLOY-RECORD.md","ownership":"exact","sha256":"f2c17c0febc322b0ad50fb9d6f7e64e6c0cfb15c8a3e445a99da40f0a0dd1901","executable":false,"scope":"project","version":"4.2.5"},{"path":"docs/design/_TEMPLATE-DD.md","source":"generated:scaffold_templates:docs/design/_TEMPLATE-DD.md","ownership":"exact","sha256":"6ca022d127bfff68521f466b60bace4f1206baf0913daa855b9f751e74198db3","executable":false,"scope":"project","version":"4.2.5"},{"path":"docs/reviews/_TEMPLATE-REVIEW.md","source":"generated:scaffold_templates:docs/reviews/_TEMPLATE-REVIEW.md","ownership":"exact","sha256":"134f0d1bd3c7a317ef3cf4c2aea9f0539f3d53dccd5bcdabf6915b3629ef8802","executable":false,"scope":"project","version":"4.2.5"},{"path":"docs/tools/autopipeline/ap.py","source":"skill/data/templates/tools/ap.py","ownership":"exact","sha256":"c352fbf2cbcb9692a34fd952d8541b1cbe6d475c6e11e64500a1f6b5283a00be","executable":false,"scope":"project","version":"4.2.5"}],"managed_namespaces":[{"path":".agents/skills/auto-coding-skill","scope":"shared"},{"path":"docs/tools/autopipeline","scope":"project"}],"preserved":[".agents/archive/**",".agents/agents/* (except paths listed in entries)","docs/project/**","docs/architecture/structure-standard.md","docs/architecture/adr/[0-9]*.md","docs/design/*.md","docs/interfaces/*.md","docs/deployment/deploy-records/*.md","docs/reviews/*.md"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
workflow:
|
|
3
|
-
skill_version: "4.2.
|
|
3
|
+
skill_version: "4.2.5"
|
|
4
4
|
mode: "dev"
|
|
5
5
|
profile: "auto"
|
|
6
6
|
completion: "push"
|
|
@@ -83,7 +83,7 @@ docs:
|
|
|
83
83
|
api_change_log: "docs/interfaces/api-change-log.md"
|
|
84
84
|
---
|
|
85
85
|
# Engineering Configuration and Project Facts
|
|
86
|
-
<!-- auto-coding-skill:managed-workflow:start version=4.2.
|
|
86
|
+
<!-- auto-coding-skill:managed-workflow:start version=4.2.5 -->
|
|
87
87
|
Root `AGENTS.md` is the single shared behavioral protocol. The installed
|
|
88
88
|
`SKILL.md` contains invocation guidance. This file is the exact-schema source for
|
|
89
89
|
project workflow configuration and access values that neither file can infer.
|
|
@@ -85,7 +85,7 @@ _FINAL_GATE_CACHE_ALGORITHM = "final-gate-v1"
|
|
|
85
85
|
_WORKFLOW_MIGRATION_POLICY = Path("data/policies/workflow-migrations-v1.json")
|
|
86
86
|
_FALLBACK_WORKFLOW_MIGRATION_POLICY = {
|
|
87
87
|
"schema_version": 1,
|
|
88
|
-
"managed_versions": {"agents": "4.2.
|
|
88
|
+
"managed_versions": {"agents": "4.2.5", "engineering": "4.2.5"},
|
|
89
89
|
"known_official_engineering_body_sha256": [
|
|
90
90
|
"d1306cc626e8baf8c83c953b760fd771066de2bf125168eca3a7b7d6ff2b87a2",
|
|
91
91
|
"305931c6edef770033a4f1970b00e5fb1c1728351856a173dbfa497daf563021",
|
|
@@ -1148,8 +1148,8 @@ def _migrate_fast_development_defaults(cfg: dict, repo: Path) -> list[str]:
|
|
|
1148
1148
|
if _text(workflow_cfg.get("completion")).lower() != "push":
|
|
1149
1149
|
workflow_cfg["completion"] = "push"
|
|
1150
1150
|
changed.append("workflow.completion")
|
|
1151
|
-
if _text(workflow_cfg.get("skill_version")) != "4.2.
|
|
1152
|
-
workflow_cfg["skill_version"] = "4.2.
|
|
1151
|
+
if _text(workflow_cfg.get("skill_version")) != "4.2.5":
|
|
1152
|
+
workflow_cfg["skill_version"] = "4.2.5"
|
|
1153
1153
|
changed.append("workflow.skill_version")
|
|
1154
1154
|
|
|
1155
1155
|
commands_cfg = cfg.setdefault("commands", {})
|
|
@@ -1462,16 +1462,16 @@ def cmd_upgrade(args: argparse.Namespace) -> None:
|
|
|
1462
1462
|
if current_agents:
|
|
1463
1463
|
archive_dir = repo / "docs" / "archive" / "workflow"
|
|
1464
1464
|
archive_header = (
|
|
1465
|
-
"# Archived AGENTS.md before auto-coding-skill 4.2.
|
|
1465
|
+
"# Archived AGENTS.md before auto-coding-skill 4.2.5\n\n"
|
|
1466
1466
|
"This file is historical and non-authoritative. The root AGENTS.md is fully managed.\n"
|
|
1467
1467
|
"Move any still-current project facts into docs/ENGINEERING.md or docs/project/,\n"
|
|
1468
1468
|
"without copying workflow rules back into the root AGENTS.md.\n\n---\n\n"
|
|
1469
1469
|
)
|
|
1470
1470
|
archive_content = archive_header + current_agents
|
|
1471
|
-
archive = archive_dir / "AGENTS.pre-4.2.
|
|
1471
|
+
archive = archive_dir / "AGENTS.pre-4.2.5.md"
|
|
1472
1472
|
if archive.exists() and archive.read_text(encoding="utf-8") != archive_content:
|
|
1473
1473
|
digest = hashlib.sha256(current_agents.encode("utf-8")).hexdigest()[:12]
|
|
1474
|
-
archive = archive_dir / f"AGENTS.pre-4.2.
|
|
1474
|
+
archive = archive_dir / f"AGENTS.pre-4.2.5-{digest}.md"
|
|
1475
1475
|
if not archive.exists():
|
|
1476
1476
|
add_action("policy", archive, "archive", "historical and non-authoritative")
|
|
1477
1477
|
if write:
|
|
@@ -4370,13 +4370,138 @@ def _ensure_structure_deadline(deadline: Optional[float]) -> None:
|
|
|
4370
4370
|
raise APError("Final changed-scope gate timed out during structure check.")
|
|
4371
4371
|
|
|
4372
4372
|
|
|
4373
|
+
_JSX_TAG_RE = re.compile(r"</?>|</?[A-Za-z_$][A-Za-z0-9_.$:-]*(?:\s[^<>]*?)?/?>")
|
|
4374
|
+
_JSX_NONCODE_RE = re.compile(
|
|
4375
|
+
r'''"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`(?:\\.|[^`\\])*`|//.*|/\*.*?\*/'''
|
|
4376
|
+
)
|
|
4377
|
+
|
|
4378
|
+
|
|
4379
|
+
def _mask_jsx_noncode(text: str) -> str:
|
|
4380
|
+
masked = list(_JSX_NONCODE_RE.sub(lambda match: " " * len(match.group(0)), text))
|
|
4381
|
+
for index, char in enumerate(masked):
|
|
4382
|
+
if char != "/":
|
|
4383
|
+
continue
|
|
4384
|
+
prefix = "".join(masked[:index]).rstrip()
|
|
4385
|
+
regex_context = prefix.endswith(("=", "(", "[", "{", ",", ":", ";", "!", "?")) or bool(
|
|
4386
|
+
re.search(r"\b(?:return|case|throw|yield)\s*$", prefix)
|
|
4387
|
+
)
|
|
4388
|
+
if not regex_context:
|
|
4389
|
+
continue
|
|
4390
|
+
terminator = _regex_line_terminator(text, index)
|
|
4391
|
+
if terminator is None:
|
|
4392
|
+
continue
|
|
4393
|
+
suffix = terminator + 1
|
|
4394
|
+
while suffix < len(text) and text[suffix] in "dgimsuvy":
|
|
4395
|
+
suffix += 1
|
|
4396
|
+
masked[index:suffix] = " " * (suffix - index)
|
|
4397
|
+
return "".join(masked)
|
|
4398
|
+
|
|
4399
|
+
|
|
4400
|
+
def _jsx_prefix_has_open_tag(text: str) -> bool:
|
|
4401
|
+
masked = _mask_jsx_noncode(text)
|
|
4402
|
+
depth = 0
|
|
4403
|
+
expression_depth = 0
|
|
4404
|
+
cursor = 0
|
|
4405
|
+
for match in _JSX_TAG_RE.finditer(masked):
|
|
4406
|
+
for char in masked[cursor:match.start()]:
|
|
4407
|
+
if depth <= 0:
|
|
4408
|
+
continue
|
|
4409
|
+
if char == "{":
|
|
4410
|
+
expression_depth += 1
|
|
4411
|
+
elif char == "}" and expression_depth > 0:
|
|
4412
|
+
expression_depth -= 1
|
|
4413
|
+
token = match.group(0)
|
|
4414
|
+
if token.startswith("</"):
|
|
4415
|
+
depth = max(0, depth - 1)
|
|
4416
|
+
elif token != "</>" and not token.endswith("/>"):
|
|
4417
|
+
previous = masked[:match.start()].rstrip()
|
|
4418
|
+
following = masked[match.end():].lstrip()
|
|
4419
|
+
if (
|
|
4420
|
+
previous
|
|
4421
|
+
and (previous[-1].isalnum() or previous[-1] in {"_", "$"})
|
|
4422
|
+
and (
|
|
4423
|
+
depth == 0
|
|
4424
|
+
or expression_depth > 0
|
|
4425
|
+
or following.startswith(("(", ".", "?."))
|
|
4426
|
+
)
|
|
4427
|
+
):
|
|
4428
|
+
cursor = match.end()
|
|
4429
|
+
continue
|
|
4430
|
+
depth += 1
|
|
4431
|
+
if depth == 0:
|
|
4432
|
+
expression_depth = 0
|
|
4433
|
+
cursor = match.end()
|
|
4434
|
+
return depth > 0
|
|
4435
|
+
|
|
4436
|
+
|
|
4437
|
+
def _regex_line_terminator(line: str, index: int) -> Optional[int]:
|
|
4438
|
+
escaped = False
|
|
4439
|
+
char_class = False
|
|
4440
|
+
for char_index in range(index + 1, len(line)):
|
|
4441
|
+
char = line[char_index]
|
|
4442
|
+
if escaped:
|
|
4443
|
+
escaped = False
|
|
4444
|
+
elif char == "\\":
|
|
4445
|
+
escaped = True
|
|
4446
|
+
elif char == "[":
|
|
4447
|
+
char_class = True
|
|
4448
|
+
elif char == "]":
|
|
4449
|
+
char_class = False
|
|
4450
|
+
elif char == "/" and not char_class:
|
|
4451
|
+
suffix_index = char_index + 1
|
|
4452
|
+
while suffix_index < len(line) and line[suffix_index] in "dgimsuvy":
|
|
4453
|
+
suffix_index += 1
|
|
4454
|
+
if suffix_index < len(line) and (
|
|
4455
|
+
line[suffix_index].isalnum() or line[suffix_index] in {"_", "$"}
|
|
4456
|
+
):
|
|
4457
|
+
return None
|
|
4458
|
+
token_index = suffix_index
|
|
4459
|
+
while token_index < len(line) and line[token_index].isspace():
|
|
4460
|
+
token_index += 1
|
|
4461
|
+
if token_index < len(line) and (
|
|
4462
|
+
line[token_index].isalnum() or line[token_index] in {"_", "$"}
|
|
4463
|
+
):
|
|
4464
|
+
token = re.match(r"[A-Za-z_$][A-Za-z0-9_$]*", line[token_index:])
|
|
4465
|
+
if token is None or token.group(0) not in {"as", "in", "instanceof", "satisfies"}:
|
|
4466
|
+
return None
|
|
4467
|
+
return char_index
|
|
4468
|
+
return None
|
|
4469
|
+
|
|
4470
|
+
|
|
4373
4471
|
def _looks_like_regex_start(line: str, index: int) -> bool:
|
|
4374
4472
|
prefix = line[:index].rstrip()
|
|
4375
|
-
if
|
|
4376
|
-
|
|
4377
|
-
if
|
|
4473
|
+
next_char = line[index + 1] if index + 1 < len(line) else ""
|
|
4474
|
+
terminator = _regex_line_terminator(line, index)
|
|
4475
|
+
if terminator is None:
|
|
4476
|
+
return False
|
|
4477
|
+
closing_tag = re.match(r"/[A-Za-z_$][A-Za-z0-9_.$:-]*\s*>", line[index:])
|
|
4478
|
+
keyword_context = bool(re.search(r"\b(?:return|case|throw|yield)\s*$", prefix))
|
|
4479
|
+
operator_context = prefix.endswith(("=", "(", "[", "{", ",", ":", ";", "!", "?", "<", ">", "=>"))
|
|
4480
|
+
if prefix.endswith("<") and closing_tag:
|
|
4481
|
+
before_less_than = prefix[:-1].rstrip()
|
|
4482
|
+
operand_context = bool(re.search(r"(?:[A-Za-z0-9_$\]\)}'\"`]|\+\+|--)$", before_less_than))
|
|
4483
|
+
tag_end = index + closing_tag.end()
|
|
4484
|
+
between = line[tag_end:terminator]
|
|
4485
|
+
terminator_next = line[terminator + 1] if terminator + 1 < len(line) else ""
|
|
4486
|
+
if (
|
|
4487
|
+
_jsx_prefix_has_open_tag(before_less_than)
|
|
4488
|
+
or not operand_context
|
|
4489
|
+
or (between and not between.strip())
|
|
4490
|
+
or terminator_next in {"/", "*"}
|
|
4491
|
+
):
|
|
4492
|
+
return False
|
|
4493
|
+
if next_char == ">":
|
|
4494
|
+
if not prefix:
|
|
4495
|
+
return False
|
|
4496
|
+
if prefix.endswith("<"):
|
|
4497
|
+
before_less_than = prefix[:-1].rstrip()
|
|
4498
|
+
if not re.search(r"(?:[A-Za-z0-9_$\]\)}'\"`]|\+\+|--)$", before_less_than):
|
|
4499
|
+
return False
|
|
4500
|
+
elif not (operator_context or keyword_context):
|
|
4501
|
+
return False
|
|
4502
|
+
if not prefix or operator_context:
|
|
4378
4503
|
return True
|
|
4379
|
-
return
|
|
4504
|
+
return keyword_context
|
|
4380
4505
|
|
|
4381
4506
|
|
|
4382
4507
|
def _python_function_end(
|
|
@@ -4445,18 +4570,20 @@ def _python_function_ranges(
|
|
|
4445
4570
|
return sorted(ranges)
|
|
4446
4571
|
|
|
4447
4572
|
|
|
4448
|
-
def
|
|
4573
|
+
def _find_arrow_locations(
|
|
4449
4574
|
lines: list[str],
|
|
4450
4575
|
start: int,
|
|
4451
4576
|
deadline: Optional[float],
|
|
4452
|
-
) ->
|
|
4453
|
-
"""Find a declaration's top-level arrow
|
|
4577
|
+
) -> list[tuple[int, int]]:
|
|
4578
|
+
"""Find a declaration's top-level arrow candidates with exact columns."""
|
|
4454
4579
|
state = "code"
|
|
4455
4580
|
escaped = False
|
|
4456
4581
|
regex_char_class = False
|
|
4457
4582
|
paren_depth = 0
|
|
4458
4583
|
bracket_depth = 0
|
|
4459
4584
|
brace_depth = 0
|
|
4585
|
+
angle_depth = 0
|
|
4586
|
+
locations: list[tuple[int, int]] = []
|
|
4460
4587
|
indent = len(lines[start]) - len(lines[start].lstrip())
|
|
4461
4588
|
limit = min(len(lines), start + 200)
|
|
4462
4589
|
equals = lines[start].find("=")
|
|
@@ -4467,8 +4594,10 @@ def _find_arrow_line(
|
|
|
4467
4594
|
if line_index > start:
|
|
4468
4595
|
stripped = line.strip()
|
|
4469
4596
|
current_indent = len(line) - len(line.lstrip())
|
|
4470
|
-
if stripped and current_indent <= indent and not (
|
|
4471
|
-
|
|
4597
|
+
if stripped and current_indent <= indent and not (
|
|
4598
|
+
paren_depth or bracket_depth or brace_depth or angle_depth
|
|
4599
|
+
):
|
|
4600
|
+
return locations
|
|
4472
4601
|
char_index = equals + 1 if line_index == start and equals >= 0 else 0
|
|
4473
4602
|
while char_index < len(line):
|
|
4474
4603
|
char = line[char_index]
|
|
@@ -4526,25 +4655,32 @@ def _find_arrow_line(
|
|
|
4526
4655
|
bracket_depth += 1
|
|
4527
4656
|
elif char == "]":
|
|
4528
4657
|
bracket_depth = max(0, bracket_depth - 1)
|
|
4658
|
+
elif char == "<" and not (paren_depth or bracket_depth or brace_depth):
|
|
4659
|
+
angle_depth += 1
|
|
4660
|
+
elif char == ">" and angle_depth and not (paren_depth or bracket_depth or brace_depth):
|
|
4661
|
+
angle_depth -= 1
|
|
4529
4662
|
elif char == "{":
|
|
4530
4663
|
brace_depth += 1
|
|
4531
4664
|
elif char == "}":
|
|
4532
4665
|
brace_depth = max(0, brace_depth - 1)
|
|
4533
|
-
elif char == "=" and next_char == ">"
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
|
|
4666
|
+
elif char == "=" and next_char == ">":
|
|
4667
|
+
if not (paren_depth or bracket_depth or brace_depth or angle_depth):
|
|
4668
|
+
locations.append((line_index, char_index))
|
|
4669
|
+
char_index += 2
|
|
4670
|
+
continue
|
|
4671
|
+
elif char == ";" and not (paren_depth or bracket_depth or brace_depth or angle_depth):
|
|
4672
|
+
return locations
|
|
4537
4673
|
char_index += 1
|
|
4538
4674
|
if line_index > start:
|
|
4539
4675
|
stripped = line.strip()
|
|
4540
4676
|
current_indent = len(line) - len(line.lstrip())
|
|
4541
|
-
if stripped and current_indent <= indent and not (paren_depth or bracket_depth or brace_depth):
|
|
4542
|
-
return
|
|
4543
|
-
return
|
|
4677
|
+
if stripped and current_indent <= indent and not (paren_depth or bracket_depth or brace_depth or angle_depth):
|
|
4678
|
+
return locations
|
|
4679
|
+
return locations
|
|
4544
4680
|
|
|
4545
4681
|
|
|
4546
|
-
def _arrow_body_kind(lines: list[str],
|
|
4547
|
-
arrow_column =
|
|
4682
|
+
def _arrow_body_kind(lines: list[str], arrow_location: tuple[int, int]) -> str:
|
|
4683
|
+
arrow_line, arrow_column = arrow_location
|
|
4548
4684
|
for line_index in range(arrow_line, min(len(lines), arrow_line + 20)):
|
|
4549
4685
|
text = lines[line_index][arrow_column + 2 :] if line_index == arrow_line else lines[line_index]
|
|
4550
4686
|
stripped = text.strip()
|
|
@@ -4556,10 +4692,7 @@ def _arrow_body_kind(lines: list[str], arrow_line: int) -> str:
|
|
|
4556
4692
|
|
|
4557
4693
|
def _looks_like_return_type_brace(line: str, index: int) -> bool:
|
|
4558
4694
|
prefix = line[:index].rstrip()
|
|
4559
|
-
|
|
4560
|
-
return True
|
|
4561
|
-
close_paren = prefix.rfind(")")
|
|
4562
|
-
return close_paren >= 0 and ":" in prefix[close_paren + 1 :]
|
|
4695
|
+
return bool(re.search(r"\b(?:struct|interface)\s*$", prefix))
|
|
4563
4696
|
|
|
4564
4697
|
|
|
4565
4698
|
def _brace_function_end(
|
|
@@ -4567,7 +4700,8 @@ def _brace_function_end(
|
|
|
4567
4700
|
start: int,
|
|
4568
4701
|
threshold: int,
|
|
4569
4702
|
deadline: Optional[float],
|
|
4570
|
-
|
|
4703
|
+
arrow_location: Optional[tuple[int, int]] = None,
|
|
4704
|
+
suffix: str = "",
|
|
4571
4705
|
) -> Optional[tuple[int, bool]]:
|
|
4572
4706
|
depth = 0
|
|
4573
4707
|
opened = False
|
|
@@ -4577,7 +4711,13 @@ def _brace_function_end(
|
|
|
4577
4711
|
paren_depth = 0
|
|
4578
4712
|
bracket_depth = 0
|
|
4579
4713
|
type_brace_depth = 0
|
|
4580
|
-
arrow_seen =
|
|
4714
|
+
arrow_seen = arrow_location is None
|
|
4715
|
+
typescript_declaration = arrow_location is None and suffix in {".ts", ".tsx"}
|
|
4716
|
+
ts_phase = "before_params"
|
|
4717
|
+
ts_pre_angle_depth = ts_pre_brace_depth = 0
|
|
4718
|
+
ts_type_angle_depth = ts_type_paren_depth = ts_type_bracket_depth = 0
|
|
4719
|
+
ts_type_brace_depth = 0
|
|
4720
|
+
ts_type_expects_operand = True
|
|
4581
4721
|
limit = min(len(lines), start + threshold + 1)
|
|
4582
4722
|
|
|
4583
4723
|
for line_index in range(start, limit):
|
|
@@ -4643,10 +4783,107 @@ def _brace_function_end(
|
|
|
4643
4783
|
char_index += 1
|
|
4644
4784
|
continue
|
|
4645
4785
|
if char == "=" and next_char == ">":
|
|
4646
|
-
if
|
|
4786
|
+
if arrow_location == (line_index, char_index):
|
|
4647
4787
|
arrow_seen = True
|
|
4788
|
+
if typescript_declaration and ts_phase == "return_type":
|
|
4789
|
+
ts_type_expects_operand = True
|
|
4648
4790
|
char_index += 2
|
|
4649
4791
|
continue
|
|
4792
|
+
if typescript_declaration and not opened:
|
|
4793
|
+
if char in {"'", '"', "`"}:
|
|
4794
|
+
state = {"'": "single_quote", '"': "double_quote", "`": "backtick"}[char]
|
|
4795
|
+
escaped = False
|
|
4796
|
+
if ts_phase == "return_type":
|
|
4797
|
+
ts_type_expects_operand = False
|
|
4798
|
+
char_index += 1
|
|
4799
|
+
continue
|
|
4800
|
+
if ts_phase == "before_params":
|
|
4801
|
+
if ts_pre_brace_depth > 0:
|
|
4802
|
+
if char == "{":
|
|
4803
|
+
ts_pre_brace_depth += 1
|
|
4804
|
+
elif char == "}":
|
|
4805
|
+
ts_pre_brace_depth -= 1
|
|
4806
|
+
elif char == "<":
|
|
4807
|
+
ts_pre_angle_depth += 1
|
|
4808
|
+
elif char == ">":
|
|
4809
|
+
ts_pre_angle_depth = max(0, ts_pre_angle_depth - 1)
|
|
4810
|
+
elif char == "{":
|
|
4811
|
+
ts_pre_brace_depth = 1
|
|
4812
|
+
elif char == "(" and ts_pre_angle_depth == 0:
|
|
4813
|
+
ts_phase = "params"
|
|
4814
|
+
paren_depth = 1
|
|
4815
|
+
elif ts_phase == "params":
|
|
4816
|
+
if char == "(":
|
|
4817
|
+
paren_depth += 1
|
|
4818
|
+
elif char == ")":
|
|
4819
|
+
paren_depth = max(0, paren_depth - 1)
|
|
4820
|
+
if paren_depth == 0:
|
|
4821
|
+
ts_phase = "after_params"
|
|
4822
|
+
elif ts_phase == "after_params":
|
|
4823
|
+
if char == ":":
|
|
4824
|
+
ts_phase = "return_type"
|
|
4825
|
+
ts_type_expects_operand = True
|
|
4826
|
+
elif char == "{":
|
|
4827
|
+
opened = True
|
|
4828
|
+
depth = 1
|
|
4829
|
+
elif char == ";":
|
|
4830
|
+
return None
|
|
4831
|
+
elif ts_type_brace_depth > 0:
|
|
4832
|
+
if char == "{":
|
|
4833
|
+
ts_type_brace_depth += 1
|
|
4834
|
+
elif char == "}":
|
|
4835
|
+
ts_type_brace_depth -= 1
|
|
4836
|
+
if ts_type_brace_depth == 0:
|
|
4837
|
+
ts_type_expects_operand = False
|
|
4838
|
+
elif char == "{":
|
|
4839
|
+
if (
|
|
4840
|
+
ts_type_angle_depth
|
|
4841
|
+
or ts_type_paren_depth
|
|
4842
|
+
or ts_type_bracket_depth
|
|
4843
|
+
or ts_type_expects_operand
|
|
4844
|
+
):
|
|
4845
|
+
ts_type_brace_depth = 1
|
|
4846
|
+
ts_type_expects_operand = False
|
|
4847
|
+
else:
|
|
4848
|
+
opened = True
|
|
4849
|
+
depth = 1
|
|
4850
|
+
elif char == "<":
|
|
4851
|
+
ts_type_angle_depth += 1
|
|
4852
|
+
ts_type_expects_operand = True
|
|
4853
|
+
elif char == ">":
|
|
4854
|
+
ts_type_angle_depth = max(0, ts_type_angle_depth - 1)
|
|
4855
|
+
ts_type_expects_operand = False
|
|
4856
|
+
elif char == "(":
|
|
4857
|
+
ts_type_paren_depth += 1
|
|
4858
|
+
ts_type_expects_operand = True
|
|
4859
|
+
elif char == ")":
|
|
4860
|
+
ts_type_paren_depth = max(0, ts_type_paren_depth - 1)
|
|
4861
|
+
ts_type_expects_operand = False
|
|
4862
|
+
elif char == "[":
|
|
4863
|
+
ts_type_bracket_depth += 1
|
|
4864
|
+
ts_type_expects_operand = True
|
|
4865
|
+
elif char == "]":
|
|
4866
|
+
ts_type_bracket_depth = max(0, ts_type_bracket_depth - 1)
|
|
4867
|
+
ts_type_expects_operand = False
|
|
4868
|
+
elif char in "|&?:,.=":
|
|
4869
|
+
ts_type_expects_operand = True
|
|
4870
|
+
elif char.isalpha() or char in {"_", "$"}:
|
|
4871
|
+
word_match = re.match(r"[A-Za-z_$][\w$]*", line[char_index:])
|
|
4872
|
+
word = word_match.group(0) if word_match else char
|
|
4873
|
+
ts_type_expects_operand = word in {
|
|
4874
|
+
"abstract", "asserts", "extends", "in", "infer", "is",
|
|
4875
|
+
"keyof", "new", "readonly", "typeof", "unique",
|
|
4876
|
+
}
|
|
4877
|
+
char_index += len(word)
|
|
4878
|
+
continue
|
|
4879
|
+
elif char.isdigit():
|
|
4880
|
+
ts_type_expects_operand = False
|
|
4881
|
+
elif char == ";" and not (
|
|
4882
|
+
ts_type_angle_depth or ts_type_paren_depth or ts_type_bracket_depth
|
|
4883
|
+
):
|
|
4884
|
+
return None
|
|
4885
|
+
char_index += 1
|
|
4886
|
+
continue
|
|
4650
4887
|
if char == "'":
|
|
4651
4888
|
state = "single_quote"
|
|
4652
4889
|
escaped = False
|
|
@@ -4669,14 +4906,14 @@ def _brace_function_end(
|
|
|
4669
4906
|
if not arrow_seen:
|
|
4670
4907
|
char_index += 1
|
|
4671
4908
|
continue
|
|
4672
|
-
if
|
|
4909
|
+
if arrow_location is None and (paren_depth > 0 or bracket_depth > 0):
|
|
4673
4910
|
char_index += 1
|
|
4674
4911
|
continue
|
|
4675
4912
|
if type_brace_depth > 0:
|
|
4676
4913
|
type_brace_depth += 1
|
|
4677
4914
|
char_index += 1
|
|
4678
4915
|
continue
|
|
4679
|
-
if
|
|
4916
|
+
if arrow_location is None and _looks_like_return_type_brace(line, char_index):
|
|
4680
4917
|
type_brace_depth = 1
|
|
4681
4918
|
char_index += 1
|
|
4682
4919
|
continue
|
|
@@ -4700,13 +4937,10 @@ _EXPRESSION_CONTINUATION_SUFFIXES = (
|
|
|
4700
4937
|
_EXPRESSION_CONTINUATION_PREFIXES = (
|
|
4701
4938
|
".", "?.", "+", "-", "*", "/", "%", "&&", "||", "??", "?", ":", ",",
|
|
4702
4939
|
)
|
|
4703
|
-
_JSX_TAG_RE = re.compile(r"</?>|</?[A-Za-z][A-Za-z0-9_.:-]*(?:\s[^<>]*?)?/?>")
|
|
4704
|
-
|
|
4705
|
-
|
|
4706
4940
|
def _expression_arrow_end(
|
|
4707
4941
|
lines: list[str],
|
|
4708
4942
|
start: int,
|
|
4709
|
-
|
|
4943
|
+
arrow_location: tuple[int, int],
|
|
4710
4944
|
threshold: int,
|
|
4711
4945
|
deadline: Optional[float],
|
|
4712
4946
|
suffix: str,
|
|
@@ -4720,7 +4954,7 @@ def _expression_arrow_end(
|
|
|
4720
4954
|
jsx_mode = False
|
|
4721
4955
|
jsx_depth = 0
|
|
4722
4956
|
saw_jsx_tag = False
|
|
4723
|
-
arrow_column =
|
|
4957
|
+
arrow_line, arrow_column = arrow_location
|
|
4724
4958
|
|
|
4725
4959
|
for line_index in range(arrow_line, limit):
|
|
4726
4960
|
if (line_index - arrow_line) % 32 == 0:
|
|
@@ -4768,7 +5002,16 @@ def _expression_arrow_end(
|
|
|
4768
5002
|
state = "block_comment"
|
|
4769
5003
|
char_index += 2
|
|
4770
5004
|
continue
|
|
4771
|
-
|
|
5005
|
+
jsx_token_slash = (
|
|
5006
|
+
suffix in {".jsx", ".tsx"}
|
|
5007
|
+
and jsx_mode
|
|
5008
|
+
and brace_depth == 0
|
|
5009
|
+
and (
|
|
5010
|
+
next_char == ">"
|
|
5011
|
+
or (char_index > 0 and line[char_index - 1] == "<")
|
|
5012
|
+
)
|
|
5013
|
+
)
|
|
5014
|
+
if char == "/" and not jsx_token_slash and _looks_like_regex_start(line, char_index):
|
|
4772
5015
|
state = "regex"
|
|
4773
5016
|
regex_char_class = False
|
|
4774
5017
|
escaped = False
|
|
@@ -4848,37 +5091,51 @@ def _function_size_warnings(
|
|
|
4848
5091
|
if suffix == ".py":
|
|
4849
5092
|
ranges = _python_function_ranges(lines, threshold, deadline)
|
|
4850
5093
|
else:
|
|
4851
|
-
candidates: dict[int, Optional[int]] = {}
|
|
5094
|
+
candidates: dict[int, list[Optional[tuple[int, int]]]] = {}
|
|
5095
|
+
claimed_arrow_lines: set[int] = set()
|
|
4852
5096
|
for index, line in enumerate(lines):
|
|
4853
5097
|
if index % 256 == 0:
|
|
4854
5098
|
_ensure_structure_deadline(deadline)
|
|
4855
5099
|
if _ARROW_DECLARATION_RE.search(line):
|
|
4856
|
-
|
|
4857
|
-
if
|
|
4858
|
-
candidates[index] =
|
|
5100
|
+
arrow_locations = _find_arrow_locations(lines, index, deadline)
|
|
5101
|
+
if arrow_locations:
|
|
5102
|
+
candidates[index] = list(arrow_locations)
|
|
5103
|
+
claimed_arrow_lines.update(location[0] for location in arrow_locations)
|
|
4859
5104
|
continue
|
|
4860
|
-
if
|
|
4861
|
-
candidates[index] = index
|
|
4862
|
-
elif Path(path).name == "Jenkinsfile":
|
|
5105
|
+
if Path(path).name == "Jenkinsfile":
|
|
4863
5106
|
if re.match(r"^\s*def\s+[A-Za-z_]\w*\s*\(", line):
|
|
4864
|
-
candidates[index] = None
|
|
5107
|
+
candidates[index] = [None]
|
|
4865
5108
|
elif _FUNCTION_START_RE.search(line):
|
|
4866
|
-
candidates[index] = None
|
|
5109
|
+
candidates[index] = [None]
|
|
5110
|
+
elif index not in claimed_arrow_lines:
|
|
5111
|
+
arrow_matches = list(_ARROW_FUNCTION_BODY_RE.finditer(line))
|
|
5112
|
+
if arrow_matches:
|
|
5113
|
+
candidates[index] = [(index, match.start()) for match in arrow_matches]
|
|
4867
5114
|
|
|
4868
5115
|
ranges = []
|
|
4869
|
-
for start,
|
|
5116
|
+
for start, arrow_locations in sorted(candidates.items()):
|
|
4870
5117
|
_ensure_structure_deadline(deadline)
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
5118
|
+
candidate_ranges: list[tuple[int, bool]] = []
|
|
5119
|
+
for arrow_location in arrow_locations:
|
|
5120
|
+
if arrow_location is not None and _arrow_body_kind(lines, arrow_location) == "expression":
|
|
5121
|
+
candidate_ranges.append(
|
|
5122
|
+
_expression_arrow_end(
|
|
5123
|
+
lines, start, arrow_location, threshold, deadline, suffix
|
|
5124
|
+
)
|
|
5125
|
+
)
|
|
5126
|
+
continue
|
|
5127
|
+
result = _brace_function_end(
|
|
5128
|
+
lines,
|
|
5129
|
+
start,
|
|
5130
|
+
threshold,
|
|
5131
|
+
deadline,
|
|
5132
|
+
arrow_location=arrow_location,
|
|
5133
|
+
suffix=suffix,
|
|
4874
5134
|
)
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
)
|
|
4880
|
-
if result is not None:
|
|
4881
|
-
end, truncated = result
|
|
5135
|
+
if result is not None:
|
|
5136
|
+
candidate_ranges.append(result)
|
|
5137
|
+
if candidate_ranges:
|
|
5138
|
+
end, truncated = max(candidate_ranges, key=lambda item: (item[0], item[1]))
|
|
4882
5139
|
ranges.append((start, end, truncated))
|
|
4883
5140
|
|
|
4884
5141
|
warnings: list[str] = []
|
|
@@ -1694,6 +1694,188 @@ class AutoCodingProfileTests(unittest.TestCase):
|
|
|
1694
1694
|
1,
|
|
1695
1695
|
6,
|
|
1696
1696
|
),
|
|
1697
|
+
(
|
|
1698
|
+
"typed-arrow-factory.ts",
|
|
1699
|
+
[
|
|
1700
|
+
"const factory = (): (x: string) => { value: string } => {",
|
|
1701
|
+
" const build = (value: string) => ({ value });",
|
|
1702
|
+
" return build;",
|
|
1703
|
+
"};",
|
|
1704
|
+
"const after = 1;",
|
|
1705
|
+
],
|
|
1706
|
+
1,
|
|
1707
|
+
4,
|
|
1708
|
+
),
|
|
1709
|
+
(
|
|
1710
|
+
"typed-generic-arrow-factory.ts",
|
|
1711
|
+
[
|
|
1712
|
+
"const factory = (): <T>(x: T) => { value: T } => {",
|
|
1713
|
+
" const build = <T>(value: T) => ({ value });",
|
|
1714
|
+
" return build;",
|
|
1715
|
+
"};",
|
|
1716
|
+
"const after = 1;",
|
|
1717
|
+
],
|
|
1718
|
+
1,
|
|
1719
|
+
4,
|
|
1720
|
+
),
|
|
1721
|
+
(
|
|
1722
|
+
"typed-constrained-generic-arrow.ts",
|
|
1723
|
+
[
|
|
1724
|
+
"const factory = <T extends (x: string) => { value: string }>(cb: T): void => {",
|
|
1725
|
+
" void cb;",
|
|
1726
|
+
" return;",
|
|
1727
|
+
"};",
|
|
1728
|
+
"const after = 1;",
|
|
1729
|
+
],
|
|
1730
|
+
1,
|
|
1731
|
+
4,
|
|
1732
|
+
),
|
|
1733
|
+
(
|
|
1734
|
+
"typed-defaulted-generic-arrow.ts",
|
|
1735
|
+
[
|
|
1736
|
+
"const factory = <T = () => { value: string }>(cb?: T): void => {",
|
|
1737
|
+
" void cb;",
|
|
1738
|
+
" return;",
|
|
1739
|
+
"};",
|
|
1740
|
+
"const after = 1;",
|
|
1741
|
+
],
|
|
1742
|
+
1,
|
|
1743
|
+
4,
|
|
1744
|
+
),
|
|
1745
|
+
(
|
|
1746
|
+
"typed-function.ts",
|
|
1747
|
+
[
|
|
1748
|
+
"export async function listBudgetRanges(",
|
|
1749
|
+
" scope: string,",
|
|
1750
|
+
"): Promise<BudgetRange[]> {",
|
|
1751
|
+
" return request(scope);",
|
|
1752
|
+
"}",
|
|
1753
|
+
"const after = 1;",
|
|
1754
|
+
],
|
|
1755
|
+
1,
|
|
1756
|
+
5,
|
|
1757
|
+
),
|
|
1758
|
+
(
|
|
1759
|
+
"typed-literal-function.ts",
|
|
1760
|
+
[
|
|
1761
|
+
"export function buildValue(): {",
|
|
1762
|
+
" value: string;",
|
|
1763
|
+
"} {",
|
|
1764
|
+
" return { value: 'ready' };",
|
|
1765
|
+
"}",
|
|
1766
|
+
"const after = 1;",
|
|
1767
|
+
],
|
|
1768
|
+
1,
|
|
1769
|
+
5,
|
|
1770
|
+
),
|
|
1771
|
+
(
|
|
1772
|
+
"typed-generic-constraint.ts",
|
|
1773
|
+
[
|
|
1774
|
+
"export function constrained<T extends { kind: string }>(",
|
|
1775
|
+
" value: T,",
|
|
1776
|
+
"): T {",
|
|
1777
|
+
" return value;",
|
|
1778
|
+
"}",
|
|
1779
|
+
"const after = 1;",
|
|
1780
|
+
],
|
|
1781
|
+
1,
|
|
1782
|
+
5,
|
|
1783
|
+
),
|
|
1784
|
+
(
|
|
1785
|
+
"typed-function-return.ts",
|
|
1786
|
+
[
|
|
1787
|
+
"export function makeFactory(): (x: string) => { value: string } {",
|
|
1788
|
+
" return value => ({ value });",
|
|
1789
|
+
"}",
|
|
1790
|
+
"const after = 1;",
|
|
1791
|
+
],
|
|
1792
|
+
1,
|
|
1793
|
+
3,
|
|
1794
|
+
),
|
|
1795
|
+
(
|
|
1796
|
+
"typed-generic-function-return.ts",
|
|
1797
|
+
[
|
|
1798
|
+
"export function makeGenericFactory(): <T>(x: T) => { value: T } {",
|
|
1799
|
+
" return value => ({ value });",
|
|
1800
|
+
"}",
|
|
1801
|
+
"const after = 1;",
|
|
1802
|
+
],
|
|
1803
|
+
1,
|
|
1804
|
+
3,
|
|
1805
|
+
),
|
|
1806
|
+
(
|
|
1807
|
+
"typed-conditional-return.ts",
|
|
1808
|
+
[
|
|
1809
|
+
"export function choose<T>(",
|
|
1810
|
+
" value: T,",
|
|
1811
|
+
"): T extends { kind: string } ? { matched: T } : { matched: never } {",
|
|
1812
|
+
" return { matched: value } as never;",
|
|
1813
|
+
"}",
|
|
1814
|
+
"const after = 1;",
|
|
1815
|
+
],
|
|
1816
|
+
1,
|
|
1817
|
+
5,
|
|
1818
|
+
),
|
|
1819
|
+
(
|
|
1820
|
+
"typed-keyof-return.ts",
|
|
1821
|
+
[
|
|
1822
|
+
"export function key(): keyof { ready: boolean } {",
|
|
1823
|
+
" return 'ready';",
|
|
1824
|
+
"}",
|
|
1825
|
+
"const after = 1;",
|
|
1826
|
+
],
|
|
1827
|
+
1,
|
|
1828
|
+
3,
|
|
1829
|
+
),
|
|
1830
|
+
(
|
|
1831
|
+
"typed-predicate-return.ts",
|
|
1832
|
+
[
|
|
1833
|
+
"export function isReady(value: unknown): value is { ready: true } {",
|
|
1834
|
+
" return Boolean(value);",
|
|
1835
|
+
"}",
|
|
1836
|
+
"const after = 1;",
|
|
1837
|
+
],
|
|
1838
|
+
1,
|
|
1839
|
+
3,
|
|
1840
|
+
),
|
|
1841
|
+
(
|
|
1842
|
+
"typed-multiline-generic-return.ts",
|
|
1843
|
+
[
|
|
1844
|
+
"export function load(): Promise<",
|
|
1845
|
+
" { value: string }",
|
|
1846
|
+
"> {",
|
|
1847
|
+
" return Promise.resolve({ value: 'ready' });",
|
|
1848
|
+
"}",
|
|
1849
|
+
"const after = 1;",
|
|
1850
|
+
],
|
|
1851
|
+
1,
|
|
1852
|
+
5,
|
|
1853
|
+
),
|
|
1854
|
+
(
|
|
1855
|
+
"typed-multiline-union-return.ts",
|
|
1856
|
+
[
|
|
1857
|
+
"export function union():",
|
|
1858
|
+
" | { kind: 'a' }",
|
|
1859
|
+
" | { kind: 'b' }",
|
|
1860
|
+
"{",
|
|
1861
|
+
" return { kind: 'a' };",
|
|
1862
|
+
"}",
|
|
1863
|
+
"const after = 1;",
|
|
1864
|
+
],
|
|
1865
|
+
1,
|
|
1866
|
+
6,
|
|
1867
|
+
),
|
|
1868
|
+
(
|
|
1869
|
+
"typed-commented-return.ts",
|
|
1870
|
+
[
|
|
1871
|
+
"export function commented(): /* result */ { value: string } {",
|
|
1872
|
+
" return { value: 'ready' };",
|
|
1873
|
+
"}",
|
|
1874
|
+
"const after = 1;",
|
|
1875
|
+
],
|
|
1876
|
+
1,
|
|
1877
|
+
3,
|
|
1878
|
+
),
|
|
1697
1879
|
(
|
|
1698
1880
|
"same-indent-plus.ts",
|
|
1699
1881
|
[
|
|
@@ -1729,6 +1911,72 @@ class AutoCodingProfileTests(unittest.TestCase):
|
|
|
1729
1911
|
1,
|
|
1730
1912
|
5,
|
|
1731
1913
|
),
|
|
1914
|
+
(
|
|
1915
|
+
"self-closing-jsx.tsx",
|
|
1916
|
+
[
|
|
1917
|
+
"function CompactView({ value }: { value: string }) {",
|
|
1918
|
+
" return (",
|
|
1919
|
+
" <section>",
|
|
1920
|
+
" <Widget",
|
|
1921
|
+
" value={value}",
|
|
1922
|
+
" />",
|
|
1923
|
+
' <span title="login/payment">{value}</span>',
|
|
1924
|
+
" </section>",
|
|
1925
|
+
" );",
|
|
1926
|
+
"}",
|
|
1927
|
+
"const after = 1;",
|
|
1928
|
+
],
|
|
1929
|
+
1,
|
|
1930
|
+
10,
|
|
1931
|
+
),
|
|
1932
|
+
(
|
|
1933
|
+
"self-closing-expression-jsx.tsx",
|
|
1934
|
+
[
|
|
1935
|
+
"const CompactIcon = () => (",
|
|
1936
|
+
" <svg>",
|
|
1937
|
+
" <path",
|
|
1938
|
+
" d=\"M0 0\"",
|
|
1939
|
+
" />",
|
|
1940
|
+
' <text aria-label="login/payment">ok</text>',
|
|
1941
|
+
" </svg>",
|
|
1942
|
+
");",
|
|
1943
|
+
"const after = 1;",
|
|
1944
|
+
],
|
|
1945
|
+
1,
|
|
1946
|
+
8,
|
|
1947
|
+
),
|
|
1948
|
+
(
|
|
1949
|
+
"conditional-self-closing-jsx.tsx",
|
|
1950
|
+
[
|
|
1951
|
+
"function ConditionalView({ show }: { show: boolean }) {",
|
|
1952
|
+
" return (",
|
|
1953
|
+
" <section>",
|
|
1954
|
+
" {show && <Widget",
|
|
1955
|
+
' value="ready"',
|
|
1956
|
+
" />}",
|
|
1957
|
+
" </section>",
|
|
1958
|
+
" );",
|
|
1959
|
+
"}",
|
|
1960
|
+
"const after = 1;",
|
|
1961
|
+
],
|
|
1962
|
+
1,
|
|
1963
|
+
9,
|
|
1964
|
+
),
|
|
1965
|
+
(
|
|
1966
|
+
"conditional-self-closing-expression.tsx",
|
|
1967
|
+
[
|
|
1968
|
+
"const ConditionalView = ({ show }: { show: boolean }) => (",
|
|
1969
|
+
" <section>",
|
|
1970
|
+
" {show && <Widget",
|
|
1971
|
+
' value="ready"',
|
|
1972
|
+
" />}",
|
|
1973
|
+
" </section>",
|
|
1974
|
+
");",
|
|
1975
|
+
"const after = 1;",
|
|
1976
|
+
],
|
|
1977
|
+
1,
|
|
1978
|
+
7,
|
|
1979
|
+
),
|
|
1732
1980
|
]
|
|
1733
1981
|
trailing_top_level_lines = [f"top_level_{index} = {index}" for index in range(20)]
|
|
1734
1982
|
for path, lines, start_line, expected_size in fixtures:
|
|
@@ -1746,6 +1994,28 @@ class AutoCodingProfileTests(unittest.TestCase):
|
|
|
1746
1994
|
lines = ["def ready(): return True"] + [f"top_level_{index} = {index}" for index in range(200)]
|
|
1747
1995
|
self.assertEqual([], ap._function_size_warnings("inline.py", lines, 120))
|
|
1748
1996
|
|
|
1997
|
+
def test_multiline_arrow_declaration_has_one_size_finding(self) -> None:
|
|
1998
|
+
lines = [
|
|
1999
|
+
"const multi = (",
|
|
2000
|
+
" value: string,",
|
|
2001
|
+
") => {",
|
|
2002
|
+
*[f" const value_{index} = value;" for index in range(10)],
|
|
2003
|
+
"};",
|
|
2004
|
+
]
|
|
2005
|
+
warnings = ap._function_size_warnings("multi.ts", lines, 5)
|
|
2006
|
+
self.assertEqual(1, len(warnings), warnings)
|
|
2007
|
+
self.assertIn("multi.ts:1", warnings[0])
|
|
2008
|
+
|
|
2009
|
+
def test_same_line_fallback_uses_longest_callback(self) -> None:
|
|
2010
|
+
lines = [
|
|
2011
|
+
"consume(first => {}, second => {",
|
|
2012
|
+
*[f" const value_{index} = second;" for index in range(10)],
|
|
2013
|
+
"});",
|
|
2014
|
+
]
|
|
2015
|
+
warnings = ap._function_size_warnings("callbacks.ts", lines, 5)
|
|
2016
|
+
self.assertEqual(1, len(warnings), warnings)
|
|
2017
|
+
self.assertIn("callbacks.ts:1", warnings[0])
|
|
2018
|
+
|
|
1749
2019
|
def test_function_ranges_ignore_type_braces_regex_literals_and_prior_assignments(self) -> None:
|
|
1750
2020
|
long_body = [f" value_{index} := {index}" for index in range(130)]
|
|
1751
2021
|
go_lines = [
|
|
@@ -1767,6 +2037,207 @@ class AutoCodingProfileTests(unittest.TestCase):
|
|
|
1767
2037
|
]
|
|
1768
2038
|
self.assertEqual(1, len(ap._function_size_warnings("regex.js", js_lines, 120)))
|
|
1769
2039
|
|
|
2040
|
+
regex_gt_lines = [
|
|
2041
|
+
"function block() {",
|
|
2042
|
+
" const matcher = />}/;",
|
|
2043
|
+
*[f" const value_{index} = {index};" for index in range(130)],
|
|
2044
|
+
"}",
|
|
2045
|
+
]
|
|
2046
|
+
self.assertEqual(1, len(ap._function_size_warnings("regex-gt.js", regex_gt_lines, 120)))
|
|
2047
|
+
closing_tag_regex_lines = [
|
|
2048
|
+
"function block() {",
|
|
2049
|
+
" const matcher = /section>}/;",
|
|
2050
|
+
*[f" const value_{index} = {index};" for index in range(130)],
|
|
2051
|
+
"}",
|
|
2052
|
+
]
|
|
2053
|
+
self.assertEqual(
|
|
2054
|
+
1,
|
|
2055
|
+
len(ap._function_size_warnings("closing-tag-regex.js", closing_tag_regex_lines, 120)),
|
|
2056
|
+
)
|
|
2057
|
+
comparison_regex_lines = [
|
|
2058
|
+
"function block() {",
|
|
2059
|
+
' const matched = value</section>}/.test("section>}");',
|
|
2060
|
+
*[f" const value_{index} = {index};" for index in range(130)],
|
|
2061
|
+
"}",
|
|
2062
|
+
]
|
|
2063
|
+
self.assertEqual(
|
|
2064
|
+
1,
|
|
2065
|
+
len(ap._function_size_warnings("comparison-regex.js", comparison_regex_lines, 120)),
|
|
2066
|
+
)
|
|
2067
|
+
semicolon_regex_lines = [
|
|
2068
|
+
"function block() {",
|
|
2069
|
+
r' const matched = value</section>;\}/.test("section>;} ");',
|
|
2070
|
+
*[f" const value_{index} = {index};" for index in range(130)],
|
|
2071
|
+
"}",
|
|
2072
|
+
]
|
|
2073
|
+
self.assertEqual(
|
|
2074
|
+
1,
|
|
2075
|
+
len(ap._function_size_warnings("semicolon-regex.js", semicolon_regex_lines, 120)),
|
|
2076
|
+
)
|
|
2077
|
+
for suffix_expression in ["/}/ as RegExp", "/}/ satisfies RegExp"]:
|
|
2078
|
+
ts_regex_lines = [
|
|
2079
|
+
"function block() {",
|
|
2080
|
+
f" const matcher = {suffix_expression};",
|
|
2081
|
+
*[f" const value_{index} = {index};" for index in range(130)],
|
|
2082
|
+
"}",
|
|
2083
|
+
]
|
|
2084
|
+
with self.subTest(suffix_expression=suffix_expression):
|
|
2085
|
+
self.assertEqual(
|
|
2086
|
+
1,
|
|
2087
|
+
len(ap._function_size_warnings("regex-suffix.ts", ts_regex_lines, 120)),
|
|
2088
|
+
)
|
|
2089
|
+
for prefix_expression in [
|
|
2090
|
+
'const html = "<Tag>";',
|
|
2091
|
+
"const pattern = /<Tag>/;",
|
|
2092
|
+
"foo<Tag>();",
|
|
2093
|
+
"const typed: Box<Tag> | null = null;",
|
|
2094
|
+
"const cast = box as Box<Tag>;",
|
|
2095
|
+
"const first = <A></A>; const second = <B></B>;",
|
|
2096
|
+
]:
|
|
2097
|
+
prefixed_regex_lines = [
|
|
2098
|
+
"function block() {",
|
|
2099
|
+
f" {prefix_expression} const matched = value</section>}}/.test(text);",
|
|
2100
|
+
*[f" const value_{index} = {index};" for index in range(130)],
|
|
2101
|
+
"}",
|
|
2102
|
+
]
|
|
2103
|
+
with self.subTest(prefix_expression=prefix_expression):
|
|
2104
|
+
self.assertEqual(
|
|
2105
|
+
1,
|
|
2106
|
+
len(ap._function_size_warnings("prefixed-regex.ts", prefixed_regex_lines, 120)),
|
|
2107
|
+
)
|
|
2108
|
+
for generic_comparison in [
|
|
2109
|
+
" const matched = (box as Box<Tag>).value</section>}/.test(text);",
|
|
2110
|
+
" const matched: boolean | Box<Tag> = value</section>}/.test(text);",
|
|
2111
|
+
" const matched = (<Outer>{foo<Tag>()}</Outer>) && value</section>}/.test(text);",
|
|
2112
|
+
" const matched = (<Outer>{(box as Box<Tag>).value}</Outer>) && value</section>}/.test(text);",
|
|
2113
|
+
" const matched = (<Outer>{show && <Tag>hello</Tag>}</Outer>) && value</section>}/.test(text);",
|
|
2114
|
+
" const matched = (<Outer>hello<Tag>world</Tag></Outer>) && value</section>}/.test(text);",
|
|
2115
|
+
]:
|
|
2116
|
+
generic_regex_lines = [
|
|
2117
|
+
"function block() {",
|
|
2118
|
+
generic_comparison,
|
|
2119
|
+
*[f" const value_{index} = {index};" for index in range(130)],
|
|
2120
|
+
"}",
|
|
2121
|
+
]
|
|
2122
|
+
with self.subTest(generic_comparison=generic_comparison):
|
|
2123
|
+
self.assertEqual(
|
|
2124
|
+
1,
|
|
2125
|
+
len(ap._function_size_warnings("generic-regex.ts", generic_regex_lines, 120)),
|
|
2126
|
+
)
|
|
2127
|
+
comparison = "const matched = value</>}/.test(text);"
|
|
2128
|
+
self.assertTrue(ap._looks_like_regex_start(comparison, comparison.index("/")))
|
|
2129
|
+
named_comparison = "const matched = value</section>}/.test(text);"
|
|
2130
|
+
self.assertTrue(ap._looks_like_regex_start(named_comparison, named_comparison.index("/")))
|
|
2131
|
+
assigned = "const matcher = /section>}/;"
|
|
2132
|
+
self.assertTrue(ap._looks_like_regex_start(assigned, assigned.index("/")))
|
|
2133
|
+
returned = "return /foo>/;"
|
|
2134
|
+
self.assertTrue(ap._looks_like_regex_start(returned, returned.index("/")))
|
|
2135
|
+
self.assertFalse(ap._looks_like_regex_start(" />", 4))
|
|
2136
|
+
self.assertFalse(ap._looks_like_regex_start(" </section>", 5))
|
|
2137
|
+
self.assertFalse(ap._looks_like_regex_start(" </_Private>", 5))
|
|
2138
|
+
self.assertFalse(ap._looks_like_regex_start(" </$Component>", 5))
|
|
2139
|
+
self.assertFalse(ap._looks_like_regex_start(" />}", 4))
|
|
2140
|
+
self.assertFalse(ap._looks_like_regex_start(" /> : null}", 4))
|
|
2141
|
+
jsx_close_same_line = " />}</section>;"
|
|
2142
|
+
self.assertFalse(ap._looks_like_regex_start(jsx_close_same_line, 4))
|
|
2143
|
+
|
|
2144
|
+
jsx_block = [
|
|
2145
|
+
"function F() {",
|
|
2146
|
+
" return <section>",
|
|
2147
|
+
" {show && <Widget",
|
|
2148
|
+
" x={1}",
|
|
2149
|
+
" />}</section>;",
|
|
2150
|
+
*[f" const value_{index} = {index};" for index in range(130)],
|
|
2151
|
+
"}",
|
|
2152
|
+
]
|
|
2153
|
+
self.assertEqual(1, len(ap._function_size_warnings("jsx-block.tsx", jsx_block, 120)))
|
|
2154
|
+
|
|
2155
|
+
jsx_expression = [
|
|
2156
|
+
"const F = () => (",
|
|
2157
|
+
" <section>",
|
|
2158
|
+
" {show && <Widget",
|
|
2159
|
+
" x={1}",
|
|
2160
|
+
" />}</section>",
|
|
2161
|
+
");",
|
|
2162
|
+
"const after = 1;",
|
|
2163
|
+
]
|
|
2164
|
+
arrow_location = ap._find_arrow_locations(jsx_expression, 0, None)[0]
|
|
2165
|
+
self.assertEqual(
|
|
2166
|
+
(6, False),
|
|
2167
|
+
ap._expression_arrow_end(jsx_expression, 0, arrow_location, 6, None, ".tsx"),
|
|
2168
|
+
)
|
|
2169
|
+
self.assertEqual([], ap._function_size_warnings("jsx-expression.tsx", jsx_expression, 6))
|
|
2170
|
+
|
|
2171
|
+
trailing_jsx_expressions = [
|
|
2172
|
+
["const F = () => <Tag></Tag>; // comment", "const after = 1;"],
|
|
2173
|
+
["const F = () => <Tag></Tag>; /* comment */", "const after = 1;"],
|
|
2174
|
+
["const F = () => <Tag></Tag> / divisor;", "const after = 1;"],
|
|
2175
|
+
["const F = () => <Tag>hello</Tag>/(divisor);", "const after = 1;"],
|
|
2176
|
+
["const F = () => <></>; // comment", "const after = 1;"],
|
|
2177
|
+
[
|
|
2178
|
+
"const F = () => (",
|
|
2179
|
+
" <Widget",
|
|
2180
|
+
" value={1}",
|
|
2181
|
+
" />); // comment",
|
|
2182
|
+
"const after = 1;",
|
|
2183
|
+
],
|
|
2184
|
+
]
|
|
2185
|
+
for expression in trailing_jsx_expressions:
|
|
2186
|
+
with self.subTest(expression=expression):
|
|
2187
|
+
arrow_location = ap._find_arrow_locations(expression, 0, None)[0]
|
|
2188
|
+
expected_end = len(expression) - 1
|
|
2189
|
+
self.assertEqual(
|
|
2190
|
+
(expected_end, False),
|
|
2191
|
+
ap._expression_arrow_end(
|
|
2192
|
+
expression, 0, arrow_location, expected_end, None, ".tsx"
|
|
2193
|
+
),
|
|
2194
|
+
)
|
|
2195
|
+
self.assertEqual(
|
|
2196
|
+
[],
|
|
2197
|
+
ap._function_size_warnings("trailing-jsx.tsx", expression, expected_end),
|
|
2198
|
+
)
|
|
2199
|
+
|
|
2200
|
+
multiline_jsx_text = [
|
|
2201
|
+
"const F = () => (",
|
|
2202
|
+
" <Tag>",
|
|
2203
|
+
" hello</Tag>/(divisor)",
|
|
2204
|
+
");",
|
|
2205
|
+
"const after = 1;",
|
|
2206
|
+
]
|
|
2207
|
+
arrow_location = ap._find_arrow_locations(multiline_jsx_text, 0, None)[0]
|
|
2208
|
+
self.assertEqual(
|
|
2209
|
+
(4, False),
|
|
2210
|
+
ap._expression_arrow_end(multiline_jsx_text, 0, arrow_location, 4, None, ".tsx"),
|
|
2211
|
+
)
|
|
2212
|
+
self.assertEqual([], ap._function_size_warnings("multiline-jsx.tsx", multiline_jsx_text, 4))
|
|
2213
|
+
|
|
2214
|
+
for jsx_expression_body in [
|
|
2215
|
+
' {value</section>}/.test(text) ? "yes" : "no"}',
|
|
2216
|
+
' {/>}/.test(text) ? "yes" : "no"}',
|
|
2217
|
+
]:
|
|
2218
|
+
jsx_regex_expression = [
|
|
2219
|
+
"const F = () => <Tag>",
|
|
2220
|
+
jsx_expression_body,
|
|
2221
|
+
"</Tag>;",
|
|
2222
|
+
"const after = 1;",
|
|
2223
|
+
]
|
|
2224
|
+
with self.subTest(jsx_expression_body=jsx_expression_body):
|
|
2225
|
+
arrow_location = ap._find_arrow_locations(jsx_regex_expression, 0, None)[0]
|
|
2226
|
+
self.assertEqual(
|
|
2227
|
+
(3, False),
|
|
2228
|
+
ap._expression_arrow_end(
|
|
2229
|
+
jsx_regex_expression, 0, arrow_location, 3, None, ".tsx"
|
|
2230
|
+
),
|
|
2231
|
+
)
|
|
2232
|
+
self.assertEqual(
|
|
2233
|
+
1,
|
|
2234
|
+
len(
|
|
2235
|
+
ap._function_size_warnings(
|
|
2236
|
+
"jsx-regex-expression.tsx", jsx_regex_expression, 2
|
|
2237
|
+
)
|
|
2238
|
+
),
|
|
2239
|
+
)
|
|
2240
|
+
|
|
1770
2241
|
separate_declarations = [
|
|
1771
2242
|
'const label = "ready"',
|
|
1772
2243
|
"const block = () => {",
|
package/cli/tests/index.test.js
CHANGED
|
@@ -314,7 +314,7 @@ function testInitFullyConvergesExistingProject() {
|
|
|
314
314
|
}
|
|
315
315
|
assert(exists(path.join(repo, ".agents", "agents", "custom.toml")), "project-owned custom agents must survive init");
|
|
316
316
|
assert(!exists(path.join(repo, ".agents", "skills", "auto-coding-skill", "obsolete.txt")), "extra Skill files must be removed");
|
|
317
|
-
assert(exists(path.join(repo, ".agents", "archive", "auto-coding-skill", "4.2.
|
|
317
|
+
assert(exists(path.join(repo, ".agents", "archive", "auto-coding-skill", "4.2.5", "docs", "legacy", "old-taskbook.md")), "removed docs must be archived outside active docs");
|
|
318
318
|
assert(fs.readFileSync(structureStandard, "utf8") === customStructureStandard, "init must preserve a project-owned structure standard");
|
|
319
319
|
assert(fs.readFileSync(path.join(repo, "docs", "architecture", "adr", "0042-project-choice.md"), "utf8").includes("Keep me"), "numbered ADR artifacts must survive init");
|
|
320
320
|
assert(fs.readFileSync(path.join(repo, "docs", "architecture", "system-context.md"), "utf8").includes("Keep me"), "architecture artifacts must survive init");
|
|
@@ -440,7 +440,7 @@ function testMinimalInitConvergesWithinBudget() {
|
|
|
440
440
|
// Integrity, staging, fail-closed classification, contract helpers, and the
|
|
441
441
|
// language-aware structure scanner are executable support code, not prompt
|
|
442
442
|
// context. Keep a measured ceiling while leaving deterministic checks readable.
|
|
443
|
-
assert(lines <=
|
|
443
|
+
assert(lines <= 15120, `minimal scaffold line budget exceeded: ${lines}`);
|
|
444
444
|
const engineering = fs.readFileSync(path.join(repo, "docs", "ENGINEERING.md"), "utf8");
|
|
445
445
|
assert(engineering.includes("profile: auto"), "engineering should enable adaptive profiles");
|
|
446
446
|
assert(engineering.includes("isolation: adaptive"), "engineering should default to adaptive clean-branch/worktree isolation");
|
|
@@ -979,7 +979,7 @@ function testManagedEngineeringInitIsAuthoritativeAndIdempotent() {
|
|
|
979
979
|
|
|
980
980
|
const engineering = path.join(repo, "docs", "ENGINEERING.md");
|
|
981
981
|
const initial = fs.readFileSync(engineering, "utf8");
|
|
982
|
-
const startPattern = /<!-- auto-coding-skill:managed-workflow:start version=4\.2\.
|
|
982
|
+
const startPattern = /<!-- auto-coding-skill:managed-workflow:start version=4\.2\.5 -->/;
|
|
983
983
|
const endMarker = "<!-- auto-coding-skill:managed-workflow:end -->";
|
|
984
984
|
assert(startPattern.test(initial), "new projects should include a versioned managed workflow marker");
|
|
985
985
|
assert(initial.includes(endMarker), "new projects should include the managed workflow end marker");
|
|
@@ -993,21 +993,21 @@ function testManagedEngineeringInitIsAuthoritativeAndIdempotent() {
|
|
|
993
993
|
const dryRun = run("node", [cli, "sync", "--projects", repo, "--dry-run", "--json"]);
|
|
994
994
|
const dryResult = JSON.parse(dryRun.stdout).results[0];
|
|
995
995
|
assert(dryResult.managedWorkflow.state === "stale", `dry-run should expose stale workflow state: ${dryRun.stdout}`);
|
|
996
|
-
assert(dryResult.managedWorkflow.version === "4.2.
|
|
996
|
+
assert(dryResult.managedWorkflow.version === "4.2.5", "dry-run should expose the target workflow version");
|
|
997
997
|
assert(dryResult.actions.some(item => item.action === "would-update" && item.path === "docs/ENGINEERING.md"), "dry-run should plan the managed body update");
|
|
998
998
|
assert(fs.readFileSync(engineering, "utf8") === customized, "dry-run must not write ENGINEERING.md");
|
|
999
999
|
|
|
1000
1000
|
run("node", [cli, "init"], { cwd: repo });
|
|
1001
1001
|
const updated = fs.readFileSync(engineering, "utf8");
|
|
1002
1002
|
assert(!updated.includes("project note before") && !updated.includes("project note after"), "init must remove text outside the canonical ENGINEERING body");
|
|
1003
|
-
assert(updated.includes("version=4.2.
|
|
1003
|
+
assert(updated.includes("version=4.2.5"), "init should install the current managed workflow version");
|
|
1004
1004
|
assert(updated.includes("The frontmatter contract is:"), "init should refresh stale managed workflow content");
|
|
1005
1005
|
|
|
1006
1006
|
fillRequiredAccess(repo);
|
|
1007
1007
|
const status = run("node", [cli, "status", "--projects", repo, "--json"]);
|
|
1008
1008
|
const statusResult = JSON.parse(status.stdout).results[0];
|
|
1009
1009
|
assert(statusResult.managedWorkflow.state === "current", `status should expose current managed workflow state: ${status.stdout}`);
|
|
1010
|
-
assert(statusResult.managedWorkflow.version === "4.2.
|
|
1010
|
+
assert(statusResult.managedWorkflow.version === "4.2.5", "status should expose the installed managed workflow version");
|
|
1011
1011
|
|
|
1012
1012
|
const beforeSecondInit = fs.readFileSync(engineering, "utf8");
|
|
1013
1013
|
run("node", [cli, "init"], { cwd: repo });
|
|
@@ -1034,7 +1034,7 @@ function testLegacyEngineeringMigrationPreservesExistingBody() {
|
|
|
1034
1034
|
assert(dryResult.actions.find(item => item.path === "docs/ENGINEERING.md")?.detail.includes("preserved-custom"), "custom legacy action should be labeled preserved-custom");
|
|
1035
1035
|
run("node", [cli, "sync", "--projects", repo]);
|
|
1036
1036
|
const migrated = fs.readFileSync(engineering, "utf8");
|
|
1037
|
-
assert(migrated.includes("version=4.2.
|
|
1037
|
+
assert(migrated.includes("version=4.2.5"), "legacy migration should insert the current managed workflow");
|
|
1038
1038
|
assert(migrated.includes(legacyNote), "legacy migration must preserve the complete existing body");
|
|
1039
1039
|
const stable = fs.readFileSync(engineering, "utf8");
|
|
1040
1040
|
run("node", [cli, "sync", "--projects", repo]);
|
|
@@ -1134,7 +1134,7 @@ function testManagedAgentsMigrationReplacesWholeFileAndArchivesPreviousRules() {
|
|
|
1134
1134
|
run("node", [cli, "sync", "--projects", repo]);
|
|
1135
1135
|
const agents = path.join(repo, "AGENTS.md");
|
|
1136
1136
|
const initial = fs.readFileSync(agents, "utf8");
|
|
1137
|
-
assert(initial.includes("managed-agents:start version=4.2.
|
|
1137
|
+
assert(initial.includes("managed-agents:start version=4.2.5"), "new projects should receive the versioned root AGENTS block");
|
|
1138
1138
|
|
|
1139
1139
|
const custom = [
|
|
1140
1140
|
"# Project rules",
|
|
@@ -1153,12 +1153,12 @@ function testManagedAgentsMigrationReplacesWholeFileAndArchivesPreviousRules() {
|
|
|
1153
1153
|
|
|
1154
1154
|
run("node", [cli, "sync", "--projects", repo]);
|
|
1155
1155
|
const migrated = fs.readFileSync(agents, "utf8");
|
|
1156
|
-
assert(migrated.includes("managed-agents:start version=4.2.
|
|
1156
|
+
assert(migrated.includes("managed-agents:start version=4.2.5"), "AGENTS migration should install the current managed block");
|
|
1157
1157
|
assert(!migrated.includes("Preserve this repository-specific rule exactly."), "root AGENTS must contain no project-specific tail");
|
|
1158
1158
|
assert(!migrated.includes("must execute `commands.gate_full`"), "known official conflicting rule should be removed");
|
|
1159
1159
|
const canonical = fs.readFileSync(path.join(repoRoot, "cli", "assets", "skill", "data", "templates", "bridges", "AGENTS.md"), "utf8");
|
|
1160
1160
|
assert(migrated === canonical, "root AGENTS must be byte-identical to the packaged canonical file");
|
|
1161
|
-
const archive = path.join(repo, "docs", "archive", "workflow", "AGENTS.pre-4.2.
|
|
1161
|
+
const archive = path.join(repo, "docs", "archive", "workflow", "AGENTS.pre-4.2.5.md");
|
|
1162
1162
|
assert(fs.readFileSync(archive, "utf8").includes("Preserve this repository-specific rule exactly."), "previous AGENTS content must be archived once");
|
|
1163
1163
|
const stable = fs.readFileSync(agents);
|
|
1164
1164
|
run("node", [cli, "sync", "--projects", repo]);
|
|
@@ -1215,7 +1215,7 @@ function testEngineeringFrameworkRejectsAnyNonCanonicalWorkflowText() {
|
|
|
1215
1215
|
|
|
1216
1216
|
run("node", [cli, "init"], { cwd: repo });
|
|
1217
1217
|
assert(!fs.readFileSync(engineering, "utf8").includes("backend owns APIs"), "init must restore the canonical ENGINEERING body");
|
|
1218
|
-
const archived = path.join(repo, ".agents", "archive", "auto-coding-skill", "4.2.
|
|
1218
|
+
const archived = path.join(repo, ".agents", "archive", "auto-coding-skill", "4.2.5", "docs", "ENGINEERING.md");
|
|
1219
1219
|
assert(fs.readFileSync(archived, "utf8").includes("backend owns APIs"), "removed project text should remain in non-authoritative history");
|
|
1220
1220
|
}
|
|
1221
1221
|
|
|
@@ -1227,12 +1227,12 @@ function testManagedInstallIntegrityIsBoundedAndRepairable() {
|
|
|
1227
1227
|
|
|
1228
1228
|
const manifestPath = path.join(repo, ".agents", "managed-install.json");
|
|
1229
1229
|
const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
|
|
1230
|
-
assert(manifest.schema_version === 1 && manifest.skill_version === "4.2.
|
|
1230
|
+
assert(manifest.schema_version === 1 && manifest.skill_version === "4.2.5", "installed manifest must identify the release");
|
|
1231
1231
|
assert(manifest.entries.length > 0, "installed manifest must list managed files");
|
|
1232
1232
|
for (const entry of manifest.entries) {
|
|
1233
1233
|
assert(typeof entry.path === "string" && !path.isAbsolute(entry.path) && !entry.path.includes(".."), "manifest paths must be safe relative paths");
|
|
1234
1234
|
assert(/^[0-9a-f]{64}$/.test(entry.sha256), `${entry.path}: manifest hash must be sha256`);
|
|
1235
|
-
assert(entry.version === "4.2.
|
|
1235
|
+
assert(entry.version === "4.2.5" && typeof entry.executable === "boolean", `${entry.path}: version/executable metadata missing`);
|
|
1236
1236
|
}
|
|
1237
1237
|
assert(!manifest.managed_namespaces.some(item => item.path === ".agents" || item.path === "docs"), "manifest must not mirror entire project-owned trees");
|
|
1238
1238
|
|
|
@@ -1302,14 +1302,14 @@ function testManagedInstallIntegrityIsBoundedAndRepairable() {
|
|
|
1302
1302
|
}
|
|
1303
1303
|
|
|
1304
1304
|
function testReleaseVersionMarkersStayInSync() {
|
|
1305
|
-
const expected = "4.2.
|
|
1305
|
+
const expected = "4.2.5";
|
|
1306
1306
|
const pkg = JSON.parse(fs.readFileSync(path.join(repoRoot, "package.json"), "utf8"));
|
|
1307
1307
|
const lock = JSON.parse(fs.readFileSync(path.join(repoRoot, "package-lock.json"), "utf8"));
|
|
1308
1308
|
const policy = JSON.parse(fs.readFileSync(
|
|
1309
1309
|
path.join(repoRoot, "src", "auto-coding-skill", "data", "policies", "workflow-migrations-v1.json"),
|
|
1310
1310
|
"utf8",
|
|
1311
1311
|
));
|
|
1312
|
-
assert(pkg.version === expected, "package version must match the 4.2.
|
|
1312
|
+
assert(pkg.version === expected, "package version must match the 4.2.5 release");
|
|
1313
1313
|
assert(lock.version === expected && lock.packages[""].version === expected, "package-lock versions must match");
|
|
1314
1314
|
assert(policy.managed_versions.engineering === expected && policy.managed_versions.agents === expected, "managed workflow versions must match");
|
|
1315
1315
|
const manifest = JSON.parse(fs.readFileSync(path.join(repoRoot, "cli", "assets", "managed-install.json"), "utf8"));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elvis1513/auto-coding-skill",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.5",
|
|
4
4
|
"description": "CLI installer for a delivery-first .agents workflow with adaptive Git isolation, routed changed-scope validation, risk-based review, push completion, and safe cleanup.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|