@elvis1513/auto-coding-skill 4.0.0 → 4.1.1
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 +61 -14
- package/cli/assets/agents/reviewer.toml +3 -2
- package/cli/assets/skill/SKILL.md +38 -92
- package/cli/assets/skill/data/contracts/orchestration-v1.schema.json +16 -1
- package/cli/assets/skill/data/policies/workflow-migrations-v1.json +291 -5
- package/cli/assets/skill/data/templates/ENGINEERING.md +40 -134
- package/cli/assets/skill/data/templates/bridges/AGENTS.md +117 -27
- 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/cli/assets/skill/scripts/ap.py +427 -57
- package/cli/assets/skill/scripts/core.py +21 -5
- package/cli/assets/skill/scripts/scaffold_templates.py +40 -5
- package/cli/src/index.js +192 -85
- package/cli/tests/ap_concurrency_test.py +77 -11
- package/cli/tests/ap_profiles_test.py +66 -23
- package/cli/tests/index.test.js +98 -66
- package/package.json +1 -1
- package/cli/assets/skill/data/templates/docs/tasks/closure-log.md +0 -17
- package/cli/assets/skill/data/templates/docs/tasks/taskbook.md +0 -30
|
@@ -6,6 +6,7 @@ from __future__ import annotations
|
|
|
6
6
|
|
|
7
7
|
import os
|
|
8
8
|
import re
|
|
9
|
+
import signal
|
|
9
10
|
import shutil
|
|
10
11
|
import subprocess
|
|
11
12
|
from pathlib import Path
|
|
@@ -108,8 +109,23 @@ def find_config(repo: Path) -> Path:
|
|
|
108
109
|
)
|
|
109
110
|
|
|
110
111
|
|
|
111
|
-
def run_shell(command: str, cwd: Optional[Path] = None) -> None:
|
|
112
|
-
"""Run shell command
|
|
113
|
-
p = subprocess.
|
|
114
|
-
|
|
115
|
-
|
|
112
|
+
def run_shell(command: str, cwd: Optional[Path] = None, timeout_s: Optional[float] = None) -> None:
|
|
113
|
+
"""Run a shell command and terminate its process group on timeout."""
|
|
114
|
+
p = subprocess.Popen(
|
|
115
|
+
["bash", "-lc", command],
|
|
116
|
+
cwd=str(cwd) if cwd else None,
|
|
117
|
+
text=True,
|
|
118
|
+
start_new_session=True,
|
|
119
|
+
)
|
|
120
|
+
try:
|
|
121
|
+
returncode = p.wait(timeout=timeout_s)
|
|
122
|
+
except subprocess.TimeoutExpired as exc:
|
|
123
|
+
os.killpg(p.pid, signal.SIGTERM)
|
|
124
|
+
try:
|
|
125
|
+
p.wait(timeout=2)
|
|
126
|
+
except subprocess.TimeoutExpired:
|
|
127
|
+
os.killpg(p.pid, signal.SIGKILL)
|
|
128
|
+
p.wait()
|
|
129
|
+
raise APError(f"Command timed out after {timeout_s:.1f}s: {command}") from exc
|
|
130
|
+
if returncode != 0:
|
|
131
|
+
raise APError(f"Command failed ({returncode}): {command}")
|
|
@@ -5,6 +5,41 @@ from __future__ import annotations
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
TEMPLATES: dict[str, dict[str, str]] = {
|
|
8
|
+
"project": {
|
|
9
|
+
"docs/project/overview.md": """# Project Overview
|
|
10
|
+
|
|
11
|
+
Record durable project facts, not workflow rules.
|
|
12
|
+
|
|
13
|
+
## Product scope and non-goals
|
|
14
|
+
## Domain boundaries and invariants
|
|
15
|
+
## Users, roles, and critical journeys
|
|
16
|
+
## External systems and safety boundaries
|
|
17
|
+
## Current contracts and decision links
|
|
18
|
+
""",
|
|
19
|
+
"docs/project/repository-map.md": """# Repository Map
|
|
20
|
+
|
|
21
|
+
Map existing ownership and reuse points. Keep behavior details in code/tests.
|
|
22
|
+
|
|
23
|
+
| Area | Paths | Responsibility | Generated / source | Validation route |
|
|
24
|
+
| --- | --- | --- | --- | --- |
|
|
25
|
+
|
|
26
|
+
## Cross-module dependencies
|
|
27
|
+
## Shared components and helpers
|
|
28
|
+
## Files or directories with special ownership
|
|
29
|
+
""",
|
|
30
|
+
"docs/project/runtime.md": """# Runtime And Deployment Facts
|
|
31
|
+
|
|
32
|
+
Record current environment topology and operating constraints, not normal
|
|
33
|
+
development gate rules.
|
|
34
|
+
|
|
35
|
+
## Local runtime
|
|
36
|
+
## Shared services and dependencies
|
|
37
|
+
## Jenkins and artifact flow
|
|
38
|
+
## Deployment topology
|
|
39
|
+
## External-device / production-write safeguards
|
|
40
|
+
## Fixtures, simulators, and repeatable diagnostic entry points
|
|
41
|
+
""",
|
|
42
|
+
},
|
|
8
43
|
"api": {
|
|
9
44
|
"docs/interfaces/api.md": """# API Contract
|
|
10
45
|
|
|
@@ -23,10 +58,10 @@ Record only current, externally relevant endpoints or events.
|
|
|
23
58
|
""",
|
|
24
59
|
},
|
|
25
60
|
"design": {
|
|
26
|
-
"docs/design/_TEMPLATE-DD.md": """# DD — <
|
|
61
|
+
"docs/design/_TEMPLATE-DD.md": """# DD — <Decision ID> <Title>
|
|
27
62
|
|
|
28
63
|
- Status: Draft | Reviewed | Approved
|
|
29
|
-
- Related
|
|
64
|
+
- Related requirement / commit:
|
|
30
65
|
|
|
31
66
|
## Context and goal
|
|
32
67
|
## Scope and non-goals
|
|
@@ -56,7 +91,7 @@ Project conventions are authoritative. The generic checker is advisory unless
|
|
|
56
91
|
|
|
57
92
|
- Status: Proposed | Accepted | Superseded
|
|
58
93
|
- Date: YYYY-MM-DD
|
|
59
|
-
- Related
|
|
94
|
+
- Related requirement / commit:
|
|
60
95
|
|
|
61
96
|
## Context
|
|
62
97
|
## Decision
|
|
@@ -67,7 +102,7 @@ Project conventions are authoritative. The generic checker is advisory unless
|
|
|
67
102
|
""",
|
|
68
103
|
},
|
|
69
104
|
"review": {
|
|
70
|
-
"docs/reviews/_TEMPLATE-REVIEW.md": """# Review — <
|
|
105
|
+
"docs/reviews/_TEMPLATE-REVIEW.md": """# Review — <Change ID>
|
|
71
106
|
|
|
72
107
|
- Scope:
|
|
73
108
|
- Evidence:
|
|
@@ -79,7 +114,7 @@ List P0/P1/P2/P3 findings with impact, evidence, and remediation.
|
|
|
79
114
|
|
|
80
115
|
## Verdict
|
|
81
116
|
|
|
82
|
-
|
|
117
|
+
approved | changes-requested
|
|
83
118
|
""",
|
|
84
119
|
},
|
|
85
120
|
"testing": {
|
package/cli/src/index.js
CHANGED
|
@@ -111,11 +111,8 @@ function validateCommandArgs(args){
|
|
|
111
111
|
if (invalid.length) {
|
|
112
112
|
die(`${invalid.map(name => ARG_FLAGS[name] || name).join(", ")} not valid for '${args.cmd}'`);
|
|
113
113
|
}
|
|
114
|
-
if (args.cmd === "sync" &&
|
|
115
|
-
die("--components
|
|
116
|
-
}
|
|
117
|
-
if (args.cmd === "sync" && args.components === "skill" && args.resetAgentModels) {
|
|
118
|
-
die("--reset-agent-models cannot be used with --components skill");
|
|
114
|
+
if (args.cmd === "sync" && args.components !== "all") {
|
|
115
|
+
die("partial Skill sync was removed in 4.1; use --components all so Skill, AGENTS.md, ENGINEERING.md, agents, and runtime converge together");
|
|
119
116
|
}
|
|
120
117
|
}
|
|
121
118
|
|
|
@@ -493,7 +490,33 @@ function applyKnownOfficialFragments(text, documentPath, policy){
|
|
|
493
490
|
for (const fragment of policy.known_official_fragments) {
|
|
494
491
|
if (!fragment.paths?.includes(documentPath) || !fragment.text) continue;
|
|
495
492
|
let pattern;
|
|
496
|
-
if (fragment.match === "
|
|
493
|
+
if (fragment.match === "heading-section") {
|
|
494
|
+
const lines = output.match(/.*(?:\r?\n|$)/g).filter(Boolean);
|
|
495
|
+
const offsets = [];
|
|
496
|
+
let cursor = 0;
|
|
497
|
+
for (const line of lines) {
|
|
498
|
+
offsets.push(cursor);
|
|
499
|
+
cursor += line.length;
|
|
500
|
+
}
|
|
501
|
+
const spans = [];
|
|
502
|
+
for (let index = 0; index < lines.length; index += 1) {
|
|
503
|
+
const heading = lines[index].replace(/\r?\n$/, "").match(/^(\s*)(#{1,6})\s+(.+?)\s*#*\s*$/);
|
|
504
|
+
if (!heading || heading[3].trim() !== fragment.text.trim()) continue;
|
|
505
|
+
const level = heading[2].length;
|
|
506
|
+
let end = index + 1;
|
|
507
|
+
while (end < lines.length) {
|
|
508
|
+
const next = lines[end].replace(/\r?\n$/, "").match(/^\s*(#{1,6})\s+/);
|
|
509
|
+
if (next && next[1].length <= level) break;
|
|
510
|
+
end += 1;
|
|
511
|
+
}
|
|
512
|
+
spans.push([offsets[index], end < lines.length ? offsets[end] : output.length]);
|
|
513
|
+
}
|
|
514
|
+
if (spans.length) {
|
|
515
|
+
for (const [start, end] of spans.reverse()) output = output.slice(0, start) + output.slice(end);
|
|
516
|
+
migrations.push(fragment.id);
|
|
517
|
+
}
|
|
518
|
+
continue;
|
|
519
|
+
} else if (fragment.match === "exact-line") {
|
|
497
520
|
pattern = new RegExp(`^[\\t ]*${escapeRegExp(fragment.text.trim())}[\\t ]*(?:\\r?\\n|$)`, "gm");
|
|
498
521
|
} else if (fragment.match === "exact-block") {
|
|
499
522
|
const source = fragment.text.split("\n").map(escapeRegExp).join("\\r?\\n");
|
|
@@ -656,6 +679,8 @@ function planEngineeringSync(project, assetSkill, policy = loadWorkflowMigration
|
|
|
656
679
|
detail: "unknown workflow directives conflict with the managed fast-gate policy",
|
|
657
680
|
};
|
|
658
681
|
}
|
|
682
|
+
const sectionMigration = migrated.migrations.some(item => item.startsWith("engineering-section-"));
|
|
683
|
+
const archive = sectionMigration ? engineeringArchivePlan(root, current, templateRegion.version) : {};
|
|
659
684
|
return {
|
|
660
685
|
state: "legacy-custom",
|
|
661
686
|
version: templateRegion.version,
|
|
@@ -664,6 +689,7 @@ function planEngineeringSync(project, assetSkill, policy = loadWorkflowMigration
|
|
|
664
689
|
engineering,
|
|
665
690
|
migrations: migrated.migrations,
|
|
666
691
|
conflicts: [],
|
|
692
|
+
...archive,
|
|
667
693
|
};
|
|
668
694
|
}
|
|
669
695
|
const beforeParts = splitEngineeringDocument(current.slice(0, currentRegion.start));
|
|
@@ -689,6 +715,8 @@ function planEngineeringSync(project, assetSkill, policy = loadWorkflowMigration
|
|
|
689
715
|
const migratedRegion = inspectManagedWorkflow(migratedCurrent);
|
|
690
716
|
const output = replaceManagedBlock(migratedCurrent, migratedRegion, templateRegion.block);
|
|
691
717
|
if (current === output) return { state: "current", version: templateRegion.version, output, engineering, migrations: [], conflicts: [] };
|
|
718
|
+
const sectionMigration = migrations.some(item => item.startsWith("engineering-section-"));
|
|
719
|
+
const archive = sectionMigration ? engineeringArchivePlan(root, current, templateRegion.version) : {};
|
|
692
720
|
return {
|
|
693
721
|
state: "stale",
|
|
694
722
|
version: templateRegion.version,
|
|
@@ -697,6 +725,34 @@ function planEngineeringSync(project, assetSkill, policy = loadWorkflowMigration
|
|
|
697
725
|
engineering,
|
|
698
726
|
migrations,
|
|
699
727
|
conflicts: [],
|
|
728
|
+
...archive,
|
|
729
|
+
};
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
function engineeringArchivePlan(root, current, version){
|
|
733
|
+
const archiveHeader = [
|
|
734
|
+
`# Archived ENGINEERING.md before auto-coding-skill ${version} docs convergence`,
|
|
735
|
+
"",
|
|
736
|
+
"This file is historical and non-authoritative. Known duplicate workflow sections",
|
|
737
|
+
"were removed from docs/ENGINEERING.md. Move any still-current project facts into",
|
|
738
|
+
"docs/ENGINEERING.md project-fact sections or docs/project/.",
|
|
739
|
+
"",
|
|
740
|
+
"---",
|
|
741
|
+
"",
|
|
742
|
+
].join("\n");
|
|
743
|
+
const archiveOutput = `${archiveHeader}${current}`;
|
|
744
|
+
const archiveDir = path.join(root, "docs", "archive", "workflow");
|
|
745
|
+
let archiveDocument = path.join(archiveDir, `ENGINEERING.pre-${version}.md`);
|
|
746
|
+
if (exists(archiveDocument) && fs.readFileSync(archiveDocument, "utf8") !== archiveOutput) {
|
|
747
|
+
archiveDocument = path.join(
|
|
748
|
+
archiveDir,
|
|
749
|
+
`ENGINEERING.pre-${version}-${engineeringBodyHash(current).slice(0, 12)}.md`,
|
|
750
|
+
);
|
|
751
|
+
}
|
|
752
|
+
return {
|
|
753
|
+
archiveDocument,
|
|
754
|
+
archiveOutput,
|
|
755
|
+
archiveRequired: !exists(archiveDocument),
|
|
700
756
|
};
|
|
701
757
|
}
|
|
702
758
|
|
|
@@ -713,71 +769,39 @@ function planAgentsDocumentSync(project, assetSkill, policy = loadWorkflowMigrat
|
|
|
713
769
|
return { state: "missing", version: templateRegion.version, output: template, agentsDocument, migrations: [], conflicts: [] };
|
|
714
770
|
}
|
|
715
771
|
const current = fs.readFileSync(agentsDocument, "utf8");
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
return {
|
|
719
|
-
state: "legacy-official",
|
|
720
|
-
version: templateRegion.version,
|
|
721
|
-
output: template,
|
|
722
|
-
agentsDocument,
|
|
723
|
-
migrations: [`agents-sha256:${currentHash}`],
|
|
724
|
-
conflicts: [],
|
|
725
|
-
};
|
|
726
|
-
}
|
|
727
|
-
const currentRegion = inspectManagedAgentsDocument(current);
|
|
728
|
-
if (currentRegion.state === "invalid") return { ...currentRegion, agentsDocument };
|
|
729
|
-
if (currentRegion.state === "absent") {
|
|
730
|
-
const migrated = migrateDocumentText(current, "AGENTS.md", policy);
|
|
731
|
-
if (migrated.conflicts.length) {
|
|
732
|
-
return {
|
|
733
|
-
state: "conflict",
|
|
734
|
-
version: templateRegion.version,
|
|
735
|
-
agentsDocument,
|
|
736
|
-
migrations: migrated.migrations,
|
|
737
|
-
conflicts: migrated.conflicts,
|
|
738
|
-
detail: "unknown workflow directives conflict with the managed fast-gate policy",
|
|
739
|
-
};
|
|
740
|
-
}
|
|
741
|
-
const separator = migrated.output ? (migrated.output.startsWith("\n") ? "" : "\n") : "";
|
|
742
|
-
return {
|
|
743
|
-
state: "legacy-custom",
|
|
744
|
-
version: templateRegion.version,
|
|
745
|
-
preservedCustom: true,
|
|
746
|
-
output: `${templateRegion.block}${separator}${migrated.output}`,
|
|
747
|
-
agentsDocument,
|
|
748
|
-
migrations: migrated.migrations,
|
|
749
|
-
conflicts: [],
|
|
750
|
-
};
|
|
772
|
+
if (current === template) {
|
|
773
|
+
return { state: "current", version: templateRegion.version, output: template, agentsDocument, migrations: [], conflicts: [] };
|
|
751
774
|
}
|
|
752
|
-
const
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
775
|
+
const archiveHeader = [
|
|
776
|
+
`# Archived AGENTS.md before auto-coding-skill ${templateRegion.version}`,
|
|
777
|
+
"",
|
|
778
|
+
"This file is historical and non-authoritative. The root AGENTS.md is fully managed.",
|
|
779
|
+
"Move any still-current project facts into docs/ENGINEERING.md or docs/project/",
|
|
780
|
+
"without copying workflow rules back into the root AGENTS.md.",
|
|
781
|
+
"",
|
|
782
|
+
"---",
|
|
783
|
+
"",
|
|
784
|
+
].join("\n");
|
|
785
|
+
const archiveOutput = `${archiveHeader}${current}`;
|
|
786
|
+
const archiveDir = path.join(root, "docs", "archive", "workflow");
|
|
787
|
+
let archiveDocument = path.join(archiveDir, `AGENTS.pre-${templateRegion.version}.md`);
|
|
788
|
+
if (exists(archiveDocument) && fs.readFileSync(archiveDocument, "utf8") !== archiveOutput) {
|
|
789
|
+
archiveDocument = path.join(
|
|
790
|
+
archiveDir,
|
|
791
|
+
`AGENTS.pre-${templateRegion.version}-${engineeringBodyHash(current).slice(0, 12)}.md`,
|
|
792
|
+
);
|
|
769
793
|
}
|
|
770
|
-
const
|
|
771
|
-
const migratedRegion = inspectManagedAgentsDocument(migratedCurrent);
|
|
772
|
-
const output = replaceManagedBlock(migratedCurrent, migratedRegion, templateRegion.block);
|
|
773
|
-
if (current === output) return { state: "current", version: templateRegion.version, output, agentsDocument, migrations: [], conflicts: [] };
|
|
794
|
+
const currentRegion = inspectManagedAgentsDocument(current);
|
|
774
795
|
return {
|
|
775
|
-
state: "stale",
|
|
796
|
+
state: currentRegion.state === "present" ? "stale" : "legacy-custom",
|
|
776
797
|
version: templateRegion.version,
|
|
777
|
-
previousVersion: currentRegion.version,
|
|
778
|
-
output,
|
|
798
|
+
...(currentRegion.state === "present" ? { previousVersion: currentRegion.version } : {}),
|
|
799
|
+
output: template,
|
|
779
800
|
agentsDocument,
|
|
780
|
-
|
|
801
|
+
archiveDocument,
|
|
802
|
+
archiveOutput,
|
|
803
|
+
archiveRequired: !exists(archiveDocument),
|
|
804
|
+
migrations: ["agents-whole-file-replacement"],
|
|
781
805
|
conflicts: [],
|
|
782
806
|
};
|
|
783
807
|
}
|
|
@@ -797,13 +821,14 @@ function publicEngineeringPlan(plan){
|
|
|
797
821
|
...(plan.previousVersion ? { previousVersion: plan.previousVersion } : {}),
|
|
798
822
|
...(plan.previousBodyHash ? { previousBodyHash: plan.previousBodyHash } : {}),
|
|
799
823
|
...(plan.preservedCustom ? { preservedCustom: true } : {}),
|
|
824
|
+
...(plan.archiveDocument ? { archive: plan.archiveDocument } : {}),
|
|
800
825
|
...(plan.migrations?.length ? { migrations: plan.migrations } : {}),
|
|
801
826
|
...(plan.conflicts?.length ? { conflicts: plan.conflicts } : {}),
|
|
802
827
|
...(plan.detail ? { detail: plan.detail } : {}),
|
|
803
828
|
};
|
|
804
829
|
}
|
|
805
830
|
|
|
806
|
-
function
|
|
831
|
+
function registeredTasks(project){
|
|
807
832
|
const root = path.resolve(project);
|
|
808
833
|
let commonDir;
|
|
809
834
|
try {
|
|
@@ -817,7 +842,7 @@ function registeredLegacyTasks(project){
|
|
|
817
842
|
}
|
|
818
843
|
const tasksDir = path.join(commonDir, "auto-coding-skill", "tasks");
|
|
819
844
|
if (!exists(tasksDir)) return [];
|
|
820
|
-
const
|
|
845
|
+
const registered = [];
|
|
821
846
|
for (const entry of fs.readdirSync(tasksDir, { withFileTypes: true })) {
|
|
822
847
|
if (!entry.isFile() || !entry.name.endsWith(".json")) continue;
|
|
823
848
|
const manifestPath = path.join(tasksDir, entry.name);
|
|
@@ -825,24 +850,22 @@ function registeredLegacyTasks(project){
|
|
|
825
850
|
try {
|
|
826
851
|
manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
|
|
827
852
|
} catch {
|
|
828
|
-
|
|
853
|
+
registered.push({ project: root, manifest: entry.name, schema: "invalid" });
|
|
829
854
|
continue;
|
|
830
855
|
}
|
|
831
856
|
const schema = Number(manifest?.schema ?? 0);
|
|
832
|
-
|
|
833
|
-
legacy.push({ project: root, manifest: entry.name, schema: Number.isFinite(schema) ? schema : "invalid" });
|
|
834
|
-
}
|
|
857
|
+
registered.push({ project: root, manifest: entry.name, schema: Number.isFinite(schema) ? schema : "invalid" });
|
|
835
858
|
}
|
|
836
|
-
return
|
|
859
|
+
return registered;
|
|
837
860
|
}
|
|
838
861
|
|
|
839
|
-
function
|
|
840
|
-
const
|
|
841
|
-
if (!
|
|
842
|
-
const locations =
|
|
862
|
+
function assertNoRegisteredTasks(projects){
|
|
863
|
+
const active = projects.flatMap(project => registeredTasks(project));
|
|
864
|
+
if (!active.length) return;
|
|
865
|
+
const locations = active.map(item => `${item.project}:${item.manifest}(schema=${item.schema})`).join(", ");
|
|
843
866
|
die(
|
|
844
|
-
"refusing the entire sync batch because registered auto-coding tasks
|
|
845
|
-
+ `${locations}\nFinish, integrate,
|
|
867
|
+
"refusing the entire sync batch because registered auto-coding tasks are still active: "
|
|
868
|
+
+ `${locations}\nFinish, integrate, or clean these tasks with the currently installed runtime before upgrading. `
|
|
846
869
|
+ "sync will not change the lifecycle semantics of an in-flight task.",
|
|
847
870
|
);
|
|
848
871
|
}
|
|
@@ -884,6 +907,36 @@ function frontmatterPathState(text, keyPath){
|
|
|
884
907
|
return { present: false, value: "" };
|
|
885
908
|
}
|
|
886
909
|
|
|
910
|
+
function frontmatterSequenceHasItems(text, keyPath){
|
|
911
|
+
const frontmatter = extractFrontmatter(text);
|
|
912
|
+
if (!frontmatter) return false;
|
|
913
|
+
const lines = frontmatter.split(/\r?\n/);
|
|
914
|
+
const stack = [];
|
|
915
|
+
for (let index = 0; index < lines.length; index += 1) {
|
|
916
|
+
const rawLine = lines[index];
|
|
917
|
+
if (!rawLine.trim() || rawLine.trim().startsWith("#")) continue;
|
|
918
|
+
const match = rawLine.match(/^(\s*)(["']?[^:"']+["']?)\s*:(.*)$/);
|
|
919
|
+
if (!match) continue;
|
|
920
|
+
const indent = match[1].replace(/\t/g, " ").length;
|
|
921
|
+
const key = match[2].replace(/^["']|["']$/g, "").trim();
|
|
922
|
+
while (stack.length && stack[stack.length - 1].indent >= indent) stack.pop();
|
|
923
|
+
const currentPath = [...stack.map(item => item.key), key];
|
|
924
|
+
if (currentPath.length === keyPath.length && currentPath.every((part, pathIndex) => part === keyPath[pathIndex])) {
|
|
925
|
+
const inline = match[3].trim();
|
|
926
|
+
if (/^\[(?:\s*[^\]])/.test(inline)) return true;
|
|
927
|
+
for (let child = index + 1; child < lines.length; child += 1) {
|
|
928
|
+
if (!lines[child].trim() || lines[child].trim().startsWith("#")) continue;
|
|
929
|
+
const childIndent = lines[child].match(/^\s*/)[0].replace(/\t/g, " ").length;
|
|
930
|
+
if (childIndent <= indent) return false;
|
|
931
|
+
if (/^\s*-\s+\S/.test(lines[child])) return true;
|
|
932
|
+
}
|
|
933
|
+
return false;
|
|
934
|
+
}
|
|
935
|
+
stack.push({ indent, key });
|
|
936
|
+
}
|
|
937
|
+
return false;
|
|
938
|
+
}
|
|
939
|
+
|
|
887
940
|
function legacyGateEscalationTokens(text){
|
|
888
941
|
const frontmatter = extractFrontmatter(text);
|
|
889
942
|
if (!frontmatter) return [];
|
|
@@ -1029,10 +1082,12 @@ function projectStatus(project, assetSkill, assetAgents){
|
|
|
1029
1082
|
{ label: "concurrency.cleanup_merged", path: ["concurrency", "cleanup_merged"] },
|
|
1030
1083
|
{ label: "concurrency.delete_remote_branch", path: ["concurrency", "delete_remote_branch"] },
|
|
1031
1084
|
{ label: "concurrency.disposable_ignored", path: ["concurrency", "disposable_ignored"] },
|
|
1032
|
-
{ label: "commands.project_fast", path: ["commands", "project_fast"], filled: true },
|
|
1033
1085
|
{ label: "validation.on_unmapped", path: ["validation", "on_unmapped"] },
|
|
1034
|
-
{ label: "validation.
|
|
1086
|
+
{ label: "validation.max_command_seconds", path: ["validation", "max_command_seconds"] },
|
|
1087
|
+
{ label: "validation.max_total_seconds", path: ["validation", "max_total_seconds"] },
|
|
1088
|
+
{ label: "validation.routes", path: ["validation", "routes"], sequence: true },
|
|
1035
1089
|
{ label: "risk.rules", path: ["risk", "rules"] },
|
|
1090
|
+
{ label: "docs.framework", path: ["docs", "framework"], filled: true },
|
|
1036
1091
|
{ label: "project.name", path: ["project", "name"], filled: true },
|
|
1037
1092
|
{ label: "access.project.frontend.url", path: ["access", "project", "frontend", "url"], filled: true },
|
|
1038
1093
|
{ label: "access.project.frontend.username", path: ["access", "project", "frontend", "username"], filled: true },
|
|
@@ -1061,12 +1116,33 @@ function projectStatus(project, assetSkill, assetAgents){
|
|
|
1061
1116
|
const states = requiredConfigPaths.map(item => ({ item, state: frontmatterPathState(text, item.path) }));
|
|
1062
1117
|
missingConfigPaths = states.filter(({ state }) => !state.present).map(({ item }) => item.label);
|
|
1063
1118
|
unfilledConfigTokens = states
|
|
1064
|
-
.filter(({ item, state }) => state.present &&
|
|
1119
|
+
.filter(({ item, state }) => state.present && (
|
|
1120
|
+
(item.filled === true && !frontmatterValueIsFilled(state.value))
|
|
1121
|
+
|| (item.sequence === true && !frontmatterSequenceHasItems(text, item.path))
|
|
1122
|
+
))
|
|
1065
1123
|
.map(({ item }) => item.label);
|
|
1066
1124
|
const isolationState = frontmatterPathState(text, ["concurrency", "isolation"]);
|
|
1067
1125
|
if (isolationState.present && !["adaptive", "worktree"].includes(frontmatterScalarValue(isolationState.value).toLowerCase())) {
|
|
1068
1126
|
invalidConfigTokens.push("concurrency.isolation (must be adaptive or worktree)");
|
|
1069
1127
|
}
|
|
1128
|
+
for (const [pathParts, maximum] of [
|
|
1129
|
+
[["validation", "max_command_seconds"], 120],
|
|
1130
|
+
[["validation", "max_total_seconds"], 180],
|
|
1131
|
+
]) {
|
|
1132
|
+
const state = frontmatterPathState(text, pathParts);
|
|
1133
|
+
if (!state.present) continue;
|
|
1134
|
+
const value = Number(frontmatterScalarValue(state.value));
|
|
1135
|
+
if (!Number.isFinite(value) || value <= 0 || value > maximum) {
|
|
1136
|
+
invalidConfigTokens.push(`${pathParts.join(".")} (must be > 0 and <= ${maximum})`);
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
const commandState = frontmatterPathState(text, ["validation", "max_command_seconds"]);
|
|
1140
|
+
const totalState = frontmatterPathState(text, ["validation", "max_total_seconds"]);
|
|
1141
|
+
const commandBudget = Number(frontmatterScalarValue(commandState.value));
|
|
1142
|
+
const totalBudget = Number(frontmatterScalarValue(totalState.value));
|
|
1143
|
+
if (commandState.present && totalState.present && Number.isFinite(commandBudget) && Number.isFinite(totalBudget) && commandBudget > totalBudget) {
|
|
1144
|
+
invalidConfigTokens.push("validation.max_command_seconds (cannot exceed max_total_seconds)");
|
|
1145
|
+
}
|
|
1070
1146
|
invalidConfigTokens.push(...legacyGateEscalationTokens(text));
|
|
1071
1147
|
}
|
|
1072
1148
|
const missingConfigTokens = [...missingConfigPaths, ...unfilledConfigTokens, ...invalidConfigTokens];
|
|
@@ -1174,6 +1250,15 @@ function syncProject(project, assetSkill, assetAgents, dryRun, resetAgentModels
|
|
|
1174
1250
|
fs.copyFileSync(path.join(assetSkill, "data", "templates", "tools", "ap.py"), path.join(toolDir, "ap.py"));
|
|
1175
1251
|
for (const copied of copyMissingDocs(assetSkill, root)) actions.push({ action: "create", path: copied });
|
|
1176
1252
|
if (plan.state !== "current") {
|
|
1253
|
+
if (plan.archiveRequired) {
|
|
1254
|
+
fs.mkdirSync(path.dirname(plan.archiveDocument), { recursive: true });
|
|
1255
|
+
fs.writeFileSync(plan.archiveDocument, plan.archiveOutput);
|
|
1256
|
+
actions.push({
|
|
1257
|
+
action: "archive",
|
|
1258
|
+
path: path.relative(root, plan.archiveDocument),
|
|
1259
|
+
detail: "previous ENGINEERING.md before duplicate workflow cleanup",
|
|
1260
|
+
});
|
|
1261
|
+
}
|
|
1177
1262
|
fs.mkdirSync(path.dirname(plan.engineering), { recursive: true });
|
|
1178
1263
|
fs.writeFileSync(plan.engineering, plan.output);
|
|
1179
1264
|
actions.push({
|
|
@@ -1183,6 +1268,15 @@ function syncProject(project, assetSkill, assetAgents, dryRun, resetAgentModels
|
|
|
1183
1268
|
});
|
|
1184
1269
|
}
|
|
1185
1270
|
if (agentsDocumentPlan.state !== "current") {
|
|
1271
|
+
if (agentsDocumentPlan.archiveRequired) {
|
|
1272
|
+
fs.mkdirSync(path.dirname(agentsDocumentPlan.archiveDocument), { recursive: true });
|
|
1273
|
+
fs.writeFileSync(agentsDocumentPlan.archiveDocument, agentsDocumentPlan.archiveOutput);
|
|
1274
|
+
actions.push({
|
|
1275
|
+
action: "archive",
|
|
1276
|
+
path: path.relative(root, agentsDocumentPlan.archiveDocument),
|
|
1277
|
+
detail: "previous root AGENTS.md; historical and non-authoritative",
|
|
1278
|
+
});
|
|
1279
|
+
}
|
|
1186
1280
|
fs.writeFileSync(agentsDocumentPlan.agentsDocument, agentsDocumentPlan.output);
|
|
1187
1281
|
actions.push({
|
|
1188
1282
|
action: agentsDocumentPlan.state === "missing" ? "create" : "update",
|
|
@@ -1195,6 +1289,13 @@ function syncProject(project, assetSkill, assetAgents, dryRun, resetAgentModels
|
|
|
1195
1289
|
if (!exists(path.join(root, "docs", rel))) actions.push({ action: "would-create", path: path.join("docs", rel) });
|
|
1196
1290
|
}
|
|
1197
1291
|
if (plan.state !== "current") {
|
|
1292
|
+
if (plan.archiveRequired) {
|
|
1293
|
+
actions.push({
|
|
1294
|
+
action: "would-archive",
|
|
1295
|
+
path: path.relative(root, plan.archiveDocument),
|
|
1296
|
+
detail: "previous ENGINEERING.md before duplicate workflow cleanup",
|
|
1297
|
+
});
|
|
1298
|
+
}
|
|
1198
1299
|
actions.push({
|
|
1199
1300
|
action: plan.state === "missing" ? "would-create" : "would-update",
|
|
1200
1301
|
path: path.join("docs", "ENGINEERING.md"),
|
|
@@ -1202,6 +1303,13 @@ function syncProject(project, assetSkill, assetAgents, dryRun, resetAgentModels
|
|
|
1202
1303
|
});
|
|
1203
1304
|
}
|
|
1204
1305
|
if (agentsDocumentPlan.state !== "current") {
|
|
1306
|
+
if (agentsDocumentPlan.archiveRequired) {
|
|
1307
|
+
actions.push({
|
|
1308
|
+
action: "would-archive",
|
|
1309
|
+
path: path.relative(root, agentsDocumentPlan.archiveDocument),
|
|
1310
|
+
detail: "previous root AGENTS.md; historical and non-authoritative",
|
|
1311
|
+
});
|
|
1312
|
+
}
|
|
1205
1313
|
actions.push({
|
|
1206
1314
|
action: agentsDocumentPlan.state === "missing" ? "would-create" : "would-update",
|
|
1207
1315
|
path: "AGENTS.md",
|
|
@@ -1275,13 +1383,12 @@ autocoding - install auto-coding-skill into generic .agents paths
|
|
|
1275
1383
|
Usage:
|
|
1276
1384
|
autocoding init [--mode project|global] [--dest <repo-root|.agents-dir|skill-dir>] [--force] [--reset-agent-models]
|
|
1277
1385
|
autocoding status --projects <path[,path...]> [--json]
|
|
1278
|
-
autocoding sync --projects <path[,path...]> [--
|
|
1386
|
+
autocoding sync --projects <path[,path...]> [--dry-run] [--json] [--reset-agent-models]
|
|
1279
1387
|
|
|
1280
1388
|
Examples:
|
|
1281
1389
|
autocoding init
|
|
1282
1390
|
autocoding status --projects /Users/elvis/Product/xjmate,/Users/elvis/Product/geesight
|
|
1283
1391
|
autocoding sync --projects /Users/elvis/Product/xjmate --dry-run
|
|
1284
|
-
autocoding sync --projects /Users/elvis/Product/geesight --components skill
|
|
1285
1392
|
|
|
1286
1393
|
Compatibility:
|
|
1287
1394
|
--ai <value> is accepted for old scripts and ignored.
|
|
@@ -1316,7 +1423,7 @@ Compatibility:
|
|
|
1316
1423
|
|
|
1317
1424
|
if (args.cmd === "sync") {
|
|
1318
1425
|
const projects = args.projects.length ? args.projects : [projectRoot()];
|
|
1319
|
-
|
|
1426
|
+
assertNoRegisteredTasks(projects);
|
|
1320
1427
|
const controlledPlans = new Map();
|
|
1321
1428
|
for (const project of projects) {
|
|
1322
1429
|
const root = path.resolve(project);
|