@tienne/gestalt 0.149.0 → 0.151.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.
Files changed (154) hide show
  1. package/dist/package.json +1 -1
  2. package/dist/plugin/.codex-plugin/plugin.json +1 -1
  3. package/dist/plugin/skills/architecture/SKILL.md +103 -16
  4. package/dist/plugin/skills/architecture/references/domain-flow.md +1 -1
  5. package/dist/plugin/skills/architecture/references/merge-analyses.md +4 -3
  6. package/dist/plugin/skills/architecture/references/rerun.md +5 -5
  7. package/dist/schemas/architecture-ir.schema.json +18 -1
  8. package/dist/src/architecture/commit-policy.d.ts +31 -0
  9. package/dist/src/architecture/commit-policy.d.ts.map +1 -0
  10. package/dist/src/architecture/commit-policy.js +95 -0
  11. package/dist/src/architecture/commit-policy.js.map +1 -0
  12. package/dist/src/architecture/csp.d.ts +14 -0
  13. package/dist/src/architecture/csp.d.ts.map +1 -0
  14. package/dist/src/architecture/csp.js +56 -0
  15. package/dist/src/architecture/csp.js.map +1 -0
  16. package/dist/src/architecture/delta-renderer.d.ts.map +1 -1
  17. package/dist/src/architecture/delta-renderer.js +12 -9
  18. package/dist/src/architecture/delta-renderer.js.map +1 -1
  19. package/dist/src/architecture/delta.d.ts +2 -1
  20. package/dist/src/architecture/delta.d.ts.map +1 -1
  21. package/dist/src/architecture/delta.js +4 -2
  22. package/dist/src/architecture/delta.js.map +1 -1
  23. package/dist/src/architecture/did-you-mean.d.ts +14 -0
  24. package/dist/src/architecture/did-you-mean.d.ts.map +1 -0
  25. package/dist/src/architecture/did-you-mean.js +63 -0
  26. package/dist/src/architecture/did-you-mean.js.map +1 -0
  27. package/dist/src/architecture/drilldown.d.ts +53 -1
  28. package/dist/src/architecture/drilldown.d.ts.map +1 -1
  29. package/dist/src/architecture/drilldown.js +441 -32
  30. package/dist/src/architecture/drilldown.js.map +1 -1
  31. package/dist/src/architecture/endpoint-match.d.ts +33 -2
  32. package/dist/src/architecture/endpoint-match.d.ts.map +1 -1
  33. package/dist/src/architecture/endpoint-match.js +295 -42
  34. package/dist/src/architecture/endpoint-match.js.map +1 -1
  35. package/dist/src/architecture/git-facts.d.ts +54 -0
  36. package/dist/src/architecture/git-facts.d.ts.map +1 -0
  37. package/dist/src/architecture/git-facts.js +225 -0
  38. package/dist/src/architecture/git-facts.js.map +1 -0
  39. package/dist/src/architecture/html-client.d.ts +9 -0
  40. package/dist/src/architecture/html-client.d.ts.map +1 -1
  41. package/dist/src/architecture/html-client.js +397 -40
  42. package/dist/src/architecture/html-client.js.map +1 -1
  43. package/dist/src/architecture/html-renderer.d.ts +2 -0
  44. package/dist/src/architecture/html-renderer.d.ts.map +1 -1
  45. package/dist/src/architecture/html-renderer.js +230 -24
  46. package/dist/src/architecture/html-renderer.js.map +1 -1
  47. package/dist/src/architecture/html-theme.d.ts +17 -10
  48. package/dist/src/architecture/html-theme.d.ts.map +1 -1
  49. package/dist/src/architecture/html-theme.js +271 -137
  50. package/dist/src/architecture/html-theme.js.map +1 -1
  51. package/dist/src/architecture/index.d.ts +3 -0
  52. package/dist/src/architecture/index.d.ts.map +1 -1
  53. package/dist/src/architecture/index.js +3 -0
  54. package/dist/src/architecture/index.js.map +1 -1
  55. package/dist/src/architecture/ir-schema.d.ts +296 -264
  56. package/dist/src/architecture/ir-schema.d.ts.map +1 -1
  57. package/dist/src/architecture/ir-schema.js +75 -0
  58. package/dist/src/architecture/ir-schema.js.map +1 -1
  59. package/dist/src/architecture/layout-tuning.d.ts +49 -0
  60. package/dist/src/architecture/layout-tuning.d.ts.map +1 -0
  61. package/dist/src/architecture/layout-tuning.js +51 -0
  62. package/dist/src/architecture/layout-tuning.js.map +1 -0
  63. package/dist/src/architecture/layout.d.ts +35 -3
  64. package/dist/src/architecture/layout.d.ts.map +1 -1
  65. package/dist/src/architecture/layout.js +75 -15
  66. package/dist/src/architecture/layout.js.map +1 -1
  67. package/dist/src/architecture/live-ask.d.ts +35 -0
  68. package/dist/src/architecture/live-ask.d.ts.map +1 -0
  69. package/dist/src/architecture/live-ask.js +69 -0
  70. package/dist/src/architecture/live-ask.js.map +1 -0
  71. package/dist/src/architecture/live-client.d.ts +17 -0
  72. package/dist/src/architecture/live-client.d.ts.map +1 -0
  73. package/dist/src/architecture/live-client.js +272 -0
  74. package/dist/src/architecture/live-client.js.map +1 -0
  75. package/dist/src/architecture/live-port.d.ts +17 -0
  76. package/dist/src/architecture/live-port.d.ts.map +1 -0
  77. package/dist/src/architecture/live-port.js +23 -0
  78. package/dist/src/architecture/live-port.js.map +1 -0
  79. package/dist/src/architecture/live-server.d.ts +79 -0
  80. package/dist/src/architecture/live-server.d.ts.map +1 -0
  81. package/dist/src/architecture/live-server.js +409 -0
  82. package/dist/src/architecture/live-server.js.map +1 -0
  83. package/dist/src/architecture/live-session.d.ts +13 -0
  84. package/dist/src/architecture/live-session.d.ts.map +1 -0
  85. package/dist/src/architecture/live-session.js +48 -0
  86. package/dist/src/architecture/live-session.js.map +1 -0
  87. package/dist/src/architecture/merge.d.ts +17 -0
  88. package/dist/src/architecture/merge.d.ts.map +1 -1
  89. package/dist/src/architecture/merge.js +27 -3
  90. package/dist/src/architecture/merge.js.map +1 -1
  91. package/dist/src/architecture/packs/generic.d.ts +2 -2
  92. package/dist/src/architecture/packs/generic.js +2 -2
  93. package/dist/src/architecture/packs/generic.js.map +1 -1
  94. package/dist/src/architecture/packs/index.d.ts +2 -2
  95. package/dist/src/architecture/repo-visibility.d.ts +32 -0
  96. package/dist/src/architecture/repo-visibility.d.ts.map +1 -0
  97. package/dist/src/architecture/repo-visibility.js +93 -0
  98. package/dist/src/architecture/repo-visibility.js.map +1 -0
  99. package/dist/src/architecture/secret-mask.d.ts +61 -0
  100. package/dist/src/architecture/secret-mask.d.ts.map +1 -0
  101. package/dist/src/architecture/secret-mask.js +618 -0
  102. package/dist/src/architecture/secret-mask.js.map +1 -0
  103. package/dist/src/architecture/store.d.ts +88 -6
  104. package/dist/src/architecture/store.d.ts.map +1 -1
  105. package/dist/src/architecture/store.js +419 -50
  106. package/dist/src/architecture/store.js.map +1 -1
  107. package/dist/src/architecture/types.d.ts +8 -0
  108. package/dist/src/architecture/types.d.ts.map +1 -1
  109. package/dist/src/architecture/types.js.map +1 -1
  110. package/dist/src/architecture/validator.d.ts +75 -3
  111. package/dist/src/architecture/validator.d.ts.map +1 -1
  112. package/dist/src/architecture/validator.js +318 -45
  113. package/dist/src/architecture/validator.js.map +1 -1
  114. package/dist/src/cli/commands/conductor.d.ts.map +1 -1
  115. package/dist/src/cli/commands/conductor.js +50 -1
  116. package/dist/src/cli/commands/conductor.js.map +1 -1
  117. package/dist/src/conductor/recent-events.d.ts +22 -0
  118. package/dist/src/conductor/recent-events.d.ts.map +1 -0
  119. package/dist/src/conductor/recent-events.js +126 -0
  120. package/dist/src/conductor/recent-events.js.map +1 -0
  121. package/dist/src/digest/blocks.d.ts +14 -14
  122. package/dist/src/digest/diagram-schema.d.ts +2 -2
  123. package/dist/src/digest/lens-schema.d.ts +38 -38
  124. package/dist/src/digest/lens-source.d.ts +2 -2
  125. package/dist/src/digest/lens-widget-schema.d.ts +58 -58
  126. package/dist/src/digest/lint-lens-context.d.ts +8 -8
  127. package/dist/src/digest/prd-guide.d.ts +1 -1
  128. package/dist/src/digest/prd-schema.d.ts +18 -18
  129. package/dist/src/digest/schema.d.ts +1046 -1046
  130. package/dist/src/digest/session-request.d.ts +2 -2
  131. package/dist/src/humanize/detectors.d.ts.map +1 -1
  132. package/dist/src/humanize/detectors.js +3 -1
  133. package/dist/src/humanize/detectors.js.map +1 -1
  134. package/dist/src/lens/attach.d.ts +42 -42
  135. package/dist/src/mcp/schemas.d.ts +16 -8
  136. package/dist/src/mcp/schemas.d.ts.map +1 -1
  137. package/dist/src/mcp/schemas.js +11 -2
  138. package/dist/src/mcp/schemas.js.map +1 -1
  139. package/dist/src/mcp/tools/architecture-passthrough.d.ts +18 -0
  140. package/dist/src/mcp/tools/architecture-passthrough.d.ts.map +1 -1
  141. package/dist/src/mcp/tools/architecture-passthrough.js +244 -33
  142. package/dist/src/mcp/tools/architecture-passthrough.js.map +1 -1
  143. package/dist/src/research/schema.d.ts +395 -395
  144. package/dist/src/research/source-schema.d.ts +5 -5
  145. package/dist/src/research/target.d.ts +37 -37
  146. package/package.json +1 -1
  147. package/plugin/.codex-plugin/plugin.json +1 -1
  148. package/plugin/.mcp.json +1 -1
  149. package/plugin/mcp.json +1 -1
  150. package/plugin/skills/architecture/SKILL.md +103 -16
  151. package/plugin/skills/architecture/references/domain-flow.md +1 -1
  152. package/plugin/skills/architecture/references/merge-analyses.md +4 -3
  153. package/plugin/skills/architecture/references/rerun.md +5 -5
  154. package/schemas/architecture-ir.schema.json +18 -1
@@ -5,10 +5,89 @@ import { deriveEr, erCounts, erOverBudget, isUnconfirmedFk } from './er-layout.j
5
5
  import { deriveLifecycle, lifecycleCounts, lifecycleOverBudget } from './lifecycle-layout.js';
6
6
  import { resolveInfraPlacement } from './infra-placement.js';
7
7
  import { indexMicroApps } from './micro-app.js';
8
+ import { SECRET_MASK, maskIrSecrets } from './secret-mask.js';
8
9
  import { ALL_PACKS_VOCABULARY, irVocabulary, packById } from './packs/index.js';
9
10
  import { KNOWLEDGE_DOC_KINDS } from './packs/knowledge.js';
10
11
  import { FLOW_REF_KINDS, HARNESS_KINDS, PARENT_KINDS, PLACED_IN_TARGET_KINDS, hasCardDescription, } from './types.js';
11
- const CODE_LOCATION_RE = /^([^:]+):(.+):(\d+)$/;
12
+ import { suggestOne } from './did-you-mean.js';
13
+ import { drillLevelOwners, shouldDrillDown } from './drilldown.js';
14
+ /**
15
+ * IR 전체를 거부하는 에러 코드. 문서(docs/architecture-view.md) 표가 이 배열과 같은지 테스트가 본다
16
+ */
17
+ export const ARCHITECTURE_VALIDATION_ERROR_CODES = [
18
+ 'SOLID_EDGE_WITHOUT_EVIDENCE',
19
+ 'CODE_EVIDENCE_NOT_FOUND',
20
+ 'PRIVATE_EXCERPT_PRESENT',
21
+ 'DANGLING_EDGE',
22
+ 'PARENT_NOT_FOUND',
23
+ 'PARENT_CYCLE',
24
+ 'INVALID_PARENT_KIND',
25
+ 'LIVE_COMMAND_NOT_READ_ONLY',
26
+ 'ACCOUNT_NOT_FOUND',
27
+ 'INVALID_ACCOUNT_KIND',
28
+ 'PLACED_IN_NOT_FOUND',
29
+ 'INVALID_PLACED_IN_KIND',
30
+ 'CLOUD_ID_IN_ID',
31
+ 'GROUP_MEMBER_NOT_FOUND',
32
+ 'DUPLICATE_GROUP_ID',
33
+ 'SERVES_SERVICE_WITH_APPS',
34
+ 'INVALID_LOADS_ENDS',
35
+ 'INVALID_HARNESS_EDGE_ENDS',
36
+ 'INVALID_CALL_ACTIONS',
37
+ 'UNKNOWN_MCP_ACTION',
38
+ 'MD_CODE_EVIDENCE',
39
+ 'FLOW_SERVICE_NOT_FOUND',
40
+ 'DUPLICATE_FLOW_ID',
41
+ 'FLOW_ACTOR_NOT_FOUND',
42
+ 'FLOW_STEP_NOT_FOUND',
43
+ 'FLOW_REF_NOT_FOUND',
44
+ 'INVALID_FLOW_REF_KIND',
45
+ 'SOLID_TRANSITION_WITHOUT_EVIDENCE',
46
+ 'DUPLICATE_STAGE_ID',
47
+ 'STAGE_NODE_NOT_FOUND',
48
+ 'STAGE_NODE_TWICE',
49
+ 'UNKNOWN_PACK',
50
+ 'KIND_NOT_IN_PACKS',
51
+ 'CODE_EVIDENCE_IN_DOC_REPO',
52
+ 'DUPLICATE_PROJECTION_ID',
53
+ 'DUPLICATE_MESSAGE_ID',
54
+ 'PROJECTION_NODE_NOT_FOUND',
55
+ 'PROJECTION_EDGE_NOT_FOUND',
56
+ 'PROJECTION_EDGE_MISMATCH',
57
+ 'PROJECTION_BLOCK_NOT_FOUND',
58
+ 'PROJECTION_BLOCK_SPLIT',
59
+ 'SOLID_MESSAGE_WITHOUT_EVIDENCE',
60
+ 'PROJECTION_EMPTY',
61
+ 'PROJECTION_SHAPE_FIELD',
62
+ 'PROJECTION_FLOW_NOT_FOUND',
63
+ 'DUPLICATE_PHASE_ID',
64
+ 'PROJECTION_PHASE_MESSAGE_NOT_FOUND',
65
+ 'PROJECTION_PHASE_REVERSED',
66
+ 'PROJECTION_PHASE_OVERLAP',
67
+ 'PROJECTION_PHASE_GAP',
68
+ 'INVALID_DESCRIBES_FROM',
69
+ 'SOLID_DESCRIBES',
70
+ 'COLUMN_REFERENCE_NOT_FOUND',
71
+ 'INVALID_COLUMN_REFERENCE_KIND',
72
+ ];
73
+ /**
74
+ * 못 찾은 id 가운데 첫 번째로 가까운 후보가 있는 것에 제안 하나를 붙인다.
75
+ * 여러 개를 한꺼번에 못 찾아도 제안은 하나만 싣는다(고치는 쪽이 하나씩 확인하게).
76
+ */
77
+ function withNodeIdSuggestion(error, missingIds, known) {
78
+ for (const id of missingIds) {
79
+ const suggestion = suggestOne(id, known.keys());
80
+ if (suggestion === undefined)
81
+ continue;
82
+ return {
83
+ ...error,
84
+ message: `${error.message} "${suggestion}"를 가리키려던 건지 확인한다.`,
85
+ suggestion,
86
+ };
87
+ }
88
+ return error;
89
+ }
90
+ export const CODE_LOCATION_RE = /^([^:]+):(.+):(\d+)$/;
12
91
  /** AWS 계정 ID 꼴(숫자 12자리). 앞뒤가 숫자면 더 긴 수의 일부라 계정 ID로 보지 않는다 */
13
92
  export const ACCOUNT_ID_RE = /(?<!\d)\d{12}(?!\d)/g;
14
93
  // CloudFront 배포 ID 꼴. 대문자 id나 이름과 헷갈릴 수 있어 이름은 cdn 노드에서만, 질문 글자는 통째로 가린다
@@ -19,7 +98,7 @@ export function deriveLineStyle(evidence) {
19
98
  return evidence.some((e) => e.type === 'code' || e.type === 'spec') ? 'solid' : 'dashed';
20
99
  }
21
100
  /** code 근거 위치가 실제 파일의 실제 줄을 가리키는지 본다. 문제가 없으면 빈 객체 */
22
- function checkCodeLocation(location, excerpt, repoRoots, cache) {
101
+ function checkCodeLocation(location, excerpt, repoRoots, cache, findMoved) {
23
102
  const match = CODE_LOCATION_RE.exec(location);
24
103
  if (!match) {
25
104
  return { problem: `code 근거 위치 "${location}"가 <repoId>:<relPath>:<line> 꼴이 아니다.` };
@@ -39,10 +118,19 @@ function checkCodeLocation(location, excerpt, repoRoots, cache) {
39
118
  : `code 근거 위치 "${location}"의 경로가 레포 루트 밖을 가리킨다.`,
40
119
  };
41
120
  }
42
- const check = checkLineExcerpt(readSourceLines(resolved.abs, cache), line, excerpt);
121
+ // 저장 IR에서 다시 들어온 가린 excerpt는 코드 줄과 같을 수 없다. 가린 자리 앞까지만 맞춘다
122
+ // 맨 앞이 가려졌으면 줄 범위만 보고 여러 줄 excerpt면 가린 자리 뒤 줄도 대조에서 빠진다
123
+ const maskAt = excerpt?.indexOf(SECRET_MASK) ?? -1;
124
+ const comparable = maskAt === -1 ? excerpt : excerpt.slice(0, maskAt);
125
+ const check = checkLineExcerpt(readSourceLines(resolved.abs, cache), line, comparable);
43
126
  switch (check.status) {
44
- case 'missing_file':
45
- return { problem: `code 근거 위치 "${location}"의 파일이 레포 "${repoId}"에 없다.` };
127
+ case 'missing_file': {
128
+ const problem = `code 근거 위치 "${location}"의 파일이 레포 "${repoId}"에 없다.`;
129
+ const movedTo = movedLocations(repoId, root, relPath, line, cache, findMoved);
130
+ if (movedTo.length === 0)
131
+ return { problem };
132
+ return { problem: `${problem} git에서 ${movedTo.join(', ')}(으)로 옮겨진 것 같다.`, movedTo };
133
+ }
46
134
  case 'out_of_range':
47
135
  return {
48
136
  problem: `code 근거 위치 "${location}"의 줄 번호 ${line}이 파일 범위(1~${check.lineCount}) 밖이다.`,
@@ -65,6 +153,40 @@ function checkCodeLocation(location, excerpt, repoRoots, cache) {
65
153
  return {};
66
154
  }
67
155
  }
156
+ /**
157
+ * code 근거가 모두 지금 있는 파일의 범위 안 줄을 가리키는지 보는 함수를 만든다.
158
+ * validate가 CODE_EVIDENCE_NOT_FOUND로 막는 경우만 false다. excerpt 불일치는 경고라 따지지 않는다.
159
+ * 병합이 지난 흐름과 투영을 이어 싣기 전에 거르는 데 쓴다. 만든 함수끼리 파일 캐시를 함께 쓴다
160
+ */
161
+ export function createCodeEvidenceCheck(repoRoots) {
162
+ const cache = new Map();
163
+ return (evidence) => evidence.every((ev) => ev.type !== 'code' ||
164
+ checkCodeLocation(ev.location, undefined, repoRoots, cache).problem === undefined);
165
+ }
166
+ /** 옮겨 간 후보 중 지금 실제로 있는 파일만 남긴다. 줄 번호는 그대로 두고 세션이 excerpt로 다시 맞춘다 */
167
+ function movedLocations(repoId, root, relPath, line, cache, findMoved) {
168
+ if (!findMoved)
169
+ return [];
170
+ let candidates;
171
+ try {
172
+ candidates = findMoved(repoId, root, relPath);
173
+ }
174
+ catch {
175
+ return [];
176
+ }
177
+ const out = [];
178
+ for (const candidate of candidates) {
179
+ if (candidate === relPath)
180
+ continue;
181
+ const resolved = resolveInsideRoot(root, candidate);
182
+ if (!resolved.ok || readSourceLines(resolved.abs, cache) === null)
183
+ continue;
184
+ const location = `${repoId}:${candidate}:${line}`;
185
+ if (!out.includes(location))
186
+ out.push(location);
187
+ }
188
+ return out;
189
+ }
68
190
  function checkEvidenceList(evidence, owner, ctx, errors) {
69
191
  evidence.forEach((ev, evidenceIndex) => {
70
192
  if (ev.visibility === 'private' && ev.excerpt !== undefined) {
@@ -89,13 +211,14 @@ function checkEvidenceList(evidence, owner, ctx, errors) {
89
211
  }
90
212
  }
91
213
  if (ev.type === 'code' && ctx.checkFiles) {
92
- const verdict = checkCodeLocation(ev.location, ev.visibility === 'public' ? ev.excerpt : undefined, ctx.repoRoots, ctx.cache);
214
+ const verdict = checkCodeLocation(ev.location, ev.visibility === 'public' ? ev.excerpt : undefined, ctx.repoRoots, ctx.cache, ctx.findMoved);
93
215
  if (verdict.problem) {
94
216
  errors.push({
95
217
  code: 'CODE_EVIDENCE_NOT_FOUND',
96
218
  message: verdict.problem,
97
219
  ...owner,
98
220
  evidenceIndex,
221
+ ...(verdict.movedTo ? { movedTo: verdict.movedTo } : {}),
99
222
  });
100
223
  }
101
224
  else if (verdict.mismatch) {
@@ -212,11 +335,11 @@ function checkAccounts(ir, errors) {
212
335
  continue;
213
336
  const account = byId.get(node.account);
214
337
  if (!account) {
215
- errors.push({
338
+ errors.push(withNodeIdSuggestion({
216
339
  code: 'ACCOUNT_NOT_FOUND',
217
340
  message: `노드 "${node.id}"의 account "${node.account}"가 nodes에 없다.`,
218
341
  nodeId: node.id,
219
- });
342
+ }, [node.account], byId));
220
343
  }
221
344
  else if (account.kind !== 'cloud_account') {
222
345
  errors.push({
@@ -234,11 +357,11 @@ function checkPlacedIn(ir, errors) {
234
357
  continue;
235
358
  const target = byId.get(node.placedIn);
236
359
  if (!target) {
237
- errors.push({
360
+ errors.push(withNodeIdSuggestion({
238
361
  code: 'PLACED_IN_NOT_FOUND',
239
362
  message: `노드 "${node.id}"의 placedIn "${node.placedIn}"가 nodes에 없다.`,
240
363
  nodeId: node.id,
241
- });
364
+ }, [node.placedIn], byId));
242
365
  }
243
366
  else if (!PLACED_IN_TARGET_KINDS.includes(target.kind)) {
244
367
  errors.push({
@@ -305,11 +428,11 @@ function checkParents(ir, errors) {
305
428
  continue;
306
429
  const parent = byId.get(node.parent);
307
430
  if (!parent) {
308
- errors.push({
431
+ errors.push(withNodeIdSuggestion({
309
432
  code: 'PARENT_NOT_FOUND',
310
433
  message: `노드 "${node.id}"의 parent "${node.parent}"가 nodes에 없다.`,
311
434
  nodeId: node.id,
312
- });
435
+ }, [node.parent], byId));
313
436
  continue;
314
437
  }
315
438
  // 고리에 걸린 노드마다 한 번씩만 알린다. 고리 밖에서 고리로 들어가는 노드는 고리 쪽 에러로 충분하다
@@ -1311,6 +1434,7 @@ export function validateArchitectureIr(ir, opts = {}) {
1311
1434
  repoRoots,
1312
1435
  cache: new Map(),
1313
1436
  warnings: excerptWarnings,
1437
+ ...(opts.findMoved ? { findMoved: opts.findMoved } : {}),
1314
1438
  };
1315
1439
  const errors = [];
1316
1440
  const nodeIds = new Set(ir.nodes.map((n) => n.id));
@@ -1341,11 +1465,11 @@ export function validateArchitectureIr(ir, opts = {}) {
1341
1465
  for (const edge of ir.edges) {
1342
1466
  const missing = [edge.from, edge.to].filter((id) => !nodeIds.has(id));
1343
1467
  if (missing.length > 0) {
1344
- errors.push({
1468
+ errors.push(withNodeIdSuggestion({
1345
1469
  code: 'DANGLING_EDGE',
1346
1470
  message: `엣지 "${edge.id}"가 nodes에 없는 노드 ${missing.map((id) => `"${id}"`).join(', ')}를 가리킨다.`,
1347
1471
  edgeId: edge.id,
1348
- });
1472
+ }, missing, nodeIds));
1349
1473
  }
1350
1474
  // 실선은 "코드나 스펙으로 확인했다"는 주장이라 근거 없이 내면 그림 전체를 믿을 수 없게 된다.
1351
1475
  // 그래서 미해결로 조용히 돌리지 않고 거부한다. 근거 없는 점선 엣지만 (e)에서 미해결로 간다.
@@ -1478,36 +1602,38 @@ export function validateArchitectureIr(ir, opts = {}) {
1478
1602
  const projectionResult = ir.projections !== undefined
1479
1603
  ? settleProjections(ir.projections, new Map(ir.edges.map((e) => [e.id, e])), drawableNodeIds, nameById, ask, drawnFlows)
1480
1604
  : undefined;
1481
- return {
1482
- ok: true,
1483
- value: {
1484
- ir: {
1485
- ...ir,
1486
- edges,
1487
- ...(ir.flows !== undefined ? { flows: flowResult.flows } : {}),
1488
- ...(projectionResult !== undefined ? { projections: projectionResult.projections } : {}),
1489
- },
1490
- drawableNodeIds,
1491
- drawableEdgeIds,
1492
- drawableStepIds: flowResult.steps,
1493
- drawableTransitionIds: flowResult.transitions,
1494
- ...(projectionResult !== undefined
1495
- ? {
1496
- drawableMessageIds: projectionResult.messages,
1497
- drawableProjectionIds: projectionResult.drawable,
1498
- }
1499
- : {}),
1500
- autoUnresolved,
1501
- warnings: [
1502
- ...excerptWarnings,
1503
- ...descriptionWarnings(ir.nodes, drawableNodeIds),
1504
- ...infraPlacementWarnings(ir.nodes),
1505
- ...(projectionResult !== undefined
1506
- ? budgetWarnings(projectionResult.projections, projectionResult.drawable, drawnFlows)
1507
- : []),
1508
- ],
1605
+ const value = {
1606
+ ir: {
1607
+ ...ir,
1608
+ edges,
1609
+ ...(ir.flows !== undefined ? { flows: flowResult.flows } : {}),
1610
+ ...(projectionResult !== undefined ? { projections: projectionResult.projections } : {}),
1509
1611
  },
1612
+ drawableNodeIds,
1613
+ drawableEdgeIds,
1614
+ drawableStepIds: flowResult.steps,
1615
+ drawableTransitionIds: flowResult.transitions,
1616
+ ...(projectionResult !== undefined
1617
+ ? {
1618
+ drawableMessageIds: projectionResult.messages,
1619
+ drawableProjectionIds: projectionResult.drawable,
1620
+ }
1621
+ : {}),
1622
+ autoUnresolved,
1623
+ warnings: [
1624
+ ...excerptWarnings,
1625
+ ...descriptionWarnings(ir.nodes, drawableNodeIds),
1626
+ ...infraPlacementWarnings(ir.nodes),
1627
+ ...(projectionResult !== undefined
1628
+ ? budgetWarnings(projectionResult.projections, projectionResult.drawable, drawnFlows)
1629
+ : []),
1630
+ ...nodeTitleWarnings(ir.nodes, drawableNodeIds),
1631
+ ...flowStepDescriptionWarnings(flowResult.flows, drawnFlows.drawn, flowResult.steps),
1632
+ ],
1510
1633
  };
1634
+ // 레벨 판정은 그릴 노드가 정해진 뒤라야 해서 마지막에 붙인다
1635
+ value.warnings.push(...levelSummaryWarnings(value));
1636
+ return { ok: true, value };
1511
1637
  }
1512
1638
  // 노드마다 한 건씩 내면 큰 그림에서 응답이 그만큼 불어나 코드 하나에 묶는다
1513
1639
  function descriptionWarnings(nodes, drawableNodeIds) {
@@ -1525,6 +1651,150 @@ function descriptionWarnings(nodes, drawableNodeIds) {
1525
1651
  },
1526
1652
  ];
1527
1653
  }
1654
+ const HANGUL_RE = /[\uac00-\ud7a3]/;
1655
+ const PATH_EXTENSIONS = new Set([
1656
+ 'ts',
1657
+ 'tsx',
1658
+ 'js',
1659
+ 'jsx',
1660
+ 'mjs',
1661
+ 'cjs',
1662
+ 'json',
1663
+ 'jsonl',
1664
+ 'md',
1665
+ 'mdx',
1666
+ 'yml',
1667
+ 'yaml',
1668
+ 'toml',
1669
+ 'py',
1670
+ 'go',
1671
+ 'rs',
1672
+ 'java',
1673
+ 'kt',
1674
+ 'swift',
1675
+ 'rb',
1676
+ 'php',
1677
+ 'sh',
1678
+ 'sql',
1679
+ 'db',
1680
+ 'html',
1681
+ 'css',
1682
+ 'scss',
1683
+ 'vue',
1684
+ 'svelte',
1685
+ 'txt',
1686
+ 'env',
1687
+ 'lock',
1688
+ 'xml',
1689
+ 'proto',
1690
+ ]);
1691
+ // 콜론 뒤에 슬래시 없이 경로가 바로 붙는 scheme. kafka:orders나 redis:cache 같은 카드 이름과 가르려고 아는 것만 둔다
1692
+ const BARE_PATH_SCHEME_RE = /^(?:sqlite|file|classpath|jdbc|s3|gs):\S+$/i;
1693
+ /** 공백과 한글이 없고 슬래시가 있거나 파일 확장자로 끝나거나 아는 scheme:경로 꼴이면 경로로 본다 */
1694
+ export function isPathlikeTitle(title) {
1695
+ const t = title.trim();
1696
+ if (t === '' || /\s/.test(t) || HANGUL_RE.test(t))
1697
+ return false;
1698
+ if (/[\\/]/.test(t))
1699
+ return true;
1700
+ if (BARE_PATH_SCHEME_RE.test(t))
1701
+ return true;
1702
+ const ext = /\.([A-Za-z0-9]+)$/.exec(t);
1703
+ if (ext === null || !PATH_EXTENSIONS.has(ext[1].toLowerCase()))
1704
+ return false;
1705
+ // Next.js, Node.js처럼 대문자로 시작하는 프레임워크 이름은 파일이 아니다
1706
+ return !/^[A-Z][A-Za-z]*\.js$/.test(t);
1707
+ }
1708
+ function sortedIds(ids) {
1709
+ return ids.sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));
1710
+ }
1711
+ // 노드마다 한 건씩 내면 응답이 불어나 코드마다 한 건으로 묶는다
1712
+ function nodeTitleWarnings(nodes, drawableNodeIds) {
1713
+ const drawn = nodes.filter((n) => drawableNodeIds.has(n.id));
1714
+ const out = [];
1715
+ const pathlike = sortedIds(drawn
1716
+ .filter((n) => n.kind !== 'endpoint' && isPathlikeTitle(n.displayName ?? n.label))
1717
+ .map((n) => n.id));
1718
+ if (pathlike.length > 0) {
1719
+ out.push({
1720
+ code: 'NODE_TITLE_PATHLIKE',
1721
+ message: `카드 제목이 경로나 파일 이름인 노드 ${pathlike.length}개는 무엇인지 안 읽힌다. 하는 일을 담은 displayName을 단다.`,
1722
+ nodeIds: pathlike,
1723
+ });
1724
+ }
1725
+ const described = drawn.filter((n) => hasCardDescription(n.description));
1726
+ const korean = described.filter((n) => HANGUL_RE.test(n.description)).length;
1727
+ // 설명 글이 한글 쪽으로 기울어야 사용자 언어를 한국어로 본다
1728
+ if (described.length > 0 && korean * 2 > described.length) {
1729
+ const foreign = sortedIds(drawn
1730
+ .filter((n) => n.displayName !== undefined &&
1731
+ n.displayName.trim() !== '' &&
1732
+ !HANGUL_RE.test(n.displayName))
1733
+ .map((n) => n.id));
1734
+ if (foreign.length > 0) {
1735
+ out.push({
1736
+ code: 'DISPLAY_NAME_LANGUAGE',
1737
+ message: `설명 글은 한글인데 displayName에 한글이 없는 노드 ${foreign.length}개가 있다. 사용자 언어로 옮겨 쓰고 옮기면 안 되는 고유명사면 그대로 둔다.`,
1738
+ nodeIds: foreign,
1739
+ });
1740
+ }
1741
+ }
1742
+ return out;
1743
+ }
1744
+ function flowStepDescriptionWarnings(flows, drawnFlowIds, drawableStepIds) {
1745
+ const out = [];
1746
+ for (const flow of [...flows].sort((a, b) => (a.id < b.id ? -1 : a.id > b.id ? 1 : 0))) {
1747
+ if (!drawnFlowIds.has(flow.id))
1748
+ continue;
1749
+ const missing = flow.steps
1750
+ .filter((st) => drawableStepIds.has(st.id) && !hasCardDescription(st.description))
1751
+ .map((st) => st.id);
1752
+ if (missing.length === 0)
1753
+ continue;
1754
+ out.push({
1755
+ code: 'FLOW_STEP_DESCRIPTION_MISSING',
1756
+ message: `"${flow.title}" 흐름의 단계 ${missing.length}개에 description이 없어 단계 서랍에 거기서 하는 일이 안 나온다. 단계마다 한 문장을 단다.`,
1757
+ flowId: flow.id,
1758
+ stepIds: missing,
1759
+ });
1760
+ }
1761
+ return out;
1762
+ }
1763
+ function levelSummaryWarnings(validated) {
1764
+ if (!shouldDrillDown(validated))
1765
+ return [];
1766
+ const nodeById = new Map(validated.ir.nodes.map((n) => [n.id, n]));
1767
+ const levelIds = [];
1768
+ const nodeIds = [];
1769
+ for (const level of drillLevelOwners(validated)) {
1770
+ let text;
1771
+ if (level.kind === 'root') {
1772
+ text = validated.ir.summary;
1773
+ }
1774
+ else {
1775
+ const owner = level.ownerId !== undefined ? nodeById.get(level.ownerId) : undefined;
1776
+ // 여는 노드가 IR에 없는 레벨(질문별 그림 같은)은 채울 자리가 없어 묻지 않는다
1777
+ if (owner === undefined)
1778
+ continue;
1779
+ text = owner.summary;
1780
+ }
1781
+ if (hasCardDescription(text))
1782
+ continue;
1783
+ levelIds.push(level.levelId);
1784
+ if (level.ownerId !== undefined)
1785
+ nodeIds.push(level.ownerId);
1786
+ }
1787
+ if (levelIds.length === 0)
1788
+ return [];
1789
+ return [
1790
+ {
1791
+ code: 'LEVEL_SUMMARY_MISSING',
1792
+ message: `요약이 없는 레벨 ${levelIds.length}개는 들어갔을 때 무엇을 보는 화면인지 안 나온다. root는 IR 최상위 summary, 나머지는 nodeIds 노드의 summary를 1~2문장으로 채운다.`,
1793
+ levelIds,
1794
+ nodeIds: [...new Set(nodeIds)],
1795
+ },
1796
+ ];
1797
+ }
1528
1798
  function mapEvidence(ir, fn) {
1529
1799
  const mapNode = (n) => ({
1530
1800
  ...n,
@@ -1684,6 +1954,7 @@ function maskNodeText(node) {
1684
1954
  label: mask(node.label),
1685
1955
  ...(node.displayName !== undefined ? { displayName: mask(node.displayName) } : {}),
1686
1956
  ...(node.description !== undefined ? { description: mask(node.description) } : {}),
1957
+ ...(node.summary !== undefined ? { summary: mask(node.summary) } : {}),
1687
1958
  ...(node.region !== undefined ? { region: mask(node.region) } : {}),
1688
1959
  ...(doc !== undefined ? { doc: maskDocInfo(doc) } : {}),
1689
1960
  ...(node.columns !== undefined
@@ -1712,7 +1983,7 @@ function maskNodeText(node) {
1712
1983
  }
1713
1984
  /**
1714
1985
  * 공유용 사본. 입력은 바꾸지 않는다.
1715
- * private 근거는 type과 visibility만 남긴다. live 근거는 public이어도 명령과 리소스 식별자에 계정 ID나
1986
+ * private 근거는 type과 visibility만 남긴다. 계정 ID를 가린 뒤 남은 글자 칸의 비밀값도 가린다. live 근거는 public이어도 명령과 리소스 식별자에 계정 ID나
1716
1987
  * 리소스 ID가 담기므로 조회 시각만 남긴다. 노드 이름과 질문 글자의 계정 ID 꼴 숫자도 가린다
1717
1988
  */
1718
1989
  export function redactForSharing(ir) {
@@ -1728,7 +1999,7 @@ export function redactForSharing(ir) {
1728
1999
  ? { type: ev.type, visibility: ev.visibility }
1729
2000
  : { ...ev };
1730
2001
  });
1731
- return {
2002
+ return maskIrSecrets({
1732
2003
  ...redacted,
1733
2004
  nodes: redacted.nodes.map(maskNodeText),
1734
2005
  edges: redacted.edges.map(maskDocLink),
@@ -1743,7 +2014,9 @@ export function redactForSharing(ir) {
1743
2014
  ? { groups: redacted.groups.map((g) => ({ ...g, name: maskSharedText(g.name) })) }
1744
2015
  : {}),
1745
2016
  unresolved: redacted.unresolved.map(maskSharedQuestion),
1746
- };
2017
+ ...(redacted.summary !== undefined ? { summary: maskSharedText(redacted.summary) } : {}),
2018
+ ...(redacted.note !== undefined ? { note: maskSharedText(redacted.note) } : {}),
2019
+ }).ir;
1747
2020
  }
1748
2021
  /** 공유본의 질문. 저장된 질문과 그릴 때 만든 자동 질문이 같은 규칙으로 가려지게 한 곳에 둔다 */
1749
2022
  export function maskSharedQuestion(q) {