cuelo 0.10.85 → 0.10.87

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.
Files changed (87) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-path-routes-manifest.json +35 -35
  3. package/.next/build-manifest.json +2 -2
  4. package/.next/prerender-manifest.json +3 -3
  5. package/.next/required-server-files.js +1 -1
  6. package/.next/required-server-files.json +1 -1
  7. package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  8. package/.next/server/app/_global-error.html +1 -1
  9. package/.next/server/app/_global-error.rsc +1 -1
  10. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  11. package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  12. package/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  13. package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  14. package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  15. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  16. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  17. package/.next/server/app/_not-found.html +1 -1
  18. package/.next/server/app/_not-found.rsc +2 -2
  19. package/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
  20. package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  21. package/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
  22. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  23. package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  24. package/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  25. package/.next/server/app/api/agent/[id]/events/route.js +2 -2
  26. package/.next/server/app/api/model-roles/route.js +1 -1
  27. package/.next/server/app/api/models/route.js +1 -1
  28. package/.next/server/app/api/models-config/route.js +2 -2
  29. package/.next/server/app/api/models-config/route.js.nft.json +1 -1
  30. package/.next/server/app/api/updates/route.js +1 -1
  31. package/.next/server/app/index.html +1 -1
  32. package/.next/server/app/index.rsc +4 -4
  33. package/.next/server/app/index.segments/__PAGE__.segment.rsc +3 -3
  34. package/.next/server/app/index.segments/_full.segment.rsc +4 -4
  35. package/.next/server/app/index.segments/_head.segment.rsc +1 -1
  36. package/.next/server/app/index.segments/_index.segment.rsc +2 -2
  37. package/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  38. package/.next/server/app/page.js +21 -21
  39. package/.next/server/app/page_client-reference-manifest.js +1 -1
  40. package/.next/server/app/recover/page_client-reference-manifest.js +1 -1
  41. package/.next/server/app/recover.html +1 -1
  42. package/.next/server/app/recover.rsc +2 -2
  43. package/.next/server/app/recover.segments/_full.segment.rsc +2 -2
  44. package/.next/server/app/recover.segments/_head.segment.rsc +1 -1
  45. package/.next/server/app/recover.segments/_index.segment.rsc +2 -2
  46. package/.next/server/app/recover.segments/_tree.segment.rsc +1 -1
  47. package/.next/server/app/recover.segments/recover/__PAGE__.segment.rsc +1 -1
  48. package/.next/server/app/recover.segments/recover.segment.rsc +1 -1
  49. package/.next/server/app-paths-manifest.json +35 -35
  50. package/.next/server/chunks/1008.js +1 -1
  51. package/.next/server/chunks/6429.js +4 -4
  52. package/.next/server/middleware-build-manifest.js +1 -1
  53. package/.next/server/pages/404.html +1 -1
  54. package/.next/server/pages/500.html +1 -1
  55. package/.next/server/server-reference-manifest.json +1 -1
  56. package/.next/static/chunks/app/{layout-9732ddae4dc9638c.js → layout-96ff72e1112f83e3.js} +1 -1
  57. package/.next/static/chunks/app/page-d672db1a3c9cee38.js +75 -0
  58. package/.next/trace +108 -108
  59. package/.next/trace-build +1 -1
  60. package/README.md +6 -1
  61. package/Tools/CUELO_Setup/files/native-runtime-patch.js +1 -1
  62. package/Tools/OMP_Global_Config/agent/RULES.md +16 -12
  63. package/Tools/OMP_Global_Config/agent/agents/maker.md +17 -12
  64. package/Tools/OMP_Global_Config/agent/extensions/command-guard/task-guard.ts +2 -1
  65. package/Tools/OMP_Global_Config/agent/extensions/cross-review.ts +24 -12
  66. package/Tools/OMP_Global_Config/agent/extensions/edit-lessons.ts +32 -1
  67. package/Tools/OMP_Global_Config/agent/extensions/lib/cross-review.ts +254 -37
  68. package/Tools/OMP_Global_Config/agent/extensions/lib/maker-routing.ts +55 -5
  69. package/Tools/OMP_Global_Config/agent/extensions/lib/routing-ledger.ts +3 -2
  70. package/Tools/OMP_Global_Config/agent/extensions/lib/slop-gate.ts +192 -25
  71. package/Tools/OMP_Global_Config/agent/extensions/report-chart-guard.ts +149 -19
  72. package/Tools/OMP_Global_Config/agent/extensions/slop-gate/review.ts +122 -64
  73. package/Tools/OMP_Global_Config/agent/extensions/slop-gate.ts +25 -13
  74. package/Tools/OMP_Global_Config/agent/prompt-copies/RULES.en.md +3 -3
  75. package/Tools/OMP_Global_Config/agent/rules/harness-policy.json +14 -7
  76. package/Tools/OMP_Global_Config/agent/rules/omp-harness.md +2 -1
  77. package/Tools/OMP_Global_Config/agent/rules/subagent.md +20 -8
  78. package/Tools/OMP_Global_Config/agent/rules/task-guard.md +1 -0
  79. package/Tools/OMP_Global_Config/agent/sop/_writer.md +14 -9
  80. package/Tools/OMP_Global_Config/agent/sop/maker.md +2 -2
  81. package/Tools/OMP_Global_Config/agent/tools/git-finalizer/index.ts +6 -3
  82. package/Tools/OMP_Global_Config/patches/apply-core-patch.mjs +316 -3
  83. package/install.mjs +11 -4
  84. package/package.json +1 -1
  85. package/.next/static/chunks/app/page-8e9c8449e2f53ae8.js +0 -75
  86. /package/.next/static/{y4k_8nU4FYWcP7nTP4oCU → nLKOmVsY9AF1w5V0Fsm8L}/_buildManifest.js +0 -0
  87. /package/.next/static/{y4k_8nU4FYWcP7nTP4oCU → nLKOmVsY9AF1w5V0Fsm8L}/_ssgManifest.js +0 -0
@@ -1,5 +1,5 @@
1
1
  import { createHash } from "node:crypto";
2
- import { appendFileSync, chmodSync, existsSync, mkdirSync, readdirSync, readFileSync, statSync } from "node:fs";
2
+ import { appendFileSync, chmodSync, existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, statSync } from "node:fs";
3
3
  import { homedir, tmpdir } from "node:os";
4
4
  import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
5
5
  import { collectChanges, currentBlobs, hashBytes, resolveRepoTargets, spawnExec, type Exec } from "./cross-review";
@@ -68,26 +68,26 @@ function matches(patterns: readonly string[] | undefined, path: string): boolean
68
68
 
69
69
  /**
70
70
  * 한 줄 분류. path는 저장소·cwd 기준 상대 경로이거나 절대 경로다. 절대 경로(저장소 밖 산출물, 예: Windows 문서 폴더)는
71
- * 폴더 규칙 없이 확장자만 본다. 우선순위: 프로젝트 visible → 내부·생성물·테스트 → 보이는 형식.
71
+ * 폴더 규칙 없이 확장자만 본다. 우선순위: 내부·생성물·테스트(선언으로도 못 바꾼다) → 프로젝트 visible → 보이는 형식.
72
72
  */
73
73
  export function classify(path: string, config: SlopConfig = {}): Classification {
74
74
  const p = norm(path);
75
75
  const external = isAbsolute(path) || /^[A-Za-z]:\//.test(p);
76
- if (matches(config.visible, p)) return { visible: true, reason: "project declared" };
77
76
  const segments = p.split("/");
78
77
  const name = segments.at(-1) ?? "";
79
78
  if (internalRecord(segments)) return { visible: false, reason: "internal record" };
80
79
  if (external) {
81
80
  const excluded = externalExcluded(p);
82
81
  if (excluded) return { visible: false, reason: excluded };
83
- } else {
84
- const dirs = segments.slice(0, -1);
85
- if (dirs.some((segment) => GENERATED_SEGMENT[segment])) return { visible: false, reason: "generated or vendored" };
86
- if (dirs.some((segment) => INTERNAL_SEGMENT[segment])) return { visible: false, reason: "internal record, rule, prompt or skill" };
87
- if (dirs.some((segment) => TEST_SEGMENT[segment]) || TEST_FILE.test(p)) return { visible: false, reason: "test or fixture" };
88
- if (GENERATED_FILE.test(p)) return { visible: false, reason: "generated" };
89
82
  }
83
+ // 폴더 규칙은 절대 경로에도 적용한다: 내부·테스트·생성물 판정은 어떤 공개 선언보다 먼저다(저장소 밖 생성물 폴더는 externalExcluded가 본다).
84
+ const dirs = segments.slice(0, -1);
85
+ if (!external && dirs.some((segment) => GENERATED_SEGMENT[segment])) return { visible: false, reason: "generated or vendored" };
86
+ if (dirs.some((segment) => INTERNAL_SEGMENT[segment])) return { visible: false, reason: "internal record, rule, prompt or skill" };
87
+ if (dirs.some((segment) => TEST_SEGMENT[segment]) || TEST_FILE.test(p)) return { visible: false, reason: "test or fixture" };
88
+ if (GENERATED_FILE.test(p)) return { visible: false, reason: "generated" };
90
89
  if (INTERNAL_NAME.test(name)) return { visible: false, reason: "internal prompt or rule file" };
90
+ if (matches(config.visible, p)) return { visible: true, reason: "project declared" };
91
91
  if (MARKDOWN.test(name)) return { visible: true, reason: "public markdown" };
92
92
  if (MARKUP.test(name)) return { visible: true, reason: "html page" };
93
93
  if (OFFICE.test(name)) return { visible: true, reason: "office or pdf document" };
@@ -113,6 +113,134 @@ export function loadSlopConfig(root: string): SlopConfig {
113
113
  } catch { return {}; }
114
114
  }
115
115
 
116
+ // ── 공개 여부 ────────────────────────────────────────────────────────────────
117
+
118
+ /**
119
+ * 공개·공유되는 산출물만 슬롭 점검 대상이다(사용자 결정 2026-10-26). 비공개·내부 문서는 사용자에게 건네도 대상이 아니다.
120
+ * 정본은 저장소 루트의 `.publicignore`다: publish-public.yml이 `git ls-files -ci --exclude-from=.publicignore`로 미러에서 지우는 것이 비공개다.
121
+ * 그 밖의 선언은 `.slop-gate.json` visible glob과 slop_check `public:true`(선언 없는 일회성 산출물)뿐이다. 선언이 없으면 모르는 파일이라
122
+ * 공개가 아니다: 모델에 보내지 않고 게이트도 없다. 세 곳(slop_check·커밋 게이트·턴 끝)이 모두 바이트를 읽기 전에 이 판정을 쓴다.
123
+ */
124
+ export const PUBLIC_IGNORE = ".publicignore";
125
+ export interface Publication {
126
+ public: boolean;
127
+ reason: string;
128
+ /** 아무 선언도 없다. public:true 선언만 이것을 공개로 바꿀 수 있다. */
129
+ unknown?: true;
130
+ /** 저장소 상태를 읽지 못해 판정하지 못했다(공개로 보지 않는다). */
131
+ error?: true;
132
+ }
133
+
134
+ const DECLARED: Publication = { public: true, reason: `declared public in ${CONFIG_FILE}` };
135
+ const UNDECLARED: Publication = { public: false, unknown: true, reason: `no publication declaration (${PUBLIC_IGNORE} or ${CONFIG_FILE}), so it is not a public artifact` };
136
+
137
+ /**
138
+ * 저장소 안 경로(저장소 상대)의 공개 여부. 요청한 경로에만 git ls-files를 돌린다(저장소 전체를 훑지 않는다). `.publicignore`가 있으면 그것이
139
+ * 지운 것(부정 규칙 반영, 추적하지 않는 새 파일 포함)은 비공개이고, 남은 것 중 추적 중이거나 git이 무시하지 않는 새 파일이 공개다.
140
+ * `.publicignore`가 없으면 `.slop-gate.json`이 선언한 경로만 공개다. git이 실패하면 던진다(공개 여부를 모른 채 열어 두지 않는다).
141
+ */
142
+ export async function repoPublication(exec: Exec, git: string, root: string, paths: readonly string[], config: SlopConfig): Promise<Map<string, Publication>> {
143
+ const out = new Map<string, Publication>();
144
+ if (paths.length === 0) return out;
145
+ if (!existsSync(join(root, PUBLIC_IGNORE))) {
146
+ for (const path of paths) out.set(path, matches(config.visible, path) ? DECLARED : UNDECLARED);
147
+ return out;
148
+ }
149
+ const list = async (args: string[]) => {
150
+ const result = await exec(git, ["--literal-pathspecs", "ls-files", "-z", ...args, "--", ...paths], { cwd: root });
151
+ if (result.code !== 0) throw new Error(`git ls-files failed while applying ${PUBLIC_IGNORE}: ${(result.stderr || result.stdout).trim()}`);
152
+ return new Set(result.stdout.split("\0").filter(Boolean));
153
+ };
154
+ const excluded = await list(["--cached", "--others", "--ignored", `--exclude-from=${PUBLIC_IGNORE}`]);
155
+ const published = await list(["--cached", "--others", "--exclude-standard"]);
156
+ for (const path of paths) {
157
+ out.set(path, excluded.has(path) ? { public: false, reason: `excluded from the public mirror by ${PUBLIC_IGNORE} (private)` }
158
+ : published.has(path) ? { public: true, reason: `published by the ${PUBLIC_IGNORE} mirror` }
159
+ : { public: false, reason: "ignored by git, so never published" });
160
+ }
161
+ return out;
162
+ }
163
+
164
+ /** 저장소 밖 산출물의 `.slop-gate.json`을 읽는 곳: cwd에서 가장 가까운 git 저장소 루트, 없으면 cwd. */
165
+ export function configRootOf(cwd: string): string {
166
+ let current = resolve(cwd);
167
+ for (;;) {
168
+ if (existsSync(join(current, ".git"))) return current;
169
+ const parent = dirname(current);
170
+ if (parent === current) return resolve(cwd);
171
+ current = parent;
172
+ }
173
+ }
174
+
175
+ /** git 밖 파일의 공개 여부: `.slop-gate.json` visible glob이 설정 루트 기준 상대 경로나 절대 경로로 선언하면 공개, 아니면 모르는 파일이다. */
176
+ export function externalPublication(abs: string, root: string, config: SlopConfig): Publication {
177
+ const inside = relative(root, abs);
178
+ const local = inside !== "" && !inside.startsWith("..") && !isAbsolute(inside) ? norm(inside) : undefined;
179
+ return matches(config.visible, norm(abs)) || (local !== undefined && matches(config.visible, local)) ? DECLARED : UNDECLARED;
180
+ }
181
+
182
+ /**
183
+ * 호출자의 명시 선언(slop_check public:true). 선언 없는(unknown) 파일 중 보이는 산출물 형식인 것만 공개로 바꾸고, `.publicignore`가 지운
184
+ * 비공개 파일·git이 무시한 파일·내부 기록·코드는 바꾸지 않는다. path는 classify에 넘길 경로(저장소·cwd 상대 또는 절대)다.
185
+ */
186
+ export function withDeclaration(publication: Publication, path: string): Publication {
187
+ if (publication.public || !publication.unknown) return publication;
188
+ const kind = classify(path);
189
+ return kind.visible ? { public: true, reason: "declared public by the caller (public:true)" } : { public: false, reason: `${kind.reason}; a public:true declaration cannot make it public` };
190
+ }
191
+
192
+ /**
193
+ * slop_check 대상(실제 절대 경로)의 공개 여부. git 안이면 그 저장소의 repoPublication(선언은 .publicignore·.slop-gate.json뿐), 밖이면
194
+ * externalPublication이고, declared(public:true 또는 이번 입력에서 그렇게 선언한 파일)는 git 밖의 모르는 파일만 바꾼다.
195
+ * 저장소 상태를 읽지 못한 파일은 error로 돌려준다.
196
+ */
197
+ export async function publicationOf(paths: readonly string[], cwd: string, declared: (abs: string) => boolean, exec: Exec = spawnExec(), gitFor?: (root: string) => Promise<string>): Promise<Map<string, Publication>> {
198
+ const out = new Map<string, Publication>();
199
+ const root = configRootOf(cwd);
200
+ const config = loadSlopConfig(root);
201
+ // 공개여도 내부·생성물·테스트로 분류되는 파일은 대상이 아니다(게이트들과 같은 분류가 먼저다).
202
+ const veto = (found: Publication, path: string, cfg: SlopConfig): Publication => {
203
+ if (!found.public) return found;
204
+ const kind = classify(path, cfg);
205
+ return kind.visible ? found : { public: false, reason: `${kind.reason}, not a gated artifact` };
206
+ };
207
+ const repos = new Map<string, { abs: string; rel: string }[]>();
208
+ for (const abs of paths) {
209
+ const repo = gitRootOf(abs);
210
+ if (!repo) {
211
+ const inside = relative(cwd, abs);
212
+ const local = inside !== "" && !inside.startsWith("..") && !isAbsolute(inside) ? inside : abs;
213
+ const found = externalPublication(abs, root, config);
214
+ out.set(abs, veto(declared(abs) ? withDeclaration(found, local) : found, local, config));
215
+ continue;
216
+ }
217
+ const group = repos.get(repo) ?? [];
218
+ group.push({ abs, rel: relative(repo, abs).split(sep).join("/") });
219
+ repos.set(repo, group);
220
+ }
221
+ for (const [repo, files] of repos) {
222
+ let found: Map<string, Publication>;
223
+ const repoConfig = loadSlopConfig(repo);
224
+ try { found = await repoPublication(exec, (await gitFor?.(repo)) ?? "git", repo, files.map((file) => file.rel), repoConfig); } catch (error) {
225
+ for (const file of files) out.set(file.abs, { public: false, error: true, reason: `could not decide whether it is public: ${error instanceof Error ? error.message : String(error)}` });
226
+ continue;
227
+ }
228
+ for (const file of files) out.set(file.abs, veto(found.get(file.rel)!, file.rel, repoConfig));
229
+ }
230
+ return out;
231
+ }
232
+
233
+ /** 조상 중 `.git`(폴더 또는 worktree·submodule 파일)이 있는 가장 가까운 폴더. 없으면 undefined(git 밖). */
234
+ export function gitRootOf(path: string): string | undefined {
235
+ let current = dirname(path);
236
+ for (;;) {
237
+ if (existsSync(join(current, ".git"))) return current;
238
+ const parent = dirname(current);
239
+ if (parent === current) return undefined;
240
+ current = parent;
241
+ }
242
+ }
243
+
116
244
  export const sha256 = (bytes: Uint8Array | string): string => createHash("sha256").update(bytes).digest("hex");
117
245
 
118
246
  // ── 원장 ─────────────────────────────────────────────────────────────────────
@@ -120,8 +248,12 @@ export const sha256 = (bytes: Uint8Array | string): string => createHash("sha256
120
248
  export interface SlopFindingRecord { id: string; quote: string; rule: string; fix: string; quoteFound?: boolean; reviewer?: string }
121
249
  export interface SlopReviewRecord {
122
250
  type: "slop-review"; reviewId: string; ts: string; model: string;
123
- reviewers?: { family: string; model?: string; status: string; error?: string; advisory?: true }[];
251
+ reviewers?: { family: string; model?: string; status: string; error?: string; raw?: string; advisory?: true }[];
124
252
  files: { path: string; sha256: string; scope?: string; findings: SlopFindingRecord[] }[];
253
+ /** 필수 reviewer 실패·누락으로 심사하지 못한 파일과 그 진단. resolve는 files만 보므로 여기 든 파일은 통과가 될 수 없다. */
254
+ failed?: { path: string; sha256: string; error: string; reviewer?: { family: string; model?: string; status: string; error?: string; raw?: string }; diagnostics?: SlopFindingRecord[] }[];
255
+ /** 모든 묶음의 실패한 reviewer 호출(자문 포함). */
256
+ failedAttempts?: { family: string; model?: string; status: string; error?: string; raw?: string; advisory?: true }[];
125
257
  }
126
258
  export interface SlopResolveRecord { type: "slop-resolve"; reviewId: string; ts: string; resolutions: { id: string; status: string; evidence: string }[] }
127
259
  export interface SlopPassRecord {
@@ -183,12 +315,14 @@ export interface SlopGateOutcome {
183
315
  artifacts: { path: string; sha256: string }[];
184
316
  /** 요청한 모든 경로의 blob(보이는 산출물은 통과를 맞춘 바로 그 바이트의 blob). finalizer가 잠금 안에서 stage된 내용과 대조한다. */
185
317
  gateBlobs?: Record<string, string>;
318
+ /** 보이는 형식이지만 공개 산출물이 아니라 게이트가 보지 않은 파일(요청한 경로)과 그 이유. 통과가 아니다. */
319
+ notPublic?: { path: string; reason: string }[];
186
320
  }
187
321
 
188
322
  /**
189
- * git_finalize가 cross-review 다음에 부르는 게이트. 새로 커밋할 변경이 없는 파일(resume-push)과 삭제는 대상이 아니다.
190
- * 통과 기록이 없으면 SlopGateRefusal. waiver는 기록을 남기고 통과시킨다. 입력 모양이 잘못된 경우(절대 경로 등)만
191
- * finalizer.ps1의 판정에 맡기고, 저장소 상태를 읽지 못하면 열어 두지 않는다.
323
+ * git_finalize가 cross-review 다음에 부르는 게이트. 새로 커밋할 변경이 없는 파일(resume-push)과 삭제는 대상이 아니고, 공개 산출물이 아닌
324
+ * 파일(repoPublication)은 바이트를 읽지 않고 notPublic으로 알린다. 통과 기록이 없으면 SlopGateRefusal. waiver는 기록을 남기고 통과시킨다.
325
+ * 입력 모양이 잘못된 경우(절대 경로 등)만 finalizer.ps1의 판정에 맡기고, 저장소 상태나 공개 여부를 읽지 못하면 열어 두지 않는다.
192
326
  */
193
327
  export async function runSlopGate(options: SlopGateOptions): Promise<SlopGateOutcome> {
194
328
  const exec = options.exec ?? spawnExec();
@@ -201,14 +335,23 @@ export async function runSlopGate(options: SlopGateOptions): Promise<SlopGateOut
201
335
  const config = loadSlopConfig(resolved.root);
202
336
  const { changed, unchanged } = await collectChanges(exec, git, resolved.root, resolved.targets.map((target) => target.path));
203
337
  const visible = changed.filter((change) => change.status !== "deleted" && classify(change.path, config).visible);
204
- if (visible.length === 0) return { checked: true, artifacts: [] };
338
+ if (visible.length === 0) return { checked: true, artifacts: [], notPublic: [] };
205
339
 
206
340
  const inputOf = new Map(resolved.targets.map((target) => [target.path, target.input]));
341
+ let publication: Map<string, Publication>;
342
+ try { publication = await repoPublication(exec, git, resolved.root, visible.map((change) => change.path), config); } catch (error) {
343
+ throw new SlopGateRefusal(`could not decide which files are public, so the slop-gate requirement cannot be checked: ${error instanceof Error ? error.message : String(error)}`);
344
+ }
345
+ const notPublic = visible.filter((change) => !publication.get(change.path)!.public)
346
+ .map((change) => ({ path: inputOf.get(change.path) ?? change.path, reason: publication.get(change.path)!.reason }));
347
+ const gated = visible.filter((change) => publication.get(change.path)!.public);
348
+ if (gated.length === 0) return { checked: true, artifacts: [], notPublic };
349
+
207
350
  const records = readSlopRecords(options.ledgerPath);
208
351
  const artifacts: { path: string; sha256: string }[] = [];
209
352
  const blobs: Record<string, string> = {};
210
353
  const uncovered: { input: string; sha256: string; note?: string }[] = [];
211
- for (const change of visible) {
354
+ for (const change of gated) {
212
355
  const abs = join(resolved.root, ...change.path.split("/"));
213
356
  let bytes: Buffer;
214
357
  try { bytes = readFileSync(abs); } catch (error) {
@@ -238,17 +381,18 @@ export async function runSlopGate(options: SlopGateOptions): Promise<SlopGateOut
238
381
  ...uncovered.map((file) => `- ${file.input}${file.note ? ` [${file.note}]` : ""}`),
239
382
  `Next: run slop_check {files:${names}, authors:[<the model selectors that wrote the text, or "main">]} (reviewers follow the same author-family rule as cross_review; only text changed since HEAD is reviewed for tracked files), fix or refute every finding (a clean review records the pass by itself; refuted findings are closed with slop_check {action:"resolve"}), then call git_finalize again with the same files. Do not edit these files after the pass: it is tied to their exact content (sha256).`,
240
383
  "A waiver (slopGateWaiver) is allowed only on the user's explicit instruction and is recorded in the slop-gate ledger.",
384
+ ...(notPublic.length > 0 ? [`Not gated because they are not public artifacts (no pass either): ${notPublic.map((file) => `${file.path} (${file.reason})`).join("; ")}.`] : []),
241
385
  ].join("\n"));
242
386
  }
243
387
  try {
244
388
  appendSlopRecord(options.ledgerPath, {
245
389
  type: "slop-waiver", ts: (options.now?.() ?? new Date()).toISOString(), root: resolved.root, reason,
246
- files: visible.map((change) => ({ path: change.path, sha256: artifacts.find((artifact) => artifact.path === change.path)!.sha256 })),
390
+ files: gated.map((change) => ({ path: change.path, sha256: artifacts.find((artifact) => artifact.path === change.path)!.sha256 })),
247
391
  });
248
392
  } catch { throw new SlopGateRefusal("slop-gate waiver could not be recorded in the slop-gate ledger; refusing to commit without a record."); }
249
- return { checked: true, waived: true, artifacts, gateBlobs };
393
+ return { checked: true, waived: true, artifacts, gateBlobs, notPublic };
250
394
  }
251
- return { checked: true, artifacts, gateBlobs };
395
+ return { checked: true, artifacts, gateBlobs, notPublic };
252
396
  }
253
397
 
254
398
  /**
@@ -328,6 +472,20 @@ export function candidatesOf(toolName: string, input: Record<string, unknown>, c
328
472
  return { files: [...files], dirs: [...dirs] };
329
473
  }
330
474
 
475
+ /** slop_check {public:true}가 선언한 파일(적힌 경로와 실제 경로). 턴 끝 게이트는 이번 입력 동안 이 파일을 공개로 본다. */
476
+ export function declaredPublic(toolName: string, input: Record<string, unknown>, cwd: string): string[] {
477
+ if (toolName !== "slop_check" || input.public !== true || !Array.isArray(input.files)) return [];
478
+ const out: string[] = [];
479
+ for (const file of input.files) {
480
+ if (typeof file !== "string" || !file.trim()) continue;
481
+ const spelled = wslPath(file.trim());
482
+ const lexical = isAbsolute(spelled) ? resolve(spelled) : resolve(cwd, spelled);
483
+ out.push(lexical);
484
+ try { out.push(realpathSync(lexical)); } catch { /* 아직 없는 파일은 적힌 경로만 */ }
485
+ }
486
+ return out;
487
+ }
488
+
331
489
  const SKIP_WALK: Record<string, true> = { ...GENERATED_SEGMENT };
332
490
 
333
491
  /** dir 아래(깊이·개수 제한)에서 since 이후 바뀐 보이는 형식 파일. */
@@ -364,11 +522,12 @@ export function insideGit(path: string): boolean {
364
522
  export interface PendingArtifact { path: string; sha256: string; reason: string }
365
523
 
366
524
  /**
367
- * 턴 끝 판정. 후보 중 존재하고, 턴 시작 이후 바뀌었고, git 밖이고, 보이는 산출물이며, 현재 내용의 통과가 없는 것.
525
+ * 턴 끝 판정. 후보 중 존재하고, 턴 시작 이후 바뀌었고, git 밖이고, 보이는 산출물이며, 공개 선언(`.slop-gate.json` glob 또는 이번 입력의
526
+ * slop_check public:true, declared)이 있고, 현재 내용의 통과가 없는 것. 선언 없는 저장소 밖 문서는 모르는 파일이라 깨우지 않는다.
368
527
  * since는 mtime 시계 차이(Windows 드라이브)를 감안해 2초 일찍 잡는다.
369
528
  */
370
529
  export function pendingArtifacts(
371
- tracked: { files: Iterable<string>; dirs: Iterable<string> }, cwd: string, since: number, records: readonly SlopRecord[],
530
+ tracked: { files: Iterable<string>; dirs: Iterable<string> }, cwd: string, since: number, records: readonly SlopRecord[], declared: ReadonlySet<string> = new Set(),
372
531
  ): PendingArtifact[] {
373
532
  const found = new Set<string>(tracked.files);
374
533
  const floor = since - 2_000;
@@ -377,18 +536,26 @@ export function pendingArtifacts(
377
536
  for (const file of recentVisibleFiles(dir, floor)) found.add(file);
378
537
  }
379
538
  if (!insideGit(cwd) && !cwd.startsWith("/mnt/")) for (const file of recentVisibleFiles(cwd, floor)) found.add(file);
539
+ const root = configRootOf(cwd);
540
+ const config = loadSlopConfig(root);
541
+ let base = cwd;
542
+ try { base = realpathSync(cwd); } catch { /* cwd를 읽지 못하면 적힌 대로 */ }
380
543
  const out: PendingArtifact[] = [];
381
544
  for (const path of [...found].sort()) {
382
- if (insideGit(path)) continue;
545
+ // 링크는 실제 경로로만 판정하고 읽는다: 별칭 이름이 산출물처럼 보여도 대상의 저장소·분류·공개 선언을 따른다.
546
+ let real: string;
547
+ try { real = realpathSync(path); } catch { continue; }
548
+ if (insideGit(real)) continue;
383
549
  // cwd 안 파일은 상대 경로로 분류한다(폴더 규칙이 적용되고, cwd가 /tmp 아래여도 산출물로 본다).
384
- const inside = relative(cwd, path);
385
- const kind = classify(inside !== "" && !inside.startsWith("..") && !isAbsolute(inside) ? inside : path);
550
+ const inside = relative(base, real);
551
+ const kind = classify(inside !== "" && !inside.startsWith("..") && !isAbsolute(inside) ? inside : real, config);
386
552
  if (!kind.visible) continue;
553
+ if (!externalPublication(real, root, config).public && !declared.has(real)) continue;
387
554
  let bytes: Buffer;
388
555
  try {
389
- const stat = statSync(path);
556
+ const stat = statSync(real);
390
557
  if (!stat.isFile() || stat.mtimeMs < floor) continue;
391
- bytes = readFileSync(path);
558
+ bytes = readFileSync(real);
392
559
  } catch { continue; }
393
560
  const hash = sha256(bytes);
394
561
  if (!passFor(records, hash)) out.push({ path, sha256: hash, reason: kind.reason });
@@ -10,6 +10,8 @@ import { onSessionLifecycle } from "./lib/session-identity";
10
10
 
11
11
  export const REMINDER_TYPE = "report-chart-guard";
12
12
  export const MIN_VALUES = 3;
13
+ // 표 전체(열·행이 달라도)는 2×2 전후 비교가 되는 4개부터 센다. 열마다 뜻이 다른 표의 값 셋은 비교로 보지 않는다.
14
+ export const MIN_TABLE_VALUES = 4;
13
15
 
14
16
  type Message = { role?: string; content?: unknown; synthetic?: boolean; attribution?: string };
15
17
 
@@ -20,10 +22,41 @@ const UNIT_KIND: Readonly<Record<string, string>> = {
20
22
  "%": "percent", "배": "ratio", "건": "count-건", "회": "count-회",
21
23
  KB: "size", MB: "size", GB: "size", KiB: "size", MiB: "size", GiB: "size",
22
24
  };
23
- // 버전(0.10.38)·시각(04:48)·날짜(10-19)·경로 조각 안의 숫자는 수치로 보지 않는다(앞뒤 문자 경계).
24
- // 단위 바로 뒤에 다른 낱말이 붙으면(배포·분석·회의·초기·건너…) 단위가 아니다.
25
+ // 버전(0.10.38)·시각(04:48)·날짜(10-19)·경로 조각 안의 숫자는 수치로 보지 않는다(앞뒤 문자 경계). 구간 뒤쪽 끝(1~2분)도 뺀다.
26
+ // 단위 바로 뒤에 다른 낱말이 붙으면(배포·분석·회의·초기·건너…) 단위가 아니다. 회차(1회차)는 순번이다.
27
+ // 천 단위 쉼표 수(1,395건)는 한 값이다.
25
28
  const QUANTITY =
26
- /(?<![\d.:/\-A-Za-z_])(\d+(?:\.\d+)?)\s?(ms|s|초|분|시간|%|배|건|회|KiB|MiB|GiB|KB|MB|GB)(?![A-Za-z\d])(?!(?:포|치|열|석|류|기|화|의|수|복|너|당|위|면|산|간|리|야|장|별)[가-힣])/g;
29
+ /(?<![\d.:/\-A-Za-z_~∼]|\d,|[~∼]\s+)(\d{1,3}(?:,\d{3})+(?:\.\d+)?|\d+(?:\.\d+)?)\s?(ms|s|초|분|시간|%|배|건|회|KiB|MiB|GiB|KB|MB|GB)(?![A-Za-z\d])(?!차)(?!(?:포|치|열|석|류|기|화|의|수|복|너|당|위|면|산|간|리|야|장|별)[가-힣])/g;
30
+ // 비교할 기록 값이 아닌 말씨만 뺀다: 추정("약 7MB"·"7분쯤"), 구간("10분~20분"), 주기("1분마다"·"3ms 간격"), 한계 이름("5초 제한"),
31
+ // 진행 순번("25분째"), 전체 중 일부("17건 중 16건"의 앞 값). 최대·최소·이상·이하·0건은 실제 기록일 수 있어 건드리지 않는다.
32
+ const NOT_A_RECORD_BEFORE = /(?<![가-힣])(?:약|대략|거의|(?:제한|한도|상한|하한)[은는이가]?\s?[::]?)\s?$/; // "계약 2건"·"권한도 2건"의 약·한도는 낱말 일부다.
33
+ const NOT_A_RECORD_AFTER = /^(?:\s*[~∼]|\s?(?:마다|간격|쯤|정도|가량|째|제한|한도|상한|중(?:에서?|으로)?(?![가-힣])))/;
34
+ // 한 시간 값이 "5분 15초"처럼 큰 단위 뒤에 작은 단위로 이어지면 하나로 센다.
35
+ const TIME_RANK: Readonly<Record<string, number>> = { ms: 0, s: 1, "초": 1, "분": 2, "시간": 3 };
36
+
37
+ type Quantity = { value: string; kind: string; start: number; end: number; unit: string };
38
+
39
+ /** 한 조각(문단·표 칸)에서 비교할 만한 수치를 순서대로 뽑는다. */
40
+ function quantitiesOf(segment: string): Quantity[] {
41
+ const raw: Quantity[] = [];
42
+ for (const match of segment.matchAll(QUANTITY)) {
43
+ const kind = UNIT_KIND[match[2]!];
44
+ if (kind) raw.push({ value: `${match[1]}${match[2]}`, kind, start: match.index!, end: match.index! + match[0].length, unit: match[2]! });
45
+ }
46
+ const merged: Quantity[] = [];
47
+ for (const q of raw) {
48
+ const prev = merged[merged.length - 1];
49
+ const rank = TIME_RANK[q.unit];
50
+ if (prev && rank !== undefined && TIME_RANK[prev.unit] !== undefined && rank < TIME_RANK[prev.unit]! && /^[ \t]?$/.test(segment.slice(prev.end, q.start))) {
51
+ prev.value = `${prev.value} ${q.value}`;
52
+ prev.end = q.end;
53
+ prev.unit = q.unit;
54
+ continue;
55
+ }
56
+ merged.push({ ...q });
57
+ }
58
+ return merged.filter((q) => !NOT_A_RECORD_BEFORE.test(segment.slice(0, q.start)) && !NOT_A_RECORD_AFTER.test(segment.slice(q.end)));
59
+ }
27
60
 
28
61
  function textOf(content: unknown): string {
29
62
  if (typeof content === "string") return content;
@@ -34,23 +67,118 @@ function textOf(content: unknown): string {
34
67
  .join("\n");
35
68
  }
36
69
 
37
- /** 값이 셋 이상인 같은 종류의 수치 묶음. 없으면 null. Mermaid 블록이 이미 있으면 판정하지 않는다. */
38
- export function chartCandidate(text: string): { kind: string; values: string[] } | null {
70
+ // 산문 블록의 경계: 제목·굵은 글씨만 있는 라벨 줄은 새 블록이다(라벨 바로 뒤 빈 줄은 넘는다). 빈 줄 뒤도 새 블록이지만
71
+ // 목록 항목 사이의 빈 줄(들여쓴 이어 줄 포함)과 ":"로 끝난 소개 문단 뒤 목록 앞의 빈 줄은 넘는다.
72
+ const LIST_ITEM = /^\s*(?:[-*+]|\d+[.)])\s/;
73
+ const LABEL_LINE = /^\s*(?:#{1,6}\s|\*\*[^*\n]+\*\*[::]?\s*$)/;
74
+ // 같은 블록 안에 비교 말씨가 있으면 값이 서로 견주어졌다고 본다. 이 말씨나 표·목록 구조가 없는 산문 묶음은 "모호한 후보"다.
75
+ const COMPARATIVE = /(각각|비교|대비|보다|\bvs\b|→|->|전후|변경 전|변경 후|전에는|후에는|차이|늘었|줄었|늘어|줄어|증가|감소|느려|빨라|개선|악화)/;
76
+
77
+ export type ChartCandidate = { kind: string; values: string[]; strong: boolean };
78
+
79
+ // 라벨+값이 쉼표·세미콜론·가운뎃점·와/과로 이어진 반복 측정("빌드 20.8분, 배포 34.6분, 검증 42.0분")은 서로 다른 값 셋 이상이면
80
+ // 나열된 비교로 본다. 값 사이 글이 구분자로 시작하고 짧은 라벨뿐이어야 한다(문장·괄호·종결 부호가 끼면 이어진 나열이 아니다).
81
+ const CHAIN_GAP = /^\s?(?:[,;·/、]|[와과]|및)\s?([^,;.!?()()|\n]{0,14})$/;
82
+ function hasLabelledRun(text: string): boolean {
83
+ const quantities = quantitiesOf(text);
84
+ let run: string[] = [];
85
+ for (const [i, q] of quantities.entries()) {
86
+ const prev = quantities[i - 1];
87
+ const label = prev ? CHAIN_GAP.exec(text.slice(prev.end, q.start))?.[1] : undefined;
88
+ if (prev && prev.kind === q.kind && label !== undefined && label.trim() !== "") run.push(q.value);
89
+ else run = [q.value];
90
+ if (new Set(run).size >= MIN_VALUES) return true;
91
+ }
92
+ return false;
93
+ }
94
+
95
+ /**
96
+ * 값이 셋 이상인 같은 종류의 수치 묶음. 없으면 null. Mermaid 블록이 이미 있으면 판정하지 않는다.
97
+ * 한 묶음은 같은 비교 구조 안의 값이다: 표는 열 하나·행 하나 안의 서로 다른 값 셋, 또는 표 전체의 같은 종류 칸 넷(서로 다른 값 셋 이상,
98
+ * 2×2 전후 비교). 표 밖은 한 문단·한 목록(제목·라벨·빈 줄로 갈라지는 블록) 안의 값이다. 서로 다른 블록의 값은 합치지 않는다.
99
+ */
100
+ export function chartCandidate(text: string): ChartCandidate | null {
39
101
  if (/```\s*mermaid\b/i.test(text)) return null;
40
- const groups = new Map<string, string[]>();
41
102
  // 코드 블록·인라인 코드 안의 수치(명령·로그)는 보고 수치로 세지 않는다.
42
- const prose = text.replace(/```[\s\S]*?(?:```|$)/g, "\n").replace(/`[^`\n]*`/g, " ");
43
- for (const match of prose.matchAll(QUANTITY)) {
44
- const kind = UNIT_KIND[match[2]!];
45
- if (!kind) continue;
46
- const value = `${match[1]}${match[2]}`;
47
- const list = groups.get(kind) ?? [];
48
- if (!list.includes(value)) list.push(value);
49
- groups.set(kind, list);
50
- }
51
- let best: { kind: string; values: string[] } | null = null;
52
- for (const [kind, values] of groups) {
53
- if (values.length >= MIN_VALUES && (!best || values.length > best.values.length)) best = { kind, values };
103
+ const prose = text.replace(/\n?```[\s\S]*?(?:```|$)\n?/g, "\n").replace(/`[^`\n]*`/g, " ");
104
+ const series = new Map<string, Map<string, string[]>>();
105
+ const add = (key: string, q: Quantity) => {
106
+ const kinds = series.get(key) ?? new Map<string, string[]>();
107
+ const list = kinds.get(q.kind) ?? [];
108
+ list.push(q.value);
109
+ kinds.set(q.kind, list);
110
+ series.set(key, kinds);
111
+ };
112
+ const lines = prose.split("\n");
113
+ let block = 0;
114
+ let pendingBreak = false;
115
+ let prevList = false;
116
+ let labelOpen = false;
117
+ let introColon = false;
118
+ const proseLines = new Map<number, string[]>();
119
+ const toProse = (line: string) => {
120
+ if (line.trim() === "") { pendingBreak = true; return; }
121
+ const isList = LIST_ITEM.test(line);
122
+ const isLabel = LABEL_LINE.test(line);
123
+ const listAfterIntro = pendingBreak && isList && !prevList && introColon;
124
+ // 굵은 라벨이 목록 항목 바로 뒤에 오면 라벨별로 묶인 한 목록이다. 제목(#)과 산문 뒤 라벨은 새 블록이다.
125
+ const groupedLabel = isLabel && prevList && !pendingBreak && !/^\s*#/.test(line);
126
+ const continuation = prevList && !isList && /^\s{2,}\S/.test(line); // 목록 항목의 들여쓴 이어 줄은 빈 줄 뒤에도 그 항목 소속이다.
127
+ if ((isLabel && !groupedLabel && !continuation) || (pendingBreak && !labelOpen && !listAfterIntro && !continuation && !(prevList && isList))) block += 1;
128
+ labelOpen = isLabel;
129
+ pendingBreak = false;
130
+ prevList = isList || (prevList && (groupedLabel || /^\s{2,}\S/.test(line)));
131
+ introColon = /[::]\s*$/.test(line);
132
+ const list = proseLines.get(block) ?? [];
133
+ list.push(line);
134
+ proseLines.set(block, list);
135
+ };
136
+ // 머리글 구분선(---|---) 바로 앞 줄부터 `|`가 있는 줄까지가 표다. 바깥 파이프가 없는 표도 포함한다.
137
+ const isSeparator = (line: string | undefined) => line !== undefined && line.includes("|") && /^[\s|:\-]+$/.test(line) && line.includes("-");
138
+ let table = 0;
139
+ let row = 0;
140
+ let inTable = false;
141
+ const tableCells = new Map<string, number>(); // 표 번호|종류 → 그 종류 수치가 든 칸 수
142
+ lines.forEach((line, i) => {
143
+ const newBlock = !/^\s*\|/.test(line) && /^\s*(?:#{1,6}\s|>|[-*+]\s|\d+[.)]\s)/.test(line); // 제목·인용·목록 줄은 표가 아니라 새 블록이다.
144
+ if (!line.includes("|") || newBlock || !(inTable || isSeparator(lines[i + 1]) || isSeparator(line))) {
145
+ inTable = false;
146
+ toProse(line);
147
+ return;
148
+ }
149
+ if (!inTable) { inTable = true; table += 1; row = 0; pendingBreak = true; prevList = false; labelOpen = false; introColon = false; }
150
+ if (isSeparator(line)) return;
151
+ row += 1;
152
+ line.trim().replace(/^\|/, "").replace(/\|$/, "").split("|").forEach((cell, col) => {
153
+ const quantities = quantitiesOf(cell);
154
+ for (const q of quantities) { add(`t${table}c${col}`, q); add(`t${table}r${row}`, q); add(`t${table}`, q); }
155
+ for (const kind of new Set(quantities.map((q) => q.kind))) tableCells.set(`${table}|${kind}`, (tableCells.get(`${table}|${kind}`) ?? 0) + 1);
156
+ });
157
+ });
158
+ for (const [id, blockLines] of proseLines) for (const q of quantitiesOf(blockLines.join("\n"))) add(`p${id}`, q);
159
+ // 강한 후보: 표 열·행·전체, 또는 목록 항목 셋 이상이 각각 같은 종류 값을 가진 블록, 또는 비교 말씨가 있는 블록.
160
+ const isStrong = (key: string, kind: string): boolean => {
161
+ if (key.startsWith("t")) return true;
162
+ const blockLines = proseLines.get(Number(key.slice(1))) ?? [];
163
+ // 목록 항목 = 목록 줄 + 들여쓴 이어 줄. 값은 항목 안 어디에 있어도 된다.
164
+ const itemTexts: string[] = [];
165
+ for (const line of blockLines) {
166
+ if (LIST_ITEM.test(line)) itemTexts.push(line);
167
+ else if (itemTexts.length > 0 && /^\s{2,}\S/.test(line)) itemTexts[itemTexts.length - 1] += `\n${line}`;
168
+ }
169
+ const items = itemTexts.filter((item) => quantitiesOf(item).some((q) => q.kind === kind)).length;
170
+ const blockText = blockLines.join("\n");
171
+ return items >= MIN_VALUES || COMPARATIVE.test(blockText) || hasLabelledRun(blockText);
172
+ };
173
+ let best: ChartCandidate | null = null;
174
+ for (const [key, kinds] of series) {
175
+ const wholeTable = /^t\d+$/.test(key);
176
+ for (const [kind, cells] of kinds) {
177
+ const values = [...new Set(cells)];
178
+ if (values.length < MIN_VALUES || (wholeTable && (tableCells.get(`${key.slice(1)}|${kind}`) ?? 0) < MIN_TABLE_VALUES)) continue;
179
+ const strong = isStrong(key, kind);
180
+ if (!best || (strong && !best.strong) || (strong === best.strong && values.length > best.values.length)) best = { kind, values, strong };
181
+ }
54
182
  }
55
183
  return best;
56
184
  }
@@ -79,10 +207,12 @@ export default function reportChartGuard(pi: ExtensionAPI): void {
79
207
  if (reminded || message.role !== "assistant" || ctx.agent.kind !== "main") return;
80
208
  const candidate = chartCandidate(textOf(message.content));
81
209
  if (!candidate) return;
82
- reminded = true;
83
210
  const calls = Array.isArray(message.content)
84
211
  ? message.content.filter((block): block is { type: string; name?: string } => block?.type === "toolCall")
85
212
  : [];
213
+ // 이미 끝난 답을 다시 여는 강제 이어 가기는 표·목록·비교 말씨가 있는 후보에만 쓴다. 값만 나열된 모호한 산문은 조용히 둔다.
214
+ if (calls.length === 0 && !candidate.strong) return;
215
+ reminded = true;
86
216
  if (calls.some((call) => call.name === "ask")) {
87
217
  askHold = `[report-chart-guard] 질문을 보내지 않았다. ${reminderText(candidate)} 차트가 필요하면 차트를 붙인 응답에서 같은 질문을 다시 보낸다. 필요 없으면 같은 질문을 그대로 다시 보낸다.`;
88
218
  return;