@hiroshi.inoue/agent-spectrum-kernel 1.0.0 → 1.1.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.ja.md +160 -0
- package/README.md +11 -154
- package/dist/AGENTS.md +1 -1
- package/dist/CUSTOM_INSTRUCTIONS.md +3 -2
- package/dist/README.md +11 -154
- package/dist/adapters/claude-code/plugin/skills/handoff/SKILL.md +1 -1
- package/dist/adapters/claude-code/plugin/skills/implement/SKILL.md +1 -1
- package/dist/adapters/claude-code/plugin/skills/investigate/SKILL.md +1 -1
- package/dist/adapters/claude-code/plugin/skills/review-pr/SKILL.md +1 -1
- package/dist/adapters/claude-code/plugin/skills/verify/SKILL.md +1 -1
- package/dist/docs/README.md +1 -0
- package/dist/docs/architecture/README.md +54 -0
- package/dist/docs/architecture/model.json +318 -0
- package/dist/docs/architecture/views/skill-assets.md +109 -0
- package/dist/docs/fixtures/adapter-runtime-bundle.json +85 -69
- package/dist/docs/fixtures/adapter-runtime-evidence.json +4 -4
- package/dist/docs/fixtures/adapter-runtime-profiles.json +97 -61
- package/dist/docs/fixtures/verification-proof-policy-cases.json +1 -1
- package/dist/docs/npm-distribution-ja.md +8 -6
- package/dist/docs/npm-distribution.md +6 -7
- package/dist/docs/routing-model.md +15 -0
- package/dist/docs/skill-matrix.md +4 -0
- package/dist/docs/validation-report.md +36 -30
- package/dist/manifest.json +36 -1
- package/dist/npm-runtime-inventory.json +214 -119
- package/dist/package.json +2 -2
- package/dist/schemas/adoption-plan.schema.json +5 -1
- package/dist/schemas/architecture-model.schema.json +619 -0
- package/dist/scripts/ask-primary-runtime-lineage.mjs +2 -1
- package/dist/scripts/ask-setup-apply-state.mjs +2 -2
- package/dist/scripts/ask-setup-apply.mjs +3 -3
- package/dist/scripts/ask-setup.mjs +37 -18
- package/dist/scripts/codex-exec-runner.mjs +7 -2
- package/dist/scripts/install-claude-adapter.mjs +14 -1
- package/dist/scripts/install-codex-adapter.mjs +17 -1
- package/dist/scripts/install-kernel.mjs +8 -4
- package/dist/scripts/installer-lifecycle.mjs +41 -0
- package/dist/scripts/kernel-principles.mjs +4 -2
- package/dist/skills/adr-review/SKILL.md +1 -0
- package/dist/skills/application-boundary-architecture/SKILL.md +1 -0
- package/dist/skills/architecture-decision-memory/SKILL.md +1 -0
- package/dist/skills/architecture-modeling/SKILL.md +22 -0
- package/dist/skills/architecture-modeling/references/architecture-model.mjs +441 -0
- package/dist/skills/architecture-modeling/references/last-seat.json +37 -0
- package/dist/skills/architecture-modeling/references/model.md +42 -0
- package/dist/skills/architecture-modeling/references/views.md +18 -0
- package/dist/skills/architecture-modeling/references/views.mjs +370 -0
- package/dist/skills/code-visualization/SKILL.md +8 -4
- package/dist/skills/code-visualization/references/design-preview.mjs +74 -0
- package/dist/skills/code-visualization/references/examples/last-seat.json +42 -0
- package/dist/skills/code-visualization/references/guide-input.md +30 -0
- package/dist/skills/code-visualization/references/render-guide.mjs +53 -11
- package/dist/skills/code-visualization/references/structure-index.mjs +41 -0
- package/dist/skills/code-visualization/references/visual-player.js +34 -3
- package/dist/skills/code-visualization/references/visual-surface.css +3 -0
- package/dist/skills/controlled-implementation/SKILL.md +4 -0
- package/dist/skills/documentation-knowledge-compiler/SKILL.md +2 -1
- package/dist/skills/doubt-driven-development/SKILL.md +2 -0
- package/dist/skills/engineering-documentation-generation/SKILL.md +27 -0
- package/dist/skills/engineering-documentation-generation/references/diagram-selection.md +25 -0
- package/dist/skills/engineering-documentation-generation/references/document-types.md +16 -0
- package/dist/skills/engineering-documentation-generation/references/reservation.md +61 -0
- package/dist/skills/engineering-documentation-generation/references/update-and-check.md +24 -0
- package/dist/skills/grill-design/SKILL.md +6 -2
- package/dist/skills/grill-with-docs/SKILL.md +4 -2
- package/dist/skills/handoff-generation/SKILL.md +1 -0
- package/dist/skills/implementation-context-generation/SKILL.md +1 -0
- package/dist/skills/mr-readme-generation/SKILL.md +2 -0
- package/dist/skills/operating-mode-router/SKILL.md +1 -0
- package/dist/skills/project-adoption-pack-generation/SKILL.md +1 -0
- package/dist/skills/refactor-implementation/SKILL.md +1 -0
- package/dist/skills/repository-orientation/SKILL.md +2 -0
- package/dist/skills/requirement-grill/SKILL.md +2 -0
- package/dist/skills/review-architecture-impact/SKILL.md +2 -0
- package/dist/skills/review-context-generation/SKILL.md +1 -0
- package/dist/skills/review-domain-impact/SKILL.md +2 -0
- package/dist/skills/skill-router/SKILL.md +5 -1
- package/dist/skills/spec-driven-development/SKILL.md +4 -0
- package/dist/skills/spec-driven-development/references/examples/javascript/candidate-preview.mjs +44 -0
- package/dist/skills/spec-driven-development/references/examples/javascript/scenario-review.mjs +10 -1
- package/dist/skills/spec-driven-development/references/scenario-visual-review.md +16 -0
- package/dist/skills/spec-driven-development/references/spec-index.md +8 -0
- package/dist/skills/test-first-verification/SKILL.md +2 -0
- package/dist/skills/work-package-compiler/SKILL.md +2 -0
- package/package.json +2 -2
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
// All reader-facing projections share one set of claims and one set of gap rules.
|
|
2
|
+
const byId = (rows, id) => rows.find((row) => row.id === id);
|
|
3
|
+
const levels = { person: 'C1', system: 'C1', container: 'C2', component: 'C3' };
|
|
4
|
+
const established = (c) => ['Verified', 'Supported'].includes(c?.status);
|
|
5
|
+
|
|
6
|
+
// Bind the same placement or run only once across edges, results and comparisons.
|
|
7
|
+
export function deploymentEnvironments(model, extraComparison) {
|
|
8
|
+
const environments = new Map();
|
|
9
|
+
const edges = new Map(model.relationships.map((edge) => [edge.id, edge]));
|
|
10
|
+
const deployments = model.relationships.filter((edge) => edge.kind === 'deployment');
|
|
11
|
+
const unused = new Set(deployments.map((edge) => edge.id));
|
|
12
|
+
const scoped = new Set(deployments.map((edge) => edge.claim));
|
|
13
|
+
for (const claim of model.claims) if (claim.kind === 'observed-execution') scoped.add(claim.id);
|
|
14
|
+
const record = (id, environment) => {
|
|
15
|
+
if (!environment || !scoped.has(id)) return;
|
|
16
|
+
if (environments.has(id) && environments.get(id) !== environment)
|
|
17
|
+
throw new Error('Use separate deployment claims for different environments: ' + id);
|
|
18
|
+
environments.set(id, environment);
|
|
19
|
+
};
|
|
20
|
+
const scenarios = new Map();
|
|
21
|
+
for (const scenario of model.scenarios) {
|
|
22
|
+
const { environment } = scenario;
|
|
23
|
+
scenarios.set(scenario.id, environment);
|
|
24
|
+
record(scenario.claim, environment);
|
|
25
|
+
for (const id of scenario.path) {
|
|
26
|
+
const edge = edges.get(id);
|
|
27
|
+
if (edge?.kind === 'deployment') {
|
|
28
|
+
if (!environment) throw new Error('Missing deployment environment for ' + id);
|
|
29
|
+
unused.delete(id);
|
|
30
|
+
}
|
|
31
|
+
record(edge?.claim, environment);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (unused.size) throw new Error('Missing deployment environment for ' + [...unused].join(', '));
|
|
35
|
+
const comparisons = extraComparison ? [...model.comparisons, extraComparison] : model.comparisons;
|
|
36
|
+
for (const row of comparisons) {
|
|
37
|
+
const environment = scenarios.get(row.scenario);
|
|
38
|
+
for (const id of [row.actual, row.execution, row.intended, ...(row.proposed ?? [])]) record(id, environment);
|
|
39
|
+
}
|
|
40
|
+
return environments;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function differences(model, row) {
|
|
44
|
+
deploymentEnvironments(model, row);
|
|
45
|
+
return comparisonGaps(model, row);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function comparisonGaps(model, row) {
|
|
49
|
+
const [intent, actual, run] = [row.intended, row.actual, row.execution].map((id) => byId(model.claims, id));
|
|
50
|
+
const gaps = new Set(row.gap ? [row.gap] : []);
|
|
51
|
+
if (!established(intent)) gaps.add('unresolved-authority');
|
|
52
|
+
if (!established(actual) && row.gap !== 'missing-implementation') gaps.add('unknown');
|
|
53
|
+
if (established(intent)) {
|
|
54
|
+
for (const fact of [actual, run].filter(established)) {
|
|
55
|
+
if (intent.outcome && fact.outcome && fact.outcome !== intent.outcome) gaps.add('unexpected-behavior');
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (!established(run)) gaps.add('missing-verification');
|
|
59
|
+
return [...gaps];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const gapLabels = (ja) =>
|
|
63
|
+
ja
|
|
64
|
+
? {
|
|
65
|
+
'missing-implementation': '未実装',
|
|
66
|
+
'unexpected-behavior': '期待と異なる動作',
|
|
67
|
+
'outdated-model-or-doc': 'モデル・文書が古い',
|
|
68
|
+
'missing-verification': '実行による確認が不足',
|
|
69
|
+
'unresolved-authority': '判断の根拠が未確定',
|
|
70
|
+
unknown: '不明',
|
|
71
|
+
}
|
|
72
|
+
: {};
|
|
73
|
+
|
|
74
|
+
export function projectGuide(model, guide) {
|
|
75
|
+
deploymentEnvironments(model);
|
|
76
|
+
if (model.scopes.some((s) => s.snapshot?.mode !== 'commit'))
|
|
77
|
+
throw new Error('No worktree paths in a committed guide');
|
|
78
|
+
if (model.scopes.some((s) => s.snapshot.commit !== guide.revision))
|
|
79
|
+
throw new Error('Guide revision does not match source');
|
|
80
|
+
if (guide.githubRepository && model.repository !== 'github.com/' + guide.githubRepository.toLowerCase())
|
|
81
|
+
throw new Error('Guide repository does not match source');
|
|
82
|
+
const ja = guide.language === 'ja';
|
|
83
|
+
const labels = gapLabels(ja);
|
|
84
|
+
const describeIntent = (row) => {
|
|
85
|
+
const intent = byId(model.claims, row.intended);
|
|
86
|
+
if (!intent) return ja ? '未確定' : 'Unknown';
|
|
87
|
+
const ref = intent.sources.find((r) => r.spec_ref)?.spec_ref;
|
|
88
|
+
const item = ref ? [ref.artifact_id + '@' + ref.observed_revision + '#' + ref.item_id] : [];
|
|
89
|
+
return [intent.status, ...item, intent.summary].join(' · ');
|
|
90
|
+
};
|
|
91
|
+
const describeGap = (row) => {
|
|
92
|
+
const gaps = comparisonGaps(model, row).map((g) => labels[g] ?? g);
|
|
93
|
+
return gaps.length ? gaps.join(' / ') + ' · ' + row.owner + ' → ' + row.next : '';
|
|
94
|
+
};
|
|
95
|
+
const elements = model.elements.map((e) => {
|
|
96
|
+
const c = byId(model.claims, e.claim);
|
|
97
|
+
if (c.kind !== 'actual' || !established(c))
|
|
98
|
+
throw new Error('Use a current static view, keep proposals in design-preview');
|
|
99
|
+
const links = e.links ?? [];
|
|
100
|
+
for (const link of links) {
|
|
101
|
+
const node = guide.flows[link.flow]?.visual?.nodes?.find((n) => n.id === link.node);
|
|
102
|
+
if (!node?.refs.some((r) => r.side === 'target')) throw new Error('Missing target node for ' + e.id);
|
|
103
|
+
}
|
|
104
|
+
// Display the promise at the owning element, not every participant on its path.
|
|
105
|
+
const rows = model.comparisons.filter((row) => row.actual === e.claim);
|
|
106
|
+
const spec = rows.map(describeIntent).join(' ');
|
|
107
|
+
const gap = rows.map(describeGap).filter(Boolean).join(' ');
|
|
108
|
+
const sources = rows.length ? rows.flatMap((r) => [r.intended, r.actual, r.execution]) : [e.claim];
|
|
109
|
+
const evidence = [...new Set(sources.filter(Boolean))]
|
|
110
|
+
.map((id) => byId(model.claims, id))
|
|
111
|
+
.flatMap((claim) =>
|
|
112
|
+
claim.sources.map((r) => ({
|
|
113
|
+
label: claim.authority + ' · ' + claim.status + ' · ' + r.role,
|
|
114
|
+
path: r.path,
|
|
115
|
+
startLine: r.line,
|
|
116
|
+
...(r.end ? { endLine: r.end } : {}),
|
|
117
|
+
}))
|
|
118
|
+
);
|
|
119
|
+
return {
|
|
120
|
+
id: e.id,
|
|
121
|
+
level: levels[e.type],
|
|
122
|
+
label: e.name,
|
|
123
|
+
responsibility: e.responsibility,
|
|
124
|
+
...(e.parent ? { parent: e.parent } : {}),
|
|
125
|
+
...(spec ? { spec } : {}),
|
|
126
|
+
...(gap ? { gap } : {}),
|
|
127
|
+
...(evidence.length ? { evidence } : {}),
|
|
128
|
+
links,
|
|
129
|
+
};
|
|
130
|
+
});
|
|
131
|
+
if (!elements.some((e) => e.links.length)) throw new Error('No mapped steps');
|
|
132
|
+
// A missing implementation has no component to host its comparison.
|
|
133
|
+
const unknowns = new Set([...(guide.unknowns ?? []), ...model.unknowns]);
|
|
134
|
+
for (const row of model.comparisons) {
|
|
135
|
+
if (model.elements.some((e) => row.actual === e.claim)) continue;
|
|
136
|
+
const scenario = byId(model.scenarios, row.scenario);
|
|
137
|
+
const actual = byId(model.claims, row.actual);
|
|
138
|
+
unknowns.add(
|
|
139
|
+
[
|
|
140
|
+
scenario.title,
|
|
141
|
+
ja ? '担当する構成要素は未特定' : 'No mapped component',
|
|
142
|
+
describeIntent(row),
|
|
143
|
+
actual && actual.status + ' · ' + actual.summary,
|
|
144
|
+
describeGap(row) || row.owner + ' → ' + row.next,
|
|
145
|
+
ja ? '根拠はモデルの Markdown 版を参照してください。' : 'See the Markdown view for evidence.',
|
|
146
|
+
]
|
|
147
|
+
.filter(Boolean)
|
|
148
|
+
.join(' · ')
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
return { ...guide, unknowns: [...unknowns], structure: { revision: guide.revision, elements } };
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const escape = (s) =>
|
|
155
|
+
String(s)
|
|
156
|
+
.replace(/[\r\n]+/g, ' ')
|
|
157
|
+
.replaceAll('&', '&')
|
|
158
|
+
.replaceAll('<', '<')
|
|
159
|
+
.replaceAll('>', '>')
|
|
160
|
+
.replace(/[\\`*_[\]|]/g, '\\$&');
|
|
161
|
+
const chars = (path) =>
|
|
162
|
+
path
|
|
163
|
+
.split('/')
|
|
164
|
+
.map((p) => encodeURIComponent(p).replaceAll('(', '%28').replaceAll(')', '%29'))
|
|
165
|
+
.join('/');
|
|
166
|
+
function source(model, s, r) {
|
|
167
|
+
const snap = s.snapshot;
|
|
168
|
+
const label = escape(r.role + ' · ' + r.path + '#L' + r.line + (r.end ? '-L' + r.end : ''));
|
|
169
|
+
const spec = r.spec_ref;
|
|
170
|
+
const item = spec ? ' · ' + escape(spec.artifact_id + '@' + spec.observed_revision + '#' + spec.item_id) : '';
|
|
171
|
+
if (snap?.mode === 'commit' && /^github\.com\/[\w.-]+\/[\w.-]+$/u.test(model.repository)) {
|
|
172
|
+
return (
|
|
173
|
+
'[' +
|
|
174
|
+
label +
|
|
175
|
+
'](https://' +
|
|
176
|
+
model.repository +
|
|
177
|
+
'/blob/' +
|
|
178
|
+
snap.commit +
|
|
179
|
+
'/' +
|
|
180
|
+
chars(r.path) +
|
|
181
|
+
'#L' +
|
|
182
|
+
r.line +
|
|
183
|
+
(r.end ? '-L' + r.end : '') +
|
|
184
|
+
')' +
|
|
185
|
+
item
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
return label + item;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export function markdown(model, state) {
|
|
192
|
+
const environments = deploymentEnvironments(model);
|
|
193
|
+
const ja = model.language === 'ja';
|
|
194
|
+
const t = (jaText, enText) => (ja ? jaText : enText);
|
|
195
|
+
const out = ['# ' + escape(model.title), '', escape(model.purpose), ''];
|
|
196
|
+
const section = (title) => out.push('', '## ' + title, '');
|
|
197
|
+
const claim = (id) => byId(model.claims, id);
|
|
198
|
+
const element = (id) => byId(model.elements, id);
|
|
199
|
+
const fresh = (id) => byId(state, claim(id).scope)?.state === 'current';
|
|
200
|
+
const label = (id) => escape(element(id).name);
|
|
201
|
+
const refs = (ids) =>
|
|
202
|
+
[...new Set(ids)]
|
|
203
|
+
.map((id) => '[' + escape(claim(id).kind) + ' · ' + escape(claim(id).status) + '](#claim-' + id + ')')
|
|
204
|
+
.join(' / ');
|
|
205
|
+
const warning = (ids) => (ids.every(fresh) ? '' : t('**要再確認** ', '**Recheck sources** '));
|
|
206
|
+
const kind = ja
|
|
207
|
+
? {
|
|
208
|
+
intended: '仕様・要求',
|
|
209
|
+
actual: 'コードから読める動作',
|
|
210
|
+
proposed: '提案・未承認',
|
|
211
|
+
'observed-execution': '実行記録',
|
|
212
|
+
}
|
|
213
|
+
: {
|
|
214
|
+
intended: 'Intended',
|
|
215
|
+
actual: 'Static implementation',
|
|
216
|
+
proposed: 'Proposal, not approved',
|
|
217
|
+
'observed-execution': 'Observed run',
|
|
218
|
+
};
|
|
219
|
+
const gapText = gapLabels(ja);
|
|
220
|
+
if (state.some((s) => s.state !== 'current'))
|
|
221
|
+
out.push(
|
|
222
|
+
t(
|
|
223
|
+
'> 失効した範囲の説明は過去の記録です。現在のコードと契約を直接確認してください。',
|
|
224
|
+
'> Stale sections describe a past view. Inspect current code and contracts directly.'
|
|
225
|
+
),
|
|
226
|
+
''
|
|
227
|
+
);
|
|
228
|
+
out.push(t('対象', 'Scope') + ' · ' + escape(model.project) + ' / ' + escape(model.profile));
|
|
229
|
+
for (const s of model.scopes) {
|
|
230
|
+
const snap = s.snapshot;
|
|
231
|
+
out.push(
|
|
232
|
+
'- ' +
|
|
233
|
+
escape(s.boundary) +
|
|
234
|
+
' — ' +
|
|
235
|
+
(byId(state, s.id)?.state ?? 'unknown') +
|
|
236
|
+
' · ' +
|
|
237
|
+
(snap ? snap.mode + ' `' + (snap.mode === 'commit' ? snap.commit : snap.fingerprint) + '`' : '—')
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
section(t('誰が何を担うか', 'Responsibilities'));
|
|
241
|
+
for (const level of ['C1', 'C2', 'C3']) {
|
|
242
|
+
const rows = model.elements.filter((e) => levels[e.type] === level);
|
|
243
|
+
if (!rows.length) continue;
|
|
244
|
+
out.push(
|
|
245
|
+
'### ' +
|
|
246
|
+
{
|
|
247
|
+
C1: t('利用者とシステム', 'People and systems'),
|
|
248
|
+
C2: t('アプリケーションとデータストア', 'Applications and stores'),
|
|
249
|
+
C3: t('内部の役割', 'Components'),
|
|
250
|
+
}[level],
|
|
251
|
+
''
|
|
252
|
+
);
|
|
253
|
+
for (const e of rows) {
|
|
254
|
+
const ids = [e.claim, ...(e.parent ? [element(e.parent).claim] : [])];
|
|
255
|
+
out.push(
|
|
256
|
+
'- ' +
|
|
257
|
+
warning(ids) +
|
|
258
|
+
'**' +
|
|
259
|
+
label(e.id) +
|
|
260
|
+
'**' +
|
|
261
|
+
(e.parent ? ' (' + label(e.parent) + ')' : '') +
|
|
262
|
+
' — ' +
|
|
263
|
+
escape(e.responsibility) +
|
|
264
|
+
' ' +
|
|
265
|
+
refs([e.claim])
|
|
266
|
+
);
|
|
267
|
+
const details = [e.technology, e.contract, e.owner, e.state].filter(Boolean);
|
|
268
|
+
if (details.length) out.push(' - ' + details.map(escape).join(' · '));
|
|
269
|
+
}
|
|
270
|
+
out.push('');
|
|
271
|
+
}
|
|
272
|
+
section(t('関係と処理の向き', 'Directed relationships'));
|
|
273
|
+
out.push(
|
|
274
|
+
t(
|
|
275
|
+
'矢印は左から右への利用、呼び出し、依存、データの移動を示します。',
|
|
276
|
+
'Read each edge from its source to its target. The label identifies the interaction.'
|
|
277
|
+
),
|
|
278
|
+
''
|
|
279
|
+
);
|
|
280
|
+
const relationship = (r, environment = '') => {
|
|
281
|
+
const ids = [r.claim, element(r.from).claim, element(r.to).claim];
|
|
282
|
+
out.push(
|
|
283
|
+
'- ' +
|
|
284
|
+
warning(ids) +
|
|
285
|
+
(environment ? escape(environment) + ' · ' : '') +
|
|
286
|
+
label(r.from) +
|
|
287
|
+
' → ' +
|
|
288
|
+
label(r.to) +
|
|
289
|
+
' — ' +
|
|
290
|
+
escape(r.meaning) +
|
|
291
|
+
' (' +
|
|
292
|
+
escape(r.kind) +
|
|
293
|
+
(r.technology ? ' · ' + escape(r.technology) : '') +
|
|
294
|
+
') ' +
|
|
295
|
+
refs([r.claim])
|
|
296
|
+
);
|
|
297
|
+
};
|
|
298
|
+
for (const r of model.relationships) if (r.kind !== 'deployment') relationship(r);
|
|
299
|
+
const deployments = model.relationships.filter((r) => r.kind === 'deployment');
|
|
300
|
+
if (deployments.length) {
|
|
301
|
+
section(t('環境ごとの配置', 'Deployment by environment'));
|
|
302
|
+
out.push(t('設定から分かる配置と、実行記録で確認した配置を区別します。',
|
|
303
|
+
'Configuration describes placement. Only an observed run confirms it.'), '');
|
|
304
|
+
for (const r of deployments) relationship(r, environments.get(r.claim));
|
|
305
|
+
}
|
|
306
|
+
for (const s of model.scenarios) {
|
|
307
|
+
section(escape(s.title));
|
|
308
|
+
const edges = s.path.map((id) => byId(model.relationships, id));
|
|
309
|
+
const ids = [s.claim, ...edges.flatMap((r) => [r.claim, element(r.from).claim, element(r.to).claim])];
|
|
310
|
+
out.push(
|
|
311
|
+
warning(ids) + [s.environment, s.condition, s.input].filter(Boolean).map(escape).join(' · '),
|
|
312
|
+
'',
|
|
313
|
+
[edges[0].from, ...edges.map((r) => r.to)].map(label).join(' → '),
|
|
314
|
+
'',
|
|
315
|
+
escape(s.result) + ' ' + refs([s.claim]),
|
|
316
|
+
''
|
|
317
|
+
);
|
|
318
|
+
for (const row of model.comparisons.filter((r) => r.scenario === s.id)) {
|
|
319
|
+
const facts = [row.intended, row.actual, ...(row.proposed ?? []), row.execution].filter(Boolean);
|
|
320
|
+
for (const id of facts)
|
|
321
|
+
out.push(
|
|
322
|
+
'- ' + warning([id]) + kind[claim(id).kind] + ' — ' + escape(claim(id).summary) + ' ' + refs([id])
|
|
323
|
+
);
|
|
324
|
+
const gaps = comparisonGaps(model, row);
|
|
325
|
+
if (gaps.length)
|
|
326
|
+
out.push('', warning([...ids, ...facts]) + '**' + gaps.map((g) => gapText[g] ?? g).join(' / ') + '**');
|
|
327
|
+
out.push('', escape(row.owner) + ' → ' + escape(row.next), '');
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
if (model.unknowns.length) {
|
|
331
|
+
section(t('分かっていないこと', 'Open questions'));
|
|
332
|
+
out.push(...model.unknowns.map((u) => '- ' + escape(u)));
|
|
333
|
+
}
|
|
334
|
+
section(t('どこで確かめるか', 'Evidence and reverse lookup'));
|
|
335
|
+
for (const c of model.claims) {
|
|
336
|
+
const scope = byId(model.scopes, c.scope);
|
|
337
|
+
const uses = [
|
|
338
|
+
...model.elements.filter((e) => e.claim === c.id).map((e) => e.name),
|
|
339
|
+
...model.relationships.filter((r) => r.claim === c.id).map((r) => r.meaning),
|
|
340
|
+
...model.scenarios
|
|
341
|
+
.filter(
|
|
342
|
+
(s) =>
|
|
343
|
+
s.claim === c.id ||
|
|
344
|
+
model.comparisons.some(
|
|
345
|
+
(r) =>
|
|
346
|
+
r.scenario === s.id && [r.intended, r.actual, r.execution, ...(r.proposed ?? [])].includes(c.id)
|
|
347
|
+
)
|
|
348
|
+
)
|
|
349
|
+
.map((s) => s.title),
|
|
350
|
+
];
|
|
351
|
+
out.push(
|
|
352
|
+
'<a id="claim-' + c.id + '"></a>',
|
|
353
|
+
'',
|
|
354
|
+
warning([c.id]) +
|
|
355
|
+
'**' +
|
|
356
|
+
escape(c.summary) +
|
|
357
|
+
'** · ' +
|
|
358
|
+
escape(c.authority) +
|
|
359
|
+
' · ' +
|
|
360
|
+
kind[c.kind] +
|
|
361
|
+
' / ' +
|
|
362
|
+
c.status,
|
|
363
|
+
''
|
|
364
|
+
);
|
|
365
|
+
if (uses.length) out.push(uses.map(escape).join(' · '), '');
|
|
366
|
+
for (const r of c.sources) out.push('- ' + source(model, scope, r));
|
|
367
|
+
out.push('');
|
|
368
|
+
}
|
|
369
|
+
return out.join('\n').trimEnd() + '\n';
|
|
370
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: code-visualization
|
|
3
|
-
description: Produce an interactive local HTML guide for understanding a PR's changes or catching up on existing code without a PR or diff.
|
|
3
|
+
description: Produce an interactive local HTML guide for understanding a PR's changes or catching up on existing code without a PR or diff. Compare proposed designs on the same input before implementation, or trace current responsibilities through representative paths to exact source and tests.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Code visualization
|
|
@@ -9,16 +9,20 @@ description: Produce an interactive local HTML guide for understanding a PR's ch
|
|
|
9
9
|
|
|
10
10
|
Create the guide when asked to visualize a change or understand existing code visually. Use [the renderer and input reference](references/guide-input.md). Rendering is a local, additive action, not a review gate, an approval, or a decision to publish.
|
|
11
11
|
|
|
12
|
-
##
|
|
12
|
+
## Before a design decision
|
|
13
|
+
|
|
14
|
+
For “compare how these designs behave” or 「この2案で処理がどう変わるか見せて」, first align the reader, decision, input, assumptions and observable difference. A short table often suffices. When replay helps, use [design-preview](references/guide-input.md#compare-designs-before-code-exists) even with no checkout. Keep proposals visibly unapproved and unexecuted. Bind a supplied current path to real source. Show the recommendation, tradeoffs and one question in the conversation. Return the decision to the requesting design or requirement workflow. A diagram cannot make that decision. Do not require durable files or another capability for a simple comparison.
|
|
15
|
+
|
|
16
|
+
## Process for existing code
|
|
13
17
|
|
|
14
18
|
1. Choose the question and reading boundary. For **PR review**, use the actual base/head commits, inspect the diff and affected consumers, and show what changes from before to after, the impact, and what remains unverified. For **code catch-up**, use a repository or directory at one revision; no PR, diff, or specific question is required. Identify what the code does, where to start, and the main behavior paths. If a specific goal is given, narrow the first view to that goal. If a boundary is omitted, use the current checkout; disclose omissions that could affect understanding.
|
|
15
|
-
2. Inspect real entry points, configuration, implementation and relevant tests. Pick an object a human cares about (a request, an identity, a record, a file or a result). Show what it encounters, what changes, and what remains. For PRs, compare the same input across versions on one map. Show permission or other conditions, the person or system that receives work, and the actual result as separate objects when that distinction matters. For catch-up, show what is copied, retained, excluded, transformed or not returned; do not draw a directory dump. Use a matching C4 asset as optional context only.
|
|
19
|
+
2. Inspect real entry points, configuration, implementation and relevant tests. Pick an object a human cares about (a request, an identity, a record, a file or a result). Show what it encounters, what changes, and what remains. For PRs, compare the same input across versions on one map. Show permission or other conditions, the person or system that receives work, and the actual result as separate objects when that distinction matters. For catch-up, show what is copied, retained, excluded, transformed or not returned; do not draw a directory dump. Use a matching C4 asset as optional context only. When relevant, [connect its current responsibilities to the map](references/guide-input.md#trace-a-structure-to-code) and show differences between expected and actual paths, including missing checks. Inspect code regardless of model coverage.
|
|
16
20
|
3. Prepare the guide input. Choose meaningful shapes and short identity labels, selective branches and representative cases. Include a successful zero outcome separately from no result if relevant. Place related states so the first static view tells the story; replay and a single step should show what happens, not replace the static view. Put explanation, verified source and tests behind object selection. Only cite source at exact commits, only excerpt what is needed, and label observed runs separately from static code evidence. Unknown cases must stay visible as unknown; do not claim exhaustive coverage.
|
|
17
21
|
4. Generate the self-contained HTML with the bundled renderer. Pass the source repository checkout if different from the current directory. Save to a new path in a user-appropriate local scratch/output directory. Do not change tracked project files, run unrelated code, attach/export private code, or upload automatically. If shell execution, a suitable local output directory or the renderer is unavailable, say what is missing instead of claiming that a guide was generated. Report the file path, scope, and material limitations.
|
|
18
22
|
5. Check at least one successful and consequential alternative path if the code has both. In a browser, check the static map, playback and stepping, and open a source excerpt. On a narrow screen confirm labels do not overlap the route. If browser verification is unavailable, state that it was not done. If the checked-out code has uncommitted edits, pinned links still point to committed content; either visualize the committed revision or explain the omitted changes.
|
|
19
23
|
|
|
20
24
|
## Output
|
|
21
25
|
|
|
22
|
-
Deliver the local HTML path, its scope
|
|
26
|
+
Deliver the local HTML path, its scope, source revision if applicable, and what remains unverified. Do not attach, publish, or claim a review decision by default.
|
|
23
27
|
|
|
24
28
|
For an actual review decision use `review-router`; for a durable rationale or rollback note use `mr-readme-generation`; for comparing specification/test scenarios use the visual-review reference in `spec-driven-development`. Generating this guide does not replace any of those workflows.
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { compileScene } from './scene-model.mjs';
|
|
2
|
+
|
|
3
|
+
const messages = {
|
|
4
|
+
en: {
|
|
5
|
+
design:'Design comparison', proposed:'Proposed', scene:'Path', evidence:'Step details',
|
|
6
|
+
path:'Proposed path', inferred:'Proposals · Not approved · Not run', notRun:'Playback does not measure elapsed time.',
|
|
7
|
+
status:'Proposals · Not approved · Not run', noCurrent:'No current implementation supplied.',
|
|
8
|
+
current:'Current implementation', premise:'Shared premise', case:'Input', owner:'Owner', state:'State change',
|
|
9
|
+
boundary:'Boundary', effects:'Side effects', expected:'Expected outcome', assumption:'Assumption',
|
|
10
|
+
unknown:'Still to verify', hint:'Select a step to inspect its role and assumptions.',
|
|
11
|
+
details:'Compare responsibilities and uncertainties', outcome:'Outcome',
|
|
12
|
+
},
|
|
13
|
+
ja: {
|
|
14
|
+
design:'設計案の比較', proposed:'提案', scene:'処理経路', evidence:'手順の詳細',
|
|
15
|
+
path:'提案した処理', inferred:'設計案は未承認・未実行', notRun:'再生時間は処理時間を示しません。',
|
|
16
|
+
status:'設計案は未承認・未実行', noCurrent:'現行実装の提示はありません。',
|
|
17
|
+
current:'現行実装', premise:'共通の前提', case:'入力', owner:'状態の管理者', state:'状態の変化',
|
|
18
|
+
boundary:'処理の境界', effects:'副作用', expected:'想定する結果', assumption:'仮定',
|
|
19
|
+
unknown:'要確認', hint:'図の各手順を選ぶと、処理の内容と前提が分かります。',
|
|
20
|
+
details:'責務の違いと未確認事項を比べる', outcome:'結果',
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
function requireField(ok, field) {
|
|
25
|
+
if (!ok) throw new Error('Invalid guide design-preview: '+field);
|
|
26
|
+
}
|
|
27
|
+
function record(value, fields, optional=[]) {
|
|
28
|
+
requireField(value && typeof value==='object' && !Array.isArray(value)
|
|
29
|
+
&& Object.keys(value).every(key=>fields.includes(key)||optional.includes(key)), 'unexpected field');
|
|
30
|
+
for(const key of fields) requireField(typeof value[key]==='string' && value[key].trim(),key);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Only proposed text/steps reach this path. Existing code uses the Git compiler separately.
|
|
34
|
+
export function compileProposals(guide, language, escape) {
|
|
35
|
+
record(guide,['mode','title','question','premise','input'],['language','alternatives','current']);
|
|
36
|
+
const alternatives=guide.alternatives;
|
|
37
|
+
requireField(Array.isArray(alternatives) && alternatives.length>=2 && alternatives.length<=4, '2–4 alternatives');
|
|
38
|
+
const labels=messages[language];
|
|
39
|
+
const ids=new Set(), names=new Set();
|
|
40
|
+
const fields=['owner','state','boundary','effects','assumption','unknown'];
|
|
41
|
+
const compiled=alternatives.map((option,index)=>{
|
|
42
|
+
record(option,['id','label','expected',...fields],['steps']);
|
|
43
|
+
requireField(!ids.has(option.id) && !names.has(option.label), 'distinct alternatives');
|
|
44
|
+
ids.add(option.id); names.add(option.label);
|
|
45
|
+
requireField(Array.isArray(option.steps) && option.steps.length>=1 && option.steps.length<=6,'1–6 steps');
|
|
46
|
+
option.steps.forEach(step=>record(step,['label','detail','shape']));
|
|
47
|
+
const steps=[
|
|
48
|
+
{label:guide.input,detail:guide.premise,shape:'request'},
|
|
49
|
+
...option.steps,
|
|
50
|
+
{label:labels.outcome,detail:option.expected,shape:'result'},
|
|
51
|
+
];
|
|
52
|
+
const token=(_,i)=>'proposal-'+index+'-'+i;
|
|
53
|
+
const nodes=steps.map(({label,shape},i)=>({
|
|
54
|
+
id:'step-'+i,stage:i,label,shape,refs:[{side:'target',step:i}],
|
|
55
|
+
}));
|
|
56
|
+
const scene=compileScene({nodes,cases:[{label:guide.input,target:nodes.map(node=>node.id)}]},
|
|
57
|
+
{target:steps.map(()=>({status:'proposed'}))},token);
|
|
58
|
+
return {
|
|
59
|
+
scene:{...scene,title:option.label,summary:option.expected,absent:'',proposed:true},
|
|
60
|
+
templates:steps.map(({detail},i)=>`<template id="${token(null,i)}"><span class="badge proposed">${labels.proposed}</span>
|
|
61
|
+
<p>${escape(detail)}</p><h3>${labels.assumption}</h3><p>${escape(option.assumption)}</p>
|
|
62
|
+
<h3>${labels.unknown}</h3><p>${escape(option.unknown)}</p></template>`),
|
|
63
|
+
};
|
|
64
|
+
});
|
|
65
|
+
const summary=`<section class="comparison"><p><strong>${labels.premise}</strong> ${escape(guide.premise)}</p>
|
|
66
|
+
<p><strong>${labels.case}</strong> ${escape(guide.input)}</p>
|
|
67
|
+
<div class="outcomes">${alternatives.map((option,index)=>`<button type="button" data-proposal="${index}" aria-pressed="${index===0}">
|
|
68
|
+
<strong>${escape(option.label)}</strong><span>${labels.expected}</span>${escape(option.expected)}</button>`).join('')}</div>
|
|
69
|
+
<details><summary>${labels.details}</summary><div class="comparison-grid">${alternatives.map(option=>
|
|
70
|
+
`<section><h3>${escape(option.label)}</h3><dl>${fields.map(key=>`<dt>${labels[key]}</dt><dd>${escape(option[key])}</dd>`).join('')}</dl></section>`).join('')}</div></details>
|
|
71
|
+
<p>${guide.current?`${labels.current} · <code>${escape(guide.current.revision)}</code> · ${escape(guide.current.flow.summary)}`:labels.noCurrent}</p>
|
|
72
|
+
</section>`;
|
|
73
|
+
return {labels,summary,compiled};
|
|
74
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"mode": "design-preview",
|
|
3
|
+
"language": "ja",
|
|
4
|
+
"title": "最後の1枠を確定するのは誰か",
|
|
5
|
+
"question": "同時に申し込んだ2人のうち、予約を確定できるのは1人だけとしますか?",
|
|
6
|
+
"premise": "両方の画面に「残り1枠」と表示されている。通信は成功し、キャンセルはない。",
|
|
7
|
+
"input": "2人が同時に1枠ずつ申し込む",
|
|
8
|
+
"alternatives": [
|
|
9
|
+
{
|
|
10
|
+
"id": "screen",
|
|
11
|
+
"label": "案A 画面で確定",
|
|
12
|
+
"owner": "各利用者の画面",
|
|
13
|
+
"state": "画面ごとに残数を1から0にする。",
|
|
14
|
+
"boundary": "画面内で確認を終え、確定後にサーバーへ通知する。",
|
|
15
|
+
"effects": "2人とも確定通知を受け取り、後から調整が必要になる。",
|
|
16
|
+
"expected": "2人とも予約できたと表示される",
|
|
17
|
+
"assumption": "サーバーは通知を受け取るだけで、空き枠を再確認しない。",
|
|
18
|
+
"unknown": "重複した予約をどう取り消し、誰に連絡するか。",
|
|
19
|
+
"steps": [
|
|
20
|
+
{"label":"各画面で確認","detail":"2人の画面が、それぞれ手元の残り1枠を参照する。","shape":"gate"},
|
|
21
|
+
{"label":"各画面で確定","detail":"それぞれが予約に成功したと判断し、画面上の残数を減らす。","shape":"service"},
|
|
22
|
+
{"label":"確定を2件通知","detail":"残り1枠に対して、2件の確定通知がサーバーに届く想定。","shape":"artifact"}
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"id": "service",
|
|
27
|
+
"label": "案B 予約サービスで確定",
|
|
28
|
+
"owner": "サーバーの予約サービス",
|
|
29
|
+
"state": "共有する残数を一度だけ1から0にする。",
|
|
30
|
+
"boundary": "空き枠の確認と確保を一つの操作にまとめる。",
|
|
31
|
+
"effects": "成功した1人だけに確定通知を送る。もう1人には満席を伝える。",
|
|
32
|
+
"expected": "1人が予約でき、もう1人は満席になる",
|
|
33
|
+
"assumption": "保存先が競合する更新を直列化できる。画面は応答を待って結果を伝える。",
|
|
34
|
+
"unknown": "実際の保存先で同時更新を試し、確保数と通知先の両方を確認する必要がある。",
|
|
35
|
+
"steps": [
|
|
36
|
+
{"label":"2件を受け付ける","detail":"どちらの画面も予約の確定を待つ。","shape":"service"},
|
|
37
|
+
{"label":"一度だけ確保","detail":"先に処理した1件が残数を0にする。次の1件では状態を変えない。","shape":"gate"},
|
|
38
|
+
{"label":"結果を別々に返す","detail":"1人に確定を通知し、もう1人には満席と伝える。","shape":"artifact"}
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
}
|
|
@@ -46,3 +46,33 @@ For example, for a single committed path with two evidence steps:
|
|
|
46
46
|
```
|
|
47
47
|
|
|
48
48
|
Full examples with pinned public ASK source: [PR comparison](examples/pr497.json) and [code catch-up](examples/skill-assets.json). Both are source-derived scenarios, not stored live runs. These files are input examples, not assumptions about another project. Use only exact evidence from the project being visualized.
|
|
49
|
+
|
|
50
|
+
## Trace a structure to code
|
|
51
|
+
|
|
52
|
+
An optional top-level `structure` describes the target commit. Derive it from the current, scoped architecture view after checking repository, revision and freshness. Retain the existing model element IDs. Omit it when no matching model is available. The renderer checks revision and links, not the truth of a responsibility or completeness of the model.
|
|
53
|
+
|
|
54
|
+
```json
|
|
55
|
+
{
|
|
56
|
+
"revision": "<same full SHA as guide.revision>",
|
|
57
|
+
"elements": [
|
|
58
|
+
{"id":"orders","level":"C1","label":"Orders","responsibility":"Accept orders.","links":[]},
|
|
59
|
+
{"id":"api","level":"C2","parent":"orders","label":"Order API","responsibility":"Check availability.","spec":"SPEC-ORDER@2#RESERVE","gap":"Concurrent requests not verified.","links":[{"flow":0,"node":"request"}]}
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Use C1 for context, C2 for real runtime boundaries, and C3 only for relevant components. A supplied parent must resolve to a higher level. Each link selects an existing target-side visual object in a zero-based flow and opens the first applicable input and its evidence. Include at least one link. A selected object links back to its responsibilities. Keep `spec` (an existing locator or explicit unknown) and `gap` (difference, owner and next check) short. An optional `evidence` list on an element uses the same target-side file ranges as a step. Keep excerpts within the same size limits. Links must be reachable in at least one target case. A link cannot establish a run or repair missing step evidence. For a removed path inspect the PR's base side directly. Never represent dirty content with a commit link.
|
|
65
|
+
|
|
66
|
+
## Compare designs before code exists
|
|
67
|
+
|
|
68
|
+
Run this from the skill's `references` directory with a fresh local path:
|
|
69
|
+
|
|
70
|
+
```sh
|
|
71
|
+
node render-guide.mjs examples/last-seat.json /tmp/last-seat.html
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
[Two people requesting one seat](examples/last-seat.json) illustrates the closed `design-preview` input. Set `language` to `en` or `ja`, then supply `title`, one decision `question`, one shared `premise` and a short shared `input` (up to 36 characters). Provide 2–4 `alternatives` with distinct `id` and `label`, plus `owner`, `state`, `boundary`, `effects`, `expected`, `assumption`, `unknown` and 1–6 `steps`. Each step carries only `label`, `detail` and a supported `shape`. Use the assumption and open question to name the basis, tradeoff and distinguishing check. Never assign a commit, run, approval or implementation status to a proposal.
|
|
75
|
+
|
|
76
|
+
For an existing implementation add `current: {revision, flow}`. Supply one normal catch-up flow with one case whose label matches the common input and at least one visible code-bound step. Confirm the actual inputs and preconditions match from source. Equal labels alone cannot prove that. Keep an unverified baseline explicitly absent. Use a normal PR guide when both sides already have source.
|
|
77
|
+
|
|
78
|
+
Select an option to inspect its path. Playback illustrates the premise. Selection has no approval effect. Carry the same alternatives into the specification candidate preview without the implementation-only `current` field. When a person changes an answer, revise the affected assumptions, results and paths, then return the decision to its existing Requirement, Spec or ADR owner.
|