@imunitic/synapse 0.4.6 → 0.5.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@imunitic/synapse",
3
- "version": "0.4.6",
3
+ "version": "0.5.0",
4
4
  "description": "Memory for Claude Code, Codex CLI, and OpenCode: a durable markdown vault plus a per-repo code graph.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -23,9 +23,9 @@
23
23
  "*.conf.template"
24
24
  ],
25
25
  "optionalDependencies": {
26
- "@imunitic/synapse-darwin-arm64": "0.4.6",
27
- "@imunitic/synapse-linux-x64": "0.4.6",
28
- "@imunitic/synapse-linux-arm64": "0.4.6"
26
+ "@imunitic/synapse-darwin-arm64": "0.5.0",
27
+ "@imunitic/synapse-linux-x64": "0.5.0",
28
+ "@imunitic/synapse-linux-arm64": "0.5.0"
29
29
  },
30
30
  "license": "SEE LICENSE IN LICENSE"
31
31
  }
@@ -0,0 +1,96 @@
1
+ # Declared keys are the full v1 spec; enforcement is a deliberate subset -- unknown note fields are ignored, never an error.
2
+ # `sources` is declared last on purpose: `field_order: relative` requires every other declared
3
+ # field to sit ahead of it in the actual file, so a small, frequently-looked-up scalar is never
4
+ # behind a `sources:` block that can run to hundreds of `path`/`hash` pairs on a large repo.
5
+ schema: synapse-note-schema/v1
6
+ id: graph-node/v1
7
+
8
+ frontmatter:
9
+ field_order: relative
10
+ fields:
11
+ schema:
12
+ type: string
13
+ required: true
14
+ const: graph-node/v1
15
+ title:
16
+ type: string
17
+ required: true
18
+ min_length: 1
19
+ summary:
20
+ type: string
21
+ required: true
22
+ min_length: 1
23
+ node_type:
24
+ type: string
25
+ required: true
26
+ const: synapse-node
27
+ project:
28
+ type: string
29
+ required: true
30
+ min_length: 1
31
+ branch:
32
+ type: string
33
+ required: true
34
+ min_length: 1
35
+ sources_digest:
36
+ type: string
37
+ required: true
38
+ pattern: '^[0-9a-f]{64}$'
39
+ stale:
40
+ type: boolean
41
+ required: true
42
+ built_at:
43
+ type: string
44
+ required: true
45
+ pattern: '^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$'
46
+ commit:
47
+ type: string
48
+ required: false
49
+ crux_path:
50
+ type: string
51
+ required: false
52
+ crux_lines:
53
+ type: string
54
+ required: false
55
+ grounded_in:
56
+ type: any
57
+ required: false
58
+ sources:
59
+ type: any
60
+ required: true
61
+
62
+ body:
63
+ h1:
64
+ required: true
65
+ count: 1
66
+ equals: frontmatter.title
67
+ # Crux and Links are `synapse-node-format`'s documented convention for every
68
+ # authored node, but nothing has ever structurally required either heading
69
+ # to exist -- `write-node`'s own crux/grounded_in extraction is scoped to
70
+ # `## Crux` only when present, never required. Required here would be a new
71
+ # constraint this schema doesn't need to introduce to do its actual job
72
+ # (field order, schema identity); Summary/Sources/Notes are required because
73
+ # `write-node` always emits all three unconditionally today, so requiring
74
+ # them adds no new constraint at all.
75
+ sections:
76
+ - title: Summary
77
+ level: 2
78
+ required: true
79
+ non_empty: true
80
+ - title: Crux
81
+ level: 2
82
+ required: false
83
+ non_empty: true
84
+ - title: Links
85
+ level: 2
86
+ required: false
87
+ - title: Sources
88
+ level: 2
89
+ required: true
90
+ non_empty: true
91
+ - title: Notes
92
+ level: 2
93
+ required: true
94
+ section_order: relative
95
+
96
+ checks: []
@@ -55,7 +55,11 @@ to orient someone already inside. A node without one is an error, not a default.
55
55
  finds its node via this list). Do **not** trim it to a handful of "representative" files —
56
56
  doing so silently destroys that lookup, leaves the node unable to answer "which files am I
57
57
  about", and reduces hash verification to whatever survived the trim. Readability pressure
58
- belongs on `## Sources` below, never here.
58
+ belongs on `## Sources` below, never here. Always the *last* frontmatter field — on a large
59
+ project it can run to hundreds of `path`/`hash` pairs, and every other field stays ahead of it so
60
+ a single-key lookup never has to scan past it. `graph-node/v1`'s schema enforces this order
61
+ directly (`field_order: relative`); this document and `synapse write-node`'s own emission order
62
+ agree with it, not the other way around.
59
63
  - **`sources_digest`:** `sha256` over the sorted `path:hash` lines of `sources` (see "Computing
60
64
  `sources_digest`" below). Lets a staleness check answer "has this node changed" by reading one
61
65
  field instead of every hash.
@@ -149,18 +153,19 @@ to orient someone already inside. A node without one is an error, not a default.
149
153
 
150
154
  ```yaml
151
155
  ---
156
+ schema: graph-node/v1
152
157
  title: "World — entity/component/resource core"
153
158
  node_type: synapse-node
154
159
  project: acme
160
+ sources_digest: <sha256 over the sorted "path:hash" lines>
161
+ stale: false
162
+ built_at: "<now>"
155
163
  sources:
156
164
  - path: acme_ecs/world.ml
157
165
  hash: <git hash-object output>
158
166
  - path: acme_ecs/world.mli
159
167
  hash: <git hash-object output>
160
168
  # ... every file the node covers, not a selection
161
- sources_digest: <sha256 over the sorted "path:hash" lines>
162
- stale: false
163
- built_at: "<now>"
164
169
  ---
165
170
 
166
171
  # World — entity/component/resource core
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: synapse-query
3
- description: This repo has a Synapse code graph. For ANY task here — understanding how something works, finding where code lives, tracing what depends on a file, or scoping an edit — consult synapse/{project}/Index.md and synapse query before grepping or reading source files. Grep only after Synapse has named the exact file(s) to read.
3
+ description: This repo has a Synapse code graph. For ANY task here — understanding how something works, finding where code lives, tracing what depends on a file, or scoping an edit — consult synapse/{project}/Index.md and synapse query before grepping or reading source files. Grep only after Synapse has named the exact file(s) to read. Also applies when this repo has no graph of its own but the task concerns another checkout that does — synapse query --namespace <repo>@<branch> reaches that graph without switching directories.
4
4
  ---
5
5
 
6
6
  # Synapse Query: Day-to-Day Use of the Code Graph
@@ -56,6 +56,7 @@ required:
56
56
  | A node's prose, without its (possibly huge) `sources` list | `synapse query body "{Node}"` | Disk read, never the API; skips frontmatter and `## Notes`. See the cost note above. |
57
57
  | Every file a node covers | `synapse query sources "{Node}" [--count\|--modules\|--filter <p>]` | Filtered/counted/grouped, never the raw megabyte-scale list. |
58
58
  | Is this node's understanding still accurate? | `synapse query stale` / `drift` / `grounding` | Hand off to the `synapse-node` skill's procedure — this skill doesn't re-explain that. |
59
+ | A node in a *different* checkout's graph, from a repo with no namespace of its own (or the wrong one) | `synapse query --namespace <repo>@<branch> body "{Node}"` (any subcommand takes it) | Names the target namespace directly instead of deriving it from cwd. `stale`/`drift`/`grounding`/`symbol` still need that checkout's real files on disk and refuse without `SYNAPSE_REPO_ROOT` set to it — `body`/`sources`/`field`/`links` don't. |
59
60
 
60
61
  ## Usage scenarios
61
62
 
@@ -87,12 +88,17 @@ resolve the specific symbol-level question:
87
88
  ## Guardrails
88
89
 
89
90
  - **Never grep the whole repo before checking `synapse/{project}/Index.md`**, unless this repo has
90
- no Synapse namespace at all (`vault_list` on `synapse/{project}/` comes back empty — in that case
91
- there's nothing to consult, say so and proceed normally).
91
+ no Synapse namespace at all (`vault_list` on `synapse/{project}/` comes back empty). Before
92
+ concluding there's nothing to consult, check whether the task actually concerns a *different*
93
+ checkout — `synapse query --namespace <repo>@<branch> body "{Node}"` reaches that repo's graph
94
+ without switching directories or checking it out. Only when no namespace anywhere covers the task
95
+ is there truly nothing to consult; say so and proceed normally.
92
96
  - **Never treat a node's summary as ground truth for a symbol-level claim** it wasn't built to make
93
97
  precisely — see "When a node isn't enough" above.
94
- - **Never `vault_read` a node just to read its prose.** That pulls the full frontmatter, which can
95
- run to megabytes on a hub node. Use `synapse query body` (see the cost note above).
98
+ - **Never `vault_read` a node just to read its prose — including a node in another checkout's
99
+ namespace.** That pulls the full frontmatter, which can run to megabytes on a hub node. Use
100
+ `synapse query body` (add `--namespace <repo>@<branch>` for a graph outside this checkout) — see
101
+ the cost note above.
96
102
  - **Never reason about a node's staleness inline in this skill.** Hand off to `synapse-node`'s
97
103
  procedure — that's its job, not this skill's.
98
104
  - **Never treat `synapse query`'s exit 1 as "clean."** It means the check could not run (no
@@ -30,7 +30,7 @@ Search before you answer when the question is about:
30
30
  synapse vault-search-text <query> full-text, relevance-ranked, with match context
31
31
  synapse vault-search --fields <f1,f2,...> JsonLogic over frontmatter, tags, content, path globs
32
32
  synapse vault-list when you already know roughly where it is
33
- synapse vault-read <path> the whole note -- no partial/targeted read exists
33
+ synapse vault-read <path> the whole note -- no partial/targeted read, except one path shape below
34
34
  ```
35
35
 
36
36
  `vault-search`'s JsonLogic filter and `--fields` projection both stop at frontmatter/tags/content/
@@ -39,6 +39,13 @@ exists yet), and `vault-read` always returns the full body, never one section on
39
39
  exactly what you need with `--fields` instead of over-fetching, and pull a specific section out of
40
40
  `vault-read`'s output locally when that's all you actually need.
41
41
 
42
+ **The one exception is a `synapse/{project}/*.md` code-graph node.** `vault-read` on one of those
43
+ returns the same whole-note body as any other path — frontmatter included, which on a hub node can
44
+ run to megabytes just to reach a few hundred words of prose. `synapse query body <node>` (add
45
+ `--namespace <repo>@<branch>` to reach a different checkout's graph) is the targeted read for that
46
+ one path shape: prose only, no frontmatter. Reach for it instead of `vault-read` for anything under
47
+ `synapse/` — see the `synapse-query` skill for the rest of its subcommands.
48
+
42
49
  A search that returns nothing is a real result and worth one line in the note you then write —
43
50
  a negative result cannot be rediscovered by searching for it.
44
51