@elvis1513/auto-coding-skill 4.0.0 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -9
- package/cli/assets/agents/reviewer.toml +3 -2
- package/cli/assets/skill/SKILL.md +45 -16
- package/cli/assets/skill/data/policies/workflow-migrations-v1.json +291 -5
- package/cli/assets/skill/data/templates/ENGINEERING.md +46 -19
- package/cli/assets/skill/data/templates/bridges/AGENTS.md +133 -27
- package/cli/assets/skill/scripts/ap.py +241 -50
- package/cli/assets/skill/scripts/scaffold_templates.py +40 -5
- package/cli/src/index.js +172 -85
- package/cli/tests/ap_concurrency_test.py +62 -10
- package/cli/tests/ap_profiles_test.py +27 -20
- package/cli/tests/index.test.js +78 -62
- 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
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
|
-
};
|
|
772
|
+
if (current === template) {
|
|
773
|
+
return { state: "current", version: templateRegion.version, output: template, agentsDocument, migrations: [], conflicts: [] };
|
|
726
774
|
}
|
|
727
|
-
const
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
preservedCustom: true,
|
|
746
|
-
output: `${templateRegion.block}${separator}${migrated.output}`,
|
|
747
|
-
agentsDocument,
|
|
748
|
-
migrations: migrated.migrations,
|
|
749
|
-
conflicts: [],
|
|
750
|
-
};
|
|
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
|
+
);
|
|
751
793
|
}
|
|
752
|
-
const
|
|
753
|
-
const migratedAfter = migrateDocumentText(current.slice(currentRegion.endExclusive), "AGENTS.md", policy);
|
|
754
|
-
const conflicts = [
|
|
755
|
-
...migratedBefore.conflicts,
|
|
756
|
-
...offsetConflicts(migratedAfter.conflicts, lineCount(current.slice(0, currentRegion.endExclusive))),
|
|
757
|
-
];
|
|
758
|
-
const migrations = [...migratedBefore.migrations, ...migratedAfter.migrations];
|
|
759
|
-
if (conflicts.length) {
|
|
760
|
-
return {
|
|
761
|
-
state: "conflict",
|
|
762
|
-
version: templateRegion.version,
|
|
763
|
-
previousVersion: currentRegion.version,
|
|
764
|
-
agentsDocument,
|
|
765
|
-
migrations,
|
|
766
|
-
conflicts,
|
|
767
|
-
detail: "unknown workflow directives conflict with the managed fast-gate policy",
|
|
768
|
-
};
|
|
769
|
-
}
|
|
770
|
-
const migratedCurrent = `${migratedBefore.output}${currentRegion.block}${migratedAfter.output}`;
|
|
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,10 @@ 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.routes", path: ["validation", "routes"] },
|
|
1086
|
+
{ label: "validation.routes", path: ["validation", "routes"], sequence: true },
|
|
1035
1087
|
{ label: "risk.rules", path: ["risk", "rules"] },
|
|
1088
|
+
{ label: "docs.framework", path: ["docs", "framework"], filled: true },
|
|
1036
1089
|
{ label: "project.name", path: ["project", "name"], filled: true },
|
|
1037
1090
|
{ label: "access.project.frontend.url", path: ["access", "project", "frontend", "url"], filled: true },
|
|
1038
1091
|
{ label: "access.project.frontend.username", path: ["access", "project", "frontend", "username"], filled: true },
|
|
@@ -1061,7 +1114,10 @@ function projectStatus(project, assetSkill, assetAgents){
|
|
|
1061
1114
|
const states = requiredConfigPaths.map(item => ({ item, state: frontmatterPathState(text, item.path) }));
|
|
1062
1115
|
missingConfigPaths = states.filter(({ state }) => !state.present).map(({ item }) => item.label);
|
|
1063
1116
|
unfilledConfigTokens = states
|
|
1064
|
-
.filter(({ item, state }) => state.present &&
|
|
1117
|
+
.filter(({ item, state }) => state.present && (
|
|
1118
|
+
(item.filled === true && !frontmatterValueIsFilled(state.value))
|
|
1119
|
+
|| (item.sequence === true && !frontmatterSequenceHasItems(text, item.path))
|
|
1120
|
+
))
|
|
1065
1121
|
.map(({ item }) => item.label);
|
|
1066
1122
|
const isolationState = frontmatterPathState(text, ["concurrency", "isolation"]);
|
|
1067
1123
|
if (isolationState.present && !["adaptive", "worktree"].includes(frontmatterScalarValue(isolationState.value).toLowerCase())) {
|
|
@@ -1174,6 +1230,15 @@ function syncProject(project, assetSkill, assetAgents, dryRun, resetAgentModels
|
|
|
1174
1230
|
fs.copyFileSync(path.join(assetSkill, "data", "templates", "tools", "ap.py"), path.join(toolDir, "ap.py"));
|
|
1175
1231
|
for (const copied of copyMissingDocs(assetSkill, root)) actions.push({ action: "create", path: copied });
|
|
1176
1232
|
if (plan.state !== "current") {
|
|
1233
|
+
if (plan.archiveRequired) {
|
|
1234
|
+
fs.mkdirSync(path.dirname(plan.archiveDocument), { recursive: true });
|
|
1235
|
+
fs.writeFileSync(plan.archiveDocument, plan.archiveOutput);
|
|
1236
|
+
actions.push({
|
|
1237
|
+
action: "archive",
|
|
1238
|
+
path: path.relative(root, plan.archiveDocument),
|
|
1239
|
+
detail: "previous ENGINEERING.md before duplicate workflow cleanup",
|
|
1240
|
+
});
|
|
1241
|
+
}
|
|
1177
1242
|
fs.mkdirSync(path.dirname(plan.engineering), { recursive: true });
|
|
1178
1243
|
fs.writeFileSync(plan.engineering, plan.output);
|
|
1179
1244
|
actions.push({
|
|
@@ -1183,6 +1248,15 @@ function syncProject(project, assetSkill, assetAgents, dryRun, resetAgentModels
|
|
|
1183
1248
|
});
|
|
1184
1249
|
}
|
|
1185
1250
|
if (agentsDocumentPlan.state !== "current") {
|
|
1251
|
+
if (agentsDocumentPlan.archiveRequired) {
|
|
1252
|
+
fs.mkdirSync(path.dirname(agentsDocumentPlan.archiveDocument), { recursive: true });
|
|
1253
|
+
fs.writeFileSync(agentsDocumentPlan.archiveDocument, agentsDocumentPlan.archiveOutput);
|
|
1254
|
+
actions.push({
|
|
1255
|
+
action: "archive",
|
|
1256
|
+
path: path.relative(root, agentsDocumentPlan.archiveDocument),
|
|
1257
|
+
detail: "previous root AGENTS.md; historical and non-authoritative",
|
|
1258
|
+
});
|
|
1259
|
+
}
|
|
1186
1260
|
fs.writeFileSync(agentsDocumentPlan.agentsDocument, agentsDocumentPlan.output);
|
|
1187
1261
|
actions.push({
|
|
1188
1262
|
action: agentsDocumentPlan.state === "missing" ? "create" : "update",
|
|
@@ -1195,6 +1269,13 @@ function syncProject(project, assetSkill, assetAgents, dryRun, resetAgentModels
|
|
|
1195
1269
|
if (!exists(path.join(root, "docs", rel))) actions.push({ action: "would-create", path: path.join("docs", rel) });
|
|
1196
1270
|
}
|
|
1197
1271
|
if (plan.state !== "current") {
|
|
1272
|
+
if (plan.archiveRequired) {
|
|
1273
|
+
actions.push({
|
|
1274
|
+
action: "would-archive",
|
|
1275
|
+
path: path.relative(root, plan.archiveDocument),
|
|
1276
|
+
detail: "previous ENGINEERING.md before duplicate workflow cleanup",
|
|
1277
|
+
});
|
|
1278
|
+
}
|
|
1198
1279
|
actions.push({
|
|
1199
1280
|
action: plan.state === "missing" ? "would-create" : "would-update",
|
|
1200
1281
|
path: path.join("docs", "ENGINEERING.md"),
|
|
@@ -1202,6 +1283,13 @@ function syncProject(project, assetSkill, assetAgents, dryRun, resetAgentModels
|
|
|
1202
1283
|
});
|
|
1203
1284
|
}
|
|
1204
1285
|
if (agentsDocumentPlan.state !== "current") {
|
|
1286
|
+
if (agentsDocumentPlan.archiveRequired) {
|
|
1287
|
+
actions.push({
|
|
1288
|
+
action: "would-archive",
|
|
1289
|
+
path: path.relative(root, agentsDocumentPlan.archiveDocument),
|
|
1290
|
+
detail: "previous root AGENTS.md; historical and non-authoritative",
|
|
1291
|
+
});
|
|
1292
|
+
}
|
|
1205
1293
|
actions.push({
|
|
1206
1294
|
action: agentsDocumentPlan.state === "missing" ? "would-create" : "would-update",
|
|
1207
1295
|
path: "AGENTS.md",
|
|
@@ -1275,13 +1363,12 @@ autocoding - install auto-coding-skill into generic .agents paths
|
|
|
1275
1363
|
Usage:
|
|
1276
1364
|
autocoding init [--mode project|global] [--dest <repo-root|.agents-dir|skill-dir>] [--force] [--reset-agent-models]
|
|
1277
1365
|
autocoding status --projects <path[,path...]> [--json]
|
|
1278
|
-
autocoding sync --projects <path[,path...]> [--
|
|
1366
|
+
autocoding sync --projects <path[,path...]> [--dry-run] [--json] [--reset-agent-models]
|
|
1279
1367
|
|
|
1280
1368
|
Examples:
|
|
1281
1369
|
autocoding init
|
|
1282
1370
|
autocoding status --projects /Users/elvis/Product/xjmate,/Users/elvis/Product/geesight
|
|
1283
1371
|
autocoding sync --projects /Users/elvis/Product/xjmate --dry-run
|
|
1284
|
-
autocoding sync --projects /Users/elvis/Product/geesight --components skill
|
|
1285
1372
|
|
|
1286
1373
|
Compatibility:
|
|
1287
1374
|
--ai <value> is accepted for old scripts and ignored.
|
|
@@ -1316,7 +1403,7 @@ Compatibility:
|
|
|
1316
1403
|
|
|
1317
1404
|
if (args.cmd === "sync") {
|
|
1318
1405
|
const projects = args.projects.length ? args.projects : [projectRoot()];
|
|
1319
|
-
|
|
1406
|
+
assertNoRegisteredTasks(projects);
|
|
1320
1407
|
const controlledPlans = new Map();
|
|
1321
1408
|
for (const project of projects) {
|
|
1322
1409
|
const root = path.resolve(project);
|
|
@@ -202,7 +202,7 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
202
202
|
return current_path
|
|
203
203
|
self.fail(f"no worktree registered for {wanted}")
|
|
204
204
|
|
|
205
|
-
def start_task(self, repo: Path, task_id: str) -> Path:
|
|
205
|
+
def start_task(self, repo: Path, task_id: str, owned_path: str = ".") -> Path:
|
|
206
206
|
result = self.ap(
|
|
207
207
|
repo,
|
|
208
208
|
"task-start",
|
|
@@ -210,7 +210,7 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
210
210
|
"--base",
|
|
211
211
|
"origin/dev",
|
|
212
212
|
"--owned-path",
|
|
213
|
-
|
|
213
|
+
owned_path,
|
|
214
214
|
"--isolated",
|
|
215
215
|
"--review-required",
|
|
216
216
|
)
|
|
@@ -701,8 +701,8 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
701
701
|
|
|
702
702
|
def test_control_commands_are_rejected_from_another_task_worktree(self) -> None:
|
|
703
703
|
_, repo, _ = self.make_repo()
|
|
704
|
-
first = self.start_task(repo, "CROSS-1")
|
|
705
|
-
second = self.start_task(repo, "CROSS-2")
|
|
704
|
+
first = self.start_task(repo, "CROSS-1", "cross/one")
|
|
705
|
+
second = self.start_task(repo, "CROSS-2", "cross/two")
|
|
706
706
|
|
|
707
707
|
commands = [
|
|
708
708
|
("task-integrate", "CROSS-1"),
|
|
@@ -735,6 +735,58 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
735
735
|
}
|
|
736
736
|
self.assertEqual(before, after)
|
|
737
737
|
|
|
738
|
+
def test_task_start_rejects_overlapping_active_owned_paths(self) -> None:
|
|
739
|
+
_, repo, _ = self.make_repo()
|
|
740
|
+
first = self.start_task(repo, "OWNER-1", "backend")
|
|
741
|
+
result = self.ap(
|
|
742
|
+
repo,
|
|
743
|
+
"task-start",
|
|
744
|
+
"OWNER-2",
|
|
745
|
+
"--base",
|
|
746
|
+
"origin/dev",
|
|
747
|
+
"--owned-path",
|
|
748
|
+
"backend/api",
|
|
749
|
+
"--isolated",
|
|
750
|
+
check=False,
|
|
751
|
+
)
|
|
752
|
+
self.assertNotEqual(0, result.returncode)
|
|
753
|
+
self.assertIn("overlap active task OWNER-1", result.stdout + result.stderr)
|
|
754
|
+
self.assertTrue(first.exists())
|
|
755
|
+
self.assertFalse(self.registry_manifest_path(repo, "OWNER-2").exists())
|
|
756
|
+
self.assert_local_branch(repo, "codex/OWNER-2", False)
|
|
757
|
+
|
|
758
|
+
def test_task_start_rejects_terminal_ledger_lifecycle_and_multi_writer(self) -> None:
|
|
759
|
+
_, repo, _ = self.make_repo()
|
|
760
|
+
terminal = self.ap(
|
|
761
|
+
repo,
|
|
762
|
+
"task-start",
|
|
763
|
+
"LEDGER-END",
|
|
764
|
+
"--base",
|
|
765
|
+
"origin/dev",
|
|
766
|
+
"--owned-path",
|
|
767
|
+
"docs/tasks/closure-log.md",
|
|
768
|
+
check=False,
|
|
769
|
+
)
|
|
770
|
+
self.assertNotEqual(0, terminal.returncode)
|
|
771
|
+
self.assertIn("terminal maintenance", terminal.stdout + terminal.stderr)
|
|
772
|
+
self.assertFalse(self.registry_manifest_path(repo, "LEDGER-END").exists())
|
|
773
|
+
|
|
774
|
+
multi = self.ap(
|
|
775
|
+
repo,
|
|
776
|
+
"task-start",
|
|
777
|
+
"MULTI-1",
|
|
778
|
+
"--base",
|
|
779
|
+
"origin/dev",
|
|
780
|
+
"--owned-path",
|
|
781
|
+
"frontend",
|
|
782
|
+
"--writers",
|
|
783
|
+
"2",
|
|
784
|
+
check=False,
|
|
785
|
+
)
|
|
786
|
+
self.assertNotEqual(0, multi.returncode)
|
|
787
|
+
self.assertIn("exactly one writer lease", multi.stdout + multi.stderr)
|
|
788
|
+
self.assertFalse(self.registry_manifest_path(repo, "MULTI-1").exists())
|
|
789
|
+
|
|
738
790
|
def test_missing_task_manifest_is_rejected_in_linked_worktree(self) -> None:
|
|
739
791
|
_, repo, remote = self.make_repo("worktree")
|
|
740
792
|
worktree = self.start_task(repo, "NO-MANIFEST")
|
|
@@ -786,8 +838,8 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
786
838
|
|
|
787
839
|
def test_commit_push_requires_matching_manifest_and_isolated_worktree(self) -> None:
|
|
788
840
|
_, repo, remote = self.make_repo()
|
|
789
|
-
worktree = self.start_task(repo, "ISOLATED-1")
|
|
790
|
-
second_worktree = self.start_task(repo, "ISOLATED-2")
|
|
841
|
+
worktree = self.start_task(repo, "ISOLATED-1", "task-only.txt")
|
|
842
|
+
second_worktree = self.start_task(repo, "ISOLATED-2", "second-task-only.txt")
|
|
791
843
|
(worktree / "task-only.txt").write_text("task change\n", encoding="utf-8")
|
|
792
844
|
(second_worktree / "second-task-only.txt").write_text(
|
|
793
845
|
"second task change\n",
|
|
@@ -953,8 +1005,8 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
953
1005
|
|
|
954
1006
|
def test_task_deletion_is_isolated_and_committed_only_on_its_task_branch(self) -> None:
|
|
955
1007
|
_, repo, remote = self.make_repo()
|
|
956
|
-
deleting = self.start_task(repo, "DELETE-1")
|
|
957
|
-
observer = self.start_task(repo, "DELETE-2")
|
|
1008
|
+
deleting = self.start_task(repo, "DELETE-1", "shared.txt")
|
|
1009
|
+
observer = self.start_task(repo, "DELETE-2", "observer.txt")
|
|
958
1010
|
(deleting / "shared.txt").unlink()
|
|
959
1011
|
(observer / "observer.txt").write_text("observer\n", encoding="utf-8")
|
|
960
1012
|
|
|
@@ -972,7 +1024,7 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
972
1024
|
def test_task_finish_refuses_dirty_or_unmerged_tasks(self) -> None:
|
|
973
1025
|
_, repo, _ = self.make_repo()
|
|
974
1026
|
|
|
975
|
-
dirty_worktree = self.start_task(repo, "DIRTY-1")
|
|
1027
|
+
dirty_worktree = self.start_task(repo, "DIRTY-1", "dirty.txt")
|
|
976
1028
|
(dirty_worktree / "dirty.txt").write_text("not committed\n", encoding="utf-8")
|
|
977
1029
|
dirty = self.ap(repo, "task-finish", "DIRTY-1", check=False)
|
|
978
1030
|
self.assertNotEqual(0, dirty.returncode)
|
|
@@ -980,7 +1032,7 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
980
1032
|
self.assert_local_branch(repo, "codex/DIRTY-1", True)
|
|
981
1033
|
self.assertTrue((dirty_worktree / "dirty.txt").exists())
|
|
982
1034
|
|
|
983
|
-
unmerged_worktree = self.start_task(repo, "UNMERGED-1")
|
|
1035
|
+
unmerged_worktree = self.start_task(repo, "UNMERGED-1", "unmerged.txt")
|
|
984
1036
|
(unmerged_worktree / "unmerged.txt").write_text("committed only on task\n", encoding="utf-8")
|
|
985
1037
|
git(unmerged_worktree, "add", "unmerged.txt")
|
|
986
1038
|
git(unmerged_worktree, "commit", "-qm", "unmerged task commit")
|
|
@@ -233,7 +233,10 @@ class AutoCodingProfileTests(unittest.TestCase):
|
|
|
233
233
|
self.assertEqual(["src/frontend/LoginPage.tsx"], plan["classification_files"])
|
|
234
234
|
self.assertTrue(plan["intent_provided"])
|
|
235
235
|
self.assertEqual(["auth", "release_or_tooling", "ui"], plan["intent_categories"])
|
|
236
|
-
self.
|
|
236
|
+
self.assertTrue(plan["needs_browser"])
|
|
237
|
+
self.assertEqual(["reviewer"], plan["recommended_agents"])
|
|
238
|
+
self.assertNotIn("browser_debugger", plan["recommended_agents"])
|
|
239
|
+
self.assertNotIn("docs_researcher", plan["recommended_agents"])
|
|
237
240
|
self.assertNotIn("新增登录鉴权页面并发布", str(plan))
|
|
238
241
|
|
|
239
242
|
def test_ordinary_code_resolves_standard(self) -> None:
|
|
@@ -329,22 +332,22 @@ class AutoCodingProfileTests(unittest.TestCase):
|
|
|
329
332
|
self.assertFalse(plan["needs_jenkins"])
|
|
330
333
|
self.assertFalse(plan["needs_target"])
|
|
331
334
|
|
|
332
|
-
def
|
|
335
|
+
def test_ui_api_reports_capabilities_without_auto_dispatch(self) -> None:
|
|
333
336
|
repo, cfg = self.make_repo("src/api/settings-page.tsx")
|
|
334
337
|
plan = self.plan(repo, cfg)
|
|
335
|
-
|
|
336
|
-
self.assertEqual(
|
|
337
|
-
self.assertEqual(
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
]
|
|
347
|
-
self.assertEqual(
|
|
338
|
+
self.assertTrue(plan["needs_browser"])
|
|
339
|
+
self.assertEqual([], plan["recommended_agents"])
|
|
340
|
+
self.assertEqual("main-only", plan["agent_plan"]["strategy"])
|
|
341
|
+
self.assertEqual(["main"], plan["agent_plan"]["stages"][0]["roles"])
|
|
342
|
+
|
|
343
|
+
def test_terminal_ledger_maintenance_creates_no_lifecycle_plan(self) -> None:
|
|
344
|
+
repo, cfg = self.make_repo()
|
|
345
|
+
plan = self.plan(repo, cfg, planned_paths=["docs/tasks/closure-log.md"])
|
|
346
|
+
self.assertTrue(plan["terminal_maintenance"])
|
|
347
|
+
self.assertEqual("none", plan["execution_mode"])
|
|
348
|
+
self.assertFalse(plan["review_required"])
|
|
349
|
+
self.assertFalse(plan["design_required"])
|
|
350
|
+
self.assertEqual([], plan["recommended_agents"])
|
|
348
351
|
|
|
349
352
|
def test_requested_verify_mode_is_rejected(self) -> None:
|
|
350
353
|
repo, cfg = self.make_repo("src/widget.py")
|
|
@@ -551,9 +554,13 @@ class AutoCodingProfileTests(unittest.TestCase):
|
|
|
551
554
|
|
|
552
555
|
def test_upgrade_unknown_policy_conflict_fails_before_any_write(self) -> None:
|
|
553
556
|
repo, _ = self.make_repo()
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
+
engineering = repo / "docs" / "ENGINEERING.md"
|
|
558
|
+
engineering.write_text(
|
|
559
|
+
engineering.read_text(encoding="utf-8")
|
|
560
|
+
+ "High-risk work must run the full gate.\n",
|
|
561
|
+
encoding="utf-8",
|
|
562
|
+
)
|
|
563
|
+
before = engineering.read_text(encoding="utf-8")
|
|
557
564
|
args = argparse.Namespace(repo=str(repo), write=True, dry_run=False, json=False)
|
|
558
565
|
with mock.patch.object(
|
|
559
566
|
ap,
|
|
@@ -562,8 +569,8 @@ class AutoCodingProfileTests(unittest.TestCase):
|
|
|
562
569
|
):
|
|
563
570
|
with self.assertRaises(APError) as context:
|
|
564
571
|
ap.cmd_upgrade(args)
|
|
565
|
-
self.assertIn("
|
|
566
|
-
self.assertEqual(before,
|
|
572
|
+
self.assertIn("docs/ENGINEERING.md", str(context.exception))
|
|
573
|
+
self.assertEqual(before, engineering.read_text(encoding="utf-8"))
|
|
567
574
|
self.assertFalse((repo / ".agents").exists())
|
|
568
575
|
|
|
569
576
|
def test_doctor_ignores_managed_blocks_but_rejects_unknown_external_rule(self) -> None:
|