@rt-tools/agent-kit 0.36.0 → 0.37.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.
@@ -28,6 +28,8 @@ sections through the override; they merge here by heading, and a package edit do
28
28
  - **Layout** — the transfer of a resource from the package into the tree, by its kind and by the layer settings
29
29
  - **Laid-out file** — a file in the tree with the package header. Edited through the override, not in place: an in-place edit is lost on the next layout
30
30
  - **Override** — a file of the tree that merges with the laid-out file by section headings
31
+ - **Trait** — what a tree has: a storage, an admin, an application, a code graph. Named in a list in the tree settings; a resource that needs a trait is laid out only to a tree that named it
32
+ - **Code graph** — a build artefact next to the tree: which file calls, imports and contains what. Answers relations, not numbers or behaviour; it is fresh when it was built from the head
31
33
  - **Disabled role** — a role whose call the tree no longer treats as mandatory: the guard stays silent about it. Named in a list in the tree settings, not removed from the layout, and called by hand
32
34
  - **Observation** — a line about an event of the rules layer: a rule was loaded, a gate refused, a guard declined. Written by a guard, lives in the tree, leaves as counters. Not called a log
33
35
  - **Digest** — what the observations say over a span of days: what was used, what never was, what people stumbled on
@@ -0,0 +1,94 @@
1
+ ---
2
+ name: task-flow-graph
3
+ kind: pattern
4
+ rule: task-flow
5
+ description: Pattern of rule task-flow. Load when the tree holds a code graph and a domain is explored or a shared symbol is about to be edited. Not for a claim about behaviour, a number or a rule text — those are read from the code and the documents.
6
+ ---
7
+
8
+ # Working with the tree's code graph
9
+
10
+ Pattern of the rule `task-flow`. What must be true meanwhile — the law
11
+ `docs/constitution/work-conduct.md`.
12
+
13
+ The graph is a build artefact of the tool `graphify`: it lies next to the tree and is rebuilt from
14
+ the code. It answers relations, not behaviour. The tool is not part of the package, and the pattern
15
+ is laid out only to a tree that names the trait `graph`. A copy that names the trait and has no
16
+ artefact on disk — a fresh clone, a new working tree — builds it by `graphify update .` before the
17
+ first exploration of the turn, or the turn names that there is no graph, and none of the steps below
18
+ applies.
19
+
20
+ ## When to use
21
+
22
+ - The first exploration of a domain in a turn, before reading files one by one.
23
+ - Before an edit of a shared symbol: who calls, imports or re-exports it.
24
+ - A question of the shape of the tree: which files belong to a domain, where the procedures of a
25
+ service lie.
26
+
27
+ ## Freshness
28
+
29
+ The build records the commit it was made from. It is compared with the head in every turn, before
30
+ the first exploration:
31
+
32
+ ```bash
33
+ python3 -c "import json;print(json.load(open('graphify-out/graph.json'))['built_at_commit'])"
34
+ git rev-parse HEAD
35
+ ```
36
+
37
+ Equal — the graph describes the head. Behind — the graph is stale, and the difference is read before
38
+ anything else: it names the files whose relations the graph no longer knows.
39
+
40
+ ```bash
41
+ git log --oneline --stat <built_at_commit>..HEAD
42
+ ```
43
+
44
+ A rebuild re-extracts code files and calls no model:
45
+
46
+ ```bash
47
+ graphify update .
48
+ ```
49
+
50
+ A stale graph not rebuilt is not a source: the turn names why it was not rebuilt, and no answer
51
+ cites it. A turn where the graph exists and was not used names one of two reasons: the answer is
52
+ about behaviour, numbers or texts, or the graph is stale and was not rebuilt.
53
+
54
+ ## The inventory
55
+
56
+ Nodes carry the file they came from. Listing them shows a domain whole: files, classes, procedures,
57
+ functions.
58
+
59
+ ```bash
60
+ python3 -c "import json,collections;g=json.load(open('graphify-out/graph.json'));c=collections.Counter(n.get('source_file','') for n in g['nodes'] if '<domain>' in n.get('source_file',''));print('\n'.join(f'{v:5d} {k}' for k,v in c.most_common()))"
61
+ ```
62
+
63
+ ## The relations
64
+
65
+ ```bash
66
+ graphify explain "<node>" # a node and its neighbours
67
+ graphify affected "<symbol>" --depth 2 # who depends on it, reverse traversal
68
+ graphify path "<caller>" "<callee>" # the chain between two nodes
69
+ ```
70
+
71
+ A node is named by a file name or a symbol, not by a path: `board.mjs` is found, `tools/board.mjs`
72
+ is not. `explain` answers with `imports`, `imports_from`, `calls`, `contains` and `re_exports`;
73
+ `affected` is the reverse traversal an edit of a shared symbol needs.
74
+
75
+ ## What the graph never answers
76
+
77
+ - A constant, a limit, a number: values are not nodes.
78
+ - The body of an `async function*`: the extraction may leave it out, and a function absent from the
79
+ graph is not absent from the code.
80
+ - A template, a style sheet, a generated file: often outside the extraction.
81
+ - The meaning of a document: document nodes are headings, not the text under them.
82
+ - A permission or an enum value: names are nodes, strings are not.
83
+
84
+ ## Common misses
85
+
86
+ - **A free-text query looks like the entry point and is not.** `graphify query` walks breadth-first
87
+ over the words of the question and starts from whatever token it matched: it answers with
88
+ neighbours of a word, not with the domain. `explain` is asked by a file name or a symbol.
89
+ - **A barrel file distorts a path.** `index.ts` nodes stand between a caller and a callee, and
90
+ `graphify path` returns a chain through re-exports that no reader would walk. `affected` on the
91
+ symbol is used instead, and the relations are read.
92
+ - **A rebuild after deleted code keeps the old graph.** `graphify update` does not overwrite
93
+ `graph.json` when the rebuild has fewer nodes, and `built_at_commit` stays old: after an edit that
94
+ removes code it is run with `--force`, and the commit is compared again.
@@ -232,6 +232,11 @@ flowchart TD
232
232
  - **A mission is set by the owner.** A session only proposes a wording from its analysis and waits
233
233
  for approval.
234
234
  - **Building by a sample begins with reading the sample itself, whole, by walking the directories.**
235
+ - **Exploration of a tree that holds a code graph begins with the graph.** A tree with a graph names
236
+ the trait `graph` in its settings and follows the pattern `task-flow-graph`: in every turn the
237
+ graph is checked against the head before the first exploration, and a turn that does not use it
238
+ names the reason. Relations are taken from the graph; numbers, behaviour and texts — from the code
239
+ and the documents.
235
240
  - **What acts on the tree, not on the edit, lies outside the index.** The path to the sample and the
236
241
  permission to work outside the epic do not belong to the branch and live next to the handover. A
237
242
  number in the permitted list repeats the owner's word, not replaces it.
@@ -294,3 +299,5 @@ nothing counts; it is held by reading both texts in a row on every such edit.
294
299
  - `task-flow-close` — lifting the draft, merging the agreement, bringing the texts up to date.
295
300
  - `task-flow-archive` — taking the task folder apart, the move to the archive, review by the rules.
296
301
  - `task-flow-cycle` — an edit chosen by the report and judged by the next one.
302
+ - `task-flow-graph` — where the tree names the trait `graph`: the freshness check, the domain inventory and
303
+ what the graph never answers.
@@ -13,5 +13,8 @@
13
13
  },
14
14
  "mockups": {
15
15
  "title": "макеты: рисунки экранов в дизайн-инструменте до кода"
16
+ },
17
+ "graph": {
18
+ "title": "граф кода: построенная карта вызовов и импортов дерева рядом с ним"
16
19
  }
17
20
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rt-tools/agent-kit",
3
- "version": "0.36.0",
3
+ "version": "0.37.0",
4
4
  "description": "Переносимый слой правил для агента: законы, хуки, проверки и агенты, раскладываемые в репозиторий одной командой",
5
5
  "author": "RT Team",
6
6
  "license": "Apache-2.0",