-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathindex.ts
More file actions
146 lines (129 loc) · 4.05 KB
/
index.ts
File metadata and controls
146 lines (129 loc) · 4.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
import { userRequest } from "../input.js";
import { logger } from "../utils/logger.js";
import { findIsGoodToGo, findWhatIdo } from "../utils/match.js";
import { speak } from "../utils/speak.js";
import { doArchitectAntithese } from "./antithese.js";
import { doArchitectSynthese } from "./synthese.js";
import { doArchitectThese } from "./these.js";
import fs from "node:fs";
export const doArchitect = async () => {
logger("요청사항에 따른 개발 기획을 진행 중 입니다...");
await speak("요청사항에 따른 개발 기획을 진행 중 입니다...");
let reviewCount = 1;
const preDialect = await doDialecticSynthese(userRequest, (these) => {
fs.writeFileSync(`./result/architect-ver-${reviewCount++}.txt`, these);
});
let isGoodToGo = preDialect.isGoodToGo;
let synthese = preDialect.synthese;
while (true) {
const dialect = await doDialectic({
isGoodToGo,
synthese,
reviewCount,
userRequest,
});
isGoodToGo = dialect.isGoodToGo;
synthese = `${dialect.synthese}`;
reviewCount += 1;
if (isGoodToGo) {
logger(
`개발 기획이 완료되었습니다. (${reviewCount} 번째 검토 만에 완료)`
);
await speak(
`개발 기획이 완료되었습니다. ${reviewCount} 번째 검토 만에 완료되었습니다.`
);
fs.writeFileSync(`./result/architect-ver-${reviewCount}.txt`, synthese);
return synthese;
}
}
};
export const doDialectic = async ({
isGoodToGo,
synthese: these,
reviewCount,
userRequest,
}: {
isGoodToGo: boolean;
synthese: string;
reviewCount?: number;
userRequest?: string;
}) => {
if (isGoodToGo) {
return { isGoodToGo, synthese: these };
} else {
logger(
`개발 기획을 추가로 보완하고 있습니다... (${reviewCount} 번째 검토)`
);
await speak(
`개발 기획을 추가로 보완하고 있습니다... (${reviewCount} 번째 검토)`
);
fs.writeFileSync(`./result/architect-ver-${reviewCount}.txt`, these);
const antithese = await doArchitectAntithese(these);
console.log(antithese);
const whatAntitheseDo = findWhatIdo(antithese);
if (whatAntitheseDo) {
logger(whatAntitheseDo);
await speak(whatAntitheseDo);
} else {
logger("개발 기획을 보완하는 중입니다...");
}
// * Synthese 구하기
const synthese = await doArchitectSynthese(`${these}\n${antithese}`);
console.log(synthese);
const whatSyntheseDo = findWhatIdo(synthese);
if (whatSyntheseDo) {
logger(whatSyntheseDo);
await speak(whatSyntheseDo);
} else {
logger("개발 기획을 검토하는 중입니다...");
}
const isGoodToGo = findIsGoodToGo(synthese);
return {
isGoodToGo,
synthese: `----USER REQUEST\n${userRequest}\n${synthese}`,
};
}
};
export const doDialecticSynthese = async (
userRequest: string,
onThese: (these: string) => unknown
) => {
// * These 구하기
const these = await doArchitectThese(userRequest);
console.log(these);
onThese(these);
const whatTheseDo = findWhatIdo(these);
if (whatTheseDo) {
logger(whatTheseDo);
await speak(whatTheseDo);
} else {
logger("개발 기획을 세우는 중입니다...");
}
// * Antithese 구하기
const antithese = await doArchitectAntithese(
`----USER REQUEST\n${userRequest}\n${these}`
);
console.log(antithese);
const whatAntitheseDo = findWhatIdo(antithese);
if (whatAntitheseDo) {
logger(whatAntitheseDo);
await speak(whatAntitheseDo);
} else {
logger("개발 기획을 보완하는 중입니다...");
}
// * Synthese 구하기
const synthese = await doArchitectSynthese(`${these}\n${antithese}`);
console.log(synthese);
const whatSyntheseDo = findWhatIdo(synthese);
if (whatSyntheseDo) {
logger(whatSyntheseDo);
await speak(whatSyntheseDo);
} else {
logger("개발 기획을 검토하는 중입니다...");
}
const isGoodToGo = findIsGoodToGo(synthese);
return {
isGoodToGo,
synthese: `----USER REQUEST\n${userRequest}\n${synthese}`,
};
};