archsight 0.5.2 → 0.5.4
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.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/docs/archimate.md +1 -1
- data/docs/configuration.md +1 -1
- data/docs/diagram.md +12 -2
- data/docs/import.md +27 -2
- data/docs/modeling.md +17 -6
- data/docs/pages.md +1 -1
- data/docs/search.md +19 -0
- data/lib/archsight/annotations/capacity_annotations.rb +15 -0
- data/lib/archsight/database.rb +1 -1
- data/lib/archsight/diagram/graph/attributes.rb +11 -3
- data/lib/archsight/diagram/graph/builder.rb +1 -0
- data/lib/archsight/diagram/graph/node.rb +26 -2
- data/lib/archsight/diagram/layout/expander.rb +39 -0
- data/lib/archsight/diagram/layout.rb +11 -0
- data/lib/archsight/diagram/legend/inventory.rb +6 -2
- data/lib/archsight/diagram/parser.rb +1 -1
- data/lib/archsight/diagram/renderer/node_renderer.rb +6 -1
- data/lib/archsight/diagram/renderer/stylesheet.rb +2 -0
- data/lib/archsight/diagram/style/representers.rb +14 -0
- data/lib/archsight/diagram/support/text_metrics.rb +38 -0
- data/lib/archsight/git_source.rb +5 -3
- data/lib/archsight/helpers.rb +3 -1
- data/lib/archsight/import/handlers/gitea.rb +195 -0
- data/lib/archsight/import/handlers/github.rb +1 -0
- data/lib/archsight/import/handlers/gitlab.rb +1 -0
- data/lib/archsight/import/handlers/repository.rb +32 -4
- data/lib/archsight/linter.rb +13 -2
- data/lib/archsight/mcp/analyze_resource_tool.rb +145 -43
- data/lib/archsight/mcp/base.rb +112 -5
- data/lib/archsight/mcp/execute_analysis_tool.rb +11 -1
- data/lib/archsight/mcp/query_hints.rb +119 -0
- data/lib/archsight/mcp/query_tool.rb +90 -5
- data/lib/archsight/mcp/relations_tool.rb +89 -0
- data/lib/archsight/mcp/resource_doc_tool.rb +39 -20
- data/lib/archsight/mcp/summary_tool.rb +106 -0
- data/lib/archsight/mcp.rb +2 -0
- data/lib/archsight/query/ast.rb +28 -0
- data/lib/archsight/query/evaluator.rb +2 -0
- data/lib/archsight/query/lexer.rb +2 -2
- data/lib/archsight/query/parser.rb +45 -0
- data/lib/archsight/query/text_search.rb +38 -0
- data/lib/archsight/query.rb +1 -0
- data/lib/archsight/reading_time.rb +66 -0
- data/lib/archsight/resources/base.rb +12 -0
- data/lib/archsight/resources/business_contract.rb +8 -1
- data/lib/archsight/resources/config.rb +28 -0
- data/lib/archsight/resources/implementation_work_package.rb +2 -0
- data/lib/archsight/resources/motivation_requirement.rb +10 -0
- data/lib/archsight/resources/technology_device.rb +14 -0
- data/lib/archsight/resources/technology_equipment.rb +3 -1
- data/lib/archsight/resources/technology_node.rb +8 -1
- data/lib/archsight/summary/builder.rb +204 -0
- data/lib/archsight/summary/lens.rb +224 -0
- data/lib/archsight/summary.rb +11 -0
- data/lib/archsight/version.rb +1 -1
- data/lib/archsight/web/api/openapi/spec.yaml +20 -1
- data/lib/archsight/web/api/page_helpers.rb +5 -1
- data/lib/archsight/web/application.rb +2 -0
- data/lib/archsight/web/public/vue/{DocPage-B2AVspsD.js → DocPage-BHffBQ3u.js} +1 -1
- data/lib/archsight/web/public/vue/{EditorPage-BYSZG_O0.js → EditorPage-BHZtvtnN.js} +1 -1
- data/lib/archsight/web/public/vue/{ErrorPage-eL_Woec4.js → ErrorPage-BQARAwF8.js} +1 -1
- data/lib/archsight/web/public/vue/{GraphView-YEiPBxPd.js → GraphView-D84CH00D.js} +1 -1
- data/lib/archsight/web/public/vue/{HomePage-BeLTwv2y.js → HomePage-BJpTPWFz.js} +2 -2
- data/lib/archsight/web/public/vue/{InstanceRouter-DgvdUouW.js → InstanceRouter-C1Da3nWo.js} +1 -1
- data/lib/archsight/web/public/vue/{KindList-BkYvYpnh.js → KindList-DNRUVuEJ.js} +1 -1
- data/lib/archsight/web/public/vue/PageView-DzKj212I.js +1 -0
- data/lib/archsight/web/public/vue/{QueryError-DzGMgvyb.js → QueryError-CTVAL1Tm.js} +1 -1
- data/lib/archsight/web/public/vue/{ResourceList-Cr9ExUDn.js → ResourceList-CRt_FpfS.js} +1 -1
- data/lib/archsight/web/public/vue/{SearchResults-D6tx3Atc.js → SearchResults-BMwBz4BB.js} +1 -1
- data/lib/archsight/web/public/vue/{WikiPage-BhaaveRq.js → WikiPage-DSEL2gmd.js} +1 -1
- data/lib/archsight/web/public/vue/{index-le1guGp1.js → index-JZkWwfYg.js} +2 -2
- data/lib/archsight/web/public/vue.html +1 -1
- metadata +24 -14
- data/lib/archsight/web/public/vue/PageView-B3SnDw9S.js +0 -1
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "json"
|
|
4
|
+
|
|
5
|
+
module Archsight
|
|
6
|
+
module Summary
|
|
7
|
+
# The direct relations of a resource, both ways, as Related(verb, direction, resource); "out" = the resource
|
|
8
|
+
# declares the relation, "in" = the other resource points at it
|
|
9
|
+
Related = Struct.new(:verb, :direction, :resource)
|
|
10
|
+
|
|
11
|
+
module Relations
|
|
12
|
+
module_function
|
|
13
|
+
|
|
14
|
+
def direct(instance)
|
|
15
|
+
outgoing = instance.relations_grouped.flat_map do |verb, kinds|
|
|
16
|
+
kinds.values.flatten.map { |target| Related.new(verb.to_s, "out", target) }
|
|
17
|
+
end
|
|
18
|
+
incoming = instance.references.map { |ref| Related.new(ref[:verb].to_s, "in", ref[:instance]) }
|
|
19
|
+
(outgoing + incoming).uniq { |rel| [rel.verb, rel.direction, rel.resource.object_id] }
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Builds the summary of one resource as markdown: what it is, the sections of its lens (each relation group with
|
|
24
|
+
# a count and the first few resources as `[[Kind/Name]]` links, and the exact call that lists the rest) and a
|
|
25
|
+
# pointer to the other layers that have related resources. Empty sections are not shown. The result is bounded: the
|
|
26
|
+
# lists shrink and sections drop until it fits `max_chars`. Only the model is read, so it is reproducible.
|
|
27
|
+
class Builder
|
|
28
|
+
NOISE_KINDS = %w[Page PageMenu].freeze # followed only by an explicit verb, never through `*`
|
|
29
|
+
DESCRIPTION_CHARS = 400
|
|
30
|
+
FACTS = 6
|
|
31
|
+
|
|
32
|
+
Group = Struct.new(:label, :resources, :call)
|
|
33
|
+
Block = Struct.new(:title, :groups)
|
|
34
|
+
|
|
35
|
+
def initialize(database, per_section: 5, max_chars: 6000)
|
|
36
|
+
@db = database
|
|
37
|
+
@per_section = [[per_section.to_i, 1].max, 20].min
|
|
38
|
+
@max_chars = max_chars
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# @param lens_layer [String, nil] the layer whose lens to use instead of the one of the resource's kind
|
|
42
|
+
# @param source [Hash, nil] where the resource is defined: {source: "path:line", generated: bool}
|
|
43
|
+
# @return [String] markdown
|
|
44
|
+
def call(instance, lens_layer: nil, source: nil)
|
|
45
|
+
@source = source
|
|
46
|
+
lens = lens_layer || instance.class.layer
|
|
47
|
+
sections = Lens.for(@db, lens, kind: lens_layer ? nil : instance.klass)
|
|
48
|
+
blocks = sections.filter_map { |section| block_for(instance, section) }
|
|
49
|
+
render_bounded(instance, lens, blocks)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
private
|
|
53
|
+
|
|
54
|
+
def render_bounded(instance, lens, blocks)
|
|
55
|
+
limits = [@per_section, 3, 2, 1].uniq.select { |n| n <= @per_section }
|
|
56
|
+
text = nil
|
|
57
|
+
limits.each do |per|
|
|
58
|
+
text = render(instance, lens, blocks, per)
|
|
59
|
+
return text if text.length <= @max_chars
|
|
60
|
+
end
|
|
61
|
+
blocks = blocks.dup
|
|
62
|
+
while blocks.length > 1 && text.length > @max_chars
|
|
63
|
+
blocks.pop
|
|
64
|
+
text = render(instance, lens, blocks, limits.last, omitted: true)
|
|
65
|
+
end
|
|
66
|
+
text
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def render(instance, lens, blocks, per, omitted: false)
|
|
70
|
+
lines = header(instance, lens)
|
|
71
|
+
blocks.each do |block|
|
|
72
|
+
lines << "" << "## #{block.title}"
|
|
73
|
+
block.groups.each { |group| lines << group_line(group, per) }
|
|
74
|
+
end
|
|
75
|
+
lines.concat(other_layers(instance, lens))
|
|
76
|
+
lines << "" << "_More sections were left out to keep this short; use the `relations` tool for the rest._" if omitted
|
|
77
|
+
lines.join("\n")
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def header(instance, lens)
|
|
81
|
+
kind = instance.klass
|
|
82
|
+
layer = instance.class.layer
|
|
83
|
+
meta = ["**#{kind}**", "#{layer} layer"]
|
|
84
|
+
meta << "viewed through the #{lens} lens" if lens != layer
|
|
85
|
+
lines = ["# #{link(instance)}", meta.join(" · ")]
|
|
86
|
+
lines << source_line if @source&.dig(:source)
|
|
87
|
+
description = description_of(instance)
|
|
88
|
+
lines << "" << description if description
|
|
89
|
+
facts = facts_of(instance)
|
|
90
|
+
lines << "" << facts.join(" · ") unless facts.empty?
|
|
91
|
+
lines
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def source_line
|
|
95
|
+
note = @source[:generated] ? " (generated: change the importer or generator, not this file)" : ""
|
|
96
|
+
"Defined in `#{@source[:source]}`#{note}"
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# The opening of the description: its first paragraph up to a list, heading or code block, which stay in the
|
|
100
|
+
# resource itself
|
|
101
|
+
def description_of(instance)
|
|
102
|
+
paragraph = instance.annotations["architecture/description"].to_s.strip.split(/\n\s*\n/).first.to_s
|
|
103
|
+
lines = paragraph.lines.take_while { |line| !line.match?(/\A\s*([-*+]\s|\d+[.)]\s|\#|```)/) }
|
|
104
|
+
text = lines.map(&:strip).join(" ").sub(/:\z/, "").strip
|
|
105
|
+
return nil if text.empty?
|
|
106
|
+
|
|
107
|
+
text.length > DESCRIPTION_CHARS ? "#{text[0, DESCRIPTION_CHARS - 1].rstrip}…" : text
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
# The summary attributes of the kind that have a value, as "Title: value"
|
|
111
|
+
def facts_of(instance)
|
|
112
|
+
instance.class.summary_annotations.filter_map do |annotation|
|
|
113
|
+
value = Array(annotation.value_for(instance)).map(&:to_s).reject(&:empty?)
|
|
114
|
+
next if value.empty?
|
|
115
|
+
|
|
116
|
+
text = value.join(", ")
|
|
117
|
+
"#{annotation.title}: #{text.length > 80 ? "#{text[0, 79]}…" : text}"
|
|
118
|
+
end.first(FACTS)
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def block_for(instance, section)
|
|
122
|
+
groups = section.depth > 1 ? deep_groups(instance, section) : direct_groups(instance, section)
|
|
123
|
+
groups.empty? ? nil : Block.new(section.title, groups)
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def direct_groups(instance, section)
|
|
127
|
+
matching(Relations.direct(instance), section).group_by(&:verb).sort.map do |verb, rels|
|
|
128
|
+
entries = ordered(rels.map(&:resource))
|
|
129
|
+
call = "relations(kind: #{instance.klass.to_json}, name: #{instance.name.to_json}, verb: #{verb.to_json}, direction: #{section.direction.to_json})"
|
|
130
|
+
Group.new(verb, entries, call)
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
# Resources reached in up to `depth` steps along the section's verbs, grouped by step, nearest first
|
|
135
|
+
def deep_groups(instance, section)
|
|
136
|
+
seen = {}.compare_by_identity
|
|
137
|
+
seen[instance] = true
|
|
138
|
+
frontier = [instance]
|
|
139
|
+
(1..section.depth).filter_map do |step|
|
|
140
|
+
reached = []
|
|
141
|
+
frontier.each do |resource|
|
|
142
|
+
matching(Relations.direct(resource), section).each do |rel|
|
|
143
|
+
next if seen[rel.resource]
|
|
144
|
+
|
|
145
|
+
seen[rel.resource] = true
|
|
146
|
+
reached << rel.resource
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
frontier = reached
|
|
150
|
+
next if reached.empty?
|
|
151
|
+
|
|
152
|
+
Group.new("#{section.verbs.join("/")} (step #{step})", ordered(reached), deep_call(instance, section))
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
def deep_call(instance, section)
|
|
157
|
+
verbs = section.all_verbs? ? "" : ", verbs: #{section.verbs.to_json}"
|
|
158
|
+
"analyze_resource(kind: #{instance.klass.to_json}, name: #{instance.name.to_json}, impact: true, direction: #{section.direction.to_json}#{verbs}, depth: #{section.depth})"
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
def matching(relations, section)
|
|
162
|
+
relations.select do |rel|
|
|
163
|
+
next false unless rel.direction == section.direction
|
|
164
|
+
next false if section.all_verbs? && NOISE_KINDS.include?(rel.resource.klass)
|
|
165
|
+
|
|
166
|
+
section.all_verbs? || section.verbs.include?(rel.verb)
|
|
167
|
+
end
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
# Resources with a description first (they explain themselves), then by name: reproducible
|
|
171
|
+
def ordered(resources)
|
|
172
|
+
resources.uniq(&:object_id).sort_by { |r| [r.annotations["architecture/description"].to_s.strip.empty? ? 1 : 0, r.name] }
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
def group_line(group, per)
|
|
176
|
+
shown = group.resources.first(per)
|
|
177
|
+
total = group.resources.length
|
|
178
|
+
label = total > 1 ? "#{group.label} (#{total})" : group.label
|
|
179
|
+
line = "- #{label}: #{shown.map { |r| link(r) }.join(", ")}"
|
|
180
|
+
rest = total - shown.length
|
|
181
|
+
rest.positive? ? "#{line}, +#{rest} more: `#{group.call}`" : line
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
# Layers other than the one the lens shows that have directly related resources
|
|
185
|
+
def other_layers(instance, lens)
|
|
186
|
+
by_layer = Relations.direct(instance).map(&:resource).uniq(&:object_id).group_by { |r| r.class.layer }
|
|
187
|
+
by_layer = by_layer.reject { |layer, _| layer == lens || layer == "other" }
|
|
188
|
+
return [] if by_layer.empty?
|
|
189
|
+
|
|
190
|
+
lines = ["", "## Related in other layers"]
|
|
191
|
+
Lens::DEFAULTS.each_key do |layer|
|
|
192
|
+
resources = by_layer[layer] or next
|
|
193
|
+
kinds = resources.group_by(&:klass).sort.map { |kind, list| "#{kind} #{list.length}" }.join(", ")
|
|
194
|
+
lines << "- #{layer} (#{resources.length}): #{kinds}; `summary(kind: #{instance.klass.to_json}, name: #{instance.name.to_json}, lens: #{layer.to_json})`"
|
|
195
|
+
end
|
|
196
|
+
lines
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
def link(resource)
|
|
200
|
+
"[[#{resource.klass}/#{resource.name}]]"
|
|
201
|
+
end
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
end
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Archsight
|
|
4
|
+
module Summary
|
|
5
|
+
# What a summary follows from a resource, depending on its layer: an ordered list of sections, each one a set of
|
|
6
|
+
# relation verbs in one direction (and how many steps deep).
|
|
7
|
+
#
|
|
8
|
+
# One section per line, `<out|in> <verb>[, <verb>...] [depth=N][: <title>]`:
|
|
9
|
+
#
|
|
10
|
+
# in servedBy, realizedBy: Used by
|
|
11
|
+
# out dependsOn depth=2: Depends on
|
|
12
|
+
# in *: Referenced by
|
|
13
|
+
#
|
|
14
|
+
# `out` = the resource points at the target (it declares the relation), `in` = the target points at it; `*` = every
|
|
15
|
+
# verb. The built-in lenses below apply when the model has no Config of type `summary`; its annotation
|
|
16
|
+
# `summary/lens-<layer>` replaces the lens of that layer and `summary/lens-<Kind>` the one of a single kind (the
|
|
17
|
+
# kind wins), so lenses are tuned without a release.
|
|
18
|
+
module Lens
|
|
19
|
+
TYPE = "summary" # the `config/type` of the Config that holds the lenses
|
|
20
|
+
DEFAULT_CONFIG = "default"
|
|
21
|
+
MAX_DEPTH = 5
|
|
22
|
+
|
|
23
|
+
Section = Struct.new(:title, :direction, :verbs, :depth) do
|
|
24
|
+
def all_verbs?
|
|
25
|
+
verbs == ["*"]
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
class ParseError < StandardError; end
|
|
30
|
+
|
|
31
|
+
DEFAULTS = {
|
|
32
|
+
"motivation" => <<~LENS,
|
|
33
|
+
in hasConcern: Stakeholders
|
|
34
|
+
out representedBy: Represented by
|
|
35
|
+
in refinedBy: Refines
|
|
36
|
+
out refinedBy: Refined by
|
|
37
|
+
in realizes, partiallyRealizes, plans: Realized by
|
|
38
|
+
in satisfies, stipulates: Satisfied by
|
|
39
|
+
out mitigatedBy: Mitigated by
|
|
40
|
+
in assesses, influences: Assessed and influenced by
|
|
41
|
+
out evidencedBy: Evidence
|
|
42
|
+
out ownedBy: Owners
|
|
43
|
+
in mentions, depicts: Documented in
|
|
44
|
+
LENS
|
|
45
|
+
"strategy" => <<~LENS,
|
|
46
|
+
out realizes: Realizes
|
|
47
|
+
out servedBy: Served by
|
|
48
|
+
in hasConcern: Stakeholders
|
|
49
|
+
in realizes: Realized by
|
|
50
|
+
in mentions, depicts: Documented in
|
|
51
|
+
LENS
|
|
52
|
+
"implementation" => <<~LENS,
|
|
53
|
+
out contains: Contains
|
|
54
|
+
in contains: Part of
|
|
55
|
+
out compares: Compares
|
|
56
|
+
out closedBy: Closed by
|
|
57
|
+
in closedBy: Closes
|
|
58
|
+
out affects: Affects
|
|
59
|
+
out realizes: Realizes
|
|
60
|
+
in realizes: Realized by
|
|
61
|
+
out performedBy, ownedBy: People
|
|
62
|
+
in mentions, depicts: Documented in
|
|
63
|
+
LENS
|
|
64
|
+
"business" => <<~LENS,
|
|
65
|
+
out performedBy, ownedBy, executedBy, agreedBy: People
|
|
66
|
+
out guidedBy: Controls
|
|
67
|
+
out servedBy: Supported by
|
|
68
|
+
out exposes: Exposes
|
|
69
|
+
out aggregates, composedOf: Composed of
|
|
70
|
+
in aggregates, composedOf, compositeOf: Part of
|
|
71
|
+
out realizes, satisfies, stipulates: Requirements
|
|
72
|
+
out covers: Covers
|
|
73
|
+
out evidencedBy, provides: Evidence
|
|
74
|
+
in performedBy, ownedBy, executedBy: Responsible for
|
|
75
|
+
in maintainedBy, operatedBy, contributedBy: Maintains and operates
|
|
76
|
+
in mentions, depicts: Documented in
|
|
77
|
+
LENS
|
|
78
|
+
"application" => <<~LENS,
|
|
79
|
+
out exposes: Interfaces
|
|
80
|
+
out realizedThrough, realizedBy: Realized through
|
|
81
|
+
in realizedThrough, realizedBy: Realizes
|
|
82
|
+
out servedBy, provisions: Runs on
|
|
83
|
+
out dependsOn: Depends on
|
|
84
|
+
in dependsOn: Used by
|
|
85
|
+
in serves: Serves
|
|
86
|
+
out maintainedBy, operatedBy: Owners
|
|
87
|
+
out realizes, partiallyRealizes, plans: Requirements
|
|
88
|
+
out evidencedBy: Evidence
|
|
89
|
+
in servedBy: Served
|
|
90
|
+
in exposes: Exposed by
|
|
91
|
+
in mentions, depicts: Documented in
|
|
92
|
+
LENS
|
|
93
|
+
"technology" => <<~LENS,
|
|
94
|
+
out servedBy, realizedBy, suppliedBy, realizedThrough: Built on
|
|
95
|
+
in servedBy, realizedBy, suppliedBy, assignedTo: Runs on it
|
|
96
|
+
out composedOf, aggregates: Composed of
|
|
97
|
+
in composedOf, aggregates: Part of
|
|
98
|
+
out locatedAt: Located at
|
|
99
|
+
out connectedTo, connects: Connected to
|
|
100
|
+
out maintainedBy, operatedBy, ownedBy, contributedBy: Owners
|
|
101
|
+
out realizes, partiallyRealizes, plans: Requirements
|
|
102
|
+
out evidencedBy: Evidence
|
|
103
|
+
in mentions, depicts: Documented in
|
|
104
|
+
LENS
|
|
105
|
+
"other" => <<~LENS
|
|
106
|
+
out *: Points at
|
|
107
|
+
in *: Referenced by
|
|
108
|
+
in mentions, depicts: Documented in
|
|
109
|
+
LENS
|
|
110
|
+
}.freeze
|
|
111
|
+
|
|
112
|
+
# Kinds whose layer lens is too coarse; looked up before the lens of the layer
|
|
113
|
+
KIND_DEFAULTS = {
|
|
114
|
+
"BusinessActor" => <<~LENS,
|
|
115
|
+
in performedBy, executedBy: Performs
|
|
116
|
+
in ownedBy: Owns
|
|
117
|
+
in maintainedBy, operatedBy, contributedBy: Maintains and operates
|
|
118
|
+
out compositeOf: Composed of
|
|
119
|
+
in compositeOf: Part of
|
|
120
|
+
in representedBy: Represented as stakeholder
|
|
121
|
+
in agreedBy: Contracts
|
|
122
|
+
in servedBy: Serves
|
|
123
|
+
in mentions, depicts: Documented in
|
|
124
|
+
LENS
|
|
125
|
+
"ApplicationService" => <<~LENS,
|
|
126
|
+
out realizedThrough: Realized through
|
|
127
|
+
out dependsOn: Depends on
|
|
128
|
+
in dependsOn: Used by
|
|
129
|
+
in servedBy: Serves
|
|
130
|
+
out maintainedBy: Owners
|
|
131
|
+
out realizes, partiallyRealizes, plans: Requirements
|
|
132
|
+
out evidencedBy: Evidence
|
|
133
|
+
in mentions, depicts: Documented in
|
|
134
|
+
LENS
|
|
135
|
+
"MotivationAssessment" => <<~LENS
|
|
136
|
+
out assesses: Assesses
|
|
137
|
+
out influences: Influences
|
|
138
|
+
out mitigatedBy: Mitigated by
|
|
139
|
+
out ownedBy: Owners
|
|
140
|
+
in mentions, depicts: Documented in
|
|
141
|
+
LENS
|
|
142
|
+
}.freeze
|
|
143
|
+
|
|
144
|
+
class << self
|
|
145
|
+
# The sections for a resource of `kind` in `layer`, from the first of: the `summary/lens-<Kind>` and then the
|
|
146
|
+
# `summary/lens-<layer>` of the Config named `default` of type summary (or the first of that type), the built-in
|
|
147
|
+
# lens of the kind, the built-in lens of the layer
|
|
148
|
+
def for(database, layer, kind: nil)
|
|
149
|
+
candidates = [configured(database, kind), configured(database, layer), KIND_DEFAULTS[kind], DEFAULTS[layer]]
|
|
150
|
+
candidates.compact.each do |text|
|
|
151
|
+
return parse(text)
|
|
152
|
+
rescue ParseError
|
|
153
|
+
next # a bad Config (the linter reports it) must not break the summary: the next candidate is used
|
|
154
|
+
end
|
|
155
|
+
parse(DEFAULTS["other"])
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
# nil when `suffix` of a `summary/lens-<suffix>` key is a layer or a kind, else the message
|
|
159
|
+
def key_error(suffix)
|
|
160
|
+
return nil if Archsight::Resources::LAYERS.include?(suffix) || Archsight::Resources[suffix]
|
|
161
|
+
|
|
162
|
+
"expected a layer (#{Archsight::Resources::LAYERS.join(", ")}) or a kind, not #{suffix}"
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
# Sections of lens text; raises ParseError naming the line
|
|
166
|
+
def parse(text)
|
|
167
|
+
text.to_s.lines.map.with_index(1) { |line, number| [line.strip, number] }.reject { |line, _| line.empty? || line.start_with?("#") }.map do |line, number|
|
|
168
|
+
parse_line(line)
|
|
169
|
+
rescue ParseError => e
|
|
170
|
+
raise ParseError, "line #{number} (#{line}): #{e.message}"
|
|
171
|
+
end
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
# nil when the text is a valid lens, else the message (the validator of the Config annotation)
|
|
175
|
+
def parse_error(text)
|
|
176
|
+
sections = parse(text)
|
|
177
|
+
sections.empty? ? "expected at least one line like `in servedBy: Used by`" : nil
|
|
178
|
+
rescue ParseError => e
|
|
179
|
+
e.message
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
def known_verbs
|
|
183
|
+
@known_verbs ||= Archsight::Resources.constants.filter_map do |name|
|
|
184
|
+
klass = Archsight::Resources.const_get(name)
|
|
185
|
+
klass.relations.map { |verb, _, _| verb.to_s } if klass.is_a?(Class) && klass < Archsight::Resources::Base
|
|
186
|
+
end.flatten.uniq.sort
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
private
|
|
190
|
+
|
|
191
|
+
def configured(database, key)
|
|
192
|
+
return nil unless key
|
|
193
|
+
|
|
194
|
+
configs = database.instances_by_kind("Config").values.select { |c| c.annotations["config/type"].to_s.casecmp?(TYPE) }
|
|
195
|
+
config = configs.find { |c| c.name == DEFAULT_CONFIG } || configs.first
|
|
196
|
+
text = config&.annotations&.[]("summary/lens-#{key}").to_s
|
|
197
|
+
text.strip.empty? ? nil : text
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
def parse_line(line)
|
|
201
|
+
spec, title = line.split(":", 2).map(&:strip)
|
|
202
|
+
direction, rest = spec.split(/\s+/, 2)
|
|
203
|
+
raise ParseError, "expected `out` or `in` first" unless %w[out in].include?(direction)
|
|
204
|
+
|
|
205
|
+
depth = 1
|
|
206
|
+
words = rest.to_s.split(/[,\s]+/).reject(&:empty?).reject do |word|
|
|
207
|
+
next false unless (m = word.match(/\Adepth=(\d+)\z/))
|
|
208
|
+
|
|
209
|
+
depth = m[1].to_i
|
|
210
|
+
true
|
|
211
|
+
end
|
|
212
|
+
raise ParseError, "expected at least one verb" if words.empty?
|
|
213
|
+
raise ParseError, "depth must be 1 to #{MAX_DEPTH}" unless depth.between?(1, MAX_DEPTH)
|
|
214
|
+
|
|
215
|
+
verbs = words.include?("*") ? ["*"] : words
|
|
216
|
+
unknown = verbs - ["*"] - known_verbs
|
|
217
|
+
raise ParseError, "unknown verb #{unknown.join(", ")}" unless unknown.empty?
|
|
218
|
+
|
|
219
|
+
Section.new(title.to_s.empty? ? "#{direction} #{verbs.join(", ")}" : title, direction, verbs, depth)
|
|
220
|
+
end
|
|
221
|
+
end
|
|
222
|
+
end
|
|
223
|
+
end
|
|
224
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "summary/lens"
|
|
4
|
+
require_relative "summary/builder"
|
|
5
|
+
|
|
6
|
+
module Archsight
|
|
7
|
+
# A short, structured explanation of a resource in context: what it is and how it fits in, assembled from the model
|
|
8
|
+
# only. See Archsight::Summary::Lens for what is followed per layer and Archsight::MCP::SummaryTool for the entry point.
|
|
9
|
+
module Summary
|
|
10
|
+
end
|
|
11
|
+
end
|
data/lib/archsight/version.rb
CHANGED
|
@@ -313,6 +313,10 @@ paths:
|
|
|
313
313
|
tags:
|
|
314
314
|
- howto
|
|
315
315
|
- wiki
|
|
316
|
+
reading:
|
|
317
|
+
minutes: 2
|
|
318
|
+
words: 310
|
|
319
|
+
diagrams: 1
|
|
316
320
|
toc:
|
|
317
321
|
- level: 2
|
|
318
322
|
id: create-a-page
|
|
@@ -2289,7 +2293,7 @@ components:
|
|
|
2289
2293
|
|
|
2290
2294
|
PageResponse:
|
|
2291
2295
|
type: object
|
|
2292
|
-
required: [name, title, status, author, owner, created, updated, properties, links, tags, slides, toc, breadcrumb, html, backlinks]
|
|
2296
|
+
required: [name, title, status, author, owner, created, updated, properties, links, tags, slides, reading, toc, breadcrumb, html, backlinks]
|
|
2293
2297
|
properties:
|
|
2294
2298
|
name:
|
|
2295
2299
|
type: string
|
|
@@ -2344,6 +2348,21 @@ components:
|
|
|
2344
2348
|
- $ref: '#/components/schemas/PageSlides'
|
|
2345
2349
|
- type: 'null'
|
|
2346
2350
|
description: The slide deck of the page, null if it has none or the file cannot be served
|
|
2351
|
+
reading:
|
|
2352
|
+
type: object
|
|
2353
|
+
description: Estimated reading time of the body, its words plus its `asd` diagrams (more nodes and edges take longer)
|
|
2354
|
+
required: [minutes, words, diagrams]
|
|
2355
|
+
properties:
|
|
2356
|
+
minutes:
|
|
2357
|
+
type: integer
|
|
2358
|
+
minimum: 1
|
|
2359
|
+
description: Rounded up, at least 1
|
|
2360
|
+
words:
|
|
2361
|
+
type: integer
|
|
2362
|
+
description: Words of the text (code blocks and diagram sources not included)
|
|
2363
|
+
diagrams:
|
|
2364
|
+
type: integer
|
|
2365
|
+
description: Number of `asd` diagrams (fenced blocks and embedded `.asd` files)
|
|
2347
2366
|
toc:
|
|
2348
2367
|
type: array
|
|
2349
2368
|
description: Headings of the body; empty unless the frontmatter has `toc` `yes`
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require_relative "../../page_tree"
|
|
4
4
|
require_relative "../../slides"
|
|
5
|
+
require_relative "../../reading_time"
|
|
5
6
|
|
|
6
7
|
module Archsight; end
|
|
7
8
|
module Archsight::Web; end
|
|
@@ -33,6 +34,7 @@ module Archsight::Web::API::PageHelpers
|
|
|
33
34
|
annotations = page.annotations
|
|
34
35
|
body = strip_duplicate_title(annotations["page/content"].to_s, page)
|
|
35
36
|
tree = Archsight::PageTree.new(db)
|
|
37
|
+
base = Archsight::Assets.base_dir_for(page, resources_dir: Archsight.resources_dir)
|
|
36
38
|
{
|
|
37
39
|
name: page.name,
|
|
38
40
|
title: page.title,
|
|
@@ -45,9 +47,11 @@ module Archsight::Web::API::PageHelpers
|
|
|
45
47
|
links: annotations.select { |key, _| key.start_with?("link/") }.transform_keys { |key| key.delete_prefix("link/") },
|
|
46
48
|
tags: Archsight::Resources::Page.annotation_matching("page/tags")&.value_for(page) || [],
|
|
47
49
|
slides: Archsight::Slides.for_page(page),
|
|
50
|
+
reading: Archsight::ReadingTime.estimate(body, base_dir: base, resources_dir: Archsight.resources_dir,
|
|
51
|
+
includes: Archsight::Helpers::DiagramIncludes.for(db)),
|
|
48
52
|
toc: annotations["page/toc"] == "yes" ? Archsight::PageTree.toc(body) : [],
|
|
49
53
|
breadcrumb: tree.breadcrumb(page),
|
|
50
|
-
html: markdown(body, base:
|
|
54
|
+
html: markdown(body, base: base, page: page),
|
|
51
55
|
backlinks: page_backlinks(page)
|
|
52
56
|
}
|
|
53
57
|
end
|
|
@@ -92,6 +92,8 @@ class Archsight::Web::Application < Sinatra::Base
|
|
|
92
92
|
|
|
93
93
|
mcp_server.register_tool(Archsight::MCP::QueryTool)
|
|
94
94
|
mcp_server.register_tool(Archsight::MCP::AnalyzeResourceTool)
|
|
95
|
+
mcp_server.register_tool(Archsight::MCP::SummaryTool)
|
|
96
|
+
mcp_server.register_tool(Archsight::MCP::RelationsTool)
|
|
95
97
|
mcp_server.register_tool(Archsight::MCP::ResourceDocTool)
|
|
96
98
|
mcp_server.register_tool(Archsight::MCP::ExecuteAnalysisTool)
|
|
97
99
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{B as e,L as t,R as n,X as r,it as i,p as a,t as o,tt as s}from"./index-
|
|
1
|
+
import{B as e,L as t,R as n,X as r,it as i,p as a,t as o,tt as s}from"./index-JZkWwfYg.js";import{t as c}from"./WikiPage-DSEL2gmd.js";var l={key:1},u={__name:`DocPage`,props:{filename:String},setup(u){let d=u,f=i(null);function p(e,t){let n=new DOMParser().parseFromString(e,`text/html`).body,r=n.querySelector(`:scope > article`)||n,i=r.querySelector(`h1`),a=i?.textContent.trim()||t.split(`/`).pop().replace(/[-_]/g,` `);i?.remove();let o=[...r.querySelectorAll(`h2[id], h3[id], h4[id]`)].map(e=>({level:Number(e.tagName[1]),id:e.id,text:e.textContent.trim()})),s=[{title:`Documentation`}];return t.startsWith(`resources/`)&&s.push({title:`Resource types`}),{title:a,html:r.innerHTML,toc:o.length>=2?o:[],breadcrumb:s}}async function m(){let e=await a(d.filename);f.value=e?p(e,d.filename):{title:`Not found`,html:`<p>Documentation not found.</p>`,toc:[],breadcrumb:[{title:`Documentation`}]},o(f.value.title)}return s(()=>d.filename,m,{immediate:!0}),(i,a)=>f.value?(r(),n(c,{key:0,title:f.value.title,html:f.value.html,breadcrumb:f.value.breadcrumb,toc:f.value.toc},null,8,[`title`,`html`,`breadcrumb`,`toc`])):(r(),e(`article`,l,[...a[0]||=[t(`p`,null,`Loading...`,-1)]]))}};export{u as default};
|