@elvis1513/auto-coding-skill 4.1.1 → 4.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -8
- package/cli/assets/skill/SKILL.md +30 -25
- package/cli/assets/skill/data/contracts/orchestration-v1.schema.json +7 -1
- package/cli/assets/skill/data/policies/workflow-migrations-v1.json +2 -2
- package/cli/assets/skill/data/templates/ENGINEERING.md +6 -6
- package/cli/assets/skill/data/templates/bridges/AGENTS.md +14 -10
- package/cli/assets/skill/scripts/ap.py +233 -89
- package/cli/src/check-package.js +38 -0
- package/cli/src/index.js +5 -5
- package/cli/tests/ap_concurrency_test.py +24 -0
- package/cli/tests/ap_profiles_test.py +78 -4
- package/cli/tests/index.test.js +11 -11
- package/package.json +5 -2
- package/cli/assets/skill/scripts/__pycache__/core.cpython-314.pyc +0 -0
- package/cli/assets/skill/scripts/__pycache__/scaffold_templates.cpython-314.pyc +0 -0
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.1.
|
|
12
|
+
Version 4.1.2 makes the workflow decision explicit: mechanisms are required,
|
|
13
|
+
model-selectable when beneficial, or forbidden for the current task. Version
|
|
14
|
+
4.1.1 consolidated the 4.x delivery-first workflow into one canonical
|
|
13
15
|
repository contract. Version 4.0 replaced the 3.x governance-first defaults with progressive
|
|
14
16
|
guardrails. Clean single-writer work stays on the current branch. Worktrees,
|
|
15
17
|
parallel fixers, fingerprint review, durable design records, and stronger
|
|
@@ -65,8 +67,11 @@ The result includes:
|
|
|
65
67
|
- `execution_mode=isolated`: dirty checkout, explicit isolation, or multiple writers.
|
|
66
68
|
- `execution_mode=none`: no task signal or change; create no branch/worktree.
|
|
67
69
|
- `review_required` and `design_required`: risk-based escalation decisions.
|
|
70
|
+
- `task_kind`: `read_only`, `change`, `terminal_maintenance`, or `none`.
|
|
68
71
|
- `mechanism_plan.required`: the complete minimum mechanism set for the task.
|
|
69
|
-
- `mechanism_plan.
|
|
72
|
+
- `mechanism_plan.optional_when_beneficial`: model-selectable mechanisms whose
|
|
73
|
+
expected benefit must exceed coordination cost.
|
|
74
|
+
- `mechanism_plan.forbidden`: mechanisms that stay off unless the user overrides.
|
|
70
75
|
- an adaptive agent plan that does not force fan-out for ordinary work.
|
|
71
76
|
|
|
72
77
|
Clean serial work proceeds directly on the current branch with normal Git; it does
|
|
@@ -75,7 +80,7 @@ requires isolation/review or the user explicitly requests lifecycle tracking:
|
|
|
75
80
|
|
|
76
81
|
```bash
|
|
77
82
|
python3 docs/tools/autopipeline/ap.py task-start T0001 \
|
|
78
|
-
--owned-path backend/internal/orders
|
|
83
|
+
--owned-path backend/internal/orders --force-lifecycle
|
|
79
84
|
python3 docs/tools/autopipeline/ap.py commit-push T0001 \
|
|
80
85
|
--msg "T0001: fix order retry"
|
|
81
86
|
```
|
|
@@ -90,8 +95,9 @@ Dirty or parallel work receives an isolated task branch/worktree:
|
|
|
90
95
|
python3 docs/tools/autopipeline/ap.py task-start T0002 \
|
|
91
96
|
--owned-path backend --review-required
|
|
92
97
|
# implement in the printed worktree
|
|
98
|
+
python3 docs/tools/autopipeline/ap.py task-status T0002 --json
|
|
93
99
|
python3 docs/tools/autopipeline/ap.py task-review T0002 \
|
|
94
|
-
--verdict approved --diff-fingerprint "$
|
|
100
|
+
--verdict approved --diff-fingerprint "$CURRENT_DIFF_FINGERPRINT"
|
|
95
101
|
python3 docs/tools/autopipeline/ap.py commit-push T0002 \
|
|
96
102
|
--msg "T0002: bounded change"
|
|
97
103
|
python3 docs/tools/autopipeline/ap.py task-integrate T0002
|
|
@@ -122,6 +128,7 @@ validation:
|
|
|
122
128
|
- name: backend
|
|
123
129
|
paths: ["backend/**", "contracts/**"]
|
|
124
130
|
commands: [backend_fast]
|
|
131
|
+
timeout_seconds: 90
|
|
125
132
|
- name: frontend
|
|
126
133
|
paths: ["frontend/**"]
|
|
127
134
|
commands: [frontend_fast]
|
|
@@ -152,9 +159,10 @@ closure gate is limited to one stable-diff run. Full regression, Docker, builds,
|
|
|
152
159
|
Jenkins, deployment, API verification, and target checks remain explicit
|
|
153
160
|
diagnostics outside normal closure.
|
|
154
161
|
|
|
155
|
-
The final closure
|
|
156
|
-
seconds total
|
|
157
|
-
route
|
|
162
|
+
The recommended final closure defaults are 120 seconds per command and 180
|
|
163
|
+
seconds total. Projects may raise them for measured affected-scope checks or set
|
|
164
|
+
a smaller `timeout_seconds` on a route. A timeout calls for a narrower route and
|
|
165
|
+
never triggers a broader fallback.
|
|
158
166
|
|
|
159
167
|
## Risk and subagent policy
|
|
160
168
|
|
|
@@ -192,11 +200,25 @@ project-specific facts outside the managed ENGINEERING block. Root `AGENTS.md` i
|
|
|
192
200
|
replaced as a whole; its previous content is archived under
|
|
193
201
|
`docs/archive/workflow/` as historical, non-authoritative context.
|
|
194
202
|
|
|
203
|
+
## What changed in 4.1.2
|
|
204
|
+
|
|
205
|
+
- Added explicit read-only, change, and terminal-maintenance task kinds so
|
|
206
|
+
intent-only questions cannot accidentally trigger code-delivery machinery.
|
|
207
|
+
- Split mechanism planning into required, model-selectable, and forbidden sets;
|
|
208
|
+
read-only discovery agents remain available when they save time or add needed
|
|
209
|
+
expertise.
|
|
210
|
+
- Made 120/180-second gate budgets recommended defaults, added route-level
|
|
211
|
+
timeouts, and kept project-specific affected-scope overrides valid.
|
|
212
|
+
- Rejected unnecessary lifecycle creation before access checks, fetching, locks,
|
|
213
|
+
or branch work; corrected the review lifecycle examples.
|
|
214
|
+
- Added a release-package assertion and prepack cache cleanup so generated Python
|
|
215
|
+
caches cannot leak into the npm tarball.
|
|
216
|
+
|
|
195
217
|
## What changed in 4.1.1
|
|
196
218
|
|
|
197
219
|
- Added a machine-readable minimum mechanism plan and rejected unnecessary clean
|
|
198
220
|
serial task lifecycles unless explicitly requested.
|
|
199
|
-
- Added
|
|
221
|
+
- Added bounded per-command and total time budgets for the final changed-scope gate.
|
|
200
222
|
- Made root `AGENTS.md` the sole behavioral protocol, reduced `SKILL.md` to
|
|
201
223
|
invocation guidance, and reduced `ENGINEERING.md` to project configuration and
|
|
202
224
|
facts.
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: auto-coding-skill
|
|
3
|
-
description:
|
|
3
|
+
description: Optional delivery-first engineering workflow for repository changes. Use when its bounded validation, adaptive Git isolation, review, or coordination will improve delivery speed or defect prevention. Keep clean serial work on the current branch and let the model select beneficial design or subagents without turning them into mandatory ceremony.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Auto Coding Skill
|
|
7
7
|
|
|
8
8
|
## Use the two authorities
|
|
9
9
|
|
|
10
|
-
Read root `AGENTS.md` for the shared behavioral protocol
|
|
11
|
-
`docs/ENGINEERING.md`
|
|
12
|
-
|
|
13
|
-
from historical task documents.
|
|
10
|
+
Read root `AGENTS.md` for the shared behavioral protocol and
|
|
11
|
+
`docs/ENGINEERING.md` for project facts, access, risk, validation, and budgets.
|
|
12
|
+
Do not reconstruct or duplicate those rules from historical task documents.
|
|
14
13
|
|
|
15
14
|
Normal delivery is:
|
|
16
15
|
|
|
@@ -19,24 +18,32 @@ changed-scope gate → commit/push`.
|
|
|
19
18
|
|
|
20
19
|
## Select the minimum mechanism set
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
ledger maintenance
|
|
21
|
+
Read-only questions need no workflow command. Obvious clean serial edits and
|
|
22
|
+
terminal ledger maintenance may follow root `AGENTS.md` directly. When task kind,
|
|
23
|
+
impact, risk, or concurrency is unclear, run:
|
|
24
24
|
|
|
25
25
|
```bash
|
|
26
26
|
python3 docs/tools/autopipeline/ap.py classify --scope auto \
|
|
27
|
-
--planned-path <PATH> --intent "<intent>" [--writers <N>]
|
|
27
|
+
--planned-path <PATH> --intent "<intent>" [--writers <N>] \
|
|
28
|
+
[--task-kind read_only|change|terminal_maintenance]
|
|
28
29
|
```
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
`
|
|
32
|
-
|
|
31
|
+
Run `mechanism_plan.required`. The model may select
|
|
32
|
+
`optional_when_beneficial` only when expected value exceeds coordination cost.
|
|
33
|
+
Do not run `forbidden` mechanisms unless the user explicitly overrides the plan.
|
|
34
|
+
Reclassify only when task kind, scope, risk, or writer count materially changes.
|
|
35
|
+
Ordinary direct work does not create a task lifecycle.
|
|
33
36
|
|
|
34
37
|
Use the registered lifecycle only when classification requires isolation or
|
|
35
38
|
fingerprinted review, or when the user explicitly requests it:
|
|
36
39
|
|
|
37
40
|
```bash
|
|
38
41
|
python3 docs/tools/autopipeline/ap.py task-start T0001 \
|
|
39
|
-
--owned-path src [--isolated] [--review-required]
|
|
42
|
+
--owned-path src [--isolated] [--review-required] [--force-lifecycle]
|
|
43
|
+
# For review-required work, obtain the current fingerprint and approve it:
|
|
44
|
+
python3 docs/tools/autopipeline/ap.py task-status T0001 --json
|
|
45
|
+
python3 docs/tools/autopipeline/ap.py task-review T0001 \
|
|
46
|
+
--verdict approved --diff-fingerprint <CURRENT_DIFF_FINGERPRINT>
|
|
40
47
|
python3 docs/tools/autopipeline/ap.py commit-push T0001 --msg "T0001: summary"
|
|
41
48
|
# Isolated tasks only:
|
|
42
49
|
python3 docs/tools/autopipeline/ap.py task-integrate T0001
|
|
@@ -54,21 +61,20 @@ python3 docs/tools/autopipeline/ap.py light-gate --scope changed --explain
|
|
|
54
61
|
```
|
|
55
62
|
|
|
56
63
|
Every changed code/config path must map to a real project command. The runtime
|
|
57
|
-
de-duplicates
|
|
58
|
-
|
|
59
|
-
|
|
64
|
+
de-duplicates commands and enforces route, command, and total budgets. Defaults
|
|
65
|
+
are 120 seconds per command and 180 total; projects may raise them for a measured
|
|
66
|
+
affected-scope check. Timeouts should narrow the route, never trigger a full build.
|
|
67
|
+
Focused test/fix/retest loops remain allowed before the final gate.
|
|
60
68
|
|
|
61
69
|
Run full regression, Docker, Jenkins, deployment, browser/device writes, or target
|
|
62
|
-
acceptance only as an explicit diagnostic.
|
|
63
|
-
|
|
64
|
-
new ledger lifecycle.
|
|
70
|
+
acceptance only as an explicit diagnostic. A requested just-pushed failure
|
|
71
|
+
diagnosis continues in the same task without inventing another lifecycle.
|
|
65
72
|
|
|
66
73
|
## Keep state and upgrades safe
|
|
67
74
|
|
|
68
|
-
Machine task state, leases, fingerprints, and gate evidence stay in Git
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
and commits once without creating another lifecycle.
|
|
75
|
+
Machine task state, leases, fingerprints, and gate evidence stay in Git local
|
|
76
|
+
state. Ordinary work creates no taskbook, closure, evidence JSONL, active-task,
|
|
77
|
+
or design artifact. Terminal ledger reconciliation validates and commits once.
|
|
72
78
|
|
|
73
79
|
```bash
|
|
74
80
|
autocoding init
|
|
@@ -78,6 +84,5 @@ python3 docs/tools/autopipeline/ap.py upgrade --write
|
|
|
78
84
|
python3 docs/tools/autopipeline/ap.py doctor
|
|
79
85
|
```
|
|
80
86
|
|
|
81
|
-
Finish registered tasks before changing
|
|
82
|
-
|
|
83
|
-
and access values, and converges all managed Skill/runtime/agent assets together.
|
|
87
|
+
Finish registered tasks before changing versions. Sync replaces root `AGENTS.md`,
|
|
88
|
+
archives it, preserves project facts/access, and converges all managed assets.
|
|
@@ -13,9 +13,11 @@
|
|
|
13
13
|
},
|
|
14
14
|
"mechanismPlan": {
|
|
15
15
|
"type": "object",
|
|
16
|
-
"required": ["required", "not_required", "lifecycle_required", "rule"],
|
|
16
|
+
"required": ["required", "optional_when_beneficial", "forbidden", "not_required", "lifecycle_required", "rule"],
|
|
17
17
|
"properties": {
|
|
18
18
|
"required": { "$ref": "#/$defs/stringArray" },
|
|
19
|
+
"optional_when_beneficial": { "$ref": "#/$defs/stringArray" },
|
|
20
|
+
"forbidden": { "$ref": "#/$defs/stringArray" },
|
|
19
21
|
"not_required": { "$ref": "#/$defs/stringArray" },
|
|
20
22
|
"lifecycle_required": { "type": "boolean" },
|
|
21
23
|
"rule": { "type": "string", "minLength": 1 }
|
|
@@ -452,6 +454,7 @@
|
|
|
452
454
|
"classification_files",
|
|
453
455
|
"intent_provided",
|
|
454
456
|
"intent_categories",
|
|
457
|
+
"task_kind",
|
|
455
458
|
"profile",
|
|
456
459
|
"categories",
|
|
457
460
|
"recommended_agents",
|
|
@@ -480,6 +483,9 @@
|
|
|
480
483
|
"intent_categories": {
|
|
481
484
|
"$ref": "#/$defs/stringArray"
|
|
482
485
|
},
|
|
486
|
+
"task_kind": {
|
|
487
|
+
"enum": ["none", "read_only", "change", "terminal_maintenance"]
|
|
488
|
+
},
|
|
483
489
|
"profile": {
|
|
484
490
|
"enum": [
|
|
485
491
|
"micro",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
workflow:
|
|
3
|
-
skill_version: "4.1.
|
|
3
|
+
skill_version: "4.1.2"
|
|
4
4
|
mode: "dev"
|
|
5
5
|
profile: "auto"
|
|
6
6
|
completion: "push"
|
|
@@ -56,8 +56,8 @@ commands:
|
|
|
56
56
|
|
|
57
57
|
validation:
|
|
58
58
|
on_unmapped: "error"
|
|
59
|
-
#
|
|
60
|
-
#
|
|
59
|
+
# Recommended fast defaults. Raise only for a measured affected-scope check;
|
|
60
|
+
# an individual route may set a smaller timeout_seconds.
|
|
61
61
|
max_command_seconds: 120
|
|
62
62
|
max_total_seconds: 180
|
|
63
63
|
# Initialization must replace this with real path-to-command mappings. Empty
|
|
@@ -94,7 +94,7 @@ docs:
|
|
|
94
94
|
|
|
95
95
|
# Engineering Configuration and Project Facts
|
|
96
96
|
|
|
97
|
-
<!-- auto-coding-skill:managed-workflow:start version=4.1.
|
|
97
|
+
<!-- auto-coding-skill:managed-workflow:start version=4.1.2 -->
|
|
98
98
|
|
|
99
99
|
Root `AGENTS.md` is the single shared behavioral protocol. The installed
|
|
100
100
|
`SKILL.md` contains invocation guidance. This file is the single source for the
|
|
@@ -107,8 +107,8 @@ The frontmatter contract is:
|
|
|
107
107
|
- `concurrency`: target branch and adaptive isolation settings.
|
|
108
108
|
- `commands`: project-native executable commands.
|
|
109
109
|
- `validation`: explicit path-to-command routes plus the bounded final-gate time
|
|
110
|
-
budget. Code/config paths must be mapped;
|
|
111
|
-
|
|
110
|
+
budget. Code/config paths must be mapped; route-level `timeout_seconds` can
|
|
111
|
+
bound a slower command without changing the project defaults.
|
|
112
112
|
- `risk`: project-specific signals that increase design/review depth but never
|
|
113
113
|
expand the automatic local gate.
|
|
114
114
|
- `structure` and `optimization`: advisory architecture and no-new-debt policy.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<!-- auto-coding-skill:managed-agents:start version=4.1.
|
|
1
|
+
<!-- auto-coding-skill:managed-agents:start version=4.1.2 -->
|
|
2
2
|
# Shared Engineering Protocol
|
|
3
3
|
|
|
4
4
|
This file is fully managed by `auto-coding-skill`. Keep project-specific facts,
|
|
@@ -26,7 +26,7 @@ The default budget is:
|
|
|
26
26
|
|
|
27
27
|
| Situation | Required mechanisms |
|
|
28
28
|
| --- | --- |
|
|
29
|
-
| Read-only question |
|
|
29
|
+
| Read-only question | analysis only; no workflow command |
|
|
30
30
|
| Obvious clean serial edit | analysis, affected gate, commit/push |
|
|
31
31
|
| Terminal ledger/archive maintenance | targeted consistency check, one commit |
|
|
32
32
|
| Dirty checkout or concurrent writer | registered lifecycle and isolated worktree |
|
|
@@ -34,9 +34,11 @@ The default budget is:
|
|
|
34
34
|
| Multiple independent writers | one task/worktree/lease per writer, ordered integration |
|
|
35
35
|
|
|
36
36
|
Do not add classify, task lifecycle, durable design, subagents, reviewer, or a
|
|
37
|
-
worktree
|
|
38
|
-
|
|
39
|
-
`
|
|
37
|
+
worktree merely because the tool exists. If task kind or impact is unclear, run
|
|
38
|
+
`classify`: run `mechanism_plan.required`, let the model select
|
|
39
|
+
`optional_when_beneficial` only when expected value exceeds coordination cost,
|
|
40
|
+
and keep `forbidden` mechanisms off unless the user explicitly overrides the
|
|
41
|
+
plan. Reclassify only after a material task-kind, scope, risk, or writer change.
|
|
40
42
|
|
|
41
43
|
Normal delivery is:
|
|
42
44
|
|
|
@@ -64,8 +66,9 @@ failure may continue in the same conversation/task without a second lifecycle.
|
|
|
64
66
|
|
|
65
67
|
## Design, agents, and review
|
|
66
68
|
|
|
67
|
-
- Micro and standard tasks stay main-agent-only unless
|
|
68
|
-
|
|
69
|
+
- Micro and standard tasks stay main-agent-only unless the model identifies an
|
|
70
|
+
independent question whose latency or expertise benefit exceeds coordination
|
|
71
|
+
cost.
|
|
69
72
|
- Create DD/ADR only for lasting cross-module, API, data, security, deployment,
|
|
70
73
|
or key user-flow decisions.
|
|
71
74
|
- Use read-only explorer/docs/browser agents only for independent questions.
|
|
@@ -90,9 +93,10 @@ failure may continue in the same conversation/task without a second lifecycle.
|
|
|
90
93
|
validation.
|
|
91
94
|
- Focused tests may run and rerun during development. Run one final routed gate
|
|
92
95
|
after the diff is stable.
|
|
93
|
-
- The final gate
|
|
94
|
-
|
|
95
|
-
|
|
96
|
+
- The final gate defaults to 120 seconds per command and 180 seconds total. A
|
|
97
|
+
project may raise either budget for a measured affected-scope check, and may set
|
|
98
|
+
a smaller `timeout_seconds` on an individual route. A timeout should narrow the
|
|
99
|
+
route; never expand or retry it as a full gate.
|
|
96
100
|
- Do not proactively install dependencies. Only after the selected route fails
|
|
97
101
|
because a repository-locked dependency is absent may it be restored once and
|
|
98
102
|
only that route retried.
|
|
@@ -46,12 +46,12 @@ _GENERATED_NOISE_PATTERNS = [
|
|
|
46
46
|
]
|
|
47
47
|
_AGENT_CONTRACT_VERSION = 1
|
|
48
48
|
_AGENT_CONTRACT_SCHEMA = "data/contracts/orchestration-v1.schema.json"
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
_RECOMMENDED_FINAL_COMMAND_SECONDS = 120.0
|
|
50
|
+
_RECOMMENDED_FINAL_TOTAL_SECONDS = 180.0
|
|
51
51
|
_WORKFLOW_MIGRATION_POLICY = Path("data/policies/workflow-migrations-v1.json")
|
|
52
52
|
_FALLBACK_WORKFLOW_MIGRATION_POLICY = {
|
|
53
53
|
"schema_version": 1,
|
|
54
|
-
"managed_versions": {"agents": "4.1.
|
|
54
|
+
"managed_versions": {"agents": "4.1.2", "engineering": "4.1.2"},
|
|
55
55
|
"known_official_engineering_body_sha256": [
|
|
56
56
|
"d1306cc626e8baf8c83c953b760fd771066de2bf125168eca3a7b7d6ff2b87a2",
|
|
57
57
|
"305931c6edef770033a4f1970b00e5fb1c1728351856a173dbfa497daf563021",
|
|
@@ -638,8 +638,8 @@ def _migrate_fast_development_defaults(cfg: dict, repo: Path) -> list[str]:
|
|
|
638
638
|
if _text(workflow_cfg.get("completion")).lower() != "push":
|
|
639
639
|
workflow_cfg["completion"] = "push"
|
|
640
640
|
changed.append("workflow.completion")
|
|
641
|
-
if _text(workflow_cfg.get("skill_version")) != "4.1.
|
|
642
|
-
workflow_cfg["skill_version"] = "4.1.
|
|
641
|
+
if _text(workflow_cfg.get("skill_version")) != "4.1.2":
|
|
642
|
+
workflow_cfg["skill_version"] = "4.1.2"
|
|
643
643
|
changed.append("workflow.skill_version")
|
|
644
644
|
|
|
645
645
|
commands_cfg = cfg.setdefault("commands", {})
|
|
@@ -689,8 +689,8 @@ def _migrate_fast_development_defaults(cfg: dict, repo: Path) -> list[str]:
|
|
|
689
689
|
validation_cfg["on_unmapped"] = "error"
|
|
690
690
|
changed.append("validation.on_unmapped")
|
|
691
691
|
for key, default_value in [
|
|
692
|
-
("max_command_seconds", int(
|
|
693
|
-
("max_total_seconds", int(
|
|
692
|
+
("max_command_seconds", int(_RECOMMENDED_FINAL_COMMAND_SECONDS)),
|
|
693
|
+
("max_total_seconds", int(_RECOMMENDED_FINAL_TOTAL_SECONDS)),
|
|
694
694
|
]:
|
|
695
695
|
if key not in validation_cfg:
|
|
696
696
|
validation_cfg[key] = default_value
|
|
@@ -952,16 +952,16 @@ def cmd_upgrade(args: argparse.Namespace) -> None:
|
|
|
952
952
|
if current_agents:
|
|
953
953
|
archive_dir = repo / "docs" / "archive" / "workflow"
|
|
954
954
|
archive_header = (
|
|
955
|
-
"# Archived AGENTS.md before auto-coding-skill 4.1.
|
|
955
|
+
"# Archived AGENTS.md before auto-coding-skill 4.1.2\n\n"
|
|
956
956
|
"This file is historical and non-authoritative. The root AGENTS.md is fully managed.\n"
|
|
957
957
|
"Move any still-current project facts into docs/ENGINEERING.md or docs/project/,\n"
|
|
958
958
|
"without copying workflow rules back into the root AGENTS.md.\n\n---\n\n"
|
|
959
959
|
)
|
|
960
960
|
archive_content = archive_header + current_agents
|
|
961
|
-
archive = archive_dir / "AGENTS.pre-4.1.
|
|
961
|
+
archive = archive_dir / "AGENTS.pre-4.1.2.md"
|
|
962
962
|
if archive.exists() and archive.read_text(encoding="utf-8") != archive_content:
|
|
963
963
|
digest = hashlib.sha256(current_agents.encode("utf-8")).hexdigest()[:12]
|
|
964
|
-
archive = archive_dir / f"AGENTS.pre-4.1.
|
|
964
|
+
archive = archive_dir / f"AGENTS.pre-4.1.2-{digest}.md"
|
|
965
965
|
if not archive.exists():
|
|
966
966
|
add_action("policy", archive, "archive", "historical and non-authoritative")
|
|
967
967
|
if write:
|
|
@@ -1732,6 +1732,17 @@ def _task_registry_path(repo: Path, task_id: str) -> Path:
|
|
|
1732
1732
|
return _task_state_root(repo) / "tasks" / f"{_validate_task_id(task_id)}.json"
|
|
1733
1733
|
|
|
1734
1734
|
|
|
1735
|
+
def _has_registered_active_task(repo: Path) -> bool:
|
|
1736
|
+
registry = _task_state_root(repo) / "tasks"
|
|
1737
|
+
if not registry.exists():
|
|
1738
|
+
return False
|
|
1739
|
+
for path in sorted(registry.glob("*.json")):
|
|
1740
|
+
payload = _read_json_object(path) or {}
|
|
1741
|
+
if _text(payload.get("state")) not in {"", "integrated", "cleanup-pending"}:
|
|
1742
|
+
return True
|
|
1743
|
+
return False
|
|
1744
|
+
|
|
1745
|
+
|
|
1735
1746
|
def _worktree_manifest_path(repo: Path) -> Path:
|
|
1736
1747
|
return _git_dir(repo) / "auto-coding-skill-task.json"
|
|
1737
1748
|
|
|
@@ -2466,6 +2477,7 @@ def _resolve_secret(section_name: str, section_cfg: dict, field: str) -> str:
|
|
|
2466
2477
|
|
|
2467
2478
|
_GATE_SCOPES = {"auto", "changed", "standard", "full"}
|
|
2468
2479
|
_WORKFLOW_PROFILES = {"auto", "micro", "standard", "high-risk"}
|
|
2480
|
+
_TASK_KINDS = {"auto", "none", "read_only", "change", "terminal_maintenance"}
|
|
2469
2481
|
_PROFILE_GATE_SCOPE = {"micro": "changed", "standard": "changed", "high-risk": "changed"}
|
|
2470
2482
|
_PROFILE_RANK = {"micro": 0, "standard": 1, "high-risk": 2}
|
|
2471
2483
|
_SCOPE_RANK = {"changed": 0, "standard": 1, "full": 2}
|
|
@@ -2529,24 +2541,14 @@ def _final_gate_budget(cfg: dict) -> dict[str, float]:
|
|
|
2529
2541
|
validation_cfg = _validation_cfg(cfg)
|
|
2530
2542
|
command_seconds = _positive_seconds(
|
|
2531
2543
|
validation_cfg.get("max_command_seconds"),
|
|
2532
|
-
|
|
2544
|
+
_RECOMMENDED_FINAL_COMMAND_SECONDS,
|
|
2533
2545
|
"validation.max_command_seconds",
|
|
2534
2546
|
)
|
|
2535
2547
|
total_seconds = _positive_seconds(
|
|
2536
2548
|
validation_cfg.get("max_total_seconds"),
|
|
2537
|
-
|
|
2549
|
+
_RECOMMENDED_FINAL_TOTAL_SECONDS,
|
|
2538
2550
|
"validation.max_total_seconds",
|
|
2539
2551
|
)
|
|
2540
|
-
if command_seconds > _MAX_FINAL_COMMAND_SECONDS:
|
|
2541
|
-
raise APError(
|
|
2542
|
-
f"validation.max_command_seconds cannot exceed {_MAX_FINAL_COMMAND_SECONDS:.0f}; "
|
|
2543
|
-
"move slower checks to an explicit diagnostic command"
|
|
2544
|
-
)
|
|
2545
|
-
if total_seconds > _MAX_FINAL_TOTAL_SECONDS:
|
|
2546
|
-
raise APError(
|
|
2547
|
-
f"validation.max_total_seconds cannot exceed {_MAX_FINAL_TOTAL_SECONDS:.0f}; "
|
|
2548
|
-
"move slower checks to an explicit diagnostic command"
|
|
2549
|
-
)
|
|
2550
2552
|
if command_seconds > total_seconds:
|
|
2551
2553
|
raise APError("validation.max_command_seconds cannot exceed validation.max_total_seconds")
|
|
2552
2554
|
return {"command_seconds": command_seconds, "total_seconds": total_seconds}
|
|
@@ -2588,6 +2590,7 @@ def _run_configured_command_list(
|
|
|
2588
2590
|
*,
|
|
2589
2591
|
deadline: Optional[float] = None,
|
|
2590
2592
|
command_timeout_s: Optional[float] = None,
|
|
2593
|
+
command_timeouts: Optional[dict[str, float]] = None,
|
|
2591
2594
|
) -> list[str]:
|
|
2592
2595
|
executed: list[str] = []
|
|
2593
2596
|
missing: list[str] = []
|
|
@@ -2597,6 +2600,9 @@ def _run_configured_command_list(
|
|
|
2597
2600
|
continue
|
|
2598
2601
|
if _configured_command(cfg, name):
|
|
2599
2602
|
timeout_s = command_timeout_s
|
|
2603
|
+
route_timeout = (command_timeouts or {}).get(name)
|
|
2604
|
+
if route_timeout is not None:
|
|
2605
|
+
timeout_s = min(timeout_s, route_timeout) if timeout_s is not None else route_timeout
|
|
2600
2606
|
if deadline is not None:
|
|
2601
2607
|
remaining = deadline - time.monotonic()
|
|
2602
2608
|
if remaining <= 0:
|
|
@@ -2784,6 +2790,7 @@ def _validation_plan(cfg: dict, paths: list[str]) -> dict:
|
|
|
2784
2790
|
normalized = _unique_paths(paths)
|
|
2785
2791
|
routes = _validation_routes(cfg)
|
|
2786
2792
|
command_names: list[str] = []
|
|
2793
|
+
command_timeouts: dict[str, float] = {}
|
|
2787
2794
|
matched_routes: list[str] = []
|
|
2788
2795
|
coverage: dict[str, list[str]] = {}
|
|
2789
2796
|
unmapped: list[str] = []
|
|
@@ -2794,6 +2801,13 @@ def _validation_plan(cfg: dict, paths: list[str]) -> dict:
|
|
|
2794
2801
|
if not _validation_route_matches(path, route):
|
|
2795
2802
|
continue
|
|
2796
2803
|
route_name = _text(route.get("name")) or f"route-{index + 1}"
|
|
2804
|
+
route_timeout: Optional[float] = None
|
|
2805
|
+
if route.get("timeout_seconds") not in {None, ""}:
|
|
2806
|
+
route_timeout = _positive_seconds(
|
|
2807
|
+
route.get("timeout_seconds"),
|
|
2808
|
+
1.0,
|
|
2809
|
+
f"validation.routes[{index}].timeout_seconds",
|
|
2810
|
+
)
|
|
2797
2811
|
names.append(route_name)
|
|
2798
2812
|
if route_name not in matched_routes:
|
|
2799
2813
|
matched_routes.append(route_name)
|
|
@@ -2801,6 +2815,13 @@ def _validation_plan(cfg: dict, paths: list[str]) -> dict:
|
|
|
2801
2815
|
command_name = _command_name(command_ref)
|
|
2802
2816
|
if command_name and command_name not in command_names:
|
|
2803
2817
|
command_names.append(command_name)
|
|
2818
|
+
if command_name and route_timeout is not None:
|
|
2819
|
+
current_timeout = command_timeouts.get(command_name)
|
|
2820
|
+
command_timeouts[command_name] = (
|
|
2821
|
+
min(current_timeout, route_timeout)
|
|
2822
|
+
if current_timeout is not None
|
|
2823
|
+
else route_timeout
|
|
2824
|
+
)
|
|
2804
2825
|
coverage[path] = names
|
|
2805
2826
|
if not names and not _path_matches(path, _DOC_PATH_PATTERNS):
|
|
2806
2827
|
unmapped.append(path)
|
|
@@ -2829,6 +2850,7 @@ def _validation_plan(cfg: dict, paths: list[str]) -> dict:
|
|
|
2829
2850
|
return {
|
|
2830
2851
|
"paths": normalized,
|
|
2831
2852
|
"commands": command_names,
|
|
2853
|
+
"command_timeouts": command_timeouts,
|
|
2832
2854
|
"matched_routes": matched_routes,
|
|
2833
2855
|
"coverage": coverage,
|
|
2834
2856
|
"unmapped": unmapped,
|
|
@@ -2965,6 +2987,7 @@ def _run_changed_gate(
|
|
|
2965
2987
|
plan["commands"],
|
|
2966
2988
|
deadline=deadline,
|
|
2967
2989
|
command_timeout_s=command_timeout_s,
|
|
2990
|
+
command_timeouts=plan["command_timeouts"],
|
|
2968
2991
|
)
|
|
2969
2992
|
print(
|
|
2970
2993
|
"[validation] routes="
|
|
@@ -2990,6 +3013,7 @@ def cmd_validation_map_check(args: argparse.Namespace) -> None:
|
|
|
2990
3013
|
result = {
|
|
2991
3014
|
"paths": plan["paths"],
|
|
2992
3015
|
"commands": plan["commands"],
|
|
3016
|
+
"command_timeouts": plan["command_timeouts"],
|
|
2993
3017
|
"matched_routes": plan["matched_routes"],
|
|
2994
3018
|
"coverage": plan["coverage"],
|
|
2995
3019
|
"docs_only": plan["docs_only"],
|
|
@@ -4464,6 +4488,47 @@ def _classify_intent(intent: str) -> list[str]:
|
|
|
4464
4488
|
)
|
|
4465
4489
|
|
|
4466
4490
|
|
|
4491
|
+
def _resolve_task_kind(
|
|
4492
|
+
requested: str,
|
|
4493
|
+
paths: list[str],
|
|
4494
|
+
intent: str,
|
|
4495
|
+
) -> str:
|
|
4496
|
+
value = _text(requested).lower().replace("-", "_") or "auto"
|
|
4497
|
+
if value not in _TASK_KINDS:
|
|
4498
|
+
raise APError("task kind must be one of: " + ", ".join(sorted(_TASK_KINDS)))
|
|
4499
|
+
if value != "auto":
|
|
4500
|
+
return value
|
|
4501
|
+
if _is_terminal_ledger_maintenance(paths):
|
|
4502
|
+
return "terminal_maintenance"
|
|
4503
|
+
if paths:
|
|
4504
|
+
return "change"
|
|
4505
|
+
normalized_intent = _text(intent).lower()
|
|
4506
|
+
if not normalized_intent:
|
|
4507
|
+
return "none"
|
|
4508
|
+
terminal_action = bool(
|
|
4509
|
+
re.search(r"\b(archive|close|reconcile)\b", normalized_intent)
|
|
4510
|
+
or any(keyword in normalized_intent for keyword in ["归档", "对账", "收口"])
|
|
4511
|
+
)
|
|
4512
|
+
terminal_subject = bool(
|
|
4513
|
+
re.search(r"\b(closure|ledger|task\s+records?|taskbook)\b", normalized_intent)
|
|
4514
|
+
or any(keyword in normalized_intent for keyword in ["台账", "任务记录", "关闭记录"])
|
|
4515
|
+
)
|
|
4516
|
+
if terminal_action and terminal_subject:
|
|
4517
|
+
return "terminal_maintenance"
|
|
4518
|
+
english_change = re.search(
|
|
4519
|
+
r"\b(add|build|change|create|delete|deploy|develop|fix|implement|migrate|optimize|publish|refactor|release|remove|rename|resolve|update|upgrade)\b",
|
|
4520
|
+
normalized_intent,
|
|
4521
|
+
)
|
|
4522
|
+
chinese_change = any(
|
|
4523
|
+
keyword in normalized_intent
|
|
4524
|
+
for keyword in [
|
|
4525
|
+
"修改", "新增", "删除", "修复", "解决", "整改", "实现", "迁移", "发布",
|
|
4526
|
+
"重构", "改名", "升级", "优化", "完善", "补充", "清理", "落地", "提交", "推送",
|
|
4527
|
+
]
|
|
4528
|
+
)
|
|
4529
|
+
return "change" if english_change or chinese_change else "read_only"
|
|
4530
|
+
|
|
4531
|
+
|
|
4467
4532
|
def _normalize_workflow_profile(value: object, default: str = "auto") -> str:
|
|
4468
4533
|
profile = _text(value).lower() or default
|
|
4469
4534
|
if profile not in _WORKFLOW_PROFILES:
|
|
@@ -4645,46 +4710,66 @@ def _agent_execution_plan(
|
|
|
4645
4710
|
|
|
4646
4711
|
def _mechanism_plan(
|
|
4647
4712
|
*,
|
|
4648
|
-
|
|
4649
|
-
terminal_maintenance: bool,
|
|
4713
|
+
task_kind: str,
|
|
4650
4714
|
execution_mode: str,
|
|
4651
4715
|
review_required: bool,
|
|
4652
4716
|
design_required: bool,
|
|
4653
4717
|
parallel_writers: int,
|
|
4654
4718
|
) -> dict:
|
|
4655
|
-
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4719
|
+
universe = [
|
|
4720
|
+
"analysis",
|
|
4721
|
+
"targeted_consistency_check",
|
|
4722
|
+
"durable_design",
|
|
4723
|
+
"task_lifecycle",
|
|
4724
|
+
"worktree",
|
|
4725
|
+
"read_only_subagents",
|
|
4726
|
+
"parallel_fixers",
|
|
4727
|
+
"independent_review",
|
|
4728
|
+
"final_changed_scope_gate",
|
|
4729
|
+
"commit_push",
|
|
4730
|
+
]
|
|
4731
|
+
required: list[str] = []
|
|
4732
|
+
optional: list[str] = []
|
|
4733
|
+
if task_kind == "read_only":
|
|
4734
|
+
required = ["analysis"]
|
|
4735
|
+
optional = ["read_only_subagents"]
|
|
4736
|
+
elif task_kind == "terminal_maintenance":
|
|
4737
|
+
required = ["analysis", "targeted_consistency_check", "commit_push"]
|
|
4738
|
+
elif task_kind == "change":
|
|
4739
|
+
required = ["analysis"]
|
|
4740
|
+
if design_required:
|
|
4741
|
+
required.append("durable_design")
|
|
4742
|
+
else:
|
|
4743
|
+
optional.append("durable_design")
|
|
4744
|
+
if execution_mode == "isolated":
|
|
4745
|
+
required.extend(["task_lifecycle", "worktree"])
|
|
4746
|
+
elif review_required:
|
|
4747
|
+
required.append("task_lifecycle")
|
|
4748
|
+
if parallel_writers > 1:
|
|
4749
|
+
required.append("parallel_fixers")
|
|
4750
|
+
else:
|
|
4751
|
+
optional.append("parallel_fixers")
|
|
4752
|
+
if review_required:
|
|
4753
|
+
required.append("independent_review")
|
|
4754
|
+
else:
|
|
4755
|
+
optional.append("independent_review")
|
|
4756
|
+
optional.append("read_only_subagents")
|
|
4668
4757
|
required.extend(["final_changed_scope_gate", "commit_push"])
|
|
4669
4758
|
ordered = list(dict.fromkeys(required))
|
|
4670
|
-
optional = [
|
|
4671
|
-
|
|
4672
|
-
for mechanism in [
|
|
4673
|
-
"classify",
|
|
4674
|
-
"durable_design",
|
|
4675
|
-
"task_lifecycle",
|
|
4676
|
-
"worktree",
|
|
4677
|
-
"read_only_subagents",
|
|
4678
|
-
"parallel_fixers",
|
|
4679
|
-
"independent_review",
|
|
4680
|
-
]
|
|
4681
|
-
if mechanism not in ordered
|
|
4682
|
-
]
|
|
4759
|
+
optional = [item for item in dict.fromkeys(optional) if item not in ordered]
|
|
4760
|
+
forbidden = [item for item in universe if item not in ordered and item not in optional]
|
|
4683
4761
|
return {
|
|
4684
4762
|
"required": ordered,
|
|
4685
|
-
"
|
|
4763
|
+
"optional_when_beneficial": optional,
|
|
4764
|
+
"forbidden": forbidden,
|
|
4765
|
+
# 4.1 compatibility: old clients treat only truly forbidden mechanisms
|
|
4766
|
+
# as not required; model-selectable mechanisms remain available.
|
|
4767
|
+
"not_required": forbidden,
|
|
4686
4768
|
"lifecycle_required": "task_lifecycle" in ordered,
|
|
4687
|
-
"rule":
|
|
4769
|
+
"rule": (
|
|
4770
|
+
"run required mechanisms; select optional mechanisms only when expected value exceeds "
|
|
4771
|
+
"coordination cost; do not run forbidden mechanisms unless the user explicitly overrides"
|
|
4772
|
+
),
|
|
4688
4773
|
}
|
|
4689
4774
|
|
|
4690
4775
|
|
|
@@ -4700,6 +4785,7 @@ def _resolve_execution_plan(
|
|
|
4700
4785
|
planned_paths: Optional[list[str]] = None,
|
|
4701
4786
|
intent: str = "",
|
|
4702
4787
|
parallel_writers: int = 1,
|
|
4788
|
+
requested_task_kind: str = "",
|
|
4703
4789
|
) -> dict:
|
|
4704
4790
|
impact = _impact_summary(
|
|
4705
4791
|
cfg,
|
|
@@ -4713,6 +4799,7 @@ def _resolve_execution_plan(
|
|
|
4713
4799
|
{_normalize_owned_path(item) for item in (planned_paths or []) if _text(item)}
|
|
4714
4800
|
)
|
|
4715
4801
|
classification_inputs = [*paths, *normalized_planned_paths]
|
|
4802
|
+
task_kind = _resolve_task_kind(requested_task_kind, classification_inputs, intent)
|
|
4716
4803
|
classification = _classify_paths(classification_inputs)
|
|
4717
4804
|
intent_categories = _classify_intent(intent)
|
|
4718
4805
|
merged_categories = set(classification["categories"]) | set(intent_categories)
|
|
@@ -4733,8 +4820,11 @@ def _resolve_execution_plan(
|
|
|
4733
4820
|
(docs_only_paths and str(impact["selected_scope"]) != "full")
|
|
4734
4821
|
or _tests_only(classification_inputs)
|
|
4735
4822
|
)
|
|
4736
|
-
terminal_maintenance =
|
|
4737
|
-
if
|
|
4823
|
+
terminal_maintenance = task_kind == "terminal_maintenance"
|
|
4824
|
+
if task_kind in {"read_only", "terminal_maintenance", "none"}:
|
|
4825
|
+
detected_profile = "micro"
|
|
4826
|
+
profile_reasons.append(f"task kind: {task_kind}")
|
|
4827
|
+
elif docs_or_tests_only and str(impact["selected_scope"]) != "full":
|
|
4738
4828
|
detected_profile = "micro"
|
|
4739
4829
|
profile_reasons.append("only docs/test files changed")
|
|
4740
4830
|
|
|
@@ -4745,10 +4835,10 @@ def _resolve_execution_plan(
|
|
|
4745
4835
|
"matched gate rule has invalid profile: " + ", ".join(sorted(invalid_rule_profiles))
|
|
4746
4836
|
)
|
|
4747
4837
|
rule_profiles = raw_rule_profiles
|
|
4748
|
-
if "micro" in rule_profiles and detected_profile == "standard":
|
|
4838
|
+
if task_kind == "change" and "micro" in rule_profiles and detected_profile == "standard":
|
|
4749
4839
|
detected_profile = "micro"
|
|
4750
4840
|
profile_reasons.append("matched gate rule with profile=micro")
|
|
4751
|
-
if "standard" in rule_profiles and detected_profile == "micro":
|
|
4841
|
+
if task_kind == "change" and "standard" in rule_profiles and detected_profile == "micro":
|
|
4752
4842
|
detected_profile = "standard"
|
|
4753
4843
|
profile_reasons.append("matched gate rule with profile=standard")
|
|
4754
4844
|
|
|
@@ -4762,9 +4852,9 @@ def _resolve_execution_plan(
|
|
|
4762
4852
|
"release_or_tooling",
|
|
4763
4853
|
}
|
|
4764
4854
|
high_signals: list[str] = []
|
|
4765
|
-
if categories & high_categories and not docs_or_tests_only:
|
|
4855
|
+
if task_kind == "change" and categories & high_categories and not docs_or_tests_only:
|
|
4766
4856
|
high_signals.append("high-risk category: " + ", ".join(sorted(categories & high_categories)))
|
|
4767
|
-
if "high-risk" in rule_profiles:
|
|
4857
|
+
if task_kind == "change" and "high-risk" in rule_profiles:
|
|
4768
4858
|
high_signals.append("matched gate rule with profile=high-risk")
|
|
4769
4859
|
if high_signals:
|
|
4770
4860
|
detected_profile = "high-risk"
|
|
@@ -4817,19 +4907,19 @@ def _resolve_execution_plan(
|
|
|
4817
4907
|
and categories & {"api", "db", "auth", "payment", "file_transfer", "gateway", "prod_config"}
|
|
4818
4908
|
)
|
|
4819
4909
|
review_required = bool(
|
|
4820
|
-
|
|
4910
|
+
task_kind == "change"
|
|
4821
4911
|
and (effective_profile == "high-risk" or writer_count > 1 or cross_module_contract_risk or rule_review)
|
|
4822
4912
|
)
|
|
4823
4913
|
design_required = bool(
|
|
4824
|
-
|
|
4914
|
+
task_kind == "change"
|
|
4825
4915
|
and (rule_design or (effective_profile == "high-risk" and cross_module))
|
|
4826
4916
|
)
|
|
4827
|
-
has_task_signal = bool(classification_inputs or _text(intent))
|
|
4828
4917
|
workspace_dirty = bool(_working_tree_paths(repo))
|
|
4918
|
+
active_writer = _has_registered_active_task(repo)
|
|
4829
4919
|
configured_isolation = _task_isolation(cfg)
|
|
4830
|
-
if
|
|
4920
|
+
if task_kind != "change":
|
|
4831
4921
|
execution_mode = "none"
|
|
4832
|
-
elif configured_isolation == "worktree" or writer_count > 1 or workspace_dirty:
|
|
4922
|
+
elif configured_isolation == "worktree" or writer_count > 1 or workspace_dirty or active_writer:
|
|
4833
4923
|
execution_mode = "isolated"
|
|
4834
4924
|
else:
|
|
4835
4925
|
execution_mode = "direct"
|
|
@@ -4849,8 +4939,7 @@ def _resolve_execution_plan(
|
|
|
4849
4939
|
review_required=review_required,
|
|
4850
4940
|
)
|
|
4851
4941
|
mechanism_plan = _mechanism_plan(
|
|
4852
|
-
|
|
4853
|
-
terminal_maintenance=terminal_maintenance,
|
|
4942
|
+
task_kind=task_kind,
|
|
4854
4943
|
execution_mode=execution_mode,
|
|
4855
4944
|
review_required=review_required,
|
|
4856
4945
|
design_required=design_required,
|
|
@@ -4863,6 +4952,7 @@ def _resolve_execution_plan(
|
|
|
4863
4952
|
"planned_files": normalized_planned_paths,
|
|
4864
4953
|
"classification_files": classification_inputs,
|
|
4865
4954
|
"intent_provided": bool(_text(intent)),
|
|
4955
|
+
"task_kind": task_kind,
|
|
4866
4956
|
"intent_categories": intent_categories,
|
|
4867
4957
|
"reasons": execution_reasons,
|
|
4868
4958
|
"configured_profile": configured_profile,
|
|
@@ -4875,6 +4965,7 @@ def _resolve_execution_plan(
|
|
|
4875
4965
|
"execution_mode": execution_mode,
|
|
4876
4966
|
"terminal_maintenance": terminal_maintenance,
|
|
4877
4967
|
"workspace_dirty": workspace_dirty,
|
|
4968
|
+
"active_writer": active_writer,
|
|
4878
4969
|
"parallel_writers": writer_count,
|
|
4879
4970
|
"cross_module": cross_module,
|
|
4880
4971
|
"review_required": review_required,
|
|
@@ -4923,6 +5014,7 @@ def cmd_classify(args: argparse.Namespace) -> None:
|
|
|
4923
5014
|
planned_paths=list(getattr(args, "planned_path", []) or []),
|
|
4924
5015
|
intent="\n".join(part for part in intent_parts if part),
|
|
4925
5016
|
parallel_writers=int(getattr(args, "writers", 1) or 1),
|
|
5017
|
+
requested_task_kind=_text(getattr(args, "task_kind", "")),
|
|
4926
5018
|
)
|
|
4927
5019
|
risk = {"micro": "P3", "standard": "P2", "high-risk": "P1"}[plan["profile"]]
|
|
4928
5020
|
commands: list[str] = []
|
|
@@ -4937,6 +5029,7 @@ def cmd_classify(args: argparse.Namespace) -> None:
|
|
|
4937
5029
|
print(json.dumps(result, ensure_ascii=False, indent=2))
|
|
4938
5030
|
else:
|
|
4939
5031
|
print(f"[classify] risk={risk}")
|
|
5032
|
+
print(f"[classify] task_kind={result['task_kind']}")
|
|
4940
5033
|
print(f"[classify] profile={result['profile']}")
|
|
4941
5034
|
print(f"[classify] effective_mode={result['effective_mode']}")
|
|
4942
5035
|
print(f"[classify] execution_mode={result['execution_mode']}")
|
|
@@ -4951,8 +5044,12 @@ def cmd_classify(args: argparse.Namespace) -> None:
|
|
|
4951
5044
|
+ (", ".join(result["mechanism_plan"]["required"]) or "(none)")
|
|
4952
5045
|
)
|
|
4953
5046
|
print(
|
|
4954
|
-
"[classify]
|
|
4955
|
-
+ (", ".join(result["mechanism_plan"]["
|
|
5047
|
+
"[classify] optional_when_beneficial="
|
|
5048
|
+
+ (", ".join(result["mechanism_plan"]["optional_when_beneficial"]) or "(none)")
|
|
5049
|
+
)
|
|
5050
|
+
print(
|
|
5051
|
+
"[classify] forbidden="
|
|
5052
|
+
+ (", ".join(result["mechanism_plan"]["forbidden"]) or "(none)")
|
|
4956
5053
|
)
|
|
4957
5054
|
for stage in result["agent_plan"]["stages"]:
|
|
4958
5055
|
print(
|
|
@@ -5217,6 +5314,7 @@ def cmd_doctor(args: argparse.Namespace) -> None:
|
|
|
5217
5314
|
|
|
5218
5315
|
missing: List[str] = []
|
|
5219
5316
|
validation_errors: List[str] = []
|
|
5317
|
+
advisories: List[str] = []
|
|
5220
5318
|
validation_errors.extend(_workflow_policy_issues(repo, cfg))
|
|
5221
5319
|
|
|
5222
5320
|
mode = str(workflow_cfg.get("mode") or "dev").strip().lower()
|
|
@@ -5303,9 +5401,23 @@ def cmd_doctor(args: argparse.Namespace) -> None:
|
|
|
5303
5401
|
if on_unmapped not in {"error", "fallback"}:
|
|
5304
5402
|
validation_errors.append("validation.on_unmapped must be error or fallback")
|
|
5305
5403
|
try:
|
|
5306
|
-
_final_gate_budget(cfg)
|
|
5404
|
+
final_budget = _final_gate_budget(cfg)
|
|
5405
|
+
if final_budget["command_seconds"] > _RECOMMENDED_FINAL_COMMAND_SECONDS:
|
|
5406
|
+
advisories.append(
|
|
5407
|
+
"validation.max_command_seconds exceeds the recommended 120s default; "
|
|
5408
|
+
"keep the affected-scope route targeted"
|
|
5409
|
+
)
|
|
5410
|
+
if final_budget["total_seconds"] > _RECOMMENDED_FINAL_TOTAL_SECONDS:
|
|
5411
|
+
advisories.append(
|
|
5412
|
+
"validation.max_total_seconds exceeds the recommended 180s default; "
|
|
5413
|
+
"keep the final gate bounded to affected scope"
|
|
5414
|
+
)
|
|
5307
5415
|
except APError as exc:
|
|
5308
5416
|
validation_errors.append(str(exc))
|
|
5417
|
+
final_budget = {
|
|
5418
|
+
"command_seconds": _RECOMMENDED_FINAL_COMMAND_SECONDS,
|
|
5419
|
+
"total_seconds": _RECOMMENDED_FINAL_TOTAL_SECONDS,
|
|
5420
|
+
}
|
|
5309
5421
|
routes = validation_cfg.get("routes") or []
|
|
5310
5422
|
if not isinstance(routes, list):
|
|
5311
5423
|
validation_errors.append("validation.routes must be a list")
|
|
@@ -5324,6 +5436,20 @@ def cmd_doctor(args: argparse.Namespace) -> None:
|
|
|
5324
5436
|
validation_errors.append(
|
|
5325
5437
|
f"validation.routes[{index}] references missing commands.{command_name}"
|
|
5326
5438
|
)
|
|
5439
|
+
if "timeout_seconds" in route:
|
|
5440
|
+
try:
|
|
5441
|
+
route_timeout = _positive_seconds(
|
|
5442
|
+
route.get("timeout_seconds"),
|
|
5443
|
+
final_budget["command_seconds"],
|
|
5444
|
+
f"validation.routes[{index}].timeout_seconds",
|
|
5445
|
+
)
|
|
5446
|
+
if route_timeout > final_budget["command_seconds"]:
|
|
5447
|
+
advisories.append(
|
|
5448
|
+
f"validation.routes[{index}].timeout_seconds exceeds max_command_seconds "
|
|
5449
|
+
"and will be capped"
|
|
5450
|
+
)
|
|
5451
|
+
except APError as exc:
|
|
5452
|
+
validation_errors.append(str(exc))
|
|
5327
5453
|
fallback_name = _command_name(validation_cfg.get("fallback_command"))
|
|
5328
5454
|
if on_unmapped == "fallback" and not fallback_name:
|
|
5329
5455
|
validation_errors.append(
|
|
@@ -5390,6 +5516,8 @@ def cmd_doctor(args: argparse.Namespace) -> None:
|
|
|
5390
5516
|
"pass",
|
|
5391
5517
|
{"mode": mode, "completion": completion, "access_fields": len(_REQUIRED_ACCESS_FIELDS)},
|
|
5392
5518
|
)
|
|
5519
|
+
for advisory in advisories:
|
|
5520
|
+
print(f"[doctor] WARN: {advisory}")
|
|
5393
5521
|
print("[doctor] OK")
|
|
5394
5522
|
|
|
5395
5523
|
|
|
@@ -6600,6 +6728,41 @@ def cmd_task_start(args: argparse.Namespace) -> None:
|
|
|
6600
6728
|
repo = Path(args.repo).resolve()
|
|
6601
6729
|
ensure_git_repo(repo)
|
|
6602
6730
|
cfg = _load_cfg(repo)
|
|
6731
|
+
_require_control_checkout(repo)
|
|
6732
|
+
task_id = _validate_task_id(args.task_id)
|
|
6733
|
+
owned_paths = sorted({_normalize_owned_path(item) for item in (args.owned_path or [])})
|
|
6734
|
+
if not owned_paths:
|
|
6735
|
+
raise APError("task-start requires at least one --owned-path.")
|
|
6736
|
+
if _is_terminal_ledger_maintenance(owned_paths):
|
|
6737
|
+
raise APError(
|
|
6738
|
+
"Pure taskbook/closure/archive reconciliation is terminal maintenance and must not "
|
|
6739
|
+
"create another task lifecycle. Run the targeted document check, commit once, and push."
|
|
6740
|
+
)
|
|
6741
|
+
writer_count = max(1, int(getattr(args, "writers", 1) or 1))
|
|
6742
|
+
if writer_count != 1:
|
|
6743
|
+
raise APError(
|
|
6744
|
+
"task-start creates exactly one writer lease and one worktree. Start each parallel "
|
|
6745
|
+
"writer as its own task ID; use --writers only with classify for planning."
|
|
6746
|
+
)
|
|
6747
|
+
explicit_lifecycle = bool(
|
|
6748
|
+
getattr(args, "isolated", False)
|
|
6749
|
+
or getattr(args, "review_required", False)
|
|
6750
|
+
or getattr(args, "force_lifecycle", False)
|
|
6751
|
+
)
|
|
6752
|
+
preflight_plan = _resolve_execution_plan(
|
|
6753
|
+
cfg,
|
|
6754
|
+
repo,
|
|
6755
|
+
planned_paths=owned_paths,
|
|
6756
|
+
parallel_writers=writer_count,
|
|
6757
|
+
requested_task_kind="change",
|
|
6758
|
+
)
|
|
6759
|
+
if not preflight_plan["mechanism_plan"]["lifecycle_required"] and not explicit_lifecycle:
|
|
6760
|
+
raise APError(
|
|
6761
|
+
"This clean serial task does not need a machine task lifecycle. Work directly on "
|
|
6762
|
+
"the current branch, run the routed final gate, commit, and push. Use task-start "
|
|
6763
|
+
"only when classify requires isolation/review or the user explicitly requests it."
|
|
6764
|
+
)
|
|
6765
|
+
|
|
6603
6766
|
_require_workflow_policy_clean(repo, cfg)
|
|
6604
6767
|
configured_isolation = _task_isolation(cfg)
|
|
6605
6768
|
access_issues = _access_config_issues(cfg)
|
|
@@ -6608,8 +6771,6 @@ def cmd_task_start(args: argparse.Namespace) -> None:
|
|
|
6608
6771
|
"Project initialization is incomplete; fill docs/ENGINEERING.md before starting work:\n- "
|
|
6609
6772
|
+ "\n- ".join(access_issues)
|
|
6610
6773
|
)
|
|
6611
|
-
task_id = _validate_task_id(args.task_id)
|
|
6612
|
-
_require_control_checkout(repo)
|
|
6613
6774
|
remote, target_branch, base_ref = _task_remote_and_target(cfg, args)
|
|
6614
6775
|
concurrency_cfg = _concurrency_cfg(cfg)
|
|
6615
6776
|
timeout_s = float(concurrency_cfg.get("lock_timeout_sec") or 30)
|
|
@@ -6626,20 +6787,6 @@ def cmd_task_start(args: argparse.Namespace) -> None:
|
|
|
6626
6787
|
if not getattr(args, "no_fetch", False) and base_ref.startswith(f"{remote}/"):
|
|
6627
6788
|
_fetch_target(repo, remote, target_branch)
|
|
6628
6789
|
base_sha = _resolve_commit(repo, base_ref)
|
|
6629
|
-
owned_paths = sorted({_normalize_owned_path(item) for item in (args.owned_path or [])})
|
|
6630
|
-
if not owned_paths:
|
|
6631
|
-
raise APError("task-start requires at least one --owned-path.")
|
|
6632
|
-
if _is_terminal_ledger_maintenance(owned_paths):
|
|
6633
|
-
raise APError(
|
|
6634
|
-
"Pure taskbook/closure/archive reconciliation is terminal maintenance and must not "
|
|
6635
|
-
"create another task lifecycle. Run the targeted document check, commit once, and push."
|
|
6636
|
-
)
|
|
6637
|
-
writer_count = max(1, int(getattr(args, "writers", 1) or 1))
|
|
6638
|
-
if writer_count != 1:
|
|
6639
|
-
raise APError(
|
|
6640
|
-
"task-start creates exactly one writer lease and one worktree. Start each parallel "
|
|
6641
|
-
"writer as its own task ID; use --writers only with classify for planning."
|
|
6642
|
-
)
|
|
6643
6790
|
registry_dir = _task_state_root(repo) / "tasks"
|
|
6644
6791
|
for manifest_path in sorted(registry_dir.glob("*.json")) if registry_dir.exists() else []:
|
|
6645
6792
|
active_manifest = _read_json_object(manifest_path) or {}
|
|
@@ -6679,11 +6826,7 @@ def cmd_task_start(args: argparse.Namespace) -> None:
|
|
|
6679
6826
|
repo,
|
|
6680
6827
|
planned_paths=owned_paths,
|
|
6681
6828
|
parallel_writers=writer_count,
|
|
6682
|
-
|
|
6683
|
-
explicit_lifecycle = bool(
|
|
6684
|
-
getattr(args, "isolated", False)
|
|
6685
|
-
or getattr(args, "review_required", False)
|
|
6686
|
-
or getattr(args, "force_lifecycle", False)
|
|
6829
|
+
requested_task_kind="change",
|
|
6687
6830
|
)
|
|
6688
6831
|
if not plan["mechanism_plan"]["lifecycle_required"] and not explicit_lifecycle:
|
|
6689
6832
|
raise APError(
|
|
@@ -7925,6 +8068,7 @@ def main(argv: Optional[List[str]] = None) -> int:
|
|
|
7925
8068
|
s.add_argument("--planned-path", action="append")
|
|
7926
8069
|
s.add_argument("--intent")
|
|
7927
8070
|
s.add_argument("--intent-file")
|
|
8071
|
+
s.add_argument("--task-kind", choices=sorted(_TASK_KINDS), default="auto")
|
|
7928
8072
|
s.add_argument("--writers", type=int, default=1)
|
|
7929
8073
|
s.add_argument("--json", action="store_true")
|
|
7930
8074
|
s.set_defaults(func=cmd_classify)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { spawnSync } from "node:child_process";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
|
|
7
|
+
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
const repoRoot = path.resolve(here, "..", "..");
|
|
9
|
+
const npmCommand = process.platform === "win32" ? "npm.cmd" : "npm";
|
|
10
|
+
const packed = spawnSync(
|
|
11
|
+
npmCommand,
|
|
12
|
+
["pack", "--dry-run", "--json", "--ignore-scripts"],
|
|
13
|
+
{ cwd: repoRoot, encoding: "utf8" },
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
if (packed.status !== 0) {
|
|
17
|
+
process.stderr.write(packed.stderr || packed.stdout || "npm pack --dry-run failed\n");
|
|
18
|
+
process.exit(packed.status || 1);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
let payload;
|
|
22
|
+
try {
|
|
23
|
+
payload = JSON.parse(packed.stdout);
|
|
24
|
+
} catch (error) {
|
|
25
|
+
process.stderr.write(`Cannot parse npm pack output: ${error.message}\n`);
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const files = payload?.[0]?.files?.map(item => String(item.path || "")) || [];
|
|
30
|
+
const forbidden = files.filter(file =>
|
|
31
|
+
/(^|\/)__pycache__(\/|$)/.test(file) || /\.py[cod]$/i.test(file),
|
|
32
|
+
);
|
|
33
|
+
if (forbidden.length > 0) {
|
|
34
|
+
process.stderr.write(`Generated Python cache leaked into package:\n- ${forbidden.join("\n- ")}\n`);
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
process.stdout.write(`[package-check] OK files=${files.length}\n`);
|
package/cli/src/index.js
CHANGED
|
@@ -1125,15 +1125,15 @@ function projectStatus(project, assetSkill, assetAgents){
|
|
|
1125
1125
|
if (isolationState.present && !["adaptive", "worktree"].includes(frontmatterScalarValue(isolationState.value).toLowerCase())) {
|
|
1126
1126
|
invalidConfigTokens.push("concurrency.isolation (must be adaptive or worktree)");
|
|
1127
1127
|
}
|
|
1128
|
-
for (const
|
|
1129
|
-
[
|
|
1130
|
-
[
|
|
1128
|
+
for (const pathParts of [
|
|
1129
|
+
["validation", "max_command_seconds"],
|
|
1130
|
+
["validation", "max_total_seconds"],
|
|
1131
1131
|
]) {
|
|
1132
1132
|
const state = frontmatterPathState(text, pathParts);
|
|
1133
1133
|
if (!state.present) continue;
|
|
1134
1134
|
const value = Number(frontmatterScalarValue(state.value));
|
|
1135
|
-
if (!Number.isFinite(value) || value <= 0
|
|
1136
|
-
invalidConfigTokens.push(`${pathParts.join(".")} (must be > 0
|
|
1135
|
+
if (!Number.isFinite(value) || value <= 0) {
|
|
1136
|
+
invalidConfigTokens.push(`${pathParts.join(".")} (must be > 0)`);
|
|
1137
1137
|
}
|
|
1138
1138
|
}
|
|
1139
1139
|
const commandState = frontmatterPathState(text, ["validation", "max_command_seconds"]);
|
|
@@ -420,6 +420,30 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
420
420
|
self.assertEqual(before, git_output(repo, "rev-parse", "HEAD"))
|
|
421
421
|
self.assertFalse(self.registry_manifest_path(repo, "DIRECT-NOOP").exists())
|
|
422
422
|
|
|
423
|
+
def test_unnecessary_lifecycle_rejects_before_access_or_fetch_checks(self) -> None:
|
|
424
|
+
_, repo, _ = self.make_repo("adaptive", require_review=False)
|
|
425
|
+
engineering = repo / "docs" / "ENGINEERING.md"
|
|
426
|
+
text = engineering.read_text(encoding="utf-8")
|
|
427
|
+
engineering.write_text(text.replace("front-pass", "", 1), encoding="utf-8")
|
|
428
|
+
git(repo, "add", "docs/ENGINEERING.md")
|
|
429
|
+
git(repo, "commit", "-qm", "invalidate access for preflight test")
|
|
430
|
+
git(repo, "push", "-q", "origin", "dev")
|
|
431
|
+
|
|
432
|
+
result = self.ap(
|
|
433
|
+
repo,
|
|
434
|
+
"task-start",
|
|
435
|
+
"DIRECT-PREFLIGHT",
|
|
436
|
+
"--base",
|
|
437
|
+
"origin/branch-that-must-not-be-fetched",
|
|
438
|
+
"--owned-path",
|
|
439
|
+
"shared.txt",
|
|
440
|
+
check=False,
|
|
441
|
+
)
|
|
442
|
+
output = result.stdout + result.stderr
|
|
443
|
+
self.assertNotEqual(0, result.returncode)
|
|
444
|
+
self.assertIn("does not need a machine task lifecycle", output)
|
|
445
|
+
self.assertNotIn("initialization is incomplete", output)
|
|
446
|
+
|
|
423
447
|
def test_schema_one_task_status_fails_closed_with_migration_recovery(self) -> None:
|
|
424
448
|
_, repo, _ = self.make_repo()
|
|
425
449
|
self.start_task(repo, "LEGACY-SCHEMA")
|
|
@@ -243,6 +243,7 @@ class AutoCodingProfileTests(unittest.TestCase):
|
|
|
243
243
|
repo, cfg = self.make_repo()
|
|
244
244
|
plan = self.plan(repo, cfg, planned_paths=["src/widget.py"])
|
|
245
245
|
self.assertEqual("standard", plan["profile"])
|
|
246
|
+
self.assertEqual("change", plan["task_kind"])
|
|
246
247
|
self.assertEqual("changed", plan["selected_scope"])
|
|
247
248
|
self.assertEqual("dev", plan["effective_mode"])
|
|
248
249
|
self.assertEqual([], plan["recommended_agents"])
|
|
@@ -269,7 +270,48 @@ class AutoCodingProfileTests(unittest.TestCase):
|
|
|
269
270
|
plan["mechanism_plan"]["required"],
|
|
270
271
|
)
|
|
271
272
|
self.assertFalse(plan["mechanism_plan"]["lifecycle_required"])
|
|
272
|
-
self.assertIn("
|
|
273
|
+
self.assertIn("read_only_subagents", plan["mechanism_plan"]["optional_when_beneficial"])
|
|
274
|
+
self.assertIn("task_lifecycle", plan["mechanism_plan"]["forbidden"])
|
|
275
|
+
|
|
276
|
+
def test_intent_only_classifies_read_only_change_and_terminal_work(self) -> None:
|
|
277
|
+
repo, cfg = self.make_repo()
|
|
278
|
+
read_only = self.plan(repo, cfg, intent="Explain how authentication currently works")
|
|
279
|
+
self.assertEqual("read_only", read_only["task_kind"])
|
|
280
|
+
self.assertEqual("none", read_only["execution_mode"])
|
|
281
|
+
self.assertEqual(["analysis"], read_only["mechanism_plan"]["required"])
|
|
282
|
+
self.assertIn(
|
|
283
|
+
"read_only_subagents",
|
|
284
|
+
read_only["mechanism_plan"]["optional_when_beneficial"],
|
|
285
|
+
)
|
|
286
|
+
self.assertIn("commit_push", read_only["mechanism_plan"]["forbidden"])
|
|
287
|
+
|
|
288
|
+
change = self.plan(repo, cfg, intent="Fix the login redirect bug")
|
|
289
|
+
self.assertEqual("change", change["task_kind"])
|
|
290
|
+
self.assertEqual("direct", change["execution_mode"])
|
|
291
|
+
self.assertIn("commit_push", change["mechanism_plan"]["required"])
|
|
292
|
+
|
|
293
|
+
chinese_change = self.plan(repo, cfg, intent="请解决并优化登录跳转问题")
|
|
294
|
+
self.assertEqual("change", chinese_change["task_kind"])
|
|
295
|
+
|
|
296
|
+
forced_read_only = self.plan(
|
|
297
|
+
repo,
|
|
298
|
+
cfg,
|
|
299
|
+
intent="Fix wording in the explanation",
|
|
300
|
+
requested_task_kind="read_only",
|
|
301
|
+
)
|
|
302
|
+
self.assertEqual("read_only", forced_read_only["task_kind"])
|
|
303
|
+
|
|
304
|
+
terminal = self.plan(
|
|
305
|
+
repo,
|
|
306
|
+
cfg,
|
|
307
|
+
intent="reconcile the completed task ledger",
|
|
308
|
+
)
|
|
309
|
+
self.assertEqual("terminal_maintenance", terminal["task_kind"])
|
|
310
|
+
self.assertEqual(
|
|
311
|
+
["analysis", "targeted_consistency_check", "commit_push"],
|
|
312
|
+
terminal["mechanism_plan"]["required"],
|
|
313
|
+
)
|
|
314
|
+
self.assertIn("task_lifecycle", terminal["mechanism_plan"]["forbidden"])
|
|
273
315
|
|
|
274
316
|
def test_execution_mode_is_none_direct_isolated_or_parallel(self) -> None:
|
|
275
317
|
repo, cfg = self.make_repo()
|
|
@@ -312,7 +354,7 @@ class AutoCodingProfileTests(unittest.TestCase):
|
|
|
312
354
|
ap._validate_validation_plan(cfg, ap._validation_plan(cfg, ["contracts/api.yaml"]))
|
|
313
355
|
self.assertIn("no validation route", str(context.exception))
|
|
314
356
|
|
|
315
|
-
def
|
|
357
|
+
def test_final_gate_budget_is_configurable_and_times_out(self) -> None:
|
|
316
358
|
cfg = base_config()
|
|
317
359
|
cfg["validation"] = {
|
|
318
360
|
"on_unmapped": "error",
|
|
@@ -335,10 +377,42 @@ class AutoCodingProfileTests(unittest.TestCase):
|
|
|
335
377
|
)
|
|
336
378
|
self.assertIn("timed out", str(context.exception))
|
|
337
379
|
|
|
338
|
-
cfg["validation"]["max_command_seconds"] =
|
|
380
|
+
cfg["validation"]["max_command_seconds"] = 240
|
|
381
|
+
cfg["validation"]["max_total_seconds"] = 300
|
|
382
|
+
self.assertEqual(
|
|
383
|
+
{"command_seconds": 240.0, "total_seconds": 300.0},
|
|
384
|
+
ap._final_gate_budget(cfg),
|
|
385
|
+
)
|
|
386
|
+
|
|
387
|
+
cfg["validation"]["max_total_seconds"] = 200
|
|
339
388
|
with self.assertRaises(APError) as context:
|
|
340
389
|
ap._final_gate_budget(cfg)
|
|
341
|
-
self.assertIn("cannot exceed
|
|
390
|
+
self.assertIn("cannot exceed validation.max_total_seconds", str(context.exception))
|
|
391
|
+
|
|
392
|
+
def test_route_timeout_uses_smallest_matching_budget(self) -> None:
|
|
393
|
+
cfg = base_config()
|
|
394
|
+
cfg["commands"] = {"one": "true", "two": "true"}
|
|
395
|
+
cfg["validation"] = {
|
|
396
|
+
"on_unmapped": "error",
|
|
397
|
+
"max_command_seconds": 120,
|
|
398
|
+
"max_total_seconds": 180,
|
|
399
|
+
"routes": [
|
|
400
|
+
{
|
|
401
|
+
"name": "all-src",
|
|
402
|
+
"paths": ["src/**"],
|
|
403
|
+
"commands": ["one", "two"],
|
|
404
|
+
"timeout_seconds": 90,
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
"name": "python",
|
|
408
|
+
"paths": ["**/*.py"],
|
|
409
|
+
"commands": ["two"],
|
|
410
|
+
"timeout_seconds": 30,
|
|
411
|
+
},
|
|
412
|
+
],
|
|
413
|
+
}
|
|
414
|
+
plan = ap._validation_plan(cfg, ["src/widget.py"])
|
|
415
|
+
self.assertEqual({"one": 90.0, "two": 30.0}, plan["command_timeouts"])
|
|
342
416
|
|
|
343
417
|
def test_test_only_change_resolves_micro(self) -> None:
|
|
344
418
|
repo, cfg = self.make_repo("tests/widget_test.py")
|
package/cli/tests/index.test.js
CHANGED
|
@@ -733,7 +733,7 @@ function testManagedEngineeringSyncIsControlledAndIdempotent() {
|
|
|
733
733
|
|
|
734
734
|
const engineering = path.join(repo, "docs", "ENGINEERING.md");
|
|
735
735
|
const initial = fs.readFileSync(engineering, "utf8");
|
|
736
|
-
const startPattern = /<!-- auto-coding-skill:managed-workflow:start version=4\.1\.
|
|
736
|
+
const startPattern = /<!-- auto-coding-skill:managed-workflow:start version=4\.1\.2 -->/;
|
|
737
737
|
const endMarker = "<!-- auto-coding-skill:managed-workflow:end -->";
|
|
738
738
|
assert(startPattern.test(initial), "new projects should include a versioned managed workflow marker");
|
|
739
739
|
assert(initial.includes(endMarker), "new projects should include the managed workflow end marker");
|
|
@@ -752,7 +752,7 @@ function testManagedEngineeringSyncIsControlledAndIdempotent() {
|
|
|
752
752
|
const dryRun = run("node", [cli, "sync", "--projects", repo, "--dry-run", "--json"]);
|
|
753
753
|
const dryResult = JSON.parse(dryRun.stdout).results[0];
|
|
754
754
|
assert(dryResult.managedWorkflow.state === "stale", `dry-run should expose stale workflow state: ${dryRun.stdout}`);
|
|
755
|
-
assert(dryResult.managedWorkflow.version === "4.1.
|
|
755
|
+
assert(dryResult.managedWorkflow.version === "4.1.2", "dry-run should expose the target workflow version");
|
|
756
756
|
assert(dryResult.actions.some(item => item.action === "would-update" && item.path === "docs/ENGINEERING.md"), "dry-run should plan the managed body update");
|
|
757
757
|
assert(fs.readFileSync(engineering, "utf8") === customized, "dry-run must not write ENGINEERING.md");
|
|
758
758
|
|
|
@@ -762,14 +762,14 @@ function testManagedEngineeringSyncIsControlledAndIdempotent() {
|
|
|
762
762
|
const updatedEnd = updated.indexOf(endMarker) + endMarker.length;
|
|
763
763
|
assert(updated.slice(0, updatedStart) === outsideBefore, "sync must preserve frontmatter and content before the managed block byte-for-byte");
|
|
764
764
|
assert(updated.slice(updatedEnd) === outsideAfter, "sync must preserve content after the managed block byte-for-byte");
|
|
765
|
-
assert(updated.includes("version=4.1.
|
|
765
|
+
assert(updated.includes("version=4.1.2"), "sync should install the current managed workflow version");
|
|
766
766
|
assert(updated.includes("The frontmatter contract is:"), "sync should refresh stale managed workflow content");
|
|
767
767
|
|
|
768
768
|
fillRequiredAccess(repo);
|
|
769
769
|
const status = run("node", [cli, "status", "--projects", repo, "--json"]);
|
|
770
770
|
const statusResult = JSON.parse(status.stdout).results[0];
|
|
771
771
|
assert(statusResult.managedWorkflow.state === "current", `status should expose current managed workflow state: ${status.stdout}`);
|
|
772
|
-
assert(statusResult.managedWorkflow.version === "4.1.
|
|
772
|
+
assert(statusResult.managedWorkflow.version === "4.1.2", "status should expose the installed managed workflow version");
|
|
773
773
|
|
|
774
774
|
const beforeSecondSync = fs.readFileSync(engineering, "utf8");
|
|
775
775
|
const second = run("node", [cli, "sync", "--projects", repo, "--json"]);
|
|
@@ -797,7 +797,7 @@ function testLegacyEngineeringMigrationPreservesExistingBody() {
|
|
|
797
797
|
assert(dryResult.actions.find(item => item.path === "docs/ENGINEERING.md")?.detail.includes("preserved-custom"), "custom legacy action should be labeled preserved-custom");
|
|
798
798
|
run("node", [cli, "sync", "--projects", repo]);
|
|
799
799
|
const migrated = fs.readFileSync(engineering, "utf8");
|
|
800
|
-
assert(migrated.includes("version=4.1.
|
|
800
|
+
assert(migrated.includes("version=4.1.2"), "legacy migration should insert the current managed workflow");
|
|
801
801
|
assert(migrated.includes(legacyNote), "legacy migration must preserve the complete existing body");
|
|
802
802
|
const migratedStart = migrated.indexOf("<!-- auto-coding-skill:managed-workflow:start");
|
|
803
803
|
const migratedEnd = migrated.indexOf(endMarker) + endMarker.length;
|
|
@@ -901,7 +901,7 @@ function testManagedAgentsMigrationReplacesWholeFileAndArchivesPreviousRules() {
|
|
|
901
901
|
run("node", [cli, "sync", "--projects", repo]);
|
|
902
902
|
const agents = path.join(repo, "AGENTS.md");
|
|
903
903
|
const initial = fs.readFileSync(agents, "utf8");
|
|
904
|
-
assert(initial.includes("managed-agents:start version=4.1.
|
|
904
|
+
assert(initial.includes("managed-agents:start version=4.1.2"), "new projects should receive the versioned root AGENTS block");
|
|
905
905
|
|
|
906
906
|
const custom = [
|
|
907
907
|
"# Project rules",
|
|
@@ -920,12 +920,12 @@ function testManagedAgentsMigrationReplacesWholeFileAndArchivesPreviousRules() {
|
|
|
920
920
|
|
|
921
921
|
run("node", [cli, "sync", "--projects", repo]);
|
|
922
922
|
const migrated = fs.readFileSync(agents, "utf8");
|
|
923
|
-
assert(migrated.includes("managed-agents:start version=4.1.
|
|
923
|
+
assert(migrated.includes("managed-agents:start version=4.1.2"), "AGENTS migration should install the current managed block");
|
|
924
924
|
assert(!migrated.includes("Preserve this repository-specific rule exactly."), "root AGENTS must contain no project-specific tail");
|
|
925
925
|
assert(!migrated.includes("must execute `commands.gate_full`"), "known official conflicting rule should be removed");
|
|
926
926
|
const canonical = fs.readFileSync(path.join(repoRoot, "cli", "assets", "skill", "data", "templates", "bridges", "AGENTS.md"), "utf8");
|
|
927
927
|
assert(migrated === canonical, "root AGENTS must be byte-identical to the packaged canonical file");
|
|
928
|
-
const archive = path.join(repo, "docs", "archive", "workflow", "AGENTS.pre-4.1.
|
|
928
|
+
const archive = path.join(repo, "docs", "archive", "workflow", "AGENTS.pre-4.1.2.md");
|
|
929
929
|
assert(fs.readFileSync(archive, "utf8").includes("Preserve this repository-specific rule exactly."), "previous AGENTS content must be archived once");
|
|
930
930
|
const stable = fs.readFileSync(agents);
|
|
931
931
|
run("node", [cli, "sync", "--projects", repo]);
|
|
@@ -984,7 +984,7 @@ function testEngineeringFrameworkAllowsProjectFactsButRejectsDuplicateWorkflow()
|
|
|
984
984
|
const migrationResult = JSON.parse(migration.stdout).results[0];
|
|
985
985
|
assert(migrationResult.managedWorkflow.state === "stale", "known duplicate sections should use controlled migration");
|
|
986
986
|
assert(migrationResult.managedWorkflow.migrations.includes("engineering-section-delivery-flow"), "known section migration should be explicit");
|
|
987
|
-
assert(migrationResult.actions.some(item => item.action === "would-archive" && item.path.includes("ENGINEERING.pre-4.1.
|
|
987
|
+
assert(migrationResult.actions.some(item => item.action === "would-archive" && item.path.includes("ENGINEERING.pre-4.1.2")), "controlled section cleanup should archive the previous ENGINEERING file");
|
|
988
988
|
run("node", [cli, "sync", "--projects", repo]);
|
|
989
989
|
assert(!fs.readFileSync(engineering, "utf8").includes("Known obsolete workflow"), "known duplicate workflow section should be removed");
|
|
990
990
|
|
|
@@ -996,14 +996,14 @@ function testEngineeringFrameworkAllowsProjectFactsButRejectsDuplicateWorkflow()
|
|
|
996
996
|
}
|
|
997
997
|
|
|
998
998
|
function testReleaseVersionMarkersStayInSync() {
|
|
999
|
-
const expected = "4.1.
|
|
999
|
+
const expected = "4.1.2";
|
|
1000
1000
|
const pkg = JSON.parse(fs.readFileSync(path.join(repoRoot, "package.json"), "utf8"));
|
|
1001
1001
|
const lock = JSON.parse(fs.readFileSync(path.join(repoRoot, "package-lock.json"), "utf8"));
|
|
1002
1002
|
const policy = JSON.parse(fs.readFileSync(
|
|
1003
1003
|
path.join(repoRoot, "src", "auto-coding-skill", "data", "policies", "workflow-migrations-v1.json"),
|
|
1004
1004
|
"utf8",
|
|
1005
1005
|
));
|
|
1006
|
-
assert(pkg.version === expected, "package version must match the 4.1.
|
|
1006
|
+
assert(pkg.version === expected, "package version must match the 4.1.2 release");
|
|
1007
1007
|
assert(lock.version === expected && lock.packages[""].version === expected, "package-lock versions must match");
|
|
1008
1008
|
assert(policy.managed_versions.engineering === expected && policy.managed_versions.agents === expected, "managed workflow versions must match");
|
|
1009
1009
|
for (const rel of [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elvis1513/auto-coding-skill",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.2",
|
|
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": {
|
|
@@ -15,11 +15,14 @@
|
|
|
15
15
|
"LICENSE"
|
|
16
16
|
],
|
|
17
17
|
"scripts": {
|
|
18
|
+
"clean:cache": "find cli src -type d -name '__pycache__' -prune -exec rm -rf {} +",
|
|
19
|
+
"prepack": "npm run clean:cache",
|
|
20
|
+
"check:package": "npm run clean:cache && node cli/src/check-package.js",
|
|
18
21
|
"test": "node -c cli/src/index.js && node -c cli/src/sync-assets.js && node -c cli/tests/index.test.js && node cli/tests/index.test.js && python3 -c \"import ast, pathlib; files = ['cli/assets/skill/scripts/ap.py', 'cli/assets/skill/scripts/core.py', 'cli/assets/skill/scripts/http_checks.py', 'cli/assets/skill/scripts/scaffold_templates.py']; [ast.parse(pathlib.Path(rel).read_text(encoding='utf-8'), filename=rel, feature_version=(3, 11)) for rel in files]; print('python311-asset-grammar-ok')\" && python3 -m py_compile cli/assets/skill/scripts/ap.py cli/assets/skill/scripts/core.py cli/assets/skill/scripts/http_checks.py cli/assets/skill/scripts/scaffold_templates.py && python3 cli/tests/ap_profiles_test.py && python3 cli/tests/ap_concurrency_test.py && python3 -c \"import pathlib, tomllib; files = sorted(pathlib.Path('cli/assets/agents').glob('*.toml')); [tomllib.loads(path.read_text(encoding='utf-8')) for path in files]; print('asset-agent-toml-ok')\" && find cli -type d -name '__pycache__' -prune -exec rm -rf {} +",
|
|
19
22
|
"test:src": "python3 -c \"import ast, pathlib; files = ['src/auto-coding-skill/scripts/ap.py', 'src/auto-coding-skill/scripts/core.py', 'src/auto-coding-skill/scripts/http_checks.py', 'src/auto-coding-skill/scripts/scaffold_templates.py']; [ast.parse(pathlib.Path(rel).read_text(encoding='utf-8'), filename=rel, feature_version=(3, 11)) for rel in files]; print('python311-src-grammar-ok')\" && python3 -m py_compile src/auto-coding-skill/scripts/ap.py src/auto-coding-skill/scripts/core.py src/auto-coding-skill/scripts/http_checks.py src/auto-coding-skill/scripts/scaffold_templates.py && python3 -c \"import pathlib, tomllib; files = sorted(pathlib.Path('src/agents').glob('*.toml')); [tomllib.loads(path.read_text(encoding='utf-8')) for path in files]; print('src-agent-toml-ok')\" && find src -type d -name '__pycache__' -prune -exec rm -rf {} +",
|
|
20
23
|
"check:assets": "node cli/src/sync-assets.js --check",
|
|
21
24
|
"sync-assets": "node cli/src/sync-assets.js",
|
|
22
|
-
"release:check": "npm run check:assets && npm run test:src && npm run test && npm
|
|
25
|
+
"release:check": "npm run check:assets && npm run test:src && npm run test && npm run check:package"
|
|
23
26
|
},
|
|
24
27
|
"license": "MIT",
|
|
25
28
|
"publishConfig": {
|
|
Binary file
|
|
Binary file
|