@tienne/gestalt 0.160.1 → 0.162.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.
- package/README.md +1 -1
- package/dist/package.json +1 -1
- package/dist/plugin/.codex-plugin/plugin.json +1 -1
- package/dist/plugin/role-agents/lens-reader/AGENT.md +73 -11
- package/dist/plugin/skills/_shared/conductor-plan.md +32 -0
- package/dist/plugin/skills/_shared/proactive-routing.md +1 -1
- package/dist/plugin/skills/conductor/SKILL.md +9 -2
- package/dist/plugin/skills/execute/SKILL.md +18 -2
- package/dist/plugin/skills/interview/SKILL.md +8 -2
- package/dist/plugin/skills/lens/SKILL.md +12 -9
- package/dist/plugin/skills/spec/SKILL.md +19 -3
- package/dist/src/agent-sync/run-store.d.ts +4 -4
- package/dist/src/cli/commands/conductor-approval.d.ts +32 -0
- package/dist/src/cli/commands/conductor-approval.d.ts.map +1 -0
- package/dist/src/cli/commands/conductor-approval.js +207 -0
- package/dist/src/cli/commands/conductor-approval.js.map +1 -0
- package/dist/src/cli/commands/conductor-plan.d.ts +10 -0
- package/dist/src/cli/commands/conductor-plan.d.ts.map +1 -0
- package/dist/src/cli/commands/conductor-plan.js +301 -0
- package/dist/src/cli/commands/conductor-plan.js.map +1 -0
- package/dist/src/cli/commands/conductor.d.ts +116 -0
- package/dist/src/cli/commands/conductor.d.ts.map +1 -1
- package/dist/src/cli/commands/conductor.js +697 -72
- package/dist/src/cli/commands/conductor.js.map +1 -1
- package/dist/src/cli/index.d.ts.map +1 -1
- package/dist/src/cli/index.js +104 -12
- package/dist/src/cli/index.js.map +1 -1
- package/dist/src/conductor/activity-tick.d.ts +2 -1
- package/dist/src/conductor/activity-tick.d.ts.map +1 -1
- package/dist/src/conductor/activity-tick.js +19 -10
- package/dist/src/conductor/activity-tick.js.map +1 -1
- package/dist/src/conductor/adapters.d.ts.map +1 -1
- package/dist/src/conductor/adapters.js +13 -8
- package/dist/src/conductor/adapters.js.map +1 -1
- package/dist/src/conductor/approval-overlap.d.ts +13 -0
- package/dist/src/conductor/approval-overlap.d.ts.map +1 -0
- package/dist/src/conductor/approval-overlap.js +53 -0
- package/dist/src/conductor/approval-overlap.js.map +1 -0
- package/dist/src/conductor/approval-server.d.ts +69 -0
- package/dist/src/conductor/approval-server.d.ts.map +1 -0
- package/dist/src/conductor/approval-server.js +279 -0
- package/dist/src/conductor/approval-server.js.map +1 -0
- package/dist/src/conductor/archive.d.ts.map +1 -1
- package/dist/src/conductor/archive.js +8 -6
- package/dist/src/conductor/archive.js.map +1 -1
- package/dist/src/conductor/bot-approval.d.ts +82 -1
- package/dist/src/conductor/bot-approval.d.ts.map +1 -1
- package/dist/src/conductor/bot-approval.js +362 -24
- package/dist/src/conductor/bot-approval.js.map +1 -1
- package/dist/src/conductor/bot-handoff-coordination.d.ts +24 -0
- package/dist/src/conductor/bot-handoff-coordination.d.ts.map +1 -0
- package/dist/src/conductor/bot-handoff-coordination.js +98 -0
- package/dist/src/conductor/bot-handoff-coordination.js.map +1 -0
- package/dist/src/conductor/bot-handoff-edit.d.ts +21 -0
- package/dist/src/conductor/bot-handoff-edit.d.ts.map +1 -0
- package/dist/src/conductor/bot-handoff-edit.js +141 -0
- package/dist/src/conductor/bot-handoff-edit.js.map +1 -0
- package/dist/src/conductor/bot-handoff-record.d.ts +20 -0
- package/dist/src/conductor/bot-handoff-record.d.ts.map +1 -0
- package/dist/src/conductor/bot-handoff-record.js +21 -0
- package/dist/src/conductor/bot-handoff-record.js.map +1 -0
- package/dist/src/conductor/bot-handoff.d.ts +45 -0
- package/dist/src/conductor/bot-handoff.d.ts.map +1 -0
- package/dist/src/conductor/bot-handoff.js +430 -0
- package/dist/src/conductor/bot-handoff.js.map +1 -0
- package/dist/src/conductor/bot-owner.d.ts +8 -3
- package/dist/src/conductor/bot-owner.d.ts.map +1 -1
- package/dist/src/conductor/bot-owner.js +23 -5
- package/dist/src/conductor/bot-owner.js.map +1 -1
- package/dist/src/conductor/deployment-evidence.d.ts +21 -0
- package/dist/src/conductor/deployment-evidence.d.ts.map +1 -0
- package/dist/src/conductor/deployment-evidence.js +133 -0
- package/dist/src/conductor/deployment-evidence.js.map +1 -0
- package/dist/src/conductor/engine.d.ts +12 -2
- package/dist/src/conductor/engine.d.ts.map +1 -1
- package/dist/src/conductor/engine.js +267 -47
- package/dist/src/conductor/engine.js.map +1 -1
- package/dist/src/conductor/gate-completion.d.ts +12 -0
- package/dist/src/conductor/gate-completion.d.ts.map +1 -0
- package/dist/src/conductor/gate-completion.js +111 -0
- package/dist/src/conductor/gate-completion.js.map +1 -0
- package/dist/src/conductor/gates.d.ts +5 -1
- package/dist/src/conductor/gates.d.ts.map +1 -1
- package/dist/src/conductor/gates.js +26 -23
- package/dist/src/conductor/gates.js.map +1 -1
- package/dist/src/conductor/input-error.d.ts +7 -0
- package/dist/src/conductor/input-error.d.ts.map +1 -0
- package/dist/src/conductor/input-error.js +7 -0
- package/dist/src/conductor/input-error.js.map +1 -0
- package/dist/src/conductor/intake.d.ts +2 -0
- package/dist/src/conductor/intake.d.ts.map +1 -1
- package/dist/src/conductor/intake.js +23 -8
- package/dist/src/conductor/intake.js.map +1 -1
- package/dist/src/conductor/launcher.d.ts +20 -2
- package/dist/src/conductor/launcher.d.ts.map +1 -1
- package/dist/src/conductor/launcher.js +35 -7
- package/dist/src/conductor/launcher.js.map +1 -1
- package/dist/src/conductor/monitor.d.ts +18 -0
- package/dist/src/conductor/monitor.d.ts.map +1 -0
- package/dist/src/conductor/monitor.js +110 -0
- package/dist/src/conductor/monitor.js.map +1 -0
- package/dist/src/conductor/orca-approval-attestation.d.ts +91 -0
- package/dist/src/conductor/orca-approval-attestation.d.ts.map +1 -0
- package/dist/src/conductor/orca-approval-attestation.js +85 -0
- package/dist/src/conductor/orca-approval-attestation.js.map +1 -0
- package/dist/src/conductor/orca-automation.d.ts +17 -0
- package/dist/src/conductor/orca-automation.d.ts.map +1 -0
- package/dist/src/conductor/orca-automation.js +87 -0
- package/dist/src/conductor/orca-automation.js.map +1 -0
- package/dist/src/conductor/orca-item-approval.d.ts +55 -0
- package/dist/src/conductor/orca-item-approval.d.ts.map +1 -0
- package/dist/src/conductor/orca-item-approval.js +155 -0
- package/dist/src/conductor/orca-item-approval.js.map +1 -0
- package/dist/src/conductor/pr-watch.d.ts +6 -0
- package/dist/src/conductor/pr-watch.d.ts.map +1 -1
- package/dist/src/conductor/pr-watch.js +69 -1
- package/dist/src/conductor/pr-watch.js.map +1 -1
- package/dist/src/conductor/prepared-plan.d.ts +488 -0
- package/dist/src/conductor/prepared-plan.d.ts.map +1 -0
- package/dist/src/conductor/prepared-plan.js +51 -0
- package/dist/src/conductor/prepared-plan.js.map +1 -0
- package/dist/src/conductor/slack-state.d.ts +21 -0
- package/dist/src/conductor/slack-state.d.ts.map +1 -0
- package/dist/src/conductor/slack-state.js +151 -0
- package/dist/src/conductor/slack-state.js.map +1 -0
- package/dist/src/conductor/slack.d.ts +35 -5
- package/dist/src/conductor/slack.d.ts.map +1 -1
- package/dist/src/conductor/slack.js +153 -25
- package/dist/src/conductor/slack.js.map +1 -1
- package/dist/src/conductor/store.d.ts +11 -5
- package/dist/src/conductor/store.d.ts.map +1 -1
- package/dist/src/conductor/store.js +225 -16
- package/dist/src/conductor/store.js.map +1 -1
- package/dist/src/conductor/successful-tick.d.ts +8 -0
- package/dist/src/conductor/successful-tick.d.ts.map +1 -0
- package/dist/src/conductor/successful-tick.js +33 -0
- package/dist/src/conductor/successful-tick.js.map +1 -0
- package/dist/src/conductor/types.d.ts +119 -1
- package/dist/src/conductor/types.d.ts.map +1 -1
- package/dist/src/conductor/types.js.map +1 -1
- package/dist/src/conductor/webauthn-approval.d.ts +81 -0
- package/dist/src/conductor/webauthn-approval.d.ts.map +1 -0
- package/dist/src/conductor/webauthn-approval.js +181 -0
- package/dist/src/conductor/webauthn-approval.js.map +1 -0
- package/dist/src/conductor/worker-completion.d.ts +11 -0
- package/dist/src/conductor/worker-completion.d.ts.map +1 -0
- package/dist/src/conductor/worker-completion.js +34 -0
- package/dist/src/conductor/worker-completion.js.map +1 -0
- package/dist/src/core/errors.d.ts +4 -0
- package/dist/src/core/errors.d.ts.map +1 -1
- package/dist/src/core/errors.js +8 -0
- package/dist/src/core/errors.js.map +1 -1
- package/dist/src/core/json-file.d.ts.map +1 -1
- package/dist/src/core/json-file.js +2 -0
- package/dist/src/core/json-file.js.map +1 -1
- package/dist/src/core/types.d.ts +7 -0
- package/dist/src/core/types.d.ts.map +1 -1
- package/dist/src/digest/blocks.d.ts +36 -36
- package/dist/src/digest/diagram-schema.d.ts +4 -4
- package/dist/src/digest/format.d.ts +2 -0
- package/dist/src/digest/format.d.ts.map +1 -1
- package/dist/src/digest/format.js +2 -0
- package/dist/src/digest/format.js.map +1 -1
- package/dist/src/digest/lens-source.d.ts +6 -6
- package/dist/src/digest/lens-steps.d.ts +179 -0
- package/dist/src/digest/lens-steps.d.ts.map +1 -0
- package/dist/src/digest/lens-steps.js +99 -0
- package/dist/src/digest/lens-steps.js.map +1 -0
- package/dist/src/digest/lens-widget-schema.d.ts +2225 -29
- package/dist/src/digest/lens-widget-schema.d.ts.map +1 -1
- package/dist/src/digest/lens-widget-schema.js +195 -6
- package/dist/src/digest/lens-widget-schema.js.map +1 -1
- package/dist/src/digest/lens-widgets.d.ts +25 -3
- package/dist/src/digest/lens-widgets.d.ts.map +1 -1
- package/dist/src/digest/lens-widgets.js +501 -43
- package/dist/src/digest/lens-widgets.js.map +1 -1
- package/dist/src/digest/lint-lens-context.d.ts +8 -8
- package/dist/src/digest/lint-lens.d.ts +11 -0
- package/dist/src/digest/lint-lens.d.ts.map +1 -1
- package/dist/src/digest/lint-lens.js +87 -1
- package/dist/src/digest/lint-lens.js.map +1 -1
- package/dist/src/digest/lint.d.ts.map +1 -1
- package/dist/src/digest/lint.js +21 -0
- package/dist/src/digest/lint.js.map +1 -1
- package/dist/src/digest/prd-schema.d.ts +66 -66
- package/dist/src/digest/prose.d.ts.map +1 -1
- package/dist/src/digest/prose.js +6 -0
- package/dist/src/digest/prose.js.map +1 -1
- package/dist/src/digest/render-blocks.d.ts +1 -0
- package/dist/src/digest/render-blocks.d.ts.map +1 -1
- package/dist/src/digest/render-blocks.js +1 -1
- package/dist/src/digest/render-blocks.js.map +1 -1
- package/dist/src/digest/render-html.d.ts.map +1 -1
- package/dist/src/digest/render-html.js +15 -5
- package/dist/src/digest/render-html.js.map +1 -1
- package/dist/src/digest/render-lens.d.ts +6 -2
- package/dist/src/digest/render-lens.d.ts.map +1 -1
- package/dist/src/digest/render-lens.js +19 -2
- package/dist/src/digest/render-lens.js.map +1 -1
- package/dist/src/digest/render-md.d.ts.map +1 -1
- package/dist/src/digest/render-md.js +23 -13
- package/dist/src/digest/render-md.js.map +1 -1
- package/dist/src/digest/render-widgets-flow.d.ts +42 -0
- package/dist/src/digest/render-widgets-flow.d.ts.map +1 -0
- package/dist/src/digest/render-widgets-flow.js +387 -0
- package/dist/src/digest/render-widgets-flow.js.map +1 -0
- package/dist/src/digest/render-widgets-graph.d.ts +27 -0
- package/dist/src/digest/render-widgets-graph.d.ts.map +1 -0
- package/dist/src/digest/render-widgets-graph.js +435 -0
- package/dist/src/digest/render-widgets-graph.js.map +1 -0
- package/dist/src/digest/render-widgets.d.ts +1 -1
- package/dist/src/digest/render-widgets.d.ts.map +1 -1
- package/dist/src/digest/render-widgets.js +59 -25
- package/dist/src/digest/render-widgets.js.map +1 -1
- package/dist/src/digest/reports.d.ts +4 -2
- package/dist/src/digest/reports.d.ts.map +1 -1
- package/dist/src/digest/reports.js +12 -4
- package/dist/src/digest/reports.js.map +1 -1
- package/dist/src/digest/schema.d.ts +37943 -15646
- package/dist/src/digest/schema.d.ts.map +1 -1
- package/dist/src/digest/schema.js +17 -3
- package/dist/src/digest/schema.js.map +1 -1
- package/dist/src/digest/viewer-js.d.ts.map +1 -1
- package/dist/src/digest/viewer-js.js +37 -1
- package/dist/src/digest/viewer-js.js.map +1 -1
- package/dist/src/events/types.d.ts +2 -0
- package/dist/src/events/types.d.ts.map +1 -1
- package/dist/src/events/types.js +2 -0
- package/dist/src/events/types.js.map +1 -1
- package/dist/src/execute/orchestrators/evaluation.d.ts.map +1 -1
- package/dist/src/execute/orchestrators/evaluation.js +4 -3
- package/dist/src/execute/orchestrators/evaluation.js.map +1 -1
- package/dist/src/execute/orchestrators/execution.d.ts.map +1 -1
- package/dist/src/execute/orchestrators/execution.js +4 -3
- package/dist/src/execute/orchestrators/execution.js.map +1 -1
- package/dist/src/execute/orchestrators/planning.d.ts +3 -1
- package/dist/src/execute/orchestrators/planning.d.ts.map +1 -1
- package/dist/src/execute/orchestrators/planning.js +19 -3
- package/dist/src/execute/orchestrators/planning.js.map +1 -1
- package/dist/src/execute/passthrough-engine.d.ts +3 -1
- package/dist/src/execute/passthrough-engine.d.ts.map +1 -1
- package/dist/src/execute/passthrough-engine.js +3 -0
- package/dist/src/execute/passthrough-engine.js.map +1 -1
- package/dist/src/execute/plan-destination.d.ts +16 -0
- package/dist/src/execute/plan-destination.d.ts.map +1 -0
- package/dist/src/execute/plan-destination.js +86 -0
- package/dist/src/execute/plan-destination.js.map +1 -0
- package/dist/src/execute/plan-schema.d.ts +335 -0
- package/dist/src/execute/plan-schema.d.ts.map +1 -0
- package/dist/src/execute/plan-schema.js +52 -0
- package/dist/src/execute/plan-schema.js.map +1 -0
- package/dist/src/execute/repository.d.ts.map +1 -1
- package/dist/src/execute/repository.js +16 -2
- package/dist/src/execute/repository.js.map +1 -1
- package/dist/src/execute/session.d.ts +6 -0
- package/dist/src/execute/session.d.ts.map +1 -1
- package/dist/src/execute/session.js +92 -1
- package/dist/src/execute/session.js.map +1 -1
- package/dist/src/harness-review/related-repos.d.ts +1 -0
- package/dist/src/harness-review/related-repos.d.ts.map +1 -1
- package/dist/src/harness-review/related-repos.js +4 -0
- package/dist/src/harness-review/related-repos.js.map +1 -1
- package/dist/src/mcp/schemas.d.ts +36 -20
- package/dist/src/mcp/schemas.d.ts.map +1 -1
- package/dist/src/mcp/schemas.js +10 -44
- package/dist/src/mcp/schemas.js.map +1 -1
- package/dist/src/mcp/server.d.ts.map +1 -1
- package/dist/src/mcp/server.js +6 -8
- package/dist/src/mcp/server.js.map +1 -1
- package/dist/src/mcp/tools/execute/evaluate.js +4 -4
- package/dist/src/mcp/tools/execute/evaluate.js.map +1 -1
- package/dist/src/mcp/tools/execute/execution.d.ts.map +1 -1
- package/dist/src/mcp/tools/execute/execution.js +5 -3
- package/dist/src/mcp/tools/execute/execution.js.map +1 -1
- package/dist/src/mcp/tools/execute/planning.d.ts +1 -0
- package/dist/src/mcp/tools/execute/planning.d.ts.map +1 -1
- package/dist/src/mcp/tools/execute/planning.js +117 -4
- package/dist/src/mcp/tools/execute/planning.js.map +1 -1
- package/dist/src/mcp/tools/execute/utility.js +4 -0
- package/dist/src/mcp/tools/execute/utility.js.map +1 -1
- package/dist/src/mcp/tools/execute/utils.d.ts +1 -0
- package/dist/src/mcp/tools/execute/utils.d.ts.map +1 -1
- package/dist/src/mcp/tools/execute/utils.js +6 -0
- package/dist/src/mcp/tools/execute/utils.js.map +1 -1
- package/dist/src/mcp/tools/execute-passthrough.d.ts.map +1 -1
- package/dist/src/mcp/tools/execute-passthrough.js +23 -7
- package/dist/src/mcp/tools/execute-passthrough.js.map +1 -1
- package/dist/src/mcp/tools/spec-passthrough.d.ts +2 -1
- package/dist/src/mcp/tools/spec-passthrough.d.ts.map +1 -1
- package/dist/src/mcp/tools/spec-passthrough.js +15 -1
- package/dist/src/mcp/tools/spec-passthrough.js.map +1 -1
- package/dist/src/mcp/tools/spec.d.ts +2 -1
- package/dist/src/mcp/tools/spec.d.ts.map +1 -1
- package/dist/src/mcp/tools/spec.js +15 -1
- package/dist/src/mcp/tools/spec.js.map +1 -1
- package/dist/src/research/schema.d.ts +26 -26
- package/dist/src/spec/generator.d.ts.map +1 -1
- package/dist/src/spec/generator.js +1 -0
- package/dist/src/spec/generator.js.map +1 -1
- package/dist/src/spec/passthrough-generator.d.ts.map +1 -1
- package/dist/src/spec/passthrough-generator.js +2 -0
- package/dist/src/spec/passthrough-generator.js.map +1 -1
- package/dist/src/spec/repository.d.ts +8 -0
- package/dist/src/spec/repository.d.ts.map +1 -0
- package/dist/src/spec/repository.js +37 -0
- package/dist/src/spec/repository.js.map +1 -0
- package/package.json +1 -1
- package/plugin/.codex-plugin/plugin.json +1 -1
- package/plugin/.mcp.json +1 -1
- package/plugin/commands/gestalt-execute.md +4 -0
- package/plugin/commands/gestalt-interview.md +3 -1
- package/plugin/commands/gestalt-spec.md +4 -0
- package/plugin/mcp.json +1 -1
- package/plugin/role-agents/lens-reader/AGENT.md +73 -11
- package/plugin/skills/_shared/conductor-plan.md +32 -0
- package/plugin/skills/_shared/proactive-routing.md +1 -1
- package/plugin/skills/conductor/SKILL.md +9 -2
- package/plugin/skills/execute/SKILL.md +18 -2
- package/plugin/skills/interview/SKILL.md +8 -2
- package/plugin/skills/lens/SKILL.md +12 -9
- package/plugin/skills/spec/SKILL.md +19 -3
|
@@ -1,16 +1,43 @@
|
|
|
1
1
|
import { cellNumber } from './lens-source.js';
|
|
2
|
-
import { numbersIn } from './lint-lens.js';
|
|
3
|
-
|
|
2
|
+
import { metricWords, numbersIn, sourceNumbersIn } from './lint-lens.js';
|
|
3
|
+
import { lintSteps } from './lens-steps.js';
|
|
4
|
+
/** 인터랙티브 그림 lint. 스키마와 A, B, C, D 구분은 lens-widget-schema.ts에 있다 */
|
|
4
5
|
const ALLOWED_KINDS = {
|
|
5
6
|
A: ['toggleBars', 'heatmap', 'beforeAfter'],
|
|
6
|
-
B: [
|
|
7
|
-
|
|
7
|
+
B: [
|
|
8
|
+
'stepSlider',
|
|
9
|
+
'beforeAfter',
|
|
10
|
+
'laneGraph',
|
|
11
|
+
'stepper',
|
|
12
|
+
'analogyMap',
|
|
13
|
+
'stateMachine',
|
|
14
|
+
'sequence',
|
|
15
|
+
'swimlane',
|
|
16
|
+
],
|
|
17
|
+
C: [
|
|
18
|
+
'stepSlider',
|
|
19
|
+
'toggleBars',
|
|
20
|
+
'heatmap',
|
|
21
|
+
'beforeAfter',
|
|
22
|
+
'laneGraph',
|
|
23
|
+
'calendar',
|
|
24
|
+
'stepper',
|
|
25
|
+
'stateMachine',
|
|
26
|
+
'sequence',
|
|
27
|
+
'swimlane',
|
|
28
|
+
],
|
|
29
|
+
// calendar는 값 칸이 없어 A로 대조할 숫자가 없다. 원문 표에서 온 일정은 D로 쓰고 기간마다 표 칸 출처를 단다
|
|
30
|
+
D: [
|
|
31
|
+
'stepSlider',
|
|
32
|
+
'beforeAfter',
|
|
33
|
+
'laneGraph',
|
|
34
|
+
'calendar',
|
|
35
|
+
'stepper',
|
|
36
|
+
'stateMachine',
|
|
37
|
+
'sequence',
|
|
38
|
+
'swimlane',
|
|
39
|
+
],
|
|
8
40
|
};
|
|
9
|
-
/**
|
|
10
|
-
* 결과로 읽히는 지표 말. B는 아예 못 쓰고 A와 C는 원문에 나온 말만 쓴다.
|
|
11
|
-
* 라벨 하나에 지표 말이 여럿 들 수 있어 g로 전부 본다. F1-score는 F1보다 먼저 둬야 통째로 잡힌다
|
|
12
|
-
*/
|
|
13
|
-
const METRIC = /(점수|정확도|정답률|일치도|성능|정밀도|재현율|오차|손실|F1-score|F-score|score|accuracy|precision|recall|\bF1\b|\bNMI\b|\bMSE\b|\bBLEU\b|\bAUC\b|loss)/gi;
|
|
14
41
|
/** 한국어 리포트가 영어 원문의 지표를 옮겨 쓴 경우를 받으려고 짝을 둔다. 어느 쪽이든 원문에 있으면 원문 지표다 */
|
|
15
42
|
const METRIC_ALIASES = {
|
|
16
43
|
점수: ['score'],
|
|
@@ -24,7 +51,6 @@ const METRIC_ALIASES = {
|
|
|
24
51
|
손실: ['loss'],
|
|
25
52
|
};
|
|
26
53
|
const escapeRe = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
27
|
-
const metricWords = (text) => [...text.matchAll(METRIC)].map((m) => m[0]);
|
|
28
54
|
/**
|
|
29
55
|
* 영숫자 경계로 감싸 대조한다(knowledge.ts의 노트 검색과 같은 꼴). \b는 한글 앞뒤를 경계로 못 잡는다.
|
|
30
56
|
* 영어 지표는 복수형(scores)까지 같은 말로 본다
|
|
@@ -58,7 +84,55 @@ export function widgetValues(w, wp) {
|
|
|
58
84
|
}
|
|
59
85
|
return out;
|
|
60
86
|
}
|
|
61
|
-
/**
|
|
87
|
+
/** 모델이 적은 공통 단계. stepSlider는 단계마다 노드를 통째로 적는 옛 꼴이라 빠진다 */
|
|
88
|
+
export function commonSteps(w) {
|
|
89
|
+
return w.kind === 'stepSlider' ||
|
|
90
|
+
w.kind === 'toggleBars' ||
|
|
91
|
+
w.kind === 'heatmap' ||
|
|
92
|
+
w.kind === 'beforeAfter' ||
|
|
93
|
+
w.kind === 'analogyMap'
|
|
94
|
+
? undefined
|
|
95
|
+
: w.steps;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* sequence가 화면에 보일 단계. 모델이 단계를 안 적었으면 메시지 하나를 한 단계로 만든다.
|
|
99
|
+
* 메시지를 하나씩 드러낼 뿐 새 내용을 지어내지 않아서 D 단계 출처와 C 장면 수 검사는 모델이 적은 단계만 받는다
|
|
100
|
+
*/
|
|
101
|
+
export function sequenceSteps(w) {
|
|
102
|
+
if (w.steps)
|
|
103
|
+
return w.steps;
|
|
104
|
+
if (w.messages.length < 2)
|
|
105
|
+
return undefined;
|
|
106
|
+
return w.messages.map((m, k) => ({
|
|
107
|
+
label: m.label,
|
|
108
|
+
...(m.cite ? { cite: m.cite } : {}),
|
|
109
|
+
...(k > 0 ? { show: [m.id] } : {}),
|
|
110
|
+
focus: [m.id],
|
|
111
|
+
}));
|
|
112
|
+
}
|
|
113
|
+
/** 공통 단계가 가리킬 수 있는 요소 id */
|
|
114
|
+
export function stepElementIds(w) {
|
|
115
|
+
if (w.kind === 'laneGraph')
|
|
116
|
+
return w.nodes.map((n) => n.id);
|
|
117
|
+
if (w.kind === 'calendar')
|
|
118
|
+
return w.spans.flatMap((sp) => (sp.id ? [sp.id] : []));
|
|
119
|
+
if (w.kind === 'stepper')
|
|
120
|
+
return w.items.map((it) => it.id);
|
|
121
|
+
if (w.kind === 'stateMachine') {
|
|
122
|
+
return [...w.states.map((s) => s.id), ...w.transitions.map((t) => t.id)];
|
|
123
|
+
}
|
|
124
|
+
if (w.kind === 'sequence') {
|
|
125
|
+
return [...w.actors.map((a) => a.id), ...w.messages.map((m) => m.id)];
|
|
126
|
+
}
|
|
127
|
+
if (w.kind === 'swimlane') {
|
|
128
|
+
return [
|
|
129
|
+
...w.activities.map((a) => a.id),
|
|
130
|
+
...(w.arrows ?? []).flatMap((ar) => (ar.id ? [ar.id] : [])),
|
|
131
|
+
];
|
|
132
|
+
}
|
|
133
|
+
return [];
|
|
134
|
+
}
|
|
135
|
+
const mark = (illustrative) => (illustrative ? { illustrative: true } : {});
|
|
62
136
|
export function widgetLabels(w, wp) {
|
|
63
137
|
const out = [];
|
|
64
138
|
if (w.kind === 'toggleBars') {
|
|
@@ -74,25 +148,123 @@ export function widgetLabels(w, wp) {
|
|
|
74
148
|
}
|
|
75
149
|
else if (w.kind === 'stepSlider') {
|
|
76
150
|
w.steps.forEach((s, k) => {
|
|
77
|
-
out.push({ text: s.label, path: `${wp}.steps.${k}.label
|
|
151
|
+
out.push({ text: s.label, path: `${wp}.steps.${k}.label`, step: k });
|
|
78
152
|
if (s.note)
|
|
79
|
-
out.push({ text: s.note, path: `${wp}.steps.${k}.note
|
|
80
|
-
s.nodes.forEach((n, j) => out.push({
|
|
153
|
+
out.push({ text: s.note, path: `${wp}.steps.${k}.note`, step: k });
|
|
154
|
+
s.nodes.forEach((n, j) => out.push({
|
|
155
|
+
text: n.label,
|
|
156
|
+
path: `${wp}.steps.${k}.nodes.${j}.label`,
|
|
157
|
+
step: k,
|
|
158
|
+
...mark(n.illustrative),
|
|
159
|
+
}));
|
|
81
160
|
});
|
|
82
161
|
}
|
|
83
|
-
else {
|
|
162
|
+
else if (w.kind === 'beforeAfter') {
|
|
84
163
|
for (const side of ['before', 'after']) {
|
|
85
164
|
out.push({ text: w[side].title, path: `${wp}.${side}.title` });
|
|
86
|
-
w[side].items.forEach((it, k) => out.push({
|
|
165
|
+
w[side].items.forEach((it, k) => out.push({
|
|
166
|
+
text: it.label,
|
|
167
|
+
path: `${wp}.${side}.items.${k}.label`,
|
|
168
|
+
...mark(it.illustrative),
|
|
169
|
+
}));
|
|
87
170
|
}
|
|
88
171
|
}
|
|
172
|
+
else if (w.kind === 'laneGraph') {
|
|
173
|
+
w.lanes.forEach((l, k) => out.push({ text: l.label, path: `${wp}.lanes.${k}.label` }));
|
|
174
|
+
w.nodes.forEach((n, k) => out.push({
|
|
175
|
+
text: n.label,
|
|
176
|
+
path: `${wp}.nodes.${k}.label`,
|
|
177
|
+
...(n.cite ? { cite: n.cite } : {}),
|
|
178
|
+
...mark(n.illustrative),
|
|
179
|
+
}));
|
|
180
|
+
}
|
|
181
|
+
else if (w.kind === 'calendar') {
|
|
182
|
+
w.columns.forEach((c, k) => out.push({ text: c, path: `${wp}.columns.${k}` }));
|
|
183
|
+
w.tracks.forEach((t, k) => out.push({ text: t.label, path: `${wp}.tracks.${k}.label` }));
|
|
184
|
+
w.spans.forEach((sp, k) => out.push({
|
|
185
|
+
text: sp.label,
|
|
186
|
+
path: `${wp}.spans.${k}.label`,
|
|
187
|
+
...(sp.cite ? { cite: sp.cite } : {}),
|
|
188
|
+
...mark(sp.illustrative),
|
|
189
|
+
}));
|
|
190
|
+
if (w.note)
|
|
191
|
+
out.push({ text: w.note, path: `${wp}.note` });
|
|
192
|
+
}
|
|
193
|
+
else if (w.kind === 'stepper') {
|
|
194
|
+
w.items.forEach((it, k) => {
|
|
195
|
+
const own = { ...(it.cite ? { cite: it.cite } : {}), ...mark(it.illustrative) };
|
|
196
|
+
out.push({ text: it.label, path: `${wp}.items.${k}.label`, ...own });
|
|
197
|
+
if (it.detail)
|
|
198
|
+
out.push({ text: it.detail, path: `${wp}.items.${k}.detail`, ...own });
|
|
199
|
+
});
|
|
200
|
+
w.loops?.forEach((l, k) => {
|
|
201
|
+
if (l.label)
|
|
202
|
+
out.push({ text: l.label, path: `${wp}.loops.${k}.label` });
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
else if (w.kind === 'stateMachine') {
|
|
206
|
+
w.states.forEach((st, k) => out.push({
|
|
207
|
+
text: st.label,
|
|
208
|
+
path: `${wp}.states.${k}.label`,
|
|
209
|
+
...(st.cite ? { cite: st.cite } : {}),
|
|
210
|
+
...mark(st.illustrative),
|
|
211
|
+
}));
|
|
212
|
+
w.transitions.forEach((t, k) => {
|
|
213
|
+
if (!t.label)
|
|
214
|
+
return;
|
|
215
|
+
out.push({
|
|
216
|
+
text: t.label,
|
|
217
|
+
path: `${wp}.transitions.${k}.label`,
|
|
218
|
+
...(t.cite ? { cite: t.cite } : {}),
|
|
219
|
+
...mark(t.illustrative),
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
else if (w.kind === 'sequence') {
|
|
224
|
+
w.actors.forEach((a, k) => out.push({ text: a.label, path: `${wp}.actors.${k}.label`, ...mark(a.illustrative) }));
|
|
225
|
+
w.messages.forEach((m, k) => out.push({
|
|
226
|
+
text: m.label,
|
|
227
|
+
path: `${wp}.messages.${k}.label`,
|
|
228
|
+
...(m.cite ? { cite: m.cite } : {}),
|
|
229
|
+
...mark(m.illustrative),
|
|
230
|
+
}));
|
|
231
|
+
}
|
|
232
|
+
else if (w.kind === 'swimlane') {
|
|
233
|
+
w.lanes.forEach((l, k) => out.push({ text: l.label, path: `${wp}.lanes.${k}.label` }));
|
|
234
|
+
w.activities.forEach((a, k) => out.push({
|
|
235
|
+
text: a.label,
|
|
236
|
+
path: `${wp}.activities.${k}.label`,
|
|
237
|
+
...(a.cite ? { cite: a.cite } : {}),
|
|
238
|
+
...mark(a.illustrative),
|
|
239
|
+
}));
|
|
240
|
+
w.arrows?.forEach((ar, k) => {
|
|
241
|
+
if (ar.label)
|
|
242
|
+
out.push({ text: ar.label, path: `${wp}.arrows.${k}.label` });
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
out.push({ text: w.domain, path: `${wp}.domain`, role: 'analog' });
|
|
247
|
+
w.rows.forEach((r, k) => {
|
|
248
|
+
out.push({ text: r.term, path: `${wp}.rows.${k}.term`, cite: r.termCite });
|
|
249
|
+
out.push({ text: r.analog, path: `${wp}.rows.${k}.analog`, role: 'analog' });
|
|
250
|
+
});
|
|
251
|
+
w.breaks.forEach((b, k) => out.push({ text: b, path: `${wp}.breaks.${k}`, role: 'break' }));
|
|
252
|
+
}
|
|
253
|
+
// 상태 칸 키는 단계끼리 맞춰야 해서 윤문에 넘기지 않는다. 값만 넘긴다
|
|
254
|
+
commonSteps(w)?.forEach((s, k) => {
|
|
255
|
+
out.push({ text: s.label, path: `${wp}.steps.${k}.label`, step: k });
|
|
256
|
+
if (s.note)
|
|
257
|
+
out.push({ text: s.note, path: `${wp}.steps.${k}.note`, step: k });
|
|
258
|
+
s.state?.forEach((kv, j) => out.push({ text: kv.value, path: `${wp}.steps.${k}.state.${j}.value`, step: k }));
|
|
259
|
+
});
|
|
89
260
|
return out;
|
|
90
261
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
* 본문 칸은 4자 이상이면 라벨 안에 들어 있어도 잡는다
|
|
94
|
-
*/
|
|
262
|
+
// 위젯마다 원문 표 전체를 다시 훑지 않게 원문 하나에 한 번만 만든다
|
|
263
|
+
const sourceNamesCache = new WeakMap();
|
|
95
264
|
function sourceNames(source) {
|
|
265
|
+
const cached = source && sourceNamesCache.get(source);
|
|
266
|
+
if (cached)
|
|
267
|
+
return cached;
|
|
96
268
|
const exact = new Set();
|
|
97
269
|
const contained = [];
|
|
98
270
|
for (const t of source?.tables ?? []) {
|
|
@@ -102,13 +274,303 @@ function sourceNames(source) {
|
|
|
102
274
|
if (c.length < 3 || cellNumber(cell) !== null)
|
|
103
275
|
continue;
|
|
104
276
|
exact.add(c);
|
|
105
|
-
if (r > 0 && c.length >= 4)
|
|
106
|
-
contained.push(
|
|
277
|
+
if (r > 0 && c.length >= 4)
|
|
278
|
+
contained.push(escapeRe(c));
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
const names = {
|
|
283
|
+
exact,
|
|
284
|
+
contained: contained.length
|
|
285
|
+
? new RegExp(`(?<![A-Za-z0-9])(?:${contained.join('|')})(?![A-Za-z0-9])`, 'i')
|
|
286
|
+
: null,
|
|
287
|
+
};
|
|
288
|
+
if (source)
|
|
289
|
+
sourceNamesCache.set(source, names);
|
|
290
|
+
return names;
|
|
291
|
+
}
|
|
292
|
+
/** B 그림과 D의 예시 요소 글자가 받는 검사. 원문 값이나 결과처럼 읽히는 글자를 막는다 */
|
|
293
|
+
function illustrativeChecks(l, err) {
|
|
294
|
+
// "1단계"처럼 순서를 적은 숫자도 원문 값처럼 읽혀서 처음, 다음, 끝으로 쓴다
|
|
295
|
+
if (numbersIn(l.text).length > 0) {
|
|
296
|
+
err(l.path, 'B_HAS_NUMBER', `"${l.text}"에 숫자가 있다. 설명용 그림이나 예시 요소는 값처럼 읽히는 숫자를 쓰지 않는다. 순서는 처음, 다음, 끝으로 쓴다`);
|
|
297
|
+
}
|
|
298
|
+
if (metricWords(l.text).length > 0 || l.text.includes('%')) {
|
|
299
|
+
err(l.path, 'B_METRIC_LABEL', `"${l.text}"는 결과 지표로 읽힌다. 설명용 그림이나 예시 요소에는 점수나 정확도, %를 쓰지 않는다`);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* D 그림에서 원문과 대조할 이름. 영문자가 든 토큰이고 release/20260728이나 force-push처럼 /, -, _, .로 이어진 건 통째로 본다.
|
|
304
|
+
* 한국어 설명 말은 대조하지 않는다
|
|
305
|
+
*/
|
|
306
|
+
function nameTokens(text) {
|
|
307
|
+
return [...text.matchAll(/[A-Za-z0-9]+(?:[-/_.][A-Za-z0-9]+)*/g)]
|
|
308
|
+
.map((m) => m[0])
|
|
309
|
+
.filter((t) => t.length >= 2 && /[A-Za-z]/.test(t));
|
|
310
|
+
}
|
|
311
|
+
let nameCacheText = null;
|
|
312
|
+
let nameCacheLower = '';
|
|
313
|
+
const nameCache = new Map();
|
|
314
|
+
/**
|
|
315
|
+
* 영문자로만 된 이름은 복수형까지 같은 이름으로 본다(commit과 commits, branch와 branches).
|
|
316
|
+
* 원문 글자가 바뀌기 전까지 같은 이름은 다시 찾지 않는다
|
|
317
|
+
*/
|
|
318
|
+
function nameInSource(name, allText) {
|
|
319
|
+
if (allText !== nameCacheText) {
|
|
320
|
+
nameCacheText = allText;
|
|
321
|
+
nameCacheLower = allText.toLowerCase();
|
|
322
|
+
nameCache.clear();
|
|
323
|
+
}
|
|
324
|
+
const key = name.toLowerCase();
|
|
325
|
+
const hit = nameCache.get(key);
|
|
326
|
+
if (hit !== undefined)
|
|
327
|
+
return hit;
|
|
328
|
+
let found;
|
|
329
|
+
if (/^[a-z]+$/.test(key)) {
|
|
330
|
+
const stems = new Set([key]);
|
|
331
|
+
for (const end of ['s', 'es']) {
|
|
332
|
+
if (key.endsWith(end) && key.length - end.length >= 3)
|
|
333
|
+
stems.add(key.slice(0, -end.length));
|
|
334
|
+
}
|
|
335
|
+
const alt = [...stems].map(escapeRe).join('|');
|
|
336
|
+
found = new RegExp(`(?<![a-z0-9])(?:${alt})(?:e?s)?(?![a-z0-9])`).test(nameCacheLower);
|
|
337
|
+
}
|
|
338
|
+
else {
|
|
339
|
+
found = false;
|
|
340
|
+
for (let at = nameCacheLower.indexOf(key); at !== -1; at = nameCacheLower.indexOf(key, at + 1)) {
|
|
341
|
+
const before = nameCacheLower[at - 1] ?? '';
|
|
342
|
+
const after = nameCacheLower[at + key.length] ?? '';
|
|
343
|
+
if (!/[a-z0-9]/.test(before) && !/[a-z0-9]/.test(after)) {
|
|
344
|
+
found = true;
|
|
345
|
+
break;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
nameCache.set(key, found);
|
|
350
|
+
return found;
|
|
351
|
+
}
|
|
352
|
+
/** 요소 출처의 원문 글자. 표 칸이면 표 번호와 머리줄, 그 칸이 든 줄이다(근거 숫자를 고를 때와 같은 범위) */
|
|
353
|
+
function refText(ref, ctx) {
|
|
354
|
+
if (!('table' in ref))
|
|
355
|
+
return ctx.unitText(ref);
|
|
356
|
+
const t = ctx.source?.tables.find((x) => x.id === ref.table);
|
|
357
|
+
if (!t)
|
|
358
|
+
return '';
|
|
359
|
+
return [t.number, ...(t.rows[0] ?? []), ...(t.rows[ref.row] ?? [])].join(' ');
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* 원문에서 온 글자의 이름과 숫자를 본다. 이름은 원문 어디에든 있으면 된다. 한 번 정의한 이름을 여러 문단에서 가리키기 때문이다.
|
|
363
|
+
* 숫자는 그림 출처 문단과 그 글자가 속한 단계, 요소의 출처 안에 있어야 한다
|
|
364
|
+
*/
|
|
365
|
+
function describedLabelChecks(labels, widgetCite, stepCites, ctx, err) {
|
|
366
|
+
const widgetNumbers = sourceNumbersIn(ctx.unitText(widgetCite));
|
|
367
|
+
for (const l of labels) {
|
|
368
|
+
for (const name of new Set(nameTokens(l.text))) {
|
|
369
|
+
if (nameInSource(name, ctx.allText))
|
|
370
|
+
continue;
|
|
371
|
+
err(l.path, 'D_NAME_UNKNOWN', `"${name}"가 원문에 없다. 원문 이름을 글자 그대로 쓴다. 원문에 없는 요소면 illustrative를 단다`);
|
|
372
|
+
}
|
|
373
|
+
const stepCite = l.step === undefined ? undefined : stepCites[l.step];
|
|
374
|
+
const allowed = new Set([
|
|
375
|
+
...widgetNumbers,
|
|
376
|
+
...(stepCite ? sourceNumbersIn(ctx.unitText(stepCite)) : []),
|
|
377
|
+
...(l.cite ? sourceNumbersIn(refText(l.cite, ctx)) : []),
|
|
378
|
+
]);
|
|
379
|
+
const unknown = [...new Set(numbersIn(l.text))].filter((n) => n !== 0 && !allowed.has(n));
|
|
380
|
+
if (unknown.length > 0) {
|
|
381
|
+
err(l.path, 'D_NUMBER_UNKNOWN', `숫자 ${unknown.join(', ')}이 그 단계나 요소, 그림의 출처에 없다. 원문 숫자만 그대로 쓴다`);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
/** D 그림 검사. 원문 그림이 있으면 C로 보내고 단계마다 출처를 받는다 */
|
|
386
|
+
function lintDescribed(w, wp, labels, ctx, err) {
|
|
387
|
+
if (w.figure) {
|
|
388
|
+
err(`${wp}.figure`, 'D_FIGURE_REF', '원문 그림을 다시 그리는 자리면 C로 만든다');
|
|
389
|
+
}
|
|
390
|
+
const steps = w.kind === 'stepSlider' ? w.steps : (commonSteps(w) ?? []);
|
|
391
|
+
const stepCites = steps.map((s) => s.cite);
|
|
392
|
+
stepCites.forEach((c, k) => {
|
|
393
|
+
if (!c) {
|
|
394
|
+
err(`${wp}.steps.${k}.cite`, 'D_STEP_NO_CITE', 'D 그림은 단계마다 그 단계가 옮긴 원문 문단(cite)을 단다');
|
|
395
|
+
}
|
|
396
|
+
});
|
|
397
|
+
// 상태 칸 키는 윤문에 안 넘겨서 labels에 없다. 이름 대조만 따로 한다
|
|
398
|
+
const keyLabels = (commonSteps(w)?.[0]?.state ?? []).map((kv, j) => ({
|
|
399
|
+
text: kv.key,
|
|
400
|
+
path: `${wp}.steps.0.state.${j}.key`,
|
|
401
|
+
step: 0,
|
|
402
|
+
}));
|
|
403
|
+
const plain = [...labels, ...keyLabels].filter((l) => !l.illustrative);
|
|
404
|
+
labels.filter((l) => l.illustrative).forEach((l) => illustrativeChecks(l, err));
|
|
405
|
+
describedLabelChecks(plain, w.cite, stepCites, ctx, err);
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* 비유 표 검사. 원문 말 칸은 D 규칙, 비유 칸은 B 규칙을 받는다. 비유 칸에는 원문 이름도 못 쓴다.
|
|
409
|
+
* 비유가 어디서 안 맞는지(breaks)를 한 줄 이상 적어야 비유를 믿고 틀리게 이해하는 걸 막는다
|
|
410
|
+
*/
|
|
411
|
+
function lintAnalogy(w, wp, labels, ctx, err) {
|
|
412
|
+
if (w.figure)
|
|
413
|
+
err(`${wp}.figure`, 'B_FIGURE_REF', '원문 그림을 다시 그리려면 C로 만든다');
|
|
414
|
+
if (!w.breaks.some((b) => b.trim())) {
|
|
415
|
+
err(`${wp}.breaks`, 'ANALOGY_BREAKS_EMPTY', '비유가 원문과 안 맞는 지점을 한 줄 이상 적는다. 모르면 비유를 믿고 틀리게 이해한다');
|
|
416
|
+
}
|
|
417
|
+
for (const l of labels.filter((x) => x.role === 'analog')) {
|
|
418
|
+
illustrativeChecks(l, err);
|
|
419
|
+
const borrowed = nameTokens(l.text).find((n) => nameInSource(n, ctx.allText));
|
|
420
|
+
if (borrowed) {
|
|
421
|
+
err(l.path, 'B_BORROWS_NAME', `"${borrowed}"는 원문에 있는 이름이다. 비유 칸에는 원문 이름을 쓰지 않는다`);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
// 안 맞는 곳은 원문 이름을 짚어야 해서 이름은 두고 원문 결과처럼 읽히는 숫자와 지표 말만 막는다
|
|
425
|
+
for (const l of labels.filter((x) => x.role === 'break'))
|
|
426
|
+
illustrativeChecks(l, err);
|
|
427
|
+
const sourceSide = labels.filter((x) => x.role === undefined);
|
|
428
|
+
describedLabelChecks(sourceSide, w.cite, [], ctx, err);
|
|
429
|
+
metricChecks(sourceSide, ctx, err);
|
|
430
|
+
}
|
|
431
|
+
/** 원문에서 온 글자의 지표 말은 원문에 나온 것만 쓴다 */
|
|
432
|
+
function metricChecks(labels, ctx, err) {
|
|
433
|
+
for (const l of labels) {
|
|
434
|
+
for (const word of new Set(metricWords(l.text))) {
|
|
435
|
+
if (metricInSource(word, ctx.allText))
|
|
436
|
+
continue;
|
|
437
|
+
err(l.path, 'WIDGET_METRIC_UNKNOWN', `"${word}"는 원문에 없는 지표다. 원문에 나온 지표 이름만 쓴다`);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
/** 새 종류의 모양 검사. 구분과 상관없이 본다 */
|
|
442
|
+
function lintShape(w, wp, ctx, err, issues) {
|
|
443
|
+
// 단계가 요소를 id 하나로 가리켜서 상태와 전이처럼 다른 목록끼리도 id가 겹치면 안 된다
|
|
444
|
+
const dupes = (ids, path, more = []) => {
|
|
445
|
+
const seen = new Set();
|
|
446
|
+
for (const [list, at] of [[ids, path], ...more]) {
|
|
447
|
+
list.forEach((id, k) => {
|
|
448
|
+
if (!id)
|
|
449
|
+
return;
|
|
450
|
+
if (seen.has(id))
|
|
451
|
+
err(`${at}.${k}.id`, 'WIDGET_ID_DUPLICATE', `id ${id}가 두 번 나온다`);
|
|
452
|
+
seen.add(id);
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
if (w.kind === 'laneGraph') {
|
|
457
|
+
dupes(w.lanes.map((l) => l.id), `${wp}.lanes`);
|
|
458
|
+
dupes(w.nodes.map((n) => n.id), `${wp}.nodes`);
|
|
459
|
+
const lanes = new Set(w.lanes.map((l) => l.id));
|
|
460
|
+
const order = new Map(w.nodes.map((n, k) => [n.id, k]));
|
|
461
|
+
w.nodes.forEach((n, k) => {
|
|
462
|
+
if (!lanes.has(n.lane)) {
|
|
463
|
+
err(`${wp}.nodes.${k}.lane`, 'LANE_UNKNOWN', `줄 ${n.lane}가 lanes에 없다`);
|
|
464
|
+
}
|
|
465
|
+
const refs = [...(n.parents ?? []), ...(n.copyOf ? [n.copyOf] : [])];
|
|
466
|
+
for (const ref of refs) {
|
|
467
|
+
const at = order.get(ref);
|
|
468
|
+
if (at === undefined) {
|
|
469
|
+
err(`${wp}.nodes.${k}`, 'LANE_PARENT_UNKNOWN', `${n.id}가 가리키는 ${ref}가 nodes에 없다`);
|
|
470
|
+
}
|
|
471
|
+
else if (at >= k) {
|
|
472
|
+
err(`${wp}.nodes.${k}`, 'LANE_PARENT_ORDER', `${n.id}가 가리키는 ${ref}가 자기보다 뒤에 있다. 가로 순서는 nodes 배열 순서다`);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
else if (w.kind === 'calendar') {
|
|
478
|
+
dupes(w.tracks.map((t) => t.id), `${wp}.tracks`);
|
|
479
|
+
// id 없는 칸을 빈 값으로 남겨야 겹친 칸의 경로가 spans 순번과 맞는다
|
|
480
|
+
dupes(w.spans.map((sp) => sp.id ?? ''), `${wp}.spans`);
|
|
481
|
+
const tracks = new Set(w.tracks.map((t) => t.id));
|
|
482
|
+
const last = w.columns.length - 1;
|
|
483
|
+
w.spans.forEach((sp, k) => {
|
|
484
|
+
const at = `${wp}.spans.${k}`;
|
|
485
|
+
if (!tracks.has(sp.track)) {
|
|
486
|
+
err(`${at}.track`, 'CALENDAR_TRACK_UNKNOWN', `트랙 ${sp.track}가 tracks에 없다`);
|
|
487
|
+
}
|
|
488
|
+
const ranged = sp.from !== undefined && sp.to !== undefined;
|
|
489
|
+
if (ranged === (sp.at !== undefined)) {
|
|
490
|
+
err(at, 'CALENDAR_SPAN_SHAPE', '기간은 from과 to, 한 칸짜리 사건은 at 하나만 쓴다');
|
|
491
|
+
}
|
|
492
|
+
else if (ranged ? sp.from > sp.to || sp.to > last : sp.at > last) {
|
|
493
|
+
err(at, 'CALENDAR_SPAN_OUT_OF_RANGE', `칸 번호가 columns(0~${last}) 밖이거나 from이 to보다 크다`);
|
|
494
|
+
}
|
|
495
|
+
if (sp.cite && 'table' in sp.cite) {
|
|
496
|
+
const ref = sp.cite;
|
|
497
|
+
const table = ctx.source?.tables.find((t) => t.id === ref.table);
|
|
498
|
+
if (!table) {
|
|
499
|
+
err(`${at}.cite`, 'TABLE_REF_UNKNOWN', `표 ${ref.table}가 source.json에 없다`);
|
|
500
|
+
}
|
|
501
|
+
else if (table.rows[ref.row]?.[ref.col] === undefined) {
|
|
502
|
+
err(`${at}.cite`, 'CELL_REF_OUT_OF_RANGE', `${ref.table}에 ${ref.row}행 ${ref.col}열이 없다`);
|
|
107
503
|
}
|
|
108
504
|
}
|
|
109
505
|
});
|
|
110
506
|
}
|
|
111
|
-
|
|
507
|
+
else if (w.kind === 'stepper') {
|
|
508
|
+
dupes(stepElementIds(w), `${wp}.items`);
|
|
509
|
+
const ids = new Set(stepElementIds(w));
|
|
510
|
+
w.loops?.forEach((l, k) => {
|
|
511
|
+
if (!ids.has(l.from) || !ids.has(l.to)) {
|
|
512
|
+
err(`${wp}.loops.${k}`, 'STEPPER_LOOP_UNKNOWN', `되돌아가는 화살표 ${l.from}→${l.to}의 카드가 items에 없다`);
|
|
513
|
+
}
|
|
514
|
+
});
|
|
515
|
+
}
|
|
516
|
+
else if (w.kind === 'stateMachine') {
|
|
517
|
+
dupes(w.states.map((st) => st.id), `${wp}.states`, [[w.transitions.map((t) => t.id), `${wp}.transitions`]]);
|
|
518
|
+
const states = new Set(w.states.map((st) => st.id));
|
|
519
|
+
w.transitions.forEach((t, k) => {
|
|
520
|
+
if (!states.has(t.from) || !states.has(t.to)) {
|
|
521
|
+
err(`${wp}.transitions.${k}`, 'STATE_TRANSITION_UNKNOWN', `전이 ${t.from}→${t.to}의 상태가 states에 없다`);
|
|
522
|
+
}
|
|
523
|
+
});
|
|
524
|
+
if (w.states.filter((st) => st.initial).length > 1) {
|
|
525
|
+
err(`${wp}.states`, 'STATE_INITIAL_MANY', '시작 상태(initial)는 하나만 둔다');
|
|
526
|
+
}
|
|
527
|
+
const taken = new Map();
|
|
528
|
+
w.states.forEach((st, k) => {
|
|
529
|
+
if (!st.pos)
|
|
530
|
+
return;
|
|
531
|
+
const key = `${st.pos.row}:${st.pos.col}`;
|
|
532
|
+
const other = taken.get(key);
|
|
533
|
+
if (other) {
|
|
534
|
+
err(`${wp}.states.${k}.pos`, 'STATE_POS_OVERLAP', `${st.id}와 ${other}가 같은 자리(${st.pos.row}행 ${st.pos.col}열)에 있다`);
|
|
535
|
+
}
|
|
536
|
+
taken.set(key, st.id);
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
else if (w.kind === 'sequence') {
|
|
540
|
+
dupes(w.actors.map((a) => a.id), `${wp}.actors`, [[w.messages.map((m) => m.id), `${wp}.messages`]]);
|
|
541
|
+
const actors = new Set(w.actors.map((a) => a.id));
|
|
542
|
+
w.messages.forEach((m, k) => {
|
|
543
|
+
if (!actors.has(m.from) || !actors.has(m.to)) {
|
|
544
|
+
err(`${wp}.messages.${k}`, 'SEQUENCE_ACTOR_UNKNOWN', `메시지 ${m.from}→${m.to}의 참여자가 actors에 없다`);
|
|
545
|
+
}
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
else if (w.kind === 'swimlane') {
|
|
549
|
+
dupes(w.lanes.map((l) => l.id), `${wp}.lanes`);
|
|
550
|
+
dupes(w.activities.map((a) => a.id), `${wp}.activities`, [[(w.arrows ?? []).map((ar) => ar.id ?? ''), `${wp}.arrows`]]);
|
|
551
|
+
const lanes = new Set(w.lanes.map((l) => l.id));
|
|
552
|
+
const acts = new Set(w.activities.map((a) => a.id));
|
|
553
|
+
const taken = new Map();
|
|
554
|
+
w.activities.forEach((a, k) => {
|
|
555
|
+
if (!lanes.has(a.lane)) {
|
|
556
|
+
err(`${wp}.activities.${k}.lane`, 'SWIMLANE_LANE_UNKNOWN', `줄 ${a.lane}가 lanes에 없다`);
|
|
557
|
+
}
|
|
558
|
+
const key = `${a.lane}:${a.col}`;
|
|
559
|
+
const other = taken.get(key);
|
|
560
|
+
if (other) {
|
|
561
|
+
err(`${wp}.activities.${k}.col`, 'SWIMLANE_CELL_TAKEN', `${a.id}와 ${other}가 같은 줄 같은 칸(${a.col})에 있다`);
|
|
562
|
+
}
|
|
563
|
+
taken.set(key, a.id);
|
|
564
|
+
});
|
|
565
|
+
w.arrows?.forEach((ar, k) => {
|
|
566
|
+
if (!acts.has(ar.from) || !acts.has(ar.to)) {
|
|
567
|
+
err(`${wp}.arrows.${k}`, 'SWIMLANE_ARROW_UNKNOWN', `화살표 ${ar.from}→${ar.to}의 활동이 activities에 없다`);
|
|
568
|
+
}
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
const steps = commonSteps(w);
|
|
572
|
+
if (steps)
|
|
573
|
+
lintSteps(steps, stepElementIds(w), `${wp}.steps`, issues);
|
|
112
574
|
}
|
|
113
575
|
/**
|
|
114
576
|
* 위젯 하나를 본다. 렌더러가 붙이는 배지는 스키마에 칸이 없어서 모델이 끄거나 글을 바꿀 수 없다.
|
|
@@ -130,6 +592,7 @@ export function lintWidget(w, wp, ctx, issues) {
|
|
|
130
592
|
});
|
|
131
593
|
});
|
|
132
594
|
}
|
|
595
|
+
lintShape(w, wp, ctx, err, issues);
|
|
133
596
|
if (w.kind === 'heatmap') {
|
|
134
597
|
const rowsOk = w.cells.length === w.y.labels.length;
|
|
135
598
|
const colsOk = w.cells.every((r) => r.length === w.x.labels.length);
|
|
@@ -141,6 +604,10 @@ export function lintWidget(w, wp, ctx, issues) {
|
|
|
141
604
|
const labels = [{ text: w.title, path: `${wp}.title` }, ...widgetLabels(w, wp)];
|
|
142
605
|
if (w.caption)
|
|
143
606
|
labels.push({ text: w.caption, path: `${wp}.caption` });
|
|
607
|
+
if (w.kind === 'analogyMap') {
|
|
608
|
+
lintAnalogy(w, wp, labels, ctx, err);
|
|
609
|
+
return;
|
|
610
|
+
}
|
|
144
611
|
if (w.class === 'B') {
|
|
145
612
|
if (values.length > 0) {
|
|
146
613
|
err(values[0].path, 'B_HAS_DATA', 'B 그림은 값을 쓰지 않는다. 원문 데이터를 빌리면 원문 결과처럼 읽힌다');
|
|
@@ -152,15 +619,9 @@ export function lintWidget(w, wp, ctx, issues) {
|
|
|
152
619
|
}
|
|
153
620
|
const names = sourceNames(ctx.source);
|
|
154
621
|
for (const l of labels) {
|
|
155
|
-
|
|
156
|
-
if (numbersIn(l.text).length > 0) {
|
|
157
|
-
err(l.path, 'B_HAS_NUMBER', `"${l.text}"에 숫자가 있다. B 그림은 값처럼 읽히는 숫자를 쓰지 않는다. 순서는 처음, 다음, 끝으로 쓴다`);
|
|
158
|
-
}
|
|
159
|
-
if (metricWords(l.text).length > 0 || l.text.includes('%')) {
|
|
160
|
-
err(l.path, 'B_METRIC_LABEL', `"${l.text}"는 결과 지표로 읽힌다. B 그림에는 점수나 정확도, %를 쓰지 않는다`);
|
|
161
|
-
}
|
|
622
|
+
illustrativeChecks(l, err);
|
|
162
623
|
const t = l.text.trim().toLowerCase();
|
|
163
|
-
if (names.exact.has(t) || names.contained
|
|
624
|
+
if (names.exact.has(t) || names.contained?.test(t)) {
|
|
164
625
|
err(l.path, 'B_BORROWS_NAME', `"${l.text}"는 원문 표에 있는 이름이다. B 그림은 원문 이름을 빌리지 않는다`);
|
|
165
626
|
}
|
|
166
627
|
}
|
|
@@ -191,18 +652,14 @@ export function lintWidget(w, wp, ctx, issues) {
|
|
|
191
652
|
err(path, 'WIDGET_VALUE_MISMATCH', `값 ${v.value}가 ${ref.table} ${ref.row}행 ${ref.col}열 "${cell}"과 다르다`);
|
|
192
653
|
}
|
|
193
654
|
}
|
|
194
|
-
else if (!
|
|
655
|
+
else if (!sourceNumbersIn(ctx.unitText(src.cite)).includes(Math.abs(v.value))) {
|
|
195
656
|
err(path, 'WIDGET_VALUE_MISMATCH', `값 ${v.value}가 출처 문단에 없다`);
|
|
196
657
|
}
|
|
197
658
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
continue;
|
|
203
|
-
err(l.path, 'WIDGET_METRIC_UNKNOWN', `"${word}"는 원문에 없는 지표다. 원문에 나온 지표 이름만 쓴다`);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
659
|
+
if (w.class === 'D')
|
|
660
|
+
lintDescribed(w, wp, labels, ctx, err);
|
|
661
|
+
// heatmap 축 라벨도 widgetLabels에 들어 있어 같이 본다. D의 예시 요소는 위에서 B 규칙으로 봤다
|
|
662
|
+
metricChecks(labels.filter((l) => !l.illustrative), ctx, err);
|
|
206
663
|
if (w.class === 'C') {
|
|
207
664
|
const fig = w.figure ? ctx.source?.figures.find((f) => f.id === w.figure) : undefined;
|
|
208
665
|
if (!w.figure)
|
|
@@ -212,12 +669,13 @@ export function lintWidget(w, wp, ctx, issues) {
|
|
|
212
669
|
if (!(w.differences ?? []).some((d) => d.trim())) {
|
|
213
670
|
err(`${wp}.differences`, 'C_DIFFERENCES_EMPTY', '원문 그림과 다르게 그린 점을 한 줄 이상 적는다. 무엇을 빼고 무엇을 단순하게 했는지, 원문 결과와 다르게 보이는 자리가 있는지다');
|
|
214
671
|
}
|
|
215
|
-
|
|
672
|
+
const stepCount = w.kind === 'stepSlider' ? w.steps.length : commonSteps(w)?.length;
|
|
673
|
+
if (fig && stepCount !== undefined) {
|
|
216
674
|
if (fig.panels === undefined) {
|
|
217
675
|
err(`${wp}.figure`, 'C_PANELS_UNKNOWN', `원문 그림 ${fig.id}의 장면 수를 모른다. 원문에서 잘라낸 그림을 보고 gestalt lens panels로 먼저 적는다`);
|
|
218
676
|
}
|
|
219
|
-
else if (
|
|
220
|
-
err(`${wp}.steps`, 'C_STEPS_EXCEED_PANELS', `원문 그림은 ${fig.panels}장면인데
|
|
677
|
+
else if (stepCount > fig.panels) {
|
|
678
|
+
err(`${wp}.steps`, 'C_STEPS_EXCEED_PANELS', `원문 그림은 ${fig.panels}장면인데 단계가 ${stepCount}칸이다. 원문에 없는 중간 단계를 만들지 않는다`);
|
|
221
679
|
}
|
|
222
680
|
}
|
|
223
681
|
}
|