agent-mp 0.4.0 → 0.4.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/dist/core/engine.d.ts +8 -0
- package/dist/core/engine.js +64 -0
- package/package.json +1 -1
package/dist/core/engine.d.ts
CHANGED
|
@@ -40,6 +40,14 @@ export declare class AgentEngine {
|
|
|
40
40
|
runReviewer(taskId: string, plan: TaskPlan, progress: TaskProgress): Promise<{
|
|
41
41
|
verdict: string;
|
|
42
42
|
}>;
|
|
43
|
+
/**
|
|
44
|
+
* Scan contextDir for stray files (outside the allowed structure) and clean them up:
|
|
45
|
+
* - Old timestamped explorer-*.md reports → delete (content already in architecture.md)
|
|
46
|
+
* - Other stray .md files at root level → append content to architecture.md, then delete
|
|
47
|
+
* Allowed root-level files: architecture.md, explorer-last.md
|
|
48
|
+
* Allowed subdirectory files: <service>/architecture.md (not touched here)
|
|
49
|
+
*/
|
|
50
|
+
private _cleanContextDir;
|
|
43
51
|
runExplorer(task?: string): Promise<string>;
|
|
44
52
|
/** Called when the current binary IS the configured explorer CLI (prevents recursion).
|
|
45
53
|
* Builds the full exploration prompt and calls Qwen API using own credentials. */
|
package/dist/core/engine.js
CHANGED
|
@@ -799,6 +799,66 @@ INSTRUCCIONES:
|
|
|
799
799
|
log.verdict(verdict);
|
|
800
800
|
return { verdict };
|
|
801
801
|
}
|
|
802
|
+
/**
|
|
803
|
+
* Scan contextDir for stray files (outside the allowed structure) and clean them up:
|
|
804
|
+
* - Old timestamped explorer-*.md reports → delete (content already in architecture.md)
|
|
805
|
+
* - Other stray .md files at root level → append content to architecture.md, then delete
|
|
806
|
+
* Allowed root-level files: architecture.md, explorer-last.md
|
|
807
|
+
* Allowed subdirectory files: <service>/architecture.md (not touched here)
|
|
808
|
+
*/
|
|
809
|
+
async _cleanContextDir(contextDir) {
|
|
810
|
+
let entries;
|
|
811
|
+
try {
|
|
812
|
+
entries = await fs.readdir(contextDir, { withFileTypes: true });
|
|
813
|
+
}
|
|
814
|
+
catch {
|
|
815
|
+
return;
|
|
816
|
+
} // dir doesn't exist yet
|
|
817
|
+
const archPath = path.join(contextDir, 'architecture.md');
|
|
818
|
+
const stray = [];
|
|
819
|
+
for (const e of entries) {
|
|
820
|
+
if (!e.isFile())
|
|
821
|
+
continue;
|
|
822
|
+
if (!e.name.endsWith('.md'))
|
|
823
|
+
continue;
|
|
824
|
+
if (e.name === 'architecture.md' || e.name === 'explorer-last.md')
|
|
825
|
+
continue;
|
|
826
|
+
stray.push(e.name);
|
|
827
|
+
}
|
|
828
|
+
if (stray.length === 0)
|
|
829
|
+
return;
|
|
830
|
+
log.info(`Limpiando ${stray.length} archivo(s) fuera de estructura en .agent/context/`);
|
|
831
|
+
for (const name of stray) {
|
|
832
|
+
const filePath = path.join(contextDir, name);
|
|
833
|
+
// Old timestamped explorer reports — just delete (content is redundant)
|
|
834
|
+
if (/^explorer-\d{4}-\d{2}-/.test(name)) {
|
|
835
|
+
await fs.unlink(filePath);
|
|
836
|
+
log.ok(` Eliminado: ${name}`);
|
|
837
|
+
continue;
|
|
838
|
+
}
|
|
839
|
+
// Other stray files — migrate content to architecture.md, then delete
|
|
840
|
+
try {
|
|
841
|
+
const content = (await readFile(filePath)).trim();
|
|
842
|
+
if (content) {
|
|
843
|
+
let arch = '';
|
|
844
|
+
try {
|
|
845
|
+
arch = await readFile(archPath);
|
|
846
|
+
}
|
|
847
|
+
catch { /* no arch yet */ }
|
|
848
|
+
const label = name.replace(/\.md$/, '');
|
|
849
|
+
await writeFile(archPath, `${arch}\n\n---\n## ${label}\n\n${content}\n`);
|
|
850
|
+
log.ok(` Migrado: ${name} → architecture.md`);
|
|
851
|
+
}
|
|
852
|
+
else {
|
|
853
|
+
log.ok(` Eliminado (vacío): ${name}`);
|
|
854
|
+
}
|
|
855
|
+
await fs.unlink(filePath);
|
|
856
|
+
}
|
|
857
|
+
catch (err) {
|
|
858
|
+
log.warn(` No se pudo limpiar ${name}: ${err.message}`);
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
}
|
|
802
862
|
async runExplorer(task) {
|
|
803
863
|
if (!this.config.roles.explorer) {
|
|
804
864
|
if (!this.config.fallback_global) {
|
|
@@ -813,6 +873,8 @@ INSTRUCCIONES:
|
|
|
813
873
|
const contextDir = path.join(agentDir, 'context');
|
|
814
874
|
await fs.mkdir(contextDir, { recursive: true });
|
|
815
875
|
await fs.mkdir(path.join(agentDir, 'rules'), { recursive: true });
|
|
876
|
+
// Clean up stray files before running
|
|
877
|
+
await this._cleanContextDir(contextDir);
|
|
816
878
|
// Read existing architecture doc if any
|
|
817
879
|
const archPath = path.join(contextDir, 'architecture.md');
|
|
818
880
|
let existingArch = '';
|
|
@@ -863,6 +925,8 @@ REGLAS:
|
|
|
863
925
|
const agentDir = path.join(this.projectDir, '.agent');
|
|
864
926
|
const contextDir = path.join(agentDir, 'context');
|
|
865
927
|
await fs.mkdir(contextDir, { recursive: true });
|
|
928
|
+
// Clean up stray files before running
|
|
929
|
+
await this._cleanContextDir(contextDir);
|
|
866
930
|
const archPath = path.join(contextDir, 'architecture.md');
|
|
867
931
|
let existingArch = '';
|
|
868
932
|
try {
|