@tuzi-ince/hi-loop 0.3.1 → 0.3.3
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 +73 -1
- package/bin/hi-loop.js +29 -92
- package/bin/setup.js +46 -2
- package/docs/guide.md +34 -6
- package/docs/spec.md +60 -1
- package/package.json +1 -1
- package/skills/{hi-loop → flow}/SKILL.md +1 -1
- package/src/cli-commands.js +100 -0
- package/src/cli-options.js +6 -0
- package/src/loop.js +47 -56
- package/src/mcp-server.js +25 -0
- package/src/preflight.js +119 -0
- package/src/prompts.js +10 -3
- package/src/reconcile.js +101 -0
- package/src/resume.js +8 -5
- package/src/runners.js +8 -2
- package/src/stage-context.js +46 -0
- package/src/state.js +11 -4
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* stage 핸들러 실행 맥락 조립 (loop.js 에서 분리, NFR-5).
|
|
3
|
+
*
|
|
4
|
+
* loop.js 는 "다음 stage 를 정하는" 책임만 남기고, "무엇을 핸들러에 넘기는가"는 여기 모은다.
|
|
5
|
+
* `state` 는 getter/setter 라 핸들러가 재대입해도 loop.js 의 `let state` 에 반영된다
|
|
6
|
+
* (가정 기록은 순수 함수라 새 객체를 만들기 때문에 이 반영이 필요하다).
|
|
7
|
+
*/
|
|
8
|
+
export function buildStageContext({
|
|
9
|
+
getState,
|
|
10
|
+
setState,
|
|
11
|
+
save,
|
|
12
|
+
goal,
|
|
13
|
+
cwd,
|
|
14
|
+
logger,
|
|
15
|
+
notify,
|
|
16
|
+
gate,
|
|
17
|
+
nextAfterReview,
|
|
18
|
+
nextAfterCommit,
|
|
19
|
+
statePath,
|
|
20
|
+
baselineFiles,
|
|
21
|
+
designReviewEnabled,
|
|
22
|
+
ports,
|
|
23
|
+
opts,
|
|
24
|
+
}) {
|
|
25
|
+
return {
|
|
26
|
+
get state() {
|
|
27
|
+
return getState();
|
|
28
|
+
},
|
|
29
|
+
set state(v) {
|
|
30
|
+
setState(v);
|
|
31
|
+
},
|
|
32
|
+
goal,
|
|
33
|
+
cwd,
|
|
34
|
+
logger,
|
|
35
|
+
notify,
|
|
36
|
+
gate,
|
|
37
|
+
nextAfterReview,
|
|
38
|
+
nextAfterCommit,
|
|
39
|
+
statePath,
|
|
40
|
+
baselineFiles,
|
|
41
|
+
designReviewEnabled,
|
|
42
|
+
save,
|
|
43
|
+
ports,
|
|
44
|
+
opts,
|
|
45
|
+
};
|
|
46
|
+
}
|
package/src/state.js
CHANGED
|
@@ -86,10 +86,12 @@ export function statePathFor(cwd) {
|
|
|
86
86
|
* goal 해시를 쓰는 이유: 같은 goal 이면 같은 경로가 나와야 resume 이 이어지고,
|
|
87
87
|
* 다른 goal 끼리는 충돌하지 않는다. 한국어 goal 도 파일명이 깨지지 않는다.
|
|
88
88
|
*/
|
|
89
|
-
export function planPathsFor({ cwd, goal }) {
|
|
89
|
+
export function planPathsFor({ cwd, goal, specPath = null }) {
|
|
90
90
|
const slug = createHash('sha1').update(String(goal)).digest('hex').slice(0, 8);
|
|
91
91
|
return {
|
|
92
|
-
|
|
92
|
+
// `--spec` 으로 명시 고정하면 goal 해시로 비켜가지 않는다 — 그게 오라클 고정의 핵심이다.
|
|
93
|
+
// 사람이 관리하는 표준 문서를 여러 goal 이 같은 오라클로 공유해 문서↔소스 drift 를 막는다.
|
|
94
|
+
specPath: specPath || (existsSync(join(cwd, DEFAULT_SPEC_PATH)) ? `docs/spec-${slug}.md` : DEFAULT_SPEC_PATH),
|
|
93
95
|
testPath: existsSync(join(cwd, DEFAULT_TEST_PATH)) ? `tests/app-${slug}.test.js` : DEFAULT_TEST_PATH,
|
|
94
96
|
};
|
|
95
97
|
}
|
|
@@ -107,11 +109,12 @@ export function createState({
|
|
|
107
109
|
testCommand,
|
|
108
110
|
maxLoops,
|
|
109
111
|
cwd = process.cwd(),
|
|
112
|
+
specPath: pinnedSpecPath = null,
|
|
110
113
|
now = new Date().toISOString(),
|
|
111
114
|
}) {
|
|
112
115
|
// 경로는 **한 번만** 정하고 상태에 박아둔다. 매번 다시 계산하면 PLAN 이 만든 파일 때문에
|
|
113
|
-
// 2회차부터 경로가 밀려난다.
|
|
114
|
-
const { specPath, testPath } = planPathsFor({ cwd, goal });
|
|
116
|
+
// 2회차부터 경로가 밀려난다. pinnedSpecPath(--spec)가 있으면 그것으로 고정한다.
|
|
117
|
+
const { specPath, testPath } = planPathsFor({ cwd, goal, specPath: pinnedSpecPath });
|
|
115
118
|
return {
|
|
116
119
|
version: STATE_VERSION,
|
|
117
120
|
goal,
|
|
@@ -125,6 +128,10 @@ export function createState({
|
|
|
125
128
|
sessionSerial: 1,
|
|
126
129
|
specPath,
|
|
127
130
|
testPath,
|
|
131
|
+
// 사용자가 스펙 오라클을 고정했는가(--spec). PLAN 이 이 표준 문서를 덮어쓰지 않도록 신호한다.
|
|
132
|
+
specPinned: Boolean(pinnedSpecPath),
|
|
133
|
+
// FR-21: 문서 정합 게이트를 이미 거쳤는가. 같은 goal 재개 시 다시 묻지 않도록.
|
|
134
|
+
reconciled: false,
|
|
128
135
|
specSummary: '',
|
|
129
136
|
lastError: '',
|
|
130
137
|
costUsd: 0,
|